@@ -791,28 +791,29 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FFREXP(SDNode *N) {
791
791
return ReturnVal;
792
792
}
793
793
794
- SDValue DAGTypeLegalizer::SoftenFloatRes_FSINCOS (SDNode *N) {
795
- assert (!N->isStrictFPOpcode () && " strictfp not implemented for fsincos" );
794
+ SDValue
795
+ DAGTypeLegalizer::SoftenFloatRes_UnaryWithTwoFPResults (SDNode *N,
796
+ RTLIB::Libcall LC) {
797
+ assert (!N->isStrictFPOpcode () && " strictfp not implemented" );
796
798
EVT VT = N->getValueType (0 );
797
- RTLIB::Libcall LC = RTLIB::getFSINCOS (VT);
798
799
799
800
if (!TLI.getLibcallName (LC))
800
801
return SDValue ();
801
802
802
803
EVT NVT = TLI.getTypeToTransformTo (*DAG.getContext (), VT);
803
- SDValue StackSlotSin = DAG.CreateStackTemporary (NVT);
804
- SDValue StackSlotCos = DAG.CreateStackTemporary (NVT);
804
+ SDValue FirstResultSlot = DAG.CreateStackTemporary (NVT);
805
+ SDValue SecondResultSlot = DAG.CreateStackTemporary (NVT);
805
806
806
807
SDLoc DL (N);
807
808
808
809
TargetLowering::MakeLibCallOptions CallOptions;
809
- std::array Ops{GetSoftenedFloat (N->getOperand (0 )), StackSlotSin ,
810
- StackSlotCos };
811
- std::array OpsVT{VT, StackSlotSin .getValueType (),
812
- StackSlotCos .getValueType ()};
810
+ std::array Ops{GetSoftenedFloat (N->getOperand (0 )), FirstResultSlot ,
811
+ SecondResultSlot };
812
+ std::array OpsVT{VT, FirstResultSlot .getValueType (),
813
+ SecondResultSlot .getValueType ()};
813
814
814
815
// TODO: setTypeListBeforeSoften can't properly express multiple return types,
815
- // but since both returns have the same type for sincos it should be okay.
816
+ // but since both returns have the same type it should be okay.
816
817
CallOptions.setTypeListBeforeSoften ({OpsVT}, VT, true );
817
818
818
819
auto [ReturnVal, Chain] = TLI.makeLibCall (DAG, LC, NVT, Ops, CallOptions, DL,
@@ -824,12 +825,17 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FSINCOS(SDNode *N) {
824
825
MachinePointerInfo::getFixedStack (DAG.getMachineFunction (), FrameIdx);
825
826
return DAG.getLoad (NVT, DL, Chain, StackSlot, PtrInfo);
826
827
};
827
- SetSoftenedFloat (SDValue (N, 0 ), CreateStackLoad (StackSlotSin ));
828
- SetSoftenedFloat (SDValue (N, 1 ), CreateStackLoad (StackSlotCos ));
828
+ SetSoftenedFloat (SDValue (N, 0 ), CreateStackLoad (FirstResultSlot ));
829
+ SetSoftenedFloat (SDValue (N, 1 ), CreateStackLoad (SecondResultSlot ));
829
830
830
831
return SDValue ();
831
832
}
832
833
834
+ SDValue DAGTypeLegalizer::SoftenFloatRes_FSINCOS (SDNode *N) {
835
+ return SoftenFloatRes_UnaryWithTwoFPResults (
836
+ N, RTLIB::getFSINCOS (N->getValueType (0 )));
837
+ }
838
+
833
839
SDValue DAGTypeLegalizer::SoftenFloatRes_FREM (SDNode *N) {
834
840
return SoftenFloatRes_Binary (N, GetFPLibCall (N->getValueType (0 ),
835
841
RTLIB::REM_F32,
@@ -2761,7 +2767,7 @@ void DAGTypeLegalizer::PromoteFloatResult(SDNode *N, unsigned ResNo) {
2761
2767
case ISD::FFREXP: R = PromoteFloatRes_FFREXP (N); break ;
2762
2768
2763
2769
case ISD::FSINCOS:
2764
- R = PromoteFloatRes_FSINCOS (N);
2770
+ R = PromoteFloatRes_UnaryWithTwoFPResults (N);
2765
2771
break ;
2766
2772
2767
2773
case ISD::FP_ROUND: R = PromoteFloatRes_FP_ROUND (N); break ;
@@ -2959,7 +2965,7 @@ SDValue DAGTypeLegalizer::PromoteFloatRes_FFREXP(SDNode *N) {
2959
2965
return Res;
2960
2966
}
2961
2967
2962
- SDValue DAGTypeLegalizer::PromoteFloatRes_FSINCOS (SDNode *N) {
2968
+ SDValue DAGTypeLegalizer::PromoteFloatRes_UnaryWithTwoFPResults (SDNode *N) {
2963
2969
EVT VT = N->getValueType (0 );
2964
2970
EVT NVT = TLI.getTypeToTransformTo (*DAG.getContext (), VT);
2965
2971
SDValue Op = GetPromotedFloat (N->getOperand (0 ));
@@ -3223,7 +3229,7 @@ void DAGTypeLegalizer::SoftPromoteHalfResult(SDNode *N, unsigned ResNo) {
3223
3229
case ISD::FFREXP: R = SoftPromoteHalfRes_FFREXP (N); break ;
3224
3230
3225
3231
case ISD::FSINCOS:
3226
- R = SoftPromoteHalfRes_FSINCOS (N);
3232
+ R = SoftPromoteHalfRes_UnaryWithTwoFPResults (N);
3227
3233
break ;
3228
3234
3229
3235
case ISD::LOAD: R = SoftPromoteHalfRes_LOAD (N); break ;
@@ -3382,7 +3388,7 @@ SDValue DAGTypeLegalizer::SoftPromoteHalfRes_FFREXP(SDNode *N) {
3382
3388
return DAG.getNode (GetPromotionOpcode (NVT, OVT), dl, MVT::i16, Res);
3383
3389
}
3384
3390
3385
- SDValue DAGTypeLegalizer::SoftPromoteHalfRes_FSINCOS (SDNode *N) {
3391
+ SDValue DAGTypeLegalizer::SoftPromoteHalfRes_UnaryWithTwoFPResults (SDNode *N) {
3386
3392
EVT OVT = N->getValueType (0 );
3387
3393
EVT NVT = TLI.getTypeToTransformTo (*DAG.getContext (), OVT);
3388
3394
SDValue Op = GetSoftPromotedHalf (N->getOperand (0 ));
0 commit comments