eliminate redundant argument to EmitJumpTableInfo
[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 "DwarfLabel.h"
18 #include "llvm/CodeGen/MachineLocation.h"
19 #include "llvm/Support/Compiler.h"
20 #include "llvm/Support/FormattedStream.h"
21 #include <vector>
22
23 namespace llvm {
24 class AsmPrinter;
25 class MachineFunction;
26 class MachineModuleInfo;
27 class Module;
28 class MCAsmInfo;
29 class TargetData;
30 class TargetRegisterInfo;
31 class MCSymbol;
32 class Twine;
33
34 class DwarfPrinter {
35 protected:
36   //===-------------------------------------------------------------==---===//
37   // Core attributes used by the DWARF printer.
38   //
39
40   /// O - Stream to .s file.
41   raw_ostream &O;
42
43   /// Asm - Target of Dwarf emission.
44   AsmPrinter *Asm;
45
46   /// MAI - Target asm information.
47   const MCAsmInfo *MAI;
48
49   /// TD - Target data.
50   const TargetData *TD;
51
52   /// RI - Register Information.
53   const TargetRegisterInfo *RI;
54
55   /// M - Current module.
56   Module *M;
57
58   /// MF - Current machine function.
59   MachineFunction *MF;
60
61   /// MMI - Collected machine module information.
62   MachineModuleInfo *MMI;
63
64   /// SubprogramCount - The running count of functions being compiled.
65   unsigned SubprogramCount;
66
67   /// Flavor - A unique string indicating what dwarf producer this is, used to
68   /// unique labels.
69   const char * const Flavor;
70
71   /// SetCounter - A unique number for each '.set' directive.
72   unsigned SetCounter;
73
74   DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
75                const char *flavor);
76 public:
77   
78   //===------------------------------------------------------------------===//
79   // Accessors.
80   //
81   const AsmPrinter *getAsm() const { return Asm; }
82   MachineModuleInfo *getMMI() const { return MMI; }
83   const MCAsmInfo *getMCAsmInfo() const { return MAI; }
84   const TargetData *getTargetData() const { return TD; }
85
86   void PrintRelDirective(bool Force32Bit = false,
87                          bool isInSection = false) const;
88
89   /// EOL - Print a newline character to asm stream.  If a comment is present
90   /// then it will be printed first.  Comments should not contain '\n'.
91   void EOL(const Twine &Comment) const;
92   
93   /// EmitEncodingByte - Emit a .byte 42 directive that corresponds to an
94   /// encoding.  If verbose assembly output is enabled, we output comments
95   /// describing the encoding.  Desc is a string saying what the encoding is
96   /// specifying (e.g. "LSDA").
97   void EmitEncodingByte(unsigned Val, const char *Desc);
98   
99   /// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value.
100   void EmitCFAByte(unsigned Val);
101   
102   
103   /// EmitSLEB128 - emit the specified signed leb128 value.
104   void EmitSLEB128(int Value, const char *Desc) const;
105
106   /// EmitULEB128 - emit the specified unsigned leb128 value.
107   void EmitULEB128(unsigned Value, const char *Desc = 0) const;
108
109   
110   /// PrintLabelName - Print label name in form used by Dwarf writer.
111   ///
112   void PrintLabelName(const DWLabel &Label) const {
113     PrintLabelName(Label.getTag(), Label.getNumber());
114   }
115   void PrintLabelName(const char *Tag, unsigned Number) const;
116   void PrintLabelName(const char *Tag, unsigned Number,
117                       const char *Suffix) const;
118
119   /// EmitLabel - Emit location label for internal use by Dwarf.
120   ///
121   void EmitLabel(const DWLabel &Label) const {
122     EmitLabel(Label.getTag(), Label.getNumber());
123   }
124   void EmitLabel(const char *Tag, unsigned Number) const;
125
126   /// EmitReference - Emit a reference to a label.
127   ///
128   void EmitReference(const DWLabel &Label, bool IsPCRelative = false,
129                      bool Force32Bit = false) const {
130     EmitReference(Label.getTag(), Label.getNumber(),
131                   IsPCRelative, Force32Bit);
132   }
133   void EmitReference(const char *Tag, unsigned Number,
134                      bool IsPCRelative = false,
135                      bool Force32Bit = false) const;
136   void EmitReference(const std::string &Name, bool IsPCRelative = false,
137                      bool Force32Bit = false) const;
138   void EmitReference(const MCSymbol *Sym, bool IsPCRelative = false,
139                      bool Force32Bit = false) const;
140
141   /// EmitDifference - Emit the difference between two labels.  Some
142   /// assemblers do not behave with absolute expressions with data directives,
143   /// so there is an option (needsSet) to use an intermediary set expression.
144   void EmitDifference(const DWLabel &LabelHi, const DWLabel &LabelLo,
145                       bool IsSmall = false) {
146     EmitDifference(LabelHi.getTag(), LabelHi.getNumber(),
147                    LabelLo.getTag(), LabelLo.getNumber(),
148                    IsSmall);
149   }
150   void EmitDifference(const char *TagHi, unsigned NumberHi,
151                       const char *TagLo, unsigned NumberLo,
152                       bool IsSmall = false);
153
154   void EmitSectionOffset(const char* Label, const char* Section,
155                          unsigned LabelNumber, unsigned SectionNumber,
156                          bool IsSmall = false, bool isEH = false,
157                          bool useSet = true);
158
159   /// EmitFrameMoves - Emit frame instructions to describe the layout of the
160   /// frame.
161   void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
162                       const std::vector<MachineMove> &Moves, bool isEH);
163 };
164
165 } // end llvm namespace
166
167 #endif