Add a new predicate for integer type equality tests.
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 5 Jan 2010 20:04:48 +0000 (20:04 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 5 Jan 2010 20:04:48 +0000 (20:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92759 91177308-0d34-0410-b5e6-96231b3b80d8

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

index e5169824f805500d6eb44923c301ef4dcb5e829d..2c37a6890e903d08d45d4abea787cb659a3ff6b3 100644 (file)
@@ -217,6 +217,9 @@ public:
   ///
   bool isInteger() const { return ID == IntegerTyID; } 
 
+  /// isInteger - Return true if this is an IntegerType of the specified width.
+  bool isInteger(unsigned Bitwidth) const;
+
   /// isIntOrIntVector - Return true if this is an integer type or a vector of
   /// integer types.
   ///
index 77ede893b1be77ee4da84b0bcf4627a507476c88..20945be79dfb9396568c3d29f6e4b631aec5f265 100644 (file)
@@ -124,6 +124,11 @@ const Type *Type::getScalarType() const {
   return this;
 }
 
+/// isInteger - Return true if this is an IntegerType of the specified width.
+bool Type::isInteger(unsigned Bitwidth) const {
+  return isInteger() && cast<IntegerType>(this)->getBitWidth() == Bitwidth;
+}
+
 /// isIntOrIntVector - Return true if this is an integer type or a vector of
 /// integer types.
 ///