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,
62 v16i1 = 17, // 16 x i1
63 v32i1 = 18, // 32 x i1
64 v64i1 = 19, // 64 x i1
65 v512i1 = 20, // 512 x i1
66 v1024i1 = 21, // 1024 x i1
72 v16i8 = 26, // 16 x i8
73 v32i8 = 27, // 32 x i8
74 v64i8 = 28, // 64 x i8
75 v128i8 = 29, //128 x i8
76 v256i8 = 30, //256 x i8
78 v1i16 = 31, // 1 x i16
79 v2i16 = 32, // 2 x i16
80 v4i16 = 33, // 4 x i16
81 v8i16 = 34, // 8 x i16
82 v16i16 = 35, // 16 x i16
83 v32i16 = 36, // 32 x i16
84 v64i16 = 37, // 64 x i16
85 v128i16 = 38, //128 x i16
87 v1i32 = 39, // 1 x i32
88 v2i32 = 40, // 2 x i32
89 v4i32 = 41, // 4 x i32
90 v8i32 = 42, // 8 x i32
91 v16i32 = 43, // 16 x i32
92 v32i32 = 44, // 32 x i32
93 v64i32 = 45, // 64 x i32
95 v1i64 = 46, // 1 x i64
96 v2i64 = 47, // 2 x i64
97 v4i64 = 48, // 4 x i64
98 v8i64 = 49, // 8 x i64
99 v16i64 = 50, // 16 x i64
100 v32i64 = 51, // 32 x i64
102 v1i128 = 52, // 1 x i128
104 // Scalable integer types
105 nxv2i1 = 53, // n x 2 x i1
106 nxv4i1 = 54, // n x 4 x i1
107 nxv8i1 = 55, // n x 8 x i1
108 nxv16i1 = 56, // n x 16 x i1
109 nxv32i1 = 57, // n x 32 x i1
111 nxv1i8 = 58, // n x 1 x i8
112 nxv2i8 = 59, // n x 2 x i8
113 nxv4i8 = 60, // n x 4 x i8
114 nxv8i8 = 61, // n x 8 x i8
115 nxv16i8 = 62, // n x 16 x i8
116 nxv32i8 = 63, // n x 32 x i8
118 nxv1i16 = 64, // n x 1 x i16
119 nxv2i16 = 65, // n x 2 x i16
120 nxv4i16 = 66, // n x 4 x i16
121 nxv8i16 = 67, // n x 8 x i16
122 nxv16i16 = 68, // n x 16 x i16
123 nxv32i16 = 69, // n x 32 x i16
125 nxv1i32 = 70, // n x 1 x i32
126 nxv2i32 = 71, // n x 2 x i32
127 nxv4i32 = 72, // n x 4 x i32
128 nxv8i32 = 73, // n x 8 x i32
129 nxv16i32 = 74, // n x 16 x i32
130 nxv32i32 = 75, // n x 32 x i32
132 nxv1i64 = 76, // n x 1 x i64
133 nxv2i64 = 77, // n x 2 x i64
134 nxv4i64 = 78, // n x 4 x i64
135 nxv8i64 = 79, // n x 8 x i64
136 nxv16i64 = 80, // n x 16 x i64
137 nxv32i64 = 81, // n x 32 x i64
139 FIRST_INTEGER_VECTOR_VALUETYPE = v2i1,
140 LAST_INTEGER_VECTOR_VALUETYPE = nxv32i64,
142 FIRST_INTEGER_SCALABLE_VALUETYPE = nxv2i1,
143 LAST_INTEGER_SCALABLE_VALUETYPE = nxv32i64,
145 v2f16 = 82, // 2 x f16
146 v4f16 = 83, // 4 x f16
147 v8f16 = 84, // 8 x f16
148 v1f32 = 85, // 1 x f32
149 v2f32 = 86, // 2 x f32
150 v4f32 = 87, // 4 x f32
151 v8f32 = 88, // 8 x f32
152 v16f32 = 89, // 16 x f32
153 v1f64 = 90, // 1 x f64
154 v2f64 = 91, // 2 x f64
155 v4f64 = 92, // 4 x f64
156 v8f64 = 93, // 8 x f64
158 nxv2f16 = 94, // n x 2 x f16
159 nxv4f16 = 95, // n x 4 x f16
160 nxv8f16 = 96, // n x 8 x f16
161 nxv1f32 = 97, // n x 1 x f32
162 nxv2f32 = 98, // n x 2 x f32
163 nxv4f32 = 99, // n x 4 x f32
164 nxv8f32 = 100, // n x 8 x f32
165 nxv16f32 = 101, // n x 16 x f32
166 nxv1f64 = 102, // n x 1 x f64
167 nxv2f64 = 103, // n x 2 x f64
168 nxv4f64 = 104, // n x 4 x f64
169 nxv8f64 = 105, // n x 8 x f64
171 FIRST_FP_VECTOR_VALUETYPE = v2f16,
172 LAST_FP_VECTOR_VALUETYPE = nxv8f64,
174 FIRST_FP_SCALABLE_VALUETYPE = nxv2f16,
175 LAST_FP_SCALABLE_VALUETYPE = nxv8f64,
177 FIRST_VECTOR_VALUETYPE = v2i1,
178 LAST_VECTOR_VALUETYPE = nxv8f64,
180 x86mmx = 106, // This is an X86 MMX value
182 Glue = 107, // This glues nodes together during pre-RA sched
184 isVoid = 108, // This has no value
186 Untyped = 109, // This value takes a register, but has
187 // unspecified type. The register class
188 // will be determined by the opcode.
190 FIRST_VALUETYPE = 1, // This is always the beginning of the list.
191 LAST_VALUETYPE = 110, // This always remains at the end of the list.
193 // This is the current maximum for LAST_VALUETYPE.
194 // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
195 // This value must be a multiple of 32.
196 MAX_ALLOWED_VALUETYPE = 128,
198 // A value of type llvm::TokenTy
201 // This is MDNode or MDString.
204 // An int value the size of the pointer of the current
205 // target to any address space. This must only be used internal to
206 // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
209 // A vector with any length and element size. This is used
210 // for intrinsics that have overloadings based on vector types.
211 // This is only for tblgen's consumption!
214 // Any floating-point or vector floating-point value. This is used
215 // for intrinsics that have overloadings based on floating-point types.
216 // This is only for tblgen's consumption!
219 // An integer or vector integer value of any bit width. This is
220 // used for intrinsics that have overloadings based on integer bit widths.
221 // This is only for tblgen's consumption!
224 // An int value the size of the pointer of the current
225 // target. This should only be used internal to tblgen!
228 // Any type. This is used for intrinsics that have overloadings.
229 // This is only for tblgen's consumption!
233 SimpleValueType SimpleTy;
236 // A class to represent the number of elements in a vector
238 // For fixed-length vectors, the total number of elements is equal to 'Min'
239 // For scalable vectors, the total number of elements is a multiple of 'Min'
245 ElementCount(unsigned Min, bool Scalable)
246 : Min(Min), Scalable(Scalable) {}
248 ElementCount operator*(unsigned RHS) {
249 return { Min * RHS, Scalable };
252 ElementCount& operator*=(unsigned RHS) {
257 ElementCount operator/(unsigned RHS) {
258 return { Min / RHS, Scalable };
261 ElementCount& operator/=(unsigned RHS) {
266 bool operator==(const ElementCount& RHS) {
267 return Min == RHS.Min && Scalable == RHS.Scalable;
271 constexpr MVT() : SimpleTy(INVALID_SIMPLE_VALUE_TYPE) {}
272 constexpr MVT(SimpleValueType SVT) : SimpleTy(SVT) {}
274 bool operator>(const MVT& S) const { return SimpleTy > S.SimpleTy; }
275 bool operator<(const MVT& S) const { return SimpleTy < S.SimpleTy; }
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; }
281 /// Return true if this is a valid simple valuetype.
282 bool isValid() const {
283 return (SimpleTy >= MVT::FIRST_VALUETYPE &&
284 SimpleTy < MVT::LAST_VALUETYPE);
287 /// Return true if this is a FP or a vector FP type.
288 bool isFloatingPoint() const {
289 return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE &&
290 SimpleTy <= MVT::LAST_FP_VALUETYPE) ||
291 (SimpleTy >= MVT::FIRST_FP_VECTOR_VALUETYPE &&
292 SimpleTy <= MVT::LAST_FP_VECTOR_VALUETYPE));
295 /// Return true if this is an integer or a vector integer type.
296 bool isInteger() const {
297 return ((SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
298 SimpleTy <= MVT::LAST_INTEGER_VALUETYPE) ||
299 (SimpleTy >= MVT::FIRST_INTEGER_VECTOR_VALUETYPE &&
300 SimpleTy <= MVT::LAST_INTEGER_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_INTEGER_SCALABLE_VALUETYPE &&
319 SimpleTy <= MVT::LAST_INTEGER_SCALABLE_VALUETYPE) ||
320 (SimpleTy >= MVT::FIRST_FP_SCALABLE_VALUETYPE &&
321 SimpleTy <= MVT::LAST_FP_SCALABLE_VALUETYPE));
324 /// Return true if this is a 16-bit vector type.
325 bool is16BitVector() const {
326 return (SimpleTy == MVT::v2i8 || SimpleTy == MVT::v1i16 ||
327 SimpleTy == MVT::v16i1);
330 /// Return true if this is a 32-bit vector type.
331 bool is32BitVector() const {
332 return (SimpleTy == MVT::v32i1 || SimpleTy == MVT::v4i8 ||
333 SimpleTy == MVT::v2i16 || SimpleTy == MVT::v1i32 ||
334 SimpleTy == MVT::v2f16 || SimpleTy == MVT::v1f32);
337 /// Return true if this is a 64-bit vector type.
338 bool is64BitVector() const {
339 return (SimpleTy == MVT::v64i1 || SimpleTy == MVT::v8i8 ||
340 SimpleTy == MVT::v4i16 || SimpleTy == MVT::v2i32 ||
341 SimpleTy == MVT::v1i64 || SimpleTy == MVT::v4f16 ||
342 SimpleTy == MVT::v2f32 || SimpleTy == MVT::v1f64);
345 /// Return true if this is a 128-bit vector type.
346 bool is128BitVector() const {
347 return (SimpleTy == MVT::v16i8 || SimpleTy == MVT::v8i16 ||
348 SimpleTy == MVT::v4i32 || SimpleTy == MVT::v2i64 ||
349 SimpleTy == MVT::v1i128 || SimpleTy == MVT::v8f16 ||
350 SimpleTy == MVT::v4f32 || SimpleTy == MVT::v2f64);
353 /// Return true if this is a 256-bit vector type.
354 bool is256BitVector() const {
355 return (SimpleTy == MVT::v8f32 || SimpleTy == MVT::v4f64 ||
356 SimpleTy == MVT::v32i8 || SimpleTy == MVT::v16i16 ||
357 SimpleTy == MVT::v8i32 || SimpleTy == MVT::v4i64);
360 /// Return true if this is a 512-bit vector type.
361 bool is512BitVector() const {
362 return (SimpleTy == MVT::v16f32 || SimpleTy == MVT::v8f64 ||
363 SimpleTy == MVT::v512i1 || SimpleTy == MVT::v64i8 ||
364 SimpleTy == MVT::v32i16 || SimpleTy == MVT::v16i32 ||
365 SimpleTy == MVT::v8i64);
368 /// Return true if this is a 1024-bit vector type.
369 bool is1024BitVector() const {
370 return (SimpleTy == MVT::v1024i1 || SimpleTy == MVT::v128i8 ||
371 SimpleTy == MVT::v64i16 || SimpleTy == MVT::v32i32 ||
372 SimpleTy == MVT::v16i64);
375 /// Return true if this is a 1024-bit vector type.
376 bool is2048BitVector() const {
377 return (SimpleTy == MVT::v256i8 || SimpleTy == MVT::v128i16 ||
378 SimpleTy == MVT::v64i32 || SimpleTy == MVT::v32i64);
381 /// Return true if this is an overloaded type for TableGen.
382 bool isOverloaded() const {
383 return (SimpleTy==MVT::Any ||
384 SimpleTy==MVT::iAny || SimpleTy==MVT::fAny ||
385 SimpleTy==MVT::vAny || SimpleTy==MVT::iPTRAny);
388 /// Returns true if the given vector is a power of 2.
389 bool isPow2VectorType() const {
390 unsigned NElts = getVectorNumElements();
391 return !(NElts & (NElts - 1));
394 /// Widens the length of the given vector MVT up to the nearest power of 2
395 /// and returns that type.
396 MVT getPow2VectorType() const {
397 if (isPow2VectorType())
400 unsigned NElts = getVectorNumElements();
401 unsigned Pow2NElts = 1 << Log2_32_Ceil(NElts);
402 return MVT::getVectorVT(getVectorElementType(), Pow2NElts);
405 /// If this is a vector, return the element type, otherwise return this.
406 MVT getScalarType() const {
407 return isVector() ? getVectorElementType() : *this;
410 MVT getVectorElementType() const {
413 llvm_unreachable("Not a vector MVT!");
426 case nxv32i1: return i1;
441 case nxv32i8: return i8;
455 case nxv32i16: return i16;
468 case nxv32i32: return i32;
480 case nxv32i64: return i64;
481 case v1i128: return i128;
487 case nxv8f16: return f16;
497 case nxv16f32: return f32;
505 case nxv8f64: return f64;
509 unsigned getVectorNumElements() const {
512 llvm_unreachable("Not a vector MVT!");
513 case v1024i1: return 1024;
514 case v512i1: return 512;
515 case v256i8: return 256;
517 case v128i16: return 128;
521 case v64i32: return 64;
531 case nxv32i64: return 32;
543 case nxv16f32: return 16;
559 case nxv8f64: return 8;
575 case nxv4f64: return 4;
591 case nxv2f64: return 2;
604 case nxv1f64: return 1;
608 MVT::ElementCount getVectorElementCount() const {
609 return { getVectorNumElements(), isScalableVector() };
612 unsigned getSizeInBits() const {
615 llvm_unreachable("getSizeInBits called on extended MVT.");
617 llvm_unreachable("Value type is non-standard value, Other.");
619 llvm_unreachable("Value type size is target-dependent. Ask TLI.");
625 llvm_unreachable("Value type is overloaded.");
627 llvm_unreachable("Token type is a sentinel that cannot be used "
628 "in codegen and has no size");
630 llvm_unreachable("Value type is metadata.");
633 case nxv2i1: return 2;
635 case nxv4i1: return 4;
640 case nxv8i1: return 8;
648 case nxv1i16: return 16;
662 case nxv1f32: return 32;
680 case nxv1f64: return 64;
681 case f80 : return 80;
699 case nxv2f64: return 128;
711 case nxv4f64: return 256;
723 case nxv8f64: return 512;
730 case nxv16i64: return 1024;
735 case nxv32i64: return 2048;
739 unsigned getScalarSizeInBits() const {
740 return getScalarType().getSizeInBits();
743 /// Return the number of bytes overwritten by a store of the specified value
745 unsigned getStoreSize() const {
746 return (getSizeInBits() + 7) / 8;
749 /// Return the number of bits overwritten by a store of the specified value
751 unsigned getStoreSizeInBits() const {
752 return getStoreSize() * 8;
755 /// Return true if this has more bits than VT.
756 bool bitsGT(MVT VT) const {
757 return getSizeInBits() > VT.getSizeInBits();
760 /// Return true if this has no less bits than VT.
761 bool bitsGE(MVT VT) const {
762 return getSizeInBits() >= VT.getSizeInBits();
765 /// Return true if this has less bits than VT.
766 bool bitsLT(MVT VT) const {
767 return getSizeInBits() < VT.getSizeInBits();
770 /// Return true if this has no more bits than VT.
771 bool bitsLE(MVT VT) const {
772 return getSizeInBits() <= VT.getSizeInBits();
776 static MVT getFloatingPointVT(unsigned BitWidth) {
779 llvm_unreachable("Bad bit width!");
793 static MVT getIntegerVT(unsigned BitWidth) {
796 return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
812 static MVT getVectorVT(MVT VT, unsigned NumElements) {
813 switch (VT.SimpleTy) {
817 if (NumElements == 2) return MVT::v2i1;
818 if (NumElements == 4) return MVT::v4i1;
819 if (NumElements == 8) return MVT::v8i1;
820 if (NumElements == 16) return MVT::v16i1;
821 if (NumElements == 32) return MVT::v32i1;
822 if (NumElements == 64) return MVT::v64i1;
823 if (NumElements == 512) return MVT::v512i1;
824 if (NumElements == 1024) return MVT::v1024i1;
827 if (NumElements == 1) return MVT::v1i8;
828 if (NumElements == 2) return MVT::v2i8;
829 if (NumElements == 4) return MVT::v4i8;
830 if (NumElements == 8) return MVT::v8i8;
831 if (NumElements == 16) return MVT::v16i8;
832 if (NumElements == 32) return MVT::v32i8;
833 if (NumElements == 64) return MVT::v64i8;
834 if (NumElements == 128) return MVT::v128i8;
835 if (NumElements == 256) return MVT::v256i8;
838 if (NumElements == 1) return MVT::v1i16;
839 if (NumElements == 2) return MVT::v2i16;
840 if (NumElements == 4) return MVT::v4i16;
841 if (NumElements == 8) return MVT::v8i16;
842 if (NumElements == 16) return MVT::v16i16;
843 if (NumElements == 32) return MVT::v32i16;
844 if (NumElements == 64) return MVT::v64i16;
845 if (NumElements == 128) return MVT::v128i16;
848 if (NumElements == 1) return MVT::v1i32;
849 if (NumElements == 2) return MVT::v2i32;
850 if (NumElements == 4) return MVT::v4i32;
851 if (NumElements == 8) return MVT::v8i32;
852 if (NumElements == 16) return MVT::v16i32;
853 if (NumElements == 32) return MVT::v32i32;
854 if (NumElements == 64) return MVT::v64i32;
857 if (NumElements == 1) return MVT::v1i64;
858 if (NumElements == 2) return MVT::v2i64;
859 if (NumElements == 4) return MVT::v4i64;
860 if (NumElements == 8) return MVT::v8i64;
861 if (NumElements == 16) return MVT::v16i64;
862 if (NumElements == 32) return MVT::v32i64;
865 if (NumElements == 1) return MVT::v1i128;
868 if (NumElements == 2) return MVT::v2f16;
869 if (NumElements == 4) return MVT::v4f16;
870 if (NumElements == 8) return MVT::v8f16;
873 if (NumElements == 1) return MVT::v1f32;
874 if (NumElements == 2) return MVT::v2f32;
875 if (NumElements == 4) return MVT::v4f32;
876 if (NumElements == 8) return MVT::v8f32;
877 if (NumElements == 16) return MVT::v16f32;
880 if (NumElements == 1) return MVT::v1f64;
881 if (NumElements == 2) return MVT::v2f64;
882 if (NumElements == 4) return MVT::v4f64;
883 if (NumElements == 8) return MVT::v8f64;
886 return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
889 static MVT getScalableVectorVT(MVT VT, unsigned NumElements) {
890 switch(VT.SimpleTy) {
894 if (NumElements == 2) return MVT::nxv2i1;
895 if (NumElements == 4) return MVT::nxv4i1;
896 if (NumElements == 8) return MVT::nxv8i1;
897 if (NumElements == 16) return MVT::nxv16i1;
898 if (NumElements == 32) return MVT::nxv32i1;
901 if (NumElements == 1) return MVT::nxv1i8;
902 if (NumElements == 2) return MVT::nxv2i8;
903 if (NumElements == 4) return MVT::nxv4i8;
904 if (NumElements == 8) return MVT::nxv8i8;
905 if (NumElements == 16) return MVT::nxv16i8;
906 if (NumElements == 32) return MVT::nxv32i8;
909 if (NumElements == 1) return MVT::nxv1i16;
910 if (NumElements == 2) return MVT::nxv2i16;
911 if (NumElements == 4) return MVT::nxv4i16;
912 if (NumElements == 8) return MVT::nxv8i16;
913 if (NumElements == 16) return MVT::nxv16i16;
914 if (NumElements == 32) return MVT::nxv32i16;
917 if (NumElements == 1) return MVT::nxv1i32;
918 if (NumElements == 2) return MVT::nxv2i32;
919 if (NumElements == 4) return MVT::nxv4i32;
920 if (NumElements == 8) return MVT::nxv8i32;
921 if (NumElements == 16) return MVT::nxv16i32;
922 if (NumElements == 32) return MVT::nxv32i32;
925 if (NumElements == 1) return MVT::nxv1i64;
926 if (NumElements == 2) return MVT::nxv2i64;
927 if (NumElements == 4) return MVT::nxv4i64;
928 if (NumElements == 8) return MVT::nxv8i64;
929 if (NumElements == 16) return MVT::nxv16i64;
930 if (NumElements == 32) return MVT::nxv32i64;
933 if (NumElements == 2) return MVT::nxv2f16;
934 if (NumElements == 4) return MVT::nxv4f16;
935 if (NumElements == 8) return MVT::nxv8f16;
938 if (NumElements == 1) return MVT::nxv1f32;
939 if (NumElements == 2) return MVT::nxv2f32;
940 if (NumElements == 4) return MVT::nxv4f32;
941 if (NumElements == 8) return MVT::nxv8f32;
942 if (NumElements == 16) return MVT::nxv16f32;
945 if (NumElements == 1) return MVT::nxv1f64;
946 if (NumElements == 2) return MVT::nxv2f64;
947 if (NumElements == 4) return MVT::nxv4f64;
948 if (NumElements == 8) return MVT::nxv8f64;
951 return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
954 static MVT getVectorVT(MVT VT, unsigned NumElements, bool IsScalable) {
956 return getScalableVectorVT(VT, NumElements);
957 return getVectorVT(VT, NumElements);
960 static MVT getVectorVT(MVT VT, MVT::ElementCount EC) {
962 return getScalableVectorVT(VT, EC.Min);
963 return getVectorVT(VT, EC.Min);
966 /// Return the value type corresponding to the specified type. This returns
967 /// all pointers as iPTR. If HandleUnknown is true, unknown types are
968 /// returned as Other, otherwise they are invalid.
969 static MVT getVT(Type *Ty, bool HandleUnknown = false);
972 /// A simple iterator over the MVT::SimpleValueType enum.
973 struct mvt_iterator {
975 mvt_iterator(SimpleValueType VT) : VT(VT) {}
976 MVT operator*() const { return VT; }
977 bool operator!=(const mvt_iterator &LHS) const { return VT != LHS.VT; }
978 mvt_iterator& operator++() {
979 VT = (MVT::SimpleValueType)((int)VT + 1);
980 assert((int)VT <= MVT::MAX_ALLOWED_VALUETYPE &&
981 "MVT iterator overflowed.");
985 /// A range of the MVT::SimpleValueType enum.
986 typedef iterator_range<mvt_iterator> mvt_range;
989 /// SimpleValueType Iteration
991 static mvt_range all_valuetypes() {
992 return mvt_range(MVT::FIRST_VALUETYPE, MVT::LAST_VALUETYPE);
994 static mvt_range integer_valuetypes() {
995 return mvt_range(MVT::FIRST_INTEGER_VALUETYPE,
996 (MVT::SimpleValueType)(MVT::LAST_INTEGER_VALUETYPE + 1));
998 static mvt_range fp_valuetypes() {
999 return mvt_range(MVT::FIRST_FP_VALUETYPE,
1000 (MVT::SimpleValueType)(MVT::LAST_FP_VALUETYPE + 1));
1002 static mvt_range vector_valuetypes() {
1003 return mvt_range(MVT::FIRST_VECTOR_VALUETYPE,
1004 (MVT::SimpleValueType)(MVT::LAST_VECTOR_VALUETYPE + 1));
1006 static mvt_range integer_vector_valuetypes() {
1008 MVT::FIRST_INTEGER_VECTOR_VALUETYPE,
1009 (MVT::SimpleValueType)(MVT::LAST_INTEGER_VECTOR_VALUETYPE + 1));
1011 static mvt_range fp_vector_valuetypes() {
1013 MVT::FIRST_FP_VECTOR_VALUETYPE,
1014 (MVT::SimpleValueType)(MVT::LAST_FP_VECTOR_VALUETYPE + 1));
1016 static mvt_range integer_scalable_vector_valuetypes() {
1017 return mvt_range(MVT::FIRST_INTEGER_SCALABLE_VALUETYPE,
1018 (MVT::SimpleValueType)(MVT::LAST_INTEGER_SCALABLE_VALUETYPE + 1));
1020 static mvt_range fp_scalable_vector_valuetypes() {
1021 return mvt_range(MVT::FIRST_FP_SCALABLE_VALUETYPE,
1022 (MVT::SimpleValueType)(MVT::LAST_FP_SCALABLE_VALUETYPE + 1));
1027 } // End llvm namespace