aboutsummaryrefslogtreecommitdiffhomepage
path: root/ir.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-05-31 23:31:58 +0200
committerlemon <lsof@mailbox.org>2023-05-31 23:31:58 +0200
commit82cac0ae5d4e335719445857ab16ffdf05413222 (patch)
tree51af015a1eed86d8a6c543f415d3b5107a5043bd /ir.c
parente2d649f575c31d96f2fc7595594ba8c360f7bdc5 (diff)
regalloc skeleton
Diffstat (limited to 'ir.c')
-rw-r--r--ir.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/ir.c b/ir.c
index 3d2ad8e..65280f8 100644
--- a/ir.c
+++ b/ir.c
@@ -1,7 +1,7 @@
#include "ir.h"
#include "common.h"
-uchar type2cls[TYARRAY + 1];
+uchar type2cls[NTYPETAG];
uchar cls2siz[KF8+1];
const uchar siz2intcls[] = { [1] = KI4, [2] = KI4, [4] = KI4, [8] = KI8 };
@@ -34,6 +34,7 @@ irinit(struct function *fn)
cls2siz[KPTR] = targ_primsizes[TYPTR];
}
fn->entry = fn->curblk = alloc(&fn->arena, sizeof(struct block), 0);
+ memset(fn->entry, 0, sizeof *fn->entry);
fn->entry->lprev = fn->entry->lnext = fn->entry;
}
@@ -264,4 +265,25 @@ putjump(struct function *fn, enum jumpkind j, union ref arg, struct block *t, st
fn->curblk = NULL;
}
+static void
+freefn(struct function *fn)
+{
+ struct block *blk = fn->entry;
+ do {
+ vfree(&blk->phi);
+ vfree(&blk->ins);
+ blk = blk->lnext;
+ } while (blk != fn->entry);
+}
+
+void
+irfini(struct function *fn)
+{
+ regalloc(fn);
+ efmt("after regalloc:\n");
+ irdump(fn, fn->name);
+
+ freefn(fn);
+}
+
/* vim:set ts=3 sw=3 expandtab: */