LLVM 24.0.0git
MIR2Vec.cpp File Reference

This file implements the MIR2Vec algorithm for Machine IR embeddings. More...

Go to the source code of this file.

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
namespace  llvm::mir2vec

Macros

#define DEBUG_TYPE   "mir2vec"

Typedefs

using VocabMap = std::map<std::string, Embedding>

Functions

 STATISTIC (MIRVocabMissCounter, "Number of lookups to MIR entities not present in the vocabulary")
 STATISTIC (MIRClasslessRegCounter, "Number of register operands with no register class")
cl::OptionCategory llvm::mir2vec::MIR2VecCategory ("MIR2Vec Options")
static Error readVocabulary (VocabMap &OpcodeVocab, VocabMap &CommonOperandVocab, VocabMap &PhyRegVocabMap, VocabMap &VirtRegVocabMap)
static Expected< mir2vec::MIRVocabulary > buildVocabulary (const TargetSubtargetInfo &ST)
 INITIALIZE_PASS_BEGIN (MIR2VecVocabLegacyAnalysis, "mir2vec-vocab-analysis", "MIR2Vec Vocabulary Analysis", false, true) INITIALIZE_PASS_END(MIR2VecVocabLegacyAnalysis
 INITIALIZE_PASS_BEGIN (MIR2VecVocabPrinterLegacyPass, "print-mir2vec-vocab", "MIR2Vec Vocabulary Printer Pass", false, true) INITIALIZE_PASS_END(MIR2VecVocabPrinterLegacyPass
print mir2vec MIR2Vec Vocabulary Printer static true void printVocabulary (const mir2vec::MIRVocabulary &MIR2VecVocab, raw_ostream &OS)
static void printEmbeddings (const MachineFunction &MF, const mir2vec::MIRVocabulary &MIRVocab, raw_ostream &OS)
 INITIALIZE_PASS_BEGIN (MIR2VecPrinterLegacyPass, "print-mir2vec", "MIR2Vec Embedder Printer Pass", false, true) INITIALIZE_PASS_END(MIR2VecPrinterLegacyPass

Variables

static cl::opt< std::string > llvm::mir2vec::VocabFile ("mir2vec-vocab-path", cl::desc("Path to the vocabulary file for MIR2Vec"), cl::init(""), cl::cat(MIR2VecCategory))
static cl::opt< float > llvm::mir2vec::OpcWeight ("mir2vec-opc-weight", cl::init(1.0), cl::desc("Weight for machine opcode embeddings"), cl::cat(MIR2VecCategory))
static cl::opt< float > llvm::mir2vec::CommonOperandWeight ("mir2vec-common-operand-weight", cl::init(1.0), cl::desc("Weight for common operand embeddings"), cl::cat(MIR2VecCategory))
static cl::opt< float > llvm::mir2vec::RegOperandWeight ("mir2vec-reg-operand-weight", cl::init(1.0), cl::desc("Weight for register operand embeddings"), cl::cat(MIR2VecCategory))
cl::opt< MIR2VecKind > llvm::mir2vec::MIR2VecEmbeddingKind ("mir2vec-kind", cl::values(clEnumValN(MIR2VecKind::Symbolic, "symbolic", "Generate symbolic embeddings for MIR")), cl::init(MIR2VecKind::Symbolic), cl::desc("MIR2Vec embedding kind"), cl::cat(MIR2VecCategory))
static cl::opt< bool > llvm::mir2vec::PrintAllVocabEntries ("mir2vec-print-all-vocab-entries", cl::init(false), cl::desc("Print all vocabulary entries including zero embeddings"), cl::cat(MIR2VecCategory))
mir2vec vocab analysis
mir2vec vocab MIR2Vec Vocabulary Analysis
mir2vec vocab MIR2Vec Vocabulary false
print mir2vec vocab
print mir2vec MIR2Vec Vocabulary Printer Pass
print mir2vec

Detailed Description

This file implements the MIR2Vec algorithm for Machine IR embeddings.

Definition in file MIR2Vec.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "mir2vec"

Definition at line 31 of file MIR2Vec.cpp.

Typedef Documentation

◆ VocabMap

using VocabMap = std::map<std::string, Embedding>

Definition at line 473 of file MIR2Vec.cpp.

Function Documentation

◆ buildVocabulary()

Expected< mir2vec::MIRVocabulary > buildVocabulary ( const TargetSubtargetInfo & ST)
static

◆ INITIALIZE_PASS_BEGIN() [1/3]

INITIALIZE_PASS_BEGIN ( MIR2VecPrinterLegacyPass ,
"print-mir2vec" ,
"MIR2Vec Embedder Printer Pass" ,
false ,
true  )

◆ INITIALIZE_PASS_BEGIN() [2/3]

INITIALIZE_PASS_BEGIN ( MIR2VecVocabLegacyAnalysis ,
"mir2vec-vocab-analysis" ,
"MIR2Vec Vocabulary Analysis" ,
false ,
true  )

◆ INITIALIZE_PASS_BEGIN() [3/3]

INITIALIZE_PASS_BEGIN ( MIR2VecVocabPrinterLegacyPass ,
"print-mir2vec-vocab" ,
"MIR2Vec Vocabulary Printer Pass" ,
false ,
true  )

◆ printEmbeddings()

◆ printVocabulary()

print mir2vec MIR2Vec Vocabulary Printer static true void printVocabulary ( const mir2vec::MIRVocabulary & MIR2VecVocab,
raw_ostream & OS )
static

◆ readVocabulary()

◆ STATISTIC() [1/2]

STATISTIC ( MIRClasslessRegCounter ,
"Number of register operands with no register class"  )

◆ STATISTIC() [2/2]

STATISTIC ( MIRVocabMissCounter ,
"Number of lookups to MIR entities not present in the vocabulary"  )

Variable Documentation

◆ Analysis

mir2vec vocab MIR2Vec Vocabulary Analysis

Definition at line 554 of file MIR2Vec.cpp.

◆ analysis

mir2vec vocab analysis

Definition at line 553 of file MIR2Vec.cpp.

◆ false

print MIR2Vec Embedder Printer false

Definition at line 554 of file MIR2Vec.cpp.

◆ mir2vec

print mir2vec

Definition at line 752 of file MIR2Vec.cpp.

◆ Pass

◆ vocab

print mir2vec vocab

Definition at line 666 of file MIR2Vec.cpp.