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"
26 /// Machine Value Type. Every type that is supported natively by some
27 /// processor targeted by LLVM occurs here. This means that any legal value
28 /// type can be represented by an MVT.
31 enum SimpleValueType : uint8_t {
32 // Simple value types that aren't explicitly part of this enumeration
33 // are considered extended value types.
34 INVALID_SIMPLE_VALUE_TYPE = 0,
36 // If you change this numbering, you must change the values in
37 // ValueTypes.td as well!
38 Other = 1, // This is a non-standard value
39 i1 = 2, // This is a 1 bit integer value
40 i8 = 3, // This is an 8 bit integer value
41 i16 = 4, // This is a 16 bit integer value
42 i32 = 5, // This is a 32 bit integer value
43 i64 = 6, // This is a 64 bit integer value
44 i128 = 7, // This is a 128 bit integer value
46 FIRST_INTEGER_VALUETYPE = i1,
47 LAST_INTEGER_VALUETYPE = i128,
49 f16 = 8, // This is a 16 bit floating point value
50 f32 = 9, // This is a 32 bit floating point value
51 f64 = 10, // This is a 64 bit floating point value
52 f80 = 11, // This is a 80 bit floating point value
53 f128 = 12, // This is a 128 bit floating point value
54 ppcf128 = 13, // This is a PPC 128-bit floating point value
56 FIRST_FP_VALUETYPE = f16,
57 LAST_FP_VALUETYPE = ppcf128,
63 v16i1 = 18, // 16 x i1
64 v32i1 = 19, // 32 x i1
65 v64i1 = 20, // 64 x i1
66 v512i1 = 21, // 512 x i1
67 v1024i1 = 22, // 1024 x i1
73 v16i8 = 27, // 16 x i8
74 v32i8 = 28, // 32 x i8
75 v64i8 = 29, // 64 x i8
76 v128i8 = 30, //128 x i8
77 v256i8 = 31, //256 x i8
79 v1i16 = 32, // 1 x i16
80 v2i16 = 33, // 2 x i16
81 v4i16 = 34, // 4 x i16
82 v8i16 = 35, // 8 x i16
83 v16i16 = 36, // 16 x i16
84 v32i16 = 37, // 32 x i16
85 v64i16 = 38, // 64 x i16
86 v128i16 = 39, //128 x i16
88 v1i32 = 40, // 1 x i32
89 v2i32 = 41, // 2 x i32
90 v4i32 = 42, // 4 x i32
91 v8i32 = 43, // 8 x i32
92 v16i32 = 44, // 16 x i32
93 v32i32 = 45, // 32 x i32
94 v64i32 = 46, // 64 x i32
96 v1i64 = 47, // 1 x i64
97 v2i64 = 48, // 2 x i64
98 v4i64 = 49, // 4 x i64
99 v8i64 = 50, // 8 x i64
100 v16i64 = 51, // 16 x i64
101 v32i64 = 52, // 32 x i64
103 v1i128 = 53, // 1 x i128
105 // Scalable integer types
106 nxv1i1 = 54, // n x 1 x i1
107 nxv2i1 = 55, // n x 2 x i1
108 nxv4i1 = 56, // n x 4 x i1
109 nxv8i1 = 57, // n x 8 x i1
110 nxv16i1 = 58, // n x 16 x i1
111 nxv32i1 = 59, // n x 32 x i1
113 nxv1i8 = 60, // n x 1 x i8
114 nxv2i8 = 61, // n x 2 x i8
115 nxv4i8 = 62, // n x 4 x i8
116 nxv8i8 = 63, // n x 8 x i8
117 nxv16i8 = 64, // n x 16 x i8
118 nxv32i8 = 65, // n x 32 x i8
120 nxv1i16 = 66, // n x 1 x i16
121 nxv2i16 = 67, // n x 2 x i16
122 nxv4i16 = 68, // n x 4 x i16
123 nxv8i16 = 69, // n x 8 x i16
124 nxv16i16 = 70, // n x 16 x i16
125 nxv32i16 = 71, // n x 32 x i16
127 nxv1i32 = 72, // n x 1 x i32
128 nxv2i32 = 73, // n x 2 x i32
129 nxv4i32 = 74, // n x 4 x i32
130 nxv8i32 = 75, // n x 8 x i32
131 nxv16i32 = 76, // n x 16 x i32
132 nxv32i32 = 77, // n x 32 x i32
134 nxv1i64 = 78, // n x 1 x i64
135 nxv2i64 = 79, // n x 2 x i64
136 nxv4i64 = 80, // n x 4 x i64
137 nxv8i64 = 81, // n x 8 x i64
138 nxv16i64 = 82, // n x 16 x i64
139 nxv32i64 = 83, // n x 32 x i64
141 FIRST_INTEGER_VECTOR_VALUETYPE = v1i1,
142 LAST_INTEGER_VECTOR_VALUETYPE = nxv32i64,
144 FIRST_INTEGER_SCALABLE_VALUETYPE = nxv1i1,
145 LAST_INTEGER_SCALABLE_VALUETYPE = nxv32i64,
147 v2f16 = 84, // 2 x f16
148 v4f16 = 85, // 4 x f16
149 v8f16 = 86, // 8 x f16
150 v1f32 = 87, // 1 x f32
151 v2f32 = 88, // 2 x f32
152 v4f32 = 89, // 4 x f32
153 v8f32 = 90, // 8 x f32
154 v16f32 = 91, // 16 x f32
155 v1f64 = 92, // 1 x f64
156 v2f64 = 93, // 2 x f64
157 v4f64 = 94, // 4 x f64
158 v8f64 = 95, // 8 x f64
160 nxv2f16 = 96, // n x 2 x f16
161 nxv4f16 = 97, // n x 4 x f16
162 nxv8f16 = 98, // n x 8 x f16
163 nxv1f32 = 99, // n x 1 x f32
164 nxv2f32 = 100, // n x 2 x f32
165 nxv4f32 = 101, // n x 4 x f32
166 nxv8f32 = 102, // n x 8 x f32
167 nxv16f32 = 103, // n x 16 x f32
168 nxv1f64 = 104, // n x 1 x f64
169 nxv2f64 = 105, // n x 2 x f64
170 nxv4f64 = 106, // n x 4 x f64
171 nxv8f64 = 107, // n x 8 x f64
173 FIRST_FP_VECTOR_VALUETYPE = v2f16,
174 LAST_FP_VECTOR_VALUETYPE = nxv8f64,
176 FIRST_FP_SCALABLE_VALUETYPE = nxv2f16,
177 LAST_FP_SCALABLE_VALUETYPE = nxv8f64,
179 FIRST_VECTOR_VALUETYPE = v1i1,
180 LAST_VECTOR_VALUETYPE = nxv8f64,
182 x86mmx = 108, // This is an X86 MMX value
184 Glue = 109, // This glues nodes together during pre-RA sched
186 isVoid = 110, // This has no value
188 Untyped = 111, // This value takes a register, but has
189 // unspecified type. The register class
190 // will be determined by the opcode.
192 FIRST_VALUETYPE = 1, // This is always the beginning of the list.
193 LAST_VALUETYPE = 112, // This always remains at the end of the list.
195 // This is the current maximum for LAST_VALUETYPE.
196 // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
197 // This value must be a multiple of 32.
198 MAX_ALLOWED_VALUETYPE = 128,
200 // A value of type llvm::TokenTy
203 // This is MDNode or MDString.
206 // An int value the size of the pointer of the current
207 // target to any address space. This must only be used internal to
208 // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
211 // A vector with any length and element size. This is used
212 // for intrinsics that have overloadings based on vector types.
213 // This is only for tblgen's consumption!
216 // Any floating-point or vector floating-point value. This is used
217 // for intrinsics that have overloadings based on floating-point types.
218 // This is only for tblgen's consumption!
221 // An integer or vector integer value of any bit width. This is
222 // used for intrinsics that have overloadings based on integer bit widths.
223 // This is only for tblgen's consumption!
226 // An int value the size of the pointer of the current
227 // target. This should only be used internal to tblgen!
230 // Any type. This is used for intrinsics that have overloadings.
231 // This is only for tblgen's consumption!
235 SimpleValueType SimpleTy;
238 // A class to represent the number of elements in a vector
240 // For fixed-length vectors, the total number of elements is equal to 'Min'
241 // For scalable vectors, the total number of elements is a multiple of 'Min'
247 ElementCount(unsigned Min, bool Scalable)
248 : Min(Min), Scalable(Scalable) {}
250 ElementCount operator*(unsigned RHS) {
251 return { Min * RHS, Scalable };
254 ElementCount& operator*=(unsigned RHS) {
259 ElementCount operator/(unsigned RHS) {
260 return { Min / RHS, Scalable };
263 ElementCount& operator/=(unsigned RHS) {
268 bool operator==(const ElementCount& RHS) {
269 return Min == RHS.Min && Scalable == RHS.Scalable;
273 constexpr MVT() : SimpleTy(INVALID_SIMPLE_VALUE_TYPE) {}
274 constexpr MVT(SimpleValueType SVT) : SimpleTy(SVT) {}
276 bool operator>(const MVT& S) const { return SimpleTy > S.SimpleTy; }
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; }
283 /// Return true if this is a valid simple valuetype.
284 bool isValid() const {
285 return (SimpleTy >= MVT::FIRST_VALUETYPE &&
286 SimpleTy < MVT::LAST_VALUETYPE);
289 /// Return true if this is a FP or a vector FP type.
290 bool isFloatingPoint() const {
291 return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE &&
292 SimpleTy <= MVT::LAST_FP_VALUETYPE) ||
293 (SimpleTy >= MVT::FIRST_FP_VECTOR_VALUETYPE &&
294 SimpleTy <= MVT::LAST_FP_VECTOR_VALUETYPE));
297 /// Return true if this is an integer or a vector integer type.
298 bool isInteger() const {
299 return ((SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
300 SimpleTy <= MVT::LAST_INTEGER_VALUETYPE) ||
301 (SimpleTy >= MVT::FIRST_INTEGER_VECTOR_VALUETYPE &&
302 SimpleTy <= MVT::LAST_INTEGER_VECTOR_VALUETYPE));
305 /// Return true if this is an integer, not including vectors.
306 bool isScalarInteger() const {
307 return (SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
308 SimpleTy <= MVT::LAST_INTEGER_VALUETYPE);
311 /// Return true if this is a vector value type.
312 bool isVector() const {
313 return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE &&
314 SimpleTy <= MVT::LAST_VECTOR_VALUETYPE);
317 /// Return true if this is a vector value type where the
318 /// runtime length is machine dependent
319 bool isScalableVector() const {
320 return ((SimpleTy >= MVT::FIRST_INTEGER_SCALABLE_VALUETYPE &&
321 SimpleTy <= MVT::LAST_INTEGER_SCALABLE_VALUETYPE) ||
322 (SimpleTy >= MVT::FIRST_FP_SCALABLE_VALUETYPE &&
323 SimpleTy <= MVT::LAST_FP_SCALABLE_VALUETYPE));
326 /// Return true if this is a 16-bit vector type.
327 bool is16BitVector() const {
328 return (SimpleTy == MVT::v2i8 || SimpleTy == MVT::v1i16 ||
329 SimpleTy == MVT::v16i1);
332 /// Return true if this is a 32-bit vector type.
333 bool is32BitVector() const {
334 return (SimpleTy == MVT::v32i1 || SimpleTy == MVT::v4i8 ||
335 SimpleTy == MVT::v2i16 || SimpleTy == MVT::v1i32 ||
336 SimpleTy == MVT::v2f16 || SimpleTy == MVT::v1f32);
339 /// Return true if this is a 64-bit vector type.
340 bool is64BitVector() const {
341 return (SimpleTy == MVT::v64i1 || SimpleTy == MVT::v8i8 ||
342 SimpleTy == MVT::v4i16 || SimpleTy == MVT::v2i32 ||
343 SimpleTy == MVT::v1i64 || SimpleTy == MVT::v4f16 ||
344 SimpleTy == MVT::v2f32 || SimpleTy == MVT::v1f64);
347 /// Return true if this is a 128-bit vector type.
348 bool is128BitVector() const {
349 return (SimpleTy == MVT::v16i8 || SimpleTy == MVT::v8i16 ||
350 SimpleTy == MVT::v4i32 || SimpleTy == MVT::v2i64 ||
351 SimpleTy == MVT::v1i128 || SimpleTy == MVT::v8f16 ||
352 SimpleTy == MVT::v4f32 || SimpleTy == MVT::v2f64);
355 /// Return true if this is a 256-bit vector type.
356 bool is256BitVector() const {
357 return (SimpleTy == MVT::v8f32 || SimpleTy == MVT::v4f64 ||
358 SimpleTy == MVT::v32i8 || SimpleTy == MVT::v16i16 ||
359 SimpleTy == MVT::v8i32 || SimpleTy == MVT::v4i64);
362 /// Return true if this is a 512-bit vector type.
363 bool is512BitVector() const {
364 return (SimpleTy == MVT::v16f32 || SimpleTy == MVT::v8f64 ||
365 SimpleTy == MVT::v512i1 || SimpleTy == MVT::v64i8 ||
366 SimpleTy == MVT::v32i16 || SimpleTy == MVT::v16i32 ||
367 SimpleTy == MVT::v8i64);
370 /// Return true if this is a 1024-bit vector type.
371 bool is1024BitVector() const {
372 return (SimpleTy == MVT::v1024i1 || SimpleTy == MVT::v128i8 ||
373 SimpleTy == MVT::v64i16 || SimpleTy == MVT::v32i32 ||
374 SimpleTy == MVT::v16i64);
377 /// Return true if this is a 1024-bit vector type.
378 bool is2048BitVector() const {
379 return (SimpleTy == MVT::v256i8 || SimpleTy == MVT::v128i16 ||
380 SimpleTy == MVT::v64i32 || SimpleTy == MVT::v32i64);
383 /// Return true if this is an overloaded type for TableGen.
384 bool isOverloaded() const {
385 return (SimpleTy==MVT::Any ||
386 SimpleTy==MVT::iAny || SimpleTy==MVT::fAny ||
387 SimpleTy==MVT::vAny || SimpleTy==MVT::iPTRAny);
390 /// Returns true if the given vector is a power of 2.
391 bool isPow2VectorType() const {
392 unsigned NElts = getVectorNumElements();
393 return !(NElts & (NElts - 1));
396 /// Widens the length of the given vector MVT up to the nearest power of 2
397 /// and returns that type.
398 MVT getPow2VectorType() const {
399 if (isPow2VectorType())
402 unsigned NElts = getVectorNumElements();
403 unsigned Pow2NElts = 1 << Log2_32_Ceil(NElts);
404 return MVT::getVectorVT(getVectorElementType(), Pow2NElts);
407 /// If this is a vector, return the element type, otherwise return this.
408 MVT getScalarType() const {
409 return isVector() ? getVectorElementType() : *this;
412 MVT getVectorElementType() const {
415 llvm_unreachable("Not a vector MVT!");
430 case nxv32i1: return i1;
445 case nxv32i8: return i8;
459 case nxv32i16: return i16;
472 case nxv32i32: return i32;
484 case nxv32i64: return i64;
485 case v1i128: return i128;
491 case nxv8f16: return f16;
501 case nxv16f32: return f32;
509 case nxv8f64: return f64;
513 unsigned getVectorNumElements() const {
516 llvm_unreachable("Not a vector MVT!");
517 case v1024i1: return 1024;
518 case v512i1: return 512;
519 case v256i8: return 256;
521 case v128i16: return 128;
525 case v64i32: return 64;
535 case nxv32i64: return 32;
547 case nxv16f32: return 16;
563 case nxv8f64: return 8;
579 case nxv4f64: return 4;
595 case nxv2f64: return 2;
610 case nxv1f64: return 1;
614 MVT::ElementCount getVectorElementCount() const {
615 return { getVectorNumElements(), isScalableVector() };
618 unsigned getSizeInBits() const {
621 llvm_unreachable("getSizeInBits called on extended MVT.");
623 llvm_unreachable("Value type is non-standard value, Other.");
625 llvm_unreachable("Value type size is target-dependent. Ask TLI.");
631 llvm_unreachable("Value type is overloaded.");
633 llvm_unreachable("Token type is a sentinel that cannot be used "
634 "in codegen and has no size");
636 llvm_unreachable("Value type is metadata.");
639 case nxv1i1: return 1;
641 case nxv2i1: return 2;
643 case nxv4i1: return 4;
648 case nxv8i1: return 8;
656 case nxv1i16: return 16;
670 case nxv1f32: return 32;
688 case nxv1f64: return 64;
689 case f80 : return 80;
707 case nxv2f64: return 128;
719 case nxv4f64: return 256;
731 case nxv8f64: return 512;
738 case nxv16i64: return 1024;
743 case nxv32i64: return 2048;
747 unsigned getScalarSizeInBits() const {
748 return getScalarType().getSizeInBits();
751 /// Return the number of bytes overwritten by a store of the specified value
753 unsigned getStoreSize() const {
754 return (getSizeInBits() + 7) / 8;
757 /// Return the number of bits overwritten by a store of the specified value
759 unsigned getStoreSizeInBits() const {
760 return getStoreSize() * 8;
763 /// Return true if this has more bits than VT.
764 bool bitsGT(MVT VT) const {
765 return getSizeInBits() > VT.getSizeInBits();
768 /// Return true if this has no less bits than VT.
769 bool bitsGE(MVT VT) const {
770 return getSizeInBits() >= VT.getSizeInBits();
773 /// Return true if this has less bits than VT.
774 bool bitsLT(MVT VT) const {
775 return getSizeInBits() < VT.getSizeInBits();
778 /// Return true if this has no more bits than VT.
779 bool bitsLE(MVT VT) const {
780 return getSizeInBits() <= VT.getSizeInBits();
784 static MVT getFloatingPointVT(unsigned BitWidth) {
787 llvm_unreachable("Bad bit width!");
801 static MVT getIntegerVT(unsigned BitWidth) {
804 return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
820 static MVT getVectorVT(MVT VT, unsigned NumElements) {
821 switch (VT.SimpleTy) {
825 if (NumElements == 1) return MVT::v1i1;
826 if (NumElements == 2) return MVT::v2i1;
827 if (NumElements == 4) return MVT::v4i1;
828 if (NumElements == 8) return MVT::v8i1;
829 if (NumElements == 16) return MVT::v16i1;
830 if (NumElements == 32) return MVT::v32i1;
831 if (NumElements == 64) return MVT::v64i1;
832 if (NumElements == 512) return MVT::v512i1;
833 if (NumElements == 1024) return MVT::v1024i1;
836 if (NumElements == 1) return MVT::v1i8;
837 if (NumElements == 2) return MVT::v2i8;
838 if (NumElements == 4) return MVT::v4i8;
839 if (NumElements == 8) return MVT::v8i8;
840 if (NumElements == 16) return MVT::v16i8;
841 if (NumElements == 32) return MVT::v32i8;
842 if (NumElements == 64) return MVT::v64i8;
843 if (NumElements == 128) return MVT::v128i8;
844 if (NumElements == 256) return MVT::v256i8;
847 if (NumElements == 1) return MVT::v1i16;
848 if (NumElements == 2) return MVT::v2i16;
849 if (NumElements == 4) return MVT::v4i16;
850 if (NumElements == 8) return MVT::v8i16;
851 if (NumElements == 16) return MVT::v16i16;
852 if (NumElements == 32) return MVT::v32i16;
853 if (NumElements == 64) return MVT::v64i16;
854 if (NumElements == 128) return MVT::v128i16;
857 if (NumElements == 1) return MVT::v1i32;
858 if (NumElements == 2) return MVT::v2i32;
859 if (NumElements == 4) return MVT::v4i32;
860 if (NumElements == 8) return MVT::v8i32;
861 if (NumElements == 16) return MVT::v16i32;
862 if (NumElements == 32) return MVT::v32i32;
863 if (NumElements == 64) return MVT::v64i32;
866 if (NumElements == 1) return MVT::v1i64;
867 if (NumElements == 2) return MVT::v2i64;
868 if (NumElements == 4) return MVT::v4i64;
869 if (NumElements == 8) return MVT::v8i64;
870 if (NumElements == 16) return MVT::v16i64;
871 if (NumElements == 32) return MVT::v32i64;
874 if (NumElements == 1) return MVT::v1i128;
877 if (NumElements == 2) return MVT::v2f16;
878 if (NumElements == 4) return MVT::v4f16;
879 if (NumElements == 8) return MVT::v8f16;
882 if (NumElements == 1) return MVT::v1f32;
883 if (NumElements == 2) return MVT::v2f32;
884 if (NumElements == 4) return MVT::v4f32;
885 if (NumElements == 8) return MVT::v8f32;
886 if (NumElements == 16) return MVT::v16f32;
889 if (NumElements == 1) return MVT::v1f64;
890 if (NumElements == 2) return MVT::v2f64;
891 if (NumElements == 4) return MVT::v4f64;
892 if (NumElements == 8) return MVT::v8f64;
895 return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
898 static MVT getScalableVectorVT(MVT VT, unsigned NumElements) {
899 switch(VT.SimpleTy) {
903 if (NumElements == 1) return MVT::nxv1i1;
904 if (NumElements == 2) return MVT::nxv2i1;
905 if (NumElements == 4) return MVT::nxv4i1;
906 if (NumElements == 8) return MVT::nxv8i1;
907 if (NumElements == 16) return MVT::nxv16i1;
908 if (NumElements == 32) return MVT::nxv32i1;
911 if (NumElements == 1) return MVT::nxv1i8;
912 if (NumElements == 2) return MVT::nxv2i8;
913 if (NumElements == 4) return MVT::nxv4i8;
914 if (NumElements == 8) return MVT::nxv8i8;
915 if (NumElements == 16) return MVT::nxv16i8;
916 if (NumElements == 32) return MVT::nxv32i8;
919 if (NumElements == 1) return MVT::nxv1i16;
920 if (NumElements == 2) return MVT::nxv2i16;
921 if (NumElements == 4) return MVT::nxv4i16;
922 if (NumElements == 8) return MVT::nxv8i16;
923 if (NumElements == 16) return MVT::nxv16i16;
924 if (NumElements == 32) return MVT::nxv32i16;
927 if (NumElements == 1) return MVT::nxv1i32;
928 if (NumElements == 2) return MVT::nxv2i32;
929 if (NumElements == 4) return MVT::nxv4i32;
930 if (NumElements == 8) return MVT::nxv8i32;
931 if (NumElements == 16) return MVT::nxv16i32;
932 if (NumElements == 32) return MVT::nxv32i32;
935 if (NumElements == 1) return MVT::nxv1i64;
936 if (NumElements == 2) return MVT::nxv2i64;
937 if (NumElements == 4) return MVT::nxv4i64;
938 if (NumElements == 8) return MVT::nxv8i64;
939 if (NumElements == 16) return MVT::nxv16i64;
940 if (NumElements == 32) return MVT::nxv32i64;
943 if (NumElements == 2) return MVT::nxv2f16;
944 if (NumElements == 4) return MVT::nxv4f16;
945 if (NumElements == 8) return MVT::nxv8f16;
948 if (NumElements == 1) return MVT::nxv1f32;
949 if (NumElements == 2) return MVT::nxv2f32;
950 if (NumElements == 4) return MVT::nxv4f32;
951 if (NumElements == 8) return MVT::nxv8f32;
952 if (NumElements == 16) return MVT::nxv16f32;
955 if (NumElements == 1) return MVT::nxv1f64;
956 if (NumElements == 2) return MVT::nxv2f64;
957 if (NumElements == 4) return MVT::nxv4f64;
958 if (NumElements == 8) return MVT::nxv8f64;
961 return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
964 static MVT getVectorVT(MVT VT, unsigned NumElements, bool IsScalable) {
966 return getScalableVectorVT(VT, NumElements);
967 return getVectorVT(VT, NumElements);
970 static MVT getVectorVT(MVT VT, MVT::ElementCount EC) {
972 return getScalableVectorVT(VT, EC.Min);
973 return getVectorVT(VT, EC.Min);
976 /// Return the value type corresponding to the specified type. This returns
977 /// all pointers as iPTR. If HandleUnknown is true, unknown types are
978 /// returned as Other, otherwise they are invalid.
979 static MVT getVT(Type *Ty, bool HandleUnknown = false);
982 /// A simple iterator over the MVT::SimpleValueType enum.
983 struct mvt_iterator {
985 mvt_iterator(SimpleValueType VT) : VT(VT) {}
986 MVT operator*() const { return VT; }
987 bool operator!=(const mvt_iterator &LHS) const { return VT != LHS.VT; }
988 mvt_iterator& operator++() {
989 VT = (MVT::SimpleValueType)((int)VT + 1);
990 assert((int)VT <= MVT::MAX_ALLOWED_VALUETYPE &&
991 "MVT iterator overflowed.");
995 /// A range of the MVT::SimpleValueType enum.
996 typedef iterator_range<mvt_iterator> mvt_range;
999 /// SimpleValueType Iteration
1001 static mvt_range all_valuetypes() {
1002 return mvt_range(MVT::FIRST_VALUETYPE, MVT::LAST_VALUETYPE);
1004 static mvt_range integer_valuetypes() {
1005 return mvt_range(MVT::FIRST_INTEGER_VALUETYPE,
1006 (MVT::SimpleValueType)(MVT::LAST_INTEGER_VALUETYPE + 1));
1008 static mvt_range fp_valuetypes() {
1009 return mvt_range(MVT::FIRST_FP_VALUETYPE,
1010 (MVT::SimpleValueType)(MVT::LAST_FP_VALUETYPE + 1));
1012 static mvt_range vector_valuetypes() {
1013 return mvt_range(MVT::FIRST_VECTOR_VALUETYPE,
1014 (MVT::SimpleValueType)(MVT::LAST_VECTOR_VALUETYPE + 1));
1016 static mvt_range integer_vector_valuetypes() {
1018 MVT::FIRST_INTEGER_VECTOR_VALUETYPE,
1019 (MVT::SimpleValueType)(MVT::LAST_INTEGER_VECTOR_VALUETYPE + 1));
1021 static mvt_range fp_vector_valuetypes() {
1023 MVT::FIRST_FP_VECTOR_VALUETYPE,
1024 (MVT::SimpleValueType)(MVT::LAST_FP_VECTOR_VALUETYPE + 1));
1026 static mvt_range integer_scalable_vector_valuetypes() {
1027 return mvt_range(MVT::FIRST_INTEGER_SCALABLE_VALUETYPE,
1028 (MVT::SimpleValueType)(MVT::LAST_INTEGER_SCALABLE_VALUETYPE + 1));
1030 static mvt_range fp_scalable_vector_valuetypes() {
1031 return mvt_range(MVT::FIRST_FP_SCALABLE_VALUETYPE,
1032 (MVT::SimpleValueType)(MVT::LAST_FP_SCALABLE_VALUETYPE + 1));
1037 } // End llvm namespace