diff options
author | Ori Bernstein <ori@eigenstate.org> | 2012-07-31 11:36:58 -0400 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2012-07-31 11:36:58 -0400 |
commit | 0c574aa0d1cf26d51211668522db935da52a5ebe (patch) | |
tree | a0ed1761e34800a94e638184871868f6bb524057 /6 | |
parent | 1692dfdd9688c970e0b5fb1def9758b229bc1402 (diff) | |
download | mc-0c574aa0d1cf26d51211668522db935da52a5ebe.tar.gz |
Move towards registerizing stuff.
Diffstat (limited to '6')
-rw-r--r-- | 6/asm.h | 1 | ||||
-rw-r--r-- | 6/isel.c | 5 | ||||
-rw-r--r-- | 6/simp.c | 39 |
3 files changed, 14 insertions, 31 deletions
@@ -109,6 +109,7 @@ struct Isel { Node *ret; /* we store the return into here */ Htab *locs; /* decl id => int stkoff */ + Htab *reglocs; /* decl id => Loc *reg */ Htab *globls; /* decl id => char *globlname */ /* increased when we spill */ @@ -94,7 +94,9 @@ static Loc *loc(Isel *s, Node *n) rip = locphysreg(Rrip); l = locmeml(htget(s->globls, n), rip, NULL, mode(n)); } else { - die("%s (id=%ld) not found", namestr(n->expr.args[0]), n->expr.did); + if (!hthas(s->reglocs, n)) + htput(s->reglocs, n, locreg(mode(n))); + return htget(s->reglocs, n); } break; case Olit: @@ -870,6 +872,7 @@ void genasm(FILE *fd, Func *fn, Htab *globls) size_t i, j; char buf[128]; + is.reglocs = mkht(dclhash, dcleq); is.locs = fn->locs; is.globls = globls; is.ret = fn->ret; @@ -151,30 +151,6 @@ static Node *disp(int line, uint v) return n; } -static size_t did(Node *n) -{ - if (n->type == Ndecl) { - return n->decl.did; - } else if (n->type == Nexpr) { - assert(exprop(n) == Ovar); - return n->expr.did; - } - dump(n, stderr); - die("Can't get did"); - return 0; -} - -static ulong dclhash(void *dcl) -{ - /* large-prime hash. meh. */ - return did(dcl) * 366787; -} - -static int dcleq(void *a, void *b) -{ - return did(a) == did(b); -} - static void append(Simp *s, Node *n) { lappend(&s->stmts, &s->nstmts, n); @@ -325,7 +301,8 @@ static Node *temp(Simp *simp, Node *e) assert(e->type == Nexpr); t = gentemp(simp, e, e->expr.type, &dcl); - declarelocal(simp, dcl); + if (stacknode(e)) + declarelocal(simp, dcl); return t; } @@ -1094,11 +1071,13 @@ static Node *rval(Simp *s, Node *n, Node *dst) static void declarelocal(Simp *s, Node *n) { assert(n->type == Ndecl); - s->stksz += size(n); - s->stksz = align(s->stksz, min(size(n), Ptrsz)); - if (debug) - printf("declare %s:%s(%zd) at %zd\n", declname(n), tystr(decltype(n)), n->decl.did, s->stksz); - htput(s->locs, n, (void*)s->stksz); + if (stacknode(n)) { + s->stksz += size(n); + s->stksz = align(s->stksz, min(size(n), Ptrsz)); + if (debug) + printf("declare %s:%s(%zd) at %zd\n", declname(n), tystr(decltype(n)), n->decl.did, s->stksz); + htput(s->locs, n, (void*)s->stksz); + } } static void declarearg(Simp *s, Node *n) |