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/ScalableSize.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 v512i1
= 22, // 512 x i1
69 v1024i1
= 23, // 1024 x i1
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
81 v1i16
= 33, // 1 x i16
82 v2i16
= 34, // 2 x i16
83 v3i16
= 35, // 3 x i16
84 v4i16
= 36, // 4 x i16
85 v8i16
= 37, // 8 x i16
86 v16i16
= 38, // 16 x i16
87 v32i16
= 39, // 32 x i16
88 v64i16
= 40, // 64 x i16
89 v128i16
= 41, //128 x i16
91 v1i32
= 42, // 1 x i32
92 v2i32
= 43, // 2 x i32
93 v3i32
= 44, // 3 x i32
94 v4i32
= 45, // 4 x i32
95 v5i32
= 46, // 5 x i32
96 v8i32
= 47, // 8 x i32
97 v16i32
= 48, // 16 x i32
98 v32i32
= 49, // 32 x i32
99 v64i32
= 50, // 64 x i32
100 v128i32
= 51, // 128 x i32
101 v256i32
= 52, // 256 x i32
102 v512i32
= 53, // 512 x i32
103 v1024i32
= 54, // 1024 x i32
104 v2048i32
= 55, // 2048 x i32
106 v1i64
= 56, // 1 x i64
107 v2i64
= 57, // 2 x i64
108 v4i64
= 58, // 4 x i64
109 v8i64
= 59, // 8 x i64
110 v16i64
= 60, // 16 x i64
111 v32i64
= 61, // 32 x i64
113 v1i128
= 62, // 1 x i128
115 // Scalable integer types
116 nxv1i1
= 63, // n x 1 x i1
117 nxv2i1
= 64, // n x 2 x i1
118 nxv4i1
= 65, // n x 4 x i1
119 nxv8i1
= 66, // n x 8 x i1
120 nxv16i1
= 67, // n x 16 x i1
121 nxv32i1
= 68, // n x 32 x i1
123 nxv1i8
= 69, // n x 1 x i8
124 nxv2i8
= 70, // n x 2 x i8
125 nxv4i8
= 71, // n x 4 x i8
126 nxv8i8
= 72, // n x 8 x i8
127 nxv16i8
= 73, // n x 16 x i8
128 nxv32i8
= 74, // n x 32 x i8
130 nxv1i16
= 75, // n x 1 x i16
131 nxv2i16
= 76, // n x 2 x i16
132 nxv4i16
= 77, // n x 4 x i16
133 nxv8i16
= 78, // n x 8 x i16
134 nxv16i16
= 79, // n x 16 x i16
135 nxv32i16
= 80, // n x 32 x i16
137 nxv1i32
= 81, // n x 1 x i32
138 nxv2i32
= 82, // n x 2 x i32
139 nxv4i32
= 83, // n x 4 x i32
140 nxv8i32
= 84, // n x 8 x i32
141 nxv16i32
= 85, // n x 16 x i32
142 nxv32i32
= 86, // n x 32 x i32
144 nxv1i64
= 87, // n x 1 x i64
145 nxv2i64
= 88, // n x 2 x i64
146 nxv4i64
= 89, // n x 4 x i64
147 nxv8i64
= 90, // n x 8 x i64
148 nxv16i64
= 91, // n x 16 x i64
149 nxv32i64
= 92, // n x 32 x i64
151 FIRST_INTEGER_VECTOR_VALUETYPE
= v1i1
,
152 LAST_INTEGER_VECTOR_VALUETYPE
= nxv32i64
,
154 FIRST_INTEGER_SCALABLE_VALUETYPE
= nxv1i1
,
155 LAST_INTEGER_SCALABLE_VALUETYPE
= nxv32i64
,
157 v2f16
= 93, // 2 x f16
158 v3f16
= 94, // 3 x f16
159 v4f16
= 95, // 4 x f16
160 v8f16
= 96, // 8 x f16
161 v16f16
= 97, // 16 x f16
162 v32f16
= 98, // 32 x f16
163 v1f32
= 99, // 1 x f32
164 v2f32
= 100, // 2 x f32
165 v3f32
= 101, // 3 x f32
166 v4f32
= 102, // 4 x f32
167 v5f32
= 103, // 5 x f32
168 v8f32
= 104, // 8 x f32
169 v16f32
= 105, // 16 x f32
170 v32f32
= 106, // 32 x f32
171 v64f32
= 107, // 64 x f32
172 v128f32
= 108, // 128 x f32
173 v256f32
= 109, // 256 x f32
174 v512f32
= 110, // 512 x f32
175 v1024f32
= 111, // 1024 x f32
176 v2048f32
= 112, // 2048 x f32
177 v1f64
= 113, // 1 x f64
178 v2f64
= 114, // 2 x f64
179 v4f64
= 115, // 4 x f64
180 v8f64
= 116, // 8 x f64
182 nxv2f16
= 117, // n x 2 x f16
183 nxv4f16
= 118, // n x 4 x f16
184 nxv8f16
= 119, // n x 8 x f16
185 nxv1f32
= 120, // n x 1 x f32
186 nxv2f32
= 121, // n x 2 x f32
187 nxv4f32
= 122, // n x 4 x f32
188 nxv8f32
= 123, // n x 8 x f32
189 nxv16f32
= 124, // n x 16 x f32
190 nxv1f64
= 125, // n x 1 x f64
191 nxv2f64
= 126, // n x 2 x f64
192 nxv4f64
= 127, // n x 4 x f64
193 nxv8f64
= 128, // n x 8 x f64
195 FIRST_FP_VECTOR_VALUETYPE
= v2f16
,
196 LAST_FP_VECTOR_VALUETYPE
= nxv8f64
,
198 FIRST_FP_SCALABLE_VALUETYPE
= nxv2f16
,
199 LAST_FP_SCALABLE_VALUETYPE
= nxv8f64
,
201 FIRST_VECTOR_VALUETYPE
= v1i1
,
202 LAST_VECTOR_VALUETYPE
= nxv8f64
,
204 x86mmx
= 129, // This is an X86 MMX value
206 Glue
= 130, // This glues nodes together during pre-RA sched
208 isVoid
= 131, // This has no value
210 Untyped
= 132, // This value takes a register, but has
211 // unspecified type. The register class
212 // will be determined by the opcode.
214 exnref
= 133, // WebAssembly's exnref type
216 FIRST_VALUETYPE
= 1, // This is always the beginning of the list.
217 LAST_VALUETYPE
= 134, // This always remains at the end of the list.
219 // This is the current maximum for LAST_VALUETYPE.
220 // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
221 // This value must be a multiple of 32.
222 MAX_ALLOWED_VALUETYPE
= 160,
224 // A value of type llvm::TokenTy
227 // This is MDNode or MDString.
230 // An int value the size of the pointer of the current
231 // target to any address space. This must only be used internal to
232 // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
235 // A vector with any length and element size. This is used
236 // for intrinsics that have overloadings based on vector types.
237 // This is only for tblgen's consumption!
240 // Any floating-point or vector floating-point value. This is used
241 // for intrinsics that have overloadings based on floating-point types.
242 // This is only for tblgen's consumption!
245 // An integer or vector integer value of any bit width. This is
246 // used for intrinsics that have overloadings based on integer bit widths.
247 // This is only for tblgen's consumption!
250 // An int value the size of the pointer of the current
251 // target. This should only be used internal to tblgen!
254 // Any type. This is used for intrinsics that have overloadings.
255 // This is only for tblgen's consumption!
259 SimpleValueType SimpleTy
= INVALID_SIMPLE_VALUE_TYPE
;
261 constexpr MVT() = default;
262 constexpr MVT(SimpleValueType SVT
) : SimpleTy(SVT
) {}
264 bool operator>(const MVT
& S
) const { return SimpleTy
> S
.SimpleTy
; }
265 bool operator<(const MVT
& S
) const { return SimpleTy
< S
.SimpleTy
; }
266 bool operator==(const MVT
& S
) const { return SimpleTy
== S
.SimpleTy
; }
267 bool operator!=(const MVT
& S
) const { return SimpleTy
!= S
.SimpleTy
; }
268 bool operator>=(const MVT
& S
) const { return SimpleTy
>= S
.SimpleTy
; }
269 bool operator<=(const MVT
& S
) const { return SimpleTy
<= S
.SimpleTy
; }
271 /// Return true if this is a valid simple valuetype.
272 bool isValid() const {
273 return (SimpleTy
>= MVT::FIRST_VALUETYPE
&&
274 SimpleTy
< MVT::LAST_VALUETYPE
);
277 /// Return true if this is a FP or a vector FP type.
278 bool isFloatingPoint() const {
279 return ((SimpleTy
>= MVT::FIRST_FP_VALUETYPE
&&
280 SimpleTy
<= MVT::LAST_FP_VALUETYPE
) ||
281 (SimpleTy
>= MVT::FIRST_FP_VECTOR_VALUETYPE
&&
282 SimpleTy
<= MVT::LAST_FP_VECTOR_VALUETYPE
));
285 /// Return true if this is an integer or a vector integer type.
286 bool isInteger() const {
287 return ((SimpleTy
>= MVT::FIRST_INTEGER_VALUETYPE
&&
288 SimpleTy
<= MVT::LAST_INTEGER_VALUETYPE
) ||
289 (SimpleTy
>= MVT::FIRST_INTEGER_VECTOR_VALUETYPE
&&
290 SimpleTy
<= MVT::LAST_INTEGER_VECTOR_VALUETYPE
));
293 /// Return true if this is an integer, not including vectors.
294 bool isScalarInteger() const {
295 return (SimpleTy
>= MVT::FIRST_INTEGER_VALUETYPE
&&
296 SimpleTy
<= MVT::LAST_INTEGER_VALUETYPE
);
299 /// Return true if this is a vector value type.
300 bool isVector() const {
301 return (SimpleTy
>= MVT::FIRST_VECTOR_VALUETYPE
&&
302 SimpleTy
<= MVT::LAST_VECTOR_VALUETYPE
);
305 /// Return true if this is a vector value type where the
306 /// runtime length is machine dependent
307 bool isScalableVector() const {
308 return ((SimpleTy
>= MVT::FIRST_INTEGER_SCALABLE_VALUETYPE
&&
309 SimpleTy
<= MVT::LAST_INTEGER_SCALABLE_VALUETYPE
) ||
310 (SimpleTy
>= MVT::FIRST_FP_SCALABLE_VALUETYPE
&&
311 SimpleTy
<= MVT::LAST_FP_SCALABLE_VALUETYPE
));
314 /// Return true if this is a 16-bit vector type.
315 bool is16BitVector() const {
316 return (SimpleTy
== MVT::v2i8
|| SimpleTy
== MVT::v1i16
||
317 SimpleTy
== MVT::v16i1
);
320 /// Return true if this is a 32-bit vector type.
321 bool is32BitVector() const {
322 return (SimpleTy
== MVT::v32i1
|| SimpleTy
== MVT::v4i8
||
323 SimpleTy
== MVT::v2i16
|| SimpleTy
== MVT::v1i32
||
324 SimpleTy
== MVT::v2f16
|| SimpleTy
== MVT::v1f32
);
327 /// Return true if this is a 64-bit vector type.
328 bool is64BitVector() const {
329 return (SimpleTy
== MVT::v64i1
|| SimpleTy
== MVT::v8i8
||
330 SimpleTy
== MVT::v4i16
|| SimpleTy
== MVT::v2i32
||
331 SimpleTy
== MVT::v1i64
|| SimpleTy
== MVT::v4f16
||
332 SimpleTy
== MVT::v2f32
|| SimpleTy
== MVT::v1f64
);
335 /// Return true if this is a 128-bit vector type.
336 bool is128BitVector() const {
337 return (SimpleTy
== MVT::v128i1
|| SimpleTy
== MVT::v16i8
||
338 SimpleTy
== MVT::v8i16
|| SimpleTy
== MVT::v4i32
||
339 SimpleTy
== MVT::v2i64
|| SimpleTy
== MVT::v1i128
||
340 SimpleTy
== MVT::v8f16
|| SimpleTy
== MVT::v4f32
||
341 SimpleTy
== MVT::v2f64
);
344 /// Return true if this is a 256-bit vector type.
345 bool is256BitVector() const {
346 return (SimpleTy
== MVT::v16f16
|| SimpleTy
== MVT::v8f32
||
347 SimpleTy
== MVT::v4f64
|| SimpleTy
== MVT::v32i8
||
348 SimpleTy
== MVT::v16i16
|| SimpleTy
== MVT::v8i32
||
349 SimpleTy
== MVT::v4i64
);
352 /// Return true if this is a 512-bit vector type.
353 bool is512BitVector() const {
354 return (SimpleTy
== MVT::v32f16
|| SimpleTy
== MVT::v16f32
||
355 SimpleTy
== MVT::v8f64
|| SimpleTy
== MVT::v512i1
||
356 SimpleTy
== MVT::v64i8
|| SimpleTy
== MVT::v32i16
||
357 SimpleTy
== MVT::v16i32
|| SimpleTy
== MVT::v8i64
);
360 /// Return true if this is a 1024-bit vector type.
361 bool is1024BitVector() const {
362 return (SimpleTy
== MVT::v1024i1
|| SimpleTy
== MVT::v128i8
||
363 SimpleTy
== MVT::v64i16
|| SimpleTy
== MVT::v32i32
||
364 SimpleTy
== MVT::v16i64
);
367 /// Return true if this is a 2048-bit vector type.
368 bool is2048BitVector() const {
369 return (SimpleTy
== MVT::v256i8
|| SimpleTy
== MVT::v128i16
||
370 SimpleTy
== MVT::v64i32
|| SimpleTy
== MVT::v32i64
);
373 /// Return true if this is an overloaded type for TableGen.
374 bool isOverloaded() const {
375 return (SimpleTy
==MVT::Any
||
376 SimpleTy
==MVT::iAny
|| SimpleTy
==MVT::fAny
||
377 SimpleTy
==MVT::vAny
|| SimpleTy
==MVT::iPTRAny
);
380 /// Return a VT for a vector type with the same element type but
381 /// half the number of elements.
382 MVT
getHalfNumVectorElementsVT() const {
383 MVT EltVT
= getVectorElementType();
384 auto EltCnt
= getVectorElementCount();
385 assert(!(EltCnt
.Min
& 1) && "Splitting vector, but not in half!");
386 return getVectorVT(EltVT
, EltCnt
/ 2);
389 /// Returns true if the given vector is a power of 2.
390 bool isPow2VectorType() const {
391 unsigned NElts
= getVectorNumElements();
392 return !(NElts
& (NElts
- 1));
395 /// Widens the length of the given vector MVT up to the nearest power of 2
396 /// and returns that type.
397 MVT
getPow2VectorType() const {
398 if (isPow2VectorType())
401 unsigned NElts
= getVectorNumElements();
402 unsigned Pow2NElts
= 1 << Log2_32_Ceil(NElts
);
403 return MVT::getVectorVT(getVectorElementType(), Pow2NElts
);
406 /// If this is a vector, return the element type, otherwise return this.
407 MVT
getScalarType() const {
408 return isVector() ? getVectorElementType() : *this;
411 MVT
getVectorElementType() const {
414 llvm_unreachable("Not a vector MVT!");
430 case nxv32i1
: return i1
;
445 case nxv32i8
: return i8
;
460 case nxv32i16
: return i16
;
480 case nxv32i32
: return i32
;
492 case nxv32i64
: return i64
;
493 case v1i128
: return i128
;
502 case nxv8f16
: return f16
;
521 case nxv16f32
: return f32
;
529 case nxv8f64
: return f64
;
533 unsigned getVectorNumElements() const {
536 llvm_unreachable("Not a vector MVT!");
538 case v2048f32
: return 2048;
541 case v1024f32
: return 1024;
544 case v512f32
: return 512;
547 case v256f32
: return 256;
552 case v128f32
: return 128;
557 case v64f32
: return 64;
569 case nxv32i64
: return 32;
582 case nxv16f32
: return 16;
598 case nxv8f64
: return 8;
600 case v5f32
: return 5;
616 case nxv4f64
: return 4;
620 case v3f32
: return 3;
636 case nxv2f64
: return 2;
651 case nxv1f64
: return 1;
655 ElementCount
getVectorElementCount() const {
656 return { getVectorNumElements(), isScalableVector() };
659 unsigned getSizeInBits() const {
662 llvm_unreachable("getSizeInBits called on extended MVT.");
664 llvm_unreachable("Value type is non-standard value, Other.");
666 llvm_unreachable("Value type size is target-dependent. Ask TLI.");
672 llvm_unreachable("Value type is overloaded.");
674 llvm_unreachable("Token type is a sentinel that cannot be used "
675 "in codegen and has no size");
677 llvm_unreachable("Value type is metadata.");
680 case nxv1i1
: return 1;
682 case nxv2i1
: return 2;
684 case nxv4i1
: return 4;
689 case nxv8i1
: return 8;
697 case nxv1i16
: return 16;
711 case nxv1f32
: return 32;
713 case v3f16
: return 48;
731 case nxv1f64
: return 64;
732 case f80
: return 80;
734 case v3f32
: return 96;
753 case nxv2f64
: return 128;
755 case v5f32
: return 160;
768 case nxv4f64
: return 256;
781 case nxv8f64
: return 512;
789 case nxv16i64
: return 1024;
795 case nxv32i64
: return 2048;
797 case v128f32
: return 4096;
799 case v256f32
: return 8192;
801 case v512f32
: return 16384;
803 case v1024f32
: return 32768;
805 case v2048f32
: return 65536;
806 case exnref
: return 0; // opaque type
810 unsigned getScalarSizeInBits() const {
811 return getScalarType().getSizeInBits();
814 /// Return the number of bytes overwritten by a store of the specified value
816 unsigned getStoreSize() const {
817 return (getSizeInBits() + 7) / 8;
820 /// Return the number of bits overwritten by a store of the specified value
822 unsigned getStoreSizeInBits() const {
823 return getStoreSize() * 8;
826 /// Return true if this has more bits than VT.
827 bool bitsGT(MVT VT
) const {
828 return getSizeInBits() > VT
.getSizeInBits();
831 /// Return true if this has no less bits than VT.
832 bool bitsGE(MVT VT
) const {
833 return getSizeInBits() >= VT
.getSizeInBits();
836 /// Return true if this has less bits than VT.
837 bool bitsLT(MVT VT
) const {
838 return getSizeInBits() < VT
.getSizeInBits();
841 /// Return true if this has no more bits than VT.
842 bool bitsLE(MVT VT
) const {
843 return getSizeInBits() <= VT
.getSizeInBits();
846 static MVT
getFloatingPointVT(unsigned BitWidth
) {
849 llvm_unreachable("Bad bit width!");
863 static MVT
getIntegerVT(unsigned BitWidth
) {
866 return (MVT::SimpleValueType
)(MVT::INVALID_SIMPLE_VALUE_TYPE
);
882 static MVT
getVectorVT(MVT VT
, unsigned NumElements
) {
883 switch (VT
.SimpleTy
) {
887 if (NumElements
== 1) return MVT::v1i1
;
888 if (NumElements
== 2) return MVT::v2i1
;
889 if (NumElements
== 4) return MVT::v4i1
;
890 if (NumElements
== 8) return MVT::v8i1
;
891 if (NumElements
== 16) return MVT::v16i1
;
892 if (NumElements
== 32) return MVT::v32i1
;
893 if (NumElements
== 64) return MVT::v64i1
;
894 if (NumElements
== 128) return MVT::v128i1
;
895 if (NumElements
== 512) return MVT::v512i1
;
896 if (NumElements
== 1024) return MVT::v1024i1
;
899 if (NumElements
== 1) return MVT::v1i8
;
900 if (NumElements
== 2) return MVT::v2i8
;
901 if (NumElements
== 4) return MVT::v4i8
;
902 if (NumElements
== 8) return MVT::v8i8
;
903 if (NumElements
== 16) return MVT::v16i8
;
904 if (NumElements
== 32) return MVT::v32i8
;
905 if (NumElements
== 64) return MVT::v64i8
;
906 if (NumElements
== 128) return MVT::v128i8
;
907 if (NumElements
== 256) return MVT::v256i8
;
910 if (NumElements
== 1) return MVT::v1i16
;
911 if (NumElements
== 2) return MVT::v2i16
;
912 if (NumElements
== 3) return MVT::v3i16
;
913 if (NumElements
== 4) return MVT::v4i16
;
914 if (NumElements
== 8) return MVT::v8i16
;
915 if (NumElements
== 16) return MVT::v16i16
;
916 if (NumElements
== 32) return MVT::v32i16
;
917 if (NumElements
== 64) return MVT::v64i16
;
918 if (NumElements
== 128) return MVT::v128i16
;
921 if (NumElements
== 1) return MVT::v1i32
;
922 if (NumElements
== 2) return MVT::v2i32
;
923 if (NumElements
== 3) return MVT::v3i32
;
924 if (NumElements
== 4) return MVT::v4i32
;
925 if (NumElements
== 5) return MVT::v5i32
;
926 if (NumElements
== 8) return MVT::v8i32
;
927 if (NumElements
== 16) return MVT::v16i32
;
928 if (NumElements
== 32) return MVT::v32i32
;
929 if (NumElements
== 64) return MVT::v64i32
;
930 if (NumElements
== 128) return MVT::v128i32
;
931 if (NumElements
== 256) return MVT::v256i32
;
932 if (NumElements
== 512) return MVT::v512i32
;
933 if (NumElements
== 1024) return MVT::v1024i32
;
934 if (NumElements
== 2048) return MVT::v2048i32
;
937 if (NumElements
== 1) return MVT::v1i64
;
938 if (NumElements
== 2) return MVT::v2i64
;
939 if (NumElements
== 4) return MVT::v4i64
;
940 if (NumElements
== 8) return MVT::v8i64
;
941 if (NumElements
== 16) return MVT::v16i64
;
942 if (NumElements
== 32) return MVT::v32i64
;
945 if (NumElements
== 1) return MVT::v1i128
;
948 if (NumElements
== 2) return MVT::v2f16
;
949 if (NumElements
== 3) return MVT::v3f16
;
950 if (NumElements
== 4) return MVT::v4f16
;
951 if (NumElements
== 8) return MVT::v8f16
;
952 if (NumElements
== 16) return MVT::v16f16
;
953 if (NumElements
== 32) return MVT::v32f16
;
956 if (NumElements
== 1) return MVT::v1f32
;
957 if (NumElements
== 2) return MVT::v2f32
;
958 if (NumElements
== 3) return MVT::v3f32
;
959 if (NumElements
== 4) return MVT::v4f32
;
960 if (NumElements
== 5) return MVT::v5f32
;
961 if (NumElements
== 8) return MVT::v8f32
;
962 if (NumElements
== 16) return MVT::v16f32
;
963 if (NumElements
== 32) return MVT::v32f32
;
964 if (NumElements
== 64) return MVT::v64f32
;
965 if (NumElements
== 128) return MVT::v128f32
;
966 if (NumElements
== 256) return MVT::v256f32
;
967 if (NumElements
== 512) return MVT::v512f32
;
968 if (NumElements
== 1024) return MVT::v1024f32
;
969 if (NumElements
== 2048) return MVT::v2048f32
;
972 if (NumElements
== 1) return MVT::v1f64
;
973 if (NumElements
== 2) return MVT::v2f64
;
974 if (NumElements
== 4) return MVT::v4f64
;
975 if (NumElements
== 8) return MVT::v8f64
;
978 return (MVT::SimpleValueType
)(MVT::INVALID_SIMPLE_VALUE_TYPE
);
981 static MVT
getScalableVectorVT(MVT VT
, unsigned NumElements
) {
982 switch(VT
.SimpleTy
) {
986 if (NumElements
== 1) return MVT::nxv1i1
;
987 if (NumElements
== 2) return MVT::nxv2i1
;
988 if (NumElements
== 4) return MVT::nxv4i1
;
989 if (NumElements
== 8) return MVT::nxv8i1
;
990 if (NumElements
== 16) return MVT::nxv16i1
;
991 if (NumElements
== 32) return MVT::nxv32i1
;
994 if (NumElements
== 1) return MVT::nxv1i8
;
995 if (NumElements
== 2) return MVT::nxv2i8
;
996 if (NumElements
== 4) return MVT::nxv4i8
;
997 if (NumElements
== 8) return MVT::nxv8i8
;
998 if (NumElements
== 16) return MVT::nxv16i8
;
999 if (NumElements
== 32) return MVT::nxv32i8
;
1002 if (NumElements
== 1) return MVT::nxv1i16
;
1003 if (NumElements
== 2) return MVT::nxv2i16
;
1004 if (NumElements
== 4) return MVT::nxv4i16
;
1005 if (NumElements
== 8) return MVT::nxv8i16
;
1006 if (NumElements
== 16) return MVT::nxv16i16
;
1007 if (NumElements
== 32) return MVT::nxv32i16
;
1010 if (NumElements
== 1) return MVT::nxv1i32
;
1011 if (NumElements
== 2) return MVT::nxv2i32
;
1012 if (NumElements
== 4) return MVT::nxv4i32
;
1013 if (NumElements
== 8) return MVT::nxv8i32
;
1014 if (NumElements
== 16) return MVT::nxv16i32
;
1015 if (NumElements
== 32) return MVT::nxv32i32
;
1018 if (NumElements
== 1) return MVT::nxv1i64
;
1019 if (NumElements
== 2) return MVT::nxv2i64
;
1020 if (NumElements
== 4) return MVT::nxv4i64
;
1021 if (NumElements
== 8) return MVT::nxv8i64
;
1022 if (NumElements
== 16) return MVT::nxv16i64
;
1023 if (NumElements
== 32) return MVT::nxv32i64
;
1026 if (NumElements
== 2) return MVT::nxv2f16
;
1027 if (NumElements
== 4) return MVT::nxv4f16
;
1028 if (NumElements
== 8) return MVT::nxv8f16
;
1031 if (NumElements
== 1) return MVT::nxv1f32
;
1032 if (NumElements
== 2) return MVT::nxv2f32
;
1033 if (NumElements
== 4) return MVT::nxv4f32
;
1034 if (NumElements
== 8) return MVT::nxv8f32
;
1035 if (NumElements
== 16) return MVT::nxv16f32
;
1038 if (NumElements
== 1) return MVT::nxv1f64
;
1039 if (NumElements
== 2) return MVT::nxv2f64
;
1040 if (NumElements
== 4) return MVT::nxv4f64
;
1041 if (NumElements
== 8) return MVT::nxv8f64
;
1044 return (MVT::SimpleValueType
)(MVT::INVALID_SIMPLE_VALUE_TYPE
);
1047 static MVT
getVectorVT(MVT VT
, unsigned NumElements
, bool IsScalable
) {
1049 return getScalableVectorVT(VT
, NumElements
);
1050 return getVectorVT(VT
, NumElements
);
1053 static MVT
getVectorVT(MVT VT
, ElementCount EC
) {
1055 return getScalableVectorVT(VT
, EC
.Min
);
1056 return getVectorVT(VT
, EC
.Min
);
1059 /// Return the value type corresponding to the specified type. This returns
1060 /// all pointers as iPTR. If HandleUnknown is true, unknown types are
1061 /// returned as Other, otherwise they are invalid.
1062 static MVT
getVT(Type
*Ty
, bool HandleUnknown
= false);
1065 /// A simple iterator over the MVT::SimpleValueType enum.
1066 struct mvt_iterator
{
1069 mvt_iterator(SimpleValueType VT
) : VT(VT
) {}
1071 MVT
operator*() const { return VT
; }
1072 bool operator!=(const mvt_iterator
&LHS
) const { return VT
!= LHS
.VT
; }
1074 mvt_iterator
& operator++() {
1075 VT
= (MVT::SimpleValueType
)((int)VT
+ 1);
1076 assert((int)VT
<= MVT::MAX_ALLOWED_VALUETYPE
&&
1077 "MVT iterator overflowed.");
1082 /// A range of the MVT::SimpleValueType enum.
1083 using mvt_range
= iterator_range
<mvt_iterator
>;
1086 /// SimpleValueType Iteration
1088 static mvt_range
all_valuetypes() {
1089 return mvt_range(MVT::FIRST_VALUETYPE
, MVT::LAST_VALUETYPE
);
1092 static mvt_range
integer_valuetypes() {
1093 return mvt_range(MVT::FIRST_INTEGER_VALUETYPE
,
1094 (MVT::SimpleValueType
)(MVT::LAST_INTEGER_VALUETYPE
+ 1));
1097 static mvt_range
fp_valuetypes() {
1098 return mvt_range(MVT::FIRST_FP_VALUETYPE
,
1099 (MVT::SimpleValueType
)(MVT::LAST_FP_VALUETYPE
+ 1));
1102 static mvt_range
vector_valuetypes() {
1103 return mvt_range(MVT::FIRST_VECTOR_VALUETYPE
,
1104 (MVT::SimpleValueType
)(MVT::LAST_VECTOR_VALUETYPE
+ 1));
1107 static mvt_range
integer_vector_valuetypes() {
1109 MVT::FIRST_INTEGER_VECTOR_VALUETYPE
,
1110 (MVT::SimpleValueType
)(MVT::LAST_INTEGER_VECTOR_VALUETYPE
+ 1));
1113 static mvt_range
fp_vector_valuetypes() {
1115 MVT::FIRST_FP_VECTOR_VALUETYPE
,
1116 (MVT::SimpleValueType
)(MVT::LAST_FP_VECTOR_VALUETYPE
+ 1));
1119 static mvt_range
integer_scalable_vector_valuetypes() {
1120 return mvt_range(MVT::FIRST_INTEGER_SCALABLE_VALUETYPE
,
1121 (MVT::SimpleValueType
)(MVT::LAST_INTEGER_SCALABLE_VALUETYPE
+ 1));
1124 static mvt_range
fp_scalable_vector_valuetypes() {
1125 return mvt_range(MVT::FIRST_FP_SCALABLE_VALUETYPE
,
1126 (MVT::SimpleValueType
)(MVT::LAST_FP_SCALABLE_VALUETYPE
+ 1));
1131 } // end namespace llvm
1133 #endif // LLVM_CODEGEN_MACHINEVALUETYPE_H