summary refs log tree commit diff
path: root/arm64
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2017-05-17 09:40:07 -0400
committerQuentin Carbonneaux <quentin@c9x.me>2017-05-17 10:05:28 -0400
commita3a1451c5fabb5c94f7fbeb13fdc6b1e2c23181f (patch)
tree1fb1ba60e8f3cab09c629ce9dd63e00e01974c39 /arm64
parent2d02070af019e9896ecf2a63bedc098092fd395d (diff)
downloadroux-a3a1451c5fabb5c94f7fbeb13fdc6b1e2c23181f.tar.gz
intern symbol names
Symbols in the source file are still limited in
length because the rest of the code assumes that
strings always fit in NString bytes.

Regardless, there is already a benefit because
comparing/copying symbol names does not require
using strcmp()/strcpy() anymore.
Diffstat (limited to 'arm64')
-rw-r--r--arm64/emit.c4
-rw-r--r--arm64/isel.c4
2 files changed, 5 insertions, 3 deletions
diff --git a/arm64/emit.c b/arm64/emit.c
index 1b71179..8211c4f 100644
--- a/arm64/emit.c
+++ b/arm64/emit.c
@@ -244,9 +244,9 @@ loadcon(Con *c, int r, int k, FILE *f)
 			off[0] = 0;
 		p = c->local ? ".L" : "";
 		fprintf(f, "\tadrp\t%s, %s%s%s\n",
-			rn, p, c->label, off);
+			rn, p, str(c->label), off);
 		fprintf(f, "\tadd\t%s, %s, #:lo12:%s%s%s\n",
-			rn, rn, p, c->label, off);
+			rn, rn, p, str(c->label), off);
 		return;
 	}
 	assert(c->type == CBits);
diff --git a/arm64/isel.c b/arm64/isel.c
index 2d4e995..7ab368f 100644
--- a/arm64/isel.c
+++ b/arm64/isel.c
@@ -69,6 +69,7 @@ Check:
 static void
 fixarg(Ref *pr, int k, int phi, Fn *fn)
 {
+	char buf[32];
 	Ref r0, r1, r2;
 	int s, n;
 	Con *c;
@@ -86,8 +87,9 @@ fixarg(Ref *pr, int k, int phi, Fn *fn)
 			n = gasstashfp(c->bits.i, KWIDE(k));
 			vgrow(&fn->con, ++fn->ncon);
 			c = &fn->con[fn->ncon-1];
+			sprintf(buf, "fp%d", n);
 			*c = (Con){.type = CAddr, .local = 1};
-			sprintf(c->label, "fp%d", n);
+			c->label = intern(buf);
 			r2 = newtmp("isel", Kl, fn);
 			emit(Oload, k, r1, r2, R);
 			emit(Ocopy, Kl, r2, CON(c-fn->con), R);