Implement "general dynamic", "initial exec" and "local exec" TLS models for
[oota-llvm.git] / include / llvm / CodeGen / MachineModuleInfo.h
index a1c69083be1f88560894389a9bf0780e7a712fee..28201dcfdc69c9ef6d897fb5800e7cae38d6ca3c 100644 (file)
@@ -44,6 +44,7 @@ namespace llvm {
 class Constant;
 class DebugInfoDesc;
 class GlobalVariable;
+class MachineBasicBlock;
 class MachineFunction;
 class MachineMove;
 class Module;
@@ -948,6 +949,30 @@ public:
   void AddVariable(DebugVariable *V) { Variables.push_back(V); }
 };
 
+//===----------------------------------------------------------------------===//
+/// LandingPadInfo - This structure is used to retain landing pad info for
+/// the current function.
+///
+struct LandingPadInfo {
+  MachineBasicBlock *LandingPadBlock;   // Landing pad block.
+  unsigned BeginLabel;                  // Label prior to invoke.
+  unsigned EndLabel;                    // Label after invoke.
+  unsigned LandingPadLabel;             // Label at beginning of landing pad.
+  Function *Personality;                // Personality function.
+  std::vector<unsigned> TypeIds;        // List of type ids.
+  bool IsFilter;                        // Indicate if the landing pad is a
+                                        // throw filter.
+  
+  LandingPadInfo(MachineBasicBlock *MBB)
+  : LandingPadBlock(MBB)
+  , BeginLabel(0)
+  , EndLabel(0)
+  , LandingPadLabel(0)
+  , TypeIds()
+  , IsFilter(false)
+  {}
+};
+
 //===----------------------------------------------------------------------===//
 /// MachineModuleInfo - This class contains meta information specific to a
 /// module.  Queries can be made by different debugging and exception handling 
@@ -987,6 +1012,14 @@ private:
   // FrameMoves - List of moves done by a function's prolog.  Used to construct
   // frame maps by debug and exception handling consumers.
   std::vector<MachineMove> FrameMoves;
+  
+  // LandingPads - List of LandingPadInfo describing the landing pad information
+  // in the current function.
+  std::vector<LandingPadInfo> LandingPads;
+  
+  // TypeInfos - List of C++ TypeInfo used in the current function.
+  //
+  std::vector<GlobalVariable *> TypeInfos;
 
 public:
   MachineModuleInfo();
@@ -1025,6 +1058,10 @@ public:
   ///
   bool hasDebugInfo() const { return !CompileUnits.empty(); }
   
+  /// needsFrameInfo - Returns true if we need to gather callee-saved register
+  /// move info for the frame.
+  bool needsFrameInfo() const;
+  
   /// NextLabelID - Return the next unique label id.
   ///
   unsigned NextLabelID() {
@@ -1086,11 +1123,6 @@ public:
     return Lines;
   }
   
-  // FIXME: nuke this.
-  void ClearLineInfo() {
-    Lines.clear();
-  }
-  
   /// SetupCompileUnits - Set up the unique vector of compile units.
   ///
   void SetupCompileUnits(Module &M);
@@ -1148,6 +1180,58 @@ public:
   /// function's prologue.  Used to construct frame maps for debug and exception
   /// handling comsumers.
   std::vector<MachineMove> &getFrameMoves() { return FrameMoves; }
+  
+  //===-EH-----------------------------------------------------------------===//
+
+  /// getOrCreateLandingPadInfo - Find or create an LandingPadInfo for the
+  /// specified MachineBasicBlock.
+  LandingPadInfo &getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad);
+
+  /// addInvoke - Provide the begin and end labels of an invoke style call and
+  /// associate it with a try landing pad block.
+  void addInvoke(MachineBasicBlock *LandingPad, unsigned BeginLabel,
+                                                unsigned EndLabel);
+  
+  /// addLandingPad - Add a new panding pad.  Returns the label ID for the 
+  /// landing pad entry.
+  unsigned addLandingPad(MachineBasicBlock *LandingPad);
+  
+  /// addPersonality - Provide the personality function for the exception
+  /// information.
+  void addPersonality(MachineBasicBlock *LandingPad, Function *Personality);
+  
+  /// addCatchTypeInfo - Provide the catch typeinfo for a landing pad.
+  ///
+  void addCatchTypeInfo(MachineBasicBlock *LandingPad,
+                        std::vector<GlobalVariable *> &TyInfo);
+                        
+  /// setIsFilterLandingPad - Indicates that the landing pad is a throw filter.
+  ///
+  void setIsFilterLandingPad(MachineBasicBlock *LandingPad);
+                        
+  /// getTypeIDFor - Return the type id for the specified typeinfo.  This is 
+  /// function wide.
+  unsigned getTypeIDFor(GlobalVariable *TI);
+  
+  /// TidyLandingPads - Remap landing pad labels and remove any deleted landing
+  /// pads.
+  void TidyLandingPads();
+                        
+  /// getLandingPadInfos - Return a reference to the landing pad info for the
+  /// current function.
+  const std::vector<LandingPadInfo> &getLandingPads() const {
+    return LandingPads;
+  }
+  
+  /// getTypeInfos - Return a reference to the C++ typeinfo for the current
+  /// function.
+  const std::vector<GlobalVariable *> &getTypeInfos() const {
+    return TypeInfos;
+  }
+  
+  /// getPersonality - Return a personality function if available.  The presence
+  /// of one is required to emit exception handling info.
+  Function *getPersonality() const;
 
 }; // End class MachineModuleInfo