27#define DEBUG_TYPE "legalize-types"
33 RTLIB::Libcall Call_F32,
34 RTLIB::Libcall Call_F64,
35 RTLIB::Libcall Call_F80,
36 RTLIB::Libcall Call_F128,
37 RTLIB::Libcall Call_PPCF128) {
39 VT == MVT::f32 ? Call_F32 :
40 VT == MVT::f64 ? Call_F64 :
41 VT == MVT::f80 ? Call_F80 :
42 VT == MVT::f128 ? Call_F128 :
43 VT == MVT::ppcf128 ? Call_PPCF128 :
44 RTLIB::UNKNOWN_LIBCALL;
51void DAGTypeLegalizer::SoftenFloatResult(
SDNode *
N,
unsigned ResNo) {
52 LLVM_DEBUG(
dbgs() <<
"Soften float result " << ResNo <<
": ";
N->dump(&DAG));
55 switch (
N->getOpcode()) {
59 dbgs() <<
"SoftenFloatResult #" << ResNo <<
": ";
60 N->dump(&DAG);
dbgs() <<
"\n";
71 R = SoftenFloatRes_EXTRACT_VECTOR_ELT(
N, ResNo);
break;
74 R = SoftenFloatRes_FCANONICALIZE(
N);
break;
117 case ISD::FMA:
R = SoftenFloatRes_FMA(
N);
break;
188 SetSoftenedFloat(
SDValue(
N, ResNo), R);
192SDValue DAGTypeLegalizer::SoftenFloatRes_Unary(
SDNode *
N, RTLIB::Libcall LC) {
194 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
195 unsigned Offset = IsStrict ? 1 : 0;
197 "Unexpected number of operands!");
200 TargetLowering::MakeLibCallOptions CallOptions;
201 EVT OpVT =
N->getOperand(0 +
Offset).getValueType();
203 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, NVT,
Op,
204 CallOptions, SDLoc(
N),
207 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
211SDValue DAGTypeLegalizer::SoftenFloatRes_Binary(
SDNode *
N, RTLIB::Libcall LC) {
212 bool IsStrict =
N->isStrictFPOpcode();
213 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
214 unsigned Offset = IsStrict ? 1 : 0;
216 "Unexpected number of operands!");
218 GetSoftenedFloat(
N->getOperand(1 +
Offset)) };
220 TargetLowering::MakeLibCallOptions CallOptions;
221 EVT OpsVT[2] = {
N->getOperand(0 +
Offset).getValueType(),
222 N->getOperand(1 +
Offset).getValueType() };
224 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, NVT,
Ops,
225 CallOptions, SDLoc(
N),
228 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
233 return BitConvertToInteger(
N->getOperand(0));
237 EVT Ty = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
239 GetSoftenedFloat(
N->getOperand(0)));
243 EVT Ty = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
245 GetSoftenedFloat(
N->getOperand(0)));
251 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
252 return BitConvertToInteger(
Op);
258 TLI.getTypeToTransformTo(*DAG.getContext(),
260 BitConvertToInteger(
N->getOperand(0)),
261 BitConvertToInteger(
N->getOperand(1)));
273 if (DAG.getDataLayout().isBigEndian() &&
277 APInt Val(128, words);
278 return DAG.getConstant(Val, SDLoc(CN),
279 TLI.getTypeToTransformTo(*DAG.getContext(),
283 TLI.getTypeToTransformTo(*DAG.getContext(),
288SDValue DAGTypeLegalizer::SoftenFloatRes_EXTRACT_ELEMENT(
SDNode *
N) {
290 assert(Src.getValueType() == MVT::ppcf128 &&
291 "In floats only ppcf128 can be extracted by element!");
293 N->getValueType(0).changeTypeToInteger(),
294 DAG.getBitcast(MVT::i128, Src),
N->getOperand(1));
297SDValue DAGTypeLegalizer::SoftenFloatRes_EXTRACT_VECTOR_ELT(
SDNode *
N,
unsigned ResNo) {
298 SDValue NewOp = BitConvertVectorToIntegerVector(
N->getOperand(0));
301 NewOp,
N->getOperand(1));
305 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
312 SDValue Op = GetSoftenedFloat(
N->getOperand(0));
313 return DAG.getNode(
ISD::AND, SDLoc(
N), NVT,
Op, Mask);
316SDValue DAGTypeLegalizer::SoftenFloatRes_FCANONICALIZE(
SDNode *
N) {
330 SDValue One = DAG.getConstantFP(1.0, dl, VT);
331 SDValue Chain = DAG.getEntryNode();
334 SDNodeFlags CanonicalizeFlags =
N->
getFlags();
337 {Chain, Operand, One}, CanonicalizeFlags);
338 return BitConvertToInteger(
Mul);
342 if (
SDValue SelCC = TLI.createSelectForFMINNUM_FMAXNUM(
N, DAG))
343 return SoftenFloatRes_SELECT_CC(SelCC.getNode());
349 RTLIB::FMIN_PPCF128));
353 if (
SDValue SelCC = TLI.createSelectForFMINNUM_FMAXNUM(
N, DAG))
354 return SoftenFloatRes_SELECT_CC(SelCC.getNode());
360 RTLIB::FMAX_PPCF128));
364 return SoftenFloatRes_Binary(
366 RTLIB::FMINIMUM_NUM_F64, RTLIB::FMINIMUM_NUM_F80,
367 RTLIB::FMINIMUM_NUM_F128, RTLIB::FMINIMUM_NUM_PPCF128));
371 return SoftenFloatRes_Binary(
373 RTLIB::FMAXIMUM_NUM_F64, RTLIB::FMAXIMUM_NUM_F80,
374 RTLIB::FMAXIMUM_NUM_F128, RTLIB::FMAXIMUM_NUM_PPCF128));
378 return SoftenFloatRes_Binary(
380 RTLIB::FMINIMUM_F64, RTLIB::FMINIMUM_F80,
381 RTLIB::FMINIMUM_F128, RTLIB::FMINIMUM_PPCF128));
385 return SoftenFloatRes_Binary(
387 RTLIB::FMAXIMUM_F64, RTLIB::FMAXIMUM_F80,
388 RTLIB::FMAXIMUM_F128, RTLIB::FMAXIMUM_PPCF128));
397 RTLIB::ADD_PPCF128));
401 return SoftenFloatRes_Unary(
402 N,
GetFPLibCall(
N->getValueType(0), RTLIB::ACOS_F32, RTLIB::ACOS_F64,
403 RTLIB::ACOS_F80, RTLIB::ACOS_F128, RTLIB::ACOS_PPCF128));
407 return SoftenFloatRes_Unary(
408 N,
GetFPLibCall(
N->getValueType(0), RTLIB::ASIN_F32, RTLIB::ASIN_F64,
409 RTLIB::ASIN_F80, RTLIB::ASIN_F128, RTLIB::ASIN_PPCF128));
413 return SoftenFloatRes_Unary(
414 N,
GetFPLibCall(
N->getValueType(0), RTLIB::ATAN_F32, RTLIB::ATAN_F64,
415 RTLIB::ATAN_F80, RTLIB::ATAN_F128, RTLIB::ATAN_PPCF128));
419 return SoftenFloatRes_Binary(
421 GetFPLibCall(
N->getValueType(0), RTLIB::ATAN2_F32, RTLIB::ATAN2_F64,
422 RTLIB::ATAN2_F80, RTLIB::ATAN2_F128, RTLIB::ATAN2_PPCF128));
431 RTLIB::CBRT_PPCF128));
440 RTLIB::CEIL_PPCF128));
445 SDValue RHS = BitConvertToInteger(
N->getOperand(1));
448 EVT LVT =
LHS.getValueType();
449 EVT RVT =
RHS.getValueType();
456 ISD::SHL, dl, RVT, DAG.getConstant(1, dl, RVT),
457 DAG.getConstant(RSize - 1, dl,
458 TLI.getShiftAmountTy(RVT, DAG.getDataLayout())));
466 DAG.getConstant(SizeDiff, dl,
468 DAG.getDataLayout())));
470 }
else if (SizeDiff < 0) {
474 DAG.getConstant(-SizeDiff, dl,
476 DAG.getDataLayout())));
481 ISD::SHL, dl, LVT, DAG.getConstant(1, dl, LVT),
482 DAG.getConstant(LSize - 1, dl,
483 TLI.getShiftAmountTy(LVT, DAG.getDataLayout())));
484 Mask = DAG.getNode(
ISD::SUB, dl, LVT, Mask, DAG.getConstant(1, dl, LVT));
488 return DAG.getNode(
ISD::OR, dl, LVT,
LHS, SignBit);
497 RTLIB::COS_PPCF128));
501 return SoftenFloatRes_Unary(
502 N,
GetFPLibCall(
N->getValueType(0), RTLIB::COSH_F32, RTLIB::COSH_F64,
503 RTLIB::COSH_F80, RTLIB::COSH_F128, RTLIB::COSH_PPCF128));
512 RTLIB::DIV_PPCF128));
521 RTLIB::EXP_PPCF128));
530 RTLIB::EXP2_PPCF128));
534 return SoftenFloatRes_Unary(
536 GetFPLibCall(
N->getValueType(0), RTLIB::EXP10_F32, RTLIB::EXP10_F64,
537 RTLIB::EXP10_F80, RTLIB::EXP10_F128, RTLIB::EXP10_PPCF128));
546 RTLIB::FLOOR_PPCF128));
555 RTLIB::LOG_PPCF128));
564 RTLIB::LOG2_PPCF128));
573 RTLIB::LOG10_PPCF128));
577 bool IsStrict =
N->isStrictFPOpcode();
578 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
579 unsigned Offset = IsStrict ? 1 : 0;
581 GetSoftenedFloat(
N->getOperand(1 +
Offset)),
582 GetSoftenedFloat(
N->getOperand(2 +
Offset)) };
584 TargetLowering::MakeLibCallOptions CallOptions;
585 EVT OpsVT[3] = {
N->getOperand(0 +
Offset).getValueType(),
586 N->getOperand(1 +
Offset).getValueType(),
587 N->getOperand(2 +
Offset).getValueType() };
589 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG,
596 NVT,
Ops, CallOptions, SDLoc(
N), Chain);
598 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
608 RTLIB::MUL_PPCF128));
613 RTLIB::NEARBYINT_F32,
614 RTLIB::NEARBYINT_F64,
615 RTLIB::NEARBYINT_F80,
616 RTLIB::NEARBYINT_F128,
617 RTLIB::NEARBYINT_PPCF128));
621 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
626 return DAG.getNode(
ISD::XOR, dl, NVT, GetSoftenedFloat(
N->getOperand(0)),
627 DAG.getConstant(SignMask, dl, NVT));
631 bool IsStrict =
N->isStrictFPOpcode();
632 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
638 Op = GetPromotedFloat(
Op);
641 if (
Op.getValueType() ==
N->getValueType(0)) {
643 ReplaceValueWith(
SDValue(
N, 1), Chain);
644 return BitConvertToInteger(
Op);
652 if ((
Op.getValueType() == MVT::f16 ||
Op.getValueType() == MVT::bf16) &&
653 N->getValueType(0) != MVT::f32) {
656 { MVT::f32, MVT::Other }, { Chain,
Op });
657 Chain =
Op.getValue(1);
663 if (
Op.getValueType() == MVT::bf16) {
665 return SoftenFloatRes_BF16_TO_FP(
N);
669 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported FP_EXTEND!");
670 TargetLowering::MakeLibCallOptions CallOptions;
671 EVT OpVT =
N->getOperand(IsStrict ? 1 : 0).getValueType();
673 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, NVT,
Op,
674 CallOptions, SDLoc(
N),
677 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
684 EVT MidVT = TLI.getTypeToTransformTo(*DAG.getContext(), MVT::f32);
686 TargetLowering::MakeLibCallOptions CallOptions;
687 EVT OpsVT[1] = {
N->getOperand(0).getValueType() };
689 SDValue Res32 = TLI.makeLibCall(DAG, RTLIB::FPEXT_F16_F32, MidVT,
Op,
690 CallOptions, SDLoc(
N)).first;
691 if (
N->getValueType(0) == MVT::f32)
694 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
696 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported FP_EXTEND!");
697 return TLI.makeLibCall(DAG, LC, NVT, Res32, CallOptions, SDLoc(
N)).first;
703 assert(
N->getValueType(0) == MVT::f32 &&
704 "Can only soften BF16_TO_FP with f32 result");
705 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), MVT::f32);
711 DAG.getShiftAmountConstant(16, NVT,
DL));
716 bool IsStrict =
N->isStrictFPOpcode();
717 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
721 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported FP_ROUND!");
722 TargetLowering::MakeLibCallOptions CallOptions;
723 EVT OpVT =
N->getOperand(IsStrict ? 1 : 0).getValueType();
725 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, NVT,
Op,
726 CallOptions, SDLoc(
N),
729 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
738 bool IsStrict =
N->isStrictFPOpcode();
739 unsigned Offset = IsStrict ? 1 : 0;
742 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
746 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fpowi.");
747 if (TLI.getLibcallImpl(LC) == RTLIB::Unsupported) {
750 DAG.getContext()->emitError(
"do not know how to soften fpowi to fpow");
752 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
753 return DAG.getPOISON(NVT);
756 if (DAG.getLibInfo().getIntSize() !=
757 N->getOperand(1 +
Offset).getValueType().getSizeInBits()) {
760 DAG.getContext()->emitError(
"powi exponent does not match sizeof(int)");
762 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
763 return DAG.getPOISON(NVT);
769 TargetLowering::MakeLibCallOptions CallOptions;
770 EVT OpsVT[2] = {
N->getOperand(0 +
Offset).getValueType(),
771 N->getOperand(1 +
Offset).getValueType() };
773 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, NVT,
Ops,
774 CallOptions, SDLoc(
N),
777 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
782 assert(!
N->isStrictFPOpcode() &&
"strictfp not implemented for frexp");
783 EVT VT0 =
N->getValueType(0);
784 EVT VT1 =
N->getValueType(1);
786 EVT NVT0 = TLI.getTypeToTransformTo(*DAG.getContext(), VT0);
793 DAG.getContext()->emitError(
"ffrexp exponent does not match sizeof(int)");
794 SDValue PoisonExp = DAG.getPOISON(VT1);
795 ReplaceValueWith(
SDValue(
N, 1), PoisonExp);
796 return DAG.getMergeValues({DAG.getPOISON(NVT0), PoisonExp},
DL);
799 SDValue StackSlot = DAG.CreateStackTemporary(VT1);
802 TargetLowering::MakeLibCallOptions CallOptions;
803 SDValue Ops[2] = {GetSoftenedFloat(
N->getOperand(0)), StackSlot};
810 .setOpsTypeOverrides(CallOpsTypeOverrides);
812 auto [ReturnVal, Chain] = TLI.makeLibCall(DAG, LC, NVT0,
Ops, CallOptions,
DL,
818 SDValue LoadExp = DAG.getLoad(VT1,
DL, Chain, StackSlot, PtrInfo);
820 ReplaceValueWith(
SDValue(
N, 1), LoadExp);
824bool DAGTypeLegalizer::SoftenFloatRes_UnaryWithTwoFPResults(
825 SDNode *
N, RTLIB::Libcall LC, std::optional<unsigned> CallRetResNo) {
826 assert(!
N->isStrictFPOpcode() &&
"strictfp not implemented");
827 EVT VT =
N->getValueType(0);
829 assert(VT ==
N->getValueType(1) &&
830 "expected both return values to have the same type");
832 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
833 if (LCImpl == RTLIB::Unsupported)
836 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
843 std::array<SDValue, 2> StackSlots;
846 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ++ResNum) {
847 if (ResNum == CallRetResNo)
849 SDValue StackSlot = DAG.CreateStackTemporary(NVT);
850 Ops.push_back(StackSlot);
852 StackSlots[ResNum] = StackSlot;
856 TargetLowering::MakeLibCallOptions CallOptions;
860 .setOpsTypeOverrides(CallOpsTypeOverrides);
862 auto [ReturnVal, Chain] =
863 TLI.makeLibCall(DAG, LCImpl, NVT,
Ops, CallOptions,
DL,
866 auto CreateStackLoad = [&, Chain = Chain](
SDValue StackSlot) {
870 return DAG.getLoad(NVT,
DL, Chain, StackSlot, PtrInfo);
873 for (
auto [ResNum, SlackSlot] :
enumerate(StackSlots)) {
874 if (CallRetResNo == ResNum) {
875 SetSoftenedFloat(
SDValue(
N, ResNum), ReturnVal);
878 SetSoftenedFloat(
SDValue(
N, ResNum), CreateStackLoad(SlackSlot));
885 EVT VT =
N->getValueType(0);
894 if (TLI.getLibcallImpl(SinLC) == RTLIB::Unsupported ||
895 TLI.getLibcallImpl(CosLC) == RTLIB::Unsupported) {
896 DAG.getContext()->emitError(
"do not know how to soften fsincos");
898 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
899 SoftSin = SoftCos = DAG.getPOISON(NVT);
901 SoftSin = SoftenFloatRes_Unary(
N, SinLC);
902 SoftCos = SoftenFloatRes_Unary(
N, CosLC);
905 SetSoftenedFloat(
SDValue(
N, 0), SoftSin);
906 SetSoftenedFloat(
SDValue(
N, 1), SoftCos);
911 EVT VT =
N->getValueType(0);
916 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
917 DAG.getContext()->emitError(
"do not know how to soften fmodf");
930 RTLIB::REM_PPCF128));
939 RTLIB::RINT_PPCF128));
948 RTLIB::ROUND_PPCF128));
953 RTLIB::ROUNDEVEN_F32,
954 RTLIB::ROUNDEVEN_F64,
955 RTLIB::ROUNDEVEN_F80,
956 RTLIB::ROUNDEVEN_F128,
957 RTLIB::ROUNDEVEN_PPCF128));
966 RTLIB::SIN_PPCF128));
970 return SoftenFloatRes_Unary(
971 N,
GetFPLibCall(
N->getValueType(0), RTLIB::SINH_F32, RTLIB::SINH_F64,
972 RTLIB::SINH_F80, RTLIB::SINH_F128, RTLIB::SINH_PPCF128));
981 RTLIB::SQRT_PPCF128));
990 RTLIB::SUB_PPCF128));
994 return SoftenFloatRes_Unary(
995 N,
GetFPLibCall(
N->getValueType(0), RTLIB::TAN_F32, RTLIB::TAN_F64,
996 RTLIB::TAN_F80, RTLIB::TAN_F128, RTLIB::TAN_PPCF128));
1000 return SoftenFloatRes_Unary(
1001 N,
GetFPLibCall(
N->getValueType(0), RTLIB::TANH_F32, RTLIB::TANH_F64,
1002 RTLIB::TANH_F80, RTLIB::TANH_F128, RTLIB::TANH_PPCF128));
1011 RTLIB::TRUNC_PPCF128));
1016 EVT VT =
N->getValueType(0);
1017 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
1021 L->getMemOperand()->getFlags() &
1025 NewL = DAG.getLoad(
L->getAddressingMode(),
L->getExtensionType(), NVT, dl,
1026 L->getChain(),
L->getBasePtr(),
L->getOffset(),
1027 L->getPointerInfo(), NVT,
L->getBaseAlign(), MMOFlags,
1037 dl,
L->getChain(),
L->getBasePtr(),
L->getOffset(),
1038 L->getPointerInfo(),
L->getMemoryVT(),
L->getBaseAlign(),
1039 MMOFlags,
L->getAAInfo());
1044 return BitConvertToInteger(ExtendNode);
1049 EVT VT =
N->getValueType(0);
1050 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
1056 {L->getChain(), L->getBasePtr()},
L->getMemOperand());
1070 return DAG.getSelect(SDLoc(
N),
1071 LHS.getValueType(),
N->getOperand(0),
LHS,
RHS);
1078 LHS.getValueType(),
N->getOperand(0),
1079 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1083 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1084 N->getValueType(0)));
1090 EVT VT =
N->getValueType(0);
1091 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
1095 NewVAARG = DAG.getVAArg(NVT, dl, Chain, Ptr,
N->getOperand(2),
1096 N->getConstantOperandVal(3));
1106 bool IsStrict =
N->isStrictFPOpcode();
1109 EVT SVT =
N->getOperand(IsStrict ? 1 : 0).getValueType();
1110 EVT RVT =
N->getValueType(0);
1117 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
1118 for (
unsigned t = MVT::FIRST_INTEGER_VALUETYPE;
1119 t <= MVT::LAST_INTEGER_VALUETYPE && LC == RTLIB::UNKNOWN_LIBCALL; ++t) {
1125 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported XINT_TO_FP!");
1130 NVT,
N->getOperand(IsStrict ? 1 : 0));
1131 TargetLowering::MakeLibCallOptions CallOptions;
1134 std::pair<SDValue, SDValue> Tmp =
1135 TLI.makeLibCall(DAG, LC, TLI.getTypeToTransformTo(*DAG.getContext(), RVT),
1136 Op, CallOptions, dl, Chain);
1139 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
1145 ReplaceValueWith(
SDValue(
N, 0), TLI.expandVecReduce(
N, DAG));
1149SDValue DAGTypeLegalizer::SoftenFloatRes_VECREDUCE_SEQ(
SDNode *
N) {
1150 ReplaceValueWith(
SDValue(
N, 0), TLI.expandVecReduceSeq(
N, DAG));
1158bool DAGTypeLegalizer::SoftenFloatOperand(
SDNode *
N,
unsigned OpNo) {
1159 LLVM_DEBUG(
dbgs() <<
"Soften float operand " << OpNo <<
": ";
N->dump(&DAG));
1162 switch (
N->getOpcode()) {
1165 dbgs() <<
"SoftenFloatOperand Op #" << OpNo <<
": ";
1166 N->dump(&DAG);
dbgs() <<
"\n";
1171 case ISD::BR_CC: Res = SoftenFloatOp_BR_CC(
N);
break;
1184 Res = SoftenFloatOp_FP_TO_XINT_SAT(
N);
break;
1186 case ISD::LROUND: Res = SoftenFloatOp_LROUND(
N);
break;
1190 case ISD::LRINT: Res = SoftenFloatOp_LRINT(
N);
break;
1192 case ISD::LLRINT: Res = SoftenFloatOp_LLRINT(
N);
break;
1196 case ISD::SETCC: Res = SoftenFloatOp_SETCC(
N);
break;
1197 case ISD::STORE: Res = SoftenFloatOp_STORE(
N, OpNo);
break;
1199 Res = SoftenFloatOp_ATOMIC_STORE(
N, OpNo);
1203 Res = SoftenFloatOp_FAKE_USE(
N);
1206 Res = SoftenFloatOp_STACKMAP(
N, OpNo);
1209 Res = SoftenFloatOp_PATCHPOINT(
N, OpNo);
1214 if (!Res.
getNode())
return false;
1222 "Invalid operand softening");
1224 ReplaceValueWith(
SDValue(
N, 0), Res);
1229 SDValue Op0 = GetSoftenedFloat(
N->getOperand(0));
1231 return DAG.getNode(
ISD::BITCAST, SDLoc(
N),
N->getValueType(0), Op0);
1243 bool IsStrict =
N->isStrictFPOpcode();
1244 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
1245 EVT SVT =
Op.getValueType();
1246 EVT RVT =
N->getValueType(0);
1250 FloatRVT = MVT::f16;
1253 FloatRVT = MVT::bf16;
1256 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported FP_ROUND libcall");
1259 Op = GetSoftenedFloat(
Op);
1260 TargetLowering::MakeLibCallOptions CallOptions;
1262 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RVT,
Op,
1263 CallOptions, SDLoc(
N),
1266 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
1267 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
1278 NewLHS = GetSoftenedFloat(NewLHS);
1279 NewRHS = GetSoftenedFloat(NewRHS);
1280 TLI.softenSetCCOperands(DAG, VT, NewLHS, NewRHS, CCCode, SDLoc(
N),
1281 N->getOperand(2),
N->getOperand(3));
1285 if (!NewRHS.getNode()) {
1286 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
1291 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
1292 DAG.getCondCode(CCCode), NewLHS, NewRHS,
1302 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
1303 for (
unsigned IntVT = MVT::FIRST_INTEGER_VALUETYPE;
1304 IntVT <= MVT::LAST_INTEGER_VALUETYPE && LC == RTLIB::UNKNOWN_LIBCALL;
1308 if (Promoted.
bitsGE(RetVT))
1316 bool IsStrict =
N->isStrictFPOpcode();
1320 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
1321 EVT SVT =
Op.getValueType();
1322 EVT RVT =
N->getValueType(0);
1332 "Unsupported FP_TO_XINT!");
1334 Op = GetSoftenedFloat(
Op);
1336 TargetLowering::MakeLibCallOptions CallOptions;
1338 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, NVT,
Op,
1339 CallOptions, dl, Chain);
1347 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
1348 ReplaceValueWith(
SDValue(
N, 0), Res);
1352SDValue DAGTypeLegalizer::SoftenFloatOp_FP_TO_XINT_SAT(
SDNode *
N) {
1353 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
1362 NewLHS = GetSoftenedFloat(NewLHS);
1363 NewRHS = GetSoftenedFloat(NewRHS);
1364 TLI.softenSetCCOperands(DAG, VT, NewLHS, NewRHS, CCCode, SDLoc(
N),
1365 N->getOperand(0),
N->getOperand(1));
1369 if (!NewRHS.getNode()) {
1370 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
1375 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
1376 N->getOperand(2),
N->getOperand(3),
1377 DAG.getCondCode(CCCode)),
1382 bool IsStrict =
N->isStrictFPOpcode();
1390 SDValue NewLHS = GetSoftenedFloat(Op0);
1391 SDValue NewRHS = GetSoftenedFloat(Op1);
1392 TLI.softenSetCCOperands(DAG, VT, NewLHS, NewRHS, CCCode, SDLoc(
N), Op0, Op1,
1399 NewRHS, DAG.getCondCode(CCCode));
1401 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
1402 DAG.getCondCode(CCCode)), 0);
1407 "Unexpected setcc expansion!");
1410 ReplaceValueWith(
SDValue(
N, 0), NewLHS);
1411 ReplaceValueWith(
SDValue(
N, 1), Chain);
1417SDValue DAGTypeLegalizer::SoftenFloatOp_STORE(
SDNode *
N,
unsigned OpNo) {
1419 assert(OpNo == 1 &&
"Can only soften the stored value!");
1424 if (
ST->isTruncatingStore())
1426 Val = BitConvertToInteger(
1428 DAG.getIntPtrConstant(0, dl,
true)));
1430 Val = GetSoftenedFloat(Val);
1432 return DAG.getStore(
ST->getChain(), dl, Val,
ST->getBasePtr(),
1433 ST->getMemOperand());
1436SDValue DAGTypeLegalizer::SoftenFloatOp_ATOMIC_STORE(
SDNode *
N,
unsigned OpNo) {
1437 assert(OpNo == 1 &&
"Can only soften the stored value!");
1443 assert(
ST->getMemoryVT() == VT &&
"truncating atomic store not handled");
1445 SDValue NewVal = GetSoftenedFloat(Val);
1447 ST->getBasePtr(),
ST->getMemOperand());
1452 SDValue RHS = BitConvertToInteger(
N->getOperand(1));
1455 EVT LVT =
LHS.getValueType();
1457 EVT RVT =
RHS.getValueType();
1463 int SizeDiff = RSize - LSize;
1467 DAG.getConstant(SizeDiff, dl,
1468 TLI.getShiftAmountTy(
RHS.getValueType(),
1469 DAG.getDataLayout())));
1471 }
else if (SizeDiff < 0) {
1475 DAG.getConstant(-SizeDiff, dl,
1476 TLI.getShiftAmountTy(
RHS.getValueType(),
1477 DAG.getDataLayout())));
1480 RHS = DAG.getBitcast(LVT,
RHS);
1484SDValue DAGTypeLegalizer::SoftenFloatOp_Unary(
SDNode *
N, RTLIB::Libcall LC) {
1485 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1486 bool IsStrict =
N->isStrictFPOpcode();
1487 unsigned Offset = IsStrict ? 1 : 0;
1490 TargetLowering::MakeLibCallOptions CallOptions;
1491 EVT OpVT =
N->getOperand(0 +
Offset).getValueType();
1493 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, NVT,
Op,
1494 CallOptions, SDLoc(
N),
1497 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
1498 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
1506 EVT OpVT =
N->getOperand(
N->isStrictFPOpcode() ? 1 : 0).getValueType();
1512 RTLIB::LROUND_PPCF128));
1516 EVT OpVT =
N->getOperand(
N->isStrictFPOpcode() ? 1 : 0).getValueType();
1521 RTLIB::LLROUND_F128,
1522 RTLIB::LLROUND_PPCF128));
1526 EVT OpVT =
N->getOperand(
N->isStrictFPOpcode() ? 1 : 0).getValueType();
1532 RTLIB::LRINT_PPCF128));
1536 EVT OpVT =
N->getOperand(
N->isStrictFPOpcode() ? 1 : 0).getValueType();
1542 RTLIB::LLRINT_PPCF128));
1546 SDValue Op1 = BitConvertToInteger(
N->getOperand(1));
1547 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
1548 N->getOperand(0), Op1);
1551SDValue DAGTypeLegalizer::SoftenFloatOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
1554 NewOps[OpNo] = GetSoftenedFloat(NewOps[OpNo]);
1555 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
1558SDValue DAGTypeLegalizer::SoftenFloatOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
1561 NewOps[OpNo] = GetSoftenedFloat(NewOps[OpNo]);
1562 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
1573void DAGTypeLegalizer::ExpandFloatResult(
SDNode *
N,
unsigned ResNo) {
1579 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
1582 switch (
N->getOpcode()) {
1585 dbgs() <<
"ExpandFloatResult #" << ResNo <<
": ";
1586 N->dump(&DAG);
dbgs() <<
"\n";
1701 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1703 "Do not know how to expand this float constant!");
1707 Lo = DAG.getConstantFP(
APFloat(Sem,
C.extractBits(64, 64)), dl, NVT);
1708 Hi = DAG.getConstantFP(
APFloat(Sem,
C.extractBits(64, 0)), dl, NVT);
1711void DAGTypeLegalizer::ExpandFloatRes_Unary(
SDNode *
N, RTLIB::Libcall LC,
1713 bool IsStrict =
N->isStrictFPOpcode();
1714 unsigned Offset = IsStrict ? 1 : 0;
1717 TargetLowering::MakeLibCallOptions CallOptions;
1718 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC,
N->getValueType(0),
1719 Op, CallOptions, SDLoc(
N),
1722 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
1723 GetPairElements(Tmp.first,
Lo,
Hi);
1726void DAGTypeLegalizer::ExpandFloatRes_Binary(
SDNode *
N, RTLIB::Libcall LC,
1728 bool IsStrict =
N->isStrictFPOpcode();
1729 unsigned Offset = IsStrict ? 1 : 0;
1732 TargetLowering::MakeLibCallOptions CallOptions;
1733 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC,
N->getValueType(0),
1734 Ops, CallOptions, SDLoc(
N),
1737 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
1738 GetPairElements(Tmp.first,
Lo,
Hi);
1741void DAGTypeLegalizer::ExpandFloatRes_FMODF(
SDNode *
N) {
1742 ExpandFloatRes_UnaryWithTwoFPResults(
N,
RTLIB::getMODF(
N->getValueType(0)),
1746void DAGTypeLegalizer::ExpandFloatRes_FSINCOS(
SDNode *
N) {
1750void DAGTypeLegalizer::ExpandFloatRes_FSINCOSPI(
SDNode *
N) {
1751 ExpandFloatRes_UnaryWithTwoFPResults(
N,
1755void DAGTypeLegalizer::ExpandFloatRes_UnaryWithTwoFPResults(
1756 SDNode *
N, RTLIB::Libcall LC, std::optional<unsigned> CallRetResNo) {
1757 assert(!
N->isStrictFPOpcode() &&
"strictfp not implemented");
1759 TLI.expandMultipleResultFPLibCall(DAG, LC,
N,
Results, CallRetResNo);
1762 GetPairElements(Res,
Lo,
Hi);
1769 assert(
N->getValueType(0) == MVT::ppcf128 &&
1770 "Logic only correct for ppcf128!");
1773 GetExpandedFloat(
N->getOperand(0),
Lo, Tmp);
1776 Lo = DAG.getSelectCC(dl, Tmp,
Hi,
Lo,
1784 RTLIB::FMIN_F32, RTLIB::FMIN_F64,
1785 RTLIB::FMIN_F80, RTLIB::FMIN_F128,
1786 RTLIB::FMIN_PPCF128),
Lo,
Hi);
1792 RTLIB::FMAX_F32, RTLIB::FMAX_F64,
1793 RTLIB::FMAX_F80, RTLIB::FMAX_F128,
1794 RTLIB::FMAX_PPCF128),
Lo,
Hi);
1799 ExpandFloatRes_Binary(
1802 RTLIB::FMINIMUM_NUM_F64, RTLIB::FMINIMUM_NUM_F80,
1803 RTLIB::FMINIMUM_NUM_F128, RTLIB::FMINIMUM_NUM_PPCF128),
1809 ExpandFloatRes_Binary(
1812 RTLIB::FMAXIMUM_NUM_F64, RTLIB::FMAXIMUM_NUM_F80,
1813 RTLIB::FMAXIMUM_NUM_F128, RTLIB::FMAXIMUM_NUM_PPCF128),
1820 RTLIB::ADD_F32, RTLIB::ADD_F64,
1821 RTLIB::ADD_F80, RTLIB::ADD_F128,
1822 RTLIB::ADD_PPCF128),
Lo,
Hi);
1827 ExpandFloatRes_Unary(
N,
1829 RTLIB::ACOS_F64, RTLIB::ACOS_F80,
1830 RTLIB::ACOS_F128, RTLIB::ACOS_PPCF128),
1836 ExpandFloatRes_Unary(
N,
1838 RTLIB::ASIN_F64, RTLIB::ASIN_F80,
1839 RTLIB::ASIN_F128, RTLIB::ASIN_PPCF128),
1845 ExpandFloatRes_Unary(
N,
1847 RTLIB::ATAN_F64, RTLIB::ATAN_F80,
1848 RTLIB::ATAN_F128, RTLIB::ATAN_PPCF128),
1854 ExpandFloatRes_Binary(
N,
1856 RTLIB::ATAN2_F64, RTLIB::ATAN2_F80,
1857 RTLIB::ATAN2_F128, RTLIB::ATAN2_PPCF128),
1863 ExpandFloatRes_Unary(
N,
GetFPLibCall(
N->getValueType(0), RTLIB::CBRT_F32,
1864 RTLIB::CBRT_F64, RTLIB::CBRT_F80,
1866 RTLIB::CBRT_PPCF128),
Lo,
Hi);
1869void DAGTypeLegalizer::ExpandFloatRes_FCEIL(
SDNode *
N,
1872 RTLIB::CEIL_F32, RTLIB::CEIL_F64,
1873 RTLIB::CEIL_F80, RTLIB::CEIL_F128,
1874 RTLIB::CEIL_PPCF128),
Lo,
Hi);
1877void DAGTypeLegalizer::ExpandFloatRes_FCOPYSIGN(
SDNode *
N,
1880 RTLIB::COPYSIGN_F32,
1881 RTLIB::COPYSIGN_F64,
1882 RTLIB::COPYSIGN_F80,
1883 RTLIB::COPYSIGN_F128,
1884 RTLIB::COPYSIGN_PPCF128),
Lo,
Hi);
1887void DAGTypeLegalizer::ExpandFloatRes_FCOS(
SDNode *
N,
1890 RTLIB::COS_F32, RTLIB::COS_F64,
1891 RTLIB::COS_F80, RTLIB::COS_F128,
1892 RTLIB::COS_PPCF128),
Lo,
Hi);
1897 ExpandFloatRes_Unary(
N,
1899 RTLIB::COSH_F64, RTLIB::COSH_F80,
1900 RTLIB::COSH_F128, RTLIB::COSH_PPCF128),
1911 RTLIB::DIV_PPCF128),
Lo,
Hi);
1914void DAGTypeLegalizer::ExpandFloatRes_FEXP(
SDNode *
N,
1917 RTLIB::EXP_F32, RTLIB::EXP_F64,
1918 RTLIB::EXP_F80, RTLIB::EXP_F128,
1919 RTLIB::EXP_PPCF128),
Lo,
Hi);
1922void DAGTypeLegalizer::ExpandFloatRes_FEXP2(
SDNode *
N,
1925 RTLIB::EXP2_F32, RTLIB::EXP2_F64,
1926 RTLIB::EXP2_F80, RTLIB::EXP2_F128,
1927 RTLIB::EXP2_PPCF128),
Lo,
Hi);
1932 ExpandFloatRes_Unary(
N,
1934 RTLIB::EXP10_F64, RTLIB::EXP10_F80,
1935 RTLIB::EXP10_F128, RTLIB::EXP10_PPCF128),
1939void DAGTypeLegalizer::ExpandFloatRes_FFLOOR(
SDNode *
N,
1942 RTLIB::FLOOR_F32, RTLIB::FLOOR_F64,
1943 RTLIB::FLOOR_F80, RTLIB::FLOOR_F128,
1944 RTLIB::FLOOR_PPCF128),
Lo,
Hi);
1947void DAGTypeLegalizer::ExpandFloatRes_FLOG(
SDNode *
N,
1950 RTLIB::LOG_F32, RTLIB::LOG_F64,
1951 RTLIB::LOG_F80, RTLIB::LOG_F128,
1952 RTLIB::LOG_PPCF128),
Lo,
Hi);
1955void DAGTypeLegalizer::ExpandFloatRes_FLOG2(
SDNode *
N,
1958 RTLIB::LOG2_F32, RTLIB::LOG2_F64,
1959 RTLIB::LOG2_F80, RTLIB::LOG2_F128,
1960 RTLIB::LOG2_PPCF128),
Lo,
Hi);
1963void DAGTypeLegalizer::ExpandFloatRes_FLOG10(
SDNode *
N,
1966 RTLIB::LOG10_F32, RTLIB::LOG10_F64,
1967 RTLIB::LOG10_F80, RTLIB::LOG10_F128,
1968 RTLIB::LOG10_PPCF128),
Lo,
Hi);
1973 bool IsStrict =
N->isStrictFPOpcode();
1974 unsigned Offset = IsStrict ? 1 : 0;
1978 TargetLowering::MakeLibCallOptions CallOptions;
1979 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG,
GetFPLibCall(
N->getValueType(0),
1984 RTLIB::FMA_PPCF128),
1985 N->getValueType(0),
Ops, CallOptions,
1988 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
1989 GetPairElements(Tmp.first,
Lo,
Hi);
1999 RTLIB::MUL_PPCF128),
Lo,
Hi);
2002void DAGTypeLegalizer::ExpandFloatRes_FNEARBYINT(
SDNode *
N,
2005 RTLIB::NEARBYINT_F32,
2006 RTLIB::NEARBYINT_F64,
2007 RTLIB::NEARBYINT_F80,
2008 RTLIB::NEARBYINT_F128,
2009 RTLIB::NEARBYINT_PPCF128),
Lo,
Hi);
2015 GetExpandedFloat(
N->getOperand(0),
Lo,
Hi);
2020void DAGTypeLegalizer::ExpandFloatRes_AssertNoFPClass(
SDNode *
N,
SDValue &
Lo,
2024 GetExpandedFloat(
N->getOperand(0),
Lo,
Hi);
2029 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
2031 bool IsStrict =
N->isStrictFPOpcode();
2036 if (NVT ==
N->getOperand(1).getValueType()) {
2037 Hi =
N->getOperand(1);
2042 {
N->getOperand(0),
N->getOperand(1) });
2052 ReplaceValueWith(
SDValue(
N, 1), Chain);
2055void DAGTypeLegalizer::ExpandFloatRes_FPOW(
SDNode *
N,
2058 RTLIB::POW_F32, RTLIB::POW_F64,
2059 RTLIB::POW_F80, RTLIB::POW_F128,
2060 RTLIB::POW_PPCF128),
Lo,
Hi);
2063void DAGTypeLegalizer::ExpandFloatRes_FPOWI(
SDNode *
N,
2073void DAGTypeLegalizer::ExpandFloatRes_FREEZE(
SDNode *
N,
2075 assert(
N->getValueType(0) == MVT::ppcf128 &&
2076 "Logic only correct for ppcf128!");
2079 GetExpandedFloat(
N->getOperand(0),
Lo,
Hi);
2084void DAGTypeLegalizer::ExpandFloatRes_FREM(
SDNode *
N,
2087 RTLIB::REM_F32, RTLIB::REM_F64,
2088 RTLIB::REM_F80, RTLIB::REM_F128,
2089 RTLIB::REM_PPCF128),
Lo,
Hi);
2092void DAGTypeLegalizer::ExpandFloatRes_FRINT(
SDNode *
N,
2095 RTLIB::RINT_F32, RTLIB::RINT_F64,
2096 RTLIB::RINT_F80, RTLIB::RINT_F128,
2097 RTLIB::RINT_PPCF128),
Lo,
Hi);
2100void DAGTypeLegalizer::ExpandFloatRes_FROUND(
SDNode *
N,
2107 RTLIB::ROUND_PPCF128),
Lo,
Hi);
2110void DAGTypeLegalizer::ExpandFloatRes_FROUNDEVEN(
SDNode *
N,
2113 RTLIB::ROUNDEVEN_F32,
2114 RTLIB::ROUNDEVEN_F64,
2115 RTLIB::ROUNDEVEN_F80,
2116 RTLIB::ROUNDEVEN_F128,
2117 RTLIB::ROUNDEVEN_PPCF128),
Lo,
Hi);
2120void DAGTypeLegalizer::ExpandFloatRes_FSIN(
SDNode *
N,
2123 RTLIB::SIN_F32, RTLIB::SIN_F64,
2124 RTLIB::SIN_F80, RTLIB::SIN_F128,
2125 RTLIB::SIN_PPCF128),
Lo,
Hi);
2130 ExpandFloatRes_Unary(
N,
2132 RTLIB::SINH_F64, RTLIB::SINH_F80,
2133 RTLIB::SINH_F128, RTLIB::SINH_PPCF128),
2137void DAGTypeLegalizer::ExpandFloatRes_FSQRT(
SDNode *
N,
2140 RTLIB::SQRT_F32, RTLIB::SQRT_F64,
2141 RTLIB::SQRT_F80, RTLIB::SQRT_F128,
2142 RTLIB::SQRT_PPCF128),
Lo,
Hi);
2152 RTLIB::SUB_PPCF128),
Lo,
Hi);
2157 ExpandFloatRes_Unary(
N,
2159 RTLIB::TAN_F64, RTLIB::TAN_F80,
2160 RTLIB::TAN_F128, RTLIB::TAN_PPCF128),
2166 ExpandFloatRes_Unary(
N,
2168 RTLIB::TANH_F64, RTLIB::TANH_F80,
2169 RTLIB::TANH_F128, RTLIB::TANH_PPCF128),
2173void DAGTypeLegalizer::ExpandFloatRes_FTRUNC(
SDNode *
N,
2176 RTLIB::TRUNC_F32, RTLIB::TRUNC_F64,
2177 RTLIB::TRUNC_F80, RTLIB::TRUNC_F128,
2178 RTLIB::TRUNC_PPCF128),
Lo,
Hi);
2184 ExpandRes_NormalLoad(
N,
Lo,
Hi);
2194 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
LD->getValueType(0));
2196 assert(
LD->getMemoryVT().bitsLE(NVT) &&
"Float type not round?");
2198 Hi = DAG.getExtLoad(
LD->getExtensionType(), dl, NVT, Chain, Ptr,
2199 LD->getMemoryVT(),
LD->getMemOperand());
2209 ReplaceValueWith(
SDValue(LD, 1), Chain);
2214 assert(
N->getValueType(0) == MVT::ppcf128 &&
"Unsupported XINT_TO_FP!");
2215 EVT VT =
N->getValueType(0);
2216 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
2217 bool Strict =
N->isStrictFPOpcode();
2218 SDValue Src =
N->getOperand(Strict ? 1 : 0);
2219 EVT SrcVT = Src.getValueType();
2227 Flags.setNoFPExcept(
N->getFlags().hasNoFPExcept());
2232 if (SrcVT.
bitsLE(MVT::i32)) {
2236 Hi = DAG.getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
2237 {Chain, Src}, Flags);
2240 Hi = DAG.getNode(
N->getOpcode(), dl, NVT, Src);
2242 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
2243 if (SrcVT.
bitsLE(MVT::i64)) {
2246 LC = RTLIB::SINTTOFP_I64_PPCF128;
2247 }
else if (SrcVT.
bitsLE(MVT::i128)) {
2249 LC = RTLIB::SINTTOFP_I128_PPCF128;
2251 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported XINT_TO_FP!");
2253 TargetLowering::MakeLibCallOptions CallOptions;
2255 std::pair<SDValue, SDValue> Tmp =
2256 TLI.makeLibCall(DAG, LC, VT, Src, CallOptions, dl, Chain);
2259 GetPairElements(Tmp.first,
Lo,
Hi);
2263 if (isSigned || SrcVT.
bitsLE(MVT::i32)) {
2265 ReplaceValueWith(
SDValue(
N, 1), Chain);
2275 SrcVT = Src.getValueType();
2278 static const uint64_t TwoE32[] = { 0x41f0000000000000LL, 0 };
2279 static const uint64_t TwoE64[] = { 0x43f0000000000000LL, 0 };
2280 static const uint64_t TwoE128[] = { 0x47f0000000000000LL, 0 };
2281 ArrayRef<uint64_t> Parts;
2298 SDValue NewLo = DAG.getConstantFP(
2302 {Chain, Hi, NewLo}, Flags);
2304 ReplaceValueWith(
SDValue(
N, 1), Chain);
2307 Lo = DAG.getSelectCC(dl, Src, DAG.getConstant(0, dl, SrcVT),
2309 GetPairElements(
Lo,
Lo,
Hi);
2321bool DAGTypeLegalizer::ExpandFloatOperand(
SDNode *
N,
unsigned OpNo) {
2326 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
2329 switch (
N->getOpcode()) {
2332 dbgs() <<
"ExpandFloatOperand Op #" << OpNo <<
": ";
2333 N->dump(&DAG);
dbgs() <<
"\n";
2341 case ISD::BR_CC: Res = ExpandFloatOp_BR_CC(
N);
break;
2349 case ISD::LROUND: Res = ExpandFloatOp_LROUND(
N);
break;
2351 case ISD::LRINT: Res = ExpandFloatOp_LRINT(
N);
break;
2352 case ISD::LLRINT: Res = ExpandFloatOp_LLRINT(
N);
break;
2356 case ISD::SETCC: Res = ExpandFloatOp_SETCC(
N);
break;
2362 if (!Res.
getNode())
return false;
2370 "Invalid operand expansion");
2372 ReplaceValueWith(
SDValue(
N, 0), Res);
2378void DAGTypeLegalizer::FloatExpandSetCCOperands(
SDValue &NewLHS,
2383 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
2384 GetExpandedFloat(NewLHS, LHSLo, LHSHi);
2385 GetExpandedFloat(NewRHS, RHSLo, RHSHi);
2394 SDValue Tmp1, Tmp2, Tmp3, OutputChain;
2395 Tmp1 = DAG.getSetCC(dl, getSetCCResultType(LHSHi.
getValueType()), LHSHi,
2398 Tmp2 = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
2399 RHSLo, CCCode, OutputChain, IsSignaling);
2403 DAG.getSetCC(dl, getSetCCResultType(LHSHi.
getValueType()), LHSHi, RHSHi,
2406 Tmp2 = DAG.getSetCC(dl, getSetCCResultType(LHSHi.
getValueType()), LHSHi,
2407 RHSHi, CCCode, OutputChain, IsSignaling);
2412 Chain = OutputChain;
2419 FloatExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N), Chain);
2424 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
2429 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2430 DAG.getCondCode(CCCode), NewLHS, NewRHS,
2431 N->getOperand(4)), 0);
2435 assert(
N->getOperand(1).getValueType() == MVT::ppcf128 &&
2436 "Logic only correct for ppcf128!");
2438 GetExpandedFloat(
N->getOperand(1),
Lo,
Hi);
2442 N->getValueType(0),
N->getOperand(0),
Hi);
2446 bool IsStrict =
N->isStrictFPOpcode();
2447 assert(
N->getOperand(IsStrict ? 1 : 0).getValueType() == MVT::ppcf128 &&
2448 "Logic only correct for ppcf128!");
2450 GetExpandedFloat(
N->getOperand(IsStrict ? 1 : 0),
Lo,
Hi);
2455 N->getValueType(0),
Hi,
N->getOperand(1));
2459 if (
Hi.getValueType() ==
N->getValueType(0)) {
2461 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
2467 {
N->getValueType(0), MVT::Other},
2468 {
N->getOperand(0),
Hi,
N->getOperand(2)});
2475 EVT RVT =
N->getValueType(0);
2478 bool IsStrict =
N->isStrictFPOpcode();
2481 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
2487 "Unsupported FP_TO_XINT!");
2488 TargetLowering::MakeLibCallOptions CallOptions;
2489 std::pair<SDValue, SDValue> Tmp =
2490 TLI.makeLibCall(DAG, LC, NVT,
Op, CallOptions, dl, Chain);
2494 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2495 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2503 FloatExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N), Chain);
2508 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
2513 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
2514 N->getOperand(2),
N->getOperand(3),
2515 DAG.getCondCode(CCCode)), 0);
2519 bool IsStrict =
N->isStrictFPOpcode();
2525 FloatExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N), Chain,
2531 "Unexpected setcc expansion!");
2533 ReplaceValueWith(
SDValue(
N, 0), NewLHS);
2534 ReplaceValueWith(
SDValue(
N, 1), Chain);
2540SDValue DAGTypeLegalizer::ExpandFloatOp_STORE(
SDNode *
N,
unsigned OpNo) {
2542 return ExpandOp_NormalStore(
N, OpNo);
2545 assert(OpNo == 1 &&
"Can only expand the stored value so far");
2551 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
2552 ST->getValue().getValueType());
2554 assert(
ST->getMemoryVT().bitsLE(NVT) &&
"Float type not round?");
2558 GetExpandedOp(
ST->getValue(),
Lo,
Hi);
2560 return DAG.getTruncStore(Chain, SDLoc(
N),
Hi, Ptr,
2561 ST->getMemoryVT(),
ST->getMemOperand());
2565 EVT RVT =
N->getValueType(0);
2566 EVT RetVT =
N->getOperand(0).getValueType();
2567 TargetLowering::MakeLibCallOptions CallOptions;
2573 RTLIB::LROUND_PPCF128),
2574 RVT,
N->getOperand(0), CallOptions, SDLoc(
N)).first;
2578 EVT RVT =
N->getValueType(0);
2579 EVT RetVT =
N->getOperand(0).getValueType();
2580 TargetLowering::MakeLibCallOptions CallOptions;
2585 RTLIB::LLROUND_F128,
2586 RTLIB::LLROUND_PPCF128),
2587 RVT,
N->getOperand(0), CallOptions, SDLoc(
N)).first;
2591 EVT RVT =
N->getValueType(0);
2592 EVT RetVT =
N->getOperand(0).getValueType();
2593 TargetLowering::MakeLibCallOptions CallOptions;
2599 RTLIB::LRINT_PPCF128),
2600 RVT,
N->getOperand(0), CallOptions, SDLoc(
N)).first;
2604 EVT RVT =
N->getValueType(0);
2605 EVT RetVT =
N->getOperand(0).getValueType();
2606 TargetLowering::MakeLibCallOptions CallOptions;
2612 RTLIB::LLRINT_PPCF128),
2613 RVT,
N->getOperand(0), CallOptions, SDLoc(
N)).first;
2622 if (OpVT == MVT::f16)
2624 if (RetVT == MVT::f16)
2626 if (OpVT == MVT::bf16)
2628 if (RetVT == MVT::bf16)
2634 if (OpVT == MVT::f16)
2636 if (RetVT == MVT::f16)
2638 if (OpVT == MVT::bf16)
2640 if (RetVT == MVT::bf16)
2645bool DAGTypeLegalizer::PromoteFloatOperand(
SDNode *
N,
unsigned OpNo) {
2646 LLVM_DEBUG(
dbgs() <<
"Promote float operand " << OpNo <<
": ";
N->dump(&DAG));
2649 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2660 switch (
N->getOpcode()) {
2663 dbgs() <<
"PromoteFloatOperand Op #" << OpNo <<
": ";
2664 N->dump(&DAG);
dbgs() <<
"\n";
2670 R = PromoteFloatOp_FAKE_USE(
N, OpNo);
2678 case ISD::LLRINT:
R = PromoteFloatOp_UnaryOp(
N, OpNo);
break;
2682 R = PromoteFloatOp_FP_TO_XINT_SAT(
N, OpNo);
break;
2685 R = PromoteFloatOp_STRICT_FP_EXTEND(
N, OpNo);
2688 case ISD::SETCC:
R = PromoteFloatOp_SETCC(
N, OpNo);
break;
2689 case ISD::STORE:
R = PromoteFloatOp_STORE(
N, OpNo);
break;
2695 ReplaceValueWith(
SDValue(
N, 0), R);
2699SDValue DAGTypeLegalizer::PromoteFloatOp_BITCAST(
SDNode *
N,
unsigned OpNo) {
2701 EVT OpVT =
Op->getValueType(0);
2703 SDValue Promoted = GetPromotedFloat(
N->getOperand(0));
2712 return DAG.getBitcast(
N->getValueType(0), Convert);
2715SDValue DAGTypeLegalizer::PromoteFloatOp_FAKE_USE(
SDNode *
N,
unsigned OpNo) {
2716 assert(OpNo == 1 &&
"Only Operand 1 must need promotion here");
2717 SDValue Op = GetPromotedFloat(
N->getOperand(OpNo));
2718 return DAG.getNode(
N->getOpcode(), SDLoc(
N), MVT::Other,
N->getOperand(0),
2724SDValue DAGTypeLegalizer::PromoteFloatOp_FCOPYSIGN(
SDNode *
N,
unsigned OpNo) {
2725 assert (OpNo == 1 &&
"Only Operand 1 must need promotion here");
2726 SDValue Op1 = GetPromotedFloat(
N->getOperand(1));
2728 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2729 N->getOperand(0), Op1);
2733SDValue DAGTypeLegalizer::PromoteFloatOp_UnaryOp(
SDNode *
N,
unsigned OpNo) {
2734 SDValue Op = GetPromotedFloat(
N->getOperand(0));
2735 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
Op);
2739SDValue DAGTypeLegalizer::PromoteFloatOp_AssertNoFPClass(
SDNode *
N,
2741 return GetPromotedFloat(
N->getOperand(0));
2744SDValue DAGTypeLegalizer::PromoteFloatOp_FP_TO_XINT_SAT(
SDNode *
N,
2746 SDValue Op = GetPromotedFloat(
N->getOperand(0));
2747 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
Op,
2751SDValue DAGTypeLegalizer::PromoteFloatOp_FP_EXTEND(
SDNode *
N,
unsigned OpNo) {
2752 SDValue Op = GetPromotedFloat(
N->getOperand(0));
2753 EVT VT =
N->getValueType(0);
2756 if (VT ==
Op->getValueType(0))
2763SDValue DAGTypeLegalizer::PromoteFloatOp_STRICT_FP_EXTEND(
SDNode *
N,
2765 assert(OpNo == 1 &&
"Promoting unpromotable operand");
2767 SDValue Op = GetPromotedFloat(
N->getOperand(1));
2768 EVT VT =
N->getValueType(0);
2771 if (VT ==
Op->getValueType(0)) {
2772 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
2778 N->getOperand(0),
Op);
2786SDValue DAGTypeLegalizer::PromoteFloatOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2791 LHS,
RHS,
N->getOperand(2),
N->getOperand(3),
2797SDValue DAGTypeLegalizer::PromoteFloatOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2798 EVT VT =
N->getValueType(0);
2799 SDValue Op0 = GetPromotedFloat(
N->getOperand(0));
2800 SDValue Op1 = GetPromotedFloat(
N->getOperand(1));
2803 return DAG.getSetCC(SDLoc(
N), VT, Op0, Op1, CCCode);
2809SDValue DAGTypeLegalizer::PromoteFloatOp_STORE(
SDNode *
N,
unsigned OpNo) {
2814 SDValue Promoted = GetPromotedFloat(Val);
2815 EVT VT =
ST->getOperand(1).getValueType();
2822 return DAG.getStore(
ST->getChain(),
DL, NewVal,
ST->getBasePtr(),
2823 ST->getMemOperand());
2832 SDValue Promoted = GetPromotedFloat(Val);
2833 EVT VT =
ST->getOperand(1).getValueType();
2840 ST->getBasePtr(),
ST->getMemOperand());
2847void DAGTypeLegalizer::PromoteFloatResult(
SDNode *
N,
unsigned ResNo) {
2848 LLVM_DEBUG(
dbgs() <<
"Promote float result " << ResNo <<
": ";
N->dump(&DAG));
2852 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true)) {
2857 switch (
N->getOpcode()) {
2864 dbgs() <<
"PromoteFloatResult #" << ResNo <<
": ";
2865 N->dump(&DAG);
dbgs() <<
"\n";
2870 R = PromoteFloatRes_BITCAST(
N);
2873 R = PromoteFloatRes_FREEZE(
N);
2877 R = PromoteFloatRes_EXTRACT_VECTOR_ELT(
N);
break;
2909 R = PromoteFloatRes_AssertNoFPClass(
N);
2927 case ISD::FSUB:
R = PromoteFloatRes_BinOp(
N);
break;
2930 case ISD::FMAD:
R = PromoteFloatRes_FMAD(
N);
break;
2939 R = PromoteFloatRes_UnaryWithTwoFPResults(
N);
2943 R = PromoteFloatRes_STRICT_FP_ROUND(
N);
2945 case ISD::LOAD:
R = PromoteFloatRes_LOAD(
N);
break;
2947 R = PromoteFloatRes_ATOMIC_LOAD(
N);
2963 R = PromoteFloatRes_VECREDUCE(
N);
2967 R = PromoteFloatRes_VECREDUCE_SEQ(
N);
2972 SetPromotedFloat(
SDValue(
N, ResNo), R);
2981 EVT VT =
N->getValueType(0);
2982 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
2986 N->getOperand(0).getValueType().getSizeInBits());
2987 SDValue Cast = DAG.getBitcast(IVT,
N->getOperand(0));
2992 EVT VT =
N->getValueType(0);
2993 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
2997 N->getOperand(0).getValueType().getSizeInBits());
2998 SDValue Cast = DAG.getBitcast(IVT,
N->getOperand(0));
3000 DAG.getFreeze(Cast));
3005 EVT VT =
N->getValueType(0);
3016 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3024SDValue DAGTypeLegalizer::PromoteFloatRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
3037 switch (getTypeAction(VecVT)) {
3040 SDValue Res = GetScalarizedVector(
N->getOperand(0));
3041 ReplaceValueWith(
SDValue(
N, 0), Res);
3045 Vec = GetWidenedVector(Vec);
3047 ReplaceValueWith(
SDValue(
N, 0), Res);
3052 GetSplitVector(Vec,
Lo,
Hi);
3054 uint64_t LoElts =
Lo.getValueType().getVectorNumElements();
3056 if (IdxVal < LoElts)
3060 DAG.getConstant(IdxVal - LoElts,
DL,
3062 ReplaceValueWith(
SDValue(
N, 0), Res);
3070 SDValue NewOp = BitConvertVectorToIntegerVector(
N->getOperand(0));
3075 NewOp,
N->getOperand(1));
3078 EVT VT =
N->getValueType(0);
3079 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3087 EVT VT =
N->getValueType(0);
3088 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3089 SDValue Op0 = GetPromotedFloat(
N->getOperand(0));
3093 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), NVT, Op0, Op1);
3100 EVT VT =
N->getValueType(0);
3101 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3102 SDValue Op = GetPromotedFloat(
N->getOperand(0));
3103 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NVT,
Op);
3109SDValue DAGTypeLegalizer::PromoteFloatRes_AssertNoFPClass(
SDNode *
N) {
3110 return GetPromotedFloat(
N->getOperand(0));
3117 EVT VT =
N->getValueType(0);
3118 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3119 SDValue Op0 = GetPromotedFloat(
N->getOperand(0));
3120 SDValue Op1 = GetPromotedFloat(
N->getOperand(1));
3121 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NVT, Op0, Op1,
N->getFlags());
3125 EVT VT =
N->getValueType(0);
3126 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3127 SDValue Op0 = GetPromotedFloat(
N->getOperand(0));
3128 SDValue Op1 = GetPromotedFloat(
N->getOperand(1));
3129 SDValue Op2 = GetPromotedFloat(
N->getOperand(2));
3131 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NVT, Op0, Op1, Op2);
3136 EVT VT =
N->getValueType(0);
3137 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3138 SDValue Op0 = GetPromotedFloat(
N->getOperand(0));
3141 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), NVT, Op0, Op1);
3145 EVT VT =
N->getValueType(0);
3146 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3147 SDValue Op = GetPromotedFloat(
N->getOperand(0));
3149 DAG.
getNode(
N->getOpcode(), SDLoc(
N), {NVT,
N->getValueType(1)},
Op);
3155SDValue DAGTypeLegalizer::PromoteFloatRes_UnaryWithTwoFPResults(
SDNode *
N) {
3156 EVT VT =
N->getValueType(0);
3157 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3158 SDValue Op = GetPromotedFloat(
N->getOperand(0));
3161 for (
unsigned ResNum = 0, NumValues =
N->getNumValues(); ResNum < NumValues;
3175 EVT VT =
N->getValueType(0);
3176 EVT OpVT =
Op->getValueType(0);
3177 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3188SDValue DAGTypeLegalizer::PromoteFloatRes_STRICT_FP_ROUND(
SDNode *
N) {
3193 EVT VT =
N->getValueType(0);
3194 EVT OpVT =
Op->getValueType(0);
3195 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3200 DAG.getVTList(IVT, MVT::Other), Chain,
Op);
3204 DAG.getVTList(NVT, MVT::Other), Round.
getValue(1), Round);
3211 EVT VT =
N->getValueType(0);
3216 L->getAddressingMode(),
L->getExtensionType(), IVT, SDLoc(
N),
3217 L->getChain(),
L->getBasePtr(),
L->getOffset(),
L->getPointerInfo(), IVT,
3218 L->getBaseAlign(),
L->getMemOperand()->getFlags(),
L->getAAInfo());
3224 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3228SDValue DAGTypeLegalizer::PromoteFloatRes_ATOMIC_LOAD(
SDNode *
N) {
3243 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3253 N->getOperand(0), TrueVal, FalseVal);
3263 TrueVal.getNode()->getValueType(0),
N->getOperand(0),
3264 N->getOperand(1), TrueVal, FalseVal,
N->getOperand(4));
3271 EVT VT =
N->getValueType(0);
3272 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3273 SDValue NV = DAG.getNode(
N->getOpcode(),
DL, NVT,
N->getOperand(0));
3278 DAG.getIntPtrConstant(0,
DL,
true)));
3282 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
3283 N->getValueType(0)));
3291 ReplaceValueWith(
SDValue(
N, 0), TLI.expandVecReduce(
N, DAG));
3295SDValue DAGTypeLegalizer::PromoteFloatRes_VECREDUCE_SEQ(
SDNode *
N) {
3296 ReplaceValueWith(
SDValue(
N, 0), TLI.expandVecReduceSeq(
N, DAG));
3301 EVT VT =
N->getValueType(0);
3311 DAG.getVTList(CastVT, MVT::Other),
3312 { AM->getChain(), AM->getBasePtr(), CastVal },
3318 EVT NFPVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3335void DAGTypeLegalizer::SoftPromoteHalfResult(
SDNode *
N,
unsigned ResNo) {
3336 LLVM_DEBUG(
dbgs() <<
"Soft promote half result " << ResNo <<
": ";
3341 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true)) {
3346 switch (
N->getOpcode()) {
3349 dbgs() <<
"SoftPromoteHalfResult #" << ResNo <<
": ";
3350 N->dump(&DAG);
dbgs() <<
"\n";
3356 R = SoftPromoteHalfRes_ARITH_FENCE(
N);
break;
3360 R = SoftPromoteHalfRes_EXTRACT_VECTOR_ELT(
N);
break;
3393 R = SoftPromoteHalfRes_FABS(
N);
3396 R = SoftPromoteHalfRes_FNEG(
N);
3399 R = SoftPromoteHalfRes_AssertNoFPClass(
N);
3415 case ISD::FSUB:
R = SoftPromoteHalfRes_BinOp(
N);
break;
3418 case ISD::FMAD:
R = SoftPromoteHalfRes_FMAD(
N);
break;
3428 R = SoftPromoteHalfRes_UnaryWithTwoFPResults(
N);
3431 case ISD::LOAD:
R = SoftPromoteHalfRes_LOAD(
N);
break;
3433 R = SoftPromoteHalfRes_ATOMIC_LOAD(
N);
3442 case ISD::UNDEF:
R = SoftPromoteHalfRes_UNDEF(
N);
break;
3450 R = SoftPromoteHalfRes_VECREDUCE(
N);
3454 R = SoftPromoteHalfRes_VECREDUCE_SEQ(
N);
3459 SetSoftPromotedHalf(
SDValue(
N, ResNo), R);
3462SDValue DAGTypeLegalizer::SoftPromoteHalfRes_ARITH_FENCE(
SDNode *
N) {
3464 BitConvertToInteger(
N->getOperand(0)));
3468 return BitConvertToInteger(
N->getOperand(0));
3471SDValue DAGTypeLegalizer::SoftPromoteHalfRes_ConstantFP(
SDNode *
N) {
3479SDValue DAGTypeLegalizer::SoftPromoteHalfRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
3480 SDValue NewOp = BitConvertVectorToIntegerVector(
N->getOperand(0));
3486SDValue DAGTypeLegalizer::SoftPromoteHalfRes_FCOPYSIGN(
SDNode *
N) {
3487 SDValue LHS = GetSoftPromotedHalf(
N->getOperand(0));
3488 SDValue RHS = BitConvertToInteger(
N->getOperand(1));
3491 EVT LVT =
LHS.getValueType();
3492 EVT RVT =
RHS.getValueType();
3499 ISD::SHL, dl, RVT, DAG.getConstant(1, dl, RVT),
3500 DAG.getConstant(RSize - 1, dl,
3501 TLI.getShiftAmountTy(RVT, DAG.getDataLayout())));
3509 DAG.getConstant(SizeDiff, dl,
3511 DAG.getDataLayout())));
3513 }
else if (SizeDiff < 0) {
3517 DAG.getConstant(-SizeDiff, dl,
3519 DAG.getDataLayout())));
3524 ISD::SHL, dl, LVT, DAG.getConstant(1, dl, LVT),
3525 DAG.getConstant(LSize - 1, dl,
3526 TLI.getShiftAmountTy(LVT, DAG.getDataLayout())));
3527 Mask = DAG.getNode(
ISD::SUB, dl, LVT, Mask, DAG.getConstant(1, dl, LVT));
3531 return DAG.getNode(
ISD::OR, dl, LVT,
LHS, SignBit);
3536 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
3537 SDValue Op0 = GetSoftPromotedHalf(
N->getOperand(0));
3538 SDValue Op1 = GetSoftPromotedHalf(
N->getOperand(1));
3539 SDValue Op2 = GetSoftPromotedHalf(
N->getOperand(2));
3540 SDNodeFlags
Flags =
N->getFlags();
3545 Op0 = DAG.
getNode(PromotionOpcode, dl, NVT, Op0);
3546 Op1 = DAG.
getNode(PromotionOpcode, dl, NVT, Op1);
3547 Op2 = DAG.
getNode(PromotionOpcode, dl, NVT, Op2);
3550 if (OVT == MVT::f16) {
3559 if (TLI.isFMAFasterThanFMulAndFAdd(DAG.getMachineFunction(), MVT::f64)) {
3570 Res = DAG.
getNode(
N->getOpcode(), dl, NVT, Op0, Op1, Op2, Flags);
3575 EVT OVT =
N->getValueType(0);
3576 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
3577 SDValue Op0 = GetSoftPromotedHalf(
N->getOperand(0));
3591 EVT OVT =
N->getValueType(0);
3592 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
3593 SDValue Op = GetSoftPromotedHalf(
N->getOperand(0));
3600 DAG.getVTList(NVT,
N->getValueType(1)),
Op);
3608SDValue DAGTypeLegalizer::SoftPromoteHalfRes_UnaryWithTwoFPResults(
SDNode *
N) {
3609 EVT OVT =
N->getValueType(0);
3610 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
3611 SDValue Op = GetSoftPromotedHalf(
N->getOperand(0));
3620 for (
unsigned ResNum = 0, NumValues =
N->getNumValues(); ResNum < NumValues;
3622 SDValue Trunc = DAG.getNode(Truncate, dl, MVT::i16, Res.
getValue(ResNum));
3623 SetSoftPromotedHalf(
SDValue(
N, ResNum), Trunc);
3629SDValue DAGTypeLegalizer::SoftPromoteHalfRes_FP_ROUND(
SDNode *
N) {
3630 EVT RVT =
N->getValueType(0);
3631 bool IsStrict =
N->isStrictFPOpcode();
3632 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
3633 EVT SVT =
Op.getValueType();
3639 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported FP_ROUND libcall");
3642 Op = GetSoftenedFloat(
Op);
3643 TargetLowering::MakeLibCallOptions CallOptions;
3645 std::pair<SDValue, SDValue> Tmp =
3646 TLI.makeLibCall(DAG, LC, RVT,
Op, CallOptions, SDLoc(
N), Chain);
3648 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3649 return DAG.getNode(
ISD::BITCAST, SDLoc(
N), MVT::i16, Tmp.first);
3654 {MVT::i16, MVT::Other}, {
N->getOperand(0),
Op});
3669 DAG.getLoad(
L->getAddressingMode(),
L->getExtensionType(), MVT::i16,
3670 SDLoc(
N),
L->getChain(),
L->getBasePtr(),
L->getOffset(),
3671 L->getPointerInfo(), MVT::i16,
L->getBaseAlign(),
3672 L->getMemOperand()->getFlags(),
L->getAAInfo());
3679SDValue DAGTypeLegalizer::SoftPromoteHalfRes_ATOMIC_LOAD(
SDNode *
N) {
3694 SDValue Op1 = GetSoftPromotedHalf(
N->getOperand(1));
3695 SDValue Op2 = GetSoftPromotedHalf(
N->getOperand(2));
3696 return DAG.getSelect(SDLoc(
N), Op1.
getValueType(),
N->getOperand(0), Op1,
3700SDValue DAGTypeLegalizer::SoftPromoteHalfRes_SELECT_CC(
SDNode *
N) {
3701 SDValue Op2 = GetSoftPromotedHalf(
N->getOperand(2));
3702 SDValue Op3 = GetSoftPromotedHalf(
N->getOperand(3));
3704 N->getOperand(0),
N->getOperand(1), Op2, Op3,
3708SDValue DAGTypeLegalizer::SoftPromoteHalfRes_XINT_TO_FP(
SDNode *
N) {
3709 EVT OVT =
N->getValueType(0);
3710 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
3713 if (
N->isStrictFPOpcode()) {
3714 SDValue Op = DAG.getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
3715 {N->getOperand(0), N->getOperand(1)});
3717 {MVT::i16, MVT::Other}, {
Op.getValue(1),
Op});
3718 ReplaceValueWith(
SDValue(
N, 1),
Op.getValue(1));
3729 return DAG.getUNDEF(MVT::i16);
3733 EVT OVT =
N->getValueType(0);
3734 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
3735 SDValue Op = GetSoftPromotedHalf(
N->getOperand(0));
3748 SDValue Op = GetSoftPromotedHalf(
N->getOperand(0));
3752 return DAG.getNode(
ISD::AND, dl, MVT::i16,
Op,
3753 DAG.getConstant(0x7fff, dl, MVT::i16));
3757 SDValue Op = GetSoftPromotedHalf(
N->getOperand(0));
3761 return DAG.getNode(
ISD::XOR, dl, MVT::i16,
Op,
3762 DAG.getConstant(0x8000, dl, MVT::i16));
3765SDValue DAGTypeLegalizer::SoftPromoteHalfRes_AssertNoFPClass(
SDNode *
N) {
3766 return GetSoftPromotedHalf(
N->getOperand(0));
3770 EVT OVT =
N->getValueType(0);
3771 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
3772 SDValue Op0 = GetSoftPromotedHalf(
N->getOperand(0));
3773 SDValue Op1 = GetSoftPromotedHalf(
N->getOperand(1));
3778 Op0 = DAG.
getNode(PromotionOpcode, dl, NVT, Op0);
3779 Op1 = DAG.
getNode(PromotionOpcode, dl, NVT, Op1);
3787SDValue DAGTypeLegalizer::SoftPromoteHalfRes_VECREDUCE(
SDNode *
N) {
3789 ReplaceValueWith(
SDValue(
N, 0), TLI.expandVecReduce(
N, DAG));
3793SDValue DAGTypeLegalizer::SoftPromoteHalfRes_VECREDUCE_SEQ(
SDNode *
N) {
3795 ReplaceValueWith(
SDValue(
N, 0), TLI.expandVecReduceSeq(
N, DAG));
3803bool DAGTypeLegalizer::SoftPromoteHalfOperand(
SDNode *
N,
unsigned OpNo) {
3804 LLVM_DEBUG(
dbgs() <<
"Soft promote half operand " << OpNo <<
": ";
3808 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
3818 switch (
N->getOpcode()) {
3821 dbgs() <<
"SoftPromoteHalfOperand Op #" << OpNo <<
": ";
3822 N->dump(&DAG);
dbgs() <<
"\n";
3827 case ISD::BITCAST: Res = SoftPromoteHalfOp_BITCAST(
N);
break;
3829 Res = SoftPromoteHalfOp_FAKE_USE(
N, OpNo);
3831 case ISD::FCOPYSIGN: Res = SoftPromoteHalfOp_FCOPYSIGN(
N, OpNo);
break;
3840 Res = SoftPromoteHalfOp_Op0WithStrict(
N);
3844 Res = SoftPromoteHalfOp_FP_TO_XINT_SAT(
N);
break;
3847 case ISD::SELECT_CC: Res = SoftPromoteHalfOp_SELECT_CC(
N, OpNo);
break;
3848 case ISD::SETCC: Res = SoftPromoteHalfOp_SETCC(
N);
break;
3849 case ISD::STORE: Res = SoftPromoteHalfOp_STORE(
N, OpNo);
break;
3851 Res = SoftPromoteHalfOp_ATOMIC_STORE(
N, OpNo);
3854 Res = SoftPromoteHalfOp_STACKMAP(
N, OpNo);
3857 Res = SoftPromoteHalfOp_PATCHPOINT(
N, OpNo);
3867 "Invalid operand expansion");
3869 ReplaceValueWith(
SDValue(
N, 0), Res);
3874 SDValue Op0 = GetSoftPromotedHalf(
N->getOperand(0));
3876 return DAG.getNode(
ISD::BITCAST, SDLoc(
N),
N->getValueType(0), Op0);
3879SDValue DAGTypeLegalizer::SoftPromoteHalfOp_FAKE_USE(
SDNode *
N,
unsigned OpNo) {
3880 assert(OpNo == 1 &&
"Only Operand 1 must need promotion here");
3881 SDValue Op = GetSoftPromotedHalf(
N->getOperand(OpNo));
3882 return DAG.getNode(
N->getOpcode(), SDLoc(
N), MVT::Other,
N->getOperand(0),
3888 assert(OpNo == 1 &&
"Only Operand 1 must need promotion here");
3893 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), Op1.
getValueType());
3895 Op1 = GetSoftPromotedHalf(Op1);
3898 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0),
N->getOperand(0),
3902SDValue DAGTypeLegalizer::SoftPromoteHalfOp_FP_EXTEND(
SDNode *
N) {
3903 EVT RVT =
N->getValueType(0);
3904 bool IsStrict =
N->isStrictFPOpcode();
3905 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
3906 EVT SVT =
Op.getValueType();
3907 Op = GetSoftPromotedHalf(
N->getOperand(IsStrict ? 1 : 0));
3911 {RVT, MVT::Other}, {
N->getOperand(0),
Op});
3913 ReplaceValueWith(
SDValue(
N, 0), Res);
3920SDValue DAGTypeLegalizer::SoftPromoteHalfOp_Op0WithStrict(
SDNode *
N) {
3921 EVT RVT =
N->getValueType(0);
3922 bool IsStrict =
N->isStrictFPOpcode();
3923 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
3924 EVT SVT =
Op.getValueType();
3927 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), SVT);
3928 Op = GetSoftPromotedHalf(
Op);
3932 {
N->getOperand(0),
Op});
3933 Op = DAG.getNode(
N->getOpcode(), dl, {RVT, MVT::Other},
3934 {Op.getValue(1), Op});
3935 ReplaceValueWith(
SDValue(
N, 1),
Op.getValue(1));
3941 return DAG.getNode(
N->getOpcode(), dl, RVT, Res);
3944SDValue DAGTypeLegalizer::SoftPromoteHalfOp_FP_TO_XINT_SAT(
SDNode *
N) {
3945 EVT RVT =
N->getValueType(0);
3947 EVT SVT =
Op.getValueType();
3950 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
Op.getValueType());
3952 Op = GetSoftPromotedHalf(
Op);
3956 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), Res,
3962 assert(OpNo == 0 &&
"Can only soften the comparison values");
3968 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), SVT);
3970 Op0 = GetSoftPromotedHalf(Op0);
3971 Op1 = GetSoftPromotedHalf(Op1);
3975 Op0 = DAG.
getNode(PromotionOpcode, dl, NVT, Op0);
3976 Op1 = DAG.
getNode(PromotionOpcode, dl, NVT, Op1);
3979 N->getOperand(2),
N->getOperand(3),
N->getOperand(4));
3989 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), Op0.
getValueType());
3991 Op0 = GetSoftPromotedHalf(Op0);
3992 Op1 = GetSoftPromotedHalf(Op1);
3996 Op0 = DAG.
getNode(PromotionOpcode, dl, NVT, Op0);
3997 Op1 = DAG.
getNode(PromotionOpcode, dl, NVT, Op1);
3999 return DAG.getSetCC(SDLoc(
N),
N->getValueType(0), Op0, Op1, CCCode);
4002SDValue DAGTypeLegalizer::SoftPromoteHalfOp_STORE(
SDNode *
N,
unsigned OpNo) {
4003 assert(OpNo == 1 &&
"Can only soften the stored value!");
4008 assert(!
ST->isTruncatingStore() &&
"Unexpected truncating store.");
4009 SDValue Promoted = GetSoftPromotedHalf(Val);
4010 return DAG.getStore(
ST->getChain(), dl, Promoted,
ST->getBasePtr(),
4011 ST->getMemOperand());
4014SDValue DAGTypeLegalizer::SoftPromoteHalfOp_ATOMIC_STORE(
SDNode *
N,
4016 assert(OpNo == 1 &&
"Can only soften the stored value!");
4021 SDValue Promoted = GetSoftPromotedHalf(Val);
4023 ST->getChain(), Promoted,
ST->getBasePtr(),
4024 ST->getMemOperand());
4027SDValue DAGTypeLegalizer::SoftPromoteHalfOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
4031 NewOps[OpNo] = GetSoftPromotedHalf(
Op);
4033 DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getVTList(), NewOps);
4035 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
4046 NewOps[OpNo] = GetSoftPromotedHalf(
Op);
4048 DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getVTList(), NewOps);
4050 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static RTLIB::Libcall findFPToIntLibcall(EVT SrcVT, EVT RetVT, EVT &Promoted, bool Signed)
static RTLIB::Libcall GetFPLibCall(EVT VT, RTLIB::Libcall Call_F32, RTLIB::Libcall Call_F64, RTLIB::Libcall Call_F80, RTLIB::Libcall Call_F128, RTLIB::Libcall Call_PPCF128)
GetFPLibCall - Return the right libcall for the given floating point type.
static ISD::NodeType GetPromotionOpcode(EVT OpVT, EVT RetVT)
static ISD::NodeType GetPromotionOpcodeStrict(EVT OpVT, EVT RetVT)
static Type * getValueType(Value *V)
Returns the type of the given value/instruction V.
static const fltSemantics & PPCDoubleDouble()
APInt bitcastToAPInt() const
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
void clearBit(unsigned BitPosition)
Set a given bit to 0.
static APInt getSignMask(unsigned BitWidth)
Get the SignMask for a specific bit width.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
const SDValue & getVal() const
const APFloat & getValueAPF() const
@ NewNode
This is a new node, not before seen, that was created in the process of legalizing some other node.
@ MODereferenceable
The memory access is dereferenceable (i.e., doesn't trap).
@ MOInvariant
The memory access always returns the same value (or traps).
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
SDNodeFlags getFlags() const
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
const SDValue & getOperand(unsigned Num) const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
void push_back(const T &Elt)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ C
The default llvm calling convention, compatible with C.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ MERGE_VALUES
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
@ POISON
POISON - A poison node.
@ VECREDUCE_SEQ_FADD
Generic reduction nodes.
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, val, ptr) This corresponds to "store atomic" instruction.
@ FMAD
FMAD - Perform a * b + c, while getting the same result as the separately rounded operations.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ FMA
FMA - Perform a * b + c with no intermediate rounding step.
@ FMODF
FMODF - Decomposes the operand into integral and fractional parts, each having the same type and sign...
@ FATAN2
FATAN2 - atan2, inspired by libm.
@ FSINCOSPI
FSINCOSPI - Compute both the sine and cosine times pi more accurately than FSINCOS(pi*x),...
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ VECREDUCE_FMAX
FMIN/FMAX nodes can have flags, for NaN/NoNaN variants.
@ FADD
Simple binary floating point operators.
@ VECREDUCE_FMAXIMUM
FMINIMUM/FMAXIMUM nodes propatate NaNs and signed zeroes using the llvm.minimum and llvm....
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ FAKE_USE
FAKE_USE represents a use of the operand but does not do anything.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ STRICT_FSQRT
Constrained versions of libm-equivalent floating point intrinsics.
@ SIGN_EXTEND
Conversion operators.
@ VECREDUCE_FADD
These reductions have relaxed evaluation order semantics, and have a single vector operand.
@ FSINCOS
FSINCOS - Compute both fsin and fcos as a single operation.
@ FNEG
Perform various unary floating-point operations inspired by libm.
@ BR_CC
BR_CC - Conditional branch.
@ FCANONICALIZE
Returns platform specific canonical encoding of a floating point number.
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ ATOMIC_LOAD
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
@ UNDEF
UNDEF - An undefined node.
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ ARITH_FENCE
ARITH_FENCE - This corresponds to a arithmetic fence intrinsic.
@ SHL
Shift and rotation operations.
@ AssertNoFPClass
AssertNoFPClass - These nodes record if a register contains a float value that is known to be not som...
@ FMINNUM_IEEE
FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimumNumber or maximumNumber on two values,...
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ FMINNUM
FMINNUM/FMAXNUM - Perform floating-point minimum maximum on two values, following IEEE-754 definition...
@ PATCHPOINT
The llvm.experimental.patchpoint.
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ STRICT_SINT_TO_FP
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
@ BF16_TO_FP
BF16_TO_FP, FP_TO_BF16 - These operators are used to perform promotions and truncation for bfloat16.
@ STRICT_FP_ROUND
X = STRICT_FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision ...
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FMINIMUM
FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0 as less than 0....
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ STRICT_FP_EXTEND
X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ STRICT_FADD
Constrained versions of the binary floating point operators.
@ STACKMAP
The llvm.experimental.stackmap intrinsic.
@ FREEZE
FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or is evaluated to UNDEF),...
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
@ FFREXP
FFREXP - frexp, extract fractional and exponent component of a floating-point value.
@ FP_ROUND
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
@ FP_TO_SINT_SAT
FP_TO_[US]INT_SAT - Convert floating point value in operand 0 to a signed or unsigned scalar integer ...
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ VAARG
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
@ FCOPYSIGN
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
@ FMINIMUMNUM
FMINIMUMNUM/FMAXIMUMNUM - minimumnum/maximumnum that is same with FMINNUM_IEEE and FMAXNUM_IEEE besid...
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
bool isUNINDEXEDLoad(const SDNode *N)
Returns true if the specified node is an unindexed load.
bool isUNINDEXEDStore(const SDNode *N)
Returns true if the specified node is an unindexed store.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
LLVM_ABI Libcall getPOWI(EVT RetVT)
getPOWI - Return the POWI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getLDEXP(EVT RetVT)
getLDEXP - Return the LDEXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFREXP(EVT RetVT)
getFREXP - Return the FREXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINCOSPI(EVT RetVT)
getSINCOSPI - Return the SINCOSPI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getCOS(EVT RetVT)
Return the COS_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getMODF(EVT VT)
getMODF - Return the MODF_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPEXT(EVT OpVT, EVT RetVT)
getFPEXT - Return the FPEXT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPROUND(EVT OpVT, EVT RetVT)
getFPROUND - Return the FPROUND_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSIN(EVT RetVT)
Return the SIN_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getPOW(EVT RetVT)
getPOW - Return the POW_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINCOS(EVT RetVT)
getSINCOS - Return the SINCOS_* value for the given types, or UNKNOWN_LIBCALL if there is none.
DiagnosticInfoOptimizationBase::Argument NV
This is an optimization pass for GlobalISel generic memory operations.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Mul
Product of integers.
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
LLVM_ABI const fltSemantics & getFltSemantics() const
Returns an APFloat semantics tag appropriate for the value type.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
void setNoFPExcept(bool b)
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT)
MakeLibCallOptions & setIsSigned(bool Value=true)