From 1608769abeb1430dc34f31ffac0d9850f99ae36a Mon Sep 17 00:00:00 2001 From: Nadav Rotem Date: Mon, 5 Dec 2011 06:29:09 +0000 Subject: Add support for vectors of pointers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145801 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Type.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/VMCore/Type.cpp') diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 10184bc6f0..469defdb85 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -46,6 +46,14 @@ Type *Type::getScalarType() { return this; } +/// getNumElements - If this is a vector type, return the number of elements, +/// otherwise return zero. +unsigned Type::getNumElements() { + if (VectorType *VTy = dyn_cast(this)) + return VTy->getNumElements(); + return 0; +} + /// isIntegerTy - Return true if this is an IntegerType of the specified width. bool Type::isIntegerTy(unsigned Bitwidth) const { return isIntegerTy() && cast(this)->getBitWidth() == Bitwidth; @@ -664,6 +672,8 @@ VectorType *VectorType::get(Type *elementType, unsigned NumElements) { } bool VectorType::isValidElementType(Type *ElemTy) { + if (PointerType *PTy = dyn_cast(ElemTy)) + ElemTy = PTy->getElementType(); return ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy(); } -- cgit v1.2.3