aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Type.h3
-rw-r--r--lib/VMCore/Type.cpp5
2 files changed, 8 insertions, 0 deletions
diff --git a/include/llvm/Type.h b/include/llvm/Type.h
index e5169824f8..2c37a6890e 100644
--- a/include/llvm/Type.h
+++ b/include/llvm/Type.h
@@ -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.
///
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index 77ede893b1..20945be79d 100644
--- a/lib/VMCore/Type.cpp
+++ b/lib/VMCore/Type.cpp
@@ -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.
///