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";
64 case ISD::BSWAP: Res = PromoteIntRes_BSWAP(
N);
break;
68 case ISD::CTLZ: Res = PromoteIntRes_CTLZ(
N);
break;
69 case ISD::CTLS: Res = PromoteIntRes_CTLS(
N);
break;
71 case ISD::CTPOP: Res = PromoteIntRes_CTPOP_PARITY(
N);
break;
73 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(
N);
break;
76 case ISD::VP_CTTZ_ELTS_ZERO_POISON:
77 case ISD::VP_CTTZ_ELTS:
78 Res = PromoteIntRes_VP_CttzElements(
N);
81 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(
N);
break;
91 Res = PromoteIntRes_VECTOR_COMPRESS(
N);
96 Res = PromoteIntRes_Select(
N);
101 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
103 case ISD::SHL: Res = PromoteIntRes_SHL(
N);
break;
105 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
106 case ISD::SRA: Res = PromoteIntRes_SRA(
N);
break;
107 case ISD::SRL: Res = PromoteIntRes_SRL(
N);
break;
110 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
111 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
115 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
117 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
119 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
121 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
124 Res = PromoteIntRes_VECTOR_SPLICE(
N);
127 Res = PromoteIntRes_VECTOR_REPEAT(
N);
131 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
134 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
136 Res = PromoteIntRes_BUILD_VECTOR(
N);
140 Res = PromoteIntRes_ScalarOp(
N);
144 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
149 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
152 Res = PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
N);
156 Res = PromoteIntRes_GET_ACTIVE_LANE_MASK(
N);
159 Res = PromoteIntRes_MASK_BEFOREFIRST(
N);
162 Res = PromoteIntRes_VECTOR_MATCH(
N);
168 Res = PromoteIntRes_PARTIAL_REDUCE_MLA(
N);
182 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
186 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
189 Res = PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
N);
193 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
202 case ISD::MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
212 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
219 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
223 case ISD::ABDU: Res = PromoteIntRes_SExtOrZExtIntBinOp(
N);
break;
227 Res = PromoteIntRes_ZExtMaskedIntBinOp(
N);
231 Res = PromoteIntRes_SExtMaskedIntBinOp(
N);
235 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
237 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
239 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
255 Res = PromoteIntRes_ADDSUBSHLSAT(
N);
260 Res = PromoteIntRes_CMP(
N);
275 Res = PromoteIntRes_ABS(
N);
309 Res = PromoteIntRes_VECREDUCE(
N);
312 case ISD::VP_REDUCE_ADD:
313 case ISD::VP_REDUCE_MUL:
314 case ISD::VP_REDUCE_AND:
315 case ISD::VP_REDUCE_OR:
316 case ISD::VP_REDUCE_XOR:
317 case ISD::VP_REDUCE_SMAX:
318 case ISD::VP_REDUCE_SMIN:
319 case ISD::VP_REDUCE_UMAX:
320 case ISD::VP_REDUCE_UMIN:
321 Res = PromoteIntRes_VP_REDUCE(
N);
326 Res = PromoteIntRes_LOOP_DEPENDENCE_MASK(
N);
330 Res = PromoteIntRes_FREEZE(
N);
335 Res = PromoteIntRes_Rotate(
N);
340 Res = PromoteIntRes_FunnelShift(
N);
346 Res = PromoteIntRes_CLMUL(
N);
350 Res = PromoteIntRes_PEXT(
N);
354 Res = PromoteIntRes_PDEP(
N);
359 Res = PromoteIntRes_MULH(
N);
363 Res = PromoteIntRes_IS_FPCLASS(
N);
366 Res = PromoteIntRes_FFREXP(
N);
371 Res = PromoteIntRes_XRINT(
N);
375 Res = PromoteIntRes_PATCHPOINT(
N);
378 Res = PromoteIntRes_READ_REGISTER(
N);
384 SetPromotedInteger(
SDValue(
N, ResNo), Res);
389 SDValue
Op = DisintegrateMERGE_VALUES(
N, ResNo);
390 return GetPromotedInteger(
Op);
393SDValue DAGTypeLegalizer::PromoteIntRes_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
395 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
396 return DAG.getNode(
N->getOpcode(), SDLoc(
N), NewVT,
N->ops());
401 SDValue
Op = SExtPromotedInteger(
N->getOperand(0));
403 Op.getValueType(),
Op,
N->getOperand(1));
408 SDValue
Op = ZExtPromotedInteger(
N->getOperand(0));
410 Op.getValueType(),
Op,
N->getOperand(1));
414 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
417 switch (TLI.getExtendForAtomicOps()) {
433 DAG.getAtomicLoad(ExtType, SDLoc(
N),
N->getMemoryVT(), ResVT,
434 N->getChain(),
N->getBasePtr(),
N->getMemOperand());
438 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
444 switch (TLI.getExtendForAtomicRMWArg(
N->getOpcode())) {
446 Op2 = SExtPromotedInteger(Op2);
449 Op2 = ZExtPromotedInteger(Op2);
452 Op2 = GetPromotedInteger(Op2);
457 SDValue Res = DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
459 N->getChain(),
N->getBasePtr(),
460 Op2,
N->getMemOperand());
463 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
471 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
472 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
476 if (!TLI.isTypeLegal(SVT))
479 SDVTList VTs = DAG.getVTList(
N->getValueType(0), SVT, MVT::Other);
480 SDValue Res = DAG.getAtomicCmpSwap(
482 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
484 ReplaceValueWith(SDValue(
N, 0), Res.
getValue(0));
485 ReplaceValueWith(SDValue(
N, 2), Res.
getValue(2));
486 return DAG.getSExtOrTrunc(Res.
getValue(1), SDLoc(
N), NVT);
492 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
493 switch (TLI.getExtendForAtomicCmpSwapArg()) {
495 Op2 = SExtPromotedInteger(Op2);
498 Op2 = ZExtPromotedInteger(Op2);
501 Op2 = GetPromotedInteger(Op2);
508 DAG.getVTList(Op2.
getValueType(),
N->getValueType(1), MVT::Other);
509 SDValue Res = DAG.getAtomicCmpSwap(
510 N->getOpcode(), SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
511 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
513 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
514 ReplaceValueWith(SDValue(
N, i), Res.
getValue(i));
521 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
522 EVT OutVT =
N->getValueType(0);
523 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
526 switch (getTypeAction(InVT)) {
532 return DAG.getNode(
ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));
536 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp));
539 return DAG.getNode(
ISD::ANY_EXTEND, dl, NOutVT, GetSoftPromotedHalf(InOp));
547 BitConvertToInteger(GetScalarizedVector(InOp)));
556 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
557 Lo = BitConvertToInteger(
Lo);
558 Hi = BitConvertToInteger(
Hi);
560 if (DAG.getDataLayout().isBigEndian())
566 JoinIntegers(
Lo,
Hi));
581 if (DAG.getDataLayout().isBigEndian()) {
585 DAG.getShiftAmountConstant(ShiftAmt, NOutVT, dl));
600 if (isTypeLegal(WideOutVT)) {
601 InOp = DAG.getBitcast(WideOutVT, GetWidenedVector(InOp));
603 DAG.getVectorIdxConstant(0, dl));
612 DAG.getDataLayout().isLittleEndian()) {
623 if (isTypeLegal(WideVecVT)) {
625 DAG.getUNDEF(WideVecVT), InOp,
626 DAG.getVectorIdxConstant(0, dl));
634 CreateStackStoreLoad(InOp, OutVT));
638 SDValue
V = GetPromotedInteger(
N->getOperand(0));
640 V.getValueType(), V);
644 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
645 EVT OVT =
N->getValueType(0);
646 EVT NVT =
Op.getValueType();
654 !TLI.isOperationLegalOrCustomOrPromote(
ISD::BSWAP, NVT)) {
655 if (SDValue Res = TLI.expandBSWAP(
N, DAG))
660 SDValue ShAmt = DAG.getShiftAmountConstant(DiffBits, NVT, dl);
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);
691 TLI.getTypeToTransformTo(*DAG.getContext(),
692 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
697 EVT VT =
N->getValueType(0);
704 TLI.getTypeToTransformTo(*DAG.getContext(), VT),
711 EVT OVT =
N->getValueType(0);
712 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
718 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
719 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTLZ, NVT) &&
721 if (SDValue Result = TLI.expandCTLZ(
N, DAG)) {
727 unsigned CtlzOpcode =
N->getOpcode();
730 SDValue ExtractLeadingBits = DAG.getConstant(
733 SDValue
Op = ZExtPromotedInteger(
N->getOperand(0));
737 return DAG.getNode(
ISD::SUB, dl, NVT,
738 DAG.getNode(
N->getOpcode(), dl, NVT,
Op),
743 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
747 DAG.getShiftAmountConstant(SHLAmount,
Op.getValueType(), dl);
749 return DAG.getNode(CtlzOpcode, dl, NVT,
Op);
755 EVT OVT =
N->getValueType(0);
756 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
759 SDValue ExtractLeadingBits = DAG.getConstant(
762 SDValue
Op = SExtPromotedInteger(
N->getOperand(0));
768 EVT OVT =
N->getValueType(0);
769 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
777 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTPOP, NVT)) {
778 if (SDValue Result = TLI.expandCTPOP(
N, DAG)) {
785 SDValue
Op = ZExtPromotedInteger(
N->getOperand(0));
786 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
Op.getValueType(),
Op);
790 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
791 EVT OVT =
N->getValueType(0);
792 EVT NVT =
Op.getValueType();
799 if (!OVT.
isVector() && TLI.isTypeLegal(NVT) &&
800 !TLI.isOperationLegalOrCustomOrPromote(
ISD::CTTZ, NVT) &&
804 if (SDValue Result = TLI.expandCTTZ(
N, DAG)) {
810 unsigned NewOpc =
N->getOpcode();
817 Op = DAG.getNode(
ISD::OR, dl, NVT,
Op, DAG.getConstant(TopBit, dl, NVT));
820 return DAG.getNode(NewOpc, dl, NVT,
Op);
823SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
825 EVT NewVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
826 return DAG.getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
829SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
831 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
833 SDValue Op0 =
N->getOperand(0);
834 SDValue Op1 =
N->getOperand(1);
838 if (TLI.getTypeAction(*DAG.getContext(), Op0.
getValueType())
840 SDValue
In = GetPromotedInteger(Op0);
844 EVT SVT =
In.getValueType().getScalarType();
847 return DAG.getAnyExtOrTrunc(Ext, dl, NVT);
855 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
857 TLI.getPreferredFPToIntOpcode(
N->getOpcode(),
N->getValueType(0), NVT);
861 if (
N->isStrictFPOpcode()) {
862 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
863 {
N->getOperand(0),
N->getOperand(1)});
866 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
868 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
883 DAG.getValueType(
N->getValueType(0).getScalarType()));
886SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
888 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
890 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
894SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
895 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
898 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
903SDValue DAGTypeLegalizer::PromoteIntRes_CONVERT_TO_ARBITRARY_FP(
SDNode *
N) {
904 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
908 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
911SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
912 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
915 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(NVT, MVT::Other),
916 N->getOperand(0),
N->getOperand(1));
917 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
922 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
924 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
928 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
932 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
936 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
941 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
944 if (getTypeAction(
N->getOperand(0).getValueType())
946 SDValue Res = GetPromotedInteger(
N->getOperand(0));
955 DAG.getValueType(
N->getOperand(0).getValueType()));
957 return DAG.getZeroExtendInReg(Res, dl,
N->getOperand(0).getValueType());
964 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
969 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
973 SDValue Res = DAG.getExtLoad(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
974 N->getMemoryVT(),
N->getMemOperand());
978 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
983 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
984 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
987 :
N->getExtensionType();
990 DAG.getExtLoadVP(ExtType, dl, NVT,
N->getChain(),
N->getBasePtr(),
991 N->getMask(),
N->getVectorLength(),
N->getMemoryVT(),
992 N->getMemOperand(),
N->isExpandingLoad());
995 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
1000 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1001 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1008 SDValue Res = DAG.getMaskedLoad(NVT, dl,
N->getChain(),
N->getBasePtr(),
1009 N->getOffset(),
N->getMask(), ExtPassThru,
1010 N->getMemoryVT(),
N->getMemOperand(),
1011 N->getAddressingMode(), ExtType,
1012 N->isExpandingLoad());
1015 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
1020 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1021 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1023 "Gather result type and the passThru argument type should be the same");
1030 SDValue
Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1031 N->getIndex(),
N->getScale() };
1032 SDValue Res = DAG.getMaskedGather(DAG.getVTList(NVT, MVT::Other),
1033 N->getMemoryVT(), dl,
Ops,
1034 N->getMemOperand(),
N->getIndexType(),
1038 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
1042SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1043 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1044 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1046 N->getOperand(1), Passthru);
1053 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1054 EVT VT =
N->getValueType(0);
1055 EVT SVT = getSetCCResultType(VT);
1056 SDValue
Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1057 unsigned NumOps =
N->getNumOperands();
1060 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1063 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, SVT),
1068 ReplaceValueWith(SDValue(
N, 0), Res);
1071 return DAG.getBoolExtOrTrunc(Res.
getValue(1), dl, NVT, VT);
1086 unsigned Opcode =
N->getOpcode();
1092 SExtOrZExtPromotedOperands(Op1, Op2);
1098 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1100 if (TLI.isSExtCheaperThanZExt(OVT, NVT)) {
1101 Op1 = SExtPromotedInteger(Op1);
1102 Op2 = SExtPromotedInteger(Op2);
1106 Op1 = ZExtPromotedInteger(Op1);
1107 Op2 = ZExtPromotedInteger(Op2);
1110 SDValue SatMax = DAG.getConstant(MaxVal, dl, NVT);
1111 SDValue
Add = DAG.getNode(
ISD::ADD, dl, NVT, Op1, Op2);
1119 Op1 = GetPromotedInteger(Op1);
1121 Op2 = ZExtPromotedInteger(Op2);
1123 Op1 = SExtPromotedInteger(Op1);
1124 Op2 = SExtPromotedInteger(Op2);
1131 if (IsShift || TLI.isOperationLegal(Opcode, PromotedType)) {
1144 "addition, subtraction or left shift");
1147 unsigned SHLAmount = NewBits - OldBits;
1148 SDValue ShiftAmount =
1149 DAG.getShiftAmountConstant(SHLAmount, PromotedType, dl);
1154 SDValue
Result = DAG.getNode(Opcode, dl, PromotedType, Op1, Op2);
1155 return DAG.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1161 SDValue SatMin = DAG.getConstant(MinVal, dl, PromotedType);
1162 SDValue SatMax = DAG.getConstant(MaxVal, dl, PromotedType);
1163 SDValue
Result = DAG.getNode(AddOp, dl, PromotedType, Op1, Op2);
1172 SDValue Op1Promoted, Op2Promoted;
1178 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1179 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1181 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1182 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1184 EVT OldType =
N->getOperand(0).getValueType();
1196 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1197 SDValue
Result = DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1198 Op2Promoted,
N->getOperand(2));
1200 return DAG.getNode(ShiftOp, dl, PromotedType, Result,
1201 DAG.getShiftAmountConstant(DiffSize, PromotedType, dl));
1203 return DAG.getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1208 unsigned SatW,
bool Signed,
1211 EVT VT = V.getValueType();
1238 EVT VT =
LHS.getValueType();
1254 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1260 "Tried to saturate to more than the original type?");
1269 SDValue Op1Promoted, Op2Promoted;
1275 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1276 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1278 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1279 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1282 unsigned Scale =
N->getConstantOperandVal(2);
1286 if (TLI.isTypeLegal(PromotedType)) {
1288 TLI.getFixedPointOperationAction(
N->getOpcode(), PromotedType, Scale);
1291 N->getValueType(0).getScalarSizeInBits();
1295 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1296 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1297 Op2Promoted,
N->getOperand(2));
1300 DAG.getShiftAmountConstant(Diff, PromotedType, dl));
1306 if (SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl, Op1Promoted,
1307 Op2Promoted, Scale, DAG)) {
1310 N->getValueType(0).getScalarSizeInBits(),
1318 N->getValueType(0).getScalarSizeInBits());
1321SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1323 return PromoteIntRes_Overflow(
N);
1327 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1328 SDValue
RHS = SExtPromotedInteger(
N->getOperand(1));
1329 EVT OVT =
N->getOperand(0).getValueType();
1330 EVT NVT =
LHS.getValueType();
1340 DAG.getValueType(OVT));
1342 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1345 ReplaceValueWith(SDValue(
N, 1), Ofl);
1351 EVT PromotedResultTy =
1352 TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1353 return DAG.
getNode(
N->getOpcode(), SDLoc(
N), PromotedResultTy,
1354 N->getOperand(0),
N->getOperand(1));
1358 SDValue
Mask =
N->getOperand(0);
1360 SDValue
LHS = GetPromotedInteger(
N->getOperand(1));
1361 SDValue
RHS = GetPromotedInteger(
N->getOperand(2));
1363 unsigned Opcode =
N->getOpcode();
1364 if (Opcode == ISD::VP_MERGE)
1365 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS,
1367 return DAG.getNode(Opcode, SDLoc(
N),
LHS.getValueType(), Mask,
LHS,
RHS);
1371 SDValue
LHS = GetPromotedInteger(
N->getOperand(2));
1372 SDValue
RHS = GetPromotedInteger(
N->getOperand(3));
1374 LHS.getValueType(),
N->getOperand(0),
1375 N->getOperand(1),
LHS,
RHS,
N->getOperand(4));
1380 EVT InVT =
N->getOperand(OpNo).getValueType();
1381 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1383 EVT SVT = getSetCCResultType(InVT);
1390 InVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
1391 SVT = getSetCCResultType(InVT);
1399 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1400 "Vector compare must return a vector result!");
1404 if (
N->isStrictFPOpcode()) {
1405 SDVTList VTs = DAG.getVTList({SVT, MVT::Other});
1406 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1407 N->getOperand(2),
N->getOperand(3)};
1408 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1411 ReplaceValueWith(SDValue(
N, 1), SetCC.
getValue(1));
1413 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1414 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1417 return DAG.getSExtOrTrunc(SetCC, dl, NVT);
1422 SDValue Arg =
N->getOperand(0);
1423 SDValue
Test =
N->getOperand(1);
1424 EVT NResVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1429 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(1));
1430 EVT VT =
N->getValueType(0);
1434 DAG.
getNode(
N->getOpcode(), dl, DAG.getVTList(VT, NVT),
N->getOperand(0));
1436 ReplaceValueWith(SDValue(
N, 0), Res);
1441 SDValue
LHS = GetPromotedInteger(
N->getOperand(0));
1442 SDValue
RHS =
N->getOperand(1);
1444 RHS = ZExtPromotedInteger(
RHS);
1445 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1448SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1449 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
1451 Op.getValueType(),
Op,
N->getOperand(1));
1454SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1458 SDValue
LHS = GetPromotedInteger(
N->getOperand(0));
1459 SDValue
RHS = GetPromotedInteger(
N->getOperand(1));
1460 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1465 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1466 SDValue
RHS = SExtPromotedInteger(
N->getOperand(1));
1467 if (
N->getNumOperands() == 2)
1468 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1469 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1470 assert((
N->getOpcode() == ISD::VP_SDIV ||
N->getOpcode() == ISD::VP_SREM) &&
1471 "Expected VP opcode");
1472 SDValue
Mask =
N->getOperand(2);
1473 SDValue EVL =
N->getOperand(3);
1474 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1480 SDValue
LHS = ZExtPromotedInteger(
N->getOperand(0));
1481 SDValue
RHS = ZExtPromotedInteger(
N->getOperand(1));
1482 if (
N->getNumOperands() == 2)
1483 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1484 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1485 assert((
N->getOpcode() == ISD::VP_UDIV ||
N->getOpcode() == ISD::VP_UREM) &&
1486 "Expected VP opcode");
1488 SDValue
Mask =
N->getOperand(2);
1494SDValue DAGTypeLegalizer::PromoteIntRes_ZExtMaskedIntBinOp(
SDNode *
N) {
1495 SDValue
LHS = ZExtPromotedInteger(
N->getOperand(0));
1496 SDValue
RHS = ZExtPromotedInteger(
N->getOperand(1));
1497 SDValue
Mask =
N->getOperand(2);
1498 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1502SDValue DAGTypeLegalizer::PromoteIntRes_SExtMaskedIntBinOp(
SDNode *
N) {
1503 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1504 SDValue
RHS = SExtPromotedInteger(
N->getOperand(1));
1505 SDValue
Mask =
N->getOperand(2);
1506 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS,
1510SDValue DAGTypeLegalizer::PromoteIntRes_SExtOrZExtIntBinOp(
SDNode *
N) {
1511 SDValue
LHS =
N->getOperand(0);
1512 SDValue
RHS =
N->getOperand(1);
1516 SExtOrZExtPromotedOperands(
LHS,
RHS);
1518 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
1524 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1525 SDValue
RHS =
N->getOperand(1);
1527 RHS = ZExtPromotedInteger(
RHS);
1528 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1532 SDValue
RHS =
N->getOperand(1);
1534 SDValue
LHS = ZExtPromotedInteger(
N->getOperand(0));
1536 RHS = ZExtPromotedInteger(
RHS);
1537 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
LHS.getValueType(),
LHS,
RHS);
1542 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1543 SDValue Amt =
N->getOperand(1);
1544 unsigned Opcode =
N->getOpcode();
1555 !TLI.isOperationLegalOrCustom(Opcode, VT) &&
1558 SDValue Op0 = GetPromotedInteger(
N->getOperand(0));
1560 Amt = ZExtPromotedInteger(Amt);
1566 DAG.getConstant(OldBits,
DL, AmtVT));
1567 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1568 SDValue
Hi = DAG.getNode(
ISD::SHL,
DL, VT, Op0, HiShift);
1569 SDValue
Lo = DAG.getZeroExtendInReg(Op0,
DL, OldVT);
1581 SDValue Res = TLI.expandROT(
N,
true , DAG);
1582 ReplaceValueWith(SDValue(
N, 0), Res);
1587 SDValue
Hi = GetPromotedInteger(
N->getOperand(0));
1588 SDValue
Lo = GetPromotedInteger(
N->getOperand(1));
1591 Amt = ZExtPromotedInteger(Amt);
1595 EVT OldVT =
N->getOperand(0).getValueType();
1596 EVT VT =
Lo.getValueType();
1597 unsigned Opcode =
N->getOpcode();
1604 DAG.getConstant(OldBits,
DL, AmtVT));
1612 !TLI.isOperationLegalOrCustom(Opcode, VT)) {
1613 SDValue HiShift = DAG.getShiftAmountConstant(OldBits, VT,
DL);
1615 Lo = DAG.getZeroExtendInReg(
Lo,
DL, OldVT);
1625 DAG.getShiftAmountConstant(NewBits - OldBits, VT,
DL));
1631 DAG.getConstant(NewBits - OldBits,
DL, AmtVT));
1633 return DAG.getNode(Opcode,
DL, VT,
Hi,
Lo, Amt);
1637 unsigned Opcode =
N->getOpcode();
1640 EVT OldVT =
N->getOperand(0).getValueType();
1641 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(), OldVT);
1646 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::CLMUL, VT) &&
1648 TLI.isOperationLegalOrCustom(
1649 ISD::CLMUL, TLI.getRegisterType(*DAG.getContext(), VT)))) {
1650 if (SDValue Res = TLI.expandCLMUL(
N, DAG))
1653 SDValue
X = GetPromotedInteger(
N->getOperand(0));
1654 SDValue
Y = GetPromotedInteger(
N->getOperand(1));
1658 SDValue
X = ZExtPromotedInteger(
N->getOperand(0));
1659 SDValue
Y = ZExtPromotedInteger(
N->getOperand(1));
1663 if (NewBits < 2 * OldBits) {
1665 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1667 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1669 ShAmt = Opcode ==
ISD::CLMULH ? NewBits - OldBits : NewBits - OldBits + 1;
1671 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1676 unsigned ShAmt = Opcode ==
ISD::CLMULH ? OldBits : OldBits - 1;
1678 DAG.getShiftAmountConstant(ShAmt, VT,
DL));
1683 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1684 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PEXT, VT)) {
1685 if (SDValue Res = TLI.expandPEXT(
N, DAG))
1690 SDValue
X = GetPromotedInteger(
N->getOperand(0));
1691 SDValue
Y = ZExtPromotedInteger(
N->getOperand(1));
1697 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1698 if (!TLI.isOperationLegalOrCustomOrPromote(
ISD::PDEP, VT)) {
1699 if (SDValue Res = TLI.expandPDEP(
N, DAG))
1704 SDValue
X = GetPromotedInteger(
N->getOperand(0));
1705 SDValue
Y = GetPromotedInteger(
N->getOperand(1));
1711 EVT VT =
N->getValueType(0);
1712 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
1719 LHS = SExtPromotedInteger(
N->getOperand(0));
1720 RHS = SExtPromotedInteger(
N->getOperand(1));
1722 LHS = ZExtPromotedInteger(
N->getOperand(0));
1723 RHS = ZExtPromotedInteger(
N->getOperand(1));
1730 DAG.getShiftAmountConstant(BW, NVT, dl));
1734 DAG.getShiftAmountConstant(NBW - BW, NVT, dl));
1735 return DAG.getNode(
N->getOpcode(), dl, NVT,
LHS,
RHS);
1739 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1751 Res = GetPromotedInteger(InOp);
1758 "Dst and Src must have the same number of elements");
1760 "Promoted vector type must be a power of two");
1763 GetSplitVector(InOp, EOp1, EOp2);
1772 SDValue WideInOp = GetWidenedVector(InOp);
1777 N->getValueType(0).getScalarType(), NumElem);
1778 SDValue WideTrunc = DAG.getNode(
ISD::TRUNCATE, dl, TruncVT, WideInOp);
1786 SDValue ZeroIdx = DAG.getVectorIdxConstant(0, dl);
1795SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1797 return PromoteIntRes_Overflow(
N);
1801 SDValue
LHS = ZExtPromotedInteger(
N->getOperand(0));
1802 SDValue
RHS = ZExtPromotedInteger(
N->getOperand(1));
1803 EVT OVT =
N->getOperand(0).getValueType();
1804 EVT NVT =
LHS.getValueType();
1813 SDValue Ofl = DAG.getZeroExtendInReg(Res, dl, OVT);
1815 Ofl = DAG.getSetCC(dl,
N->getValueType(1), Ofl, Res,
ISD::SETNE);
1818 ReplaceValueWith(SDValue(
N, 1), Ofl);
1829 return PromoteIntRes_Overflow(
N);
1841 SDValue
LHS = SExtPromotedInteger(
N->getOperand(0));
1842 SDValue
RHS = SExtPromotedInteger(
N->getOperand(1));
1844 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1847 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), DAG.getVTList(ValueVTs),
1851 ReplaceValueWith(SDValue(
N, 1), Res.
getValue(1));
1853 return SDValue(Res.
getNode(), 0);
1858 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1859 return PromoteIntRes_Overflow(
N);
1863 EVT OVT =
N->getValueType(0);
1864 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), OVT);
1870 !TLI.isOperationLegalOrCustomOrPromote(
ISD::ABS, NVT) &&
1872 !TLI.isOperationLegal(
ISD::SMAX, NVT)) {
1873 if (SDValue Res = TLI.expandABS(
N, DAG))
1877 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1881SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1884 return PromoteIntRes_Overflow(
N);
1886 SDValue
LHS =
N->getOperand(0),
RHS =
N->getOperand(1);
1888 EVT SmallVT =
LHS.getValueType();
1895 LHS = SExtPromotedInteger(
LHS);
1896 RHS = SExtPromotedInteger(
RHS);
1898 LHS = ZExtPromotedInteger(
LHS);
1899 RHS = ZExtPromotedInteger(
RHS);
1901 SDVTList VTs = DAG.getVTList(
LHS.getValueType(),
N->getValueType(1));
1902 SDValue
Mul = DAG.getNode(
N->getOpcode(),
DL, VTs,
LHS,
RHS);
1913 DAG.getShiftAmountConstant(Shift,
Mul.getValueType(),
DL));
1914 Overflow = DAG.getSetCC(
DL,
N->getValueType(1),
Hi,
1915 DAG.getConstant(0,
DL,
Hi.getValueType()),
1920 Mul, DAG.getValueType(SmallVT));
1927 SDValue(
Mul.getNode(), 1));
1930 ReplaceValueWith(SDValue(
N, 1), Overflow);
1935 return DAG.getUNDEF(TLI.getTypeToTransformTo(*DAG.getContext(),
1936 N->getValueType(0)));
1940 EVT VT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1942 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1949 EVT VT =
N->getValueType(0);
1952 MVT RegVT = TLI.getRegisterType(*DAG.getContext(), VT);
1953 unsigned NumRegs = TLI.getNumRegisters(*DAG.getContext(), VT);
1957 for (
unsigned i = 0; i < NumRegs; ++i) {
1958 Parts[i] = DAG.getVAArg(RegVT, dl, Chain, Ptr,
N->getOperand(2),
1959 N->getConstantOperandVal(3));
1964 if (DAG.getDataLayout().isBigEndian())
1965 std::reverse(Parts.begin(), Parts.end());
1968 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
1970 for (
unsigned i = 1; i < NumRegs; ++i) {
1975 DAG.getShiftAmountConstant(i * RegVT.
getSizeInBits(), NVT, dl));
1981 ReplaceValueWith(SDValue(
N, 1), Chain);
1994bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
1996 SDValue Res = SDValue();
1997 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
2002 switch (
N->getOpcode()) {
2005 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
2006 N->dump(&DAG);
dbgs() <<
"\n";
2012 Res = PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
N);
2018 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
2019 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
2024 Res = PromoteIntOp_COND_LOOP(
N, OpNo);
2028 Res = PromoteIntOp_FAKE_USE(
N);
2031 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
2035 Res = PromoteIntOp_ScalarOp(
N);
2038 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
2040 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
2058 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
2065 Res = PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
N);
2080 Res = PromoteIntOp_Shift(
N);
2084 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2087 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2113 case ISD::VP_REDUCE_ADD:
2114 case ISD::VP_REDUCE_MUL:
2115 case ISD::VP_REDUCE_AND:
2116 case ISD::VP_REDUCE_OR:
2117 case ISD::VP_REDUCE_XOR:
2118 case ISD::VP_REDUCE_SMAX:
2119 case ISD::VP_REDUCE_SMIN:
2120 case ISD::VP_REDUCE_UMAX:
2121 case ISD::VP_REDUCE_UMIN:
2122 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2127 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2130 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2133 Res = PromoteIntOp_WRITE_REGISTER(
N, OpNo);
2135 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2136 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2137 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2139 case ISD::EXPERIMENTAL_VP_SPLICE:
2140 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2143 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2148 Res = PromoteIntOp_UnaryBooleanVectorOp(
N, OpNo);
2151 Res = PromoteIntOp_GET_ACTIVE_LANE_MASK(
N);
2154 Res = PromoteIntOp_VECTOR_MATCH(
N, OpNo);
2160 Res = PromoteIntOp_MaskedBinOp(
N, OpNo);
2165 Res = PromoteIntOp_PARTIAL_REDUCE_MLA(
N);
2168 Res = PromoteIntOp_VECTOR_REPEAT(
N);
2172 Res = PromoteIntOp_LOOP_DEPENDENCE_MASK(
N);
2177 if (!Res.
getNode())
return false;
2184 const bool IsStrictFp =
N->isStrictFPOpcode();
2186 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2187 "Invalid operand expansion");
2191 ReplaceValueWith(SDValue(
N, 0), Res);
2193 ReplaceValueWith(SDValue(
N, 1), SDValue(Res.
getNode(), 1));
2202 SDValue OpL = GetPromotedInteger(
LHS);
2203 SDValue OpR = GetPromotedInteger(
RHS);
2205 if (TLI.isSExtCheaperThanZExt(
LHS.getValueType(), OpL.
getValueType())) {
2209 unsigned OpLEffectiveBits =
2210 DAG.computeKnownBits(OpL).countMaxActiveBits();
2211 unsigned OpREffectiveBits =
2212 DAG.computeKnownBits(OpR).countMaxActiveBits();
2213 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2214 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2221 LHS = SExtPromotedInteger(
LHS);
2222 RHS = SExtPromotedInteger(
RHS);
2231 unsigned OpLEffectiveBits = DAG.ComputeMaxSignificantBits(OpL);
2232 unsigned OpREffectiveBits = DAG.ComputeMaxSignificantBits(OpR);
2233 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2234 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2241 LHS = ZExtPromotedInteger(
LHS);
2242 RHS = ZExtPromotedInteger(
RHS);
2256 LHS = SExtPromotedInteger(
LHS);
2257 RHS = SExtPromotedInteger(
RHS);
2262 "Unknown integer comparison!");
2264 SExtOrZExtPromotedOperands(
LHS,
RHS);
2268 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2272SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND_VECTOR_INREG(
SDNode *
N) {
2273 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2274 EVT ResVT =
N->getValueType(0);
2275 EVT OpVT =
Op.getValueType();
2278 Op = DAG.getExtractSubvector(SDLoc(
Op), NewVT,
Op, 0);
2283 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2284 return DAG.getAtomic(
N->getOpcode(), SDLoc(
N),
N->getMemoryVT(),
2285 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2289 EVT OutVT =
N->getValueType(0);
2292 EVT NInVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
2295 switch (getTypeAction(InVT)) {
2301 if (OutEltBits % InEltBits == 0 && isTypeLegal(IntVT)) {
2304 SDValue Promoted = GetPromotedInteger(InOp);
2307 if (PromotedEltBits % InEltBits == 0) {
2308 unsigned Scale = PromotedEltBits / InEltBits;
2316 PromotedBits / OutEltBits);
2317 if (isTypeLegal(PackedVT) && isTypeLegal(CastVT) &&
2324 Mask[
I] =
I * Scale +
2325 (DAG.getDataLayout().isBigEndian() ? Scale - 1 : 0);
2326 if (TLI.isShuffleMaskLegal(Mask, PackedVT)) {
2329 Packed = DAG.getVectorShuffle(PackedVT, dl, Packed,
2330 DAG.getUNDEF(PackedVT), Mask);
2333 return DAG.getExtractSubvector(dl, OutVT, Packed, 0);
2334 return DAG.getExtractVectorElt(dl, OutVT, Packed, 0);
2339 unsigned PartsPerElt = OutEltBits / InEltBits;
2343 for (
unsigned I = 0;
I != NumElts; ++
I) {
2344 SDValue
Packed = DAG.getConstant(0, dl, IntVT);
2345 for (
unsigned J = 0; J != PartsPerElt; ++J) {
2346 SDValue Part = DAG.getExtractVectorElt(
2348 I * PartsPerElt + J);
2349 Part = DAG.getZeroExtendInReg(Part, dl, InVT.
getScalarType());
2350 Part = DAG.getZExtOrTrunc(Part, dl, IntVT);
2351 unsigned Shift = DAG.getDataLayout().isBigEndian()
2352 ? (PartsPerElt - 1 - J) * InEltBits
2355 DAG.getShiftAmountConstant(Shift, IntVT, dl));
2360 SDValue
Packed = Elts[0];
2363 Packed = DAG.getBuildVector(VecVT, dl, Elts);
2370 DAG.getDataLayout().isLittleEndian()) {
2380 if (isTypeLegal(WideVecVT)) {
2381 SDValue Promoted = GetPromotedInteger(InOp);
2382 SDValue Cast = DAG.getNode(
ISD::BITCAST, dl, WideVecVT, Promoted);
2384 DAG.getVectorIdxConstant(0, dl));
2397 return CreateStackStoreLoad(InOp, OutVT);
2400SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2401 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2403 SDValue
LHS =
N->getOperand(2);
2404 SDValue
RHS =
N->getOperand(3);
2409 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2410 N->getOperand(1),
LHS,
RHS,
N->getOperand(4)),
2414SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2415 assert(OpNo == 1 &&
"only know how to promote condition");
2418 SDValue
Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2421 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond,
2422 N->getOperand(2)), 0);
2425SDValue DAGTypeLegalizer::PromoteIntOp_COND_LOOP(
SDNode *
N,
unsigned OpNo) {
2426 assert(OpNo == 1 &&
"only know how to promote condition");
2429 SDValue
Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2432 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Cond), 0);
2437 EVT OVT =
N->getOperand(0).getValueType();
2438 SDValue
Lo = ZExtPromotedInteger(
N->getOperand(0));
2439 SDValue
Hi = GetPromotedInteger(
N->getOperand(1));
2440 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2445 DAG.getShiftAmountConstant(OVT.
getSizeInBits(),
N->getValueType(0), dl));
2446 return DAG.getNode(
ISD::OR, dl,
N->getValueType(0),
Lo,
Hi);
2455 assert(!((NumElts & 1) && (!TLI.isTypeLegal(VecVT))) &&
2456 "Legal vector of one illegal element?");
2461 assert(
N->getOperand(0).getValueSizeInBits() >=
2462 N->getValueType(0).getScalarSizeInBits() &&
2463 "Type of inserted value narrower than vector element type!");
2466 for (
unsigned i = 0; i < NumElts; ++i)
2467 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2469 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2472SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2479 assert(
N->getOperand(1).getValueSizeInBits() >=
2480 N->getValueType(0).getScalarSizeInBits() &&
2481 "Type of inserted value narrower than vector element type!");
2482 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2483 GetPromotedInteger(
N->getOperand(1)),
2488 assert(OpNo == 2 &&
"Different operand and result vector types?");
2491 SDValue
Idx = DAG.getZExtOrTrunc(
N->getOperand(2), SDLoc(
N),
2492 TLI.getVectorIdxTy(DAG.getDataLayout()));
2493 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2494 N->getOperand(1), Idx), 0);
2498 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2502 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2505SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2506 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2507 SDValue
Cond =
N->getOperand(0);
2508 EVT OpTy =
N->getOperand(1).getValueType();
2511 if (SDValue Res = WidenVSELECTMask(
N))
2512 return DAG.getNode(
N->getOpcode(), SDLoc(
N),
N->getValueType(0),
2513 Res,
N->getOperand(1),
N->getOperand(2));
2517 Cond = PromoteTargetBoolean(
Cond, OpVT);
2519 return SDValue(DAG.UpdateNodeOperands(
N,
Cond,
N->getOperand(1),
2520 N->getOperand(2)), 0);
2523SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2524 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2526 SDValue
LHS =
N->getOperand(0);
2527 SDValue
RHS =
N->getOperand(1);
2531 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2),
2532 N->getOperand(3),
N->getOperand(4)), 0);
2535SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2536 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2538 SDValue
LHS =
N->getOperand(0);
2539 SDValue
RHS =
N->getOperand(1);
2543 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS,
N->getOperand(2)), 0);
2547 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2548 ZExtPromotedInteger(
N->getOperand(1))), 0);
2552 SDValue
LHS =
N->getOperand(0);
2553 SDValue
RHS =
N->getOperand(1);
2556 LHS = SExtPromotedInteger(
LHS);
2557 RHS = SExtPromotedInteger(
RHS);
2559 SExtOrZExtPromotedOperands(
LHS,
RHS);
2562 return SDValue(DAG.UpdateNodeOperands(
N,
LHS,
RHS), 0);
2566 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1),
2567 ZExtPromotedInteger(
N->getOperand(2))), 0);
2571 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2575 Op, DAG.getValueType(
N->getOperand(0).getValueType()));
2579 return SDValue(DAG.UpdateNodeOperands(
N,
2580 SExtPromotedInteger(
N->getOperand(0))), 0);
2583SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2584 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2585 SExtPromotedInteger(
N->getOperand(1))), 0);
2590 SDValue Ch =
N->getChain(), Ptr =
N->getBasePtr();
2593 SDValue Val = GetPromotedInteger(
N->getValue());
2596 return DAG.getTruncStore(Ch, dl, Val, Ptr,
2597 N->getMemoryVT(),
N->getMemOperand());
2603 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2604 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2606 SDValue DataOp = GetPromotedInteger(
N->getValue());
2607 return DAG.getTruncStoreVP(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2608 N->getMask(),
N->getVectorLength(),
2609 N->getMemoryVT(),
N->getMemOperand(),
2610 N->isCompressingStore());
2615 SDValue DataOp =
N->getValue();
2616 SDValue
Mask =
N->getMask();
2621 Mask = PromoteTargetBoolean(Mask, DataVT);
2624 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2627 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2628 DataOp = GetPromotedInteger(DataOp);
2630 return DAG.getMaskedStore(
N->getChain(), SDLoc(
N), DataOp,
N->getBasePtr(),
2631 N->getOffset(), Mask,
N->getMemoryVT(),
2632 N->getMemOperand(),
N->getAddressingMode(),
2633 true,
N->isCompressingStore());
2638 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2639 EVT DataVT =
N->getValueType(0);
2640 SDValue
Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2642 NewOps[OpNo] =
Mask;
2643 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2645 return SDValue(Res, 0);
2648 ReplaceValueWith(SDValue(
N, 0), SDValue(Res, 0));
2649 ReplaceValueWith(SDValue(
N, 1), SDValue(Res, 1));
2659 EVT DataVT =
N->getValueType(0);
2660 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2661 }
else if (OpNo == 4) {
2663 if (
N->isIndexSigned())
2665 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2667 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2669 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2671 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
2673 return SDValue(Res, 0);
2676 ReplaceValueWith(SDValue(
N, 0), SDValue(Res, 0));
2677 ReplaceValueWith(SDValue(
N, 1), SDValue(Res, 1));
2683 bool TruncateStore =
N->isTruncatingStore();
2688 EVT DataVT =
N->getValue().getValueType();
2689 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2690 }
else if (OpNo == 4) {
2692 if (
N->isIndexSigned())
2694 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2696 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2698 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2699 TruncateStore =
true;
2702 return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
N->getMemoryVT(),
2703 SDLoc(
N), NewOps,
N->getMemOperand(),
2704 N->getIndexType(), TruncateStore);
2709 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2713 SDValue
Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2718 SDValue
Op = GetPromotedInteger(
N->getOperand(0));
2723 return SDValue(DAG.UpdateNodeOperands(
N,
2724 ZExtPromotedInteger(
N->getOperand(0))), 0);
2727SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_FROM_ARBITRARY_FP(
SDNode *
N) {
2728 return SDValue(DAG.UpdateNodeOperands(
N, GetPromotedInteger(
N->getOperand(0)),
2733SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2734 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
2735 ZExtPromotedInteger(
N->getOperand(1))), 0);
2740 SDValue Src =
N->getOperand(0);
2741 SDValue
Op = GetPromotedInteger(Src);
2742 EVT VT =
N->getValueType(0);
2747 if (
N->getFlags().hasNonNeg() &&
Op.getValueType() == VT &&
2748 TLI.isSExtCheaperThanZExt(Src.getValueType(), VT)) {
2749 unsigned OpEffectiveBits = DAG.ComputeMaxSignificantBits(
Op);
2750 if (OpEffectiveBits <= Src.getScalarValueSizeInBits())
2755 return DAG.getZeroExtendInReg(
Op, dl, Src.getValueType());
2759 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2761 DAG.UpdateNodeOperands(
N,
N->getOperand(0),
N->getOperand(1), Op2), 0);
2764SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2766 SDValue
Op = ZExtPromotedInteger(
N->getOperand(0));
2767 return SDValue(DAG.UpdateNodeOperands(
N,
Op), 0);
2772 SDValue Chain = IsStrict ?
N->getOperand(0) : SDValue();
2776 unsigned OpOffset = IsStrict ? 1 : 0;
2780 RTLIB::Libcall LC = IsPowI ? RTLIB::getPOWI(
N->getValueType(0))
2783 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
2784 if (LCImpl == RTLIB::Unsupported) {
2790 if (IsPowI &&
N->getValueType(0).isVector())
2791 return DAG.UnrollVectorOp(
N);
2793 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2794 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2806 if (
N->getOperand(1 + OpOffset).getScalarValueSizeInBits() >
2807 DAG.getLibInfo().getIntSize()) {
2808 const Function &Fn = DAG.getMachineFunction().getFunction();
2809 Fn.getContext().diagnose(DiagnosticInfoLegalizationFailure(
2810 Twine(IsPowI ?
"powi" :
"ldexp") +
2811 " exponent does not match sizeof(int)",
2812 Fn, N->getDebugLoc()));
2814 ReplaceValueWith(SDValue(N, 1), Chain);
2815 ReplaceValueWith(SDValue(N, 0), DAG.getPOISON(N->getValueType(0)));
2819 TargetLowering::MakeLibCallOptions CallOptions;
2820 CallOptions.setIsSigned(
true);
2821 SDValue
Ops[2] = {N->getOperand(0 + OpOffset), N->getOperand(1 + OpOffset)};
2822 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(
2823 DAG, LCImpl,
N->getValueType(0),
Ops, CallOptions, SDLoc(
N), Chain);
2824 ReplaceValueWith(SDValue(
N, 0), Tmp.first);
2826 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
2831 switch (
N->getOpcode()) {
2839 case ISD::VP_REDUCE_ADD:
2840 case ISD::VP_REDUCE_MUL:
2841 case ISD::VP_REDUCE_AND:
2842 case ISD::VP_REDUCE_OR:
2843 case ISD::VP_REDUCE_XOR:
2847 case ISD::VP_REDUCE_SMAX:
2848 case ISD::VP_REDUCE_SMIN:
2852 case ISD::VP_REDUCE_UMAX:
2853 case ISD::VP_REDUCE_UMIN:
2863 return GetPromotedInteger(V);
2865 return SExtPromotedInteger(V);
2867 return ZExtPromotedInteger(V);
2873 SDValue
Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2875 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2876 EVT InVT =
Op.getValueType();
2878 EVT ResVT =
N->getValueType(0);
2879 unsigned Opcode =
N->getOpcode();
2896 switch (TLI.getBooleanContents(InVT)) {
2899 Op = ZExtPromotedInteger(
N->getOperand(0));
2902 Op = SExtPromotedInteger(
N->getOperand(0));
2915 switch (TLI.getBooleanContents(InVT)) {
2918 Op = ZExtPromotedInteger(
N->getOperand(0));
2921 Op = SExtPromotedInteger(
N->getOperand(0));
2927 return DAG.getNode(Opcode, SDLoc(
N), ResVT,
Op);
2931 SDValue Reduce = DAG.getNode(Opcode, dl, EltVT,
Op);
2935SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2937 SDValue
Op =
N->getOperand(OpNo);
2942 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2943 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2946 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2948 Op = PromoteIntOpVectorReduction(
N,
Op);
2952 EVT VT =
N->getValueType(0);
2953 EVT EltVT =
Op.getValueType().getScalarType();
2956 return DAG.getNode(
N->getOpcode(), SDLoc(
N), VT, NewOps);
2963 SDValue Reduce = DAG.
getNode(
N->getOpcode(),
DL, EltVT, NewOps);
2968 SDValue
Op = ZExtPromotedInteger(
N->getOperand(1));
2969 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Op), 0);
2972SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2975 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2976 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2979SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2982 NewOps[OpNo] = GetPromotedInteger(NewOps[OpNo]);
2983 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
2988 const Function &Fn = DAG.getMachineFunction().getFunction();
2990 "cannot use llvm.write_register with illegal type", Fn,
2992 return N->getOperand(0);
2995SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2996 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2997 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
3000 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3001 SDNode *Res = DAG.UpdateNodeOperands(
N, NewOps);
3003 return SDValue(Res, 0);
3006 ReplaceValueWith(SDValue(
N, 0), SDValue(Res, 0));
3007 ReplaceValueWith(SDValue(
N, 1), SDValue(Res, 1));
3011SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
3015 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
3016 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3019 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
3021 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
3022 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3025SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
3027 assert(OpNo == 1 &&
"Unexpected operand for promotion");
3029 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
3030 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3033SDValue DAGTypeLegalizer::PromoteIntOp_UnaryBooleanVectorOp(
SDNode *
N,
3035 assert(OpNo == 0 &&
"Unexpected operand for promotion");
3036 SDValue
Op =
N->getOperand(0);
3039 if (TLI.getBooleanContents(
Op.getValueType()) ==
3041 NewOp = SExtPromotedInteger(
Op);
3043 NewOp = ZExtPromotedInteger(
Op);
3045 return SDValue(DAG.UpdateNodeOperands(
N, NewOp), 0);
3048SDValue DAGTypeLegalizer::PromoteIntOp_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
3050 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3051 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3052 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3055SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_MATCH(
SDNode *
N,
unsigned OpNo) {
3056 assert(OpNo < 3 &&
"Unexpected operand for promotion");
3058 return TLI.expandVectorMatch(
N, DAG);
3061 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2),
N->getValueType(0));
3062 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3065SDValue DAGTypeLegalizer::PromoteIntOp_MaskedBinOp(
SDNode *
N,
unsigned OpNo) {
3068 NewOps[2] = PromoteTargetBoolean(NewOps[2],
N->getValueType(0));
3069 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3072SDValue DAGTypeLegalizer::PromoteIntOp_PARTIAL_REDUCE_MLA(
SDNode *
N) {
3074 switch (
N->getOpcode()) {
3076 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3077 NewOps[2] = SExtPromotedInteger(
N->getOperand(2));
3080 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3081 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3084 NewOps[1] = SExtPromotedInteger(
N->getOperand(1));
3085 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3090 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3093SDValue DAGTypeLegalizer::PromoteIntOp_LOOP_DEPENDENCE_MASK(
SDNode *
N) {
3095 NewOps[0] = ZExtPromotedInteger(
N->getOperand(0));
3096 NewOps[1] = ZExtPromotedInteger(
N->getOperand(1));
3097 NewOps[2] = ZExtPromotedInteger(
N->getOperand(2));
3099 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
3104 SDValue Src = GetPromotedInteger(
N->getOperand(0));
3105 EVT SrcVT = Src.getValueType();
3106 EVT OrigVT =
N->getValueType(0);
3121void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
3124 Lo =
Hi = SDValue();
3127 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
3130 switch (
N->getOpcode()) {
3133 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
3134 N->dump(&DAG);
dbgs() <<
"\n";
3163 ExpandIntRes_ABS(
N,
Lo,
Hi);
3215 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
3216 SplitInteger(Tmp.first,
Lo,
Hi);
3217 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
3222 SDVTList VTs = DAG.getVTList(
N->getValueType(0), MVT::Other);
3223 SDValue Tmp = DAG.getAtomicCmpSwap(
3225 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
3231 SDValue
Success = DAG.getSetCC(SDLoc(
N),
N->getValueType(1), Tmp,
3234 SplitInteger(Tmp,
Lo,
Hi);
3235 ReplaceValueWith(SDValue(
N, 1),
Success);
3236 ReplaceValueWith(SDValue(
N, 2), Tmp.
getValue(1));
3313 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3318 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3324 ExpandIntRes_CLMUL(
N,
Lo,
Hi);
3328 ExpandIntRes_PEXT(
N,
Lo,
Hi);
3332 ExpandIntRes_PDEP(
N,
Lo,
Hi);
3337 ExpandIntRes_MULH(
N,
Lo,
Hi);
3341 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3345 ExpandIntRes_READ_REGISTER(
N,
Lo,
Hi);
3350 ExpandIntRes_CTTZ_ELTS(
N,
Lo,
Hi);
3356 SetExpandedInteger(SDValue(
N, ResNo),
Lo,
Hi);
3360std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
3361 unsigned Opc =
Node->getOpcode();
3367 EVT RetVT =
Node->getValueType(0);
3368 TargetLowering::MakeLibCallOptions CallOptions;
3371 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3372 if (LCImpl != RTLIB::Unsupported) {
3374 Ops.push_back(
Node->getOperand(1));
3377 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3378 "Unexpected atomic op or value type!");
3380 LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
3382 return TLI.makeLibCall(DAG, LCImpl, RetVT,
Ops, CallOptions, SDLoc(Node),
3383 Node->getOperand(0));
3388void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3393 GetExpandedInteger(
N->getOperand(0), InL, InH);
3408 if (Amt.
uge(VTBits)) {
3409 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3410 }
else if (Amt.
ugt(NVTBits)) {
3411 Lo = DAG.getConstant(0,
DL, NVT);
3413 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3414 }
else if (Amt == NVTBits) {
3415 Lo = DAG.getConstant(0,
DL, NVT);
3419 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3421 if (TLI.isOperationLegal(
ISD::FSHL, NVT)) {
3423 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3428 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3430 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3437 if (Amt.
uge(VTBits)) {
3438 Lo =
Hi = DAG.getConstant(0,
DL, NVT);
3439 }
else if (Amt.
ugt(NVTBits)) {
3441 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3442 Hi = DAG.getConstant(0,
DL, NVT);
3443 }
else if (Amt == NVTBits) {
3445 Hi = DAG.getConstant(0,
DL, NVT);
3448 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3450 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3455 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3457 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3460 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3466 if (Amt.
uge(VTBits)) {
3468 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3469 }
else if (Amt.
ugt(NVTBits)) {
3471 DAG.getShiftAmountConstant(Amt - NVTBits, NVT,
DL));
3473 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3474 }
else if (Amt == NVTBits) {
3477 DAG.getShiftAmountConstant(NVTBits - 1, NVT,
DL));
3480 if (TLI.isOperationLegal(
ISD::FSHR, NVT)) {
3482 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3487 DAG.getShiftAmountConstant(Amt, NVT,
DL)),
3489 DAG.getShiftAmountConstant(-Amt + NVTBits, NVT,
DL)));
3492 DAG.getShiftAmountConstant(Amt, NVT,
DL));
3500bool DAGTypeLegalizer::
3502 unsigned Opc =
N->getOpcode();
3503 SDValue
In =
N->getOperand(0);
3504 SDValue Amt =
N->getOperand(1);
3505 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3510 "Expanded integer type size not a power of two!");
3514 KnownBits
Known = DAG.computeKnownBits(Amt);
3517 if (((
Known.Zero |
Known.One) & HighBitMask) == 0)
3522 GetExpandedInteger(In, InL, InH);
3526 if (
Known.One.intersects(HighBitMask)) {
3529 DAG.getConstant(~HighBitMask, dl, ShTy));
3534 Lo = DAG.getConstant(0, dl, NVT);
3535 Hi = DAG.getNode(
ISD::SHL, dl, NVT, InL, Amt);
3538 Hi = DAG.getConstant(0, dl, NVT);
3539 Lo = DAG.getNode(
ISD::SRL, dl, NVT, InH, Amt);
3543 DAG.getConstant(NVTBits - 1, dl, ShTy));
3544 Lo = DAG.getNode(
ISD::SRA, dl, NVT, InH, Amt);
3555 SDValue Amt2 = DAG.getNode(
ISD::XOR, dl, ShTy, Amt,
3556 DAG.getConstant(NVTBits - 1, dl, ShTy));
3572 SDValue Sh1 = DAG.getNode(Op2, dl, NVT, InL, DAG.getConstant(1, dl, ShTy));
3574 SDValue Sh2 = DAG.getNode(Op2, dl, NVT, Sh1, Amt2);
3576 Lo = DAG.getNode(
Opc, dl, NVT, InL, Amt);
3577 Hi = DAG.getNode(
ISD::OR, dl, NVT, DAG.getNode(Op1, dl, NVT, InH, Amt),Sh2);
3589bool DAGTypeLegalizer::
3592 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
3596 "Expanded integer type size not a power of two!");
3601 GetExpandedInteger(
N->getOperand(0), InL, InH);
3603 SDValue NVBitsNode = DAG.getConstant(NVTBits, dl, ShTy);
3604 SDValue AmtExcess = DAG.getNode(
ISD::SUB, dl, ShTy, Amt, NVBitsNode);
3605 SDValue AmtLack = DAG.getNode(
ISD::SUB, dl, ShTy, NVBitsNode, Amt);
3606 SDValue isShort = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3608 SDValue
isZero = DAG.getSetCC(dl, getSetCCResultType(ShTy),
3609 Amt, DAG.getConstant(0, dl, ShTy),
3612 SDValue LoS, HiS, LoL, HiL;
3613 switch (
N->getOpcode()) {
3619 DAG.getNode(
ISD::SHL, dl, NVT, InH, Amt),
3620 DAG.getNode(
ISD::SRL, dl, NVT, InL, AmtLack));
3623 LoL = DAG.getConstant(0, dl, NVT);
3626 Lo = DAG.getSelect(dl, NVT, isShort, LoS, LoL);
3627 Hi = DAG.getSelect(dl, NVT,
isZero, InH,
3628 DAG.getSelect(dl, NVT, isShort, HiS, HiL));
3634 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3637 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3640 HiL = DAG.getConstant(0, dl, NVT);
3643 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3644 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3645 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3651 DAG.getNode(
ISD::SRL, dl, NVT, InL, Amt),
3652 DAG.getNode(
ISD::SHL, dl, NVT, InH, AmtLack));
3656 DAG.getConstant(NVTBits - 1, dl, ShTy));
3659 Lo = DAG.getSelect(dl, NVT,
isZero, InL,
3660 DAG.getSelect(dl, NVT, isShort, LoS, LoL));
3661 Hi = DAG.getSelect(dl, NVT, isShort, HiS, HiL);
3684 SDValue
LHS =
N->getOperand(0);
3685 SDValue
RHS =
N->getOperand(1);
3686 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3691 Res = DAG.getBoolExtOrTrunc(Res,
DL,
N->getValueType(0), NewVT);
3692 SplitInteger(Res,
Lo,
Hi);
3695void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3699 SDValue
LHS =
N->getOperand(0);
3700 SDValue
RHS =
N->getOperand(1);
3704 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3705 unsigned NumHalfBits = NumBits / 2;
3706 if (DAG.ComputeNumSignBits(
LHS) > NumHalfBits &&
3707 DAG.ComputeNumSignBits(
RHS) > NumHalfBits) {
3708 SDValue LHSL, LHSH, RHSL, RHSH;
3709 GetExpandedInteger(
LHS, LHSL, LHSH);
3710 GetExpandedInteger(
RHS, RHSL, RHSH);
3713 Lo = DAG.getNode(
N->getOpcode(),
DL, NVT, LHSL, RHSL);
3715 DAG.getShiftAmountConstant(NumHalfBits - 1, NVT,
DL));
3723 SDValue LHSL, LHSH, RHSL, RHSH;
3724 GetExpandedInteger(
LHS, LHSL, LHSH);
3725 GetExpandedInteger(
RHS, RHSL, RHSH);
3727 EVT CCT = getSetCCResultType(NVT);
3730 DAG.getSetCC(
DL, CCT, LHSH, DAG.getConstant(0,
DL, NVT),
ISD::SETLT);
3732 Lo = DAG.getSelect(
DL, NVT, HiNeg, LHSL, DAG.getAllOnesConstant(
DL, NVT));
3734 Lo = DAG.getSelect(
DL, NVT, HiNeg, DAG.getConstant(0,
DL, NVT), LHSL);
3736 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3740 const APInt *RHSVal =
nullptr;
3742 RHSVal = &RHSConst->getAPIntValue();
3749 SDValue LHSL, LHSH, RHSL, RHSH;
3750 GetExpandedInteger(
LHS, LHSL, LHSH);
3751 GetExpandedInteger(
RHS, RHSL, RHSH);
3753 EVT CCT = getSetCCResultType(NVT);
3759 Hi = DAG.getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3762 SDValue IsHiLeft = DAG.getSetCC(
DL, CCT, LHSH, RHSH, CondC);
3763 SDValue IsHiEq = DAG.getSetCC(
DL, CCT, LHSH, RHSH,
ISD::SETEQ);
3766 SDValue LoCmp = DAG.getSelect(
DL, NVT, IsHiLeft, LHSL, RHSL);
3769 SDValue LoMinMax = DAG.getNode(LoOpc,
DL, NVT, {LHSL, RHSL});
3771 Lo = DAG.getSelect(
DL, NVT, IsHiEq, LoMinMax, LoCmp);
3778 switch (
N->getOpcode()) {
3805 EVT VT =
N->getValueType(0);
3806 EVT CCT = getSetCCResultType(VT);
3809 SplitInteger(Result,
Lo,
Hi);
3813 SDValue ExpandedCMP = TLI.expandCMP(
N, DAG);
3814 SplitInteger(ExpandedCMP,
Lo,
Hi);
3817void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3821 SDValue LHSL, LHSH, RHSL, RHSH;
3822 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3823 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3826 SDValue LoOps[2] = { LHSL, RHSL };
3827 SDValue HiOps[3] = { LHSH, RHSH };
3829 bool HasOpCarry = TLI.isOperationLegalOrCustom(
3831 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3833 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
3837 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3843 Hi = DAG.computeKnownBits(HiOps[2]).isZero()
3856 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3858 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3861 SDVTList VTList = DAG.getVTList(NVT, MVT::Glue);
3875 TLI.isOperationLegalOrCustom(
N->getOpcode() ==
ISD::ADD ?
3877 TLI.getTypeToExpandTo(*DAG.getContext(), NVT));
3881 EVT OvfVT = getSetCCResultType(NVT);
3882 SDVTList VTList = DAG.getVTList(NVT, OvfVT);
3893 SDValue OVF =
Lo.getValue(1);
3897 OVF = DAG.
getNode(
ISD::AND, dl, OvfVT, DAG.getConstant(1, dl, OvfVT), OVF);
3900 OVF = DAG.getZExtOrTrunc(OVF, dl, NVT);
3904 OVF = DAG.getSExtOrTrunc(OVF, dl, NVT);
3916 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
3920 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3923 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3926 Cmp = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3931 Carry = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3933 Carry = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3934 DAG.getConstant(0, dl, NVT));
3937 Hi = DAG.getNode(
ISD::SUB, dl, NVT, HiOps[0], Carry);
3946 DAG.getSetCC(dl, getSetCCResultType(LoOps[0].
getValueType()),
3951 Borrow = DAG.getZExtOrTrunc(Cmp, dl, NVT);
3953 Borrow = DAG.getSelect(dl, NVT, Cmp, DAG.getConstant(1, dl, NVT),
3954 DAG.getConstant(0, dl, NVT));
3960void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3963 SDValue LHSL, LHSH, RHSL, RHSH;
3965 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3966 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3967 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3968 SDValue LoOps[2] = { LHSL, RHSL };
3969 SDValue HiOps[3] = { LHSH, RHSH };
3983 ReplaceValueWith(SDValue(
N, 1),
Hi.getValue(1));
3986void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3989 SDValue LHSL, LHSH, RHSL, RHSH;
3991 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3992 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3993 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(), MVT::Glue);
3994 SDValue LoOps[3] = { LHSL, RHSL,
N->
getOperand(2) };
3995 SDValue HiOps[3] = { LHSH, RHSH };
3997 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3999 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4003 ReplaceValueWith(SDValue(
N, 1),
Hi.getValue(1));
4006void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
4008 SDValue
LHS =
N->getOperand(0);
4009 SDValue
RHS =
N->getOperand(1);
4014 unsigned CarryOp, NoCarryOp;
4016 switch(
N->getOpcode()) {
4031 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4032 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4036 SDValue LHSL, LHSH, RHSL, RHSH;
4037 GetExpandedInteger(
LHS, LHSL, LHSH);
4038 GetExpandedInteger(
RHS, RHSL, RHSH);
4039 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4040 SDValue LoOps[2] = { LHSL, RHSL };
4041 SDValue HiOps[3] = { LHSH, RHSH };
4043 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4045 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
4051 SDValue Sum = DAG.getNode(NoCarryOp, dl,
LHS.getValueType(),
LHS,
RHS);
4052 SplitInteger(Sum,
Lo,
Hi);
4058 Ovf = DAG.getSetCC(dl,
N->getValueType(1),
Or,
4059 DAG.getConstant(0, dl,
Lo.getValueType()),
ISD::SETEQ);
4063 DAG.getSetCC(dl,
N->getValueType(1),
LHS,
4068 Ovf = DAG.getSetCC(dl,
N->getValueType(1), Sum,
LHS,
Cond);
4074 ReplaceValueWith(SDValue(
N, 1), Ovf);
4080 SDValue LHSL, LHSH, RHSL, RHSH;
4082 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4083 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4084 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4085 SDValue LoOps[3] = { LHSL, RHSL,
N->
getOperand(2) };
4086 SDValue HiOps[3] = { LHSH, RHSH, SDValue() };
4088 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
4090 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
4094 ReplaceValueWith(SDValue(
N, 1),
Hi.getValue(1));
4097void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
4100 SDValue LHSL, LHSH, RHSL, RHSH;
4102 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4103 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
4104 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
N->getValueType(1));
4109 Lo = DAG.getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->
getOperand(2) });
4110 Hi = DAG.getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
4114 ReplaceValueWith(SDValue(
N, 1),
Hi.getValue(1));
4117void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
4119 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4121 SDValue
Op =
N->getOperand(0);
4122 if (
Op.getValueType().bitsLE(NVT)) {
4125 Hi = DAG.getUNDEF(NVT);
4129 assert(getTypeAction(
Op.getValueType()) ==
4131 "Only know how to promote this result!");
4132 SDValue Res = GetPromotedInteger(
Op);
4134 "Operand over promoted?");
4136 SplitInteger(Res,
Lo,
Hi);
4140void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
4143 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4144 EVT NVT =
Lo.getValueType();
4149 if (NVTBits < EVTBits) {
4152 EVTBits - NVTBits)));
4157 DAG.getShiftAmountConstant(NVTBits - 1, NVT, dl));
4161void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
4164 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4165 EVT NVT =
Lo.getValueType();
4170 if (NVTBits < EVTBits) {
4173 EVTBits - NVTBits)));
4177 Hi = DAG.getConstant(0, dl, NVT);
4181void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
4184 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4189void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
4192 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
4201 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4202 EVT NVT =
Lo.getValueType();
4205 Hi = DAG.getConstant(0, dl, NVT);
4208void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
4210 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4213 const APInt &Cst =
Constant->getAPIntValue();
4214 bool IsTarget =
Constant->isTargetOpcode();
4215 bool IsOpaque =
Constant->isOpaque();
4217 Lo = DAG.getConstant(Cst.
trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
4218 Hi = DAG.getConstant(Cst.
lshr(NBitWidth).
trunc(NBitWidth), dl, NVT, IsTarget,
4225 SDValue N0 =
N->getOperand(0);
4226 GetExpandedInteger(N0,
Lo,
Hi);
4227 EVT NVT =
Lo.getValueType();
4232 unsigned NumSignBits = DAG.ComputeNumSignBits(N0);
4237 Lo = DAG.getNode(AbsOpc, dl, NVT,
Lo);
4238 Hi = DAG.getConstant(0, dl, NVT);
4248 bool HasSubCarry = TLI.isOperationLegalOrCustom(
4251 SDValue Sign = DAG.getNode(
4253 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - 1, NVT, dl));
4254 SDVTList VTList = DAG.getVTList(NVT, getSetCCResultType(NVT));
4263 EVT VT =
N->getValueType(0);
4264 SDValue Neg = DAG.getNode(
ISD::SUB, dl, VT,
4265 DAG.getConstant(0, dl, VT), N0);
4266 SDValue NegLo, NegHi;
4267 SplitInteger(Neg, NegLo, NegHi);
4269 SDValue HiIsNeg = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4271 Lo = DAG.getSelect(dl, NVT, HiIsNeg, NegLo,
Lo);
4272 Hi = DAG.getSelect(dl, NVT, HiIsNeg, NegHi,
Hi);
4275void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
4279 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4280 EVT NVT =
Lo.getValueType();
4282 SDValue HiNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi,
4285 SDValue LoLZ = DAG.getNode(
N->getOpcode(), dl, NVT,
Lo);
4288 Lo = DAG.getSelect(dl, NVT, HiNotZero, HiLZ,
4289 DAG.getNode(
ISD::ADD, dl, NVT, LoLZ,
4292 Hi = DAG.getConstant(0, dl, NVT);
4300 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4301 EVT NVT =
Lo.getValueType();
4304 SDValue Constant0 = DAG.getConstant(0, dl, NVT);
4305 SDValue ConstantBWM1 = DAG.getConstant(NVTBits - 1, dl, NVT);
4307 SDValue HiCTLS = DAG.getNode(
ISD::CTLS, dl, NVT,
Hi);
4308 SDValue IsAllSignBits = DAG.getSetCC(dl, getSetCCResultType(NVT), HiCTLS,
4310 SDValue IsNegative =
4311 DAG.getSetCC(dl, getSetCCResultType(NVT),
Hi, Constant0,
ISD::SETLT);
4312 SDValue AdjustedLo =
4313 DAG.getSelect(dl, NVT, IsNegative, DAG.getNOT(dl,
Lo, NVT),
Lo);
4314 SDValue LoCLZ = DAG.getNode(
ISD::CTLZ, dl, NVT, AdjustedLo);
4315 Lo = DAG.getSelect(dl, NVT, IsAllSignBits,
4316 DAG.getNode(
ISD::ADD, dl, NVT, LoCLZ, ConstantBWM1),
4318 Hi = DAG.getConstant(0, dl, NVT);
4322 SDValue
Result = TLI.expandABD(
N, DAG);
4323 SplitInteger(Result,
Lo,
Hi);
4327 SDValue
Op =
N->getOperand(0);
4328 EVT VT =
N->getValueType(0);
4333 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
4334 "LibCall explicitly requested, but not available");
4336 if (RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
4337 TargetLowering::MakeLibCallOptions CallOptions;
4341 TLI.makeLibCall(DAG, LCImpl, IntVT,
Op, CallOptions,
DL).first;
4342 SplitInteger(DAG.getSExtOrTrunc(Res,
DL, VT),
Lo,
Hi);
4350 GetExpandedInteger(
Op,
Lo,
Hi);
4351 EVT NVT =
Lo.getValueType();
4354 Hi = DAG.getConstant(0,
DL, NVT);
4357void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
4361 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4362 EVT NVT =
Lo.getValueType();
4364 SDValue LoNotZero = DAG.getSetCC(dl, getSetCCResultType(NVT),
Lo,
4368 SDValue HiLZ = DAG.
getNode(
N->getOpcode(), dl, NVT,
Hi);
4370 Lo = DAG.getSelect(dl, NVT, LoNotZero, LoLZ,
4371 DAG.getNode(
ISD::ADD, dl, NVT, HiLZ,
4374 Hi = DAG.getConstant(0, dl, NVT);
4380 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4387 DAG.getShiftAmountConstant(NBitWidth - 1, NVT, dl));
4391 ReplaceValueWith(SDValue(
N, 1), Chain);
4399 Chain =
Op.getValue(1);
4408 EVT VT =
N->getValueType(0);
4412 bool IsStrict =
N->isStrictFPOpcode();
4413 SDValue Chain = IsStrict ?
N->getOperand(0) : SDValue();
4414 SDValue
Op =
N->getOperand(IsStrict ? 1 : 0);
4418 EVT SrcVT =
Op.getValueType();
4419 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4423 if (TLI.isTypeLegal(SrcVT) && MinIntBits <= NVT.
getSizeInBits()) {
4424 unsigned NewOpc = TLI.getPreferredFPToIntOpcode(
N->getOpcode(), SrcVT, NVT);
4426 Lo = DAG.getNode(NewOpc, dl, {NVT, MVT::Other}, {Chain,
Op});
4427 ReplaceValueWith(SDValue(
N, 1),
Lo.getValue(1));
4429 Lo = DAG.getNode(NewOpc, dl, NVT,
Op);
4432 DAG.getShiftAmountConstant(
4434 : DAG.getConstant(0, dl, NVT);
4440 Op.getValueType() == MVT::bf16) {
4446 EVT OpVT =
Op.getValueType();
4450 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4451 TargetLowering::MakeLibCallOptions CallOptions;
4456 std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, VT,
Op,
4457 CallOptions, dl, Chain);
4458 SplitInteger(Tmp.first,
Lo,
Hi);
4461 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
4466 SDValue Res = TLI.expandFP_TO_INT_SAT(
N, DAG);
4467 SplitInteger(Res,
Lo,
Hi);
4473 bool IsStrict =
N->isStrictFPOpcode();
4474 SDValue
Op =
N->getOperand(IsStrict ? 1 : 0);
4475 SDValue Chain = IsStrict ?
N->getOperand(0) : SDValue();
4477 EVT VT =
Op.getValueType();
4479 if (VT == MVT::f16) {
4485 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
4488 LC = RTLIB::getLROUND(VT);
4489 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4492 LC = RTLIB::getLRINT(VT);
4493 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4496 LC = RTLIB::getLLROUND(VT);
4497 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4500 LC = RTLIB::getLLRINT(VT);
4501 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4505 EVT RetVT =
N->getValueType(0);
4507 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4508 if (LCImpl == RTLIB::Unsupported) {
4509 DAG.getContext()->emitError(Twine(
"no libcall available for ") +
4510 N->getOperationName(&DAG));
4511 SDValue
Poison = DAG.getPOISON(
N->getValueType(0));
4512 SplitInteger(Poison,
Lo,
Hi);
4513 if (
N->isStrictFPOpcode())
4514 ReplaceValueWith(SDValue(
N, 1),
N->getOperand(0));
4518 TargetLowering::MakeLibCallOptions CallOptions;
4520 std::pair<SDValue, SDValue> Tmp =
4521 TLI.makeLibCall(DAG, LCImpl, RetVT,
Op, CallOptions, dl, Chain);
4522 SplitInteger(Tmp.first,
Lo,
Hi);
4524 if (
N->isStrictFPOpcode())
4525 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
4528void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4530 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4533 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4539 EVT VT =
N->getValueType(0);
4540 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4541 SDValue Ch =
N->getChain();
4542 SDValue Ptr =
N->getBasePtr();
4545 MMOMetadata
Metadata =
N->getMMOMetadataForSubAccess();
4550 if (
N->getMemoryVT().bitsLE(NVT)) {
4551 EVT MemVT =
N->getMemoryVT();
4553 Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(), MemVT,
4562 unsigned LoSize =
Lo.getValueSizeInBits();
4564 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
4567 Hi = DAG.getConstant(0, dl, NVT);
4571 Hi = DAG.getUNDEF(NVT);
4573 }
else if (DAG.getDataLayout().isLittleEndian()) {
4575 Lo = DAG.getLoad(NVT, dl, Ch, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
4578 unsigned ExcessBits =
4585 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
4586 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4596 EVT MemVT =
N->getMemoryVT();
4599 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4602 Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr,
N->getPointerInfo(),
4611 N->getPointerInfo().getWithOffset(IncrementSize),
4625 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
4629 DAG.getShiftAmountConstant(
4636 ReplaceValueWith(SDValue(
N, 1), Ch);
4639void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4642 SDValue LL, LH, RL, RH;
4643 GetExpandedInteger(
N->getOperand(0), LL, LH);
4644 GetExpandedInteger(
N->getOperand(1), RL, RH);
4648 Flags.setDisjoint(
N->getFlags().hasDisjoint());
4650 Lo = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LL, RL, Flags);
4651 Hi = DAG.getNode(
N->getOpcode(), dl, LL.
getValueType(), LH, RH, Flags);
4654void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4656 EVT VT =
N->getValueType(0);
4657 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4660 SDValue LL, LH, RL, RH;
4661 GetExpandedInteger(
N->getOperand(0), LL, LH);
4662 GetExpandedInteger(
N->getOperand(1), RL, RH);
4664 if (TLI.expandMUL(
N,
Lo,
Hi, NVT, DAG,
4671 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
4672 if (LCImpl == RTLIB::Unsupported) {
4675 TLI.forceExpandMultiply(DAG, dl,
false,
Lo,
Hi, LL, RL, LH, RH);
4681 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4682 TargetLowering::MakeLibCallOptions CallOptions;
4684 SplitInteger(TLI.makeLibCall(DAG, LCImpl, VT,
Ops, CallOptions, dl).first,
Lo,
4691 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
4692 SDVTList VTs = DAG.getVTList(NVT, NVT, MVT::Other);
4693 SDValue
R = DAG.getNode(
N->getOpcode(),
DL, VTs,
N->getOperand(0));
4696 ReplaceValueWith(SDValue(
N, 1),
R.getValue(2));
4700 SDValue
Result = TLI.expandAVG(
N, DAG);
4701 SplitInteger(Result,
Lo,
Hi);
4706 SDValue
Result = TLI.expandAddSubSat(
N, DAG);
4707 SplitInteger(Result,
Lo,
Hi);
4712 SDValue
Result = TLI.expandShlSat(
N, DAG);
4713 SplitInteger(Result,
Lo,
Hi);
4724 EVT VT =
N->getValueType(0);
4726 SDValue
LHS =
N->getOperand(0);
4727 SDValue
RHS =
N->getOperand(1);
4728 uint64_t Scale =
N->getConstantOperandVal(2);
4740 EVT BoolVT = getSetCCResultType(VT);
4742 Result = DAG.getNode(MulOp, dl, DAG.getVTList(VT, BoolVT),
LHS,
RHS);
4743 SDValue Product =
Result.getValue(0);
4744 SDValue Overflow =
Result.getValue(1);
4748 SDValue SatMin = DAG.getConstant(MinVal, dl, VT);
4749 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4750 SDValue
Zero = DAG.getConstant(0, dl, VT);
4754 SDValue ProdNeg = DAG.getSetCC(dl, BoolVT,
Xor, Zero,
ISD::SETLT);
4755 Result = DAG.getSelect(dl, VT, ProdNeg, SatMin, SatMax);
4756 Result = DAG.getSelect(dl, VT, Overflow, Result, Product);
4761 SDValue SatMax = DAG.getConstant(MaxVal, dl, VT);
4762 Result = DAG.getSelect(dl, VT, Overflow, SatMax, Product);
4765 SplitInteger(Result,
Lo,
Hi);
4771 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4773 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
4774 SDValue LL, LH, RL, RH;
4775 GetExpandedInteger(
LHS, LL, LH);
4776 GetExpandedInteger(
RHS, RL, RH);
4780 if (!TLI.expandMUL_LOHI(LoHiOp, VT, dl,
LHS,
RHS, Result, NVT, DAG,
4786 SDValue LoTmp, HiTmp;
4787 TLI.forceExpandWideMUL(DAG, dl,
Signed,
LHS,
RHS, LoTmp, HiTmp);
4788 SplitInteger(LoTmp, Result[0], Result[1]);
4789 SplitInteger(HiTmp, Result[2], Result[3]);
4791 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4794 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4795 "the size of the current value type");
4817 if (Scale % NVTSize) {
4818 SDValue ShiftAmount = DAG.getShiftAmountConstant(Scale % NVTSize, NVT, dl);
4821 Hi = DAG.getNode(
ISD::FSHR, dl, NVT, Result[Part0 + 2], Result[Part0 + 1],
4833 if (Scale == VTSize)
4848 SDValue ResultHL =
Result[2];
4849 SDValue ResultHH =
Result[3];
4851 SDValue SatMax, SatMin;
4852 SDValue NVTZero = DAG.getConstant(0, dl, NVT);
4853 SDValue NVTNeg1 = DAG.getAllOnesConstant(dl, NVT);
4854 EVT BoolNVT = getSetCCResultType(NVT);
4857 if (Scale < NVTSize) {
4859 SDValue HLAdjusted =
4860 DAG.getNode(
ISD::SRL, dl, NVT, ResultHL,
4861 DAG.getShiftAmountConstant(Scale, NVT, dl));
4862 SDValue Tmp = DAG.getNode(
ISD::OR, dl, NVT, HLAdjusted, ResultHH);
4863 SatMax = DAG.getSetCC(dl, BoolNVT, Tmp, NVTZero,
ISD::SETNE);
4864 }
else if (Scale == NVTSize) {
4866 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETNE);
4867 }
else if (Scale < VTSize) {
4869 SDValue HHAdjusted =
4870 DAG.getNode(
ISD::SRL, dl, NVT, ResultHH,
4871 DAG.getShiftAmountConstant(Scale - NVTSize, NVT, dl));
4872 SatMax = DAG.getSetCC(dl, BoolNVT, HHAdjusted, NVTZero,
ISD::SETNE);
4875 "(and saturation can't happen with Scale==VTSize).");
4877 Hi = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Hi);
4878 Lo = DAG.getSelect(dl, NVT, SatMax, NVTNeg1,
Lo);
4882 if (Scale < NVTSize) {
4887 unsigned OverflowBits = VTSize - Scale + 1;
4888 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4889 "Extent of overflow bits must start within HL");
4890 SDValue HLHiMask = DAG.getConstant(
4892 SDValue HLLoMask = DAG.getConstant(
4895 SDValue HHGT0 = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETGT);
4896 SDValue HHEQ0 = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETEQ);
4897 SDValue HLUGT = DAG.getSetCC(dl, BoolNVT, ResultHL, HLLoMask,
ISD::SETUGT);
4899 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLUGT));
4901 SDValue HHLT = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTNeg1,
ISD::SETLT);
4902 SDValue HHEQ = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTNeg1,
ISD::SETEQ);
4903 SDValue HLULT = DAG.getSetCC(dl, BoolNVT, ResultHL, HLHiMask,
ISD::SETULT);
4905 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLULT));
4906 }
else if (Scale == NVTSize) {
4908 SDValue HHGT0 = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETGT);
4909 SDValue HHEQ0 = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTZero,
ISD::SETEQ);
4910 SDValue HLNeg = DAG.getSetCC(dl, BoolNVT, ResultHL, NVTZero,
ISD::SETLT);
4912 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ0, HLNeg));
4914 SDValue HHLT = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTNeg1,
ISD::SETLT);
4915 SDValue HHEQ = DAG.getSetCC(dl, BoolNVT, ResultHH, NVTNeg1,
ISD::SETEQ);
4916 SDValue HLPos = DAG.getSetCC(dl, BoolNVT, ResultHL, NVTZero,
ISD::SETGE);
4918 DAG.getNode(
ISD::AND, dl, BoolNVT, HHEQ, HLPos));
4919 }
else if (Scale < VTSize) {
4922 unsigned OverflowBits = VTSize - Scale + 1;
4923 SDValue HHHiMask = DAG.getConstant(
4925 SDValue HHLoMask = DAG.getConstant(
4927 SatMax = DAG.getSetCC(dl, BoolNVT, ResultHH, HHLoMask,
ISD::SETGT);
4928 SatMin = DAG.getSetCC(dl, BoolNVT, ResultHH, HHHiMask,
ISD::SETLT);
4935 Hi = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxHi, dl, NVT),
Hi);
4936 Lo = DAG.getSelect(dl, NVT, SatMax, DAG.getConstant(MaxLo, dl, NVT),
Lo);
4939 Hi = DAG.getSelect(dl, NVT, SatMin, DAG.getConstant(MinHi, dl, NVT),
Hi);
4940 Lo = DAG.getSelect(dl, NVT, SatMin, NVTZero,
Lo);
4947 SDValue Res = TLI.expandFixedPointDiv(
N->getOpcode(), dl,
N->getOperand(0),
4949 N->getConstantOperandVal(2), DAG);
4953 N->getConstantOperandVal(2), TLI, DAG);
4954 SplitInteger(Res,
Lo,
Hi);
4957void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
4960 "Node has unexpected Opcode");
4961 SDValue
LHS =
Node->getOperand(0);
4962 SDValue
RHS =
Node->getOperand(1);
4970 bool HasCarryOp = TLI.isOperationLegalOrCustom(
4971 CarryOp, TLI.getTypeToExpandTo(*DAG.getContext(),
LHS.getValueType()));
4975 SDValue LHSL, LHSH, RHSL, RHSH;
4976 GetExpandedInteger(
LHS, LHSL, LHSH);
4977 GetExpandedInteger(
RHS, RHSL, RHSH);
4978 SDVTList VTList = DAG.getVTList(LHSL.
getValueType(),
Node->getValueType(1));
4981 Hi = DAG.getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.
getValue(1) });
4990 SplitInteger(Sum,
Lo,
Hi);
5015 EVT VT =
LHS.getValueType();
5018 SignsMatch = DAG.getNOT(dl, SignsMatch, VT);
5022 EVT OType =
Node->getValueType(1);
5023 Ovf = DAG.getSetCC(dl, OType, Ovf, DAG.getConstant(0, dl, VT),
ISD::SETLT);
5027 ReplaceValueWith(SDValue(Node, 1), Ovf);
5030void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
5032 EVT VT =
N->getValueType(0);
5034 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5043 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
5045 TargetLowering::MakeLibCallOptions CallOptions;
5047 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5050void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
5053 SDValue Shiftee =
N->getOperand(0);
5055 SDValue ShAmt =
N->getOperand(1);
5060 LoadVT = TLI.getTypeToTransformTo(*DAG.getContext(), LoadVT);
5061 }
while (!TLI.isTypeLegal(LoadVT));
5066 "Shifting unit is not a a power of two!");
5068 const bool IsOneStepShift =
5069 DAG.computeKnownBits(ShAmt).countMinTrailingZeros() >=
5074 if (!IsOneStepShift)
5075 ShAmt = DAG.getFreeze(ShAmt);
5078 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
5079 unsigned VTByteWidth = VTBitWidth / 8;
5081 "Shiftee type size is not a power of two!");
5082 unsigned StackSlotByteWidth = 2 * VTByteWidth;
5083 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
5088 Align StackAlign = DAG.getReducedAlign(StackSlotVT,
false);
5090 DAG.CreateStackTemporary(StackSlotVT.
getStoreSize(), StackAlign);
5091 EVT PtrTy =
StackPtr.getValueType();
5092 SDValue Ch = DAG.getEntryNode();
5095 DAG.getMachineFunction(),
5101 unsigned WideningOpc =
5103 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
5106 SDValue AllZeros = DAG.getConstant(0, dl, VT);
5110 Ch = DAG.getStore(Ch, dl, Init, StackPtr, StackPtrInfo, StackAlign);
5116 Flags.setExact(IsOneStepShift);
5117 SDValue SrlTmp = DAG.getNode(
5119 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT), Flags);
5121 DAG.getNode(
ISD::SHL, dl, ShAmtVT, SrlTmp,
5122 DAG.getConstant(
Log2_32(ShiftUnitInBits), dl, ShAmtVT));
5124 SDValue ByteOffset =
5125 DAG.getNode(
ISD::SRL, dl, ShAmtVT, BitOffset,
5130 DAG.getConstant(VTByteWidth - 1, dl, ShAmtVT));
5137 if (DAG.getDataLayout().isBigEndian())
5138 WillIndexUpwards = !WillIndexUpwards;
5140 SDValue AdjStackPtr;
5141 if (WillIndexUpwards) {
5144 AdjStackPtr = DAG.getMemBasePlusOffset(
5145 StackPtr, DAG.getConstant(VTByteWidth, dl, PtrTy), dl);
5146 ByteOffset = DAG.getNegative(ByteOffset, dl, ShAmtVT);
5150 ByteOffset = DAG.getSExtOrTrunc(ByteOffset, dl, PtrTy);
5151 AdjStackPtr = DAG.getMemBasePlusOffset(AdjStackPtr, ByteOffset, dl);
5155 DAG.getLoad(VT, dl, Ch, AdjStackPtr,
5160 if (!IsOneStepShift) {
5162 DAG.getNode(
ISD::AND, dl, ShAmtVT, ShAmt,
5163 DAG.getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
5164 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
5168 SplitInteger(Res,
Lo,
Hi);
5171void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
5173 EVT VT =
N->getValueType(0);
5174 unsigned Opc =
N->getOpcode();
5180 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
5184 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
5201 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
5203 const bool LegalOrCustom =
5207 unsigned ExpansionFactor = 1;
5209 for (EVT TmpVT = NVT;;) {
5210 EVT NewTMPVT = TLI.getTypeToTransformTo(*DAG.getContext(), TmpVT);
5211 if (NewTMPVT == TmpVT)
5218 TLI.preferredShiftLegalizationStrategy(DAG,
N, ExpansionFactor);
5221 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
5223 if (LegalOrCustom &&
5227 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
5233 SDValue ShiftOp =
N->getOperand(1);
5234 EVT ShiftTy = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
5236 ShiftOp = DAG.getZExtOrTrunc(ShiftOp, dl, ShiftTy);
5238 SDValue
Ops[] = { LHSL, LHSH, ShiftOp };
5239 Lo = DAG.
getNode(PartsOpc, dl, DAG.getVTList(VT, VT),
Ops);
5240 Hi =
Lo.getValue(1);
5245 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
5259 if (RTLIB::LibcallImpl LibcallImpl = DAG.getLibcalls().getLibcallImpl(LC)) {
5262 SDValue ShAmt = DAG.getZExtOrTrunc(
N->getOperand(1), dl, ShAmtTy);
5263 SDValue
Ops[2] = {
N->getOperand(0), ShAmt};
5264 TargetLowering::MakeLibCallOptions CallOptions;
5267 TLI.makeLibCall(DAG, LibcallImpl, VT,
Ops, CallOptions, dl).first,
Lo,
5272 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
5276void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
5278 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5280 SDValue
Op =
N->getOperand(0);
5281 if (
Op.getValueType().bitsLE(NVT)) {
5287 DAG.getShiftAmountConstant(LoSize - 1, NVT, dl));
5291 assert(getTypeAction(
Op.getValueType()) ==
5293 "Only know how to promote this result!");
5294 SDValue Res = GetPromotedInteger(
Op);
5296 "Operand over promoted?");
5298 SplitInteger(Res,
Lo,
Hi);
5306void DAGTypeLegalizer::
5309 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5312 if (EVT.
bitsLE(
Lo.getValueType())) {
5320 DAG.getShiftAmountConstant(
Hi.getValueSizeInBits() - 1,
5321 Hi.getValueType(), dl));
5332void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
5334 EVT VT =
N->getValueType(0);
5336 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5345 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
5347 TargetLowering::MakeLibCallOptions CallOptions;
5349 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5352void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5354 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5364void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5366 EVT VT =
N->getValueType(0);
5384 SDValue
LHS =
N->getOperand(0),
RHS =
N->getOperand(1);
5385 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5386 GetExpandedInteger(
LHS, LHSLow, LHSHigh);
5387 GetExpandedInteger(
RHS, RHSLow, RHSHigh);
5389 EVT BitVT =
N->getValueType(1);
5390 SDVTList VTHalfWithO = DAG.getVTList(HalfVT, BitVT);
5392 SDValue HalfZero = DAG.getConstant(0, dl, HalfVT);
5394 DAG.getSetCC(dl, BitVT, LHSHigh, HalfZero,
ISD::SETNE),
5395 DAG.getSetCC(dl, BitVT, RHSHigh, HalfZero,
ISD::SETNE));
5397 SDValue One = DAG.getNode(
ISD::UMULO, dl, VTHalfWithO, LHSHigh, RHSLow);
5400 SDValue Two = DAG.getNode(
ISD::UMULO, dl, VTHalfWithO, RHSHigh, LHSLow);
5403 SDValue HighSum = DAG.getNode(
ISD::ADD, dl, HalfVT, One, Two);
5411 SDValue Three = DAG.getNode(
ISD::MUL, dl, VT,
5414 SplitInteger(Three,
Lo,
Hi);
5418 ReplaceValueWith(SDValue(
N, 1), Overflow);
5423 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
5428 RTLIB::LibcallImpl LCImpl = DAG.getLibcalls().getLibcallImpl(LC);
5432 if (LCImpl == RTLIB::Unsupported ||
5434 DAG.getMachineFunction().getName()) {
5436 SDValue MulLo, MulHi;
5437 TLI.forceExpandWideMUL(DAG, dl,
true,
N->getOperand(0),
5438 N->getOperand(1), MulLo, MulHi);
5439 SDValue
SRA = DAG.getNode(
5443 DAG.getSetCC(dl,
N->getValueType(1), MulHi, SRA,
ISD::SETNE);
5444 SplitInteger(MulLo,
Lo,
Hi);
5445 ReplaceValueWith(SDValue(
N, 1), Overflow);
5449 SDValue Temp = DAG.CreateStackTemporary(PtrVT);
5452 DAG.getStore(DAG.getEntryNode(), dl, DAG.getConstant(0, dl, PtrVT), Temp,
5453 MachinePointerInfo());
5456 for (
const SDValue &
Op :
N->op_values()) {
5457 EVT ArgVT =
Op.getValueType();
5459 TargetLowering::ArgListEntry
Entry(
Op, ArgTy);
5460 Entry.IsSExt =
true;
5461 Entry.IsZExt =
false;
5462 Args.push_back(Entry);
5466 TargetLowering::ArgListEntry
Entry(
5468 Entry.IsSExt =
true;
5469 Entry.IsZExt =
false;
5470 Args.push_back(Entry);
5472 SDValue
Func = DAG.getExternalSymbol(LCImpl, PtrVT);
5474 TargetLowering::CallLoweringInfo CLI(DAG);
5477 .setLibCallee(DAG.getLibcalls().getLibcallImplCallingConv(LCImpl), RetTy,
5478 Func, std::move(Args))
5481 std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
5483 SplitInteger(CallInfo.first,
Lo,
Hi);
5485 DAG.getLoad(PtrVT, dl, CallInfo.second, Temp, MachinePointerInfo());
5486 SDValue Ofl = DAG.getSetCC(dl,
N->getValueType(1), Temp2,
5487 DAG.getConstant(0, dl, PtrVT),
5490 ReplaceValueWith(SDValue(
N, 1), Ofl);
5493void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5495 EVT VT =
N->getValueType(0);
5497 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5507 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5509 if (isTypeLegal(NVT)) {
5511 GetExpandedInteger(
N->getOperand(0), InL, InH);
5513 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5522 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5524 TargetLowering::MakeLibCallOptions CallOptions;
5525 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5528void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5530 EVT VT =
N->getValueType(0);
5532 SDValue
Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5542 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5544 if (isTypeLegal(NVT)) {
5546 GetExpandedInteger(
N->getOperand(0), InL, InH);
5548 if (TLI.expandDIVREMByConstant(
N, Result, NVT, DAG, InL, InH)) {
5557 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5559 TargetLowering::MakeLibCallOptions CallOptions;
5560 SplitInteger(TLI.makeLibCall(DAG, LC, VT,
Ops, CallOptions, dl).first,
Lo,
Hi);
5563void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5565 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
5567 SDValue
Op =
N->getOperand(0);
5568 if (
Op.getValueType().bitsLE(NVT)) {
5571 Hi = DAG.getConstant(0, dl, NVT);
5575 assert(getTypeAction(
Op.getValueType()) ==
5577 "Only know how to promote this result!");
5578 SDValue Res = GetPromotedInteger(
Op);
5580 "Operand over promoted?");
5582 SplitInteger(Res,
Lo,
Hi);
5584 Hi = DAG.getZeroExtendInReg(
Hi, dl,
5590void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5594 SDVTList VTs = DAG.getVTList(VT, MVT::i1, MVT::Other);
5595 SDValue
Zero = DAG.getConstant(0, dl, VT);
5596 SDValue
Swap = DAG.getAtomicCmpSwap(
5601 ReplaceValueWith(SDValue(
N, 0),
Swap.getValue(0));
5602 ReplaceValueWith(SDValue(
N, 1),
Swap.getValue(2));
5605void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5609 SDValue Res = TLI.expandVecReduce(
N, DAG);
5610 SplitInteger(Res,
Lo,
Hi);
5613void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5618 SDValue Res = DAG.
getNode(Opcode,
DL,
N->getValueType(0),
N->getOperand(0),
5619 N->getOperand(0),
N->getOperand(1));
5620 SplitInteger(Res,
Lo,
Hi);
5626 SDValue In1, In2, In3, In4;
5627 GetExpandedInteger(
N->getOperand(0), In3, In4);
5628 GetExpandedInteger(
N->getOperand(1), In1, In2);
5632 unsigned Opc =
N->getOpcode();
5635 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5639 SDValue AndNode = DAG.getNode(
ISD::AND,
DL, ShAmtVT, ShAmt,
5640 DAG.getConstant(HalfVTBits,
DL, ShAmtVT));
5642 DAG.getSetCC(
DL, ShAmtCCVT, AndNode, DAG.getConstant(0,
DL, ShAmtVT),
5646 EVT NewShAmtVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
5647 SDValue NewShAmt = DAG.getAnyExtOrTrunc(ShAmt,
DL, NewShAmtVT);
5652 Lo = DAG.getNode(
Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5653 Hi = DAG.getNode(
Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5658 SDValue Res = TLI.expandCLMUL(
N, DAG);
5659 return SplitInteger(Res,
Lo,
Hi);
5662 SDValue LL, LH, RL, RH;
5663 GetExpandedInteger(
N->getOperand(0), LL, LH);
5664 GetExpandedInteger(
N->getOperand(1), RL, RH);
5675 SDValue HiLoCross1 = DAG.getNode(
ISD::CLMUL,
DL, HalfVT, LL, RH);
5676 SDValue HiLoCross2 = DAG.getNode(
ISD::CLMUL,
DL, HalfVT, LH, RL);
5677 SDValue HiLoCross = DAG.getNode(
ISD::XOR,
DL, HalfVT, HiLoCross1, HiLoCross2);
5678 Hi = DAG.getNode(
ISD::XOR,
DL, HalfVT, LoH, HiLoCross);
5682 SDValue Res = TLI.expandPEXT(
N, DAG);
5683 SplitInteger(Res,
Lo,
Hi);
5687 SDValue Res = TLI.expandPDEP(
N, DAG);
5688 SplitInteger(Res,
Lo,
Hi);
5692 SDValue Res = TLI.expandMULH(
N, DAG);
5693 SplitInteger(Res,
Lo,
Hi);
5698 EVT VT =
N->getValueType(0);
5705 SDValue VScaleBase = DAG.getVScale(dl, HalfVT, One);
5708 SplitInteger(Res,
Lo,
Hi);
5715 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
5716 ReplaceValueWith(SDValue(
N, 1),
N->getOperand(0));
5718 std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(
N->getValueType(0));
5719 Lo = DAG.getPOISON(LoVT);
5720 Hi = DAG.getPOISON(HiVT);
5727 EVT VT =
N->getSimpleValueType(0);
5728 EVT IdxVT = TLI.getVectorIdxTy(DAG.getDataLayout());
5730 "VectorIdxTy should be smaller than type to be expanded?");
5732 SDValue Res = DAG.
getNode(
N->getOpcode(), SDLoc(
N), IdxVT,
N->getOperand(0));
5734 SplitInteger(Res,
Lo,
Hi);
5745bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5747 SDValue Res = SDValue();
5749 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5752 switch (
N->getOpcode()) {
5755 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5756 N->dump(&DAG);
dbgs() <<
"\n";
5761 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5765 Res = ExpandOp_FAKE_USE(
N);
5769 Res = TLI.expandLoopDependenceMask(
N, DAG);
5775 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5788 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5793 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5797 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5800 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5802 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5803 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5804 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5807 Res = ExpandIntOp_WRITE_REGISTER(
N, OpNo);
5812 if (!Res.
getNode())
return false;
5820 "Invalid operand expansion");
5822 ReplaceValueWith(SDValue(
N, 0), Res);
5828void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5832 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5833 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5834 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5847 NewRHS = DAG.getConstant(0, dl, NewLHS.
getValueType());
5854 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5855 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5883 SDValue LoCmp, HiCmp;
5885 LoCmp = TLI.SimplifySetCC(getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5886 RHSLo, LowCC,
false, DagCombineInfo, dl);
5888 LoCmp = DAG.getSetCC(dl, getSetCCResultType(LHSLo.
getValueType()), LHSLo,
5891 HiCmp = TLI.SimplifySetCC(getSetCCResultType(LHSHi.
getValueType()), LHSHi,
5892 RHSHi, CCCode,
false, DagCombineInfo, dl);
5896 LHSHi, RHSHi, DAG.getCondCode(CCCode));
5905 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5907 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5916 if (LHSHi == RHSHi) {
5925 EVT ExpandVT = TLI.getTypeToExpandTo(*DAG.getContext(), HiVT);
5926 bool HasSETCCCARRY = TLI.isOperationLegalOrCustom(
ISD::SETCCCARRY, ExpandVT);
5929 if (HasSETCCCARRY) {
5932 bool FlipOperands =
false;
5949 SDVTList VTList = DAG.getVTList(LoVT, getSetCCResultType(LoVT));
5950 SDValue LowCmp = DAG.getNode(
ISD::USUBO, dl, VTList, LHSLo, RHSLo);
5953 DAG.getCondCode(CCCode));
5959 NewLHS = TLI.SimplifySetCC(getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ,
5960 false, DagCombineInfo, dl);
5963 DAG.getSetCC(dl, getSetCCResultType(HiVT), LHSHi, RHSHi,
ISD::SETEQ);
5964 NewLHS = DAG.getSelect(dl, LoCmp.
getValueType(), NewLHS, LoCmp, HiCmp);
5971 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5976 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5981 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
5982 DAG.getCondCode(CCCode), NewLHS, NewRHS,
5983 N->getOperand(4)), 0);
5989 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
5994 NewRHS = DAG.getConstant(0, SDLoc(
N), NewLHS.
getValueType());
5999 return SDValue(DAG.UpdateNodeOperands(
N, NewLHS, NewRHS,
6000 N->getOperand(2),
N->getOperand(3),
6001 DAG.getCondCode(CCCode)), 0);
6007 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode, SDLoc(
N));
6012 "Unexpected setcc expansion!");
6018 DAG.UpdateNodeOperands(
N, NewLHS, NewRHS, DAG.getCondCode(CCCode)), 0);
6022 SDValue
LHS =
N->getOperand(0);
6023 SDValue
RHS =
N->getOperand(1);
6025 SDValue
Cond =
N->getOperand(3);
6026 SDLoc dl = SDLoc(
N);
6028 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
6029 GetExpandedInteger(
LHS, LHSLo, LHSHi);
6030 GetExpandedInteger(
RHS, RHSLo, RHSHi);
6043 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6053 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
6054 return SDValue(DAG.UpdateNodeOperands(
N,
N->getOperand(0),
Lo), 0);
6058 return TLI.expandCMP(
N, DAG);
6066 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
6067 return SDValue(DAG.UpdateNodeOperands(
N,
Lo), 0);
6071 bool IsStrict =
N->isStrictFPOpcode();
6074 SDValue Chain = IsStrict ?
N->getOperand(0) : SDValue();
6075 SDValue
Op =
N->getOperand(IsStrict ? 1 : 0);
6076 EVT DstVT =
N->getValueType(0);
6079 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
6080 "Don't know how to expand this XINT_TO_FP!");
6081 TargetLowering::MakeLibCallOptions CallOptions;
6083 std::pair<SDValue, SDValue> Tmp =
6084 TLI.makeLibCall(DAG, LC, DstVT,
Op, CallOptions, SDLoc(
N), Chain);
6089 ReplaceValueWith(SDValue(
N, 1), Tmp.second);
6090 ReplaceValueWith(SDValue(
N, 0), Tmp.first);
6095 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
6098 return ExpandOp_NormalStore(
N, OpNo);
6101 assert(OpNo == 1 &&
"Can only expand the stored value so far");
6103 EVT VT =
N->getOperand(1).getValueType();
6104 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6105 SDValue Ch =
N->getChain();
6106 SDValue Ptr =
N->getBasePtr();
6108 MMOMetadata
Metadata =
N->getMMOMetadataForSubAccess();
6114 if (
N->getMemoryVT().bitsLE(NVT)) {
6115 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6116 return DAG.getTruncStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
6117 N->getMemoryVT(),
N->getBaseAlign(), MMOFlags,
6121 if (DAG.getDataLayout().isLittleEndian()) {
6123 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6125 Lo = DAG.getStore(Ch, dl,
Lo, Ptr,
N->getPointerInfo(),
N->getBaseAlign(),
6128 unsigned ExcessBits =
6135 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
6136 N->getPointerInfo().getWithOffset(IncrementSize),
6137 NEVT,
N->getBaseAlign(), MMOFlags,
Metadata);
6143 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
6145 EVT ExtVT =
N->getMemoryVT();
6148 unsigned ExcessBits = (EBytes - IncrementSize)*8;
6156 DAG.getShiftAmountConstant(NVT.
getSizeInBits() - ExcessBits, NVT, dl));
6160 DAG.getShiftAmountConstant(ExcessBits, NVT, dl)));
6164 Hi = DAG.getTruncStore(Ch, dl,
Hi, Ptr,
N->getPointerInfo(), HiVT,
6170 Lo = DAG.getTruncStore(Ch, dl,
Lo, Ptr,
6171 N->getPointerInfo().getWithOffset(IncrementSize),
6179 GetExpandedInteger(
N->getOperand(0), InL, InH);
6188 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
6190 return Swap.getValue(1);
6193SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
6194 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
6195 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
6199 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
6201 return SDValue(DAG.UpdateNodeOperands(
N, NewOps), 0);
6204SDValue DAGTypeLegalizer::ExpandIntOp_WRITE_REGISTER(
SDNode *
N,
unsigned OpNo) {
6207 "cannot use llvm.write_register with illegal type", Fn,
6210 return N->getOperand(0);
6213SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
6216 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6217 SDValue
V1 = GetPromotedInteger(
N->getOperand(1));
6218 EVT OutVT =
V0.getValueType();
6220 return DAG.getNode(
N->getOpcode(), dl, OutVT, V0,
V1,
N->getOperand(2));
6223SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REPEAT(
SDNode *
N) {
6226 EVT OutVT =
N->getValueType(0);
6227 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6232 return DAG.getNode(
N->getOpcode(),
DL, NOutVT,
Op);
6235SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
6237 unsigned Factor =
N->getNumOperands();
6240 for (
unsigned i = 0; i != Factor; i++)
6241 Ops[i] = GetPromotedInteger(
N->getOperand(i));
6244 SDValue Res = DAG.
getNode(
N->getOpcode(),
DL, DAG.getVTList(ResVTs),
Ops);
6246 for (
unsigned i = 0; i != Factor; i++)
6247 SetPromotedInteger(SDValue(
N, i), Res.
getValue(i));
6252SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
6254 EVT OutVT =
N->getValueType(0);
6255 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6256 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6260 SDValue BaseIdx =
N->getOperand(1);
6265 SDValue InOp0 =
N->getOperand(0);
6277 DAG.getConstant(
alignDown(IdxVal, NElts), dl,
6279 SDValue Step2 = DAG.getNode(
6281 DAG.getConstant(IdxVal % NElts, dl, BaseIdx.
getValueType()));
6287 SDValue
Ops[] = {GetWidenedVector(InOp0), BaseIdx};
6296 SDValue
Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
6300 "Promoted operand has an element type greater than result");
6313 InOp0 = GetPromotedInteger(InOp0);
6320 Ops.reserve(OutNumElems);
6321 for (
unsigned i = 0; i != OutNumElems; ++i) {
6326 N->getOperand(0), Index);
6327 SDValue
Op = DAG.getAnyExtOrTrunc(Ext, dl, NOutVTElem);
6332 return DAG.getBuildVector(NOutVT, dl,
Ops);
6335SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
6336 EVT OutVT =
N->getValueType(0);
6337 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6338 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6343 SDValue
Idx =
N->getOperand(2);
6350 Vec = GetPromotedInteger(Vec);
6356SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
6359 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6360 EVT OutVT =
V0.getValueType();
6365SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
6367 EVT VT =
N->getValueType(0);
6372 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6373 SDValue
V1 = GetPromotedInteger(
N->getOperand(1));
6374 EVT OutVT =
V0.getValueType();
6376 return DAG.getVectorShuffle(OutVT, dl, V0,
V1, NewMask);
6380 EVT OutVT =
N->getValueType(0);
6381 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6382 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6383 unsigned NumElems =
N->getNumOperands();
6390 Ops.reserve(NumElems);
6391 for (
unsigned i = 0; i != NumElems; ++i) {
6392 SDValue
Op =
N->getOperand(i);
6393 EVT OpVT =
Op.getValueType();
6398 if (OpVT.
bitsLT(NOutVTElem)) {
6404 ExtOpc = NOutExtOpc;
6405 Op = DAG.getNode(ExtOpc, dl, NOutVTElem,
Op);
6410 return DAG.getBuildVector(NOutVT, dl,
Ops);
6417 assert(!
N->getOperand(0).getValueType().isVector() &&
6418 "Input must be a scalar");
6420 EVT OutVT =
N->getValueType(0);
6421 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6422 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6426 return DAG.getNode(
N->getOpcode(), dl, NOutVT,
Op);
6431 EVT OutVT =
N->getValueType(0);
6432 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6434 "Type must be promoted to a scalable vector type");
6435 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6436 return DAG.getStepVector(dl, NOutVT,
6440SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6443 EVT OutVT =
N->getValueType(0);
6444 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6445 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6447 unsigned NumOperands =
N->getNumOperands();
6451 EVT OpVT =
N->getOperand(0).getValueType();
6456 "Unhandled legalization type");
6462 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6463 SDValue
Op =
N->getOperand(
I);
6465 Op = GetPromotedInteger(
Op);
6474 *DAG.getContext(),
Ops[0].getValueType().getVectorElementType());
6475 return DAG.getAnyExtOrTrunc(
6479 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6480 assert(NumElem * NumOperands == NumOutElem &&
6481 "Unexpected number of elements");
6485 for (
unsigned i = 0; i < NumOperands; ++i) {
6486 SDValue
Op =
N->getOperand(i);
6488 Op = GetPromotedInteger(
Op);
6489 EVT SclrTy =
Op.getValueType().getVectorElementType();
6490 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6491 "Unexpected number of elements");
6493 for (
unsigned j = 0;
j < NumElem; ++
j) {
6495 DAG.getVectorIdxConstant(j, dl));
6496 Ops[i * NumElem +
j] = DAG.getAnyExtOrTrunc(Ext, dl, OutElemTy);
6500 return DAG.getBuildVector(NOutVT, dl,
Ops);
6503SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6504 EVT VT =
N->getValueType(0);
6505 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6506 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6514 if (getTypeAction(
N->getOperand(0).getValueType())
6518 switch(
N->getOpcode()) {
6520 Promoted = SExtPromotedInteger(
N->getOperand(0));
6523 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6526 Promoted = GetPromotedInteger(
N->getOperand(0));
6538 DAG.getVectorIdxConstant(0, dl));
6540 return DAG.getNode(
N->getOpcode(), dl, NVT, Promoted);
6544 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6547SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_FIND_LAST_ACTIVE(
SDNode *
N) {
6548 EVT VT =
N->getValueType(0);
6549 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6553SDValue DAGTypeLegalizer::PromoteIntRes_GET_ACTIVE_LANE_MASK(
SDNode *
N) {
6554 EVT VT =
N->getValueType(0);
6555 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6559SDValue DAGTypeLegalizer::PromoteIntRes_MASK_BEFOREFIRST(
SDNode *
N) {
6560 EVT VT =
N->getValueType(0);
6561 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6562 SDValue
Op = PromoteTargetBoolean(
N->getOperand(0), NVT);
6567 EVT VT =
N->getValueType(0);
6568 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6570 NewOps[2] = PromoteTargetBoolean(
N->getOperand(2), NVT);
6574SDValue DAGTypeLegalizer::PromoteIntRes_PARTIAL_REDUCE_MLA(
SDNode *
N) {
6576 EVT VT =
N->getValueType(0);
6577 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
6578 SDValue ExtAcc = GetPromotedInteger(
N->getOperand(0));
6579 return DAG.getNode(
N->getOpcode(),
DL, NVT, ExtAcc,
N->getOperand(1),
6583SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6584 EVT OutVT =
N->getValueType(0);
6585 EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
6586 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6591 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6594 NOutVTElem,
N->getOperand(1));
6596 V0, ConvElem,
N->getOperand(2));
6603 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6604 return DAG.getNode(
N->getOpcode(), dl, NVT,
N->ops());
6612 SDValue
Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6613 return DAG.getNode(
N->getOpcode(),
DL,
Start.getValueType(), Start,
6614 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6618 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6621 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6622 SDVTList VTList = DAG.getVTList({NVT, MVT::Other, MVT::Glue});
6628 SDValue From[] = {SDValue(
N, 1), SDValue(
N, 2)};
6630 DAG.ReplaceAllUsesOfValuesWith(From, To, 2);
6635SDValue DAGTypeLegalizer::PromoteIntRes_READ_REGISTER(
SDNode *
N) {
6638 "cannot use llvm.read_register with illegal type", Fn,
N->getDebugLoc()));
6640 EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(),
N->getValueType(0));
6641 ReplaceValueWith(SDValue(
N, 1),
N->getOperand(0));
6642 return DAG.getPOISON(NVT);
6645SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6647 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6648 SDValue
V1 = DAG.getZExtOrTrunc(
N->getOperand(1), dl,
6649 TLI.getVectorIdxTy(DAG.getDataLayout()));
6651 V0->getValueType(0).getScalarType(), V0,
V1);
6656 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6659SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6663 SDValue
V0 =
N->getOperand(0);
6664 SDValue
V1 = GetPromotedInteger(
N->getOperand(1));
6665 SDValue
Idx =
N->getOperand(2);
6667 V1.getValueType().getVectorElementType(),
6668 V0.getValueType().getVectorElementCount());
6669 V0 = DAG.getAnyExtOrTrunc(V0, dl, PromVT);
6671 return DAG.getAnyExtOrTrunc(Ext, dl,
N->getValueType(0));
6678 SDValue
V0 =
N->getOperand(0);
6679 SDValue
V1 =
N->getOperand(1);
6680 EVT InVT1 =
V1.getValueType();
6683 TLI.getTypeToTransformTo(*DAG.getContext(), InVT1),
V1);
6684 return DAG.getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6687SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6689 SDValue
V0 = GetPromotedInteger(
N->getOperand(0));
6690 MVT InVT =
V0.getValueType().getSimpleVT();
6697SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6700 EVT ResVT =
N->getValueType(0);
6701 unsigned NumElems =
N->getNumOperands();
6704 EVT PromotedOpTy = TLI.getTypeToTransformTo(*DAG.getContext(),
6705 N->getOperand(0).getValueType());
6708 if (isTypeLegal(WideVT)) {
6710 for (
const SDValue &
Op :
N->ops())
6713 SDValue WideConcat =
6715 return DAG.getAnyExtOrTrunc(WideConcat, dl, ResVT);
6719 SDValue ResVec = DAG.getPOISON(ResVT);
6721 for (
unsigned OpIdx = 0; OpIdx < NumElems; ++OpIdx) {
6722 SDValue
Op =
N->getOperand(OpIdx);
6723 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6725 DAG.getIntPtrConstant(OpIdx * OpNumElts, dl));
6733 for (
const SDValue &
Op :
N->ops())
6734 DAG.ExtractVectorElements(GetPromotedInteger(
Op), NewOps);
6735 return DAG.getBuildVector(ResVT, dl, NewOps);
6738SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6740 SDValue
Op =
N->getOperand(OpNo);
6751 for (
unsigned I = 0;
I < OpNo;
I++)
6754 EVT Ty =
Op.getValueType();
6755 SDLoc
DL = SDLoc(
N);
6758 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6766 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6769 SDValue
NewNode = DAG.getNode(
N->getOpcode(),
DL,
N->getVTList(), NewOps);
6771 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6772 ReplaceValueWith(SDValue(
N, ResNum),
NewNode.getValue(ResNum));
6777SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6779 SDValue
Op =
N->getOperand(OpNo);
6790 for (
unsigned I = 0;
I < OpNo;
I++)
6793 EVT Ty =
Op.getValueType();
6794 SDLoc
DL = SDLoc(
N);
6797 DAG.getTargetConstant(StackMaps::ConstantOp,
DL, MVT::i64));
6805 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6808 SDValue
NewNode = DAG.getNode(
N->getOpcode(),
DL,
N->getVTList(), NewOps);
6810 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6811 ReplaceValueWith(SDValue(
N, ResNum),
NewNode.getValue(ResNum));
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool isSigned(unsigned Opcode)
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)
SmallVector< MachineOperand, 4 > Cond
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This file describes how to lower LLVM code to machine code.
static LLVM_ABI unsigned int semanticsIntSizeInBits(const fltSemantics &, bool)
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.
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.
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.
constexpr bool isPowerOf2() const
const Function & getFunction() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This class is used to represent ISD::LOAD nodes.
unsigned getVectorNumElements() const
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
Flags
Flags values. These may be or'd together.
This class is used to represent an MGATHER node.
This class is used to represent an MLOAD node.
This class is used to represent an MSCATTER node.
This class is used to represent an MSTORE node.
MachineMemOperand * getMemOperand() const
Return the unique MachineMemOperand object describing the memory reference performed by operation.
EVT getMemoryVT() const
Return the type of the in-memory value.
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
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.
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
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...
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
@ 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*X will result in a value whose quantity matches our ...
constexpr ScalarTy getKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns a value X where RHS*X will result in a value whose quantity matches our own.
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
@ MASK_BEFOREFIRST
Has one mask vector operand.
@ COND_LOOP
COND_LOOP is a conditional branch to self, used for implementing efficient conditional traps.
@ MLOAD
Masked load and store - consecutive vector load and store operations with additional mask operand tha...
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
@ BSWAP
Byte Swap and Counting operators.
@ SMULFIX
RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same...
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, val, ptr) This corresponds to "store atomic" instruction.
@ ADDC
Carry-setting nodes for multiple precision addition and subtraction.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ SMULFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ CTTZ_ELTS
Returns the number of number of trailing (least significant) zero elements in a vector.
@ VECTOR_FIND_LAST_ACTIVE
Finds the index of the last active mask element Operands: Mask.
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ FAKE_USE
FAKE_USE represents a use of the operand but does not do anything.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ CLMUL
Carry-less multiplication operations.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ CONVERT_FROM_ARBITRARY_FP
CONVERT_FROM_ARBITRARY_FP - This operator converts from an arbitrary floating-point represented as an...
@ SET_ROUNDING
Set rounding mode.
@ SIGN_EXTEND
Conversion operators.
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ READSTEADYCOUNTER
READSTEADYCOUNTER - This corresponds to the readfixedcounter intrinsic.
@ SETCCCARRY
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
@ BR_CC
BR_CC - Conditional branch.
@ SSUBO
Same for subtraction.
@ VECTOR_INTERLEAVE
VECTOR_INTERLEAVE(VEC1, VEC2, ...) - Returns N vectors from N input vectors, where N is the factor to...
@ STEP_VECTOR
STEP_VECTOR(IMM) - Returns a scalable vector whose lanes are comprised of a linear sequence of unsign...
@ IS_FPCLASS
Performs a check of floating point class property, defined by IEEE-754.
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ ATOMIC_LOAD
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
@ UNDEF
UNDEF - An undefined node.
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ GET_ACTIVE_LANE_MASK
GET_ACTIVE_LANE_MASK - this corrosponds to the llvm.get.active.lane.mask intrinsic.
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ ARITH_FENCE
ARITH_FENCE - This corresponds to a arithmetic fence intrinsic.
@ CTLS
Count leading redundant sign bits.
@ VECREDUCE_ADD
Integer reductions may have a result type larger than the vector element type.
@ GET_ROUNDING
Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest, ties to even 2 Round to ...
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ READ_REGISTER
READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on the DAG, which implements the n...
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ VSCALE
VSCALE(IMM) - Returns the runtime scaling factor used to calculate the number of elements within a sc...
@ ATOMIC_CMP_SWAP
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo,...
@ SSHLSAT
RESULT = [US]SHLSAT(LHS, RHS) - Perform saturation left shift.
@ PATCHPOINT
The llvm.experimental.patchpoint.
@ SMULO
Same for multiplication.
@ VECTOR_SPLICE_LEFT
VECTOR_SPLICE_LEFT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1, VEC2) left by OFFSET elements an...
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ MASKED_UDIV
Masked vector arithmetic that returns poison on disabled lanes.
@ 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.
@ PEXT
Parallel bit extract (compress) and parallel bit deposit (expand).
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
@ STRICT_FP_EXTEND
X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ SCMP
[US]CMP - 3-way comparison of signed or unsigned integers.
@ AVGFLOORS
AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of type i[N+1],...
@ VECTOR_MATCH
VECTOR_MATCH - this corresponds to the llvm.experimental.vector.match intrinsic.
@ VECTOR_SPLICE_RIGHT
VECTOR_SPLICE_RIGHT(VEC1, VEC2, OFFSET) - Shifts CONCAT_VECTORS(VEC1,VEC2) right by OFFSET elements a...
@ ADDE
Carry-using nodes for multiple precision addition and subtraction.
@ STACKMAP
The llvm.experimental.stackmap intrinsic.
@ SPLAT_VECTOR_PARTS
SPLAT_VECTOR_PARTS(SCALAR1, SCALAR2, ...) - Returns a vector with the scalar values joined together a...
@ FREEZE
FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or is evaluated to UNDEF),...
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
@ CTTZ_ZERO_POISON
Bit counting operators with a poisoned result for zero inputs.
@ 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.
@ CONVERT_TO_ARBITRARY_FP
CONVERT_TO_ARBITRARY_FP - Converts a native FP value to an arbitrary floating-point format,...
@ 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_REPEAT
VECTOR_REPEAT(FIXED_LENGTH_VECTOR) Repeatedly copies the elements of the source fixed-length vector t...
@ 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.
@ ABS_MIN_POISON
ABS with a poison result for INT_MIN.
@ 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 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 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 getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
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 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
Type * getValueType(Value *V, bool ReVec, bool LookThroughCmp)
Returns the "element type" of the given value/instruction V.
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.
@ Known
Known to have no common set bits.
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.
EVT changeVectorElementCount(LLVMContext &Context, ElementCount EC) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element coun...
bool isFixedLengthVector() const
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...
LLVM_ABI const fltSemantics & getFltSemantics() const
Returns an APFloat semantics tag appropriate for the value type.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
static LLVM_ABI MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
static StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl)
Get the libcall routine name for the specified libcall implementation.
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT)
MakeLibCallOptions & setIsSigned(bool Value=true)