Skip to content
Snippets Groups Projects
Commit 2ae235d7 authored by Sapphie's avatar Sapphie
Browse files

Implement blocktag reduction

parent 63f24da2
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,8 @@ abstract class CPSOptimizer[T <: CPSTreeModule { type Name = Symbol }]
cEnv: Map[Name, Cnt] = Map.empty,
fEnv: Map[Name, Fun] = Map.empty) {
def eEnv: Map[Atom, (ValuePrimitive, Seq[Atom])] =
eInvEnv.map(_.swap)
def dead(s: Name): Boolean =
! census.contains(s)
def appliedOnce(s: Name): Boolean =
......@@ -140,6 +142,14 @@ abstract class CPSOptimizer[T <: CPSTreeModule { type Name = Symbol }]
// Right Absorbing
case Seq(a1, AtomL(l2)) if rightAbsorbing((prim, l2)) =>
shrink(body, s.withASubst(name, l2))
case Seq(a1) if prim == blockTag && s.eEnv.isDefinedAt(a1) =>
val maybeBlockAlloc = s.eEnv(a1)._1
blockAllocTag.lift(maybeBlockAlloc) match {
case Some(tag) =>
shrink(body, s.withASubst(name, AtomL(tag)))
case None =>
noOp
}
case _ => noOp
}
}
......
......@@ -14,15 +14,15 @@ object Main {
val stats = new Statistics()
val backEnd: Tree => TerminalPhaseResult = (
CL3ToCPSTranslator
andThen treePrinter("---------- After CPS translation")
// andThen treePrinter("---------- After CPS translation")
andThen CPSOptimizerHigh
andThen treePrinter("---------- After Optimization (High)")
// andThen treePrinter("---------- After Optimization (High)")
andThen treeChecker
andThen CPSValueRepresenter
andThen treePrinter("---------- After value representation")
// andThen treePrinter("---------- After value representation")
andThen treeChecker
andThen CPSHoister
andThen treePrinter("---------- After hoisting")
// andThen treePrinter("---------- After hoisting")
andThen CPSOptimizerLow
andThen treePrinter("---------- After Optimization (Low)")
andThen treeChecker
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment