aboutsummaryrefslogtreecommitdiffhomepage
path: root/ir
diff options
context:
space:
mode:
Diffstat (limited to 'ir')
-rw-r--r--ir/ir.c27
-rw-r--r--ir/ir.h4
-rw-r--r--ir/mem2reg.c (renamed from ir/optmem.c)0
-rw-r--r--ir/ssa.c28
4 files changed, 29 insertions, 30 deletions
diff --git a/ir/ir.c b/ir/ir.c
index 553885d..8ae41a9 100644
--- a/ir/ir.c
+++ b/ir/ir.c
@@ -403,6 +403,33 @@ Shrink:
return 1;
}
+void
+filluses(struct function *fn)
+{
+ struct block *blk = fn->entry;
+
+ for (int i = 0; i < ninstr; ++i)
+ deluses(i);
+
+ do {
+ for (int i = 0; i < blk->phi.n; ++i) {
+ int ins = blk->phi.p[i];
+ union ref *phi = phitab.p[instrtab[ins].l.i];
+ for (int i = 0; i < blk->npred; ++i)
+ adduse(blk, ins, phi[i]);
+ }
+ for (int i = 0; i < blk->ins.n; ++i) {
+ int ins = blk->ins.p[i];
+ adduse(blk, ins, instrtab[ins].l);
+ adduse(blk, ins, instrtab[ins].r);
+ }
+ adduse(blk, USERJUMP, blk->jmp.arg[0]);
+ adduse(blk, USERJUMP, blk->jmp.arg[1]);
+ } while ((blk = blk->lnext) != fn->entry);
+
+ fn->prop |= FNUSE;
+}
+
int
newinstr(struct block *at, struct instr ins)
{
diff --git a/ir/ir.h b/ir/ir.h
index 174cdab..4049811 100644
--- a/ir/ir.h
+++ b/ir/ir.h
@@ -271,6 +271,7 @@ union ref insertphi(struct block *, enum irclass cls);
void replcuses(union ref from, union ref to);
bool deluse(struct block *ublk, int ui, union ref r);
void deluses(int ins);
+void filluses(struct function *);
void delinstr(struct block *, int idx);
void delphi(struct block *, int idx);
void delnops(struct block *blk);
@@ -300,7 +301,6 @@ bool foldunop(union ref *to, enum op, enum irclass, union ref);
void irdump(struct function *);
/** ssa.c **/
-void filluses(struct function *);
void copyopt(struct function *);
/** cfg.c **/
@@ -311,7 +311,7 @@ void filldom(struct function *fn);
void abi0(struct function *);
void abi0_call(struct function *, struct instr *, struct block *blk, int *curi);
-/** optmem.c **/
+/** mem2reg.c **/
void mem2reg(struct function *);
/** intrin.c **/
diff --git a/ir/optmem.c b/ir/mem2reg.c
index f9ad245..f9ad245 100644
--- a/ir/optmem.c
+++ b/ir/mem2reg.c
diff --git a/ir/ssa.c b/ir/ssa.c
index 5c9c8f3..31cab4b 100644
--- a/ir/ssa.c
+++ b/ir/ssa.c
@@ -39,32 +39,4 @@ copyopt(struct function *fn)
} while ((blk = blk->lnext) != fn->entry);
}
-void
-filluses(struct function *fn)
-{
- extern int ninstr;
- struct block *blk = fn->entry;
-
- for (int i = 0; i < ninstr; ++i)
- deluses(i);
-
- do {
- for (int i = 0; i < blk->phi.n; ++i) {
- int ins = blk->phi.p[i];
- union ref *phi = phitab.p[instrtab[ins].l.i];
- for (int i = 0; i < blk->npred; ++i)
- adduse(blk, ins, phi[i]);
- }
- for (int i = 0; i < blk->ins.n; ++i) {
- int ins = blk->ins.p[i];
- adduse(blk, ins, instrtab[ins].l);
- adduse(blk, ins, instrtab[ins].r);
- }
- adduse(blk, USERJUMP, blk->jmp.arg[0]);
- adduse(blk, USERJUMP, blk->jmp.arg[1]);
- } while ((blk = blk->lnext) != fn->entry);
-
- fn->prop |= FNUSE;
-}
-
/* vim:set ts=3 sw=3 expandtab: */