summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-12-04 14:18:04 -0800
committerOri Bernstein <ori@eigenstate.org>2016-12-04 14:18:04 -0800
commitdc611e92af421149bc0277b199250966919fe7e7 (patch)
tree73be6d2cbd8bcc15235085650f1f883833291152 /6
parentfbc01b056541c245dce94569d3564fd8812ec72b (diff)
downloadmc-dc611e92af421149bc0277b199250966919fe7e7.tar.gz
Reset register numbers.
In our register allocator, we create a matrix that's got nreg*nreg bits in it. When the register numbers get big, this matrix also can get big. We can't do anything about that in giant functions, but if we have lots of smaller functions, we can clear the value before generating the code, keeping the sizes of the matrixes and bit sets in check. This speeds up builds significantly in files with thousands of functions.
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;