Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 1 | //===--- 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. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Bill Wendling | 0310d76 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 14 | #ifndef CODEGEN_ASMPRINTER_DIE_H__ |
| 15 | #define CODEGEN_ASMPRINTER_DIE_H__ |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 16 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/FoldingSet.h" |
| 18 | #include "llvm/ADT/SmallVector.h" |
| 19 | #include "llvm/Support/Compiler.h" |
| 20 | #include "llvm/Support/Dwarf.h" |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 21 | #include <vector> |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 22 | |
| 23 | namespace llvm { |
| 24 | class AsmPrinter; |
Chris Lattner | 858431d | 2010-01-16 18:50:28 +0000 | [diff] [blame] | 25 | class MCSymbol; |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 26 | class raw_ostream; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 27 | |
| 28 | //===--------------------------------------------------------------------===// |
| 29 | /// DIEAbbrevData - Dwarf abbreviation data, describes the one attribute of a |
| 30 | /// Dwarf abbreviation. |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 31 | class DIEAbbrevData { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 32 | /// Attribute - Dwarf attribute code. |
| 33 | /// |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame^] | 34 | uint16_t Attribute; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 35 | |
| 36 | /// Form - Dwarf form code. |
| 37 | /// |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame^] | 38 | uint16_t Form; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 39 | public: |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame^] | 40 | DIEAbbrevData(uint16_t A, uint16_t F) : Attribute(A), Form(F) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 41 | |
| 42 | // Accessors. |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame^] | 43 | uint16_t getAttribute() const { return Attribute; } |
| 44 | uint16_t getForm() const { return Form; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 45 | |
| 46 | /// Profile - Used to gather unique data for the abbreviation folding set. |
| 47 | /// |
| 48 | void Profile(FoldingSetNodeID &ID) const; |
| 49 | }; |
| 50 | |
| 51 | //===--------------------------------------------------------------------===// |
| 52 | /// DIEAbbrev - Dwarf abbreviation, describes the organization of a debug |
| 53 | /// information object. |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 54 | class DIEAbbrev : public FoldingSetNode { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 55 | /// Tag - Dwarf tag code. |
| 56 | /// |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame^] | 57 | uint16_t Tag; |
| 58 | |
| 59 | /// ChildrenFlag - Dwarf children flag. |
| 60 | /// |
| 61 | uint16_t ChildrenFlag; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 62 | |
| 63 | /// Unique number for node. |
| 64 | /// |
| 65 | unsigned Number; |
| 66 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 67 | /// Data - Raw data bytes for abbreviation. |
| 68 | /// |
| 69 | SmallVector<DIEAbbrevData, 8> Data; |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 70 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 71 | public: |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame^] | 72 | DIEAbbrev(uint16_t T, uint16_t C) : Tag(T), ChildrenFlag(C), Data() {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 73 | |
| 74 | // Accessors. |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame^] | 75 | uint16_t getTag() const { return Tag; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 76 | unsigned getNumber() const { return Number; } |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame^] | 77 | uint16_t getChildrenFlag() const { return ChildrenFlag; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 78 | const SmallVector<DIEAbbrevData, 8> &getData() const { return Data; } |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame^] | 79 | void setTag(uint16_t T) { Tag = T; } |
| 80 | void setChildrenFlag(uint16_t CF) { ChildrenFlag = CF; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 81 | void setNumber(unsigned N) { Number = N; } |
| 82 | |
| 83 | /// AddAttribute - Adds another set of attribute information to the |
| 84 | /// abbreviation. |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame^] | 85 | void AddAttribute(uint16_t Attribute, uint16_t Form) { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 86 | Data.push_back(DIEAbbrevData(Attribute, Form)); |
| 87 | } |
| 88 | |
| 89 | /// AddFirstAttribute - Adds a set of attribute information to the front |
| 90 | /// of the abbreviation. |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame^] | 91 | void AddFirstAttribute(uint16_t Attribute, uint16_t Form) { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 92 | Data.insert(Data.begin(), DIEAbbrevData(Attribute, Form)); |
| 93 | } |
| 94 | |
| 95 | /// Profile - Used to gather unique data for the abbreviation folding set. |
| 96 | /// |
| 97 | void Profile(FoldingSetNodeID &ID) const; |
| 98 | |
| 99 | /// Emit - Print the abbreviation using the specified asm printer. |
| 100 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 101 | void Emit(AsmPrinter *AP) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 102 | |
| 103 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 104 | void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 105 | void dump(); |
| 106 | #endif |
| 107 | }; |
| 108 | |
| 109 | //===--------------------------------------------------------------------===// |
| 110 | /// DIE - A structured debug information entry. Has an abbreviation which |
| 111 | /// describes it's organization. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 112 | class DIEValue; |
| 113 | |
Devang Patel | 6f01d9c | 2009-11-21 00:31:03 +0000 | [diff] [blame] | 114 | class DIE { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 115 | protected: |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 116 | /// Offset - Offset in debug info section. |
| 117 | /// |
| 118 | unsigned Offset; |
| 119 | |
| 120 | /// Size - Size of instance + children. |
| 121 | /// |
| 122 | unsigned Size; |
| 123 | |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame^] | 124 | /// Abbrev - Buffer for constructing abbreviation. |
| 125 | /// |
| 126 | DIEAbbrev Abbrev; |
| 127 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 128 | /// Children DIEs. |
| 129 | /// |
| 130 | std::vector<DIE *> Children; |
| 131 | |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 132 | DIE *Parent; |
| 133 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 134 | /// Attributes values. |
| 135 | /// |
| 136 | SmallVector<DIEValue*, 32> Values; |
| 137 | |
Owen Anderson | d5509f2 | 2009-06-24 23:13:56 +0000 | [diff] [blame] | 138 | // Private data for print() |
| 139 | mutable unsigned IndentCount; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 140 | public: |
| 141 | explicit DIE(unsigned Tag) |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame^] | 142 | : Offset(0), Size(0), Abbrev(Tag, dwarf::DW_CHILDREN_no), Parent(0), |
| 143 | IndentCount(0) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 144 | virtual ~DIE(); |
| 145 | |
| 146 | // Accessors. |
| 147 | DIEAbbrev &getAbbrev() { return Abbrev; } |
| 148 | unsigned getAbbrevNumber() const { return Abbrev.getNumber(); } |
| 149 | unsigned getTag() const { return Abbrev.getTag(); } |
| 150 | unsigned getOffset() const { return Offset; } |
| 151 | unsigned getSize() const { return Size; } |
| 152 | const std::vector<DIE *> &getChildren() const { return Children; } |
Jeffrey Yasskin | 638fe8d | 2010-03-22 18:47:14 +0000 | [diff] [blame] | 153 | const SmallVector<DIEValue*, 32> &getValues() const { return Values; } |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 154 | DIE *getParent() const { return Parent; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 155 | void setTag(unsigned Tag) { Abbrev.setTag(Tag); } |
| 156 | void setOffset(unsigned O) { Offset = O; } |
| 157 | void setSize(unsigned S) { Size = S; } |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 158 | |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 159 | /// addValue - Add a value and attributes to a DIE. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 160 | /// |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 161 | void addValue(unsigned Attribute, unsigned Form, DIEValue *Value) { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 162 | Abbrev.AddAttribute(Attribute, Form); |
| 163 | Values.push_back(Value); |
| 164 | } |
| 165 | |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 166 | /// addChild - Add a child to the DIE. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 167 | /// |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 168 | void addChild(DIE *Child) { |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 169 | if (Child->getParent()) { |
| 170 | assert (Child->getParent() == this && "Unexpected DIE Parent!"); |
| 171 | return; |
| 172 | } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 173 | Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes); |
| 174 | Children.push_back(Child); |
Jeffrey Yasskin | 5c213dc | 2010-03-12 17:45:06 +0000 | [diff] [blame] | 175 | Child->Parent = this; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 178 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 179 | void print(raw_ostream &O, unsigned IncIndent = 0); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 180 | void dump(); |
| 181 | #endif |
| 182 | }; |
| 183 | |
| 184 | //===--------------------------------------------------------------------===// |
| 185 | /// DIEValue - A debug information entry value. |
| 186 | /// |
Devang Patel | 6f01d9c | 2009-11-21 00:31:03 +0000 | [diff] [blame] | 187 | class DIEValue { |
David Blaikie | 2d24e2a | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 188 | virtual void anchor(); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 189 | public: |
| 190 | enum { |
| 191 | isInteger, |
| 192 | isString, |
| 193 | isLabel, |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 194 | isDelta, |
| 195 | isEntry, |
| 196 | isBlock |
| 197 | }; |
| 198 | protected: |
| 199 | /// Type - Type of data stored in the value. |
| 200 | /// |
| 201 | unsigned Type; |
| 202 | public: |
| 203 | explicit DIEValue(unsigned T) : Type(T) {} |
| 204 | virtual ~DIEValue() {} |
| 205 | |
| 206 | // Accessors |
| 207 | unsigned getType() const { return Type; } |
| 208 | |
| 209 | /// EmitValue - Emit value via the Dwarf writer. |
| 210 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 211 | virtual void EmitValue(AsmPrinter *AP, unsigned Form) const = 0; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 212 | |
| 213 | /// SizeOf - Return the size of a value in bytes. |
| 214 | /// |
Chris Lattner | a37d538 | 2010-04-05 00:18:22 +0000 | [diff] [blame] | 215 | virtual unsigned SizeOf(AsmPrinter *AP, unsigned Form) const = 0; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 216 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 217 | // Implement isa/cast/dyncast. |
| 218 | static bool classof(const DIEValue *) { return true; } |
| 219 | |
| 220 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 221 | virtual void print(raw_ostream &O) = 0; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 222 | void dump(); |
| 223 | #endif |
| 224 | }; |
| 225 | |
| 226 | //===--------------------------------------------------------------------===// |
| 227 | /// DIEInteger - An integer value DIE. |
| 228 | /// |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 229 | class DIEInteger : public DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 230 | uint64_t Integer; |
| 231 | public: |
| 232 | explicit DIEInteger(uint64_t I) : DIEValue(isInteger), Integer(I) {} |
| 233 | |
| 234 | /// BestForm - Choose the best form for integer. |
| 235 | /// |
| 236 | static unsigned BestForm(bool IsSigned, uint64_t Int) { |
| 237 | if (IsSigned) { |
| 238 | if ((char)Int == (signed)Int) return dwarf::DW_FORM_data1; |
| 239 | if ((short)Int == (signed)Int) return dwarf::DW_FORM_data2; |
| 240 | if ((int)Int == (signed)Int) return dwarf::DW_FORM_data4; |
| 241 | } else { |
| 242 | if ((unsigned char)Int == Int) return dwarf::DW_FORM_data1; |
| 243 | if ((unsigned short)Int == Int) return dwarf::DW_FORM_data2; |
| 244 | if ((unsigned int)Int == Int) return dwarf::DW_FORM_data4; |
| 245 | } |
| 246 | return dwarf::DW_FORM_data8; |
| 247 | } |
| 248 | |
| 249 | /// EmitValue - Emit integer of appropriate size. |
| 250 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 251 | virtual void EmitValue(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 252 | |
Devang Patel | f2548ca | 2010-04-16 23:33:45 +0000 | [diff] [blame] | 253 | uint64_t getValue() const { return Integer; } |
| 254 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 255 | /// SizeOf - Determine size of integer value in bytes. |
| 256 | /// |
Chris Lattner | a37d538 | 2010-04-05 00:18:22 +0000 | [diff] [blame] | 257 | virtual unsigned SizeOf(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 258 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 259 | // Implement isa/cast/dyncast. |
| 260 | static bool classof(const DIEInteger *) { return true; } |
| 261 | static bool classof(const DIEValue *I) { return I->getType() == isInteger; } |
| 262 | |
| 263 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 264 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 265 | #endif |
| 266 | }; |
| 267 | |
| 268 | //===--------------------------------------------------------------------===// |
Chris Lattner | 4faf59a | 2010-03-08 22:31:46 +0000 | [diff] [blame] | 269 | /// DIELabel - A label expression DIE. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 270 | // |
Chris Lattner | 4faf59a | 2010-03-08 22:31:46 +0000 | [diff] [blame] | 271 | class DIELabel : public DIEValue { |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 272 | const MCSymbol *Label; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 273 | public: |
Chris Lattner | 4faf59a | 2010-03-08 22:31:46 +0000 | [diff] [blame] | 274 | explicit DIELabel(const MCSymbol *L) : DIEValue(isLabel), Label(L) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 275 | |
| 276 | /// EmitValue - Emit label value. |
| 277 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 278 | virtual void EmitValue(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 279 | |
Devang Patel | c3f5f78 | 2010-05-25 23:40:22 +0000 | [diff] [blame] | 280 | /// getValue - Get MCSymbol. |
| 281 | /// |
| 282 | const MCSymbol *getValue() const { return Label; } |
| 283 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 284 | /// SizeOf - Determine size of label value in bytes. |
| 285 | /// |
Chris Lattner | a37d538 | 2010-04-05 00:18:22 +0000 | [diff] [blame] | 286 | virtual unsigned SizeOf(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 287 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 288 | // Implement isa/cast/dyncast. |
Chris Lattner | 4faf59a | 2010-03-08 22:31:46 +0000 | [diff] [blame] | 289 | static bool classof(const DIELabel *) { return true; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 290 | static bool classof(const DIEValue *L) { return L->getType() == isLabel; } |
| 291 | |
| 292 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 293 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 294 | #endif |
| 295 | }; |
| 296 | |
| 297 | //===--------------------------------------------------------------------===// |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 298 | /// DIEDelta - A simple label difference DIE. |
| 299 | /// |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 300 | class DIEDelta : public DIEValue { |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 301 | const MCSymbol *LabelHi; |
| 302 | const MCSymbol *LabelLo; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 303 | public: |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 304 | DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo) |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 305 | : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {} |
| 306 | |
| 307 | /// EmitValue - Emit delta value. |
| 308 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 309 | virtual void EmitValue(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 310 | |
| 311 | /// SizeOf - Determine size of delta value in bytes. |
| 312 | /// |
Chris Lattner | a37d538 | 2010-04-05 00:18:22 +0000 | [diff] [blame] | 313 | virtual unsigned SizeOf(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 314 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 315 | // Implement isa/cast/dyncast. |
| 316 | static bool classof(const DIEDelta *) { return true; } |
| 317 | static bool classof(const DIEValue *D) { return D->getType() == isDelta; } |
| 318 | |
| 319 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 320 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 321 | #endif |
| 322 | }; |
| 323 | |
| 324 | //===--------------------------------------------------------------------===// |
Nick Lewycky | 024170f | 2011-10-18 22:39:43 +0000 | [diff] [blame] | 325 | /// DIEEntry - A pointer to another debug information entry. An instance of |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 326 | /// this class can also be used as a proxy for a debug information entry not |
| 327 | /// yet defined (ie. types.) |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 328 | class DIEEntry : public DIEValue { |
Jeffrey Yasskin | 5c213dc | 2010-03-12 17:45:06 +0000 | [diff] [blame] | 329 | DIE *const Entry; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 330 | public: |
| 331 | explicit DIEEntry(DIE *E) : DIEValue(isEntry), Entry(E) {} |
| 332 | |
| 333 | DIE *getEntry() const { return Entry; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 334 | |
| 335 | /// EmitValue - Emit debug information entry offset. |
| 336 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 337 | virtual void EmitValue(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 338 | |
| 339 | /// SizeOf - Determine size of debug information entry in bytes. |
| 340 | /// |
Chris Lattner | a37d538 | 2010-04-05 00:18:22 +0000 | [diff] [blame] | 341 | virtual unsigned SizeOf(AsmPrinter *AP, unsigned Form) const { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 342 | return sizeof(int32_t); |
| 343 | } |
| 344 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 345 | // Implement isa/cast/dyncast. |
| 346 | static bool classof(const DIEEntry *) { return true; } |
| 347 | static bool classof(const DIEValue *E) { return E->getType() == isEntry; } |
| 348 | |
| 349 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 350 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 351 | #endif |
| 352 | }; |
| 353 | |
| 354 | //===--------------------------------------------------------------------===// |
| 355 | /// DIEBlock - A block of values. Primarily used for location expressions. |
| 356 | // |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 357 | class DIEBlock : public DIEValue, public DIE { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 358 | unsigned Size; // Size in bytes excluding size header. |
| 359 | public: |
| 360 | DIEBlock() |
| 361 | : DIEValue(isBlock), DIE(0), Size(0) {} |
| 362 | virtual ~DIEBlock() {} |
| 363 | |
| 364 | /// ComputeSize - calculate the size of the block. |
| 365 | /// |
Chris Lattner | a37d538 | 2010-04-05 00:18:22 +0000 | [diff] [blame] | 366 | unsigned ComputeSize(AsmPrinter *AP); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 367 | |
| 368 | /// BestForm - Choose the best form for data. |
| 369 | /// |
| 370 | unsigned BestForm() const { |
| 371 | if ((unsigned char)Size == Size) return dwarf::DW_FORM_block1; |
| 372 | if ((unsigned short)Size == Size) return dwarf::DW_FORM_block2; |
| 373 | if ((unsigned int)Size == Size) return dwarf::DW_FORM_block4; |
| 374 | return dwarf::DW_FORM_block; |
| 375 | } |
| 376 | |
| 377 | /// EmitValue - Emit block data. |
| 378 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 379 | virtual void EmitValue(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 380 | |
| 381 | /// SizeOf - Determine size of block data in bytes. |
| 382 | /// |
Chris Lattner | a37d538 | 2010-04-05 00:18:22 +0000 | [diff] [blame] | 383 | virtual unsigned SizeOf(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 384 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 385 | // Implement isa/cast/dyncast. |
| 386 | static bool classof(const DIEBlock *) { return true; } |
| 387 | static bool classof(const DIEValue *E) { return E->getType() == isBlock; } |
| 388 | |
| 389 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 390 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 391 | #endif |
| 392 | }; |
| 393 | |
| 394 | } // end llvm namespace |
| 395 | |
| 396 | #endif |