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
2ae235d7
Commit
2ae235d7
authored
May 06, 2021
by
Sapphie
Browse files
Implement blocktag reduction
parent
63f24da2
Changes
2
Hide whitespace changes
Inline
Side-by-side
compiler/src/l3/CPSOptimizer.scala
View file @
2ae235d7
...
...
@@ -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
}
}
...
...
compiler/src/l3/Main.scala
View file @
2ae235d7
...
...
@@ -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
...
...
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