[llvm-commits] CVS: llvm/include/llvm/Support/PatternMatch.h
Chris Lattner
lattner at cs.uiuc.edu
Mon Sep 26 23:38:16 PDT 2005
Changes in directory llvm/include/llvm/Support:
PatternMatch.h updated: 1.5 -> 1.6
---
Log message:
Make this slightly more efficient by pushing actual type information down
into the evaluator. This shrinks a release build of instcombine's text
section from 216363 to 215975 bytes (on PPC).
---
Diffs of the changes: (+11 -8)
PatternMatch.h | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
Index: llvm/include/llvm/Support/PatternMatch.h
diff -u llvm/include/llvm/Support/PatternMatch.h:1.5 llvm/include/llvm/Support/PatternMatch.h:1.6
--- llvm/include/llvm/Support/PatternMatch.h:1.5 Thu Apr 21 15:44:59 2005
+++ llvm/include/llvm/Support/PatternMatch.h Tue Sep 27 01:38:05 2005
@@ -71,7 +71,8 @@
// Matchers for specific binary operators
//
-template<typename LHS_t, typename RHS_t, unsigned Opcode>
+template<typename LHS_t, typename RHS_t,
+ unsigned Opcode, typename ConcreteTy = BinaryOperator>
struct BinaryOp_match {
LHS_t L;
RHS_t R;
@@ -80,9 +81,11 @@
template<typename OpTy>
bool match(OpTy *V) {
- if (Instruction *I = dyn_cast<Instruction>(V))
+ if (V->getValueType() == Value::InstructionVal + Opcode) {
+ ConcreteTy *I = cast<ConcreteTy>(V);
return I->getOpcode() == Opcode && L.match(I->getOperand(0)) &&
R.match(I->getOperand(1));
+ }
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
return CE->getOpcode() == Opcode && L.match(CE->getOperand(0)) &&
R.match(CE->getOperand(1));
@@ -139,15 +142,15 @@
}
template<typename LHS, typename RHS>
-inline BinaryOp_match<LHS, RHS, Instruction::Shl> m_Shl(const LHS &L,
- const RHS &R) {
- return BinaryOp_match<LHS, RHS, Instruction::Shl>(L, R);
+inline BinaryOp_match<LHS, RHS, Instruction::Shl,
+ ShiftInst> m_Shl(const LHS &L, const RHS &R) {
+ return BinaryOp_match<LHS, RHS, Instruction::Shl, ShiftInst>(L, R);
}
template<typename LHS, typename RHS>
-inline BinaryOp_match<LHS, RHS, Instruction::Shr> m_Shr(const LHS &L,
- const RHS &R) {
- return BinaryOp_match<LHS, RHS, Instruction::Shr>(L, R);
+inline BinaryOp_match<LHS, RHS, Instruction::Shr,
+ ShiftInst> m_Shr(const LHS &L, const RHS &R) {
+ return BinaryOp_match<LHS, RHS, Instruction::Shr, ShiftInst>(L, R);
}
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list