13#ifndef LLVM_CODEGEN_SDPATTERNMATCH_H
14#define LLVM_CODEGEN_SDPATTERNMATCH_H
41 : DAG(DAG), TLI(DAG ? &DAG->getTargetLoweringInfo() : nullptr) {}
44 : DAG(nullptr), TLI(TLI) {}
54 return N->getOpcode() == Opcode;
60template <
typename Pattern,
typename MatchContext>
63 return P.match(Ctx,
N);
66template <
typename Pattern,
typename MatchContext>
72template <
typename Pattern>
77template <
typename Pattern>
82template <
typename Pattern>
87template <
typename Pattern>
100 template <
typename MatchContext>
bool match(
const MatchContext &,
SDValue N) {
120 template <
typename MatchContext>
122 return N.getResNo() == ResNo &&
P.match(Ctx,
N);
127template <
unsigned ResNo,
typename Pattern>
137 template <
typename MatchContext>
bool match(
const MatchContext &,
SDValue N) {
156 template <
typename MatchContext>
163template <
typename... Preds>
struct And {
164 template <
typename MatchContext>
bool match(
const MatchContext &,
SDValue N) {
169template <
typename Pred,
typename... Preds>
170struct And<Pred, Preds...> :
And<Preds...> {
172 And(
const Pred &p,
const Preds &...preds) :
And<Preds...>(preds...),
P(p) {}
174 template <
typename MatchContext>
180template <
typename... Preds>
struct Or {
181 template <
typename MatchContext>
bool match(
const MatchContext &,
SDValue N) {
186template <
typename Pred,
typename... Preds>
187struct Or<Pred, Preds...> :
Or<Preds...> {
189 Or(
const Pred &p,
const Preds &...preds) :
Or<Preds...>(preds...),
P(p) {}
191 template <
typename MatchContext>
197template <
typename Pred>
struct Not {
202 template <
typename MatchContext>
204 return !
P.match(Ctx,
N);
215template <
typename... Preds>
And<Preds...>
m_AllOf(
const Preds &...preds) {
216 return And<Preds...>(preds...);
219template <
typename... Preds>
Or<Preds...>
m_AnyOf(
const Preds &...preds) {
220 return Or<Preds...>(preds...);
223template <
typename... Preds>
auto m_NoneOf(
const Preds &...preds) {
242 template <
typename MatchContext>
247 return P.match(Ctx,
N) &&
N->hasNUsesOfValue(NumUses,
N.getResNo());
251template <
typename Pattern>
255template <
unsigned N,
typename Pattern>
273 template <
typename MatchContext>
275 if (!
Pred.match(Ctx,
N))
287template <
typename PredPattern>
299 template <
typename MatchContext>
301 assert(Ctx.getTLI() &&
"TargetLowering is required for this pattern.");
302 return PredFunc(*Ctx.getTLI(),
N) &&
P.match(Ctx,
N);
307template <
typename PredFuncT,
typename Pattern>
322 const NewMatchContext &
Ctx;
325 template <
typename OrigMatchContext>
327 return P.match(
Ctx,
N);
331template <
typename MatchContext,
typename Pattern>
345 template <
typename MatchContext>
348 return P.match(Ctx,
N);
352template <
typename Pattern>
369 template <
typename MatchContext>
371 return PredFunc(
N.getValueType()) &&
P.match(Ctx,
N);
376template <
typename PredFuncT,
typename Pattern>
381template <
typename Pattern>
393template <
typename Pattern>
404template <
typename Pattern>
407 return VT.isVector() &&
408 VT.getVectorElementType() == RefVT;
414 return VT.isVector() &&
415 VT.getVectorElementType() == RefVT;
473 template <
typename MatchContext>
477 return Ctx.getNumOperands(
N) ==
OpIdx;
481template <
unsigned OpIdx,
typename OpndPred,
typename... OpndPreds>
489 template <
typename MatchContext>
492 return P.match(Ctx,
N->getOperand(
OpIdx)) &&
500template <
typename... OpndPreds>
501auto m_Node(
unsigned Opcode,
const OpndPreds &...preds) {
512 template <
typename MatchContext>
514 const unsigned TotalNumOps = Ctx.getNumOperands(
N);
516 for (
unsigned I = 0;
I < TotalNumOps; ++
I) {
519 EVT VT =
N->getOperand(
I).getValueType();
520 if (VT != MVT::Glue && VT != MVT::Other) {
533 template <
typename MatchContext>
535 :
Size(Ctx.getNumOperands(
N)) {}
539template <
typename T0_P,
typename T1_P,
typename T2_P,
bool Commutable =
false,
540 bool ExcludeChain =
false>
551 template <
typename MatchContext>
558 (Commutable &&
Op0.match(Ctx,
N->getOperand(EO.
FirstIndex + 1)) &&
567template <
typename T0_P,
typename T1_P,
typename T2_P>
568inline 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, true, false>
580template <
typename T0_P,
typename T1_P,
typename T2_P>
581inline TernaryOpc_match<T0_P, T1_P, T2_P>
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>
597template <
typename T0_P,
typename T1_P,
typename T2_P>
598inline Result_match<0, TernaryOpc_match<T0_P, T1_P, T2_P>>
604template <
typename T0_P,
typename T1_P,
typename T2_P>
605inline TernaryOpc_match<T0_P, T1_P, T2_P>
611template <
typename LHS,
typename RHS,
typename IDX>
612inline TernaryOpc_match<LHS, RHS, IDX>
617template <
typename T0_P,
typename T1_P,
typename T2_P>
618inline TernaryOpc_match<T0_P, T1_P, T2_P>
623template <
typename T0_P,
typename T1_P,
typename T2_P>
624inline TernaryOpc_match<T0_P, T1_P, T2_P, true>
629template <
typename LTy,
typename RTy,
typename TTy,
typename FTy,
typename CCTy>
630inline auto m_SelectCC(
const LTy &L,
const RTy &R,
const TTy &
T,
const FTy &
F,
635template <
typename LTy,
typename RTy,
typename TTy,
typename FTy,
typename CCTy>
637 const FTy &
F,
const CCTy &CC) {
642template <
typename LHS_P,
typename RHS_P,
bool Commutable =
false,
643 bool ExcludeChain =
false>
653 template <
typename MatchContext>
660 (Commutable &&
LHS.match(Ctx,
N->getOperand(EO.
FirstIndex + 1)) &&
680 template <
typename MatchContext>
683 return Op1.match(Ctx,
I->getOperand(0)) &&
684 Op2.match(Ctx,
I->getOperand(1)) &&
Mask.match(
I->getMask());
704template <
typename LHS_P,
typename RHS_P,
typename Pred_t,
705 bool Commutable =
false,
bool ExcludeChain =
false>
713 template <
typename MatchContext>
717 if ((TrueValue != L || FalseValue != R) &&
718 (TrueValue != R || FalseValue != L))
722 TrueValue == L ? CC : getSetCCInverse(CC, L.getValueType());
723 if (!Pred_t::match(
Cond))
726 return (
LHS.match(Ctx, L) &&
RHS.match(Ctx, R)) ||
727 (Commutable &&
LHS.match(Ctx, R) &&
RHS.match(Ctx, L));
745 return MatchMinMax(L, R, TrueValue, FalseValue, CondNode->get());
758 return MatchMinMax(L, R, TrueValue, FalseValue, CondNode->get());
793template <
typename LHS,
typename RHS>
799template <
typename LHS,
typename RHS>
806template <
typename LHS,
typename RHS>
811template <
typename LHS,
typename RHS>
818template <
typename LHS,
typename RHS>
823template <
typename LHS,
typename RHS>
828template <
typename LHS,
typename RHS>
833template <
typename LHS,
typename RHS>
838template <
typename LHS,
typename RHS>
843template <
typename LHS,
typename RHS>
849template <
typename LHS,
typename RHS>
854template <
typename LHS,
typename RHS>
859template <
typename LHS,
typename RHS>
864template <
unsigned Opc,
typename Pred,
typename LHS,
typename RHS>
870template <
typename LHS,
typename RHS>
875template <
typename LHS,
typename RHS>
883template <
typename LHS,
typename RHS>
888template <
typename LHS,
typename RHS>
896template <
typename LHS,
typename RHS>
901template <
typename LHS,
typename RHS>
909template <
typename LHS,
typename RHS>
914template <
typename LHS,
typename RHS>
922template <
typename LHS,
typename RHS>
926template <
typename LHS,
typename RHS>
931template <
typename LHS,
typename RHS>
935template <
typename LHS,
typename RHS>
940template <
typename LHS,
typename RHS>
945template <
typename LHS,
typename RHS>
949template <
typename LHS,
typename RHS>
953template <
typename LHS,
typename RHS>
959template <
typename LHS,
typename RHS>
964template <
typename LHS,
typename RHS>
969template <
typename T0_P,
typename T1_P,
typename T2_P>
970inline TernaryOpc_match<T0_P, T1_P, T2_P>
971m_FShL(
const T0_P &Op0,
const T1_P &Op1,
const T2_P &Op2) {
975template <
typename T0_P,
typename T1_P,
typename T2_P>
976inline TernaryOpc_match<T0_P, T1_P, T2_P>
977m_FShR(
const T0_P &Op0,
const T1_P &Op1,
const T2_P &Op2) {
981template <
typename T0_P,
typename T1_P,
typename T2_P,
bool Left>
995 if (BitWidthBits > SumWidth)
998 return ShlV.
zext(SumWidth) + SrlV.
zext(SumWidth) ==
1002 template <
typename MatchContext>
1004 return Op0.match(Ctx,
X) &&
Op1.match(Ctx,
Y) &&
Op2.match(Ctx, Z);
1007 template <
typename MatchContext>
1010 template <
typename MatchContext>
1022 return matchShiftOr(Ctx,
N,
N.getValueType().getScalarSizeInBits());
1026template <
typename T0_P,
typename T1_P,
typename T2_P>
1027inline FunnelShiftLike_match<T0_P, T1_P, T2_P, true>
1032template <
typename T0_P,
typename T1_P,
typename T2_P>
1033inline FunnelShiftLike_match<T0_P, T1_P, T2_P, false>
1038template <
typename LHS,
typename RHS>
1043template <
typename LHS,
typename RHS>
1048template <
typename LHS,
typename RHS>
1053template <
typename LHS,
typename RHS>
1058template <
typename LHS,
typename RHS>
1063template <
typename LHS,
typename RHS>
1068template <
typename V1_t,
typename V2_t>
1073template <
typename V1_t,
typename V2_t,
typename Mask_t>
1074inline SDShuffle_match<V1_t, V2_t, Mask_t>
1079template <
typename LHS,
typename RHS>
1084template <
typename LHS,
typename RHS>
1099 template <
typename MatchContext>
1114template <
typename Opnd>
1118template <
typename Opnd>
1128template <
typename Opnd>
1133template <
typename Opnd>
1142template <
typename Opnd>
1147template <
typename Opnd>
inline auto m_SExt(
const Opnd &
Op) {
1185template <
typename Opnd>
1192template <
typename Opnd>
1249 static_assert(
sizeof(
T) == 8,
"T must be 64 bits wide");
1255 template <
typename MatchContext>
1261 if constexpr (std::is_signed_v<T>) {
1262 if (std::optional<int64_t> TrySExt = V.trySExtValue()) {
1268 if constexpr (std::is_unsigned_v<T>) {
1269 if (std::optional<uint64_t> TryZExt = V.tryZExtValue()) {
1297template <
typename T0_P,
typename T1_P,
typename T2_P,
bool Left>
1298template <
typename MatchContext>
1302 APInt ShlConst, SrlConst;
1318 template <
typename MatchContext>
1340 template <
typename MatchContext>
1343 return CFP->isExactlyValue(
Val);
1358 template <
typename MatchContext>
1366 template <
typename MatchContext>
1374 template <
typename MatchContext>
1382 template <
typename MatchContext>
1390 template <
typename MatchContext>
1402 template <
typename MatchContext>
1469 return ConstVal.
isOne();
1473 return (ConstVal & 0x01) == 1;
1490 return ConstVal.
isZero();
1492 return (ConstVal & 0x01) == 0;
1534template <
typename ValTy>
1540template <
typename ValTy>
1545template <
unsigned IntrinsicId,
typename... OpndPreds>
1555 template <
typename MatchContext>
1562 return LHS->getAPIntValue() == -
RHS->getAPIntValue();
1577 std::tuple_size_v<std::tuple<PatternTs...>>;
1588 template <
typename MatchContext>
1590 std::array<SDValue, NumPatterns> Leaves;
1591 size_t LeavesIdx = 0;
1597 [&](
auto &...
P) ->
bool {
1604 std::size_t &LeafIdx) {
1606 for (
size_t I = 0,
N = V->getNumOperands();
I <
N;
I++)
1611 Leaves[LeafIdx] = V;
1618 template <
typename MatchContext,
typename PatternHd,
typename... PatternTl>
1619 [[nodiscard]]
inline bool
1622 PatternTl &...TailPatterns) {
1623 for (
size_t Match = 0,
N = Used.size(); Match <
N; Match++) {
1634 template <
typename MatchContext>
1635 [[nodiscard]]
inline bool
1642template <
typename... PatternTs>
1643inline ReassociatableOpc_match<PatternTs...>
1648template <
typename... PatternTs>
1649inline ReassociatableOpc_match<PatternTs...>
1654template <
typename... PatternTs>
1655inline ReassociatableOpc_match<PatternTs...>
1660template <
typename... PatternTs>
1661inline ReassociatableOpc_match<PatternTs...>
1666template <
typename... PatternTs>
1667inline ReassociatableOpc_match<PatternTs...>
1673template <
typename... PatternTs>
1674inline 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.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This file describes how to lower LLVM code to machine code.
This file implements the C++20 <bit> header.
Class for arbitrary precision integers.
LLVM_ABI APInt zext(unsigned width) const
Zero extend to a new width.
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.
unsigned getBitWidth() const
Return the number of bits in the APInt.
static bool isSameValue(const APInt &I1, const APInt &I2, bool SignedCompare=false)
Determine if two APInts have the same value, after zero-extending or sign-extending (if SignedCompare...
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),...
This is a constexpr reimplementation of a subset of std::bitset.
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...
LLVM_ABI KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
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.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ 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.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ CLMUL
Carry-less multiplication operations.
@ SIGN_EXTEND
Conversion operators.
@ FNEG
Perform various unary floating-point operations inspired by libm.
@ 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) ...
@ VSCALE
VSCALE(IMM) - Returns the runtime scaling factor used to calculate the number of elements within a sc...
@ 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.
@ INTRINSIC_WO_CHAIN
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
@ 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.
LLVM_ABI bool matchBinaryPredicate(SDValue LHS, SDValue RHS, std::function< bool(ConstantSDNode *, ConstantSDNode *)> Match, bool AllowUndefs=false, bool AllowTypeMismatch=false)
Attempt to match a binary predicate against a pair of scalar/splat constants or every element of a pa...
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.
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().
auto m_BinOp()
Match an arbitrary binary operation and ignore it.
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)
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)
Opcode_match m_SpecificOpc(unsigned Opcode)
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.
auto m_MaxMinLike(const LHS &L, const RHS &R)
BinaryOpc_match< LHS, RHS, true > m_c_BinOp(unsigned Opc, const LHS &L, const RHS &R, SDNodeFlags Flgs=SDNodeFlags())
BinaryOpc_match< LHS, RHS, true > m_Mul(const LHS &L, const RHS &R)
BinaryOpc_match< LHS, RHS, true > m_Clmul(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)
StrictlyPositive_match m_StrictlyPositive()
BinaryOpc_match< LHS, RHS, true > m_SMin(const LHS &L, const RHS &R)
auto m_IntrinsicWOChain(const OpndPreds &...Opnds)
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)
TernaryOpc_match< T0_P, T1_P, T2_P > m_FShR(const T0_P &Op0, const T1_P &Op1, const T2_P &Op2)
And< Preds... > m_AllOf(const Preds &...preds)
auto m_ScalableVectorVT()
BinaryOpc_match< LHS, RHS > m_FDiv(const LHS &L, const RHS &R)
NonPositive_match m_NonPositive()
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)
FunnelShiftLike_match< T0_P, T1_P, T2_P, false > m_FShRLike(const T0_P &Op0, const T1_P &Op1, const T2_P &Op2)
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)
NonZero_match m_NonZero()
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)
SpecificFP_match m_SpecificFP(APFloat V)
Match a specific float constant.
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)
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)
ReassociatableOpc_match< PatternTs... > m_ReassociatableNUWAdd(const PatternTs &...Patterns)
TernaryOpc_match< T0_P, T1_P, T2_P > m_SetCC(const T0_P &LHS, const T1_P &RHS, const T2_P &CC)
auto m_VT(EVT &VT)
Retreive the ValueType of the current SDValue.
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)
SpecificNeg_match m_SpecificNeg(SDValue V)
Match a negation of a specific value V, either as sub(0, V) or as constant(s) that are the negation o...
BinaryOpc_match< LHS, RHS > m_SDiv(const LHS &L, const RHS &R)
SwitchContext< MatchContext, Pattern > m_Context(const MatchContext &Ctx, Pattern &&P)
NonNegative_match m_NonNegative()
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)
TernaryOpc_match< T0_P, T1_P, T2_P > m_FShL(const T0_P &Op0, const T1_P &Op1, const T2_P &Op2)
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)
ReassociatableOpc_match< PatternTs... > m_ReassociatableNSWAdd(const PatternTs &...Patterns)
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.
Negative_match m_Negative()
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.
UnaryOpc_match< Opnd > m_FAbs(const Opnd &Op)
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)
ValueType_bind(const Pattern &P) -> ValueType_bind< Pattern >
ConstantInt_match m_ConstInt()
Match any integer constants or splat of an integer constant.
FunnelShiftLike_match< T0_P, T1_P, T2_P, true > m_FShLLike(const T0_P &Op0, const T1_P &Op1, const T2_P &Op2)
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.
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.
int bit_width(T Value)
Returns the number of bits needed to represent Value if Value is nonzero.
LLVM_ABI ConstantFPSDNode * isConstOrConstSplatFP(SDValue N, bool AllowUndefs=false)
Returns the SDNode if it is a constant splat BuildVector or constant float.
auto dyn_cast_or_null(const Y &Val)
@ Sub
Subtraction of integers.
DWARFExpression::Operation Op
constexpr unsigned BitWidth
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.
bool isNonNegative() const
Returns true if this value is known to be non-negative.
bool isNonZero() const
Returns true if this value is known to be non-zero.
bool isStrictlyPositive() const
Returns true if this value is known to be positive.
bool isNegative() const
Returns true if this value is known to be negative.
bool isNonPositive() const
Returns true if this value is known to be non-positive.
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
bool match(const MatchContext &Ctx, SDValue N)
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)
bool match(const MatchContext &Ctx, SDValue N)
bool matchShiftOr(const MatchContext &Ctx, SDValue N, unsigned BitWidth)
static bool hasComplementaryConstantShifts(const APInt &ShlV, const APInt &SrlV, unsigned BitWidth)
FunnelShiftLike_match(const T0_P &Op0, const T1_P &Op1, const T2_P &Op2)
bool matchOperands(const MatchContext &Ctx, SDValue X, SDValue Y, SDValue Z)
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)
bool match(const MatchContext &Ctx, SDValue N)
bool match(const MatchContext &Ctx, SDValue N)
bool match(const MatchContext &Ctx, SDValue N)
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)
bool reassociatableMatchHelper(const MatchContext &Ctx, ArrayRef< SDValue > Leaves, Bitset< NumPatterns > &Used, PatternHd &HeadPattern, PatternTl &...TailPatterns)
static constexpr size_t NumPatterns
std::tuple< PatternTs... > Patterns
bool collectLeaves(SDValue V, std::array< SDValue, NumPatterns > &Leaves, std::size_t &LeafIdx)
bool reassociatableMatchHelper(const MatchContext &Ctx, ArrayRef< SDValue > Leaves, Bitset< NumPatterns > &Used)
ReassociatableOpc_match(unsigned Opcode, const PatternTs &...Patterns)
ReassociatableOpc_match(unsigned Opcode, SDNodeFlags Flags, const PatternTs &...Patterns)
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)
SpecificFP_match(APFloat V)
bool match(const MatchContext &Ctx, SDValue V)
SpecificInt_match(APInt APV)
bool match(const MatchContext &Ctx, SDValue N)
bool match(const MatchContext &Ctx, SDValue N)
SpecificNeg_match(SDValue V)
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)
UnaryOpc_match(unsigned Opc, const Opnd_P &Op, SDNodeFlags Flgs=SDNodeFlags())
bool match(const MatchContext &Ctx, SDValue N)
ValueType_bind(EVT &Bind, const Pattern &P)
bool match(const MatchContext &Ctx, SDValue N)
ValueType_match(const PredFuncT &Pred, const Pattern &P)
bool match(const MatchContext &Ctx, SDValue N)
Value_bind(SDValue &N, const PredPattern &P)
bool match(const MatchContext &Ctx, 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)