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;
83 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
84 case ISD::VP_CTTZ_ELTS:
85 Res = PromoteIntRes_VP_CttzElements(
N);
88 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(
N);
break;
98 Res = PromoteIntRes_VECTOR_COMPRESS(
N);
104 Res = PromoteIntRes_Select(
N);
109 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
111 case ISD::SMAX: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
113 case ISD::UMAX: Res = PromoteIntRes_UMINUMAX(
N);
break;
116 case ISD::VP_SHL: Res = PromoteIntRes_SHL(
N);
break;
118 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
120 case ISD::VP_SRA: Res = PromoteIntRes_SRA(
N);
break;
122 case ISD::VP_SRL: Res = PromoteIntRes_SRL(
N);
break;
123 case ISD::VP_TRUNCATE:
126 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
127 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
131 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
133 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
135 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
137 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
140 Res = PromoteIntRes_VECTOR_SPLICE(
N);
144 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
147 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
149 Res = PromoteIntRes_BUILD_VECTOR(
N);
153 Res = PromoteIntRes_ScalarOp(
N);
157 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
162 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
165 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
169 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
175 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
179 case ISD::VP_SIGN_EXTEND:
181 case ISD::VP_ZERO_EXTEND:
184 case ISD::VP_FP_TO_SINT:
185 case ISD::VP_FP_TO_UINT:
193 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
197 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
201 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
216 case ISD::VP_MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
226 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
236 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
239 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
241 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
243 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
259 Res = PromoteIntRes_ADDSUBSHLSAT<EmptyMatchContext>(
N);
261 case ISD::VP_SADDSAT:
262 case ISD::VP_UADDSAT:
263 case ISD::VP_SSUBSAT:
264 case ISD::VP_USUBSAT:
265 Res = PromoteIntRes_ADDSUBSHLSAT<VPMatchContext>(
N);
270 Res = PromoteIntRes_CMP(
N);
283 case ISD::ABS: Res = PromoteIntRes_ABS(
N);
break;
316 Res = PromoteIntRes_VECREDUCE(
N);
319 case ISD::VP_REDUCE_ADD:
320 case ISD::VP_REDUCE_MUL:
321 case ISD::VP_REDUCE_AND:
322 case ISD::VP_REDUCE_OR:
323 case ISD::VP_REDUCE_XOR:
324 case ISD::VP_REDUCE_SMAX:
325 case ISD::VP_REDUCE_SMIN:
326 case ISD::VP_REDUCE_UMAX:
327 case ISD::VP_REDUCE_UMIN:
328 Res = PromoteIntRes_VP_REDUCE(
N);
333 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
337 Res = PromoteIntRes_FREEZE(
N);
342 Res = PromoteIntRes_Rotate(
N);
347 Res = PromoteIntRes_FunnelShift(
N);
352 Res = PromoteIntRes_VPFunnelShift(
N);
358 Res = PromoteIntRes_CLMUL(
N);
362 Res = PromoteIntRes_IS_FPCLASS(
N);
365 Res = PromoteIntRes_FFREXP(
N);
370 Res = PromoteIntRes_XRINT(
N);
374 Res = PromoteIntRes_PATCHPOINT(
N);
377 Res = PromoteIntRes_READ_REGISTER(
N);
383 SetPromotedInteger(
SDValue(
N, ResNo), Res);
388 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
389 return GetPromotedInteger(
Op);
392SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
394 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
395 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
400 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
402 Op.getValueType(),
Op,
N->getOperand(1));
407 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
409 Op.getValueType(),
Op,
N->getOperand(1));
413 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
416 switch (TLI.getExtendForAtomicOps()) {
432 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
433 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
443 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
445 Op2 = SExtPromotedInteger(Op2);
448 Op2 = ZExtPromotedInteger(Op2);
451 Op2 = GetPromotedInteger(Op2);
456 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
458 N->getChain(),
N->getBasePtr(),
459 Op2,
N->getMemOperand());
470 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
471 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
475 if (!TLI.isTypeLegal(SVT))
478 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
479 SDValue Res = DAG.getAtomicCmpSwap(
481 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
485 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
491 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
492 switch (TLI.getExtendForAtomicCmpSwapArg()) {
494 Op2 = SExtPromotedInteger(Op2);
497 Op2 = ZExtPromotedInteger(Op2);
500 Op2 = GetPromotedInteger(Op2);
507 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
508 SDValue Res = DAG.getAtomicCmpSwap(
509 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
510 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
512 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
520 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
521 EVT OutVT =
N->getValueType(0);
522 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
525 switch (getTypeAction(InVT)) {
531 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
535 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
538 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
546 BitConvertToInteger(GetScalarizedVector(InOp)));
555 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
556 Lo = BitConvertToInteger(
Lo);
557 Hi = BitConvertToInteger(
Hi);
559 if (DAG.getDataLayout().isBigEndian())
565 JoinIntegers(
Lo,
Hi));
580 if (DAG.getDataLayout().isBigEndian()) {
584 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
599 if (isTypeLegal(WideOutVT)) {
600 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
602 DAG.getVectorIdxConstant(0, dl));
611 DAG.getDataLayout().isLittleEndian()) {
622 if (isTypeLegal(WideVecVT)) {
624 DAG.getUNDEF(WideVecVT), InOp,
625 DAG.getVectorIdxConstant(0, dl));
633 CreateStackStoreLoad(InOp, OutVT));
637 SDValue V = GetPromotedInteger(
N->getOperand(0));
639 V.getValueType(), V);
643 SDValue Op = GetPromotedInteger(
N->getOperand(0));
644 EVT OVT =
N->getValueType(0);
645 EVT NVT =
Op.getValueType();
653 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
654 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
659 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
665 return DAG.getNode(ISD::VP_SRL, dl, NVT,
666 DAG.getNode(ISD::VP_BSWAP, dl, NVT,
Op, Mask, EVL), ShAmt,
671 SDValue Op = GetPromotedInteger(
N->getOperand(0));
672 EVT OVT =
N->getValueType(0);
673 EVT NVT =
Op.getValueType();
682 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
687 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
693 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
694 DAG.getNode(ISD::VP_BITREVERSE, dl, NVT,
Op, Mask, EVL),
702 TLI.getTypeToTransformTo(*DAG.getContext(),
703 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
708 EVT VT =
N->getValueType(0);
715 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
722 EVT OVT =
N->getValueType(0);
723 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
729 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
730 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
732 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
738 unsigned CtlzOpcode =
N->getOpcode();
739 if (CtlzOpcode ==
ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
741 SDValue ExtractLeadingBits = DAG.getConstant(
744 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
746 if (!
N->isVPOpcode())
747 return DAG.getNode(
ISD::SUB, dl, NVT,
748 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
752 return DAG.
getNode(ISD::VP_SUB, dl, NVT,
753 DAG.getNode(
N->getOpcode(), dl, NVT,
Op, Mask, EVL),
754 ExtractLeadingBits, Mask, EVL);
757 CtlzOpcode == ISD::VP_CTLZ_ZERO_UNDEF) {
759 SDValue Op = GetPromotedInteger(
N->getOperand(0));
763 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
764 if (!
N->isVPOpcode()) {
766 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
771 Op = DAG.getNode(ISD::VP_SHL, dl, NVT,
Op, ShiftConst, Mask, EVL);
772 return DAG.getNode(CtlzOpcode, dl, NVT,
Op, Mask, EVL);
778 EVT OVT =
N->getValueType(0);
779 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
782 SDValue ExtractLeadingBits = DAG.getConstant(
785 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
791 EVT OVT =
N->getValueType(0);
792 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
800 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
801 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
808 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
809 if (!
N->isVPOpcode())
810 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
814 return DAG.
getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op, Mask,
819 SDValue Op = GetPromotedInteger(
N->getOperand(0));
820 EVT OVT =
N->getValueType(0);
821 EVT NVT =
Op.getValueType();
828 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
829 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
833 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
839 unsigned NewOpc =
N->getOpcode();
840 if (NewOpc ==
ISD::CTTZ || NewOpc == ISD::VP_CTTZ) {
847 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
851 DAG.getNode(ISD::VP_OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT),
852 N->getOperand(1),
N->getOperand(2));
853 NewOpc = ISD::VP_CTTZ_ZERO_UNDEF;
856 if (!
N->isVPOpcode())
857 return DAG.getNode(NewOpc, dl, NVT,
Op);
858 return DAG.getNode(NewOpc, dl, NVT,
Op,
N->getOperand(1),
N->getOperand(2));
861SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
863 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
864 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
867SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
869 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
876 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
882 EVT SVT =
In.getValueType().getScalarType();
885 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
893 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
895 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
899 if (
N->isStrictFPOpcode()) {
900 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
901 {
N->getOperand(0),
N->getOperand(1)});
905 }
else if (NewOpc == ISD::VP_FP_TO_SINT || NewOpc == ISD::VP_FP_TO_UINT) {
906 Res = DAG.
getNode(NewOpc, dl, NVT, {
N->getOperand(0),
N->getOperand(1),
909 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
921 N->getOpcode() == ISD::VP_FP_TO_UINT)
925 DAG.getValueType(
N->getValueType(0).getScalarType()));
928SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
930 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
932 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
936SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
937 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
940 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
943SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
944 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
947 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
948 N->getOperand(0),
N->getOperand(1));
954 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
956 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
960 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
964 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
973 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
976 if (getTypeAction(
N->getOperand(0).getValueType())
978 SDValue Res = GetPromotedInteger(
N->getOperand(0));
987 DAG.getValueType(
N->getOperand(0).getValueType()));
989 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
996 if (
N->getNumOperands() != 1) {
997 assert(
N->getNumOperands() == 3 &&
"Unexpected number of operands!");
998 assert(
N->isVPOpcode() &&
"Expected VP opcode");
999 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
1000 N->getOperand(1),
N->getOperand(2));
1002 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
1007 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1011 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1012 N->getMemoryVT(),
N->getMemOperand());
1021 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
1022 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1025 :
N->getExtensionType();
1028 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1029 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
1030 N->getMemOperand(),
N->isExpandingLoad());
1038 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1039 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1046 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1047 N->getOffset(),
N->getMask(), ExtPassThru,
1048 N->getMemoryVT(),
N->getMemOperand(),
1049 N->getAddressingMode(), ExtType,
1050 N->isExpandingLoad());
1058 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1059 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1061 "Gather result type and the passThru argument type should be the same");
1068 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1069 N->getIndex(),
N->getScale() };
1070 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1071 N->getMemoryVT(), dl,
Ops,
1072 N->getMemOperand(),
N->getIndexType(),
1080SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1081 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1082 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1084 N->getOperand(1), Passthru);
1091 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1092 EVT VT =
N->getValueType(0);
1093 EVT SVT = getSetCCResultType(VT);
1094 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1095 unsigned NumOps =
N->getNumOperands();
1098 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1106 ReplaceValueWith(
SDValue(
N, 0), Res);
1109 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1112template <
class MatchContextClass>
1124 MatchContextClass matcher(DAG, TLI,
N);
1126 unsigned Opcode = matcher.getRootBaseOpcode();
1132 SExtOrZExtPromotedOperands(Op1, Op2);
1138 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1140 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1141 Op1 = SExtPromotedInteger(Op1);
1142 Op2 = SExtPromotedInteger(Op2);
1143 return matcher.getNode(
ISD::UADDSAT, dl, NVT, Op1, Op2);
1146 Op1 = ZExtPromotedInteger(Op1);
1147 Op2 = ZExtPromotedInteger(Op2);
1150 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1152 return matcher.getNode(
ISD::UMIN, dl, NVT,
Add, SatMax);
1159 Op1 = GetPromotedInteger(Op1);
1161 Op2 = ZExtPromotedInteger(Op2);
1163 Op1 = SExtPromotedInteger(Op1);
1164 Op2 = SExtPromotedInteger(Op2);
1171 if (IsShift || matcher.isOperationLegal(Opcode, PromotedType)) {
1184 "addition, subtraction or left shift");
1187 unsigned SHLAmount = NewBits - OldBits;
1189 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1194 SDValue Result = matcher.getNode(Opcode, dl, PromotedType, Op1, Op2);
1195 return matcher.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1201 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1202 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1203 SDValue Result = matcher.getNode(AddOp, dl, PromotedType, Op1, Op2);
1204 Result = matcher.getNode(
ISD::SMIN, dl, PromotedType, Result, SatMax);
1205 Result = matcher.getNode(
ISD::SMAX, dl, PromotedType, Result, SatMin);
1212 SDValue Op1Promoted, Op2Promoted;
1218 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1219 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1221 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1222 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1224 EVT OldType =
N->getOperand(0).getValueType();
1236 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1237 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1238 Op2Promoted,
N->getOperand(2));
1240 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1241 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1243 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1248 unsigned SatW,
bool Signed,
1251 EVT VT = V.getValueType();
1278 EVT VT =
LHS.getValueType();
1294 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1300 "Tried to saturate to more than the original type?");
1309 SDValue Op1Promoted, Op2Promoted;
1315 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1316 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1318 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1319 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1322 unsigned Scale =
N->getConstantOperandVal(2);
1326 if (TLI.isTypeLegal(PromotedType)) {
1328 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1331 N->getValueType(0).getScalarSizeInBits();
1335 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1336 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1337 Op2Promoted,
N->getOperand(2));
1340 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1346 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1347 Op2Promoted, Scale, DAG)) {
1350 N->getValueType(0).getScalarSizeInBits(),
1358 N->getValueType(0).getScalarSizeInBits());
1361SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1363 return PromoteIntRes_Overflow(
N);
1367 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1368 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1369 EVT OVT =
N->getOperand(0).getValueType();
1370 EVT NVT =
LHS.getValueType();
1380 DAG.getValueType(OVT));
1382 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1385 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1391 EVT PromotedResultTy =
1392 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1393 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1394 N->getOperand(0),
N->getOperand(1));
1400 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1401 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1403 unsigned Opcode =
N->getOpcode();
1404 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1405 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1407 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1411 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1412 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1414 LHS.getValueType(),
N->getOperand(0),
1415 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1420 EVT InVT =
N->getOperand(OpNo).getValueType();
1421 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1423 EVT SVT = getSetCCResultType(InVT);
1430 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1431 SVT = getSetCCResultType(InVT);
1439 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1440 "Vector compare must return a vector result!");
1444 if (
N->isStrictFPOpcode()) {
1445 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1446 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1447 N->getOperand(2),
N->getOperand(3)};
1448 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1453 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1454 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1457 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1464 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1469 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1470 EVT VT =
N->getValueType(0);
1474 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1476 ReplaceValueWith(
SDValue(
N, 0), Res);
1481 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1484 RHS = ZExtPromotedInteger(
RHS);
1485 if (
N->getOpcode() != ISD::VP_SHL)
1486 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1494SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1495 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1497 Op.getValueType(),
Op,
N->getOperand(1));
1500SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1504 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1505 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1506 if (
N->getNumOperands() == 2)
1507 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1508 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1509 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1510 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1511 N->getOperand(2),
N->getOperand(3));
1516 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1517 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1518 if (
N->getNumOperands() == 2)
1519 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1520 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1521 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1530 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1531 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1532 if (
N->getNumOperands() == 2)
1533 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1534 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1535 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1549 SExtOrZExtPromotedOperands(
LHS,
RHS);
1551 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1557 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1560 RHS = ZExtPromotedInteger(
RHS);
1561 if (
N->getOpcode() != ISD::VP_SRA)
1562 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1573 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1575 RHS = ZExtPromotedInteger(
RHS);
1576 if (
N->getOpcode() != ISD::VP_SRL)
1577 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1587 SDValue Res = TLI.expandROT(
N,
true , DAG);
1588 ReplaceValueWith(
SDValue(
N, 0), Res);
1593 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1594 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1597 Amt = ZExtPromotedInteger(Amt);
1601 EVT OldVT =
N->getOperand(0).getValueType();
1602 EVT VT =
Lo.getValueType();
1603 unsigned Opcode =
N->getOpcode();
1610 DAG.getConstant(OldBits,
DL, AmtVT));
1618 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1619 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1621 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1631 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1637 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1639 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1643SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1644 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1645 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1650 Amt = ZExtPromotedInteger(Amt);
1654 EVT OldVT =
N->getOperand(0).getValueType();
1655 EVT VT =
Lo.getValueType();
1656 unsigned Opcode =
N->getOpcode();
1657 bool IsFSHR = Opcode == ISD::VP_FSHR;
1662 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1663 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1671 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1672 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1673 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1674 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1676 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1679 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1684 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1685 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1690 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1692 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1696 unsigned Opcode =
N->getOpcode();
1699 EVT OldVT =
N->getOperand(0).getValueType();
1700 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1703 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT)) {
1704 if (
SDValue Res = TLI.expandCLMUL(
N, DAG))
1707 SDValue X = GetPromotedInteger(
N->getOperand(0));
1708 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1712 SDValue X = ZExtPromotedInteger(
N->getOperand(0));
1713 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1717 if (NewBits < 2 * OldBits) {
1719 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1721 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1723 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1725 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1730 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1732 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1736 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1748 Res = GetPromotedInteger(InOp);
1755 "Dst and Src must have the same number of elements");
1757 "Promoted vector type must be a power of two");
1760 GetSplitVector(InOp, EOp1, EOp2);
1768 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1769 "Expected VP_TRUNCATE opcode");
1770 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1771 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1772 std::tie(EVLLo, EVLHi) =
1773 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1774 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1775 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1782 SDValue WideInOp = GetWidenedVector(InOp);
1787 N->getValueType(0).getScalarType(), NumElem);
1796 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1802 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1803 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1808SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1810 return PromoteIntRes_Overflow(
N);
1814 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1815 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1816 EVT OVT =
N->getOperand(0).getValueType();
1817 EVT NVT =
LHS.getValueType();
1826 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1828 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1831 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1842 return PromoteIntRes_Overflow(
N);
1854 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1855 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1857 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1860 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1871 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1872 return PromoteIntRes_Overflow(
N);
1876 EVT OVT =
N->getValueType(0);
1877 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1883 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1884 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1885 if (
SDValue Res = TLI.expandABS(
N, DAG))
1889 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1893SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1896 return PromoteIntRes_Overflow(
N);
1900 EVT SmallVT =
LHS.getValueType();
1907 LHS = SExtPromotedInteger(
LHS);
1908 RHS = SExtPromotedInteger(
RHS);
1910 LHS = ZExtPromotedInteger(
LHS);
1911 RHS = ZExtPromotedInteger(
RHS);
1913 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1925 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1926 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1927 DAG.getConstant(0,
DL,
Hi.getValueType()),
1932 Mul, DAG.getValueType(SmallVT));
1942 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1947 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1948 N->getValueType(0)));
1952 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1954 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1961 EVT VT =
N->getValueType(0);
1964 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1965 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1969 for (
unsigned i = 0; i < NumRegs; ++i) {
1970 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
1971 N->getConstantOperandVal(3));
1976 if (DAG.getDataLayout().isBigEndian())
1977 std::reverse(Parts.begin(), Parts.end());
1980 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1982 for (
unsigned i = 1; i < NumRegs; ++i) {
1987 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1993 ReplaceValueWith(
SDValue(
N, 1), Chain);
2006bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
2009 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2014 switch (
N->getOpcode()) {
2017 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2018 N->dump(&DAG);
dbgs() <<
"\n";
2024 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2030 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2031 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2036 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2040 Res = PromoteIntOp_FAKE_USE(
N);
2043 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2047 Res = PromoteIntOp_ScalarOp(
N);
2050 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2053 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2055 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2056 case ISD::VP_SINT_TO_FP:
2073 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2075 case ISD::VP_TRUNCATE:
2079 case ISD::VP_UINT_TO_FP:
2082 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2087 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2098 Res = PromoteIntOp_Shift(
N);
2102 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2105 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2131 case ISD::VP_REDUCE_ADD:
2132 case ISD::VP_REDUCE_MUL:
2133 case ISD::VP_REDUCE_AND:
2134 case ISD::VP_REDUCE_OR:
2135 case ISD::VP_REDUCE_XOR:
2136 case ISD::VP_REDUCE_SMAX:
2137 case ISD::VP_REDUCE_SMIN:
2138 case ISD::VP_REDUCE_UMAX:
2139 case ISD::VP_REDUCE_UMIN:
2140 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2145 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2148 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2151 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2153 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2154 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2155 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2157 case ISD::EXPERIMENTAL_VP_SPLICE:
2158 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2161 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2164 Res = PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
N, OpNo);
2167 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2172 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2177 if (!Res.
getNode())
return false;
2184 const bool IsStrictFp =
N->isStrictFPOpcode();
2186 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2187 "Invalid operand expansion");
2191 ReplaceValueWith(
SDValue(
N, 0), Res);
2205 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2209 unsigned OpLEffectiveBits =
2210 DAG.computeKnownBits(OpL).countMaxActiveBits();
2211 unsigned OpREffectiveBits =
2212 DAG.computeKnownBits(OpR).countMaxActiveBits();
2213 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2214 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2221 LHS = SExtPromotedInteger(
LHS);
2222 RHS = SExtPromotedInteger(
RHS);
2231 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2232 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2233 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2234 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2241 LHS = ZExtPromotedInteger(
LHS);
2242 RHS = ZExtPromotedInteger(
RHS);
2256 LHS = SExtPromotedInteger(
LHS);
2257 RHS = SExtPromotedInteger(
RHS);
2262 "Unknown integer comparison!");
2264 SExtOrZExtPromotedOperands(
LHS,
RHS);
2268 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2272SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2273 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2274 EVT ResVT =
N->getValueType(0);
2275 EVT OpVT =
Op.getValueType();
2278 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2283 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2284 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2285 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2289 EVT OutVT =
N->getValueType(0);
2292 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2295 switch (getTypeAction(InVT)) {
2299 DAG.getDataLayout().isLittleEndian()) {
2309 if (isTypeLegal(WideVecVT)) {
2310 SDValue Promoted = GetPromotedInteger(InOp);
2313 DAG.getVectorIdxConstant(0, dl));
2326 return CreateStackStoreLoad(InOp, OutVT);
2329SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2330 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2338 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2339 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2343SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2344 assert(OpNo == 1 &&
"only know how to promote condition");
2347 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2350 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2351 N->getOperand(2)), 0);
2354SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2355 assert(OpNo == 1 &&
"only know how to promote condition");
2358 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2361 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2366 EVT OVT =
N->getOperand(0).getValueType();
2367 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2368 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2369 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2374 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2375 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2384 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2385 "Legal vector of one illegal element?");
2390 assert(
N->getOperand(0).getValueSizeInBits() >=
2391 N->getValueType(0).getScalarSizeInBits() &&
2392 "Type of inserted value narrower than vector element type!");
2395 for (
unsigned i = 0; i < NumElts; ++i)
2396 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2398 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2401SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2408 assert(
N->getOperand(1).getValueSizeInBits() >=
2409 N->getValueType(0).getScalarSizeInBits() &&
2410 "Type of inserted value narrower than vector element type!");
2411 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2412 GetPromotedInteger(
N->getOperand(1)),
2417 assert(OpNo == 2 &&
"Different operand and result vector types?");
2420 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2421 TLI.getVectorIdxTy(DAG.getDataLayout()));
2422 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2423 N->getOperand(1), Idx), 0);
2427 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2431 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2434SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2435 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2437 EVT OpTy =
N->getOperand(1).getValueType();
2440 if (
SDValue Res = WidenVSELECTMask(
N))
2441 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2442 Res,
N->getOperand(1),
N->getOperand(2));
2446 Cond = PromoteTargetBoolean(
Cond, OpVT);
2448 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2449 N->getOperand(2)), 0);
2452SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2453 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2461 N->getOperand(3),
N->getOperand(4)), 0);
2464SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2465 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2473 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2475 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2478 N->getOperand(3),
N->getOperand(4)),
2483 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2484 ZExtPromotedInteger(
N->getOperand(1))), 0);
2492 LHS = SExtPromotedInteger(
LHS);
2493 RHS = SExtPromotedInteger(
RHS);
2495 SExtOrZExtPromotedOperands(
LHS,
RHS);
2502 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2503 ZExtPromotedInteger(
N->getOperand(2))), 0);
2507 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2511 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2514SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2516 EVT VT =
N->getValueType(0);
2517 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2519 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2523 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2525 SDValue Shl = DAG.getNode(ISD::VP_SHL, dl, VT,
Op, ShAmt,
N->getOperand(1),
2527 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2532 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2533 return SDValue(DAG.UpdateNodeOperands(
N,
2534 SExtPromotedInteger(
N->getOperand(0)),
2535 N->getOperand(1),
N->getOperand(2)),
2537 return SDValue(DAG.UpdateNodeOperands(
N,
2538 SExtPromotedInteger(
N->getOperand(0))), 0);
2541SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2542 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2543 SExtPromotedInteger(
N->getOperand(1))), 0);
2548 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2551 SDValue Val = GetPromotedInteger(
N->getValue());
2554 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2555 N->getMemoryVT(),
N->getMemOperand());
2561 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2562 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2564 SDValue DataOp = GetPromotedInteger(
N->getValue());
2565 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2566 N->getMask(),
N->getVectorLength(),
2567 N->getMemoryVT(),
N->getMemOperand(),
2568 N->isCompressingStore());
2579 Mask = PromoteTargetBoolean(Mask, DataVT);
2582 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2585 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2586 DataOp = GetPromotedInteger(DataOp);
2588 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2589 N->getOffset(), Mask,
N->getMemoryVT(),
2590 N->getMemOperand(),
N->getAddressingMode(),
2591 true,
N->isCompressingStore());
2596 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2597 EVT DataVT =
N->getValueType(0);
2598 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2600 NewOps[OpNo] =
Mask;
2601 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2617 EVT DataVT =
N->getValueType(0);
2618 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2619 }
else if (OpNo == 4) {
2621 if (
N->isIndexSigned())
2623 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2625 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2627 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2629 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2641 bool TruncateStore =
N->isTruncatingStore();
2646 EVT DataVT =
N->getValue().getValueType();
2647 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2648 }
else if (OpNo == 4) {
2650 if (
N->isIndexSigned())
2652 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2654 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2656 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2657 TruncateStore =
true;
2660 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2661 SDLoc(
N), NewOps,
N->getMemOperand(),
2662 N->getIndexType(), TruncateStore);
2667 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2671 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2676 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2677 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2678 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2679 N->getOperand(1),
N->getOperand(2));
2684 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2685 return SDValue(DAG.UpdateNodeOperands(
N,
2686 ZExtPromotedInteger(
N->getOperand(0)),
2687 N->getOperand(1),
N->getOperand(2)),
2689 return SDValue(DAG.UpdateNodeOperands(
N,
2690 ZExtPromotedInteger(
N->getOperand(0))), 0);
2693SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2694 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2699SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2700 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2701 ZExtPromotedInteger(
N->getOperand(1))), 0);
2708 EVT VT =
N->getValueType(0);
2713 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2714 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2715 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2716 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2721 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2724SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2726 EVT VT =
N->getValueType(0);
2727 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2729 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2731 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2732 N->getOperand(0).getValueType());
2736 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2738 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2741SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2743 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2744 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2753 unsigned OpOffset = IsStrict ? 1 : 0;
2760 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2761 if (LCImpl == RTLIB::Unsupported) {
2767 if (IsPowI &&
N->getValueType(0).isVector())
2768 return DAG.UnrollVectorOp(
N);
2770 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2771 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2781 assert(DAG.getLibInfo().getIntSize() ==
2782 N->getOperand(1 + OpOffset).getValueType().getSizeInBits() &&
2783 "POWI exponent should match with sizeof(int) when doing the libcall.");
2784 TargetLowering::MakeLibCallOptions CallOptions;
2786 SDValue Ops[2] = {
N->getOperand(0 + OpOffset),
N->getOperand(1 + OpOffset)};
2787 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2788 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2789 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2791 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2796 switch (
N->getOpcode()) {
2804 case ISD::VP_REDUCE_ADD:
2805 case ISD::VP_REDUCE_MUL:
2806 case ISD::VP_REDUCE_AND:
2807 case ISD::VP_REDUCE_OR:
2808 case ISD::VP_REDUCE_XOR:
2812 case ISD::VP_REDUCE_SMAX:
2813 case ISD::VP_REDUCE_SMIN:
2817 case ISD::VP_REDUCE_UMAX:
2818 case ISD::VP_REDUCE_UMIN:
2828 return GetPromotedInteger(V);
2830 return SExtPromotedInteger(V);
2832 return ZExtPromotedInteger(V);
2838 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2840 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2841 EVT InVT =
Op.getValueType();
2843 EVT ResVT =
N->getValueType(0);
2844 unsigned Opcode =
N->getOpcode();
2861 switch (TLI.getBooleanContents(InVT)) {
2864 Op = ZExtPromotedInteger(
N->getOperand(0));
2867 Op = SExtPromotedInteger(
N->getOperand(0));
2880 switch (TLI.getBooleanContents(InVT)) {
2883 Op = ZExtPromotedInteger(
N->getOperand(0));
2886 Op = SExtPromotedInteger(
N->getOperand(0));
2892 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2896 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2900SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2907 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2908 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2911 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2913 Op = PromoteIntOpVectorReduction(
N,
Op);
2917 EVT VT =
N->getValueType(0);
2918 EVT EltVT =
Op.getValueType().getScalarType();
2921 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2933 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2934 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2937SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2940 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2941 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2944SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2947 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2948 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2953 const Function &Fn = DAG.getMachineFunction().getFunction();
2955 "cannot use llvm.write_register with illegal type", Fn,
2957 return N->getOperand(0);
2960SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2961 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2962 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2965 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2967 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2970SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2974 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2975 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2978 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2980 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2981 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2984SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2986 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2988 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2989 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2992SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N,
2995 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2996 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2999SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
3001 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3002 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3003 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3006SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3008 switch (
N->getOpcode()) {
3010 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3011 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3014 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3015 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3018 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3019 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3024 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3035void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3041 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3044 switch (
N->getOpcode()) {
3047 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3048 N->dump(&DAG);
dbgs() <<
"\n";
3126 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3127 SplitInteger(Tmp.first,
Lo,
Hi);
3128 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3133 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3134 SDValue Tmp = DAG.getAtomicCmpSwap(
3136 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3145 SplitInteger(Tmp,
Lo,
Hi);
3224 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3229 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3235 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3239 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3243 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3248 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3258std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3259 unsigned Opc =
Node->getOpcode();
3265 EVT RetVT =
Node->getValueType(0);
3266 TargetLowering::MakeLibCallOptions CallOptions;
3269 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3270 if (LCImpl != RTLIB::Unsupported) {
3272 Ops.push_back(
Node->getOperand(1));
3275 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3276 "Unexpected atomic op or value type!");
3278 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3280 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3281 Node->getOperand(0));
3286void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3291 GetExpandedInteger(
N->getOperand(0), InL, InH);
3306 if (Amt.
uge(VTBits)) {
3307 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3308 }
else if (Amt.
ugt(NVTBits)) {
3309 Lo = DAG.getConstant(0,
DL, NVT);
3311 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3312 }
else if (Amt == NVTBits) {
3313 Lo = DAG.getConstant(0,
DL, NVT);
3317 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3319 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3321 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3326 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3328 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3335 if (Amt.
uge(VTBits)) {
3336 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3337 }
else if (Amt.
ugt(NVTBits)) {
3339 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3340 Hi = DAG.getConstant(0,
DL, NVT);
3341 }
else if (Amt == NVTBits) {
3343 Hi = DAG.getConstant(0,
DL, NVT);
3346 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3348 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3353 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3355 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3358 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3364 if (Amt.
uge(VTBits)) {
3366 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3367 }
else if (Amt.
ugt(NVTBits)) {
3369 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3371 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3372 }
else if (Amt == NVTBits) {
3375 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3378 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3380 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3385 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3387 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3390 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3398bool DAGTypeLegalizer::
3400 unsigned Opc =
N->getOpcode();
3403 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3408 "Expanded integer type size not a power of two!");
3412 KnownBits Known = DAG.computeKnownBits(Amt);
3415 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3420 GetExpandedInteger(In, InL, InH);
3427 DAG.getConstant(~HighBitMask, dl, ShTy));
3432 Lo = DAG.getConstant(0, dl, NVT);
3433 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3436 Hi = DAG.getConstant(0, dl, NVT);
3437 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3441 DAG.getConstant(NVTBits - 1, dl, ShTy));
3442 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3454 DAG.getConstant(NVTBits - 1, dl, ShTy));
3470 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3472 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3474 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3475 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3487bool DAGTypeLegalizer::
3490 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3494 "Expanded integer type size not a power of two!");
3499 GetExpandedInteger(
N->getOperand(0), InL, InH);
3501 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3504 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3507 Amt, DAG.getConstant(0, dl, ShTy),
3511 switch (
N->getOpcode()) {
3517 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3518 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3521 LoL = DAG.getConstant(0, dl, NVT);
3524 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3525 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3526 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3532 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3535 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3538 HiL = DAG.getConstant(0, dl, NVT);
3541 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3542 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3543 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3549 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3550 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3554 DAG.getConstant(NVTBits - 1, dl, ShTy));
3557 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3558 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3559 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3584 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3589 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3590 SplitInteger(Res,
Lo,
Hi);
3593void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3602 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3603 unsigned NumHalfBits = NumBits / 2;
3604 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3605 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3606 SDValue LHSL, LHSH, RHSL, RHSH;
3607 GetExpandedInteger(
LHS, LHSL, LHSH);
3608 GetExpandedInteger(
RHS, RHSL, RHSH);
3611 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3613 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3621 SDValue LHSL, LHSH, RHSL, RHSH;
3622 GetExpandedInteger(
LHS, LHSL, LHSH);
3623 GetExpandedInteger(
RHS, RHSL, RHSH);
3625 EVT CCT = getSetCCResultType(NVT);
3628 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3630 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3632 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3634 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3638 const APInt *RHSVal =
nullptr;
3640 RHSVal = &RHSConst->getAPIntValue();
3647 SDValue LHSL, LHSH, RHSL, RHSH;
3648 GetExpandedInteger(
LHS, LHSL, LHSH);
3649 GetExpandedInteger(
RHS, RHSL, RHSH);
3651 EVT CCT = getSetCCResultType(NVT);
3657 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3660 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3664 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3667 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3669 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3676 switch (
N->getOpcode()) {
3703 EVT VT =
N->getValueType(0);
3704 EVT CCT = getSetCCResultType(VT);
3707 SplitInteger(Result,
Lo,
Hi);
3711 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3712 SplitInteger(ExpandedCMP,
Lo,
Hi);
3715void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3719 SDValue LHSL, LHSH, RHSL, RHSH;
3720 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3721 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3724 SDValue LoOps[2] = { LHSL, RHSL };
3725 SDValue HiOps[3] = { LHSH, RHSH };
3727 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3729 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3731 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3735 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3741 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3754 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3756 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3759 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3773 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3775 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3779 EVT OvfVT = getSetCCResultType(NVT);
3780 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3795 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3798 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3802 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3814 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3818 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3821 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3824 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3829 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3831 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3832 DAG.getConstant(0, dl, NVT));
3835 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3844 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3849 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3851 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3852 DAG.getConstant(0, dl, NVT));
3858void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3861 SDValue LHSL, LHSH, RHSL, RHSH;
3863 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3864 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3865 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3866 SDValue LoOps[2] = { LHSL, RHSL };
3867 SDValue HiOps[3] = { LHSH, RHSH };
3881 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3884void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3887 SDValue LHSL, LHSH, RHSL, RHSH;
3889 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3890 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3891 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3893 SDValue HiOps[3] = { LHSH, RHSH };
3895 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3897 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3901 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3904void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3912 unsigned CarryOp, NoCarryOp;
3914 switch(
N->getOpcode()) {
3929 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3930 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3934 SDValue LHSL, LHSH, RHSL, RHSH;
3935 GetExpandedInteger(
LHS, LHSL, LHSH);
3936 GetExpandedInteger(
RHS, RHSL, RHSH);
3937 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3938 SDValue LoOps[2] = { LHSL, RHSL };
3939 SDValue HiOps[3] = { LHSH, RHSH };
3941 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3943 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3950 SplitInteger(Sum,
Lo,
Hi);
3956 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
3957 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
3961 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
3966 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
3972 ReplaceValueWith(
SDValue(
N, 1), Ovf);
3978 SDValue LHSL, LHSH, RHSL, RHSH;
3980 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3981 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3982 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3986 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3988 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3992 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3995void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
3998 SDValue LHSL, LHSH, RHSL, RHSH;
4000 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4001 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4002 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4007 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4008 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4012 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
4015void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4017 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4020 if (
Op.getValueType().bitsLE(NVT)) {
4023 Hi = DAG.getUNDEF(NVT);
4027 assert(getTypeAction(
Op.getValueType()) ==
4029 "Only know how to promote this result!");
4032 "Operand over promoted?");
4034 SplitInteger(Res,
Lo,
Hi);
4038void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4041 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4042 EVT NVT =
Lo.getValueType();
4047 if (NVTBits < EVTBits) {
4050 EVTBits - NVTBits)));
4055 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4059void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4062 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4063 EVT NVT =
Lo.getValueType();
4068 if (NVTBits < EVTBits) {
4071 EVTBits - NVTBits)));
4075 Hi = DAG.getConstant(0, dl, NVT);
4079void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4082 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4087void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4090 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4099 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4100 EVT NVT =
Lo.getValueType();
4103 Hi = DAG.getConstant(0, dl, NVT);
4106void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4108 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4111 const APInt &Cst =
Constant->getAPIntValue();
4112 bool IsTarget =
Constant->isTargetOpcode();
4113 bool IsOpaque =
Constant->isOpaque();
4115 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4116 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4124 GetExpandedInteger(N0,
Lo,
Hi);
4125 EVT NVT =
Lo.getValueType();
4131 Hi = DAG.getConstant(0, dl, NVT);
4141 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4146 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4147 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4156 EVT VT =
N->getValueType(0);
4158 DAG.getConstant(0, dl, VT), N0);
4160 SplitInteger(Neg, NegLo, NegHi);
4162 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4164 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4165 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4168void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4172 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4173 EVT NVT =
Lo.getValueType();
4175 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4178 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4181 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4182 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4185 Hi = DAG.getConstant(0, dl, NVT);
4193 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4194 EVT NVT =
Lo.getValueType();
4197 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4198 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4201 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4204 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4206 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4208 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4209 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4211 Hi = DAG.getConstant(0, dl, NVT);
4216 SplitInteger(Result,
Lo,
Hi);
4221 EVT VT =
N->getValueType(0);
4226 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4227 "LibCall explicitly requested, but not available");
4229 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4230 TargetLowering::MakeLibCallOptions CallOptions;
4234 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4235 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4243 GetExpandedInteger(
Op,
Lo,
Hi);
4244 EVT NVT =
Lo.getValueType();
4247 Hi = DAG.getConstant(0,
DL, NVT);
4250void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4254 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4255 EVT NVT =
Lo.getValueType();
4257 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4263 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4264 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4267 Hi = DAG.getConstant(0, dl, NVT);
4273 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4280 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4284 ReplaceValueWith(
SDValue(
N, 1), Chain);
4292 Chain =
Op.getValue(1);
4301 EVT VT =
N->getValueType(0);
4305 bool IsStrict =
N->isStrictFPOpcode();
4307 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4311 Op.getValueType() == MVT::bf16) {
4317 EVT OpVT =
Op.getValueType();
4321 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4322 TargetLowering::MakeLibCallOptions CallOptions;
4327 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4328 CallOptions, dl, Chain);
4329 SplitInteger(Tmp.first,
Lo,
Hi);
4332 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4337 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4338 SplitInteger(Res,
Lo,
Hi);
4344 bool IsStrict =
N->isStrictFPOpcode();
4345 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4348 EVT VT =
Op.getValueType();
4350 if (VT == MVT::f16) {
4356 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4360 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4364 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4368 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4372 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4376 EVT RetVT =
N->getValueType(0);
4378 TargetLowering::MakeLibCallOptions CallOptions;
4380 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4381 Op, CallOptions, dl,
4383 SplitInteger(Tmp.first,
Lo,
Hi);
4385 if (
N->isStrictFPOpcode())
4386 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4389void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4391 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4394 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4400 EVT VT =
N->getValueType(0);
4401 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4406 AAMDNodes AAInfo =
N->getAAInfo();
4411 if (
N->getMemoryVT().bitsLE(NVT)) {
4412 EVT MemVT =
N->getMemoryVT();
4414 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4415 N->getBaseAlign(), MMOFlags, AAInfo);
4423 unsigned LoSize =
Lo.getValueSizeInBits();
4425 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4428 Hi = DAG.getConstant(0, dl, NVT);
4432 Hi = DAG.getUNDEF(NVT);
4434 }
else if (DAG.getDataLayout().isLittleEndian()) {
4436 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4439 unsigned ExcessBits =
4446 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4447 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4448 N->getBaseAlign(), MMOFlags, AAInfo);
4457 EVT MemVT =
N->getMemoryVT();
4460 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4463 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4466 N->getBaseAlign(), MMOFlags, AAInfo);
4472 N->getPointerInfo().getWithOffset(IncrementSize),
4474 N->getBaseAlign(), MMOFlags, AAInfo);
4486 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4490 DAG.getShiftAmountConstant(
4497 ReplaceValueWith(
SDValue(
N, 1), Ch);
4500void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4504 GetExpandedInteger(
N->getOperand(0), LL, LH);
4505 GetExpandedInteger(
N->getOperand(1), RL, RH);
4509 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4511 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4512 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4515void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4517 EVT VT =
N->getValueType(0);
4518 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4522 GetExpandedInteger(
N->getOperand(0), LL, LH);
4523 GetExpandedInteger(
N->getOperand(1), RL, RH);
4525 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4532 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4533 if (LCImpl == RTLIB::Unsupported) {
4536 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4542 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4543 TargetLowering::MakeLibCallOptions CallOptions;
4545 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4552 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4553 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4554 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4557 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4562 SplitInteger(Result,
Lo,
Hi);
4568 SplitInteger(Result,
Lo,
Hi);
4574 SplitInteger(Result,
Lo,
Hi);
4585 EVT VT =
N->getValueType(0);
4589 uint64_t Scale =
N->getConstantOperandVal(2);
4601 EVT BoolVT = getSetCCResultType(VT);
4603 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4609 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4610 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4616 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4617 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4622 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4623 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4626 SplitInteger(Result,
Lo,
Hi);
4632 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4634 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4636 GetExpandedInteger(
LHS, LL, LH);
4637 GetExpandedInteger(
RHS, RL, RH);
4641 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4648 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4649 SplitInteger(LoTmp, Result[0], Result[1]);
4650 SplitInteger(HiTmp, Result[2], Result[3]);
4652 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4655 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4656 "the size of the current value type");
4677 uint64_t Part0 = Scale / NVTSize;
4678 if (Scale % NVTSize) {
4679 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4682 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4694 if (Scale == VTSize)
4713 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4714 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4715 EVT BoolNVT = getSetCCResultType(NVT);
4718 if (Scale < NVTSize) {
4721 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4722 DAG.getShiftAmountConstant(Scale, NVT, dl));
4723 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4724 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4725 }
else if (Scale == NVTSize) {
4727 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4728 }
else if (Scale < VTSize) {
4732 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4733 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4736 "(and saturation can't happen with Scale==VTSize).");
4738 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4739 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4743 if (Scale < NVTSize) {
4748 unsigned OverflowBits = VTSize - Scale + 1;
4749 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4750 "Extent of overflow bits must start within HL");
4751 SDValue HLHiMask = DAG.getConstant(
4753 SDValue HLLoMask = DAG.getConstant(
4760 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4766 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4767 }
else if (Scale == NVTSize) {
4773 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4779 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4780 }
else if (Scale < VTSize) {
4783 unsigned OverflowBits = VTSize - Scale + 1;
4784 SDValue HHHiMask = DAG.getConstant(
4786 SDValue HHLoMask = DAG.getConstant(
4788 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4789 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4796 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4797 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4800 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4801 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4808 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4810 N->getConstantOperandVal(2), DAG);
4814 N->getConstantOperandVal(2), TLI, DAG);
4815 SplitInteger(Res,
Lo,
Hi);
4818void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4821 "Node has unexpected Opcode");
4831 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4832 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4836 SDValue LHSL, LHSH, RHSL, RHSH;
4837 GetExpandedInteger(
LHS, LHSL, LHSH);
4838 GetExpandedInteger(
RHS, RHSL, RHSH);
4839 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4842 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4851 SplitInteger(Sum,
Lo,
Hi);
4876 EVT VT =
LHS.getValueType();
4879 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4883 EVT OType =
Node->getValueType(1);
4884 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4888 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4891void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4893 EVT VT =
N->getValueType(0);
4895 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4904 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4906 TargetLowering::MakeLibCallOptions CallOptions;
4908 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4911void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4914 SDValue Shiftee =
N->getOperand(0);
4921 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4922 }
while (!TLI.isTypeLegal(LoadVT));
4927 "Shifting unit is not a a power of two!");
4929 const bool IsOneStepShift =
4930 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4935 if (!IsOneStepShift)
4936 ShAmt = DAG.getFreeze(ShAmt);
4939 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4940 unsigned VTByteWidth = VTBitWidth / 8;
4942 "Shiftee type size is not a power of two!");
4943 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4944 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4949 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
4951 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
4952 EVT PtrTy =
StackPtr.getValueType();
4953 SDValue Ch = DAG.getEntryNode();
4956 DAG.getMachineFunction(),
4962 unsigned WideningOpc =
4964 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
4967 SDValue AllZeros = DAG.getConstant(0, dl, VT);
4971 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
4977 Flags.setExact(IsOneStepShift);
4980 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
4982 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
4983 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
4986 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
4991 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
4998 if (DAG.getDataLayout().isBigEndian())
4999 WillIndexUpwards = !WillIndexUpwards;
5002 if (WillIndexUpwards) {
5005 AdjStackPtr = DAG.getMemBasePlusOffset(
5006 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5007 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5011 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5012 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5016 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5021 if (!IsOneStepShift) {
5023 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5024 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5025 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5029 SplitInteger(Res,
Lo,
Hi);
5032void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5034 EVT VT =
N->getValueType(0);
5035 unsigned Opc =
N->getOpcode();
5041 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5045 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5062 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5064 const bool LegalOrCustom =
5068 unsigned ExpansionFactor = 1;
5070 for (EVT TmpVT = NVT;;) {
5071 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5072 if (NewTMPVT == TmpVT)
5079 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5082 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5084 if (LegalOrCustom &&
5088 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5094 SDValue ShiftOp =
N->getOperand(1);
5095 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5097 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5100 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5101 Hi =
Lo.getValue(1);
5106 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5120 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5123 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5125 TargetLowering::MakeLibCallOptions CallOptions;
5128 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5133 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5137void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5139 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5142 if (
Op.getValueType().bitsLE(NVT)) {
5148 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5152 assert(getTypeAction(
Op.getValueType()) ==
5154 "Only know how to promote this result!");
5157 "Operand over promoted?");
5159 SplitInteger(Res,
Lo,
Hi);
5167void DAGTypeLegalizer::
5170 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5173 if (EVT.
bitsLE(
Lo.getValueType())) {
5181 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5182 Hi.getValueType(), dl));
5193void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5195 EVT VT =
N->getValueType(0);
5197 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5206 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5208 TargetLowering::MakeLibCallOptions CallOptions;
5210 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5213void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5215 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5225void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5227 EVT VT =
N->getValueType(0);
5246 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5247 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5248 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5250 EVT BitVT =
N->getValueType(1);
5251 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5253 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5255 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5256 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5275 SplitInteger(Three,
Lo,
Hi);
5279 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5284 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5289 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5293 if (LCImpl == RTLIB::Unsupported ||
5295 DAG.getMachineFunction().getName()) {
5298 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5299 N->getOperand(1), MulLo, MulHi);
5304 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5305 SplitInteger(MulLo,
Lo,
Hi);
5306 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5310 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5313 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5314 MachinePointerInfo());
5318 EVT ArgVT =
Op.getValueType();
5320 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5321 Entry.IsSExt =
true;
5322 Entry.IsZExt =
false;
5323 Args.push_back(Entry);
5327 TargetLowering::ArgListEntry
Entry(
5329 Entry.IsSExt =
true;
5330 Entry.IsZExt =
false;
5331 Args.push_back(Entry);
5333 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5335 TargetLowering::CallLoweringInfo CLI(DAG);
5338 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5339 Func, std::move(Args))
5342 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5344 SplitInteger(CallInfo.first,
Lo,
Hi);
5346 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5347 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5348 DAG.getConstant(0, dl, PtrVT),
5351 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5354void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5356 EVT VT =
N->getValueType(0);
5358 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5368 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5370 if (isTypeLegal(NVT)) {
5372 GetExpandedInteger(
N->getOperand(0), InL, InH);
5374 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5383 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5385 TargetLowering::MakeLibCallOptions CallOptions;
5386 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5389void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5391 EVT VT =
N->getValueType(0);
5393 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5403 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5405 if (isTypeLegal(NVT)) {
5407 GetExpandedInteger(
N->getOperand(0), InL, InH);
5409 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5418 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5420 TargetLowering::MakeLibCallOptions CallOptions;
5421 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5424void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5426 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5429 if (
Op.getValueType().bitsLE(NVT)) {
5432 Hi = DAG.getConstant(0, dl, NVT);
5436 assert(getTypeAction(
Op.getValueType()) ==
5438 "Only know how to promote this result!");
5441 "Operand over promoted?");
5443 SplitInteger(Res,
Lo,
Hi);
5445 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5451void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5455 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5457 SDValue Swap = DAG.getAtomicCmpSwap(
5466void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5470 SDValue Res = TLI.expandVecReduce(
N, DAG);
5471 SplitInteger(Res,
Lo,
Hi);
5474void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5480 N->getOperand(0),
N->getOperand(1));
5481 SplitInteger(Res,
Lo,
Hi);
5488 GetExpandedInteger(
N->getOperand(0), In3, In4);
5489 GetExpandedInteger(
N->getOperand(1), In1, In2);
5493 unsigned Opc =
N->getOpcode();
5496 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5501 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5503 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5507 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5508 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5513 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5514 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5519 SDValue Res = TLI.expandCLMUL(
N, DAG);
5520 return SplitInteger(Res,
Lo,
Hi);
5524 GetExpandedInteger(
N->getOperand(0), LL, LH);
5525 GetExpandedInteger(
N->getOperand(1), RL, RH);
5539 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5544 EVT VT =
N->getValueType(0);
5551 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5554 SplitInteger(Res,
Lo,
Hi);
5561 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5562 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5564 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5565 Lo = DAG.getPOISON(LoVT);
5566 Hi = DAG.getPOISON(HiVT);
5573 EVT VT =
N->getSimpleValueType(0);
5574 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5576 "VectorIdxTy should be smaller than type to be expanded?");
5580 SplitInteger(Res,
Lo,
Hi);
5591bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5595 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5598 switch (
N->getOpcode()) {
5601 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5602 N->dump(&DAG);
dbgs() <<
"\n";
5607 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5611 Res = ExpandOp_FAKE_USE(
N);
5617 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5630 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5635 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5639 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5642 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5644 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5645 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5646 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5649 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5654 if (!Res.
getNode())
return false;
5662 "Invalid operand expansion");
5664 ReplaceValueWith(
SDValue(
N, 0), Res);
5670void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5674 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5675 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5676 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5689 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5696 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5697 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5728 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5729 RHSLo, LowCC,
false, DagCombineInfo, dl);
5731 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5735 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5736 RHSHi, CCCode,
false, DagCombineInfo, dl);
5740 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5749 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5751 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5760 if (LHSHi == RHSHi) {
5769 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5770 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5773 if (HasSETCCCARRY) {
5776 bool FlipOperands =
false;
5793 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5797 DAG.getCondCode(CCCode));
5803 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5804 false, DagCombineInfo, dl);
5807 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5808 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5815 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5820 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5825 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5826 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5827 N->getOperand(4)), 0);
5833 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5838 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5843 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5844 N->getOperand(2),
N->getOperand(3),
5845 DAG.getCondCode(CCCode)), 0);
5851 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5856 "Unexpected setcc expansion!");
5862 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5870 SDLoc dl = SDLoc(
N);
5872 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5873 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5874 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5887 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5897 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5898 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5902 return TLI.expandCMP(
N, DAG);
5910 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5911 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5915 bool IsStrict =
N->isStrictFPOpcode();
5919 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5920 EVT DstVT =
N->getValueType(0);
5923 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5924 "Don't know how to expand this XINT_TO_FP!");
5925 TargetLowering::MakeLibCallOptions CallOptions;
5927 std::pair<SDValue, SDValue> Tmp =
5928 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5933 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
5934 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
5939 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
5942 return ExpandOp_NormalStore(
N, OpNo);
5945 assert(OpNo == 1 &&
"Can only expand the stored value so far");
5947 EVT VT =
N->getOperand(1).getValueType();
5948 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5952 AAMDNodes AAInfo =
N->getAAInfo();
5958 if (
N->getMemoryVT().bitsLE(NVT)) {
5959 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5960 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
5961 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
5965 if (DAG.getDataLayout().isLittleEndian()) {
5967 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5969 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
5972 unsigned ExcessBits =
5979 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
5980 N->getPointerInfo().getWithOffset(IncrementSize),
5981 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
5987 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5989 EVT ExtVT =
N->getMemoryVT();
5992 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6000 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6004 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6008 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6009 N->getBaseAlign(), MMOFlags, AAInfo);
6014 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6015 N->getPointerInfo().getWithOffset(IncrementSize),
6017 N->getBaseAlign(), MMOFlags, AAInfo);
6023 GetExpandedInteger(
N->getOperand(0), InL, InH);
6032 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6037SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6038 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6039 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6043 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6045 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6048SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6051 "cannot use llvm.write_register with illegal type", Fn,
6054 return N->getOperand(0);
6057SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6060 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6061 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6064 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0, V1,
N->getOperand(2));
6067SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6069 unsigned Factor =
N->getNumOperands();
6072 for (
unsigned i = 0; i != Factor; i++)
6073 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6078 for (
unsigned i = 0; i != Factor; i++)
6084SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6086 EVT OutVT =
N->getValueType(0);
6087 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6088 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6092 SDValue BaseIdx =
N->getOperand(1);
6109 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6113 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6119 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6128 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6132 "Promoted operand has an element type greater than result");
6145 InOp0 = GetPromotedInteger(InOp0);
6152 Ops.reserve(OutNumElems);
6153 for (
unsigned i = 0; i != OutNumElems; ++i) {
6158 N->getOperand(0), Index);
6159 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6164 return DAG.getBuildVector(NOutVT, dl,
Ops);
6167SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6168 EVT OutVT =
N->getValueType(0);
6169 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6170 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6182 Vec = GetPromotedInteger(Vec);
6188SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6191 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6197SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6199 EVT VT =
N->getValueType(0);
6204 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6205 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6208 return DAG.getVectorShuffle(OutVT, dl, V0, V1, NewMask);
6212 EVT OutVT =
N->getValueType(0);
6213 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6214 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6215 unsigned NumElems =
N->getNumOperands();
6222 Ops.reserve(NumElems);
6223 for (
unsigned i = 0; i != NumElems; ++i) {
6225 EVT OpVT =
Op.getValueType();
6230 if (OpVT.
bitsLT(NOutVTElem)) {
6236 ExtOpc = NOutExtOpc;
6237 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6242 return DAG.getBuildVector(NOutVT, dl,
Ops);
6249 assert(!
N->getOperand(0).getValueType().isVector() &&
6250 "Input must be a scalar");
6252 EVT OutVT =
N->getValueType(0);
6253 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6254 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6258 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6263 EVT OutVT =
N->getValueType(0);
6264 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6266 "Type must be promoted to a scalable vector type");
6267 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6268 return DAG.getStepVector(dl, NOutVT,
6272SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6275 EVT OutVT =
N->getValueType(0);
6276 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6277 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6279 unsigned NumOperands =
N->getNumOperands();
6284 SDUse *MaxSizedValue = std::max_element(
6286 EVT AVT = A.getValueType().getVectorElementType();
6287 EVT BVT = B.getValueType().getVectorElementType();
6288 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6294 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6296 EVT OpVT =
Op.getValueType();
6298 Op = GetPromotedInteger(
Op);
6301 "Unhandled legalization type");
6305 Op = DAG.getAnyExtOrTrunc(
6313 return DAG.getAnyExtOrTrunc(
6321 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6322 assert(NumElem * NumOperands == NumOutElem &&
6323 "Unexpected number of elements");
6327 for (
unsigned i = 0; i < NumOperands; ++i) {
6330 Op = GetPromotedInteger(
Op);
6331 EVT SclrTy =
Op.getValueType().getVectorElementType();
6332 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6333 "Unexpected number of elements");
6335 for (
unsigned j = 0;
j < NumElem; ++
j) {
6337 DAG.getVectorIdxConstant(j, dl));
6338 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6342 return DAG.getBuildVector(NOutVT, dl,
Ops);
6345SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6346 EVT VT =
N->getValueType(0);
6347 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6348 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6356 if (getTypeAction(
N->getOperand(0).getValueType())
6360 switch(
N->getOpcode()) {
6362 Promoted = SExtPromotedInteger(
N->getOperand(0));
6365 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6368 Promoted = GetPromotedInteger(
N->getOperand(0));
6380 DAG.getVectorIdxConstant(0, dl));
6382 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6386 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6389SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6390 EVT VT =
N->getValueType(0);
6391 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6395SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6396 EVT VT =
N->getValueType(0);
6397 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6401SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6403 EVT VT =
N->getValueType(0);
6404 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6405 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6406 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6410SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6411 EVT OutVT =
N->getValueType(0);
6412 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6413 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6418 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6421 NOutVTElem,
N->getOperand(1));
6423 V0, ConvElem,
N->getOperand(2));
6430 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6431 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6439 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6440 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6441 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6445 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6448 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6449 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6457 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6462SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6465 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6467 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6468 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6469 return DAG.getPOISON(NVT);
6472SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6474 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6475 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6476 TLI.getVectorIdxTy(DAG.getDataLayout()));
6483 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6486SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6491 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6496 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6498 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6510 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1), V1);
6511 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6514SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6516 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6524SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6527 EVT ResVT =
N->getValueType(0);
6528 unsigned NumElems =
N->getNumOperands();
6531 SDValue ResVec = DAG.getUNDEF(ResVT);
6535 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6537 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6549 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6550 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6554 for (
unsigned i=0; i<NumElem; ++i) {
6557 DAG.getVectorIdxConstant(i, dl));
6563 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6566SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6579 for (
unsigned I = 0;
I < OpNo;
I++)
6582 EVT Ty =
Op.getValueType();
6583 SDLoc
DL = SDLoc(
N);
6586 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6594 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6599 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6605SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6618 for (
unsigned I = 0;
I < OpNo;
I++)
6621 EVT Ty =
Op.getValueType();
6622 SDLoc
DL = SDLoc(
N);
6625 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6633 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6638 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")
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.
@ CTTZ_ELTS
Returns the number of number of trailing (least significant) zero elements in a vector.
@ VECTOR_FIND_LAST_ACTIVE
Finds the index of the last active mask element Operands: Mask.
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ FAKE_USE
FAKE_USE represents a use of the operand but does not do anything.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ CLMUL
Carry-less multiplication operations.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ CONVERT_FROM_ARBITRARY_FP
CONVERT_FROM_ARBITRARY_FP - This operator converts from an arbitrary floating-point represented as an...
@ SET_ROUNDING
Set rounding mode.
@ SIGN_EXTEND
Conversion operators.
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ READSTEADYCOUNTER
READSTEADYCOUNTER - This corresponds to the readfixedcounter intrinsic.
@ 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)