summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2012-07-31 11:41:01 -0400
committerOri Bernstein <ori@eigenstate.org>2012-07-31 11:41:01 -0400
commit001eb2aee8d88faa8186c858e503c6ea80b1e145 (patch)
treeda16958fbc4eff2378d11a4d5eb8c6bc2285b7aa /6
parent0c574aa0d1cf26d51211668522db935da52a5ebe (diff)
parentb2fa7003bf8809ce27699c88eecce4b55618dd5f (diff)
downloadmc-001eb2aee8d88faa8186c858e503c6ea80b1e145.tar.gz
Merge branch 'master' of git+ssh://mimir.eigenstate.org/git/ori/mc2
Conflicts: 6/simp.c
Diffstat (limited to '6')
-rw-r--r--6/asm.h1
-rw-r--r--6/simp.c30
2 files changed, 24 insertions, 7 deletions
diff --git a/6/asm.h b/6/asm.h
index 5240582..2941e81 100644
--- 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 */
diff --git a/6/simp.c b/6/simp.c
index f57d80d..5f0d1ac 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -54,6 +54,7 @@ static void declarelocal(Simp *s, Node *n);
/* useful constants */
static Type *tyintptr;
+static Type *tyword;
static Type *tyvoid;
static Type *base(Type *t)
@@ -151,6 +152,15 @@ static Node *disp(int line, uint v)
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 @@ static Node *uconid(Node *n, size_t off)
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 @@ static Node *ucompare(Simp *s, Node *a, Node *b, Type *t, size_t off)
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 @@ static Node *lowerucon(Simp *s, Node *n, Node *dst)
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 @@ void gen(Node *file, char *out)
/* declare useful constants */
tyintptr = mkty(-1, Tyuint64);
+ tyword = mkty(-1, Tyuint);
tyvoid = mkty(-1, Tyvoid);
fn = NULL;