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;
36 //===-------------------------------------------------------------==---===//
37 // Core attributes used by the DWARF printer.
40 /// O - Stream to .s file.
43 /// Asm - Target of Dwarf emission.
46 /// MAI - Target asm information.
52 /// RI - Register Information.
53 const TargetRegisterInfo *RI;
55 /// M - Current module.
58 /// MF - Current machine function.
59 const MachineFunction *MF;
61 /// MMI - Collected machine module information.
62 MachineModuleInfo *MMI;
64 /// SubprogramCount - The running count of functions being compiled.
65 unsigned SubprogramCount;
67 /// Flavor - A unique string indicating what dwarf producer this is, used to
69 const char * const Flavor;
71 /// SetCounter - A unique number for each '.set' directive.
74 DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
78 //===------------------------------------------------------------------===//
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; }
86 void PrintRelDirective(bool Force32Bit = false,
87 bool isInSection = false) const;
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;
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);
99 /// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value.
100 void EmitCFAByte(unsigned Val);
103 /// EmitSLEB128 - emit the specified signed leb128 value.
104 void EmitSLEB128(int Value, const char *Desc) const;
106 /// EmitULEB128 - emit the specified unsigned leb128 value.
107 void EmitULEB128(unsigned Value, const char *Desc = 0) const;
110 /// PrintLabelName - Print label name in form used by Dwarf writer.
112 void PrintLabelName(const DWLabel &Label) const {
113 PrintLabelName(Label.getTag(), Label.getNumber());
115 void PrintLabelName(const char *Tag, unsigned Number) const;
116 void PrintLabelName(const char *Tag, unsigned Number,
117 const char *Suffix) const;
119 /// EmitLabel - Emit location label for internal use by Dwarf.
121 void EmitLabel(const DWLabel &Label) const {
122 EmitLabel(Label.getTag(), Label.getNumber());
124 void EmitLabel(const char *Tag, unsigned Number) const;
126 /// EmitReference - Emit a reference to a label.
128 void EmitReference(const DWLabel &Label, bool IsPCRelative = false,
129 bool Force32Bit = false) const {
130 EmitReference(Label.getTag(), Label.getNumber(),
131 IsPCRelative, Force32Bit);
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;
141 /// EmitDifference - Emit the difference between two labels.
142 void EmitDifference(const DWLabel &LabelHi, const DWLabel &LabelLo,
143 bool IsSmall = false) {
144 EmitDifference(LabelHi.getTag(), LabelHi.getNumber(),
145 LabelLo.getTag(), LabelLo.getNumber(),
148 void EmitDifference(const char *TagHi, unsigned NumberHi,
149 const char *TagLo, unsigned NumberLo,
150 bool IsSmall = false);
152 void EmitSectionOffset(const char* Label, const char* Section,
153 unsigned LabelNumber, unsigned SectionNumber,
154 bool IsSmall = false, bool isEH = false,
157 /// EmitFrameMoves - Emit frame instructions to describe the layout of the
159 void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
160 const std::vector<MachineMove> &Moves, bool isEH);
163 } // end llvm namespace