Go to the documentation of this file.
58 return isIntegerTy() && cast<IntegerType>(
this)->getBitWidth() == Bitwidth;
62 if (
auto *PTy = dyn_cast<PointerType>(
this))
63 return PTy->isOpaque();
116 if (isa<VectorType>(
this) && isa<VectorType>(Ty))
120 if (((isa<FixedVectorType>(
this)) && Ty->
isX86_MMXTy()) &&
128 if (((isa<FixedVectorType>(
this)) && Ty->
isX86_AMXTy()) &&
139 if (
auto *PTy = dyn_cast<PointerType>(
this)) {
140 if (
auto *OtherPTy = dyn_cast<PointerType>(Ty))
141 return PTy->getAddressSpace() == OtherPTy->getAddressSpace();
148 if (
auto *ATy = dyn_cast<ArrayType>(
this)) {
149 unsigned NumElements = ATy->getNumElements();
150 return NumElements == 0 || ATy->getElementType()->isEmptyTy();
153 if (
auto *STy = dyn_cast<StructType>(
this)) {
154 unsigned NumElements = STy->getNumElements();
155 for (
unsigned i = 0;
i < NumElements; ++
i)
156 if (!STy->getElementType(
i)->isEmptyTy())
179 const VectorType *VTy = cast<VectorType>(
this);
182 assert(!ETS.
isScalable() &&
"Vector type should have fixed-width elements");
183 return {ETS.
getFixedSize() * EC.getKnownMinValue(), EC.isScalable()};
195 if (
auto *VTy = dyn_cast<VectorType>(
this))
196 return VTy->getElementType()->getFPMantissaWidth();
209 if (
auto *ATy = dyn_cast<ArrayType>(
this))
210 return ATy->getElementType()->isSized(Visited);
212 if (
auto *VTy = dyn_cast<VectorType>(
this))
213 return VTy->getElementType()->isSized(Visited);
215 return cast<StructType>(
this)->isSized(Visited);
343 :
Type(Result->getContext(), FunctionTyID) {
344 Type **SubTys =
reinterpret_cast<Type**
>(
this+1);
345 assert(isValidReturnType(Result) &&
"invalid return type for function");
350 for (
unsigned i = 0,
e = Params.
size();
i !=
e; ++
i) {
351 assert(isValidArgumentType(Params[
i]) &&
352 "Not a valid type for function argument!");
353 SubTys[
i+1] = Params[
i];
372 if (Insertion.second) {
379 *Insertion.first = FT;
382 FT = *Insertion.first;
418 if (Insertion.second) {
422 ST->setSubclassData(SCDB_IsLiteral);
424 *Insertion.first =
ST;
427 ST = *Insertion.first;
435 if (isa<ScalableVectorType>(Ty))
437 if (
auto *STy = dyn_cast<StructType>(Ty))
438 if (STy->containsScalableVectorType())
454 if (Elements.
empty()) {
489 if (!IterBool.second) {
491 TempStr.push_back(
'.');
500 std::make_pair(TmpStream.
str(),
this));
501 }
while (!IterBool.second);
542 "This method may not be invoked with an empty list");
548 "This method may not be invoked with an empty list");
567 if (isa<ScalableVectorType>(Ty))
569 if (!Ty->isSized(Visited))
595 if (
this ==
Other)
return true;
604 unsigned Idx = (unsigned)cast<Constant>(V)->getUniqueInteger().getZExtValue();
614 if (isa<ScalableVectorType>(V->
getType()))
616 const Constant *
C = dyn_cast<Constant>(V);
618 C =
C->getSplatValue();
624 return C.pImpl->NamedStructTypes.lookup(
Name);
632 :
Type(ElType->getContext(), ArrayTyID), ContainedType(ElType),
643 pImpl->
ArrayTypes[std::make_pair(ElementType, NumElements)];
654 !isa<ScalableVectorType>(ElemTy);
662 :
Type(ElType->getContext(), TID), ContainedType(ElType),
663 ElementQuantity(
EQ) {
685 assert(NumElts > 0 &&
"#Elements of a VectorType must be greater than 0");
687 "be an integer, floating point, or "
698 return cast<FixedVectorType>(Entry);
706 unsigned MinNumElts) {
707 assert(MinNumElts > 0 &&
"#Elements of a VectorType must be greater than 0");
709 "be an integer, floating point, or "
720 return cast<ScalableVectorType>(Entry);
728 assert(EltTy &&
"Can't get a pointer to <null> type!");
749 "Can only create opaque pointers in opaque pointer mode");
762 PointerType::PointerType(
Type *
E,
unsigned AddrSpace)
763 :
Type(
E->getContext(), PointerTyID), PointeeTy(
E) {
769 PointerType::PointerType(
LLVMContext &
C,
unsigned AddrSpace)
770 :
Type(
C, PointerTyID), PointeeTy(nullptr) {
LLVMContextImpl *const pImpl
@ FloatTyID
32-bit floating point type
Class to represent scalable SIMD vectors.
@ 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.
static PointerType * getInt16PtrTy(LLVMContext &C, unsigned AS=0)
static IntegerType * getInt1Ty(LLVMContext &C)
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
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.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
bool isX86_MMXTy() const
Return true if this is X86 MMX.
static Type * getFP128Ty(LLVMContext &C)
bool isPointerTy() const
True if this is an instance of PointerType.
static const fltSemantics & IEEEsingle() LLVM_READNONE
ScalarTy getFixedSize() const
@ VoidTyID
type with no size
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
void setBody(ArrayRef< Type * > Elements, bool isPacked=false)
Specify a body for an opaque identified type.
DenseMap< std::pair< Type *, uint64_t >, ArrayType * > ArrayTypes
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
const fltSemantics & getFltSemantics() const
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
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.
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
The instances of the Type class are immutable: once they are created, they are never changed.
static const fltSemantics & BFloat() LLVM_READNONE
static StructType * getTypeByName(LLVMContext &C, StringRef Name)
Return the type with the specified name, or null if there is none by that name.
static Type * getTokenTy(LLVMContext &C)
static Type * getPrimitiveType(LLVMContext &C, TypeID IDNumber)
Return a type based on an identifier.
Type * getElementType() const
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
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.
Class to represent fixed width SIMD vectors.
static PointerType * getInt32PtrTy(LLVMContext &C, unsigned AS=0)
bool isMetadataTy() const
Return true if this is 'metadata'.
static IntegerType * getInt8Ty(LLVMContext &C)
StructTypeSet AnonStructTypes
bool isScalable() const
Returns whether the size is scaled by a runtime quantity (vscale).
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...
static IntegerType * getInt32Ty(LLVMContext &C)
bool empty() const
empty - Check if the array is empty.
@ MAX_INT_BITS
Maximum number of bits that can be specified.
static PointerType * getBFloatPtrTy(LLVMContext &C, unsigned AS=0)
static const fltSemantics & IEEEquad() LLVM_READNONE
APInt getMask() const
For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc.
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
This is the shared class of boolean and integer constants.
static Type * getMetadataTy(LLVMContext &C)
static PointerType * getFP128PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getX86_AMXTy(LLVMContext &C)
static Type * getPPC_FP128Ty(LLVMContext &C)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static const fltSemantics & IEEEhalf() LLVM_READNONE
FixedVectorType(Type *ElTy, unsigned NumElts)
static Type * getDoubleTy(LLVMContext &C)
(vector float) vec_cmpeq(*A, *B) C
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
isSized - Return true if this is a sized type.
static PointerType * getPPC_FP128PtrTy(LLVMContext &C, unsigned AS=0)
DenseMap< Type *, PointerType * > PointerTypes
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
static bool isValidReturnType(Type *RetTy)
Return true if the specified type is valid as a return type.
bool isVectorTy() const
True if this is an instance of VectorType.
@ 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...
static TypeSize Fixed(ScalarTy MinVal)
DenseMap< std::pair< Type *, ElementCount >, VectorType * > VectorTypes
Class to represent integer types.
bool isTokenTy() const
Return true if this is 'token'.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
static PointerType * getInt1PtrTy(LLVMContext &C, unsigned AS=0)
bool isFunctionTy() const
True if this is an instance of FunctionType.
@ BFloatTyID
16-bit floating point type (7-bit significand)
static ElementCount getFixed(ScalarTy MinVal)
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
bool isIntegerTy() const
True if this is an instance of IntegerType.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
static PointerType * getIntNPtrTy(LLVMContext &C, unsigned N, unsigned AS=0)
Base class of all SIMD vector types.
int getFPMantissaWidth() const
Return the width of the mantissa of this type.
This is an important base class in LLVM.
std::pair< iterator, bool > insert_as(const ValueT &V, const LookupKeyT &LookupKey)
Alternative version of insert that uses a different (and possibly less expensive) key type.
@ X86_MMXTyID
MMX vectors (64 bits, X86 specific)
static PointerType * getHalfPtrTy(LLVMContext &C, unsigned AS=0)
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.
unsigned NamedStructTypesUniqueID
static PointerType * getInt64PtrTy(LLVMContext &C, unsigned AS=0)
static bool isValidArgumentType(Type *ArgTy)
Return true if the specified type is valid as an argument type.
Class to represent pointers.
static PointerType * getX86_MMXPtrTy(LLVMContext &C, unsigned AS=0)
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isVoidTy() const
Return true if this is 'void'.
AllocatorTy & getAllocator()
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
static Type * getX86_FP80Ty(LLVMContext &C)
static PointerType * getDoublePtrTy(LLVMContext &C, unsigned AS=0)
Class for arbitrary precision integers.
@ FP128TyID
128-bit floating point type (112-bit significand)
void setSubclassData(unsigned val)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Class to represent struct types.
static const fltSemantics & IEEEdouble() LLVM_READNONE
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
StringRef - Represent a constant reference to a string, i.e.
StringRef str() const
Return a StringRef for the vector contents.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getType() const
All values are typed, get the type of this value.
bool indexValid(const Value *V) const
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
bool isLabelTy() const
Return true if this is 'label'.
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.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static IntegerType * getInt128Ty(LLVMContext &C)
static PointerType * getFloatPtrTy(LLVMContext &C, unsigned AS=0)
unsigned getNumElements() const
Random access to the elements.
@ IntegerTyID
Arbitrary bit width integers.
Symbol info for RuntimeDyld.
unsigned NumContainedTys
Keeps track of how many Type*'s there are in the ContainedTys list.
static IntegerType * getInt64Ty(LLVMContext &C)
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
static Type * getHalfTy(LLVMContext &C)
ArrayRef< Type * > elements() const
@ FixedVectorTyID
Fixed width SIMD vector type.
bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
bool isIEEE() const
Return whether the type is IEEE compatible, as defined by the eponymous method in APFloat.
static ElementCount getScalable(ScalarTy MinVal)
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
DenseMap< std::pair< Type *, unsigned >, PointerType * > ASPointerTypes
static Type * getBFloatTy(LLVMContext &C)
Type *const * ContainedTys
A pointer to the array of Types contained by this Type.
static PointerType * getX86_FP80PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getVoidTy(LLVMContext &C)
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
bool isOpaquePointerTy() const
True if this is an instance of an opaque PointerType.
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.
size_t size() const
size - Get the array size.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
A raw_ostream that writes to an SmallVector or SmallString.
Type * getElementType(unsigned N) const
static IntegerType * getInt16Ty(LLVMContext &C)
@ 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)
static Type * getLabelTy(LLVMContext &C)
TypeID
Definitions of all of the base types for the Type system.
static Type * getX86_MMXTy(LLVMContext &C)
bool isLiteral() const
Return true if this type is uniqued by structural equivalence, false if it is a struct definition.
bool canLosslesslyBitCastTo(Type *Ty) const
Return true if this type could be converted with a lossless BitCast to type 'Ty'.
StringMap< StructType * > NamedStructTypes
bool isLayoutIdentical(StructType *Other) const
Return true if this is layout identical to the specified struct.
LLVM Value Representation.
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
static PointerType * getX86_AMXPtrTy(LLVMContext &C, unsigned AS=0)
@ HalfTyID
16-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
static Type * getFloatTy(LLVMContext &C)
static Type * getFloatingPointTy(LLVMContext &C, const fltSemantics &S)
bool isX86_AMXTy() const
Return true if this is X86 AMX.
FunctionTypeSet FunctionTypes
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
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.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
MutableArrayRef< T > copy(Allocator &A)