-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New system for testing generated IR based on pretty printing the IR and comparing to a reference string. String comparison is an excellent way to do IR comparisons because * It's very simple to implement * Writing test cases is simple * It's easy to pinpoint errors in tests * Irrelevant detail can easily be omitted in the pretty printing The main downside is that, in principle, the pretty printing may have ambiguities, and changing the pretty printing causes high churn in test cases. However these seem like reasonable tradeoffs, given the benefits.
- Loading branch information
Showing
4 changed files
with
124 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
###################################### | ||
# Basic branching tail && value | ||
begin | ||
local a, b | ||
if a | ||
b | ||
end | ||
end | ||
#------------------------- | ||
1 slot.₁/a | ||
2 (gotoifnot ssa.₁ label.₅) | ||
3 slot.₂/b | ||
4 (return ssa.₃) | ||
5 core.nothing | ||
6 (return ssa.₅) | ||
|
||
###################################### | ||
# Branching, !tail && !value | ||
begin | ||
local a, b, c | ||
if a | ||
b | ||
end | ||
c | ||
end | ||
#------------------------- | ||
1 slot.₁/a | ||
2 (gotoifnot ssa.₁ label.₄) | ||
3 slot.₂/b | ||
4 slot.₃/c | ||
5 (return ssa.₄) | ||
|
||
###################################### | ||
# Branching with else | ||
begin | ||
local a, b, c | ||
if a | ||
b | ||
else | ||
c | ||
end | ||
end | ||
#--------------------- | ||
1 slot.₁/a | ||
2 (gotoifnot ssa.₁ label.₅) | ||
3 slot.₂/b | ||
4 (return ssa.₃) | ||
5 slot.₃/c | ||
6 (return ssa.₅) | ||
|
||
###################################### | ||
# Branching with else, !tail && !value | ||
begin | ||
local a, b, c, d | ||
if a | ||
b | ||
else | ||
c | ||
end | ||
d | ||
end | ||
#--------------------- | ||
1 slot.₁/a | ||
2 (gotoifnot ssa.₁ label.₅) | ||
3 slot.₂/b | ||
4 (goto label.₆) | ||
5 slot.₃/c | ||
6 slot.₄/d | ||
7 (return ssa.₆) | ||
|
||
###################################### | ||
# Blocks compile directly to branches | ||
begin | ||
local a, b, c, d | ||
if (a; b && c) | ||
d | ||
end | ||
end | ||
#--------------------- | ||
1 slot.₁/a | ||
2 slot.₂/b | ||
3 (gotoifnot ssa.₂ label.₈) | ||
4 slot.₃/c | ||
5 (gotoifnot ssa.₄ label.₈) | ||
6 slot.₄/d | ||
7 (return ssa.₆) | ||
8 core.nothing | ||
9 (return ssa.₈) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,8 @@ break | |
continue | ||
""") | ||
|
||
test_ir_cases(joinpath(@__DIR__, "loops_ir.jl")) | ||
|
||
# TODO: Test scope rules | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters