[cfe-users] How to change alignment of long long
Philipp Klaus Krause via cfe-users
cfe-users at lists.llvm.org
Sat Oct 22 04:14:14 PDT 2016
On 22.10.2016 09:35, Philipp Klaus Krause via cfe-users wrote:
> Found another one that encountered this problem:
> Again no solution there.
> Is anyone sucessfully using clang (preferably 3.8) with an alignment for
> long long or double that is not 64 bits?
To all the other encountering this issue: I was able to track down the
In general, alignment handling in clang is a mess.
Yes, there are some values in the Target for alignment, but they dont't
always do what one might think. They seem to be fine for char, int, long
and float. For short, there is none, as short alignment is hardcoded to
16 bits. For long long and double there are alignment values, but they
are not used. Instead the width is used as alignment: In
ASTContext::getPreferredTypeAlign, unless the target is xcore, for
double, long long and unsigned long long, the alignment of the type is
replaced by the width.
So, to make alignment for long long and double work, you need add a
special case for your target in ASTContext::getPreferredTypeAlign like
there already is for xcore. And to make alignment work for short, you
need to make getShortAlign() virtual in TargetInfo and override it in
P.S.: I am using clang 3.8, the above might or might not apply to other
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 183 bytes
Desc: OpenPGP digital signature
More information about the cfe-users