27 #define DEBUG_TYPE "legalize-types" 42 RTLIB::UNKNOWN_LIBCALL;
49 bool DAGTypeLegalizer::SoftenFloatResult(
SDNode *
N,
unsigned ResNo) {
57 dbgs() <<
"SoftenFloatResult #" << ResNo <<
": ";
66 "Unsupported SoftenFloatRes opcode!");
71 case ISD::BITCAST: R = SoftenFloatRes_BITCAST(N, ResNo);
break;
75 R = SoftenFloatRes_EXTRACT_VECTOR_ELT(N, ResNo);
break;
76 case ISD::FABS: R = SoftenFloatRes_FABS(N, ResNo);
break;
79 case ISD::FADD: R = SoftenFloatRes_FADD(N);
break;
80 case ISD::FCEIL: R = SoftenFloatRes_FCEIL(N);
break;
81 case ISD::FCOPYSIGN: R = SoftenFloatRes_FCOPYSIGN(N, ResNo);
break;
82 case ISD::FCOS: R = SoftenFloatRes_FCOS(N);
break;
83 case ISD::FDIV: R = SoftenFloatRes_FDIV(N);
break;
84 case ISD::FEXP: R = SoftenFloatRes_FEXP(N);
break;
85 case ISD::FEXP2: R = SoftenFloatRes_FEXP2(N);
break;
86 case ISD::FFLOOR: R = SoftenFloatRes_FFLOOR(N);
break;
87 case ISD::FLOG: R = SoftenFloatRes_FLOG(N);
break;
88 case ISD::FLOG2: R = SoftenFloatRes_FLOG2(N);
break;
89 case ISD::FLOG10: R = SoftenFloatRes_FLOG10(N);
break;
90 case ISD::FMA: R = SoftenFloatRes_FMA(N);
break;
91 case ISD::FMUL: R = SoftenFloatRes_FMUL(N);
break;
93 case ISD::FNEG: R = SoftenFloatRes_FNEG(N, ResNo);
break;
97 case ISD::FPOW: R = SoftenFloatRes_FPOW(N);
break;
98 case ISD::FPOWI: R = SoftenFloatRes_FPOWI(N);
break;
99 case ISD::FREM: R = SoftenFloatRes_FREM(N);
break;
100 case ISD::FRINT: R = SoftenFloatRes_FRINT(N);
break;
101 case ISD::FROUND: R = SoftenFloatRes_FROUND(N);
break;
102 case ISD::FSIN: R = SoftenFloatRes_FSIN(N);
break;
103 case ISD::FSQRT: R = SoftenFloatRes_FSQRT(N);
break;
104 case ISD::FSUB: R = SoftenFloatRes_FSUB(N);
break;
105 case ISD::FTRUNC: R = SoftenFloatRes_FTRUNC(N);
break;
106 case ISD::LOAD: R = SoftenFloatRes_LOAD(N, ResNo);
break;
107 case ISD::SELECT: R = SoftenFloatRes_SELECT(N, ResNo);
break;
108 case ISD::SELECT_CC: R = SoftenFloatRes_SELECT_CC(N, ResNo);
break;
111 case ISD::UNDEF: R = SoftenFloatRes_UNDEF(N);
break;
112 case ISD::VAARG: R = SoftenFloatRes_VAARG(N);
break;
115 if (R.getNode() && R.getNode() !=
N) {
116 SetSoftenedFloat(
SDValue(N, ResNo), R);
126 SDValue DAGTypeLegalizer::SoftenFloatRes_BITCAST(
SDNode *N,
unsigned ResNo) {
132 SDValue DAGTypeLegalizer::SoftenFloatRes_MERGE_VALUES(
SDNode *N,
134 SDValue Op = DisintegrateMERGE_VALUES(N, ResNo);
135 return BitConvertToInteger(Op);
138 SDValue DAGTypeLegalizer::SoftenFloatRes_BUILD_PAIR(
SDNode *N) {
147 SDValue DAGTypeLegalizer::SoftenFloatRes_ConstantFP(
SDNode *N,
unsigned ResNo) {
163 APInt Val(128, words);
174 SDValue DAGTypeLegalizer::SoftenFloatRes_EXTRACT_VECTOR_ELT(
SDNode *N,
unsigned ResNo) {
184 SDValue DAGTypeLegalizer::SoftenFloatRes_FABS(
SDNode *N,
unsigned ResNo) {
199 SDValue DAGTypeLegalizer::SoftenFloatRes_FMINNUM(
SDNode *N) {
208 RTLIB::FMIN_PPCF128),
212 SDValue DAGTypeLegalizer::SoftenFloatRes_FMAXNUM(
SDNode *N) {
221 RTLIB::FMAX_PPCF128),
246 RTLIB::CEIL_PPCF128),
250 SDValue DAGTypeLegalizer::SoftenFloatRes_FCOPYSIGN(
SDNode *N,
unsigned ResNo) {
259 EVT RVT = RHS.getValueType();
280 }
else if (SizeDiff < 0) {
346 RTLIB::EXP2_PPCF128),
358 RTLIB::FLOOR_PPCF128),
382 RTLIB::LOG2_PPCF128),
394 RTLIB::LOG10_PPCF128),
425 SDValue DAGTypeLegalizer::SoftenFloatRes_FNEARBYINT(
SDNode *N) {
429 RTLIB::NEARBYINT_F32,
430 RTLIB::NEARBYINT_F64,
431 RTLIB::NEARBYINT_F80,
432 RTLIB::NEARBYINT_F128,
433 RTLIB::NEARBYINT_PPCF128),
437 SDValue DAGTypeLegalizer::SoftenFloatRes_FNEG(
SDNode *N,
unsigned ResNo) {
452 NVT, Ops,
false, dl).first;
455 SDValue DAGTypeLegalizer::SoftenFloatRes_FP_EXTEND(
SDNode *N) {
469 Op = GetPromotedFloat(Op);
473 return BitConvertToInteger(Op);
478 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported FP_EXTEND!");
484 SDValue DAGTypeLegalizer::SoftenFloatRes_FP16_TO_FP(
SDNode *N) {
488 false,
SDLoc(N)).first;
494 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported FP_EXTEND!");
498 SDValue DAGTypeLegalizer::SoftenFloatRes_FP_ROUND(
SDNode *N) {
508 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported FP_ROUND!");
527 "Unsupported power type!");
535 RTLIB::POWI_PPCF128),
560 RTLIB::RINT_PPCF128),
572 RTLIB::ROUND_PPCF128),
596 RTLIB::SQRT_PPCF128),
624 RTLIB::TRUNC_PPCF128),
628 SDValue DAGTypeLegalizer::SoftenFloatRes_LOAD(
SDNode *N,
unsigned ResNo) {
629 bool LegalInHWReg = isLegalInHWReg(N->
getValueType(ResNo));
636 L->getMemOperand()->getFlags() &
640 NewL = DAG.
getLoad(L->getAddressingMode(), L->getExtensionType(), NVT, dl,
641 L->getChain(), L->getBasePtr(), L->getOffset(),
642 L->getPointerInfo(), NVT, L->getAlignment(), MMOFlags,
653 dl, L->getChain(), L->getBasePtr(), L->getOffset(),
654 L->getPointerInfo(), L->getMemoryVT(), L->getAlignment(),
655 MMOFlags, L->getAAInfo());
662 return BitConvertToInteger(ExtendNode);
665 SDValue DAGTypeLegalizer::SoftenFloatRes_SELECT(
SDNode *N,
unsigned ResNo) {
674 SDValue DAGTypeLegalizer::SoftenFloatRes_SELECT_CC(
SDNode *N,
unsigned ResNo) {
707 SDValue DAGTypeLegalizer::SoftenFloatRes_XINT_TO_FP(
SDNode *N) {
725 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported XINT_TO_FP!");
732 Op, Signed, dl).first;
740 bool DAGTypeLegalizer::SoftenFloatOperand(
SDNode *N,
unsigned OpNo) {
747 if (CanSkipSoftenFloatOperand(N, OpNo))
750 dbgs() <<
"SoftenFloatOperand Op #" << OpNo <<
": ";
755 case ISD::BITCAST: Res = SoftenFloatOp_BITCAST(N);
break;
757 case ISD::BR_CC: Res = SoftenFloatOp_BR_CC(N);
break;
758 case ISD::FABS: Res = SoftenFloatOp_FABS(N);
break;
760 case ISD::FNEG: Res = SoftenFloatOp_FNEG(N);
break;
766 case ISD::SELECT: Res = SoftenFloatOp_SELECT(N);
break;
768 case ISD::SETCC: Res = SoftenFloatOp_SETCC(N);
break;
770 Res = SoftenFloatOp_STORE(N, OpNo);
774 if (Res.getNode() == N &&
782 if (!Res.getNode())
return false;
786 if (Res.getNode() ==
N)
790 "Invalid operand expansion");
792 ReplaceValueWith(
SDValue(N, 0), Res);
796 bool DAGTypeLegalizer::CanSkipSoftenFloatOperand(
SDNode *N,
unsigned OpNo) {
831 SDValue DAGTypeLegalizer::SoftenFloatOp_COPY_TO_REG(
SDNode *N) {
846 SDValue DAGTypeLegalizer::SoftenFloatOp_FP_EXTEND(
SDNode *N) {
856 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported FP_EXTEND libcall");
862 SDValue DAGTypeLegalizer::SoftenFloatOp_FP_ROUND(
SDNode *N) {
872 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported FP_ROUND libcall");
883 NewLHS = GetSoftenedFloat(NewLHS);
884 NewRHS = GetSoftenedFloat(NewRHS);
889 if (!NewRHS.getNode()) {
910 SDValue DAGTypeLegalizer::SoftenFloatOp_FCOPYSIGN(
SDNode *N) {
929 SDValue DAGTypeLegalizer::SoftenFloatOp_FP_TO_XINT(
SDNode *N) {
949 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported FP_TO_XINT!");
969 SDValue DAGTypeLegalizer::SoftenFloatOp_SELECT_CC(
SDNode *N) {
974 NewLHS = GetSoftenedFloat(NewLHS);
975 NewRHS = GetSoftenedFloat(NewRHS);
980 if (!NewRHS.getNode()) {
997 NewLHS = GetSoftenedFloat(NewLHS);
998 NewRHS = GetSoftenedFloat(NewRHS);
1002 if (!NewRHS.getNode()) {
1004 "Unexpected setcc expansion!");
1014 SDValue DAGTypeLegalizer::SoftenFloatOp_STORE(
SDNode *N,
unsigned OpNo) {
1016 assert(OpNo == 1 &&
"Can only soften the stored value!");
1026 Val = GetSoftenedFloat(Val);
1041 void DAGTypeLegalizer::ExpandFloatResult(
SDNode *N,
unsigned ResNo) {
1053 dbgs() <<
"ExpandFloatResult #" << ResNo <<
": ";
1056 llvm_unreachable(
"Do not know how to expand the result of this operator!");
1058 case ISD::UNDEF: SplitRes_UNDEF(N, Lo, Hi);
break;
1059 case ISD::SELECT: SplitRes_SELECT(N, Lo, Hi);
break;
1063 case ISD::BITCAST: ExpandRes_BITCAST(N, Lo, Hi);
break;
1067 case ISD::VAARG: ExpandRes_VAARG(N, Lo, Hi);
break;
1070 case ISD::FABS: ExpandFloatRes_FABS(N, Lo, Hi);
break;
1071 case ISD::FMINNUM: ExpandFloatRes_FMINNUM(N, Lo, Hi);
break;
1072 case ISD::FMAXNUM: ExpandFloatRes_FMAXNUM(N, Lo, Hi);
break;
1073 case ISD::FADD: ExpandFloatRes_FADD(N, Lo, Hi);
break;
1074 case ISD::FCEIL: ExpandFloatRes_FCEIL(N, Lo, Hi);
break;
1076 case ISD::FCOS: ExpandFloatRes_FCOS(N, Lo, Hi);
break;
1077 case ISD::FDIV: ExpandFloatRes_FDIV(N, Lo, Hi);
break;
1078 case ISD::FEXP: ExpandFloatRes_FEXP(N, Lo, Hi);
break;
1079 case ISD::FEXP2: ExpandFloatRes_FEXP2(N, Lo, Hi);
break;
1080 case ISD::FFLOOR: ExpandFloatRes_FFLOOR(N, Lo, Hi);
break;
1081 case ISD::FLOG: ExpandFloatRes_FLOG(N, Lo, Hi);
break;
1082 case ISD::FLOG2: ExpandFloatRes_FLOG2(N, Lo, Hi);
break;
1083 case ISD::FLOG10: ExpandFloatRes_FLOG10(N, Lo, Hi);
break;
1084 case ISD::FMA: ExpandFloatRes_FMA(N, Lo, Hi);
break;
1085 case ISD::FMUL: ExpandFloatRes_FMUL(N, Lo, Hi);
break;
1087 case ISD::FNEG: ExpandFloatRes_FNEG(N, Lo, Hi);
break;
1089 case ISD::FPOW: ExpandFloatRes_FPOW(N, Lo, Hi);
break;
1090 case ISD::FPOWI: ExpandFloatRes_FPOWI(N, Lo, Hi);
break;
1091 case ISD::FRINT: ExpandFloatRes_FRINT(N, Lo, Hi);
break;
1092 case ISD::FROUND: ExpandFloatRes_FROUND(N, Lo, Hi);
break;
1093 case ISD::FSIN: ExpandFloatRes_FSIN(N, Lo, Hi);
break;
1094 case ISD::FSQRT: ExpandFloatRes_FSQRT(N, Lo, Hi);
break;
1095 case ISD::FSUB: ExpandFloatRes_FSUB(N, Lo, Hi);
break;
1096 case ISD::FTRUNC: ExpandFloatRes_FTRUNC(N, Lo, Hi);
break;
1097 case ISD::LOAD: ExpandFloatRes_LOAD(N, Lo, Hi);
break;
1100 case ISD::FREM: ExpandFloatRes_FREM(N, Lo, Hi);
break;
1108 void DAGTypeLegalizer::ExpandFloatRes_ConstantFP(
SDNode *N,
SDValue &
Lo,
1112 "Do not know how to expand this float constant!");
1113 APInt C = cast<ConstantFPSDNode>(
N)->getValueAPF().bitcastToAPInt();
1116 APInt(64, C.getRawData()[1])),
1119 APInt(64, C.getRawData()[0])),
1123 void DAGTypeLegalizer::ExpandFloatRes_FABS(
SDNode *N,
SDValue &Lo,
1126 "Logic only correct for ppcf128!");
1137 void DAGTypeLegalizer::ExpandFloatRes_FMINNUM(
SDNode *N,
SDValue &Lo,
1140 RTLIB::FMIN_F32, RTLIB::FMIN_F64,
1141 RTLIB::FMIN_F80, RTLIB::FMIN_F128,
1142 RTLIB::FMIN_PPCF128),
1144 GetPairElements(Call, Lo, Hi);
1147 void DAGTypeLegalizer::ExpandFloatRes_FMAXNUM(
SDNode *N,
SDValue &Lo,
1150 RTLIB::FMAX_F32, RTLIB::FMAX_F64,
1151 RTLIB::FMAX_F80, RTLIB::FMAX_F128,
1152 RTLIB::FMAX_PPCF128),
1154 GetPairElements(Call, Lo, Hi);
1157 void DAGTypeLegalizer::ExpandFloatRes_FADD(
SDNode *N,
SDValue &Lo,
1160 RTLIB::ADD_F32, RTLIB::ADD_F64,
1161 RTLIB::ADD_F80, RTLIB::ADD_F128,
1162 RTLIB::ADD_PPCF128),
1164 GetPairElements(Call, Lo, Hi);
1167 void DAGTypeLegalizer::ExpandFloatRes_FCEIL(
SDNode *N,
1170 RTLIB::CEIL_F32, RTLIB::CEIL_F64,
1171 RTLIB::CEIL_F80, RTLIB::CEIL_F128,
1172 RTLIB::CEIL_PPCF128),
1174 GetPairElements(Call, Lo, Hi);
1177 void DAGTypeLegalizer::ExpandFloatRes_FCOPYSIGN(
SDNode *N,
1180 RTLIB::COPYSIGN_F32,
1181 RTLIB::COPYSIGN_F64,
1182 RTLIB::COPYSIGN_F80,
1183 RTLIB::COPYSIGN_F128,
1184 RTLIB::COPYSIGN_PPCF128),
1186 GetPairElements(Call, Lo, Hi);
1189 void DAGTypeLegalizer::ExpandFloatRes_FCOS(
SDNode *N,
1192 RTLIB::COS_F32, RTLIB::COS_F64,
1193 RTLIB::COS_F80, RTLIB::COS_F128,
1194 RTLIB::COS_PPCF128),
1196 GetPairElements(Call, Lo, Hi);
1199 void DAGTypeLegalizer::ExpandFloatRes_FDIV(
SDNode *N,
SDValue &Lo,
1207 RTLIB::DIV_PPCF128),
1210 GetPairElements(Call, Lo, Hi);
1213 void DAGTypeLegalizer::ExpandFloatRes_FEXP(
SDNode *N,
1216 RTLIB::EXP_F32, RTLIB::EXP_F64,
1217 RTLIB::EXP_F80, RTLIB::EXP_F128,
1218 RTLIB::EXP_PPCF128),
1220 GetPairElements(Call, Lo, Hi);
1223 void DAGTypeLegalizer::ExpandFloatRes_FEXP2(
SDNode *N,
1226 RTLIB::EXP2_F32, RTLIB::EXP2_F64,
1227 RTLIB::EXP2_F80, RTLIB::EXP2_F128,
1228 RTLIB::EXP2_PPCF128),
1230 GetPairElements(Call, Lo, Hi);
1233 void DAGTypeLegalizer::ExpandFloatRes_FFLOOR(
SDNode *N,
1236 RTLIB::FLOOR_F32, RTLIB::FLOOR_F64,
1237 RTLIB::FLOOR_F80, RTLIB::FLOOR_F128,
1238 RTLIB::FLOOR_PPCF128),
1240 GetPairElements(Call, Lo, Hi);
1243 void DAGTypeLegalizer::ExpandFloatRes_FLOG(
SDNode *N,
1246 RTLIB::LOG_F32, RTLIB::LOG_F64,
1247 RTLIB::LOG_F80, RTLIB::LOG_F128,
1248 RTLIB::LOG_PPCF128),
1250 GetPairElements(Call, Lo, Hi);
1253 void DAGTypeLegalizer::ExpandFloatRes_FLOG2(
SDNode *N,
1256 RTLIB::LOG2_F32, RTLIB::LOG2_F64,
1257 RTLIB::LOG2_F80, RTLIB::LOG2_F128,
1258 RTLIB::LOG2_PPCF128),
1260 GetPairElements(Call, Lo, Hi);
1263 void DAGTypeLegalizer::ExpandFloatRes_FLOG10(
SDNode *N,
1266 RTLIB::LOG10_F32, RTLIB::LOG10_F64,
1267 RTLIB::LOG10_F80, RTLIB::LOG10_F128,
1268 RTLIB::LOG10_PPCF128),
1270 GetPairElements(Call, Lo, Hi);
1273 void DAGTypeLegalizer::ExpandFloatRes_FMA(
SDNode *N,
SDValue &Lo,
1281 RTLIB::FMA_PPCF128),
1284 GetPairElements(Call, Lo, Hi);
1287 void DAGTypeLegalizer::ExpandFloatRes_FMUL(
SDNode *N,
SDValue &Lo,
1295 RTLIB::MUL_PPCF128),
1298 GetPairElements(Call, Lo, Hi);
1301 void DAGTypeLegalizer::ExpandFloatRes_FNEARBYINT(
SDNode *N,
1304 RTLIB::NEARBYINT_F32,
1305 RTLIB::NEARBYINT_F64,
1306 RTLIB::NEARBYINT_F80,
1307 RTLIB::NEARBYINT_F128,
1308 RTLIB::NEARBYINT_PPCF128),
1310 GetPairElements(Call, Lo, Hi);
1313 void DAGTypeLegalizer::ExpandFloatRes_FNEG(
SDNode *N,
SDValue &Lo,
1321 void DAGTypeLegalizer::ExpandFloatRes_FP_EXTEND(
SDNode *N,
SDValue &Lo,
1330 void DAGTypeLegalizer::ExpandFloatRes_FPOW(
SDNode *N,
1333 RTLIB::POW_F32, RTLIB::POW_F64,
1334 RTLIB::POW_F80, RTLIB::POW_F128,
1335 RTLIB::POW_PPCF128),
1337 GetPairElements(Call, Lo, Hi);
1340 void DAGTypeLegalizer::ExpandFloatRes_FPOWI(
SDNode *N,
1343 RTLIB::POWI_F32, RTLIB::POWI_F64,
1344 RTLIB::POWI_F80, RTLIB::POWI_F128,
1345 RTLIB::POWI_PPCF128),
1347 GetPairElements(Call, Lo, Hi);
1350 void DAGTypeLegalizer::ExpandFloatRes_FREM(
SDNode *N,
1353 RTLIB::REM_F32, RTLIB::REM_F64,
1354 RTLIB::REM_F80, RTLIB::REM_F128,
1355 RTLIB::REM_PPCF128),
1357 GetPairElements(Call, Lo, Hi);
1360 void DAGTypeLegalizer::ExpandFloatRes_FRINT(
SDNode *N,
1363 RTLIB::RINT_F32, RTLIB::RINT_F64,
1364 RTLIB::RINT_F80, RTLIB::RINT_F128,
1365 RTLIB::RINT_PPCF128),
1367 GetPairElements(Call, Lo, Hi);
1370 void DAGTypeLegalizer::ExpandFloatRes_FROUND(
SDNode *N,
1377 RTLIB::ROUND_PPCF128),
1379 GetPairElements(Call, Lo, Hi);
1382 void DAGTypeLegalizer::ExpandFloatRes_FSIN(
SDNode *N,
1385 RTLIB::SIN_F32, RTLIB::SIN_F64,
1386 RTLIB::SIN_F80, RTLIB::SIN_F128,
1387 RTLIB::SIN_PPCF128),
1389 GetPairElements(Call, Lo, Hi);
1392 void DAGTypeLegalizer::ExpandFloatRes_FSQRT(
SDNode *N,
1395 RTLIB::SQRT_F32, RTLIB::SQRT_F64,
1396 RTLIB::SQRT_F80, RTLIB::SQRT_F128,
1397 RTLIB::SQRT_PPCF128),
1399 GetPairElements(Call, Lo, Hi);
1402 void DAGTypeLegalizer::ExpandFloatRes_FSUB(
SDNode *N,
SDValue &Lo,
1410 RTLIB::SUB_PPCF128),
1413 GetPairElements(Call, Lo, Hi);
1416 void DAGTypeLegalizer::ExpandFloatRes_FTRUNC(
SDNode *N,
1419 RTLIB::TRUNC_F32, RTLIB::TRUNC_F64,
1420 RTLIB::TRUNC_F80, RTLIB::TRUNC_F128,
1421 RTLIB::TRUNC_PPCF128),
1423 GetPairElements(Call, Lo, Hi);
1426 void DAGTypeLegalizer::ExpandFloatRes_LOAD(
SDNode *N,
SDValue &Lo,
1429 ExpandRes_NormalLoad(N, Lo, Hi);
1451 APInt(NVT.getSizeInBits(), 0)), dl, NVT);
1455 ReplaceValueWith(
SDValue(LD, 1), Chain);
1458 void DAGTypeLegalizer::ExpandFloatRes_XINT_TO_FP(
SDNode *N,
SDValue &Lo,
1483 LC = RTLIB::SINTTOFP_I64_PPCF128;
1486 LC = RTLIB::SINTTOFP_I128_PPCF128;
1488 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported XINT_TO_FP!");
1490 Hi = TLI.
makeLibCall(DAG, LC, VT, Src,
true, dl).first;
1491 GetPairElements(Hi, Lo, Hi);
1502 static const uint64_t TwoE32[] = { 0x41f0000000000000LL, 0 };
1503 static const uint64_t TwoE64[] = { 0x43f0000000000000LL, 0 };
1504 static const uint64_t TwoE128[] = { 0x47f0000000000000LL, 0 };
1528 GetPairElements(Lo, Lo, Hi);
1540 bool DAGTypeLegalizer::ExpandFloatOperand(
SDNode *N,
unsigned OpNo) {
1551 dbgs() <<
"ExpandFloatOperand Op #" << OpNo <<
": ";
1560 case ISD::BR_CC: Res = ExpandFloatOp_BR_CC(N);
break;
1566 case ISD::SETCC: Res = ExpandFloatOp_SETCC(N);
break;
1567 case ISD::STORE: Res = ExpandFloatOp_STORE(cast<StoreSDNode>(N),
1572 if (!Res.getNode())
return false;
1576 if (Res.getNode() ==
N)
1580 "Invalid operand expansion");
1582 ReplaceValueWith(
SDValue(N, 0), Res);
1588 void DAGTypeLegalizer::FloatExpandSetCCOperands(
SDValue &NewLHS,
1592 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
1593 GetExpandedFloat(NewLHS, LHSLo, LHSHi);
1594 GetExpandedFloat(NewRHS, RHSLo, RHSHi);
1607 LHSLo, RHSLo, CCCode);
1612 LHSHi, RHSHi, CCCode);
1614 NewLHS = DAG.
getNode(
ISD::OR, dl, Tmp1.getValueType(), Tmp1, Tmp3);
1621 FloatExpandSetCCOperands(NewLHS, NewRHS, CCCode,
SDLoc(N));
1636 SDValue DAGTypeLegalizer::ExpandFloatOp_FCOPYSIGN(
SDNode *N) {
1638 "Logic only correct for ppcf128!");
1647 SDValue DAGTypeLegalizer::ExpandFloatOp_FP_ROUND(
SDNode *N) {
1649 "Logic only correct for ppcf128!");
1657 SDValue DAGTypeLegalizer::ExpandFloatOp_FP_TO_SINT(
SDNode *N) {
1662 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported FP_TO_SINT!");
1666 SDValue DAGTypeLegalizer::ExpandFloatOp_FP_TO_UINT(
SDNode *N) {
1671 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported FP_TO_UINT!");
1676 SDValue DAGTypeLegalizer::ExpandFloatOp_SELECT_CC(
SDNode *N) {
1679 FloatExpandSetCCOperands(NewLHS, NewRHS, CCCode,
SDLoc(N));
1697 FloatExpandSetCCOperands(NewLHS, NewRHS, CCCode,
SDLoc(N));
1702 "Unexpected setcc expansion!");
1711 SDValue DAGTypeLegalizer::ExpandFloatOp_STORE(
SDNode *N,
unsigned OpNo) {
1713 return ExpandOp_NormalStore(N, OpNo);
1716 assert(OpNo == 1 &&
"Can only expand the stored value so far");
1750 bool DAGTypeLegalizer::PromoteFloatOperand(
SDNode *N,
unsigned OpNo) {
1767 case ISD::BITCAST: R = PromoteFloatOp_BITCAST(N, OpNo);
break;
1768 case ISD::FCOPYSIGN: R = PromoteFloatOp_FCOPYSIGN(N, OpNo);
break;
1771 case ISD::FP_EXTEND: R = PromoteFloatOp_FP_EXTEND(N, OpNo);
break;
1772 case ISD::SELECT_CC: R = PromoteFloatOp_SELECT_CC(N, OpNo);
break;
1773 case ISD::SETCC: R = PromoteFloatOp_SETCC(N, OpNo);
break;
1774 case ISD::STORE: R = PromoteFloatOp_STORE(N, OpNo);
break;
1778 ReplaceValueWith(
SDValue(N, 0), R);
1782 SDValue DAGTypeLegalizer::PromoteFloatOp_BITCAST(
SDNode *N,
unsigned OpNo) {
1800 SDValue DAGTypeLegalizer::PromoteFloatOp_FCOPYSIGN(
SDNode *N,
unsigned OpNo) {
1801 assert (OpNo == 1 &&
"Only Operand 1 must need promotion here");
1809 SDValue DAGTypeLegalizer::PromoteFloatOp_FP_TO_XINT(
SDNode *N,
unsigned OpNo) {
1814 SDValue DAGTypeLegalizer::PromoteFloatOp_FP_EXTEND(
SDNode *N,
unsigned OpNo) {
1829 SDValue DAGTypeLegalizer::PromoteFloatOp_SELECT_CC(
SDNode *N,
unsigned OpNo) {
1840 SDValue DAGTypeLegalizer::PromoteFloatOp_SETCC(
SDNode *N,
unsigned OpNo) {
1853 SDValue DAGTypeLegalizer::PromoteFloatOp_STORE(
SDNode *N,
unsigned OpNo) {
1858 SDValue Promoted = GetPromotedFloat(Val);
1874 void DAGTypeLegalizer::PromoteFloatResult(
SDNode *N,
unsigned ResNo) {
1885 case ISD::BITCAST: R = PromoteFloatRes_BITCAST(N);
break;
1888 R = PromoteFloatRes_EXTRACT_VECTOR_ELT(N);
break;
1920 case ISD::FSUB: R = PromoteFloatRes_BinOp(N);
break;
1923 case ISD::FMAD: R = PromoteFloatRes_FMAD(N);
break;
1925 case ISD::FPOWI: R = PromoteFloatRes_FPOWI(N);
break;
1928 case ISD::LOAD: R = PromoteFloatRes_LOAD(N);
break;
1929 case ISD::SELECT: R = PromoteFloatRes_SELECT(N);
break;
1934 case ISD::UNDEF: R = PromoteFloatRes_UNDEF(N);
break;
1939 SetPromotedFloat(
SDValue(N, ResNo), R);
1947 SDValue DAGTypeLegalizer::PromoteFloatRes_BITCAST(
SDNode *N) {
1958 SDValue DAGTypeLegalizer::PromoteFloatRes_ConstantFP(
SDNode *N) {
1979 SDValue DAGTypeLegalizer::PromoteFloatRes_EXTRACT_VECTOR_ELT(
SDNode *N) {
1990 uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
1992 switch (getTypeAction(VecVT)) {
1996 ReplaceValueWith(
SDValue(N, 0), Res);
2000 Vec = GetWidenedVector(Vec);
2002 ReplaceValueWith(
SDValue(N, 0), Res);
2007 GetSplitVector(Vec, Lo, Hi);
2011 if (IdxVal < LoElts)
2017 ReplaceValueWith(
SDValue(N, 0), Res);
2041 SDValue DAGTypeLegalizer::PromoteFloatRes_FCOPYSIGN(
SDNode *N) {
2054 SDValue DAGTypeLegalizer::PromoteFloatRes_UnaryOp(
SDNode *N) {
2065 SDValue DAGTypeLegalizer::PromoteFloatRes_BinOp(
SDNode *N) {
2084 SDValue DAGTypeLegalizer::PromoteFloatRes_FPOWI(
SDNode *N) {
2095 SDValue DAGTypeLegalizer::PromoteFloatRes_FP_ROUND(
SDNode *N) {
2132 SDValue DAGTypeLegalizer::PromoteFloatRes_SELECT(
SDNode *N) {
2142 SDValue DAGTypeLegalizer::PromoteFloatRes_SELECT_CC(
SDNode *N) {
2153 SDValue DAGTypeLegalizer::PromoteFloatRes_XINT_TO_FP(
SDNode *N) {
2164 SDValue DAGTypeLegalizer::PromoteFloatRes_UNDEF(
SDNode *N) {
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
EVT getValueType() const
Return the ValueType of the referenced return value.
const SDValue & getOffset() const
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant, which is required to be operand #1) half of the integer or float value specified as operand #0.
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
DiagnosticInfoOptimizationBase::Argument NV
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond)
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
BR_CC - Conditional branch.
This class represents lattice values for constants.
FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0 as less than 0...
const SDValue & getBasePtr() const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
const SDValue & getValue() const
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit...
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
const SDValue & getChain() const
ISD::MemIndexedMode getAddressingMode() const
Return the addressing mode for this load or store: unindexed, pre-inc, pre-dec, post-inc, or post-dec.
static const fltSemantics & EVTToAPFloatSemantics(EVT VT)
Returns an APFloat semantics tag appropriate for the given type.
unsigned getAlignment() const
SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS)
Helper function to make it easier to build Select's if you just have operands and don't want to check...
void softenSetCCOperands(SelectionDAG &DAG, EVT VT, SDValue &NewLHS, SDValue &NewRHS, ISD::CondCode &CCCode, const SDLoc &DL) const
Soften the operands of a comparison.
const SDNodeFlags getFlags() const
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
Libcall getFPROUND(EVT OpVT, EVT RetVT)
getFPROUND - Return the FPROUND_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
bool isTruncatingStore() const
Return true if the op does a truncation before store.
Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
Shift and rotation operations.
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
CopyToReg - This node has three operands: a chain, a register number to set to this value...
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
The memory access is dereferenceable (i.e., doesn't trap).
const DataLayout & getDataLayout() const
SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
bool isUNINDEXEDStore(const SDNode *N)
Returns true if the specified node is an unindexed store.
void clearBit(unsigned BitPosition)
Set a given bit to 0.
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
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.
UNDEF - An undefined node.
This class is used to represent ISD::STORE nodes.
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the specified, possibly variable...
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
const SDValue & getBasePtr() const
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
Simple binary floating point operators.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
const SDValue & getOperand(unsigned Num) const
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
unsigned getNumOperands() const
Return the number of values used by this operation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands...
bool isUNINDEXEDLoad(const SDNode *N)
Returns true if the specified node is an unindexed load.
SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type...
Libcall getFPEXT(EVT OpVT, EVT RetVT)
getFPEXT - Return the FPEXT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
void dump() const
Dump this node, for debugging.
Returns platform specific canonical encoding of a floating point number.
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
EVT getVectorElementType() const
Given a vector type, return the type of each element.
SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
EVT getMemoryVT() const
Return the type of the in-memory value.
Class for arbitrary precision integers.
SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, bool isTarget=false)
Create a ConstantFPSDNode wrapping a constant value.
Select(COND, TRUEVAL, FALSEVAL).
ZERO_EXTEND - Used for integer types, zeroing the new bits.
ANY_EXTEND - Used for integer types. The high bits are undefined.
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
Bitwise operators - logical and, logical or, logical xor.
std::pair< SDValue, SDValue > makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, ArrayRef< SDValue > Ops, bool isSigned, const SDLoc &dl, bool doesNotReturn=false, bool isReturnValueUsed=true) const
Returns a pair of (return value, chain).
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
Flags getFlags() const
Return the raw flags of the source value,.
The memory access always returns the same value (or traps).
unsigned getOpcode() const
SDValue getValue(unsigned R) const
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
SDValue getCondCode(ISD::CondCode Cond)
Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
SDValue getVAArg(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue SV, unsigned Align)
VAArg produces a result and token chain, and takes a pointer and a source value as input...
const MachinePointerInfo & getPointerInfo() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
uint64_t getConstantOperandVal(unsigned Num) const
Helper method returns the integer value of a ConstantSDNode operand.
FMA - Perform a * b + c with no intermediate rounding step.
SDValue getSelectCC(const SDLoc &DL, SDValue LHS, SDValue RHS, SDValue True, SDValue False, ISD::CondCode Cond)
Helper function to make it easier to build SelectCC's if you just have an ISD::CondCode instead of an...
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
const APFloat & getValueAPF() const
FMAD - Perform a * b + c, while getting the same result as the separately rounded operations...
SetCC operator - This evaluates to a true value iff the condition is true.
APInt bitcastToAPInt() const
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
TRUNCATE - Completely drop the high bits.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
Perform various unary floating-point operations inspired by libm.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
static ISD::NodeType GetPromotionOpcode(EVT OpVT, EVT RetVT)
LLVMContext * getContext() const
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL, bool LegalTypes=true) const
This class is used to represent ISD::LOAD nodes.