Stream: cranelift

Topic: Where does `InstructionData::Branch` store the branch cond?


view this post on Zulip Teymour Aldridge (Jan 05 2022 at 17:21):

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.

view this post on Zulip Chris Fallin (Jan 05 2022 at 17:23):

It's implicitly included in the opcode -- the two opcodes that use the Branch format are Brz and Brnz (zero, not-zero)

view this post on Zulip Chris Fallin (Jan 05 2022 at 17:23):

other branch types that use other conditions (e.g. brif -- branch on iflags condition) use the BranchCond instruction format

view this post on Zulip Teymour Aldridge (Jan 05 2022 at 17:25):

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?

view this post on Zulip Chris Fallin (Jan 05 2022 at 17:27):

yes, exactly

view this post on Zulip Teymour Aldridge (Jan 05 2022 at 17:32):

Thanks!


Last updated: Oct 23 2024 at 20:03 UTC