From caf495ce6cca95bce89201a3f34664ff6915f920 Mon Sep 17 00:00:00 2001
From: rtoy <rtoy>
Date: Sun, 11 Dec 2005 03:45:36 +0000
Subject: [PATCH] The boxed register reg_FDEFN is r10, but r10 is one of the
 registers used in the C calling convention, so it's a bad idea to have
 reg_FDEFN be r10.

So, make r10 be the new unboxed register reg_NL7 and replace reg_L2
with reg_FDEFN.  (I was too lazy to renumber all registers, and I
don't think it matters where reg_FDEFN is.)

A simple cross-compile is needed.  Use boot-2005-12-1-ppc.lisp for the
cross-compile script.

compiler/ppc/vm.lisp:
o Make old FDEFN be the new unboxed register NL7.
o Rename L2 to be FDEFN, removing L2 complete.

lisp/ppc-assem.S:
o reg_L2 no longer exists, so don't use it.

lisp/ppc-lispregs.h:
o Make the corresponding changes here that were made in vm.lisp.

bootfiles/19c/boot-2005-12-1-ppc.lisp:
o Simple cross-compile script for this change.
---
 bootfiles/19c/boot-2005-12-1-ppc.lisp |  5 +++++
 compiler/ppc/vm.lisp                  | 12 +++++++-----
 lisp/ppc-assem.S                      |  4 ++--
 lisp/ppc-lispregs.h                   | 14 +++++++-------
 4 files changed, 21 insertions(+), 14 deletions(-)
 create mode 100644 bootfiles/19c/boot-2005-12-1-ppc.lisp

diff --git a/bootfiles/19c/boot-2005-12-1-ppc.lisp b/bootfiles/19c/boot-2005-12-1-ppc.lisp
new file mode 100644
index 000000000..de3b2f9f8
--- /dev/null
+++ b/bootfiles/19c/boot-2005-12-1-ppc.lisp
@@ -0,0 +1,5 @@
+;; This is a cross-compile script for ppc/darwin for moving the FDEFN
+;; register.  R10 is an integer arg register for calling C, so FDEFN
+;; shouldn't be there.
+
+(load "target:tools/cross-scripts/cross-ppc-ppc-darwin")
diff --git a/compiler/ppc/vm.lisp b/compiler/ppc/vm.lisp
index f5e5faec9..b7d438f09 100644
--- a/compiler/ppc/vm.lisp
+++ b/compiler/ppc/vm.lisp
@@ -7,7 +7,7 @@
 ;;; Scott Fahlman or slisp-group@cs.cmu.edu.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/ppc/vm.lisp,v 1.3 2004/07/25 18:15:52 pmai Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/ppc/vm.lisp,v 1.4 2005/12/11 03:45:36 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -45,6 +45,8 @@
 (defreg zero 0)
 (defreg nsp 1)
 (defreg rtoc 2)                         ; May be "NULL" someday.
+;; r3-r10 are used for the C calling convention.  They should be
+;; non-descriptors.
 (defreg nl0 3)
 (defreg nl1 4)
 (defreg nl2 5)
@@ -52,7 +54,7 @@
 (defreg nl4 7)
 (defreg nl5 8)
 (defreg nl6 9)
-(defreg fdefn 10)
+(defreg nl7 10)
 (defreg nargs 11)
 ;;; The following two registers were originally reversed in the PPC Linux
 ;;; port.  Putting the address of the called function in GPR12 is however
@@ -78,14 +80,14 @@
 (defreg a3 27)
 (defreg l0 28)
 (defreg l1 29)
-(defreg l2 30)
+(defreg fdefn 30)
 (defreg lip 31)
 
 (defregset non-descriptor-regs
-  nl0 nl1 nl2 nl3 nl4 nl5 nl6 cfunc nargs nfp)
+  nl0 nl1 nl2 nl3 nl4 nl5 nl6 nl7 cfunc nargs nfp)
 
 (defregset descriptor-regs
-  fdefn a0 a1 a2 a3  ocfp lra cname lexenv l0 l1 l2 )
+  fdefn a0 a1 a2 a3  ocfp lra cname lexenv l0 l1 )
 
 (defregset register-arg-offsets
   a0 a1 a2 a3)
diff --git a/lisp/ppc-assem.S b/lisp/ppc-assem.S
index f5cb68bd9..433d00a3f 100644
--- a/lisp/ppc-assem.S
+++ b/lisp/ppc-assem.S
@@ -197,7 +197,7 @@ x:
 	li reg_A3,0
 	li reg_L0,0
 	li reg_L1,0
-	li reg_L2,0
+/*	li reg_L2,0*/
 	li reg_LIP,0
 	lis reg_NULL,hi16(NIL)
 	ori reg_NULL,reg_NULL,lo16(NIL)
@@ -362,7 +362,7 @@ lra:
 	li reg_A3,0
 	li reg_L0,0
 	li reg_L1,0
-	li reg_L2,0
+/*	li reg_L2,0*/
 	li reg_LIP,0
 
 	/* Atomic ... */
diff --git a/lisp/ppc-lispregs.h b/lisp/ppc-lispregs.h
index 1514ab839..3a55e0822 100644
--- a/lisp/ppc-lispregs.h
+++ b/lisp/ppc-lispregs.h
@@ -25,7 +25,7 @@
 #define reg_NL4       REG(7)
 #define reg_NL5       REG(8)
 #define reg_NL6       REG(9)
-#define reg_FDEFN     REG(10)	/* Last (8th) FF param */
+#define reg_NL7       REG(10)	/* Last (8th) FF param */
 #define reg_NARGS     REG(11)
 #define reg_CFUNC     REG(12)	/* Silly to blow a reg on FF-name */
 #define reg_NFP       REG(13)	/* Lisp may save around FF-call */
@@ -45,7 +45,7 @@
 #define reg_A3        REG(27)	/* Last of (only) 4 arg regs */
 #define reg_L0	      REG(28)	/* Tagged temp regs */
 #define reg_L1        REG(29)
-#define reg_L2        REG(30)	/* Last lisp temp reg */
+#define reg_FDEFN     REG(30)
 #define reg_LIP       REG(31)	/* Lisp Interior Pointer, e.g., locative */
 
 /*
@@ -63,7 +63,7 @@
 #define reg_NL4_NUM       7
 #define reg_NL5_NUM       8
 #define reg_NL6_NUM       9
-#define reg_FDEFN_NUM     10	/* Last (8th) FF param */
+#define reg_NL7_NUM       10	/* Last (8th) FF param */
 #define reg_NARGS_NUM     11
 #define reg_CFUNC_NUM     12	/* Silly to blow a reg on FF-name */
 #define reg_NFP_NUM       13	/* Lisp may save around FF-call */
@@ -83,23 +83,23 @@
 #define reg_A3_NUM        27	/* Last of (only) 4 arg regs */
 #define reg_L0_NUM	  28	/* Tagged temp regs */
 #define reg_L1_NUM        29
-#define reg_L2_NUM        30	/* Last lisp temp reg */
+#define reg_FDEFN_NUM     30
 #define reg_LIP_NUM       31	/* Lisp Interior Pointer, e.g., locative */
 
 #define REGNAMES \
         "ZERO",		"NSP",	        "POLL",		"NL0", \
 	"NL1",		"NL2",		"NL3P",		"NL4", \
-        "NL5",		"NL6",		"FDEFN",	"NARGS", \
+        "NL5",		"NL6",		"NL7",		"NARGS", \
         "CFUNC",	"NFP"		"BSP",		"CFP", \
         "CSP",		"ALLOC",	"NULL",		"CODE", \
         "CNAME",	"LEXENV",	"OCFP",		"LRA", \
         "A0",	        "A1",	        "A2",		"A3", \
-        "L0",		"L1",		"L2",		"LIP"
+        "L0",		"L1",		"FDEFN",	"LIP"
 
 #define BOXED_REGISTERS { \
     reg_FDEFN, reg_CODE, reg_CNAME, reg_LEXENV, reg_OCFP, reg_LRA, \
     reg_A0, reg_A1, reg_A2, reg_A3, \
-    reg_L0, reg_L1, reg_L2 \
+    reg_L0, reg_L1 \
 }
 
 #ifndef LANGUAGE_ASSEMBLY
-- 
GitLab