mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-27 15:29:51 +00:00
Add isIdentityCopy to check for identity copy (or extract_subreg, etc.)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85044 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f5a86f45e7
commit
f5fe5e4e79
@ -145,20 +145,30 @@ public:
|
||||
/// isIdentityCopy - Return true if the instruction is a copy (or
|
||||
/// extract_subreg, insert_subreg, subreg_to_reg) where the source and
|
||||
/// destination registers are the same.
|
||||
bool isIdentityCopy(const MachineInstr &MI) const {
|
||||
unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
|
||||
bool isIdentityCopy(const MachineInstr &MI,
|
||||
unsigned &SrcReg, unsigned &DstReg,
|
||||
unsigned &SrcSubIdx, unsigned &DstSubIdx) const {
|
||||
if (isMoveInstr(MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
|
||||
SrcReg == DstReg)
|
||||
return true;
|
||||
|
||||
if (MI.getOpcode() == TargetInstrInfo::EXTRACT_SUBREG &&
|
||||
MI.getOperand(0).getReg() == MI.getOperand(1).getReg())
|
||||
return true;
|
||||
if (MI.getOpcode() == TargetInstrInfo::EXTRACT_SUBREG) {
|
||||
DstReg = MI.getOperand(0).getReg();
|
||||
DstSubIdx = MI.getOperand(0).getSubReg();
|
||||
SrcReg = MI.getOperand(1).getReg();
|
||||
SrcSubIdx = MI.getOperand(1).getSubReg();
|
||||
return DstReg == SrcReg;
|
||||
}
|
||||
|
||||
if (MI.getOpcode() == TargetInstrInfo::INSERT_SUBREG ||
|
||||
MI.getOpcode() == TargetInstrInfo::SUBREG_TO_REG) {
|
||||
DstReg = MI.getOperand(0).getReg();
|
||||
DstSubIdx = MI.getOperand(0).getSubReg();
|
||||
SrcReg = MI.getOperand(2).getReg();
|
||||
SrcSubIdx = MI.getOperand(2).getSubReg();
|
||||
return DstReg == SrcReg;
|
||||
}
|
||||
|
||||
if ((MI.getOpcode() == TargetInstrInfo::INSERT_SUBREG ||
|
||||
MI.getOpcode() == TargetInstrInfo::SUBREG_TO_REG) &&
|
||||
MI.getOperand(0).getReg() == MI.getOperand(2).getReg())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user