shithub: mc

Download patch

ref: 686c217308daa55a0fbe9ace3258767b80b6ba5b
parent: d8c6d1da46db43dd973a51bbd370549d7d98e773
author: Ori Bernstein <[email protected]>
date: Sun Dec 21 16:31:33 EST 2014

More work towards plan9 workingness.

--- a/6/genp9.c
+++ b/6/genp9.c
@@ -90,23 +90,34 @@
         if (l->mem.constdisp)
             fprintf(fd, "%ld", l->mem.constdisp);
     } else {
-        if (l->mem.lbldisp)
-            fprintf(fd, "%s", l->mem.lbldisp);
+        if (l->mem.lbldisp) {
+            if (l->mem.base)
+                fprintf(fd, "$%s", l->mem.lbldisp);
+            else
+                fprintf(fd, "%s", l->mem.lbldisp);
+        }
     }
-    if (l->mem.base && l->mem.base->reg.colour != Rrip) {
-        fprintf(fd, "(");
-        locprint(fd, l->mem.base, 'r');
-        if (l->mem.idx) {
-            fprintf(fd, ",");
-            locprint(fd, l->mem.idx, 'r');
+    if (l->mem.base) {
+        if (l->mem.base->reg.colour == Rrip) {
+            fprintf(fd, "+0(SB)");
+        } else {
+            fprintf(fd, "(");
+            locprint(fd, l->mem.base, 'r');
+            if (l->mem.idx) {
+                fprintf(fd, ",");
+                locprint(fd, l->mem.idx, 'r');
+            }
+            if (l->mem.scale > 1)
+                fprintf(fd, ",%d", l->mem.scale);
+            if (l->mem.base)
+                fprintf(fd, ")");
         }
-        if (l->mem.scale > 1)
-            fprintf(fd, ",%d", l->mem.scale);
-        if (l->mem.base)
-            fprintf(fd, ")");
     } else if (l->type != Locmeml) {
         die("Only locmeml can have unspecified base reg");
+    } else {
+        fprintf(fd, "+0(SB)");
     }
+
 }
 
 static void locprint(FILE *fd, Loc *l, char spec)
@@ -312,7 +323,7 @@
                lbl = genlblstr(buf, sizeof buf);
                htput(strtab, &v->lit.strval, strdup(lbl));
            }
-           fprintf(fd, "DATA %s+%zd(SB)/8,%s<>+0(SB)\n", name, off, lbl);
+           fprintf(fd, "DATA %s+%zd(SB)/8,$%s<>+0(SB)\n", name, off, lbl);
            fprintf(fd, "DATA %s+%zd(SB)/8,$%zd\n", name, off+8, v->lit.strval.len);
            break;
         case Lfunc:
@@ -343,7 +354,7 @@
     return n->lit.intval;
 }
 
-static size_t writeslice(FILE *fd, Htab *globls, Htab *strtab, Node *n)
+static size_t writeslice(FILE *fd, char *name, size_t off, Htab *globls, Htab *strtab, Node *n)
 {
     Node *base, *lo, *hi;
     ssize_t loval, hival, sz;
@@ -363,8 +374,8 @@
     sz = tysize(tybase(exprtype(base))->sub[0]);
 
     lbl = htget(globls, base);
-    fprintf(fd, "\t.quad %s + (%zd*%zd)\n", lbl, loval, sz);
-    fprintf(fd, "\t.quad %zd\n", (hival - loval));
+    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));
     return size(n);
 }
 
@@ -416,7 +427,7 @@
             sz = writelit(fd, name, off, strtab, n->expr.args[0], exprtype(n));
             break;
         case Oslice:
-            sz = writeslice(fd, globls, strtab, n);
+            sz = writeslice(fd, name, off, globls, strtab, n);
             break;
         default:
             dump(n, stdout);
@@ -467,8 +478,7 @@
     assert(blob->type == Ndecl);
 
     lbl = htget(globls, blob);
-    if (blob->decl.vis != Visintern)
-        fprintf(fd, "GLOBL %s,%zd\n", lbl, size(blob));
+    fprintf(fd, "GLOBL %s+0(SB),$%zd\n", lbl, size(blob));
     if (blob->decl.init)
         writeblob(fd, lbl, 0, globls, strtab, blob->decl.init);
     else
--- a/6/mkfile
+++ b/6/mkfile
@@ -1,15 +1,20 @@
 </$objtype/mkfile
 CC=pcc
-CFLAGS=-c -D_POSIX_SOURCE -D_SUSV2_SOURCE -D_C99_SNPRINTF_EXTENSION -I../parse -I../opt
-LDFLAGS=-L../parse -lparse -L../opt -lopt 
+CFLAGS=-c -D_POSIX_SOURCE -D_SUSV2_SOURCE -D_C99_SNPRINTF_EXTENSION -I../parse -I../mi
+LDFLAGS=-L../parse -lparse -L../mi -lmi
 
 TARG=6m
-OFILES=isel.$O \
-    locs.$O \
-    main.$O \
-    ra.$O \
-    simp.$O \
+OFILES=\
+	gen.$O\
+	gengas.$O\
+	genp9.$O\
+	isel.$O\
+	locs.$O\
+	main.$O\
+	ra.$O\
+	simp.$O\
+	typeinfo.$O\
 
-LIB=../parse/libparse.a ../opt/libopt.a
+LIB=../parse/libparse.a ../mi/libmi.a
 
-</sys/src/cmd/mkone
\ No newline at end of file
+</sys/src/cmd/mkone
--- a/mi/mkfile
+++ b/mi/mkfile
@@ -3,12 +3,12 @@
 LD=pcc
 CFLAGS=-c -D_POSIX_SOURCE -D_SUSV2_SOURCE -D_C99_SNPRINTF_EXTENSION -I../parse
 
-LIB=libopt.a
+LIB=libmi.a
 OFILES=cfg.$O \
     fold.$O \
     df.$O
 
-HFILES=opt.h
+HFILES=mi.h
 
 </sys/src/cmd/mklib
 
--- a/mkfile
+++ b/mkfile
@@ -1,7 +1,7 @@
 </$objtype/mkfile
 
 SUB = parse \
-      opt \
+      mi \
       6 \
       muse \
       myrbuild \