[Top][All Lists]

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

Re: [avr-gcc-list] RTL epilogues and prologues

From: Marek Michalkiewicz
Subject: Re: [avr-gcc-list] RTL epilogues and prologues
Date: Mon, 21 Mar 2005 10:38:17 +0100
User-agent: Mutt/1.5.6+20040907i

On Sun, Mar 20, 2005 at 07:06:55AM -0500, address@hidden wrote:

> This also should also fix the c++ bug caused by the existing code using the 
> function name as a label. (sorry the PR escapes me!)

PR 18551, now fixed (4.0 and 3.4 too).

> Small stack adjustments are made using "rcall ." (2 bytes) and "push r0" (1 
> byte). This avoids difficult direct manipulation of stack pointer when it is 
> less efficient. Choice is based on instruction size - but thats pretty close 
> to speed.

Nice trick with "rcall .", we just have to remember it will push 3 (not 2)
bytes on ATmega256x.  And hope it's not patented in the Banana Union ;-)

> All stack pointer loads are now handled by move_hi code. This removes 
> duplicated tests and simplifies code.

For a long time, I've been thinking about simplifying this further by
making main() just a normal function, without any special handling.
The SP load has to be done earlier anyway (so C++ constructors can be
called) so the one in main() is unnecessary (the stack still has to be
adjusted for locals, of course).  Saving registers on stack can be
avoided by using "noreturn" attribute (if we don't need destructors -
most AVR applications run an infinite loop so main() never returns),
or a new function attribute which works like "OS_Task" on h8300 (IAR C
has a __C_task keyword for this purpose): "this function can return,
but does not need to save/restore any registers".

One more thing: interrupt/signal handling could be simplified too.
The msp430 port seems to have a cleaner implementation, where the
interrupt vector number is an argument of function attribute and it
doesn't matter how the function itself is named.  You can also have
a function which saves all registers like an interrupt handler, but
no vector points to it directly - this could be used if you need to
do something timing critical in assembler (say, cbi/sbi on some port
pin, without saving any registers) and then jump to some slower code
written in C.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]