From ef1af7d6d5be039e7eea46f8f3a2720fb5a1a153 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 20 Aug 2007 19:25:59 +0000 Subject: [PATCH] Add Type::isIntOrIntVector, like Type::isFPOrFPVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41190 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Type.h | 5 +++++ lib/VMCore/Type.cpp | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/llvm/Type.h b/include/llvm/Type.h index bd264a0ea0f..72e70b44a95 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -180,6 +180,11 @@ public: /// bool isInteger() const { return ID == IntegerTyID; } + /// isIntOrIntVector - Return true if this is an integer type or a vector of + /// integer types. + /// + bool isIntOrIntVector() const; + /// isFloatingPoint - Return true if this is one of the two floating point /// types bool isFloatingPoint() const { return ID == FloatTyID || ID == DoubleTyID || diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 3f8643e7e6d..3e085f4027f 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -126,6 +126,17 @@ const Type *Type::getVAArgsPromotedType() const { return this; } +/// isIntOrIntVector - Return true if this is an integer type or a vector of +/// integer types. +/// +bool Type::isIntOrIntVector() const { + if (isInteger()) + return true; + if (ID != Type::VectorTyID) return false; + + return cast(this)->getElementType()->isInteger(); +} + /// isFPOrFPVector - Return true if this is a FP type or a vector of FP types. /// bool Type::isFPOrFPVector() const {