LLVM 24.0.0git
llvm::mir2vec::MIRVocabulary Class Reference

Class for storing and accessing the MIR2Vec vocabulary. More...

#include "llvm/CodeGen/MIR2Vec.h"

Public Types

using const_iterator = ir2vec::VocabStorage::const_iterator

Public Member Functions

LLVM_ABI unsigned getCanonicalIndexForBaseName (StringRef BaseName) const
 Get indices from opcode or operand names.
LLVM_ABI unsigned getCanonicalIndexForOperandName (StringRef OperandName) const
LLVM_ABI unsigned getCanonicalIndexForRegisterClass (StringRef RegName, bool IsPhysical=true) const
LLVM_ABI std::string getStringKey (unsigned Pos) const
 Get the string key for a vocabulary entry at the given position.
unsigned getDimension () const
unsigned getEntityIDForOpcode (unsigned Opcode) const
 Get entity ID (flat index) for an opcode This is used for triplet generation.
unsigned getEntityIDForMachineOperand (const MachineOperand &MO) const
 Get entity ID (flat index) for a machine operand This is used for triplet generation.
const Embeddingoperator[] (unsigned Opcode) const
const Embeddingoperator[] (MachineOperand Operand) const
const_iterator begin () const
const_iterator end () const
 MIRVocabulary ()=delete
size_t getCanonicalSize () const
 Total number of entries in the vocabulary.

Static Public Member Functions

static LLVM_ABI std::string extractBaseOpcodeName (StringRef InstrName)
 Static method for extracting base opcode names (public for testing)
static LLVM_ABI Expected< MIRVocabularycreate (VocabMap &&OpcMap, VocabMap &&CommonOperandsMap, VocabMap &&PhyRegMap, VocabMap &&VirtRegMap, const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI)
 Factory method to create MIRVocabulary from vocabulary map.
static LLVM_ABI Expected< MIRVocabularycreateDummyVocabForTest (const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, unsigned Dim=1)
 Create a dummy vocabulary for testing purposes.

Friends

class llvm::MIR2VecVocabLegacyAnalysis

Detailed Description

Class for storing and accessing the MIR2Vec vocabulary.

The MIRVocabulary class manages seed embeddings for LLVM Machine IR

Definition at line 87 of file MIR2Vec.h.

Member Typedef Documentation

◆ const_iterator

Constructor & Destructor Documentation

◆ MIRVocabulary()

llvm::mir2vec::MIRVocabulary::MIRVocabulary ( )
delete

References LLVM_ABI.

Referenced by create().

Member Function Documentation

◆ begin()

const_iterator llvm::mir2vec::MIRVocabulary::begin ( ) const
inline

Definition at line 270 of file MIR2Vec.h.

◆ create()

Expected< MIRVocabulary > MIRVocabulary::create ( VocabMap && OpcMap,
VocabMap && CommonOperandsMap,
VocabMap && PhyRegMap,
VocabMap && VirtRegMap,
const TargetInstrInfo & TII,
const TargetRegisterInfo & TRI,
const MachineRegisterInfo & MRI )
static

◆ createDummyVocabForTest()

Expected< MIRVocabulary > MIRVocabulary::createDummyVocabForTest ( const TargetInstrInfo & TII,
const TargetRegisterInfo & TRI,
const MachineRegisterInfo & MRI,
unsigned Dim = 1 )
static

Create a dummy vocabulary for testing purposes.

Definition at line 402 of file MIR2Vec.cpp.

References assert(), create(), and extractBaseOpcodeName().

◆ end()

const_iterator llvm::mir2vec::MIRVocabulary::end ( ) const
inline

Definition at line 272 of file MIR2Vec.h.

◆ extractBaseOpcodeName()

std::string MIRVocabulary::extractBaseOpcodeName ( StringRef InstrName)
static

◆ getCanonicalIndexForBaseName()

unsigned MIRVocabulary::getCanonicalIndexForBaseName ( StringRef BaseName) const

Get indices from opcode or operand names.

These are public for testing. String based lookups are inefficient and should be avoided in general.

Definition at line 151 of file MIR2Vec.cpp.

References assert(), and llvm::StringRef::str().

◆ getCanonicalIndexForOperandName()

unsigned MIRVocabulary::getCanonicalIndexForOperandName ( StringRef OperandName) const

Definition at line 166 of file MIR2Vec.cpp.

References assert().

◆ getCanonicalIndexForRegisterClass()

unsigned MIRVocabulary::getCanonicalIndexForRegisterClass ( StringRef RegName,
bool IsPhysical = true ) const

Definition at line 176 of file MIR2Vec.cpp.

References assert(), and RegName.

◆ getCanonicalSize()

size_t llvm::mir2vec::MIRVocabulary::getCanonicalSize ( ) const
inline

Total number of entries in the vocabulary.

Definition at line 289 of file MIR2Vec.h.

◆ getDimension()

unsigned llvm::mir2vec::MIRVocabulary::getDimension ( ) const
inline

Definition at line 238 of file MIR2Vec.h.

◆ getEntityIDForMachineOperand()

unsigned llvm::mir2vec::MIRVocabulary::getEntityIDForMachineOperand ( const MachineOperand & MO) const
inline

Get entity ID (flat index) for a machine operand This is used for triplet generation.

Definition at line 248 of file MIR2Vec.h.

References llvm::MachineOperand::getReg(), llvm::MachineOperand::getType(), and llvm::MachineOperand::MO_Register.

◆ getEntityIDForOpcode()

unsigned llvm::mir2vec::MIRVocabulary::getEntityIDForOpcode ( unsigned Opcode) const
inline

Get entity ID (flat index) for an opcode This is used for triplet generation.

Definition at line 242 of file MIR2Vec.h.

◆ getStringKey()

std::string MIRVocabulary::getStringKey ( unsigned Pos) const

Get the string key for a vocabulary entry at the given position.

Definition at line 186 of file MIR2Vec.cpp.

References assert(), and Msg.

◆ operator[]() [1/2]

const Embedding & llvm::mir2vec::MIRVocabulary::operator[] ( MachineOperand Operand) const
inline

◆ operator[]() [2/2]

const Embedding & llvm::mir2vec::MIRVocabulary::operator[] ( unsigned Opcode) const
inline

Definition at line 255 of file MIR2Vec.h.

◆ llvm::MIR2VecVocabLegacyAnalysis

friend class llvm::MIR2VecVocabLegacyAnalysis
friend

Definition at line 88 of file MIR2Vec.h.

Member Data Documentation

◆ CommonOperandBase

size_t llvm::mir2vec::MIRVocabulary::CommonOperandBase = 0

Definition at line 109 of file MIR2Vec.h.

◆ OpcodeBase

size_t llvm::mir2vec::MIRVocabulary::OpcodeBase = 0

Definition at line 108 of file MIR2Vec.h.

◆ PhyRegBase

size_t llvm::mir2vec::MIRVocabulary::PhyRegBase = 0

Definition at line 110 of file MIR2Vec.h.

◆ TotalEntries

size_t llvm::mir2vec::MIRVocabulary::TotalEntries = 0

Definition at line 112 of file MIR2Vec.h.

◆ VirtRegBase

size_t llvm::mir2vec::MIRVocabulary::VirtRegBase = 0

Definition at line 111 of file MIR2Vec.h.


The documentation for this class was generated from the following files: