13#ifndef LLVM_CODEGEN_SDPATTERNMATCH_H
14#define LLVM_CODEGEN_SDPATTERNMATCH_H
37 : DAG(DAG), TLI(DAG ? &DAG->getTargetLoweringInfo() : nullptr) {}
40 : DAG(nullptr), TLI(TLI) {}
50 return N->getOpcode() == Opcode;
56template <
typename Pattern,
typename MatchContext>
59 return P.match(Ctx,
N);
62template <
typename Pattern,
typename MatchContext>
68template <
typename Pattern>
73template <
typename Pattern>
78template <
typename Pattern>
83template <
typename Pattern>
96 template <
typename MatchContext>
bool match(
const MatchContext &,
SDValue N) {
116 template <
typename MatchContext>
118 return N.getResNo() == ResNo &&
P.match(Ctx,
N);
123template <
unsigned ResNo,
typename Pattern>
133 template <
typename MatchContext>
bool match(
const MatchContext &,
SDValue N) {
152 template <
typename MatchContext>
159template <
typename... Preds>
struct And {
160 template <
typename MatchContext>
bool match(
const MatchContext &,
SDValue N) {
165template <
typename Pred,
typename... Preds>
166struct And<Pred, Preds...> :
And<Preds...> {
168 And(
const Pred &p,
const Preds &...preds) :
And<Preds...>(preds...),
P(p) {}
170 template <
typename MatchContext>
176template <
typename... Preds>
struct Or {
177 template <
typename MatchContext>
bool match(
const MatchContext &,
SDValue N) {
182template <
typename Pred,
typename... Preds>
183struct Or<Pred, Preds...> :
Or<Preds...> {
185 Or(
const Pred &p,
const Preds &...preds) :
Or<Preds...>(preds...),
P(p) {}
187 template <
typename MatchContext>
193template <
typename Pred>
struct Not {
198 template <
typename MatchContext>
200 return !
P.match(Ctx,
N);
211template <
typename... Preds>
And<Preds...>
m_AllOf(
const Preds &...preds) {
212 return And<Preds...>(preds...);
215template <
typename... Preds>
Or<Preds...>
m_AnyOf(
const Preds &...preds) {
216 return Or<Preds...>(preds...);
219template <
typename... Preds>
auto m_NoneOf(
const Preds &...preds) {
234 template <
typename MatchContext>
239 return P.match(Ctx,
N) &&
N->hasNUsesOfValue(NumUses,
N.getResNo());
243template <
typename Pattern>
247template <
unsigned N,
typename Pattern>
264 template <
typename MatchContext>
bool match(
const MatchContext &,
SDValue N) {
279 template <
typename MatchContext>
281 assert(Ctx.getTLI() &&
"TargetLowering is required for this pattern.");
282 return PredFunc(*Ctx.getTLI(),
N) &&
P.match(Ctx,
N);
287template <
typename PredFuncT,
typename Pattern>
302 const NewMatchContext &
Ctx;
305 template <
typename OrigMatchContext>
307 return P.match(
Ctx,
N);
311template <
typename MatchContext,
typename Pattern>
323 template <
typename MatchContext>
bool match(
const MatchContext &,
SDValue N) {
339 template <
typename MatchContext>
341 return PredFunc(
N.getValueType()) &&
P.match(Ctx,
N);
346template <
typename PredFuncT,
typename Pattern>
351template <
typename Pattern>
363template <
typename Pattern>
374template <
typename Pattern>
377 return VT.isVector() &&
378 VT.getVectorElementType() == RefVT;
384 return VT.isVector() &&
385 VT.getVectorElementType() == RefVT;
443 template <
typename MatchContext>
447 return Ctx.getNumOperands(
N) ==
OpIdx;
451template <
unsigned OpIdx,
typename OpndPred,
typename... OpndPreds>
459 template <
typename MatchContext>
462 return P.match(Ctx,
N->getOperand(
OpIdx)) &&
470template <
typename... OpndPreds>
471auto m_Node(
unsigned Opcode,
const OpndPreds &...preds) {
481 template <
typename MatchContext>
483 const unsigned TotalNumOps = Ctx.getNumOperands(
N);
485 for (
unsigned I = 0;
I < TotalNumOps; ++
I) {
488 EVT VT =
N->getOperand(
I).getValueType();
489 if (VT != MVT::Glue && VT != MVT::Other) {
502 template <
typename MatchContext>
504 :
Size(Ctx.getNumOperands(
N)) {}
508template <
typename T0_P,
typename T1_P,
typename T2_P,
bool Commutable =
false,
509 bool ExcludeChain =
false>
520 template <
typename MatchContext>
527 (Commutable &&
Op0.match(Ctx,
N->getOperand(EO.
FirstIndex + 1)) &&
536template <
typename T0_P,
typename T1_P,
typename T2_P>
537inline TernaryOpc_match<T0_P, T1_P, T2_P>
542template <
typename T0_P,
typename T1_P,
typename T2_P>
543inline TernaryOpc_match<T0_P, T1_P, T2_P, true, false>
549template <
typename T0_P,
typename T1_P,
typename T2_P>
550inline TernaryOpc_match<T0_P, T1_P, T2_P>
555template <
typename T0_P,
typename T1_P,
typename T2_P>
556inline TernaryOpc_match<T0_P, T1_P, T2_P>
561template <
typename T0_P,
typename T1_P,
typename T2_P>
566template <
typename T0_P,
typename T1_P,
typename T2_P>
567inline Result_match<0, TernaryOpc_match<T0_P, T1_P, T2_P>>
573template <
typename T0_P,
typename T1_P,
typename T2_P>
574inline TernaryOpc_match<T0_P, T1_P, T2_P>
580template <
typename LHS,
typename RHS,
typename IDX>
581inline TernaryOpc_match<LHS, RHS, IDX>
586template <
typename T0_P,
typename T1_P,
typename T2_P>
587inline TernaryOpc_match<T0_P, T1_P, T2_P>
592template <
typename T0_P,
typename T1_P,
typename T2_P>
593inline TernaryOpc_match<T0_P, T1_P, T2_P, true>
598template <
typename LTy,
typename RTy,
typename TTy,
typename FTy,
typename CCTy>
599inline auto m_SelectCC(
const LTy &L,
const RTy &R,
const TTy &
T,
const FTy &
F,
604template <
typename LTy,
typename RTy,
typename TTy,
typename FTy,
typename CCTy>
606 const FTy &
F,
const CCTy &CC) {
611template <
typename LHS_P,
typename RHS_P,
bool Commutable =
false,
612 bool ExcludeChain =
false>
622 template <
typename MatchContext>
629 (Commutable &&
LHS.match(Ctx,
N->getOperand(EO.
FirstIndex + 1)) &&
649 template <
typename MatchContext>
652 return Op1.match(Ctx,
I->getOperand(0)) &&
653 Op2.match(Ctx,
I->getOperand(1)) &&
Mask.match(
I->getMask());
673template <
typename LHS_P,
typename RHS_P,
typename Pred_t,
674 bool Commutable =
false,
bool ExcludeChain =
false>
682 template <
typename MatchContext>
686 if ((TrueValue != L || FalseValue != R) &&
687 (TrueValue != R || FalseValue != L))
691 TrueValue == L ? CC : getSetCCInverse(CC, L.getValueType());
692 if (!Pred_t::match(
Cond))
695 return (
LHS.match(Ctx, L) &&
RHS.match(Ctx, R)) ||
696 (Commutable &&
LHS.match(Ctx, R) &&
RHS.match(Ctx, L));
714 return MatchMinMax(L, R, TrueValue, FalseValue, CondNode->get());
727 return MatchMinMax(L, R, TrueValue, FalseValue, CondNode->get());
762template <
typename LHS,
typename RHS>
767template <
typename LHS,
typename RHS>
773template <
typename LHS,
typename RHS>
778template <
typename LHS,
typename RHS>
785template <
typename LHS,
typename RHS>
790template <
typename LHS,
typename RHS>
795template <
typename LHS,
typename RHS>
800template <
typename LHS,
typename RHS>
805template <
typename LHS,
typename RHS>
810template <
typename LHS,
typename RHS>
816template <
typename LHS,
typename RHS>
821template <
typename LHS,
typename RHS>
826template <
typename LHS,
typename RHS>
831template <
typename LHS,
typename RHS>
836template <
typename LHS,
typename RHS>
842template <
typename LHS,
typename RHS>
847template <
typename LHS,
typename RHS>
853template <
typename LHS,
typename RHS>
858template <
typename LHS,
typename RHS>
864template <
typename LHS,
typename RHS>
869template <
typename LHS,
typename RHS>
875template <
typename LHS,
typename RHS>
879template <
typename LHS,
typename RHS>
884template <
typename LHS,
typename RHS>
888template <
typename LHS,
typename RHS>
893template <
typename LHS,
typename RHS>
898template <
typename LHS,
typename RHS>
902template <
typename LHS,
typename RHS>
906template <
typename LHS,
typename RHS>
912template <
typename LHS,
typename RHS>
917template <
typename LHS,
typename RHS>
922template <
typename LHS,
typename RHS>
927template <
typename LHS,
typename RHS>
932template <
typename LHS,
typename RHS>
937template <
typename LHS,
typename RHS>
942template <
typename LHS,
typename RHS>
947template <
typename V1_t,
typename V2_t>
952template <
typename V1_t,
typename V2_t,
typename Mask_t>
953inline SDShuffle_match<V1_t, V2_t, Mask_t>
958template <
typename LHS,
typename RHS>
963template <
typename LHS,
typename RHS>
975 std::optional<SDNodeFlags> Flgs = std::nullopt)
978 template <
typename MatchContext>
985 if (!
Flags.has_value())
995template <
typename Opnd>
999template <
typename Opnd>
1009template <
typename Opnd>
1014template <
typename Opnd>
1023template <
typename Opnd>
1028template <
typename Opnd>
inline auto m_SExt(
const Opnd &
Op) {
1062template <
typename Opnd>
1069template <
typename Opnd>
1135 template <
typename MatchContext>
1157 template <
typename MatchContext>
1202 return ConstVal.
isOne();
1206 return (ConstVal & 0x01) == 1;
1223 return ConstVal.
isZero();
1225 return (ConstVal & 0x01) == 0;
1267template <
typename ValTy>
1273template <
typename ValTy>
1285 template <
typename MatchContext>
1287 constexpr size_t NumPatterns = std::tuple_size_v<std::tuple<PatternTs...>>;
1291 if (Leaves.
size() != NumPatterns)
1296 std::array<SmallBitVector, NumPatterns> Matches;
1297 for (
size_t I = 0;
I != NumPatterns;
I++) {
1310 if (V->getOpcode() ==
Opcode) {
1311 for (
size_t I = 0,
N = V->getNumOperands();
I <
N;
I++)
1318 [[nodiscard]]
inline bool
1321 if (Curr == Matches.
size())
1323 for (
size_t Match = 0,
N = Matches[Curr].
size(); Match <
N; Match++) {
1324 if (!Matches[Curr][Match] || Used[Match])
1329 Used[Match] =
false;
1335template <
typename... PatternTs>
1336inline ReassociatableOpc_match<PatternTs...>
1341template <
typename... PatternTs>
1342inline ReassociatableOpc_match<PatternTs...>
1347template <
typename... PatternTs>
1348inline ReassociatableOpc_match<PatternTs...>
1353template <
typename... PatternTs>
1354inline ReassociatableOpc_match<PatternTs...>
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
static constexpr unsigned long long mask(BlockVerifier::State S)
MachineInstr unsigned OpIdx
const SmallVectorImpl< MachineOperand > & Cond
This file implements the SmallBitVector class.
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
bool isAllOnes() const
Determine if all bits are set. This is true for zero-width values.
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
static bool isSameValue(const APInt &I1, const APInt &I2)
Determine if two APInts have the same value, after zero-extending one of them (if needed!...
bool isOne() const
Determine if this is a value of 1.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
Represents one node in the SelectionDAG.
MatchContext can repurpose existing patterns to behave differently under a certain context.
const TargetLowering * getTLI() const
const SelectionDAG * getDAG() const
BasicMatchContext(const TargetLowering *TLI)
BasicMatchContext(const SelectionDAG *DAG)
bool match(SDValue N, unsigned Opcode) const
Return true if N effectively has opcode Opcode.
unsigned getNumOperands(SDValue N) const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
reference emplace_back(ArgTypes &&... Args)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
BooleanContent getBooleanContents(bool isVec, bool isFloat) const
For targets without i1 registers, this gives the nature of the high-bits of boolean values held in ty...
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
@ ZeroOrOneBooleanContent
@ UndefinedBooleanContent
@ ZeroOrNegativeOneBooleanContent
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
@ C
The default llvm calling convention, compatible with C.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ POISON
POISON - A poison node.
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
@ BSWAP
Byte Swap and Counting operators.
@ ADD
Simple integer binary arithmetic operators.
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ FADD
Simple binary floating point operators.
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SIGN_EXTEND
Conversion operators.
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ UNDEF
UNDEF - An undefined node.
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
LLVM_ABI bool isConstantSplatVector(const SDNode *N, APInt &SplatValue)
Node predicates.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
cst_pred_ty< is_all_ones > m_AllOnes()
Match an integer or vector with all bits set.
class_match< BinaryOperator > m_BinOp()
Match an arbitrary binary operation and ignore it.
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
IntrinsicID_match m_VScale()
Matches a call to llvm.vscale().
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
BinaryOpc_match< Zero_match, ValTy, false > m_Neg(const ValTy &V)
Match a negate as a sub(0, v)
Result_match< 0, TernaryOpc_match< T0_P, T1_P, T2_P > > m_Load(const T0_P &Ch, const T1_P &Ptr, const T2_P &Offset)
ReassociatableOpc_match< PatternTs... > m_ReassociatableMul(const PatternTs &...Patterns)
Opcode_match m_Opc(unsigned Opcode)
auto m_SelectCCLike(const LTy &L, const RTy &R, const TTy &T, const FTy &F, const CCTy &CC)
auto m_ExactSr(const LHS &L, const RHS &R)
BinaryOpc_match< LHS, RHS > m_Srl(const LHS &L, const RHS &R)
auto m_SExtLike(const Opnd &Op)
auto m_SpecificVT(EVT RefVT, const Pattern &P)
Match a specific ValueType.
auto m_SelectCC(const LTy &L, const RTy &R, const TTy &T, const FTy &F, const CCTy &CC)
BinaryOpc_match< LHS, RHS > m_Sra(const LHS &L, const RHS &R)
BinaryOpc_match< LHS, RHS > m_FRem(const LHS &L, const RHS &R)
TLI_pred_match(const PredFuncT &Pred, const Pattern &P) -> TLI_pred_match< Pattern, PredFuncT >
Result_match< ResNo, Pattern > m_Result(const Pattern &P)
Match only if the SDValue is a certain result at ResNo.
BinaryOpc_match< LHS, RHS, true > m_Mul(const LHS &L, const RHS &R)
auto m_UMinLike(const LHS &L, const RHS &R)
auto m_SelectLike(const T0_P &Cond, const T1_P &T, const T2_P &F)
TernaryOpc_match< LHS, RHS, IDX > m_InsertSubvector(const LHS &Base, const RHS &Sub, const IDX &Idx)
auto m_UMaxLike(const LHS &L, const RHS &R)
BinaryOpc_match< LHS, RHS, true > m_Or(const LHS &L, const RHS &R)
UnaryOpc_match< Opnd > m_Abs(const Opnd &Op)
TernaryOpc_match< T0_P, T1_P, T2_P > m_TernaryOp(unsigned Opc, const T0_P &Op0, const T1_P &Op1, const T2_P &Op2)
TernaryOpc_match< T0_P, T1_P, T2_P > m_InsertElt(const T0_P &Vec, const T1_P &Val, const T2_P &Idx)
BinaryOpc_match< LHS, RHS, false, true > m_ChainedBinOp(unsigned Opc, const LHS &L, const RHS &R)
BinaryOpc_match< LHS, RHS, true > m_SMin(const LHS &L, const RHS &R)
UnaryOpc_match< Opnd > m_Trunc(const Opnd &Op)
BinaryOpc_match< LHS, RHS > m_FSub(const LHS &L, const RHS &R)
auto m_AddLike(const LHS &L, const RHS &R)
BinaryOpc_match< LHS, RHS > m_URem(const LHS &L, const RHS &R)
UnaryOpc_match< Opnd > m_BSwap(const Opnd &Op)
Or< Preds... > m_AnyOf(const Preds &...preds)
BinaryOpc_match< LHS, RHS, true, true > m_c_ChainedBinOp(unsigned Opc, const LHS &L, const RHS &R)
Or< UnaryOpc_match< Opnd >, Opnd > m_TruncOrSelf(const Opnd &Op)
Match a trunc or identity Allows to peek through optional truncations.
UnaryOpc_match< Opnd > m_NNegZExt(const Opnd &Op)
And< Preds... > m_AllOf(const Preds &...preds)
auto m_ScalableVectorVT()
BinaryOpc_match< LHS, RHS > m_FDiv(const LHS &L, const RHS &R)
auto m_LegalType(const Pattern &P)
Match legal ValueTypes based on the information provided by TargetLowering.
UnaryOpc_match< Opnd > m_BitCast(const Opnd &Op)
UnaryOpc_match< Opnd > m_FNeg(const Opnd &Op)
BinaryOpc_match< LHS, RHS, true > m_UMin(const LHS &L, const RHS &R)
Not< Pred > m_Unless(const Pred &P)
Match if the inner pattern does NOT match.
BinaryOpc_match< LHS, RHS, true > m_SMax(const LHS &L, const RHS &R)
auto m_SpecificScalarVT(EVT RefVT, const Pattern &P)
Match a scalar ValueType.
NUses_match< N, Value_match > m_NUses()
UnaryOpc_match< Opnd, true > m_ChainedUnaryOp(unsigned Opc, const Opnd &Op)
ValueType_match(const PredFuncT &Pred, const Pattern &P) -> ValueType_match< Pattern, PredFuncT >
SpecificInt_match m_SpecificInt(APInt V)
Match a specific integer constant or constant splat value.
UnaryOpc_match< Opnd > m_FPToUI(const Opnd &Op)
Value_match m_Specific(SDValue N)
BinaryOpc_match< LHS, RHS > m_ExtractElt(const LHS &Vec, const RHS &Idx)
BinaryOpc_match< LHS, RHS > m_ExtractSubvector(const LHS &Vec, const RHS &Idx)
UnaryOpc_match< Opnd > m_BitReverse(const Opnd &Op)
BinaryOpc_match< LHS, RHS, true > m_And(const LHS &L, const RHS &R)
ValueType_bind m_VT(EVT &VT)
Retreive the ValueType of the current SDValue.
BinaryOpc_match< LHS, RHS > m_Sub(const LHS &L, const RHS &R)
TernaryOpc_match< T0_P, T1_P, T2_P, true > m_c_TernaryOp(unsigned Opc, const T0_P &Op0, const T1_P &Op1, const T2_P &Op2)
TernaryOpc_match< T0_P, T1_P, T2_P > m_SetCC(const T0_P &LHS, const T1_P &RHS, const T2_P &CC)
BinaryOpc_match< ValTy, AllOnes_match, true > m_Not(const ValTy &V)
Match a Not as a xor(v, -1) or xor(-1, v)
ReassociatableOpc_match< PatternTs... > m_ReassociatableOr(const PatternTs &...Patterns)
BinaryOpc_match< LHS, RHS > m_Rotr(const LHS &L, const RHS &R)
ReassociatableOpc_match< PatternTs... > m_ReassociatableAdd(const PatternTs &...Patterns)
UnaryOpc_match< Opnd > m_AnyExt(const Opnd &Op)
BinaryOpc_match< LHS, RHS > m_Rotl(const LHS &L, const RHS &R)
UnaryOpc_match< Opnd > m_Cttz(const Opnd &Op)
auto m_Node(unsigned Opcode, const OpndPreds &...preds)
BinaryOpc_match< LHS, RHS, true > m_DisjointOr(const LHS &L, const RHS &R)
auto m_SMaxLike(const LHS &L, const RHS &R)
TernaryOpc_match< T0_P, T1_P, T2_P > m_Select(const T0_P &Cond, const T1_P &T, const T2_P &F)
BinaryOpc_match< LHS, RHS > m_UDiv(const LHS &L, const RHS &R)
UnaryOpc_match< Opnd > m_Ctlz(const Opnd &Op)
BinaryOpc_match< LHS, RHS > m_SDiv(const LHS &L, const RHS &R)
SwitchContext< MatchContext, Pattern > m_Context(const MatchContext &Ctx, Pattern &&P)
BinaryOpc_match< LHS, RHS, true > m_FAdd(const LHS &L, const RHS &R)
Or< UnaryOpc_match< Opnd >, Opnd > m_AExtOrSelf(const Opnd &Op)
Match a aext or identity Allows to peek through optional extensions.
BinaryOpc_match< LHS, RHS, true > m_UMax(const LHS &L, const RHS &R)
TernaryOpc_match< T0_P, T1_P, T2_P > m_VSelect(const T0_P &Cond, const T1_P &T, const T2_P &F)
bool sd_match(SDNode *N, const SelectionDAG *DAG, Pattern &&P)
UnaryOpc_match< Opnd > m_UnaryOp(unsigned Opc, const Opnd &Op)
auto m_SExt(const Opnd &Op)
BinaryOpc_match< LHS, RHS, true > m_Xor(const LHS &L, const RHS &R)
auto m_SMinLike(const LHS &L, const RHS &R)
BinaryOpc_match< LHS, RHS > m_SRem(const LHS &L, const RHS &R)
auto m_NoneOf(const Preds &...preds)
CondCode_match m_SpecificCondCode(ISD::CondCode CC)
Match a conditional code SDNode with a specific ISD::CondCode.
UnaryOpc_match< Opnd > m_ZExt(const Opnd &Op)
Value_match m_Value()
Match any valid SDValue.
BinaryOpc_match< LHS, RHS, true > m_Add(const LHS &L, const RHS &R)
auto m_SpecificVectorElementVT(EVT RefVT, const Pattern &P)
Match a vector ValueType.
BinaryOpc_match< LHS, RHS > m_Shl(const LHS &L, const RHS &R)
auto m_LegalOp(const Pattern &P)
Match legal SDNodes based on the information provided by TargetLowering.
auto m_BitwiseLogic(const LHS &L, const RHS &R)
auto m_True()
Match true boolean value based on the information provided by TargetLowering.
UnaryOpc_match< Opnd > m_Ctpop(const Opnd &Op)
ReassociatableOpc_match< PatternTs... > m_ReassociatableAnd(const PatternTs &...Patterns)
UnaryOpc_match< Opnd > m_FPToSI(const Opnd &Op)
NUses_match< 1, Value_match > m_OneUse()
auto m_False()
Match false boolean value based on the information provided by TargetLowering.
auto m_SExtOrSelf(const Opnd &Op)
Match a sext or identity Allows to peek through optional extensions.
CondCode_match m_CondCode()
Match any conditional code SDNode.
BinaryOpc_match< LHS, RHS, true > m_c_BinOp(unsigned Opc, const LHS &L, const RHS &R)
Not(const Pred &P) -> Not< Pred >
DeferredValue_match m_Deferred(SDValue &V)
Similar to m_Specific, but the specific value to match is determined by another sub-pattern in the sa...
TernaryOpc_match< T0_P, T1_P, T2_P, true, false > m_c_SetCC(const T0_P &LHS, const T1_P &RHS, const T2_P &CC)
bool sd_context_match(SDValue N, const MatchContext &Ctx, Pattern &&P)
BinaryOpc_match< LHS, RHS, true > m_FMul(const LHS &L, const RHS &R)
BinaryOpc_match< V1_t, V2_t > m_Shuffle(const V1_t &v1, const V2_t &v2)
ConstantInt_match m_ConstInt()
Match any integer constants or splat of an integer constant.
auto m_ZExtOrSelf(const Opnd &Op)
Match a zext or identity Allows to peek through optional extensions.
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
LLVM_ABI bool isAllOnesOrAllOnesSplat(const MachineInstr &MI, const MachineRegisterInfo &MRI, bool AllowUndefs=false)
Return true if the value is a constant -1 integer or a splatted vector of a constant -1 integer (with...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto dyn_cast_or_null(const Y &Val)
@ Sub
Subtraction of integers.
DWARFExpression::Operation Op
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isZeroOrZeroSplat(SDValue N, bool AllowUndefs=false)
Return true if the value is a constant 0 integer or a splatted vector of a constant 0 integer (with n...
LLVM_ABI bool isOnesOrOnesSplat(SDValue N, bool AllowUndefs=false)
Return true if the value is a constant 1 integer or a splatted vector of a constant 1 integer (with n...
Implement std::hash so that hash_code can be used in STL containers.
These are IR-level optimization flags that may be propagated to SDNodes.
AllOnes_match(bool AllowUndefs)
bool match(const MatchContext &, SDValue N)
And(const Pred &p, const Preds &...preds)
bool match(const MatchContext &Ctx, SDValue N)
bool match(const MatchContext &, SDValue N)
bool match(const MatchContext &Ctx, SDValue N)
BinaryOpc_match(unsigned Opc, const LHS_P &L, const RHS_P &R, SDNodeFlags Flgs=SDNodeFlags())
CondCode_match(ISD::CondCode CC)
bool match(const MatchContext &, SDValue N)
CondCode_match(ISD::CondCode *CC)
std::optional< ISD::CondCode > CCToMatch
ConstantInt_match(APInt *V)
bool match(const MatchContext &, SDValue N)
bool match(const MatchContext &, SDValue N)
DeferredValue_match(SDValue &Match)
EffectiveOperands(SDValue N, const MatchContext &Ctx)
Provide number of operands that are not chain or glue, as well as the first index of such operand.
EffectiveOperands(SDValue N, const MatchContext &Ctx)
MaxMin_match(const LHS_P &L, const RHS_P &R)
bool match(const MatchContext &Ctx, SDValue N)
bool match(const MatchContext &Ctx, SDValue N)
NUses_match(const Pattern &P)
bool match(const MatchContext &Ctx, SDValue N)
Ones_match(bool AllowUndefs)
bool match(const MatchContext &, SDValue N)
bool match(const MatchContext &Ctx, SDValue N)
Opcode_match(unsigned Opc)
Operands_match(const OpndPred &p, const OpndPreds &...preds)
bool match(const MatchContext &Ctx, SDValue N)
bool match(const MatchContext &Ctx, SDValue N)
Or(const Pred &p, const Preds &...preds)
bool match(const MatchContext &Ctx, SDValue N)
bool match(const MatchContext &, SDValue N)
bool match(const MatchContext &Ctx, SDValue N)
void collectLeaves(SDValue V, SmallVector< SDValue > &Leaves)
std::tuple< PatternTs... > Patterns
ReassociatableOpc_match(unsigned Opcode, const PatternTs &...Patterns)
bool reassociatableMatchHelper(ArrayRef< SmallBitVector > Matches, SmallBitVector &Used, size_t Curr=0)
bool match(const MatchContext &Ctx, SDValue N)
Result_match(const Pattern &P)
Matching while capturing mask.
bool match(const MatchContext &Ctx, SDValue N)
SDShuffle_match(const T0 &Op1, const T1 &Op2, const T2 &Mask)
SpecificInt_match(APInt APV)
bool match(const MatchContext &Ctx, SDValue N)
Switch to a different MatchContext for subsequent patterns.
const NewMatchContext & Ctx
bool match(const OrigMatchContext &, SDValue N)
bool match(const MatchContext &Ctx, SDValue N)
TLI_pred_match(const PredFuncT &Pred, const Pattern &P)
bool match(const MatchContext &Ctx, SDValue N)
TernaryOpc_match(unsigned Opc, const T0_P &Op0, const T1_P &Op1, const T2_P &Op2)
std::optional< SDNodeFlags > Flags
UnaryOpc_match(unsigned Opc, const Opnd_P &Op, std::optional< SDNodeFlags > Flgs=std::nullopt)
bool match(const MatchContext &Ctx, SDValue N)
bool match(const MatchContext &, SDValue N)
ValueType_bind(EVT &Bind)
ValueType_match(const PredFuncT &Pred, const Pattern &P)
bool match(const MatchContext &Ctx, SDValue N)
bool match(const MatchContext &, SDValue N)
bool match(const MatchContext &, SDValue N)
Value_match(SDValue Match)
Zero_match(bool AllowUndefs)
bool match(const MatchContext &, SDValue N) const
bool match(ArrayRef< int > Mask)
ArrayRef< int > & MaskRef
m_Mask(ArrayRef< int > &MaskRef)
m_SpecificMask(ArrayRef< int > MaskRef)
bool match(ArrayRef< int > Mask)
static bool match(ISD::CondCode Cond)
static bool match(ISD::CondCode Cond)
static bool match(ISD::CondCode Cond)
static bool match(ISD::CondCode Cond)