Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 1 | //===- subzero/src/IceTypes.cpp - Primitive type properties ---------------===// |
| 2 | // |
| 3 | // The Subzero Code Generator |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 9 | /// |
| 10 | /// \file |
Jim Stichnoth | 92a6e5b | 2015-12-02 16:52:44 -0800 | [diff] [blame] | 11 | /// \brief Defines a few attributes of Subzero primitive types. |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 12 | /// |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 15 | #include "IceTypes.h" |
| 16 | |
John Porto | 67f8de9 | 2015-06-25 10:14:17 -0700 | [diff] [blame] | 17 | #include "IceDefs.h" |
Nicolas Capens | 32f9cce | 2016-10-19 01:24:27 -0400 | [diff] [blame] | 18 | #include "IceTargetLowering.h" |
John Porto | 67f8de9 | 2015-06-25 10:14:17 -0700 | [diff] [blame] | 19 | |
Nicolas Capens | dbd600d | 2016-09-01 16:53:49 -0400 | [diff] [blame] | 20 | #include "llvm/Support/ErrorHandling.h" |
| 21 | |
John Porto | 36d6aa6 | 2016-02-26 07:19:59 -0800 | [diff] [blame] | 22 | #include <climits> |
| 23 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 24 | namespace Ice { |
| 25 | |
| 26 | namespace { |
| 27 | |
Karl Schimpf | b262c5e | 2014-10-27 14:41:57 -0700 | [diff] [blame] | 28 | const char *TargetArchName[] = { |
Jan Voung | 08c3bcd | 2014-12-01 17:55:16 -0800 | [diff] [blame] | 29 | #define X(tag, str, is_elf64, e_machine, e_flags) str, |
| 30 | TARGETARCH_TABLE |
Karl Schimpf | b262c5e | 2014-10-27 14:41:57 -0700 | [diff] [blame] | 31 | #undef X |
| 32 | }; |
| 33 | |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 34 | // Show tags match between ICETYPE_TABLE and ICETYPE_PROPS_TABLE. |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 35 | |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 36 | // Define a temporary set of enum values based on ICETYPE_TABLE |
| 37 | enum { |
Jim Stichnoth | 2544d4d | 2016-01-22 13:07:46 -0800 | [diff] [blame] | 38 | #define X(tag, sizeLog2, align, elts, elty, str, rcstr) _table_tag_##tag, |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 39 | ICETYPE_TABLE |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 40 | #undef X |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 41 | _enum_table_tag_Names |
| 42 | }; |
| 43 | // Define a temporary set of enum values based on ICETYPE_PROPS_TABLE |
| 44 | enum { |
Karl Schimpf | ff94f59 | 2015-09-18 10:37:44 -0700 | [diff] [blame] | 45 | #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, IsParam, \ |
| 46 | CompareResult) \ |
Karl Schimpf | 41689df | 2014-09-10 14:36:07 -0700 | [diff] [blame] | 47 | _props_table_tag_##tag, |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 48 | ICETYPE_PROPS_TABLE |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 49 | #undef X |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 50 | _enum_props_table_tag_Names |
| 51 | }; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 52 | // Assert that tags in ICETYPE_TABLE are also in ICETYPE_PROPS_TABLE. |
Jim Stichnoth | 2544d4d | 2016-01-22 13:07:46 -0800 | [diff] [blame] | 53 | #define X(tag, sizeLog2, align, elts, elty, str, rcstr) \ |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 54 | static_assert( \ |
| 55 | (unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag, \ |
| 56 | "Inconsistency between ICETYPE_PROPS_TABLE and ICETYPE_TABLE"); |
JF Bastien | 8427ea2 | 2015-01-27 12:56:49 -0800 | [diff] [blame] | 57 | ICETYPE_TABLE |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 58 | #undef X |
| 59 | // Assert that tags in ICETYPE_PROPS_TABLE is in ICETYPE_TABLE. |
Karl Schimpf | ff94f59 | 2015-09-18 10:37:44 -0700 | [diff] [blame] | 60 | #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, IsParam, \ |
| 61 | CompareResult) \ |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 62 | static_assert( \ |
| 63 | (unsigned)_table_tag_##tag == (unsigned)_props_table_tag_##tag, \ |
| 64 | "Inconsistency between ICETYPE_PROPS_TABLE and ICETYPE_TABLE"); |
| 65 | ICETYPE_PROPS_TABLE |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 66 | #undef X |
| 67 | |
Andrew Scull | 57e1268 | 2015-09-16 11:30:19 -0700 | [diff] [blame] | 68 | // Show vector definitions match in ICETYPE_TABLE and ICETYPE_PROPS_TABLE. |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 69 | |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 70 | // Define constants for each element size in ICETYPE_TABLE. |
| 71 | enum { |
Jim Stichnoth | 2544d4d | 2016-01-22 13:07:46 -0800 | [diff] [blame] | 72 | #define X(tag, sizeLog2, align, elts, elty, str, rcstr) \ |
| 73 | _table_elts_##tag = elts, |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 74 | ICETYPE_TABLE |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 75 | #undef X |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 76 | _enum_table_elts_Elements = 0 |
| 77 | }; |
| 78 | // Define constants for boolean flag if vector in ICETYPE_PROPS_TABLE. |
| 79 | enum { |
Karl Schimpf | ff94f59 | 2015-09-18 10:37:44 -0700 | [diff] [blame] | 80 | #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, IsParam, \ |
| 81 | CompareResult) \ |
Karl Schimpf | 41689df | 2014-09-10 14:36:07 -0700 | [diff] [blame] | 82 | _props_table_IsVec_##tag = IsVec, |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 83 | ICETYPE_PROPS_TABLE |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 84 | #undef X |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 85 | }; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 86 | // Verify that the number of vector elements is consistent with IsVec. |
Karl Schimpf | ff94f59 | 2015-09-18 10:37:44 -0700 | [diff] [blame] | 87 | #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsLoadStore, IsParam, \ |
| 88 | CompareResult) \ |
Jim Stichnoth | fac5517 | 2014-10-01 13:06:21 -0700 | [diff] [blame] | 89 | static_assert((_table_elts_##tag > 1) == _props_table_IsVec_##tag, \ |
| 90 | "Inconsistent vector specification in ICETYPE_PROPS_TABLE"); |
JF Bastien | 8427ea2 | 2015-01-27 12:56:49 -0800 | [diff] [blame] | 91 | ICETYPE_PROPS_TABLE |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 92 | #undef X |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 93 | |
| 94 | struct TypeAttributeFields { |
Andrew Scull | 87f80c1 | 2015-07-20 10:19:16 -0700 | [diff] [blame] | 95 | int8_t TypeWidthInBytesLog2; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 96 | size_t TypeAlignInBytes; |
Matt Wala | 928f129 | 2014-07-07 16:50:46 -0700 | [diff] [blame] | 97 | size_t TypeNumElements; |
| 98 | Type TypeElementType; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 99 | const char *DisplayString; |
Jim Stichnoth | 2544d4d | 2016-01-22 13:07:46 -0800 | [diff] [blame] | 100 | const char *RegClassString; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | const struct TypeAttributeFields TypeAttributes[] = { |
Jim Stichnoth | 2544d4d | 2016-01-22 13:07:46 -0800 | [diff] [blame] | 104 | #define X(tag, sizeLog2, align, elts, elty, str, rcstr) \ |
| 105 | { sizeLog2, align, elts, IceType_##elty, str, rcstr } \ |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 106 | , |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 107 | ICETYPE_TABLE |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 108 | #undef X |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 109 | }; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 110 | |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 111 | struct TypePropertyFields { |
| 112 | bool TypeIsVectorType; |
| 113 | bool TypeIsIntegerType; |
| 114 | bool TypeIsScalarIntegerType; |
| 115 | bool TypeIsVectorIntegerType; |
| 116 | bool TypeIsIntegerArithmeticType; |
| 117 | bool TypeIsFloatingType; |
| 118 | bool TypeIsScalarFloatingType; |
| 119 | bool TypeIsVectorFloatingType; |
Nicolas Capens | e965530 | 2017-02-13 10:21:20 -0500 | [diff] [blame] | 120 | bool TypeIsBooleanType; |
Karl Schimpf | ff94f59 | 2015-09-18 10:37:44 -0700 | [diff] [blame] | 121 | bool TypeIsCallParameterType; |
Karl Schimpf | 83f9f0c | 2014-09-05 08:30:55 -0700 | [diff] [blame] | 122 | Type CompareResultType; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 123 | }; |
| 124 | |
| 125 | const TypePropertyFields TypePropertiesTable[] = { |
Nicolas Capens | e965530 | 2017-02-13 10:21:20 -0500 | [diff] [blame] | 126 | #define X(tag, IsVec, IsInt, IsFloat, IsIntArith, IsBoolean, IsParam, \ |
Karl Schimpf | ff94f59 | 2015-09-18 10:37:44 -0700 | [diff] [blame] | 127 | CompareResult) \ |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 128 | { \ |
Mircea Trofin | 59c6f5a | 2015-04-06 16:06:47 -0700 | [diff] [blame] | 129 | IsVec, IsInt, IsInt & !IsVec, IsInt & IsVec, IsIntArith, IsFloat, \ |
Nicolas Capens | e965530 | 2017-02-13 10:21:20 -0500 | [diff] [blame] | 130 | IsFloat & !IsVec, IsFloat & IsVec, IsBoolean, IsParam, \ |
Jim Stichnoth | c59288b | 2015-11-09 11:38:40 -0800 | [diff] [blame] | 131 | IceType_##CompareResult \ |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 132 | } \ |
| 133 | , |
Jim Stichnoth | dd842db | 2015-01-27 12:53:53 -0800 | [diff] [blame] | 134 | ICETYPE_PROPS_TABLE |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 135 | #undef X |
| 136 | }; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 137 | |
| 138 | } // end anonymous namespace |
| 139 | |
Karl Schimpf | b262c5e | 2014-10-27 14:41:57 -0700 | [diff] [blame] | 140 | const char *targetArchString(const TargetArch Arch) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 141 | if (Arch < TargetArch_NUM) |
| 142 | return TargetArchName[Arch]; |
Karl Schimpf | b262c5e | 2014-10-27 14:41:57 -0700 | [diff] [blame] | 143 | llvm_unreachable("Invalid target arch for targetArchString"); |
| 144 | return "???"; |
| 145 | } |
| 146 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 147 | size_t typeWidthInBytes(Type Ty) { |
Andrew Scull | 87f80c1 | 2015-07-20 10:19:16 -0700 | [diff] [blame] | 148 | int8_t Shift = typeWidthInBytesLog2(Ty); |
| 149 | return (Shift < 0) ? 0 : 1 << Shift; |
| 150 | } |
| 151 | |
| 152 | int8_t typeWidthInBytesLog2(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 153 | if (Ty < IceType_NUM) |
| 154 | return TypeAttributes[Ty].TypeWidthInBytesLog2; |
Andrew Scull | 87f80c1 | 2015-07-20 10:19:16 -0700 | [diff] [blame] | 155 | llvm_unreachable("Invalid type for typeWidthInBytesLog2()"); |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 156 | return 0; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | size_t typeAlignInBytes(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 160 | if (Ty < IceType_NUM) |
| 161 | return TypeAttributes[Ty].TypeAlignInBytes; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 162 | llvm_unreachable("Invalid type for typeAlignInBytes()"); |
| 163 | return 1; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 164 | } |
| 165 | |
Matt Wala | 928f129 | 2014-07-07 16:50:46 -0700 | [diff] [blame] | 166 | size_t typeNumElements(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 167 | if (Ty < IceType_NUM) |
| 168 | return TypeAttributes[Ty].TypeNumElements; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 169 | llvm_unreachable("Invalid type for typeNumElements()"); |
| 170 | return 1; |
Matt Wala | 928f129 | 2014-07-07 16:50:46 -0700 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | Type typeElementType(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 174 | if (Ty < IceType_NUM) |
| 175 | return TypeAttributes[Ty].TypeElementType; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 176 | llvm_unreachable("Invalid type for typeElementType()"); |
| 177 | return IceType_void; |
Matt Wala | 928f129 | 2014-07-07 16:50:46 -0700 | [diff] [blame] | 178 | } |
| 179 | |
Nicolas Capens | 32f9cce | 2016-10-19 01:24:27 -0400 | [diff] [blame] | 180 | Type getPointerType() { return TargetLowering::getPointerType(); } |
| 181 | |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 182 | bool isVectorType(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 183 | if (Ty < IceType_NUM) |
| 184 | return TypePropertiesTable[Ty].TypeIsVectorType; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 185 | llvm_unreachable("Invalid type for isVectorType()"); |
| 186 | return false; |
| 187 | } |
| 188 | |
Nicolas Capens | e965530 | 2017-02-13 10:21:20 -0500 | [diff] [blame] | 189 | bool isBooleanType(Type Ty) { |
| 190 | if (Ty < IceType_NUM) |
| 191 | return TypePropertiesTable[Ty].TypeIsBooleanType; |
| 192 | llvm_unreachable("Invalid type for isBooleanType()"); |
| 193 | return false; |
| 194 | } |
| 195 | |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 196 | bool isIntegerType(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 197 | if (Ty < IceType_NUM) |
| 198 | return TypePropertiesTable[Ty].TypeIsIntegerType; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 199 | llvm_unreachable("Invalid type for isIntegerType()"); |
| 200 | return false; |
| 201 | } |
| 202 | |
| 203 | bool isScalarIntegerType(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 204 | if (Ty < IceType_NUM) |
| 205 | return TypePropertiesTable[Ty].TypeIsScalarIntegerType; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 206 | llvm_unreachable("Invalid type for isScalIntegerType()"); |
| 207 | return false; |
| 208 | } |
| 209 | |
| 210 | bool isVectorIntegerType(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 211 | if (Ty < IceType_NUM) |
| 212 | return TypePropertiesTable[Ty].TypeIsVectorIntegerType; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 213 | llvm_unreachable("Invalid type for isVectorIntegerType()"); |
| 214 | return false; |
| 215 | } |
| 216 | |
| 217 | bool isIntegerArithmeticType(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 218 | if (Ty < IceType_NUM) |
| 219 | return TypePropertiesTable[Ty].TypeIsIntegerArithmeticType; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 220 | llvm_unreachable("Invalid type for isIntegerArithmeticType()"); |
| 221 | return false; |
| 222 | } |
| 223 | |
| 224 | bool isFloatingType(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 225 | if (Ty < IceType_NUM) |
| 226 | return TypePropertiesTable[Ty].TypeIsFloatingType; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 227 | llvm_unreachable("Invalid type for isFloatingType()"); |
| 228 | return false; |
| 229 | } |
| 230 | |
| 231 | bool isScalarFloatingType(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 232 | if (Ty < IceType_NUM) |
| 233 | return TypePropertiesTable[Ty].TypeIsScalarFloatingType; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 234 | llvm_unreachable("Invalid type for isScalarFloatingType()"); |
| 235 | return false; |
| 236 | } |
| 237 | |
| 238 | bool isVectorFloatingType(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 239 | if (Ty < IceType_NUM) |
| 240 | return TypePropertiesTable[Ty].TypeIsVectorFloatingType; |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 241 | llvm_unreachable("Invalid type for isVectorFloatingType()"); |
| 242 | return false; |
| 243 | } |
| 244 | |
Karl Schimpf | 41689df | 2014-09-10 14:36:07 -0700 | [diff] [blame] | 245 | bool isLoadStoreType(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 246 | if (Ty < IceType_NUM) |
Nicolas Capens | e965530 | 2017-02-13 10:21:20 -0500 | [diff] [blame] | 247 | return Ty != IceType_void && !isBooleanType(Ty); |
Karl Schimpf | 41689df | 2014-09-10 14:36:07 -0700 | [diff] [blame] | 248 | llvm_unreachable("Invalid type for isLoadStoreType()"); |
| 249 | return false; |
| 250 | } |
| 251 | |
Karl Schimpf | ff94f59 | 2015-09-18 10:37:44 -0700 | [diff] [blame] | 252 | bool isCallParameterType(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 253 | if (Ty < IceType_NUM) |
| 254 | return TypePropertiesTable[Ty].TypeIsCallParameterType; |
Karl Schimpf | ff94f59 | 2015-09-18 10:37:44 -0700 | [diff] [blame] | 255 | llvm_unreachable("Invalid type for isCallParameterType()"); |
| 256 | return false; |
| 257 | } |
| 258 | |
Karl Schimpf | 83f9f0c | 2014-09-05 08:30:55 -0700 | [diff] [blame] | 259 | Type getCompareResultType(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 260 | if (Ty < IceType_NUM) |
| 261 | return TypePropertiesTable[Ty].CompareResultType; |
Karl Schimpf | 83f9f0c | 2014-09-05 08:30:55 -0700 | [diff] [blame] | 262 | llvm_unreachable("Invalid type for getCompareResultType"); |
| 263 | return IceType_void; |
| 264 | } |
| 265 | |
Karl Schimpf | d1a971a | 2014-09-17 15:38:17 -0700 | [diff] [blame] | 266 | SizeT getScalarIntBitWidth(Type Ty) { |
| 267 | assert(isScalarIntegerType(Ty)); |
Karl Schimpf | 645aa1a | 2014-10-08 09:05:53 -0700 | [diff] [blame] | 268 | if (Ty == IceType_i1) |
Karl Schimpf | d1a971a | 2014-09-17 15:38:17 -0700 | [diff] [blame] | 269 | return 1; |
| 270 | return typeWidthInBytes(Ty) * CHAR_BIT; |
| 271 | } |
| 272 | |
Karl Schimpf | d6064a1 | 2014-08-27 15:34:58 -0700 | [diff] [blame] | 273 | // ======================== Dump routines ======================== // |
| 274 | |
Jim Stichnoth | 78282f6 | 2014-07-27 23:14:00 -0700 | [diff] [blame] | 275 | const char *typeString(Type Ty) { |
Jim Stichnoth | 2d6c826 | 2016-02-07 09:50:27 -0800 | [diff] [blame] | 276 | if (Ty < IceType_NUM) |
| 277 | return TypeAttributes[Ty].DisplayString; |
Jim Stichnoth | 78282f6 | 2014-07-27 23:14:00 -0700 | [diff] [blame] | 278 | llvm_unreachable("Invalid type for typeString"); |
| 279 | return "???"; |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 280 | } |
| 281 | |
Jim Stichnoth | 2544d4d | 2016-01-22 13:07:46 -0800 | [diff] [blame] | 282 | const char *regClassString(RegClass C) { |
| 283 | if (static_cast<size_t>(C) < IceType_NUM) |
| 284 | return TypeAttributes[C].RegClassString; |
| 285 | llvm_unreachable("Invalid type for regClassString"); |
| 286 | return "???"; |
| 287 | } |
| 288 | |
Karl Schimpf | 645aa1a | 2014-10-08 09:05:53 -0700 | [diff] [blame] | 289 | void FuncSigType::dump(Ostream &Stream) const { |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 290 | if (!BuildDefs::dump()) |
Karl Schimpf | b6c96af | 2014-11-17 10:58:39 -0800 | [diff] [blame] | 291 | return; |
Karl Schimpf | 645aa1a | 2014-10-08 09:05:53 -0700 | [diff] [blame] | 292 | Stream << ReturnType << " ("; |
| 293 | bool IsFirst = true; |
| 294 | for (const Type ArgTy : ArgList) { |
| 295 | if (IsFirst) { |
| 296 | IsFirst = false; |
| 297 | } else { |
| 298 | Stream << ", "; |
| 299 | } |
| 300 | Stream << ArgTy; |
| 301 | } |
| 302 | Stream << ")"; |
| 303 | } |
| 304 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 305 | } // end of namespace Ice |