aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Support/PatternMatch.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-20 04:47:44 +0000
committerChris Lattner <sabre@nondot.org>2007-12-20 04:47:44 +0000
commit46f1a8797cfc9ff2a64438060deaed5e8f1f9a6b (patch)
tree899d5ca06a55ec8ba7ddd44718acbd1127c706bd /include/llvm/Support/PatternMatch.h
parente3c1cfb181ff7f2cbb324d5cc02e013a45bd7faf (diff)
Add m_Zero().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45255 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/PatternMatch.h')
-rw-r--r--include/llvm/Support/PatternMatch.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index 6b295d6482..e046b29122 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -46,9 +46,24 @@ struct leaf_ty {
bool match(ITy *V) { return isa<Class>(V); }
};
+/// m_Value() - Match an arbitrary value and ignore it.
inline leaf_ty<Value> m_Value() { return leaf_ty<Value>(); }
+/// m_ConstantInt() - Match an arbitrary ConstantInt and ignore it.
inline leaf_ty<ConstantInt> m_ConstantInt() { return leaf_ty<ConstantInt>(); }
+struct zero_ty {
+ template<typename ITy>
+ bool match(ITy *V) {
+ if (const Constant *C = dyn_cast<Constant>(V))
+ return C->isNullValue();
+ return false;
+ }
+};
+
+/// m_Zero() - Match an arbitrary zero/null constant.
+inline zero_ty m_Zero() { return zero_ty(); }
+
+
template<typename Class>
struct bind_ty {
Class *&VR;
@@ -64,7 +79,10 @@ struct bind_ty {
}
};
+/// m_Value - Match a value, capturing it if we match.
inline bind_ty<Value> m_Value(Value *&V) { return V; }
+
+/// m_ConstantInt - Match a ConstantInt, capturing the value if we match.
inline bind_ty<ConstantInt> m_ConstantInt(ConstantInt *&CI) { return CI; }
//===----------------------------------------------------------------------===//