[llvm-commits] [llvm] r81940 - in /llvm/trunk: include/llvm/CodeGen/MachineFunction.h include/llvm/CodeGen/MachineModuleInfo.h lib/CodeGen/MachineFunction.cpp lib/CodeGen/MachineModuleInfo.cpp
Chris Lattner
sabre at nondot.org
Tue Sep 15 15:44:26 PDT 2009
Author: lattner
Date: Tue Sep 15 17:44:26 2009
New Revision: 81940
URL: http://llvm.org/viewvc/llvm-project?rev=81940&view=rev
Log:
add hooks to hang target-specific goop off MachineModuleInfo,
move MachineFunctionInfo virtual method out of line to give it
a home.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineFunction.h
llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
llvm/trunk/lib/CodeGen/MachineFunction.cpp
llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=81940&r1=81939&r2=81940&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Tue Sep 15 17:44:26 2009
@@ -63,7 +63,7 @@
/// of type are accessed/created with MF::getInfo and destroyed when the
/// MachineFunction is destroyed.
struct MachineFunctionInfo {
- virtual ~MachineFunctionInfo() {}
+ virtual ~MachineFunctionInfo();
};
class MachineFunction {
@@ -159,8 +159,8 @@
///
void setAlignment(unsigned A) { Alignment = A; }
- /// MachineFunctionInfo - Keep track of various per-function pieces of
- /// information for backends that would like to do so.
+ /// getInfo - Keep track of various per-function pieces of information for
+ /// backends that would like to do so.
///
template<typename Ty>
Ty *getInfo() {
Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=81940&r1=81939&r2=81940&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Tue Sep 15 17:44:26 2009
@@ -54,6 +54,17 @@
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 @@
/// 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 @@
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 @@
///
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);
Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=81940&r1=81939&r2=81940&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Tue Sep 15 17:44:26 2009
@@ -73,6 +73,9 @@
// MachineFunction implementation
//===---------------------------------------------------------------------===//
+// Out of line virtual method.
+MachineFunctionInfo::~MachineFunctionInfo() {}
+
void ilist_traits<MachineBasicBlock>::deleteNode(MachineBasicBlock *MBB) {
MBB->getParent()->DeleteMachineBasicBlock(MBB);
}
Modified: llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=81940&r1=81939&r2=81940&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp Tue Sep 15 17:44:26 2009
@@ -32,23 +32,23 @@
X("machinemoduleinfo", "Module Information");
char MachineModuleInfo::ID = 0;
+// Out of line virtual method.
+MachineModuleInfoImpl::~MachineModuleInfoImpl() {}
+
//===----------------------------------------------------------------------===//
MachineModuleInfo::MachineModuleInfo()
: ImmutablePass(&ID)
-, LabelIDList()
-, FrameMoves()
-, LandingPads()
-, Personalities()
+, TargetMMI(0)
, CallsEHReturn(0)
, CallsUnwindInit(0)
-, DbgInfoAvailable(false)
-{
+, DbgInfoAvailable(false) {
// Always emit some info, by default "no personality" info.
Personalities.push_back(NULL);
}
-MachineModuleInfo::~MachineModuleInfo() {
+MachineModuleInfo::~MachineModuleInfo() {
+ delete TargetMMI;
}
/// doInitialization - Initialize the state for a new module.
More information about the llvm-commits
mailing list