diff --git a/llvm/include/llvm/CodeGen/SDPatternMatch.h b/llvm/include/llvm/CodeGen/SDPatternMatch.h index 7970441c83715b..071a27a7950642 100644 --- a/llvm/include/llvm/CodeGen/SDPatternMatch.h +++ b/llvm/include/llvm/CodeGen/SDPatternMatch.h @@ -330,9 +330,7 @@ template struct And { template struct And : And { Pred P; - And(Pred &&p, Preds &&...preds) - : And(std::forward(preds)...), P(std::forward(p)) { - } + And(const Pred &p, const Preds &...preds) : And(preds...), P(p) {} template bool match(const MatchContext &Ctx, SDValue N) { @@ -349,8 +347,7 @@ template struct Or { template struct Or : Or { Pred P; - Or(Pred &&p, Preds &&...preds) - : Or(std::forward(preds)...), P(std::forward(p)) {} + Or(const Pred &p, const Preds &...preds) : Or(preds...), P(p) {} template bool match(const MatchContext &Ctx, SDValue N) { @@ -376,16 +373,16 @@ template inline Not m_Unless(const Pred &P) { return Not{P}; } -template And m_AllOf(Preds &&...preds) { - return And(std::forward(preds)...); +template And m_AllOf(const Preds &...preds) { + return And(preds...); } -template Or m_AnyOf(Preds &&...preds) { - return Or(std::forward(preds)...); +template Or m_AnyOf(const Preds &...preds) { + return Or(preds...); } -template auto m_NoneOf(Preds &&...preds) { - return m_Unless(m_AnyOf(std::forward(preds)...)); +template auto m_NoneOf(const Preds &...preds) { + return m_Unless(m_AnyOf(preds...)); } // === Generic node matching === @@ -402,10 +399,8 @@ struct Operands_match : Operands_match { OpndPred P; - Operands_match(OpndPred &&p, OpndPreds &&...preds) - : Operands_match( - std::forward(preds)...), - P(std::forward(p)) {} + Operands_match(const OpndPred &p, const OpndPreds &...preds) + : Operands_match(preds...), P(p) {} template bool match(const MatchContext &Ctx, SDValue N) { @@ -419,9 +414,8 @@ struct Operands_match }; template -auto m_Node(unsigned Opcode, OpndPreds &&...preds) { - return m_AllOf(m_Opc(Opcode), Operands_match<0, OpndPreds...>( - std::forward(preds)...)); +auto m_Node(unsigned Opcode, const OpndPreds &...preds) { + return m_AllOf(m_Opc(Opcode), Operands_match<0, OpndPreds...>(preds...)); } /// Provide number of operands that are not chain or glue, as well as the first @@ -647,10 +641,9 @@ template inline UnaryOpc_match m_ZExt(const Opnd &Op) { return UnaryOpc_match(ISD::ZERO_EXTEND, Op); } -template inline auto m_SExt(Opnd &&Op) { - return m_AnyOf( - UnaryOpc_match(ISD::SIGN_EXTEND, Op), - m_Node(ISD::SIGN_EXTEND_INREG, std::forward(Op), m_Value())); +template inline auto m_SExt(const Opnd &Op) { + return m_AnyOf(UnaryOpc_match(ISD::SIGN_EXTEND, Op), + m_Node(ISD::SIGN_EXTEND_INREG, Op, m_Value())); } template inline UnaryOpc_match m_AnyExt(const Opnd &Op) { @@ -663,30 +656,28 @@ template inline UnaryOpc_match m_Trunc(const Opnd &Op) { /// Match a zext or identity /// Allows to peek through optional extensions -template inline auto m_ZExtOrSelf(Opnd &&Op) { - return m_AnyOf(m_ZExt(std::forward(Op)), std::forward(Op)); +template inline auto m_ZExtOrSelf(const Opnd &Op) { + return m_AnyOf(m_ZExt(Op), Op); } /// Match a sext or identity /// Allows to peek through optional extensions -template inline auto m_SExtOrSelf(Opnd &&Op) { - return m_AnyOf(m_SExt(std::forward(Op)), std::forward(Op)); +template inline auto m_SExtOrSelf(const Opnd &Op) { + return m_AnyOf(m_SExt(Op), Op); } /// Match a aext or identity /// Allows to peek through optional extensions template -inline Or, Opnd> m_AExtOrSelf(Opnd &&Op) { - return Or, Opnd>(m_AnyExt(std::forward(Op)), - std::forward(Op)); +inline Or, Opnd> m_AExtOrSelf(const Opnd &Op) { + return Or, Opnd>(m_AnyExt(Op), Op); } /// Match a trunc or identity /// Allows to peek through optional truncations template -inline Or, Opnd> m_TruncOrSelf(Opnd &&Op) { - return Or, Opnd>(m_Trunc(std::forward(Op)), - std::forward(Op)); +inline Or, Opnd> m_TruncOrSelf(const Opnd &Op) { + return Or, Opnd>(m_Trunc(Op), Op); } // === Constants ===