15
15
#define LLVM_ANALYSIS_SCALAREVOLUTIONPATTERNMATCH_H
16
16
17
17
#include " llvm/Analysis/ScalarEvolutionExpressions.h"
18
+ #include " llvm/IR/PatternMatch.h"
18
19
19
20
namespace llvm {
20
21
namespace SCEVPatternMatch {
@@ -24,34 +25,19 @@ bool match(const SCEV *S, const Pattern &P) {
24
25
return P.match (S);
25
26
}
26
27
27
- // / Match a specified integer value. \p BitWidth optionally specifies the
28
- // / bitwidth the matched constant must have. If it is 0, the matched constant
29
- // / can have any bitwidth.
30
- template <unsigned BitWidth = 0 > struct specific_intval {
31
- APInt Val;
28
+ struct specific_intval64 : public PatternMatch ::specific_intval64<false > {
29
+ specific_intval64 (uint64_t V) : PatternMatch::specific_intval64<false >(V) {}
32
30
33
- specific_intval (APInt V) : Val(std::move(V)) {}
34
-
35
- bool match (const SCEV *S) const {
36
- const auto *C = dyn_cast<SCEVConstant>(S);
37
- if (!C)
38
- return false ;
39
-
40
- if (BitWidth != 0 && C->getAPInt ().getBitWidth () != BitWidth)
41
- return false ;
42
- return APInt::isSameValue (C->getAPInt (), Val);
31
+ bool match (const SCEV *S) {
32
+ auto *Cast = dyn_cast<SCEVConstant>(S);
33
+ return Cast &&
34
+ PatternMatch::specific_intval64<false >::match (Cast->getValue ());
43
35
}
44
36
};
45
37
46
- inline specific_intval<0 > m_scev_Zero () {
47
- return specific_intval<0 >(APInt (64 , 0 ));
48
- }
49
- inline specific_intval<0 > m_scev_One () {
50
- return specific_intval<0 >(APInt (64 , 1 ));
51
- }
52
- inline specific_intval<0 > m_scev_MinusOne () {
53
- return specific_intval<0 >(APInt (64 , -1 ));
54
- }
38
+ inline specific_intval64 m_scev_Zero () { return specific_intval64 (0 ); }
39
+ inline specific_intval64 m_scev_One () { return specific_intval64 (1 ); }
40
+ inline specific_intval64 m_scev_MinusOne () { return specific_intval64 (-1 ); }
55
41
56
42
} // namespace SCEVPatternMatch
57
43
} // namespace llvm
0 commit comments