/* This file is part of the sirit project. * Copyright (c) 2018 ReinUsesLisp * This software may be used and distributed according to the terms of the GNU * Lesser General Public License version 2.1 or any later version. */ #include "common_types.h" #include "op.h" #include "sirit/sirit.h" #include namespace Sirit { Id Module::OpLoopMerge(Id merge_block, Id continue_target, spv::LoopControlMask loop_control, const std::vector& literals) { auto op{std::make_unique(spv::Op::OpLoopMerge)}; op->Add(merge_block); op->Add(continue_target); op->Add(static_cast(loop_control)); op->Add(literals); return AddCode(std::move(op)); } Id Module::OpSelectionMerge(Id merge_block, spv::SelectionControlMask selection_control) { auto op{std::make_unique(spv::Op::OpSelectionMerge)}; op->Add(merge_block); op->Add(static_cast(selection_control)); return AddCode(std::move(op)); } Id Module::OpLabel() { return AddCode(spv::Op::OpLabel, bound++); } Id Module::OpBranch(Id target_label) { auto op{std::make_unique(spv::Op::OpBranch)}; op->Add(target_label); return AddCode(std::move(op)); } Id Module::OpBranchConditional(Id condition, Id true_label, Id false_label, u32 true_weight, u32 false_weight) { auto op{std::make_unique(spv::Op::OpBranchConditional)}; op->Add(condition); op->Add(true_label); op->Add(false_label); if (true_weight != 0 || false_weight != 0) { op->Add(true_weight); op->Add(false_weight); } return AddCode(std::move(op)); } Id Module::OpReturn() { return AddCode(spv::Op::OpReturn); } Id Module::OpReturnValue(Id value) { auto op{std::make_unique(spv::Op::OpReturnValue)}; op->Add(value); return AddCode(std::move(op)); } } // namespace Sirit