LLVM 23.0.0git
ValueTypes.h
Go to the documentation of this file.
1//===- CodeGen/ValueTypes.h - Low-Level Target independ. 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 low-level target independent types which various
10// values in the code generator are. This allows the target specific behavior
11// of instructions to be described to target independent passes.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_VALUETYPES_H
16#define LLVM_CODEGEN_VALUETYPES_H
17
22#include <cassert>
23#include <cstdint>
24#include <string>
25
26namespace llvm {
27
28 class LLVMContext;
29 class Type;
30 struct fltSemantics;
31
32 /// Extended Value Type. Capable of holding value types which are not native
33 /// for any processor (such as the i12345 type), as well as the types an MVT
34 /// can represent.
35 struct EVT {
36 private:
38 Type *LLVMTy = nullptr;
39
40 public:
41 constexpr EVT() = default;
42 constexpr EVT(MVT::SimpleValueType SVT) : V(SVT) {}
43 constexpr EVT(MVT S) : V(S) {}
44
45 bool operator==(EVT VT) const {
46 return !(*this != VT);
47 }
48 bool operator!=(EVT VT) const {
49 return V.SimpleTy != VT.V.SimpleTy || LLVMTy != VT.LLVMTy;
50 }
51
52 /// Returns the EVT that represents a floating-point type with the given
53 /// number of bits. There are two floating-point types with 128 bits - this
54 /// returns f128 rather than ppcf128.
55 static EVT getFloatingPointVT(unsigned BitWidth) {
57 }
58
59 /// Returns the EVT that represents an integer with the given number of
60 /// bits.
61 static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth) {
63 if (M.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE)
64 return M;
65 return getExtendedIntegerVT(Context, BitWidth);
66 }
67
68 /// Returns the EVT that represents a vector NumElements in length, where
69 /// each element is of type VT.
70 static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements,
71 bool IsScalable = false) {
72 MVT M = MVT::getVectorVT(VT.V, NumElements, IsScalable);
73 if (M.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE)
74 return M;
75 return getExtendedVectorVT(Context, VT, NumElements, IsScalable);
76 }
77
78 /// Returns the EVT that represents a vector EC.Min elements in length,
79 /// where each element is of type VT.
80 static EVT getVectorVT(LLVMContext &Context, EVT VT, ElementCount EC) {
81 MVT M = MVT::getVectorVT(VT.V, EC);
82 if (M.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE)
83 return M;
84 return getExtendedVectorVT(Context, VT, EC);
85 }
86
87 /// Return a vector with the same number of elements as this vector, but
88 /// with the element type converted to an integer type with the same
89 /// bitwidth.
91 if (isSimple())
93 return changeExtendedVectorElementTypeToInteger();
94 }
95
96 /// Return a VT for a vector type whose attributes match ourselves
97 /// with the exception of the element type that is chosen by the caller.
98 EVT changeVectorElementType(LLVMContext &Context, EVT EltVT) const {
99 if (isSimple() && EltVT.isSimple()) {
102 return M;
103 }
104 return getVectorVT(Context, EltVT, getVectorElementCount());
105 }
106
107 /// Return a VT for a vector type whose attributes match ourselves
108 /// with the exception of the element count that is chosen by the caller.
110 assert(isVector() && "Not a vector EVT!");
111 if (isSimple()) {
114 return M;
115 }
116 return getVectorVT(Context, getVectorElementType(), EC);
117 }
118
119 /// Return a VT for a type whose attributes match ourselves with the
120 /// exception of the element type that is chosen by the caller.
121 EVT changeElementType(LLVMContext &Context, EVT EltVT) const {
122 EltVT = EltVT.getScalarType();
123 return isVector() ? changeVectorElementType(Context, EltVT) : EltVT;
124 }
125
126 /// Return the type converted to an equivalently sized integer or vector
127 /// with integer element type. Similar to changeVectorElementTypeToInteger,
128 /// but also handles scalars.
130 if (isVector())
132
133 if (isSimple())
135 return changeExtendedTypeToInteger();
136 }
137
138 /// Test if the given EVT has zero size, this will fail if called on a
139 /// scalable type
140 bool isZeroSized() const {
141 return getSizeInBits().isZero();
142 }
143
144 /// Test if the given EVT is simple (as opposed to being extended).
145 bool isSimple() const {
146 return V.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE;
147 }
148
149 /// Test if the given EVT is extended (as opposed to being simple).
150 bool isExtended() const {
151 return !isSimple();
152 }
153
154 /// Return true if this is a FP or a vector FP type.
155 bool isFloatingPoint() const {
156 return isSimple() ? V.isFloatingPoint() : isExtendedFloatingPoint();
157 }
158
159 /// Return true if this is an integer or a vector integer type.
160 bool isInteger() const {
161 return isSimple() ? V.isInteger() : isExtendedInteger();
162 }
163
164 /// Return true if this is an integer, but not a vector.
165 bool isScalarInteger() const {
166 return isSimple() ? V.isScalarInteger() : isExtendedScalarInteger();
167 }
168
169 /// Return true if this is a vector type where the runtime
170 /// length is machine dependent
172 return isSimple() && V.isScalableTargetExtVT();
173 }
174
175 /// Return true if this is a vector value type.
176 bool isVector() const {
177 return isSimple() ? V.isVector() : isExtendedVector();
178 }
179
180 /// Return true if this is a vector with matching element type.
181 bool isVectorOf(EVT EltVT) const {
182 return isVector() && getVectorElementType() == EltVT;
183 }
184
185 /// Return true if this is a vector type where the runtime
186 /// length is machine dependent
187 bool isScalableVector() const {
188 return isSimple() ? V.isScalableVector() : isExtendedScalableVector();
189 }
190
191 /// Return true if this is a scalable vector with matching element type.
192 bool isScalableVectorOf(EVT EltVT) const {
193 return isScalableVector() && getVectorElementType() == EltVT;
194 }
195
196 /// Return true if this is a vector value type.
197 bool isRISCVVectorTuple() const { return V.isRISCVVectorTuple(); }
198
199 bool isFixedLengthVector() const {
200 return isSimple() ? V.isFixedLengthVector()
201 : isExtendedFixedLengthVector();
202 }
203
204 /// Return true if this is a fixed length vector with matching element type.
205 bool isFixedLengthVectorOf(EVT EltVT) const {
206 return isFixedLengthVector() && getVectorElementType() == EltVT;
207 }
208
209 /// Return true if the type is a scalable type.
210 bool isScalableVT() const {
212 }
213
214 /// Return true if this is a 16-bit vector type.
215 bool is16BitVector() const {
216 return isSimple() ? V.is16BitVector() : isExtended16BitVector();
217 }
218
219 /// Return true if this is a 32-bit vector type.
220 bool is32BitVector() const {
221 return isSimple() ? V.is32BitVector() : isExtended32BitVector();
222 }
223
224 /// Return true if this is a 64-bit vector type.
225 bool is64BitVector() const {
226 return isSimple() ? V.is64BitVector() : isExtended64BitVector();
227 }
228
229 /// Return true if this is a 128-bit vector type.
230 bool is128BitVector() const {
231 return isSimple() ? V.is128BitVector() : isExtended128BitVector();
232 }
233
234 /// Return true if this is a 256-bit vector type.
235 bool is256BitVector() const {
236 return isSimple() ? V.is256BitVector() : isExtended256BitVector();
237 }
238
239 /// Return true if this is a 512-bit vector type.
240 bool is512BitVector() const {
241 return isSimple() ? V.is512BitVector() : isExtended512BitVector();
242 }
243
244 /// Return true if this is a 1024-bit vector type.
245 bool is1024BitVector() const {
246 return isSimple() ? V.is1024BitVector() : isExtended1024BitVector();
247 }
248
249 /// Return true if this is a 2048-bit vector type.
250 bool is2048BitVector() const {
251 return isSimple() ? V.is2048BitVector() : isExtended2048BitVector();
252 }
253
254 /// Return true if this is a capability type.
255 bool isCheriCapability() const {
256 return isSimple() ? V.isCheriCapability() : false;
257 }
258
259 /// Return true if this is an overloaded type for TableGen.
260 bool isOverloaded() const {
261 return (V == MVT::iAny || V == MVT::fAny || V == MVT::vAny ||
262 V == MVT::pAny);
263 }
264
265 /// Return true if the bit size is a multiple of 8.
266 bool isByteSized() const {
268 }
269
270 /// Return true if the size is a power-of-two number of bytes.
271 bool isRound() const {
272 if (isScalableVector())
273 return false;
274 unsigned BitSize = getSizeInBits();
275 return BitSize >= 8 && !(BitSize & (BitSize - 1));
276 }
277
278 /// Return true if this has the same number of bits as VT.
279 bool bitsEq(EVT VT) const {
280 if (EVT::operator==(VT)) return true;
281 return getSizeInBits() == VT.getSizeInBits();
282 }
283
284 /// Return true if we know at compile time this has more bits than VT.
285 bool knownBitsGT(EVT VT) const {
287 }
288
289 /// Return true if we know at compile time this has more than or the same
290 /// bits as VT.
291 bool knownBitsGE(EVT VT) const {
293 }
294
295 /// Return true if we know at compile time this has fewer bits than VT.
296 bool knownBitsLT(EVT VT) const {
298 }
299
300 /// Return true if we know at compile time this has fewer than or the same
301 /// bits as VT.
302 bool knownBitsLE(EVT VT) const {
304 }
305
306 /// Return true if this has more bits than VT.
307 bool bitsGT(EVT VT) const {
308 if (EVT::operator==(VT)) return false;
310 "Comparison between scalable and fixed types");
311 return knownBitsGT(VT);
312 }
313
314 /// Return true if this has no less bits than VT.
315 bool bitsGE(EVT VT) const {
316 if (EVT::operator==(VT)) return true;
318 "Comparison between scalable and fixed types");
319 return knownBitsGE(VT);
320 }
321
322 /// Return true if this has less bits than VT.
323 bool bitsLT(EVT VT) const {
324 if (EVT::operator==(VT)) return false;
326 "Comparison between scalable and fixed types");
327 return knownBitsLT(VT);
328 }
329
330 /// Return true if this has no more bits than VT.
331 bool bitsLE(EVT VT) const {
332 if (EVT::operator==(VT)) return true;
334 "Comparison between scalable and fixed types");
335 return knownBitsLE(VT);
336 }
337
338 /// Return the SimpleValueType held in the specified simple EVT.
339 MVT getSimpleVT() const {
340 assert(isSimple() && "Expected a SimpleValueType!");
341 return V;
342 }
343
344 /// If this is a vector type, return the element type, otherwise return
345 /// this.
347 return isVector() ? getVectorElementType() : *this;
348 }
349
350 /// Given a vector type, return the type of each element.
352 assert(isVector() && "Invalid vector type!");
353 if (isSimple())
354 return V.getVectorElementType();
355 return getExtendedVectorElementType();
356 }
357
358 /// Given a vector type, return the number of elements it contains.
359 unsigned getVectorNumElements() const {
360 assert(isVector() && "Invalid vector type!");
361
362 if (isScalableVector())
364 "Possible incorrect use of EVT::getVectorNumElements() for "
365 "scalable vector. Scalable flag may be dropped, use "
366 "EVT::getVectorElementCount() instead");
367
368 return isSimple() ? V.getVectorNumElements()
369 : getExtendedVectorNumElements();
370 }
371
372 // Given a (possibly scalable) vector type, return the ElementCount
374 assert((isVector()) && "Invalid vector type!");
375 if (isSimple())
376 return V.getVectorElementCount();
377
378 return getExtendedVectorElementCount();
379 }
380
381 /// Given a vector type, return the minimum number of elements it contains.
382 unsigned getVectorMinNumElements() const {
384 }
385
386 /// Given a RISCV vector tuple type, return the num_fields.
388 return V.getRISCVVectorTupleNumFields();
389 }
390
391 /// Return the size of the specified value type in bits.
392 ///
393 /// If the value type is a scalable vector type, the scalable property will
394 /// be set and the runtime size will be a positive integer multiple of the
395 /// base size.
397 if (isSimple())
398 return V.getSizeInBits();
399 return getExtendedSizeInBits();
400 }
401
402 /// Return the size of the specified fixed width value type in bits. The
403 /// function will assert if the type is scalable.
407
411
412 /// Return the number of bytes overwritten by a store of the specified value
413 /// type.
414 ///
415 /// If the value type is a scalable vector type, the scalable property will
416 /// be set and the runtime size will be a positive integer multiple of the
417 /// base size.
419 TypeSize BaseSize = getSizeInBits();
420 return {(BaseSize.getKnownMinValue() + 7) / 8, BaseSize.isScalable()};
421 }
422
423 // Return the number of bytes overwritten by a store of this value type or
424 // this value type's element type in the case of a vector.
428
429 /// Return the number of bits overwritten by a store of the specified value
430 /// type.
431 ///
432 /// If the value type is a scalable vector type, the scalable property will
433 /// be set and the runtime size will be a positive integer multiple of the
434 /// base size.
436 return getStoreSize() * 8;
437 }
438
439 /// Rounds the bit-width of the given integer EVT up to the nearest power of
440 /// two (and at least to eight), and returns the integer EVT with that
441 /// number of bits.
443 assert(isInteger() && !isVector() && "Invalid integer type!");
444 unsigned BitWidth = getSizeInBits();
445 if (BitWidth <= 8)
446 return EVT(MVT::i8);
447 return getIntegerVT(Context, llvm::bit_ceil(BitWidth));
448 }
449
450 /// Finds the smallest simple value type that is greater than or equal to
451 /// half the width of this EVT. If no simple value type can be found, an
452 /// extended integer value type of half the size (rounded up) is returned.
454 assert(isInteger() && !isVector() && "Invalid integer type!");
455 unsigned EVTSize = getSizeInBits();
456 for (unsigned IntVT = MVT::FIRST_INTEGER_VALUETYPE;
457 IntVT <= MVT::LAST_INTEGER_VALUETYPE; ++IntVT) {
458 EVT HalfVT = EVT((MVT::SimpleValueType)IntVT);
459 if (HalfVT.getSizeInBits() * 2 >= EVTSize)
460 return HalfVT;
461 }
462 return getIntegerVT(Context, (EVTSize + 1) / 2);
463 }
464
465 /// Return a VT for an integer element type with doubled bit width.
466 /// The type returned may be an extended type.
468 unsigned EVTSize = getScalarSizeInBits();
469 EVT EltVT = EVT::getIntegerVT(Context, 2 * EVTSize);
470 return changeElementType(Context, EltVT);
471 }
472
473 /// Return a VT for an integer vector type with the size of the
474 /// elements doubled. The type returned may be an extended type.
476 EVT EltVT = getVectorElementType();
477 EltVT = EVT::getIntegerVT(Context, 2 * EltVT.getSizeInBits());
478 return EVT::getVectorVT(Context, EltVT, getVectorElementCount());
479 }
480
481 // Return a VT for a vector type with the same element type but
482 // half the number of elements. The type returned may be an
483 // extended type.
485 EVT EltVT = getVectorElementType();
486 auto EltCnt = getVectorElementCount();
487 assert(EltCnt.isKnownEven() && "Splitting vector, but not in half!");
488 return EVT::getVectorVT(Context, EltVT, EltCnt.divideCoefficientBy(2));
489 }
490
491 // Return a VT for a vector type with the same element type but
492 // double the number of elements. The type returned may be an
493 // extended type.
495 EVT EltVT = getVectorElementType();
496 auto EltCnt = getVectorElementCount();
497 return EVT::getVectorVT(Context, EltVT, EltCnt * 2);
498 }
499
500 /// Returns true if the given vector is a power of 2.
501 bool isPow2VectorType() const {
502 unsigned NElts = getVectorMinNumElements();
503 return !(NElts & (NElts - 1));
504 }
505
506 /// Widens the length of the given vector EVT up to the nearest power of 2
507 /// and returns that type.
509 if (!isPow2VectorType()) {
511 unsigned NewMinCount = 1 << Log2_32_Ceil(NElts.getKnownMinValue());
512 NElts = ElementCount::get(NewMinCount, NElts.isScalable());
513 return EVT::getVectorVT(Context, getVectorElementType(), NElts);
514 }
515 else {
516 return *this;
517 }
518 }
519
520 /// This function returns value type as a string, e.g. "i32".
521 LLVM_ABI std::string getEVTString() const;
522
523 /// Support for debugging, callable in GDB: VT.dump()
524 LLVM_ABI void dump() const;
525
526 /// Implement operator<<.
527 void print(raw_ostream &OS) const {
528 OS << getEVTString();
529 }
530
531 /// This method returns an LLVM type corresponding to the specified EVT.
532 /// For integer types, this returns an unsigned type. Note that this will
533 /// abort for types that cannot be represented.
534 LLVM_ABI Type *getTypeForEVT(LLVMContext &Context) const;
535
536 /// Return the value type corresponding to the specified type.
537 /// If HandleUnknown is true, unknown types are returned as Other,
538 /// otherwise they are invalid.
539 /// NB: This includes pointer types, which require a DataLayout to convert
540 /// to a concrete value type.
541 LLVM_ABI static EVT getEVT(Type *Ty, bool HandleUnknown = false);
542
543 intptr_t getRawBits() const {
544 if (isSimple())
545 return V.SimpleTy;
546 else
547 return (intptr_t)(LLVMTy);
548 }
549
550 /// A meaningless but well-behaved order, useful for constructing
551 /// containers.
553 bool operator()(EVT L, EVT R) const {
554 if (L.V.SimpleTy == R.V.SimpleTy)
555 return L.LLVMTy < R.LLVMTy;
556 else
557 return L.V.SimpleTy < R.V.SimpleTy;
558 }
559 };
560
561 /// Returns an APFloat semantics tag appropriate for the value type. If this
562 /// is a vector type, the element semantics are returned.
564
565 private:
566 // Methods for handling the Extended-type case in functions above.
567 // These are all out-of-line to prevent users of this header file
568 // from having a dependency on Type.h.
569 LLVM_ABI EVT changeExtendedTypeToInteger() const;
570 LLVM_ABI EVT changeExtendedVectorElementType(EVT EltVT) const;
571 LLVM_ABI EVT changeExtendedVectorElementTypeToInteger() const;
572 LLVM_ABI static EVT getExtendedIntegerVT(LLVMContext &C, unsigned BitWidth);
573 LLVM_ABI static EVT getExtendedVectorVT(LLVMContext &C, EVT VT,
574 unsigned NumElements,
575 bool IsScalable);
576 LLVM_ABI static EVT getExtendedVectorVT(LLVMContext &Context, EVT VT,
577 ElementCount EC);
578 LLVM_ABI bool isExtendedFloatingPoint() const LLVM_READONLY;
579 LLVM_ABI bool isExtendedInteger() const LLVM_READONLY;
580 LLVM_ABI bool isExtendedScalarInteger() const LLVM_READONLY;
581 LLVM_ABI bool isExtendedVector() const LLVM_READONLY;
582 LLVM_ABI bool isExtended16BitVector() const LLVM_READONLY;
583 LLVM_ABI bool isExtended32BitVector() const LLVM_READONLY;
584 LLVM_ABI bool isExtended64BitVector() const LLVM_READONLY;
585 LLVM_ABI bool isExtended128BitVector() const LLVM_READONLY;
586 LLVM_ABI bool isExtended256BitVector() const LLVM_READONLY;
587 LLVM_ABI bool isExtended512BitVector() const LLVM_READONLY;
588 LLVM_ABI bool isExtended1024BitVector() const LLVM_READONLY;
589 LLVM_ABI bool isExtended2048BitVector() const LLVM_READONLY;
590 LLVM_ABI bool isExtendedFixedLengthVector() const LLVM_READONLY;
591 LLVM_ABI bool isExtendedScalableVector() const LLVM_READONLY;
592 LLVM_ABI EVT getExtendedVectorElementType() const;
593 LLVM_ABI unsigned getExtendedVectorNumElements() const LLVM_READONLY;
594 LLVM_ABI ElementCount getExtendedVectorElementCount() const LLVM_READONLY;
595 LLVM_ABI TypeSize getExtendedSizeInBits() const LLVM_READONLY;
596 };
597
598 inline raw_ostream &operator<<(raw_ostream &OS, const EVT &V) {
599 V.print(OS);
600 return OS;
601 }
602} // end namespace llvm
603
604#endif // LLVM_CODEGEN_VALUETYPES_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
aarch64 promote const
always inline
#define LLVM_ABI
Definition Compiler.h:213
#define LLVM_READONLY
Definition Compiler.h:322
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
Definition TypeSize.h:315
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Machine Value Type.
static MVT getFloatingPointVT(unsigned BitWidth)
@ INVALID_SIMPLE_VALUE_TYPE
SimpleValueType SimpleTy
MVT changeTypeToInteger()
Return the type converted to an equivalently sized integer or vector with integer element type.
MVT changeVectorElementCount(ElementCount EC) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element coun...
static MVT getVectorVT(MVT VT, unsigned NumElements)
static MVT getIntegerVT(unsigned BitWidth)
MVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
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
constexpr bool isZero() const
Definition TypeSize.h:153
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
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
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:344
T bit_ceil(T Value)
Returns the smallest integral power of two no smaller than Value if Value is nonzero.
Definition bit.h:362
LLVM_ABI void reportFatalInternalError(Error Err)
Report a fatal error that indicates a bug in LLVM.
Definition Error.cpp:173
constexpr unsigned BitWidth
A meaningless but well-behaved order, useful for constructing containers.
Definition ValueTypes.h:552
bool operator()(EVT L, EVT R) const
Definition ValueTypes.h:553
Extended Value Type.
Definition ValueTypes.h:35
bool isScalableVectorOf(EVT EltVT) const
Return true if this is a scalable vector with matching element type.
Definition ValueTypes.h:192
EVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
Definition ValueTypes.h:90
constexpr EVT()=default
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
Definition ValueTypes.h:418
EVT getPow2VectorType(LLVMContext &Context) const
Widens the length of the given vector EVT up to the nearest power of 2 and returns that type.
Definition ValueTypes.h:508
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
Definition ValueTypes.h:145
constexpr EVT(MVT::SimpleValueType SVT)
Definition ValueTypes.h:42
intptr_t getRawBits() const
Definition ValueTypes.h:543
bool knownBitsLE(EVT VT) const
Return true if we know at compile time this has fewer than or the same bits as VT.
Definition ValueTypes.h:302
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
Definition ValueTypes.h:70
EVT changeTypeToInteger() const
Return the type converted to an equivalently sized integer or vector with integer element type.
Definition ValueTypes.h:129
uint64_t getScalarStoreSize() const
Definition ValueTypes.h:425
bool isOverloaded() const
Return true if this is an overloaded type for TableGen.
Definition ValueTypes.h:260
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
Definition ValueTypes.h:307
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
Definition ValueTypes.h:323
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
Definition ValueTypes.h:155
ElementCount getVectorElementCount() const
Definition ValueTypes.h:373
EVT getDoubleNumVectorElementsVT(LLVMContext &Context) const
Definition ValueTypes.h:494
bool is32BitVector() const
Return true if this is a 32-bit vector type.
Definition ValueTypes.h:220
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
Definition ValueTypes.h:396
bool isByteSized() const
Return true if the bit size is a multiple of 8.
Definition ValueTypes.h:266
bool isCheriCapability() const
Return true if this is a capability type.
Definition ValueTypes.h:255
bool is1024BitVector() const
Return true if this is a 1024-bit vector type.
Definition ValueTypes.h:245
bool knownBitsGT(EVT VT) const
Return true if we know at compile time this has more bits than VT.
Definition ValueTypes.h:285
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
Definition ValueTypes.h:382
unsigned getRISCVVectorTupleNumFields() const
Given a RISCV vector tuple type, return the num_fields.
Definition ValueTypes.h:387
uint64_t getScalarSizeInBits() const
Definition ValueTypes.h:408
EVT getHalfSizedIntegerVT(LLVMContext &Context) const
Finds the smallest simple value type that is greater than or equal to half the width of this EVT.
Definition ValueTypes.h:453
bool isPow2VectorType() const
Returns true if the given vector is a power of 2.
Definition ValueTypes.h:501
static LLVM_ABI EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
Definition ValueTypes.h:435
EVT changeVectorElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
Definition ValueTypes.h:98
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Definition ValueTypes.h:339
LLVM_ABI void dump() const
Support for debugging, callable in GDB: VT.dump()
constexpr EVT(MVT S)
Definition ValueTypes.h:43
bool is128BitVector() const
Return true if this is a 128-bit vector type.
Definition ValueTypes.h:230
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
Definition ValueTypes.h:61
bool is2048BitVector() const
Return true if this is a 2048-bit vector type.
Definition ValueTypes.h:250
bool isRISCVVectorTuple() const
Return true if this is a vector value type.
Definition ValueTypes.h:197
uint64_t getFixedSizeInBits() const
Return the size of the specified fixed width value type in bits.
Definition ValueTypes.h:404
EVT widenIntegerVectorElementType(LLVMContext &Context) const
Return a VT for an integer vector type with the size of the elements doubled.
Definition ValueTypes.h:475
bool knownBitsLT(EVT VT) const
Return true if we know at compile time this has fewer bits than VT.
Definition ValueTypes.h:296
EVT changeVectorElementCount(LLVMContext &Context, ElementCount EC) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element coun...
Definition ValueTypes.h:109
bool isScalableVT() const
Return true if the type is a scalable type.
Definition ValueTypes.h:210
bool is512BitVector() const
Return true if this is a 512-bit vector type.
Definition ValueTypes.h:240
bool isFixedLengthVector() const
Definition ValueTypes.h:199
LLVM_ABI std::string getEVTString() const
This function returns value type as a string, e.g. "i32".
static EVT getFloatingPointVT(unsigned BitWidth)
Returns the EVT that represents a floating-point type with the given number of bits.
Definition ValueTypes.h:55
bool operator!=(EVT VT) const
Definition ValueTypes.h:48
EVT getRoundIntegerType(LLVMContext &Context) const
Rounds the bit-width of the given integer EVT up to the nearest power of two (and at least to eight),...
Definition ValueTypes.h:442
bool isFixedLengthVectorOf(EVT EltVT) const
Return true if this is a fixed length vector with matching element type.
Definition ValueTypes.h:205
bool isVector() const
Return true if this is a vector value type.
Definition ValueTypes.h:176
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
Definition ValueTypes.h:346
bool is16BitVector() const
Return true if this is a 16-bit vector type.
Definition ValueTypes.h:215
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
Definition ValueTypes.h:315
bool is256BitVector() const
Return true if this is a 256-bit vector type.
Definition ValueTypes.h:235
bool bitsEq(EVT VT) const
Return true if this has the same number of bits as VT.
Definition ValueTypes.h:279
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
EVT widenIntegerElementType(LLVMContext &Context) const
Return a VT for an integer element type with doubled bit width.
Definition ValueTypes.h:467
bool isRound() const
Return true if the size is a power-of-two number of bytes.
Definition ValueTypes.h:271
static EVT getVectorVT(LLVMContext &Context, EVT VT, ElementCount EC)
Returns the EVT that represents a vector EC.Min elements in length, where each element is of type VT.
Definition ValueTypes.h:80
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
Definition ValueTypes.h:187
bool knownBitsGE(EVT VT) const
Return true if we know at compile time this has more than or the same bits as VT.
Definition ValueTypes.h:291
EVT getVectorElementType() const
Given a vector type, return the type of each element.
Definition ValueTypes.h:351
bool isExtended() const
Test if the given EVT is extended (as opposed to being simple).
Definition ValueTypes.h:150
EVT changeElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a type whose attributes match ourselves with the exception of the element type that i...
Definition ValueTypes.h:121
void print(raw_ostream &OS) const
Implement operator<<.
Definition ValueTypes.h:527
bool isVectorOf(EVT EltVT) const
Return true if this is a vector with matching element type.
Definition ValueTypes.h:181
bool isScalableTargetExtVT() const
Return true if this is a vector type where the runtime length is machine dependent.
Definition ValueTypes.h:171
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
Definition ValueTypes.h:165
LLVM_ABI const fltSemantics & getFltSemantics() const
Returns an APFloat semantics tag appropriate for the value type.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
Definition ValueTypes.h:359
bool operator==(EVT VT) const
Definition ValueTypes.h:45
bool isZeroSized() const
Test if the given EVT has zero size, this will fail if called on a scalable type.
Definition ValueTypes.h:140
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
Definition ValueTypes.h:331
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
Definition ValueTypes.h:484
bool isInteger() const
Return true if this is an integer or a vector integer type.
Definition ValueTypes.h:160
bool is64BitVector() const
Return true if this is a 64-bit vector type.
Definition ValueTypes.h:225