28 #define DEBUG_TYPE "legalize-types" 38 void DAGTypeLegalizer::PromoteIntegerResult(
SDNode *
N,
unsigned ResNo) {
52 dbgs() <<
"PromoteIntegerResult #" << ResNo <<
": ";
59 case ISD::BITCAST: Res = PromoteIntRes_BITCAST(N);
break;
61 case ISD::BSWAP: Res = PromoteIntRes_BSWAP(N);
break;
65 case ISD::CTLZ: Res = PromoteIntRes_CTLZ(N);
break;
66 case ISD::CTPOP: Res = PromoteIntRes_CTPOP(N);
break;
68 case ISD::CTTZ: Res = PromoteIntRes_CTTZ(N);
break;
70 Res = PromoteIntRes_EXTRACT_VECTOR_ELT(N);
break;
71 case ISD::LOAD: Res = PromoteIntRes_LOAD(cast<LoadSDNode>(N));
break;
72 case ISD::MLOAD: Res = PromoteIntRes_MLOAD(cast<MaskedLoadSDNode>(N));
74 case ISD::MGATHER: Res = PromoteIntRes_MGATHER(cast<MaskedGatherSDNode>(N));
76 case ISD::SELECT: Res = PromoteIntRes_SELECT(N);
break;
77 case ISD::VSELECT: Res = PromoteIntRes_VSELECT(N);
break;
79 case ISD::SETCC: Res = PromoteIntRes_SETCC(N);
break;
81 case ISD::SMAX: Res = PromoteIntRes_SExtIntBinOp(N);
break;
83 case ISD::UMAX: Res = PromoteIntRes_ZExtIntBinOp(N);
break;
85 case ISD::SHL: Res = PromoteIntRes_SHL(N);
break;
87 Res = PromoteIntRes_SIGN_EXTEND_INREG(N);
break;
88 case ISD::SRA: Res = PromoteIntRes_SRA(N);
break;
89 case ISD::SRL: Res = PromoteIntRes_SRL(N);
break;
91 case ISD::UNDEF: Res = PromoteIntRes_UNDEF(N);
break;
92 case ISD::VAARG: Res = PromoteIntRes_VAARG(N);
break;
95 Res = PromoteIntRes_EXTRACT_SUBVECTOR(N);
break;
97 Res = PromoteIntRes_VECTOR_SHUFFLE(N);
break;
99 Res = PromoteIntRes_INSERT_VECTOR_ELT(N);
break;
101 Res = PromoteIntRes_BUILD_VECTOR(N);
break;
103 Res = PromoteIntRes_SCALAR_TO_VECTOR(N);
break;
105 Res = PromoteIntRes_CONCAT_VECTORS(N);
break;
110 Res = PromoteIntRes_EXTEND_VECTOR_INREG(N);
break;
126 case ISD::MUL: Res = PromoteIntRes_SimpleIntBinOp(N);
break;
129 case ISD::SREM: Res = PromoteIntRes_SExtIntBinOp(N);
break;
132 case ISD::UREM: Res = PromoteIntRes_ZExtIntBinOp(N);
break;
135 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(N, ResNo);
break;
137 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(N, ResNo);
break;
139 case ISD::UMULO: Res = PromoteIntRes_XMULO(N, ResNo);
break;
142 case ISD::SUBCARRY: Res = PromoteIntRes_ADDSUBCARRY(N, ResNo);
break;
145 Res = PromoteIntRes_Atomic0(cast<AtomicSDNode>(N));
break;
159 Res = PromoteIntRes_Atomic1(cast<AtomicSDNode>(N));
break;
163 Res = PromoteIntRes_AtomicCmpSwap(cast<AtomicSDNode>(N), ResNo);
169 SetPromotedInteger(
SDValue(N, ResNo), Res);
174 SDValue Op = DisintegrateMERGE_VALUES(N, ResNo);
175 return GetPromotedInteger(Op);
178 SDValue DAGTypeLegalizer::PromoteIntRes_AssertSext(
SDNode *N) {
185 SDValue DAGTypeLegalizer::PromoteIntRes_AssertZext(
SDNode *N) {
246 for (
unsigned i = 1, NumResults = N->
getNumValues(); i < NumResults; ++i)
259 switch (getTypeAction(InVT)) {
283 BitConvertToInteger(GetScalarizedVector(InOp)));
290 Lo = BitConvertToInteger(Lo);
291 Hi = BitConvertToInteger(Hi);
299 JoinIntegers(Lo, Hi));
311 CreateStackStoreLoad(InOp, OutVT));
327 SDValue DAGTypeLegalizer::PromoteIntRes_BITREVERSE(
SDNode *N) {
340 SDValue DAGTypeLegalizer::PromoteIntRes_BUILD_PAIR(
SDNode *N) {
349 SDValue DAGTypeLegalizer::PromoteIntRes_Constant(
SDNode *N) {
359 assert(isa<ConstantSDNode>(Result) &&
"Didn't constant fold ext?");
393 OVT.getScalarSizeInBits());
399 SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *N) {
406 SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT(
SDNode *N) {
434 SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16(
SDNode *N) {
441 SDValue DAGTypeLegalizer::PromoteIntRes_INT_EXTEND(
SDNode *N) {
502 "Gather result type and the passThru agrument type should be the same");
517 SDValue DAGTypeLegalizer::PromoteIntRes_Overflow(
SDNode *N) {
523 assert(NumOps <= 3 &&
"Too many operands");
532 ReplaceValueWith(
SDValue(N, 0), Res);
537 SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *N,
unsigned ResNo) {
539 return PromoteIntRes_Overflow(N);
561 ReplaceValueWith(
SDValue(N, 1), Ofl);
582 SDValue DAGTypeLegalizer::PromoteIntRes_SELECT_CC(
SDNode *N) {
594 EVT SVT = getSetCCResultType(InVT);
602 SVT = getSetCCResultType(InVT);
611 "Vector compare must return a vector result!");
625 RHS = ZExtPromotedInteger(RHS);
629 SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *N) {
635 SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *N) {
645 SDValue DAGTypeLegalizer::PromoteIntRes_SExtIntBinOp(
SDNode *N) {
653 SDValue DAGTypeLegalizer::PromoteIntRes_ZExtIntBinOp(
SDNode *N) {
666 RHS = ZExtPromotedInteger(RHS);
675 RHS = ZExtPromotedInteger(RHS);
679 SDValue DAGTypeLegalizer::PromoteIntRes_TRUNCATE(
SDNode *N) {
692 Res = GetPromotedInteger(InOp);
699 "Dst and Src must have the same number of elements");
701 "Promoted vector type must be a power of two");
704 GetSplitVector(InOp, EOp1, EOp2);
714 SDValue WideInOp = GetWidenedVector(InOp);
738 SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *N,
unsigned ResNo) {
740 return PromoteIntRes_Overflow(N);
761 ReplaceValueWith(
SDValue(N, 1), Ofl);
766 SDValue DAGTypeLegalizer::PromoteIntRes_ADDSUBCARRY(
SDNode *N,
unsigned ResNo) {
768 return PromoteIntRes_Overflow(N);
795 SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *N,
unsigned ResNo) {
798 return PromoteIntRes_Overflow(N);
809 LHS = SExtPromotedInteger(LHS);
810 RHS = SExtPromotedInteger(RHS);
812 LHS = ZExtPromotedInteger(LHS);
813 RHS = ZExtPromotedInteger(RHS);
843 ReplaceValueWith(
SDValue(N, 1), Overflow);
863 for (
unsigned i = 0; i < NumRegs; ++i) {
866 Chain = Parts[i].getValue(1);
876 for (
unsigned i = 1; i < NumRegs; ++i) {
887 ReplaceValueWith(
SDValue(N, 1), Chain);
900 bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *N,
unsigned OpNo) {
913 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
920 Res = PromoteIntOp_ATOMIC_STORE(cast<AtomicSDNode>(N));
922 case ISD::BITCAST: Res = PromoteIntOp_BITCAST(N);
break;
923 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(N, OpNo);
break;
924 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(N, OpNo);
break;
930 Res = PromoteIntOp_INSERT_VECTOR_ELT(N, OpNo);
break;
932 Res = PromoteIntOp_SCALAR_TO_VECTOR(N);
break;
934 case ISD::SELECT: Res = PromoteIntOp_SELECT(N, OpNo);
break;
935 case ISD::SELECT_CC: Res = PromoteIntOp_SELECT_CC(N, OpNo);
break;
936 case ISD::SETCC: Res = PromoteIntOp_SETCC(N, OpNo);
break;
939 case ISD::STORE: Res = PromoteIntOp_STORE(cast<StoreSDNode>(N),
941 case ISD::MSTORE: Res = PromoteIntOp_MSTORE(cast<MaskedStoreSDNode>(N),
943 case ISD::MLOAD: Res = PromoteIntOp_MLOAD(cast<MaskedLoadSDNode>(N),
945 case ISD::MGATHER: Res = PromoteIntOp_MGATHER(cast<MaskedGatherSDNode>(N),
947 case ISD::MSCATTER: Res = PromoteIntOp_MSCATTER(cast<MaskedScatterSDNode>(N),
959 case ISD::ROTR: Res = PromoteIntOp_Shift(N);
break;
962 case ISD::SUBCARRY: Res = PromoteIntOp_ADDSUBCARRY(N, OpNo);
break;
966 if (!Res.getNode())
return false;
970 if (Res.getNode() ==
N)
974 "Invalid operand expansion");
976 ReplaceValueWith(
SDValue(N, 0), Res);
982 void DAGTypeLegalizer::PromoteSetCCOperands(
SDValue &NewLHS,
SDValue &NewRHS,
991 SDValue OpL = GetPromotedInteger(NewLHS);
992 SDValue OpR = GetPromotedInteger(NewRHS);
998 unsigned OpLEffectiveBits =
1000 unsigned OpREffectiveBits =
1007 NewLHS = ZExtPromotedInteger(NewLHS);
1008 NewRHS = ZExtPromotedInteger(NewRHS);
1019 NewLHS = ZExtPromotedInteger(NewLHS);
1020 NewRHS = ZExtPromotedInteger(NewRHS);
1026 NewLHS = SExtPromotedInteger(NewLHS);
1027 NewRHS = SExtPromotedInteger(NewRHS);
1032 SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND(
SDNode *N) {
1049 SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *N,
unsigned OpNo) {
1050 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
1054 PromoteSetCCOperands(LHS, RHS, cast<CondCodeSDNode>(N->
getOperand(1))->
get());
1063 SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *N,
unsigned OpNo) {
1064 assert(OpNo == 1 &&
"only know how to promote condition");
1074 SDValue DAGTypeLegalizer::PromoteIntOp_BUILD_PAIR(
SDNode *N) {
1088 SDValue DAGTypeLegalizer::PromoteIntOp_BUILD_VECTOR(
SDNode *N) {
1095 "Legal vector of one illegal element?");
1102 "Type of inserted value narrower than vector element type!");
1105 for (
unsigned i = 0; i < NumElts; ++i)
1111 SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *N,
1120 "Type of inserted value narrower than vector element type!");
1127 assert(OpNo == 2 &&
"Different operand and result vector types?");
1136 SDValue DAGTypeLegalizer::PromoteIntOp_SCALAR_TO_VECTOR(
SDNode *N) {
1143 SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *N,
unsigned OpNo) {
1144 assert(OpNo == 0 &&
"Only know how to promote the condition!");
1149 if (
SDValue Res = WidenVSELECTAndMask(N))
1154 Cond = PromoteTargetBoolean(Cond, OpVT);
1160 SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *N,
unsigned OpNo) {
1161 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
1165 PromoteSetCCOperands(LHS, RHS, cast<CondCodeSDNode>(N->
getOperand(4))->
get());
1172 SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *N,
unsigned OpNo) {
1173 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
1177 PromoteSetCCOperands(LHS, RHS, cast<CondCodeSDNode>(N->
getOperand(2))->
get());
1188 SDValue DAGTypeLegalizer::PromoteIntOp_SIGN_EXTEND(
SDNode *N) {
1196 SDValue DAGTypeLegalizer::PromoteIntOp_SINT_TO_FP(
SDNode *N) {
1221 bool TruncateStore =
false;
1229 Mask = PromoteTargetBoolean(Mask, DataVT);
1237 return PromoteIntOp_MSTORE(N, 3);
1239 return WidenVecOp_MSTORE(N, 3);
1241 return SplitVecOp_MSTORE(N, 3);
1243 assert(OpNo == 3 &&
"Unexpected operand for promotion");
1244 DataOp = GetPromotedInteger(DataOp);
1245 TruncateStore =
true;
1255 assert(OpNo == 2 &&
"Only know how to promote the mask!");
1259 NewOps[OpNo] =
Mask;
1270 NewOps[OpNo] = PromoteTargetBoolean(N->
getOperand(OpNo), DataVT);
1271 }
else if (OpNo == 4) {
1273 NewOps[OpNo] = SExtPromotedInteger(N->
getOperand(OpNo));
1275 NewOps[OpNo] = GetPromotedInteger(N->
getOperand(OpNo));
1279 if (Res.getNode() ==
N)
1293 NewOps[OpNo] = PromoteTargetBoolean(N->
getOperand(OpNo), DataVT);
1294 }
else if (OpNo == 4) {
1296 NewOps[OpNo] = SExtPromotedInteger(N->
getOperand(OpNo));
1298 NewOps[OpNo] = GetPromotedInteger(N->
getOperand(OpNo));
1302 SDValue DAGTypeLegalizer::PromoteIntOp_TRUNCATE(
SDNode *N) {
1307 SDValue DAGTypeLegalizer::PromoteIntOp_UINT_TO_FP(
SDNode *N) {
1312 SDValue DAGTypeLegalizer::PromoteIntOp_ZERO_EXTEND(
SDNode *N) {
1320 SDValue DAGTypeLegalizer::PromoteIntOp_ADDSUBCARRY(
SDNode *N,
unsigned OpNo) {
1321 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
1353 void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *N,
unsigned ResNo) {
1366 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
1369 llvm_unreachable(
"Do not know how to expand the result of this operator!");
1372 case ISD::SELECT: SplitRes_SELECT(N, Lo, Hi);
break;
1374 case ISD::UNDEF: SplitRes_UNDEF(N, Lo, Hi);
break;
1376 case ISD::BITCAST: ExpandRes_BITCAST(N, Lo, Hi);
break;
1380 case ISD::VAARG: ExpandRes_VAARG(N, Lo, Hi);
break;
1386 case ISD::BSWAP: ExpandIntRes_BSWAP(N, Lo, Hi);
break;
1387 case ISD::Constant: ExpandIntRes_Constant(N, Lo, Hi);
break;
1389 case ISD::CTLZ: ExpandIntRes_CTLZ(N, Lo, Hi);
break;
1390 case ISD::CTPOP: ExpandIntRes_CTPOP(N, Lo, Hi);
break;
1392 case ISD::CTTZ: ExpandIntRes_CTTZ(N, Lo, Hi);
break;
1396 case ISD::LOAD: ExpandIntRes_LOAD(cast<LoadSDNode>(N), Lo, Hi);
break;
1397 case ISD::MUL: ExpandIntRes_MUL(N, Lo, Hi);
break;
1399 case ISD::SDIV: ExpandIntRes_SDIV(N, Lo, Hi);
break;
1402 case ISD::SREM: ExpandIntRes_SREM(N, Lo, Hi);
break;
1403 case ISD::TRUNCATE: ExpandIntRes_TRUNCATE(N, Lo, Hi);
break;
1404 case ISD::UDIV: ExpandIntRes_UDIV(N, Lo, Hi);
break;
1405 case ISD::UREM: ExpandIntRes_UREM(N, Lo, Hi);
break;
1422 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(N);
1423 SplitInteger(Tmp.first, Lo, Hi);
1424 ReplaceValueWith(
SDValue(N, 1), Tmp.second);
1441 SplitInteger(Tmp, Lo, Hi);
1442 ReplaceValueWith(
SDValue(N, 1), Success);
1449 case ISD::XOR: ExpandIntRes_Logical(N, Lo, Hi);
break;
1454 case ISD::SMIN: ExpandIntRes_MINMAX(N, Lo, Hi);
break;
1457 case ISD::SUB: ExpandIntRes_ADDSUB(N, Lo, Hi);
break;
1460 case ISD::SUBC: ExpandIntRes_ADDSUBC(N, Lo, Hi);
break;
1463 case ISD::SUBE: ExpandIntRes_ADDSUBE(N, Lo, Hi);
break;
1466 case ISD::SUBCARRY: ExpandIntRes_ADDSUBCARRY(N, Lo, Hi);
break;
1470 case ISD::SRL: ExpandIntRes_Shift(N, Lo, Hi);
break;
1473 case ISD::SSUBO: ExpandIntRes_SADDSUBO(N, Lo, Hi);
break;
1475 case ISD::USUBO: ExpandIntRes_UADDSUBO(N, Lo, Hi);
break;
1477 case ISD::SMULO: ExpandIntRes_XMULO(N, Lo, Hi);
break;
1486 std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
1488 MVT VT = cast<AtomicSDNode>(Node)->getMemoryVT().getSimpleVT();
1490 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected atomic op or value type!");
1492 return ExpandChainLibCall(LC, Node,
false);
1497 void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *N,
const APInt &Amt,
1502 GetExpandedInteger(N->
getOperand(0), InL, InH);
1518 if (Amt.
ugt(VTBits)) {
1520 }
else if (Amt.
ugt(NVTBits)) {
1523 NVT, InL, DAG.
getConstant(Amt - NVTBits, DL, ShTy));
1524 }
else if (Amt == NVTBits) {
1539 if (Amt.
ugt(VTBits)) {
1541 }
else if (Amt.
ugt(NVTBits)) {
1543 NVT, InH, DAG.
getConstant(Amt - NVTBits, DL, ShTy));
1545 }
else if (Amt == NVTBits) {
1560 if (Amt.
ugt(VTBits)) {
1563 }
else if (Amt.
ugt(NVTBits)) {
1568 }
else if (Amt == NVTBits) {
1586 bool DAGTypeLegalizer::
1594 "Expanded integer type size not a power of two!");
1602 if (((Known.
Zero|Known.
One) & HighBitMask) == 0)
1607 GetExpandedInteger(N->
getOperand(0), InL, InH);
1674 bool DAGTypeLegalizer::
1681 "Expanded integer type size not a power of two!");
1686 GetExpandedInteger(N->
getOperand(0), InL, InH);
1711 Lo = DAG.
getSelect(dl, NVT, isShort, LoS, LoL);
1712 Hi = DAG.
getSelect(dl, NVT, isZero, InH,
1713 DAG.
getSelect(dl, NVT, isShort, HiS, HiL));
1728 Lo = DAG.
getSelect(dl, NVT, isZero, InL,
1729 DAG.
getSelect(dl, NVT, isShort, LoS, LoL));
1730 Hi = DAG.
getSelect(dl, NVT, isShort, HiS, HiL);
1744 Lo = DAG.
getSelect(dl, NVT, isZero, InL,
1745 DAG.
getSelect(dl, NVT, isShort, LoS, LoL));
1746 Hi = DAG.
getSelect(dl, NVT, isShort, HiS, HiL);
1766 void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *N,
1774 SDValue LHSL, LHSH, RHSL, RHSH;
1775 GetExpandedInteger(N->
getOperand(0), LHSL, LHSH);
1776 GetExpandedInteger(N->
getOperand(1), RHSL, RHSH);
1779 EVT NVT = LHSL.getValueType();
1780 EVT CCT = getSetCCResultType(NVT);
1796 Lo = DAG.
getSelect(DL, NVT, IsHiEq, LoMinMax, LoCmp);
1799 void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *N,
1803 SDValue LHSL, LHSH, RHSL, RHSH;
1804 GetExpandedInteger(N->
getOperand(0), LHSL, LHSH);
1805 GetExpandedInteger(N->
getOperand(1), RHSL, RHSH);
1808 SDValue LoOps[2] = { LHSL, RHSL };
1809 SDValue HiOps[3] = { LHSH, RHSH };
1859 EVT OvfVT = getSetCCResultType(NVT);
1883 Hi = DAG.
getNode(RevOpc, dl, NVT, Hi, OVF);
1891 SDValue Cmp1 = DAG.
getSetCC(dl, getSetCCResultType(NVT), Lo, LoOps[0],
1903 SDValue Cmp2 = DAG.
getSetCC(dl, getSetCCResultType(NVT), Lo, LoOps[1],
1912 DAG.
getSetCC(dl, getSetCCResultType(LoOps[0].getValueType()),
1926 void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *N,
1929 SDValue LHSL, LHSH, RHSL, RHSH;
1931 GetExpandedInteger(N->
getOperand(0), LHSL, LHSH);
1932 GetExpandedInteger(N->
getOperand(1), RHSL, RHSH);
1934 SDValue LoOps[2] = { LHSL, RHSL };
1935 SDValue HiOps[3] = { LHSH, RHSH };
1952 void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *N,
1955 SDValue LHSL, LHSH, RHSL, RHSH;
1957 GetExpandedInteger(N->
getOperand(0), LHSL, LHSH);
1958 GetExpandedInteger(N->
getOperand(1), RHSL, RHSH);
1961 SDValue HiOps[3] = { LHSH, RHSH };
1972 void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *N,
1986 SDValue LHSL, LHSH, RHSL, RHSH;
1987 GetExpandedInteger(LHS, LHSL, LHSH);
1988 GetExpandedInteger(RHS, RHSL, RHSH);
1990 SDValue LoOps[2] = { LHSL, RHSL };
1991 SDValue HiOps[3] = { LHSH, RHSH };
1996 Hi = DAG.
getNode(Opc, dl, VTList, HiOps);
2004 SplitInteger(Sum, Lo, Hi);
2014 ReplaceValueWith(
SDValue(N, 1), Ovf);
2017 void DAGTypeLegalizer::ExpandIntRes_ADDSUBCARRY(
SDNode *N,
2020 SDValue LHSL, LHSH, RHSL, RHSH;
2022 GetExpandedInteger(N->
getOperand(0), LHSL, LHSH);
2023 GetExpandedInteger(N->
getOperand(1), RHSL, RHSH);
2037 void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *N,
2051 "Only know how to promote this result!");
2052 SDValue Res = GetPromotedInteger(Op);
2054 "Operand over promoted?");
2056 SplitInteger(Res, Lo, Hi);
2060 void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *N,
2066 unsigned NVTBits = NVT.getSizeInBits();
2069 if (NVTBits < EVTBits) {
2072 EVTBits - NVTBits)));
2082 void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *N,
2088 unsigned NVTBits = NVT.getSizeInBits();
2091 if (NVTBits < EVTBits) {
2094 EVTBits - NVTBits)));
2102 void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *N,
2110 void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *N,
2118 void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *N,
2122 auto Constant = cast<ConstantSDNode>(
N);
2124 bool IsTarget =
Constant->isTargetOpcode();
2125 bool IsOpaque =
Constant->isOpaque();
2127 Lo = DAG.
getConstant(Cst.trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
2128 Hi = DAG.
getConstant(Cst.lshr(NBitWidth).trunc(NBitWidth), dl, NVT, IsTarget,
2132 void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *N,
2145 Lo = DAG.
getSelect(dl, NVT, HiNotZero, HiLZ,
2152 void DAGTypeLegalizer::ExpandIntRes_CTPOP(
SDNode *N,
2163 void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *N,
2176 Lo = DAG.
getSelect(dl, NVT, LoNotZero, LoLZ,
2183 void DAGTypeLegalizer::ExpandIntRes_FLT_ROUNDS(
SDNode *N,
SDValue &Lo,
2196 void DAGTypeLegalizer::ExpandIntRes_FP_TO_SINT(
SDNode *N,
SDValue &Lo,
2203 Op = GetPromotedFloat(Op);
2206 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-sint conversion!");
2207 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Op,
true, dl).first,
2211 void DAGTypeLegalizer::ExpandIntRes_FP_TO_UINT(
SDNode *N,
SDValue &Lo,
2218 Op = GetPromotedFloat(Op);
2221 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-uint conversion!");
2222 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Op,
false, dl).first,
2226 void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *N,
2229 ExpandRes_NormalLoad(N, Lo, Hi);
2251 Alignment, MMOFlags, AAInfo);
2276 unsigned ExcessBits =
2284 Hi = DAG.
getExtLoad(ExtType, dl, NVT, Ch, Ptr,
2286 MinAlign(Alignment, IncrementSize), MMOFlags, AAInfo);
2298 unsigned ExcessBits = (EBytes - IncrementSize)*8;
2304 Alignment, MMOFlags, AAInfo);
2313 MinAlign(Alignment, IncrementSize), MMOFlags, AAInfo);
2337 ReplaceValueWith(
SDValue(N, 1), Ch);
2340 void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *N,
2344 GetExpandedInteger(N->
getOperand(0), LL, LH);
2345 GetExpandedInteger(N->
getOperand(1), RL, RH);
2350 void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *N,
2357 GetExpandedInteger(N->
getOperand(0), LL, LH);
2358 GetExpandedInteger(N->
getOperand(1), RL, RH);
2368 LC = RTLIB::MUL_I16;
2370 LC = RTLIB::MUL_I32;
2372 LC = RTLIB::MUL_I64;
2374 LC = RTLIB::MUL_I128;
2382 unsigned HalfBits = Bits >> 1;
2425 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops,
true, dl).first,
2429 void DAGTypeLegalizer::ExpandIntRes_READCYCLECOUNTER(
SDNode *N,
SDValue &Lo,
2440 void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
2451 SplitInteger(Sum, Lo, Hi);
2479 ReplaceValueWith(
SDValue(Node, 1), Cmp);
2482 void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *N,
2496 LC = RTLIB::SDIV_I16;
2498 LC = RTLIB::SDIV_I32;
2500 LC = RTLIB::SDIV_I64;
2502 LC = RTLIB::SDIV_I128;
2503 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
2505 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops,
true, dl).first,
Lo,
Hi);
2508 void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *N,
2516 return ExpandShiftByConstant(N, CN->getAPIntValue(),
Lo,
Hi);
2520 if (ExpandShiftWithKnownAmountBit(N, Lo, Hi))
2542 GetExpandedInteger(N->
getOperand(0), LHSL, LHSH);
2552 "ShiftAmountTy is too small to cover the range of this type!");
2556 SDValue Ops[] = { LHSL, LHSH, ShiftOp };
2568 LC = RTLIB::SHL_I16;
2570 LC = RTLIB::SHL_I32;
2572 LC = RTLIB::SHL_I64;
2574 LC = RTLIB::SHL_I128;
2578 LC = RTLIB::SRL_I16;
2580 LC = RTLIB::SRL_I32;
2582 LC = RTLIB::SRL_I64;
2584 LC = RTLIB::SRL_I128;
2589 LC = RTLIB::SRA_I16;
2591 LC = RTLIB::SRA_I32;
2593 LC = RTLIB::SRA_I64;
2595 LC = RTLIB::SRA_I128;
2600 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops, isSigned, dl).first,
Lo,
Hi);
2604 if (!ExpandShiftWithUnknownAmountBit(N, Lo, Hi))
2608 void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *N,
2626 "Only know how to promote this result!");
2627 SDValue Res = GetPromotedInteger(Op);
2629 "Operand over promoted?");
2631 SplitInteger(Res, Lo, Hi);
2639 void DAGTypeLegalizer::
2665 void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *N,
2679 LC = RTLIB::SREM_I16;
2681 LC = RTLIB::SREM_I32;
2683 LC = RTLIB::SREM_I64;
2685 LC = RTLIB::SREM_I128;
2686 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
2688 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops,
true, dl).first,
Lo,
Hi);
2691 void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *N,
2703 void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *N,
2713 SplitInteger(MUL, Lo, Hi);
2727 ReplaceValueWith(
SDValue(N, 1), Overflow);
2738 LC = RTLIB::MULO_I32;
2740 LC = RTLIB::MULO_I64;
2742 LC = RTLIB::MULO_I128;
2743 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported XMULO!");
2752 TargetLowering::ArgListEntry Entry;
2754 EVT ArgVT =
Op.getValueType();
2758 Entry.IsSExt =
true;
2759 Entry.IsZExt =
false;
2760 Args.push_back(Entry);
2766 Entry.IsSExt =
true;
2767 Entry.IsZExt =
false;
2768 Args.push_back(Entry);
2780 SplitInteger(CallInfo.first, Lo, Hi);
2787 ReplaceValueWith(
SDValue(N, 1), Ofl);
2790 void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *N,
2804 LC = RTLIB::UDIV_I16;
2806 LC = RTLIB::UDIV_I32;
2808 LC = RTLIB::UDIV_I64;
2810 LC = RTLIB::UDIV_I128;
2811 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
2813 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops,
false, dl).first,
Lo,
Hi);
2816 void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *N,
2830 LC = RTLIB::UREM_I16;
2832 LC = RTLIB::UREM_I32;
2834 LC = RTLIB::UREM_I64;
2836 LC = RTLIB::UREM_I128;
2837 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
2839 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops,
false, dl).first,
Lo,
Hi);
2842 void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *N,
2856 "Only know how to promote this result!");
2857 SDValue Res = GetPromotedInteger(Op);
2859 "Operand over promoted?");
2861 SplitInteger(Res, Lo, Hi);
2869 void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *N,
2872 EVT VT = cast<AtomicSDNode>(
N)->getMemoryVT();
2877 cast<AtomicSDNode>(N)->getMemoryVT(), VTs, N->
getOperand(0),
2878 N->
getOperand(1), Zero, Zero, cast<AtomicSDNode>(
N)->getMemOperand());
2892 bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *N,
unsigned OpNo) {
2903 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
2909 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(N);
break;
2915 case ISD::SETCC: Res = ExpandIntOp_SETCC(N);
break;
2918 case ISD::STORE: Res = ExpandIntOp_STORE(cast<StoreSDNode>(N), OpNo);
break;
2926 case ISD::ROTR: Res = ExpandIntOp_Shift(N);
break;
2934 if (!Res.getNode())
return false;
2938 if (Res.getNode() ==
N)
2942 "Invalid operand expansion");
2944 ReplaceValueWith(
SDValue(N, 0), Res);
2950 void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
2954 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
2955 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
2956 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
2959 if (RHSLo == RHSHi) {
2961 if (RHSCST->isAllOnesValue()) {
2981 if ((CCCode ==
ISD::SETLT && CST->isNullValue()) ||
2982 (CCCode ==
ISD::SETGT && CST->isAllOnesValue())) {
3014 RHSLo, LowCC,
false, DagCombineInfo, dl);
3021 RHSHi, CCCode,
false, DagCombineInfo, dl);
3033 if ((EqAllowed && (HiCmpC && HiCmpC->isNullValue())) ||
3034 (!EqAllowed && ((HiCmpC && (HiCmpC->getAPIntValue() == 1)) ||
3044 if (LHSHi == RHSHi) {
3057 if (HasSETCCCARRY) {
3060 bool FlipOperands =
false;
3088 false, DagCombineInfo, dl);
3099 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode,
SDLoc(N));
3114 SDValue DAGTypeLegalizer::ExpandIntOp_SELECT_CC(
SDNode *N) {
3117 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode,
SDLoc(N));
3135 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode,
SDLoc(N));
3140 "Unexpected setcc expansion!");
3149 SDValue DAGTypeLegalizer::ExpandIntOp_SETCCCARRY(
SDNode *N) {
3156 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
3157 GetExpandedInteger(LHS, LHSLo, LHSHi);
3158 GetExpandedInteger(RHS, RHSLo, RHSHi);
3176 SDValue DAGTypeLegalizer::ExpandIntOp_RETURNADDR(
SDNode *N) {
3185 SDValue DAGTypeLegalizer::ExpandIntOp_SINT_TO_FP(
SDNode *N) {
3189 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3190 "Don't know how to expand this SINT_TO_FP!");
3196 return ExpandOp_NormalStore(N, OpNo);
3199 assert(OpNo == 1 &&
"Can only expand the stored value so far");
3226 unsigned ExcessBits =
3235 MinAlign(Alignment, IncrementSize), MMOFlags, AAInfo);
3246 unsigned ExcessBits = (EBytes - IncrementSize)*8;
3248 ExtVT.getSizeInBits() - ExcessBits);
3272 MinAlign(Alignment, IncrementSize), MMOFlags, AAInfo);
3278 GetExpandedInteger(N->
getOperand(0), InL, InH);
3283 SDValue DAGTypeLegalizer::ExpandIntOp_UINT_TO_FP(
SDNode *N) {
3303 const uint64_t F32TwoE32 = 0x4F800000ULL;
3304 const uint64_t F32TwoE64 = 0x5F800000ULL;
3305 const uint64_t F32TwoE128 = 0x7F800000ULL;
3309 FF =
APInt(32, F32TwoE32);
3311 FF =
APInt(32, F32TwoE64);
3313 FF =
APInt(32, F32TwoE128);
3319 GetExpandedInteger(Op, Lo, Hi);
3338 unsigned Alignment = cast<ConstantPoolSDNode>(FudgePtr)->
getAlignment();
3341 Alignment = std::min(Alignment, 4u);
3354 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3355 "Don't know how to expand this UINT_TO_FP!");
3356 return TLI.
makeLibCall(DAG, LC, DstVT, Op,
true, dl).first;
3359 SDValue DAGTypeLegalizer::ExpandIntOp_ATOMIC_STORE(
SDNode *N) {
3362 cast<AtomicSDNode>(N)->getMemoryVT(),
3365 cast<AtomicSDNode>(
N)->getMemOperand());
3370 SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *N) {
3376 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
3385 for (
unsigned i = 0; i != OutNumElems; ++i) {
3402 SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *N) {
3417 SDValue DAGTypeLegalizer::PromoteIntRes_BUILD_VECTOR(
SDNode *N) {
3420 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
3428 for (
unsigned i = 0; i != NumElems; ++i) {
3444 SDValue DAGTypeLegalizer::PromoteIntRes_SCALAR_TO_VECTOR(
SDNode *N) {
3449 "Input must be a scalar");
3453 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
3461 SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *N) {
3466 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
3473 assert(NumElem * NumOperands == NumOutElem &&
3474 "Unexpected number of elements");
3478 for (
unsigned i = 0; i < NumOperands; ++i) {
3481 Op = GetPromotedInteger(Op);
3484 "Unexpected number of elements");
3486 for (
unsigned j = 0; j < NumElem; ++j) {
3497 SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *N) {
3500 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
3514 Promoted = SExtPromotedInteger(N->
getOperand(0));
3517 Promoted = ZExtPromotedInteger(N->
getOperand(0));
3520 Promoted = GetPromotedInteger(N->
getOperand(0));
3532 SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *N) {
3535 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
3548 SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *N) {
3562 SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *N) {
3572 SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *N) {
3582 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
3587 for (
unsigned i=0; i<NumElem; ++i) {
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...
void push_back(const T &Elt)
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
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.
static std::pair< ISD::CondCode, ISD::NodeType > getExpandedMinMaxOps(int Op)
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant, which is required to be operand #1) half of the integer or float value specified as operand #0.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond)
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an vector value) starting with the ...
BR_CC - Conditional branch.
Compute iterated dominance frontiers using a linear time algorithm.
static MVT getVectorVT(MVT VT, unsigned NumElements)
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.
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
Libcall getSYNC(unsigned Opc, MVT VT)
Return the SYNC_FETCH_AND_* value for the given opcode and type, or UNKNOWN_LIBCALL if there is none...
const SDValue & getBasePtr() const
Carry-setting nodes for multiple precision addition and subtraction.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
APInt zext(unsigned width) const
Zero extend to a new width.
const SDValue & getValue() const
bool isCompressingStore() const
Returns true if the op does a compression to the vector before storing.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Get a value with low bits set.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit...
const SDValue & getBasePtr() const
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
const SDValue & getBasePtr() const
const SDValue & getChain() const
static const fltSemantics & EVTToAPFloatSemantics(EVT VT)
Returns an APFloat semantics tag appropriate for the given type.
unsigned getAlignment() const
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
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.
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.
void reserve(size_type N)
bool isOperationLegalOrCustom(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
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.
SDValue getConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offs=0, bool isT=false, unsigned char TargetFlags=0)
unsigned getValueSizeInBits() const
Returns the size of the value in bits.
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...
SDValue getExternalSymbol(const char *Sym, EVT VT)
Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations...
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
static uint32_t getAlignment(const MCSectionCOFF &Sec)
SDValue SimplifySetCC(EVT VT, SDValue N0, SDValue N1, ISD::CondCode Cond, bool foldBooleans, DAGCombinerInfo &DCI, const SDLoc &dl) const
Try to simplify a setcc built with the specified operands and cc.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Shift and rotation operations.
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
CallLoweringInfo & setChain(SDValue InChain)
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
op_iterator op_end() const
unsigned getScalarValueSizeInBits() const
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
FLT_ROUNDS_ - Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest 2 Round to ...
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amt) For double-word atomic operations: ValLo, ValHi, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amtLo, amtHi) ValLo, ValHi, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amtLo, amtHi) These correspond to the atomicrmw instruction.
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.
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG...
This is an SDNode representing atomic operations.
bool expandMUL(SDNode *N, SDValue &Lo, SDValue &Hi, EVT HiLoVT, SelectionDAG &DAG, MulExpansionKind Kind, SDValue LL=SDValue(), SDValue LH=SDValue(), SDValue RL=SDValue(), SDValue RH=SDValue()) const
Expand a MUL into two nodes.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
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 getSizeInBits() const
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
SDValue getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign-extending or trunca...
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)
bool isUNINDEXEDStore(const SDNode *N)
Returns true if the specified node is an unindexed store.
const SDValue & getScale() const
CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const
Get the CallingConv that should be used for the specified libcall.
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
Simple integer binary arithmetic operators.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool isLittleEndian() const
Layout endianness...
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)
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
op_iterator op_begin() const
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
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...
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Get a value with high bits set.
unsigned ComputeNumSignBits(SDValue Op, unsigned Depth=0) const
Return the number of times the sign bit of the register is replicated into the other bits...
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.
EVT getTypeToExpandTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
const SDValue & getBasePtr() const
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE 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...
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
The instances of the Type class are immutable: once they are created, they are never changed...
Simple binary floating point operators.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
This is an important base class in LLVM.
iterator_range< value_op_iterator > op_values() const
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
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...
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
Carry-using nodes for multiple precision addition and subtraction.
Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const
This callback is invoked for operations that are unsupported by the target, which are registered to u...
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
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.
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo...
std::vector< ArgListEntry > ArgListTy
const SDValue & getIndex() const
const SDValue & getBasePtr() const
This structure contains all information that is necessary for lowering calls.
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 getAtomicCmpSwap(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDVTList VTs, SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp, MachinePointerInfo PtrInfo, unsigned Alignment, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SyncScope::ID SSID)
Gets a node for an atomic cmpxchg op.
SDValue getZeroExtendInReg(SDValue Op, const SDLoc &DL, EVT VT)
Return the expression required to zero extend the Op value assuming it was the smaller SrcTy value...
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 isUNINDEXEDLoad(const SDNode *N)
Returns true if the specified node is an unindexed load.
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
TokenFactor - This node takes multiple tokens as input and produces a single token result...
void dump() const
Dump this node, for debugging.
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.
SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
Like SetCC, ops #0 and #1 are the LHS and RHS operands to compare, but op #2 is a boolean indicating ...
SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
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.
BRCOND - Conditional branch.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Byte Swap and Counting operators.
LegalizeAction getOperationAction(unsigned Op, EVT VT) const
Return how this operation should be treated: either it is legal, needs to be promoted to a larger siz...
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Represents one node in the SelectionDAG.
static unsigned int semanticsPrecision(const fltSemantics &)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
MachinePointerInfo getWithOffset(int64_t O) const
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
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.
Class for arbitrary precision integers.
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.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
Flags
Flags values. These may be or'd together.
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
bool ugt(const APInt &RHS) const
Unsigned greather than comparison.
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
Libcall getFPTOUINT(EVT OpVT, EVT RetVT)
getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
bool isVector() const
Return true if this is a vector value type.
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
Bitwise operators - logical and, logical or, logical xor.
std::pair< SDValue, SDValue > makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, ArrayRef< SDValue > Ops, bool isSigned, const SDLoc &dl, bool doesNotReturn=false, bool isReturnValueUsed=true) const
Returns a pair of (return value, chain).
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
void computeKnownBits(SDValue Op, KnownBits &Known, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
static bool isSigned(Value *V)
Can the given value generate sign bits.
Flags getFlags() const
Return the raw flags of the source value,.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool isNON_EXTLoad(const SDNode *N)
Returns true if the specified node is a non-extending load.
SDValue getValue(unsigned R) const
This class is used to represent an MSCATTER node.
unsigned getNumRegisters(LLVMContext &Context, EVT VT) const
Return the number of registers that this ValueType will eventually require.
static MachinePointerInfo getConstantPool(MachineFunction &MF)
Return a MachinePointerInfo record that refers to the constant pool.
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
SDValue getCondCode(ISD::CondCode Cond)
Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none...
SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Val, const Value *PtrVal, unsigned Alignment, AtomicOrdering Ordering, SyncScope::ID SSID)
Gets a node for an atomic op, produces result (if relevant) and chain and takes 2 operands...
SDValue getVAArg(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue SV, unsigned Align)
VAArg produces a result and token chain, and takes a pointer and a source value as input...
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.
ArrayRef< int > getMask() const
uint64_t getConstantOperandVal(unsigned Num) const
Helper method returns the integer value of a ConstantSDNode operand.
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...
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.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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.
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.
OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val) This corresponds to "store atomic" instruction.
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...
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.
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
LLVMContext * getContext() const
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL, bool LegalTypes=true) const
Carry-using nodes for multiple precision addition and subtraction.
const SDValue & getMask() const
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
This class is used to represent ISD::LOAD nodes.