diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index a2b4e9b..1fe338f 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -164,6 +164,9 @@ public: /// The block label instruction: Any reference to a block is through this ref. Ref Label(); + /// Unconditional jump to label. + Ref Branch(Ref target_label); + /// Returns with no value from a function with void return type. Ref Return(); diff --git a/src/insts/flow.cpp b/src/insts/flow.cpp index a7baac7..a9edf5c 100644 --- a/src/insts/flow.cpp +++ b/src/insts/flow.cpp @@ -30,6 +30,12 @@ Ref Module::Label() { return AddCode(spv::Op::OpLabel, bound++); } +Ref Module::Branch(Ref target_label) { + Op* op{new Op(spv::Op::OpBranch)}; + op->Add(target_label); + return AddCode(op); +} + Ref Module::Return() { return AddCode(spv::Op::OpReturn); }