LLVM  4.0.0
TypeIndex.h
Go to the documentation of this file.
1 //===- TypeIndex.h ----------------------------------------------*- 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 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEINDEX_H
11 #define LLVM_DEBUGINFO_CODEVIEW_TYPEINDEX_H
12 
13 #include "llvm/Support/Endian.h"
14 #include <cassert>
15 #include <cinttypes>
16 
17 namespace llvm {
18 namespace codeview {
19 
20 enum class SimpleTypeKind : uint32_t {
21  None = 0x0000, // uncharacterized type (no type)
22  Void = 0x0003, // void
23  NotTranslated = 0x0007, // type not translated by cvpack
24  HResult = 0x0008, // OLE/COM HRESULT
25 
26  SignedCharacter = 0x0010, // 8 bit signed
27  UnsignedCharacter = 0x0020, // 8 bit unsigned
28  NarrowCharacter = 0x0070, // really a char
29  WideCharacter = 0x0071, // wide char
30  Character16 = 0x007a, // char16_t
31  Character32 = 0x007b, // char32_t
32 
33  SByte = 0x0068, // 8 bit signed int
34  Byte = 0x0069, // 8 bit unsigned int
35  Int16Short = 0x0011, // 16 bit signed
36  UInt16Short = 0x0021, // 16 bit unsigned
37  Int16 = 0x0072, // 16 bit signed int
38  UInt16 = 0x0073, // 16 bit unsigned int
39  Int32Long = 0x0012, // 32 bit signed
40  UInt32Long = 0x0022, // 32 bit unsigned
41  Int32 = 0x0074, // 32 bit signed int
42  UInt32 = 0x0075, // 32 bit unsigned int
43  Int64Quad = 0x0013, // 64 bit signed
44  UInt64Quad = 0x0023, // 64 bit unsigned
45  Int64 = 0x0076, // 64 bit signed int
46  UInt64 = 0x0077, // 64 bit unsigned int
47  Int128Oct = 0x0014, // 128 bit signed int
48  UInt128Oct = 0x0024, // 128 bit unsigned int
49  Int128 = 0x0078, // 128 bit signed int
50  UInt128 = 0x0079, // 128 bit unsigned int
51 
52  Float16 = 0x0046, // 16 bit real
53  Float32 = 0x0040, // 32 bit real
54  Float32PartialPrecision = 0x0045, // 32 bit PP real
55  Float48 = 0x0044, // 48 bit real
56  Float64 = 0x0041, // 64 bit real
57  Float80 = 0x0042, // 80 bit real
58  Float128 = 0x0043, // 128 bit real
59 
60  Complex16 = 0x0056, // 16 bit complex
61  Complex32 = 0x0050, // 32 bit complex
62  Complex32PartialPrecision = 0x0055, // 32 bit PP complex
63  Complex48 = 0x0054, // 48 bit complex
64  Complex64 = 0x0051, // 64 bit complex
65  Complex80 = 0x0052, // 80 bit complex
66  Complex128 = 0x0053, // 128 bit complex
67 
68  Boolean8 = 0x0030, // 8 bit boolean
69  Boolean16 = 0x0031, // 16 bit boolean
70  Boolean32 = 0x0032, // 32 bit boolean
71  Boolean64 = 0x0033, // 64 bit boolean
72  Boolean128 = 0x0034, // 128 bit boolean
73 };
74 
75 enum class SimpleTypeMode : uint32_t {
76  Direct = 0x00000000, // Not a pointer
77  NearPointer = 0x00000100, // Near pointer
78  FarPointer = 0x00000200, // Far pointer
79  HugePointer = 0x00000300, // Huge pointer
80  NearPointer32 = 0x00000400, // 32 bit near pointer
81  FarPointer32 = 0x00000500, // 32 bit far pointer
82  NearPointer64 = 0x00000600, // 64 bit near pointer
83  NearPointer128 = 0x00000700 // 128 bit near pointer
84 };
85 
86 /// A 32-bit type reference. Types are indexed by their order of appearance in
87 /// .debug$T plus 0x1000. Type indices less than 0x1000 are "simple" types,
88 /// composed of a SimpleTypeMode byte followed by a SimpleTypeKind byte.
89 class TypeIndex {
90 public:
91  static const uint32_t FirstNonSimpleIndex = 0x1000;
92  static const uint32_t SimpleKindMask = 0x000000ff;
93  static const uint32_t SimpleModeMask = 0x00000700;
94 
95 public:
96  TypeIndex() : Index(static_cast<uint32_t>(SimpleTypeKind::None)) {}
97  explicit TypeIndex(uint32_t Index) : Index(Index) {}
99  : Index(static_cast<uint32_t>(Kind)) {}
101  : Index(static_cast<uint32_t>(Kind) | static_cast<uint32_t>(Mode)) {}
102 
103  uint32_t getIndex() const { return Index; }
104  void setIndex(uint32_t I) { Index = I; }
105  bool isSimple() const { return Index < FirstNonSimpleIndex; }
106 
107  bool isNoneType() const { return *this == None(); }
108 
110  assert(isSimple());
111  return static_cast<SimpleTypeKind>(Index & SimpleKindMask);
112  }
113 
115  assert(isSimple());
116  return static_cast<SimpleTypeMode>(Index & SimpleModeMask);
117  }
118 
123  }
126  }
127 
130  }
133  }
136  }
139  }
142  }
145  }
151  }
157  }
158 
161 
162  friend inline bool operator==(const TypeIndex &A, const TypeIndex &B) {
163  return A.getIndex() == B.getIndex();
164  }
165 
166  friend inline bool operator!=(const TypeIndex &A, const TypeIndex &B) {
167  return A.getIndex() != B.getIndex();
168  }
169 
170  friend inline bool operator<(const TypeIndex &A, const TypeIndex &B) {
171  return A.getIndex() < B.getIndex();
172  }
173 
174  friend inline bool operator<=(const TypeIndex &A, const TypeIndex &B) {
175  return A.getIndex() <= B.getIndex();
176  }
177 
178  friend inline bool operator>(const TypeIndex &A, const TypeIndex &B) {
179  return A.getIndex() > B.getIndex();
180  }
181 
182  friend inline bool operator>=(const TypeIndex &A, const TypeIndex &B) {
183  return A.getIndex() >= B.getIndex();
184  }
185 
186 private:
187  support::ulittle32_t Index;
188 };
189 
190 }
191 }
192 
193 #endif
bool isSimple() const
Definition: TypeIndex.h:105
static TypeIndex UInt64Quad()
Definition: TypeIndex.h:155
static TypeIndex UInt64()
Definition: TypeIndex.h:153
friend bool operator!=(const TypeIndex &A, const TypeIndex &B)
Definition: TypeIndex.h:166
friend bool operator>=(const TypeIndex &A, const TypeIndex &B)
Definition: TypeIndex.h:182
SI Whole Quad Mode
bool isNoneType() const
Definition: TypeIndex.h:107
static TypeIndex Float32()
Definition: TypeIndex.h:159
static TypeIndex UInt32()
Definition: TypeIndex.h:147
TypeIndex(SimpleTypeKind Kind)
Definition: TypeIndex.h:98
TypeIndex(SimpleTypeKind Kind, SimpleTypeMode Mode)
Definition: TypeIndex.h:100
static TypeIndex Int16Short()
Definition: TypeIndex.h:140
void setIndex(uint32_t I)
Definition: TypeIndex.h:104
static TypeIndex UInt16Short()
Definition: TypeIndex.h:143
friend bool operator==(const TypeIndex &A, const TypeIndex &B)
Definition: TypeIndex.h:162
static const uint32_t FirstNonSimpleIndex
Definition: TypeIndex.h:91
A 32-bit type reference.
Definition: TypeIndex.h:89
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
static TypeIndex NarrowCharacter()
Definition: TypeIndex.h:134
uint32_t getIndex() const
Definition: TypeIndex.h:103
static TypeIndex VoidPointer64()
Definition: TypeIndex.h:124
TypeIndex(uint32_t Index)
Definition: TypeIndex.h:97
static TypeIndex Int64()
Definition: TypeIndex.h:152
static TypeIndex Int64Quad()
Definition: TypeIndex.h:154
static TypeIndex Int32()
Definition: TypeIndex.h:146
SimpleTypeKind getSimpleKind() const
Definition: TypeIndex.h:109
static TypeIndex UInt32Long()
Definition: TypeIndex.h:149
static TypeIndex Float64()
Definition: TypeIndex.h:160
static TypeIndex WideCharacter()
Definition: TypeIndex.h:137
static TypeIndex Int32Long()
Definition: TypeIndex.h:148
friend bool operator>(const TypeIndex &A, const TypeIndex &B)
Definition: TypeIndex.h:178
friend bool operator<(const TypeIndex &A, const TypeIndex &B)
Definition: TypeIndex.h:170
static TypeIndex Void()
Definition: TypeIndex.h:120
static TypeIndex UnsignedCharacter()
Definition: TypeIndex.h:131
static const uint32_t SimpleKindMask
Definition: TypeIndex.h:92
#define I(x, y, z)
Definition: MD5.cpp:54
static TypeIndex VoidPointer32()
Definition: TypeIndex.h:121
const unsigned Kind
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SimpleTypeMode getSimpleMode() const
Definition: TypeIndex.h:114
friend bool operator<=(const TypeIndex &A, const TypeIndex &B)
Definition: TypeIndex.h:174
static const uint32_t SimpleModeMask
Definition: TypeIndex.h:93
static TypeIndex None()
Definition: TypeIndex.h:119
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
static TypeIndex SignedCharacter()
Definition: TypeIndex.h:128