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

Side by Side Diff: src/IceTypes.cpp

Issue 618313003: Subzero: Move to C++11 static_assert(). (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 2 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
« src/IceIntrinsics.cpp ('K') | « src/IceTargetLoweringX8632.cpp ('k') | no next file » | 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 23 matching lines...) Expand all
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, IsLoadStore, 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( \
45 (unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag, \
46 "Inconsistency between ICETYPE_PROPS_TABLE and ICETYPE_TABLE");
45 ICETYPE_TABLE; 47 ICETYPE_TABLE;
46 #undef X 48 #undef X
47 // Assert that tags in ICETYPE_PROPS_TABLE is in ICETYPE_TABLE. 49 // Assert that tags in ICETYPE_PROPS_TABLE is in ICETYPE_TABLE.
48 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ 50 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \
49 STATIC_ASSERT((unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag); 51 static_assert( \
52 (unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag, \
53 "Inconsistency between ICETYPE_PROPS_TABLE and ICETYPE_TABLE");
50 ICETYPE_PROPS_TABLE 54 ICETYPE_PROPS_TABLE
51 #undef X 55 #undef X
52 56
53 // Show vector definitions match in ICETYPE_TABLE and 57 // Show vector definitions match in ICETYPE_TABLE and
54 // ICETYPE_PROPS_TABLE. 58 // ICETYPE_PROPS_TABLE.
55 59
56 // Define constants for each element size in ICETYPE_TABLE. 60 // Define constants for each element size in ICETYPE_TABLE.
57 enum { 61 enum {
58 #define X(tag, size, align, elts, elty, str) _table_elts_##tag = elts, 62 #define X(tag, size, align, elts, elty, str) _table_elts_##tag = elts,
59 ICETYPE_TABLE 63 ICETYPE_TABLE
60 #undef X 64 #undef X
61 _enum_table_elts_Elements = 0 65 _enum_table_elts_Elements = 0
62 }; 66 };
63 // Define constants for boolean flag if vector in ICETYPE_PROPS_TABLE. 67 // Define constants for boolean flag if vector in ICETYPE_PROPS_TABLE.
64 enum { 68 enum {
65 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ 69 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \
66 _props_table_IsVec_##tag = IsVec, 70 _props_table_IsVec_##tag = IsVec,
67 ICETYPE_PROPS_TABLE 71 ICETYPE_PROPS_TABLE
68 #undef X 72 #undef X
69 }; 73 };
70 // Verify that the number of vector elements is consistent with IsVec. 74 // Verify that the number of vector elements is consistent with IsVec.
71 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ 75 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \
72 STATIC_ASSERT((_table_elts_##tag > 1) == _props_table_IsVec_##tag); 76 static_assert((_table_elts_##tag > 1) == _props_table_IsVec_##tag, \
77 "Inconsistent vector specification in ICETYPE_PROPS_TABLE");
73 ICETYPE_PROPS_TABLE; 78 ICETYPE_PROPS_TABLE;
74 #undef X 79 #undef X
75 } 80 }
76 81
77 struct TypeAttributeFields { 82 struct TypeAttributeFields {
78 size_t TypeWidthInBytes; 83 size_t TypeWidthInBytes;
79 size_t TypeAlignInBytes; 84 size_t TypeAlignInBytes;
80 size_t TypeNumElements; 85 size_t TypeNumElements;
81 Type TypeElementType; 86 Type TypeElementType;
82 const char *DisplayString; 87 const char *DisplayString;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 244
240 const char *typeString(Type Ty) { 245 const char *typeString(Type Ty) {
241 size_t Index = static_cast<size_t>(Ty); 246 size_t Index = static_cast<size_t>(Ty);
242 if (Index < IceType_NUM) 247 if (Index < IceType_NUM)
243 return TypeAttributes[Index].DisplayString; 248 return TypeAttributes[Index].DisplayString;
244 llvm_unreachable("Invalid type for typeString"); 249 llvm_unreachable("Invalid type for typeString");
245 return "???"; 250 return "???";
246 } 251 }
247 252
248 } // end of namespace Ice 253 } // end of namespace Ice
OLDNEW
« src/IceIntrinsics.cpp ('K') | « src/IceTargetLoweringX8632.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698