aboutsummaryrefslogtreecommitdiff
path: root/source/opt/desc_sroa_util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/opt/desc_sroa_util.cpp')
-rw-r--r--source/opt/desc_sroa_util.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/source/opt/desc_sroa_util.cpp b/source/opt/desc_sroa_util.cpp
index dba3de9c..1954e2cc 100644
--- a/source/opt/desc_sroa_util.cpp
+++ b/source/opt/desc_sroa_util.cpp
@@ -17,11 +17,12 @@
namespace spvtools {
namespace opt {
namespace {
-constexpr uint32_t kOpAccessChainInOperandIndexes = 1;
+
+const uint32_t kOpAccessChainInOperandIndexes = 1;
// Returns the length of array type |type|.
uint32_t GetLengthOfArrayType(IRContext* context, Instruction* type) {
- assert(type->opcode() == spv::Op::OpTypeArray && "type must be array");
+ assert(type->opcode() == SpvOpTypeArray && "type must be array");
uint32_t length_id = type->GetSingleWordInOperand(1);
const analysis::Constant* length_const =
context->get_constant_mgr()->FindDeclaredConstant(length_id);
@@ -34,20 +35,20 @@ uint32_t GetLengthOfArrayType(IRContext* context, Instruction* type) {
namespace descsroautil {
bool IsDescriptorArray(IRContext* context, Instruction* var) {
- if (var->opcode() != spv::Op::OpVariable) {
+ if (var->opcode() != SpvOpVariable) {
return false;
}
uint32_t ptr_type_id = var->type_id();
Instruction* ptr_type_inst = context->get_def_use_mgr()->GetDef(ptr_type_id);
- if (ptr_type_inst->opcode() != spv::Op::OpTypePointer) {
+ if (ptr_type_inst->opcode() != SpvOpTypePointer) {
return false;
}
uint32_t var_type_id = ptr_type_inst->GetSingleWordInOperand(1);
Instruction* var_type_inst = context->get_def_use_mgr()->GetDef(var_type_id);
- if (var_type_inst->opcode() != spv::Op::OpTypeArray &&
- var_type_inst->opcode() != spv::Op::OpTypeStruct) {
+ if (var_type_inst->opcode() != SpvOpTypeArray &&
+ var_type_inst->opcode() != SpvOpTypeStruct) {
return false;
}
@@ -58,23 +59,23 @@ bool IsDescriptorArray(IRContext* context, Instruction* var) {
}
if (!context->get_decoration_mgr()->HasDecoration(
- var->result_id(), uint32_t(spv::Decoration::DescriptorSet))) {
+ var->result_id(), SpvDecorationDescriptorSet)) {
return false;
}
- return context->get_decoration_mgr()->HasDecoration(
- var->result_id(), uint32_t(spv::Decoration::Binding));
+ return context->get_decoration_mgr()->HasDecoration(var->result_id(),
+ SpvDecorationBinding);
}
bool IsTypeOfStructuredBuffer(IRContext* context, const Instruction* type) {
- if (type->opcode() != spv::Op::OpTypeStruct) {
+ if (type->opcode() != SpvOpTypeStruct) {
return false;
}
// All buffers have offset decorations for members of their structure types.
// This is how we distinguish it from a structure of descriptors.
- return context->get_decoration_mgr()->HasDecoration(
- type->result_id(), uint32_t(spv::Decoration::Offset));
+ return context->get_decoration_mgr()->HasDecoration(type->result_id(),
+ SpvDecorationOffset);
}
const analysis::Constant* GetAccessChainIndexAsConst(
@@ -98,15 +99,15 @@ uint32_t GetNumberOfElementsForArrayOrStruct(IRContext* context,
Instruction* var) {
uint32_t ptr_type_id = var->type_id();
Instruction* ptr_type_inst = context->get_def_use_mgr()->GetDef(ptr_type_id);
- assert(ptr_type_inst->opcode() == spv::Op::OpTypePointer &&
+ assert(ptr_type_inst->opcode() == SpvOpTypePointer &&
"Variable should be a pointer to an array or structure.");
uint32_t pointee_type_id = ptr_type_inst->GetSingleWordInOperand(1);
Instruction* pointee_type_inst =
context->get_def_use_mgr()->GetDef(pointee_type_id);
- if (pointee_type_inst->opcode() == spv::Op::OpTypeArray) {
+ if (pointee_type_inst->opcode() == SpvOpTypeArray) {
return GetLengthOfArrayType(context, pointee_type_inst);
}
- assert(pointee_type_inst->opcode() == spv::Op::OpTypeStruct &&
+ assert(pointee_type_inst->opcode() == SpvOpTypeStruct &&
"Variable should be a pointer to an array or structure.");
return pointee_type_inst->NumInOperands();
}