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. --- amd64/emit.c | 8 ++++---- amd64/isel.c | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'amd64') diff --git a/amd64/emit.c b/amd64/emit.c index eccbd02..cd485bb 100644 --- a/amd64/emit.c +++ b/amd64/emit.c @@ -161,12 +161,12 @@ slot(int s, Fn *fn) static void emitcon(Con *con, FILE *f) { + char *p; + switch (con->type) { case CAddr: - if (con->local) - fprintf(f, "%s%s", gasloc, con->label); - else - fprintf(f, "%s%s", gassym, con->label); + p = con->local ? gasloc : gassym; + fprintf(f, "%s%s", p, str(con->label)); if (con->bits.i) fprintf(f, "%+"PRId64, con->bits.i); break; diff --git a/amd64/isel.c b/amd64/isel.c index 0dbaad3..39fc9e8 100644 --- a/amd64/isel.c +++ b/amd64/isel.c @@ -61,6 +61,7 @@ rslot(Ref r, Fn *fn) static void fixarg(Ref *r, int k, int op, Fn *fn) { + char buf[32]; Addr a, *m; Ref r0, r1; int s, n, cpy, mem; @@ -80,7 +81,8 @@ fixarg(Ref *r, int k, int op, Fn *fn) a.offset.type = CAddr; a.offset.local = 1; n = gasstashfp(fn->con[r0.val].bits.i, KWIDE(k)); - sprintf(a.offset.label, "fp%d", n); + sprintf(buf, "fp%d", n); + a.offset.label = intern(buf); fn->mem[fn->nmem-1] = a; } else if (!cpy && k == Kl && noimm(r0, fn)) { -- cgit 1.4.1