Commit 4399af88 authored by Sapphie's avatar Sapphie
Browse files

Implement blocklength reduction

parent 2ae235d7
...@@ -142,14 +142,21 @@ abstract class CPSOptimizer[T <: CPSTreeModule { type Name = Symbol }] ...@@ -142,14 +142,21 @@ abstract class CPSOptimizer[T <: CPSTreeModule { type Name = Symbol }]
// Right Absorbing // Right Absorbing
case Seq(a1, AtomL(l2)) if rightAbsorbing((prim, l2)) => case Seq(a1, AtomL(l2)) if rightAbsorbing((prim, l2)) =>
shrink(body, s.withASubst(name, l2)) shrink(body, s.withASubst(name, l2))
case Seq(a1) if prim == blockTag && s.eEnv.isDefinedAt(a1) => case Seq(a1) if s.eEnv.isDefinedAt(a1) =>
val maybeBlockAlloc = s.eEnv(a1)._1 val (maybeBlockAlloc, maybeLengthAtom) = s.eEnv(a1)
blockAllocTag.lift(maybeBlockAlloc) match { blockAllocTag.lift(maybeBlockAlloc) match {
case Some(tag) => case Some(tag) =>
if (prim == blockTag) {
shrink(body, s.withASubst(name, AtomL(tag))) shrink(body, s.withASubst(name, AtomL(tag)))
} else if (prim == blockLength) {
shrink(body, s.withASubst(name, maybeLengthAtom(0)))
} else {
noOp
}
case None => case None =>
noOp noOp
} }
case _ => noOp case _ => noOp
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment