aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/MachineModuleInfo.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-15 22:44:26 +0000
committerChris Lattner <sabre@nondot.org>2009-09-15 22:44:26 +0000
commita70e2e3d4831b8a39ea6bae5c62df29fa82a86f3 (patch)
tree05c14c52d3fe8ebd8caa27117542615e0f00a1ae /include/llvm/CodeGen/MachineModuleInfo.h
parent40fe16fadaccb86d9bff13ebe1c9a0cb20b2251b (diff)
add hooks to hang target-specific goop off MachineModuleInfo,
move MachineFunctionInfo virtual method out of line to give it a home. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81940 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineModuleInfo.h')
-rw-r--r--include/llvm/CodeGen/MachineModuleInfo.h41
1 files changed, 34 insertions, 7 deletions
diff --git a/include/llvm/CodeGen/MachineModuleInfo.h b/include/llvm/CodeGen/MachineModuleInfo.h
index 3618898a79..88aba7ee5e 100644
--- a/include/llvm/CodeGen/MachineModuleInfo.h
+++ b/include/llvm/CodeGen/MachineModuleInfo.h
@@ -54,6 +54,17 @@ class MachineFunction;
class Module;
class PointerType;
class StructType;
+
+
+/// MachineModuleInfoImpl - This class can be derived from and used by targets
+/// to hold private target-specific information for each Module. Objects of
+/// type are accessed/created with MMI::getInfo and destroyed when the
+/// MachineModuleInfo is destroyed.
+struct MachineModuleInfoImpl {
+ virtual ~MachineModuleInfoImpl();
+};
+
+
//===----------------------------------------------------------------------===//
/// LandingPadInfo - This structure is used to retain landing pad info for
@@ -80,7 +91,10 @@ struct LandingPadInfo {
/// schemes and reformated for specific use.
///
class MachineModuleInfo : public ImmutablePass {
-private:
+ /// TargetMMI - This is the target-specific implementation of
+ /// MachineModuleInfoImpl, which lets them accumulate whatever info they want.
+ MachineModuleInfoImpl *TargetMMI;
+
// LabelIDList - One entry per assigned label. Normally the entry is equal to
// the list index(+1). If the entry is zero then the label has been deleted.
// Any other value indicates the label has been deleted by is mapped to
@@ -132,14 +146,9 @@ public:
MachineModuleInfo();
~MachineModuleInfo();
- /// doInitialization - Initialize the state for a new module.
- ///
bool doInitialization();
-
- /// doFinalization - Tear down the state after completion of a module.
- ///
bool doFinalization();
-
+
/// BeginFunction - Begin gathering function meta information.
///
void BeginFunction(MachineFunction *MF);
@@ -148,6 +157,24 @@ public:
///
void EndFunction();
+ /// getInfo - Keep track of various per-function pieces of information for
+ /// backends that would like to do so.
+ ///
+ template<typename Ty>
+ Ty *getInfo() {
+ if (TargetMMI == 0)
+ TargetMMI = new Ty(*this);
+
+ assert((void*)dynamic_cast<Ty*>(TargetMMI) == (void*)TargetMMI &&
+ "Invalid concrete type or multiple inheritence for getInfo");
+ return static_cast<Ty*>(TargetMMI);
+ }
+
+ template<typename Ty>
+ const Ty *getInfo() const {
+ return const_cast<MachineModuleInfo*>(this)->getInfo<Ty>();
+ }
+
/// AnalyzeModule - Scan the module for global debug information.
///
void AnalyzeModule(Module &M);