/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/MachineValueType.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===- CodeGen/MachineValueType.h - Machine-Level types ---------*- C++ -*-===// |
2 | | // |
3 | | // The LLVM Compiler Infrastructure |
4 | | // |
5 | | // This file is distributed under the University of Illinois Open Source |
6 | | // License. See LICENSE.TXT for details. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | // |
10 | | // This file defines the set of machine-level target independent types which |
11 | | // legal values in the code generator use. |
12 | | // |
13 | | //===----------------------------------------------------------------------===// |
14 | | |
15 | | #ifndef LLVM_CODEGEN_MACHINEVALUETYPE_H |
16 | | #define LLVM_CODEGEN_MACHINEVALUETYPE_H |
17 | | |
18 | | #include "llvm/ADT/iterator_range.h" |
19 | | #include "llvm/Support/ErrorHandling.h" |
20 | | #include "llvm/Support/MathExtras.h" |
21 | | #include <cassert> |
22 | | |
23 | | namespace llvm { |
24 | | |
25 | | class Type; |
26 | | |
27 | | /// Machine Value Type. Every type that is supported natively by some |
28 | | /// processor targeted by LLVM occurs here. This means that any legal value |
29 | | /// type can be represented by an MVT. |
30 | 0 | class MVT { Unexecuted instantiation: llvm::MVT::operator=(llvm::MVT const&) Unexecuted instantiation: llvm::MVT::operator=(llvm::MVT&&) |
31 | | public: |
32 | | enum SimpleValueType : uint8_t { |
33 | | // Simple value types that aren't explicitly part of this enumeration |
34 | | // are considered extended value types. |
35 | | INVALID_SIMPLE_VALUE_TYPE = 0, |
36 | | |
37 | | // If you change this numbering, you must change the values in |
38 | | // ValueTypes.td as well! |
39 | | Other = 1, // This is a non-standard value |
40 | | i1 = 2, // This is a 1 bit integer value |
41 | | i8 = 3, // This is an 8 bit integer value |
42 | | i16 = 4, // This is a 16 bit integer value |
43 | | i32 = 5, // This is a 32 bit integer value |
44 | | i64 = 6, // This is a 64 bit integer value |
45 | | i128 = 7, // This is a 128 bit integer value |
46 | | |
47 | | FIRST_INTEGER_VALUETYPE = i1, |
48 | | LAST_INTEGER_VALUETYPE = i128, |
49 | | |
50 | | f16 = 8, // This is a 16 bit floating point value |
51 | | f32 = 9, // This is a 32 bit floating point value |
52 | | f64 = 10, // This is a 64 bit floating point value |
53 | | f80 = 11, // This is a 80 bit floating point value |
54 | | f128 = 12, // This is a 128 bit floating point value |
55 | | ppcf128 = 13, // This is a PPC 128-bit floating point value |
56 | | |
57 | | FIRST_FP_VALUETYPE = f16, |
58 | | LAST_FP_VALUETYPE = ppcf128, |
59 | | |
60 | | v1i1 = 14, // 1 x i1 |
61 | | v2i1 = 15, // 2 x i1 |
62 | | v4i1 = 16, // 4 x i1 |
63 | | v8i1 = 17, // 8 x i1 |
64 | | v16i1 = 18, // 16 x i1 |
65 | | v32i1 = 19, // 32 x i1 |
66 | | v64i1 = 20, // 64 x i1 |
67 | | v128i1 = 21, // 128 x i1 |
68 | | v512i1 = 22, // 512 x i1 |
69 | | v1024i1 = 23, // 1024 x i1 |
70 | | |
71 | | v1i8 = 24, // 1 x i8 |
72 | | v2i8 = 25, // 2 x i8 |
73 | | v4i8 = 26, // 4 x i8 |
74 | | v8i8 = 27, // 8 x i8 |
75 | | v16i8 = 28, // 16 x i8 |
76 | | v32i8 = 29, // 32 x i8 |
77 | | v64i8 = 30, // 64 x i8 |
78 | | v128i8 = 31, //128 x i8 |
79 | | v256i8 = 32, //256 x i8 |
80 | | |
81 | | v1i16 = 33, // 1 x i16 |
82 | | v2i16 = 34, // 2 x i16 |
83 | | v4i16 = 35, // 4 x i16 |
84 | | v8i16 = 36, // 8 x i16 |
85 | | v16i16 = 37, // 16 x i16 |
86 | | v32i16 = 38, // 32 x i16 |
87 | | v64i16 = 39, // 64 x i16 |
88 | | v128i16 = 40, //128 x i16 |
89 | | |
90 | | v1i32 = 41, // 1 x i32 |
91 | | v2i32 = 42, // 2 x i32 |
92 | | v4i32 = 43, // 4 x i32 |
93 | | v8i32 = 44, // 8 x i32 |
94 | | v16i32 = 45, // 16 x i32 |
95 | | v32i32 = 46, // 32 x i32 |
96 | | v64i32 = 47, // 64 x i32 |
97 | | |
98 | | v1i64 = 48, // 1 x i64 |
99 | | v2i64 = 49, // 2 x i64 |
100 | | v4i64 = 50, // 4 x i64 |
101 | | v8i64 = 51, // 8 x i64 |
102 | | v16i64 = 52, // 16 x i64 |
103 | | v32i64 = 53, // 32 x i64 |
104 | | |
105 | | v1i128 = 54, // 1 x i128 |
106 | | |
107 | | // Scalable integer types |
108 | | nxv1i1 = 55, // n x 1 x i1 |
109 | | nxv2i1 = 56, // n x 2 x i1 |
110 | | nxv4i1 = 57, // n x 4 x i1 |
111 | | nxv8i1 = 58, // n x 8 x i1 |
112 | | nxv16i1 = 59, // n x 16 x i1 |
113 | | nxv32i1 = 60, // n x 32 x i1 |
114 | | |
115 | | nxv1i8 = 61, // n x 1 x i8 |
116 | | nxv2i8 = 62, // n x 2 x i8 |
117 | | nxv4i8 = 63, // n x 4 x i8 |
118 | | nxv8i8 = 64, // n x 8 x i8 |
119 | | nxv16i8 = 65, // n x 16 x i8 |
120 | | nxv32i8 = 66, // n x 32 x i8 |
121 | | |
122 | | nxv1i16 = 67, // n x 1 x i16 |
123 | | nxv2i16 = 68, // n x 2 x i16 |
124 | | nxv4i16 = 69, // n x 4 x i16 |
125 | | nxv8i16 = 70, // n x 8 x i16 |
126 | | nxv16i16 = 71, // n x 16 x i16 |
127 | | nxv32i16 = 72, // n x 32 x i16 |
128 | | |
129 | | nxv1i32 = 73, // n x 1 x i32 |
130 | | nxv2i32 = 74, // n x 2 x i32 |
131 | | nxv4i32 = 75, // n x 4 x i32 |
132 | | nxv8i32 = 76, // n x 8 x i32 |
133 | | nxv16i32 = 77, // n x 16 x i32 |
134 | | nxv32i32 = 78, // n x 32 x i32 |
135 | | |
136 | | nxv1i64 = 79, // n x 1 x i64 |
137 | | nxv2i64 = 80, // n x 2 x i64 |
138 | | nxv4i64 = 81, // n x 4 x i64 |
139 | | nxv8i64 = 82, // n x 8 x i64 |
140 | | nxv16i64 = 83, // n x 16 x i64 |
141 | | nxv32i64 = 84, // n x 32 x i64 |
142 | | |
143 | | FIRST_INTEGER_VECTOR_VALUETYPE = v1i1, |
144 | | LAST_INTEGER_VECTOR_VALUETYPE = nxv32i64, |
145 | | |
146 | | FIRST_INTEGER_SCALABLE_VALUETYPE = nxv1i1, |
147 | | LAST_INTEGER_SCALABLE_VALUETYPE = nxv32i64, |
148 | | |
149 | | v2f16 = 85, // 2 x f16 |
150 | | v4f16 = 86, // 4 x f16 |
151 | | v8f16 = 87, // 8 x f16 |
152 | | v1f32 = 88, // 1 x f32 |
153 | | v2f32 = 89, // 2 x f32 |
154 | | v4f32 = 90, // 4 x f32 |
155 | | v8f32 = 91, // 8 x f32 |
156 | | v16f32 = 92, // 16 x f32 |
157 | | v1f64 = 93, // 1 x f64 |
158 | | v2f64 = 94, // 2 x f64 |
159 | | v4f64 = 95, // 4 x f64 |
160 | | v8f64 = 96, // 8 x f64 |
161 | | |
162 | | nxv2f16 = 97, // n x 2 x f16 |
163 | | nxv4f16 = 98, // n x 4 x f16 |
164 | | nxv8f16 = 99, // n x 8 x f16 |
165 | | nxv1f32 = 100, // n x 1 x f32 |
166 | | nxv2f32 = 101, // n x 2 x f32 |
167 | | nxv4f32 = 102, // n x 4 x f32 |
168 | | nxv8f32 = 103, // n x 8 x f32 |
169 | | nxv16f32 = 104, // n x 16 x f32 |
170 | | nxv1f64 = 105, // n x 1 x f64 |
171 | | nxv2f64 = 106, // n x 2 x f64 |
172 | | nxv4f64 = 107, // n x 4 x f64 |
173 | | nxv8f64 = 108, // n x 8 x f64 |
174 | | |
175 | | FIRST_FP_VECTOR_VALUETYPE = v2f16, |
176 | | LAST_FP_VECTOR_VALUETYPE = nxv8f64, |
177 | | |
178 | | FIRST_FP_SCALABLE_VALUETYPE = nxv2f16, |
179 | | LAST_FP_SCALABLE_VALUETYPE = nxv8f64, |
180 | | |
181 | | FIRST_VECTOR_VALUETYPE = v1i1, |
182 | | LAST_VECTOR_VALUETYPE = nxv8f64, |
183 | | |
184 | | x86mmx = 109, // This is an X86 MMX value |
185 | | |
186 | | Glue = 110, // This glues nodes together during pre-RA sched |
187 | | |
188 | | isVoid = 111, // This has no value |
189 | | |
190 | | Untyped = 112, // This value takes a register, but has |
191 | | // unspecified type. The register class |
192 | | // will be determined by the opcode. |
193 | | |
194 | | ExceptRef = 113, // WebAssembly's except_ref type |
195 | | |
196 | | FIRST_VALUETYPE = 1, // This is always the beginning of the list. |
197 | | LAST_VALUETYPE = 114, // This always remains at the end of the list. |
198 | | |
199 | | // This is the current maximum for LAST_VALUETYPE. |
200 | | // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors |
201 | | // This value must be a multiple of 32. |
202 | | MAX_ALLOWED_VALUETYPE = 128, |
203 | | |
204 | | // A value of type llvm::TokenTy |
205 | | token = 248, |
206 | | |
207 | | // This is MDNode or MDString. |
208 | | Metadata = 249, |
209 | | |
210 | | // An int value the size of the pointer of the current |
211 | | // target to any address space. This must only be used internal to |
212 | | // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR. |
213 | | iPTRAny = 250, |
214 | | |
215 | | // A vector with any length and element size. This is used |
216 | | // for intrinsics that have overloadings based on vector types. |
217 | | // This is only for tblgen's consumption! |
218 | | vAny = 251, |
219 | | |
220 | | // Any floating-point or vector floating-point value. This is used |
221 | | // for intrinsics that have overloadings based on floating-point types. |
222 | | // This is only for tblgen's consumption! |
223 | | fAny = 252, |
224 | | |
225 | | // An integer or vector integer value of any bit width. This is |
226 | | // used for intrinsics that have overloadings based on integer bit widths. |
227 | | // This is only for tblgen's consumption! |
228 | | iAny = 253, |
229 | | |
230 | | // An int value the size of the pointer of the current |
231 | | // target. This should only be used internal to tblgen! |
232 | | iPTR = 254, |
233 | | |
234 | | // Any type. This is used for intrinsics that have overloadings. |
235 | | // This is only for tblgen's consumption! |
236 | | Any = 255 |
237 | | }; |
238 | | |
239 | | SimpleValueType SimpleTy = INVALID_SIMPLE_VALUE_TYPE; |
240 | | |
241 | | // A class to represent the number of elements in a vector |
242 | | // |
243 | | // For fixed-length vectors, the total number of elements is equal to 'Min' |
244 | | // For scalable vectors, the total number of elements is a multiple of 'Min' |
245 | | class ElementCount { |
246 | | public: |
247 | | unsigned Min; |
248 | | bool Scalable; |
249 | | |
250 | | ElementCount(unsigned Min, bool Scalable) |
251 | 279k | : Min(Min), Scalable(Scalable) {} |
252 | | |
253 | | ElementCount operator*(unsigned RHS) { |
254 | | return { Min * RHS, Scalable }; |
255 | | } |
256 | | |
257 | | ElementCount& operator*=(unsigned RHS) { |
258 | | Min *= RHS; |
259 | | return *this; |
260 | | } |
261 | | |
262 | 136k | ElementCount operator/(unsigned RHS) { |
263 | 136k | return { Min / RHS, Scalable }; |
264 | 136k | } |
265 | | |
266 | | ElementCount& operator/=(unsigned RHS) { |
267 | | Min /= RHS; |
268 | | return *this; |
269 | | } |
270 | | |
271 | | bool operator==(const ElementCount& RHS) { |
272 | | return Min == RHS.Min && Scalable == RHS.Scalable; |
273 | | } |
274 | | }; |
275 | | |
276 | 54.7M | constexpr MVT() = default; |
277 | 2.59G | constexpr MVT(SimpleValueType SVT) : SimpleTy(SVT) {} |
278 | | |
279 | 2.00k | bool operator>(const MVT& S) const { return SimpleTy > S.SimpleTy; } |
280 | 807k | bool operator<(const MVT& S) const { return SimpleTy < S.SimpleTy; } |
281 | 917M | bool operator==(const MVT& S) const { return SimpleTy == S.SimpleTy; } |
282 | 440M | bool operator!=(const MVT& S) const { return SimpleTy != S.SimpleTy; } |
283 | 4.34k | bool operator>=(const MVT& S) const { return SimpleTy >= S.SimpleTy; } |
284 | 4.72k | bool operator<=(const MVT& S) const { return SimpleTy <= S.SimpleTy; } |
285 | | |
286 | | /// Return true if this is a valid simple valuetype. |
287 | 3.32M | bool isValid() const { |
288 | 3.32M | return (SimpleTy >= MVT::FIRST_VALUETYPE && |
289 | 3.32M | SimpleTy < MVT::LAST_VALUETYPE3.27M ); |
290 | 3.32M | } |
291 | | |
292 | | /// Return true if this is a FP or a vector FP type. |
293 | 7.22M | bool isFloatingPoint() const { |
294 | 7.22M | return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE && |
295 | 7.22M | SimpleTy <= MVT::LAST_FP_VALUETYPE3.64M ) || |
296 | 7.22M | (6.72M SimpleTy >= MVT::FIRST_FP_VECTOR_VALUETYPE6.72M && |
297 | 6.72M | SimpleTy <= MVT::LAST_FP_VECTOR_VALUETYPE1.10M )); |
298 | 7.22M | } |
299 | | |
300 | | /// Return true if this is an integer or a vector integer type. |
301 | 47.1M | bool isInteger() const { |
302 | 47.1M | return ((SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE && |
303 | 47.1M | SimpleTy <= MVT::LAST_INTEGER_VALUETYPE47.1M ) || |
304 | 47.1M | (9.49M SimpleTy >= MVT::FIRST_INTEGER_VECTOR_VALUETYPE9.49M && |
305 | 9.49M | SimpleTy <= MVT::LAST_INTEGER_VECTOR_VALUETYPE8.40M )); |
306 | 47.1M | } |
307 | | |
308 | | /// Return true if this is an integer, not including vectors. |
309 | 5.53M | bool isScalarInteger() const { |
310 | 5.53M | return (SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE && |
311 | 5.53M | SimpleTy <= MVT::LAST_INTEGER_VALUETYPE); |
312 | 5.53M | } |
313 | | |
314 | | /// Return true if this is a vector value type. |
315 | 443M | bool isVector() const { |
316 | 443M | return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE && |
317 | 443M | SimpleTy <= MVT::LAST_VECTOR_VALUETYPE119M ); |
318 | 443M | } |
319 | | |
320 | | /// Return true if this is a vector value type where the |
321 | | /// runtime length is machine dependent |
322 | 6.71M | bool isScalableVector() const { |
323 | 6.71M | return ((SimpleTy >= MVT::FIRST_INTEGER_SCALABLE_VALUETYPE && |
324 | 6.71M | SimpleTy <= MVT::LAST_INTEGER_SCALABLE_VALUETYPE2.70M ) || |
325 | 6.71M | (6.17M SimpleTy >= MVT::FIRST_FP_SCALABLE_VALUETYPE6.17M && |
326 | 6.17M | SimpleTy <= MVT::LAST_FP_SCALABLE_VALUETYPE619k )); |
327 | 6.71M | } |
328 | | |
329 | | /// Return true if this is a 16-bit vector type. |
330 | | bool is16BitVector() const { |
331 | | return (SimpleTy == MVT::v2i8 || SimpleTy == MVT::v1i16 || |
332 | | SimpleTy == MVT::v16i1); |
333 | | } |
334 | | |
335 | | /// Return true if this is a 32-bit vector type. |
336 | 1.40k | bool is32BitVector() const { |
337 | 1.40k | return (SimpleTy == MVT::v32i1 || SimpleTy == MVT::v4i8 || |
338 | 1.40k | SimpleTy == MVT::v2i16 || SimpleTy == MVT::v1i32 || |
339 | 1.40k | SimpleTy == MVT::v2f16 || SimpleTy == MVT::v1f32); |
340 | 1.40k | } |
341 | | |
342 | | /// Return true if this is a 64-bit vector type. |
343 | 14.8k | bool is64BitVector() const { |
344 | 14.8k | return (SimpleTy == MVT::v64i1 || SimpleTy == MVT::v8i8 || |
345 | 14.8k | SimpleTy == MVT::v4i1614.0k || SimpleTy == MVT::v2i3212.7k || |
346 | 14.8k | SimpleTy == MVT::v1i6410.8k || SimpleTy == MVT::v4f1610.5k || |
347 | 14.8k | SimpleTy == MVT::v2f3210.3k || SimpleTy == MVT::v1f6410.3k ); |
348 | 14.8k | } |
349 | | |
350 | | /// Return true if this is a 128-bit vector type. |
351 | 3.10M | bool is128BitVector() const { |
352 | 3.10M | return (SimpleTy == MVT::v128i1 || SimpleTy == MVT::v16i8 || |
353 | 3.10M | SimpleTy == MVT::v8i162.99M || SimpleTy == MVT::v4i322.87M || |
354 | 3.10M | SimpleTy == MVT::v2i642.76M || SimpleTy == MVT::v1i1282.68M || |
355 | 3.10M | SimpleTy == MVT::v8f162.68M || SimpleTy == MVT::v4f322.68M || |
356 | 3.10M | SimpleTy == MVT::v2f642.65M ); |
357 | 3.10M | } |
358 | | |
359 | | /// Return true if this is a 256-bit vector type. |
360 | 2.96M | bool is256BitVector() const { |
361 | 2.96M | return (SimpleTy == MVT::v8f32 || SimpleTy == MVT::v4f642.94M || |
362 | 2.96M | SimpleTy == MVT::v32i82.92M || SimpleTy == MVT::v16i162.88M || |
363 | 2.96M | SimpleTy == MVT::v8i322.82M || SimpleTy == MVT::v4i642.78M ); |
364 | 2.96M | } |
365 | | |
366 | | /// Return true if this is a 512-bit vector type. |
367 | 1.11M | bool is512BitVector() const { |
368 | 1.11M | return (SimpleTy == MVT::v16f32 || SimpleTy == MVT::v8f641.10M || |
369 | 1.11M | SimpleTy == MVT::v512i11.10M || SimpleTy == MVT::v64i81.10M || |
370 | 1.11M | SimpleTy == MVT::v32i161.10M || SimpleTy == MVT::v16i321.09M || |
371 | 1.11M | SimpleTy == MVT::v8i641.09M ); |
372 | 1.11M | } |
373 | | |
374 | | /// Return true if this is a 1024-bit vector type. |
375 | | bool is1024BitVector() const { |
376 | | return (SimpleTy == MVT::v1024i1 || SimpleTy == MVT::v128i8 || |
377 | | SimpleTy == MVT::v64i16 || SimpleTy == MVT::v32i32 || |
378 | | SimpleTy == MVT::v16i64); |
379 | | } |
380 | | |
381 | | /// Return true if this is a 2048-bit vector type. |
382 | | bool is2048BitVector() const { |
383 | | return (SimpleTy == MVT::v256i8 || SimpleTy == MVT::v128i16 || |
384 | | SimpleTy == MVT::v64i32 || SimpleTy == MVT::v32i64); |
385 | | } |
386 | | |
387 | | /// Return true if this is an overloaded type for TableGen. |
388 | | bool isOverloaded() const { |
389 | | return (SimpleTy==MVT::Any || |
390 | | SimpleTy==MVT::iAny || SimpleTy==MVT::fAny || |
391 | | SimpleTy==MVT::vAny || SimpleTy==MVT::iPTRAny); |
392 | | } |
393 | | |
394 | | /// Returns true if the given vector is a power of 2. |
395 | 3.51M | bool isPow2VectorType() const { |
396 | 3.51M | unsigned NElts = getVectorNumElements(); |
397 | 3.51M | return !(NElts & (NElts - 1)); |
398 | 3.51M | } |
399 | | |
400 | | /// Widens the length of the given vector MVT up to the nearest power of 2 |
401 | | /// and returns that type. |
402 | 3.51M | MVT getPow2VectorType() const { |
403 | 3.51M | if (isPow2VectorType()) |
404 | 3.51M | return *this; |
405 | 18.4E | |
406 | 18.4E | unsigned NElts = getVectorNumElements(); |
407 | 18.4E | unsigned Pow2NElts = 1 << Log2_32_Ceil(NElts); |
408 | 18.4E | return MVT::getVectorVT(getVectorElementType(), Pow2NElts); |
409 | 18.4E | } |
410 | | |
411 | | /// If this is a vector, return the element type, otherwise return this. |
412 | 68.3M | MVT getScalarType() const { |
413 | 68.3M | return isVector() ? getVectorElementType()68.0M : *this290k ; |
414 | 68.3M | } |
415 | | |
416 | 424M | MVT getVectorElementType() const { |
417 | 424M | switch (SimpleTy) { |
418 | 424M | default: |
419 | 0 | llvm_unreachable("Not a vector MVT!"); |
420 | 424M | case v1i1: |
421 | 54.4M | case v2i1: |
422 | 54.4M | case v4i1: |
423 | 54.4M | case v8i1: |
424 | 54.4M | case v16i1: |
425 | 54.4M | case v32i1: |
426 | 54.4M | case v64i1: |
427 | 54.4M | case v128i1: |
428 | 54.4M | case v512i1: |
429 | 54.4M | case v1024i1: |
430 | 54.4M | case nxv1i1: |
431 | 54.4M | case nxv2i1: |
432 | 54.4M | case nxv4i1: |
433 | 54.4M | case nxv8i1: |
434 | 54.4M | case nxv16i1: |
435 | 54.4M | case nxv32i1: return i1; |
436 | 59.0M | case v1i8: |
437 | 59.0M | case v2i8: |
438 | 59.0M | case v4i8: |
439 | 59.0M | case v8i8: |
440 | 59.0M | case v16i8: |
441 | 59.0M | case v32i8: |
442 | 59.0M | case v64i8: |
443 | 59.0M | case v128i8: |
444 | 59.0M | case v256i8: |
445 | 59.0M | case nxv1i8: |
446 | 59.0M | case nxv2i8: |
447 | 59.0M | case nxv4i8: |
448 | 59.0M | case nxv8i8: |
449 | 59.0M | case nxv16i8: |
450 | 59.0M | case nxv32i8: return i8; |
451 | 61.2M | case v1i16: |
452 | 61.2M | case v2i16: |
453 | 61.2M | case v4i16: |
454 | 61.2M | case v8i16: |
455 | 61.2M | case v16i16: |
456 | 61.2M | case v32i16: |
457 | 61.2M | case v64i16: |
458 | 61.2M | case v128i16: |
459 | 61.2M | case nxv1i16: |
460 | 61.2M | case nxv2i16: |
461 | 61.2M | case nxv4i16: |
462 | 61.2M | case nxv8i16: |
463 | 61.2M | case nxv16i16: |
464 | 61.2M | case nxv32i16: return i16; |
465 | 66.2M | case v1i32: |
466 | 66.2M | case v2i32: |
467 | 66.2M | case v4i32: |
468 | 66.2M | case v8i32: |
469 | 66.2M | case v16i32: |
470 | 66.2M | case v32i32: |
471 | 66.2M | case v64i32: |
472 | 66.2M | case nxv1i32: |
473 | 66.2M | case nxv2i32: |
474 | 66.2M | case nxv4i32: |
475 | 66.2M | case nxv8i32: |
476 | 66.2M | case nxv16i32: |
477 | 66.2M | case nxv32i32: return i32; |
478 | 66.2M | case v1i64: |
479 | 64.3M | case v2i64: |
480 | 64.3M | case v4i64: |
481 | 64.3M | case v8i64: |
482 | 64.3M | case v16i64: |
483 | 64.3M | case v32i64: |
484 | 64.3M | case nxv1i64: |
485 | 64.3M | case nxv2i64: |
486 | 64.3M | case nxv4i64: |
487 | 64.3M | case nxv8i64: |
488 | 64.3M | case nxv16i64: |
489 | 64.3M | case nxv32i64: return i64; |
490 | 64.3M | case v1i128: return i1284.30M ; |
491 | 64.3M | case v2f16: |
492 | 27.3M | case v4f16: |
493 | 27.3M | case v8f16: |
494 | 27.3M | case nxv2f16: |
495 | 27.3M | case nxv4f16: |
496 | 27.3M | case nxv8f16: return f16; |
497 | 47.7M | case v1f32: |
498 | 47.7M | case v2f32: |
499 | 47.7M | case v4f32: |
500 | 47.7M | case v8f32: |
501 | 47.7M | case v16f32: |
502 | 47.7M | case nxv1f32: |
503 | 47.7M | case nxv2f32: |
504 | 47.7M | case nxv4f32: |
505 | 47.7M | case nxv8f32: |
506 | 47.7M | case nxv16f32: return f32; |
507 | 47.7M | case v1f64: |
508 | 40.0M | case v2f64: |
509 | 40.0M | case v4f64: |
510 | 40.0M | case v8f64: |
511 | 40.0M | case nxv1f64: |
512 | 40.0M | case nxv2f64: |
513 | 40.0M | case nxv4f64: |
514 | 40.0M | case nxv8f64: return f64; |
515 | 0 | } |
516 | 0 | } |
517 | | |
518 | 89.0M | unsigned getVectorNumElements() const { |
519 | 89.0M | switch (SimpleTy) { |
520 | 89.0M | default: |
521 | 0 | llvm_unreachable("Not a vector MVT!"); |
522 | 89.0M | case v1024i1: return 1024391k ; |
523 | 89.0M | case v512i1: return 512352k ; |
524 | 89.0M | case v256i8: return 256677k ; |
525 | 89.0M | case v128i1: |
526 | 1.82M | case v128i8: |
527 | 1.82M | case v128i16: return 128; |
528 | 3.12M | case v64i1: |
529 | 3.12M | case v64i8: |
530 | 3.12M | case v64i16: |
531 | 3.12M | case v64i32: return 64; |
532 | 11.3M | case v32i1: |
533 | 11.3M | case v32i8: |
534 | 11.3M | case v32i16: |
535 | 11.3M | case v32i32: |
536 | 11.3M | case v32i64: |
537 | 11.3M | case nxv32i1: |
538 | 11.3M | case nxv32i8: |
539 | 11.3M | case nxv32i16: |
540 | 11.3M | case nxv32i32: |
541 | 11.3M | case nxv32i64: return 32; |
542 | 13.0M | case v16i1: |
543 | 13.0M | case v16i8: |
544 | 13.0M | case v16i16: |
545 | 13.0M | case v16i32: |
546 | 13.0M | case v16i64: |
547 | 13.0M | case v16f32: |
548 | 13.0M | case nxv16i1: |
549 | 13.0M | case nxv16i8: |
550 | 13.0M | case nxv16i16: |
551 | 13.0M | case nxv16i32: |
552 | 13.0M | case nxv16i64: |
553 | 13.0M | case nxv16f32: return 16; |
554 | 14.2M | case v8i1: |
555 | 14.2M | case v8i8: |
556 | 14.2M | case v8i16: |
557 | 14.2M | case v8i32: |
558 | 14.2M | case v8i64: |
559 | 14.2M | case v8f16: |
560 | 14.2M | case v8f32: |
561 | 14.2M | case v8f64: |
562 | 14.2M | case nxv8i1: |
563 | 14.2M | case nxv8i8: |
564 | 14.2M | case nxv8i16: |
565 | 14.2M | case nxv8i32: |
566 | 14.2M | case nxv8i64: |
567 | 14.2M | case nxv8f16: |
568 | 14.2M | case nxv8f32: |
569 | 14.2M | case nxv8f64: return 8; |
570 | 15.7M | case v4i1: |
571 | 15.7M | case v4i8: |
572 | 15.7M | case v4i16: |
573 | 15.7M | case v4i32: |
574 | 15.7M | case v4i64: |
575 | 15.7M | case v4f16: |
576 | 15.7M | case v4f32: |
577 | 15.7M | case v4f64: |
578 | 15.7M | case nxv4i1: |
579 | 15.7M | case nxv4i8: |
580 | 15.7M | case nxv4i16: |
581 | 15.7M | case nxv4i32: |
582 | 15.7M | case nxv4i64: |
583 | 15.7M | case nxv4f16: |
584 | 15.7M | case nxv4f32: |
585 | 15.7M | case nxv4f64: return 4; |
586 | 16.6M | case v2i1: |
587 | 16.6M | case v2i8: |
588 | 16.6M | case v2i16: |
589 | 16.6M | case v2i32: |
590 | 16.6M | case v2i64: |
591 | 16.6M | case v2f16: |
592 | 16.6M | case v2f32: |
593 | 16.6M | case v2f64: |
594 | 16.6M | case nxv2i1: |
595 | 16.6M | case nxv2i8: |
596 | 16.6M | case nxv2i16: |
597 | 16.6M | case nxv2i32: |
598 | 16.6M | case nxv2i64: |
599 | 16.6M | case nxv2f16: |
600 | 16.6M | case nxv2f32: |
601 | 16.6M | case nxv2f64: return 2; |
602 | 16.6M | case v1i1: |
603 | 11.6M | case v1i8: |
604 | 11.6M | case v1i16: |
605 | 11.6M | case v1i32: |
606 | 11.6M | case v1i64: |
607 | 11.6M | case v1i128: |
608 | 11.6M | case v1f32: |
609 | 11.6M | case v1f64: |
610 | 11.6M | case nxv1i1: |
611 | 11.6M | case nxv1i8: |
612 | 11.6M | case nxv1i16: |
613 | 11.6M | case nxv1i32: |
614 | 11.6M | case nxv1i64: |
615 | 11.6M | case nxv1f32: |
616 | 11.6M | case nxv1f64: return 1; |
617 | 0 | } |
618 | 0 | } |
619 | | |
620 | 136k | MVT::ElementCount getVectorElementCount() const { |
621 | 136k | return { getVectorNumElements(), isScalableVector() }; |
622 | 136k | } |
623 | | |
624 | 469M | unsigned getSizeInBits() const { |
625 | 469M | switch (SimpleTy) { |
626 | 469M | default: |
627 | 0 | llvm_unreachable("getSizeInBits called on extended MVT."); |
628 | 469M | case Other: |
629 | 0 | llvm_unreachable("Value type is non-standard value, Other."); |
630 | 469M | case iPTR: |
631 | 0 | llvm_unreachable("Value type size is target-dependent. Ask TLI."); |
632 | 469M | case iPTRAny: |
633 | 0 | case iAny: |
634 | 0 | case fAny: |
635 | 0 | case vAny: |
636 | 0 | case Any: |
637 | 0 | llvm_unreachable("Value type is overloaded."); |
638 | 0 | case token: |
639 | 0 | llvm_unreachable("Token type is a sentinel that cannot be used " |
640 | 0 | "in codegen and has no size"); |
641 | 0 | case Metadata: |
642 | 0 | llvm_unreachable("Value type is metadata."); |
643 | 35.9M | case i1: |
644 | 35.9M | case v1i1: |
645 | 35.9M | case nxv1i1: return 1; |
646 | 35.9M | case v2i1: |
647 | 182k | case nxv2i1: return 2; |
648 | 182k | case v4i1: |
649 | 141k | case nxv4i1: return 4; |
650 | 44.0M | case i8 : |
651 | 44.0M | case v1i8: |
652 | 44.0M | case v8i1: |
653 | 44.0M | case nxv1i8: |
654 | 44.0M | case nxv8i1: return 8; |
655 | 46.1M | case i16 : |
656 | 46.1M | case f16: |
657 | 46.1M | case v16i1: |
658 | 46.1M | case v2i8: |
659 | 46.1M | case v1i16: |
660 | 46.1M | case nxv16i1: |
661 | 46.1M | case nxv2i8: |
662 | 46.1M | case nxv1i16: return 16; |
663 | 111M | case f32 : |
664 | 111M | case i32 : |
665 | 111M | case v32i1: |
666 | 111M | case v4i8: |
667 | 111M | case v2i16: |
668 | 111M | case v2f16: |
669 | 111M | case v1f32: |
670 | 111M | case v1i32: |
671 | 111M | case nxv32i1: |
672 | 111M | case nxv4i8: |
673 | 111M | case nxv2i16: |
674 | 111M | case nxv1i32: |
675 | 111M | case nxv2f16: |
676 | 111M | case nxv1f32: return 32; |
677 | 144M | case x86mmx: |
678 | 144M | case f64 : |
679 | 144M | case i64 : |
680 | 144M | case v64i1: |
681 | 144M | case v8i8: |
682 | 144M | case v4i16: |
683 | 144M | case v2i32: |
684 | 144M | case v1i64: |
685 | 144M | case v4f16: |
686 | 144M | case v2f32: |
687 | 144M | case v1f64: |
688 | 144M | case nxv8i8: |
689 | 144M | case nxv4i16: |
690 | 144M | case nxv2i32: |
691 | 144M | case nxv1i64: |
692 | 144M | case nxv4f16: |
693 | 144M | case nxv2f32: |
694 | 144M | case nxv1f64: return 64; |
695 | 144M | case f80 : return 801.76M ; |
696 | 144M | case f128: |
697 | 78.7M | case ppcf128: |
698 | 78.7M | case i128: |
699 | 78.7M | case v128i1: |
700 | 78.7M | case v16i8: |
701 | 78.7M | case v8i16: |
702 | 78.7M | case v4i32: |
703 | 78.7M | case v2i64: |
704 | 78.7M | case v1i128: |
705 | 78.7M | case v8f16: |
706 | 78.7M | case v4f32: |
707 | 78.7M | case v2f64: |
708 | 78.7M | case nxv16i8: |
709 | 78.7M | case nxv8i16: |
710 | 78.7M | case nxv4i32: |
711 | 78.7M | case nxv2i64: |
712 | 78.7M | case nxv8f16: |
713 | 78.7M | case nxv4f32: |
714 | 78.7M | case nxv2f64: return 128; |
715 | 78.7M | case v32i8: |
716 | 4.21M | case v16i16: |
717 | 4.21M | case v8i32: |
718 | 4.21M | case v4i64: |
719 | 4.21M | case v8f32: |
720 | 4.21M | case v4f64: |
721 | 4.21M | case nxv32i8: |
722 | 4.21M | case nxv16i16: |
723 | 4.21M | case nxv8i32: |
724 | 4.21M | case nxv4i64: |
725 | 4.21M | case nxv8f32: |
726 | 4.21M | case nxv4f64: return 256; |
727 | 4.21M | case v512i1: |
728 | 1.37M | case v64i8: |
729 | 1.37M | case v32i16: |
730 | 1.37M | case v16i32: |
731 | 1.37M | case v8i64: |
732 | 1.37M | case v16f32: |
733 | 1.37M | case v8f64: |
734 | 1.37M | case nxv32i16: |
735 | 1.37M | case nxv16i32: |
736 | 1.37M | case nxv8i64: |
737 | 1.37M | case nxv16f32: |
738 | 1.37M | case nxv8f64: return 512; |
739 | 1.37M | case v1024i1: |
740 | 94.7k | case v128i8: |
741 | 94.7k | case v64i16: |
742 | 94.7k | case v32i32: |
743 | 94.7k | case v16i64: |
744 | 94.7k | case nxv32i32: |
745 | 94.7k | case nxv16i64: return 1024; |
746 | 94.7k | case v256i8: |
747 | 76.7k | case v128i16: |
748 | 76.7k | case v64i32: |
749 | 76.7k | case v32i64: |
750 | 76.7k | case nxv32i64: return 2048; |
751 | 76.7k | case ExceptRef: return 00 ; // opaque type |
752 | 0 | } |
753 | 0 | } |
754 | | |
755 | 68.2M | unsigned getScalarSizeInBits() const { |
756 | 68.2M | return getScalarType().getSizeInBits(); |
757 | 68.2M | } |
758 | | |
759 | | /// Return the number of bytes overwritten by a store of the specified value |
760 | | /// type. |
761 | 592k | unsigned getStoreSize() const { |
762 | 592k | return (getSizeInBits() + 7) / 8; |
763 | 592k | } |
764 | | |
765 | | /// Return the number of bits overwritten by a store of the specified value |
766 | | /// type. |
767 | 25 | unsigned getStoreSizeInBits() const { |
768 | 25 | return getStoreSize() * 8; |
769 | 25 | } |
770 | | |
771 | | /// Return true if this has more bits than VT. |
772 | 1.97k | bool bitsGT(MVT VT) const { |
773 | 1.97k | return getSizeInBits() > VT.getSizeInBits(); |
774 | 1.97k | } |
775 | | |
776 | | /// Return true if this has no less bits than VT. |
777 | 162 | bool bitsGE(MVT VT) const { |
778 | 162 | return getSizeInBits() >= VT.getSizeInBits(); |
779 | 162 | } |
780 | | |
781 | | /// Return true if this has less bits than VT. |
782 | 1.10k | bool bitsLT(MVT VT) const { |
783 | 1.10k | return getSizeInBits() < VT.getSizeInBits(); |
784 | 1.10k | } |
785 | | |
786 | | /// Return true if this has no more bits than VT. |
787 | | bool bitsLE(MVT VT) const { |
788 | | return getSizeInBits() <= VT.getSizeInBits(); |
789 | | } |
790 | | |
791 | 17.9k | static MVT getFloatingPointVT(unsigned BitWidth) { |
792 | 17.9k | switch (BitWidth) { |
793 | 17.9k | default: |
794 | 0 | llvm_unreachable("Bad bit width!"); |
795 | 17.9k | case 16: |
796 | 2 | return MVT::f16; |
797 | 17.9k | case 32: |
798 | 9.00k | return MVT::f32; |
799 | 17.9k | case 64: |
800 | 8.95k | return MVT::f64; |
801 | 17.9k | case 80: |
802 | 0 | return MVT::f80; |
803 | 17.9k | case 128: |
804 | 0 | return MVT::f128; |
805 | 0 | } |
806 | 0 | } |
807 | | |
808 | 77.7M | static MVT getIntegerVT(unsigned BitWidth) { |
809 | 77.7M | switch (BitWidth) { |
810 | 77.7M | default: |
811 | 862k | return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE); |
812 | 77.7M | case 1: |
813 | 5.28M | return MVT::i1; |
814 | 77.7M | case 8: |
815 | 4.10M | return MVT::i8; |
816 | 77.7M | case 16: |
817 | 1.65M | return MVT::i16; |
818 | 77.7M | case 32: |
819 | 20.9M | return MVT::i32; |
820 | 77.7M | case 64: |
821 | 44.2M | return MVT::i64; |
822 | 77.7M | case 128: |
823 | 683k | return MVT::i128; |
824 | 0 | } |
825 | 0 | } |
826 | | |
827 | 20.3M | static MVT getVectorVT(MVT VT, unsigned NumElements) { |
828 | 20.3M | switch (VT.SimpleTy) { |
829 | 20.3M | default: |
830 | 13.9k | break; |
831 | 20.3M | case MVT::i1: |
832 | 3.18M | if (NumElements == 1) return MVT::v1i1573k ; |
833 | 2.61M | if (NumElements == 2) return MVT::v2i1575k ; |
834 | 2.04M | if (NumElements == 4) return MVT::v4i1452k ; |
835 | 1.58M | if (NumElements == 8) return MVT::v8i1396k ; |
836 | 1.19M | if (NumElements == 16) return MVT::v16i1360k ; |
837 | 831k | if (NumElements == 32) return MVT::v32i1284k ; |
838 | 547k | if (NumElements == 64) return MVT::v64i1200k ; |
839 | 347k | if (NumElements == 128) return MVT::v128i1132k ; |
840 | 215k | if (NumElements == 512) return MVT::v512i186.3k ; |
841 | 128k | if (NumElements == 1024) return MVT::v1024i142.9k ; |
842 | 85.7k | break; |
843 | 2.47M | case MVT::i8: |
844 | 2.47M | if (NumElements == 1) return MVT::v1i8388k ; |
845 | 2.09M | if (NumElements == 2) return MVT::v2i8342k ; |
846 | 1.74M | if (NumElements == 4) return MVT::v4i8266k ; |
847 | 1.48M | if (NumElements == 8) return MVT::v8i8264k ; |
848 | 1.21M | if (NumElements == 16) return MVT::v16i8607k ; |
849 | 609k | if (NumElements == 32) return MVT::v32i8276k ; |
850 | 333k | if (NumElements == 64) return MVT::v64i8151k ; |
851 | 182k | if (NumElements == 128) return MVT::v128i893.3k ; |
852 | 89.1k | if (NumElements == 256) return MVT::v256i846.8k ; |
853 | 42.2k | break; |
854 | 2.30M | case MVT::i16: |
855 | 2.30M | if (NumElements == 1) return MVT::v1i16342k ; |
856 | 1.96M | if (NumElements == 2) return MVT::v2i16325k ; |
857 | 1.63M | if (NumElements == 4) return MVT::v4i16305k ; |
858 | 1.33M | if (NumElements == 8) return MVT::v8i16658k ; |
859 | 675k | if (NumElements == 16) return MVT::v16i16339k ; |
860 | 336k | if (NumElements == 32) return MVT::v32i16197k ; |
861 | 139k | if (NumElements == 64) return MVT::v64i1686.7k ; |
862 | 52.3k | if (NumElements == 128) return MVT::v128i1642.8k ; |
863 | 9.45k | break; |
864 | 4.55M | case MVT::i32: |
865 | 4.55M | if (NumElements == 1) return MVT::v1i32512k ; |
866 | 4.04M | if (NumElements == 2) return MVT::v2i321.40M ; |
867 | 2.64M | if (NumElements == 4) return MVT::v4i321.38M ; |
868 | 1.26M | if (NumElements == 8) return MVT::v8i32505k ; |
869 | 756k | if (NumElements == 16) return MVT::v16i32318k ; |
870 | 438k | if (NumElements == 32) return MVT::v32i32144k ; |
871 | 294k | if (NumElements == 64) return MVT::v64i3248.9k ; |
872 | 245k | break; |
873 | 3.50M | case MVT::i64: |
874 | 3.50M | if (NumElements == 1) return MVT::v1i64311k ; |
875 | 3.19M | if (NumElements == 2) return MVT::v2i641.84M ; |
876 | 1.34M | if (NumElements == 4) return MVT::v4i64666k ; |
877 | 683k | if (NumElements == 8) return MVT::v8i64349k ; |
878 | 334k | if (NumElements == 16) return MVT::v16i64192k ; |
879 | 141k | if (NumElements == 32) return MVT::v32i6489.1k ; |
880 | 52.4k | break; |
881 | 58.9k | case MVT::i128: |
882 | 58.9k | if (NumElements == 1) return MVT::v1i12849.1k ; |
883 | 9.75k | break; |
884 | 911k | case MVT::f16: |
885 | 911k | if (NumElements == 2) return MVT::v2f16279k ; |
886 | 632k | if (NumElements == 4) return MVT::v4f16213k ; |
887 | 418k | if (NumElements == 8) return MVT::v8f16145k ; |
888 | 273k | break; |
889 | 1.69M | case MVT::f32: |
890 | 1.69M | if (NumElements == 1) return MVT::v1f32224k ; |
891 | 1.47M | if (NumElements == 2) return MVT::v2f32502k ; |
892 | 968k | if (NumElements == 4) return MVT::v4f32600k ; |
893 | 368k | if (NumElements == 8) return MVT::v8f32235k ; |
894 | 133k | if (NumElements == 16) return MVT::v16f32120k ; |
895 | 12.9k | break; |
896 | 1.59M | case MVT::f64: |
897 | 1.59M | if (NumElements == 1) return MVT::v1f64183k ; |
898 | 1.40M | if (NumElements == 2) return MVT::v2f64876k ; |
899 | 531k | if (NumElements == 4) return MVT::v4f64281k ; |
900 | 250k | if (NumElements == 8) return MVT::v8f64152k ; |
901 | 97.9k | break; |
902 | 843k | } |
903 | 843k | return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE); |
904 | 843k | } |
905 | | |
906 | 9 | static MVT getScalableVectorVT(MVT VT, unsigned NumElements) { |
907 | 9 | switch(VT.SimpleTy) { |
908 | 9 | default: |
909 | 0 | break; |
910 | 9 | case MVT::i1: |
911 | 0 | if (NumElements == 1) return MVT::nxv1i1; |
912 | 0 | if (NumElements == 2) return MVT::nxv2i1; |
913 | 0 | if (NumElements == 4) return MVT::nxv4i1; |
914 | 0 | if (NumElements == 8) return MVT::nxv8i1; |
915 | 0 | if (NumElements == 16) return MVT::nxv16i1; |
916 | 0 | if (NumElements == 32) return MVT::nxv32i1; |
917 | 0 | break; |
918 | 0 | case MVT::i8: |
919 | 0 | if (NumElements == 1) return MVT::nxv1i8; |
920 | 0 | if (NumElements == 2) return MVT::nxv2i8; |
921 | 0 | if (NumElements == 4) return MVT::nxv4i8; |
922 | 0 | if (NumElements == 8) return MVT::nxv8i8; |
923 | 0 | if (NumElements == 16) return MVT::nxv16i8; |
924 | 0 | if (NumElements == 32) return MVT::nxv32i8; |
925 | 0 | break; |
926 | 0 | case MVT::i16: |
927 | 0 | if (NumElements == 1) return MVT::nxv1i16; |
928 | 0 | if (NumElements == 2) return MVT::nxv2i16; |
929 | 0 | if (NumElements == 4) return MVT::nxv4i16; |
930 | 0 | if (NumElements == 8) return MVT::nxv8i16; |
931 | 0 | if (NumElements == 16) return MVT::nxv16i16; |
932 | 0 | if (NumElements == 32) return MVT::nxv32i16; |
933 | 0 | break; |
934 | 3 | case MVT::i32: |
935 | 3 | if (NumElements == 1) return MVT::nxv1i320 ; |
936 | 3 | if (NumElements == 2) return MVT::nxv2i322 ; |
937 | 1 | if (NumElements == 4) return MVT::nxv4i32; |
938 | 0 | if (NumElements == 8) return MVT::nxv8i32; |
939 | 0 | if (NumElements == 16) return MVT::nxv16i32; |
940 | 0 | if (NumElements == 32) return MVT::nxv32i32; |
941 | 0 | break; |
942 | 5 | case MVT::i64: |
943 | 5 | if (NumElements == 1) return MVT::nxv1i641 ; |
944 | 4 | if (NumElements == 2) return MVT::nxv2i643 ; |
945 | 1 | if (NumElements == 4) return MVT::nxv4i64; |
946 | 0 | if (NumElements == 8) return MVT::nxv8i64; |
947 | 0 | if (NumElements == 16) return MVT::nxv16i64; |
948 | 0 | if (NumElements == 32) return MVT::nxv32i64; |
949 | 0 | break; |
950 | 0 | case MVT::f16: |
951 | 0 | if (NumElements == 2) return MVT::nxv2f16; |
952 | 0 | if (NumElements == 4) return MVT::nxv4f16; |
953 | 0 | if (NumElements == 8) return MVT::nxv8f16; |
954 | 0 | break; |
955 | 0 | case MVT::f32: |
956 | 0 | if (NumElements == 1) return MVT::nxv1f32; |
957 | 0 | if (NumElements == 2) return MVT::nxv2f32; |
958 | 0 | if (NumElements == 4) return MVT::nxv4f32; |
959 | 0 | if (NumElements == 8) return MVT::nxv8f32; |
960 | 0 | if (NumElements == 16) return MVT::nxv16f32; |
961 | 0 | break; |
962 | 1 | case MVT::f64: |
963 | 1 | if (NumElements == 1) return MVT::nxv1f640 ; |
964 | 1 | if (NumElements == 2) return MVT::nxv2f64; |
965 | 0 | if (NumElements == 4) return MVT::nxv4f64; |
966 | 0 | if (NumElements == 8) return MVT::nxv8f64; |
967 | 0 | break; |
968 | 0 | } |
969 | 0 | return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE); |
970 | 0 | } |
971 | | |
972 | 6.87M | static MVT getVectorVT(MVT VT, unsigned NumElements, bool IsScalable) { |
973 | 6.87M | if (IsScalable) |
974 | 2 | return getScalableVectorVT(VT, NumElements); |
975 | 6.87M | return getVectorVT(VT, NumElements); |
976 | 6.87M | } |
977 | | |
978 | 142k | static MVT getVectorVT(MVT VT, MVT::ElementCount EC) { |
979 | 142k | if (EC.Scalable) |
980 | 7 | return getScalableVectorVT(VT, EC.Min); |
981 | 142k | return getVectorVT(VT, EC.Min); |
982 | 142k | } |
983 | | |
984 | | /// Return the value type corresponding to the specified type. This returns |
985 | | /// all pointers as iPTR. If HandleUnknown is true, unknown types are |
986 | | /// returned as Other, otherwise they are invalid. |
987 | | static MVT getVT(Type *Ty, bool HandleUnknown = false); |
988 | | |
989 | | private: |
990 | | /// A simple iterator over the MVT::SimpleValueType enum. |
991 | | struct mvt_iterator { |
992 | | SimpleValueType VT; |
993 | | |
994 | 14.5M | mvt_iterator(SimpleValueType VT) : VT(VT) {} |
995 | | |
996 | 740M | MVT operator*() const { return VT; } |
997 | 747M | bool operator!=(const mvt_iterator &LHS) const { return VT != LHS.VT; } |
998 | | |
999 | 740M | mvt_iterator& operator++() { |
1000 | 740M | VT = (MVT::SimpleValueType)((int)VT + 1); |
1001 | 740M | assert((int)VT <= MVT::MAX_ALLOWED_VALUETYPE && |
1002 | 740M | "MVT iterator overflowed."); |
1003 | 740M | return *this; |
1004 | 740M | } |
1005 | | }; |
1006 | | |
1007 | | /// A range of the MVT::SimpleValueType enum. |
1008 | | using mvt_range = iterator_range<mvt_iterator>; |
1009 | | |
1010 | | public: |
1011 | | /// SimpleValueType Iteration |
1012 | | /// @{ |
1013 | 4.00M | static mvt_range all_valuetypes() { |
1014 | 4.00M | return mvt_range(MVT::FIRST_VALUETYPE, MVT::LAST_VALUETYPE); |
1015 | 4.00M | } |
1016 | | |
1017 | 104k | static mvt_range integer_valuetypes() { |
1018 | 104k | return mvt_range(MVT::FIRST_INTEGER_VALUETYPE, |
1019 | 104k | (MVT::SimpleValueType)(MVT::LAST_INTEGER_VALUETYPE + 1)); |
1020 | 104k | } |
1021 | | |
1022 | 79.1k | static mvt_range fp_valuetypes() { |
1023 | 79.1k | return mvt_range(MVT::FIRST_FP_VALUETYPE, |
1024 | 79.1k | (MVT::SimpleValueType)(MVT::LAST_FP_VALUETYPE + 1)); |
1025 | 79.1k | } |
1026 | | |
1027 | 2.94M | static mvt_range vector_valuetypes() { |
1028 | 2.94M | return mvt_range(MVT::FIRST_VECTOR_VALUETYPE, |
1029 | 2.94M | (MVT::SimpleValueType)(MVT::LAST_VECTOR_VALUETYPE + 1)); |
1030 | 2.94M | } |
1031 | | |
1032 | 81.9k | static mvt_range integer_vector_valuetypes() { |
1033 | 81.9k | return mvt_range( |
1034 | 81.9k | MVT::FIRST_INTEGER_VECTOR_VALUETYPE, |
1035 | 81.9k | (MVT::SimpleValueType)(MVT::LAST_INTEGER_VECTOR_VALUETYPE + 1)); |
1036 | 81.9k | } |
1037 | | |
1038 | 66.1k | static mvt_range fp_vector_valuetypes() { |
1039 | 66.1k | return mvt_range( |
1040 | 66.1k | MVT::FIRST_FP_VECTOR_VALUETYPE, |
1041 | 66.1k | (MVT::SimpleValueType)(MVT::LAST_FP_VECTOR_VALUETYPE + 1)); |
1042 | 66.1k | } |
1043 | | |
1044 | | static mvt_range integer_scalable_vector_valuetypes() { |
1045 | | return mvt_range(MVT::FIRST_INTEGER_SCALABLE_VALUETYPE, |
1046 | | (MVT::SimpleValueType)(MVT::LAST_INTEGER_SCALABLE_VALUETYPE + 1)); |
1047 | | } |
1048 | | |
1049 | | static mvt_range fp_scalable_vector_valuetypes() { |
1050 | | return mvt_range(MVT::FIRST_FP_SCALABLE_VALUETYPE, |
1051 | | (MVT::SimpleValueType)(MVT::LAST_FP_SCALABLE_VALUETYPE + 1)); |
1052 | | } |
1053 | | /// @} |
1054 | | }; |
1055 | | |
1056 | | } // end namespace llvm |
1057 | | |
1058 | | #endif // LLVM_CODEGEN_MACHINEVALUETYPE_H |