aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-11 07:51:25 +0000
committerChris Lattner <sabre@nondot.org>2009-10-11 07:51:25 +0000
commit0c7a6448809f6dc46ba73d35edfe8710c9758f64 (patch)
tree1c9c290af5afee2d16291af37d55ed94d4699088 /include
parented90ae261ab94579121d50605807e8b9ad5e9b00 (diff)
downloadexternal_llvm-0c7a6448809f6dc46ba73d35edfe8710c9758f64.zip
external_llvm-0c7a6448809f6dc46ba73d35edfe8710c9758f64.tar.gz
external_llvm-0c7a6448809f6dc46ba73d35edfe8710c9758f64.tar.bz2
add a helper for matching "1".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83760 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Support/PatternMatch.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index eb393ac..c0b6a6b 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -87,6 +87,18 @@ struct zero_ty {
/// m_Zero() - Match an arbitrary zero/null constant.
inline zero_ty m_Zero() { return zero_ty(); }
+struct one_ty {
+ template<typename ITy>
+ bool match(ITy *V) {
+ if (const ConstantInt *C = dyn_cast<ConstantInt>(V))
+ return C->isOne();
+ return false;
+ }
+};
+
+/// m_One() - Match a an integer 1.
+inline one_ty m_One() { return one_ty(); }
+
template<typename Class>
struct bind_ty {