Commit ded6fc57 authored by Sapphie's avatar Sapphie
Browse files

Change Value representer to use XOr more

parent 9c120d52
...@@ -141,9 +141,8 @@ abstract class CPSOptimizer[T <: CPSTreeModule { type Name = Symbol }] ...@@ -141,9 +141,8 @@ abstract class CPSOptimizer[T <: CPSTreeModule { type Name = Symbol }]
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 _ => { case _ => {
// If the primitive is id if (false && prim == identity) {
if (prim == identity) { shrink(body, s.withASubst(name, replacedArgs(0)))
shrink(body, s.withASubst(name, s.aSubst(replacedArgs(0))))
} else { } else {
noOp noOp
} }
......
...@@ -302,7 +302,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) { ...@@ -302,7 +302,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
tempLetP(op, Seq(Right(x1), Right(y1))) { truDiv => tempLetP(op, Seq(Right(x1), Right(y1))) { truDiv =>
// Retag the result // Retag the result
tempLetP(CPS.ShiftLeft, Seq(Right(truDiv), lAtomOne)) { shiftedRes => tempLetP(CPS.ShiftLeft, Seq(Right(truDiv), lAtomOne)) { shiftedRes =>
L.LetP(n, CPS.Add, Seq(shiftedRes, L.AtomL(1)), transform(body)) L.LetP(n, CPS.XOr, Seq(shiftedRes, L.AtomL(1)), transform(body))
} }
} }
} }
...@@ -311,12 +311,12 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) { ...@@ -311,12 +311,12 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
prim match { prim match {
case L3.IntAdd => case L3.IntAdd =>
tempLetP(CPS.Sub, Seq(Left(x), lAtomOne)) { x1 => tempLetP(CPS.XOr, Seq(Left(x), lAtomOne)) { x1 =>
L.LetP(n, CPS.Add, Seq(x1, rewrite(y)), transform(body)) L.LetP(n, CPS.Add, Seq(x1, rewrite(y)), transform(body))
} }
case L3.IntSub => case L3.IntSub =>
tempLetP(CPS.Add, Seq(Left(x), lAtomOne)) { x1 => tempLetP(CPS.Sub, Seq(Left(x), Left(y))) { res =>
L.LetP(n, CPS.Sub, Seq(x1, rewrite(y)), transform(body)) L.LetP(n, CPS.XOr, Seq(res, L.AtomL(1)), transform(body))
} }
case L3.IntMul => case L3.IntMul =>
tempLetP(CPS.Sub, Seq(Left(x), lAtomOne)) { x1 => tempLetP(CPS.Sub, Seq(Left(x), lAtomOne)) { x1 =>
...@@ -338,10 +338,10 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) { ...@@ -338,10 +338,10 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
} }
case L3.IntShiftLeft => case L3.IntShiftLeft =>
tempLetP(CPS.Sub, Seq(Left(x), lAtomOne)) { x1 => tempLetP(CPS.XOr, Seq(Left(x), lAtomOne)) { x1 =>
tempLetP(CPS.ShiftRight, Seq(Left(y), lAtomOne)) { y1 => tempLetP(CPS.ShiftRight, Seq(Left(y), lAtomOne)) { y1 =>
tempLetP(CPS.ShiftLeft, Seq(Right(x1), Right(y1))) { z => tempLetP(CPS.ShiftLeft, Seq(Right(x1), Right(y1))) { z =>
L.LetP(n, CPS.Add, Seq(z, L.AtomL(1)), transform(body)) L.LetP(n, CPS.XOr, Seq(z, L.AtomL(1)), transform(body))
} }
} }
} }
...@@ -372,13 +372,13 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) { ...@@ -372,13 +372,13 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
case L3.BlockTag => case L3.BlockTag =>
tempLetP(CPS.BlockTag, args map (Left(_))) { t1 => tempLetP(CPS.BlockTag, args map (Left(_))) { t1 =>
tempLetP(CPS.ShiftLeft, Seq(Right(t1), lAtomOne)) { t2 => tempLetP(CPS.ShiftLeft, Seq(Right(t1), lAtomOne)) { t2 =>
L.LetP(n, CPS.Add, Seq(t2, L.AtomL(1)), transform(body)) L.LetP(n, CPS.XOr, Seq(t2, L.AtomL(1)), transform(body))
} }
} }
case L3.BlockLength => case L3.BlockLength =>
tempLetP(CPS.BlockLength, args map (Left(_))) { t1 => tempLetP(CPS.BlockLength, args map (Left(_))) { t1 =>
tempLetP(CPS.ShiftLeft, Seq(Right(t1), lAtomOne)) { t2 => tempLetP(CPS.ShiftLeft, Seq(Right(t1), lAtomOne)) { t2 =>
L.LetP(n, CPS.Add, Seq(t2, L.AtomL(1)), transform(body)) L.LetP(n, CPS.XOr, Seq(t2, L.AtomL(1)), transform(body))
} }
} }
case L3.BlockSet => case L3.BlockSet =>
......
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