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

Duncan Sands baldrick at free.fr
Tue Jul 15 14:00:27 PDT 2008


Hi Dale,

> >> +    // 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.)

thanks for the explanation.  However llvm-gcc already supports
variable byte-offsets, i.e. where the value of the byte offset
depends on the value of some variable, the content of a memory
location etc.  Ada does this for example.  So why does ObjC2
need something special here?

Ciao,

Duncan.



More information about the llvm-commits mailing list