Mail Archives: djgpp/1998/08/31/21:02:15
GAMMELJL AT SLU DOT EDU wrote:
>
> The following C/C++ code when compiled:
> gxx example9.cc -S -O2
> results in the .s file below it. It is plain that the arguments
> of zadd are passed on the stack. Eli Zareteskii has told me that
> passing them in registers requires
> __attribute__((regparm=2))
> and that the information about this is in the GCC docs. Please:
> someone expert in searching these docs tell me exactly where this
> attribute statement goes in the C++ code below and exactly what the
> correct syntax is.
>From GCC Manual, node "Function Attributes":
# The keyword `__attribute__' allows you to specify special
attributes
# when making a declaration. This keyword is followed by an attribute
# specification inside double parentheses.
...
# `regparm (NUMBER)'
# On the Intel 386, the `regparm' attribute causes the compiler to
# pass up to NUMBER integer arguments in registers EAX, EDX, and
ECX
# instead of on the stack. Functions that take a variable number
of
# arguments will continue to be passed all of their arguments on
the
# stack.
So:
extern int zadd(int m, int n) __attribute__((regparm(2)));
Make sure this prototype is in scope when you define `zadd'!
(I added the explicit `int').
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -