On 04/11/12 10:34, Mischa Baars wrote:
On 11/04/2012 02:45 AM, Ian Lance Taylor wrote:
On Sat, Nov 3, 2012 at 12:55 AM, Mischa Baars <mjbaars1...@gmail.com>
wrote:
On 11/02/2012 07:11 PM, Ian Lance Taylor wrote:
On Fri, Nov 2, 2012 at 8:13 AM, Mischa Baars <mjbaars1...@gmail.com>
wrote:
I have been writing this piece of example code, but it seems that
someone
has been modifying the compiler in the meantime such that arguments
are
now
passed in xmm registers instead of over the stack. Also the npx top of
stack
pointer isn't handled alike for all three different types of real
numbers
on
function return any more.
I have not looked at your code.  However, I can tell you that on
32-bit x86 floating point function arguments are normally passed on
the stack and on 64-bit x86 floating point arguments are normally
passed in the xmm registers.  There are various ways that you can
change this default behaviour, but if you are seeing an unexpected
change then I would guess that you changed from 32-bit compilation to
64-bit compilation.

Ian

By the way, it seems this only holds for single and double real numbers.
These are indeed passed in xmm registers, the long double however is
still
passed over the stack.
Yes.

Do we have any compiler options that change this behaviour back to the
original? The default behaviour in 64-bit mode is not even the same
for all
real number types.
There is no "original."  The 32-bit and 64-bit ABIs are different.
The 64-bit ABI has always passed arguments in registers.  There is no
option to force the 64-bit compiler to pass arguments on the stack.

Ian

Sounds more logical to me, that a least all types of numbers are treated
in the same manner. I suppose the ABI should be modified then if you ask
me.

Mischa.


I am completely failing to see your problem here.

gcc is a C (and C++, Fortran, etc.) compiler. When you write C code, there are only two reasons for caring about ABI and parameter passing - one is that it should be as efficient as possible, and the other is that for external linkage code, it should conform to the platform's standard ABI so that you can link to libraries, or assembly code written to match the ABI.

The 64-bit ABI uses the xmm registers for efficiency. This is a /good/ thing. Write your code in C, and it will work correctly and efficiently whether it is compiled as 32-bit or 64-bit code.


If you want to use a little bit of assembly in your C code (I don't know why you want to do so here, but I presume you've got good reasons - such as for learning), then I strongly recommend you learn about gcc's inline assembly syntax. It will save you from worrying about what data is in which place, since it will handle such moves for you. And it will give you more efficient code, and is easier to work with for small assembly functions.

David


Reply via email to