29#ifndef LLVM_CODEGEN_MIR2VEC_H
30#define LLVM_CODEGEN_MIR2VEC_H
65 using VocabMap = std::map<std::string, ir2vec::Embedding>;
75 enum class Section :
unsigned { Opcodes = 0, MaxSections };
78 mutable std::set<std::string> UniqueBaseOpcodeNames;
80 void generateStorage(
const VocabMap &OpcodeMap);
81 void buildCanonicalOpcodeMapping();
84 unsigned getCanonicalOpcodeIndex(
unsigned Opcode)
const;
100 unsigned LocalIndex = getCanonicalOpcodeIndex(Opcode);
101 return Storage[
static_cast<unsigned>(Section::Opcodes)][LocalIndex];
127 using VocabVector = std::vector<mir2vec::Embedding>;
128 using VocabMap = std::map<std::string, mir2vec::Embedding>;
129 VocabMap StrVocabMap;
133 Error readVocabulary();
165 return "MIR2Vec Vocabulary Printer Pass";
Provides ErrorOr<T> smart pointer.
const HexagonInstrInfo * TII
This file defines the IR2Vec vocabulary analysis(IR2VecVocabAnalysis), the core ir2vec::Embedder inte...
This header defines various interfaces for pass management in LLVM.
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.
Tagged union holding either a T or a Error.
This is an important class for using LLVM in a threaded context.
Pass to analyze and populate MIR2Vec vocabulary from a module.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
MIR2VecVocabLegacyAnalysis()
Expected< mir2vec::MIRVocabulary > getMIR2VecVocabulary(const Module &M)
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
MIR2VecVocabPrinterLegacyPass(raw_ostream &OS)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
MachineFunctionPass(char &ID)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
A Module instance is used to store all the information related to an LLVM module.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
Iterator support for section-based access.
Generic storage class for section-based vocabularies.
unsigned getDimension() const
const_iterator end() const
static std::string extractBaseOpcodeName(StringRef InstrName)
Static method for extracting base opcode names (public for testing)
ir2vec::VocabStorage::const_iterator const_iterator
const_iterator begin() const
const Embedding & operator[](unsigned Opcode) const
size_t getCanonicalSize() const
Total number of entries in the vocabulary.
static Expected< MIRVocabulary > create(VocabMap &&Entries, const TargetInstrInfo &TII)
Factory method to create MIRVocabulary from vocabulary map.
std::string getStringKey(unsigned Pos) const
Get the string key for a vocabulary entry at the given position.
unsigned getCanonicalIndexForBaseName(StringRef BaseName) const
Get canonical index for base name (public for testing)
This class implements an extremely fast bulk output stream that can only output to a stream.
llvm::cl::OptionCategory MIR2VecCategory
cl::opt< float > OpcWeight
ir2vec::Embedding Embedding
This is an optimization pass for GlobalISel generic memory operations.
Embedding is a datatype that wraps std::vector<double>.