LLVM 22.0.0git
llvm::mir2vec::MIREmbedder Class Referenceabstract

Base class for MIR embedders. More...

#include "llvm/CodeGen/MIR2Vec.h"

Inheritance diagram for llvm::mir2vec::MIREmbedder:
[legend]

Public Member Functions

virtual ~MIREmbedder ()=default
Embedding getMInstVector (const MachineInstr &MI) const
 Computes and returns the embedding for a given machine instruction MI in the machine function MF.
Embedding getMBBVector (const MachineBasicBlock &MBB) const
 Computes and returns the embedding for a given machine basic block in the machine function MF.
Embedding getMFunctionVector () const
 Computes and returns the embedding for the current machine function.

Static Public Member Functions

static std::unique_ptr< MIREmbeddercreate (MIR2VecKind Mode, const MachineFunction &MF, const MIRVocabulary &Vocab)
 Factory method to create an Embedder object of the specified kind Returns nullptr if the requested kind is not supported.

Protected Member Functions

 MIREmbedder (const MachineFunction &MF, const MIRVocabulary &Vocab)
Embedding computeEmbeddings () const
 Function to compute embeddings.
Embedding computeEmbeddings (const MachineBasicBlock &MBB) const
 Function to compute the embedding for a given machine basic block.
virtual Embedding computeEmbeddings (const MachineInstr &MI) const =0
 Function to compute the embedding for a given machine instruction.

Protected Attributes

const MachineFunctionMF
const MIRVocabularyVocab
const unsigned Dimension
 Dimension of the embeddings; Captured from the vocabulary.
const float OpcWeight
 Weight for opcode embeddings.
const float CommonOperandWeight
const float RegOperandWeight

Detailed Description

Base class for MIR embedders.

Definition at line 249 of file MIR2Vec.h.

Constructor & Destructor Documentation

◆ MIREmbedder()

llvm::mir2vec::MIREmbedder::MIREmbedder ( const MachineFunction & MF,
const MIRVocabulary & Vocab )
inlineprotected

◆ ~MIREmbedder()

virtual llvm::mir2vec::MIREmbedder::~MIREmbedder ( )
virtualdefault

References MF, Mode, and Vocab.

Member Function Documentation

◆ computeEmbeddings() [1/3]

Embedding MIREmbedder::computeEmbeddings ( ) const
protected

Function to compute embeddings.

Definition at line 549 of file MIR2Vec.cpp.

References computeEmbeddings(), llvm::depth_first(), Dimension, MBB, and MF.

Referenced by computeEmbeddings(), computeEmbeddings(), getMBBVector(), getMFunctionVector(), and getMInstVector().

◆ computeEmbeddings() [2/3]

Embedding MIREmbedder::computeEmbeddings ( const MachineBasicBlock & MBB) const
protected

Function to compute the embedding for a given machine basic block.

Definition at line 526 of file MIR2Vec.cpp.

References computeEmbeddings(), Dimension, MBB, MF, MI, and TII.

◆ computeEmbeddings() [3/3]

virtual Embedding llvm::mir2vec::MIREmbedder::computeEmbeddings ( const MachineInstr & MI) const
protectedpure virtual

Function to compute the embedding for a given machine instruction.

Specific to the kind of embeddings being computed.

References MI.

◆ create()

std::unique_ptr< MIREmbedder > MIREmbedder::create ( MIR2VecKind Mode,
const MachineFunction & MF,
const MIRVocabulary & Vocab )
static

Factory method to create an Embedder object of the specified kind Returns nullptr if the requested kind is not supported.

Definition at line 516 of file MIR2Vec.cpp.

References MF, llvm::Symbolic, and Vocab.

Referenced by llvm::MIR2VecPrinterLegacyPass::runOnMachineFunction().

◆ getMBBVector()

Embedding llvm::mir2vec::MIREmbedder::getMBBVector ( const MachineBasicBlock & MBB) const
inline

Computes and returns the embedding for a given machine basic block in the machine function MF.

Definition at line 293 of file MIR2Vec.h.

References computeEmbeddings(), and MBB.

◆ getMFunctionVector()

Embedding llvm::mir2vec::MIREmbedder::getMFunctionVector ( ) const
inline

Computes and returns the embedding for the current machine function.

Definition at line 298 of file MIR2Vec.h.

References computeEmbeddings().

◆ getMInstVector()

Embedding llvm::mir2vec::MIREmbedder::getMInstVector ( const MachineInstr & MI) const
inline

Computes and returns the embedding for a given machine instruction MI in the machine function MF.

Definition at line 287 of file MIR2Vec.h.

References computeEmbeddings(), and MI.

Member Data Documentation

◆ CommonOperandWeight

const float llvm::mir2vec::MIREmbedder::CommonOperandWeight
protected

Definition at line 258 of file MIR2Vec.h.

Referenced by MIREmbedder().

◆ Dimension

const unsigned llvm::mir2vec::MIREmbedder::Dimension
protected

Dimension of the embeddings; Captured from the vocabulary.

Definition at line 255 of file MIR2Vec.h.

Referenced by computeEmbeddings(), computeEmbeddings(), and MIREmbedder().

◆ MF

◆ OpcWeight

const float llvm::mir2vec::MIREmbedder::OpcWeight
protected

Weight for opcode embeddings.

Definition at line 258 of file MIR2Vec.h.

Referenced by MIREmbedder().

◆ RegOperandWeight

const float llvm::mir2vec::MIREmbedder::RegOperandWeight
protected

Definition at line 258 of file MIR2Vec.h.

Referenced by MIREmbedder().

◆ Vocab


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