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