From 76aa677ec348ce6e88a5af977b135a05799419d4 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 5 Jan 2010 20:04:48 +0000 Subject: [PATCH] Add a new predicate for integer type equality tests. llvm-svn: 92759 --- llvm/include/llvm/Type.h | 3 +++ llvm/lib/VMCore/Type.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/llvm/include/llvm/Type.h b/llvm/include/llvm/Type.h index e5169824f805..2c37a6890e90 100644 --- a/llvm/include/llvm/Type.h +++ b/llvm/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/llvm/lib/VMCore/Type.cpp b/llvm/lib/VMCore/Type.cpp index 77ede893b1be..20945be79dfb 100644 --- a/llvm/lib/VMCore/Type.cpp +++ b/llvm/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(this)->getBitWidth() == Bitwidth; +} + /// isIntOrIntVector - Return true if this is an integer type or a vector of /// integer types. ///