32#define DEBUG_TYPE "legalize-types"
42void DAGTypeLegalizer::PromoteIntegerResult(
SDNode *
N,
unsigned ResNo) {
47 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true)) {
52 switch (
N->getOpcode()) {
55 dbgs() <<
"PromoteIntegerResult #" << ResNo <<
": ";
56 N->dump(&DAG);
dbgs() <<
"\n";
64 case ISD::BSWAP: Res = PromoteIntRes_BSWAP(
N);
break;
68 case ISD::CTLZ: Res = PromoteIntRes_CTLZ(
N);
break;
69 case ISD::CTLS: Res = PromoteIntRes_CTLS(
N);
break;
71 case ISD::CTPOP: Res = PromoteIntRes_CTPOP_PARITY(
N);
break;
73 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(
N);
break;
76 case ISD::VP_CTTZ_ELTS_ZERO_POISON:
77 case ISD::VP_CTTZ_ELTS:
78 Res = PromoteIntRes_VP_CttzElements(
N);
81 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(
N);
break;
91 Res = PromoteIntRes_VECTOR_COMPRESS(
N);
94 Res = PromoteIntRes_VECTOR_SHUFFLE_VAR(
N);
99 Res = PromoteIntRes_Select(
N);
104 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
106 case ISD::SHL: Res = PromoteIntRes_SHL(
N);
break;
108 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
109 case ISD::SRA: Res = PromoteIntRes_SRA(
N);
break;
110 case ISD::SRL: Res = PromoteIntRes_SRL(
N);
break;
113 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
114 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
118 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
120 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
122 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
124 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
127 Res = PromoteIntRes_VECTOR_SPLICE(
N);
130 Res = PromoteIntRes_VECTOR_REPEAT(
N);
134 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
137 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
139 Res = PromoteIntRes_BUILD_VECTOR(
N);
143 Res = PromoteIntRes_ScalarOp(
N);
147 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
152 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
155 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
159 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
162 Res = PromoteIntRes_MASK_BEFOREFIRST(
N);
165 Res = PromoteIntRes_VECTOR_MATCH(
N);
171 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
185 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
189 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
192 Res = PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
N);
196 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
205 case ISD::MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
215 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
222 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
226 case ISD::ABDU: Res = PromoteIntRes_SExtOrZExtIntBinOp(
N);
break;
230 Res = PromoteIntRes_ZExtMaskedIntBinOp(
N);
234 Res = PromoteIntRes_SExtMaskedIntBinOp(
N);
238 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
240 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
242 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
258 Res = PromoteIntRes_ADDSUBSHLSAT(
N);
263 Res = PromoteIntRes_CMP(
N);
278 Res = PromoteIntRes_ABS(
N);
312 Res = PromoteIntRes_VECREDUCE(
N);
315 case ISD::VP_REDUCE_ADD:
316 case ISD::VP_REDUCE_MUL:
317 case ISD::VP_REDUCE_AND:
318 case ISD::VP_REDUCE_OR:
319 case ISD::VP_REDUCE_XOR:
320 case ISD::VP_REDUCE_SMAX:
321 case ISD::VP_REDUCE_SMIN:
322 case ISD::VP_REDUCE_UMAX:
323 case ISD::VP_REDUCE_UMIN:
324 Res = PromoteIntRes_VP_REDUCE(
N);
329 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
333 Res = PromoteIntRes_FREEZE(
N);
338 Res = PromoteIntRes_Rotate(
N);
343 Res = PromoteIntRes_FunnelShift(
N);
349 Res = PromoteIntRes_CLMUL(
N);
353 Res = PromoteIntRes_PEXT(
N);
357 Res = PromoteIntRes_PDEP(
N);
362 Res = PromoteIntRes_MULH(
N);
366 Res = PromoteIntRes_IS_FPCLASS(
N);
369 Res = PromoteIntRes_FFREXP(
N);
374 Res = PromoteIntRes_XRINT(
N);
378 Res = PromoteIntRes_PATCHPOINT(
N);
381 Res = PromoteIntRes_READ_REGISTER(
N);
387 SetPromotedInteger(
SDValue(
N, ResNo), Res);
392 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
393 return GetPromotedInteger(
Op);
396SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
398 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
399 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
404 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
406 Op.getValueType(),
Op,
N->getOperand(1));
411 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
413 Op.getValueType(),
Op,
N->getOperand(1));
417 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
420 switch (TLI.getExtendForAtomicOps()) {
436 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
437 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
447 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
449 Op2 = SExtPromotedInteger(Op2);
452 Op2 = ZExtPromotedInteger(Op2);
455 Op2 = GetPromotedInteger(Op2);
460 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
462 N->getChain(),
N->getBasePtr(),
463 Op2,
N->getMemOperand());
474 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
475 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
479 if (!TLI.isTypeLegal(SVT))
482 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
483 SDValue Res = DAG.getAtomicCmpSwap(
485 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
489 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
495 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
496 switch (TLI.getExtendForAtomicCmpSwapArg()) {
498 Op2 = SExtPromotedInteger(Op2);
501 Op2 = ZExtPromotedInteger(Op2);
504 Op2 = GetPromotedInteger(Op2);
511 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
512 SDValue Res = DAG.getAtomicCmpSwap(
513 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
514 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
516 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
524 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
525 EVT OutVT =
N->getValueType(0);
526 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
529 switch (getTypeAction(InVT)) {
535 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
539 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
542 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
550 BitConvertToInteger(GetScalarizedVector(InOp)));
559 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
560 Lo = BitConvertToInteger(
Lo);
561 Hi = BitConvertToInteger(
Hi);
563 if (DAG.getDataLayout().isBigEndian())
569 JoinIntegers(
Lo,
Hi));
584 if (DAG.getDataLayout().isBigEndian()) {
588 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
603 if (isTypeLegal(WideOutVT)) {
604 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
606 DAG.getVectorIdxConstant(0, dl));
615 DAG.getDataLayout().isLittleEndian()) {
626 if (isTypeLegal(WideVecVT)) {
628 DAG.getUNDEF(WideVecVT), InOp,
629 DAG.getVectorIdxConstant(0, dl));
637 CreateStackStoreLoad(InOp, OutVT));
641 SDValue V = GetPromotedInteger(
N->getOperand(0));
643 V.getValueType(),
V);
647 SDValue Op = GetPromotedInteger(
N->getOperand(0));
648 EVT OVT =
N->getValueType(0);
649 EVT NVT =
Op.getValueType();
657 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
658 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
663 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
669 SDValue Op = GetPromotedInteger(
N->getOperand(0));
670 EVT OVT =
N->getValueType(0);
671 EVT NVT =
Op.getValueType();
680 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
685 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
694 TLI.getTypeToTransformTo(*DAG.getContext(),
695 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
700 EVT VT =
N->getValueType(0);
707 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
714 EVT OVT =
N->getValueType(0);
715 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
721 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
722 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
724 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
730 unsigned CtlzOpcode =
N->getOpcode();
733 SDValue ExtractLeadingBits = DAG.getConstant(
736 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
740 return DAG.getNode(
ISD::SUB, dl, NVT,
741 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
746 SDValue Op = GetPromotedInteger(
N->getOperand(0));
750 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
752 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
758 EVT OVT =
N->getValueType(0);
759 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
762 SDValue ExtractLeadingBits = DAG.getConstant(
765 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
771 EVT OVT =
N->getValueType(0);
772 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
780 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
781 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
788 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
789 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
793 SDValue Op = GetPromotedInteger(
N->getOperand(0));
794 EVT OVT =
N->getValueType(0);
795 EVT NVT =
Op.getValueType();
802 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
803 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
807 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
813 unsigned NewOpc =
N->getOpcode();
820 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
823 return DAG.getNode(NewOpc, dl, NVT,
Op);
826SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
828 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
829 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
832SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
834 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
841 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
847 EVT SVT =
In.getValueType().getScalarType();
850 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
858 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
860 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
864 if (
N->isStrictFPOpcode()) {
865 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
866 {
N->getOperand(0),
N->getOperand(1)});
871 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
886 DAG.getValueType(
N->getValueType(0).getScalarType()));
889SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
891 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
893 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
897SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
898 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
901 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
906SDValue DAGTypeLegalizer::PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
SDNode *
N) {
907 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
911 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
914SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
915 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
918 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
919 N->getOperand(0),
N->getOperand(1));
925 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
927 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
931 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
935 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
944 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
947 if (getTypeAction(
N->getOperand(0).getValueType())
949 SDValue Res = GetPromotedInteger(
N->getOperand(0));
958 DAG.getValueType(
N->getOperand(0).getValueType()));
960 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
967 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
972 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
976 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
977 N->getMemoryVT(),
N->getMemOperand());
986 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
987 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
990 :
N->getExtensionType();
993 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
994 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
995 N->getMemOperand(),
N->isExpandingLoad());
1003 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1004 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1011 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1012 N->getOffset(),
N->getMask(), ExtPassThru,
1013 N->getMemoryVT(),
N->getMemOperand(),
1014 N->getAddressingMode(), ExtType,
1015 N->isExpandingLoad());
1023 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1024 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1026 "Gather result type and the passThru argument type should be the same");
1033 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1034 N->getIndex(),
N->getScale() };
1035 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1036 N->getMemoryVT(), dl,
Ops,
1037 N->getMemOperand(),
N->getIndexType(),
1045SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1046 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1047 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1049 N->getOperand(1), Passthru);
1052SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE_VAR(
SDNode *
N) {
1053 SDValue V = GetPromotedInteger(
N->getOperand(0));
1062 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1063 EVT VT =
N->getValueType(0);
1064 EVT SVT = getSetCCResultType(VT);
1065 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1066 unsigned NumOps =
N->getNumOperands();
1069 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1077 ReplaceValueWith(
SDValue(
N, 0), Res);
1080 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1095 unsigned Opcode =
N->getOpcode();
1101 SExtOrZExtPromotedOperands(Op1, Op2);
1107 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1109 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1110 Op1 = SExtPromotedInteger(Op1);
1111 Op2 = SExtPromotedInteger(Op2);
1115 Op1 = ZExtPromotedInteger(Op1);
1116 Op2 = ZExtPromotedInteger(Op2);
1119 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1128 Op1 = GetPromotedInteger(Op1);
1130 Op2 = ZExtPromotedInteger(Op2);
1132 Op1 = SExtPromotedInteger(Op1);
1133 Op2 = SExtPromotedInteger(Op2);
1140 if (IsShift || TLI.isOperationLegal(Opcode, PromotedType)) {
1153 "addition, subtraction or left shift");
1156 unsigned SHLAmount = NewBits - OldBits;
1158 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1163 SDValue Result = DAG.getNode(Opcode, dl, PromotedType, Op1, Op2);
1164 return DAG.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1170 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1171 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1172 SDValue Result = DAG.getNode(AddOp, dl, PromotedType, Op1, Op2);
1181 SDValue Op1Promoted, Op2Promoted;
1187 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1188 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1190 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1191 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1193 EVT OldType =
N->getOperand(0).getValueType();
1205 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1206 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1207 Op2Promoted,
N->getOperand(2));
1209 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1210 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1212 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1217 unsigned SatW,
bool Signed,
1220 EVT VT =
V.getValueType();
1247 EVT VT =
LHS.getValueType();
1263 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1269 "Tried to saturate to more than the original type?");
1278 SDValue Op1Promoted, Op2Promoted;
1284 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1285 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1287 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1288 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1291 unsigned Scale =
N->getConstantOperandVal(2);
1295 if (TLI.isTypeLegal(PromotedType)) {
1297 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1300 N->getValueType(0).getScalarSizeInBits();
1304 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1305 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1306 Op2Promoted,
N->getOperand(2));
1309 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1315 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1316 Op2Promoted, Scale, DAG)) {
1319 N->getValueType(0).getScalarSizeInBits(),
1327 N->getValueType(0).getScalarSizeInBits());
1330SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1332 return PromoteIntRes_Overflow(
N);
1336 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1337 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1338 EVT OVT =
N->getOperand(0).getValueType();
1339 EVT NVT =
LHS.getValueType();
1349 DAG.getValueType(OVT));
1351 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1354 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1360 EVT PromotedResultTy =
1361 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1362 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1363 N->getOperand(0),
N->getOperand(1));
1369 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1370 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1372 unsigned Opcode =
N->getOpcode();
1373 if (Opcode == ISD::VP_MERGE)
1374 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1376 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1380 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1381 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1383 LHS.getValueType(),
N->getOperand(0),
1384 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1389 EVT InVT =
N->getOperand(OpNo).getValueType();
1390 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1392 EVT SVT = getSetCCResultType(InVT);
1399 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1400 SVT = getSetCCResultType(InVT);
1408 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1409 "Vector compare must return a vector result!");
1413 if (
N->isStrictFPOpcode()) {
1414 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1415 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1416 N->getOperand(2),
N->getOperand(3)};
1417 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1422 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1423 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1426 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1433 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1438 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1439 EVT VT =
N->getValueType(0);
1443 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1445 ReplaceValueWith(
SDValue(
N, 0), Res);
1450 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1453 RHS = ZExtPromotedInteger(
RHS);
1454 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1457SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1458 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1460 Op.getValueType(),
Op,
N->getOperand(1));
1463SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1467 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1468 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1469 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1474 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1475 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1476 if (
N->getNumOperands() == 2)
1477 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1478 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1479 assert((
N->getOpcode() == ISD::VP_SDIV ||
N->getOpcode() == ISD::VP_SREM) &&
1480 "Expected VP opcode");
1483 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1489 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1490 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1491 if (
N->getNumOperands() == 2)
1492 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1493 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1494 assert((
N->getOpcode() == ISD::VP_UDIV ||
N->getOpcode() == ISD::VP_UREM) &&
1495 "Expected VP opcode");
1503SDValue DAGTypeLegalizer::PromoteIntRes_ZExtMaskedIntBinOp(
SDNode *
N) {
1504 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1505 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1507 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1511SDValue DAGTypeLegalizer::PromoteIntRes_SExtMaskedIntBinOp(
SDNode *
N) {
1512 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1513 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1515 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1519SDValue DAGTypeLegalizer::PromoteIntRes_SExtOrZExtIntBinOp(
SDNode *
N) {
1525 SExtOrZExtPromotedOperands(
LHS,
RHS);
1527 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1533 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1536 RHS = ZExtPromotedInteger(
RHS);
1537 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1543 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1545 RHS = ZExtPromotedInteger(
RHS);
1546 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1551 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1553 unsigned Opcode =
N->getOpcode();
1564 !TLI.isOperationLegalOrCustom(Opcode, VT) &&
1567 SDValue Op0 = GetPromotedInteger(
N->getOperand(0));
1569 Amt = ZExtPromotedInteger(Amt);
1575 DAG.getConstant(OldBits,
DL, AmtVT));
1576 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1578 SDValue Lo = DAG.getZeroExtendInReg(Op0,
DL, OldVT);
1590 SDValue Res = TLI.expandROT(
N,
true , DAG);
1591 ReplaceValueWith(
SDValue(
N, 0), Res);
1596 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1597 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1600 Amt = ZExtPromotedInteger(Amt);
1604 EVT OldVT =
N->getOperand(0).getValueType();
1605 EVT VT =
Lo.getValueType();
1606 unsigned Opcode =
N->getOpcode();
1613 DAG.getConstant(OldBits,
DL, AmtVT));
1621 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1622 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1624 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1634 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1640 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1642 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1646 unsigned Opcode =
N->getOpcode();
1649 EVT OldVT =
N->getOperand(0).getValueType();
1650 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1655 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT) &&
1657 TLI.isOperationLegalOrCustom(
1658 ISD::CLMUL, TLI.getRegisterType(*DAG.getContext(), VT)))) {
1659 if (
SDValue Res = TLI.expandCLMUL(
N, DAG))
1662 SDValue X = GetPromotedInteger(
N->getOperand(0));
1663 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1667 SDValue X = ZExtPromotedInteger(
N->getOperand(0));
1668 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1672 if (NewBits < 2 * OldBits) {
1674 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1676 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1678 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1680 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1685 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1687 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1692 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1693 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PEXT, VT)) {
1694 if (
SDValue Res = TLI.expandPEXT(
N, DAG))
1699 SDValue X = GetPromotedInteger(
N->getOperand(0));
1700 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1706 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1707 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PDEP, VT)) {
1708 if (
SDValue Res = TLI.expandPDEP(
N, DAG))
1713 SDValue X = GetPromotedInteger(
N->getOperand(0));
1714 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1720 EVT VT =
N->getValueType(0);
1721 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
1728 LHS = SExtPromotedInteger(
N->getOperand(0));
1729 RHS = SExtPromotedInteger(
N->getOperand(1));
1731 LHS = ZExtPromotedInteger(
N->getOperand(0));
1732 RHS = ZExtPromotedInteger(
N->getOperand(1));
1739 DAG.getShiftAmountConstant(BW, NVT, dl));
1743 DAG.getShiftAmountConstant(NBW - BW, NVT, dl));
1744 return DAG.getNode(
N->getOpcode(), dl, NVT,
LHS,
RHS);
1748 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1760 Res = GetPromotedInteger(InOp);
1767 "Dst and Src must have the same number of elements");
1769 "Promoted vector type must be a power of two");
1772 GetSplitVector(InOp, EOp1, EOp2);
1781 SDValue WideInOp = GetWidenedVector(InOp);
1786 N->getValueType(0).getScalarType(), NumElem);
1795 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1804SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1806 return PromoteIntRes_Overflow(
N);
1810 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1811 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1812 EVT OVT =
N->getOperand(0).getValueType();
1813 EVT NVT =
LHS.getValueType();
1822 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1824 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1827 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1838 return PromoteIntRes_Overflow(
N);
1850 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1851 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1853 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1856 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1867 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1868 return PromoteIntRes_Overflow(
N);
1872 EVT OVT =
N->getValueType(0);
1873 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1879 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1881 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1882 if (
SDValue Res = TLI.expandABS(
N, DAG))
1886 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1890SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1893 return PromoteIntRes_Overflow(
N);
1897 EVT SmallVT =
LHS.getValueType();
1904 LHS = SExtPromotedInteger(
LHS);
1905 RHS = SExtPromotedInteger(
RHS);
1907 LHS = ZExtPromotedInteger(
LHS);
1908 RHS = ZExtPromotedInteger(
RHS);
1910 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1922 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1923 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1924 DAG.getConstant(0,
DL,
Hi.getValueType()),
1929 Mul, DAG.getValueType(SmallVT));
1939 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1944 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1945 N->getValueType(0)));
1949 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1951 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1958 EVT VT =
N->getValueType(0);
1961 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1962 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1966 for (
unsigned i = 0; i < NumRegs; ++i) {
1967 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
1968 N->getConstantOperandVal(3));
1973 if (DAG.getDataLayout().isBigEndian())
1974 std::reverse(Parts.begin(), Parts.end());
1977 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1979 for (
unsigned i = 1; i < NumRegs; ++i) {
1984 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1990 ReplaceValueWith(
SDValue(
N, 1), Chain);
2003bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
2006 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2011 switch (
N->getOpcode()) {
2014 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2015 N->dump(&DAG);
dbgs() <<
"\n";
2021 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2027 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2028 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2033 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2037 Res = PromoteIntOp_FAKE_USE(
N);
2040 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2044 Res = PromoteIntOp_ScalarOp(
N);
2047 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2049 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2067 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2070 Res = PromoteIntOp_VECTOR_SHUFFLE_VAR(
N, OpNo);
2077 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2092 Res = PromoteIntOp_Shift(
N);
2096 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2099 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2125 case ISD::VP_REDUCE_ADD:
2126 case ISD::VP_REDUCE_MUL:
2127 case ISD::VP_REDUCE_AND:
2128 case ISD::VP_REDUCE_OR:
2129 case ISD::VP_REDUCE_XOR:
2130 case ISD::VP_REDUCE_SMAX:
2131 case ISD::VP_REDUCE_SMIN:
2132 case ISD::VP_REDUCE_UMAX:
2133 case ISD::VP_REDUCE_UMIN:
2134 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2139 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2142 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2145 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2147 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2148 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2149 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2151 case ISD::EXPERIMENTAL_VP_SPLICE:
2152 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2155 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2160 Res = PromoteIntOp_UnaryBooleanVectorOp(
N, OpNo);
2163 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2166 Res = PromoteIntOp_VECTOR_MATCH(
N, OpNo);
2172 Res = PromoteIntOp_MaskedBinOp(
N, OpNo);
2177 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2180 Res = PromoteIntOp_VECTOR_REPEAT(
N);
2184 Res = PromoteIntOp_LOOP_DEPENDENCE_MASK(
N);
2189 if (!Res.
getNode())
return false;
2196 const bool IsStrictFp =
N->isStrictFPOpcode();
2198 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2199 "Invalid operand expansion");
2203 ReplaceValueWith(
SDValue(
N, 0), Res);
2217 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2221 unsigned OpLEffectiveBits =
2222 DAG.computeKnownBits(OpL).countMaxActiveBits();
2223 unsigned OpREffectiveBits =
2224 DAG.computeKnownBits(OpR).countMaxActiveBits();
2225 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2226 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2233 LHS = SExtPromotedInteger(
LHS);
2234 RHS = SExtPromotedInteger(
RHS);
2243 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2244 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2245 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2246 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2253 LHS = ZExtPromotedInteger(
LHS);
2254 RHS = ZExtPromotedInteger(
RHS);
2268 LHS = SExtPromotedInteger(
LHS);
2269 RHS = SExtPromotedInteger(
RHS);
2274 "Unknown integer comparison!");
2276 SExtOrZExtPromotedOperands(
LHS,
RHS);
2280 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2284SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2285 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2286 EVT ResVT =
N->getValueType(0);
2287 EVT OpVT =
Op.getValueType();
2290 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2295 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2296 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2297 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2301 EVT OutVT =
N->getValueType(0);
2304 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2307 switch (getTypeAction(InVT)) {
2313 if (OutEltBits % InEltBits == 0 && isTypeLegal(IntVT)) {
2316 SDValue Promoted = GetPromotedInteger(InOp);
2319 if (PromotedEltBits % InEltBits == 0) {
2320 unsigned Scale = PromotedEltBits / InEltBits;
2328 PromotedBits / OutEltBits);
2329 if (isTypeLegal(PackedVT) && isTypeLegal(CastVT) &&
2336 Mask[
I] =
I * Scale +
2337 (DAG.getDataLayout().isBigEndian() ? Scale - 1 : 0);
2338 if (TLI.isShuffleMaskLegal(Mask, PackedVT)) {
2341 Packed = DAG.getVectorShuffle(PackedVT, dl, Packed,
2342 DAG.getUNDEF(PackedVT), Mask);
2345 return DAG.getExtractSubvector(dl, OutVT, Packed, 0);
2346 return DAG.getExtractVectorElt(dl, OutVT, Packed, 0);
2351 unsigned PartsPerElt = OutEltBits / InEltBits;
2355 for (
unsigned I = 0;
I != NumElts; ++
I) {
2357 for (
unsigned J = 0; J != PartsPerElt; ++J) {
2358 SDValue Part = DAG.getExtractVectorElt(
2360 I * PartsPerElt + J);
2361 Part = DAG.getZeroExtendInReg(Part, dl, InVT.
getScalarType());
2362 Part = DAG.getZExtOrTrunc(Part, dl, IntVT);
2363 unsigned Shift = DAG.getDataLayout().isBigEndian()
2364 ? (PartsPerElt - 1 - J) * InEltBits
2367 DAG.getShiftAmountConstant(Shift, IntVT, dl));
2375 Packed = DAG.getBuildVector(VecVT, dl, Elts);
2382 DAG.getDataLayout().isLittleEndian()) {
2392 if (isTypeLegal(WideVecVT)) {
2393 SDValue Promoted = GetPromotedInteger(InOp);
2396 DAG.getVectorIdxConstant(0, dl));
2409 return CreateStackStoreLoad(InOp, OutVT);
2412SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2413 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2417 PromoteSetCCOperands(
LHS,
RHS,
N->getOperandCondCode(1));
2421 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2422 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2426SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2427 assert(OpNo == 1 &&
"only know how to promote condition");
2430 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2433 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2434 N->getOperand(2)), 0);
2437SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2438 assert(OpNo == 1 &&
"only know how to promote condition");
2441 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2444 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2449 EVT OVT =
N->getOperand(0).getValueType();
2450 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2451 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2452 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2457 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2458 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2467 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2468 "Legal vector of one illegal element?");
2473 assert(
N->getOperand(0).getValueSizeInBits() >=
2474 N->getValueType(0).getScalarSizeInBits() &&
2475 "Type of inserted value narrower than vector element type!");
2478 for (
unsigned i = 0; i < NumElts; ++i)
2479 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2481 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2484SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2491 assert(
N->getOperand(1).getValueSizeInBits() >=
2492 N->getValueType(0).getScalarSizeInBits() &&
2493 "Type of inserted value narrower than vector element type!");
2494 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2495 GetPromotedInteger(
N->getOperand(1)),
2500 assert(OpNo == 2 &&
"Different operand and result vector types?");
2503 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2504 TLI.getVectorIdxTy(DAG.getDataLayout()));
2505 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2506 N->getOperand(1), Idx), 0);
2510 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2514 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2517SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2518 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2520 EVT OpTy =
N->getOperand(1).getValueType();
2523 if (
SDValue Res = WidenVSELECTMask(
N))
2524 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2525 Res,
N->getOperand(1),
N->getOperand(2));
2529 Cond = PromoteTargetBoolean(
Cond, OpVT);
2531 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2532 N->getOperand(2)), 0);
2535SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2536 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2540 PromoteSetCCOperands(
LHS,
RHS,
N->getOperandCondCode(4));
2544 N->getOperand(3),
N->getOperand(4)), 0);
2547SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2548 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2552 PromoteSetCCOperands(
LHS,
RHS,
N->getOperandCondCode(2));
2555 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2559 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2560 ZExtPromotedInteger(
N->getOperand(1))), 0);
2568 LHS = SExtPromotedInteger(
LHS);
2569 RHS = SExtPromotedInteger(
RHS);
2571 SExtOrZExtPromotedOperands(
LHS,
RHS);
2578 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2579 ZExtPromotedInteger(
N->getOperand(2))), 0);
2583 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2587 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2591 return SDValue(DAG.UpdateNodeOperands(
N,
2592 SExtPromotedInteger(
N->getOperand(0))), 0);
2595SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2596 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2597 SExtPromotedInteger(
N->getOperand(1))), 0);
2602 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2605 SDValue Val = GetPromotedInteger(
N->getValue());
2608 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2609 N->getMemoryVT(),
N->getMemOperand());
2615 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2616 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2618 SDValue DataOp = GetPromotedInteger(
N->getValue());
2619 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2620 N->getMask(),
N->getVectorLength(),
2621 N->getMemoryVT(),
N->getMemOperand(),
2622 N->isCompressingStore());
2633 Mask = PromoteTargetBoolean(Mask, DataVT);
2636 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2639 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2640 DataOp = GetPromotedInteger(DataOp);
2642 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2643 N->getOffset(), Mask,
N->getMemoryVT(),
2644 N->getMemOperand(),
N->getAddressingMode(),
2645 true,
N->isCompressingStore());
2650 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2651 EVT DataVT =
N->getValueType(0);
2652 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2654 NewOps[OpNo] =
Mask;
2655 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2671 EVT DataVT =
N->getValueType(0);
2672 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2673 }
else if (OpNo == 4) {
2675 if (
N->isIndexSigned())
2677 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2679 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2681 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2683 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2695 bool TruncateStore =
N->isTruncatingStore();
2700 EVT DataVT =
N->getValue().getValueType();
2701 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2702 }
else if (OpNo == 4) {
2704 if (
N->isIndexSigned())
2706 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2708 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2710 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2711 TruncateStore =
true;
2714 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2715 SDLoc(
N), NewOps,
N->getMemOperand(),
2716 N->getIndexType(), TruncateStore);
2721 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2725 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2729SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_SHUFFLE_VAR(
SDNode *
N,
2731 assert(OpNo == 1 &&
"The source shares the result's type, so promoting it "
2732 "is a result promotion.");
2735 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0), Mask), 0);
2739 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2744 return SDValue(DAG.UpdateNodeOperands(
N,
2745 ZExtPromotedInteger(
N->getOperand(0))), 0);
2748SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2749 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2754SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2755 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2756 ZExtPromotedInteger(
N->getOperand(1))), 0);
2763 EVT VT =
N->getValueType(0);
2768 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2769 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2770 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2771 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2776 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2780 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2782 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2785SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2787 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2788 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2797 unsigned OpOffset = IsStrict ? 1 : 0;
2801 RTLIB::Libcall LC = IsPowI ? RTLIB::getPOWI(
N->getValueType(0))
2804 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2805 if (LCImpl == RTLIB::Unsupported) {
2811 if (IsPowI &&
N->getValueType(0).isVector())
2812 return DAG.UnrollVectorOp(
N);
2814 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2815 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2827 if (
N->getOperand(1 + OpOffset).getScalarValueSizeInBits() >
2828 DAG.getLibInfo().getIntSize()) {
2829 const Function &Fn = DAG.getMachineFunction().getFunction();
2830 Fn.getContext().diagnose(DiagnosticInfoLegalizationFailure(
2831 Twine(IsPowI ?
"powi" :
"ldexp") +
2832 " exponent does not match sizeof(int)",
2833 Fn, N->getDebugLoc()));
2835 ReplaceValueWith(SDValue(N, 1), Chain);
2836 ReplaceValueWith(SDValue(N, 0), DAG.getPOISON(N->getValueType(0)));
2840 TargetLowering::MakeLibCallOptions CallOptions;
2841 CallOptions.setIsSigned(
true);
2842 SDValue Ops[2] = {N->getOperand(0 + OpOffset), N->getOperand(1 + OpOffset)};
2843 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2844 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2845 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2847 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2852 switch (
N->getOpcode()) {
2860 case ISD::VP_REDUCE_ADD:
2861 case ISD::VP_REDUCE_MUL:
2862 case ISD::VP_REDUCE_AND:
2863 case ISD::VP_REDUCE_OR:
2864 case ISD::VP_REDUCE_XOR:
2868 case ISD::VP_REDUCE_SMAX:
2869 case ISD::VP_REDUCE_SMIN:
2873 case ISD::VP_REDUCE_UMAX:
2874 case ISD::VP_REDUCE_UMIN:
2884 return GetPromotedInteger(
V);
2886 return SExtPromotedInteger(
V);
2888 return ZExtPromotedInteger(
V);
2894 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2896 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2897 EVT InVT =
Op.getValueType();
2899 EVT ResVT =
N->getValueType(0);
2900 unsigned Opcode =
N->getOpcode();
2917 switch (TLI.getBooleanContents(InVT)) {
2920 Op = ZExtPromotedInteger(
N->getOperand(0));
2923 Op = SExtPromotedInteger(
N->getOperand(0));
2936 switch (TLI.getBooleanContents(InVT)) {
2939 Op = ZExtPromotedInteger(
N->getOperand(0));
2942 Op = SExtPromotedInteger(
N->getOperand(0));
2948 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2952 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2956SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2963 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2964 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2967 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2969 Op = PromoteIntOpVectorReduction(
N,
Op);
2973 EVT VT =
N->getValueType(0);
2974 EVT EltVT =
Op.getValueType().getScalarType();
2977 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2989 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2990 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2993SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2996 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2997 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3000SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
3003 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
3004 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3009 const Function &Fn = DAG.getMachineFunction().getFunction();
3011 "cannot use llvm.write_register with illegal type", Fn,
3013 return N->getOperand(0);
3016SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
3017 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
3018 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
3021 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3022 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
3032SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
3036 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3037 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3040 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
3042 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
3043 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3046SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
3048 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3050 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
3051 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3054SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
3056 assert(OpNo == 0 &&
"Unexpected operand for promotion");
3060 if (TLI.getBooleanContents(
Op.getValueType()) ==
3062 NewOp = SExtPromotedInteger(
Op);
3064 NewOp = ZExtPromotedInteger(
Op);
3066 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
3069SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
3071 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3072 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3073 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3076SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_MATCH(
SDNode *
N,
unsigned OpNo) {
3077 assert(OpNo < 3 &&
"Unexpected operand for promotion");
3079 return TLI.expandVectorMatch(
N, DAG);
3082 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2),
N->getValueType(0));
3083 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3086SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
3089 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
3090 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3093SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3095 switch (
N->getOpcode()) {
3097 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3098 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3101 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3102 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3105 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3106 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3111 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3114SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
3116 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3117 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3118 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3120 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3125 SDValue Src = GetPromotedInteger(
N->getOperand(0));
3126 EVT SrcVT = Src.getValueType();
3127 EVT OrigVT =
N->getValueType(0);
3142void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3148 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3151 switch (
N->getOpcode()) {
3154 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3155 N->dump(&DAG);
dbgs() <<
"\n";
3184 ExpandIntRes_ABS(
N,
Lo,
Hi);
3236 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3237 SplitInteger(Tmp.first,
Lo,
Hi);
3238 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3243 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3244 SDValue Tmp = DAG.getAtomicCmpSwap(
3246 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3255 SplitInteger(Tmp,
Lo,
Hi);
3334 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3339 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3345 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3349 ExpandIntRes_PEXT(
N,
Lo,
Hi);
3353 ExpandIntRes_PDEP(
N,
Lo,
Hi);
3358 ExpandIntRes_MULH(
N,
Lo,
Hi);
3362 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3366 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3371 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3381std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3382 unsigned Opc =
Node->getOpcode();
3385 "expanded atomic requires a libcall action for the memory type");
3387 RTLIB::AtomicLibcall LC =
3389 EVT RetVT =
Node->getValueType(0);
3390 TargetLowering::MakeLibCallOptions CallOptions;
3394 Ops.push_back(
Node->getOperand(1));
3398 return TLI.makeLibCall(DAG, LC.
Impl, RetVT,
Ops, CallOptions, SDLoc(Node),
3399 Node->getOperand(0));
3404void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3409 GetExpandedInteger(
N->getOperand(0), InL, InH);
3424 if (Amt.
uge(VTBits)) {
3425 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3426 }
else if (Amt.
ugt(NVTBits)) {
3427 Lo = DAG.getConstant(0,
DL, NVT);
3429 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3430 }
else if (Amt == NVTBits) {
3431 Lo = DAG.getConstant(0,
DL, NVT);
3435 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3437 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3439 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3444 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3446 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3453 if (Amt.
uge(VTBits)) {
3454 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3455 }
else if (Amt.
ugt(NVTBits)) {
3457 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3458 Hi = DAG.getConstant(0,
DL, NVT);
3459 }
else if (Amt == NVTBits) {
3461 Hi = DAG.getConstant(0,
DL, NVT);
3464 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3466 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3471 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3473 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3476 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3482 if (Amt.
uge(VTBits)) {
3484 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3485 }
else if (Amt.
ugt(NVTBits)) {
3487 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3489 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3490 }
else if (Amt == NVTBits) {
3493 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3496 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3498 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3503 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3505 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3508 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3516bool DAGTypeLegalizer::
3518 unsigned Opc =
N->getOpcode();
3521 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3526 "Expanded integer type size not a power of two!");
3530 KnownBits
Known = DAG.computeKnownBits(Amt);
3533 if (((
Known.Zero |
Known.One) & HighBitMask) == 0)
3538 GetExpandedInteger(In, InL, InH);
3542 if (
Known.One.intersects(HighBitMask)) {
3545 DAG.getConstant(~HighBitMask, dl, ShTy));
3550 Lo = DAG.getConstant(0, dl, NVT);
3551 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3554 Hi = DAG.getConstant(0, dl, NVT);
3555 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3559 DAG.getConstant(NVTBits - 1, dl, ShTy));
3560 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3572 DAG.getConstant(NVTBits - 1, dl, ShTy));
3588 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3590 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3592 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3593 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3605bool DAGTypeLegalizer::
3608 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3612 "Expanded integer type size not a power of two!");
3617 GetExpandedInteger(
N->getOperand(0), InL, InH);
3619 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3622 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3625 Amt, DAG.getConstant(0, dl, ShTy),
3629 switch (
N->getOpcode()) {
3635 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3636 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3639 LoL = DAG.getConstant(0, dl, NVT);
3642 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3643 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3644 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3650 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3653 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3656 HiL = DAG.getConstant(0, dl, NVT);
3659 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3660 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3661 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3667 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3668 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3672 DAG.getConstant(NVTBits - 1, dl, ShTy));
3675 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3676 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3677 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3702 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3707 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3708 SplitInteger(Res,
Lo,
Hi);
3711void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3720 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3721 unsigned NumHalfBits = NumBits / 2;
3722 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3723 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3724 SDValue LHSL, LHSH, RHSL, RHSH;
3725 GetExpandedInteger(
LHS, LHSL, LHSH);
3726 GetExpandedInteger(
RHS, RHSL, RHSH);
3729 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3731 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3739 SDValue LHSL, LHSH, RHSL, RHSH;
3740 GetExpandedInteger(
LHS, LHSL, LHSH);
3741 GetExpandedInteger(
RHS, RHSL, RHSH);
3743 EVT CCT = getSetCCResultType(NVT);
3746 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3748 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3750 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3752 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3756 const APInt *RHSVal =
nullptr;
3758 RHSVal = &RHSConst->getAPIntValue();
3765 SDValue LHSL, LHSH, RHSL, RHSH;
3766 GetExpandedInteger(
LHS, LHSL, LHSH);
3767 GetExpandedInteger(
RHS, RHSL, RHSH);
3769 EVT CCT = getSetCCResultType(NVT);
3775 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3778 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3782 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3785 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3787 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3794 switch (
N->getOpcode()) {
3821 EVT VT =
N->getValueType(0);
3822 EVT CCT = getSetCCResultType(VT);
3825 SplitInteger(Result,
Lo,
Hi);
3829 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3830 SplitInteger(ExpandedCMP,
Lo,
Hi);
3833void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3837 SDValue LHSL, LHSH, RHSL, RHSH;
3838 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3839 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3842 SDValue LoOps[2] = { LHSL, RHSL };
3843 SDValue HiOps[3] = { LHSH, RHSH };
3845 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3847 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3849 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3853 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3859 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3872 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3874 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3877 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3891 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3893 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3897 EVT OvfVT = getSetCCResultType(NVT);
3898 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3913 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3916 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3920 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3932 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3936 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3939 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3942 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3947 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3949 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3950 DAG.getConstant(0, dl, NVT));
3953 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3962 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3967 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3969 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3970 DAG.getConstant(0, dl, NVT));
3976void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3979 SDValue LHSL, LHSH, RHSL, RHSH;
3981 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3982 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3983 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3984 SDValue LoOps[2] = { LHSL, RHSL };
3985 SDValue HiOps[3] = { LHSH, RHSH };
3999 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4002void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
4005 SDValue LHSL, LHSH, RHSL, RHSH;
4007 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4008 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4009 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
4011 SDValue HiOps[3] = { LHSH, RHSH };
4013 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4015 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4019 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4022void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
4030 unsigned CarryOp, NoCarryOp;
4032 switch(
N->getOpcode()) {
4047 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4048 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4052 SDValue LHSL, LHSH, RHSL, RHSH;
4053 GetExpandedInteger(
LHS, LHSL, LHSH);
4054 GetExpandedInteger(
RHS, RHSL, RHSH);
4055 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4056 SDValue LoOps[2] = { LHSL, RHSL };
4057 SDValue HiOps[3] = { LHSH, RHSH };
4059 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4061 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
4068 SplitInteger(Sum,
Lo,
Hi);
4074 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
4075 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
4079 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
4084 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
4090 ReplaceValueWith(
SDValue(
N, 1), Ovf);
4096 SDValue LHSL, LHSH, RHSL, RHSH;
4098 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4099 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4100 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4104 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4106 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4110 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4113void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4116 SDValue LHSL, LHSH, RHSL, RHSH;
4118 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4119 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4120 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4125 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4126 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4130 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4133void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4135 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4138 if (
Op.getValueType().bitsLE(NVT)) {
4141 Hi = DAG.getUNDEF(NVT);
4145 assert(getTypeAction(
Op.getValueType()) ==
4147 "Only know how to promote this result!");
4150 "Operand over promoted?");
4152 SplitInteger(Res,
Lo,
Hi);
4156void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4159 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4160 EVT NVT =
Lo.getValueType();
4165 if (NVTBits < EVTBits) {
4168 EVTBits - NVTBits)));
4173 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4177void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4180 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4181 EVT NVT =
Lo.getValueType();
4186 if (NVTBits < EVTBits) {
4189 EVTBits - NVTBits)));
4193 Hi = DAG.getConstant(0, dl, NVT);
4197void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4200 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4205void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4208 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4217 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4218 EVT NVT =
Lo.getValueType();
4221 Hi = DAG.getConstant(0, dl, NVT);
4224void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4226 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4229 const APInt &Cst =
Constant->getAPIntValue();
4230 bool IsTarget =
Constant->isTargetOpcode();
4231 bool IsOpaque =
Constant->isOpaque();
4233 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4234 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4242 GetExpandedInteger(N0,
Lo,
Hi);
4243 EVT NVT =
Lo.getValueType();
4248 unsigned NumSignBits = DAG.ComputeNumSignBits(N0);
4253 Lo = DAG.getNode(AbsOpc, dl, NVT,
Lo);
4254 Hi = DAG.getConstant(0, dl, NVT);
4264 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4269 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4270 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4279 EVT VT =
N->getValueType(0);
4281 DAG.getConstant(0, dl, VT), N0);
4283 SplitInteger(Neg, NegLo, NegHi);
4285 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4287 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4288 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4291void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4295 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4296 EVT NVT =
Lo.getValueType();
4298 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4301 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4304 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4305 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4308 Hi = DAG.getConstant(0, dl, NVT);
4316 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4317 EVT NVT =
Lo.getValueType();
4320 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4321 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4324 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4327 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4329 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4331 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4332 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4334 Hi = DAG.getConstant(0, dl, NVT);
4339 SplitInteger(Result,
Lo,
Hi);
4344 EVT VT =
N->getValueType(0);
4349 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4350 "LibCall explicitly requested, but not available");
4352 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4353 TargetLowering::MakeLibCallOptions CallOptions;
4357 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4358 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4366 GetExpandedInteger(
Op,
Lo,
Hi);
4367 EVT NVT =
Lo.getValueType();
4370 Hi = DAG.getConstant(0,
DL, NVT);
4373void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4377 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4378 EVT NVT =
Lo.getValueType();
4380 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4386 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4387 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4390 Hi = DAG.getConstant(0, dl, NVT);
4396 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4403 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4407 ReplaceValueWith(
SDValue(
N, 1), Chain);
4415 Chain =
Op.getValue(1);
4424 EVT VT =
N->getValueType(0);
4428 bool IsStrict =
N->isStrictFPOpcode();
4430 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4434 EVT SrcVT =
Op.getValueType();
4435 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4439 if (TLI.isTypeLegal(SrcVT) && MinIntBits <= NVT.
getSizeInBits()) {
4440 unsigned NewOpc = TLI.getPreferredFPToIntOpcode(
N->getOpcode(), SrcVT, NVT);
4442 Lo = DAG.getNode(NewOpc, dl, {NVT, MVT::Other}, {Chain,
Op});
4443 ReplaceValueWith(
SDValue(
N, 1),
Lo.getValue(1));
4445 Lo = DAG.getNode(NewOpc, dl, NVT,
Op);
4448 DAG.getShiftAmountConstant(
4450 : DAG.getConstant(0, dl, NVT);
4456 Op.getValueType() == MVT::bf16) {
4462 EVT OpVT =
Op.getValueType();
4466 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4467 TargetLowering::MakeLibCallOptions CallOptions;
4472 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4473 CallOptions, dl, Chain);
4474 SplitInteger(Tmp.first,
Lo,
Hi);
4477 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4482 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4483 SplitInteger(Res,
Lo,
Hi);
4489 bool IsStrict =
N->isStrictFPOpcode();
4490 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4493 EVT VT =
Op.getValueType();
4495 if (VT == MVT::f16) {
4501 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4504 LC = RTLIB::getLROUND(VT);
4505 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4508 LC = RTLIB::getLRINT(VT);
4509 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4512 LC = RTLIB::getLLROUND(VT);
4513 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4516 LC = RTLIB::getLLRINT(VT);
4517 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4521 EVT RetVT =
N->getValueType(0);
4523 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4524 if (LCImpl == RTLIB::Unsupported) {
4525 DAG.getContext()->emitError(Twine(
"no libcall available for ") +
4526 N->getOperationName(&DAG));
4528 SplitInteger(Poison,
Lo,
Hi);
4529 if (
N->isStrictFPOpcode())
4530 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
4534 TargetLowering::MakeLibCallOptions CallOptions;
4536 std::pair<SDValue, SDValue> Tmp =
4537 TLI.makeLibCall(DAG, LCImpl, RetVT,
Op, CallOptions, dl, Chain);
4538 SplitInteger(Tmp.first,
Lo,
Hi);
4540 if (
N->isStrictFPOpcode())
4541 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4544void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4546 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4549 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4555 EVT VT =
N->getValueType(0);
4556 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4561 MMOMetadata
Metadata =
N->getMMOMetadataForSubAccess();
4566 if (
N->getMemoryVT().bitsLE(NVT)) {
4567 EVT MemVT =
N->getMemoryVT();
4569 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4578 unsigned LoSize =
Lo.getValueSizeInBits();
4580 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4583 Hi = DAG.getConstant(0, dl, NVT);
4587 Hi = DAG.getUNDEF(NVT);
4589 }
else if (DAG.getDataLayout().isLittleEndian()) {
4591 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4594 unsigned ExcessBits =
4601 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4602 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4612 EVT MemVT =
N->getMemoryVT();
4615 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4618 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4627 N->getPointerInfo().getWithOffset(IncrementSize),
4641 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4645 DAG.getShiftAmountConstant(
4652 ReplaceValueWith(
SDValue(
N, 1), Ch);
4655void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4659 GetExpandedInteger(
N->getOperand(0), LL, LH);
4660 GetExpandedInteger(
N->getOperand(1), RL, RH);
4664 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4666 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4667 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4670void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4672 EVT VT =
N->getValueType(0);
4673 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4677 GetExpandedInteger(
N->getOperand(0), LL, LH);
4678 GetExpandedInteger(
N->getOperand(1), RL, RH);
4680 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4687 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4688 if (LCImpl == RTLIB::Unsupported) {
4691 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4697 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4698 TargetLowering::MakeLibCallOptions CallOptions;
4700 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4707 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4708 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4709 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4712 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4717 SplitInteger(Result,
Lo,
Hi);
4723 SplitInteger(Result,
Lo,
Hi);
4729 SplitInteger(Result,
Lo,
Hi);
4740 EVT VT =
N->getValueType(0);
4744 uint64_t Scale =
N->getConstantOperandVal(2);
4756 EVT BoolVT = getSetCCResultType(VT);
4758 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4764 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4765 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4771 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4772 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4777 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4778 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4781 SplitInteger(Result,
Lo,
Hi);
4787 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4789 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4791 GetExpandedInteger(
LHS, LL, LH);
4792 GetExpandedInteger(
RHS, RL, RH);
4796 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4803 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4804 SplitInteger(LoTmp, Result[0], Result[1]);
4805 SplitInteger(HiTmp, Result[2], Result[3]);
4807 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4810 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4811 "the size of the current value type");
4833 if (Scale % NVTSize) {
4834 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4837 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4849 if (Scale == VTSize)
4868 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4869 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4870 EVT BoolNVT = getSetCCResultType(NVT);
4873 if (Scale < NVTSize) {
4876 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4877 DAG.getShiftAmountConstant(Scale, NVT, dl));
4878 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4879 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4880 }
else if (Scale == NVTSize) {
4882 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4883 }
else if (Scale < VTSize) {
4886 DAG.getNode(
ISD::SRL, dl, NVT, ResultHH,
4887 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4888 SatMax = DAG.getSetCC(dl, BoolNVT, HHAdjusted, NVTZero,
ISD::SETNE);
4891 "(and saturation can't happen with Scale==VTSize).");
4893 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4894 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4898 if (Scale < NVTSize) {
4903 unsigned OverflowBits = VTSize - Scale + 1;
4904 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4905 "Extent of overflow bits must start within HL");
4906 SDValue HLHiMask = DAG.getConstant(
4908 SDValue HLLoMask = DAG.getConstant(
4915 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4921 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4922 }
else if (Scale == NVTSize) {
4928 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4934 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4935 }
else if (Scale < VTSize) {
4938 unsigned OverflowBits = VTSize - Scale + 1;
4939 SDValue HHHiMask = DAG.getConstant(
4941 SDValue HHLoMask = DAG.getConstant(
4943 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4944 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4951 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4952 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4955 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4956 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4963 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4965 N->getConstantOperandVal(2), DAG);
4969 N->getConstantOperandVal(2), TLI, DAG);
4970 SplitInteger(Res,
Lo,
Hi);
4973void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4976 "Node has unexpected Opcode");
4986 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4987 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4991 SDValue LHSL, LHSH, RHSL, RHSH;
4992 GetExpandedInteger(
LHS, LHSL, LHSH);
4993 GetExpandedInteger(
RHS, RHSL, RHSH);
4994 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4997 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
5006 SplitInteger(Sum,
Lo,
Hi);
5031 EVT VT =
LHS.getValueType();
5034 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
5038 EVT OType =
Node->getValueType(1);
5039 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
5043 ReplaceValueWith(
SDValue(Node, 1), Ovf);
5046void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
5048 EVT VT =
N->getValueType(0);
5050 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5059 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
5061 TargetLowering::MakeLibCallOptions CallOptions;
5063 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5066void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
5069 SDValue Shiftee =
N->getOperand(0);
5076 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
5077 }
while (!TLI.isTypeLegal(LoadVT));
5082 "Shifting unit is not a a power of two!");
5084 const bool IsOneStepShift =
5085 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
5090 if (!IsOneStepShift)
5091 ShAmt = DAG.getFreeze(ShAmt);
5094 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
5095 unsigned VTByteWidth = VTBitWidth / 8;
5097 "Shiftee type size is not a power of two!");
5098 unsigned StackSlotByteWidth = 2 * VTByteWidth;
5099 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
5104 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
5106 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
5107 EVT PtrTy =
StackPtr.getValueType();
5108 SDValue Ch = DAG.getEntryNode();
5111 DAG.getMachineFunction(),
5117 unsigned WideningOpc =
5119 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
5122 SDValue AllZeros = DAG.getConstant(0, dl, VT);
5126 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
5132 Flags.setExact(IsOneStepShift);
5135 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
5137 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
5138 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
5141 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5146 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5153 if (DAG.getDataLayout().isBigEndian())
5154 WillIndexUpwards = !WillIndexUpwards;
5157 if (WillIndexUpwards) {
5160 AdjStackPtr = DAG.getMemBasePlusOffset(
5161 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5162 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5166 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5167 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5171 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5176 if (!IsOneStepShift) {
5178 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5179 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5180 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5184 SplitInteger(Res,
Lo,
Hi);
5187void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5189 EVT VT =
N->getValueType(0);
5190 unsigned Opc =
N->getOpcode();
5196 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5200 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5217 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5219 const bool LegalOrCustom =
5223 unsigned ExpansionFactor = 1;
5225 for (EVT TmpVT = NVT;;) {
5226 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5227 if (NewTMPVT == TmpVT)
5234 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5237 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5239 if (LegalOrCustom &&
5243 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5249 SDValue ShiftOp =
N->getOperand(1);
5250 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5252 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5255 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5256 Hi =
Lo.getValue(1);
5261 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5275 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5278 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5280 TargetLowering::MakeLibCallOptions CallOptions;
5283 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5288 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5292void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5294 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5297 if (
Op.getValueType().bitsLE(NVT)) {
5303 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5307 assert(getTypeAction(
Op.getValueType()) ==
5309 "Only know how to promote this result!");
5312 "Operand over promoted?");
5314 SplitInteger(Res,
Lo,
Hi);
5322void DAGTypeLegalizer::
5325 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5328 if (EVT.
bitsLE(
Lo.getValueType())) {
5336 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5337 Hi.getValueType(), dl));
5348void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5350 EVT VT =
N->getValueType(0);
5352 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5361 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5363 TargetLowering::MakeLibCallOptions CallOptions;
5365 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5368void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5370 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5380void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5382 EVT VT =
N->getValueType(0);
5401 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5402 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5403 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5405 EVT BitVT =
N->getValueType(1);
5406 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5408 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5410 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5411 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5430 SplitInteger(Three,
Lo,
Hi);
5434 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5439 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5444 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5448 if (LCImpl == RTLIB::Unsupported ||
5450 DAG.getMachineFunction().getName()) {
5453 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5454 N->getOperand(1), MulLo, MulHi);
5459 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5460 SplitInteger(MulLo,
Lo,
Hi);
5461 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5465 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5468 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5469 MachinePointerInfo());
5473 EVT ArgVT =
Op.getValueType();
5475 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5476 Entry.IsSExt =
true;
5477 Entry.IsZExt =
false;
5478 Args.push_back(Entry);
5482 TargetLowering::ArgListEntry
Entry(
5484 Entry.IsSExt =
true;
5485 Entry.IsZExt =
false;
5486 Args.push_back(Entry);
5488 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5490 TargetLowering::CallLoweringInfo CLI(DAG);
5493 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5494 Func, std::move(Args))
5497 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5499 SplitInteger(CallInfo.first,
Lo,
Hi);
5501 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5502 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5503 DAG.getConstant(0, dl, PtrVT),
5506 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5509void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5511 EVT VT =
N->getValueType(0);
5513 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5523 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5525 if (isTypeLegal(NVT)) {
5527 GetExpandedInteger(
N->getOperand(0), InL, InH);
5529 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5538 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5540 TargetLowering::MakeLibCallOptions CallOptions;
5541 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5544void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5546 EVT VT =
N->getValueType(0);
5548 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5558 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5560 if (isTypeLegal(NVT)) {
5562 GetExpandedInteger(
N->getOperand(0), InL, InH);
5564 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5573 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5575 TargetLowering::MakeLibCallOptions CallOptions;
5576 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5579void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5581 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5584 if (
Op.getValueType().bitsLE(NVT)) {
5587 Hi = DAG.getConstant(0, dl, NVT);
5591 assert(getTypeAction(
Op.getValueType()) ==
5593 "Only know how to promote this result!");
5596 "Operand over promoted?");
5598 SplitInteger(Res,
Lo,
Hi);
5600 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5606void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5610 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5621void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5625 SDValue Res = TLI.expandVecReduce(
N, DAG);
5626 SplitInteger(Res,
Lo,
Hi);
5629void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5635 N->getOperand(0),
N->getOperand(1));
5636 SplitInteger(Res,
Lo,
Hi);
5643 GetExpandedInteger(
N->getOperand(0), In3, In4);
5644 GetExpandedInteger(
N->getOperand(1), In1, In2);
5648 unsigned Opc =
N->getOpcode();
5651 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5656 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5658 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5662 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5663 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5668 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5669 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5674 SDValue Res = TLI.expandCLMUL(
N, DAG);
5675 return SplitInteger(Res,
Lo,
Hi);
5679 GetExpandedInteger(
N->getOperand(0), LL, LH);
5680 GetExpandedInteger(
N->getOperand(1), RL, RH);
5694 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5698 SDValue Res = TLI.expandPEXT(
N, DAG);
5699 SplitInteger(Res,
Lo,
Hi);
5703 SDValue Res = TLI.expandPDEP(
N, DAG);
5704 SplitInteger(Res,
Lo,
Hi);
5708 SDValue Res = TLI.expandMULH(
N, DAG);
5709 SplitInteger(Res,
Lo,
Hi);
5714 EVT VT =
N->getValueType(0);
5721 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5724 SplitInteger(Res,
Lo,
Hi);
5731 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5732 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5734 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5735 Lo = DAG.getPOISON(LoVT);
5736 Hi = DAG.getPOISON(HiVT);
5743 EVT VT =
N->getSimpleValueType(0);
5744 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5746 "VectorIdxTy should be smaller than type to be expanded?");
5750 SplitInteger(Res,
Lo,
Hi);
5761bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5765 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5768 switch (
N->getOpcode()) {
5771 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5772 N->dump(&DAG);
dbgs() <<
"\n";
5777 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5781 Res = ExpandOp_FAKE_USE(
N);
5785 Res = TLI.expandLoopDependenceMask(
N, DAG);
5791 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5804 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5809 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5813 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5816 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5818 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5819 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5820 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5823 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5828 if (!Res.
getNode())
return false;
5836 "Invalid operand expansion");
5838 ReplaceValueWith(
SDValue(
N, 0), Res);
5844void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5848 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5849 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5850 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5863 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5870 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5871 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5901 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5902 RHSLo, LowCC,
false, DagCombineInfo, dl);
5904 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5907 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5908 RHSHi, CCCode,
false, DagCombineInfo, dl);
5912 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5921 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5923 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5932 if (LHSHi == RHSHi) {
5941 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5942 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5945 if (HasSETCCCARRY) {
5948 bool FlipOperands =
false;
5965 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5969 DAG.getCondCode(CCCode));
5975 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5976 false, DagCombineInfo, dl);
5979 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5980 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5987 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5992 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5997 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5998 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5999 N->getOperand(4)), 0);
6005 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6010 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
6015 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
6016 N->getOperand(2),
N->getOperand(3),
6017 DAG.getCondCode(CCCode)), 0);
6023 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6028 "Unexpected setcc expansion!");
6034 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
6042 SDLoc dl = SDLoc(
N);
6044 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
6045 GetExpandedInteger(
LHS, LHSLo, LHSHi);
6046 GetExpandedInteger(
RHS, RHSLo, RHSHi);
6059 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6069 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
6070 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
6074 return TLI.expandCMP(
N, DAG);
6082 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6083 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
6087 bool IsStrict =
N->isStrictFPOpcode();
6091 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
6092 EVT DstVT =
N->getValueType(0);
6095 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
6096 "Don't know how to expand this XINT_TO_FP!");
6097 TargetLowering::MakeLibCallOptions CallOptions;
6099 std::pair<SDValue, SDValue> Tmp =
6100 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
6105 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
6106 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
6111 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
6114 return ExpandOp_NormalStore(
N, OpNo);
6117 assert(OpNo == 1 &&
"Can only expand the stored value so far");
6119 EVT VT =
N->getOperand(1).getValueType();
6120 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6124 MMOMetadata
Metadata =
N->getMMOMetadataForSubAccess();
6130 if (
N->getMemoryVT().bitsLE(NVT)) {
6131 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6132 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
6133 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
6137 if (DAG.getDataLayout().isLittleEndian()) {
6139 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6141 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
6144 unsigned ExcessBits =
6151 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
6152 N->getPointerInfo().getWithOffset(IncrementSize),
6153 NEVT,
N->getBaseAlign(), MMOFlags,
Metadata);
6159 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6161 EVT ExtVT =
N->getMemoryVT();
6164 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6172 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6176 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6180 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6186 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6187 N->getPointerInfo().getWithOffset(IncrementSize),
6195 GetExpandedInteger(
N->getOperand(0), InL, InH);
6204 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6206 return Swap.getValue(1);
6209SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6210 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6211 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6215 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6217 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6220SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6223 "cannot use llvm.write_register with illegal type", Fn,
6226 return N->getOperand(0);
6229SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6232 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6233 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6234 EVT OutVT =
V0.getValueType();
6236 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0,
V1,
N->getOperand(2));
6239SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REPEAT(
SDNode *
N) {
6242 EVT OutVT =
N->getValueType(0);
6243 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6248 return DAG.getNode(
N->getOpcode(),
DL, NOutVT,
Op);
6251SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6253 unsigned Factor =
N->getNumOperands();
6256 for (
unsigned i = 0; i != Factor; i++)
6257 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6262 for (
unsigned i = 0; i != Factor; i++)
6268SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6270 EVT OutVT =
N->getValueType(0);
6271 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6272 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6276 SDValue BaseIdx =
N->getOperand(1);
6293 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6297 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6303 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6312 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6316 "Promoted operand has an element type greater than result");
6329 InOp0 = GetPromotedInteger(InOp0);
6336 Ops.reserve(OutNumElems);
6337 for (
unsigned i = 0; i != OutNumElems; ++i) {
6342 N->getOperand(0), Index);
6343 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6348 return DAG.getBuildVector(NOutVT, dl,
Ops);
6351SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6352 EVT OutVT =
N->getValueType(0);
6353 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6354 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6366 Vec = GetPromotedInteger(Vec);
6372SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6375 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6376 EVT OutVT =
V0.getValueType();
6381SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6383 EVT VT =
N->getValueType(0);
6388 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6389 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6390 EVT OutVT =
V0.getValueType();
6392 return DAG.getVectorShuffle(OutVT, dl, V0,
V1, NewMask);
6396 EVT OutVT =
N->getValueType(0);
6397 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6398 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6399 unsigned NumElems =
N->getNumOperands();
6406 Ops.reserve(NumElems);
6407 for (
unsigned i = 0; i != NumElems; ++i) {
6409 EVT OpVT =
Op.getValueType();
6414 if (OpVT.
bitsLT(NOutVTElem)) {
6420 ExtOpc = NOutExtOpc;
6421 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6426 return DAG.getBuildVector(NOutVT, dl,
Ops);
6433 assert(!
N->getOperand(0).getValueType().isVector() &&
6434 "Input must be a scalar");
6436 EVT OutVT =
N->getValueType(0);
6437 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6438 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6442 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6447 EVT OutVT =
N->getValueType(0);
6448 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6450 "Type must be promoted to a scalable vector type");
6451 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6452 return DAG.getStepVector(dl, NOutVT,
6456SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6459 EVT OutVT =
N->getValueType(0);
6460 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6461 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6463 unsigned NumOperands =
N->getNumOperands();
6467 EVT OpVT =
N->getOperand(0).getValueType();
6472 "Unhandled legalization type");
6478 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6481 Op = GetPromotedInteger(
Op);
6490 *DAG.getContext(),
Ops[0].getValueType().getVectorElementType());
6491 return DAG.getAnyExtOrTrunc(
6495 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6496 assert(NumElem * NumOperands == NumOutElem &&
6497 "Unexpected number of elements");
6501 for (
unsigned i = 0; i < NumOperands; ++i) {
6504 Op = GetPromotedInteger(
Op);
6505 EVT SclrTy =
Op.getValueType().getVectorElementType();
6506 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6507 "Unexpected number of elements");
6509 for (
unsigned j = 0;
j < NumElem; ++
j) {
6511 DAG.getVectorIdxConstant(j, dl));
6512 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6516 return DAG.getBuildVector(NOutVT, dl,
Ops);
6519SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6520 EVT VT =
N->getValueType(0);
6521 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6522 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6530 if (getTypeAction(
N->getOperand(0).getValueType())
6534 switch(
N->getOpcode()) {
6536 Promoted = SExtPromotedInteger(
N->getOperand(0));
6539 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6542 Promoted = GetPromotedInteger(
N->getOperand(0));
6554 DAG.getVectorIdxConstant(0, dl));
6556 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6560 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6563SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6564 EVT VT =
N->getValueType(0);
6565 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6569SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6570 EVT VT =
N->getValueType(0);
6571 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6575SDValue DAGTypeLegalizer::PromoteIntRes_MASK_BEFOREFIRST(
SDNode *
N) {
6576 EVT VT =
N->getValueType(0);
6577 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6578 SDValue Op = PromoteTargetBoolean(
N->getOperand(0), NVT);
6583 EVT VT =
N->getValueType(0);
6584 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6586 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2), NVT);
6590SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6592 EVT VT =
N->getValueType(0);
6593 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6594 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6595 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6599SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6600 EVT OutVT =
N->getValueType(0);
6601 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6602 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6607 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6610 NOutVTElem,
N->getOperand(1));
6612 V0, ConvElem,
N->getOperand(2));
6619 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6620 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6628 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6629 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6630 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6634 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6637 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6638 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6646 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6651SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6654 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6656 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6657 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6658 return DAG.getPOISON(NVT);
6661SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6663 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6664 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6665 TLI.getVectorIdxTy(DAG.getDataLayout()));
6667 V0->getValueType(0).getScalarType(), V0,
V1);
6672 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6675SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6680 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6683 V1.getValueType().getVectorElementType(),
6684 V0.getValueType().getVectorElementCount());
6685 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6687 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6696 EVT InVT1 =
V1.getValueType();
6699 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1),
V1);
6700 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6703SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6705 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6706 MVT InVT =
V0.getValueType().getSimpleVT();
6713SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6716 EVT ResVT =
N->getValueType(0);
6717 unsigned NumElems =
N->getNumOperands();
6720 EVT PromotedOpTy = TLI.getTypeToTransformTo(*DAG.getContext(),
6721 N->getOperand(0).getValueType());
6724 if (isTypeLegal(WideVT)) {
6731 return DAG.getAnyExtOrTrunc(WideConcat, dl, ResVT);
6735 SDValue ResVec = DAG.getPOISON(ResVT);
6737 for (
unsigned OpIdx = 0; OpIdx < NumElems; ++OpIdx) {
6739 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6741 DAG.getIntPtrConstant(OpIdx * OpNumElts, dl));
6750 DAG.ExtractVectorElements(GetPromotedInteger(
Op), NewOps);
6751 return DAG.getBuildVector(ResVT, dl, NewOps);
6754SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6767 for (
unsigned I = 0;
I < OpNo;
I++)
6770 EVT Ty =
Op.getValueType();
6771 SDLoc
DL = SDLoc(
N);
6774 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6782 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6787 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6793SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6806 for (
unsigned I = 0;
I < OpNo;
I++)
6809 EVT Ty =
Op.getValueType();
6810 SDLoc
DL = SDLoc(
N);
6813 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6821 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6826 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool isSigned(unsigned Opcode)
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static SDValue SaturateWidenedDIVFIX(SDValue V, SDLoc &dl, unsigned SatW, bool Signed, const TargetLowering &TLI, SelectionDAG &DAG)
static SDValue fpExtendHelper(SDValue Op, SDValue &Chain, bool IsStrict, EVT VT, SDLoc DL, SelectionDAG &DAG)
static SDValue earlyExpandDIVFIX(SDNode *N, SDValue LHS, SDValue RHS, unsigned Scale, const TargetLowering &TLI, SelectionDAG &DAG, unsigned SatW=0)
static unsigned getExtendForIntVecReduction(SDNode *N)
static std::pair< ISD::CondCode, ISD::NodeType > getExpandedMinMaxOps(int Op)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
SmallVector< MachineOperand, 4 > Cond
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This file describes how to lower LLVM code to machine code.
static LLVM_ABI unsigned int semanticsIntSizeInBits(const fltSemantics &, bool)
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
unsigned getActiveBits() const
Compute the number of active bits in the value.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
unsigned countLeadingOnes() const
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned countTrailingZeros() const
unsigned countLeadingZeros() const
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
unsigned countTrailingOnes() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
This is an SDNode representing atomic operations.
const APInt & getValue() const
Return the constant as an APInt value reference.
const ConstantInt * getConstantIntValue() const
uint64_t getZExtValue() const
@ NewNode
This is a new node, not before seen, that was created in the process of legalizing some other node.
constexpr bool isPowerOf2() const
const Function & getFunction() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This class is used to represent ISD::LOAD nodes.
unsigned getVectorNumElements() const
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
Flags
Flags values. These may be or'd together.
This class is used to represent an MGATHER node.
This class is used to represent an MLOAD node.
This class is used to represent an MSCATTER node.
This class is used to represent an MSTORE node.
MachineMemOperand * getMemOperand() const
Return the unique MachineMemOperand object describing the memory reference performed by operation.
EVT getMemoryVT() const
Return the type of the in-memory value.
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
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.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
ISD::CondCode getOperandCondCode(unsigned Num) const
Helper method returns the CondCode of a CondCodeSDNode.
SDNodeFlags getFlags() const
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
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.
uint64_t getScalarValueSizeInBits() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT, unsigned Opcode)
Convert Op, which must be of integer type, to the integer type VT, by either any/sign/zero-extending ...
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVM_ABI SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
LLVMContext * getContext() const
void reserve(size_type N)
void push_back(const T &Elt)
This class is used to represent ISD::STORE nodes.
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
ShiftLegalizationStrategy
Return the preferred strategy to legalize tihs SHIFT instruction, with ExpansionFactor being the recu...
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
@ TypeScalarizeScalableVector
BooleanContent
Enum that describes how the target represents true/false values.
@ ZeroOrOneBooleanContent
@ UndefinedBooleanContent
@ ZeroOrNegativeOneBooleanContent
std::vector< ArgListEntry > ArgListTy
static ISD::NodeType getExtendForContent(BooleanContent Content)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
static constexpr TypeSize getFixed(ScalarTy ExactSize)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
This class is used to represent a VP_LOAD node.
This class is used to represent a VP_STORE node.
constexpr bool hasKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns true if there exists a value X where RHS*X will result in a value whose quantity matches our ...
constexpr ScalarTy getKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns a value X where RHS*X will result in a value whose quantity matches our own.
constexpr LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
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.
bool isNON_EXTLoad(const SDNode *N)
Returns true if the specified node is a non-extending load.
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.
@ PARTIAL_REDUCE_SMLA
PARTIAL_REDUCE_[U|S]MLA(Accumulator, Input1, Input2) The partial reduction nodes sign or zero extend ...
@ LOOP_DEPENDENCE_RAW_MASK
@ MASK_BEFOREFIRST
Has one mask vector operand.
@ COND_LOOP
COND_LOOP is a conditional branch to self, used for implementing efficient conditional traps.
@ MLOAD
Masked load and store - consecutive vector load and store operations with additional mask operand tha...
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
@ BSWAP
Byte Swap and Counting operators.
@ SMULFIX
RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same...
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, val, ptr) This corresponds to "store atomic" instruction.
@ ADDC
Carry-setting nodes for multiple precision addition and subtraction.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ SMULFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ CTTZ_ELTS
Returns the number of number of trailing (least significant) zero elements in a vector.
@ VECTOR_FIND_LAST_ACTIVE
Finds the index of the last active mask element Operands: Mask.
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ VECTOR_SHUFFLE_VAR
VECTOR_SHUFFLE_VAR(VEC, MASK) - Returns VEC permuted by MASK, an integer vector with the same number ...
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ 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.
@ CLMUL
Carry-less multiplication operations.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ CONVERT_FROM_ARBITRARY_FP
CONVERT_FROM_ARBITRARY_FP - This operator converts from an arbitrary floating-point represented as an...
@ SET_ROUNDING
Set rounding mode.
@ SIGN_EXTEND
Conversion operators.
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ READSTEADYCOUNTER
READSTEADYCOUNTER - This corresponds to the readfixedcounter intrinsic.
@ SETCCCARRY
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
@ BR_CC
BR_CC - Conditional branch.
@ SSUBO
Same for subtraction.
@ VECTOR_INTERLEAVE
VECTOR_INTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor to...
@ STEP_VECTOR
STEP_VECTOR(IMM) - Returns a scalable vector whose lanes are comprised of a linear sequence of unsign...
@ IS_FPCLASS
Performs a check of floating point class property, defined by IEEE-754.
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
@ 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,...
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ GET_ACTIVE_LANE_MASK
GET_ACTIVE_LANE_MASK - this corrosponds to the llvm.get.active.lane.mask intrinsic.
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ ARITH_FENCE
ARITH_FENCE - This corresponds to a arithmetic fence intrinsic.
@ CTLS
Count leading redundant sign bits.
@ VECREDUCE_ADD
Integer reductions may have a result type larger than the vector element type.
@ GET_ROUNDING
Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest, ties to even 2 Round to ...
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ READ_REGISTER
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
@ 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) ...
@ VSCALE
VSCALE(IMM) - Returns the runtime scaling factor used to calculate the number of elements within a sc...
@ ATOMIC_CMP_SWAP
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo,...
@ SSHLSAT
RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift.
@ PATCHPOINT
The llvm.experimental.patchpoint.
@ SMULO
Same for multiplication.
@ VECTOR_SPLICE_LEFT
VECTOR_SPLICE_LEFT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1, VEC2) left by OFFSET elements an...
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ MASKED_UDIV
Masked vector arithmetic that returns poison on disabled lanes.
@ VECTOR_REVERSE
VECTOR_REVERSE(VECTOR) - Returns a vector, of the same type as VECTOR, whose elements are shuffled us...
@ SDIVFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ STRICT_SINT_TO_FP
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
@ MGATHER
Masked gather and scatter - load and store operations for a vector of random addresses with additiona...
@ BF16_TO_FP
BF16_TO_FP, FP_TO_BF16 - These operators are used to perform promotions and truncation for bfloat16.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ PEXT
Parallel bit extract (compress) and parallel bit deposit (expand).
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
@ 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.
@ SCMP
[US]CMP - 3-way comparison of signed or unsigned integers.
@ AVGFLOORS
AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of type i[N+1],...
@ VECTOR_MATCH
VECTOR_MATCH - this corresponds to the llvm.experimental.vector.match intrinsic.
@ VECTOR_SPLICE_RIGHT
VECTOR_SPLICE_RIGHT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1,VEC2) right by OFFSET elements a...
@ ADDE
Carry-using nodes for multiple precision addition and subtraction.
@ STACKMAP
The llvm.experimental.stackmap intrinsic.
@ SPLAT_VECTOR_PARTS
SPLAT_VECTOR_PARTS(SCALAR1, SCALAR2, ...) - Returns a vector with the scalar values joined together a...
@ FREEZE
FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or is evaluated to UNDEF),...
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
@ CTTZ_ZERO_POISON
Bit counting operators with a poisoned result for zero inputs.
@ FFREXP
FFREXP - frexp, extract fractional and exponent component of a floating-point value.
@ VECTOR_COMPRESS
VECTOR_COMPRESS(Vec, Mask, Passthru) consecutively place vector elements based on mask e....
@ ZERO_EXTEND_VECTOR_INREG
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
@ EXPERIMENTAL_VECTOR_HISTOGRAM
Experimental vector histogram intrinsic Operands: Input Chain, Inc, Mask, Base, Index,...
@ 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.
@ BRCOND
BRCOND - Conditional branch.
@ CONVERT_TO_ARBITRARY_FP
CONVERT_TO_ARBITRARY_FP - Converts a native FP value to an arbitrary floating-point format,...
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ VECTOR_REPEAT
VECTOR_REPEAT(FIXED_LENGTH_VECTOR) Repeatedly copies the elements of the source fixed-length vector t...
@ VECTOR_DEINTERLEAVE
VECTOR_DEINTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor ...
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ SADDO_CARRY
Carry-using overflow-aware nodes for multiple precision addition and subtraction.
@ ABS_MIN_POISON
ABS with a poison result for INT_MIN.
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
@ LOOP_DEPENDENCE_WAR_MASK
The llvm.loop.dependence.
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
bool isTrueWhenEqual(CondCode Cond)
Return true if the specified condition returns true if the two operands to the condition are equal.
bool isUNINDEXEDLoad(const SDNode *N)
Returns true if the specified node is an unindexed load.
bool isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
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,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
bool isUnsignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs an unsigned comparison when used with intege...
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
bool isIntEqualitySetCC(CondCode Code)
Return true if this is a setcc instruction that performs an equality comparison when used with intege...
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 getUREM(EVT VT)
LLVM_ABI Libcall getSHL(EVT VT)
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 getSDIV(EVT VT)
LLVM_ABI Libcall getSRL(EVT VT)
LLVM_ABI Libcall getSRA(EVT VT)
LLVM_ABI Libcall getUDIV(EVT VT)
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 getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSREM(EVT VT)
LLVM_ABI Libcall getMUL(EVT VT)
LLVM_ABI AtomicLibcall selectAtomicLibcall(const LibcallLoweringInfo &Libcalls, unsigned Opc, AtomicOrdering Order, MVT VT)
Lower to outline atomic libcall if outline atomics enabled, or to sync libcall otherwise.
LLVM_ABI Libcall getCTPOP(EVT VT)
LLVM_ABI Libcall getMULO(EVT VT)
NodeAddr< NodeBase * > Node
NodeAddr< FuncNode * > Func
Type * getValueType(Value *V, bool ReVec, bool LookThroughCmp)
Returns the "element type" of the given value/instruction V.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
@ Known
Known to have no common set bits.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr T alignDown(U Value, V Align, W Skew=0)
Returns the largest unsigned integer less than or equal to Value and is Skew mod Align.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
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...
@ Success
The lock was released successfully.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
LLVM_ABI bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
ElementCount getVectorElementCount() const
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.
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
uint64_t getScalarSizeInBits() const
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
EVT changeVectorElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
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.
EVT changeVectorElementCount(LLVMContext &Context, ElementCount EC) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element coun...
bool isFixedLengthVector() const
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
bool bitsEq(EVT VT) const
Return true if this has the same number of bits as VT.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
EVT changeElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a type whose attributes match ourselves with the exception of the element type that i...
LLVM_ABI const fltSemantics & getFltSemantics() const
Returns an APFloat semantics tag appropriate for the value type.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
static LLVM_ABI MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
static StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl)
Get the libcall routine name for the specified libcall implementation.
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT)
MakeLibCallOptions & setIsSigned(bool Value=true)