@@ -56,6 +56,16 @@ template <typename Class> struct class_match {
56
56
template <typename ITy> bool match (ITy *V) const { return isa<Class>(V); }
57
57
};
58
58
59
+ inline class_match<const SCEV> m_SCEV () { return class_match<const SCEV>(); }
60
+
61
+ inline class_match<const SCEVConstant> m_SCEVConstant () {
62
+ return class_match<const SCEVConstant>();
63
+ }
64
+
65
+ inline class_match<const SCEVUnknown> m_SCEVUnknown () {
66
+ return class_match<const SCEVUnknown>();
67
+ }
68
+
59
69
template <typename Class> struct bind_ty {
60
70
Class *&VR;
61
71
@@ -91,6 +101,25 @@ struct specificscev_ty {
91
101
// / Match if we have a specific specified SCEV.
92
102
inline specificscev_ty m_Specific (const SCEV *S) { return S; }
93
103
104
+ template <typename Op0_t> struct cst_match {
105
+ Op0_t Op0;
106
+
107
+ cst_match (Op0_t Op0) : Op0(Op0) {}
108
+
109
+ bool match (const SCEV *S) const {
110
+ assert ((isa<SCEVCouldNotCompute>(S) || !S->getType ()->isVectorTy ()) &&
111
+ " no vector types expected from SCEVs" );
112
+ auto *C = dyn_cast<SCEVConstant>(S);
113
+ return C && C->getAPInt () == Op0;
114
+ }
115
+ };
116
+
117
+ // / Match an SCEV constant with an APInt.
118
+ inline cst_match<APInt> m_SCEVConstant (const APInt &V) { return V; }
119
+
120
+ // / Match an SCEV constant with a plain integer.
121
+ inline cst_match<uint64_t > m_SCEVConstant (uint64_t V) { return V; }
122
+
94
123
// / Match a unary SCEV.
95
124
template <typename SCEVTy, typename Op0_t> struct SCEVUnaryExpr_match {
96
125
Op0_t Op0;
@@ -147,6 +176,17 @@ m_scev_Add(const Op0_t &Op0, const Op1_t &Op1) {
147
176
return m_scev_Binary<SCEVAddExpr>(Op0, Op1);
148
177
}
149
178
179
+ template <typename Op0_t, typename Op1_t>
180
+ inline SCEVBinaryExpr_match<SCEVMulExpr, Op0_t, Op1_t>
181
+ m_scev_Mul (const Op0_t &Op0, const Op1_t &Op1) {
182
+ return m_scev_Binary<SCEVMulExpr>(Op0, Op1);
183
+ }
184
+
185
+ template <typename Op0_t, typename Op1_t>
186
+ inline SCEVBinaryExpr_match<SCEVUDivExpr, Op0_t, Op1_t>
187
+ m_scev_UDiv (const Op0_t &Op0, const Op1_t &Op1) {
188
+ return m_scev_Binary<SCEVUDivExpr>(Op0, Op1);
189
+ }
150
190
} // namespace SCEVPatternMatch
151
191
} // namespace llvm
152
192
0 commit comments