PatternMatch: Introduce a matcher for instructions with the "exact" bit. Use it to simplify a few matchers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147403 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer
2012-01-01 17:55:30 +00:00
parent 395363a9b9
commit 55c6d57734
3 changed files with 30 additions and 19 deletions
+20
View File
@@ -441,6 +441,26 @@ m_IDiv(const LHS &L, const RHS &R) {
return BinOp2_match<LHS, RHS, Instruction::SDiv, Instruction::UDiv>(L, R);
}
//===----------------------------------------------------------------------===//
// Class that matches exact binary ops.
//
template<typename SubPattern_t>
struct Exact_match {
SubPattern_t SubPattern;
Exact_match(const SubPattern_t &SP) : SubPattern(SP) {}
template<typename OpTy>
bool match(OpTy *V) {
if (PossiblyExactOperator *PEO = dyn_cast<PossiblyExactOperator>(V))
return PEO->isExact() && SubPattern.match(V);
return false;
}
};
template<typename T>
inline Exact_match<T> m_Exact(const T &SubPattern) { return SubPattern; }
//===----------------------------------------------------------------------===//
// Matchers for CmpInst classes
//