ref: 001eb2aee8d88faa8186c858e503c6ea80b1e145
parent: 0c574aa0d1cf26d51211668522db935da52a5ebe
parent: b2fa7003bf8809ce27699c88eecce4b55618dd5f
author: Ori Bernstein <[email protected]>
date: Tue Jul 31 07:41:01 EDT 2012
Merge branch 'master' of git+ssh://mimir.eigenstate.org/git/ori/mc2 Conflicts: 6/simp.c
--- a/6/asm.h
+++ b/6/asm.h
@@ -1,4 +1,5 @@
#define Maxarg 4 /* maximum number of args an insn can have */
+#define Wordsz 4 /* the size of a "natural int" */
#define Ptrsz 8 /* the size of a machine word (ie, pointer size) */
#define K 14 /* the number of allocatable registers */
--- a/6/simp.c
+++ b/6/simp.c
@@ -54,6 +54,7 @@
/* useful constants */
static Type *tyintptr;
+static Type *tyword;
static Type *tyvoid;
static Type *base(Type *t)
@@ -151,6 +152,15 @@
return n;
}
+static Node *word(int line, uint v)
+{
+ Node *n;
+
+ n = mkintlit(line, v);
+ n->expr.type = tyword;
+ return n;
+}
+
static void append(Simp *s, Node *n)
{
lappend(&s->stmts, &s->nstmts, n);
@@ -412,10 +422,10 @@
Ucon *uc;
if (exprop(n) != Ocons)
- return load(add(addr(n, tyintptr), disp(n->line, off)));
+ return load(addk(addr(n, mkty(n->line, Tyuint)), off));
uc = finducon(n);
- return disp(uc->line, uc->id);
+ return word(uc->line, uc->id);
}
static Node *uval(Node *n, size_t off, Type *t)
@@ -463,7 +473,7 @@
r = mkexpr(a->line, Oeq, x, y, NULL);
r->expr.type = tyintptr;
if (uc->etype) {
- off += Ptrsz;
+ off += Wordsz;
v = ucompare(s, a, b, uc->etype, off);
r = mkexpr(a->line, Oland, r, v, NULL);
r->expr.type = tyintptr;
@@ -887,14 +897,19 @@
tmp = dst;
else
tmp = temp(s, n);
- u = addr(tmp, exprtype(n));
- tag = disp(n->line, uc->id);
+
+ /* Set the tag on the ucon */
+ u = addr(tmp, mkty(n->line, Tyuint));
+ tag = mkintlit(n->line, uc->id);
+ tag->expr.type = mkty(n->line, Tyuint);
append(s, store(u, tag));
+
+
+ /* fill the value, if needed */
if (!uc->etype)
return tmp;
-
elt = rval(s, n->expr.args[1], NULL);
- u = addk(u, Ptrsz);
+ u = addk(u, Wordsz);
if (stacktype(uc->etype)) {
elt = addr(elt, uc->etype);
sz = disp(n->line, tysize(uc->utype));
@@ -1279,6 +1294,7 @@
/* declare useful constants */
tyintptr = mkty(-1, Tyuint64);
+ tyword = mkty(-1, Tyuint);
tyvoid = mkty(-1, Tyvoid);
fn = NULL;