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);
96 Res = PromoteIntRes_Select(
N);
101 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
103 case ISD::SMAX: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
105 case ISD::UMAX: Res = PromoteIntRes_UMINUMAX(
N);
break;
107 case ISD::SHL: Res = PromoteIntRes_SHL(
N);
break;
109 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
110 case ISD::SRA: Res = PromoteIntRes_SRA(
N);
break;
111 case ISD::SRL: Res = PromoteIntRes_SRL(
N);
break;
114 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
115 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
119 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
121 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
123 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
125 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
128 Res = PromoteIntRes_VECTOR_SPLICE(
N);
132 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
135 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
137 Res = PromoteIntRes_BUILD_VECTOR(
N);
141 Res = PromoteIntRes_ScalarOp(
N);
145 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
150 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
153 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
157 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
160 Res = PromoteIntRes_VECTOR_MATCH(
N);
166 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
180 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
184 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
187 Res = PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
N);
191 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
200 case ISD::MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
208 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
216 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
220 Res = PromoteIntRes_ZExtMaskedIntBinOp(
N);
224 Res = PromoteIntRes_SExtMaskedIntBinOp(
N);
228 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
230 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
232 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
248 Res = PromoteIntRes_ADDSUBSHLSAT(
N);
253 Res = PromoteIntRes_CMP(
N);
268 Res = PromoteIntRes_ABS(
N);
302 Res = PromoteIntRes_VECREDUCE(
N);
305 case ISD::VP_REDUCE_ADD:
306 case ISD::VP_REDUCE_MUL:
307 case ISD::VP_REDUCE_AND:
308 case ISD::VP_REDUCE_OR:
309 case ISD::VP_REDUCE_XOR:
310 case ISD::VP_REDUCE_SMAX:
311 case ISD::VP_REDUCE_SMIN:
312 case ISD::VP_REDUCE_UMAX:
313 case ISD::VP_REDUCE_UMIN:
314 Res = PromoteIntRes_VP_REDUCE(
N);
319 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
323 Res = PromoteIntRes_FREEZE(
N);
328 Res = PromoteIntRes_Rotate(
N);
333 Res = PromoteIntRes_FunnelShift(
N);
339 Res = PromoteIntRes_CLMUL(
N);
343 Res = PromoteIntRes_PEXT(
N);
347 Res = PromoteIntRes_PDEP(
N);
351 Res = PromoteIntRes_IS_FPCLASS(
N);
354 Res = PromoteIntRes_FFREXP(
N);
359 Res = PromoteIntRes_XRINT(
N);
363 Res = PromoteIntRes_PATCHPOINT(
N);
366 Res = PromoteIntRes_READ_REGISTER(
N);
372 SetPromotedInteger(
SDValue(
N, ResNo), Res);
377 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
378 return GetPromotedInteger(
Op);
381SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
383 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
384 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
389 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
391 Op.getValueType(),
Op,
N->getOperand(1));
396 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
398 Op.getValueType(),
Op,
N->getOperand(1));
402 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
405 switch (TLI.getExtendForAtomicOps()) {
421 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
422 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
432 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
434 Op2 = SExtPromotedInteger(Op2);
437 Op2 = ZExtPromotedInteger(Op2);
440 Op2 = GetPromotedInteger(Op2);
445 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
447 N->getChain(),
N->getBasePtr(),
448 Op2,
N->getMemOperand());
459 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
460 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
464 if (!TLI.isTypeLegal(SVT))
467 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
468 SDValue Res = DAG.getAtomicCmpSwap(
470 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
474 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
480 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
481 switch (TLI.getExtendForAtomicCmpSwapArg()) {
483 Op2 = SExtPromotedInteger(Op2);
486 Op2 = ZExtPromotedInteger(Op2);
489 Op2 = GetPromotedInteger(Op2);
496 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
497 SDValue Res = DAG.getAtomicCmpSwap(
498 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
499 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
501 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
509 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
510 EVT OutVT =
N->getValueType(0);
511 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
514 switch (getTypeAction(InVT)) {
520 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
524 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
527 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
535 BitConvertToInteger(GetScalarizedVector(InOp)));
544 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
545 Lo = BitConvertToInteger(
Lo);
546 Hi = BitConvertToInteger(
Hi);
548 if (DAG.getDataLayout().isBigEndian())
554 JoinIntegers(
Lo,
Hi));
569 if (DAG.getDataLayout().isBigEndian()) {
573 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
588 if (isTypeLegal(WideOutVT)) {
589 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
591 DAG.getVectorIdxConstant(0, dl));
600 DAG.getDataLayout().isLittleEndian()) {
611 if (isTypeLegal(WideVecVT)) {
613 DAG.getUNDEF(WideVecVT), InOp,
614 DAG.getVectorIdxConstant(0, dl));
622 CreateStackStoreLoad(InOp, OutVT));
626 SDValue V = GetPromotedInteger(
N->getOperand(0));
628 V.getValueType(), V);
632 SDValue Op = GetPromotedInteger(
N->getOperand(0));
633 EVT OVT =
N->getValueType(0);
634 EVT NVT =
Op.getValueType();
642 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
643 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
648 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
654 SDValue Op = GetPromotedInteger(
N->getOperand(0));
655 EVT OVT =
N->getValueType(0);
656 EVT NVT =
Op.getValueType();
665 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
670 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
679 TLI.getTypeToTransformTo(*DAG.getContext(),
680 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
685 EVT VT =
N->getValueType(0);
692 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
699 EVT OVT =
N->getValueType(0);
700 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
706 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
707 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
709 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
715 unsigned CtlzOpcode =
N->getOpcode();
718 SDValue ExtractLeadingBits = DAG.getConstant(
721 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
725 return DAG.getNode(
ISD::SUB, dl, NVT,
726 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
731 SDValue Op = GetPromotedInteger(
N->getOperand(0));
735 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
737 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
743 EVT OVT =
N->getValueType(0);
744 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
747 SDValue ExtractLeadingBits = DAG.getConstant(
750 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
756 EVT OVT =
N->getValueType(0);
757 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
765 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
766 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
773 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
774 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
778 SDValue Op = GetPromotedInteger(
N->getOperand(0));
779 EVT OVT =
N->getValueType(0);
780 EVT NVT =
Op.getValueType();
787 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
788 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
792 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
798 unsigned NewOpc =
N->getOpcode();
805 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
808 return DAG.getNode(NewOpc, dl, NVT,
Op);
811SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
813 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
814 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
817SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
819 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
826 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
832 EVT SVT =
In.getValueType().getScalarType();
835 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
843 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
845 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
849 if (
N->isStrictFPOpcode()) {
850 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
851 {
N->getOperand(0),
N->getOperand(1)});
856 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
871 DAG.getValueType(
N->getValueType(0).getScalarType()));
874SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
876 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
878 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
882SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
883 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
886 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
891SDValue DAGTypeLegalizer::PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
SDNode *
N) {
892 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
896 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
899SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
900 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
903 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
904 N->getOperand(0),
N->getOperand(1));
910 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
912 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
916 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
920 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
929 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
932 if (getTypeAction(
N->getOperand(0).getValueType())
934 SDValue Res = GetPromotedInteger(
N->getOperand(0));
943 DAG.getValueType(
N->getOperand(0).getValueType()));
945 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
952 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
957 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
961 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
962 N->getMemoryVT(),
N->getMemOperand());
971 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
972 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
975 :
N->getExtensionType();
978 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
979 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
980 N->getMemOperand(),
N->isExpandingLoad());
988 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
989 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
996 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
997 N->getOffset(),
N->getMask(), ExtPassThru,
998 N->getMemoryVT(),
N->getMemOperand(),
999 N->getAddressingMode(), ExtType,
1000 N->isExpandingLoad());
1008 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1009 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1011 "Gather result type and the passThru argument type should be the same");
1018 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1019 N->getIndex(),
N->getScale() };
1020 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1021 N->getMemoryVT(), dl,
Ops,
1022 N->getMemOperand(),
N->getIndexType(),
1030SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1031 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1032 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1034 N->getOperand(1), Passthru);
1041 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1042 EVT VT =
N->getValueType(0);
1043 EVT SVT = getSetCCResultType(VT);
1044 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1045 unsigned NumOps =
N->getNumOperands();
1048 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1056 ReplaceValueWith(
SDValue(
N, 0), Res);
1059 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1080 SExtOrZExtPromotedOperands(Op1, Op2);
1086 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1088 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1089 Op1 = SExtPromotedInteger(Op1);
1090 Op2 = SExtPromotedInteger(Op2);
1094 Op1 = ZExtPromotedInteger(Op1);
1095 Op2 = ZExtPromotedInteger(Op2);
1098 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1107 Op1 = GetPromotedInteger(Op1);
1109 Op2 = ZExtPromotedInteger(Op2);
1111 Op1 = SExtPromotedInteger(Op1);
1112 Op2 = SExtPromotedInteger(Op2);
1119 if (IsShift || TLI.isOperationLegal(Opcode, PromotedType)) {
1132 "addition, subtraction or left shift");
1135 unsigned SHLAmount = NewBits - OldBits;
1137 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1142 SDValue Result = DAG.getNode(Opcode, dl, PromotedType, Op1, Op2);
1143 return DAG.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1149 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1150 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1151 SDValue Result = DAG.getNode(AddOp, dl, PromotedType, Op1, Op2);
1160 SDValue Op1Promoted, Op2Promoted;
1166 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1167 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1169 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1170 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1172 EVT OldType =
N->getOperand(0).getValueType();
1184 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1185 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1186 Op2Promoted,
N->getOperand(2));
1188 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1189 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1191 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1196 unsigned SatW,
bool Signed,
1199 EVT VT = V.getValueType();
1226 EVT VT =
LHS.getValueType();
1242 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1248 "Tried to saturate to more than the original type?");
1257 SDValue Op1Promoted, Op2Promoted;
1263 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1264 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1266 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1267 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1270 unsigned Scale =
N->getConstantOperandVal(2);
1274 if (TLI.isTypeLegal(PromotedType)) {
1276 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1279 N->getValueType(0).getScalarSizeInBits();
1283 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1284 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1285 Op2Promoted,
N->getOperand(2));
1288 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1294 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1295 Op2Promoted, Scale, DAG)) {
1298 N->getValueType(0).getScalarSizeInBits(),
1306 N->getValueType(0).getScalarSizeInBits());
1309SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1311 return PromoteIntRes_Overflow(
N);
1315 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1316 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1317 EVT OVT =
N->getOperand(0).getValueType();
1318 EVT NVT =
LHS.getValueType();
1328 DAG.getValueType(OVT));
1330 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1333 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1339 EVT PromotedResultTy =
1340 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1341 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1342 N->getOperand(0),
N->getOperand(1));
1348 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1349 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1351 unsigned Opcode =
N->getOpcode();
1352 if (Opcode == ISD::VP_MERGE)
1353 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1355 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1359 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1360 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1362 LHS.getValueType(),
N->getOperand(0),
1363 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1368 EVT InVT =
N->getOperand(OpNo).getValueType();
1369 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1371 EVT SVT = getSetCCResultType(InVT);
1378 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1379 SVT = getSetCCResultType(InVT);
1387 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1388 "Vector compare must return a vector result!");
1392 if (
N->isStrictFPOpcode()) {
1393 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1394 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1395 N->getOperand(2),
N->getOperand(3)};
1396 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1401 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1402 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1405 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1412 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1417 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1418 EVT VT =
N->getValueType(0);
1422 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1424 ReplaceValueWith(
SDValue(
N, 0), Res);
1429 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1432 RHS = ZExtPromotedInteger(
RHS);
1433 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1436SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1437 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1439 Op.getValueType(),
Op,
N->getOperand(1));
1442SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1446 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1447 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1448 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1453 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1454 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1455 if (
N->getNumOperands() == 2)
1456 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1457 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1458 assert((
N->getOpcode() == ISD::VP_SDIV ||
N->getOpcode() == ISD::VP_SREM) &&
1459 "Expected VP opcode");
1462 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1468 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1469 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1470 if (
N->getNumOperands() == 2)
1471 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1472 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1473 assert((
N->getOpcode() == ISD::VP_UDIV ||
N->getOpcode() == ISD::VP_UREM) &&
1474 "Expected VP opcode");
1482SDValue DAGTypeLegalizer::PromoteIntRes_ZExtMaskedIntBinOp(
SDNode *
N) {
1483 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1484 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1486 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1490SDValue DAGTypeLegalizer::PromoteIntRes_SExtMaskedIntBinOp(
SDNode *
N) {
1491 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1492 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1494 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1504 SExtOrZExtPromotedOperands(
LHS,
RHS);
1506 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1512 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1515 RHS = ZExtPromotedInteger(
RHS);
1516 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1522 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1524 RHS = ZExtPromotedInteger(
RHS);
1525 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1530 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1532 unsigned Opcode =
N->getOpcode();
1543 !TLI.isOperationLegalOrCustom(Opcode, VT) &&
1546 SDValue Op0 = GetPromotedInteger(
N->getOperand(0));
1548 Amt = ZExtPromotedInteger(Amt);
1554 DAG.getConstant(OldBits,
DL, AmtVT));
1555 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1557 SDValue Lo = DAG.getZeroExtendInReg(Op0,
DL, OldVT);
1569 SDValue Res = TLI.expandROT(
N,
true , DAG);
1570 ReplaceValueWith(
SDValue(
N, 0), Res);
1575 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1576 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1579 Amt = ZExtPromotedInteger(Amt);
1583 EVT OldVT =
N->getOperand(0).getValueType();
1584 EVT VT =
Lo.getValueType();
1585 unsigned Opcode =
N->getOpcode();
1592 DAG.getConstant(OldBits,
DL, AmtVT));
1600 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1601 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1603 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1613 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1619 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1621 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1625 unsigned Opcode =
N->getOpcode();
1628 EVT OldVT =
N->getOperand(0).getValueType();
1629 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1634 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT) &&
1636 TLI.isOperationLegalOrCustom(
1637 ISD::CLMUL, TLI.getRegisterType(*DAG.getContext(), VT)))) {
1638 if (
SDValue Res = TLI.expandCLMUL(
N, DAG))
1641 SDValue X = GetPromotedInteger(
N->getOperand(0));
1642 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1646 SDValue X = ZExtPromotedInteger(
N->getOperand(0));
1647 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1651 if (NewBits < 2 * OldBits) {
1653 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1655 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1657 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1659 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1664 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1666 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1671 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1672 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PEXT, VT)) {
1673 if (
SDValue Res = TLI.expandPEXT(
N, DAG))
1678 SDValue X = GetPromotedInteger(
N->getOperand(0));
1679 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1685 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1686 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PDEP, VT)) {
1687 if (
SDValue Res = TLI.expandPDEP(
N, DAG))
1692 SDValue X = GetPromotedInteger(
N->getOperand(0));
1693 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1698 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1710 Res = GetPromotedInteger(InOp);
1717 "Dst and Src must have the same number of elements");
1719 "Promoted vector type must be a power of two");
1722 GetSplitVector(InOp, EOp1, EOp2);
1731 SDValue WideInOp = GetWidenedVector(InOp);
1736 N->getValueType(0).getScalarType(), NumElem);
1745 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1754SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1756 return PromoteIntRes_Overflow(
N);
1760 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1761 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1762 EVT OVT =
N->getOperand(0).getValueType();
1763 EVT NVT =
LHS.getValueType();
1772 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1774 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1777 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1788 return PromoteIntRes_Overflow(
N);
1800 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1801 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1803 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1806 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1817 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1818 return PromoteIntRes_Overflow(
N);
1822 EVT OVT =
N->getValueType(0);
1823 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1829 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1831 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1832 if (
SDValue Res = TLI.expandABS(
N, DAG))
1836 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1840SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1843 return PromoteIntRes_Overflow(
N);
1847 EVT SmallVT =
LHS.getValueType();
1854 LHS = SExtPromotedInteger(
LHS);
1855 RHS = SExtPromotedInteger(
RHS);
1857 LHS = ZExtPromotedInteger(
LHS);
1858 RHS = ZExtPromotedInteger(
RHS);
1860 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1872 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1873 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1874 DAG.getConstant(0,
DL,
Hi.getValueType()),
1879 Mul, DAG.getValueType(SmallVT));
1889 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1894 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1895 N->getValueType(0)));
1899 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1901 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1908 EVT VT =
N->getValueType(0);
1911 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1912 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1916 for (
unsigned i = 0; i < NumRegs; ++i) {
1917 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
1918 N->getConstantOperandVal(3));
1923 if (DAG.getDataLayout().isBigEndian())
1924 std::reverse(Parts.begin(), Parts.end());
1927 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1929 for (
unsigned i = 1; i < NumRegs; ++i) {
1934 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1940 ReplaceValueWith(
SDValue(
N, 1), Chain);
1953bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
1956 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
1961 switch (
N->getOpcode()) {
1964 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
1965 N->dump(&DAG);
dbgs() <<
"\n";
1971 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
1977 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
1978 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
1983 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
1987 Res = PromoteIntOp_FAKE_USE(
N);
1990 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
1994 Res = PromoteIntOp_ScalarOp(
N);
1997 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
1999 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2017 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2024 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2039 Res = PromoteIntOp_Shift(
N);
2043 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2046 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2072 case ISD::VP_REDUCE_ADD:
2073 case ISD::VP_REDUCE_MUL:
2074 case ISD::VP_REDUCE_AND:
2075 case ISD::VP_REDUCE_OR:
2076 case ISD::VP_REDUCE_XOR:
2077 case ISD::VP_REDUCE_SMAX:
2078 case ISD::VP_REDUCE_SMIN:
2079 case ISD::VP_REDUCE_UMAX:
2080 case ISD::VP_REDUCE_UMIN:
2081 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2086 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2089 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2092 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2094 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2095 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2096 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2098 case ISD::EXPERIMENTAL_VP_SPLICE:
2099 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2102 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2107 Res = PromoteIntOp_UnaryBooleanVectorOp(
N, OpNo);
2110 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2113 Res = PromoteIntOp_VECTOR_MATCH(
N, OpNo);
2119 Res = PromoteIntOp_MaskedBinOp(
N, OpNo);
2124 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2128 Res = PromoteIntOp_LOOP_DEPENDENCE_MASK(
N);
2133 if (!Res.
getNode())
return false;
2140 const bool IsStrictFp =
N->isStrictFPOpcode();
2142 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2143 "Invalid operand expansion");
2147 ReplaceValueWith(
SDValue(
N, 0), Res);
2161 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2165 unsigned OpLEffectiveBits =
2166 DAG.computeKnownBits(OpL).countMaxActiveBits();
2167 unsigned OpREffectiveBits =
2168 DAG.computeKnownBits(OpR).countMaxActiveBits();
2169 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2170 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2177 LHS = SExtPromotedInteger(
LHS);
2178 RHS = SExtPromotedInteger(
RHS);
2187 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2188 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2189 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2190 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2197 LHS = ZExtPromotedInteger(
LHS);
2198 RHS = ZExtPromotedInteger(
RHS);
2212 LHS = SExtPromotedInteger(
LHS);
2213 RHS = SExtPromotedInteger(
RHS);
2218 "Unknown integer comparison!");
2220 SExtOrZExtPromotedOperands(
LHS,
RHS);
2224 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2228SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2229 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2230 EVT ResVT =
N->getValueType(0);
2231 EVT OpVT =
Op.getValueType();
2234 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2239 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2240 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2241 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2245 EVT OutVT =
N->getValueType(0);
2248 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2251 switch (getTypeAction(InVT)) {
2255 DAG.getDataLayout().isLittleEndian()) {
2265 if (isTypeLegal(WideVecVT)) {
2266 SDValue Promoted = GetPromotedInteger(InOp);
2269 DAG.getVectorIdxConstant(0, dl));
2282 return CreateStackStoreLoad(InOp, OutVT);
2285SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2286 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2294 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2295 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2299SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2300 assert(OpNo == 1 &&
"only know how to promote condition");
2303 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2306 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2307 N->getOperand(2)), 0);
2310SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2311 assert(OpNo == 1 &&
"only know how to promote condition");
2314 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2317 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2322 EVT OVT =
N->getOperand(0).getValueType();
2323 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2324 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2325 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2330 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2331 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2340 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2341 "Legal vector of one illegal element?");
2346 assert(
N->getOperand(0).getValueSizeInBits() >=
2347 N->getValueType(0).getScalarSizeInBits() &&
2348 "Type of inserted value narrower than vector element type!");
2351 for (
unsigned i = 0; i < NumElts; ++i)
2352 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2354 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2357SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2364 assert(
N->getOperand(1).getValueSizeInBits() >=
2365 N->getValueType(0).getScalarSizeInBits() &&
2366 "Type of inserted value narrower than vector element type!");
2367 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2368 GetPromotedInteger(
N->getOperand(1)),
2373 assert(OpNo == 2 &&
"Different operand and result vector types?");
2376 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2377 TLI.getVectorIdxTy(DAG.getDataLayout()));
2378 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2379 N->getOperand(1), Idx), 0);
2383 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2387 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2390SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2391 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2393 EVT OpTy =
N->getOperand(1).getValueType();
2396 if (
SDValue Res = WidenVSELECTMask(
N))
2397 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2398 Res,
N->getOperand(1),
N->getOperand(2));
2402 Cond = PromoteTargetBoolean(
Cond, OpVT);
2404 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2405 N->getOperand(2)), 0);
2408SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2409 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2417 N->getOperand(3),
N->getOperand(4)), 0);
2420SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2421 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2428 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2432 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2433 ZExtPromotedInteger(
N->getOperand(1))), 0);
2441 LHS = SExtPromotedInteger(
LHS);
2442 RHS = SExtPromotedInteger(
RHS);
2444 SExtOrZExtPromotedOperands(
LHS,
RHS);
2451 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2452 ZExtPromotedInteger(
N->getOperand(2))), 0);
2456 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2460 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2464 return SDValue(DAG.UpdateNodeOperands(
N,
2465 SExtPromotedInteger(
N->getOperand(0))), 0);
2468SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2469 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2470 SExtPromotedInteger(
N->getOperand(1))), 0);
2475 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2478 SDValue Val = GetPromotedInteger(
N->getValue());
2481 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2482 N->getMemoryVT(),
N->getMemOperand());
2488 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2489 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2491 SDValue DataOp = GetPromotedInteger(
N->getValue());
2492 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2493 N->getMask(),
N->getVectorLength(),
2494 N->getMemoryVT(),
N->getMemOperand(),
2495 N->isCompressingStore());
2506 Mask = PromoteTargetBoolean(Mask, DataVT);
2509 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2512 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2513 DataOp = GetPromotedInteger(DataOp);
2515 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2516 N->getOffset(), Mask,
N->getMemoryVT(),
2517 N->getMemOperand(),
N->getAddressingMode(),
2518 true,
N->isCompressingStore());
2523 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2524 EVT DataVT =
N->getValueType(0);
2525 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2527 NewOps[OpNo] =
Mask;
2528 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2544 EVT DataVT =
N->getValueType(0);
2545 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2546 }
else if (OpNo == 4) {
2548 if (
N->isIndexSigned())
2550 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2552 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2554 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2556 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2568 bool TruncateStore =
N->isTruncatingStore();
2573 EVT DataVT =
N->getValue().getValueType();
2574 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2575 }
else if (OpNo == 4) {
2577 if (
N->isIndexSigned())
2579 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2581 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2583 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2584 TruncateStore =
true;
2587 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2588 SDLoc(
N), NewOps,
N->getMemOperand(),
2589 N->getIndexType(), TruncateStore);
2594 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2598 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2603 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2608 return SDValue(DAG.UpdateNodeOperands(
N,
2609 ZExtPromotedInteger(
N->getOperand(0))), 0);
2612SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2613 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2618SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2619 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2620 ZExtPromotedInteger(
N->getOperand(1))), 0);
2627 EVT VT =
N->getValueType(0);
2632 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2633 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2634 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2635 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2640 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2644 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2646 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2649SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2651 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2652 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2661 unsigned OpOffset = IsStrict ? 1 : 0;
2665 RTLIB::Libcall LC = IsPowI ? RTLIB::getPOWI(
N->getValueType(0))
2668 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2669 if (LCImpl == RTLIB::Unsupported) {
2675 if (IsPowI &&
N->getValueType(0).isVector())
2676 return DAG.UnrollVectorOp(
N);
2678 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2679 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2691 if (
N->getOperand(1 + OpOffset).getScalarValueSizeInBits() >
2692 DAG.getLibInfo().getIntSize()) {
2693 const Function &Fn = DAG.getMachineFunction().getFunction();
2694 Fn.getContext().diagnose(DiagnosticInfoLegalizationFailure(
2695 Twine(IsPowI ?
"powi" :
"ldexp") +
2696 " exponent does not match sizeof(int)",
2697 Fn, N->getDebugLoc()));
2699 ReplaceValueWith(SDValue(N, 1), Chain);
2700 ReplaceValueWith(SDValue(N, 0), DAG.getPOISON(N->getValueType(0)));
2704 TargetLowering::MakeLibCallOptions CallOptions;
2705 CallOptions.setIsSigned(
true);
2706 SDValue Ops[2] = {N->getOperand(0 + OpOffset), N->getOperand(1 + OpOffset)};
2707 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2708 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2709 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2711 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2716 switch (
N->getOpcode()) {
2724 case ISD::VP_REDUCE_ADD:
2725 case ISD::VP_REDUCE_MUL:
2726 case ISD::VP_REDUCE_AND:
2727 case ISD::VP_REDUCE_OR:
2728 case ISD::VP_REDUCE_XOR:
2732 case ISD::VP_REDUCE_SMAX:
2733 case ISD::VP_REDUCE_SMIN:
2737 case ISD::VP_REDUCE_UMAX:
2738 case ISD::VP_REDUCE_UMIN:
2748 return GetPromotedInteger(V);
2750 return SExtPromotedInteger(V);
2752 return ZExtPromotedInteger(V);
2758 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2760 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2761 EVT InVT =
Op.getValueType();
2763 EVT ResVT =
N->getValueType(0);
2764 unsigned Opcode =
N->getOpcode();
2781 switch (TLI.getBooleanContents(InVT)) {
2784 Op = ZExtPromotedInteger(
N->getOperand(0));
2787 Op = SExtPromotedInteger(
N->getOperand(0));
2800 switch (TLI.getBooleanContents(InVT)) {
2803 Op = ZExtPromotedInteger(
N->getOperand(0));
2806 Op = SExtPromotedInteger(
N->getOperand(0));
2812 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2816 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2820SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2827 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2828 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2831 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2833 Op = PromoteIntOpVectorReduction(
N,
Op);
2837 EVT VT =
N->getValueType(0);
2838 EVT EltVT =
Op.getValueType().getScalarType();
2841 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2853 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2854 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2857SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2860 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2861 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2864SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2867 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2868 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2873 const Function &Fn = DAG.getMachineFunction().getFunction();
2875 "cannot use llvm.write_register with illegal type", Fn,
2877 return N->getOperand(0);
2880SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2881 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2882 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2885 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2886 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2896SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2900 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2901 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2904 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2906 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2907 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2910SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2912 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2914 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2915 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2918SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
2920 assert(OpNo == 0 &&
"Unexpected operand for promotion");
2924 if (TLI.getBooleanContents(
Op.getValueType()) ==
2926 NewOp = SExtPromotedInteger(
Op);
2928 NewOp = ZExtPromotedInteger(
Op);
2930 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
2933SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
2935 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
2936 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2937 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2940SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_MATCH(
SDNode *
N,
unsigned OpNo) {
2941 assert(OpNo < 3 &&
"Unexpected operand for promotion");
2943 return TLI.expandVectorMatch(
N, DAG);
2946 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2),
N->getValueType(0));
2947 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2950SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
2953 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
2954 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2957SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
2959 switch (
N->getOpcode()) {
2961 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2962 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
2965 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2966 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2969 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2970 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2975 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2978SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
2980 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
2981 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2982 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2984 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2995void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3001 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3004 switch (
N->getOpcode()) {
3007 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3008 N->dump(&DAG);
dbgs() <<
"\n";
3037 ExpandIntRes_ABS(
N,
Lo,
Hi);
3089 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3090 SplitInteger(Tmp.first,
Lo,
Hi);
3091 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3096 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3097 SDValue Tmp = DAG.getAtomicCmpSwap(
3099 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3108 SplitInteger(Tmp,
Lo,
Hi);
3187 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3192 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3198 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3202 ExpandIntRes_PEXT(
N,
Lo,
Hi);
3206 ExpandIntRes_PDEP(
N,
Lo,
Hi);
3210 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3214 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3219 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3229std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3230 unsigned Opc =
Node->getOpcode();
3236 EVT RetVT =
Node->getValueType(0);
3237 TargetLowering::MakeLibCallOptions CallOptions;
3240 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3241 if (LCImpl != RTLIB::Unsupported) {
3243 Ops.push_back(
Node->getOperand(1));
3246 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3247 "Unexpected atomic op or value type!");
3249 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3251 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3252 Node->getOperand(0));
3257void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3262 GetExpandedInteger(
N->getOperand(0), InL, InH);
3277 if (Amt.
uge(VTBits)) {
3278 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3279 }
else if (Amt.
ugt(NVTBits)) {
3280 Lo = DAG.getConstant(0,
DL, NVT);
3282 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3283 }
else if (Amt == NVTBits) {
3284 Lo = DAG.getConstant(0,
DL, NVT);
3288 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3290 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3292 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3297 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3299 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3306 if (Amt.
uge(VTBits)) {
3307 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3308 }
else if (Amt.
ugt(NVTBits)) {
3310 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3311 Hi = DAG.getConstant(0,
DL, NVT);
3312 }
else if (Amt == NVTBits) {
3314 Hi = DAG.getConstant(0,
DL, NVT);
3317 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3319 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3324 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3326 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3329 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3335 if (Amt.
uge(VTBits)) {
3337 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3338 }
else if (Amt.
ugt(NVTBits)) {
3340 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3342 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3343 }
else if (Amt == NVTBits) {
3346 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3349 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3351 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3356 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3358 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3361 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3369bool DAGTypeLegalizer::
3371 unsigned Opc =
N->getOpcode();
3374 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3379 "Expanded integer type size not a power of two!");
3383 KnownBits
Known = DAG.computeKnownBits(Amt);
3386 if (((
Known.Zero |
Known.One) & HighBitMask) == 0)
3391 GetExpandedInteger(In, InL, InH);
3395 if (
Known.One.intersects(HighBitMask)) {
3398 DAG.getConstant(~HighBitMask, dl, ShTy));
3403 Lo = DAG.getConstant(0, dl, NVT);
3404 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3407 Hi = DAG.getConstant(0, dl, NVT);
3408 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3412 DAG.getConstant(NVTBits - 1, dl, ShTy));
3413 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3425 DAG.getConstant(NVTBits - 1, dl, ShTy));
3441 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3443 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3445 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3446 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3458bool DAGTypeLegalizer::
3461 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3465 "Expanded integer type size not a power of two!");
3470 GetExpandedInteger(
N->getOperand(0), InL, InH);
3472 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3475 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3478 Amt, DAG.getConstant(0, dl, ShTy),
3482 switch (
N->getOpcode()) {
3488 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3489 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3492 LoL = DAG.getConstant(0, dl, NVT);
3495 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3496 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3497 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3503 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3506 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3509 HiL = DAG.getConstant(0, dl, NVT);
3512 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3513 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3514 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3520 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3521 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3525 DAG.getConstant(NVTBits - 1, dl, ShTy));
3528 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3529 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3530 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3555 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3560 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3561 SplitInteger(Res,
Lo,
Hi);
3564void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3573 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3574 unsigned NumHalfBits = NumBits / 2;
3575 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3576 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3577 SDValue LHSL, LHSH, RHSL, RHSH;
3578 GetExpandedInteger(
LHS, LHSL, LHSH);
3579 GetExpandedInteger(
RHS, RHSL, RHSH);
3582 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3584 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3592 SDValue LHSL, LHSH, RHSL, RHSH;
3593 GetExpandedInteger(
LHS, LHSL, LHSH);
3594 GetExpandedInteger(
RHS, RHSL, RHSH);
3596 EVT CCT = getSetCCResultType(NVT);
3599 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3601 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3603 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3605 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3609 const APInt *RHSVal =
nullptr;
3611 RHSVal = &RHSConst->getAPIntValue();
3618 SDValue LHSL, LHSH, RHSL, RHSH;
3619 GetExpandedInteger(
LHS, LHSL, LHSH);
3620 GetExpandedInteger(
RHS, RHSL, RHSH);
3622 EVT CCT = getSetCCResultType(NVT);
3628 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3631 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3635 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3638 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3640 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3647 switch (
N->getOpcode()) {
3674 EVT VT =
N->getValueType(0);
3675 EVT CCT = getSetCCResultType(VT);
3678 SplitInteger(Result,
Lo,
Hi);
3682 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3683 SplitInteger(ExpandedCMP,
Lo,
Hi);
3686void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3690 SDValue LHSL, LHSH, RHSL, RHSH;
3691 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3692 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3695 SDValue LoOps[2] = { LHSL, RHSL };
3696 SDValue HiOps[3] = { LHSH, RHSH };
3698 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3700 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3702 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3706 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3712 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3725 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3727 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3730 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3744 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3746 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3750 EVT OvfVT = getSetCCResultType(NVT);
3751 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3766 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3769 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3773 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3785 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3789 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3792 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3795 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3800 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3802 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3803 DAG.getConstant(0, dl, NVT));
3806 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3815 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3820 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3822 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3823 DAG.getConstant(0, dl, NVT));
3829void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3832 SDValue LHSL, LHSH, RHSL, RHSH;
3834 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3835 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3836 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3837 SDValue LoOps[2] = { LHSL, RHSL };
3838 SDValue HiOps[3] = { LHSH, RHSH };
3852 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3855void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3858 SDValue LHSL, LHSH, RHSL, RHSH;
3860 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3861 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3862 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3864 SDValue HiOps[3] = { LHSH, RHSH };
3866 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3868 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3872 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3875void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3883 unsigned CarryOp, NoCarryOp;
3885 switch(
N->getOpcode()) {
3900 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3901 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3905 SDValue LHSL, LHSH, RHSL, RHSH;
3906 GetExpandedInteger(
LHS, LHSL, LHSH);
3907 GetExpandedInteger(
RHS, RHSL, RHSH);
3908 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3909 SDValue LoOps[2] = { LHSL, RHSL };
3910 SDValue HiOps[3] = { LHSH, RHSH };
3912 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3914 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3921 SplitInteger(Sum,
Lo,
Hi);
3927 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
3928 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
3932 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
3937 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
3943 ReplaceValueWith(
SDValue(
N, 1), Ovf);
3949 SDValue LHSL, LHSH, RHSL, RHSH;
3951 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3952 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3953 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3957 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3959 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3963 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3966void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
3969 SDValue LHSL, LHSH, RHSL, RHSH;
3971 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3972 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3973 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3978 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
3979 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
3983 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3986void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
3988 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3991 if (
Op.getValueType().bitsLE(NVT)) {
3994 Hi = DAG.getUNDEF(NVT);
3998 assert(getTypeAction(
Op.getValueType()) ==
4000 "Only know how to promote this result!");
4003 "Operand over promoted?");
4005 SplitInteger(Res,
Lo,
Hi);
4009void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4012 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4013 EVT NVT =
Lo.getValueType();
4018 if (NVTBits < EVTBits) {
4021 EVTBits - NVTBits)));
4026 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4030void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4033 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4034 EVT NVT =
Lo.getValueType();
4039 if (NVTBits < EVTBits) {
4042 EVTBits - NVTBits)));
4046 Hi = DAG.getConstant(0, dl, NVT);
4050void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4053 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4058void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4061 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4070 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4071 EVT NVT =
Lo.getValueType();
4074 Hi = DAG.getConstant(0, dl, NVT);
4077void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4079 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4082 const APInt &Cst =
Constant->getAPIntValue();
4083 bool IsTarget =
Constant->isTargetOpcode();
4084 bool IsOpaque =
Constant->isOpaque();
4086 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4087 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4095 GetExpandedInteger(N0,
Lo,
Hi);
4096 EVT NVT =
Lo.getValueType();
4101 unsigned NumSignBits = DAG.ComputeNumSignBits(N0);
4106 Lo = DAG.getNode(AbsOpc, dl, NVT,
Lo);
4107 Hi = DAG.getConstant(0, dl, NVT);
4117 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4122 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4123 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4132 EVT VT =
N->getValueType(0);
4134 DAG.getConstant(0, dl, VT), N0);
4136 SplitInteger(Neg, NegLo, NegHi);
4138 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4140 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4141 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4144void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4148 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4149 EVT NVT =
Lo.getValueType();
4151 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4154 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4157 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4158 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4161 Hi = DAG.getConstant(0, dl, NVT);
4169 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4170 EVT NVT =
Lo.getValueType();
4173 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4174 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4177 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4180 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4182 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4184 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4185 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4187 Hi = DAG.getConstant(0, dl, NVT);
4192 SplitInteger(Result,
Lo,
Hi);
4197 EVT VT =
N->getValueType(0);
4202 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4203 "LibCall explicitly requested, but not available");
4205 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4206 TargetLowering::MakeLibCallOptions CallOptions;
4210 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4211 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4219 GetExpandedInteger(
Op,
Lo,
Hi);
4220 EVT NVT =
Lo.getValueType();
4223 Hi = DAG.getConstant(0,
DL, NVT);
4226void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4230 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4231 EVT NVT =
Lo.getValueType();
4233 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4239 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4240 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4243 Hi = DAG.getConstant(0, dl, NVT);
4249 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4256 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4260 ReplaceValueWith(
SDValue(
N, 1), Chain);
4268 Chain =
Op.getValue(1);
4277 EVT VT =
N->getValueType(0);
4281 bool IsStrict =
N->isStrictFPOpcode();
4283 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4287 Op.getValueType() == MVT::bf16) {
4293 EVT OpVT =
Op.getValueType();
4297 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4298 TargetLowering::MakeLibCallOptions CallOptions;
4303 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4304 CallOptions, dl, Chain);
4305 SplitInteger(Tmp.first,
Lo,
Hi);
4308 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4313 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4314 SplitInteger(Res,
Lo,
Hi);
4320 bool IsStrict =
N->isStrictFPOpcode();
4321 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4324 EVT VT =
Op.getValueType();
4326 if (VT == MVT::f16) {
4332 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4335 LC = RTLIB::getLROUND(VT);
4336 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4339 LC = RTLIB::getLRINT(VT);
4340 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4343 LC = RTLIB::getLLROUND(VT);
4344 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4347 LC = RTLIB::getLLRINT(VT);
4348 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4352 EVT RetVT =
N->getValueType(0);
4354 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4355 if (LCImpl == RTLIB::Unsupported) {
4356 DAG.getContext()->emitError(Twine(
"no libcall available for ") +
4357 N->getOperationName(&DAG));
4360 if (
N->isStrictFPOpcode())
4361 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
4365 TargetLowering::MakeLibCallOptions CallOptions;
4367 std::pair<SDValue, SDValue> Tmp =
4368 TLI.makeLibCall(DAG, LCImpl, RetVT,
Op, CallOptions, dl, Chain);
4369 SplitInteger(Tmp.first,
Lo,
Hi);
4371 if (
N->isStrictFPOpcode())
4372 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4375void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4377 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4380 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4386 EVT VT =
N->getValueType(0);
4387 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4392 AAMDNodes AAInfo =
N->getAAInfo();
4397 if (
N->getMemoryVT().bitsLE(NVT)) {
4398 EVT MemVT =
N->getMemoryVT();
4400 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4401 N->getBaseAlign(), MMOFlags, AAInfo);
4409 unsigned LoSize =
Lo.getValueSizeInBits();
4411 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4414 Hi = DAG.getConstant(0, dl, NVT);
4418 Hi = DAG.getUNDEF(NVT);
4420 }
else if (DAG.getDataLayout().isLittleEndian()) {
4422 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4425 unsigned ExcessBits =
4432 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4433 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4434 N->getBaseAlign(), MMOFlags, AAInfo);
4443 EVT MemVT =
N->getMemoryVT();
4446 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4449 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4452 N->getBaseAlign(), MMOFlags, AAInfo);
4458 N->getPointerInfo().getWithOffset(IncrementSize),
4460 N->getBaseAlign(), MMOFlags, AAInfo);
4472 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4476 DAG.getShiftAmountConstant(
4483 ReplaceValueWith(
SDValue(
N, 1), Ch);
4486void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4490 GetExpandedInteger(
N->getOperand(0), LL, LH);
4491 GetExpandedInteger(
N->getOperand(1), RL, RH);
4495 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4497 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4498 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4501void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4503 EVT VT =
N->getValueType(0);
4504 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4508 GetExpandedInteger(
N->getOperand(0), LL, LH);
4509 GetExpandedInteger(
N->getOperand(1), RL, RH);
4511 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4518 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4519 if (LCImpl == RTLIB::Unsupported) {
4522 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4528 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4529 TargetLowering::MakeLibCallOptions CallOptions;
4531 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4538 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4539 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4540 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4543 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4548 SplitInteger(Result,
Lo,
Hi);
4554 SplitInteger(Result,
Lo,
Hi);
4560 SplitInteger(Result,
Lo,
Hi);
4571 EVT VT =
N->getValueType(0);
4575 uint64_t Scale =
N->getConstantOperandVal(2);
4587 EVT BoolVT = getSetCCResultType(VT);
4589 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4595 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4596 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4602 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4603 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4608 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4609 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4612 SplitInteger(Result,
Lo,
Hi);
4618 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4620 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4622 GetExpandedInteger(
LHS, LL, LH);
4623 GetExpandedInteger(
RHS, RL, RH);
4627 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4634 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4635 SplitInteger(LoTmp, Result[0], Result[1]);
4636 SplitInteger(HiTmp, Result[2], Result[3]);
4638 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4641 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4642 "the size of the current value type");
4664 if (Scale % NVTSize) {
4665 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4668 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4680 if (Scale == VTSize)
4699 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4700 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4701 EVT BoolNVT = getSetCCResultType(NVT);
4704 if (Scale < NVTSize) {
4707 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4708 DAG.getShiftAmountConstant(Scale, NVT, dl));
4709 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4710 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4711 }
else if (Scale == NVTSize) {
4713 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4714 }
else if (Scale < VTSize) {
4718 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4719 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4722 "(and saturation can't happen with Scale==VTSize).");
4724 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4725 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4729 if (Scale < NVTSize) {
4734 unsigned OverflowBits = VTSize - Scale + 1;
4735 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4736 "Extent of overflow bits must start within HL");
4737 SDValue HLHiMask = DAG.getConstant(
4739 SDValue HLLoMask = DAG.getConstant(
4746 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4752 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4753 }
else if (Scale == NVTSize) {
4759 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4765 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4766 }
else if (Scale < VTSize) {
4769 unsigned OverflowBits = VTSize - Scale + 1;
4770 SDValue HHHiMask = DAG.getConstant(
4772 SDValue HHLoMask = DAG.getConstant(
4774 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4775 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4782 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4783 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4786 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4787 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4794 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4796 N->getConstantOperandVal(2), DAG);
4800 N->getConstantOperandVal(2), TLI, DAG);
4801 SplitInteger(Res,
Lo,
Hi);
4804void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4807 "Node has unexpected Opcode");
4817 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4818 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4822 SDValue LHSL, LHSH, RHSL, RHSH;
4823 GetExpandedInteger(
LHS, LHSL, LHSH);
4824 GetExpandedInteger(
RHS, RHSL, RHSH);
4825 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4828 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4837 SplitInteger(Sum,
Lo,
Hi);
4862 EVT VT =
LHS.getValueType();
4865 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4869 EVT OType =
Node->getValueType(1);
4870 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4874 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4877void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4879 EVT VT =
N->getValueType(0);
4881 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4890 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4892 TargetLowering::MakeLibCallOptions CallOptions;
4894 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4897void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4900 SDValue Shiftee =
N->getOperand(0);
4907 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4908 }
while (!TLI.isTypeLegal(LoadVT));
4913 "Shifting unit is not a a power of two!");
4915 const bool IsOneStepShift =
4916 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4921 if (!IsOneStepShift)
4922 ShAmt = DAG.getFreeze(ShAmt);
4925 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4926 unsigned VTByteWidth = VTBitWidth / 8;
4928 "Shiftee type size is not a power of two!");
4929 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4930 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4935 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
4937 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
4938 EVT PtrTy =
StackPtr.getValueType();
4939 SDValue Ch = DAG.getEntryNode();
4942 DAG.getMachineFunction(),
4948 unsigned WideningOpc =
4950 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
4953 SDValue AllZeros = DAG.getConstant(0, dl, VT);
4957 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
4963 Flags.setExact(IsOneStepShift);
4966 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
4968 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
4969 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
4972 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
4977 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
4984 if (DAG.getDataLayout().isBigEndian())
4985 WillIndexUpwards = !WillIndexUpwards;
4988 if (WillIndexUpwards) {
4991 AdjStackPtr = DAG.getMemBasePlusOffset(
4992 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
4993 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
4997 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
4998 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5002 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5007 if (!IsOneStepShift) {
5009 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5010 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5011 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5015 SplitInteger(Res,
Lo,
Hi);
5018void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5020 EVT VT =
N->getValueType(0);
5021 unsigned Opc =
N->getOpcode();
5027 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5031 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5048 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5050 const bool LegalOrCustom =
5054 unsigned ExpansionFactor = 1;
5056 for (EVT TmpVT = NVT;;) {
5057 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5058 if (NewTMPVT == TmpVT)
5065 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5068 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5070 if (LegalOrCustom &&
5074 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5080 SDValue ShiftOp =
N->getOperand(1);
5081 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5083 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5086 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5087 Hi =
Lo.getValue(1);
5092 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5106 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5109 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5111 TargetLowering::MakeLibCallOptions CallOptions;
5114 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5119 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5123void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5125 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5128 if (
Op.getValueType().bitsLE(NVT)) {
5134 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5138 assert(getTypeAction(
Op.getValueType()) ==
5140 "Only know how to promote this result!");
5143 "Operand over promoted?");
5145 SplitInteger(Res,
Lo,
Hi);
5153void DAGTypeLegalizer::
5156 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5159 if (EVT.
bitsLE(
Lo.getValueType())) {
5167 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5168 Hi.getValueType(), dl));
5179void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5181 EVT VT =
N->getValueType(0);
5183 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5192 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5194 TargetLowering::MakeLibCallOptions CallOptions;
5196 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5199void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5201 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5211void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5213 EVT VT =
N->getValueType(0);
5232 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5233 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5234 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5236 EVT BitVT =
N->getValueType(1);
5237 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5239 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5241 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5242 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5261 SplitInteger(Three,
Lo,
Hi);
5265 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5270 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5275 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5279 if (LCImpl == RTLIB::Unsupported ||
5281 DAG.getMachineFunction().getName()) {
5284 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5285 N->getOperand(1), MulLo, MulHi);
5290 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5291 SplitInteger(MulLo,
Lo,
Hi);
5292 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5296 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5299 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5300 MachinePointerInfo());
5304 EVT ArgVT =
Op.getValueType();
5306 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5307 Entry.IsSExt =
true;
5308 Entry.IsZExt =
false;
5309 Args.push_back(Entry);
5313 TargetLowering::ArgListEntry
Entry(
5315 Entry.IsSExt =
true;
5316 Entry.IsZExt =
false;
5317 Args.push_back(Entry);
5319 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5321 TargetLowering::CallLoweringInfo CLI(DAG);
5324 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5325 Func, std::move(Args))
5328 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5330 SplitInteger(CallInfo.first,
Lo,
Hi);
5332 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5333 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5334 DAG.getConstant(0, dl, PtrVT),
5337 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5340void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5342 EVT VT =
N->getValueType(0);
5344 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5354 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5356 if (isTypeLegal(NVT)) {
5358 GetExpandedInteger(
N->getOperand(0), InL, InH);
5360 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5369 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5371 TargetLowering::MakeLibCallOptions CallOptions;
5372 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5375void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5377 EVT VT =
N->getValueType(0);
5379 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5389 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5391 if (isTypeLegal(NVT)) {
5393 GetExpandedInteger(
N->getOperand(0), InL, InH);
5395 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5404 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5406 TargetLowering::MakeLibCallOptions CallOptions;
5407 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5410void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5412 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5415 if (
Op.getValueType().bitsLE(NVT)) {
5418 Hi = DAG.getConstant(0, dl, NVT);
5422 assert(getTypeAction(
Op.getValueType()) ==
5424 "Only know how to promote this result!");
5427 "Operand over promoted?");
5429 SplitInteger(Res,
Lo,
Hi);
5431 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5437void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5441 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5443 SDValue Swap = DAG.getAtomicCmpSwap(
5452void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5456 SDValue Res = TLI.expandVecReduce(
N, DAG);
5457 SplitInteger(Res,
Lo,
Hi);
5460void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5466 N->getOperand(0),
N->getOperand(1));
5467 SplitInteger(Res,
Lo,
Hi);
5474 GetExpandedInteger(
N->getOperand(0), In3, In4);
5475 GetExpandedInteger(
N->getOperand(1), In1, In2);
5479 unsigned Opc =
N->getOpcode();
5482 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5487 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5489 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5493 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5494 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5499 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5500 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5505 SDValue Res = TLI.expandCLMUL(
N, DAG);
5506 return SplitInteger(Res,
Lo,
Hi);
5510 GetExpandedInteger(
N->getOperand(0), LL, LH);
5511 GetExpandedInteger(
N->getOperand(1), RL, RH);
5525 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5529 SDValue Res = TLI.expandPEXT(
N, DAG);
5530 SplitInteger(Res,
Lo,
Hi);
5534 SDValue Res = TLI.expandPDEP(
N, DAG);
5535 SplitInteger(Res,
Lo,
Hi);
5540 EVT VT =
N->getValueType(0);
5547 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5550 SplitInteger(Res,
Lo,
Hi);
5557 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5558 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5560 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5561 Lo = DAG.getPOISON(LoVT);
5562 Hi = DAG.getPOISON(HiVT);
5569 EVT VT =
N->getSimpleValueType(0);
5570 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5572 "VectorIdxTy should be smaller than type to be expanded?");
5576 SplitInteger(Res,
Lo,
Hi);
5587bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5591 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5594 switch (
N->getOpcode()) {
5597 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5598 N->dump(&DAG);
dbgs() <<
"\n";
5603 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5607 Res = ExpandOp_FAKE_USE(
N);
5611 Res = TLI.expandLoopDependenceMask(
N, DAG);
5617 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5630 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5635 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5639 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5642 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5644 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5645 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5646 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5649 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5654 if (!Res.
getNode())
return false;
5662 "Invalid operand expansion");
5664 ReplaceValueWith(
SDValue(
N, 0), Res);
5670void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5674 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5675 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5676 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5689 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5696 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5697 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5727 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5728 RHSLo, LowCC,
false, DagCombineInfo, dl);
5730 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5733 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5734 RHSHi, CCCode,
false, DagCombineInfo, dl);
5738 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5747 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5749 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5758 if (LHSHi == RHSHi) {
5767 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5768 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5771 if (HasSETCCCARRY) {
5774 bool FlipOperands =
false;
5791 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5795 DAG.getCondCode(CCCode));
5801 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5802 false, DagCombineInfo, dl);
5805 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5806 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5813 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5818 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5823 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5824 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5825 N->getOperand(4)), 0);
5831 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5836 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5841 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5842 N->getOperand(2),
N->getOperand(3),
5843 DAG.getCondCode(CCCode)), 0);
5849 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5854 "Unexpected setcc expansion!");
5860 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5868 SDLoc dl = SDLoc(
N);
5870 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5871 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5872 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5885 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5895 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5896 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5900 return TLI.expandCMP(
N, DAG);
5908 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5909 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5913 bool IsStrict =
N->isStrictFPOpcode();
5917 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5918 EVT DstVT =
N->getValueType(0);
5921 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5922 "Don't know how to expand this XINT_TO_FP!");
5923 TargetLowering::MakeLibCallOptions CallOptions;
5925 std::pair<SDValue, SDValue> Tmp =
5926 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5931 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
5932 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
5937 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
5940 return ExpandOp_NormalStore(
N, OpNo);
5943 assert(OpNo == 1 &&
"Can only expand the stored value so far");
5945 EVT VT =
N->getOperand(1).getValueType();
5946 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5950 AAMDNodes AAInfo =
N->getAAInfo();
5956 if (
N->getMemoryVT().bitsLE(NVT)) {
5957 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5958 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
5959 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
5963 if (DAG.getDataLayout().isLittleEndian()) {
5965 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5967 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
5970 unsigned ExcessBits =
5977 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
5978 N->getPointerInfo().getWithOffset(IncrementSize),
5979 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
5985 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5987 EVT ExtVT =
N->getMemoryVT();
5990 unsigned ExcessBits = (EBytes - IncrementSize)*8;
5998 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6002 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6006 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6007 N->getBaseAlign(), MMOFlags, AAInfo);
6012 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6013 N->getPointerInfo().getWithOffset(IncrementSize),
6015 N->getBaseAlign(), MMOFlags, AAInfo);
6021 GetExpandedInteger(
N->getOperand(0), InL, InH);
6030 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6035SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6036 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6037 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6041 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6043 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6046SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6049 "cannot use llvm.write_register with illegal type", Fn,
6052 return N->getOperand(0);
6055SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6058 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6059 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6062 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0,
V1,
N->getOperand(2));
6065SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6067 unsigned Factor =
N->getNumOperands();
6070 for (
unsigned i = 0; i != Factor; i++)
6071 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6076 for (
unsigned i = 0; i != Factor; i++)
6082SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6084 EVT OutVT =
N->getValueType(0);
6085 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6086 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6090 SDValue BaseIdx =
N->getOperand(1);
6107 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6111 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6117 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6126 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6130 "Promoted operand has an element type greater than result");
6143 InOp0 = GetPromotedInteger(InOp0);
6150 Ops.reserve(OutNumElems);
6151 for (
unsigned i = 0; i != OutNumElems; ++i) {
6156 N->getOperand(0), Index);
6157 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6162 return DAG.getBuildVector(NOutVT, dl,
Ops);
6165SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6166 EVT OutVT =
N->getValueType(0);
6167 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6168 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6180 Vec = GetPromotedInteger(Vec);
6186SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6189 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6195SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6197 EVT VT =
N->getValueType(0);
6202 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6203 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6206 return DAG.getVectorShuffle(OutVT, dl, V0,
V1, NewMask);
6210 EVT OutVT =
N->getValueType(0);
6211 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6212 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6213 unsigned NumElems =
N->getNumOperands();
6220 Ops.reserve(NumElems);
6221 for (
unsigned i = 0; i != NumElems; ++i) {
6223 EVT OpVT =
Op.getValueType();
6228 if (OpVT.
bitsLT(NOutVTElem)) {
6234 ExtOpc = NOutExtOpc;
6235 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6240 return DAG.getBuildVector(NOutVT, dl,
Ops);
6247 assert(!
N->getOperand(0).getValueType().isVector() &&
6248 "Input must be a scalar");
6250 EVT OutVT =
N->getValueType(0);
6251 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6252 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6256 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6261 EVT OutVT =
N->getValueType(0);
6262 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6264 "Type must be promoted to a scalable vector type");
6265 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6266 return DAG.getStepVector(dl, NOutVT,
6270SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6273 EVT OutVT =
N->getValueType(0);
6274 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6275 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6277 unsigned NumOperands =
N->getNumOperands();
6282 SDUse *MaxSizedValue = std::max_element(
6284 EVT AVT = A.getValueType().getVectorElementType();
6285 EVT BVT = B.getValueType().getVectorElementType();
6286 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6292 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6294 EVT OpVT =
Op.getValueType();
6296 Op = GetPromotedInteger(
Op);
6299 "Unhandled legalization type");
6303 Op = DAG.getAnyExtOrTrunc(
6311 return DAG.getAnyExtOrTrunc(
6319 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6320 assert(NumElem * NumOperands == NumOutElem &&
6321 "Unexpected number of elements");
6325 for (
unsigned i = 0; i < NumOperands; ++i) {
6328 Op = GetPromotedInteger(
Op);
6329 EVT SclrTy =
Op.getValueType().getVectorElementType();
6330 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6331 "Unexpected number of elements");
6333 for (
unsigned j = 0;
j < NumElem; ++
j) {
6335 DAG.getVectorIdxConstant(j, dl));
6336 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6340 return DAG.getBuildVector(NOutVT, dl,
Ops);
6343SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6344 EVT VT =
N->getValueType(0);
6345 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6346 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6354 if (getTypeAction(
N->getOperand(0).getValueType())
6358 switch(
N->getOpcode()) {
6360 Promoted = SExtPromotedInteger(
N->getOperand(0));
6363 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6366 Promoted = GetPromotedInteger(
N->getOperand(0));
6378 DAG.getVectorIdxConstant(0, dl));
6380 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6384 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6387SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6388 EVT VT =
N->getValueType(0);
6389 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6393SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6394 EVT VT =
N->getValueType(0);
6395 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6400 EVT VT =
N->getValueType(0);
6401 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6403 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2), NVT);
6407SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6409 EVT VT =
N->getValueType(0);
6410 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6411 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6412 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6416SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6417 EVT OutVT =
N->getValueType(0);
6418 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6419 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6424 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6427 NOutVTElem,
N->getOperand(1));
6429 V0, ConvElem,
N->getOperand(2));
6436 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6437 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6445 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6446 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6447 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6451 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6454 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6455 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6463 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6468SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6471 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6473 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6474 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6475 return DAG.getPOISON(NVT);
6478SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6480 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6481 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6482 TLI.getVectorIdxTy(DAG.getDataLayout()));
6489 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6492SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6497 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6500 V1.getValueType().getVectorElementType(),
6502 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6504 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6513 EVT InVT1 =
V1.getValueType();
6516 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1),
V1);
6517 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6520SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6522 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6530SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6533 EVT ResVT =
N->getValueType(0);
6534 unsigned NumElems =
N->getNumOperands();
6537 SDValue ResVec = DAG.getUNDEF(ResVT);
6539 for (
unsigned OpIdx = 0; OpIdx < NumElems; ++OpIdx) {
6541 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6543 DAG.getIntPtrConstant(OpIdx * OpNumElts, dl));
6555 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6556 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6560 for (
unsigned i=0; i<NumElem; ++i) {
6563 DAG.getVectorIdxConstant(i, dl));
6569 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6572SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6585 for (
unsigned I = 0;
I < OpNo;
I++)
6588 EVT Ty =
Op.getValueType();
6589 SDLoc
DL = SDLoc(
N);
6592 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6600 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6605 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6611SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6624 for (
unsigned I = 0;
I < OpNo;
I++)
6627 EVT Ty =
Op.getValueType();
6628 SDLoc
DL = SDLoc(
N);
6631 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6639 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6644 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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)
const SmallVectorImpl< MachineOperand > & Cond
static Type * getValueType(Value *V, bool LookThroughCmp=false)
Returns the "element type" of the given value/instruction V.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This file describes how to lower LLVM code to machine code.
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.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
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.
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.
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.
EVT getValueType() const
Convenience function for get().getValueType().
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
ArrayRef< int > getMask() 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...
@ 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...
SDValue expandFixedPointDiv(unsigned Opcode, const SDLoc &dl, SDValue LHS, SDValue RHS, unsigned Scale, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]DIVFIX[SAT].
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.multiplyCoefficientBy(X) will result in a value whos...
constexpr ScalarTy getKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns a value X where RHS.multiplyCoefficientBy(X) will result in a value whose quantity matches ou...
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
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
@ 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 ...
@ 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 ...
@ 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_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 getSYNC(unsigned Opc, MVT VT)
Return the SYNC_FETCH_AND_* value for the given opcode and type, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall 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 getOUTLINE_ATOMIC(unsigned Opc, AtomicOrdering Order, MVT VT)
Return the outline atomics value for the given opcode, atomic ordering and type, or UNKNOWN_LIBCALL i...
LLVM_ABI Libcall getSREM(EVT VT)
LLVM_ABI Libcall getMUL(EVT VT)
LLVM_ABI Libcall getCTPOP(EVT VT)
LLVM_ABI Libcall getMULO(EVT VT)
NodeAddr< NodeBase * > Node
NodeAddr< FuncNode * > Func
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.
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...
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)