Remove Op prefix on Type instructions

This commit is contained in:
ReinUsesLisp 2019-03-13 18:32:38 -03:00
parent 3fa70013b8
commit 1c06f8530e
3 changed files with 48 additions and 48 deletions

View file

@ -34,7 +34,7 @@ public:
AddCapability(spv::Capability::Shader); AddCapability(spv::Capability::Shader);
SetMemoryModel(spv::AddressingModel::Logical, spv::MemoryModel::GLSL450); SetMemoryModel(spv::AddressingModel::Logical, spv::MemoryModel::GLSL450);
auto main_type{OpTypeFunction(TypeVoid())}; auto main_type{TypeFunction(TypeVoid())};
auto main_func{Emit(OpFunction(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type))}; auto main_func{Emit(OpFunction(TypeVoid(), spv::FunctionControlMask::MaskNone, main_type))};
Emit(OpLabel()); Emit(OpLabel());
Emit(OpReturn()); Emit(OpReturn());

View file

@ -87,78 +87,78 @@ public:
// Types // Types
/// Returns type void. /// Returns type void.
Id OpTypeVoid(); Id TypeVoid();
/// Returns type bool. /// Returns type bool.
Id OpTypeBool(); Id TypeBool();
/// Returns type integer. /// Returns type integer.
Id OpTypeInt(int width, bool is_signed); Id TypeInt(int width, bool is_signed);
/// Returns type float. /// Returns type float.
Id OpTypeFloat(int width); Id TypeFloat(int width);
/// Returns type vector. /// Returns type vector.
Id OpTypeVector(Id component_type, int component_count); Id TypeVector(Id component_type, int component_count);
/// Returns type matrix. /// Returns type matrix.
Id OpTypeMatrix(Id column_type, int column_count); Id TypeMatrix(Id column_type, int column_count);
/// Returns type image. /// Returns type image.
Id OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, bool ms, int sampled, Id TypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, bool ms, int sampled,
spv::ImageFormat image_format, spv::ImageFormat image_format,
std::optional<spv::AccessQualifier> access_qualifier = {}); std::optional<spv::AccessQualifier> access_qualifier = {});
/// Returns type sampler. /// Returns type sampler.
Id OpTypeSampler(); Id TypeSampler();
/// Returns type sampled image. /// Returns type sampled image.
Id OpTypeSampledImage(Id image_type); Id TypeSampledImage(Id image_type);
/// Returns type array. /// Returns type array.
Id OpTypeArray(Id element_type, Id length); Id TypeArray(Id element_type, Id length);
/// Returns type runtime array. /// Returns type runtime array.
Id OpTypeRuntimeArray(Id element_type); Id TypeRuntimeArray(Id element_type);
/// Returns type struct. /// Returns type struct.
Id OpTypeStruct(const std::vector<Id>& members = {}); Id TypeStruct(const std::vector<Id>& members = {});
/// Returns type struct. /// Returns type struct.
template <typename... Ts> template <typename... Ts>
Id OpTypeStruct(Ts&&... members) { Id TypeStruct(Ts&&... members) {
return OpTypeStruct({members...}); return TypeStruct({members...});
} }
/// Returns type opaque. /// Returns type opaque.
Id OpTypeOpaque(const std::string& name); Id TypeOpaque(const std::string& name);
/// Returns type pointer. /// Returns type pointer.
Id OpTypePointer(spv::StorageClass storage_class, Id type); Id TypePointer(spv::StorageClass storage_class, Id type);
/// Returns type function. /// Returns type function.
Id OpTypeFunction(Id return_type, const std::vector<Id>& arguments = {}); Id TypeFunction(Id return_type, const std::vector<Id>& arguments = {});
/// Returns type function. /// Returns type function.
template <typename... Ts> template <typename... Ts>
Id OpTypeFunction(Id return_type, Ts&&... arguments) { Id TypeFunction(Id return_type, Ts&&... arguments) {
return OpTypeFunction(return_type, {arguments...}); return OpTypeFunction(return_type, {arguments...});
} }
/// Returns type event. /// Returns type event.
Id OpTypeEvent(); Id TypeEvent();
/// Returns type device event. /// Returns type device event.
Id OpTypeDeviceEvent(); Id TypeDeviceEvent();
/// Returns type reserve id. /// Returns type reserve id.
Id OpTypeReserveId(); Id TypeReserveId();
/// Returns type queue. /// Returns type queue.
Id OpTypeQueue(); Id TypeQueue();
/// Returns type pipe. /// Returns type pipe.
Id OpTypePipe(spv::AccessQualifier access_qualifier); Id TypePipe(spv::AccessQualifier access_qualifier);
// Constant // Constant

View file

@ -13,28 +13,28 @@
namespace Sirit { namespace Sirit {
Id Module::OpTypeVoid() { Id Module::TypeVoid() {
return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeVoid, bound)); return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeVoid, bound));
} }
Id Module::OpTypeBool() { Id Module::TypeBool() {
return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeBool, bound)); return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeBool, bound));
} }
Id Module::OpTypeInt(int width, bool is_signed) { Id Module::TypeInt(int width, bool is_signed) {
auto op{std::make_unique<Op>(spv::Op::OpTypeInt, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeInt, bound)};
op->Add(width); op->Add(width);
op->Add(is_signed ? 1 : 0); op->Add(is_signed ? 1 : 0);
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
} }
Id Module::OpTypeFloat(int width) { Id Module::TypeFloat(int width) {
auto op{std::make_unique<Op>(spv::Op::OpTypeFloat, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeFloat, bound)};
op->Add(width); op->Add(width);
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
} }
Id Module::OpTypeVector(Id component_type, int component_count) { Id Module::TypeVector(Id component_type, int component_count) {
assert(component_count >= 2); assert(component_count >= 2);
auto op{std::make_unique<Op>(spv::Op::OpTypeVector, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeVector, bound)};
op->Add(component_type); op->Add(component_type);
@ -42,7 +42,7 @@ Id Module::OpTypeVector(Id component_type, int component_count) {
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
} }
Id Module::OpTypeMatrix(Id column_type, int column_count) { Id Module::TypeMatrix(Id column_type, int column_count) {
assert(column_count >= 2); assert(column_count >= 2);
auto op{std::make_unique<Op>(spv::Op::OpTypeMatrix, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeMatrix, bound)};
op->Add(column_type); op->Add(column_type);
@ -50,9 +50,9 @@ Id Module::OpTypeMatrix(Id column_type, int column_count) {
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
} }
Id Module::OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, bool ms, int sampled, Id Module::TypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, bool ms, int sampled,
spv::ImageFormat image_format, spv::ImageFormat image_format,
std::optional<spv::AccessQualifier> access_qualifier) { std::optional<spv::AccessQualifier> access_qualifier) {
auto op{std::make_unique<Op>(spv::Op::OpTypeImage, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeImage, bound)};
op->Add(sampled_type); op->Add(sampled_type);
op->Add(static_cast<u32>(dim)); op->Add(static_cast<u32>(dim));
@ -67,72 +67,72 @@ Id Module::OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, b
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
} }
Id Module::OpTypeSampler() { Id Module::TypeSampler() {
return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeSampler, bound)); return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeSampler, bound));
} }
Id Module::OpTypeSampledImage(Id image_type) { Id Module::TypeSampledImage(Id image_type) {
auto op{std::make_unique<Op>(spv::Op::OpTypeSampledImage, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeSampledImage, bound)};
op->Add(image_type); op->Add(image_type);
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
} }
Id Module::OpTypeArray(Id element_type, Id length) { Id Module::TypeArray(Id element_type, Id length) {
auto op{std::make_unique<Op>(spv::Op::OpTypeArray, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeArray, bound)};
op->Add(element_type); op->Add(element_type);
op->Add(length); op->Add(length);
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
} }
Id Module::OpTypeRuntimeArray(Id element_type) { Id Module::TypeRuntimeArray(Id element_type) {
auto op{std::make_unique<Op>(spv::Op::OpTypeRuntimeArray, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeRuntimeArray, bound)};
op->Add(element_type); op->Add(element_type);
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
} }
Id Module::OpTypeStruct(const std::vector<Id>& members) { Id Module::TypeStruct(const std::vector<Id>& members) {
auto op{std::make_unique<Op>(spv::Op::OpTypeStruct, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeStruct, bound)};
op->Add(members); op->Add(members);
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
} }
Id Module::OpTypeOpaque(const std::string& name) { Id Module::TypeOpaque(const std::string& name) {
auto op{std::make_unique<Op>(spv::Op::OpTypeOpaque, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeOpaque, bound)};
op->Add(name); op->Add(name);
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
} }
Id Module::OpTypePointer(spv::StorageClass storage_class, Id type) { Id Module::TypePointer(spv::StorageClass storage_class, Id type) {
auto op{std::make_unique<Op>(spv::Op::OpTypePointer, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypePointer, bound)};
op->Add(static_cast<u32>(storage_class)); op->Add(static_cast<u32>(storage_class));
op->Add(type); op->Add(type);
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
} }
Id Module::OpTypeFunction(Id return_type, const std::vector<Id>& arguments) { Id Module::TypeFunction(Id return_type, const std::vector<Id>& arguments) {
auto op{std::make_unique<Op>(spv::Op::OpTypeFunction, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypeFunction, bound)};
op->Add(return_type); op->Add(return_type);
op->Add(arguments); op->Add(arguments);
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));
} }
Id Module::OpTypeEvent() { Id Module::TypeEvent() {
return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeEvent, bound)); return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeEvent, bound));
} }
Id Module::OpTypeDeviceEvent() { Id Module::TypeDeviceEvent() {
return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeDeviceEvent, bound)); return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeDeviceEvent, bound));
} }
Id Module::OpTypeReserveId() { Id Module::TypeReserveId() {
return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeReserveId, bound)); return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeReserveId, bound));
} }
Id Module::OpTypeQueue() { Id Module::TypeQueue() {
return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeQueue, bound)); return AddDeclaration(std::make_unique<Op>(spv::Op::OpTypeQueue, bound));
} }
Id Module::OpTypePipe(spv::AccessQualifier access_qualifier) { Id Module::TypePipe(spv::AccessQualifier access_qualifier) {
auto op{std::make_unique<Op>(spv::Op::OpTypePipe, bound)}; auto op{std::make_unique<Op>(spv::Op::OpTypePipe, bound)};
op->Add(static_cast<u32>(access_qualifier)); op->Add(static_cast<u32>(access_qualifier));
return AddDeclaration(std::move(op)); return AddDeclaration(std::move(op));