aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ir_simpl.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-03-21 22:20:34 +0100
committerlemon <lsof@mailbox.org>2026-03-22 10:49:26 +0100
commit79874c83bf76a5b3efd3d558933b90d9b53b829e (patch)
tree566930a17f1e090f86c2051ffec33106012908eb /src/ir_simpl.c
parent83342d3b60438ef2421160a0673fb45d48b2f39f (diff)
IR: add 3rd operand to Instr
The motivation is for aarch64 msub/madd instrs, for isel to produce. But it should be useful for other things too.
Diffstat (limited to 'src/ir_simpl.c')
-rw-r--r--src/ir_simpl.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/ir_simpl.c b/src/ir_simpl.c
index 8bf8c98..ad25a9f 100644
--- a/src/ir_simpl.c
+++ b/src/ir_simpl.c
@@ -21,12 +21,12 @@ mulk(Instr *ins, Block *blk, int *curi)
/* x * 5 ==> (x << 2) + x */
ins->op = Oadd;
ins->r = ins->l;
- ins->l = insertinstr(blk, (*curi)++, mkinstr(Oshl, cls, ins->l, mkref(RICON, ilog2(iv-1))));
+ ins->l = insertinstr(blk, (*curi)++, mkinstr2(Oshl, cls, ins->l, mkref(RICON, ilog2(iv-1))));
} else if (ispo2(iv+1)) {
/* x * 7 ==> (x << 3) - x */
ins->op = Osub;
ins->r = ins->l;
- ins->l = insertinstr(blk, (*curi)++, mkinstr(Oshl, cls, ins->l, mkref(RICON, ilog2(iv+1))));
+ ins->l = insertinstr(blk, (*curi)++, mkinstr2(Oshl, cls, ins->l, mkref(RICON, ilog2(iv+1))));
} else return 0;
if (neg) {
ins->l = insertinstr(blk, (*curi)++, *ins);
@@ -58,12 +58,12 @@ divmodk(Instr *ins, Block *blk, int *curi)
case Odiv: case Orem:
/* have to adjust to round negatives toward zero */
/* x' = (((x < 0 ? -1 : 0) >>> (Nbit - s)) + x) */
- temp = insertinstr(blk, (*curi)++, mkinstr(Osar, cls, ins->l, mkref(RICON, nbit - 1)));
- temp = insertinstr(blk, (*curi)++, mkinstr(Oslr, cls, temp, mkref(RICON, nbit - s)));
- temp = insertinstr(blk, (*curi)++, mkinstr(Oadd, cls, ins->l, temp));
+ temp = insertinstr(blk, (*curi)++, mkinstr2(Osar, cls, ins->l, mkref(RICON, nbit - 1)));
+ temp = insertinstr(blk, (*curi)++, mkinstr2(Oslr, cls, temp, mkref(RICON, nbit - s)));
+ temp = insertinstr(blk, (*curi)++, mkinstr2(Oadd, cls, ins->l, temp));
if (op == Odiv) {
/* (-) (x' >> s) */
- Instr sar = mkinstr(Osar, cls, temp, mkref(RICON, s));
+ Instr sar = mkinstr2(Osar, cls, temp, mkref(RICON, s));
if (!neg) *ins = sar;
else {
temp = insertinstr(blk, (*curi)++, sar);
@@ -71,7 +71,7 @@ divmodk(Instr *ins, Block *blk, int *curi)
}
} else {
/* x - (x' & -(2^s)) */
- temp = insertinstr(blk, (*curi)++, mkinstr(Oand, cls, temp, mkintcon(cls, neg ? iv : -iv)));
+ temp = insertinstr(blk, (*curi)++, mkinstr2(Oand, cls, temp, mkintcon(cls, neg ? iv : -iv)));
ins->op = Osub, ins->r = temp;
}
break;
@@ -89,7 +89,7 @@ doins(Instr *ins, Block *blk, int *curi)
Ref r = narg == 1 ? irunop(NULL, ins->op, ins->cls, ins->l)
: irbinop(NULL, ins->op, ins->cls, ins->l, ins->r);
if (r.bits) {
- *ins = mkinstr(Onop,0,);
+ *ins = mkinstr0(Onop,0);
replcuses(mkref(RTMP, ins - instrtab), r);
return 1;
}
@@ -101,7 +101,7 @@ doins(Instr *ins, Block *blk, int *curi)
|| (isnumcon(ins->l) && k == concls(ins->l))
|| (kisint(k) && ins->l.t == RICON)) {
Ref it = ins->l;
- *ins = mkinstr(Onop,0,);
+ *ins = mkinstr0(Onop,0);
replcuses(mkref(RTMP, ins - instrtab), it);
return 1;
}
@@ -130,7 +130,7 @@ doins(Instr *ins, Block *blk, int *curi)
}
ins->l = lhs->l, ins->r = mkintcon(ins->cls, c);
deluse(blk, ins - instrtab, mkref(RTMP, lhs - instrtab));
- if (!instruse[lhs - instrtab]) *lhs = mkinstr(Onop,0,);
+ if (!instruse[lhs - instrtab]) *lhs = mkinstr0(Onop,0);
return 1;
}
}