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

Jim Laskey jlaskey at apple.com
Wed Jan 4 05:52:43 PST 2006



Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.34 -> 1.35
DwarfWriter.cpp updated: 1.2 -> 1.3
---
Log message:

Tie dwarf generation to darwin assembler.


---
Diffs of the changes:  (+96 -0)

 AsmPrinter.cpp  |    1 
 DwarfWriter.cpp |   95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.34 llvm/lib/CodeGen/AsmPrinter.cpp:1.35
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.34	Wed Dec 28 00:29:02 2005
+++ llvm/lib/CodeGen/AsmPrinter.cpp	Wed Jan  4 07:52:30 2006
@@ -16,6 +16,7 @@
 #include "llvm/Constants.h"
 #include "llvm/Module.h"
 #include "llvm/CodeGen/MachineConstantPool.h"
+#include "llvm/CodeGen/MachineDebugInfo.h"
 #include "llvm/Support/Mangler.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Target/TargetMachine.h"


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.2 llvm/lib/CodeGen/DwarfWriter.cpp:1.3
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.2	Wed Dec 21 19:41:00 2005
+++ llvm/lib/CodeGen/DwarfWriter.cpp	Wed Jan  4 07:52:30 2006
@@ -12,4 +12,99 @@
 //===----------------------------------------------------------------------===//
 
 
+#include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/DwarfWriter.h"
+#include "llvm/Support/CommandLine.h"
+
+
+namespace llvm {
+
+static cl::opt<bool>
+DwarfVerbose("dwarf-verbose", cl::Hidden,
+                                cl::desc("Add comments to dwarf directives."));
+
+/// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
+/// unsigned leb128 value.
+///
+void DwarfWriter::EmitULEB128Bytes(unsigned Value, std::string Comment) {
+  if (hasLEB128) {
+    O << "\t.uleb128\t"
+      << Value;
+  } else {
+    O << Asm->getData8bitsDirective();
+    EmitULEB128(Value);
+  }
+  if (DwarfVerbose) {
+    O << "\t"
+      << Asm->getCommentString()
+      << " "
+      << Comment
+      << " "
+      << Value;
+  }
+  O << "\n";
+}
+
+/// EmitSLEB128Bytes - Emit an assembler byte data directive to compose a
+/// signed leb128 value.
+///
+void DwarfWriter::EmitSLEB128Bytes(int Value, std::string Comment) {
+  if (hasLEB128) {
+    O << "\t.sleb128\t"
+      << Value;
+  } else {
+    O << Asm->getData8bitsDirective();
+    EmitSLEB128(Value);
+  }
+  if (DwarfVerbose) {
+    O << "\t"
+      << Asm->getCommentString()
+      << " "
+      << Comment
+      << " "
+      << Value;
+  }
+  O << "\n";
+}
+
+/// BeginModule - Emit all dwarf sections that should come prior to the content.
+///
+void DwarfWriter::BeginModule() {
+  EmitComment("Dwarf Begin Module");
+  
+  // define base addresses for dwarf sections
+  Asm->SwitchSection(DwarfAbbrevSection, 0);
+  EmitLabel("abbrev", 0);
+  Asm->SwitchSection(DwarfInfoSection, 0);
+  EmitLabel("info", 0);
+  Asm->SwitchSection(DwarfLineSection, 0);
+  EmitLabel("line", 0);
+}
+
+/// EndModule - Emit all dwarf sections that should come after the content.
+///
+void DwarfWriter::EndModule() {
+  EmitComment("Dwarf End Module");
+  // Print out dwarf file info
+  std::vector<std::string> Sources = DebugInfo.getSourceFiles();
+  for (unsigned i = 0, N = Sources.size(); i < N; i++) {
+    O << "\t; .file\t" << (i + 1) << "," << "\"" << Sources[i]  << "\"" << "\n";
+  }
+}
+
+
+/// BeginFunction - Emit pre-function debug information.
+///
+void DwarfWriter::BeginFunction() {
+  EmitComment("Dwarf Begin Function");
+}
+
+/// EndFunction - Emit post-function debug information.
+///
+void DwarfWriter::EndFunction() {
+  EmitComment("Dwarf End Function");
+}
+
+
+} // End llvm namespace
+






More information about the llvm-commits mailing list