Mail Archives: djgpp/1998/09/01/20:17:55
From: | GAMMELJL AT SLU DOT EDU
|
Date: | Tue, 01 Sep 1998 15:15:37 -0500 (CDT)
|
Subject: | Getting registers for arguments and inlining functions
|
To: | djgpp AT delorie DOT com
|
Message-id: | <01J1AOXNWNZ694JQYE@SLU.EDU>
|
Organization: | SAINT LOUIS UNIVERSITY St. Louis, MO
|
MIME-version: | 1.0
|
By looking at the .s file below ones sees that the function zadd is
not inline. The call _zadd__Fii has not been eliminated. In fact
the .s file looks exactly like the one with no effort to inline.
How does one make the compiler do inlining? I have read "An inline
function is as fast as a macro" where I got the scheme for declaring
zadd to be inline, but I don't get what I expected in the .s file.
I explain what I expected below.
_____________Source code for codename.cc_________________________________
extern inline int zadd(int m,int n) __attribute__ ((regparm(2)));
int i,j,k;
I am indebted to Nate Eldredge for
main() telling me how to use the above
{i=2; attribute to cause the compiler
j=3; to pass the arguments of zadd in
zadd(i,j); registers.
return 0;
}
inline int
zadd(int m,int n)
{k=m+n;
}
________The .s file produce by gxx codename.cc -S -O2_____________________
.file "example9.cc"
gcc2_compiled.:
___gnu_compiled_cplusplus:
.text
.align 2
.globl _main
_main:
pushl %ebp
movl %esp,%ebp
call ___main
movl $2,_i
movl $3,_j
movl $3,%edx
movl $2,%eax
call _zadd__Fii -------> I expected to see addl %edx,%eax here;
xorl %eax,%eax
leave (see below)
ret
.align 2
_zadd__Fii:
pushl %ebp
movl %esp,%ebp
addl %edx,%eax ------> namely, this line, and nothing else.
movl %eax,_k
leave
ret
.globl _i
.data
.align 2
_i:
.space 4
.globl _j
.align 2
_j:
.space 4
.globl _k
.align 2
_k:
.space 4
- Raw text -