[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2007-01-24 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.112 -> 1.113
MachineDebugInfo.cpp updated: 1.69 -> 1.70
---
Log message:

Repair debug frames as a prelude to eh_frames.  Switched to using MachineMoves
by value so that clean up is less confusing (these vectors tend to be small.)


---
Diffs of the changes:  (+28 -16)

 DwarfWriter.cpp  |   43 ---
 MachineDebugInfo.cpp |1 -
 2 files changed, 28 insertions(+), 16 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.112 
llvm/lib/CodeGen/DwarfWriter.cpp:1.113
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.112  Wed Jan 24 07:12:32 2007
+++ llvm/lib/CodeGen/DwarfWriter.cppWed Jan 24 12:45:13 2007
@@ -2112,16 +2112,25 @@
   /// EmitFrameMoves - Emit frame instructions to describe the layout of the
   /// frame.
   void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
-   std::vector &Moves) {
+   std::vector &Moves) {
+int stackGrowth =
+Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
+  TargetFrameInfo::StackGrowsUp ?
+TAI->getAddressSize() : -TAI->getAddressSize();
+
 for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
-  MachineMove *Move = Moves[i];
-  unsigned LabelID = DebugInfo->MappedLabel(Move->getLabelID());
+  MachineMove &Move = Moves[i];
+  unsigned LabelID = Move.getLabelID();
   
-  // Throw out move if the label is invalid.
-  if (!LabelID) continue;
+  if (LabelID) {
+LabelID = DebugInfo->MappedLabel(LabelID);
   
-  const MachineLocation &Dst = Move->getDestination();
-  const MachineLocation &Src = Move->getSource();
+// Throw out move if the label is invalid.
+if (!LabelID) continue;
+  }
+  
+  const MachineLocation &Dst = Move.getDestination();
+  const MachineLocation &Src = Move.getSource();
   
   // Advance row if new location.
   if (BaseLabel && LabelID && BaseLabelID != LabelID) {
@@ -2134,11 +2143,6 @@
 BaseLabel = "loc";
   }
   
-  int stackGrowth =
-  Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
-TargetFrameInfo::StackGrowsUp ?
-  TAI->getAddressSize() : -TAI->getAddressSize();
-
   // If advancing cfa.
   if (Dst.isRegister() && Dst.getRegister() == MachineLocation::VirtualFP) 
{
 if (!Src.isRegister()) {
@@ -2159,6 +2163,16 @@
 } else {
   assert(0 && "Machine move no supported yet.");
 }
+  } else if (Src.isRegister() &&
+Src.getRegister() == MachineLocation::VirtualFP) {
+if (Dst.isRegister()) {
+  EmitInt8(DW_CFA_def_cfa_register);
+  EOL("DW_CFA_def_cfa_register");
+  EmitULEB128Bytes(RI->getDwarfRegNum(Dst.getRegister()));
+  EOL("Register");
+} else {
+  assert(0 && "Machine move no supported yet.");
+}
   } else {
 unsigned Reg = RI->getDwarfRegNum(Src.getRegister());
 int Offset = Dst.getOffset() / stackGrowth;
@@ -2433,10 +2447,9 @@
 EmitSLEB128Bytes(stackGrowth); EOL("CIE Data Alignment Factor");   
 EmitInt8(RI->getDwarfRegNum(RI->getRARegister())); EOL("CIE RA Column");
 
-std::vector Moves;
+std::vector Moves;
 RI->getInitialFrameState(Moves);
 EmitFrameMoves(NULL, 0, Moves);
-for (unsigned i = 0, N = Moves.size(); i < N; ++i) delete Moves[i];
 
 Asm->EmitAlignment(2);
 EmitLabel("frame_common_end", 0);
@@ -2467,7 +2480,7 @@
"func_begin", SubprogramCount);
 EOL("FDE address range");
 
-std::vector &Moves = DebugInfo->getFrameMoves();
+std::vector &Moves = DebugInfo->getFrameMoves();
 
 EmitFrameMoves("func_begin", SubprogramCount, Moves);
 


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.69 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.70
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.69  Thu Jan 11 22:24:45 2007
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Wed Jan 24 12:45:13 2007
@@ -1505,7 +1505,6 @@
   }
   
   // Clean up frame info.
-  for (unsigned i = 0, N = FrameMoves.size(); i < N; ++i) delete FrameMoves[i];
   FrameMoves.clear();
 }
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-10-24 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.84 -> 1.85
MachineDebugInfo.cpp updated: 1.52 -> 1.53
---
Log message:

Tighter data structure for deleted debug labels.

---
Diffs of the changes:  (+20 -4)

 DwarfWriter.cpp  |3 +--
 MachineDebugInfo.cpp |   21 +++--
 2 files changed, 20 insertions(+), 4 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.84 
llvm/lib/CodeGen/DwarfWriter.cpp:1.85
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.84   Mon Oct 23 09:56:37 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppTue Oct 24 06:50:43 2006
@@ -2207,8 +2207,7 @@
   const SourceLineInfo &LineInfo = LineInfos[i];
   unsigned LabelID = LineInfo.getLabelID();
   
-  // Throw out line info if label is invalid.
-  if (!DebugInfo->isLabelValid(LabelID)) continue;
+  // Source line labels are validated at the MachineDebugInfo level.
   
   if (DwarfVerbose) {
 unsigned SourceID = LineInfo.getSourceID();


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.52 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.53
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.52  Mon Oct 23 09:56:37 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Tue Oct 24 06:50:43 2006
@@ -1544,16 +1544,33 @@
   return ID;
 }
 
+static bool LabelUIDComparison(const SourceLineInfo &LI, unsigned UID) {
+  return LI.getLabelID() < UID;
+}
+ 
 /// InvalidateLabel - Inhibit use of the specified label # from
 /// MachineDebugInfo, for example because the code was deleted.
 void MachineDebugInfo::InvalidateLabel(unsigned LabelID) {
-  DeletedLabelIDs.insert(LabelID);
+  // Check source line list first.  SourceLineInfo is sorted by LabelID.
+  std::vector::iterator I =
+std::lower_bound(Lines.begin(), Lines.end(), LabelID, LabelUIDComparison);
+  if (I != Lines.end() && I->getLabelID() == LabelID) {
+Lines.erase(I);
+return;
+  }
+  
+  // Otherwise add for use by isLabelValid.
+  std::vector::iterator J =
+std::lower_bound(DeletedLabelIDs.begin(), DeletedLabelIDs.end(), LabelID);
+  DeletedLabelIDs.insert(J, LabelID);
 }
 
 /// isLabelValid - Check to make sure the label is still valid before
 /// attempting to use.
 bool MachineDebugInfo::isLabelValid(unsigned LabelID) {
-  return DeletedLabelIDs.find(LabelID) == DeletedLabelIDs.end();
+  std::vector::iterator I =
+std::lower_bound(DeletedLabelIDs.begin(), DeletedLabelIDs.end(), LabelID);
+  return I != DeletedLabelIDs.end() && *I == LabelID;
 }
 
 /// RecordSource - Register a source file with debug info. Returns an source



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-10-17 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.82 -> 1.83
MachineDebugInfo.cpp updated: 1.48 -> 1.49
---
Log message:

Do not leak all of the SourceLineInfo objects.  Do not bother mallocing each
one separately.


---
Diffs of the changes:  (+15 -14)

 DwarfWriter.cpp  |   27 ++-
 MachineDebugInfo.cpp |2 +-
 2 files changed, 15 insertions(+), 14 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.82 
llvm/lib/CodeGen/DwarfWriter.cpp:1.83
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.82   Tue Oct 17 12:17:24 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppTue Oct 17 17:06:46 2006
@@ -2178,7 +2178,7 @@
   // A sequence for each text section.
   for (unsigned j = 0, M = SectionSourceLines.size(); j < M; ++j) {
 // Isolate current sections line info.
-const std::vector &LineInfos = SectionSourceLines[j];
+const std::vector &LineInfos = SectionSourceLines[j];
 
 if (DwarfVerbose) {
   O << "\t"
@@ -2193,40 +2193,40 @@
 
 // Construct rows of the address, source, line, column matrix.
 for (unsigned i = 0, N = LineInfos.size(); i < N; ++i) {
-  SourceLineInfo *LineInfo = LineInfos[i];
+  const SourceLineInfo &LineInfo = LineInfos[i];
   
   if (DwarfVerbose) {
-unsigned SourceID = LineInfo->getSourceID();
+unsigned SourceID = LineInfo.getSourceID();
 const SourceFileInfo &SourceFile = SourceFiles[SourceID];
 unsigned DirectoryID = SourceFile.getDirectoryID();
 O << "\t"
   << TAI->getCommentString() << " "
   << Directories[DirectoryID]
   << SourceFile.getName() << ":"
-  << LineInfo->getLine() << "\n"; 
+  << LineInfo.getLine() << "\n"; 
   }
 
   // Define the line address.
   EmitInt8(0); EOL("Extended Op");
   EmitInt8(4 + 1); EOL("Op size");
   EmitInt8(DW_LNE_set_address); EOL("DW_LNE_set_address");
-  EmitReference("loc",  LineInfo->getLabelID()); EOL("Location label");
+  EmitReference("loc",  LineInfo.getLabelID()); EOL("Location label");
   
   // If change of source, then switch to the new source.
-  if (Source != LineInfo->getSourceID()) {
-Source = LineInfo->getSourceID();
+  if (Source != LineInfo.getSourceID()) {
+Source = LineInfo.getSourceID();
 EmitInt8(DW_LNS_set_file); EOL("DW_LNS_set_file");
 EmitULEB128Bytes(Source); EOL("New Source");
   }
   
   // If change of line.
-  if (Line != LineInfo->getLine()) {
+  if (Line != LineInfo.getLine()) {
 // Determine offset.
-int Offset = LineInfo->getLine() - Line;
+int Offset = LineInfo.getLine() - Line;
 int Delta = Offset - MinLineDelta;
 
 // Update line.
-Line = LineInfo->getLine();
+Line = LineInfo.getLine();
 
 // If delta is small enough and in range...
 if (Delta >= 0 && Delta < (MaxLineDelta - 1)) {
@@ -2635,13 +2635,13 @@
   EmitLabel("func_end", SubprogramCount);
 
   // Get function line info.
-  std::vector &LineInfos = DebugInfo->getSourceLines();
+  const std::vector &LineInfos = DebugInfo->getSourceLines();
 
   if (!LineInfos.empty()) {
 // Get section line info.
 unsigned ID = SectionMap.insert(Asm->CurrentSection);
 if (SectionSourceLines.size() < ID) SectionSourceLines.resize(ID);
-std::vector &SectionLineInfos =SectionSourceLines[ID-1];
+std::vector &SectionLineInfos = SectionSourceLines[ID-1];
 // Append the function info to section info.
 SectionLineInfos.insert(SectionLineInfos.end(),
 LineInfos.begin(), LineInfos.end());
@@ -2654,7 +2654,8 @@
   EmitFunctionDebugFrame();
   
   // Reset the line numbers for the next function.
-  LineInfos.clear();
+  // FIXME: move this to release memory of the debuginfo object.
+  DebugInfo->ClearLineInfo();
 
   // Clear function debug information.
   DebugInfo->EndFunction();


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.48 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.49
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.48  Fri Oct 13 08:01:34 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Tue Oct 17 17:06:46 2006
@@ -1538,7 +1538,7 @@
 unsigned MachineDebugInfo::RecordLabel(unsigned Line, unsigned Column,
unsigned Source) {
   unsigned ID = NextLabelID();
-  Lines.push_back(new SourceLineInfo(Line, Column, Source, ID));
+  Lines.push_back(SourceLineInfo(Line, Column, Source, ID));
   return ID;
 }
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-07-13 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.68 -> 1.69
MachineDebugInfo.cpp updated: 1.45 -> 1.46
---
Log message:

Fixed a bug handling void function types.
Requires rebuild of llvm-gcc4 (touch llvm-debug.cpp.)



---
Diffs of the changes:  (+21 -12)

 DwarfWriter.cpp  |2 +-
 MachineDebugInfo.cpp |   31 ---
 2 files changed, 21 insertions(+), 12 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.68 
llvm/lib/CodeGen/DwarfWriter.cpp:1.69
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.68   Tue Jul 11 10:58:09 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppThu Jul 13 10:27:42 2006
@@ -1413,7 +1413,7 @@
   Ty->AddUInt(DW_AT_prototyped, DW_FORM_flag, 1);
   // Add return type.
   Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4,
- NewType(Context, cast(Elements[0]), Unit));
+ NewType(Context, dyn_cast(Elements[0]), Unit));
   
   // Add arguments.
   for(unsigned i = 1, N = Elements.size(); i < N; ++i) {


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.45 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.46
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.45  Tue Jul 11 10:58:09 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Thu Jul 13 10:27:42 2006
@@ -223,16 +223,21 @@
 Field = getGlobalVariable(C);
   }
   virtual void Apply(std::vector &Field) {
+Field.resize(0);
 Constant *C = CI->getOperand(I++);
 GlobalVariable *GV = getGlobalVariable(C);
-Field.resize(0);
-// Have to be able to deal with the empty array case (zero initializer)
-if (!GV->hasInitializer()) return;
-if (ConstantArray *CA = dyn_cast(GV->getInitializer())) {
-  for (unsigned i = 0, N = CA->getNumOperands(); i < N; ++i) {
-GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i));
-DebugInfoDesc *DE = DR.Deserialize(GVE);
-Field.push_back(DE);
+if (GV->hasInitializer()) {
+  if (ConstantArray *CA = dyn_cast(GV->getInitializer())) {
+for (unsigned i = 0, N = CA->getNumOperands(); i < N; ++i) {
+  GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i));
+  DebugInfoDesc *DE = DR.Deserialize(GVE);
+  Field.push_back(DE);
+}
+  } else if (GV->getInitializer()->isNullValue()) {
+if (const ArrayType *T =
+dyn_cast(GV->getType()->getElementType())) {
+  Field.resize(T->getNumElements());
+}
   }
 }
   }
@@ -305,9 +310,13 @@
 std::vector ArrayElements;
 
 for (unsigned i = 0, N = Field.size(); i < N; ++i) {
-  GlobalVariable *GVE = SR.Serialize(Field[i]);
-  Constant *CE = ConstantExpr::getCast(GVE, EmptyTy);
-  ArrayElements.push_back(cast(CE));
+  if (DebugInfoDesc *Element = Field[i]) {
+GlobalVariable *GVE = SR.Serialize(Element);
+Constant *CE = ConstantExpr::getCast(GVE, EmptyTy);
+ArrayElements.push_back(cast(CE));
+  } else {
+ArrayElements.push_back(ConstantPointerNull::get(EmptyTy));
+  }
 }
 
 Constant *CA = ConstantArray::get(AT, ArrayElements);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-07-11 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.67 -> 1.68
MachineDebugInfo.cpp updated: 1.44 -> 1.45
---
Log message:

1. Support for c++ mangled names.
2. Support for private/protected class members.


---
Diffs of the changes:  (+14 -1)

 DwarfWriter.cpp  |6 ++
 MachineDebugInfo.cpp |9 -
 2 files changed, 14 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.67 
llvm/lib/CodeGen/DwarfWriter.cpp:1.68
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.67   Fri Jun 23 07:51:53 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppTue Jul 11 10:58:09 2006
@@ -1383,6 +1383,12 @@
 Block->AddUInt(DW_FORM_udata, FieldOffset >> 3);
 Block->ComputeSize(*this);
 Member->AddBlock(DW_AT_data_member_location, 0, Block);
+
+if (MemberDesc->isProtected()) {
+  Member->AddUInt(DW_AT_accessibility, 0, DW_ACCESS_protected);
+} else if (MemberDesc->isPrivate()) {
+  Member->AddUInt(DW_AT_accessibility, 0, DW_ACCESS_private);
+}
 
 Ty->AddChild(Member);
   }


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.44 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.45
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.44  Tue Jun 20 14:41:06 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Tue Jul 11 10:58:09 2006
@@ -671,6 +671,7 @@
 , Size(0)
 , Align(0)
 , Offset(0)
+, Flags(0)
 {}
 
 /// ApplyToFields - Target the visitor to the fields of the TypeDesc.
@@ -685,6 +686,7 @@
   Visitor->Apply(Size);
   Visitor->Apply(Align);
   Visitor->Apply(Offset);
+  if (getVersion() > LLVMDebugVersion4) Visitor->Apply(Flags);
 }
 
 /// getDescString - Return a string used to compose global names and labels.
@@ -710,7 +712,8 @@
 << "Line(" << Line << "), "
 << "Size(" << Size << "), "
 << "Align(" << Align << "), "
-<< "Offset(" << Offset << ")\n";
+<< "Offset(" << Offset << "), "
+<< "Flags(" << Flags << ")\n";
 }
 #endif
 
@@ -1029,6 +1032,7 @@
 : AnchoredDesc(T)
 , Context(0)
 , Name("")
+, DisplayName("")
 , File(NULL)
 , Line(0)
 , TyDesc(NULL)
@@ -1043,6 +1047,7 @@
 
   Visitor->Apply(Context);
   Visitor->Apply(Name);
+  if (getVersion() > LLVMDebugVersion4) Visitor->Apply(DisplayName);
   Visitor->Apply(File);
   Visitor->Apply(Line);
   Visitor->Apply(TyDesc);
@@ -1096,6 +1101,7 @@
 << "Tag(" << getTag() << "), "
 << "Anchor(" << getAnchor() << "), "
 << "Name(\"" << getName() << "\"), "
+<< "DisplayName(\"" << getDisplayName() << "\"), "
 << "File(" << getFile() << "),"
 << "Line(" << getLine() << "),"
 << "Type(\"" << getType() << "\"), "
@@ -1148,6 +1154,7 @@
 << "Tag(" << getTag() << "), "
 << "Anchor(" << getAnchor() << "), "
 << "Name(\"" << getName() << "\"), "
+<< "DisplayName(\"" << getDisplayName() << "\"), "
 << "File(" << getFile() << "),"
 << "Line(" << getLine() << "),"
 << "Type(\"" << getType() << "\"), "



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-06-20 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.65 -> 1.66
MachineDebugInfo.cpp updated: 1.43 -> 1.44
---
Log message:

Add support for function types.


---
Diffs of the changes:  (+20 -1)

 DwarfWriter.cpp  |   17 +
 MachineDebugInfo.cpp |4 +++-
 2 files changed, 20 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.65 
llvm/lib/CodeGen/DwarfWriter.cpp:1.66
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.65   Mon Jun 19 14:49:42 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppTue Jun 20 14:41:06 2006
@@ -1402,6 +1402,23 @@
 
   break;
 }
+case DW_TAG_subroutine_type: {
+  // Add prototype flag.
+  Ty->AddUInt(DW_AT_prototyped, DW_FORM_flag, 1);
+  // Add return type.
+  Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4,
+ NewType(Context, cast(Elements[0]), Unit));
+  
+  // Add arguments.
+  for(unsigned i = 1, N = Elements.size(); i < N; ++i) {
+DIE *Arg = new DIE(DW_TAG_formal_parameter);
+Arg->AddDIEntry(DW_AT_type, DW_FORM_ref4,
+NewType(Context, cast(Elements[i]), Unit));
+Ty->AddChild(Arg);
+  }
+  
+  break;
+}
 default: break;
 }
   }


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.43 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.44
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.43  Mon Jun 19 07:54:15 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Tue Jun 20 14:41:06 2006
@@ -493,7 +493,8 @@
   case DW_TAG_structure_type:
   case DW_TAG_union_type:
   case DW_TAG_enumeration_type:
-  case DW_TAG_vector_type:  return new CompositeTypeDesc(Tag);
+  case DW_TAG_vector_type:
+  case DW_TAG_subroutine_type:  return new CompositeTypeDesc(Tag);
   case DW_TAG_subrange_type:return new SubrangeDesc();
   case DW_TAG_enumerator:   return new EnumeratorDesc();
   case DW_TAG_return_variable:
@@ -831,6 +832,7 @@
   case DW_TAG_union_type:
   case DW_TAG_enumeration_type:
   case DW_TAG_vector_type:
+  case DW_TAG_subroutine_type:
 return true;
   default: break;
   }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-06-16 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.62 -> 1.63
MachineDebugInfo.cpp updated: 1.41 -> 1.42
---
Log message:

1. Revise vector debug support.

2. Update docs for vector debug support and new version control.

3. Simplify serialization of DebugDescInfo subclasses.


---
Diffs of the changes:  (+24 -35)

 DwarfWriter.cpp  |   16 +---
 MachineDebugInfo.cpp |   43 +++
 2 files changed, 24 insertions(+), 35 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.62 
llvm/lib/CodeGen/DwarfWriter.cpp:1.63
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.62   Thu Jun 15 15:51:43 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppFri Jun 16 08:14:03 2006
@@ -1276,11 +1276,18 @@
  NewType(Context, FromTy, Unit));
 }
   } else if (CompositeTypeDesc *CompTy = dyn_cast(TyDesc)) {
+// Fetch tag
+unsigned Tag = CompTy->getTag();
+
 // Create specific DIE.
-Slot = Ty = new DIE(CompTy->getTag());
+Slot = Ty = Tag == DW_TAG_vector_type ? new DIE(DW_TAG_array_type) :
+new DIE(Tag);
+
 std::vector &Elements = CompTy->getElements();
 
-switch (CompTy->getTag()) {
+switch (Tag) {
+case DW_TAG_vector_type: Ty->AddUInt(DW_AT_GNU_vector, DW_FORM_flag, 1);
+  // Fall thru
 case DW_TAG_array_type: {
   // Add element type.
   if (TypeDesc *FromTy = CompTy->getFromType()) {
@@ -1288,11 +1295,6 @@
NewType(Context, FromTy, Unit));
   }
   
-  // check for vector type
-  if (CompTy->isVector()) {
-Ty->AddUInt(DW_AT_GNU_vector, DW_FORM_flag, 1);
-  }
-  
   // Don't emit size attribute.
   Size = 0;
   


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.41 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.42
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.41  Thu Jun 15 15:51:43 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Fri Jun 16 08:14:03 2006
@@ -459,7 +459,8 @@
 /// GlobalVariable.   Return DIIValid if operand is not an unsigned int. 
 unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) {
   ConstantUInt *C = getUIntOperand(GV, 0);
-  return C ? ((unsigned)C->getValue() & tag_mask) : (unsigned)DW_TAG_invalid;
+  return C ? ((unsigned)C->getValue() & ~LLVMDebugVersionMask) :
+ (unsigned)DW_TAG_invalid;
 }
 
 /// VersionFromGlobal - Returns the version number from a debug info
@@ -467,7 +468,7 @@
 /// int.
 unsigned  DebugInfoDesc::VersionFromGlobal(GlobalVariable *GV) {
   ConstantUInt *C = getUIntOperand(GV, 0);
-  return C ? ((unsigned)C->getValue() >> version_shift) :
+  return C ? ((unsigned)C->getValue() & LLVMDebugVersionMask) :
  (unsigned)DW_TAG_invalid;
 }
 
@@ -491,7 +492,8 @@
   case DW_TAG_array_type:
   case DW_TAG_structure_type:
   case DW_TAG_union_type:
-  case DW_TAG_enumeration_type: return new CompositeTypeDesc(Tag);
+  case DW_TAG_enumeration_type:
+  case DW_TAG_vector_type:  return new CompositeTypeDesc(Tag);
   case DW_TAG_subrange_type:return new SubrangeDesc();
   case DW_TAG_enumerator:   return new EnumeratorDesc();
   case DW_TAG_return_variable:
@@ -590,9 +592,7 @@
 void AnchoredDesc::ApplyToFields(DIVisitor *Visitor) {
   DebugInfoDesc::ApplyToFields(Visitor);
 
-  DebugInfoDesc *Tmp = Anchor;
-  Visitor->Apply(Tmp);
-  Anchor = (AnchorDesc*)Tmp;
+  Visitor->Apply(Anchor);
 }
 
 
//===--===//
@@ -673,9 +673,7 @@
   
   Visitor->Apply(Context);
   Visitor->Apply(Name);
-  DebugInfoDesc* Tmp = File;
-  Visitor->Apply(Tmp);
-  File = (CompileUnitDesc*)Tmp;
+  Visitor->Apply(File);
   Visitor->Apply(Line);
   Visitor->Apply(Size);
   Visitor->Apply(Align);
@@ -782,9 +780,7 @@
 void DerivedTypeDesc::ApplyToFields(DIVisitor *Visitor) {
   TypeDesc::ApplyToFields(Visitor);
   
-  DebugInfoDesc* Tmp = FromType;
-  Visitor->Apply(Tmp);
-  FromType = (TypeDesc*)Tmp;
+  Visitor->Apply(FromType);
 }
 
 /// getDescString - Return a string used to compose global names and labels.
@@ -817,7 +813,6 @@
 
 CompositeTypeDesc::CompositeTypeDesc(unsigned T)
 : DerivedTypeDesc(T)
-, IsVector(false)
 , Elements()
 {}
   
@@ -829,6 +824,7 @@
   case DW_TAG_structure_type:
   case DW_TAG_union_type:
   case DW_TAG_enumeration_type:
+  case DW_TAG_vector_type:
 return true;
   default: break;
   }
@@ -838,9 +834,8 @@
 /// ApplyToFields - Target the visitor to the fields of the CompositeTypeDesc.
 ///
 void CompositeTypeDesc::ApplyToFields(DIVisitor *Visitor) {
-  DerivedTypeDesc::ApplyToFields(Visitor);
-  
-  Visitor->Apply(IsVector);
+  DerivedTypeDesc::ApplyToFields(Visitor);  
+
   Visitor->Apply(Elements);
 }
 
@@ -990,13 +985,9 @@
   
   Visitor->Apply(Context);
   Visitor->Apply(Name);
-  DebugInfoDesc* Tmp1 = File;
-  Visitor->Apply(Tmp1);
-  File = (CompileU

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-06-15 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.61 -> 1.62
MachineDebugInfo.cpp updated: 1.40 -> 1.41
---
Log message:

1. Support standard dwarf format (was bootstrapping in Apple format.)

2. Add vector support.


---
Diffs of the changes:  (+14 -4)

 DwarfWriter.cpp  |   16 
 MachineDebugInfo.cpp |2 ++
 2 files changed, 14 insertions(+), 4 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.61 
llvm/lib/CodeGen/DwarfWriter.cpp:1.62
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.61   Wed Jun 14 06:35:03 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppThu Jun 15 15:51:43 2006
@@ -1265,7 +1265,7 @@
 // Fundamental types like int, float, bool
 Slot = Ty = new DIE(DW_TAG_base_type);
 unsigned Encoding = BasicTy->getEncoding();
-Ty->AddUInt  (DW_AT_encoding,  DW_FORM_data1, Encoding);
+Ty->AddUInt(DW_AT_encoding,  DW_FORM_data1, Encoding);
   } else if (DerivedTypeDesc *DerivedTy = dyn_cast(TyDesc)) {
 // Create specific DIE.
 Slot = Ty = new DIE(DerivedTy->getTag());
@@ -1287,6 +1287,12 @@
 Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4,
NewType(Context, FromTy, Unit));
   }
+  
+  // check for vector type
+  if (CompTy->isVector()) {
+Ty->AddUInt(DW_AT_GNU_vector, DW_FORM_flag, 1);
+  }
+  
   // Don't emit size attribute.
   Size = 0;
   
@@ -1419,7 +1425,8 @@
  unsigned ID) {
   // Construct debug information entry.
   DIE *Die = new DIE(DW_TAG_compile_unit);
-  Die->AddLabel (DW_AT_stmt_list, DW_FORM_data4,  DWLabel("line", 0));
+  Die->AddDelta (DW_AT_stmt_list, DW_FORM_data4,  DWLabel("line", 0),
+  DWLabel("section_line", 0));
   Die->AddLabel (DW_AT_high_pc,   DW_FORM_addr,   DWLabel("text_end", 0));
   Die->AddLabel (DW_AT_low_pc,DW_FORM_addr,   DWLabel("text_begin", 0));
   Die->AddString(DW_AT_producer,  DW_FORM_string, UnitDesc->getProducer());
@@ -1842,7 +1849,7 @@
 int stackGrowth =
 Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
   TargetFrameInfo::StackGrowsUp ?
-AddressSize : -AddressSize;
+AddressSize : -AddressSize;
 
 EmitULEB128Bytes(Src.getOffset() / stackGrowth);
 EOL("Offset");
@@ -1875,7 +1882,8 @@
  
   EmitInt32(ContentSize);  EOL("Length of Compilation Unit Info");
   EmitInt16(DWARF_VERSION); EOL("DWARF version number");
-  EmitReference("abbrev_begin", 0); EOL("Offset Into Abbrev. Section");
+  EmitDifference("abbrev_begin", 0, "section_abbrev", 0);
+  EOL("Offset Into Abbrev. Section");
   EmitInt8(AddressSize); EOL("Address Size (in bytes)");
 
   EmitDIE(Die);


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.40 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.41
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.40  Wed Jun 14 09:45:39 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Thu Jun 15 15:51:43 2006
@@ -817,6 +817,7 @@
 
 CompositeTypeDesc::CompositeTypeDesc(unsigned T)
 : DerivedTypeDesc(T)
+, IsVector(false)
 , Elements()
 {}
   
@@ -839,6 +840,7 @@
 void CompositeTypeDesc::ApplyToFields(DIVisitor *Visitor) {
   DerivedTypeDesc::ApplyToFields(Visitor);
   
+  Visitor->Apply(IsVector);
   Visitor->Apply(Elements);
 }
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-06-14 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.60 -> 1.61
MachineDebugInfo.cpp updated: 1.38 -> 1.39
---
Log message:

Place dwarf headers at earliest possible point.  Well behaved when skipping
functions.


---
Diffs of the changes:  (+57 -51)

 DwarfWriter.cpp  |  100 +++
 MachineDebugInfo.cpp |8 ++--
 2 files changed, 57 insertions(+), 51 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.60 
llvm/lib/CodeGen/DwarfWriter.cpp:1.61
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.60   Fri May 12 01:33:48 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppWed Jun 14 06:35:03 2006
@@ -1646,7 +1646,11 @@
 /// EmitInitial - Emit initial Dwarf declarations.  This is necessary for cc
 /// tools to recognize the object file contains Dwarf information.
 ///
-void DwarfWriter::EmitInitial() const {
+void DwarfWriter::EmitInitial() {
+  // Check to see if we already emitted intial headers.
+  if (didInitial) return;
+  didInitial = true;
+  
   // Dwarf sections base addresses.
   Asm->SwitchToDataSection(DwarfFrameSection, 0);
   EmitLabel("section_frame", 0);
@@ -1676,6 +1680,9 @@
   EmitLabel("text_begin", 0);
   Asm->SwitchToDataSection(DataSection, 0);
   EmitLabel("data_begin", 0);
+  
+  // Emit common frame information.
+  EmitInitialDebugFrame();
 }
 
 /// EmitDIE - Recusively Emits a debug information entry.
@@ -2286,35 +2293,6 @@
   }
 }
 
-/// ShouldEmitDwarf - Determine if Dwarf declarations should be made.
-///
-bool DwarfWriter::ShouldEmitDwarf() {
-  // Check if debug info is present.
-  if (!DebugInfo || !DebugInfo->hasInfo()) return false;
-  
-  // Make sure initial declarations are made.
-  if (!didInitial) {
-EmitInitial();
-  
-// Emit common frame information.
-EmitInitialDebugFrame();
-  
-// Create all the compile unit DIEs.
-ConstructCompileUnitDIEs();
-
-// Create DIEs for each of the externally visible global variables.
-ConstructGlobalDIEs();
-
-// Create DIEs for each of the externally visible subprograms.
-ConstructSubprogramDIEs();
-
-didInitial = true;
-  }
-  
-  // Okay to emit.
-  return true;
-}
-
 
//===--===//
 // Main entry points.
 //
@@ -2328,6 +2306,8 @@
 , MF(NULL)
 , DebugInfo(NULL)
 , didInitial(false)
+, shouldEmit(false)
+, IsNormalText(false)
 , SubprogramCount(0)
 , CompileUnits()
 , Abbreviations()
@@ -2363,7 +2343,23 @@
 /// SetDebugInfo - Set DebugInfo when it's known that pass manager has
 /// created it.  Set by the target AsmPrinter.
 void DwarfWriter::SetDebugInfo(MachineDebugInfo *DI) {
-  DebugInfo = DI;
+  // Make sure initial declarations are made.
+  if (!DebugInfo && DI->hasInfo()) {
+DebugInfo = DI;
+shouldEmit = true;
+
+// Emit initial sections
+EmitInitial();
+  
+// Create all the compile unit DIEs.
+ConstructCompileUnitDIEs();
+
+// Create DIEs for each of the externally visible global variables.
+ConstructGlobalDIEs();
+
+// Create DIEs for each of the externally visible subprograms.
+ConstructSubprogramDIEs();
+  }
 }
 
 /// BeginModule - Emit all Dwarf sections that should come prior to the 
content.
@@ -2420,17 +2416,24 @@
 
 /// BeginFunction - Gather pre-function debug information.  Assumes being 
 /// emitted immediately after the function entry point.
-void DwarfWriter::BeginFunction(MachineFunction *MF) {
+void DwarfWriter::BeginFunction(MachineFunction *MF, bool IsNormalText) {
   this->MF = MF;
+  // FIXME - should be able to debug coalesced functions.
+  this->IsNormalText = IsNormalText;
   
-  // Begin accumulating function debug information.
-  DebugInfo->BeginFunction(MF);
-  
-  if (!ShouldEmitDwarf()) return;
-  EOL("Dwarf Begin Function");
-  
-  // Assumes in correct section after the entry point.
-  EmitLabel("func_begin", ++SubprogramCount);
+  // FIXME - should be able to debug coalesced functions.
+  if (IsNormalText) {
+// Begin accumulating function debug information.
+DebugInfo->BeginFunction(MF);
+
+if (!ShouldEmitDwarf()) return;
+EOL("Dwarf Begin Function");
+  
+// Assumes in correct section after the entry point.
+EmitLabel("func_begin", ++SubprogramCount);
+  } else {
+ShouldEmitDwarf();
+  }
 }
 
 /// EndFunction - Gather and emit post-function debug information.
@@ -2439,14 +2442,17 @@
   if (!ShouldEmitDwarf()) return;
   EOL("Dwarf End Function");
   
-  // Define end label for subprogram.
-  EmitLabel("func_end", SubprogramCount);
-  
-  // Construct scopes for subprogram.
-  ConstructRootScope(DebugInfo->getRootScope());
+  // FIXME - should be able to debug coalesced functions.
+  if (IsNormalText) {
+// Define end label for subprogram.
+EmitLabel("func_end", SubprogramCount);
   
-  // Emit function frame information.
-  EmitFunctionDebugFrame();
+// Construct scopes for subprogram.
+Construc

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp PrologEpilogInserter.cpp

2006-04-07 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.53 -> 1.54
MachineDebugInfo.cpp updated: 1.36 -> 1.37
PrologEpilogInserter.cpp updated: 1.52 -> 1.53
---
Log message:

Foundation for call frame information.


---
Diffs of the changes:  (+153 -43)

 DwarfWriter.cpp  |  153 +--
 MachineDebugInfo.cpp |   37 +++
 PrologEpilogInserter.cpp |6 +
 3 files changed, 153 insertions(+), 43 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.53 
llvm/lib/CodeGen/DwarfWriter.cpp:1.54
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.53   Tue Mar 28 08:58:32 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppFri Apr  7 11:34:45 2006
@@ -18,6 +18,7 @@
 #include "llvm/Type.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/MachineDebugInfo.h"
+#include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/CommandLine.h"
@@ -1073,8 +1074,6 @@
   if (Asm->Data64bitsDirective) {
 O << Asm->Data64bitsDirective << "0x" << std::hex << Value << std::dec;
   } else {
-const TargetData &TD = Asm->TM.getTargetData();
-
 if (TD.isBigEndian()) {
   EmitInt32(unsigned(Value >> 32)); O << "\n";
   EmitInt32(unsigned(Value));
@@ -1216,12 +1215,14 @@
 /// AddAddress - Add an address attribute to a die based on the location
 /// provided.
 void DwarfWriter::AddAddress(DIE *Die, unsigned Attribute,
- MachineLocation &Location) {
+ const MachineLocation &Location) {
   DIEBlock *Block = new DIEBlock();
   if (Location.isRegister()) {
-Block->AddUInt(DW_FORM_data1, DW_OP_reg0 + Location.getRegister());
+Block->AddUInt(DW_FORM_data1,
+   DW_OP_reg0 + RI->getDwarfRegNum(Location.getRegister()));
   } else {
-Block->AddUInt(DW_FORM_data1, DW_OP_breg0 + Location.getRegister());
+Block->AddUInt(DW_FORM_data1,
+   DW_OP_breg0 + RI->getDwarfRegNum(Location.getRegister()));
 Block->AddUInt(DW_FORM_sdata, Location.getOffset());
   }
   Block->ComputeSize(*this);
@@ -1358,8 +1359,7 @@
   // Now normalize offset to the field.
   Offset -= FieldOffset;
   
-  // Maybe we need to work from the other.
-  const TargetData &TD = Asm->TM.getTargetData();
+  // Maybe we need to work from the other end.
   if (TD.isLittleEndian()) Offset = FieldSize - (Offset + Size);
   
   Member->AddUInt(DW_AT_byte_size, 0, FieldSize >> 3);
@@ -1515,8 +1515,11 @@
 
   DIE *SubprogramDie = new DIE(DW_TAG_subprogram);
   SubprogramDie->AddString (DW_AT_name,  DW_FORM_string, Name);
-  SubprogramDie->AddDIEntry(DW_AT_type,  DW_FORM_ref4,   Type);
-  SubprogramDie->AddUInt   (DW_AT_external,  DW_FORM_flag,   IsExternal);
+  if (Type) {
+SubprogramDie->AddDIEntry(DW_AT_type,  DW_FORM_ref4,   Type);
+  }
+  SubprogramDie->AddUInt   (DW_AT_external,DW_FORM_flag,   IsExternal);
+  SubprogramDie->AddUInt   (DW_AT_prototyped,  DW_FORM_flag,   1);
   
   // Add source line info if available.
   AddSourceLine(SubprogramDie, UnitDesc, SPD->getLine());
@@ -1561,7 +1564,7 @@
   
   // Add variable address.
   MachineLocation Location;
-  Asm->TM.getRegisterInfo()->getLocation(*MF, DV->getFrameIndex(), Location);
+  RI->getLocation(*MF, DV->getFrameIndex(), Location);
   AddAddress(VariableDie, DW_AT_location, Location);
   
   return VariableDie;
@@ -1621,18 +1624,20 @@
   
   // Get the compile unit context.
   CompileUnitDesc *UnitDesc = static_cast(SPD->getContext());
-  CompileUnit *Unit = FindCompileUnit(UnitDesc);  
+  CompileUnit *Unit = FindCompileUnit(UnitDesc);
+  
+  // Generate the mangled name.
+  std::string MangledName = Asm->Mang->getValueName(MF->getFunction());
   
   // Get the subprogram die.
   DIE *SPDie = Unit->getDieMapSlotFor(SPD);
   assert(SPDie && "Missing subprogram descriptor");
   
   // Add the function bounds.
-  SPDie->AddLabel(DW_AT_low_pc, DW_FORM_addr,
-  DWLabel("func_begin", SubprogramCount));
+  SPDie->AddObjectLabel(DW_AT_low_pc, DW_FORM_addr, MangledName);
   SPDie->AddLabel(DW_AT_high_pc, DW_FORM_addr,
   DWLabel("func_end", SubprogramCount));
-  MachineLocation Location(Asm->TM.getRegisterInfo()->getFrameRegister(*MF));
+  MachineLocation Location(RI->getFrameRegister(*MF));
   AddAddress(SPDie, DW_AT_frame_base, Location);
   
   ConstructScope(RootScope, SPDie, Unit);
@@ -1792,6 +1797,50 @@
   }
 }
 
+/// EmitFrameMoves - Emit frame instructions to describe the layout of the
+/// frame.
+void DwarfWriter::EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
+ std::vector &Moves) {
+  for (unsigned i = 0, N = Moves.size(); i < N; ++i) {
+MachineMove *Move = Moves[i];

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-03-23 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.48 -> 1.49
MachineDebugInfo.cpp updated: 1.32 -> 1.33
---
Log message:

Generate local variable and scope information and equivalent dwarf forms.


---
Diffs of the changes:  (+434 -79)

 DwarfWriter.cpp  |  324 ---
 MachineDebugInfo.cpp |  189 +++--
 2 files changed, 434 insertions(+), 79 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.48 
llvm/lib/CodeGen/DwarfWriter.cpp:1.49
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.48   Wed Mar 15 13:09:58 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppThu Mar 23 12:07:55 2006
@@ -18,9 +18,11 @@
 #include "llvm/Type.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/MachineDebugInfo.h"
+#include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Mangler.h"
+#include "llvm/Target/MRegisterInfo.h"
 #include "llvm/Target/TargetMachine.h"
 
 #include 
@@ -47,7 +49,7 @@
 private:
   CompileUnitDesc *Desc;// Compile unit debug descriptor.
   unsigned ID;  // File ID for source.
-  DIE *Die; // Compile unit die.
+  DIE *Die; // Compile unit debug information 
entry.
   std::map Globals; // A map of globally visible named
 // entities for this unit.
 
@@ -153,6 +155,12 @@
 Data.push_back(DIEAbbrevData(Attribute, Form));
   }
   
+  /// AddFirstAttribute - Adds a set of attribute information to the front
+  /// of the abbreviation.
+  void AddFirstAttribute(unsigned Attribute, unsigned Form) {
+Data.insert(Data.begin(), DIEAbbrevData(Attribute, Form));
+  }
+  
   /// Emit - Print the abbreviation using the specified Dwarf writer.
   ///
   void Emit(const DwarfWriter &DW) const; 
@@ -321,11 +329,11 @@
   static bool classof(const DIEntry *)   { return true; }
   static bool classof(const DIEValue *E) { return E->Type == isEntry; }
   
-  /// EmitValue - Emit die entry offset.
+  /// EmitValue - Emit debug information entry offset.
   ///
   virtual void EmitValue(const DwarfWriter &DW, unsigned Form) const;
   
-  /// SizeOf - Determine size of die entry in bytes.
+  /// SizeOf - Determine size of debug information entry in bytes.
   ///
   virtual unsigned SizeOf(const DwarfWriter &DW, unsigned Form) const;
 };
@@ -424,6 +432,10 @@
   /// SiblingOffset - Return the offset of the debug information entry's
   /// sibling.
   unsigned SiblingOffset() const { return Offset + Size; }
+  
+  /// AddSiblingOffset - Add a sibling offset field to the front of the DIE.
+  ///
+  void AddSiblingOffset();
 
   /// AddUInt - Add an unsigned integer attribute data and value.
   ///
@@ -591,9 +603,13 @@
 void DIEInteger::EmitValue(const DwarfWriter &DW, unsigned Form) const {
   switch (Form) {
   case DW_FORM_flag:  // Fall thru
+  case DW_FORM_ref1:  // Fall thru
   case DW_FORM_data1: DW.EmitInt8(Integer); break;
+  case DW_FORM_ref2:  // Fall thru
   case DW_FORM_data2: DW.EmitInt16(Integer);break;
+  case DW_FORM_ref4:  // Fall thru
   case DW_FORM_data4: DW.EmitInt32(Integer);break;
+  case DW_FORM_ref8:  // Fall thru
   case DW_FORM_data8: DW.EmitInt64(Integer);break;
   case DW_FORM_udata: DW.EmitULEB128Bytes(Integer); break;
   case DW_FORM_sdata: DW.EmitSLEB128Bytes(Integer); break;
@@ -606,9 +622,13 @@
 unsigned DIEInteger::SizeOf(const DwarfWriter &DW, unsigned Form) const {
   switch (Form) {
   case DW_FORM_flag:  // Fall thru
+  case DW_FORM_ref1:  // Fall thru
   case DW_FORM_data1: return sizeof(int8_t);
+  case DW_FORM_ref2:  // Fall thru
   case DW_FORM_data2: return sizeof(int16_t);
+  case DW_FORM_ref4:  // Fall thru
   case DW_FORM_data4: return sizeof(int32_t);
+  case DW_FORM_ref8:  // Fall thru
   case DW_FORM_data8: return sizeof(int64_t);
   case DW_FORM_udata: return DW.SizeULEB128(Integer);
   case DW_FORM_sdata: return DW.SizeSLEB128(Integer);
@@ -674,13 +694,13 @@
 }
 
 
//===--===//
-/// EmitValue - Emit die entry offset.
+/// EmitValue - Emit debug information entry offset.
 ///
 void DIEntry::EmitValue(const DwarfWriter &DW, unsigned Form) const {
   DW.EmitInt32(Entry->getOffset());
 }
 
-/// SizeOf - Determine size of die value in bytes.
+/// SizeOf - Determine size of debug information entry value in bytes.
 ///
 unsigned DIEntry::SizeOf(const DwarfWriter &DW, unsigned Form) const {
   return sizeof(int32_t);
@@ -818,6 +838,14 @@
   }
 }
 
+/// AddSiblingOffset - Add a sibling offset field to the front of the DIE.
+///
+void DIE::AddSiblingOffset() {
+  DIEInteger *DI = new DIEInteger(0);
+  Values.insert(Values.begin(), DI);
+  Abbrev->AddFirstAttribute(DW_AT_sibling, DW_FORM_ref4);
+}
+
 /// AddUInt - Add an unsigned integer att

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-03-15 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.47 -> 1.48
MachineDebugInfo.cpp updated: 1.31 -> 1.32
---
Log message:

Expand subprogram and added block descriptor.


---
Diffs of the changes:  (+79 -29)

 DwarfWriter.cpp  |   14 +++
 MachineDebugInfo.cpp |   94 +++
 2 files changed, 79 insertions(+), 29 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.47 
llvm/lib/CodeGen/DwarfWriter.cpp:1.48
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.47   Thu Mar  9 11:48:46 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppWed Mar 15 13:09:58 2006
@@ -1518,19 +1518,19 @@
 
   // Gather the details (simplify add attribute code.)
   const std::string &Name = SPD->getName();
-  unsigned FileID = Unit->getID();
-  // FIXME - faking the line for the time being.
-  unsigned Line = 1;
-  
-  // FIXME - faking the type for the time being.
-  DIE *Type = NewBasicType(Unit->getDie(), Type::IntTy); 
+  CompileUnitDesc *FileDesc = static_cast(SPD->getFile());
+  CompileUnit *File = FindCompileUnit(FileDesc);
+  unsigned FileID = File->getID();
+  DIE *Type = NewBasicType(Unit->getDie(), Type::IntTy);
+  unsigned Line = SPD->getLine();
+  unsigned IsExternal = SPD->isStatic() ? 0 : 1;
 
   DIE *SubprogramDie = new DIE(DW_TAG_subprogram);
   SubprogramDie->AddString (DW_AT_name,  DW_FORM_string, Name);
   SubprogramDie->AddUInt   (DW_AT_decl_file, 0,  FileID);
   SubprogramDie->AddUInt   (DW_AT_decl_line, 0,  Line);
   SubprogramDie->AddDIEntry(DW_AT_type,  DW_FORM_ref4,   Type);
-  SubprogramDie->AddUInt   (DW_AT_external,  DW_FORM_flag,   1);
+  SubprogramDie->AddUInt   (DW_AT_external,  DW_FORM_flag,   IsExternal);
   
   // Add to map.
   Slot = SubprogramDie;


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.31 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.32
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.31  Tue Mar 14 12:37:57 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Wed Mar 15 13:09:58 2006
@@ -270,16 +270,12 @@
 Elements.push_back(ConstantBool::get(Field));
   }
   virtual void Apply(std::string &Field) {
-if (Field.empty()) {
-  Elements.push_back(NULL);
-} else {
   Elements.push_back(SR.getString(Field));
-}
   }
   virtual void Apply(DebugInfoDesc *&Field) {
 GlobalVariable *GV = NULL;
 
-// If non-NULL the convert to global.
+// If non-NULL then convert to global.
 if (Field) GV = SR.Serialize(Field);
 
 // FIXME - At some point should use specific type.
@@ -473,19 +469,21 @@
   case DW_TAG_compile_unit: return new CompileUnitDesc();
   case DW_TAG_variable: return new GlobalVariableDesc();
   case DW_TAG_subprogram:   return new SubprogramDesc();
+  case DW_TAG_lexical_block:return new BlockDesc();
   case DW_TAG_base_type:return new BasicTypeDesc();
   case DW_TAG_typedef:
-  case DW_TAG_pointer_type: 
+  case DW_TAG_pointer_type:
   case DW_TAG_reference_type:
   case DW_TAG_const_type:
-  case DW_TAG_volatile_type: 
-  case DW_TAG_restrict_type:return new DerivedTypeDesc(Tag);
+  case DW_TAG_volatile_type:
+  case DW_TAG_restrict_type:
+  case DW_TAG_formal_parameter:
+  case DW_TAG_member:   return new DerivedTypeDesc(Tag);
   case DW_TAG_array_type:
   case DW_TAG_structure_type:
   case DW_TAG_union_type:
   case DW_TAG_enumeration_type: return new CompositeTypeDesc(Tag);
   case DW_TAG_subrange_type:return new SubrangeDesc();
-  case DW_TAG_member:   return new DerivedTypeDesc(DW_TAG_member);
   case DW_TAG_enumerator:   return new EnumeratorDesc();
   default: break;
   }
@@ -761,6 +759,7 @@
   case DW_TAG_const_type:
   case DW_TAG_volatile_type:
   case DW_TAG_restrict_type:
+  case DW_TAG_formal_parameter:
   case DW_TAG_member:
 return true;
   default: break;
@@ -948,6 +947,8 @@
 : AnchoredDesc(T)
 , Context(0)
 , Name("")
+, File(NULL)
+, Line(0)
 , TyDesc(NULL)
 , IsStatic(false)
 , IsDefinition(false)
@@ -960,6 +961,8 @@
 
   Visitor->Apply(Context);
   Visitor->Apply(Name);
+  Visitor->Apply((DebugInfoDesc *&)File);
+  Visitor->Apply(Line);
   Visitor->Apply((DebugInfoDesc *&)TyDesc);
   Visitor->Apply(IsStatic);
   Visitor->Apply(IsDefinition);
@@ -983,7 +986,6 @@
   GlobalDesc::ApplyToFields(Visitor);
 
   Visitor->Apply(Global);
-  Visitor->Apply(Line);
 }
 
 /// getDescString - Return a string used to compose global names and labels.
@@ -1011,11 +1013,12 @@
 << "Tag(" << getTag() << "), "
 << "Anchor(" << getAnchor() << "), "
 << "Name(\"" << getName() << "\"), "
+<< "File(" << getFile() << "),"
+<< "Line(" << getLine() << "),"
 << "Type(\"" << getTypeDesc() << "\"), "
 << "IsStatic(" << (isStatic() ? "true" : "false

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-03-09 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.44 -> 1.45
MachineDebugInfo.cpp updated: 1.27 -> 1.28
---
Log message:

Move bit field endianness to backend.


---
Diffs of the changes:  (+29 -10)

 DwarfWriter.cpp  |   36 ++--
 MachineDebugInfo.cpp |3 +++
 2 files changed, 29 insertions(+), 10 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.44 
llvm/lib/CodeGen/DwarfWriter.cpp:1.45
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.44   Wed Mar  8 12:11:06 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppThu Mar  9 07:28:47 2006
@@ -1323,6 +1323,7 @@
 unsigned Line = MemberDesc->getLine();
 TypeDesc *MemTy = MemberDesc->getFromType();
 uint64_t Size = MemberDesc->getSize();
+uint64_t Align = MemberDesc->getAlign();
 uint64_t Offset = MemberDesc->getOffset();

 // Construct member die.
@@ -1338,27 +1339,42 @@
   Member->AddUInt(DW_AT_decl_line, 0, Line);
 }
 
-// FIXME - Bitfields not quite right but getting there.
-uint64_t ByteSize = Size;
-uint64_t ByteOffset = Offset;
+// Most of the time the field info is the same as the members.
+uint64_t FieldSize = Size;
+uint64_t FieldAlign = Align;
+uint64_t FieldOffset = Offset;
 
 if (TypeDesc *FromTy = MemberDesc->getFromType()) {
Member->AddDIEntry(DW_AT_type, DW_FORM_ref4,
   NewType(Context, FromTy));
-   ByteSize = FromTy->getSize();
+   FieldSize = FromTy->getSize();
+   FieldAlign = FromTy->getSize();
 }
 
-if (ByteSize != Size) {
-  ByteOffset -=  Offset % ByteSize;
-  Member->AddUInt(DW_AT_byte_size, 0, ByteSize >> 3);
-  Member->AddUInt(DW_AT_bit_size, 0, Size % ByteSize);
-  Member->AddUInt(DW_AT_bit_offset, 0, Offset - ByteOffset);
+// Unless we have a bit field.
+if (FieldSize != Size) {
+  // Construct the alignment mask.
+  uint64_t AlignMask = ~(FieldAlign - 1);
+  // Determine the high bit + 1 of the declared size.
+  uint64_t HiMark = (Offset + FieldSize) & AlignMask;
+  // Work backwards to determine the base offset of the field.
+  FieldOffset = HiMark - FieldSize;
+  // Now normalize offset to the field.
+  Offset -= FieldOffset;
+  
+  // Maybe we need to work from the other.
+  const TargetData &TD = Asm->TM.getTargetData();
+  if (TD.isLittleEndian()) Offset = FieldSize - (Offset + Size);
+  
+  Member->AddUInt(DW_AT_byte_size, 0, FieldSize >> 3);
+  Member->AddUInt(DW_AT_bit_size, 0, Size);
+  Member->AddUInt(DW_AT_bit_offset, 0, Offset);
 }
 
 // Add computation for offset.
 DIEBlock *Block = new DIEBlock();
 Block->AddUInt(DW_FORM_data1, DW_OP_plus_uconst);
-Block->AddUInt(DW_FORM_udata, ByteOffset >> 3);
+Block->AddUInt(DW_FORM_udata, FieldOffset >> 3);
 Block->ComputeSize(*this);
 Member->AddBlock(DW_AT_data_member_location, 0, Block);
 


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.27 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.28
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.27  Wed Mar  8 12:11:06 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Thu Mar  9 07:28:47 2006
@@ -653,6 +653,7 @@
 , Name("")
 , File(NULL)
 , Size(0)
+, Align(0)
 , Offset(0)
 {}
 
@@ -666,6 +667,7 @@
   Visitor->Apply((DebugInfoDesc *&)File);
   Visitor->Apply(Line);
   Visitor->Apply(Size);
+  Visitor->Apply(Align);
   Visitor->Apply(Offset);
 }
 
@@ -690,6 +692,7 @@
 << "File(" << File << "), "
 << "Line(" << Line << "), "
 << "Size(" << Size << "), "
+<< "Align(" << Align << "), "
 << "Offset(" << Offset << ")\n";
 }
 #endif



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-03-08 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.43 -> 1.44
MachineDebugInfo.cpp updated: 1.26 -> 1.27
---
Log message:

Get rid of the multiple copies of getStringValue.  Now a Constant:: method.


---
Diffs of the changes:  (+2 -42)

 DwarfWriter.cpp  |1 -
 MachineDebugInfo.cpp |   43 ++-
 2 files changed, 2 insertions(+), 42 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.43 
llvm/lib/CodeGen/DwarfWriter.cpp:1.44
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.43   Tue Mar  7 09:51:33 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppWed Mar  8 12:11:06 2006
@@ -1244,7 +1244,6 @@
 /// NewType - Create a new type DIE.
 ///
 DIE *DwarfWriter::NewType(DIE *Context, TypeDesc *TyDesc) {
-  // FIXME - hack to get around NULL types short term.
   if (!TyDesc)  return NewBasicType(Context, Type::IntTy);
   
   // FIXME - Should handle other contexts that compile units.


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.26 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.27
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.26  Tue Mar  7 20:07:02 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Wed Mar  8 12:11:06 2006
@@ -67,45 +67,6 @@
   return Result;
 }
   
-/// getStringValue - Turn an LLVM constant pointer that eventually points to a
-/// global into a string value.  Return an empty string if we can't do it.
-///
-static const std::string getStringValue(Value *V, unsigned Offset = 0) {
-  if (GlobalVariable *GV = dyn_cast(V)) {
-if (GV->hasInitializer() && isa(GV->getInitializer())) {
-  ConstantArray *Init = cast(GV->getInitializer());
-  if (Init->isString()) {
-std::string Result = Init->getAsString();
-if (Offset < Result.size()) {
-  // If we are pointing INTO The string, erase the beginning...
-  Result.erase(Result.begin(), Result.begin()+Offset);
-
-  // Take off the null terminator, and any string fragments after it.
-  std::string::size_type NullPos = Result.find_first_of((char)0);
-  if (NullPos != std::string::npos)
-Result.erase(Result.begin()+NullPos, Result.end());
-  return Result;
-}
-  }
-}
-  } else if (Constant *C = dyn_cast(V)) {
-if (GlobalValue *GV = dyn_cast(C))
-  return getStringValue(GV, Offset);
-else if (ConstantExpr *CE = dyn_cast(C)) {
-  if (CE->getOpcode() == Instruction::GetElementPtr) {
-// Turn a gep into the specified offset.
-if (CE->getNumOperands() == 3 &&
-cast(CE->getOperand(1))->isNullValue() &&
-isa(CE->getOperand(2))) {
-  return getStringValue(CE->getOperand(0),
-   Offset+cast(CE->getOperand(2))->getRawValue());
-}
-  }
-}
-  }
-  return "";
-}
-
 /// isStringValue - Return true if the given value can be coerced to a string.
 ///
 static bool isStringValue(Value *V) {
@@ -250,7 +211,7 @@
   }
   virtual void Apply(std::string &Field) {
 Constant *C = CI->getOperand(I++);
-Field = getStringValue(C);
+Field = C->getStringValue();
   }
   virtual void Apply(DebugInfoDesc *&Field) {
 Constant *C = CI->getOperand(I++);
@@ -571,7 +532,7 @@
 
 /// getDescString - Return a string used to compose global names and labels. A
 /// A global variable name needs to be defined for each debug descriptor that 
is
-/// anchored. NOTE: that each global variable name here also needs to be added
+/// anchored. NOTE: that each global variable named here also needs to be added
 /// to the list of names left external in the internalizer.
 ///   ExternalNames.insert("llvm.dbg.compile_units");
 ///   ExternalNames.insert("llvm.dbg.global_variables");



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-03-03 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.40 -> 1.41
MachineDebugInfo.cpp updated: 1.22 -> 1.23
---
Log message:

Adding basic structure support.


---
Diffs of the changes:  (+46 -4)

 DwarfWriter.cpp  |   43 ---
 MachineDebugInfo.cpp |7 ++-
 2 files changed, 46 insertions(+), 4 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.40 
llvm/lib/CodeGen/DwarfWriter.cpp:1.41
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.40   Wed Mar  1 17:52:37 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppFri Mar  3 09:06:57 2006
@@ -41,6 +41,8 @@
 class DIE;
 
 
//===--===//
+// CompileUnit - This dwarf writer support class manages information associate
+// with a source file.
 class CompileUnit {
 private:
   CompileUnitDesc *Desc;// Compile unit debug descriptor.
@@ -505,6 +507,13 @@
   case DW_FORM_data8: DW.EmitInt64(Integer);break;
   case DW_FORM_udata: DW.EmitULEB128Bytes(Integer); break;
   case DW_FORM_sdata: DW.EmitSLEB128Bytes(Integer); break;
+  // FIXME - Punting on field offsets.
+  case DW_FORM_block1: {
+DW.EmitInt8(1 +  DW.SizeULEB128(Integer)); DW.EOL("Form1 Size");
+DW.EmitInt8(DW_OP_plus_uconst); DW.EOL("DW_OP_plus_uconst");
+DW.EmitULEB128Bytes(Integer);
+break;
+  }
   default: assert(0 && "DIE Value form not supported yet"); break;
   }
 }
@@ -520,6 +529,8 @@
   case DW_FORM_data8: return sizeof(int64_t);
   case DW_FORM_udata: return DW.SizeULEB128(Integer);
   case DW_FORM_sdata: return DW.SizeSLEB128(Integer);
+  // FIXME - Punting on field offsets.
+  case DW_FORM_block1:   return 2 + DW.SizeULEB128(Integer);
   default: assert(0 && "DIE Value form not supported yet"); break;
   }
   return 0;
@@ -1117,10 +1128,36 @@
   
   break;
 }
-case DW_TAG_structure_type: {
-  break;
-}
+case DW_TAG_structure_type:
 case DW_TAG_union_type: {
+  // FIXME - this is just the basics.
+  // Add elements to structure type.
+  for(unsigned i = 0, N = Elements.size(); i < N; ++i) {
+DerivedTypeDesc *MemberDesc = cast(Elements[i]);
+const std::string &Name = MemberDesc->getName();
+unsigned Line = MemberDesc->getLine();
+TypeDesc *MemTy = MemberDesc->getFromType();
+uint64_t Size = MemberDesc->getSize();
+uint64_t Offset = MemberDesc->getOffset();
+   
+DIE *Member = new DIE(DW_TAG_member);
+if (!Name.empty()) Member->AddString(DW_AT_name, DW_FORM_string, Name);
+if (CompileUnitDesc *File = MemberDesc->getFile()) {
+  CompileUnit *FileUnit = FindCompileUnit(File);
+  unsigned FileID = FileUnit->getID();
+  int Line = TyDesc->getLine();
+  Member->AddUInt(DW_AT_decl_file, 0, FileID);
+  Member->AddUInt(DW_AT_decl_line, 0, Line);
+}
+if (TypeDesc *FromTy = MemberDesc->getFromType()) {
+   Member->AddDIEntry(DW_AT_type, DW_FORM_ref4,
+  NewType(Context, FromTy));
+}
+// FIXME - Punt on the Address.
+Member->AddUInt(DW_AT_data_member_location, DW_FORM_block1,
+Offset >> 3);
+Ty->AddChild(Member);
+  }
   break;
 }
 case DW_TAG_enumeration_type: {


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.22 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.23
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.22  Wed Mar  1 17:52:37 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Fri Mar  3 09:06:57 2006
@@ -516,6 +516,7 @@
   case DW_TAG_union_type:
   case DW_TAG_enumeration_type: return new CompositeTypeDesc(Tag);
   case DW_TAG_subrange_type:return new SubrangeDesc();
+  case DW_TAG_member:   return new DerivedTypeDesc(DW_TAG_member);
   case DW_TAG_enumerator:   return new EnumeratorDesc();
   default: break;
   }
@@ -673,6 +674,7 @@
 , Name("")
 , File(NULL)
 , Size(0)
+, Offset(0)
 {}
 
 /// ApplyToFields - Target the visitor to the fields of the TypeDesc.
@@ -685,6 +687,7 @@
   Visitor->Apply((DebugInfoDesc *&)File);
   Visitor->Apply(Line);
   Visitor->Apply(Size);
+  Visitor->Apply(Offset);
 }
 
 /// getDescString - Return a string used to compose global names and labels.
@@ -707,7 +710,8 @@
 << "Name(\"" << Name << "\"), "
 << "File(" << File << "), "
 << "Line(" << Line << "), "
-<< "Size(" << Size << ")\n";
+<< "Size(" << Size << "), "
+<< "Offset(" << Offset << ")\n";
 }
 #endif
 
@@ -771,6 +775,7 @@
   case DW_TAG_const_type:
   case DW_TAG_volatile_type:
   case DW_TAG_restrict_type:
+  case DW_TAG_member:
 return true;
   default: break;
   }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiu

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-03-01 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.39 -> 1.40
MachineDebugInfo.cpp updated: 1.21 -> 1.22
---
Log message:

Support for enumerations.


---
Diffs of the changes:  (+57 -2)

 DwarfWriter.cpp  |   15 +--
 MachineDebugInfo.cpp |   44 
 2 files changed, 57 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.39 
llvm/lib/CodeGen/DwarfWriter.cpp:1.40
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.39   Wed Mar  1 14:39:35 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppWed Mar  1 17:52:37 2006
@@ -1109,8 +1109,8 @@
 if (Lo != Hi) {
   Subrange->AddDIEntry(DW_AT_type, DW_FORM_ref4, IndexTy);
   // Only add low if non-zero.
-  if (Lo) Subrange->AddUInt(DW_AT_lower_bound, 0, Lo);
-  Subrange->AddUInt(DW_AT_upper_bound, 0, Hi);
+  if (Lo) Subrange->AddSInt(DW_AT_lower_bound, 0, Lo);
+  Subrange->AddSInt(DW_AT_upper_bound, 0, Hi);
 }
 Ty->AddChild(Subrange);
   }
@@ -1124,6 +1124,17 @@
   break;
 }
 case DW_TAG_enumeration_type: {
+  // Add enumerators to enumeration type.
+  for(unsigned i = 0, N = Elements.size(); i < N; ++i) {
+EnumeratorDesc *ED = cast(Elements[i]);
+const std::string &Name = ED->getName();
+int64_t Value = ED->getValue();
+DIE *Enumerator = new DIE(DW_TAG_enumerator);
+Enumerator->AddString(DW_AT_name, DW_FORM_string, Name);
+Enumerator->AddSInt(DW_AT_const_value, DW_FORM_sdata, Value);
+Ty->AddChild(Enumerator);
+  }
+
   break;
 }
 default: break;


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.21 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.22
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.21  Wed Mar  1 14:39:36 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Wed Mar  1 17:52:37 2006
@@ -516,6 +516,7 @@
   case DW_TAG_union_type:
   case DW_TAG_enumeration_type: return new CompositeTypeDesc(Tag);
   case DW_TAG_subrange_type:return new SubrangeDesc();
+  case DW_TAG_enumerator:   return new EnumeratorDesc();
   default: break;
   }
   return NULL;
@@ -909,6 +910,49 @@
 
 
//===--===//
 
+EnumeratorDesc::EnumeratorDesc()
+: DebugInfoDesc(DW_TAG_enumerator)
+, Name("")
+, Value(0)
+{}
+
+// Implement isa/cast/dyncast.
+bool EnumeratorDesc::classof(const DebugInfoDesc *D) {
+  return D->getTag() == DW_TAG_enumerator;
+}
+
+/// ApplyToFields - Target the visitor to the fields of the EnumeratorDesc.
+///
+void EnumeratorDesc::ApplyToFields(DIVisitor *Visitor) {
+  DebugInfoDesc::ApplyToFields(Visitor);
+
+  Visitor->Apply(Name);
+  Visitor->Apply(Value);
+}
+
+/// getDescString - Return a string used to compose global names and labels.
+///
+const char *EnumeratorDesc::getDescString() const {
+  return "llvm.dbg.enumerator";
+}
+  
+/// getTypeString - Return a string used to label this descriptor's type.
+///
+const char *EnumeratorDesc::getTypeString() const {
+  return "llvm.dbg.enumerator.type";
+}
+
+#ifndef NDEBUG
+void EnumeratorDesc::dump() {
+  std::cerr << getDescString() << " "
+<< "Tag(" << getTag() << "), "
+<< "Name(" << Name << "), "
+<< "Value(" << Value << ")\n";
+}
+#endif
+
+//===--===//
+
 GlobalDesc::GlobalDesc(unsigned T)
 : AnchoredDesc(T)
 , Context(0)



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-03-01 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.38 -> 1.39
MachineDebugInfo.cpp updated: 1.20 -> 1.21
---
Log message:

Switch back to using actual dwarf tags.  Simplifies code without loss to other
debug forms.


---
Diffs of the changes:  (+103 -55)

 DwarfWriter.cpp  |   34 ++---
 MachineDebugInfo.cpp |  124 +++
 2 files changed, 103 insertions(+), 55 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.38 
llvm/lib/CodeGen/DwarfWriter.cpp:1.39
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.38   Wed Mar  1 12:20:30 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppWed Mar  1 14:39:35 2006
@@ -1070,42 +1070,20 @@
 unsigned Encoding = BasicTy->getEncoding();
 Ty->AddUInt  (DW_AT_encoding,  DW_FORM_data1, Encoding);
   } else if (DerivedTypeDesc *DerivedTy = dyn_cast(TyDesc)) {
-// Determine which derived type.
-unsigned T = 0;
-switch (DerivedTy->getTag()) {
-case DI_TAG_typedef:   T = DW_TAG_typedef; break;
-case DI_TAG_pointer:   T = DW_TAG_pointer_type;break;
-case DI_TAG_reference: T = DW_TAG_reference_type;  break;
-case DI_TAG_const: T = DW_TAG_const_type;  break;
-case DI_TAG_volatile:  T = DW_TAG_volatile_type;   break;
-case DI_TAG_restrict:  T = DW_TAG_restrict_type;   break;
-default: assert( 0 && "Unknown tag on derived type");
-}
-
 // Create specific DIE.
-Slot = Ty = new DIE(T);
+Slot = Ty = new DIE(DerivedTy->getTag());
 
 // Map to main type, void will not have a type.
 if (TypeDesc *FromTy = DerivedTy->getFromType()) {
Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Context, FromTy));
 }
   } else if (CompositeTypeDesc *CompTy = dyn_cast(TyDesc)) {
-// Determine which composite type.
-unsigned T = 0;
-switch (CompTy->getTag()) {
-case DI_TAG_array: T = DW_TAG_array_type;   break;
-case DI_TAG_struct:T = DW_TAG_structure_type;   break;
-case DI_TAG_union: T = DW_TAG_union_type;   break;
-case DI_TAG_enum:  T = DW_TAG_enumeration_type; break;
-default: assert( 0 && "Unknown tag on composite type");
-}
-
 // Create specific DIE.
-Slot = Ty = new DIE(T);
+Slot = Ty = new DIE(CompTy->getTag());
 std::vector &Elements = CompTy->getElements();
 
 switch (CompTy->getTag()) {
-case DI_TAG_array: {
+case DW_TAG_array_type: {
   // Add element type.
   if (TypeDesc *FromTy = CompTy->getFromType()) {
  Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Context, FromTy));
@@ -1139,13 +1117,13 @@
   
   break;
 }
-case DI_TAG_struct: {
+case DW_TAG_structure_type: {
   break;
 }
-case DI_TAG_union: {
+case DW_TAG_union_type: {
   break;
 }
-case DI_TAG_enum: {
+case DW_TAG_enumeration_type: {
   break;
 }
 default: break;


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.20 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.21
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.20  Wed Mar  1 11:53:02 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Wed Mar  1 14:39:36 2006
@@ -20,6 +20,7 @@
 #include 
 
 using namespace llvm;
+using namespace llvm::dwarf;
 
 // Handle the Pass registration stuff necessary to use TargetData's.
 namespace {
@@ -492,29 +493,29 @@
 /// GlobalVariable.  
 unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) {
   ConstantUInt *C = getUIntOperand(GV, 0);
-  return C ? (unsigned)C->getValue() : (unsigned)DIInvalid;
+  return C ? (unsigned)C->getValue() : (unsigned)DW_TAG_invalid;
 }
 
 /// DescFactory - Create an instance of debug info descriptor based on Tag.
 /// Return NULL if not a recognized Tag.
 DebugInfoDesc *DebugInfoDesc::DescFactory(unsigned Tag) {
   switch (Tag) {
-  case DI_TAG_anchor:  return new AnchorDesc();
-  case DI_TAG_compile_unit:return new CompileUnitDesc();
-  case DI_TAG_global_variable: return new GlobalVariableDesc();
-  case DI_TAG_subprogram:  return new SubprogramDesc();
-  case DI_TAG_basictype:   return new BasicTypeDesc();
-  case DI_TAG_typedef:
-  case DI_TAG_pointer: 
-  case DI_TAG_reference:
-  case DI_TAG_const:
-  case DI_TAG_volatile: 
-  case DI_TAG_restrict:return new DerivedTypeDesc(Tag);
-  case DI_TAG_array:
-  case DI_TAG_struct:
-  case DI_TAG_union:
-  case DI_TAG_enum:return new CompositeTypeDesc(Tag);
-  case DI_TAG_subrange:return new SubrangeDesc();
+  case DW_TAG_anchor:   return new AnchorDesc();
+  case DW_TAG_compile_unit: return new CompileUnitDesc();
+  case DW_TAG_variable: return new GlobalVariableDesc();
+  case DW_TAG_subprogram:   return new SubprogramDesc();
+  case DW_TAG_base_type:return new BasicTypeDesc();
+  case DW_TAG_typedef:
+  case DW_TAG_pointer_type: 
+  case DW_TA

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-03-01 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.35 -> 1.36
MachineDebugInfo.cpp updated: 1.19 -> 1.20
---
Log message:

Basic array support.


---
Diffs of the changes:  (+197 -10)

 DwarfWriter.cpp  |   73 +--
 MachineDebugInfo.cpp |  134 +--
 2 files changed, 197 insertions(+), 10 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.35 
llvm/lib/CodeGen/DwarfWriter.cpp:1.36
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.35   Tue Feb 28 14:15:07 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppWed Mar  1 11:53:02 2006
@@ -1072,12 +1072,12 @@
 // Determine which derived type.
 unsigned T = 0;
 switch (DerivedTy->getTag()) {
-case DI_TAG_typedef:   T = DW_TAG_typedef;break;
-case DI_TAG_pointer:   T = DW_TAG_pointer_type;   break;
-case DI_TAG_reference: T = DW_TAG_reference_type; break;
-case DI_TAG_const: T = DW_TAG_const_type; break;
-case DI_TAG_volatile:  T = DW_TAG_volatile_type;  break;
-case DI_TAG_restrict:  T = DW_TAG_restrict_type;  break;
+case DI_TAG_typedef:   T = DW_TAG_typedef; break;
+case DI_TAG_pointer:   T = DW_TAG_pointer_type;break;
+case DI_TAG_reference: T = DW_TAG_reference_type;  break;
+case DI_TAG_const: T = DW_TAG_const_type;  break;
+case DI_TAG_volatile:  T = DW_TAG_volatile_type;   break;
+case DI_TAG_restrict:  T = DW_TAG_restrict_type;   break;
 default: assert( 0 && "Unknown tag on derived type");
 }
 
@@ -1088,6 +1088,67 @@
 if (TypeDesc *FromTy = DerivedTy->getFromType()) {
Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Unit, FromTy));
 }
+  } else if (CompositeTypeDesc *CompTy = dyn_cast(TyDesc)) {
+// Determine which composite type.
+unsigned T = 0;
+switch (CompTy->getTag()) {
+case DI_TAG_array: T = DW_TAG_array_type;   break;
+case DI_TAG_struct:T = DW_TAG_structure_type;   break;
+case DI_TAG_union: T = DW_TAG_union_type;   break;
+case DI_TAG_enum:  T = DW_TAG_enumeration_type; break;
+default: assert( 0 && "Unknown tag on composite type");
+}
+
+// Create specific DIE.
+Slot = Ty = new DIE(T);
+std::vector &Elements = CompTy->getElements();
+
+switch (CompTy->getTag()) {
+case DI_TAG_array: {
+  // Add element type.
+  if (TypeDesc *FromTy = CompTy->getFromType()) {
+ Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Unit, FromTy));
+  }
+  // Don't emit size attribute.
+  Size = 0;
+  
+  // Construct an anonymous type for index type.
+  DIE *IndexTy = new DIE(DW_TAG_base_type);
+  IndexTy->AddUInt(DW_AT_byte_size, 0, 4);
+  IndexTy->AddUInt(DW_AT_encoding, DW_FORM_data1, DW_ATE_signed);
+  // Add to context.
+  Unit->getDie()->AddChild(IndexTy);
+
+  // Add subranges to array type.
+  for(unsigned i = 0, N = Elements.size(); i < N; ++i) {
+SubrangeDesc *SRD = cast(Elements[i]);
+int64_t Lo = SRD->getLo();
+int64_t Hi = SRD->getHi();
+DIE *Subrange = new DIE(DW_TAG_subrange_type);
+
+// If a range is available.
+if (Lo != Hi) {
+  Subrange->AddDIEntry(DW_AT_type, DW_FORM_ref4, IndexTy);
+  // Only add low if non-zero.
+  if (Lo) Subrange->AddUInt(DW_AT_lower_bound, 0, Lo);
+  Subrange->AddUInt(DW_AT_upper_bound, 0, Hi);
+}
+Ty->AddChild(Subrange);
+  }
+  
+  break;
+}
+case DI_TAG_struct: {
+  break;
+}
+case DI_TAG_union: {
+  break;
+}
+case DI_TAG_enum: {
+  break;
+}
+default: break;
+}
   }
   
   assert(Ty && "Type not supported yet");


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.19 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.20
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.19  Tue Feb 28 14:15:07 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Wed Mar  1 11:53:02 2006
@@ -197,6 +197,7 @@
   ///
   virtual void Apply(int &Field) { ++Count; }
   virtual void Apply(unsigned &Field){ ++Count; }
+  virtual void Apply(int64_t &Field) { ++Count; }
   virtual void Apply(uint64_t &Field){ ++Count; }
   virtual void Apply(bool &Field){ ++Count; }
   virtual void Apply(std::string &Field) { ++Count; }
@@ -234,6 +235,10 @@
 Constant *C = CI->getOperand(I++);
 Field = cast(C)->getValue();
   }
+  virtual void Apply(int64_t &Field) {
+Constant *C = CI->getOperand(I++);
+Field = cast(C)->getValue();
+  }
   virtual void Apply(uint64_t &Field) {
 Constant *C = CI->getOperand(I++);
 Field = cast(C)->getValue();
@@ -290,6 +295,9 @@
   virtual void Apply(unsigned &Field) {
 Elements.push_back(ConstantUInt::get(Type::UIntTy, Field));
   }
+  virtual void Apply(int64_t &Field) {

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-02-28 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.34 -> 1.35
MachineDebugInfo.cpp updated: 1.18 -> 1.19
---
Log message:

Add const, volatile, restrict support.
Add array of debug descriptor support.


---
Diffs of the changes:  (+67 -5)

 DwarfWriter.cpp  |3 ++
 MachineDebugInfo.cpp |   69 +++
 2 files changed, 67 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.34 
llvm/lib/CodeGen/DwarfWriter.cpp:1.35
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.34   Mon Feb 27 16:37:23 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppTue Feb 28 14:15:07 2006
@@ -1075,6 +1075,9 @@
 case DI_TAG_typedef:   T = DW_TAG_typedef;break;
 case DI_TAG_pointer:   T = DW_TAG_pointer_type;   break;
 case DI_TAG_reference: T = DW_TAG_reference_type; break;
+case DI_TAG_const: T = DW_TAG_const_type; break;
+case DI_TAG_volatile:  T = DW_TAG_volatile_type;  break;
+case DI_TAG_restrict:  T = DW_TAG_restrict_type;  break;
 default: assert( 0 && "Unknown tag on derived type");
 }
 


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.18 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.19
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.18  Fri Feb 24 10:46:40 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Tue Feb 28 14:15:07 2006
@@ -202,6 +202,9 @@
   virtual void Apply(std::string &Field) { ++Count; }
   virtual void Apply(DebugInfoDesc *&Field)  { ++Count; }
   virtual void Apply(GlobalVariable *&Field) { ++Count; }
+  virtual void Apply(std::vector &Field) {
+++Count;
+  }
 };
 
 
//===--===//
@@ -251,6 +254,17 @@
 Constant *C = CI->getOperand(I++);
 Field = getGlobalVariable(C);
   }
+  virtual void Apply(std::vector &Field) {
+Constant *C = CI->getOperand(I++);
+GlobalVariable *GV = getGlobalVariable(C);
+ConstantArray *CA = cast(GV->getInitializer());
+Field.resize(0);
+for (unsigned i = 0, N = CA->getNumOperands(); i < N; ++i) {
+  GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i));
+  DebugInfoDesc *DE = DR.Deserialize(GVE);
+  Field.push_back(DE);
+}
+  }
 };
 
 
//===--===//
@@ -310,6 +324,22 @@
   Elements.push_back(ConstantPointerNull::get(EmptyTy));
 }
   }
+  virtual void Apply(std::vector &Field) {
+const PointerType *EmptyTy = SR.getEmptyStructPtrType();
+unsigned N = Field.size();
+ArrayType *AT = ArrayType::get(EmptyTy, N);
+std::vector ArrayElements;
+
+for (unsigned i = 0, N = Field.size(); i < N; ++i) {
+  GlobalVariable *GVE = SR.Serialize(Field[i]);
+  Constant *CE = ConstantExpr::getCast(GVE, EmptyTy);
+  ArrayElements.push_back(cast(CE));
+}
+
+Constant *CA = ConstantArray::get(AT, ArrayElements);
+Constant *CAE = ConstantExpr::getCast(CA, EmptyTy);
+Elements.push_back(CAE);
+  }
 };
 
 
//===--===//
@@ -353,6 +383,10 @@
 const PointerType *EmptyTy = SR.getEmptyStructPtrType();
 Fields.push_back(EmptyTy);
   }
+  virtual void Apply(std::vector &Field) {
+const PointerType *EmptyTy = SR.getEmptyStructPtrType();
+Fields.push_back(EmptyTy);
+  }
 };
 
 
//===--===//
@@ -409,6 +443,27 @@
 Constant *C = CI->getOperand(I++);
 IsValid = IsValid && isGlobalVariable(C);
   }
+  virtual void Apply(std::vector &Field) {
+Constant *C = CI->getOperand(I++);
+IsValid = IsValid && isGlobalVariable(C);
+if (!IsValid) return;
+
+GlobalVariable *GV = getGlobalVariable(C);
+IsValid = IsValid && GV && GV->hasInitializer();
+if (!IsValid) return;
+
+ConstantArray *CA = dyn_cast(GV->getInitializer());
+IsValid = IsValid && CA;
+if (!IsValid) return;
+
+for (unsigned i = 0, N = CA->getNumOperands(); IsValid && i < N; ++i) {
+  IsValid = IsValid && isGlobalVariable(CA->getOperand(i));
+  if (!IsValid) return;
+
+  GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i));
+  VR.Verify(GVE);
+}
+  }
 };
 
 
@@ -430,9 +485,12 @@
   case DI_TAG_global_variable: return new GlobalVariableDesc();
   case DI_TAG_subprogram:  return new SubprogramDesc();
   case DI_TAG_basictype:   return new BasicTypeDesc();
-  case DI_TAG_typedef: return new DerivedTypeDesc(DI_TAG_typedef);
-  case DI_TAG_pointer: return new DerivedTypeDesc(DI_TAG_pointer); 

-  case DI_TAG_reference:   return new DerivedTypeDesc(DI_TAG_reference);
+  case DI_TAG_typedef:
+  case DI_TAG_pointer: 
+  case DI_TAG_reference:
+  case DI_TAG_const:
+  case DI_TAG_volatile: 
+  case DI_TAG_restrict:return new DerivedTypeDesc(Ta

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-02-24 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.29 -> 1.30
MachineDebugInfo.cpp updated: 1.17 -> 1.18
---
Log message:

Add pointer and reference types.  Added short-term code to ignore NULL types
(to allow llvm-gcc4 to build.)


---
Diffs of the changes:  (+52 -29)

 DwarfWriter.cpp  |   43 ++-
 MachineDebugInfo.cpp |   38 ++
 2 files changed, 52 insertions(+), 29 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.29 
llvm/lib/CodeGen/DwarfWriter.cpp:1.30
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.29   Thu Feb 23 16:37:30 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppFri Feb 24 10:46:40 2006
@@ -1235,6 +1235,9 @@
 /// NewType - Create a new type DIE.
 ///
 DIE *DwarfWriter::NewType(DIE *Unit, TypeDesc *TyDesc) {
+  // FIXME - hack to get around NULL types short term.
+  if (!TyDesc)  return NewBasicType(Unit, Type::IntTy);
+
   // Check for pre-existence.
   DIE *&Slot = DescToDieMap[TyDesc];
   if (Slot) return Slot;
@@ -1246,29 +1249,43 @@
   
   DIE *Ty = NULL;
   
-  // Determine how to handle.
   if (BasicTypeDesc *BasicTy = dyn_cast(TyDesc)) {
+// Fundamental types like int, float, bool
 Slot = Ty = new DIE(DW_TAG_base_type);
 unsigned Encoding = BasicTy->getEncoding();
 Ty->AddUInt  (DW_AT_encoding,  DW_FORM_data1, Encoding);
-  } else if (TypedefDesc *TypedefTy = dyn_cast(TyDesc)) {
-Slot = Ty = new DIE(DW_TAG_typedef);
-TypeDesc *FromTy = TypedefTy->getFromType();
-DIE *FromTyDie = NewType(Unit, FromTy);
-CompileUnitDesc *File = TypedefTy->getFile();
-unsigned FileID = DebugInfo->RecordSource(File);
-int Line = TypedefTy->getLine();
-
-Ty->AddDIEntry(DW_AT_type,  DW_FORM_ref4, FromTyDie);
-Ty->AddUInt   (DW_AT_decl_file, 0,FileID);
-Ty->AddUInt   (DW_AT_decl_line, 0,Line);
+  } else if (DerivedTypeDesc *DerivedTy = dyn_cast(TyDesc)) {
+// Determine which derived type.
+unsigned T = 0;
+switch (DerivedTy->getTag()) {
+case DI_TAG_typedef:   T = DW_TAG_typedef;break;
+case DI_TAG_pointer:   T = DW_TAG_pointer_type;   break;
+case DI_TAG_reference: T = DW_TAG_reference_type; break;
+default: assert( 0 && "Unknown tag on derived type");
+}
+
+// Create specific DIE.
+Slot = Ty = new DIE(T);
+
+// Map to main type, void will not have a type.
+if (TypeDesc *FromTy = DerivedTy->getFromType()) {
+   Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Unit, FromTy));
+}
   }
   
   assert(Ty && "Type not supported yet");
  
-  // Add common information.
+  // Add size if non-zero (derived types don't have a size.)
   if (Size) Ty->AddUInt(DW_AT_byte_size, 0, Size);
+  // Add name if not anonymous or intermediate type.
   if (!Name.empty()) Ty->AddString(DW_AT_name, DW_FORM_string, Name);
+  // Add source line info if present.
+  if (CompileUnitDesc *File = TyDesc->getFile()) {
+unsigned FileID = DebugInfo->RecordSource(File);
+int Line = TyDesc->getLine();
+Ty->AddUInt(DW_AT_decl_file, 0, FileID);
+Ty->AddUInt(DW_AT_decl_line, 0, Line);
+  }
 
   // Add to context owner.
   Unit->AddChild(Ty);


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.17 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.18
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.17  Thu Feb 23 16:37:30 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Fri Feb 24 10:46:40 2006
@@ -430,7 +430,9 @@
   case DI_TAG_global_variable: return new GlobalVariableDesc();
   case DI_TAG_subprogram:  return new SubprogramDesc();
   case DI_TAG_basictype:   return new BasicTypeDesc();
-  case DI_TAG_typedef: return new TypedefDesc();
+  case DI_TAG_typedef: return new DerivedTypeDesc(DI_TAG_typedef);
+  case DI_TAG_pointer: return new DerivedTypeDesc(DI_TAG_pointer); 

+  case DI_TAG_reference:   return new DerivedTypeDesc(DI_TAG_reference);
   default: break;
   }
   return NULL;
@@ -566,16 +568,19 @@
 : DebugInfoDesc(T)
 , Context(NULL)
 , Name("")
+, File(NULL)
 , Size(0)
 {}
 
-/// ApplyToFields - Target the visitor to the fields of the  TypeDesc.
+/// ApplyToFields - Target the visitor to the fields of the TypeDesc.
 ///
 void TypeDesc::ApplyToFields(DIVisitor *Visitor) {
   DebugInfoDesc::ApplyToFields(Visitor);
   
   Visitor->Apply(Context);
   Visitor->Apply(Name);
+  Visitor->Apply((DebugInfoDesc *&)File);
+  Visitor->Apply(Line);
   Visitor->Apply(Size);
 }
 
@@ -597,6 +602,8 @@
 << "Tag(" << getTag() << "), "
 << "Context(" << Context << "), "
 << "Name(\"" << Name << "\"), "
+<< "File(" << File << "), "
+<< "Line(" << Line << "), "
 << "Size(" << Size << ")\n";
 }
 #endif
@@ -608,7 +615,7 @@
 , Encoding(0)
 {}
 
-/// ApplyToFields - Target the visitor to the fields of the  BasicTypeD

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-02-23 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.28 -> 1.29
MachineDebugInfo.cpp updated: 1.16 -> 1.17
---
Log message:

Added basic support for typedefs.


---
Diffs of the changes:  (+56 -15)

 DwarfWriter.cpp  |   37 -
 MachineDebugInfo.cpp |   34 --
 2 files changed, 56 insertions(+), 15 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.28 
llvm/lib/CodeGen/DwarfWriter.cpp:1.29
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.28   Thu Feb 23 10:58:18 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppThu Feb 23 16:37:30 2006
@@ -1244,23 +1244,34 @@
   // FIXME - handle larger sizes.
   unsigned Size = TyDesc->getSize() >> 3;
   
-  // Determine how to handle.
-  if (BasicTypeDesc *BasicTyDesc = dyn_cast(TyDesc)) {
-unsigned Encoding = BasicTyDesc->getEncoding();
+  DIE *Ty = NULL;
   
-DIE *Ty = new DIE(DW_TAG_base_type);
-if (!Name.empty())  Ty->AddString(DW_AT_name, DW_FORM_string, Name);
-
-Ty->AddUInt  (DW_AT_byte_size, 0,  Size);
-Ty->AddUInt  (DW_AT_encoding,  DW_FORM_data1,  Encoding);
-
-Slot = Ty;
-  } else {
-assert(0 && "Type not supported yet");
+  // Determine how to handle.
+  if (BasicTypeDesc *BasicTy = dyn_cast(TyDesc)) {
+Slot = Ty = new DIE(DW_TAG_base_type);
+unsigned Encoding = BasicTy->getEncoding();
+Ty->AddUInt  (DW_AT_encoding,  DW_FORM_data1, Encoding);
+  } else if (TypedefDesc *TypedefTy = dyn_cast(TyDesc)) {
+Slot = Ty = new DIE(DW_TAG_typedef);
+TypeDesc *FromTy = TypedefTy->getFromType();
+DIE *FromTyDie = NewType(Unit, FromTy);
+CompileUnitDesc *File = TypedefTy->getFile();
+unsigned FileID = DebugInfo->RecordSource(File);
+int Line = TypedefTy->getLine();
+
+Ty->AddDIEntry(DW_AT_type,  DW_FORM_ref4, FromTyDie);
+Ty->AddUInt   (DW_AT_decl_file, 0,FileID);
+Ty->AddUInt   (DW_AT_decl_line, 0,Line);
   }
+  
+  assert(Ty && "Type not supported yet");
  
+  // Add common information.
+  if (Size) Ty->AddUInt(DW_AT_byte_size, 0, Size);
+  if (!Name.empty()) Ty->AddString(DW_AT_name, DW_FORM_string, Name);
+
   // Add to context owner.
-  Unit->AddChild(Slot);
+  Unit->AddChild(Ty);
   
   return Slot;
 }


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.16 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.17
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.16  Thu Feb 23 10:58:18 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Thu Feb 23 16:37:30 2006
@@ -430,6 +430,7 @@
   case DI_TAG_global_variable: return new GlobalVariableDesc();
   case DI_TAG_subprogram:  return new SubprogramDesc();
   case DI_TAG_basictype:   return new BasicTypeDesc();
+  case DI_TAG_typedef: return new TypedefDesc();
   default: break;
   }
   return NULL;
@@ -561,8 +562,6 @@
 
 
//===--===//
 
-//===--===//
-
 TypeDesc::TypeDesc(unsigned T)
 : DebugInfoDesc(T)
 , Context(NULL)
@@ -627,6 +626,37 @@
 << "Encoding(" << Encoding << ")\n";
 }
 #endif
+//===--===//
+
+TypedefDesc::TypedefDesc()
+: TypeDesc(DI_TAG_typedef)
+, FromType(NULL)
+, File(NULL)
+, Line(0)
+{}
+
+/// ApplyToFields - Target the visitor to the fields of the  TypedefDesc.
+///
+void TypedefDesc::ApplyToFields(DIVisitor *Visitor) {
+  TypeDesc::ApplyToFields(Visitor);
+  
+  Visitor->Apply((DebugInfoDesc *&)FromType);
+  Visitor->Apply((DebugInfoDesc *&)File);
+  Visitor->Apply(Line);
+}
+
+#ifndef NDEBUG
+void TypedefDesc::dump() {
+  std::cerr << getDescString() << " "
+<< "Tag(" << getTag() << "), "
+<< "Context(" << getContext() << "), "
+<< "Name(\"" << getName() << "\"), "
+<< "Size(" << getSize() << "), "
+<< "FromType(" << FromType << "), "
+<< "File(" << File << "), "
+<< "Line(" << Line << ")\n";
+}
+#endif
 
 
//===--===//
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-02-23 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.27 -> 1.28
MachineDebugInfo.cpp updated: 1.15 -> 1.16
---
Log message:

DwarfWriter reading basic type information from llvm-gcc4 code.


---
Diffs of the changes:  (+126 -7)

 DwarfWriter.cpp  |   42 +--
 MachineDebugInfo.cpp |   91 +--
 2 files changed, 126 insertions(+), 7 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.27 
llvm/lib/CodeGen/DwarfWriter.cpp:1.28
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.27   Wed Feb 22 13:02:11 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppThu Feb 23 10:58:18 2006
@@ -1232,7 +1232,40 @@
   GlobalEntities[Name] = Entity;
 }
 
-/// NewCompileUnit - Create new compile unit information.
+/// NewType - Create a new type DIE.
+///
+DIE *DwarfWriter::NewType(DIE *Unit, TypeDesc *TyDesc) {
+  // Check for pre-existence.
+  DIE *&Slot = DescToDieMap[TyDesc];
+  if (Slot) return Slot;
+
+  // Get core information.
+  const std::string &Name = TyDesc->getName();
+  // FIXME - handle larger sizes.
+  unsigned Size = TyDesc->getSize() >> 3;
+  
+  // Determine how to handle.
+  if (BasicTypeDesc *BasicTyDesc = dyn_cast(TyDesc)) {
+unsigned Encoding = BasicTyDesc->getEncoding();
+  
+DIE *Ty = new DIE(DW_TAG_base_type);
+if (!Name.empty())  Ty->AddString(DW_AT_name, DW_FORM_string, Name);
+
+Ty->AddUInt  (DW_AT_byte_size, 0,  Size);
+Ty->AddUInt  (DW_AT_encoding,  DW_FORM_data1,  Encoding);
+
+Slot = Ty;
+  } else {
+assert(0 && "Type not supported yet");
+  }
+ 
+  // Add to context owner.
+  Unit->AddChild(Slot);
+  
+  return Slot;
+}
+
+/// NewCompileUnit - Create new compile unit DIE.
 ///
 DIE *DwarfWriter::NewCompileUnit(CompileUnitDesc *CompileUnit) {
   // Check for pre-existence.
@@ -1275,9 +1308,10 @@
   unsigned FileID = DebugInfo->RecordSource(CompileUnit);
   unsigned Line = GVD->getLine();
   
-  // FIXME - faking the type for the time being.
-  DIE *Type = NewBasicType(Unit, Type::IntTy); 
-
+  // Get the global's type.
+  DIE *Type = NewType(Unit, GVD->getTypeDesc()); 
+
+  // Create the globale variable DIE.
   DIE *VariableDie = new DIE(DW_TAG_variable);
   VariableDie->AddString (DW_AT_name,  DW_FORM_string, Name);
   VariableDie->AddUInt   (DW_AT_decl_file, 0,  FileID);


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.15 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.16
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.15  Wed Feb 22 13:02:11 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Thu Feb 23 10:58:18 2006
@@ -197,6 +197,7 @@
   ///
   virtual void Apply(int &Field) { ++Count; }
   virtual void Apply(unsigned &Field){ ++Count; }
+  virtual void Apply(uint64_t &Field){ ++Count; }
   virtual void Apply(bool &Field){ ++Count; }
   virtual void Apply(std::string &Field) { ++Count; }
   virtual void Apply(DebugInfoDesc *&Field)  { ++Count; }
@@ -230,6 +231,10 @@
 Constant *C = CI->getOperand(I++);
 Field = cast(C)->getValue();
   }
+  virtual void Apply(uint64_t &Field) {
+Constant *C = CI->getOperand(I++);
+Field = cast(C)->getValue();
+  }
   virtual void Apply(bool &Field) {
 Constant *C = CI->getOperand(I++);
 Field = cast(C)->getValue();
@@ -271,6 +276,9 @@
   virtual void Apply(unsigned &Field) {
 Elements.push_back(ConstantUInt::get(Type::UIntTy, Field));
   }
+  virtual void Apply(uint64_t &Field) {
+Elements.push_back(ConstantUInt::get(Type::UIntTy, Field));
+  }
   virtual void Apply(bool &Field) {
 Elements.push_back(ConstantBool::get(Field));
   }
@@ -327,6 +335,9 @@
   virtual void Apply(unsigned &Field) {
 Fields.push_back(Type::UIntTy);
   }
+  virtual void Apply(uint64_t &Field) {
+Fields.push_back(Type::UIntTy);
+  }
   virtual void Apply(bool &Field) {
 Fields.push_back(Type::BoolTy);
   }
@@ -377,6 +388,10 @@
 Constant *C = CI->getOperand(I++);
 IsValid = IsValid && isa(C);
   }
+  virtual void Apply(uint64_t &Field) {
+Constant *C = CI->getOperand(I++);
+IsValid = IsValid && isa(C);
+  }
   virtual void Apply(bool &Field) {
 Constant *C = CI->getOperand(I++);
 IsValid = IsValid && isa(C);
@@ -414,6 +429,7 @@
   case DI_TAG_compile_unit:return new CompileUnitDesc();
   case DI_TAG_global_variable: return new GlobalVariableDesc();
   case DI_TAG_subprogram:  return new SubprogramDesc();
+  case DI_TAG_basictype:   return new BasicTypeDesc();
   default: break;
   }
   return NULL;
@@ -545,6 +561,75 @@
 
 
//===--===//
 
+//===--===//
+
+TypeDesc::TypeDesc(unsigned T)
+: DebugInfoDesc(T)
+, Context(NULL)
+, Name("")
+, Size(0)
+{}
+
+/// ApplyToFields - Targ

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-02-22 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.26 -> 1.27
MachineDebugInfo.cpp updated: 1.14 -> 1.15
---
Log message:

Coordinate activities with llvm-gcc4 and dwarf.


---
Diffs of the changes:  (+257 -195)

 DwarfWriter.cpp  |  406 ++-
 MachineDebugInfo.cpp |   46 +
 2 files changed, 257 insertions(+), 195 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.26 
llvm/lib/CodeGen/DwarfWriter.cpp:1.27
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.26   Tue Feb 14 16:01:57 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppWed Feb 22 13:02:11 2006
@@ -774,12 +774,11 @@
 
 
//===--===//
 
-DIE::DIE(unsigned Tag, unsigned ChildrenFlag)
-: Abbrev(new DIEAbbrev(Tag, ChildrenFlag))
+DIE::DIE(unsigned Tag)
+: Abbrev(new DIEAbbrev(Tag, DW_CHILDREN_no))
 , AbbrevID(0)
 , Offset(0)
 , Size(0)
-, Context(NULL)
 , Children()
 , Values()
 {}
@@ -794,8 +793,6 @@
   for (unsigned j = 0, M = Values.size(); j < M; ++j) {
 delete Values[j];
   }
-  
-  if (Context) delete Context;
 }
 
 /// AddUInt - Add an unsigned integer attribute data and value.
@@ -875,115 +872,14 @@
 /// AddChild - Add a child to the DIE.
 ///
 void DIE::AddChild(DIE *Child) {
+  assert(Abbrev && "Adding children without an abbreviation");
+  Abbrev->setChildrenFlag(DW_CHILDREN_yes);
   Children.push_back(Child);
 }
 
 
//===--===//
 
-/// NewBasicType - Creates a new basic type if necessary, then adds to the
-/// context and owner.
-DIE *DWContext::NewBasicType(const Type *Ty, unsigned Size, unsigned Align) {
-  DIE *TypeDie = Types[Ty];
-  
-  // If first occurance of type.
-  if (!TypeDie) {
-const char *Name;
-unsigned Encoding = 0;
-
-switch (Ty->getTypeID()) {
-case Type::UByteTyID:
-  Name = "unsigned char";
-  Encoding = DW_ATE_unsigned_char;
-  break;
-case Type::SByteTyID:
-  Name = "char";
-  Encoding = DW_ATE_signed_char;
-  break;
-case Type::UShortTyID:
-  Name = "unsigned short";
-  Encoding = DW_ATE_unsigned;
-  break;
-case Type::ShortTyID:
-  Name = "short";
-  Encoding = DW_ATE_signed;
-  break;
-case Type::UIntTyID:
-  Name = "unsigned int";
-  Encoding = DW_ATE_unsigned;
-  break;
-case Type::IntTyID:
-  Name = "int";
-  Encoding = DW_ATE_signed;
-  break;
-case Type::ULongTyID:
-  Name = "unsigned long long";
-  Encoding = DW_ATE_unsigned;
-  break;
-case Type::LongTyID:
-  Name = "long long";
-  Encoding = DW_ATE_signed;
-  break;
-case Type::FloatTyID:
-  Name = "float";
-  Encoding = DW_ATE_float;
-  break;
-case Type::DoubleTyID:
-  Name = "float";
-  Encoding = DW_ATE_float;
-  break;
-default: 
-// FIXME - handle more complex types.
-  Name = "unknown";
-  Encoding = DW_ATE_address;
-  break;
-}
-
-// construct the type DIE.
-TypeDie = new DIE(DW_TAG_base_type, DW_CHILDREN_no);
-TypeDie->AddString(DW_AT_name,  DW_FORM_string, Name);
-TypeDie->AddUInt  (DW_AT_byte_size, 0,  Size);
-TypeDie->AddUInt  (DW_AT_encoding,  DW_FORM_data1,  Encoding);
-TypeDie->Complete(DW);
-
-// Add to context owner.
-Owner->AddChild(TypeDie);
-
-// Add to map.
-Types[Ty] = TypeDie;
-  }
-  
-  return TypeDie;
-}
-
-/// NewGlobalVariable - Creates a global variable, if necessary, then adds in
-/// the context and owner.
-DIE *DWContext::NewGlobalVariable(const std::string &Name,
-  const std::string &MangledName,
-  DIE *Type) {
-  DIE *VariableDie = Variables[MangledName];
-  
-  // If first occurance of variable.
-  if (!VariableDie) {
-// FIXME - need source file name line number.
-VariableDie = new DIE(DW_TAG_variable, DW_CHILDREN_no);
-VariableDie->AddString (DW_AT_name,  DW_FORM_string, Name);
-VariableDie->AddUInt   (DW_AT_decl_file, 0,  0);
-VariableDie->AddUInt   (DW_AT_decl_line, 0,  0);
-VariableDie->AddDIEntry(DW_AT_type,  DW_FORM_ref4,   Type);
-VariableDie->AddUInt   (DW_AT_external,  DW_FORM_flag,   1);
-// FIXME - needs to be a proper expression.
-VariableDie->AddObjectLabel(DW_AT_location,  DW_FORM_block1, MangledName);
-VariableDie->Complete(DW);
- 
-// Add to context owner.
-Owner->AddChild(VariableDie);
-
-// Add to map.
-Variables[MangledName] = VariableDie;
-  }
-  
-  return VariableDie;
-}
+/// DWContext
 
 
//===--===//
 
@@ -1088,14 +984,14 @@
 ///
 void DwarfWriter::EmitInt8(int Value) const {
   O << Asm->Data8bitsDirective;
-  PrintHex(Value);
+  PrintHex(Value & 0

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-02-06 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.24 -> 1.25
MachineDebugInfo.cpp updated: 1.9 -> 1.10
---
Log message:

Changing model for the construction of debug information.


---
Diffs of the changes:  (+626 -106)

 DwarfWriter.cpp  |   22 -
 MachineDebugInfo.cpp |  710 ---
 2 files changed, 626 insertions(+), 106 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.24 
llvm/lib/CodeGen/DwarfWriter.cpp:1.25
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.24   Fri Jan 27 14:31:25 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppMon Feb  6 09:33:21 2006
@@ -1269,16 +1269,16 @@
 
 /// NewCompileUnit - Create new compile unit information.
 ///
-DIE *DwarfWriter::NewCompileUnit(const CompileUnitWrapper &CompileUnit) {
+DIE *DwarfWriter::NewCompileUnit(const CompileUnitDesc *CompileUnit) {
   DIE *Unit = new DIE(DW_TAG_compile_unit, DW_CHILDREN_yes);
   // FIXME - use the correct line set.
   Unit->AddLabel (DW_AT_stmt_list, DW_FORM_data4,  DWLabel("line", 0));
   Unit->AddLabel (DW_AT_high_pc,   DW_FORM_addr,   DWLabel("text_end", 0));
   Unit->AddLabel (DW_AT_low_pc,DW_FORM_addr,   DWLabel("text_begin", 0));
-  Unit->AddString(DW_AT_producer,  DW_FORM_string, CompileUnit.getProducer());
-  Unit->AddUInt  (DW_AT_language,  DW_FORM_data1,  CompileUnit.getLanguage());
-  Unit->AddString(DW_AT_name,  DW_FORM_string, CompileUnit.getFileName());
-  Unit->AddString(DW_AT_comp_dir,  DW_FORM_string, CompileUnit.getDirectory());
+  Unit->AddString(DW_AT_producer,  DW_FORM_string, CompileUnit->getProducer());
+  Unit->AddUInt  (DW_AT_language,  DW_FORM_data1,  CompileUnit->getLanguage());
+  Unit->AddString(DW_AT_name,  DW_FORM_string, CompileUnit->getFileName());
+  Unit->AddString(DW_AT_comp_dir,  DW_FORM_string, 
CompileUnit->getDirectory());
   Unit->Complete(*this);
   
   return Unit;
@@ -1723,11 +1723,10 @@
 /// ConstructCompileUnitDIEs - Create a compile unit DIE for each source and
 /// header file.
 void DwarfWriter::ConstructCompileUnitDIEs() {
-  const UniqueVector CUW = DebugInfo->getCompileUnits();
+  const UniqueVector CUW = DebugInfo->getCompileUnits();
   
   for (unsigned i = 1, N = CUW.size(); i <= N; ++i) {
-const CompileUnitWrapper &CompileUnit = CUW[i];
-DIE *Unit = NewCompileUnit(CompileUnit);
+DIE *Unit = NewCompileUnit(CUW[i]);
 DWContext *Context = new DWContext(*this, NULL, Unit);
 CompileUnits.push_back(Unit);
   }
@@ -1738,11 +1737,12 @@
 void DwarfWriter::ConstructGlobalDIEs(Module &M) {
   const TargetData &TD = Asm->TM.getTargetData();
   
-  std::vector GlobalVariables = 
DebugInfo->getGlobalVariables(M);
+  std::vector GlobalVariables =
+   
DebugInfo->getGlobalVariables(M);
   
   for (unsigned i = 0, N = GlobalVariables.size(); i < N; ++i) {
-GlobalWrapper &GW = GlobalVariables[i];
-GlobalVariable *GV = GW.getGlobalVariable();
+GlobalVariableDesc *GVD = GlobalVariables[i];
+GlobalVariable *GV = GVD->getGlobalVariable();
 
 if (!GV->hasInitializer()) continue;   // External global require no code
 


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.9 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.10
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.9   Fri Jan 27 11:31:30 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Mon Feb  6 09:33:21 2006
@@ -11,11 +11,14 @@
 
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
+#include "llvm/GlobalVariable.h"
 #include "llvm/Intrinsics.h"
 #include "llvm/Instructions.h"
 #include "llvm/Module.h"
 #include "llvm/Support/Dwarf.h"
 
+#include 
+
 using namespace llvm;
 
 // Handle the Pass registration stuff necessary to use TargetData's.
@@ -25,14 +28,14 @@
 
 
//===--===//
 
-/// getGlobalVariablesUsing - Return all of the global variables which have the
+/// getGlobalVariablesUsing - Return all of the GlobalVariables which have the
 /// specified value in their initializer somewhere.
 static void
 getGlobalVariablesUsing(Value *V, std::vector &Result) {
   // Scan though value users.
   for (Value::use_iterator I = V->use_begin(), E = V->use_end(); I != E; ++I) {
 if (GlobalVariable *GV = dyn_cast(*I)) {
-  // If the user is a global variable then add to result.
+  // If the user is a GlobalVariable then add to result.
   Result.push_back(GV);
 } else if (Constant *C = dyn_cast(*I)) {
   // If the user is a constant variable then scan its users
@@ -41,13 +44,13 @@
   }
 }
 
-/// getGlobalVariablesUsing - Return all of the global variables that use the
-/// named global variable.
+/// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
+/// named GlobalVariable.
 static std::vector
 getGlobalVariablesUsing(Module &M, const std::string &RootName) {
-  std::vector Result;  // Glob

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-01-27 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.19 -> 1.20
MachineDebugInfo.cpp updated: 1.6 -> 1.7
---
Log message:

Improve visibility/correctness of operand indices in "llvm.db" objects.
Handle 64 in DIEs.


---
Diffs of the changes:  (+71 -48)

 DwarfWriter.cpp  |   59 --
 MachineDebugInfo.cpp |   60 +++
 2 files changed, 71 insertions(+), 48 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.19 
llvm/lib/CodeGen/DwarfWriter.cpp:1.20
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.19   Thu Jan 26 15:22:49 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppFri Jan 27 09:20:54 2006
@@ -674,6 +674,7 @@
   case DW_FORM_data1: DW.EmitByte(Integer); break;
   case DW_FORM_data2: DW.EmitShort(Integer);break;
   case DW_FORM_data4: DW.EmitLong(Integer); break;
+  case DW_FORM_data8: DW.EmitLongLong(Integer); break;
   case DW_FORM_udata: DW.EmitULEB128Bytes(Integer); break;
   case DW_FORM_sdata: DW.EmitSLEB128Bytes(Integer); break;
   default: assert(0 && "DIE Value form not supported yet"); break;
@@ -688,6 +689,7 @@
   case DW_FORM_data1: return sizeof(int8_t);
   case DW_FORM_data2: return sizeof(int16_t);
   case DW_FORM_data4: return sizeof(int32_t);
+  case DW_FORM_data8: return sizeof(int64_t);
   case DW_FORM_udata: return DW.SizeULEB128(Integer);
   case DW_FORM_sdata: return DW.SizeSLEB128(Integer);
   default: assert(0 && "DIE Value form not supported yet"); break;
@@ -796,20 +798,27 @@
   if (Context) delete Context;
 }
 
-/// AddInt - Add a simple integer attribute data and value.
+/// AddUInt - Add an unsigned integer attribute data and value.
 ///
-void DIE::AddInt(unsigned Attribute, unsigned Form,
- int Integer, bool IsSigned) {
+void DIE::AddUInt(unsigned Attribute, unsigned Form, uint64_t Integer) {
   if (Form == 0) {
-if (IsSigned) {
-  if ((char)Integer == Integer)   Form = DW_FORM_data1;
-  else if ((short)Integer == Integer) Form = DW_FORM_data2;
-  elseForm = DW_FORM_data4;
-} else {
   if ((unsigned char)Integer == Integer)   Form = DW_FORM_data1;
   else if ((unsigned short)Integer == Integer) Form = DW_FORM_data2;
-  else Form = DW_FORM_data4;
-}
+  else if ((unsigned int)Integer == Integer)   Form = DW_FORM_data4;
+  else Form = DW_FORM_data8;
+  }
+  Abbrev->AddAttribute(Attribute, Form);
+  Values.push_back(new DIEInteger(Integer));
+}
+
+/// AddSInt - Add an signed integer attribute data and value.
+///
+void DIE::AddSInt(unsigned Attribute, unsigned Form, int64_t Integer) {
+  if (Form == 0) {
+  if ((char)Integer == Integer)   Form = DW_FORM_data1;
+  else if ((short)Integer == Integer) Form = DW_FORM_data2;
+  else if ((int)Integer == Integer)   Form = DW_FORM_data4;
+  elseForm = DW_FORM_data8;
   }
   Abbrev->AddAttribute(Attribute, Form);
   Values.push_back(new DIEInteger(Integer));
@@ -932,8 +941,8 @@
 // construct the type DIE.
 TypeDie = new DIE(DW_TAG_base_type, DW_CHILDREN_no);
 TypeDie->AddString(DW_AT_name,  DW_FORM_string, Name);
-TypeDie->AddInt   (DW_AT_byte_size, DW_FORM_data1,  Size);
-TypeDie->AddInt   (DW_AT_encoding,  DW_FORM_data1,  Encoding);
+TypeDie->AddUInt  (DW_AT_byte_size, DW_FORM_data1,  Size);
+TypeDie->AddUInt  (DW_AT_encoding,  DW_FORM_data1,  Encoding);
 TypeDie->Complete(DW);
 
 // Add to context owner.
@@ -958,10 +967,10 @@
 // FIXME - need source file name line number.
 VariableDie = new DIE(DW_TAG_variable, DW_CHILDREN_no);
 VariableDie->AddString (DW_AT_name,  DW_FORM_string, Name);
-VariableDie->AddInt(DW_AT_decl_file, 0,  0);
-VariableDie->AddInt(DW_AT_decl_line, 0,  0);
+VariableDie->AddUInt   (DW_AT_decl_file, 0,  0);
+VariableDie->AddUInt   (DW_AT_decl_line, 0,  0);
 VariableDie->AddDIEntry(DW_AT_type,  DW_FORM_ref4,   Type);
-VariableDie->AddInt(DW_AT_external,  DW_FORM_flag,   1);
+VariableDie->AddUInt   (DW_AT_external,  DW_FORM_flag,   1);
 // FIXME - needs to be a proper expression.
 VariableDie->AddObjectLabel(DW_AT_location,  DW_FORM_block1, MangledName);
 VariableDie->Complete(DW);
@@ -1096,6 +1105,24 @@
   PrintHex(Value);
 }
 
+/// EmitLongLong - Emit a long long directive and value.
+///
+void DwarfWriter::EmitLongLong(uint64_t Value) const {
+  if (Asm->Data64bitsDirective) {
+O << Asm->Data64bitsDirective << "0x" << std::hex << Value << std::dec;
+  } else {
+const TargetData &TD = Asm->TM.getTargetData();
+
+if (TD.isBigEndian()) {
+  EmitLong(unsigned(Value >> 32)); O << "\n";
+  EmitLo

[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

2006-01-26 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.18 -> 1.19
MachineDebugInfo.cpp updated: 1.5 -> 1.6
---
Log message:

Use global information to fill out Dwarf compile units.


---
Diffs of the changes:  (+18 -22)

 DwarfWriter.cpp  |   30 ++
 MachineDebugInfo.cpp |   10 --
 2 files changed, 18 insertions(+), 22 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.18 
llvm/lib/CodeGen/DwarfWriter.cpp:1.19
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.18   Thu Jan 26 14:21:46 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppThu Jan 26 15:22:49 2006
@@ -1242,20 +1242,16 @@
 
 /// NewCompileUnit - Create new compile unit information.
 ///
-DIE *DwarfWriter::NewCompileUnit(const std::string &Directory,
- const std::string &SourceName) {
+DIE *DwarfWriter::NewCompileUnit(const CompileUnitWrapper &CompileUnit) {
   DIE *Unit = new DIE(DW_TAG_compile_unit, DW_CHILDREN_yes);
   // FIXME - use the correct line set.
   Unit->AddLabel (DW_AT_stmt_list, DW_FORM_data4,  DWLabel("line", 0));
   Unit->AddLabel (DW_AT_high_pc,   DW_FORM_addr,   DWLabel("text_end", 0));
   Unit->AddLabel (DW_AT_low_pc,DW_FORM_addr,   DWLabel("text_begin", 0));
-  // FIXME - The producer needs to be in this form, but should come from
-  // an appropriate source.
-  Unit->AddString(DW_AT_producer,  DW_FORM_string,
-  "llvm 3.4.x (LLVM Research Group)");
-  Unit->AddInt   (DW_AT_language,  DW_FORM_data1,  DW_LANG_C89);
-  Unit->AddString(DW_AT_name,  DW_FORM_string, SourceName);
-  Unit->AddString(DW_AT_comp_dir,  DW_FORM_string, Directory);
+  Unit->AddString(DW_AT_producer,  DW_FORM_string, CompileUnit.getProducer());
+  Unit->AddInt   (DW_AT_language,  DW_FORM_data1,  CompileUnit.getLanguage());
+  Unit->AddString(DW_AT_name,  DW_FORM_string, CompileUnit.getFileName());
+  Unit->AddString(DW_AT_comp_dir,  DW_FORM_string, CompileUnit.getDirectory());
   Unit->Complete(*this);
   
   return Unit;
@@ -1700,17 +1696,11 @@
 /// ConstructCompileUnitDIEs - Create a compile unit DIE for each source and
 /// header file.
 void DwarfWriter::ConstructCompileUnitDIEs() {
-  // Get directory and source information.
-  const UniqueVector &Directories = DebugInfo->getDirectories();
-  const UniqueVector &SourceFiles = 
DebugInfo->getSourceFiles();
-
-  // Construct compile unit DIEs for each source.
-  for (unsigned SourceID = 1, NSID = SourceFiles.size();
-SourceID <=  NSID; ++SourceID) {
-const SourceFileInfo &SourceFile = SourceFiles[SourceID];
-const std::string &Directory = Directories[SourceFile.getDirectoryID()];
-const std::string &SourceName = SourceFile.getName();
-DIE *Unit = NewCompileUnit(Directory, SourceName);
+  const UniqueVector CUW = DebugInfo->getCompileUnits();
+  
+  for (unsigned i = 1, N = CUW.size(); i <= N; ++i) {
+const CompileUnitWrapper &CompileUnit = CUW[i];
+DIE *Unit = NewCompileUnit(CompileUnit);
 DWContext *Context = new DWContext(*this, NULL, Unit);
 CompileUnits.push_back(Unit);
   }


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.5 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.6
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.5   Thu Jan 26 14:21:46 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Thu Jan 26 15:22:49 2006
@@ -180,7 +180,7 @@
 /// getContext - Return the "lldb.compile_unit" context global.
 ///
 GlobalVariable *GlobalWrapper::getContext() const {
-  return dyn_cast(IC->getOperand(1));
+  return cast(IC->getOperand(1));
 }
 
 /// getName - Return the name of the global.
@@ -192,7 +192,7 @@
 /// getType - Return the type of the global.
 ///
 const GlobalVariable *GlobalWrapper::getType() const {
-  return dyn_cast(IC->getOperand(4));
+  return cast(IC->getOperand(4));
 }
 
 /// isStatic - Return true if the global is static.
@@ -274,6 +274,12 @@
   if (CompileUnits.size() != Globals.size()) CompileUnits.reset();
 }
 
+/// getCompileUnits - Return a vector of debug compile units.
+///
+const UniqueVector 
MachineDebugInfo::getCompileUnits()const{
+  return CompileUnits;
+}
+
 /// getGlobalVariables - Return a vector of debug global variables.
 ///
 std::vector MachineDebugInfo::getGlobalVariables(Module &M) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits