From 765c8833c49279ec7303f32cf3fd095831554466 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Mon, 27 Aug 2018 00:38:25 -0300 Subject: [PATCH] Add OpConstantComposite --- include/sirit/sirit.h | 3 +++ src/opcodes/constant.cpp | 7 +++++++ tests/main.cpp | 3 +++ 3 files changed, 13 insertions(+) diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index b704cd6..e2c0266 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -132,6 +132,9 @@ public: /// Returns a numeric scalar constant. const Op* Constant(const Op* result_type, Operand* literal); + /// Returns a numeric scalar constant. + const Op* ConstantComposite(const Op* result_type, const std::vector& constituents); + // Function /// Emits a function. diff --git a/src/opcodes/constant.cpp b/src/opcodes/constant.cpp index 6df4e4b..764253d 100644 --- a/src/opcodes/constant.cpp +++ b/src/opcodes/constant.cpp @@ -24,4 +24,11 @@ const Op* Module::Constant(const Op* result_type, Operand* literal) { return AddDeclaration(op); } +const Op* Module::ConstantComposite(const Op* result_type, + const std::vector& constituents) { + Op* op{new Op(spv::Op::OpConstantComposite, bound, result_type)}; + op->Add(constituents); + return AddDeclaration(op); +} + } // namespace Sirit diff --git a/tests/main.cpp b/tests/main.cpp index 7a3236b..2f60422 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -48,6 +48,9 @@ public: Constant(TypeInt(32, false), Literal(30u)); Constant(TypeInt(16, false), Literal(30u)); Constant(TypeInt(8, false), Literal(30u)); + ConstantComposite(TypeVector(TypeFloat(32), 2), + {Constant(TypeFloat(32), Literal(50.0f)), + Constant(TypeFloat(32), Literal(50.0f))}); auto main_type{TypeFunction(TypeVoid())}; auto main_func{Emit(Function(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type))};