aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-10-26 18:22:45 +0000
committerChris Lattner <sabre@nondot.org>2006-10-26 18:22:45 +0000
commit2e1c1964706c5202305f6a7086865ff3559920df (patch)
tree5f8d2e5fe8af7ab90027ed22daa0d01f0f1767f8
parent7ae68ab3bccb6ef2d0e4c489f0648dc5d37ae362 (diff)
Add isFPOrFPVector() method, which indicates if a type is either FP or a
vector of FP types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31198 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Type.h4
-rw-r--r--lib/VMCore/Type.cpp10
2 files changed, 14 insertions, 0 deletions
diff --git a/include/llvm/Type.h b/include/llvm/Type.h
index 37532ac04c..dab6c127cd 100644
--- a/include/llvm/Type.h
+++ b/include/llvm/Type.h
@@ -185,6 +185,10 @@ public:
/// types
bool isFloatingPoint() const { return ID == FloatTyID || ID == DoubleTyID; }
+ /// isFPOrFPVector - Return true if this is a FP type or a vector of FP types.
+ ///
+ bool isFPOrFPVector() const;
+
/// isAbstract - True if the type is either an Opaque type, or is a derived
/// type that includes an opaque type somewhere in it.
///
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index fb8cf033e0..7ccf35a973 100644
--- a/lib/VMCore/Type.cpp
+++ b/lib/VMCore/Type.cpp
@@ -90,6 +90,16 @@ const Type *Type::getPrimitiveType(TypeID IDNumber) {
}
}
+/// isFPOrFPVector - Return true if this is a FP type or a vector of FP types.
+///
+bool Type::isFPOrFPVector() const {
+ if (ID == Type::FloatTyID || ID == Type::DoubleTyID) return true;
+ if (ID != Type::PackedTyID) return false;
+
+ return cast<PackedType>(this)->getElementType()->isFloatingPoint();
+}
+
+
// isLosslesslyConvertibleTo - Return true if this type can be converted to
// 'Ty' without any reinterpretation of bits. For example, uint to int.
//