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 the value type as a string, e.g. `i32`.
78 std::string getString() const {
79 std::string S;
81 print(Stream);
82 return S;
83 }
84
85 /// Return true if this is a valid simple valuetype.
86 bool isValid() const {
87 return (SimpleTy >= MVT::FIRST_VALUETYPE &&
88 SimpleTy <= MVT::LAST_VALUETYPE);
89 }
90
91 /// Return true if this is a FP or a vector FP type.
92 bool isFloatingPoint() const {
93 return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE &&
94 SimpleTy <= MVT::LAST_FP_VALUETYPE) ||
95 (SimpleTy >= MVT::FIRST_FP_FIXEDLEN_VECTOR_VALUETYPE &&
96 SimpleTy <= MVT::LAST_FP_FIXEDLEN_VECTOR_VALUETYPE) ||
97 (SimpleTy >= MVT::FIRST_FP_SCALABLE_VECTOR_VALUETYPE &&
98 SimpleTy <= MVT::LAST_FP_SCALABLE_VECTOR_VALUETYPE));
99 }
100
101 /// Return true if this is an integer or a vector integer type.
102 bool isInteger() const {
103 return ((SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
104 SimpleTy <= MVT::LAST_INTEGER_VALUETYPE) ||
105 (SimpleTy >= MVT::FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE &&
106 SimpleTy <= MVT::LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE) ||
107 (SimpleTy >= MVT::FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE &&
108 SimpleTy <= MVT::LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE));
109 }
110
111 /// Return true if this is an integer, not including vectors.
112 bool isScalarInteger() const {
113 return (SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
114 SimpleTy <= MVT::LAST_INTEGER_VALUETYPE);
115 }
116
117 /// Return true if this is a vector value type.
118 bool isVector() const {
119 return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE &&
120 SimpleTy <= MVT::LAST_VECTOR_VALUETYPE);
121 }
122
123 /// Return true if this is a vector with matching element type.
124 bool isVectorOf(MVT EltVT) const {
125 return isVector() && getVectorElementType() == EltVT;
126 }
127
128 /// Return true if this is a vector value type where the
129 /// runtime length is machine dependent
130 bool isScalableVector() const {
131 return (SimpleTy >= MVT::FIRST_SCALABLE_VECTOR_VALUETYPE &&
132 SimpleTy <= MVT::LAST_SCALABLE_VECTOR_VALUETYPE);
133 }
134
135 /// Return true if this is a scalable vector with matching element type.
136 bool isScalableVectorOf(MVT EltVT) const {
137 return isScalableVector() && getVectorElementType() == EltVT;
138 }
139
140 /// Return true if this is a RISCV vector tuple type where the
141 /// runtime length is machine dependent
142 bool isRISCVVectorTuple() const {
143 return (SimpleTy >= MVT::FIRST_RISCV_VECTOR_TUPLE_VALUETYPE &&
144 SimpleTy <= MVT::LAST_RISCV_VECTOR_TUPLE_VALUETYPE);
145 }
146
147 /// Return true if this is a custom target type that has a scalable size.
149 return SimpleTy == MVT::aarch64svcount || isRISCVVectorTuple();
150 }
151
152 /// Return true if the type is a scalable type.
153 bool isScalableVT() const {
155 }
156
157 bool isFixedLengthVector() const {
158 return (SimpleTy >= MVT::FIRST_FIXEDLEN_VECTOR_VALUETYPE &&
159 SimpleTy <= MVT::LAST_FIXEDLEN_VECTOR_VALUETYPE);
160 }
161
162 /// Return true if this is a fixed length vector with matching element type.
163 bool isFixedLengthVectorOf(MVT EltVT) const {
164 return isFixedLengthVector() && getVectorElementType() == EltVT;
165 }
166
167 /// Return true if this is a 16-bit vector type.
168 bool is16BitVector() const {
169 return (isFixedLengthVector() && getFixedSizeInBits() == 16);
170 }
171
172 /// Return true if this is a 32-bit vector type.
173 bool is32BitVector() const {
174 return (isFixedLengthVector() && getFixedSizeInBits() == 32);
175 }
176
177 /// Return true if this is a 64-bit vector type.
178 bool is64BitVector() const {
179 return (isFixedLengthVector() && getFixedSizeInBits() == 64);
180 }
181
182 /// Return true if this is a 128-bit vector type.
183 bool is128BitVector() const {
184 return (isFixedLengthVector() && getFixedSizeInBits() == 128);
185 }
186
187 /// Return true if this is a 256-bit vector type.
188 bool is256BitVector() const {
189 return (isFixedLengthVector() && getFixedSizeInBits() == 256);
190 }
191
192 /// Return true if this is a 512-bit vector type.
193 bool is512BitVector() const {
194 return (isFixedLengthVector() && getFixedSizeInBits() == 512);
195 }
196
197 /// Return true if this is a 1024-bit vector type.
198 bool is1024BitVector() const {
199 return (isFixedLengthVector() && getFixedSizeInBits() == 1024);
200 }
201
202 /// Return true if this is a 2048-bit vector type.
203 bool is2048BitVector() const {
204 return (isFixedLengthVector() && getFixedSizeInBits() == 2048);
205 }
206
207 /// Return true if this is a CHERI capability type.
208 bool isCheriCapability() const {
209 return (SimpleTy >= MVT::FIRST_CHERI_CAPABILITY_VALUETYPE) &&
210 (SimpleTy <= MVT::LAST_CHERI_CAPABILITY_VALUETYPE);
211 }
212
213 /// Return true if this is an overloaded type for TableGen.
214 bool isOverloaded() const {
215 switch (SimpleTy) {
216#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
217 case Ty: \
218 return Any;
219#include "llvm/CodeGen/GenVT.inc"
220#undef GET_VT_ATTR
221 default:
222 return false;
223 }
224 }
225
226 /// Return a vector with the same number of elements as this vector, but
227 /// with the element type converted to an integer type with the same
228 /// bitwidth.
230 MVT EltTy = getVectorElementType();
234 "Simple vector VT not representable by simple integer vector VT!");
235 return VecTy;
236 }
237
238 /// Return a VT for a vector type whose attributes match ourselves
239 /// with the exception of the element type that is chosen by the caller.
243 "Simple vector VT not representable by simple integer vector VT!");
244 return VecTy;
245 }
246
247 /// Return a VT for a vector type whose attributes match ourselves with
248 /// the exception of the element count that is chosen by the caller.
250 assert(isVector() && "Not a vector MVT!");
252 }
253
254 /// Return a VT for a type whose attributes match ourselves with
255 /// the exception of the element count that is chosen by the caller.
257 MVT EltVT = getScalarType();
258 if (!isVector() && EC.isScalar())
259 return EltVT;
260 return MVT::getVectorVT(EltVT, EC);
261 }
262
263 /// Return a VT for a type whose attributes match ourselves with the
264 /// exception of the element type that is chosen by the caller.
265 MVT changeElementType(MVT EltVT) const {
266 EltVT = EltVT.getScalarType();
267 return isVector() ? changeVectorElementType(EltVT) : EltVT;
268 }
269
270 /// Return the type converted to an equivalently sized integer or vector
271 /// with integer element type. Similar to changeVectorElementTypeToInteger,
272 /// but also handles scalars.
278
279 /// Return a VT for a vector type with the same element type but
280 /// half the number of elements.
282 MVT EltVT = getVectorElementType();
283 auto EltCnt = getVectorElementCount();
284 assert(EltCnt.isKnownEven() && "Splitting vector, but not in half!");
285 return getVectorVT(EltVT, EltCnt.divideCoefficientBy(2));
286 }
287
288 // Return a VT for a vector type with the same element type but
289 // double the number of elements.
291 MVT EltVT = getVectorElementType();
292 auto EltCnt = getVectorElementCount();
293 return MVT::getVectorVT(EltVT, EltCnt * 2);
294 }
295
296 // Return a VT for an Integer or vetor of integer type doubled in size
298 MVT BaseTy = getScalarType();
299 assert(BaseTy.isInteger() && "Not an integer or vector of integer MVT!");
300 assert((BaseTy != MVT::LAST_INTEGER_VALUETYPE) &&
301 "Widening of this Integer type not supported !");
302 MVT SclTy = getIntegerVT(BaseTy.getScalarSizeInBits() * 2);
304 "Failed to widen to a valid scalar MVT!");
305 MVT ResTy = changeElementType(SclTy);
307 "Failed to widen to a valid vector MVT!");
308 return ResTy;
309 }
310
311 /// Returns true if the given vector is a power of 2.
312 bool isPow2VectorType() const {
313 unsigned NElts = getVectorMinNumElements();
314 return !(NElts & (NElts - 1));
315 }
316
317 /// Widens the length of the given vector MVT up to the nearest power of 2
318 /// and returns that type.
320 if (isPow2VectorType())
321 return *this;
322
324 unsigned NewMinCount = 1 << Log2_32_Ceil(NElts.getKnownMinValue());
325 NElts = ElementCount::get(NewMinCount, NElts.isScalable());
326 return MVT::getVectorVT(getVectorElementType(), NElts);
327 }
328
329 /// If this is a vector, return the element type, otherwise return this.
331 return isVector() ? getVectorElementType() : *this;
332 }
333
335 assert(SimpleTy >= FIRST_VALUETYPE && SimpleTy <= LAST_VALUETYPE);
336 static constexpr SimpleValueType EltTyTable[] = {
337#define GET_VT_ATTR(Ty, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
338 EltTy,
339#include "llvm/CodeGen/GenVT.inc"
340#undef GET_VT_ATTR
341 };
342 SimpleValueType VT = EltTyTable[SimpleTy - FIRST_VALUETYPE];
343 assert(VT != INVALID_SIMPLE_VALUE_TYPE && "Not a vector MVT!");
344 return VT;
345 }
346
347 /// Given a vector type, return the minimum number of elements it contains.
348 unsigned getVectorMinNumElements() const {
349 assert(SimpleTy >= FIRST_VALUETYPE && SimpleTy <= LAST_VALUETYPE);
350 static constexpr uint16_t NElemTable[] = {
351#define GET_VT_ATTR(Ty, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
352 NElem,
353#include "llvm/CodeGen/GenVT.inc"
354#undef GET_VT_ATTR
355 };
356 unsigned NElem = NElemTable[SimpleTy - FIRST_VALUETYPE];
357 assert(NElem != 0 && "Not a vector MVT!");
358 return NElem;
359 }
360
364
365 unsigned getVectorNumElements() const {
366 if (isScalableVector())
368 "Possible incorrect use of MVT::getVectorNumElements() for "
369 "scalable vector. Scalable flag may be dropped, use "
370 "MVT::getVectorElementCount() instead");
372 }
373
374 /// Returns the size of the specified MVT in bits.
375 ///
376 /// If the value type is a scalable vector type, the scalable property will
377 /// be set and the runtime size will be a positive integer multiple of the
378 /// base size.
380 static constexpr TypeSize SizeTable[] = {
381#define GET_VT_ATTR(Ty, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
382 TypeSize(Sz, Sc || Tup || Ty == aarch64svcount /* FIXME: Not in the td. \
383 */),
384#include "llvm/CodeGen/GenVT.inc"
385#undef GET_VT_ATTR
386 };
387
388 switch (SimpleTy) {
390 llvm_unreachable("getSizeInBits called on extended MVT.");
391 case Other:
392 llvm_unreachable("Value type is non-standard value, Other.");
393 case iPTR:
394 llvm_unreachable("Value type size is target-dependent. Ask TLI.");
395 case pAny:
396 case iAny:
397 case fAny:
398 case vAny:
399 case Any:
400 llvm_unreachable("Value type is overloaded.");
401 case token:
402 llvm_unreachable("Token type is a sentinel that cannot be used "
403 "in codegen and has no size");
404 case Metadata:
405 llvm_unreachable("Value type is metadata.");
406 default:
407 assert(SimpleTy < VALUETYPE_SIZE && "Unexpected value type!");
408 return SizeTable[SimpleTy - FIRST_VALUETYPE];
409 }
410 }
411
412 /// Return the size of the specified fixed width value type in bits. The
413 /// function will assert if the type is scalable.
415 return getSizeInBits().getFixedValue();
416 }
420 }
421
422 /// Return the number of bytes 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.
428 TypeSize getStoreSize() const {
429 TypeSize BaseSize = getSizeInBits();
430 return {(BaseSize.getKnownMinValue() + 7) / 8, BaseSize.isScalable()};
431 }
432
433 // Return the number of bytes overwritten by a store of this value type or
434 // this value type's element type in the case of a vector.
437 }
438
439 /// Return the number of bits overwritten by a store of the specified value
440 /// type.
441 ///
442 /// If the value type is a scalable vector type, the scalable property will
443 /// be set and the runtime size will be a positive integer multiple of the
444 /// base size.
446 return getStoreSize() * 8;
447 }
448
449 /// Returns true if the number of bits for the type is a multiple of an
450 /// 8-bit byte.
451 bool isByteSized() const { return getSizeInBits().isKnownMultipleOf(8); }
452
453 /// Return true if we know at compile time this has more bits than VT.
454 bool knownBitsGT(MVT VT) const {
456 }
457
458 /// Return true if we know at compile time this has more than or the same
459 /// bits as VT.
460 bool knownBitsGE(MVT VT) const {
462 }
463
464 /// Return true if we know at compile time this has fewer bits than VT.
465 bool knownBitsLT(MVT VT) const {
467 }
468
469 /// Return true if we know at compile time this has fewer than or the same
470 /// bits as VT.
471 bool knownBitsLE(MVT VT) const {
473 }
474
475 /// Return true if this has more bits than VT.
476 bool bitsGT(MVT VT) const {
478 "Comparison between scalable and fixed types");
479 return knownBitsGT(VT);
480 }
481
482 /// Return true if this has no less bits than VT.
483 bool bitsGE(MVT VT) const {
485 "Comparison between scalable and fixed types");
486 return knownBitsGE(VT);
487 }
488
489 /// Return true if this has less bits than VT.
490 bool bitsLT(MVT VT) const {
492 "Comparison between scalable and fixed types");
493 return knownBitsLT(VT);
494 }
495
496 /// Return true if this has no more bits than VT.
497 bool bitsLE(MVT VT) const {
499 "Comparison between scalable and fixed types");
500 return knownBitsLE(VT);
501 }
503 static MVT getFloatingPointVT(unsigned BitWidth) {
504#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
505 if (FP == 3 && sz == BitWidth) \
506 return Ty;
507#include "llvm/CodeGen/GenVT.inc"
508#undef GET_VT_ATTR
509
510 llvm_unreachable("Bad bit width!");
511 }
513 static MVT getIntegerVT(unsigned BitWidth) {
514#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) \
515 if (Int == 3 && sz == BitWidth) \
516 return Ty;
517#include "llvm/CodeGen/GenVT.inc"
518#undef GET_VT_ATTR
519
521 }
523 static MVT getVectorVT(MVT VT, unsigned NumElements) {
524 return getVectorVT(VT, NumElements, /*IsScalable=*/false);
525 }
527 static MVT getScalableVectorVT(MVT VT, unsigned NumElements) {
528 return getVectorVT(VT, NumElements, /*IsScalable=*/true);
529 }
531 static MVT getRISCVVectorTupleVT(unsigned Sz, unsigned NFields) {
532#define GET_VT_ATTR(Ty, sz, Any, Int, FP, Vec, Sc, Tup, NF, nElem, EltTy) \
533 if (Tup && sz == Sz && NF == NFields) \
534 return Ty;
535#include "llvm/CodeGen/GenVT.inc"
536#undef GET_VT_ATTR
537
538 llvm_unreachable("Invalid RISCV vector tuple type");
539 }
540
541 /// Given a RISC-V vector tuple type, return the num_fields.
542 unsigned getRISCVVectorTupleNumFields() const {
543 assert(isRISCVVectorTuple() && SimpleTy >= FIRST_VALUETYPE &&
544 SimpleTy <= LAST_VALUETYPE);
545 static constexpr uint8_t NFTable[] = {
546#define GET_VT_ATTR(Ty, Sz, Any, Int, FP, Vec, Sc, Tup, NF, NElem, EltTy) NF,
547#include "llvm/CodeGen/GenVT.inc"
548#undef GET_VT_ATTR
549 };
550 return NFTable[SimpleTy - FIRST_VALUETYPE];
551 }
552
553 /// Lookup table for getVectorVT. All simple vector types must fit into
554 /// the table; if a target has vector VTs that do not fit, building
555 /// MachineValueType.cpp, which defines the table, will fail.
556 struct VecVTTable {
557 static constexpr unsigned MaxNumElements = 4096;
558 static constexpr unsigned NumSlots = 32;
559 // Maps number of elements to a compact slot index. Only element counts
560 // used by any vector type get a slot; others stay 0. There are only a
561 // small number (< NumSlots) of distinct element counts for vector types.
562 uint8_t Slots[MaxNumElements + 1] = {};
563 // The vector MVTs, indexed by [IsScalable][ElementType][Slot]. Element
564 // types are scalar MVTs, so only those need an entry. Other entries
565 // stay INVALID_SIMPLE_VALUE_TYPE.
566 SimpleValueType Tys[2][FIRST_VECTOR_VALUETYPE][NumSlots] = {};
567 };
568 LLVM_ABI static const VecVTTable VecVTs;
570 static MVT getVectorVT(MVT VT, unsigned NumElements, bool IsScalable) {
571 if (VT.SimpleTy >= FIRST_VECTOR_VALUETYPE ||
572 NumElements > VecVTTable::MaxNumElements)
574 return VecVTs.Tys[IsScalable][VT.SimpleTy][VecVTs.Slots[NumElements]];
575 }
577 static MVT getVectorVT(MVT VT, ElementCount EC) {
578 return getVectorVT(VT, EC.getKnownMinValue(), EC.isScalable());
579 }
580
581 /// Return the value type corresponding to the specified type.
582 /// If HandleUnknown is true, unknown types are returned as Other,
583 /// otherwise they are invalid.
584 /// NB: This includes pointer types, which require a DataLayout to convert
585 /// to a concrete value type.
586 LLVM_ABI static MVT getVT(Type *Ty, bool HandleUnknown = false);
587
588 /// Returns an APFloat semantics tag appropriate for the value type. If this
589 /// is a vector type, the element semantics are returned.
591
592 public:
593 /// SimpleValueType Iteration
594 /// @{
595 static auto all_valuetypes() {
596 return enum_seq_inclusive(MVT::FIRST_VALUETYPE, MVT::LAST_VALUETYPE,
598 }
600 static auto integer_valuetypes() {
601 return enum_seq_inclusive(MVT::FIRST_INTEGER_VALUETYPE,
602 MVT::LAST_INTEGER_VALUETYPE,
604 }
606 static auto fp_valuetypes() {
607 return enum_seq_inclusive(MVT::FIRST_FP_VALUETYPE, MVT::LAST_FP_VALUETYPE,
609 }
611 static auto vector_valuetypes() {
612 return enum_seq_inclusive(MVT::FIRST_VECTOR_VALUETYPE,
613 MVT::LAST_VECTOR_VALUETYPE,
615 }
617 static auto fixedlen_vector_valuetypes() {
618 return enum_seq_inclusive(MVT::FIRST_FIXEDLEN_VECTOR_VALUETYPE,
619 MVT::LAST_FIXEDLEN_VECTOR_VALUETYPE,
621 }
623 static auto scalable_vector_valuetypes() {
624 return enum_seq_inclusive(MVT::FIRST_SCALABLE_VECTOR_VALUETYPE,
625 MVT::LAST_SCALABLE_VECTOR_VALUETYPE,
627 }
630 return enum_seq_inclusive(MVT::FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE,
631 MVT::LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE,
633 }
635 static auto fp_fixedlen_vector_valuetypes() {
636 return enum_seq_inclusive(MVT::FIRST_FP_FIXEDLEN_VECTOR_VALUETYPE,
637 MVT::LAST_FP_FIXEDLEN_VECTOR_VALUETYPE,
639 }
642 return enum_seq_inclusive(MVT::FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE,
643 MVT::LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE,
645 }
647 static auto fp_scalable_vector_valuetypes() {
648 return enum_seq_inclusive(MVT::FIRST_FP_SCALABLE_VECTOR_VALUETYPE,
649 MVT::LAST_FP_SCALABLE_VECTOR_VALUETYPE,
651 }
653 static auto cheri_capability_valuetypes() {
654 return enum_seq_inclusive(MVT::FIRST_CHERI_CAPABILITY_VALUETYPE,
655 MVT::LAST_CHERI_CAPABILITY_VALUETYPE,
657 }
658 /// @}
659 };
661 inline raw_ostream &operator<<(raw_ostream &OS, const MVT &VT) {
662 VT.print(OS);
663 return OS;
664 }
665
666} // end namespace llvm
667
668#endif // LLVM_CODEGEN_MACHINEVALUETYPE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
#define LLVM_ABI
Definition Compiler.h:211
Provides some synthesis utilities to produce sequences of values.
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
Definition TypeSize.h:312
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.
MVT changeElementCount(ElementCount EC) const
Return a VT for a type whose attributes match ourselves with the exception of the element count that ...
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.
std::string getString() const
Return the value type as a string, e.g. i32.
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
static LLVM_ABI const VecVTTable VecVTs
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:181
constexpr ScalarTy getFixedValue() const
Definition TypeSize.h:201
static constexpr bool isKnownLE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition TypeSize.h:231
static constexpr bool isKnownLT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition TypeSize.h:217
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition TypeSize.h:169
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition TypeSize.h:166
static constexpr bool isKnownGT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition TypeSize.h:224
static constexpr bool isKnownGE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition TypeSize.h:238
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
A raw_ostream that writes to an std::string.
#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:339
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
Lookup table for getVectorVT.
SimpleValueType Tys[2][FIRST_VECTOR_VALUETYPE][NumSlots]
static constexpr unsigned MaxNumElements
uint8_t Slots[MaxNumElements+1]
static constexpr unsigned NumSlots