@@ -845,6 +845,7 @@ mutable struct Pipe
845
845
map:: Dict{Any,Any}
846
846
var:: Int
847
847
branch
848
+ block
848
849
end
849
850
850
851
var! (p:: Pipe ) = NewVariable (p. var += 1 )
@@ -857,7 +858,7 @@ substitute(p::Pipe, x::Expr) = Expr(x.head, substitute.((p,), x.args)...)
857
858
substitute (p:: Pipe ) = x -> substitute (p, x)
858
859
859
860
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 )
861
862
for (x, T) in zip (p. from. blocks[1 ]. args, p. from. blocks[1 ]. argtypes)
862
863
y = argument! (blocks (p. to)[end ], nothing , T, insert = false )
863
864
substitute! (p, x, y)
@@ -871,8 +872,10 @@ function pipestate(ir::IR)
871
872
end
872
873
873
874
branches (f, p:: Pipe ) = (p. branch = f)
875
+ blocks (f, p:: Pipe ) = (p. block = f)
874
876
875
877
function iterate (p:: Pipe , (ks, b, i) = (pipestate (p. from), 1 , 1 ))
878
+ i == 1 && b == 1 && p. block (b)
876
879
if i == 1 && b != 1
877
880
for (x, T) in zip (p. from. blocks[b]. args, p. from. blocks[b]. argtypes)
878
881
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))
885
888
br′ == nothing || push! (p. to. blocks[end ]. branches, map (substitute (p), br′))
886
889
end
887
890
b == length (ks) && return
891
+ p. block (b)
888
892
block! (p. to)
889
893
return iterate (p, (ks, b+ 1 , 1 ))
890
894
end
0 commit comments