mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
[mips] Fix instruction selection pattern for sint_to_fp node to avoid emitting an
invalid instruction sequence. Rather than emitting an int-to-FP move instruction and an int-to-FP conversion instruction during instruction selection, we emit a pseudo instruction which gets expanded post-RA. Without this change, register allocation can possibly insert a floating point register move instruction between the two instructions, which is not valid according to the ISA manual. mtc1 $f4, $4 # int-to-fp move instruction. mov.s $f2, $f4 # move contents of $f4 to $f2. cvt.s.w $f0, $f2 # int-to-fp conversion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182042 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -253,6 +253,21 @@ bool MipsSEInstrInfo::expandPostRAPseudo(MachineBasicBlock::iterator MI) const {
|
||||
case Mips::RetRA:
|
||||
expandRetRA(MBB, MI, Mips::RET);
|
||||
break;
|
||||
case Mips::PseudoCVT_S_W:
|
||||
expandCvtFPInt(MBB, MI, Mips::CVT_S_W, Mips::MTC1, false, false, false);
|
||||
break;
|
||||
case Mips::PseudoCVT_D32_W:
|
||||
expandCvtFPInt(MBB, MI, Mips::CVT_D32_W, Mips::MTC1, true, false, false);
|
||||
break;
|
||||
case Mips::PseudoCVT_S_L:
|
||||
expandCvtFPInt(MBB, MI, Mips::CVT_S_L, Mips::DMTC1, false, true, true);
|
||||
break;
|
||||
case Mips::PseudoCVT_D64_W:
|
||||
expandCvtFPInt(MBB, MI, Mips::CVT_D64_W, Mips::MTC1, true, false, true);
|
||||
break;
|
||||
case Mips::PseudoCVT_D64_L:
|
||||
expandCvtFPInt(MBB, MI, Mips::CVT_D64_L, Mips::DMTC1, false, false, true);
|
||||
break;
|
||||
case Mips::BuildPairF64:
|
||||
expandBuildPairF64(MBB, MI);
|
||||
break;
|
||||
@@ -374,6 +389,28 @@ void MipsSEInstrInfo::expandRetRA(MachineBasicBlock &MBB,
|
||||
BuildMI(MBB, I, I->getDebugLoc(), get(Opc)).addReg(Mips::RA);
|
||||
}
|
||||
|
||||
void MipsSEInstrInfo::expandCvtFPInt(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator I,
|
||||
unsigned CvtOpc, unsigned MovOpc,
|
||||
bool DstIsLarger, bool SrcIsLarger,
|
||||
bool IsI64) const {
|
||||
const MCInstrDesc &CvtDesc = get(CvtOpc), &MovDesc = get(MovOpc);
|
||||
const MachineOperand &Dst = I->getOperand(0), &Src = I->getOperand(1);
|
||||
unsigned DstReg = Dst.getReg(), SrcReg = Src.getReg(), TmpReg = DstReg;
|
||||
unsigned KillSrc = getKillRegState(Src.isKill());
|
||||
DebugLoc DL = I->getDebugLoc();
|
||||
unsigned SubIdx = (IsI64 ? Mips::sub_32 : Mips::sub_fpeven);
|
||||
|
||||
if (DstIsLarger)
|
||||
TmpReg = getRegisterInfo().getSubReg(DstReg, SubIdx);
|
||||
|
||||
if (SrcIsLarger)
|
||||
DstReg = getRegisterInfo().getSubReg(DstReg, SubIdx);
|
||||
|
||||
BuildMI(MBB, I, DL, MovDesc, TmpReg).addReg(SrcReg, KillSrc);
|
||||
BuildMI(MBB, I, DL, CvtDesc, DstReg).addReg(TmpReg, RegState::Kill);
|
||||
}
|
||||
|
||||
void MipsSEInstrInfo::expandExtractElementF64(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator I) const {
|
||||
unsigned DstReg = I->getOperand(0).getReg();
|
||||
|
Reference in New Issue
Block a user