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
07caad17
Commit
07caad17
authored
Apr 16, 2021
by
Sapphie
Browse files
Begin optimiser implementation
parent
92317d94
Changes
1
Show whitespace changes
Inline
Side-by-side
compiler/src/l3/CPSOptimizer.scala
View file @
07caad17
...
...
@@ -276,28 +276,82 @@ object CPSOptimizerHigh extends CPSOptimizer(SymbolicCPSTreeModule)
protected
val
unstable
:
ValuePrimitive
=>
Boolean
=
???
protected
val
blockAllocTag
:
PartialFunction
[
ValuePrimitive
,
Literal
]
=
???
protected
val
blockTag
:
ValuePrimitive
=
???
protected
val
blockLength
:
ValuePrimitive
=
???
protected
val
blockAllocTag
:
PartialFunction
[
ValuePrimitive
,
Literal
]
=
{
case
BlockAlloc
(
t
)
=>
t
}
protected
val
blockTag
:
ValuePrimitive
=
BlockTag
protected
val
blockLength
:
ValuePrimitive
=
BlockLength
protected
val
identity
:
ValuePrimitive
=
???
protected
val
identity
:
ValuePrimitive
=
Id
protected
val
leftNeutral
:
Set
[(
Literal
,
ValuePrimitive
)]
=
???
protected
val
rightNeutral
:
Set
[(
ValuePrimitive
,
Literal
)]
=
???
protected
val
leftNeutral
:
Set
[(
Literal
,
ValuePrimitive
)]
=
Set
(
(
IntLit
(
L3Int
(
0
)),
IntAdd
),
(
IntLit
(
L3Int
(
1
)),
IntMul
),
(
IntLit
(
L3Int
((-
1
<<
1
)
>>
1
)),
IntBitwiseAnd
),
(
IntLit
(
L3Int
(
0
)),
IntBitwiseOr
),
(
IntLit
(
L3Int
(
0
)),
IntBitwiseXOr
)
)
protected
val
rightNeutral
:
Set
[(
ValuePrimitive
,
Literal
)]
=
Set
(
(
IntAdd
,
IntLit
(
L3Int
(
0
))),
(
IntSub
,
IntLit
(
L3Int
(
0
))),
(
IntMul
,
IntLit
(
L3Int
(
1
))),
(
IntDiv
,
IntLit
(
L3Int
(
1
))),
(
IntShiftLeft
,
IntLit
(
L3Int
(
0
))),
(
IntShiftRight
,
IntLit
(
L3Int
(
0
))),
(
IntBitwiseAnd
,
IntLit
(
L3Int
((-
1
<<
1
)
>>
1
))),
(
IntBitwiseOr
,
IntLit
(
L3Int
(
0
))),
(
IntBitwiseXOr
,
IntLit
(
L3Int
(
0
))),
)
protected
val
leftAbsorbing
:
Set
[(
Literal
,
ValuePrimitive
)]
=
Set
(
(
IntLit
(
L3Int
(
0
)),
IntMul
),
(
IntLit
(
L3Int
(
0
)),
IntMod
),
(
IntLit
(
L3Int
(
0
)),
IntBitwiseAnd
),
(
IntLit
(
L3Int
((-
1
<<
1
)
>>
1
)),
IntBitwiseOr
),
(
IntLit
(
L3Int
(
0
)),
IntShiftLeft
),
(
IntLit
(
L3Int
(
0
)),
IntShiftRight
)
)
protected
val
rightAbsorbing
:
Set
[(
ValuePrimitive
,
Literal
)]
=
Set
(
(
IntMul
,
IntLit
(
L3Int
(
0
))),
(
IntBitwiseAnd
,
IntLit
(
L3Int
(
0
))),
(
IntBitwiseOr
,
IntLit
(
L3Int
((-
1
<<
1
)
>>
1
)))
)
protected
val
leftAbsorbing
:
Set
[(
Literal
,
ValuePrimitive
)]
=
???
protected
val
rightAbsorbing
:
Set
[(
ValuePrimitive
,
Literal
)]
=
???
protected
val
sameArgReduce
:
PartialFunction
[(
ValuePrimitive
,
Atom
)
,
Atom
]
=
{
case
(
IntBitwiseAnd
|
IntBitwiseOr
,
a
)
=>
a
case
(
IntSub
|
IntBitwiseXOr
|
IntMod
,
_
)
=>
AtomL
(
IntLit
(
L3Int
(
0
)))
case
(
IntDiv
,
_
)
=>
AtomL
(
IntLit
(
L3Int
(
1
)))
}
protected
val
sameArgReduce
:
PartialFunction
[(
ValuePrimitive
,
Atom
)
,
Atom
]
=
???
protected
val
sameArgReduceC
:
PartialFunction
[
TestPrimitive
,
Boolean
]
=
???
protected
val
sameArgReduceC
:
PartialFunction
[
TestPrimitive
,
Boolean
]
=
{
case
IntLt
=>
false
case
IntLe
|
Eq
=>
true
}
protected
val
vEvaluator
:
PartialFunction
[(
ValuePrimitive
,
Seq
[
Literal
])
,
Literal
]
=
???
Literal
]
=
{
case
(
vPrim
,
Seq
(
IntLit
(
x
),
IntLit
(
y
)))
=>
vPrim
match
{
case
IntAdd
=>
IntLit
(
x
+
y
)
case
IntSub
=>
IntLit
(
x
-
y
)
case
IntMod
=>
IntLit
(
x
%
y
)
case
IntDiv
=>
IntLit
(
x
/
y
)
case
IntMul
=>
IntLit
(
x
*
y
)
case
IntBitwiseAnd
=>
IntLit
(
x
&
y
)
case
IntBitwiseOr
=>
IntLit
(
x
|
y
)
case
IntBitwiseXOr
=>
IntLit
(
x
^
y
)
case
IntShiftLeft
=>
IntLit
(
x
<<
y
)
case
IntShiftRight
=>
IntLit
(
x
>>
y
)
}
}
protected
val
cEvaluator
:
PartialFunction
[(
TestPrimitive
,
Seq
[
Literal
])
,
Boolean
]
=
???
Boolean
]
=
{
case
(
IntLe
,
Seq
(
IntLit
(
x
),
IntLit
(
y
)))
=>
x
<=
y
case
(
IntLt
,
Seq
(
IntLit
(
x
),
IntLit
(
y
)))
=>
x
<
y
case
(
Eq
,
Seq
(
l1
,
l2
))
=>
l1
==
l2
}
}
object
CPSOptimizerLow
extends
CPSOptimizer
(
SymbolicCPSTreeModuleLow
)
...
...
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