[LLVMdev] Proposal: intp type

Kenneth Uildriks kennethuil at gmail.com
Thu Nov 12 09:20:43 PST 2009


On Thu, Nov 12, 2009 at 3:42 AM, Duncan Sands <baldrick at free.fr> wrote:
>> I mean within a structure or array.  I don't know whether any
>> platforms would pass them any differently as function arguments, but I
>> do know that the "default" data layout (which I believe is the Sparc
>> data layout) aligns int32's on 32-bit boundaries and 32-bit pointers
>> on 64-bit boundaries.
>
> Wrap the pointer in a packed struct maybe?
>
> Ciao,
>
> Duncan.
>

That sets the alignment to 1 unconditionally, which might also be wrong.

Now I assume that a one-element regular struct would have the same
alignment as the element, right?  In that case:

1. A type such as intp will get the following definition:

struct {
{intAAA, intBBB, intCCC, intDDD, intEEE,  intFFF, intGGG, intHHH}*[0];
int32 or int64
};

where AAA, BBB, CCC, DDD, EEE, FFF, GGG, HHH are 16 bit values that
combine to form a GUID.  Since it's zero-sized, the struct as a whole
will align the same way as the int.

Then define a transform that looks for the GUID and changes the int32
to the platform-specific intp integer-size.  This transform will be
run at link time.




More information about the llvm-dev mailing list