aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <[email protected]>2025-03-15 14:22:59 +0100
committerQuentin Carbonneaux <[email protected]>2025-03-15 14:27:34 +0100
commit86d13b93e85ad9c11ae453529ab7b33896f39dd0 (patch)
treebc87a644afbdb21496f253adef048b8a75cc54a2
parentec5502645fe748b0b9b7aa0f1be8c96465620212 (diff)
arm64: use IP1 as scratch register
On Apple platforms x18 is not guaranteed to be preserved across context switches. So we now use IP1 as scratch register. En passant, one dubious use of IP0 in arm64/emit.c fixarg() was transitioned to IP1. I believe the previous code could clobber a user value if IP0 was live.
-rw-r--r--arm64/emit.c10
-rw-r--r--arm64/targ.c4
2 files changed, 7 insertions, 7 deletions
diff --git a/arm64/emit.c b/arm64/emit.c
index 28cd6a5..9b6cf0f 100644
--- a/arm64/emit.c
+++ b/arm64/emit.c
@@ -195,7 +195,7 @@ emitf(char *s, Ins *i, E *e)
goto Switch;
case '?':
if (KBASE(k) == 0)
- fputs(rname(R18, k), e->f);
+ fputs(rname(IP1, k), e->f);
else
fputs(k==Ks ? "s31" : "d31", e->f);
break;
@@ -346,9 +346,9 @@ fixarg(Ref *pr, int sz, E *e)
if (rtype(r) == RSlot) {
s = slot(r, e);
if (s > sz * 4095u) {
- i = &(Ins){Oaddr, Kl, TMP(IP0), {r}};
+ i = &(Ins){Oaddr, Kl, TMP(IP1), {r}};
emitins(i, e);
- *pr = TMP(IP0);
+ *pr = TMP(IP1);
}
}
}
@@ -393,7 +393,7 @@ emitins(Ins *i, E *e)
if (rtype(i->to) == RSlot) {
r = i->to;
if (!isreg(i->arg[0])) {
- i->to = TMP(R18);
+ i->to = TMP(IP1);
emitins(i, e);
i->arg[0] = i->to;
}
@@ -414,7 +414,7 @@ emitins(Ins *i, E *e)
emitins(i, e);
break;
default:
- assert(i->to.val != R18);
+ assert(i->to.val != IP1);
goto Table;
}
break;
diff --git a/arm64/targ.c b/arm64/targ.c
index 232376d..4c2643a 100644
--- a/arm64/targ.c
+++ b/arm64/targ.c
@@ -16,7 +16,7 @@ int arm64_rclob[] = {
-1
};
-#define RGLOB (BIT(FP) | BIT(SP) | BIT(R18))
+#define RGLOB (BIT(FP) | BIT(SP) | BIT(IP1) | BIT(R18))
static int
arm64_memargs(int op)
@@ -31,7 +31,7 @@ arm64_memargs(int op)
.fpr0 = V0, \
.nfpr = NFPR, \
.rglob = RGLOB, \
- .nrglob = 3, \
+ .nrglob = 4, \
.rsave = arm64_rsave, \
.nrsave = {NGPS, NFPS}, \
.retregs = arm64_retregs, \