[llvm-commits] [llvm-gcc-4.2] r69795 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Chris Lattner clattner at apple.com
Thu Apr 23 10:11:00 PDT 2009


On Apr 23, 2009, at 1:03 AM, Duncan Sands wrote:
> Hi Chris,
>
>> Thanks for doing this.  Do you have a testcase?
>
> I only have an Ada testcase, and since you can't even build
> the Ada front-end without this fix it seemed rather pointless
> to add it to the testsuite.

Ok :)

>> Is this right on big-endian systems?
>
> I think so but I'm not sure.

You can get a reasonable amount of testing by just taking the reduced  
testcase (which just contains the global) and compiling it with a PPC- 
targetting "cc1".  It is reasonably fast to build a GCC and llvm-gcc  
cross to PPC if you don't care about anything other than cc1.  With  
that, you can just compare the .byte output from each compiler.


> By the way, isn't this just the same as how C stores an
> integer to a bitfield?  Suppose you have
>  int x : 2;
> Then when you write a value to x, what happens?

The behavior that I'm seeing is that convert to constant returns an  
"i2" value.  I assume this is because C is using TREE_PRECISION  
differently than ada?

> The
> value is truncated down to 2 bits and those bits are
> stored.  In the record constructor, each field of the
> constructor is being assigned to the corresponding
> bitfield.  So it seems reasonable to me to say that
> integers get truncated down to the size of the bitfield
> before being stored.  It's not that I like it, but it is
> consistent with C bitfield assignment.


Sure, makes sense.

-Chris



More information about the llvm-commits mailing list