Go to the documentation of this file.
17 #ifndef LLVM_IR_DERIVEDTYPES_H
18 #define LLVM_IR_DERIVEDTYPES_H
98 return cast<IntegerType>(
this)->getBitWidth();
147 "Alignment sufficient for objects appended to FunctionType");
150 return cast<FunctionType>(
this)->isVarArg();
154 return cast<FunctionType>(
this)->getParamType(
i);
158 return cast<FunctionType>(
this)->getNumParams();
169 template <
typename T,
typename U = decltype(&T::getFunctionType)>
186 explicit operator bool() {
return Callee; }
190 Value *Callee =
nullptr;
244 template <
class... Tys>
247 assert(elt1 &&
"Cannot create a struct type with no elements with this");
261 template <
class... Tys>
264 assert(elt1 &&
"Cannot create a struct type with no elements with this");
304 template <
typename... Tys>
307 assert(elt1 &&
"Cannot create a struct type with no elements with this");
345 return cast<StructType>(
this)->getName();
349 return cast<StructType>(
this)->getNumElements();
353 return cast<StructType>(
this)->getElementType(
N);
385 return cast<ArrayType>(
this)->getNumElements();
442 assert(EltBits &&
"Element size must be of a non-zero size");
473 assert((EltBits & 1) == 0 &&
474 "Cannot truncate vector element with odd bit-width");
484 for (
int i = 0;
i < NumSubdivs; ++
i) {
495 assert(EltCnt.isKnownEven() &&
496 "Cannot halve vector with odd number of elements.");
498 EltCnt.divideCoefficientBy(2));
505 assert((EltCnt.getKnownMinValue() * 2ull) <= UINT_MAX &&
506 "Too many elements in vector");
546 return cast<FixedVectorType>(
552 return cast<FixedVectorType>(
591 return cast<ScalableVectorType>(
597 return cast<ScalableVectorType>(
603 return cast<ScalableVectorType>(
614 return cast<ScalableVectorType>(
689 return isOpaque() || PointeeTy == Ty;
697 return PointeeTy ==
Other->PointeeTy;
709 "Original type expected to be a vector of integers or a scalar integer.");
710 if (
auto *VTy = dyn_cast<VectorType>(
this))
713 return cast<IntegerType>(
this)->getExtendedType();
717 if (
auto *VTy = dyn_cast<VectorType>(
this))
725 "Original type expected to be a vector of integers or a scalar integer.");
730 return cast<PointerType>(
getScalarType())->getAddressSpace();
735 #endif // LLVM_IR_DERIVEDTYPES_H
bool isFunctionVarArg() const
static ScalableVectorType * getInteger(ScalableVectorType *VTy)
@ FloatTyID
32-bit floating point type
Class to represent scalable SIMD vectors.
static VectorType * getSubdividedVectorType(VectorType *VTy, int NumSubdivs)
@ DoubleTyID
64-bit floating point type
This is an optimization pass for GlobalISel generic memory operations.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
StringRef getName() const
Return the name for this struct type if it has an identity.
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
unsigned getFunctionNumParams() const
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
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 PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
Type::subtype_iterator element_iterator
void setBody(ArrayRef< Type * > Elements, bool isPacked=false)
Specify a body for an opaque identified type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
const unsigned ElementQuantity
The element quantity of this vector.
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...
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
unsigned getSubclassData() const
TypeID getTypeID() const
Return the type id for the type.
The instances of the Type class are immutable: once they are created, they are never changed.
FunctionCallee(FunctionType *FnTy, Value *Callee)
static StructType * getTypeByName(LLVMContext &C, StringRef Name)
Return the type with the specified name, or null if there is none by that name.
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...
bool indexValid(unsigned Idx) const
Type * getElementType() const
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
Type *const * subtype_iterator
Class to represent array types.
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
ScalableVectorType(Type *ElTy, unsigned MinNumElts)
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
Class to represent fixed width SIMD vectors.
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...
Type * getWithNewType(Type *EltTy) const
Given vector type, change the element type, whilst keeping the old number of elements.
IntegerType * getExtendedType() const
Returns type twice as wide the input type.
@ MAX_INT_BITS
Maximum number of bits that can be specified.
APInt getMask() const
For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc.
static FixedVectorType * getTruncatedElementVectorType(FixedVectorType *VTy)
FunctionType & operator=(const FunctionType &)=delete
PointerType & operator=(const PointerType &)=delete
unsigned getNumElements() const
bool isOpaqueOrPointeeTypeMatches(Type *Ty)
Return true if either this is an opaque pointer type or if this pointee type matches Ty.
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
static ElementCount get(ScalarTy MinVal, bool Scalable)
uint64_t getNumElements() const
static ScalableVectorType * getDoubleElementsVectorType(ScalableVectorType *VTy)
static ScalableVectorType * getTruncatedElementVectorType(ScalableVectorType *VTy)
FixedVectorType(Type *ElTy, unsigned NumElts)
(vector float) vec_cmpeq(*A, *B) C
param_iterator param_end() const
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
isSized - Return true if this is a sized type.
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type,...
StringRef getStructName() const
static FixedVectorType * get(Type *ElementType, const FixedVectorType *FVTy)
static bool isValidReturnType(Type *RetTy)
Return true if the specified type is valid as a return type.
@ MIN_INT_BITS
Minimum number of bits that can be specified.
IntegerType(LLVMContext &C, unsigned NumBits)
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
Class to represent integer types.
ArrayType & operator=(const ArrayType &)=delete
param_iterator param_begin() const
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
ArrayRef< Type * > params() const
FunctionType * getFunctionType()
std::enable_if_t< are_base_of< Type, Tys... >::value, void > setBody(Type *elt1, Tys *... elts)
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 ...
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
static ScalableVectorType * getHalfElementsVectorType(ScalableVectorType *VTy)
VectorType & operator=(const VectorType &)=delete
unsigned getIntegerBitWidth() const
unsigned getStructNumElements() const
Type * getExtendedType() const
Given scalar/vector integer type, returns a type with elements twice as wide as in the original type.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Base class of all SIMD vector types.
static ScalableVectorType * getExtendedElementVectorType(ScalableVectorType *VTy)
static FixedVectorType * getExtendedElementVectorType(FixedVectorType *VTy)
Type::subtype_iterator param_iterator
static bool classof(const Type *T)
Implement support type inquiry through isa, cast, and dyn_cast.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Type * getWithNewBitWidth(unsigned NewBitWidth) const
Given an integer or vector type, change the lane bitwidth to NewBitwidth, whilst keeping the old numb...
static VectorType * get(Type *ElementType, unsigned NumElements, bool Scalable)
bool isOpaque() const
Return true if this is a type with an identity that has no body specified yet.
This is an important class for using LLVM in a threaded context.
Type * getParamType(unsigned i) const
Parameter type accessors.
static bool isValidArgumentType(Type *ArgTy)
Return true if the specified type is valid as an argument type.
Class to represent pointers.
static ScalableVectorType * getSubdividedVectorType(ScalableVectorType *VTy, int NumSubdivs)
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
static bool classof(const Type *T)
uint64_t getArrayNumElements() const
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
Class for arbitrary precision integers.
static FixedVectorType * getInteger(FixedVectorType *VTy)
void setSubclassData(unsigned val)
Type(LLVMContext &C, TypeID tid)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
static bool classof(const Type *T)
Class to represent struct types.
StringRef - Represent a constant reference to a string, i.e.
static FixedVectorType * getSubdividedVectorType(FixedVectorType *VTy, int NumSubdivs)
Type * getStructElementType(unsigned N) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
element_iterator element_begin() const
bool indexValid(const Value *V) const
FunctionCallee(std::nullptr_t)
VectorType(Type *ElType, unsigned EQ, Type::TypeID TID)
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
static VectorType * getHalfElementsVectorType(VectorType *VTy)
This static method returns a VectorType with half as many elements as the input type and the same ele...
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
unsigned getNumElements() const
Random access to the elements.
@ IntegerTyID
Arbitrary bit width integers.
amdgpu Simplify well known AMD library false FunctionCallee Callee
static VectorType * getExtendedElementVectorType(VectorType *VTy)
This static method is like getInteger except that the element types are twice as wide as the elements...
Symbol info for RuntimeDyld.
bool hasName() const
Return true if this is a named struct that has a non-empty name.
unsigned NumContainedTys
Keeps track of how many Type*'s there are in the ContainedTys list.
StructType & operator=(const StructType &)=delete
uint64_t getMinNumElements() const
Get the minimum number of elements in this vector.
bool hasSameElementTypeAs(PointerType *Other)
Return true if both pointer types have the same element type.
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
static Type * getHalfTy(LLVMContext &C)
ArrayRef< Type * > elements() const
@ FixedVectorTyID
Fixed width SIMD vector type.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
static ScalableVectorType * get(Type *ElementType, const ScalableVectorType *SVTy)
element_iterator element_end() const
Type *const * ContainedTys
A pointer to the array of Types contained by this Type.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
static std::enable_if_t< are_base_of< Type, Tys... >::value, StructType * > create(StringRef Name, Type *elt1, Tys *... elts)
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
static bool isLoadableOrStorableType(Type *ElemTy)
Return true if we can load or store from a pointer to this type.
bool containsScalableVectorType() const
Returns true if this struct contains a scalable vector.
static PointerType * getWithSamePointeeType(PointerType *PT, unsigned AddressSpace)
This constructs a pointer type with the same pointee type as input PointerType (or opaque pointer if ...
static VectorType * get(Type *ElementType, const VectorType *Other)
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Type * getElementType(unsigned N) const
@ ScalableVectorTyID
Scalable SIMD vector type.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
static ScalableVectorType * get(Type *ElementType, unsigned MinNumElts)
TypeID
Definitions of all of the base types for the Type system.
static FixedVectorType * getHalfElementsVectorType(FixedVectorType *VTy)
Type * getFunctionParamType(unsigned i) const
bool isLiteral() const
Return true if this type is uniqued by structural equivalence, false if it is a struct definition.
bool isLayoutIdentical(StructType *Other) const
Return true if this is layout identical to the specified struct.
Type * getReturnType() const
LLVM Value Representation.
Type * getTypeAtIndex(unsigned N) const
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
static FixedVectorType * getDoubleElementsVectorType(FixedVectorType *VTy)
static Type * getFloatTy(LLVMContext &C)
Type * getElementType() const
Optional< std::vector< StOtherPiece > > Other
Class to represent function types.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.