blob: 96a01327f769ff2407ee96ca2e99190a7fa44bc8 [file] [log] [blame]
Bill Wendling88423ee2009-05-15 00:11:17 +00001//===--- lib/CodeGen/DIE.h - DWARF Info Entries -----------------*- 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// Data structures for DWARF info entries.
Eric Christopherff348452013-01-07 22:40:45 +000011//
Bill Wendling88423ee2009-05-15 00:11:17 +000012//===----------------------------------------------------------------------===//
13
Bill Wendling0310d762009-05-15 09:23:25 +000014#ifndef CODEGEN_ASMPRINTER_DIE_H__
15#define CODEGEN_ASMPRINTER_DIE_H__
Bill Wendling88423ee2009-05-15 00:11:17 +000016
Bill Wendling88423ee2009-05-15 00:11:17 +000017#include "llvm/ADT/FoldingSet.h"
18#include "llvm/ADT/SmallVector.h"
19#include "llvm/Support/Compiler.h"
20#include "llvm/Support/Dwarf.h"
David Blaikie95e72c92013-06-28 20:05:04 +000021#include "llvm/MC/MCExpr.h"
Chris Lattnerb01acfa2009-08-23 01:01:17 +000022#include <vector>
Bill Wendling88423ee2009-05-15 00:11:17 +000023
24namespace llvm {
25 class AsmPrinter;
Chris Lattner858431d2010-01-16 18:50:28 +000026 class MCSymbol;
David Blaikie95e72c92013-06-28 20:05:04 +000027 class MCSymbolRefExpr;
Chris Lattnerb98b1bf2010-03-08 22:23:36 +000028 class raw_ostream;
Bill Wendling88423ee2009-05-15 00:11:17 +000029
30 //===--------------------------------------------------------------------===//
Eric Christopher0fbaa372013-06-10 22:24:07 +000031 /// DIEAbbrevData - Dwarf abbreviation data, describes one attribute of a
Bill Wendling88423ee2009-05-15 00:11:17 +000032 /// Dwarf abbreviation.
Benjamin Kramer55c06ae2013-09-11 18:05:11 +000033 class DIEAbbrevData {
Bill Wendling88423ee2009-05-15 00:11:17 +000034 /// Attribute - Dwarf attribute code.
35 ///
David Blaikie770530b2013-10-21 17:28:37 +000036 dwarf::Attribute Attribute;
Bill Wendling88423ee2009-05-15 00:11:17 +000037
38 /// Form - Dwarf form code.
39 ///
David Blaikie770530b2013-10-21 17:28:37 +000040 dwarf::Form Form;
Bill Wendling88423ee2009-05-15 00:11:17 +000041 public:
David Blaikie770530b2013-10-21 17:28:37 +000042 DIEAbbrevData(dwarf::Attribute A, dwarf::Form F) : Attribute(A), Form(F) {}
Bill Wendling88423ee2009-05-15 00:11:17 +000043
44 // Accessors.
David Blaikie770530b2013-10-21 17:28:37 +000045 dwarf::Attribute getAttribute() const { return Attribute; }
46 dwarf::Form getForm() const { return Form; }
Bill Wendling88423ee2009-05-15 00:11:17 +000047
48 /// Profile - Used to gather unique data for the abbreviation folding set.
49 ///
50 void Profile(FoldingSetNodeID &ID) const;
51 };
52
53 //===--------------------------------------------------------------------===//
54 /// DIEAbbrev - Dwarf abbreviation, describes the organization of a debug
55 /// information object.
Benjamin Kramer55c06ae2013-09-11 18:05:11 +000056 class DIEAbbrev : public FoldingSetNode {
Bill Wendling88423ee2009-05-15 00:11:17 +000057 /// Tag - Dwarf tag code.
58 ///
David Blaikie770530b2013-10-21 17:28:37 +000059 dwarf::Tag Tag;
Benjamin Kramere697b4f2012-01-24 12:08:28 +000060
61 /// ChildrenFlag - Dwarf children flag.
62 ///
63 uint16_t ChildrenFlag;
Bill Wendling88423ee2009-05-15 00:11:17 +000064
65 /// Unique number for node.
66 ///
67 unsigned Number;
68
Bill Wendling88423ee2009-05-15 00:11:17 +000069 /// Data - Raw data bytes for abbreviation.
70 ///
Eric Christopher2df938a2013-03-29 20:23:06 +000071 SmallVector<DIEAbbrevData, 12> Data;
Devang Patel6404e4e2009-12-15 19:16:48 +000072
Bill Wendling88423ee2009-05-15 00:11:17 +000073 public:
David Blaikie770530b2013-10-21 17:28:37 +000074 DIEAbbrev(dwarf::Tag T, uint16_t C) : Tag(T), ChildrenFlag(C), Data() {}
Bill Wendling88423ee2009-05-15 00:11:17 +000075
76 // Accessors.
David Blaikie770530b2013-10-21 17:28:37 +000077 dwarf::Tag getTag() const { return Tag; }
Bill Wendling88423ee2009-05-15 00:11:17 +000078 unsigned getNumber() const { return Number; }
Benjamin Kramere697b4f2012-01-24 12:08:28 +000079 uint16_t getChildrenFlag() const { return ChildrenFlag; }
Eric Christopherf7cef702013-03-29 23:34:06 +000080 const SmallVectorImpl<DIEAbbrevData> &getData() const { return Data; }
Benjamin Kramere697b4f2012-01-24 12:08:28 +000081 void setChildrenFlag(uint16_t CF) { ChildrenFlag = CF; }
Bill Wendling88423ee2009-05-15 00:11:17 +000082 void setNumber(unsigned N) { Number = N; }
83
84 /// AddAttribute - Adds another set of attribute information to the
85 /// abbreviation.
David Blaikie770530b2013-10-21 17:28:37 +000086 void AddAttribute(dwarf::Attribute Attribute, dwarf::Form Form) {
Bill Wendling88423ee2009-05-15 00:11:17 +000087 Data.push_back(DIEAbbrevData(Attribute, Form));
88 }
89
Bill Wendling88423ee2009-05-15 00:11:17 +000090 /// Profile - Used to gather unique data for the abbreviation folding set.
91 ///
92 void Profile(FoldingSetNodeID &ID) const;
93
94 /// Emit - Print the abbreviation using the specified asm printer.
95 ///
Chris Lattnerd38fee82010-04-05 00:13:49 +000096 void Emit(AsmPrinter *AP) const;
Bill Wendling88423ee2009-05-15 00:11:17 +000097
98#ifndef NDEBUG
Chris Lattnerb01acfa2009-08-23 01:01:17 +000099 void print(raw_ostream &O);
Bill Wendling88423ee2009-05-15 00:11:17 +0000100 void dump();
101#endif
102 };
103
104 //===--------------------------------------------------------------------===//
105 /// DIE - A structured debug information entry. Has an abbreviation which
Eric Christopher0c5cdc52013-04-03 05:29:58 +0000106 /// describes its organization.
Bill Wendling88423ee2009-05-15 00:11:17 +0000107 class DIEValue;
108
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000109 class DIE {
Bill Wendling88423ee2009-05-15 00:11:17 +0000110 protected:
Bill Wendling88423ee2009-05-15 00:11:17 +0000111 /// Offset - Offset in debug info section.
112 ///
113 unsigned Offset;
114
115 /// Size - Size of instance + children.
116 ///
117 unsigned Size;
118
Benjamin Kramere697b4f2012-01-24 12:08:28 +0000119 /// Abbrev - Buffer for constructing abbreviation.
120 ///
121 DIEAbbrev Abbrev;
122
Bill Wendling88423ee2009-05-15 00:11:17 +0000123 /// Children DIEs.
124 ///
125 std::vector<DIE *> Children;
126
Devang Patel6404e4e2009-12-15 19:16:48 +0000127 DIE *Parent;
128
Bill Wendling034b94b2012-12-19 07:18:57 +0000129 /// Attribute values.
Bill Wendling88423ee2009-05-15 00:11:17 +0000130 ///
Eric Christopher2df938a2013-03-29 20:23:06 +0000131 SmallVector<DIEValue*, 12> Values;
Bill Wendling88423ee2009-05-15 00:11:17 +0000132
Bill Wendling88423ee2009-05-15 00:11:17 +0000133 public:
134 explicit DIE(unsigned Tag)
David Blaikie770530b2013-10-21 17:28:37 +0000135 : Offset(0), Size(0), Abbrev((dwarf::Tag)Tag, dwarf::DW_CHILDREN_no),
136 Parent(0) {}
Bill Wendling88423ee2009-05-15 00:11:17 +0000137 virtual ~DIE();
138
139 // Accessors.
140 DIEAbbrev &getAbbrev() { return Abbrev; }
David Blaikie851aa942013-10-24 17:51:43 +0000141 const DIEAbbrev &getAbbrev() const { return Abbrev; }
Bill Wendling88423ee2009-05-15 00:11:17 +0000142 unsigned getAbbrevNumber() const { return Abbrev.getNumber(); }
David Blaikie770530b2013-10-21 17:28:37 +0000143 dwarf::Tag getTag() const { return Abbrev.getTag(); }
Bill Wendling88423ee2009-05-15 00:11:17 +0000144 unsigned getOffset() const { return Offset; }
145 unsigned getSize() const { return Size; }
146 const std::vector<DIE *> &getChildren() const { return Children; }
Eric Christopherf7cef702013-03-29 23:34:06 +0000147 const SmallVectorImpl<DIEValue*> &getValues() const { return Values; }
Devang Patel6404e4e2009-12-15 19:16:48 +0000148 DIE *getParent() const { return Parent; }
Manman Ren3eabc2a2013-10-29 22:57:10 +0000149 /// Climb up the parent chain to get the compile unit DIE this DIE belongs
150 /// to.
151 const DIE *getCompileUnit() const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000152 void setOffset(unsigned O) { Offset = O; }
153 void setSize(unsigned S) { Size = S; }
Eric Christopherff348452013-01-07 22:40:45 +0000154
Devang Patel2c4ceb12009-11-21 02:48:08 +0000155 /// addValue - Add a value and attributes to a DIE.
Bill Wendling88423ee2009-05-15 00:11:17 +0000156 ///
David Blaikie770530b2013-10-21 17:28:37 +0000157 void addValue(dwarf::Attribute Attribute, dwarf::Form Form,
158 DIEValue *Value) {
Bill Wendling88423ee2009-05-15 00:11:17 +0000159 Abbrev.AddAttribute(Attribute, Form);
160 Values.push_back(Value);
161 }
162
Devang Patel2c4ceb12009-11-21 02:48:08 +0000163 /// addChild - Add a child to the DIE.
Bill Wendling88423ee2009-05-15 00:11:17 +0000164 ///
Devang Patel2c4ceb12009-11-21 02:48:08 +0000165 void addChild(DIE *Child) {
David Blaikiee5830c42013-10-03 20:07:20 +0000166 assert(!Child->getParent());
Bill Wendling88423ee2009-05-15 00:11:17 +0000167 Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes);
168 Children.push_back(Child);
Jeffrey Yasskin5c213dc2010-03-12 17:45:06 +0000169 Child->Parent = this;
Bill Wendling88423ee2009-05-15 00:11:17 +0000170 }
171
Eric Christopherb7669132013-08-07 01:18:33 +0000172 /// findAttribute - Find a value in the DIE with the attribute given, returns NULL
173 /// if no such attribute exists.
Eric Christopher31667622013-08-08 01:41:00 +0000174 DIEValue *findAttribute(uint16_t Attribute);
Eric Christopherb7669132013-08-07 01:18:33 +0000175
Bill Wendling88423ee2009-05-15 00:11:17 +0000176#ifndef NDEBUG
Eric Christopher30cb8362013-05-06 17:50:50 +0000177 void print(raw_ostream &O, unsigned IndentCount = 0) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000178 void dump();
179#endif
180 };
181
182 //===--------------------------------------------------------------------===//
183 /// DIEValue - A debug information entry value.
184 ///
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000185 class DIEValue {
David Blaikie2d24e2a2011-12-20 02:50:00 +0000186 virtual void anchor();
Bill Wendling88423ee2009-05-15 00:11:17 +0000187 public:
188 enum {
189 isInteger,
190 isString,
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000191 isExpr,
Bill Wendling88423ee2009-05-15 00:11:17 +0000192 isLabel,
Bill Wendling88423ee2009-05-15 00:11:17 +0000193 isDelta,
194 isEntry,
195 isBlock
196 };
197 protected:
198 /// Type - Type of data stored in the value.
199 ///
200 unsigned Type;
201 public:
202 explicit DIEValue(unsigned T) : Type(T) {}
203 virtual ~DIEValue() {}
204
205 // Accessors
206 unsigned getType() const { return Type; }
207
208 /// EmitValue - Emit value via the Dwarf writer.
209 ///
David Blaikie770530b2013-10-21 17:28:37 +0000210 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const = 0;
Bill Wendling88423ee2009-05-15 00:11:17 +0000211
212 /// SizeOf - Return the size of a value in bytes.
213 ///
David Blaikie770530b2013-10-21 17:28:37 +0000214 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const = 0;
Bill Wendling88423ee2009-05-15 00:11:17 +0000215
Bill Wendling88423ee2009-05-15 00:11:17 +0000216#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000217 virtual void print(raw_ostream &O) const = 0;
218 void dump() const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000219#endif
220 };
221
222 //===--------------------------------------------------------------------===//
223 /// DIEInteger - An integer value DIE.
224 ///
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000225 class DIEInteger : public DIEValue {
Bill Wendling88423ee2009-05-15 00:11:17 +0000226 uint64_t Integer;
227 public:
228 explicit DIEInteger(uint64_t I) : DIEValue(isInteger), Integer(I) {}
229
230 /// BestForm - Choose the best form for integer.
231 ///
David Blaikie770530b2013-10-21 17:28:37 +0000232 static dwarf::Form BestForm(bool IsSigned, uint64_t Int) {
Bill Wendling88423ee2009-05-15 00:11:17 +0000233 if (IsSigned) {
Hans Wennborga12c6742013-03-18 17:03:05 +0000234 const int64_t SignedInt = Int;
235 if ((char)Int == SignedInt) return dwarf::DW_FORM_data1;
236 if ((short)Int == SignedInt) return dwarf::DW_FORM_data2;
237 if ((int)Int == SignedInt) return dwarf::DW_FORM_data4;
Bill Wendling88423ee2009-05-15 00:11:17 +0000238 } else {
239 if ((unsigned char)Int == Int) return dwarf::DW_FORM_data1;
240 if ((unsigned short)Int == Int) return dwarf::DW_FORM_data2;
241 if ((unsigned int)Int == Int) return dwarf::DW_FORM_data4;
242 }
243 return dwarf::DW_FORM_data8;
244 }
245
246 /// EmitValue - Emit integer of appropriate size.
247 ///
David Blaikie770530b2013-10-21 17:28:37 +0000248 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000249
Devang Patelf2548ca2010-04-16 23:33:45 +0000250 uint64_t getValue() const { return Integer; }
251
Bill Wendling88423ee2009-05-15 00:11:17 +0000252 /// SizeOf - Determine size of integer value in bytes.
253 ///
David Blaikie770530b2013-10-21 17:28:37 +0000254 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000255
Bill Wendling88423ee2009-05-15 00:11:17 +0000256 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000257 static bool classof(const DIEValue *I) { return I->getType() == isInteger; }
258
259#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000260 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000261#endif
262 };
263
264 //===--------------------------------------------------------------------===//
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000265 /// DIEExpr - An expression DIE.
266 //
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000267 class DIEExpr : public DIEValue {
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000268 const MCExpr *Expr;
269 public:
270 explicit DIEExpr(const MCExpr *E) : DIEValue(isExpr), Expr(E) {}
271
272 /// EmitValue - Emit expression value.
273 ///
David Blaikie770530b2013-10-21 17:28:37 +0000274 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000275
276 /// getValue - Get MCExpr.
277 ///
278 const MCExpr *getValue() const { return Expr; }
279
280 /// SizeOf - Determine size of expression value in bytes.
281 ///
David Blaikie770530b2013-10-21 17:28:37 +0000282 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000283
284 // Implement isa/cast/dyncast.
285 static bool classof(const DIEValue *E) { return E->getType() == isExpr; }
286
287#ifndef NDEBUG
288 virtual void print(raw_ostream &O) const;
289#endif
290 };
291
292 //===--------------------------------------------------------------------===//
293 /// DIELabel - A label DIE.
Bill Wendling88423ee2009-05-15 00:11:17 +0000294 //
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000295 class DIELabel : public DIEValue {
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000296 const MCSymbol *Label;
Bill Wendling88423ee2009-05-15 00:11:17 +0000297 public:
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000298 explicit DIELabel(const MCSymbol *L) : DIEValue(isLabel), Label(L) {}
Bill Wendling88423ee2009-05-15 00:11:17 +0000299
300 /// EmitValue - Emit label value.
301 ///
David Blaikie770530b2013-10-21 17:28:37 +0000302 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000303
Devang Patelc3f5f782010-05-25 23:40:22 +0000304 /// getValue - Get MCSymbol.
305 ///
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000306 const MCSymbol *getValue() const { return Label; }
Devang Patelc3f5f782010-05-25 23:40:22 +0000307
Bill Wendling88423ee2009-05-15 00:11:17 +0000308 /// SizeOf - Determine size of label value in bytes.
309 ///
David Blaikie770530b2013-10-21 17:28:37 +0000310 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000311
Bill Wendling88423ee2009-05-15 00:11:17 +0000312 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000313 static bool classof(const DIEValue *L) { return L->getType() == isLabel; }
314
315#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000316 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000317#endif
318 };
319
320 //===--------------------------------------------------------------------===//
Bill Wendling88423ee2009-05-15 00:11:17 +0000321 /// DIEDelta - A simple label difference DIE.
322 ///
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000323 class DIEDelta : public DIEValue {
Chris Lattnerb98b1bf2010-03-08 22:23:36 +0000324 const MCSymbol *LabelHi;
325 const MCSymbol *LabelLo;
Bill Wendling88423ee2009-05-15 00:11:17 +0000326 public:
Chris Lattnerb98b1bf2010-03-08 22:23:36 +0000327 DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
Bill Wendling88423ee2009-05-15 00:11:17 +0000328 : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {}
329
330 /// EmitValue - Emit delta value.
331 ///
David Blaikie770530b2013-10-21 17:28:37 +0000332 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000333
334 /// SizeOf - Determine size of delta value in bytes.
335 ///
David Blaikie770530b2013-10-21 17:28:37 +0000336 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000337
Bill Wendling88423ee2009-05-15 00:11:17 +0000338 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000339 static bool classof(const DIEValue *D) { return D->getType() == isDelta; }
340
341#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000342 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000343#endif
344 };
345
346 //===--------------------------------------------------------------------===//
Eric Christopher3dee5752013-07-26 17:02:41 +0000347 /// DIEString - A container for string values.
348 ///
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000349 class DIEString : public DIEValue {
Eric Christopher3dee5752013-07-26 17:02:41 +0000350 const DIEValue *Access;
351 const StringRef Str;
352
353 public:
354 DIEString(const DIEValue *Acc, const StringRef S)
355 : DIEValue(isString), Access(Acc), Str(S) {}
356
357 /// getString - Grab the string out of the object.
358 StringRef getString() const { return Str; }
359
360 /// EmitValue - Emit delta value.
361 ///
David Blaikie770530b2013-10-21 17:28:37 +0000362 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Eric Christopher3dee5752013-07-26 17:02:41 +0000363
364 /// SizeOf - Determine size of delta value in bytes.
365 ///
David Blaikie770530b2013-10-21 17:28:37 +0000366 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
Eric Christopher3dee5752013-07-26 17:02:41 +0000367
368 // Implement isa/cast/dyncast.
369 static bool classof(const DIEValue *D) { return D->getType() == isString; }
370
371 #ifndef NDEBUG
372 virtual void print(raw_ostream &O) const;
373 #endif
374 };
375
376 //===--------------------------------------------------------------------===//
Nick Lewycky024170f2011-10-18 22:39:43 +0000377 /// DIEEntry - A pointer to another debug information entry. An instance of
Bill Wendling88423ee2009-05-15 00:11:17 +0000378 /// this class can also be used as a proxy for a debug information entry not
379 /// yet defined (ie. types.)
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000380 class DIEEntry : public DIEValue {
Jeffrey Yasskin5c213dc2010-03-12 17:45:06 +0000381 DIE *const Entry;
Bill Wendling88423ee2009-05-15 00:11:17 +0000382 public:
David Blaikie17a692e2013-05-14 00:35:19 +0000383 explicit DIEEntry(DIE *E) : DIEValue(isEntry), Entry(E) {
384 assert(E && "Cannot construct a DIEEntry with a null DIE");
385 }
Bill Wendling88423ee2009-05-15 00:11:17 +0000386
387 DIE *getEntry() const { return Entry; }
Bill Wendling88423ee2009-05-15 00:11:17 +0000388
389 /// EmitValue - Emit debug information entry offset.
390 ///
David Blaikie770530b2013-10-21 17:28:37 +0000391 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000392
393 /// SizeOf - Determine size of debug information entry in bytes.
394 ///
David Blaikie770530b2013-10-21 17:28:37 +0000395 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const {
Eric Christopher31667622013-08-08 01:41:00 +0000396 return Form == dwarf::DW_FORM_ref_addr ? getRefAddrSize(AP)
397 : sizeof(int32_t);
Manman Ren624a93e2013-04-04 23:13:11 +0000398 }
Bill Wendling88423ee2009-05-15 00:11:17 +0000399
Manman Ren0e6783f2013-07-02 23:40:10 +0000400 /// Returns size of a ref_addr entry.
401 static unsigned getRefAddrSize(AsmPrinter *AP);
402
Bill Wendling88423ee2009-05-15 00:11:17 +0000403 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000404 static bool classof(const DIEValue *E) { return E->getType() == isEntry; }
405
406#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000407 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000408#endif
409 };
410
411 //===--------------------------------------------------------------------===//
412 /// DIEBlock - A block of values. Primarily used for location expressions.
413 //
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000414 class DIEBlock : public DIEValue, public DIE {
Bill Wendling88423ee2009-05-15 00:11:17 +0000415 unsigned Size; // Size in bytes excluding size header.
416 public:
David Blaikie770530b2013-10-21 17:28:37 +0000417 DIEBlock() : DIEValue(isBlock), DIE(0), Size(0) {}
Bill Wendling88423ee2009-05-15 00:11:17 +0000418
419 /// ComputeSize - calculate the size of the block.
420 ///
Chris Lattnera37d5382010-04-05 00:18:22 +0000421 unsigned ComputeSize(AsmPrinter *AP);
Bill Wendling88423ee2009-05-15 00:11:17 +0000422
423 /// BestForm - Choose the best form for data.
424 ///
David Blaikie770530b2013-10-21 17:28:37 +0000425 dwarf::Form BestForm() const {
Bill Wendling88423ee2009-05-15 00:11:17 +0000426 if ((unsigned char)Size == Size) return dwarf::DW_FORM_block1;
427 if ((unsigned short)Size == Size) return dwarf::DW_FORM_block2;
428 if ((unsigned int)Size == Size) return dwarf::DW_FORM_block4;
429 return dwarf::DW_FORM_block;
430 }
431
432 /// EmitValue - Emit block data.
433 ///
David Blaikie770530b2013-10-21 17:28:37 +0000434 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000435
436 /// SizeOf - Determine size of block data in bytes.
437 ///
David Blaikie770530b2013-10-21 17:28:37 +0000438 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000439
Bill Wendling88423ee2009-05-15 00:11:17 +0000440 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000441 static bool classof(const DIEValue *E) { return E->getType() == isBlock; }
442
443#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000444 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000445#endif
446 };
447
448} // end llvm namespace
449
450#endif