-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
BasicBlock
to separate source file
This is so we can add type declarations to fields in ir.jl that are domtrees, by breaking the dependency loop between domtree.jl (uses basic blocks but defines domtrees) and ir.jl (uses domtrees but defined basic blocks).
- Loading branch information
Showing
3 changed files
with
36 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
""" | ||
Like UnitRange{Int}, but can handle the `last` field, being temporarily | ||
< first (this can happen during compacting) | ||
""" | ||
struct StmtRange <: AbstractUnitRange{Int} | ||
start::Int | ||
stop::Int | ||
end | ||
|
||
first(r::StmtRange) = r.start | ||
last(r::StmtRange) = r.stop | ||
iterate(r::StmtRange, state=0) = (last(r) - first(r) < state) ? nothing : (first(r) + state, state + 1) | ||
|
||
StmtRange(range::UnitRange{Int}) = StmtRange(first(range), last(range)) | ||
|
||
struct BasicBlock | ||
stmts::StmtRange | ||
preds::Vector{Int} | ||
succs::Vector{Int} | ||
end | ||
|
||
function BasicBlock(stmts::StmtRange) | ||
return BasicBlock(stmts, Int[], Int[]) | ||
end | ||
|
||
function BasicBlock(old_bb, stmts) | ||
return BasicBlock(stmts, old_bb.preds, old_bb.succs) | ||
end | ||
|
||
copy(bb::BasicBlock) = BasicBlock(bb.stmts, copy(bb.preds), copy(bb.succs)) |
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