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)
108 for (
unsigned i = 0; i < NumElements; ++i)
143 if (
const VectorType *VTy = dyn_cast<VectorType>(
this))
144 return VTy->getElementType()->getFPMantissaWidth();
158 bool Type::isSizedDerivedType()
const {
162 if (
const ArrayType *ATy = dyn_cast<ArrayType>(
this))
163 return ATy->getElementType()->isSized();
165 if (
const VectorType *VTy = dyn_cast<VectorType>(
this))
166 return VTy->getElementType()->isSized();
171 return cast<StructType>(
this)->
isSized();
183 return cast<FunctionType>(
this)->isVarArg();
187 return cast<FunctionType>(
this)->getParamType(i);
191 return cast<FunctionType>(
this)->getNumParams();
195 return cast<StructType>(
this)->
getName();
199 return cast<StructType>(
this)->getNumElements();
203 return cast<StructType>(
this)->getElementType(N);
207 return cast<SequentialType>(
this)->getElementType();
211 return cast<ArrayType>(
this)->getNumElements();
215 return cast<VectorType>(
this)->getNumElements();
219 return cast<PointerType>(
getScalarType())->getAddressSpace();
306 assert(NumBits >=
MIN_INT_BITS &&
"bitwidth too small");
307 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];
427 assert(
isOpaque() &&
"Struct body already set!");
433 unsigned NumElements = Elements.
size();
435 memcpy(Elts, Elements.
data(),
sizeof(Elements[0]) * NumElements);
449 if (SymbolTableEntry)
450 SymbolTable.
remove((EntryTy *)SymbolTableEntry);
454 if (SymbolTableEntry) {
456 ((EntryTy *)SymbolTableEntry)->Destroy(SymbolTable.
getAllocator());
457 SymbolTableEntry = 0;
466 if (Entry->getValue()) {
473 TempStr.
resize(NameSize + 1);
478 NamedStructTypes.GetOrCreateValue(TmpStream.
str());
479 }
while (Entry->getValue());
483 Entry->setValue(
this);
486 if (SymbolTableEntry)
487 ((EntryTy *)SymbolTableEntry)->Destroy(SymbolTable.
getAllocator());
488 SymbolTableEntry = Entry;
506 assert(type != 0 &&
"Cannot create a struct type with no elements with this");
521 ST->
setBody(Elements, isPacked);
535 assert(!Elements.
empty() &&
536 "This method may not be invoked with an empty list");
541 assert(!Elements.
empty() &&
542 "This method may not be invoked with an empty list");
547 assert(type != 0 &&
"Cannot create a struct type with no elements with this");
569 if (!(*I)->isSized())
581 assert(!
isLiteral() &&
"Literal structs never have names");
582 if (SymbolTableEntry == 0)
return StringRef();
588 assert(type != 0 &&
"Cannot create a struct type with no elements with this");
607 if (
this == Other)
return true;
628 if (
StructType *STy = dyn_cast<StructType>(
this)) {
630 (
unsigned)cast<Constant>(V)->getUniqueInteger().getZExtValue();
631 assert(
indexValid(Idx) &&
"Invalid structure index!");
632 return STy->getElementType(Idx);
635 return cast<SequentialType>(
this)->getElementType();
638 if (
StructType *STy = dyn_cast<StructType>(
this)) {
639 assert(
indexValid(Idx) &&
"Invalid structure index!");
640 return STy->getElementType(Idx);
643 return cast<SequentialType>(
this)->getElementType();
646 if (
const StructType *STy = dyn_cast<StructType>(
this)) {
654 const ConstantInt *CU = dyn_cast_or_null<ConstantInt>(
C);
655 return CU && CU->
getZExtValue() < STy->getNumElements();
663 if (
const StructType *STy = dyn_cast<StructType>(
this))
664 return Idx < STy->getNumElements();
674 ArrayType::ArrayType(
Type *ElType, uint64_t NumEl)
680 Type *ElementType =
const_cast<Type*
>(elementType);
685 pImpl->
ArrayTypes[std::make_pair(ElementType, NumElements)];
701 VectorType::VectorType(
Type *ElType,
unsigned NumEl)
707 Type *ElementType =
const_cast<Type*
>(elementType);
708 assert(NumElements > 0 &&
"#Elements of a VectorType must be greater than 0");
710 "Elements of a VectorType must be a primitive type");
714 ->
VectorTypes[std::make_pair(ElementType, NumElements)];
731 assert(EltTy &&
"Can't get a pointer to <null> type!");
746 PointerType::PointerType(
Type *E,
unsigned AddrSpace)
753 assert(oldNCT ==
NumContainedTys &&
"bitfield written out of bounds?");
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.
APInt getMask() const
Get a bit mask for this type.
unsigned getScalarSizeInBits()
void remove(MapEntryTy *KeyValue)
2: 32-bit floating point type
Constant * getSplatValue() const
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static PointerType * getInt32PtrTy(LLVMContext &C, unsigned AS=0)
bool indexValid(const Value *V) const
static PointerType * get(Type *ElementType, unsigned AddressSpace)
int getFPMantissaWidth() const
4: 80-bit floating point type (X87)
FunctionTypeMap FunctionTypes
static bool isValidReturnType(Type *RetTy)
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)
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
static PointerType * getInt64PtrTy(LLVMContext &C, unsigned AS=0)
static Type * getX86_FP80Ty(LLVMContext &C)
Type *const * ContainedTys
element_iterator element_end() const
static unsigned getBitWidth(Type *Ty, const DataLayout *TD)
Type::subtype_iterator element_iterator
static Type * getFloatTy(LLVMContext &C)
bool canLosslesslyBitCastTo(Type *Ty) const
Determine if this type could be losslessly bitcast to Ty.
iterator find_as(const LookupKeyT &Val)
DenseMap< std::pair< Type *, uint64_t >, ArrayType * > ArrayTypes
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
uint64_t getZExtValue() const
Return the zero extended value.
static Type * getLabelTy(LLVMContext &C)
unsigned NamedStructTypesUniqueID
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
Minimum number of bits that can be specified.
static bool isValidElementType(Type *ElemTy)
static PointerType * getDoublePtrTy(LLVMContext &C, unsigned AS=0)
bool isFirstClassType() const
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
bool isFloatingPointTy() const
unsigned getSubclassData() const
DenseMap< std::pair< Type *, unsigned >, VectorType * > VectorTypes
Type * getElementType() const
size_t size() const
size - Get the array size.
10: Arbitrary bit width integers
unsigned getFunctionNumParams() const
bool isIntOrIntVectorTy() const
StructTypeMap AnonStructTypes
Type * getElementType(unsigned N) const
LLVM Constant Representation.
bool isLayoutIdentical(StructType *Other) const
static Type * getVoidTy(LLVMContext &C)
Type * getTypeAtIndex(const Value *V)
uint64_t getNumElements() const
6: 128-bit floating point type (two 64-bits, PowerPC)
Integer representation type.
bool empty() const
empty - Check if the array is empty.
static PointerType * getPPC_FP128PtrTy(LLVMContext &C, unsigned AS=0)
static bool isValidElementType(Type *ElemTy)
static PointerType * getFloatPtrTy(LLVMContext &C, unsigned AS=0)
PointerType * getPointerTo(unsigned AddrSpace=0)
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)
static Type * getHalfTy(LLVMContext &C)
static IntegerType * get(LLVMContext &C, unsigned NumBits)
Get or create an IntegerType instance.
static PointerType * getInt1PtrTy(LLVMContext &C, unsigned AS=0)
unsigned getIntegerBitWidth() const
static bool isValidElementType(Type *ElemTy)
Class for constant integers.
bool isFunctionTy() const
15: SIMD 'packed' format, or other vector type
unsigned getVectorNumElements() const
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
bool isFunctionVarArg() const
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
static PointerType * getHalfPtrTy(LLVMContext &C, unsigned AS=0)
static Type * getPrimitiveType(LLVMContext &C, TypeID IDNumber)
getPrimitiveType - Return a type based on an identifier.
static PointerType * getFP128PtrTy(LLVMContext &C, unsigned AS=0)
Class for arbitrary precision integers.
void * Allocate(size_t Size, size_t Alignment)
StringRef getName() const
void setName(StringRef Name)
std::string getName(ID id, ArrayRef< Type * > Tys=None)
static IntegerType * getInt32Ty(LLVMContext &C)
StringMap< StructType * > NamedStructTypes
static bool isValidElementType(Type *ElemTy)
static ArrayType * get(Type *ElementType, uint64_t NumElements)
bool isSized() const
isSized - Return true if this is a sized type.
bool isPowerOf2ByteWidth() const
Is this a power-of-2 byte-width IntegerType ?
const Type * getScalarType() const
uint64_t getArrayNumElements() const
unsigned getPrimitiveSizeInBits() 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 isLabelTy() const
isLabelTy - Return true if this is 'label'.
LLVM Value Representation.
static VectorType * get(Type *ElementType, unsigned NumElements)
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)
AllocatorRefTy getAllocator()
DenseMap< Type *, PointerType * > PointerTypes
9: MMX vectors (64 bits, X86 specific)
unsigned getNumElements() const
Random access to the elements.
static IntegerType * getInt8Ty(LLVMContext &C)
LLVMContext & getContext() const
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'.