Refactor address attributes. Add base register to frame info.
authorJim Laskey <jlaskey@mac.com>
Tue, 28 Mar 2006 14:58:32 +0000 (14:58 +0000)
committerJim Laskey <jlaskey@mac.com>
Tue, 28 Mar 2006 14:58:32 +0000 (14:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27226 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/DwarfWriter.h
lib/CodeGen/DwarfWriter.cpp

index f7b5eaaf3b32703c204f8e26f55f78787f5531c6..7ac5aa6ba465ac6fc34fc30246fb91d997738a58 100644 (file)
@@ -41,6 +41,7 @@ class DIE;
 class DIEAbbrev;
 class GlobalVariableDesc;
 class MachineDebugInfo;
+class MachineLocation;
 class MachineFunction;
 class Module;
 class SubprogramDesc;
@@ -321,6 +322,10 @@ private:
   /// entry. 
   void AddSourceLine(DIE *Die, CompileUnitDesc *File, unsigned Line);
 
+  /// AddAddress - Add an address attribute to a die based on the location
+  /// provided.
+  void AddAddress(DIE *Die, unsigned Attribute, MachineLocation &Location);
+
   /// NewType - Create a new type DIE.
   ///
   DIE *NewType(DIE *Context, TypeDesc *TyDesc, CompileUnit *Unit);
index ab38f3158a56790e8665e3ed4ac8563a502530bf..43fbb3b902fe949a7f34e2ac249575fd539282e2 100644 (file)
@@ -1213,6 +1213,21 @@ void DwarfWriter::AddSourceLine(DIE *Die, CompileUnitDesc *File, unsigned Line)
   }
 }
 
+/// AddAddress - Add an address attribute to a die based on the location
+/// provided.
+void DwarfWriter::AddAddress(DIE *Die, unsigned Attribute,
+                             MachineLocation &Location) {
+  DIEBlock *Block = new DIEBlock();
+  if (Location.isRegister()) {
+    Block->AddUInt(DW_FORM_data1, DW_OP_reg0 + Location.getRegister());
+  } else {
+    Block->AddUInt(DW_FORM_data1, DW_OP_breg0 + Location.getRegister());
+    Block->AddUInt(DW_FORM_sdata, Location.getOffset());
+  }
+  Block->ComputeSize(*this);
+  Die->AddBlock(Attribute, 0, Block);
+}
+
 /// getDieMapSlotFor - Returns the debug information entry map slot for the
 /// specified debug descriptor.
 DIE *&DwarfWriter::getDieMapSlotFor(DebugInfoDesc *DD) {
@@ -1518,7 +1533,6 @@ DIE *DwarfWriter::NewSubprogram(SubprogramDesc *SPD) {
   return SubprogramDie;
 }
 
-
 /// NewScopeVariable - Create a new scope variable.
 ///
 DIE *DwarfWriter::NewScopeVariable(DebugVariable *DV, CompileUnit *Unit) {
@@ -1545,20 +1559,10 @@ DIE *DwarfWriter::NewScopeVariable(DebugVariable *DV, CompileUnit *Unit) {
   DIE *Type = NewType(Unit->getDie(), VD->getType(), Unit); 
   VariableDie->AddDIEntry(DW_AT_type, DW_FORM_ref4, Type);
   
-  // Get variable address.
+  // Add variable address.
   MachineLocation Location;
   Asm->TM.getRegisterInfo()->getLocation(*MF, DV->getFrameIndex(), Location);
-  
-  // Add computation for variable.
-  DIEBlock *Block = new DIEBlock();
-  if (Location.isRegister()) {
-    Block->AddUInt(DW_FORM_data1, DW_OP_reg0 + Location.getRegister());
-  } else {
-    Block->AddUInt(DW_FORM_data1, DW_OP_breg0 + Location.getRegister());
-    Block->AddUInt(DW_FORM_sdata, Location.getOffset());
-  }
-  Block->ComputeSize(*this);
-  VariableDie->AddBlock(DW_AT_location, 0, Block);
+  AddAddress(VariableDie, DW_AT_location, Location);
   
   return VariableDie;
 }
@@ -1628,6 +1632,8 @@ void DwarfWriter::ConstructRootScope(DebugScope *RootScope) {
                   DWLabel("func_begin", SubprogramCount));
   SPDie->AddLabel(DW_AT_high_pc, DW_FORM_addr,
                   DWLabel("func_end", SubprogramCount));
+  MachineLocation Location(Asm->TM.getRegisterInfo()->getFrameRegister(*MF));
+  AddAddress(SPDie, DW_AT_frame_base, Location);
                   
   ConstructScope(RootScope, SPDie, Unit);
 }