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; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 25 | class TargetData; |
Chris Lattner | 858431d | 2010-01-16 18:50:28 +0000 | [diff] [blame] | 26 | class MCSymbol; |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 27 | class raw_ostream; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 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; |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 71 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 72 | public: |
| 73 | DIEAbbrev(unsigned T, unsigned C) : Tag(T), ChildrenFlag(C), Data() {} |
| 74 | virtual ~DIEAbbrev() {} |
| 75 | |
| 76 | // Accessors. |
| 77 | unsigned getTag() const { return Tag; } |
| 78 | unsigned getNumber() const { return Number; } |
| 79 | unsigned getChildrenFlag() const { return ChildrenFlag; } |
| 80 | const SmallVector<DIEAbbrevData, 8> &getData() const { return Data; } |
| 81 | void setTag(unsigned T) { Tag = T; } |
| 82 | void setChildrenFlag(unsigned CF) { ChildrenFlag = CF; } |
| 83 | void setNumber(unsigned N) { Number = N; } |
| 84 | |
| 85 | /// AddAttribute - Adds another set of attribute information to the |
| 86 | /// abbreviation. |
| 87 | void AddAttribute(unsigned Attribute, unsigned Form) { |
| 88 | Data.push_back(DIEAbbrevData(Attribute, Form)); |
| 89 | } |
| 90 | |
| 91 | /// AddFirstAttribute - Adds a set of attribute information to the front |
| 92 | /// of the abbreviation. |
| 93 | void AddFirstAttribute(unsigned Attribute, unsigned Form) { |
| 94 | Data.insert(Data.begin(), DIEAbbrevData(Attribute, Form)); |
| 95 | } |
| 96 | |
| 97 | /// Profile - Used to gather unique data for the abbreviation folding set. |
| 98 | /// |
| 99 | void Profile(FoldingSetNodeID &ID) const; |
| 100 | |
| 101 | /// Emit - Print the abbreviation using the specified asm printer. |
| 102 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame^] | 103 | void Emit(AsmPrinter *AP) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 104 | |
| 105 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 106 | void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 107 | void dump(); |
| 108 | #endif |
| 109 | }; |
| 110 | |
| 111 | //===--------------------------------------------------------------------===// |
| 112 | /// DIE - A structured debug information entry. Has an abbreviation which |
| 113 | /// describes it's organization. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 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 | |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 134 | DIE *Parent; |
| 135 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 136 | /// Attributes values. |
| 137 | /// |
| 138 | SmallVector<DIEValue*, 32> Values; |
| 139 | |
Owen Anderson | d5509f2 | 2009-06-24 23:13:56 +0000 | [diff] [blame] | 140 | // Private data for print() |
| 141 | mutable unsigned IndentCount; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 142 | public: |
| 143 | explicit DIE(unsigned Tag) |
Owen Anderson | d5509f2 | 2009-06-24 23:13:56 +0000 | [diff] [blame] | 144 | : Abbrev(Tag, dwarf::DW_CHILDREN_no), Offset(0), |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 145 | Size(0), Parent (0), IndentCount(0) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 146 | virtual ~DIE(); |
| 147 | |
| 148 | // Accessors. |
| 149 | DIEAbbrev &getAbbrev() { return Abbrev; } |
| 150 | unsigned getAbbrevNumber() const { return Abbrev.getNumber(); } |
| 151 | unsigned getTag() const { return Abbrev.getTag(); } |
| 152 | unsigned getOffset() const { return Offset; } |
| 153 | unsigned getSize() const { return Size; } |
| 154 | const std::vector<DIE *> &getChildren() const { return Children; } |
Jeffrey Yasskin | 638fe8d | 2010-03-22 18:47:14 +0000 | [diff] [blame] | 155 | const SmallVector<DIEValue*, 32> &getValues() const { return Values; } |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 156 | DIE *getParent() const { return Parent; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 157 | void setTag(unsigned Tag) { Abbrev.setTag(Tag); } |
| 158 | void setOffset(unsigned O) { Offset = O; } |
| 159 | void setSize(unsigned S) { Size = S; } |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 160 | |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 161 | /// addValue - Add a value and attributes to a DIE. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 162 | /// |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 163 | void addValue(unsigned Attribute, unsigned Form, DIEValue *Value) { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 164 | Abbrev.AddAttribute(Attribute, Form); |
| 165 | Values.push_back(Value); |
| 166 | } |
| 167 | |
| 168 | /// SiblingOffset - Return the offset of the debug information entry's |
| 169 | /// sibling. |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 170 | unsigned getSiblingOffset() const { return Offset + Size; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 171 | |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 172 | /// addSiblingOffset - Add a sibling offset field to the front of the DIE. |
Jeffrey Yasskin | 638fe8d | 2010-03-22 18:47:14 +0000 | [diff] [blame] | 173 | /// The caller is responsible for deleting the return value at or after the |
| 174 | /// same time it destroys this DIE. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 175 | /// |
Benjamin Kramer | 345ef34 | 2010-03-31 19:34:01 +0000 | [diff] [blame] | 176 | DIEValue *addSiblingOffset(BumpPtrAllocator &A); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 177 | |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 178 | /// addChild - Add a child to the DIE. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 179 | /// |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 180 | void addChild(DIE *Child) { |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 181 | if (Child->getParent()) { |
| 182 | assert (Child->getParent() == this && "Unexpected DIE Parent!"); |
| 183 | return; |
| 184 | } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 185 | Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes); |
| 186 | Children.push_back(Child); |
Jeffrey Yasskin | 5c213dc | 2010-03-12 17:45:06 +0000 | [diff] [blame] | 187 | Child->Parent = this; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 188 | } |
| 189 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 190 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 191 | void print(raw_ostream &O, unsigned IncIndent = 0); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 192 | void dump(); |
| 193 | #endif |
| 194 | }; |
| 195 | |
| 196 | //===--------------------------------------------------------------------===// |
| 197 | /// DIEValue - A debug information entry value. |
| 198 | /// |
Devang Patel | 6f01d9c | 2009-11-21 00:31:03 +0000 | [diff] [blame] | 199 | class DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 200 | public: |
| 201 | enum { |
| 202 | isInteger, |
| 203 | isString, |
| 204 | isLabel, |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 205 | isSectionOffset, |
| 206 | isDelta, |
| 207 | isEntry, |
| 208 | isBlock |
| 209 | }; |
| 210 | protected: |
| 211 | /// Type - Type of data stored in the value. |
| 212 | /// |
| 213 | unsigned Type; |
| 214 | public: |
| 215 | explicit DIEValue(unsigned T) : Type(T) {} |
| 216 | virtual ~DIEValue() {} |
| 217 | |
| 218 | // Accessors |
| 219 | unsigned getType() const { return Type; } |
| 220 | |
| 221 | /// EmitValue - Emit value via the Dwarf writer. |
| 222 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame^] | 223 | virtual void EmitValue(AsmPrinter *AP, unsigned Form) const = 0; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 224 | |
| 225 | /// SizeOf - Return the size of a value in bytes. |
| 226 | /// |
| 227 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const = 0; |
| 228 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 229 | // Implement isa/cast/dyncast. |
| 230 | static bool classof(const DIEValue *) { return true; } |
| 231 | |
| 232 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 233 | virtual void print(raw_ostream &O) = 0; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 234 | void dump(); |
| 235 | #endif |
| 236 | }; |
| 237 | |
| 238 | //===--------------------------------------------------------------------===// |
| 239 | /// DIEInteger - An integer value DIE. |
| 240 | /// |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 241 | class DIEInteger : public DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 242 | uint64_t Integer; |
| 243 | public: |
| 244 | explicit DIEInteger(uint64_t I) : DIEValue(isInteger), Integer(I) {} |
| 245 | |
| 246 | /// BestForm - Choose the best form for integer. |
| 247 | /// |
| 248 | static unsigned BestForm(bool IsSigned, uint64_t Int) { |
| 249 | if (IsSigned) { |
| 250 | if ((char)Int == (signed)Int) return dwarf::DW_FORM_data1; |
| 251 | if ((short)Int == (signed)Int) return dwarf::DW_FORM_data2; |
| 252 | if ((int)Int == (signed)Int) return dwarf::DW_FORM_data4; |
| 253 | } else { |
| 254 | if ((unsigned char)Int == Int) return dwarf::DW_FORM_data1; |
| 255 | if ((unsigned short)Int == Int) return dwarf::DW_FORM_data2; |
| 256 | if ((unsigned int)Int == Int) return dwarf::DW_FORM_data4; |
| 257 | } |
| 258 | return dwarf::DW_FORM_data8; |
| 259 | } |
| 260 | |
| 261 | /// EmitValue - Emit integer of appropriate size. |
| 262 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame^] | 263 | virtual void EmitValue(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 264 | |
| 265 | /// SizeOf - Determine size of integer value in bytes. |
| 266 | /// |
| 267 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const; |
| 268 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 269 | |
| 270 | // Implement isa/cast/dyncast. |
| 271 | static bool classof(const DIEInteger *) { return true; } |
| 272 | static bool classof(const DIEValue *I) { return I->getType() == isInteger; } |
| 273 | |
| 274 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 275 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 276 | #endif |
| 277 | }; |
| 278 | |
| 279 | //===--------------------------------------------------------------------===// |
Devang Patel | 69f57b1 | 2009-12-02 15:25:16 +0000 | [diff] [blame] | 280 | /// DIEString - A string value DIE. This DIE keeps string reference only. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 281 | /// |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 282 | class DIEString : public DIEValue { |
Devang Patel | e9a0597 | 2009-11-24 19:42:17 +0000 | [diff] [blame] | 283 | const StringRef Str; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 284 | public: |
Devang Patel | e9a0597 | 2009-11-24 19:42:17 +0000 | [diff] [blame] | 285 | explicit DIEString(const StringRef S) : DIEValue(isString), Str(S) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 286 | |
| 287 | /// EmitValue - Emit string value. |
| 288 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame^] | 289 | virtual void EmitValue(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 290 | |
| 291 | /// SizeOf - Determine size of string value in bytes. |
| 292 | /// |
| 293 | virtual unsigned SizeOf(const TargetData *, unsigned /*Form*/) const { |
| 294 | return Str.size() + sizeof(char); // sizeof('\0'); |
| 295 | } |
| 296 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 297 | // Implement isa/cast/dyncast. |
| 298 | static bool classof(const DIEString *) { return true; } |
| 299 | static bool classof(const DIEValue *S) { return S->getType() == isString; } |
| 300 | |
| 301 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 302 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 303 | #endif |
| 304 | }; |
| 305 | |
| 306 | //===--------------------------------------------------------------------===// |
Chris Lattner | 4faf59a | 2010-03-08 22:31:46 +0000 | [diff] [blame] | 307 | /// DIELabel - A label expression DIE. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 308 | // |
Chris Lattner | 4faf59a | 2010-03-08 22:31:46 +0000 | [diff] [blame] | 309 | class DIELabel : public DIEValue { |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 310 | const MCSymbol *Label; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 311 | public: |
Chris Lattner | 4faf59a | 2010-03-08 22:31:46 +0000 | [diff] [blame] | 312 | explicit DIELabel(const MCSymbol *L) : DIEValue(isLabel), Label(L) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 313 | |
| 314 | /// EmitValue - Emit label value. |
| 315 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame^] | 316 | virtual void EmitValue(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 317 | |
| 318 | /// SizeOf - Determine size of label value in bytes. |
| 319 | /// |
| 320 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const; |
| 321 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 322 | // Implement isa/cast/dyncast. |
Chris Lattner | 4faf59a | 2010-03-08 22:31:46 +0000 | [diff] [blame] | 323 | static bool classof(const DIELabel *) { return true; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 324 | static bool classof(const DIEValue *L) { return L->getType() == isLabel; } |
| 325 | |
| 326 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 327 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 328 | #endif |
| 329 | }; |
| 330 | |
| 331 | //===--------------------------------------------------------------------===// |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 332 | /// DIEDelta - A simple label difference DIE. |
| 333 | /// |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 334 | class DIEDelta : public DIEValue { |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 335 | const MCSymbol *LabelHi; |
| 336 | const MCSymbol *LabelLo; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 337 | public: |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 338 | DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo) |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 339 | : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {} |
| 340 | |
| 341 | /// EmitValue - Emit delta value. |
| 342 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame^] | 343 | virtual void EmitValue(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 344 | |
| 345 | /// SizeOf - Determine size of delta value in bytes. |
| 346 | /// |
| 347 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const; |
| 348 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 349 | // Implement isa/cast/dyncast. |
| 350 | static bool classof(const DIEDelta *) { return true; } |
| 351 | static bool classof(const DIEValue *D) { return D->getType() == isDelta; } |
| 352 | |
| 353 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 354 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 355 | #endif |
| 356 | }; |
| 357 | |
| 358 | //===--------------------------------------------------------------------===// |
| 359 | /// DIEntry - A pointer to another debug information entry. An instance of |
| 360 | /// this class can also be used as a proxy for a debug information entry not |
| 361 | /// yet defined (ie. types.) |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 362 | class DIEEntry : public DIEValue { |
Jeffrey Yasskin | 5c213dc | 2010-03-12 17:45:06 +0000 | [diff] [blame] | 363 | DIE *const Entry; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 364 | public: |
| 365 | explicit DIEEntry(DIE *E) : DIEValue(isEntry), Entry(E) {} |
| 366 | |
| 367 | DIE *getEntry() const { return Entry; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 368 | |
| 369 | /// EmitValue - Emit debug information entry offset. |
| 370 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame^] | 371 | virtual void EmitValue(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 372 | |
| 373 | /// SizeOf - Determine size of debug information entry in bytes. |
| 374 | /// |
| 375 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const { |
| 376 | return sizeof(int32_t); |
| 377 | } |
| 378 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 379 | // Implement isa/cast/dyncast. |
| 380 | static bool classof(const DIEEntry *) { return true; } |
| 381 | static bool classof(const DIEValue *E) { return E->getType() == isEntry; } |
| 382 | |
| 383 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 384 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 385 | #endif |
| 386 | }; |
| 387 | |
| 388 | //===--------------------------------------------------------------------===// |
| 389 | /// DIEBlock - A block of values. Primarily used for location expressions. |
| 390 | // |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 391 | class DIEBlock : public DIEValue, public DIE { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 392 | unsigned Size; // Size in bytes excluding size header. |
| 393 | public: |
| 394 | DIEBlock() |
| 395 | : DIEValue(isBlock), DIE(0), Size(0) {} |
| 396 | virtual ~DIEBlock() {} |
| 397 | |
| 398 | /// ComputeSize - calculate the size of the block. |
| 399 | /// |
| 400 | unsigned ComputeSize(const TargetData *TD); |
| 401 | |
| 402 | /// BestForm - Choose the best form for data. |
| 403 | /// |
| 404 | unsigned BestForm() const { |
| 405 | if ((unsigned char)Size == Size) return dwarf::DW_FORM_block1; |
| 406 | if ((unsigned short)Size == Size) return dwarf::DW_FORM_block2; |
| 407 | if ((unsigned int)Size == Size) return dwarf::DW_FORM_block4; |
| 408 | return dwarf::DW_FORM_block; |
| 409 | } |
| 410 | |
| 411 | /// EmitValue - Emit block data. |
| 412 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame^] | 413 | virtual void EmitValue(AsmPrinter *AP, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 414 | |
| 415 | /// SizeOf - Determine size of block data in bytes. |
| 416 | /// |
| 417 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const; |
| 418 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 419 | // Implement isa/cast/dyncast. |
| 420 | static bool classof(const DIEBlock *) { return true; } |
| 421 | static bool classof(const DIEValue *E) { return E->getType() == isBlock; } |
| 422 | |
| 423 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 424 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 425 | #endif |
| 426 | }; |
| 427 | |
| 428 | } // end llvm namespace |
| 429 | |
| 430 | #endif |