blob: 01aa775ebe584e1d8f5d1aa396630c4135704cab [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"
20#include "llvm/Support/raw_ostream.h"
21#include <vector>
22
23namespace llvm {
24 class AsmPrinter;
25 class MachineFunction;
26 class MachineModuleInfo;
27 class Module;
Chris Lattner621c44d2009-08-22 20:48:53 +000028 class MCAsmInfo;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000029 class TargetData;
30 class TargetRegisterInfo;
31
32 class VISIBILITY_HIDDEN Dwarf {
33 protected:
34 //===-------------------------------------------------------------==---===//
35 // Core attributes used by the DWARF printer.
36 //
37
38 /// O - Stream to .s file.
39 ///
40 raw_ostream &O;
41
42 /// Asm - Target of Dwarf emission.
43 ///
44 AsmPrinter *Asm;
45
Chris Lattnera5ef4d32009-08-22 21:43:10 +000046 /// MAI - Target asm information.
Bill Wendlingbbee8c92009-05-15 00:11:17 +000047 ///
Chris Lattnera5ef4d32009-08-22 21:43:10 +000048 const MCAsmInfo *MAI;
Bill Wendlingbbee8c92009-05-15 00:11:17 +000049
50 /// TD - Target data.
51 ///
52 const TargetData *TD;
53
54 /// RI - Register Information.
55 ///
56 const TargetRegisterInfo *RI;
57
58 /// M - Current module.
59 ///
60 Module *M;
61
62 /// MF - Current machine function.
63 ///
64 MachineFunction *MF;
65
66 /// MMI - Collected machine module information.
67 ///
68 MachineModuleInfo *MMI;
69
70 /// SubprogramCount - The running count of functions being compiled.
71 ///
72 unsigned SubprogramCount;
73
74 /// Flavor - A unique string indicating what dwarf producer this is, used to
75 /// unique labels.
76 ///
77 const char * const Flavor;
78
79 /// SetCounter - A unique number for each '.set' directive.
80 ///
81 unsigned SetCounter;
82
Chris Lattner621c44d2009-08-22 20:48:53 +000083 Dwarf(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
Bill Wendlingbbee8c92009-05-15 00:11:17 +000084 const char *flavor);
85 public:
86 //===------------------------------------------------------------------===//
87 // Accessors.
88 //
89 const AsmPrinter *getAsm() const { return Asm; }
90 MachineModuleInfo *getMMI() const { return MMI; }
Chris Lattnera5ef4d32009-08-22 21:43:10 +000091 const MCAsmInfo *getMCAsmInfo() const { return MAI; }
Bill Wendlingbbee8c92009-05-15 00:11:17 +000092 const TargetData *getTargetData() const { return TD; }
93
94 void PrintRelDirective(bool Force32Bit = false,
95 bool isInSection = false) const;
96
97
98 /// PrintLabelName - Print label name in form used by Dwarf writer.
99 ///
100 void PrintLabelName(const DWLabel &Label) const {
101 PrintLabelName(Label.getTag(), Label.getNumber());
102 }
Bill Wendlingbbee8c92009-05-15 00:11:17 +0000103 void PrintLabelName(const char *Tag, unsigned Number,
Jim Grosbach5e0257f2009-09-01 01:57:56 +0000104 bool ForcePrivate = true) const;
105 void PrintLabelName(const char *Tag, unsigned Number,
106 const char *Suffix, bool ForcePrivate = true) const;
Bill Wendlingbbee8c92009-05-15 00:11:17 +0000107
108 /// EmitLabel - Emit location label for internal use by Dwarf.
109 ///
110 void EmitLabel(const DWLabel &Label) const {
111 EmitLabel(Label.getTag(), Label.getNumber());
112 }
Jim Grosbach5e0257f2009-09-01 01:57:56 +0000113 void EmitLabel(const char *Tag, unsigned Number,
114 bool ForcePrivate = true) const;
Bill Wendlingbbee8c92009-05-15 00:11:17 +0000115
116 /// EmitReference - Emit a reference to a label.
117 ///
118 void EmitReference(const DWLabel &Label, bool IsPCRelative = false,
119 bool Force32Bit = false) const {
120 EmitReference(Label.getTag(), Label.getNumber(),
121 IsPCRelative, Force32Bit);
122 }
123 void EmitReference(const char *Tag, unsigned Number,
124 bool IsPCRelative = false,
125 bool Force32Bit = false) const;
126 void EmitReference(const std::string &Name, bool IsPCRelative = false,
127 bool Force32Bit = false) const;
128
129 /// EmitDifference - Emit the difference between two labels. Some
130 /// assemblers do not behave with absolute expressions with data directives,
131 /// so there is an option (needsSet) to use an intermediary set expression.
132 void EmitDifference(const DWLabel &LabelHi, const DWLabel &LabelLo,
133 bool IsSmall = false) {
134 EmitDifference(LabelHi.getTag(), LabelHi.getNumber(),
135 LabelLo.getTag(), LabelLo.getNumber(),
136 IsSmall);
137 }
138 void EmitDifference(const char *TagHi, unsigned NumberHi,
139 const char *TagLo, unsigned NumberLo,
140 bool IsSmall = false);
141
142 void EmitSectionOffset(const char* Label, const char* Section,
143 unsigned LabelNumber, unsigned SectionNumber,
144 bool IsSmall = false, bool isEH = false,
145 bool useSet = true);
146
147 /// EmitFrameMoves - Emit frame instructions to describe the layout of the
148 /// frame.
149 void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
150 const std::vector<MachineMove> &Moves, bool isEH);
151};
152
153} // end llvm namespace
154
155#endif