Construct and emit DW_TAG_inlined_subroutine DIEs for inlined subroutine scopes ...
[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 MachineInstr;
33 class Value;
34 class Module;
35 class GlobalVariable;
36 class TargetAsmInfo;
37 class raw_ostream;
38 class Instruction;
39 class DISubprogram;
40 class DIVariable;
41
42 //===----------------------------------------------------------------------===//
43 // DwarfWriter - Emits Dwarf debug and exception handling directives.
44 //
45
46 class DwarfWriter : public ImmutablePass {
47 private:
48   /// DD - Provides the DwarfWriter debug implementation.
49   ///
50   DwarfDebug *DD;
51
52   /// DE - Provides the DwarfWriter exception implementation.
53   ///
54   DwarfException *DE;
55
56 public:
57   static char ID; // Pass identification, replacement for typeid
58
59   DwarfWriter();
60   virtual ~DwarfWriter();
61
62   //===--------------------------------------------------------------------===//
63   // Main entry points.
64   //
65   
66   /// BeginModule - Emit all Dwarf sections that should come prior to the
67   /// content.
68   void BeginModule(Module *M, MachineModuleInfo *MMI, raw_ostream &OS,
69                    AsmPrinter *A, const TargetAsmInfo *T);
70   
71   /// EndModule - Emit all Dwarf sections that should come after the content.
72   ///
73   void EndModule();
74   
75   /// BeginFunction - Gather pre-function debug information.  Assumes being 
76   /// emitted immediately after the function entry point.
77   void BeginFunction(MachineFunction *MF);
78   
79   /// EndFunction - Gather and emit post-function debug information.
80   ///
81   void EndFunction(MachineFunction *MF);
82
83   /// ValidDebugInfo - Return true if V represents valid debug info value.
84   bool ValidDebugInfo(Value *V, bool FastISel);
85
86   /// RecordSourceLine - Register a source line with debug info. Returns a
87   /// unique label ID used to generate a label and provide correspondence to
88   /// the source line list.
89   unsigned RecordSourceLine(unsigned Line, unsigned Col, unsigned Src);
90
91   /// getOrCreateSourceID - Look up the source id with the given directory and
92   /// source file names. If none currently exists, create a new id and insert it
93   /// in the SourceIds map. This can update DirectoryIds and SourceFileIds maps
94   /// as well.
95   unsigned getOrCreateSourceID(const std::string &DirName,
96                                const std::string &FileName);
97
98   /// RecordRegionStart - Indicate the start of a region.
99   unsigned RecordRegionStart(GlobalVariable *V);
100
101   /// RecordRegionEnd - Indicate the end of a region.
102   unsigned RecordRegionEnd(GlobalVariable *V);
103
104   /// getRecordSourceLineCount - Count source lines.
105   unsigned getRecordSourceLineCount();
106
107   /// RecordVariable - Indicate the declaration of  a local variable.
108   ///
109   void RecordVariable(GlobalVariable *GV, unsigned FrameIndex, 
110                       const MachineInstr *MI);
111
112   /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
113   /// be emitted.
114   bool ShouldEmitDwarfDebug() const;
115
116   //// RecordInlinedFnStart - Indicate the start of a inlined function.
117   void RecordInlinedFnStart(Instruction *I, DISubprogram &SP, unsigned LabelID,
118                             unsigned Src, unsigned Line, unsigned Col);
119
120   /// RecordInlinedFnEnd - Indicate the end of inlined subroutine.
121   unsigned RecordInlinedFnEnd(DISubprogram &SP);
122
123   /// RecordVariableScope - Record scope for the variable declared by
124   /// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE.
125   void RecordVariableScope(DIVariable &DV, const MachineInstr *DeclareMI);
126 };
127
128
129 } // end llvm namespace
130
131 #endif