Add DwarfWriter interface to mainipulate source location info.
[oota-llvm.git] / include / llvm / CodeGen / DwarfWriter.h
1 //===-- llvm/CodeGen/DwarfWriter.h - Dwarf Framework ------------*- C++ -*-===//
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 debug and exception info into
11 // asm files.  For Details on the Dwarf 3 specfication see DWARF Debugging
12 // Information Format V.3 reference manual http://dwarf.freestandards.org ,
13 //
14 // The role of the Dwarf Writer class is to extract information from the
15 // MachineModuleInfo object, organize it in Dwarf form and then emit it into asm
16 // the current asm file using data and high level Dwarf directives.
17 // 
18 //===----------------------------------------------------------------------===//
19
20 #ifndef LLVM_CODEGEN_DWARFWRITER_H
21 #define LLVM_CODEGEN_DWARFWRITER_H
22
23 #include "llvm/Pass.h"
24
25 namespace llvm {
26
27 class AsmPrinter;
28 class DwarfDebug;
29 class DwarfException;
30 class MachineModuleInfo;
31 class MachineFunction;
32 class Module;
33 class GlobalVariable;
34 class TargetAsmInfo;
35 class raw_ostream;
36
37 //===----------------------------------------------------------------------===//
38 // DwarfWriter - Emits Dwarf debug and exception handling directives.
39 //
40
41 class DwarfWriter : public ImmutablePass {
42 private:
43   /// DD - Provides the DwarfWriter debug implementation.
44   ///
45   DwarfDebug *DD;
46
47   /// DE - Provides the DwarfWriter exception implementation.
48   ///
49   DwarfException *DE;
50   
51 public:
52   static char ID; // Pass identification, replacement for typeid
53
54   DwarfWriter();
55   virtual ~DwarfWriter();
56   
57   //===--------------------------------------------------------------------===//
58   // Main entry points.
59   //
60   
61   /// BeginModule - Emit all Dwarf sections that should come prior to the
62   /// content.
63   void BeginModule(Module *M, MachineModuleInfo *MMI, raw_ostream &OS,
64                    AsmPrinter *A, const TargetAsmInfo *T);
65   
66   /// EndModule - Emit all Dwarf sections that should come after the content.
67   ///
68   void EndModule();
69   
70   /// BeginFunction - Gather pre-function debug information.  Assumes being 
71   /// emitted immediately after the function entry point.
72   void BeginFunction(MachineFunction *MF);
73   
74   /// EndFunction - Gather and emit post-function debug information.
75   ///
76   void EndFunction(MachineFunction *MF);
77
78
79   /// label. Returns a unique label ID used to generate a label and provide
80   /// correspondence to the source line list.
81   unsigned RecordSourceLine(unsigned Line, unsigned Col, unsigned Src);
82
83   /// RecordSource - Register a source file with debug info. Returns an source
84   /// ID.
85   unsigned RecordSource(const std::string &Dir, const std::string &File);
86
87   /// RecordRegionStart - Indicate the start of a region.
88   unsigned RecordRegionStart(GlobalVariable *V);
89
90   /// RecordRegionEnd - Indicate the end of a region.
91   unsigned RecordRegionEnd(GlobalVariable *V);
92
93   /// getRecordSourceLineCount - Count source lines.
94   unsigned getRecordSourceLineCount();
95
96 };
97
98
99 } // end llvm namespace
100
101 #endif