linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Neuling <mikey@neuling.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <michael@ellerman.id.au>
Cc: mikey@neuling.org, linuxppc-dev@ozlabs.org,
	schwab@linux-m68k.org, Anton Blanchard <anton@samba.org>,
	Olof Johannsson <olof@lixom.net>
Subject: [PATCH 16/18] powerpc: enforce usage of R0-R31 where possible
Date: Thu, 14 Jun 2012 16:15:52 +1000	[thread overview]
Message-ID: <20120614061552.8AF08D42BEA@localhost.localdomain> (raw)
In-Reply-To: <1339654536.159274.140684871779.qpush@ale>

Enforce the use of R0-R31 in macros where possible now we have all the
fixes in.

R0-R31 macros are removed here so that can't be used anymore.  They
should not be defined anywhere.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---

 arch/powerpc/include/asm/ppc-opcode.h |    8 ++---
 arch/powerpc/include/asm/ppc_asm.h    |   50 ++++++----------------------------
 arch/powerpc/kernel/fpu.S             |   12 ++++----
 arch/powerpc/kvm/booke_interrupts.S   |    3 +-
 4 files changed, 23 insertions(+), 50 deletions(-)

Index: powerpc-test/arch/powerpc/include/asm/ppc-opcode.h
===================================================================
--- powerpc-test.orig/arch/powerpc/include/asm/ppc-opcode.h
+++ powerpc-test/arch/powerpc/include/asm/ppc-opcode.h
@@ -115,10 +115,10 @@
 #define ___PPC_RB(b)	(((b) & 0x1f) << 11)
 #define ___PPC_RS(s)	(((s) & 0x1f) << 21)
 #define ___PPC_RT(t)	___PPC_RS(t)
-#define __PPC_RA(a)	(((a) & 0x1f) << 16)
-#define __PPC_RB(b)	(((b) & 0x1f) << 11)
-#define __PPC_RS(s)	(((s) & 0x1f) << 21)
-#define __PPC_RT(s)	__PPC_RS(s)
+#define __PPC_RA(a)	___PPC_RA(__REG_##a)
+#define __PPC_RB(b)	___PPC_RB(__REG_##b)
+#define __PPC_RS(s)	___PPC_RS(__REG_##s)
+#define __PPC_RT(t)	___PPC_RT(__REG_##t)
 #define __PPC_XA(a)	((((a) & 0x1f) << 16) | (((a) & 0x20) >> 3))
 #define __PPC_XB(b)	((((b) & 0x1f) << 11) | (((b) & 0x20) >> 4))
 #define __PPC_XS(s)	((((s) & 0x1f) << 21) | (((s) & 0x20) >> 5))
Index: powerpc-test/arch/powerpc/include/asm/ppc_asm.h
===================================================================
--- powerpc-test.orig/arch/powerpc/include/asm/ppc_asm.h
+++ powerpc-test/arch/powerpc/include/asm/ppc_asm.h
@@ -126,26 +126,26 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLP
 #define REST_32VRS(n,b,base)	REST_16VRS(n,b,base); REST_16VRS(n+16,b,base)
 
 /* Save the lower 32 VSRs in the thread VSR region */
-#define SAVE_VSR(n,b,base)	li b,THREAD_VSR0+(16*(n));  STXVD2X(n,base,b)
+#define SAVE_VSR(n,b,base)	li b,THREAD_VSR0+(16*(n));  STXVD2X(n,R##base,R##b)
 #define SAVE_2VSRS(n,b,base)	SAVE_VSR(n,b,base); SAVE_VSR(n+1,b,base)
 #define SAVE_4VSRS(n,b,base)	SAVE_2VSRS(n,b,base); SAVE_2VSRS(n+2,b,base)
 #define SAVE_8VSRS(n,b,base)	SAVE_4VSRS(n,b,base); SAVE_4VSRS(n+4,b,base)
 #define SAVE_16VSRS(n,b,base)	SAVE_8VSRS(n,b,base); SAVE_8VSRS(n+8,b,base)
 #define SAVE_32VSRS(n,b,base)	SAVE_16VSRS(n,b,base); SAVE_16VSRS(n+16,b,base)
-#define REST_VSR(n,b,base)	li b,THREAD_VSR0+(16*(n)); LXVD2X(n,base,b)
+#define REST_VSR(n,b,base)	li b,THREAD_VSR0+(16*(n)); LXVD2X(n,R##base,R##b)
 #define REST_2VSRS(n,b,base)	REST_VSR(n,b,base); REST_VSR(n+1,b,base)
 #define REST_4VSRS(n,b,base)	REST_2VSRS(n,b,base); REST_2VSRS(n+2,b,base)
 #define REST_8VSRS(n,b,base)	REST_4VSRS(n,b,base); REST_4VSRS(n+4,b,base)
 #define REST_16VSRS(n,b,base)	REST_8VSRS(n,b,base); REST_8VSRS(n+8,b,base)
 #define REST_32VSRS(n,b,base)	REST_16VSRS(n,b,base); REST_16VSRS(n+16,b,base)
 /* Save the upper 32 VSRs (32-63) in the thread VSX region (0-31) */
-#define SAVE_VSRU(n,b,base)	li b,THREAD_VR0+(16*(n));  STXVD2X(n+32,base,b)
+#define SAVE_VSRU(n,b,base)	li b,THREAD_VR0+(16*(n));  STXVD2X(n+32,R##base,R##b)
 #define SAVE_2VSRSU(n,b,base)	SAVE_VSRU(n,b,base); SAVE_VSRU(n+1,b,base)
 #define SAVE_4VSRSU(n,b,base)	SAVE_2VSRSU(n,b,base); SAVE_2VSRSU(n+2,b,base)
 #define SAVE_8VSRSU(n,b,base)	SAVE_4VSRSU(n,b,base); SAVE_4VSRSU(n+4,b,base)
 #define SAVE_16VSRSU(n,b,base)	SAVE_8VSRSU(n,b,base); SAVE_8VSRSU(n+8,b,base)
 #define SAVE_32VSRSU(n,b,base)	SAVE_16VSRSU(n,b,base); SAVE_16VSRSU(n+16,b,base)
-#define REST_VSRU(n,b,base)	li b,THREAD_VR0+(16*(n)); LXVD2X(n+32,base,b)
+#define REST_VSRU(n,b,base)	li b,THREAD_VR0+(16*(n)); LXVD2X(n+32,R##base,R##b)
 #define REST_2VSRSU(n,b,base)	REST_VSRU(n,b,base); REST_VSRU(n+1,b,base)
 #define REST_4VSRSU(n,b,base)	REST_2VSRSU(n,b,base); REST_2VSRSU(n+2,b,base)
 #define REST_8VSRSU(n,b,base)	REST_4VSRSU(n,b,base); REST_4VSRSU(n+4,b,base)
@@ -183,15 +183,18 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLP
 #else
 #define ULONG_SIZE	4
 #endif
-#define VCPU_GPR(n)	(VCPU_GPRS + (n * ULONG_SIZE))
+#define __VCPU_GPR(n)	(VCPU_GPRS + (n * ULONG_SIZE))
+#define VCPU_GPR(n)	__VCPU_GPR(__REG_##n)
 
 #ifdef __KERNEL__
 #ifdef CONFIG_PPC64
 
 #define STACKFRAMESIZE 256
-#define STK_REG(i)     (112 + ((i)-14)*8)
+#define __STK_REG(i)   (112 + ((i)-14)*8)
+#define STK_REG(i)     __STK_REG(__REG_##i)
 
-#define STK_PARAM(i)	(48 + ((i)-3)*8)
+#define __STK_PARAM(i)	(48 + ((i)-3)*8)
+#define STK_PARAM(i)	__STK_PARAM(__REG_##i)
 
 #define XGLUE(a,b) a##b
 #define GLUE(a,b) XGLUE(a,b)
@@ -543,39 +546,6 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
 #define	r30	%r30
 #define	r31	%r31
 
-#define	R0	0
-#define	R1	1
-#define	R2	2
-#define	R3	3
-#define	R4	4
-#define	R5	5
-#define	R6	6
-#define	R7	7
-#define	R8	8
-#define	R9	9
-#define	R10	10
-#define	R11	11
-#define	R12	12
-#define	R13	13
-#define	R14	14
-#define	R15	15
-#define	R16	16
-#define	R17	17
-#define	R18	18
-#define	R19	19
-#define	R20	20
-#define	R21	21
-#define	R22	22
-#define	R23	23
-#define	R24	24
-#define	R25	25
-#define	R26	26
-#define	R27	27
-#define	R28	28
-#define	R29	29
-#define	R30	30
-#define	R31	31
-
 #define	__REG_R0	0
 #define	__REG_R1	1
 #define	__REG_R2	2
Index: powerpc-test/arch/powerpc/kernel/fpu.S
===================================================================
--- powerpc-test.orig/arch/powerpc/kernel/fpu.S
+++ powerpc-test/arch/powerpc/kernel/fpu.S
@@ -26,7 +26,7 @@
 #include <asm/ptrace.h>
 
 #ifdef CONFIG_VSX
-#define REST_32FPVSRS(n,c,base)						\
+#define __REST_32FPVSRS(n,c,base)					\
 BEGIN_FTR_SECTION							\
 	b	2f;							\
 END_FTR_SECTION_IFSET(CPU_FTR_VSX);					\
@@ -35,7 +35,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX);
 2:	REST_32VSRS(n,c,base);						\
 3:
 
-#define SAVE_32FPVSRS(n,c,base)						\
+#define __SAVE_32FPVSRS(n,c,base)					\
 BEGIN_FTR_SECTION							\
 	b	2f;							\
 END_FTR_SECTION_IFSET(CPU_FTR_VSX);					\
@@ -44,9 +44,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX);
 2:	SAVE_32VSRS(n,c,base);						\
 3:
 #else
-#define REST_32FPVSRS(n,b,base)	REST_32FPRS(n, base)
-#define SAVE_32FPVSRS(n,b,base)	SAVE_32FPRS(n, base)
+#define __REST_32FPVSRS(n,b,base)	REST_32FPRS(n, base)
+#define __SAVE_32FPVSRS(n,b,base)	SAVE_32FPRS(n, base)
 #endif
+#define REST_32FPVSRS(n,c,base) __REST_32FPVSRS(n,__REG_##c,__REG_##base)
+#define SAVE_32FPVSRS(n,c,base) __SAVE_32FPVSRS(n,__REG_##c,__REG_##base)
 
 /*
  * This task wants to use the FPU now.
@@ -79,7 +81,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
 	beq	1f
 	toreal(r4)
 	addi	r4,r4,THREAD		/* want last_task_used_math->thread */
-	SAVE_32FPVSRS(0, r5, r4)
+	SAVE_32FPVSRS(0, R5, R4)
 	mffs	fr0
 	stfd	fr0,THREAD_FPSCR(r4)
 	PPC_LL	r5,PT_REGS(r4)
Index: powerpc-test/arch/powerpc/kvm/booke_interrupts.S
===================================================================
--- powerpc-test.orig/arch/powerpc/kvm/booke_interrupts.S
+++ powerpc-test/arch/powerpc/kvm/booke_interrupts.S
@@ -34,7 +34,8 @@
 #define HOST_R2         12
 #define HOST_CR         16
 #define HOST_NV_GPRS    20
-#define HOST_NV_GPR(n)  (HOST_NV_GPRS + ((n - 14) * 4))
+#define __HOST_NV_GPR(n)  (HOST_NV_GPRS + ((n - 14) * 4))
+#define HOST_NV_GPR(n)  __HOST_NV_GPR(__REG_##n)
 #define HOST_MIN_STACK_SIZE (HOST_NV_GPR(R31) + 4)
 #define HOST_STACK_SIZE (((HOST_MIN_STACK_SIZE + 15) / 16) * 16) /* Align. */
 #define HOST_STACK_LR   (HOST_STACK_SIZE + 4) /* In caller stack frame. */

  parent reply	other threads:[~2012-06-14  6:15 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-04  7:58 [PATCH] powerpc: Optimise the 64bit optimised __clear_user Anton Blanchard
2012-06-04 13:12 ` Olof Johansson
2012-06-04 14:44   ` Kumar Gala
2012-06-05  2:02 ` Anton Blanchard
2012-06-06 16:40   ` Segher Boessenkool
2012-06-06 21:20     ` Benjamin Herrenschmidt
2012-06-07  6:05       ` Michael Neuling
2012-06-07  6:07         ` Michael Ellerman
2012-06-07  6:12           ` Michael Neuling
2012-06-07  6:18             ` Michael Ellerman
2012-06-07 23:52               ` [PATCH] powerpc: Fix sldi to take literal not register name Michael Neuling
2012-06-08  0:19                 ` Benjamin Herrenschmidt
2012-06-07  6:39         ` [PATCH] powerpc: Optimise the 64bit optimised __clear_user Benjamin Herrenschmidt
2012-06-07  8:41           ` David Laight
2012-06-08 11:36       ` [PATCH 0/15] powerpc: convert GPR usage to %r0-31 and R0-31 Michael Neuling
2012-06-08 11:36         ` [PATCH 11/15] powerpc: fix VSX macros so register names aren't wrapped Michael Neuling
2012-06-08 11:36         ` [PATCH 10/15] powerpc: fixes for instructions not using correct register naming Michael Neuling
2012-06-08 11:36         ` [PATCH 5/15] powerpc: convert to %r for all GPR usage Michael Neuling
2012-06-08 21:54           ` Jesse Larrew
2012-06-14  3:25             ` Michael Neuling
2012-06-14  6:50               ` Jesse Larrew
2012-06-08 11:36         ` [PATCH 2/15] powerpc: modify macro ready for %r0 register change Michael Neuling
2012-06-08 11:36         ` [PATCH 8/15] powerpc: change mtcrf to use real register names Michael Neuling
2012-06-08 11:36         ` [PATCH 13/15] powerpc: start using ___PPC_RA/B/S/T where necessary Michael Neuling
2012-06-08 11:36         ` [PATCH 3/15] powerpc: fix usage of register macros getting ready for %r0 change Michael Neuling
2012-06-08 11:36         ` [PATCH 7/15] powerpc: merge STK_REG/PARAM/FRAMESIZE Michael Neuling
2012-06-08 11:36         ` [PATCH 4/15] powerpc: Fix sldi to take literal not register name Michael Neuling
2012-06-08 11:36         ` [PATCH 14/15] powerpc: Introduce new __REG_R macros Michael Neuling
2012-06-08 11:36         ` [PATCH 15/15] powerpc: enforce usage of R0-R31 where possible Michael Neuling
2012-06-08 11:36         ` [PATCH 9/15] powerpc: change LOAD_REG_ADDR to use real register names Michael Neuling
2012-06-08 11:36         ` [PATCH 6/15] powerpc/pasemi: move lbz/stbciz to ppc-opcode.h Michael Neuling
2012-06-08 11:36         ` [PATCH 12/15] powerpc: introduce new ___PPC_RA/B/S/T macros Michael Neuling
2012-06-08 11:36         ` [PATCH 1/15] powerpc: Add defines for R0-R31 Michael Neuling
     [not found]         ` <20120608113605.80B73D43B2B__2857.47079547054$1339155968$gmane$org@localhost.localdomain>
2012-06-08 12:12           ` [PATCH 7/15] powerpc: merge STK_REG/PARAM/FRAMESIZE Andreas Schwab
     [not found]         ` <20120608113605.91B88D43B2F__24549.446340143$1339156128$gmane$org@localhost.localdomain>
2012-06-08 12:15           ` [PATCH 10/15] powerpc: fixes for instructions not using correct register naming Andreas Schwab
2012-06-08 22:42             ` Benjamin Herrenschmidt
2012-06-09  6:53               ` Andreas Schwab
2012-06-09  7:17                 ` Benjamin Herrenschmidt
2012-06-09  9:39                   ` Andreas Schwab
2012-06-14  6:15                     ` [PATCH 0/18] powerpc: convert GPR usage to %r0-31 and R0-31 Michael Neuling
2012-06-14  6:15                       ` [PATCH 1/18] powerpc: Add defines for R0-R31 Michael Neuling
2012-06-14  6:15                       ` [PATCH 2/18] powerpc: modify macro ready for %r0 register change Michael Neuling
2012-06-14  6:15                       ` [PATCH 3/18] powerpc: fix usage of register macros getting ready for %r0 change Michael Neuling
2012-06-14  6:15                       ` [PATCH 4/18] powerpc: Fix sldi to take literal not register name Michael Neuling
2012-06-14  6:15                       ` [PATCH 5/18] powerpc: convert to %r for all GPR usage Michael Neuling
2012-06-14  6:15                       ` [PATCH 6/18] powerpc/pasemi: move lbz/stbciz to ppc-opcode.h Michael Neuling
2012-06-14  6:15                       ` [PATCH 7/18] powerpc: merge STK_REG/PARAM/FRAMESIZE Michael Neuling
2012-06-14  6:15                       ` [PATCH 8/18] powerpc: merge VCPU_GPR Michael Neuling
2012-06-14  6:15                       ` [PATCH 9/18] powerpc: change mtcrf to use real register names Michael Neuling
2012-06-14  6:15                       ` [PATCH 10/18] powerpc: change LOAD_REG_ADDR " Michael Neuling
2012-06-14  6:15                       ` [PATCH 11/18] powerpc: fixes for instructions not using correct register naming Michael Neuling
2012-06-14  6:15                       ` [PATCH 12/18] powerpc: fix VSX macros so register names aren't wrapped Michael Neuling
2012-06-14  6:15                       ` [PATCH 13/18] powerpc: introduce new ___PPC_RA/B/S/T macros Michael Neuling
2012-06-14  6:15                       ` [PATCH 14/18] powerpc: start using ___PPC_RA/B/S/T where necessary Michael Neuling
2012-06-14  6:15                       ` [PATCH 15/18] powerpc: Introduce new __REG_R macros Michael Neuling
2012-06-14  6:15                       ` Michael Neuling [this message]
2012-06-14  6:15                       ` [PATCH 17/18] powerpc: Add defines for RA 0-R31 Michael Neuling
2012-06-14  6:15                       ` [PATCH 18/18] powerpc: enforce usage of RA 0-R31 where possible Michael Neuling
2012-06-07  3:04     ` [PATCH] powerpc: Optimise the 64bit optimised __clear_user Paul Mackerras
2012-06-07 17:51       ` Scott Wood
2012-06-08  0:51         ` Benjamin Herrenschmidt
2012-06-08  7:34         ` Andreas Schwab
2012-06-07  0:30   ` Olof Johansson
2012-06-21  2:04 [PATCH 0/18] powerpc: convert GPR usage to %r0-31 and R0-31 Michael Neuling
2012-06-21  2:04 ` [PATCH 16/18] powerpc: enforce usage of R0-R31 where possible Michael Neuling
2012-06-25 23:33 [PATCH 0/18] powerpc: convert GPR usage to %r0-31 and R0-31 Michael Neuling
2012-06-25 23:33 ` [PATCH 16/18] powerpc: enforce usage of R0-R31 where possible Michael Neuling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120614061552.8AF08D42BEA@localhost.localdomain \
    --to=mikey@neuling.org \
    --cc=anton@samba.org \
    --cc=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=michael@ellerman.id.au \
    --cc=olof@lixom.net \
    --cc=paulus@samba.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).