[PING^2][PATCH][AVR] gas: Fix PR32704: Better ISR prologues

Georg-Johann Lay avr@gjlay.de
Wed Mar 5 15:28:22 GMT 2025


Hi, this is Ping #2 for the patch below.

https://sourceware.org/pipermail/binutils/2025-February/139497.html
https://sourceware.org/PR32704

Ok to apply to trunk? (I have write-after-approval).

Johann

--

gas/
	PR gas/32704
	PR gas/21683
	* config/tc-avr.c (avr_isr): bool-ize.
	(avr_emit_insn): Emit "mov" code as  MOV R1,<reg>.
	(avr_isr_stack_t): New typedef.
	(avr_emit_push, avr_emit_pop): New static functions.
	(avr_patch_gccisr_frag): Overhaul prologue and epilogue
	generation.

--

> The prologue generated by __gcc_isr can be improved in
> situations where:
> 
> * ZERO_REG is needed, and
> * SREG is not clobbered by the ISR, and
> * avr-gcc provides a GPR >= R16 with the Done chunk, and
> * Code generation is for ordinary AVRs (not AVRrc).
> 
> For example, the prologue for
> 
> volatile char var;
> 
> __attribute__((signal)) void __vector_1 (void)
> {
>      var = 1;
>      var = 0;
> }
> 
> may be
> 
> 00000000 <__vector_1>:
>     0:	8f 93       	push	r24
>     2:	1f 92       	push	r1
>     4:	80 e0       	ldi	r24, 0
>     6:	18 2e       	mov	r1, r24
> 
> instead of the code as currently generated by GAS:
> 
> 00000000 <__vector_1>:
>     0:	1f 92       	push	r1
>     2:	1f b6       	in	r1, SREG
>     4:	1f 92       	push	r1
>     6:	11 24       	clr	r1
>     8:	8f 93       	push	r24
> 
> which consumes more stack, time and code than needed.
> 
> The patch is for trunk.  [...]
> 
> Johann
> 
> --
> 
> ChangeLog:
> 
> AVR: gas/32704 - Improve code generation for __gcc_isr.
> 
> The prologue generated by __gcc_isr can be improved in
> situations where:
> 
> * ZERO_REG is needed, and
> * SREG is not clobbered by the ISR, and
> * avr-gcc provides a GPR >= R16 with the Done chunk, and
> * Code generation is for ordinary AVRs (not AVRrc).
> 
> For example, the prologue for
> 
> volatile char var;
> 
> __attribute__((signal)) void __vector_1 (void)
> {
>      var = 1;
>      var = 0;
> }
> 
> may be
> 
> 00000000 <__vector_1>:
>     0:	8f 93       	push	r24
>     2:	1f 92       	push	r1
>     4:	80 e0       	ldi	r24, 0
>     6:	18 2e       	mov	r1, r24
> 
> instead of the code as currently generated by GAS:
> 
> 00000000 <__vector_1>:
>     0:	1f 92       	push	r1
>     2:	1f b6       	in	r1, SREG
>     4:	1f 92       	push	r1
>     6:	11 24       	clr	r1
>     8:	8f 93       	push	r24
> 
> which consumes more stack, time and code than needed.
> 
> gas/
> 	PR gas/32704
> 	PR gas/21683
> 	* config/tc-avr.c (avr_isr): bool-ize.
> 	(avr_emit_insn): Emit "mov" code as  MOV R1,<reg>.
> 	(avr_isr_stack_t): New typedef.
> 	(avr_emit_push, avr_emit_pop): New static functions.
> 	(avr_patch_gccisr_frag): Overhaul prologue and epilogue
> 	generation.
> -------------- next part --------------
> AVR: gas/32704 - Improve code generation for __gcc_isr.
> 
> The prologue generated by __gcc_isr can be improved in
> situations where:
> 
> * ZERO_REG is needed, and
> * SREG is not clobbered by the ISR, and
> * avr-gcc provides a GPR >= R16 with the Done chunk, and
> * Code generation is for ordinary AVRs (not AVRrc).
> 
> For example, the prologue for
> 
> volatile char var;
> 
> __attribute__((signal)) void __vector_1 (void)
> {
>     var = 1;
>     var = 0;
> }
> 
> may be
> 
> 00000000 <__vector_1>:
>    0:	8f 93       	push	r24
>    2:	1f 92       	push	r1
>    4:	80 e0       	ldi	r24, 0
>    6:	18 2e       	mov	r1, r24
> 
> instead of the code as currently generated by GAS:
> 
> 00000000 <__vector_1>:
>    0:	1f 92       	push	r1
>    2:	1f b6       	in	r1, SREG
>    4:	1f 92       	push	r1
>    6:	11 24       	clr	r1
>    8:	8f 93       	push	r24
> 
> which consumes more stack, time and code than needed.
> 
> gas/
> 	PR gas/32704
> 	PR gas/21683
> 	* config/tc-avr.c (avr_isr): bool-ize.
> 	(avr_emit_insn): Emit "mov" code as  MOV R1,<reg>.
> 	(avr_isr_stack_t): New typedef.
> 	(avr_emit_push, avr_emit_pop): New static functions.
> 	(avr_patch_gccisr_frag): Overhaul prologue and epilogue
> 	generation.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr32704-gas.diff
Type: text/x-patch
Size: 8141 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20250305/dd41a9e4/attachment.bin>


More information about the Binutils mailing list