Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Haley Sapphie Owsianko
ACC-project
Commits
ded6fc57
Commit
ded6fc57
authored
May 01, 2021
by
Sapphie
Browse files
Change Value representer to use XOr more
parent
9c120d52
Changes
2
Hide whitespace changes
Inline
Side-by-side
compiler/src/l3/CPSOptimizer.scala
View file @
ded6fc57
...
...
@@ -141,9 +141,8 @@ abstract class CPSOptimizer[T <: CPSTreeModule { type Name = Symbol }]
case
Seq
(
a1
,
AtomL
(
l2
))
if
rightAbsorbing
((
prim
,
l2
))
=>
shrink
(
body
,
s
.
withASubst
(
name
,
l2
))
case
_
=>
{
// If the primitive is id
if
(
prim
==
identity
)
{
shrink
(
body
,
s
.
withASubst
(
name
,
s
.
aSubst
(
replacedArgs
(
0
))))
if
(
false
&&
prim
==
identity
)
{
shrink
(
body
,
s
.
withASubst
(
name
,
replacedArgs
(
0
)))
}
else
{
noOp
}
...
...
compiler/src/l3/CPSValueRepresenter.scala
View file @
ded6fc57
...
...
@@ -302,7 +302,7 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
tempLetP
(
op
,
Seq
(
Right
(
x1
),
Right
(
y1
)))
{
truDiv
=>
// Retag the result
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) {
prim
match
{
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
))
}
case
L3
.
IntSub
=>
tempLetP
(
CPS
.
Add
,
Seq
(
Left
(
x
),
lAtomOne
))
{
x1
=>
L
.
LetP
(
n
,
CPS
.
Sub
,
Seq
(
x1
,
rewrite
(
y
)),
transform
(
body
))
tempLetP
(
CPS
.
Sub
,
Seq
(
Left
(
x
),
Left
(
y
))
)
{
res
=>
L
.
LetP
(
n
,
CPS
.
XOr
,
Seq
(
res
,
L
.
AtomL
(
1
)),
transform
(
body
))
}
case
L3
.
IntMul
=>
tempLetP
(
CPS
.
Sub
,
Seq
(
Left
(
x
),
lAtomOne
))
{
x1
=>
...
...
@@ -338,10 +338,10 @@ object CPSValueRepresenter extends (H.Tree => L.Tree) {
}
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
.
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) {
case
L3
.
BlockTag
=>
tempLetP
(
CPS
.
BlockTag
,
args
map
(
Left
(
_
)))
{
t1
=>
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
=>
tempLetP
(
CPS
.
BlockLength
,
args
map
(
Left
(
_
)))
{
t1
=>
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
=>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment