Say, I have an instance of IRCode like this:
7 1 ─ %1 = Main.bar(_2)::Tuple{Float64, Float64} │
│ %2 = Base.indexed_iterate(%1, 1)::PartialStruct(Tuple{Float64, Int64}, Any[Float64, Const(2)])
│ %3 = Core.getfield(%2, 1)::Float64 │
│ %4 = Core.getfield(%2, 2)::Const(2) │
│ %9 = π (%4, Const(2)) │
│ %5 = Base.indexed_iterate(%1, 2, %9)::PartialStruct(Tuple{Float64, Int64}, Any[Float64, Const(3)])
│ %6 = Core.getfield(%5, 1)::Float64 │
8 │ %7 = (%3 + %6)::Float64 │
└── return %7
I know how to:
- get the list of all original nodes:
ir.stmts.inst
- get the ids of nodes in the
i
th block:ir.cfg.blocks[i].stmts
- get the list of new nodes, e.g. the
PiNode
above, as well as their place in the common list of nodes:ir.new_nodes.stmts.inst
,ir.new_nodes.info
Now I want to get the list of all nodes - the original and the new ones - belonging to a particular block. Is there a mapping of blocks to new nodes or an utility function to iterate all block statements in the correct order?