From a3a1451c5fabb5c94f7fbeb13fdc6b1e2c23181f Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Wed, 17 May 2017 09:40:07 -0400 Subject: 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. --- arm64/emit.c | 4 ++-- arm64/isel.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'arm64') 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); -- cgit 1.4.1