1 //===-- llvm/CodeGen/DwarfWriter.cpp - Dwarf Framework --------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains support for writing dwarf info into asm files.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/DwarfWriter.h"
15 #include "DwarfDebug.h"
16 #include "DwarfException.h"
17 #include "llvm/CodeGen/MachineModuleInfo.h"
21 static RegisterPass<DwarfWriter>
22 X("dwarfwriter", "DWARF Information Writer");
23 char DwarfWriter::ID = 0;
25 //===----------------------------------------------------------------------===//
26 /// DwarfWriter Implementation
29 DwarfWriter::DwarfWriter()
30 : ImmutablePass(&ID), DD(0), DE(0) {}
32 DwarfWriter::~DwarfWriter() {
37 /// BeginModule - Emit all Dwarf sections that should come prior to the
39 void DwarfWriter::BeginModule(Module *M, AsmPrinter *A) {
40 DE = new DwarfException(A);
41 DD = new DwarfDebug(A, M);
44 /// EndModule - Emit all Dwarf sections that should come after the content.
46 void DwarfWriter::EndModule() {
53 /// BeginFunction - Gather pre-function debug information. Assumes being
54 /// emitted immediately after the function entry point.
55 void DwarfWriter::BeginFunction(const MachineFunction *MF) {
56 DE->BeginFunction(MF);
57 DD->beginFunction(MF);
60 /// EndFunction - Gather and emit post-function debug information.
62 void DwarfWriter::EndFunction(const MachineFunction *MF) {
66 if (MachineModuleInfo *MMI = DE->MMI)
67 // Clear function debug information.
71 /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
73 bool DwarfWriter::ShouldEmitDwarfDebug() const {
74 return DD && DD->MMI->hasDebugInfo();
77 void DwarfWriter::BeginScope(const MachineInstr *MI) {
80 void DwarfWriter::EndScope(const MachineInstr *MI) {