mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
For PR950:
This patch converts the old SHR instruction into two instructions, AShr (Arithmetic) and LShr (Logical). The Shr instructions now are not dependent on the sign of their operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31542 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -172,9 +172,49 @@ inline BinaryOp_match<LHS, RHS, Instruction::Shl,
|
||||
}
|
||||
|
||||
template<typename LHS, typename RHS>
|
||||
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);
|
||||
inline BinaryOp_match<LHS, RHS, Instruction::LShr,
|
||||
ShiftInst> m_LShr(const LHS &L, const RHS &R) {
|
||||
return BinaryOp_match<LHS, RHS, Instruction::LShr, ShiftInst>(L, R);
|
||||
}
|
||||
|
||||
template<typename LHS, typename RHS>
|
||||
inline BinaryOp_match<LHS, RHS, Instruction::AShr,
|
||||
ShiftInst> m_AShr(const LHS &L, const RHS &R) {
|
||||
return BinaryOp_match<LHS, RHS, Instruction::AShr, ShiftInst>(L, R);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Matchers for either AShr or LShr .. for convenience
|
||||
//
|
||||
template<typename LHS_t, typename RHS_t, typename ConcreteTy = ShiftInst>
|
||||
struct Shr_match {
|
||||
LHS_t L;
|
||||
RHS_t R;
|
||||
|
||||
Shr_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {}
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V) {
|
||||
if (V->getValueType() == Value::InstructionVal + Instruction::LShr ||
|
||||
V->getValueType() == Value::InstructionVal + Instruction::AShr) {
|
||||
ConcreteTy *I = cast<ConcreteTy>(V);
|
||||
return (I->getOpcode() == Instruction::AShr ||
|
||||
I->getOpcode() == Instruction::LShr) &&
|
||||
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)) &&
|
||||
R.match(CE->getOperand(1));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename LHS, typename RHS>
|
||||
inline Shr_match<LHS, RHS> m_Shr(const LHS &L, const RHS &R) {
|
||||
return Shr_match<LHS, RHS>(L, R);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
Reference in New Issue
Block a user