| 159 | |
| 160 | template <class ElementType, class Function> |
| 161 | void CheckForExpectedVectorConstant(Instruction* inst, |
| 162 | std::vector<ElementType> expected_result, |
| 163 | Function GetValue) { |
| 164 | ASSERT_TRUE(inst); |
| 165 | |
| 166 | IRContext* context = inst->context(); |
| 167 | EXPECT_EQ(inst->opcode(), spv::Op::OpCopyObject); |
| 168 | analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr(); |
| 169 | inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0)); |
| 170 | std::vector<spv::Op> opcodes = {spv::Op::OpConstantComposite}; |
| 171 | EXPECT_THAT(opcodes, Contains(inst->opcode())); |
| 172 | analysis::ConstantManager* const_mrg = context->get_constant_mgr(); |
| 173 | const analysis::Constant* result = const_mrg->GetConstantFromInst(inst); |
| 174 | EXPECT_NE(result, nullptr); |
| 175 | if (result != nullptr) { |
| 176 | const std::vector<const analysis::Constant*>& componenets = |
| 177 | result->AsVectorConstant()->GetComponents(); |
| 178 | EXPECT_EQ(componenets.size(), expected_result.size()); |
| 179 | for (size_t i = 0; i < componenets.size(); i++) { |
| 180 | EXPECT_EQ(expected_result[i], GetValue(componenets[i])); |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | using IntegerInstructionFoldingTest = |
| 186 | ::testing::TestWithParam<InstructionFoldingCase<uint32_t>>; |
no test coverage detected