OLD | NEW |
1 //===- subzero/src/IceTypes.cpp - Primitive type properties ---------------===// | 1 //===- subzero/src/IceTypes.cpp - Primitive type properties ---------------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file defines a few attributes of Subzero primitive types. | 10 // This file defines a few attributes of Subzero primitive types. |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 // Define a temporary set of enum values based on ICETYPE_TABLE | 27 // Define a temporary set of enum values based on ICETYPE_TABLE |
28 enum { | 28 enum { |
29 #define X(tag, size, align, elts, elty, str) _table_tag_##tag, | 29 #define X(tag, size, align, elts, elty, str) _table_tag_##tag, |
30 ICETYPE_TABLE | 30 ICETYPE_TABLE |
31 #undef X | 31 #undef X |
32 _enum_table_tag_Names | 32 _enum_table_tag_Names |
33 }; | 33 }; |
34 // Define a temporary set of enum values based on ICETYPE_PROPS_TABLE | 34 // Define a temporary set of enum values based on ICETYPE_PROPS_TABLE |
35 enum { | 35 enum { |
36 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, CompareResult) \ | 36 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ |
37 _props_table_tag_##tag, | 37 _props_table_tag_##tag, |
38 ICETYPE_PROPS_TABLE | 38 ICETYPE_PROPS_TABLE |
39 #undef X | 39 #undef X |
40 _enum_props_table_tag_Names | 40 _enum_props_table_tag_Names |
41 }; | 41 }; |
42 // Assert that tags in ICETYPE_TABLE are also in ICETYPE_PROPS_TABLE. | 42 // Assert that tags in ICETYPE_TABLE are also in ICETYPE_PROPS_TABLE. |
43 #define X(tag, size, align, elts, elty, str) \ | 43 #define X(tag, size, align, elts, elty, str) \ |
44 STATIC_ASSERT((unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag); | 44 STATIC_ASSERT((unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag); |
45 ICETYPE_TABLE; | 45 ICETYPE_TABLE; |
46 #undef X | 46 #undef X |
47 // Assert that tags in ICETYPE_PROPS_TABLE is in ICETYPE_TABLE. | 47 // Assert that tags in ICETYPE_PROPS_TABLE is in ICETYPE_TABLE. |
48 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, CompareResult) \ | 48 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ |
49 STATIC_ASSERT((unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag); | 49 STATIC_ASSERT((unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag); |
50 ICETYPE_PROPS_TABLE; | 50 ICETYPE_PROPS_TABLE |
51 #undef X | 51 #undef X |
52 | 52 |
53 // Show vector definitions match in ICETYPE_TABLE and | 53 // Show vector definitions match in ICETYPE_TABLE and |
54 // ICETYPE_PROPS_TABLE. | 54 // ICETYPE_PROPS_TABLE. |
55 | 55 |
56 // Define constants for each element size in ICETYPE_TABLE. | 56 // Define constants for each element size in ICETYPE_TABLE. |
57 enum { | 57 enum { |
58 #define X(tag, size, align, elts, elty, str) _table_elts_##tag = elts, | 58 #define X(tag, size, align, elts, elty, str) _table_elts_##tag = elts, |
59 ICETYPE_TABLE | 59 ICETYPE_TABLE |
60 #undef X | 60 #undef X |
61 _enum_table_elts_Elements = 0 | 61 _enum_table_elts_Elements = 0 |
62 }; | 62 }; |
63 // Define constants for boolean flag if vector in ICETYPE_PROPS_TABLE. | 63 // Define constants for boolean flag if vector in ICETYPE_PROPS_TABLE. |
64 enum { | 64 enum { |
65 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, CompareResult) \ | 65 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ |
66 _props_table_IsVec_##tag = IsVec, | 66 _props_table_IsVec_##tag = IsVec, |
67 ICETYPE_PROPS_TABLE | 67 ICETYPE_PROPS_TABLE |
68 #undef X | 68 #undef X |
69 }; | 69 }; |
70 // Verify that the number of vector elements is consistent with IsVec. | 70 // Verify that the number of vector elements is consistent with IsVec. |
71 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, CompareResult) \ | 71 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ |
72 STATIC_ASSERT((_table_elts_##tag > 1) == _props_table_IsVec_##tag); | 72 STATIC_ASSERT((_table_elts_##tag > 1) == _props_table_IsVec_##tag); |
73 ICETYPE_PROPS_TABLE; | 73 ICETYPE_PROPS_TABLE; |
74 #undef X | 74 #undef X |
75 } | 75 } |
76 | 76 |
77 struct TypeAttributeFields { | 77 struct TypeAttributeFields { |
78 size_t TypeWidthInBytes; | 78 size_t TypeWidthInBytes; |
79 size_t TypeAlignInBytes; | 79 size_t TypeAlignInBytes; |
80 size_t TypeNumElements; | 80 size_t TypeNumElements; |
81 Type TypeElementType; | 81 Type TypeElementType; |
(...skipping 10 matching lines...) Expand all Loading... |
92 | 92 |
93 struct TypePropertyFields { | 93 struct TypePropertyFields { |
94 bool TypeIsVectorType; | 94 bool TypeIsVectorType; |
95 bool TypeIsIntegerType; | 95 bool TypeIsIntegerType; |
96 bool TypeIsScalarIntegerType; | 96 bool TypeIsScalarIntegerType; |
97 bool TypeIsVectorIntegerType; | 97 bool TypeIsVectorIntegerType; |
98 bool TypeIsIntegerArithmeticType; | 98 bool TypeIsIntegerArithmeticType; |
99 bool TypeIsFloatingType; | 99 bool TypeIsFloatingType; |
100 bool TypeIsScalarFloatingType; | 100 bool TypeIsScalarFloatingType; |
101 bool TypeIsVectorFloatingType; | 101 bool TypeIsVectorFloatingType; |
| 102 bool TypeIsLoadStoreType; |
102 Type CompareResultType; | 103 Type CompareResultType; |
103 }; | 104 }; |
104 | 105 |
105 const TypePropertyFields TypePropertiesTable[] = { | 106 const TypePropertyFields TypePropertiesTable[] = { |
106 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, CompareResult) \ | 107 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ |
107 { \ | 108 { \ |
108 IsVec, IsInt, IsInt && !IsVec, IsInt && IsVec, IsIntArith, IsFloat, \ | 109 IsVec, IsInt, IsInt && !IsVec, IsInt && IsVec, IsIntArith, IsFloat, \ |
109 IsFloat && !IsVec, IsFloat && IsVec, CompareResult \ | 110 IsFloat && !IsVec, IsFloat && IsVec, IsLoadStore, CompareResult \ |
110 } \ | 111 } \ |
111 , | 112 , |
112 ICETYPE_PROPS_TABLE | 113 ICETYPE_PROPS_TABLE |
113 #undef X | 114 #undef X |
114 }; | 115 }; |
115 | 116 |
116 } // end anonymous namespace | 117 } // end anonymous namespace |
117 | 118 |
118 size_t typeWidthInBytes(Type Ty) { | 119 size_t typeWidthInBytes(Type Ty) { |
119 size_t Index = static_cast<size_t>(Ty); | 120 size_t Index = static_cast<size_t>(Ty); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 205 } |
205 | 206 |
206 bool isVectorFloatingType(Type Ty) { | 207 bool isVectorFloatingType(Type Ty) { |
207 size_t Index = static_cast<size_t>(Ty); | 208 size_t Index = static_cast<size_t>(Ty); |
208 if (Index < IceType_NUM) | 209 if (Index < IceType_NUM) |
209 return TypePropertiesTable[Index].TypeIsVectorFloatingType; | 210 return TypePropertiesTable[Index].TypeIsVectorFloatingType; |
210 llvm_unreachable("Invalid type for isVectorFloatingType()"); | 211 llvm_unreachable("Invalid type for isVectorFloatingType()"); |
211 return false; | 212 return false; |
212 } | 213 } |
213 | 214 |
| 215 bool isLoadStoreType(Type Ty) { |
| 216 size_t Index = static_cast<size_t>(Ty); |
| 217 if (Index < IceType_NUM) |
| 218 return TypePropertiesTable[Index].TypeIsLoadStoreType; |
| 219 llvm_unreachable("Invalid type for isLoadStoreType()"); |
| 220 return false; |
| 221 } |
| 222 |
214 Type getCompareResultType(Type Ty) { | 223 Type getCompareResultType(Type Ty) { |
215 size_t Index = static_cast<size_t>(Ty); | 224 size_t Index = static_cast<size_t>(Ty); |
216 if (Index < IceType_NUM) | 225 if (Index < IceType_NUM) |
217 return TypePropertiesTable[Index].CompareResultType; | 226 return TypePropertiesTable[Index].CompareResultType; |
218 llvm_unreachable("Invalid type for getCompareResultType"); | 227 llvm_unreachable("Invalid type for getCompareResultType"); |
219 return IceType_void; | 228 return IceType_void; |
220 } | 229 } |
221 | 230 |
222 // ======================== Dump routines ======================== // | 231 // ======================== Dump routines ======================== // |
223 | 232 |
224 const char *typeString(Type Ty) { | 233 const char *typeString(Type Ty) { |
225 size_t Index = static_cast<size_t>(Ty); | 234 size_t Index = static_cast<size_t>(Ty); |
226 if (Index < IceType_NUM) | 235 if (Index < IceType_NUM) |
227 return TypeAttributes[Index].DisplayString; | 236 return TypeAttributes[Index].DisplayString; |
228 llvm_unreachable("Invalid type for typeString"); | 237 llvm_unreachable("Invalid type for typeString"); |
229 return "???"; | 238 return "???"; |
230 } | 239 } |
231 | 240 |
232 } // end of namespace Ice | 241 } // end of namespace Ice |
OLD | NEW |