move gettemplabel and getdwlabel to AsmPrinter and rename
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfPrinter.h
1 //===--- lib/CodeGen/DwarfPrinter.h - Dwarf Printer -------------*- 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 // Emit general DWARF directives.
11 // 
12 //===----------------------------------------------------------------------===//
13
14 #ifndef CODEGEN_ASMPRINTER_DWARFPRINTER_H__
15 #define CODEGEN_ASMPRINTER_DWARFPRINTER_H__
16
17 #include "llvm/CodeGen/MachineLocation.h"
18 #include "llvm/Support/Compiler.h"
19 #include "llvm/Support/FormattedStream.h"
20 #include <vector>
21
22 namespace llvm {
23 class AsmPrinter;
24 class MachineFunction;
25 class MachineModuleInfo;
26 class Module;
27 class MCAsmInfo;
28 class TargetData;
29 class TargetRegisterInfo;
30 class GlobalValue;
31 class MCSymbol;
32 class Twine;
33
34 class DwarfPrinter {
35 protected:
36   ~DwarfPrinter() {}
37
38   //===-------------------------------------------------------------==---===//
39   // Core attributes used by the DWARF printer.
40   //
41
42   /// Asm - Target of Dwarf emission.
43   AsmPrinter *Asm;
44
45   /// MAI - Target asm information.
46   const MCAsmInfo *MAI;
47
48   /// TD - Target data.
49   const TargetData *TD;
50
51   /// RI - Register Information.
52   const TargetRegisterInfo *RI;
53
54   /// M - Current module.
55   Module *M;
56
57   /// MF - Current machine function.
58   const MachineFunction *MF;
59
60   /// MMI - Collected machine module information.
61   MachineModuleInfo *MMI;
62
63   /// SubprogramCount - The running count of functions being compiled.
64   unsigned SubprogramCount;
65
66   DwarfPrinter(AsmPrinter *A);
67 public:
68   
69   //===------------------------------------------------------------------===//
70   // Accessors.
71   //
72   const AsmPrinter *getAsm() const { return Asm; }
73   MachineModuleInfo *getMMI() const { return MMI; }
74   const MCAsmInfo *getMCAsmInfo() const { return MAI; }
75   const TargetData *getTargetData() const { return TD; }
76
77   /// SizeOfEncodedValue - Return the size of the encoding in bytes.
78   unsigned SizeOfEncodedValue(unsigned Encoding) const;
79
80   /// EmitEncodingByte - Emit a .byte 42 directive that corresponds to an
81   /// encoding.  If verbose assembly output is enabled, we output comments
82   /// describing the encoding.  Desc is a string saying what the encoding is
83   /// specifying (e.g. "LSDA").
84   void EmitEncodingByte(unsigned Val, const char *Desc);
85   
86   /// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value.
87   void EmitCFAByte(unsigned Val);
88   
89     
90   /// EmitReference - Emit a reference to a label.
91   ///
92   void EmitReference(const MCSymbol *Sym, unsigned Encoding) const;
93   void EmitReference(const GlobalValue *GV, unsigned Encoding) const;
94
95   /// EmitDifference - Emit the difference between two labels.
96   void EmitDifference(const MCSymbol *LabelHi, const MCSymbol *LabelLo,
97                       bool IsSmall = false);
98
99   /// EmitSectionOffset - Emit Label-Section or use a special purpose directive
100   /// to emit a section offset if the target has one.
101   void EmitSectionOffset(const MCSymbol *Label, const MCSymbol *Section,
102                          bool IsSmall = false, bool isEH = false);
103   
104   /// EmitFrameMoves - Emit frame instructions to describe the layout of the
105   /// frame.
106   void EmitFrameMoves(MCSymbol *BaseLabel,
107                       const std::vector<MachineMove> &Moves, bool isEH);
108 };
109
110 } // end llvm namespace
111
112 #endif