This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How to inform gcc not to save registers on entering a function?
- From: David Daney <ddaney at avtrex dot com>
- To: PRC <panruochen at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Thu, 12 Jun 2008 23:51:54 -0700
- Subject: Re: How to inform gcc not to save registers on entering a function?
- References: <200806131038481525454@gmail.com>
PRC wrote:
> 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?
>
I don't think it is possible.
Unless you want to modify the compiler, you have to live with it correctly implementing the ABI.
David Daney