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();
1281 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1287 "Tried to saturate to more than the original type?");
1296 SDValue Op1Promoted, Op2Promoted;
1302 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1303 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1305 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1306 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1309 unsigned Scale =
N->getConstantOperandVal(2);
1313 if (TLI.isTypeLegal(PromotedType)) {
1315 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1318 N->getValueType(0).getScalarSizeInBits();
1322 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1323 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1324 Op2Promoted,
N->getOperand(2));
1327 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1333 if (
SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1334 Op2Promoted, Scale, DAG)) {
1337 N->getValueType(0).getScalarSizeInBits(),
1345 N->getValueType(0).getScalarSizeInBits());
1348SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1350 return PromoteIntRes_Overflow(
N);
1354 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1355 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1356 EVT OVT =
N->getOperand(0).getValueType();
1357 EVT NVT =
LHS.getValueType();
1367 DAG.getValueType(OVT));
1369 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1372 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1378 EVT PromotedResultTy =
1379 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1380 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1381 N->getOperand(0),
N->getOperand(1));
1387 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1388 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1390 unsigned Opcode =
N->getOpcode();
1391 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1392 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1394 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1398 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1399 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1401 LHS.getValueType(),
N->getOperand(0),
1402 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1407 EVT InVT =
N->getOperand(OpNo).getValueType();
1408 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1410 EVT SVT = getSetCCResultType(InVT);
1417 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1418 SVT = getSetCCResultType(InVT);
1426 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1427 "Vector compare must return a vector result!");
1431 if (
N->isStrictFPOpcode()) {
1432 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1433 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1434 N->getOperand(2),
N->getOperand(3)};
1435 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1440 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1441 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1444 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1451 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1456 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1457 EVT VT =
N->getValueType(0);
1461 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1463 ReplaceValueWith(
SDValue(
N, 0), Res);
1468 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1470 if (
N->getOpcode() != ISD::VP_SHL) {
1472 RHS = ZExtPromotedInteger(
RHS);
1474 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1480 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1481 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1485SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1486 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1488 Op.getValueType(),
Op,
N->getOperand(1));
1491SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1495 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1496 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1497 if (
N->getNumOperands() == 2)
1498 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1499 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1500 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1501 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1502 N->getOperand(2),
N->getOperand(3));
1506 if (
N->getNumOperands() == 2) {
1508 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1509 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1510 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1512 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1513 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1517 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1518 SDValue RHS = VPSExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1519 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1524 if (
N->getNumOperands() == 2) {
1526 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1527 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1528 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1530 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1531 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1535 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1536 SDValue RHS = VPZExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1537 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1547 SExtOrZExtPromotedOperands(
LHS,
RHS);
1549 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1555 if (
N->getOpcode() != ISD::VP_SRA) {
1557 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1559 RHS = ZExtPromotedInteger(
RHS);
1560 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1566 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1568 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1569 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1575 if (
N->getOpcode() != ISD::VP_SRL) {
1577 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1579 RHS = ZExtPromotedInteger(
RHS);
1580 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1586 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1588 RHS = VPZExtPromotedInteger(
RHS, Mask, EVL);
1589 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1595 SDValue Res = TLI.expandROT(
N,
true , DAG);
1596 ReplaceValueWith(
SDValue(
N, 0), Res);
1601 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1602 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1605 Amt = ZExtPromotedInteger(Amt);
1609 EVT OldVT =
N->getOperand(0).getValueType();
1610 EVT VT =
Lo.getValueType();
1611 unsigned Opcode =
N->getOpcode();
1618 DAG.getConstant(OldBits,
DL, AmtVT));
1626 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1627 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1629 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1639 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1645 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1647 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1651SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1652 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1653 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1658 Amt = VPZExtPromotedInteger(Amt, Mask, EVL);
1662 EVT OldVT =
N->getOperand(0).getValueType();
1663 EVT VT =
Lo.getValueType();
1664 unsigned Opcode =
N->getOpcode();
1665 bool IsFSHR = Opcode == ISD::VP_FSHR;
1670 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1671 DAG.getConstant(OldBits,
DL, AmtVT), Mask, EVL);
1679 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1680 SDValue HiShift = DAG.getConstant(OldBits,
DL, VT);
1681 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1682 Lo = DAG.getVPZeroExtendInReg(
Lo, Mask, EVL,
DL, OldVT);
1684 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1687 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1692 SDValue ShiftOffset = DAG.getConstant(NewBits - OldBits,
DL, AmtVT);
1693 Lo = DAG.getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1698 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1700 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt, Mask, EVL);
1704 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1716 Res = GetPromotedInteger(InOp);
1723 "Dst and Src must have the same number of elements");
1725 "Promoted vector type must be a power of two");
1728 GetSplitVector(InOp, EOp1, EOp2);
1736 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1737 "Expected VP_TRUNCATE opcode");
1738 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1739 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1740 std::tie(EVLLo, EVLHi) =
1741 DAG.SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1742 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1743 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1750 SDValue WideInOp = GetWidenedVector(InOp);
1755 N->getValueType(0).getScalarType(), NumElem);
1764 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1770 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1771 return DAG.getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1776SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1778 return PromoteIntRes_Overflow(
N);
1782 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1783 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1784 EVT OVT =
N->getOperand(0).getValueType();
1785 EVT NVT =
LHS.getValueType();
1794 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1796 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1799 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1810 return PromoteIntRes_Overflow(
N);
1822 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1823 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1825 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1828 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1839 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1840 return PromoteIntRes_Overflow(
N);
1844 EVT OVT =
N->getValueType(0);
1845 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1851 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1852 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1853 if (
SDValue Res = TLI.expandABS(
N, DAG))
1857 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1861SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1864 return PromoteIntRes_Overflow(
N);
1868 EVT SmallVT =
LHS.getValueType();
1875 LHS = SExtPromotedInteger(
LHS);
1876 RHS = SExtPromotedInteger(
RHS);
1878 LHS = ZExtPromotedInteger(
LHS);
1879 RHS = ZExtPromotedInteger(
RHS);
1881 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1893 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1894 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1895 DAG.getConstant(0,
DL,
Hi.getValueType()),
1900 Mul, DAG.getValueType(SmallVT));
1910 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1915 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1916 N->getValueType(0)));
1920 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1922 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1929 EVT VT =
N->getValueType(0);
1932 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1933 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1937 for (
unsigned i = 0; i < NumRegs; ++i) {
1938 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
1939 N->getConstantOperandVal(3));
1944 if (DAG.getDataLayout().isBigEndian())
1945 std::reverse(Parts.begin(), Parts.end());
1948 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1950 for (
unsigned i = 1; i < NumRegs; ++i) {
1955 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1961 ReplaceValueWith(
SDValue(
N, 1), Chain);
1974bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
1977 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
1982 switch (
N->getOpcode()) {
1985 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
1986 N->dump(&DAG);
dbgs() <<
"\n";
1995 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
1996 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2002 Res = PromoteIntOp_FAKE_USE(
N);
2005 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2009 Res = PromoteIntOp_ScalarOp(
N);
2012 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2015 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2017 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
2018 case ISD::VP_SINT_TO_FP:
2035 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2037 case ISD::VP_TRUNCATE:
2041 case ISD::VP_UINT_TO_FP:
2046 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2057 Res = PromoteIntOp_Shift(
N);
2061 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2064 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2090 case ISD::VP_REDUCE_ADD:
2091 case ISD::VP_REDUCE_MUL:
2092 case ISD::VP_REDUCE_AND:
2093 case ISD::VP_REDUCE_OR:
2094 case ISD::VP_REDUCE_XOR:
2095 case ISD::VP_REDUCE_SMAX:
2096 case ISD::VP_REDUCE_SMIN:
2097 case ISD::VP_REDUCE_UMAX:
2098 case ISD::VP_REDUCE_UMIN:
2099 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2104 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2107 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2110 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2112 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2113 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2114 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2116 case ISD::EXPERIMENTAL_VP_SPLICE:
2117 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2120 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2123 Res = PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
N, OpNo);
2126 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2131 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2136 if (!Res.
getNode())
return false;
2143 const bool IsStrictFp =
N->isStrictFPOpcode();
2145 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2146 "Invalid operand expansion");
2150 ReplaceValueWith(
SDValue(
N, 0), Res);
2164 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2168 unsigned OpLEffectiveBits =
2169 DAG.computeKnownBits(OpL).countMaxActiveBits();
2170 unsigned OpREffectiveBits =
2171 DAG.computeKnownBits(OpR).countMaxActiveBits();
2172 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2173 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2180 LHS = SExtPromotedInteger(
LHS);
2181 RHS = SExtPromotedInteger(
RHS);
2190 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2191 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2192 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2193 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2200 LHS = ZExtPromotedInteger(
LHS);
2201 RHS = ZExtPromotedInteger(
RHS);
2215 LHS = SExtPromotedInteger(
LHS);
2216 RHS = SExtPromotedInteger(
RHS);
2221 "Unknown integer comparison!");
2223 SExtOrZExtPromotedOperands(
LHS,
RHS);
2227 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2232 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2233 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2234 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2238 EVT OutVT =
N->getValueType(0);
2241 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2244 switch (getTypeAction(InVT)) {
2248 DAG.getDataLayout().isLittleEndian()) {
2258 if (isTypeLegal(WideVecVT)) {
2259 SDValue Promoted = GetPromotedInteger(InOp);
2262 DAG.getVectorIdxConstant(0, dl));
2275 return CreateStackStoreLoad(InOp, OutVT);
2278SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2279 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2287 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2288 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2292SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2293 assert(OpNo == 1 &&
"only know how to promote condition");
2296 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2299 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2300 N->getOperand(2)), 0);
2305 EVT OVT =
N->getOperand(0).getValueType();
2306 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2307 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2308 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2313 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2314 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2323 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2324 "Legal vector of one illegal element?");
2329 assert(
N->getOperand(0).getValueSizeInBits() >=
2330 N->getValueType(0).getScalarSizeInBits() &&
2331 "Type of inserted value narrower than vector element type!");
2334 for (
unsigned i = 0; i < NumElts; ++i)
2335 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2337 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2340SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2347 assert(
N->getOperand(1).getValueSizeInBits() >=
2348 N->getValueType(0).getScalarSizeInBits() &&
2349 "Type of inserted value narrower than vector element type!");
2350 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2351 GetPromotedInteger(
N->getOperand(1)),
2356 assert(OpNo == 2 &&
"Different operand and result vector types?");
2359 SDValue Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2360 TLI.getVectorIdxTy(DAG.getDataLayout()));
2361 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2362 N->getOperand(1), Idx), 0);
2366 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2370 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2373SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2374 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2376 EVT OpTy =
N->getOperand(1).getValueType();
2379 if (
SDValue Res = WidenVSELECTMask(
N))
2380 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2381 Res,
N->getOperand(1),
N->getOperand(2));
2385 Cond = PromoteTargetBoolean(
Cond, OpVT);
2387 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2388 N->getOperand(2)), 0);
2391SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2392 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2400 N->getOperand(3),
N->getOperand(4)), 0);
2403SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2404 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2412 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2414 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2417 N->getOperand(3),
N->getOperand(4)),
2422 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2423 ZExtPromotedInteger(
N->getOperand(1))), 0);
2431 LHS = SExtPromotedInteger(
LHS);
2432 RHS = SExtPromotedInteger(
RHS);
2434 SExtOrZExtPromotedOperands(
LHS,
RHS);
2441 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2442 ZExtPromotedInteger(
N->getOperand(2))), 0);
2446 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2450 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2453SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2455 EVT VT =
N->getValueType(0);
2456 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2458 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2462 SDValue ShAmt = DAG.getShiftAmountConstant(Diff, VT, dl);
2466 return DAG.getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2471 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2472 return SDValue(DAG.UpdateNodeOperands(
N,
2473 SExtPromotedInteger(
N->getOperand(0)),
2474 N->getOperand(1),
N->getOperand(2)),
2476 return SDValue(DAG.UpdateNodeOperands(
N,
2477 SExtPromotedInteger(
N->getOperand(0))), 0);
2480SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2481 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2482 SExtPromotedInteger(
N->getOperand(1))), 0);
2487 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2490 SDValue Val = GetPromotedInteger(
N->getValue());
2493 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2494 N->getMemoryVT(),
N->getMemOperand());
2500 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2501 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2503 SDValue DataOp = GetPromotedInteger(
N->getValue());
2504 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2505 N->getMask(),
N->getVectorLength(),
2506 N->getMemoryVT(),
N->getMemOperand(),
2507 N->isCompressingStore());
2518 Mask = PromoteTargetBoolean(Mask, DataVT);
2521 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2524 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2525 DataOp = GetPromotedInteger(DataOp);
2527 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2528 N->getOffset(), Mask,
N->getMemoryVT(),
2529 N->getMemOperand(),
N->getAddressingMode(),
2530 true,
N->isCompressingStore());
2535 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2536 EVT DataVT =
N->getValueType(0);
2537 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2539 NewOps[OpNo] =
Mask;
2540 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2556 EVT DataVT =
N->getValueType(0);
2557 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2558 }
else if (OpNo == 4) {
2560 if (
N->isIndexSigned())
2562 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2564 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2566 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2568 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2580 bool TruncateStore =
N->isTruncatingStore();
2585 EVT DataVT =
N->getValue().getValueType();
2586 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2587 }
else if (OpNo == 4) {
2589 if (
N->isIndexSigned())
2591 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2593 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2595 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2596 TruncateStore =
true;
2599 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2600 SDLoc(
N), NewOps,
N->getMemOperand(),
2601 N->getIndexType(), TruncateStore);
2606 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2610 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2615 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2616 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2617 return DAG.getNode(ISD::VP_TRUNCATE, SDLoc(
N),
N->getValueType(0),
Op,
2618 N->getOperand(1),
N->getOperand(2));
2623 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2624 return SDValue(DAG.UpdateNodeOperands(
N,
2625 ZExtPromotedInteger(
N->getOperand(0)),
2626 N->getOperand(1),
N->getOperand(2)),
2628 return SDValue(DAG.UpdateNodeOperands(
N,
2629 ZExtPromotedInteger(
N->getOperand(0))), 0);
2632SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2633 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2634 ZExtPromotedInteger(
N->getOperand(1))), 0);
2641 EVT VT =
N->getValueType(0);
2646 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2647 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2648 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2649 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2654 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2657SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2659 EVT VT =
N->getValueType(0);
2660 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2662 Op = DAG.getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2664 return DAG.getVPZeroExtendInReg(
Op,
N->getOperand(1),
N->getOperand(2), dl,
2665 N->getOperand(0).getValueType());
2669 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2671 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2674SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2676 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2677 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2686 unsigned OpOffset = IsStrict ? 1 : 0;
2693 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
2694 if (LCImpl == RTLIB::Unsupported) {
2700 if (IsPowI &&
N->getValueType(0).isVector())
2701 return DAG.UnrollVectorOp(
N);
2703 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2704 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2714 assert(DAG.getLibInfo().getIntSize() ==
2715 N->getOperand(1 + OpOffset).getValueType().getSizeInBits() &&
2716 "POWI exponent should match with sizeof(int) when doing the libcall.");
2717 TargetLowering::MakeLibCallOptions CallOptions;
2719 SDValue Ops[2] = {
N->getOperand(0 + OpOffset),
N->getOperand(1 + OpOffset)};
2720 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2721 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2722 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2724 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2729 switch (
N->getOpcode()) {
2737 case ISD::VP_REDUCE_ADD:
2738 case ISD::VP_REDUCE_MUL:
2739 case ISD::VP_REDUCE_AND:
2740 case ISD::VP_REDUCE_OR:
2741 case ISD::VP_REDUCE_XOR:
2745 case ISD::VP_REDUCE_SMAX:
2746 case ISD::VP_REDUCE_SMIN:
2750 case ISD::VP_REDUCE_UMAX:
2751 case ISD::VP_REDUCE_UMIN:
2761 return GetPromotedInteger(V);
2763 return SExtPromotedInteger(V);
2765 return ZExtPromotedInteger(V);
2771 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2773 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2774 EVT InVT =
Op.getValueType();
2776 EVT ResVT =
N->getValueType(0);
2777 unsigned Opcode =
N->getOpcode();
2794 switch (TLI.getBooleanContents(InVT)) {
2797 Op = ZExtPromotedInteger(
N->getOperand(0));
2800 Op = SExtPromotedInteger(
N->getOperand(0));
2813 switch (TLI.getBooleanContents(InVT)) {
2816 Op = ZExtPromotedInteger(
N->getOperand(0));
2819 Op = SExtPromotedInteger(
N->getOperand(0));
2825 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2829 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2833SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2840 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2841 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2844 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2846 Op = PromoteIntOpVectorReduction(
N,
Op);
2850 EVT VT =
N->getValueType(0);
2851 EVT EltVT =
Op.getValueType().getScalarType();
2854 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2866 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2867 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2870SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2873 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2874 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2877SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2880 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2881 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2886 const Function &Fn = DAG.getMachineFunction().getFunction();
2888 "cannot use llvm.write_register with illegal type", Fn,
2890 return N->getOperand(0);
2893SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2894 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2895 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2898 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2900 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2903SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2907 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2908 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2911 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2913 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2914 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2917SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2919 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2921 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2922 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2925SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N,
2928 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2929 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2932SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
2934 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
2935 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2936 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2939SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
2941 switch (
N->getOpcode()) {
2943 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2944 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
2947 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
2948 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2951 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
2952 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
2957 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2968void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
2974 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
2977 switch (
N->getOpcode()) {
2980 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
2981 N->dump(&DAG);
dbgs() <<
"\n";
3058 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3059 SplitInteger(Tmp.first,
Lo,
Hi);
3060 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
3065 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3066 SDValue Tmp = DAG.getAtomicCmpSwap(
3068 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3077 SplitInteger(Tmp,
Lo,
Hi);
3156 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3161 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3165 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3169 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3179std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3180 unsigned Opc =
Node->getOpcode();
3186 EVT RetVT =
Node->getValueType(0);
3187 TargetLowering::MakeLibCallOptions CallOptions;
3190 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
3191 if (LCImpl != RTLIB::Unsupported) {
3193 Ops.push_back(
Node->getOperand(1));
3196 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3197 "Unexpected atomic op or value type!");
3199 LCImpl = TLI.getLibcallImpl(LC);
3201 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3202 Node->getOperand(0));
3207void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3212 GetExpandedInteger(
N->getOperand(0), InL, InH);
3227 if (Amt.
uge(VTBits)) {
3228 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3229 }
else if (Amt.
ugt(NVTBits)) {
3230 Lo = DAG.getConstant(0,
DL, NVT);
3232 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3233 }
else if (Amt == NVTBits) {
3234 Lo = DAG.getConstant(0,
DL, NVT);
3238 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3242 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3244 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3250 if (Amt.
uge(VTBits)) {
3251 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3252 }
else if (Amt.
ugt(NVTBits)) {
3254 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3255 Hi = DAG.getConstant(0,
DL, NVT);
3256 }
else if (Amt == NVTBits) {
3258 Hi = DAG.getConstant(0,
DL, NVT);
3263 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3265 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3267 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3273 if (Amt.
uge(VTBits)) {
3275 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3276 }
else if (Amt.
ugt(NVTBits)) {
3278 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3280 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3281 }
else if (Amt == NVTBits) {
3284 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3289 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3291 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3293 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3301bool DAGTypeLegalizer::
3303 unsigned Opc =
N->getOpcode();
3306 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3311 "Expanded integer type size not a power of two!");
3315 KnownBits Known = DAG.computeKnownBits(Amt);
3318 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3323 GetExpandedInteger(In, InL, InH);
3330 DAG.getConstant(~HighBitMask, dl, ShTy));
3335 Lo = DAG.getConstant(0, dl, NVT);
3336 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3339 Hi = DAG.getConstant(0, dl, NVT);
3340 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3344 DAG.getConstant(NVTBits - 1, dl, ShTy));
3345 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3357 DAG.getConstant(NVTBits - 1, dl, ShTy));
3373 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3375 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3377 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3378 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3390bool DAGTypeLegalizer::
3393 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3397 "Expanded integer type size not a power of two!");
3402 GetExpandedInteger(
N->getOperand(0), InL, InH);
3404 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3407 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3410 Amt, DAG.getConstant(0, dl, ShTy),
3414 switch (
N->getOpcode()) {
3420 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3421 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3424 LoL = DAG.getConstant(0, dl, NVT);
3427 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3428 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3429 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3435 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3438 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3441 HiL = DAG.getConstant(0, dl, NVT);
3444 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3445 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3446 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3452 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3453 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3457 DAG.getConstant(NVTBits - 1, dl, ShTy));
3460 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3461 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3462 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3487 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3492 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3493 SplitInteger(Res,
Lo,
Hi);
3496void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3505 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3506 unsigned NumHalfBits = NumBits / 2;
3507 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3508 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3509 SDValue LHSL, LHSH, RHSL, RHSH;
3510 GetExpandedInteger(
LHS, LHSL, LHSH);
3511 GetExpandedInteger(
RHS, RHSL, RHSH);
3514 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3516 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3524 SDValue LHSL, LHSH, RHSL, RHSH;
3525 GetExpandedInteger(
LHS, LHSL, LHSH);
3526 GetExpandedInteger(
RHS, RHSL, RHSH);
3528 EVT CCT = getSetCCResultType(NVT);
3531 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3533 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3535 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3537 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3541 const APInt *RHSVal =
nullptr;
3543 RHSVal = &RHSConst->getAPIntValue();
3550 SDValue LHSL, LHSH, RHSL, RHSH;
3551 GetExpandedInteger(
LHS, LHSL, LHSH);
3552 GetExpandedInteger(
RHS, RHSL, RHSH);
3554 EVT CCT = getSetCCResultType(NVT);
3560 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3563 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3567 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3570 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3572 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3579 switch (
N->getOpcode()) {
3606 EVT VT =
N->getValueType(0);
3607 EVT CCT = getSetCCResultType(VT);
3610 SplitInteger(Result,
Lo,
Hi);
3614 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3615 SplitInteger(ExpandedCMP,
Lo,
Hi);
3618void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3622 SDValue LHSL, LHSH, RHSL, RHSH;
3623 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3624 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3627 SDValue LoOps[2] = { LHSL, RHSL };
3628 SDValue HiOps[3] = { LHSH, RHSH };
3630 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3632 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3634 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3638 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3644 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3657 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3659 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3662 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3676 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3678 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3682 EVT OvfVT = getSetCCResultType(NVT);
3683 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3698 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3701 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3705 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3717 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3721 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3724 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3727 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3732 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3734 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3735 DAG.getConstant(0, dl, NVT));
3738 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3747 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3752 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3754 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3755 DAG.getConstant(0, dl, NVT));
3761void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3764 SDValue LHSL, LHSH, RHSL, RHSH;
3766 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3767 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3768 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3769 SDValue LoOps[2] = { LHSL, RHSL };
3770 SDValue HiOps[3] = { LHSH, RHSH };
3784 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3787void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3790 SDValue LHSL, LHSH, RHSL, RHSH;
3792 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3793 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3794 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3796 SDValue HiOps[3] = { LHSH, RHSH };
3798 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3800 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3804 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3807void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3815 unsigned CarryOp, NoCarryOp;
3817 switch(
N->getOpcode()) {
3832 bool HasCarryOp = TLI.isOperationLegalOrCustom(
3833 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
3837 SDValue LHSL, LHSH, RHSL, RHSH;
3838 GetExpandedInteger(
LHS, LHSL, LHSH);
3839 GetExpandedInteger(
RHS, RHSL, RHSH);
3840 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3841 SDValue LoOps[2] = { LHSL, RHSL };
3842 SDValue HiOps[3] = { LHSH, RHSH };
3844 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3846 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3853 SplitInteger(Sum,
Lo,
Hi);
3859 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
3860 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
3864 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
3869 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
3875 ReplaceValueWith(
SDValue(
N, 1), Ovf);
3881 SDValue LHSL, LHSH, RHSL, RHSH;
3883 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3884 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3885 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3889 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3891 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3895 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3898void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
3901 SDValue LHSL, LHSH, RHSL, RHSH;
3903 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3904 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3905 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
3910 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
3911 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
3915 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3918void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
3920 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3923 if (
Op.getValueType().bitsLE(NVT)) {
3926 Hi = DAG.getUNDEF(NVT);
3930 assert(getTypeAction(
Op.getValueType()) ==
3932 "Only know how to promote this result!");
3935 "Operand over promoted?");
3937 SplitInteger(Res,
Lo,
Hi);
3941void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
3944 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3945 EVT NVT =
Lo.getValueType();
3950 if (NVTBits < EVTBits) {
3953 EVTBits - NVTBits)));
3958 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
3962void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
3965 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3966 EVT NVT =
Lo.getValueType();
3971 if (NVTBits < EVTBits) {
3974 EVTBits - NVTBits)));
3978 Hi = DAG.getConstant(0, dl, NVT);
3982void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
3985 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
3990void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
3993 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4002 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4003 EVT NVT =
Lo.getValueType();
4006 Hi = DAG.getConstant(0, dl, NVT);
4009void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4011 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4014 const APInt &Cst =
Constant->getAPIntValue();
4015 bool IsTarget =
Constant->isTargetOpcode();
4016 bool IsOpaque =
Constant->isOpaque();
4018 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4019 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4027 GetExpandedInteger(N0,
Lo,
Hi);
4028 EVT NVT =
Lo.getValueType();
4034 Hi = DAG.getConstant(0, dl, NVT);
4044 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4049 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4050 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4059 EVT VT =
N->getValueType(0);
4061 DAG.getConstant(0, dl, VT), N0);
4063 SplitInteger(Neg, NegLo, NegHi);
4065 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4067 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4068 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4071void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4075 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4076 EVT NVT =
Lo.getValueType();
4078 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4081 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4084 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4085 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4088 Hi = DAG.getConstant(0, dl, NVT);
4093 SplitInteger(Result,
Lo,
Hi);
4098 EVT VT =
N->getValueType(0);
4103 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4104 "LibCall explicitly requested, but not available");
4106 if (RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC)) {
4107 TargetLowering::MakeLibCallOptions CallOptions;
4111 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4112 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4120 GetExpandedInteger(
Op,
Lo,
Hi);
4121 EVT NVT =
Lo.getValueType();
4124 Hi = DAG.getConstant(0,
DL, NVT);
4127void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4131 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4132 EVT NVT =
Lo.getValueType();
4134 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4140 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4141 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4144 Hi = DAG.getConstant(0, dl, NVT);
4150 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4157 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4161 ReplaceValueWith(
SDValue(
N, 1), Chain);
4169 Chain =
Op.getValue(1);
4178 EVT VT =
N->getValueType(0);
4182 bool IsStrict =
N->isStrictFPOpcode();
4184 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4186 Op = GetPromotedFloat(
Op);
4190 Op.getValueType() == MVT::bf16) {
4196 EVT OpVT =
Op.getValueType();
4200 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4201 TargetLowering::MakeLibCallOptions CallOptions;
4206 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4207 CallOptions, dl, Chain);
4208 SplitInteger(Tmp.first,
Lo,
Hi);
4211 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4216 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4217 SplitInteger(Res,
Lo,
Hi);
4223 bool IsStrict =
N->isStrictFPOpcode();
4224 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4228 "Input type needs to be promoted!");
4230 EVT VT =
Op.getValueType();
4232 if (VT == MVT::f16) {
4238 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4242 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4246 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4250 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4254 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4258 EVT RetVT =
N->getValueType(0);
4260 TargetLowering::MakeLibCallOptions CallOptions;
4262 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT,
4263 Op, CallOptions, dl,
4265 SplitInteger(Tmp.first,
Lo,
Hi);
4267 if (
N->isStrictFPOpcode())
4268 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4271void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4273 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4276 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4282 EVT VT =
N->getValueType(0);
4283 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4288 AAMDNodes AAInfo =
N->getAAInfo();
4293 if (
N->getMemoryVT().bitsLE(NVT)) {
4294 EVT MemVT =
N->getMemoryVT();
4296 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4297 N->getBaseAlign(), MMOFlags, AAInfo);
4305 unsigned LoSize =
Lo.getValueSizeInBits();
4307 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4310 Hi = DAG.getConstant(0, dl, NVT);
4314 Hi = DAG.getUNDEF(NVT);
4316 }
else if (DAG.getDataLayout().isLittleEndian()) {
4318 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4321 unsigned ExcessBits =
4328 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4329 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4330 N->getBaseAlign(), MMOFlags, AAInfo);
4339 EVT MemVT =
N->getMemoryVT();
4342 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4345 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4348 N->getBaseAlign(), MMOFlags, AAInfo);
4354 N->getPointerInfo().getWithOffset(IncrementSize),
4356 N->getBaseAlign(), MMOFlags, AAInfo);
4368 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4372 DAG.getShiftAmountConstant(
4379 ReplaceValueWith(
SDValue(
N, 1), Ch);
4382void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4386 GetExpandedInteger(
N->getOperand(0), LL, LH);
4387 GetExpandedInteger(
N->getOperand(1), RL, RH);
4391 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4393 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4394 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4397void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4399 EVT VT =
N->getValueType(0);
4400 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4404 GetExpandedInteger(
N->getOperand(0), LL, LH);
4405 GetExpandedInteger(
N->getOperand(1), RL, RH);
4407 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4414 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
4415 if (LCImpl == RTLIB::Unsupported) {
4418 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4424 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4425 TargetLowering::MakeLibCallOptions CallOptions;
4427 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4434 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4435 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4436 SDValue R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4439 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4444 SplitInteger(Result,
Lo,
Hi);
4450 SplitInteger(Result,
Lo,
Hi);
4456 SplitInteger(Result,
Lo,
Hi);
4467 EVT VT =
N->getValueType(0);
4471 uint64_t Scale =
N->getConstantOperandVal(2);
4483 EVT BoolVT = getSetCCResultType(VT);
4485 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4491 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4492 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4498 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4499 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4504 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4505 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4508 SplitInteger(Result,
Lo,
Hi);
4514 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4516 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4518 GetExpandedInteger(
LHS, LL, LH);
4519 GetExpandedInteger(
RHS, RL, RH);
4523 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4530 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4531 SplitInteger(LoTmp, Result[0], Result[1]);
4532 SplitInteger(HiTmp, Result[2], Result[3]);
4534 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4537 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4538 "the size of the current value type");
4559 uint64_t Part0 = Scale / NVTSize;
4560 if (Scale % NVTSize) {
4561 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4564 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4576 if (Scale == VTSize)
4595 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4596 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4597 EVT BoolNVT = getSetCCResultType(NVT);
4600 if (Scale < NVTSize) {
4603 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4604 DAG.getShiftAmountConstant(Scale, NVT, dl));
4605 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4606 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4607 }
else if (Scale == NVTSize) {
4609 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4610 }
else if (Scale < VTSize) {
4614 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4615 SatMax = DAG.getSetCC(dl, BoolNVT, HLAdjusted, NVTZero,
ISD::SETNE);
4618 "(and saturation can't happen with Scale==VTSize).");
4620 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4621 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4625 if (Scale < NVTSize) {
4630 unsigned OverflowBits = VTSize - Scale + 1;
4631 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4632 "Extent of overflow bits must start within HL");
4633 SDValue HLHiMask = DAG.getConstant(
4635 SDValue HLLoMask = DAG.getConstant(
4642 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4648 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4649 }
else if (Scale == NVTSize) {
4655 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4661 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4662 }
else if (Scale < VTSize) {
4665 unsigned OverflowBits = VTSize - Scale + 1;
4666 SDValue HHHiMask = DAG.getConstant(
4668 SDValue HHLoMask = DAG.getConstant(
4670 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4671 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4678 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4679 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4682 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4683 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4690 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4692 N->getConstantOperandVal(2), DAG);
4696 N->getConstantOperandVal(2), TLI, DAG);
4697 SplitInteger(Res,
Lo,
Hi);
4700void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4703 "Node has unexpected Opcode");
4713 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4714 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4718 SDValue LHSL, LHSH, RHSL, RHSH;
4719 GetExpandedInteger(
LHS, LHSL, LHSH);
4720 GetExpandedInteger(
RHS, RHSL, RHSH);
4721 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4724 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4733 SplitInteger(Sum,
Lo,
Hi);
4758 EVT VT =
LHS.getValueType();
4761 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
4765 EVT OType =
Node->getValueType(1);
4766 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
4770 ReplaceValueWith(
SDValue(Node, 1), Ovf);
4773void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4775 EVT VT =
N->getValueType(0);
4777 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4786 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4788 TargetLowering::MakeLibCallOptions CallOptions;
4790 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
4793void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4796 SDValue Shiftee =
N->getOperand(0);
4803 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
4804 }
while (!TLI.isTypeLegal(LoadVT));
4809 "Shifting unit is not a a power of two!");
4811 const bool IsOneStepShift =
4812 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
4817 if (!IsOneStepShift)
4818 ShAmt = DAG.getFreeze(ShAmt);
4821 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4822 unsigned VTByteWidth = VTBitWidth / 8;
4824 "Shiftee type size is not a power of two!");
4825 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4826 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4831 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
4833 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
4834 EVT PtrTy =
StackPtr.getValueType();
4835 SDValue Ch = DAG.getEntryNode();
4838 DAG.getMachineFunction(),
4844 unsigned WideningOpc =
4846 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
4849 SDValue AllZeros = DAG.getConstant(0, dl, VT);
4853 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
4859 Flags.setExact(IsOneStepShift);
4862 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
4864 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
4865 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
4868 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
4873 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
4880 if (DAG.getDataLayout().isBigEndian())
4881 WillIndexUpwards = !WillIndexUpwards;
4884 if (WillIndexUpwards) {
4887 AdjStackPtr = DAG.getMemBasePlusOffset(
4888 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
4889 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
4893 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
4894 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
4898 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
4903 if (!IsOneStepShift) {
4905 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
4906 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
4907 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
4911 SplitInteger(Res,
Lo,
Hi);
4914void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
4916 EVT VT =
N->getValueType(0);
4917 unsigned Opc =
N->getOpcode();
4923 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
4927 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
4944 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4946 const bool LegalOrCustom =
4950 unsigned ExpansionFactor = 1;
4952 for (EVT TmpVT = NVT;;) {
4953 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
4954 if (NewTMPVT == TmpVT)
4961 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
4964 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
4966 if (LegalOrCustom &&
4970 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4976 SDValue ShiftOp =
N->getOperand(1);
4977 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
4979 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
4982 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
4983 Hi =
Lo.getValue(1);
4988 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5002 if (RTLIB::LibcallImpl LibcallImpl = TLI.getLibcallImpl(LC)) {
5005 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5007 TargetLowering::MakeLibCallOptions CallOptions;
5010 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5015 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5019void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5021 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5024 if (
Op.getValueType().bitsLE(NVT)) {
5030 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5034 assert(getTypeAction(
Op.getValueType()) ==
5036 "Only know how to promote this result!");
5039 "Operand over promoted?");
5041 SplitInteger(Res,
Lo,
Hi);
5049void DAGTypeLegalizer::
5052 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5055 if (EVT.
bitsLE(
Lo.getValueType())) {
5063 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5064 Hi.getValueType(), dl));
5075void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5077 EVT VT =
N->getValueType(0);
5079 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5088 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5090 TargetLowering::MakeLibCallOptions CallOptions;
5092 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5095void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5097 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5107void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5109 EVT VT =
N->getValueType(0);
5128 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5129 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5130 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5132 EVT BitVT =
N->getValueType(1);
5133 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5135 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5137 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5138 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5157 SplitInteger(Three,
Lo,
Hi);
5161 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5166 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5171 RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
5175 if (LCImpl == RTLIB::Unsupported ||
5176 TLI.getLibcallImplName(LCImpl) == DAG.getMachineFunction().getName()) {
5179 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5180 N->getOperand(1), MulLo, MulHi);
5185 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5186 SplitInteger(MulLo,
Lo,
Hi);
5187 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5191 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5194 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5195 MachinePointerInfo());
5199 EVT ArgVT =
Op.getValueType();
5201 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5202 Entry.IsSExt =
true;
5203 Entry.IsZExt =
false;
5204 Args.push_back(Entry);
5208 TargetLowering::ArgListEntry
Entry(
5210 Entry.IsSExt =
true;
5211 Entry.IsZExt =
false;
5212 Args.push_back(Entry);
5214 SDValue Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5216 TargetLowering::CallLoweringInfo CLI(DAG);
5219 .setLibCallee(TLI.getLibcallImplCallingConv(LCImpl), RetTy, Func,
5223 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5225 SplitInteger(CallInfo.first,
Lo,
Hi);
5227 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5228 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5229 DAG.getConstant(0, dl, PtrVT),
5232 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5235void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5237 EVT VT =
N->getValueType(0);
5239 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5249 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5251 if (isTypeLegal(NVT)) {
5253 GetExpandedInteger(
N->getOperand(0), InL, InH);
5255 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5264 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5266 TargetLowering::MakeLibCallOptions CallOptions;
5267 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5270void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5272 EVT VT =
N->getValueType(0);
5274 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5284 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5286 if (isTypeLegal(NVT)) {
5288 GetExpandedInteger(
N->getOperand(0), InL, InH);
5290 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5299 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5301 TargetLowering::MakeLibCallOptions CallOptions;
5302 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5305void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5307 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5310 if (
Op.getValueType().bitsLE(NVT)) {
5313 Hi = DAG.getConstant(0, dl, NVT);
5317 assert(getTypeAction(
Op.getValueType()) ==
5319 "Only know how to promote this result!");
5322 "Operand over promoted?");
5324 SplitInteger(Res,
Lo,
Hi);
5326 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5332void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5336 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5338 SDValue Swap = DAG.getAtomicCmpSwap(
5347void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5351 SDValue Res = TLI.expandVecReduce(
N, DAG);
5352 SplitInteger(Res,
Lo,
Hi);
5355void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5361 N->getOperand(0),
N->getOperand(1));
5362 SplitInteger(Res,
Lo,
Hi);
5369 GetExpandedInteger(
N->getOperand(0), In3, In4);
5370 GetExpandedInteger(
N->getOperand(1), In1, In2);
5374 unsigned Opc =
N->getOpcode();
5377 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5382 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5384 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5388 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5389 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5394 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5395 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5400 EVT VT =
N->getValueType(0);
5407 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5410 SplitInteger(Res,
Lo,
Hi);
5417 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5418 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
5420 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5421 Lo = DAG.getPOISON(LoVT);
5422 Hi = DAG.getPOISON(HiVT);
5433bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5437 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5440 switch (
N->getOpcode()) {
5443 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5444 N->dump(&DAG);
dbgs() <<
"\n";
5449 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5453 Res = ExpandOp_FAKE_USE(
N);
5459 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5472 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5477 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5481 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5484 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5486 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5487 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5488 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5491 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5496 if (!Res.
getNode())
return false;
5504 "Invalid operand expansion");
5506 ReplaceValueWith(
SDValue(
N, 0), Res);
5512void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5516 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5517 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5518 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5531 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5538 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5539 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5570 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5571 RHSLo, LowCC,
false, DagCombineInfo, dl);
5573 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5577 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5578 RHSHi, CCCode,
false, DagCombineInfo, dl);
5582 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5591 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5593 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5602 if (LHSHi == RHSHi) {
5611 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5612 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5615 if (HasSETCCCARRY) {
5618 bool FlipOperands =
false;
5635 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5639 DAG.getCondCode(CCCode));
5645 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5646 false, DagCombineInfo, dl);
5649 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5650 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5657 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5662 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5667 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5668 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5669 N->getOperand(4)), 0);
5675 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5680 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5685 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
5686 N->getOperand(2),
N->getOperand(3),
5687 DAG.getCondCode(CCCode)), 0);
5693 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5698 "Unexpected setcc expansion!");
5704 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
5712 SDLoc dl = SDLoc(
N);
5714 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5715 GetExpandedInteger(
LHS, LHSLo, LHSHi);
5716 GetExpandedInteger(
RHS, RHSLo, RHSHi);
5729 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5739 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5740 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
5744 return TLI.expandCMP(
N, DAG);
5752 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5753 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
5757 bool IsStrict =
N->isStrictFPOpcode();
5761 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5762 EVT DstVT =
N->getValueType(0);
5765 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5766 "Don't know how to expand this XINT_TO_FP!");
5767 TargetLowering::MakeLibCallOptions CallOptions;
5769 std::pair<SDValue, SDValue> Tmp =
5770 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
5775 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
5776 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
5781 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
5784 return ExpandOp_NormalStore(
N, OpNo);
5787 assert(OpNo == 1 &&
"Can only expand the stored value so far");
5789 EVT VT =
N->getOperand(1).getValueType();
5790 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5794 AAMDNodes AAInfo =
N->getAAInfo();
5800 if (
N->getMemoryVT().bitsLE(NVT)) {
5801 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5802 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
5803 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
5807 if (DAG.getDataLayout().isLittleEndian()) {
5809 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5811 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
5814 unsigned ExcessBits =
5821 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
5822 N->getPointerInfo().getWithOffset(IncrementSize),
5823 NEVT,
N->getBaseAlign(), MMOFlags, AAInfo);
5829 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5831 EVT ExtVT =
N->getMemoryVT();
5834 unsigned ExcessBits = (EBytes - IncrementSize)*8;
5842 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
5846 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
5850 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
5851 N->getBaseAlign(), MMOFlags, AAInfo);
5856 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
5857 N->getPointerInfo().getWithOffset(IncrementSize),
5859 N->getBaseAlign(), MMOFlags, AAInfo);
5865 GetExpandedInteger(
N->getOperand(0), InL, InH);
5874 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
5879SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
5880 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
5881 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
5885 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
5887 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
5890SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
5893 "cannot use llvm.write_register with illegal type", Fn,
5896 return N->getOperand(0);
5899SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
5902 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
5903 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
5909SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
5911 unsigned Factor =
N->getNumOperands();
5914 for (
unsigned i = 0; i != Factor; i++)
5915 Ops[i] = GetPromotedInteger(
N->getOperand(i));
5920 for (
unsigned i = 0; i != Factor; i++)
5926SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
5928 EVT OutVT =
N->getValueType(0);
5929 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
5930 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
5934 SDValue BaseIdx =
N->getOperand(1);
5951 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
5955 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
5961 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
5970 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
5974 "Promoted operand has an element type greater than result");
5987 InOp0 = GetPromotedInteger(InOp0);
5994 Ops.reserve(OutNumElems);
5995 for (
unsigned i = 0; i != OutNumElems; ++i) {
6000 N->getOperand(0), Index);
6001 SDValue Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6006 return DAG.getBuildVector(NOutVT, dl,
Ops);
6009SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6010 EVT OutVT =
N->getValueType(0);
6011 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6012 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6024 Vec = GetPromotedInteger(Vec);
6030SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6033 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6039SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6041 EVT VT =
N->getValueType(0);
6046 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6047 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6050 return DAG.getVectorShuffle(OutVT, dl, V0, V1, NewMask);
6054 EVT OutVT =
N->getValueType(0);
6055 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6056 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6057 unsigned NumElems =
N->getNumOperands();
6064 Ops.reserve(NumElems);
6065 for (
unsigned i = 0; i != NumElems; ++i) {
6067 EVT OpVT =
Op.getValueType();
6072 if (OpVT.
bitsLT(NOutVTElem)) {
6078 ExtOpc = NOutExtOpc;
6079 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6084 return DAG.getBuildVector(NOutVT, dl,
Ops);
6091 assert(!
N->getOperand(0).getValueType().isVector() &&
6092 "Input must be a scalar");
6094 EVT OutVT =
N->getValueType(0);
6095 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6096 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6100 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6105 EVT OutVT =
N->getValueType(0);
6106 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6108 "Type must be promoted to a scalable vector type");
6109 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6110 return DAG.getStepVector(dl, NOutVT,
6114SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6117 EVT OutVT =
N->getValueType(0);
6118 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6119 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6121 unsigned NumOperands =
N->getNumOperands();
6126 SDUse *MaxSizedValue = std::max_element(
6128 EVT AVT = A.getValueType().getVectorElementType();
6129 EVT BVT = B.getValueType().getVectorElementType();
6130 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6136 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6138 EVT OpVT =
Op.getValueType();
6140 Op = GetPromotedInteger(
Op);
6143 "Unhandled legalization type");
6147 Op = DAG.getAnyExtOrTrunc(
6155 return DAG.getAnyExtOrTrunc(
6163 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6164 assert(NumElem * NumOperands == NumOutElem &&
6165 "Unexpected number of elements");
6169 for (
unsigned i = 0; i < NumOperands; ++i) {
6172 Op = GetPromotedInteger(
Op);
6173 EVT SclrTy =
Op.getValueType().getVectorElementType();
6174 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6175 "Unexpected number of elements");
6177 for (
unsigned j = 0;
j < NumElem; ++
j) {
6179 DAG.getVectorIdxConstant(j, dl));
6180 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6184 return DAG.getBuildVector(NOutVT, dl,
Ops);
6187SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6188 EVT VT =
N->getValueType(0);
6189 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6190 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6198 if (getTypeAction(
N->getOperand(0).getValueType())
6202 switch(
N->getOpcode()) {
6204 Promoted = SExtPromotedInteger(
N->getOperand(0));
6207 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6210 Promoted = GetPromotedInteger(
N->getOperand(0));
6222 DAG.getVectorIdxConstant(0, dl));
6224 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6228 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6231SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6232 EVT VT =
N->getValueType(0);
6233 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6237SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6238 EVT VT =
N->getValueType(0);
6239 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6243SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6245 EVT VT =
N->getValueType(0);
6246 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6247 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6248 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6252SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6253 EVT OutVT =
N->getValueType(0);
6254 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6255 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6260 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6263 NOutVTElem,
N->getOperand(1));
6265 V0, ConvElem,
N->getOperand(2));
6272 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6273 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6281 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6282 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6283 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6287 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6290 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6291 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6299 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6304SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6307 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6309 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6310 ReplaceValueWith(
SDValue(
N, 1),
N->getOperand(0));
6311 return DAG.getPOISON(NVT);
6314SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6316 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6317 SDValue V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6318 TLI.getVectorIdxTy(DAG.getDataLayout()));
6325 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6328SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6333 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6338 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6340 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6352 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1), V1);
6353 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6356SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6358 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6366SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6369 EVT ResVT =
N->getValueType(0);
6370 unsigned NumElems =
N->getNumOperands();
6373 SDValue ResVec = DAG.getUNDEF(ResVT);
6377 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6379 DAG.getIntPtrConstant(
OpIdx * OpNumElts, dl));
6391 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6392 SDValue Incoming = GetPromotedInteger(
N->getOperand(VecIdx));
6396 for (
unsigned i=0; i<NumElem; ++i) {
6399 DAG.getVectorIdxConstant(i, dl));
6405 return DAG.getBuildVector(
N->getValueType(0), dl, NewOps);
6408SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6421 for (
unsigned I = 0;
I < OpNo;
I++)
6424 EVT Ty =
Op.getValueType();
6425 SDLoc
DL = SDLoc(
N);
6428 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6436 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6441 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6447SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6460 for (
unsigned I = 0;
I < OpNo;
I++)
6463 EVT Ty =
Op.getValueType();
6464 SDLoc
DL = SDLoc(
N);
6467 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6475 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6480 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.
EVT changeVectorElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
bool bitsEq(EVT VT) const
Return true if this has the same number of bits as VT.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
EVT changeElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a type whose attributes match ourselves with the exception of the element type that i...
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
static LLVM_ABI MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT)
MakeLibCallOptions & setIsSigned(bool Value=true)