aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-05 23:53:12 +0000
committerChris Lattner <sabre@nondot.org>2009-01-05 23:53:12 +0000
commit159c35b3ee500b521d682cf585e61dea2858d0dc (patch)
tree7e4fe7adb82673bbce6c905dc1e0fcc8f9b1e7a0 /include
parent06ebbcc71de34fdbf6e652b2b48a2d50b6331ddc (diff)
downloadexternal_llvm-159c35b3ee500b521d682cf585e61dea2858d0dc.zip
external_llvm-159c35b3ee500b521d682cf585e61dea2858d0dc.tar.gz
external_llvm-159c35b3ee500b521d682cf585e61dea2858d0dc.tar.bz2
Change m_ConstantInt and m_SelectCst to take their constant integers
as template arguments instead of as instance variables, exposing more optimization opportunities to the compiler earlier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61776 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Support/PatternMatch.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index 55b4b6a..98964eb 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -51,10 +51,8 @@ inline leaf_ty<Value> m_Value() { return leaf_ty<Value>(); }
/// m_ConstantInt() - Match an arbitrary ConstantInt and ignore it.
inline leaf_ty<ConstantInt> m_ConstantInt() { return leaf_ty<ConstantInt>(); }
+template<int64_t Val>
struct constantint_ty {
- int64_t Val;
- explicit constantint_ty(int64_t val) : Val(val) {}
-
template<typename ITy>
bool match(ITy *V) {
if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
@@ -72,8 +70,9 @@ struct constantint_ty {
/// m_ConstantInt(int64_t) - Match a ConstantInt with a specific value
/// and ignore it.
-inline constantint_ty m_ConstantInt(int64_t Val) {
- return constantint_ty(Val);
+template<int64_t Val>
+inline constantint_ty<Val> m_ConstantInt() {
+ return constantint_ty<Val>();
}
struct zero_ty {
@@ -393,12 +392,12 @@ m_Select(const Cond &C, const LHS &L, const RHS &R) {
/// m_SelectCst - This matches a select of two constants, e.g.:
/// m_SelectCst(m_Value(V), -1, 0)
-template<typename Cond>
-inline SelectClass_match<Cond, constantint_ty, constantint_ty>
-m_SelectCst(const Cond &C, int64_t L, int64_t R) {
- return SelectClass_match<Cond, constantint_ty,
- constantint_ty>(C, m_ConstantInt(L),
- m_ConstantInt(R));
+template<int64_t L, int64_t R, typename Cond>
+inline SelectClass_match<Cond, constantint_ty<L>, constantint_ty<R> >
+m_SelectCst(const Cond &C) {
+ return SelectClass_match<Cond, constantint_ty<L>,
+ constantint_ty<R> >(C, m_ConstantInt<L>(),
+ m_ConstantInt<R>());
}