mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
add an m_ConstantInt matching predicate that binds to a uint64_t, and add an m_OneUse()
predicate that matches if the subexpr has a single use. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130235 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f7da8821b4
commit
3443493cc7
@ -40,6 +40,23 @@ bool match(Val *V, const Pattern &P) {
|
|||||||
return const_cast<Pattern&>(P).match(V);
|
return const_cast<Pattern&>(P).match(V);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename SubPattern_t>
|
||||||
|
struct OneUse_match {
|
||||||
|
SubPattern_t SubPattern;
|
||||||
|
|
||||||
|
OneUse_match(const SubPattern_t &SP) : SubPattern(SP) {}
|
||||||
|
|
||||||
|
template<typename OpTy>
|
||||||
|
bool match(OpTy *V) {
|
||||||
|
return V->hasOneUse() && SubPattern.match(V);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline OneUse_match<T> m_OneUse(const T &SubPattern) { return SubPattern; }
|
||||||
|
|
||||||
|
|
||||||
template<typename Class>
|
template<typename Class>
|
||||||
struct class_match {
|
struct class_match {
|
||||||
template<typename ITy>
|
template<typename ITy>
|
||||||
@ -227,6 +244,24 @@ struct specificval_ty {
|
|||||||
/// m_Specific - Match if we have a specific specified value.
|
/// m_Specific - Match if we have a specific specified value.
|
||||||
inline specificval_ty m_Specific(const Value *V) { return V; }
|
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<typename ITy>
|
||||||
|
bool match(ITy *V) {
|
||||||
|
if (ConstantInt *CV = dyn_cast<ConstantInt>(V))
|
||||||
|
if (CV->getBitWidth() <= 64) {
|
||||||
|
VR = CV->getZExtValue();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// 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.
|
// Matchers for specific binary operators.
|
||||||
|
Loading…
Reference in New Issue
Block a user