ref: 335908ff6d49b6ee4da3803b2c44f23916a9047f
parent: 375ca707e7a2701421a7901873f3f61f23f223c4
author: Ori Bernstein <[email protected]>
date: Mon Nov 10 13:43:38 EST 2014
Operator shuffling. Preparation for better compilation of match statements.
--- a/6/isel.c
+++ b/6/isel.c
@@ -668,6 +668,9 @@
case Ocjmp:
selcjmp(s, n, args);
break;
+ case Ojtab:
+ die("jump tables not yet implemented\n");
+ break;
case Olit: /* fall through */
r = loc(s, n);
break;
@@ -680,9 +683,6 @@
r = loc(s, n);
}
break;
- case Olbl:
- r = loclbl(args[0]);
- break;
case Oblit:
a = selexpr(s, args[0]);
r = selexpr(s, args[1]);
@@ -740,10 +740,11 @@
case Opostdec: case Olor: case Oland: case Oaddeq:
case Osubeq: case Omuleq: case Odiveq: case Omodeq: case Oboreq:
case Obandeq: case Obxoreq: case Obsleq: case Obsreq: case Omemb:
- case Oslice: case Oidx: case Osize: case Numops:
- case Oucon: case Ouget: case Otup: case Oarr: case Ostruct:
- case Oslbase: case Osllen: case Ocast:
- case Obreak: case Ocontinue:
+ case Oslbase: case Osllen: case Ocast: case Outag: case Oudata:
+ case Oucon: case Otup: case Oarr: case Ostruct:
+ case Oslice: case Oidx: case Osize:
+ case Obreak: case Ocontinue:
+ case Numops:
dump(n, stdout);
die("Should not see %s in isel", opstr(exprop(n)));
break;
--- a/6/simp.c
+++ b/6/simp.c
@@ -1291,7 +1291,10 @@
case Oucon:
r = simpucon(s, n, dst);
break;
- case Ouget:
+ case Outag:
+ die("union tags not yet supported\n");
+ break;
+ case Oudata:
r = simpuget(s, n, dst);
break;
case Otup:
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1437,11 +1437,8 @@
}
settype(st, n, type(st, args[0]));
break;
- case Olbl: /* :lbl -> void* */
- infersub(st, n, ret, sawret, &isconst);
- settype(st, n, mktyptr(n->loc, mktype(Zloc, Tyvoid)));
- case Obad: case Ocjmp: case Oset:
- case Oslbase: case Osllen:
+ case Obad: case Ocjmp: case Ojtab: case Oset:
+ case Oslbase: case Osllen: case Outag:
case Oblit: case Numops:
case Otrunc: case Oswiden: case Ozwiden:
case Oint2flt: case Oflt2int: case Oflt2flt:
@@ -1448,7 +1445,7 @@
case Ofadd: case Ofsub: case Ofmul: case Ofdiv: case Ofneg:
case Ofeq: case Ofne: case Ofgt: case Ofge: case Oflt: case Ofle:
case Oueq: case Oune: case Ougt: case Ouge: case Oult: case Oule:
- case Ouget:
+ case Oudata:
die("Should not see %s in fe", opstr(exprop(n)));
break;
}
--- a/parse/ops.def
+++ b/parse/ops.def
@@ -50,9 +50,7 @@
O(Ocontinue, 0)
O(Ovar, 1)
O(Olit, 1)
-O(Olbl, 1)
O(Oucon, 1)
-O(Ouget, 1)
O(Otup, 1)
O(Ostruct, 1)
O(Oarr, 1)
@@ -59,16 +57,25 @@
/* all below this point are backend-only */
O(Ocjmp, 1) /* conditional jump */
+O(Ojtab, 1) /* jump table */
O(Oset, 1) /* store to var */
O(Osllen, 1) /* size of slice */
O(Oslbase, 1) /* base of sice */
-O(Oblit, 1) /* block copy of memory */
+O(Outag, 1) /* tag of union */
+O(Oudata, 1) /* pointer to contents of union */
+O(Oblit, 1) /* blit memory */
+
+/* integer conversions */
O(Otrunc, 1) /* truncating cast */
O(Ozwiden, 1) /* zero-extending widening cast */
O(Oswiden, 1) /* sign-extending widening cast */
+
+/* float conversions */
O(Oflt2int, 1) /* float to int conversion */
O(Oint2flt, 1) /* int to float conversion */
O(Oflt2flt, 1) /* flt32<->flt64 conversion */
+
+/* floating arithmetic */
O(Ofadd, 1)
O(Ofsub, 1)
O(Ofmul, 1)
@@ -82,6 +89,7 @@
O(Ofge, 1)
O(Oflt, 1)
O(Ofle, 1)
+
/* unsigned comparisons */
O(Oueq, 1)
O(Oune, 1)