shithub: mc

Download patch

ref: 13e55845018e40a4e943891a2cb371bc2a9cd572
parent: 14f1055a8f6709a4740ae23cde2e72e45327fcfc
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Dec 26 11:22:33 EST 2014

Handle localness of labels a bit differently.

    use asmname() more liberally. it does the right thign.

--- a/6/asm.h
+++ b/6/asm.h
@@ -210,8 +210,8 @@
 extern size_t maxregid;
 extern Loc **locmap; /* mapping from reg id => Loc * */
 
-char *gendatalbl(char *buf, size_t sz);
-char *genjmplbl(char *buf, size_t sz);
+char *genlocallblstr(char *buf, size_t sz);
+char *genlblstr(char *buf, size_t sz);
 Node *genlbl(Srcloc loc);
 Loc *loclbl(Node *lbl);
 Loc *locstrlbl(char *lbl);
--- a/6/gen.c
+++ b/6/gen.c
@@ -24,7 +24,7 @@
 }
 
 static int nextlbl;
-char *gendatalbl(char *buf, size_t sz)
+char *genlocallblstr(char *buf, size_t sz)
 {
     if (asmsyntax == Plan9)
         snprintf(buf, 128, ".L%d<>", nextlbl++);
@@ -33,7 +33,7 @@
     return buf;
 }
 
-char *genjmplbl(char *buf, size_t sz)
+char *genlblstr(char *buf, size_t sz)
 {
     snprintf(buf, 128, ".L%d", nextlbl++);
     return buf;
--- a/6/gengas.c
+++ b/6/gengas.c
@@ -293,7 +293,7 @@
            if (hthas(strtab, &v->lit.strval)) {
                lbl = htget(strtab, &v->lit.strval);
            } else {
-               lbl = gendatalbl(buf, sizeof buf);
+               lbl = genlocallblstr(buf, sizeof buf);
                htput(strtab, &v->lit.strval, strdup(lbl));
            }
            fprintf(fd, "\t.quad %s\n", lbl);
--- a/6/genp9.c
+++ b/6/genp9.c
@@ -298,7 +298,7 @@
            if (hthas(strtab, &v->lit.strval)) {
                lbl = htget(strtab, &v->lit.strval);
            } else {
-               lbl = gendatalbl(buf, sizeof buf);
+               lbl = genlocallblstr(buf, sizeof buf);
                htput(strtab, &v->lit.strval, strdup(lbl));
            }
            if (v->lit.strval.len > 0)
@@ -361,7 +361,7 @@
 
     lbl = htget(globls, base);
     fprintf(fd, "DATA %s+%zd(SB)/8,$%s+%zd(SB)\n", name, off, lbl, loval*sz);
-    fprintf(fd, "DATA %s+%zd(SB)/8,$%zd\n", name, off, (hival - loval));
+    fprintf(fd, "DATA %s+%zd(SB)/8,$%zd\n", name, off + Ptrsz, (hival - loval));
     return size(n);
 }
 
--- a/6/locs.c
+++ b/6/locs.c
@@ -35,7 +35,7 @@
 {
     char buf[128];
 
-    genjmplbl(buf, 128);
+    genlblstr(buf, 128);
     return mklbl(loc, buf);
 }
 
--- a/6/simp.c
+++ b/6/simp.c
@@ -688,7 +688,7 @@
     Node *n, *d, *r;
     char lbl[128];
 
-    n = mkname(blob->loc, gendatalbl(lbl, 128));
+    n = mkname(blob->loc, genlblstr(lbl, 128));
     d = mkdecl(blob->loc, n, blob->expr.type);
     r = mkexpr(blob->loc, Ovar, n, NULL);
 
@@ -695,7 +695,7 @@
     d->decl.init = blob;
     d->decl.type = blob->expr.type;
     d->decl.isconst = 1;
-    htput(s->globls, d, strdup(lbl));
+    htput(s->globls, d, asmname(d));
 
     r->expr.did = d->decl.did;
     r->expr.type = blob->expr.type;
--- a/mkfile
+++ b/mkfile
@@ -40,7 +40,7 @@
 		mk $MKFLAGS
 	}
 
-check:V:
+check:V: all
 	cd test
 	mk check