31#define DEBUG_TYPE "mir2vec"
34 "Number of lookups to MIR entities not present in the vocabulary");
36 "Number of register operands with no register class");
49 cl::desc(
"Weight for machine opcode embeddings"),
53 cl::desc(
"Weight for common operand embeddings"),
57 cl::desc(
"Weight for register operand embeddings"),
62 "Generate symbolic embeddings for MIR")),
67 "mir2vec-print-all-vocab-entries",
cl::init(
false),
68 cl::desc(
"Print all vocabulary entries including zero embeddings"),
84 buildCanonicalOpcodeMapping();
85 unsigned CanonicalOpcodeCount = UniqueBaseOpcodeNames.size();
86 assert(CanonicalOpcodeCount > 0 &&
87 "No canonical opcodes found for target - invalid vocabulary");
89 buildRegisterOperandMapping();
92 Layout.OpcodeBase = 0;
93 Layout.CommonOperandBase = CanonicalOpcodeCount;
95 Layout.PhyRegBase = Layout.CommonOperandBase + std::size(CommonOperands);
96 Layout.VirtRegBase = Layout.PhyRegBase + RegisterOperandNames.size();
98 generateStorage(OpcodeMap, CommonOperandMap, PhysicalRegisterMap,
100 Layout.TotalEntries = Storage.size();
104 VocabMap &&CommonOperandMap,
105 VocabMap &&PhyRegMap,
109 if (OpcodeMap.empty() || CommonOperandMap.empty() || PhyRegMap.empty() ||
112 "Empty vocabulary entries provided");
114 MIRVocabulary Vocab(std::move(OpcodeMap), std::move(CommonOperandMap),
115 std::move(PhyRegMap), std::move(
VirtRegMap), TII, TRI);
120 "Failed to create valid vocabulary storage");
122 return std::move(Vocab);
137 assert(!InstrName.
empty() &&
"Instruction name should not be empty");
140 static const Regex BaseOpcodeRegex(
"([a-zA-Z_]+)");
143 if (BaseOpcodeRegex.
match(InstrName, &Matches) && Matches.
size() > 1) {
146 while (!Match.
empty() && Match.
back() ==
'_')
152 return InstrName.
str();
156 assert(!UniqueBaseOpcodeNames.empty() &&
"Canonical mapping not built");
158 assert(It != UniqueBaseOpcodeNames.end() && *It == BaseName &&
159 "Base name not found in unique opcodes");
160 return std::distance(UniqueBaseOpcodeNames.begin(), It);
163unsigned MIRVocabulary::getCanonicalOpcodeIndex(
unsigned Opcode)
const {
164 assert(Opcode < OpcodeToCanonicalIndex.size() &&
"Opcode out of bounds");
165 return OpcodeToCanonicalIndex[Opcode];
170 auto It =
llvm::find_if(CommonOperands, [&](
const CommonOperandEntry &E) {
171 return E.Name == OperandName;
173 assert(It != std::end(CommonOperands) &&
174 "Operand name not found in common operands");
175 return Layout.CommonOperandBase +
176 std::distance(std::begin(CommonOperands), It);
181 bool IsPhysical)
const {
182 auto It = std::find(RegisterOperandNames.begin(), RegisterOperandNames.end(),
184 assert(It != RegisterOperandNames.end() &&
185 "Register name not found in register operands");
186 unsigned LocalIndex = std::distance(RegisterOperandNames.begin(), It);
187 return (IsPhysical ? Layout.PhyRegBase : Layout.VirtRegBase) + LocalIndex;
191 assert(Pos < Layout.TotalEntries &&
"Position out of bounds in vocabulary");
194 if (Pos < Layout.CommonOperandBase) {
196 assert(Pos < UniqueBaseOpcodeNames.size() &&
197 "Canonical index out of bounds in opcode section");
198 return UniqueBaseOpcodeNames[Pos];
201 auto getLocalIndex = [](
unsigned Pos,
size_t BaseOffset,
size_t Bound,
203 unsigned LocalIndex = Pos - BaseOffset;
209 if (Pos < Layout.PhyRegBase) {
210 unsigned LocalIndex =
211 getLocalIndex(Pos, Layout.CommonOperandBase, std::size(CommonOperands),
212 "Local index out of bounds in common operands");
213 return CommonOperands[LocalIndex].Name.str();
217 if (Pos < Layout.VirtRegBase) {
218 unsigned LocalIndex =
219 getLocalIndex(Pos, Layout.PhyRegBase, RegisterOperandNames.size(),
220 "Local index out of bounds in physical registers");
221 return "PhyReg_" + RegisterOperandNames[LocalIndex];
225 unsigned LocalIndex =
226 getLocalIndex(Pos, Layout.VirtRegBase, RegisterOperandNames.size(),
227 "Local index out of bounds in virtual registers");
228 return "VirtReg_" + RegisterOperandNames[LocalIndex];
231void MIRVocabulary::generateStorage(
const VocabMap &OpcodeMap,
241 <<
"; using zero vector. This will result in an error "
243 ++MIRVocabMissCounter;
247 unsigned EmbeddingDim = OpcodeMap.begin()->second.size();
248 std::vector<Embedding> OpcodeEmbeddings(Layout.CommonOperandBase,
252 for (
auto COpcodeName : UniqueBaseOpcodeNames) {
253 if (
auto It = OpcodeMap.find(COpcodeName); It != OpcodeMap.end()) {
254 auto COpcodeIndex = getCanonicalIndexForBaseName(COpcodeName);
255 assert(COpcodeIndex < Layout.CommonOperandBase &&
256 "Canonical index out of bounds");
257 OpcodeEmbeddings[COpcodeIndex] = It->second;
259 handleMissingEntity(COpcodeName);
264 std::vector<Embedding> CommonOperandEmbeddings(std::size(CommonOperands),
266 unsigned OperandIndex = 0;
267 for (
const CommonOperandEntry &Entry : CommonOperands) {
268 if (
auto It = CommonOperandsMap.find(
Entry.Name.str());
269 It != CommonOperandsMap.end()) {
270 CommonOperandEmbeddings[OperandIndex] = It->second;
272 handleMissingEntity(
Entry.Name);
278 auto createRegisterEmbeddings = [&](
const VocabMap &RegMap) {
279 std::vector<Embedding> RegEmbeddings(RegisterOperandNames.size(),
281 unsigned RegOperandIndex = 0;
282 for (
const auto &RegOperandName : RegisterOperandNames) {
283 if (
auto It = RegMap.find(RegOperandName); It != RegMap.end())
284 RegEmbeddings[RegOperandIndex] = It->second;
286 handleMissingEntity(RegOperandName);
289 return RegEmbeddings;
293 std::vector<Embedding> PhyRegEmbeddings = createRegisterEmbeddings(PhyRegMap);
294 std::vector<Embedding> VirtRegEmbeddings =
298 auto scaleVocabSection = [](std::vector<Embedding> &Embeddings,
303 scaleVocabSection(OpcodeEmbeddings,
OpcWeight);
308 std::vector<std::vector<Embedding>> Sections(
309 static_cast<unsigned>(Section::MaxSections));
310 Sections[
static_cast<unsigned>(Section::Opcodes)] =
311 std::move(OpcodeEmbeddings);
312 Sections[
static_cast<unsigned>(Section::CommonOperands)] =
313 std::move(CommonOperandEmbeddings);
314 Sections[
static_cast<unsigned>(Section::PhyRegisters)] =
315 std::move(PhyRegEmbeddings);
316 Sections[
static_cast<unsigned>(Section::VirtRegisters)] =
317 std::move(VirtRegEmbeddings);
322void MIRVocabulary::buildCanonicalOpcodeMapping() {
324 if (!UniqueBaseOpcodeNames.empty())
328 unsigned NumOpcodes =
TII.getNumOpcodes();
330 BaseOpcodes.
reserve(NumOpcodes);
331 for (
unsigned Opcode = 0; Opcode < NumOpcodes; ++Opcode)
332 BaseOpcodes.
push_back(extractBaseOpcodeName(
TII.getName(Opcode)));
334 UniqueBaseOpcodeNames = BaseOpcodes;
336 UniqueBaseOpcodeNames.erase(
llvm::unique(UniqueBaseOpcodeNames),
337 UniqueBaseOpcodeNames.end());
339 OpcodeToCanonicalIndex.reserve(NumOpcodes);
340 for (
const std::string &BaseOpcode : BaseOpcodes)
341 OpcodeToCanonicalIndex.push_back(getCanonicalIndexForBaseName(BaseOpcode));
343 LLVM_DEBUG(
dbgs() <<
"MIR2Vec: Built canonical mapping for target with "
344 << UniqueBaseOpcodeNames.size()
345 <<
" unique base opcodes\n");
348void MIRVocabulary::buildRegisterOperandMapping() {
350 if (!RegisterOperandNames.empty())
353 for (
unsigned RC = 0; RC <
TRI.getNumRegClasses(); ++RC) {
360 RegisterOperandNames.push_back(ClassName.
str());
362 assert(RegisterOperandNames.size() ==
TRI.getNumRegClasses() &&
363 "Register operand names must be indexed by register class ID");
365 "Register class name collides with NoRegClass");
366 RegisterOperandNames.push_back(NoRegClassName.str());
369std::optional<unsigned> MIRVocabulary::getCommonOperandIndex(
372 "Expected non-register operand type");
374 "Operand type out of bounds");
376 static constexpr auto OperandTypeToIndex = [] {
377 std::array<unsigned, MachineOperand::MO_Last + 1>
Map{};
378 for (
unsigned &
I : Map)
380 for (
unsigned I = 0;
I < std::size(CommonOperands); ++
I)
381 Map[CommonOperands[
I].
Type] =
I;
391MIRVocabulary::getRegisterOperandIndex(
Register Reg,
393 assert(!RegisterOperandNames.empty() &&
"Register operand mapping not built");
396 "Expected a physical or virtual register");
404 RegClass =
TRI.getMinimalPhysRegClass(
Reg);
418 <<
", using NoRegClass.\n");
419 ++MIRClasslessRegCounter;
420 return RegisterOperandNames.size() - 1;
423 return RegClass->
getID();
428 assert(Dim > 0 &&
"Dimension must be greater than zero");
430 float DummyVal = 0.1f;
432 VocabMap DummyOpcMap, DummyOperandMap, DummyPhyRegMap, DummyVirtRegMap;
435 for (
unsigned Opcode = 0; Opcode < TII.getNumOpcodes(); ++Opcode) {
437 if (DummyOpcMap.count(BaseOpcode) == 0) {
438 DummyOpcMap[BaseOpcode] =
Embedding(Dim, DummyVal);
444 for (
const CommonOperandEntry &Entry : CommonOperands) {
445 DummyOperandMap[Entry.Name.str()] =
Embedding(Dim, DummyVal);
450 for (
unsigned RC = 0; RC < TRI.getNumRegClasses(); ++RC) {
455 std::string ClassName = TRI.getRegClassName(RegClass);
456 DummyPhyRegMap[ClassName] =
Embedding(Dim, DummyVal);
457 DummyVirtRegMap[ClassName] =
Embedding(Dim, DummyVal);
460 DummyPhyRegMap[NoRegClassName.str()] =
Embedding(Dim, DummyVal);
461 DummyVirtRegMap[NoRegClassName.str()] =
Embedding(Dim, DummyVal);
465 std::move(DummyOpcMap), std::move(DummyOperandMap),
466 std::move(DummyPhyRegMap), std::move(DummyVirtRegMap), TII, TRI);
481 "MIR2Vec vocabulary file path not specified; set it "
482 "using --mir2vec-vocab-path");
488 auto Content = BufOrError.get()->getBuffer();
491 if (!ParsedVocabValue)
494 unsigned OpcodeDim = 0, CommonOperandDim = 0, PhyRegOperandDim = 0,
495 VirtRegOperandDim = 0;
497 "Opcodes", *ParsedVocabValue, OpcodeVocab, OpcodeDim))
501 "CommonOperands", *ParsedVocabValue, CommonOperandVocab,
506 "PhysicalRegisters", *ParsedVocabValue, PhyRegVocabMap,
511 "VirtualRegisters", *ParsedVocabValue, VirtRegVocabMap,
516 if (!(OpcodeDim == CommonOperandDim && CommonOperandDim == PhyRegOperandDim &&
517 PhyRegOperandDim == VirtRegOperandDim)) {
520 "MIR2Vec vocabulary sections have different dimensions");
528 VocabMap OpcVocab, CommonOperandVocab, PhyRegVocabMap, VirtRegVocabMap;
532 return std::move(Err);
535 std::move(OpcVocab), std::move(CommonOperandVocab),
536 std::move(PhyRegVocabMap), std::move(VirtRegVocabMap), *ST.getInstrInfo(),
537 *ST.getRegisterInfo());
542 auto Defs = M.getFunctionDefs();
545 "No function definitions found in module");
546 return buildVocabulary(*MMI.getTarget().getSubtargetImpl(*Defs.begin()));
551 "MIR2Vec Vocabulary Analysis",
false,
true)
557 return "MIR2Vec Vocabulary Analysis";
563 ModuleAnalysisManager::Invalidator &Inv)
const {
574 return std::move(*VocabOrErr);
586 return std::make_unique<SymbolicMIREmbedder>(
MF,
Vocab);
604 MF.getFunction().getContext().emitError(
605 "MIR2Vec: No TargetInstrInfo available; cannot compute embeddings");
610 for (
const auto &
MI :
MBB) {
612 if (
MI.isDebugInstr())
636std::unique_ptr<SymbolicMIREmbedder>
639 return std::make_unique<SymbolicMIREmbedder>(
MF,
Vocab);
644 if (
MI.isDebugInstr())
654 return InstructionEmbedding;
663 "MIR2Vec Vocabulary Printer Pass",
false,
true)
672 for (
const auto &Entry : MIR2VecVocab) {
676 OS <<
"Key: " << MIR2VecVocab.getStringKey(Pos) <<
": ";
689 auto MIR2VecVocabOrErr =
Analysis.getMIR2VecVocabulary(M);
691 if (!MIR2VecVocabOrErr) {
692 OS <<
"MIR2Vec Vocabulary Printer: Failed to get vocabulary - "
693 <<
toString(MIR2VecVocabOrErr.takeError()) <<
"\n";
717 OS <<
"Error creating MIR2Vec embeddings for function " << MF.
getName()
722 OS <<
"MIR2Vec embeddings for machine function " << MF.
getName() <<
":\n";
723 OS <<
"Machine Function vector: ";
724 Emb->getMFunctionVector().print(OS);
726 OS <<
"Machine basic block vectors:\n";
728 OS <<
"Machine basic block: " <<
MBB.getFullName() <<
":\n";
729 Emb->getMBBVector(
MBB).print(OS);
732 OS <<
"Machine instruction vectors:\n";
737 if (
MI.isDebugInstr())
740 OS <<
"Machine instruction: ";
742 Emb->getMInstVector(
MI).print(OS);
749 "MIR2Vec Embedder Printer Pass",
false,
true)
753 "MIR2Vec Embedder Printer Pass",
false,
true)
758 Analysis.getMIR2VecVocabulary(*MF.getFunction().getParent());
const AArch64Subtarget & Subtarget
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const AArch64InstrInfo & TII
block Block Frequency Analysis
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
This file builds on the ADT/GraphTraits.h file to build generic depth first graph iterator.
Module.h This file contains the declarations for the Module class.
static void printEmbeddings(const MachineFunction &MF, const mir2vec::MIRVocabulary &MIRVocab, raw_ostream &OS)
static Error readVocabulary(VocabMap &OpcodeVocab, VocabMap &CommonOperandVocab, VocabMap &PhyRegVocabMap, VocabMap &VirtRegVocabMap)
std::map< std::string, Embedding > VocabMap
print mir2vec MIR2Vec Vocabulary Printer static true void printVocabulary(const mir2vec::MIRVocabulary &MIR2VecVocab, raw_ostream &OS)
static Expected< mir2vec::MIRVocabulary > buildVocabulary(const TargetSubtargetInfo &ST)
This file defines the MIR2Vec framework for generating Machine IR embeddings.
Register const TargetRegisterInfo * TRI
ModuleAnalysisManager MAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
SmallVector< MachineBasicBlock *, 4 > MBBVector
MachineRegisterInfo & MRI
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static const unsigned InvalidIndex
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
Module * getParent()
Get the module that this global value is contained inside of...
unsigned getID() const
getID() - Return the register class ID number.
This pass prints the MIR2Vec embeddings for machine functions, basic blocks, and instructions.
MIR2VecPrinterLegacyPass(raw_ostream &OS)
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
New pass manager analysis that provides the MIR2Vec vocabulary for a module.
LLVM_ABI Result run(Module &M, ModuleAnalysisManager &MAM)
const mir2vec::MIRVocabulary Result
Pass to analyze and populate MIR2Vec vocabulary from a module.
This pass prints the embeddings in the MIR2Vec vocabulary.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
MIR2Vec vocabulary provider used by pass managers and standalone tools.
LLVM_ABI Expected< mir2vec::MIRVocabulary > getVocabulary(const Module &M)
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
An analysis that produces MachineModuleInfo for a module.
MachineOperand class - Representation of each machine instruction operand.
@ MO_Register
Register operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const TargetRegisterClass * getRegClassOrNull(Register Reg) const
Return the register class of Reg, or null if Reg has not been assigned a register class yet.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
A Module instance is used to store all the information related to an LLVM module.
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
LLVM_ABI bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr, std::string *Error=nullptr) const
matches - Match the regex against a given String.
Wrapper class representing virtual and physical registers.
constexpr bool isValid() const
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
constexpr unsigned id() const
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
std::string str() const
Get the contents as an std::string.
constexpr bool empty() const
Check if the string is empty.
char back() const
Get the last character in the string.
StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TargetSubtargetInfo - Generic base class for all target subtargets.
The instances of the Type class are immutable: once they are created, they are never changed.
Generic storage class for section-based vocabularies.
static LLVM_ABI Error parseVocabSection(StringRef Key, const json::Value &ParsedVocabValue, VocabMap &TargetVocab, unsigned &Dim)
Parse a vocabulary section from JSON and populate the target vocabulary map.
unsigned getDimension() const
Get vocabulary dimension.
bool isValid() const
Check if vocabulary is valid (has data)
const unsigned Dimension
Dimension of the embeddings; Captured from the vocabulary.
const MIRVocabulary & Vocab
const float RegOperandWeight
const float CommonOperandWeight
LLVM_ABI Embedding computeEmbeddings() const
Function to compute embeddings.
const float OpcWeight
Weight for opcode embeddings.
const MachineFunction & MF
static LLVM_ABI std::unique_ptr< MIREmbedder > create(MIR2VecKind Mode, const MachineFunction &MF, const MIRVocabulary &Vocab)
Factory method to create an Embedder object of the specified kind Returns nullptr if the requested ki...
LLVM_ABI MIREmbedder(const MachineFunction &MF, const MIRVocabulary &Vocab)
Class for storing and accessing the MIR2Vec vocabulary.
const Embedding & getOperandEmbedding(const MachineOperand &Operand, const MachineRegisterInfo &MRI) const
LLVM_ABI unsigned getCanonicalIndexForOperandName(StringRef OperandName) const
LLVM_ABI unsigned getCanonicalIndexForRegisterClass(StringRef RegName, bool IsPhysical=true) const
static LLVM_ABI std::string extractBaseOpcodeName(StringRef InstrName)
Static method for extracting base opcode names (public for testing)
static LLVM_ABI Expected< MIRVocabulary > createDummyVocabForTest(const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, unsigned Dim=1)
Create a dummy vocabulary for testing purposes.
static LLVM_ABI Expected< MIRVocabulary > create(VocabMap &&OpcMap, VocabMap &&CommonOperandsMap, VocabMap &&PhyRegMap, VocabMap &&VirtRegMap, const TargetInstrInfo &TII, const TargetRegisterInfo &TRI)
Factory method to create MIRVocabulary from vocabulary map.
LLVM_ABI std::string getStringKey(unsigned Pos) const
Get the string key for a vocabulary entry at the given position.
LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &Inv) const
The vocabulary stays valid unless explicitly invalidated.
LLVM_ABI unsigned getCanonicalIndexForBaseName(StringRef BaseName) const
Get indices from opcode or operand names.
static std::unique_ptr< SymbolicMIREmbedder > create(const MachineFunction &MF, const MIRVocabulary &Vocab)
SymbolicMIREmbedder(const MachineFunction &F, const MIRVocabulary &Vocab)
This class implements an extremely fast bulk output stream that can only output to a stream.
OperandType
Operands are tagged with one of the values of this enum.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
initializer< Ty > init(const Ty &Val)
LLVM_ABI llvm::Expected< Value > parse(llvm::StringRef JSON)
Parses the provided JSON source, or returns a ParseError.
LLVM_ABI llvm::cl::OptionCategory MIR2VecCategory
static cl::opt< float > OpcWeight("mir2vec-opc-weight", cl::init(1.0), cl::desc("Weight for machine opcode embeddings"), cl::cat(MIR2VecCategory))
static cl::opt< float > RegOperandWeight("mir2vec-reg-operand-weight", cl::init(1.0), cl::desc("Weight for register operand embeddings"), cl::cat(MIR2VecCategory))
static cl::opt< bool > PrintAllVocabEntries("mir2vec-print-all-vocab-entries", cl::init(false), cl::desc("Print all vocabulary entries including zero embeddings"), cl::cat(MIR2VecCategory))
ir2vec::Embedding Embedding
cl::opt< MIR2VecKind > 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< std::string > VocabFile("mir2vec-vocab-path", cl::desc("Path to the vocabulary file for MIR2Vec"), cl::init(""), cl::cat(MIR2VecCategory))
static cl::opt< float > CommonOperandWeight("mir2vec-common-operand-weight", cl::init(1.0), cl::desc("Weight for common operand embeddings"), cl::cat(MIR2VecCategory))
This is an optimization pass for GlobalISel generic memory operations.
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
OuterAnalysisManagerProxy< ModuleAnalysisManager, MachineFunction > ModuleAnalysisManagerMachineFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
auto unique(Range &&R, Predicate P)
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
LLVM_ABI MachineFunctionPass * createMIR2VecPrinterLegacyPass(raw_ostream &OS)
Create a machine pass that prints MIR2Vec embeddings.
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
LLVM_ABI MachineFunctionPass * createMIR2VecVocabPrinterLegacyPass(raw_ostream &OS)
MIR2VecVocabPrinter pass - This pass prints out the MIR2Vec vocabulary contents to the given stream a...
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
iterator_range< df_iterator< T > > depth_first(const T &G)
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
MCRegisterClass TargetRegisterClass
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
A special type used by analysis passes to provide an address that identifies that particular analysis...