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

Side by Side Diff: src/IceTypes.cpp

Issue 1354673002: Fix call instructions to check parameter types for consistency. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: remove typo Created 5 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 /// \file 10 /// \file
(...skipping 19 matching lines...) Expand all
30 30
31 // Define a temporary set of enum values based on ICETYPE_TABLE 31 // Define a temporary set of enum values based on ICETYPE_TABLE
32 enum { 32 enum {
33 #define X(tag, sizeLog2, align, elts, elty, str) _table_tag_##tag, 33 #define X(tag, sizeLog2, align, elts, elty, str) _table_tag_##tag,
34 ICETYPE_TABLE 34 ICETYPE_TABLE
35 #undef X 35 #undef X
36 _enum_table_tag_Names 36 _enum_table_tag_Names
37 }; 37 };
38 // Define a temporary set of enum values based on ICETYPE_PROPS_TABLE 38 // Define a temporary set of enum values based on ICETYPE_PROPS_TABLE
39 enum { 39 enum {
40 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ 40 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, IsParam, \
41 CompareResult) \
41 _props_table_tag_##tag, 42 _props_table_tag_##tag,
42 ICETYPE_PROPS_TABLE 43 ICETYPE_PROPS_TABLE
43 #undef X 44 #undef X
44 _enum_props_table_tag_Names 45 _enum_props_table_tag_Names
45 }; 46 };
46 // Assert that tags in ICETYPE_TABLE are also in ICETYPE_PROPS_TABLE. 47 // Assert that tags in ICETYPE_TABLE are also in ICETYPE_PROPS_TABLE.
47 #define X(tag, sizeLog2, align, elts, elty, str) \ 48 #define X(tag, sizeLog2, align, elts, elty, str) \
48 static_assert( \ 49 static_assert( \
49 (unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag, \ 50 (unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag, \
50 "Inconsistency between ICETYPE_PROPS_TABLE and ICETYPE_TABLE"); 51 "Inconsistency between ICETYPE_PROPS_TABLE and ICETYPE_TABLE");
51 ICETYPE_TABLE 52 ICETYPE_TABLE
52 #undef X 53 #undef X
53 // Assert that tags in ICETYPE_PROPS_TABLE is in ICETYPE_TABLE. 54 // Assert that tags in ICETYPE_PROPS_TABLE is in ICETYPE_TABLE.
54 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ 55 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, IsParam, \
56 CompareResult) \
55 static_assert( \ 57 static_assert( \
56 (unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag, \ 58 (unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag, \
57 "Inconsistency between ICETYPE_PROPS_TABLE and ICETYPE_TABLE"); 59 "Inconsistency between ICETYPE_PROPS_TABLE and ICETYPE_TABLE");
58 ICETYPE_PROPS_TABLE 60 ICETYPE_PROPS_TABLE
59 #undef X 61 #undef X
60 62
61 // Show vector definitions match in ICETYPE_TABLE and ICETYPE_PROPS_TABLE. 63 // Show vector definitions match in ICETYPE_TABLE and ICETYPE_PROPS_TABLE.
62 64
63 // Define constants for each element size in ICETYPE_TABLE. 65 // Define constants for each element size in ICETYPE_TABLE.
64 enum { 66 enum {
65 #define X(tag, sizeLog2, align, elts, elty, str) _table_elts_##tag = elts, 67 #define X(tag, sizeLog2, align, elts, elty, str) _table_elts_##tag = elts,
66 ICETYPE_TABLE 68 ICETYPE_TABLE
67 #undef X 69 #undef X
68 _enum_table_elts_Elements = 0 70 _enum_table_elts_Elements = 0
69 }; 71 };
70 // Define constants for boolean flag if vector in ICETYPE_PROPS_TABLE. 72 // Define constants for boolean flag if vector in ICETYPE_PROPS_TABLE.
71 enum { 73 enum {
72 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ 74 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, IsParam, \
75 CompareResult) \
73 _props_table_IsVec_##tag = IsVec, 76 _props_table_IsVec_##tag = IsVec,
74 ICETYPE_PROPS_TABLE 77 ICETYPE_PROPS_TABLE
75 #undef X 78 #undef X
76 }; 79 };
77 // Verify that the number of vector elements is consistent with IsVec. 80 // Verify that the number of vector elements is consistent with IsVec.
78 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ 81 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, IsParam, \
82 CompareResult) \
79 static_assert((_table_elts_##tag > 1) == _props_table_IsVec_##tag, \ 83 static_assert((_table_elts_##tag > 1) == _props_table_IsVec_##tag, \
80 "Inconsistent vector specification in ICETYPE_PROPS_TABLE"); 84 "Inconsistent vector specification in ICETYPE_PROPS_TABLE");
81 ICETYPE_PROPS_TABLE 85 ICETYPE_PROPS_TABLE
82 #undef X 86 #undef X
83 87
84 struct TypeAttributeFields { 88 struct TypeAttributeFields {
85 int8_t TypeWidthInBytesLog2; 89 int8_t TypeWidthInBytesLog2;
86 size_t TypeAlignInBytes; 90 size_t TypeAlignInBytes;
87 size_t TypeNumElements; 91 size_t TypeNumElements;
88 Type TypeElementType; 92 Type TypeElementType;
(...skipping 11 matching lines...) Expand all
100 struct TypePropertyFields { 104 struct TypePropertyFields {
101 bool TypeIsVectorType; 105 bool TypeIsVectorType;
102 bool TypeIsIntegerType; 106 bool TypeIsIntegerType;
103 bool TypeIsScalarIntegerType; 107 bool TypeIsScalarIntegerType;
104 bool TypeIsVectorIntegerType; 108 bool TypeIsVectorIntegerType;
105 bool TypeIsIntegerArithmeticType; 109 bool TypeIsIntegerArithmeticType;
106 bool TypeIsFloatingType; 110 bool TypeIsFloatingType;
107 bool TypeIsScalarFloatingType; 111 bool TypeIsScalarFloatingType;
108 bool TypeIsVectorFloatingType; 112 bool TypeIsVectorFloatingType;
109 bool TypeIsLoadStoreType; 113 bool TypeIsLoadStoreType;
114 bool TypeIsCallParameterType;
110 Type CompareResultType; 115 Type CompareResultType;
111 }; 116 };
112 117
113 const TypePropertyFields TypePropertiesTable[] = { 118 const TypePropertyFields TypePropertiesTable[] = {
114 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ 119 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, IsParam, \
120 CompareResult) \
115 { \ 121 { \
116 IsVec, IsInt, IsInt & !IsVec, IsInt & IsVec, IsIntArith, IsFloat, \ 122 IsVec, IsInt, IsInt & !IsVec, IsInt & IsVec, IsIntArith, IsFloat, \
117 IsFloat & !IsVec, IsFloat & IsVec, IsLoadStore, CompareResult \ 123 IsFloat & !IsVec, IsFloat & IsVec, IsLoadStore, IsParam, CompareResult \
118 } \ 124 } \
119 , 125 ,
120 ICETYPE_PROPS_TABLE 126 ICETYPE_PROPS_TABLE
121 #undef X 127 #undef X
122 }; 128 };
123 129
124 } // end anonymous namespace 130 } // end anonymous namespace
125 131
126 const char *targetArchString(const TargetArch Arch) { 132 const char *targetArchString(const TargetArch Arch) {
127 size_t Index = static_cast<size_t>(Arch); 133 size_t Index = static_cast<size_t>(Arch);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 239 }
234 240
235 bool isLoadStoreType(Type Ty) { 241 bool isLoadStoreType(Type Ty) {
236 size_t Index = static_cast<size_t>(Ty); 242 size_t Index = static_cast<size_t>(Ty);
237 if (Index < IceType_NUM) 243 if (Index < IceType_NUM)
238 return TypePropertiesTable[Index].TypeIsLoadStoreType; 244 return TypePropertiesTable[Index].TypeIsLoadStoreType;
239 llvm_unreachable("Invalid type for isLoadStoreType()"); 245 llvm_unreachable("Invalid type for isLoadStoreType()");
240 return false; 246 return false;
241 } 247 }
242 248
249 bool isCallParameterType(Type Ty) {
250 size_t Index = static_cast<size_t>(Ty);
251 if (Index < IceType_NUM)
252 return TypePropertiesTable[Index].TypeIsCallParameterType;
253 llvm_unreachable("Invalid type for isCallParameterType()");
254 return false;
255 }
256
243 Type getCompareResultType(Type Ty) { 257 Type getCompareResultType(Type Ty) {
244 size_t Index = static_cast<size_t>(Ty); 258 size_t Index = static_cast<size_t>(Ty);
245 if (Index < IceType_NUM) 259 if (Index < IceType_NUM)
246 return TypePropertiesTable[Index].CompareResultType; 260 return TypePropertiesTable[Index].CompareResultType;
247 llvm_unreachable("Invalid type for getCompareResultType"); 261 llvm_unreachable("Invalid type for getCompareResultType");
248 return IceType_void; 262 return IceType_void;
249 } 263 }
250 264
251 SizeT getScalarIntBitWidth(Type Ty) { 265 SizeT getScalarIntBitWidth(Type Ty) {
252 assert(isScalarIntegerType(Ty)); 266 assert(isScalarIntegerType(Ty));
(...skipping 22 matching lines...) Expand all
275 IsFirst = false; 289 IsFirst = false;
276 } else { 290 } else {
277 Stream << ", "; 291 Stream << ", ";
278 } 292 }
279 Stream << ArgTy; 293 Stream << ArgTy;
280 } 294 }
281 Stream << ")"; 295 Stream << ")";
282 } 296 }
283 297
284 } // end of namespace Ice 298 } // 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