llvm.org GIT mirror llvm / e36bfe6
Add the remaining fp_round libcalls: FPROUND_F80_F32, FPROUND_PPCF128_F32, FPROUND_F80_F64, FPROUND_PPCF128_F64 Support for soften float fp_round operands is added, Mips needs this to round f64->f32. Also added support to soften float FABS result, Mips doesn't support double fabs results while in 'single float only' mode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54484 91177308-0d34-0410-b5e6-96231b3b80d8 Bruno Cardoso Lopes 12 years ago
4 changed file(s) with 45 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
100100 // CONVERSION
101101 FPEXT_F32_F64,
102102 FPROUND_F64_F32,
103 FPROUND_F80_F32,
104 FPROUND_PPCF128_F32,
105 FPROUND_F80_F64,
106 FPROUND_PPCF128_F64,
103107 FPTOSINT_F32_I32,
104108 FPTOSINT_F32_I64,
105109 FPTOSINT_F32_I128,
5858 case ISD::ConstantFP:
5959 R = SoftenFloatRes_ConstantFP(cast(N));
6060 break;
61 case ISD::FABS: R = SoftenFloatRes_FABS(N); break;
6162 case ISD::FADD: R = SoftenFloatRes_FADD(N); break;
6263 case ISD::FCOPYSIGN: R = SoftenFloatRes_FCOPYSIGN(N); break;
6364 case ISD::FDIV: R = SoftenFloatRes_FDIV(N); break;
9596 TLI.getTypeToTransformTo(N->getValueType(0)));
9697 }
9798
99 SDValue DAGTypeLegalizer::SoftenFloatRes_FABS(SDNode *N) {
100 MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
101 unsigned Size = NVT.getSizeInBits();
102
103 // Mask = ~(1 << (Size-1))
104 SDValue Mask = DAG.getConstant(APInt::getAllOnesValue(Size).clear(Size-1),
105 NVT);
106 SDValue Op = GetSoftenedFloat(N->getOperand(0));
107 return DAG.getNode(ISD::AND, NVT, Op, Mask);
108 }
109
98110 SDValue DAGTypeLegalizer::SoftenFloatRes_FADD(SDNode *N) {
99111 MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
100112 SDValue Ops[2] = { GetSoftenedFloat(N->getOperand(0)),
289301
290302 case ISD::BIT_CONVERT: Res = SoftenFloatOp_BIT_CONVERT(N); break;
291303 case ISD::BR_CC: Res = SoftenFloatOp_BR_CC(N); break;
304 case ISD::FP_ROUND: Res = SoftenFloatOp_FP_ROUND(N); break;
292305 case ISD::FP_TO_SINT: Res = SoftenFloatOp_FP_TO_SINT(N); break;
293306 case ISD::FP_TO_UINT: Res = SoftenFloatOp_FP_TO_UINT(N); break;
294307 case ISD::SELECT_CC: Res = SoftenFloatOp_SELECT_CC(N); break;
406419 GetSoftenedFloat(N->getOperand(0)));
407420 }
408421
422 SDValue DAGTypeLegalizer::SoftenFloatOp_FP_ROUND(SDNode *N) {
423 MVT SVT = N->getOperand(0).getValueType();
424 MVT RVT = N->getValueType(0);
425
426 RTLIB::Libcall LC = RTLIB::getFPROUND(SVT, RVT);
427 assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported FP_ROUND libcall");
428
429 SDValue Op = GetSoftenedFloat(N->getOperand(0));
430 return MakeLibCall(LC, RVT, &Op, 1, false);
431 }
432
409433 SDValue DAGTypeLegalizer::SoftenFloatOp_BR_CC(SDNode *N) {
410434 SDValue NewLHS = N->getOperand(2), NewRHS = N->getOperand(3);
411435 ISD::CondCode CCCode = cast(N->getOperand(1))->get();
333333 SDValue SoftenFloatRes_BIT_CONVERT(SDNode *N);
334334 SDValue SoftenFloatRes_BUILD_PAIR(SDNode *N);
335335 SDValue SoftenFloatRes_ConstantFP(ConstantFPSDNode *N);
336 SDValue SoftenFloatRes_FABS(SDNode *N);
336337 SDValue SoftenFloatRes_FADD(SDNode *N);
337338 SDValue SoftenFloatRes_FCOPYSIGN(SDNode *N);
338339 SDValue SoftenFloatRes_FDIV(SDNode *N);
351352 bool SoftenFloatOperand(SDNode *N, unsigned OpNo);
352353 SDValue SoftenFloatOp_BIT_CONVERT(SDNode *N);
353354 SDValue SoftenFloatOp_BR_CC(SDNode *N);
355 SDValue SoftenFloatOp_FP_ROUND(SDNode *N);
354356 SDValue SoftenFloatOp_FP_TO_SINT(SDNode *N);
355357 SDValue SoftenFloatOp_FP_TO_UINT(SDNode *N);
356358 SDValue SoftenFloatOp_SELECT_CC(SDNode *N);
9696 Names[RTLIB::POW_PPCF128] = "powl";
9797 Names[RTLIB::FPEXT_F32_F64] = "__extendsfdf2";
9898 Names[RTLIB::FPROUND_F64_F32] = "__truncdfsf2";
99 Names[RTLIB::FPROUND_F80_F32] = "__truncxfsf2";
100 Names[RTLIB::FPROUND_PPCF128_F32] = "__trunctfsf2";
101 Names[RTLIB::FPROUND_F80_F64] = "__truncxfdf2";
102 Names[RTLIB::FPROUND_PPCF128_F64] = "__trunctfdf2";
99103 Names[RTLIB::FPTOSINT_F32_I32] = "__fixsfsi";
100104 Names[RTLIB::FPTOSINT_F32_I64] = "__fixsfdi";
101105 Names[RTLIB::FPTOSINT_F32_I128] = "__fixsfti";
175179 /// getFPROUND - Return the FPROUND_*_* value for the given types, or
176180 /// UNKNOWN_LIBCALL if there is none.
177181 RTLIB::Libcall RTLIB::getFPROUND(MVT OpVT, MVT RetVT) {
178 if (OpVT == MVT::f64) {
179 if (RetVT == MVT::f32)
182 if (RetVT == MVT::f32) {
183 if (OpVT == MVT::f64)
180184 return FPROUND_F64_F32;
185 if (OpVT == MVT::f80)
186 return FPROUND_F80_F32;
187 if (OpVT == MVT::ppcf128)
188 return FPROUND_PPCF128_F32;
189 } else if (RetVT == MVT::f64) {
190 if (OpVT == MVT::f80)
191 return FPROUND_F80_F64;
192 if (OpVT == MVT::ppcf128)
193 return FPROUND_PPCF128_F64;
181194 }
182195 return UNKNOWN_LIBCALL;
183196 }