diff options
author | Evan Cheng <evan.cheng@apple.com> | 2006-02-18 02:36:28 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2006-02-18 02:36:28 +0000 |
commit | 2b1527157116ba6045667eb29568f2f460d7b670 (patch) | |
tree | c4356a063c8b3fabfcf2fe8797e1616ad18ac22f | |
parent | fbad70808cc17b56703777598d276723608d717d (diff) |
Added fisttp for fp to int conversion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26283 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/X86FloatingPoint.cpp | 17 | ||||
-rw-r--r-- | lib/Target/X86/X86InstrInfo.td | 15 |
2 files changed, 29 insertions, 3 deletions
diff --git a/lib/Target/X86/X86FloatingPoint.cpp b/lib/Target/X86/X86FloatingPoint.cpp index af5bb7db33..81597a24dc 100644 --- a/lib/Target/X86/X86FloatingPoint.cpp +++ b/lib/Target/X86/X86FloatingPoint.cpp @@ -357,6 +357,9 @@ static const TableEntry OpcodeTable[] = { { X86::FpIST16m , X86::FIST16m }, { X86::FpIST32m , X86::FIST32m }, { X86::FpIST64m , X86::FISTP64m }, + { X86::FpISTT16m , X86::FISTTP16m}, + { X86::FpISTT32m , X86::FISTTP32m}, + { X86::FpISTT64m , X86::FISTTP64m}, { X86::FpISUB16m , X86::FISUB16m }, { X86::FpISUB32m , X86::FISUB32m }, { X86::FpISUBR16m, X86::FISUBR16m}, @@ -502,12 +505,17 @@ void FPS::handleOneArgFP(MachineBasicBlock::iterator &I) { unsigned Reg = getFPReg(MI->getOperand(MI->getNumOperands()-1)); bool KillsSrc = LV->KillsRegister(MI, X86::FP0+Reg); - // FISTP64r is strange because there isn't a non-popping versions. + // FISTP64m is strange because there isn't a non-popping versions. // If we have one _and_ we don't want to pop the operand, duplicate the value // on the stack instead of moving it. This ensure that popping the value is // always ok. + // Ditto FISTTP16m, FISTTP32m, FISTTP64m. // - if (MI->getOpcode() == X86::FpIST64m && !KillsSrc) { + if (!KillsSrc && + (MI->getOpcode() == X86::FpIST64m || + MI->getOpcode() == X86::FpISTT16m || + MI->getOpcode() == X86::FpISTT32m || + MI->getOpcode() == X86::FpISTT64m)) { duplicateToTop(Reg, 7 /*temp register*/, I); } else { moveToTop(Reg, I); // Move to the top of the stack... @@ -517,7 +525,10 @@ void FPS::handleOneArgFP(MachineBasicBlock::iterator &I) { MI->RemoveOperand(MI->getNumOperands()-1); // Remove explicit ST(0) operand MI->setOpcode(getConcreteOpcode(MI->getOpcode())); - if (MI->getOpcode() == X86::FISTP64m) { + if (MI->getOpcode() == X86::FISTP64m || + MI->getOpcode() == X86::FISTTP16m || + MI->getOpcode() == X86::FISTTP32m || + MI->getOpcode() == X86::FISTTP64m) { assert(StackTop > 0 && "Stack empty??"); --StackTop; } else if (KillsSrc) { // Last use of operand? diff --git a/lib/Target/X86/X86InstrInfo.td b/lib/Target/X86/X86InstrInfo.td index 32d88492a9..f077280a3c 100644 --- a/lib/Target/X86/X86InstrInfo.td +++ b/lib/Target/X86/X86InstrInfo.td @@ -2957,6 +2957,21 @@ def FISTP16m : FPI<0xDF, MRM3m, (ops i16mem:$dst), "fistp{s} $dst">; def FISTP32m : FPI<0xDB, MRM3m, (ops i32mem:$dst), "fistp{l} $dst">; def FISTP64m : FPI<0xDF, MRM7m, (ops i64mem:$dst), "fistp{ll} $dst">; +// FISTTP requires SSE3 even though it's a FPStack op. +def FpISTT16m : FpI_<(ops i16mem:$op, RFP:$src), OneArgFP, + [(X86fp_to_i16mem RFP:$src, addr:$op)]>, + Requires<[HasSSE3]>; +def FpISTT32m : FpI_<(ops i32mem:$op, RFP:$src), OneArgFP, + [(X86fp_to_i32mem RFP:$src, addr:$op)]>, + Requires<[HasSSE3]>; +def FpISTT64m : FpI_<(ops i64mem:$op, RFP:$src), OneArgFP, + [(X86fp_to_i64mem RFP:$src, addr:$op)]>, + Requires<[HasSSE3]>; + +def FISTTP16m : FPI<0xDF, MRM1m, (ops i16mem:$dst), "fisttp{s} $dst">; +def FISTTP32m : FPI<0xDB, MRM1m, (ops i32mem:$dst), "fisttp{l} $dst">; +def FISTTP64m : FPI<0xDD, MRM1m, (ops i64mem:$dst), "fisttp{ll} $dst">; + // FP Stack manipulation instructions. def FLDrr : FPI<0xC0, AddRegFrm, (ops RST:$op), "fld $op">, D9; def FSTrr : FPI<0xD0, AddRegFrm, (ops RST:$op), "fst $op">, DD; |