From cdeeb9127c17d2b15235bb1379f055caf71dcaff Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Fri, 31 Aug 2018 04:10:05 -0300 Subject: [PATCH] Add OpBranch --- include/sirit/sirit.h | 3 +++ src/insts/flow.cpp | 6 ++++++ 2 files changed, 9 insertions(+) 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); }