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";
63 case ISD::VP_BITREVERSE:
66 case ISD::BSWAP: Res = PromoteIntRes_BSWAP(
N);
break;
69 case ISD::VP_CTLZ_ZERO_UNDEF:
72 case ISD::CTLZ: Res = PromoteIntRes_CTLZ(
N);
break;
73 case ISD::CTLS: Res = PromoteIntRes_CTLS(
N);
break;
76 case ISD::CTPOP: Res = PromoteIntRes_CTPOP_PARITY(
N);
break;
77 case ISD::VP_CTTZ_ZERO_UNDEF:
80 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(
N);
break;
81 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
82 case ISD::VP_CTTZ_ELTS:
83 Res = PromoteIntRes_VP_CttzElements(
N);
86 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(
N);
break;
96 Res = PromoteIntRes_VECTOR_COMPRESS(
N);
102 Res = PromoteIntRes_Select(
N);
107 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
109 case ISD::SMAX: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
111 case ISD::UMAX: Res = PromoteIntRes_UMINUMAX(
N);
break;
114 case ISD::VP_SHL: Res = PromoteIntRes_SHL(
N);
break;
116 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
118 case ISD::VP_SRA: Res = PromoteIntRes_SRA(
N);
break;
120 case ISD::VP_SRL: Res = PromoteIntRes_SRL(
N);
break;
121 case ISD::VP_TRUNCATE:
124 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
125 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
129 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
131 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
133 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
135 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
138 Res = PromoteIntRes_VECTOR_SPLICE(
N);
142 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
145 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
147 Res = PromoteIntRes_BUILD_VECTOR(
N);
151 Res = PromoteIntRes_ScalarOp(
N);
155 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
160 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
163 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
167 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
173 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
177 case ISD::VP_SIGN_EXTEND:
179 case ISD::VP_ZERO_EXTEND:
182 case ISD::VP_FP_TO_SINT:
183 case ISD::VP_FP_TO_UINT:
191 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
195 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
199 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
214 case ISD::VP_MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
224 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
234 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
237 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
239 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
241 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
257 Res = PromoteIntRes_ADDSUBSHLSAT<EmptyMatchContext>(
N);
259 case ISD::VP_SADDSAT:
260 case ISD::VP_UADDSAT:
261 case ISD::VP_SSUBSAT:
262 case ISD::VP_USUBSAT:
263 Res = PromoteIntRes_ADDSUBSHLSAT<VPMatchContext>(
N);
268 Res = PromoteIntRes_CMP(
N);
281 case ISD::ABS: Res = PromoteIntRes_ABS(
N);
break;
314 Res = PromoteIntRes_VECREDUCE(
N);
317 case ISD::VP_REDUCE_ADD:
318 case ISD::VP_REDUCE_MUL:
319 case ISD::VP_REDUCE_AND:
320 case ISD::VP_REDUCE_OR:
321 case ISD::VP_REDUCE_XOR:
322 case ISD::VP_REDUCE_SMAX:
323 case ISD::VP_REDUCE_SMIN:
324 case ISD::VP_REDUCE_UMAX:
325 case ISD::VP_REDUCE_UMIN:
326 Res = PromoteIntRes_VP_REDUCE(
N);
331 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
335 Res = PromoteIntRes_FREEZE(
N);
340 Res = PromoteIntRes_Rotate(
N);
345 Res = PromoteIntRes_FunnelShift(
N);
350 Res = PromoteIntRes_VPFunnelShift(
N);
356 Res = PromoteIntRes_CLMUL(
N);
360 Res = PromoteIntRes_IS_FPCLASS(
N);
363 Res = PromoteIntRes_FFREXP(
N);
368 Res = PromoteIntRes_XRINT(
N);
372 Res = PromoteIntRes_PATCHPOINT(
N);
375 Res = PromoteIntRes_READ_REGISTER(
N);
381 SetPromotedInteger(
SDValue(
N, ResNo), Res);
386 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
387 return GetPromotedInteger(
Op);
390SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
392 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
393 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
398 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
400 Op.getValueType(),
Op,
N->getOperand(1));
405 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
407 Op.getValueType(),
Op,
N->getOperand(1));
411 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
414 switch (TLI.getExtendForAtomicOps()) {
430 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
431 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
441 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
443 Op2 = SExtPromotedInteger(Op2);
446 Op2 = ZExtPromotedInteger(Op2);
449 Op2 = GetPromotedInteger(Op2);
454 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
456 N->getChain(),
N->getBasePtr(),
457 Op2,
N->getMemOperand());
468 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
469 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
473 if (!TLI.isTypeLegal(SVT))
476 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
477 SDValue Res = DAG.getAtomicCmpSwap(
479 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
483 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
489 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
490 switch (TLI.getExtendForAtomicCmpSwapArg()) {
492 Op2 = SExtPromotedInteger(Op2);
495 Op2 = ZExtPromotedInteger(Op2);
498 Op2 = GetPromotedInteger(Op2);
505 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
506 SDValue Res = DAG.getAtomicCmpSwap(
507 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
508 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
510 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
518 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
519 EVT OutVT =
N->getValueType(0);
520 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
523 switch (getTypeAction(InVT)) {
529 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
533 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
536 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
544 BitConvertToInteger(GetScalarizedVector(InOp)));
553 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
554 Lo = BitConvertToInteger(
Lo);
555 Hi = BitConvertToInteger(
Hi);
557 if (DAG.getDataLayout().isBigEndian())
563 JoinIntegers(
Lo,
Hi));
578 if (DAG.getDataLayout().isBigEndian()) {
582 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
597 if (isTypeLegal(WideOutVT)) {
598 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
600 DAG.getVectorIdxConstant(0, dl));
609 DAG.getDataLayout().isLittleEndian()) {
620 if (isTypeLegal(WideVecVT)) {
622 DAG.getUNDEF(WideVecVT), InOp,
623 DAG.getVectorIdxConstant(0, dl));
631 CreateStackStoreLoad(InOp, OutVT));
635 SDValue V = GetPromotedInteger(
N->getOperand(0));
637 V.getValueType(), V);
641 SDValue Op = GetPromotedInteger(
N->getOperand(0));
642 EVT OVT =
N->getValueType(0);
643 EVT NVT =
Op.getValueType();
651 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
652 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
657 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
663 return DAG.getNode(ISD::VP_SRL, dl, NVT,
664 DAG.getNode(ISD::VP_BSWAP, dl, NVT,
Op, Mask, EVL), ShAmt,
669 SDValue Op = GetPromotedInteger(
N->getOperand(0));
670 EVT OVT =
N->getValueType(0);
671 EVT NVT =
Op.getValueType();
680 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
685 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
691 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
692 DAG.getNode(ISD::VP_BITREVERSE, dl, NVT,
Op, Mask, EVL),
700 TLI.getTypeToTransformTo(*DAG.getContext(),
701 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
706 EVT VT =
N->getValueType(0);
713 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
720 EVT OVT =
N->getValueType(0);
721 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
727 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
728 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
730 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
736 unsigned CtlzOpcode =
N->getOpcode();
737 if (CtlzOpcode ==
ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
739 SDValue ExtractLeadingBits = DAG.getConstant(
742 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
744 if (!
N->isVPOpcode())
745 return DAG.getNode(
ISD::SUB, dl, NVT,
746 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
750 return DAG.
getNode(ISD::VP_SUB, dl, NVT,
751 DAG.getNode(
N->getOpcode(), dl, NVT,
Op, Mask, EVL),
752 ExtractLeadingBits, Mask, EVL);
755 CtlzOpcode == ISD::VP_CTLZ_ZERO_UNDEF) {
757 SDValue Op = GetPromotedInteger(
N->getOperand(0));
761 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
762 if (!
N->isVPOpcode()) {
764 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
769 Op = DAG.getNode(ISD::VP_SHL, dl, NVT,
Op, ShiftConst, Mask, EVL);
770 return DAG.getNode(CtlzOpcode, dl, NVT,
Op, Mask, EVL);
776 EVT OVT =
N->getValueType(0);
777 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
780 SDValue ExtractLeadingBits = DAG.getConstant(
783 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
789 EVT OVT =
N->getValueType(0);
790 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
798 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
799 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
806 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
807 if (!
N->isVPOpcode())
808 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
812 return DAG.
getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op, Mask,
817 SDValue Op = GetPromotedInteger(
N->getOperand(0));
818 EVT OVT =
N->getValueType(0);
819 EVT NVT =
Op.getValueType();
826 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
827 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
831 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
837 unsigned NewOpc =
N->getOpcode();
838 if (NewOpc ==
ISD::CTTZ || NewOpc == ISD::VP_CTTZ) {
845 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
849 DAG.getNode(ISD::VP_OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT),
850 N->getOperand(1),
N->getOperand(2));
851 NewOpc = ISD::VP_CTTZ_ZERO_UNDEF;
854 if (!
N->isVPOpcode())
855 return DAG.getNode(NewOpc, dl, NVT,
Op);
856 return DAG.getNode(NewOpc, dl, NVT,
Op,
N->getOperand(1),
N->getOperand(2));
859SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
861 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
862 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
865SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
867 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
874 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
880 EVT SVT =
In.getValueType().getScalarType();
883 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
891 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
893 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
897 if (
N->isStrictFPOpcode()) {
898 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
899 {
N->getOperand(0),
N->getOperand(1)});
903 }
else if (NewOpc == ISD::VP_FP_TO_SINT || NewOpc == ISD::VP_FP_TO_UINT) {
904 Res = DAG.
getNode(NewOpc, dl, NVT, {
N->getOperand(0),
N->getOperand(1),
907 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
919 N->getOpcode() == ISD::VP_FP_TO_UINT)
923 DAG.getValueType(
N->getValueType(0).getScalarType()));
926SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
928 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
930 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
934SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
935 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
938 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
941SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
942 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
945 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
946 N->getOperand(0),
N->getOperand(1));
952 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
954 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
958 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
962 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
971 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
974 if (getTypeAction(
N->getOperand(0).getValueType())
976 SDValue Res = GetPromotedInteger(
N->getOperand(0));
985 DAG.getValueType(
N->getOperand(0).getValueType()));
987 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
994 if (
N->getNumOperands() != 1) {
995 assert(
N->getNumOperands() == 3 &&
"Unexpected number of operands!");
996 assert(
N->isVPOpcode() &&
"Expected VP opcode");
997 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
998 N->getOperand(1),
N->getOperand(2));
1000 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
1005 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1009 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1010 N->getMemoryVT(),
N->getMemOperand());
1019 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
1020 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1023 :
N->getExtensionType();
1026 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1027 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
1028 N->getMemOperand(),
N->isExpandingLoad());
1036 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1037 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1044 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1045 N->getOffset(),
N->getMask(), ExtPassThru,
1046 N->getMemoryVT(),
N->getMemOperand(),
1047 N->getAddressingMode(), ExtType,
1048 N->isExpandingLoad());
1056 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1057 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1059 "Gather result type and the passThru argument type should be the same");
1066 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1067 N->getIndex(),
N->getScale() };
1068 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1069 N->getMemoryVT(), dl,
Ops,
1070 N->getMemOperand(),
N->getIndexType(),
1078SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1079 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1080 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1082 N->getOperand(1), Passthru);
1089 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1090 EVT VT =
N->getValueType(0);
1091 EVT SVT = getSetCCResultType(VT);
1092 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1093 unsigned NumOps =
N->getNumOperands();
1096 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1104 ReplaceValueWith(
SDValue(
N, 0), Res);
1107 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1110template <
class MatchContextClass>
1122 MatchContextClass matcher(DAG, TLI,
N);
1124 unsigned Opcode = matcher.getRootBaseOpcode();
1130 SExtOrZExtPromotedOperands(Op1, Op2);
1136 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1138 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1139 Op1 = SExtPromotedInteger(Op1);
1140 Op2 = SExtPromotedInteger(Op2);
1141 return matcher.getNode(
ISD::UADDSAT, dl, NVT, Op1, Op2);
1144 Op1 = ZExtPromotedInteger(Op1);
1145 Op2 = ZExtPromotedInteger(Op2);
1148 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1150 return matcher.getNode(
ISD::UMIN, dl, NVT,
Add, SatMax);
1157 Op1 = GetPromotedInteger(Op1);
1159 Op2 = ZExtPromotedInteger(Op2);
1161 Op1 = SExtPromotedInteger(Op1);
1162 Op2 = SExtPromotedInteger(Op2);
1169 if (IsShift || matcher.isOperationLegal(Opcode, PromotedType)) {
1182 "addition, subtraction or left shift");
1185 unsigned SHLAmount = NewBits - OldBits;
1187 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1192 SDValue Result = matcher.getNode(Opcode, dl, PromotedType, Op1, Op2);
1193 return matcher.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1199 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1200 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1201 SDValue Result = matcher.getNode(AddOp, dl, PromotedType, Op1, Op2);
1202 Result = matcher.getNode(
ISD::SMIN, dl, PromotedType, Result, SatMax);
1203 Result = matcher.getNode(
ISD::SMAX, dl, PromotedType, Result, SatMin);
1210 SDValue Op1Promoted, Op2Promoted;
1216 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1217 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1219 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1220 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1222 EVT OldType =
N->getOperand(0).getValueType();
1234 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1235 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1236 Op2Promoted,
N->getOperand(2));
1238 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1239 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1241 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1246 unsigned SatW,
bool Signed,
1249 EVT VT = V.getValueType();
1276 EVT VT =
LHS.getValueType();
1292 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1298 "Tried to saturate to more than the original type?");
1307 SDValue Op1Promoted, Op2Promoted;
1313 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1314 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1316 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1317 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1320 unsigned Scale =
N->getConstantOperandVal(2);
1324 if (TLI.isTypeLegal(PromotedType)) {
1326 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1329 N->getValueType(0).getScalarSizeInBits();
1333 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1334 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1335 Op2Promoted,
N->getOperand(2));
1338 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1344 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1345 Op2Promoted, Scale, DAG)) {
1348 N->getValueType(0).getScalarSizeInBits(),
1356 N->getValueType(0).getScalarSizeInBits());
1359SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1361 return PromoteIntRes_Overflow(
N);
1365 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1366 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1367 EVT OVT =
N->getOperand(0).getValueType();
1368 EVT NVT =
LHS.getValueType();
1378 DAG.getValueType(OVT));
1380 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1383 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1389 EVT PromotedResultTy =
1390 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1391 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1392 N->getOperand(0),
N->getOperand(1));
1398 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1399 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1401 unsigned Opcode =
N->getOpcode();
1402 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1403 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1405 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1409 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1410 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1412 LHS.getValueType(),
N->getOperand(0),
1413 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1418 EVT InVT =
N->getOperand(OpNo).getValueType();
1419 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1421 EVT SVT = getSetCCResultType(InVT);
1428 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1429 SVT = getSetCCResultType(InVT);
1437 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1438 "Vector compare must return a vector result!");
1442 if (
N->isStrictFPOpcode()) {
1443 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1444 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1445 N->getOperand(2),
N->getOperand(3)};
1446 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1451 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1452 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1455 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1462 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1467 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1468 EVT VT =
N->getValueType(0);
1472 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1474 ReplaceValueWith(
SDValue(
N, 0), Res);
1479 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1482 RHS = ZExtPromotedInteger(
RHS);
1483 if (
N->getOpcode() != ISD::VP_SHL)
1484 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1492SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1493 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1495 Op.getValueType(),
Op,
N->getOperand(1));
1498SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1502 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1503 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1504 if (
N->getNumOperands() == 2)
1505 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1506 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1507 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1508 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1509 N->getOperand(2),
N->getOperand(3));
1514 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1515 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1516 if (
N->getNumOperands() == 2)
1517 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1518 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1519 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1528 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1529 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1530 if (
N->getNumOperands() == 2)
1531 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1532 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1533 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1547 SExtOrZExtPromotedOperands(
LHS,
RHS);
1549 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1555 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1558 RHS = ZExtPromotedInteger(
RHS);
1559 if (
N->getOpcode() != ISD::VP_SRA)
1560 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1571 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1573 RHS = ZExtPromotedInteger(
RHS);
1574 if (
N->getOpcode() != ISD::VP_SRL)
1575 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1585 SDValue Res = TLI.expandROT(
N,
true , DAG);
1586 ReplaceValueWith(
SDValue(
N, 0), Res);
1591 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1592 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1595 Amt = ZExtPromotedInteger(Amt);
1599 EVT OldVT =
N->getOperand(0).getValueType();
1600 EVT VT =
Lo.getValueType();
1601 unsigned Opcode =
N->getOpcode();
1608 DAG.getConstant(OldBits,
DL, AmtVT));
1616 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1617 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1619 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1629 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1635 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1637 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1641SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1642 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1643 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1648 Amt = ZExtPromotedInteger(Amt);
1652 EVT OldVT =
N->getOperand(0).getValueType();
1653 EVT VT =
Lo.getValueType();
1654 unsigned Opcode =
N->getOpcode();
1655 bool IsFSHR = Opcode == ISD::VP_FSHR;
1660 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1661 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1669 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1670 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1671 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1672 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1674 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1677 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1682 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1683 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1688 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1690 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1694 unsigned Opcode =
N->getOpcode();
1697 EVT OldVT =
N->getOperand(0).getValueType();
1698 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1701 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT)) {
1702 if (
SDValue Res = TLI.expandCLMUL(
N, DAG))
1705 SDValue X = GetPromotedInteger(
N->getOperand(0));
1706 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1710 SDValue X = ZExtPromotedInteger(
N->getOperand(0));
1711 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1715 if (NewBits < 2 * OldBits) {
1717 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1719 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1721 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1723 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1728 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1730 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1734 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1746 Res = GetPromotedInteger(InOp);
1753 "Dst and Src must have the same number of elements");
1755 "Promoted vector type must be a power of two");
1758 GetSplitVector(InOp, EOp1, EOp2);
1766 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1767 "Expected VP_TRUNCATE opcode");
1768 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1769 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1770 std::tie(EVLLo, EVLHi) =
1771 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1772 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1773 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1780 SDValue WideInOp = GetWidenedVector(InOp);
1785 N->getValueType(0).getScalarType(), NumElem);
1794 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1800 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1801 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1806SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1808 return PromoteIntRes_Overflow(
N);
1812 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1813 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1814 EVT OVT =
N->getOperand(0).getValueType();
1815 EVT NVT =
LHS.getValueType();
1824 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1826 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1829 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1840 return PromoteIntRes_Overflow(
N);
1852 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1853 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1855 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1858 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1869 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1870 return PromoteIntRes_Overflow(
N);
1874 EVT OVT =
N->getValueType(0);
1875 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1881 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1882 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1883 if (
SDValue Res = TLI.expandABS(
N, DAG))
1887 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1891SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1894 return PromoteIntRes_Overflow(
N);
1898 EVT SmallVT =
LHS.getValueType();
1905 LHS = SExtPromotedInteger(
LHS);
1906 RHS = SExtPromotedInteger(
RHS);
1908 LHS = ZExtPromotedInteger(
LHS);
1909 RHS = ZExtPromotedInteger(
RHS);
1911 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1923 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1924 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1925 DAG.getConstant(0,
DL,
Hi.getValueType()),
1930 Mul, DAG.getValueType(SmallVT));
1940 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1945 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1946 N->getValueType(0)));
1950 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1952 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1959 EVT VT =
N->getValueType(0);
1962 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1963 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1967 for (
unsigned i = 0; i < NumRegs; ++i) {
1968 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
1969 N->getConstantOperandVal(3));
1974 if (DAG.getDataLayout().isBigEndian())
1975 std::reverse(Parts.begin(), Parts.end());
1978 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1980 for (
unsigned i = 1; i < NumRegs; ++i) {
1985 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1991 ReplaceValueWith(
SDValue(
N, 1), Chain);
2004bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
2007 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2012 switch (
N->getOpcode()) {
2015 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2016 N->dump(&DAG);
dbgs() <<
"\n";
2022 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2028 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2029 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2034 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2038 Res = PromoteIntOp_FAKE_USE(
N);
2041 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2045 Res = PromoteIntOp_ScalarOp(
N);
2048 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2051 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2053 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2054 case ISD::VP_SINT_TO_FP:
2071 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2073 case ISD::VP_TRUNCATE:
2077 case ISD::VP_UINT_TO_FP:
2080 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2085 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2096 Res = PromoteIntOp_Shift(
N);
2100 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2103 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2129 case ISD::VP_REDUCE_ADD:
2130 case ISD::VP_REDUCE_MUL:
2131 case ISD::VP_REDUCE_AND:
2132 case ISD::VP_REDUCE_OR:
2133 case ISD::VP_REDUCE_XOR:
2134 case ISD::VP_REDUCE_SMAX:
2135 case ISD::VP_REDUCE_SMIN:
2136 case ISD::VP_REDUCE_UMAX:
2137 case ISD::VP_REDUCE_UMIN:
2138 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2143 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2146 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2149 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2151 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2152 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2153 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2155 case ISD::EXPERIMENTAL_VP_SPLICE:
2156 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2159 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2162 Res = PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
N, OpNo);
2165 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2170 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2175 if (!Res.
getNode())
return false;
2182 const bool IsStrictFp =
N->isStrictFPOpcode();
2184 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2185 "Invalid operand expansion");
2189 ReplaceValueWith(
SDValue(
N, 0), Res);
2203 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2207 unsigned OpLEffectiveBits =
2208 DAG.computeKnownBits(OpL).countMaxActiveBits();
2209 unsigned OpREffectiveBits =
2210 DAG.computeKnownBits(OpR).countMaxActiveBits();
2211 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2212 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2219 LHS = SExtPromotedInteger(
LHS);
2220 RHS = SExtPromotedInteger(
RHS);
2229 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2230 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2231 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2232 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2239 LHS = ZExtPromotedInteger(
LHS);
2240 RHS = ZExtPromotedInteger(
RHS);
2254 LHS = SExtPromotedInteger(
LHS);
2255 RHS = SExtPromotedInteger(
RHS);
2260 "Unknown integer comparison!");
2262 SExtOrZExtPromotedOperands(
LHS,
RHS);
2266 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2270SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2271 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2272 EVT ResVT =
N->getValueType(0);
2273 EVT OpVT =
Op.getValueType();
2276 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2281 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2282 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2283 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2287 EVT OutVT =
N->getValueType(0);
2290 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2293 switch (getTypeAction(InVT)) {
2297 DAG.getDataLayout().isLittleEndian()) {
2307 if (isTypeLegal(WideVecVT)) {
2308 SDValue Promoted = GetPromotedInteger(InOp);
2311 DAG.getVectorIdxConstant(0, dl));
2324 return CreateStackStoreLoad(InOp, OutVT);
2327SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2328 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2336 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2337 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2341SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2342 assert(OpNo == 1 &&
"only know how to promote condition");
2345 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2348 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2349 N->getOperand(2)), 0);
2352SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2353 assert(OpNo == 1 &&
"only know how to promote condition");
2356 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2359 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2364 EVT OVT =
N->getOperand(0).getValueType();
2365 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2366 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2367 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2372 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2373 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2382 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2383 "Legal vector of one illegal element?");
2388 assert(
N->getOperand(0).getValueSizeInBits() >=
2389 N->getValueType(0).getScalarSizeInBits() &&
2390 "Type of inserted value narrower than vector element type!");
2393 for (
unsigned i = 0; i < NumElts; ++i)
2394 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2396 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2399SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2406 assert(
N->getOperand(1).getValueSizeInBits() >=
2407 N->getValueType(0).getScalarSizeInBits() &&
2408 "Type of inserted value narrower than vector element type!");
2409 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2410 GetPromotedInteger(
N->getOperand(1)),
2415 assert(OpNo == 2 &&
"Different operand and result vector types?");
2418 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2419 TLI.getVectorIdxTy(DAG.getDataLayout()));
2420 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2421 N->getOperand(1), Idx), 0);
2425 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2429 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2432SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2433 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2435 EVT OpTy =
N->getOperand(1).getValueType();
2438 if (
SDValue Res = WidenVSELECTMask(
N))
2439 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2440 Res,
N->getOperand(1),
N->getOperand(2));
2444 Cond = PromoteTargetBoolean(
Cond, OpVT);
2446 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2447 N->getOperand(2)), 0);
2450SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2451 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2459 N->getOperand(3),
N->getOperand(4)), 0);
2462SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2463 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2471 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2473 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2476 N->getOperand(3),
N->getOperand(4)),
2481 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2482 ZExtPromotedInteger(
N->getOperand(1))), 0);
2490 LHS = SExtPromotedInteger(
LHS);
2491 RHS = SExtPromotedInteger(
RHS);
2493 SExtOrZExtPromotedOperands(
LHS,
RHS);
2500 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2501 ZExtPromotedInteger(
N->getOperand(2))), 0);
2505 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2509 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2512SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2514 EVT VT =
N->getValueType(0);
2515 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2517 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2521 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2523 SDValue Shl = DAG.getNode(ISD::VP_SHL, dl, VT,
Op, ShAmt,
N->getOperand(1),
2525 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2530 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2531 return SDValue(DAG.UpdateNodeOperands(
N,
2532 SExtPromotedInteger(
N->getOperand(0)),
2533 N->getOperand(1),
N->getOperand(2)),
2535 return SDValue(DAG.UpdateNodeOperands(
N,
2536 SExtPromotedInteger(
N->getOperand(0))), 0);
2539SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2540 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2541 SExtPromotedInteger(
N->getOperand(1))), 0);
2546 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2549 SDValue Val = GetPromotedInteger(
N->getValue());
2552 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2553 N->getMemoryVT(),
N->getMemOperand());
2559 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2560 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2562 SDValue DataOp = GetPromotedInteger(
N->getValue());
2563 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2564 N->getMask(),
N->getVectorLength(),
2565 N->getMemoryVT(),
N->getMemOperand(),
2566 N->isCompressingStore());
2577 Mask = PromoteTargetBoolean(Mask, DataVT);
2580 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2583 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2584 DataOp = GetPromotedInteger(DataOp);
2586 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2587 N->getOffset(), Mask,
N->getMemoryVT(),
2588 N->getMemOperand(),
N->getAddressingMode(),
2589 true,
N->isCompressingStore());
2594 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2595 EVT DataVT =
N->getValueType(0);
2596 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2598 NewOps[OpNo] =
Mask;
2599 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2615 EVT DataVT =
N->getValueType(0);
2616 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2617 }
else if (OpNo == 4) {
2619 if (
N->isIndexSigned())
2621 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2623 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2625 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2627 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2639 bool TruncateStore =
N->isTruncatingStore();
2644 EVT DataVT =
N->getValue().getValueType();
2645 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2646 }
else if (OpNo == 4) {
2648 if (
N->isIndexSigned())
2650 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2652 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2654 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2655 TruncateStore =
true;
2658 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2659 SDLoc(
N), NewOps,
N->getMemOperand(),
2660 N->getIndexType(), TruncateStore);
2665 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2669 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2674 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2675 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2676 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2677 N->getOperand(1),
N->getOperand(2));
2682 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2683 return SDValue(DAG.UpdateNodeOperands(
N,
2684 ZExtPromotedInteger(
N->getOperand(0)),
2685 N->getOperand(1),
N->getOperand(2)),
2687 return SDValue(DAG.UpdateNodeOperands(
N,
2688 ZExtPromotedInteger(
N->getOperand(0))), 0);
2691SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2692 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2697SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2698 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2699 ZExtPromotedInteger(
N->getOperand(1))), 0);
2706 EVT VT =
N->getValueType(0);
2711 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2712 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2713 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2714 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2719 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2722SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2724 EVT VT =
N->getValueType(0);
2725 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2727 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2729 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2730 N->getOperand(0).getValueType());
2734 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2736 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2739SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2741 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2742 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2751 unsigned OpOffset = IsStrict ? 1 : 0;
2758 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2759 if (LCImpl == RTLIB::Unsupported) {
2765 if (IsPowI &&
N->getValueType(0).isVector())
2766 return DAG.UnrollVectorOp(
N);
2768 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2769 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2779 assert(DAG.getLibInfo().getIntSize() ==
2780 N->getOperand(1 + OpOffset).getValueType().getSizeInBits() &&
2781 "POWI exponent should match with sizeof(int) when doing the libcall.");
2782 TargetLowering::MakeLibCallOptions CallOptions;
2784 SDValue Ops[2] = {
N->getOperand(0 + OpOffset),
N->getOperand(1 + OpOffset)};
2785 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2786 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2787 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2789 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2794 switch (
N->getOpcode()) {
2802 case ISD::VP_REDUCE_ADD:
2803 case ISD::VP_REDUCE_MUL:
2804 case ISD::VP_REDUCE_AND:
2805 case ISD::VP_REDUCE_OR:
2806 case ISD::VP_REDUCE_XOR:
2810 case ISD::VP_REDUCE_SMAX:
2811 case ISD::VP_REDUCE_SMIN:
2815 case ISD::VP_REDUCE_UMAX:
2816 case ISD::VP_REDUCE_UMIN:
2826 return GetPromotedInteger(V);
2828 return SExtPromotedInteger(V);
2830 return ZExtPromotedInteger(V);
2836 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2838 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2839 EVT InVT =
Op.getValueType();
2841 EVT ResVT =
N->getValueType(0);
2842 unsigned Opcode =
N->getOpcode();
2859 switch (TLI.getBooleanContents(InVT)) {
2862 Op = ZExtPromotedInteger(
N->getOperand(0));
2865 Op = SExtPromotedInteger(
N->getOperand(0));
2878 switch (TLI.getBooleanContents(InVT)) {
2881 Op = ZExtPromotedInteger(
N->getOperand(0));
2884 Op = SExtPromotedInteger(
N->getOperand(0));
2890 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2894 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2898SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2905 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2906 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2909 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2911 Op = PromoteIntOpVectorReduction(
N,
Op);
2915 EVT VT =
N->getValueType(0);
2916 EVT EltVT =
Op.getValueType().getScalarType();
2919 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2931 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2932 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2935SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2938 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2939 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2942SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2945 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2946 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2951 const Function &Fn = DAG.getMachineFunction().getFunction();
2953 "cannot use llvm.write_register with illegal type", Fn,
2955 return N->getOperand(0);
2958SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2959 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2960 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2963 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2965 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2968SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2972 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2973 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2976 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2978 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2979 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2982SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2984 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2986 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2987 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2990SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N,
2993 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2994 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2997SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
2999 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3000 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3001 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3004SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3006 switch (
N->getOpcode()) {
3008 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3009 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3012 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3013 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3016 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3017 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3022 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3033void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3039 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3042 switch (
N->getOpcode()) {
3045 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3046 N->dump(&DAG);
dbgs() <<
"\n";
3124 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3125 SplitInteger(Tmp.first,
Lo,
Hi);
3126 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3131 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3132 SDValue Tmp = DAG.getAtomicCmpSwap(
3134 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3143 SplitInteger(Tmp,
Lo,
Hi);
3222 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3227 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3233 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3237 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3241 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3251std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3252 unsigned Opc =
Node->getOpcode();
3258 EVT RetVT =
Node->getValueType(0);
3259 TargetLowering::MakeLibCallOptions CallOptions;
3262 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3263 if (LCImpl != RTLIB::Unsupported) {
3265 Ops.push_back(
Node->getOperand(1));
3268 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3269 "Unexpected atomic op or value type!");
3271 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3273 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3274 Node->getOperand(0));
3279void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3284 GetExpandedInteger(
N->getOperand(0), InL, InH);
3299 if (Amt.
uge(VTBits)) {
3300 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3301 }
else if (Amt.
ugt(NVTBits)) {
3302 Lo = DAG.getConstant(0,
DL, NVT);
3304 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3305 }
else if (Amt == NVTBits) {
3306 Lo = DAG.getConstant(0,
DL, NVT);
3310 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3312 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3314 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3319 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3321 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3328 if (Amt.
uge(VTBits)) {
3329 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3330 }
else if (Amt.
ugt(NVTBits)) {
3332 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3333 Hi = DAG.getConstant(0,
DL, NVT);
3334 }
else if (Amt == NVTBits) {
3336 Hi = DAG.getConstant(0,
DL, NVT);
3339 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3341 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3346 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3348 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3351 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3357 if (Amt.
uge(VTBits)) {
3359 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3360 }
else if (Amt.
ugt(NVTBits)) {
3362 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3364 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3365 }
else if (Amt == NVTBits) {
3368 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3371 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3373 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3378 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3380 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3383 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3391bool DAGTypeLegalizer::
3393 unsigned Opc =
N->getOpcode();
3396 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3401 "Expanded integer type size not a power of two!");
3405 KnownBits Known = DAG.computeKnownBits(Amt);
3408 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3413 GetExpandedInteger(In, InL, InH);
3420 DAG.getConstant(~HighBitMask, dl, ShTy));
3425 Lo = DAG.getConstant(0, dl, NVT);
3426 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3429 Hi = DAG.getConstant(0, dl, NVT);
3430 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3434 DAG.getConstant(NVTBits - 1, dl, ShTy));
3435 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3447 DAG.getConstant(NVTBits - 1, dl, ShTy));
3463 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3465 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3467 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3468 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3480bool DAGTypeLegalizer::
3483 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3487 "Expanded integer type size not a power of two!");
3492 GetExpandedInteger(
N->getOperand(0), InL, InH);
3494 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3497 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3500 Amt, DAG.getConstant(0, dl, ShTy),
3504 switch (
N->getOpcode()) {
3510 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3511 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3514 LoL = DAG.getConstant(0, dl, NVT);
3517 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3518 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3519 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3525 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3528 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3531 HiL = DAG.getConstant(0, dl, NVT);
3534 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3535 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3536 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3542 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3543 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3547 DAG.getConstant(NVTBits - 1, dl, ShTy));
3550 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3551 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3552 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3577 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3582 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3583 SplitInteger(Res,
Lo,
Hi);
3586void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3595 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3596 unsigned NumHalfBits = NumBits / 2;
3597 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3598 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3599 SDValue LHSL, LHSH, RHSL, RHSH;
3600 GetExpandedInteger(
LHS, LHSL, LHSH);
3601 GetExpandedInteger(
RHS, RHSL, RHSH);
3604 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3606 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3614 SDValue LHSL, LHSH, RHSL, RHSH;
3615 GetExpandedInteger(
LHS, LHSL, LHSH);
3616 GetExpandedInteger(
RHS, RHSL, RHSH);
3618 EVT CCT = getSetCCResultType(NVT);
3621 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3623 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3625 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3627 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3631 const APInt *RHSVal =
nullptr;
3633 RHSVal = &RHSConst->getAPIntValue();
3640 SDValue LHSL, LHSH, RHSL, RHSH;
3641 GetExpandedInteger(
LHS, LHSL, LHSH);
3642 GetExpandedInteger(
RHS, RHSL, RHSH);
3644 EVT CCT = getSetCCResultType(NVT);
3650 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3653 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3657 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3660 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3662 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3669 switch (
N->getOpcode()) {
3696 EVT VT =
N->getValueType(0);
3697 EVT CCT = getSetCCResultType(VT);
3700 SplitInteger(Result,
Lo,
Hi);
3704 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3705 SplitInteger(ExpandedCMP,
Lo,
Hi);
3708void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3712 SDValue LHSL, LHSH, RHSL, RHSH;
3713 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3714 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3717 SDValue LoOps[2] = { LHSL, RHSL };
3718 SDValue HiOps[3] = { LHSH, RHSH };
3720 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3722 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3724 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3728 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3734 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3747 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3749 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3752 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3766 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3768 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3772 EVT OvfVT = getSetCCResultType(NVT);
3773 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3788 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3791 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3795 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3807 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3811 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3814 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3817 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3822 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3824 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3825 DAG.getConstant(0, dl, NVT));
3828 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3837 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3842 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3844 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3845 DAG.getConstant(0, dl, NVT));
3851void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3854 SDValue LHSL, LHSH, RHSL, RHSH;
3856 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3857 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3858 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3859 SDValue LoOps[2] = { LHSL, RHSL };
3860 SDValue HiOps[3] = { LHSH, RHSH };
3874 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3877void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3880 SDValue LHSL, LHSH, RHSL, RHSH;
3882 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3883 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3884 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3886 SDValue HiOps[3] = { LHSH, RHSH };
3888 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3890 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3894 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3897void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3905 unsigned CarryOp, NoCarryOp;
3907 switch(
N->getOpcode()) {
3922 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3923 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3927 SDValue LHSL, LHSH, RHSL, RHSH;
3928 GetExpandedInteger(
LHS, LHSL, LHSH);
3929 GetExpandedInteger(
RHS, RHSL, RHSH);
3930 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3931 SDValue LoOps[2] = { LHSL, RHSL };
3932 SDValue HiOps[3] = { LHSH, RHSH };
3934 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3936 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3943 SplitInteger(Sum,
Lo,
Hi);
3949 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
3950 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
3954 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
3959 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
3965 ReplaceValueWith(
SDValue(
N, 1), Ovf);
3971 SDValue LHSL, LHSH, RHSL, RHSH;
3973 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3974 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3975 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3979 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3981 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3985 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3988void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
3991 SDValue LHSL, LHSH, RHSL, RHSH;
3993 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3994 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3995 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4000 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4001 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4005 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4008void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4010 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4013 if (
Op.getValueType().bitsLE(NVT)) {
4016 Hi = DAG.getUNDEF(NVT);
4020 assert(getTypeAction(
Op.getValueType()) ==
4022 "Only know how to promote this result!");
4025 "Operand over promoted?");
4027 SplitInteger(Res,
Lo,
Hi);
4031void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4034 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4035 EVT NVT =
Lo.getValueType();
4040 if (NVTBits < EVTBits) {
4043 EVTBits - NVTBits)));
4048 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4052void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4055 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4056 EVT NVT =
Lo.getValueType();
4061 if (NVTBits < EVTBits) {
4064 EVTBits - NVTBits)));
4068 Hi = DAG.getConstant(0, dl, NVT);
4072void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4075 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4080void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4083 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4092 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4093 EVT NVT =
Lo.getValueType();
4096 Hi = DAG.getConstant(0, dl, NVT);
4099void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4101 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4104 const APInt &Cst =
Constant->getAPIntValue();
4105 bool IsTarget =
Constant->isTargetOpcode();
4106 bool IsOpaque =
Constant->isOpaque();
4108 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4109 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4117 GetExpandedInteger(N0,
Lo,
Hi);
4118 EVT NVT =
Lo.getValueType();
4124 Hi = DAG.getConstant(0, dl, NVT);
4134 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4139 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4140 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4149 EVT VT =
N->getValueType(0);
4151 DAG.getConstant(0, dl, VT), N0);
4153 SplitInteger(Neg, NegLo, NegHi);
4155 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4157 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4158 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4161void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4165 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4166 EVT NVT =
Lo.getValueType();
4168 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4171 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4174 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4175 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4178 Hi = DAG.getConstant(0, dl, NVT);
4186 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4187 EVT NVT =
Lo.getValueType();
4190 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4191 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4194 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4197 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4199 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4201 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4202 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4204 Hi = DAG.getConstant(0, dl, NVT);
4209 SplitInteger(Result,
Lo,
Hi);
4214 EVT VT =
N->getValueType(0);
4219 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4220 "LibCall explicitly requested, but not available");
4222 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4223 TargetLowering::MakeLibCallOptions CallOptions;
4227 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4228 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4236 GetExpandedInteger(
Op,
Lo,
Hi);
4237 EVT NVT =
Lo.getValueType();
4240 Hi = DAG.getConstant(0,
DL, NVT);
4243void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4247 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4248 EVT NVT =
Lo.getValueType();
4250 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4256 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4257 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4260 Hi = DAG.getConstant(0, dl, NVT);
4266 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4273 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4277 ReplaceValueWith(
SDValue(
N, 1), Chain);
4285 Chain =
Op.getValue(1);
4294 EVT VT =
N->getValueType(0);
4298 bool IsStrict =
N->isStrictFPOpcode();
4300 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4304 Op.getValueType() == MVT::bf16) {
4310 EVT OpVT =
Op.getValueType();
4314 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4315 TargetLowering::MakeLibCallOptions CallOptions;
4320 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4321 CallOptions, dl, Chain);
4322 SplitInteger(Tmp.first,
Lo,
Hi);
4325 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4330 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4331 SplitInteger(Res,
Lo,
Hi);
4337 bool IsStrict =
N->isStrictFPOpcode();
4338 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4341 EVT VT =
Op.getValueType();
4343 if (VT == MVT::f16) {
4349 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4353 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4357 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4361 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4365 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4369 EVT RetVT =
N->getValueType(0);
4371 TargetLowering::MakeLibCallOptions CallOptions;
4373 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4374 Op, CallOptions, dl,
4376 SplitInteger(Tmp.first,
Lo,
Hi);
4378 if (
N->isStrictFPOpcode())
4379 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4382void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4384 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4387 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4393 EVT VT =
N->getValueType(0);
4394 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4399 AAMDNodes AAInfo =
N->getAAInfo();
4404 if (
N->getMemoryVT().bitsLE(NVT)) {
4405 EVT MemVT =
N->getMemoryVT();
4407 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4408 N->getBaseAlign(), MMOFlags, AAInfo);
4416 unsigned LoSize =
Lo.getValueSizeInBits();
4418 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4421 Hi = DAG.getConstant(0, dl, NVT);
4425 Hi = DAG.getUNDEF(NVT);
4427 }
else if (DAG.getDataLayout().isLittleEndian()) {
4429 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4432 unsigned ExcessBits =
4439 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4440 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4441 N->getBaseAlign(), MMOFlags, AAInfo);
4450 EVT MemVT =
N->getMemoryVT();
4453 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4456 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4459 N->getBaseAlign(), MMOFlags, AAInfo);
4465 N->getPointerInfo().getWithOffset(IncrementSize),
4467 N->getBaseAlign(), MMOFlags, AAInfo);
4479 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4483 DAG.getShiftAmountConstant(
4490 ReplaceValueWith(
SDValue(
N, 1), Ch);
4493void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4497 GetExpandedInteger(
N->getOperand(0), LL, LH);
4498 GetExpandedInteger(
N->getOperand(1), RL, RH);
4502 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4504 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4505 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4508void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4510 EVT VT =
N->getValueType(0);
4511 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4515 GetExpandedInteger(
N->getOperand(0), LL, LH);
4516 GetExpandedInteger(
N->getOperand(1), RL, RH);
4518 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4525 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4526 if (LCImpl == RTLIB::Unsupported) {
4529 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4535 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4536 TargetLowering::MakeLibCallOptions CallOptions;
4538 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4545 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4546 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4547 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4550 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4555 SplitInteger(Result,
Lo,
Hi);
4561 SplitInteger(Result,
Lo,
Hi);
4567 SplitInteger(Result,
Lo,
Hi);
4578 EVT VT =
N->getValueType(0);
4582 uint64_t Scale =
N->getConstantOperandVal(2);
4594 EVT BoolVT = getSetCCResultType(VT);
4596 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4602 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4603 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4609 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4610 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4615 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4616 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4619 SplitInteger(Result,
Lo,
Hi);
4625 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4627 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4629 GetExpandedInteger(
LHS, LL, LH);
4630 GetExpandedInteger(
RHS, RL, RH);
4634 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4641 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4642 SplitInteger(LoTmp, Result[0], Result[1]);
4643 SplitInteger(HiTmp, Result[2], Result[3]);
4645 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4648 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4649 "the size of the current value type");
4670 uint64_t Part0 = Scale / NVTSize;
4671 if (Scale % NVTSize) {
4672 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4675 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4687 if (Scale == VTSize)
4706 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4707 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4708 EVT BoolNVT = getSetCCResultType(NVT);
4711 if (Scale < NVTSize) {
4714 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4715 DAG.getShiftAmountConstant(Scale, NVT, dl));
4716 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4717 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4718 }
else if (Scale == NVTSize) {
4720 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4721 }
else if (Scale < VTSize) {
4725 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4726 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4729 "(and saturation can't happen with Scale==VTSize).");
4731 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4732 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4736 if (Scale < NVTSize) {
4741 unsigned OverflowBits = VTSize - Scale + 1;
4742 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4743 "Extent of overflow bits must start within HL");
4744 SDValue HLHiMask = DAG.getConstant(
4746 SDValue HLLoMask = DAG.getConstant(
4753 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4759 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4760 }
else if (Scale == NVTSize) {
4766 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4772 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4773 }
else if (Scale < VTSize) {
4776 unsigned OverflowBits = VTSize - Scale + 1;
4777 SDValue HHHiMask = DAG.getConstant(
4779 SDValue HHLoMask = DAG.getConstant(
4781 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4782 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4789 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4790 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4793 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4794 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4801 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4803 N->getConstantOperandVal(2), DAG);
4807 N->getConstantOperandVal(2), TLI, DAG);
4808 SplitInteger(Res,
Lo,
Hi);
4811void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4814 "Node has unexpected Opcode");
4824 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4825 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4829 SDValue LHSL, LHSH, RHSL, RHSH;
4830 GetExpandedInteger(
LHS, LHSL, LHSH);
4831 GetExpandedInteger(
RHS, RHSL, RHSH);
4832 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4835 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4844 SplitInteger(Sum,
Lo,
Hi);
4869 EVT VT =
LHS.getValueType();
4872 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4876 EVT OType =
Node->getValueType(1);
4877 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4881 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4884void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4886 EVT VT =
N->getValueType(0);
4888 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4897 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4899 TargetLowering::MakeLibCallOptions CallOptions;
4901 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4904void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4907 SDValue Shiftee =
N->getOperand(0);
4914 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4915 }
while (!TLI.isTypeLegal(LoadVT));
4920 "Shifting unit is not a a power of two!");
4922 const bool IsOneStepShift =
4923 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4928 if (!IsOneStepShift)
4929 ShAmt = DAG.getFreeze(ShAmt);
4932 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4933 unsigned VTByteWidth = VTBitWidth / 8;
4935 "Shiftee type size is not a power of two!");
4936 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4937 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4942 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
4944 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
4945 EVT PtrTy =
StackPtr.getValueType();
4946 SDValue Ch = DAG.getEntryNode();
4949 DAG.getMachineFunction(),
4955 unsigned WideningOpc =
4957 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
4960 SDValue AllZeros = DAG.getConstant(0, dl, VT);
4964 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
4970 Flags.setExact(IsOneStepShift);
4973 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
4975 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
4976 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
4979 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
4984 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
4991 if (DAG.getDataLayout().isBigEndian())
4992 WillIndexUpwards = !WillIndexUpwards;
4995 if (WillIndexUpwards) {
4998 AdjStackPtr = DAG.getMemBasePlusOffset(
4999 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5000 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5004 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5005 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5009 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5014 if (!IsOneStepShift) {
5016 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5017 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5018 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5022 SplitInteger(Res,
Lo,
Hi);
5025void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5027 EVT VT =
N->getValueType(0);
5028 unsigned Opc =
N->getOpcode();
5034 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5038 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5055 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5057 const bool LegalOrCustom =
5061 unsigned ExpansionFactor = 1;
5063 for (EVT TmpVT = NVT;;) {
5064 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5065 if (NewTMPVT == TmpVT)
5072 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5075 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5077 if (LegalOrCustom &&
5081 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5087 SDValue ShiftOp =
N->getOperand(1);
5088 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5090 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5093 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5094 Hi =
Lo.getValue(1);
5099 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5113 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5116 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5118 TargetLowering::MakeLibCallOptions CallOptions;
5121 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5126 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5130void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5132 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5135 if (
Op.getValueType().bitsLE(NVT)) {
5141 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5145 assert(getTypeAction(
Op.getValueType()) ==
5147 "Only know how to promote this result!");
5150 "Operand over promoted?");
5152 SplitInteger(Res,
Lo,
Hi);
5160void DAGTypeLegalizer::
5163 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5166 if (EVT.
bitsLE(
Lo.getValueType())) {
5174 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5175 Hi.getValueType(), dl));
5186void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5188 EVT VT =
N->getValueType(0);
5190 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5199 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5201 TargetLowering::MakeLibCallOptions CallOptions;
5203 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5206void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5208 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5218void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5220 EVT VT =
N->getValueType(0);
5239 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5240 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5241 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5243 EVT BitVT =
N->getValueType(1);
5244 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5246 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5248 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5249 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5268 SplitInteger(Three,
Lo,
Hi);
5272 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5277 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5282 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5286 if (LCImpl == RTLIB::Unsupported ||
5288 DAG.getMachineFunction().getName()) {
5291 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5292 N->getOperand(1), MulLo, MulHi);
5297 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5298 SplitInteger(MulLo,
Lo,
Hi);
5299 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5303 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5306 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5307 MachinePointerInfo());
5311 EVT ArgVT =
Op.getValueType();
5313 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5314 Entry.IsSExt =
true;
5315 Entry.IsZExt =
false;
5316 Args.push_back(Entry);
5320 TargetLowering::ArgListEntry
Entry(
5322 Entry.IsSExt =
true;
5323 Entry.IsZExt =
false;
5324 Args.push_back(Entry);
5326 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5328 TargetLowering::CallLoweringInfo CLI(DAG);
5331 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5332 Func, std::move(Args))
5335 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5337 SplitInteger(CallInfo.first,
Lo,
Hi);
5339 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5340 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5341 DAG.getConstant(0, dl, PtrVT),
5344 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5347void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5349 EVT VT =
N->getValueType(0);
5351 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5361 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5363 if (isTypeLegal(NVT)) {
5365 GetExpandedInteger(
N->getOperand(0), InL, InH);
5367 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5376 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5378 TargetLowering::MakeLibCallOptions CallOptions;
5379 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5382void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5384 EVT VT =
N->getValueType(0);
5386 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5396 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5398 if (isTypeLegal(NVT)) {
5400 GetExpandedInteger(
N->getOperand(0), InL, InH);
5402 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5411 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5413 TargetLowering::MakeLibCallOptions CallOptions;
5414 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5417void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5419 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5422 if (
Op.getValueType().bitsLE(NVT)) {
5425 Hi = DAG.getConstant(0, dl, NVT);
5429 assert(getTypeAction(
Op.getValueType()) ==
5431 "Only know how to promote this result!");
5434 "Operand over promoted?");
5436 SplitInteger(Res,
Lo,
Hi);
5438 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5444void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5448 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5450 SDValue Swap = DAG.getAtomicCmpSwap(
5459void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5463 SDValue Res = TLI.expandVecReduce(
N, DAG);
5464 SplitInteger(Res,
Lo,
Hi);
5467void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5473 N->getOperand(0),
N->getOperand(1));
5474 SplitInteger(Res,
Lo,
Hi);
5481 GetExpandedInteger(
N->getOperand(0), In3, In4);
5482 GetExpandedInteger(
N->getOperand(1), In1, In2);
5486 unsigned Opc =
N->getOpcode();
5489 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5494 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5496 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5500 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5501 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5506 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5507 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5512 SDValue Res = TLI.expandCLMUL(
N, DAG);
5513 return SplitInteger(Res,
Lo,
Hi);
5517 GetExpandedInteger(
N->getOperand(0), LL, LH);
5518 GetExpandedInteger(
N->getOperand(1), RL, RH);
5532 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5537 EVT VT =
N->getValueType(0);
5544 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5547 SplitInteger(Res,
Lo,
Hi);
5554 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5555 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5557 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5558 Lo = DAG.getPOISON(LoVT);
5559 Hi = DAG.getPOISON(HiVT);
5570bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5574 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5577 switch (
N->getOpcode()) {
5580 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5581 N->dump(&DAG);
dbgs() <<
"\n";
5586 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5590 Res = ExpandOp_FAKE_USE(
N);
5596 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5609 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5614 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5618 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5621 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5623 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5624 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5625 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5628 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5633 if (!Res.
getNode())
return false;
5641 "Invalid operand expansion");
5643 ReplaceValueWith(
SDValue(
N, 0), Res);
5649void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5653 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5654 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5655 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5668 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5675 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5676 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5707 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5708 RHSLo, LowCC,
false, DagCombineInfo, dl);
5710 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5714 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5715 RHSHi, CCCode,
false, DagCombineInfo, dl);
5719 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5728 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5730 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5739 if (LHSHi == RHSHi) {
5748 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5749 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5752 if (HasSETCCCARRY) {
5755 bool FlipOperands =
false;
5772 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5776 DAG.getCondCode(CCCode));
5782 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5783 false, DagCombineInfo, dl);
5786 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5787 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5794 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5799 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5804 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5805 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5806 N->getOperand(4)), 0);
5812 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5817 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5822 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5823 N->getOperand(2),
N->getOperand(3),
5824 DAG.getCondCode(CCCode)), 0);
5830 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5835 "Unexpected setcc expansion!");
5841 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5849 SDLoc dl = SDLoc(
N);
5851 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5852 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5853 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5866 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5876 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5877 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5881 return TLI.expandCMP(
N, DAG);
5889 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5890 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5894 bool IsStrict =
N->isStrictFPOpcode();
5898 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5899 EVT DstVT =
N->getValueType(0);
5902 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5903 "Don't know how to expand this XINT_TO_FP!");
5904 TargetLowering::MakeLibCallOptions CallOptions;
5906 std::pair<SDValue, SDValue> Tmp =
5907 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5912 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
5913 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
5918 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
5921 return ExpandOp_NormalStore(
N, OpNo);
5924 assert(OpNo == 1 &&
"Can only expand the stored value so far");
5926 EVT VT =
N->getOperand(1).getValueType();
5927 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5931 AAMDNodes AAInfo =
N->getAAInfo();
5937 if (
N->getMemoryVT().bitsLE(NVT)) {
5938 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5939 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
5940 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
5944 if (DAG.getDataLayout().isLittleEndian()) {
5946 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5948 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
5951 unsigned ExcessBits =
5958 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
5959 N->getPointerInfo().getWithOffset(IncrementSize),
5960 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
5966 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5968 EVT ExtVT =
N->getMemoryVT();
5971 unsigned ExcessBits = (EBytes - IncrementSize)*8;
5979 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
5983 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
5987 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
5988 N->getBaseAlign(), MMOFlags, AAInfo);
5993 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
5994 N->getPointerInfo().getWithOffset(IncrementSize),
5996 N->getBaseAlign(), MMOFlags, AAInfo);
6002 GetExpandedInteger(
N->getOperand(0), InL, InH);
6011 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6016SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6017 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6018 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6022 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6024 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6027SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6030 "cannot use llvm.write_register with illegal type", Fn,
6033 return N->getOperand(0);
6036SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6039 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6040 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6043 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0, V1,
N->getOperand(2));
6046SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6048 unsigned Factor =
N->getNumOperands();
6051 for (
unsigned i = 0; i != Factor; i++)
6052 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6057 for (
unsigned i = 0; i != Factor; i++)
6063SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6065 EVT OutVT =
N->getValueType(0);
6066 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6067 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6071 SDValue BaseIdx =
N->getOperand(1);
6088 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6092 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6098 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6107 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6111 "Promoted operand has an element type greater than result");
6124 InOp0 = GetPromotedInteger(InOp0);
6131 Ops.reserve(OutNumElems);
6132 for (
unsigned i = 0; i != OutNumElems; ++i) {
6137 N->getOperand(0), Index);
6138 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6143 return DAG.getBuildVector(NOutVT, dl,
Ops);
6146SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6147 EVT OutVT =
N->getValueType(0);
6148 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6149 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6161 Vec = GetPromotedInteger(Vec);
6167SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6170 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6176SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6178 EVT VT =
N->getValueType(0);
6183 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6184 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6187 return DAG.getVectorShuffle(OutVT, dl, V0, V1, NewMask);
6191 EVT OutVT =
N->getValueType(0);
6192 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6193 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6194 unsigned NumElems =
N->getNumOperands();
6201 Ops.reserve(NumElems);
6202 for (
unsigned i = 0; i != NumElems; ++i) {
6204 EVT OpVT =
Op.getValueType();
6209 if (OpVT.
bitsLT(NOutVTElem)) {
6215 ExtOpc = NOutExtOpc;
6216 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6221 return DAG.getBuildVector(NOutVT, dl,
Ops);
6228 assert(!
N->getOperand(0).getValueType().isVector() &&
6229 "Input must be a scalar");
6231 EVT OutVT =
N->getValueType(0);
6232 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6233 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6237 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6242 EVT OutVT =
N->getValueType(0);
6243 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6245 "Type must be promoted to a scalable vector type");
6246 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6247 return DAG.getStepVector(dl, NOutVT,
6251SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6254 EVT OutVT =
N->getValueType(0);
6255 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6256 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6258 unsigned NumOperands =
N->getNumOperands();
6263 SDUse *MaxSizedValue = std::max_element(
6265 EVT AVT = A.getValueType().getVectorElementType();
6266 EVT BVT = B.getValueType().getVectorElementType();
6267 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6273 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6275 EVT OpVT =
Op.getValueType();
6277 Op = GetPromotedInteger(
Op);
6280 "Unhandled legalization type");
6284 Op = DAG.getAnyExtOrTrunc(
6292 return DAG.getAnyExtOrTrunc(
6300 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6301 assert(NumElem * NumOperands == NumOutElem &&
6302 "Unexpected number of elements");
6306 for (
unsigned i = 0; i < NumOperands; ++i) {
6309 Op = GetPromotedInteger(
Op);
6310 EVT SclrTy =
Op.getValueType().getVectorElementType();
6311 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6312 "Unexpected number of elements");
6314 for (
unsigned j = 0;
j < NumElem; ++
j) {
6316 DAG.getVectorIdxConstant(j, dl));
6317 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6321 return DAG.getBuildVector(NOutVT, dl,
Ops);
6324SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6325 EVT VT =
N->getValueType(0);
6326 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6327 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6335 if (getTypeAction(
N->getOperand(0).getValueType())
6339 switch(
N->getOpcode()) {
6341 Promoted = SExtPromotedInteger(
N->getOperand(0));
6344 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6347 Promoted = GetPromotedInteger(
N->getOperand(0));
6359 DAG.getVectorIdxConstant(0, dl));
6361 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6365 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6368SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6369 EVT VT =
N->getValueType(0);
6370 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6374SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6375 EVT VT =
N->getValueType(0);
6376 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6380SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6382 EVT VT =
N->getValueType(0);
6383 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6384 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6385 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6389SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6390 EVT OutVT =
N->getValueType(0);
6391 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6392 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6397 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6400 NOutVTElem,
N->getOperand(1));
6402 V0, ConvElem,
N->getOperand(2));
6409 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6410 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6418 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6419 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6420 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6424 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6427 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6428 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6436 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6441SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6444 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6446 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6447 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6448 return DAG.getPOISON(NVT);
6451SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6453 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6454 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6455 TLI.getVectorIdxTy(DAG.getDataLayout()));
6462 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6465SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6470 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6475 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6477 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6489 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1), V1);
6490 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6493SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6495 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6503SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6506 EVT ResVT =
N->getValueType(0);
6507 unsigned NumElems =
N->getNumOperands();
6510 SDValue ResVec = DAG.getUNDEF(ResVT);
6514 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6516 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6528 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6529 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6533 for (
unsigned i=0; i<NumElem; ++i) {
6536 DAG.getVectorIdxConstant(i, dl));
6542 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6545SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6558 for (
unsigned I = 0;
I < OpNo;
I++)
6561 EVT Ty =
Op.getValueType();
6562 SDLoc
DL = SDLoc(
N);
6565 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6573 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6578 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6584SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6597 for (
unsigned I = 0;
I < OpNo;
I++)
6600 EVT Ty =
Op.getValueType();
6601 SDLoc
DL = SDLoc(
N);
6604 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6612 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6617 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")
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)
MachineInstr unsigned OpIdx
const SmallVectorImpl< MachineOperand > & Cond
static Type * getValueType(Value *V)
Returns the type of the given value/instruction V.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
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.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
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(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
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.
@ 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.
@ CTTZ_ZERO_UNDEF
Bit counting operators with an undefined result for zero inputs.
@ 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.
@ 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.
@ 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_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,...
@ 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.
@ 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.
@ 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 getPOWI(EVT RetVT)
getPOWI - Return the POWI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall 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 getLDEXP(EVT RetVT)
getLDEXP - Return the LDEXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall 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 getLLROUND(EVT VT)
LLVM_ABI Libcall getLROUND(EVT VT)
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 getLRINT(EVT RetVT)
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 getLLRINT(EVT RetVT)
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.
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)