13#ifndef LLVM_CODEGEN_SDPATTERNMATCH_H
14#define LLVM_CODEGEN_SDPATTERNMATCH_H
32template <
typename Pattern>
37template <
typename Pattern>
74template <
unsigned ResNo,
typename Pattern>
109template <
typename... Preds>
struct And {
113template <
typename Pred,
typename... Preds>
114struct And<Pred, Preds...> :
And<Preds...> {
116 And(
const Pred &p,
const Preds &...preds) :
And<Preds...>(preds...),
P(p) {}
121template <
typename... Preds>
struct Or {
125template <
typename Pred,
typename... Preds>
126struct Or<Pred, Preds...> :
Or<Preds...> {
128 Or(
const Pred &p,
const Preds &...preds) :
Or<Preds...>(preds...),
P(p) {}
133template <
typename Pred>
struct Not {
148template <
typename... Preds>
And<Preds...>
m_AllOf(
const Preds &...preds) {
149 return And<Preds...>(preds...);
152template <
typename... Preds>
Or<Preds...>
m_AnyOf(
const Preds &...preds) {
153 return Or<Preds...>(preds...);
156template <
typename... Preds>
auto m_NoneOf(
const Preds &...preds) {
183 return P.match(
N) &&
N->hasNUsesOfValue(NumUses,
N.getResNo());
187template <
typename Pattern>
191template <
unsigned N,
typename Pattern>
216template <
typename PredPattern>
232template <
typename PredFuncT,
typename Pattern>
237template <
typename Pattern>
241 N->getOpcode(),
N.getValueType());
260template <
typename Pattern>
281template <
typename PredFuncT,
typename Pattern>
286template <
typename Pattern>
298template <
typename Pattern>
309template <
typename Pattern>
312 return VT.isVector() &&
313 VT.getVectorElementType() == RefVT;
319 return VT.isVector() &&
320 VT.getVectorElementType() == RefVT;
369template <
typename Pattern>
382 return N->getNumOperands() == OpIdx;
386template <
unsigned OpIdx,
typename OpndPred,
typename... OpndPreds>
395 if (OpIdx < N->getNumOperands())
396 return P.match(
N->getOperand(OpIdx)) &&
404template <
unsigned Opcode,
typename... OpndPreds>
410template <
typename... OpndPreds>
411auto m_Node(
unsigned Opcode,
const OpndPreds &...preds) {
425 if (
Size != 0 &&
N->getOperand(
Size - 1).getValueType() == MVT::Glue)
428 if (
Size != 0 &&
N->getOperand(0).getValueType() == MVT::Other) {
437template <
typename T0_P,
typename T1_P,
typename T2_P,
bool Commutable =
false,
438 bool ExcludeChain =
false>
498template <
typename T0_P,
typename T1_P>
506template <
typename T0_P,
typename T1_P>
507inline TernaryOpc_match<T0_P, T1_P, CondCode_match>
514template <
typename T0_P,
typename T1_P>
515inline TernaryOpc_match<T0_P, T1_P, CondCode_match>
523template <
typename T0_P,
typename T1_P>
524inline TernaryOpc_match<T0_P, T1_P, CondCode_match, true, false>
532template <
typename T0_P,
typename T1_P>
533inline TernaryOpc_match<T0_P, T1_P, CondCode_match, true, false>
541template <
typename T0_P,
typename T1_P>
542inline TernaryOpc_match<T0_P, T1_P, CondCode_match, true, false>
548template <
typename T0_P,
typename T1_P,
typename T2_P>
549inline TernaryOpc_match<T0_P, T1_P, T2_P>
554template <
typename T0_P,
typename T1_P,
typename T2_P>
555inline TernaryOpc_match<T0_P, T1_P, T2_P>
560template <
typename T0_P,
typename T1_P,
typename T2_P>
565template <
typename T0_P,
typename T1_P,
typename T2_P>
566inline Result_match<0, TernaryOpc_match<T0_P, T1_P, T2_P>>
572template <
typename T0_P,
typename T1_P,
typename T2_P>
573inline TernaryOpc_match<T0_P, T1_P, T2_P>
579template <
typename LHS,
typename RHS,
typename IDX>
580inline TernaryOpc_match<LHS, RHS, IDX>
585template <
typename T0_P,
typename T1_P,
typename T2_P>
586inline 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>
598template <
typename T0_P,
typename T1_P,
typename T2_P>
599inline TernaryOpc_match<T0_P, T1_P, T2_P, true>
605template <
typename LTy,
typename RTy,
typename TTy,
typename FTy>
606inline auto m_SelectCC(
const LTy &L,
const RTy &R,
const TTy &
T,
const FTy &
F) {
612template <
typename LTy,
typename RTy,
typename TTy,
typename FTy>
614 const TTy &
T,
const FTy &
F) {
619template <
typename LTy,
typename RTy,
typename TTy,
typename FTy>
621 const TTy &
T,
const FTy &
F) {
626template <
typename LTy,
typename RTy,
typename TTy,
typename FTy>
634template <
typename LTy,
typename RTy,
typename TTy,
typename FTy>
636 const TTy &
T,
const FTy &
F) {
641template <
typename LTy,
typename RTy,
typename TTy,
typename FTy>
643 const TTy &
T,
const FTy &
F) {
649template <
typename LHS_P,
typename RHS_P,
bool Commutable =
false,
650 bool ExcludeChain =
false>
688 return Op1.match(
I->getOperand(0)) &&
Op2.match(
I->getOperand(1)) &&
689 Mask.match(
I->getMask());
709template <
typename LHS_P,
typename RHS_P,
typename Pred_t,
710 bool Commutable =
false>
721 if ((TrueValue != L || FalseValue != R) &&
722 (TrueValue != R || FalseValue != L))
726 TrueValue == L ?
CC : getSetCCInverse(
CC, L.getValueType());
727 if (!Pred_t::match(
Cond))
730 return (
LHS.match(L) &&
RHS.match(R)) ||
731 (Commutable &&
LHS.match(R) &&
RHS.match(L));
735 assert(
N.getNumOperands() == 3);
737 SDValue TrueValue =
N.getOperand(1);
738 SDValue FalseValue =
N.getOperand(2);
745 return MatchMinMax(L, R, TrueValue, FalseValue,
CC);
750 assert(
N.getNumOperands() == 5);
753 SDValue TrueValue =
N.getOperand(2);
754 SDValue FalseValue =
N.getOperand(3);
756 return MatchMinMax(L, R, TrueValue, FalseValue,
CC);
791template <
typename LHS,
typename RHS>
797template <
typename LHS,
typename RHS>
804template <
typename LHS,
typename RHS>
809template <
typename LHS,
typename RHS>
816template <
typename LHS,
typename RHS>
821template <
typename LHS,
typename RHS>
827template <
typename LHS,
typename RHS>
833template <
typename LHS,
typename RHS>
838template <
typename LHS,
typename RHS>
843template <
typename LHS,
typename RHS>
848template <
typename LHS,
typename RHS>
853template <
typename LHS,
typename RHS>
859template <
typename LHS,
typename RHS>
864template <
typename LHS,
typename RHS>
869template <
typename LHS,
typename RHS>
874template <
typename LHS,
typename RHS>
879template <
typename LHS,
typename RHS>
884template <
unsigned Opc,
typename Pred,
typename LHS,
typename RHS>
890template <
typename LHS,
typename RHS>
895template <
typename LHS,
typename RHS>
900template <
typename LHS,
typename RHS>
905template <
typename LHS,
typename RHS>
910template <
typename LHS,
typename RHS>
915template <
typename LHS,
typename RHS>
920template <
typename LHS,
typename RHS>
925template <
typename LHS,
typename RHS>
930template <
typename LHS,
typename RHS>
934template <
typename LHS,
typename RHS>
939template <
typename LHS,
typename RHS>
943template <
typename LHS,
typename RHS>
948template <
typename LHS,
typename RHS>
953template <
typename LHS,
typename RHS>
957template <
typename LHS,
typename RHS>
961template <
typename LHS,
typename RHS>
967template <
typename LHS,
typename RHS>
972template <
typename LHS,
typename RHS>
977template <
typename T0_P,
typename T1_P,
typename T2_P>
978inline TernaryOpc_match<T0_P, T1_P, T2_P>
979m_FShL(
const T0_P &Op0,
const T1_P &Op1,
const T2_P &Op2) {
983template <
typename T0_P,
typename T1_P,
typename T2_P>
984inline TernaryOpc_match<T0_P, T1_P, T2_P>
985m_FShR(
const T0_P &Op0,
const T1_P &Op1,
const T2_P &Op2) {
989template <
typename T0_P,
typename T1_P,
typename T2_P,
bool Left>
1003 if (BitWidthBits > SumWidth)
1006 return ShlV.
zext(SumWidth) + SrlV.
zext(SumWidth) ==
1011 return Op0.match(
X) &&
Op1.match(
Y) &&
Op2.match(Z);
1029template <
typename T0_P,
typename T1_P,
typename T2_P>
1030inline FunnelShiftLike_match<T0_P, T1_P, T2_P, true>
1035template <
typename T0_P,
typename T1_P,
typename T2_P>
1036inline FunnelShiftLike_match<T0_P, T1_P, T2_P, false>
1041template <
typename LHS,
typename RHS>
1046template <
typename LHS,
typename RHS>
1051template <
typename LHS,
typename RHS>
1056template <
typename LHS,
typename RHS>
1061template <
typename LHS,
typename RHS>
1066template <
typename LHS,
typename RHS>
1071template <
typename V1_t,
typename V2_t>
1076template <
typename V1_t,
typename V2_t,
typename Mask_t>
1077inline SDShuffle_match<V1_t, V2_t, Mask_t>
1082template <
typename LHS,
typename RHS>
1087template <
typename LHS,
typename RHS>
1116template <
typename Opnd>
1120template <
typename Opnd>
1130template <
typename Opnd>
1135template <
typename Opnd>
1144template <
typename Opnd>
1149template <
typename Opnd>
inline auto m_SExt(
const Opnd &
Op) {
1161template <
typename Opnd>
inline auto m_Abs(
const Opnd &
Op) {
1193template <
typename Opnd>
1200template <
typename Opnd>
1233template <
typename Opnd>
1262 static_assert(
sizeof(
T) == 8,
"T must be 64 bits wide");
1273 if constexpr (std::is_signed_v<T>) {
1274 if (std::optional<int64_t> TrySExt = V.trySExtValue()) {
1280 if constexpr (std::is_unsigned_v<T>) {
1281 if (std::optional<uint64_t> TryZExt = V.tryZExtValue()) {
1309template <
typename T0_P,
typename T1_P,
typename T2_P,
bool Left>
1313 APInt ShlConst, SrlConst;
1351 return CFP->isExactlyValue(
Val);
1416 auto Res =
DAG.isBoolConstant(
N);
1430template <
typename ValTy>
1436template <
typename ValTy>
1458 !KnownMin.
isIntN(std::numeric_limits<typename TS::ScalarTy>::digits))
1472template <
unsigned IntrinsicId,
typename... OpndPreds>
1488 return LHS->getAPIntValue() == -
RHS->getAPIntValue();
1503 std::tuple_size_v<std::tuple<PatternTs...>>;
1515 std::array<SDValue, NumPatterns> Leaves;
1516 size_t LeavesIdx = 0;
1522 [&](
auto &...
P) ->
bool {
1529 std::size_t &LeafIdx) {
1531 for (
size_t I = 0,
N = V->getNumOperands();
I <
N;
I++)
1536 Leaves[LeafIdx] = V;
1543 template <
typename PatternHd,
typename... PatternTl>
1544 [[nodiscard]]
inline bool
1546 PatternHd &HeadPattern,
1547 PatternTl &...TailPatterns) {
1548 for (
size_t Match = 0,
N = Used.size(); Match <
N; Match++) {
1549 if (Used[Match] || !(
sd_match(Leaves[Match], HeadPattern)))
1559 [[nodiscard]]
inline bool
1566template <
typename... PatternTs>
1567inline ReassociatableOpc_match<PatternTs...>
1572template <
typename... PatternTs>
1573inline ReassociatableOpc_match<PatternTs...>
1578template <
typename... PatternTs>
1579inline ReassociatableOpc_match<PatternTs...>
1584template <
typename... PatternTs>
1585inline ReassociatableOpc_match<PatternTs...>
1590template <
typename... PatternTs>
1591inline ReassociatableOpc_match<PatternTs...>
1597template <
typename... PatternTs>
1598inline 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)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
SmallVector< MachineOperand, 4 > 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.
uint64_t getZExtValue() const
Get zero extended value.
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool isNegative() const
Determine sign of this 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 isIntN(unsigned N) const
Check if this APInt has an N-bits unsigned integer value.
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.
Tagged union holding either a T or a Error.
Represents one node in the SelectionDAG.
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...
const TargetLowering & getTargetLoweringInfo() const
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.
@ 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.
@ VECTOR_REVERSE
VECTOR_REVERSE(VECTOR) - Returns a vector, of the same type as VECTOR, whose elements are shuffled us...
@ 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...
@ VECTOR_SPLICE_RIGHT
VECTOR_SPLICE_RIGHT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1,VEC2) right by OFFSET elements a...
@ 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.
@ ABS_MIN_POISON
ABS with a poison result for INT_MIN.
LLVM_ABI bool matchBinaryPredicate(SDValue LHS, SDValue RHS, const APInt &DemandedElts, 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...
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,...
AllOnesConstantMatch m_AllOnes()
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
auto m_BinOp()
Match an arbitrary binary operation and ignore it.
auto m_VScale()
Matches a call to llvm.vscale().
is_zero< true > 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_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.
BinaryOpc_match< LHS, RHS > m_Sra(const LHS &L, const RHS &R)
BinaryOpc_match< LHS, RHS > m_FRem(const LHS &L, const RHS &R)
auto m_False(const SelectionDAG &DAG)
Match false boolean value based on the information provided by TargetLowering.
TLI_pred_match(const PredFuncT &Pred, const Pattern &P) -> TLI_pred_match< Pattern, PredFuncT >
TernaryOpc_match< T0_P, T1_P, CondCode_match, true, false > m_c_SetCC(const T0_P &LHS, const T1_P &RHS)
Match a SETCC with any condition code, allowing the operands to be commuted.
auto m_Abs(const Opnd &Op)
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())
auto m_Node(const OpndPreds &...Preds)
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_SelectCC(const LTy &L, const RTy &R, const TTy &T, const FTy &F)
Match a SELECT_CC with any condition code.
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)
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)
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)
auto m_SpecificSelectCCLike(ISD::CondCode CC, const LTy &L, const RTy &R, const TTy &T, const FTy &F)
Match a SELECT of a SETCC or a SELECT_CC with a specific condition code.
BinaryOpc_match< LHS, RHS > m_URem(const LHS &L, const RHS &R)
AnyZeroFP_match m_AnyZeroFP()
Match a floating-point +0.0 or -0.0 constant or splat.
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)
UnaryOpc_match< Opnd > m_VectorReverse(const Opnd &Op)
auto m_ScalableVectorVT()
BinaryOpc_match< LHS, RHS > m_FDiv(const LHS &L, const RHS &R)
auto m_NSWAdd(const LHS &L, const RHS &R)
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)
auto m_LegalType(const SelectionDAG &DAG, const Pattern &P)
Match legal ValueTypes based on the information provided by TargetLowering.
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.
auto m_True(const SelectionDAG &DAG)
Match true boolean value based on the information provided by TargetLowering.
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)
auto m_NUWAddLike(const LHS &L, const RHS &R)
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, CondCode_match > m_SpecificSetCC(ISD::CondCode CC, const T0_P &LHS, const T1_P &RHS)
Match a SETCC with a specific condition code.
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)
auto m_NSWAddLike(const LHS &L, const RHS &R)
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)
auto m_ZExtOrSExt(const Opnd &Op)
Match a zext or sext.
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_SelectCCLike(const LTy &L, const RTy &R, const TTy &T, const FTy &F)
Match a SELECT of a SETCC or a SELECT_CC with any condition code.
TernaryOpc_match< T0_P, T1_P, CondCode_match, true, false > m_c_SpecificSetCC(ISD::CondCode CC, const T0_P &LHS, const T1_P &RHS)
Match a SETCC with a specific condition code, allowing the operands to be commuted.
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)
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)
TypeSize_match< ElementCount > m_ElementCount(ElementCount &V)
Match any integer constant or constant multiple of VSCALE that can be represented using ElementCount.
TernaryOpc_match< T0_P, T1_P, T2_P > m_FShL(const T0_P &Op0, const T1_P &Op1, const T2_P &Op2)
UnaryOpc_match< Opnd > m_UnaryOp(unsigned Opc, const Opnd &Op)
auto m_SExt(const Opnd &Op)
bool sd_match(SDValue N, Pattern &&P)
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_BitwiseLogic(const LHS &L, const RHS &R)
UnaryOpc_match< Opnd > m_Ctpop(const Opnd &Op)
auto m_LegalOp(const SelectionDAG &DAG, const Pattern &P)
Match legal SDNodes based on the information provided by TargetLowering.
TernaryOpc_match< T0_P, T1_P, CondCode_match > m_SetCC(const T0_P &LHS, const T1_P &RHS)
Match a SETCC with any condition code.
ReassociatableOpc_match< PatternTs... > m_ReassociatableAnd(const PatternTs &...Patterns)
TernaryOpc_match< T0_P, T1_P, T2_P > m_SpliceRight(const T0_P &V1, const T1_P &V2, const T2_P &Offset)
UnaryOpc_match< Opnd > m_FPToSI(const Opnd &Op)
NUses_match< 1, Value_match > m_OneUse()
auto m_NUWAdd(const LHS &L, const RHS &R)
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...
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)
auto m_SpecificSelectCC(ISD::CondCode CC, const LTy &L, const RTy &R, const TTy &T, const FTy &F)
Match a SELECT_CC with a specific condition code.
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)
LLVM_ABI bool isOneOrOneSplat(SDValue V, bool AllowUndefs=false)
Return true if the value is a constant 1 integer or a splatted vector of a constant 1 integer (with n...
@ 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...
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)
And(const Pred &p, const Preds &...preds)
BinaryOpc_match(unsigned Opc, const LHS_P &L, const RHS_P &R, SDNodeFlags Flgs=SDNodeFlags())
Bool_match(const SelectionDAG &DAG)
CondCode_match(ISD::CondCode CC)
CondCode_match(ISD::CondCode *CC)
std::optional< ISD::CondCode > CCToMatch
ConstantInt_match(APInt *V)
DeferredValue_match(SDValue &Match)
Provide number of operands that are not chain or glue, as well as the first index of such operand.
EffectiveOperands(SDValue N)
bool matchShiftOr(SDValue N, unsigned BitWidth)
bool matchOperands(SDValue X, SDValue Y, SDValue Z)
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)
MaxMin_match(const LHS_P &L, const RHS_P &R)
NUses_match(const Pattern &P)
One_match(bool AllowUndefs)
Opcode_match(unsigned Opc)
Operands_match(const OpndPred &p, const OpndPreds &...preds)
Or(const Pred &p, const Preds &...preds)
bool reassociatableMatchHelper(ArrayRef< SDValue > Leaves, Bitset< NumPatterns > &Used)
bool reassociatableMatchHelper(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)
ReassociatableOpc_match(unsigned Opcode, const PatternTs &...Patterns)
ReassociatableOpc_match(unsigned Opcode, SDNodeFlags Flags, const PatternTs &...Patterns)
Result_match(const Pattern &P)
Matching while capturing mask.
SDShuffle_match(const T0 &Op1, const T1 &Op2, const T2 &Mask)
SpecificFP_match(APFloat V)
SpecificInt_match(APInt APV)
SpecificNeg_match(SDValue V)
TLI_pred_match(const PredFuncT &Pred, const Pattern &P)
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())
ValueType_bind(EVT &Bind, const Pattern &P)
ValueType_match(const PredFuncT &Pred, const Pattern &P)
Value_match(SDValue Match)
Zero_match(bool AllowUndefs)
bool match(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)