summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorReed Kotler <rkotler@mips.com>2014-10-01 18:47:02 +0000
committerReed Kotler <rkotler@mips.com>2014-10-01 18:47:02 +0000
commitb9dc248e9e964bccd8358de113cbeb3d9427f7ca (patch)
tree67656c1410e2ff6c0f0cda23dba52ea06087b925 /llvm/lib
parent30c9242caad0f82daedb838d73d8311e82b9201b (diff)
downloadbcm5719-llvm-b9dc248e9e964bccd8358de113cbeb3d9427f7ca.tar.gz
bcm5719-llvm-b9dc248e9e964bccd8358de113cbeb3d9427f7ca.zip
Add fptrunc to mips fast-sel
Summary: Implement conversion of 64 to 32 bit floating point numbers (fptrunc) in mips fast-isel Test Plan: fptrunc.ll checked also with 4 internal mips build bot flavors mip32r1/miprs32r2 and at -O0 and -O2 Reviewers: dsanders Reviewed By: dsanders Subscribers: rfuhler Differential Revision: http://reviews.llvm.org/D5553 llvm-svn: 218785
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/Mips/MipsFastISel.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/Target/Mips/MipsFastISel.cpp b/llvm/lib/Target/Mips/MipsFastISel.cpp
index bd3d08527b7..14cf86f0b77 100644
--- a/llvm/lib/Target/Mips/MipsFastISel.cpp
+++ b/llvm/lib/Target/Mips/MipsFastISel.cpp
@@ -81,6 +81,7 @@ private:
bool SelectIntExt(const Instruction *I);
bool SelectTrunc(const Instruction *I);
bool SelectFPExt(const Instruction *I);
+ bool SelectFPTrunc(const Instruction *I);
bool isTypeLegal(Type *Ty, MVT &VT);
bool isLoadTypeLegal(Type *Ty, MVT &VT);
@@ -406,6 +407,28 @@ bool MipsFastISel::SelectFPExt(const Instruction *I) {
return true;
}
+// Attempt to fast-select a floating-point truncate instruction.
+bool MipsFastISel::SelectFPTrunc(const Instruction *I) {
+ Value *Src = I->getOperand(0);
+ EVT SrcVT = TLI.getValueType(Src->getType(), true);
+ EVT DestVT = TLI.getValueType(I->getType(), true);
+
+ if (SrcVT != MVT::f64 || DestVT != MVT::f32)
+ return false;
+
+ unsigned SrcReg = getRegForValue(Src);
+ if (!SrcReg)
+ return false;
+
+ unsigned DestReg = createResultReg(&Mips::FGR32RegClass);
+ if (!DestReg)
+ return false;
+
+ EmitInst(Mips::CVT_S_D32, DestReg).addReg(SrcReg);
+ updateValueMap(I, DestReg);
+ return true;
+}
+
bool MipsFastISel::SelectIntExt(const Instruction *I) {
Type *DestTy = I->getType();
Value *Src = I->getOperand(0);
@@ -475,6 +498,8 @@ bool MipsFastISel::fastSelectInstruction(const Instruction *I) {
case Instruction::ZExt:
case Instruction::SExt:
return SelectIntExt(I);
+ case Instruction::FPTrunc:
+ return SelectFPTrunc(I);
case Instruction::FPExt:
return SelectFPExt(I);
}
OpenPOWER on IntegriCloud