[llvm-commits] [llvm] r45744 - /llvm/trunk/include/llvm/Support/PatternMatch.h

Chris Lattner sabre at nondot.org
Mon Jan 7 23:02:45 PST 2008


Author: lattner
Date: Tue Jan  8 01:02:44 2008
New Revision: 45744

URL: http://llvm.org/viewvc/llvm-project?rev=45744&view=rev
Log:
add match support for casts.

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=45744&r1=45743&r2=45744&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/PatternMatch.h (original)
+++ llvm/trunk/include/llvm/Support/PatternMatch.h Tue Jan  8 01:02:44 2008
@@ -322,6 +322,30 @@
 }
 
 //===----------------------------------------------------------------------===//
+// Matchers for CastInst classes
+//
+
+template<typename Op_t, typename Class>
+struct CastClass_match {
+  Op_t Op;
+  
+  CastClass_match(const Op_t &OpMatch) : Op(OpMatch) {}
+  
+  template<typename OpTy>
+  bool match(OpTy *V) {
+    if (Class *I = dyn_cast<Class>(V))
+      return Op.match(I->getOperand(0));
+    return false;
+  }
+};
+
+template<typename Class, typename OpTy>
+inline CastClass_match<OpTy, Class> m_Cast(const OpTy &Op) {
+  return CastClass_match<OpTy, Class>(Op);
+}
+
+  
+//===----------------------------------------------------------------------===//
 // Matchers for unary operators
 //
 





More information about the llvm-commits mailing list