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
19 enum class SimpleTypeKind : uint32_t {
20 None = 0x0000, // uncharacterized type (no type)
21 Void = 0x0003, // void
22 NotTranslated = 0x0007, // type not translated by cvpack
23 HResult = 0x0008, // OLE/COM HRESULT
25 SignedCharacter = 0x0010, // 8 bit signed
26 UnsignedCharacter = 0x0020, // 8 bit unsigned
27 NarrowCharacter = 0x0070, // really a char
28 WideCharacter = 0x0071, // wide char
30 SByte = 0x0068, // 8 bit signed int
31 Byte = 0x0069, // 8 bit unsigned int
32 Int16Short = 0x0011, // 16 bit signed
33 UInt16Short = 0x0021, // 16 bit unsigned
34 Int16 = 0x0072, // 16 bit signed int
35 UInt16 = 0x0073, // 16 bit unsigned int
36 Int32Long = 0x0012, // 32 bit signed
37 UInt32Long = 0x0022, // 32 bit unsigned
38 Int32 = 0x0074, // 32 bit signed int
39 UInt32 = 0x0075, // 32 bit unsigned int
40 Int64Quad = 0x0013, // 64 bit signed
41 UInt64Quad = 0x0023, // 64 bit unsigned
42 Int64 = 0x0076, // 64 bit signed int
43 UInt64 = 0x0077, // 64 bit unsigned int
44 Int128 = 0x0078, // 128 bit signed int
45 UInt128 = 0x0079, // 128 bit unsigned int
47 Float16 = 0x0046, // 16 bit real
48 Float32 = 0x0040, // 32 bit real
49 Float32PartialPrecision = 0x0045, // 32 bit PP real
50 Float48 = 0x0044, // 48 bit real
51 Float64 = 0x0041, // 64 bit real
52 Float80 = 0x0042, // 80 bit real
53 Float128 = 0x0043, // 128 bit real
55 Complex32 = 0x0050, // 32 bit complex
56 Complex64 = 0x0051, // 64 bit complex
57 Complex80 = 0x0052, // 80 bit complex
58 Complex128 = 0x0053, // 128 bit complex
60 Boolean8 = 0x0030, // 8 bit boolean
61 Boolean16 = 0x0031, // 16 bit boolean
62 Boolean32 = 0x0032, // 32 bit boolean
63 Boolean64 = 0x0033 // 64 bit boolean
66 enum class SimpleTypeMode : uint32_t {
67 Direct = 0x00000000, // Not a pointer
68 NearPointer = 0x00000100, // Near pointer
69 FarPointer = 0x00000200, // Far pointer
70 HugePointer = 0x00000300, // Huge pointer
71 NearPointer32 = 0x00000400, // 32 bit near pointer
72 FarPointer32 = 0x00000500, // 32 bit far pointer
73 NearPointer64 = 0x00000600, // 64 bit near pointer
74 NearPointer128 = 0x00000700 // 128 bit near pointer
79 static const uint32_t FirstNonSimpleIndex = 0x1000;
80 static const uint32_t SimpleKindMask = 0x000000ff;
81 static const uint32_t SimpleModeMask = 0x00000700;
84 TypeIndex() : Index(0) {}
85 explicit TypeIndex(uint32_t Index) : Index(Index) {}
86 explicit TypeIndex(SimpleTypeKind Kind)
87 : Index(static_cast<uint32_t>(Kind)) {}
88 TypeIndex(SimpleTypeKind Kind, SimpleTypeMode Mode)
89 : Index(static_cast<uint32_t>(Kind) | static_cast<uint32_t>(Mode)) {}
91 uint32_t getIndex() const { return Index; }
92 bool isSimple() const { return Index < FirstNonSimpleIndex; }
94 SimpleTypeKind getSimpleKind() const {
96 return static_cast<SimpleTypeKind>(Index & SimpleKindMask);
99 SimpleTypeMode getSimpleMode() const {
101 return static_cast<SimpleTypeMode>(Index & SimpleModeMask);
104 static TypeIndex Void() { return TypeIndex(SimpleTypeKind::Void); }
105 static TypeIndex VoidPointer32() {
106 return TypeIndex(SimpleTypeKind::Void, SimpleTypeMode::NearPointer32);
108 static TypeIndex VoidPointer64() {
109 return TypeIndex(SimpleTypeKind::Void, SimpleTypeMode::NearPointer64);
112 static TypeIndex SignedCharacter() {
113 return TypeIndex(SimpleTypeKind::SignedCharacter);
115 static TypeIndex UnsignedCharacter() {
116 return TypeIndex(SimpleTypeKind::UnsignedCharacter);
118 static TypeIndex NarrowCharacter() {
119 return TypeIndex(SimpleTypeKind::NarrowCharacter);
121 static TypeIndex WideCharacter() {
122 return TypeIndex(SimpleTypeKind::WideCharacter);
124 static TypeIndex Int16Short() {
125 return TypeIndex(SimpleTypeKind::Int16Short);
127 static TypeIndex UInt16Short() {
128 return TypeIndex(SimpleTypeKind::UInt16Short);
130 static TypeIndex Int32() { return TypeIndex(SimpleTypeKind::Int32); }
131 static TypeIndex UInt32() { return TypeIndex(SimpleTypeKind::UInt32); }
132 static TypeIndex Int32Long() { return TypeIndex(SimpleTypeKind::Int32Long); }
133 static TypeIndex UInt32Long() {
134 return TypeIndex(SimpleTypeKind::UInt32Long);
136 static TypeIndex Int64() { return TypeIndex(SimpleTypeKind::Int64); }
137 static TypeIndex UInt64() { return TypeIndex(SimpleTypeKind::UInt64); }
138 static TypeIndex Int64Quad() { return TypeIndex(SimpleTypeKind::Int64Quad); }
139 static TypeIndex UInt64Quad() {
140 return TypeIndex(SimpleTypeKind::UInt64Quad);
143 static TypeIndex Float32() { return TypeIndex(SimpleTypeKind::Float32); }
144 static TypeIndex Float64() { return TypeIndex(SimpleTypeKind::Float64); }
150 inline bool operator==(const TypeIndex &A, const TypeIndex &B) {
151 return A.getIndex() == B.getIndex();
154 inline bool operator!=(const TypeIndex &A, const TypeIndex &B) {
155 return A.getIndex() != B.getIndex();
158 inline bool operator<(const TypeIndex &A, const TypeIndex &B) {
159 return A.getIndex() < B.getIndex();
162 inline bool operator<=(const TypeIndex &A, const TypeIndex &B) {
163 return A.getIndex() <= B.getIndex();
166 inline bool operator>(const TypeIndex &A, const TypeIndex &B) {
167 return A.getIndex() > B.getIndex();
170 inline bool operator>=(const TypeIndex &A, const TypeIndex &B) {
171 return A.getIndex() >= B.getIndex();