On Wed, Nov 11, 2009 at 2:46 PM, Nick Lewycky <nicholas at mxc.ca> wrote:> I'd be happy to permit arithmetic and bitwise operations on pointers. (I > thought we already did. We don't.)That would be very helpful too.> > You still can't create literal values with it (besides null) because you > don't know whether your constant will fit. Or rather, what you get is > exactly what the inttoptr instruction already gives you.> Within a structure or array you mean? Or do you mean that some platforms > pass pointers and integers differently as function arguments? > > Nick >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.
> 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.
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.