mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Remove a bunch more now-unnecessary Context arguments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78809 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -31,20 +31,19 @@
|
||||
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/LLVMContext.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace PatternMatch {
|
||||
|
||||
template<typename Val, typename Pattern>
|
||||
bool match(Val *V, const Pattern &P, LLVMContext &Context) {
|
||||
return const_cast<Pattern&>(P).match(V, Context);
|
||||
bool match(Val *V, const Pattern &P) {
|
||||
return const_cast<Pattern&>(P).match(V);
|
||||
}
|
||||
|
||||
template<typename Class>
|
||||
struct leaf_ty {
|
||||
template<typename ITy>
|
||||
bool match(ITy *V, LLVMContext&) { return isa<Class>(V); }
|
||||
bool match(ITy *V) { return isa<Class>(V); }
|
||||
};
|
||||
|
||||
/// m_Value() - Match an arbitrary value and ignore it.
|
||||
@@ -55,7 +54,7 @@ inline leaf_ty<ConstantInt> m_ConstantInt() { return leaf_ty<ConstantInt>(); }
|
||||
template<int64_t Val>
|
||||
struct constantint_ty {
|
||||
template<typename ITy>
|
||||
bool match(ITy *V, LLVMContext&) {
|
||||
bool match(ITy *V) {
|
||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
|
||||
const APInt &CIV = CI->getValue();
|
||||
if (Val >= 0)
|
||||
@@ -78,7 +77,7 @@ inline constantint_ty<Val> m_ConstantInt() {
|
||||
|
||||
struct zero_ty {
|
||||
template<typename ITy>
|
||||
bool match(ITy *V, LLVMContext&) {
|
||||
bool match(ITy *V) {
|
||||
if (const Constant *C = dyn_cast<Constant>(V))
|
||||
return C->isNullValue();
|
||||
return false;
|
||||
@@ -95,7 +94,7 @@ struct bind_ty {
|
||||
bind_ty(Class *&V) : VR(V) {}
|
||||
|
||||
template<typename ITy>
|
||||
bool match(ITy *V, LLVMContext&) {
|
||||
bool match(ITy *V) {
|
||||
if (Class *CV = dyn_cast<Class>(V)) {
|
||||
VR = CV;
|
||||
return true;
|
||||
@@ -116,7 +115,7 @@ struct specificval_ty {
|
||||
specificval_ty(const Value *V) : Val(V) {}
|
||||
|
||||
template<typename ITy>
|
||||
bool match(ITy *V, LLVMContext&) {
|
||||
bool match(ITy *V) {
|
||||
return V == Val;
|
||||
}
|
||||
};
|
||||
@@ -138,15 +137,15 @@ struct BinaryOp_match {
|
||||
BinaryOp_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {}
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V, LLVMContext &Context) {
|
||||
bool match(OpTy *V) {
|
||||
if (V->getValueID() == Value::InstructionVal + Opcode) {
|
||||
ConcreteTy *I = cast<ConcreteTy>(V);
|
||||
return I->getOpcode() == Opcode && L.match(I->getOperand(0), Context) &&
|
||||
R.match(I->getOperand(1), Context);
|
||||
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), Context) &&
|
||||
R.match(CE->getOperand(1), Context);
|
||||
return CE->getOpcode() == Opcode && L.match(CE->getOperand(0)) &&
|
||||
R.match(CE->getOperand(1));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -270,20 +269,20 @@ struct Shr_match {
|
||||
Shr_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {}
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V, LLVMContext &Context) {
|
||||
bool match(OpTy *V) {
|
||||
if (V->getValueID() == Value::InstructionVal + Instruction::LShr ||
|
||||
V->getValueID() == Value::InstructionVal + Instruction::AShr) {
|
||||
ConcreteTy *I = cast<ConcreteTy>(V);
|
||||
return (I->getOpcode() == Instruction::AShr ||
|
||||
I->getOpcode() == Instruction::LShr) &&
|
||||
L.match(I->getOperand(0), Context) &&
|
||||
R.match(I->getOperand(1), Context);
|
||||
L.match(I->getOperand(0)) &&
|
||||
R.match(I->getOperand(1));
|
||||
}
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
||||
return (CE->getOpcode() == Instruction::LShr ||
|
||||
CE->getOpcode() == Instruction::AShr) &&
|
||||
L.match(CE->getOperand(0), Context) &&
|
||||
R.match(CE->getOperand(1), Context);
|
||||
L.match(CE->getOperand(0)) &&
|
||||
R.match(CE->getOperand(1));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -310,10 +309,10 @@ struct BinaryOpClass_match {
|
||||
: Opcode(0), L(LHS), R(RHS) {}
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V, LLVMContext &Context) {
|
||||
bool match(OpTy *V) {
|
||||
if (Class *I = dyn_cast<Class>(V))
|
||||
if (L.match(I->getOperand(0), Context) &&
|
||||
R.match(I->getOperand(1), Context)) {
|
||||
if (L.match(I->getOperand(0)) &&
|
||||
R.match(I->getOperand(1))) {
|
||||
if (Opcode)
|
||||
*Opcode = I->getOpcode();
|
||||
return true;
|
||||
@@ -356,10 +355,10 @@ struct CmpClass_match {
|
||||
: Predicate(Pred), L(LHS), R(RHS) {}
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V, LLVMContext &Context) {
|
||||
bool match(OpTy *V) {
|
||||
if (Class *I = dyn_cast<Class>(V))
|
||||
if (L.match(I->getOperand(0), Context) &&
|
||||
R.match(I->getOperand(1), Context)) {
|
||||
if (L.match(I->getOperand(0)) &&
|
||||
R.match(I->getOperand(1))) {
|
||||
Predicate = I->getPredicate();
|
||||
return true;
|
||||
}
|
||||
@@ -396,11 +395,11 @@ struct SelectClass_match {
|
||||
: C(Cond), L(LHS), R(RHS) {}
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V, LLVMContext &Context) {
|
||||
bool match(OpTy *V) {
|
||||
if (SelectInst *I = dyn_cast<SelectInst>(V))
|
||||
return C.match(I->getOperand(0), Context) &&
|
||||
L.match(I->getOperand(1), Context) &&
|
||||
R.match(I->getOperand(2), Context);
|
||||
return C.match(I->getOperand(0)) &&
|
||||
L.match(I->getOperand(1)) &&
|
||||
R.match(I->getOperand(2));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -433,9 +432,9 @@ struct CastClass_match {
|
||||
CastClass_match(const Op_t &OpMatch) : Op(OpMatch) {}
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V, LLVMContext &Context) {
|
||||
bool match(OpTy *V) {
|
||||
if (Class *I = dyn_cast<Class>(V))
|
||||
return Op.match(I->getOperand(0), Context);
|
||||
return Op.match(I->getOperand(0));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -457,27 +456,27 @@ struct not_match {
|
||||
not_match(const LHS_t &LHS) : L(LHS) {}
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V, LLVMContext &Context) {
|
||||
bool match(OpTy *V) {
|
||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||
if (I->getOpcode() == Instruction::Xor)
|
||||
return matchIfNot(I->getOperand(0), I->getOperand(1), Context);
|
||||
return matchIfNot(I->getOperand(0), I->getOperand(1));
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
||||
if (CE->getOpcode() == Instruction::Xor)
|
||||
return matchIfNot(CE->getOperand(0), CE->getOperand(1), Context);
|
||||
return matchIfNot(CE->getOperand(0), CE->getOperand(1));
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
|
||||
return L.match(ConstantExpr::getNot(CI), Context);
|
||||
return L.match(ConstantExpr::getNot(CI));
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
bool matchIfNot(Value *LHS, Value *RHS, LLVMContext &Context) {
|
||||
bool matchIfNot(Value *LHS, Value *RHS) {
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS))
|
||||
return CI->isAllOnesValue() && L.match(LHS, Context);
|
||||
return CI->isAllOnesValue() && L.match(LHS);
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(LHS))
|
||||
return CI->isAllOnesValue() && L.match(RHS, Context);
|
||||
return CI->isAllOnesValue() && L.match(RHS);
|
||||
if (ConstantVector *CV = dyn_cast<ConstantVector>(RHS))
|
||||
return CV->isAllOnesValue() && L.match(LHS, Context);
|
||||
return CV->isAllOnesValue() && L.match(LHS);
|
||||
if (ConstantVector *CV = dyn_cast<ConstantVector>(LHS))
|
||||
return CV->isAllOnesValue() && L.match(RHS, Context);
|
||||
return CV->isAllOnesValue() && L.match(RHS);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -493,21 +492,21 @@ struct neg_match {
|
||||
neg_match(const LHS_t &LHS) : L(LHS) {}
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V, LLVMContext &Context) {
|
||||
bool match(OpTy *V) {
|
||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||
if (I->getOpcode() == Instruction::Sub)
|
||||
return matchIfNeg(I->getOperand(0), I->getOperand(1), Context);
|
||||
return matchIfNeg(I->getOperand(0), I->getOperand(1));
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
||||
if (CE->getOpcode() == Instruction::Sub)
|
||||
return matchIfNeg(CE->getOperand(0), CE->getOperand(1), Context);
|
||||
return matchIfNeg(CE->getOperand(0), CE->getOperand(1));
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
|
||||
return L.match(ConstantExpr::getNeg(CI), Context);
|
||||
return L.match(ConstantExpr::getNeg(CI));
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
bool matchIfNeg(Value *LHS, Value *RHS, LLVMContext &Context) {
|
||||
bool matchIfNeg(Value *LHS, Value *RHS) {
|
||||
return LHS == ConstantFP::getZeroValueForNegation(LHS->getType()) &&
|
||||
L.match(RHS, Context);
|
||||
L.match(RHS);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -522,21 +521,21 @@ struct fneg_match {
|
||||
fneg_match(const LHS_t &LHS) : L(LHS) {}
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V, LLVMContext &Context) {
|
||||
bool match(OpTy *V) {
|
||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||
if (I->getOpcode() == Instruction::FSub)
|
||||
return matchIfFNeg(I->getOperand(0), I->getOperand(1), Context);
|
||||
return matchIfFNeg(I->getOperand(0), I->getOperand(1));
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
||||
if (CE->getOpcode() == Instruction::FSub)
|
||||
return matchIfFNeg(CE->getOperand(0), CE->getOperand(1), Context);
|
||||
return matchIfFNeg(CE->getOperand(0), CE->getOperand(1));
|
||||
if (ConstantFP *CF = dyn_cast<ConstantFP>(V))
|
||||
return L.match(ConstantExpr::getFNeg(CF), Context);
|
||||
return L.match(ConstantExpr::getFNeg(CF));
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
bool matchIfFNeg(Value *LHS, Value *RHS, LLVMContext &Context) {
|
||||
bool matchIfFNeg(Value *LHS, Value *RHS) {
|
||||
return LHS == ConstantFP::getZeroValueForNegation(LHS->getType()) &&
|
||||
L.match(RHS, Context);
|
||||
L.match(RHS);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -557,10 +556,10 @@ struct brc_match {
|
||||
}
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V, LLVMContext &Context) {
|
||||
bool match(OpTy *V) {
|
||||
if (BranchInst *BI = dyn_cast<BranchInst>(V))
|
||||
if (BI->isConditional()) {
|
||||
if (Cond.match(BI->getCondition(), Context)) {
|
||||
if (Cond.match(BI->getCondition())) {
|
||||
T = BI->getSuccessor(0);
|
||||
F = BI->getSuccessor(1);
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user