Changeset View
Changeset View
Standalone View
Standalone View
llvm/include/llvm/CodeGen/MachineModuleInfo.h
Show All 27 Lines | |||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#ifndef LLVM_CODEGEN_MACHINEMODULEINFO_H | #ifndef LLVM_CODEGEN_MACHINEMODULEINFO_H | ||||
#define LLVM_CODEGEN_MACHINEMODULEINFO_H | #define LLVM_CODEGEN_MACHINEMODULEINFO_H | ||||
#include "llvm/ADT/ArrayRef.h" | #include "llvm/ADT/ArrayRef.h" | ||||
#include "llvm/ADT/DenseMap.h" | #include "llvm/ADT/DenseMap.h" | ||||
#include "llvm/ADT/PointerIntPair.h" | #include "llvm/ADT/PointerIntPair.h" | ||||
#include "llvm/IR/PassManager.h" | |||||
#include "llvm/MC/MCContext.h" | #include "llvm/MC/MCContext.h" | ||||
#include "llvm/MC/MCSymbol.h" | #include "llvm/MC/MCSymbol.h" | ||||
#include "llvm/Pass.h" | #include "llvm/Pass.h" | ||||
#include <memory> | #include <memory> | ||||
#include <utility> | #include <utility> | ||||
#include <vector> | #include <vector> | ||||
namespace llvm { | namespace llvm { | ||||
Show All 25 Lines | protected: | ||||
static SymbolListTy getSortedStubs(DenseMap<MCSymbol*, StubValueTy>&); | static SymbolListTy getSortedStubs(DenseMap<MCSymbol*, StubValueTy>&); | ||||
}; | }; | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
/// This class contains meta information specific to a module. Queries can be | /// This class contains meta information specific to a module. Queries can be | ||||
/// made by different debugging and exception handling schemes and reformated | /// made by different debugging and exception handling schemes and reformated | ||||
/// for specific use. | /// for specific use. | ||||
/// | /// | ||||
class MachineModuleInfo : public ImmutablePass { | class MachineModuleInfo { | ||||
friend class MachineModuleInfoWrapperPass; | |||||
friend class MachineModuleAnalysis; | |||||
const LLVMTargetMachine &TM; | const LLVMTargetMachine &TM; | ||||
/// This is the MCContext used for the entire code generator. | /// This is the MCContext used for the entire code generator. | ||||
MCContext Context; | MCContext Context; | ||||
/// This is the LLVM Module being worked on. | /// This is the LLVM Module being worked on. | ||||
const Module *TheModule; | const Module *TheModule; | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | class MachineModuleInfo { | ||||
/// Maps IR Functions to their corresponding MachineFunctions. | /// Maps IR Functions to their corresponding MachineFunctions. | ||||
DenseMap<const Function*, std::unique_ptr<MachineFunction>> MachineFunctions; | DenseMap<const Function*, std::unique_ptr<MachineFunction>> MachineFunctions; | ||||
/// Next unique number available for a MachineFunction. | /// Next unique number available for a MachineFunction. | ||||
unsigned NextFnNum = 0; | unsigned NextFnNum = 0; | ||||
const Function *LastRequest = nullptr; ///< Used for shortcut/cache. | const Function *LastRequest = nullptr; ///< Used for shortcut/cache. | ||||
MachineFunction *LastResult = nullptr; ///< Used for shortcut/cache. | MachineFunction *LastResult = nullptr; ///< Used for shortcut/cache. | ||||
public: | public: | ||||
static char ID; // Pass identification, replacement for typeid | |||||
explicit MachineModuleInfo(const LLVMTargetMachine *TM = nullptr); | explicit MachineModuleInfo(const LLVMTargetMachine *TM = nullptr); | ||||
~MachineModuleInfo() override; | |||||
// Initialization and Finalization | MachineModuleInfo(MachineModuleInfo &&MMII); | ||||
bool doInitialization(Module &) override; | MachineModuleInfo &operator=(MachineModuleInfo &&MMII) = default; | ||||
bool doFinalization(Module &) override; | |||||
~MachineModuleInfo(); | |||||
void initialize(); | |||||
void finalize(); | |||||
const LLVMTargetMachine &getTarget() const { return TM; } | const LLVMTargetMachine &getTarget() const { return TM; } | ||||
const MCContext &getContext() const { return Context; } | const MCContext &getContext() const { return Context; } | ||||
MCContext &getContext() { return Context; } | MCContext &getContext() { return Context; } | ||||
const Module *getModule() const { return TheModule; } | const Module *getModule() const { return TheModule; } | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | public: | ||||
/// Return array of personality functions ever seen. | /// Return array of personality functions ever seen. | ||||
const std::vector<const Function *>& getPersonalities() const { | const std::vector<const Function *>& getPersonalities() const { | ||||
return Personalities; | return Personalities; | ||||
} | } | ||||
/// \} | /// \} | ||||
}; // End class MachineModuleInfo | }; // End class MachineModuleInfo | ||||
class MachineModuleInfoWrapperPass : public ImmutablePass { | |||||
MachineModuleInfo MMI; | |||||
public: | |||||
static char ID; // Pass identification, replacement for typeid | |||||
explicit MachineModuleInfoWrapperPass(const LLVMTargetMachine *TM = nullptr); | |||||
explicit MachineModuleInfoWrapperPass(const MachineModuleInfo &MMI); | |||||
// Initialization and Finalization | |||||
bool doInitialization(Module &) override; | |||||
bool doFinalization(Module &) override; | |||||
MachineModuleInfo &getMMI() { return MMI; } | |||||
const MachineModuleInfo &getMMI() const { return MMI; } | |||||
}; | |||||
/// An analysis that produces \c MachineInfo for a module. | |||||
class MachineModuleAnalysis : public AnalysisInfoMixin<MachineModuleAnalysis> { | |||||
friend AnalysisInfoMixin<MachineModuleAnalysis>; | |||||
static AnalysisKey Key; | |||||
const LLVMTargetMachine *TM; | |||||
public: | |||||
/// Provide the result type for this analysis pass. | |||||
using Result = MachineModuleInfo; | |||||
MachineModuleAnalysis(const LLVMTargetMachine *TM) : TM(TM) {} | |||||
MaskRay: `{};` -> ` {}` | |||||
/// Run the analysis pass and produce machine module information. | |||||
MachineModuleInfo run(Module &M, ModuleAnalysisManager &); | |||||
}; | |||||
} // end namespace llvm | } // end namespace llvm | ||||
#endif // LLVM_CODEGEN_MACHINEMODULEINFO_H | #endif // LLVM_CODEGEN_MACHINEMODULEINFO_H |
{}; -> {}