shithub: mc

Download patch

ref: 829925518e7c2124085b80334765351b6645e066
parent: 1322203e42cf437adb88ff233bf8955a3d68aac6
author: Ori Bernstein <[email protected]>
date: Thu Jun 7 06:37:37 EDT 2012

More instructions implemented.

    ~x and *x should now work.

--- a/8/insns.def
+++ b/8/insns.def
@@ -30,6 +30,7 @@
 Insn(Iand,      "\tand%t %r,%x\n",              0)
 Insn(Ior,       "\tor%t %r,%x\n",               0)
 Insn(Ixor,      "\txor%t %r,%x\n",              0)
+Insn(Inot,      "\tnot%t %x\n",              0)
 Insn(Ishl,      "\tsal%1t %r,%x\n",              0)
 Insn(Isar,      "\tshr%1t %r,%x\n",              0)
 Insn(Ishr,      "\tshr%1t %r,%x\n",              0)
--- a/8/isel.c
+++ b/8/isel.c
@@ -360,6 +360,15 @@
         return inr(s, a);
 }
 
+/* ensures that a location is within a reg or an imm */
+Loc inrm(Isel *s, Loc a)
+{
+    if (a.type == Locreg || a.type == Locmem)
+        return a;
+    else
+        return inr(s, a);
+}
+
 /* If we're testing equality, etc, it's a bit silly
  * to generate the test, store it to a bite, expand it
  * to the right width, and then test it again. Try to optimize
@@ -584,9 +593,20 @@
             freeloc(s, b);
             r = a;
             break;
-        case Obnot:     die("Unimplemented op %s", opstr(exprop(n))); break;
+        case Obnot:
+            r = selexpr(s, args[0]);
+            r = inrm(s, r);
+            g(s, Inot, &r, NULL);
+            break;
 
-        case Oderef:    die("Unimplemented op %s", opstr(exprop(n))); break;
+        case Oderef:
+            a = selexpr(s, args[0]);
+            a = inr(s, a);
+            r = getreg(s, a.mode);
+            locmem(&c, 0, a.reg, Rnone, a.mode);
+            g(s, Imov, &c, &r, NULL);
+            break;
+
         case Oaddr:
             a = selexpr(s, args[0]);
             r = getreg(s, ModeL);