Adds a new block to the CFG, containing the provided code as its body.
the block expression
a reference to the block
Adds a new block, which ends with a switch/br_table, with provided code and condition (that determines where we go in the switch).
the block expression
contition to determine the jump destination
Adds a branch from a block to another block, with a condition (or nothing, if this is the default branch to take from the origin — each block must have one such branch), and optional code to execute on the branch (useful for phis).
source block
destination block
contition to evaluate: if true, jumps to the given block; else does nothing
code to evaluate in between block jumps
Adds a branch from a block ending in a switch, to another block, using an array of indexes that determine where to go, and optional code to execute on the branch.
source block
destination block
array containing corresponding indices for destination blocks
code to evaluate in between block jumps
Renders and cleans up the Relooper instance. Call this after you have created all the blocks and branches, giving it the entry block (where control flow begins), a label helper variable (an index of a local we can use, necessary for irreducible control flow), and the module. This returns an expression — normal WebAssembly code — that you can use normally anywhere.
Constructs a relooper instance. This lets you provide an arbitrary CFG, and the relooper will structure it for WebAssembly.