[fpc-devel] Stack alignment on i386

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sun Dec 18 16:53:07 CET 2011


Jonas Maebe schrieb:

>> However current fpc 2.4.4 does not align the stack as such. I do
>> not know if this correct or not when reading things like: 
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838#c8 
>> http://groups.google.com/group/ia32-abi/browse_thread/thread/4f9b3e5069943bf1
>> 
>> 
>> I tried to change alignment with {$CODEALIGN 16} but this didn't
>> work.
> 
> That's because it changes the alignment of procedures (code), rather
> than that of the stack. You cannot change this setting via a switch,
> it's hardcoded in the compiler as part of the ABI.

I'm just curious, where can I find more information about SSE alignment
requirements? What exactly should be aligned - the stack segment, ESP or
EBP?

A requirement like
"so try that "test $15, %esp; jnz abort" at every function"
doesn't look sane to me, because every following push will result in a 
differently aligned ESP.

I could imagine that the addresses of SSE *operands* have to be aligned
on 16 byte boundaries, what can be satisfied almost only by using
accordingly aligned (static) variables, instead of pushing such *values*
onto the stack. Then even local (stack based) SSE variables could be
allocated in blocks 15 or 16 bytes bigger than requested, so that the
references into such an block can be adjusted dynamically to a 16 bit
boundary.

DoDi




More information about the fpc-devel mailing list