shithub: mc

Download patch

ref: dc611e92af421149bc0277b199250966919fe7e7
parent: fbc01b056541c245dce94569d3564fd8812ec72b
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Dec 4 09:18:04 EST 2016

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.

--- a/6/asm.h
+++ b/6/asm.h
@@ -272,6 +272,7 @@
 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);
--- a/6/gengas.c
+++ b/6/gengas.c
@@ -348,6 +348,7 @@
 {
 	Isel is = {0,};
 
+	resetregs();
 	is.reglocs = mkht(varhash, vareq);
 	is.name = fn->name;
 	is.stkoff = fn->stkoff;
@@ -355,6 +356,7 @@
 	is.globls = globls;
 	is.ret = fn->ret;
 	is.cfg = fn->cfg;
+
 	if (fn->hasenv)
 		is.envp = locreg(ModeQ);
 
--- a/6/locs.c
+++ b/6/locs.c
@@ -67,6 +67,11 @@
 Loc **locmap = NULL;
 size_t maxregid = 0;
 
+void resetregs()
+{
+	maxregid = Nreg;
+}
+
 static Loc *locregid(regid id, Mode m)
 {
 	Loc *l;