Teach the x86 floating point stackifier to handle COPY instructions.

This pass runs before COPY instructions are passed to copyPhysReg, so we simply
translate COPY to the proper pseudo instruction. Note that copyPhysReg does not
handle floating point stack copies.

Once COPY is used everywhere, this can be cleaned up a bit, and most of the
pseudo instructions can be removed.

llvm-svn: 107899
This commit is contained in:
Jakob Stoklund Olesen 2010-07-08 19:46:30 +00:00
parent 930f8082c3
commit 63a622b768
1 changed files with 36 additions and 1 deletions

View File

@ -164,6 +164,8 @@ namespace {
void handleCompareFP(MachineBasicBlock::iterator &I);
void handleCondMovFP(MachineBasicBlock::iterator &I);
void handleSpecialFP(MachineBasicBlock::iterator &I);
bool translateCopy(MachineInstr*);
};
char FPS::ID = 0;
}
@ -237,7 +239,10 @@ bool FPS::processBasicBlock(MachineFunction &MF, MachineBasicBlock &BB) {
unsigned FPInstClass = Flags & X86II::FPTypeMask;
if (MI->isInlineAsm())
FPInstClass = X86II::SpecialFP;
if (MI->isCopy() && translateCopy(MI))
FPInstClass = X86II::SpecialFP;
if (FPInstClass == X86II::NotFP)
continue; // Efficiently ignore non-fp insts!
@ -1206,3 +1211,33 @@ void FPS::handleSpecialFP(MachineBasicBlock::iterator &I) {
I = MBB->erase(I); // Remove the pseudo instruction
--I;
}
// Translate a COPY instruction to a pseudo-op that handleSpecialFP understands.
bool FPS::translateCopy(MachineInstr *MI) {
unsigned DstReg = MI->getOperand(0).getReg();
unsigned SrcReg = MI->getOperand(1).getReg();
if (DstReg == X86::ST0) {
MI->setDesc(TII->get(X86::FpSET_ST0_80));
MI->RemoveOperand(0);
return true;
}
if (DstReg == X86::ST1) {
MI->setDesc(TII->get(X86::FpSET_ST1_80));
MI->RemoveOperand(0);
return true;
}
if (SrcReg == X86::ST0) {
MI->setDesc(TII->get(X86::FpGET_ST0_80));
return true;
}
if (SrcReg == X86::ST1) {
MI->setDesc(TII->get(X86::FpGET_ST1_80));
return true;
}
if (X86::RFP80RegClass.contains(DstReg, SrcReg)) {
MI->setDesc(TII->get(X86::MOV_Fp8080));
return true;
}
return false;
}