1 //===--- lib/CodeGen/DwarfPrinter.h - Dwarf Printer -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Emit general DWARF directives.
12 //===----------------------------------------------------------------------===//
14 #ifndef CODEGEN_ASMPRINTER_DWARFPRINTER_H__
15 #define CODEGEN_ASMPRINTER_DWARFPRINTER_H__
17 #include "DwarfLabel.h"
18 #include "llvm/CodeGen/MachineLocation.h"
19 #include "llvm/Support/Compiler.h"
20 #include "llvm/Support/raw_ostream.h"
25 class MachineFunction;
26 class MachineModuleInfo;
30 class TargetRegisterInfo;
32 class VISIBILITY_HIDDEN Dwarf {
34 //===-------------------------------------------------------------==---===//
35 // Core attributes used by the DWARF printer.
38 /// O - Stream to .s file.
42 /// Asm - Target of Dwarf emission.
46 /// TAI - Target asm information.
48 const TargetAsmInfo *TAI;
54 /// RI - Register Information.
56 const TargetRegisterInfo *RI;
58 /// M - Current module.
62 /// MF - Current machine function.
66 /// MMI - Collected machine module information.
68 MachineModuleInfo *MMI;
70 /// SubprogramCount - The running count of functions being compiled.
72 unsigned SubprogramCount;
74 /// Flavor - A unique string indicating what dwarf producer this is, used to
77 const char * const Flavor;
79 /// SetCounter - A unique number for each '.set' directive.
83 Dwarf(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T,
86 //===------------------------------------------------------------------===//
89 const AsmPrinter *getAsm() const { return Asm; }
90 MachineModuleInfo *getMMI() const { return MMI; }
91 const TargetAsmInfo *getTargetAsmInfo() const { return TAI; }
92 const TargetData *getTargetData() const { return TD; }
94 void PrintRelDirective(bool Force32Bit = false,
95 bool isInSection = false) const;
98 /// PrintLabelName - Print label name in form used by Dwarf writer.
100 void PrintLabelName(const DWLabel &Label) const {
101 PrintLabelName(Label.getTag(), Label.getNumber());
103 void PrintLabelName(const char *Tag, unsigned Number) const;
104 void PrintLabelName(const char *Tag, unsigned Number,
105 const char *Suffix) const;
107 /// EmitLabel - Emit location label for internal use by Dwarf.
109 void EmitLabel(const DWLabel &Label) const {
110 EmitLabel(Label.getTag(), Label.getNumber());
112 void EmitLabel(const char *Tag, unsigned Number) const;
114 /// EmitReference - Emit a reference to a label.
116 void EmitReference(const DWLabel &Label, bool IsPCRelative = false,
117 bool Force32Bit = false) const {
118 EmitReference(Label.getTag(), Label.getNumber(),
119 IsPCRelative, Force32Bit);
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;
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(),
136 void EmitDifference(const char *TagHi, unsigned NumberHi,
137 const char *TagLo, unsigned NumberLo,
138 bool IsSmall = false);
140 void EmitSectionOffset(const char* Label, const char* Section,
141 unsigned LabelNumber, unsigned SectionNumber,
142 bool IsSmall = false, bool isEH = false,
145 /// EmitFrameMoves - Emit frame instructions to describe the layout of the
147 void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
148 const std::vector<MachineMove> &Moves, bool isEH);
151 } // end llvm namespace