summaryrefslogtreecommitdiff
path: root/lib/VMCore/Type.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nadav.rotem@intel.com>2011-12-05 06:29:09 +0000
committerNadav Rotem <nadav.rotem@intel.com>2011-12-05 06:29:09 +0000
commit1608769abeb1430dc34f31ffac0d9850f99ae36a (patch)
tree7834f9a415e0348f155f2834c40171c3b13d60ed /lib/VMCore/Type.cpp
parent8e1b12ae68cd6ae5180cb300a05bae5ddf0c49ae (diff)
downloadllvm-1608769abeb1430dc34f31ffac0d9850f99ae36a.tar.gz
llvm-1608769abeb1430dc34f31ffac0d9850f99ae36a.tar.bz2
llvm-1608769abeb1430dc34f31ffac0d9850f99ae36a.tar.xz
Add support for vectors of pointers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145801 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Type.cpp')
-rw-r--r--lib/VMCore/Type.cpp10
1 files changed, 10 insertions, 0 deletions
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<VectorType>(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<IntegerType>(this)->getBitWidth() == Bitwidth;
@@ -664,6 +672,8 @@ VectorType *VectorType::get(Type *elementType, unsigned NumElements) {
}
bool VectorType::isValidElementType(Type *ElemTy) {
+ if (PointerType *PTy = dyn_cast<PointerType>(ElemTy))
+ ElemTy = PTy->getElementType();
return ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy();
}