LLVM  13.0.0git
MIPatternMatch.h
Go to the documentation of this file.
1 //==------ llvm/CodeGen/GlobalISel/MIPatternMatch.h -------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 /// \file
9 /// Contains matchers for matching SSA Machine Instructions.
10 ///
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CODEGEN_GLOBALISEL_MIPATTERNMATCH_H
14 #define LLVM_CODEGEN_GLOBALISEL_MIPATTERNMATCH_H
15 
18 #include "llvm/IR/InstrTypes.h"
19 
20 namespace llvm {
21 namespace MIPatternMatch {
22 
23 template <typename Reg, typename Pattern>
25  return P.match(MRI, R);
26 }
27 
28 // TODO: Extend for N use.
29 template <typename SubPatternT> struct OneUse_match {
30  SubPatternT SubPat;
31  OneUse_match(const SubPatternT &SP) : SubPat(SP) {}
32 
34  return MRI.hasOneUse(Reg) && SubPat.match(MRI, Reg);
35  }
36 };
37 
38 template <typename SubPat>
39 inline OneUse_match<SubPat> m_OneUse(const SubPat &SP) {
40  return SP;
41 }
42 
43 template <typename SubPatternT> struct OneNonDBGUse_match {
44  SubPatternT SubPat;
45  OneNonDBGUse_match(const SubPatternT &SP) : SubPat(SP) {}
46 
48  return MRI.hasOneNonDBGUse(Reg) && SubPat.match(MRI, Reg);
49  }
50 };
51 
52 template <typename SubPat>
53 inline OneNonDBGUse_match<SubPat> m_OneNonDBGUse(const SubPat &SP) {
54  return SP;
55 }
56 
57 struct ConstantMatch {
58  int64_t &CR;
59  ConstantMatch(int64_t &C) : CR(C) {}
61  if (auto MaybeCst = getConstantVRegSExtVal(Reg, MRI)) {
62  CR = *MaybeCst;
63  return true;
64  }
65  return false;
66  }
67 };
68 
69 inline ConstantMatch m_ICst(int64_t &Cst) { return ConstantMatch(Cst); }
70 
71 /// Matcher for a specific constant value.
73  int64_t RequestedVal;
76  int64_t MatchedVal;
77  return mi_match(Reg, MRI, m_ICst(MatchedVal)) && MatchedVal == RequestedVal;
78  }
79 };
80 
81 /// Matches a constant equal to \p RequestedValue.
82 inline SpecificConstantMatch m_SpecificICst(int64_t RequestedValue) {
83  return SpecificConstantMatch(RequestedValue);
84 }
85 
86 ///{
87 /// Convenience matchers for specific integer values.
90  return SpecificConstantMatch(-1);
91 }
92 ///}
93 
94 // TODO: Rework this for different kinds of MachineOperand.
95 // Currently assumes the Src for a match is a register.
96 // We might want to support taking in some MachineOperands and call getReg on
97 // that.
98 
100  bool match(const MachineRegisterInfo &MRI, Register Reg) { return true; }
102  return MO->isReg();
103  }
104 };
105 
107 
108 /// Matching combinators.
109 template <typename... Preds> struct And {
110  template <typename MatchSrc>
111  bool match(const MachineRegisterInfo &MRI, MatchSrc &&src) {
112  return true;
113  }
114 };
115 
116 template <typename Pred, typename... Preds>
117 struct And<Pred, Preds...> : And<Preds...> {
118  Pred P;
119  And(Pred &&p, Preds &&... preds)
120  : And<Preds...>(std::forward<Preds>(preds)...), P(std::forward<Pred>(p)) {
121  }
122  template <typename MatchSrc>
123  bool match(const MachineRegisterInfo &MRI, MatchSrc &&src) {
124  return P.match(MRI, src) && And<Preds...>::match(MRI, src);
125  }
126 };
127 
128 template <typename... Preds> struct Or {
129  template <typename MatchSrc>
130  bool match(const MachineRegisterInfo &MRI, MatchSrc &&src) {
131  return false;
132  }
133 };
134 
135 template <typename Pred, typename... Preds>
136 struct Or<Pred, Preds...> : Or<Preds...> {
137  Pred P;
138  Or(Pred &&p, Preds &&... preds)
139  : Or<Preds...>(std::forward<Preds>(preds)...), P(std::forward<Pred>(p)) {}
140  template <typename MatchSrc>
141  bool match(const MachineRegisterInfo &MRI, MatchSrc &&src) {
142  return P.match(MRI, src) || Or<Preds...>::match(MRI, src);
143  }
144 };
145 
146 template <typename... Preds> And<Preds...> m_all_of(Preds &&... preds) {
147  return And<Preds...>(std::forward<Preds>(preds)...);
148 }
149 
150 template <typename... Preds> Or<Preds...> m_any_of(Preds &&... preds) {
151  return Or<Preds...>(std::forward<Preds>(preds)...);
152 }
153 
154 template <typename BindTy> struct bind_helper {
155  static bool bind(const MachineRegisterInfo &MRI, BindTy &VR, BindTy &V) {
156  VR = V;
157  return true;
158  }
159 };
160 
161 template <> struct bind_helper<MachineInstr *> {
162  static bool bind(const MachineRegisterInfo &MRI, MachineInstr *&MI,
163  Register Reg) {
164  MI = MRI.getVRegDef(Reg);
165  if (MI)
166  return true;
167  return false;
168  }
169 };
170 
171 template <> struct bind_helper<LLT> {
172  static bool bind(const MachineRegisterInfo &MRI, LLT Ty, Register Reg) {
173  Ty = MRI.getType(Reg);
174  if (Ty.isValid())
175  return true;
176  return false;
177  }
178 };
179 
180 template <> struct bind_helper<const ConstantFP *> {
181  static bool bind(const MachineRegisterInfo &MRI, const ConstantFP *&F,
182  Register Reg) {
184  if (F)
185  return true;
186  return false;
187  }
188 };
189 
190 template <typename Class> struct bind_ty {
191  Class &VR;
192 
193  bind_ty(Class &V) : VR(V) {}
194 
195  template <typename ITy> bool match(const MachineRegisterInfo &MRI, ITy &&V) {
196  return bind_helper<Class>::bind(MRI, VR, V);
197  }
198 };
199 
200 inline bind_ty<Register> m_Reg(Register &R) { return R; }
202 inline bind_ty<LLT> m_Type(LLT Ty) { return Ty; }
205 
206 // Helper for matching G_FCONSTANT
207 inline bind_ty<const ConstantFP *> m_GFCst(const ConstantFP *&C) { return C; }
208 
209 // General helper for all the binary generic MI such as G_ADD/G_SUB etc
210 template <typename LHS_P, typename RHS_P, unsigned Opcode,
211  bool Commutable = false>
213  LHS_P L;
214  RHS_P R;
215 
216  BinaryOp_match(const LHS_P &LHS, const RHS_P &RHS) : L(LHS), R(RHS) {}
217  template <typename OpTy>
218  bool match(const MachineRegisterInfo &MRI, OpTy &&Op) {
219  MachineInstr *TmpMI;
220  if (mi_match(Op, MRI, m_MInstr(TmpMI))) {
221  if (TmpMI->getOpcode() == Opcode && TmpMI->getNumOperands() == 3) {
222  return (L.match(MRI, TmpMI->getOperand(1).getReg()) &&
223  R.match(MRI, TmpMI->getOperand(2).getReg())) ||
224  (Commutable && (R.match(MRI, TmpMI->getOperand(1).getReg()) &&
225  L.match(MRI, TmpMI->getOperand(2).getReg())));
226  }
227  }
228  return false;
229  }
230 };
231 
232 template <typename LHS, typename RHS>
233 inline BinaryOp_match<LHS, RHS, TargetOpcode::G_ADD, true>
234 m_GAdd(const LHS &L, const RHS &R) {
236 }
237 
238 template <typename LHS, typename RHS>
239 inline BinaryOp_match<LHS, RHS, TargetOpcode::G_PTR_ADD, true>
240 m_GPtrAdd(const LHS &L, const RHS &R) {
242 }
243 
244 template <typename LHS, typename RHS>
246  const RHS &R) {
248 }
249 
250 template <typename LHS, typename RHS>
251 inline BinaryOp_match<LHS, RHS, TargetOpcode::G_MUL, true>
252 m_GMul(const LHS &L, const RHS &R) {
254 }
255 
256 template <typename LHS, typename RHS>
257 inline BinaryOp_match<LHS, RHS, TargetOpcode::G_FADD, true>
258 m_GFAdd(const LHS &L, const RHS &R) {
260 }
261 
262 template <typename LHS, typename RHS>
263 inline BinaryOp_match<LHS, RHS, TargetOpcode::G_FMUL, true>
264 m_GFMul(const LHS &L, const RHS &R) {
266 }
267 
268 template <typename LHS, typename RHS>
269 inline BinaryOp_match<LHS, RHS, TargetOpcode::G_FSUB, false>
270 m_GFSub(const LHS &L, const RHS &R) {
272 }
273 
274 template <typename LHS, typename RHS>
275 inline BinaryOp_match<LHS, RHS, TargetOpcode::G_AND, true>
276 m_GAnd(const LHS &L, const RHS &R) {
278 }
279 
280 template <typename LHS, typename RHS>
281 inline BinaryOp_match<LHS, RHS, TargetOpcode::G_XOR, true>
282 m_GXor(const LHS &L, const RHS &R) {
284 }
285 
286 template <typename LHS, typename RHS>
288  const RHS &R) {
290 }
291 
292 template <typename LHS, typename RHS>
293 inline BinaryOp_match<LHS, RHS, TargetOpcode::G_SHL, false>
294 m_GShl(const LHS &L, const RHS &R) {
296 }
297 
298 template <typename LHS, typename RHS>
299 inline BinaryOp_match<LHS, RHS, TargetOpcode::G_LSHR, false>
300 m_GLShr(const LHS &L, const RHS &R) {
302 }
303 
304 template <typename LHS, typename RHS>
305 inline BinaryOp_match<LHS, RHS, TargetOpcode::G_ASHR, false>
306 m_GAShr(const LHS &L, const RHS &R) {
308 }
309 
310 template <typename LHS, typename RHS>
311 inline BinaryOp_match<LHS, RHS, TargetOpcode::G_SMAX, false>
312 m_GSMax(const LHS &L, const RHS &R) {
314 }
315 
316 template <typename LHS, typename RHS>
317 inline BinaryOp_match<LHS, RHS, TargetOpcode::G_SMIN, false>
318 m_GSMin(const LHS &L, const RHS &R) {
320 }
321 
322 // Helper for unary instructions (G_[ZSA]EXT/G_TRUNC) etc
323 template <typename SrcTy, unsigned Opcode> struct UnaryOp_match {
324  SrcTy L;
325 
326  UnaryOp_match(const SrcTy &LHS) : L(LHS) {}
327  template <typename OpTy>
328  bool match(const MachineRegisterInfo &MRI, OpTy &&Op) {
329  MachineInstr *TmpMI;
330  if (mi_match(Op, MRI, m_MInstr(TmpMI))) {
331  if (TmpMI->getOpcode() == Opcode && TmpMI->getNumOperands() == 2) {
332  return L.match(MRI, TmpMI->getOperand(1).getReg());
333  }
334  }
335  return false;
336  }
337 };
338 
339 template <typename SrcTy>
340 inline UnaryOp_match<SrcTy, TargetOpcode::G_ANYEXT>
341 m_GAnyExt(const SrcTy &Src) {
343 }
344 
345 template <typename SrcTy>
348 }
349 
350 template <typename SrcTy>
353 }
354 
355 template <typename SrcTy>
358 }
359 
360 template <typename SrcTy>
363 }
364 
365 template <typename SrcTy>
366 inline UnaryOp_match<SrcTy, TargetOpcode::G_BITCAST>
367 m_GBitcast(const SrcTy &Src) {
369 }
370 
371 template <typename SrcTy>
372 inline UnaryOp_match<SrcTy, TargetOpcode::G_PTRTOINT>
373 m_GPtrToInt(const SrcTy &Src) {
375 }
376 
377 template <typename SrcTy>
378 inline UnaryOp_match<SrcTy, TargetOpcode::G_INTTOPTR>
379 m_GIntToPtr(const SrcTy &Src) {
381 }
382 
383 template <typename SrcTy>
384 inline UnaryOp_match<SrcTy, TargetOpcode::G_FPTRUNC>
385 m_GFPTrunc(const SrcTy &Src) {
387 }
388 
389 template <typename SrcTy>
392 }
393 
394 template <typename SrcTy>
397 }
398 
399 template <typename SrcTy>
401  return UnaryOp_match<SrcTy, TargetOpcode::COPY>(std::forward<SrcTy>(Src));
402 }
403 
404 // General helper for generic MI compares, i.e. G_ICMP and G_FCMP
405 // TODO: Allow checking a specific predicate.
406 template <typename Pred_P, typename LHS_P, typename RHS_P, unsigned Opcode>
408  Pred_P P;
409  LHS_P L;
410  RHS_P R;
411 
412  CompareOp_match(const Pred_P &Pred, const LHS_P &LHS, const RHS_P &RHS)
413  : P(Pred), L(LHS), R(RHS) {}
414 
415  template <typename OpTy>
416  bool match(const MachineRegisterInfo &MRI, OpTy &&Op) {
417  MachineInstr *TmpMI;
418  if (!mi_match(Op, MRI, m_MInstr(TmpMI)) || TmpMI->getOpcode() != Opcode)
419  return false;
420 
421  auto TmpPred =
422  static_cast<CmpInst::Predicate>(TmpMI->getOperand(1).getPredicate());
423  if (!P.match(MRI, TmpPred))
424  return false;
425 
426  return L.match(MRI, TmpMI->getOperand(2).getReg()) &&
427  R.match(MRI, TmpMI->getOperand(3).getReg());
428  }
429 };
430 
431 template <typename Pred, typename LHS, typename RHS>
432 inline CompareOp_match<Pred, LHS, RHS, TargetOpcode::G_ICMP>
433 m_GICmp(const Pred &P, const LHS &L, const RHS &R) {
435 }
436 
437 template <typename Pred, typename LHS, typename RHS>
438 inline CompareOp_match<Pred, LHS, RHS, TargetOpcode::G_FCMP>
439 m_GFCmp(const Pred &P, const LHS &L, const RHS &R) {
441 }
442 
443 // Helper for checking if a Reg is of specific type.
444 struct CheckType {
446  CheckType(const LLT Ty) : Ty(Ty) {}
447 
449  return MRI.getType(Reg) == Ty;
450  }
451 };
452 
453 inline CheckType m_SpecificType(LLT Ty) { return Ty; }
454 
455 template <typename Src0Ty, typename Src1Ty, typename Src2Ty, unsigned Opcode>
457  Src0Ty Src0;
458  Src1Ty Src1;
459  Src2Ty Src2;
460 
461  TernaryOp_match(const Src0Ty &Src0, const Src1Ty &Src1, const Src2Ty &Src2)
462  : Src0(Src0), Src1(Src1), Src2(Src2) {}
463  template <typename OpTy>
464  bool match(const MachineRegisterInfo &MRI, OpTy &&Op) {
465  MachineInstr *TmpMI;
466  if (mi_match(Op, MRI, m_MInstr(TmpMI))) {
467  if (TmpMI->getOpcode() == Opcode && TmpMI->getNumOperands() == 4) {
468  return (Src0.match(MRI, TmpMI->getOperand(1).getReg()) &&
469  Src1.match(MRI, TmpMI->getOperand(2).getReg()) &&
470  Src2.match(MRI, TmpMI->getOperand(3).getReg()));
471  }
472  }
473  return false;
474  }
475 };
476 template <typename Src0Ty, typename Src1Ty, typename Src2Ty>
477 inline TernaryOp_match<Src0Ty, Src1Ty, Src2Ty,
478  TargetOpcode::G_INSERT_VECTOR_ELT>
479 m_GInsertVecElt(const Src0Ty &Src0, const Src1Ty &Src1, const Src2Ty &Src2) {
480  return TernaryOp_match<Src0Ty, Src1Ty, Src2Ty,
481  TargetOpcode::G_INSERT_VECTOR_ELT>(Src0, Src1, Src2);
482 }
483 
484 template <typename Src0Ty, typename Src1Ty, typename Src2Ty>
485 inline TernaryOp_match<Src0Ty, Src1Ty, Src2Ty, TargetOpcode::G_SELECT>
486 m_GISelect(const Src0Ty &Src0, const Src1Ty &Src1, const Src2Ty &Src2) {
488  Src0, Src1, Src2);
489 }
490 
491 /// Matches a register negated by a G_SUB.
492 /// G_SUB 0, %negated_reg
493 template <typename SrcTy>
494 inline BinaryOp_match<SpecificConstantMatch, SrcTy, TargetOpcode::G_SUB>
495 m_Neg(const SrcTy &&Src) {
496  return m_GSub(m_ZeroInt(), Src);
497 }
498 
499 /// Matches a register not-ed by a G_XOR.
500 /// G_XOR %not_reg, -1
501 template <typename SrcTy>
502 inline BinaryOp_match<SrcTy, SpecificConstantMatch, TargetOpcode::G_XOR, true>
503 m_Not(const SrcTy &&Src) {
504  return m_GXor(Src, m_AllOnesInt());
505 }
506 
507 } // namespace MIPatternMatch
508 } // namespace llvm
509 
510 #endif
llvm::MIPatternMatch::CheckType
Definition: MIPatternMatch.h:444
llvm::MIPatternMatch::operand_type_match::match
bool match(const MachineRegisterInfo &MRI, MachineOperand *MO)
Definition: MIPatternMatch.h:101
llvm::MIPatternMatch::TernaryOp_match::match
bool match(const MachineRegisterInfo &MRI, OpTy &&Op)
Definition: MIPatternMatch.h:464
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:100
llvm
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
llvm::MIPatternMatch::bind_helper< LLT >::bind
static bool bind(const MachineRegisterInfo &MRI, LLT Ty, Register Reg)
Definition: MIPatternMatch.h:172
llvm::MIPatternMatch::UnaryOp_match::UnaryOp_match
UnaryOp_match(const SrcTy &LHS)
Definition: MIPatternMatch.h:326
llvm::CmpInst::Predicate
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:722
llvm::MIPatternMatch::m_GFPExt
UnaryOp_match< SrcTy, TargetOpcode::G_FPEXT > m_GFPExt(const SrcTy &Src)
Definition: MIPatternMatch.h:356
llvm::MIPatternMatch::m_GFNeg
UnaryOp_match< SrcTy, TargetOpcode::G_FNEG > m_GFNeg(const SrcTy &Src)
Definition: MIPatternMatch.h:395
llvm::MIPatternMatch::m_Reg
operand_type_match m_Reg()
Definition: MIPatternMatch.h:106
llvm::MIPatternMatch::ConstantMatch::ConstantMatch
ConstantMatch(int64_t &C)
Definition: MIPatternMatch.h:59
llvm::MIPatternMatch::m_GAnd
BinaryOp_match< LHS, RHS, TargetOpcode::G_AND, true > m_GAnd(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:276
llvm::MIPatternMatch::m_GShl
BinaryOp_match< LHS, RHS, TargetOpcode::G_SHL, false > m_GShl(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:294
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:52
llvm::MIPatternMatch::Or< Pred, Preds... >::P
Pred P
Definition: MIPatternMatch.h:137
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::MIPatternMatch::m_GLShr
BinaryOp_match< LHS, RHS, TargetOpcode::G_LSHR, false > m_GLShr(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:300
llvm::MIPatternMatch::UnaryOp_match::L
SrcTy L
Definition: MIPatternMatch.h:324
llvm::MCID::Commutable
@ Commutable
Definition: MCInstrDesc.h:172
llvm::MIPatternMatch::m_OneNonDBGUse
OneNonDBGUse_match< SubPat > m_OneNonDBGUse(const SubPat &SP)
Definition: MIPatternMatch.h:53
llvm::MIPatternMatch::m_GSub
BinaryOp_match< LHS, RHS, TargetOpcode::G_SUB > m_GSub(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:245
llvm::MIPatternMatch::m_GTrunc
UnaryOp_match< SrcTy, TargetOpcode::G_TRUNC > m_GTrunc(const SrcTy &Src)
Definition: MIPatternMatch.h:361
llvm::MIPatternMatch::m_GFSub
BinaryOp_match< LHS, RHS, TargetOpcode::G_FSUB, false > m_GFSub(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:270
llvm::MIPatternMatch::m_GSMax
BinaryOp_match< LHS, RHS, TargetOpcode::G_SMAX, false > m_GSMax(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:312
llvm::MIPatternMatch::CheckType::CheckType
CheckType(const LLT Ty)
Definition: MIPatternMatch.h:446
llvm::MIPatternMatch::m_GICmp
CompareOp_match< Pred, LHS, RHS, TargetOpcode::G_ICMP > m_GICmp(const Pred &P, const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:433
llvm::LLT::isValid
bool isValid() const
Definition: LowLevelTypeImpl.h:90
llvm::MIPatternMatch::m_GFAdd
BinaryOp_match< LHS, RHS, TargetOpcode::G_FADD, true > m_GFAdd(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:258
llvm::MIPatternMatch::m_GSMin
BinaryOp_match< LHS, RHS, TargetOpcode::G_SMIN, false > m_GSMin(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:318
llvm::MIPatternMatch::bind_ty::match
bool match(const MachineRegisterInfo &MRI, ITy &&V)
Definition: MIPatternMatch.h:195
llvm::MIPatternMatch::SpecificConstantMatch::RequestedVal
int64_t RequestedVal
Definition: MIPatternMatch.h:73
preds
preds
Definition: README.txt:340
p
the resulting code requires compare and branches when and if * p
Definition: README.txt:396
llvm::MIPatternMatch::BinaryOp_match::R
RHS_P R
Definition: MIPatternMatch.h:214
llvm::MIPatternMatch::BinaryOp_match::L
LHS_P L
Definition: MIPatternMatch.h:213
llvm::MIPatternMatch::m_GPtrToInt
UnaryOp_match< SrcTy, TargetOpcode::G_PTRTOINT > m_GPtrToInt(const SrcTy &Src)
Definition: MIPatternMatch.h:373
llvm::MIPatternMatch::m_GFabs
UnaryOp_match< SrcTy, TargetOpcode::G_FABS > m_GFabs(const SrcTy &Src)
Definition: MIPatternMatch.h:390
F
#define F(x, y, z)
Definition: MD5.cpp:56
MachineRegisterInfo.h
llvm::MIPatternMatch::operand_type_match::match
bool match(const MachineRegisterInfo &MRI, Register Reg)
Definition: MIPatternMatch.h:100
llvm::MIPatternMatch::OneNonDBGUse_match
Definition: MIPatternMatch.h:43
llvm::MIPatternMatch::ConstantMatch::match
bool match(const MachineRegisterInfo &MRI, Register Reg)
Definition: MIPatternMatch.h:60
llvm::MIPatternMatch::m_GSExt
UnaryOp_match< SrcTy, TargetOpcode::G_SEXT > m_GSExt(const SrcTy &Src)
Definition: MIPatternMatch.h:346
llvm::MIPatternMatch::m_GMul
BinaryOp_match< LHS, RHS, TargetOpcode::G_MUL, true > m_GMul(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:252
llvm::MIPatternMatch::ConstantMatch
Definition: MIPatternMatch.h:57
llvm::MIPatternMatch::TernaryOp_match::TernaryOp_match
TernaryOp_match(const Src0Ty &Src0, const Src1Ty &Src1, const Src2Ty &Src2)
Definition: MIPatternMatch.h:461
llvm::MIPatternMatch::m_GZExt
UnaryOp_match< SrcTy, TargetOpcode::G_ZEXT > m_GZExt(const SrcTy &Src)
Definition: MIPatternMatch.h:351
llvm::MIPatternMatch::OneNonDBGUse_match::OneNonDBGUse_match
OneNonDBGUse_match(const SubPatternT &SP)
Definition: MIPatternMatch.h:45
llvm::MIPatternMatch::m_GPtrAdd
BinaryOp_match< LHS, RHS, TargetOpcode::G_PTR_ADD, true > m_GPtrAdd(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:240
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::MachineInstr::getOperand
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:488
llvm::MIPatternMatch::Or::match
bool match(const MachineRegisterInfo &MRI, MatchSrc &&src)
Definition: MIPatternMatch.h:130
llvm::MIPatternMatch::SpecificConstantMatch::match
bool match(const MachineRegisterInfo &MRI, Register Reg)
Definition: MIPatternMatch.h:75
InstrTypes.h
Utils.h
llvm::MIPatternMatch::bind_ty
Definition: MIPatternMatch.h:190
llvm::MIPatternMatch::m_GIntToPtr
UnaryOp_match< SrcTy, TargetOpcode::G_INTTOPTR > m_GIntToPtr(const SrcTy &Src)
Definition: MIPatternMatch.h:379
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:49
llvm::MIPatternMatch::m_ZeroInt
SpecificConstantMatch m_ZeroInt()
{ Convenience matchers for specific integer values.
Definition: MIPatternMatch.h:88
llvm::MIPatternMatch::Or< Pred, Preds... >::match
bool match(const MachineRegisterInfo &MRI, MatchSrc &&src)
Definition: MIPatternMatch.h:141
llvm::ConstantFP
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:255
llvm::MIPatternMatch::Or< Pred, Preds... >::Or
Or(Pred &&p, Preds &&... preds)
Definition: MIPatternMatch.h:138
llvm::MIPatternMatch::bind_helper< MachineInstr * >::bind
static bool bind(const MachineRegisterInfo &MRI, MachineInstr *&MI, Register Reg)
Definition: MIPatternMatch.h:162
llvm::MIPatternMatch::m_SpecificICst
SpecificConstantMatch m_SpecificICst(int64_t RequestedValue)
Matches a constant equal to RequestedValue.
Definition: MIPatternMatch.h:82
llvm::MIPatternMatch::OneUse_match::OneUse_match
OneUse_match(const SubPatternT &SP)
Definition: MIPatternMatch.h:31
llvm::MIPatternMatch::UnaryOp_match::match
bool match(const MachineRegisterInfo &MRI, OpTy &&Op)
Definition: MIPatternMatch.h:328
llvm::MIPatternMatch::m_MInstr
bind_ty< MachineInstr * > m_MInstr(MachineInstr *&MI)
Definition: MIPatternMatch.h:201
llvm::MIPatternMatch::m_Pred
bind_ty< CmpInst::Predicate > m_Pred(CmpInst::Predicate &P)
Definition: MIPatternMatch.h:203
llvm::MIPatternMatch::m_SpecificType
CheckType m_SpecificType(LLT Ty)
Definition: MIPatternMatch.h:453
llvm::MIPatternMatch::UnaryOp_match
Definition: MIPatternMatch.h:323
llvm::MIPatternMatch::m_GAnyExt
UnaryOp_match< SrcTy, TargetOpcode::G_ANYEXT > m_GAnyExt(const SrcTy &Src)
Definition: MIPatternMatch.h:341
llvm::MIPatternMatch::CompareOp_match::match
bool match(const MachineRegisterInfo &MRI, OpTy &&Op)
Definition: MIPatternMatch.h:416
llvm::MIPatternMatch::SpecificConstantMatch::SpecificConstantMatch
SpecificConstantMatch(int64_t RequestedVal)
Definition: MIPatternMatch.h:74
llvm::MIPatternMatch::m_GOr
BinaryOp_match< LHS, RHS, TargetOpcode::G_OR, true > m_GOr(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:287
llvm::MachineOperand::isReg
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Definition: MachineOperand.h:318
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:64
llvm::MIPatternMatch::BinaryOp_match
Definition: MIPatternMatch.h:212
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
llvm::MIPatternMatch::OneNonDBGUse_match::SubPat
SubPatternT SubPat
Definition: MIPatternMatch.h:44
llvm::MIPatternMatch::And< Pred, Preds... >::match
bool match(const MachineRegisterInfo &MRI, MatchSrc &&src)
Definition: MIPatternMatch.h:123
llvm::MIPatternMatch::bind_ty::VR
Class & VR
Definition: MIPatternMatch.h:191
llvm::MIPatternMatch::Or
Definition: MIPatternMatch.h:128
llvm::MIPatternMatch::m_AllOnesInt
SpecificConstantMatch m_AllOnesInt()
Definition: MIPatternMatch.h:89
llvm::MIPatternMatch::And
Matching combinators.
Definition: MIPatternMatch.h:109
llvm::MIPatternMatch::CheckType::match
bool match(const MachineRegisterInfo &MRI, Register Reg)
Definition: MIPatternMatch.h:448
llvm::MachineOperand::getPredicate
unsigned getPredicate() const
Definition: MachineOperand.h:585
llvm::getConstantVRegSExtVal
Optional< int64_t > getConstantVRegSExtVal(Register VReg, const MachineRegisterInfo &MRI)
If VReg is defined by a G_CONSTANT fits in int64_t returns it.
Definition: Utils.cpp:281
llvm::MIPatternMatch::m_Type
bind_ty< LLT > m_Type(LLT Ty)
Definition: MIPatternMatch.h:202
llvm::MachineOperand::getReg
Register getReg() const
getReg - Returns the register number.
Definition: MachineOperand.h:357
llvm::MIPatternMatch::OneNonDBGUse_match::match
bool match(const MachineRegisterInfo &MRI, Register Reg)
Definition: MIPatternMatch.h:47
llvm::MIPatternMatch::bind_ty::bind_ty
bind_ty(Class &V)
Definition: MIPatternMatch.h:193
llvm::MIPatternMatch::TernaryOp_match::Src2
Src2Ty Src2
Definition: MIPatternMatch.h:459
llvm::MIPatternMatch::m_GFCst
bind_ty< const ConstantFP * > m_GFCst(const ConstantFP *&C)
Definition: MIPatternMatch.h:207
llvm::MIPatternMatch::BinaryOp_match::match
bool match(const MachineRegisterInfo &MRI, OpTy &&Op)
Definition: MIPatternMatch.h:218
llvm::MachineInstr::getOpcode
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:478
llvm::MIPatternMatch::m_any_of
Or< Preds... > m_any_of(Preds &&... preds)
Definition: MIPatternMatch.h:150
llvm::MIPatternMatch::m_GXor
BinaryOp_match< LHS, RHS, TargetOpcode::G_XOR, true > m_GXor(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:282
llvm::MIPatternMatch::TernaryOp_match::Src1
Src1Ty Src1
Definition: MIPatternMatch.h:458
llvm::MIPatternMatch::bind_helper::bind
static bool bind(const MachineRegisterInfo &MRI, BindTy &VR, BindTy &V)
Definition: MIPatternMatch.h:155
llvm::MIPatternMatch::m_Copy
UnaryOp_match< SrcTy, TargetOpcode::COPY > m_Copy(SrcTy &&Src)
Definition: MIPatternMatch.h:400
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::MIPatternMatch::m_GAShr
BinaryOp_match< LHS, RHS, TargetOpcode::G_ASHR, false > m_GAShr(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:306
llvm::MIPatternMatch::And::match
bool match(const MachineRegisterInfo &MRI, MatchSrc &&src)
Definition: MIPatternMatch.h:111
std
Definition: BitVector.h:838
llvm::MIPatternMatch::m_GFCmp
CompareOp_match< Pred, LHS, RHS, TargetOpcode::G_FCMP > m_GFCmp(const Pred &P, const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:439
llvm::MIPatternMatch::m_GAdd
BinaryOp_match< LHS, RHS, TargetOpcode::G_ADD, true > m_GAdd(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:234
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:314
llvm::MIPatternMatch::CompareOp_match::P
Pred_P P
Definition: MIPatternMatch.h:408
llvm::MIPatternMatch::CompareOp_match
Definition: MIPatternMatch.h:407
llvm::MIPatternMatch::And< Pred, Preds... >::P
Pred P
Definition: MIPatternMatch.h:118
llvm::MIPatternMatch::m_GISelect
TernaryOp_match< Src0Ty, Src1Ty, Src2Ty, TargetOpcode::G_SELECT > m_GISelect(const Src0Ty &Src0, const Src1Ty &Src1, const Src2Ty &Src2)
Definition: MIPatternMatch.h:486
llvm::MIPatternMatch::CompareOp_match::L
LHS_P L
Definition: MIPatternMatch.h:409
llvm::MIPatternMatch::m_ICst
ConstantMatch m_ICst(int64_t &Cst)
Definition: MIPatternMatch.h:69
llvm::MIPatternMatch::bind_helper
Definition: MIPatternMatch.h:154
llvm::MIPatternMatch::OneUse_match::SubPat
SubPatternT SubPat
Definition: MIPatternMatch.h:30
llvm::MIPatternMatch::CompareOp_match::CompareOp_match
CompareOp_match(const Pred_P &Pred, const LHS_P &LHS, const RHS_P &RHS)
Definition: MIPatternMatch.h:412
llvm::Pattern
Definition: FileCheckImpl.h:614
llvm::MIPatternMatch::bind_helper< const ConstantFP * >::bind
static bool bind(const MachineRegisterInfo &MRI, const ConstantFP *&F, Register Reg)
Definition: MIPatternMatch.h:181
llvm::MIPatternMatch::m_GFPTrunc
UnaryOp_match< SrcTy, TargetOpcode::G_FPTRUNC > m_GFPTrunc(const SrcTy &Src)
Definition: MIPatternMatch.h:385
llvm::MIPatternMatch::m_GBitcast
UnaryOp_match< SrcTy, TargetOpcode::G_BITCAST > m_GBitcast(const SrcTy &Src)
Definition: MIPatternMatch.h:367
llvm::MIPatternMatch::operand_type_match
}
Definition: MIPatternMatch.h:99
llvm::MachineInstr::getNumOperands
unsigned getNumOperands() const
Retuns the total number of operands.
Definition: MachineInstr.h:481
llvm::MIPatternMatch::m_GFMul
BinaryOp_match< LHS, RHS, TargetOpcode::G_FMUL, true > m_GFMul(const LHS &L, const RHS &R)
Definition: MIPatternMatch.h:264
llvm::MIPatternMatch::m_Neg
BinaryOp_match< SpecificConstantMatch, SrcTy, TargetOpcode::G_SUB > m_Neg(const SrcTy &&Src)
Matches a register negated by a G_SUB.
Definition: MIPatternMatch.h:495
llvm::MIPatternMatch::OneUse_match
Definition: MIPatternMatch.h:29
llvm::MIPatternMatch::BinaryOp_match::BinaryOp_match
BinaryOp_match(const LHS_P &LHS, const RHS_P &RHS)
Definition: MIPatternMatch.h:216
llvm::getConstantFPVRegVal
const ConstantFP * getConstantFPVRegVal(Register VReg, const MachineRegisterInfo &MRI)
Definition: Utils.cpp:369
llvm::MIPatternMatch::m_all_of
And< Preds... > m_all_of(Preds &&... preds)
Definition: MIPatternMatch.h:146
llvm::MIPatternMatch::CheckType::Ty
LLT Ty
Definition: MIPatternMatch.h:445
llvm::MIPatternMatch::m_Not
BinaryOp_match< SrcTy, SpecificConstantMatch, TargetOpcode::G_XOR, true > m_Not(const SrcTy &&Src)
Matches a register not-ed by a G_XOR.
Definition: MIPatternMatch.h:503
llvm::MIPatternMatch::OneUse_match::match
bool match(const MachineRegisterInfo &MRI, Register Reg)
Definition: MIPatternMatch.h:33
llvm::MIPatternMatch::mi_match
bool mi_match(Reg R, const MachineRegisterInfo &MRI, Pattern &&P)
Definition: MIPatternMatch.h:24
llvm::MIPatternMatch::TernaryOp_match
Definition: MIPatternMatch.h:456
llvm::MIPatternMatch::TernaryOp_match::Src0
Src0Ty Src0
Definition: MIPatternMatch.h:457
llvm::MIPatternMatch::m_GInsertVecElt
TernaryOp_match< Src0Ty, Src1Ty, Src2Ty, TargetOpcode::G_INSERT_VECTOR_ELT > m_GInsertVecElt(const Src0Ty &Src0, const Src1Ty &Src1, const Src2Ty &Src2)
Definition: MIPatternMatch.h:479
llvm::MIPatternMatch::m_OneUse
OneUse_match< SubPat > m_OneUse(const SubPat &SP)
Definition: MIPatternMatch.h:39
llvm::MIPatternMatch::SpecificConstantMatch
Matcher for a specific constant value.
Definition: MIPatternMatch.h:72
llvm::MIPatternMatch::ConstantMatch::CR
int64_t & CR
Definition: MIPatternMatch.h:58
llvm::MIPatternMatch::And< Pred, Preds... >::And
And(Pred &&p, Preds &&... preds)
Definition: MIPatternMatch.h:119
llvm::MIPatternMatch::CompareOp_match::R
RHS_P R
Definition: MIPatternMatch.h:410
llvm::LLT
Definition: LowLevelTypeImpl.h:40