[IR2VecTest] Avoid magic constants

Instead make the members of Vocabulary public. This was causing test
failures with https://github.com/llvm/llvm-project/pull/139357.

Reviewed By: svkeerthy, boomanaiden154

Pull Request: https://github.com/llvm/llvm-project/pull/150878
This commit is contained in:
Alexander Richardson
2025-07-28 09:50:51 -07:00
committed by GitHub
parent 4f58c829fd
commit fc2850fc76
2 changed files with 4 additions and 4 deletions

View File

@@ -153,6 +153,7 @@ class Vocabulary {
static_cast<unsigned>(OperandKind::MaxOperandKind),
"OperandKindNames array size must match MaxOperandKind");
public:
/// Vocabulary layout constants
#define LAST_OTHER_INST(NUM) static constexpr unsigned MaxOpcodes = NUM;
#include "llvm/IR/Instruction.def"
@@ -162,7 +163,6 @@ class Vocabulary {
static constexpr unsigned MaxOperandKinds =
static_cast<unsigned>(OperandKind::MaxOperandKind);
public:
Vocabulary() = default;
Vocabulary(VocabVector &&Vocab);

View File

@@ -364,9 +364,9 @@ TEST_F(IR2VecTestFixture, GetFunctionVector) {
EXPECT_TRUE(FuncVec.approximatelyEquals(Embedding(2, 44.4)));
}
static constexpr unsigned MaxOpcodes = 67;
static constexpr unsigned MaxTypeIDs = 21;
static constexpr unsigned MaxOperands = 4;
static constexpr unsigned MaxOpcodes = Vocabulary::MaxOpcodes;
static constexpr unsigned MaxTypeIDs = Vocabulary::MaxTypeIDs;
static constexpr unsigned MaxOperands = Vocabulary::MaxOperandKinds;
TEST(IR2VecVocabularyTest, DummyVocabTest) {
for (unsigned Dim = 1; Dim <= 10; ++Dim) {