For my 16 bit based target implementation, I need objects larger than 1 byte to get always aligned to 2 bytes.
For simple types, this is easily made by setting alignments in the MyTarget.h file (for example IntWidth=16; IntAlign=16; and so on)
For arrays, I have set LargeArrayMinWidth = 8; LargeArrayAlign = 16; so that all of them get an alignment of 2 bytes.
However, I am lost at what to do with Structs. The desired behaviour is obtained when I explicitly give the attribute( (aligned) ) in the source C code, such as this
} attribute( (aligned) );
but I would want CLang to set that attribute by default to all aggregate types.
Setting MinGlobalAlign is not an option because I still want single bytes to be 1 byte aligned, also, this does not work for objects initialised on the stack.
So, what’s the code hook to instruct Clang to always emit aligned code (as if the attribute( (aligned) ) was specified) ?