diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h index 221fa8b3ebf..36b6db7a72c 100644 --- a/include/llvm/Support/PatternMatch.h +++ b/include/llvm/Support/PatternMatch.h @@ -41,13 +41,13 @@ bool match(Val *V, const Pattern &P) { return const_cast(P).match(V); } - + template struct OneUse_match { SubPattern_t SubPattern; - + OneUse_match(const SubPattern_t &SP) : SubPattern(SP) {} - + template bool match(OpTy *V) { return V->hasOneUse() && SubPattern.match(V); @@ -56,8 +56,8 @@ struct OneUse_match { template inline OneUse_match m_OneUse(const T &SubPattern) { return SubPattern; } - - + + template struct class_match { template @@ -74,7 +74,7 @@ inline class_match m_ConstantInt() { inline class_match m_Undef() { return class_match(); } inline class_match m_Constant() { return class_match(); } - + struct match_zero { template bool match(ITy *V) { @@ -83,12 +83,12 @@ struct match_zero { return false; } }; - + /// m_Zero() - Match an arbitrary zero/null constant. This includes /// zero_initializer for vectors and ConstantPointerNull for pointers. inline match_zero m_Zero() { return match_zero(); } - - + + struct apint_match { const APInt *&Res; apint_match(const APInt *&R) : Res(R) {} @@ -114,12 +114,12 @@ struct apint_match { return false; } }; - + /// m_APInt - Match a ConstantInt or splatted ConstantVector, binding the /// specified pointer to the contained APInt. inline apint_match m_APInt(const APInt *&Res) { return Res; } - + template struct constantint_match { template @@ -161,7 +161,7 @@ struct cst_pred_ty : public Predicate { return false; } }; - + /// 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. template @@ -175,7 +175,7 @@ struct api_pred_ty : public Predicate { Res = &CI->getValue(); return true; } - + // FIXME: remove. if (const ConstantVector *CV = dyn_cast(V)) if (ConstantInt *CI = dyn_cast_or_null(CV->getSplatValue())) @@ -183,7 +183,7 @@ struct api_pred_ty : public Predicate { Res = &CI->getValue(); return true; } - + if (const ConstantDataVector *CV = dyn_cast(V)) if (ConstantInt *CI = dyn_cast_or_null(CV->getSplatValue())) if (this->isValue(CI->getValue())) { @@ -194,8 +194,8 @@ struct api_pred_ty : public Predicate { return false; } }; - - + + struct is_one { bool isValue(const APInt &C) { return C == 1; } }; @@ -203,11 +203,11 @@ struct is_one { /// m_One() - Match an integer 1 or a vector with all elements equal to 1. inline cst_pred_ty m_One() { return cst_pred_ty(); } inline api_pred_ty m_One(const APInt *&V) { return V; } - + struct is_all_ones { bool isValue(const APInt &C) { return C.isAllOnesValue(); } }; - + /// m_AllOnes() - Match an integer or vector with all bits set to true. inline cst_pred_ty m_AllOnes() {return cst_pred_ty();} inline api_pred_ty m_AllOnes(const APInt *&V) { return V; } @@ -269,7 +269,7 @@ inline specificval_ty m_Specific(const Value *V) { return V; } struct bind_const_intval_ty { uint64_t &VR; bind_const_intval_ty(uint64_t &V) : VR(V) {} - + template bool match(ITy *V) { if (ConstantInt *CV = dyn_cast(V)) @@ -284,7 +284,7 @@ struct bind_const_intval_ty { /// m_ConstantInt - Match a ConstantInt and bind to its value. This does not /// match ConstantInts wider than 64-bits. inline bind_const_intval_ty m_ConstantInt(uint64_t &V) { return V; } - + //===----------------------------------------------------------------------===// // Matchers for specific binary operators. // @@ -583,7 +583,7 @@ inline CastClass_match m_BitCast(const OpTy &Op) { return CastClass_match(Op); } - + /// m_PtrToInt template inline CastClass_match @@ -611,7 +611,7 @@ inline CastClass_match m_ZExt(const OpTy &Op) { return CastClass_match(Op); } - + //===----------------------------------------------------------------------===// // Matchers for unary operators