summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVenkatraman Govindaraju <venkatra@cs.wisc.edu>2013-11-03 08:00:19 +0000
committerVenkatraman Govindaraju <venkatra@cs.wisc.edu>2013-11-03 08:00:19 +0000
commit5e45051e0ee8917a88e84d799c5c90840d0c465b (patch)
treed9874a2adb34eb9d396c0b4add084c344cc46479 /lib
parent30288ac4020138a09ae2a0e4c989b1003340150b (diff)
downloadllvm-5e45051e0ee8917a88e84d799c5c90840d0c465b.tar.gz
llvm-5e45051e0ee8917a88e84d799c5c90840d0c465b.tar.bz2
llvm-5e45051e0ee8917a88e84d799c5c90840d0c465b.tar.xz
[Sparc] Expand FP_TO_UINT, UINT_TO_FP for fp128.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193947 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/Sparc/SparcISelLowering.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/lib/Target/Sparc/SparcISelLowering.cpp b/lib/Target/Sparc/SparcISelLowering.cpp
index e09802b9ff..bdee864274 100644
--- a/lib/Target/Sparc/SparcISelLowering.cpp
+++ b/lib/Target/Sparc/SparcISelLowering.cpp
@@ -1354,9 +1354,9 @@ SparcTargetLowering::SparcTargetLowering(TargetMachine &TM)
setOperationAction(ISD::FP_TO_SINT, MVT::i32, Custom);
setOperationAction(ISD::SINT_TO_FP, MVT::i32, Custom);
- // Expand fp<->uint
- setOperationAction(ISD::FP_TO_UINT, MVT::i32, Expand);
- setOperationAction(ISD::UINT_TO_FP, MVT::i32, Expand);
+ // Custom Expand fp<->uint
+ setOperationAction(ISD::FP_TO_UINT, MVT::i32, Custom);
+ setOperationAction(ISD::UINT_TO_FP, MVT::i32, Custom);
setOperationAction(ISD::BITCAST, MVT::f32, Expand);
setOperationAction(ISD::BITCAST, MVT::i32, Expand);
@@ -1520,7 +1520,9 @@ SparcTargetLowering::SparcTargetLowering(TargetMachine &TM)
setLibcallName(RTLIB::DIV_F128, "_Qp_div");
setLibcallName(RTLIB::SQRT_F128, "_Qp_sqrt");
setLibcallName(RTLIB::FPTOSINT_F128_I32, "_Qp_qtoi");
+ setLibcallName(RTLIB::FPTOUINT_F128_I32, "_Qp_qtoui");
setLibcallName(RTLIB::SINTTOFP_I32_F128, "_Qp_itoq");
+ setLibcallName(RTLIB::UINTTOFP_I32_F128, "_Qp_uitoq");
setLibcallName(RTLIB::FPEXT_F32_F128, "_Qp_stoq");
setLibcallName(RTLIB::FPEXT_F64_F128, "_Qp_dtoq");
setLibcallName(RTLIB::FPROUND_F128_F32, "_Qp_qtos");
@@ -1532,7 +1534,9 @@ SparcTargetLowering::SparcTargetLowering(TargetMachine &TM)
setLibcallName(RTLIB::DIV_F128, "_Q_div");
setLibcallName(RTLIB::SQRT_F128, "_Q_sqrt");
setLibcallName(RTLIB::FPTOSINT_F128_I32, "_Q_qtoi");
+ setLibcallName(RTLIB::FPTOUINT_F128_I32, "_Q_qtou");
setLibcallName(RTLIB::SINTTOFP_I32_F128, "_Q_itoq");
+ setLibcallName(RTLIB::UINTTOFP_I32_F128, "_Q_utoq");
setLibcallName(RTLIB::FPEXT_F32_F128, "_Q_stoq");
setLibcallName(RTLIB::FPEXT_F64_F128, "_Q_dtoq");
setLibcallName(RTLIB::FPROUND_F128_F32, "_Q_qtos");
@@ -2075,6 +2079,37 @@ static SDValue LowerSINT_TO_FP(SDValue Op, SelectionDAG &DAG,
return DAG.getNode(SPISD::ITOF, dl, Op.getValueType(), Tmp);
}
+static SDValue LowerFP_TO_UINT(SDValue Op, SelectionDAG &DAG,
+ const SparcTargetLowering &TLI,
+ bool hasHardQuad) {
+ // Expand if it does not involve f128 or the target has support for
+ // quad floating point instructions.
+ if (Op.getOperand(0).getValueType() != MVT::f128 || hasHardQuad)
+ return SDValue(0, 0);
+
+ SDLoc dl(Op);
+ assert(Op.getValueType() == MVT::i32);
+
+ return TLI.LowerF128Op(Op, DAG,
+ TLI.getLibcallName(RTLIB::FPTOUINT_F128_I32), 1);
+}
+
+
+static SDValue LowerUINT_TO_FP(SDValue Op, SelectionDAG &DAG,
+ const SparcTargetLowering &TLI,
+ bool hasHardQuad) {
+ // Expand if it does not involve f128 or the target has support for
+ // quad floating point instructions.
+ if (Op.getValueType() != MVT::f128 || hasHardQuad)
+ return SDValue(0, 0);
+
+ SDLoc dl(Op);
+ assert(Op.getOperand(0).getValueType() == MVT::i32);
+
+ return TLI.LowerF128Op(Op, DAG,
+ TLI.getLibcallName(RTLIB::UINTTOFP_I32_F128), 1);
+}
+
static SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG,
const SparcTargetLowering &TLI,
bool hasHardQuad) {
@@ -2518,6 +2553,10 @@ LowerOperation(SDValue Op, SelectionDAG &DAG) const {
hasHardQuad);
case ISD::SINT_TO_FP: return LowerSINT_TO_FP(Op, DAG, *this,
hasHardQuad);
+ case ISD::FP_TO_UINT: return LowerFP_TO_UINT(Op, DAG, *this,
+ hasHardQuad);
+ case ISD::UINT_TO_FP: return LowerUINT_TO_FP(Op, DAG, *this,
+ hasHardQuad);
case ISD::BR_CC: return LowerBR_CC(Op, DAG, *this,
hasHardQuad);
case ISD::SELECT_CC: return LowerSELECT_CC(Op, DAG, *this,