https://gcc.gnu.org/g:940bc8be6b3adb22d1f365d60cec3fc6b45d3470
commit r17-1549-g940bc8be6b3adb22d1f365d60cec3fc6b45d3470 Author: Georg-Johann Lay <[email protected]> Date: Sun Jun 14 15:24:12 2026 +0200 AVR: lib1funcs.S: Use PC_SIZE instead of a magic number. libgcc/ * config/avr/asm-defs.h (REGNO): Recognize: x, y, z, X, Y, Z. (PC_SIZE): New define. * config/avr/lib1funcs.S (__mulpsi3, __mulsi3): Use it. Diff: --- libgcc/config/avr/asm-defs.h | 15 +++++++++++---- libgcc/config/avr/lib1funcs.S | 36 +++++++++++++++++------------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/libgcc/config/avr/asm-defs.h b/libgcc/config/avr/asm-defs.h index 1e0add530217..62879464f9d3 100644 --- a/libgcc/config/avr/asm-defs.h +++ b/libgcc/config/avr/asm-defs.h @@ -73,7 +73,9 @@ xl, xh, yl, yh, zl, zh, \ Xl, Xh, Yl, Yh, Zl, Zh, \ xL, xH, yL, yH, zL, zH, \ - XL, XH, YL, YH, ZL, ZH + XL, XH, YL, YH, ZL, ZH, \ + x, xh, y, yh, z, zh, \ + X, XH, Y, YH, Z, ZH .ifc \name,\reg \sym = 26 + ..regno % 6 ..regno.done = 1 @@ -102,9 +104,11 @@ #if defined (__AVR_HAVE_EIJMP_EICALL__) #define XICALL eicall #define XIJMP eijmp +#define PC_SIZE 3 #else #define XICALL icall #define XIJMP ijmp +#define PC_SIZE 2 #endif @@ -229,7 +233,10 @@ #ifndef __AVR_TINY__ -;;; Prologue stuff +;;; Convenience macro for easy use of __prologue_saves__. +;;; Push the N_PUSHED callee-saved registers Y, R17, R16, R15, ... +;;; with 0 <= N_PUSHED <= 18. The frame pointer (Y) is set up according +;;; to a frame size of N_FRAME. Clobbers TMP_REG. Does not clobber T. .macro do_prologue_saves n_pushed n_frame=0 ldi r26, lo8 (\n_frame) ldi r27, hi8 (\n_frame) @@ -239,8 +246,8 @@ .L_prologue_saves.\@: .endm - -;; Epilogue stuff +;;; Convenience macro for easy use of __epilogue_restores__. +;;; Undo the effect of __prologue_saves__. Clobbers TMP_REG. .macro do_epilogue_restores n_pushed n_frame=0 in r28, __SP_L__ #ifdef __AVR_HAVE_SPH__ diff --git a/libgcc/config/avr/lib1funcs.S b/libgcc/config/avr/lib1funcs.S index 4978a2e969ca..6af40122f022 100644 --- a/libgcc/config/avr/lib1funcs.S +++ b/libgcc/config/avr/lib1funcs.S @@ -273,16 +273,15 @@ ENDF __mulhisi3 #if defined (L_mulsi3) DEFUN __mulsi3 #if defined (__AVR_TINY__) - in r26, __SP_L__ ; safe to use X, as it is CC0/CC1 - in r27, __SP_H__ - subi r26, lo8(-3) ; Add 3 to point past return address - sbci r27, hi8(-3) - push B0 ; save callee saved regs - push B1 - ld B0, X+ ; load from caller stack - ld B1, X+ - ld B2, X+ - ld B3, X + in r26, __SP_L__ ; Safe to use X, as it is CC0/CC1. + in r27, __SP_H__ + waddi r26, 1 + PC_SIZE ; Add 3 to point past return address. + push B0 ; Save callee saved regs. + push B1 + ld B0, X+ ; Load from arg pointer. + ld B1, X+ + ld B2, X+ + ld B3, X #endif ;; Clear result clr CC2 @@ -569,15 +568,14 @@ ENDF __mulpsi3 DEFUN __mulpsi3 #if defined (__AVR_TINY__) - in r26,__SP_L__ - in r27,__SP_H__ - subi r26, lo8(-3) ; Add 3 to point past return address - sbci r27, hi8(-3) - push B0 ; save callee saved regs - push B1 - ld B0,X+ ; load from caller stack - ld B1,X+ - ld B2,X+ + in r26, __SP_L__ + in r27, __SP_H__ + waddi r26, 1 + PC_SIZE ; Add 3 to point past return address. + push B0 ; Save callee saved regs. + push B1 + ld B0, X+ ; Load from arg pointer. + ld B1, X+ + ld B2, X+ #endif /* defined (__AVR_TINY__) */ ;; C[] = 0
