57 return isIntegerTy() && cast<IntegerType>(
this)->getBitWidth() == Bitwidth;
61 if (
auto *PTy = dyn_cast<PointerType>(
this))
62 return PTy->isOpaque();
67 if (
const auto *STy = dyn_cast<StructType>(
this)) {
69 return STy->containsScalableVectorType(&Visited);
92 if (
auto *TT = dyn_cast<TargetExtType>(
this))
93 return isa<ScalableVectorType>(
TT->getLayoutType());
129 if (isa<VectorType>(
this) && isa<VectorType>(Ty))
133 if (((isa<FixedVectorType>(
this)) && Ty->
isX86_MMXTy()) &&
141 if (((isa<FixedVectorType>(
this)) && Ty->
isX86_AMXTy()) &&
152 if (
auto *PTy = dyn_cast<PointerType>(
this)) {
153 if (
auto *OtherPTy = dyn_cast<PointerType>(Ty))
154 return PTy->getAddressSpace() == OtherPTy->getAddressSpace();
161 if (
auto *ATy = dyn_cast<ArrayType>(
this)) {
162 unsigned NumElements = ATy->getNumElements();
163 return NumElements == 0 || ATy->getElementType()->isEmptyTy();
166 if (
auto *STy = dyn_cast<StructType>(
this)) {
167 unsigned NumElements = STy->getNumElements();
168 for (
unsigned i = 0; i < NumElements; ++i)
169 if (!STy->getElementType(i)->isEmptyTy())
192 const VectorType *VTy = cast<VectorType>(
this);
194 TypeSize ETS = VTy->getElementType()->getPrimitiveSizeInBits();
195 assert(!ETS.
isScalable() &&
"Vector type should have fixed-width elements");
208 if (
auto *VTy = dyn_cast<VectorType>(
this))
209 return VTy->getElementType()->getFPMantissaWidth();
222 if (
auto *ATy = dyn_cast<ArrayType>(
this))
223 return ATy->getElementType()->isSized(Visited);
225 if (
auto *VTy = dyn_cast<VectorType>(
this))
226 return VTy->getElementType()->isSized(Visited);
228 if (
auto *TTy = dyn_cast<TargetExtType>(
this))
229 return TTy->getLayoutType()->isSized(Visited);
231 return cast<StructType>(
this)->isSized(Visited);
371 :
Type(Result->getContext(), FunctionTyID) {
372 Type **SubTys =
reinterpret_cast<Type**
>(
this+1);
373 assert(isValidReturnType(Result) &&
"invalid return type for function");
378 for (
unsigned i = 0, e = Params.
size(); i != e; ++i) {
379 assert(isValidArgumentType(Params[i]) &&
380 "Not a valid type for function argument!");
381 SubTys[i+1] = Params[i];
400 if (Insertion.second) {
407 *Insertion.first = FT;
410 FT = *Insertion.first;
420 return !
RetTy->isFunctionTy() && !
RetTy->isLabelTy() &&
421 !
RetTy->isMetadataTy();
446 if (Insertion.second) {
450 ST->setSubclassData(SCDB_IsLiteral);
452 *Insertion.first = ST;
455 ST = *Insertion.first;
473 if (isa<ScalableVectorType>(Ty)) {
478 if (
auto *STy = dyn_cast<StructType>(Ty)) {
479 if (STy->containsScalableVectorType(Visited)) {
498 if (!FirstTy || !isa<ScalableVectorType>(FirstTy))
515 if (Elements.empty()) {
550 if (!IterBool.second) {
561 std::make_pair(TmpStream.
str(),
this));
562 }
while (!IterBool.second);
602 assert(!Elements.empty() &&
603 "This method may not be invoked with an empty list");
608 assert(!Elements.empty() &&
609 "This method may not be invoked with an empty list");
665 if (
this ==
Other)
return true;
674 unsigned Idx = (
unsigned)cast<Constant>(V)->getUniqueInteger().getZExtValue();
682 if (!V->getType()->isIntOrIntVectorTy(32))
684 if (isa<ScalableVectorType>(V->getType()))
686 const Constant *
C = dyn_cast<Constant>(V);
687 if (
C && V->getType()->isVectorTy())
688 C =
C->getSplatValue();
694 return C.pImpl->NamedStructTypes.lookup(
Name);
702 :
Type(ElType->getContext(), ArrayTyID), ContainedType(ElType),
713 pImpl->
ArrayTypes[std::make_pair(ElementType, NumElements)];
724 !isa<ScalableVectorType>(ElemTy);
732 :
Type(ElType->getContext(), TID), ContainedType(ElType),
733 ElementQuantity(
EQ) {
755 assert(NumElts > 0 &&
"#Elements of a VectorType must be greater than 0");
757 "be an integer, floating point, or "
768 return cast<FixedVectorType>(Entry);
776 unsigned MinNumElts) {
777 assert(MinNumElts > 0 &&
"#Elements of a VectorType must be greater than 0");
779 "be an integer, floating point, or "
790 return cast<ScalableVectorType>(Entry);
798 assert(EltTy &&
"Can't get a pointer to <null> type!");
818 "Can only create opaque pointers in opaque pointer mode");
829PointerType::PointerType(
Type *
E,
unsigned AddrSpace)
830 :
Type(
E->getContext(), PointerTyID), PointeeTy(
E) {
836PointerType::PointerType(
LLVMContext &
C,
unsigned AddrSpace)
837 :
Type(
C, PointerTyID), PointeeTy(nullptr) {
865 Type **Params =
reinterpret_cast<Type **
>(
this + 1);
867 for (
Type *
T : Types)
871 unsigned *IntParamSpace =
reinterpret_cast<unsigned *
>(Params);
872 IntParams = IntParamSpace;
873 for (
unsigned IntParam : Ints)
874 *IntParamSpace++ = IntParam;
887 auto Insertion =
C.pImpl->TargetExtTypes.insert_as(
nullptr, Key);
888 if (Insertion.second) {
896 *Insertion.first = TT;
899 TT = *Insertion.first;
905struct TargetTypeInfo {
909 template <
typename... ArgTys>
910 TargetTypeInfo(
Type *LayoutType, ArgTys... Properties)
911 : LayoutType(LayoutType), Properties((0 | ... | Properties)) {}
918 if (
Name.startswith(
"spirv."))
923 if (
Name ==
"aarch64.svcount")
935 return (Properties & Prop) == Prop;
This file defines the StringMap class.
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
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
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty)
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
Class to represent array types.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
This is the shared class of boolean and integer constants.
This is an important base class in LLVM.
static constexpr ElementCount getScalable(ScalarTy MinVal)
static constexpr ElementCount getFixed(ScalarTy MinVal)
Class to represent fixed width SIMD vectors.
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
Class to represent function types.
static bool isValidArgumentType(Type *ArgTy)
Return true if the specified type is valid as an argument type.
static bool isValidReturnType(Type *RetTy)
Return true if the specified type is valid as a return type.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Class to represent integer types.
@ MIN_INT_BITS
Minimum number of bits that can be specified.
@ MAX_INT_BITS
Maximum number of bits that can be specified.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
APInt getMask() const
For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
StructTypeSet AnonStructTypes
DenseMap< std::pair< Type *, uint64_t >, ArrayType * > ArrayTypes
DenseMap< std::pair< Type *, ElementCount >, VectorType * > VectorTypes
DenseMap< std::pair< Type *, unsigned >, PointerType * > LegacyPointerTypes
DenseMap< unsigned, PointerType * > PointerTypes
StringMap< StructType * > NamedStructTypes
PointerType * AS0PointerType
unsigned NamedStructTypesUniqueID
FunctionTypeSet FunctionTypes
This is an important class for using LLVM in a threaded context.
LLVMContextImpl *const pImpl
Class to represent pointers.
static bool isLoadableOrStorableType(Type *ElemTy)
Return true if we can load or store from a pointer to this type.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Class to represent scalable SIMD vectors.
static ScalableVectorType * get(Type *ElementType, unsigned MinNumElts)
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void push_back(const T &Elt)
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
StringRef - Represent a constant reference to a string, i.e.
Class to represent struct types.
bool indexValid(const Value *V) const
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
ArrayRef< Type * > elements() const
void setBody(ArrayRef< Type * > Elements, bool isPacked=false)
Specify a body for an opaque identified type.
bool containsHomogeneousScalableVectorTypes() const
Returns true if this struct contains homogeneous scalable vector types.
static StructType * getTypeByName(LLVMContext &C, StringRef Name)
Return the type with the specified name, or null if there is none by that name.
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
unsigned getNumElements() const
Random access to the elements.
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
isSized - Return true if this is a sized type.
bool containsScalableVectorType(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Returns true if this struct contains a scalable vector.
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...
bool isLayoutIdentical(StructType *Other) const
Return true if this is layout identical to the specified struct.
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
bool isLiteral() const
Return true if this type is uniqued by structural equivalence, false if it is a struct definition.
bool isOpaque() const
Return true if this is a type with an identity that has no body specified yet.
Type * getElementType(unsigned N) const
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...
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.
bool hasProperty(Property Prop) const
Returns true if the target extension type contains the given property.
@ HasZeroInit
zeroinitializer is valid for this target extension type.
@ CanBeGlobal
This type may be used as the value type of a global variable.
StringRef getName() const
Return the name for this target extension type.
Type * getLayoutType() const
Returns an underlying layout type for the target extension type.
static constexpr TypeSize Fixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
static PointerType * getInt32PtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * getFP128PtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * getPPC_FP128PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getHalfTy(LLVMContext &C)
static Type * getDoubleTy(LLVMContext &C)
const fltSemantics & getFltSemantics() const
static Type * getFloatingPointTy(LLVMContext &C, const fltSemantics &S)
static PointerType * getHalfPtrTy(LLVMContext &C, unsigned AS=0)
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
static PointerType * getInt1PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getX86_FP80Ty(LLVMContext &C)
static PointerType * getX86_FP80PtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * getX86_MMXPtrTy(LLVMContext &C, unsigned AS=0)
bool isLabelTy() const
Return true if this is 'label'.
static Type * getBFloatTy(LLVMContext &C)
bool isPointerTy() const
True if this is an instance of PointerType.
static PointerType * getBFloatPtrTy(LLVMContext &C, unsigned AS=0)
static IntegerType * getInt1Ty(LLVMContext &C)
bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty.
static Type * getX86_AMXTy(LLVMContext &C)
static Type * getMetadataTy(LLVMContext &C)
TypeID
Definitions of all of the base types for the Type system.
@ X86_MMXTyID
MMX vectors (64 bits, X86 specific)
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
@ TypedPointerTyID
Typed pointer used by some GPU targets.
@ HalfTyID
16-bit floating point type
@ VoidTyID
type with no size
@ ScalableVectorTyID
Scalable SIMD vector type.
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ FixedVectorTyID
Fixed width SIMD vector type.
@ BFloatTyID
16-bit floating point type (7-bit significand)
@ DoubleTyID
64-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ FP128TyID
128-bit floating point type (112-bit significand)
bool isX86_MMXTy() const
Return true if this is X86 MMX.
unsigned NumContainedTys
Keeps track of how many Type*'s there are in the ContainedTys list.
static Type * getX86_MMXTy(LLVMContext &C)
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
static Type * getVoidTy(LLVMContext &C)
static Type * getLabelTy(LLVMContext &C)
bool isScalableTargetExtTy() const
Return true if this is a target extension type with a scalable layout.
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
static Type * getFP128Ty(LLVMContext &C)
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
static IntegerType * getInt16Ty(LLVMContext &C)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static Type * getPrimitiveType(LLVMContext &C, TypeID IDNumber)
Return a type based on an identifier.
int getFPMantissaWidth() const
Return the width of the mantissa of this type.
Type *const * ContainedTys
A pointer to the array of Types contained by this Type.
unsigned getSubclassData() const
static IntegerType * getInt8Ty(LLVMContext &C)
bool isIEEE() const
Return whether the type is IEEE compatible, as defined by the eponymous method in APFloat.
static IntegerType * getInt128Ty(LLVMContext &C)
static PointerType * getIntNPtrTy(LLVMContext &C, unsigned N, unsigned AS=0)
static PointerType * getX86_AMXPtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * getDoublePtrTy(LLVMContext &C, unsigned AS=0)
void setSubclassData(unsigned val)
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getTokenTy(LLVMContext &C)
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
bool isX86_AMXTy() const
Return true if this is X86 AMX.
bool isFunctionTy() const
True if this is an instance of FunctionType.
bool isScalableTy() const
Return true if this is a scalable vector type or a target extension type with a scalable layout.
bool canLosslesslyBitCastTo(Type *Ty) const
Return true if this type could be converted with a lossless BitCast to type 'Ty'.
static IntegerType * getInt32Ty(LLVMContext &C)
static PointerType * getFloatPtrTy(LLVMContext &C, unsigned AS=0)
static IntegerType * getInt64Ty(LLVMContext &C)
static Type * getFloatTy(LLVMContext &C)
bool isIntegerTy() const
True if this is an instance of IntegerType.
TypeID getTypeID() const
Return the type id for the type.
static Type * getWasm_FuncrefTy(LLVMContext &C)
bool isTokenTy() const
Return true if this is 'token'.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
static PointerType * getInt16PtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * getInt64PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getPPC_FP128Ty(LLVMContext &C)
bool isOpaquePointerTy() const
True if this is an instance of an opaque PointerType.
static Type * getWasm_ExternrefTy(LLVMContext &C)
bool isVoidTy() const
Return true if this is 'void'.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isMetadataTy() const
Return true if this is 'metadata'.
LLVM Value Representation.
Base class of all SIMD vector types.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
VectorType(Type *ElType, unsigned EQ, Type::TypeID TID)
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
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.
constexpr ScalarTy getFixedValue() const
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
A raw_ostream that writes to an SmallVector or SmallString.
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.
@ C
The default llvm calling convention, compatible with C.
constexpr size_t NameSize
This is an optimization pass for GlobalISel generic memory operations.
static const fltSemantics & IEEEsingle() LLVM_READNONE
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
static const fltSemantics & IEEEquad() LLVM_READNONE
static const fltSemantics & IEEEdouble() LLVM_READNONE
static const fltSemantics & IEEEhalf() LLVM_READNONE
static const fltSemantics & BFloat() LLVM_READNONE