[llvm] [TableGen] Implement getOperandIdxName (PR #154944)
Mikael Holmen via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 25 05:31:31 PDT 2025
================
@@ -320,3 +320,23 @@ TEST(AMDGPU, TestReverseComposeSubRegIndices) {
}
}
}
+
+TEST(AMDGPU, TestGetNamedOperandIdx) {
+ std::unique_ptr<const GCNTargetMachine> TM =
+ createAMDGPUTargetMachine("amdgcn-amd-", "gfx900", "");
+ if (!TM)
+ return;
+ const MCInstrInfo *MCII = TM->getMCInstrInfo();
+
+ for (unsigned Opcode = 0, E = MCII->getNumOpcodes(); Opcode != E; ++Opcode) {
+ const MCInstrDesc &Desc = MCII->get(Opcode);
+ for (unsigned Idx = 0; Idx < Desc.getNumOperands(); ++Idx) {
+ AMDGPU::OpName OpName = AMDGPU::getOperandIdxName(Opcode, Idx);
+ if (OpName == AMDGPU::OpName::NUM_OPERAND_NAMES)
+ continue;
+ int16_t RetrievedIdx = AMDGPU::getNamedOperandIdx(Opcode, OpName);
+ EXPECT_EQ(Idx, RetrievedIdx)
----------------
mikaelholmen wrote:
Hello @ro-i ,
Warning on this line:
```
../../third-party/unittest/googletest/include/gtest/gtest.h:1379:11: error: comparison of integers of different signs: 'const unsigned int' and 'const short' [-Werror,-Wsign-compare]
1379 | if (lhs == rhs) {
| ~~~ ^ ~~~
../../third-party/unittest/googletest/include/gtest/gtest.h:1398:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned int, short>' requested here
1398 | return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
| ^
../unittests/Target/AMDGPU/AMDGPUUnitTests.cpp:338:7: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned int, short, nullptr>' requested here
338 | EXPECT_EQ(Idx, RetrievedIdx)
| ^
``
https://github.com/llvm/llvm-project/pull/154944
More information about the llvm-commits
mailing list