Skip to content

Commit f14ff10

Browse files
committed
pipe: block function
1 parent 65ed539 commit f14ff10

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/ir/ir.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,7 @@ mutable struct Pipe
845845
map::Dict{Any,Any}
846846
var::Int
847847
branch
848+
block
848849
end
849850

850851
var!(p::Pipe) = NewVariable(p.var += 1)
@@ -857,7 +858,7 @@ substitute(p::Pipe, x::Expr) = Expr(x.head, substitute.((p,), x.args)...)
857858
substitute(p::Pipe) = x -> substitute(p, x)
858859

859860
function Pipe(ir)
860-
p = Pipe(ir, IR(copy(ir.lines), meta = ir.meta), Dict(), 0, identity)
861+
p = Pipe(ir, IR(copy(ir.lines), meta = ir.meta), Dict(), 0, identity, identity)
861862
for (x, T) in zip(p.from.blocks[1].args, p.from.blocks[1].argtypes)
862863
y = argument!(blocks(p.to)[end], nothing, T, insert = false)
863864
substitute!(p, x, y)
@@ -871,8 +872,10 @@ function pipestate(ir::IR)
871872
end
872873

873874
branches(f, p::Pipe) = (p.branch = f)
875+
blocks(f, p::Pipe) = (p.block = f)
874876

875877
function iterate(p::Pipe, (ks, b, i) = (pipestate(p.from), 1, 1))
878+
i == 1 && b == 1 && p.block(b)
876879
if i == 1 && b != 1
877880
for (x, T) in zip(p.from.blocks[b].args, p.from.blocks[b].argtypes)
878881
y = argument!(blocks(p.to)[end], nothing, T, insert = false)
@@ -885,6 +888,7 @@ function iterate(p::Pipe, (ks, b, i) = (pipestate(p.from), 1, 1))
885888
br′ == nothing || push!(p.to.blocks[end].branches, map(substitute(p), br′))
886889
end
887890
b == length(ks) && return
891+
p.block(b)
888892
block!(p.to)
889893
return iterate(p, (ks, b+1, 1))
890894
end

0 commit comments

Comments
 (0)