fix indentation
[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
33 class Dwarf {
34 protected:
35   //===-------------------------------------------------------------==---===//
36   // Core attributes used by the DWARF printer.
37   //
38
39   /// O - Stream to .s file.
40   raw_ostream &O;
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   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   /// Flavor - A unique string indicating what dwarf producer this is, used to
67   /// unique labels.
68   const char * const Flavor;
69
70   /// SetCounter - A unique number for each '.set' directive.
71   unsigned SetCounter;
72
73   Dwarf(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
74         const char *flavor);
75 public:
76   //===------------------------------------------------------------------===//
77   // Accessors.
78   //
79   const AsmPrinter *getAsm() const { return Asm; }
80   MachineModuleInfo *getMMI() const { return MMI; }
81   const MCAsmInfo *getMCAsmInfo() const { return MAI; }
82   const TargetData *getTargetData() const { return TD; }
83
84   void PrintRelDirective(bool Force32Bit = false,
85                          bool isInSection = false) const;
86
87
88   /// PrintLabelName - Print label name in form used by Dwarf writer.
89   ///
90   void PrintLabelName(const DWLabel &Label) const {
91     PrintLabelName(Label.getTag(), Label.getNumber());
92   }
93   void PrintLabelName(const char *Tag, unsigned Number) const;
94   void PrintLabelName(const char *Tag, unsigned Number,
95                       const char *Suffix) const;
96
97   /// EmitLabel - Emit location label for internal use by Dwarf.
98   ///
99   void EmitLabel(const DWLabel &Label) const {
100     EmitLabel(Label.getTag(), Label.getNumber());
101   }
102   void EmitLabel(const char *Tag, unsigned Number) const;
103
104   /// EmitReference - Emit a reference to a label.
105   ///
106   void EmitReference(const DWLabel &Label, bool IsPCRelative = false,
107                      bool Force32Bit = false) const {
108     EmitReference(Label.getTag(), Label.getNumber(),
109                   IsPCRelative, Force32Bit);
110   }
111   void EmitReference(const char *Tag, unsigned Number,
112                      bool IsPCRelative = false,
113                      bool Force32Bit = false) const;
114   void EmitReference(const std::string &Name, bool IsPCRelative = false,
115                      bool Force32Bit = false) const;
116   void EmitReference(const MCSymbol *Sym, bool IsPCRelative = false,
117                      bool Force32Bit = false) const;
118
119   /// EmitDifference - Emit the difference between two labels.  Some
120   /// assemblers do not behave with absolute expressions with data directives,
121   /// so there is an option (needsSet) to use an intermediary set expression.
122   void EmitDifference(const DWLabel &LabelHi, const DWLabel &LabelLo,
123                       bool IsSmall = false) {
124     EmitDifference(LabelHi.getTag(), LabelHi.getNumber(),
125                    LabelLo.getTag(), LabelLo.getNumber(),
126                    IsSmall);
127   }
128   void EmitDifference(const char *TagHi, unsigned NumberHi,
129                       const char *TagLo, unsigned NumberLo,
130                       bool IsSmall = false);
131
132   void EmitSectionOffset(const char* Label, const char* Section,
133                          unsigned LabelNumber, unsigned SectionNumber,
134                          bool IsSmall = false, bool isEH = false,
135                          bool useSet = true);
136
137   /// EmitFrameMoves - Emit frame instructions to describe the layout of the
138   /// frame.
139   void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
140                       const std::vector<MachineMove> &Moves, bool isEH);
141 };
142
143 } // end llvm namespace
144
145 #endif