Skip to content

Commit 35eb283

Browse files
Merge pull request #41 from CompilerProgramming/develop
Bug fixes
2 parents 0c98320 + d4bec63 commit 35eb283

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ The project is under development and subject to change. At this point in time, w
2626
* [semantic](./semantic/README.md) - semantic analyzer
2727
* [stackvm](./stackvm/README.md) - a compiler that generates IR for a stack based virtual machine
2828
* [registervm](./registervm/README.md) - a compiler that generates a so called three-address IR and an interpreter that can execute the IR
29-
* [optvm](./optvm/README.md) - an optimizing compiler (WIP) that supports SSA.
30-
* [seaofnodes](./seaofnodes/README.md) - a compiler that will generate Sea of Nodes IR, using SoN backend from [Simple](https://github.com/SeaOfNodes/Simple).
29+
* [optvm](./optvm/README.md) - WIP optimizing compiler with SSA transformation, constant propagation, graph coloring register allocation
30+
targeting an abstract machine.
31+
* [seaofnodes](./seaofnodes/README.md) - WIP compiler that generates Sea of Nodes IR, using SoN backend from [Simple](https://github.com/SeaOfNodes/Simple).
3132

3233
## How can you contribute?
3334

optvm/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ a physical machine. Therefore, all our optimization passes will work on the inst
3333
each register has a unique integer ID and these ids are allocated in a sequential manner.
3434
* [Liveness](src/main/java/com/compilerprogramming/ezlang/compiler/Liveness.java) - Liveness calculator, works for both SSA and non-SSA forms. Computes
3535
liveness data per basic block - mainly live-out. Note that the interference graph builder starts here and computes instruction level liveness as necessary.
36-
* [EnterSSA](src/main/java/com/compilerprogramming/ezlang/compiler/EnterSSA.java) - Transforms into SSA, using algorithm by Preston Briggs.
36+
* [EnterSSA](src/main/java/com/compilerprogramming/ezlang/compiler/EnterSSA.java) - Transforms into SSA, using [algorithm by Preston Briggs](https://dl.acm.org/doi/10.5555/295545.295551). This is one of available mechanisms to transform the IR into SSA.
37+
The other alternative is to generate SSA IR directly from the AST, using [Braun's method](https://dl.acm.org/doi/10.1007/978-3-642-37051-9_6) - this option is integrated into the
38+
[compiler]((src/main/java/com/compilerprogramming/ezlang/compiler/CompiledFunction.java)) and enabled using an option.
3739
* [ExitSSA](src/main/java/com/compilerprogramming/ezlang/compiler/ExitSSA.java) - Exits SSA form, using algorithm by Preston Briggs.
3840
* [SparseConditionalConstantPropagation](src/main/java/com/compilerprogramming/ezlang/compiler/SparseConditionalConstantPropagation.java) - Conditional Constant Propagation on SSA form (SCCP)
39-
* [SSAEdges](src/main/java/com/compilerprogramming/ezlang/compiler/SSAEdges.java) - SSAEdges are def-use chains used by SCCP algorithm
41+
* [ConstantComparisonPropagation](src/main/java/com/compilerprogramming/ezlang/compiler/ConstantComparisonPropagation.java) - Detects equals and not equals against constants within conditionals,
42+
and inserts variables with appropriately specialized type within the dominated blocks, so that a second pass of SCCP can further optimize code.
43+
* [SSAEdges](src/main/java/com/compilerprogramming/ezlang/compiler/SSAEdges.java) - SSAEdges are def-use chains used by SCCP algorithm, and also generated during incremental SSA construction using Braun's method.
4044
* [LoopFinder](src/main/java/com/compilerprogramming/ezlang/compiler/LoopFinder.java) - Discovers loops. (Not used yet)
4145
* [LoopNest](src/main/java/com/compilerprogramming/ezlang/compiler/LoopNest.java) - Representation of loop nesting. (Not used yet)
4246
* [InterferenceGraph](src/main/java/com/compilerprogramming/ezlang/compiler/InterferenceGraph.java) - Representation of an Interference Graph

optvm/src/test/java/com/compilerprogramming/ezlang/interpreter/TestInterpreter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ public void testMergeSort() {
613613
String src = """
614614
// based on the top-down version from https://en.wikipedia.org/wiki/Merge_sort
615615
// via https://github.com/SeaOfNodes/Simple
616-
func merge_sort(a: [Int], b: [int], n: Int)
616+
func merge_sort(a: [Int], b: [Int], n: Int)
617617
{
618618
copy_array(a, 0, n, b)
619619
split_merge(a, 0, n, b)

registervm/src/test/java/com/compilerprogramming/ezlang/interpreter/TestInterpreter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public void testMergeSort() {
250250
String src = """
251251
// based on the top-down version from https://en.wikipedia.org/wiki/Merge_sort
252252
// via https://github.com/SeaOfNodes/Simple
253-
func merge_sort(a: [Int], b: [int], n: Int)
253+
func merge_sort(a: [Int], b: [Int], n: Int)
254254
{
255255
copy_array(a, 0, n, b)
256256
split_merge(a, 0, n, b)

seaofnodes/src/main/java/com/compilerprogramming/ezlang/compiler/Compiler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,11 @@ private Node compileLet(AST.VarStmt letStmt) {
941941
}
942942

943943
private Node compileReturn(AST.ReturnStmt returnStmt) {
944-
var expr = compileExpr(returnStmt.expr);
944+
Node expr;
945+
if (returnStmt.expr != null)
946+
expr = compileExpr(returnStmt.expr);
947+
else
948+
expr = ZERO;
945949
// Need default memory, since it can be lazy, need to force
946950
// a non-lazy Phi
947951
_fun.addReturn(ctrl(), _scope.mem().merge(), expr);

0 commit comments

Comments
 (0)