confusion on caller-saved registers and callee-saved registers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I am quite confused about how the gcc distinguish them. I know there
is a macro CALL_USED_REGISTER, where one register should be saved in
the stack when used in a function if the corresponding value in
CALL_USED_REGISTER is set to 0. So it becomes reasonable for the
caller to save the registers if their CALL_USED_REGISTER values are 1.

Suppose r24's value is 1, and I set r24 to be the first register for
allocation. I write a program where foo () is calling test(),
something like:
int test () // test is an assembler-language written file
{
 ... ...
}

int foo () // foo is a C written file
{
  test ();
 ... ...
}

It is obvious that test () would use r24, and because of the
attribution of r24, test () will not save r24 automaticly, which pass
the work to the caller of test () to save them, namely

_test:
add r24, r8, r9
...

_foo
sw r24, sp, off
call _test

But I didn't see  GCC generate sw r24, sp, off. Is there something I
am missing? Or maybe I misunderstand the concept of call-used
registers.
Thank you in advance.

--
He Xiao
Shanghai Jiaotong University, 800 Dongchuang Road, Shanghai, China


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux