AVR [patch] Enable nostackframe directive for interrupt routines
Original Reporter info from Mantis: ccrause @ccrause
-
Reporter name: Christo Crause
Original Reporter info from Mantis: ccrause @ccrause
- Reporter name: Christo Crause
Description:
Currently the compiler ignores the nostackframe directive for interrupt routines. This results in stack frame prologue & epilogue generation, even if not required. Consider the simple example in steps to reproduce below. The code generated for this interrupt is 12 instructions (excluding reti). Since the sbi instruction doesn't modify any status flags nor involve any registers it is a good candidate for the nostackframe directive.
The interrupt below can be rewritten in assembler as follows:
procedure Timer0Overflow; public name 'TIMER0_OVF_ISR'; interrupt; nostackframe; assembler;
asm
sbi PORTB+(-32), 5
end;
Currently the compiler ignores the nostackframe directive, resulting in 9 extra instructions for stack frame prologue/epilogue.
Attached a patch which enables the nostackframe directive for interrupt routines. The code generated by this patch only contains the sbi instruction followed by reti, a substantial reduction in code size for this simple example.
Steps to reproduce:
procedure Timer0Overflow; public name 'TIMER0_OVF_ISR'; interrupt;
begin
PORTB := PORTB or (1 shl 5);
end;
Resulting code:
procedure Timer0Overflow; public name 'TIMER0_OVF_ISR'; interrupt;
begin
9e: 2f 93 push r18
a0: 1f 92 push r1
a2: 0f 92 push r0
a4: 0f b6 in r0, 0x3f ; 63
a6: 0f 92 push r0
a8: 11 24 eor r1, r1
PORTB := PORTB or (1 shl 5);
aa: 2d 9a sbi 0x05, 5 ; 5
end;
ac: 0f 90 pop r0
ae: 0f be out 0x3f, r0 ; 63
b0: 0f 90 pop r0
b2: 1f 90 pop r1
b4: 2f 91 pop r18
b6: 18 95 reti
Mantis conversion info:
- Mantis ID: 35899
- Build: 42516
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 42519 (#f72342ed)