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 | 066c9ac | 2010-01-22 22:23:57 +0000 | [diff] [blame] | 25 | class DwarfPrinter; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 26 | class TargetData; |
Chris Lattner | 858431d | 2010-01-16 18:50:28 +0000 | [diff] [blame] | 27 | class MCSymbol; |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 28 | class raw_ostream; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 29 | |
| 30 | //===--------------------------------------------------------------------===// |
| 31 | /// DIEAbbrevData - Dwarf abbreviation data, describes the one attribute of a |
| 32 | /// Dwarf abbreviation. |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 33 | class DIEAbbrevData { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 34 | /// Attribute - Dwarf attribute code. |
| 35 | /// |
| 36 | unsigned Attribute; |
| 37 | |
| 38 | /// Form - Dwarf form code. |
| 39 | /// |
| 40 | unsigned Form; |
| 41 | public: |
| 42 | DIEAbbrevData(unsigned A, unsigned F) : Attribute(A), Form(F) {} |
| 43 | |
| 44 | // Accessors. |
| 45 | unsigned getAttribute() const { return Attribute; } |
| 46 | unsigned getForm() const { return Form; } |
| 47 | |
| 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. |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 56 | class DIEAbbrev : public FoldingSetNode { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 57 | /// Tag - Dwarf tag code. |
| 58 | /// |
| 59 | unsigned Tag; |
| 60 | |
| 61 | /// Unique number for node. |
| 62 | /// |
| 63 | unsigned Number; |
| 64 | |
| 65 | /// ChildrenFlag - Dwarf children flag. |
| 66 | /// |
| 67 | unsigned ChildrenFlag; |
| 68 | |
| 69 | /// Data - Raw data bytes for abbreviation. |
| 70 | /// |
| 71 | SmallVector<DIEAbbrevData, 8> Data; |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 72 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 73 | public: |
| 74 | DIEAbbrev(unsigned T, unsigned C) : Tag(T), ChildrenFlag(C), Data() {} |
| 75 | virtual ~DIEAbbrev() {} |
| 76 | |
| 77 | // Accessors. |
| 78 | unsigned getTag() const { return Tag; } |
| 79 | unsigned getNumber() const { return Number; } |
| 80 | unsigned getChildrenFlag() const { return ChildrenFlag; } |
| 81 | const SmallVector<DIEAbbrevData, 8> &getData() const { return Data; } |
| 82 | void setTag(unsigned T) { Tag = T; } |
| 83 | void setChildrenFlag(unsigned CF) { ChildrenFlag = CF; } |
| 84 | void setNumber(unsigned N) { Number = N; } |
| 85 | |
| 86 | /// AddAttribute - Adds another set of attribute information to the |
| 87 | /// abbreviation. |
| 88 | void AddAttribute(unsigned Attribute, unsigned Form) { |
| 89 | Data.push_back(DIEAbbrevData(Attribute, Form)); |
| 90 | } |
| 91 | |
| 92 | /// AddFirstAttribute - Adds a set of attribute information to the front |
| 93 | /// of the abbreviation. |
| 94 | void AddFirstAttribute(unsigned Attribute, unsigned Form) { |
| 95 | Data.insert(Data.begin(), DIEAbbrevData(Attribute, Form)); |
| 96 | } |
| 97 | |
| 98 | /// Profile - Used to gather unique data for the abbreviation folding set. |
| 99 | /// |
| 100 | void Profile(FoldingSetNodeID &ID) const; |
| 101 | |
| 102 | /// Emit - Print the abbreviation using the specified asm printer. |
| 103 | /// |
Chris Lattner | 12e555c | 2010-01-23 00:15:00 +0000 | [diff] [blame] | 104 | void Emit(const DwarfPrinter *DP) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 105 | |
| 106 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 107 | void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 108 | void dump(); |
| 109 | #endif |
| 110 | }; |
| 111 | |
| 112 | //===--------------------------------------------------------------------===// |
| 113 | /// DIE - A structured debug information entry. Has an abbreviation which |
| 114 | /// describes it's organization. |
Douglas Gregor | 1ddcf35 | 2010-03-08 02:58:37 +0000 | [diff] [blame] | 115 | class CompileUnit; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 116 | class DIEValue; |
| 117 | |
Devang Patel | 6f01d9c | 2009-11-21 00:31:03 +0000 | [diff] [blame] | 118 | class DIE { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 119 | protected: |
| 120 | /// Abbrev - Buffer for constructing abbreviation. |
| 121 | /// |
| 122 | DIEAbbrev Abbrev; |
| 123 | |
| 124 | /// Offset - Offset in debug info section. |
| 125 | /// |
| 126 | unsigned Offset; |
| 127 | |
| 128 | /// Size - Size of instance + children. |
| 129 | /// |
| 130 | unsigned Size; |
| 131 | |
| 132 | /// Children DIEs. |
| 133 | /// |
| 134 | std::vector<DIE *> Children; |
| 135 | |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 136 | DIE *Parent; |
| 137 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 138 | /// Attributes values. |
| 139 | /// |
| 140 | SmallVector<DIEValue*, 32> Values; |
| 141 | |
Owen Anderson | d5509f2 | 2009-06-24 23:13:56 +0000 | [diff] [blame] | 142 | // Private data for print() |
| 143 | mutable unsigned IndentCount; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 144 | public: |
| 145 | explicit DIE(unsigned Tag) |
Owen Anderson | d5509f2 | 2009-06-24 23:13:56 +0000 | [diff] [blame] | 146 | : Abbrev(Tag, dwarf::DW_CHILDREN_no), Offset(0), |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 147 | Size(0), Parent (0), IndentCount(0) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 148 | virtual ~DIE(); |
| 149 | |
| 150 | // Accessors. |
| 151 | DIEAbbrev &getAbbrev() { return Abbrev; } |
| 152 | unsigned getAbbrevNumber() const { return Abbrev.getNumber(); } |
| 153 | unsigned getTag() const { return Abbrev.getTag(); } |
| 154 | unsigned getOffset() const { return Offset; } |
| 155 | unsigned getSize() const { return Size; } |
| 156 | const std::vector<DIE *> &getChildren() const { return Children; } |
| 157 | SmallVector<DIEValue*, 32> &getValues() { return Values; } |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 158 | DIE *getParent() const { return Parent; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 159 | void setTag(unsigned Tag) { Abbrev.setTag(Tag); } |
| 160 | void setOffset(unsigned O) { Offset = O; } |
| 161 | void setSize(unsigned S) { Size = S; } |
Douglas Gregor | 1ddcf35 | 2010-03-08 02:58:37 +0000 | [diff] [blame] | 162 | void setParent(DIE *P) { Parent = P; } |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 163 | |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 164 | /// addValue - Add a value and attributes to a DIE. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 165 | /// |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 166 | void addValue(unsigned Attribute, unsigned Form, DIEValue *Value) { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 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. |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 173 | unsigned getSiblingOffset() const { return Offset + Size; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 174 | |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 175 | /// addSiblingOffset - Add a sibling offset field to the front of the DIE. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 176 | /// |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 177 | void addSiblingOffset(); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 178 | |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 179 | /// addChild - Add a child to the DIE. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 180 | /// |
Devang Patel | 2c4ceb1 | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 181 | void addChild(DIE *Child) { |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 182 | if (Child->getParent()) { |
| 183 | assert (Child->getParent() == this && "Unexpected DIE Parent!"); |
| 184 | return; |
| 185 | } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 186 | Abbrev.setChildrenFlag(dwarf::DW_CHILDREN_yes); |
| 187 | Children.push_back(Child); |
Douglas Gregor | 1ddcf35 | 2010-03-08 02:58:37 +0000 | [diff] [blame] | 188 | Child->setParent(this); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 189 | } |
| 190 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 191 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 192 | void print(raw_ostream &O, unsigned IncIndent = 0); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 193 | void dump(); |
| 194 | #endif |
| 195 | }; |
| 196 | |
| 197 | //===--------------------------------------------------------------------===// |
| 198 | /// DIEValue - A debug information entry value. |
| 199 | /// |
Devang Patel | 6f01d9c | 2009-11-21 00:31:03 +0000 | [diff] [blame] | 200 | class DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 201 | public: |
| 202 | enum { |
| 203 | isInteger, |
| 204 | isString, |
| 205 | isLabel, |
| 206 | isAsIsLabel, |
| 207 | isSectionOffset, |
| 208 | isDelta, |
| 209 | isEntry, |
| 210 | isBlock |
| 211 | }; |
| 212 | protected: |
| 213 | /// Type - Type of data stored in the value. |
| 214 | /// |
| 215 | unsigned Type; |
| 216 | public: |
| 217 | explicit DIEValue(unsigned T) : Type(T) {} |
| 218 | virtual ~DIEValue() {} |
| 219 | |
| 220 | // Accessors |
| 221 | unsigned getType() const { return Type; } |
| 222 | |
| 223 | /// EmitValue - Emit value via the Dwarf writer. |
| 224 | /// |
Chris Lattner | 066c9ac | 2010-01-22 22:23:57 +0000 | [diff] [blame] | 225 | virtual void EmitValue(DwarfPrinter *D, unsigned Form) const = 0; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 226 | |
| 227 | /// SizeOf - Return the size of a value in bytes. |
| 228 | /// |
| 229 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const = 0; |
| 230 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 231 | // Implement isa/cast/dyncast. |
| 232 | static bool classof(const DIEValue *) { return true; } |
| 233 | |
| 234 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 235 | virtual void print(raw_ostream &O) = 0; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 236 | void dump(); |
| 237 | #endif |
| 238 | }; |
| 239 | |
| 240 | //===--------------------------------------------------------------------===// |
| 241 | /// DIEInteger - An integer value DIE. |
| 242 | /// |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 243 | class DIEInteger : public DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 244 | uint64_t Integer; |
| 245 | public: |
| 246 | explicit DIEInteger(uint64_t I) : DIEValue(isInteger), Integer(I) {} |
| 247 | |
| 248 | /// BestForm - Choose the best form for integer. |
| 249 | /// |
| 250 | static unsigned BestForm(bool IsSigned, uint64_t Int) { |
| 251 | if (IsSigned) { |
| 252 | if ((char)Int == (signed)Int) return dwarf::DW_FORM_data1; |
| 253 | if ((short)Int == (signed)Int) return dwarf::DW_FORM_data2; |
| 254 | if ((int)Int == (signed)Int) return dwarf::DW_FORM_data4; |
| 255 | } else { |
| 256 | if ((unsigned char)Int == Int) return dwarf::DW_FORM_data1; |
| 257 | if ((unsigned short)Int == Int) return dwarf::DW_FORM_data2; |
| 258 | if ((unsigned int)Int == Int) return dwarf::DW_FORM_data4; |
| 259 | } |
| 260 | return dwarf::DW_FORM_data8; |
| 261 | } |
| 262 | |
| 263 | /// EmitValue - Emit integer of appropriate size. |
| 264 | /// |
Chris Lattner | 066c9ac | 2010-01-22 22:23:57 +0000 | [diff] [blame] | 265 | virtual void EmitValue(DwarfPrinter *D, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 266 | |
| 267 | /// SizeOf - Determine size of integer value in bytes. |
| 268 | /// |
| 269 | virtual unsigned SizeOf(const TargetData *TD, unsigned Form) const; |
| 270 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 271 | |
| 272 | // Implement isa/cast/dyncast. |
| 273 | static bool classof(const DIEInteger *) { return true; } |
| 274 | static bool classof(const DIEValue *I) { return I->getType() == isInteger; } |
| 275 | |
| 276 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 277 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 278 | #endif |
| 279 | }; |
| 280 | |
| 281 | //===--------------------------------------------------------------------===// |
Devang Patel | 69f57b1 | 2009-12-02 15:25:16 +0000 | [diff] [blame] | 282 | /// DIEString - A string value DIE. This DIE keeps string reference only. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 283 | /// |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 284 | class DIEString : public DIEValue { |
Devang Patel | e9a0597 | 2009-11-24 19:42:17 +0000 | [diff] [blame] | 285 | const StringRef Str; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 286 | public: |
Devang Patel | e9a0597 | 2009-11-24 19:42:17 +0000 | [diff] [blame] | 287 | explicit DIEString(const StringRef S) : DIEValue(isString), Str(S) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 288 | |
| 289 | /// EmitValue - Emit string value. |
| 290 | /// |
Chris Lattner | 066c9ac | 2010-01-22 22:23:57 +0000 | [diff] [blame] | 291 | virtual void EmitValue(DwarfPrinter *D, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 292 | |
| 293 | /// SizeOf - Determine size of string value in bytes. |
| 294 | /// |
| 295 | virtual unsigned SizeOf(const TargetData *, unsigned /*Form*/) const { |
| 296 | return Str.size() + sizeof(char); // sizeof('\0'); |
| 297 | } |
| 298 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 299 | // Implement isa/cast/dyncast. |
| 300 | static bool classof(const DIEString *) { return true; } |
| 301 | static bool classof(const DIEValue *S) { return S->getType() == isString; } |
| 302 | |
| 303 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 304 | virtual void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 305 | #endif |
| 306 | }; |
| 307 | |
| 308 | //===--------------------------------------------------------------------===// |
| 309 | /// DIEDwarfLabel - A Dwarf internal label expression DIE. |
| 310 | // |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 311 | /// FIXME: Merge into DIEObjectLabel. |
Nick Lewycky | 381afae | 2009-11-17 09:17:08 +0000 | [diff] [blame] | 312 | class DIEDwarfLabel : public DIEValue { |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 313 | const MCSymbol *Label; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 314 | public: |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 315 | explicit DIEDwarfLabel(const MCSymbol *L) : DIEValue(isLabel), Label(L) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 316 | |
| 317 | /// EmitValue - Emit label value. |
| 318 | /// |
Chris Lattner | 066c9ac | 2010-01-22 22:23:57 +0000 | [diff] [blame] | 319 | virtual void EmitValue(DwarfPrinter *D, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 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 { |
Chris Lattner | 858431d | 2010-01-16 18:50:28 +0000 | [diff] [blame] | 338 | const MCSymbol *Sym; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 339 | public: |
Chris Lattner | 858431d | 2010-01-16 18:50:28 +0000 | [diff] [blame] | 340 | explicit DIEObjectLabel(const MCSymbol *S) |
| 341 | : DIEValue(isAsIsLabel), Sym(S) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 342 | |
| 343 | /// EmitValue - Emit label value. |
| 344 | /// |
Chris Lattner | 066c9ac | 2010-01-22 22:23:57 +0000 | [diff] [blame] | 345 | virtual void EmitValue(DwarfPrinter *D, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 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 { |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 366 | const MCSymbol *Label; |
| 367 | const MCSymbol *Section; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 368 | bool IsEH : 1; |
| 369 | bool UseSet : 1; |
| 370 | public: |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 371 | DIESectionOffset(const MCSymbol *Lab, const MCSymbol *Sec, |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 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 | /// |
Chris Lattner | 066c9ac | 2010-01-22 22:23:57 +0000 | [diff] [blame] | 378 | virtual void EmitValue(DwarfPrinter *D, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 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 { |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 399 | const MCSymbol *LabelHi; |
| 400 | const MCSymbol *LabelLo; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 401 | public: |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 402 | DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo) |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 403 | : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {} |
| 404 | |
| 405 | /// EmitValue - Emit delta value. |
| 406 | /// |
Chris Lattner | 066c9ac | 2010-01-22 22:23:57 +0000 | [diff] [blame] | 407 | virtual void EmitValue(DwarfPrinter *D, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 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 | /// |
Chris Lattner | 066c9ac | 2010-01-22 22:23:57 +0000 | [diff] [blame] | 436 | virtual void EmitValue(DwarfPrinter *D, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 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 | /// |
Chris Lattner | 066c9ac | 2010-01-22 22:23:57 +0000 | [diff] [blame] | 478 | virtual void EmitValue(DwarfPrinter *D, unsigned Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 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 |