1 //===-- Type.cpp - Implement the Type class -------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the Type class for the VMCore library.
12 //===----------------------------------------------------------------------===//
14 #include "LLVMContextImpl.h"
15 #include "llvm/Module.h"
18 #include "llvm/ADT/SmallString.h"
21 //===----------------------------------------------------------------------===//
22 // Type Class Implementation
23 //===----------------------------------------------------------------------===//
25 Type *Type::getPrimitiveType(LLVMContext &C, TypeID IDNumber) {
27 case VoidTyID : return getVoidTy(C);
28 case FloatTyID : return getFloatTy(C);
29 case DoubleTyID : return getDoubleTy(C);
30 case X86_FP80TyID : return getX86_FP80Ty(C);
31 case FP128TyID : return getFP128Ty(C);
32 case PPC_FP128TyID : return getPPC_FP128Ty(C);
33 case LabelTyID : return getLabelTy(C);
34 case MetadataTyID : return getMetadataTy(C);
35 case X86_MMXTyID : return getX86_MMXTy(C);
41 /// getScalarType - If this is a vector type, return the element type,
42 /// otherwise return this.
43 Type *Type::getScalarType() {
44 if (VectorType *VTy = dyn_cast<VectorType>(this))
45 return VTy->getElementType();
49 /// getNumElements - If this is a vector type, return the number of elements,
50 /// otherwise return zero.
51 unsigned Type::getNumElements() {
52 if (VectorType *VTy = dyn_cast<VectorType>(this))
53 return VTy->getNumElements();
57 /// isIntegerTy - Return true if this is an IntegerType of the specified width.
58 bool Type::isIntegerTy(unsigned Bitwidth) const {
59 return isIntegerTy() && cast<IntegerType>(this)->getBitWidth() == Bitwidth;
62 /// isIntOrIntVectorTy - Return true if this is an integer type or a vector of
65 bool Type::isIntOrIntVectorTy() const {
68 if (ID != Type::VectorTyID) return false;
70 return cast<VectorType>(this)->getElementType()->isIntegerTy();
73 /// isFPOrFPVectorTy - Return true if this is a FP type or a vector of FP types.
75 bool Type::isFPOrFPVectorTy() const {
76 if (ID == Type::FloatTyID || ID == Type::DoubleTyID ||
77 ID == Type::FP128TyID || ID == Type::X86_FP80TyID ||
78 ID == Type::PPC_FP128TyID)
80 if (ID != Type::VectorTyID) return false;
82 return cast<VectorType>(this)->getElementType()->isFloatingPointTy();
85 // canLosslesslyBitCastTo - Return true if this type can be converted to
86 // 'Ty' without any reinterpretation of bits. For example, i8* to i32*.
88 bool Type::canLosslesslyBitCastTo(Type *Ty) const {
89 // Identity cast means no change so return true
93 // They are not convertible unless they are at least first class types
94 if (!this->isFirstClassType() || !Ty->isFirstClassType())
97 // Vector -> Vector conversions are always lossless if the two vector types
98 // have the same size, otherwise not. Also, 64-bit vector types can be
99 // converted to x86mmx.
100 if (const VectorType *thisPTy = dyn_cast<VectorType>(this)) {
101 if (const VectorType *thatPTy = dyn_cast<VectorType>(Ty))
102 return thisPTy->getBitWidth() == thatPTy->getBitWidth();
103 if (Ty->getTypeID() == Type::X86_MMXTyID &&
104 thisPTy->getBitWidth() == 64)
108 if (this->getTypeID() == Type::X86_MMXTyID)
109 if (const VectorType *thatPTy = dyn_cast<VectorType>(Ty))
110 if (thatPTy->getBitWidth() == 64)
113 // At this point we have only various mismatches of the first class types
114 // remaining and ptr->ptr. Just select the lossless conversions. Everything
115 // else is not lossless.
116 if (this->isPointerTy())
117 return Ty->isPointerTy();
118 return false; // Other types have no identity values
121 bool Type::isEmptyTy() const {
122 const ArrayType *ATy = dyn_cast<ArrayType>(this);
124 unsigned NumElements = ATy->getNumElements();
125 return NumElements == 0 || ATy->getElementType()->isEmptyTy();
128 const StructType *STy = dyn_cast<StructType>(this);
130 unsigned NumElements = STy->getNumElements();
131 for (unsigned i = 0; i < NumElements; ++i)
132 if (!STy->getElementType(i)->isEmptyTy())
140 unsigned Type::getPrimitiveSizeInBits() const {
141 switch (getTypeID()) {
142 case Type::FloatTyID: return 32;
143 case Type::DoubleTyID: return 64;
144 case Type::X86_FP80TyID: return 80;
145 case Type::FP128TyID: return 128;
146 case Type::PPC_FP128TyID: return 128;
147 case Type::X86_MMXTyID: return 64;
148 case Type::IntegerTyID: return cast<IntegerType>(this)->getBitWidth();
149 case Type::VectorTyID: return cast<VectorType>(this)->getBitWidth();
154 /// getScalarSizeInBits - If this is a vector type, return the
155 /// getPrimitiveSizeInBits value for the element type. Otherwise return the
156 /// getPrimitiveSizeInBits value for this type.
157 unsigned Type::getScalarSizeInBits() {
158 return getScalarType()->getPrimitiveSizeInBits();
161 /// getFPMantissaWidth - Return the width of the mantissa of this type. This
162 /// is only valid on floating point types. If the FP type does not
163 /// have a stable mantissa (e.g. ppc long double), this method returns -1.
164 int Type::getFPMantissaWidth() const {
165 if (const VectorType *VTy = dyn_cast<VectorType>(this))
166 return VTy->getElementType()->getFPMantissaWidth();
167 assert(isFloatingPointTy() && "Not a floating point type!");
168 if (ID == FloatTyID) return 24;
169 if (ID == DoubleTyID) return 53;
170 if (ID == X86_FP80TyID) return 64;
171 if (ID == FP128TyID) return 113;
172 assert(ID == PPC_FP128TyID && "unknown fp type");
176 /// isSizedDerivedType - Derived types like structures and arrays are sized
177 /// iff all of the members of the type are sized as well. Since asking for
178 /// their size is relatively uncommon, move this operation out of line.
179 bool Type::isSizedDerivedType() const {
180 if (this->isIntegerTy())
183 if (const ArrayType *ATy = dyn_cast<ArrayType>(this))
184 return ATy->getElementType()->isSized();
186 if (const VectorType *VTy = dyn_cast<VectorType>(this))
187 return VTy->getElementType()->isSized();
189 if (!this->isStructTy())
192 // Opaque structs have no size.
193 if (cast<StructType>(this)->isOpaque())
196 // Okay, our struct is sized if all of the elements are.
197 for (subtype_iterator I = subtype_begin(), E = subtype_end(); I != E; ++I)
198 if (!(*I)->isSized())
204 //===----------------------------------------------------------------------===//
205 // Primitive 'Type' data
206 //===----------------------------------------------------------------------===//
208 Type *Type::getVoidTy(LLVMContext &C) { return &C.pImpl->VoidTy; }
209 Type *Type::getLabelTy(LLVMContext &C) { return &C.pImpl->LabelTy; }
210 Type *Type::getFloatTy(LLVMContext &C) { return &C.pImpl->FloatTy; }
211 Type *Type::getDoubleTy(LLVMContext &C) { return &C.pImpl->DoubleTy; }
212 Type *Type::getMetadataTy(LLVMContext &C) { return &C.pImpl->MetadataTy; }
213 Type *Type::getX86_FP80Ty(LLVMContext &C) { return &C.pImpl->X86_FP80Ty; }
214 Type *Type::getFP128Ty(LLVMContext &C) { return &C.pImpl->FP128Ty; }
215 Type *Type::getPPC_FP128Ty(LLVMContext &C) { return &C.pImpl->PPC_FP128Ty; }
216 Type *Type::getX86_MMXTy(LLVMContext &C) { return &C.pImpl->X86_MMXTy; }
218 IntegerType *Type::getInt1Ty(LLVMContext &C) { return &C.pImpl->Int1Ty; }
219 IntegerType *Type::getInt8Ty(LLVMContext &C) { return &C.pImpl->Int8Ty; }
220 IntegerType *Type::getInt16Ty(LLVMContext &C) { return &C.pImpl->Int16Ty; }
221 IntegerType *Type::getInt32Ty(LLVMContext &C) { return &C.pImpl->Int32Ty; }
222 IntegerType *Type::getInt64Ty(LLVMContext &C) { return &C.pImpl->Int64Ty; }
224 IntegerType *Type::getIntNTy(LLVMContext &C, unsigned N) {
225 return IntegerType::get(C, N);
228 PointerType *Type::getFloatPtrTy(LLVMContext &C, unsigned AS) {
229 return getFloatTy(C)->getPointerTo(AS);
232 PointerType *Type::getDoublePtrTy(LLVMContext &C, unsigned AS) {
233 return getDoubleTy(C)->getPointerTo(AS);
236 PointerType *Type::getX86_FP80PtrTy(LLVMContext &C, unsigned AS) {
237 return getX86_FP80Ty(C)->getPointerTo(AS);
240 PointerType *Type::getFP128PtrTy(LLVMContext &C, unsigned AS) {
241 return getFP128Ty(C)->getPointerTo(AS);
244 PointerType *Type::getPPC_FP128PtrTy(LLVMContext &C, unsigned AS) {
245 return getPPC_FP128Ty(C)->getPointerTo(AS);
248 PointerType *Type::getX86_MMXPtrTy(LLVMContext &C, unsigned AS) {
249 return getX86_MMXTy(C)->getPointerTo(AS);
252 PointerType *Type::getIntNPtrTy(LLVMContext &C, unsigned N, unsigned AS) {
253 return getIntNTy(C, N)->getPointerTo(AS);
256 PointerType *Type::getInt1PtrTy(LLVMContext &C, unsigned AS) {
257 return getInt1Ty(C)->getPointerTo(AS);
260 PointerType *Type::getInt8PtrTy(LLVMContext &C, unsigned AS) {
261 return getInt8Ty(C)->getPointerTo(AS);
264 PointerType *Type::getInt16PtrTy(LLVMContext &C, unsigned AS) {
265 return getInt16Ty(C)->getPointerTo(AS);
268 PointerType *Type::getInt32PtrTy(LLVMContext &C, unsigned AS) {
269 return getInt32Ty(C)->getPointerTo(AS);
272 PointerType *Type::getInt64PtrTy(LLVMContext &C, unsigned AS) {
273 return getInt64Ty(C)->getPointerTo(AS);
277 //===----------------------------------------------------------------------===//
278 // IntegerType Implementation
279 //===----------------------------------------------------------------------===//
281 IntegerType *IntegerType::get(LLVMContext &C, unsigned NumBits) {
282 assert(NumBits >= MIN_INT_BITS && "bitwidth too small");
283 assert(NumBits <= MAX_INT_BITS && "bitwidth too large");
285 // Check for the built-in integer types
287 case 1: return cast<IntegerType>(Type::getInt1Ty(C));
288 case 8: return cast<IntegerType>(Type::getInt8Ty(C));
289 case 16: return cast<IntegerType>(Type::getInt16Ty(C));
290 case 32: return cast<IntegerType>(Type::getInt32Ty(C));
291 case 64: return cast<IntegerType>(Type::getInt64Ty(C));
296 IntegerType *&Entry = C.pImpl->IntegerTypes[NumBits];
299 Entry = new (C.pImpl->TypeAllocator) IntegerType(C, NumBits);
304 bool IntegerType::isPowerOf2ByteWidth() const {
305 unsigned BitWidth = getBitWidth();
306 return (BitWidth > 7) && isPowerOf2_32(BitWidth);
309 APInt IntegerType::getMask() const {
310 return APInt::getAllOnesValue(getBitWidth());
313 //===----------------------------------------------------------------------===//
314 // FunctionType Implementation
315 //===----------------------------------------------------------------------===//
317 FunctionType::FunctionType(Type *Result, ArrayRef<Type*> Params,
319 : Type(Result->getContext(), FunctionTyID) {
320 Type **SubTys = reinterpret_cast<Type**>(this+1);
321 assert(isValidReturnType(Result) && "invalid return type for function");
322 setSubclassData(IsVarArgs);
324 SubTys[0] = const_cast<Type*>(Result);
326 for (unsigned i = 0, e = Params.size(); i != e; ++i) {
327 assert(isValidArgumentType(Params[i]) &&
328 "Not a valid type for function argument!");
329 SubTys[i+1] = Params[i];
332 ContainedTys = SubTys;
333 NumContainedTys = Params.size() + 1; // + 1 for result type
336 // FunctionType::get - The factory function for the FunctionType class.
337 FunctionType *FunctionType::get(Type *ReturnType,
338 ArrayRef<Type*> Params, bool isVarArg) {
339 // TODO: This is brutally slow.
340 std::vector<Type*> Key;
341 Key.reserve(Params.size()+2);
342 Key.push_back(const_cast<Type*>(ReturnType));
343 for (unsigned i = 0, e = Params.size(); i != e; ++i)
344 Key.push_back(const_cast<Type*>(Params[i]));
348 LLVMContextImpl *pImpl = ReturnType->getContext().pImpl;
349 FunctionType *&FT = pImpl->FunctionTypes[Key];
352 FT = (FunctionType*) pImpl->TypeAllocator.
353 Allocate(sizeof(FunctionType) + sizeof(Type*)*(Params.size()+1),
354 AlignOf<FunctionType>::Alignment);
355 new (FT) FunctionType(ReturnType, Params, isVarArg);
362 FunctionType *FunctionType::get(Type *Result, bool isVarArg) {
363 return get(Result, ArrayRef<Type *>(), isVarArg);
367 /// isValidReturnType - Return true if the specified type is valid as a return
369 bool FunctionType::isValidReturnType(Type *RetTy) {
370 return !RetTy->isFunctionTy() && !RetTy->isLabelTy() &&
371 !RetTy->isMetadataTy();
374 /// isValidArgumentType - Return true if the specified type is valid as an
376 bool FunctionType::isValidArgumentType(Type *ArgTy) {
377 return ArgTy->isFirstClassType();
380 //===----------------------------------------------------------------------===//
381 // StructType Implementation
382 //===----------------------------------------------------------------------===//
384 // Primitive Constructors.
386 StructType *StructType::get(LLVMContext &Context, ArrayRef<Type*> ETypes,
388 // FIXME: std::vector is horribly inefficient for this probe.
389 std::vector<Type*> Key;
390 for (unsigned i = 0, e = ETypes.size(); i != e; ++i) {
391 assert(isValidElementType(ETypes[i]) &&
392 "Invalid type for structure element!");
393 Key.push_back(ETypes[i]);
398 StructType *&ST = Context.pImpl->AnonStructTypes[Key];
401 // Value not found. Create a new type!
402 ST = new (Context.pImpl->TypeAllocator) StructType(Context);
403 ST->setSubclassData(SCDB_IsLiteral); // Literal struct.
404 ST->setBody(ETypes, isPacked);
408 void StructType::setBody(ArrayRef<Type*> Elements, bool isPacked) {
409 assert(isOpaque() && "Struct body already set!");
411 setSubclassData(getSubclassData() | SCDB_HasBody);
413 setSubclassData(getSubclassData() | SCDB_Packed);
415 Type **Elts = getContext().pImpl->
416 TypeAllocator.Allocate<Type*>(Elements.size());
417 memcpy(Elts, Elements.data(), sizeof(Elements[0])*Elements.size());
420 NumContainedTys = Elements.size();
423 void StructType::setName(StringRef Name) {
424 if (Name == getName()) return;
426 // If this struct already had a name, remove its symbol table entry.
427 if (SymbolTableEntry) {
428 getContext().pImpl->NamedStructTypes.erase(getName());
429 SymbolTableEntry = 0;
432 // If this is just removing the name, we're done.
436 // Look up the entry for the name.
437 StringMapEntry<StructType*> *Entry =
438 &getContext().pImpl->NamedStructTypes.GetOrCreateValue(Name);
440 // While we have a name collision, try a random rename.
441 if (Entry->getValue()) {
442 SmallString<64> TempStr(Name);
443 TempStr.push_back('.');
444 raw_svector_ostream TmpStream(TempStr);
447 TempStr.resize(Name.size()+1);
449 TmpStream << getContext().pImpl->NamedStructTypesUniqueID++;
451 Entry = &getContext().pImpl->
452 NamedStructTypes.GetOrCreateValue(TmpStream.str());
453 } while (Entry->getValue());
456 // Okay, we found an entry that isn't used. It's us!
457 Entry->setValue(this);
459 SymbolTableEntry = Entry;
462 //===----------------------------------------------------------------------===//
463 // StructType Helper functions.
465 StructType *StructType::create(LLVMContext &Context, StringRef Name) {
466 StructType *ST = new (Context.pImpl->TypeAllocator) StructType(Context);
472 StructType *StructType::get(LLVMContext &Context, bool isPacked) {
473 return get(Context, llvm::ArrayRef<Type*>(), isPacked);
476 StructType *StructType::get(Type *type, ...) {
477 assert(type != 0 && "Cannot create a struct type with no elements with this");
478 LLVMContext &Ctx = type->getContext();
480 SmallVector<llvm::Type*, 8> StructFields;
483 StructFields.push_back(type);
484 type = va_arg(ap, llvm::Type*);
486 return llvm::StructType::get(Ctx, StructFields);
489 StructType *StructType::create(LLVMContext &Context, ArrayRef<Type*> Elements,
490 StringRef Name, bool isPacked) {
491 StructType *ST = create(Context, Name);
492 ST->setBody(Elements, isPacked);
496 StructType *StructType::create(LLVMContext &Context, ArrayRef<Type*> Elements) {
497 return create(Context, Elements, StringRef());
500 StructType *StructType::create(LLVMContext &Context) {
501 return create(Context, StringRef());
505 StructType *StructType::create(ArrayRef<Type*> Elements, StringRef Name,
507 assert(!Elements.empty() &&
508 "This method may not be invoked with an empty list");
509 return create(Elements[0]->getContext(), Elements, Name, isPacked);
512 StructType *StructType::create(ArrayRef<Type*> Elements) {
513 assert(!Elements.empty() &&
514 "This method may not be invoked with an empty list");
515 return create(Elements[0]->getContext(), Elements, StringRef());
518 StructType *StructType::create(StringRef Name, Type *type, ...) {
519 assert(type != 0 && "Cannot create a struct type with no elements with this");
520 LLVMContext &Ctx = type->getContext();
522 SmallVector<llvm::Type*, 8> StructFields;
525 StructFields.push_back(type);
526 type = va_arg(ap, llvm::Type*);
528 return llvm::StructType::create(Ctx, StructFields, Name);
532 StringRef StructType::getName() const {
533 assert(!isLiteral() && "Literal structs never have names");
534 if (SymbolTableEntry == 0) return StringRef();
536 return ((StringMapEntry<StructType*> *)SymbolTableEntry)->getKey();
539 void StructType::setBody(Type *type, ...) {
540 assert(type != 0 && "Cannot create a struct type with no elements with this");
542 SmallVector<llvm::Type*, 8> StructFields;
545 StructFields.push_back(type);
546 type = va_arg(ap, llvm::Type*);
548 setBody(StructFields);
551 bool StructType::isValidElementType(Type *ElemTy) {
552 return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() &&
553 !ElemTy->isMetadataTy() && !ElemTy->isFunctionTy();
556 /// isLayoutIdentical - Return true if this is layout identical to the
557 /// specified struct.
558 bool StructType::isLayoutIdentical(StructType *Other) const {
559 if (this == Other) return true;
561 if (isPacked() != Other->isPacked() ||
562 getNumElements() != Other->getNumElements())
565 return std::equal(element_begin(), element_end(), Other->element_begin());
569 /// getTypeByName - Return the type with the specified name, or null if there
570 /// is none by that name.
571 StructType *Module::getTypeByName(StringRef Name) const {
572 StringMap<StructType*>::iterator I =
573 getContext().pImpl->NamedStructTypes.find(Name);
574 if (I != getContext().pImpl->NamedStructTypes.end())
580 //===----------------------------------------------------------------------===//
581 // CompositeType Implementation
582 //===----------------------------------------------------------------------===//
584 Type *CompositeType::getTypeAtIndex(const Value *V) {
585 if (StructType *STy = dyn_cast<StructType>(this)) {
586 unsigned Idx = (unsigned)cast<ConstantInt>(V)->getZExtValue();
587 assert(indexValid(Idx) && "Invalid structure index!");
588 return STy->getElementType(Idx);
591 return cast<SequentialType>(this)->getElementType();
593 Type *CompositeType::getTypeAtIndex(unsigned Idx) {
594 if (StructType *STy = dyn_cast<StructType>(this)) {
595 assert(indexValid(Idx) && "Invalid structure index!");
596 return STy->getElementType(Idx);
599 return cast<SequentialType>(this)->getElementType();
601 bool CompositeType::indexValid(const Value *V) const {
602 if (const StructType *STy = dyn_cast<StructType>(this)) {
603 // Structure indexes require 32-bit integer constants.
604 if (V->getType()->isIntegerTy(32))
605 if (const ConstantInt *CU = dyn_cast<ConstantInt>(V))
606 return CU->getZExtValue() < STy->getNumElements();
610 // Sequential types can be indexed by any integer.
611 return V->getType()->isIntegerTy();
614 bool CompositeType::indexValid(unsigned Idx) const {
615 if (const StructType *STy = dyn_cast<StructType>(this))
616 return Idx < STy->getNumElements();
617 // Sequential types can be indexed by any integer.
622 //===----------------------------------------------------------------------===//
623 // ArrayType Implementation
624 //===----------------------------------------------------------------------===//
626 ArrayType::ArrayType(Type *ElType, uint64_t NumEl)
627 : SequentialType(ArrayTyID, ElType) {
632 ArrayType *ArrayType::get(Type *elementType, uint64_t NumElements) {
633 Type *ElementType = const_cast<Type*>(elementType);
634 assert(isValidElementType(ElementType) && "Invalid type for array element!");
636 LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
638 pImpl->ArrayTypes[std::make_pair(ElementType, NumElements)];
641 Entry = new (pImpl->TypeAllocator) ArrayType(ElementType, NumElements);
645 bool ArrayType::isValidElementType(Type *ElemTy) {
646 return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() &&
647 !ElemTy->isMetadataTy() && !ElemTy->isFunctionTy();
650 //===----------------------------------------------------------------------===//
651 // VectorType Implementation
652 //===----------------------------------------------------------------------===//
654 VectorType::VectorType(Type *ElType, unsigned NumEl)
655 : SequentialType(VectorTyID, ElType) {
659 VectorType *VectorType::get(Type *elementType, unsigned NumElements) {
660 Type *ElementType = const_cast<Type*>(elementType);
661 assert(NumElements > 0 && "#Elements of a VectorType must be greater than 0");
662 assert(isValidElementType(ElementType) &&
663 "Elements of a VectorType must be a primitive type");
665 LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
666 VectorType *&Entry = ElementType->getContext().pImpl
667 ->VectorTypes[std::make_pair(ElementType, NumElements)];
670 Entry = new (pImpl->TypeAllocator) VectorType(ElementType, NumElements);
674 bool VectorType::isValidElementType(Type *ElemTy) {
675 if (PointerType *PTy = dyn_cast<PointerType>(ElemTy))
676 ElemTy = PTy->getElementType();
677 return ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy();
680 //===----------------------------------------------------------------------===//
681 // PointerType Implementation
682 //===----------------------------------------------------------------------===//
684 PointerType *PointerType::get(Type *EltTy, unsigned AddressSpace) {
685 assert(EltTy && "Can't get a pointer to <null> type!");
686 assert(isValidElementType(EltTy) && "Invalid type for pointer element!");
688 LLVMContextImpl *CImpl = EltTy->getContext().pImpl;
690 // Since AddressSpace #0 is the common case, we special case it.
691 PointerType *&Entry = AddressSpace == 0 ? CImpl->PointerTypes[EltTy]
692 : CImpl->ASPointerTypes[std::make_pair(EltTy, AddressSpace)];
695 Entry = new (CImpl->TypeAllocator) PointerType(EltTy, AddressSpace);
700 PointerType::PointerType(Type *E, unsigned AddrSpace)
701 : SequentialType(PointerTyID, E) {
702 setSubclassData(AddrSpace);
705 PointerType *Type::getPointerTo(unsigned addrs) {
706 return PointerType::get(this, addrs);
709 bool PointerType::isValidElementType(Type *ElemTy) {
710 return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() &&
711 !ElemTy->isMetadataTy();