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/FormattedStream.h"
25 class MachineFunction;
26 class MachineModuleInfo;
30 class TargetRegisterInfo;
35 //===-------------------------------------------------------------==---===//
36 // Core attributes used by the DWARF printer.
39 /// O - Stream to .s file.
42 /// Asm - Target of Dwarf emission.
45 /// MAI - Target asm information.
51 /// RI - Register Information.
52 const TargetRegisterInfo *RI;
54 /// M - Current module.
57 /// MF - Current machine function.
60 /// MMI - Collected machine module information.
61 MachineModuleInfo *MMI;
63 /// SubprogramCount - The running count of functions being compiled.
64 unsigned SubprogramCount;
66 /// Flavor - A unique string indicating what dwarf producer this is, used to
68 const char * const Flavor;
70 /// SetCounter - A unique number for each '.set' directive.
73 Dwarf(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
76 //===------------------------------------------------------------------===//
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; }
84 void PrintRelDirective(bool Force32Bit = false,
85 bool isInSection = false) const;
88 /// PrintLabelName - Print label name in form used by Dwarf writer.
90 void PrintLabelName(const DWLabel &Label) const {
91 PrintLabelName(Label.getTag(), Label.getNumber());
93 void PrintLabelName(const char *Tag, unsigned Number) const;
94 void PrintLabelName(const char *Tag, unsigned Number,
95 const char *Suffix) const;
97 /// EmitLabel - Emit location label for internal use by Dwarf.
99 void EmitLabel(const DWLabel &Label) const {
100 EmitLabel(Label.getTag(), Label.getNumber());
102 void EmitLabel(const char *Tag, unsigned Number) const;
104 /// EmitReference - Emit a reference to a label.
106 void EmitReference(const DWLabel &Label, bool IsPCRelative = false,
107 bool Force32Bit = false) const {
108 EmitReference(Label.getTag(), Label.getNumber(),
109 IsPCRelative, Force32Bit);
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;
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(),
128 void EmitDifference(const char *TagHi, unsigned NumberHi,
129 const char *TagLo, unsigned NumberLo,
130 bool IsSmall = false);
132 void EmitSectionOffset(const char* Label, const char* Section,
133 unsigned LabelNumber, unsigned SectionNumber,
134 bool IsSmall = false, bool isEH = false,
137 /// EmitFrameMoves - Emit frame instructions to describe the layout of the
139 void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
140 const std::vector<MachineMove> &Moves, bool isEH);
143 } // end llvm namespace