29 #define DEBUG_TYPE "legalize-types" 35 void DAGTypeLegalizer::ScalarizeVectorResult(
SDNode *
N,
unsigned ResNo) {
43 dbgs() <<
"ScalarizeVectorResult #" << ResNo <<
": ";
51 case ISD::BITCAST: R = ScalarizeVecRes_BITCAST(N);
break;
56 case ISD::FPOWI: R = ScalarizeVecRes_FPOWI(N);
break;
58 case ISD::LOAD: R = ScalarizeVecRes_LOAD(cast<LoadSDNode>(N));
break;
61 case ISD::VSELECT: R = ScalarizeVecRes_VSELECT(N);
break;
62 case ISD::SELECT: R = ScalarizeVecRes_SELECT(N);
break;
64 case ISD::SETCC: R = ScalarizeVecRes_SETCC(N);
break;
65 case ISD::UNDEF: R = ScalarizeVecRes_UNDEF(N);
break;
70 R = ScalarizeVecRes_VecInregOp(N);
105 R = ScalarizeVecRes_UnaryOp(N);
137 R = ScalarizeVecRes_BinOp(N);
140 R = ScalarizeVecRes_TernaryOp(N);
146 SetScalarizedVector(
SDValue(N, ResNo), R);
156 SDValue DAGTypeLegalizer::ScalarizeVecRes_TernaryOp(
SDNode *N) {
164 SDValue DAGTypeLegalizer::ScalarizeVecRes_MERGE_VALUES(
SDNode *N,
166 SDValue Op = DisintegrateMERGE_VALUES(N, ResNo);
167 return GetScalarizedVector(Op);
170 SDValue DAGTypeLegalizer::ScalarizeVecRes_BITCAST(
SDNode *N) {
175 Op = GetScalarizedVector(Op);
181 SDValue DAGTypeLegalizer::ScalarizeVecRes_BUILD_VECTOR(
SDNode *N) {
191 SDValue DAGTypeLegalizer::ScalarizeVecRes_EXTRACT_SUBVECTOR(
SDNode *N) {
197 SDValue DAGTypeLegalizer::ScalarizeVecRes_FP_ROUND(
SDNode *N) {
210 SDValue DAGTypeLegalizer::ScalarizeVecRes_INSERT_VECTOR_ELT(
SDNode *N) {
238 SDValue DAGTypeLegalizer::ScalarizeVecRes_UnaryOp(
SDNode *N) {
252 Op = GetScalarizedVector(Op);
262 SDValue DAGTypeLegalizer::ScalarizeVecRes_InregOp(
SDNode *N) {
270 SDValue DAGTypeLegalizer::ScalarizeVecRes_VecInregOp(
SDNode *N) {
279 Op = GetScalarizedVector(Op);
298 SDValue DAGTypeLegalizer::ScalarizeVecRes_SCALAR_TO_VECTOR(
SDNode *N) {
308 SDValue DAGTypeLegalizer::ScalarizeVecRes_VSELECT(
SDNode *N) {
316 Cond = GetScalarizedVector(Cond);
346 if (ScalarBool != VecBool) {
347 switch (ScalarBool) {
368 auto BoolVT = getSetCCResultType(CondVT);
369 if (BoolVT.bitsLT(CondVT))
377 SDValue DAGTypeLegalizer::ScalarizeVecRes_SELECT(
SDNode *N) {
384 SDValue DAGTypeLegalizer::ScalarizeVecRes_SELECT_CC(
SDNode *N) {
396 SDValue DAGTypeLegalizer::ScalarizeVecRes_VECTOR_SHUFFLE(
SDNode *N) {
401 unsigned Op = !cast<ConstantSDNode>(
Arg)->isNullValue();
402 return GetScalarizedVector(N->
getOperand(Op));
408 "Operand types must be vectors");
411 EVT OpVT = LHS.getValueType();
417 LHS = GetScalarizedVector(LHS);
418 RHS = GetScalarizedVector(RHS);
436 return DAG.
getNode(ExtendCode, DL, NVT, Res);
444 bool DAGTypeLegalizer::ScalarizeVectorOperand(
SDNode *N,
unsigned OpNo) {
449 if (!Res.getNode()) {
453 dbgs() <<
"ScalarizeVectorOperand Op #" << OpNo <<
": ";
460 Res = ScalarizeVecOp_BITCAST(N);
470 Res = ScalarizeVecOp_UnaryOp(N);
473 Res = ScalarizeVecOp_CONCAT_VECTORS(N);
476 Res = ScalarizeVecOp_EXTRACT_VECTOR_ELT(N);
479 Res = ScalarizeVecOp_VSELECT(N);
482 Res = ScalarizeVecOp_VSETCC(N);
485 Res = ScalarizeVecOp_STORE(cast<StoreSDNode>(N), OpNo);
488 Res = ScalarizeVecOp_FP_ROUND(N, OpNo);
494 if (!Res.getNode())
return false;
498 if (Res.getNode() ==
N)
502 "Invalid operand expansion");
504 ReplaceValueWith(
SDValue(N, 0), Res);
510 SDValue DAGTypeLegalizer::ScalarizeVecOp_BITCAST(
SDNode *N) {
518 SDValue DAGTypeLegalizer::ScalarizeVecOp_UnaryOp(
SDNode *N) {
520 "Unexpected vector type!");
530 SDValue DAGTypeLegalizer::ScalarizeVecOp_CONCAT_VECTORS(
SDNode *N) {
533 Ops[i] = GetScalarizedVector(N->
getOperand(i));
539 SDValue DAGTypeLegalizer::ScalarizeVecOp_EXTRACT_VECTOR_ELT(
SDNode *N) {
552 SDValue DAGTypeLegalizer::ScalarizeVecOp_VSELECT(
SDNode *N) {
566 "Operand types must be vectors");
585 Res = DAG.
getNode(ExtendCode, DL, NVT, Res);
594 assert(OpNo == 1 &&
"Do not know how to scalarize this operand!");
612 SDValue DAGTypeLegalizer::ScalarizeVecOp_FP_ROUND(
SDNode *N,
unsigned OpNo) {
628 void DAGTypeLegalizer::SplitVectorResult(
SDNode *N,
unsigned ResNo) {
639 dbgs() <<
"SplitVectorResult #" << ResNo <<
": ";
648 case ISD::SELECT: SplitRes_SELECT(N, Lo, Hi);
break;
650 case ISD::UNDEF: SplitRes_UNDEF(N, Lo, Hi);
break;
651 case ISD::BITCAST: SplitVecRes_BITCAST(N, Lo, Hi);
break;
657 case ISD::FPOWI: SplitVecRes_FPOWI(N, Lo, Hi);
break;
663 SplitVecRes_LOAD(cast<LoadSDNode>(N), Lo, Hi);
666 SplitVecRes_MLOAD(cast<MaskedLoadSDNode>(N), Lo, Hi);
669 SplitVecRes_MGATHER(cast<MaskedGatherSDNode>(N), Lo, Hi);
672 SplitVecRes_SETCC(N, Lo, Hi);
675 SplitVecRes_VECTOR_SHUFFLE(cast<ShuffleVectorSDNode>(N), Lo, Hi);
681 SplitVecRes_ExtVecInRegOp(N, Lo, Hi);
715 SplitVecRes_UnaryOp(N, Lo, Hi);
721 SplitVecRes_ExtendOp(N, Lo, Hi);
753 SplitVecRes_BinOp(N, Lo, Hi);
756 SplitVecRes_TernaryOp(N, Lo, Hi);
775 SplitVecRes_StrictFPOp(N, Lo, Hi);
787 GetSplitVector(N->
getOperand(0), LHSLo, LHSHi);
789 GetSplitVector(N->
getOperand(1), RHSLo, RHSHi);
798 void DAGTypeLegalizer::SplitVecRes_TernaryOp(
SDNode *N,
SDValue &Lo,
801 GetSplitVector(N->
getOperand(0), Op0Lo, Op0Hi);
803 GetSplitVector(N->
getOperand(1), Op1Lo, Op1Hi);
805 GetSplitVector(N->
getOperand(2), Op2Lo, Op2Hi);
809 Op0Lo, Op1Lo, Op2Lo);
811 Op0Hi, Op1Hi, Op2Hi);
814 void DAGTypeLegalizer::SplitVecRes_BITCAST(
SDNode *N,
SDValue &Lo,
826 switch (getTypeAction(InVT)) {
840 GetExpandedOp(InOp, Lo, Hi);
851 GetSplitVector(InOp, Lo, Hi);
863 SplitInteger(BitConvertToInteger(InOp), LoIntVT, HiIntVT, Lo, Hi);
871 void DAGTypeLegalizer::SplitVecRes_BUILD_VECTOR(
SDNode *N,
SDValue &Lo,
884 void DAGTypeLegalizer::SplitVecRes_CONCAT_VECTORS(
SDNode *N,
SDValue &Lo,
889 if (NumSubvectors == 1) {
905 void DAGTypeLegalizer::SplitVecRes_EXTRACT_SUBVECTOR(
SDNode *N,
SDValue &Lo,
915 uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
921 void DAGTypeLegalizer::SplitVecRes_INSERT_SUBVECTOR(
SDNode *N,
SDValue &Lo,
927 GetSplitVector(Vec, Lo, Hi);
940 unsigned IdxVal = ConstIdx->getZExtValue();
941 if ((IdxVal == 0) && (IdxVal + SubElems <= VecElems / 2)) {
968 DAG.
getConstant(IncrementSize, dl, StackPtr.getValueType()));
972 MinAlign(Alignment, IncrementSize));
975 void DAGTypeLegalizer::SplitVecRes_FPOWI(
SDNode *N,
SDValue &Lo,
983 void DAGTypeLegalizer::SplitVecRes_FCOPYSIGN(
SDNode *N,
SDValue &Lo,
986 GetSplitVector(N->
getOperand(0), LHSLo, LHSHi);
993 GetSplitVector(RHS, RHSLo, RHSHi);
1002 void DAGTypeLegalizer::SplitVecRes_InregOp(
SDNode *N,
SDValue &Lo,
1005 GetSplitVector(N->
getOperand(0), LHSLo, LHSHi);
1009 std::tie(LoVT, HiVT) =
1018 void DAGTypeLegalizer::SplitVecRes_ExtVecInRegOp(
SDNode *N,
SDValue &Lo,
1027 GetSplitVector(N0, InLo, InHi);
1034 EVT OutLoVT, OutHiVT;
1037 assert((2 * OutNumElements) <= InNumElements &&
1038 "Illegal extend vector in reg split");
1048 for (
unsigned i = 0; i != OutNumElements; ++i)
1049 SplitHi[i] = i + OutNumElements;
1052 Lo = DAG.
getNode(Opcode, dl, OutLoVT, InLo);
1053 Hi = DAG.
getNode(Opcode, dl, OutHiVT, InHi);
1056 void DAGTypeLegalizer::SplitVecRes_StrictFPOp(
SDNode *N,
SDValue &Lo,
1072 for (
unsigned i = 1; i < NumOps; ++i) {
1082 GetSplitVector(Op, OpLo, OpHi);
1092 EVT HiValueVTs[] = {HiVT, MVT::Other};
1103 ReplaceValueWith(
SDValue(N, 1), Chain);
1106 void DAGTypeLegalizer::SplitVecRes_INSERT_VECTOR_ELT(
SDNode *N,
SDValue &Lo,
1112 GetSplitVector(Vec, Lo, Hi);
1115 unsigned IdxVal = CIdx->getZExtValue();
1117 if (IdxVal < LoNumElts)
1164 Lo = DAG.
getLoad(LoVT, dl, Store, StackPtr, PtrInfo);
1168 StackPtr = DAG.
getNode(
ISD::ADD, dl, StackPtr.getValueType(), StackPtr,
1170 StackPtr.getValueType()));
1173 Hi = DAG.
getLoad(HiVT, dl, Store, StackPtr,
1174 PtrInfo.getWithOffset(IncrementSize),
1175 MinAlign(Alignment, IncrementSize));
1185 void DAGTypeLegalizer::SplitVecRes_SCALAR_TO_VECTOR(
SDNode *N,
SDValue &Lo,
1210 EVT LoMemVT, HiMemVT;
1220 Alignment, MMOFlags, AAInfo);
1229 ReplaceValueWith(
SDValue(LD, 1), Ch);
1247 unsigned SecondHalfAlignment =
1249 Alignment/2 : Alignment;
1254 GetSplitVector(Mask, MaskLo, MaskHi);
1256 std::tie(MaskLo, MaskHi) = DAG.
SplitVector(Mask, dl);
1259 EVT LoMemVT, HiMemVT;
1264 GetSplitVector(Src0, Src0Lo, Src0Hi);
1266 std::tie(Src0Lo, Src0Hi) = DAG.
SplitVector(Src0, dl);
1273 Lo = DAG.
getMaskedLoad(LoVT, dl, Ch, Ptr, MaskLo, Src0Lo, LoMemVT, MMO,
1285 Hi = DAG.
getMaskedLoad(HiVT, dl, Ch, Ptr, MaskHi, Src0Hi, HiMemVT, MMO,
1295 ReplaceValueWith(
SDValue(MLD, 1), Ch);
1316 GetSplitVector(Mask, MaskLo, MaskHi);
1318 std::tie(MaskLo, MaskHi) = DAG.
SplitVector(Mask, dl);
1321 EVT LoMemVT, HiMemVT;
1327 GetSplitVector(Src0, Src0Lo, Src0Hi);
1329 std::tie(Src0Lo, Src0Hi) = DAG.
SplitVector(Src0, dl);
1333 GetSplitVector(Index, IndexLo, IndexHi);
1335 std::tie(IndexLo, IndexHi) = DAG.
SplitVector(Index, dl);
1342 SDValue OpsLo[] = {Ch, Src0Lo, MaskLo, Ptr, IndexLo, Scale};
1346 SDValue OpsHi[] = {Ch, Src0Hi, MaskHi, Ptr, IndexHi, Scale};
1357 ReplaceValueWith(
SDValue(MGT, 1), Ch);
1364 "Operand types must be vectors");
1388 void DAGTypeLegalizer::SplitVecRes_UnaryOp(
SDNode *N,
SDValue &Lo,
1412 void DAGTypeLegalizer::SplitVecRes_ExtendOp(
SDNode *N,
SDValue &Lo,
1434 if ((NumElements & 1) == 0 &&
1440 EVT SplitLoVT, SplitHiVT;
1444 LLVM_DEBUG(
dbgs() <<
"Split vector extend via incremental extend:";
1458 SplitVecRes_UnaryOp(N, Lo, Hi);
1466 GetSplitVector(N->
getOperand(0), Inputs[0], Inputs[1]);
1467 GetSplitVector(N->
getOperand(1), Inputs[2], Inputs[3]);
1482 unsigned InputUsed[2] = { -1U, -1U };
1483 unsigned FirstMaskIdx =
High * NewElts;
1484 bool useBuildVector =
false;
1485 for (
unsigned MaskOffset = 0; MaskOffset < NewElts; ++MaskOffset) {
1487 int Idx = N->
getMaskElt(FirstMaskIdx + MaskOffset);
1490 unsigned Input = (
unsigned)Idx / NewElts;
1499 Idx -= Input * NewElts;
1504 if (InputUsed[OpNo] == Input) {
1507 }
else if (InputUsed[OpNo] == -1U) {
1509 InputUsed[OpNo] = Input;
1517 useBuildVector =
true;
1525 if (useBuildVector) {
1530 for (
unsigned MaskOffset = 0; MaskOffset < NewElts; ++MaskOffset) {
1532 int Idx = N->
getMaskElt(FirstMaskIdx + MaskOffset);
1535 unsigned Input = (
unsigned)Idx / NewElts;
1544 Idx -= Input * NewElts;
1554 }
else if (InputUsed[0] == -1U) {
1558 SDValue Op0 = Inputs[InputUsed[0]];
1560 SDValue Op1 = InputUsed[1] == -1U ?
1561 DAG.
getUNDEF(NewVT) : Inputs[InputUsed[1]];
1579 bool DAGTypeLegalizer::SplitVectorOperand(
SDNode *N,
unsigned OpNo) {
1587 if (!Res.getNode()) {
1591 dbgs() <<
"SplitVectorOperand Op #" << OpNo <<
": ";
1598 case ISD::SETCC: Res = SplitVecOp_VSETCC(N);
break;
1604 Res = SplitVecOp_TruncateHelper(N);
1609 Res = SplitVecOp_STORE(cast<StoreSDNode>(N), OpNo);
1612 Res = SplitVecOp_MSTORE(cast<MaskedStoreSDNode>(N), OpNo);
1615 Res = SplitVecOp_MSCATTER(cast<MaskedScatterSDNode>(N), OpNo);
1618 Res = SplitVecOp_MGATHER(cast<MaskedGatherSDNode>(N), OpNo);
1621 Res = SplitVecOp_VSELECT(N, OpNo);
1626 Res = SplitVecOp_TruncateHelper(N);
1628 Res = SplitVecOp_UnaryOp(N);
1633 Res = SplitVecOp_TruncateHelper(N);
1635 Res = SplitVecOp_UnaryOp(N);
1646 Res = SplitVecOp_UnaryOp(N);
1652 Res = SplitVecOp_ExtVecInRegOp(N);
1668 Res = SplitVecOp_VECREDUCE(N, OpNo);
1674 if (!Res.getNode())
return false;
1678 if (Res.getNode() ==
N)
1682 "Invalid operand expansion");
1684 ReplaceValueWith(
SDValue(N, 0), Res);
1688 SDValue DAGTypeLegalizer::SplitVecOp_VSELECT(
SDNode *N,
unsigned OpNo) {
1691 assert(OpNo == 0 &&
"Illegal operand must be mask");
1702 assert(Lo.getValueType() == Hi.getValueType() &&
1703 "Lo and Hi have differing types");
1707 assert(LoOpVT == HiOpVT &&
"Asymmetric vector split?");
1709 SDValue LoOp0, HiOp0, LoOp1, HiOp1, LoMask, HiMask;
1710 std::tie(LoOp0, HiOp0) = DAG.
SplitVector(Src0, DL);
1711 std::tie(LoOp1, HiOp1) = DAG.
SplitVector(Src1, DL);
1712 std::tie(LoMask, HiMask) = DAG.
SplitVector(Mask, DL);
1722 SDValue DAGTypeLegalizer::SplitVecOp_VECREDUCE(
SDNode *N,
unsigned OpNo) {
1729 assert(VecVT.
isVector() &&
"Can only split reduce vector operand");
1730 GetSplitVector(VecOp, Lo, Hi);
1735 unsigned CombineOpc = 0;
1787 Lo = BitConvertToInteger(Lo);
1788 Hi = BitConvertToInteger(Hi);
1794 JoinIntegers(Lo, Hi));
1797 SDValue DAGTypeLegalizer::SplitVecOp_EXTRACT_SUBVECTOR(
SDNode *N) {
1806 uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
1808 if (IdxVal < LoElts) {
1810 "Extracted subvector crosses vector split!");
1819 SDValue DAGTypeLegalizer::SplitVecOp_EXTRACT_VECTOR_ELT(
SDNode *N) {
1824 if (isa<ConstantSDNode>(Idx)) {
1825 uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
1829 GetSplitVector(Vec, Lo, Hi);
1831 uint64_t LoElts = Lo.getValueType().getVectorNumElements();
1833 if (IdxVal < LoElts)
1868 SDValue DAGTypeLegalizer::SplitVecOp_ExtVecInRegOp(
SDNode *N) {
1873 SplitVecRes_ExtVecInRegOp(N, Lo, Hi);
1895 GetSplitVector(Mask, MaskLo, MaskHi);
1897 std::tie(MaskLo, MaskHi) = DAG.
SplitVector(Mask, dl);
1900 EVT LoMemVT, HiMemVT;
1905 GetSplitVector(Src0, Src0Lo, Src0Hi);
1907 std::tie(Src0Lo, Src0Hi) = DAG.
SplitVector(Src0, dl);
1911 GetSplitVector(Index, IndexLo, IndexHi);
1913 std::tie(IndexLo, IndexHi) = DAG.
SplitVector(Index, dl);
1920 SDValue OpsLo[] = {Ch, Src0Lo, MaskLo, Ptr, IndexLo, Scale};
1930 SDValue OpsHi[] = {Ch, Src0Hi, MaskHi, Ptr, IndexHi, Scale};
1941 ReplaceValueWith(
SDValue(MGT, 1), Ch);
1945 ReplaceValueWith(
SDValue(MGT, 0), Res);
1959 EVT LoMemVT, HiMemVT;
1965 GetSplitVector(Data, DataLo, DataHi);
1967 std::tie(DataLo, DataHi) = DAG.
SplitVector(Data, DL);
1972 GetSplitVector(Mask, MaskLo, MaskHi);
1974 std::tie(MaskLo, MaskHi) = DAG.
SplitVector(Mask, DL);
1978 unsigned SecondHalfAlignment =
1980 Alignment/2 : Alignment;
1988 Lo = DAG.
getMaskedStore(Ch, DL, DataLo, Ptr, MaskLo, LoMemVT, MMO,
2001 Hi = DAG.
getMaskedStore(Ch, DL, DataHi, Ptr, MaskHi, HiMemVT, MMO,
2022 EVT LoMemVT, HiMemVT;
2028 GetSplitVector(Data, DataLo, DataHi);
2030 std::tie(DataLo, DataHi) = DAG.
SplitVector(Data, DL);
2035 GetSplitVector(Mask, MaskLo, MaskHi);
2037 std::tie(MaskLo, MaskHi) = DAG.
SplitVector(Mask, DL);
2041 GetSplitVector(Index, IndexLo, IndexHi);
2043 std::tie(IndexLo, IndexHi) = DAG.
SplitVector(Index, DL);
2051 SDValue OpsLo[] = {Ch, DataLo, MaskLo, Ptr, IndexLo, Scale};
2063 SDValue OpsHi[] = {
Lo, DataHi, MaskHi, Ptr, IndexHi, Scale};
2070 assert(OpNo == 1 &&
"Can only split the stored value");
2083 EVT LoMemVT, HiMemVT;
2087 if (!LoMemVT.isByteSized() || !HiMemVT.isByteSized())
2090 unsigned IncrementSize = LoMemVT.getSizeInBits()/8;
2094 Alignment, MMOFlags, AAInfo);
2105 HiMemVT, Alignment, MMOFlags, AAInfo);
2109 Alignment, MMOFlags, AAInfo);
2114 SDValue DAGTypeLegalizer::SplitVecOp_CONCAT_VECTORS(
SDNode *N) {
2125 for (
unsigned i = 0, e =
Op.getValueType().getVectorNumElements();
2136 SDValue DAGTypeLegalizer::SplitVecOp_TruncateHelper(
SDNode *N) {
2162 assert(!(NumElements & 1) &&
"Splitting vector, but not in half!");
2170 if (InElementSize <= OutElementSize * 2)
2171 return SplitVecOp_UnaryOp(N);
2176 GetSplitVector(InVec, InLoVec, InHiVec);
2178 EVT HalfElementVT = IsFloat ?
2203 "Operand types must be vectors");
2205 SDValue Lo0, Hi0, Lo1, Hi1, LoRes, HiRes;
2209 unsigned PartElements = Lo0.getValueType().getVectorNumElements();
2248 void DAGTypeLegalizer::WidenVectorResult(
SDNode *N,
unsigned ResNo) {
2260 dbgs() <<
"WidenVectorResult #" << ResNo <<
": ";
2267 case ISD::BITCAST: Res = WidenVecRes_BITCAST(N);
break;
2273 case ISD::LOAD: Res = WidenVecRes_LOAD(N);
break;
2277 case ISD::SELECT: Res = WidenVecRes_SELECT(N);
break;
2279 case ISD::SETCC: Res = WidenVecRes_SETCC(N);
break;
2280 case ISD::UNDEF: Res = WidenVecRes_UNDEF(N);
break;
2282 Res = WidenVecRes_VECTOR_SHUFFLE(cast<ShuffleVectorSDNode>(N));
2285 Res = WidenVecRes_MLOAD(cast<MaskedLoadSDNode>(N));
2288 Res = WidenVecRes_MGATHER(cast<MaskedGatherSDNode>(N));
2307 Res = WidenVecRes_Binary(N);
2320 Res = WidenVecRes_BinaryCanTrap(N);
2324 Res = WidenVecRes_FCOPYSIGN(N);
2328 Res = WidenVecRes_POWI(N);
2334 Res = WidenVecRes_Shift(N);
2340 Res = WidenVecRes_EXTEND_VECTOR_INREG(N);
2353 Res = WidenVecRes_Convert(N);
2377 Res = WidenVecRes_Unary(N);
2380 Res = WidenVecRes_Ternary(N);
2386 SetWidenedVector(
SDValue(N, ResNo), Res);
2408 SDValue DAGTypeLegalizer::WidenVecRes_BinaryCanTrap(
SDNode *N) {
2418 NumElts = NumElts / 2;
2440 unsigned ConcatEnd = 0;
2448 while (CurNumElts != 0) {
2449 while (CurNumElts >= NumElts) {
2456 ConcatOps[ConcatEnd++] = DAG.
getNode(Opcode, dl, VT, EOp1, EOp2, Flags);
2458 CurNumElts -= NumElts;
2461 NumElts = NumElts / 2;
2466 for (
unsigned i = 0; i != CurNumElts; ++i, ++Idx) {
2473 ConcatOps[ConcatEnd++] = DAG.
getNode(Opcode, dl, WidenEltVT,
2481 if (ConcatEnd == 1) {
2482 VT = ConcatOps[0].getValueType();
2484 return ConcatOps[0];
2491 while (ConcatOps[ConcatEnd-1].getValueType() != MaxVT) {
2492 Idx = ConcatEnd - 1;
2493 VT = ConcatOps[Idx--].getValueType();
2494 while (Idx >= 0 && ConcatOps[Idx].getValueType() == VT)
2507 unsigned NumToInsert = ConcatEnd - Idx - 1;
2508 for (
unsigned i = 0, OpIdx = Idx+1; i < NumToInsert; i++, OpIdx++) {
2513 ConcatOps[Idx+1] = VecOp;
2514 ConcatEnd = Idx + 2;
2520 unsigned RealVals = ConcatEnd - Idx - 1;
2521 unsigned SubConcatEnd = 0;
2522 unsigned SubConcatIdx = Idx + 1;
2523 while (SubConcatEnd < RealVals)
2524 SubConcatOps[SubConcatEnd++] = ConcatOps[++Idx];
2525 while (SubConcatEnd < OpsToConcat)
2526 SubConcatOps[SubConcatEnd++] = undefVec;
2528 NextVT, SubConcatOps);
2529 ConcatEnd = SubConcatIdx + 1;
2534 if (ConcatEnd == 1) {
2535 VT = ConcatOps[0].getValueType();
2537 return ConcatOps[0];
2542 if (NumOps != ConcatEnd ) {
2544 for (
unsigned j = ConcatEnd; j < NumOps; ++j)
2545 ConcatOps[j] = UndefVal;
2568 InVTNumElts = InVT.getVectorNumElements();
2569 if (InVTNumElts == WidenNumElts) {
2571 return DAG.
getNode(Opcode, DL, WidenVT, InOp);
2591 if (WidenNumElts % InVTNumElts == 0) {
2593 unsigned NumConcat = WidenNumElts/InVTNumElts;
2597 for (
unsigned i = 1; i != NumConcat; ++i)
2601 return DAG.
getNode(Opcode, DL, WidenVT, InVec);
2605 if (InVTNumElts % WidenNumElts == 0) {
2611 return DAG.
getNode(Opcode, DL, WidenVT, InVal);
2619 unsigned MinElts = std::min(InVTNumElts, WidenNumElts);
2621 for (i=0; i < MinElts; ++i) {
2626 Ops[i] = DAG.
getNode(Opcode, DL, EltVT, Val);
2632 for (; i < WidenNumElts; ++i)
2638 SDValue DAGTypeLegalizer::WidenVecRes_EXTEND_VECTOR_INREG(
SDNode *N) {
2652 InOp = GetWidenedVector(InOp);
2668 for (
unsigned i = 0, e = std::min(InVTNumElts, WidenNumElts); i != e; ++i) {
2687 while (Ops.
size() != WidenNumElts)
2693 SDValue DAGTypeLegalizer::WidenVecRes_FCOPYSIGN(
SDNode *N) {
2697 return WidenVecRes_BinaryCanTrap(N);
2716 EVT ShVT = ShOp.getValueType();
2718 ShOp = GetWidenedVector(ShOp);
2719 ShVT = ShOp.getValueType();
2724 if (ShVT != ShWidenVT)
2725 ShOp = ModifyToType(ShOp, ShWidenVT);
2741 .getVectorElementType(),
2748 SDValue DAGTypeLegalizer::WidenVecRes_MERGE_VALUES(
SDNode *N,
unsigned ResNo) {
2749 SDValue WidenVec = DisintegrateMERGE_VALUES(N, ResNo);
2750 return GetWidenedVector(WidenVec);
2760 switch (getTypeAction(InVT)) {
2772 InOp = GetPromotedInteger(InOp);
2774 if (WidenVT.
bitsEq(InVT))
2787 InOp = GetWidenedVector(InOp);
2789 if (WidenVT.
bitsEq(InVT))
2798 if (WidenSize % InSize == 0 && InVT !=
MVT::x86mmx) {
2803 unsigned NewNumElts = WidenSize / InSize;
2821 for (
unsigned i = 1; i < NewNumElts; ++i)
2833 return CreateStackStoreLoad(InOp, WidenVT);
2836 SDValue DAGTypeLegalizer::WidenVecRes_BUILD_VECTOR(
SDNode *N) {
2850 assert(WidenNumElts >= NumElts &&
"Shrinking vector instead of widening!");
2851 NewOps.append(WidenNumElts - NumElts, DAG.
getUNDEF(EltVT));
2856 SDValue DAGTypeLegalizer::WidenVecRes_CONCAT_VECTORS(
SDNode *N) {
2864 bool InputWidened =
false;
2872 for (
unsigned i=0; i < NumOperands; ++i)
2874 for (
unsigned i = NumOperands; i != NumConcat; ++i)
2879 InputWidened =
true;
2883 for (i=1; i < NumOperands; ++i)
2887 if (i == NumOperands)
2892 if (NumOperands == 2) {
2895 for (
unsigned i = 0; i < NumInElts; ++i) {
2897 MaskOps[i + NumInElts] = i + WidenNumElts;
2911 for (
unsigned i=0; i < NumOperands; ++i) {
2914 InOp = GetWidenedVector(InOp);
2915 for (
unsigned j=0; j < NumInElts; ++j)
2921 for (; Idx < WidenNumElts; ++Idx)
2922 Ops[Idx] = UndefVal;
2926 SDValue DAGTypeLegalizer::WidenVecRes_EXTRACT_SUBVECTOR(
SDNode *N) {
2935 InOp = GetWidenedVector(InOp);
2940 uint64_t IdxVal = cast<ConstantSDNode>(Idx)->getZExtValue();
2941 if (IdxVal == 0 && InVT == WidenVT)
2946 if (IdxVal % WidenNumElts == 0 && IdxVal + WidenNumElts < InNumElts)
2955 for (i=0; i < NumElts; ++i)
2962 for (; i < WidenNumElts; ++i)
2967 SDValue DAGTypeLegalizer::WidenVecRes_INSERT_VECTOR_ELT(
SDNode *N) {
2981 Result = GenWidenVectorExtLoads(LdChain, LD, ExtType);
2983 Result = GenWidenVectorLoads(LdChain, LD);
2989 if (LdChain.
size() == 1)
2990 NewChain = LdChain[0];
2996 ReplaceValueWith(
SDValue(N, 1), NewChain);
3014 Mask = ModifyToType(Mask, WideMaskVT,
true);
3040 Mask = ModifyToType(Mask, WideMaskVT,
true);
3047 Index = ModifyToType(Index, WideIndexVT);
3059 SDValue DAGTypeLegalizer::WidenVecRes_SCALAR_TO_VECTOR(
SDNode *N) {
3123 if (MaskScalarBits < ToMaskScalBits) {
3127 }
else if (MaskScalarBits > ToMaskScalBits) {
3135 "Mask should have the right element size by now.");
3153 "A mask of ToMaskVT should have been produced by now.");
3159 EVT DAGTypeLegalizer::getSETCCWidenedResultTy(
SDValue SetCC) {
3194 EVT FinalVT = VSelVT;
3206 EVT SetCCResVT = getSetCCResultType(SetCCOpVT);
3224 VSelOp1 = GetWidenedVector(VSelOp1);
3225 VSelOp2 = GetWidenedVector(VSelOp2);
3229 EVT ToMaskVT = VSelVT;
3235 EVT MaskVT = getSETCCWidenedResultTy(Cond);
3236 Mask = convertMask(Cond, MaskVT, ToMaskVT);
3243 EVT VT0 = getSETCCWidenedResultTy(SETCC0);
3244 EVT VT1 = getSETCCWidenedResultTy(SETCC1);
3252 if (ScalarBits0 != ScalarBits1) {
3253 EVT NarrowVT = ((ScalarBits0 < ScalarBits1) ? VT0 : VT1);
3254 EVT WideVT = ((NarrowVT == VT0) ? VT1 : VT0);
3266 SETCC0 = convertMask(SETCC0, VT0, MaskVT);
3267 SETCC1 = convertMask(SETCC1, VT1, MaskVT);
3271 Mask = convertMask(Cond, MaskVT, ToMaskVT);
3285 if (
SDValue Res = WidenVSELECTAndMask(N))
3290 CondEltVT, WidenNumElts);
3292 Cond1 = GetWidenedVector(Cond1);
3300 SDValue SplitSelect = SplitVecOp_VSELECT(N, 0);
3301 SDValue Res = ModifyToType(SplitSelect, WidenVT);
3306 Cond1 = ModifyToType(Cond1, CondWidenVT);
3313 WidenVT, Cond1, InOp1, InOp2);
3316 SDValue DAGTypeLegalizer::WidenVecRes_SELECT_CC(
SDNode *N) {
3342 for (
unsigned i = 0; i != NumElts; ++i) {
3344 if (Idx < (
int)NumElts)
3345 NewMask.push_back(Idx);
3347 NewMask.push_back(Idx - NumElts + WidenNumElts);
3349 for (
unsigned i = NumElts; i != WidenNumElts; ++i)
3350 NewMask.push_back(-1);
3357 "Operands must be vectors");
3371 SDValue SplitVSetCC = SplitVecOp_VSETCC(N);
3372 SDValue Res = ModifyToType(SplitVSetCC, WidenVT);
3376 InOp1 = GetWidenedVector(InOp1);
3383 "Input not widened to expected type!");
3393 bool DAGTypeLegalizer::WidenVectorOperand(
SDNode *N,
unsigned OpNo) {
3405 dbgs() <<
"WidenVectorOperand op #" << OpNo <<
": ";
3415 case ISD::STORE: Res = WidenVecOp_STORE(N);
break;
3416 case ISD::MSTORE: Res = WidenVecOp_MSTORE(N, OpNo);
break;
3417 case ISD::MSCATTER: Res = WidenVecOp_MSCATTER(N, OpNo);
break;
3418 case ISD::SETCC: Res = WidenVecOp_SETCC(N);
break;
3424 Res = WidenVecOp_EXTEND(N);
3433 Res = WidenVecOp_Convert(N);
3438 if (!Res.getNode())
return false;
3442 if (Res.getNode() ==
N)
3447 "Invalid operand expansion");
3449 ReplaceValueWith(
SDValue(N, 0), Res);
3460 "Unexpected type action");
3461 InOp = GetWidenedVector(InOp);
3464 "Input wasn't widened!");
3476 FixedEltVT == InEltVT) {
3478 "Not enough elements in the fixed type for the operand!");
3480 "We can't have the same type as we started with!");
3497 return WidenVecOp_Convert(N);
3530 "Unexpected type action");
3531 InOp = GetWidenedVector(InOp);
3548 for (
unsigned i=0; i < NumElts; ++i)
3565 unsigned InWidenSize = InWidenVT.getSizeInBits();
3569 unsigned NewNumElts = InWidenSize /
Size;
3579 return CreateStackStoreLoad(InOp, VT);
3582 SDValue DAGTypeLegalizer::WidenVecOp_CONCAT_VECTORS(
SDNode *N) {
3597 for (
unsigned i=0; i < NumOperands; ++i) {
3601 "Unexpected type action");
3602 InOp = GetWidenedVector(InOp);
3603 for (
unsigned j=0; j < NumInElts; ++j)
3611 SDValue DAGTypeLegalizer::WidenVecOp_EXTRACT_SUBVECTOR(
SDNode *N) {
3617 SDValue DAGTypeLegalizer::WidenVecOp_EXTRACT_VECTOR_ELT(
SDNode *N) {
3633 GenWidenVectorTruncStores(StChain, ST);
3635 GenWidenVectorStores(StChain, ST);
3637 if (StChain.
size() == 1)
3643 SDValue DAGTypeLegalizer::WidenVecOp_MSTORE(
SDNode *N,
unsigned OpNo) {
3644 assert((OpNo == 2 || OpNo == 3) &&
3645 "Can widen only data or mask operand of mstore");
3648 EVT MaskVT = Mask.getValueType();
3654 StVal = GetWidenedVector(StVal);
3661 Mask = ModifyToType(Mask, WideMaskVT,
true);
3664 Mask = ModifyToType(Mask, WideMaskVT,
true);
3668 StVal = GetWidenedVector(StVal);
3673 StVal = ModifyToType(StVal, WideVT);
3677 assert(Mask.getValueType().getVectorNumElements() ==
3679 "Mask and data vectors should have the same number of elements");
3685 SDValue DAGTypeLegalizer::WidenVecOp_MSCATTER(
SDNode *N,
unsigned OpNo) {
3686 assert(OpNo == 1 &&
"Can widen only data operand of mscatter");
3694 SDValue WideVal = GetWidenedVector(DataOp);
3702 Mask = ModifyToType(Mask, WideMaskVT,
true);
3709 Index = ModifyToType(Index, WideIndexVT);
3748 return PromoteTargetBoolean(CC, VT);
3764 unsigned Width,
EVT WidenVT,
3765 unsigned Align = 0,
unsigned WidenEx = 0) {
3769 unsigned AlignInBits =
Align*8;
3772 EVT RetVT = WidenEltVT;
3773 if (Width == WidenEltWidth)
3787 (WidenWidth % MemVTWidth) == 0 &&
3789 (MemVTWidth <= Width ||
3790 (
Align!=0 && MemVTWidth<=AlignInBits && MemVTWidth<=Width+WidenEx))) {
3803 (WidenWidth % MemVTWidth) == 0 &&
3805 (MemVTWidth <= Width ||
3806 (
Align!=0 && MemVTWidth<=AlignInBits && MemVTWidth<=Width+WidenEx))) {
3821 unsigned Start,
unsigned End) {
3823 SDLoc dl(LdOps[Start]);
3824 EVT LdTy = LdOps[Start].getValueType();
3832 for (
unsigned i = Start + 1; i != End; ++i) {
3833 EVT NewLdTy = LdOps[i].getValueType();
3834 if (NewLdTy != LdTy) {
3870 int WidthDiff = WidenWidth - LdWidth;
3874 EVT NewVT =
FindMemType(DAG, TLI, LdWidth, WidenVT, LdAlign, WidthDiff);
3877 Align, MMOFlags, AAInfo);
3881 if (LdWidth <= NewVTWidth) {
3883 unsigned NumElts = WidenWidth / NewVTWidth;
3888 if (NewVT == WidenVT)
3891 assert(WidenWidth % NewVTWidth == 0);
3892 unsigned NumConcat = WidenWidth / NewVTWidth;
3895 ConcatOps[0] = LdOp;
3896 for (
unsigned i = 1; i != NumConcat; ++i)
3897 ConcatOps[i] = UndefVal;
3905 LdWidth -= NewVTWidth;
3908 while (LdWidth > 0) {
3909 unsigned Increment = NewVTWidth / 8;
3910 Offset += Increment;
3914 if (LdWidth < NewVTWidth) {
3916 NewVT =
FindMemType(DAG, TLI, LdWidth, WidenVT, LdAlign, WidthDiff);
3918 L = DAG.
getLoad(NewVT, dl, Chain, BasePtr,
3920 MinAlign(Align, Increment), MMOFlags, AAInfo);
3929 while (size < LdOp->getValueSizeInBits(0)) {
3936 L = DAG.
getLoad(NewVT, dl, Chain, BasePtr,
3938 MinAlign(Align, Increment), MMOFlags, AAInfo);
3945 LdWidth -= NewVTWidth;
3949 unsigned End = LdOps.
size();
3950 if (!LdOps[0].getValueType().
isVector())
3960 EVT LdTy = LdOps[i].getValueType();
3963 for (--i; i >= 0; --i) {
3964 LdTy = LdOps[i].getValueType();
3970 ConcatOps[--Idx] = LdOps[i];
3971 for (--i; i >= 0; --i) {
3972 EVT NewLdTy = LdOps[i].getValueType();
3973 if (NewLdTy != LdTy) {
3980 ConcatOps[--Idx] = LdOps[i];
3993 for (; i != End-Idx; ++i)
3994 WidenOps[i] = ConcatOps[Idx+i];
3995 for (; i != NumOps; ++i)
3996 WidenOps[i] = UndefVal;
4029 LdEltVT,
Align, MMOFlags, AAInfo);
4031 unsigned i = 0,
Offset = Increment;
4032 for (i=1; i < NumElts; ++i,
Offset += Increment) {
4034 Ops[i] = DAG.
getExtLoad(ExtType, dl, EltVT, Chain, NewBasePtr,
4036 Align, MMOFlags, AAInfo);
4042 for (; i != WidenNumElts; ++i)
4071 while (StWidth != 0) {
4075 unsigned Increment = NewVTWidth / 8;
4084 MinAlign(Align, Offset), MMOFlags, AAInfo));
4085 StWidth -= NewVTWidth;
4086 Offset += Increment;
4090 }
while (StWidth != 0 && StWidth >= NewVTWidth);
4093 unsigned NumElts = ValWidth / NewVTWidth;
4097 Idx = Idx * ValEltWidth / NewVTWidth;
4105 MinAlign(Align, Offset), MMOFlags, AAInfo));
4106 StWidth -= NewVTWidth;
4107 Offset += Increment;
4109 }
while (StWidth != 0 && StWidth >= NewVTWidth);
4111 Idx = Idx * NewVTWidth / ValEltWidth;
4149 unsigned Offset = Increment;
4150 for (
unsigned i=1; i < NumElts; ++i, Offset += Increment) {
4157 StEltVT,
MinAlign(Align, Offset), MMOFlags, AAInfo));
4165 bool FillWithZeroes) {
4170 "input and widen element type must match");
4179 if (WidenNumElts > InNumElts && WidenNumElts % InNumElts == 0) {
4180 unsigned NumConcat = WidenNumElts / InNumElts;
4185 for (
unsigned i = 1; i != NumConcat; ++i)
4191 if (WidenNumElts < InNumElts && InNumElts % WidenNumElts)
4199 unsigned MinNumElts = std::min(WidenNumElts, InNumElts);
4201 for (Idx = 0; Idx < MinNumElts; ++Idx)
4208 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 ...
void push_back(const T &Elt)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
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 getValueType() const
Return the ValueType of the referenced return value.
Constrained versions of libm-equivalent floating point intrinsics.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
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 ...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Compute iterated dominance frontiers using a linear time algorithm.
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
SDValue scalarizeVectorStore(StoreSDNode *ST, SelectionDAG &DAG) const
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
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...
const SDValue & getBasePtr() const
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
const SDValue & getValue() const
bool isCompressingStore() const
Returns true if the op does a compression to the vector before storing.
const SDValue & getBasePtr() const
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
static ISD::NodeType getExtendForContent(BooleanContent Content)
const SDValue & getChain() const
unsigned getAlignment() const
unsigned getValueSizeInBits(unsigned ResNo) const
Returns MVT::getSizeInBits(getValueType(ResNo)).
Constrained versions of the binary floating point operators.
bool isInteger() const
Return true if this is an integer or a vector integer type.
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 ...
[US]{MIN/MAX} - Binary minimum or maximum or signed or unsigned integers.
const SDNodeFlags getFlags() const
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...
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1 at the ...
unsigned getValueSizeInBits() const
Returns the size of the value in bits.
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.
const SDValue & getValue() const
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
bool isTruncatingStore() const
Return true if the op does a truncation before store.
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 isFloatingPoint() const
Return true if this is a FP or a vector FP type.
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
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.
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
This is used by foldAnyOrAllBitsSet() to capture a source value (Root) and the bit indexes (Mask) nee...
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...
op_iterator op_end() const
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
const SDValue & getValue() const
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
const DataLayout & getDataLayout() const
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
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.
unsigned getScalarSizeInBits() const
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
MachineFunction & getMachineFunction() const
[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)
const SDValue & getScale() const
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
Simple integer binary arithmetic operators.
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)
op_iterator op_begin() const
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...
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...
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...
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
const SDValue & getBasePtr() const
SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
static MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
These reductions are non-strict, and have a single vector operand.
SDValue getVectorElementPointer(SelectionDAG &DAG, SDValue VecPtr, EVT VecVT, SDValue Index) const
Get a pointer to vector element Idx located in memory for a vector of type VecVT starting at a base a...
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...
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
bool isExpandingLoad() const
static EVT FindMemType(SelectionDAG &DAG, const TargetLowering &TLI, unsigned Width, EVT WidenVT, unsigned Align=0, unsigned WidenEx=0)
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.
Simple binary floating point operators.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
iterator_range< value_op_iterator > op_values() const
const SDValue & getOperand(unsigned Num) 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.
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
static EVT getFloatingPointVT(unsigned BitWidth)
Returns the EVT that represents a floating-point type with the given number of bits.
unsigned getOriginalAlignment() const
Returns alignment and volatility of the memory access.
SDValue getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Mask, SDValue Src0, EVT MemVT, MachineMemOperand *MMO, ISD::LoadExtType, bool IsExpanding=false)
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 & getIndex() const
const SDValue & getBasePtr() const
const SDValue & getSrc0() const
This class contains a discriminated union of information about pointers in memory operands...
unsigned getNumOperands() const
Return the number of values used by this operation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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 SDValue & getMask() const
bool isUnindexed() const
Return true if this is NOT a pre/post inc/dec load/store.
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...
TokenFactor - This node takes multiple tokens as input and produces a single token result...
void dump() const
Dump this node, for debugging.
const TargetLowering & getTargetLoweringInfo() const
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
Returns platform specific canonical encoding of a floating point number.
virtual bool canOpTrap(unsigned Op, EVT VT) const
Returns true if the operation can trap for the value type.
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
EVT getVectorElementType() const
Given a vector type, return the type of each element.
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.
bool isVector(MCInstrInfo const &MCII, MCInst const &MCI)
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
EVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Byte Swap and Counting operators.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
EVT widenIntegerVectorElementType(LLVMContext &Context) const
Return a VT for an integer vector type with the size of the elements doubled.
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...
Represents one node in the SelectionDAG.
static bool isSETCCorConvertedSETCC(SDValue N)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
MachinePointerInfo getWithOffset(int64_t O) const
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
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...
EVT getMemoryVT() const
Return the type of the in-memory value.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
Select(COND, TRUEVAL, FALSEVAL).
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
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.
int getMaskElt(unsigned Idx) const
FMINNAN/FMAXNAN - Behave identically to FMINNUM/FMAXNUM, except that when a single input is NaN...
Flags
Flags values. These may be or'd together.
amdgpu Simplify well known AMD library false Value Value * Arg
The memory access reads data.
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.
bool isVector() const
Return true if this is a vector value type.
Bitwise operators - logical and, logical or, logical xor.
pointer data()
Return a pointer to the vector's buffer, even if empty().
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...
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const
Return the ValueType of the result of SETCC operations.
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 ...
Flags getFlags() const
Return the raw flags of the source value,.
unsigned getOpcode() const
SDValue getValue(unsigned R) const
This class is used to represent an MSCATTER node.
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
const MachinePointerInfo & getPointerInfo() const
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
This class is used to represent an MLOAD node.
FMA - Perform a * b + c with no intermediate rounding step.
FMIN/FMAX nodes can have flags, for NaN/NoNaN variants.
const MDNode * getRanges() const
Returns the Ranges that describes the dereference.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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.
bool isUndef() const
Return true if the type of the node type undefined.
ISD::LoadExtType getExtensionType() const
SetCC operator - This evaluates to a true value iff the condition is true.
bool bitsEq(EVT VT) const
Return true if this has the same number of bits as VT.
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.
const SDValue & getOperand(unsigned i) const
TRUNCATE - Completely drop the high bits.
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Op, int64_t Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object...
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.
EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
LLVMContext * getContext() const
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
const SDValue & getMask() const
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
This class is used to represent ISD::LOAD nodes.