17 #ifndef LLVM_IR_DERIVEDTYPES_H 18 #define LLVM_IR_DERIVEDTYPES_H 123 static bool isValidReturnType(
Type *RetTy);
126 static bool isValidArgumentType(
Type *ArgTy);
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)>
176 : FnTy(Fn ? Fn->getFunctionType() : nullptr),
Callee(Fn) {}
179 : FnTy(FnTy), Callee(Callee) {
180 assert((FnTy ==
nullptr) == (Callee ==
nullptr));
205 Type *getTypeAtIndex(
const Value *V)
const;
206 Type *getTypeAtIndex(
unsigned Idx)
const;
207 bool indexValid(
const Value *V)
const;
208 bool indexValid(
unsigned Idx)
const;
264 bool isPacked =
false);
269 template <
class... Tys>
273 assert(elt1 &&
"Cannot create a struct type with no elements with this");
275 return create(StructFields, Name);
280 bool isPacked =
false);
288 template <
class... Tys>
291 get(Type *elt1, Tys *... elts) {
292 assert(elt1 &&
"Cannot create a struct type with no elements with this");
312 bool hasName()
const {
return SymbolTableEntry !=
nullptr; }
326 template <
typename... Tys>
329 assert(elt1 &&
"Cannot create a struct type with no elements with this");
331 setBody(StructFields);
363 return cast<StructType>(
this)->
getName();
367 return cast<StructType>(
this)->getNumElements();
371 return cast<StructType>(
this)->getElementType(N);
382 uint64_t NumElements;
387 NumElements(NumElements) {
416 static ArrayType *
get(
Type *ElementType, uint64_t NumElements);
428 return cast<ArrayType>(
this)->getNumElements();
461 bool Scalable =
false) {
470 assert(EltBits &&
"Element size must be of a non-zero size");
501 assert((EltBits & 1) == 0 &&
502 "Cannot truncate vector element with odd bit-width");
512 for (
int i = 0; i < NumSubdivs; ++i) {
523 assert ((EltCnt.Min & 1) == 0 &&
524 "Cannot halve vector with odd number of elements.");
533 "Too many elements in vector");
543 uint64_t MinimumEltCnt = getNumElements();
544 assert(MinimumEltCnt <= UINT_MAX &&
"Too many elements in vector");
545 return { (
unsigned)MinimumEltCnt, Scalable };
557 return getNumElements() * getElementType()->getPrimitiveSizeInBits();
567 return cast<VectorType>(
this)->getNumElements();
571 return cast<VectorType>(
this)->isScalable();
575 return cast<VectorType>(
this)->getElementCount();
604 static bool isLoadableOrStorableType(
Type *ElemTy);
618 "Original type expected to be a vector of integers or a scalar integer.");
619 if (
auto *VTy = dyn_cast<VectorType>(
this))
621 const_cast<VectorType *>(VTy));
628 "Original type expected to be a vector of integers or a scalar integer.");
636 return cast<PointerType>(
getScalarType())->getAddressSpace();
641 #endif // LLVM_IR_DERIVEDTYPES_H
FunctionCallee(std::nullptr_t)
CompositeType(LLVMContext &C, TypeID tid)
This class represents lattice values for constants.
Type * getParamType(unsigned i) const
Parameter type accessors.
Type * getElementType(unsigned N) const
unsigned getFunctionNumParams() const
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
2: 32-bit floating point type
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
ArrayRef< Type * > const elements() const
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
unsigned getNumElements() const
Random access to the elements.
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
Optional< std::vector< StOtherPiece > > Other
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
Minimum number of bits that can be specified.
Type * getStructElementType(unsigned N) const
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
param_iterator param_end() const
bool isOpaque() const
Return true if this is a type with an identity that has no body specified yet.
SequentialType(TypeID TID, Type *ElType, uint64_t NumElements)
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
bool isVectorTy() const
True if this is an instance of VectorType.
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
Type *const * ContainedTys
A pointer to the array of Types contained by this Type.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
unsigned getBitWidth() const
Return the minimum number of bits in the Vector type.
APInt getMask() const
For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc.
static Type * getFloatTy(LLVMContext &C)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
TypeID getTypeID() const
Return the type id for the type.
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
uint64_t getArrayNumElements() const
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
Class to represent struct types.
static StringRef getName(Value *V)
TypeID
Definitions of all of the base types for the Type system.
Type * getFunctionParamType(unsigned i) const
uint64_t getNumElements() const
For scalable vectors, this will return the minimum number of elements in the vector.
static StructType * get(LLVMContext &Context, ArrayRef< Type *> Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Maximum number of bits that can be specified.
Class to represent function types.
Class to represent array types.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
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...
Type(LLVMContext &C, TypeID tid)
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Type * getExtendedType() const
Given scalar/vector integer type, returns a type with elements twice as wide as in the original type...
Type *const * subtype_iterator
Type::subtype_iterator element_iterator
IntegerType * getExtendedType() const
Returns type twice as wide the input type.
Class to represent pointers.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
11: Arbitrary bit width integers
ElementCount getVectorElementCount() const
static VectorType * getHalfElementsVectorType(VectorType *VTy)
This static method returns a VectorType with half as many elements as the input type and the same ele...
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
static std::enable_if< are_base_of< Type, Tys... >::value, StructType * >::type create(StringRef Name, Type *elt1, Tys *... elts)
FunctionCallee(FunctionType *FnTy, Value *Callee)
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
element_iterator element_end() const
ArrayRef< Type * > params() const
param_iterator param_begin() const
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type...
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
unsigned getStructNumElements() const
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Class to represent integer types.
static VectorType * getDoubleElementsVectorType(VectorType *VTy)
This static method returns a VectorType with twice as many elements as the input type and the same el...
bool isFunctionVarArg() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getWithNewBitWidth(unsigned NewBitWidth) const
Given an integer or vector type, change the lane bitwidth to NewBitwidth, whilst keeping the old numb...
This is the superclass of the array and vector type classes.
static Type * getHalfTy(LLVMContext &C)
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
bool isScalable() const
Returns whether or not this is a scalable vector (meaning the total element count is a multiple of th...
16: SIMD 'packed' format, or other vector type
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
Type::subtype_iterator param_iterator
Type * getReturnType() const
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
static VectorType * getExtendedElementVectorType(VectorType *VTy)
This static method is like getInteger except that the element types are twice as wide as the elements...
unsigned getVectorNumElements() const
Symbol info for RuntimeDyld.
bool isLiteral() const
Return true if this type is uniqued by structural equivalence, false if it is a struct definition...
Class to represent vector types.
Class for arbitrary precision integers.
amdgpu Simplify well known AMD library false FunctionCallee Callee
element_iterator element_begin() const
Common super class of ArrayType, StructType and VectorType.
static bool classof(const Type *T)
Methods for support type inquiry through isa, cast, and dyn_cast.
std::enable_if< are_base_of< Type, Tys... >::value, void >::type setBody(Type *elt1, Tys *... elts)
unsigned getSubclassData() const
bool isPowerOf2ByteWidth() const
This method determines if the width of this IntegerType is a power-of-2 in terms of 8 bit bytes...
unsigned getIntegerBitWidth() const
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
static bool isValidElementType(Type *Ty)
Predicate for the element types that the SLP vectorizer supports.
static VectorType * getSubdividedVectorType(VectorType *VTy, int NumSubdivs)
FunctionType * getFunctionType()
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 ...
bool getVectorIsScalable() const
static bool classof(const Type *T)
Implement support type inquiry through isa, cast, and dyn_cast.
IntegerType(LLVMContext &C, unsigned NumBits)
3: 64-bit floating point type
void setSubclassData(unsigned val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
traits class for checking whether type T is a base class for all the given types in the variadic list...
LLVM Value Representation.
Type * getElementType() const
StringRef - Represent a constant reference to a string, i.e.
bool hasName() const
Return true if this is a named struct that has a non-empty name.
Type * getElementType() const
unsigned NumContainedTys
Keeps track of how many Type*'s there are in the ContainedTys list.
StringRef getStructName() const