Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: src/IceTypes.cpp

Issue 543793003: Add icmp and fcmp instructions to Subzero bitcode reader. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nit. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceTypes.h ('k') | src/IceTypes.def » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) _props_table_tag_##tag, 36 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, CompareResult) \
37 _props_table_tag_##tag,
37 ICETYPE_PROPS_TABLE 38 ICETYPE_PROPS_TABLE
38 #undef X 39 #undef X
39 _enum_props_table_tag_Names 40 _enum_props_table_tag_Names
40 }; 41 };
41 // 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.
42 #define X(tag, size, align, elts, elty, str) \ 43 #define X(tag, size, align, elts, elty, str) \
43 STATIC_ASSERT((unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag); 44 STATIC_ASSERT((unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag);
44 ICETYPE_TABLE; 45 ICETYPE_TABLE;
45 #undef X 46 #undef X
46 // Assert that tags in ICETYPE_PROPS_TABLE is in ICETYPE_TABLE. 47 // Assert that tags in ICETYPE_PROPS_TABLE is in ICETYPE_TABLE.
47 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith) \ 48 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, CompareResult) \
48 STATIC_ASSERT((unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag); 49 STATIC_ASSERT((unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag);
49 ICETYPE_PROPS_TABLE; 50 ICETYPE_PROPS_TABLE;
50 #undef X 51 #undef X
51 52
52 // Show vector definitions match in ICETYPE_TABLE and 53 // Show vector definitions match in ICETYPE_TABLE and
53 // ICETYPE_PROPS_TABLE. 54 // ICETYPE_PROPS_TABLE.
54 55
55 // Define constants for each element size in ICETYPE_TABLE. 56 // Define constants for each element size in ICETYPE_TABLE.
56 enum { 57 enum {
57 #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,
58 ICETYPE_TABLE 59 ICETYPE_TABLE
59 #undef X 60 #undef X
60 _enum_table_elts_Elements = 0 61 _enum_table_elts_Elements = 0
61 }; 62 };
62 // Define constants for boolean flag if vector in ICETYPE_PROPS_TABLE. 63 // Define constants for boolean flag if vector in ICETYPE_PROPS_TABLE.
63 enum { 64 enum {
64 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith) \ 65 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, CompareResult) \
65 _props_table_IsVec_##tag = IsVec, 66 _props_table_IsVec_##tag = IsVec,
66 ICETYPE_PROPS_TABLE 67 ICETYPE_PROPS_TABLE
67 #undef X 68 #undef X
68 }; 69 };
69 // Verify that the number of vector elements is consistent with IsVec. 70 // Verify that the number of vector elements is consistent with IsVec.
70 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith) \ 71 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, CompareResult) \
71 STATIC_ASSERT((_table_elts_##tag > 1) == _props_table_IsVec_##tag); 72 STATIC_ASSERT((_table_elts_##tag > 1) == _props_table_IsVec_##tag);
72 ICETYPE_PROPS_TABLE; 73 ICETYPE_PROPS_TABLE;
73 #undef X 74 #undef X
74 } 75 }
75 76
76 struct TypeAttributeFields { 77 struct TypeAttributeFields {
77 size_t TypeWidthInBytes; 78 size_t TypeWidthInBytes;
78 size_t TypeAlignInBytes; 79 size_t TypeAlignInBytes;
79 size_t TypeNumElements; 80 size_t TypeNumElements;
80 Type TypeElementType; 81 Type TypeElementType;
(...skipping 10 matching lines...) Expand all
91 92
92 struct TypePropertyFields { 93 struct TypePropertyFields {
93 bool TypeIsVectorType; 94 bool TypeIsVectorType;
94 bool TypeIsIntegerType; 95 bool TypeIsIntegerType;
95 bool TypeIsScalarIntegerType; 96 bool TypeIsScalarIntegerType;
96 bool TypeIsVectorIntegerType; 97 bool TypeIsVectorIntegerType;
97 bool TypeIsIntegerArithmeticType; 98 bool TypeIsIntegerArithmeticType;
98 bool TypeIsFloatingType; 99 bool TypeIsFloatingType;
99 bool TypeIsScalarFloatingType; 100 bool TypeIsScalarFloatingType;
100 bool TypeIsVectorFloatingType; 101 bool TypeIsVectorFloatingType;
102 Type CompareResultType;
101 }; 103 };
102 104
103 const TypePropertyFields TypePropertiesTable[] = { 105 const TypePropertyFields TypePropertiesTable[] = {
104 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith) \ 106 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, CompareResult) \
105 { \ 107 { \
106 IsVec, IsInt, IsInt && !IsVec, IsInt && IsVec, IsIntArith, IsFloat, \ 108 IsVec, IsInt, IsInt && !IsVec, IsInt && IsVec, IsIntArith, IsFloat, \
107 IsFloat && !IsVec, IsFloat && IsVec \ 109 IsFloat && !IsVec, IsFloat && IsVec, CompareResult \
108 } \ 110 } \
109 , 111 ,
110 ICETYPE_PROPS_TABLE 112 ICETYPE_PROPS_TABLE
111 #undef X 113 #undef X
112 }; 114 };
113 115
114 } // end anonymous namespace 116 } // end anonymous namespace
115 117
116 size_t typeWidthInBytes(Type Ty) { 118 size_t typeWidthInBytes(Type Ty) {
117 size_t Index = static_cast<size_t>(Ty); 119 size_t Index = static_cast<size_t>(Ty);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 204 }
203 205
204 bool isVectorFloatingType(Type Ty) { 206 bool isVectorFloatingType(Type Ty) {
205 size_t Index = static_cast<size_t>(Ty); 207 size_t Index = static_cast<size_t>(Ty);
206 if (Index < IceType_NUM) 208 if (Index < IceType_NUM)
207 return TypePropertiesTable[Index].TypeIsVectorFloatingType; 209 return TypePropertiesTable[Index].TypeIsVectorFloatingType;
208 llvm_unreachable("Invalid type for isVectorFloatingType()"); 210 llvm_unreachable("Invalid type for isVectorFloatingType()");
209 return false; 211 return false;
210 } 212 }
211 213
214 Type getCompareResultType(Type Ty) {
215 size_t Index = static_cast<size_t>(Ty);
216 if (Index < IceType_NUM)
217 return TypePropertiesTable[Index].CompareResultType;
218 llvm_unreachable("Invalid type for getCompareResultType");
219 return IceType_void;
220 }
221
212 // ======================== Dump routines ======================== // 222 // ======================== Dump routines ======================== //
213 223
214 const char *typeString(Type Ty) { 224 const char *typeString(Type Ty) {
215 size_t Index = static_cast<size_t>(Ty); 225 size_t Index = static_cast<size_t>(Ty);
216 if (Index < IceType_NUM) 226 if (Index < IceType_NUM)
217 return TypeAttributes[Index].DisplayString; 227 return TypeAttributes[Index].DisplayString;
218 llvm_unreachable("Invalid type for typeString"); 228 llvm_unreachable("Invalid type for typeString");
219 return "???"; 229 return "???";
220 } 230 }
221 231
222 } // end of namespace Ice 232 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTypes.h ('k') | src/IceTypes.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698