2.3. Control Flow¶
TODO.
2.3.1. Instructions¶
-
block.end
[flow::BlockEnd]
¶ Internal instruction marking the end of a block that doesn’t have any other terminator.
-
call
op1 op2
[flow::CallVoid]
¶ Operator 1: function() -> void Operator 2: tuple<*>
-
dispatch
op1 op2 op3
[flow::DispatchUnion]
¶ Operator 1: union<*> Operator 2: label Operator 3: tuple<*> Branches to one of several alternatives. The type of the current value of union op1 determines which alternative to take. op3 is a tuple of giving all alternatives as 2-tuples (type, destination). type must be one of the types that the union op1 defines. and destination is a block label. If type equals that of the current value of op1, control is transfered to the corresponding block. If multiple alternatives match the type, one of them is taken but it’s undefined which one. If no alternative matches (including when no unit field is set), control is transfered to block op2.
-
if.else
op1 op2 op3
[flow::IfElse]
¶ Operator 1: bool Operator 2: label Operator 3: label Transfers control label op2 if op1 is true, and to op3 otherwise.
-
jump
op1
[flow::Jump]
¶ Operator 1: label Jumps unconditionally to label op2.
-
return.result
op1
[flow::ReturnResult]
¶ Operator 1: any
-
return.void
[flow::ReturnVoid]
¶
-
switch
op1 op2 op3
[flow::Switch]
¶ Operator 1: any Operator 2: label Operator 3: tuple<*> Branches to one of several alternatives. op1 determines which alternative to take. op3 is a tuple of giving all alternatives as 2-tuples (value, destination). value must be of the same type as op1, and destination is a block label. If value equals op1, control is transfered to the corresponding block. If multiple alternatives match op1, one of them is taken but it’s undefined which one. If no alternative matches, control is transfered to block op2.
-
yield
[flow::Yield]
¶ Yields processing back to the current scheduler, to be resumed later. If running in a virtual thread other than zero, this instruction yields to other virtual threads running within the same physical thread. If running in virtual thread zero (or in non-threading mode), returns execution back to the calling C function (see interfacing with C).
-
yield.until
op1
[flow::YieldUntil]
¶ Operator 1: any