Minimum target alignment for a datatype

Mike Stump mrs@apple.com
Fri Jul 22 19:33:00 GMT 2005


On Friday, July 22, 2005, at 11:07 AM, Chris Lattner wrote:
> I'm trying to determine (in target-independent code) what the 
> *minimum* target alignment of a type is.  For example, on darwin, 
> double's are normally 4-byte aligned, but are 8-byte aligned in some 
> cases (e.g. when they are the first element of a struct).  TYPE_ALIGN 
> on a double returns 8 bytes, is there any way to find out that they 
> may end up being aligned to a 4-byte boundary?

I'm having a hard time with the simplicity of your question:

/* The alignment necessary for objects of this type.
    The value is an int, measured in bits.  */
#define TYPE_ALIGN(NODE) (TYPE_CHECK (NODE)->type.align)

/* 1 if the alignment for this type was requested by "aligned" 
attribute,
    0 if it is the default for this type.  */
#define TYPE_USER_ALIGN(NODE) (TYPE_CHECK (NODE)->type.user_align)

/* The alignment for NODE, in bytes.  */
#define TYPE_ALIGN_UNIT(NODE) (TYPE_ALIGN (NODE) / BITS_PER_UNIT)

?  Certainly, I don't expect that to answer your question, but I don't 
understand why.



More information about the Gcc mailing list