diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index ee3a024..c729595 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -27,7 +27,7 @@ using Id = const Op*; class Module { public: - explicit Module(); + explicit Module(std::uint32_t version = spv::Version); ~Module(); /** @@ -238,6 +238,11 @@ class Module { /// Make an intermediate object whose value is undefined. Id OpUndef(Id result_type); + // Logical + + /// Result is true if Operand is false. Result is false if Operand is true. + Id OpLogicalNot(Id result_type, Id operand); + private: Id AddCode(std::unique_ptr op); @@ -247,6 +252,8 @@ class Module { Id AddAnnotation(std::unique_ptr op); + const std::uint32_t version; + std::uint32_t bound{1}; std::set capabilities; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3f3ff24..b48292f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,6 +20,7 @@ add_library(sirit insts/memory.cpp insts/annotation.cpp insts/misc.cpp + insts/logical.cpp ) target_include_directories(sirit PUBLIC ../include diff --git a/src/sirit.cpp b/src/sirit.cpp index fd90205..56b25b8 100644 --- a/src/sirit.cpp +++ b/src/sirit.cpp @@ -26,7 +26,7 @@ template static void WriteSet(Stream& stream, const T& set) { } } -Module::Module() {} +Module::Module(u32 version) : version(version) {} Module::~Module() = default; @@ -35,7 +35,7 @@ std::vector Module::Assemble() const { Stream stream{bytes}; stream.Write(spv::MagicNumber); - stream.Write(spv::Version); + stream.Write(version); stream.Write(GENERATOR_MAGIC_NUMBER); stream.Write(bound); stream.Write(static_cast(0));