]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/CodeGen/AsmPrinter/DwarfPrinter.h
Update LLVM to r89205.
[FreeBSD/FreeBSD.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/raw_ostream.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
32   class Dwarf {
33   protected:
34     //===-------------------------------------------------------------==---===//
35     // Core attributes used by the DWARF printer.
36     //
37
38     /// O - Stream to .s file.
39     ///
40     raw_ostream &O;
41
42     /// Asm - Target of Dwarf emission.
43     ///
44     AsmPrinter *Asm;
45
46     /// MAI - Target asm information.
47     /// 
48     const MCAsmInfo *MAI;
49
50     /// TD - Target data.
51     /// 
52     const TargetData *TD;
53
54     /// RI - Register Information.
55     /// 
56     const TargetRegisterInfo *RI;
57
58     /// M - Current module.
59     ///
60     Module *M;
61
62     /// MF - Current machine function.
63     ///
64     MachineFunction *MF;
65
66     /// MMI - Collected machine module information.
67     ///
68     MachineModuleInfo *MMI;
69
70     /// SubprogramCount - The running count of functions being compiled.
71     ///
72     unsigned SubprogramCount;
73
74     /// Flavor - A unique string indicating what dwarf producer this is, used to
75     /// unique labels.
76     /// 
77     const char * const Flavor;
78
79     /// SetCounter - A unique number for each '.set' directive.
80     /// 
81     unsigned SetCounter;
82
83     Dwarf(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
84           const char *flavor);
85   public:
86     //===------------------------------------------------------------------===//
87     // Accessors.
88     //
89     const AsmPrinter *getAsm() const { return Asm; }
90     MachineModuleInfo *getMMI() const { return MMI; }
91     const MCAsmInfo *getMCAsmInfo() const { return MAI; }
92     const TargetData *getTargetData() const { return TD; }
93
94     void PrintRelDirective(bool Force32Bit = false,
95                            bool isInSection = false) const;
96
97
98     /// PrintLabelName - Print label name in form used by Dwarf writer.
99     ///
100     void PrintLabelName(const DWLabel &Label) const {
101       PrintLabelName(Label.getTag(), Label.getNumber());
102     }
103     void PrintLabelName(const char *Tag, unsigned Number) const;
104     void PrintLabelName(const char *Tag, unsigned Number,
105                         const char *Suffix) const;
106
107     /// EmitLabel - Emit location label for internal use by Dwarf.
108     ///
109     void EmitLabel(const DWLabel &Label) const {
110       EmitLabel(Label.getTag(), Label.getNumber());
111     }
112     void EmitLabel(const char *Tag, unsigned Number) const;
113
114     /// EmitReference - Emit a reference to a label.
115     ///
116     void EmitReference(const DWLabel &Label, bool IsPCRelative = false,
117                        bool Force32Bit = false) const {
118       EmitReference(Label.getTag(), Label.getNumber(),
119                     IsPCRelative, Force32Bit);
120     }
121     void EmitReference(const char *Tag, unsigned Number,
122                        bool IsPCRelative = false,
123                        bool Force32Bit = false) const;
124     void EmitReference(const std::string &Name, bool IsPCRelative = false,
125                        bool Force32Bit = false) const;
126
127     /// EmitDifference - Emit the difference between two labels.  Some
128     /// assemblers do not behave with absolute expressions with data directives,
129     /// so there is an option (needsSet) to use an intermediary set expression.
130     void EmitDifference(const DWLabel &LabelHi, const DWLabel &LabelLo,
131                         bool IsSmall = false) {
132       EmitDifference(LabelHi.getTag(), LabelHi.getNumber(),
133                      LabelLo.getTag(), LabelLo.getNumber(),
134                      IsSmall);
135     }
136     void EmitDifference(const char *TagHi, unsigned NumberHi,
137                         const char *TagLo, unsigned NumberLo,
138                         bool IsSmall = false);
139
140     void EmitSectionOffset(const char* Label, const char* Section,
141                            unsigned LabelNumber, unsigned SectionNumber,
142                            bool IsSmall = false, bool isEH = false,
143                            bool useSet = true);
144
145     /// EmitFrameMoves - Emit frame instructions to describe the layout of the
146     /// frame.
147     void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
148                         const std::vector<MachineMove> &Moves, bool isEH);
149 };
150
151 } // end llvm namespace
152
153 #endif