X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FCodeGen%2FMachineModuleInfo.h;h=b7b90198b1681c004e78eb2c00b4693d2e1ee6f3;hb=75549f4444cbb14e73c8f10ab90ec36c60413e8e;hp=75956058c457041816b488a4ebf2ea7e1f5aab2d;hpb=6268d69d7386bdd4ba1db5586feedeb0b7e6ddb6;p=oota-llvm.git diff --git a/include/llvm/CodeGen/MachineModuleInfo.h b/include/llvm/CodeGen/MachineModuleInfo.h index 75956058c45..b7b90198b16 100644 --- a/include/llvm/CodeGen/MachineModuleInfo.h +++ b/include/llvm/CodeGen/MachineModuleInfo.h @@ -37,6 +37,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/UniqueVector.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringMap.h" #include "llvm/CodeGen/MachineLocation.h" #include "llvm/GlobalValue.h" @@ -47,12 +48,25 @@ namespace llvm { //===----------------------------------------------------------------------===// // Forward declarations. class Constant; +class MDNode; class GlobalVariable; class MachineBasicBlock; 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. +class MachineModuleInfoImpl { +public: + virtual ~MachineModuleInfoImpl(); +}; + + //===----------------------------------------------------------------------===// /// LandingPadInfo - This structure is used to retain landing pad info for @@ -79,7 +93,11 @@ struct LandingPadInfo { /// schemes and reformated for specific use. /// class MachineModuleInfo : public ImmutablePass { -private: + /// ObjFileMMI - This is the object-file-format-specific implementation of + /// MachineModuleInfoImpl, which lets targets accumulate whatever info they + /// want. + MachineModuleInfoImpl *ObjFileMMI; + // 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 @@ -111,38 +129,59 @@ private: // common EH frames. std::vector Personalities; - // UsedFunctions - the functions in the llvm.used list in a more easily - // searchable format. + /// UsedFunctions - The functions in the @llvm.used list in a more easily + /// searchable format. This does not include the functions in + /// llvm.compiler.used. SmallPtrSet UsedFunctions; + /// UsedDbgLabels - labels are used by debug info entries. + SmallSet UsedDbgLabels; + bool CallsEHReturn; bool CallsUnwindInit; /// DbgInfoAvailable - True if debugging information is available /// in this module. bool DbgInfoAvailable; + public: static char ID; // Pass identification, replacement for typeid + typedef DenseMap > VariableDbgInfoMapTy; + VariableDbgInfoMapTy VariableDbgInfo; + 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); + void BeginFunction(MachineFunction *) {} /// EndFunction - Discard function meta information. /// void EndFunction(); + /// getInfo - Keep track of various per-function pieces of information for + /// backends that would like to do so. + /// + template + Ty &getObjFileInfo() { + if (ObjFileMMI == 0) + ObjFileMMI = new Ty(*this); + + assert((void*)dynamic_cast(ObjFileMMI) == (void*)ObjFileMMI && + "Invalid concrete type or multiple inheritence for getInfo"); + return *static_cast(ObjFileMMI); + } + + template + const Ty &getObjFileInfo() const { + return const_cast(this)->getObjFileInfo(); + } + /// AnalyzeModule - Scan the module for global debug information. /// void AnalyzeModule(Module &M); @@ -166,11 +205,6 @@ public: return ID; } - /// RecordSourceLine - Records location information and associates it with a - /// label. Returns a unique label ID used to generate a label and - /// provide correspondence to the source line list. - unsigned RecordSourceLine(unsigned Line, unsigned Column, unsigned Source); - /// InvalidateLabel - Inhibit use of the specified label # from /// MachineModuleInfo, for example because the code was deleted. void InvalidateLabel(unsigned LabelID) { @@ -195,6 +229,19 @@ public: return LabelID ? LabelIDList[LabelID - 1] : 0; } + /// isDbgLabelUsed - Return true if label with LabelID is used by + /// DwarfWriter. + bool isDbgLabelUsed(unsigned LabelID) { + return UsedDbgLabels.count(LabelID); + } + + /// RecordUsedDbgLabel - Mark label with LabelID as used. This is used + /// by DwarfWriter to inform DebugLabelFolder that certain labels are + /// not to be deleted. + void RecordUsedDbgLabel(unsigned LabelID) { + UsedDbgLabels.insert(LabelID); + } + /// getFrameMoves - Returns a reference to a list of moves done in the current /// function's prologue. Used to construct frame maps for debug and exception /// handling comsumers. @@ -228,9 +275,11 @@ public: return Personalities; } - // UsedFunctions - Return set of the functions in the llvm.used list. - const SmallPtrSet& getUsedFunctions() const { - return UsedFunctions; + /// isUsedFunction - Return true if the functions in the llvm.used list. This + /// does not return true for things in llvm.compiler.used unless they are also + /// in llvm.used. + bool isUsedFunction(const Function *F) { + return UsedFunctions.count(F); } /// addCatchTypeInfo - Provide the catch typeinfo for a landing pad. @@ -281,6 +330,15 @@ public: /// of one is required to emit exception handling info. Function *getPersonality() const; + /// setVariableDbgInfo - Collect information used to emit debugging information + /// of a variable. + void setVariableDbgInfo(MDNode *N, MDNode *L, unsigned S) { + if (N && L) + VariableDbgInfo[N] = std::make_pair(L, S); + } + + VariableDbgInfoMapTy &getVariableDbgInfo() { return VariableDbgInfo; } + }; // End class MachineModuleInfo } // End llvm namespace