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