summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--all.h29
-rw-r--r--emit.c8
-rw-r--r--live.c14
-rw-r--r--parse.c14
-rw-r--r--rega.c6
-rw-r--r--spill.c12
-rw-r--r--sysv.c8
7 files changed, 42 insertions, 49 deletions
diff --git a/all.h b/all.h
index a983108..e22a1f5 100644
--- a/all.h
+++ b/all.h
@@ -96,8 +96,8 @@ struct BSet {
 };
 
 struct Ref {
-	uint16_t type:2;
-	uint16_t val:14;
+	uint32_t type:3;
+	uint32_t val:29;
 };
 
 enum Alt {
@@ -105,7 +105,7 @@ enum Alt {
 	ACall,
 	AMem,
 
-	AShift = 12,
+	AShift = 28,
 	AMask = (1<<AShift) - 1
 };
 
@@ -113,13 +113,9 @@ enum {
 	RTmp,
 	RCon,
 	RSlot,
-	RAlt,
-
-	RAType = RAlt + AType,
-	RACall = RAlt + ACall,
-	RAMem  = RAlt + AMem,
-
-	NRef = (1<<14) - 1
+	RType,
+	RCall,
+	RMem,
 };
 
 #define R        (Ref){0, 0}
@@ -127,10 +123,9 @@ enum {
 #define CON(x)   (Ref){RCon, x}
 #define CON_Z    CON(0)          /* reserved zero constant */
 #define SLOT(x)  (Ref){RSlot, x}
-#define TYPE(x)  (Ref){RAlt, (x)|(AType<<AShift)}
-#define CALL(x)  (Ref){RAlt, (x)|(ACall<<AShift)}
-#define MEM(x)   (assert(x<(1<<AShift) && "too many mems"), \
-                 (Ref){RAlt, (x)|(AMem<<AShift)})
+#define TYPE(x)  (Ref){RType, x}
+#define CALL(x)  (Ref){RCall, x}
+#define MEM(x)   (Ref){RMem, x}
 
 static inline int req(Ref a, Ref b)
 {
@@ -141,8 +136,6 @@ static inline int rtype(Ref r)
 {
 	if (req(r, R))
 		return -1;
-	if (r.type == RAlt)
-		return RAlt + (r.val >> AShift);
 	return r.type;
 }
 
@@ -316,10 +309,10 @@ struct OpDesc {
 };
 
 struct Ins {
-	ushort op:14;
+	uint op:30;
 	Ref to;
 	Ref arg[2];
-	ushort cls:2;
+	uint cls:2;
 };
 
 struct Phi {
diff --git a/emit.c b/emit.c
index 32e4078..4d8bd67 100644
--- a/emit.c
+++ b/emit.c
@@ -129,7 +129,7 @@ static char *rname[][4] = {
 static int
 slot(int s, Fn *fn)
 {
-	struct { int i:14; } x;
+	struct { int i:29; } x;
 
 	/* sign extend s using a bitfield */
 	x.i = s;
@@ -263,9 +263,9 @@ Next:
 		case RSlot:
 			fprintf(f, "%d(%%rbp)", slot(ref.val, fn));
 			break;
-		case RAMem:
+		case RMem:
 		Mem:
-			m = &fn->mem[ref.val & AMask];
+			m = &fn->mem[ref.val];
 			if (rtype(m->base) == RSlot) {
 				off.type = CBits;
 				off.bits.i = slot(m->base.val, fn);
@@ -310,7 +310,7 @@ Next:
 		c = *s++;
 		ref = getarg(c, i);
 		switch (rtype(ref)) {
-		case RAMem:
+		case RMem:
 			goto Mem;
 		case RSlot:
 			fprintf(f, "%d(%%rbp)", slot(ref.val, fn));
diff --git a/live.c b/live.c
index cd02aec..3265b3e 100644
--- a/live.c
+++ b/live.c
@@ -26,7 +26,7 @@ phitmp(int t, Tmp *tmp)
 }
 
 static void
-phifix(int t1, short *phi, Tmp *tmp)
+phifix(int t1, int *phi, Tmp *tmp)
 {
 	int t, t2;
 
@@ -49,7 +49,7 @@ phifix(int t1, short *phi, Tmp *tmp)
 }
 
 static void
-bset(Ref r, Blk *b, int *nlv, short *phi, Tmp *tmp)
+bset(Ref r, Blk *b, int *nlv, int *phi, Tmp *tmp)
 {
 
 	if (rtype(r) != RTmp)
@@ -71,7 +71,7 @@ filllive(Fn *f)
 	Blk *b;
 	Ins *i;
 	int k, t, m[2], n, chg, nlv[2];
-	short *phi;
+	int *phi;
 	BSet u[1], v[1];
 	Mem *ma;
 
@@ -106,7 +106,7 @@ Again:
 			phifix(t, phi, f->tmp);
 			nlv[KBASE(f->tmp[t].cls)]++;
 		}
-		if (rtype(b->jmp.arg) == RACall) {
+		if (rtype(b->jmp.arg) == RCall) {
 			assert(bscount(b->in) == 0 && nlv[0] == 0 && nlv[1] == 0);
 			b->in->t[0] |= retregs(b->jmp.arg, nlv);
 		} else
@@ -114,7 +114,7 @@ Again:
 		for (k=0; k<2; k++)
 			b->nlive[k] = nlv[k];
 		for (i=&b->ins[b->nins]; i!=b->ins;) {
-			if ((--i)->op == OCall && rtype(i->arg[1]) == RACall) {
+			if ((--i)->op == OCall && rtype(i->arg[1]) == RCall) {
 				b->in->t[0] &= ~retregs(i->arg[1], m);
 				for (k=0; k<2; k++)
 					nlv[k] -= m[k];
@@ -137,8 +137,8 @@ Again:
 			}
 			for (k=0; k<2; k++)
 				switch (rtype(i->arg[k])) {
-				case RAMem:
-					ma = &f->mem[i->arg[k].val & AMask];
+				case RMem:
+					ma = &f->mem[i->arg[k].val];
 					bset(ma->base, b, nlv, phi, f->tmp);
 					bset(ma->index, b, nlv, phi, f->tmp);
 					break;
diff --git a/parse.c b/parse.c
index 521e2bf..ba6eeba 100644
--- a/parse.c
+++ b/parse.c
@@ -952,17 +952,17 @@ printref(Ref r, Fn *fn, FILE *f)
 		printcon(&fn->con[r.val], f);
 		break;
 	case RSlot:
-		fprintf(f, "S%d", r.val);
+		fprintf(f, "S%d", (r.val&(1<<28)) ? r.val-(1<<29) : r.val);
 		break;
-	case RACall:
-		fprintf(f, "%03x", r.val & AMask);
+	case RCall:
+		fprintf(f, "%03x", r.val);
 		break;
-	case RAType:
-		fprintf(f, ":%s", typ[r.val & AMask].name);
+	case RType:
+		fprintf(f, ":%s", typ[r.val].name);
 		break;
-	case RAMem:
+	case RMem:
 		i = 0;
-		m = &fn->mem[r.val & AMask];
+		m = &fn->mem[r.val];
 		fputc('[', f);
 		if (m->offset.type != CUndef) {
 			printcon(&m->offset, f);
diff --git a/rega.c b/rega.c
index 23f078c..927e5aa 100644
--- a/rega.c
+++ b/rega.c
@@ -365,7 +365,7 @@ doblk(Blk *b, RMap *cur)
 
 	if (rtype(b->jmp.arg) == RTmp)
 		b->jmp.arg = ralloc(cur, b->jmp.arg.val);
-	else if (rtype(b->jmp.arg) == RACall) {
+	else if (rtype(b->jmp.arg) == RCall) {
 		/* add return registers */
 		rs = retregs(b->jmp.arg, 0);
 		for (r=0; rs; rs/=2, r++)
@@ -404,8 +404,8 @@ doblk(Blk *b, RMap *cur)
 		}
 		for (x=0, nr=0; x<2; x++)
 			switch (rtype(i->arg[x])) {
-			case RAMem:
-				m = &mem[i->arg[x].val & AMask];
+			case RMem:
+				m = &mem[i->arg[x].val];
 				if (rtype(m->base) == RTmp)
 					insert(&m->base, ra, nr++);
 				if (rtype(m->index) == RTmp)
diff --git a/spill.c b/spill.c
index dad18d2..23d7bf6 100644
--- a/spill.c
+++ b/spill.c
@@ -34,8 +34,8 @@ tmpuse(Ref r, int use, int loop, Fn *fn)
 	Mem *m;
 	Tmp *t;
 
-	if (rtype(r) == RAMem) {
-		m = &fn->mem[r.val & AMask];
+	if (rtype(r) == RMem) {
+		m = &fn->mem[r.val];
 		tmpuse(m->base, 1, loop, fn);
 		tmpuse(m->index, 1, loop, fn);
 	}
@@ -386,7 +386,7 @@ spill(Fn *fn)
 				bsunion(v, u);
 			}
 			limit2(v, 0, 0, w);
-		} else if (rtype(b->jmp.arg) == RACall) {
+		} else if (rtype(b->jmp.arg) == RCall) {
 			/* return */
 			r = retregs(b->jmp.arg, 0);
 			v->t[0] |= r;
@@ -416,13 +416,13 @@ spill(Fn *fn)
 			}
 			j = opdesc[i->op].nmem;
 			for (n=0; n<2; n++)
-				if (rtype(i->arg[n]) == RAMem)
+				if (rtype(i->arg[n]) == RMem)
 					j--;
 			for (n=0; n<2; n++)
 				switch (rtype(i->arg[n])) {
-				case RAMem:
+				case RMem:
 					t = i->arg[n].val;
-					m = &fn->mem[t & AMask];
+					m = &fn->mem[t];
 					if (rtype(m->base) == RTmp) {
 						bsset(v, m->base.val);
 						bsset(w, m->base.val);
diff --git a/sysv.c b/sysv.c
index 404c0ac..5a8934b 100644
--- a/sysv.c
+++ b/sysv.c
@@ -209,7 +209,7 @@ retregs(Ref r, int p[2])
 	bits b;
 	int ni, nf;
 
-	assert(rtype(r) == RACall);
+	assert(rtype(r) == RCall);
 	b = 0;
 	ni = r.val & 3;
 	nf = (r.val >> 2) & 3;
@@ -234,7 +234,7 @@ argregs(Ref r, int p[2])
 	bits b;
 	int j, ni, nf;
 
-	assert(rtype(r) == RACall);
+	assert(rtype(r) == RCall);
 	b = 0;
 	ni = (r.val >> 4) & 15;
 	nf = (r.val >> 8) & 15;
@@ -270,8 +270,8 @@ selcall(Fn *fn, Ins *i0, Ins *i1, RAlloc **rap)
 
 	ac = alloc((i1-i0) * sizeof ac[0]);
 	if (!req(i1->arg[1], R)) {
-		assert(rtype(i1->arg[1]) == RAType);
-		aclass(&aret, &typ[i1->arg[1].val & AMask]);
+		assert(rtype(i1->arg[1]) == RType);
+		aclass(&aret, &typ[i1->arg[1].val]);
 		ca = classify(i0, i1, ac, OArg, &aret);
 	} else
 		ca = classify(i0, i1, ac, OArg, 0);