32#define DEBUG_TYPE "legalize-types"
42void DAGTypeLegalizer::PromoteIntegerResult(
SDNode *
N,
unsigned ResNo) {
47 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true)) {
52 switch (
N->getOpcode()) {
55 dbgs() <<
"PromoteIntegerResult #" << ResNo <<
": ";
56 N->dump(&DAG);
dbgs() <<
"\n";
63 case ISD::VP_BITREVERSE:
66 case ISD::BSWAP: Res = PromoteIntRes_BSWAP(
N);
break;
69 case ISD::VP_CTLZ_ZERO_UNDEF:
72 case ISD::CTLZ: Res = PromoteIntRes_CTLZ(
N);
break;
73 case ISD::CTLS: Res = PromoteIntRes_CTLS(
N);
break;
76 case ISD::CTPOP: Res = PromoteIntRes_CTPOP_PARITY(
N);
break;
77 case ISD::VP_CTTZ_ZERO_UNDEF:
80 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(
N);
break;
81 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
82 case ISD::VP_CTTZ_ELTS:
83 Res = PromoteIntRes_VP_CttzElements(
N);
86 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(
N);
break;
96 Res = PromoteIntRes_VECTOR_COMPRESS(
N);
102 Res = PromoteIntRes_Select(
N);
107 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
109 case ISD::SMAX: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
111 case ISD::UMAX: Res = PromoteIntRes_UMINUMAX(
N);
break;
114 case ISD::VP_SHL: Res = PromoteIntRes_SHL(
N);
break;
116 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
118 case ISD::VP_SRA: Res = PromoteIntRes_SRA(
N);
break;
120 case ISD::VP_SRL: Res = PromoteIntRes_SRL(
N);
break;
121 case ISD::VP_TRUNCATE:
124 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
125 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
129 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
131 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
133 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
135 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
138 Res = PromoteIntRes_VECTOR_SPLICE(
N);
142 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
145 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
147 Res = PromoteIntRes_BUILD_VECTOR(
N);
151 Res = PromoteIntRes_ScalarOp(
N);
155 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
160 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
163 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
167 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
173 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
177 case ISD::VP_SIGN_EXTEND:
179 case ISD::VP_ZERO_EXTEND:
182 case ISD::VP_FP_TO_SINT:
183 case ISD::VP_FP_TO_UINT:
191 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
195 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
199 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
214 case ISD::VP_MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
224 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
234 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
237 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
239 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
241 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
257 Res = PromoteIntRes_ADDSUBSHLSAT<EmptyMatchContext>(
N);
259 case ISD::VP_SADDSAT:
260 case ISD::VP_UADDSAT:
261 case ISD::VP_SSUBSAT:
262 case ISD::VP_USUBSAT:
263 Res = PromoteIntRes_ADDSUBSHLSAT<VPMatchContext>(
N);
268 Res = PromoteIntRes_CMP(
N);
281 case ISD::ABS: Res = PromoteIntRes_ABS(
N);
break;
314 Res = PromoteIntRes_VECREDUCE(
N);
317 case ISD::VP_REDUCE_ADD:
318 case ISD::VP_REDUCE_MUL:
319 case ISD::VP_REDUCE_AND:
320 case ISD::VP_REDUCE_OR:
321 case ISD::VP_REDUCE_XOR:
322 case ISD::VP_REDUCE_SMAX:
323 case ISD::VP_REDUCE_SMIN:
324 case ISD::VP_REDUCE_UMAX:
325 case ISD::VP_REDUCE_UMIN:
326 Res = PromoteIntRes_VP_REDUCE(
N);
331 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
335 Res = PromoteIntRes_FREEZE(
N);
340 Res = PromoteIntRes_Rotate(
N);
345 Res = PromoteIntRes_FunnelShift(
N);
350 Res = PromoteIntRes_VPFunnelShift(
N);
356 Res = PromoteIntRes_CLMUL(
N);
360 Res = PromoteIntRes_IS_FPCLASS(
N);
363 Res = PromoteIntRes_FFREXP(
N);
368 Res = PromoteIntRes_XRINT(
N);
372 Res = PromoteIntRes_PATCHPOINT(
N);
375 Res = PromoteIntRes_READ_REGISTER(
N);
381 SetPromotedInteger(
SDValue(
N, ResNo), Res);
386 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
387 return GetPromotedInteger(
Op);
390SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
392 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
393 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
398 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
400 Op.getValueType(),
Op,
N->getOperand(1));
405 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
407 Op.getValueType(),
Op,
N->getOperand(1));
411 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
414 switch (TLI.getExtendForAtomicOps()) {
430 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
431 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
441 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
443 Op2 = SExtPromotedInteger(Op2);
446 Op2 = ZExtPromotedInteger(Op2);
449 Op2 = GetPromotedInteger(Op2);
454 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
456 N->getChain(),
N->getBasePtr(),
457 Op2,
N->getMemOperand());
468 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
469 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
473 if (!TLI.isTypeLegal(SVT))
476 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
477 SDValue Res = DAG.getAtomicCmpSwap(
479 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
483 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
489 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
490 switch (TLI.getExtendForAtomicCmpSwapArg()) {
492 Op2 = SExtPromotedInteger(Op2);
495 Op2 = ZExtPromotedInteger(Op2);
498 Op2 = GetPromotedInteger(Op2);
505 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
506 SDValue Res = DAG.getAtomicCmpSwap(
507 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
508 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
510 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
518 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
519 EVT OutVT =
N->getValueType(0);
520 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
523 switch (getTypeAction(InVT)) {
529 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
533 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
536 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
540 return DAG.getNode(
ISD::FP_TO_FP16, dl, NOutVT, GetPromotedFloat(InOp));
550 BitConvertToInteger(GetScalarizedVector(InOp)));
559 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
560 Lo = BitConvertToInteger(
Lo);
561 Hi = BitConvertToInteger(
Hi);
563 if (DAG.getDataLayout().isBigEndian())
569 JoinIntegers(
Lo,
Hi));
584 if (DAG.getDataLayout().isBigEndian()) {
588 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
603 if (isTypeLegal(WideOutVT)) {
604 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
606 DAG.getVectorIdxConstant(0, dl));
615 DAG.getDataLayout().isLittleEndian()) {
626 if (isTypeLegal(WideVecVT)) {
628 DAG.getUNDEF(WideVecVT), InOp,
629 DAG.getVectorIdxConstant(0, dl));
637 CreateStackStoreLoad(InOp, OutVT));
641 SDValue V = GetPromotedInteger(
N->getOperand(0));
643 V.getValueType(), V);
647 SDValue Op = GetPromotedInteger(
N->getOperand(0));
648 EVT OVT =
N->getValueType(0);
649 EVT NVT =
Op.getValueType();
657 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
658 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
663 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
669 return DAG.getNode(ISD::VP_SRL, dl, NVT,
670 DAG.getNode(ISD::VP_BSWAP, dl, NVT,
Op, Mask, EVL), ShAmt,
675 SDValue Op = GetPromotedInteger(
N->getOperand(0));
676 EVT OVT =
N->getValueType(0);
677 EVT NVT =
Op.getValueType();
686 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
691 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
697 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
698 DAG.getNode(ISD::VP_BITREVERSE, dl, NVT,
Op, Mask, EVL),
706 TLI.getTypeToTransformTo(*DAG.getContext(),
707 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
712 EVT VT =
N->getValueType(0);
719 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
726 EVT OVT =
N->getValueType(0);
727 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
733 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
734 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
736 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
742 unsigned CtlzOpcode =
N->getOpcode();
743 if (CtlzOpcode ==
ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
745 SDValue ExtractLeadingBits = DAG.getConstant(
748 if (!
N->isVPOpcode()) {
750 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
751 return DAG.getNode(
ISD::SUB, dl, NVT,
752 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
758 SDValue Op = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
759 return DAG.getNode(ISD::VP_SUB, dl, NVT,
760 DAG.getNode(
N->getOpcode(), dl, NVT,
Op, Mask, EVL),
761 ExtractLeadingBits, Mask, EVL);
764 CtlzOpcode == ISD::VP_CTLZ_ZERO_UNDEF) {
766 SDValue Op = GetPromotedInteger(
N->getOperand(0));
770 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
771 if (!
N->isVPOpcode()) {
773 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
778 Op = DAG.getNode(ISD::VP_SHL, dl, NVT,
Op, ShiftConst, Mask, EVL);
779 return DAG.getNode(CtlzOpcode, dl, NVT,
Op, Mask, EVL);
785 EVT OVT =
N->getValueType(0);
786 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
789 SDValue ExtractLeadingBits = DAG.getConstant(
792 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
798 EVT OVT =
N->getValueType(0);
799 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
807 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
808 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
815 if (!
N->isVPOpcode()) {
816 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
817 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
822 SDValue Op = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
823 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op, Mask,
828 SDValue Op = GetPromotedInteger(
N->getOperand(0));
829 EVT OVT =
N->getValueType(0);
830 EVT NVT =
Op.getValueType();
837 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
838 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
842 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
848 unsigned NewOpc =
N->getOpcode();
849 if (NewOpc ==
ISD::CTTZ || NewOpc == ISD::VP_CTTZ) {
856 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
860 DAG.getNode(ISD::VP_OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT),
861 N->getOperand(1),
N->getOperand(2));
862 NewOpc = ISD::VP_CTTZ_ZERO_UNDEF;
865 if (!
N->isVPOpcode())
866 return DAG.getNode(NewOpc, dl, NVT,
Op);
867 return DAG.getNode(NewOpc, dl, NVT,
Op,
N->getOperand(1),
N->getOperand(2));
870SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
872 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
873 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
876SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
878 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
885 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
891 EVT SVT =
In.getValueType().getScalarType();
894 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
902 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
904 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
908 if (
N->isStrictFPOpcode()) {
909 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
910 {
N->getOperand(0),
N->getOperand(1)});
914 }
else if (NewOpc == ISD::VP_FP_TO_SINT || NewOpc == ISD::VP_FP_TO_UINT) {
915 Res = DAG.
getNode(NewOpc, dl, NVT, {
N->getOperand(0),
N->getOperand(1),
918 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
930 N->getOpcode() == ISD::VP_FP_TO_UINT)
934 DAG.getValueType(
N->getValueType(0).getScalarType()));
937SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
939 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
941 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
945SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
946 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
949 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
952SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
953 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
956 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
957 N->getOperand(0),
N->getOperand(1));
963 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
965 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
969 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
973 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
982 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
985 if (getTypeAction(
N->getOperand(0).getValueType())
987 SDValue Res = GetPromotedInteger(
N->getOperand(0));
996 DAG.getValueType(
N->getOperand(0).getValueType()));
998 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
1005 if (
N->getNumOperands() != 1) {
1006 assert(
N->getNumOperands() == 3 &&
"Unexpected number of operands!");
1007 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1008 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
1009 N->getOperand(1),
N->getOperand(2));
1011 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
1016 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1020 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1021 N->getMemoryVT(),
N->getMemOperand());
1030 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
1031 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1034 :
N->getExtensionType();
1037 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1038 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
1039 N->getMemOperand(),
N->isExpandingLoad());
1047 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1048 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1055 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1056 N->getOffset(),
N->getMask(), ExtPassThru,
1057 N->getMemoryVT(),
N->getMemOperand(),
1058 N->getAddressingMode(), ExtType,
1059 N->isExpandingLoad());
1067 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1068 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1070 "Gather result type and the passThru argument type should be the same");
1077 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1078 N->getIndex(),
N->getScale() };
1079 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1080 N->getMemoryVT(), dl,
Ops,
1081 N->getMemOperand(),
N->getIndexType(),
1089SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1090 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1091 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1093 N->getOperand(1), Passthru);
1100 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1101 EVT VT =
N->getValueType(0);
1102 EVT SVT = getSetCCResultType(VT);
1103 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1104 unsigned NumOps =
N->getNumOperands();
1107 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1115 ReplaceValueWith(
SDValue(
N, 0), Res);
1118 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1121template <
class MatchContextClass>
1133 MatchContextClass matcher(DAG, TLI,
N);
1135 unsigned Opcode = matcher.getRootBaseOpcode();
1141 SExtOrZExtPromotedOperands(Op1, Op2);
1147 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1149 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1150 Op1 = SExtPromotedInteger(Op1);
1151 Op2 = SExtPromotedInteger(Op2);
1152 return matcher.getNode(
ISD::UADDSAT, dl, NVT, Op1, Op2);
1155 Op1 = ZExtPromotedInteger(Op1);
1156 Op2 = ZExtPromotedInteger(Op2);
1159 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1161 return matcher.getNode(
ISD::UMIN, dl, NVT,
Add, SatMax);
1168 Op1 = GetPromotedInteger(Op1);
1170 Op2 = ZExtPromotedInteger(Op2);
1172 Op1 = SExtPromotedInteger(Op1);
1173 Op2 = SExtPromotedInteger(Op2);
1180 if (IsShift || matcher.isOperationLegal(Opcode, PromotedType)) {
1193 "addition, subtraction or left shift");
1196 unsigned SHLAmount = NewBits - OldBits;
1198 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1203 SDValue Result = matcher.getNode(Opcode, dl, PromotedType, Op1, Op2);
1204 return matcher.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1210 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1211 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1212 SDValue Result = matcher.getNode(AddOp, dl, PromotedType, Op1, Op2);
1213 Result = matcher.getNode(
ISD::SMIN, dl, PromotedType, Result, SatMax);
1214 Result = matcher.getNode(
ISD::SMAX, dl, PromotedType, Result, SatMin);
1221 SDValue Op1Promoted, Op2Promoted;
1227 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1228 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1230 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1231 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1233 EVT OldType =
N->getOperand(0).getValueType();
1245 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1246 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1247 Op2Promoted,
N->getOperand(2));
1249 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1250 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1252 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1257 unsigned SatW,
bool Signed,
1260 EVT VT = V.getValueType();
1287 EVT VT =
LHS.getValueType();
1303 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1309 "Tried to saturate to more than the original type?");
1318 SDValue Op1Promoted, Op2Promoted;
1324 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1325 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1327 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1328 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1331 unsigned Scale =
N->getConstantOperandVal(2);
1335 if (TLI.isTypeLegal(PromotedType)) {
1337 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1340 N->getValueType(0).getScalarSizeInBits();
1344 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1345 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1346 Op2Promoted,
N->getOperand(2));
1349 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1355 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1356 Op2Promoted, Scale, DAG)) {
1359 N->getValueType(0).getScalarSizeInBits(),
1367 N->getValueType(0).getScalarSizeInBits());
1370SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1372 return PromoteIntRes_Overflow(
N);
1376 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1377 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1378 EVT OVT =
N->getOperand(0).getValueType();
1379 EVT NVT =
LHS.getValueType();
1389 DAG.getValueType(OVT));
1391 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1394 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1400 EVT PromotedResultTy =
1401 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1402 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1403 N->getOperand(0),
N->getOperand(1));
1409 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1410 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1412 unsigned Opcode =
N->getOpcode();
1413 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1414 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1416 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1420 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1421 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1423 LHS.getValueType(),
N->getOperand(0),
1424 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1429 EVT InVT =
N->getOperand(OpNo).getValueType();
1430 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1432 EVT SVT = getSetCCResultType(InVT);
1439 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1440 SVT = getSetCCResultType(InVT);
1448 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1449 "Vector compare must return a vector result!");
1453 if (
N->isStrictFPOpcode()) {
1454 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1455 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1456 N->getOperand(2),
N->getOperand(3)};
1457 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1462 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1463 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1466 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1473 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1478 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1479 EVT VT =
N->getValueType(0);
1483 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1485 ReplaceValueWith(
SDValue(
N, 0), Res);
1490 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1492 if (
N->getOpcode() != ISD::VP_SHL) {
1494 RHS = ZExtPromotedInteger(
RHS);
1496 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1502 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1503 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1507SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1508 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1510 Op.getValueType(),
Op,
N->getOperand(1));
1513SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1517 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1518 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1519 if (
N->getNumOperands() == 2)
1520 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1521 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1522 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1523 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1524 N->getOperand(2),
N->getOperand(3));
1528 if (
N->getNumOperands() == 2) {
1530 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1531 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1532 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");
1539 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1540 SDValue RHS = VPSExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1541 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1546 if (
N->getNumOperands() == 2) {
1548 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1549 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1550 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1552 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1553 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1557 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1558 SDValue RHS = VPZExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1559 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1569 SExtOrZExtPromotedOperands(
LHS,
RHS);
1571 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1577 if (
N->getOpcode() != ISD::VP_SRA) {
1579 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1581 RHS = ZExtPromotedInteger(
RHS);
1582 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1588 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1590 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1591 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1597 if (
N->getOpcode() != ISD::VP_SRL) {
1599 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1601 RHS = ZExtPromotedInteger(
RHS);
1602 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1608 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1610 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1611 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1617 SDValue Res = TLI.expandROT(
N,
true , DAG);
1618 ReplaceValueWith(
SDValue(
N, 0), Res);
1623 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1624 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1627 Amt = ZExtPromotedInteger(Amt);
1631 EVT OldVT =
N->getOperand(0).getValueType();
1632 EVT VT =
Lo.getValueType();
1633 unsigned Opcode =
N->getOpcode();
1640 DAG.getConstant(OldBits,
DL, AmtVT));
1648 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1649 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1651 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1661 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1667 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1669 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1673SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1674 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1675 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1680 Amt = VPZExtPromotedInteger(Amt, Mask, EVL);
1684 EVT OldVT =
N->getOperand(0).getValueType();
1685 EVT VT =
Lo.getValueType();
1686 unsigned Opcode =
N->getOpcode();
1687 bool IsFSHR = Opcode == ISD::VP_FSHR;
1692 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1693 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1701 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1702 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1703 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1704 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1706 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1709 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1714 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1715 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1720 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1722 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1726 unsigned Opcode =
N->getOpcode();
1729 EVT OldVT =
N->getOperand(0).getValueType();
1730 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1733 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT)) {
1734 if (
SDValue Res = TLI.expandCLMUL(
N, DAG))
1737 SDValue X = GetPromotedInteger(
N->getOperand(0));
1738 SDValue Y = GetPromotedInteger(
N->getOperand(1));
1742 SDValue X = ZExtPromotedInteger(
N->getOperand(0));
1743 SDValue Y = ZExtPromotedInteger(
N->getOperand(1));
1747 if (NewBits < 2 * OldBits) {
1749 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1751 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1753 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1755 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1760 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1762 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1766 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1778 Res = GetPromotedInteger(InOp);
1785 "Dst and Src must have the same number of elements");
1787 "Promoted vector type must be a power of two");
1790 GetSplitVector(InOp, EOp1, EOp2);
1798 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1799 "Expected VP_TRUNCATE opcode");
1800 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1801 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1802 std::tie(EVLLo, EVLHi) =
1803 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1804 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1805 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1812 SDValue WideInOp = GetWidenedVector(InOp);
1817 N->getValueType(0).getScalarType(), NumElem);
1826 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1832 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1833 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1838SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1840 return PromoteIntRes_Overflow(
N);
1844 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1845 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1846 EVT OVT =
N->getOperand(0).getValueType();
1847 EVT NVT =
LHS.getValueType();
1856 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1858 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1861 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1872 return PromoteIntRes_Overflow(
N);
1884 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1885 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1887 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1890 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1901 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1902 return PromoteIntRes_Overflow(
N);
1906 EVT OVT =
N->getValueType(0);
1907 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1913 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1914 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1915 if (
SDValue Res = TLI.expandABS(
N, DAG))
1919 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1923SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1926 return PromoteIntRes_Overflow(
N);
1930 EVT SmallVT =
LHS.getValueType();
1937 LHS = SExtPromotedInteger(
LHS);
1938 RHS = SExtPromotedInteger(
RHS);
1940 LHS = ZExtPromotedInteger(
LHS);
1941 RHS = ZExtPromotedInteger(
RHS);
1943 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1955 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1956 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1957 DAG.getConstant(0,
DL,
Hi.getValueType()),
1962 Mul, DAG.getValueType(SmallVT));
1972 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1977 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1978 N->getValueType(0)));
1982 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1984 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1991 EVT VT =
N->getValueType(0);
1994 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1995 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1999 for (
unsigned i = 0; i < NumRegs; ++i) {
2000 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
2001 N->getConstantOperandVal(3));
2006 if (DAG.getDataLayout().isBigEndian())
2007 std::reverse(Parts.begin(), Parts.end());
2010 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
2012 for (
unsigned i = 1; i < NumRegs; ++i) {
2017 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
2023 ReplaceValueWith(
SDValue(
N, 1), Chain);
2036bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
2039 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2044 switch (
N->getOpcode()) {
2047 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2048 N->dump(&DAG);
dbgs() <<
"\n";
2057 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2058 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2064 Res = PromoteIntOp_FAKE_USE(
N);
2067 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2071 Res = PromoteIntOp_ScalarOp(
N);
2074 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2077 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2079 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2080 case ISD::VP_SINT_TO_FP:
2097 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2099 case ISD::VP_TRUNCATE:
2103 case ISD::VP_UINT_TO_FP:
2108 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2119 Res = PromoteIntOp_Shift(
N);
2123 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2126 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2152 case ISD::VP_REDUCE_ADD:
2153 case ISD::VP_REDUCE_MUL:
2154 case ISD::VP_REDUCE_AND:
2155 case ISD::VP_REDUCE_OR:
2156 case ISD::VP_REDUCE_XOR:
2157 case ISD::VP_REDUCE_SMAX:
2158 case ISD::VP_REDUCE_SMIN:
2159 case ISD::VP_REDUCE_UMAX:
2160 case ISD::VP_REDUCE_UMIN:
2161 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2166 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2169 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2172 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2174 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2175 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2176 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2178 case ISD::EXPERIMENTAL_VP_SPLICE:
2179 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2182 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2185 Res = PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
N, OpNo);
2188 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2193 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2198 if (!Res.
getNode())
return false;
2205 const bool IsStrictFp =
N->isStrictFPOpcode();
2207 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2208 "Invalid operand expansion");
2212 ReplaceValueWith(
SDValue(
N, 0), Res);
2226 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2230 unsigned OpLEffectiveBits =
2231 DAG.computeKnownBits(OpL).countMaxActiveBits();
2232 unsigned OpREffectiveBits =
2233 DAG.computeKnownBits(OpR).countMaxActiveBits();
2234 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2235 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2242 LHS = SExtPromotedInteger(
LHS);
2243 RHS = SExtPromotedInteger(
RHS);
2252 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2253 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2254 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2255 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2262 LHS = ZExtPromotedInteger(
LHS);
2263 RHS = ZExtPromotedInteger(
RHS);
2277 LHS = SExtPromotedInteger(
LHS);
2278 RHS = SExtPromotedInteger(
RHS);
2283 "Unknown integer comparison!");
2285 SExtOrZExtPromotedOperands(
LHS,
RHS);
2289 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2294 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2295 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2296 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2300 EVT OutVT =
N->getValueType(0);
2303 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2306 switch (getTypeAction(InVT)) {
2310 DAG.getDataLayout().isLittleEndian()) {
2320 if (isTypeLegal(WideVecVT)) {
2321 SDValue Promoted = GetPromotedInteger(InOp);
2324 DAG.getVectorIdxConstant(0, dl));
2337 return CreateStackStoreLoad(InOp, OutVT);
2340SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2341 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2349 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2350 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2354SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
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,
2362 N->getOperand(2)), 0);
2367 EVT OVT =
N->getOperand(0).getValueType();
2368 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2369 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2370 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2375 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2376 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2385 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2386 "Legal vector of one illegal element?");
2391 assert(
N->getOperand(0).getValueSizeInBits() >=
2392 N->getValueType(0).getScalarSizeInBits() &&
2393 "Type of inserted value narrower than vector element type!");
2396 for (
unsigned i = 0; i < NumElts; ++i)
2397 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2399 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2402SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2409 assert(
N->getOperand(1).getValueSizeInBits() >=
2410 N->getValueType(0).getScalarSizeInBits() &&
2411 "Type of inserted value narrower than vector element type!");
2412 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2413 GetPromotedInteger(
N->getOperand(1)),
2418 assert(OpNo == 2 &&
"Different operand and result vector types?");
2421 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2422 TLI.getVectorIdxTy(DAG.getDataLayout()));
2423 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2424 N->getOperand(1), Idx), 0);
2428 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2432 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2435SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2436 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2438 EVT OpTy =
N->getOperand(1).getValueType();
2441 if (
SDValue Res = WidenVSELECTMask(
N))
2442 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2443 Res,
N->getOperand(1),
N->getOperand(2));
2447 Cond = PromoteTargetBoolean(
Cond, OpVT);
2449 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2450 N->getOperand(2)), 0);
2453SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2454 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2462 N->getOperand(3),
N->getOperand(4)), 0);
2465SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2466 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2474 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2476 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2479 N->getOperand(3),
N->getOperand(4)),
2484 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2485 ZExtPromotedInteger(
N->getOperand(1))), 0);
2493 LHS = SExtPromotedInteger(
LHS);
2494 RHS = SExtPromotedInteger(
RHS);
2496 SExtOrZExtPromotedOperands(
LHS,
RHS);
2503 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2504 ZExtPromotedInteger(
N->getOperand(2))), 0);
2508 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2512 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2515SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2517 EVT VT =
N->getValueType(0);
2518 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2520 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2524 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2526 SDValue Shl = DAG.getNode(ISD::VP_SHL, dl, VT,
Op, ShAmt,
N->getOperand(1),
2528 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2533 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2534 return SDValue(DAG.UpdateNodeOperands(
N,
2535 SExtPromotedInteger(
N->getOperand(0)),
2536 N->getOperand(1),
N->getOperand(2)),
2538 return SDValue(DAG.UpdateNodeOperands(
N,
2539 SExtPromotedInteger(
N->getOperand(0))), 0);
2542SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2543 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2544 SExtPromotedInteger(
N->getOperand(1))), 0);
2549 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2552 SDValue Val = GetPromotedInteger(
N->getValue());
2555 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2556 N->getMemoryVT(),
N->getMemOperand());
2562 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2563 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2565 SDValue DataOp = GetPromotedInteger(
N->getValue());
2566 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2567 N->getMask(),
N->getVectorLength(),
2568 N->getMemoryVT(),
N->getMemOperand(),
2569 N->isCompressingStore());
2580 Mask = PromoteTargetBoolean(Mask, DataVT);
2583 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2586 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2587 DataOp = GetPromotedInteger(DataOp);
2589 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2590 N->getOffset(), Mask,
N->getMemoryVT(),
2591 N->getMemOperand(),
N->getAddressingMode(),
2592 true,
N->isCompressingStore());
2597 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2598 EVT DataVT =
N->getValueType(0);
2599 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2601 NewOps[OpNo] =
Mask;
2602 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2618 EVT DataVT =
N->getValueType(0);
2619 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2620 }
else if (OpNo == 4) {
2622 if (
N->isIndexSigned())
2624 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2626 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2628 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2630 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2642 bool TruncateStore =
N->isTruncatingStore();
2647 EVT DataVT =
N->getValue().getValueType();
2648 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2649 }
else if (OpNo == 4) {
2651 if (
N->isIndexSigned())
2653 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2655 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2657 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2658 TruncateStore =
true;
2661 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2662 SDLoc(
N), NewOps,
N->getMemOperand(),
2663 N->getIndexType(), TruncateStore);
2668 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2672 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2677 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2678 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2679 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2680 N->getOperand(1),
N->getOperand(2));
2685 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2686 return SDValue(DAG.UpdateNodeOperands(
N,
2687 ZExtPromotedInteger(
N->getOperand(0)),
2688 N->getOperand(1),
N->getOperand(2)),
2690 return SDValue(DAG.UpdateNodeOperands(
N,
2691 ZExtPromotedInteger(
N->getOperand(0))), 0);
2694SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2695 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2696 ZExtPromotedInteger(
N->getOperand(1))), 0);
2703 EVT VT =
N->getValueType(0);
2708 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2709 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2710 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2711 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2716 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2719SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2721 EVT VT =
N->getValueType(0);
2722 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2724 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2726 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2727 N->getOperand(0).getValueType());
2731 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2733 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2736SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2738 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2739 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2748 unsigned OpOffset = IsStrict ? 1 : 0;
2755 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
2756 if (LCImpl == RTLIB::Unsupported) {
2762 if (IsPowI &&
N->getValueType(0).isVector())
2763 return DAG.UnrollVectorOp(
N);
2765 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2766 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2776 assert(DAG.getLibInfo().getIntSize() ==
2777 N->getOperand(1 + OpOffset).getValueType().getSizeInBits() &&
2778 "POWI exponent should match with sizeof(int) when doing the libcall.");
2779 TargetLowering::MakeLibCallOptions CallOptions;
2781 SDValue Ops[2] = {
N->getOperand(0 + OpOffset),
N->getOperand(1 + OpOffset)};
2782 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2783 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2784 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2786 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2791 switch (
N->getOpcode()) {
2799 case ISD::VP_REDUCE_ADD:
2800 case ISD::VP_REDUCE_MUL:
2801 case ISD::VP_REDUCE_AND:
2802 case ISD::VP_REDUCE_OR:
2803 case ISD::VP_REDUCE_XOR:
2807 case ISD::VP_REDUCE_SMAX:
2808 case ISD::VP_REDUCE_SMIN:
2812 case ISD::VP_REDUCE_UMAX:
2813 case ISD::VP_REDUCE_UMIN:
2823 return GetPromotedInteger(V);
2825 return SExtPromotedInteger(V);
2827 return ZExtPromotedInteger(V);
2833 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2835 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2836 EVT InVT =
Op.getValueType();
2838 EVT ResVT =
N->getValueType(0);
2839 unsigned Opcode =
N->getOpcode();
2856 switch (TLI.getBooleanContents(InVT)) {
2859 Op = ZExtPromotedInteger(
N->getOperand(0));
2862 Op = SExtPromotedInteger(
N->getOperand(0));
2875 switch (TLI.getBooleanContents(InVT)) {
2878 Op = ZExtPromotedInteger(
N->getOperand(0));
2881 Op = SExtPromotedInteger(
N->getOperand(0));
2887 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2891 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2895SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2902 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2903 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2906 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2908 Op = PromoteIntOpVectorReduction(
N,
Op);
2912 EVT VT =
N->getValueType(0);
2913 EVT EltVT =
Op.getValueType().getScalarType();
2916 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2928 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2929 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2932SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2935 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2936 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2939SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2942 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2943 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2948 const Function &Fn = DAG.getMachineFunction().getFunction();
2950 "cannot use llvm.write_register with illegal type", Fn,
2952 return N->getOperand(0);
2955SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2956 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2957 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2960 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2962 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2965SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2969 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2970 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2973 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2975 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2976 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2979SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2981 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2983 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2984 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2987SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N,
2990 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2991 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2994SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
2996 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
2997 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2998 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3001SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3003 switch (
N->getOpcode()) {
3005 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3006 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3009 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3010 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3013 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3014 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3019 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3030void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3036 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3039 switch (
N->getOpcode()) {
3042 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3043 N->dump(&DAG);
dbgs() <<
"\n";
3120 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3121 SplitInteger(Tmp.first,
Lo,
Hi);
3122 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3127 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3128 SDValue Tmp = DAG.getAtomicCmpSwap(
3130 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3139 SplitInteger(Tmp,
Lo,
Hi);
3218 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3223 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3229 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3233 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3237 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3247std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3248 unsigned Opc =
Node->getOpcode();
3254 EVT RetVT =
Node->getValueType(0);
3255 TargetLowering::MakeLibCallOptions CallOptions;
3258 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
3259 if (LCImpl != RTLIB::Unsupported) {
3261 Ops.push_back(
Node->getOperand(1));
3264 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3265 "Unexpected atomic op or value type!");
3267 LCImpl = TLI.getLibcallImpl(LC);
3269 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3270 Node->getOperand(0));
3275void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3280 GetExpandedInteger(
N->getOperand(0), InL, InH);
3295 if (Amt.
uge(VTBits)) {
3296 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3297 }
else if (Amt.
ugt(NVTBits)) {
3298 Lo = DAG.getConstant(0,
DL, NVT);
3300 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3301 }
else if (Amt == NVTBits) {
3302 Lo = DAG.getConstant(0,
DL, NVT);
3306 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3310 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3312 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3318 if (Amt.
uge(VTBits)) {
3319 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3320 }
else if (Amt.
ugt(NVTBits)) {
3322 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3323 Hi = DAG.getConstant(0,
DL, NVT);
3324 }
else if (Amt == NVTBits) {
3326 Hi = DAG.getConstant(0,
DL, NVT);
3331 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3333 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3335 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3341 if (Amt.
uge(VTBits)) {
3343 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3344 }
else if (Amt.
ugt(NVTBits)) {
3346 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3348 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3349 }
else if (Amt == NVTBits) {
3352 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3357 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3359 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3361 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3369bool DAGTypeLegalizer::
3371 unsigned Opc =
N->getOpcode();
3374 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3379 "Expanded integer type size not a power of two!");
3383 KnownBits Known = DAG.computeKnownBits(Amt);
3386 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3391 GetExpandedInteger(In, InL, InH);
3398 DAG.getConstant(~HighBitMask, dl, ShTy));
3403 Lo = DAG.getConstant(0, dl, NVT);
3404 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3407 Hi = DAG.getConstant(0, dl, NVT);
3408 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3412 DAG.getConstant(NVTBits - 1, dl, ShTy));
3413 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3425 DAG.getConstant(NVTBits - 1, dl, ShTy));
3441 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3443 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3445 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3446 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3458bool DAGTypeLegalizer::
3461 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3465 "Expanded integer type size not a power of two!");
3470 GetExpandedInteger(
N->getOperand(0), InL, InH);
3472 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3475 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3478 Amt, DAG.getConstant(0, dl, ShTy),
3482 switch (
N->getOpcode()) {
3488 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3489 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3492 LoL = DAG.getConstant(0, dl, NVT);
3495 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3496 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3497 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3503 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3506 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3509 HiL = DAG.getConstant(0, dl, NVT);
3512 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3513 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3514 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3520 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3521 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3525 DAG.getConstant(NVTBits - 1, dl, ShTy));
3528 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3529 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3530 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3555 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3560 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3561 SplitInteger(Res,
Lo,
Hi);
3564void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3573 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3574 unsigned NumHalfBits = NumBits / 2;
3575 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3576 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3577 SDValue LHSL, LHSH, RHSL, RHSH;
3578 GetExpandedInteger(
LHS, LHSL, LHSH);
3579 GetExpandedInteger(
RHS, RHSL, RHSH);
3582 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3584 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3592 SDValue LHSL, LHSH, RHSL, RHSH;
3593 GetExpandedInteger(
LHS, LHSL, LHSH);
3594 GetExpandedInteger(
RHS, RHSL, RHSH);
3596 EVT CCT = getSetCCResultType(NVT);
3599 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3601 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3603 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3605 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3609 const APInt *RHSVal =
nullptr;
3611 RHSVal = &RHSConst->getAPIntValue();
3618 SDValue LHSL, LHSH, RHSL, RHSH;
3619 GetExpandedInteger(
LHS, LHSL, LHSH);
3620 GetExpandedInteger(
RHS, RHSL, RHSH);
3622 EVT CCT = getSetCCResultType(NVT);
3628 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3631 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3635 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3638 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3640 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3647 switch (
N->getOpcode()) {
3674 EVT VT =
N->getValueType(0);
3675 EVT CCT = getSetCCResultType(VT);
3678 SplitInteger(Result,
Lo,
Hi);
3682 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3683 SplitInteger(ExpandedCMP,
Lo,
Hi);
3686void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3690 SDValue LHSL, LHSH, RHSL, RHSH;
3691 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3692 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3695 SDValue LoOps[2] = { LHSL, RHSL };
3696 SDValue HiOps[3] = { LHSH, RHSH };
3698 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3700 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3702 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3706 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3712 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3725 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3727 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3730 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3744 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3746 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3750 EVT OvfVT = getSetCCResultType(NVT);
3751 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3766 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3769 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3773 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3785 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3789 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3792 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3795 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3800 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3802 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3803 DAG.getConstant(0, dl, NVT));
3806 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3815 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3820 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3822 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3823 DAG.getConstant(0, dl, NVT));
3829void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3832 SDValue LHSL, LHSH, RHSL, RHSH;
3834 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3835 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3836 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3837 SDValue LoOps[2] = { LHSL, RHSL };
3838 SDValue HiOps[3] = { LHSH, RHSH };
3852 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3855void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3858 SDValue LHSL, LHSH, RHSL, RHSH;
3860 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3861 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3862 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3864 SDValue HiOps[3] = { LHSH, RHSH };
3866 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3868 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3872 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3875void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3883 unsigned CarryOp, NoCarryOp;
3885 switch(
N->getOpcode()) {
3900 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3901 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3905 SDValue LHSL, LHSH, RHSL, RHSH;
3906 GetExpandedInteger(
LHS, LHSL, LHSH);
3907 GetExpandedInteger(
RHS, RHSL, RHSH);
3908 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3909 SDValue LoOps[2] = { LHSL, RHSL };
3910 SDValue HiOps[3] = { LHSH, RHSH };
3912 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3914 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3921 SplitInteger(Sum,
Lo,
Hi);
3927 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
3928 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
3932 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
3937 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
3943 ReplaceValueWith(
SDValue(
N, 1), Ovf);
3949 SDValue LHSL, LHSH, RHSL, RHSH;
3951 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3952 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3953 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3957 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3959 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3963 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3966void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
3969 SDValue LHSL, LHSH, RHSL, RHSH;
3971 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3972 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3973 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3978 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
3979 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
3983 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3986void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
3988 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3991 if (
Op.getValueType().bitsLE(NVT)) {
3994 Hi = DAG.getUNDEF(NVT);
3998 assert(getTypeAction(
Op.getValueType()) ==
4000 "Only know how to promote this result!");
4003 "Operand over promoted?");
4005 SplitInteger(Res,
Lo,
Hi);
4009void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4012 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4013 EVT NVT =
Lo.getValueType();
4018 if (NVTBits < EVTBits) {
4021 EVTBits - NVTBits)));
4026 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4030void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4033 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4034 EVT NVT =
Lo.getValueType();
4039 if (NVTBits < EVTBits) {
4042 EVTBits - NVTBits)));
4046 Hi = DAG.getConstant(0, dl, NVT);
4050void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4053 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4058void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4061 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4070 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4071 EVT NVT =
Lo.getValueType();
4074 Hi = DAG.getConstant(0, dl, NVT);
4077void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4079 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4082 const APInt &Cst =
Constant->getAPIntValue();
4083 bool IsTarget =
Constant->isTargetOpcode();
4084 bool IsOpaque =
Constant->isOpaque();
4086 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4087 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4095 GetExpandedInteger(N0,
Lo,
Hi);
4096 EVT NVT =
Lo.getValueType();
4102 Hi = DAG.getConstant(0, dl, NVT);
4112 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4117 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4118 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4127 EVT VT =
N->getValueType(0);
4129 DAG.getConstant(0, dl, VT), N0);
4131 SplitInteger(Neg, NegLo, NegHi);
4133 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4135 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4136 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4139void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4143 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4144 EVT NVT =
Lo.getValueType();
4146 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4149 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4152 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4153 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4156 Hi = DAG.getConstant(0, dl, NVT);
4161 SplitInteger(Result,
Lo,
Hi);
4166 EVT VT =
N->getValueType(0);
4171 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4172 "LibCall explicitly requested, but not available");
4174 if (RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC)) {
4175 TargetLowering::MakeLibCallOptions CallOptions;
4179 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4180 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4188 GetExpandedInteger(
Op,
Lo,
Hi);
4189 EVT NVT =
Lo.getValueType();
4192 Hi = DAG.getConstant(0,
DL, NVT);
4195void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4199 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4200 EVT NVT =
Lo.getValueType();
4202 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4208 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4209 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4212 Hi = DAG.getConstant(0, dl, NVT);
4218 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4225 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4229 ReplaceValueWith(
SDValue(
N, 1), Chain);
4237 Chain =
Op.getValue(1);
4246 EVT VT =
N->getValueType(0);
4250 bool IsStrict =
N->isStrictFPOpcode();
4252 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4254 Op = GetPromotedFloat(
Op);
4258 Op.getValueType() == MVT::bf16) {
4264 EVT OpVT =
Op.getValueType();
4268 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4269 TargetLowering::MakeLibCallOptions CallOptions;
4274 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4275 CallOptions, dl, Chain);
4276 SplitInteger(Tmp.first,
Lo,
Hi);
4279 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4284 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4285 SplitInteger(Res,
Lo,
Hi);
4291 bool IsStrict =
N->isStrictFPOpcode();
4292 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4296 "Input type needs to be promoted!");
4298 EVT VT =
Op.getValueType();
4300 if (VT == MVT::f16) {
4306 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4310 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4314 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4318 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4322 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4326 EVT RetVT =
N->getValueType(0);
4328 TargetLowering::MakeLibCallOptions CallOptions;
4330 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4331 Op, CallOptions, dl,
4333 SplitInteger(Tmp.first,
Lo,
Hi);
4335 if (
N->isStrictFPOpcode())
4336 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4339void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4341 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4344 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4350 EVT VT =
N->getValueType(0);
4351 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4356 AAMDNodes AAInfo =
N->getAAInfo();
4361 if (
N->getMemoryVT().bitsLE(NVT)) {
4362 EVT MemVT =
N->getMemoryVT();
4364 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4365 N->getBaseAlign(), MMOFlags, AAInfo);
4373 unsigned LoSize =
Lo.getValueSizeInBits();
4375 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4378 Hi = DAG.getConstant(0, dl, NVT);
4382 Hi = DAG.getUNDEF(NVT);
4384 }
else if (DAG.getDataLayout().isLittleEndian()) {
4386 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4389 unsigned ExcessBits =
4396 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4397 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4398 N->getBaseAlign(), MMOFlags, AAInfo);
4407 EVT MemVT =
N->getMemoryVT();
4410 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4413 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4416 N->getBaseAlign(), MMOFlags, AAInfo);
4422 N->getPointerInfo().getWithOffset(IncrementSize),
4424 N->getBaseAlign(), MMOFlags, AAInfo);
4436 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4440 DAG.getShiftAmountConstant(
4447 ReplaceValueWith(
SDValue(
N, 1), Ch);
4450void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4454 GetExpandedInteger(
N->getOperand(0), LL, LH);
4455 GetExpandedInteger(
N->getOperand(1), RL, RH);
4459 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4461 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4462 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4465void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4467 EVT VT =
N->getValueType(0);
4468 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4472 GetExpandedInteger(
N->getOperand(0), LL, LH);
4473 GetExpandedInteger(
N->getOperand(1), RL, RH);
4475 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4482 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
4483 if (LCImpl == RTLIB::Unsupported) {
4486 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4492 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4493 TargetLowering::MakeLibCallOptions CallOptions;
4495 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4502 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4503 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4504 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4507 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4512 SplitInteger(Result,
Lo,
Hi);
4518 SplitInteger(Result,
Lo,
Hi);
4524 SplitInteger(Result,
Lo,
Hi);
4535 EVT VT =
N->getValueType(0);
4539 uint64_t Scale =
N->getConstantOperandVal(2);
4551 EVT BoolVT = getSetCCResultType(VT);
4553 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4559 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4560 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4566 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4567 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4572 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4573 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4576 SplitInteger(Result,
Lo,
Hi);
4582 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4584 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4586 GetExpandedInteger(
LHS, LL, LH);
4587 GetExpandedInteger(
RHS, RL, RH);
4591 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4598 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4599 SplitInteger(LoTmp, Result[0], Result[1]);
4600 SplitInteger(HiTmp, Result[2], Result[3]);
4602 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4605 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4606 "the size of the current value type");
4627 uint64_t Part0 = Scale / NVTSize;
4628 if (Scale % NVTSize) {
4629 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4632 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4644 if (Scale == VTSize)
4663 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4664 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4665 EVT BoolNVT = getSetCCResultType(NVT);
4668 if (Scale < NVTSize) {
4671 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4672 DAG.getShiftAmountConstant(Scale, NVT, dl));
4673 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4674 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4675 }
else if (Scale == NVTSize) {
4677 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4678 }
else if (Scale < VTSize) {
4682 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4683 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4686 "(and saturation can't happen with Scale==VTSize).");
4688 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4689 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4693 if (Scale < NVTSize) {
4698 unsigned OverflowBits = VTSize - Scale + 1;
4699 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4700 "Extent of overflow bits must start within HL");
4701 SDValue HLHiMask = DAG.getConstant(
4703 SDValue HLLoMask = DAG.getConstant(
4710 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4716 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4717 }
else if (Scale == NVTSize) {
4723 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4729 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4730 }
else if (Scale < VTSize) {
4733 unsigned OverflowBits = VTSize - Scale + 1;
4734 SDValue HHHiMask = DAG.getConstant(
4736 SDValue HHLoMask = DAG.getConstant(
4738 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4739 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4746 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4747 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4750 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4751 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4758 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4760 N->getConstantOperandVal(2), DAG);
4764 N->getConstantOperandVal(2), TLI, DAG);
4765 SplitInteger(Res,
Lo,
Hi);
4768void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4771 "Node has unexpected Opcode");
4781 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4782 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4786 SDValue LHSL, LHSH, RHSL, RHSH;
4787 GetExpandedInteger(
LHS, LHSL, LHSH);
4788 GetExpandedInteger(
RHS, RHSL, RHSH);
4789 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4792 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4801 SplitInteger(Sum,
Lo,
Hi);
4826 EVT VT =
LHS.getValueType();
4829 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4833 EVT OType =
Node->getValueType(1);
4834 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4838 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4841void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4843 EVT VT =
N->getValueType(0);
4845 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4854 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4856 TargetLowering::MakeLibCallOptions CallOptions;
4858 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4861void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4864 SDValue Shiftee =
N->getOperand(0);
4871 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4872 }
while (!TLI.isTypeLegal(LoadVT));
4877 "Shifting unit is not a a power of two!");
4879 const bool IsOneStepShift =
4880 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4885 if (!IsOneStepShift)
4886 ShAmt = DAG.getFreeze(ShAmt);
4889 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4890 unsigned VTByteWidth = VTBitWidth / 8;
4892 "Shiftee type size is not a power of two!");
4893 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4894 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4899 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
4901 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
4902 EVT PtrTy =
StackPtr.getValueType();
4903 SDValue Ch = DAG.getEntryNode();
4906 DAG.getMachineFunction(),
4912 unsigned WideningOpc =
4914 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
4917 SDValue AllZeros = DAG.getConstant(0, dl, VT);
4921 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
4927 Flags.setExact(IsOneStepShift);
4930 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
4932 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
4933 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
4936 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
4941 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
4948 if (DAG.getDataLayout().isBigEndian())
4949 WillIndexUpwards = !WillIndexUpwards;
4952 if (WillIndexUpwards) {
4955 AdjStackPtr = DAG.getMemBasePlusOffset(
4956 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
4957 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
4961 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
4962 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
4966 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
4971 if (!IsOneStepShift) {
4973 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
4974 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
4975 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
4979 SplitInteger(Res,
Lo,
Hi);
4982void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
4984 EVT VT =
N->getValueType(0);
4985 unsigned Opc =
N->getOpcode();
4991 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
4995 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5012 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5014 const bool LegalOrCustom =
5018 unsigned ExpansionFactor = 1;
5020 for (EVT TmpVT = NVT;;) {
5021 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5022 if (NewTMPVT == TmpVT)
5029 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5032 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5034 if (LegalOrCustom &&
5038 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5044 SDValue ShiftOp =
N->getOperand(1);
5045 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5047 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5050 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5051 Hi =
Lo.getValue(1);
5056 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5070 if (RTLIB::LibcallImpl LibcallImpl = TLI.getLibcallImpl(LC)) {
5073 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5075 TargetLowering::MakeLibCallOptions CallOptions;
5078 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5083 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5087void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5089 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5092 if (
Op.getValueType().bitsLE(NVT)) {
5098 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5102 assert(getTypeAction(
Op.getValueType()) ==
5104 "Only know how to promote this result!");
5107 "Operand over promoted?");
5109 SplitInteger(Res,
Lo,
Hi);
5117void DAGTypeLegalizer::
5120 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5123 if (EVT.
bitsLE(
Lo.getValueType())) {
5131 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5132 Hi.getValueType(), dl));
5143void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5145 EVT VT =
N->getValueType(0);
5147 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5156 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5158 TargetLowering::MakeLibCallOptions CallOptions;
5160 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5163void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5165 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5175void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5177 EVT VT =
N->getValueType(0);
5196 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5197 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5198 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5200 EVT BitVT =
N->getValueType(1);
5201 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5203 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5205 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5206 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5225 SplitInteger(Three,
Lo,
Hi);
5229 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5234 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5239 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
5243 if (LCImpl == RTLIB::Unsupported ||
5244 TLI.getLibcallImplName(LCImpl) == DAG.getMachineFunction().getName()) {
5247 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5248 N->getOperand(1), MulLo, MulHi);
5253 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5254 SplitInteger(MulLo,
Lo,
Hi);
5255 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5259 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5262 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5263 MachinePointerInfo());
5267 EVT ArgVT =
Op.getValueType();
5269 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5270 Entry.IsSExt =
true;
5271 Entry.IsZExt =
false;
5272 Args.push_back(Entry);
5276 TargetLowering::ArgListEntry
Entry(
5278 Entry.IsSExt =
true;
5279 Entry.IsZExt =
false;
5280 Args.push_back(Entry);
5282 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5284 TargetLowering::CallLoweringInfo CLI(DAG);
5287 .setLibCallee(TLI.getLibcallImplCallingConv(LCImpl), RetTy, Func,
5291 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5293 SplitInteger(CallInfo.first,
Lo,
Hi);
5295 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5296 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5297 DAG.getConstant(0, dl, PtrVT),
5300 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5303void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5305 EVT VT =
N->getValueType(0);
5307 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5317 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5319 if (isTypeLegal(NVT)) {
5321 GetExpandedInteger(
N->getOperand(0), InL, InH);
5323 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5332 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5334 TargetLowering::MakeLibCallOptions CallOptions;
5335 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5338void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5340 EVT VT =
N->getValueType(0);
5342 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5352 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5354 if (isTypeLegal(NVT)) {
5356 GetExpandedInteger(
N->getOperand(0), InL, InH);
5358 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5367 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5369 TargetLowering::MakeLibCallOptions CallOptions;
5370 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5373void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5375 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5378 if (
Op.getValueType().bitsLE(NVT)) {
5381 Hi = DAG.getConstant(0, dl, NVT);
5385 assert(getTypeAction(
Op.getValueType()) ==
5387 "Only know how to promote this result!");
5390 "Operand over promoted?");
5392 SplitInteger(Res,
Lo,
Hi);
5394 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5400void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5404 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5406 SDValue Swap = DAG.getAtomicCmpSwap(
5415void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5419 SDValue Res = TLI.expandVecReduce(
N, DAG);
5420 SplitInteger(Res,
Lo,
Hi);
5423void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5429 N->getOperand(0),
N->getOperand(1));
5430 SplitInteger(Res,
Lo,
Hi);
5437 GetExpandedInteger(
N->getOperand(0), In3, In4);
5438 GetExpandedInteger(
N->getOperand(1), In1, In2);
5442 unsigned Opc =
N->getOpcode();
5445 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5450 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5452 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5456 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5457 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5462 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5463 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5468 SDValue Res = TLI.expandCLMUL(
N, DAG);
5469 return SplitInteger(Res,
Lo,
Hi);
5473 GetExpandedInteger(
N->getOperand(0), LL, LH);
5474 GetExpandedInteger(
N->getOperand(1), RL, RH);
5488 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5493 EVT VT =
N->getValueType(0);
5500 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5503 SplitInteger(Res,
Lo,
Hi);
5510 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5511 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5513 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5514 Lo = DAG.getPOISON(LoVT);
5515 Hi = DAG.getPOISON(HiVT);
5526bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5530 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5533 switch (
N->getOpcode()) {
5536 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5537 N->dump(&DAG);
dbgs() <<
"\n";
5542 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5546 Res = ExpandOp_FAKE_USE(
N);
5552 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5565 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5570 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5574 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5577 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5579 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5580 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5581 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5584 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5589 if (!Res.
getNode())
return false;
5597 "Invalid operand expansion");
5599 ReplaceValueWith(
SDValue(
N, 0), Res);
5605void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5609 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5610 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5611 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5624 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5631 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5632 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5663 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5664 RHSLo, LowCC,
false, DagCombineInfo, dl);
5666 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5670 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5671 RHSHi, CCCode,
false, DagCombineInfo, dl);
5675 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5684 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5686 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5695 if (LHSHi == RHSHi) {
5704 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5705 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5708 if (HasSETCCCARRY) {
5711 bool FlipOperands =
false;
5728 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5732 DAG.getCondCode(CCCode));
5738 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5739 false, DagCombineInfo, dl);
5742 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5743 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5750 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5755 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5760 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5761 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5762 N->getOperand(4)), 0);
5768 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5773 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5778 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5779 N->getOperand(2),
N->getOperand(3),
5780 DAG.getCondCode(CCCode)), 0);
5786 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5791 "Unexpected setcc expansion!");
5797 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5805 SDLoc dl = SDLoc(
N);
5807 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5808 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5809 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5822 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5832 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5833 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5837 return TLI.expandCMP(
N, DAG);
5845 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5846 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5850 bool IsStrict =
N->isStrictFPOpcode();
5854 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5855 EVT DstVT =
N->getValueType(0);
5858 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5859 "Don't know how to expand this XINT_TO_FP!");
5860 TargetLowering::MakeLibCallOptions CallOptions;
5862 std::pair<SDValue, SDValue> Tmp =
5863 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5868 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
5869 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
5874 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
5877 return ExpandOp_NormalStore(
N, OpNo);
5880 assert(OpNo == 1 &&
"Can only expand the stored value so far");
5882 EVT VT =
N->getOperand(1).getValueType();
5883 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5887 AAMDNodes AAInfo =
N->getAAInfo();
5893 if (
N->getMemoryVT().bitsLE(NVT)) {
5894 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5895 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
5896 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
5900 if (DAG.getDataLayout().isLittleEndian()) {
5902 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5904 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
5907 unsigned ExcessBits =
5914 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
5915 N->getPointerInfo().getWithOffset(IncrementSize),
5916 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
5922 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5924 EVT ExtVT =
N->getMemoryVT();
5927 unsigned ExcessBits = (EBytes - IncrementSize)*8;
5935 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
5939 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
5943 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
5944 N->getBaseAlign(), MMOFlags, AAInfo);
5949 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
5950 N->getPointerInfo().getWithOffset(IncrementSize),
5952 N->getBaseAlign(), MMOFlags, AAInfo);
5958 GetExpandedInteger(
N->getOperand(0), InL, InH);
5967 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
5972SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
5973 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
5974 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
5978 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
5980 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
5983SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
5986 "cannot use llvm.write_register with illegal type", Fn,
5989 return N->getOperand(0);
5992SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
5995 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
5996 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
5999 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0, V1,
N->getOperand(2));
6002SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6004 unsigned Factor =
N->getNumOperands();
6007 for (
unsigned i = 0; i != Factor; i++)
6008 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6013 for (
unsigned i = 0; i != Factor; i++)
6019SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6021 EVT OutVT =
N->getValueType(0);
6022 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6023 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6027 SDValue BaseIdx =
N->getOperand(1);
6044 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6048 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6054 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6063 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6067 "Promoted operand has an element type greater than result");
6080 InOp0 = GetPromotedInteger(InOp0);
6087 Ops.reserve(OutNumElems);
6088 for (
unsigned i = 0; i != OutNumElems; ++i) {
6093 N->getOperand(0), Index);
6094 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6099 return DAG.getBuildVector(NOutVT, dl,
Ops);
6102SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6103 EVT OutVT =
N->getValueType(0);
6104 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6105 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6117 Vec = GetPromotedInteger(Vec);
6123SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6126 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6132SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6134 EVT VT =
N->getValueType(0);
6139 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6140 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6143 return DAG.getVectorShuffle(OutVT, dl, V0, V1, NewMask);
6147 EVT OutVT =
N->getValueType(0);
6148 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6149 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6150 unsigned NumElems =
N->getNumOperands();
6157 Ops.reserve(NumElems);
6158 for (
unsigned i = 0; i != NumElems; ++i) {
6160 EVT OpVT =
Op.getValueType();
6165 if (OpVT.
bitsLT(NOutVTElem)) {
6171 ExtOpc = NOutExtOpc;
6172 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6177 return DAG.getBuildVector(NOutVT, dl,
Ops);
6184 assert(!
N->getOperand(0).getValueType().isVector() &&
6185 "Input must be a scalar");
6187 EVT OutVT =
N->getValueType(0);
6188 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6189 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6193 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6198 EVT OutVT =
N->getValueType(0);
6199 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6201 "Type must be promoted to a scalable vector type");
6202 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6203 return DAG.getStepVector(dl, NOutVT,
6207SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6210 EVT OutVT =
N->getValueType(0);
6211 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6212 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6214 unsigned NumOperands =
N->getNumOperands();
6219 SDUse *MaxSizedValue = std::max_element(
6221 EVT AVT = A.getValueType().getVectorElementType();
6222 EVT BVT = B.getValueType().getVectorElementType();
6223 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6229 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6231 EVT OpVT =
Op.getValueType();
6233 Op = GetPromotedInteger(
Op);
6236 "Unhandled legalization type");
6240 Op = DAG.getAnyExtOrTrunc(
6248 return DAG.getAnyExtOrTrunc(
6256 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6257 assert(NumElem * NumOperands == NumOutElem &&
6258 "Unexpected number of elements");
6262 for (
unsigned i = 0; i < NumOperands; ++i) {
6265 Op = GetPromotedInteger(
Op);
6266 EVT SclrTy =
Op.getValueType().getVectorElementType();
6267 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6268 "Unexpected number of elements");
6270 for (
unsigned j = 0;
j < NumElem; ++
j) {
6272 DAG.getVectorIdxConstant(j, dl));
6273 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6277 return DAG.getBuildVector(NOutVT, dl,
Ops);
6280SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6281 EVT VT =
N->getValueType(0);
6282 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6283 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6291 if (getTypeAction(
N->getOperand(0).getValueType())
6295 switch(
N->getOpcode()) {
6297 Promoted = SExtPromotedInteger(
N->getOperand(0));
6300 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6303 Promoted = GetPromotedInteger(
N->getOperand(0));
6315 DAG.getVectorIdxConstant(0, dl));
6317 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6321 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6324SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6325 EVT VT =
N->getValueType(0);
6326 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6330SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6331 EVT VT =
N->getValueType(0);
6332 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6336SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6338 EVT VT =
N->getValueType(0);
6339 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6340 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6341 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6345SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6346 EVT OutVT =
N->getValueType(0);
6347 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6348 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6353 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6356 NOutVTElem,
N->getOperand(1));
6358 V0, ConvElem,
N->getOperand(2));
6365 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6366 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6374 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6375 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6376 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6380 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6383 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6384 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6392 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6397SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6400 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6402 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6403 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6404 return DAG.getPOISON(NVT);
6407SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6409 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6410 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6411 TLI.getVectorIdxTy(DAG.getDataLayout()));
6418 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6421SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6426 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6431 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6433 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6445 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1), V1);
6446 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6449SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6451 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6459SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6462 EVT ResVT =
N->getValueType(0);
6463 unsigned NumElems =
N->getNumOperands();
6466 SDValue ResVec = DAG.getUNDEF(ResVT);
6470 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6472 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6484 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6485 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6489 for (
unsigned i=0; i<NumElem; ++i) {
6492 DAG.getVectorIdxConstant(i, dl));
6498 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6501SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6514 for (
unsigned I = 0;
I < OpNo;
I++)
6517 EVT Ty =
Op.getValueType();
6518 SDLoc
DL = SDLoc(
N);
6521 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6529 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6534 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6540SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6553 for (
unsigned I = 0;
I < OpNo;
I++)
6556 EVT Ty =
Op.getValueType();
6557 SDLoc
DL = SDLoc(
N);
6560 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6568 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6573 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static SDValue SaturateWidenedDIVFIX(SDValue V, SDLoc &dl, unsigned SatW, bool Signed, const TargetLowering &TLI, SelectionDAG &DAG)
static SDValue fpExtendHelper(SDValue Op, SDValue &Chain, bool IsStrict, EVT VT, SDLoc DL, SelectionDAG &DAG)
static SDValue earlyExpandDIVFIX(SDNode *N, SDValue LHS, SDValue RHS, unsigned Scale, const TargetLowering &TLI, SelectionDAG &DAG, unsigned SatW=0)
static unsigned getExtendForIntVecReduction(SDNode *N)
static std::pair< ISD::CondCode, ISD::NodeType > getExpandedMinMaxOps(int Op)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
MachineInstr unsigned OpIdx
const SmallVectorImpl< MachineOperand > & Cond
static Type * getValueType(Value *V)
Returns the type of the given value/instruction V.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
unsigned getActiveBits() const
Compute the number of active bits in the value.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
unsigned countLeadingOnes() const
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned countTrailingZeros() const
unsigned countLeadingZeros() const
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
unsigned countTrailingOnes() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
This is an SDNode representing atomic operations.
const APInt & getValue() const
Return the constant as an APInt value reference.
const ConstantInt * getConstantIntValue() const
uint64_t getZExtValue() const
@ NewNode
This is a new node, not before seen, that was created in the process of legalizing some other node.
const Function & getFunction() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This class is used to represent ISD::LOAD nodes.
unsigned getVectorNumElements() const
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
Flags
Flags values. These may be or'd together.
This class is used to represent an MGATHER node.
This class is used to represent an MLOAD node.
This class is used to represent an MSCATTER node.
This class is used to represent an MSTORE node.
MachineMemOperand * getMemOperand() const
Return a 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
@ MLOAD
Masked load and store - consecutive vector load and store operations with additional mask operand tha...
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
@ BSWAP
Byte Swap and Counting operators.
@ SMULFIX
RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same...
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, val, ptr) This corresponds to "store atomic" instruction.
@ ADDC
Carry-setting nodes for multiple precision addition and subtraction.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ SMULFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ VECTOR_FIND_LAST_ACTIVE
Finds the index of the last active mask element Operands: Mask.
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ FAKE_USE
FAKE_USE represents a use of the operand but does not do anything.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ CLMUL
Carry-less multiplication operations.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ 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, IMM) - Shifts CONCAT_VECTORS(VEC1, VEC2) left by IMM elements and retu...
@ 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, IMM) - Shifts CONCAT_VECTORS(VEC1, VEC2) right by IMM elements and re...
@ 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.
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT)
MakeLibCallOptions & setIsSigned(bool Value=true)