[llvm-commits] CVS: llvm/include/llvm/CodeGen/DwarfWriter.h MachineDebugInfo.h MachineFrameInfo.h MachineLocation.h

Jim Laskey jlaskey at apple.com
Fri Apr 7 09:35:03 PDT 2006



Changes in directory llvm/include/llvm/CodeGen:

DwarfWriter.h updated: 1.32 -> 1.33
MachineDebugInfo.h updated: 1.32 -> 1.33
MachineFrameInfo.h updated: 1.16 -> 1.17
MachineLocation.h updated: 1.1 -> 1.2
---
Log message:

Foundation for call frame information.


---
Diffs of the changes:  (+100 -13)

 DwarfWriter.h      |   31 +++++++++++++++++++++++++------
 MachineDebugInfo.h |   24 +++++++++++++++++++-----
 MachineFrameInfo.h |   18 ++++++++++++++++++
 MachineLocation.h  |   40 ++++++++++++++++++++++++++++++++++++++--
 4 files changed, 100 insertions(+), 13 deletions(-)


Index: llvm/include/llvm/CodeGen/DwarfWriter.h
diff -u llvm/include/llvm/CodeGen/DwarfWriter.h:1.32 llvm/include/llvm/CodeGen/DwarfWriter.h:1.33
--- llvm/include/llvm/CodeGen/DwarfWriter.h:1.32	Tue Mar 28 08:58:32 2006
+++ llvm/include/llvm/CodeGen/DwarfWriter.h	Fri Apr  7 11:34:45 2006
@@ -41,10 +41,13 @@
 class DIEAbbrev;
 class GlobalVariableDesc;
 class MachineDebugInfo;
-class MachineLocation;
 class MachineFunction;
+class MachineLocation;
+class MachineMove;
 class Module;
+class MRegisterInfo;
 class SubprogramDesc;
+class TargetData;
 class Type;
 class TypeDesc;
   
@@ -81,6 +84,12 @@
   ///
   AsmPrinter *Asm;
   
+  /// TD - Target data.
+  const TargetData &TD;
+  
+  /// RI - Register Information.
+  const MRegisterInfo *RI;
+  
   /// M - Current module.
   ///
   Module *M;
@@ -324,7 +333,8 @@
 
   /// AddAddress - Add an address attribute to a die based on the location
   /// provided.
-  void AddAddress(DIE *Die, unsigned Attribute, MachineLocation &Location);
+  void AddAddress(DIE *Die, unsigned Attribute,
+                  const MachineLocation &Location);
 
   /// NewType - Create a new type DIE.
   ///
@@ -375,6 +385,11 @@
   ///
   void SizeAndOffsets();
   
+  /// EmitFrameMoves - Emit frame instructions to describe the layout of the
+  /// frame.
+  void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
+                      std::vector<MachineMove *> &Moves);
+
   /// EmitDebugInfo - Emit the debug info section.
   ///
   void EmitDebugInfo() const;
@@ -387,10 +402,14 @@
   ///
   void EmitDebugLines() const;
 
-  /// EmitDebugFrame - Emit info into a debug frame section.
+  /// EmitInitialDebugFrame - Emit common frame info into a debug frame section.
   ///
-  void EmitDebugFrame();
-  
+  void EmitInitialDebugFrame();
+    
+  /// EmitFunctionDebugFrame - Emit per function frame info into a debug frame
+  /// section.
+  void EmitFunctionDebugFrame();
+
   /// EmitDebugPubNames - Emit info into a debug pubnames section.
   ///
   void EmitDebugPubNames();
@@ -439,7 +458,7 @@
   
   /// SetDebugInfo - Set DebugInfo when it's known that pass manager has
   /// created it.  Set by the target AsmPrinter.
-  void SetDebugInfo(MachineDebugInfo *DI) { DebugInfo = DI; }
+  void SetDebugInfo(MachineDebugInfo *DI);
 
   //===--------------------------------------------------------------------===//
   // Main entry points.


Index: llvm/include/llvm/CodeGen/MachineDebugInfo.h
diff -u llvm/include/llvm/CodeGen/MachineDebugInfo.h:1.32 llvm/include/llvm/CodeGen/MachineDebugInfo.h:1.33
--- llvm/include/llvm/CodeGen/MachineDebugInfo.h:1.32	Sun Mar 26 16:45:20 2006
+++ llvm/include/llvm/CodeGen/MachineDebugInfo.h	Fri Apr  7 11:34:45 2006
@@ -47,6 +47,8 @@
 class Constant;
 class DebugInfoDesc;
 class GlobalVariable;
+class MachineFunction;
+class MachineMove;
 class Module;
 class PointerType;
 class StructType;
@@ -574,7 +576,7 @@
   void setName(const std::string &N)               { Name = N; }
   void setFile(CompileUnitDesc *U)                 { File = U; }
   void setLine(unsigned L)                         { Line = L; }
-  void setTypeDesc(TypeDesc *T)                    { TyDesc = T; }
+  void setType(TypeDesc *T)                        { TyDesc = T; }
   void setIsStatic(bool IS)                        { IsStatic = IS; }
   void setIsDefinition(bool ID)                    { IsDefinition = ID; }
 
@@ -940,6 +942,10 @@
   // RootScope - Top level scope for the current function.
   //
   DebugScope *RootScope;
+  
+  // FrameMoves - List of moves done by a function's prolog.  Used to construct
+  // frame maps by debug consumers.
+  std::vector<MachineMove *> FrameMoves;
 
 public:
   MachineDebugInfo();
@@ -953,6 +959,14 @@
   ///
   bool doFinalization();
   
+  /// BeginFunction - Begin gathering function debug information.
+  ///
+  void BeginFunction(MachineFunction *MF);
+  
+  /// EndFunction - Discard function debug information.
+  ///
+  void EndFunction();
+
   /// getDescFor - Convert a Value to a debug information descriptor.
   ///
   // FIXME - use new Value type when available.
@@ -1060,10 +1074,10 @@
   /// getOrCreateScope - Returns the scope associated with the given descriptor.
   ///
   DebugScope *getOrCreateScope(DebugInfoDesc *ScopeDesc);
-
-  /// ClearScopes - Delete the scope and variable info after a function is
-  /// completed.
-  void ClearScopes();
+  
+  /// getFrameMoves - Returns a reference to a list of moves done in the current
+  /// function's prologue.  Used to construct frame maps for debug comsumers.
+  std::vector<MachineMove *> &getFrameMoves() { return FrameMoves; }
 
 }; // End class MachineDebugInfo
 


Index: llvm/include/llvm/CodeGen/MachineFrameInfo.h
diff -u llvm/include/llvm/CodeGen/MachineFrameInfo.h:1.16 llvm/include/llvm/CodeGen/MachineFrameInfo.h:1.17
--- llvm/include/llvm/CodeGen/MachineFrameInfo.h:1.16	Tue Apr  4 12:39:56 2006
+++ llvm/include/llvm/CodeGen/MachineFrameInfo.h	Fri Apr  7 11:34:45 2006
@@ -44,6 +44,7 @@
 class TargetData;
 class TargetRegisterClass;
 class Type;
+class MachineDebugInfo;
 class MachineFunction;
 
 class MachineFrameInfo {
@@ -106,12 +107,21 @@
   /// insertion.
   ///
   unsigned MaxCallFrameSize;
+  
+  /// DebugInfo - This field is set (via setMachineDebugInfo) by a debug info
+  /// consumer (ex. DwarfWriter) to indicate that frame layout information
+  /// should be acquired.  Typically, it's the responsibility of the target's
+  /// MRegisterInfo prologue/epilogue emitting code to inform MachineDebugInfo
+  /// of frame layouts.
+  MachineDebugInfo *DebugInfo;
+  
 public:
   MachineFrameInfo() {
     NumFixedObjects = StackSize = MaxAlignment = 0;
     HasVarSizedObjects = false;
     HasCalls = false;
     MaxCallFrameSize = 0;
+    DebugInfo = 0;
   }
 
   /// hasStackObjects - Return true if there are any stack objects in this
@@ -230,6 +240,14 @@
     return Objects.size()-NumFixedObjects-1;
   }
 
+  /// getMachineDebugInfo - Used by a prologue/epilogue emitter (MRegisterInfo)
+  /// to provide frame layout information. 
+  MachineDebugInfo *getMachineDebugInfo() const { return DebugInfo; }
+
+  /// setMachineDebugInfo - Used by a debug consumer (DwarfWriter) to indicate
+  /// that frame layout information should be gathered.
+  void setMachineDebugInfo(MachineDebugInfo *DI) { DebugInfo = DI; }
+
   /// print - Used by the MachineFunction printer to print information about
   /// stack objects.  Implemented in MachineFunction.cpp
   ///


Index: llvm/include/llvm/CodeGen/MachineLocation.h
diff -u llvm/include/llvm/CodeGen/MachineLocation.h:1.1 llvm/include/llvm/CodeGen/MachineLocation.h:1.2
--- llvm/include/llvm/CodeGen/MachineLocation.h:1.1	Thu Mar 23 12:01:12 2006
+++ llvm/include/llvm/CodeGen/MachineLocation.h	Fri Apr  7 11:34:45 2006
@@ -8,7 +8,13 @@
 //===----------------------------------------------------------------------===//
 // The MachineLocation class is used to represent a simple location in a machine
 // frame.  Locations will be one of two forms; a register or an address formed
-// from a base address plus an offset.
+// from a base address plus an offset.  Register indirection can be specified by
+// using an offset of zero.
+//
+// The MachineMove class is used to represent abstract move operations in the 
+// prolog/epilog of a compiled function.  A collection of these objects can be
+// used by a debug consumer to track the location of values when unwinding stack
+// frames.
 //===----------------------------------------------------------------------===//
 
 
@@ -24,6 +30,11 @@
   int Offset;                           // Displacement if not register.
 
 public:
+  enum {
+    // The target register number for an abstract frame pointer. The value is
+    // an arbitrary value greater than MRegisterInfo::FirstVirtualRegister.
+    VirtualFP = ~0U
+  };
   MachineLocation()
   : IsRegister(false)
   , Register(0)
@@ -37,7 +48,7 @@
   MachineLocation(unsigned R, int O)
   : IsRegister(false)
   , Register(R)
-  , Offset(0)
+  , Offset(O)
   {}
   
   // Accessors
@@ -57,6 +68,31 @@
     Register = R;
     Offset = O;
   }
+
+#ifndef NDEBUG
+  void dump();
+#endif
+};
+
+class MachineMove {
+private:
+  unsigned LabelID;                     // Label ID number for post-instruction
+                                        // address when result of move takes
+                                        // effect.
+  const MachineLocation Destination;    // Move to location.
+  const MachineLocation Source;         // Move from location.
+  
+public:
+  MachineMove(unsigned ID, MachineLocation &D, MachineLocation &S)
+  : LabelID(ID)
+  , Destination(D)
+  , Source(S)
+  {}
+  
+  // Accessors
+  unsigned getLabelID()                   const { return LabelID; }
+  const MachineLocation &getDestination() const { return Destination; }
+  const MachineLocation &getSource()      const { return Source; }
 };
 
 } // End llvm namespace






More information about the llvm-commits mailing list