aboutsummaryrefslogtreecommitdiff
path: root/source/opt/set_spec_constant_default_value_pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/opt/set_spec_constant_default_value_pass.cpp')
-rw-r--r--source/opt/set_spec_constant_default_value_pass.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/source/opt/set_spec_constant_default_value_pass.cpp b/source/opt/set_spec_constant_default_value_pass.cpp
index 5125bd15..4def2b09 100644
--- a/source/opt/set_spec_constant_default_value_pass.cpp
+++ b/source/opt/set_spec_constant_default_value_pass.cpp
@@ -30,6 +30,7 @@
namespace spvtools {
namespace opt {
+
namespace {
using utils::EncodeNumberStatus;
using utils::NumberType;
@@ -138,9 +139,9 @@ std::vector<uint32_t> ParseDefaultValueBitPattern(
// decoration.
bool CanHaveSpecIdDecoration(const Instruction& inst) {
switch (inst.opcode()) {
- case spv::Op::OpSpecConstant:
- case spv::Op::OpSpecConstantFalse:
- case spv::Op::OpSpecConstantTrue:
+ case SpvOp::SpvOpSpecConstant:
+ case SpvOp::SpvOpSpecConstantFalse:
+ case SpvOp::SpvOpSpecConstantTrue:
return true;
default:
return false;
@@ -164,7 +165,7 @@ Instruction* GetSpecIdTargetFromDecorationGroup(
if (def_use_mgr->WhileEachUser(&decoration_group_defining_inst,
[&group_decorate_inst](Instruction* user) {
if (user->opcode() ==
- spv::Op::OpGroupDecorate) {
+ SpvOp::SpvOpGroupDecorate) {
group_decorate_inst = user;
return false;
}
@@ -216,16 +217,16 @@ Instruction* GetSpecIdTargetFromDecorationGroup(
Pass::Status SetSpecConstantDefaultValuePass::Process() {
// The operand index of decoration target in an OpDecorate instruction.
- constexpr uint32_t kTargetIdOperandIndex = 0;
+ const uint32_t kTargetIdOperandIndex = 0;
// The operand index of the decoration literal in an OpDecorate instruction.
- constexpr uint32_t kDecorationOperandIndex = 1;
+ const uint32_t kDecorationOperandIndex = 1;
// The operand index of Spec id literal value in an OpDecorate SpecId
// instruction.
- constexpr uint32_t kSpecIdLiteralOperandIndex = 2;
+ const uint32_t kSpecIdLiteralOperandIndex = 2;
// The number of operands in an OpDecorate SpecId instruction.
- constexpr uint32_t kOpDecorateSpecIdNumOperands = 3;
+ const uint32_t kOpDecorateSpecIdNumOperands = 3;
// The in-operand index of the default value in a OpSpecConstant instruction.
- constexpr uint32_t kOpSpecConstantLiteralInOperandIndex = 0;
+ const uint32_t kOpSpecConstantLiteralInOperandIndex = 0;
bool modified = false;
// Scan through all the annotation instructions to find 'OpDecorate SpecId'
@@ -239,10 +240,10 @@ Pass::Status SetSpecConstantDefaultValuePass::Process() {
// default value of the target spec constant.
for (Instruction& inst : context()->annotations()) {
// Only process 'OpDecorate SpecId' instructions
- if (inst.opcode() != spv::Op::OpDecorate) continue;
+ if (inst.opcode() != SpvOp::SpvOpDecorate) continue;
if (inst.NumOperands() != kOpDecorateSpecIdNumOperands) continue;
if (inst.GetSingleWordInOperand(kDecorationOperandIndex) !=
- uint32_t(spv::Decoration::SpecId)) {
+ uint32_t(SpvDecoration::SpvDecorationSpecId)) {
continue;
}
@@ -254,7 +255,7 @@ Pass::Status SetSpecConstantDefaultValuePass::Process() {
// target_id might be a decoration group id.
Instruction* spec_inst = nullptr;
if (Instruction* target_inst = get_def_use_mgr()->GetDef(target_id)) {
- if (target_inst->opcode() == spv::Op::OpDecorationGroup) {
+ if (target_inst->opcode() == SpvOp::SpvOpDecorationGroup) {
spec_inst =
GetSpecIdTargetFromDecorationGroup(*target_inst, get_def_use_mgr());
} else {
@@ -300,7 +301,7 @@ Pass::Status SetSpecConstantDefaultValuePass::Process() {
// Update the operand bit patterns of the spec constant defining
// instruction.
switch (spec_inst->opcode()) {
- case spv::Op::OpSpecConstant:
+ case SpvOp::SpvOpSpecConstant:
// If the new value is the same with the original value, no
// need to do anything. Otherwise update the operand words.
if (spec_inst->GetInOperand(kOpSpecConstantLiteralInOperandIndex)
@@ -310,19 +311,19 @@ Pass::Status SetSpecConstantDefaultValuePass::Process() {
modified = true;
}
break;
- case spv::Op::OpSpecConstantTrue:
+ case SpvOp::SpvOpSpecConstantTrue:
// If the new value is also 'true', no need to change anything.
// Otherwise, set the opcode to OpSpecConstantFalse;
if (!static_cast<bool>(bit_pattern.front())) {
- spec_inst->SetOpcode(spv::Op::OpSpecConstantFalse);
+ spec_inst->SetOpcode(SpvOp::SpvOpSpecConstantFalse);
modified = true;
}
break;
- case spv::Op::OpSpecConstantFalse:
+ case SpvOp::SpvOpSpecConstantFalse:
// If the new value is also 'false', no need to change anything.
// Otherwise, set the opcode to OpSpecConstantTrue;
if (static_cast<bool>(bit_pattern.front())) {
- spec_inst->SetOpcode(spv::Op::OpSpecConstantTrue);
+ spec_inst->SetOpcode(SpvOp::SpvOpSpecConstantTrue);
modified = true;
}
break;