aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ir.h
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.h
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.h')
-rw-r--r--src/ir.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/ir.h b/src/ir.h
index f54c2fb..fef38b5 100644
--- a/src/ir.h
+++ b/src/ir.h
@@ -122,9 +122,12 @@ typedef struct Instr {
keep : 1; /* for codegen, keep instr even if result seems unused */
uchar inplace : 1; /* set (by isel) for instructions which modify its first arg in place */
uchar reg; /* 0 -> no reg; else reg + 1 */
- Ref l, r; /* args */
+ union { /* operands */
+ struct { Ref l, r; };
+ Ref oper[3];
+ };
} Instr;
-static_assert(sizeof(Instr) == 4*3);
+static_assert(sizeof(Instr) == 4*4);
enum jumpkind { JXXX, Jb, Jret, Jtrap, };
@@ -253,8 +256,10 @@ extern struct dattab {vec_of(IRDat);} dattab;
extern struct contab {vec_of(IRCon);} contab;
extern struct addrtab {vec_of(IRAddr);} addrtab;
extern int visitmark;
-#define mkinstr(O, C, ...) ((Instr) { .op = (O), .cls = (C), .reg=0, __VA_ARGS__ })
-#define mkarginstr(ty, x) mkinstr(Oarg, 0, mktyperef(ty), (x))
+#define mkinstr0(O, C) ((Instr) { .op = (O), .cls = (C), .reg=0 })
+#define mkinstr1(O, C, x) ((Instr) { .op = (O), .cls = (C), .reg=0, .l = x})
+#define mkinstr2(O, C, x,y) ((Instr) { .op = (O), .cls = (C), .reg=0, .l = x, .r = y})
+#define mkarginstr(ty, x) mkinstr2(Oarg, 0, mktyperef(ty), (x))
void irinit(Function *);
void irfini(Function *);
#define cls2type(k) ((IRType){.cls=(k)})
@@ -276,7 +281,7 @@ Ref mkdatref(internstr sym, Type ctype, uint siz, uint align,
internstr xcon2sym(int ref);
Instr mkalloca(uint siz, uint align);
Ref mkcallarg(IRType ret, uint narg, int vararg);
-#define mkintrin(B, C, N) mkinstr(Ointrin, C, {{.t=RICON,B}}, mkcallarg((IRType){{0}},N,-1))
+#define mkintrin(B, C, N) mkinstr2(Ointrin, C, mkref(RICON, B), mkcallarg((IRType){{0}},N,-1))
Ref mkaddr(IRAddr);
void addpred(Block *blk, Block *p);