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;
128 case ISD::MUL: Res = PromoteIntRes_SimpleIntBinOp(N);
break;
131 case ISD::SREM: Res = PromoteIntRes_SExtIntBinOp(N);
break;
134 case ISD::UREM: Res = PromoteIntRes_ZExtIntBinOp(N);
break;
137 case ISD::SSUBO: Res = PromoteIntRes_SADDSUBO(N, ResNo);
break;
139 case ISD::USUBO: Res = PromoteIntRes_UADDSUBO(N, ResNo);
break;
141 case ISD::UMULO: Res = PromoteIntRes_XMULO(N, ResNo);
break;
146 case ISD::SUBCARRY: Res = PromoteIntRes_ADDSUBCARRY(N, ResNo);
break;
151 case ISD::USUBSAT: Res = PromoteIntRes_ADDSUBSAT(N);
break;
152 case ISD::SMULFIX: Res = PromoteIntRes_SMULFIX(N);
break;
155 Res = PromoteIntRes_Atomic0(cast<AtomicSDNode>(N));
break;
169 Res = PromoteIntRes_Atomic1(cast<AtomicSDNode>(N));
break;
173 Res = PromoteIntRes_AtomicCmpSwap(cast<AtomicSDNode>(N), ResNo);
179 SetPromotedInteger(
SDValue(N, ResNo), Res);
184 SDValue Op = DisintegrateMERGE_VALUES(N, ResNo);
185 return GetPromotedInteger(Op);
188 SDValue DAGTypeLegalizer::PromoteIntRes_AssertSext(
SDNode *N) {
195 SDValue DAGTypeLegalizer::PromoteIntRes_AssertZext(
SDNode *N) {
256 for (
unsigned i = 1, NumResults = N->
getNumValues(); i < NumResults; ++i)
269 switch (getTypeAction(InVT)) {
293 BitConvertToInteger(GetScalarizedVector(InOp)));
300 Lo = BitConvertToInteger(Lo);
301 Hi = BitConvertToInteger(Hi);
309 JoinIntegers(Lo, Hi));
324 if (WidenInSize % OutSize == 0) {
325 unsigned Scale = WidenInSize / OutSize;
329 if (isTypeLegal(WideOutVT)) {
330 InOp = DAG.
getBitcast(WideOutVT, GetWidenedVector(InOp));
341 CreateStackStoreLoad(InOp, OutVT));
369 SDValue DAGTypeLegalizer::PromoteIntRes_BITREVERSE(
SDNode *N) {
382 SDValue DAGTypeLegalizer::PromoteIntRes_BUILD_PAIR(
SDNode *N) {
391 SDValue DAGTypeLegalizer::PromoteIntRes_Constant(
SDNode *N) {
401 assert(isa<ConstantSDNode>(Result) &&
"Didn't constant fold ext?");
435 OVT.getScalarSizeInBits());
441 SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_VECTOR_ELT(
SDNode *N) {
466 SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_XINT(
SDNode *N) {
494 SDValue DAGTypeLegalizer::PromoteIntRes_FP_TO_FP16(
SDNode *N) {
501 SDValue DAGTypeLegalizer::PromoteIntRes_FLT_ROUNDS(
SDNode *N) {
508 SDValue DAGTypeLegalizer::PromoteIntRes_INT_EXTEND(
SDNode *N) {
569 "Gather result type and the passThru agrument type should be the same");
584 SDValue DAGTypeLegalizer::PromoteIntRes_Overflow(
SDNode *N) {
590 assert(NumOps <= 3 &&
"Too many operands");
599 ReplaceValueWith(
SDValue(N, 0), Res);
604 SDValue DAGTypeLegalizer::PromoteIntRes_ADDSUBSAT(
SDNode *N) {
628 "addition or subtraction");
631 SDValue Op1Promoted = GetPromotedInteger(Op1);
632 SDValue Op2Promoted = GetPromotedInteger(Op2);
636 unsigned SHLAmount = NewBits - OldBits;
645 DAG.
getNode(Opcode, dl, PromotedType, Op1Promoted, Op2Promoted);
646 return DAG.
getNode(ShiftOp, dl, PromotedType, Result, ShiftAmount);
655 return DAG.
getNode(N->
getOpcode(), dl, PromotedType, Op1Promoted, Op2Promoted,
659 SDValue DAGTypeLegalizer::PromoteIntRes_SADDSUBO(
SDNode *N,
unsigned ResNo) {
661 return PromoteIntRes_Overflow(N);
683 ReplaceValueWith(
SDValue(N, 1), Ofl);
704 SDValue DAGTypeLegalizer::PromoteIntRes_SELECT_CC(
SDNode *N) {
716 EVT SVT = getSetCCResultType(InVT);
724 SVT = getSetCCResultType(InVT);
733 "Vector compare must return a vector result!");
747 RHS = ZExtPromotedInteger(RHS);
751 SDValue DAGTypeLegalizer::PromoteIntRes_SIGN_EXTEND_INREG(
SDNode *N) {
757 SDValue DAGTypeLegalizer::PromoteIntRes_SimpleIntBinOp(
SDNode *N) {
767 SDValue DAGTypeLegalizer::PromoteIntRes_SExtIntBinOp(
SDNode *N) {
775 SDValue DAGTypeLegalizer::PromoteIntRes_ZExtIntBinOp(
SDNode *N) {
788 RHS = ZExtPromotedInteger(RHS);
797 RHS = ZExtPromotedInteger(RHS);
801 SDValue DAGTypeLegalizer::PromoteIntRes_TRUNCATE(
SDNode *N) {
814 Res = GetPromotedInteger(InOp);
821 "Dst and Src must have the same number of elements");
823 "Promoted vector type must be a power of two");
826 GetSplitVector(InOp, EOp1, EOp2);
836 SDValue WideInOp = GetWidenedVector(InOp);
860 SDValue DAGTypeLegalizer::PromoteIntRes_UADDSUBO(
SDNode *N,
unsigned ResNo) {
862 return PromoteIntRes_Overflow(N);
883 ReplaceValueWith(
SDValue(N, 1), Ofl);
891 SDValue DAGTypeLegalizer::PromoteIntRes_ADDSUBCARRY(
SDNode *N,
unsigned ResNo) {
893 return PromoteIntRes_Overflow(N);
920 SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(
SDNode *N,
unsigned ResNo) {
923 return PromoteIntRes_Overflow(N);
934 LHS = SExtPromotedInteger(LHS);
935 RHS = SExtPromotedInteger(RHS);
937 LHS = ZExtPromotedInteger(LHS);
938 RHS = ZExtPromotedInteger(RHS);
968 ReplaceValueWith(
SDValue(N, 1), Overflow);
988 for (
unsigned i = 0; i < NumRegs; ++i) {
991 Chain = Parts[i].getValue(1);
1001 for (
unsigned i = 1; i < NumRegs; ++i) {
1012 ReplaceValueWith(
SDValue(N, 1), Chain);
1025 bool DAGTypeLegalizer::PromoteIntegerOperand(
SDNode *N,
unsigned OpNo) {
1038 dbgs() <<
"PromoteIntegerOperand Op #" << OpNo <<
": ";
1045 Res = PromoteIntOp_ATOMIC_STORE(cast<AtomicSDNode>(N));
1047 case ISD::BITCAST: Res = PromoteIntOp_BITCAST(N);
break;
1048 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(N, OpNo);
break;
1049 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(N, OpNo);
break;
1055 Res = PromoteIntOp_INSERT_VECTOR_ELT(N, OpNo);
break;
1057 Res = PromoteIntOp_SCALAR_TO_VECTOR(N);
break;
1059 case ISD::SELECT: Res = PromoteIntOp_SELECT(N, OpNo);
break;
1060 case ISD::SELECT_CC: Res = PromoteIntOp_SELECT_CC(N, OpNo);
break;
1061 case ISD::SETCC: Res = PromoteIntOp_SETCC(N, OpNo);
break;
1064 case ISD::STORE: Res = PromoteIntOp_STORE(cast<StoreSDNode>(N),
1066 case ISD::MSTORE: Res = PromoteIntOp_MSTORE(cast<MaskedStoreSDNode>(N),
1068 case ISD::MLOAD: Res = PromoteIntOp_MLOAD(cast<MaskedLoadSDNode>(N),
1070 case ISD::MGATHER: Res = PromoteIntOp_MGATHER(cast<MaskedGatherSDNode>(N),
1072 case ISD::MSCATTER: Res = PromoteIntOp_MSCATTER(cast<MaskedScatterSDNode>(N),
1084 case ISD::ROTR: Res = PromoteIntOp_Shift(N);
break;
1087 case ISD::SUBCARRY: Res = PromoteIntOp_ADDSUBCARRY(N, OpNo);
break;
1092 case ISD::PREFETCH: Res = PromoteIntOp_PREFETCH(N, OpNo);
break;
1094 case ISD::SMULFIX: Res = PromoteIntOp_SMULFIX(N);
break;
1098 if (!Res.getNode())
return false;
1102 if (Res.getNode() ==
N)
1106 "Invalid operand expansion");
1108 ReplaceValueWith(
SDValue(N, 0), Res);
1114 void DAGTypeLegalizer::PromoteSetCCOperands(
SDValue &NewLHS,
SDValue &NewRHS,
1124 SDValue OpL = GetPromotedInteger(NewLHS);
1125 SDValue OpR = GetPromotedInteger(NewRHS);
1131 unsigned OpLEffectiveBits =
1133 unsigned OpREffectiveBits =
1140 NewLHS = SExtOrZExtPromotedInteger(NewLHS);
1141 NewRHS = SExtOrZExtPromotedInteger(NewRHS);
1149 NewLHS = SExtOrZExtPromotedInteger(NewLHS);
1150 NewRHS = SExtOrZExtPromotedInteger(NewRHS);
1156 NewLHS = SExtPromotedInteger(NewLHS);
1157 NewRHS = SExtPromotedInteger(NewRHS);
1162 SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND(
SDNode *N) {
1179 SDValue DAGTypeLegalizer::PromoteIntOp_BR_CC(
SDNode *N,
unsigned OpNo) {
1180 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
1184 PromoteSetCCOperands(LHS, RHS, cast<CondCodeSDNode>(N->
getOperand(1))->
get());
1193 SDValue DAGTypeLegalizer::PromoteIntOp_BRCOND(
SDNode *N,
unsigned OpNo) {
1194 assert(OpNo == 1 &&
"only know how to promote condition");
1204 SDValue DAGTypeLegalizer::PromoteIntOp_BUILD_PAIR(
SDNode *N) {
1218 SDValue DAGTypeLegalizer::PromoteIntOp_BUILD_VECTOR(
SDNode *N) {
1225 "Legal vector of one illegal element?");
1232 "Type of inserted value narrower than vector element type!");
1235 for (
unsigned i = 0; i < NumElts; ++i)
1241 SDValue DAGTypeLegalizer::PromoteIntOp_INSERT_VECTOR_ELT(
SDNode *N,
1250 "Type of inserted value narrower than vector element type!");
1257 assert(OpNo == 2 &&
"Different operand and result vector types?");
1266 SDValue DAGTypeLegalizer::PromoteIntOp_SCALAR_TO_VECTOR(
SDNode *N) {
1273 SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(
SDNode *N,
unsigned OpNo) {
1274 assert(OpNo == 0 &&
"Only know how to promote the condition!");
1279 if (
SDValue Res = WidenVSELECTAndMask(N))
1284 Cond = PromoteTargetBoolean(Cond, OpVT);
1290 SDValue DAGTypeLegalizer::PromoteIntOp_SELECT_CC(
SDNode *N,
unsigned OpNo) {
1291 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
1295 PromoteSetCCOperands(LHS, RHS, cast<CondCodeSDNode>(N->
getOperand(4))->
get());
1302 SDValue DAGTypeLegalizer::PromoteIntOp_SETCC(
SDNode *N,
unsigned OpNo) {
1303 assert(OpNo == 0 &&
"Don't know how to promote this operand!");
1307 PromoteSetCCOperands(LHS, RHS, cast<CondCodeSDNode>(N->
getOperand(2))->
get());
1318 SDValue DAGTypeLegalizer::PromoteIntOp_SIGN_EXTEND(
SDNode *N) {
1326 SDValue DAGTypeLegalizer::PromoteIntOp_SINT_TO_FP(
SDNode *N) {
1351 bool TruncateStore =
false;
1353 Mask = PromoteTargetBoolean(Mask, DataVT);
1359 assert(OpNo == 1 &&
"Unexpected operand for promotion");
1360 DataOp = GetPromotedInteger(DataOp);
1361 TruncateStore =
true;
1371 assert(OpNo == 2 &&
"Only know how to promote the mask!");
1375 NewOps[OpNo] =
Mask;
1386 NewOps[OpNo] = PromoteTargetBoolean(N->
getOperand(OpNo), DataVT);
1387 }
else if (OpNo == 4) {
1389 NewOps[OpNo] = SExtPromotedInteger(N->
getOperand(OpNo));
1391 NewOps[OpNo] = GetPromotedInteger(N->
getOperand(OpNo));
1402 NewOps[OpNo] = PromoteTargetBoolean(N->
getOperand(OpNo), DataVT);
1403 }
else if (OpNo == 4) {
1405 NewOps[OpNo] = SExtPromotedInteger(N->
getOperand(OpNo));
1407 NewOps[OpNo] = GetPromotedInteger(N->
getOperand(OpNo));
1411 SDValue DAGTypeLegalizer::PromoteIntOp_TRUNCATE(
SDNode *N) {
1416 SDValue DAGTypeLegalizer::PromoteIntOp_UINT_TO_FP(
SDNode *N) {
1421 SDValue DAGTypeLegalizer::PromoteIntOp_ZERO_EXTEND(
SDNode *N) {
1429 SDValue DAGTypeLegalizer::PromoteIntOp_ADDSUBCARRY(
SDNode *N,
unsigned OpNo) {
1430 assert(OpNo == 2 &&
"Don't know how to promote this operand!");
1460 SDValue DAGTypeLegalizer::PromoteIntOp_FRAMERETURNADDR(
SDNode *N) {
1466 SDValue DAGTypeLegalizer::PromoteIntOp_PREFETCH(
SDNode *N,
unsigned OpNo) {
1467 assert(OpNo > 1 &&
"Don't know how to promote this operand!");
1486 void DAGTypeLegalizer::ExpandIntegerResult(
SDNode *N,
unsigned ResNo) {
1499 dbgs() <<
"ExpandIntegerResult #" << ResNo <<
": ";
1502 llvm_unreachable(
"Do not know how to expand the result of this operator!");
1505 case ISD::SELECT: SplitRes_SELECT(N, Lo, Hi);
break;
1507 case ISD::UNDEF: SplitRes_UNDEF(N, Lo, Hi);
break;
1509 case ISD::BITCAST: ExpandRes_BITCAST(N, Lo, Hi);
break;
1513 case ISD::VAARG: ExpandRes_VAARG(N, Lo, Hi);
break;
1519 case ISD::BSWAP: ExpandIntRes_BSWAP(N, Lo, Hi);
break;
1520 case ISD::Constant: ExpandIntRes_Constant(N, Lo, Hi);
break;
1522 case ISD::CTLZ: ExpandIntRes_CTLZ(N, Lo, Hi);
break;
1523 case ISD::CTPOP: ExpandIntRes_CTPOP(N, Lo, Hi);
break;
1525 case ISD::CTTZ: ExpandIntRes_CTTZ(N, Lo, Hi);
break;
1529 case ISD::LOAD: ExpandIntRes_LOAD(cast<LoadSDNode>(N), Lo, Hi);
break;
1530 case ISD::MUL: ExpandIntRes_MUL(N, Lo, Hi);
break;
1532 case ISD::SDIV: ExpandIntRes_SDIV(N, Lo, Hi);
break;
1535 case ISD::SREM: ExpandIntRes_SREM(N, Lo, Hi);
break;
1536 case ISD::TRUNCATE: ExpandIntRes_TRUNCATE(N, Lo, Hi);
break;
1537 case ISD::UDIV: ExpandIntRes_UDIV(N, Lo, Hi);
break;
1538 case ISD::UREM: ExpandIntRes_UREM(N, Lo, Hi);
break;
1555 std::pair<SDValue, SDValue> Tmp = ExpandAtomic(N);
1556 SplitInteger(Tmp.first, Lo, Hi);
1557 ReplaceValueWith(
SDValue(N, 1), Tmp.second);
1574 SplitInteger(Tmp, Lo, Hi);
1575 ReplaceValueWith(
SDValue(N, 1), Success);
1582 case ISD::XOR: ExpandIntRes_Logical(N, Lo, Hi);
break;
1587 case ISD::SMIN: ExpandIntRes_MINMAX(N, Lo, Hi);
break;
1590 case ISD::SUB: ExpandIntRes_ADDSUB(N, Lo, Hi);
break;
1593 case ISD::SUBC: ExpandIntRes_ADDSUBC(N, Lo, Hi);
break;
1596 case ISD::SUBE: ExpandIntRes_ADDSUBE(N, Lo, Hi);
break;
1599 case ISD::SUBCARRY: ExpandIntRes_ADDSUBCARRY(N, Lo, Hi);
break;
1603 case ISD::SRL: ExpandIntRes_Shift(N, Lo, Hi);
break;
1606 case ISD::SSUBO: ExpandIntRes_SADDSUBO(N, Lo, Hi);
break;
1608 case ISD::USUBO: ExpandIntRes_UADDSUBO(N, Lo, Hi);
break;
1610 case ISD::SMULO: ExpandIntRes_XMULO(N, Lo, Hi);
break;
1615 case ISD::USUBSAT: ExpandIntRes_ADDSUBSAT(N, Lo, Hi);
break;
1616 case ISD::SMULFIX: ExpandIntRes_SMULFIX(N, Lo, Hi);
break;
1625 std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(
SDNode *Node) {
1627 MVT VT = cast<AtomicSDNode>(Node)->getMemoryVT().getSimpleVT();
1629 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected atomic op or value type!");
1631 return ExpandChainLibCall(LC, Node,
false);
1636 void DAGTypeLegalizer::ExpandShiftByConstant(
SDNode *N,
const APInt &Amt,
1641 GetExpandedInteger(N->
getOperand(0), InL, InH);
1657 if (Amt.
ugt(VTBits)) {
1659 }
else if (Amt.
ugt(NVTBits)) {
1662 NVT, InL, DAG.
getConstant(Amt - NVTBits, DL, ShTy));
1663 }
else if (Amt == NVTBits) {
1678 if (Amt.
ugt(VTBits)) {
1680 }
else if (Amt.
ugt(NVTBits)) {
1682 NVT, InH, DAG.
getConstant(Amt - NVTBits, DL, ShTy));
1684 }
else if (Amt == NVTBits) {
1699 if (Amt.
ugt(VTBits)) {
1702 }
else if (Amt.
ugt(NVTBits)) {
1707 }
else if (Amt == NVTBits) {
1725 bool DAGTypeLegalizer::
1733 "Expanded integer type size not a power of two!");
1740 if (((Known.
Zero|Known.
One) & HighBitMask) == 0)
1745 GetExpandedInteger(N->
getOperand(0), InL, InH);
1812 bool DAGTypeLegalizer::
1819 "Expanded integer type size not a power of two!");
1824 GetExpandedInteger(N->
getOperand(0), InL, InH);
1849 Lo = DAG.
getSelect(dl, NVT, isShort, LoS, LoL);
1850 Hi = DAG.
getSelect(dl, NVT, isZero, InH,
1851 DAG.
getSelect(dl, NVT, isShort, HiS, HiL));
1866 Lo = DAG.
getSelect(dl, NVT, isZero, InL,
1867 DAG.
getSelect(dl, NVT, isShort, LoS, LoL));
1868 Hi = DAG.
getSelect(dl, NVT, isShort, HiS, HiL);
1882 Lo = DAG.
getSelect(dl, NVT, isZero, InL,
1883 DAG.
getSelect(dl, NVT, isShort, LoS, LoL));
1884 Hi = DAG.
getSelect(dl, NVT, isShort, HiS, HiL);
1904 void DAGTypeLegalizer::ExpandIntRes_MINMAX(
SDNode *N,
1912 SDValue LHSL, LHSH, RHSL, RHSH;
1913 GetExpandedInteger(N->
getOperand(0), LHSL, LHSH);
1914 GetExpandedInteger(N->
getOperand(1), RHSL, RHSH);
1917 EVT NVT = LHSL.getValueType();
1918 EVT CCT = getSetCCResultType(NVT);
1934 Lo = DAG.
getSelect(DL, NVT, IsHiEq, LoMinMax, LoCmp);
1937 void DAGTypeLegalizer::ExpandIntRes_ADDSUB(
SDNode *N,
1941 SDValue LHSL, LHSH, RHSL, RHSH;
1942 GetExpandedInteger(N->
getOperand(0), LHSL, LHSH);
1943 GetExpandedInteger(N->
getOperand(1), RHSL, RHSH);
1946 SDValue LoOps[2] = { LHSL, RHSL };
1947 SDValue HiOps[3] = { LHSH, RHSH };
1997 EVT OvfVT = getSetCCResultType(NVT);
2021 Hi = DAG.
getNode(RevOpc, dl, NVT, Hi, OVF);
2029 SDValue Cmp1 = DAG.
getSetCC(dl, getSetCCResultType(NVT), Lo, LoOps[0],
2041 SDValue Cmp2 = DAG.
getSetCC(dl, getSetCCResultType(NVT), Lo, LoOps[1],
2050 DAG.
getSetCC(dl, getSetCCResultType(LoOps[0].getValueType()),
2064 void DAGTypeLegalizer::ExpandIntRes_ADDSUBC(
SDNode *N,
2067 SDValue LHSL, LHSH, RHSL, RHSH;
2069 GetExpandedInteger(N->
getOperand(0), LHSL, LHSH);
2070 GetExpandedInteger(N->
getOperand(1), RHSL, RHSH);
2072 SDValue LoOps[2] = { LHSL, RHSL };
2073 SDValue HiOps[3] = { LHSH, RHSH };
2090 void DAGTypeLegalizer::ExpandIntRes_ADDSUBE(
SDNode *N,
2093 SDValue LHSL, LHSH, RHSL, RHSH;
2095 GetExpandedInteger(N->
getOperand(0), LHSL, LHSH);
2096 GetExpandedInteger(N->
getOperand(1), RHSL, RHSH);
2099 SDValue HiOps[3] = { LHSH, RHSH };
2110 void DAGTypeLegalizer::ExpandIntRes_UADDSUBO(
SDNode *N,
2124 SDValue LHSL, LHSH, RHSL, RHSH;
2125 GetExpandedInteger(LHS, LHSL, LHSH);
2126 GetExpandedInteger(RHS, RHSL, RHSH);
2128 SDValue LoOps[2] = { LHSL, RHSL };
2129 SDValue HiOps[3] = { LHSH, RHSH };
2134 Hi = DAG.
getNode(Opc, dl, VTList, HiOps);
2142 SplitInteger(Sum, Lo, Hi);
2152 ReplaceValueWith(
SDValue(N, 1), Ovf);
2155 void DAGTypeLegalizer::ExpandIntRes_ADDSUBCARRY(
SDNode *N,
2158 SDValue LHSL, LHSH, RHSL, RHSH;
2160 GetExpandedInteger(N->
getOperand(0), LHSL, LHSH);
2161 GetExpandedInteger(N->
getOperand(1), RHSL, RHSH);
2175 void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(
SDNode *N,
2189 "Only know how to promote this result!");
2190 SDValue Res = GetPromotedInteger(Op);
2192 "Operand over promoted?");
2194 SplitInteger(Res, Lo, Hi);
2198 void DAGTypeLegalizer::ExpandIntRes_AssertSext(
SDNode *N,
2204 unsigned NVTBits = NVT.getSizeInBits();
2207 if (NVTBits < EVTBits) {
2210 EVTBits - NVTBits)));
2220 void DAGTypeLegalizer::ExpandIntRes_AssertZext(
SDNode *N,
2226 unsigned NVTBits = NVT.getSizeInBits();
2229 if (NVTBits < EVTBits) {
2232 EVTBits - NVTBits)));
2240 void DAGTypeLegalizer::ExpandIntRes_BITREVERSE(
SDNode *N,
2248 void DAGTypeLegalizer::ExpandIntRes_BSWAP(
SDNode *N,
2256 void DAGTypeLegalizer::ExpandIntRes_Constant(
SDNode *N,
2260 auto Constant = cast<ConstantSDNode>(
N);
2262 bool IsTarget =
Constant->isTargetOpcode();
2263 bool IsOpaque =
Constant->isOpaque();
2265 Lo = DAG.
getConstant(Cst.trunc(NBitWidth), dl, NVT, IsTarget, IsOpaque);
2266 Hi = DAG.
getConstant(Cst.lshr(NBitWidth).trunc(NBitWidth), dl, NVT, IsTarget,
2270 void DAGTypeLegalizer::ExpandIntRes_CTLZ(
SDNode *N,
2283 Lo = DAG.
getSelect(dl, NVT, HiNotZero, HiLZ,
2290 void DAGTypeLegalizer::ExpandIntRes_CTPOP(
SDNode *N,
2301 void DAGTypeLegalizer::ExpandIntRes_CTTZ(
SDNode *N,
2314 Lo = DAG.
getSelect(dl, NVT, LoNotZero, LoLZ,
2321 void DAGTypeLegalizer::ExpandIntRes_FLT_ROUNDS(
SDNode *N,
SDValue &Lo,
2334 void DAGTypeLegalizer::ExpandIntRes_FP_TO_SINT(
SDNode *N,
SDValue &Lo,
2341 Op = GetPromotedFloat(Op);
2344 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-sint conversion!");
2345 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Op,
true, dl).first,
2349 void DAGTypeLegalizer::ExpandIntRes_FP_TO_UINT(
SDNode *N,
SDValue &Lo,
2356 Op = GetPromotedFloat(Op);
2359 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected fp-to-uint conversion!");
2360 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Op,
false, dl).first,
2364 void DAGTypeLegalizer::ExpandIntRes_LOAD(
LoadSDNode *N,
2367 ExpandRes_NormalLoad(N, Lo, Hi);
2389 Alignment, MMOFlags, AAInfo);
2414 unsigned ExcessBits =
2422 Hi = DAG.
getExtLoad(ExtType, dl, NVT, Ch, Ptr,
2424 MinAlign(Alignment, IncrementSize), MMOFlags, AAInfo);
2436 unsigned ExcessBits = (EBytes - IncrementSize)*8;
2442 Alignment, MMOFlags, AAInfo);
2451 MinAlign(Alignment, IncrementSize), MMOFlags, AAInfo);
2475 ReplaceValueWith(
SDValue(N, 1), Ch);
2478 void DAGTypeLegalizer::ExpandIntRes_Logical(
SDNode *N,
2482 GetExpandedInteger(N->
getOperand(0), LL, LH);
2483 GetExpandedInteger(N->
getOperand(1), RL, RH);
2488 void DAGTypeLegalizer::ExpandIntRes_MUL(
SDNode *N,
2495 GetExpandedInteger(N->
getOperand(0), LL, LH);
2496 GetExpandedInteger(N->
getOperand(1), RL, RH);
2506 LC = RTLIB::MUL_I16;
2508 LC = RTLIB::MUL_I32;
2510 LC = RTLIB::MUL_I64;
2512 LC = RTLIB::MUL_I128;
2520 unsigned HalfBits = Bits >> 1;
2563 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops,
true, dl).first,
2567 void DAGTypeLegalizer::ExpandIntRes_READCYCLECOUNTER(
SDNode *N,
SDValue &Lo,
2578 void DAGTypeLegalizer::ExpandIntRes_ADDSUBSAT(
SDNode *N,
SDValue &Lo,
2581 SplitInteger(Result, Lo, Hi);
2584 void DAGTypeLegalizer::ExpandIntRes_SMULFIX(
SDNode *N,
SDValue &Lo,
2593 SplitInteger(Result, Lo, Hi);
2599 GetExpandedInteger(LHS, LL, LH);
2600 GetExpandedInteger(RHS, RL, RH);
2635 if (Scale < NVTSize) {
2648 }
else if (Scale == NVTSize) {
2653 }
else if (Scale < VTSize) {
2669 "Expected the scale to be less than the width of the operands");
2673 void DAGTypeLegalizer::ExpandIntRes_SADDSUBO(
SDNode *Node,
2684 SplitInteger(Sum, Lo, Hi);
2712 ReplaceValueWith(
SDValue(Node, 1), Cmp);
2715 void DAGTypeLegalizer::ExpandIntRes_SDIV(
SDNode *N,
2729 LC = RTLIB::SDIV_I16;
2731 LC = RTLIB::SDIV_I32;
2733 LC = RTLIB::SDIV_I64;
2735 LC = RTLIB::SDIV_I128;
2736 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
2738 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops,
true, dl).first,
Lo,
Hi);
2741 void DAGTypeLegalizer::ExpandIntRes_Shift(
SDNode *N,
2749 return ExpandShiftByConstant(N, CN->getAPIntValue(),
Lo,
Hi);
2753 if (ExpandShiftWithKnownAmountBit(N, Lo, Hi))
2775 GetExpandedInteger(N->
getOperand(0), LHSL, LHSH);
2785 "ShiftAmountTy is too small to cover the range of this type!");
2789 SDValue Ops[] = { LHSL, LHSH, ShiftOp };
2801 LC = RTLIB::SHL_I16;
2803 LC = RTLIB::SHL_I32;
2805 LC = RTLIB::SHL_I64;
2807 LC = RTLIB::SHL_I128;
2811 LC = RTLIB::SRL_I16;
2813 LC = RTLIB::SRL_I32;
2815 LC = RTLIB::SRL_I64;
2817 LC = RTLIB::SRL_I128;
2822 LC = RTLIB::SRA_I16;
2824 LC = RTLIB::SRA_I32;
2826 LC = RTLIB::SRA_I64;
2828 LC = RTLIB::SRA_I128;
2833 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops, isSigned, dl).first,
Lo,
Hi);
2837 if (!ExpandShiftWithUnknownAmountBit(N, Lo, Hi))
2841 void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(
SDNode *N,
2859 "Only know how to promote this result!");
2860 SDValue Res = GetPromotedInteger(Op);
2862 "Operand over promoted?");
2864 SplitInteger(Res, Lo, Hi);
2872 void DAGTypeLegalizer::
2898 void DAGTypeLegalizer::ExpandIntRes_SREM(
SDNode *N,
2912 LC = RTLIB::SREM_I16;
2914 LC = RTLIB::SREM_I32;
2916 LC = RTLIB::SREM_I64;
2918 LC = RTLIB::SREM_I128;
2919 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
2921 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops,
true, dl).first,
Lo,
Hi);
2924 void DAGTypeLegalizer::ExpandIntRes_TRUNCATE(
SDNode *N,
2936 void DAGTypeLegalizer::ExpandIntRes_XMULO(
SDNode *N,
2955 SDValue LHSHigh, LHSLow, RHSHigh, RHSLow;
2956 SplitInteger(LHS, LHSLow, LHSHigh);
2957 SplitInteger(RHS, RHSLow, RHSHigh);
2990 SplitInteger(Five, Lo, Hi);
2991 ReplaceValueWith(
SDValue(N, 1), Overflow);
3002 LC = RTLIB::MULO_I32;
3004 LC = RTLIB::MULO_I64;
3006 LC = RTLIB::MULO_I128;
3007 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported XMULO!");
3016 TargetLowering::ArgListEntry Entry;
3018 EVT ArgVT =
Op.getValueType();
3022 Entry.IsSExt =
true;
3023 Entry.IsZExt =
false;
3024 Args.push_back(Entry);
3030 Entry.IsSExt =
true;
3031 Entry.IsZExt =
false;
3032 Args.push_back(Entry);
3044 SplitInteger(CallInfo.first, Lo, Hi);
3051 ReplaceValueWith(
SDValue(N, 1), Ofl);
3054 void DAGTypeLegalizer::ExpandIntRes_UDIV(
SDNode *N,
3068 LC = RTLIB::UDIV_I16;
3070 LC = RTLIB::UDIV_I32;
3072 LC = RTLIB::UDIV_I64;
3074 LC = RTLIB::UDIV_I128;
3075 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UDIV!");
3077 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops,
false, dl).first,
Lo,
Hi);
3080 void DAGTypeLegalizer::ExpandIntRes_UREM(
SDNode *N,
3094 LC = RTLIB::UREM_I16;
3096 LC = RTLIB::UREM_I32;
3098 LC = RTLIB::UREM_I64;
3100 LC = RTLIB::UREM_I128;
3101 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported UREM!");
3103 SplitInteger(TLI.
makeLibCall(DAG, LC, VT, Ops,
false, dl).first,
Lo,
Hi);
3106 void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(
SDNode *N,
3120 "Only know how to promote this result!");
3121 SDValue Res = GetPromotedInteger(Op);
3123 "Operand over promoted?");
3125 SplitInteger(Res, Lo, Hi);
3133 void DAGTypeLegalizer::ExpandIntRes_ATOMIC_LOAD(
SDNode *N,
3136 EVT VT = cast<AtomicSDNode>(
N)->getMemoryVT();
3141 cast<AtomicSDNode>(N)->getMemoryVT(), VTs, N->
getOperand(0),
3142 N->
getOperand(1), Zero, Zero, cast<AtomicSDNode>(
N)->getMemOperand());
3156 bool DAGTypeLegalizer::ExpandIntegerOperand(
SDNode *N,
unsigned OpNo) {
3167 dbgs() <<
"ExpandIntegerOperand Op #" << OpNo <<
": ";
3173 case ISD::BR_CC: Res = ExpandIntOp_BR_CC(N);
break;
3179 case ISD::SETCC: Res = ExpandIntOp_SETCC(N);
break;
3182 case ISD::STORE: Res = ExpandIntOp_STORE(cast<StoreSDNode>(N), OpNo);
break;
3190 case ISD::ROTR: Res = ExpandIntOp_Shift(N);
break;
3198 if (!Res.getNode())
return false;
3202 if (Res.getNode() ==
N)
3206 "Invalid operand expansion");
3208 ReplaceValueWith(
SDValue(N, 0), Res);
3214 void DAGTypeLegalizer::IntegerExpandSetCCOperands(
SDValue &NewLHS,
3218 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
3219 GetExpandedInteger(NewLHS, LHSLo, LHSHi);
3220 GetExpandedInteger(NewRHS, RHSLo, RHSHi);
3223 if (RHSLo == RHSHi) {
3225 if (RHSCST->isAllOnesValue()) {
3245 if ((CCCode ==
ISD::SETLT && CST->isNullValue()) ||
3246 (CCCode ==
ISD::SETGT && CST->isAllOnesValue())) {
3278 RHSLo, LowCC,
false, DagCombineInfo, dl);
3285 RHSHi, CCCode,
false, DagCombineInfo, dl);
3297 if ((EqAllowed && (HiCmpC && HiCmpC->isNullValue())) ||
3298 (!EqAllowed && ((HiCmpC && (HiCmpC->getAPIntValue() == 1)) ||
3308 if (LHSHi == RHSHi) {
3321 if (HasSETCCCARRY) {
3324 bool FlipOperands =
false;
3352 false, DagCombineInfo, dl);
3363 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode,
SDLoc(N));
3378 SDValue DAGTypeLegalizer::ExpandIntOp_SELECT_CC(
SDNode *N) {
3381 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode,
SDLoc(N));
3399 IntegerExpandSetCCOperands(NewLHS, NewRHS, CCCode,
SDLoc(N));
3404 "Unexpected setcc expansion!");
3413 SDValue DAGTypeLegalizer::ExpandIntOp_SETCCCARRY(
SDNode *N) {
3420 SDValue LHSLo, LHSHi, RHSLo, RHSHi;
3421 GetExpandedInteger(LHS, LHSLo, LHSHi);
3422 GetExpandedInteger(RHS, RHSLo, RHSHi);
3440 SDValue DAGTypeLegalizer::ExpandIntOp_RETURNADDR(
SDNode *N) {
3449 SDValue DAGTypeLegalizer::ExpandIntOp_SINT_TO_FP(
SDNode *N) {
3453 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3454 "Don't know how to expand this SINT_TO_FP!");
3460 return ExpandOp_NormalStore(N, OpNo);
3463 assert(OpNo == 1 &&
"Can only expand the stored value so far");
3490 unsigned ExcessBits =
3499 MinAlign(Alignment, IncrementSize), MMOFlags, AAInfo);
3510 unsigned ExcessBits = (EBytes - IncrementSize)*8;
3512 ExtVT.getSizeInBits() - ExcessBits);
3536 MinAlign(Alignment, IncrementSize), MMOFlags, AAInfo);
3542 GetExpandedInteger(N->
getOperand(0), InL, InH);
3547 SDValue DAGTypeLegalizer::ExpandIntOp_UINT_TO_FP(
SDNode *N) {
3567 const uint64_t F32TwoE32 = 0x4F800000ULL;
3568 const uint64_t F32TwoE64 = 0x5F800000ULL;
3569 const uint64_t F32TwoE128 = 0x7F800000ULL;
3573 FF =
APInt(32, F32TwoE32);
3575 FF =
APInt(32, F32TwoE64);
3577 FF =
APInt(32, F32TwoE128);
3583 GetExpandedInteger(Op, Lo, Hi);
3602 unsigned Alignment = cast<ConstantPoolSDNode>(FudgePtr)->
getAlignment();
3605 Alignment = std::min(Alignment, 4u);
3618 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
3619 "Don't know how to expand this UINT_TO_FP!");
3620 return TLI.
makeLibCall(DAG, LC, DstVT, Op,
true, dl).first;
3623 SDValue DAGTypeLegalizer::ExpandIntOp_ATOMIC_STORE(
SDNode *N) {
3626 cast<AtomicSDNode>(N)->getMemoryVT(),
3629 cast<AtomicSDNode>(
N)->getMemOperand());
3634 SDValue DAGTypeLegalizer::PromoteIntRes_EXTRACT_SUBVECTOR(
SDNode *N) {
3640 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
3649 for (
unsigned i = 0; i != OutNumElems; ++i) {
3666 SDValue DAGTypeLegalizer::PromoteIntRes_VECTOR_SHUFFLE(
SDNode *N) {
3681 SDValue DAGTypeLegalizer::PromoteIntRes_BUILD_VECTOR(
SDNode *N) {
3684 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
3692 for (
unsigned i = 0; i != NumElems; ++i) {
3708 SDValue DAGTypeLegalizer::PromoteIntRes_SCALAR_TO_VECTOR(
SDNode *N) {
3713 "Input must be a scalar");
3717 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
3725 SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(
SDNode *N) {
3730 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
3737 assert(NumElem * NumOperands == NumOutElem &&
3738 "Unexpected number of elements");
3742 for (
unsigned i = 0; i < NumOperands; ++i) {
3745 Op = GetPromotedInteger(Op);
3748 "Unexpected number of elements");
3750 for (
unsigned j = 0; j < NumElem; ++j) {
3761 SDValue DAGTypeLegalizer::PromoteIntRes_EXTEND_VECTOR_INREG(
SDNode *N) {
3764 assert(NVT.
isVector() &&
"This type must be promoted to a vector type");
3778 Promoted = SExtPromotedInteger(N->
getOperand(0));
3781 Promoted = ZExtPromotedInteger(N->
getOperand(0));
3784 Promoted = GetPromotedInteger(N->
getOperand(0));
3796 SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(
SDNode *N) {
3799 assert(NOutVT.
isVector() &&
"This type must be promoted to a vector type");
3812 SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_VECTOR_ELT(
SDNode *N) {
3826 SDValue DAGTypeLegalizer::PromoteIntOp_EXTRACT_SUBVECTOR(
SDNode *N) {
3836 SDValue DAGTypeLegalizer::PromoteIntOp_CONCAT_VECTORS(
SDNode *N) {
3846 for (
unsigned VecIdx = 0; VecIdx != NumElems; ++VecIdx) {
3851 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...
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
static EVT getShiftAmountTyForConstant(unsigned Val, EVT VT, const TargetLowering &TLI, SelectionDAG &DAG)
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 ...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
BR_CC - Conditional branch.
This class represents lattice values for constants.
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.
void push_back(const T &Elt)
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...
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.
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.
RESULT = SMULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same wi...
const SDValue & getPassThru() const
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 class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
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...
const SDValue & getMask() const
UNDEF - An undefined node.
This class is used to represent ISD::STORE nodes.
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the specified, possibly variable...
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 bitsGE(EVT VT) const
Return true if this has no less bits than VT.
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.
SDValue expandAddSubSat(SDNode *Node, SelectionDAG &DAG) const
Method for building the DAG expansion of ISD::[US][ADD|SUB]SAT.
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
const SDValue & getValue() const
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.
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.
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...
SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type...
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
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 ...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
const SDValue & getMask() const
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.
const SDValue & getPassThru() const
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.
const SDValue & getBasePtr() const
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).
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
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...
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 ...
bool expandMUL_LOHI(unsigned Opcode, EVT VT, SDLoc dl, SDValue LHS, SDValue RHS, SmallVectorImpl< SDValue > &Result, EVT HiLoVT, SelectionDAG &DAG, MulExpansionKind Kind, SDValue LL=SDValue(), SDValue LH=SDValue(), SDValue RL=SDValue(), SDValue RH=SDValue()) const
Expand a MUL or [US]MUL_LOHI of n-bit values into two or four nodes, respectively, each computing an n/2-bit part of the result.
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)
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
const SDValue & getBasePtr() const
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.
PREFETCH - This corresponds to a prefetch intrinsic.
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.
KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
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.