Author: lattner Date: Wed Dec 19 22:47:44 2007 New Revision: 45255 URL: http://llvm.org/viewvc/llvm-project?rev=45255&view=rev Log: Add m_Zero().
Modified: llvm/trunk/include/llvm/Support/PatternMatch.h Modified: llvm/trunk/include/llvm/Support/PatternMatch.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PatternMatch.h?rev=45255&r1=45254&r2=45255&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/PatternMatch.h (original) +++ llvm/trunk/include/llvm/Support/PatternMatch.h Wed Dec 19 22:47:44 2007 @@ -46,9 +46,24 @@ 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 @@ } }; +/// 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; } //===----------------------------------------------------------------------===// _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits