LLVM 23.0.0git
DerivedTypes.h
Go to the documentation of this file.
1//===- llvm/DerivedTypes.h - Classes for handling data 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 contains the declarations of classes that represent "derived
10// types". These are things like "arrays of x" or "structure of x, y, z" or
11// "function returning x taking (y,z) as parameters", etc...
12//
13// The implementations of these classes live in the Type.cpp file.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_IR_DERIVEDTYPES_H
18#define LLVM_IR_DERIVEDTYPES_H
19
20#include "llvm/ADT/ArrayRef.h"
21#include "llvm/ADT/STLExtras.h"
22#include "llvm/ADT/StringRef.h"
23#include "llvm/IR/Type.h"
27#include <cassert>
28#include <cstdint>
29
30namespace llvm {
31
32class Value;
33class APInt;
34class LLVMContext;
35template <typename T> class Expected;
36class Error;
37
38/// Class to represent integer types. Note that this class is also used to
39/// represent the built-in integer types: Int1Ty, Int8Ty, Int16Ty, Int32Ty and
40/// Int64Ty.
41/// Integer representation type
42class IntegerType : public Type {
43 friend class LLVMContextImpl;
44
45protected:
46 explicit IntegerType(LLVMContext &C, unsigned NumBits) : Type(C, IntegerTyID){
47 setSubclassData(NumBits);
48 }
49
50public:
51 /// This enum is just used to hold constants we need for IntegerType.
52 enum {
53 MIN_INT_BITS = 1, ///< Minimum number of bits that can be specified
54 MAX_INT_BITS = (1<<23) ///< Maximum number of bits that can be specified
55 ///< Note that bit width is stored in the Type classes SubclassData field
56 ///< which has 24 bits. SelectionDAG type legalization can require a
57 ///< power of 2 IntegerType, so limit to the largest representable power
58 ///< of 2, 8388608.
59 };
60
61 /// This static method is the primary way of constructing an IntegerType.
62 /// If an IntegerType with the same NumBits value was previously instantiated,
63 /// that instance will be returned. Otherwise a new one will be created. Only
64 /// one instance with a given NumBits value is ever created.
65 /// Get or create an IntegerType instance.
66 LLVM_ABI static IntegerType *get(LLVMContext &C, unsigned NumBits);
67
68 /// Returns type twice as wide the input type.
72
73 /// Returns type half as wide the input type.
75 unsigned BitWidth = getBitWidth();
76 assert((BitWidth & 1) == 0 &&
77 "Cannot truncate integer type with odd bit-width");
78 return Type::getIntNTy(getContext(), BitWidth / 2);
79 }
80
81 /// Get the number of bits in this IntegerType
82 unsigned getBitWidth() const { return getSubclassData(); }
83
84 /// Return a bitmask with ones set for all of the bits that can be set by an
85 /// unsigned version of this type. This is 0xFF for i8, 0xFFFF for i16, etc.
87 return ~uint64_t(0UL) >> (64-getBitWidth());
88 }
89
90 /// Return a uint64_t with just the most significant bit set (the sign bit, if
91 /// the value is treated as a signed number).
93 return 1ULL << (getBitWidth()-1);
94 }
95
96 /// For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc.
97 /// @returns a bit mask with ones set for all the bits of this type.
98 /// Get a bit mask for this type.
99 LLVM_ABI APInt getMask() const;
100
101 /// Methods for support type inquiry through isa, cast, and dyn_cast.
102 static bool classof(const Type *T) {
103 return T->getTypeID() == IntegerTyID;
104 }
105};
106
107unsigned Type::getIntegerBitWidth() const {
108 return cast<IntegerType>(this)->getBitWidth();
109}
110
111/// Class to represent byte types.
112class ByteType : public Type {
113 friend class LLVMContextImpl;
114
115protected:
116 explicit ByteType(LLVMContext &C, unsigned NumBits) : Type(C, ByteTyID) {
117 setSubclassData(NumBits);
118 }
119
120public:
121 /// This enum is just used to hold constants we need for ByteType.
122 enum {
123 MIN_BYTE_BITS = 1, ///< Minimum number of bits that can be specified
125 (1 << 23) ///< Maximum number of bits that can be specified
126 ///< Note that bit width is stored in the Type classes
127 ///< SubclassData field which has 24 bits. SelectionDAG type
128 ///< legalization can require a power of 2 ByteType, so limit
129 ///< to the largest representable power of 2, 8388608.
130 };
131
132 /// This static method is the primary way of constructing a ByteType.
133 /// If a ByteType with the same NumBits value was previously instantiated,
134 /// that instance will be returned. Otherwise a new one will be created. Only
135 /// one instance with a given NumBits value is ever created.
136 /// Get or create a ByteType instance.
137 LLVM_ABI static ByteType *get(LLVMContext &C, unsigned NumBits);
138
139 /// Get the number of bits in this ByteType
140 unsigned getBitWidth() const { return getSubclassData(); }
141
142 /// For example, this is 0xFF for an 8 bit byte, 0xFFFF for b16, etc.
143 /// @returns a bit mask with ones set for all the bits of this type.
144 /// Get a bit mask for this type.
145 LLVM_ABI APInt getMask() const;
146
147 /// Methods for support type inquiry through isa, cast, and dyn_cast.
148 static bool classof(const Type *T) { return T->getTypeID() == ByteTyID; }
149};
150
151unsigned Type::getByteBitWidth() const {
152 return cast<ByteType>(this)->getBitWidth();
153}
154
155/// Class to represent function types
156///
157class FunctionType : public Type {
158 FunctionType(Type *Result, ArrayRef<Type*> Params, bool IsVarArgs);
159
160public:
161 FunctionType(const FunctionType &) = delete;
162 FunctionType &operator=(const FunctionType &) = delete;
163
164 /// This static method is the primary way of constructing a FunctionType.
165 LLVM_ABI static FunctionType *get(Type *Result, ArrayRef<Type *> Params,
166 bool isVarArg);
167
168 /// Create a FunctionType taking no parameters.
169 LLVM_ABI static FunctionType *get(Type *Result, bool isVarArg);
170
171 /// Return true if the specified type is valid as a return type.
172 LLVM_ABI static bool isValidReturnType(Type *RetTy);
173
174 /// Return true if the specified type is valid as an argument type.
175 LLVM_ABI static bool isValidArgumentType(Type *ArgTy);
176
177 bool isVarArg() const { return getSubclassData()!=0; }
178 Type *getReturnType() const { return ContainedTys[0]; }
179
181
185 return ArrayRef(param_begin(), param_end());
186 }
187
188 /// Parameter type accessors.
189 Type *getParamType(unsigned i) const {
190 assert(i < getNumParams() && "getParamType() out of range!");
191 return ContainedTys[i + 1];
192 }
193
194 /// Return the number of fixed parameters this function type requires.
195 /// This does not consider varargs.
196 unsigned getNumParams() const { return NumContainedTys - 1; }
197
198 /// Methods for support type inquiry through isa, cast, and dyn_cast.
199 static bool classof(const Type *T) {
200 return T->getTypeID() == FunctionTyID;
201 }
202};
203static_assert(alignof(FunctionType) >= alignof(Type *),
204 "Alignment sufficient for objects appended to FunctionType");
205
207 return cast<FunctionType>(this)->isVarArg();
208}
209
211 return cast<FunctionType>(this)->getParamType(i);
212}
213
215 return cast<FunctionType>(this)->getNumParams();
216}
217
218/// A handy container for a FunctionType+Callee-pointer pair, which can be
219/// passed around as a single entity. This assists in replacing the use of
220/// PointerType::getElementType() to access the function's type, since that's
221/// slated for removal as part of the [opaque pointer types] project.
223public:
224 // Allow implicit conversion from types which have a getFunctionType member
225 // (e.g. Function and InlineAsm).
226 template <typename T, typename U = decltype(&T::getFunctionType)>
228 : FnTy(Fn ? Fn->getFunctionType() : nullptr), Callee(Fn) {}
229
231 : FnTy(FnTy), Callee(Callee) {
232 assert((FnTy == nullptr) == (Callee == nullptr));
233 }
234
235 FunctionCallee(std::nullptr_t) {}
236
237 FunctionCallee() = default;
238
239 FunctionType *getFunctionType() { return FnTy; }
240
241 Value *getCallee() { return Callee; }
242
243 explicit operator bool() { return Callee; }
244
245private:
246 FunctionType *FnTy = nullptr;
247 Value *Callee = nullptr;
248};
249
250/// Class to represent struct types. There are two different kinds of struct
251/// types: Literal structs and Identified structs.
252///
253/// Literal struct types (e.g. { i32, i32 }) are uniqued structurally, and must
254/// always have a body when created. You can get one of these by using one of
255/// the StructType::get() forms.
256///
257/// Identified structs (e.g. %foo or %42) may optionally have a name and are not
258/// uniqued. The names for identified structs are managed at the LLVMContext
259/// level, so there can only be a single identified struct with a given name in
260/// a particular LLVMContext. Identified structs may also optionally be opaque
261/// (have no body specified). You get one of these by using one of the
262/// StructType::create() forms.
263///
264/// Independent of what kind of struct you have, the body of a struct type are
265/// laid out in memory consecutively with the elements directly one after the
266/// other (if the struct is packed) or (if not packed) with padding between the
267/// elements as defined by DataLayout (which is required to match what the code
268/// generator for a target expects).
269///
270class StructType : public Type {
271 StructType(LLVMContext &C) : Type(C, StructTyID) {}
272
273 enum {
274 /// This is the contents of the SubClassData field.
275 SCDB_HasBody = 1,
276 SCDB_Packed = 2,
277 SCDB_IsLiteral = 4,
278 SCDB_IsSized = 8,
279 SCDB_ContainsScalableVector = 16,
280 SCDB_NotContainsScalableVector = 32,
281 SCDB_ContainsNonGlobalTargetExtType = 64,
282 SCDB_NotContainsNonGlobalTargetExtType = 128,
283 SCDB_ContainsNonLocalTargetExtType = 64,
284 SCDB_NotContainsNonLocalTargetExtType = 128,
285 };
286
287 /// For a named struct that actually has a name, this is a pointer to the
288 /// symbol table entry (maintained by LLVMContext) for the struct.
289 /// This is null if the type is an literal struct or if it is a identified
290 /// type that has an empty name.
291 void *SymbolTableEntry = nullptr;
292
293public:
294 StructType(const StructType &) = delete;
295 StructType &operator=(const StructType &) = delete;
296
297 /// This creates an identified struct.
298 LLVM_ABI static StructType *create(LLVMContext &Context, StringRef Name);
299 LLVM_ABI static StructType *create(LLVMContext &Context);
300
301 LLVM_ABI static StructType *create(ArrayRef<Type *> Elements, StringRef Name,
302 bool isPacked = false);
303 LLVM_ABI static StructType *create(ArrayRef<Type *> Elements);
304 LLVM_ABI static StructType *create(LLVMContext &Context,
305 ArrayRef<Type *> Elements, StringRef Name,
306 bool isPacked = false);
307 LLVM_ABI static StructType *create(LLVMContext &Context,
308 ArrayRef<Type *> Elements);
309 template <class... Tys>
310 static std::enable_if_t<are_base_of<Type, Tys...>::value, StructType *>
311 create(StringRef Name, Type *elt1, Tys *... elts) {
312 assert(elt1 && "Cannot create a struct type with no elements with this");
313 return create(ArrayRef<Type *>({elt1, elts...}), Name);
314 }
315
316 /// This static method is the primary way to create a literal StructType.
317 LLVM_ABI static StructType *
318 get(LLVMContext &Context, ArrayRef<Type *> Elements, bool isPacked = false);
319
320 /// Create an empty structure type.
321 LLVM_ABI static StructType *get(LLVMContext &Context, bool isPacked = false);
322
323 /// This static method is a convenience method for creating structure types by
324 /// specifying the elements as arguments. Note that this method always returns
325 /// a non-packed struct, and requires at least one element type.
326 template <class... Tys>
327 static std::enable_if_t<are_base_of<Type, Tys...>::value, StructType *>
328 get(Type *elt1, Tys *... elts) {
329 assert(elt1 && "Cannot create a struct type with no elements with this");
330 LLVMContext &Ctx = elt1->getContext();
331 return StructType::get(Ctx, ArrayRef<Type *>({elt1, elts...}));
332 }
333
334 /// Return the type with the specified name, or null if there is none by that
335 /// name.
337
338 bool isPacked() const { return (getSubclassData() & SCDB_Packed) != 0; }
339
340 /// Return true if this type is uniqued by structural equivalence, false if it
341 /// is a struct definition.
342 bool isLiteral() const { return (getSubclassData() & SCDB_IsLiteral) != 0; }
343
344 /// Return true if this is a type with an identity that has no body specified
345 /// yet. These prints as 'opaque' in .ll files.
346 bool isOpaque() const { return (getSubclassData() & SCDB_HasBody) == 0; }
347
348 /// isSized - Return true if this is a sized type.
349 LLVM_ABI bool isSized(SmallPtrSetImpl<Type *> *Visited = nullptr) const;
350
351 /// Returns true if this struct contains a scalable vector.
353 using Type::isScalableTy;
354
355 /// Return true if this type is or contains a target extension type that
356 /// disallows being used as a global.
357 LLVM_ABI bool
360
361 /// Return true if this type is or contains a target extension type that
362 /// disallows being used as a local.
363 LLVM_ABI bool
366
367 /// Returns true if this struct contains homogeneous scalable vector types.
368 /// Note that the definition of homogeneous scalable vector type is not
369 /// recursive here. That means the following structure will return false
370 /// when calling this function.
371 /// {{<vscale x 2 x i32>, <vscale x 4 x i64>},
372 /// {<vscale x 2 x i32>, <vscale x 4 x i64>}}
374
375 /// Return true if this struct is non-empty and all element types are the
376 /// same.
378
379 /// Return true if this is a named struct that has a non-empty name.
380 bool hasName() const { return SymbolTableEntry != nullptr; }
381
382 /// Return the name for this struct type if it has an identity.
383 /// This may return an empty string for an unnamed struct type. Do not call
384 /// this on an literal type.
385 LLVM_ABI StringRef getName() const;
386
387 /// Change the name of this type to the specified name, or to a name with a
388 /// suffix if there is a collision. Do not call this on an literal type.
389 LLVM_ABI void setName(StringRef Name);
390
391 /// Specify a body for an opaque identified type, which must not make the type
392 /// recursive.
393 LLVM_ABI void setBody(ArrayRef<Type *> Elements, bool isPacked = false);
394
395 /// Specify a body for an opaque identified type or return an error if it
396 /// would make the type recursive.
398 bool isPacked = false);
399
400 /// Return an error if the body for an opaque identified type would make it
401 /// recursive.
403
404 /// Return true if the specified type is valid as a element type.
405 LLVM_ABI static bool isValidElementType(Type *ElemTy);
406
407 // Iterator access to the elements.
409
414 }
415
416 /// Return true if this is layout identical to the specified struct.
418
419 /// Random access to the elements
420 unsigned getNumElements() const { return NumContainedTys; }
421 Type *getElementType(unsigned N) const {
422 assert(N < NumContainedTys && "Element number out of range!");
423 return ContainedTys[N];
424 }
425 /// Given an index value into the type, return the type of the element.
426 LLVM_ABI Type *getTypeAtIndex(const Value *V) const;
427 Type *getTypeAtIndex(unsigned N) const { return getElementType(N); }
428 LLVM_ABI bool indexValid(const Value *V) const;
429 bool indexValid(unsigned Idx) const { return Idx < getNumElements(); }
430
431 /// Methods for support type inquiry through isa, cast, and dyn_cast.
432 static bool classof(const Type *T) {
433 return T->getTypeID() == StructTyID;
434 }
435};
436
438 return cast<StructType>(this)->getName();
439}
440
442 return cast<StructType>(this)->getNumElements();
443}
444
446 return cast<StructType>(this)->getElementType(N);
447}
448
449/// Class to represent array types.
450class ArrayType : public Type {
451 /// The element type of the array.
452 Type *ContainedType;
453 /// Number of elements in the array.
454 uint64_t NumElements;
455
456 ArrayType(Type *ElType, uint64_t NumEl);
457
458public:
459 ArrayType(const ArrayType &) = delete;
460 ArrayType &operator=(const ArrayType &) = delete;
461
462 uint64_t getNumElements() const { return NumElements; }
463 Type *getElementType() const { return ContainedType; }
464
465 /// This static method is the primary way to construct an ArrayType
466 LLVM_ABI static ArrayType *get(Type *ElementType, uint64_t NumElements);
467
468 /// Return true if the specified type is valid as a element type.
469 LLVM_ABI static bool isValidElementType(Type *ElemTy);
470
471 /// Methods for support type inquiry through isa, cast, and dyn_cast.
472 static bool classof(const Type *T) {
473 return T->getTypeID() == ArrayTyID;
474 }
475};
476
478 return cast<ArrayType>(this)->getNumElements();
479}
480
481/// Base class of all SIMD vector types
482class VectorType : public Type {
483 /// A fully specified VectorType is of the form <vscale x n x Ty>. 'n' is the
484 /// minimum number of elements of type Ty contained within the vector, and
485 /// 'vscale x' indicates that the total element count is an integer multiple
486 /// of 'n', where the multiple is either guaranteed to be one, or is
487 /// statically unknown at compile time.
488 ///
489 /// If the multiple is known to be 1, then the extra term is discarded in
490 /// textual IR:
491 ///
492 /// <4 x i32> - a vector containing 4 i32s
493 /// <vscale x 4 x i32> - a vector containing an unknown integer multiple
494 /// of 4 i32s
495
496 /// The element type of the vector.
497 Type *ContainedType;
498
499protected:
500 /// The element quantity of this vector. The meaning of this value depends
501 /// on the type of vector:
502 /// - For FixedVectorType = <ElementQuantity x ty>, there are
503 /// exactly ElementQuantity elements in this vector.
504 /// - For ScalableVectorType = <vscale x ElementQuantity x ty>,
505 /// there are vscale * ElementQuantity elements in this vector, where
506 /// vscale is a runtime-constant integer greater than 0.
507 const unsigned ElementQuantity;
508
509 LLVM_ABI VectorType(Type *ElType, unsigned EQ, Type::TypeID TID);
510
511public:
512 VectorType(const VectorType &) = delete;
513 VectorType &operator=(const VectorType &) = delete;
514
515 Type *getElementType() const { return ContainedType; }
516
517 /// This static method is the primary way to construct an VectorType.
518 LLVM_ABI static VectorType *get(Type *ElementType, ElementCount EC);
519
520 static VectorType *get(Type *ElementType, unsigned NumElements,
521 bool Scalable) {
522 return VectorType::get(ElementType,
523 ElementCount::get(NumElements, Scalable));
524 }
525
526 static VectorType *get(Type *ElementType, const VectorType *Other) {
527 return VectorType::get(ElementType, Other->getElementCount());
528 }
529
530 /// This static method gets a VectorType with the same number of elements as
531 /// the input type, and the element type is an integer type of the same width
532 /// as the input element type.
534 unsigned EltBits =
536 assert(EltBits && "Element size must be of a non-zero size");
537 Type *EltTy = IntegerType::get(VTy->getContext(), EltBits);
538 return VectorType::get(EltTy, VTy->getElementCount());
539 }
540
541 /// This static method is like getInteger except that the element types are
542 /// twice as wide as the elements in the input type.
544 assert(VTy->isIntOrIntVectorTy() && "VTy expected to be a vector of ints.");
545 auto *EltTy = cast<IntegerType>(VTy->getElementType());
546 return VectorType::get(EltTy->getExtendedType(), VTy->getElementCount());
547 }
548
549 // This static method gets a VectorType with the same number of elements as
550 // the input type, and the element type is an integer or float type which
551 // is half as wide as the elements in the input type.
553 Type *EltTy = VTy->getElementType();
554 if (EltTy->isFloatingPointTy()) {
555 switch (EltTy->getTypeID()) {
556 case DoubleTyID:
557 EltTy = Type::getFloatTy(VTy->getContext());
558 break;
559 case FloatTyID:
560 EltTy = Type::getHalfTy(VTy->getContext());
561 break;
562 default:
563 llvm_unreachable("Cannot create narrower fp vector element type");
564 }
565 } else {
566 EltTy = cast<IntegerType>(EltTy)->getTruncatedType();
567 }
568 return VectorType::get(EltTy, VTy->getElementCount());
569 }
570
571 // This static method returns a VectorType with a larger number of elements
572 // of a smaller type than the input element type. For example, a <4 x i64>
573 // subdivided twice would return <16 x i16>
574 static VectorType *getSubdividedVectorType(VectorType *VTy, int NumSubdivs) {
575 for (int i = 0; i < NumSubdivs; ++i) {
578 }
579 return VTy;
580 }
581
582 /// This static method returns a VectorType with half as many elements as the
583 /// input type and the same element type.
585 auto EltCnt = VTy->getElementCount();
586 assert(EltCnt.isKnownEven() &&
587 "Cannot halve vector with odd number of elements.");
588 return VectorType::get(VTy->getElementType(),
589 EltCnt.divideCoefficientBy(2));
590 }
591
593 unsigned Denominator) {
594 auto EltCnt = VTy->getElementCount();
595 assert(EltCnt.isKnownMultipleOf(Denominator) &&
596 "Cannot take one-nth of a vector");
597 return VectorType::get(VTy->getScalarType(),
598 EltCnt.divideCoefficientBy(Denominator));
599 }
600
601 /// This static method returns a VectorType with twice as many elements as the
602 /// input type and the same element type.
604 auto EltCnt = VTy->getElementCount();
605 assert((EltCnt.getKnownMinValue() * 2ull) <= UINT_MAX &&
606 "Too many elements in vector");
607 return VectorType::get(VTy->getElementType(), EltCnt * 2);
608 }
609
610 /// This static method attempts to construct a VectorType with the same
611 /// size-in-bits as SizeTy but with an element type that matches the scalar
612 /// type of EltTy. The VectorType is returned on success, nullptr otherwise.
614 if (SizeTy->getScalarType() == EltTy->getScalarType())
615 return SizeTy;
616
617 unsigned EltSize = EltTy->getScalarSizeInBits();
618 if (!SizeTy->getPrimitiveSizeInBits().isKnownMultipleOf(EltSize))
619 return nullptr;
620
621 ElementCount EC = SizeTy->getElementCount()
623 .divideCoefficientBy(EltSize);
624 return VectorType::get(EltTy->getScalarType(), EC);
625 }
626
627 /// Return true if the specified type is valid as a element type.
628 LLVM_ABI static bool isValidElementType(Type *ElemTy);
629
630 /// Return an ElementCount instance to represent the (possibly scalable)
631 /// number of elements in the vector.
632 inline ElementCount getElementCount() const;
633
634 /// Methods for support type inquiry through isa, cast, and dyn_cast.
635 static bool classof(const Type *T) {
636 return T->getTypeID() == FixedVectorTyID ||
637 T->getTypeID() == ScalableVectorTyID;
638 }
639};
640
641/// Class to represent fixed width SIMD vectors
643protected:
644 FixedVectorType(Type *ElTy, unsigned NumElts)
645 : VectorType(ElTy, NumElts, FixedVectorTyID) {}
646
647public:
648 LLVM_ABI static FixedVectorType *get(Type *ElementType, unsigned NumElts);
649
650 static FixedVectorType *get(Type *ElementType, const FixedVectorType *FVTy) {
651 return get(ElementType, FVTy->getNumElements());
652 }
653
657
661
666
668 int NumSubdivs) {
670 VectorType::getSubdividedVectorType(VTy, NumSubdivs));
671 }
672
676
680
681 static bool classof(const Type *T) {
682 return T->getTypeID() == FixedVectorTyID;
683 }
684
685 unsigned getNumElements() const { return ElementQuantity; }
686};
687
688/// Class to represent scalable SIMD vectors
690protected:
691 ScalableVectorType(Type *ElTy, unsigned MinNumElts)
692 : VectorType(ElTy, MinNumElts, ScalableVectorTyID) {}
693
694public:
695 LLVM_ABI static ScalableVectorType *get(Type *ElementType,
696 unsigned MinNumElts);
697
698 static ScalableVectorType *get(Type *ElementType,
699 const ScalableVectorType *SVTy) {
700 return get(ElementType, SVTy->getMinNumElements());
701 }
702
706
707 static ScalableVectorType *
712
713 static ScalableVectorType *
718
720 int NumSubdivs) {
722 VectorType::getSubdividedVectorType(VTy, NumSubdivs));
723 }
724
725 static ScalableVectorType *
729
730 static ScalableVectorType *
735
736 /// Get the minimum number of elements in this vector. The actual number of
737 /// elements in the vector is an integer multiple of this value.
738 unsigned getMinNumElements() const { return ElementQuantity; }
739
740 static bool classof(const Type *T) {
741 return T->getTypeID() == ScalableVectorTyID;
742 }
743};
744
748
749/// Class to represent pointers.
750class PointerType : public Type {
751 explicit PointerType(LLVMContext &C, unsigned AddrSpace);
752
753public:
754 PointerType(const PointerType &) = delete;
755 PointerType &operator=(const PointerType &) = delete;
756
757 /// This constructs a pointer to an object of the specified type in a numbered
758 /// address space.
759 [[deprecated("PointerType::get with pointee type is pending removal. Use "
760 "Context overload.")]]
761 LLVM_ABI static PointerType *get(Type *ElementType, unsigned AddressSpace);
762 /// This constructs an opaque pointer to an object in a numbered address
763 /// space.
764 LLVM_ABI static PointerType *get(LLVMContext &C, unsigned AddressSpace);
765
766 /// This constructs a pointer to an object of the specified type in the
767 /// default address space (address space zero).
768 [[deprecated("PointerType::getUnqual with pointee type is pending removal. "
769 "Use Context overload.")]]
770 static PointerType *getUnqual(Type *ElementType) {
771 assert(ElementType && "Can't get a pointer to <null> type!");
772 assert(isValidElementType(ElementType) &&
773 "Invalid type for pointer element!");
774 return PointerType::getUnqual(ElementType->getContext());
775 }
776
777 /// This constructs an opaque pointer to an object in the
778 /// default address space (address space zero).
779 static PointerType *getUnqual(LLVMContext &C) {
780 return PointerType::get(C, 0);
781 }
782
783 /// Return true if the specified type is valid as a element type.
784 LLVM_ABI static bool isValidElementType(Type *ElemTy);
785
786 /// Return true if we can load or store from a pointer to this type.
787 LLVM_ABI static bool isLoadableOrStorableType(Type *ElemTy);
788
789 /// Return the address space of the Pointer type.
790 inline unsigned getAddressSpace() const { return getSubclassData(); }
791
792 /// Implement support type inquiry through isa, cast, and dyn_cast.
793 static bool classof(const Type *T) {
794 return T->getTypeID() == PointerTyID;
795 }
796};
797
799 assert(
801 "Original type expected to be a vector of integers or a scalar integer.");
802 if (auto *VTy = dyn_cast<VectorType>(this))
804 const_cast<VectorType *>(VTy));
805 return cast<IntegerType>(this)->getExtendedType();
806}
807
809 assert(
811 "Original type expected to be a vector of integers or a scalar integer.");
812 if (auto *VTy = dyn_cast<VectorType>(this))
814 const_cast<VectorType *>(VTy));
815 return cast<IntegerType>(this)->getTruncatedType();
816}
817
819 if (auto *VTy = dyn_cast<VectorType>(this))
820 return VectorType::get(EltTy, VTy->getElementCount());
821 return EltTy;
822}
823
824Type *Type::getWithNewBitWidth(unsigned NewBitWidth) const {
825 assert(
827 "Original type expected to be a vector of integers or a scalar integer.");
828 return getWithNewType(getIntNTy(getContext(), NewBitWidth));
829}
830
832 return cast<PointerType>(getScalarType())->getAddressSpace();
833}
834
835/// Class to represent target extensions types, which are generally
836/// unintrospectable from target-independent optimizations.
837///
838/// Target extension types have a string name, and optionally have type and/or
839/// integer parameters. The exact meaning of any parameters is dependent on the
840/// target.
841class TargetExtType : public Type {
842 TargetExtType(LLVMContext &C, StringRef Name, ArrayRef<Type *> Types,
843 ArrayRef<unsigned> Ints);
844
845 // These strings are ultimately owned by the context.
846 StringRef Name;
847 unsigned *IntParams;
848
849public:
850 TargetExtType(const TargetExtType &) = delete;
851 TargetExtType &operator=(const TargetExtType &) = delete;
852
853 /// Return a target extension type having the specified name and optional
854 /// type and integer parameters.
855 LLVM_ABI static TargetExtType *get(LLVMContext &Context, StringRef Name,
856 ArrayRef<Type *> Types = {},
857 ArrayRef<unsigned> Ints = {});
858
859 /// Return a target extension type having the specified name and optional
860 /// type and integer parameters, or an appropriate Error if it fails the
861 /// parameters check.
862 LLVM_ABI static Expected<TargetExtType *>
863 getOrError(LLVMContext &Context, StringRef Name, ArrayRef<Type *> Types = {},
864 ArrayRef<unsigned> Ints = {});
865
866 /// Check that a newly created target extension type has the expected number
867 /// of type parameters and integer parameters, returning the type itself if OK
868 /// or an appropriate Error if not.
869 LLVM_ABI static Expected<TargetExtType *> checkParams(TargetExtType *TTy);
870
871 /// Return the name for this target extension type. Two distinct target
872 /// extension types may have the same name if their type or integer parameters
873 /// differ.
874 StringRef getName() const { return Name; }
875
876 /// Return the type parameters for this particular target extension type. If
877 /// there are no parameters, an empty array is returned.
881
887
888 Type *getTypeParameter(unsigned i) const { return getContainedType(i); }
889 unsigned getNumTypeParameters() const { return getNumContainedTypes(); }
890
891 /// Return the integer parameters for this particular target extension type.
892 /// If there are no parameters, an empty array is returned.
894 return ArrayRef(IntParams, getNumIntParameters());
895 }
896
897 unsigned getIntParameter(unsigned i) const { return IntParams[i]; }
898 unsigned getNumIntParameters() const { return getSubclassData(); }
899
900 enum Property {
901 /// zeroinitializer is valid for this target extension type.
902 HasZeroInit = 1U << 0,
903 /// This type may be used as the value type of a global variable.
904 CanBeGlobal = 1U << 1,
905 /// This type may be allocated on the stack, either as the allocated type
906 /// of an alloca instruction or as a byval function parameter.
907 CanBeLocal = 1U << 2,
908 /// This type may be used as an element in a vector.
910 // This type can only be used in intrinsic arguments and return values.
911 /// In particular, it cannot be used in select and phi instructions.
912 IsTokenLike = 1U << 4,
913 };
914
915 /// Returns true if the target extension type contains the given property.
916 LLVM_ABI bool hasProperty(Property Prop) const;
917
918 /// Returns an underlying layout type for the target extension type. This
919 /// type can be used to query size and alignment information, if it is
920 /// appropriate (although note that the layout type may also be void). It is
921 /// not legal to bitcast between this type and the layout type, however.
922 LLVM_ABI Type *getLayoutType() const;
923
924 /// Methods for support type inquiry through isa, cast, and dyn_cast.
925 static bool classof(const Type *T) { return T->getTypeID() == TargetExtTyID; }
926};
927
929 return cast<TargetExtType>(this)->getName();
930}
931
932} // end namespace llvm
933
934#endif // LLVM_IR_DERIVEDTYPES_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:213
#define T
This file contains some templates that are useful if you are working with the STL at all.
Class for arbitrary precision integers.
Definition APInt.h:78
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
uint64_t getNumElements() const
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Definition Type.cpp:835
ArrayType & operator=(const ArrayType &)=delete
ArrayType(const ArrayType &)=delete
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
Type * getElementType() const
Class to represent byte types.
@ MIN_BYTE_BITS
Minimum number of bits that can be specified.
@ MAX_BYTE_BITS
Maximum number of bits that can be specified Note that bit width is stored in the Type classes Subcla...
unsigned getBitWidth() const
Get the number of bits in this ByteType.
static LLVM_ABI ByteType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing a ByteType.
Definition Type.cpp:384
ByteType(LLVMContext &C, unsigned NumBits)
friend class LLVMContextImpl
LLVM_ABI APInt getMask() const
For example, this is 0xFF for an 8 bit byte, 0xFFFF for b16, etc.
Definition Type.cpp:412
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
Definition TypeSize.h:315
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
Class to represent fixed width SIMD vectors.
unsigned getNumElements() const
static FixedVectorType * getDoubleElementsVectorType(FixedVectorType *VTy)
static FixedVectorType * getInteger(FixedVectorType *VTy)
static FixedVectorType * getSubdividedVectorType(FixedVectorType *VTy, int NumSubdivs)
static FixedVectorType * getExtendedElementVectorType(FixedVectorType *VTy)
FixedVectorType(Type *ElTy, unsigned NumElts)
static FixedVectorType * get(Type *ElementType, const FixedVectorType *FVTy)
static FixedVectorType * getTruncatedElementVectorType(FixedVectorType *VTy)
static bool classof(const Type *T)
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Definition Type.cpp:873
static FixedVectorType * getHalfElementsVectorType(FixedVectorType *VTy)
FunctionCallee(std::nullptr_t)
FunctionType * getFunctionType()
FunctionCallee()=default
FunctionCallee(FunctionType *FnTy, Value *Callee)
Class to represent function types.
param_iterator param_begin() const
static LLVM_ABI bool isValidArgumentType(Type *ArgTy)
Return true if the specified type is valid as an argument type.
Definition Type.cpp:473
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
Type::subtype_iterator param_iterator
Type * getParamType(unsigned i) const
Parameter type accessors.
static LLVM_ABI bool isValidReturnType(Type *RetTy)
Return true if the specified type is valid as a return type.
Definition Type.cpp:468
FunctionType(const FunctionType &)=delete
ArrayRef< Type * > params() const
FunctionType & operator=(const FunctionType &)=delete
bool isVarArg() const
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
Type * getReturnType() const
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
param_iterator param_end() const
Class to represent integer types.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition Type.cpp:354
uint64_t getSignBit() const
Return a uint64_t with just the most significant bit set (the sign bit, if the value is treated as a ...
LLVM_ABI APInt getMask() const
For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc.
Definition Type.cpp:378
IntegerType * getExtendedType() const
Returns type twice as wide the input type.
@ MIN_INT_BITS
Minimum number of bits that can be specified.
@ MAX_INT_BITS
Maximum number of bits that can be specified.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
uint64_t getBitMask() const
Return a bitmask with ones set for all of the bits that can be set by an unsigned version of this typ...
friend class LLVMContextImpl
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
IntegerType * getTruncatedType() const
Returns type half as wide the input type.
IntegerType(LLVMContext &C, unsigned NumBits)
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
static LLVM_ABI bool isLoadableOrStorableType(Type *ElemTy)
Return true if we can load or store from a pointer to this type.
Definition Type.cpp:952
PointerType(const PointerType &)=delete
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
static bool classof(const Type *T)
Implement support type inquiry through isa, cast, and dyn_cast.
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Definition Type.cpp:946
PointerType & operator=(const PointerType &)=delete
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
unsigned getAddressSpace() const
Return the address space of the Pointer type.
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
Class to represent scalable SIMD vectors.
static ScalableVectorType * get(Type *ElementType, const ScalableVectorType *SVTy)
static ScalableVectorType * getInteger(ScalableVectorType *VTy)
static LLVM_ABI ScalableVectorType * get(Type *ElementType, unsigned MinNumElts)
Definition Type.cpp:895
static bool classof(const Type *T)
static ScalableVectorType * getExtendedElementVectorType(ScalableVectorType *VTy)
static ScalableVectorType * getHalfElementsVectorType(ScalableVectorType *VTy)
static ScalableVectorType * getSubdividedVectorType(ScalableVectorType *VTy, int NumSubdivs)
static ScalableVectorType * getDoubleElementsVectorType(ScalableVectorType *VTy)
unsigned getMinNumElements() const
Get the minimum number of elements in this vector.
ScalableVectorType(Type *ElTy, unsigned MinNumElts)
static ScalableVectorType * getTruncatedElementVectorType(ScalableVectorType *VTy)
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Class to represent struct types.
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
static std::enable_if_t< are_base_of< Type, Tys... >::value, StructType * > create(StringRef Name, Type *elt1, Tys *... elts)
LLVM_ABI bool indexValid(const Value *V) const
Definition Type.cpp:794
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Definition Type.cpp:483
element_iterator element_end() const
StructType(const StructType &)=delete
ArrayRef< Type * > elements() const
LLVM_ABI void setBody(ArrayRef< Type * > Elements, bool isPacked=false)
Specify a body for an opaque identified type, which must not make the type recursive.
Definition Type.cpp:604
LLVM_ABI bool containsHomogeneousScalableVectorTypes() const
Returns true if this struct contains homogeneous scalable vector types.
Definition Type.cpp:593
LLVM_ABI Error checkBody(ArrayRef< Type * > Elements)
Return an error if the body for an opaque identified type would make it recursive.
Definition Type.cpp:626
LLVM_ABI bool containsHomogeneousTypes() const
Return true if this struct is non-empty and all element types are the same.
Definition Type.cpp:599
element_iterator element_begin() const
static LLVM_ABI StructType * getTypeByName(LLVMContext &C, StringRef Name)
Return the type with the specified name, or null if there is none by that name.
Definition Type.cpp:808
static LLVM_ABI StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Definition Type.cpp:689
bool isPacked() const
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Definition Type.cpp:773
unsigned getNumElements() const
Random access to the elements.
LLVM_ABI bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
isSized - Return true if this is a sized type.
Definition Type.cpp:728
Type * getTypeAtIndex(unsigned N) const
StructType & operator=(const StructType &)=delete
LLVM_ABI void setName(StringRef Name)
Change the name of this type to the specified name, or to a name with a suffix if there is a collisio...
Definition Type.cpp:638
LLVM_ABI bool isLayoutIdentical(StructType *Other) const
Return true if this is layout identical to the specified struct.
Definition Type.cpp:779
LLVM_ABI bool isScalableTy() const
Definition Type.cpp:73
LLVM_ABI Error setBodyOrError(ArrayRef< Type * > Elements, bool isPacked=false)
Specify a body for an opaque identified type or return an error if it would make the type recursive.
Definition Type.cpp:608
LLVM_ABI Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
Definition Type.cpp:788
bool hasName() const
Return true if this is a named struct that has a non-empty name.
bool isLiteral() const
Return true if this type is uniqued by structural equivalence, false if it is a struct definition.
bool indexValid(unsigned Idx) const
LLVM_ABI bool containsNonLocalTargetExtType() const
Definition Type.cpp:105
LLVM_ABI bool containsNonGlobalTargetExtType() const
Definition Type.cpp:89
bool isOpaque() const
Return true if this is a type with an identity that has no body specified yet.
Type * getElementType(unsigned N) const
Type::subtype_iterator element_iterator
static std::enable_if_t< are_base_of< Type, Tys... >::value, StructType * > get(Type *elt1, Tys *... elts)
This static method is a convenience method for creating structure types by specifying the elements as...
LLVM_ABI StringRef getName() const
Return the name for this struct type if it has an identity.
Definition Type.cpp:766
ArrayRef< Type * > type_params() const
Return the type parameters for this particular target extension type.
unsigned getNumIntParameters() const
type_param_iterator type_param_end() const
Type::subtype_iterator type_param_iterator
static LLVM_ABI TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types={}, ArrayRef< unsigned > Ints={})
Return a target extension type having the specified name and optional type and integer parameters.
Definition Type.cpp:978
Type * getTypeParameter(unsigned i) const
unsigned getNumTypeParameters() const
ArrayRef< unsigned > int_params() const
Return the integer parameters for this particular target extension type.
type_param_iterator type_param_begin() const
static LLVM_ABI Expected< TargetExtType * > checkParams(TargetExtType *TTy)
Check that a newly created target extension type has the expected number of type parameters and integ...
Definition Type.cpp:1012
unsigned getIntParameter(unsigned i) const
TargetExtType(const TargetExtType &)=delete
LLVM_ABI bool hasProperty(Property Prop) const
Returns true if the target extension type contains the given property.
Definition Type.cpp:1148
TargetExtType & operator=(const TargetExtType &)=delete
@ IsTokenLike
In particular, it cannot be used in select and phi instructions.
@ HasZeroInit
zeroinitializer is valid for this target extension type.
@ CanBeVectorElement
This type may be used as an element in a vector.
@ CanBeGlobal
This type may be used as the value type of a global variable.
@ CanBeLocal
This type may be allocated on the stack, either as the allocated type of an alloca instruction or as ...
StringRef getName() const
Return the name for this target extension type.
static LLVM_ABI Expected< TargetExtType * > getOrError(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types={}, ArrayRef< unsigned > Ints={})
Return a target extension type having the specified name and optional type and integer parameters,...
Definition Type.cpp:984
LLVM_ABI Type * getLayoutType() const
Returns an underlying layout type for the target extension type.
Definition Type.cpp:1144
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM_ABI unsigned getIntegerBitWidth() const
LLVM_ABI Type * getStructElementType(unsigned N) const
LLVM_ABI Type * getTruncatedType() const
Given scalar/vector integer type, returns a type with elements half as wide as in the original type.
LLVM_ABI bool containsNonGlobalTargetExtType(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this type is or contains a target extension type that disallows being used as a global...
Definition Type.cpp:78
LLVM_ABI bool containsNonLocalTargetExtType(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this type is or contains a target extension type that disallows being used as a local.
Definition Type.cpp:94
LLVM_ABI bool isScalableTy(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this is a type whose size is a known multiple of vscale.
Definition Type.cpp:65
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition Type.h:263
LLVM_ABI StringRef getStructName() const
Type *const * subtype_iterator
Definition Type.h:379
LLVM_ABI unsigned getStructNumElements() const
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
LLVM_ABI uint64_t getArrayNumElements() const
TypeID
Definitions of all of the base types for the Type system.
Definition Type.h:55
@ FunctionTyID
Functions.
Definition Type.h:73
@ ArrayTyID
Arrays.
Definition Type.h:76
@ TargetExtTyID
Target extension type.
Definition Type.h:80
@ ScalableVectorTyID
Scalable SIMD vector type.
Definition Type.h:78
@ FloatTyID
32-bit floating point type
Definition Type.h:59
@ StructTyID
Structures.
Definition Type.h:75
@ IntegerTyID
Arbitrary bit width integers.
Definition Type.h:71
@ FixedVectorTyID
Fixed width SIMD vector type.
Definition Type.h:77
@ DoubleTyID
64-bit floating point type
Definition Type.h:60
@ ByteTyID
Arbitrary bit width bytes.
Definition Type.h:72
@ PointerTyID
Pointers.
Definition Type.h:74
unsigned getNumContainedTypes() const
Return the number of types in the derived type.
Definition Type.h:405
unsigned NumContainedTys
Keeps track of how many Type*'s there are in the ContainedTys list.
Definition Type.h:108
LLVM_ABI StringRef getTargetExtName() const
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition Type.h:370
Type(LLVMContext &C, TypeID tid)
Definition Type.h:95
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Definition Type.cpp:201
LLVM_ABI Type * getWithNewBitWidth(unsigned NewBitWidth) const
Given an integer or vector type, change the lane bitwidth to NewBitwidth, whilst keeping the old numb...
LLVM_ABI Type * getWithNewType(Type *EltTy) const
Given vector type, change the element type, whilst keeping the old number of elements.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition Type.h:130
Type *const * ContainedTys
A pointer to the array of Types contained by this Type.
Definition Type.h:115
unsigned getSubclassData() const
Definition Type.h:99
LLVM_ABI bool isFunctionVarArg() const
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Definition Type.cpp:236
void setSubclassData(unsigned val)
Definition Type.h:101
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
Definition Type.h:186
LLVM_ABI unsigned getByteBitWidth() const
LLVM_ABI Type * getExtendedType() const
Given scalar/vector integer type, returns a type with elements twice as wide as in the original type.
TypeID getTypeID() const
Return the type id for the type.
Definition Type.h:138
LLVM_ABI Type * getFunctionParamType(unsigned i) const
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Definition Type.cpp:317
Type * getContainedType(unsigned i) const
This method is used to implement the type iterator (defined at the end of the file).
Definition Type.h:399
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
Definition Type.cpp:290
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
Definition Type.cpp:288
LLVM_ABI unsigned getFunctionNumParams() const
LLVM Value Representation.
Definition Value.h:75
Base class of all SIMD vector types.
static VectorType * getHalfElementsVectorType(VectorType *VTy)
This static method returns a VectorType with half as many elements as the input type and the same ele...
LLVM_ABI VectorType(Type *ElType, unsigned EQ, Type::TypeID TID)
Definition Type.cpp:845
static VectorType * getExtendedElementVectorType(VectorType *VTy)
This static method is like getInteger except that the element types are twice as wide as the elements...
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
static VectorType * getOneNthElementsVectorType(VectorType *VTy, unsigned Denominator)
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
static VectorType * getSubdividedVectorType(VectorType *VTy, int NumSubdivs)
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type,...
const unsigned ElementQuantity
The element quantity of this vector.
static VectorType * get(Type *ElementType, const VectorType *Other)
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
VectorType & operator=(const VectorType &)=delete
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
static VectorType * getDoubleElementsVectorType(VectorType *VTy)
This static method returns a VectorType with twice as many elements as the input type and the same el...
static VectorType * getWithSizeAndScalar(VectorType *SizeTy, Type *EltTy)
This static method attempts to construct a VectorType with the same size-in-bits as SizeTy but with a...
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
static VectorType * get(Type *ElementType, unsigned NumElements, bool Scalable)
VectorType(const VectorType &)=delete
Type * getElementType() const
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
constexpr LeafTy multiplyCoefficientBy(ScalarTy RHS) const
Definition TypeSize.h:256
constexpr LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
Definition TypeSize.h:252
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
@ Other
Any other memory.
Definition ModRef.h:68
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
std::conjunction< std::is_base_of< T, Ts >... > are_base_of
traits class for checking whether type T is a base class for all the given types in the variadic list...
Definition STLExtras.h:114
#define N
#define EQ(a, b)
Definition regexec.c:65