73 if (
auto *thisPTy = dyn_cast<VectorType>(
this)) {
74 if (
auto *thatPTy = dyn_cast<VectorType>(Ty))
75 return thisPTy->getBitWidth() == thatPTy->getBitWidth();
77 thisPTy->getBitWidth() == 64)
82 if (
auto *thatPTy = dyn_cast<VectorType>(Ty))
83 if (thatPTy->getBitWidth() == 64)
90 if (
auto *PTy = dyn_cast<PointerType>(
this)) {
91 if (
auto *OtherPTy = dyn_cast<PointerType>(Ty))
92 return PTy->getAddressSpace() == OtherPTy->getAddressSpace();
99 if (
auto *ATy = dyn_cast<ArrayType>(
this)) {
100 unsigned NumElements = ATy->getNumElements();
101 return NumElements == 0 || ATy->getElementType()->isEmptyTy();
104 if (
auto *STy = dyn_cast<StructType>(
this)) {
105 unsigned NumElements = STy->getNumElements();
106 for (
unsigned i = 0; i < NumElements; ++i)
107 if (!STy->getElementType(i)->isEmptyTy())
127 const VectorType *VTy = cast<VectorType>(
this);
139 if (
auto *VTy = dyn_cast<VectorType>(
this))
140 return VTy->getElementType()->getFPMantissaWidth();
152 if (
auto *ATy = dyn_cast<ArrayType>(
this))
153 return ATy->getElementType()->isSized(Visited);
155 if (
auto *VTy = dyn_cast<VectorType>(
this))
156 return VTy->getElementType()->isSized(Visited);
158 return cast<StructType>(
this)->
isSized(Visited);
245 assert(NumBits >= MIN_INT_BITS &&
"bitwidth too small");
246 assert(NumBits <= MAX_INT_BITS &&
"bitwidth too large");
284 Type **SubTys =
reinterpret_cast<Type**
>(
this+1);
285 assert(isValidReturnType(Result) &&
"invalid return type for function");
290 for (
unsigned i = 0,
e = Params.
size(); i !=
e; ++i) {
291 assert(isValidArgumentType(Params[i]) &&
292 "Not a valid type for function argument!");
293 SubTys[i+1] = Params[i];
312 if (Insertion.second) {
319 *Insertion.first = FT;
322 FT = *Insertion.first;
328 return get(Result,
None, isVarArg);
358 if (Insertion.second) {
364 *Insertion.first =
ST;
367 ST = *Insertion.first;
374 assert(isOpaque() &&
"Struct body already set!");
382 if (Elements.
empty()) {
404 if (SymbolTableEntry) {
406 ((EntryTy *)SymbolTableEntry)->Destroy(SymbolTable.
getAllocator());
407 SymbolTableEntry =
nullptr;
417 if (!IterBool.second) {
424 TempStr.
resize(NameSize + 1);
428 std::make_pair(TmpStream.
str(),
this));
429 }
while (!IterBool.second);
433 if (SymbolTableEntry)
434 ((EntryTy *)SymbolTableEntry)->Destroy(SymbolTable.
getAllocator());
435 SymbolTableEntry = &*IterBool.first;
449 return get(Context,
None, isPacked);
455 ST->
setBody(Elements, isPacked);
460 return create(Context, Elements,
StringRef());
470 "This method may not be invoked with an empty list");
471 return create(Elements[0]->
getContext(), Elements, Name, isPacked);
476 "This method may not be invoked with an empty list");
486 if (Visited && !Visited->
insert(const_cast<StructType*>(
this)).second)
493 if (!(*I)->isSized(Visited))
505 assert(!isLiteral() &&
"Literal structs never have names");
512 if (
auto *VTy = dyn_cast<VectorType>(ElemTy))
513 return !VTy->isScalable();
520 if (
this == Other)
return true;
522 if (isPacked() != Other->
isPacked())
525 return elements() == Other->
elements();
537 if (
auto *STy = dyn_cast<StructType>(
this)) {
539 (
unsigned)cast<Constant>(V)->getUniqueInteger().getZExtValue();
540 assert(indexValid(Idx) &&
"Invalid structure index!");
541 return STy->getElementType(Idx);
544 return cast<SequentialType>(
this)->getElementType();
548 if (
auto *STy = dyn_cast<StructType>(
this)) {
549 assert(indexValid(Idx) &&
"Invalid structure index!");
550 return STy->getElementType(Idx);
553 return cast<SequentialType>(
this)->getElementType();
557 if (
auto *STy = dyn_cast<StructType>(
this)) {
566 return CU && CU->
getZExtValue() < STy->getNumElements();
574 if (
auto *STy = dyn_cast<StructType>(
this))
575 return Idx < STy->getNumElements();
584 ArrayType::ArrayType(
Type *ElType, uint64_t NumEl)
592 pImpl->
ArrayTypes[std::make_pair(ElementType, NumElements)];
600 if (
auto *VTy = dyn_cast<VectorType>(ElemTy))
601 return !VTy->isScalable();
615 assert(EC.
Min > 0 &&
"#Elements of a VectorType must be greater than 0");
617 "be an integer, floating point, or " 638 assert(EltTy &&
"Can't get a pointer to <null> type!");
652 PointerType::PointerType(
Type *
E,
unsigned AddrSpace)
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
DenseMap< unsigned, IntegerType * > IntegerTypes
static Type * getDoubleTy(LLVMContext &C)
static IntegerType * getInt1Ty(LLVMContext &C)
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
bool isMetadataTy() const
Return true if this is 'metadata'.
This class represents lattice values for constants.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
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
void push_back(const T &Elt)
static PointerType * getInt32PtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
A raw_ostream that writes to an SmallVector or SmallString.
4: 80-bit floating point type (X87)
static bool isValidReturnType(Type *RetTy)
Return true if the specified type is valid as a return type.
static bool isLoadableOrStorableType(Type *ElemTy)
Return true if we can load or store from a pointer to this type.
1: 16-bit floating point type
static IntegerType * getInt64Ty(LLVMContext &C)
DenseMap< std::pair< Type *, unsigned >, PointerType * > ASPointerTypes
static Type * getMetadataTy(LLVMContext &C)
bool isVectorTy() const
True if this is an instance of VectorType.
static bool isValidArgumentType(Type *ArgTy)
Return true if the specified type is valid as an argument type.
static IntegerType * getInt16Ty(LLVMContext &C)
static Type * getX86_MMXTy(LLVMContext &C)
static PointerType * getX86_MMXPtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * getInt64PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getX86_FP80Ty(LLVMContext &C)
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...
bool indexValid(const Value *V) const
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 * getTokenTy(LLVMContext &C)
static Type * getFloatTy(LLVMContext &C)
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.
Class to represent struct types.
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
DenseMap< std::pair< Type *, uint64_t >, ArrayType * > ArrayTypes
static StringRef getName(Value *V)
TypeID
Definitions of all of the base types for the Type system.
static PointerType * getInt16PtrTy(LLVMContext &C, unsigned AS=0)
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
ArrayRef< T > copy(Allocator &A)
static Type * getPPC_FP128Ty(LLVMContext &C)
static StructType * get(LLVMContext &Context, ArrayRef< Type *> Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
This file implements a class to represent arbitrary precision integral constant values and operations...
Class to represent function types.
static Type * getLabelTy(LLVMContext &C)
unsigned NamedStructTypesUniqueID
Type * getType() const
All values are typed, get the type of this value.
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value. ...
Class to represent array types.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
static PointerType * getDoublePtrTy(LLVMContext &C, unsigned AS=0)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LLVM_NODISCARD size_t size() const
size - Get the string size.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
int getFPMantissaWidth() const
Return the width of the mantissa of this type.
Type(LLVMContext &C, TypeID tid)
void setBody(ArrayRef< Type *> Elements, bool isPacked=false)
Specify a body for an opaque identified type.
Type::subtype_iterator element_iterator
Class to represent pointers.
DenseMap< std::pair< Type *, ElementCount >, VectorType * > VectorTypes
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
11: Arbitrary bit width integers
Constant * getSplatValue(bool AllowUndefs=false) const
If all elements of the vector constant have the same value, return that value.
bool isVoidTy() const
Return true if this is 'void'.
static IntegerType * getInt128Ty(LLVMContext &C)
bool isLabelTy() const
Return true if this is 'label'.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
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 bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
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.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isPointerTy() const
True if this is an instance of PointerType.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
static Type * getVoidTy(LLVMContext &C)
StringRef getName() const
Return the name for this struct type if it has an identity.
6: 128-bit floating point type (two 64-bits, PowerPC)
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.
static PointerType * getPPC_FP128PtrTy(LLVMContext &C, unsigned AS=0)
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
static PointerType * getFloatPtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
LLVMContextImpl *const pImpl
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
isSized - Return true if this is a sized type.
static Type * getFP128Ty(LLVMContext &C)
static PointerType * getX86_FP80PtrTy(LLVMContext &C, unsigned AS=0)
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 * getInt1PtrTy(LLVMContext &C, unsigned AS=0)
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
This is the shared class of boolean and integer constants.
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...
Module.h This file contains the declarations for the Module class.
AllocatorTy & getAllocator()
FunctionTypeSet FunctionTypes
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
static PointerType * getHalfPtrTy(LLVMContext &C, unsigned AS=0)
StringRef str()
Return a StringRef for the vector contents.
static Type * getPrimitiveType(LLVMContext &C, TypeID IDNumber)
Return a type based on an identifier.
static PointerType * getFP128PtrTy(LLVMContext &C, unsigned AS=0)
Symbol info for RuntimeDyld.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Class to represent vector types.
Class for arbitrary precision integers.
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
StructTypeSet AnonStructTypes
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 constexpr TypeSize Fixed(uint64_t Size)
bool isLayoutIdentical(StructType *Other) const
Return true if this is layout identical to the specified struct.
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...
bool isFunctionTy() const
True if this is an instance of FunctionType.
static IntegerType * getInt32Ty(LLVMContext &C)
StringMap< StructType * > NamedStructTypes
bool isTokenTy() const
Return true if this is 'token'.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
bool canLosslesslyBitCastTo(Type *Ty) const
Return true if this type could be converted with a lossless BitCast to type 'Ty'. ...
static bool isValidElementType(Type *Ty)
Predicate for the element types that the SLP vectorizer supports.
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
StructType * getTypeByName(StringRef Name) const
Return the type with the specified name, or null if there is none by that name.
static PointerType * getIntNPtrTy(LLVMContext &C, unsigned N, unsigned AS=0)
3: 64-bit floating point type
void setSubclassData(unsigned val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
StringRef - Represent a constant reference to a string, i.e.
DenseMap< Type *, PointerType * > PointerTypes
bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty...
9: MMX vectors (64 bits, X86 specific)
static IntegerType * getInt8Ty(LLVMContext &C)
unsigned NumContainedTys
Keeps track of how many Type*'s there are in the ContainedTys list.
bool empty() const
empty - Check if the array is empty.
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
5: 128-bit floating point type (112-bit mantissa)