diff options
author | Jim Laskey <jlaskey@mac.com> | 2006-01-04 13:52:30 +0000 |
---|---|---|
committer | Jim Laskey <jlaskey@mac.com> | 2006-01-04 13:52:30 +0000 |
commit | b0609d91c3953f199e3d9b496f6ae6cc28ff76e4 (patch) | |
tree | 70a4b84ee057b104d045469f27ef9f308f5a16c2 /llvm/lib/CodeGen | |
parent | 1e8731ef6012744927b2000404876338956a911f (diff) | |
download | bcm5719-llvm-b0609d91c3953f199e3d9b496f6ae6cc28ff76e4.tar.gz bcm5719-llvm-b0609d91c3953f199e3d9b496f6ae6cc28ff76e4.zip |
Tie dwarf generation to darwin assembler.
llvm-svn: 25093
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/CodeGen/DwarfWriter.cpp | 95 |
2 files changed, 96 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter.cpp index 5fdfbfd5a30..475928250e5 100644 --- a/llvm/lib/CodeGen/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter.cpp @@ -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" diff --git a/llvm/lib/CodeGen/DwarfWriter.cpp b/llvm/lib/CodeGen/DwarfWriter.cpp index dcfb6e4e0ef..2fc65e6f956 100644 --- a/llvm/lib/CodeGen/DwarfWriter.cpp +++ b/llvm/lib/CodeGen/DwarfWriter.cpp @@ -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 + |