blob: 007df29ed2c216e91788ea560c3c776b3ee81d4c [file] [log] [blame]
Bill Wendlingbbee8c92009-05-15 00:11:17 +00001//===--- 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
Bill Wendlingb12b3d72009-05-15 09:23:25 +000014#ifndef CODEGEN_ASMPRINTER_DWARFPRINTER_H__
15#define CODEGEN_ASMPRINTER_DWARFPRINTER_H__
Bill Wendlingbbee8c92009-05-15 00:11:17 +000016
17#include "DwarfLabel.h"
18#include "llvm/CodeGen/MachineLocation.h"
19#include "llvm/Support/Compiler.h"
Chris Lattnerad653482010-01-22 22:09:00 +000020#include "llvm/Support/FormattedStream.h"
Bill Wendlingbbee8c92009-05-15 00:11:17 +000021#include <vector>
22
23namespace llvm {
Chris Lattner57939f62010-01-22 22:19:51 +000024class AsmPrinter;
25class MachineFunction;
26class MachineModuleInfo;
27class Module;
28class MCAsmInfo;
29class TargetData;
30class TargetRegisterInfo;
31class MCSymbol;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000032
Chris Lattner57939f62010-01-22 22:19:51 +000033class Dwarf {
34protected:
35 //===-------------------------------------------------------------==---===//
36 // Core attributes used by the DWARF printer.
37 //
Bill Wendlingbbee8c92009-05-15 00:11:17 +000038
Chris Lattner57939f62010-01-22 22:19:51 +000039 /// O - Stream to .s file.
40 raw_ostream &O;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000041
Chris Lattner57939f62010-01-22 22:19:51 +000042 /// Asm - Target of Dwarf emission.
43 AsmPrinter *Asm;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000044
Chris Lattner57939f62010-01-22 22:19:51 +000045 /// MAI - Target asm information.
46 const MCAsmInfo *MAI;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000047
Chris Lattner57939f62010-01-22 22:19:51 +000048 /// TD - Target data.
49 const TargetData *TD;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000050
Chris Lattner57939f62010-01-22 22:19:51 +000051 /// RI - Register Information.
52 const TargetRegisterInfo *RI;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000053
Chris Lattner57939f62010-01-22 22:19:51 +000054 /// M - Current module.
55 Module *M;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000056
Chris Lattner57939f62010-01-22 22:19:51 +000057 /// MF - Current machine function.
58 MachineFunction *MF;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000059
Chris Lattner57939f62010-01-22 22:19:51 +000060 /// MMI - Collected machine module information.
61 MachineModuleInfo *MMI;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000062
Chris Lattner57939f62010-01-22 22:19:51 +000063 /// SubprogramCount - The running count of functions being compiled.
64 unsigned SubprogramCount;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000065
Chris Lattner57939f62010-01-22 22:19:51 +000066 /// Flavor - A unique string indicating what dwarf producer this is, used to
67 /// unique labels.
68 const char * const Flavor;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000069
Chris Lattner57939f62010-01-22 22:19:51 +000070 /// SetCounter - A unique number for each '.set' directive.
71 unsigned SetCounter;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000072
Chris Lattner57939f62010-01-22 22:19:51 +000073 Dwarf(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
74 const char *flavor);
75public:
76 //===------------------------------------------------------------------===//
77 // Accessors.
78 //
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; }
Bill Wendlingbbee8c92009-05-15 00:11:17 +000083
Chris Lattner57939f62010-01-22 22:19:51 +000084 void PrintRelDirective(bool Force32Bit = false,
85 bool isInSection = false) const;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000086
87
Chris Lattner57939f62010-01-22 22:19:51 +000088 /// PrintLabelName - Print label name in form used by Dwarf writer.
89 ///
90 void PrintLabelName(const DWLabel &Label) const {
91 PrintLabelName(Label.getTag(), Label.getNumber());
92 }
93 void PrintLabelName(const char *Tag, unsigned Number) const;
94 void PrintLabelName(const char *Tag, unsigned Number,
95 const char *Suffix) const;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000096
Chris Lattner57939f62010-01-22 22:19:51 +000097 /// EmitLabel - Emit location label for internal use by Dwarf.
98 ///
99 void EmitLabel(const DWLabel &Label) const {
100 EmitLabel(Label.getTag(), Label.getNumber());
101 }
102 void EmitLabel(const char *Tag, unsigned Number) const;
Bill Wendlingbbee8c92009-05-15 00:11:17 +0000103
Chris Lattner57939f62010-01-22 22:19:51 +0000104 /// EmitReference - Emit a reference to a label.
105 ///
106 void EmitReference(const DWLabel &Label, bool IsPCRelative = false,
107 bool Force32Bit = false) const {
108 EmitReference(Label.getTag(), Label.getNumber(),
109 IsPCRelative, Force32Bit);
110 }
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;
Bill Wendlingbbee8c92009-05-15 00:11:17 +0000118
Chris Lattner57939f62010-01-22 22:19:51 +0000119 /// 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(),
126 IsSmall);
127 }
128 void EmitDifference(const char *TagHi, unsigned NumberHi,
129 const char *TagLo, unsigned NumberLo,
130 bool IsSmall = false);
Bill Wendlingbbee8c92009-05-15 00:11:17 +0000131
Chris Lattner57939f62010-01-22 22:19:51 +0000132 void EmitSectionOffset(const char* Label, const char* Section,
133 unsigned LabelNumber, unsigned SectionNumber,
134 bool IsSmall = false, bool isEH = false,
135 bool useSet = true);
Bill Wendlingbbee8c92009-05-15 00:11:17 +0000136
Chris Lattner57939f62010-01-22 22:19:51 +0000137 /// EmitFrameMoves - Emit frame instructions to describe the layout of the
138 /// frame.
139 void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
140 const std::vector<MachineMove> &Moves, bool isEH);
Bill Wendlingbbee8c92009-05-15 00:11:17 +0000141};
142
143} // end llvm namespace
144
145#endif