remove dead makefile flags.
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfWriter.cpp
1 //===-- llvm/CodeGen/DwarfWriter.cpp - Dwarf Framework --------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains support for writing dwarf info into asm files.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/CodeGen/DwarfWriter.h"
15 #include "DwarfDebug.h"
16 #include "DwarfException.h"
17 #include "llvm/CodeGen/MachineModuleInfo.h"
18
19 using namespace llvm;
20
21 static RegisterPass<DwarfWriter>
22 X("dwarfwriter", "DWARF Information Writer");
23 char DwarfWriter::ID = 0;
24
25 //===----------------------------------------------------------------------===//
26 /// DwarfWriter Implementation
27 ///
28
29 DwarfWriter::DwarfWriter()
30   : ImmutablePass(&ID), DD(0), DE(0) {}
31
32 DwarfWriter::~DwarfWriter() {
33   delete DE;
34   delete DD;
35 }
36
37 /// BeginModule - Emit all Dwarf sections that should come prior to the
38 /// content.
39 void DwarfWriter::BeginModule(Module *M,
40                               MachineModuleInfo *MMI,
41                               raw_ostream &OS, AsmPrinter *A,
42                               const TargetAsmInfo *T) {
43   DE = new DwarfException(OS, A, T);
44   DD = new DwarfDebug(OS, A, T);
45   DE->BeginModule(M);
46   DD->BeginModule(M);
47   DD->SetDebugInfo(MMI);
48   DE->SetModuleInfo(MMI);
49 }
50
51 /// EndModule - Emit all Dwarf sections that should come after the content.
52 ///
53 void DwarfWriter::EndModule() {
54   DE->EndModule();
55   DD->EndModule();
56 }
57
58 /// BeginFunction - Gather pre-function debug information.  Assumes being
59 /// emitted immediately after the function entry point.
60 void DwarfWriter::BeginFunction(MachineFunction *MF) {
61   DE->BeginFunction(MF);
62   DD->BeginFunction(MF);
63 }
64
65 /// EndFunction - Gather and emit post-function debug information.
66 ///
67 void DwarfWriter::EndFunction(MachineFunction *MF) {
68   DD->EndFunction(MF);
69   DE->EndFunction();
70
71   if (MachineModuleInfo *MMI = DD->getMMI() ? DD->getMMI() : DE->getMMI())
72     // Clear function debug information.
73     MMI->EndFunction();
74 }
75
76 /// RecordSourceLine - Records location information and associates it with a 
77 /// label. Returns a unique label ID used to generate a label and provide
78 /// correspondence to the source line list.
79 unsigned DwarfWriter::RecordSourceLine(unsigned Line, unsigned Col, 
80                                        DICompileUnit CU) {
81   return DD->RecordSourceLine(Line, Col, CU);
82 }
83
84 /// RecordRegionStart - Indicate the start of a region.
85 unsigned DwarfWriter::RecordRegionStart(GlobalVariable *V) {
86   return DD->RecordRegionStart(V);
87 }
88
89 /// RecordRegionEnd - Indicate the end of a region.
90 unsigned DwarfWriter::RecordRegionEnd(GlobalVariable *V) {
91   return DD->RecordRegionEnd(V);
92 }
93
94 /// getRecordSourceLineCount - Count source lines.
95 unsigned DwarfWriter::getRecordSourceLineCount() {
96   return DD->getRecordSourceLineCount();
97 }
98
99 /// RecordVariable - Indicate the declaration of  a local variable.
100 ///
101 void DwarfWriter::RecordVariable(GlobalVariable *GV, unsigned FrameIndex,
102                                  const MachineInstr *MI) {
103   DD->RecordVariable(GV, FrameIndex, MI);
104 }
105
106 /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
107 /// be emitted.
108 bool DwarfWriter::ShouldEmitDwarfDebug() const {
109   return DD && DD->ShouldEmitDwarfDebug();
110 }
111
112 //// RecordInlinedFnStart - Global variable GV is inlined at the location marked
113 //// by LabelID label.
114 unsigned DwarfWriter::RecordInlinedFnStart(DISubprogram SP, DICompileUnit CU,
115                                            unsigned Line, unsigned Col) {
116   return DD->RecordInlinedFnStart(SP, CU, Line, Col);
117 }
118
119 /// RecordInlinedFnEnd - Indicate the end of inlined subroutine.
120 unsigned DwarfWriter::RecordInlinedFnEnd(DISubprogram SP) {
121   return DD->RecordInlinedFnEnd(SP);
122 }
123
124 /// RecordVariableScope - Record scope for the variable declared by
125 /// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE.
126 void DwarfWriter::RecordVariableScope(DIVariable &DV,
127                                       const MachineInstr *DeclareMI) {
128   DD->RecordVariableScope(DV, DeclareMI);
129 }