[llvm-commits] Size of long double (X86_FP80Ty)

Duncan Sands baldrick at free.fr
Mon Oct 1 00:47:21 PDT 2007


> By the way, to be consistent, getTypeSize for an APInt
> should return the number of bits rounded up to a multiple
> of 8, rather than rounded up to a power of 2 as it is now.
> Shall I make this change?

Due to the way ExpandOp works for loads and stores, it looks
like the size needs to be the smallest power of 2 bigger than
or equal to the bitwidth.  For example, consider i36 on a 32
bit machine.  The type to expand to is i32, and a store gets
expanded into two i32 stores, i.e. 64 bits.  This suggests
that the size needs to be at least 8 bytes, since otherwise
you may write outside the allocated memory.

Note that this applies regardless of alignment (I say this
because getTypeSize seems to round the size of APInt's up
to the next multiple of the alignment).  For example, consider
i128.  This first gets expanded to i64, result on two 64 bit
writes, then i64 to i32, resulting in four 32 bit writes.  In
any case, you write 128 bits so the size should presumably be
16 bytes, and alignment didn't come into this anywhere...

Am I wrong?

Thanks,

Duncan.

PS: Is it the same for floating point types?  Can a 128 bit
fp type be expanded into two 64 bit fp types?




More information about the llvm-commits mailing list