aboutsummaryrefslogtreecommitdiff
path: root/source/opt/module.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/opt/module.cpp')
-rw-r--r--source/opt/module.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/source/opt/module.cpp b/source/opt/module.cpp
index a9710c6a..c98af8f5 100644
--- a/source/opt/module.cpp
+++ b/source/opt/module.cpp
@@ -69,14 +69,14 @@ std::vector<const Instruction*> Module::GetConstants() const {
return const_insts;
}
-uint32_t Module::GetGlobalValue(spv::Op opcode) const {
+uint32_t Module::GetGlobalValue(SpvOp opcode) const {
for (auto& inst : types_values_) {
if (inst.opcode() == opcode) return inst.result_id();
}
return 0;
}
-void Module::AddGlobalValue(spv::Op opcode, uint32_t result_id,
+void Module::AddGlobalValue(SpvOp opcode, uint32_t result_id,
uint32_t type_id) {
std::unique_ptr<Instruction> newGlobal(
new Instruction(context(), opcode, type_id, result_id, {}));
@@ -159,6 +159,7 @@ void Module::ToBinary(std::vector<uint32_t>* binary, bool skip_nop) const {
if (between_merge_and_branch && i->IsLineInst()) {
return;
}
+ between_merge_and_branch = false;
if (last_line_inst != nullptr) {
// If the current instruction is OpLine or DebugLine and it is the same
// as the last line instruction that is still effective (can be applied
@@ -180,30 +181,28 @@ void Module::ToBinary(std::vector<uint32_t>* binary, bool skip_nop) const {
->get_feature_mgr()
->GetExtInstImportId_Shader100DebugInfo();
if (shader_set_id != 0) {
- binary->push_back((5 << 16) |
- static_cast<uint16_t>(spv::Op::OpExtInst));
+ binary->push_back((5 << 16) | static_cast<uint16_t>(SpvOpExtInst));
binary->push_back(context()->get_type_mgr()->GetVoidTypeId());
binary->push_back(context()->TakeNextId());
binary->push_back(shader_set_id);
binary->push_back(NonSemanticShaderDebugInfo100DebugNoLine);
} else {
- binary->push_back((1 << 16) |
- static_cast<uint16_t>(spv::Op::OpNoLine));
+ binary->push_back((1 << 16) | static_cast<uint16_t>(SpvOpNoLine));
}
last_line_inst = nullptr;
}
}
- if (opcode == spv::Op::OpLabel) {
+ if (opcode == SpvOpLabel) {
between_label_and_phi_var = true;
- } else if (opcode != spv::Op::OpVariable && opcode != spv::Op::OpPhi &&
+ } else if (opcode != SpvOpVariable && opcode != SpvOpPhi &&
!spvtools::opt::IsOpLineInst(opcode)) {
between_label_and_phi_var = false;
}
if (!(skip_nop && i->IsNop())) {
const auto& scope = i->GetDebugScope();
- if (scope != last_scope && !between_merge_and_branch) {
+ if (scope != last_scope) {
// Can only emit nonsemantic instructions after all phi instructions
// in a block so don't emit scope instructions before phi instructions
// for NonSemantic.Shader.DebugInfo.100.
@@ -222,11 +221,9 @@ void Module::ToBinary(std::vector<uint32_t>* binary, bool skip_nop) const {
i->ToBinaryWithoutAttachedDebugInsts(binary);
}
// Update the last line instruction.
- between_merge_and_branch = false;
if (spvOpcodeIsBlockTerminator(opcode) || i->IsNoLine()) {
last_line_inst = nullptr;
- } else if (opcode == spv::Op::OpLoopMerge ||
- opcode == spv::Op::OpSelectionMerge) {
+ } else if (opcode == SpvOpLoopMerge || opcode == SpvOpSelectionMerge) {
between_merge_and_branch = true;
last_line_inst = nullptr;
} else if (i->IsLine()) {
@@ -275,7 +272,7 @@ uint32_t Module::GetExtInstImportId(const char* extstr) {
std::ostream& operator<<(std::ostream& str, const Module& module) {
module.ForEachInst([&str](const Instruction* inst) {
str << *inst;
- if (inst->opcode() != spv::Op::OpFunctionEnd) {
+ if (inst->opcode() != SpvOpFunctionEnd) {
str << std::endl;
}
});