RFC: gfc_simplify_transfer implementation.

Brooks Moses brooks.moses@codesourcery.com
Wed Mar 28 18:38:00 GMT 2007


François-Xavier Coudert wrote:
>>> - create a constant tree from the constant value
>>> - fold_convert the value into the other type of similar length
>>> - read back the value from the constant tree
>> This is how I thought to do this in the first place.  However, you
>> right away run into problems with arrays.
> 
> Arrays will be transferred element after element, no? I must be
> missing something very basic, because I don't understand what can be a
> problem with arrays.

Indeed, that would be how I would be expecting it to work, and it works 
well enough in the host-memory implementation.  The slight complication 
is that we need to convert to a memory buffer and back (requiring 
fold_convert-ish things twice) to handle partly-overlapping elements, 
but that's not a big deal and I know how to handle it.  As Paola Bonzini 
(and now Richard Henderson) have pointed out, there's an implementation 
of something much like this in fold-const.c's native_encode_expr and 
native_interpret_expr which does a lot of this.

At present, my implementation plans are to hack fold-const.c slightly to 
make those two functions non-static, and then call them from the new 
export_integer/real and import_integer/real functions.  Paul, if you 
have a look at fold-const.c, you'll see that it _is_ reasonably beyond 
our wit to get the numerics right -- just for integer and floats, it's 
about 100 lines of code, and in the floating-point cases that's just 
setting up a byte array to pass to a back-end hook for interpretation. 
We could copy all of it, but I don't want to be maintaining it!  :)

I'm not going to have a chance to work on this before the middle of next 
week, but I'll get to it as soon as I can.  Thanks to everyone for the 
comments and suggestions!

- Brooks



More information about the Gcc-patches mailing list