29 #ifndef LLVM_IR_PATTERNMATCH_H
30 #define LLVM_IR_PATTERNMATCH_H
47 namespace PatternMatch {
49 template <
typename Val,
typename Pattern>
bool match(Val *V,
const Pattern &
P) {
50 return const_cast<Pattern &
>(
P).
match(V);
58 template <
typename OpTy>
bool match(OpTy *V) {
68 template <
typename ITy>
bool match(ITy *V) {
return isa<Class>(V); }
100 template <
typename ITy>
bool match(ITy *V) {
115 template <
typename ITy>
bool match(ITy *V) {
124 template <
typename LTy,
typename RTy>
130 template <
typename LTy,
typename RTy>
136 template <
typename ITy>
bool match(ITy *V) {
137 if (
const auto *
C = dyn_cast<Constant>(V))
138 return C->isNullValue();
148 template <
typename ITy>
bool match(ITy *V) {
149 if (
const auto *
C = dyn_cast<Constant>(V))
150 return C->isNegativeZeroValue();
162 template <
typename ITy>
bool match(ITy *V) {
163 if (
const auto *
C = dyn_cast<Constant>(V))
164 return C->isZeroValue();
175 template <
typename ITy>
bool match(ITy *V) {
176 if (
const auto *
C = dyn_cast<ConstantFP>(V))
186 template <
typename ITy>
bool match(ITy *V) {
187 if (
const auto *
C = dyn_cast<Constant>(V))
188 return C->isOneValue();
197 template <
typename ITy>
bool match(ITy *V) {
198 if (
const auto *
C = dyn_cast<Constant>(V))
199 return C->isAllOnesValue();
208 template <
typename ITy>
bool match(ITy *V) {
209 if (
const auto *
C = dyn_cast<Constant>(V))
210 return C->isMinSignedValue();
223 template <
typename ITy>
bool match(ITy *V) {
224 if (
auto *CI = dyn_cast<ConstantInt>(V)) {
225 Res = &CI->getValue();
228 if (V->getType()->isVectorTy())
229 if (
const auto *
C = dyn_cast<Constant>(V))
230 if (
auto *CI = dyn_cast_or_null<ConstantInt>(
C->getSplatValue())) {
231 Res = &CI->getValue();
243 template <
typename ITy>
bool match(ITy *V) {
244 if (
const auto *CI = dyn_cast<ConstantInt>(V)) {
245 const APInt &CIV = CI->getValue();
247 return CIV ==
static_cast<uint64_t
>(Val);
258 template <
int64_t Val>
inline constantint_match<Val>
m_ConstantInt() {
259 return constantint_match<Val>();
265 template <
typename ITy>
bool match(ITy *V) {
266 if (
const auto *CI = dyn_cast<ConstantInt>(V))
267 return this->isValue(CI->getValue());
268 if (V->getType()->isVectorTy())
269 if (
const auto *
C = dyn_cast<Constant>(V))
270 if (
const auto *CI = dyn_cast_or_null<ConstantInt>(
C->getSplatValue()))
271 return this->isValue(CI->getValue());
283 template <
typename ITy>
bool match(ITy *V) {
284 if (
const auto *CI = dyn_cast<ConstantInt>(V))
285 if (this->isValue(CI->getValue())) {
286 Res = &CI->getValue();
289 if (V->getType()->isVectorTy())
290 if (
const auto *
C = dyn_cast<Constant>(V))
291 if (
auto *CI = dyn_cast_or_null<ConstantInt>(
C->getSplatValue()))
292 if (this->isValue(CI->getValue())) {
293 Res = &CI->getValue();
321 template <
typename ITy>
bool match(ITy *V) {
322 if (
auto *CV = dyn_cast<Class>(V)) {
354 template <
typename ITy>
bool match(ITy *V) {
return V ==
Val; }
367 template <
typename ITy>
bool match(ITy *V) {
368 if (
const auto *CFP = dyn_cast<ConstantFP>(V))
369 return CFP->isExactlyValue(
Val);
370 if (V->getType()->isVectorTy())
371 if (
const auto *
C = dyn_cast<Constant>(V))
372 if (
auto *CFP = dyn_cast_or_null<ConstantFP>(
C->getSplatValue()))
373 return CFP->isExactlyValue(
Val);
390 template <
typename ITy>
bool match(ITy *V) {
391 if (
const auto *CV = dyn_cast<ConstantInt>(V))
392 if (CV->getValue().ule(UINT64_MAX)) {
393 VR = CV->getZExtValue();
407 template <
typename ITy>
bool match(ITy *V) {
409 if (!CI && V->getType()->isVectorTy())
410 if (
const auto *
C = dyn_cast<Constant>(V))
411 CI = dyn_cast_or_null<ConstantInt>(
C->getSplatValue());
428 template <
typename LHS_t,
typename RHS_t,
bool Commutable = false>
435 template <
typename OpTy>
bool match(OpTy *V) {
436 if (
auto *
I = dyn_cast<BinaryOperator>(V))
437 return (
L.match(
I->getOperand(0)) &&
R.match(
I->getOperand(1))) ||
439 L.match(
I->getOperand(1)));
444 template <
typename LHS,
typename RHS>
453 template <
typename LHS_t,
typename RHS_t,
unsigned Opcode,
461 template <
typename OpTy>
bool match(OpTy *V) {
462 if (V->getValueID() == Value::InstructionVal + Opcode) {
463 auto *
I = cast<BinaryOperator>(V);
464 return (
L.match(
I->getOperand(0)) &&
R.match(
I->getOperand(1))) ||
466 L.match(
I->getOperand(1)));
468 if (
auto *CE = dyn_cast<ConstantExpr>(V))
469 return CE->getOpcode() == Opcode &&
470 ((
L.match(CE->getOperand(0)) &&
R.match(CE->getOperand(1))) ||
472 L.match(CE->getOperand(1))));
477 template <
typename LHS,
typename RHS>
483 template <
typename LHS,
typename RHS>
489 template <
typename LHS,
typename RHS>
495 template <
typename LHS,
typename RHS>
501 template <
typename LHS,
typename RHS>
507 template <
typename LHS,
typename RHS>
513 template <
typename LHS,
typename RHS>
519 template <
typename LHS,
typename RHS>
525 template <
typename LHS,
typename RHS>
531 template <
typename LHS,
typename RHS>
537 template <
typename LHS,
typename RHS>
543 template <
typename LHS,
typename RHS>
549 template <
typename LHS,
typename RHS>
555 template <
typename LHS,
typename RHS>
561 template <
typename LHS,
typename RHS>
567 template <
typename LHS,
typename RHS>
573 template <
typename LHS,
typename RHS>
579 template <
typename LHS,
typename RHS>
585 template <
typename LHS_t,
typename RHS_t,
unsigned Opcode,
586 unsigned WrapFlags = 0>
594 template <
typename OpTy>
bool match(OpTy *V) {
595 if (
auto *
Op = dyn_cast<OverflowingBinaryOperator>(V)) {
596 if (
Op->getOpcode() != Opcode)
599 !
Op->hasNoUnsignedWrap())
602 !
Op->hasNoSignedWrap())
604 return L.match(
Op->getOperand(0)) &&
R.match(
Op->getOperand(1));
610 template <
typename LHS,
typename RHS>
618 template <
typename LHS,
typename RHS>
619 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Sub,
626 template <
typename LHS,
typename RHS>
627 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Mul,
634 template <
typename LHS,
typename RHS>
635 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Shl,
643 template <
typename LHS,
typename RHS>
651 template <
typename LHS,
typename RHS>
652 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Sub,
659 template <
typename LHS,
typename RHS>
660 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Mul,
667 template <
typename LHS,
typename RHS>
668 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Shl,
679 template <
typename LHS_t,
typename RHS_t,
typename Predicate>
686 template <
typename OpTy>
bool match(OpTy *V) {
687 if (
auto *
I = dyn_cast<Instruction>(V))
688 return this->isOpType(
I->getOpcode()) &&
L.match(
I->getOperand(0)) &&
689 R.match(
I->getOperand(1));
690 if (
auto *CE = dyn_cast<ConstantExpr>(V))
691 return this->isOpType(CE->getOpcode()) &&
L.match(CE->getOperand(0)) &&
692 R.match(CE->getOperand(1));
703 return Opcode == Instruction::LShr || Opcode == Instruction::AShr;
709 return Opcode == Instruction::LShr || Opcode == Instruction::Shl;
721 return Opcode == Instruction::SDiv || Opcode == Instruction::UDiv;
726 template <
typename LHS,
typename RHS>
733 template <
typename LHS,
typename RHS>
740 template <
typename LHS,
typename RHS>
741 inline BinOpPred_match<LHS, RHS, is_logical_shift_op>
747 template <
typename LHS,
typename RHS>
748 inline BinOpPred_match<LHS, RHS, is_bitwiselogic_op>
754 template <
typename LHS,
typename RHS>
768 template <
typename OpTy>
bool match(OpTy *V) {
769 if (
auto *PEO = dyn_cast<PossiblyExactOperator>(V))
783 template <
typename LHS_t,
typename RHS_t,
typename Class,
typename PredicateTy,
793 template <
typename OpTy>
bool match(OpTy *V) {
794 if (
auto *
I = dyn_cast<Class>(V))
795 if ((
L.match(
I->getOperand(0)) &&
R.match(
I->getOperand(1))) ||
797 L.match(
I->getOperand(1)))) {
805 template <
typename LHS,
typename RHS>
806 inline CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>
811 template <
typename LHS,
typename RHS>
812 inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>
817 template <
typename LHS,
typename RHS>
818 inline CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>
827 template <
typename Cond_t,
typename LHS_t,
typename RHS_t>
834 :
C(Cond),
L(LHS),
R(RHS) {}
836 template <
typename OpTy>
bool match(OpTy *V) {
837 if (
auto *
I = dyn_cast<SelectInst>(V))
838 return C.match(
I->getOperand(0)) &&
L.match(
I->getOperand(1)) &&
839 R.match(
I->getOperand(2));
844 template <
typename Cond,
typename LHS,
typename RHS>
852 template <
int64_t L,
int64_t R,
typename Cond>
853 inline SelectClass_match<Cond, constantint_match<L>, constantint_match<R>>
855 return m_Select(C, m_ConstantInt<L>(), m_ConstantInt<R>());
867 template <
typename OpTy>
bool match(OpTy *V) {
868 if (
auto *O = dyn_cast<Operator>(V))
869 return O->getOpcode() == Opcode &&
Op.match(O->getOperand(0));
875 template <
typename OpTy>
881 template <
typename OpTy>
887 template <
typename OpTy>
893 template <
typename OpTy>
899 template <
typename OpTy>
904 template <
typename OpTy>
905 inline match_combine_or<CastClass_match<OpTy, Instruction::ZExt>,
906 CastClass_match<OpTy, Instruction::SExt>>
912 template <
typename OpTy>
918 template <
typename OpTy>
924 template <
typename OpTy>
930 template <
typename OpTy>
944 template <
typename OpTy>
bool match(OpTy *V) {
945 if (
auto *O = dyn_cast<Operator>(V))
946 if (O->getOpcode() == Instruction::Xor) {
947 if (isAllOnes(O->getOperand(1)))
948 return L.match(O->getOperand(0));
949 if (isAllOnes(O->getOperand(0)))
950 return L.match(O->getOperand(1));
956 bool isAllOnes(
Value *V) {
957 return isa<Constant>(V) && cast<Constant>(V)->isAllOnesValue();
968 template <
typename OpTy>
bool match(OpTy *V) {
969 if (
auto *O = dyn_cast<Operator>(V))
970 if (O->getOpcode() == Instruction::Sub)
971 return matchIfNeg(O->getOperand(0), O->getOperand(1));
977 return ((isa<ConstantInt>(LHS) && cast<ConstantInt>(LHS)->
isZero()) ||
978 isa<ConstantAggregateZero>(LHS)) &&
991 template <
typename OpTy>
bool match(OpTy *V) {
992 if (
auto *O = dyn_cast<Operator>(V))
993 if (O->getOpcode() == Instruction::FSub)
994 return matchIfFNeg(O->getOperand(0), O->getOperand(1));
1000 if (
const auto *
C = dyn_cast<ConstantFP>(LHS))
1001 return C->isNegativeZeroValue() &&
L.match(RHS);
1020 template <
typename OpTy>
bool match(OpTy *V) {
1021 if (
auto *BI = dyn_cast<BranchInst>(V))
1022 if (BI->isUnconditional()) {
1023 Succ = BI->getSuccessor(0);
1039 template <
typename OpTy>
bool match(OpTy *V) {
1040 if (
auto *BI = dyn_cast<BranchInst>(V))
1041 if (BI->isConditional() &&
Cond.match(BI->getCondition())) {
1042 T = BI->getSuccessor(0);
1043 F = BI->getSuccessor(1);
1050 template <
typename Cond_t>
1059 template <
typename CmpInst_t,
typename LHS_t,
typename RHS_t,
typename Pred_t,
1067 template <
typename OpTy>
bool match(OpTy *V) {
1072 auto *Cmp =
dyn_cast<CmpInst_t>(
SI->getCondition());
1077 Value *TrueVal =
SI->getTrueValue();
1078 Value *FalseVal =
SI->getFalseValue();
1079 Value *LHS = Cmp->getOperand(0);
1080 Value *RHS = Cmp->getOperand(1);
1081 if ((TrueVal != LHS || FalseVal != RHS) &&
1082 (TrueVal != RHS || FalseVal != LHS))
1085 LHS == TrueVal ? Cmp->getPredicate() : Cmp->getInversePredicate();
1090 return (
L.match(LHS) &&
R.match(RHS)) ||
1151 template <
typename LHS,
typename RHS>
1157 template <
typename LHS,
typename RHS>
1163 template <
typename LHS,
typename RHS>
1169 template <
typename LHS,
typename RHS>
1184 template <
typename LHS,
typename RHS>
1199 template <
typename LHS,
typename RHS>
1214 template <
typename LHS,
typename RHS>
1215 inline MaxMin_match<FCmpInst, LHS, RHS, ufmax_pred_ty>
1229 template <
typename LHS,
typename RHS>
1230 inline MaxMin_match<FCmpInst, LHS, RHS, ufmin_pred_ty>
1239 template <
typename LHS_t,
typename RHS_t,
typename Sum_t>
1246 : L(L), R(R), S(S) {}
1248 template <
typename OpTy>
bool match(OpTy *V) {
1249 Value *ICmpLHS, *ICmpRHS;
1254 Value *AddLHS, *AddRHS;
1259 if (AddExpr.match(ICmpLHS) && (ICmpRHS == AddLHS || ICmpRHS == AddRHS))
1260 return L.match(AddLHS) &&
R.match(AddRHS) &&
S.match(ICmpLHS);
1264 if (AddExpr.match(ICmpRHS) && (ICmpLHS == AddLHS || ICmpLHS == AddRHS))
1265 return L.match(AddLHS) &&
R.match(AddRHS) &&
S.match(ICmpRHS);
1275 template <
typename LHS_t,
typename RHS_t,
typename Sum_t>
1276 UAddWithOverflow_match<LHS_t, RHS_t, Sum_t>
1287 template <
typename OpTy>
bool match(OpTy *V) {
1294 template <
unsigned OpI,
typename Opnd_t>
1305 template <
typename OpTy>
bool match(OpTy *V) {
1306 if (
const auto *CI = dyn_cast<CallInst>(V))
1307 if (
const auto *
F = CI->getCalledFunction())
1308 return F->getIntrinsicID() ==
ID;
1317 template <
typename T0 = void,
typename T1 = void,
typename T2 = void,
1318 typename T3 = void,
typename T4 = void,
typename T5 = void,
1319 typename T6 = void,
typename T7 = void,
typename T8 = void,
1320 typename T9 = void,
typename T10 =
void>
1329 template <
typename T0,
typename T1,
typename T2>
1335 template <
typename T0,
typename T1,
typename T2,
typename T3>
1348 template <Intrinsic::ID IntrID,
typename T0>
1350 return m_CombineAnd(m_Intrinsic<IntrID>(), m_Argument<0>(Op0));
1353 template <Intrinsic::ID IntrID,
typename T0,
typename T1>
1356 return m_CombineAnd(m_Intrinsic<IntrID>(Op0), m_Argument<1>(Op1));
1359 template <Intrinsic::ID IntrID,
typename T0,
typename T1,
typename T2>
1362 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1), m_Argument<2>(Op2));
1365 template <
Intrinsic::ID IntrID,
typename T0,
typename T1,
typename T2,
1369 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1, Op2), m_Argument<3>(Op3));
1373 template <
typename Opnd0>
1375 return m_Intrinsic<Intrinsic::bitreverse>(Op0);
1378 template <
typename Opnd0>
1380 return m_Intrinsic<Intrinsic::bswap>(Op0);
1383 template <
typename Opnd0,
typename Opnd1>
1386 return m_Intrinsic<Intrinsic::minnum>(Op0, Op1);
1389 template <
typename Opnd0,
typename Opnd1>
1392 return m_Intrinsic<Intrinsic::maxnum>(Op0, Op1);
1399 template <
typename OpTy>
bool match(OpTy *V) {
1400 unsigned TypeSize = V->getType()->getScalarSizeInBits();
1404 unsigned ShiftWidth = TypeSize - 1;
1405 Value *OpL =
nullptr, *OpR =
nullptr;
1419 auto Signum =
m_Or(LHS, RHS);
1421 return Signum.match(V) && OpL == OpR &&
Val.match(OpL);
1440 template <
typename LHS,
typename RHS>
1447 template <
typename LHS,
typename RHS>
1448 inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true>
1455 template <
typename LHS,
typename RHS>
1462 template <
typename LHS,
typename RHS>
1469 template <
typename LHS,
typename RHS>
1476 template <
typename LHS,
typename RHS>
1483 template <
typename LHS,
typename RHS>
1490 template <
typename LHS,
typename RHS>
1491 inline MaxMin_match<ICmpInst, LHS, RHS, smin_pred_ty, true>
1496 template <
typename LHS,
typename RHS>
1497 inline MaxMin_match<ICmpInst, LHS, RHS, smax_pred_ty, true>
1502 template <
typename LHS,
typename RHS>
1503 inline MaxMin_match<ICmpInst, LHS, RHS, umin_pred_ty, true>
1508 template <
typename LHS,
typename RHS>
1509 inline MaxMin_match<ICmpInst, LHS, RHS, umax_pred_ty, true>
1517 #endif // LLVM_IR_PATTERNMATCH_H
MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty > m_UMin(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
BinOpPred_match< LHS, RHS, is_right_shift_op > m_Shr(const LHS &L, const RHS &R)
Matches logical shift operations.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Sub, OverflowingBinaryOperator::NoSignedWrap > m_NSWSub(const LHS &L, const RHS &R)
m_Intrinsic_Ty< Opnd0, Opnd1 >::Ty m_FMin(const Opnd0 &Op0, const Opnd1 &Op1)
static bool match(FCmpInst::Predicate Pred)
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
class_match< UndefValue > m_Undef()
Match an arbitrary undef constant.
Match a specified integer value or vector of all elements of that.
class_match< CmpInst > m_Cmp()
Matches any compare instruction and ignore it.
BinaryOp_match< LHS, RHS, Instruction::Sub > m_Sub(const LHS &L, const RHS &R)
br_match(BasicBlock *&Succ)
bool isValue(const APInt &C)
BinaryOp_match< LHS, RHS, Instruction::Xor, true > m_c_Xor(const LHS &L, const RHS &R)
Matches an Xor with LHS and RHS in either order.
BinaryOp_match< LHS, RHS, Instruction::FAdd > m_FAdd(const LHS &L, const RHS &R)
m_Intrinsic_Ty< Opnd0 >::Ty m_BitReverse(const Opnd0 &Op0)
Match a specified floating point value or vector of all elements of that value.
m_Intrinsic_Ty< Opnd0, Opnd1 >::Ty m_FMax(const Opnd0 &Op0, const Opnd1 &Op1)
BinaryOp_match< LHS, RHS, Instruction::FDiv > m_FDiv(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::SRem > m_SRem(const LHS &L, const RHS &R)
match_zero m_Zero()
Match an arbitrary zero/null constant.
Exact_match(const SubPattern_t &SP)
bool isOpType(unsigned Opcode)
api_pred_ty(const APInt *&R)
BinaryOp_match< LHS, RHS, Instruction::Mul > m_Mul(const LHS &L, const RHS &R)
br_match m_UnconditionalBr(BasicBlock *&Succ)
class_match< Constant > m_Constant()
Match an arbitrary Constant and ignore it.
m_Intrinsic_Ty< Opnd0 >::Ty m_BSwap(const Opnd0 &Op0)
BinaryOp_match< LHS, RHS, Instruction::AShr > m_AShr(const LHS &L, const RHS &R)
apint_match(const APInt *&R)
static bool match(ICmpInst::Predicate Pred)
0 1 0 0 True if ordered and less than
match_combine_and< typename m_Intrinsic_Ty< T0, T1, T2 >::Ty, Argument_match< T3 >> Ty
CmpClass_match< LHS, RHS, ICmpInst, ICmpInst::Predicate, true > m_c_ICmp(ICmpInst::Predicate &Pred, const LHS &L, const RHS &R)
Matches an ICmp with a predicate over LHS and RHS in either order.
match_combine_or(const LTy &Left, const RTy &Right)
BinaryOp_match< LHS, RHS, Instruction::FSub > m_FSub(const LHS &L, const RHS &R)
MaxMin_match< FCmpInst, LHS, RHS, ufmax_pred_ty > m_UnordFMax(const LHS &L, const RHS &R)
Match an 'unordered' floating point maximum function.
fneg_match< LHS > m_FNeg(const LHS &L)
Match a floating point negate.
Argument_match(unsigned OpIdx, const Opnd_t &V)
AnyBinaryOp_match< LHS, RHS, true > m_c_BinOp(const LHS &L, const RHS &R)
Matches a BinaryOperator with LHS and RHS in either order.
BinOpPred_match< LHS, RHS, is_logical_shift_op > m_LogicalShift(const LHS &L, const RHS &R)
Matches logical shift operations.
bool isOpType(unsigned Opcode)
specific_fpval m_SpecificFP(double V)
Match a specific floating point value or vector with all elements equal to the value.
bool match(Val *V, const Pattern &P)
CmpClass_match< LHS, RHS, FCmpInst, FCmpInst::Predicate > m_FCmp(FCmpInst::Predicate &Pred, const LHS &L, const RHS &R)
Helper class for identifying signed min predicates.
BinaryOp_match< LHS, RHS, Instruction::Xor > m_Xor(const LHS &L, const RHS &R)
This class represents the LLVM 'select' instruction.
const APInt & getValue() const
Return the constant as an APInt value reference.
Exact_match< T > m_Exact(const T &SubPattern)
specificval_ty(const Value *V)
CastClass_match< OpTy, Instruction::Trunc > m_Trunc(const OpTy &Op)
Matches Trunc.
bool isCall() const
Return true if a CallInst is enclosed.
cst_pred_ty< is_maxsignedvalue > m_MaxSignedValue()
0 1 0 1 True if ordered and less than or equal
MaxMin_match< FCmpInst, LHS, RHS, ufmin_pred_ty > m_UnordFMin(const LHS &L, const RHS &R)
Match an 'unordered' floating point minimum function.
This file implements a class to represent arbitrary precision integral constant values and operations...
not_match< LHS > m_Not(const LHS &L)
BinaryOp_match< LHS, RHS, Instruction::Add > m_Add(const LHS &L, const RHS &R)
bind_ty< ConstantFP > m_ConstantFP(ConstantFP *&C)
Match a ConstantFP, capturing the value if we match.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWAdd(const LHS &L, const RHS &R)
match_combine_and< typename m_Intrinsic_Ty< T0, T1 >::Ty, Argument_match< T2 >> Ty
CastClass_match< OpTy, Instruction::FPExt > m_FPExt(const OpTy &Op)
Matches FPExt.
match_combine_or< LTy, RTy > m_CombineOr(const LTy &L, const RTy &R)
Combine two pattern matchers matching L || R.
CastClass_match(const Op_t &OpMatch)
CastClass_match< OpTy, Instruction::ZExt > m_ZExt(const OpTy &Op)
Matches ZExt.
CastClass_match< OpTy, Instruction::FPTrunc > m_FPTrunc(const OpTy &Op)
Matches FPTrunc.
MaxMin_match< FCmpInst, LHS, RHS, ofmin_pred_ty > m_OrdFMin(const LHS &L, const RHS &R)
Match an 'ordered' floating point minimum function.
MaxMin_match< ICmpInst, LHS, RHS, smin_pred_ty > m_SMin(const LHS &L, const RHS &R)
class_match< ConstantInt > m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
UAddWithOverflow_match(const LHS_t &L, const RHS_t &R, const Sum_t &S)
IntrinsicID_match(Intrinsic::ID IntrID)
SelectClass_match< Cond, LHS, RHS > m_Select(const Cond &C, const LHS &L, const RHS &R)
Signum_match(const Opnd_t &V)
cst_pred_ty< is_power2 > m_Power2()
Match an integer or vector power of 2.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Mul, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWMul(const LHS &L, const RHS &R)
MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty, true > m_c_UMin(const LHS &L, const RHS &R)
Matches a UMin with LHS and RHS in either order.
specific_intval(uint64_t V)
static bool match(FCmpInst::Predicate Pred)
Helper class for identifying ordered min predicates.
match_combine_and(const LTy &Left, const RTy &Right)
OneUse_match< T > m_OneUse(const T &SubPattern)
BinaryOp_match< LHS, RHS, Instruction::LShr > m_LShr(const LHS &L, const RHS &R)
Helper class for identifying signed max predicates.
MaxMin_match< ICmpInst, LHS, RHS, umax_pred_ty > m_UMax(const LHS &L, const RHS &R)
apint_match m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt...
BinaryOp_match< LHS, RHS, Instruction::SDiv > m_SDiv(const LHS &L, const RHS &R)
This helper class is used to match scalar and vector constants that satisfy a specified predicate...
BinaryOp_match< LHS, RHS, Instruction::Add, true > m_c_Add(const LHS &L, const RHS &R)
Matches a Add with LHS and RHS in either order.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Shl, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWShl(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::FRem > m_FRem(const LHS &L, const RHS &R)
LLVM Basic Block Representation.
BinaryOp_match< LHS, RHS, Instruction::Or > m_Or(const LHS &L, const RHS &R)
CastClass_match< OpTy, Instruction::BitCast > m_BitCast(const OpTy &Op)
Matches BitCast.
This is an important base class in LLVM.
bool isMaxSignedValue() const
Determine if this is the largest signed value.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
BinaryOp_match< LHS, RHS, Instruction::And, true > m_c_And(const LHS &L, const RHS &R)
Matches an And with LHS and RHS in either order.
ConstantFP - Floating Point Values [float, double].
bind_const_intval_ty(uint64_t &V)
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
brc_match< Cond_t > m_Br(const Cond_t &C, BasicBlock *&T, BasicBlock *&F)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
BinaryOp_match< LHS, RHS, Instruction::Shl > m_Shl(const LHS &L, const RHS &R)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
match_combine_or< CastClass_match< OpTy, Instruction::ZExt >, CastClass_match< OpTy, Instruction::SExt > > m_ZExtOrSExt(const OpTy &Op)
Helper class for identifying unsigned min predicates.
BinOpPred_match< LHS, RHS, is_bitwiselogic_op > m_BitwiseLogic(const LHS &L, const RHS &R)
Matches bitwise logic operations.
MaxMin_match< ICmpInst, LHS, RHS, smax_pred_ty, true > m_c_SMax(const LHS &L, const RHS &R)
Matches an SMax with LHS and RHS in either order.
AnyBinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
class_match< BinaryOperator > m_BinOp()
Match an arbitrary binary operation and ignore it.
Signum_match< Val_t > m_Signum(const Val_t &V)
Matches a signum pattern.
BinOpPred_match< LHS, RHS, is_idiv_op > m_IDiv(const LHS &L, const RHS &R)
Matches integer division operations.
Helper class for identifying unordered min predicates.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
1 1 0 1 True if unordered, less than, or equal
BinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
Argument_match< Opnd_t > m_Argument(const Opnd_t &Op)
Match an argument.
neg_match< LHS > m_Neg(const LHS &L)
Match an integer negate.
CastClass_match< OpTy, Instruction::SExt > m_SExt(const OpTy &Op)
Matches SExt.
MaxMin_match< ICmpInst, LHS, RHS, umax_pred_ty, true > m_c_UMax(const LHS &L, const RHS &R)
Matches a UMax with LHS and RHS in either order.
OneUse_match(const SubPattern_t &SP)
0 0 1 0 True if ordered and greater than
Intrinsic matches are combinations of ID matchers, and argument matchers.
static bool match(ICmpInst::Predicate Pred)
BinaryOp_match< LHS, RHS, Instruction::Or, true > m_c_Or(const LHS &L, const RHS &R)
Matches an Or with LHS and RHS in either order.
This is the shared class of boolean and integer constants.
static bool match(ICmpInst::Predicate Pred)
bool isValue(const APInt &C)
Match a specified Value*.
match_any_zero m_AnyZero()
Match an arbitrary zero/null constant.
ValTy * getArgument(unsigned ArgNo) const
1 1 0 0 True if unordered or less than
brc_match(const Cond_t &C, BasicBlock *&t, BasicBlock *&f)
BinaryOp_match< LHS, RHS, Instruction::URem > m_URem(const LHS &L, const RHS &R)
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
BinaryOp_match< LHS, RHS, Instruction::UDiv > m_UDiv(const LHS &L, const RHS &R)
bool isOpType(unsigned Opcode)
BinaryOp_match< LHS, RHS, Instruction::Mul, true > m_c_Mul(const LHS &L, const RHS &R)
Matches a Mul with LHS and RHS in either order.
CastClass_match< OpTy, Instruction::UIToFP > m_UIToFP(const OpTy &Op)
Matches UIToFP.
BinaryOp_match< LHS, RHS, Instruction::FMul > m_FMul(const LHS &L, const RHS &R)
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoSignedWrap > m_NSWAdd(const LHS &L, const RHS &R)
Class for arbitrary precision integers.
not_match(const LHS_t &LHS)
CastClass_match< OpTy, Instruction::PtrToInt > m_PtrToInt(const OpTy &Op)
Matches PtrToInt.
BinOpPred_match< LHS, RHS, is_shift_op > m_Shift(const LHS &L, const RHS &R)
Matches shift operations.
Helper class for identifying unsigned max predicates.
Helper class for identifying ordered max predicates.
OverflowingBinaryOp_match< LHS, RHS, Instruction::Sub, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWSub(const LHS &L, const RHS &R)
specific_fpval m_FPOne()
Match a float 1.0 or vector with all elements equal to 1.0.
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
neg_match(const LHS_t &LHS)
unsigned greater or equal
match_one m_One()
Match an integer 1 or a vector with all elements equal to 1.
MaxMin_match< ICmpInst, LHS, RHS, smin_pred_ty, true > m_c_SMin(const LHS &L, const RHS &R)
Matches an SMin with LHS and RHS in either order.
CmpClass_match(PredicateTy &Pred, const LHS_t &LHS, const RHS_t &RHS)
OverflowingBinaryOp_match< LHS, RHS, Instruction::Shl, OverflowingBinaryOperator::NoSignedWrap > m_NSWShl(const LHS &L, const RHS &R)
MaxMin_match< ICmpInst, LHS, RHS, smax_pred_ty > m_SMax(const LHS &L, const RHS &R)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
CastClass_match< OpTy, Instruction::SIToFP > m_SIToFP(const OpTy &Op)
Matches SIToFP.
1 0 1 0 True if unordered or greater than
fneg_match(const LHS_t &LHS)
SelectClass_match< Cond, constantint_match< L >, constantint_match< R > > m_SelectCst(const Cond &C)
This matches a select of two constants, e.g.
match_neg_zero m_NegZero()
Match an arbitrary zero/null constant.
OverflowingBinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
bool isOpType(unsigned Opcode)
bool isOpType(unsigned Opcode)
static bool match(FCmpInst::Predicate Pred)
match_all_ones m_AllOnes()
Match an integer or vector with all bits set to true.
MaxMin_match< FCmpInst, LHS, RHS, ofmax_pred_ty > m_OrdFMax(const LHS &L, const RHS &R)
Match an 'ordered' floating point maximum function.
Helper class for identifying unordered max predicates.
match_sign_mask m_SignMask()
Match an integer or vector with only the sign bit(s) set.
LLVM Value Representation.
1 0 1 1 True if unordered, greater than, or equal
OverflowingBinaryOp_match< LHS, RHS, Instruction::Mul, OverflowingBinaryOperator::NoSignedWrap > m_NSWMul(const LHS &L, const RHS &R)
static bool match(ICmpInst::Predicate Pred)
BinOpPred_match(const LHS_t &LHS, const RHS_t &RHS)
match_combine_and< LTy, RTy > m_CombineAnd(const LTy &L, const RTy &R)
Combine two pattern matchers matching L && R.
static bool match(FCmpInst::Predicate Pred)
IntrinsicID_match m_Intrinsic()
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
match_nan m_NaN()
Match an arbitrary NaN constant. This includes quiet and signalling nans.
specific_intval m_SpecificInt(uint64_t V)
Match a specific integer value or vector with all elements equal to the value.
MaxMin_match(const LHS_t &LHS, const RHS_t &RHS)
SelectClass_match(const Cond_t &Cond, const LHS_t &LHS, const RHS_t &RHS)
bool isBitwiseLogicOp() const
Return true if this is and/or/xor.
0 0 1 1 True if ordered and greater than or equal
This helper class is used to match scalar and vector constants that satisfy a specified predicate...
bind_ty< Instruction > m_Instruction(Instruction *&I)
Match an instruction, capturing it if we match.
UAddWithOverflow_match< LHS_t, RHS_t, Sum_t > m_UAddWithOverflow(const LHS_t &L, const RHS_t &R, const Sum_t &S)
Match an icmp instruction checking for unsigned overflow on addition.
CmpClass_match< LHS, RHS, ICmpInst, ICmpInst::Predicate > m_ICmp(ICmpInst::Predicate &Pred, const LHS &L, const RHS &R)