In https://docs.rs/cranelift-codegen/latest/cranelift_codegen/ir/instructions/enum.InstructionData.html#variant.Branch, where is the branch condition stored? I thought it might be in args
, but those are (I think) supposed to be passed to the block that is being branched to.
It's implicitly included in the opcode -- the two opcodes that use the Branch format are Brz and Brnz (zero, not-zero)
other branch types that use other conditions (e.g. brif -- branch on iflags condition) use the BranchCond instruction format
I'm trying to translate brnz
into WebAssembly – would I check if the first argument is non-zero, and then pass the rest onto the destination block, or something else?
yes, exactly
Thanks!
Last updated: Nov 22 2024 at 17:03 UTC