shithub: mc

Download patch

ref: ced0753bec92450b81816e9f33badb1a9a57a1ff
parent: e091f0e5c9f334e0a0c35fd56d5805bb2464eea0
parent: a7124a8f1ea92ff0aac1fa2dc7a2a573e0643ffa
author: Ori Bernstein <[email protected]>
date: Tue Jul 24 16:24:05 EDT 2012

Merge branch 'master' of git+ssh://mimir.eigenstate.org/git/ori/mc2

--- a/8/isel.c
+++ b/8/isel.c
@@ -871,5 +871,7 @@
     epilogue(&is);
     regalloc(&is);
 
+    if (debug)
+        writeasm(stdout, &is, fn);
     writeasm(fd, &is, fn);
 }
--- a/8/ra.c
+++ b/8/ra.c
@@ -18,6 +18,8 @@
     int r[Maxarg + 1];
 };
 
+static void printedge(FILE *fd, char *msg, size_t a, size_t b);
+
 Usage usetab[] = {
 #define Use(...) {__VA_ARGS__}
 #define Insn(i, fmt, use, def) use,
@@ -530,13 +532,8 @@
     size_t i, j;
     int has;
 
-    if (debugopt['r']) {
-        printf("Combine ");
-        locprint(stdout, locmap[u], 'x');
-        printf(" ==> ");
-        locprint(stdout, locmap[v], 'x');
-        printf("\n");
-    }
+    if (debugopt['r'])
+        printedge(stdout, "combining:", u, v);
     if (wlhas(s->wlfreeze, s->nwlfreeze, v, &idx))
         ldel(&s->wlfreeze, &s->nwlfreeze, idx);
     else if (wlhas(s->wlspill, s->nwlspill, v, &idx))
@@ -558,7 +555,9 @@
     }
 
     for (t = 0; adjiter(s, v, &t); t++) {
-        gbputedge(s, t, u);
+        if (debugopt['r'])
+            printedge(stdout, "combine-putedge:", v, t);
+        addedge(s, t, u);
         decdegree(s, t);
     }
     if (s->degree[u] >= K && wlhas(s->wlfreeze, s->nwlfreeze, u, &idx)) {
@@ -687,7 +686,9 @@
         bzero(taken, K*sizeof(int));
         n = lpop(&s->selstk, &s->nselstk);
 
-        for (l = 0; adjiter(s, n->reg.id, &l); l++) {
+        for (l = 0; bsiter(s->gadj[n->reg.id], &l); l++) {
+            if (debugopt['r'] > 1)
+                printedge(stdout, "paint-edge:", n->reg.id, l);
             w = locmap[getalias(s, l)];
             if (w->reg.colour)
                 taken[colourmap[w->reg.colour]] = 1;
@@ -697,8 +698,9 @@
         for (i = 0; i < K; i++) {
             if (!taken[i]) {
                 if (debugopt['r']) {
+                    fprintf(stdout, "\tselecting ");
                     locprint(stdout, n, 'x');
-                    printf(" ==> %s\n", regnames[regmap[i][n->mode]]);
+                    fprintf(stdout, " = %s\n", regnames[regmap[i][n->mode]]);
                 }
                 n->reg.colour = regmap[i][n->mode];
                 found = 1;
@@ -786,6 +788,15 @@
     fprintf(fd, "\n");
 }
 
+static void printedge(FILE *fd, char *msg, size_t a, size_t b)
+{
+    fprintf(fd, "\t%s ", msg);
+    locprint(fd, locmap[a], 'x');
+    fprintf(fd, " -- ");
+    locprint(fd, locmap[b], 'x');
+    fprintf(fd, "\n");
+}
+
 void dumpasm(Isel *s, FILE *fd)
 {
     size_t i, j;
@@ -795,12 +806,8 @@
     fprintf(fd, "IGRAPH ----- \n");
     for (i = 0; i < maxregid; i++) {
         for (j = i; j < maxregid; j++) {
-            if (gbhasedge(s, i, j)) {
-                locprint(fd, locmap[i], 'x');
-                fprintf(fd, " -- ");
-                locprint(fd, locmap[j], 'x');
-                fprintf(fd, "\n");
-            }
+            if (gbhasedge(s, i, j))
+                printedge(stdout, "", i, j);
         }
     }
     fprintf(fd, "ASM -------- \n");
--- a/8/simp.c
+++ b/8/simp.c
@@ -1246,12 +1246,6 @@
     if (!fd)
         die("Couldn't open fd %s", out);
 
-    if (debug) {
-        for (i = 0; i < nblob; i++)
-            genblob(stdout, blob[i], globls);
-        for (i = 0; i < nfn; i++)
-            genasm(stdout, fn[i], globls);
-    }
     fprintf(fd, ".data\n");
     for (i = 0; i < nblob; i++)
         genblob(fd, blob[i], globls);