1 //===- CodeGen/MachineValueType.h - Machine-Level types ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the set of machine-level target independent types which
11 // legal values in the code generator use.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_MACHINEVALUETYPE_H
16 #define LLVM_CODEGEN_MACHINEVALUETYPE_H
18 #include "llvm/ADT/iterator_range.h"
19 #include "llvm/Support/ErrorHandling.h"
20 #include "llvm/Support/MathExtras.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 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
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
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
105 v1i128 = 54, // 1 x i128
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
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
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
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
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
143 FIRST_INTEGER_VECTOR_VALUETYPE = v1i1,
144 LAST_INTEGER_VECTOR_VALUETYPE = nxv32i64,
146 FIRST_INTEGER_SCALABLE_VALUETYPE = nxv1i1,
147 LAST_INTEGER_SCALABLE_VALUETYPE = nxv32i64,
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
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
175 FIRST_FP_VECTOR_VALUETYPE = v2f16,
176 LAST_FP_VECTOR_VALUETYPE = nxv8f64,
178 FIRST_FP_SCALABLE_VALUETYPE = nxv2f16,
179 LAST_FP_SCALABLE_VALUETYPE = nxv8f64,
181 FIRST_VECTOR_VALUETYPE = v1i1,
182 LAST_VECTOR_VALUETYPE = nxv8f64,
184 x86mmx = 109, // This is an X86 MMX value
186 Glue = 110, // This glues nodes together during pre-RA sched
188 isVoid = 111, // This has no value
190 Untyped = 112, // This value takes a register, but has
191 // unspecified type. The register class
192 // will be determined by the opcode.
194 FIRST_VALUETYPE = 1, // This is always the beginning of the list.
195 LAST_VALUETYPE = 113, // This always remains at the end of the list.
197 // This is the current maximum for LAST_VALUETYPE.
198 // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
199 // This value must be a multiple of 32.
200 MAX_ALLOWED_VALUETYPE = 128,
202 // A value of type llvm::TokenTy
205 // This is MDNode or MDString.
208 // An int value the size of the pointer of the current
209 // target to any address space. This must only be used internal to
210 // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
213 // A vector with any length and element size. This is used
214 // for intrinsics that have overloadings based on vector types.
215 // This is only for tblgen's consumption!
218 // Any floating-point or vector floating-point value. This is used
219 // for intrinsics that have overloadings based on floating-point types.
220 // This is only for tblgen's consumption!
223 // An integer or vector integer value of any bit width. This is
224 // used for intrinsics that have overloadings based on integer bit widths.
225 // This is only for tblgen's consumption!
228 // An int value the size of the pointer of the current
229 // target. This should only be used internal to tblgen!
232 // Any type. This is used for intrinsics that have overloadings.
233 // This is only for tblgen's consumption!
237 SimpleValueType SimpleTy = INVALID_SIMPLE_VALUE_TYPE;
239 // A class to represent the number of elements in a vector
241 // For fixed-length vectors, the total number of elements is equal to 'Min'
242 // For scalable vectors, the total number of elements is a multiple of 'Min'
248 ElementCount(unsigned Min, bool Scalable)
249 : Min(Min), Scalable(Scalable) {}
251 ElementCount operator*(unsigned RHS) {
252 return { Min * RHS, Scalable };
255 ElementCount& operator*=(unsigned RHS) {
260 ElementCount operator/(unsigned RHS) {
261 return { Min / RHS, Scalable };
264 ElementCount& operator/=(unsigned RHS) {
269 bool operator==(const ElementCount& RHS) {
270 return Min == RHS.Min && Scalable == RHS.Scalable;
274 constexpr MVT() = default;
275 constexpr MVT(SimpleValueType SVT) : SimpleTy(SVT) {}
277 bool operator>(const MVT& S) const { return SimpleTy > S.SimpleTy; }
278 bool operator<(const MVT& S) const { return SimpleTy < S.SimpleTy; }
279 bool operator==(const MVT& S) const { return SimpleTy == S.SimpleTy; }
280 bool operator!=(const MVT& S) const { return SimpleTy != S.SimpleTy; }
281 bool operator>=(const MVT& S) const { return SimpleTy >= S.SimpleTy; }
282 bool operator<=(const MVT& S) const { return SimpleTy <= S.SimpleTy; }
284 /// Return true if this is a valid simple valuetype.
285 bool isValid() const {
286 return (SimpleTy >= MVT::FIRST_VALUETYPE &&
287 SimpleTy < MVT::LAST_VALUETYPE);
290 /// Return true if this is a FP or a vector FP type.
291 bool isFloatingPoint() const {
292 return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE &&
293 SimpleTy <= MVT::LAST_FP_VALUETYPE) ||
294 (SimpleTy >= MVT::FIRST_FP_VECTOR_VALUETYPE &&
295 SimpleTy <= MVT::LAST_FP_VECTOR_VALUETYPE));
298 /// Return true if this is an integer or a vector integer type.
299 bool isInteger() const {
300 return ((SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
301 SimpleTy <= MVT::LAST_INTEGER_VALUETYPE) ||
302 (SimpleTy >= MVT::FIRST_INTEGER_VECTOR_VALUETYPE &&
303 SimpleTy <= MVT::LAST_INTEGER_VECTOR_VALUETYPE));
306 /// Return true if this is an integer, not including vectors.
307 bool isScalarInteger() const {
308 return (SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
309 SimpleTy <= MVT::LAST_INTEGER_VALUETYPE);
312 /// Return true if this is a vector value type.
313 bool isVector() const {
314 return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE &&
315 SimpleTy <= MVT::LAST_VECTOR_VALUETYPE);
318 /// Return true if this is a vector value type where the
319 /// runtime length is machine dependent
320 bool isScalableVector() const {
321 return ((SimpleTy >= MVT::FIRST_INTEGER_SCALABLE_VALUETYPE &&
322 SimpleTy <= MVT::LAST_INTEGER_SCALABLE_VALUETYPE) ||
323 (SimpleTy >= MVT::FIRST_FP_SCALABLE_VALUETYPE &&
324 SimpleTy <= MVT::LAST_FP_SCALABLE_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::v8f32 || SimpleTy == MVT::v4f64 ||
360 SimpleTy == MVT::v32i8 || SimpleTy == MVT::v16i16 ||
361 SimpleTy == MVT::v8i32 || SimpleTy == MVT::v4i64);
364 /// Return true if this is a 512-bit vector type.
365 bool is512BitVector() const {
366 return (SimpleTy == MVT::v16f32 || SimpleTy == MVT::v8f64 ||
367 SimpleTy == MVT::v512i1 || SimpleTy == MVT::v64i8 ||
368 SimpleTy == MVT::v32i16 || SimpleTy == MVT::v16i32 ||
369 SimpleTy == MVT::v8i64);
372 /// Return true if this is a 1024-bit vector type.
373 bool is1024BitVector() const {
374 return (SimpleTy == MVT::v1024i1 || SimpleTy == MVT::v128i8 ||
375 SimpleTy == MVT::v64i16 || SimpleTy == MVT::v32i32 ||
376 SimpleTy == MVT::v16i64);
379 /// Return true if this is a 1024-bit vector type.
380 bool is2048BitVector() const {
381 return (SimpleTy == MVT::v256i8 || SimpleTy == MVT::v128i16 ||
382 SimpleTy == MVT::v64i32 || SimpleTy == MVT::v32i64);
385 /// Return true if this is an overloaded type for TableGen.
386 bool isOverloaded() const {
387 return (SimpleTy==MVT::Any ||
388 SimpleTy==MVT::iAny || SimpleTy==MVT::fAny ||
389 SimpleTy==MVT::vAny || SimpleTy==MVT::iPTRAny);
392 /// Returns true if the given vector is a power of 2.
393 bool isPow2VectorType() const {
394 unsigned NElts = getVectorNumElements();
395 return !(NElts & (NElts - 1));
398 /// Widens the length of the given vector MVT up to the nearest power of 2
399 /// and returns that type.
400 MVT getPow2VectorType() const {
401 if (isPow2VectorType())
404 unsigned NElts = getVectorNumElements();
405 unsigned Pow2NElts = 1 << Log2_32_Ceil(NElts);
406 return MVT::getVectorVT(getVectorElementType(), Pow2NElts);
409 /// If this is a vector, return the element type, otherwise return this.
410 MVT getScalarType() const {
411 return isVector() ? getVectorElementType() : *this;
414 MVT getVectorElementType() const {
417 llvm_unreachable("Not a vector MVT!");
433 case nxv32i1: return i1;
448 case nxv32i8: return i8;
462 case nxv32i16: return i16;
475 case nxv32i32: return i32;
487 case nxv32i64: return i64;
488 case v1i128: return i128;
494 case nxv8f16: return f16;
504 case nxv16f32: return f32;
512 case nxv8f64: return f64;
516 unsigned getVectorNumElements() const {
519 llvm_unreachable("Not a vector MVT!");
520 case v1024i1: return 1024;
521 case v512i1: return 512;
522 case v256i8: return 256;
525 case v128i16: return 128;
529 case v64i32: return 64;
539 case nxv32i64: return 32;
551 case nxv16f32: return 16;
567 case nxv8f64: return 8;
583 case nxv4f64: return 4;
599 case nxv2f64: return 2;
614 case nxv1f64: return 1;
618 MVT::ElementCount getVectorElementCount() const {
619 return { getVectorNumElements(), isScalableVector() };
622 unsigned getSizeInBits() const {
625 llvm_unreachable("getSizeInBits called on extended MVT.");
627 llvm_unreachable("Value type is non-standard value, Other.");
629 llvm_unreachable("Value type size is target-dependent. Ask TLI.");
635 llvm_unreachable("Value type is overloaded.");
637 llvm_unreachable("Token type is a sentinel that cannot be used "
638 "in codegen and has no size");
640 llvm_unreachable("Value type is metadata.");
643 case nxv1i1: return 1;
645 case nxv2i1: return 2;
647 case nxv4i1: return 4;
652 case nxv8i1: return 8;
660 case nxv1i16: return 16;
674 case nxv1f32: return 32;
692 case nxv1f64: return 64;
693 case f80 : return 80;
712 case nxv2f64: return 128;
724 case nxv4f64: return 256;
736 case nxv8f64: return 512;
743 case nxv16i64: return 1024;
748 case nxv32i64: return 2048;
752 unsigned getScalarSizeInBits() const {
753 return getScalarType().getSizeInBits();
756 /// Return the number of bytes overwritten by a store of the specified value
758 unsigned getStoreSize() const {
759 return (getSizeInBits() + 7) / 8;
762 /// Return the number of bits overwritten by a store of the specified value
764 unsigned getStoreSizeInBits() const {
765 return getStoreSize() * 8;
768 /// Return true if this has more bits than VT.
769 bool bitsGT(MVT VT) const {
770 return getSizeInBits() > VT.getSizeInBits();
773 /// Return true if this has no less bits than VT.
774 bool bitsGE(MVT VT) const {
775 return getSizeInBits() >= VT.getSizeInBits();
778 /// Return true if this has less bits than VT.
779 bool bitsLT(MVT VT) const {
780 return getSizeInBits() < VT.getSizeInBits();
783 /// Return true if this has no more bits than VT.
784 bool bitsLE(MVT VT) const {
785 return getSizeInBits() <= VT.getSizeInBits();
788 static MVT getFloatingPointVT(unsigned BitWidth) {
791 llvm_unreachable("Bad bit width!");
805 static MVT getIntegerVT(unsigned BitWidth) {
808 return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
824 static MVT getVectorVT(MVT VT, unsigned NumElements) {
825 switch (VT.SimpleTy) {
829 if (NumElements == 1) return MVT::v1i1;
830 if (NumElements == 2) return MVT::v2i1;
831 if (NumElements == 4) return MVT::v4i1;
832 if (NumElements == 8) return MVT::v8i1;
833 if (NumElements == 16) return MVT::v16i1;
834 if (NumElements == 32) return MVT::v32i1;
835 if (NumElements == 64) return MVT::v64i1;
836 if (NumElements == 128) return MVT::v128i1;
837 if (NumElements == 512) return MVT::v512i1;
838 if (NumElements == 1024) return MVT::v1024i1;
841 if (NumElements == 1) return MVT::v1i8;
842 if (NumElements == 2) return MVT::v2i8;
843 if (NumElements == 4) return MVT::v4i8;
844 if (NumElements == 8) return MVT::v8i8;
845 if (NumElements == 16) return MVT::v16i8;
846 if (NumElements == 32) return MVT::v32i8;
847 if (NumElements == 64) return MVT::v64i8;
848 if (NumElements == 128) return MVT::v128i8;
849 if (NumElements == 256) return MVT::v256i8;
852 if (NumElements == 1) return MVT::v1i16;
853 if (NumElements == 2) return MVT::v2i16;
854 if (NumElements == 4) return MVT::v4i16;
855 if (NumElements == 8) return MVT::v8i16;
856 if (NumElements == 16) return MVT::v16i16;
857 if (NumElements == 32) return MVT::v32i16;
858 if (NumElements == 64) return MVT::v64i16;
859 if (NumElements == 128) return MVT::v128i16;
862 if (NumElements == 1) return MVT::v1i32;
863 if (NumElements == 2) return MVT::v2i32;
864 if (NumElements == 4) return MVT::v4i32;
865 if (NumElements == 8) return MVT::v8i32;
866 if (NumElements == 16) return MVT::v16i32;
867 if (NumElements == 32) return MVT::v32i32;
868 if (NumElements == 64) return MVT::v64i32;
871 if (NumElements == 1) return MVT::v1i64;
872 if (NumElements == 2) return MVT::v2i64;
873 if (NumElements == 4) return MVT::v4i64;
874 if (NumElements == 8) return MVT::v8i64;
875 if (NumElements == 16) return MVT::v16i64;
876 if (NumElements == 32) return MVT::v32i64;
879 if (NumElements == 1) return MVT::v1i128;
882 if (NumElements == 2) return MVT::v2f16;
883 if (NumElements == 4) return MVT::v4f16;
884 if (NumElements == 8) return MVT::v8f16;
887 if (NumElements == 1) return MVT::v1f32;
888 if (NumElements == 2) return MVT::v2f32;
889 if (NumElements == 4) return MVT::v4f32;
890 if (NumElements == 8) return MVT::v8f32;
891 if (NumElements == 16) return MVT::v16f32;
894 if (NumElements == 1) return MVT::v1f64;
895 if (NumElements == 2) return MVT::v2f64;
896 if (NumElements == 4) return MVT::v4f64;
897 if (NumElements == 8) return MVT::v8f64;
900 return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
903 static MVT getScalableVectorVT(MVT VT, unsigned NumElements) {
904 switch(VT.SimpleTy) {
908 if (NumElements == 1) return MVT::nxv1i1;
909 if (NumElements == 2) return MVT::nxv2i1;
910 if (NumElements == 4) return MVT::nxv4i1;
911 if (NumElements == 8) return MVT::nxv8i1;
912 if (NumElements == 16) return MVT::nxv16i1;
913 if (NumElements == 32) return MVT::nxv32i1;
916 if (NumElements == 1) return MVT::nxv1i8;
917 if (NumElements == 2) return MVT::nxv2i8;
918 if (NumElements == 4) return MVT::nxv4i8;
919 if (NumElements == 8) return MVT::nxv8i8;
920 if (NumElements == 16) return MVT::nxv16i8;
921 if (NumElements == 32) return MVT::nxv32i8;
924 if (NumElements == 1) return MVT::nxv1i16;
925 if (NumElements == 2) return MVT::nxv2i16;
926 if (NumElements == 4) return MVT::nxv4i16;
927 if (NumElements == 8) return MVT::nxv8i16;
928 if (NumElements == 16) return MVT::nxv16i16;
929 if (NumElements == 32) return MVT::nxv32i16;
932 if (NumElements == 1) return MVT::nxv1i32;
933 if (NumElements == 2) return MVT::nxv2i32;
934 if (NumElements == 4) return MVT::nxv4i32;
935 if (NumElements == 8) return MVT::nxv8i32;
936 if (NumElements == 16) return MVT::nxv16i32;
937 if (NumElements == 32) return MVT::nxv32i32;
940 if (NumElements == 1) return MVT::nxv1i64;
941 if (NumElements == 2) return MVT::nxv2i64;
942 if (NumElements == 4) return MVT::nxv4i64;
943 if (NumElements == 8) return MVT::nxv8i64;
944 if (NumElements == 16) return MVT::nxv16i64;
945 if (NumElements == 32) return MVT::nxv32i64;
948 if (NumElements == 2) return MVT::nxv2f16;
949 if (NumElements == 4) return MVT::nxv4f16;
950 if (NumElements == 8) return MVT::nxv8f16;
953 if (NumElements == 1) return MVT::nxv1f32;
954 if (NumElements == 2) return MVT::nxv2f32;
955 if (NumElements == 4) return MVT::nxv4f32;
956 if (NumElements == 8) return MVT::nxv8f32;
957 if (NumElements == 16) return MVT::nxv16f32;
960 if (NumElements == 1) return MVT::nxv1f64;
961 if (NumElements == 2) return MVT::nxv2f64;
962 if (NumElements == 4) return MVT::nxv4f64;
963 if (NumElements == 8) return MVT::nxv8f64;
966 return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
969 static MVT getVectorVT(MVT VT, unsigned NumElements, bool IsScalable) {
971 return getScalableVectorVT(VT, NumElements);
972 return getVectorVT(VT, NumElements);
975 static MVT getVectorVT(MVT VT, MVT::ElementCount EC) {
977 return getScalableVectorVT(VT, EC.Min);
978 return getVectorVT(VT, EC.Min);
981 /// Return the value type corresponding to the specified type. This returns
982 /// all pointers as iPTR. If HandleUnknown is true, unknown types are
983 /// returned as Other, otherwise they are invalid.
984 static MVT getVT(Type *Ty, bool HandleUnknown = false);
987 /// A simple iterator over the MVT::SimpleValueType enum.
988 struct mvt_iterator {
991 mvt_iterator(SimpleValueType VT) : VT(VT) {}
993 MVT operator*() const { return VT; }
994 bool operator!=(const mvt_iterator &LHS) const { return VT != LHS.VT; }
996 mvt_iterator& operator++() {
997 VT = (MVT::SimpleValueType)((int)VT + 1);
998 assert((int)VT <= MVT::MAX_ALLOWED_VALUETYPE &&
999 "MVT iterator overflowed.");
1004 /// A range of the MVT::SimpleValueType enum.
1005 using mvt_range = iterator_range<mvt_iterator>;
1008 /// SimpleValueType Iteration
1010 static mvt_range all_valuetypes() {
1011 return mvt_range(MVT::FIRST_VALUETYPE, MVT::LAST_VALUETYPE);
1014 static mvt_range integer_valuetypes() {
1015 return mvt_range(MVT::FIRST_INTEGER_VALUETYPE,
1016 (MVT::SimpleValueType)(MVT::LAST_INTEGER_VALUETYPE + 1));
1019 static mvt_range fp_valuetypes() {
1020 return mvt_range(MVT::FIRST_FP_VALUETYPE,
1021 (MVT::SimpleValueType)(MVT::LAST_FP_VALUETYPE + 1));
1024 static mvt_range vector_valuetypes() {
1025 return mvt_range(MVT::FIRST_VECTOR_VALUETYPE,
1026 (MVT::SimpleValueType)(MVT::LAST_VECTOR_VALUETYPE + 1));
1029 static mvt_range integer_vector_valuetypes() {
1031 MVT::FIRST_INTEGER_VECTOR_VALUETYPE,
1032 (MVT::SimpleValueType)(MVT::LAST_INTEGER_VECTOR_VALUETYPE + 1));
1035 static mvt_range fp_vector_valuetypes() {
1037 MVT::FIRST_FP_VECTOR_VALUETYPE,
1038 (MVT::SimpleValueType)(MVT::LAST_FP_VECTOR_VALUETYPE + 1));
1041 static mvt_range integer_scalable_vector_valuetypes() {
1042 return mvt_range(MVT::FIRST_INTEGER_SCALABLE_VALUETYPE,
1043 (MVT::SimpleValueType)(MVT::LAST_INTEGER_SCALABLE_VALUETYPE + 1));
1046 static mvt_range fp_scalable_vector_valuetypes() {
1047 return mvt_range(MVT::FIRST_FP_SCALABLE_VALUETYPE,
1048 (MVT::SimpleValueType)(MVT::LAST_FP_SCALABLE_VALUETYPE + 1));
1053 } // end namespace llvm
1055 #endif // LLVM_CODEGEN_MACHINEVALUETYPE_H