summary refs log tree commit diff
path: root/lisc/ssa.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-07-10 13:55:47 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:27 -0400
commit851e79f9590b705a0fb168d16755caad03650348 (patch)
treee74b6dd89f53b4bd81661387cc6cbdea23836b63 /lisc/ssa.c
parent11db0b61d95d63830e1e87f20464b10c5d316d0f (diff)
downloadroux-851e79f9590b705a0fb168d16755caad03650348.tar.gz
add rpo information to functions
Diffstat (limited to 'lisc/ssa.c')
-rw-r--r--lisc/ssa.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/lisc/ssa.c b/lisc/ssa.c
index e01bcc6..4703d0a 100644
--- a/lisc/ssa.c
+++ b/lisc/ssa.c
@@ -38,3 +38,47 @@ fillpreds(Fn *f)
 			addpred(b, b->s2);
 	}
 }
+
+static int
+rporec(Blk *b, int x)
+{
+	if (b->rpo >= 0)
+		return x;
+	if (b->s1)
+		x = rporec(b->s1, x);
+	if (b->s2)
+		x = rporec(b->s2, x);
+	b->rpo = x;
+	return x - 1;
+}
+
+void
+fillrpo(Fn *f)
+{
+	int n;
+	Blk *b, **p;
+
+	for (b=f->start; b; b=b->link)
+		b->rpo = -1;
+	n = rporec(f->start, f->nblk-1);
+	f->rpo = alloc(n * sizeof(Blk*));
+	for (p=&f->start; *p;) {
+		b = *p;
+		if (b->rpo == -1) {
+			*p = b->link;
+			/* todo, free block */
+		} else {
+			b->rpo -= n;
+			f->rpo[b->rpo] = b;
+			p=&(*p)->link;
+		}
+	}
+}
+
+void
+ssafix(Fn *f, Ref v)
+{
+	(void)f;
+	(void)v;
+	return;
+}