@@ -791,28 +791,29 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FFREXP(SDNode *N) {
791791 return ReturnVal;
792792}
793793
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" );
796798 EVT VT = N->getValueType (0 );
797- RTLIB::Libcall LC = RTLIB::getFSINCOS (VT);
798799
799800 if (!TLI.getLibcallName (LC))
800801 return SDValue ();
801802
802803 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);
805806
806807 SDLoc DL (N);
807808
808809 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 ()};
813814
814815 // 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.
816817 CallOptions.setTypeListBeforeSoften ({OpsVT}, VT, true );
817818
818819 auto [ReturnVal, Chain] = TLI.makeLibCall (DAG, LC, NVT, Ops, CallOptions, DL,
@@ -824,12 +825,17 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FSINCOS(SDNode *N) {
824825 MachinePointerInfo::getFixedStack (DAG.getMachineFunction (), FrameIdx);
825826 return DAG.getLoad (NVT, DL, Chain, StackSlot, PtrInfo);
826827 };
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 ));
829830
830831 return SDValue ();
831832}
832833
834+ SDValue DAGTypeLegalizer::SoftenFloatRes_FSINCOS (SDNode *N) {
835+ return SoftenFloatRes_UnaryWithTwoFPResults (
836+ N, RTLIB::getFSINCOS (N->getValueType (0 )));
837+ }
838+
833839SDValue DAGTypeLegalizer::SoftenFloatRes_FREM (SDNode *N) {
834840 return SoftenFloatRes_Binary (N, GetFPLibCall (N->getValueType (0 ),
835841 RTLIB::REM_F32,
@@ -2761,7 +2767,7 @@ void DAGTypeLegalizer::PromoteFloatResult(SDNode *N, unsigned ResNo) {
27612767 case ISD::FFREXP: R = PromoteFloatRes_FFREXP (N); break ;
27622768
27632769 case ISD::FSINCOS:
2764- R = PromoteFloatRes_FSINCOS (N);
2770+ R = PromoteFloatRes_UnaryWithTwoFPResults (N);
27652771 break ;
27662772
27672773 case ISD::FP_ROUND: R = PromoteFloatRes_FP_ROUND (N); break ;
@@ -2959,7 +2965,7 @@ SDValue DAGTypeLegalizer::PromoteFloatRes_FFREXP(SDNode *N) {
29592965 return Res;
29602966}
29612967
2962- SDValue DAGTypeLegalizer::PromoteFloatRes_FSINCOS (SDNode *N) {
2968+ SDValue DAGTypeLegalizer::PromoteFloatRes_UnaryWithTwoFPResults (SDNode *N) {
29632969 EVT VT = N->getValueType (0 );
29642970 EVT NVT = TLI.getTypeToTransformTo (*DAG.getContext (), VT);
29652971 SDValue Op = GetPromotedFloat (N->getOperand (0 ));
@@ -3223,7 +3229,7 @@ void DAGTypeLegalizer::SoftPromoteHalfResult(SDNode *N, unsigned ResNo) {
32233229 case ISD::FFREXP: R = SoftPromoteHalfRes_FFREXP (N); break ;
32243230
32253231 case ISD::FSINCOS:
3226- R = SoftPromoteHalfRes_FSINCOS (N);
3232+ R = SoftPromoteHalfRes_UnaryWithTwoFPResults (N);
32273233 break ;
32283234
32293235 case ISD::LOAD: R = SoftPromoteHalfRes_LOAD (N); break ;
@@ -3382,7 +3388,7 @@ SDValue DAGTypeLegalizer::SoftPromoteHalfRes_FFREXP(SDNode *N) {
33823388 return DAG.getNode (GetPromotionOpcode (NVT, OVT), dl, MVT::i16 , Res);
33833389}
33843390
3385- SDValue DAGTypeLegalizer::SoftPromoteHalfRes_FSINCOS (SDNode *N) {
3391+ SDValue DAGTypeLegalizer::SoftPromoteHalfRes_UnaryWithTwoFPResults (SDNode *N) {
33863392 EVT OVT = N->getValueType (0 );
33873393 EVT NVT = TLI.getTypeToTransformTo (*DAG.getContext (), OVT);
33883394 SDValue Op = GetSoftPromotedHalf (N->getOperand (0 ));
0 commit comments