LLVM 24.0.0git
MachineValueType.h
Go to the documentation of this file.
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"
24#include <cassert>
25#include <cstdint>
26
27namespace 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:
39 // Simple value types that aren't explicitly part of this enumeration
40 // are considered extended value types.
42
43#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) Ty,
44#define GET_VT_RANGES
45#include "llvm/CodeGen/GenVT.inc"
46#undef GET_VT_ATTR
47#undef GET_VT_RANGES
48
49 VALUETYPE_SIZE = LAST_VALUETYPE + 1,
50 };
51
52 static_assert(FIRST_VALUETYPE > 0);
53 static_assert(LAST_VALUETYPE < token);
54
56
57 constexpr MVT() = default;
58 constexpr MVT(SimpleValueType SVT) : SimpleTy(SVT) {}
59
60 bool operator>(const MVT& S) const { return SimpleTy > S.SimpleTy; }
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
67 // Support comparison with SimpleValueType.
68 bool operator==(SimpleValueType S) const { return SimpleTy == S; }
69 bool operator!=(SimpleValueType S) const { return SimpleTy != S; }
70
71 /// Support for debugging, callable in GDB: VT.dump()
72 LLVM_ABI void dump() const;
73
74 /// Implement operator<<.
75 LLVM_ABI void print(raw_ostream &OS) const;
76
77 /// Return true if this is a valid simple valuetype.
78 bool isValid() const {
79 return (SimpleTy >= MVT::FIRST_VALUETYPE &&
80 SimpleTy <= MVT::LAST_VALUETYPE);
81 }
82
83 /// Return true if this is a FP or a vector FP type.
84 bool isFloatingPoint() const {
85 return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE &&
86 SimpleTy <= MVT::LAST_FP_VALUETYPE) ||
87 (SimpleTy >= MVT::FIRST_FP_FIXEDLEN_VECTOR_VALUETYPE &&
88 SimpleTy <= MVT::LAST_FP_FIXEDLEN_VECTOR_VALUETYPE) ||
89 (SimpleTy >= MVT::FIRST_FP_SCALABLE_VECTOR_VALUETYPE &&
90 SimpleTy <= MVT::LAST_FP_SCALABLE_VECTOR_VALUETYPE));
91 }
92
93 /// Return true if this is an integer or a vector integer type.
94 bool isInteger() const {
95 return ((SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
96 SimpleTy <= MVT::LAST_INTEGER_VALUETYPE) ||
97 (SimpleTy >= MVT::FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE &&
98 SimpleTy <= MVT::LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE) ||
99 (SimpleTy >= MVT::FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE &&
100 SimpleTy <= MVT::LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE));
101 }
102
103 /// Return true if this is an integer, not including vectors.
104 bool isScalarInteger() const {
105 return (SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
106 SimpleTy <= MVT::LAST_INTEGER_VALUETYPE);
107 }
108
109 /// Return true if this is a vector value type.
110 bool isVector() const {
111 return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE &&
112 SimpleTy <= MVT::LAST_VECTOR_VALUETYPE);
113 }
114
115 /// Return true if this is a vector with matching element type.
116 bool isVectorOf(MVT EltVT) const {
117 return isVector() && getVectorElementType() == EltVT;
118 }
119
120 /// Return true if this is a vector value type where the
121 /// runtime length is machine dependent
122 bool isScalableVector() const {
123 return (SimpleTy >= MVT::FIRST_SCALABLE_VECTOR_VALUETYPE &&
124 SimpleTy <= MVT::LAST_SCALABLE_VECTOR_VALUETYPE);
125 }
126
127 /// Return true if this is a scalable vector with matching element type.
128 bool isScalableVectorOf(MVT EltVT) const {
129 return isScalableVector() && getVectorElementType() == EltVT;
130 }
131
132 /// Return true if this is a RISCV vector tuple type where the
133 /// runtime length is machine dependent
134 bool isRISCVVectorTuple() const {
135 return (SimpleTy >= MVT::FIRST_RISCV_VECTOR_TUPLE_VALUETYPE &&
136 SimpleTy <= MVT::LAST_RISCV_VECTOR_TUPLE_VALUETYPE);
137 }
138
139 /// Return true if this is a custom target type that has a scalable size.
141 return SimpleTy == MVT::aarch64svcount || isRISCVVectorTuple();
142 }
143
144 /// Return true if the type is a scalable type.
145 bool isScalableVT() const {
147 }
148
149 bool isFixedLengthVector() const {
150 return (SimpleTy >= MVT::FIRST_FIXEDLEN_VECTOR_VALUETYPE &&
151 SimpleTy <= MVT::LAST_FIXEDLEN_VECTOR_VALUETYPE);
152 }
153
154 /// Return true if this is a fixed length vector with matching element type.
155 bool isFixedLengthVectorOf(MVT EltVT) const {
156 return isFixedLengthVector() && getVectorElementType() == EltVT;
157 }
158
159 /// Return true if this is a 16-bit vector type.
160 bool is16BitVector() const {
161 return (isFixedLengthVector() && getFixedSizeInBits() == 16);
162 }
163
164 /// Return true if this is a 32-bit vector type.
165 bool is32BitVector() const {
166 return (isFixedLengthVector() && getFixedSizeInBits() == 32);
167 }
168
169 /// Return true if this is a 64-bit vector type.
170 bool is64BitVector() const {
171 return (isFixedLengthVector() && getFixedSizeInBits() == 64);
172 }
173
174 /// Return true if this is a 128-bit vector type.
175 bool is128BitVector() const {
176 return (isFixedLengthVector() && getFixedSizeInBits() == 128);
177 }
178
179 /// Return true if this is a 256-bit vector type.
180 bool is256BitVector() const {
181 return (isFixedLengthVector() && getFixedSizeInBits() == 256);
182 }
183
184 /// Return true if this is a 512-bit vector type.
185 bool is512BitVector() const {
186 return (isFixedLengthVector() && getFixedSizeInBits() == 512);
187 }
188
189 /// Return true if this is a 1024-bit vector type.
190 bool is1024BitVector() const {
191 return (isFixedLengthVector() && getFixedSizeInBits() == 1024);
192 }
193
194 /// Return true if this is a 2048-bit vector type.
195 bool is2048BitVector() const {
196 return (isFixedLengthVector() && getFixedSizeInBits() == 2048);
197 }
198
199 /// Return true if this is a CHERI capability type.
200 bool isCheriCapability() const {
201 return (SimpleTy >= MVT::FIRST_CHERI_CAPABILITY_VALUETYPE) &&
202 (SimpleTy <= MVT::LAST_CHERI_CAPABILITY_VALUETYPE);
203 }
204
205 /// Return true if this is an overloaded type for TableGen.
206 bool isOverloaded() const {
207 switch (SimpleTy) {
208#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
209 case Ty: \
210 return Any;
211#include "llvm/CodeGen/GenVT.inc"
212#undef GET_VT_ATTR
213 default:
214 return false;
215 }
216 }
217
218 /// Return a vector with the same number of elements as this vector, but
219 /// with the element type converted to an integer type with the same
220 /// bitwidth.
222 MVT EltTy = getVectorElementType();
226 "Simple vector VT not representable by simple integer vector VT!");
227 return VecTy;
228 }
229
230 /// Return a VT for a vector type whose attributes match ourselves
231 /// with the exception of the element type that is chosen by the caller.
235 "Simple vector VT not representable by simple integer vector VT!");
236 return VecTy;
237 }
238
239 /// Return a VT for a vector type whose attributes match ourselves with
240 /// the exception of the element count that is chosen by the caller.
242 assert(isVector() && "Not a vector MVT!");
244 }
245
246 /// Return a VT for a type whose attributes match ourselves with the
247 /// exception of the element type that is chosen by the caller.
248 MVT changeElementType(MVT EltVT) const {
249 EltVT = EltVT.getScalarType();
250 return isVector() ? changeVectorElementType(EltVT) : EltVT;
251 }
252
253 /// Return the type converted to an equivalently sized integer or vector
254 /// with integer element type. Similar to changeVectorElementTypeToInteger,
255 /// but also handles scalars.
261
262 /// Return a VT for a vector type with the same element type but
263 /// half the number of elements.
265 MVT EltVT = getVectorElementType();
266 auto EltCnt = getVectorElementCount();
267 assert(EltCnt.isKnownEven() && "Splitting vector, but not in half!");
268 return getVectorVT(EltVT, EltCnt.divideCoefficientBy(2));
269 }
270
271 // Return a VT for a vector type with the same element type but
272 // double the number of elements.
274 MVT EltVT = getVectorElementType();
275 auto EltCnt = getVectorElementCount();
276 return MVT::getVectorVT(EltVT, EltCnt * 2);
277 }
278
279 // Return a VT for an Integer or vetor of integer type doubled in size
281 MVT BaseTy = getScalarType();
282 assert(BaseTy.isInteger() && "Not an integer or vector of integer MVT!");
283 assert((BaseTy != MVT::LAST_INTEGER_VALUETYPE) &&
284 "Widening of this Integer type not supported !");
285 MVT SclTy = getIntegerVT(BaseTy.getScalarSizeInBits() * 2);
287 "Failed to widen to a valid scalar MVT!");
288 MVT ResTy = changeElementType(SclTy);
290 "Failed to widen to a valid vector MVT!");
291 return ResTy;
292 }
293
294 /// Returns true if the given vector is a power of 2.
295 bool isPow2VectorType() const {
296 unsigned NElts = getVectorMinNumElements();
297 return !(NElts & (NElts - 1));
298 }
299
300 /// Widens the length of the given vector MVT up to the nearest power of 2
301 /// and returns that type.
303 if (isPow2VectorType())
304 return *this;
305
307 unsigned NewMinCount = 1 << Log2_32_Ceil(NElts.getKnownMinValue());
308 NElts = ElementCount::get(NewMinCount, NElts.isScalable());
309 return MVT::getVectorVT(getVectorElementType(), NElts);
310 }
311
312 /// If this is a vector, return the element type, otherwise return this.
314 return isVector() ? getVectorElementType() : *this;
315 }
316
318 assert(SimpleTy >= FIRST_VALUETYPE && SimpleTy <= LAST_VALUETYPE);
319 static constexpr SimpleValueType EltTyTable[] = {
320#define GET_VT_ATTR(Ty, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
321 EltTy,
322#include "llvm/CodeGen/GenVT.inc"
323#undef GET_VT_ATTR
324 };
325 SimpleValueType VT = EltTyTable[SimpleTy - FIRST_VALUETYPE];
326 assert(VT != INVALID_SIMPLE_VALUE_TYPE && "Not a vector MVT!");
327 return VT;
328 }
329
330 /// Given a vector type, return the minimum number of elements it contains.
331 unsigned getVectorMinNumElements() const {
332 assert(SimpleTy >= FIRST_VALUETYPE && SimpleTy <= LAST_VALUETYPE);
333 static constexpr uint16_t NElemTable[] = {
334#define GET_VT_ATTR(Ty, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
335 NElem,
336#include "llvm/CodeGen/GenVT.inc"
337#undef GET_VT_ATTR
338 };
339 unsigned NElem = NElemTable[SimpleTy - FIRST_VALUETYPE];
340 assert(NElem != 0 && "Not a vector MVT!");
341 return NElem;
342 }
343
347
348 unsigned getVectorNumElements() const {
349 if (isScalableVector())
351 "Possible incorrect use of MVT::getVectorNumElements() for "
352 "scalable vector. Scalable flag may be dropped, use "
353 "MVT::getVectorElementCount() instead");
355 }
356
357 /// Returns the size of the specified MVT in bits.
358 ///
359 /// If the value type is a scalable vector type, the scalable property will
360 /// be set and the runtime size will be a positive integer multiple of the
361 /// base size.
363 static constexpr TypeSize SizeTable[] = {
364#define GET_VT_ATTR(Ty, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
365 TypeSize(Sz, Sc || Tup || Ty == aarch64svcount /* FIXME: Not in the td. \
366 */),
367#include "llvm/CodeGen/GenVT.inc"
368#undef GET_VT_ATTR
369 };
370
371 switch (SimpleTy) {
373 llvm_unreachable("getSizeInBits called on extended MVT.");
374 case Other:
375 llvm_unreachable("Value type is non-standard value, Other.");
376 case iPTR:
377 llvm_unreachable("Value type size is target-dependent. Ask TLI.");
378 case pAny:
379 case iAny:
380 case fAny:
381 case vAny:
382 case Any:
383 llvm_unreachable("Value type is overloaded.");
384 case token:
385 llvm_unreachable("Token type is a sentinel that cannot be used "
386 "in codegen and has no size");
387 case Metadata:
388 llvm_unreachable("Value type is metadata.");
389 default:
390 assert(SimpleTy < VALUETYPE_SIZE && "Unexpected value type!");
391 return SizeTable[SimpleTy - FIRST_VALUETYPE];
392 }
393 }
394
395 /// Return the size of the specified fixed width value type in bits. The
396 /// function will assert if the type is scalable.
398 return getSizeInBits().getFixedValue();
399 }
403 }
404
405 /// Return the number of bytes overwritten by a store of the specified value
406 /// type.
407 ///
408 /// If the value type is a scalable vector type, the scalable property will
409 /// be set and the runtime size will be a positive integer multiple of the
410 /// base size.
411 TypeSize getStoreSize() const {
412 TypeSize BaseSize = getSizeInBits();
413 return {(BaseSize.getKnownMinValue() + 7) / 8, BaseSize.isScalable()};
414 }
415
416 // Return the number of bytes overwritten by a store of this value type or
417 // this value type's element type in the case of a vector.
420 }
421
422 /// Return the number of bits overwritten by a store of the specified value
423 /// type.
424 ///
425 /// If the value type is a scalable vector type, the scalable property will
426 /// be set and the runtime size will be a positive integer multiple of the
427 /// base size.
429 return getStoreSize() * 8;
430 }
431
432 /// Returns true if the number of bits for the type is a multiple of an
433 /// 8-bit byte.
434 bool isByteSized() const { return getSizeInBits().isKnownMultipleOf(8); }
435
436 /// Return true if we know at compile time this has more bits than VT.
437 bool knownBitsGT(MVT VT) const {
439 }
440
441 /// Return true if we know at compile time this has more than or the same
442 /// bits as VT.
443 bool knownBitsGE(MVT VT) const {
445 }
446
447 /// Return true if we know at compile time this has fewer bits than VT.
448 bool knownBitsLT(MVT VT) const {
450 }
451
452 /// Return true if we know at compile time this has fewer than or the same
453 /// bits as VT.
454 bool knownBitsLE(MVT VT) const {
456 }
457
458 /// Return true if this has more bits than VT.
459 bool bitsGT(MVT VT) const {
461 "Comparison between scalable and fixed types");
462 return knownBitsGT(VT);
463 }
464
465 /// Return true if this has no less bits than VT.
466 bool bitsGE(MVT VT) const {
468 "Comparison between scalable and fixed types");
469 return knownBitsGE(VT);
470 }
471
472 /// Return true if this has less bits than VT.
473 bool bitsLT(MVT VT) const {
475 "Comparison between scalable and fixed types");
476 return knownBitsLT(VT);
477 }
478
479 /// Return true if this has no more bits than VT.
480 bool bitsLE(MVT VT) const {
482 "Comparison between scalable and fixed types");
483 return knownBitsLE(VT);
484 }
486 static MVT getFloatingPointVT(unsigned BitWidth) {
487#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
488 if (FP == 3 && sz == BitWidth) \
489 return Ty;
490#include "llvm/CodeGen/GenVT.inc"
491#undef GET_VT_ATTR
492
493 llvm_unreachable("Bad bit width!");
494 }
496 static MVT getIntegerVT(unsigned BitWidth) {
497#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
498 if (Int == 3 && sz == BitWidth) \
499 return Ty;
500#include "llvm/CodeGen/GenVT.inc"
501#undef GET_VT_ATTR
502
504 }
506 static MVT getVectorVT(MVT VT, unsigned NumElements) {
507#define GET_VT_VECATTR(Ty, Sc, Tup, nElem, ElTy) \
508 if (!Sc && !Tup && VT.SimpleTy == ElTy && NumElements == nElem) \
509 return Ty;
510#include "llvm/CodeGen/GenVT.inc"
511#undef GET_VT_VECATTR
512
514 }
516 static MVT getScalableVectorVT(MVT VT, unsigned NumElements) {
517#define GET_VT_VECATTR(Ty, Sc, Tup, nElem, ElTy) \
518 if (Sc && VT.SimpleTy == ElTy && NumElements == nElem) \
519 return Ty;
520#include "llvm/CodeGen/GenVT.inc"
521#undef GET_VT_VECATTR
522
524 }
526 static MVT getRISCVVectorTupleVT(unsigned Sz, unsigned NFields) {
527#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, nElem, EltTy) \
528 if (Tup && sz == Sz && NF == NFields) \
529 return Ty;
530#include "llvm/CodeGen/GenVT.inc"
531#undef GET_VT_ATTR
532
533 llvm_unreachable("Invalid RISCV vector tuple type");
534 }
535
536 /// Given a RISC-V vector tuple type, return the num_fields.
537 unsigned getRISCVVectorTupleNumFields() const {
538 assert(isRISCVVectorTuple() && SimpleTy >= FIRST_VALUETYPE &&
539 SimpleTy <= LAST_VALUETYPE);
540 static constexpr uint8_t NFTable[] = {
541#define GET_VT_ATTR(Ty, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) NF,
542#include "llvm/CodeGen/GenVT.inc"
543#undef GET_VT_ATTR
544 };
545 return NFTable[SimpleTy - FIRST_VALUETYPE];
546 }
548 static MVT getVectorVT(MVT VT, unsigned NumElements, bool IsScalable) {
549 if (IsScalable)
550 return getScalableVectorVT(VT, NumElements);
551 return getVectorVT(VT, NumElements);
552 }
554 static MVT getVectorVT(MVT VT, ElementCount EC) {
555 if (EC.isScalable())
556 return getScalableVectorVT(VT, EC.getKnownMinValue());
557 return getVectorVT(VT, EC.getKnownMinValue());
558 }
559
560 /// Return the value type corresponding to the specified type.
561 /// If HandleUnknown is true, unknown types are returned as Other,
562 /// otherwise they are invalid.
563 /// NB: This includes pointer types, which require a DataLayout to convert
564 /// to a concrete value type.
565 LLVM_ABI static MVT getVT(Type *Ty, bool HandleUnknown = false);
566
567 /// Returns an APFloat semantics tag appropriate for the value type. If this
568 /// is a vector type, the element semantics are returned.
570
571 public:
572 /// SimpleValueType Iteration
573 /// @{
574 static auto all_valuetypes() {
575 return enum_seq_inclusive(MVT::FIRST_VALUETYPE, MVT::LAST_VALUETYPE,
577 }
579 static auto integer_valuetypes() {
580 return enum_seq_inclusive(MVT::FIRST_INTEGER_VALUETYPE,
581 MVT::LAST_INTEGER_VALUETYPE,
583 }
585 static auto fp_valuetypes() {
586 return enum_seq_inclusive(MVT::FIRST_FP_VALUETYPE, MVT::LAST_FP_VALUETYPE,
588 }
590 static auto vector_valuetypes() {
591 return enum_seq_inclusive(MVT::FIRST_VECTOR_VALUETYPE,
592 MVT::LAST_VECTOR_VALUETYPE,
594 }
596 static auto fixedlen_vector_valuetypes() {
597 return enum_seq_inclusive(MVT::FIRST_FIXEDLEN_VECTOR_VALUETYPE,
598 MVT::LAST_FIXEDLEN_VECTOR_VALUETYPE,
600 }
602 static auto scalable_vector_valuetypes() {
603 return enum_seq_inclusive(MVT::FIRST_SCALABLE_VECTOR_VALUETYPE,
604 MVT::LAST_SCALABLE_VECTOR_VALUETYPE,
606 }
609 return enum_seq_inclusive(MVT::FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE,
610 MVT::LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE,
612 }
614 static auto fp_fixedlen_vector_valuetypes() {
615 return enum_seq_inclusive(MVT::FIRST_FP_FIXEDLEN_VECTOR_VALUETYPE,
616 MVT::LAST_FP_FIXEDLEN_VECTOR_VALUETYPE,
618 }
621 return enum_seq_inclusive(MVT::FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE,
622 MVT::LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE,
624 }
626 static auto fp_scalable_vector_valuetypes() {
627 return enum_seq_inclusive(MVT::FIRST_FP_SCALABLE_VECTOR_VALUETYPE,
628 MVT::LAST_FP_SCALABLE_VECTOR_VALUETYPE,
630 }
632 static auto cheri_capability_valuetypes() {
633 return enum_seq_inclusive(MVT::FIRST_CHERI_CAPABILITY_VALUETYPE,
634 MVT::LAST_CHERI_CAPABILITY_VALUETYPE,
636 }
637 /// @}
638 };
640 inline raw_ostream &operator<<(raw_ostream &OS, const MVT &VT) {
641 VT.print(OS);
642 return OS;
643 }
644
645} // end namespace llvm
646
647#endif // LLVM_CODEGEN_MACHINEVALUETYPE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:215
Provides some synthesis utilities to produce sequences of values.
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
Definition TypeSize.h:315
Machine Value Type.
LLVM_ABI void dump() const
Support for debugging, callable in GDB: VT.dump()
bool isVectorOf(MVT EltVT) const
Return true if this is a vector with matching element type.
static MVT getFloatingPointVT(unsigned BitWidth)
bool isByteSized() const
Returns true if the number of bits for the type is a multiple of an 8-bit byte.
bool is128BitVector() const
Return true if this is a 128-bit vector type.
bool knownBitsGT(MVT VT) const
Return true if we know at compile time this has more bits than VT.
@ INVALID_SIMPLE_VALUE_TYPE
static auto integer_fixedlen_vector_valuetypes()
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
bool isRISCVVectorTuple() const
Return true if this is a RISCV vector tuple type where the runtime length is machine dependent.
bool operator>(const MVT &S) const
SimpleValueType SimpleTy
bool isOverloaded() const
Return true if this is an overloaded type for TableGen.
bool isScalableTargetExtVT() const
Return true if this is a custom target type that has a scalable size.
uint64_t getScalarSizeInBits() const
MVT changeVectorElementType(MVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
bool operator<=(const MVT &S) const
constexpr MVT()=default
bool bitsLE(MVT VT) const
Return true if this has no more bits than VT.
unsigned getVectorNumElements() const
bool knownBitsLT(MVT VT) const
Return true if we know at compile time this has fewer bits than VT.
static MVT getRISCVVectorTupleVT(unsigned Sz, unsigned NFields)
bool isVector() const
Return true if this is a vector value type.
bool isScalableVectorOf(MVT EltVT) const
Return true if this is a scalable vector with matching element type.
bool isInteger() const
Return true if this is an integer or a vector integer type.
bool isScalableVector() const
Return true if this is a vector value type where the runtime length is machine dependent.
static MVT getScalableVectorVT(MVT VT, unsigned NumElements)
bool is16BitVector() const
Return true if this is a 16-bit vector type.
bool is32BitVector() const
Return true if this is a 32-bit vector type.
unsigned getRISCVVectorTupleNumFields() const
Given a RISC-V vector tuple type, return the num_fields.
MVT changeTypeToInteger()
Return the type converted to an equivalently sized integer or vector with integer element type.
static LLVM_ABI MVT getVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
bool isScalableVT() const
Return true if the type is a scalable type.
bool bitsLT(MVT VT) const
Return true if this has less bits than VT.
MVT widenIntegerElementType() const
bool operator!=(SimpleValueType S) const
static auto all_valuetypes()
SimpleValueType Iteration.
bool operator<(const MVT &S) const
bool is512BitVector() const
Return true if this is a 512-bit vector type.
bool operator==(const MVT &S) const
static auto integer_valuetypes()
bool is1024BitVector() const
Return true if this is a 1024-bit vector type.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
bool isPow2VectorType() const
Returns true if the given vector is a power of 2.
uint64_t getScalarStoreSize() const
static auto scalable_vector_valuetypes()
static auto fixedlen_vector_valuetypes()
uint64_t getFixedSizeInBits() const
Return the size of the specified fixed width value type in bits.
LLVM_ABI const fltSemantics & getFltSemantics() const
Returns an APFloat semantics tag appropriate for the value type.
bool bitsGT(MVT VT) const
Return true if this has more bits than VT.
bool isFixedLengthVector() const
static auto vector_valuetypes()
bool is256BitVector() const
Return true if this is a 256-bit vector type.
ElementCount getVectorElementCount() const
MVT changeElementType(MVT EltVT) const
Return a VT for a type whose attributes match ourselves with the exception of the element type that i...
bool isCheriCapability() const
Return true if this is a CHERI capability type.
MVT changeVectorElementCount(ElementCount EC) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element coun...
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool bitsGE(MVT VT) const
Return true if this has no less bits than VT.
bool isScalarInteger() const
Return true if this is an integer, not including vectors.
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
static MVT getVectorVT(MVT VT, unsigned NumElements)
bool knownBitsGE(MVT VT) const
Return true if we know at compile time this has more than or the same bits as VT.
static auto fp_scalable_vector_valuetypes()
MVT getVectorElementType() const
bool isFixedLengthVectorOf(MVT EltVT) const
Return true if this is a fixed length vector with matching element type.
bool operator==(SimpleValueType S) const
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
bool operator>=(const MVT &S) const
bool isValid() const
Return true if this is a valid simple valuetype.
static MVT getIntegerVT(unsigned BitWidth)
MVT getDoubleNumVectorElementsVT() const
static auto fp_valuetypes()
MVT getHalfNumVectorElementsVT() const
Return a VT for a vector type with the same element type but half the number of elements.
bool knownBitsLE(MVT VT) const
Return true if we know at compile time this has fewer than or the same bits as VT.
bool operator!=(const MVT &S) const
MVT getScalarType() const
If this is a vector, return the element type, otherwise return this.
static auto integer_scalable_vector_valuetypes()
LLVM_ABI void print(raw_ostream &OS) const
Implement operator<<.
static auto cheri_capability_valuetypes()
bool is64BitVector() const
Return true if this is a 64-bit vector type.
MVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
MVT getPow2VectorType() const
Widens the length of the given vector MVT up to the nearest power of 2 and returns that type.
static auto fp_fixedlen_vector_valuetypes()
constexpr MVT(SimpleValueType SVT)
bool is2048BitVector() const
Return true if this is a 2048-bit vector type.
Root of the metadata hierarchy.
Definition Metadata.h:64
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
constexpr bool isKnownMultipleOf(ScalarTy RHS) const
This function tells the caller whether the element count is known at compile time to be a multiple of...
Definition TypeSize.h:180
constexpr ScalarTy getFixedValue() const
Definition TypeSize.h:200
static constexpr bool isKnownLE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition TypeSize.h:230
static constexpr bool isKnownLT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition TypeSize.h:216
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition TypeSize.h:168
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition TypeSize.h:165
static constexpr bool isKnownGT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition TypeSize.h:223
static constexpr bool isKnownGE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition TypeSize.h:237
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
Definition MathExtras.h:345
constexpr force_iteration_on_noniterable_enum_t force_iteration_on_noniterable_enum
Definition Sequence.h:110
LLVM_ABI void reportFatalInternalError(Error Err)
Report a fatal error that indicates a bug in LLVM.
Definition Error.cpp:173
constexpr auto enum_seq_inclusive(EnumT Begin, EnumT End)
Iterate over an enum type from Begin to End inclusive.
Definition Sequence.h:401
@ Other
Any other memory.
Definition ModRef.h:68
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
constexpr unsigned BitWidth