17#ifndef LLVM_IR_DERIVEDTYPES_H
18#define LLVM_IR_DERIVEDTYPES_H
35template <
typename T>
class Expected;
100 return cast<IntegerType>(
this)->getBitWidth();
152 "Alignment sufficient for objects appended to FunctionType");
155 return cast<FunctionType>(
this)->isVarArg();
159 return cast<FunctionType>(
this)->getParamType(i);
163 return cast<FunctionType>(
this)->getNumParams();
174 template <
typename T,
typename U = decltype(&T::getFunctionType)>
179 : FnTy(FnTy), Callee(Callee) {
180 assert((FnTy ==
nullptr) == (Callee ==
nullptr));
191 explicit operator bool() {
return Callee; }
195 Value *Callee =
nullptr;
227 SCDB_ContainsScalableVector = 16,
228 SCDB_NotContainsScalableVector = 32,
229 SCDB_ContainsNonGlobalTargetExtType = 64,
230 SCDB_NotContainsNonGlobalTargetExtType = 128,
231 SCDB_ContainsNonLocalTargetExtType = 64,
232 SCDB_NotContainsNonLocalTargetExtType = 128,
257 template <
class... Tys>
260 assert(elt1 &&
"Cannot create a struct type with no elements with this");
274 template <
class... Tys>
277 assert(elt1 &&
"Cannot create a struct type with no elements with this");
386 return cast<StructType>(
this)->getName();
390 return cast<StructType>(
this)->getNumElements();
394 return cast<StructType>(
this)->getElementType(
N);
426 return cast<ArrayType>(
this)->getNumElements();
483 assert(EltBits &&
"Element size must be of a non-zero size");
514 assert((EltBits & 1) == 0 &&
515 "Cannot truncate vector element with odd bit-width");
525 for (
int i = 0; i < NumSubdivs; ++i) {
536 assert(EltCnt.isKnownEven() &&
537 "Cannot halve vector with odd number of elements.");
539 EltCnt.divideCoefficientBy(2));
543 unsigned Denominator) {
545 assert(EltCnt.isKnownMultipleOf(Denominator) &&
546 "Cannot take one-nth of a vector");
548 EltCnt.divideCoefficientBy(Denominator));
555 assert((EltCnt.getKnownMinValue() * 2ull) <= UINT_MAX &&
556 "Too many elements in vector");
613 return cast<FixedVectorType>(
619 return cast<FixedVectorType>(
646 unsigned MinNumElts);
659 return cast<ScalableVectorType>(
665 return cast<ScalableVectorType>(
671 return cast<ScalableVectorType>(
682 return cast<ScalableVectorType>(
709 [[deprecated(
"PointerType::get with pointee type is pending removal. Use "
710 "Context overload.")]]
718 [[deprecated(
"PointerType::getUnqual with pointee type is pending removal. "
719 "Use Context overload.")]]
721 assert(ElementType &&
"Can't get a pointer to <null> type!");
723 "Invalid type for pointer element!");
751 "Original type expected to be a vector of integers or a scalar integer.");
752 if (
auto *VTy = dyn_cast<VectorType>(
this))
755 return cast<IntegerType>(
this)->getExtendedType();
759 if (
auto *VTy = dyn_cast<VectorType>(
this))
767 "Original type expected to be a vector of integers or a scalar integer.");
772 return cast<PointerType>(
getScalarType())->getAddressSpace();
802 LLVM_ABI static Expected<TargetExtType *>
803 getOrError(LLVMContext &Context, StringRef Name, ArrayRef<Type *> Types = {},
804 ArrayRef<unsigned> Ints = {});
869 return cast<TargetExtType>(
this)->getName();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Given that RA is a live value
Class for arbitrary precision integers.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Class to represent array types.
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.
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
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
Lightweight error class with error context and mandatory checking.
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)
static FixedVectorType * getHalfElementsVectorType(FixedVectorType *VTy)
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
FunctionCallee(std::nullptr_t)
FunctionType * getFunctionType()
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.
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.
FunctionType(const FunctionType &)=delete
ArrayRef< Type * > params() const
FunctionType & operator=(const FunctionType &)=delete
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.
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.
IntegerType * getExtendedType() const
Returns type twice as wide the input type.
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...
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
IntegerType(LLVMContext &C, unsigned NumBits)
@ MIN_INT_BITS
Minimum number of bits that can be specified.
@ MAX_INT_BITS
Maximum number of bits that can be specified.
This is an important class for using LLVM in a threaded context.
Class to represent pointers.
static LLVM_ABI bool isLoadableOrStorableType(Type *ElemTy)
Return true if we can load or store from a pointer to this type.
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.
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)
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...
StringRef - Represent a constant reference to a string, i.e.
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
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.
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.
LLVM_ABI bool containsNonLocalTargetExtType() const
LLVM_ABI bool containsHomogeneousScalableVectorTypes() const
Returns true if this struct contains homogeneous scalable vector types.
LLVM_ABI Error checkBody(ArrayRef< Type * > Elements)
Return an error if the body for an opaque identified type would make it recursive.
LLVM_ABI bool containsHomogeneousTypes() const
Return true if this struct is non-empty and all element types are the same.
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.
static LLVM_ABI StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
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.
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...
LLVM_ABI bool isLayoutIdentical(StructType *Other) const
Return true if this is layout identical to the specified struct.
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.
LLVM_ABI Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
bool hasName() const
Return true if this is a named struct that has a non-empty name.
LLVM_ABI bool containsNonGlobalTargetExtType() const
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 isScalableTy() const
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.
Symbol info for RuntimeDyld.
Class to represent target extensions types, which are generally unintrospectable from target-independ...
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.
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...
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.
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,...
LLVM_ABI Type * getLayoutType() const
Returns an underlying layout type for the target extension type.
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.
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
LLVM_ABI bool isFunctionVarArg() const
LLVM_ABI Type * getExtendedType() const
Given scalar/vector integer type, returns a type with elements twice as wide as in the original type.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
LLVM_ABI bool containsNonLocalTargetExtType() const
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
LLVM_ABI StringRef getTargetExtName() const
Type *const * subtype_iterator
TypeID
Definitions of all of the base types for the Type system.
@ TargetExtTyID
Target extension type.
@ ScalableVectorTyID
Scalable SIMD vector type.
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ FixedVectorTyID
Fixed width SIMD vector type.
@ DoubleTyID
64-bit floating point type
unsigned getNumContainedTypes() const
Return the number of types in the derived type.
unsigned NumContainedTys
Keeps track of how many Type*'s there are in the ContainedTys list.
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 StringRef getStructName() const
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Type *const * ContainedTys
A pointer to the array of Types contained by this Type.
unsigned getSubclassData() const
void setSubclassData(unsigned val)
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
LLVM_ABI Type * getFunctionParamType(unsigned i) const
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
LLVM_ABI bool containsNonGlobalTargetExtType() const
TypeID getTypeID() const
Return the type id for the type.
LLVM_ABI Type * getStructElementType(unsigned N) const
Type * getContainedType(unsigned i) const
This method is used to implement the type iterator (defined at the end of the file).
LLVM_ABI bool isScalableTy() const
LLVM_ABI unsigned getStructNumElements() const
LLVM_ABI unsigned getIntegerBitWidth() const
LLVM_ABI unsigned getFunctionNumParams() const
LLVM_ABI uint64_t getArrayNumElements() const
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVM_ABI Type * getWithNewType(Type *EltTy) const
Given vector type, change the element type, whilst keeping the old number of elements.
LLVM Value Representation.
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...
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...
constexpr LeafTy multiplyCoefficientBy(ScalarTy RHS) const
constexpr LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
This is an optimization pass for GlobalISel generic memory operations.
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...