Add isFPOrFPVector() method, which indicates if a type is either FP or a
authorChris Lattner <sabre@nondot.org>
Thu, 26 Oct 2006 18:22:45 +0000 (18:22 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 26 Oct 2006 18:22:45 +0000 (18:22 +0000)
vector of FP types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31198 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Type.h
lib/VMCore/Type.cpp

index 37532ac04c6c29553af14665f72bba879d8c638d..dab6c127cd1694e08888d82266048f67ec48a8cf 100644 (file)
@@ -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.
   ///
index fb8cf033e08077e0e524fe1cb8226782d7d44ba5..7ccf35a9736cf1f704d817dea60de7324737e2f9 100644 (file)
@@ -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.
 //