31#define DEBUG_TYPE "legalize-types"
41void DAGTypeLegalizer::PromoteIntegerResult(
SDNode *
N,
unsigned ResNo) {
46 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true)) {
51 switch (
N->getOpcode()) {
54 dbgs() <<
"PromoteIntegerResult #" << ResNo <<
": ";
55 N->dump(&DAG);
dbgs() <<
"\n";
62 case ISD::VP_BITREVERSE:
65 case ISD::BSWAP: Res = PromoteIntRes_BSWAP(
N);
break;
68 case ISD::VP_CTLZ_ZERO_UNDEF:
71 case ISD::CTLZ: Res = PromoteIntRes_CTLZ(
N);
break;
74 case ISD::CTPOP: Res = PromoteIntRes_CTPOP_PARITY(
N);
break;
75 case ISD::VP_CTTZ_ZERO_UNDEF:
78 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(
N);
break;
79 case ISD::VP_CTTZ_ELTS_ZERO_UNDEF:
80 case ISD::VP_CTTZ_ELTS:
81 Res = PromoteIntRes_VP_CttzElements(
N);
84 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(
N);
break;
85 case ISD::LOAD: Res = PromoteIntRes_LOAD(cast<LoadSDNode>(
N));
break;
87 Res = PromoteIntRes_VP_LOAD(cast<VPLoadSDNode>(
N));
89 case ISD::MLOAD: Res = PromoteIntRes_MLOAD(cast<MaskedLoadSDNode>(
N));
91 case ISD::MGATHER: Res = PromoteIntRes_MGATHER(cast<MaskedGatherSDNode>(
N));
94 Res = PromoteIntRes_VECTOR_COMPRESS(
N);
100 Res = PromoteIntRes_Select(
N);
105 case ISD::SETCC: Res = PromoteIntRes_SETCC(
N);
break;
107 case ISD::SMAX: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
109 case ISD::UMAX: Res = PromoteIntRes_UMINUMAX(
N);
break;
112 case ISD::VP_SHL: Res = PromoteIntRes_SHL(
N);
break;
114 Res = PromoteIntRes_SIGN_EXTEND_INREG(
N);
break;
116 case ISD::VP_SRA: Res = PromoteIntRes_SRA(
N);
break;
118 case ISD::VP_SRL: Res = PromoteIntRes_SRL(
N);
break;
119 case ISD::VP_TRUNCATE:
121 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(
N);
break;
122 case ISD::VAARG: Res = PromoteIntRes_VAARG(
N);
break;
126 Res = PromoteIntRes_EXTRACT_SUBVECTOR(
N);
break;
128 Res = PromoteIntRes_INSERT_SUBVECTOR(
N);
break;
130 Res = PromoteIntRes_VECTOR_REVERSE(
N);
break;
132 Res = PromoteIntRes_VECTOR_SHUFFLE(
N);
break;
134 Res = PromoteIntRes_VECTOR_SPLICE(
N);
break;
137 Res = PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
N);
140 Res = PromoteIntRes_INSERT_VECTOR_ELT(
N);
break;
142 Res = PromoteIntRes_BUILD_VECTOR(
N);
146 case ISD::EXPERIMENTAL_VP_SPLAT:
147 Res = PromoteIntRes_ScalarOp(
N);
151 Res = PromoteIntRes_CONCAT_VECTORS(
N);
break;
156 Res = PromoteIntRes_EXTEND_VECTOR_INREG(
N);
break;
159 case ISD::VP_SIGN_EXTEND:
161 case ISD::VP_ZERO_EXTEND:
164 case ISD::VP_FP_TO_SINT:
165 case ISD::VP_FP_TO_UINT:
173 Res = PromoteIntRes_FP_TO_XINT_SAT(
N);
break;
177 Res = PromoteIntRes_FP_TO_FP16_BF16(
N);
181 Res = PromoteIntRes_STRICT_FP_TO_FP16_BF16(
N);
196 case ISD::VP_MUL: Res = PromoteIntRes_SimpleIntBinOp(
N);
break;
206 case ISD::VP_SREM: Res = PromoteIntRes_SExtIntBinOp(
N);
break;
216 case ISD::VP_UREM: Res = PromoteIntRes_ZExtIntBinOp(
N);
break;
219 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(
N, ResNo);
break;
221 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(
N, ResNo);
break;
223 case ISD::UMULO: Res = PromoteIntRes_XMULO(
N, ResNo);
break;
239 Res = PromoteIntRes_ADDSUBSHLSAT<EmptyMatchContext>(
N);
241 case ISD::VP_SADDSAT:
242 case ISD::VP_UADDSAT:
243 case ISD::VP_SSUBSAT:
244 case ISD::VP_USUBSAT:
245 Res = PromoteIntRes_ADDSUBSHLSAT<VPMatchContext>(
N);
250 Res = PromoteIntRes_CMP(
N);
263 case ISD::ABS: Res = PromoteIntRes_ABS(
N);
break;
266 Res = PromoteIntRes_Atomic0(cast<AtomicSDNode>(
N));
break;
280 Res = PromoteIntRes_Atomic1(cast<AtomicSDNode>(
N));
break;
284 Res = PromoteIntRes_AtomicCmpSwap(cast<AtomicSDNode>(
N), ResNo);
296 Res = PromoteIntRes_VECREDUCE(
N);
299 case ISD::VP_REDUCE_ADD:
300 case ISD::VP_REDUCE_MUL:
301 case ISD::VP_REDUCE_AND:
302 case ISD::VP_REDUCE_OR:
303 case ISD::VP_REDUCE_XOR:
304 case ISD::VP_REDUCE_SMAX:
305 case ISD::VP_REDUCE_SMIN:
306 case ISD::VP_REDUCE_UMAX:
307 case ISD::VP_REDUCE_UMIN:
308 Res = PromoteIntRes_VP_REDUCE(
N);
312 Res = PromoteIntRes_FREEZE(
N);
317 Res = PromoteIntRes_Rotate(
N);
322 Res = PromoteIntRes_FunnelShift(
N);
327 Res = PromoteIntRes_VPFunnelShift(
N);
331 Res = PromoteIntRes_IS_FPCLASS(
N);
334 Res = PromoteIntRes_FFREXP(
N);
339 Res = PromoteIntRes_XRINT(
N);
343 Res = PromoteIntRes_PATCHPOINT(
N);
349 SetPromotedInteger(
SDValue(
N, ResNo), Res);
354 SDValue Op = DisintegrateMERGE_VALUES(
N, ResNo);
355 return GetPromotedInteger(
Op);
360 SDValue Op = SExtPromotedInteger(
N->getOperand(0));
362 Op.getValueType(),
Op,
N->getOperand(1));
367 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
369 Op.getValueType(),
Op,
N->getOperand(1));
375 N->getMemoryVT(), ResVT,
376 N->getChain(),
N->getBasePtr(),
395 cast<AtomicSDNode>(Res)->setExtensionType(ETy);
405 SDValue Op2 = GetPromotedInteger(
N->getOperand(2));
408 N->getChain(),
N->getBasePtr(),
409 Op2,
N->getMemOperand());
420 EVT SVT = getSetCCResultType(
N->getOperand(2).getValueType());
431 N->getChain(),
N->getBasePtr(),
N->getOperand(2),
N->getOperand(3),
441 SDValue Op3 = GetPromotedInteger(
N->getOperand(3));
444 Op2 = SExtPromotedInteger(Op2);
447 Op2 = ZExtPromotedInteger(Op2);
450 Op2 = GetPromotedInteger(Op2);
459 N->getOpcode(),
SDLoc(
N),
N->getMemoryVT(), VTs,
N->getChain(),
460 N->getBasePtr(), Op2, Op3,
N->getMemOperand());
462 for (
unsigned i = 1, NumResults =
N->getNumValues(); i < NumResults; ++i)
471 EVT OutVT =
N->getValueType(0);
475 switch (getTypeAction(InVT)) {
502 BitConvertToInteger(GetScalarizedVector(InOp)));
511 GetSplitVector(
N->getOperand(0),
Lo,
Hi);
512 Lo = BitConvertToInteger(
Lo);
513 Hi = BitConvertToInteger(
Hi);
521 JoinIntegers(
Lo,
Hi));
555 if (isTypeLegal(WideOutVT)) {
556 InOp = DAG.
getBitcast(WideOutVT, GetWidenedVector(InOp));
566 CreateStackStoreLoad(InOp, OutVT));
570 SDValue V = GetPromotedInteger(
N->getOperand(0));
572 V.getValueType(), V);
576 SDValue Op = GetPromotedInteger(
N->getOperand(0));
577 EVT OVT =
N->getValueType(0);
578 EVT NVT =
Op.getValueType();
598 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
599 DAG.
getNode(ISD::VP_BSWAP, dl, NVT,
Op, Mask, EVL), ShAmt,
604 SDValue Op = GetPromotedInteger(
N->getOperand(0));
605 EVT OVT =
N->getValueType(0);
606 EVT NVT =
Op.getValueType();
626 return DAG.
getNode(ISD::VP_SRL, dl, NVT,
627 DAG.
getNode(ISD::VP_BITREVERSE, dl, NVT,
Op, Mask, EVL),
636 N->getValueType(0)), JoinIntegers(
N->getOperand(0),
641 EVT VT =
N->getValueType(0);
650 assert(isa<ConstantSDNode>(Result) &&
"Didn't constant fold ext?");
655 EVT OVT =
N->getValueType(0);
671 unsigned CtlzOpcode =
N->getOpcode();
672 if (CtlzOpcode ==
ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
677 if (!
N->isVPOpcode()) {
679 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
687 SDValue Op = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
688 return DAG.
getNode(ISD::VP_SUB, dl, NVT,
689 DAG.
getNode(
N->getOpcode(), dl, NVT,
Op, Mask, EVL),
690 ExtractLeadingBits, Mask, EVL);
693 CtlzOpcode == ISD::VP_CTLZ_ZERO_UNDEF) {
695 SDValue Op = GetPromotedInteger(
N->getOperand(0));
700 if (!
N->isVPOpcode()) {
702 return DAG.
getNode(CtlzOpcode, dl, NVT,
Op);
707 Op = DAG.
getNode(ISD::VP_SHL, dl, NVT,
Op, ShiftConst, Mask, EVL);
708 return DAG.
getNode(CtlzOpcode, dl, NVT,
Op, Mask, EVL);
714 EVT OVT =
N->getValueType(0);
731 if (!
N->isVPOpcode()) {
732 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
738 SDValue Op = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
744 SDValue Op = GetPromotedInteger(
N->getOperand(0));
745 EVT OVT =
N->getValueType(0);
746 EVT NVT =
Op.getValueType();
764 unsigned NewOpc =
N->getOpcode();
765 if (NewOpc ==
ISD::CTTZ || NewOpc == ISD::VP_CTTZ) {
777 N->getOperand(1),
N->getOperand(2));
778 NewOpc = ISD::VP_CTTZ_ZERO_UNDEF;
781 if (!
N->isVPOpcode())
783 return DAG.
getNode(NewOpc, dl, NVT,
Op,
N->getOperand(1),
N->getOperand(2));
786SDValue DAGTypeLegalizer::PromoteIntRes_VP_CttzElements(
SDNode *
N) {
789 return DAG.
getNode(
N->getOpcode(),
DL, NewVT,
N->ops());
792SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *
N) {
807 EVT SVT =
In.getValueType().getScalarType();
819 unsigned NewOpc =
N->getOpcode();
836 if (
N->getOpcode() == ISD::VP_FP_TO_UINT &&
839 NewOpc = ISD::VP_FP_TO_SINT;
842 if (
N->isStrictFPOpcode()) {
843 Res = DAG.
getNode(NewOpc, dl, {NVT, MVT::Other},
844 {
N->getOperand(0),
N->getOperand(1)});
848 }
else if (NewOpc == ISD::VP_FP_TO_SINT || NewOpc == ISD::VP_FP_TO_UINT) {
849 Res = DAG.
getNode(NewOpc, dl, NVT, {
N->getOperand(0),
N->getOperand(1),
852 Res = DAG.
getNode(NewOpc, dl, NVT,
N->getOperand(0));
864 N->getOpcode() == ISD::VP_FP_TO_UINT)
871SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT_SAT(
SDNode *
N) {
875 return DAG.
getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
879SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16_BF16(
SDNode *
N) {
883 return DAG.
getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
886SDValue DAGTypeLegalizer::PromoteIntRes_STRICT_FP_TO_FP16_BF16(
SDNode *
N) {
891 N->getOperand(0),
N->getOperand(1));
899 return DAG.
getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
907 DAG.
getNode(
N->getOpcode(), dl, {NVT, MVT::Other},
N->getOperand(0));
919 if (getTypeAction(
N->getOperand(0).getValueType())
921 SDValue Res = GetPromotedInteger(
N->getOperand(0));
939 if (
N->getNumOperands() != 1) {
940 assert(
N->getNumOperands() == 3 &&
"Unexpected number of operands!");
941 assert(
N->isVPOpcode() &&
"Expected VP opcode");
942 return DAG.
getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0),
943 N->getOperand(1),
N->getOperand(2));
945 return DAG.
getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
955 N->getMemoryVT(),
N->getMemOperand());
964 assert(!
N->isIndexed() &&
"Indexed vp_load during type legalization!");
968 :
N->getExtensionType();
971 DAG.
getLoadVP(
N->getAddressingMode(), ExtType, NVT, dl,
N->getChain(),
972 N->getBasePtr(),
N->getOffset(),
N->getMask(),
973 N->getVectorLength(),
N->getMemoryVT(),
N->getMemOperand());
982 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
990 N->getOffset(),
N->getMask(), ExtPassThru,
991 N->getMemoryVT(),
N->getMemOperand(),
992 N->getAddressingMode(), ExtType,
993 N->isExpandingLoad());
1002 SDValue ExtPassThru = GetPromotedInteger(
N->getPassThru());
1004 "Gather result type and the passThru argument type should be the same");
1011 SDValue Ops[] = {
N->getChain(), ExtPassThru,
N->getMask(),
N->getBasePtr(),
1012 N->getIndex(),
N->getScale() };
1014 N->getMemoryVT(), dl, Ops,
1015 N->getMemOperand(),
N->getIndexType(),
1023SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_COMPRESS(
SDNode *
N) {
1024 SDValue Vec = GetPromotedInteger(
N->getOperand(0));
1025 SDValue Passthru = GetPromotedInteger(
N->getOperand(2));
1027 N->getOperand(1), Passthru);
1035 EVT VT =
N->getValueType(0);
1036 EVT SVT = getSetCCResultType(VT);
1037 SDValue Ops[3] = {
N->getOperand(0),
N->getOperand(1) };
1038 unsigned NumOps =
N->getNumOperands();
1039 assert(NumOps <= 3 &&
"Too many operands");
1041 Ops[2] = PromoteTargetBoolean(
N->getOperand(2), VT);
1049 ReplaceValueWith(
SDValue(
N, 0), Res);
1055template <
class MatchContextClass>
1067 MatchContextClass matcher(DAG, TLI,
N);
1069 unsigned Opcode = matcher.getRootBaseOpcode();
1075 SExtOrZExtPromotedOperands(Op1, Op2);
1084 Op1 = SExtPromotedInteger(Op1);
1085 Op2 = SExtPromotedInteger(Op2);
1086 return matcher.getNode(
ISD::UADDSAT, dl, NVT, Op1, Op2);
1089 Op1 = ZExtPromotedInteger(Op1);
1090 Op2 = ZExtPromotedInteger(Op2);
1095 return matcher.getNode(
ISD::UMIN, dl, NVT,
Add, SatMax);
1102 Op1 = GetPromotedInteger(Op1);
1103 Op2 = ZExtPromotedInteger(Op2);
1105 Op1 = SExtPromotedInteger(Op1);
1106 Op2 = SExtPromotedInteger(Op2);
1113 if (IsShift || matcher.isOperationLegal(Opcode, PromotedType)) {
1126 "addition, subtraction or left shift");
1129 unsigned SHLAmount = NewBits - OldBits;
1136 SDValue Result = matcher.getNode(Opcode, dl, PromotedType, Op1, Op2);
1137 return matcher.getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
1145 SDValue Result = matcher.getNode(AddOp, dl, PromotedType, Op1, Op2);
1146 Result = matcher.getNode(
ISD::SMIN, dl, PromotedType, Result, SatMax);
1147 Result = matcher.getNode(
ISD::SMAX, dl, PromotedType, Result, SatMin);
1154 SDValue Op1Promoted, Op2Promoted;
1160 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1161 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1163 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1164 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1166 EVT OldType =
N->getOperand(0).getValueType();
1180 Op2Promoted,
N->getOperand(2));
1182 return DAG.
getNode(ShiftOp, dl, PromotedType, Result,
1185 return DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
1190 unsigned SatW,
bool Signed,
1193 EVT VT = V.getValueType();
1220 EVT VT =
LHS.getValueType();
1238 assert(Res &&
"Expanding DIVFIX with wide type failed?");
1244 "Tried to saturate to more than the original type?");
1253 SDValue Op1Promoted, Op2Promoted;
1259 Op1Promoted = SExtPromotedInteger(
N->getOperand(0));
1260 Op2Promoted = SExtPromotedInteger(
N->getOperand(1));
1262 Op1Promoted = ZExtPromotedInteger(
N->getOperand(0));
1263 Op2Promoted = ZExtPromotedInteger(
N->getOperand(1));
1266 unsigned Scale =
N->getConstantOperandVal(2);
1275 N->getValueType(0).getScalarSizeInBits();
1280 SDValue Res = DAG.
getNode(
N->getOpcode(), dl, PromotedType, Op1Promoted,
1281 Op2Promoted,
N->getOperand(2));
1291 Op2Promoted, Scale, DAG)) {
1294 N->getValueType(0).getScalarSizeInBits(),
1302 N->getValueType(0).getScalarSizeInBits());
1305SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *
N,
unsigned ResNo) {
1307 return PromoteIntRes_Overflow(
N);
1311 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1312 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1313 EVT OVT =
N->getOperand(0).getValueType();
1314 EVT NVT =
LHS.getValueType();
1329 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1335 EVT PromotedResultTy =
1338 N->getOperand(0),
N->getOperand(1));
1344 SDValue LHS = GetPromotedInteger(
N->getOperand(1));
1345 SDValue RHS = GetPromotedInteger(
N->getOperand(2));
1347 unsigned Opcode =
N->getOpcode();
1348 if (Opcode == ISD::VP_SELECT || Opcode == ISD::VP_MERGE)
1355 SDValue LHS = GetPromotedInteger(
N->getOperand(2));
1356 SDValue RHS = GetPromotedInteger(
N->getOperand(3));
1358 LHS.getValueType(),
N->getOperand(0),
1359 N->getOperand(1), LHS, RHS,
N->getOperand(4));
1363 unsigned OpNo =
N->isStrictFPOpcode() ? 1 : 0;
1364 EVT InVT =
N->getOperand(OpNo).getValueType();
1367 EVT SVT = getSetCCResultType(InVT);
1375 SVT = getSetCCResultType(InVT);
1383 assert(SVT.
isVector() ==
N->getOperand(OpNo).getValueType().isVector() &&
1384 "Vector compare must return a vector result!");
1388 if (
N->isStrictFPOpcode()) {
1390 SDValue Opers[] = {
N->getOperand(0),
N->getOperand(1),
1391 N->getOperand(2),
N->getOperand(3)};
1392 SetCC = DAG.
getNode(
N->getOpcode(), dl, VTs, Opers,
N->getFlags());
1397 SetCC = DAG.
getNode(
N->getOpcode(), dl, SVT,
N->getOperand(0),
1398 N->getOperand(1),
N->getOperand(2),
N->getFlags());
1414 EVT VT =
N->getValueType(0);
1420 ReplaceValueWith(
SDValue(
N, 0), Res);
1425 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1427 if (
N->getOpcode() != ISD::VP_SHL) {
1429 RHS = ZExtPromotedInteger(RHS);
1437 RHS = VPZExtPromotedInteger(RHS, Mask, EVL);
1442SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *
N) {
1443 SDValue Op = GetPromotedInteger(
N->getOperand(0));
1445 Op.getValueType(),
Op,
N->getOperand(1));
1448SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *
N) {
1452 SDValue LHS = GetPromotedInteger(
N->getOperand(0));
1453 SDValue RHS = GetPromotedInteger(
N->getOperand(1));
1454 if (
N->getNumOperands() == 2)
1456 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1457 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1459 N->getOperand(2),
N->getOperand(3));
1463 if (
N->getNumOperands() == 2) {
1465 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1466 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1469 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1470 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1474 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1475 SDValue RHS = VPSExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1481 if (
N->getNumOperands() == 2) {
1483 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1484 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1487 assert(
N->getNumOperands() == 4 &&
"Unexpected number of operands!");
1488 assert(
N->isVPOpcode() &&
"Expected VP opcode");
1492 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1493 SDValue RHS = VPZExtPromotedInteger(
N->getOperand(1), Mask, EVL);
1504 SExtOrZExtPromotedOperands(LHS, RHS);
1507 LHS.getValueType(), LHS, RHS);
1512 if (
N->getOpcode() != ISD::VP_SRA) {
1514 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1516 RHS = ZExtPromotedInteger(RHS);
1523 SDValue LHS = VPSExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1525 RHS = VPZExtPromotedInteger(RHS, Mask, EVL);
1532 if (
N->getOpcode() != ISD::VP_SRL) {
1534 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1536 RHS = ZExtPromotedInteger(RHS);
1543 SDValue LHS = VPZExtPromotedInteger(
N->getOperand(0), Mask, EVL);
1545 RHS = VPZExtPromotedInteger(RHS, Mask, EVL);
1553 ReplaceValueWith(
SDValue(
N, 0), Res);
1558 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1559 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1562 Amt = ZExtPromotedInteger(Amt);
1566 EVT OldVT =
N->getOperand(0).getValueType();
1567 EVT VT =
Lo.getValueType();
1568 unsigned Opcode =
N->getOpcode();
1582 if (NewBits >= (2 * OldBits) && !isa<ConstantSDNode>(Amt) &&
1607SDValue DAGTypeLegalizer::PromoteIntRes_VPFunnelShift(
SDNode *
N) {
1608 SDValue Hi = GetPromotedInteger(
N->getOperand(0));
1609 SDValue Lo = GetPromotedInteger(
N->getOperand(1));
1614 Amt = VPZExtPromotedInteger(Amt, Mask, EVL);
1618 EVT OldVT =
N->getOperand(0).getValueType();
1619 EVT VT =
Lo.getValueType();
1620 unsigned Opcode =
N->getOpcode();
1621 bool IsFSHR = Opcode == ISD::VP_FSHR;
1626 Amt = DAG.
getNode(ISD::VP_UREM,
DL, AmtVT, Amt,
1634 if (NewBits >= (2 * OldBits) && !isa<ConstantSDNode>(Amt) &&
1637 Hi = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Hi, HiShift, Mask, EVL);
1640 Res = DAG.
getNode(IsFSHR ? ISD::VP_SRL : ISD::VP_SHL,
DL, VT, Res, Amt,
1643 Res = DAG.
getNode(ISD::VP_SRL,
DL, VT, Res, HiShift, Mask, EVL);
1649 Lo = DAG.
getNode(ISD::VP_SHL,
DL, VT,
Lo, ShiftOffset, Mask, EVL);
1654 Amt = DAG.
getNode(ISD::VP_ADD,
DL, AmtVT, Amt, ShiftOffset, Mask, EVL);
1672 Res = GetPromotedInteger(InOp);
1679 "Dst and Src must have the same number of elements");
1681 "Promoted vector type must be a power of two");
1684 GetSplitVector(InOp, EOp1, EOp2);
1692 assert(
N->getOpcode() == ISD::VP_TRUNCATE &&
1693 "Expected VP_TRUNCATE opcode");
1694 SDValue MaskLo, MaskHi, EVLLo, EVLHi;
1695 std::tie(MaskLo, MaskHi) = SplitMask(
N->getOperand(1));
1696 std::tie(EVLLo, EVLHi) =
1697 DAG.
SplitEVL(
N->getOperand(2),
N->getValueType(0), dl);
1698 EOp1 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp1, MaskLo, EVLLo);
1699 EOp2 = DAG.
getNode(ISD::VP_TRUNCATE, dl, HalfNVT, EOp2, MaskHi, EVLHi);
1706 SDValue WideInOp = GetWidenedVector(InOp);
1711 N->getValueType(0).getScalarType(), NumElem);
1726 if (
N->getOpcode() == ISD::VP_TRUNCATE)
1727 return DAG.
getNode(ISD::VP_TRUNCATE, dl, NVT, Res,
N->getOperand(1),
1732SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *
N,
unsigned ResNo) {
1734 return PromoteIntRes_Overflow(
N);
1738 SDValue LHS = ZExtPromotedInteger(
N->getOperand(0));
1739 SDValue RHS = ZExtPromotedInteger(
N->getOperand(1));
1740 EVT OVT =
N->getOperand(0).getValueType();
1741 EVT NVT =
LHS.getValueType();
1755 ReplaceValueWith(
SDValue(
N, 1), Ofl);
1766 return PromoteIntRes_Overflow(
N);
1778 SDValue LHS = SExtPromotedInteger(
N->getOperand(0));
1779 SDValue RHS = SExtPromotedInteger(
N->getOperand(1));
1781 EVT ValueVTs[] = {
LHS.getValueType(),
N->getValueType(1)};
1785 LHS, RHS,
N->getOperand(2));
1795 assert(ResNo == 1 &&
"Don't know how to promote other results yet.");
1796 return PromoteIntRes_Overflow(
N);
1800 EVT OVT =
N->getValueType(0);
1813 SDValue Op0 = SExtPromotedInteger(
N->getOperand(0));
1817SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *
N,
unsigned ResNo) {
1820 return PromoteIntRes_Overflow(
N);
1824 EVT SmallVT =
LHS.getValueType();
1831 LHS = SExtPromotedInteger(LHS);
1832 RHS = SExtPromotedInteger(RHS);
1834 LHS = ZExtPromotedInteger(LHS);
1835 RHS = ZExtPromotedInteger(RHS);
1866 ReplaceValueWith(
SDValue(
N, 1), Overflow);
1872 N->getValueType(0)));
1878 const APInt &MulImm =
N->getConstantOperandAPInt(0);
1885 EVT VT =
N->getValueType(0);
1893 for (
unsigned i = 0; i < NumRegs; ++i) {
1894 Parts[i] = DAG.
getVAArg(RegVT, dl, Chain,
Ptr,
N->getOperand(2),
1895 N->getConstantOperandVal(3));
1901 std::reverse(Parts.begin(), Parts.end());
1906 for (
unsigned i = 1; i < NumRegs; ++i) {
1917 ReplaceValueWith(
SDValue(
N, 1), Chain);
1930bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *
N,
unsigned OpNo) {
1933 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false)) {
1938 switch (
N->getOpcode()) {
1941 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
1942 N->dump(&DAG);
dbgs() <<
"\n";
1948 Res = PromoteIntOp_ATOMIC_STORE(cast<AtomicSDNode>(
N));
1951 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(
N, OpNo);
break;
1952 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(
N, OpNo);
break;
1958 Res = PromoteIntOp_FAKE_USE(
N);
1961 Res = PromoteIntOp_INSERT_VECTOR_ELT(
N, OpNo);
1965 case ISD::EXPERIMENTAL_VP_SPLAT:
1966 Res = PromoteIntOp_ScalarOp(
N);
1969 case ISD::SELECT: Res = PromoteIntOp_SELECT(
N, OpNo);
break;
1972 case ISD::SETCC: Res = PromoteIntOp_SETCC(
N, OpNo);
break;
1974 case ISD::VP_SIGN_EXTEND: Res = PromoteIntOp_VP_SIGN_EXTEND(
N);
break;
1975 case ISD::VP_SINT_TO_FP:
1978 case ISD::STORE: Res = PromoteIntOp_STORE(cast<StoreSDNode>(
N),
1981 Res = PromoteIntOp_VP_STORE(cast<VPStoreSDNode>(
N), OpNo);
1983 case ISD::MSTORE: Res = PromoteIntOp_MSTORE(cast<MaskedStoreSDNode>(
N),
1985 case ISD::MLOAD: Res = PromoteIntOp_MLOAD(cast<MaskedLoadSDNode>(
N),
1987 case ISD::MGATHER: Res = PromoteIntOp_MGATHER(cast<MaskedGatherSDNode>(
N),
1989 case ISD::MSCATTER: Res = PromoteIntOp_MSCATTER(cast<MaskedScatterSDNode>(
N),
1992 Res = PromoteIntOp_VECTOR_COMPRESS(
N, OpNo);
1994 case ISD::VP_TRUNCATE:
1998 case ISD::VP_UINT_TO_FP:
2003 case ISD::VP_ZERO_EXTEND: Res = PromoteIntOp_VP_ZERO_EXTEND(
N);
break;
2011 case ISD::ROTR: Res = PromoteIntOp_Shift(
N);
break;
2014 case ISD::UCMP: Res = PromoteIntOp_CMP(
N);
break;
2017 case ISD::FSHR: Res = PromoteIntOp_FunnelShift(
N);
break;
2043 case ISD::VP_REDUCE_ADD:
2044 case ISD::VP_REDUCE_MUL:
2045 case ISD::VP_REDUCE_AND:
2046 case ISD::VP_REDUCE_OR:
2047 case ISD::VP_REDUCE_XOR:
2048 case ISD::VP_REDUCE_SMAX:
2049 case ISD::VP_REDUCE_SMIN:
2050 case ISD::VP_REDUCE_UMAX:
2051 case ISD::VP_REDUCE_UMIN:
2052 Res = PromoteIntOp_VP_REDUCE(
N, OpNo);
2057 Res = PromoteIntOp_STACKMAP(
N, OpNo);
2060 Res = PromoteIntOp_PATCHPOINT(
N, OpNo);
2062 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2063 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2064 Res = PromoteIntOp_VP_STRIDED(
N, OpNo);
2066 case ISD::EXPERIMENTAL_VP_SPLICE:
2067 Res = PromoteIntOp_VP_SPLICE(
N, OpNo);
2070 Res = PromoteIntOp_VECTOR_HISTOGRAM(
N, OpNo);
2075 if (!Res.
getNode())
return false;
2082 const bool IsStrictFp =
N->isStrictFPOpcode();
2084 N->getNumValues() == (IsStrictFp ? 2 : 1) &&
2085 "Invalid operand expansion");
2089 ReplaceValueWith(
SDValue(
N, 0), Res);
2099void DAGTypeLegalizer::SExtOrZExtPromotedOperands(
SDValue &LHS,
SDValue &RHS) {
2100 SDValue OpL = GetPromotedInteger(LHS);
2101 SDValue OpR = GetPromotedInteger(RHS);
2107 unsigned OpLEffectiveBits =
2109 unsigned OpREffectiveBits =
2111 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2112 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2119 LHS = SExtPromotedInteger(LHS);
2120 RHS = SExtPromotedInteger(RHS);
2131 if (OpLEffectiveBits <=
LHS.getScalarValueSizeInBits() &&
2132 OpREffectiveBits <=
RHS.getScalarValueSizeInBits()) {
2139 LHS = ZExtPromotedInteger(LHS);
2140 RHS = ZExtPromotedInteger(RHS);
2145void DAGTypeLegalizer::PromoteSetCCOperands(
SDValue &LHS,
SDValue &RHS,
2154 LHS = SExtPromotedInteger(LHS);
2155 RHS = SExtPromotedInteger(RHS);
2160 "Unknown integer comparison!");
2162 SExtOrZExtPromotedOperands(LHS, RHS);
2166 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2171 SDValue Op1 = GetPromotedInteger(
N->getOperand(1));
2173 N->getChain(), Op1,
N->getBasePtr(),
N->getMemOperand());
2179 return CreateStackStoreLoad(
N->getOperand(0),
N->getValueType(0));
2182SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *
N,
unsigned OpNo) {
2183 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
2187 PromoteSetCCOperands(LHS, RHS, cast<CondCodeSDNode>(
N->getOperand(1))->get());
2192 N->getOperand(1), LHS, RHS,
N->getOperand(4)),
2196SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *
N,
unsigned OpNo) {
2197 assert(OpNo == 1 &&
"only know how to promote condition");
2200 SDValue Cond = PromoteTargetBoolean(
N->getOperand(1), MVT::Other);
2204 N->getOperand(2)), 0);
2209 EVT OVT =
N->getOperand(0).getValueType();
2210 SDValue Lo = ZExtPromotedInteger(
N->getOperand(0));
2211 SDValue Hi = GetPromotedInteger(
N->getOperand(1));
2212 assert(
Lo.getValueType() ==
N->getValueType(0) &&
"Operand over promoted?");
2225 EVT VecVT =
N->getValueType(0);
2228 "Legal vector of one illegal element?");
2233 assert(
N->getOperand(0).getValueSizeInBits() >=
2234 N->getValueType(0).getScalarSizeInBits() &&
2235 "Type of inserted value narrower than vector element type!");
2238 for (
unsigned i = 0; i < NumElts; ++i)
2239 NewOps.
push_back(GetPromotedInteger(
N->getOperand(i)));
2244SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *
N,
2251 assert(
N->getOperand(1).getValueSizeInBits() >=
2252 N->getValueType(0).getScalarSizeInBits() &&
2253 "Type of inserted value narrower than vector element type!");
2255 GetPromotedInteger(
N->getOperand(1)),
2260 assert(OpNo == 2 &&
"Different operand and result vector types?");
2266 N->getOperand(1),
Idx), 0);
2270 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2271 if (
N->getOpcode() == ISD::EXPERIMENTAL_VP_SPLAT)
2280SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *
N,
unsigned OpNo) {
2281 assert(OpNo == 0 &&
"Only know how to promote the condition!");
2283 EVT OpTy =
N->getOperand(1).getValueType();
2286 if (
SDValue Res = WidenVSELECTMask(
N))
2288 Res,
N->getOperand(1),
N->getOperand(2));
2292 Cond = PromoteTargetBoolean(
Cond, OpVT);
2295 N->getOperand(2)), 0);
2298SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *
N,
unsigned OpNo) {
2299 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2303 PromoteSetCCOperands(LHS, RHS, cast<CondCodeSDNode>(
N->getOperand(4))->get());
2307 N->getOperand(3),
N->getOperand(4)), 0);
2310SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *
N,
unsigned OpNo) {
2311 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
2315 PromoteSetCCOperands(LHS, RHS, cast<CondCodeSDNode>(
N->getOperand(2))->get());
2321 assert(
N->getOpcode() == ISD::VP_SETCC &&
"Expected VP_SETCC opcode");
2324 N->getOperand(3),
N->getOperand(4)),
2330 ZExtPromotedInteger(
N->getOperand(1))), 0);
2338 LHS = SExtPromotedInteger(LHS);
2339 RHS = SExtPromotedInteger(RHS);
2341 SExtOrZExtPromotedOperands(LHS, RHS);
2349 ZExtPromotedInteger(
N->getOperand(2))), 0);
2353 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2360SDValue DAGTypeLegalizer::PromoteIntOp_VP_SIGN_EXTEND(
SDNode *
N) {
2362 EVT VT =
N->getValueType(0);
2363 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2365 Op = DAG.
getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2373 return DAG.
getNode(ISD::VP_SRA, dl, VT, Shl, ShAmt,
N->getOperand(1),
2378 if (
N->getOpcode() == ISD::VP_SINT_TO_FP)
2380 SExtPromotedInteger(
N->getOperand(0)),
2381 N->getOperand(1),
N->getOperand(2)),
2384 SExtPromotedInteger(
N->getOperand(0))), 0);
2387SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_SINT_TO_FP(
SDNode *
N) {
2389 SExtPromotedInteger(
N->getOperand(1))), 0);
2397 SDValue Val = GetPromotedInteger(
N->getValue());
2401 N->getMemoryVT(),
N->getMemOperand());
2407 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2408 assert(!
N->isIndexed() &&
"expecting unindexed vp_store!");
2410 SDValue DataOp = GetPromotedInteger(
N->getValue());
2412 N->getMask(),
N->getVectorLength(),
2413 N->getMemoryVT(),
N->getMemOperand(),
2414 N->isCompressingStore());
2425 Mask = PromoteTargetBoolean(Mask, DataVT);
2431 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2432 DataOp = GetPromotedInteger(DataOp);
2435 N->getOffset(), Mask,
N->getMemoryVT(),
2436 N->getMemOperand(),
N->getAddressingMode(),
2437 true,
N->isCompressingStore());
2442 assert(OpNo == 3 &&
"Only know how to promote the mask!");
2443 EVT DataVT =
N->getValueType(0);
2444 SDValue Mask = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2446 NewOps[OpNo] =
Mask;
2463 EVT DataVT =
N->getValueType(0);
2464 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2465 }
else if (OpNo == 4) {
2467 if (
N->isIndexSigned())
2469 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2471 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2473 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2487 bool TruncateStore =
N->isTruncatingStore();
2492 EVT DataVT =
N->getValue().getValueType();
2493 NewOps[OpNo] = PromoteTargetBoolean(
N->getOperand(OpNo), DataVT);
2494 }
else if (OpNo == 4) {
2496 if (
N->isIndexSigned())
2498 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2500 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2502 NewOps[OpNo] = GetPromotedInteger(
N->getOperand(OpNo));
2503 TruncateStore =
true;
2507 SDLoc(
N), NewOps,
N->getMemOperand(),
2508 N->getIndexType(), TruncateStore);
2513 assert(OpNo == 1 &&
"Can only promote VECTOR_COMPRESS mask.");
2516 SDValue Passthru =
N->getOperand(2);
2517 SDValue Mask = PromoteTargetBoolean(
N->getOperand(1), VT);
2522 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2523 if (
N->getOpcode() == ISD::VP_TRUNCATE)
2525 N->getOperand(1),
N->getOperand(2));
2530 if (
N->getOpcode() == ISD::VP_UINT_TO_FP)
2532 ZExtPromotedInteger(
N->getOperand(0)),
2533 N->getOperand(1),
N->getOperand(2)),
2536 ZExtPromotedInteger(
N->getOperand(0))), 0);
2539SDValue DAGTypeLegalizer::PromoteIntOp_STRICT_UINT_TO_FP(
SDNode *
N) {
2541 ZExtPromotedInteger(
N->getOperand(1))), 0);
2546 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2551SDValue DAGTypeLegalizer::PromoteIntOp_VP_ZERO_EXTEND(
SDNode *
N) {
2553 EVT VT =
N->getValueType(0);
2554 SDValue Op = GetPromotedInteger(
N->getOperand(0));
2556 Op = DAG.
getNode(ISD::VP_ZERO_EXTEND, dl, VT,
Op,
N->getOperand(1),
2559 N->getOperand(0).getValueType());
2563 SDValue Op2 = ZExtPromotedInteger(
N->getOperand(2));
2568SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *
N) {
2570 SDValue Op = ZExtPromotedInteger(
N->getOperand(0));
2575 bool IsStrict =
N->isStrictFPOpcode();
2580 unsigned OpOffset = IsStrict ? 1 : 0;
2593 if (IsPowI &&
N->getValueType(0).isVector())
2596 NewOps[1 + OpOffset] = SExtPromotedInteger(
N->getOperand(1 + OpOffset));
2608 N->getOperand(1 + OpOffset).getValueType().getSizeInBits() &&
2609 "POWI exponent should match with sizeof(int) when doing the libcall.");
2612 SDValue Ops[2] = {
N->getOperand(0 + OpOffset),
N->getOperand(1 + OpOffset)};
2613 std::pair<SDValue, SDValue> Tmp = TLI.
makeLibCall(
2614 DAG, LC,
N->getValueType(0), Ops, CallOptions,
SDLoc(
N), Chain);
2615 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
2617 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2622 switch (
N->getOpcode()) {
2630 case ISD::VP_REDUCE_ADD:
2631 case ISD::VP_REDUCE_MUL:
2632 case ISD::VP_REDUCE_AND:
2633 case ISD::VP_REDUCE_OR:
2634 case ISD::VP_REDUCE_XOR:
2638 case ISD::VP_REDUCE_SMAX:
2639 case ISD::VP_REDUCE_SMIN:
2643 case ISD::VP_REDUCE_UMAX:
2644 case ISD::VP_REDUCE_UMIN:
2654 return GetPromotedInteger(V);
2656 return SExtPromotedInteger(V);
2658 return ZExtPromotedInteger(V);
2664 SDValue Op = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
2666 EVT OrigEltVT =
N->getOperand(0).getValueType().getVectorElementType();
2667 EVT InVT =
Op.getValueType();
2669 EVT ResVT =
N->getValueType(0);
2670 unsigned Opcode =
N->getOpcode();
2690 Op = ZExtPromotedInteger(
N->getOperand(0));
2693 Op = SExtPromotedInteger(
N->getOperand(0));
2709 Op = ZExtPromotedInteger(
N->getOperand(0));
2712 Op = SExtPromotedInteger(
N->getOperand(0));
2726SDValue DAGTypeLegalizer::PromoteIntOp_VP_REDUCE(
SDNode *
N,
unsigned OpNo) {
2733 NewOps[2] = PromoteTargetBoolean(
Op,
N->getOperand(1).getValueType());
2737 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2739 Op = PromoteIntOpVectorReduction(
N,
Op);
2743 EVT VT =
N->getValueType(0);
2744 EVT EltVT =
Op.getValueType().getScalarType();
2759 SDValue Op = ZExtPromotedInteger(
N->getOperand(1));
2763SDValue DAGTypeLegalizer::PromoteIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
2766 SDValue Operand =
N->getOperand(OpNo);
2772SDValue DAGTypeLegalizer::PromoteIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
2775 SDValue Operand =
N->getOperand(OpNo);
2781SDValue DAGTypeLegalizer::PromoteIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
2782 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
2783 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
2786 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2791SDValue DAGTypeLegalizer::PromoteIntOp_VP_SPLICE(
SDNode *
N,
unsigned OpNo) {
2795 NewOps[OpNo] = SExtPromotedInteger(
N->getOperand(OpNo));
2799 assert((OpNo == 4 || OpNo == 5) &&
"Unexpected operand for promotion");
2801 NewOps[OpNo] = ZExtPromotedInteger(
N->getOperand(OpNo));
2805SDValue DAGTypeLegalizer::PromoteIntOp_VECTOR_HISTOGRAM(
SDNode *
N,
2807 assert(OpNo == 1 &&
"Unexpected operand for promotion");
2809 NewOps[1] = GetPromotedInteger(
N->getOperand(1));
2821void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *
N,
unsigned ResNo) {
2827 if (CustomLowerNode(
N,
N->getValueType(ResNo),
true))
2830 switch (
N->getOpcode()) {
2833 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
2834 N->dump(&DAG);
dbgs() <<
"\n";
2883 case ISD::LOAD: ExpandIntRes_LOAD(cast<LoadSDNode>(
N),
Lo,
Hi);
break;
2910 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(
N);
2911 SplitInteger(Tmp.first,
Lo,
Hi);
2912 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
2920 N->getOperand(0),
N->getOperand(1),
N->getOperand(2),
N->getOperand(3),
2929 SplitInteger(Tmp,
Lo,
Hi);
3008 ExpandIntRes_Rotate(
N,
Lo,
Hi);
3013 ExpandIntRes_FunnelShift(
N,
Lo,
Hi);
3017 ExpandIntRes_VSCALE(
N,
Lo,
Hi);
3027std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *
Node) {
3028 unsigned Opc =
Node->getOpcode();
3034 EVT RetVT =
Node->getValueType(0);
3042 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3043 "Unexpected atomic op or value type!");
3047 Node->getOperand(0));
3052void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *
N,
const APInt &Amt,
3057 GetExpandedInteger(
N->getOperand(0), InL, InH);
3068 unsigned VTBits =
N->getValueType(0).getSizeInBits();
3072 if (Amt.
uge(VTBits)) {
3074 }
else if (Amt.
ugt(NVTBits)) {
3078 }
else if (Amt == NVTBits) {
3095 if (Amt.
uge(VTBits)) {
3097 }
else if (Amt.
ugt(NVTBits)) {
3101 }
else if (Amt == NVTBits) {
3118 if (Amt.
uge(VTBits)) {
3121 }
else if (Amt.
ugt(NVTBits)) {
3126 }
else if (Amt == NVTBits) {
3146bool DAGTypeLegalizer::
3148 unsigned Opc =
N->getOpcode();
3156 "Expanded integer type size not a power of two!");
3163 if (((Known.
Zero | Known.
One) & HighBitMask) == 0)
3168 GetExpandedInteger(In, InL, InH);
3222 Lo = DAG.
getNode(Opc, dl, NVT, InL, Amt);
3235bool DAGTypeLegalizer::
3242 "Expanded integer type size not a power of two!");
3247 GetExpandedInteger(
N->getOperand(0), InL, InH);
3259 switch (
N->getOpcode()) {
3274 DAG.
getSelect(dl, NVT, isShort, HiS, HiL));
3290 DAG.
getSelect(dl, NVT, isShort, LoS, LoL));
3306 DAG.
getSelect(dl, NVT, isShort, LoS, LoL));
3332 EVT NewVT = getSetCCResultType(
LHS.getValueType());
3338 SplitInteger(Res,
Lo,
Hi);
3341void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *
N,
3350 unsigned NumBits =
N->getValueType(0).getScalarSizeInBits();
3351 unsigned NumHalfBits = NumBits / 2;
3354 SDValue LHSL, LHSH, RHSL, RHSH;
3355 GetExpandedInteger(LHS, LHSL, LHSH);
3356 GetExpandedInteger(RHS, RHSL, RHSH);
3369 SDValue LHSL, LHSH, RHSL, RHSH;
3370 GetExpandedInteger(LHS, LHSL, LHSH);
3371 GetExpandedInteger(RHS, RHSL, RHSH);
3373 EVT CCT = getSetCCResultType(NVT);
3382 Hi = DAG.
getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3386 const APInt *RHSVal =
nullptr;
3387 if (
auto *RHSConst = dyn_cast<ConstantSDNode>(RHS))
3388 RHSVal = &RHSConst->getAPIntValue();
3395 SDValue LHSL, LHSH, RHSL, RHSH;
3396 GetExpandedInteger(LHS, LHSL, LHSH);
3397 GetExpandedInteger(RHS, RHSL, RHSH);
3399 EVT CCT = getSetCCResultType(NVT);
3405 Hi = DAG.
getNode(
N->getOpcode(),
DL, NVT, {LHSH, RHSH});
3424 switch (
N->getOpcode()) {
3451 EVT VT =
N->getValueType(0);
3452 EVT CCT = getSetCCResultType(VT);
3455 SplitInteger(Result,
Lo,
Hi);
3460 SplitInteger(ExpandedCMP,
Lo,
Hi);
3463void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *
N,
3467 SDValue LHSL, LHSH, RHSL, RHSH;
3468 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3469 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3472 SDValue LoOps[2] = { LHSL, RHSL };
3473 SDValue HiOps[3] = { LHSH, RHSH };
3482 HiOps[2] =
Lo.getValue(1);
3488 HiOps[2] =
Lo.getValue(1);
3510 HiOps[2] =
Lo.getValue(1);
3514 HiOps[2] =
Lo.getValue(1);
3527 EVT OvfVT = getSetCCResultType(NVT);
3566 Cmp = DAG.
getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3569 Cmp = DAG.
getSetCC(dl, getSetCCResultType(NVT), LoOps[0],
3572 Cmp = DAG.
getSetCC(dl, getSetCCResultType(NVT),
Lo, LoOps[0],
3606void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *
N,
3609 SDValue LHSL, LHSH, RHSL, RHSH;
3611 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3612 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3614 SDValue LoOps[2] = { LHSL, RHSL };
3615 SDValue HiOps[3] = { LHSH, RHSH };
3619 HiOps[2] =
Lo.getValue(1);
3623 HiOps[2] =
Lo.getValue(1);
3629 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3632void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *
N,
3635 SDValue LHSL, LHSH, RHSL, RHSH;
3637 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3638 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3640 SDValue LoOps[3] = { LHSL, RHSL,
N->getOperand(2) };
3641 SDValue HiOps[3] = { LHSH, RHSH };
3643 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3644 HiOps[2] =
Lo.getValue(1);
3645 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3649 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3652void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *
N,
3660 unsigned CarryOp, NoCarryOp;
3662 switch(
N->getOpcode()) {
3682 SDValue LHSL, LHSH, RHSL, RHSH;
3683 GetExpandedInteger(LHS, LHSL, LHSH);
3684 GetExpandedInteger(RHS, RHSL, RHSH);
3686 SDValue LoOps[2] = { LHSL, RHSL };
3687 SDValue HiOps[3] = { LHSH, RHSH };
3689 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3690 HiOps[2] =
Lo.getValue(1);
3691 Hi = DAG.
getNode(CarryOp, dl, VTList, HiOps);
3693 Ovf =
Hi.getValue(1);
3698 SplitInteger(Sum,
Lo,
Hi);
3709 DAG.
getSetCC(dl,
N->getValueType(1), LHS,
3720 ReplaceValueWith(
SDValue(
N, 1), Ovf);
3726 SDValue LHSL, LHSH, RHSL, RHSH;
3728 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3729 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3731 SDValue LoOps[3] = { LHSL, RHSL,
N->getOperand(2) };
3734 Lo = DAG.
getNode(
N->getOpcode(), dl, VTList, LoOps);
3735 HiOps[2] =
Lo.getValue(1);
3736 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, HiOps);
3740 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3743void DAGTypeLegalizer::ExpandIntRes_SADDSUBO_CARRY(
SDNode *
N,
3746 SDValue LHSL, LHSH, RHSL, RHSH;
3748 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
3749 GetExpandedInteger(
N->getOperand(1), RHSL, RHSH);
3755 Lo = DAG.
getNode(CarryOp, dl, VTList, { LHSL, RHSL,
N->getOperand(2) });
3756 Hi = DAG.
getNode(
N->getOpcode(), dl, VTList, { LHSH, RHSH, Lo.getValue(1) });
3760 ReplaceValueWith(
SDValue(
N, 1),
Hi.getValue(1));
3763void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *
N,
3768 if (
Op.getValueType().bitsLE(NVT)) {
3775 assert(getTypeAction(
Op.getValueType()) ==
3777 "Only know how to promote this result!");
3780 "Operand over promoted?");
3782 SplitInteger(Res,
Lo,
Hi);
3786void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *
N,
3789 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3790 EVT NVT =
Lo.getValueType();
3791 EVT EVT = cast<VTSDNode>(
N->getOperand(1))->getVT();
3795 if (NVTBits < EVTBits) {
3798 EVTBits - NVTBits)));
3808void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *
N,
3811 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3812 EVT NVT =
Lo.getValueType();
3813 EVT EVT = cast<VTSDNode>(
N->getOperand(1))->getVT();
3817 if (NVTBits < EVTBits) {
3820 EVTBits - NVTBits)));
3828void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *
N,
3831 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
3836void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *
N,
3839 GetExpandedInteger(
N->getOperand(0),
Hi,
Lo);
3848 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3849 EVT NVT =
Lo.getValueType();
3855void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *
N,
3859 auto Constant = cast<ConstantSDNode>(
N);
3861 bool IsTarget =
Constant->isTargetOpcode();
3862 bool IsOpaque =
Constant->isOpaque();
3873 GetExpandedInteger(N0,
Lo,
Hi);
3874 EVT NVT =
Lo.getValueType();
3905 EVT VT =
N->getValueType(0);
3909 SplitInteger(Neg, NegLo, NegHi);
3917void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *
N,
3921 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3922 EVT NVT =
Lo.getValueType();
3939 SplitInteger(Result,
Lo,
Hi);
3942void DAGTypeLegalizer::ExpandIntRes_CTPOP(
SDNode *
N,
3946 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3947 EVT NVT =
Lo.getValueType();
3953void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *
N,
3957 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
3958 EVT NVT =
Lo.getValueType();
3987 ReplaceValueWith(
SDValue(
N, 1), Chain);
3995 Chain =
Op.getValue(1);
4004 EVT VT =
N->getValueType(0);
4008 bool IsStrict =
N->isStrictFPOpcode();
4010 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4012 Op = GetPromotedFloat(
Op);
4016 Op.getValueType() == MVT::bf16) {
4022 EVT OpVT =
Op.getValueType();
4026 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-xint conversion!");
4032 std::pair<SDValue, SDValue> Tmp = TLI.
makeLibCall(DAG, LC, VT,
Op,
4033 CallOptions, dl, Chain);
4034 SplitInteger(Tmp.first,
Lo,
Hi);
4037 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4043 SplitInteger(Res,
Lo,
Hi);
4049 bool IsStrict =
N->isStrictFPOpcode();
4050 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
4054 "Input type needs to be promoted!");
4056 EVT VT =
Op.getValueType();
4058 if (VT == MVT::f16) {
4068 LC = RTLIB::LROUND_F32;
4069 else if (VT == MVT::f64)
4070 LC = RTLIB::LROUND_F64;
4071 else if (VT == MVT::f80)
4072 LC = RTLIB::LROUND_F80;
4073 else if (VT == MVT::f128)
4074 LC = RTLIB::LROUND_F128;
4075 else if (VT == MVT::ppcf128)
4076 LC = RTLIB::LROUND_PPCF128;
4077 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lround input type!");
4081 LC = RTLIB::LRINT_F32;
4082 else if (VT == MVT::f64)
4083 LC = RTLIB::LRINT_F64;
4084 else if (VT == MVT::f80)
4085 LC = RTLIB::LRINT_F80;
4086 else if (VT == MVT::f128)
4087 LC = RTLIB::LRINT_F128;
4088 else if (VT == MVT::ppcf128)
4089 LC = RTLIB::LRINT_PPCF128;
4090 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected lrint input type!");
4094 LC = RTLIB::LLROUND_F32;
4095 else if (VT == MVT::f64)
4096 LC = RTLIB::LLROUND_F64;
4097 else if (VT == MVT::f80)
4098 LC = RTLIB::LLROUND_F80;
4099 else if (VT == MVT::f128)
4100 LC = RTLIB::LLROUND_F128;
4101 else if (VT == MVT::ppcf128)
4102 LC = RTLIB::LLROUND_PPCF128;
4103 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llround input type!");
4107 LC = RTLIB::LLRINT_F32;
4108 else if (VT == MVT::f64)
4109 LC = RTLIB::LLRINT_F64;
4110 else if (VT == MVT::f80)
4111 LC = RTLIB::LLRINT_F80;
4112 else if (VT == MVT::f128)
4113 LC = RTLIB::LLRINT_F128;
4114 else if (VT == MVT::ppcf128)
4115 LC = RTLIB::LLRINT_PPCF128;
4116 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected llrint input type!");
4120 EVT RetVT =
N->getValueType(0);
4124 std::pair<SDValue, SDValue> Tmp = TLI.
makeLibCall(DAG, LC, RetVT,
4125 Op, CallOptions, dl,
4127 SplitInteger(Tmp.first,
Lo,
Hi);
4129 if (
N->isStrictFPOpcode())
4130 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
4133void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *
N,
4135 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_LOAD?");
4138 ExpandRes_NormalLoad(
N,
Lo,
Hi);
4144 EVT VT =
N->getValueType(0);
4155 if (
N->getMemoryVT().bitsLE(NVT)) {
4156 EVT MemVT =
N->getMemoryVT();
4159 N->getOriginalAlign(), MMOFlags, AAInfo);
4162 Ch =
Lo.getValue(1);
4167 unsigned LoSize =
Lo.getValueSizeInBits();
4182 N->getOriginalAlign(), MMOFlags, AAInfo);
4184 unsigned ExcessBits =
4192 N->getPointerInfo().getWithOffset(IncrementSize), NEVT,
4193 N->getOriginalAlign(), MMOFlags, AAInfo);
4202 EVT MemVT =
N->getMemoryVT();
4205 unsigned ExcessBits = (EBytes - IncrementSize)*8;
4211 N->getOriginalAlign(), MMOFlags, AAInfo);
4217 N->getPointerInfo().getWithOffset(IncrementSize),
4219 N->getOriginalAlign(), MMOFlags, AAInfo);
4243 ReplaceValueWith(
SDValue(
N, 1), Ch);
4246void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *
N,
4250 GetExpandedInteger(
N->getOperand(0), LL, LH);
4251 GetExpandedInteger(
N->getOperand(1), RL, RH);
4256void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *
N,
4258 EVT VT =
N->getValueType(0);
4263 GetExpandedInteger(
N->getOperand(0), LL, LH);
4264 GetExpandedInteger(
N->getOperand(1), RL, RH);
4274 LC = RTLIB::MUL_I16;
4275 else if (VT == MVT::i32)
4276 LC = RTLIB::MUL_I32;
4277 else if (VT == MVT::i64)
4278 LC = RTLIB::MUL_I64;
4279 else if (VT == MVT::i128)
4280 LC = RTLIB::MUL_I128;
4292 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4295 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops, CallOptions, dl).first,
4307 ReplaceValueWith(
SDValue(
N, 1),
R.getValue(2));
4312 SplitInteger(Result,
Lo,
Hi);
4318 SplitInteger(Result,
Lo,
Hi);
4324 SplitInteger(Result,
Lo,
Hi);
4335 EVT VT =
N->getValueType(0);
4339 uint64_t Scale =
N->getConstantOperandVal(2);
4351 EVT BoolVT = getSetCCResultType(VT);
4376 SplitInteger(Result,
Lo,
Hi);
4382 assert(Scale <= VTSize &&
"Scale can't be larger than the value type size.");
4386 GetExpandedInteger(LHS, LL, LH);
4387 GetExpandedInteger(RHS, RL, RH);
4391 if (!TLI.
expandMUL_LOHI(LoHiOp, VT, dl, LHS, RHS, Result, NVT, DAG,
4399 SplitInteger(LoTmp, Result[0], Result[1]);
4400 SplitInteger(HiTmp, Result[2], Result[3]);
4402 assert(
Result.size() == 4 &&
"Unexpected number of partlets in the result");
4405 assert((VTSize == NVTSize * 2) &&
"Expected the new value type to be half "
4406 "the size of the current value type");
4428 if (Scale % NVTSize) {
4444 if (Scale == VTSize)
4465 EVT BoolNVT = getSetCCResultType(NVT);
4468 if (Scale < NVTSize) {
4475 }
else if (Scale == NVTSize) {
4478 }
else if (Scale < VTSize) {
4486 "(and saturation can't happen with Scale==VTSize).");
4493 if (Scale < NVTSize) {
4498 unsigned OverflowBits = VTSize - Scale + 1;
4499 assert(OverflowBits <= VTSize && OverflowBits > NVTSize &&
4500 "Extent of overflow bits must start within HL");
4517 }
else if (Scale == NVTSize) {
4530 }
else if (Scale < VTSize) {
4533 unsigned OverflowBits = VTSize - Scale + 1;
4560 N->getConstantOperandVal(2), DAG);
4564 N->getConstantOperandVal(2), TLI, DAG);
4565 SplitInteger(Res,
Lo,
Hi);
4568void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *
Node,
4571 "Node has unexpected Opcode");
4586 SDValue LHSL, LHSH, RHSL, RHSH;
4587 GetExpandedInteger(LHS, LHSL, LHSH);
4588 GetExpandedInteger(RHS, RHSL, RHSH);
4592 Hi = DAG.
getNode(CarryOp, dl, VTList, { LHSH, RHSH,
Lo.getValue(1) });
4594 Ovf =
Hi.getValue(1);
4601 SplitInteger(Sum,
Lo,
Hi);
4626 EVT VT =
LHS.getValueType();
4629 SignsMatch = DAG.
getNOT(dl, SignsMatch, VT);
4633 EVT OType =
Node->getValueType(1);
4641void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *
N,
4643 EVT VT =
N->getValueType(0);
4645 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4655 LC = RTLIB::SDIV_I16;
4656 else if (VT == MVT::i32)
4657 LC = RTLIB::SDIV_I32;
4658 else if (VT == MVT::i64)
4659 LC = RTLIB::SDIV_I64;
4660 else if (VT == MVT::i128)
4661 LC = RTLIB::SDIV_I128;
4662 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
4666 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops, CallOptions, dl).first,
Lo,
Hi);
4669void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(
SDNode *
N,
SDValue &
Lo,
4672 SDValue Shiftee =
N->getOperand(0);
4685 "Shifting unit is not a a power of two!");
4687 const bool IsOneStepShift =
4693 if (!IsOneStepShift)
4697 assert(VTBitWidth % 8 == 0 &&
"Shifting a not byte multiple value?");
4698 unsigned VTByteWidth = VTBitWidth / 8;
4700 "Shiftee type size is not a power of two!");
4701 unsigned StackSlotByteWidth = 2 * VTByteWidth;
4702 unsigned StackSlotBitWidth = 8 * StackSlotByteWidth;
4715 cast<FrameIndexSDNode>(
StackPtr.getNode())->getIndex());
4720 unsigned WideningOpc =
4722 Init = DAG.
getNode(WideningOpc, dl, StackSlotVT, Shiftee);
4729 Ch = DAG.
getStore(Ch, dl,
Init, StackPtr, StackPtrInfo, StackAlign);
4735 Flags.setExact(IsOneStepShift);
4755 bool WillIndexUpwards =
N->getOpcode() !=
ISD::SHL;
4757 WillIndexUpwards = !WillIndexUpwards;
4760 if (WillIndexUpwards) {
4764 StackPtr, DAG.
getConstant(VTByteWidth, dl, PtrTy), dl);
4765 ByteOffset = DAG.
getNegative(ByteOffset, dl, ShAmtVT);
4774 DAG.
getLoad(VT, dl, Ch, AdjStackPtr,
4779 if (!IsOneStepShift) {
4782 DAG.
getConstant(ShiftUnitInBits - 1, dl, ShAmtVT));
4783 Res = DAG.
getNode(
N->getOpcode(), dl, VT, Res, ShAmtRem);
4787 SplitInteger(Res,
Lo,
Hi);
4790void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *
N,
4792 EVT VT =
N->getValueType(0);
4793 unsigned Opc =
N->getOpcode();
4799 return ExpandShiftByConstant(
N, CN->getAPIntValue(),
Lo,
Hi);
4803 if (ExpandShiftWithKnownAmountBit(
N,
Lo,
Hi))
4822 const bool LegalOrCustom =
4826 unsigned ExpansionFactor = 1;
4828 for (
EVT TmpVT = NVT;;) {
4830 if (NewTMPVT == TmpVT)
4840 return ExpandIntRes_ShiftThroughStack(
N,
Lo,
Hi);
4842 if (LegalOrCustom &&
4846 GetExpandedInteger(
N->getOperand(0), LHSL, LHSH);
4852 SDValue ShiftOp =
N->getOperand(1);
4857 SDValue Ops[] = { LHSL, LHSH, ShiftOp };
4859 Hi =
Lo.getValue(1);
4869 LC = RTLIB::SHL_I16;
4870 else if (VT == MVT::i32)
4871 LC = RTLIB::SHL_I32;
4872 else if (VT == MVT::i64)
4873 LC = RTLIB::SHL_I64;
4874 else if (VT == MVT::i128)
4875 LC = RTLIB::SHL_I128;
4879 LC = RTLIB::SRL_I16;
4880 else if (VT == MVT::i32)
4881 LC = RTLIB::SRL_I32;
4882 else if (VT == MVT::i64)
4883 LC = RTLIB::SRL_I64;
4884 else if (VT == MVT::i128)
4885 LC = RTLIB::SRL_I128;
4890 LC = RTLIB::SRA_I16;
4891 else if (VT == MVT::i32)
4892 LC = RTLIB::SRA_I32;
4893 else if (VT == MVT::i64)
4894 LC = RTLIB::SRA_I64;
4895 else if (VT == MVT::i128)
4896 LC = RTLIB::SRA_I128;
4903 SDValue Ops[2] = {
N->getOperand(0), ShAmt};
4906 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops, CallOptions, dl).first,
Lo,
Hi);
4910 if (!ExpandShiftWithUnknownAmountBit(
N,
Lo,
Hi))
4914void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *
N,
4919 if (
Op.getValueType().bitsLE(NVT)) {
4930 assert(getTypeAction(
Op.getValueType()) ==
4932 "Only know how to promote this result!");
4935 "Operand over promoted?");
4937 SplitInteger(Res,
Lo,
Hi);
4945void DAGTypeLegalizer::
4948 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
4949 EVT EVT = cast<VTSDNode>(
N->getOperand(1))->getVT();
4971void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *
N,
4973 EVT VT =
N->getValueType(0);
4975 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
4985 LC = RTLIB::SREM_I16;
4986 else if (VT == MVT::i32)
4987 LC = RTLIB::SREM_I32;
4988 else if (VT == MVT::i64)
4989 LC = RTLIB::SREM_I64;
4990 else if (VT == MVT::i128)
4991 LC = RTLIB::SREM_I128;
4992 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
4996 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops, CallOptions, dl).first,
Lo,
Hi);
4999void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *
N,
5011void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *
N,
5013 EVT VT =
N->getValueType(0);
5032 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
5033 GetExpandedInteger(LHS, LHSLow, LHSHigh);
5034 GetExpandedInteger(RHS, RHSLow, RHSHigh);
5036 EVT BitVT =
N->getValueType(1);
5061 SplitInteger(Three,
Lo,
Hi);
5065 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5076 LC = RTLIB::MULO_I32;
5077 else if (VT == MVT::i64)
5078 LC = RTLIB::MULO_I64;
5079 else if (VT == MVT::i128)
5080 LC = RTLIB::MULO_I128;
5093 SplitInteger(
Mul, MulLo, MulHi);
5099 SplitInteger(MulLo,
Lo,
Hi);
5100 ReplaceValueWith(
SDValue(
N, 1), Overflow);
5113 EVT ArgVT =
Op.getValueType();
5117 Entry.IsSExt =
true;
5118 Entry.IsZExt =
false;
5119 Args.push_back(Entry);
5125 Entry.IsSExt =
true;
5126 Entry.IsZExt =
false;
5127 Args.push_back(Entry);
5146 ReplaceValueWith(
SDValue(
N, 1), Ofl);
5149void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *
N,
5151 EVT VT =
N->getValueType(0);
5153 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5162 if (isa<ConstantSDNode>(
N->getOperand(1))) {
5165 if (isTypeLegal(NVT)) {
5167 GetExpandedInteger(
N->getOperand(0), InL, InH);
5179 LC = RTLIB::UDIV_I16;
5180 else if (VT == MVT::i32)
5181 LC = RTLIB::UDIV_I32;
5182 else if (VT == MVT::i64)
5183 LC = RTLIB::UDIV_I64;
5184 else if (VT == MVT::i128)
5185 LC = RTLIB::UDIV_I128;
5186 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
5189 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops, CallOptions, dl).first,
Lo,
Hi);
5192void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *
N,
5194 EVT VT =
N->getValueType(0);
5196 SDValue Ops[2] = {
N->getOperand(0),
N->getOperand(1) };
5205 if (isa<ConstantSDNode>(
N->getOperand(1))) {
5208 if (isTypeLegal(NVT)) {
5210 GetExpandedInteger(
N->getOperand(0), InL, InH);
5222 LC = RTLIB::UREM_I16;
5223 else if (VT == MVT::i32)
5224 LC = RTLIB::UREM_I32;
5225 else if (VT == MVT::i64)
5226 LC = RTLIB::UREM_I64;
5227 else if (VT == MVT::i128)
5228 LC = RTLIB::UREM_I128;
5229 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
5232 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops, CallOptions, dl).first,
Lo,
Hi);
5235void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *
N,
5240 if (
Op.getValueType().bitsLE(NVT)) {
5247 assert(getTypeAction(
Op.getValueType()) ==
5249 "Only know how to promote this result!");
5252 "Operand over promoted?");
5254 SplitInteger(Res,
Lo,
Hi);
5262void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *
N,
5265 EVT VT = cast<AtomicSDNode>(
N)->getMemoryVT();
5270 cast<AtomicSDNode>(
N)->getMemoryVT(), VTs,
N->getOperand(0),
5271 N->getOperand(1), Zero, Zero, cast<AtomicSDNode>(
N)->getMemOperand());
5277void DAGTypeLegalizer::ExpandIntRes_VECREDUCE(
SDNode *
N,
5282 SplitInteger(Res,
Lo,
Hi);
5285void DAGTypeLegalizer::ExpandIntRes_Rotate(
SDNode *
N,
5291 N->getOperand(0),
N->getOperand(1));
5292 SplitInteger(Res,
Lo,
Hi);
5299 GetExpandedInteger(
N->getOperand(0), In3, In4);
5300 GetExpandedInteger(
N->getOperand(1), In1, In2);
5304 unsigned Opc =
N->getOpcode();
5307 EVT ShAmtCCVT = getSetCCResultType(ShAmtVT);
5324 Lo = DAG.
getNode(Opc,
DL, HalfVT, Select2, Select1, NewShAmt);
5325 Hi = DAG.
getNode(Opc,
DL, HalfVT, Select3, Select2, NewShAmt);
5330 EVT VT =
N->getValueType(0);
5340 SplitInteger(Res,
Lo,
Hi);
5351bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *
N,
unsigned OpNo) {
5355 if (CustomLowerNode(
N,
N->getOperand(OpNo).getValueType(),
false))
5358 switch (
N->getOpcode()) {
5361 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
5362 N->dump(&DAG);
dbgs() <<
"\n";
5367 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(
N);
break;
5371 Res = ExpandOp_FAKE_USE(
N);
5375 case ISD::EXPERIMENTAL_VP_SPLAT:
5378 case ISD::SETCC: Res = ExpandIntOp_SETCC(
N);
break;
5384 case ISD::STORE: Res = ExpandIntOp_STORE(cast<StoreSDNode>(
N), OpNo);
break;
5391 case ISD::ROTR: Res = ExpandIntOp_Shift(
N);
break;
5396 case ISD::UCMP: Res = ExpandIntOp_CMP(
N);
break;
5400 Res = ExpandIntOp_STACKMAP(
N, OpNo);
5403 Res = ExpandIntOp_PATCHPOINT(
N, OpNo);
5405 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
5406 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
5407 Res = ExpandIntOp_VP_STRIDED(
N, OpNo);
5412 if (!Res.
getNode())
return false;
5420 "Invalid operand expansion");
5422 ReplaceValueWith(
SDValue(
N, 0), Res);
5428void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
5432 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5433 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
5434 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
5454 if ((CCCode ==
ISD::SETLT && CST->isZero()) ||
5455 (CCCode ==
ISD::SETGT && CST->isAllOnes())) {
5487 RHSLo, LowCC,
false, DagCombineInfo, dl);
5494 RHSHi, CCCode,
false, DagCombineInfo, dl);
5507 if ((EqAllowed && (HiCmpC && HiCmpC->
isZero())) ||
5509 ((HiCmpC && HiCmpC->
isOne()) || (LoCmpC && LoCmpC->
isZero())))) {
5518 if (LHSHi == RHSHi) {
5531 if (HasSETCCCARRY) {
5534 bool FlipOperands =
false;
5562 false, DagCombineInfo, dl);
5571 SDValue NewLHS =
N->getOperand(2), NewRHS =
N->getOperand(3);
5572 ISD::CondCode CCCode = cast<CondCodeSDNode>(
N->getOperand(1))->get();
5573 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode,
SDLoc(
N));
5585 N->getOperand(4)), 0);
5589 SDValue NewLHS =
N->getOperand(0), NewRHS =
N->getOperand(1);
5590 ISD::CondCode CCCode = cast<CondCodeSDNode>(
N->getOperand(4))->get();
5591 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode,
SDLoc(
N));
5602 N->getOperand(2),
N->getOperand(3),
5607 SDValue NewLHS =
N->getOperand(0), NewRHS =
N->getOperand(1);
5608 ISD::CondCode CCCode = cast<CondCodeSDNode>(
N->getOperand(2))->get();
5609 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode,
SDLoc(
N));
5614 "Unexpected setcc expansion!");
5630 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
5631 GetExpandedInteger(LHS, LHSLo, LHSHi);
5632 GetExpandedInteger(RHS, RHSLo, RHSHi);
5645 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5655 GetExpandedInteger(
N->getOperand(1),
Lo,
Hi);
5668 GetExpandedInteger(
N->getOperand(0),
Lo,
Hi);
5673 bool IsStrict =
N->isStrictFPOpcode();
5677 SDValue Op =
N->getOperand(IsStrict ? 1 : 0);
5678 EVT DstVT =
N->getValueType(0);
5681 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
5682 "Don't know how to expand this XINT_TO_FP!");
5685 std::pair<SDValue, SDValue> Tmp =
5691 ReplaceValueWith(
SDValue(
N, 1), Tmp.second);
5692 ReplaceValueWith(
SDValue(
N, 0), Tmp.first);
5697 assert(!
N->isAtomic() &&
"Should have been a ATOMIC_STORE?");
5700 return ExpandOp_NormalStore(
N, OpNo);
5703 assert(OpNo == 1 &&
"Can only expand the stored value so far");
5705 EVT VT =
N->getOperand(1).getValueType();
5716 if (
N->getMemoryVT().bitsLE(NVT)) {
5717 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5719 N->getMemoryVT(),
N->getOriginalAlign(), MMOFlags,
5725 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5728 N->getOriginalAlign(), MMOFlags, AAInfo);
5730 unsigned ExcessBits =
5738 N->getPointerInfo().getWithOffset(IncrementSize),
5739 NEVT,
N->getOriginalAlign(), MMOFlags, AAInfo);
5745 GetExpandedInteger(
N->getValue(),
Lo,
Hi);
5747 EVT ExtVT =
N->getMemoryVT();
5750 unsigned ExcessBits = (EBytes - IncrementSize)*8;
5768 N->getOriginalAlign(), MMOFlags, AAInfo);
5774 N->getPointerInfo().getWithOffset(IncrementSize),
5776 N->getOriginalAlign(), MMOFlags, AAInfo);
5782 GetExpandedInteger(
N->getOperand(0), InL, InH);
5791 N->getOperand(0),
N->getOperand(2),
N->getOperand(1),
5792 cast<AtomicSDNode>(
N)->getMemOperand());
5796SDValue DAGTypeLegalizer::ExpandIntOp_VP_STRIDED(
SDNode *
N,
unsigned OpNo) {
5797 assert((
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD && OpNo == 3) ||
5798 (
N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE && OpNo == 4));
5802 GetExpandedInteger(NewOps[OpNo], NewOps[OpNo],
Hi);
5807SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SPLICE(
SDNode *
N) {
5810 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
5811 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
5817SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_INTERLEAVE_DEINTERLEAVE(
SDNode *
N) {
5820 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
5821 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
5830SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *
N) {
5832 EVT OutVT =
N->getValueType(0);
5834 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
5838 SDValue BaseIdx =
N->getOperand(1);
5865 SDValue Ops[] = {GetWidenedVector(InOp0), BaseIdx};
5874 SDValue Ops[] = { GetPromotedInteger(InOp0), BaseIdx };
5878 "Promoted operand has an element type greater than result");
5891 InOp0 = GetPromotedInteger(InOp0);
5899 for (
unsigned i = 0; i != OutNumElems; ++i) {
5904 N->getOperand(0), Index);
5913SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_SUBVECTOR(
SDNode *
N) {
5914 EVT OutVT =
N->getValueType(0);
5916 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
5928 Vec = GetPromotedInteger(Vec);
5934SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_REVERSE(
SDNode *
N) {
5937 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
5943SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *
N) {
5945 EVT VT =
N->getValueType(0);
5950 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
5951 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
5958 EVT OutVT =
N->getValueType(0);
5960 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
5961 unsigned NumElems =
N->getNumOperands();
5969 for (
unsigned i = 0; i != NumElems; ++i) {
5971 EVT OpVT =
Op.getValueType();
5976 if (OpVT.
bitsLT(NOutVTElem)) {
5982 ExtOpc = NOutExtOpc;
5995 assert(!
N->getOperand(0).getValueType().isVector() &&
5996 "Input must be a scalar");
5998 EVT OutVT =
N->getValueType(0);
6000 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6004 if (
N->isVPOpcode())
6005 return DAG.
getNode(
N->getOpcode(), dl, NOutVT,
Op,
N->getOperand(1),
6008 return DAG.
getNode(
N->getOpcode(), dl, NOutVT,
Op);
6013 EVT OutVT =
N->getValueType(0);
6016 "Type must be promoted to a scalable vector type");
6017 const APInt &StepVal =
N->getConstantOperandAPInt(0);
6022SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *
N) {
6025 EVT OutVT =
N->getValueType(0);
6027 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6029 unsigned NumOperands =
N->getNumOperands();
6034 SDUse *MaxSizedValue = std::max_element(
6036 EVT AVT = A.getValueType().getVectorElementType();
6037 EVT BVT = B.getValueType().getVectorElementType();
6038 return AVT.getScalarSizeInBits() < BVT.getScalarSizeInBits();
6044 for (
unsigned I = 0;
I < NumOperands; ++
I) {
6046 EVT OpVT =
Op.getValueType();
6048 Op = GetPromotedInteger(
Op);
6051 "Unhandled legalization type");
6068 unsigned NumElem =
N->getOperand(0).getValueType().getVectorNumElements();
6069 assert(NumElem * NumOperands == NumOutElem &&
6070 "Unexpected number of elements");
6074 for (
unsigned i = 0; i < NumOperands; ++i) {
6077 Op = GetPromotedInteger(
Op);
6078 EVT SclrTy =
Op.getValueType().getVectorElementType();
6079 assert(NumElem ==
Op.getValueType().getVectorNumElements() &&
6080 "Unexpected number of elements");
6082 for (
unsigned j = 0;
j < NumElem; ++
j) {
6092SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *
N) {
6093 EVT VT =
N->getValueType(0);
6095 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
6103 if (getTypeAction(
N->getOperand(0).getValueType())
6107 switch(
N->getOpcode()) {
6109 Promoted = SExtPromotedInteger(
N->getOperand(0));
6112 Promoted = ZExtPromotedInteger(
N->getOperand(0));
6115 Promoted = GetPromotedInteger(
N->getOperand(0));
6120 return DAG.
getNode(
N->getOpcode(), dl, NVT, Promoted);
6124 return DAG.
getNode(
N->getOpcode(), dl, NVT,
N->getOperand(0));
6127SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *
N) {
6128 EVT OutVT =
N->getValueType(0);
6130 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
6135 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6138 NOutVTElem,
N->getOperand(1));
6140 V0, ConvElem,
N->getOperand(2));
6148 return DAG.
getNode(
N->getOpcode(), dl, NVT,
N->ops());
6156 SDValue Start = PromoteIntOpVectorReduction(
N,
N->getOperand(0));
6157 return DAG.
getNode(
N->getOpcode(),
DL, Start.getValueType(), Start,
6158 N->getOperand(1),
N->getOperand(2),
N->getOperand(3));
6165 assert(
N->getNumValues() == 3 &&
"Expected 3 values for PATCHPOINT");
6179SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *
N) {
6181 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6193SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_SUBVECTOR(
SDNode *
N) {
6198 SDValue V1 = GetPromotedInteger(
N->getOperand(1));
6218 return DAG.
getNode(
N->getOpcode(), dl,
N->getValueType(0), V0, VPromoted);
6221SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *
N) {
6223 SDValue V0 = GetPromotedInteger(
N->getOperand(0));
6226 N->getValueType(0).getVectorNumElements());
6231SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *
N) {
6234 EVT ResVT =
N->getValueType(0);
6235 unsigned NumElems =
N->getNumOperands();
6240 for (
unsigned OpIdx = 0; OpIdx < NumElems; ++OpIdx) {
6242 unsigned OpNumElts =
Op.getValueType().getVectorMinNumElements();
6250 EVT RetSclrTy =
N->getValueType(0).getVectorElementType();
6256 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
6258 EVT SclrTy =
Incoming->getValueType(0).getVectorElementType();
6259 unsigned NumElem =
Incoming->getValueType(0).getVectorNumElements();
6261 for (
unsigned i=0; i<NumElem; ++i) {
6273SDValue DAGTypeLegalizer::ExpandIntOp_STACKMAP(
SDNode *
N,
unsigned OpNo) {
6286 for (
unsigned I = 0;
I < OpNo;
I++)
6289 EVT Ty =
Op.getValueType();
6301 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6306 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
6312SDValue DAGTypeLegalizer::ExpandIntOp_PATCHPOINT(
SDNode *
N,
unsigned OpNo) {
6325 for (
unsigned I = 0;
I < OpNo;
I++)
6328 EVT Ty =
Op.getValueType();
6340 for (
unsigned I = OpNo + 1;
I <
N->getNumOperands();
I++)
6345 for (
unsigned ResNum = 0; ResNum <
N->getNumValues(); ResNum++)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static bool isSigned(unsigned int Opcode)
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)
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static Type * getValueType(Value *V)
Returns the type of the given value/instruction V.
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
unsigned getActiveBits() const
Compute the number of active bits in the value.
APInt trunc(unsigned width) const
Truncate to new width.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
unsigned countLeadingOnes() const
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned countTrailingZeros() const
unsigned countLeadingZeros() const
APInt sext(unsigned width) const
Sign extend to a new width.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
unsigned countTrailingOnes() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
This is an SDNode representing atomic operations.
const APInt & getValue() const
Return the constant as an APInt value reference.
const ConstantInt * getConstantIntValue() const
uint64_t getZExtValue() const
This is an important base class in LLVM.
@ NewNode
This is a new node, not before seen, that was created in the process of legalizing some other node.
This class represents an Operation in the Expression.
bool isLittleEndian() const
Layout endianness...
This class is used to represent ISD::LOAD nodes.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Flags
Flags values. These may be or'd together.
This class is used to represent an MGATHER node.
This class is used to represent an MLOAD node.
This class is used to represent an MSCATTER node.
This class is used to represent an MSTORE node.
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
EVT getMemoryVT() const
Return the type of the in-memory value.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
Represents a use of a SDNode.
EVT getValueType() const
Convenience function for get().getValueType().
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
uint64_t getScalarValueSizeInBits() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Align getReducedAlign(EVT VT, bool UseABI)
In most cases this function returns the ABI alignment for a given type, except for illegal vector typ...
SDValue getVPZeroExtendInReg(SDValue Op, SDValue Mask, SDValue EVL, const SDLoc &DL, EVT VT)
Return the expression required to zero extend the Op value assuming it was the smaller SrcTy value.
SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
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 ...
unsigned ComputeMaxSignificantBits(SDValue Op, unsigned Depth=0) const
Get the upper bound on bit size for this Value Op as a signed integer.
SDValue getMaskedGather(SDVTList VTs, EVT MemVT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO, ISD::MemIndexType IndexType, ISD::LoadExtType ExtTy)
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
SDValue getShiftAmountConstant(uint64_t Val, EVT VT, const SDLoc &DL)
SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget=false, bool IsOpaque=false)
SDValue getVScale(const SDLoc &DL, EVT VT, APInt MulImm, bool ConstantFold=true)
Return a node that represents the runtime scaling 'MulImm * RuntimeVL'.
SDValue getFreeze(SDValue V)
Return a freeze using the SDLoc of the value operand.
SDValue getAtomicCmpSwap(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDVTList VTs, SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp, MachineMemOperand *MMO)
Gets a node for an atomic cmpxchg op.
void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To, unsigned Num)
Like ReplaceAllUsesOfValueWith, but for multiple values at once.
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false)
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
SDValue UnrollVectorOp(SDNode *N, unsigned ResNE=0)
Utility function used by legalize and lowering to "unroll" a vector operation by splitting out the sc...
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands,...
SDValue getStepVector(const SDLoc &DL, EVT ResVT, const APInt &StepVal)
Returns a vector of type ResVT whose elements contain the linear sequence <0, Step,...
SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Val, MachineMemOperand *MMO)
Gets a node for an atomic op, produces result (if relevant) and chain and takes 2 operands.
SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a bitwise NOT operation as (XOR Val, -1).
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type.
SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS, SDNodeFlags Flags=SDNodeFlags())
Helper function to make it easier to build Select's if you just have operands and don't want to check...
SDValue getNegative(SDValue Val, const SDLoc &DL, EVT VT)
Create negative operation as (SUB 0, Val).
SDValue getZeroExtendInReg(SDValue Op, const SDLoc &DL, EVT VT)
Return the expression required to zero extend the Op value assuming it was the smaller SrcTy value.
const DataLayout & getDataLayout() const
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
SDValue getMemBasePlusOffset(SDValue Base, TypeSize Offset, const SDLoc &DL, const SDNodeFlags Flags=SDNodeFlags())
Returns sum of the base pointer and offset.
SDValue getVAArg(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue SV, unsigned Align)
VAArg produces a result and token chain, and takes a pointer and a source value as input.
SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
SDValue getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign-extending or trunca...
SDValue getBoolExtOrTrunc(SDValue Op, const SDLoc &SL, EVT VT, EVT OpVT)
Convert Op, which must be of integer type, to the integer type VT, by using an extension appropriate ...
SDValue getMaskedStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Base, SDValue Offset, SDValue Mask, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexedMode AM, bool IsTruncating=false, bool IsCompressing=false)
SDValue getExternalSymbol(const char *Sym, EVT VT)
std::pair< SDValue, SDValue > SplitEVL(SDValue N, EVT VecVT, const SDLoc &DL)
Split the explicit vector length parameter of a VP operation.
SDValue getAnyExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either any-extending or truncat...
SDValue getLoadVP(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset, SDValue Mask, SDValue EVL, MachinePointerInfo PtrInfo, EVT MemVT, Align Alignment, MachineMemOperand::Flags MMOFlags, const AAMDNodes &AAInfo, const MDNode *Ranges=nullptr, bool IsExpanding=false)
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
SDValue getValueType(EVT)
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
SDValue getTruncStoreVP(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Mask, SDValue EVL, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags, const AAMDNodes &AAInfo, bool IsCompressing=false)
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
const TargetLibraryInfo & getLibInfo() const
unsigned ComputeNumSignBits(SDValue Op, unsigned Depth=0) const
Return the number of times the sign bit of the register is replicated into the other bits.
SDValue getVectorIdxConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
MachineFunction & getMachineFunction() const
KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
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...
SDValue getCondCode(ISD::CondCode Cond)
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, TypeSize Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object.
LLVMContext * getContext() const
SDValue CreateStackTemporary(TypeSize Bytes, Align Alignment)
Create a stack temporary based on the size in bytes and the alignment.
SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
SDValue getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Base, SDValue Offset, SDValue Mask, SDValue Src0, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexedMode AM, ISD::LoadExtType, bool IsExpanding=false)
SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
SDValue getMaskedScatter(SDVTList VTs, EVT MemVT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO, ISD::MemIndexType IndexType, bool IsTruncating=false)
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
ArrayRef< int > getMask() const
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class is used to represent ISD::STORE nodes.
unsigned getIntSize() const
Get size of a C-level int or unsigned int, in bits.
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const
Get the CallingConv that should be used for the specified libcall.
ShiftLegalizationStrategy
Return the preferred strategy to legalize tihs SHIFT instruction, with ExpansionFactor being the recu...
EVT getTypeToExpandTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
virtual bool isSExtCheaperThanZExt(EVT FromTy, EVT ToTy) const
Return true if sign-extension from FromTy to ToTy is cheaper than zero-extension.
virtual MVT getVectorIdxTy(const DataLayout &DL) const
Returns the type to be used for the index operand of: ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT...
@ TypeScalarizeScalableVector
virtual unsigned getNumRegisters(LLVMContext &Context, EVT VT, std::optional< MVT > RegisterVT=std::nullopt) const
Return the number of registers that this ValueType will eventually require.
LegalizeAction getFixedPointOperationAction(unsigned Op, EVT VT, unsigned Scale) const
Some fixed point operations may be natively supported by the target but only for specific scales.
virtual ISD::NodeType getExtendForAtomicOps() const
Returns how the platform's atomic operations are extended (ZERO_EXTEND, SIGN_EXTEND,...
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL) const
Returns the type for the shift amount of a shift opcode.
virtual EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
BooleanContent getBooleanContents(bool isVec, bool isFloat) const
For targets without i1 registers, this gives the nature of the high-bits of boolean values held in ty...
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
virtual ISD::NodeType getExtendForAtomicCmpSwapArg() const
Returns how the platform's atomic compare and swap expects its comparison value to be extended (ZERO_...
BooleanContent
Enum that describes how the target represents true/false values.
@ ZeroOrOneBooleanContent
@ UndefinedBooleanContent
@ ZeroOrNegativeOneBooleanContent
virtual ShiftLegalizationStrategy preferredShiftLegalizationStrategy(SelectionDAG &DAG, SDNode *N, unsigned ExpansionFactor) const
bool isOperationLegalOrCustom(unsigned Op, EVT VT, bool LegalOnly=false) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
LegalizeTypeAction getTypeAction(LLVMContext &Context, EVT VT) const
Return how we should legalize values of this type, either it is already legal (return 'Legal') or we ...
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
std::vector< ArgListEntry > ArgListTy
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
LegalizeAction getOperationAction(unsigned Op, EVT VT) const
Return how this operation should be treated: either it is legal, needs to be promoted to a larger siz...
bool isOperationLegalOrCustomOrPromote(unsigned Op, EVT VT, bool LegalOnly=false) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
static ISD::NodeType getExtendForContent(BooleanContent Content)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
SDValue expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US][ADD|SUB]SAT.
bool expandMUL(SDNode *N, SDValue &Lo, SDValue &Hi, EVT HiLoVT, SelectionDAG &DAG, MulExpansionKind Kind, SDValue LL=SDValue(), SDValue LH=SDValue(), SDValue RL=SDValue(), SDValue RH=SDValue()) const
Expand a MUL into two nodes.
std::pair< SDValue, SDValue > makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, ArrayRef< SDValue > Ops, MakeLibCallOptions CallOptions, const SDLoc &dl, SDValue Chain=SDValue()) const
Returns a pair of (return value, chain).
SDValue expandCTLZ(SDNode *N, SelectionDAG &DAG) const
Expand CTLZ/CTLZ_ZERO_UNDEF nodes.
SDValue expandBITREVERSE(SDNode *N, SelectionDAG &DAG) const
Expand BITREVERSE nodes.
SDValue expandCTTZ(SDNode *N, SelectionDAG &DAG) const
Expand CTTZ/CTTZ_ZERO_UNDEF nodes.
SDValue expandABD(SDNode *N, SelectionDAG &DAG) const
Expand ABDS/ABDU nodes.
SDValue expandShlSat(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]SHLSAT.
SDValue expandFP_TO_INT_SAT(SDNode *N, SelectionDAG &DAG) const
Expand FP_TO_[US]INT_SAT into FP_TO_[US]INT and selects or min/max.
SDValue expandABS(SDNode *N, SelectionDAG &DAG, bool IsNegative=false) const
Expand ABS nodes.
SDValue expandVecReduce(SDNode *Node, SelectionDAG &DAG) const
Expand a VECREDUCE_* into an explicit calculation.
SDValue expandCTPOP(SDNode *N, SelectionDAG &DAG) const
Expand CTPOP nodes.
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
SDValue expandBSWAP(SDNode *N, SelectionDAG &DAG) const
Expand BSWAP nodes.
bool expandDIVREMByConstant(SDNode *N, SmallVectorImpl< SDValue > &Result, EVT HiLoVT, SelectionDAG &DAG, SDValue LL=SDValue(), SDValue LH=SDValue()) const
Attempt to expand an n-bit div/rem/divrem by constant using a n/2-bit urem by constant and other arit...
void forceExpandWideMUL(SelectionDAG &DAG, const SDLoc &dl, bool Signed, EVT WideVT, const SDValue LL, const SDValue LH, const SDValue RL, const SDValue RH, SDValue &Lo, SDValue &Hi) const
forceExpandWideMUL - Unconditionally expand a MUL into either a libcall or brute force via a wide mul...
SDValue SimplifySetCC(EVT VT, SDValue N0, SDValue N1, ISD::CondCode Cond, bool foldBooleans, DAGCombinerInfo &DCI, const SDLoc &dl) const
Try to simplify a setcc built with the specified operands and cc.
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].
SDValue expandROT(SDNode *N, bool AllowVectorOps, SelectionDAG &DAG) const
Expand rotations.
SDValue expandCMP(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US]CMP.
bool expandMUL_LOHI(unsigned Opcode, EVT VT, const SDLoc &dl, SDValue LHS, SDValue RHS, SmallVectorImpl< SDValue > &Result, EVT HiLoVT, SelectionDAG &DAG, MulExpansionKind Kind, SDValue LL=SDValue(), SDValue LH=SDValue(), SDValue RL=SDValue(), SDValue RH=SDValue()) const
Expand a MUL or [US]MUL_LOHI of n-bit values into two or four nodes, respectively,...
SDValue expandAVG(SDNode *N, SelectionDAG &DAG) const
Expand vector/scalar AVGCEILS/AVGCEILU/AVGFLOORS/AVGFLOORU nodes.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
This class is used to represent a VP_LOAD node.
This class is used to represent a VP_STORE node.
constexpr bool hasKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns true if there exists a value X where RHS.multiplyCoefficientBy(X) will result in a value whos...
constexpr ScalarTy getKnownScalarFactor(const FixedOrScalableQuantity &RHS) const
Returns a value X where RHS.multiplyCoefficientBy(X) will result in a value whose quantity matches ou...
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
constexpr LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char 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.
@ 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.
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ FAKE_USE
FAKE_USE represents a use of the operand but does not do anything.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ SDIVFIX
RESULT = [US]DIVFIX(LHS, RHS, SCALE) - Perform fixed point division on 2 integers with the same width...
@ SET_ROUNDING
Set rounding mode.
@ SIGN_EXTEND
Conversion operators.
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ READSTEADYCOUNTER
READSTEADYCOUNTER - This corresponds to the readfixedcounter intrinsic.
@ CTTZ_ZERO_UNDEF
Bit counting operators with an undefined result for zero inputs.
@ SETCCCARRY
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
@ BR_CC
BR_CC - Conditional branch.
@ SSUBO
Same for subtraction.
@ VECTOR_INTERLEAVE
VECTOR_INTERLEAVE(VEC1, VEC2) - Returns two vectors with all input and output vectors having the same...
@ 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.
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ ARITH_FENCE
ARITH_FENCE - This corresponds to a arithmetic fence intrinsic.
@ VECREDUCE_ADD
Integer reductions may have a result type larger than the vector element type.
@ GET_ROUNDING
Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest, ties to even 2 Round to ...
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ 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.
@ SMULO
Same for multiplication.
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ VECTOR_REVERSE
VECTOR_REVERSE(VECTOR) - Returns a vector, of the same type as VECTOR, whose elements are shuffled us...
@ SDIVFIXSAT
Same as the corresponding unsaturated fixed point instructions, but the result is clamped between the...
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ STRICT_SINT_TO_FP
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
@ MGATHER
Masked gather and scatter - load and store operations for a vector of random addresses with additiona...
@ BF16_TO_FP
BF16_TO_FP, FP_TO_BF16 - These operators are used to perform promotions and truncation for bfloat16.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
@ STRICT_FP_EXTEND
X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ SCMP
[US]CMP - 3-way comparison of signed or unsigned integers.
@ AVGFLOORS
AVGFLOORS/AVGFLOORU - Averaging add - Add two integers using an integer of type i[N+1],...
@ ADDE
Carry-using nodes for multiple precision addition and subtraction.
@ SPLAT_VECTOR_PARTS
SPLAT_VECTOR_PARTS(SCALAR1, SCALAR2, ...) - Returns a vector with the scalar values joined together a...
@ FREEZE
FREEZE - FREEZE(VAL) returns an arbitrary value if VAL is UNDEF (or is evaluated to UNDEF),...
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ VECTOR_SPLICE
VECTOR_SPLICE(VEC1, VEC2, IMM) - Returns a subvector of the same type as VEC1/VEC2 from CONCAT_VECTOR...
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
@ FFREXP
FFREXP - frexp, extract fractional and exponent component of a floating-point value.
@ VECTOR_COMPRESS
VECTOR_COMPRESS(Vec, Mask, Passthru) consecutively place vector elements based on mask e....
@ ZERO_EXTEND_VECTOR_INREG
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
@ EXPERIMENTAL_VECTOR_HISTOGRAM
@ FP_TO_SINT_SAT
FP_TO_[US]INT_SAT - Convert floating point value in operand 0 to a signed or unsigned scalar integer ...
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ VAARG
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
@ BRCOND
BRCOND - Conditional branch.
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ VECTOR_DEINTERLEAVE
VECTOR_DEINTERLEAVE(VEC1, VEC2) - Returns two vectors with all input and output vectors having the sa...
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ SADDO_CARRY
Carry-using overflow-aware nodes for multiple precision addition and subtraction.
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
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...
Libcall getPOWI(EVT RetVT)
getPOWI - Return the POWI_* value for the given types, or UNKNOWN_LIBCALL if there is none.
Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
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.
Libcall getLDEXP(EVT RetVT)
getLDEXP - Return the LDEXP_* value for the given types, or UNKNOWN_LIBCALL if there is none.
Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit.
Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
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...
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
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.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
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
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.
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.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
This struct is a compact representation of a valid (non-zero power of two) alignment.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
ElementCount getVectorElementCount() const
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
uint64_t getScalarSizeInBits() const
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
bool bitsEq(EVT VT) const
Return true if this has the same number of bits as VT.
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
EVT changeVectorElementType(EVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
Incoming for lane maks phi as machine instruction, incoming register Reg and incoming block Block are...
bool isZero() const
Returns true if value is all zero.
unsigned countMinTrailingZeros() const
Returns the minimum number of trailing zero bits.
unsigned countMaxActiveBits() const
Returns the maximum number of bits needed to represent all possible unsigned values with these known ...
This class contains a discriminated union of information about pointers in memory operands,...
static MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
These are IR-level optimization flags that may be propagated to SDNodes.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
This structure contains all information that is necessary for lowering calls.
This structure is used to pass arguments to makeLibCall function.
MakeLibCallOptions & setIsSigned(bool Value=true)
MakeLibCallOptions & setTypeListBeforeSoften(ArrayRef< EVT > OpsVT, EVT RetVT, bool Value=true)