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

Dale Johannesen dalej at apple.com
Tue Jul 15 10:40:44 PDT 2008


On Jul 15, 2008, at 12:39 AMPDT, Duncan Sands wrote:
>
>> +    // For ObjC2, we may have a base class field that should not  
>> be taken into
>> +    // account here, as it is already in Offset.  The ObjC FE  
>> figures this out.
>> +    tree field_bit_offset = objc_v2_bitfield_ivar_bitpos(exp);
>> +    if (field_bit_offset) {
>> +      BitStart = (unsigned)getINTEGER_CSTVal(field_bit_offset);
>> +    }
>>     // Here BitStart gives the offset of the field in bits from  
>> field_offset.
>>     // Incorporate as much of it as possible into the pointer  
>> computation.
>>     unsigned ByteOffset = BitStart/8;
>
> I didn't understand from your description what is going on here.   
> Can you
> please explain some more.

I'll try.  Bitfields are referenced by an offset in bytes relative to  
the beginning of the
object, + an offset in bits relative to the byte offset.  In ObjC V2  
the byte offset
can change at runtime, so is loaded from memory rather than computed  
at compile
time.  The value loaded from memory includes the value you would  
normally get
at compile time, so you don't want to add that in twice.  There is  
analogous code
in non-llvm-gcc's get_inner_reference.
(The comment about a base class is wrong, I'll fix that.)




More information about the llvm-commits mailing list