29 #define DEBUG_TYPE "legalize-types"
35 void DAGTypeLegalizer::ScalarizeVectorResult(
SDNode *
N,
unsigned ResNo) {
36 DEBUG(
dbgs() <<
"Scalarize node result " << ResNo <<
": ";
44 dbgs() <<
"ScalarizeVectorResult #" << ResNo <<
": ";
52 case ISD::BITCAST: R = ScalarizeVecRes_BITCAST(N);
break;
57 case ISD::FPOWI: R = ScalarizeVecRes_FPOWI(N);
break;
59 case ISD::LOAD: R = ScalarizeVecRes_LOAD(cast<LoadSDNode>(N));
break;
62 case ISD::VSELECT: R = ScalarizeVecRes_VSELECT(N);
break;
63 case ISD::SELECT: R = ScalarizeVecRes_SELECT(N);
break;
65 case ISD::SETCC: R = ScalarizeVecRes_SETCC(N);
break;
66 case ISD::UNDEF: R = ScalarizeVecRes_UNDEF(N);
break;
71 R = ScalarizeVecRes_VecInregOp(N);
106 R = ScalarizeVecRes_UnaryOp(N);
138 R = ScalarizeVecRes_BinOp(N);
141 R = ScalarizeVecRes_TernaryOp(N);
147 SetScalarizedVector(
SDValue(N, ResNo), R);
157 SDValue DAGTypeLegalizer::ScalarizeVecRes_TernaryOp(
SDNode *N) {
165 SDValue DAGTypeLegalizer::ScalarizeVecRes_MERGE_VALUES(
SDNode *N,
167 SDValue Op = DisintegrateMERGE_VALUES(N, ResNo);
168 return GetScalarizedVector(Op);
171 SDValue DAGTypeLegalizer::ScalarizeVecRes_BITCAST(
SDNode *N) {
177 SDValue DAGTypeLegalizer::ScalarizeVecRes_BUILD_VECTOR(
SDNode *N) {
187 SDValue DAGTypeLegalizer::ScalarizeVecRes_EXTRACT_SUBVECTOR(
SDNode *N) {
193 SDValue DAGTypeLegalizer::ScalarizeVecRes_FP_ROUND(
SDNode *N) {
206 SDValue DAGTypeLegalizer::ScalarizeVecRes_INSERT_VECTOR_ELT(
SDNode *N) {
234 SDValue DAGTypeLegalizer::ScalarizeVecRes_UnaryOp(
SDNode *N) {
248 Op = GetScalarizedVector(Op);
258 SDValue DAGTypeLegalizer::ScalarizeVecRes_InregOp(
SDNode *N) {
266 SDValue DAGTypeLegalizer::ScalarizeVecRes_VecInregOp(
SDNode *N) {
275 Op = GetScalarizedVector(Op);
294 SDValue DAGTypeLegalizer::ScalarizeVecRes_SCALAR_TO_VECTOR(
SDNode *N) {
304 SDValue DAGTypeLegalizer::ScalarizeVecRes_VSELECT(
SDNode *N) {
312 Cond = GetScalarizedVector(Cond);
341 if (ScalarBool != VecBool) {
343 switch (ScalarBool) {
368 SDValue DAGTypeLegalizer::ScalarizeVecRes_SELECT(
SDNode *N) {
375 SDValue DAGTypeLegalizer::ScalarizeVecRes_SELECT_CC(
SDNode *N) {
386 "Scalar/Vector type mismatch");
402 SDValue DAGTypeLegalizer::ScalarizeVecRes_VECTOR_SHUFFLE(
SDNode *N) {
407 unsigned Op = !cast<ConstantSDNode>(Arg)->isNullValue();
408 return GetScalarizedVector(N->
getOperand(Op));
411 SDValue DAGTypeLegalizer::ScalarizeVecRes_VSETCC(
SDNode *N) {
414 "Operand types must be vectors");
417 EVT OpVT = LHS.getValueType();
423 LHS = GetScalarizedVector(LHS);
424 RHS = GetScalarizedVector(RHS);
442 return DAG.
getNode(ExtendCode,
DL, NVT, Res);
450 bool DAGTypeLegalizer::ScalarizeVectorOperand(
SDNode *N,
unsigned OpNo) {
451 DEBUG(
dbgs() <<
"Scalarize node operand " << OpNo <<
": ";
456 if (!Res.getNode()) {
460 dbgs() <<
"ScalarizeVectorOperand Op #" << OpNo <<
": ";
466 Res = ScalarizeVecOp_BITCAST(N);
476 Res = ScalarizeVecOp_UnaryOp(N);
479 Res = ScalarizeVecOp_CONCAT_VECTORS(N);
482 Res = ScalarizeVecOp_EXTRACT_VECTOR_ELT(N);
485 Res = ScalarizeVecOp_VSELECT(N);
488 Res = ScalarizeVecOp_VSETCC(N);
491 Res = ScalarizeVecOp_STORE(cast<StoreSDNode>(N), OpNo);
494 Res = ScalarizeVecOp_FP_ROUND(N, OpNo);
500 if (!Res.getNode())
return false;
504 if (Res.getNode() ==
N)
508 "Invalid operand expansion");
510 ReplaceValueWith(
SDValue(N, 0), Res);
516 SDValue DAGTypeLegalizer::ScalarizeVecOp_BITCAST(
SDNode *N) {
524 SDValue DAGTypeLegalizer::ScalarizeVecOp_UnaryOp(
SDNode *N) {
526 "Unexpected vector type!");
536 SDValue DAGTypeLegalizer::ScalarizeVecOp_CONCAT_VECTORS(
SDNode *N) {
539 Ops[i] = GetScalarizedVector(N->
getOperand(i));
545 SDValue DAGTypeLegalizer::ScalarizeVecOp_EXTRACT_VECTOR_ELT(
SDNode *N) {
558 SDValue DAGTypeLegalizer::ScalarizeVecOp_VSELECT(
SDNode *N) {
572 "Operand types must be vectors");
591 Res = DAG.
getNode(ExtendCode,
DL, NVT, Res);
600 assert(OpNo == 1 &&
"Do not know how to scalarize this operand!");
618 SDValue DAGTypeLegalizer::ScalarizeVecOp_FP_ROUND(
SDNode *N,
unsigned OpNo) {
634 void DAGTypeLegalizer::SplitVectorResult(
SDNode *N,
unsigned ResNo) {
647 dbgs() <<
"SplitVectorResult #" << ResNo <<
": ";
656 case ISD::SELECT: SplitRes_SELECT(N, Lo, Hi);
break;
658 case ISD::UNDEF: SplitRes_UNDEF(N, Lo, Hi);
break;
659 case ISD::BITCAST: SplitVecRes_BITCAST(N, Lo, Hi);
break;
665 case ISD::FPOWI: SplitVecRes_FPOWI(N, Lo, Hi);
break;
671 SplitVecRes_LOAD(cast<LoadSDNode>(N), Lo, Hi);
674 SplitVecRes_MLOAD(cast<MaskedLoadSDNode>(N), Lo, Hi);
677 SplitVecRes_MGATHER(cast<MaskedGatherSDNode>(N), Lo, Hi);
680 SplitVecRes_SETCC(N, Lo, Hi);
683 SplitVecRes_VECTOR_SHUFFLE(cast<ShuffleVectorSDNode>(N), Lo, Hi);
689 SplitVecRes_ExtVecInRegOp(N, Lo, Hi);
723 SplitVecRes_UnaryOp(N, Lo, Hi);
729 SplitVecRes_ExtendOp(N, Lo, Hi);
761 SplitVecRes_BinOp(N, Lo, Hi);
764 SplitVecRes_TernaryOp(N, Lo, Hi);
773 void DAGTypeLegalizer::SplitVecRes_BinOp(
SDNode *N,
SDValue &Lo,
776 GetSplitVector(N->
getOperand(0), LHSLo, LHSHi);
778 GetSplitVector(N->
getOperand(1), RHSLo, RHSHi);
787 void DAGTypeLegalizer::SplitVecRes_TernaryOp(
SDNode *N,
SDValue &Lo,
790 GetSplitVector(N->
getOperand(0), Op0Lo, Op0Hi);
792 GetSplitVector(N->
getOperand(1), Op1Lo, Op1Hi);
794 GetSplitVector(N->
getOperand(2), Op2Lo, Op2Hi);
798 Op0Lo, Op1Lo, Op2Lo);
800 Op0Hi, Op1Hi, Op2Hi);
803 void DAGTypeLegalizer::SplitVecRes_BITCAST(
SDNode *N,
SDValue &Lo,
815 switch (getTypeAction(InVT)) {
829 GetExpandedOp(InOp, Lo, Hi);
840 GetSplitVector(InOp, Lo, Hi);
852 SplitInteger(BitConvertToInteger(InOp), LoIntVT, HiIntVT, Lo, Hi);
860 void DAGTypeLegalizer::SplitVecRes_BUILD_VECTOR(
SDNode *N,
SDValue &Lo,
873 void DAGTypeLegalizer::SplitVecRes_CONCAT_VECTORS(
SDNode *N,
SDValue &Lo,
878 if (NumSubvectors == 1) {
894 void DAGTypeLegalizer::SplitVecRes_EXTRACT_SUBVECTOR(
SDNode *N,
SDValue &Lo,
904 uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
910 void DAGTypeLegalizer::SplitVecRes_INSERT_SUBVECTOR(
SDNode *N,
SDValue &Lo,
916 GetSplitVector(Vec, Lo, Hi);
929 unsigned IdxVal = ConstIdx->getZExtValue();
930 if ((IdxVal == 0) && (IdxVal + SubElems <= VecElems / 2)) {
957 DAG.
getConstant(IncrementSize, dl, StackPtr.getValueType()));
961 MinAlign(Alignment, IncrementSize));
964 void DAGTypeLegalizer::SplitVecRes_FPOWI(
SDNode *N,
SDValue &Lo,
972 void DAGTypeLegalizer::SplitVecRes_FCOPYSIGN(
SDNode *N,
SDValue &Lo,
975 GetSplitVector(N->
getOperand(0), LHSLo, LHSHi);
982 GetSplitVector(RHS, RHSLo, RHSHi);
991 void DAGTypeLegalizer::SplitVecRes_InregOp(
SDNode *N,
SDValue &Lo,
994 GetSplitVector(N->
getOperand(0), LHSLo, LHSHi);
998 std::tie(LoVT, HiVT) =
1007 void DAGTypeLegalizer::SplitVecRes_ExtVecInRegOp(
SDNode *N,
SDValue &Lo,
1016 GetSplitVector(N0, InLo, InHi);
1023 EVT OutLoVT, OutHiVT;
1026 assert((2 * OutNumElements) <= InNumElements &&
1027 "Illegal extend vector in reg split");
1037 for (
unsigned i = 0; i != OutNumElements; ++i)
1038 SplitHi[i] = i + OutNumElements;
1041 Lo = DAG.
getNode(Opcode, dl, OutLoVT, InLo);
1042 Hi = DAG.
getNode(Opcode, dl, OutHiVT, InHi);
1045 void DAGTypeLegalizer::SplitVecRes_INSERT_VECTOR_ELT(
SDNode *N,
SDValue &Lo,
1051 GetSplitVector(Vec, Lo, Hi);
1054 unsigned IdxVal = CIdx->getZExtValue();
1056 if (IdxVal < LoNumElts)
1092 StackPtr = DAG.
getNode(
ISD::ADD, dl, StackPtr.getValueType(), StackPtr,
1094 StackPtr.getValueType()));
1098 MinAlign(Alignment, IncrementSize));
1101 void DAGTypeLegalizer::SplitVecRes_SCALAR_TO_VECTOR(
SDNode *N,
SDValue &Lo,
1126 EVT LoMemVT, HiMemVT;
1137 Alignment, MMOFlags, AAInfo);
1146 ReplaceValueWith(
SDValue(LD, 1), Ch);
1164 unsigned SecondHalfAlignment =
1166 Alignment/2 : Alignment;
1171 GetSplitVector(Mask, MaskLo, MaskHi);
1173 std::tie(MaskLo, MaskHi) = DAG.
SplitVector(Mask, dl);
1176 EVT LoMemVT, HiMemVT;
1181 GetSplitVector(Src0, Src0Lo, Src0Hi);
1183 std::tie(Src0Lo, Src0Hi) = DAG.
SplitVector(Src0, dl);
1190 Lo = DAG.
getMaskedLoad(LoVT, dl, Ch, Ptr, MaskLo, Src0Lo, LoMemVT, MMO,
1201 Hi = DAG.
getMaskedLoad(HiVT, dl, Ch, Ptr, MaskHi, Src0Hi, HiMemVT, MMO,
1212 ReplaceValueWith(
SDValue(MLD, 1), Ch);
1232 GetSplitVector(Mask, MaskLo, MaskHi);
1234 std::tie(MaskLo, MaskHi) = DAG.
SplitVector(Mask, dl);
1237 EVT LoMemVT, HiMemVT;
1243 GetSplitVector(Src0, Src0Lo, Src0Hi);
1245 std::tie(Src0Lo, Src0Hi) = DAG.
SplitVector(Src0, dl);
1249 GetSplitVector(Index, IndexLo, IndexHi);
1251 std::tie(IndexLo, IndexHi) = DAG.
SplitVector(Index, dl);
1258 SDValue OpsLo[] = {Ch, Src0Lo, MaskLo,
Ptr, IndexLo};
1262 SDValue OpsHi[] = {Ch, Src0Hi, MaskHi,
Ptr, IndexHi};
1273 ReplaceValueWith(
SDValue(MGT, 1), Ch);
1280 "Operand types must be vectors");
1295 void DAGTypeLegalizer::SplitVecRes_UnaryOp(
SDNode *N,
SDValue &Lo,
1319 void DAGTypeLegalizer::SplitVecRes_ExtendOp(
SDNode *N,
SDValue &Lo,
1341 if ((NumElements & 1) == 0 &&
1347 EVT SplitLoVT, SplitHiVT;
1351 DEBUG(
dbgs() <<
"Split vector extend via incremental extend:";
1365 SplitVecRes_UnaryOp(N, Lo, Hi);
1373 GetSplitVector(N->
getOperand(0), Inputs[0], Inputs[1]);
1374 GetSplitVector(N->
getOperand(1), Inputs[2], Inputs[3]);
1389 unsigned InputUsed[2] = { -1U, -1U };
1390 unsigned FirstMaskIdx =
High * NewElts;
1391 bool useBuildVector =
false;
1392 for (
unsigned MaskOffset = 0; MaskOffset < NewElts; ++MaskOffset) {
1394 int Idx = N->
getMaskElt(FirstMaskIdx + MaskOffset);
1397 unsigned Input = (
unsigned)Idx / NewElts;
1406 Idx -= Input * NewElts;
1411 if (InputUsed[OpNo] == Input) {
1414 }
else if (InputUsed[OpNo] == -1U) {
1416 InputUsed[OpNo] = Input;
1424 useBuildVector =
true;
1432 if (useBuildVector) {
1437 for (
unsigned MaskOffset = 0; MaskOffset < NewElts; ++MaskOffset) {
1439 int Idx = N->
getMaskElt(FirstMaskIdx + MaskOffset);
1442 unsigned Input = (
unsigned)Idx / NewElts;
1451 Idx -= Input * NewElts;
1461 }
else if (InputUsed[0] == -1U) {
1465 SDValue Op0 = Inputs[InputUsed[0]];
1467 SDValue Op1 = InputUsed[1] == -1U ?
1468 DAG.
getUNDEF(NewVT) : Inputs[InputUsed[1]];
1486 bool DAGTypeLegalizer::SplitVectorOperand(
SDNode *N,
unsigned OpNo) {
1496 if (!Res.getNode()) {
1500 dbgs() <<
"SplitVectorOperand Op #" << OpNo <<
": ";
1507 case ISD::SETCC: Res = SplitVecOp_VSETCC(N);
break;
1513 Res = SplitVecOp_TruncateHelper(N);
1518 Res = SplitVecOp_STORE(cast<StoreSDNode>(N), OpNo);
1521 Res = SplitVecOp_MSTORE(cast<MaskedStoreSDNode>(N), OpNo);
1524 Res = SplitVecOp_MSCATTER(cast<MaskedScatterSDNode>(N), OpNo);
1527 Res = SplitVecOp_MGATHER(cast<MaskedGatherSDNode>(N), OpNo);
1530 Res = SplitVecOp_VSELECT(N, OpNo);
1535 Res = SplitVecOp_TruncateHelper(N);
1537 Res = SplitVecOp_UnaryOp(N);
1542 Res = SplitVecOp_TruncateHelper(N);
1544 Res = SplitVecOp_UnaryOp(N);
1555 Res = SplitVecOp_UnaryOp(N);
1561 Res = SplitVecOp_ExtVecInRegOp(N);
1577 Res = SplitVecOp_VECREDUCE(N, OpNo);
1583 if (!Res.getNode())
return false;
1587 if (Res.getNode() ==
N)
1591 "Invalid operand expansion");
1593 ReplaceValueWith(
SDValue(N, 0), Res);
1597 SDValue DAGTypeLegalizer::SplitVecOp_VSELECT(
SDNode *N,
unsigned OpNo) {
1600 assert(OpNo == 0 &&
"Illegal operand must be mask");
1611 assert(Lo.getValueType() == Hi.getValueType() &&
1612 "Lo and Hi have differing types");
1616 assert(LoOpVT == HiOpVT &&
"Asymmetric vector split?");
1618 SDValue LoOp0, HiOp0, LoOp1, HiOp1, LoMask, HiMask;
1631 SDValue DAGTypeLegalizer::SplitVecOp_VECREDUCE(
SDNode *N,
unsigned OpNo) {
1638 assert(VecVT.
isVector() &&
"Can only split reduce vector operand");
1639 GetSplitVector(VecOp, Lo, Hi);
1644 unsigned CombineOpc = 0;
1696 Lo = BitConvertToInteger(Lo);
1697 Hi = BitConvertToInteger(Hi);
1703 JoinIntegers(Lo, Hi));
1706 SDValue DAGTypeLegalizer::SplitVecOp_EXTRACT_SUBVECTOR(
SDNode *N) {
1715 uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
1717 if (IdxVal < LoElts) {
1719 "Extracted subvector crosses vector split!");
1728 SDValue DAGTypeLegalizer::SplitVecOp_EXTRACT_VECTOR_ELT(
SDNode *N) {
1733 if (isa<ConstantSDNode>(Idx)) {
1734 uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
1738 GetSplitVector(Vec, Lo, Hi);
1740 uint64_t LoElts = Lo.getValueType().getVectorNumElements();
1742 if (IdxVal < LoElts)
1782 SDValue DAGTypeLegalizer::SplitVecOp_ExtVecInRegOp(
SDNode *N) {
1787 SplitVecRes_ExtVecInRegOp(N, Lo, Hi);
1808 GetSplitVector(Mask, MaskLo, MaskHi);
1810 std::tie(MaskLo, MaskHi) = DAG.
SplitVector(Mask, dl);
1813 EVT LoMemVT, HiMemVT;
1818 GetSplitVector(Src0, Src0Lo, Src0Hi);
1820 std::tie(Src0Lo, Src0Hi) = DAG.
SplitVector(Src0, dl);
1824 GetSplitVector(Index, IndexLo, IndexHi);
1826 std::tie(IndexLo, IndexHi) = DAG.
SplitVector(Index, dl);
1833 SDValue OpsLo[] = {Ch, Src0Lo, MaskLo,
Ptr, IndexLo};
1843 SDValue OpsHi[] = {Ch, Src0Hi, MaskHi,
Ptr, IndexHi};
1854 ReplaceValueWith(
SDValue(MGT, 1), Ch);
1858 ReplaceValueWith(
SDValue(MGT, 0), Res);
1872 EVT LoMemVT, HiMemVT;
1878 GetSplitVector(Data, DataLo, DataHi);
1885 GetSplitVector(Mask, MaskLo, MaskHi);
1889 MaskLo = PromoteTargetBoolean(MaskLo, DataLo.
getValueType());
1890 MaskHi = PromoteTargetBoolean(MaskHi, DataHi.
getValueType());
1894 unsigned SecondHalfAlignment =
1896 Alignment/2 : Alignment;
1935 EVT LoMemVT, HiMemVT;
1941 GetSplitVector(Data, DataLo, DataHi);
1948 GetSplitVector(Mask, MaskLo, MaskHi);
1954 GetSplitVector(Index, IndexLo, IndexHi);
1964 SDValue OpsLo[] = {Ch, DataLo, MaskLo,
Ptr, IndexLo};
1973 SDValue OpsHi[] = {Ch, DataHi, MaskHi,
Ptr, IndexHi};
1984 assert(OpNo == 1 &&
"Can only split the stored value");
1997 EVT LoMemVT, HiMemVT;
2000 unsigned IncrementSize = LoMemVT.getSizeInBits()/8;
2004 Alignment, MMOFlags, AAInfo);
2016 HiMemVT, Alignment, MMOFlags, AAInfo);
2020 Alignment, MMOFlags, AAInfo);
2025 SDValue DAGTypeLegalizer::SplitVecOp_CONCAT_VECTORS(
SDNode *N) {
2036 for (
unsigned i = 0, e = Op.getValueType().getVectorNumElements();
2047 SDValue DAGTypeLegalizer::SplitVecOp_TruncateHelper(
SDNode *N) {
2073 assert(!(NumElements & 1) &&
"Splitting vector, but not in half!");
2081 if (InElementSize <= OutElementSize * 2)
2082 return SplitVecOp_UnaryOp(N);
2089 EVT HalfElementVT = IsFloat ?
2091 EVT::getIntegerVT(*DAG.getContext(), InElementSize/2);
2114 "Operand types must be vectors");
2116 SDValue Lo0, Hi0, Lo1, Hi1, LoRes, HiRes;
2120 unsigned PartElements = Lo0.getValueType().getVectorNumElements();
2159 void DAGTypeLegalizer::WidenVectorResult(
SDNode *N,
unsigned ResNo) {
2160 DEBUG(
dbgs() <<
"Widen node result " << ResNo <<
": ";
2172 dbgs() <<
"WidenVectorResult #" << ResNo <<
": ";
2179 case ISD::BITCAST: Res = WidenVecRes_BITCAST(N);
break;
2185 case ISD::LOAD: Res = WidenVecRes_LOAD(N);
break;
2189 case ISD::SELECT: Res = WidenVecRes_SELECT(N);
break;
2191 case ISD::SETCC: Res = WidenVecRes_SETCC(N);
break;
2192 case ISD::UNDEF: Res = WidenVecRes_UNDEF(N);
break;
2194 Res = WidenVecRes_VECTOR_SHUFFLE(cast<ShuffleVectorSDNode>(N));
2197 Res = WidenVecRes_MLOAD(cast<MaskedLoadSDNode>(N));
2200 Res = WidenVecRes_MGATHER(cast<MaskedGatherSDNode>(N));
2219 Res = WidenVecRes_Binary(N);
2232 Res = WidenVecRes_BinaryCanTrap(N);
2236 Res = WidenVecRes_FCOPYSIGN(N);
2240 Res = WidenVecRes_POWI(N);
2246 Res = WidenVecRes_Shift(N);
2252 Res = WidenVecRes_EXTEND_VECTOR_INREG(N);
2265 Res = WidenVecRes_Convert(N);
2289 Res = WidenVecRes_Unary(N);
2292 Res = WidenVecRes_Ternary(N);
2298 SetWidenedVector(
SDValue(N, ResNo), Res);
2320 SDValue DAGTypeLegalizer::WidenVecRes_BinaryCanTrap(
SDNode *N) {
2330 NumElts = NumElts / 2;
2352 unsigned ConcatEnd = 0;
2360 while (CurNumElts != 0) {
2361 while (CurNumElts >= NumElts) {
2368 ConcatOps[ConcatEnd++] = DAG.
getNode(Opcode, dl, VT, EOp1, EOp2, Flags);
2370 CurNumElts -= NumElts;
2373 NumElts = NumElts / 2;
2378 for (
unsigned i = 0; i != CurNumElts; ++i, ++Idx) {
2385 ConcatOps[ConcatEnd++] = DAG.
getNode(Opcode, dl, WidenEltVT,
2393 if (ConcatEnd == 1) {
2394 VT = ConcatOps[0].getValueType();
2396 return ConcatOps[0];
2403 while (ConcatOps[ConcatEnd-1].getValueType() != MaxVT) {
2404 Idx = ConcatEnd - 1;
2405 VT = ConcatOps[Idx--].getValueType();
2406 while (Idx >= 0 && ConcatOps[Idx].getValueType() == VT)
2419 unsigned NumToInsert = ConcatEnd - Idx - 1;
2420 for (
unsigned i = 0, OpIdx = Idx+1; i < NumToInsert; i++, OpIdx++) {
2425 ConcatOps[Idx+1] = VecOp;
2426 ConcatEnd = Idx + 2;
2432 unsigned RealVals = ConcatEnd - Idx - 1;
2433 unsigned SubConcatEnd = 0;
2434 unsigned SubConcatIdx = Idx + 1;
2435 while (SubConcatEnd < RealVals)
2436 SubConcatOps[SubConcatEnd++] = ConcatOps[++Idx];
2437 while (SubConcatEnd < OpsToConcat)
2438 SubConcatOps[SubConcatEnd++] = undefVec;
2440 NextVT, SubConcatOps);
2441 ConcatEnd = SubConcatIdx + 1;
2446 if (ConcatEnd == 1) {
2447 VT = ConcatOps[0].getValueType();
2449 return ConcatOps[0];
2454 if (NumOps != ConcatEnd ) {
2456 for (
unsigned j = ConcatEnd; j < NumOps; ++j)
2457 ConcatOps[j] = UndefVal;
2480 InVTNumElts = InVT.getVectorNumElements();
2481 if (InVTNumElts == WidenNumElts) {
2483 return DAG.
getNode(Opcode,
DL, WidenVT, InOp);
2503 if (WidenNumElts % InVTNumElts == 0) {
2505 unsigned NumConcat = WidenNumElts/InVTNumElts;
2509 for (
unsigned i = 1; i != NumConcat; ++i)
2513 return DAG.
getNode(Opcode,
DL, WidenVT, InVec);
2517 if (InVTNumElts % WidenNumElts == 0) {
2523 return DAG.
getNode(Opcode,
DL, WidenVT, InVal);
2531 unsigned MinElts =
std::min(InVTNumElts, WidenNumElts);
2533 for (i=0; i < MinElts; ++i) {
2538 Ops[i] = DAG.
getNode(Opcode,
DL, EltVT, Val);
2544 for (; i < WidenNumElts; ++i)
2550 SDValue DAGTypeLegalizer::WidenVecRes_EXTEND_VECTOR_INREG(
SDNode *N) {
2564 InOp = GetWidenedVector(InOp);
2580 for (
unsigned i = 0, e =
std::min(InVTNumElts, WidenNumElts); i != e; ++i) {
2599 while (Ops.
size() != WidenNumElts)
2605 SDValue DAGTypeLegalizer::WidenVecRes_FCOPYSIGN(
SDNode *N) {
2609 return WidenVecRes_BinaryCanTrap(N);
2628 EVT ShVT = ShOp.getValueType();
2630 ShOp = GetWidenedVector(ShOp);
2631 ShVT = ShOp.getValueType();
2636 if (ShVT != ShWidenVT)
2637 ShOp = ModifyToType(ShOp, ShWidenVT);
2653 .getVectorElementType(),
2660 SDValue DAGTypeLegalizer::WidenVecRes_MERGE_VALUES(
SDNode *N,
unsigned ResNo) {
2661 SDValue WidenVec = DisintegrateMERGE_VALUES(N, ResNo);
2662 return GetWidenedVector(WidenVec);
2672 switch (getTypeAction(InVT)) {
2684 InOp = GetPromotedInteger(InOp);
2686 if (WidenVT.
bitsEq(InVT))
2699 InOp = GetWidenedVector(InOp);
2701 if (WidenVT.
bitsEq(InVT))
2710 if (WidenSize % InSize == 0 && InVT !=
MVT::x86mmx) {
2715 unsigned NewNumElts = WidenSize / InSize;
2733 for (
unsigned i = 1; i < NewNumElts; ++i)
2745 return CreateStackStoreLoad(InOp, WidenVT);
2748 SDValue DAGTypeLegalizer::WidenVecRes_BUILD_VECTOR(
SDNode *N) {
2762 assert(WidenNumElts >= NumElts &&
"Shrinking vector instead of widening!");
2763 NewOps.append(WidenNumElts - NumElts, DAG.
getUNDEF(EltVT));
2768 SDValue DAGTypeLegalizer::WidenVecRes_CONCAT_VECTORS(
SDNode *N) {
2776 bool InputWidened =
false;
2784 for (
unsigned i=0; i < NumOperands; ++i)
2786 for (
unsigned i = NumOperands; i != NumConcat; ++i)
2791 InputWidened =
true;
2795 for (i=1; i < NumOperands; ++i)
2799 if (i == NumOperands)
2804 if (NumOperands == 2) {
2807 for (
unsigned i = 0; i < NumInElts; ++i) {
2809 MaskOps[i + NumInElts] = i + WidenNumElts;
2823 for (
unsigned i=0; i < NumOperands; ++i) {
2826 InOp = GetWidenedVector(InOp);
2827 for (
unsigned j=0; j < NumInElts; ++j)
2833 for (; Idx < WidenNumElts; ++Idx)
2834 Ops[Idx] = UndefVal;
2838 SDValue DAGTypeLegalizer::WidenVecRes_EXTRACT_SUBVECTOR(
SDNode *N) {
2847 InOp = GetWidenedVector(InOp);
2852 uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
2853 if (IdxVal == 0 && InVT == WidenVT)
2858 if (IdxVal % WidenNumElts == 0 && IdxVal + WidenNumElts < InNumElts)
2867 for (i=0; i < NumElts; ++i)
2874 for (; i < WidenNumElts; ++i)
2879 SDValue DAGTypeLegalizer::WidenVecRes_INSERT_VECTOR_ELT(
SDNode *N) {
2893 Result = GenWidenVectorExtLoads(LdChain, LD, ExtType);
2895 Result = GenWidenVectorLoads(LdChain, LD);
2901 if (LdChain.
size() == 1)
2902 NewChain = LdChain[0];
2908 ReplaceValueWith(
SDValue(N, 1), NewChain);
2923 Mask = GetWidenedVector(Mask);
2925 EVT BoolVT = getSetCCResultType(WidenVT);
2932 unsigned NumConcat = WidenNumElts / MaskNumElts;
2936 for (
unsigned i = 1; i != NumConcat; ++i)
2961 Mask = WidenTargetBoolean(Mask, WideVT,
true);
2968 Index = ModifyToType(Index, WideIndexVT);
2980 SDValue DAGTypeLegalizer::WidenVecRes_SCALAR_TO_VECTOR(
SDNode *N) {
3044 if (MaskScalarBits < ToMaskScalBits) {
3048 }
else if (MaskScalarBits > ToMaskScalBits) {
3054 assert(Mask->getValueType(0).getScalarSizeInBits() ==
3056 "Mask should have the right element size by now.");
3059 unsigned CurrMaskNumEls = Mask->getValueType(0).getVectorNumElements();
3067 EVT SubVT = Mask->getValueType(0);
3069 SubConcatOps[0] =
Mask;
3070 for (
unsigned i = 1; i < NumSubVecs; ++i)
3071 SubConcatOps[i] = DAG.
getUNDEF(SubVT);
3076 assert((Mask->getValueType(0) == ToMaskVT) &&
3077 "A mask of ToMaskVT should have been produced by now.");
3083 EVT DAGTypeLegalizer::getSETCCWidenedResultTy(
SDValue SetCC) {
3117 EVT FinalVT = VSelVT;
3129 EVT SetCCResVT = getSetCCResultType(SetCCOpVT);
3139 VSelOp1 = GetWidenedVector(VSelOp1);
3140 VSelOp2 = GetWidenedVector(VSelOp2);
3144 EVT ToMaskVT = VSelVT;
3150 EVT MaskVT = getSETCCWidenedResultTy(Cond);
3151 Mask = convertMask(Cond, MaskVT, ToMaskVT);
3158 EVT VT0 = getSETCCWidenedResultTy(SETCC0);
3159 EVT VT1 = getSETCCWidenedResultTy(SETCC1);
3167 if (ScalarBits0 != ScalarBits1) {
3168 EVT NarrowVT = ((ScalarBits0 < ScalarBits1) ? VT0 : VT1);
3169 EVT WideVT = ((NarrowVT == VT0) ? VT1 : VT0);
3181 SETCC0 = convertMask(SETCC0, VT0, MaskVT);
3182 SETCC1 = convertMask(SETCC1, VT1, MaskVT);
3186 Mask = convertMask(Cond, MaskVT, ToMaskVT);
3200 if (
SDValue Res = WidenVSELECTAndMask(N))
3205 CondEltVT, WidenNumElts);
3207 Cond1 = GetWidenedVector(Cond1);
3215 SDValue SplitSelect = SplitVecOp_VSELECT(N, 0);
3216 SDValue Res = ModifyToType(SplitSelect, WidenVT);
3221 Cond1 = ModifyToType(Cond1, CondWidenVT);
3228 WidenVT, Cond1, InOp1, InOp2);
3231 SDValue DAGTypeLegalizer::WidenVecRes_SELECT_CC(
SDNode *N) {
3242 "Scalar/Vector type mismatch");
3270 for (
unsigned i = 0; i != NumElts; ++i) {
3272 if (Idx < (
int)NumElts)
3273 NewMask.push_back(Idx);
3275 NewMask.push_back(Idx - NumElts + WidenNumElts);
3277 for (
unsigned i = NumElts; i != WidenNumElts; ++i)
3278 NewMask.push_back(-1);
3285 "Operands must be vectors");
3287 unsigned WidenNumElts = WidenVT.getVectorNumElements();
3299 SDValue SplitVSetCC = SplitVecOp_VSETCC(N);
3300 SDValue Res = ModifyToType(SplitVSetCC, WidenVT);
3304 InOp1 = GetWidenedVector(InOp1);
3311 "Input not widened to expected type!");
3321 bool DAGTypeLegalizer::WidenVectorOperand(
SDNode *N,
unsigned OpNo) {
3322 DEBUG(
dbgs() <<
"Widen node operand " << OpNo <<
": ";
3334 dbgs() <<
"WidenVectorOperand op #" << OpNo <<
": ";
3344 case ISD::STORE: Res = WidenVecOp_STORE(N);
break;
3345 case ISD::MSTORE: Res = WidenVecOp_MSTORE(N, OpNo);
break;
3346 case ISD::MSCATTER: Res = WidenVecOp_MSCATTER(N, OpNo);
break;
3347 case ISD::SETCC: Res = WidenVecOp_SETCC(N);
break;
3353 Res = WidenVecOp_EXTEND(N);
3362 Res = WidenVecOp_Convert(N);
3367 if (!Res.getNode())
return false;
3371 if (Res.getNode() ==
N)
3376 "Invalid operand expansion");
3378 ReplaceValueWith(
SDValue(N, 0), Res);
3391 return WidenVecOp_Convert(N);
3392 InOp = GetWidenedVector(InOp);
3395 "Input wasn't widened!");
3407 FixedEltVT == InEltVT) {
3409 "Not enough elements in the fixed type for the operand!");
3411 "We can't have the same type as we started with!");
3428 return WidenVecOp_Convert(N);
3462 InOp = GetWidenedVector(InOp);
3468 for (
unsigned i=0; i < NumElts; ++i)
3485 unsigned InWidenSize = InWidenVT.getSizeInBits();
3489 unsigned NewNumElts = InWidenSize /
Size;
3499 return CreateStackStoreLoad(InOp, VT);
3502 SDValue DAGTypeLegalizer::WidenVecOp_CONCAT_VECTORS(
SDNode *N) {
3517 for (
unsigned i=0; i < NumOperands; ++i) {
3520 InOp = GetWidenedVector(InOp);
3521 for (
unsigned j=0; j < NumInElts; ++j)
3529 SDValue DAGTypeLegalizer::WidenVecOp_EXTRACT_SUBVECTOR(
SDNode *N) {
3535 SDValue DAGTypeLegalizer::WidenVecOp_EXTRACT_VECTOR_ELT(
SDNode *N) {
3548 GenWidenVectorTruncStores(StChain, ST);
3550 GenWidenVectorStores(StChain, ST);
3552 if (StChain.size() == 1)
3558 SDValue DAGTypeLegalizer::WidenVecOp_MSTORE(
SDNode *N,
unsigned OpNo) {
3561 EVT MaskVT = Mask.getValueType();
3564 SDValue WideVal = GetWidenedVector(StVal);
3568 Mask = GetWidenedVector(Mask);
3577 unsigned NumConcat = WidenNumElts / MaskNumElts;
3581 for (
unsigned i = 1; i != NumConcat; ++i)
3586 assert(Mask.getValueType().getVectorNumElements() ==
3588 "Mask and data vectors should have the same number of elements");
3594 SDValue DAGTypeLegalizer::WidenVecOp_MSCATTER(
SDNode *N,
unsigned OpNo) {
3595 assert(OpNo == 1 &&
"Can widen only data operand of mscatter");
3601 SDValue WideVal = GetWidenedVector(DataOp);
3607 Mask = WidenTargetBoolean(Mask, WideVT,
true);
3614 Index = ModifyToType(Index, WideIndexVT);
3662 unsigned Width,
EVT WidenVT,
3663 unsigned Align = 0,
unsigned WidenEx = 0) {
3667 unsigned AlignInBits =
Align*8;
3670 EVT RetVT = WidenEltVT;
3671 if (Width == WidenEltWidth)
3685 (WidenWidth % MemVTWidth) == 0 &&
3687 (MemVTWidth <= Width ||
3688 (
Align!=0 && MemVTWidth<=AlignInBits && MemVTWidth<=Width+WidenEx))) {
3701 (WidenWidth % MemVTWidth) == 0 &&
3703 (MemVTWidth <= Width ||
3704 (
Align!=0 && MemVTWidth<=AlignInBits && MemVTWidth<=Width+WidenEx))) {
3719 unsigned Start,
unsigned End) {
3721 SDLoc dl(LdOps[Start]);
3722 EVT LdTy = LdOps[Start].getValueType();
3730 for (
unsigned i = Start + 1; i !=
End; ++i) {
3731 EVT NewLdTy = LdOps[i].getValueType();
3732 if (NewLdTy != LdTy) {
3768 int WidthDiff = WidenWidth - LdWidth;
3772 EVT NewVT =
FindMemType(DAG, TLI, LdWidth, WidenVT, LdAlign, WidthDiff);
3775 Align, MMOFlags, AAInfo);
3779 if (LdWidth <= NewVTWidth) {
3781 unsigned NumElts = WidenWidth / NewVTWidth;
3786 if (NewVT == WidenVT)
3789 assert(WidenWidth % NewVTWidth == 0);
3790 unsigned NumConcat = WidenWidth / NewVTWidth;
3793 ConcatOps[0] = LdOp;
3794 for (
unsigned i = 1; i != NumConcat; ++i)
3795 ConcatOps[i] = UndefVal;
3803 LdWidth -= NewVTWidth;
3804 unsigned Offset = 0;
3806 while (LdWidth > 0) {
3807 unsigned Increment = NewVTWidth / 8;
3808 Offset += Increment;
3813 if (LdWidth < NewVTWidth) {
3815 NewVT =
FindMemType(DAG, TLI, LdWidth, WidenVT, LdAlign, WidthDiff);
3817 L = DAG.
getLoad(NewVT, dl, Chain, BasePtr,
3819 MinAlign(Align, Increment), MMOFlags, AAInfo);
3828 while (size < LdOp->getValueSizeInBits(0)) {
3835 L = DAG.
getLoad(NewVT, dl, Chain, BasePtr,
3837 MinAlign(Align, Increment), MMOFlags, AAInfo);
3844 LdWidth -= NewVTWidth;
3849 if (!LdOps[0].getValueType().
isVector())
3859 EVT LdTy = LdOps[i].getValueType();
3862 for (--i; i >= 0; --i) {
3863 LdTy = LdOps[i].getValueType();
3869 ConcatOps[--Idx] = LdOps[i];
3870 for (--i; i >= 0; --i) {
3871 EVT NewLdTy = LdOps[i].getValueType();
3872 if (NewLdTy != LdTy) {
3879 ConcatOps[--Idx] = LdOps[i];
3892 for (; i != End-Idx; ++i)
3893 WidenOps[i] = ConcatOps[Idx+i];
3894 for (; i != NumOps; ++i)
3895 WidenOps[i] = UndefVal;
3928 LdEltVT,
Align, MMOFlags, AAInfo);
3930 unsigned i = 0, Offset = Increment;
3931 for (i=1; i < NumElts; ++i, Offset += Increment) {
3936 Ops[i] = DAG.
getExtLoad(ExtType, dl, EltVT, Chain, NewBasePtr,
3938 Align, MMOFlags, AAInfo);
3944 for (; i != WidenNumElts; ++i)
3972 unsigned Offset = 0;
3973 while (StWidth != 0) {
3977 unsigned Increment = NewVTWidth / 8;
3986 MinAlign(Align, Offset), MMOFlags, AAInfo));
3987 StWidth -= NewVTWidth;
3988 Offset += Increment;
3993 }
while (StWidth != 0 && StWidth >= NewVTWidth);
3996 unsigned NumElts = ValWidth / NewVTWidth;
4000 Idx = Idx * ValEltWidth / NewVTWidth;
4008 MinAlign(Align, Offset), MMOFlags, AAInfo));
4009 StWidth -= NewVTWidth;
4010 Offset += Increment;
4014 }
while (StWidth != 0 && StWidth >= NewVTWidth);
4016 Idx = Idx * NewVTWidth / ValEltWidth;
4054 unsigned Offset = Increment;
4055 for (
unsigned i=1; i < NumElts; ++i, Offset += Increment) {
4065 StEltVT,
MinAlign(Align, Offset), MMOFlags, AAInfo));
4073 bool FillWithZeroes) {
4078 "input and widen element type must match");
4087 if (WidenNumElts > InNumElts && WidenNumElts % InNumElts == 0) {
4088 unsigned NumConcat = WidenNumElts / InNumElts;
4093 for (
unsigned i = 1; i != NumConcat; ++i)
4099 if (WidenNumElts < InNumElts && InNumElts % WidenNumElts)
4107 unsigned MinNumElts =
std::min(WidenNumElts, InNumElts);
4109 for (Idx = 0; Idx < MinNumElts; ++Idx)
4116 for ( ; Idx < WidenNumElts; ++Idx)
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
unsigned getValueSizeInBits(unsigned ResNo) const
Returns MVT::getSizeInBits(getValueType(ResNo)).
void push_back(const T &Elt)
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
SDValue getValue(unsigned R) const
const SDValue & getValue() const
bool isTruncatingStore() const
Return true if the op does a truncation before store.
Flags getFlags() const
Return the raw flags of the source value,.
LLVMContext * getContext() const
bool isBuildVectorOfConstantSDNodes(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR node of all ConstantSDNode or undef...
SDValue UnrollVectorOp(SDNode *N, unsigned ResNE=0)
Utility function used by legalize and lowering to "unroll" a vector operation by splitting out the sc...
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an vector value) starting with the ...
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 ...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
SDValue getSignExtendVectorInReg(SDValue Op, const SDLoc &DL, EVT VT)
Return an operation which will sign extend the low lanes of the operand into the specified vector typ...
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
std::pair< EVT, EVT > GetSplitDestVTs(const EVT &VT) const
Compute the VTs needed for the low/hi parts of a type which is split (or expanded) into two not neces...
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
static ISD::NodeType getExtendForContent(BooleanContent Content)
const SDValue & getSrc0() const
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool isUnindexed() const
Return true if this is NOT a pre/post inc/dec load/store.
unsigned getNumOperands() const
Return the number of values used by this operation.
unsigned getValueSizeInBits() const
Returns the size of the value in bits.
const SDValue & getOperand(unsigned Num) const
SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS)
Helper function to make it easier to build Select's if you just have operands and don't want to check...
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT TVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
[US]{MIN/MAX} - Binary minimum or maximum or signed or unsigned integers.
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
const SDValue & getBasePtr() const
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1 at the ...
static SDValue BuildVectorFromScalar(SelectionDAG &DAG, EVT VecTy, SmallVectorImpl< SDValue > &LdOps, unsigned Start, unsigned End)
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
bool isUndef() const
Return true if the type of the node type undefined.
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
SDValue getAnyExtendVectorInReg(SDValue Op, const SDLoc &DL, EVT VT)
Return an operation which will any-extend the low lanes of the operand into the specified vector type...
bool isVector() const
Return true if this is a vector value type.
virtual bool canOpTrap(unsigned Op, EVT VT) const
Returns true if the operation can trap for the value type.
A description of a memory reference used in the backend.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Shift and rotation operations.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
MachineFunction & getMachineFunction() const
SDValue getMaskedScatter(SDVTList VTs, EVT VT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
MachinePointerInfo getWithOffset(int64_t O) const
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
SDValue IncrementMemoryAddress(SDValue Addr, SDValue Mask, const SDLoc &DL, EVT DataVT, SelectionDAG &DAG, bool IsCompressedMemory) const
Increments memory address Addr according to the type of the value DataVT that should be stored...
int getMaskElt(unsigned Idx) const
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
ISD::LoadExtType getExtensionType() const
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool isInteger() const
Return true if this is an integer or a vector integer type.
SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
This class is used to represent an MSTORE node.
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...
EVT getVectorElementType() const
Given a vector type, return the type of each element.
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
SDValue getMaskedGather(SDVTList VTs, EVT VT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO)
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
Simple integer binary arithmetic operators.
const SDValue & getBasePtr() const
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
SDValue getMaskedStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Mask, EVT MemVT, MachineMemOperand *MMO, bool IsTruncating=false, bool IsCompressing=false)
EVT getMemoryVT() const
Return the type of the in-memory value.
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
SDValue getVectorElementPointer(SelectionDAG &DAG, SDValue VecPtr, EVT VecVT, SDValue Idx) const
Get a pointer to vector element Idx located in memory for a vector of type VecVT starting at a base a...
const DataLayout & getDataLayout() const
UNDEF - An undefined node.
This class is used to represent ISD::STORE nodes.
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the specified, possibly variable...
SDNode * getNode() const
get the SDNode which holds the desired result
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
unsigned getScalarSizeInBits() const
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
These reductions are non-strict, and have a single vector operand.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
static EVT FindMemType(SelectionDAG &DAG, const TargetLowering &TLI, unsigned Width, EVT WidenVT, unsigned Align=0, unsigned WidenEx=0)
const SDValue & getOperand(unsigned i) const
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
bool isCompressingStore() const
Returns true if the op does a compression to the vector before storing.
Simple binary floating point operators.
const SDNodeFlags getFlags() const
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL...
std::pair< SDValue, SDValue > SplitVectorOperand(const SDNode *N, unsigned OpNo)
Split the node's operand with EXTRACT_SUBVECTOR and return the low/high part.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
unsigned getOriginalAlignment() const
Returns alignment and volatility of the memory access.
static EVT getFloatingPointVT(unsigned BitWidth)
Returns the EVT that represents a floating-point type with the given number of bits.
static const unsigned End
unsigned getOpcode() const
const SDValue & getBasePtr() const
SDValue getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Mask, SDValue Src0, EVT MemVT, MachineMemOperand *MMO, ISD::LoadExtType, bool IsExpanding=false)
const SDValue & getValue() const
Bit counting operators with an undefined result for zero inputs.
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
const SDValue & getMask() const
bool bitsEq(EVT VT) const
Return true if this has the same number of bits as VT.
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...
This class contains a discriminated union of information about pointers in memory operands...
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, 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 CreateStackTemporary(EVT VT, unsigned minAlign=1)
Create a stack temporary, suitable for holding the specified value type.
const MachinePointerInfo & getPointerInfo() const
const MDNode * getRanges() const
Returns the Ranges that describes the dereference.
bool isUNINDEXEDLoad(const SDNode *N)
Returns true if the specified node is an unindexed load.
The memory access writes data.
SDValue getZeroExtendVectorInReg(SDValue Op, const SDLoc &DL, EVT VT)
Return an operation which will zero extend the low lanes of the operand into the specified vector typ...
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
TokenFactor - This node takes multiple tokens as input and produces a single token result...
void dump() const
Dump this node, for debugging.
Returns platform specific canonical encoding of a floating point number.
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
std::pair< SDValue, SDValue > SplitVector(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HiVT)
Split the vector with EXTRACT_SUBVECTOR using the provides VTs and return the low/high part...
SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and rounds it to a floating point val...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const
Return the ValueType of the result of SETCC operations.
bool isVector(MCInstrInfo const &MCII, MCInst const &MCI)
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
const SDValue & getChain() const
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Byte Swap and Counting operators.
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
static bool isSETCCorConvertedSETCC(SDValue N)
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
const SDValue & getValue() const
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
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...
Select(COND, TRUEVAL, FALSEVAL).
op_iterator op_begin() const
ZERO_EXTEND - Used for integer types, zeroing the new bits.
ANY_EXTEND - Used for integer types. The high bits are undefined.
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
EVT widenIntegerVectorElementType(LLVMContext &Context) const
Return a VT for an integer vector type with the size of the elements doubled.
FMINNAN/FMAXNAN - Behave identically to FMINNUM/FMAXNUM, except that when a single input is NaN...
iterator_range< value_op_iterator > op_values() const
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
Flags
Flags values. These may be or'd together.
llvm_unreachable("Unknown RegBank!")
const SDValue & getMask() const
The memory access reads data.
static std::vector< std::string > Flags
These are IR-level optimization flags that may be propagated to SDNodes.
Bitwise operators - logical and, logical or, logical xor.
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
op_iterator op_end() const
bool isExpandingLoad() const
This class is used to represent an MSCATTER node.
const SDValue & getIndex() const
EVT getValueType() const
Return the ValueType of the referenced return value.
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class is used to represent an MLOAD node.
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...
EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
FMA - Perform a * b + c with no intermediate rounding step.
const SDValue & getBasePtr() const
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...
FMIN/FMAX nodes can have flags, for NaN/NoNaN variants.
bool isTruncatingStore() const
Return true if the op does a truncation before store.
This class is used to represent an MGATHER node.
SDValue getValueType(EVT)
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
const TargetLowering & getTargetLoweringInfo() const
SetCC operator - This evaluates to a true value iff the condition is true.
static bool isLogicalMaskOp(unsigned Opcode)
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
BooleanContent
Enum that describes how the target represents true/false values.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
TRUNCATE - Completely drop the high bits.
unsigned getAlignment() const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, FLOG, FLOG2, FLOG10, FEXP, FEXP2, FCEIL, FTRUNC, FRINT, FNEARBYINT, FROUND, FFLOOR - Perform various unary floating point operations.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
EVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
This class is used to represent ISD::LOAD nodes.