1 //===- TypeIndex.h ----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEINDEX_H
11 #define LLVM_DEBUGINFO_CODEVIEW_TYPEINDEX_H
13 #include "llvm/Support/Endian.h"
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
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
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
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
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
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
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
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.
91 static const uint32_t FirstNonSimpleIndex = 0x1000;
92 static const uint32_t SimpleKindMask = 0x000000ff;
93 static const uint32_t SimpleModeMask = 0x00000700;
96 TypeIndex() : Index(0) {}
97 explicit TypeIndex(uint32_t Index) : Index(Index) {}
98 explicit TypeIndex(SimpleTypeKind Kind)
99 : Index(static_cast<uint32_t>(Kind)) {}
100 TypeIndex(SimpleTypeKind Kind, SimpleTypeMode Mode)
101 : Index(static_cast<uint32_t>(Kind) | static_cast<uint32_t>(Mode)) {}
103 uint32_t getIndex() const { return Index; }
104 bool isSimple() const { return Index < FirstNonSimpleIndex; }
106 bool isNoneType() const { return *this == None(); }
108 SimpleTypeKind getSimpleKind() const {
110 return static_cast<SimpleTypeKind>(Index & SimpleKindMask);
113 SimpleTypeMode getSimpleMode() const {
115 return static_cast<SimpleTypeMode>(Index & SimpleModeMask);
118 static TypeIndex None() { return TypeIndex(SimpleTypeKind::None); }
119 static TypeIndex Void() { return TypeIndex(SimpleTypeKind::Void); }
120 static TypeIndex VoidPointer32() {
121 return TypeIndex(SimpleTypeKind::Void, SimpleTypeMode::NearPointer32);
123 static TypeIndex VoidPointer64() {
124 return TypeIndex(SimpleTypeKind::Void, SimpleTypeMode::NearPointer64);
127 static TypeIndex SignedCharacter() {
128 return TypeIndex(SimpleTypeKind::SignedCharacter);
130 static TypeIndex UnsignedCharacter() {
131 return TypeIndex(SimpleTypeKind::UnsignedCharacter);
133 static TypeIndex NarrowCharacter() {
134 return TypeIndex(SimpleTypeKind::NarrowCharacter);
136 static TypeIndex WideCharacter() {
137 return TypeIndex(SimpleTypeKind::WideCharacter);
139 static TypeIndex Int16Short() {
140 return TypeIndex(SimpleTypeKind::Int16Short);
142 static TypeIndex UInt16Short() {
143 return TypeIndex(SimpleTypeKind::UInt16Short);
145 static TypeIndex Int32() { return TypeIndex(SimpleTypeKind::Int32); }
146 static TypeIndex UInt32() { return TypeIndex(SimpleTypeKind::UInt32); }
147 static TypeIndex Int32Long() { return TypeIndex(SimpleTypeKind::Int32Long); }
148 static TypeIndex UInt32Long() {
149 return TypeIndex(SimpleTypeKind::UInt32Long);
151 static TypeIndex Int64() { return TypeIndex(SimpleTypeKind::Int64); }
152 static TypeIndex UInt64() { return TypeIndex(SimpleTypeKind::UInt64); }
153 static TypeIndex Int64Quad() { return TypeIndex(SimpleTypeKind::Int64Quad); }
154 static TypeIndex UInt64Quad() {
155 return TypeIndex(SimpleTypeKind::UInt64Quad);
158 static TypeIndex Float32() { return TypeIndex(SimpleTypeKind::Float32); }
159 static TypeIndex Float64() { return TypeIndex(SimpleTypeKind::Float64); }
161 friend inline bool operator==(const TypeIndex &A, const TypeIndex &B) {
162 return A.getIndex() == B.getIndex();
165 friend inline bool operator!=(const TypeIndex &A, const TypeIndex &B) {
166 return A.getIndex() != B.getIndex();
169 friend inline bool operator<(const TypeIndex &A, const TypeIndex &B) {
170 return A.getIndex() < B.getIndex();
173 friend inline bool operator<=(const TypeIndex &A, const TypeIndex &B) {
174 return A.getIndex() <= B.getIndex();
177 friend inline bool operator>(const TypeIndex &A, const TypeIndex &B) {
178 return A.getIndex() > B.getIndex();
181 friend inline bool operator>=(const TypeIndex &A, const TypeIndex &B) {
182 return A.getIndex() >= B.getIndex();
186 support::ulittle32_t Index;