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. |
Eric Christopher | ff34845 | 2013-01-07 22:40:45 +0000 | [diff] [blame] | 11 | // |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 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" |
David Blaikie | 95e72c9 | 2013-06-28 20:05:04 +0000 | [diff] [blame] | 21 | #include "llvm/MC/MCExpr.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; |
Chris Lattner | 858431d | 2010-01-16 18:50:28 +0000 | [diff] [blame] | 26 | class MCSymbol; |
David Blaikie | 95e72c9 | 2013-06-28 20:05:04 +0000 | [diff] [blame] | 27 | class MCSymbolRefExpr; |
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 | //===--------------------------------------------------------------------===// |
Eric Christopher | 0fbaa37 | 2013-06-10 22:24:07 +0000 | [diff] [blame] | 31 | /// DIEAbbrevData - Dwarf abbreviation data, describes one attribute of a |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 32 | /// Dwarf abbreviation. |
Benjamin Kramer | 15f387c | 2013-09-11 17:42:27 +0000 | [diff] [blame^] | 33 | class LLVM_LIBRARY_VISIBILITY DIEAbbrevData { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 34 | /// Attribute - Dwarf attribute code. |
| 35 | /// |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame] | 36 | uint16_t Attribute; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 37 | |
| 38 | /// Form - Dwarf form code. |
| 39 | /// |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame] | 40 | uint16_t Form; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 41 | public: |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame] | 42 | DIEAbbrevData(uint16_t A, uint16_t F) : Attribute(A), Form(F) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 43 | |
| 44 | // Accessors. |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame] | 45 | uint16_t getAttribute() const { return Attribute; } |
| 46 | uint16_t getForm() const { return Form; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 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. |
Benjamin Kramer | 15f387c | 2013-09-11 17:42:27 +0000 | [diff] [blame^] | 56 | class LLVM_LIBRARY_VISIBILITY DIEAbbrev : public FoldingSetNode { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 57 | /// Tag - Dwarf tag code. |
| 58 | /// |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame] | 59 | uint16_t Tag; |
| 60 | |
| 61 | /// ChildrenFlag - Dwarf children flag. |
| 62 | /// |
| 63 | uint16_t ChildrenFlag; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 64 | |
| 65 | /// Unique number for node. |
| 66 | /// |
| 67 | unsigned Number; |
| 68 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 69 | /// Data - Raw data bytes for abbreviation. |
| 70 | /// |
Eric Christopher | 2df938a | 2013-03-29 20:23:06 +0000 | [diff] [blame] | 71 | SmallVector<DIEAbbrevData, 12> 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: |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame] | 74 | DIEAbbrev(uint16_t T, uint16_t C) : Tag(T), ChildrenFlag(C), Data() {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 75 | |
| 76 | // Accessors. |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame] | 77 | uint16_t getTag() const { return Tag; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 78 | unsigned getNumber() const { return Number; } |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame] | 79 | uint16_t getChildrenFlag() const { return ChildrenFlag; } |
Eric Christopher | f7cef70 | 2013-03-29 23:34:06 +0000 | [diff] [blame] | 80 | const SmallVectorImpl<DIEAbbrevData> &getData() const { return Data; } |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame] | 81 | void setTag(uint16_t T) { Tag = T; } |
| 82 | void setChildrenFlag(uint16_t CF) { ChildrenFlag = CF; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 83 | void setNumber(unsigned N) { Number = N; } |
| 84 | |
| 85 | /// AddAttribute - Adds another set of attribute information to the |
| 86 | /// abbreviation. |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame] | 87 | void AddAttribute(uint16_t Attribute, uint16_t Form) { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 88 | Data.push_back(DIEAbbrevData(Attribute, Form)); |
| 89 | } |
| 90 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 91 | /// Profile - Used to gather unique data for the abbreviation folding set. |
| 92 | /// |
| 93 | void Profile(FoldingSetNodeID &ID) const; |
| 94 | |
| 95 | /// Emit - Print the abbreviation using the specified asm printer. |
| 96 | /// |
Chris Lattner | d38fee8 | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 97 | void Emit(AsmPrinter *AP) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 98 | |
| 99 | #ifndef NDEBUG |
Chris Lattner | b01acfa | 2009-08-23 01:01:17 +0000 | [diff] [blame] | 100 | void print(raw_ostream &O); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 101 | void dump(); |
| 102 | #endif |
| 103 | }; |
| 104 | |
| 105 | //===--------------------------------------------------------------------===// |
| 106 | /// DIE - A structured debug information entry. Has an abbreviation which |
Eric Christopher | 0c5cdc5 | 2013-04-03 05:29:58 +0000 | [diff] [blame] | 107 | /// describes its organization. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 108 | class DIEValue; |
| 109 | |
Benjamin Kramer | 15f387c | 2013-09-11 17:42:27 +0000 | [diff] [blame^] | 110 | class LLVM_LIBRARY_VISIBILITY DIE { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 111 | protected: |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 112 | /// Offset - Offset in debug info section. |
| 113 | /// |
| 114 | unsigned Offset; |
| 115 | |
| 116 | /// Size - Size of instance + children. |
| 117 | /// |
| 118 | unsigned Size; |
| 119 | |
Benjamin Kramer | e697b4f | 2012-01-24 12:08:28 +0000 | [diff] [blame] | 120 | /// Abbrev - Buffer for constructing abbreviation. |
| 121 | /// |
| 122 | DIEAbbrev Abbrev; |
| 123 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 124 | /// Children DIEs. |
| 125 | /// |
| 126 | std::vector<DIE *> Children; |
| 127 | |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 128 | DIE *Parent; |
| 129 | |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 130 | /// Attribute values. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 131 | /// |
Eric Christopher | 2df938a | 2013-03-29 20:23:06 +0000 | [diff] [blame] | 132 | SmallVector<DIEValue*, 12> Values; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 133 | |
Eric Christopher | d32d7a5 | 2013-06-10 20:58:53 +0000 | [diff] [blame] | 134 | #ifndef NDEBUG |
Owen Anderson | d5509f2 | 2009-06-24 23:13:56 +0000 | [diff] [blame] | 135 | // Private data for print() |
| 136 | mutable unsigned IndentCount; |
Eric Christopher | d32d7a5 | 2013-06-10 20:58:53 +0000 | [diff] [blame] | 137 | #endif |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 138 | public: |
| 139 | explicit DIE(unsigned Tag) |
Eric Christopher | 30cb836 | 2013-05-06 17:50:50 +0000 | [diff] [blame] | 140 | : Offset(0), Size(0), Abbrev(Tag, dwarf::DW_CHILDREN_no), Parent(0) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 141 | virtual ~DIE(); |
| 142 | |
| 143 | // Accessors. |
| 144 | DIEAbbrev &getAbbrev() { return Abbrev; } |
| 145 | unsigned getAbbrevNumber() const { return Abbrev.getNumber(); } |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 146 | uint16_t getTag() const { return Abbrev.getTag(); } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 147 | unsigned getOffset() const { return Offset; } |
| 148 | unsigned getSize() const { return Size; } |
| 149 | const std::vector<DIE *> &getChildren() const { return Children; } |
Eric Christopher | f7cef70 | 2013-03-29 23:34:06 +0000 | [diff] [blame] | 150 | const SmallVectorImpl<DIEValue*> &getValues() const { return Values; } |
Devang Patel | 6404e4e | 2009-12-15 19:16:48 +0000 | [diff] [blame] | 151 | DIE *getParent() const { return Parent; } |
Manman Ren | bc3e96f | 2013-03-12 18:27:15 +0000 | [diff] [blame] | 152 | /// Climb up the parent chain to get the compile unit DIE this DIE belongs |
| 153 | /// to. |
Eric Christopher | 4d7f2ce | 2013-05-14 21:33:10 +0000 | [diff] [blame] | 154 | DIE *getCompileUnit(); |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 155 | void setTag(uint16_t Tag) { Abbrev.setTag(Tag); } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 156 | void setOffset(unsigned O) { Offset = O; } |
| 157 | void setSize(unsigned S) { Size = S; } |
Eric Christopher | ff34845 | 2013-01-07 22:40:45 +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 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 161 | void addValue(uint16_t Attribute, uint16_t 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 | |
Eric Christopher | b766913 | 2013-08-07 01:18:33 +0000 | [diff] [blame] | 178 | /// findAttribute - Find a value in the DIE with the attribute given, returns NULL |
| 179 | /// if no such attribute exists. |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 180 | DIEValue *findAttribute(uint16_t Attribute); |
Eric Christopher | b766913 | 2013-08-07 01:18:33 +0000 | [diff] [blame] | 181 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 182 | #ifndef NDEBUG |
Eric Christopher | 30cb836 | 2013-05-06 17:50:50 +0000 | [diff] [blame] | 183 | void print(raw_ostream &O, unsigned IndentCount = 0) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 184 | void dump(); |
| 185 | #endif |
| 186 | }; |
| 187 | |
| 188 | //===--------------------------------------------------------------------===// |
| 189 | /// DIEValue - A debug information entry value. |
| 190 | /// |
Benjamin Kramer | 15f387c | 2013-09-11 17:42:27 +0000 | [diff] [blame^] | 191 | class LLVM_LIBRARY_VISIBILITY DIEValue { |
David Blaikie | 2d24e2a | 2011-12-20 02:50:00 +0000 | [diff] [blame] | 192 | virtual void anchor(); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 193 | public: |
| 194 | enum { |
| 195 | isInteger, |
| 196 | isString, |
Ulrich Weigand | 1f8aacd | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 197 | isExpr, |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 198 | isLabel, |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 199 | isDelta, |
| 200 | isEntry, |
| 201 | isBlock |
| 202 | }; |
| 203 | protected: |
| 204 | /// Type - Type of data stored in the value. |
| 205 | /// |
| 206 | unsigned Type; |
| 207 | public: |
| 208 | explicit DIEValue(unsigned T) : Type(T) {} |
| 209 | virtual ~DIEValue() {} |
| 210 | |
| 211 | // Accessors |
| 212 | unsigned getType() const { return Type; } |
| 213 | |
| 214 | /// EmitValue - Emit value via the Dwarf writer. |
| 215 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 216 | virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const = 0; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 217 | |
| 218 | /// SizeOf - Return the size of a value in bytes. |
| 219 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 220 | virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const = 0; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 221 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 222 | #ifndef NDEBUG |
Eric Christopher | 813419e | 2013-05-31 22:50:40 +0000 | [diff] [blame] | 223 | virtual void print(raw_ostream &O) const = 0; |
| 224 | void dump() const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 225 | #endif |
| 226 | }; |
| 227 | |
| 228 | //===--------------------------------------------------------------------===// |
| 229 | /// DIEInteger - An integer value DIE. |
| 230 | /// |
Benjamin Kramer | 15f387c | 2013-09-11 17:42:27 +0000 | [diff] [blame^] | 231 | class LLVM_LIBRARY_VISIBILITY DIEInteger : public DIEValue { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 232 | uint64_t Integer; |
| 233 | public: |
| 234 | explicit DIEInteger(uint64_t I) : DIEValue(isInteger), Integer(I) {} |
| 235 | |
| 236 | /// BestForm - Choose the best form for integer. |
| 237 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 238 | static uint16_t BestForm(bool IsSigned, uint64_t Int) { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 239 | if (IsSigned) { |
Hans Wennborg | a12c674 | 2013-03-18 17:03:05 +0000 | [diff] [blame] | 240 | const int64_t SignedInt = Int; |
| 241 | if ((char)Int == SignedInt) return dwarf::DW_FORM_data1; |
| 242 | if ((short)Int == SignedInt) return dwarf::DW_FORM_data2; |
| 243 | if ((int)Int == SignedInt) return dwarf::DW_FORM_data4; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 244 | } else { |
| 245 | if ((unsigned char)Int == Int) return dwarf::DW_FORM_data1; |
| 246 | if ((unsigned short)Int == Int) return dwarf::DW_FORM_data2; |
| 247 | if ((unsigned int)Int == Int) return dwarf::DW_FORM_data4; |
| 248 | } |
| 249 | return dwarf::DW_FORM_data8; |
| 250 | } |
| 251 | |
| 252 | /// EmitValue - Emit integer of appropriate size. |
| 253 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 254 | virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 255 | |
Devang Patel | f2548ca | 2010-04-16 23:33:45 +0000 | [diff] [blame] | 256 | uint64_t getValue() const { return Integer; } |
| 257 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 258 | /// SizeOf - Determine size of integer value in bytes. |
| 259 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 260 | virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 261 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 262 | // Implement isa/cast/dyncast. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 263 | static bool classof(const DIEValue *I) { return I->getType() == isInteger; } |
| 264 | |
| 265 | #ifndef NDEBUG |
Eric Christopher | 813419e | 2013-05-31 22:50:40 +0000 | [diff] [blame] | 266 | virtual void print(raw_ostream &O) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 267 | #endif |
| 268 | }; |
| 269 | |
| 270 | //===--------------------------------------------------------------------===// |
Ulrich Weigand | 1f8aacd | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 271 | /// DIEExpr - An expression DIE. |
| 272 | // |
Benjamin Kramer | 15f387c | 2013-09-11 17:42:27 +0000 | [diff] [blame^] | 273 | class LLVM_LIBRARY_VISIBILITY DIEExpr : public DIEValue { |
Ulrich Weigand | 1f8aacd | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 274 | const MCExpr *Expr; |
| 275 | public: |
| 276 | explicit DIEExpr(const MCExpr *E) : DIEValue(isExpr), Expr(E) {} |
| 277 | |
| 278 | /// EmitValue - Emit expression value. |
| 279 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 280 | virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const; |
Ulrich Weigand | 1f8aacd | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 281 | |
| 282 | /// getValue - Get MCExpr. |
| 283 | /// |
| 284 | const MCExpr *getValue() const { return Expr; } |
| 285 | |
| 286 | /// SizeOf - Determine size of expression value in bytes. |
| 287 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 288 | virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const; |
Ulrich Weigand | 1f8aacd | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 289 | |
| 290 | // Implement isa/cast/dyncast. |
| 291 | static bool classof(const DIEValue *E) { return E->getType() == isExpr; } |
| 292 | |
| 293 | #ifndef NDEBUG |
| 294 | virtual void print(raw_ostream &O) const; |
| 295 | #endif |
| 296 | }; |
| 297 | |
| 298 | //===--------------------------------------------------------------------===// |
| 299 | /// DIELabel - A label DIE. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 300 | // |
Benjamin Kramer | 15f387c | 2013-09-11 17:42:27 +0000 | [diff] [blame^] | 301 | class LLVM_LIBRARY_VISIBILITY DIELabel : public DIEValue { |
Ulrich Weigand | 1f8aacd | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 302 | const MCSymbol *Label; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 303 | public: |
Ulrich Weigand | 1f8aacd | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 304 | explicit DIELabel(const MCSymbol *L) : DIEValue(isLabel), Label(L) {} |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 305 | |
| 306 | /// EmitValue - Emit label value. |
| 307 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 308 | virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 309 | |
Devang Patel | c3f5f78 | 2010-05-25 23:40:22 +0000 | [diff] [blame] | 310 | /// getValue - Get MCSymbol. |
| 311 | /// |
Ulrich Weigand | 1f8aacd | 2013-07-02 18:46:26 +0000 | [diff] [blame] | 312 | const MCSymbol *getValue() const { return Label; } |
Devang Patel | c3f5f78 | 2010-05-25 23:40:22 +0000 | [diff] [blame] | 313 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 314 | /// SizeOf - Determine size of label value in bytes. |
| 315 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 316 | virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 317 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 318 | // Implement isa/cast/dyncast. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 319 | static bool classof(const DIEValue *L) { return L->getType() == isLabel; } |
| 320 | |
| 321 | #ifndef NDEBUG |
Eric Christopher | 813419e | 2013-05-31 22:50:40 +0000 | [diff] [blame] | 322 | virtual void print(raw_ostream &O) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 323 | #endif |
| 324 | }; |
| 325 | |
| 326 | //===--------------------------------------------------------------------===// |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 327 | /// DIEDelta - A simple label difference DIE. |
| 328 | /// |
Benjamin Kramer | 15f387c | 2013-09-11 17:42:27 +0000 | [diff] [blame^] | 329 | class LLVM_LIBRARY_VISIBILITY DIEDelta : public DIEValue { |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 330 | const MCSymbol *LabelHi; |
| 331 | const MCSymbol *LabelLo; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 332 | public: |
Chris Lattner | b98b1bf | 2010-03-08 22:23:36 +0000 | [diff] [blame] | 333 | DIEDelta(const MCSymbol *Hi, const MCSymbol *Lo) |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 334 | : DIEValue(isDelta), LabelHi(Hi), LabelLo(Lo) {} |
| 335 | |
| 336 | /// EmitValue - Emit delta value. |
| 337 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 338 | virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 339 | |
| 340 | /// SizeOf - Determine size of delta value in bytes. |
| 341 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 342 | virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 343 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 344 | // Implement isa/cast/dyncast. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 345 | static bool classof(const DIEValue *D) { return D->getType() == isDelta; } |
| 346 | |
| 347 | #ifndef NDEBUG |
Eric Christopher | 813419e | 2013-05-31 22:50:40 +0000 | [diff] [blame] | 348 | virtual void print(raw_ostream &O) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 349 | #endif |
| 350 | }; |
| 351 | |
| 352 | //===--------------------------------------------------------------------===// |
Eric Christopher | 3dee575 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 353 | /// DIEString - A container for string values. |
| 354 | /// |
Benjamin Kramer | 15f387c | 2013-09-11 17:42:27 +0000 | [diff] [blame^] | 355 | class LLVM_LIBRARY_VISIBILITY DIEString : public DIEValue { |
Eric Christopher | 3dee575 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 356 | const DIEValue *Access; |
| 357 | const StringRef Str; |
| 358 | |
| 359 | public: |
| 360 | DIEString(const DIEValue *Acc, const StringRef S) |
| 361 | : DIEValue(isString), Access(Acc), Str(S) {} |
| 362 | |
| 363 | /// getString - Grab the string out of the object. |
| 364 | StringRef getString() const { return Str; } |
| 365 | |
| 366 | /// EmitValue - Emit delta value. |
| 367 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 368 | virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const; |
Eric Christopher | 3dee575 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 369 | |
| 370 | /// SizeOf - Determine size of delta value in bytes. |
| 371 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 372 | virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const; |
Eric Christopher | 3dee575 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 373 | |
| 374 | // Implement isa/cast/dyncast. |
| 375 | static bool classof(const DIEValue *D) { return D->getType() == isString; } |
| 376 | |
| 377 | #ifndef NDEBUG |
| 378 | virtual void print(raw_ostream &O) const; |
| 379 | #endif |
| 380 | }; |
| 381 | |
| 382 | //===--------------------------------------------------------------------===// |
Nick Lewycky | 024170f | 2011-10-18 22:39:43 +0000 | [diff] [blame] | 383 | /// DIEEntry - A pointer to another debug information entry. An instance of |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 384 | /// this class can also be used as a proxy for a debug information entry not |
| 385 | /// yet defined (ie. types.) |
Benjamin Kramer | 15f387c | 2013-09-11 17:42:27 +0000 | [diff] [blame^] | 386 | class LLVM_LIBRARY_VISIBILITY DIEEntry : public DIEValue { |
Jeffrey Yasskin | 5c213dc | 2010-03-12 17:45:06 +0000 | [diff] [blame] | 387 | DIE *const Entry; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 388 | public: |
David Blaikie | 17a692e | 2013-05-14 00:35:19 +0000 | [diff] [blame] | 389 | explicit DIEEntry(DIE *E) : DIEValue(isEntry), Entry(E) { |
| 390 | assert(E && "Cannot construct a DIEEntry with a null DIE"); |
| 391 | } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 392 | |
| 393 | DIE *getEntry() const { return Entry; } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 394 | |
| 395 | /// EmitValue - Emit debug information entry offset. |
| 396 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 397 | virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 398 | |
| 399 | /// SizeOf - Determine size of debug information entry in bytes. |
| 400 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 401 | virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const { |
| 402 | return Form == dwarf::DW_FORM_ref_addr ? getRefAddrSize(AP) |
| 403 | : sizeof(int32_t); |
Manman Ren | 624a93e | 2013-04-04 23:13:11 +0000 | [diff] [blame] | 404 | } |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 405 | |
Manman Ren | 0e6783f | 2013-07-02 23:40:10 +0000 | [diff] [blame] | 406 | /// Returns size of a ref_addr entry. |
| 407 | static unsigned getRefAddrSize(AsmPrinter *AP); |
| 408 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 409 | // Implement isa/cast/dyncast. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 410 | static bool classof(const DIEValue *E) { return E->getType() == isEntry; } |
| 411 | |
| 412 | #ifndef NDEBUG |
Eric Christopher | 813419e | 2013-05-31 22:50:40 +0000 | [diff] [blame] | 413 | virtual void print(raw_ostream &O) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 414 | #endif |
| 415 | }; |
| 416 | |
| 417 | //===--------------------------------------------------------------------===// |
| 418 | /// DIEBlock - A block of values. Primarily used for location expressions. |
| 419 | // |
Benjamin Kramer | 15f387c | 2013-09-11 17:42:27 +0000 | [diff] [blame^] | 420 | class LLVM_LIBRARY_VISIBILITY DIEBlock : public DIEValue, public DIE { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 421 | unsigned Size; // Size in bytes excluding size header. |
| 422 | public: |
| 423 | DIEBlock() |
| 424 | : DIEValue(isBlock), DIE(0), Size(0) {} |
| 425 | virtual ~DIEBlock() {} |
| 426 | |
| 427 | /// ComputeSize - calculate the size of the block. |
| 428 | /// |
Chris Lattner | a37d538 | 2010-04-05 00:18:22 +0000 | [diff] [blame] | 429 | unsigned ComputeSize(AsmPrinter *AP); |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 430 | |
| 431 | /// BestForm - Choose the best form for data. |
| 432 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 433 | uint16_t BestForm() const { |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 434 | if ((unsigned char)Size == Size) return dwarf::DW_FORM_block1; |
| 435 | if ((unsigned short)Size == Size) return dwarf::DW_FORM_block2; |
| 436 | if ((unsigned int)Size == Size) return dwarf::DW_FORM_block4; |
| 437 | return dwarf::DW_FORM_block; |
| 438 | } |
| 439 | |
| 440 | /// EmitValue - Emit block data. |
| 441 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 442 | virtual void EmitValue(AsmPrinter *AP, uint16_t Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 443 | |
| 444 | /// SizeOf - Determine size of block data in bytes. |
| 445 | /// |
Eric Christopher | 3166762 | 2013-08-08 01:41:00 +0000 | [diff] [blame] | 446 | virtual unsigned SizeOf(AsmPrinter *AP, uint16_t Form) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 447 | |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 448 | // Implement isa/cast/dyncast. |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 449 | static bool classof(const DIEValue *E) { return E->getType() == isBlock; } |
| 450 | |
| 451 | #ifndef NDEBUG |
Eric Christopher | 813419e | 2013-05-31 22:50:40 +0000 | [diff] [blame] | 452 | virtual void print(raw_ostream &O) const; |
Bill Wendling | 88423ee | 2009-05-15 00:11:17 +0000 | [diff] [blame] | 453 | #endif |
| 454 | }; |
| 455 | |
| 456 | } // end llvm namespace |
| 457 | |
| 458 | #endif |