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;
75 case ISD::CTPOP: Res = PromoteIntRes_CTPOP_PARITY(
N);
break;
76 case ISD::VP_CTTZ_ZERO_UNDEF:
79 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(
N);
break;
80 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
81 case ISD::VP_CTTZ_ELTS:
82 Res = PromoteIntRes_VP_CttzElements(
N);
85 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(
N);
break;
95 Res = PromoteIntRes_VECTOR_COMPRESS(
N);
101 Res = PromoteIntRes_Select(
N);
106 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
108 case ISD::SMAX: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
110 case ISD::UMAX: Res = PromoteIntRes_UMINUMAX(
N);
break;
113 case ISD::VP_SHL: Res = PromoteIntRes_SHL(
N);
break;
115 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
117 case ISD::VP_SRA: Res = PromoteIntRes_SRA(
N);
break;
119 case ISD::VP_SRL: Res = PromoteIntRes_SRL(
N);
break;
120 case ISD::VP_TRUNCATE:
123 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
124 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
128 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
130 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
132 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
134 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
136 Res = PromoteIntRes_VECTOR_SPLICE(
N);
break;
139 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
142 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
144 Res = PromoteIntRes_BUILD_VECTOR(
N);
148 Res = PromoteIntRes_ScalarOp(
N);
152 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
157 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
160 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
164 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
170 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
174 case ISD::VP_SIGN_EXTEND:
176 case ISD::VP_ZERO_EXTEND:
179 case ISD::VP_FP_TO_SINT:
180 case ISD::VP_FP_TO_UINT:
188 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
192 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
196 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
211 case ISD::VP_MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
221 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
231 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
234 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
236 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
238 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
254 Res = PromoteIntRes_ADDSUBSHLSAT<EmptyMatchContext>(
N);
256 case ISD::VP_SADDSAT:
257 case ISD::VP_UADDSAT:
258 case ISD::VP_SSUBSAT:
259 case ISD::VP_USUBSAT:
260 Res = PromoteIntRes_ADDSUBSHLSAT<VPMatchContext>(
N);
265 Res = PromoteIntRes_CMP(
N);
278 case ISD::ABS: Res = PromoteIntRes_ABS(
N);
break;
311 Res = PromoteIntRes_VECREDUCE(
N);
314 case ISD::VP_REDUCE_ADD:
315 case ISD::VP_REDUCE_MUL:
316 case ISD::VP_REDUCE_AND:
317 case ISD::VP_REDUCE_OR:
318 case ISD::VP_REDUCE_XOR:
319 case ISD::VP_REDUCE_SMAX:
320 case ISD::VP_REDUCE_SMIN:
321 case ISD::VP_REDUCE_UMAX:
322 case ISD::VP_REDUCE_UMIN:
323 Res = PromoteIntRes_VP_REDUCE(
N);
328 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
332 Res = PromoteIntRes_FREEZE(
N);
337 Res = PromoteIntRes_Rotate(
N);
342 Res = PromoteIntRes_FunnelShift(
N);
347 Res = PromoteIntRes_VPFunnelShift(
N);
351 Res = PromoteIntRes_IS_FPCLASS(
N);
354 Res = PromoteIntRes_FFREXP(
N);
359 Res = PromoteIntRes_XRINT(
N);
363 Res = PromoteIntRes_PATCHPOINT(
N);
366 Res = PromoteIntRes_READ_REGISTER(
N);
372 SetPromotedInteger(
SDValue(
N, ResNo), Res);
377 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
378 return GetPromotedInteger(
Op);
381SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
383 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
384 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
389 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
391 Op.getValueType(),
Op,
N->getOperand(1));
396 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
398 Op.getValueType(),
Op,
N->getOperand(1));
402 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
405 switch (TLI.getExtendForAtomicOps()) {
421 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
422 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
432 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
434 Op2 = SExtPromotedInteger(Op2);
437 Op2 = ZExtPromotedInteger(Op2);
440 Op2 = GetPromotedInteger(Op2);
445 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
447 N->getChain(),
N->getBasePtr(),
448 Op2,
N->getMemOperand());
459 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
460 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
464 if (!TLI.isTypeLegal(SVT))
467 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
468 SDValue Res = DAG.getAtomicCmpSwap(
470 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
474 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
480 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
481 switch (TLI.getExtendForAtomicCmpSwapArg()) {
483 Op2 = SExtPromotedInteger(Op2);
486 Op2 = ZExtPromotedInteger(Op2);
489 Op2 = GetPromotedInteger(Op2);
496 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
497 SDValue Res = DAG.getAtomicCmpSwap(
498 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
499 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
501 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
509 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
510 EVT OutVT =
N->getValueType(0);
511 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
514 switch (getTypeAction(InVT)) {
520 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
524 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
527 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
531 return DAG.getNode(
ISD::FP_TO_FP16, dl, NOutVT, GetPromotedFloat(InOp));
541 BitConvertToInteger(GetScalarizedVector(InOp)));
550 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
551 Lo = BitConvertToInteger(
Lo);
552 Hi = BitConvertToInteger(
Hi);
554 if (DAG.getDataLayout().isBigEndian())
560 JoinIntegers(
Lo,
Hi));
575 if (DAG.getDataLayout().isBigEndian()) {
579 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
594 if (isTypeLegal(WideOutVT)) {
595 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
597 DAG.getVectorIdxConstant(0, dl));
606 DAG.getDataLayout().isLittleEndian()) {
617 if (isTypeLegal(WideVecVT)) {
619 DAG.getUNDEF(WideVecVT), InOp,
620 DAG.getVectorIdxConstant(0, dl));
628 CreateStackStoreLoad(InOp, OutVT));
632 SDValue V = GetPromotedInteger(
N->getOperand(0));
634 V.getValueType(), V);
638 SDValue Op = GetPromotedInteger(
N->getOperand(0));
639 EVT OVT =
N->getValueType(0);
640 EVT NVT =
Op.getValueType();
648 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
649 if (
SDValue Res = TLI.expandBSWAP(
N, DAG))
654 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
660 return DAG.getNode(ISD::VP_SRL, dl, NVT,
661 DAG.getNode(ISD::VP_BSWAP, dl, NVT,
Op, Mask, EVL), ShAmt,
666 SDValue Op = GetPromotedInteger(
N->getOperand(0));
667 EVT OVT =
N->getValueType(0);
668 EVT NVT =
Op.getValueType();
677 if (
SDValue Res = TLI.expandBITREVERSE(
N, DAG))
682 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
688 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
689 DAG.getNode(ISD::VP_BITREVERSE, dl, NVT,
Op, Mask, EVL),
697 TLI.getTypeToTransformTo(*DAG.getContext(),
698 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
703 EVT VT =
N->getValueType(0);
710 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
717 EVT OVT =
N->getValueType(0);
718 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
724 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
725 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
727 if (
SDValue Result = TLI.expandCTLZ(
N, DAG)) {
733 unsigned CtlzOpcode =
N->getOpcode();
734 if (CtlzOpcode ==
ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
736 SDValue ExtractLeadingBits = DAG.getConstant(
739 if (!
N->isVPOpcode()) {
741 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
742 return DAG.getNode(
ISD::SUB, dl, NVT,
743 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
749 SDValue Op = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
750 return DAG.getNode(ISD::VP_SUB, dl, NVT,
751 DAG.getNode(
N->getOpcode(), dl, NVT,
Op, Mask, EVL),
752 ExtractLeadingBits, Mask, EVL);
755 CtlzOpcode == ISD::VP_CTLZ_ZERO_UNDEF) {
757 SDValue Op = GetPromotedInteger(
N->getOperand(0));
761 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
762 if (!
N->isVPOpcode()) {
764 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
769 Op = DAG.getNode(ISD::VP_SHL, dl, NVT,
Op, ShiftConst, Mask, EVL);
770 return DAG.getNode(CtlzOpcode, dl, NVT,
Op, Mask, EVL);
776 EVT OVT =
N->getValueType(0);
777 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
785 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
786 if (
SDValue Result = TLI.expandCTPOP(
N, DAG)) {
793 if (!
N->isVPOpcode()) {
794 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
795 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
800 SDValue Op = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
801 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op, Mask,
806 SDValue Op = GetPromotedInteger(
N->getOperand(0));
807 EVT OVT =
N->getValueType(0);
808 EVT NVT =
Op.getValueType();
815 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
816 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
820 if (
SDValue Result = TLI.expandCTTZ(
N, DAG)) {
826 unsigned NewOpc =
N->getOpcode();
827 if (NewOpc ==
ISD::CTTZ || NewOpc == ISD::VP_CTTZ) {
834 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
838 DAG.getNode(ISD::VP_OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT),
839 N->getOperand(1),
N->getOperand(2));
840 NewOpc = ISD::VP_CTTZ_ZERO_UNDEF;
843 if (!
N->isVPOpcode())
844 return DAG.getNode(NewOpc, dl, NVT,
Op);
845 return DAG.getNode(NewOpc, dl, NVT,
Op,
N->getOperand(1),
N->getOperand(2));
848SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
850 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
851 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
854SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
856 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
863 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
869 EVT SVT =
In.getValueType().getScalarType();
872 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
880 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
882 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
886 if (
N->isStrictFPOpcode()) {
887 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
888 {
N->getOperand(0),
N->getOperand(1)});
892 }
else if (NewOpc == ISD::VP_FP_TO_SINT || NewOpc == ISD::VP_FP_TO_UINT) {
893 Res = DAG.
getNode(NewOpc, dl, NVT, {
N->getOperand(0),
N->getOperand(1),
896 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
908 N->getOpcode() == ISD::VP_FP_TO_UINT)
912 DAG.getValueType(
N->getValueType(0).getScalarType()));
915SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
917 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
919 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
923SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
924 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
927 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
930SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
931 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
934 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
935 N->getOperand(0),
N->getOperand(1));
941 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
943 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
947 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
951 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
960 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
963 if (getTypeAction(
N->getOperand(0).getValueType())
965 SDValue Res = GetPromotedInteger(
N->getOperand(0));
974 DAG.getValueType(
N->getOperand(0).getValueType()));
976 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
983 if (
N->getNumOperands() != 1) {
984 assert(
N->getNumOperands() == 3 &&
"Unexpected number of operands!");
985 assert(
N->isVPOpcode() &&
"Expected VP opcode");
986 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
987 N->getOperand(1),
N->getOperand(2));
989 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
994 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
998 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
999 N->getMemoryVT(),
N->getMemOperand());
1008 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
1009 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1012 :
N->getExtensionType();
1015 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
1016 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
1017 N->getMemOperand(),
N->isExpandingLoad());
1025 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1026 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1033 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1034 N->getOffset(),
N->getMask(), ExtPassThru,
1035 N->getMemoryVT(),
N->getMemOperand(),
1036 N->getAddressingMode(), ExtType,
1037 N->isExpandingLoad());
1045 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1046 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1048 "Gather result type and the passThru argument type should be the same");
1055 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1056 N->getIndex(),
N->getScale() };
1057 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1058 N->getMemoryVT(), dl,
Ops,
1059 N->getMemOperand(),
N->getIndexType(),
1067SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1068 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1069 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1071 N->getOperand(1), Passthru);
1078 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1079 EVT VT =
N->getValueType(0);
1080 EVT SVT = getSetCCResultType(VT);
1081 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1082 unsigned NumOps =
N->getNumOperands();
1085 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1093 ReplaceValueWith(
SDValue(
N, 0), Res);
1096 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1099template <
class MatchContextClass>
1111 MatchContextClass matcher(DAG, TLI,
N);
1113 unsigned Opcode = matcher.getRootBaseOpcode();
1119 SExtOrZExtPromotedOperands(Op1, Op2);
1125 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1127 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1128 Op1 = SExtPromotedInteger(Op1);
1129 Op2 = SExtPromotedInteger(Op2);
1130 return matcher.getNode(
ISD::UADDSAT, dl, NVT, Op1, Op2);
1133 Op1 = ZExtPromotedInteger(Op1);
1134 Op2 = ZExtPromotedInteger(Op2);
1137 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1139 return matcher.getNode(
ISD::UMIN, dl, NVT,
Add, SatMax);
1146 Op1 = GetPromotedInteger(Op1);
1148 Op2 = ZExtPromotedInteger(Op2);
1150 Op1 = SExtPromotedInteger(Op1);
1151 Op2 = SExtPromotedInteger(Op2);
1158 if (IsShift || matcher.isOperationLegal(Opcode, PromotedType)) {
1171 "addition, subtraction or left shift");
1174 unsigned SHLAmount = NewBits - OldBits;
1176 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1181 SDValue Result = matcher.getNode(Opcode, dl, PromotedType, Op1, Op2);
1182 return matcher.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1188 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1189 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1190 SDValue Result = matcher.getNode(AddOp, dl, PromotedType, Op1, Op2);
1191 Result = matcher.getNode(
ISD::SMIN, dl, PromotedType, Result, SatMax);
1192 Result = matcher.getNode(
ISD::SMAX, dl, PromotedType, Result, SatMin);
1199 SDValue Op1Promoted, Op2Promoted;
1205 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1206 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1208 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1209 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1211 EVT OldType =
N->getOperand(0).getValueType();
1223 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1224 SDValue Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1225 Op2Promoted,
N->getOperand(2));
1227 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1228 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1230 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1235 unsigned SatW,
bool Signed,
1238 EVT VT = V.getValueType();
1265 EVT VT =
LHS.getValueType();
1283 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1289 "Tried to saturate to more than the original type?");
1298 SDValue Op1Promoted, Op2Promoted;
1304 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1305 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1307 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1308 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1311 unsigned Scale =
N->getConstantOperandVal(2);
1315 if (TLI.isTypeLegal(PromotedType)) {
1317 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1320 N->getValueType(0).getScalarSizeInBits();
1324 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1325 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1326 Op2Promoted,
N->getOperand(2));
1329 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1335 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1336 Op2Promoted, Scale, DAG)) {
1339 N->getValueType(0).getScalarSizeInBits(),
1347 N->getValueType(0).getScalarSizeInBits());
1350SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1352 return PromoteIntRes_Overflow(
N);
1356 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1357 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1358 EVT OVT =
N->getOperand(0).getValueType();
1359 EVT NVT =
LHS.getValueType();
1369 DAG.getValueType(OVT));
1371 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1374 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1380 EVT PromotedResultTy =
1381 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1382 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1383 N->getOperand(0),
N->getOperand(1));
1389 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1390 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1392 unsigned Opcode =
N->getOpcode();
1393 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1394 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1396 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1400 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1401 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1403 LHS.getValueType(),
N->getOperand(0),
1404 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1409 EVT InVT =
N->getOperand(OpNo).getValueType();
1410 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1412 EVT SVT = getSetCCResultType(InVT);
1419 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1420 SVT = getSetCCResultType(InVT);
1428 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1429 "Vector compare must return a vector result!");
1433 if (
N->isStrictFPOpcode()) {
1434 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1435 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1436 N->getOperand(2),
N->getOperand(3)};
1437 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1442 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1443 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1446 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1453 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1458 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1459 EVT VT =
N->getValueType(0);
1463 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1465 ReplaceValueWith(
SDValue(
N, 0), Res);
1470 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1472 if (
N->getOpcode() != ISD::VP_SHL) {
1474 RHS = ZExtPromotedInteger(
RHS);
1476 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1482 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1483 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1487SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1488 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1490 Op.getValueType(),
Op,
N->getOperand(1));
1493SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1497 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1498 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1499 if (
N->getNumOperands() == 2)
1500 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1501 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1502 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1503 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1504 N->getOperand(2),
N->getOperand(3));
1508 if (
N->getNumOperands() == 2) {
1510 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1511 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1512 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1514 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1515 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1519 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1520 SDValue RHS = VPSExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1521 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1526 if (
N->getNumOperands() == 2) {
1528 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1529 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1530 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1532 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1533 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1537 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1538 SDValue RHS = VPZExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1539 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1549 SExtOrZExtPromotedOperands(
LHS,
RHS);
1551 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1557 if (
N->getOpcode() != ISD::VP_SRA) {
1559 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1561 RHS = ZExtPromotedInteger(
RHS);
1562 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1568 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1570 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1571 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1577 if (
N->getOpcode() != ISD::VP_SRL) {
1579 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1581 RHS = ZExtPromotedInteger(
RHS);
1582 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1588 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1590 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1591 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1597 SDValue Res = TLI.expandROT(
N,
true , DAG);
1598 ReplaceValueWith(
SDValue(
N, 0), Res);
1603 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1604 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1607 Amt = ZExtPromotedInteger(Amt);
1611 EVT OldVT =
N->getOperand(0).getValueType();
1612 EVT VT =
Lo.getValueType();
1613 unsigned Opcode =
N->getOpcode();
1620 DAG.getConstant(OldBits,
DL, AmtVT));
1628 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1629 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1631 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1641 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1647 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1649 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1653SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1654 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1655 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1660 Amt = VPZExtPromotedInteger(Amt, Mask, EVL);
1664 EVT OldVT =
N->getOperand(0).getValueType();
1665 EVT VT =
Lo.getValueType();
1666 unsigned Opcode =
N->getOpcode();
1667 bool IsFSHR = Opcode == ISD::VP_FSHR;
1672 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1673 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1681 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1682 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1683 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1684 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1686 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1689 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1694 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1695 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1700 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1702 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1706 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1718 Res = GetPromotedInteger(InOp);
1725 "Dst and Src must have the same number of elements");
1727 "Promoted vector type must be a power of two");
1730 GetSplitVector(InOp, EOp1, EOp2);
1738 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1739 "Expected VP_TRUNCATE opcode");
1740 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1741 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1742 std::tie(EVLLo, EVLHi) =
1743 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1744 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1745 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1752 SDValue WideInOp = GetWidenedVector(InOp);
1757 N->getValueType(0).getScalarType(), NumElem);
1766 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1772 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1773 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1778SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1780 return PromoteIntRes_Overflow(
N);
1784 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1785 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1786 EVT OVT =
N->getOperand(0).getValueType();
1787 EVT NVT =
LHS.getValueType();
1796 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1798 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1801 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1812 return PromoteIntRes_Overflow(
N);
1824 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1825 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1827 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1830 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1841 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1842 return PromoteIntRes_Overflow(
N);
1846 EVT OVT =
N->getValueType(0);
1847 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1853 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1854 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1855 if (
SDValue Res = TLI.expandABS(
N, DAG))
1859 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1863SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1866 return PromoteIntRes_Overflow(
N);
1870 EVT SmallVT =
LHS.getValueType();
1877 LHS = SExtPromotedInteger(
LHS);
1878 RHS = SExtPromotedInteger(
RHS);
1880 LHS = ZExtPromotedInteger(
LHS);
1881 RHS = ZExtPromotedInteger(
RHS);
1883 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1895 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1896 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1897 DAG.getConstant(0,
DL,
Hi.getValueType()),
1902 Mul, DAG.getValueType(SmallVT));
1912 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1917 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1918 N->getValueType(0)));
1922 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1924 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1931 EVT VT =
N->getValueType(0);
1934 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1935 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1939 for (
unsigned i = 0; i < NumRegs; ++i) {
1940 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
1941 N->getConstantOperandVal(3));
1946 if (DAG.getDataLayout().isBigEndian())
1947 std::reverse(Parts.begin(), Parts.end());
1950 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1952 for (
unsigned i = 1; i < NumRegs; ++i) {
1957 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1963 ReplaceValueWith(
SDValue(
N, 1), Chain);
1976bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
1979 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
1984 switch (
N->getOpcode()) {
1987 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
1988 N->dump(&DAG);
dbgs() <<
"\n";
1997 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
1998 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2004 Res = PromoteIntOp_FAKE_USE(
N);
2007 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2011 Res = PromoteIntOp_ScalarOp(
N);
2014 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2017 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2019 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2020 case ISD::VP_SINT_TO_FP:
2037 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2039 case ISD::VP_TRUNCATE:
2043 case ISD::VP_UINT_TO_FP:
2048 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2059 Res = PromoteIntOp_Shift(
N);
2063 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2066 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2092 case ISD::VP_REDUCE_ADD:
2093 case ISD::VP_REDUCE_MUL:
2094 case ISD::VP_REDUCE_AND:
2095 case ISD::VP_REDUCE_OR:
2096 case ISD::VP_REDUCE_XOR:
2097 case ISD::VP_REDUCE_SMAX:
2098 case ISD::VP_REDUCE_SMIN:
2099 case ISD::VP_REDUCE_UMAX:
2100 case ISD::VP_REDUCE_UMIN:
2101 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2106 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2109 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2112 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2114 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2115 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2116 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2118 case ISD::EXPERIMENTAL_VP_SPLICE:
2119 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2122 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2125 Res = PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
N, OpNo);
2128 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2133 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2138 if (!Res.
getNode())
return false;
2145 const bool IsStrictFp =
N->isStrictFPOpcode();
2147 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2148 "Invalid operand expansion");
2152 ReplaceValueWith(
SDValue(
N, 0), Res);
2166 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2170 unsigned OpLEffectiveBits =
2171 DAG.computeKnownBits(OpL).countMaxActiveBits();
2172 unsigned OpREffectiveBits =
2173 DAG.computeKnownBits(OpR).countMaxActiveBits();
2174 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2175 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2182 LHS = SExtPromotedInteger(
LHS);
2183 RHS = SExtPromotedInteger(
RHS);
2192 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2193 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2194 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2195 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2202 LHS = ZExtPromotedInteger(
LHS);
2203 RHS = ZExtPromotedInteger(
RHS);
2217 LHS = SExtPromotedInteger(
LHS);
2218 RHS = SExtPromotedInteger(
RHS);
2223 "Unknown integer comparison!");
2225 SExtOrZExtPromotedOperands(
LHS,
RHS);
2229 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2234 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2235 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2236 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2240 EVT OutVT =
N->getValueType(0);
2243 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2246 switch (getTypeAction(InVT)) {
2250 DAG.getDataLayout().isLittleEndian()) {
2260 if (isTypeLegal(WideVecVT)) {
2261 SDValue Promoted = GetPromotedInteger(InOp);
2264 DAG.getVectorIdxConstant(0, dl));
2277 return CreateStackStoreLoad(InOp, OutVT);
2280SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2281 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2289 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2290 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2294SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2295 assert(OpNo == 1 &&
"only know how to promote condition");
2298 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2301 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2302 N->getOperand(2)), 0);
2307 EVT OVT =
N->getOperand(0).getValueType();
2308 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2309 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2310 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2315 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2316 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2325 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2326 "Legal vector of one illegal element?");
2331 assert(
N->getOperand(0).getValueSizeInBits() >=
2332 N->getValueType(0).getScalarSizeInBits() &&
2333 "Type of inserted value narrower than vector element type!");
2336 for (
unsigned i = 0; i < NumElts; ++i)
2337 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2339 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2342SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2349 assert(
N->getOperand(1).getValueSizeInBits() >=
2350 N->getValueType(0).getScalarSizeInBits() &&
2351 "Type of inserted value narrower than vector element type!");
2352 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2353 GetPromotedInteger(
N->getOperand(1)),
2358 assert(OpNo == 2 &&
"Different operand and result vector types?");
2361 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2362 TLI.getVectorIdxTy(DAG.getDataLayout()));
2363 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2364 N->getOperand(1), Idx), 0);
2368 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2372 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2375SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2376 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2378 EVT OpTy =
N->getOperand(1).getValueType();
2381 if (
SDValue Res = WidenVSELECTMask(
N))
2382 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2383 Res,
N->getOperand(1),
N->getOperand(2));
2387 Cond = PromoteTargetBoolean(
Cond, OpVT);
2389 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2390 N->getOperand(2)), 0);
2393SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2394 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2402 N->getOperand(3),
N->getOperand(4)), 0);
2405SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2406 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2414 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2416 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2419 N->getOperand(3),
N->getOperand(4)),
2424 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2425 ZExtPromotedInteger(
N->getOperand(1))), 0);
2433 LHS = SExtPromotedInteger(
LHS);
2434 RHS = SExtPromotedInteger(
RHS);
2436 SExtOrZExtPromotedOperands(
LHS,
RHS);
2443 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2444 ZExtPromotedInteger(
N->getOperand(2))), 0);
2448 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2452 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2455SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2457 EVT VT =
N->getValueType(0);
2458 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2460 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2464 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2468 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2473 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2474 return SDValue(DAG.UpdateNodeOperands(
N,
2475 SExtPromotedInteger(
N->getOperand(0)),
2476 N->getOperand(1),
N->getOperand(2)),
2478 return SDValue(DAG.UpdateNodeOperands(
N,
2479 SExtPromotedInteger(
N->getOperand(0))), 0);
2482SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2483 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2484 SExtPromotedInteger(
N->getOperand(1))), 0);
2489 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2492 SDValue Val = GetPromotedInteger(
N->getValue());
2495 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2496 N->getMemoryVT(),
N->getMemOperand());
2502 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2503 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2505 SDValue DataOp = GetPromotedInteger(
N->getValue());
2506 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2507 N->getMask(),
N->getVectorLength(),
2508 N->getMemoryVT(),
N->getMemOperand(),
2509 N->isCompressingStore());
2520 Mask = PromoteTargetBoolean(Mask, DataVT);
2523 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2526 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2527 DataOp = GetPromotedInteger(DataOp);
2529 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2530 N->getOffset(), Mask,
N->getMemoryVT(),
2531 N->getMemOperand(),
N->getAddressingMode(),
2532 true,
N->isCompressingStore());
2537 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2538 EVT DataVT =
N->getValueType(0);
2539 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2541 NewOps[OpNo] =
Mask;
2542 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2558 EVT DataVT =
N->getValueType(0);
2559 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2560 }
else if (OpNo == 4) {
2562 if (
N->isIndexSigned())
2564 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2566 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2568 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2570 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2582 bool TruncateStore =
N->isTruncatingStore();
2587 EVT DataVT =
N->getValue().getValueType();
2588 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2589 }
else if (OpNo == 4) {
2591 if (
N->isIndexSigned())
2593 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2595 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2597 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2598 TruncateStore =
true;
2601 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2602 SDLoc(
N), NewOps,
N->getMemOperand(),
2603 N->getIndexType(), TruncateStore);
2608 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2612 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2617 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2618 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2619 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2620 N->getOperand(1),
N->getOperand(2));
2625 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2626 return SDValue(DAG.UpdateNodeOperands(
N,
2627 ZExtPromotedInteger(
N->getOperand(0)),
2628 N->getOperand(1),
N->getOperand(2)),
2630 return SDValue(DAG.UpdateNodeOperands(
N,
2631 ZExtPromotedInteger(
N->getOperand(0))), 0);
2634SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2635 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2636 ZExtPromotedInteger(
N->getOperand(1))), 0);
2643 EVT VT =
N->getValueType(0);
2648 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2649 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2650 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2651 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2656 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2659SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2661 EVT VT =
N->getValueType(0);
2662 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2664 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2666 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2667 N->getOperand(0).getValueType());
2671 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2673 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2676SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2678 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2679 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2688 unsigned OpOffset = IsStrict ? 1 : 0;
2695 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
2696 if (LCImpl == RTLIB::Unsupported) {
2702 if (IsPowI &&
N->getValueType(0).isVector())
2703 return DAG.UnrollVectorOp(
N);
2705 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2706 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2716 assert(DAG.getLibInfo().getIntSize() ==
2717 N->getOperand(1 + OpOffset).getValueType().getSizeInBits() &&
2718 "POWI exponent should match with sizeof(int) when doing the libcall.");
2719 TargetLowering::MakeLibCallOptions CallOptions;
2721 SDValue Ops[2] = {
N->getOperand(0 + OpOffset),
N->getOperand(1 + OpOffset)};
2722 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2723 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2724 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2726 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2731 switch (
N->getOpcode()) {
2739 case ISD::VP_REDUCE_ADD:
2740 case ISD::VP_REDUCE_MUL:
2741 case ISD::VP_REDUCE_AND:
2742 case ISD::VP_REDUCE_OR:
2743 case ISD::VP_REDUCE_XOR:
2747 case ISD::VP_REDUCE_SMAX:
2748 case ISD::VP_REDUCE_SMIN:
2752 case ISD::VP_REDUCE_UMAX:
2753 case ISD::VP_REDUCE_UMIN:
2763 return GetPromotedInteger(V);
2765 return SExtPromotedInteger(V);
2767 return ZExtPromotedInteger(V);
2773 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2775 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2776 EVT InVT =
Op.getValueType();
2778 EVT ResVT =
N->getValueType(0);
2779 unsigned Opcode =
N->getOpcode();
2796 switch (TLI.getBooleanContents(InVT)) {
2799 Op = ZExtPromotedInteger(
N->getOperand(0));
2802 Op = SExtPromotedInteger(
N->getOperand(0));
2815 switch (TLI.getBooleanContents(InVT)) {
2818 Op = ZExtPromotedInteger(
N->getOperand(0));
2821 Op = SExtPromotedInteger(
N->getOperand(0));
2827 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2831 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2835SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2842 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2843 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2846 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2848 Op = PromoteIntOpVectorReduction(
N,
Op);
2852 EVT VT =
N->getValueType(0);
2853 EVT EltVT =
Op.getValueType().getScalarType();
2856 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2868 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2869 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2872SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2875 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2876 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2879SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2882 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2883 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2888 const Function &Fn = DAG.getMachineFunction().getFunction();
2890 "cannot use llvm.write_register with illegal type", Fn,
2892 return N->getOperand(0);
2895SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2896 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2897 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2900 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2902 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2905SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2909 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2910 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2913 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2915 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2916 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2919SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2921 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2923 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2924 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2927SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N,
2930 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2931 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2934SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
2936 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
2937 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2938 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2941SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
2943 switch (
N->getOpcode()) {
2945 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2946 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
2949 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2950 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2953 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2954 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2959 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2970void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
2976 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
2979 switch (
N->getOpcode()) {
2982 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
2983 N->dump(&DAG);
dbgs() <<
"\n";
3060 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3061 SplitInteger(Tmp.first,
Lo,
Hi);
3062 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3067 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3068 SDValue Tmp = DAG.getAtomicCmpSwap(
3070 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3079 SplitInteger(Tmp,
Lo,
Hi);
3158 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3163 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3167 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3171 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3181std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3182 unsigned Opc =
Node->getOpcode();
3188 EVT RetVT =
Node->getValueType(0);
3189 TargetLowering::MakeLibCallOptions CallOptions;
3192 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
3193 if (LCImpl != RTLIB::Unsupported) {
3195 Ops.push_back(
Node->getOperand(1));
3198 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3199 "Unexpected atomic op or value type!");
3201 LCImpl = TLI.getLibcallImpl(LC);
3203 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3204 Node->getOperand(0));
3209void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3214 GetExpandedInteger(
N->getOperand(0), InL, InH);
3229 if (Amt.
uge(VTBits)) {
3230 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3231 }
else if (Amt.
ugt(NVTBits)) {
3232 Lo = DAG.getConstant(0,
DL, NVT);
3234 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3235 }
else if (Amt == NVTBits) {
3236 Lo = DAG.getConstant(0,
DL, NVT);
3240 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3244 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3246 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3252 if (Amt.
uge(VTBits)) {
3253 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3254 }
else if (Amt.
ugt(NVTBits)) {
3256 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3257 Hi = DAG.getConstant(0,
DL, NVT);
3258 }
else if (Amt == NVTBits) {
3260 Hi = DAG.getConstant(0,
DL, NVT);
3265 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3267 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3269 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3275 if (Amt.
uge(VTBits)) {
3277 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3278 }
else if (Amt.
ugt(NVTBits)) {
3280 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3282 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3283 }
else if (Amt == NVTBits) {
3286 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3291 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3293 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3295 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3303bool DAGTypeLegalizer::
3305 unsigned Opc =
N->getOpcode();
3308 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3313 "Expanded integer type size not a power of two!");
3317 KnownBits Known = DAG.computeKnownBits(Amt);
3320 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3325 GetExpandedInteger(In, InL, InH);
3332 DAG.getConstant(~HighBitMask, dl, ShTy));
3337 Lo = DAG.getConstant(0, dl, NVT);
3338 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3341 Hi = DAG.getConstant(0, dl, NVT);
3342 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3346 DAG.getConstant(NVTBits - 1, dl, ShTy));
3347 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3359 DAG.getConstant(NVTBits - 1, dl, ShTy));
3375 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3377 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3379 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3380 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3392bool DAGTypeLegalizer::
3395 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3399 "Expanded integer type size not a power of two!");
3404 GetExpandedInteger(
N->getOperand(0), InL, InH);
3406 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3409 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3412 Amt, DAG.getConstant(0, dl, ShTy),
3416 switch (
N->getOpcode()) {
3422 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3423 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3426 LoL = DAG.getConstant(0, dl, NVT);
3429 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3430 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3431 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3437 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3440 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3443 HiL = DAG.getConstant(0, dl, NVT);
3446 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3447 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3448 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3454 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3455 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3459 DAG.getConstant(NVTBits - 1, dl, ShTy));
3462 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3463 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3464 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3489 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3494 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3495 SplitInteger(Res,
Lo,
Hi);
3498void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3507 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3508 unsigned NumHalfBits = NumBits / 2;
3509 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3510 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3511 SDValue LHSL, LHSH, RHSL, RHSH;
3512 GetExpandedInteger(
LHS, LHSL, LHSH);
3513 GetExpandedInteger(
RHS, RHSL, RHSH);
3516 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3518 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3526 SDValue LHSL, LHSH, RHSL, RHSH;
3527 GetExpandedInteger(
LHS, LHSL, LHSH);
3528 GetExpandedInteger(
RHS, RHSL, RHSH);
3530 EVT CCT = getSetCCResultType(NVT);
3533 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3535 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3537 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3539 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3543 const APInt *RHSVal =
nullptr;
3545 RHSVal = &RHSConst->getAPIntValue();
3552 SDValue LHSL, LHSH, RHSL, RHSH;
3553 GetExpandedInteger(
LHS, LHSL, LHSH);
3554 GetExpandedInteger(
RHS, RHSL, RHSH);
3556 EVT CCT = getSetCCResultType(NVT);
3562 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3565 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3569 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3572 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3574 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3581 switch (
N->getOpcode()) {
3608 EVT VT =
N->getValueType(0);
3609 EVT CCT = getSetCCResultType(VT);
3612 SplitInteger(Result,
Lo,
Hi);
3616 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3617 SplitInteger(ExpandedCMP,
Lo,
Hi);
3620void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3624 SDValue LHSL, LHSH, RHSL, RHSH;
3625 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3626 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3629 SDValue LoOps[2] = { LHSL, RHSL };
3630 SDValue HiOps[3] = { LHSH, RHSH };
3632 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3634 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3636 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3640 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3646 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3659 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3661 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3664 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3678 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3680 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3684 EVT OvfVT = getSetCCResultType(NVT);
3685 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3700 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3703 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3707 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3719 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3723 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3726 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3729 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3734 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3736 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3737 DAG.getConstant(0, dl, NVT));
3740 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3749 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3754 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3756 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3757 DAG.getConstant(0, dl, NVT));
3763void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3766 SDValue LHSL, LHSH, RHSL, RHSH;
3768 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3769 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3770 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3771 SDValue LoOps[2] = { LHSL, RHSL };
3772 SDValue HiOps[3] = { LHSH, RHSH };
3786 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3789void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3792 SDValue LHSL, LHSH, RHSL, RHSH;
3794 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3795 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3796 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3798 SDValue HiOps[3] = { LHSH, RHSH };
3800 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3802 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3806 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3809void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3817 unsigned CarryOp, NoCarryOp;
3819 switch(
N->getOpcode()) {
3834 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3835 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3839 SDValue LHSL, LHSH, RHSL, RHSH;
3840 GetExpandedInteger(
LHS, LHSL, LHSH);
3841 GetExpandedInteger(
RHS, RHSL, RHSH);
3842 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3843 SDValue LoOps[2] = { LHSL, RHSL };
3844 SDValue HiOps[3] = { LHSH, RHSH };
3846 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3848 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3855 SplitInteger(Sum,
Lo,
Hi);
3861 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
3862 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
3866 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
3871 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
3877 ReplaceValueWith(
SDValue(
N, 1), Ovf);
3883 SDValue LHSL, LHSH, RHSL, RHSH;
3885 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3886 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3887 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3891 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3893 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3897 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3900void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
3903 SDValue LHSL, LHSH, RHSL, RHSH;
3905 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3906 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3907 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3912 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
3913 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
3917 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3920void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
3922 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3925 if (
Op.getValueType().bitsLE(NVT)) {
3928 Hi = DAG.getUNDEF(NVT);
3932 assert(getTypeAction(
Op.getValueType()) ==
3934 "Only know how to promote this result!");
3937 "Operand over promoted?");
3939 SplitInteger(Res,
Lo,
Hi);
3943void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
3946 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3947 EVT NVT =
Lo.getValueType();
3952 if (NVTBits < EVTBits) {
3955 EVTBits - NVTBits)));
3960 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
3964void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
3967 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3968 EVT NVT =
Lo.getValueType();
3973 if (NVTBits < EVTBits) {
3976 EVTBits - NVTBits)));
3980 Hi = DAG.getConstant(0, dl, NVT);
3984void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
3987 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
3992void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
3995 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4004 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4005 EVT NVT =
Lo.getValueType();
4008 Hi = DAG.getConstant(0, dl, NVT);
4011void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4013 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4016 const APInt &Cst =
Constant->getAPIntValue();
4017 bool IsTarget =
Constant->isTargetOpcode();
4018 bool IsOpaque =
Constant->isOpaque();
4020 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4021 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4029 GetExpandedInteger(N0,
Lo,
Hi);
4030 EVT NVT =
Lo.getValueType();
4036 Hi = DAG.getConstant(0, dl, NVT);
4046 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4051 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4052 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4061 EVT VT =
N->getValueType(0);
4063 DAG.getConstant(0, dl, VT), N0);
4065 SplitInteger(Neg, NegLo, NegHi);
4067 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4069 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4070 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4073void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4077 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4078 EVT NVT =
Lo.getValueType();
4080 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4083 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4086 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4087 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4090 Hi = DAG.getConstant(0, dl, NVT);
4095 SplitInteger(Result,
Lo,
Hi);
4100 EVT VT =
N->getValueType(0);
4105 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4106 "LibCall explicitly requested, but not available");
4108 if (RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC)) {
4109 TargetLowering::MakeLibCallOptions CallOptions;
4113 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4114 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4122 GetExpandedInteger(
Op,
Lo,
Hi);
4123 EVT NVT =
Lo.getValueType();
4126 Hi = DAG.getConstant(0,
DL, NVT);
4129void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4133 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4134 EVT NVT =
Lo.getValueType();
4136 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4142 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4143 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4146 Hi = DAG.getConstant(0, dl, NVT);
4152 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4159 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4163 ReplaceValueWith(
SDValue(
N, 1), Chain);
4171 Chain =
Op.getValue(1);
4180 EVT VT =
N->getValueType(0);
4184 bool IsStrict =
N->isStrictFPOpcode();
4186 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4188 Op = GetPromotedFloat(
Op);
4192 Op.getValueType() == MVT::bf16) {
4198 EVT OpVT =
Op.getValueType();
4202 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4203 TargetLowering::MakeLibCallOptions CallOptions;
4208 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4209 CallOptions, dl, Chain);
4210 SplitInteger(Tmp.first,
Lo,
Hi);
4213 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4218 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4219 SplitInteger(Res,
Lo,
Hi);
4225 bool IsStrict =
N->isStrictFPOpcode();
4226 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4230 "Input type needs to be promoted!");
4232 EVT VT =
Op.getValueType();
4234 if (VT == MVT::f16) {
4240 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4244 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4248 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4252 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4256 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4260 EVT RetVT =
N->getValueType(0);
4262 TargetLowering::MakeLibCallOptions CallOptions;
4264 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4265 Op, CallOptions, dl,
4267 SplitInteger(Tmp.first,
Lo,
Hi);
4269 if (
N->isStrictFPOpcode())
4270 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4273void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4275 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4278 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4284 EVT VT =
N->getValueType(0);
4285 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4290 AAMDNodes AAInfo =
N->getAAInfo();
4295 if (
N->getMemoryVT().bitsLE(NVT)) {
4296 EVT MemVT =
N->getMemoryVT();
4298 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4299 N->getBaseAlign(), MMOFlags, AAInfo);
4307 unsigned LoSize =
Lo.getValueSizeInBits();
4309 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4312 Hi = DAG.getConstant(0, dl, NVT);
4316 Hi = DAG.getUNDEF(NVT);
4318 }
else if (DAG.getDataLayout().isLittleEndian()) {
4320 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4323 unsigned ExcessBits =
4330 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4331 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4332 N->getBaseAlign(), MMOFlags, AAInfo);
4341 EVT MemVT =
N->getMemoryVT();
4344 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4347 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4350 N->getBaseAlign(), MMOFlags, AAInfo);
4356 N->getPointerInfo().getWithOffset(IncrementSize),
4358 N->getBaseAlign(), MMOFlags, AAInfo);
4370 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4374 DAG.getShiftAmountConstant(
4381 ReplaceValueWith(
SDValue(
N, 1), Ch);
4384void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4388 GetExpandedInteger(
N->getOperand(0), LL, LH);
4389 GetExpandedInteger(
N->getOperand(1), RL, RH);
4393 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4395 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4396 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4399void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4401 EVT VT =
N->getValueType(0);
4402 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4406 GetExpandedInteger(
N->getOperand(0), LL, LH);
4407 GetExpandedInteger(
N->getOperand(1), RL, RH);
4409 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4416 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
4417 if (LCImpl == RTLIB::Unsupported) {
4420 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4426 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4427 TargetLowering::MakeLibCallOptions CallOptions;
4429 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4436 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4437 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4438 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4441 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4446 SplitInteger(Result,
Lo,
Hi);
4452 SplitInteger(Result,
Lo,
Hi);
4458 SplitInteger(Result,
Lo,
Hi);
4469 EVT VT =
N->getValueType(0);
4473 uint64_t Scale =
N->getConstantOperandVal(2);
4485 EVT BoolVT = getSetCCResultType(VT);
4487 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4493 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4494 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4500 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4501 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4506 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4507 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4510 SplitInteger(Result,
Lo,
Hi);
4516 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4518 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4520 GetExpandedInteger(
LHS, LL, LH);
4521 GetExpandedInteger(
RHS, RL, RH);
4525 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4532 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4533 SplitInteger(LoTmp, Result[0], Result[1]);
4534 SplitInteger(HiTmp, Result[2], Result[3]);
4536 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4539 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4540 "the size of the current value type");
4561 uint64_t Part0 = Scale / NVTSize;
4562 if (Scale % NVTSize) {
4563 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4566 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4578 if (Scale == VTSize)
4597 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4598 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4599 EVT BoolNVT = getSetCCResultType(NVT);
4602 if (Scale < NVTSize) {
4605 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4606 DAG.getShiftAmountConstant(Scale, NVT, dl));
4607 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4608 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4609 }
else if (Scale == NVTSize) {
4611 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4612 }
else if (Scale < VTSize) {
4616 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4617 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4620 "(and saturation can't happen with Scale==VTSize).");
4622 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4623 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4627 if (Scale < NVTSize) {
4632 unsigned OverflowBits = VTSize - Scale + 1;
4633 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4634 "Extent of overflow bits must start within HL");
4635 SDValue HLHiMask = DAG.getConstant(
4637 SDValue HLLoMask = DAG.getConstant(
4644 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4650 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4651 }
else if (Scale == NVTSize) {
4657 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4663 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4664 }
else if (Scale < VTSize) {
4667 unsigned OverflowBits = VTSize - Scale + 1;
4668 SDValue HHHiMask = DAG.getConstant(
4670 SDValue HHLoMask = DAG.getConstant(
4672 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4673 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4680 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4681 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4684 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4685 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4692 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4694 N->getConstantOperandVal(2), DAG);
4698 N->getConstantOperandVal(2), TLI, DAG);
4699 SplitInteger(Res,
Lo,
Hi);
4702void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4705 "Node has unexpected Opcode");
4715 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4716 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4720 SDValue LHSL, LHSH, RHSL, RHSH;
4721 GetExpandedInteger(
LHS, LHSL, LHSH);
4722 GetExpandedInteger(
RHS, RHSL, RHSH);
4723 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4726 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4735 SplitInteger(Sum,
Lo,
Hi);
4760 EVT VT =
LHS.getValueType();
4763 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4767 EVT OType =
Node->getValueType(1);
4768 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4772 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4775void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4777 EVT VT =
N->getValueType(0);
4779 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4788 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4790 TargetLowering::MakeLibCallOptions CallOptions;
4792 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4795void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4798 SDValue Shiftee =
N->getOperand(0);
4805 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4806 }
while (!TLI.isTypeLegal(LoadVT));
4811 "Shifting unit is not a a power of two!");
4813 const bool IsOneStepShift =
4814 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4819 if (!IsOneStepShift)
4820 ShAmt = DAG.getFreeze(ShAmt);
4823 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4824 unsigned VTByteWidth = VTBitWidth / 8;
4826 "Shiftee type size is not a power of two!");
4827 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4828 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4833 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
4835 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
4836 EVT PtrTy =
StackPtr.getValueType();
4837 SDValue Ch = DAG.getEntryNode();
4840 DAG.getMachineFunction(),
4846 unsigned WideningOpc =
4848 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
4851 SDValue AllZeros = DAG.getConstant(0, dl, VT);
4855 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
4861 Flags.setExact(IsOneStepShift);
4864 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
4866 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
4867 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
4870 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
4875 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
4882 if (DAG.getDataLayout().isBigEndian())
4883 WillIndexUpwards = !WillIndexUpwards;
4886 if (WillIndexUpwards) {
4889 AdjStackPtr = DAG.getMemBasePlusOffset(
4890 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
4891 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
4895 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
4896 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
4900 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
4905 if (!IsOneStepShift) {
4907 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
4908 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
4909 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
4913 SplitInteger(Res,
Lo,
Hi);
4916void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
4918 EVT VT =
N->getValueType(0);
4919 unsigned Opc =
N->getOpcode();
4925 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
4929 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
4946 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4948 const bool LegalOrCustom =
4952 unsigned ExpansionFactor = 1;
4954 for (EVT TmpVT = NVT;;) {
4955 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
4956 if (NewTMPVT == TmpVT)
4963 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
4966 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
4968 if (LegalOrCustom &&
4972 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4978 SDValue ShiftOp =
N->getOperand(1);
4979 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
4981 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
4984 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
4985 Hi =
Lo.getValue(1);
4990 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5004 if (RTLIB::LibcallImpl LibcallImpl = TLI.getLibcallImpl(LC)) {
5007 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5009 TargetLowering::MakeLibCallOptions CallOptions;
5012 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5017 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5021void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5023 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5026 if (
Op.getValueType().bitsLE(NVT)) {
5032 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5036 assert(getTypeAction(
Op.getValueType()) ==
5038 "Only know how to promote this result!");
5041 "Operand over promoted?");
5043 SplitInteger(Res,
Lo,
Hi);
5051void DAGTypeLegalizer::
5054 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5057 if (EVT.
bitsLE(
Lo.getValueType())) {
5065 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5066 Hi.getValueType(), dl));
5077void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5079 EVT VT =
N->getValueType(0);
5081 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5090 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5092 TargetLowering::MakeLibCallOptions CallOptions;
5094 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5097void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5099 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5109void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5111 EVT VT =
N->getValueType(0);
5130 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5131 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5132 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5134 EVT BitVT =
N->getValueType(1);
5135 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5137 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5139 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5140 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5159 SplitInteger(Three,
Lo,
Hi);
5163 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5168 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5173 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
5177 if (LCImpl == RTLIB::Unsupported ||
5178 TLI.getLibcallImplName(LCImpl) == DAG.getMachineFunction().getName()) {
5181 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5182 N->getOperand(1), MulLo, MulHi);
5187 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5188 SplitInteger(MulLo,
Lo,
Hi);
5189 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5193 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5196 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5197 MachinePointerInfo());
5201 EVT ArgVT =
Op.getValueType();
5203 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5204 Entry.IsSExt =
true;
5205 Entry.IsZExt =
false;
5206 Args.push_back(Entry);
5210 TargetLowering::ArgListEntry
Entry(
5212 Entry.IsSExt =
true;
5213 Entry.IsZExt =
false;
5214 Args.push_back(Entry);
5216 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5218 TargetLowering::CallLoweringInfo CLI(DAG);
5221 .setLibCallee(TLI.getLibcallImplCallingConv(LCImpl), RetTy, Func,
5225 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5227 SplitInteger(CallInfo.first,
Lo,
Hi);
5229 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5230 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5231 DAG.getConstant(0, dl, PtrVT),
5234 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5237void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5239 EVT VT =
N->getValueType(0);
5241 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5251 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5253 if (isTypeLegal(NVT)) {
5255 GetExpandedInteger(
N->getOperand(0), InL, InH);
5257 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5266 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5268 TargetLowering::MakeLibCallOptions CallOptions;
5269 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5272void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5274 EVT VT =
N->getValueType(0);
5276 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5286 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5288 if (isTypeLegal(NVT)) {
5290 GetExpandedInteger(
N->getOperand(0), InL, InH);
5292 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5301 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5303 TargetLowering::MakeLibCallOptions CallOptions;
5304 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5307void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5309 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5312 if (
Op.getValueType().bitsLE(NVT)) {
5315 Hi = DAG.getConstant(0, dl, NVT);
5319 assert(getTypeAction(
Op.getValueType()) ==
5321 "Only know how to promote this result!");
5324 "Operand over promoted?");
5326 SplitInteger(Res,
Lo,
Hi);
5328 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5334void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5338 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5340 SDValue Swap = DAG.getAtomicCmpSwap(
5349void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5353 SDValue Res = TLI.expandVecReduce(
N, DAG);
5354 SplitInteger(Res,
Lo,
Hi);
5357void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5363 N->getOperand(0),
N->getOperand(1));
5364 SplitInteger(Res,
Lo,
Hi);
5371 GetExpandedInteger(
N->getOperand(0), In3, In4);
5372 GetExpandedInteger(
N->getOperand(1), In1, In2);
5376 unsigned Opc =
N->getOpcode();
5379 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5384 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5386 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5390 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5391 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5396 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5397 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5402 EVT VT =
N->getValueType(0);
5409 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5412 SplitInteger(Res,
Lo,
Hi);
5419 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5420 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5422 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5423 Lo = DAG.getPOISON(LoVT);
5424 Hi = DAG.getPOISON(HiVT);
5435bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5439 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5442 switch (
N->getOpcode()) {
5445 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5446 N->dump(&DAG);
dbgs() <<
"\n";
5451 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5455 Res = ExpandOp_FAKE_USE(
N);
5461 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5474 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5479 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5483 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5486 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5488 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5489 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5490 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5493 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5498 if (!Res.
getNode())
return false;
5506 "Invalid operand expansion");
5508 ReplaceValueWith(
SDValue(
N, 0), Res);
5514void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5518 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5519 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5520 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5533 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5540 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5541 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5572 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5573 RHSLo, LowCC,
false, DagCombineInfo, dl);
5575 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5579 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5580 RHSHi, CCCode,
false, DagCombineInfo, dl);
5584 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5593 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5595 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5604 if (LHSHi == RHSHi) {
5613 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5614 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5617 if (HasSETCCCARRY) {
5620 bool FlipOperands =
false;
5637 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5641 DAG.getCondCode(CCCode));
5647 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5648 false, DagCombineInfo, dl);
5651 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5652 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5659 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5664 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5669 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5670 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5671 N->getOperand(4)), 0);
5677 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5682 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5687 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5688 N->getOperand(2),
N->getOperand(3),
5689 DAG.getCondCode(CCCode)), 0);
5695 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5700 "Unexpected setcc expansion!");
5706 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5714 SDLoc dl = SDLoc(
N);
5716 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5717 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5718 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5731 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5741 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5742 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5746 return TLI.expandCMP(
N, DAG);
5754 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5755 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5759 bool IsStrict =
N->isStrictFPOpcode();
5763 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5764 EVT DstVT =
N->getValueType(0);
5767 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5768 "Don't know how to expand this XINT_TO_FP!");
5769 TargetLowering::MakeLibCallOptions CallOptions;
5771 std::pair<SDValue, SDValue> Tmp =
5772 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5777 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
5778 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
5783 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
5786 return ExpandOp_NormalStore(
N, OpNo);
5789 assert(OpNo == 1 &&
"Can only expand the stored value so far");
5791 EVT VT =
N->getOperand(1).getValueType();
5792 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5796 AAMDNodes AAInfo =
N->getAAInfo();
5802 if (
N->getMemoryVT().bitsLE(NVT)) {
5803 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5804 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
5805 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
5809 if (DAG.getDataLayout().isLittleEndian()) {
5811 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5813 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
5816 unsigned ExcessBits =
5823 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
5824 N->getPointerInfo().getWithOffset(IncrementSize),
5825 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
5831 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5833 EVT ExtVT =
N->getMemoryVT();
5836 unsigned ExcessBits = (EBytes - IncrementSize)*8;
5844 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
5848 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
5852 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
5853 N->getBaseAlign(), MMOFlags, AAInfo);
5858 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
5859 N->getPointerInfo().getWithOffset(IncrementSize),
5861 N->getBaseAlign(), MMOFlags, AAInfo);
5867 GetExpandedInteger(
N->getOperand(0), InL, InH);
5876 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
5881SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
5882 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
5883 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
5887 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
5889 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
5892SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
5895 "cannot use llvm.write_register with illegal type", Fn,
5898 return N->getOperand(0);
5901SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
5904 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
5905 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
5911SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
5913 unsigned Factor =
N->getNumOperands();
5916 for (
unsigned i = 0; i != Factor; i++)
5917 Ops[i] = GetPromotedInteger(
N->getOperand(i));
5922 for (
unsigned i = 0; i != Factor; i++)
5928SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
5930 EVT OutVT =
N->getValueType(0);
5931 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
5932 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
5936 SDValue BaseIdx =
N->getOperand(1);
5953 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
5957 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
5963 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
5972 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
5976 "Promoted operand has an element type greater than result");
5989 InOp0 = GetPromotedInteger(InOp0);
5996 Ops.reserve(OutNumElems);
5997 for (
unsigned i = 0; i != OutNumElems; ++i) {
6002 N->getOperand(0), Index);
6003 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6008 return DAG.getBuildVector(NOutVT, dl,
Ops);
6011SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6012 EVT OutVT =
N->getValueType(0);
6013 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6014 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6026 Vec = GetPromotedInteger(Vec);
6032SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6035 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6041SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6043 EVT VT =
N->getValueType(0);
6048 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6049 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6052 return DAG.getVectorShuffle(OutVT, dl, V0, V1, NewMask);
6056 EVT OutVT =
N->getValueType(0);
6057 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6058 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6059 unsigned NumElems =
N->getNumOperands();
6066 Ops.reserve(NumElems);
6067 for (
unsigned i = 0; i != NumElems; ++i) {
6069 EVT OpVT =
Op.getValueType();
6074 if (OpVT.
bitsLT(NOutVTElem)) {
6080 ExtOpc = NOutExtOpc;
6081 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6086 return DAG.getBuildVector(NOutVT, dl,
Ops);
6093 assert(!
N->getOperand(0).getValueType().isVector() &&
6094 "Input must be a scalar");
6096 EVT OutVT =
N->getValueType(0);
6097 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6098 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6102 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6107 EVT OutVT =
N->getValueType(0);
6108 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6110 "Type must be promoted to a scalable vector type");
6111 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6112 return DAG.getStepVector(dl, NOutVT,
6116SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6119 EVT OutVT =
N->getValueType(0);
6120 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6121 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6123 unsigned NumOperands =
N->getNumOperands();
6128 SDUse *MaxSizedValue = std::max_element(
6130 EVT AVT = A.getValueType().getVectorElementType();
6131 EVT BVT = B.getValueType().getVectorElementType();
6132 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6138 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6140 EVT OpVT =
Op.getValueType();
6142 Op = GetPromotedInteger(
Op);
6145 "Unhandled legalization type");
6149 Op = DAG.getAnyExtOrTrunc(
Op, dl,
6156 return DAG.getAnyExtOrTrunc(
6162 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6163 assert(NumElem * NumOperands == NumOutElem &&
6164 "Unexpected number of elements");
6168 for (
unsigned i = 0; i < NumOperands; ++i) {
6171 Op = GetPromotedInteger(
Op);
6172 EVT SclrTy =
Op.getValueType().getVectorElementType();
6173 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6174 "Unexpected number of elements");
6176 for (
unsigned j = 0;
j < NumElem; ++
j) {
6178 DAG.getVectorIdxConstant(j, dl));
6179 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6183 return DAG.getBuildVector(NOutVT, dl,
Ops);
6186SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6187 EVT VT =
N->getValueType(0);
6188 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6189 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6197 if (getTypeAction(
N->getOperand(0).getValueType())
6201 switch(
N->getOpcode()) {
6203 Promoted = SExtPromotedInteger(
N->getOperand(0));
6206 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6209 Promoted = GetPromotedInteger(
N->getOperand(0));
6221 DAG.getVectorIdxConstant(0, dl));
6223 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6227 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6230SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6231 EVT VT =
N->getValueType(0);
6232 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6236SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6237 EVT VT =
N->getValueType(0);
6238 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6242SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6244 EVT VT =
N->getValueType(0);
6245 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6246 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6247 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6251SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6252 EVT OutVT =
N->getValueType(0);
6253 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6254 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6259 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6262 NOutVTElem,
N->getOperand(1));
6264 V0, ConvElem,
N->getOperand(2));
6271 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6272 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6280 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6281 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6282 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6286 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6289 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6290 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6298 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6303SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6306 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6308 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6309 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6310 return DAG.getPOISON(NVT);
6313SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6315 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6316 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6317 TLI.getVectorIdxTy(DAG.getDataLayout()));
6324 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6327SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6332 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6337 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6339 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6351 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1), V1);
6352 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6355SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6357 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6365SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6368 EVT ResVT =
N->getValueType(0);
6369 unsigned NumElems =
N->getNumOperands();
6372 SDValue ResVec = DAG.getUNDEF(ResVT);
6376 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6378 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6390 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6391 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6395 for (
unsigned i=0; i<NumElem; ++i) {
6398 DAG.getVectorIdxConstant(i, dl));
6404 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6407SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6420 for (
unsigned I = 0;
I < OpNo;
I++)
6423 EVT Ty =
Op.getValueType();
6424 SDLoc
DL = SDLoc(
N);
6427 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6435 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6440 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6446SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6459 for (
unsigned I = 0;
I < OpNo;
I++)
6462 EVT Ty =
Op.getValueType();
6463 SDLoc
DL = SDLoc(
N);
6466 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6474 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6479 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.
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.
@ 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.
@ 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.
@ 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],...
@ 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.
@ VECTOR_SPLICE
VECTOR_SPLICE(VEC1, VEC2, IMM) - Returns a subvector of the same type as VEC1/VEC2 from CONCAT_VECTOR...
@ 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.
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 changeVectorElementType(EVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
static LLVM_ABI MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT)
MakeLibCallOptions & setIsSigned(bool Value=true)