diff options
Diffstat (limited to 'test/opt/def_use_test.cpp')
-rw-r--r-- | test/opt/def_use_test.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/test/opt/def_use_test.cpp b/test/opt/def_use_test.cpp index 0210095d4..431501274 100644 --- a/test/opt/def_use_test.cpp +++ b/test/opt/def_use_test.cpp @@ -50,9 +50,9 @@ uint32_t NumUses(const std::unique_ptr<IRContext>& context, uint32_t id) { // // If |id| is used multiple times in a single instruction, that instruction's // opcode will appear a corresponding number of times. -std::vector<SpvOp> GetUseOpcodes(const std::unique_ptr<IRContext>& context, - uint32_t id) { - std::vector<SpvOp> opcodes; +std::vector<spv::Op> GetUseOpcodes(const std::unique_ptr<IRContext>& context, + uint32_t id) { + std::vector<spv::Op> opcodes; context->get_def_use_mgr()->ForEachUse( id, [&opcodes](Instruction* user, uint32_t) { opcodes.push_back(user->opcode()); @@ -99,7 +99,7 @@ void CheckDef(const InstDefUse& expected_defs_uses, const auto expected_def = expected_defs_uses.defs[i].second; ASSERT_EQ(1u, actual_defs.count(id)) << "expected to def id [" << id << "]"; auto def = actual_defs.at(id); - if (def->opcode() != SpvOpConstant) { + if (def->opcode() != spv::Op::OpConstant) { // Constants don't disassemble properly without a full context. EXPECT_EQ(expected_def, DisassembleInst(actual_defs.at(id))); } @@ -116,7 +116,7 @@ UserMap BuildAllUsers(const DefUseManager* mgr, uint32_t idBound) { for (uint32_t id = 0; id != idBound; ++id) { if (mgr->GetDef(id)) { mgr->ForEachUser(id, [id, &userMap](Instruction* user) { - if (user->opcode() != SpvOpConstant) { + if (user->opcode() != spv::Op::OpConstant) { userMap[id].push_back(user); } }); @@ -1298,21 +1298,23 @@ TEST(DefUseTest, OpSwitch) { { EXPECT_EQ(2u, NumUses(context, 6)); - std::vector<SpvOp> opcodes = GetUseOpcodes(context, 6u); - EXPECT_THAT(opcodes, UnorderedElementsAre(SpvOpSwitch, SpvOpReturnValue)); + std::vector<spv::Op> opcodes = GetUseOpcodes(context, 6u); + EXPECT_THAT(opcodes, UnorderedElementsAre(spv::Op::OpSwitch, + spv::Op::OpReturnValue)); } { EXPECT_EQ(6u, NumUses(context, 7)); - std::vector<SpvOp> opcodes = GetUseOpcodes(context, 7u); + std::vector<spv::Op> opcodes = GetUseOpcodes(context, 7u); // OpSwitch is now a user of %7. - EXPECT_THAT(opcodes, UnorderedElementsAre(SpvOpSelectionMerge, SpvOpBranch, - SpvOpBranch, SpvOpBranch, - SpvOpBranch, SpvOpSwitch)); + EXPECT_THAT(opcodes, UnorderedElementsAre( + spv::Op::OpSelectionMerge, spv::Op::OpBranch, + spv::Op::OpBranch, spv::Op::OpBranch, + spv::Op::OpBranch, spv::Op::OpSwitch)); } // Check all ids only used by OpSwitch after replacement. for (const auto id : {8u, 10u, 11u}) { EXPECT_EQ(1u, NumUses(context, id)); - EXPECT_EQ(SpvOpSwitch, GetUseOpcodes(context, id).back()); + EXPECT_EQ(spv::Op::OpSwitch, GetUseOpcodes(context, id).back()); } } @@ -1378,10 +1380,11 @@ TEST(AnalyzeInstDefUse, UseWithNoResultId) { // Analyze the instructions. DefUseManager manager(context.module()); - Instruction label(&context, SpvOpLabel, 0, 2, {}); + Instruction label(&context, spv::Op::OpLabel, 0, 2, {}); manager.AnalyzeInstDefUse(&label); - Instruction branch(&context, SpvOpBranch, 0, 0, {{SPV_OPERAND_TYPE_ID, {2}}}); + Instruction branch(&context, spv::Op::OpBranch, 0, 0, + {{SPV_OPERAND_TYPE_ID, {2}}}); manager.AnalyzeInstDefUse(&branch); context.module()->SetIdBound(3); @@ -1409,7 +1412,7 @@ TEST(AnalyzeInstDefUse, AddNewInstruction) { // Analyze the instructions. DefUseManager manager(context->module()); - Instruction newInst(context.get(), SpvOpConstantTrue, 1, 2, {}); + Instruction newInst(context.get(), spv::Op::OpConstantTrue, 1, 2, {}); manager.AnalyzeInstDefUse(&newInst); InstDefUse expected = { @@ -1703,7 +1706,7 @@ TEST_F(UpdateUsesTest, KeepOldUses) { DefUseManager* def_use_mgr = context->get_def_use_mgr(); Instruction* def = def_use_mgr->GetDef(9); Instruction* use = def_use_mgr->GetDef(10); - def->SetOpcode(SpvOpCopyObject); + def->SetOpcode(spv::Op::OpCopyObject); def->SetInOperands({{SPV_OPERAND_TYPE_ID, {25}}}); context->UpdateDefUse(def); |