diff options
author | Petar Jovanovic <petar.jovanovic@mips.com> | 2018-05-23 15:28:28 +0000 |
---|---|---|
committer | Petar Jovanovic <petar.jovanovic@mips.com> | 2018-05-23 15:28:28 +0000 |
commit | c051000b838a6c30e7efa6111dc3867c844ec027 (patch) | |
tree | 0cece070468a54a3caf0cb033af4b7c375832878 /llvm/lib/Target/Mips/MipsSEInstrInfo.cpp | |
parent | ba917bf053dffc91bc14616637e6fd4d2b08e2c7 (diff) | |
download | bcm5719-llvm-c051000b838a6c30e7efa6111dc3867c844ec027.tar.gz bcm5719-llvm-c051000b838a6c30e7efa6111dc3867c844ec027.zip |
[X86][MIPS][ARM] New machine instruction property 'isMoveReg'
This property is needed in order to follow values movement between
registers. This property is used in TII to implement method that
returns true if simple copy like instruction is recognized, along
with source and destination machine operands.
Patch by Nikola Prica.
Differential Revision: https://reviews.llvm.org/D45204
llvm-svn: 333093
Diffstat (limited to 'llvm/lib/Target/Mips/MipsSEInstrInfo.cpp')
-rw-r--r-- | llvm/lib/Target/Mips/MipsSEInstrInfo.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp b/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp index 386a0cd3bd1..c3a43ad9e32 100644 --- a/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp +++ b/llvm/lib/Target/Mips/MipsSEInstrInfo.cpp @@ -179,6 +179,62 @@ void MipsSEInstrInfo::copyPhysReg(MachineBasicBlock &MBB, MIB.addReg(ZeroReg); } +static bool isORCopyInst(const MachineInstr &MI) { + switch (MI.getOpcode()) { + case Mips::OR_MM: + case Mips::OR: + if (MI.getOperand(2).getReg() == Mips::ZERO) + return true; + case Mips::OR64: + if (MI.getOperand(2).getReg() == Mips::ZERO_64) + return true; + default: + return false; + } +} + +/// If @MI is WRDSP/RRDSP instruction return true with @isWrite set to true +/// if it is WRDSP instruction. +static bool isReadOrWritToDSPReg(const MachineInstr &MI, bool &isWrite) { + switch (MI.getOpcode()) { + case Mips::WRDSP: + case Mips::WRDSP_MM: + isWrite = true; + case Mips::RDDSP: + case Mips::RDDSP_MM: + return true; + default: + return false; + } +} + +/// We check for the common case of 'or', as it's MIPS' preferred instruction +/// for GPRs but we have to check the operands to ensure that is the case. +/// Other move instructions for MIPS are directly identifiable. +bool MipsSEInstrInfo::isCopyInstr(const MachineInstr &MI, MachineOperand &Src, + MachineOperand &Dest) const { + bool isDSPControlWrite = false; + // Condition is made to match the creation of WRDSP/RDDSP copy instruction + // from copyPhysReg function. + if (isReadOrWritToDSPReg(MI, isDSPControlWrite)) { + if (!MI.getOperand(1).isImm() || !MI.getOperand(1).getImm() == (1<<4)) + return false; + else if (isDSPControlWrite) { + Src = MI.getOperand(0); + Dest = MI.getOperand(2); + } else { + Dest = MI.getOperand(0); + Src = MI.getOperand(2); + } + return true; + } else if (MI.isMoveReg() || isORCopyInst(MI)) { + Dest = MI.getOperand(0); + Src = MI.getOperand(1); + return true; + } + return false; +} + void MipsSEInstrInfo:: storeRegToStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned SrcReg, bool isKill, int FI, |