[llvm] [DAG] Added m_AnyBinOp and m_c_AnyBinOp in SDPatternMatch.h (PR #86435)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 25 09:50:11 PDT 2024
================
@@ -457,6 +457,53 @@ struct BinaryOpc_match {
}
};
+template <typename LHS_t, typename RHS_t, typename PredFuncT>
+struct AnyBinaryOp_match {
+ LHS_t L;
+ RHS_t R;
+ PredFuncT PredFunc;
+ bool Commutable;
+
+ AnyBinaryOp_match(const PredFuncT &Pred, const LHS_t &LHS, const RHS_t &RHS,
+ const bool Commutable)
+ : PredFunc(Pred), L(LHS), R(RHS), Commutable(Commutable) {}
+
+ template <typename OpTy, typename MatchContext>
+ bool match(OpTy *V, const MatchContext &Ctx) {
+ assert(Ctx.getTLI() && "TargetLowering is required for this pattern");
+ if (auto *I = dyn_cast<BinaryOperator>(V))
----------------
mshockwave wrote:
I'm afraid several things are off here: first, BinaryOperator is for LLVM IR, yet we're dealing with SelectionDAG here; second, the `match` function has to conform to a certain function signature, in our SDPatternMatch, it has to be `bool match(MatchContext, SDValue)` where MatchContext can be arbitrary type, hence a template type. The `match` function here doesn't match such signature.
https://github.com/llvm/llvm-project/pull/86435
More information about the llvm-commits
mailing list