This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
How to inform gcc not to save registers on entering a function?
- From: "PRC" <panruochen at gmail dot com>
- To: "gcc-help" <gcc-help at gcc dot gnu dot org>
- Date: Fri, 13 Jun 2008 10:39:00 +0800
- Subject: How to inform gcc not to save registers on entering a function?
Hi All,
I want to implement an exception handler on MIPS.
First, I will save all registers on the entry of the exception handler written
in assembly. And then I will jump to another exception handler written in C.
------------------------------------------------
exc_handler:
SAVE_ALL_GPRS
j exc_handler_c
...
void exc_handler_c()
{
...
}
------------------------------------------------
When I check the un-assembly list file, I find gcc still saves used registers
at the begin of function exc_handler_c.
------------------------------------------------
8000d1e4: 27bdffd8 addiu sp,sp,-40
8000d1e8: afb10014 sw s1,20(sp)
8000d1ec: afbf0024 sw ra,36(sp)
8000d1f0: afb40020 sw s4,32(sp)
8000d1f4: afb3001c sw s3,28(sp)
8000d1f8: afb20018 sw s2,24(sp)
8000d1fc: afb00010 sw s0,16(sp)
...
------------------------------------------------
It is uneccessary at all since all registers have been saved before entering the function
and will be restored after leaving the function.
So how can I inform gcc not to save the registers on entering the funcion?
Best Regards,
PRC
June 13, 2008