aboutsummaryrefslogtreecommitdiffhomepage
path: root/ssa.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssa.c')
-rw-r--r--ssa.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/ssa.c b/ssa.c
index 4ce8774..4a4ed4d 100644
--- a/ssa.c
+++ b/ssa.c
@@ -1,6 +1,29 @@
#include "common.h"
#include "ir.h"
+/* require use, keeps use */
+void
+copyopt(struct function *fn)
+{
+ struct block *blk = fn->entry;
+
+ do {
+ for (int i = 0; i < blk->ins.n; ++i) {
+ struct use *use, *uend;
+ union ref var = mkref(RTMP, blk->ins.p[i]);
+ struct instr *ins = &instrtab[var.i];
+
+ if (ins->op == Ocopy) {
+ assert(ins->l.t != RREG);
+
+ replcuses(var, ins->l);
+ *ins = mkinstr(Onop,0,);
+ deluses(var.i);
+ }
+ }
+ } while ((blk = blk->lnext) != fn->entry);
+}
+
void
filluses(struct function *fn)
{