diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 85aa71c..255b89b 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -105,6 +105,21 @@ public: /// Returns type function. const Op* TypeFunction(const Op* return_type, const std::vector& arguments = {}); + /// Returns type event. + const Op* TypeEvent(); + + /// Returns type device event. + const Op* TypeDeviceEvent(); + + /// Returns type reserve id. + const Op* TypeReserveId(); + + /// Returns type queue. + const Op* TypeQueue(); + + /// Returns type pipe. + const Op* TypePipe(spv::AccessQualifier access_qualifier); + // Function /// Emits a function. diff --git a/src/opcodes/type.cpp b/src/opcodes/type.cpp index 4588506..6513e81 100644 --- a/src/opcodes/type.cpp +++ b/src/opcodes/type.cpp @@ -198,12 +198,37 @@ const Op* Module::TypePointer(spv::StorageClass storage_class, const Op* type) { } const Op* Module::TypeFunction(const Op* return_type, const std::vector& arguments) { - Op* type_func{new Op(spv::Op::OpTypeFunction, bound)}; - type_func->Add(return_type); - for (const Op* arg : arguments) { - type_func->Add(arg); - } - return AddDeclaration(type_func); + Op* op{new Op(spv::Op::OpTypeFunction, bound)}; + op->Add(return_type); + op->Add(arguments); + return AddDeclaration(op); +} + +const Op* Module::TypeEvent() { + AddCapability(spv::Capability::Kernel); + return AddDeclaration(new Op(spv::Op::OpTypeEvent, bound)); +} + +const Op* Module::TypeDeviceEvent() { + AddCapability(spv::Capability::DeviceEnqueue); + return AddDeclaration(new Op(spv::Op::OpTypeDeviceEvent, bound)); +} + +const Op* Module::TypeReserveId() { + AddCapability(spv::Capability::Pipes); + return AddDeclaration(new Op(spv::Op::OpTypeReserveId, bound)); +} + +const Op* Module::TypeQueue() { + AddCapability(spv::Capability::DeviceEnqueue); + return AddDeclaration(new Op(spv::Op::OpTypeQueue, bound)); +} + +const Op* Module::TypePipe(spv::AccessQualifier access_qualifier) { + AddCapability(spv::Capability::Pipes); + Op* op{new Op(spv::Op::OpTypePipe, bound)}; + op->Add(static_cast(access_qualifier); + return AddDeclaration(op); } } // namespace Sirit