add a helper for matching "1".
authorChris Lattner <sabre@nondot.org>
Sun, 11 Oct 2009 07:51:25 +0000 (07:51 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 11 Oct 2009 07:51:25 +0000 (07:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83760 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/PatternMatch.h

index eb393ac4c3eba638fd18cecfb2ca657cefcec783..c0b6a6b98c09d32236d1b6266cea22949526d246 100644 (file)
@@ -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 {