LLVM 24.0.0git
MIR2Vec.h
Go to the documentation of this file.
1//===- MIR2Vec.h - Implementation of MIR2Vec ------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM
4// Exceptions. See the LICENSE file for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file defines the MIR2Vec framework for generating Machine IR
11/// embeddings.
12///
13/// Design Overview:
14/// ----------------------
15/// 1. MIR2VecVocabProvider - Core vocabulary loading logic (no PM dependency)
16/// - Can be used standalone or wrapped by the pass manager
17/// - Requires MachineModuleInfo with parsed machine functions
18///
19/// 2. MIR2VecVocabLegacyAnalysis - Pass manager wrapper (ImmutablePass)
20/// - Integrated and used by llc -print-mir2vec
21///
22/// 3. MIREmbedder - Generates embeddings from vocabulary
23/// - SymbolicMIREmbedder: MIR2Vec embedding implementation
24///
25/// MIR2Vec extends IR2Vec to support Machine IR embeddings. It represents the
26/// LLVM Machine IR as embeddings which can be used as input to machine learning
27/// algorithms.
28///
29/// The original idea of MIR2Vec is described in the following paper:
30///
31/// RL4ReAl: Reinforcement Learning for Register Allocation. S. VenkataKeerthy,
32/// Siddharth Jain, Anilava Kundu, Rohit Aggarwal, Albert Cohen, and Ramakrishna
33/// Upadrasta. 2023. RL4ReAl: Reinforcement Learning for Register Allocation.
34/// Proceedings of the 32nd ACM SIGPLAN International Conference on Compiler
35/// Construction (CC 2023). https://doi.org/10.1145/3578360.3580273.
36/// https://arxiv.org/abs/2204.02013
37///
38//===----------------------------------------------------------------------===//
39
40#ifndef LLVM_CODEGEN_MIR2VEC_H
41#define LLVM_CODEGEN_MIR2VEC_H
42
51#include "llvm/IR/PassManager.h"
52#include "llvm/Pass.h"
54#include "llvm/Support/Error.h"
56#include <map>
57#include <optional>
58#include <set>
59#include <string>
60
61namespace llvm {
62
63class Module;
64class raw_ostream;
65class LLVMContext;
67class TargetInstrInfo;
68
69enum class MIR2VecKind { Symbolic };
70
71namespace mir2vec {
72
73// Forward declarations
74class MIREmbedder;
76
79
84
85/// Class for storing and accessing the MIR2Vec vocabulary.
86/// The MIRVocabulary class manages seed embeddings for LLVM Machine IR
89 using VocabMap = std::map<std::string, ir2vec::Embedding>;
90
91 // MIRVocabulary Layout:
92 // +-------------------+-----------------------------------------------------+
93 // | Entity Type | Description |
94 // +-------------------+-----------------------------------------------------+
95 // | 1. Opcodes | Target specific opcodes derived from TII, grouped |
96 // | | by instruction semantics. |
97 // | 2. Common Operands| All common operand types, except register operands, |
98 // | | defined by MachineOperand::MachineOperandType enum. |
99 // | 3. Physical | Register classes defined by the target, specialized |
100 // | Reg classes | by physical registers. |
101 // | 4. Virtual | Register classes defined by the target, specialized |
102 // | Reg classes | by virtual and physical registers. |
103 // +-------------------+-----------------------------------------------------+
104
105 /// Layout information for the MIR vocabulary. Defines the starting index
106 /// and size of each section in the vocabulary.
107 struct {
108 size_t OpcodeBase = 0;
110 size_t PhyRegBase = 0;
111 size_t VirtRegBase = 0;
112 size_t TotalEntries = 0;
113 } Layout;
114
115 // TODO: See if we can have only one reg classes section instead of physical
116 // and virtual separate sections in the vocabulary. This would reduce the
117 // number of vocabulary entities significantly.
118 // We can potentially distinguish physical and virtual registers by
119 // considering them as a separate feature.
120 enum class Section : unsigned {
121 Opcodes = 0,
122 CommonOperands = 1,
123 PhyRegisters = 2,
124 VirtRegisters = 3,
125 MaxSections
126 };
127
128 ir2vec::VocabStorage Storage;
129 std::set<std::string> UniqueBaseOpcodeNames;
130 SmallVector<std::string, 24> RegisterOperandNames;
131
132 // Some instructions have optional register operands that may be NoRegister.
133 // We return a zero vector in such cases.
134 Embedding ZeroEmbedding;
135
136 // We have specialized MO_Register handling in the Register operand section,
137 // so we don't include it here. Also, no MO_DbgInstrRef for now.
138 static constexpr StringLiteral CommonOperandNames[] = {
139 "Immediate", "CImmediate", "FPImmediate", "MBB",
140 "FrameIndex", "ConstantPoolIndex", "TargetIndex", "JumpTableIndex",
141 "ExternalSymbol", "GlobalAddress", "BlockAddress", "RegisterMask",
142 "RegisterLiveOut", "Metadata", "MCSymbol", "CFIIndex",
143 "IntrinsicID", "Predicate", "ShuffleMask", "LaneMask"};
144 static_assert(std::size(CommonOperandNames) == MachineOperand::MO_Last - 1 &&
145 "Common operand names size changed, update accordingly");
146
147 const TargetInstrInfo &TII;
148 const TargetRegisterInfo &TRI;
149 const MachineRegisterInfo &MRI;
150
151 void generateStorage(const VocabMap &OpcodeMap,
152 const VocabMap &CommonOperandMap,
153 const VocabMap &PhyRegMap, const VocabMap &VirtRegMap);
154 void buildCanonicalOpcodeMapping();
155 void buildRegisterOperandMapping();
156
157 /// Get canonical index for a machine opcode
158 LLVM_ABI unsigned getCanonicalOpcodeIndex(unsigned Opcode) const;
159
160 /// Get index for a common (non-register) machine operand
161 LLVM_ABI unsigned
162 getCommonOperandIndex(MachineOperand::MachineOperandType OperandType) const;
163
164 /// Get index for a register machine operand. Returns std::nullopt if Reg
165 /// belongs to no register class, which is a valid outcome for some target
166 /// physical registers.
167 LLVM_ABI std::optional<unsigned> getRegisterOperandIndex(Register Reg) const;
168
169 // Accessors for operand types
170 const Embedding &
171 operator[](MachineOperand::MachineOperandType OperandType) const {
172 unsigned LocalIndex = getCommonOperandIndex(OperandType);
173 return Storage[static_cast<unsigned>(Section::CommonOperands)][LocalIndex];
174 }
175
176 const Embedding &operator[](Register Reg) const {
177 // Reg is sometimes NoRegister (0) for optional operands. We return a zero
178 // vector in this case.
179 if (!Reg.isValid())
180 return ZeroEmbedding;
181 // TODO: Implement proper stack slot handling for MIR2Vec embeddings.
182 // Stack slots represent frame indices and should have their own
183 // embedding strategy rather than defaulting to register class 0.
184 // Consider: 1) Separate vocabulary section for stack slots
185 // 2) Stack slot size/alignment based embeddings
186 // 3) Frame index based categorization
187 if (Reg.isStack())
188 return ZeroEmbedding;
189
190 // Registers that belong to no register class have no vocabulary entry;
191 // treat them like the other unmapped cases above.
192 std::optional<unsigned> LocalIndex = getRegisterOperandIndex(Reg);
193 if (!LocalIndex)
194 return ZeroEmbedding;
195 auto SectionID =
196 Reg.isPhysical() ? Section::PhyRegisters : Section::VirtRegisters;
197 return Storage[static_cast<unsigned>(SectionID)][*LocalIndex];
198 }
199
200 /// Get entity ID (flat index) for a common operand type
201 /// This is used for triplet generation
202 unsigned getEntityIDForCommonOperand(
203 MachineOperand::MachineOperandType OperandType) const {
204 return Layout.CommonOperandBase + getCommonOperandIndex(OperandType);
205 }
206
207 /// Get entity ID (flat index) for a register
208 /// This is used for triplet generation
209 unsigned getEntityIDForRegister(Register Reg) const {
210 if (!Reg.isValid() || Reg.isStack())
211 return Layout
212 .VirtRegBase; // Return VirtRegBase for invalid/stack registers
213 std::optional<unsigned> LocalIndex = getRegisterOperandIndex(Reg);
214 // Registers without a register class share the invalid/stack fallback.
215 if (!LocalIndex)
216 return Layout.VirtRegBase;
217 size_t BaseOffset =
218 Reg.isPhysical() ? Layout.PhyRegBase : Layout.VirtRegBase;
219 return BaseOffset + *LocalIndex;
220 }
221
222public:
223 /// Static method for extracting base opcode names (public for testing)
224 LLVM_ABI static std::string extractBaseOpcodeName(StringRef InstrName);
225
226 /// Get indices from opcode or operand names. These are public for testing.
227 /// String based lookups are inefficient and should be avoided in general.
228 LLVM_ABI unsigned getCanonicalIndexForBaseName(StringRef BaseName) const;
229 LLVM_ABI unsigned
230 getCanonicalIndexForOperandName(StringRef OperandName) const;
231 LLVM_ABI unsigned
233 bool IsPhysical = true) const;
234
235 /// Get the string key for a vocabulary entry at the given position
236 LLVM_ABI std::string getStringKey(unsigned Pos) const;
237
238 unsigned getDimension() const { return Storage.getDimension(); }
239
240 /// Get entity ID (flat index) for an opcode
241 /// This is used for triplet generation
242 unsigned getEntityIDForOpcode(unsigned Opcode) const {
243 return Layout.OpcodeBase + getCanonicalOpcodeIndex(Opcode);
244 }
245
246 /// Get entity ID (flat index) for a machine operand
247 /// This is used for triplet generation
250 return getEntityIDForRegister(MO.getReg());
251 return getEntityIDForCommonOperand(MO.getType());
252 }
253
254 // Accessor methods
255 const Embedding &operator[](unsigned Opcode) const {
256 unsigned LocalIndex = getCanonicalOpcodeIndex(Opcode);
257 return Storage[static_cast<unsigned>(Section::Opcodes)][LocalIndex];
258 }
259
260 const Embedding &operator[](MachineOperand Operand) const {
261 auto OperandType = Operand.getType();
262 if (OperandType == MachineOperand::MO_Register)
263 return operator[](Operand.getReg());
264 else
265 return operator[](OperandType);
266 }
267
268 // Iterator access
270 const_iterator begin() const { return Storage.begin(); }
271
272 const_iterator end() const { return Storage.end(); }
273
274 MIRVocabulary() = delete;
275
276 /// Factory method to create MIRVocabulary from vocabulary map
278 create(VocabMap &&OpcMap, VocabMap &&CommonOperandsMap, VocabMap &&PhyRegMap,
279 VocabMap &&VirtRegMap, const TargetInstrInfo &TII,
280 const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI);
281
282 /// Create a dummy vocabulary for testing purposes.
285 const TargetRegisterInfo &TRI,
286 const MachineRegisterInfo &MRI, unsigned Dim = 1);
287
288 /// Total number of entries in the vocabulary
289 size_t getCanonicalSize() const { return Storage.size(); }
290
291private:
292 MIRVocabulary(VocabMap &&OpcMap, VocabMap &&CommonOperandsMap,
293 VocabMap &&PhyRegMap, VocabMap &&VirtRegMap,
295 const MachineRegisterInfo &MRI);
296};
297
298/// Base class for MIR embedders
300protected:
303
304 /// Dimension of the embeddings; Captured from the vocabulary
305 const unsigned Dimension;
306
307 /// Weight for opcode embeddings
309
315
316 /// Function to compute embeddings.
318
319 /// Function to compute the embedding for a given machine basic block.
321
322 /// Function to compute the embedding for a given machine instruction.
323 /// Specific to the kind of embeddings being computed.
324 virtual Embedding computeEmbeddings(const MachineInstr &MI) const = 0;
325
326public:
327 virtual ~MIREmbedder() = default;
328
329 /// Factory method to create an Embedder object of the specified kind
330 /// Returns nullptr if the requested kind is not supported.
331 LLVM_ABI static std::unique_ptr<MIREmbedder>
333 const MIRVocabulary &Vocab);
334
335 /// Computes and returns the embedding for a given machine instruction MI in
336 /// the machine function MF.
338 return computeEmbeddings(MI);
339 }
340
341 /// Computes and returns the embedding for a given machine basic block in the
342 /// machine function MF.
346
347 /// Computes and returns the embedding for the current machine function.
349 // Currently, we always (re)compute the embeddings for the function. This is
350 // cheaper than caching the vector.
351 return computeEmbeddings();
352 }
353};
354
355/// Class for computing Symbolic embeddings
356/// Symbolic embeddings are constructed based on the entity-level
357/// representations obtained from the MIR Vocabulary.
359private:
360 Embedding computeEmbeddings(const MachineInstr &MI) const override;
361
362public:
364 static std::unique_ptr<SymbolicMIREmbedder>
366};
367
368} // namespace mir2vec
369
370/// MIR2Vec vocabulary provider used by pass managers and standalone tools.
371/// This class encapsulates the core vocabulary loading logic and can be used
372/// independently of the pass manager infrastructure. For pass-based usage,
373/// see MIR2VecVocabLegacyAnalysis.
374///
375/// Note: This provider pattern makes new PM migration straightforward when
376/// needed. A new PM analysis wrapper can be added that delegates to this
377/// provider, similar to how MIR2VecVocabLegacyAnalysis currently wraps it.
379 using VocabMap = std::map<std::string, mir2vec::Embedding>;
380
381public:
382 MIR2VecVocabProvider(const MachineModuleInfo &MMI) : MMI(MMI) {}
383
385
386private:
387 Error readVocabulary(VocabMap &OpcVocab, VocabMap &CommonOperandVocab,
388 VocabMap &PhyRegVocabMap, VocabMap &VirtRegVocabMap);
389 const MachineModuleInfo &MMI;
390};
391
392/// Pass to analyze and populate MIR2Vec vocabulary from a module
394 using VocabVector = std::vector<mir2vec::Embedding>;
395 using VocabMap = std::map<std::string, mir2vec::Embedding>;
396
397 StringRef getPassName() const override;
398
399protected:
400 void getAnalysisUsage(AnalysisUsage &AU) const override {
402 AU.setPreservesAll();
403 }
404 std::unique_ptr<MIR2VecVocabProvider> Provider;
405
406public:
407 static char ID;
409
411 MachineModuleInfo &MMI =
413 if (!Provider)
414 Provider = std::make_unique<MIR2VecVocabProvider>(MMI);
415 return Provider->getVocabulary(M);
416 }
417
419 assert(Provider && "Provider not initialized");
420 return *Provider;
421 }
422};
423
424/// This pass prints the embeddings in the MIR2Vec vocabulary
426 raw_ostream &OS;
427
428public:
429 static char ID;
432
433 bool runOnMachineFunction(MachineFunction &MF) override;
434 bool doFinalization(Module &M) override;
440
441 StringRef getPassName() const override {
442 return "MIR2Vec Vocabulary Printer Pass";
443 }
444};
445
446/// This pass prints the MIR2Vec embeddings for machine functions, basic blocks,
447/// and instructions
449 raw_ostream &OS;
450
451public:
452 static char ID;
455
456 bool runOnMachineFunction(MachineFunction &MF) override;
462
463 StringRef getPassName() const override {
464 return "MIR2Vec Embedder Printer Pass";
465 }
466};
467
468/// Create a machine pass that prints MIR2Vec embeddings
469LLVM_ABI MachineFunctionPass *createMIR2VecPrinterLegacyPass(raw_ostream &OS);
470
471} // namespace llvm
472
473#endif // LLVM_CODEGEN_MIR2VEC_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
#define LLVM_ABI
Definition Compiler.h:215
Provides ErrorOr<T> smart pointer.
const HexagonInstrInfo * TII
This file defines the IR2Vec vocabulary analysis(IR2VecVocabAnalysis), the core ir2vec::Embedder inte...
IRTranslator LLVM IR MI
This header defines various interfaces for pass management in LLVM.
#define RegName(no)
#define F(x, y, z)
Definition MD5.cpp:54
Register Reg
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
ImmutablePass(char &pid)
Definition Pass.h:287
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
MIR2VecPrinterLegacyPass(raw_ostream &OS)
Definition MIR2Vec.h:453
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition MIR2Vec.h:457
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
Definition MIR2Vec.h:463
Pass to analyze and populate MIR2Vec vocabulary from a module.
Definition MIR2Vec.h:393
MIR2VecVocabProvider & getProvider()
Definition MIR2Vec.h:418
Expected< mir2vec::MIRVocabulary > getMIR2VecVocabulary(const Module &M)
Definition MIR2Vec.h:410
std::unique_ptr< MIR2VecVocabProvider > Provider
Definition MIR2Vec.h:404
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition MIR2Vec.h:400
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
Definition MIR2Vec.h:441
MIR2VecVocabPrinterLegacyPass(raw_ostream &OS)
Definition MIR2Vec.h:430
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition MIR2Vec.h:435
MIR2Vec vocabulary provider used by pass managers and standalone tools.
Definition MIR2Vec.h:378
MIR2VecVocabProvider(const MachineModuleInfo &MMI)
Definition MIR2Vec.h:382
LLVM_ABI Expected< mir2vec::MIRVocabulary > getVocabulary(const Module &M)
Definition MIR2Vec.cpp:449
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Representation of each machine instruction.
This class contains meta information specific to a module.
MachineOperand class - Representation of each machine instruction operand.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
Register getReg() const
getReg - Returns the register number.
@ MO_Register
Register operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition StringRef.h:888
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Iterator support for section-based access.
Definition IR2Vec.h:202
Generic storage class for section-based vocabularies.
Definition IR2Vec.h:157
Base class for MIR embedders.
Definition MIR2Vec.h:299
const unsigned Dimension
Dimension of the embeddings; Captured from the vocabulary.
Definition MIR2Vec.h:305
Embedding getMFunctionVector() const
Computes and returns the embedding for the current machine function.
Definition MIR2Vec.h:348
const MIRVocabulary & Vocab
Definition MIR2Vec.h:302
Embedding getMInstVector(const MachineInstr &MI) const
Computes and returns the embedding for a given machine instruction MI in the machine function MF.
Definition MIR2Vec.h:337
virtual Embedding computeEmbeddings(const MachineInstr &MI) const =0
Function to compute the embedding for a given machine instruction.
Embedding getMBBVector(const MachineBasicBlock &MBB) const
Computes and returns the embedding for a given machine basic block in the machine function MF.
Definition MIR2Vec.h:343
const float RegOperandWeight
Definition MIR2Vec.h:308
MIREmbedder(const MachineFunction &MF, const MIRVocabulary &Vocab)
Definition MIR2Vec.h:310
const float CommonOperandWeight
Definition MIR2Vec.h:308
LLVM_ABI Embedding computeEmbeddings() const
Function to compute embeddings.
Definition MIR2Vec.cpp:574
const float OpcWeight
Weight for opcode embeddings.
Definition MIR2Vec.h:308
const MachineFunction & MF
Definition MIR2Vec.h:301
virtual ~MIREmbedder()=default
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...
Definition MIR2Vec.cpp:541
Class for storing and accessing the MIR2Vec vocabulary.
Definition MIR2Vec.h:87
unsigned getDimension() const
Definition MIR2Vec.h:238
unsigned getEntityIDForOpcode(unsigned Opcode) const
Get entity ID (flat index) for an opcode This is used for triplet generation.
Definition MIR2Vec.h:242
const_iterator end() const
Definition MIR2Vec.h:272
LLVM_ABI unsigned getCanonicalIndexForOperandName(StringRef OperandName) const
Definition MIR2Vec.cpp:166
const Embedding & operator[](MachineOperand Operand) const
Definition MIR2Vec.h:260
LLVM_ABI unsigned getCanonicalIndexForRegisterClass(StringRef RegName, bool IsPhysical=true) const
Definition MIR2Vec.cpp:176
static LLVM_ABI Expected< MIRVocabulary > create(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.
Definition MIR2Vec.cpp:100
static LLVM_ABI std::string extractBaseOpcodeName(StringRef InstrName)
Static method for extracting base opcode names (public for testing)
Definition MIR2Vec.cpp:121
ir2vec::VocabStorage::const_iterator const_iterator
Definition MIR2Vec.h:269
const_iterator begin() const
Definition MIR2Vec.h:270
const Embedding & operator[](unsigned Opcode) const
Definition MIR2Vec.h:255
size_t getCanonicalSize() const
Total number of entries in the vocabulary.
Definition MIR2Vec.h:289
static LLVM_ABI Expected< MIRVocabulary > createDummyVocabForTest(const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, unsigned Dim=1)
Create a dummy vocabulary for testing purposes.
Definition MIR2Vec.cpp:402
unsigned getEntityIDForMachineOperand(const MachineOperand &MO) const
Get entity ID (flat index) for a machine operand This is used for triplet generation.
Definition MIR2Vec.h:248
LLVM_ABI std::string getStringKey(unsigned Pos) const
Get the string key for a vocabulary entry at the given position.
Definition MIR2Vec.cpp:186
LLVM_ABI unsigned getCanonicalIndexForBaseName(StringRef BaseName) const
Get indices from opcode or operand names.
Definition MIR2Vec.cpp:151
Class for computing Symbolic embeddings Symbolic embeddings are constructed based on the entity-level...
Definition MIR2Vec.h:358
static std::unique_ptr< SymbolicMIREmbedder > create(const MachineFunction &MF, const MIRVocabulary &Vocab)
Definition MIR2Vec.cpp:591
SymbolicMIREmbedder(const MachineFunction &F, const MIRVocabulary &Vocab)
Definition MIR2Vec.cpp:586
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
DenseMap< const MachineInstr *, Embedding > MachineInstEmbeddingsMap
Definition MIR2Vec.h:81
LLVM_ABI llvm::cl::OptionCategory MIR2VecCategory
LLVM_ABI cl::opt< float > OpcWeight
LLVM_ABI cl::opt< float > RegOperandWeight
Definition MIR2Vec.h:78
ir2vec::Embedding Embedding
Definition MIR2Vec.h:80
DenseMap< const MachineBasicBlock *, Embedding > MachineBlockEmbeddingsMap
Definition MIR2Vec.h:82
LLVM_ABI cl::opt< float > CommonOperandWeight
Definition MIR2Vec.h:78
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI MachineFunctionPass * createMIR2VecPrinterLegacyPass(raw_ostream &OS)
Create a machine pass that prints MIR2Vec embeddings.
Definition MIR2Vec.cpp:706
MIR2VecKind
Definition MIR2Vec.h:69
Embedding is a datatype that wraps std::vector<double>.
Definition IR2Vec.h:88