From 159c35b3ee500b521d682cf585e61dea2858d0dc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 5 Jan 2009 23:53:12 +0000 Subject: 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 --- include/llvm/Support/PatternMatch.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'include') 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 m_Value() { return leaf_ty(); } /// m_ConstantInt() - Match an arbitrary ConstantInt and ignore it. inline leaf_ty m_ConstantInt() { return leaf_ty(); } +template struct constantint_ty { - int64_t Val; - explicit constantint_ty(int64_t val) : Val(val) {} - template bool match(ITy *V) { if (const ConstantInt *CI = dyn_cast(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 +inline constantint_ty m_ConstantInt() { + return constantint_ty(); } 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 -inline SelectClass_match -m_SelectCst(const Cond &C, int64_t L, int64_t R) { - return SelectClass_match(C, m_ConstantInt(L), - m_ConstantInt(R)); +template +inline SelectClass_match, constantint_ty > +m_SelectCst(const Cond &C) { + return SelectClass_match, + constantint_ty >(C, m_ConstantInt(), + m_ConstantInt()); } -- cgit v1.1