blob: 3f89aea02f785cff278a010c0d103fbc97892fe3 [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 ///
Benjamin Kramere697b4f2012-01-24 12:08:28 +000036 uint16_t Attribute;
Bill Wendling88423ee2009-05-15 00:11:17 +000037
38 /// Form - Dwarf form code.
39 ///
Benjamin Kramere697b4f2012-01-24 12:08:28 +000040 uint16_t Form;
Bill Wendling88423ee2009-05-15 00:11:17 +000041 public:
Benjamin Kramere697b4f2012-01-24 12:08:28 +000042 DIEAbbrevData(uint16_t A, uint16_t F) : Attribute(A), Form(F) {}
Bill Wendling88423ee2009-05-15 00:11:17 +000043
44 // Accessors.
Benjamin Kramere697b4f2012-01-24 12:08:28 +000045 uint16_t getAttribute() const { return Attribute; }
46 uint16_t 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 ///
Benjamin Kramere697b4f2012-01-24 12:08:28 +000059 uint16_t Tag;
60
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:
Benjamin Kramere697b4f2012-01-24 12:08:28 +000074 DIEAbbrev(uint16_t T, uint16_t C) : Tag(T), ChildrenFlag(C), Data() {}
Bill Wendling88423ee2009-05-15 00:11:17 +000075
76 // Accessors.
Benjamin Kramere697b4f2012-01-24 12:08:28 +000077 uint16_t 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.
Benjamin Kramere697b4f2012-01-24 12:08:28 +000086 void AddAttribute(uint16_t Attribute, uint16_t 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
Eric Christopherd32d7a52013-06-10 20:58:53 +0000133#ifndef NDEBUG
Owen Andersond5509f22009-06-24 23:13:56 +0000134 // Private data for print()
135 mutable unsigned IndentCount;
Eric Christopherd32d7a52013-06-10 20:58:53 +0000136#endif
Bill Wendling88423ee2009-05-15 00:11:17 +0000137 public:
138 explicit DIE(unsigned Tag)
Eric Christopher30cb8362013-05-06 17:50:50 +0000139 : Offset(0), Size(0), Abbrev(Tag, dwarf::DW_CHILDREN_no), Parent(0) {}
Bill Wendling88423ee2009-05-15 00:11:17 +0000140 virtual ~DIE();
141
142 // Accessors.
143 DIEAbbrev &getAbbrev() { return Abbrev; }
144 unsigned getAbbrevNumber() const { return Abbrev.getNumber(); }
Eric Christopher31667622013-08-08 01:41:00 +0000145 uint16_t getTag() const { return Abbrev.getTag(); }
Bill Wendling88423ee2009-05-15 00:11:17 +0000146 unsigned getOffset() const { return Offset; }
147 unsigned getSize() const { return Size; }
148 const std::vector<DIE *> &getChildren() const { return Children; }
Eric Christopherf7cef702013-03-29 23:34:06 +0000149 const SmallVectorImpl<DIEValue*> &getValues() const { return Values; }
Devang Patel6404e4e2009-12-15 19:16:48 +0000150 DIE *getParent() const { return Parent; }
Bill Wendling88423ee2009-05-15 00:11:17 +0000151 void setOffset(unsigned O) { Offset = O; }
152 void setSize(unsigned S) { Size = S; }
Eric Christopherff348452013-01-07 22:40:45 +0000153
Devang Patel2c4ceb12009-11-21 02:48:08 +0000154 /// addValue - Add a value and attributes to a DIE.
Bill Wendling88423ee2009-05-15 00:11:17 +0000155 ///
Eric Christopher31667622013-08-08 01:41:00 +0000156 void addValue(uint16_t Attribute, uint16_t Form, DIEValue *Value) {
Bill Wendling88423ee2009-05-15 00:11:17 +0000157 Abbrev.AddAttribute(Attribute, Form);
158 Values.push_back(Value);
159 }
160
Devang Patel2c4ceb12009-11-21 02:48:08 +0000161 /// addChild - Add a child to the DIE.
Bill Wendling88423ee2009-05-15 00:11:17 +0000162 ///
Devang Patel2c4ceb12009-11-21 02:48:08 +0000163 void addChild(DIE *Child) {
David Blaikiee5830c42013-10-03 20:07:20 +0000164 assert(!Child->getParent());
Bill Wendling88423ee2009-05-15 00:11:17 +0000165 Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes);
166 Children.push_back(Child);
Jeffrey Yasskin5c213dc2010-03-12 17:45:06 +0000167 Child->Parent = this;
Bill Wendling88423ee2009-05-15 00:11:17 +0000168 }
169
Eric Christopherb7669132013-08-07 01:18:33 +0000170 /// findAttribute - Find a value in the DIE with the attribute given, returns NULL
171 /// if no such attribute exists.
Eric Christopher31667622013-08-08 01:41:00 +0000172 DIEValue *findAttribute(uint16_t Attribute);
Eric Christopherb7669132013-08-07 01:18:33 +0000173
Bill Wendling88423ee2009-05-15 00:11:17 +0000174#ifndef NDEBUG
Eric Christopher30cb8362013-05-06 17:50:50 +0000175 void print(raw_ostream &O, unsigned IndentCount = 0) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000176 void dump();
177#endif
178 };
179
180 //===--------------------------------------------------------------------===//
181 /// DIEValue - A debug information entry value.
182 ///
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000183 class DIEValue {
David Blaikie2d24e2a2011-12-20 02:50:00 +0000184 virtual void anchor();
Bill Wendling88423ee2009-05-15 00:11:17 +0000185 public:
186 enum {
187 isInteger,
188 isString,
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000189 isExpr,
Bill Wendling88423ee2009-05-15 00:11:17 +0000190 isLabel,
Bill Wendling88423ee2009-05-15 00:11:17 +0000191 isDelta,
192 isEntry,
193 isBlock
194 };
195 protected:
196 /// Type - Type of data stored in the value.
197 ///
198 unsigned Type;
199 public:
200 explicit DIEValue(unsigned T) : Type(T) {}
201 virtual ~DIEValue() {}
202
203 // Accessors
204 unsigned getType() const { return Type; }
205
206 /// EmitValue - Emit value via the Dwarf writer.
207 ///
Eric Christopher31667622013-08-08 01:41:00 +0000208 virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const = 0;
Bill Wendling88423ee2009-05-15 00:11:17 +0000209
210 /// SizeOf - Return the size of a value in bytes.
211 ///
Eric Christopher31667622013-08-08 01:41:00 +0000212 virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const = 0;
Bill Wendling88423ee2009-05-15 00:11:17 +0000213
Bill Wendling88423ee2009-05-15 00:11:17 +0000214#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000215 virtual void print(raw_ostream &O) const = 0;
216 void dump() const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000217#endif
218 };
219
220 //===--------------------------------------------------------------------===//
221 /// DIEInteger - An integer value DIE.
222 ///
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000223 class DIEInteger : public DIEValue {
Bill Wendling88423ee2009-05-15 00:11:17 +0000224 uint64_t Integer;
225 public:
226 explicit DIEInteger(uint64_t I) : DIEValue(isInteger), Integer(I) {}
227
228 /// BestForm - Choose the best form for integer.
229 ///
Eric Christopher31667622013-08-08 01:41:00 +0000230 static uint16_t BestForm(bool IsSigned, uint64_t Int) {
Bill Wendling88423ee2009-05-15 00:11:17 +0000231 if (IsSigned) {
Hans Wennborga12c6742013-03-18 17:03:05 +0000232 const int64_t SignedInt = Int;
233 if ((char)Int == SignedInt) return dwarf::DW_FORM_data1;
234 if ((short)Int == SignedInt) return dwarf::DW_FORM_data2;
235 if ((int)Int == SignedInt) return dwarf::DW_FORM_data4;
Bill Wendling88423ee2009-05-15 00:11:17 +0000236 } else {
237 if ((unsigned char)Int == Int) return dwarf::DW_FORM_data1;
238 if ((unsigned short)Int == Int) return dwarf::DW_FORM_data2;
239 if ((unsigned int)Int == Int) return dwarf::DW_FORM_data4;
240 }
241 return dwarf::DW_FORM_data8;
242 }
243
244 /// EmitValue - Emit integer of appropriate size.
245 ///
Eric Christopher31667622013-08-08 01:41:00 +0000246 virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000247
Devang Patelf2548ca2010-04-16 23:33:45 +0000248 uint64_t getValue() const { return Integer; }
249
Bill Wendling88423ee2009-05-15 00:11:17 +0000250 /// SizeOf - Determine size of integer value in bytes.
251 ///
Eric Christopher31667622013-08-08 01:41:00 +0000252 virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000253
Bill Wendling88423ee2009-05-15 00:11:17 +0000254 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000255 static bool classof(const DIEValue *I) { return I->getType() == isInteger; }
256
257#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000258 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000259#endif
260 };
261
262 //===--------------------------------------------------------------------===//
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000263 /// DIEExpr - An expression DIE.
264 //
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000265 class DIEExpr : public DIEValue {
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000266 const MCExpr *Expr;
267 public:
268 explicit DIEExpr(const MCExpr *E) : DIEValue(isExpr), Expr(E) {}
269
270 /// EmitValue - Emit expression value.
271 ///
Eric Christopher31667622013-08-08 01:41:00 +0000272 virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const;
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000273
274 /// getValue - Get MCExpr.
275 ///
276 const MCExpr *getValue() const { return Expr; }
277
278 /// SizeOf - Determine size of expression value in bytes.
279 ///
Eric Christopher31667622013-08-08 01:41:00 +0000280 virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const;
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000281
282 // Implement isa/cast/dyncast.
283 static bool classof(const DIEValue *E) { return E->getType() == isExpr; }
284
285#ifndef NDEBUG
286 virtual void print(raw_ostream &O) const;
287#endif
288 };
289
290 //===--------------------------------------------------------------------===//
291 /// DIELabel - A label DIE.
Bill Wendling88423ee2009-05-15 00:11:17 +0000292 //
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000293 class DIELabel : public DIEValue {
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000294 const MCSymbol *Label;
Bill Wendling88423ee2009-05-15 00:11:17 +0000295 public:
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000296 explicit DIELabel(const MCSymbol *L) : DIEValue(isLabel), Label(L) {}
Bill Wendling88423ee2009-05-15 00:11:17 +0000297
298 /// EmitValue - Emit label value.
299 ///
Eric Christopher31667622013-08-08 01:41:00 +0000300 virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000301
Devang Patelc3f5f782010-05-25 23:40:22 +0000302 /// getValue - Get MCSymbol.
303 ///
Ulrich Weigand1f8aacd2013-07-02 18:46:26 +0000304 const MCSymbol *getValue() const { return Label; }
Devang Patelc3f5f782010-05-25 23:40:22 +0000305
Bill Wendling88423ee2009-05-15 00:11:17 +0000306 /// SizeOf - Determine size of label value in bytes.
307 ///
Eric Christopher31667622013-08-08 01:41:00 +0000308 virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000309
Bill Wendling88423ee2009-05-15 00:11:17 +0000310 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000311 static bool classof(const DIEValue *L) { return L->getType() == isLabel; }
312
313#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000314 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000315#endif
316 };
317
318 //===--------------------------------------------------------------------===//
Bill Wendling88423ee2009-05-15 00:11:17 +0000319 /// DIEDelta - A simple label difference DIE.
320 ///
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000321 class DIEDelta : public DIEValue {
Chris Lattnerb98b1bf2010-03-08 22:23:36 +0000322 const MCSymbol *LabelHi;
323 const MCSymbol *LabelLo;
Bill Wendling88423ee2009-05-15 00:11:17 +0000324 public:
Chris Lattnerb98b1bf2010-03-08 22:23:36 +0000325 DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo)
Bill Wendling88423ee2009-05-15 00:11:17 +0000326 : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {}
327
328 /// EmitValue - Emit delta value.
329 ///
Eric Christopher31667622013-08-08 01:41:00 +0000330 virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000331
332 /// SizeOf - Determine size of delta value in bytes.
333 ///
Eric Christopher31667622013-08-08 01:41:00 +0000334 virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000335
Bill Wendling88423ee2009-05-15 00:11:17 +0000336 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000337 static bool classof(const DIEValue *D) { return D->getType() == isDelta; }
338
339#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000340 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000341#endif
342 };
343
344 //===--------------------------------------------------------------------===//
Eric Christopher3dee5752013-07-26 17:02:41 +0000345 /// DIEString - A container for string values.
346 ///
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000347 class DIEString : public DIEValue {
Eric Christopher3dee5752013-07-26 17:02:41 +0000348 const DIEValue *Access;
349 const StringRef Str;
350
351 public:
352 DIEString(const DIEValue *Acc, const StringRef S)
353 : DIEValue(isString), Access(Acc), Str(S) {}
354
355 /// getString - Grab the string out of the object.
356 StringRef getString() const { return Str; }
357
358 /// EmitValue - Emit delta value.
359 ///
Eric Christopher31667622013-08-08 01:41:00 +0000360 virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const;
Eric Christopher3dee5752013-07-26 17:02:41 +0000361
362 /// SizeOf - Determine size of delta value in bytes.
363 ///
Eric Christopher31667622013-08-08 01:41:00 +0000364 virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const;
Eric Christopher3dee5752013-07-26 17:02:41 +0000365
366 // Implement isa/cast/dyncast.
367 static bool classof(const DIEValue *D) { return D->getType() == isString; }
368
369 #ifndef NDEBUG
370 virtual void print(raw_ostream &O) const;
371 #endif
372 };
373
374 //===--------------------------------------------------------------------===//
Nick Lewycky024170f2011-10-18 22:39:43 +0000375 /// DIEEntry - A pointer to another debug information entry. An instance of
Bill Wendling88423ee2009-05-15 00:11:17 +0000376 /// this class can also be used as a proxy for a debug information entry not
377 /// yet defined (ie. types.)
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000378 class DIEEntry : public DIEValue {
Jeffrey Yasskin5c213dc2010-03-12 17:45:06 +0000379 DIE *const Entry;
Bill Wendling88423ee2009-05-15 00:11:17 +0000380 public:
David Blaikie17a692e2013-05-14 00:35:19 +0000381 explicit DIEEntry(DIE *E) : DIEValue(isEntry), Entry(E) {
382 assert(E && "Cannot construct a DIEEntry with a null DIE");
383 }
Bill Wendling88423ee2009-05-15 00:11:17 +0000384
385 DIE *getEntry() const { return Entry; }
Bill Wendling88423ee2009-05-15 00:11:17 +0000386
387 /// EmitValue - Emit debug information entry offset.
388 ///
Eric Christopher31667622013-08-08 01:41:00 +0000389 virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000390
391 /// SizeOf - Determine size of debug information entry in bytes.
392 ///
Eric Christopher31667622013-08-08 01:41:00 +0000393 virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const {
394 return Form == dwarf::DW_FORM_ref_addr ? getRefAddrSize(AP)
395 : sizeof(int32_t);
Manman Ren624a93e2013-04-04 23:13:11 +0000396 }
Bill Wendling88423ee2009-05-15 00:11:17 +0000397
Manman Ren0e6783f2013-07-02 23:40:10 +0000398 /// Returns size of a ref_addr entry.
399 static unsigned getRefAddrSize(AsmPrinter *AP);
400
Bill Wendling88423ee2009-05-15 00:11:17 +0000401 // Implement isa/cast/dyncast.
Bill Wendling88423ee2009-05-15 00:11:17 +0000402 static bool classof(const DIEValue *E) { return E->getType() == isEntry; }
403
404#ifndef NDEBUG
Eric Christopher813419e2013-05-31 22:50:40 +0000405 virtual void print(raw_ostream &O) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000406#endif
407 };
408
409 //===--------------------------------------------------------------------===//
410 /// DIEBlock - A block of values. Primarily used for location expressions.
411 //
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000412 class DIEBlock : public DIEValue, public DIE {
Bill Wendling88423ee2009-05-15 00:11:17 +0000413 unsigned Size; // Size in bytes excluding size header.
414 public:
415 DIEBlock()
416 : DIEValue(isBlock), DIE(0), Size(0) {}
417 virtual ~DIEBlock() {}
418
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 ///
Eric Christopher31667622013-08-08 01:41:00 +0000425 uint16_t 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 ///
Eric Christopher31667622013-08-08 01:41:00 +0000434 virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const;
Bill Wendling88423ee2009-05-15 00:11:17 +0000435
436 /// SizeOf - Determine size of block data in bytes.
437 ///
Eric Christopher31667622013-08-08 01:41:00 +0000438 virtual unsigned SizeOf(AsmPrinter *AP, uint16_t 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