Subject: [RFC PATCH 05/19] powerpc/32: Use load and store multiple in GPR save/restore macros

From: Nicholas Piggin <[email-masked]>
Date: Mon, 31 Oct 2022 15:54:26 +1000

---
 arch/powerpc/include/asm/ppc_asm.h | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 753a2757bcd4..ac44383d350a 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -57,8 +57,22 @@
 #define SAVE_NVGPRS(base)		SAVE_GPRS(14, 31, base)
 #define REST_NVGPRS(base)		REST_GPRS(14, 31, base)
 #else
-#define SAVE_GPRS(start, end, base)	OP_REGS stw, 4, start, end, base, GPR0
-#define REST_GPRS(start, end, base)	OP_REGS lwz, 4, start, end, base, GPR0
+.macro __SAVE_GPRS start, end, base, offset
+	.if \end == 31
+		stmw	\start,\offset(\base)
+	.else
+		OP_REGS stw, 4, \start, \end, \base, \offset
+	.endif
+.endm
+.macro __REST_GPRS start, end, base, offset
+	.if \end == 31
+		lmw	\start,\offset(\base)
+	.else
+		OP_REGS lwz, 4, \start, \end, \base, \offset
+	.endif
+.endm
+#define SAVE_GPRS(start, end, base)	__SAVE_GPRS start, end, base, GPR0
+#define REST_GPRS(start, end, base)	__REST_GPRS start, end, base, GPR0
 #define SAVE_NVGPRS(base)		SAVE_GPRS(13, 31, base)
 #define REST_NVGPRS(base)		REST_GPRS(13, 31, base)
 #endif
-- 
2.37.2