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;
39
//===-------------------------------------------------------------==---===//
40
// Core attributes used by the DWARF printer.
43
/// O - Stream to .s file.
46
/// Asm - Target of Dwarf emission.
49
/// MAI - Target asm information.
55
/// RI - Register Information.
56
const TargetRegisterInfo *RI;
58
/// M - Current module.
61
/// MF - Current machine function.
62
const MachineFunction *MF;
64
/// MMI - Collected machine module information.
65
MachineModuleInfo *MMI;
67
/// SubprogramCount - The running count of functions being compiled.
68
unsigned SubprogramCount;
70
/// Flavor - A unique string indicating what dwarf producer this is, used to
72
const char * const Flavor;
74
/// SetCounter - A unique number for each '.set' directive.
77
DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
81
//===------------------------------------------------------------------===//
84
const AsmPrinter *getAsm() const { return Asm; }
85
MachineModuleInfo *getMMI() const { return MMI; }
86
const MCAsmInfo *getMCAsmInfo() const { return MAI; }
87
const TargetData *getTargetData() const { return TD; }
89
/// SizeOfEncodedValue - Return the size of the encoding in bytes.
90
unsigned SizeOfEncodedValue(unsigned Encoding) const;
92
void PrintRelDirective(unsigned Encoding) const;
93
void PrintRelDirective(bool Force32Bit = false,
94
bool isInSection = false) const;
96
/// EOL - Print a newline character to asm stream. If a comment is present
97
/// then it will be printed first. Comments should not contain '\n'.
98
void EOL(const Twine &Comment) const;
100
/// EmitEncodingByte - Emit a .byte 42 directive that corresponds to an
101
/// encoding. If verbose assembly output is enabled, we output comments
102
/// describing the encoding. Desc is a string saying what the encoding is
103
/// specifying (e.g. "LSDA").
104
void EmitEncodingByte(unsigned Val, const char *Desc);
106
/// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value.
107
void EmitCFAByte(unsigned Val);
110
/// EmitSLEB128 - emit the specified signed leb128 value.
111
void EmitSLEB128(int Value, const char *Desc) const;
113
/// EmitULEB128 - emit the specified unsigned leb128 value.
114
void EmitULEB128(unsigned Value, const char *Desc = 0,
115
unsigned PadTo = 0) const;
118
/// PrintLabelName - Print label name in form used by Dwarf writer.
120
void PrintLabelName(const DWLabel &Label) const {
121
PrintLabelName(Label.getTag(), Label.getNumber());
123
void PrintLabelName(const char *Tag, unsigned Number) const;
124
void PrintLabelName(const char *Tag, unsigned Number,
125
const char *Suffix) const;
127
/// EmitLabel - Emit location label for internal use by Dwarf.
129
void EmitLabel(const DWLabel &Label) const {
130
EmitLabel(Label.getTag(), Label.getNumber());
132
void EmitLabel(const char *Tag, unsigned Number) const;
134
/// EmitReference - Emit a reference to a label.
136
void EmitReference(const DWLabel &Label, bool IsPCRelative = false,
137
bool Force32Bit = false) const {
138
EmitReference(Label.getTag(), Label.getNumber(),
139
IsPCRelative, Force32Bit);
141
void EmitReference(const char *Tag, unsigned Number,
142
bool IsPCRelative = false,
143
bool Force32Bit = false) const;
144
void EmitReference(const std::string &Name, bool IsPCRelative = false,
145
bool Force32Bit = false) const;
146
void EmitReference(const MCSymbol *Sym, bool IsPCRelative = false,
147
bool Force32Bit = false) const;
149
void EmitReference(const char *Tag, unsigned Number, unsigned Encoding) const;
150
void EmitReference(const MCSymbol *Sym, unsigned Encoding) const;
151
void EmitReference(const GlobalValue *GV, unsigned Encoding) const;
153
/// EmitDifference - Emit the difference between two labels.
154
void EmitDifference(const DWLabel &LabelHi, const DWLabel &LabelLo,
155
bool IsSmall = false) {
156
EmitDifference(LabelHi.getTag(), LabelHi.getNumber(),
157
LabelLo.getTag(), LabelLo.getNumber(),
160
void EmitDifference(const char *TagHi, unsigned NumberHi,
161
const char *TagLo, unsigned NumberLo,
162
bool IsSmall = false);
164
void EmitSectionOffset(const char* Label, const char* Section,
165
unsigned LabelNumber, unsigned SectionNumber,
166
bool IsSmall = false, bool isEH = false,
169
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
171
void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
172
const std::vector<MachineMove> &Moves, bool isEH);
175
} // end llvm namespace