46 if (
VectorType *VTy = dyn_cast<VectorType>(
this))
47 return VTy->getElementType();
52 if (
const VectorType *VTy = dyn_cast<VectorType>(
this))
53 return VTy->getElementType();
77 if (
const VectorType *thisPTy = dyn_cast<VectorType>(
this)) {
78 if (
const VectorType *thatPTy = dyn_cast<VectorType>(Ty))
79 return thisPTy->getBitWidth() == thatPTy->getBitWidth();
81 thisPTy->getBitWidth() == 64)
86 if (
const VectorType *thatPTy = dyn_cast<VectorType>(Ty))
87 if (thatPTy->getBitWidth() == 64)
94 if (
const PointerType *PTy = dyn_cast<PointerType>(
this)) {
95 if (
const PointerType *OtherPTy = dyn_cast<PointerType>(Ty))
96 return PTy->getAddressSpace() == OtherPTy->getAddressSpace();
112 for (
unsigned i = 0; i < NumElements; ++i)
147 if (
const VectorType *VTy = dyn_cast<VectorType>(
this))
148 return VTy->getElementType()->getFPMantissaWidth();
163 if (
const ArrayType *ATy = dyn_cast<ArrayType>(
this))
164 return ATy->getElementType()->isSized(Visited);
166 if (
const VectorType *VTy = dyn_cast<VectorType>(
this))
167 return VTy->getElementType()->isSized(Visited);
169 return cast<StructType>(
this)->
isSized(Visited);
181 return cast<FunctionType>(
this)->isVarArg();
185 return cast<FunctionType>(
this)->getParamType(i);
189 return cast<FunctionType>(
this)->getNumParams();
193 return cast<StructType>(
this)->
getName();
197 return cast<StructType>(
this)->getNumElements();
201 return cast<StructType>(
this)->getElementType(N);
205 return cast<SequentialType>(
this)->getElementType();
209 return cast<ArrayType>(
this)->getNumElements();
213 return cast<VectorType>(
this)->getNumElements();
217 return cast<PointerType>(
getScalarType())->getAddressSpace();
305 assert(NumBits >=
MIN_INT_BITS &&
"bitwidth too small");
306 assert(NumBits <=
MAX_INT_BITS &&
"bitwidth too large");
343 :
Type(Result->getContext(), FunctionTyID) {
344 Type **SubTys =
reinterpret_cast<Type**
>(
this+1);
345 assert(isValidReturnType(Result) &&
"invalid return type for function");
348 SubTys[0] =
const_cast<Type*
>(Result);
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];
425 assert(
isOpaque() &&
"Struct body already set!");
431 unsigned NumElements = Elements.
size();
433 memcpy(Elts, Elements.
data(),
sizeof(Elements[0]) * NumElements);
455 SymbolTableEntry =
nullptr;
465 if (!IterBool.second) {
472 TempStr.
resize(NameSize + 1);
477 std::make_pair(TmpStream.
str(),
this));
478 }
while (!IterBool.second);
484 SymbolTableEntry = &*IterBool.first;
502 assert(type &&
"Cannot create a struct type with no elements with this");
519 ST->
setBody(Elements, isPacked);
533 assert(!Elements.
empty() &&
534 "This method may not be invoked with an empty list");
539 assert(!Elements.
empty() &&
540 "This method may not be invoked with an empty list");
545 assert(type &&
"Cannot create a struct type with no elements with this");
565 if (Visited && !Visited->
insert(
this).second)
572 if (!(*I)->isSized(Visited))
584 assert(!
isLiteral() &&
"Literal structs never have names");
591 assert(type &&
"Cannot create a struct type with no elements with this");
611 if (
this == Other)
return true;
635 if (
StructType *STy = dyn_cast<StructType>(
this)) {
637 (
unsigned)cast<Constant>(V)->getUniqueInteger().getZExtValue();
638 assert(
indexValid(Idx) &&
"Invalid structure index!");
639 return STy->getElementType(Idx);
642 return cast<SequentialType>(
this)->getElementType();
645 if (
StructType *STy = dyn_cast<StructType>(
this)) {
646 assert(
indexValid(Idx) &&
"Invalid structure index!");
647 return STy->getElementType(Idx);
650 return cast<SequentialType>(
this)->getElementType();
653 if (
const StructType *STy = dyn_cast<StructType>(
this)) {
661 const ConstantInt *CU = dyn_cast_or_null<ConstantInt>(
C);
662 return CU && CU->
getZExtValue() < STy->getNumElements();
670 if (
const StructType *STy = dyn_cast<StructType>(
this))
671 return Idx < STy->getNumElements();
681 ArrayType::ArrayType(
Type *ElType, uint64_t NumEl)
687 Type *ElementType =
const_cast<Type*
>(elementType);
692 pImpl->
ArrayTypes[std::make_pair(ElementType, NumElements)];
708 VectorType::VectorType(
Type *ElType,
unsigned NumEl)
714 Type *ElementType =
const_cast<Type*
>(elementType);
715 assert(NumElements > 0 &&
"#Elements of a VectorType must be greater than 0");
717 "be an integer, floating point, or "
722 ->
VectorTypes[std::make_pair(ElementType, NumElements)];
739 assert(EltTy &&
"Can't get a pointer to <null> type!");
754 PointerType::PointerType(
Type *E,
unsigned AddrSpace)
761 assert(oldNCT ==
NumContainedTys &&
"bitfield written out of bounds?");
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type (if unknown returns 0).
DenseMap< unsigned, IntegerType * > IntegerTypes
void push_back(const T &Elt)
static Type * getDoubleTy(LLVMContext &C)
static IntegerType * getInt1Ty(LLVMContext &C)
unsigned getStructNumElements() const
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
Type * getSequentialElementType() const
size_t size() const
size - Get the string size.
AlignOf - A templated class that contains an enum value representing the alignment of the template ar...
bool isOpaque() const
isOpaque - Return true if this is a type with an identity that has no body specified yet...
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
APInt getMask() const
For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc.
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
2: 32-bit floating point type
Constant * getSplatValue() const
getSplatValue - If this is a splat vector constant, meaning that all of the elements have the same va...
static PointerType * getInt32PtrTy(LLVMContext &C, unsigned AS=0)
bool indexValid(const Value *V) const
static PointerType * get(Type *ElementType, unsigned AddressSpace)
PointerType::get - This constructs a pointer to an object of the specified type in a numbered address...
bool isSized(SmallPtrSetImpl< const Type * > *Visited=nullptr) const
isSized - Return true if this is a sized type.
A raw_ostream that writes to an SmallVector or SmallString.
int getFPMantissaWidth() const
getFPMantissaWidth - Return the width of the mantissa of this type.
4: 80-bit floating point type (X87)
static bool isValidReturnType(Type *RetTy)
isValidReturnType - 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
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
static IntegerType * getInt64Ty(LLVMContext &C)
DenseMap< std::pair< Type *, unsigned >, PointerType * > ASPointerTypes
static Type * getMetadataTy(LLVMContext &C)
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static bool isValidArgumentType(Type *ArgTy)
isValidArgumentType - 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)
StructType * getTypeByName(StringRef Name) const
Return the type with the specified name, or null if there is none by that name.
static PointerType * getInt64PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getX86_FP80Ty(LLVMContext &C)
Type *const * ContainedTys
ContainedTys - A pointer to the array of Types contained by this Type.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
element_iterator element_end() const
Minimum number of bits that can be specified.
Type::subtype_iterator element_iterator
static Type * getFloatTy(LLVMContext &C)
StructType - Class to represent struct types.
bool canLosslesslyBitCastTo(Type *Ty) const
canLosslesslyBitCastTo - Return true if this type could be converted with a lossless BitCast to type ...
DenseMap< std::pair< Type *, uint64_t >, ArrayType * > ArrayTypes
bool isLiteral() const
isLiteral - Return true if this type is uniqued by structural equivalence, false if it is a struct de...
static StringRef getName(Value *V)
TypeID
Definitions of all of the base types for the Type system.
bool isSized(SmallPtrSetImpl< const Type * > *Visited=nullptr) const
isSized - Return true if it makes sense to take the size of this type.
StringRef getStructName() const
element_iterator element_begin() const
static PointerType * getInt16PtrTy(LLVMContext &C, unsigned AS=0)
Type * getFunctionParamType(unsigned i) const
static Type * getPPC_FP128Ty(LLVMContext &C)
BumpPtrAllocator TypeAllocator
TypeAllocator - All dynamically allocated types are allocated from this.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
FunctionType - Class to represent function types.
static Type * getLabelTy(LLVMContext &C)
unsigned NamedStructTypesUniqueID
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
ArrayType - Class to represent array types.
static bool isValidElementType(Type *ElemTy)
isValidElementType - Return true if the specified type is valid as a element type.
static PointerType * getDoublePtrTy(LLVMContext &C, unsigned AS=0)
bool isFirstClassType() const
isFirstClassType - Return true if the type is "first class", meaning it is a valid type for a Value...
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
FunctionType::get - This static method is the primary way of constructing a FunctionType.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
TypeID getTypeID() const
getTypeID - Return the type id for the type.
bool isFloatingPointTy() const
isFloatingPointTy - Return true if this is one of the six floating point types
unsigned getSubclassData() const
DenseMap< std::pair< Type *, unsigned >, VectorType * > VectorTypes
Type * getElementType() const
size_t size() const
size - Get the array size.
PointerType - Class to represent pointers.
10: Arbitrary bit width integers
unsigned getFunctionNumParams() const
bool isIntOrIntVectorTy() const
isIntOrIntVectorTy - Return true if this is an integer type or a vector of integer types...
static IntegerType * getInt128Ty(LLVMContext &C)
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.
void resync()
This is called when the SmallVector we're appending to is changed outside of the raw_svector_ostream'...
bool isVectorTy() const
isVectorTy - True if this is an instance of VectorType.
Type * getElementType(unsigned N) const
This is an important base class in LLVM.
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool isLayoutIdentical(StructType *Other) const
isLayoutIdentical - Return true if this is layout identical to the specified struct.
static Type * getVoidTy(LLVMContext &C)
Type * getTypeAtIndex(const Value *V)
getTypeAtIndex - Given an index value into the type, return the type of the element.
uint64_t getNumElements() const
6: 128-bit floating point type (two 64-bits, PowerPC)
Class to represent integer types.
bool empty() const
empty - Check if the array is empty.
static PointerType * getPPC_FP128PtrTy(LLVMContext &C, unsigned AS=0)
static bool isValidElementType(Type *ElemTy)
isValidElementType - Return true if the specified type is valid as a element type.
bool isPointerTy() const
isPointerTy - True if this is an instance of PointerType.
static PointerType * getFloatPtrTy(LLVMContext &C, unsigned AS=0)
PointerType * getPointerTo(unsigned AddrSpace=0)
getPointerTo - Return a pointer to the current type.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
void setBody(ArrayRef< Type * > Elements, bool isPacked=false)
setBody - Specify a body for an opaque identified type.
LLVMContextImpl *const pImpl
static Type * getFP128Ty(LLVMContext &C)
static PointerType * getX86_FP80PtrTy(LLVMContext &C, unsigned AS=0)
SequentialType - This is the superclass of the array, pointer 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.
std::pair< iterator, bool > insert(const ValueT &V)
static PointerType * getInt1PtrTy(LLVMContext &C, unsigned AS=0)
unsigned getIntegerBitWidth() const
static bool isValidElementType(Type *ElemTy)
isValidElementType - Return true if the specified type is valid as a element type.
This is the shared class of boolean and integer constants.
bool isFunctionTy() const
isFunctionTy - True if this is an instance of FunctionType.
15: SIMD 'packed' format, or other vector type
unsigned getVectorNumElements() const
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
StructType::get - This static method is the primary way to create a literal StructType.
bool isFunctionVarArg() const
unsigned getScalarSizeInBits() const LLVM_READONLY
getScalarSizeInBits - If this is a vector type, return the getPrimitiveSizeInBits value for the eleme...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
AllocatorTy & getAllocator()
FunctionTypeSet FunctionTypes
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
static PointerType * getHalfPtrTy(LLVMContext &C, unsigned AS=0)
Maximum number of bits that can be specified.
static Type * getPrimitiveType(LLVMContext &C, TypeID IDNumber)
getPrimitiveType - 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"...
VectorType - Class to represent vector types.
Class for arbitrary precision integers.
bool isIntegerTy() const
isIntegerTy - True if this is an instance of IntegerType.
StringRef getName() const
getName - Return the name for this struct type if it has an identity.
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
iterator find_as(const LookupKeyT &Val)
Alternative version of find() which allows a different, and possibly less expensive, key type.
const Type * getScalarType() const LLVM_READONLY
getScalarType - If this is a vector type, return the element type, otherwise return 'this'...
StringRef str()
Flushes the stream contents to the target vector and return a StringRef for the vector contents...
StructTypeSet AnonStructTypes
void setName(StringRef Name)
setName - Change the name of this type to the specified name, or to a name with a suffix if there is ...
static IntegerType * getInt32Ty(LLVMContext &C)
StringMap< StructType * > NamedStructTypes
static bool isValidElementType(Type *ElemTy)
isValidElementType - Return true if the specified type is valid as a element type.
static ArrayType * get(Type *ElementType, uint64_t NumElements)
ArrayType::get - This static method is the primary way to construct an ArrayType. ...
bool isPowerOf2ByteWidth() const
This method determines if the width of this IntegerType is a power-of-2 in terms of 8 bit bytes...
uint64_t getArrayNumElements() const
IntegerType(LLVMContext &C, unsigned NumBits)
static PointerType * getIntNPtrTy(LLVMContext &C, unsigned N, unsigned AS=0)
3: 64-bit floating point type
void setSubclassData(unsigned val)
bool isEmptyTy() const
isEmptyTy - Return true if this type is empty, that is, it has no elements or all its elements are em...
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
getPrimitiveSizeInBits - Return the basic size of this type if it is a primitive type.
bool isLabelTy() const
isLabelTy - Return true if this is 'label'.
LLVM Value Representation.
static VectorType * get(Type *ElementType, unsigned NumElements)
VectorType::get - This static method is the primary way to construct an VectorType.
static StructType * create(LLVMContext &Context, StringRef Name)
StructType::create - This creates an identified struct.
Type * getStructElementType(unsigned N) const
bool isPowerOf2_32(uint32_t Value)
isPowerOf2_32 - This function returns true if the argument is a power of two > 0. ...
StringRef - Represent a constant reference to a string, i.e.
DenseMap< Type *, PointerType * > PointerTypes
9: MMX vectors (64 bits, X86 specific)
unsigned getNumElements() const
Random access to the elements.
static IntegerType * getInt8Ty(LLVMContext &C)
unsigned NumContainedTys
NumContainedTys - Keeps track of how many Type*'s there are in the ContainedTys list.
LLVMContext & getContext() const
Get the global data context.
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.
bool empty() const
empty - Check if the string is empty.
5: 128-bit floating point type (112-bit mantissa)
bool isMetadataTy() const
isMetadataTy - Return true if this is 'metadata'.