When passing _Decimal64 or _Decimal128 to a function via stack, how
should they be aligned? Currently, gcc aligns them at 4byte boundary.
Is this desirable?
On Fri, Mar 21, 2008 at 5:37 PM, Andrew Pinski <pins...@gmail.com> wrote: > On Fri, Mar 21, 2008 at 5:29 PM, H.J. <hjl.to...@gmail.com> wrote: > > When passing _Decimal64 or _Decimal128 to a function via stack, how > > should they be aligned? Currently, gcc aligns them at 4byte boundary. > > Is this desirable?
> Shouldn't it always be 4 byte aligned because the SysV ABI only talks > about word alignment?
DFP is beyond i386 psABI. Gcc aligns _Decimal32 to 4 byte, _Decimal64 to 8 bytes and _Decimal128 to 16bytes. The question is what is the best alignment for them when passing to a functions.
H.J. Lu wrote: > On Fri, Mar 21, 2008 at 5:37 PM, Andrew Pinski <pins...@gmail.com> wrote: >> On Fri, Mar 21, 2008 at 5:29 PM, H.J. <hjl.to...@gmail.com> wrote: >> > When passing _Decimal64 or _Decimal128 to a function via stack, how >> > should they be aligned? Currently, gcc aligns them at 4byte boundary. >> > Is this desirable?
>> Shouldn't it always be 4 byte aligned because the SysV ABI only talks >> about word alignment?
> DFP is beyond i386 psABI. Gcc aligns _Decimal32 to 4 byte, _Decimal64 to 8 bytes > and _Decimal128 to 16bytes. The question is what is the best alignment for them > when passing to a functions.
Unless there is some hardware penalty in loading from a 4-byte boundary rather than 8-byte boundary, then it would seem that 4-byte alignment is simpler. On the other hand, it would seem that alignment of a data value should be on the expected boundary whether it statically allocated or passed to a function.
-- Michael Eager ea...@eagercon.com 1960 Park Blvd., Palo Alto, CA 94306 650-325-8077
On Sun, Mar 23, 2008 at 11:41:00PM +1100, Ben Elliston wrote: > > DFP is beyond i386 psABI. Gcc aligns _Decimal32 to 4 byte, _Decimal64 to 8 bytes > > and _Decimal128 to 16bytes. The question is what is the best alignment for them > > when passing to a functions.
> The original work I did for the x86-64 backend placed them at that > alignment because that is the required alignment for loading those > values into SSE registers. Right?
That is a good question. For x86, _Decimal128 is passed on stack and aligned at 4 byte. For x86-64, _Decimal128 is passed in SSE registers. An implementation of _Decimal128 in 32bit may want to use SSE registers.
On Sun, Mar 23, 2008 at 8:09 AM, H.J. Lu <hjl.to...@gmail.com> wrote:
> On Sun, Mar 23, 2008 at 11:41:00PM +1100, Ben Elliston wrote: > > > DFP is beyond i386 psABI. Gcc aligns _Decimal32 to 4 byte, _Decimal64 to 8 bytes > > > and _Decimal128 to 16bytes. The question is what is the best alignment for them > > > when passing to a functions.
> > The original work I did for the x86-64 backend placed them at that > > alignment because that is the required alignment for loading those > > values into SSE registers. Right?
> That is a good question. For x86, _Decimal128 is passed on stack > and aligned at 4 byte. For x86-64, _Decimal128 is passed in SSE > registers. An implementation of _Decimal128 in 32bit may want > to use SSE registers.
I think we should align _Decimal64 and _Decimal128 to their natural alignments when passing a function. The same should apply to x86-64 when they are passed on stack.
> I think we should align _Decimal64 and _Decimal128 to their natural
> alignments when passing a function. The same should apply to x86-64
> when they are passed on stack.
Rather than aligning _Decimal64 to its natural boundary, I think it is
more sensible to be consistent with the existing 8-byte scalar types,
i.e. double and long long. That would mean aligning _Decimal64 to 4
bytes within structures and when passing to a function.
For _Decimal128, I agree with the conclusion to align to 16-bytes
within structures and as outgoing arguments. That behavior is
consistent with the existing data types __m128, __m128d, and __m128i.
Dave Kreitzer
IA-32 and Intel 64 Code Generation
Intel Compiler Lab
> > I think we should align _Decimal64 and _Decimal128 to their natural > > alignments when passing a function. The same should apply to x86-64 > > when they are passed on stack.
> Rather than aligning _Decimal64 to its natural boundary, I think it is > more sensible to be consistent with the existing 8-byte scalar types, > i.e. double and long long. That would mean aligning _Decimal64 to 4 > bytes within structures and when passing to a function.
That means to change the default alignment of _Decimal64 to 4 bytes in 32bit mode.
> For _Decimal128, I agree with the conclusion to align to 16-bytes > within structures and as outgoing arguments. That behavior is > consistent with the existing data types __m128, __m128d, and __m128i.
> Dave Kreitzer > IA-32 and Intel 64 Code Generation > Intel Compiler Lab