From 48ddaf491329c1152b70cdc70b64ffd1eec611c9 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Fri, 31 Aug 2018 04:05:12 -0300 Subject: [PATCH] Add OpSelectionMerge --- include/sirit/sirit.h | 3 +++ src/insts/flow.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 00f64e3..a2b4e9b 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -158,6 +158,9 @@ public: Ref LoopMerge(Ref merge_block, Ref continue_target, spv::LoopControlMask loop_control, const std::vector& literals = {}); + /// Declare a structured selection. + Ref SelectionMerge(Ref merge_block, spv::SelectionControlMask selection_control); + /// 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 d97b324..a7baac7 100644 --- a/src/insts/flow.cpp +++ b/src/insts/flow.cpp @@ -19,6 +19,13 @@ Ref Module::LoopMerge(Ref merge_block, Ref continue_target, spv::LoopControlMask return AddCode(op); } +Ref Module::SelectionMerge(Ref merge_block, spv::SelectionControlMask selection_control) { + Op* op{new Op(spv::Op::OpSelectionMerge)}; + op->Add(merge_block); + AddEnum(op, selection_control); + return AddCode(op); +} + Ref Module::Label() { return AddCode(spv::Op::OpLabel, bound++); }