From a582641b9925435f148d87983955cc1b3f356e81 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Tue, 28 Aug 2018 04:46:18 -0300 Subject: [PATCH] Add OpConstantNull --- include/sirit/sirit.h | 3 +++ src/insts/constant.cpp | 4 ++++ tests/main.cpp | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index eb68c00..508a33f 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -141,6 +141,9 @@ public: Ref ConstantSampler(Ref result_type, spv::SamplerAddressingMode addressing_mode, bool normalized, spv::SamplerFilterMode filter_mode); + /// Returns a null constant value. + Ref ConstantNull(Ref result_type); + // Function /// Declares a function. diff --git a/src/insts/constant.cpp b/src/insts/constant.cpp index 90af194..cf3b405 100644 --- a/src/insts/constant.cpp +++ b/src/insts/constant.cpp @@ -41,4 +41,8 @@ Ref Module::ConstantSampler(Ref result_type, spv::SamplerAddressingMode addressi return AddDeclaration(op); } +Ref Module::ConstantNull(Ref result_type) { + return AddDeclaration(new Op(spv::Op::OpConstantNull, bound, result_type)); +} + } // namespace Sirit diff --git a/tests/main.cpp b/tests/main.cpp index 2df624e..b853d07 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -40,7 +40,6 @@ public: ConstantTrue(TypeBool()); ConstantTrue(TypeBool()); ConstantFalse(TypeBool()); - Constant(TypeFloat(64), Literal(6342.2)); Constant(TypeFloat(64), Literal(6342.21)); Constant(TypeFloat(32), Literal(6342.21f)); Constant(TypeFloat(16), Literal(30u)); @@ -50,6 +49,7 @@ public: ConstantComposite(TypeVector(TypeFloat(32), 2), {Constant(TypeFloat(32), Literal(50.0f)), Constant(TypeFloat(32), Literal(50.0f))}); + ConstantNull(TypeVector(TypeInt(64, false), 4)); auto main_type{TypeFunction(TypeVoid())}; auto main_func{Emit(Function(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type))};