This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: IA64 record alignment rules, and modes?


"Gary Funck" <gary@intrepid.com> writes:
> typedef struct sptr_struct
>   {
>     long unsigned int phase: 48;
>     short unsigned int thread: 16;
>     void *addr;
>   } sptr_t;
>
> is assigned a BLKmode rather a TImode, [...]
>
> Question: If we assume that a TImode would've been a more efficient mode
> to represent the record type above, would it not have been acceptable for
> the compiler to promote the alignment of this type to 128, given there
> are no apparent restrictions otherwise, or are there other C conventions
> at work that dictate otherwise?

Well, if you had:

   struct foo {
     sptr_struct s;
     void *p;
   } foo_struct;

then sizeof (foo_struct) should be 16 + 8 == 24.  If gcc bumped the
alignment of sptr_struct to 128 bits, it would also have to bump the
size of foo_struct to 32 bytes in order to maintain current alignment.
If it didn't, a declaration like:

    struct foo x[2];

would lead to x[1].s not being correctly aligned.

Richard


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]