llvm-6502/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
Chris Lattner c608784dc8 reapply r98035:
Now that setStartLabel takes an MCSymbol, we can de-ID'ize
beginScope and RecordSourceLine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98047 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-09 04:54:43 +00:00

101 lines
3.0 KiB
C++

//===-- llvm/CodeGen/DwarfWriter.cpp - Dwarf Framework --------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains support for writing dwarf info into asm files.
//
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/DwarfWriter.h"
#include "DwarfDebug.h"
#include "DwarfException.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
using namespace llvm;
static RegisterPass<DwarfWriter>
X("dwarfwriter", "DWARF Information Writer");
char DwarfWriter::ID = 0;
//===----------------------------------------------------------------------===//
/// DwarfWriter Implementation
///
DwarfWriter::DwarfWriter()
: ImmutablePass(&ID), DD(0), DE(0) {}
DwarfWriter::~DwarfWriter() {
delete DE;
delete DD;
}
/// BeginModule - Emit all Dwarf sections that should come prior to the
/// content.
void DwarfWriter::BeginModule(Module *M,
MachineModuleInfo *MMI,
raw_ostream &OS, AsmPrinter *A,
const MCAsmInfo *T) {
DE = new DwarfException(OS, A, T);
DD = new DwarfDebug(OS, A, T);
DE->BeginModule(M, MMI);
DD->beginModule(M, MMI);
}
/// EndModule - Emit all Dwarf sections that should come after the content.
///
void DwarfWriter::EndModule() {
DE->EndModule();
DD->endModule();
delete DD; DD = 0;
delete DE; DE = 0;
}
/// BeginFunction - Gather pre-function debug information. Assumes being
/// emitted immediately after the function entry point.
void DwarfWriter::BeginFunction(const MachineFunction *MF) {
DE->BeginFunction(MF);
DD->beginFunction(MF);
}
/// EndFunction - Gather and emit post-function debug information.
///
void DwarfWriter::EndFunction(const MachineFunction *MF) {
DD->endFunction(MF);
DE->EndFunction();
if (MachineModuleInfo *MMI = DD->getMMI() ? DD->getMMI() : DE->getMMI())
// Clear function debug information.
MMI->EndFunction();
}
/// RecordSourceLine - Register a source line with debug info. Returns the
/// unique label that was emitted and which provides correspondence to
/// the source line list.
MCSymbol *DwarfWriter::RecordSourceLine(unsigned Line, unsigned Col,
MDNode *Scope) {
return DD->recordSourceLine(Line, Col, Scope);
}
/// getRecordSourceLineCount - Count source lines.
unsigned DwarfWriter::getRecordSourceLineCount() {
return DD->getSourceLineCount();
}
/// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
/// be emitted.
bool DwarfWriter::ShouldEmitDwarfDebug() const {
return DD && DD->ShouldEmitDwarfDebug();
}
void DwarfWriter::BeginScope(const MachineInstr *MI, MCSymbol *L) {
DD->beginScope(MI, L);
}
void DwarfWriter::EndScope(const MachineInstr *MI) {
DD->endScope(MI);
}