diff options
author | Ori Bernstein <ori@eigenstate.org> | 2013-02-06 17:25:08 -0500 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2013-02-06 17:25:08 -0500 |
commit | 10a3edcf0264c6e2b878a230f4a77f8954b67d0d (patch) | |
tree | 7d9f41d706437a736c724ad7e252ae5d5fda63fc | |
parent | ec1385e4eeb73318684695de73cb61f276deb887 (diff) | |
parent | f635856c50c2a640c3765af746ee23a8d4282373 (diff) | |
download | mc-10a3edcf0264c6e2b878a230f4a77f8954b67d0d.tar.gz |
Merge branch 'callee-save' of git+ssh://mimir.eigenstate.org/git/ori/mc into callee-save
-rw-r--r-- | 6/asm.h | 59 | ||||
-rw-r--r-- | 6/isel.c | 12 |
2 files changed, 38 insertions, 33 deletions
@@ -49,17 +49,22 @@ typedef enum { Nmode, } Mode; +/* a register, label, or memory location */ struct Loc { - Loctype type; - Mode mode; + Loctype type; /* the type of loc */ + Mode mode; /* the mode of this location */ union { - char *lbl; - struct { + char *lbl; /* for Loclbl, Loclitl */ + struct { /* for Locreg */ regid id; Reg colour; } reg; - long lit; - /* disp(base + index) */ + long lit; /* for Loclit */ + /* + * for Locmem, Locmeml. + * address format is + * disp(base + index) + */ struct { /* only one of lbldisp and constdisp may be used */ char *lbldisp; @@ -78,28 +83,28 @@ struct Insn { }; struct Func { - char *name; - int isexport; - size_t stksz; - Type *type; - Htab *locs; - Node *ret; - Cfg *cfg; + char *name; /* function name */ + int isexport; /* is this exported from the asm? */ + size_t stksz; /* stack size */ + Type *type; /* type of function */ + Htab *stkoff; /* Loc* -> int stackoff map */ + Node *ret; /* return value */ + Cfg *cfg; /* flow graph */ }; struct Asmbb { - int id; - char **lbls; - size_t nlbls; - Insn **il; - size_t ni; - - Bitset *pred; - Bitset *succ; - Bitset *use; - Bitset *def; - Bitset *livein; - Bitset *liveout; + int id; /* unique identifier */ + char **lbls; /* list of BB labels */ + size_t nlbls; /* number of labels */ + Insn **il; /* instructions */ + size_t ni; /* number of instructions */ + + Bitset *pred; /* set of predecessor BB ids */ + Bitset *succ; /* set of successor BB ids */ + Bitset *use; /* registers used by this BB */ + Bitset *def; /* registers defined by this BB */ + Bitset *livein; /* variables live on entrance to BB */ + Bitset *liveout; /* variables live on exit from BB */ }; @@ -112,10 +117,10 @@ struct Isel { Asmbb *curbb; Node *ret; /* we store the return into here */ - Htab *locs; /* decl id => int stkoff */ Htab *spillslots; /* reg id => int stkoff */ Htab *reglocs; /* decl id => Loc *reg */ - Htab *globls; /* decl id => char *globlname */ + Htab *stkoff; /* decl id => int stkoff */ + Htab *_globls; /* decl id => char *globlname */ /* increased when we spill */ Loc *stksz; @@ -78,21 +78,21 @@ static Mode mode(Node *n) static Loc *loc(Isel *s, Node *n) { - size_t stkoff; + ssize_t stkoff; Loc *l, *rip; Node *v; switch (exprop(n)) { case Ovar: - if (hthas(s->locs, n)) { - stkoff = (size_t)htget(s->locs, n); + if (hthas(s->stkoff, n)) { + stkoff = (ssize_t)htget(s->stkoff, n); l = locmem(-stkoff, locphysreg(Rrbp), NULL, mode(n)); - } else if (hthas(s->globls, n)) { + } else if (hthas(s->_globls, n)) { if (tybase(exprtype(n))->type == Tyfunc) rip = NULL; else rip = locphysreg(Rrip); - l = locmeml(htget(s->globls, n), rip, NULL, mode(n)); + l = locmeml(htget(s->_globls, n), rip, NULL, mode(n)); } else { if (!hthas(s->reglocs, n)) htput(s->reglocs, n, locreg(mode(n))); @@ -931,7 +931,7 @@ void genasm(FILE *fd, Func *fn, Htab *globls) char buf[128]; is.reglocs = mkht(dclhash, dcleq); - is.locs = fn->locs; + is.stkoff = fn->stkoff; is.globls = globls; is.ret = fn->ret; is.cfg = fn->cfg; |