shithub: mc

Download patch

ref: f4f2253f78a010e8ba652c405e611e5524fc19f7
parent: ea5a4f8b5cea8d90491e6568d208dd656676bf61
author: Ori Bernstein <[email protected]>
date: Sun Jul 22 10:31:27 EDT 2012

Fix bad instruction generation.

    - Fixed name for setl (we called it setlt)
    - Disallowed generation of movzbb and similar.

--- a/8/insns.def
+++ b/8/insns.def
@@ -47,7 +47,7 @@
 /* branch instructions */
 Insn(Isetz,     "\tsetz  %v\n",                 Use(),  Def(.l={1}))
 Insn(Isetnz,    "\tsetnz %v\n",                 Use(),  Def(.l={1}))
-Insn(Isetlt,    "\tsetlt %v\n",                 Use(),  Def(.l={1}))
+Insn(Isetl,     "\tsetl  %v\n",                 Use(),  Def(.l={1}))
 Insn(Isetle,    "\tsetle %v\n",                 Use(),  Def(.l={1}))
 Insn(Isetgt,    "\tsetgt %v\n",                 Use(),  Def(.l={1}))
 Insn(Isetge,    "\tsetge %v\n",                 Use(),  Def(.l={1}))
--- a/8/isel.c
+++ b/8/isel.c
@@ -44,7 +44,7 @@
     [One] = {Icmp, Ijnz, Isetnz},
     [Ogt] = {Icmp, Ijg, Isetgt},
     [Oge] = {Icmp, Ijge, Isetge},
-    [Olt] = {Icmp, Ijl, Isetlt},
+    [Olt] = {Icmp, Ijl, Isetl},
     [Ole] = {Icmp, Ijle, Isetle}
 };
 
@@ -158,6 +158,15 @@
     lappend(&s->curbb->il, &s->curbb->ni, i);
 }
 
+static void movz(Isel *s, Loc *src, Loc *dst)
+{
+    if (src->mode == dst->mode)
+        g(s, Imov, src, dst, NULL);
+    else
+        g(s, Imovz, src, dst, NULL);
+}
+
+
 static void load(Isel *s, Loc *a, Loc *b)
 {
     Loc *l;
@@ -511,7 +520,7 @@
             r = locreg(mode(n));
             g(s, reloptab[exprop(n)].test, a, a, NULL);
             g(s, reloptab[exprop(n)].getflag, b, NULL);
-            g(s, Imovz, b, r, NULL);
+            movz(s, b, r);
             break;
 
         case Oeq: case One: case Ogt: case Oge: case Olt: case Ole:
@@ -522,7 +531,7 @@
             r = locreg(mode(n));
             g(s, reloptab[exprop(n)].test, a, b, NULL);
             g(s, reloptab[exprop(n)].getflag, c, NULL);
-            g(s, Imovz, c, r, NULL);
+            movz(s, c, r);
             return r;
 
         case Oasn:  /* relabel */
--- a/util/muse.c
+++ b/util/muse.c
@@ -26,6 +26,7 @@
     printf("\t-I path\tAdd 'path' to use search path\n");
     printf("\t-d\tPrint debug dumps\n");
     printf("\t-o\tOutput to outfile\n");
+    printf("\t-s\tShow the contents of usefiles `inputs`\n");
 }
 
 
@@ -34,8 +35,6 @@
     int opt;
     int i;
     Stab *globls;
-    Node *rdback;
-    FILE *tmp;
     FILE *f;
 
     while ((opt = getopt(argc, argv, "d::ho:I:")) != -1) {
@@ -44,6 +43,9 @@
                 outfile = optarg;
                 break;
             case 'h':
+                usage(argv[0]);
+                exit(0);
+                break;
             case 'd':
                 debug = 1;
                 while (optarg && *optarg)
@@ -59,6 +61,16 @@
         }
     }
 
+    if (debugopt['s']) {
+        for (i = optind; i < argc; i++) {
+            globls = mkstab();
+            f = fopen(argv[i], "r");
+            readuse(file, globls);
+            dumpstab(globls, stdout);
+        }
+        exit(0);
+    }
+
     for (i = optind; i < argc; i++) {
         globls = mkstab();
         tyinit(globls);
@@ -69,20 +81,6 @@
         yyparse();
 
         infer(file);
-	/* before we do anything to the parse */
-        if (debugopt['p']) {
-            /* test storing tree to file */
-            tmp = fopen("a.pkl", "w");
-            pickle(file, tmp);
-            fclose(tmp);
-
-            /* and reading it back */
-            tmp = fopen("a.pkl", "r");
-            rdback = unpickle(tmp);
-            dump(rdback, stdout);
-            fclose(tmp);
-	    dump(file, stdout);
-        }
 	if (!outfile)
 	    die("need output file name right now. FIX THIS.");
 	f = fopen(outfile, "w");