1 //===- Support/MachineValueType.h - Machine-Level types ---------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines the set of machine-level target independent types which
10 // legal values in the code generator use.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SUPPORT_MACHINEVALUETYPE_H
15 #define LLVM_SUPPORT_MACHINEVALUETYPE_H
17 #include "llvm/ADT/iterator_range.h"
18 #include "llvm/Support/ErrorHandling.h"
19 #include "llvm/Support/MathExtras.h"
20 #include "llvm/Support/TypeSize.h"
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.
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,
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
47 FIRST_INTEGER_VALUETYPE
= i1
,
48 LAST_INTEGER_VALUETYPE
= i128
,
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
57 FIRST_FP_VALUETYPE
= f16
,
58 LAST_FP_VALUETYPE
= ppcf128
,
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 v256i1
= 22, // 256 x i1
69 v512i1
= 23, // 512 x i1
70 v1024i1
= 24, // 1024 x i1
76 v16i8
= 29, // 16 x i8
77 v32i8
= 30, // 32 x i8
78 v64i8
= 31, // 64 x i8
79 v128i8
= 32, //128 x i8
80 v256i8
= 33, //256 x i8
82 v1i16
= 34, // 1 x i16
83 v2i16
= 35, // 2 x i16
84 v3i16
= 36, // 3 x i16
85 v4i16
= 37, // 4 x i16
86 v8i16
= 38, // 8 x i16
87 v16i16
= 39, // 16 x i16
88 v32i16
= 40, // 32 x i16
89 v64i16
= 41, // 64 x i16
90 v128i16
= 42, //128 x i16
92 v1i32
= 43, // 1 x i32
93 v2i32
= 44, // 2 x i32
94 v3i32
= 45, // 3 x i32
95 v4i32
= 46, // 4 x i32
96 v5i32
= 47, // 5 x i32
97 v8i32
= 48, // 8 x i32
98 v16i32
= 49, // 16 x i32
99 v32i32
= 50, // 32 x i32
100 v64i32
= 51, // 64 x i32
101 v128i32
= 52, // 128 x i32
102 v256i32
= 53, // 256 x i32
103 v512i32
= 54, // 512 x i32
104 v1024i32
= 55, // 1024 x i32
105 v2048i32
= 56, // 2048 x i32
107 v1i64
= 57, // 1 x i64
108 v2i64
= 58, // 2 x i64
109 v4i64
= 59, // 4 x i64
110 v8i64
= 60, // 8 x i64
111 v16i64
= 61, // 16 x i64
112 v32i64
= 62, // 32 x i64
114 v1i128
= 63, // 1 x i128
116 FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE
= v1i1
,
117 LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE
= v1i128
,
119 v2f16
= 64, // 2 x f16
120 v3f16
= 65, // 3 x f16
121 v4f16
= 66, // 4 x f16
122 v8f16
= 67, // 8 x f16
123 v16f16
= 68, // 16 x f16
124 v32f16
= 69, // 32 x f16
125 v1f32
= 70, // 1 x f32
126 v2f32
= 71, // 2 x f32
127 v3f32
= 72, // 3 x f32
128 v4f32
= 73, // 4 x f32
129 v5f32
= 74, // 5 x f32
130 v8f32
= 75, // 8 x f32
131 v16f32
= 76, // 16 x f32
132 v32f32
= 77, // 32 x f32
133 v64f32
= 78, // 64 x f32
134 v128f32
= 79, // 128 x f32
135 v256f32
= 80, // 256 x f32
136 v512f32
= 81, // 512 x f32
137 v1024f32
= 82, // 1024 x f32
138 v2048f32
= 83, // 2048 x f32
139 v1f64
= 84, // 1 x f64
140 v2f64
= 85, // 2 x f64
141 v4f64
= 86, // 4 x f64
142 v8f64
= 87, // 8 x f64
144 FIRST_FP_FIXEDLEN_VECTOR_VALUETYPE
= v2f16
,
145 LAST_FP_FIXEDLEN_VECTOR_VALUETYPE
= v8f64
,
147 FIRST_FIXEDLEN_VECTOR_VALUETYPE
= v1i1
,
148 LAST_FIXEDLEN_VECTOR_VALUETYPE
= v8f64
,
150 nxv1i1
= 88, // n x 1 x i1
151 nxv2i1
= 89, // n x 2 x i1
152 nxv4i1
= 90, // n x 4 x i1
153 nxv8i1
= 91, // n x 8 x i1
154 nxv16i1
= 92, // n x 16 x i1
155 nxv32i1
= 93, // n x 32 x i1
157 nxv1i8
= 94, // n x 1 x i8
158 nxv2i8
= 95, // n x 2 x i8
159 nxv4i8
= 96, // n x 4 x i8
160 nxv8i8
= 97, // n x 8 x i8
161 nxv16i8
= 98, // n x 16 x i8
162 nxv32i8
= 99, // n x 32 x i8
164 nxv1i16
= 100, // n x 1 x i16
165 nxv2i16
= 101, // n x 2 x i16
166 nxv4i16
= 102, // n x 4 x i16
167 nxv8i16
= 103, // n x 8 x i16
168 nxv16i16
= 104, // n x 16 x i16
169 nxv32i16
= 105, // n x 32 x i16
171 nxv1i32
= 106, // n x 1 x i32
172 nxv2i32
= 107, // n x 2 x i32
173 nxv4i32
= 108, // n x 4 x i32
174 nxv8i32
= 109, // n x 8 x i32
175 nxv16i32
= 110, // n x 16 x i32
176 nxv32i32
= 111, // n x 32 x i32
178 nxv1i64
= 112, // n x 1 x i64
179 nxv2i64
= 113, // n x 2 x i64
180 nxv4i64
= 114, // n x 4 x i64
181 nxv8i64
= 115, // n x 8 x i64
182 nxv16i64
= 116, // n x 16 x i64
183 nxv32i64
= 117, // n x 32 x i64
185 FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE
= nxv1i1
,
186 LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE
= nxv32i64
,
188 nxv2f16
= 118, // n x 2 x f16
189 nxv4f16
= 119, // n x 4 x f16
190 nxv8f16
= 120, // n x 8 x f16
191 nxv1f32
= 121, // n x 1 x f32
192 nxv2f32
= 122, // n x 2 x f32
193 nxv4f32
= 123, // n x 4 x f32
194 nxv8f32
= 124, // n x 8 x f32
195 nxv16f32
= 125, // n x 16 x f32
196 nxv1f64
= 126, // n x 1 x f64
197 nxv2f64
= 127, // n x 2 x f64
198 nxv4f64
= 128, // n x 4 x f64
199 nxv8f64
= 129, // n x 8 x f64
201 FIRST_FP_SCALABLE_VECTOR_VALUETYPE
= nxv2f16
,
202 LAST_FP_SCALABLE_VECTOR_VALUETYPE
= nxv8f64
,
204 FIRST_SCALABLE_VECTOR_VALUETYPE
= nxv1i1
,
205 LAST_SCALABLE_VECTOR_VALUETYPE
= nxv8f64
,
207 FIRST_VECTOR_VALUETYPE
= v1i1
,
208 LAST_VECTOR_VALUETYPE
= nxv8f64
,
210 x86mmx
= 130, // This is an X86 MMX value
212 Glue
= 131, // This glues nodes together during pre-RA sched
214 isVoid
= 132, // This has no value
216 Untyped
= 133, // This value takes a register, but has
217 // unspecified type. The register class
218 // will be determined by the opcode.
220 exnref
= 134, // WebAssembly's exnref type
222 FIRST_VALUETYPE
= 1, // This is always the beginning of the list.
223 LAST_VALUETYPE
= 135, // This always remains at the end of the list.
225 // This is the current maximum for LAST_VALUETYPE.
226 // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
227 // This value must be a multiple of 32.
228 MAX_ALLOWED_VALUETYPE
= 160,
230 // A value of type llvm::TokenTy
233 // This is MDNode or MDString.
236 // An int value the size of the pointer of the current
237 // target to any address space. This must only be used internal to
238 // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
241 // A vector with any length and element size. This is used
242 // for intrinsics that have overloadings based on vector types.
243 // This is only for tblgen's consumption!
246 // Any floating-point or vector floating-point value. This is used
247 // for intrinsics that have overloadings based on floating-point types.
248 // This is only for tblgen's consumption!
251 // An integer or vector integer value of any bit width. This is
252 // used for intrinsics that have overloadings based on integer bit widths.
253 // This is only for tblgen's consumption!
256 // An int value the size of the pointer of the current
257 // target. This should only be used internal to tblgen!
260 // Any type. This is used for intrinsics that have overloadings.
261 // This is only for tblgen's consumption!
265 SimpleValueType SimpleTy
= INVALID_SIMPLE_VALUE_TYPE
;
267 constexpr MVT() = default;
268 constexpr MVT(SimpleValueType SVT
) : SimpleTy(SVT
) {}
270 bool operator>(const MVT
& S
) const { return SimpleTy
> S
.SimpleTy
; }
271 bool operator<(const MVT
& S
) const { return SimpleTy
< S
.SimpleTy
; }
272 bool operator==(const MVT
& S
) const { return SimpleTy
== S
.SimpleTy
; }
273 bool operator!=(const MVT
& S
) const { return SimpleTy
!= S
.SimpleTy
; }
274 bool operator>=(const MVT
& S
) const { return SimpleTy
>= S
.SimpleTy
; }
275 bool operator<=(const MVT
& S
) const { return SimpleTy
<= S
.SimpleTy
; }
277 /// Return true if this is a valid simple valuetype.
278 bool isValid() const {
279 return (SimpleTy
>= MVT::FIRST_VALUETYPE
&&
280 SimpleTy
< MVT::LAST_VALUETYPE
);
283 /// Return true if this is a FP or a vector FP type.
284 bool isFloatingPoint() const {
285 return ((SimpleTy
>= MVT::FIRST_FP_VALUETYPE
&&
286 SimpleTy
<= MVT::LAST_FP_VALUETYPE
) ||
287 (SimpleTy
>= MVT::FIRST_FP_FIXEDLEN_VECTOR_VALUETYPE
&&
288 SimpleTy
<= MVT::LAST_FP_FIXEDLEN_VECTOR_VALUETYPE
) ||
289 (SimpleTy
>= MVT::FIRST_FP_SCALABLE_VECTOR_VALUETYPE
&&
290 SimpleTy
<= MVT::LAST_FP_SCALABLE_VECTOR_VALUETYPE
));
293 /// Return true if this is an integer or a vector integer type.
294 bool isInteger() const {
295 return ((SimpleTy
>= MVT::FIRST_INTEGER_VALUETYPE
&&
296 SimpleTy
<= MVT::LAST_INTEGER_VALUETYPE
) ||
297 (SimpleTy
>= MVT::FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE
&&
298 SimpleTy
<= MVT::LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE
) ||
299 (SimpleTy
>= MVT::FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE
&&
300 SimpleTy
<= MVT::LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE
));
303 /// Return true if this is an integer, not including vectors.
304 bool isScalarInteger() const {
305 return (SimpleTy
>= MVT::FIRST_INTEGER_VALUETYPE
&&
306 SimpleTy
<= MVT::LAST_INTEGER_VALUETYPE
);
309 /// Return true if this is a vector value type.
310 bool isVector() const {
311 return (SimpleTy
>= MVT::FIRST_VECTOR_VALUETYPE
&&
312 SimpleTy
<= MVT::LAST_VECTOR_VALUETYPE
);
315 /// Return true if this is a vector value type where the
316 /// runtime length is machine dependent
317 bool isScalableVector() const {
318 return (SimpleTy
>= MVT::FIRST_SCALABLE_VECTOR_VALUETYPE
&&
319 SimpleTy
<= MVT::LAST_SCALABLE_VECTOR_VALUETYPE
);
322 bool isFixedLengthVector() const {
323 return (SimpleTy
>= MVT::FIRST_FIXEDLEN_VECTOR_VALUETYPE
&&
324 SimpleTy
<= MVT::LAST_FIXEDLEN_VECTOR_VALUETYPE
);
327 /// Return true if this is a 16-bit vector type.
328 bool is16BitVector() const {
329 return (SimpleTy
== MVT::v2i8
|| SimpleTy
== MVT::v1i16
||
330 SimpleTy
== MVT::v16i1
);
333 /// Return true if this is a 32-bit vector type.
334 bool is32BitVector() const {
335 return (SimpleTy
== MVT::v32i1
|| SimpleTy
== MVT::v4i8
||
336 SimpleTy
== MVT::v2i16
|| SimpleTy
== MVT::v1i32
||
337 SimpleTy
== MVT::v2f16
|| SimpleTy
== MVT::v1f32
);
340 /// Return true if this is a 64-bit vector type.
341 bool is64BitVector() const {
342 return (SimpleTy
== MVT::v64i1
|| SimpleTy
== MVT::v8i8
||
343 SimpleTy
== MVT::v4i16
|| SimpleTy
== MVT::v2i32
||
344 SimpleTy
== MVT::v1i64
|| SimpleTy
== MVT::v4f16
||
345 SimpleTy
== MVT::v2f32
|| SimpleTy
== MVT::v1f64
);
348 /// Return true if this is a 128-bit vector type.
349 bool is128BitVector() const {
350 return (SimpleTy
== MVT::v128i1
|| SimpleTy
== MVT::v16i8
||
351 SimpleTy
== MVT::v8i16
|| SimpleTy
== MVT::v4i32
||
352 SimpleTy
== MVT::v2i64
|| SimpleTy
== MVT::v1i128
||
353 SimpleTy
== MVT::v8f16
|| SimpleTy
== MVT::v4f32
||
354 SimpleTy
== MVT::v2f64
);
357 /// Return true if this is a 256-bit vector type.
358 bool is256BitVector() const {
359 return (SimpleTy
== MVT::v16f16
|| SimpleTy
== MVT::v8f32
||
360 SimpleTy
== MVT::v4f64
|| SimpleTy
== MVT::v32i8
||
361 SimpleTy
== MVT::v16i16
|| SimpleTy
== MVT::v8i32
||
362 SimpleTy
== MVT::v4i64
|| SimpleTy
== MVT::v256i1
);
365 /// Return true if this is a 512-bit vector type.
366 bool is512BitVector() const {
367 return (SimpleTy
== MVT::v32f16
|| SimpleTy
== MVT::v16f32
||
368 SimpleTy
== MVT::v8f64
|| SimpleTy
== MVT::v512i1
||
369 SimpleTy
== MVT::v64i8
|| SimpleTy
== MVT::v32i16
||
370 SimpleTy
== MVT::v16i32
|| SimpleTy
== MVT::v8i64
);
373 /// Return true if this is a 1024-bit vector type.
374 bool is1024BitVector() const {
375 return (SimpleTy
== MVT::v1024i1
|| SimpleTy
== MVT::v128i8
||
376 SimpleTy
== MVT::v64i16
|| SimpleTy
== MVT::v32i32
||
377 SimpleTy
== MVT::v16i64
);
380 /// Return true if this is a 2048-bit vector type.
381 bool is2048BitVector() const {
382 return (SimpleTy
== MVT::v256i8
|| SimpleTy
== MVT::v128i16
||
383 SimpleTy
== MVT::v64i32
|| SimpleTy
== MVT::v32i64
);
386 /// Return true if this is an overloaded type for TableGen.
387 bool isOverloaded() const {
388 return (SimpleTy
==MVT::Any
||
389 SimpleTy
==MVT::iAny
|| SimpleTy
==MVT::fAny
||
390 SimpleTy
==MVT::vAny
|| SimpleTy
==MVT::iPTRAny
);
393 /// Return a VT for a vector type with the same element type but
394 /// half the number of elements.
395 MVT
getHalfNumVectorElementsVT() const {
396 MVT EltVT
= getVectorElementType();
397 auto EltCnt
= getVectorElementCount();
398 assert(!(EltCnt
.Min
& 1) && "Splitting vector, but not in half!");
399 return getVectorVT(EltVT
, EltCnt
/ 2);
402 /// Returns true if the given vector is a power of 2.
403 bool isPow2VectorType() const {
404 unsigned NElts
= getVectorNumElements();
405 return !(NElts
& (NElts
- 1));
408 /// Widens the length of the given vector MVT up to the nearest power of 2
409 /// and returns that type.
410 MVT
getPow2VectorType() const {
411 if (isPow2VectorType())
414 unsigned NElts
= getVectorNumElements();
415 unsigned Pow2NElts
= 1 << Log2_32_Ceil(NElts
);
416 return MVT::getVectorVT(getVectorElementType(), Pow2NElts
);
419 /// If this is a vector, return the element type, otherwise return this.
420 MVT
getScalarType() const {
421 return isVector() ? getVectorElementType() : *this;
424 MVT
getVectorElementType() const {
427 llvm_unreachable("Not a vector MVT!");
444 case nxv32i1
: return i1
;
459 case nxv32i8
: return i8
;
474 case nxv32i16
: return i16
;
494 case nxv32i32
: return i32
;
506 case nxv32i64
: return i64
;
507 case v1i128
: return i128
;
516 case nxv8f16
: return f16
;
535 case nxv16f32
: return f32
;
543 case nxv8f64
: return f64
;
547 unsigned getVectorNumElements() const {
550 llvm_unreachable("Not a vector MVT!");
552 case v2048f32
: return 2048;
555 case v1024f32
: return 1024;
558 case v512f32
: return 512;
562 case v256f32
: return 256;
567 case v128f32
: return 128;
572 case v64f32
: return 64;
584 case nxv32i64
: return 32;
597 case nxv16f32
: return 16;
613 case nxv8f64
: return 8;
615 case v5f32
: return 5;
631 case nxv4f64
: return 4;
635 case v3f32
: return 3;
651 case nxv2f64
: return 2;
666 case nxv1f64
: return 1;
670 ElementCount
getVectorElementCount() const {
671 return { getVectorNumElements(), isScalableVector() };
674 unsigned getSizeInBits() const {
677 llvm_unreachable("getSizeInBits called on extended MVT.");
679 llvm_unreachable("Value type is non-standard value, Other.");
681 llvm_unreachable("Value type size is target-dependent. Ask TLI.");
687 llvm_unreachable("Value type is overloaded.");
689 llvm_unreachable("Token type is a sentinel that cannot be used "
690 "in codegen and has no size");
692 llvm_unreachable("Value type is metadata.");
695 case nxv1i1
: return 1;
697 case nxv2i1
: return 2;
699 case nxv4i1
: return 4;
704 case nxv8i1
: return 8;
712 case nxv1i16
: return 16;
726 case nxv1f32
: return 32;
728 case v3f16
: return 48;
746 case nxv1f64
: return 64;
747 case f80
: return 80;
749 case v3f32
: return 96;
768 case nxv2f64
: return 128;
770 case v5f32
: return 160;
784 case nxv4f64
: return 256;
797 case nxv8f64
: return 512;
805 case nxv16i64
: return 1024;
811 case nxv32i64
: return 2048;
813 case v128f32
: return 4096;
815 case v256f32
: return 8192;
817 case v512f32
: return 16384;
819 case v1024f32
: return 32768;
821 case v2048f32
: return 65536;
822 case exnref
: return 0; // opaque type
826 unsigned getScalarSizeInBits() const {
827 return getScalarType().getSizeInBits();
830 /// Return the number of bytes overwritten by a store of the specified value
832 unsigned getStoreSize() const {
833 return (getSizeInBits() + 7) / 8;
836 /// Return the number of bits overwritten by a store of the specified value
838 unsigned getStoreSizeInBits() const {
839 return getStoreSize() * 8;
842 /// Return true if this has more bits than VT.
843 bool bitsGT(MVT VT
) const {
844 return getSizeInBits() > VT
.getSizeInBits();
847 /// Return true if this has no less bits than VT.
848 bool bitsGE(MVT VT
) const {
849 return getSizeInBits() >= VT
.getSizeInBits();
852 /// Return true if this has less bits than VT.
853 bool bitsLT(MVT VT
) const {
854 return getSizeInBits() < VT
.getSizeInBits();
857 /// Return true if this has no more bits than VT.
858 bool bitsLE(MVT VT
) const {
859 return getSizeInBits() <= VT
.getSizeInBits();
862 static MVT
getFloatingPointVT(unsigned BitWidth
) {
865 llvm_unreachable("Bad bit width!");
879 static MVT
getIntegerVT(unsigned BitWidth
) {
882 return (MVT::SimpleValueType
)(MVT::INVALID_SIMPLE_VALUE_TYPE
);
898 static MVT
getVectorVT(MVT VT
, unsigned NumElements
) {
899 switch (VT
.SimpleTy
) {
903 if (NumElements
== 1) return MVT::v1i1
;
904 if (NumElements
== 2) return MVT::v2i1
;
905 if (NumElements
== 4) return MVT::v4i1
;
906 if (NumElements
== 8) return MVT::v8i1
;
907 if (NumElements
== 16) return MVT::v16i1
;
908 if (NumElements
== 32) return MVT::v32i1
;
909 if (NumElements
== 64) return MVT::v64i1
;
910 if (NumElements
== 128) return MVT::v128i1
;
911 if (NumElements
== 256) return MVT::v256i1
;
912 if (NumElements
== 512) return MVT::v512i1
;
913 if (NumElements
== 1024) return MVT::v1024i1
;
916 if (NumElements
== 1) return MVT::v1i8
;
917 if (NumElements
== 2) return MVT::v2i8
;
918 if (NumElements
== 4) return MVT::v4i8
;
919 if (NumElements
== 8) return MVT::v8i8
;
920 if (NumElements
== 16) return MVT::v16i8
;
921 if (NumElements
== 32) return MVT::v32i8
;
922 if (NumElements
== 64) return MVT::v64i8
;
923 if (NumElements
== 128) return MVT::v128i8
;
924 if (NumElements
== 256) return MVT::v256i8
;
927 if (NumElements
== 1) return MVT::v1i16
;
928 if (NumElements
== 2) return MVT::v2i16
;
929 if (NumElements
== 3) return MVT::v3i16
;
930 if (NumElements
== 4) return MVT::v4i16
;
931 if (NumElements
== 8) return MVT::v8i16
;
932 if (NumElements
== 16) return MVT::v16i16
;
933 if (NumElements
== 32) return MVT::v32i16
;
934 if (NumElements
== 64) return MVT::v64i16
;
935 if (NumElements
== 128) return MVT::v128i16
;
938 if (NumElements
== 1) return MVT::v1i32
;
939 if (NumElements
== 2) return MVT::v2i32
;
940 if (NumElements
== 3) return MVT::v3i32
;
941 if (NumElements
== 4) return MVT::v4i32
;
942 if (NumElements
== 5) return MVT::v5i32
;
943 if (NumElements
== 8) return MVT::v8i32
;
944 if (NumElements
== 16) return MVT::v16i32
;
945 if (NumElements
== 32) return MVT::v32i32
;
946 if (NumElements
== 64) return MVT::v64i32
;
947 if (NumElements
== 128) return MVT::v128i32
;
948 if (NumElements
== 256) return MVT::v256i32
;
949 if (NumElements
== 512) return MVT::v512i32
;
950 if (NumElements
== 1024) return MVT::v1024i32
;
951 if (NumElements
== 2048) return MVT::v2048i32
;
954 if (NumElements
== 1) return MVT::v1i64
;
955 if (NumElements
== 2) return MVT::v2i64
;
956 if (NumElements
== 4) return MVT::v4i64
;
957 if (NumElements
== 8) return MVT::v8i64
;
958 if (NumElements
== 16) return MVT::v16i64
;
959 if (NumElements
== 32) return MVT::v32i64
;
962 if (NumElements
== 1) return MVT::v1i128
;
965 if (NumElements
== 2) return MVT::v2f16
;
966 if (NumElements
== 3) return MVT::v3f16
;
967 if (NumElements
== 4) return MVT::v4f16
;
968 if (NumElements
== 8) return MVT::v8f16
;
969 if (NumElements
== 16) return MVT::v16f16
;
970 if (NumElements
== 32) return MVT::v32f16
;
973 if (NumElements
== 1) return MVT::v1f32
;
974 if (NumElements
== 2) return MVT::v2f32
;
975 if (NumElements
== 3) return MVT::v3f32
;
976 if (NumElements
== 4) return MVT::v4f32
;
977 if (NumElements
== 5) return MVT::v5f32
;
978 if (NumElements
== 8) return MVT::v8f32
;
979 if (NumElements
== 16) return MVT::v16f32
;
980 if (NumElements
== 32) return MVT::v32f32
;
981 if (NumElements
== 64) return MVT::v64f32
;
982 if (NumElements
== 128) return MVT::v128f32
;
983 if (NumElements
== 256) return MVT::v256f32
;
984 if (NumElements
== 512) return MVT::v512f32
;
985 if (NumElements
== 1024) return MVT::v1024f32
;
986 if (NumElements
== 2048) return MVT::v2048f32
;
989 if (NumElements
== 1) return MVT::v1f64
;
990 if (NumElements
== 2) return MVT::v2f64
;
991 if (NumElements
== 4) return MVT::v4f64
;
992 if (NumElements
== 8) return MVT::v8f64
;
995 return (MVT::SimpleValueType
)(MVT::INVALID_SIMPLE_VALUE_TYPE
);
998 static MVT
getScalableVectorVT(MVT VT
, unsigned NumElements
) {
999 switch(VT
.SimpleTy
) {
1003 if (NumElements
== 1) return MVT::nxv1i1
;
1004 if (NumElements
== 2) return MVT::nxv2i1
;
1005 if (NumElements
== 4) return MVT::nxv4i1
;
1006 if (NumElements
== 8) return MVT::nxv8i1
;
1007 if (NumElements
== 16) return MVT::nxv16i1
;
1008 if (NumElements
== 32) return MVT::nxv32i1
;
1011 if (NumElements
== 1) return MVT::nxv1i8
;
1012 if (NumElements
== 2) return MVT::nxv2i8
;
1013 if (NumElements
== 4) return MVT::nxv4i8
;
1014 if (NumElements
== 8) return MVT::nxv8i8
;
1015 if (NumElements
== 16) return MVT::nxv16i8
;
1016 if (NumElements
== 32) return MVT::nxv32i8
;
1019 if (NumElements
== 1) return MVT::nxv1i16
;
1020 if (NumElements
== 2) return MVT::nxv2i16
;
1021 if (NumElements
== 4) return MVT::nxv4i16
;
1022 if (NumElements
== 8) return MVT::nxv8i16
;
1023 if (NumElements
== 16) return MVT::nxv16i16
;
1024 if (NumElements
== 32) return MVT::nxv32i16
;
1027 if (NumElements
== 1) return MVT::nxv1i32
;
1028 if (NumElements
== 2) return MVT::nxv2i32
;
1029 if (NumElements
== 4) return MVT::nxv4i32
;
1030 if (NumElements
== 8) return MVT::nxv8i32
;
1031 if (NumElements
== 16) return MVT::nxv16i32
;
1032 if (NumElements
== 32) return MVT::nxv32i32
;
1035 if (NumElements
== 1) return MVT::nxv1i64
;
1036 if (NumElements
== 2) return MVT::nxv2i64
;
1037 if (NumElements
== 4) return MVT::nxv4i64
;
1038 if (NumElements
== 8) return MVT::nxv8i64
;
1039 if (NumElements
== 16) return MVT::nxv16i64
;
1040 if (NumElements
== 32) return MVT::nxv32i64
;
1043 if (NumElements
== 2) return MVT::nxv2f16
;
1044 if (NumElements
== 4) return MVT::nxv4f16
;
1045 if (NumElements
== 8) return MVT::nxv8f16
;
1048 if (NumElements
== 1) return MVT::nxv1f32
;
1049 if (NumElements
== 2) return MVT::nxv2f32
;
1050 if (NumElements
== 4) return MVT::nxv4f32
;
1051 if (NumElements
== 8) return MVT::nxv8f32
;
1052 if (NumElements
== 16) return MVT::nxv16f32
;
1055 if (NumElements
== 1) return MVT::nxv1f64
;
1056 if (NumElements
== 2) return MVT::nxv2f64
;
1057 if (NumElements
== 4) return MVT::nxv4f64
;
1058 if (NumElements
== 8) return MVT::nxv8f64
;
1061 return (MVT::SimpleValueType
)(MVT::INVALID_SIMPLE_VALUE_TYPE
);
1064 static MVT
getVectorVT(MVT VT
, unsigned NumElements
, bool IsScalable
) {
1066 return getScalableVectorVT(VT
, NumElements
);
1067 return getVectorVT(VT
, NumElements
);
1070 static MVT
getVectorVT(MVT VT
, ElementCount EC
) {
1072 return getScalableVectorVT(VT
, EC
.Min
);
1073 return getVectorVT(VT
, EC
.Min
);
1076 /// Return the value type corresponding to the specified type. This returns
1077 /// all pointers as iPTR. If HandleUnknown is true, unknown types are
1078 /// returned as Other, otherwise they are invalid.
1079 static MVT
getVT(Type
*Ty
, bool HandleUnknown
= false);
1082 /// A simple iterator over the MVT::SimpleValueType enum.
1083 struct mvt_iterator
{
1086 mvt_iterator(SimpleValueType VT
) : VT(VT
) {}
1088 MVT
operator*() const { return VT
; }
1089 bool operator!=(const mvt_iterator
&LHS
) const { return VT
!= LHS
.VT
; }
1091 mvt_iterator
& operator++() {
1092 VT
= (MVT::SimpleValueType
)((int)VT
+ 1);
1093 assert((int)VT
<= MVT::MAX_ALLOWED_VALUETYPE
&&
1094 "MVT iterator overflowed.");
1099 /// A range of the MVT::SimpleValueType enum.
1100 using mvt_range
= iterator_range
<mvt_iterator
>;
1103 /// SimpleValueType Iteration
1105 static mvt_range
all_valuetypes() {
1106 return mvt_range(MVT::FIRST_VALUETYPE
, MVT::LAST_VALUETYPE
);
1109 static mvt_range
integer_valuetypes() {
1110 return mvt_range(MVT::FIRST_INTEGER_VALUETYPE
,
1111 (MVT::SimpleValueType
)(MVT::LAST_INTEGER_VALUETYPE
+ 1));
1114 static mvt_range
fp_valuetypes() {
1115 return mvt_range(MVT::FIRST_FP_VALUETYPE
,
1116 (MVT::SimpleValueType
)(MVT::LAST_FP_VALUETYPE
+ 1));
1119 static mvt_range
vector_valuetypes() {
1120 return mvt_range(MVT::FIRST_VECTOR_VALUETYPE
,
1121 (MVT::SimpleValueType
)(MVT::LAST_VECTOR_VALUETYPE
+ 1));
1124 static mvt_range
fixedlen_vector_valuetypes() {
1126 MVT::FIRST_FIXEDLEN_VECTOR_VALUETYPE
,
1127 (MVT::SimpleValueType
)(MVT::LAST_FIXEDLEN_VECTOR_VALUETYPE
+ 1));
1130 static mvt_range
scalable_vector_valuetypes() {
1132 MVT::FIRST_SCALABLE_VECTOR_VALUETYPE
,
1133 (MVT::SimpleValueType
)(MVT::LAST_SCALABLE_VECTOR_VALUETYPE
+ 1));
1136 static mvt_range
integer_fixedlen_vector_valuetypes() {
1138 MVT::FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE
,
1139 (MVT::SimpleValueType
)(MVT::LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE
+ 1));
1142 static mvt_range
fp_fixedlen_vector_valuetypes() {
1144 MVT::FIRST_FP_FIXEDLEN_VECTOR_VALUETYPE
,
1145 (MVT::SimpleValueType
)(MVT::LAST_FP_FIXEDLEN_VECTOR_VALUETYPE
+ 1));
1148 static mvt_range
integer_scalable_vector_valuetypes() {
1150 MVT::FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE
,
1151 (MVT::SimpleValueType
)(MVT::LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE
+ 1));
1154 static mvt_range
fp_scalable_vector_valuetypes() {
1156 MVT::FIRST_FP_SCALABLE_VECTOR_VALUETYPE
,
1157 (MVT::SimpleValueType
)(MVT::LAST_FP_SCALABLE_VECTOR_VALUETYPE
+ 1));
1162 } // end namespace llvm
1164 #endif // LLVM_CODEGEN_MACHINEVALUETYPE_H