[llvm] [MIR2Vec] Added create factory methods for Vocabulary (PR #162569)
S. VenkataKeerthy via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 8 16:30:44 PDT 2025
================
@@ -92,46 +93,43 @@ class MIRVocabulary {
/// Get the string key for a vocabulary entry at the given position
std::string getStringKey(unsigned Pos) const;
- MIRVocabulary() = delete;
- MIRVocabulary(VocabMap &&Entries, const TargetInstrInfo *TII);
- MIRVocabulary(ir2vec::VocabStorage &&Storage, const TargetInstrInfo &TII)
- : Storage(std::move(Storage)), TII(TII) {}
-
- bool isValid() const {
- return UniqueBaseOpcodeNames.size() > 0 &&
- Layout.TotalEntries == Storage.size() && Storage.isValid();
- }
-
unsigned getDimension() const {
- if (!isValid())
- return 0;
return Storage.getDimension();
}
// Accessor methods
const Embedding &operator[](unsigned Opcode) const {
- assert(isValid() && "MIR2Vec Vocabulary is invalid");
unsigned LocalIndex = getCanonicalOpcodeIndex(Opcode);
return Storage[static_cast<unsigned>(Section::Opcodes)][LocalIndex];
}
// Iterator access
using const_iterator = ir2vec::VocabStorage::const_iterator;
const_iterator begin() const {
- assert(isValid() && "MIR2Vec Vocabulary is invalid");
return Storage.begin();
}
const_iterator end() const {
- assert(isValid() && "MIR2Vec Vocabulary is invalid");
return Storage.end();
}
/// Total number of entries in the vocabulary
size_t getCanonicalSize() const {
- assert(isValid() && "Invalid vocabulary");
return Storage.size();
}
+
+ MIRVocabulary() = delete;
----------------
svkeerthy wrote:
To private?
https://github.com/llvm/llvm-project/pull/162569
More information about the llvm-commits
mailing list