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