29 #ifndef LLVM_IR_PATTERNMATCH_H
30 #define LLVM_IR_PATTERNMATCH_H
39 namespace PatternMatch {
41 template <
typename Val,
typename Pattern>
bool match(Val *V,
const Pattern &
P) {
42 return const_cast<Pattern &
>(
P).
match(V);
50 template <
typename OpTy>
bool match(OpTy *V) {
60 template <
typename ITy>
bool match(ITy *V) {
return isa<Class>(V); }
92 template <
typename ITy>
bool match(ITy *V) {
107 template <
typename ITy>
bool match(ITy *V) {
116 template <
typename LTy,
typename RTy>
122 template <
typename LTy,
typename RTy>
128 template <
typename ITy>
bool match(ITy *V) {
129 if (
const auto *
C = dyn_cast<Constant>(V))
130 return C->isNullValue();
140 template <
typename ITy>
bool match(ITy *V) {
141 if (
const auto *
C = dyn_cast<Constant>(V))
142 return C->isNegativeZeroValue();
163 template <
typename ITy>
bool match(ITy *V) {
164 if (
auto *CI = dyn_cast<ConstantInt>(V)) {
165 Res = &CI->getValue();
168 if (V->getType()->isVectorTy())
169 if (
const auto *
C = dyn_cast<Constant>(V))
170 if (
auto *CI = dyn_cast_or_null<ConstantInt>(
C->getSplatValue())) {
171 Res = &CI->getValue();
183 template <
typename ITy>
bool match(ITy *V) {
184 if (
const auto *CI = dyn_cast<ConstantInt>(V)) {
185 const APInt &CIV = CI->getValue();
187 return CIV ==
static_cast<uint64_t
>(Val);
198 template <
int64_t Val>
inline constantint_match<Val>
m_ConstantInt() {
199 return constantint_match<Val>();
205 template <
typename ITy>
bool match(ITy *V) {
206 if (
const auto *CI = dyn_cast<ConstantInt>(V))
207 return this->isValue(CI->getValue());
208 if (V->getType()->isVectorTy())
209 if (
const auto *
C = dyn_cast<Constant>(V))
210 if (
const auto *CI = dyn_cast_or_null<ConstantInt>(
C->getSplatValue()))
211 return this->isValue(CI->getValue());
221 template <
typename ITy>
bool match(ITy *V) {
222 if (
const auto *CI = dyn_cast<ConstantInt>(V))
223 if (this->isValue(CI->getValue())) {
224 Res = &CI->getValue();
227 if (V->getType()->isVectorTy())
228 if (
const auto *
C = dyn_cast<Constant>(V))
229 if (
auto *CI = dyn_cast_or_null<ConstantInt>(
C->getSplatValue()))
230 if (this->isValue(CI->getValue())) {
231 Res = &CI->getValue();
286 template <
typename ITy>
bool match(ITy *V) {
287 if (
auto *CV = dyn_cast<Class>(V)) {
318 template <
typename ITy>
bool match(ITy *V) {
return V ==
Val; }
330 template <
typename ITy>
bool match(ITy *V) {
331 if (
const auto *CFP = dyn_cast<ConstantFP>(V))
332 return CFP->isExactlyValue(
Val);
333 if (V->getType()->isVectorTy())
334 if (
const auto *
C = dyn_cast<Constant>(V))
335 if (
auto *CFP = dyn_cast_or_null<ConstantFP>(
C->getSplatValue()))
336 return CFP->isExactlyValue(
Val);
352 template <
typename ITy>
bool match(ITy *V) {
353 if (
const auto *CV = dyn_cast<ConstantInt>(V))
354 if (CV->getBitWidth() <= 64) {
355 VR = CV->getZExtValue();
368 template <
typename ITy>
bool match(ITy *V) {
370 if (!CI && V->getType()->isVectorTy())
371 if (
const auto *
C = dyn_cast<Constant>(V))
372 CI = dyn_cast_or_null<ConstantInt>(
C->getSplatValue());
374 if (CI && CI->getBitWidth() <= 64)
398 template <
typename OpTy>
bool match(OpTy *V) {
399 if (
auto *
I = dyn_cast<BinaryOperator>(V))
400 return L.match(
I->getOperand(0)) &&
R.match(
I->getOperand(1));
405 template <
typename LHS,
typename RHS>
414 template <
typename LHS_t,
typename RHS_t,
unsigned Opcode>
421 template <
typename OpTy>
bool match(OpTy *V) {
422 if (V->getValueID() == Value::InstructionVal + Opcode) {
423 auto *
I = cast<BinaryOperator>(V);
424 return L.match(
I->getOperand(0)) &&
R.match(
I->getOperand(1));
426 if (
auto *CE = dyn_cast<ConstantExpr>(V))
427 return CE->getOpcode() == Opcode &&
L.match(CE->getOperand(0)) &&
428 R.match(CE->getOperand(1));
433 template <
typename LHS,
typename RHS>
439 template <
typename LHS,
typename RHS>
445 template <
typename LHS,
typename RHS>
451 template <
typename LHS,
typename RHS>
457 template <
typename LHS,
typename RHS>
463 template <
typename LHS,
typename RHS>
469 template <
typename LHS,
typename RHS>
475 template <
typename LHS,
typename RHS>
481 template <
typename LHS,
typename RHS>
487 template <
typename LHS,
typename RHS>
493 template <
typename LHS,
typename RHS>
499 template <
typename LHS,
typename RHS>
505 template <
typename LHS,
typename RHS>
511 template <
typename LHS,
typename RHS>
517 template <
typename LHS,
typename RHS>
523 template <
typename LHS,
typename RHS>
529 template <
typename LHS,
typename RHS>
535 template <
typename LHS,
typename RHS>
541 template <
typename LHS_t,
typename RHS_t,
unsigned Opcode,
542 unsigned WrapFlags = 0>
550 template <
typename OpTy>
bool match(OpTy *V) {
551 if (
auto *
Op = dyn_cast<OverflowingBinaryOperator>(V)) {
552 if (
Op->getOpcode() != Opcode)
555 !
Op->hasNoUnsignedWrap())
558 !
Op->hasNoSignedWrap())
560 return L.match(
Op->getOperand(0)) &&
R.match(
Op->getOperand(1));
566 template <
typename LHS,
typename RHS>
574 template <
typename LHS,
typename RHS>
575 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Sub,
582 template <
typename LHS,
typename RHS>
583 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Mul,
590 template <
typename LHS,
typename RHS>
591 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Shl,
599 template <
typename LHS,
typename RHS>
607 template <
typename LHS,
typename RHS>
608 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Sub,
615 template <
typename LHS,
typename RHS>
616 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Mul,
623 template <
typename LHS,
typename RHS>
624 inline OverflowingBinaryOp_match<LHS, RHS, Instruction::Shl,
635 template <
typename LHS_t,
typename RHS_t,
unsigned Opc1,
unsigned Opc2>
642 template <
typename OpTy>
bool match(OpTy *V) {
643 if (V->getValueID() == Value::InstructionVal + Opc1 ||
644 V->getValueID() == Value::InstructionVal + Opc2) {
645 auto *
I = cast<BinaryOperator>(V);
646 return L.match(
I->getOperand(0)) &&
R.match(
I->getOperand(1));
648 if (
auto *CE = dyn_cast<ConstantExpr>(V))
649 return (CE->getOpcode() == Opc1 || CE->getOpcode() == Opc2) &&
650 L.match(CE->getOperand(0)) &&
R.match(CE->getOperand(1));
656 template <
typename LHS,
typename RHS>
657 inline BinOp2_match<LHS, RHS, Instruction::LShr, Instruction::AShr>
663 template <
typename LHS,
typename RHS>
664 inline BinOp2_match<LHS, RHS, Instruction::LShr, Instruction::Shl>
670 template <
typename LHS,
typename RHS>
671 inline BinOp2_match<LHS, RHS, Instruction::SDiv, Instruction::UDiv>
684 template <
typename OpTy>
bool match(OpTy *V) {
685 if (
auto *PEO = dyn_cast<PossiblyExactOperator>(V))
699 template <
typename LHS_t,
typename RHS_t,
typename Class,
typename PredicateTy>
708 template <
typename OpTy>
bool match(OpTy *V) {
709 if (
auto *
I = dyn_cast<Class>(V))
710 if (
L.match(
I->getOperand(0)) &&
R.match(
I->getOperand(1))) {
718 template <
typename LHS,
typename RHS>
719 inline CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>
724 template <
typename LHS,
typename RHS>
725 inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>
730 template <
typename LHS,
typename RHS>
731 inline CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>
740 template <
typename Cond_t,
typename LHS_t,
typename RHS_t>
747 :
C(Cond),
L(LHS),
R(RHS) {}
749 template <
typename OpTy>
bool match(OpTy *V) {
750 if (
auto *
I = dyn_cast<SelectInst>(V))
751 return C.match(
I->getOperand(0)) &&
L.match(
I->getOperand(1)) &&
752 R.match(
I->getOperand(2));
757 template <
typename Cond,
typename LHS,
typename RHS>
765 template <
int64_t L,
int64_t R,
typename Cond>
766 inline SelectClass_match<Cond, constantint_match<L>, constantint_match<R>>
768 return m_Select(C, m_ConstantInt<L>(), m_ConstantInt<R>());
780 template <
typename OpTy>
bool match(OpTy *V) {
781 if (
auto *O = dyn_cast<Operator>(V))
782 return O->getOpcode() == Opcode &&
Op.match(O->getOperand(0));
788 template <
typename OpTy>
794 template <
typename OpTy>
800 template <
typename OpTy>
806 template <
typename OpTy>
812 template <
typename OpTy>
818 template <
typename OpTy>
824 template <
typename OpTy>
838 template <
typename OpTy>
bool match(OpTy *V) {
839 if (
auto *O = dyn_cast<Operator>(V))
841 return matchIfNot(O->getOperand(0), O->getOperand(1));
847 return (isa<ConstantInt>(RHS) || isa<ConstantDataVector>(RHS) ||
849 isa<ConstantVector>(RHS)) &&
850 cast<Constant>(RHS)->isAllOnesValue() &&
L.match(LHS);
861 template <
typename OpTy>
bool match(OpTy *V) {
862 if (
auto *O = dyn_cast<Operator>(V))
863 if (O->getOpcode() == Instruction::Sub)
864 return matchIfNeg(O->getOperand(0), O->getOperand(1));
870 return ((isa<ConstantInt>(LHS) && cast<ConstantInt>(LHS)->
isZero()) ||
871 isa<ConstantAggregateZero>(LHS)) &&
884 template <
typename OpTy>
bool match(OpTy *V) {
885 if (
auto *O = dyn_cast<Operator>(V))
886 if (O->getOpcode() == Instruction::FSub)
887 return matchIfFNeg(O->getOperand(0), O->getOperand(1));
893 if (
const auto *
C = dyn_cast<ConstantFP>(LHS))
894 return C->isNegativeZeroValue() &&
L.match(RHS);
912 template <
typename OpTy>
bool match(OpTy *V) {
913 if (
auto *BI = dyn_cast<BranchInst>(V))
914 if (BI->isUnconditional()) {
915 Succ = BI->getSuccessor(0);
930 template <
typename OpTy>
bool match(OpTy *V) {
931 if (
auto *BI = dyn_cast<BranchInst>(V))
932 if (BI->isConditional() &&
Cond.match(BI->getCondition())) {
933 T = BI->getSuccessor(0);
934 F = BI->getSuccessor(1);
941 template <
typename Cond_t>
950 template <
typename CmpInst_t,
typename LHS_t,
typename RHS_t,
typename Pred_t>
957 template <
typename OpTy>
bool match(OpTy *V) {
962 auto *Cmp =
dyn_cast<CmpInst_t>(
SI->getCondition());
967 Value *TrueVal =
SI->getTrueValue();
968 Value *FalseVal =
SI->getFalseValue();
969 Value *LHS = Cmp->getOperand(0);
970 Value *RHS = Cmp->getOperand(1);
971 if ((TrueVal != LHS || FalseVal != RHS) &&
972 (TrueVal != RHS || FalseVal != LHS))
975 LHS == TrueVal ? Cmp->getPredicate() : Cmp->getSwappedPredicate();
980 return L.match(LHS) &&
R.match(RHS);
1040 template <
typename LHS,
typename RHS>
1046 template <
typename LHS,
typename RHS>
1052 template <
typename LHS,
typename RHS>
1058 template <
typename LHS,
typename RHS>
1073 template <
typename LHS,
typename RHS>
1088 template <
typename LHS,
typename RHS>
1103 template <
typename LHS,
typename RHS>
1104 inline MaxMin_match<FCmpInst, LHS, RHS, ufmax_pred_ty>
1113 template <
typename LHS_t,
typename RHS_t,
typename Sum_t>
1120 : L(L), R(R), S(S) {}
1122 template <
typename OpTy>
bool match(OpTy *V) {
1123 Value *ICmpLHS, *ICmpRHS;
1128 Value *AddLHS, *AddRHS;
1133 if (AddExpr.match(ICmpLHS) && (ICmpRHS == AddLHS || ICmpRHS == AddRHS))
1134 return L.match(AddLHS) &&
R.match(AddRHS) &&
S.match(ICmpLHS);
1138 if (AddExpr.match(ICmpRHS) && (ICmpLHS == AddLHS || ICmpLHS == AddRHS))
1139 return L.match(AddLHS) &&
R.match(AddRHS) &&
S.match(ICmpRHS);
1149 template <
typename LHS_t,
typename RHS_t,
typename Sum_t>
1150 UAddWithOverflow_match<LHS_t, RHS_t, Sum_t>
1164 template <
typename LHS,
typename RHS>
1165 inline MaxMin_match<FCmpInst, LHS, RHS, ufmin_pred_ty>
1175 template <
typename OpTy>
bool match(OpTy *V) {
1182 template <
unsigned OpI,
typename Opnd_t>
1192 template <
typename OpTy>
bool match(OpTy *V) {
1193 if (
const auto *CI = dyn_cast<CallInst>(V))
1194 if (
const auto *
F = CI->getCalledFunction())
1195 return F->getIntrinsicID() ==
ID;
1204 template <
typename T0 = void,
typename T1 = void,
typename T2 = void,
1205 typename T3 = void,
typename T4 = void,
typename T5 = void,
1206 typename T6 = void,
typename T7 = void,
typename T8 = void,
1207 typename T9 = void,
typename T10 =
void>
1216 template <
typename T0,
typename T1,
typename T2>
1221 template <
typename T0,
typename T1,
typename T2,
typename T3>
1233 template <Intrinsic::ID IntrID,
typename T0>
1235 return m_CombineAnd(m_Intrinsic<IntrID>(), m_Argument<0>(Op0));
1238 template <Intrinsic::ID IntrID,
typename T0,
typename T1>
1241 return m_CombineAnd(m_Intrinsic<IntrID>(Op0), m_Argument<1>(Op1));
1244 template <Intrinsic::ID IntrID,
typename T0,
typename T1,
typename T2>
1247 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1), m_Argument<2>(Op2));
1250 template <
Intrinsic::ID IntrID,
typename T0,
typename T1,
typename T2,
1254 return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1, Op2), m_Argument<3>(Op3));
1258 template <
typename Opnd0>
1260 return m_Intrinsic<Intrinsic::bswap>(Op0);
1263 template <
typename Opnd0,
typename Opnd1>
1266 return m_Intrinsic<Intrinsic::minnum>(Op0, Op1);
1269 template <
typename Opnd0,
typename Opnd1>
1272 return m_Intrinsic<Intrinsic::maxnum>(Op0, Op1);
1279 template <
typename OpTy>
bool match(OpTy *V) {
1280 unsigned TypeSize = V->getType()->getScalarSizeInBits();
1284 unsigned ShiftWidth = TypeSize - 1;
1285 Value *OpL =
nullptr, *OpR =
nullptr;
1299 auto Signum =
m_Or(LHS, RHS);
1301 return Signum.match(V) && OpL == OpR &&
Val.match(OpL);
1321 template<
typename LHS,
typename RHS>
1322 inline match_combine_or<CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>,
1323 CmpClass_match<RHS, LHS, ICmpInst, ICmpInst::Predicate>>
1329 template<
typename LHS,
typename RHS>
1330 inline match_combine_or<BinaryOp_match<LHS, RHS, Instruction::And>,
1331 BinaryOp_match<RHS, LHS, Instruction::And>>
1337 template<
typename LHS,
typename RHS>
1338 inline match_combine_or<BinaryOp_match<LHS, RHS, Instruction::Or>,
1339 BinaryOp_match<RHS, LHS, Instruction::Or>>
1345 template<
typename LHS,
typename RHS>
1346 inline match_combine_or<BinaryOp_match<LHS, RHS, Instruction::Xor>,
1347 BinaryOp_match<RHS, LHS, Instruction::Xor>>
1353 template <
typename LHS,
typename RHS>
1354 inline match_combine_or<MaxMin_match<ICmpInst, LHS, RHS, smin_pred_ty>,
1355 MaxMin_match<ICmpInst, RHS, LHS, smin_pred_ty>>
1360 template <
typename LHS,
typename RHS>
1361 inline match_combine_or<MaxMin_match<ICmpInst, LHS, RHS, smax_pred_ty>,
1362 MaxMin_match<ICmpInst, RHS, LHS, smax_pred_ty>>
1367 template <
typename LHS,
typename RHS>
1368 inline match_combine_or<MaxMin_match<ICmpInst, LHS, RHS, umin_pred_ty>,
1369 MaxMin_match<ICmpInst, RHS, LHS, umin_pred_ty>>
1374 template <
typename LHS,
typename RHS>
1375 inline match_combine_or<MaxMin_match<ICmpInst, LHS, RHS, umax_pred_ty>,
1376 MaxMin_match<ICmpInst, RHS, LHS, umax_pred_ty>>
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)
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.
cst_pred_ty< is_sign_bit > m_SignBit()
Match an integer or vector with only the sign bit(s) set.
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)
match_combine_or< MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty >, MaxMin_match< ICmpInst, RHS, LHS, umin_pred_ty > > m_c_UMin(const LHS &L, const RHS &R)
Matches a UMin with LHS and RHS in either order.
BinaryOp_match< LHS, RHS, Instruction::FAdd > m_FAdd(const LHS &L, const RHS &R)
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)
api_pred_ty(const APInt *&R)
match_combine_or< BinaryOp_match< LHS, RHS, Instruction::Xor >, BinaryOp_match< RHS, LHS, Instruction::Xor > > m_c_Xor(const LHS &L, const RHS &R)
Matches an Xor with LHS and RHS in either order.
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)
match_combine_and< typename m_Intrinsic_Ty< T0, T1 >::Ty, Argument_match< T2 > > Ty
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_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)
match_combine_or< BinaryOp_match< LHS, RHS, Instruction::And >, BinaryOp_match< RHS, LHS, Instruction::And > > m_c_And(const LHS &L, const RHS &R)
Matches an And with LHS and RHS in either order.
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)
match_combine_or< BinaryOp_match< LHS, RHS, Instruction::Or >, BinaryOp_match< RHS, LHS, Instruction::Or > > m_c_Or(const LHS &L, const RHS &R)
Matches an Or with LHS and RHS in either order.
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.
Exact_match< T > m_Exact(const T &SubPattern)
BinOp2_match< LHS, RHS, Instruction::LShr, Instruction::AShr > m_Shr(const LHS &L, const RHS &R)
Matches LShr or AShr.
specificval_ty(const Value *V)
match_combine_and< typename m_Intrinsic_Ty< T0 >::Ty, Argument_match< T1 > > Ty
CastClass_match< OpTy, Instruction::Trunc > m_Trunc(const OpTy &Op)
Matches Trunc.
bool isCall() const
isCall - 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.
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.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWAdd(const LHS &L, const RHS &R)
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.
match_combine_or< CmpClass_match< LHS, RHS, ICmpInst, ICmpInst::Predicate >, CmpClass_match< RHS, LHS, ICmpInst, ICmpInst::Predicate > > 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.
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)
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...
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.
AnyBinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
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.
match_combine_and< typename m_Intrinsic_Ty< T0, T1, T2 >::Ty, Argument_match< T3 > > Ty
This file contains the declarations for the subclasses of Constant, which represent the different fla...
ConstantFP - Floating Point Values [float, double].
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
cst_pred_ty< is_all_ones > m_AllOnes()
Match an integer or vector with all bits set to true.
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)
BinaryOp_match< LHS, RHS, Instruction::Shl > m_Shl(const LHS &L, const RHS &R)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Helper class for identifying unsigned min predicates.
class_match< BinaryOperator > m_BinOp()
Match an arbitrary binary operation and ignore it.
match_combine_or< MaxMin_match< ICmpInst, LHS, RHS, smax_pred_ty >, MaxMin_match< ICmpInst, RHS, LHS, smax_pred_ty > > m_c_SMax(const LHS &L, const RHS &R)
Matches an SMax with LHS and RHS in either order.
match_combine_or< MaxMin_match< ICmpInst, LHS, RHS, umax_pred_ty >, MaxMin_match< ICmpInst, RHS, LHS, umax_pred_ty > > m_c_UMax(const LHS &L, const RHS &R)
Matches a UMax with LHS and RHS in either order.
Signum_match< Val_t > m_Signum(const Val_t &V)
Matches a signum pattern.
match_combine_or< match_zero, match_neg_zero > m_AnyZero()
Match an arbitrary zero/null constant.
match_combine_and< IntrinsicID_match, Argument_match< T0 > > Ty
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
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.
OneUse_match(const SubPattern_t &SP)
MaxMin_match(const LHS_t &LHS, const RHS_t &RHS)
0 0 1 0 True if ordered and greater than
BinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
Intrinsic matches are combinations of ID matchers, and argument matchers.
static bool match(ICmpInst::Predicate Pred)
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*.
bool isValue(const APInt &C)
ValTy * getArgument(unsigned ArgNo) const
1 1 0 0 True if unordered or less than
BinOp2_match< LHS, RHS, Instruction::LShr, Instruction::Shl > m_LogicalShift(const LHS &L, const RHS &R)
Matches LShr or Shl.
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)
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)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
Class for arbitrary precision integers.
not_match(const LHS_t &LHS)
CastClass_match< OpTy, Instruction::PtrToInt > m_PtrToInt(const OpTy &Op)
Matches PtrToInt.
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.
bool isAllOnesValue() const
Determine if all bits are set.
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
match_combine_or< MaxMin_match< ICmpInst, LHS, RHS, smin_pred_ty >, MaxMin_match< ICmpInst, RHS, LHS, smin_pred_ty > > 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)
neg_match(const LHS_t &LHS)
unsigned greater or equal
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)
bool isSignBit() const
Check if the APInt's value is returned by getSignBit.
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.
BinOp2_match< LHS, RHS, Instruction::SDiv, Instruction::UDiv > m_IDiv(const LHS &L, const RHS &R)
Matches UDiv and SDiv.
match_neg_zero m_NegZero()
Match an arbitrary zero/null constant.
OverflowingBinaryOp_match(const LHS_t &LHS, const RHS_t &RHS)
static bool match(FCmpInst::Predicate Pred)
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.
LLVM Value Representation.
bool isValue(const APInt &C)
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)
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
static bool match(ICmpInst::Predicate Pred)
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))
specific_intval m_SpecificInt(uint64_t V)
Match a specific integer value or vector with all elements equal to the value.
bool isValue(const APInt &C)
SelectClass_match(const Cond_t &Cond, const LHS_t &LHS, const RHS_t &RHS)
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.
BinOp2_match(const LHS_t &LHS, const RHS_t &RHS)
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)