xref: /freebsd/contrib/llvm-project/llvm/include/llvm/CodeGenTypes/MachineValueType.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===- CodeGenTypes/MachineValueType.h - Machine-Level types ----*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the set of machine-level target independent types which
10 // legal values in the code generator use.
11 //
12 // Constants and properties are defined in ValueTypes.td.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_CODEGEN_MACHINEVALUETYPE_H
17 #define LLVM_CODEGEN_MACHINEVALUETYPE_H
18 
19 #include "llvm/ADT/Sequence.h"
20 #include "llvm/Support/Compiler.h"
21 #include "llvm/Support/ErrorHandling.h"
22 #include "llvm/Support/MathExtras.h"
23 #include "llvm/Support/TypeSize.h"
24 #include <cassert>
25 #include <cstdint>
26 
27 namespace llvm {
28 
29   class Type;
30   struct fltSemantics;
31   class raw_ostream;
32 
33   /// Machine Value Type. Every type that is supported natively by some
34   /// processor targeted by LLVM occurs here. This means that any legal value
35   /// type can be represented by an MVT.
36   class MVT {
37   public:
38     enum SimpleValueType : uint16_t {
39       // Simple value types that aren't explicitly part of this enumeration
40       // are considered extended value types.
41       INVALID_SIMPLE_VALUE_TYPE = 0,
42 
43 #define GET_VT_ATTR(Ty, n, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
44     Ty = n,
45 #define GET_VT_RANGES
46 #include "llvm/CodeGen/GenVT.inc"
47 #undef GET_VT_ATTR
48 #undef GET_VT_RANGES
49 
50       VALUETYPE_SIZE = LAST_VALUETYPE + 1,
51     };
52 
53     static_assert(FIRST_VALUETYPE > 0);
54     static_assert(LAST_VALUETYPE < token);
55 
56     SimpleValueType SimpleTy = INVALID_SIMPLE_VALUE_TYPE;
57 
58     constexpr MVT() = default;
MVT(SimpleValueType SVT)59     constexpr MVT(SimpleValueType SVT) : SimpleTy(SVT) {}
60 
61     bool operator>(const MVT& S)  const { return SimpleTy >  S.SimpleTy; }
62     bool operator<(const MVT& S)  const { return SimpleTy <  S.SimpleTy; }
63     bool operator==(const MVT& S) const { return SimpleTy == S.SimpleTy; }
64     bool operator!=(const MVT& S) const { return SimpleTy != S.SimpleTy; }
65     bool operator>=(const MVT& S) const { return SimpleTy >= S.SimpleTy; }
66     bool operator<=(const MVT& S) const { return SimpleTy <= S.SimpleTy; }
67 
68     /// Support for debugging, callable in GDB: VT.dump()
69     LLVM_ABI void dump() const;
70 
71     /// Implement operator<<.
72     LLVM_ABI void print(raw_ostream &OS) const;
73 
74     /// Return true if this is a valid simple valuetype.
isValid()75     bool isValid() const {
76       return (SimpleTy >= MVT::FIRST_VALUETYPE &&
77               SimpleTy <= MVT::LAST_VALUETYPE);
78     }
79 
80     /// Return true if this is a FP or a vector FP type.
isFloatingPoint()81     bool isFloatingPoint() const {
82       return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE &&
83                SimpleTy <= MVT::LAST_FP_VALUETYPE) ||
84               (SimpleTy >= MVT::FIRST_FP_FIXEDLEN_VECTOR_VALUETYPE &&
85                SimpleTy <= MVT::LAST_FP_FIXEDLEN_VECTOR_VALUETYPE) ||
86               (SimpleTy >= MVT::FIRST_FP_SCALABLE_VECTOR_VALUETYPE &&
87                SimpleTy <= MVT::LAST_FP_SCALABLE_VECTOR_VALUETYPE));
88     }
89 
90     /// Return true if this is an integer or a vector integer type.
isInteger()91     bool isInteger() const {
92       return ((SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
93                SimpleTy <= MVT::LAST_INTEGER_VALUETYPE) ||
94               (SimpleTy >= MVT::FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE &&
95                SimpleTy <= MVT::LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE) ||
96               (SimpleTy >= MVT::FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE &&
97                SimpleTy <= MVT::LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE));
98     }
99 
100     /// Return true if this is an integer, not including vectors.
isScalarInteger()101     bool isScalarInteger() const {
102       return (SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
103               SimpleTy <= MVT::LAST_INTEGER_VALUETYPE);
104     }
105 
106     /// Return true if this is a vector value type.
isVector()107     bool isVector() const {
108       return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE &&
109               SimpleTy <= MVT::LAST_VECTOR_VALUETYPE);
110     }
111 
112     /// Return true if this is a vector value type where the
113     /// runtime length is machine dependent
isScalableVector()114     bool isScalableVector() const {
115       return (SimpleTy >= MVT::FIRST_SCALABLE_VECTOR_VALUETYPE &&
116               SimpleTy <= MVT::LAST_SCALABLE_VECTOR_VALUETYPE);
117     }
118 
119     /// Return true if this is a RISCV vector tuple type where the
120     /// runtime length is machine dependent
isRISCVVectorTuple()121     bool isRISCVVectorTuple() const {
122       return (SimpleTy >= MVT::FIRST_RISCV_VECTOR_TUPLE_VALUETYPE &&
123               SimpleTy <= MVT::LAST_RISCV_VECTOR_TUPLE_VALUETYPE);
124     }
125 
126     /// Return true if this is a custom target type that has a scalable size.
isScalableTargetExtVT()127     bool isScalableTargetExtVT() const {
128       return SimpleTy == MVT::aarch64svcount || isRISCVVectorTuple();
129     }
130 
131     /// Return true if the type is a scalable type.
isScalableVT()132     bool isScalableVT() const {
133       return isScalableVector() || isScalableTargetExtVT();
134     }
135 
isFixedLengthVector()136     bool isFixedLengthVector() const {
137       return (SimpleTy >= MVT::FIRST_FIXEDLEN_VECTOR_VALUETYPE &&
138               SimpleTy <= MVT::LAST_FIXEDLEN_VECTOR_VALUETYPE);
139     }
140 
141     /// Return true if this is a 16-bit vector type.
is16BitVector()142     bool is16BitVector() const {
143       return (isFixedLengthVector() && getFixedSizeInBits() == 16);
144     }
145 
146     /// Return true if this is a 32-bit vector type.
is32BitVector()147     bool is32BitVector() const {
148       return (isFixedLengthVector() && getFixedSizeInBits() == 32);
149     }
150 
151     /// Return true if this is a 64-bit vector type.
is64BitVector()152     bool is64BitVector() const {
153       return (isFixedLengthVector() && getFixedSizeInBits() == 64);
154     }
155 
156     /// Return true if this is a 128-bit vector type.
is128BitVector()157     bool is128BitVector() const {
158       return (isFixedLengthVector() && getFixedSizeInBits() == 128);
159     }
160 
161     /// Return true if this is a 256-bit vector type.
is256BitVector()162     bool is256BitVector() const {
163       return (isFixedLengthVector() && getFixedSizeInBits() == 256);
164     }
165 
166     /// Return true if this is a 512-bit vector type.
is512BitVector()167     bool is512BitVector() const {
168       return (isFixedLengthVector() && getFixedSizeInBits() == 512);
169     }
170 
171     /// Return true if this is a 1024-bit vector type.
is1024BitVector()172     bool is1024BitVector() const {
173       return (isFixedLengthVector() && getFixedSizeInBits() == 1024);
174     }
175 
176     /// Return true if this is a 2048-bit vector type.
is2048BitVector()177     bool is2048BitVector() const {
178       return (isFixedLengthVector() && getFixedSizeInBits() == 2048);
179     }
180 
181     /// Return true if this is an overloaded type for TableGen.
isOverloaded()182     bool isOverloaded() const {
183       switch (SimpleTy) {
184 #define GET_VT_ATTR(Ty, n, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
185     case Ty:                                                                   \
186       return Any;
187 #include "llvm/CodeGen/GenVT.inc"
188 #undef GET_VT_ATTR
189       default:
190         return false;
191       }
192     }
193 
194     /// Return a vector with the same number of elements as this vector, but
195     /// with the element type converted to an integer type with the same
196     /// bitwidth.
changeVectorElementTypeToInteger()197     MVT changeVectorElementTypeToInteger() const {
198       MVT EltTy = getVectorElementType();
199       MVT IntTy = MVT::getIntegerVT(EltTy.getSizeInBits());
200       MVT VecTy = MVT::getVectorVT(IntTy, getVectorElementCount());
201       assert(VecTy.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE &&
202              "Simple vector VT not representable by simple integer vector VT!");
203       return VecTy;
204     }
205 
206     /// Return a VT for a vector type whose attributes match ourselves
207     /// with the exception of the element type that is chosen by the caller.
changeVectorElementType(MVT EltVT)208     MVT changeVectorElementType(MVT EltVT) const {
209       MVT VecTy = MVT::getVectorVT(EltVT, getVectorElementCount());
210       assert(VecTy.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE &&
211              "Simple vector VT not representable by simple integer vector VT!");
212       return VecTy;
213     }
214 
215     /// Return the type converted to an equivalently sized integer or vector
216     /// with integer element type. Similar to changeVectorElementTypeToInteger,
217     /// but also handles scalars.
changeTypeToInteger()218     MVT changeTypeToInteger() {
219       if (isVector())
220         return changeVectorElementTypeToInteger();
221       return MVT::getIntegerVT(getSizeInBits());
222     }
223 
224     /// Return a VT for a vector type with the same element type but
225     /// half the number of elements.
getHalfNumVectorElementsVT()226     MVT getHalfNumVectorElementsVT() const {
227       MVT EltVT = getVectorElementType();
228       auto EltCnt = getVectorElementCount();
229       assert(EltCnt.isKnownEven() && "Splitting vector, but not in half!");
230       return getVectorVT(EltVT, EltCnt.divideCoefficientBy(2));
231     }
232 
233     // Return a VT for a vector type with the same element type but
234     // double the number of elements.
getDoubleNumVectorElementsVT()235     MVT getDoubleNumVectorElementsVT() const {
236       MVT EltVT = getVectorElementType();
237       auto EltCnt = getVectorElementCount();
238       return MVT::getVectorVT(EltVT, EltCnt * 2);
239     }
240 
241     /// Returns true if the given vector is a power of 2.
isPow2VectorType()242     bool isPow2VectorType() const {
243       unsigned NElts = getVectorMinNumElements();
244       return !(NElts & (NElts - 1));
245     }
246 
247     /// Widens the length of the given vector MVT up to the nearest power of 2
248     /// and returns that type.
getPow2VectorType()249     MVT getPow2VectorType() const {
250       if (isPow2VectorType())
251         return *this;
252 
253       ElementCount NElts = getVectorElementCount();
254       unsigned NewMinCount = 1 << Log2_32_Ceil(NElts.getKnownMinValue());
255       NElts = ElementCount::get(NewMinCount, NElts.isScalable());
256       return MVT::getVectorVT(getVectorElementType(), NElts);
257     }
258 
259     /// If this is a vector, return the element type, otherwise return this.
getScalarType()260     MVT getScalarType() const {
261       return isVector() ? getVectorElementType() : *this;
262     }
263 
getVectorElementType()264     MVT getVectorElementType() const {
265       assert(SimpleTy >= FIRST_VALUETYPE && SimpleTy <= LAST_VALUETYPE);
266       static constexpr SimpleValueType EltTyTable[] = {
267 #define GET_VT_ATTR(Ty, N, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
268     EltTy,
269 #include "llvm/CodeGen/GenVT.inc"
270 #undef GET_VT_ATTR
271       };
272       SimpleValueType VT = EltTyTable[SimpleTy - FIRST_VALUETYPE];
273       assert(VT != INVALID_SIMPLE_VALUE_TYPE && "Not a vector MVT!");
274       return VT;
275     }
276 
277     /// Given a vector type, return the minimum number of elements it contains.
getVectorMinNumElements()278     unsigned getVectorMinNumElements() const {
279       assert(SimpleTy >= FIRST_VALUETYPE && SimpleTy <= LAST_VALUETYPE);
280       static constexpr uint16_t NElemTable[] = {
281 #define GET_VT_ATTR(Ty, N, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
282     NElem,
283 #include "llvm/CodeGen/GenVT.inc"
284 #undef GET_VT_ATTR
285       };
286       unsigned NElem = NElemTable[SimpleTy - FIRST_VALUETYPE];
287       assert(NElem != 0 && "Not a vector MVT!");
288       return NElem;
289     }
290 
getVectorElementCount()291     ElementCount getVectorElementCount() const {
292       return ElementCount::get(getVectorMinNumElements(), isScalableVector());
293     }
294 
getVectorNumElements()295     unsigned getVectorNumElements() const {
296       if (isScalableVector())
297         llvm::reportInvalidSizeRequest(
298             "Possible incorrect use of MVT::getVectorNumElements() for "
299             "scalable vector. Scalable flag may be dropped, use "
300             "MVT::getVectorElementCount() instead");
301       return getVectorMinNumElements();
302     }
303 
304     /// Returns the size of the specified MVT in bits.
305     ///
306     /// If the value type is a scalable vector type, the scalable property will
307     /// be set and the runtime size will be a positive integer multiple of the
308     /// base size.
getSizeInBits()309     TypeSize getSizeInBits() const {
310       static constexpr TypeSize SizeTable[] = {
311 #define GET_VT_ATTR(Ty, N, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
312     TypeSize(Sz, Sc || Tup || Ty == aarch64svcount /* FIXME: Not in the td.    \
313                                                     */),
314 #include "llvm/CodeGen/GenVT.inc"
315 #undef GET_VT_ATTR
316       };
317 
318       switch (SimpleTy) {
319       case INVALID_SIMPLE_VALUE_TYPE:
320         llvm_unreachable("getSizeInBits called on extended MVT.");
321       case Other:
322         llvm_unreachable("Value type is non-standard value, Other.");
323       case iPTR:
324         llvm_unreachable("Value type size is target-dependent. Ask TLI.");
325       case pAny:
326       case iAny:
327       case fAny:
328       case vAny:
329       case Any:
330         llvm_unreachable("Value type is overloaded.");
331       case token:
332         llvm_unreachable("Token type is a sentinel that cannot be used "
333                          "in codegen and has no size");
334       case Metadata:
335         llvm_unreachable("Value type is metadata.");
336       default:
337         assert(SimpleTy < VALUETYPE_SIZE && "Unexpected value type!");
338         return SizeTable[SimpleTy - FIRST_VALUETYPE];
339       }
340     }
341 
342     /// Return the size of the specified fixed width value type in bits. The
343     /// function will assert if the type is scalable.
getFixedSizeInBits()344     uint64_t getFixedSizeInBits() const {
345       return getSizeInBits().getFixedValue();
346     }
347 
getScalarSizeInBits()348     uint64_t getScalarSizeInBits() const {
349       return getScalarType().getSizeInBits().getFixedValue();
350     }
351 
352     /// Return the number of bytes overwritten by a store of the specified value
353     /// type.
354     ///
355     /// If the value type is a scalable vector type, the scalable property will
356     /// be set and the runtime size will be a positive integer multiple of the
357     /// base size.
getStoreSize()358     TypeSize getStoreSize() const {
359       TypeSize BaseSize = getSizeInBits();
360       return {(BaseSize.getKnownMinValue() + 7) / 8, BaseSize.isScalable()};
361     }
362 
363     // Return the number of bytes overwritten by a store of this value type or
364     // this value type's element type in the case of a vector.
getScalarStoreSize()365     uint64_t getScalarStoreSize() const {
366       return getScalarType().getStoreSize().getFixedValue();
367     }
368 
369     /// Return the number of bits overwritten by a store of the specified value
370     /// type.
371     ///
372     /// If the value type is a scalable vector type, the scalable property will
373     /// be set and the runtime size will be a positive integer multiple of the
374     /// base size.
getStoreSizeInBits()375     TypeSize getStoreSizeInBits() const {
376       return getStoreSize() * 8;
377     }
378 
379     /// Returns true if the number of bits for the type is a multiple of an
380     /// 8-bit byte.
isByteSized()381     bool isByteSized() const { return getSizeInBits().isKnownMultipleOf(8); }
382 
383     /// Return true if we know at compile time this has more bits than VT.
knownBitsGT(MVT VT)384     bool knownBitsGT(MVT VT) const {
385       return TypeSize::isKnownGT(getSizeInBits(), VT.getSizeInBits());
386     }
387 
388     /// Return true if we know at compile time this has more than or the same
389     /// bits as VT.
knownBitsGE(MVT VT)390     bool knownBitsGE(MVT VT) const {
391       return TypeSize::isKnownGE(getSizeInBits(), VT.getSizeInBits());
392     }
393 
394     /// Return true if we know at compile time this has fewer bits than VT.
knownBitsLT(MVT VT)395     bool knownBitsLT(MVT VT) const {
396       return TypeSize::isKnownLT(getSizeInBits(), VT.getSizeInBits());
397     }
398 
399     /// Return true if we know at compile time this has fewer than or the same
400     /// bits as VT.
knownBitsLE(MVT VT)401     bool knownBitsLE(MVT VT) const {
402       return TypeSize::isKnownLE(getSizeInBits(), VT.getSizeInBits());
403     }
404 
405     /// Return true if this has more bits than VT.
bitsGT(MVT VT)406     bool bitsGT(MVT VT) const {
407       assert(isScalableVector() == VT.isScalableVector() &&
408              "Comparison between scalable and fixed types");
409       return knownBitsGT(VT);
410     }
411 
412     /// Return true if this has no less bits than VT.
bitsGE(MVT VT)413     bool bitsGE(MVT VT) const {
414       assert(isScalableVector() == VT.isScalableVector() &&
415              "Comparison between scalable and fixed types");
416       return knownBitsGE(VT);
417     }
418 
419     /// Return true if this has less bits than VT.
bitsLT(MVT VT)420     bool bitsLT(MVT VT) const {
421       assert(isScalableVector() == VT.isScalableVector() &&
422              "Comparison between scalable and fixed types");
423       return knownBitsLT(VT);
424     }
425 
426     /// Return true if this has no more bits than VT.
bitsLE(MVT VT)427     bool bitsLE(MVT VT) const {
428       assert(isScalableVector() == VT.isScalableVector() &&
429              "Comparison between scalable and fixed types");
430       return knownBitsLE(VT);
431     }
432 
getFloatingPointVT(unsigned BitWidth)433     static MVT getFloatingPointVT(unsigned BitWidth) {
434 #define GET_VT_ATTR(Ty, n, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
435     if (FP == 3 && sz == BitWidth)                                             \
436       return Ty;
437 #include "llvm/CodeGen/GenVT.inc"
438 #undef GET_VT_ATTR
439 
440       llvm_unreachable("Bad bit width!");
441     }
442 
getIntegerVT(unsigned BitWidth)443     static MVT getIntegerVT(unsigned BitWidth) {
444 #define GET_VT_ATTR(Ty, n, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
445     if (Int == 3 && sz == BitWidth)                                            \
446       return Ty;
447 #include "llvm/CodeGen/GenVT.inc"
448 #undef GET_VT_ATTR
449 
450       return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
451     }
452 
getVectorVT(MVT VT,unsigned NumElements)453     static MVT getVectorVT(MVT VT, unsigned NumElements) {
454 #define GET_VT_VECATTR(Ty, Sc, Tup, nElem, ElTy)                             \
455     if (!Sc && !Tup && VT.SimpleTy == ElTy && NumElements == nElem)            \
456       return Ty;
457 #include "llvm/CodeGen/GenVT.inc"
458 #undef GET_VT_VECATTR
459 
460       return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
461     }
462 
getScalableVectorVT(MVT VT,unsigned NumElements)463     static MVT getScalableVectorVT(MVT VT, unsigned NumElements) {
464 #define GET_VT_VECATTR(Ty, Sc, Tup, nElem, ElTy)                             \
465     if (Sc && VT.SimpleTy == ElTy && NumElements == nElem)                     \
466       return Ty;
467 #include "llvm/CodeGen/GenVT.inc"
468 #undef GET_VT_VECATTR
469 
470       return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
471     }
472 
getRISCVVectorTupleVT(unsigned Sz,unsigned NFields)473     static MVT getRISCVVectorTupleVT(unsigned Sz, unsigned NFields) {
474 #define GET_VT_ATTR(Ty, n, sz, Any, Int, FP, Vec, Sc, Tup, NF, nElem, EltTy) \
475     if (Tup && sz == Sz && NF == NFields)                                      \
476       return Ty;
477 #include "llvm/CodeGen/GenVT.inc"
478 #undef GET_VT_ATTR
479 
480       llvm_unreachable("Invalid RISCV vector tuple type");
481     }
482 
483     /// Given a RISC-V vector tuple type, return the num_fields.
getRISCVVectorTupleNumFields()484     unsigned getRISCVVectorTupleNumFields() const {
485       assert(isRISCVVectorTuple() && SimpleTy >= FIRST_VALUETYPE &&
486              SimpleTy <= LAST_VALUETYPE);
487       static constexpr uint8_t NFTable[] = {
488 #define GET_VT_ATTR(Ty, N, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
489     NF,
490 #include "llvm/CodeGen/GenVT.inc"
491 #undef GET_VT_ATTR
492       };
493       return NFTable[SimpleTy - FIRST_VALUETYPE];
494     }
495 
getVectorVT(MVT VT,unsigned NumElements,bool IsScalable)496     static MVT getVectorVT(MVT VT, unsigned NumElements, bool IsScalable) {
497       if (IsScalable)
498         return getScalableVectorVT(VT, NumElements);
499       return getVectorVT(VT, NumElements);
500     }
501 
getVectorVT(MVT VT,ElementCount EC)502     static MVT getVectorVT(MVT VT, ElementCount EC) {
503       if (EC.isScalable())
504         return getScalableVectorVT(VT, EC.getKnownMinValue());
505       return getVectorVT(VT, EC.getKnownMinValue());
506     }
507 
508     /// Return the value type corresponding to the specified type.
509     /// If HandleUnknown is true, unknown types are returned as Other,
510     /// otherwise they are invalid.
511     /// NB: This includes pointer types, which require a DataLayout to convert
512     /// to a concrete value type.
513     LLVM_ABI static MVT getVT(Type *Ty, bool HandleUnknown = false);
514 
515     /// Returns an APFloat semantics tag appropriate for the value type. If this
516     /// is a vector type, the element semantics are returned.
517     LLVM_ABI const fltSemantics &getFltSemantics() const;
518 
519   public:
520     /// SimpleValueType Iteration
521     /// @{
all_valuetypes()522     static auto all_valuetypes() {
523       return enum_seq_inclusive(MVT::FIRST_VALUETYPE, MVT::LAST_VALUETYPE,
524                                 force_iteration_on_noniterable_enum);
525     }
526 
integer_valuetypes()527     static auto integer_valuetypes() {
528       return enum_seq_inclusive(MVT::FIRST_INTEGER_VALUETYPE,
529                                 MVT::LAST_INTEGER_VALUETYPE,
530                                 force_iteration_on_noniterable_enum);
531     }
532 
fp_valuetypes()533     static auto fp_valuetypes() {
534       return enum_seq_inclusive(MVT::FIRST_FP_VALUETYPE, MVT::LAST_FP_VALUETYPE,
535                                 force_iteration_on_noniterable_enum);
536     }
537 
vector_valuetypes()538     static auto vector_valuetypes() {
539       return enum_seq_inclusive(MVT::FIRST_VECTOR_VALUETYPE,
540                                 MVT::LAST_VECTOR_VALUETYPE,
541                                 force_iteration_on_noniterable_enum);
542     }
543 
fixedlen_vector_valuetypes()544     static auto fixedlen_vector_valuetypes() {
545       return enum_seq_inclusive(MVT::FIRST_FIXEDLEN_VECTOR_VALUETYPE,
546                                 MVT::LAST_FIXEDLEN_VECTOR_VALUETYPE,
547                                 force_iteration_on_noniterable_enum);
548     }
549 
scalable_vector_valuetypes()550     static auto scalable_vector_valuetypes() {
551       return enum_seq_inclusive(MVT::FIRST_SCALABLE_VECTOR_VALUETYPE,
552                                 MVT::LAST_SCALABLE_VECTOR_VALUETYPE,
553                                 force_iteration_on_noniterable_enum);
554     }
555 
integer_fixedlen_vector_valuetypes()556     static auto integer_fixedlen_vector_valuetypes() {
557       return enum_seq_inclusive(MVT::FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE,
558                                 MVT::LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE,
559                                 force_iteration_on_noniterable_enum);
560     }
561 
fp_fixedlen_vector_valuetypes()562     static auto fp_fixedlen_vector_valuetypes() {
563       return enum_seq_inclusive(MVT::FIRST_FP_FIXEDLEN_VECTOR_VALUETYPE,
564                                 MVT::LAST_FP_FIXEDLEN_VECTOR_VALUETYPE,
565                                 force_iteration_on_noniterable_enum);
566     }
567 
integer_scalable_vector_valuetypes()568     static auto integer_scalable_vector_valuetypes() {
569       return enum_seq_inclusive(MVT::FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE,
570                                 MVT::LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE,
571                                 force_iteration_on_noniterable_enum);
572     }
573 
fp_scalable_vector_valuetypes()574     static auto fp_scalable_vector_valuetypes() {
575       return enum_seq_inclusive(MVT::FIRST_FP_SCALABLE_VECTOR_VALUETYPE,
576                                 MVT::LAST_FP_SCALABLE_VECTOR_VALUETYPE,
577                                 force_iteration_on_noniterable_enum);
578     }
579     /// @}
580   };
581 
582   inline raw_ostream &operator<<(raw_ostream &OS, const MVT &VT) {
583     VT.print(OS);
584     return OS;
585   }
586 
587 } // end namespace llvm
588 
589 #endif // LLVM_CODEGEN_MACHINEVALUETYPE_H
590