Add version select and OpLogicalNot

This commit is contained in:
ReinUsesLisp 2018-11-02 13:38:33 -03:00
parent 4043020f45
commit 4f66fb18e9
3 changed files with 11 additions and 3 deletions

View file

@ -27,7 +27,7 @@ using Id = const Op*;
class Module { class Module {
public: public:
explicit Module(); explicit Module(std::uint32_t version = spv::Version);
~Module(); ~Module();
/** /**
@ -238,6 +238,11 @@ class Module {
/// Make an intermediate object whose value is undefined. /// Make an intermediate object whose value is undefined.
Id OpUndef(Id result_type); 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: private:
Id AddCode(std::unique_ptr<Op> op); Id AddCode(std::unique_ptr<Op> op);
@ -247,6 +252,8 @@ class Module {
Id AddAnnotation(std::unique_ptr<Op> op); Id AddAnnotation(std::unique_ptr<Op> op);
const std::uint32_t version;
std::uint32_t bound{1}; std::uint32_t bound{1};
std::set<spv::Capability> capabilities; std::set<spv::Capability> capabilities;

View file

@ -20,6 +20,7 @@ add_library(sirit
insts/memory.cpp insts/memory.cpp
insts/annotation.cpp insts/annotation.cpp
insts/misc.cpp insts/misc.cpp
insts/logical.cpp
) )
target_include_directories(sirit target_include_directories(sirit
PUBLIC ../include PUBLIC ../include

View file

@ -26,7 +26,7 @@ template <typename T> static void WriteSet(Stream& stream, const T& set) {
} }
} }
Module::Module() {} Module::Module(u32 version) : version(version) {}
Module::~Module() = default; Module::~Module() = default;
@ -35,7 +35,7 @@ std::vector<u8> Module::Assemble() const {
Stream stream{bytes}; Stream stream{bytes};
stream.Write(spv::MagicNumber); stream.Write(spv::MagicNumber);
stream.Write(spv::Version); stream.Write(version);
stream.Write(GENERATOR_MAGIC_NUMBER); stream.Write(GENERATOR_MAGIC_NUMBER);
stream.Write(bound); stream.Write(bound);
stream.Write(static_cast<u32>(0)); stream.Write(static_cast<u32>(0));