summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--all.h4
-rw-r--r--amd64/sysv.c8
-rw-r--r--arm64/abi.c8
-rw-r--r--load.c2
-rw-r--r--parse.c2
-rw-r--r--ssa.c6
6 files changed, 22 insertions, 8 deletions
diff --git a/all.h b/all.h
index 59eefe1..fba93b1 100644
--- a/all.h
+++ b/all.h
@@ -206,8 +206,8 @@ struct Ins {
 
 struct Phi {
 	Ref to;
-	Ref arg[NPred];
-	Blk *blk[NPred];
+	Ref *arg;
+	Blk **blk;
 	uint narg;
 	int cls;
 	Phi *link;
diff --git a/amd64/sysv.c b/amd64/sysv.c
index ea9b2d2..286300a 100644
--- a/amd64/sysv.c
+++ b/amd64/sysv.c
@@ -590,9 +590,13 @@ selvaarg(Fn *fn, Blk *b, Ins *i)
 	*b0->phi = (Phi){
 		.cls = Kl, .to = loc,
 		.narg = 2,
-		.blk = {bstk, breg},
-		.arg = {lstk, lreg},
+		.blk = vnew(2, sizeof b0->phi->blk[0], Pfn),
+		.arg = vnew(2, sizeof b0->phi->arg[0], Pfn),
 	};
+	b0->phi->blk[0] = bstk;
+	b0->phi->blk[1] = breg;
+	b0->phi->arg[0] = lstk;
+	b0->phi->arg[1] = lreg;
 	r0 = newtmp("abi", Kl, fn);
 	r1 = newtmp("abi", Kw, fn);
 	b->jmp.type = Jjnz;
diff --git a/arm64/abi.c b/arm64/abi.c
index 8bc9c20..f5b605a 100644
--- a/arm64/abi.c
+++ b/arm64/abi.c
@@ -583,9 +583,13 @@ selvaarg(Fn *fn, Blk *b, Ins *i)
 	*b0->phi = (Phi){
 		.cls = Kl, .to = loc,
 		.narg = 2,
-		.blk = {bstk, breg},
-		.arg = {lstk, lreg},
+		.blk = vnew(2, sizeof b0->phi->blk[0], Pfn),
+		.arg = vnew(2, sizeof b0->phi->arg[0], Pfn),
 	};
+	b0->phi->blk[0] = bstk;
+	b0->phi->blk[1] = breg;
+	b0->phi->arg[0] = lstk;
+	b0->phi->arg[1] = lreg;
 	r0 = newtmp("abi", Kl, fn);
 	r1 = newtmp("abi", Kw, fn);
 	b->jmp.type = Jjnz;
diff --git a/load.c b/load.c
index 8e2dd64..ae9cfcf 100644
--- a/load.c
+++ b/load.c
@@ -330,6 +330,8 @@ def(Slice sl, bits msk, Blk *b, Ins *i, Loc *il)
 	p->to = r;
 	p->cls = sl.cls;
 	p->narg = b->npred;
+	p->arg = vnew(p->narg, sizeof p->arg[0], Pfn);
+	p->blk = vnew(p->narg, sizeof p->blk[0], Pfn);
 	for (np=0; np<b->npred; ++np) {
 		bp = b->pred[np];
 		if (!bp->s2
diff --git a/parse.c b/parse.c
index c4c1fe6..95bcf45 100644
--- a/parse.c
+++ b/parse.c
@@ -673,7 +673,9 @@ Ins:
 		phi = alloc(sizeof *phi);
 		phi->to = r;
 		phi->cls = k;
+		phi->arg = vnew(i, sizeof arg[0], Pfn);
 		memcpy(phi->arg, arg, i * sizeof arg[0]);
+		phi->blk = vnew(i, sizeof blk[0], Pfn);
 		memcpy(phi->blk, blk, i * sizeof blk[0]);
 		phi->narg = i;
 		*plink = phi;
diff --git a/ssa.c b/ssa.c
index c098438..2de02d1 100644
--- a/ssa.c
+++ b/ssa.c
@@ -181,6 +181,8 @@ phiins(Fn *fn)
 					p->cls = k;
 					p->to = TMP(t);
 					p->link = a->phi;
+					p->arg = vnew(0, sizeof p->arg[0], Pfn);
+					p->blk = vnew(0, sizeof p->blk[0], Pfn);
 					a->phi = p;
 					if (!bshas(defs, a->id))
 					if (!bshas(u, a->id)) {
@@ -294,8 +296,8 @@ renblk(Blk *b, Name **stk, Fn *fn)
 			t = p->to.val;
 			if ((t=fn->tmp[t].visit)) {
 				m = p->narg++;
-				if (m == NPred)
-					die("renblk, too many phi args");
+				vgrow(&p->arg, p->narg);
+				vgrow(&p->blk, p->narg);
 				p->arg[m] = getstk(t, b, stk);
 				p->blk[m] = b;
 			}