LLVM: include/llvm/CodeGen/SDPatternMatch.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_CODEGEN_SDPATTERNMATCH_H

14#define LLVM_CODEGEN_SDPATTERNMATCH_H

15

23

24namespace llvm {

26

27

28

29

30

34

35public:

37 : DAG(DAG), TLI(DAG ? &DAG->getTargetLoweringInfo() : nullptr) {}

38

40 : DAG(nullptr), TLI(TLI) {}

41

42

43

45

47

48

50 return N->getOpcode() == Opcode;

51 }

52

54};

55

56template <typename Pattern, typename MatchContext>

59 return P.match(Ctx, N);

60}

61

62template <typename Pattern, typename MatchContext>

67

68template

72

73template

77

78template

82

83template

87

88

91

93

95

96 template bool match(const MatchContext &, SDValue N) {

99 return N.getNode();

100 }

101};

102

103

105

110

111template <unsigned ResNo, typename Pattern> struct Result_match {

113

115

116 template

118 return N.getResNo() == ResNo && P.match(Ctx, N);

119 }

120};

121

122

123template <unsigned ResNo, typename Pattern>

127

130

132

133 template bool match(const MatchContext &, SDValue N) {

135 }

136};

137

138

139

140

141

142

146

149

151

152 template

154 return Ctx.match(N, Opcode);

155 }

156};

157

158

159template <typename... Preds> struct And {

160 template bool match(const MatchContext &, SDValue N) {

161 return true;

162 }

163};

164

165template <typename Pred, typename... Preds>

166struct And<Pred, Preds...> : And<Preds...> {

168 And(const Pred &p, const Preds &...preds) : And<Preds...>(preds...), P(p) {}

169

170 template

174};

175

176template <typename... Preds> struct Or {

177 template bool match(const MatchContext &, SDValue N) {

178 return false;

179 }

180};

181

182template <typename Pred, typename... Preds>

183struct Or<Pred, Preds...> : Or<Preds...> {

185 Or(const Pred &p, const Preds &...preds) : Or<Preds...>(preds...), P(p) {}

186

187 template

191};

192

193template struct Not {

195

196 explicit Not(const Pred &P) : P(P) {}

197

198 template

200 return P.match(Ctx, N);

201 }

202};

203

205

206

210

211template <typename... Preds> And<Preds...> m_AllOf(const Preds &...preds) {

212 return And<Preds...>(preds...);

213}

214

215template <typename... Preds> Or<Preds...> m_AnyOf(const Preds &...preds) {

216 return Or<Preds...>(preds...);

217}

218

219template <typename... Preds> auto m_NoneOf(const Preds &...preds) {

221}

222

224

228

230

231template <unsigned NumUses, typename Pattern> struct NUses_match {

233

235

236 template

238

239

240

241 return P.match(Ctx, N) && N->hasNUsesOfValue(NumUses, N.getResNo());

242 }

243};

244

245template

249template <unsigned N, typename Pattern>

253

260

263

265

266 template bool match(const MatchContext &, SDValue N) {

268 return true;

269 }

270};

271

273

274template <typename Pattern, typename PredFuncT> struct TLI_pred_match {

277

280

281 template

283 assert(Ctx.getTLI() && "TargetLowering is required for this pattern.");

284 return PredFunc(*Ctx.getTLI(), N) && P.match(Ctx, N);

285 }

286};

287

288

289template <typename PredFuncT, typename Pattern>

292

293

297 N.getValueType());

298 },

299 P};

300}

301

302

303template <typename NewMatchContext, typename Pattern> struct SwitchContext {

304 const NewMatchContext &Ctx;

306

307 template

309 return P.match(Ctx, N);

310 }

311};

312

313template <typename MatchContext, typename Pattern>

318

319

322

324

325 template bool match(const MatchContext &, SDValue N) {

326 BindVT = N.getValueType();

327 return true;

328 }

329};

330

331

333

334template <typename Pattern, typename PredFuncT> struct ValueType_match {

337

340

341 template

343 return PredFunc(N.getValueType()) && P.match(Ctx, N);

344 }

345};

346

347

348template <typename PredFuncT, typename Pattern>

351

352

353template

360

363

364

365template

374

375

376template

379 return VT.isVector() &&

380 VT.getVectorElementType() == RefVT;

381 },

382 P};

383}

386 return VT.isVector() &&

387 VT.getVectorElementType() == RefVT;

388 },

390}

391

392

399

400

408

409

416

417

425

426

434

435

442

443

445 template

447

448

449 return Ctx.getNumOperands(N) == OpIdx;

450 }

451};

452

453template <unsigned OpIdx, typename OpndPred, typename... OpndPreds>

457

460

461 template

464 return P.match(Ctx, N->getOperand(OpIdx)) &&

466

467

468 return false;

469 }

470};

471

472template <typename... OpndPreds>

473auto m_Node(unsigned Opcode, const OpndPreds &...preds) {

475}

476

477

478

482

483 template

485 const unsigned TotalNumOps = Ctx.getNumOperands(N);

487 for (unsigned I = 0; I < TotalNumOps; ++I) {

488

489

490 EVT VT = N->getOperand(I).getValueType();

491 if (VT != MVT::Glue && VT != MVT::Other) {

495 }

496 }

497 }

498};

499

503

504 template

506 : Size(Ctx.getNumOperands(N)) {}

507};

508

509

510template <typename T0_P, typename T1_P, typename T2_P, bool Commutable = false,

511 bool ExcludeChain = false>

517

521

522 template

527 return ((Op0.match(Ctx, N->getOperand(EO.FirstIndex)) &&

529 (Commutable && Op0.match(Ctx, N->getOperand(EO.FirstIndex + 1)) &&

532 }

533

534 return false;

535 }

536};

537

538template <typename T0_P, typename T1_P, typename T2_P>

539inline TernaryOpc_match<T0_P, T1_P, T2_P>

543

544template <typename T0_P, typename T1_P, typename T2_P>

545inline TernaryOpc_match<T0_P, T1_P, T2_P, true, false>

550

551template <typename T0_P, typename T1_P, typename T2_P>

552inline TernaryOpc_match<T0_P, T1_P, T2_P>

556

557template <typename T0_P, typename T1_P, typename T2_P>

558inline TernaryOpc_match<T0_P, T1_P, T2_P>

562

563template <typename T0_P, typename T1_P, typename T2_P>

567

568template <typename T0_P, typename T1_P, typename T2_P>

569inline Result_match<0, TernaryOpc_match<T0_P, T1_P, T2_P>>

574

575template <typename T0_P, typename T1_P, typename T2_P>

576inline TernaryOpc_match<T0_P, T1_P, T2_P>

577m_InsertElt(const T0_P &Vec, const T1_P &Val, const T2_P &Idx) {

579 Idx);

580}

581

582template <typename LHS, typename RHS, typename IDX>

583inline TernaryOpc_match<LHS, RHS, IDX>

587

588template <typename T0_P, typename T1_P, typename T2_P>

589inline TernaryOpc_match<T0_P, T1_P, T2_P>

590m_TernaryOp(unsigned Opc, const T0_P &Op0, const T1_P &Op1, const T2_P &Op2) {

592}

593

594template <typename T0_P, typename T1_P, typename T2_P>

595inline TernaryOpc_match<T0_P, T1_P, T2_P, true>

599

600template <typename LTy, typename RTy, typename TTy, typename FTy, typename CCTy>

601inline auto m_SelectCC(const LTy &L, const RTy &R, const TTy &T, const FTy &F,

602 const CCTy &CC) {

604}

605

606template <typename LTy, typename RTy, typename TTy, typename FTy, typename CCTy>

608 const FTy &F, const CCTy &CC) {

610}

611

612

613template <typename LHS_P, typename RHS_P, bool Commutable = false,

614 bool ExcludeChain = false>

623

624 template

629 if (!((LHS.match(Ctx, N->getOperand(EO.FirstIndex)) &&

631 (Commutable && LHS.match(Ctx, N->getOperand(EO.FirstIndex + 1)) &&

633 return false;

634

636 }

637

638 return false;

639 }

640};

641

642

643template <typename T0, typename T1, typename T2> struct SDShuffle_match {

647

650

651 template

654 return Op1.match(Ctx, I->getOperand(0)) &&

655 Op2.match(Ctx, I->getOperand(1)) && Mask.match(I->getMask());

656 }

657 return false;

658 }

659};

668

674

675template <typename LHS_P, typename RHS_P, typename Pred_t,

676 bool Commutable = false, bool ExcludeChain = false>

681

683

684 template

688 if ((TrueValue != L || FalseValue != R) &&

689 (TrueValue != R || FalseValue != L))

690 return false;

691

693 TrueValue == L ? CC : getSetCCInverse(CC, L.getValueType());

694 if (!Pred_t::match(Cond))

695 return false;

696

697 return (LHS.match(Ctx, L) && RHS.match(Ctx, R)) ||

698 (Commutable && LHS.match(Ctx, R) && RHS.match(Ctx, L));

699 };

700

708

714 auto *CondNode =

716 return MatchMinMax(L, R, TrueValue, FalseValue, CondNode->get());

717 }

718 }

719

727 auto *CondNode =

729 return MatchMinMax(L, R, TrueValue, FalseValue, CondNode->get());

730 }

731

732 return false;

733 }

734};

735

736

742

743

749

750

756

757

763

764template <typename LHS, typename RHS>

769template <typename LHS, typename RHS>

774

775template <typename LHS, typename RHS>

780template <typename LHS, typename RHS>

785

786

787template <typename LHS, typename RHS>

791

792template <typename LHS, typename RHS>

796

797template <typename LHS, typename RHS>

801

802template <typename LHS, typename RHS>

806

807template <typename LHS, typename RHS>

811

812template <typename LHS, typename RHS>

817

818template <typename LHS, typename RHS>

822

823template <typename LHS, typename RHS>

827

828template <typename LHS, typename RHS>

832

833template <typename LHS, typename RHS>

837

838template <typename LHS, typename RHS>

843

844template <typename LHS, typename RHS>

848

849template <typename LHS, typename RHS>

854

855template <typename LHS, typename RHS>

859

860template <typename LHS, typename RHS>

865

866template <typename LHS, typename RHS>

870

871template <typename LHS, typename RHS>

876

877template <typename LHS, typename RHS>

881template <typename LHS, typename RHS>

885

886template <typename LHS, typename RHS>

890template <typename LHS, typename RHS>

894

895template <typename LHS, typename RHS>

899

900template <typename LHS, typename RHS>

904template <typename LHS, typename RHS>

908template <typename LHS, typename RHS>

913

914template <typename LHS, typename RHS>

918

919template <typename LHS, typename RHS>

923

924template <typename LHS, typename RHS>

928

929template <typename LHS, typename RHS>

933

934template <typename LHS, typename RHS>

938

939template <typename LHS, typename RHS>

943

944template <typename LHS, typename RHS>

948

949template <typename V1_t, typename V2_t>

953

954template <typename V1_t, typename V2_t, typename Mask_t>

955inline SDShuffle_match<V1_t, V2_t, Mask_t>

959

960template <typename LHS, typename RHS>

964

965template <typename LHS, typename RHS>

967 const RHS &Idx) {

969}

970

971

972template <typename Opnd_P, bool ExcludeChain = false> struct UnaryOpc_match {

975 std::optional Flags;

977 std::optional Flgs = std::nullopt)

979

980 template

986 return false;

987 if (Flags.has_value())

988 return true;

989

990 return (*Flags & N->getFlags()) == *Flags;

991 }

992

993 return false;

994 }

995};

996

997template

1001template

1003 const Opnd &Op) {

1005}

1006

1010

1011template

1015

1016template

1020

1024

1025template

1029

1030template inline auto m_SExt(const Opnd &Op) {

1032}

1033

1037

1041

1045

1046

1047

1051

1052

1053

1057

1061

1062

1063

1064template

1068

1069

1070

1071template

1075

1079

1083

1087

1091

1095

1099

1103

1104

1107

1109

1110 template bool match(const MatchContext &, SDValue N) {

1111

1112

1113

1114

1117 *BindVal = C->getAPIntValue();

1118 return true;

1119 }

1120

1124 }

1125};

1126

1128

1129

1131

1134

1136

1137 template

1142 return false;

1143 }

1144};

1145

1146

1153

1156

1158

1159 template

1162 return CFP->isExactlyValue(Val);

1165 return false;

1166 }

1167};

1168

1169

1171

1175

1178

1180

1181 template

1185};

1186

1189

1191

1192 template bool match(const MatchContext &, SDValue N) {

1194 }

1195};

1196

1199

1201

1202 template bool match(const MatchContext &, SDValue N) {

1204 }

1205};

1206

1216

1217

1218

1226 return ConstVal.isOne();

1230 return (ConstVal & 0x01) == 1;

1231 }

1232

1233 return false;

1234 },

1236}

1237

1238

1247 return ConstVal.isZero();

1249 return (ConstVal & 0x01) == 0;

1250 }

1251

1252 return false;

1253 },

1255}

1256

1260

1262

1264

1265 template bool match(const MatchContext &, SDValue N) {

1268 return false;

1269

1271 *BindCC = CC->get();

1272 return true;

1273 }

1274

1275 return false;

1276 }

1277};

1278

1279

1281

1285

1289

1290

1291template

1295

1296

1297template

1301

1305

1308

1309 template

1311 constexpr size_t NumPatterns = std::tuple_size_v<std::tuple<PatternTs...>>;

1312

1315 if (Leaves.size() != NumPatterns)

1316 return false;

1317

1318

1319

1320 std::array<SmallBitVector, NumPatterns> Matches;

1321 for (size_t I = 0; I != NumPatterns; I++) {

1322 std::apply(

1323 [&](auto &...P) {

1325 },

1327 }

1328

1331 }

1332

1334 if (V->getOpcode() == Opcode) {

1335 for (size_t I = 0, N = V->getNumOperands(); I < N; I++)

1337 } else {

1339 }

1340 }

1341

1342 [[nodiscard]] inline bool

1345 if (Curr == Matches.size())

1346 return true;

1347 for (size_t Match = 0, N = Matches[Curr].size(); Match < N; Match++) {

1348 if (!Matches[Curr][Match] || Used[Match])

1349 continue;

1350 Used[Match] = true;

1352 return true;

1353 Used[Match] = false;

1354 }

1355 return false;

1356 }

1357};

1358

1359template <typename... PatternTs>

1360inline ReassociatableOpc_match<PatternTs...>

1364

1365template <typename... PatternTs>

1366inline ReassociatableOpc_match<PatternTs...>

1370

1371template <typename... PatternTs>

1372inline ReassociatableOpc_match<PatternTs...>

1376

1377template <typename... PatternTs>

1378inline ReassociatableOpc_match<PatternTs...>

1382

1383}

1384}

1385#endif

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.

Definition SDPatternMatch.h:31

const TargetLowering * getTLI() const

Definition SDPatternMatch.h:46

const SelectionDAG * getDAG() const

Definition SDPatternMatch.h:44

BasicMatchContext(const TargetLowering *TLI)

Definition SDPatternMatch.h:39

BasicMatchContext(const SelectionDAG *DAG)

Definition SDPatternMatch.h:36

bool match(SDValue N, unsigned Opcode) const

Return true if N effectively has opcode Opcode.

Definition SDPatternMatch.h:49

unsigned getNumOperands(SDValue N) const

Definition SDPatternMatch.h:53

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.

Definition SDPatternMatch.h:25

BinaryOpc_match< Zero_match, ValTy, false > m_Neg(const ValTy &V)

Match a negate as a sub(0, v)

Definition SDPatternMatch.h:1292

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)

Definition SDPatternMatch.h:570

ReassociatableOpc_match< PatternTs... > m_ReassociatableMul(const PatternTs &...Patterns)

Definition SDPatternMatch.h:1379

Opcode_match m_Opc(unsigned Opcode)

Definition SDPatternMatch.h:223

auto m_SelectCCLike(const LTy &L, const RTy &R, const TTy &T, const FTy &F, const CCTy &CC)

Definition SDPatternMatch.h:607

auto m_ExactSr(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:909

BinaryOpc_match< LHS, RHS > m_Srl(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:905

auto m_SExtLike(const Opnd &Op)

Definition SDPatternMatch.h:1058

auto m_SpecificVT(EVT RefVT, const Pattern &P)

Match a specific ValueType.

Definition SDPatternMatch.h:354

auto m_SelectCC(const LTy &L, const RTy &R, const TTy &T, const FTy &F, const CCTy &CC)

Definition SDPatternMatch.h:601

BinaryOpc_match< LHS, RHS > m_Sra(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:901

BinaryOpc_match< LHS, RHS > m_FRem(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:945

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.

Definition SDPatternMatch.h:124

BinaryOpc_match< LHS, RHS, true > m_Mul(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:798

auto m_UMinLike(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:861

auto m_SelectLike(const T0_P &Cond, const T1_P &T, const T2_P &F)

Definition SDPatternMatch.h:564

TernaryOpc_match< LHS, RHS, IDX > m_InsertSubvector(const LHS &Base, const RHS &Sub, const IDX &Idx)

Definition SDPatternMatch.h:584

auto m_UMaxLike(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:872

BinaryOpc_match< LHS, RHS, true > m_Or(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:808

UnaryOpc_match< Opnd > m_Abs(const Opnd &Op)

Definition SDPatternMatch.h:1042

TernaryOpc_match< T0_P, T1_P, T2_P > m_TernaryOp(unsigned Opc, const T0_P &Op0, const T1_P &Op1, const T2_P &Op2)

Definition SDPatternMatch.h:590

TernaryOpc_match< T0_P, T1_P, T2_P > m_InsertElt(const T0_P &Vec, const T1_P &Val, const T2_P &Idx)

Definition SDPatternMatch.h:577

BinaryOpc_match< LHS, RHS, false, true > m_ChainedBinOp(unsigned Opc, const LHS &L, const RHS &R)

Definition SDPatternMatch.h:777

auto m_OtherVT()

Definition SDPatternMatch.h:362

BinaryOpc_match< LHS, RHS, true > m_SMin(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:834

auto m_FloatingPointVT()

Definition SDPatternMatch.h:404

UnaryOpc_match< Opnd > m_Trunc(const Opnd &Op)

Definition SDPatternMatch.h:1038

BinaryOpc_match< LHS, RHS > m_FSub(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:930

auto m_AddLike(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:819

BinaryOpc_match< LHS, RHS > m_URem(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:887

UnaryOpc_match< Opnd > m_BSwap(const Opnd &Op)

Definition SDPatternMatch.h:1012

Or< Preds... > m_AnyOf(const Preds &...preds)

Definition SDPatternMatch.h:215

BinaryOpc_match< LHS, RHS, true, true > m_c_ChainedBinOp(unsigned Opc, const LHS &L, const RHS &R)

Definition SDPatternMatch.h:782

Or< UnaryOpc_match< Opnd >, Opnd > m_TruncOrSelf(const Opnd &Op)

Match a trunc or identity Allows to peek through optional truncations.

Definition SDPatternMatch.h:1072

UnaryOpc_match< Opnd > m_NNegZExt(const Opnd &Op)

Definition SDPatternMatch.h:1026

auto m_IntegerVT()

Definition SDPatternMatch.h:396

And< Preds... > m_AllOf(const Preds &...preds)

Definition SDPatternMatch.h:211

auto m_ScalableVectorVT()

Definition SDPatternMatch.h:430

BinaryOpc_match< LHS, RHS > m_FDiv(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:940

auto m_LegalType(const Pattern &P)

Match legal ValueTypes based on the information provided by TargetLowering.

Definition SDPatternMatch.h:436

UnaryOpc_match< Opnd > m_BitCast(const Opnd &Op)

Definition SDPatternMatch.h:1007

UnaryOpc_match< Opnd > m_FNeg(const Opnd &Op)

Definition SDPatternMatch.h:1100

Opcode_match m_Poison()

Definition SDPatternMatch.h:229

BinaryOpc_match< LHS, RHS, true > m_UMin(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:856

Not< Pred > m_Unless(const Pred &P)

Match if the inner pattern does NOT match.

Definition SDPatternMatch.h:207

BinaryOpc_match< LHS, RHS, true > m_SMax(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:845

auto m_SpecificScalarVT(EVT RefVT, const Pattern &P)

Match a scalar ValueType.

Definition SDPatternMatch.h:366

NUses_match< N, Value_match > m_NUses()

Definition SDPatternMatch.h:257

UnaryOpc_match< Opnd, true > m_ChainedUnaryOp(unsigned Opc, const Opnd &Op)

Definition SDPatternMatch.h:1002

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.

Definition SDPatternMatch.h:1147

UnaryOpc_match< Opnd > m_FPToUI(const Opnd &Op)

Definition SDPatternMatch.h:1080

SpecificFP_match m_SpecificFP(APFloat V)

Match a specific float constant.

Definition SDPatternMatch.h:1170

Value_match m_Specific(SDValue N)

Definition SDPatternMatch.h:106

BinaryOpc_match< LHS, RHS > m_ExtractElt(const LHS &Vec, const RHS &Idx)

Definition SDPatternMatch.h:961

BinaryOpc_match< LHS, RHS > m_ExtractSubvector(const LHS &Vec, const RHS &Idx)

Definition SDPatternMatch.h:966

UnaryOpc_match< Opnd > m_BitReverse(const Opnd &Op)

Definition SDPatternMatch.h:1017

BinaryOpc_match< LHS, RHS, true > m_And(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:803

ValueType_bind m_VT(EVT &VT)

Retreive the ValueType of the current SDValue.

Definition SDPatternMatch.h:332

BinaryOpc_match< LHS, RHS > m_Sub(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:793

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)

Definition SDPatternMatch.h:596

TernaryOpc_match< T0_P, T1_P, T2_P > m_SetCC(const T0_P &LHS, const T1_P &RHS, const T2_P &CC)

Definition SDPatternMatch.h:540

BinaryOpc_match< ValTy, AllOnes_match, true > m_Not(const ValTy &V)

Match a Not as a xor(v, -1) or xor(-1, v)

Definition SDPatternMatch.h:1298

ReassociatableOpc_match< PatternTs... > m_ReassociatableOr(const PatternTs &...Patterns)

Definition SDPatternMatch.h:1367

BinaryOpc_match< LHS, RHS > m_Rotr(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:920

ReassociatableOpc_match< PatternTs... > m_ReassociatableAdd(const PatternTs &...Patterns)

Definition SDPatternMatch.h:1361

UnaryOpc_match< Opnd > m_AnyExt(const Opnd &Op)

Definition SDPatternMatch.h:1034

BinaryOpc_match< LHS, RHS > m_Rotl(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:915

UnaryOpc_match< Opnd > m_Cttz(const Opnd &Op)

Definition SDPatternMatch.h:1096

auto m_Node(unsigned Opcode, const OpndPreds &...preds)

Definition SDPatternMatch.h:473

BinaryOpc_match< LHS, RHS, true > m_DisjointOr(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:813

auto m_SMaxLike(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:850

TernaryOpc_match< T0_P, T1_P, T2_P > m_Select(const T0_P &Cond, const T1_P &T, const T2_P &F)

Definition SDPatternMatch.h:553

BinaryOpc_match< LHS, RHS > m_UDiv(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:878

auto m_Undef()

Definition SDPatternMatch.h:225

UnaryOpc_match< Opnd > m_Ctlz(const Opnd &Op)

Definition SDPatternMatch.h:1092

auto m_FixedVectorVT()

Definition SDPatternMatch.h:421

BinaryOpc_match< LHS, RHS > m_SDiv(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:882

SwitchContext< MatchContext, Pattern > m_Context(const MatchContext &Ctx, Pattern &&P)

Definition SDPatternMatch.h:314

BinaryOpc_match< LHS, RHS, true > m_FAdd(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:925

Or< UnaryOpc_match< Opnd >, Opnd > m_AExtOrSelf(const Opnd &Op)

Match a aext or identity Allows to peek through optional extensions.

Definition SDPatternMatch.h:1065

BinaryOpc_match< LHS, RHS, true > m_UMax(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:867

TernaryOpc_match< T0_P, T1_P, T2_P > m_VSelect(const T0_P &Cond, const T1_P &T, const T2_P &F)

Definition SDPatternMatch.h:559

bool sd_match(SDNode *N, const SelectionDAG *DAG, Pattern &&P)

Definition SDPatternMatch.h:69

UnaryOpc_match< Opnd > m_UnaryOp(unsigned Opc, const Opnd &Op)

Definition SDPatternMatch.h:998

auto m_SExt(const Opnd &Op)

Definition SDPatternMatch.h:1030

BinaryOpc_match< LHS, RHS, true > m_Xor(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:824

auto m_SMinLike(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:839

BinaryOpc_match< LHS, RHS > m_SRem(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:891

auto m_NoneOf(const Preds &...preds)

Definition SDPatternMatch.h:219

CondCode_match m_SpecificCondCode(ISD::CondCode CC)

Match a conditional code SDNode with a specific ISD::CondCode.

Definition SDPatternMatch.h:1286

UnaryOpc_match< Opnd > m_ZExt(const Opnd &Op)

Definition SDPatternMatch.h:1021

Value_match m_Value()

Match any valid SDValue.

Definition SDPatternMatch.h:104

BinaryOpc_match< LHS, RHS, true > m_Add(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:788

auto m_SpecificVectorElementVT(EVT RefVT, const Pattern &P)

Match a vector ValueType.

Definition SDPatternMatch.h:377

BinaryOpc_match< LHS, RHS > m_Shl(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:896

auto m_LegalOp(const Pattern &P)

Match legal SDNodes based on the information provided by TargetLowering.

Definition SDPatternMatch.h:294

auto m_BitwiseLogic(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:829

auto m_True()

Match true boolean value based on the information provided by TargetLowering.

Definition SDPatternMatch.h:1219

UnaryOpc_match< Opnd > m_Ctpop(const Opnd &Op)

Definition SDPatternMatch.h:1088

ReassociatableOpc_match< PatternTs... > m_ReassociatableAnd(const PatternTs &...Patterns)

Definition SDPatternMatch.h:1373

UnaryOpc_match< Opnd > m_FPToSI(const Opnd &Op)

Definition SDPatternMatch.h:1084

NUses_match< 1, Value_match > m_OneUse()

Definition SDPatternMatch.h:254

auto m_False()

Match false boolean value based on the information provided by TargetLowering.

Definition SDPatternMatch.h:1239

auto m_SExtOrSelf(const Opnd &Op)

Match a sext or identity Allows to peek through optional extensions.

Definition SDPatternMatch.h:1054

CondCode_match m_CondCode()

Match any conditional code SDNode.

Definition SDPatternMatch.h:1280

BinaryOpc_match< LHS, RHS, true > m_c_BinOp(unsigned Opc, const LHS &L, const RHS &R)

Definition SDPatternMatch.h:770

Not(const Pred &P) -> Not< Pred >

auto m_VectorVT()

Definition SDPatternMatch.h:413

auto m_Glue()

Definition SDPatternMatch.h:361

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...

Definition SDPatternMatch.h:143

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)

Definition SDPatternMatch.h:546

bool sd_context_match(SDValue N, const MatchContext &Ctx, Pattern &&P)

Definition SDPatternMatch.h:57

BinaryOpc_match< LHS, RHS, true > m_FMul(const LHS &L, const RHS &R)

Definition SDPatternMatch.h:935

BinaryOpc_match< V1_t, V2_t > m_Shuffle(const V1_t &v1, const V2_t &v2)

Definition SDPatternMatch.h:950

ConstantInt_match m_ConstInt()

Match any integer constants or splat of an integer constant.

Definition SDPatternMatch.h:1127

auto m_ZExtOrSelf(const Opnd &Op)

Match a zext or identity Allows to peek through optional extensions.

Definition SDPatternMatch.h:1048

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 - Return the argument parameter cast to the specified type.

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

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 - 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.

Definition SDPatternMatch.h:1197

bool AllowUndefs

Definition SDPatternMatch.h:1198

AllOnes_match(bool AllowUndefs)

Definition SDPatternMatch.h:1200

bool match(const MatchContext &, SDValue N)

Definition SDPatternMatch.h:1202

Pred P

Definition SDPatternMatch.h:167

And(const Pred &p, const Preds &...preds)

Definition SDPatternMatch.h:168

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:171

Definition SDPatternMatch.h:159

bool match(const MatchContext &, SDValue N)

Definition SDPatternMatch.h:160

Definition SDPatternMatch.h:615

SDNodeFlags Flags

Definition SDPatternMatch.h:619

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:625

unsigned Opcode

Definition SDPatternMatch.h:616

BinaryOpc_match(unsigned Opc, const LHS_P &L, const RHS_P &R, SDNodeFlags Flgs=SDNodeFlags())

Definition SDPatternMatch.h:620

RHS_P RHS

Definition SDPatternMatch.h:618

LHS_P LHS

Definition SDPatternMatch.h:617

Definition SDPatternMatch.h:1257

CondCode_match(ISD::CondCode CC)

Definition SDPatternMatch.h:1261

bool match(const MatchContext &, SDValue N)

Definition SDPatternMatch.h:1265

CondCode_match(ISD::CondCode *CC)

Definition SDPatternMatch.h:1263

ISD::CondCode * BindCC

Definition SDPatternMatch.h:1259

std::optional< ISD::CondCode > CCToMatch

Definition SDPatternMatch.h:1258

Definition SDPatternMatch.h:1105

ConstantInt_match(APInt *V)

Definition SDPatternMatch.h:1108

bool match(const MatchContext &, SDValue N)

Definition SDPatternMatch.h:1110

APInt * BindVal

Definition SDPatternMatch.h:1106

Definition SDPatternMatch.h:128

bool match(const MatchContext &, SDValue N)

Definition SDPatternMatch.h:133

SDValue & MatchVal

Definition SDPatternMatch.h:129

DeferredValue_match(SDValue &Match)

Definition SDPatternMatch.h:131

unsigned FirstIndex

Definition SDPatternMatch.h:502

EffectiveOperands(SDValue N, const MatchContext &Ctx)

Definition SDPatternMatch.h:505

unsigned Size

Definition SDPatternMatch.h:501

Provide number of operands that are not chain or glue, as well as the first index of such operand.

Definition SDPatternMatch.h:479

unsigned FirstIndex

Definition SDPatternMatch.h:481

EffectiveOperands(SDValue N, const MatchContext &Ctx)

Definition SDPatternMatch.h:484

unsigned Size

Definition SDPatternMatch.h:480

Definition SDPatternMatch.h:677

RHS_P RHS

Definition SDPatternMatch.h:680

MaxMin_match(const LHS_P &L, const RHS_P &R)

Definition SDPatternMatch.h:682

LHS_P LHS

Definition SDPatternMatch.h:679

Pred_t PredType

Definition SDPatternMatch.h:678

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:685

Definition SDPatternMatch.h:231

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:237

NUses_match(const Pattern &P)

Definition SDPatternMatch.h:234

Pattern P

Definition SDPatternMatch.h:232

Definition SDPatternMatch.h:193

Not(const Pred &P)

Definition SDPatternMatch.h:196

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:199

Pred P

Definition SDPatternMatch.h:194

Definition SDPatternMatch.h:1187

Ones_match(bool AllowUndefs)

Definition SDPatternMatch.h:1190

bool match(const MatchContext &, SDValue N)

Definition SDPatternMatch.h:1192

bool AllowUndefs

Definition SDPatternMatch.h:1188

Definition SDPatternMatch.h:147

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:153

Opcode_match(unsigned Opc)

Definition SDPatternMatch.h:150

unsigned Opcode

Definition SDPatternMatch.h:148

Operands_match(const OpndPred &p, const OpndPreds &...preds)

Definition SDPatternMatch.h:458

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:462

OpndPred P

Definition SDPatternMatch.h:456

Definition SDPatternMatch.h:444

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:446

Or(const Pred &p, const Preds &...preds)

Definition SDPatternMatch.h:185

Pred P

Definition SDPatternMatch.h:184

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:188

Definition SDPatternMatch.h:176

bool match(const MatchContext &, SDValue N)

Definition SDPatternMatch.h:177

Definition SDPatternMatch.h:1302

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:1310

unsigned Opcode

Definition SDPatternMatch.h:1303

void collectLeaves(SDValue V, SmallVector< SDValue > &Leaves)

Definition SDPatternMatch.h:1333

std::tuple< PatternTs... > Patterns

Definition SDPatternMatch.h:1304

ReassociatableOpc_match(unsigned Opcode, const PatternTs &...Patterns)

Definition SDPatternMatch.h:1306

bool reassociatableMatchHelper(ArrayRef< SmallBitVector > Matches, SmallBitVector &Used, size_t Curr=0)

Definition SDPatternMatch.h:1343

Definition SDPatternMatch.h:111

Pattern P

Definition SDPatternMatch.h:112

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:117

Result_match(const Pattern &P)

Definition SDPatternMatch.h:114

Matching while capturing mask.

Definition SDPatternMatch.h:643

T2 Mask

Definition SDPatternMatch.h:646

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:652

SDShuffle_match(const T0 &Op1, const T1 &Op2, const T2 &Mask)

Definition SDPatternMatch.h:648

T1 Op2

Definition SDPatternMatch.h:645

T0 Op1

Definition SDPatternMatch.h:644

Definition SDPatternMatch.h:1154

APFloat Val

Definition SDPatternMatch.h:1155

SpecificFP_match(APFloat V)

Definition SDPatternMatch.h:1157

bool match(const MatchContext &Ctx, SDValue V)

Definition SDPatternMatch.h:1160

Definition SDPatternMatch.h:1132

SpecificInt_match(APInt APV)

Definition SDPatternMatch.h:1135

APInt IntVal

Definition SDPatternMatch.h:1133

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:1138

Switch to a different MatchContext for subsequent patterns.

Definition SDPatternMatch.h:303

const NewMatchContext & Ctx

Definition SDPatternMatch.h:304

Pattern P

Definition SDPatternMatch.h:305

bool match(const OrigMatchContext &, SDValue N)

Definition SDPatternMatch.h:308

Definition SDPatternMatch.h:274

PredFuncT PredFunc

Definition SDPatternMatch.h:276

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:282

Pattern P

Definition SDPatternMatch.h:275

TLI_pred_match(const PredFuncT &Pred, const Pattern &P)

Definition SDPatternMatch.h:278

Definition SDPatternMatch.h:512

T1_P Op1

Definition SDPatternMatch.h:515

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:523

unsigned Opcode

Definition SDPatternMatch.h:513

TernaryOpc_match(unsigned Opc, const T0_P &Op0, const T1_P &Op1, const T2_P &Op2)

Definition SDPatternMatch.h:518

T2_P Op2

Definition SDPatternMatch.h:516

T0_P Op0

Definition SDPatternMatch.h:514

Definition SDPatternMatch.h:972

std::optional< SDNodeFlags > Flags

Definition SDPatternMatch.h:975

unsigned Opcode

Definition SDPatternMatch.h:973

UnaryOpc_match(unsigned Opc, const Opnd_P &Op, std::optional< SDNodeFlags > Flgs=std::nullopt)

Definition SDPatternMatch.h:976

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:981

Opnd_P Opnd

Definition SDPatternMatch.h:974

Definition SDPatternMatch.h:320

bool match(const MatchContext &, SDValue N)

Definition SDPatternMatch.h:325

EVT & BindVT

Definition SDPatternMatch.h:321

ValueType_bind(EVT &Bind)

Definition SDPatternMatch.h:323

Definition SDPatternMatch.h:334

PredFuncT PredFunc

Definition SDPatternMatch.h:335

ValueType_match(const PredFuncT &Pred, const Pattern &P)

Definition SDPatternMatch.h:338

bool match(const MatchContext &Ctx, SDValue N)

Definition SDPatternMatch.h:342

Pattern P

Definition SDPatternMatch.h:336

Definition SDPatternMatch.h:261

Value_bind(SDValue &N)

Definition SDPatternMatch.h:264

bool match(const MatchContext &, SDValue N)

Definition SDPatternMatch.h:266

SDValue & BindVal

Definition SDPatternMatch.h:262

Definition SDPatternMatch.h:89

bool match(const MatchContext &, SDValue N)

Definition SDPatternMatch.h:96

Value_match(SDValue Match)

Definition SDPatternMatch.h:94

SDValue MatchVal

Definition SDPatternMatch.h:90

Definition SDPatternMatch.h:1176

Zero_match(bool AllowUndefs)

Definition SDPatternMatch.h:1179

bool AllowUndefs

Definition SDPatternMatch.h:1177

bool match(const MatchContext &, SDValue N) const

Definition SDPatternMatch.h:1182

bool match(ArrayRef< int > Mask)

Definition SDPatternMatch.h:663

ArrayRef< int > & MaskRef

Definition SDPatternMatch.h:661

m_Mask(ArrayRef< int > &MaskRef)

Definition SDPatternMatch.h:662

m_SpecificMask(ArrayRef< int > MaskRef)

Definition SDPatternMatch.h:671

ArrayRef< int > MaskRef

Definition SDPatternMatch.h:670

bool match(ArrayRef< int > Mask)

Definition SDPatternMatch.h:672

Definition SDPatternMatch.h:737

static bool match(ISD::CondCode Cond)

Definition SDPatternMatch.h:738

Definition SDPatternMatch.h:751

static bool match(ISD::CondCode Cond)

Definition SDPatternMatch.h:752

Definition SDPatternMatch.h:744

static bool match(ISD::CondCode Cond)

Definition SDPatternMatch.h:745

Definition SDPatternMatch.h:758

static bool match(ISD::CondCode Cond)

Definition SDPatternMatch.h:759