15#include <mlir/IR/Matchers.h>
16#include <mlir/IR/Operation.h>
17#include <mlir/IR/Value.h>
24template <
typename LhsMatcher,
typename RhsMatcher,
typename... OpTypes>
struct CommutativeMatcher {
28 bool match(mlir::Operation *op) {
29 using namespace mlir::detail;
30 if (!isa<OpTypes...>(op) || op->getNumOperands() != 2) {
33 bool res = matchOperandOrValueAtIndex(op, 0,
lhsMatcher) &&
36 res = matchOperandOrValueAtIndex(op, 1,
lhsMatcher) &&
46template <
typename OpType,
typename LhsMatcher,
typename RhsMatcher>
58 if (isa<mlir::BlockArgument>(v) ||
59 isa_and_present<component::MemberReadOp>(v.getDefiningOp())) {
79 if (
auto match = dyn_cast_if_present<felt::FeltConstantOp>(v.getDefiningOp())) {
RefValueCapture m_RefValue()
ConstantCapture m_Constant()
auto m_CommutativeOp(LhsMatcher lhs, RhsMatcher rhs)
This matcher will either match on lhs op rhs or rhs op lhs.
bool match(mlir::Operation *op)
CommutativeMatcher(LhsMatcher lhs, RhsMatcher rhs)
Matches and optionally captures a felt constant.
felt::FeltConstantOp * what
bool match(mlir::Value v)
ConstantCapture(felt::FeltConstantOp *capture)
Matches and optionally captures a SourceRef base value, which is either a member read or a block argu...
RefValueCapture(mlir::Value *capture)
bool match(mlir::Value v)