diff options
| author | Michael Forney <mforney@mforney.org> | 2019-05-16 23:11:01 -0700 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2019-05-16 23:11:27 -0700 |
| commit | 813a8460859200afaca250be1417c8236b8eb96a (patch) | |
| tree | fccd7cf9b02144eb7dfa0d91ea2c8c9d159c431b /pkg/qbe/patch/0002-Use-dynamic-array-for-phi-arguments.patch | |
| parent | b745c9ac807d104abf083f46608fb964bcc12ade (diff) | |
qbe: Update to latest git and apply some patches
Diffstat (limited to 'pkg/qbe/patch/0002-Use-dynamic-array-for-phi-arguments.patch')
| -rw-r--r-- | pkg/qbe/patch/0002-Use-dynamic-array-for-phi-arguments.patch | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/pkg/qbe/patch/0002-Use-dynamic-array-for-phi-arguments.patch b/pkg/qbe/patch/0002-Use-dynamic-array-for-phi-arguments.patch new file mode 100644 index 00000000..49270239 --- /dev/null +++ b/pkg/qbe/patch/0002-Use-dynamic-array-for-phi-arguments.patch @@ -0,0 +1,125 @@ +From 3415d1f4dc68092819faf1744bfab556e338649b Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sun, 21 Apr 2019 13:37:32 -0700 +Subject: [PATCH] Use dynamic array for phi arguments + +--- + all.h | 4 ++-- + amd64/sysv.c | 8 ++++++-- + arm64/abi.c | 8 ++++++-- + load.c | 4 ++-- + parse.c | 2 ++ + ssa.c | 6 ++++-- + 6 files changed, 22 insertions(+), 10 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 9894000..ae9cfcf 100644 +--- a/load.c ++++ b/load.c +@@ -330,8 +330,8 @@ def(Slice sl, bits msk, Blk *b, Ins *i, Loc *il) + p->to = r; + p->cls = sl.cls; + p->narg = b->npred; +- if (b->npred >= NPred) +- die("def, too many phi args (%u)", 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; + } +-- +2.21.0 + |
