LLVM 22.0.0git
MIR2Vec.h File Reference

This file defines the MIR2Vec framework for generating Machine IR embeddings. More...

Go to the source code of this file.

Classes

class  llvm::mir2vec::MIRVocabulary
 Class for storing and accessing the MIR2Vec vocabulary. More...
class  llvm::mir2vec::MIREmbedder
 Base class for MIR embedders. More...
class  llvm::mir2vec::SymbolicMIREmbedder
 Class for computing Symbolic embeddings Symbolic embeddings are constructed based on the entity-level representations obtained from the MIR Vocabulary. More...
class  llvm::MIR2VecVocabProvider
 MIR2Vec vocabulary provider used by pass managers and standalone tools. More...
class  llvm::MIR2VecVocabLegacyAnalysis
 Pass to analyze and populate MIR2Vec vocabulary from a module. More...
class  llvm::MIR2VecVocabPrinterLegacyPass
 This pass prints the embeddings in the MIR2Vec vocabulary. More...
class  llvm::MIR2VecPrinterLegacyPass
 This pass prints the MIR2Vec embeddings for machine functions, basic blocks, and instructions. More...

Namespaces

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

Typedefs

using llvm::mir2vec::Embedding = ir2vec::Embedding
using llvm::mir2vec::MachineInstEmbeddingsMap = DenseMap<const MachineInstr *, Embedding>
using llvm::mir2vec::MachineBlockEmbeddingsMap

Enumerations

enum class  llvm::MIR2VecKind { llvm::Symbolic }

Functions

MachineFunctionPassllvm::createMIR2VecPrinterLegacyPass (raw_ostream &OS)
 Create a machine pass that prints MIR2Vec embeddings.

Variables

llvm::cl::OptionCategory llvm::mir2vec::MIR2VecCategory
cl::opt< float > llvm::mir2vec::OpcWeight
cl::opt< float > llvm::mir2vec::CommonOperandWeight
cl::opt< float > llvm::mir2vec::RegOperandWeight

Detailed Description

This file defines the MIR2Vec framework for generating Machine IR embeddings.

Design Overview:

  1. MIR2VecVocabProvider - Core vocabulary loading logic (no PM dependency)
    • Can be used standalone or wrapped by the pass manager
    • Requires MachineModuleInfo with parsed machine functions
  2. MIR2VecVocabLegacyAnalysis - Pass manager wrapper (ImmutablePass)
    • Integrated and used by llc -print-mir2vec
  3. MIREmbedder - Generates embeddings from vocabulary
    • SymbolicMIREmbedder: MIR2Vec embedding implementation

MIR2Vec extends IR2Vec to support Machine IR embeddings. It represents the LLVM Machine IR as embeddings which can be used as input to machine learning algorithms.

The original idea of MIR2Vec is described in the following paper:

RL4ReAl: Reinforcement Learning for Register Allocation. S. VenkataKeerthy, Siddharth Jain, Anilava Kundu, Rohit Aggarwal, Albert Cohen, and Ramakrishna Upadrasta. 2023. RL4ReAl: Reinforcement Learning for Register Allocation. Proceedings of the 32nd ACM SIGPLAN International Conference on Compiler Construction (CC 2023). https://doi.org/10.1145/3578360.3580273. https://arxiv.org/abs/2204.02013

Definition in file MIR2Vec.h.