summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
Diffstat (limited to '6')
-rw-r--r--6/asm.h1
-rw-r--r--6/gengas.c2
-rw-r--r--6/locs.c5
3 files changed, 8 insertions, 0 deletions
diff --git a/6/asm.h b/6/asm.h
index 5d5349b..83b3a98 100644
--- a/6/asm.h
+++ b/6/asm.h
@@ -272,6 +272,7 @@ size_t blobsz(Blob *b);
extern size_t maxregid;
extern Loc **locmap; /* mapping from reg id => Loc * */
+void resetregs(void);
char *genlocallblstr(char *buf, size_t sz);
Type *codetype(Type *ft);
Type *closuretype(Type *ft);
diff --git a/6/gengas.c b/6/gengas.c
index 968fbe1..d315684 100644
--- a/6/gengas.c
+++ b/6/gengas.c
@@ -348,6 +348,7 @@ static void genfunc(FILE *fd, Func *fn, Htab *globls, Htab *strtab)
{
Isel is = {0,};
+ resetregs();
is.reglocs = mkht(varhash, vareq);
is.name = fn->name;
is.stkoff = fn->stkoff;
@@ -355,6 +356,7 @@ static void genfunc(FILE *fd, Func *fn, Htab *globls, Htab *strtab)
is.globls = globls;
is.ret = fn->ret;
is.cfg = fn->cfg;
+
if (fn->hasenv)
is.envp = locreg(ModeQ);
diff --git a/6/locs.c b/6/locs.c
index de110c7..a569e1e 100644
--- a/6/locs.c
+++ b/6/locs.c
@@ -67,6 +67,11 @@ Loc *loclbl(Node *e)
Loc **locmap = NULL;
size_t maxregid = 0;
+void resetregs()
+{
+ maxregid = Nreg;
+}
+
static Loc *locregid(regid id, Mode m)
{
Loc *l;