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();
807 return cast<TargetExtType>(
this)->getName();
812 #endif // LLVM_IR_DERIVEDTYPES_H
bool isFunctionVarArg() const
static TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types=std::nullopt, ArrayRef< unsigned > Ints=std::nullopt)
Return a target extension type having the specified name and optional type and integer parameters.
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.
@ MAX_INT_BITS
Maximum number of bits that can be specified.
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
unsigned getNumIntParameters() const
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
StringRef getTargetExtName() const
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.
Type::subtype_iterator type_param_iterator
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.
@ CanBeGlobal
This type may be used as the value type of a global variable.
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.
bool hasProperty(Property Prop) const
Returns true if the target extension type contains the given property.
Type *const * subtype_iterator
Class to represent array types.
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
ScalableVectorType(Type *ElTy, unsigned MinNumElts)
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
Type * getTypeParameter(unsigned i) const
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.
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)
uint64_t getNumElements() const
static ScalableVectorType * getDoubleElementsVectorType(ScalableVectorType *VTy)
static ScalableVectorType * getTruncatedElementVectorType(ScalableVectorType *VTy)
FixedVectorType(Type *ElTy, unsigned NumElts)
Type * getLayoutType() const
Returns an underlying layout type for the target extension type.
(vector float) vec_cmpeq(*A, *B) C
type_param_iterator type_param_begin() const
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
StringRef getName() const
Return the name for this target extension type.
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.
IntegerType(LLVMContext &C, unsigned NumBits)
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...
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()
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
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.
type_param_iterator type_param_end() const
This is an important class for using LLVM in a threaded context.
@ MIN_INT_BITS
Minimum number of bits that can be specified.
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.
ArrayRef< Type * > type_params() const
Return the type parameters for this particular target extension type.
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.
TargetExtType & operator=(const TargetExtType &)=delete
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
unsigned getNumContainedTypes() const
Return the number of types in the derived type.
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 getNumTypeParameters() const
Class to represent target extensions types, which are generally unintrospectable from target-independ...
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.
unsigned getIntParameter(unsigned i) const
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.
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.
std::optional< std::vector< StOtherPiece > > Other
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...
@ HasZeroInit
zeroinitializer is valid for this target extension type.
Type * getElementType(unsigned N) const
@ ScalableVectorTyID
Scalable SIMD vector type.
ArrayRef(const T &OneElt) -> ArrayRef< T >
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.
@ TargetExtTyID
Target extension type.
bool isLayoutIdentical(StructType *Other) const
Return true if this is layout identical to the specified struct.
Type * getReturnType() const
Type * getContainedType(unsigned i) const
This method is used to implement the type iterator (defined at the end of the file).
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
Class to represent function types.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
ArrayRef< unsigned > int_params() const
Return the integer parameters for this particular target extension type.