llvm::PatternMatch

Pattern-matching helpers for LLVM IR values and instructions.

Types

NameDescription
AllowFmf_match Matcher that requires a fast-math flag set on an FPMathOperator.
AnyBinaryOp_match Matches any BinaryOperator against left and right operand patterns.
AnyOps_match Matches instructions with Opcode and any number of operands.
AnyUnaryOp_match Matches any UnaryOperator against an operand pattern.
Argument_match Matcher for a specific call argument by index.
BinOpPred_match Matches a binary instruction whose opcode satisfies Predicate.
BinaryOp_match Matches a BinaryOperator with a fixed Opcode against operand patterns.
CastInst_match Matches a CastInst of a specific Class with an operand pattern.
CastOperator_match Matches a cast Operator with a fixed Opcode and operand pattern.
CmpClass_match Matches a compare instruction of Class against operand patterns.
CommutativeBinaryIntrinsic_match Matcher for a binary intrinsic with operands in either order.
ContainsMatchingVectorElement_match Matcher for a vector constant with at least one matching element.
DisjointOr_match Matches an or marked disjoint against operand patterns.
ElementWiseBitCast_match Matches a bitcast that does not change vector element count or scalar/vector kind.
Exact_match Matches a possibly-exact operator that is marked exact.
ExtractValue_match Matcher for ExtractValue with a fixed or any index.
FMaxMin_match Matches select(fcmp(Pred, L, R), L, R) fmax/fmin idioms.
FNeg_match Matches fneg, including the fsub -0.0, X form.
ICmpLike_match Matches icmp or an equivalent trunc-nuw-to-i1 pattern.
InsertValue_match Matcher for a single index InsertValue instruction.
IntrinsicID_match Matcher for a call to a specific intrinsic ID.
IntrinsicIDs_match Matcher for a call whose intrinsic ID is one of IntrIDs.
IntrinsicMatchImpl Helper that builds an intrinsic ID matcher combined with argument matchers.
LoadSimple_match Matches a simple (non-volatile, non-atomic) LoadInst.
LogicalOp_match Matcher for a logical And/Or as a bitwise op or select idiom.
NNegZExt_match Matches a zext with the nneg flag set.
NoWrapTrunc_match Matches a trunc with required no-wrap flags.
OneOps_match Matches instructions with Opcode and one operand.
OneUse_match Matcher that requires the value to have exactly one use.
OverflowingBinaryOp_match Matches an overflowing binary op with required no-wrap flags.
PtrAdd_match Matches a GEP of i8 (ptradd) against pointer and offset patterns.
PtrToIntSameSize_match Matches ptrtoint where the integer and pointer have the same bit width.
SelectLike_match Matches select or boolean zext/sext idioms equivalent to select.
ShiftLike_match Matches a shift by a constant, or the value itself with amount zero.
Shuffle_match Matches a shufflevector with operand and mask patterns.
Signum_match Matcher for the arithmetic signum idiom.
SpecificBinaryOp_match Matches a BinaryOperator whose opcode is supplied at construction time.
SpecificCmpClass_match Matches a compare of Class with a required predicate and operands.
SpecificType_match Matcher that requires a value to have a specific type and match a pattern.
Splat_match Matcher for a splat constant whose splat value matches a nested pattern.
ThreeOps_match Matches instructions with Opcode and three operands.
TwoOps_match Matches instructions with Opcode and two operands.
UAddWithOverflow_match Matcher for an icmp checking unsigned add overflow.
XorLike_match Matches xor or a nuw sub of a low-bit mask that behaves like xor.
ap_match Matcher that binds an APInt or APFloat from a constant or splat.
apf_pred_ty Match scalar and vector constants satisfying a predicate, binding an APFloat. Poison is allowed in splat vector constants.
api_pred_ty This helper class is used to match scalar and vector constants that satisfy a specified predicate, and bind them to an APInt.
bind_const_intval_ty Matcher that binds a ConstantInt value into a uint64_t.
bind_immconstant_ty Matcher that binds an immediate Constant.
br_match Matches an unconditional branch and captures its successor.
brc_match Matches a conditional branch with condition and successor patterns.
constantint_match Matcher for a ConstantInt with a compile-time integer value.
cstval_pred_ty Match scalar, splat, or fixed-vector constants that satisfy a predicate. For fixed width vector constants, poison elements are ignored if AllowPoison is true.
custom_checkfn Predicate that applies a user-provided check function to AP values.
icmp_pred_with_threshold Predicate that compares an APInt against a threshold with an icmp predicate.
immconstant_ty Helper that recognizes immediate (non-ConstantExpr) constants.
is_all_ones Predicate that matches all-ones APInt values.
is_any_apint Predicate that matches any APInt value.
is_any_zero_fp Predicate that matches any zero APFloat value.
is_bitwiselogic_op Predicate true for bitwise logic opcodes (and/or/xor).
is_finite Predicate that matches finite APFloat values.
is_finitenonzero Predicate that matches finite non-zero APFloat values.
is_idiv_op Predicate true for integer division opcodes.
is_inf Predicate that matches infinity APFloat values.
is_irem_op Predicate true for integer remainder opcodes.
is_logical_shift_op Predicate true for logical shifts (shl or lshr).
is_lowbit_mask Predicate that matches low-bit-mask APInt values.
is_lowbit_mask_or_zero Predicate that matches zero or low-bit-mask APInt values.
is_maxsignedvalue Predicate that matches the maximum signed APInt value.
is_nan Predicate that matches NaN APFloat values.
is_neg_zero_fp Predicate that matches negative-zero APFloat values.
is_negated_power2 Predicate that matches negated power-of-two APInt values.
is_negated_power2_or_zero Predicate that matches zero or negated power-of-two APInt values.
is_negative Predicate that matches negative APInt values.
is_non_zero_fp Predicate that matches non-zero APFloat values.
is_non_zero_int Predicate that matches non-zero APInt values.
is_non_zero_not_denormal_fp Predicate that matches non-zero non-denormal APFloat values.
is_noninf Predicate that matches non-infinity APFloat values.
is_nonnan Predicate that matches non-NaN APFloat values.
is_nonnegative Predicate that matches non-negative APInt values.
is_nonpositive Predicate that matches non-positive APInt values.
is_one Predicate that matches APInt value one.
is_pos_zero_fp Predicate that matches positive-zero APFloat values.
is_power2 Predicate that matches power-of-two APInt values.
is_power2_or_zero Predicate that matches zero or power-of-two APInt values.
is_right_shift_op Predicate true for logical or arithmetic right shifts.
is_shift_op Predicate true for shift opcodes.
is_shifted_mask Predicate that matches shifted-mask APInt values.
is_sign_mask Predicate that matches sign-mask APInt values.
is_signed_inf Predicate that matches signed infinity APFloat values.
is_strictlypositive Predicate that matches strictly positive APInt values.
is_zero Matcher for null constants or integer zero vectors.
is_zero_int Predicate that matches zero APInt values.
m_Mask Binds any shuffle mask to an ArrayRef output.
m_SpecificMask Matches a shuffle mask equal to a specific ArrayRef.
m_SplatMask Matches a shuffle mask where every element is equal.
m_SplatOrPoisonMask Matches a splat mask, allowing poison, and binds the splat index.
m_ZeroMask Matches a shuffle mask whose elements are all 0 or poison (-1).
match_immconstant_ty Matcher for an immediate constant that does not bind.
ofmax_pred_ty Helper class for identifying ordered max predicates.
ofmin_pred_ty Helper class for identifying ordered min predicates.
specific_bbval Match a specified basic block value.
specific_fpval Match a specified floating point value or vector of all elements of that value.
specific_intval Match a specified integer value or vector of all elements of that value.
specific_intval64 Match a specified 64-bit integer value or vector of all elements of that value.
specificval_ty Matcher for a specific Value*.
ufmax_pred_ty Helper class for identifying unordered max predicates.
ufmin_pred_ty Helper class for identifying unordered min predicates.
undef_match Matcher for undef and poison constants, including all-undef aggregates.

Type Aliases

NameDescription
cst_pred_ty specialization of cstval_pred_ty for ConstantInt
cstfp_pred_ty specialization of cstval_pred_ty for ConstantFP

Functions

NameDescription
m_APFloat Match a ConstantFP or splatted ConstantVector, binding the specified pointer to the contained APFloat.
m_APFloatAllowPoison Match APFloat while allowing poison in splat vector constants.
m_APFloatForbidPoison Match APFloat while forbidding poison in splat vector constants.
m_APInt Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt.
m_APIntAllowPoison Match APInt while allowing poison in splat vector constants.
m_APIntForbidPoison Match APInt while forbidding poison in splat vector constants.
m_AShr Matches an ashr of L and R.
m_AShrOrSelf Matches ashr L, ConstShAmt or L itself (R will be set to zero in this case).
m_Add Matches an add of L and R.
m_AddLike Match either "add" or "or disjoint".
m_AllOnes Match an integer or vector with all bits set. For vectors, this includes constants with undefined elements.
m_AllOnesForbidPoison Match an all-ones integer or vector, forbidding poison elements.
m_AllOnesOrPoison Match an all-ones constant or poison.
m_AllowContract Match an FP operator that allows contraction and matches SubPattern.
m_AllowReassoc Match an FP operator that allows reassociation and matches SubPattern.
m_AllowReciprocal Match an FP operator that allows reciprocal and matches SubPattern.
m_And Matches an and of L and R.
m_AnyIntegralConstant Match an integer or vector with any integral constant. For vectors, this includes constants with undefined elements.
m_AnyIntrinsic m_AnyIntrinsic overloads
m_AnyZeroFP Match a floating-point negative zero or positive zero. For vectors, this includes constants with undefined elements.
m_ApproxFunc Match an FP operator that allows approximate functions and matches SubPattern.
m_Argument Match an argument.
m_BSwap Matches a call to the llvm.bswap intrinsic.
m_BasicBlock m_BasicBlock overloads
m_BinOp m_BinOp overloads
m_BitCast Matches BitCast.
m_BitReverse Matches a call to the llvm.bitreverse intrinsic.
m_BitwiseLogic Matches bitwise logic operations.
m_Br m_Br overloads
m_CastOrSelf Matches any cast or self. Used to ignore casts.
m_CheckedFp m_CheckedFp overloads
m_CheckedInt m_CheckedInt overloads
m_Cmp m_Cmp overloads
m_Constant m_Constant overloads
m_ConstantExpr m_ConstantExpr overloads
m_ConstantFP m_ConstantFP overloads
m_ConstantInt m_ConstantInt overloads
m_ConstantSplat Match a constant splat. TODO: Extend this to non-constant splats.
m_ContainsMatchingVectorElement Match a vector constant with an element matching SubPattern.
m_CopySign Matches a call to the llvm.copysign intrinsic.
m_Ctlz Matches a call to the llvm.ctlz intrinsic.
m_Ctpop Matches a call to the llvm.ctpop intrinsic.
m_Cttz Matches a call to the llvm.cttz intrinsic.
m_Deferred m_Deferred overloads
m_Deinterleave2 Matches a call to the llvm.vector.deinterleave2 intrinsic.
m_DisjointOr Matches a disjoint or of L and R.
m_ElementWiseBitCast Matches an element-wise BitCast.
m_Exact Matches SubPattern only when the operator is marked exact.
m_ExtractElt Matches ExtractElementInst.
m_ExtractValue m_ExtractValue overloads
m_FAbs Matches a call to the llvm.fabs intrinsic.
m_FAdd Matches an fadd of L and R.
m_FCanonicalize Matches a call to the llvm.canonicalize intrinsic.
m_FCmp m_FCmp overloads
m_FDiv Matches an fdiv of L and R.
m_FMaxNum Matches a call to the llvm.maxnum intrinsic.
m_FMaxNum_or_FMaximumNum Matches a call to llvm.maxnum or llvm.maximumnum.
m_FMaximum Matches a call to the llvm.maximum intrinsic.
m_FMaximumNum Matches a call to the llvm.maximumnum intrinsic.
m_FMinNum Matches a call to the llvm.minnum intrinsic.
m_FMinNum_or_FMinimumNum Matches a call to llvm.minnum or llvm.minimumnum.
m_FMinimum Matches a call to the llvm.minimum intrinsic.
m_FMinimumNum Matches a call to the llvm.minimumnum intrinsic.
m_FMul Matches an fmul of L and R.
m_FNeg Match 'fneg X' as 'fsub -0.0, X'.
m_FNegNSZ Match 'fneg X' as 'fsub +-0.0, X'.
m_FPExt Matches FPExt.
m_FPOne Match a float 1.0 or vector with all elements equal to 1.0.
m_FPToI Matches FPToUI or FPToSI.
m_FPToSI Matches FPToSI.
m_FPToUI Matches FPToUI.
m_FPTrunc Matches FPTrunc.
m_FRem Matches an frem of L and R.
m_FShl Matches a call to the llvm.fshl intrinsic.
m_FShr Matches a call to the llvm.fshr intrinsic.
m_FSub Matches an fsub of L and R.
m_Finite m_Finite overloads
m_FiniteNonZero m_FiniteNonZero overloads
m_Freeze Matches FreezeInst.
m_GEP Matches GetElementPtrInst.
m_ICmp m_ICmp overloads
m_ICmpLike Matches icmp or an equivalent trunc-nuw-to-i1 pattern.
m_IDiv Matches integer division operations.
m_IRem Matches integer remainder operations.
m_IToFP Matches UIToFP or SIToFP.
m_ImmConstant m_ImmConstant overloads
m_Inf Match a positive or negative infinity FP constant. For vectors, this includes constants with undefined elements.
m_InsertElt Matches InsertElementInst.
m_InsertValue Matches a single index InsertValue instruction.
m_Instruction m_Instruction overloads
m_IntToPtr Matches IntToPtr.
m_Interleave2 Matches a call to the llvm.vector.interleave2 intrinsic.
m_Intrinsic Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
m_LShr Matches an lshr of L and R.
m_LShrOrSelf Matches lshr L, ConstShAmt or L itself (R will be set to zero in this case).
m_Load Matches LoadInst.
m_LoadSimple Matches a simple (non-volatile, non-atomic) LoadInst.
m_LogicalAnd m_LogicalAnd overloads
m_LogicalOp m_LogicalOp overloads
m_LogicalOr m_LogicalOr overloads
m_LogicalShift Matches logical shift operations.
m_LowBitMask m_LowBitMask overloads
m_LowBitMaskOrZero m_LowBitMaskOrZero overloads
m_MaskedGather Matches MaskedGather Intrinsic.
m_MaskedLoad Matches MaskedLoad Intrinsic.
m_MaskedStore Matches MaskedStore Intrinsic.
m_MaxOrMin Matches a call to llvm.smax, smin, umax, or umin.
m_MaxSignedValue m_MaxSignedValue overloads
m_Mul Matches a mul of L and R.
m_NNegZExt Matches a zext with the nneg flag.
m_NSWAdd Matches an add nsw of L and R.
m_NSWAddLike Match either "add nsw" or "or disjoint".
m_NSWMul Matches a mul nsw of L and R.
m_NSWNeg Matches a 'Neg' as 'sub nsw 0, V'.
m_NSWShl Matches a shl nsw of L and R.
m_NSWSub Matches a sub nsw of L and R.
m_NSWTrunc Matches trunc nsw.
m_NUWAdd Matches an add nuw of L and R.
m_NUWAddLike Match either "add nuw" or "or disjoint".
m_NUWMul Matches a mul nuw of L and R.
m_NUWShl Matches a shl nuw of L and R.
m_NUWSub Matches a sub nuw of L and R.
m_NUWTrunc Matches trunc nuw.
m_NaN Match an arbitrary NaN constant. This includes quiet and signalling nans. For vectors, this includes constants with undefined elements.
m_Neg Matches a 'Neg' as 'sub 0, V'.
m_NegInf Match a negative infinity FP constant. For vectors, this includes constants with undefined elements.
m_NegZeroFP Match a floating-point negative zero. For vectors, this includes constants with undefined elements.
m_NegatedPower2 m_NegatedPower2 overloads
m_NegatedPower2OrZero m_NegatedPower2OrZero overloads
m_Negative m_Negative overloads
m_NoInfs Match an FP operator with ninf and matches SubPattern.
m_NoNaNs Match an FP operator with nnan and matches SubPattern.
m_NoSignedZeros Match an FP operator with nsz and matches SubPattern.
m_NonInf Match a non-infinity FP constant, i.e. finite or NaN. For vectors, this includes constants with undefined elements.
m_NonNaN Match a non-NaN FP constant. For vectors, this includes constants with undefined elements.
m_NonNegative m_NonNegative overloads
m_NonPositive m_NonPositive overloads
m_NonZeroFP Match a floating-point non-zero. For vectors, this includes constants with undefined elements.
m_NonZeroInt Match a non-zero integer or a vector with all non-zero elements. For vectors, this includes constants with undefined elements.
m_NonZeroNotDenormalFP Match a floating-point non-zero that is not a denormal. For vectors, this includes constants with undefined elements.
m_Not Matches a 'Not' as 'xor V, -1' or 'xor -1, V'. NOTE: we first match the 'Not' (by matching '-1'), and only then match the inner matcher!
m_NotForbidPoison Matches a 'Not' as 'xor V, -1' without allowing poison in the all-ones.
m_One Match an integer 1 or a vector with all elements equal to 1. For vectors, this includes constants with undefined elements.
m_OneUse Match a value with exactly one use that also matches SubPattern.
m_Or Matches an or of L and R.
m_OrdFMax Match an ordered floating-point maximum.
m_OrdFMin Match an ordered floating-point minimum.
m_OrdOrUnordFMax Match an ordered or unordered floating-point maximum.
m_OrdOrUnordFMin Match an ordered or unordered floating-point minimum.
m_Phi Match a PHI node, capturing it if we match.
m_Poison Match an arbitrary poison constant.
m_PosInf Match a positive infinity FP constant. For vectors, this includes constants with undefined elements.
m_PosZeroFP Match a floating-point positive zero. For vectors, this includes constants with undefined elements.
m_Power2 m_Power2 overloads
m_Power2OrZero m_Power2OrZero overloads
m_PtrAdd Matches GEP with i8 source element type.
m_PtrToAddr Matches PtrToAddr.
m_PtrToInt Matches PtrToInt.
m_PtrToIntOrAddr Matches PtrToInt or PtrToAddr.
m_PtrToIntSameSize Matches ptrtoint when the integer and pointer have the same size.
m_SDiv Matches an sdiv of L and R.
m_SExt Matches SExt.
m_SExtLike Match either "sext" or "zext nneg".
m_SExtOrSelf Matches SExt or the value itself.
m_SIToFP Matches SIToFP.
m_SMax Matches a call to the llvm.smax intrinsic.
m_SMin Matches a call to the llvm.smin intrinsic.
m_SRem Matches an srem of L and R.
m_Select Matches SelectInst.
m_SelectCst Matches a select of two integer constants.
m_SelectLike Matches a boolean-controlled select or equivalent zext/sext.
m_Shift Matches shift operations.
m_ShiftedMask Match an integer or vector shifted-mask constant.
m_Shl Matches a shl of L and R.
m_ShlOrSelf Matches shl L, ConstShAmt or L itself (R will be set to zero in this case).
m_Shr Matches right-shift operations.
m_Shuffle m_Shuffle overloads
m_SignMask Match an integer or vector with only the sign bit(s) set. For vectors, this includes constants with undefined elements.
m_Signum Matches a signum pattern.
m_Specific Match if we have a specific specified value.
m_SpecificBB Match a specific basic block value.
m_SpecificCmp Matches any compare of L and R with predicate MatchPred.
m_SpecificFCmp Matches an fcmp of L and R with predicate MatchPred.
m_SpecificFP Match a specific floating point value or vector with all elements equal to the value.
m_SpecificICmp Matches an icmp of L and R with predicate MatchPred.
m_SpecificInt m_SpecificInt overloads
m_SpecificIntAllowPoison m_SpecificIntAllowPoison overloads
m_SpecificInt_ICMP Match an integer or vector with every element comparing 'pred' (eg/ne/...) to Threshold. For vectors, this includes constants with undefined elements.
m_SpecificType m_SpecificType overloads
m_Sqrt Matches a call to the llvm.sqrt intrinsic.
m_Store Matches StoreInst.
m_StrictlyPositive m_StrictlyPositive overloads
m_Sub Matches a sub of L and R.
m_Trunc Matches Trunc.
m_TruncOrSelf Matches Trunc or the value itself.
m_UAddWithOverflow Match an icmp instruction checking for unsigned overflow on addition.
m_UDiv Matches a udiv of L and R.
m_UIToFP Matches UIToFP.
m_UMax Matches a call to the llvm.umax intrinsic.
m_UMin Matches a call to the llvm.umin intrinsic.
m_URem Matches a urem of L and R.
m_UnOp m_UnOp overloads
m_UnconditionalBr Matches an unconditional branch.
m_Undef Match an arbitrary undef constant.
m_UndefValue m_UndefValue overloads
m_UnordFMax Match an unordered floating-point maximum.
m_UnordFMin Match an unordered floating-point minimum.
m_VScale Matches a call to llvm.vscale().
m_Value m_Value overloads
m_VecReverse Matches a call to the llvm.vector.reverse intrinsic.
m_VectorInsert Matches a call to the llvm.vector.insert intrinsic.
m_WithOverflowInst m_WithOverflowInst overloads
m_Xor Matches an xor of L and R.
m_ZExt Matches ZExt.
m_ZExtOrSExt Matches ZExt or SExt.
m_ZExtOrSExtOrSelf Matches ZExt, SExt, or the value itself.
m_ZExtOrSelf Matches ZExt or the value itself.
m_ZExtOrTruncOrSelf Matches ZExt, Trunc, or the value itself.
m_Zero Match any null constant or a vector with all elements equal to 0. For vectors, this includes constants with undefined elements.
m_ZeroInt Match an integer 0 or a vector with all elements equal to 0. For vectors, this includes constants with undefined elements.
m_ZeroOrPoison Match a zero constant or poison.
m_c_Add Matches a Add with LHS and RHS in either order.
m_c_And Matches an And with LHS and RHS in either order.
m_c_BinOp m_c_BinOp overloads
m_c_BitwiseLogic Matches bitwise logic operations in either order.
m_c_DisjointOr Matches a disjoint or of L and R in either order.
m_c_FAdd Matches FAdd with LHS and RHS in either order.
m_c_FMul Matches FMul with LHS and RHS in either order.
m_c_ICmp m_c_ICmp overloads
m_c_Intrinsic Matches a binary intrinsic with operands in either order.
m_c_LogicalAnd Matches L && R with LHS and RHS in either order.
m_c_LogicalOp Matches either L && R or L || R with LHS and RHS in either order.
m_c_LogicalOr Matches L || R with LHS and RHS in either order.
m_c_MaxOrMin Matches smin/smax/umin/umax with operands in either order.
m_c_Mul Matches a Mul with LHS and RHS in either order.
m_c_NSWAdd Matches an add nsw of L and R in either order.
m_c_NUWAdd Matches an add nuw of L and R in either order.
m_c_Or Matches an Or with LHS and RHS in either order.
m_c_SMax Matches an SMax with LHS and RHS in either order.
m_c_SMin Matches an SMin with LHS and RHS in either order.
m_c_Select Match Select(C, LHS, RHS) or Select(C, RHS, LHS).
m_c_SpecificICmp Matches an icmp of L and R with MatchPred in either order.
m_c_UMax Matches a UMax with LHS and RHS in either order.
m_c_UMin Matches a UMin with LHS and RHS in either order.
m_c_Xor Matches an Xor with LHS and RHS in either order.
m_c_XorLike Match either (xor L, R), (xor R, L) or (sub nuw R, L) iff R.isMask().
match match overloads
match_fn A match functor that can be used as a UnaryPredicate in functional algorithms like all_of.

Using Namespace Directives

NameDescription
PatternMatchHelpers Pattern-match helpers specialized for SCEV use wrappers.