summary refs log tree commit diff
path: root/lisc/rega.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-08-22 10:18:40 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:32 -0400
commit1eb875882480c83787507f2668fae6e58094444c (patch)
tree90becb31dff6eb9deb4000b8393019ca959d0145 /lisc/rega.c
parent762fb723e5de5676bf36f1213b629badc55cd84d (diff)
downloadroux-1eb875882480c83787507f2668fae6e58094444c.tar.gz
simplify rega's dopm()
Diffstat (limited to 'lisc/rega.c')
-rw-r--r--lisc/rega.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/lisc/rega.c b/lisc/rega.c
index 1e69d41..6d1d174 100644
--- a/lisc/rega.c
+++ b/lisc/rega.c
@@ -202,7 +202,7 @@ pmgen()
 	free(status);
 }
 
-static int
+int
 isreg(Ref r)
 {
 	return rtype(r) == RTmp && r.val < Tmp0;
@@ -212,8 +212,8 @@ static Ins *
 dopm(Blk *b, Ins *i, RMap *m)
 {
 	RMap m0;
-	int n, r, r1, t, nins;
-	Ins *i1, *ib, *ip, *ir;
+	int n, r, r1, t;
+	Ins *i1, *ip;
 
 	m0 = *m;
 	i1 = i+1;
@@ -251,22 +251,14 @@ dopm(Blk *b, Ins *i, RMap *m)
 		r = RBASE(ip->arg[0].val);
 		if (rfind(m, r) == -1)
 			radd(m, r, r);
+		*ip = (Ins){ONop, R, {R, R}};
 	}
 	pmgen();
 #ifdef TEST_PMOV
 	return 0;
 #endif
-	nins = curi-insb;
-	ib = alloc((b->nins + nins - (i1-i)) * sizeof(Ins));
-	memcpy(ip = ib, b->ins, (i - b->ins) * sizeof(Ins));
-	ip += i - b->ins;
-	memcpy(ir = ip, insb, nins * sizeof(Ins));
-	ip += nins;
-	memcpy(ip, i1, (&b->ins[b->nins] - i1) * sizeof(Ins));
-	b->nins += nins - (i1-i);
-	free(b->ins);
-	b->ins = ib;
-	return ir;
+	assert(curi-insb <= i1-i);
+	return memcpy(i, insb, (curi-insb) * sizeof(Ins));
 }
 
 /* register allocation