blob: 6d4f305c84005573b079edc89401910ff86076e0 [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; }
Bill Wendling88423ee2009-05-15 00:11:17 +0000149 void setOffset(unsigned O) { Offset = O; }
150 void setSize(unsigned S) { Size = S; }
Eric Christopherff348452013-01-07 22:40:45 +0000151
Devang Patel2c4ceb12009-11-21 02:48:08 +0000152 /// addValue - Add a value and attributes to a DIE.
Bill Wendling88423ee2009-05-15 00:11:17 +0000153 ///
David Blaikie770530b2013-10-21 17:28:37 +0000154 void addValue(dwarf::Attribute Attribute, dwarf::Form Form,
155 DIEValue *Value) {
Bill Wendling88423ee2009-05-15 00:11:17 +0000156 Abbrev.AddAttribute(Attribute, Form);
157 Values.push_back(Value);
158 }
159
Devang Patel2c4ceb12009-11-21 02:48:08 +0000160 /// addChild - Add a child to the DIE.
Bill Wendling88423ee2009-05-15 00:11:17 +0000161 ///
Devang Patel2c4ceb12009-11-21 02:48:08 +0000162 void addChild(DIE *Child) {
David Blaikiee5830c42013-10-03 20:07:20 +0000163 assert(!Child->getParent());
Bill Wendling88423ee2009-05-15 00:11:17 +0000164 Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes);
165 Children.push_back(Child);
Jeffrey Yasskin5c213dc2010-03-12 17:45:06 +0000166 Child->Parent = this;
Bill Wendling88423ee2009-05-15 00:11:17 +0000167 }
168
Eric Christopherb7669132013-08-07 01:18:33 +0000169 /// findAttribute - Find a value in the DIE with the attribute given, returns NULL
170 /// if no such attribute exists.
Eric Christopher31667622013-08-08 01:41:00 +0000171 DIEValue *findAttribute(uint16_t Attribute);
Eric Christopherb7669132013-08-07 01:18:33 +0000172
Bill Wendling88423ee2009-05-15 00:11:17 +0000173#ifndef NDEBUG
Eric Christopher30cb8362013-05-06 17:50:50 +0000174 void print(raw_ostream &O, unsigned IndentCount = 0) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000175 void dump();
176#endif
177 };
178
179 //===--------------------------------------------------------------------===//
180 /// DIEValue - A debug information entry value.
181 ///
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000182 class DIEValue {
David Blaikie2d24e2a2011-12-20 02:50:00 +0000183 virtual void anchor();
Bill Wendling88423ee2009-05-15 00:11:17 +0000184 public:
185 enum {
186 isInteger,
187 isString,
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000188 isExpr,
Bill Wendling88423ee2009-05-15 00:11:17 +0000189 isLabel,
Bill Wendling88423ee2009-05-15 00:11:17 +0000190 isDelta,
191 isEntry,
192 isBlock
193 };
194 protected:
195 /// Type - Type of data stored in the value.
196 ///
197 unsigned Type;
198 public:
199 explicit DIEValue(unsigned T) : Type(T) {}
200 virtual ~DIEValue() {}
201
202 // Accessors
203 unsigned getType() const { return Type; }
204
205 /// EmitValue - Emit value via the Dwarf writer.
206 ///
David Blaikie770530b2013-10-21 17:28:37 +0000207 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const = 0;
Bill Wendling88423ee2009-05-15 00:11:17 +0000208
209 /// SizeOf - Return the size of a value in bytes.
210 ///
David Blaikie770530b2013-10-21 17:28:37 +0000211 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const = 0;
Bill Wendling88423ee2009-05-15 00:11:17 +0000212
Bill Wendling88423ee2009-05-15 00:11:17 +0000213#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000214 virtual void print(raw_ostream &O) const = 0;
215 void dump() const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000216#endif
217 };
218
219 //===--------------------------------------------------------------------===//
220 /// DIEInteger - An integer value DIE.
221 ///
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000222 class DIEInteger : public DIEValue {
Bill Wendling88423ee2009-05-15 00:11:17 +0000223 uint64_t Integer;
224 public:
225 explicit DIEInteger(uint64_t I) : DIEValue(isInteger), Integer(I) {}
226
227 /// BestForm - Choose the best form for integer.
228 ///
David Blaikie770530b2013-10-21 17:28:37 +0000229 static dwarf::Form BestForm(bool IsSigned, uint64_t Int) {
Bill Wendling88423ee2009-05-15 00:11:17 +0000230 if (IsSigned) {
Hans Wennborga12c6742013-03-18 17:03:05 +0000231 const int64_t SignedInt = Int;
232 if ((char)Int == SignedInt) return dwarf::DW_FORM_data1;
233 if ((short)Int == SignedInt) return dwarf::DW_FORM_data2;
234 if ((int)Int == SignedInt) return dwarf::DW_FORM_data4;
Bill Wendling88423ee2009-05-15 00:11:17 +0000235 } else {
236 if ((unsigned char)Int == Int) return dwarf::DW_FORM_data1;
237 if ((unsigned short)Int == Int) return dwarf::DW_FORM_data2;
238 if ((unsigned int)Int == Int) return dwarf::DW_FORM_data4;
239 }
240 return dwarf::DW_FORM_data8;
241 }
242
243 /// EmitValue - Emit integer of appropriate size.
244 ///
David Blaikie770530b2013-10-21 17:28:37 +0000245 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000246
Devang Patelf2548ca2010-04-16 23:33:45 +0000247 uint64_t getValue() const { return Integer; }
248
Bill Wendling88423ee2009-05-15 00:11:17 +0000249 /// SizeOf - Determine size of integer value in bytes.
250 ///
David Blaikie770530b2013-10-21 17:28:37 +0000251 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000252
Bill Wendling88423ee2009-05-15 00:11:17 +0000253 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000254 static bool classof(const DIEValue *I) { return I->getType() == isInteger; }
255
256#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000257 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000258#endif
259 };
260
261 //===--------------------------------------------------------------------===//
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000262 /// DIEExpr - An expression DIE.
263 //
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000264 class DIEExpr : public DIEValue {
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000265 const MCExpr *Expr;
266 public:
267 explicit DIEExpr(const MCExpr *E) : DIEValue(isExpr), Expr(E) {}
268
269 /// EmitValue - Emit expression value.
270 ///
David Blaikie770530b2013-10-21 17:28:37 +0000271 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000272
273 /// getValue - Get MCExpr.
274 ///
275 const MCExpr *getValue() const { return Expr; }
276
277 /// SizeOf - Determine size of expression value in bytes.
278 ///
David Blaikie770530b2013-10-21 17:28:37 +0000279 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000280
281 // Implement isa/cast/dyncast.
282 static bool classof(const DIEValue *E) { return E->getType() == isExpr; }
283
284#ifndef NDEBUG
285 virtual void print(raw_ostream &O) const;
286#endif
287 };
288
289 //===--------------------------------------------------------------------===//
290 /// DIELabel - A label DIE.
Bill Wendling88423ee2009-05-15 00:11:17 +0000291 //
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000292 class DIELabel : public DIEValue {
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000293 const MCSymbol *Label;
Bill Wendling88423ee2009-05-15 00:11:17 +0000294 public:
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000295 explicit DIELabel(const MCSymbol *L) : DIEValue(isLabel), Label(L) {}
Bill Wendling88423ee2009-05-15 00:11:17 +0000296
297 /// EmitValue - Emit label value.
298 ///
David Blaikie770530b2013-10-21 17:28:37 +0000299 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000300
Devang Patelc3f5f782010-05-25 23:40:22 +0000301 /// getValue - Get MCSymbol.
302 ///
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000303 const MCSymbol *getValue() const { return Label; }
Devang Patelc3f5f782010-05-25 23:40:22 +0000304
Bill Wendling88423ee2009-05-15 00:11:17 +0000305 /// SizeOf - Determine size of label value in bytes.
306 ///
David Blaikie770530b2013-10-21 17:28:37 +0000307 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000308
Bill Wendling88423ee2009-05-15 00:11:17 +0000309 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000310 static bool classof(const DIEValue *L) { return L->getType() == isLabel; }
311
312#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000313 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000314#endif
315 };
316
317 //===--------------------------------------------------------------------===//
Bill Wendling88423ee2009-05-15 00:11:17 +0000318 /// DIEDelta - A simple label difference DIE.
319 ///
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000320 class DIEDelta : public DIEValue {
Chris Lattnerb98b1bf2010-03-08 22:23:36 +0000321 const MCSymbol *LabelHi;
322 const MCSymbol *LabelLo;
Bill Wendling88423ee2009-05-15 00:11:17 +0000323 public:
Chris Lattnerb98b1bf2010-03-08 22:23:36 +0000324 DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
Bill Wendling88423ee2009-05-15 00:11:17 +0000325 : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {}
326
327 /// EmitValue - Emit delta value.
328 ///
David Blaikie770530b2013-10-21 17:28:37 +0000329 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000330
331 /// SizeOf - Determine size of delta value in bytes.
332 ///
David Blaikie770530b2013-10-21 17:28:37 +0000333 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000334
Bill Wendling88423ee2009-05-15 00:11:17 +0000335 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000336 static bool classof(const DIEValue *D) { return D->getType() == isDelta; }
337
338#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000339 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000340#endif
341 };
342
343 //===--------------------------------------------------------------------===//
Eric Christopher3dee5752013-07-26 17:02:41 +0000344 /// DIEString - A container for string values.
345 ///
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000346 class DIEString : public DIEValue {
Eric Christopher3dee5752013-07-26 17:02:41 +0000347 const DIEValue *Access;
348 const StringRef Str;
349
350 public:
351 DIEString(const DIEValue *Acc, const StringRef S)
352 : DIEValue(isString), Access(Acc), Str(S) {}
353
354 /// getString - Grab the string out of the object.
355 StringRef getString() const { return Str; }
356
357 /// EmitValue - Emit delta value.
358 ///
David Blaikie770530b2013-10-21 17:28:37 +0000359 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Eric Christopher3dee5752013-07-26 17:02:41 +0000360
361 /// SizeOf - Determine size of delta value in bytes.
362 ///
David Blaikie770530b2013-10-21 17:28:37 +0000363 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
Eric Christopher3dee5752013-07-26 17:02:41 +0000364
365 // Implement isa/cast/dyncast.
366 static bool classof(const DIEValue *D) { return D->getType() == isString; }
367
368 #ifndef NDEBUG
369 virtual void print(raw_ostream &O) const;
370 #endif
371 };
372
373 //===--------------------------------------------------------------------===//
Nick Lewycky024170f2011-10-18 22:39:43 +0000374 /// DIEEntry - A pointer to another debug information entry. An instance of
Bill Wendling88423ee2009-05-15 00:11:17 +0000375 /// this class can also be used as a proxy for a debug information entry not
376 /// yet defined (ie. types.)
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000377 class DIEEntry : public DIEValue {
Jeffrey Yasskin5c213dc2010-03-12 17:45:06 +0000378 DIE *const Entry;
Bill Wendling88423ee2009-05-15 00:11:17 +0000379 public:
David Blaikie17a692e2013-05-14 00:35:19 +0000380 explicit DIEEntry(DIE *E) : DIEValue(isEntry), Entry(E) {
381 assert(E && "Cannot construct a DIEEntry with a null DIE");
382 }
Bill Wendling88423ee2009-05-15 00:11:17 +0000383
384 DIE *getEntry() const { return Entry; }
Bill Wendling88423ee2009-05-15 00:11:17 +0000385
386 /// EmitValue - Emit debug information entry offset.
387 ///
David Blaikie770530b2013-10-21 17:28:37 +0000388 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000389
390 /// SizeOf - Determine size of debug information entry in bytes.
391 ///
David Blaikie770530b2013-10-21 17:28:37 +0000392 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const {
Eric Christopher31667622013-08-08 01:41:00 +0000393 return Form == dwarf::DW_FORM_ref_addr ? getRefAddrSize(AP)
394 : sizeof(int32_t);
Manman Ren624a93e2013-04-04 23:13:11 +0000395 }
Bill Wendling88423ee2009-05-15 00:11:17 +0000396
Manman Ren0e6783f2013-07-02 23:40:10 +0000397 /// Returns size of a ref_addr entry.
398 static unsigned getRefAddrSize(AsmPrinter *AP);
399
Bill Wendling88423ee2009-05-15 00:11:17 +0000400 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000401 static bool classof(const DIEValue *E) { return E->getType() == isEntry; }
402
403#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000404 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000405#endif
406 };
407
408 //===--------------------------------------------------------------------===//
409 /// DIEBlock - A block of values. Primarily used for location expressions.
410 //
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000411 class DIEBlock : public DIEValue, public DIE {
Bill Wendling88423ee2009-05-15 00:11:17 +0000412 unsigned Size; // Size in bytes excluding size header.
413 public:
David Blaikie770530b2013-10-21 17:28:37 +0000414 DIEBlock() : DIEValue(isBlock), DIE(0), Size(0) {}
Bill Wendling88423ee2009-05-15 00:11:17 +0000415
416 /// ComputeSize - calculate the size of the block.
417 ///
Chris Lattnera37d5382010-04-05 00:18:22 +0000418 unsigned ComputeSize(AsmPrinter *AP);
Bill Wendling88423ee2009-05-15 00:11:17 +0000419
420 /// BestForm - Choose the best form for data.
421 ///
David Blaikie770530b2013-10-21 17:28:37 +0000422 dwarf::Form BestForm() const {
Bill Wendling88423ee2009-05-15 00:11:17 +0000423 if ((unsigned char)Size == Size) return dwarf::DW_FORM_block1;
424 if ((unsigned short)Size == Size) return dwarf::DW_FORM_block2;
425 if ((unsigned int)Size == Size) return dwarf::DW_FORM_block4;
426 return dwarf::DW_FORM_block;
427 }
428
429 /// EmitValue - Emit block data.
430 ///
David Blaikie770530b2013-10-21 17:28:37 +0000431 virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000432
433 /// SizeOf - Determine size of block data in bytes.
434 ///
David Blaikie770530b2013-10-21 17:28:37 +0000435 virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000436
Bill Wendling88423ee2009-05-15 00:11:17 +0000437 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000438 static bool classof(const DIEValue *E) { return E->getType() == isBlock; }
439
440#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000441 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000442#endif
443 };
444
445} // end llvm namespace
446
447#endif