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 | |
| 17 | #include "DwarfLabel.h" |
| 18 | #include "llvm/ADT/FoldingSet.h" |
| 19 | #include "llvm/ADT/SmallVector.h" |
| 20 | #include "llvm/Support/Compiler.h" |
| 21 | #include "llvm/Support/Dwarf.h" |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 22 | #include <vector> |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 23 | |
| 24 | namespace llvm { |
| 25 | class AsmPrinter; |
| 26 | class Dwarf; |
| 27 | class TargetData; |
| 28 | |
| 29 | //===--------------------------------------------------------------------===// |
| 30 | /// DIEAbbrevData - Dwarf abbreviation data, describes the one attribute of a |
| 31 | /// Dwarf abbreviation. |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 32 | class DIEAbbrevData { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 33 | /// Attribute - Dwarf attribute code. |
| 34 | /// |
| 35 | unsigned Attribute; |
| 36 | |
| 37 | /// Form - Dwarf form code. |
| 38 | /// |
| 39 | unsigned Form; |
| 40 | public: |
| 41 | DIEAbbrevData(unsigned A, unsigned F) : Attribute(A), Form(F) {} |
| 42 | |
| 43 | // Accessors. |
| 44 | unsigned getAttribute() const { return Attribute; } |
| 45 | unsigned getForm() const { return Form; } |
| 46 | |
| 47 | /// Profile - Used to gather unique data for the abbreviation folding set. |
| 48 | /// |
| 49 | void Profile(FoldingSetNodeID &ID) const; |
| 50 | }; |
| 51 | |
| 52 | //===--------------------------------------------------------------------===// |
| 53 | /// DIEAbbrev - Dwarf abbreviation, describes the organization of a debug |
| 54 | /// information object. |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 55 | class DIEAbbrev : public FoldingSetNode { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 56 | /// Tag - Dwarf tag code. |
| 57 | /// |
| 58 | unsigned Tag; |
| 59 | |
| 60 | /// Unique number for node. |
| 61 | /// |
| 62 | unsigned Number; |
| 63 | |
| 64 | /// ChildrenFlag - Dwarf children flag. |
| 65 | /// |
| 66 | unsigned ChildrenFlag; |
| 67 | |
| 68 | /// Data - Raw data bytes for abbreviation. |
| 69 | /// |
| 70 | SmallVector<DIEAbbrevData, 8> Data; |
| 71 | public: |
| 72 | DIEAbbrev(unsigned T, unsigned C) : Tag(T), ChildrenFlag(C), Data() {} |
| 73 | virtual ~DIEAbbrev() {} |
| 74 | |
| 75 | // Accessors. |
| 76 | unsigned getTag() const { return Tag; } |
| 77 | unsigned getNumber() const { return Number; } |
| 78 | unsigned getChildrenFlag() const { return ChildrenFlag; } |
| 79 | const SmallVector<DIEAbbrevData, 8> &getData() const { return Data; } |
| 80 | void setTag(unsigned T) { Tag = T; } |
| 81 | void setChildrenFlag(unsigned CF) { ChildrenFlag = CF; } |
| 82 | void setNumber(unsigned N) { Number = N; } |
| 83 | |
| 84 | /// AddAttribute - Adds another set of attribute information to the |
| 85 | /// abbreviation. |
| 86 | void AddAttribute(unsigned Attribute, unsigned Form) { |
| 87 | Data.push_back(DIEAbbrevData(Attribute, Form)); |
| 88 | } |
| 89 | |
| 90 | /// AddFirstAttribute - Adds a set of attribute information to the front |
| 91 | /// of the abbreviation. |
| 92 | void AddFirstAttribute(unsigned Attribute, unsigned Form) { |
| 93 | Data.insert(Data.begin(), DIEAbbrevData(Attribute, Form)); |
| 94 | } |
| 95 | |
| 96 | /// Profile - Used to gather unique data for the abbreviation folding set. |
| 97 | /// |
| 98 | void Profile(FoldingSetNodeID &ID) const; |
| 99 | |
| 100 | /// Emit - Print the abbreviation using the specified asm printer. |
| 101 | /// |
| 102 | void Emit(const AsmPrinter *Asm) const; |
| 103 | |
| 104 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 105 | void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 106 | void dump(); |
| 107 | #endif |
| 108 | }; |
| 109 | |
| 110 | //===--------------------------------------------------------------------===// |
| 111 | /// DIE - A structured debug information entry. Has an abbreviation which |
| 112 | /// describes it's organization. |
| 113 | class CompileUnit; |
| 114 | class DIEValue; |
| 115 | |
Devang Patel | 6f01d9c | 2009-11-21 00:31:03 +0000 | [diff] [blame^] | 116 | class DIE { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 117 | protected: |
| 118 | /// Abbrev - Buffer for constructing abbreviation. |
| 119 | /// |
| 120 | DIEAbbrev Abbrev; |
| 121 | |
| 122 | /// Offset - Offset in debug info section. |
| 123 | /// |
| 124 | unsigned Offset; |
| 125 | |
| 126 | /// Size - Size of instance + children. |
| 127 | /// |
| 128 | unsigned Size; |
| 129 | |
| 130 | /// Children DIEs. |
| 131 | /// |
| 132 | std::vector<DIE *> Children; |
| 133 | |
| 134 | /// Attributes values. |
| 135 | /// |
| 136 | SmallVector<DIEValue*, 32> Values; |
| 137 | |
| 138 | /// Abstract compile unit. |
| 139 | CompileUnit *AbstractCU; |
Owen Anderson | d5509f2 | 2009-06-24 23:13:56 +0000 | [diff] [blame] | 140 | |
| 141 | // Private data for print() |
| 142 | mutable unsigned IndentCount; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 143 | public: |
| 144 | explicit DIE(unsigned Tag) |
Owen Anderson | d5509f2 | 2009-06-24 23:13:56 +0000 | [diff] [blame] | 145 | : Abbrev(Tag, dwarf::DW_CHILDREN_no), Offset(0), |
| 146 | Size(0), IndentCount(0) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 147 | virtual ~DIE(); |
| 148 | |
| 149 | // Accessors. |
| 150 | DIEAbbrev &getAbbrev() { return Abbrev; } |
| 151 | unsigned getAbbrevNumber() const { return Abbrev.getNumber(); } |
| 152 | unsigned getTag() const { return Abbrev.getTag(); } |
| 153 | unsigned getOffset() const { return Offset; } |
| 154 | unsigned getSize() const { return Size; } |
| 155 | const std::vector<DIE *> &getChildren() const { return Children; } |
| 156 | SmallVector<DIEValue*, 32> &getValues() { return Values; } |
| 157 | CompileUnit *getAbstractCompileUnit() const { return AbstractCU; } |
| 158 | |
| 159 | void setTag(unsigned Tag) { Abbrev.setTag(Tag); } |
| 160 | void setOffset(unsigned O) { Offset = O; } |
| 161 | void setSize(unsigned S) { Size = S; } |
| 162 | void setAbstractCompileUnit(CompileUnit *CU) { AbstractCU = CU; } |
| 163 | |
| 164 | /// AddValue - Add a value and attributes to a DIE. |
| 165 | /// |
| 166 | void AddValue(unsigned Attribute, unsigned Form, DIEValue *Value) { |
| 167 | Abbrev.AddAttribute(Attribute, Form); |
| 168 | Values.push_back(Value); |
| 169 | } |
| 170 | |
| 171 | /// SiblingOffset - Return the offset of the debug information entry's |
| 172 | /// sibling. |
| 173 | unsigned SiblingOffset() const { return Offset + Size; } |
| 174 | |
| 175 | /// AddSiblingOffset - Add a sibling offset field to the front of the DIE. |
| 176 | /// |
| 177 | void AddSiblingOffset(); |
| 178 | |
| 179 | /// AddChild - Add a child to the DIE. |
| 180 | /// |
| 181 | void AddChild(DIE *Child) { |
| 182 | Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes); |
| 183 | Children.push_back(Child); |
| 184 | } |
| 185 | |
| 186 | /// Detach - Detaches objects connected to it after copying. |
| 187 | /// |
| 188 | void Detach() { |
| 189 | Children.clear(); |
| 190 | } |
| 191 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 192 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 193 | void print(raw_ostream &O, unsigned IncIndent = 0); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 194 | void dump(); |
| 195 | #endif |
| 196 | }; |
| 197 | |
| 198 | //===--------------------------------------------------------------------===// |
| 199 | /// DIEValue - A debug information entry value. |
| 200 | /// |
Devang Patel | 6f01d9c | 2009-11-21 00:31:03 +0000 | [diff] [blame^] | 201 | class DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 202 | public: |
| 203 | enum { |
| 204 | isInteger, |
| 205 | isString, |
| 206 | isLabel, |
| 207 | isAsIsLabel, |
| 208 | isSectionOffset, |
| 209 | isDelta, |
| 210 | isEntry, |
| 211 | isBlock |
| 212 | }; |
| 213 | protected: |
| 214 | /// Type - Type of data stored in the value. |
| 215 | /// |
| 216 | unsigned Type; |
| 217 | public: |
| 218 | explicit DIEValue(unsigned T) : Type(T) {} |
| 219 | virtual ~DIEValue() {} |
| 220 | |
| 221 | // Accessors |
| 222 | unsigned getType() const { return Type; } |
| 223 | |
| 224 | /// EmitValue - Emit value via the Dwarf writer. |
| 225 | /// |
| 226 | virtual void EmitValue(Dwarf *D, unsigned Form) const = 0; |
| 227 | |
| 228 | /// SizeOf - Return the size of a value in bytes. |
| 229 | /// |
| 230 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const = 0; |
| 231 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 232 | // Implement isa/cast/dyncast. |
| 233 | static bool classof(const DIEValue *) { return true; } |
| 234 | |
| 235 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 236 | virtual void print(raw_ostream &O) = 0; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 237 | void dump(); |
| 238 | #endif |
| 239 | }; |
| 240 | |
| 241 | //===--------------------------------------------------------------------===// |
| 242 | /// DIEInteger - An integer value DIE. |
| 243 | /// |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 244 | class DIEInteger : public DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 245 | uint64_t Integer; |
| 246 | public: |
| 247 | explicit DIEInteger(uint64_t I) : DIEValue(isInteger), Integer(I) {} |
| 248 | |
| 249 | /// BestForm - Choose the best form for integer. |
| 250 | /// |
| 251 | static unsigned BestForm(bool IsSigned, uint64_t Int) { |
| 252 | if (IsSigned) { |
| 253 | if ((char)Int == (signed)Int) return dwarf::DW_FORM_data1; |
| 254 | if ((short)Int == (signed)Int) return dwarf::DW_FORM_data2; |
| 255 | if ((int)Int == (signed)Int) return dwarf::DW_FORM_data4; |
| 256 | } else { |
| 257 | if ((unsigned char)Int == Int) return dwarf::DW_FORM_data1; |
| 258 | if ((unsigned short)Int == Int) return dwarf::DW_FORM_data2; |
| 259 | if ((unsigned int)Int == Int) return dwarf::DW_FORM_data4; |
| 260 | } |
| 261 | return dwarf::DW_FORM_data8; |
| 262 | } |
| 263 | |
| 264 | /// EmitValue - Emit integer of appropriate size. |
| 265 | /// |
| 266 | virtual void EmitValue(Dwarf *D, unsigned Form) const; |
| 267 | |
| 268 | /// SizeOf - Determine size of integer value in bytes. |
| 269 | /// |
| 270 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const; |
| 271 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 272 | |
| 273 | // Implement isa/cast/dyncast. |
| 274 | static bool classof(const DIEInteger *) { return true; } |
| 275 | static bool classof(const DIEValue *I) { return I->getType() == isInteger; } |
| 276 | |
| 277 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 278 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 279 | #endif |
| 280 | }; |
| 281 | |
| 282 | //===--------------------------------------------------------------------===// |
| 283 | /// DIEString - A string value DIE. |
| 284 | /// |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 285 | class DIEString : public DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 286 | const std::string Str; |
| 287 | public: |
| 288 | explicit DIEString(const std::string &S) : DIEValue(isString), Str(S) {} |
| 289 | |
| 290 | /// EmitValue - Emit string value. |
| 291 | /// |
| 292 | virtual void EmitValue(Dwarf *D, unsigned Form) const; |
| 293 | |
| 294 | /// SizeOf - Determine size of string value in bytes. |
| 295 | /// |
| 296 | virtual unsigned SizeOf(const TargetData *, unsigned /*Form*/) const { |
| 297 | return Str.size() + sizeof(char); // sizeof('\0'); |
| 298 | } |
| 299 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 300 | // Implement isa/cast/dyncast. |
| 301 | static bool classof(const DIEString *) { return true; } |
| 302 | static bool classof(const DIEValue *S) { return S->getType() == isString; } |
| 303 | |
| 304 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 305 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 306 | #endif |
| 307 | }; |
| 308 | |
| 309 | //===--------------------------------------------------------------------===// |
| 310 | /// DIEDwarfLabel - A Dwarf internal label expression DIE. |
| 311 | // |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 312 | class DIEDwarfLabel : public DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 313 | const DWLabel Label; |
| 314 | public: |
| 315 | explicit DIEDwarfLabel(const DWLabel &L) : DIEValue(isLabel), Label(L) {} |
| 316 | |
| 317 | /// EmitValue - Emit label value. |
| 318 | /// |
| 319 | virtual void EmitValue(Dwarf *D, unsigned Form) const; |
| 320 | |
| 321 | /// SizeOf - Determine size of label value in bytes. |
| 322 | /// |
| 323 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const; |
| 324 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 325 | // Implement isa/cast/dyncast. |
| 326 | static bool classof(const DIEDwarfLabel *) { return true; } |
| 327 | static bool classof(const DIEValue *L) { return L->getType() == isLabel; } |
| 328 | |
| 329 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 330 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 331 | #endif |
| 332 | }; |
| 333 | |
| 334 | //===--------------------------------------------------------------------===// |
| 335 | /// DIEObjectLabel - A label to an object in code or data. |
| 336 | // |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 337 | class DIEObjectLabel : public DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 338 | const std::string Label; |
| 339 | public: |
| 340 | explicit DIEObjectLabel(const std::string &L) |
| 341 | : DIEValue(isAsIsLabel), Label(L) {} |
| 342 | |
| 343 | /// EmitValue - Emit label value. |
| 344 | /// |
| 345 | virtual void EmitValue(Dwarf *D, unsigned Form) const; |
| 346 | |
| 347 | /// SizeOf - Determine size of label value in bytes. |
| 348 | /// |
| 349 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const; |
| 350 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 351 | // Implement isa/cast/dyncast. |
| 352 | static bool classof(const DIEObjectLabel *) { return true; } |
| 353 | static bool classof(const DIEValue *L) { |
| 354 | return L->getType() == isAsIsLabel; |
| 355 | } |
| 356 | |
| 357 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 358 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 359 | #endif |
| 360 | }; |
| 361 | |
| 362 | //===--------------------------------------------------------------------===// |
| 363 | /// DIESectionOffset - A section offset DIE. |
| 364 | /// |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 365 | class DIESectionOffset : public DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 366 | const DWLabel Label; |
| 367 | const DWLabel Section; |
| 368 | bool IsEH : 1; |
| 369 | bool UseSet : 1; |
| 370 | public: |
| 371 | DIESectionOffset(const DWLabel &Lab, const DWLabel &Sec, |
| 372 | bool isEH = false, bool useSet = true) |
| 373 | : DIEValue(isSectionOffset), Label(Lab), Section(Sec), |
| 374 | IsEH(isEH), UseSet(useSet) {} |
| 375 | |
| 376 | /// EmitValue - Emit section offset. |
| 377 | /// |
| 378 | virtual void EmitValue(Dwarf *D, unsigned Form) const; |
| 379 | |
| 380 | /// SizeOf - Determine size of section offset value in bytes. |
| 381 | /// |
| 382 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const; |
| 383 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 384 | // Implement isa/cast/dyncast. |
| 385 | static bool classof(const DIESectionOffset *) { return true; } |
| 386 | static bool classof(const DIEValue *D) { |
| 387 | return D->getType() == isSectionOffset; |
| 388 | } |
| 389 | |
| 390 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 391 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 392 | #endif |
| 393 | }; |
| 394 | |
| 395 | //===--------------------------------------------------------------------===// |
| 396 | /// DIEDelta - A simple label difference DIE. |
| 397 | /// |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 398 | class DIEDelta : public DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 399 | const DWLabel LabelHi; |
| 400 | const DWLabel LabelLo; |
| 401 | public: |
| 402 | DIEDelta(const DWLabel &Hi, const DWLabel &Lo) |
| 403 | : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {} |
| 404 | |
| 405 | /// EmitValue - Emit delta value. |
| 406 | /// |
| 407 | virtual void EmitValue(Dwarf *D, unsigned Form) const; |
| 408 | |
| 409 | /// SizeOf - Determine size of delta value in bytes. |
| 410 | /// |
| 411 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const; |
| 412 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 413 | // Implement isa/cast/dyncast. |
| 414 | static bool classof(const DIEDelta *) { return true; } |
| 415 | static bool classof(const DIEValue *D) { return D->getType() == isDelta; } |
| 416 | |
| 417 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 418 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 419 | #endif |
| 420 | }; |
| 421 | |
| 422 | //===--------------------------------------------------------------------===// |
| 423 | /// DIEntry - A pointer to another debug information entry. An instance of |
| 424 | /// this class can also be used as a proxy for a debug information entry not |
| 425 | /// yet defined (ie. types.) |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 426 | class DIEEntry : public DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 427 | DIE *Entry; |
| 428 | public: |
| 429 | explicit DIEEntry(DIE *E) : DIEValue(isEntry), Entry(E) {} |
| 430 | |
| 431 | DIE *getEntry() const { return Entry; } |
| 432 | void setEntry(DIE *E) { Entry = E; } |
| 433 | |
| 434 | /// EmitValue - Emit debug information entry offset. |
| 435 | /// |
| 436 | virtual void EmitValue(Dwarf *D, unsigned Form) const; |
| 437 | |
| 438 | /// SizeOf - Determine size of debug information entry in bytes. |
| 439 | /// |
| 440 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const { |
| 441 | return sizeof(int32_t); |
| 442 | } |
| 443 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 444 | // Implement isa/cast/dyncast. |
| 445 | static bool classof(const DIEEntry *) { return true; } |
| 446 | static bool classof(const DIEValue *E) { return E->getType() == isEntry; } |
| 447 | |
| 448 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 449 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 450 | #endif |
| 451 | }; |
| 452 | |
| 453 | //===--------------------------------------------------------------------===// |
| 454 | /// DIEBlock - A block of values. Primarily used for location expressions. |
| 455 | // |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 456 | class DIEBlock : public DIEValue, public DIE { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 457 | unsigned Size; // Size in bytes excluding size header. |
| 458 | public: |
| 459 | DIEBlock() |
| 460 | : DIEValue(isBlock), DIE(0), Size(0) {} |
| 461 | virtual ~DIEBlock() {} |
| 462 | |
| 463 | /// ComputeSize - calculate the size of the block. |
| 464 | /// |
| 465 | unsigned ComputeSize(const TargetData *TD); |
| 466 | |
| 467 | /// BestForm - Choose the best form for data. |
| 468 | /// |
| 469 | unsigned BestForm() const { |
| 470 | if ((unsigned char)Size == Size) return dwarf::DW_FORM_block1; |
| 471 | if ((unsigned short)Size == Size) return dwarf::DW_FORM_block2; |
| 472 | if ((unsigned int)Size == Size) return dwarf::DW_FORM_block4; |
| 473 | return dwarf::DW_FORM_block; |
| 474 | } |
| 475 | |
| 476 | /// EmitValue - Emit block data. |
| 477 | /// |
| 478 | virtual void EmitValue(Dwarf *D, unsigned Form) const; |
| 479 | |
| 480 | /// SizeOf - Determine size of block data in bytes. |
| 481 | /// |
| 482 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const; |
| 483 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 484 | // Implement isa/cast/dyncast. |
| 485 | static bool classof(const DIEBlock *) { return true; } |
| 486 | static bool classof(const DIEValue *E) { return E->getType() == isBlock; } |
| 487 | |
| 488 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 489 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 490 | #endif |
| 491 | }; |
| 492 | |
| 493 | } // end llvm namespace |
| 494 | |
| 495 | #endif |