From 136dcf88a71304a3c90890e534139ec1ef8c8b17 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Fri, 31 Aug 2018 03:55:43 -0300 Subject: [PATCH] Add OpLoopMerge --- include/sirit/sirit.h | 4 ++++ src/insts/flow.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 1e6da4d..00f64e3 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -154,6 +154,10 @@ public: // Flow + /// Declare a structured loop. + Ref LoopMerge(Ref merge_block, Ref continue_target, spv::LoopControlMask loop_control, + const std::vector& literals = {}); + /// The block label instruction: Any reference to a block is through this ref. Ref Label(); diff --git a/src/insts/flow.cpp b/src/insts/flow.cpp index e1f0b4b..d97b324 100644 --- a/src/insts/flow.cpp +++ b/src/insts/flow.cpp @@ -9,6 +9,16 @@ namespace Sirit { +Ref Module::LoopMerge(Ref merge_block, Ref continue_target, spv::LoopControlMask loop_control, + const std::vector& literals) { + Op* op{new Op(spv::Op::OpLoopMerge)}; + op->Add(merge_block); + op->Add(continue_target); + AddEnum(op, loop_control); + op->Add(literals); + return AddCode(op); +} + Ref Module::Label() { return AddCode(spv::Op::OpLabel, bound++); }