Replies: 1 comment 4 replies
-
Binaryen IR is designed to be as similar as possible to WebAssembly itself (with the exception that it is an AST rather than a stack machine), so the IR can only directly represent control flow that WebAssembly itself can directly represent. As you've noted, the C API provides a utility for constructing IR from arbitrary CFGs using the relooper, but there is currently no textual representation for arbitrary CFGs. Whether it makes sense to add a text format for arbitrary CFGs is an interesting question. Just like the IR itself, Binaryen's text format is as close as possible to WebAssembly's standard text format. We've even discussed options for replacing Binaryen's text format parser with one that conforms to the standard completely. A text format for supporting arbitrary CFGs would have to be an additional non-standard text format on top of that, and it's not clear whether the benefit outweighs the cost of defining and maintaining a new non-standard text format when it is generally more efficient to pass code to Binaryen as a binary or via the C API, where text formats are not involved. |
Beta Was this translation helpful? Give feedback.
-
We are evaluating Binaryen for the ballerina-lang wasm backend.
Is it possible to express arbitrary CFG in Binaryen IR ? Or is it only possible via the Relooper C API?
From experimenting and reading the code, it looks like the answer is "it's only available via the C API". If the answer is that, appreciate it if you can explain if it makes sense for Binaryen to have a textual input format that can express arbitrary CFG, or is there a fundamental reason this doesn't make sense.
Beta Was this translation helpful? Give feedback.
All reactions