/// Entry point for matching a pattern over an SSAValue.
template <typename Pattern>
-inline bool match(SSAValue *value, const Pattern &pattern) {
+inline bool matchPattern(SSAValue *value, const Pattern &pattern) {
// TODO: handle other cases
if (auto *op = value->getDefiningOperation())
return const_cast<Pattern &>(pattern).match(op);
return detail::constant_int_value_matcher<1>();
}
+/// Matches the given OpClass.
+template <typename OpClass> inline detail::op_matcher<OpClass> m_Op() {
+ return detail::op_matcher<OpClass>();
+}
+
/// Matches a constant scalar / vector splat / tensor splat integer zero.
inline detail::constant_int_value_matcher<0> m_Zero() {
return detail::constant_int_value_matcher<0>();
//===----------------------------------------------------------------------===//
namespace {
-/// Matches a MemRefCastOp.
-inline detail::op_matcher<MemRefCastOp> m_MemRefCast() {
- return detail::op_matcher<MemRefCastOp>();
-}
-
/// This is a common class used for patterns of the form
/// "someop(memrefcast) -> someop". It folds the source of any memref_cast
/// into the root operation directly.
std::pair<PatternBenefit, std::unique_ptr<PatternState>>
match(Operation *op) const override {
for (auto *operand : op->getOperands())
- if (::match(operand, m_MemRefCast()))
+ if (matchPattern(operand, m_Op<MemRefCastOp>()))
return matchSuccess();
return matchFailure();
match(Operation *op) const override {
auto addi = op->cast<AddIOp>();
- if (::match(addi->getOperand(1), m_Zero()))
+ if (matchPattern(addi->getOperand(1), m_Zero()))
return matchSuccess();
return matchFailure();
// Check to see if any dimensions operands are constants. If so, we can
// substitute and drop them.
for (auto *operand : alloc->getOperands())
- if (::match(operand, m_ConstantIndex()))
+ if (matchPattern(operand, m_ConstantIndex()))
return matchSuccess();
return matchFailure();
}
match(Operation *op) const override {
auto muli = op->cast<MulIOp>();
- if (::match(muli->getOperand(1), m_One()))
+ if (matchPattern(muli->getOperand(1), m_One()))
return matchSuccess();
return matchFailure();