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

Side by Side Diff: src/IceTypes.cpp

Issue 1234803007: Introduction of improved switch lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: CL feedback Created 5 years, 5 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
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 12 matching lines...) Expand all
23 const char *TargetArchName[] = { 23 const char *TargetArchName[] = {
24 #define X(tag, str, is_elf64, e_machine, e_flags) str, 24 #define X(tag, str, is_elf64, e_machine, e_flags) str,
25 TARGETARCH_TABLE 25 TARGETARCH_TABLE
26 #undef X 26 #undef X
27 }; 27 };
28 28
29 // Show tags match between ICETYPE_TABLE and ICETYPE_PROPS_TABLE. 29 // Show tags match between ICETYPE_TABLE and ICETYPE_PROPS_TABLE.
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, size, align, elts, elty, str) _table_tag_##tag, 33 #define X(tag, size, 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, CompareResult) \
41 _props_table_tag_##tag, 41 _props_table_tag_##tag,
42 ICETYPE_PROPS_TABLE 42 ICETYPE_PROPS_TABLE
43 #undef X 43 #undef X
44 _enum_props_table_tag_Names 44 _enum_props_table_tag_Names
45 }; 45 };
46 // Assert that tags in ICETYPE_TABLE are also in ICETYPE_PROPS_TABLE. 46 // Assert that tags in ICETYPE_TABLE are also in ICETYPE_PROPS_TABLE.
47 #define X(tag, size, align, elts, elty, str) \ 47 #define X(tag, size, sizeLog2, align, elts, elty, str) \
48 static_assert( \ 48 static_assert( \
49 (unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag, \ 49 (unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag, \
50 "Inconsistency between ICETYPE_PROPS_TABLE and ICETYPE_TABLE"); 50 "Inconsistency between ICETYPE_PROPS_TABLE and ICETYPE_TABLE");
51 ICETYPE_TABLE 51 ICETYPE_TABLE
52 #undef X 52 #undef X
53 // Assert that tags in ICETYPE_PROPS_TABLE is in ICETYPE_TABLE. 53 // Assert that tags in ICETYPE_PROPS_TABLE is in ICETYPE_TABLE.
54 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ 54 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \
55 static_assert( \ 55 static_assert( \
56 (unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag, \ 56 (unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag, \
57 "Inconsistency between ICETYPE_PROPS_TABLE and ICETYPE_TABLE"); 57 "Inconsistency between ICETYPE_PROPS_TABLE and ICETYPE_TABLE");
58 ICETYPE_PROPS_TABLE 58 ICETYPE_PROPS_TABLE
59 #undef X 59 #undef X
60 60
61 // Show vector definitions match in ICETYPE_TABLE and 61 // Show vector definitions match in ICETYPE_TABLE and
62 // ICETYPE_PROPS_TABLE. 62 // ICETYPE_PROPS_TABLE.
63 63
64 // Define constants for each element size in ICETYPE_TABLE. 64 // Define constants for each element size in ICETYPE_TABLE.
65 enum { 65 enum {
66 #define X(tag, size, align, elts, elty, str) _table_elts_##tag = elts, 66 #define X(tag, size, sizeLog2, align, elts, elty, str) _table_elts_##tag = elts,
67 ICETYPE_TABLE 67 ICETYPE_TABLE
68 #undef X 68 #undef X
69 _enum_table_elts_Elements = 0 69 _enum_table_elts_Elements = 0
70 }; 70 };
71 // Define constants for boolean flag if vector in ICETYPE_PROPS_TABLE. 71 // Define constants for boolean flag if vector in ICETYPE_PROPS_TABLE.
72 enum { 72 enum {
73 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ 73 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \
74 _props_table_IsVec_##tag = IsVec, 74 _props_table_IsVec_##tag = IsVec,
75 ICETYPE_PROPS_TABLE 75 ICETYPE_PROPS_TABLE
76 #undef X 76 #undef X
77 }; 77 };
78 // Verify that the number of vector elements is consistent with IsVec. 78 // Verify that the number of vector elements is consistent with IsVec.
79 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \ 79 #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, CompareResult) \
80 static_assert((_table_elts_##tag > 1) == _props_table_IsVec_##tag, \ 80 static_assert((_table_elts_##tag > 1) == _props_table_IsVec_##tag, \
81 "Inconsistent vector specification in ICETYPE_PROPS_TABLE"); 81 "Inconsistent vector specification in ICETYPE_PROPS_TABLE");
82 ICETYPE_PROPS_TABLE 82 ICETYPE_PROPS_TABLE
83 #undef X 83 #undef X
84 84
85 struct TypeAttributeFields { 85 struct TypeAttributeFields {
86 size_t TypeWidthInBytes; 86 size_t TypeWidthInBytes;
87 size_t TypeWidthInBytesLog2;
87 size_t TypeAlignInBytes; 88 size_t TypeAlignInBytes;
88 size_t TypeNumElements; 89 size_t TypeNumElements;
89 Type TypeElementType; 90 Type TypeElementType;
90 const char *DisplayString; 91 const char *DisplayString;
91 }; 92 };
92 93
93 const struct TypeAttributeFields TypeAttributes[] = { 94 const struct TypeAttributeFields TypeAttributes[] = {
94 #define X(tag, size, align, elts, elty, str) \ 95 #define X(tag, size, sizeLog2, align, elts, elty, str) \
95 { size, align, elts, elty, str } \ 96 { size, sizeLog2, align, elts, elty, str } \
96 , 97 ,
97 ICETYPE_TABLE 98 ICETYPE_TABLE
98 #undef X 99 #undef X
99 }; 100 };
100 101
101 struct TypePropertyFields { 102 struct TypePropertyFields {
102 bool TypeIsVectorType; 103 bool TypeIsVectorType;
103 bool TypeIsIntegerType; 104 bool TypeIsIntegerType;
104 bool TypeIsScalarIntegerType; 105 bool TypeIsScalarIntegerType;
105 bool TypeIsVectorIntegerType; 106 bool TypeIsVectorIntegerType;
(...skipping 27 matching lines...) Expand all
133 } 134 }
134 135
135 size_t typeWidthInBytes(Type Ty) { 136 size_t typeWidthInBytes(Type Ty) {
136 size_t Index = static_cast<size_t>(Ty); 137 size_t Index = static_cast<size_t>(Ty);
137 if (Index < IceType_NUM) 138 if (Index < IceType_NUM)
138 return TypeAttributes[Index].TypeWidthInBytes; 139 return TypeAttributes[Index].TypeWidthInBytes;
139 llvm_unreachable("Invalid type for typeWidthInBytes()"); 140 llvm_unreachable("Invalid type for typeWidthInBytes()");
140 return 0; 141 return 0;
141 } 142 }
142 143
144 size_t typeWidthInBytesLog2(Type Ty) {
145 size_t Index = static_cast<size_t>(Ty);
146 if (Index < IceType_NUM)
147 return TypeAttributes[Index].TypeWidthInBytesLog2;
148 llvm_unreachable("Invalid type for typeWidthInBytesLog2()");
149 return 0;
150 }
151
143 size_t typeAlignInBytes(Type Ty) { 152 size_t typeAlignInBytes(Type Ty) {
144 size_t Index = static_cast<size_t>(Ty); 153 size_t Index = static_cast<size_t>(Ty);
145 if (Index < IceType_NUM) 154 if (Index < IceType_NUM)
146 return TypeAttributes[Index].TypeAlignInBytes; 155 return TypeAttributes[Index].TypeAlignInBytes;
147 llvm_unreachable("Invalid type for typeAlignInBytes()"); 156 llvm_unreachable("Invalid type for typeAlignInBytes()");
148 return 1; 157 return 1;
149 } 158 }
150 159
151 size_t typeNumElements(Type Ty) { 160 size_t typeNumElements(Type Ty) {
152 size_t Index = static_cast<size_t>(Ty); 161 size_t Index = static_cast<size_t>(Ty);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 IsFirst = false; 280 IsFirst = false;
272 } else { 281 } else {
273 Stream << ", "; 282 Stream << ", ";
274 } 283 }
275 Stream << ArgTy; 284 Stream << ArgTy;
276 } 285 }
277 Stream << ")"; 286 Stream << ")";
278 } 287 }
279 288
280 } // end of namespace Ice 289 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698