aboutsummaryrefslogtreecommitdiff
path: root/src/ir.hff
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-20 11:06:38 +0200
committerlemon <lsof@mailbox.org>2022-08-20 11:06:38 +0200
commit46e1f128fd310bd29a2b4335b36c60d6cc0aa3a7 (patch)
treefeb93a69cf93773d0542435ae09c76de04e509c8 /src/ir.hff
parentdf41a4512932f1312e4725d0409757a683b091ed (diff)
initial work on IR
Diffstat (limited to 'src/ir.hff')
-rw-r--r--src/ir.hff62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/ir.hff b/src/ir.hff
new file mode 100644
index 0000000..987db3b
--- /dev/null
+++ b/src/ir.hff
@@ -0,0 +1,62 @@
+import "cffc.hff";
+
+struct IRCtx {
+ alloc *Allocator,
+}
+
+struct IRInst;
+struct IRFn {
+ body *IRInst
+}
+
+struct IRValue {
+ ty *const Type,
+ u enum union {
+ IImm i64,
+ FImm f64,
+ SImm [#]const u8,
+ BImm bool,
+ Null,
+ Tmp int,
+ }
+}
+
+enum union IRArg {
+ Val IRValue,
+ Ty *const Type,
+ Fn *Decl,
+}
+
+enum IRInstT {
+ neg,
+ compl,
+ fneg,
+ add,
+ sub,
+ mul,
+ div,
+ mod,
+ band,
+ bor,
+ xor,
+ lsl,
+ lsr,
+ asr,
+ fadd,
+ fsub,
+ fmul,
+ fdiv,
+ copy,
+ call,
+ ret0,
+}
+
+struct IRInst {
+ t IRInstT,
+ next *IRInst,
+ cond *IRInst,
+ call_nargs int,
+ args [0]IRArg,
+}
+
+extern fn irdump(*IRInst) void;