90 void SelectionDAG::DAGNodeDeletedListener::anchor() {}
92 #define DEBUG_TYPE "selectiondag" 96 cl::desc(
"Gang up loads and stores generated by inlining of memcpy"));
99 cl::desc(
"Number limit for gluing ld/st of memcpy."),
115 return getValueAPF().bitwiseIsEqual(V);
141 unsigned SplatBitSize;
144 return BV->isConstantSplat(SplatVal, SplatUndef, SplatBitSize, HasUndefs,
146 EltSize == SplatBitSize;
166 if (i == e)
return false;
179 if (CN->getAPIntValue().countTrailingOnes() < EltSize)
182 if (CFPN->getValueAPF().bitcastToAPInt().countTrailingOnes() < EltSize)
190 for (++i; i != e; ++i)
203 bool IsAllUndef =
true;
218 if (CN->getAPIntValue().countTrailingZeros() < EltSize)
221 if (CFPN->getValueAPF().bitcastToAPInt().countTrailingZeros() < EltSize)
240 if (!isa<ConstantSDNode>(
Op))
253 if (!isa<ConstantFPSDNode>(
Op))
277 if (
auto *Cst = dyn_cast<ConstantSDNode>(Op))
293 if (!Cst || Cst->getValueType(0) != SVT || !
Match(Cst))
307 if (
auto *LHSCst = dyn_cast<ConstantSDNode>(LHS))
308 if (
auto *RHSCst = dyn_cast<ConstantSDNode>(RHS))
309 return Match(LHSCst, RHSCst);
320 bool LHSUndef = AllowUndefs && LHSOp.
isUndef();
321 bool RHSUndef = AllowUndefs && RHSOp.
isUndef();
324 if ((!LHSCst && !LHSUndef) || (!RHSCst && !RHSUndef))
329 if (!
Match(LHSCst, RHSCst))
353 unsigned OldL = (Operation >> 2) & 1;
354 unsigned OldG = (Operation >> 1) & 1;
398 unsigned Op = Op1 | Op2;
454 for (
auto& Op : Ops) {
463 for (
auto& Op : Ops) {
493 ID.
AddPointer(cast<ConstantFPSDNode>(N)->getConstantFPValue());
512 ID.
AddPointer(cast<RegisterMaskSDNode>(N)->getRegMask());
515 ID.
AddPointer(cast<SrcValueSDNode>(N)->getValue());
519 ID.
AddInteger(cast<FrameIndexSDNode>(N)->getIndex());
523 ID.
AddInteger(cast<JumpTableSDNode>(N)->getIndex());
524 ID.
AddInteger(cast<JumpTableSDNode>(N)->getTargetFlags());
633 ID.
AddInteger(cast<MemSDNode>(N)->getPointerInfo().getAddrSpace());
666 for (
unsigned i = 1, e = N->
getNumValues(); i != e; ++i)
684 if (Node.use_empty())
699 while (!DeadNodes.
empty()) {
708 DUL->NodeDeleted(N,
nullptr);
711 RemoveNodeFromCSEMaps(N);
742 RemoveNodeFromCSEMaps(N);
746 DeleteNodeNotInCSEMaps(N);
749 void SelectionDAG::DeleteNodeNotInCSEMaps(
SDNode *
N) {
751 "Cannot delete the entry node!");
762 if (I == DbgValMap.end())
764 for (
auto &Val: I->second)
765 Val->setIsInvalidated();
769 void SelectionDAG::DeallocateNode(
SDNode *N) {
773 NodeAllocator.Deallocate(AllNodes.remove(N));
797 "Wrong return type!");
800 "Mismatched operand types!");
802 "Wrong operand type!");
804 "Wrong return type size");
811 "Wrong number of operands!");
814 assert((
I->getValueType() == EltVT ||
815 (EltVT.isInteger() &&
I->getValueType().isInteger() &&
816 EltVT.bitsLE(
I->getValueType()))) &&
817 "Wrong operand type!");
819 "Operands must all have the same type");
831 void SelectionDAG::InsertNode(
SDNode *N) {
832 AllNodes.push_back(N);
843 bool SelectionDAG::RemoveNodeFromCSEMaps(
SDNode *N) {
848 assert(CondCodeNodes[cast<CondCodeSDNode>(N)->
get()] &&
849 "Cond code doesn't exist!");
850 Erased = CondCodeNodes[cast<CondCodeSDNode>(
N)->
get()] !=
nullptr;
851 CondCodeNodes[cast<CondCodeSDNode>(
N)->
get()] =
nullptr;
854 Erased = ExternalSymbols.erase(cast<ExternalSymbolSDNode>(N)->
getSymbol());
858 Erased = TargetExternalSymbols.erase(
859 std::pair<std::string,unsigned char>(ESN->
getSymbol(),
864 auto *MCSN = cast<MCSymbolSDNode>(
N);
865 Erased = MCSymbols.erase(MCSN->getMCSymbol());
869 EVT VT = cast<VTSDNode>(
N)->getVT();
871 Erased = ExtendedValueTypeNodes.erase(VT);
882 Erased = CSEMap.RemoveNode(N);
904 SelectionDAG::AddModifiedNodeToCSEMaps(
SDNode *N) {
908 SDNode *Existing = CSEMap.GetOrInsertNode(N);
917 DUL->NodeDeleted(N, Existing);
918 DeleteNodeNotInCSEMaps(N);
941 SDNode *Node = FindNodeOrInsertPos(ID,
SDLoc(N), InsertPos);
961 SDNode *Node = FindNodeOrInsertPos(ID,
SDLoc(N), InsertPos);
979 SDNode *Node = FindNodeOrInsertPos(ID,
SDLoc(N), InsertPos);
995 : TM(tm), OptLevel(OL),
998 InsertNode(&EntryNode);
1007 SDAGISelPass = PassPtr;
1011 LibInfo = LibraryInfo;
1017 assert(!UpdateListeners &&
"Dangling registered DAGUpdateListeners");
1019 OperandRecycler.clear(OperandAllocator);
1023 void SelectionDAG::allnodes_clear() {
1024 assert(&*AllNodes.begin() == &EntryNode);
1025 AllNodes.remove(AllNodes.begin());
1026 while (!AllNodes.empty())
1027 DeallocateNode(&AllNodes.front());
1029 NextPersistentId = 0;
1035 SDNode *N = CSEMap.FindNodeOrInsertPos(ID, InsertPos);
1042 "debug location. Use another overload.");
1049 const SDLoc &DL,
void *&InsertPos) {
1050 SDNode *N = CSEMap.FindNodeOrInsertPos(ID, InsertPos);
1075 OperandRecycler.clear(OperandAllocator);
1076 OperandAllocator.
Reset();
1079 ExtendedValueTypeNodes.clear();
1080 ExternalSymbols.clear();
1081 TargetExternalSymbols.clear();
1083 std::fill(CondCodeNodes.begin(), CondCodeNodes.end(),
1085 std::fill(ValueTypeNodes.begin(), ValueTypeNodes.end(),
1086 static_cast<SDNode*
>(
nullptr));
1088 EntryNode.UseList =
nullptr;
1089 InsertNode(&EntryNode);
1129 "getZeroExtendInReg should use the vector element type instead of " 1130 "the vector type!");
1168 bool isT,
bool isO) {
1171 (uint64_t)((int64_t)Val >> EltVT.
getSizeInBits()) + 1 < 2) &&
1172 "getConstant with a uint64_t value that doesn't fit in the type!");
1177 bool isT,
bool isO) {
1182 EVT VT,
bool isT,
bool isO) {
1210 unsigned ViaVecNumElts = VT.
getSizeInBits() / ViaEltSizeInBits;
1222 ViaEltVT, isT, isO));
1239 Ops.
insert(Ops.
end(), EltParts.begin(), EltParts.end());
1246 "APInt size does not match type size!");
1254 if ((N = FindNodeOrInsertPos(ID, DL, IP)))
1259 N = newSDNode<ConstantSDNode>(isT, isO, Elt, EltVT);
1260 CSEMap.InsertNode(N, IP);
1283 EVT VT,
bool isTarget) {
1297 if ((N = FindNodeOrInsertPos(ID, DL, IP)))
1302 N = newSDNode<ConstantFPSDNode>(isTarget, &V, EltVT);
1303 CSEMap.InsertNode(N, IP);
1333 EVT VT, int64_t
Offset,
bool isTargetGA,
1335 assert((TargetFlags == 0 || isTargetGA) &&
1336 "Cannot set target flags on target-independent globals");
1355 if (
SDNode *
E = FindNodeOrInsertPos(ID, DL, IP))
1358 auto *N = newSDNode<GlobalAddressSDNode>(
1360 CSEMap.InsertNode(N, IP);
1371 if (
SDNode *
E = FindNodeOrInsertPos(ID, IP))
1374 auto *N = newSDNode<FrameIndexSDNode>(FI, VT, isTarget);
1375 CSEMap.InsertNode(N, IP);
1382 assert((TargetFlags == 0 || isTarget) &&
1383 "Cannot set target flags on target-independent jump tables");
1390 if (
SDNode *
E = FindNodeOrInsertPos(ID, IP))
1393 auto *N = newSDNode<JumpTableSDNode>(JTI, VT, isTarget,
TargetFlags);
1394 CSEMap.InsertNode(N, IP);
1400 unsigned Alignment,
int Offset,
1403 assert((TargetFlags == 0 || isTarget) &&
1404 "Cannot set target flags on target-independent globals");
1417 if (
SDNode *
E = FindNodeOrInsertPos(ID, IP))
1420 auto *N = newSDNode<ConstantPoolSDNode>(isTarget,
C, VT,
Offset, Alignment,
1422 CSEMap.InsertNode(N, IP);
1428 unsigned Alignment,
int Offset,
1431 assert((TargetFlags == 0 || isTarget) &&
1432 "Cannot set target flags on target-independent globals");
1443 if (
SDNode *
E = FindNodeOrInsertPos(ID, IP))
1446 auto *N = newSDNode<ConstantPoolSDNode>(isTarget,
C, VT,
Offset, Alignment,
1448 CSEMap.InsertNode(N, IP);
1461 if (
SDNode *
E = FindNodeOrInsertPos(ID, IP))
1465 CSEMap.InsertNode(N, IP);
1475 if (
SDNode *
E = FindNodeOrInsertPos(ID, IP))
1478 auto *N = newSDNode<BasicBlockSDNode>(MBB);
1479 CSEMap.InsertNode(N, IP);
1486 ValueTypeNodes.size())
1493 N = newSDNode<VTSDNode>(VT);
1499 SDNode *&N = ExternalSymbols[Sym];
1501 N = newSDNode<ExternalSymbolSDNode>(
false, Sym, 0, VT);
1507 SDNode *&N = MCSymbols[Sym];
1510 N = newSDNode<MCSymbolSDNode>(Sym, VT);
1518 TargetExternalSymbols[std::pair<std::string,unsigned char>(Sym,
1521 N = newSDNode<ExternalSymbolSDNode>(
true, Sym,
TargetFlags, VT);
1527 if ((
unsigned)Cond >= CondCodeNodes.size())
1528 CondCodeNodes.resize(Cond+1);
1530 if (!CondCodeNodes[Cond]) {
1531 auto *N = newSDNode<CondCodeSDNode>(Cond);
1532 CondCodeNodes[Cond] =
N;
1536 return SDValue(CondCodeNodes[Cond], 0);
1549 "Must have the same number of vector elements as mask elements!");
1551 "Invalid VECTOR_SHUFFLE");
1559 int NElts = Mask.
size();
1561 [&](
int M) {
return M < (NElts * 2) && M >= -1; }) &&
1562 "Index out of range");
1570 for (
int i = 0; i != NElts; ++i)
1571 if (MaskVec[i] >= NElts) MaskVec[i] -= NElts;
1587 for (
int i = 0; i < NElts; ++i) {
1588 if (MaskVec[i] <
Offset || MaskVec[i] >= (
Offset + NElts))
1592 if (UndefElements[MaskVec[i] -
Offset]) {
1598 if (!UndefElements[i])
1602 if (
auto *N1BV = dyn_cast<BuildVectorSDNode>(N1))
1603 BlendSplat(N1BV, 0);
1604 if (
auto *N2BV = dyn_cast<BuildVectorSDNode>(N2))
1605 BlendSplat(N2BV, NElts);
1610 bool AllLHS =
true, AllRHS =
true;
1612 for (
int i = 0; i != NElts; ++i) {
1613 if (MaskVec[i] >= NElts) {
1618 }
else if (MaskVec[i] >= 0) {
1622 if (AllLHS && AllRHS)
1624 if (AllLHS && !N2Undef)
1637 bool Identity =
true, AllSame =
true;
1638 for (
int i = 0; i != NElts; ++i) {
1639 if (MaskVec[i] >= 0 && MaskVec[i] != i) Identity =
false;
1640 if (MaskVec[i] != MaskVec[0]) AllSame =
false;
1642 if (Identity && NElts)
1655 if (
auto *BV = dyn_cast<BuildVectorSDNode>(V)) {
1657 SDValue Splat = BV->getSplatValue(&UndefElements);
1667 if (Splat && UndefElements.
none()) {
1672 if (
auto *
C = dyn_cast<ConstantSDNode>(Splat))
1673 if (
C->isNullValue())
1678 if (AllSame && SameNumElts) {
1679 EVT BuildVT = BV->getValueType(0);
1695 for (
int i = 0; i != NElts; ++i)
1699 if (
SDNode *
E = FindNodeOrInsertPos(ID, dl, IP))
1705 int *MaskAlloc = OperandAllocator.
Allocate<
int>(NElts);
1708 auto *N = newSDNode<ShuffleVectorSDNode>(VT, dl.
getIROrder(),
1710 createOperands(N, Ops);
1712 CSEMap.InsertNode(N, IP);
1734 if (
SDNode *
E = FindNodeOrInsertPos(ID, IP))
1737 auto *N = newSDNode<RegisterSDNode>(RegNo, VT);
1739 CSEMap.InsertNode(N, IP);
1749 if (
SDNode *
E = FindNodeOrInsertPos(ID, IP))
1752 auto *N = newSDNode<RegisterMaskSDNode>(RegMask);
1753 CSEMap.InsertNode(N, IP);
1770 if (
SDNode *
E = FindNodeOrInsertPos(ID, IP))
1774 createOperands(N, Ops);
1776 CSEMap.InsertNode(N, IP);
1793 if (
SDNode *
E = FindNodeOrInsertPos(ID, IP))
1797 CSEMap.InsertNode(N, IP);
1804 "SrcValue is not a pointer?");
1811 if (
SDNode *
E = FindNodeOrInsertPos(ID, IP))
1814 auto *N = newSDNode<SrcValueSDNode>(V);
1815 CSEMap.InsertNode(N, IP);
1826 if (
SDNode *
E = FindNodeOrInsertPos(ID, IP))
1829 auto *N = newSDNode<MDNodeSDNode>(MD);
1830 CSEMap.InsertNode(N, IP);
1843 unsigned SrcAS,
unsigned DestAS) {
1851 if (
SDNode *
E = FindNodeOrInsertPos(ID, dl, IP))
1856 createOperands(N, Ops);
1858 CSEMap.InsertNode(N, IP);
1868 if (OpTy == ShTy || OpTy.
isVector())
return Op;
1876 const Value *V = cast<SrcValueSDNode>(Node->
getOperand(2))->getValue();
1887 assert(((Align & (Align-1)) == 0) &&
"Expected Align to be a power of 2");
1890 getConstant(Align - 1, dl, VAList.getValueType()));
1893 getConstant(-(int64_t)Align, dl, VAList.getValueType()));
1900 dl, VAList.getValueType()));
1913 const Value *VD = cast<SrcValueSDNode>(Node->
getOperand(3))->getValue();
1926 unsigned StackAlign =
1973 const APInt &C2 = N2C->getAPIntValue();
1975 const APInt &C1 = N1C->getAPIntValue();
2056 return getSetCC(dl, VT, N2, N1, SwappedCond);
2072 assert(CV &&
"Const value should be ConstSDNode.");
2093 unsigned Amt = RHSC->getZExtValue();
2098 APInt NewMask = Mask << Amt;
2147 unsigned Depth)
const {
2168 for (
unsigned i = 0; i != NumElts; ++i) {
2171 UndefElts.setBit(i);
2174 if (!DemandedElts[i])
2176 if (Scl && Scl != Op)
2185 int SplatIndex = -1;
2187 for (
int i = 0; i != (int)NumElts; ++i) {
2190 UndefElts.setBit(i);
2193 if (!DemandedElts[i])
2195 if (0 <= SplatIndex && SplatIndex != M)
2211 UndefElts = UndefSrcElts.
extractBits(NumElts, Idx);
2220 APInt UndefLHS, UndefRHS;
2225 UndefElts = UndefLHS | UndefRHS;
2244 (AllowUndefs || !UndefElts);
2250 const APInt &DemandedElts) {
2259 for (
unsigned i = 0; i != NumElts; ++i) {
2260 if (!DemandedElts[i])
2276 const APInt &ShAmt = SA->getAPIntValue();
2298 unsigned Depth)
const {
2303 if (
auto *
C = dyn_cast<ConstantSDNode>(Op)) {
2305 Known.
One =
C->getAPIntValue();
2309 if (
auto *
C = dyn_cast<ConstantFPSDNode>(Op)) {
2311 Known.
One =
C->getValueAPF().bitcastToAPInt();
2323 "Unexpected vector size");
2334 if (!DemandedElts[i])
2343 "Expected BUILD_VECTOR implicit truncation");
2344 Known2 = Known2.
trunc(BitWidth);
2359 APInt DemandedLHS(NumElts, 0), DemandedRHS(NumElts, 0);
2362 assert(NumElts == SVN->
getMask().size() &&
"Unexpected vector size");
2363 for (
unsigned i = 0; i != NumElts; ++i) {
2364 if (!DemandedElts[i])
2372 DemandedLHS.clearAllBits();
2377 if ((
unsigned)M < NumElts)
2378 DemandedLHS.setBit((
unsigned)M % NumElts);
2380 DemandedRHS.
setBit((
unsigned)M % NumElts);
2383 if (!!DemandedLHS) {
2392 if (!!DemandedRHS) {
2406 for (
unsigned i = 0; i != NumSubVectors; ++i) {
2407 APInt DemandedSub = DemandedElts.
lshr(i * NumSubVectorElts);
2408 DemandedSub = DemandedSub.
trunc(NumSubVectorElts);
2409 if (!!DemandedSub) {
2433 if (!!DemandedSubElts) {
2439 APInt DemandedSrcElts = DemandedElts & ~SubMask;
2440 if (!!DemandedSrcElts) {
2474 if (DemandedElts != 1)
2480 Known = Known.
trunc(BitWidth);
2494 if (BitWidth == SubBitWidth) {
2502 if ((BitWidth % SubBitWidth) == 0) {
2509 unsigned SubScale = BitWidth / SubBitWidth;
2510 APInt SubDemandedElts(NumElts * SubScale, 0);
2511 for (
unsigned i = 0; i != NumElts; ++i)
2512 if (DemandedElts[i])
2513 SubDemandedElts.
setBit(i * SubScale);
2515 for (
unsigned i = 0; i != SubScale; ++i) {
2518 unsigned Shifts = IsLE ? i : SubScale - 1 - i;
2519 Known.
One |= Known2.
One.
zext(BitWidth).
shl(SubBitWidth * Shifts);
2525 if ((SubBitWidth % BitWidth) == 0) {
2531 unsigned SubScale = SubBitWidth / BitWidth;
2532 APInt SubDemandedElts(NumElts / SubScale, 0);
2533 for (
unsigned i = 0; i != NumElts; ++i)
2534 if (DemandedElts[i])
2535 SubDemandedElts.
setBit(i / SubScale);
2540 for (
unsigned i = 0; i != NumElts; ++i)
2541 if (DemandedElts[i]) {
2542 unsigned Shifts = IsLE ? i : NumElts - 1 - i;
2543 unsigned Offset = (Shifts % SubScale) * BitWidth;
2559 Known.
One &= Known2.One;
2561 Known.
Zero |= Known2.Zero;
2568 Known.
Zero &= Known2.Zero;
2570 Known.
One |= Known2.One;
2577 APInt KnownZeroOut = (Known.
Zero & Known2.Zero) | (Known.
One & Known2.One);
2579 Known.
One = (Known.
Zero & Known2.One) | (Known.
One & Known2.Zero);
2580 Known.
Zero = KnownZeroOut;
2592 Known2.countMinTrailingZeros();
2594 Known2.countMinLeadingZeros(),
2595 BitWidth) - BitWidth;
2611 if (RHSMaxLeadingZeros != BitWidth)
2612 LeadZ = std::min(BitWidth, LeadZ + BitWidth - RHSMaxLeadingZeros - 1);
2626 Known.
One &= Known2.One;
2627 Known.
Zero &= Known2.Zero;
2637 Known.
One &= Known2.One;
2638 Known.
Zero &= Known2.Zero;
2664 unsigned Shift = ShAmt->getZExtValue();
2665 Known.
Zero <<= Shift;
2666 Known.
One <<= Shift;
2674 unsigned Shift = ShAmt->getZExtValue();
2679 }
else if (
auto *BV = dyn_cast<BuildVectorSDNode>(Op.
getOperand(1))) {
2682 unsigned ShiftAmountMin = BitWidth;
2683 for (
unsigned i = 0; i != BV->getNumOperands(); ++i) {
2684 if (
auto *
C = dyn_cast<ConstantSDNode>(BV->getOperand(i))) {
2685 const APInt &ShAmt =
C->getAPIntValue();
2686 if (ShAmt.
ult(BitWidth)) {
2687 ShiftAmountMin = std::min<unsigned>(ShiftAmountMin,
2703 unsigned Shift = ShAmt->getZExtValue();
2713 unsigned Amt =
C->getAPIntValue().urem(BitWidth);
2719 DemandedElts, Depth + 1);
2730 Known2.One.lshrInPlace(BitWidth - Amt);
2731 Known2.Zero.lshrInPlace(BitWidth - Amt);
2733 Known.
One <<= BitWidth - Amt;
2734 Known.
Zero <<= BitWidth - Amt;
2735 Known2.One.lshrInPlace(Amt);
2736 Known2.Zero.lshrInPlace(Amt);
2738 Known.
One |= Known2.One;
2739 Known.
Zero |= Known2.Zero;
2755 InSignMask = InSignMask.
zext(BitWidth);
2757 InputDemandedBits |= InSignMask;
2760 Known.
One &= InputDemandedBits;
2761 Known.
Zero &= InputDemandedBits;
2766 Known.
Zero |= NewBits;
2767 Known.
One &= ~NewBits;
2769 Known.
One |= NewBits;
2770 Known.
Zero &= ~NewBits;
2772 Known.
Zero &= ~NewBits;
2773 Known.
One &= ~NewBits;
2782 unsigned LowBits =
Log2_32(PossibleTZ) + 1;
2791 unsigned LowBits =
Log2_32(PossibleLZ) + 1;
2819 Known = Known.
zext(BitWidth);
2826 Known = Known.
zext(BitWidth);
2836 Known = Known.
sext(BitWidth);
2843 Known = Known.
sext(BitWidth);
2848 Known = Known.
zext(BitWidth);
2853 Known = Known.
trunc(BitWidth);
2860 Known.
Zero |= (~InMask);
2861 Known.One &= (~Known.Zero);
2885 if (CLHS->getAPIntValue().isNonNegative()) {
2895 if ((Known2.Zero & MaskV) == MaskV) {
2896 unsigned NLZ2 = CLHS->getAPIntValue().countLeadingZeros();
2908 if (KnownZeroLow == 0)
2912 KnownZeroLow = std::min(KnownZeroLow, Known2.countMinTrailingZeros());
2940 unsigned KnownZeroLow = Known2.countMinTrailingZeros();
2943 KnownZeroHigh = std::min(KnownZeroHigh, Known2.countMinLeadingZeros());
2944 KnownZeroLow = std::min(KnownZeroLow, Known2.countMinTrailingZeros());
2951 if (KnownZeroLow >= 2)
2957 if (KnownZeroHigh > 1)
2963 const APInt &
RA = Rem->getAPIntValue().abs();
2965 APInt LowBits = RA - 1;
2969 Known.
Zero = Known2.Zero & LowBits;
2970 Known.
One = Known2.One & LowBits;
2974 if (Known2.Zero[BitWidth-1] || ((Known2.Zero & LowBits) == LowBits))
2975 Known.
Zero |= ~LowBits;
2979 if (Known2.One[BitWidth-1] && ((Known2.One & LowBits) != 0))
2980 Known.
One |= ~LowBits;
2981 assert((Known.
Zero & Known.
One) == 0&&
"Bits known to be one AND zero?");
2987 const APInt &
RA = Rem->getAPIntValue();
2989 APInt LowBits = (RA - 1);
2993 Known.
Zero = Known2.Zero | ~LowBits;
2994 Known.
One = Known2.One & LowBits;
3020 Known = Known.
trunc(BitWidth);
3032 if (BitWidth > EltBitWidth)
3033 Known = Known.
trunc(EltBitWidth);
3044 if (BitWidth > EltBitWidth)
3045 Known = Known.
zext(BitWidth);
3061 if (DemandedElts[EltIdx]) {
3072 Known.
One &= Known2.One;
3073 Known.
Zero &= Known2.Zero;
3100 if (Known2.isNonNegative()) {
3101 Known.
Zero = Known2.Zero;
3102 Known.
One = Known2.One;
3109 if (Known2.One.getBoolValue()) {
3122 LeadZero =
std::max(LeadZero, Known2.countMinLeadingZeros());
3124 Known.
Zero &= Known2.Zero;
3125 Known.
One &= Known2.One;
3136 LeadOne =
std::max(LeadOne, Known2.countMinLeadingOnes());
3138 Known.
Zero &= Known2.Zero;
3139 Known.
One &= Known2.One;
3153 if (CstLow && CstHigh) {
3158 const APInt &ValueHigh = CstHigh->getAPIntValue();
3159 if (ValueLow.
sle(ValueHigh)) {
3162 unsigned MinSignBits = std::min(LowSignBits, HighSignBits);
3178 Known.
Zero &= Known2.Zero;
3179 Known.
One &= Known2.One;
3214 (void)(~N0Known.
Zero).uadd_ov(~N1Known.
Zero, overflow);
3221 (~N1Known.
Zero & 0x01) == ~N1Known.
Zero)
3227 if ((~N0Known.
Zero & 0x01) == ~N0Known.
Zero)
3240 return Const->getAPIntValue().zextOrTrunc(BitWidth).isPowerOf2();
3246 if (
C &&
C->getAPIntValue() == 1)
3254 if (
C &&
C->getAPIntValue().isSignMask())
3262 return C->getAPIntValue().zextOrTrunc(BitWidth).isPowerOf2();
3284 unsigned Depth)
const {
3290 unsigned FirstAnswer = 1;
3292 if (
auto *
C = dyn_cast<ConstantSDNode>(Op)) {
3293 const APInt &Val =
C->getAPIntValue();
3307 Tmp = cast<VTSDNode>(Op.
getOperand(1))->getVT().getSizeInBits();
3308 return VTBits-Tmp+1;
3310 Tmp = cast<VTSDNode>(Op.
getOperand(1))->getVT().getSizeInBits();
3315 for (
unsigned i = 0, e = Op.
getNumOperands(); (i < e) && (Tmp > 1); ++i) {
3316 if (!DemandedElts[i])
3325 "Expected BUILD_VECTOR implicit truncation");
3327 Tmp2 = (Tmp2 > ExtraBits ? Tmp2 - ExtraBits : 1);
3329 Tmp = std::min(Tmp, Tmp2);
3336 APInt DemandedLHS(NumElts, 0), DemandedRHS(NumElts, 0);
3338 assert(NumElts == SVN->
getMask().size() &&
"Unexpected vector size");
3339 for (
unsigned i = 0; i != NumElts; ++i) {
3341 if (!DemandedElts[i])
3347 if ((
unsigned)M < NumElts)
3348 DemandedLHS.setBit((
unsigned)M % NumElts);
3350 DemandedRHS.
setBit((
unsigned)M % NumElts);
3355 if (!!DemandedRHS) {
3357 Tmp = std::min(Tmp, Tmp2);
3362 assert(Tmp <= VTBits &&
"Failed to determine minimum sign bits");
3376 if (VTBits == SrcBits)
3382 if ((SrcBits % VTBits) == 0) {
3385 unsigned Scale = SrcBits / VTBits;
3386 APInt SrcDemandedElts(NumElts / Scale, 0);
3387 for (
unsigned i = 0; i != NumElts; ++i)
3388 if (DemandedElts[i])
3389 SrcDemandedElts.
setBit(i / Scale);
3398 for (
unsigned i = 0; i != NumElts; ++i)
3399 if (DemandedElts[i]) {
3400 unsigned SubOffset = i % Scale;
3401 SubOffset = (IsLE ? ((Scale - 1) - SubOffset) : SubOffset);
3402 SubOffset = SubOffset * VTBits;
3403 if (Tmp <= SubOffset)
3405 Tmp2 = std::min(Tmp2, Tmp - SubOffset);
3417 Tmp = cast<VTSDNode>(Op.
getOperand(1))->getVT().getScalarSizeInBits();
3434 APInt ShiftVal =
C->getAPIntValue();
3444 if (
C->getAPIntValue().uge(VTBits) ||
3445 C->getAPIntValue().uge(Tmp))
break;
3446 return Tmp -
C->getZExtValue();
3456 FirstAnswer = std::min(Tmp, Tmp2);
3466 if (Tmp == 1)
return 1;
3468 return std::min(Tmp, Tmp2);
3471 if (Tmp == 1)
return 1;
3473 return std::min(Tmp, Tmp2);
3485 if (CstLow && CstHigh) {
3490 Tmp2 = CstHigh->getAPIntValue().getNumSignBits();
3491 return std::min(Tmp, Tmp2);
3500 return std::min(Tmp, Tmp2);
3508 return std::min(Tmp, Tmp2);
3534 unsigned RotAmt =
C->getAPIntValue().urem(VTBits);
3538 RotAmt = (VTBits - RotAmt) % VTBits;
3543 if (Tmp > (RotAmt + 1))
return (Tmp - RotAmt);
3551 if (Tmp == 1)
return 1;
3555 if (CRHS->isAllOnesValue()) {
3560 if ((Known.
Zero | 1).isAllOnesValue())
3570 if (Tmp2 == 1)
return 1;
3571 return std::min(Tmp, Tmp2)-1;
3575 if (Tmp2 == 1)
return 1;
3579 if (CLHS->isNullValue()) {
3583 if ((Known.
Zero | 1).isAllOnesValue())
3597 if (Tmp == 1)
return 1;
3598 return std::min(Tmp, Tmp2)-1;
3603 if (NumSrcSignBits > (NumSrcBits - VTBits))
3604 return NumSrcSignBits - (NumSrcBits - VTBits);
3618 return std::max(std::min(KnownSign - rIndex * BitWidth, BitWidth), 0);
3634 if (DemandedElts[EltIdx]) {
3643 APInt VectorElts = DemandedElts;
3647 Tmp = std::min(Tmp, Tmp2);
3653 Tmp = std::min(Tmp, Tmp2);
3655 assert(Tmp <= VTBits &&
"Failed to determine minimum sign bits");
3669 if (BitWidth != EltBitWidth)
3703 for (
unsigned i = 0; (i < NumSubVectors) && (Tmp > 1); ++i) {
3704 APInt DemandedSub = DemandedElts.
lshr(i * NumSubVectorElts);
3705 DemandedSub = DemandedSub.
trunc(NumSubVectorElts);
3709 Tmp = std::min(Tmp, Tmp2);
3711 assert(Tmp <= VTBits &&
"Failed to determine minimum sign bits");
3721 if (SubIdx && SubIdx->getAPIntValue().ule(NumElts - NumSubElts)) {
3723 uint64_t Idx = SubIdx->getZExtValue();
3725 if (!!DemandedSubElts) {
3727 if (Tmp == 1)
return 1;
3730 APInt DemandedSrcElts = DemandedElts & ~SubMask;
3731 if (!!DemandedSrcElts) {
3733 Tmp = std::min(Tmp, Tmp2);
3735 assert(Tmp <= VTBits &&
"Failed to determine minimum sign bits");
3741 if (Tmp == 1)
return 1;
3743 Tmp = std::min(Tmp, Tmp2);
3744 assert(Tmp <= VTBits &&
"Failed to determine minimum sign bits");
3753 unsigned ExtType =
LD->getExtensionType();
3757 Tmp =
LD->getMemoryVT().getScalarSizeInBits();
3758 return VTBits-Tmp+1;
3760 Tmp =
LD->getMemoryVT().getScalarSizeInBits();
3774 FirstAnswer =
std::max(FirstAnswer, NumBits);
3807 cast<ConstantSDNode>(Op.
getOperand(1))->getAPIntValue()))
3824 return !
C->getValueAPF().isNaN() ||
3825 (SNaN && !
C->getValueAPF().isSignaling());
3932 "Floating point type expected");
3937 return !
C->isZero();
3943 "Floating point types unsupported - use isKnownNeverZeroFloat");
3965 if (A == B)
return true;
3970 if (CA->isZero() && CB->isZero())
return true;
3980 "Values must have the same type");
3987 int NumOps = Ops.
size();
3988 assert(NumOps != 0 &&
"Can't build an empty vector!");
3990 "Incorrect element count in BUILD_VECTOR!");
3998 bool IsIdentity =
true;
3999 for (
int i = 0; i != NumOps; ++i) {
4002 (IdentitySrc && Ops[i].getOperand(0) != IdentitySrc) ||
4003 !isa<ConstantSDNode>(Ops[i].getOperand(1)) ||
4004 cast<ConstantSDNode>(Ops[i].getOperand(1))->getAPIntValue() != i) {
4008 IdentitySrc = Ops[i].getOperand(0);
4019 assert(!Ops.
empty() &&
"Can't concatenate an empty list of vectors!");
4024 "Concatenation of vectors with inconsistent value types!");
4025 assert((Ops.
size() * Ops[0].getValueType().getVectorNumElements()) ==
4027 "Incorrect element count in vector concatenation!");
4029 if (Ops.
size() == 1)
4072 if (
SDNode *
E = FindNodeOrInsertPos(ID, DL, IP))
4077 CSEMap.InsertNode(N, IP);
4093 const APInt &Val =
C->getAPIntValue();
4098 C->isTargetOpcode(),
C->isOpaque());
4106 C->isTargetOpcode(),
C->isOpaque());
4228 if (BV->isConstant()) {
4285 "Vector element count mismatch!");
4287 "Invalid fpext node, dst < src!");
4293 "Invalid SIGN_EXTEND!");
4298 "Vector element count mismatch!");
4300 "Invalid sext node, dst < src!");
4309 "Invalid ZERO_EXTEND!");
4314 "Vector element count mismatch!");
4316 "Invalid zext node, dst < src!");
4325 "Invalid ANY_EXTEND!");
4330 "Vector element count mismatch!");
4332 "Invalid anyext node, dst < src!");
4352 "Invalid TRUNCATE!");
4357 "Vector element count mismatch!");
4359 "Invalid truncate node, src < dst!");
4378 assert(VT.
isVector() &&
"This DAG node is restricted to vector types.");
4380 "The input must be the same size or smaller than the result.");
4383 "The destination vector type must have fewer lanes than the input.");
4395 "BSWAP types must be a multiple of 16 bits!");
4401 "Invalid BITREVERSE!");
4408 "Cannot BITCAST between types of different sizes!");
4421 "Illegal SCALAR_TO_VECTOR node!");
4426 isa<ConstantSDNode>(Operand.
getOperand(1)) &&
4453 if (
SDNode *
E = FindNodeOrInsertPos(ID, DL, IP)) {
4454 E->intersectFlagsWith(Flags);
4460 createOperands(N, Ops);
4461 CSEMap.InsertNode(N, IP);
4464 createOperands(N, Ops);
4476 case ISD::ADD:
return std::make_pair(C1 + C2,
true);
4477 case ISD::SUB:
return std::make_pair(C1 - C2,
true);
4478 case ISD::MUL:
return std::make_pair(C1 * C2,
true);
4479 case ISD::AND:
return std::make_pair(C1 & C2,
true);
4480 case ISD::OR:
return std::make_pair(C1 | C2,
true);
4481 case ISD::XOR:
return std::make_pair(C1 ^ C2,
true);
4482 case ISD::SHL:
return std::make_pair(C1 << C2,
true);
4483 case ISD::SRL:
return std::make_pair(C1.
lshr(C2),
true);
4484 case ISD::SRA:
return std::make_pair(C1.
ashr(C2),
true);
4487 case ISD::SMIN:
return std::make_pair(C1.
sle(C2) ? C1 : C2,
true);
4488 case ISD::SMAX:
return std::make_pair(C1.
sge(C2) ? C1 : C2,
true);
4489 case ISD::UMIN:
return std::make_pair(C1.
ule(C2) ? C1 : C2,
true);
4490 case ISD::UMAX:
return std::make_pair(C1.
uge(C2) ? C1 : C2,
true);
4496 if (!C2.getBoolValue())
4498 return std::make_pair(C1.
udiv(C2),
true);
4500 if (!C2.getBoolValue())
4502 return std::make_pair(C1.
urem(C2),
true);
4504 if (!C2.getBoolValue())
4506 return std::make_pair(C1.
sdiv(C2),
true);
4508 if (!C2.getBoolValue())
4510 return std::make_pair(C1.
srem(C2),
true);
4512 return std::make_pair(
APInt(1, 0),
false);
4541 case ISD::SUB: Offset = -uint64_t(Offset);
break;
4556 assert(Ops.
size() == 2 &&
"Div/rem should have 2 operands");
4563 [](
SDValue V) {
return V.isUndef() ||
4586 if (
const ConstantSDNode *Scalar1 = dyn_cast<ConstantSDNode>(Cst1)) {
4587 if (
const ConstantSDNode *Scalar2 = dyn_cast<ConstantSDNode>(Cst2)) {
4590 "Can't fold vectors ops with scalar operands");
4614 assert((!BV1 || !BV2 || BV1->getNumOperands() == BV2->getNumOperands()) &&
4615 "Vector binop with different number of elements in operands?");
4621 if (LegalSVT.
bitsLT(SVT))
4625 unsigned NumOps = BV1 ? BV1->getNumOperands() : BV2->getNumOperands();
4626 for (
unsigned I = 0;
I != NumOps; ++
I) {
4641 if (LegalSVT != SVT)
4652 "Vector size mismatch!");
4681 auto IsScalarOrSameVectorSize = [&](
const SDValue &
Op) {
4686 auto IsConstantBuildVectorOrUndef = [&](
const SDValue &
Op) {
4695 if (!
llvm::all_of(Ops, IsConstantBuildVectorOrUndef) ||
4714 for (
unsigned i = 0; i != NumElts; i++) {
4740 SDValue ScalarResult =
getNode(Opcode, DL, SVT, ScalarOps, Flags);
4743 if (LegalSVT != SVT)
4770 }
else if (N1CFP && !N2CFP) {
4784 if (N1 == N2)
return N1;
4801 assert(VT.
isInteger() &&
"This operator does not apply to FP types!");
4803 N1.
getValueType() == VT &&
"Binary operator types must match!");
4806 if (N2C && N2C->isNullValue())
4808 if (N2C && N2C->isAllOnesValue())
4815 assert(VT.
isInteger() &&
"This operator does not apply to FP types!");
4817 N1.
getValueType() == VT &&
"Binary operator types must match!");
4820 if (N2C && N2C->isNullValue())
4838 assert(VT.
isInteger() &&
"This operator does not apply to FP types!");
4840 N1.
getValueType() == VT &&
"Binary operator types must match!");
4849 N1.
getValueType() == VT &&
"Binary operator types must match!");
4855 "Invalid FCOPYSIGN!");
4866 "Shift operators return type must be the same as their first arg");
4868 "Shifts only work on integers");
4870 "Vector shift amounts must be in the same as their first arg");
4876 "Invalid use of small shift amount with oversized value!");
4883 if (N2C && N2C->isNullValue())
4887 EVT EVT = cast<VTSDNode>(N2)->getVT();
4890 "Cannot FP_ROUND_INREG integer types");
4892 "FP_ROUND_INREG type should be vector iff the operand " 4896 "Vector element counts must match in FP_ROUND_INREG");
4899 if (cast<VTSDNode>(N2)->getVT() == VT)
return N1;
4906 N2C && (N2C->getZExtValue() == 0 || N2C->getZExtValue() == 1) &&
4907 "Invalid FP_ROUND!");
4912 EVT EVT = cast<VTSDNode>(N2)->getVT();
4915 "Cannot *_EXTEND_INREG FP types");
4917 "AssertSExt/AssertZExt type should be the vector element type " 4918 "rather than the vector type!");
4924 EVT EVT = cast<VTSDNode>(N2)->getVT();
4927 "Cannot *_EXTEND_INREG FP types");
4929 "SIGN_EXTEND_INREG type should be vector iff the operand " 4933 "Vector element counts must match in SIGN_EXTEND_INREG");
4935 if (EVT == VT)
return N1;
4946 return SignExtendInReg(Val, VT);
4959 Ops.
push_back(SignExtendInReg(Val, OpVT));
4967 "The result of EXTRACT_VECTOR_ELT must be at least as wide as the \ 4968 element type of the vector.");
5014 if (N1Op2C && N2C) {
5036 assert(N2C && (
unsigned)N2C->getZExtValue() < 2 &&
"Bad EXTRACT_ELEMENT!");
5040 "Wrong types for EXTRACT_ELEMENT!");
5051 unsigned Shift = ElementSize * N2C->getZExtValue();
5059 "Extract subvector VTs must be a vectors!");
5062 "Extract subvector VTs must have the same element type!");
5064 "Extract subvector must be from larger vector to smaller vector!");
5069 &&
"Extract subvector overflow!");
5086 return N1.
getOperand(N2C->getZExtValue() / Factor);
5107 APFloat V1 = N1CFP->getValueAPF(),
V2 = N2CFP->getValueAPF();
5147 APFloat V = N1CFP->getValueAPF();
5228 if (
SDNode *
E = FindNodeOrInsertPos(ID, DL, IP)) {
5229 E->intersectFlagsWith(Flags);
5235 createOperands(N, Ops);
5236 CSEMap.InsertNode(N, IP);
5239 createOperands(N, Ops);
5260 if (N1CFP && N2CFP && N3CFP) {
5261 APFloat V1 = N1CFP->getValueAPF();
5262 const APFloat &
V2 = N2CFP->getValueAPF();
5263 const APFloat &V3 = N3CFP->getValueAPF();
5288 "SETCC operands must have the same type!");
5290 "SETCC type should be vector iff the operand type is vector!");
5293 "SETCC vector element counts must match!");
5295 if (
SDValue V =
FoldSetCC(VT, N1, N2, cast<CondCodeSDNode>(N3)->
get(), DL))
5325 "Insert subvector VTs must be a vectors");
5327 "Dest and insert subvector source types must match!");
5329 "Insert subvector must be from smaller vector to larger vector!");
5330 if (isa<ConstantSDNode>(Index)) {
5332 cast<ConstantSDNode>(
Index)->getZExtValue()
5334 &&
"Insert subvector overflow!");
5358 if (
SDNode *
E = FindNodeOrInsertPos(ID, DL, IP)) {
5359 E->intersectFlagsWith(Flags);
5365 createOperands(N, Ops);
5366 CSEMap.InsertNode(N, IP);
5369 createOperands(N, Ops);
5380 SDValue Ops[] = { N1, N2, N3, N4 };
5381 return getNode(Opcode, DL, VT, Ops);
5387 SDValue Ops[] = { N1, N2, N3, N4, N5 };
5388 return getNode(Opcode, DL, VT, Ops);
5404 if (
LoadSDNode *L = dyn_cast<LoadSDNode>(*U))
5406 if (FI->getIndex() < 0)
5421 assert(
C->getAPIntValue().getBitWidth() == 8);
5426 return DAG.
getConstant(Val, dl, VT,
false, IsOpaque);
5434 if (!IntVT.isInteger())
5461 if (Slice.
Array ==
nullptr) {
5479 unsigned NumVTBytes = NumVTBits / 8;
5480 unsigned NumBytes = std::min(NumVTBytes,
unsigned(Slice.
Length));
5482 APInt Val(NumVTBits, 0);
5484 for (
unsigned i = 0; i != NumBytes; ++i)
5485 Val |= (uint64_t)(
unsigned char)Slice[i] << i*8;
5487 for (
unsigned i = 0; i != NumBytes; ++i)
5488 Val |= (uint64_t)(
unsigned char)Slice[i] << (NumVTBytes-i-1)*8;
5507 uint64_t SrcDelta = 0;
5510 G = cast<GlobalAddressSDNode>(Src);
5514 G = cast<GlobalAddressSDNode>(Src.
getOperand(0));
5515 SrcDelta = cast<ConstantSDNode>(Src.
getOperand(1))->getZExtValue();
5529 unsigned Limit, uint64_t
Size,
5530 unsigned DstAlign,
unsigned SrcAlign,
5535 unsigned DstAS,
unsigned SrcAS,
5538 assert((SrcAlign == 0 || SrcAlign >= DstAlign) &&
5539 "Expecting memcpy / memset source to meet alignment requirement!");
5548 IsMemset, ZeroMemset, MemcpyStrSrc,
5573 unsigned NumMemOps = 0;
5576 while (VTSize > Size) {
5608 if (NumMemOps && AllowOverlap && NewVTSize < Size &&
5618 if (++NumMemOps > Limit)
5621 MemOps.push_back(VT);
5640 assert(OutLoadChains.
size() &&
"Missing loads in memcpy inlining");
5641 assert(OutStoreChains.
size() &&
"Missing stores in memcpy inlining");
5643 for (
unsigned i = From; i < To; ++i) {
5645 GluedLoadChains.push_back(OutLoadChains[i]);
5652 for (
unsigned i = From; i < To; ++i) {
5664 bool isVol,
bool AlwaysInline,
5678 std::vector<EVT> MemOps;
5679 bool DstAlignCanChange =
false;
5685 DstAlignCanChange =
true;
5687 if (Align > SrcAlign)
5691 bool isZeroConstant = CopyFromConstant && Slice.
Array ==
nullptr;
5695 (DstAlignCanChange ? 0 : Align),
5696 (isZeroConstant ? 0 : SrcAlign),
5697 false,
false, CopyFromConstant,
true,
5703 if (DstAlignCanChange) {
5704 Type *Ty = MemOps[0].getTypeForEVT(C);
5711 while (NewAlign > Align &&
5715 if (NewAlign > Align) {
5728 unsigned NumMemOps = MemOps.
size();
5729 uint64_t SrcOff = 0, DstOff = 0;
5730 for (
unsigned i = 0; i != NumMemOps; ++i) {
5735 if (VTSize > Size) {
5738 assert(i == NumMemOps-1 && i != 0);
5739 SrcOff -= VTSize -
Size;
5740 DstOff -= VTSize -
Size;
5743 if (CopyFromConstant &&
5751 if (SrcOff < Slice.
Length) {
5753 SubSlice.
move(SrcOff);
5756 SubSlice.
Array =
nullptr;
5758 SubSlice.
Length = VTSize;
5762 Store = DAG.
getStore(Chain, dl, Value,
5779 bool isDereferenceable =
5782 if (isDereferenceable)
5788 MinAlign(SrcAlign, SrcOff), SrcMMOFlags);
5803 unsigned NumLdStInMemcpy = OutStoreChains.
size();
5805 if (NumLdStInMemcpy) {
5811 for (
unsigned i = 0; i < NumLdStInMemcpy; ++i) {
5817 if (NumLdStInMemcpy <= GluedLdStLimit) {
5819 NumLdStInMemcpy, OutLoadChains,
5822 unsigned NumberLdChain = NumLdStInMemcpy / GluedLdStLimit;
5823 unsigned RemainingLdStInMemcpy = NumLdStInMemcpy % GluedLdStLimit;
5824 unsigned GlueIter = 0;
5826 for (
unsigned cnt = 0; cnt < NumberLdChain; ++cnt) {
5827 unsigned IndexFrom = NumLdStInMemcpy - GlueIter - GluedLdStLimit;
5828 unsigned IndexTo = NumLdStInMemcpy - GlueIter;
5831 OutLoadChains, OutStoreChains);
5832 GlueIter += GluedLdStLimit;
5836 if (RemainingLdStInMemcpy) {
5838 RemainingLdStInMemcpy, OutLoadChains,
5850 bool isVol,
bool AlwaysInline,
5862 std::vector<EVT> MemOps;
5863 bool DstAlignCanChange =
false;
5869 DstAlignCanChange =
true;
5871 if (Align > SrcAlign)
5876 (DstAlignCanChange ? 0 : Align), SrcAlign,
5877 false,
false,
false,
false,
5883 if (DstAlignCanChange) {
5884 Type *Ty = MemOps[0].getTypeForEVT(C);
5886 if (NewAlign > Align) {
5896 uint64_t SrcOff = 0, DstOff = 0;
5900 unsigned NumMemOps = MemOps.
size();
5901 for (
unsigned i = 0; i < NumMemOps; i++) {
5906 bool isDereferenceable =
5909 if (isDereferenceable)
5921 for (
unsigned i = 0; i < NumMemOps; i++) {
5926 Store = DAG.
getStore(Chain, dl, LoadValues[i],
5956 uint64_t
Size,
unsigned Align,
bool isVol,
5965 std::vector<EVT> MemOps;
5966 bool DstAlignCanChange =
false;
5972 DstAlignCanChange =
true;
5974 isa<ConstantSDNode>(Src) && cast<ConstantSDNode>(Src)->isNullValue();
5976 Size, (DstAlignCanChange ? 0 :
Align), 0,
5977 true, IsZeroVal,
false,
true,
5982 if (DstAlignCanChange) {
5983 Type *Ty = MemOps[0].getTypeForEVT(*DAG.getContext());
5984 unsigned NewAlign = (
unsigned)DAG.getDataLayout().getABITypeAlignment(Ty);
5985 if (NewAlign > Align) {
5994 uint64_t DstOff = 0;
5995 unsigned NumMemOps = MemOps.
size();
5998 EVT LargestVT = MemOps[0];
5999 for (
unsigned i = 1; i < NumMemOps; i++)
6000 if (MemOps[i].bitsGT(LargestVT))
6001 LargestVT = MemOps[i];
6004 for (
unsigned i = 0; i < NumMemOps; i++) {
6007 if (VTSize > Size) {
6010 assert(i == NumMemOps-1 && i != 0);
6011 DstOff -= VTSize -
Size;
6017 if (VT.
bitsLT(LargestVT)) {
6026 Chain, dl, Value, DAG.getMemBasePlusOffset(Dst, DstOff, dl),
6049 bool isVol,
bool AlwaysInline,
bool isTailCall,
6052 assert(Align &&
"The SDAG layer expects explicit alignment and reserves 0");
6064 isVol,
false, DstPtrInfo, SrcPtrInfo);
6073 *
this, dl, Chain, Dst, Src, Size, Align, isVol, AlwaysInline,
6074 DstPtrInfo, SrcPtrInfo);
6082 assert(ConstantSize &&
"AlwaysInline requires a constant size!");
6085 true, DstPtrInfo, SrcPtrInfo);
6101 Entry.
Node = Dst; Args.push_back(Entry);
6102 Entry.
Node = Src; Args.push_back(Entry);
6103 Entry.
Node =
Size; Args.push_back(Entry);
6116 std::pair<SDValue,SDValue> CallResult = TLI->
LowerCallTo(CLI);
6117 return CallResult.second;
6121 SDValue Dst,
unsigned DstAlign,
6122 SDValue Src,
unsigned SrcAlign,
6124 unsigned ElemSz,
bool isTailCall,
6132 Args.push_back(Entry);
6135 Args.push_back(Entry);
6139 Args.push_back(Entry);
6143 if (LibraryCall == RTLIB::UNKNOWN_LIBCALL)
6157 std::pair<SDValue, SDValue> CallResult = TLI->
LowerCallTo(CLI);
6158 return CallResult.second;
6163 bool isVol,
bool isTailCall,
6166 assert(Align &&
"The SDAG layer expects explicit alignment and reserves 0");
6179 false, DstPtrInfo, SrcPtrInfo);
6188 *
this, dl, Chain, Dst, Src, Size, Align, isVol, DstPtrInfo, SrcPtrInfo);
6203 Entry.
Node = Dst; Args.push_back(Entry);
6204 Entry.
Node = Src; Args.push_back(Entry);
6205 Entry.
Node =
Size; Args.push_back(Entry);
6218 std::pair<SDValue,SDValue> CallResult = TLI->
LowerCallTo(CLI);
6219 return CallResult.second;
6223 SDValue Dst,
unsigned DstAlign,
6224 SDValue Src,
unsigned SrcAlign,
6226 unsigned ElemSz,
bool isTailCall,
6234 Args.push_back(Entry);
6237 Args.push_back(Entry);
6241 Args.push_back(Entry);
6245 if (LibraryCall == RTLIB::UNKNOWN_LIBCALL)
6259 std::pair<SDValue, SDValue> CallResult = TLI->
LowerCallTo(CLI);
6260 return CallResult.second;
6265 bool isVol,
bool isTailCall,
6267 assert(Align &&
"The SDAG layer expects explicit alignment and reserves 0");
6279 Align, isVol, DstPtrInfo);
6289 *
this, dl, Chain, Dst, Src, Size, Align, isVol, DstPtrInfo);
6300 Entry.
Node = Dst; Entry.
Ty = IntPtrTy;
6301 Args.push_back(Entry);
6304 Args.push_back(Entry);
6306 Entry.
Ty = IntPtrTy;
6307 Args.push_back(Entry);
6321 std::pair<SDValue,SDValue> CallResult = TLI->
LowerCallTo(CLI);
6322 return CallResult.second;
6326 SDValue Dst,
unsigned DstAlign,
6328 unsigned ElemSz,
bool isTailCall,
6335 Args.push_back(Entry);
6339 Args.push_back(Entry);
6343 Args.push_back(Entry);
6347 if (LibraryCall == RTLIB::UNKNOWN_LIBCALL)
6361 std::pair<SDValue, SDValue> CallResult = TLI->
LowerCallTo(CLI);
6362 return CallResult.second;
6373 if (
SDNode *
E = FindNodeOrInsertPos(ID, dl, IP)) {
6374 cast<AtomicSDNode>(
E)->refineAlignment(MMO);
6379 VTList, MemVT, MMO);
6380 createOperands(N, Ops);
6382 CSEMap.InsertNode(N, IP);
6407 AAMDNodes(),
nullptr, SSID, SuccessOrdering,
6410 return getAtomicCmpSwap(Opcode, dl, MemVT, VTs, Chain, Ptr, Cmp, Swp, MMO);
6421 SDValue Ops[] = {Chain, Ptr, Cmp, Swp};
6422 return getAtomic(Opcode, dl, MemVT, VTs, Ops, MMO);
6427 const Value *PtrVal,
unsigned Alignment,
6449 nullptr, SSID, Ordering);
6451 return getAtomic(Opcode, dl, MemVT, Chain, Ptr, Val, MMO);
6470 "Invalid Atomic Op");
6476 SDValue Ops[] = {Chain, Ptr, Val};
6477 return getAtomic(Opcode, dl, MemVT, VTs, Ops, MMO);
6487 return getAtomic(Opcode, dl, MemVT, VTs, Ops, MMO);
6492 if (Ops.
size() == 1)
6497 for (
unsigned i = 0; i < Ops.
size(); ++i)
6530 "Opcode is not a memory-accessing opcode!");
6537 ID.
AddInteger(getSyntheticNodeSubclassData<MemIntrinsicSDNode>(
6538 Opcode, dl.
getIROrder(), VTList, MemVT, MMO));
6541 if (
SDNode *
E = FindNodeOrInsertPos(ID, dl, IP)) {
6542 cast<MemIntrinsicSDNode>(
E)->refineAlignment(MMO);
6547 VTList, MemVT, MMO);
6548 createOperands(N, Ops);
6550 CSEMap.InsertNode(N, IP);
6553 VTList, MemVT, MMO);
6554 createOperands(N, Ops);
6578 int FI = cast<FrameIndexSDNode>(Ptr.
getOperand(0))->getIndex();
6592 if (
ConstantSDNode *OffsetNode = dyn_cast<ConstantSDNode>(OffsetOp))
6607 "Invalid chain type");
6620 PtrInfo, MMOFlags, MemVT.
getStoreSize(), Alignment, AAInfo, Ranges);
6621 return getLoad(AM, ExtType, VT, dl, Chain, Ptr, Offset, MemVT, MMO);
6631 assert(VT == MemVT &&
"Non-extending load from different memory type!");
6635 "Should only be an extending load, not truncating!");
6637 "Cannot convert from FP to Int or Int -> FP!");
6639 "Cannot use an ext load to convert to or from a vector!");
6642 "Cannot use an ext load to change the number of vector elements!");
6646 assert((Indexed || Offset.
isUndef()) &&
"Unindexed load with an offset!");
6650 SDValue Ops[] = { Chain, Ptr, Offset };
6654 ID.
AddInteger(getSyntheticNodeSubclassData<LoadSDNode>(
6658 if (
SDNode *
E = FindNodeOrInsertPos(ID, dl, IP)) {
6659 cast<LoadSDNode>(
E)->refineAlignment(MMO);
6664 createOperands(N, Ops);
6666 CSEMap.InsertNode(N, IP);
6680 PtrInfo, VT, Alignment, MMOFlags, AAInfo, Ranges);
6698 MemVT, Alignment, MMOFlags, AAInfo);
6742 return getStore(Chain, dl, Val, Ptr, MMO);
6748 "Invalid chain type");
6752 SDValue Ops[] = { Chain, Val, Ptr, Undef };
6756 ID.
AddInteger(getSyntheticNodeSubclassData<StoreSDNode>(
6760 if (
SDNode *
E = FindNodeOrInsertPos(ID, dl, IP)) {
6761 cast<StoreSDNode>(
E)->refineAlignment(MMO);
6766 createOperands(N, Ops);
6768 CSEMap.InsertNode(N, IP);
6777 EVT SVT,
unsigned Alignment,
6781 "Invalid chain type");
6793 PtrInfo, MMOFlags, SVT.
getStoreSize(), Alignment, AAInfo);
6803 "Invalid chain type");
6805 return getStore(Chain, dl, Val, Ptr, MMO);
6808 "Should only be a truncating store, not extending!");
6810 "Can't do FP-INT conversion!");
6812 "Cannot use trunc store to convert to or from a vector!");
6815 "Cannot use trunc store to change the number of vector elements!");
6819 SDValue Ops[] = { Chain, Val, Ptr, Undef };
6823 ID.
AddInteger(getSyntheticNodeSubclassData<StoreSDNode>(
6827 if (
SDNode *
E = FindNodeOrInsertPos(ID, dl, IP)) {
6828 cast<StoreSDNode>(
E)->refineAlignment(MMO);
6833 createOperands(N, Ops);
6835 CSEMap.InsertNode(N, IP);
6855 if (
SDNode *
E = FindNodeOrInsertPos(ID, dl, IP))
6861 createOperands(N, Ops);
6863 CSEMap.InsertNode(N, IP);
6879 ID.
AddInteger(getSyntheticNodeSubclassData<MaskedLoadSDNode>(
6880 dl.
getIROrder(), VTs, ExtTy, isExpanding, MemVT, MMO));
6883 if (
SDNode *
E = FindNodeOrInsertPos(ID, dl, IP)) {
6884 cast<MaskedLoadSDNode>(
E)->refineAlignment(MMO);
6888 ExtTy, isExpanding, MemVT, MMO);
6889 createOperands(N, Ops);
6891 CSEMap.InsertNode(N, IP);
6901 bool IsTruncating,
bool IsCompressing) {
6903 "Invalid chain type");
6906 SDValue Ops[] = { Chain, Val, Ptr, Mask };
6910 ID.
AddInteger(getSyntheticNodeSubclassData<MaskedStoreSDNode>(
6911 dl.
getIROrder(), VTs, IsTruncating, IsCompressing, MemVT, MMO));
6914 if (
SDNode *
E = FindNodeOrInsertPos(ID, dl, IP)) {
6915 cast<MaskedStoreSDNode>(
E)->refineAlignment(MMO);
6919 IsTruncating, IsCompressing, MemVT, MMO);
6920 createOperands(N, Ops);
6922 CSEMap.InsertNode(N, IP);
6932 assert(Ops.
size() == 6 &&
"Incompatible number of operands");
6937 ID.AddInteger(getSyntheticNodeSubclassData<MaskedGatherSDNode>(
6941 if (
SDNode *
E = FindNodeOrInsertPos(ID, dl, IP)) {
6942 cast<MaskedGatherSDNode>(
E)->refineAlignment(MMO);
6948 createOperands(N, Ops);
6951 "Incompatible type of the PassThru value in MaskedGatherSDNode");
6954 "Vector width mismatch between mask and data");
6957 "Vector width mismatch between index and data");
6958 assert(isa<ConstantSDNode>(N->getScale()) &&
6959 cast<ConstantSDNode>(N->getScale())->getAPIntValue().isPowerOf2() &&
6960 "Scale should be a constant power of 2");
6962 CSEMap.InsertNode(N, IP);
6972 assert(Ops.
size() == 6 &&
"Incompatible number of operands");
6977 ID.AddInteger(getSyntheticNodeSubclassData<MaskedScatterSDNode>(
6981 if (
SDNode *
E = FindNodeOrInsertPos(ID, dl, IP)) {
6982 cast<MaskedScatterSDNode>(
E)->refineAlignment(MMO);
6987 createOperands(N, Ops);
6991 "Vector width mismatch between mask and data");
6994 "Vector width mismatch between index and data");
6995 assert(isa<ConstantSDNode>(N->getScale()) &&
6996 cast<ConstantSDNode>(N->getScale())->getAPIntValue().isPowerOf2() &&
6997 "Scale should be a constant power of 2");
6999 CSEMap.InsertNode(N, IP);
7019 if (
auto *CondC = dyn_cast<ConstantSDNode>(Cond))
7020 return CondC->isNullValue() ?
F :
T;
7068 switch (Ops.
size()) {
7069 case 0:
return getNode(Opcode, DL, VT);
7070 case 1:
return getNode(Opcode, DL, VT, static_cast<const SDValue>(Ops[0]));
7071 case 2:
return getNode(Opcode, DL, VT, Ops[0], Ops[1]);
7072 case 3:
return getNode(Opcode, DL, VT, Ops[0], Ops[1], Ops[2]);
7079 return getNode(Opcode, DL, VT, NewOps);
7084 unsigned NumOps = Ops.
size();
7086 case 0:
return getNode(Opcode, DL, VT);
7087 case 1:
return getNode(Opcode, DL, VT, Ops[0], Flags);
7088 case 2:
return getNode(Opcode, DL, VT, Ops[0], Ops[1], Flags);
7089 case 3:
return getNode(Opcode, DL, VT, Ops[0], Ops[1], Ops[2], Flags);
7106 assert(NumOps == 5 &&
"SELECT_CC takes 5 operands!");
7108 "LHS and RHS of condition must have same type!");
7110 "True and False arms of SelectCC must have same type!");
7112 "select_cc node must be of same type as true and false value!");
7115 assert(NumOps == 5 &&
"BR_CC takes 5 operands!");
7117 "LHS/RHS of comparison should match types!");
7130 if (
SDNode *
E = FindNodeOrInsertPos(ID, DL, IP))
7134 createOperands(N, Ops);
7136 CSEMap.InsertNode(N, IP);
7139 createOperands(N, Ops);
7156 return getNode(Opcode, DL, VTList.
VTs[0], Ops);
7167 cast<VTSDNode>(N3.getOperand(1))->getVT() !=
MVT::i1)
7168 return getNode(Opcode, DL, VT, N1, N2, N3.getOperand(0));
7169 else if (N3.getOpcode() ==
ISD::AND)
7170 if (
ConstantSDNode *AndRHS = dyn_cast<ConstantSDNode>(N3.getOperand(1))) {
7173 unsigned NumBits = VT.getScalarSizeInBits()*2;
7174 if ((AndRHS->getValue() & (NumBits-1)) == NumBits-1)
7175 return getNode(Opcode, DL, VT, N1, N2, N3.getOperand(0));
7187 if (
SDNode *
E = FindNodeOrInsertPos(ID, DL, IP))
7191 createOperands(N, Ops);
7192 CSEMap.InsertNode(N, IP);
7195 createOperands(N, Ops);
7211 return getNode(Opcode, DL, VTList, Ops);
7217 return getNode(Opcode, DL, VTList, Ops);
7222 SDValue Ops[] = { N1, N2, N3 };
7223 return getNode(Opcode, DL, VTList, Ops);
7228 SDValue Ops[] = { N1, N2, N3, N4 };
7229 return getNode(Opcode, DL, VTList, Ops);
7235 SDValue Ops[] = { N1, N2, N3, N4, N5 };
7236 return getNode(Opcode, DL, VTList, Ops);
7240 return makeVTList(SDNode::getValueTypeList(VT), 1);
7250 SDVTListNode *Result = VTListMap.FindNodeOrInsertPos(ID, IP);
7256 VTListMap.InsertNode(Result, IP);
7269 SDVTListNode *Result = VTListMap.FindNodeOrInsertPos(ID, IP);
7276 VTListMap.InsertNode(Result, IP);
7290 SDVTListNode *Result = VTListMap.FindNodeOrInsertPos(ID, IP);
7298 VTListMap.InsertNode(Result, IP);
7304 unsigned NumVTs = VTs.
size();
7307 for (
unsigned index = 0; index < NumVTs; index++) {
7312 SDVTListNode *Result = VTListMap.FindNodeOrInsertPos(ID, IP);
7317 VTListMap.InsertNode(Result, IP);
7336 void *InsertPos =
nullptr;
7337 if (
SDNode *Existing = FindModifiedNodeSlot(N, Op, InsertPos))
7342 if (!RemoveNodeFromCSEMaps(N))
7343 InsertPos =
nullptr;
7346 N->OperandList[0].set(Op);
7350 if (InsertPos) CSEMap.InsertNode(N, InsertPos);
7362 void *InsertPos =
nullptr;
7363 if (
SDNode *Existing = FindModifiedNodeSlot(N, Op1, Op2, InsertPos))
7368 if (!RemoveNodeFromCSEMaps(N))
7369 InsertPos =
nullptr;
7372 if (N->OperandList[0] != Op1)
7373 N->OperandList[0].set(Op1);
7374 if (N->OperandList[1] != Op2)
7375 N->OperandList[1].set(Op2);
7379 if (InsertPos) CSEMap.InsertNode(N, InsertPos);
7385 SDValue Ops[] = { Op1, Op2, Op3 };
7392 SDValue Ops[] = { Op1, Op2, Op3, Op4 };
7399 SDValue Ops[] = { Op1, Op2, Op3, Op4, Op5 };
7405 unsigned NumOps = Ops.
size();
7407 "Update with wrong number of operands");
7414 void *InsertPos =
nullptr;
7415 if (
SDNode *Existing = FindModifiedNodeSlot(N, Ops, InsertPos))
7420 if (!RemoveNodeFromCSEMaps(N))
7421 InsertPos =
nullptr;
7424 for (
unsigned i = 0; i != NumOps; ++i)
7425 if (N->OperandList[i] != Ops[i])
7426 N->OperandList[i].set(Ops[i]);
7430 if (InsertPos) CSEMap.InsertNode(N, InsertPos);
7447 if (NewMemRefs.
empty()) {
7453 if (NewMemRefs.
size() == 1) {
7454 N->MemRefs = NewMemRefs[0];
7460 Allocator.template Allocate<MachineMemOperand *>(NewMemRefs.
size());
7462 N->MemRefs = MemRefsBuffer;
7463 N->NumMemRefs =
static_cast<int>(NewMemRefs.
size());
7494 SDValue Ops[] = { Op1, Op2, Op3 };
7583 if (
SDNode *ON = FindNodeOrInsertPos(ID,
SDLoc(N), IP))
7584 return UpdateSDLocOnMergeSDNode(ON,
SDLoc(N));
7587 if (!RemoveNodeFromCSEMaps(N))
7592 N->ValueList = VTs.
VTs;
7593 N->NumValues = VTs.
NumVTs;
7603 DeadNodeSet.
insert(Used);
7612 createOperands(N, Ops);
7616 if (!DeadNodeSet.
empty()) {
7618 for (
SDNode *N : DeadNodeSet)
7625 CSEMap.InsertNode(N, IP);
7632 bool IsUnary =
false;
7633 bool IsTernary =
false;
7728 SDValue Ops[] = { Op1, Op2, Op3 };
7750 SDValue Ops[] = { Op1, Op2, Op3 };
7774 SDValue Ops[] = { Op1, Op2, Op3 };
7803 if (
SDNode *
E = FindNodeOrInsertPos(ID, DL, IP)) {
7804 return cast<MachineSDNode>(UpdateSDLocOnMergeSDNode(
E, DL));
7810 createOperands(N, Ops);
7813 CSEMap.InsertNode(N, IP);
7825 VT, Operand, SRIdxVal);
7835 VT, Operand, Subreg, SRIdxVal);
7848 if (
SDNode *
E = FindNodeOrInsertPos(ID,
SDLoc(), IP)) {
7849 E->intersectFlagsWith(Flags);
7860 SDNode *N,
unsigned R,
bool IsIndirect,
7862 assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
7863 "Expected inlined-at fields to agree");
7865 SDDbgValue(Var, Expr, N, R, IsIndirect, DL, O);
7873 assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
7874 "Expected inlined-at fields to agree");
7884 assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
7885 "Expected inlined-at fields to agree");
7893 unsigned VReg,
bool IsIndirect,
7895 assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
7896 "Expected inlined-at fields to agree");
7902 unsigned OffsetInBits,
unsigned SizeInBits,
7903 bool InvalidateDbg) {
7906 assert(FromNode && ToNode &&
"Can't modify dbg values");
7911 if (From == To || FromNode == ToNode)
7925 if (Dbg->getResNo() != From.
getResNo())
7929 auto *Expr = Dbg->getExpression();
7935 if (
auto FI = Expr->getFragmentInfo())
7936 if (OffsetInBits + SizeInBits > FI->SizeInBits)
7947 Dbg->getDebugLoc(), Dbg->getOrder());
7950 if (InvalidateDbg) {
7952 Dbg->setIsInvalidated();
7953 Dbg->setIsEmitted();
7967 if (DV->isInvalidated())
7982 auto *DIExpr = DV->getExpression();
7988 DV->isIndirect(), DV->getDebugLoc(), DV->getOrder());
7990 DV->setIsInvalidated();
7994 dbgs() <<
" into " << *DIExpr <<
'\n');
8006 assert(cast<DILabel>(Label)->isValidLocationForIntrinsic(DL) &&
8007 "Expected inlined-at fields to agree");
8023 while (UI != UE && N == *UI)
8044 "Cannot replace with this method!");
8045 assert(From != To.
getNode() &&
"Cannot replace uses of with self");
8058 RAUWUpdateListener Listener(*
this, UI, UE);
8063 RemoveNodeFromCSEMaps(User);
8075 }
while (UI != UE && *UI == User);
8078 AddModifiedNodeToCSEMaps(User);
8094 for (
unsigned i = 0, e = From->
getNumValues(); i != e; ++i)
8097 "Cannot use this version of ReplaceAllUsesWith!");
8105 for (
unsigned i = 0, e = From->
getNumValues(); i != e; ++i)
8107 assert((i < To->getNumValues()) &&
"Invalid To location");
8114 RAUWUpdateListener Listener(*
this, UI, UE);
8119 RemoveNodeFromCSEMaps(User);
8131 }
while (UI != UE && *UI == User);
8135 AddModifiedNodeToCSEMaps(User);
8153 for (
unsigned i = 0, e = From->
getNumValues(); i != e; ++i)
8159 RAUWUpdateListener Listener(*
this, UI, UE);
8164 RemoveNodeFromCSEMaps(User);
8170 bool To_IsDivergent =
false;
8177 }
while (UI != UE && *UI == User);
8184 AddModifiedNodeToCSEMaps(User);
8197 if (From == To)
return;
8212 RAUWUpdateListener Listener(*
this, UI, UE);
8215 bool UserRemovedFromCSEMaps =
false;
8232 if (!UserRemovedFromCSEMaps) {
8233 RemoveNodeFromCSEMaps(User);
8234 UserRemovedFromCSEMaps =
true;
8241 }
while (UI != UE && *UI == User);
8244 if (!UserRemovedFromCSEMaps)
8249 AddModifiedNodeToCSEMaps(User);
8268 bool operator<(
const UseMemo &L,
const UseMemo &R) {
8276 if (TLI->isSDNodeAlwaysUniform(N))
8278 bool IsDivergent = TLI->isSDNodeSourceOfDivergence(N, FLI, DA);
8279 for (
auto &Op : N->
ops()) {
8283 if (N->
SDNodeBits.IsDivergent != IsDivergent) {
8285 for (
auto U : N->
uses()) {
8292 void SelectionDAG::CreateTopologicalOrder(std::vector<SDNode*>& Order) {
8294 Order.
reserve(AllNodes.size());
8299 Order.push_back(&N);
8301 for (std::vector<SDNode *>::iterator
I = Order.begin();
8302 I!=Order.end();++
I) {
8304 for (
auto U : N->
uses()) {
8305 unsigned &UnsortedOps = Degree[U];
8306 if (0 == --UnsortedOps)
8315 std::vector<SDNode*> TopoOrder;
8316 CreateTopologicalOrder(TopoOrder);
8320 DivergenceMap[&
N] =
false;
8322 for (
auto N : TopoOrder) {
8323 bool IsDivergent = DivergenceMap[
N];
8325 for (
auto &Op : N->
ops()) {
8327 IsSDNodeDivergent |= DivergenceMap[Op.
getNode()];
8330 DivergenceMap[
N] =
true;
8336 "Divergence bit inconsistency detected\n");
8359 for (
unsigned i = 0; i != Num; ++i) {
8360 unsigned FromResNo = From[i].
getResNo();
8363 E = FromNode->
use_end(); UI !=
E; ++UI) {
8366 UseMemo Memo = { *UI, i, &Use };
8375 for (
unsigned UseIndex = 0, UseIndexEnd = Uses.
size();
8376 UseIndex != UseIndexEnd; ) {
8382 RemoveNodeFromCSEMaps(User);
8389 unsigned i = Uses[UseIndex].Index;
8394 }
while (UseIndex != UseIndexEnd && Uses[UseIndex].User == User);
8398 AddModifiedNodeToCSEMaps(User);
8406 unsigned DAGSize = 0;
8429 SortedPos = AllNodes.insert(SortedPos, AllNodes.remove(Q));
8430 assert(SortedPos != AllNodes.end() &&
"Overran node list");
8449 assert(Degree != 0 &&
"Invalid node degree");
8455 SortedPos = AllNodes.insert(SortedPos, AllNodes.remove(P));
8456 assert(SortedPos != AllNodes.end() &&
"Overran node list");
8463 if (Node.getIterator() == SortedPos) {
8467 dbgs() <<
"Overran sorted position:\n";
8469 dbgs() <<
"Checking if this is due to cycles\n";
8476 assert(SortedPos == AllNodes.end() &&
8477 "Topological sort incomplete!");
8479 "First node in topological sort is not the entry token!");
8480 assert(AllNodes.front().getNodeId() == 0 &&
8481 "First node in topological sort has non-zero id!");
8482 assert(AllNodes.front().getNumOperands() == 0 &&
8483 "First node in topological sort has operands!");
8484 assert(AllNodes.back().getNodeId() == (int)DAGSize-1 &&
8485 "Last node in topologic sort has unexpected id!");
8486 assert(AllNodes.back().use_empty() &&
8487 "Last node in topologic sort has users!");
8499 DbgInfo->add(DB, SD, isParameter);
8508 assert(isa<MemSDNode>(NewMemOp.
getNode()) &&
"Expected a memop node");
8527 assert(isa<ExternalSymbolSDNode>(Op) &&
"Node should be an ExternalSymbol");
8533 if (OutFunction !=
nullptr)
8541 std::string ErrorStr;
8544 ErrorFormatter <<
"Undefined external symbol ";
8545 ErrorFormatter <<
'"' <<
Symbol <<
'"';
8546 ErrorFormatter.
flush();
8572 return Const !=
nullptr && Const->
isOne();
8603 if (CN && (UndefElements.
none() || AllowUndefs) &&
8618 if (CN && (UndefElements.
none() || AllowUndefs))
8649 GlobalAddressSDNode::GlobalAddressSDNode(
unsigned Opc,
unsigned Order,
8652 int64_t o,
unsigned char TF)
8658 EVT VT,
unsigned SrcAS,
8661 SrcAddrSpace(SrcAS), DestAddrSpace(DestAS) {}
8665 :
SDNode(Opc, Order, dl, VTs), MemoryVT(memvt), MMO(mmo) {
8686 std::vector<EVT> VTs;
8703 const EVT *SDNode::getValueTypeList(
EVT VT) {
8706 return &(*EVTs->insert(VT).first);
8709 "Value type out of range!");
8722 if (UI.getUse().getResNo() == Value) {
8739 if (UI.getUse().getResNo() == Value)
8800 unsigned Depth)
const {
8801 if (*
this == Dest)
return true;
8805 if (Depth == 0)
return false;
8830 if (
LoadSDNode *Ld = dyn_cast<LoadSDNode>(*
this)) {
8831 if (!Ld->isVolatile())
8832 return Ld->getChain().reachesChainWithoutSideEffects(Dest, Depth-1);
8875 unsigned CandidateBinOp = Op.
getOpcode();
8876 for (
unsigned i = 0; i < Stages; ++i) {
8908 "Can't unroll a vector with multiple results!");
8911 unsigned NE = VT.getVectorNumElements();
8921 else if (NE > ResNE)
8925 for (i= 0; i !=
NE; ++i) {
8934 getConstant(i, dl, TLI->getVectorIdxTy(getDataLayout())));
8937 Operands[j] = Operand;
8969 for (; i < ResNE; ++i)
8973 return getBuildVector(VecVT, dl, Scalars);
8994 if (BaseLocDecomp.equalBaseIndex(LocDecomp, *
this, Offset))
8995 return (Dist * Bytes == Offset);
9004 int64_t GVOffset = 0;
9005 if (TLI->isGAPlusOffset(Ptr.
getNode(), GV, GVOffset)) {
9006 unsigned IdxWidth = getDataLayout().getIndexTypeSizeInBits(GV->
getType());
9010 unsigned Align = AlignBits ? 1 << std::min(31U, AlignBits) : 0;
9017 int FrameIdx = 1 << 31;
9018 int64_t FrameOffset = 0;
9020 FrameIdx = FI->getIndex();
9021 }
else if (isBaseWithConstantOffset(Ptr) &&
9024 FrameIdx = cast<FrameIndexSDNode>(Ptr.
getOperand(0))->getIndex();
9028 if (FrameIdx != (1 << 31)) {
9044 LoVT = HiVT = TLI->getTypeToTransformTo(*getContext(), VT);
9048 return std::make_pair(LoVT, HiVT);
9053 std::pair<SDValue, SDValue>
9058 "More vector elements requested than available!");
9061 getConstant(0, DL, TLI->getVectorIdxTy(getDataLayout())));
9064 TLI->getVectorIdxTy(getDataLayout())));
9065 return std::make_pair(Lo, Hi);
9070 unsigned Start,
unsigned Count) {
9076 EVT IdxTy = TLI->getVectorIdxTy(getDataLayout());
9078 for (
unsigned i = Start, e = Start + Count; i != e; ++i) {
9086 return getGlobal()->getType()->getAddressSpace();
9090 if (isMachineConstantPoolEntry())
9091 return Val.MachineCPVal->getType();
9092 return Val.ConstVal->getType();
9096 unsigned &SplatBitSize,
9098 unsigned MinSplatBits,
9099 bool IsBigEndian)
const {
9103 if (MinSplatBits > VecWidth)
9108 SplatValue =
APInt(VecWidth, 0);
9109 SplatUndef =
APInt(VecWidth, 0);
9116 assert(NumOps > 0 &&
"isConstantSplat has 0-size build vector");
9119 for (
unsigned j = 0; j < NumOps; ++j) {
9120 unsigned i = IsBigEndian ? NumOps - 1 - j : j;
9122 unsigned BitPos = j * EltWidth;
9125 SplatUndef.
setBits(BitPos, BitPos + EltWidth);
9126 else if (
auto *CN = dyn_cast<ConstantSDNode>(OpVal))
9127 SplatValue.
insertBits(CN->getAPIntValue().zextOrTrunc(EltWidth), BitPos);
9128 else if (
auto *CN = dyn_cast<ConstantFPSDNode>(OpVal))
9129 SplatValue.
insertBits(CN->getValueAPF().bitcastToAPInt(), BitPos);
9136 HasAnyUndefs = (SplatUndef != 0);
9139 while (VecWidth > 8) {
9140 unsigned HalfSize = VecWidth / 2;
9147 if ((HighValue & ~LowUndef) != (LowValue & ~HighUndef) ||
9148 MinSplatBits > HalfSize)
9151 SplatValue = HighValue | LowValue;
9152 SplatUndef = HighUndef & LowUndef;
9154 VecWidth = HalfSize;
9157 SplatBitSize = VecWidth;
9162 if (UndefElements) {
9163 UndefElements->
clear();
9171 (*UndefElements)[i] =
true;
9172 }
else if (!Splatted) {
9174 }
else if (Splatted != Op) {
9181 "Can only have a splat without a constant for all undefs.");
9190 return dyn_cast_or_null<ConstantSDNode>(
getSplatValue(UndefElements));
9195 return dyn_cast_or_null<ConstantFPSDNode>(
getSplatValue(UndefElements));
9202 dyn_cast_or_null<ConstantFPSDNode>(
getSplatValue(UndefElements))) {
9205 const APFloat &APF = CN->getValueAPF();
9231 assert(i != e &&
"VECTOR_SHUFFLE node with all undef indices!");
9235 for (
int Idx = Mask[i]; i != e; ++i)
9236 if (Mask[i] >= 0 && Mask[i] != Idx)
9244 if (isa<ConstantSDNode>(N))
9252 TLI->isOffsetFoldingLegal(GA))
9258 if (isa<ConstantFPSDNode>(N))
9268 assert(!Node->OperandList &&
"Node already has operands");
9269 assert(std::numeric_limits<decltype(SDNode::NumOperands)>::
max() >=
9271 "too many operands to fit into SDNode");
9272 SDUse *Ops = OperandRecycler.allocate(
9275 bool IsDivergent =
false;
9276 for (
unsigned I = 0;
I != Vals.
size(); ++
I) {
9277 Ops[
I].setUser(Node);
9278 Ops[
I].setInitial(Vals[
I]);
9280 IsDivergent = IsDivergent || Ops[I].getNode()->isDivergent();
9282 Node->NumOperands = Vals.
size();
9283 Node->OperandList = Ops;
9284 IsDivergent |= TLI->isSDNodeSourceOfDivergence(Node, FLI, DA);
9285 if (!TLI->isSDNodeAlwaysUniform(Node))
9296 if (Checked.
count(N))
9301 if (!Visited.
insert(N).second) {
9302 errs() <<
"Detected cycle in SelectionDAG\n";
9303 dbgs() <<
"Offending node:\n";
9321 #ifdef EXPENSIVE_CHECKS 9323 #endif // EXPENSIVE_CHECKS 9325 assert(N &&
"Checking nonexistent SDNode");
void clearAllBits()
Set every bit to 0.
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.
APInt abs() const
Get the absolute value;.
Pass interface - Implemented by all 'passes'.
SDNode * MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs, ArrayRef< SDValue > Ops)
This mutates the specified node to have the specified return type, opcode, and operands.
bool isMachineConstantPoolEntry() const
void resize(unsigned N, bool t=false)
resize - Grow or shrink the bitvector.
opStatus roundToIntegral(roundingMode RM)
static APFloat getNaN(const fltSemantics &Sem, bool Negative=false, uint64_t payload=0)
Factory for NaN values.
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
static const fltSemantics & IEEEquad() LLVM_READNONE
bool isEqualTo(SDValue A, SDValue B) const
Test whether two SDValues are known to compare equal.
SDValue getGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, bool isTargetGA=false, unsigned char TargetFlags=0)
void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, OptimizationRemarkEmitter *ORE=nullptr, bool UseInstrInfo=true)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
SDNode * SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT)
These are used for target selectors to mutate the specified node to have the specified return type...
BUILTIN_OP_END - This must be the last enum value in this list.
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
EVT getValueType() const
Return the ValueType of the referenced return value.
OverflowKind
Used to represent the possible overflow behavior of an operation.
static void commuteMask(MutableArrayRef< int > Mask)
Change values in a shuffle permute mask assuming the two vector operands have swapped position...
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
const SDValue & getOffset() const
void setFlags(SDNodeFlags NewFlags)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
opStatus convertFromAPInt(const APInt &Input, bool IsSigned, roundingMode RM)
bool hasNoSignedZeros() const
Constrained versions of libm-equivalent floating point intrinsics.
This SDNode is used for target intrinsics that touch memory and need an associated MachineMemOperand...
SDValue getBoolExtOrTrunc(SDValue Op, const SDLoc &SL, EVT VT, EVT OpVT)
Convert Op, which must be of integer type, to the integer type VT, by using an extension appropriate ...
const GlobalValue * getGlobal() const
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.
uint64_t getZExtValue() const
Get zero extended value.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
SDValue getTargetIndex(int Index, EVT VT, int64_t Offset=0, unsigned char TargetFlags=0)
Keeps track of dbg_value information through SDISel.
bool isBuildVectorOfConstantSDNodes(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR node of all ConstantSDNode or undef...
void setBits(unsigned loBit, unsigned hiBit)
Set the bits from loBit (inclusive) to hiBit (exclusive) to 1.
SDValue UnrollVectorOp(SDNode *N, unsigned ResNE=0)
Utility function used by legalize and lowering to "unroll" a vector operation by splitting out the sc...
SDValue 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...
bool isIndexed() const
Return true if this is a pre/post inc/dec load/store.
SDValue getIndexedLoad(SDValue OrigLoad, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef, unsigned &SplatBitSize, bool &HasAnyUndefs, unsigned MinSplatBits=0, bool isBigEndian=false) const
Check if this is a constant splat, and if so, find the smallest element size that splats the vector...
unsigned char getTargetFlags() const
NodeType getExtForLoadExtType(bool IsFP, LoadExtType)
DELETED_NODE - This is an illegal value that is used to catch errors.
MDNODE_SDNODE - This is a node that holdes an MDNode*, which is used to reference metadata in the IR...
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an vector value) starting with the ...
BR_CC - Conditional branch.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
SDValue simplifyShift(SDValue X, SDValue Y)
Try to simplify a shift into 1 of its operands or a constant.
void intersectWith(const SDNodeFlags Flags)
Clear any flags in this flag set that aren't also set in Flags.
FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0 as less than 0...
void VerifyDAGDiverence()
unsigned countMinPopulation() const
Returns the number of bits known to be one.
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.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module. ...
APInt sdiv(const APInt &RHS) const
Signed division function for APInt.
bool exceedsNaturalStackAlignment(unsigned Align) const
Returns true if the given alignment exceeds the natural stack alignment.
SDValue getAtomicMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, unsigned DstAlign, SDValue Src, unsigned SrcAlign, SDValue Size, Type *SizeTy, unsigned ElemSz, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
bool hasConflict() const
Returns true if there is conflicting information.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
const Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
bool isNullOrNullSplat(SDValue V)
Return true if the value is a constant 0 integer or a splatted vector of a constant 0 integer (with n...
unsigned getIROrder() const
Return the node ordering.
bool isNegative() const
Return true if the value is negative.
bool isTargetMemoryOpcode() const
Test if this node has a target-specific memory-referencing opcode (in the <target>ISD namespace and g...
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.
Clients of various APIs that cause global effects on the DAG can optionally implement this interface...
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
SDValue makeEquivalentMemoryOrdering(LoadSDNode *Old, SDValue New)
If an existing load has uses of its chain, create a token factor node with that chain and the new mem...
APInt zext(unsigned width) const
Zero extend to a new width.
friend struct DAGUpdateListener
DAGUpdateListener is a friend so it can manipulate the listener stack.
APInt uadd_sat(const APInt &RHS) const
bool slt(const APInt &RHS) const
Signed less than comparison.
const SDValue & getValue() const
APInt udiv(const APInt &RHS) const
Unsigned division operation.
SDVTList getVTList() const
CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger)
Return the result of a logical AND between different comparisons of identical values: ((X op1 Y) & (X...
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Get a value with low bits set.
static void commuteShuffle(SDValue &N1, SDValue &N2, MutableArrayRef< int > M)
Swaps the values of N1 and N2.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
virtual void addSelectionDAGCSEId(FoldingSetNodeID &ID)=0
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit...
virtual const TargetLowering * getTargetLowering() const
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
#define __asan_unpoison_memory_region(p, size)
SDValue getBasicBlock(MachineBasicBlock *MBB)
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
FoldingSetNodeIDRef Intern(BumpPtrAllocator &Allocator) const
Intern - Copy this node's data to a memory region allocated from the given allocator and return a Fol...
Completely target-dependent object reference.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
static SDValue FoldCONCAT_VECTORS(const SDLoc &DL, EVT VT, ArrayRef< SDValue > Ops, SelectionDAG &DAG)
static ISD::NodeType getExtendForContent(BooleanContent Content)
const SDValue & getChain() const
unsigned getResNo() const
Convenience function for get().getResNo().
bool NewNodesMustHaveLegalTypes
When true, additional steps are taken to ensure that getConstant() and similar functions return DAG n...
uint64_t getSize() const
Return the size in bytes of the memory reference.
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
virtual bool isCommutativeBinOp(unsigned Opcode) const
Returns true if the opcode is a commutative binary operation.
static const fltSemantics & EVTToAPFloatSemantics(EVT VT)
Returns an APFloat semantics tag appropriate for the given type.
unsigned getAlignment() const
unsigned getMaxStoresPerMemset(bool OptSize) const
Get maximum # of store operations permitted for llvm.memset.
Recycle small arrays allocated from a BumpPtrAllocator.
unsigned getValueSizeInBits(unsigned ResNo) const
Returns MVT::getSizeInBits(getValueType(ResNo)).
bool isBitwiseNot(SDValue V)
Returns true if V is a bitwise not operation.
virtual bool isSafeMemOpType(MVT) const
Returns true if it's safe to use load / store of the specified type to expand memcpy / memset inline...
bool sgt(const APInt &RHS) const
Signed greather than comparison.
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
bool isAllOnesOrAllOnesSplat(SDValue V)
Return true if the value is a constant -1 integer or a splatted vector of a constant -1 integer (with...
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
SDValue getIndexedStore(SDValue OrigStore, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
APInt trunc(unsigned width) const
Truncate to new width.
void setAllBits()
Set every bit to 1.
Constrained versions of the binary floating point operators.
unsigned const TargetRegisterInfo * TRI
bool isInteger() const
Return true if this is an integer or a vector integer type.
void updateDivergence(SDNode *N)
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
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.
APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
const SDNodeFlags getFlags() const
SDNode * isConstantFPBuildVectorOrConstantFP(SDValue N)
Test whether the given value is a constant FP or similar node.
void setNodeId(int Id)
Set unique node id.
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
void setBitsFrom(unsigned loBit)
Set the top bits starting from loBit.
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned char TargetFlags=0)
unsigned countMaxTrailingZeros() const
Returns the maximum number of trailing zero bits possible.
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
virtual bool isZExtFree(Type *FromTy, Type *ToTy) const
Return true if any actual instruction that defines a value of type FromTy implicitly zero-extends the...
const SDValue & setRoot(SDValue N)
Set the current root tag of the SelectionDAG.
void reserve(size_type N)
uint64_t Offset
Slice starts at this Offset.
bool sle(const APInt &RHS) const
Signed less or equal comparison.
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...
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
void DeleteNode(SDNode *N)
Remove the specified node from the system.
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1 at the ...
SDValue getConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offs=0, bool isT=false, unsigned char TargetFlags=0)
void intersectFlagsWith(const SDNodeFlags Flags)
Clear any flags in this node that aren't also set in Flags.
std::size_t countLeadingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the most significant bit to the least stopping at the first 1...
uint16_t PersistentId
Unique and persistent id per SDNode in the DAG.
const DebugLoc & getDebugLoc() const
Return the source location info.
unsigned getValueSizeInBits() const
Returns the size of the value in bits.
EntryToken - This is the marker used to indicate the start of a region.
virtual SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, unsigned Align, bool isVolatile, MachinePointerInfo DstPtrInfo) const
Emit target-specific code that performs a memset.
void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, Pass *PassPtr, const TargetLibraryInfo *LibraryInfo, LegacyDivergenceAnalysis *Divergence)
Prepare this SelectionDAG to process code in the given MachineFunction.
void AddDbgValue(SDDbgValue *DB, SDNode *SD, bool isParameter)
Add a dbg_value SDNode.
unsigned getBitWidth() const
getBitWidth - Return the bitwidth of this constant.
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
SDValue getMCSymbol(MCSymbol *Sym, EVT VT)
void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To, unsigned Num)
Like ReplaceAllUsesOfValueWith, but for multiple values at once.
virtual void NodeUpdated(SDNode *N)
The node N that was updated.
Value is a virtual register.
INT = FGETSIGN(FP) - Return the sign bit of the specified floating point value as an integer 0/1 valu...
static bool areOnlyUsersOf(ArrayRef< const SDNode *> Nodes, const SDNode *N)
Return true if all the users of N are contained in Nodes.
unsigned getBitWidth() const
Return the number of bits in the APInt.
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
SDValue getExternalSymbol(const char *Sym, EVT VT)
bool isAllOnesValue() const
bool isCondCodeLegal(ISD::CondCode CC, MVT VT) const
Return true if the specified condition code is legal on this target.
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
void transferDbgValues(SDValue From, SDValue To, unsigned OffsetInBits=0, unsigned SizeInBits=0, bool InvalidateDbg=true)
Transfer debug values from one node to another, while optionally generating fragment expressions for ...
static DIExpression * prepend(const DIExpression *Expr, bool DerefBefore, int64_t Offset=0, bool DerefAfter=false, bool StackValue=false)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value...
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
bool isTruncatingStore() const
Return true if the op does a truncation before store.
SDValue getAtomicMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, unsigned DstAlign, SDValue Value, SDValue Size, Type *SizeTy, unsigned ElemSz, bool isTailCall, MachinePointerInfo DstPtrInfo)
unsigned countMinTrailingZeros() const
Returns the minimum number of trailing zero bits.
static bool hasPredecessorHelper(const SDNode *N, SmallPtrSetImpl< const SDNode *> &Visited, SmallVectorImpl< const SDNode *> &Worklist, unsigned int MaxSteps=0, bool TopologicalPrune=false)
Returns true if N is a predecessor of any node in Worklist.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
SDValue getMemBasePlusOffset(SDValue Base, unsigned Offset, const SDLoc &DL)
Returns sum of the base pointer and offset.
unsigned char getTargetFlags() const
unsigned getAddrSpace() const
Return the LLVM IR address space number that this pointer points into.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
SI optimize exec mask operations pre RA
opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations...
unsigned countTrailingZeros() const
Count the number of trailing zero bits.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
virtual unsigned ComputeNumSignBitsForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const
This method can be implemented by targets that want to expose additional information about sign bits ...
opStatus divide(const APFloat &RHS, roundingMode RM)
The address of a basic block.
void clear()
Clear state and free memory necessary to make this SelectionDAG ready to process a new block...
bool hasOneUse() const
Return true if there is exactly one use of this node.
A description of a memory reference used in the backend.
void clear()
clear - Removes all bits from the bitvector. Does not change capacity.
OverflowKind computeOverflowKind(SDValue N0, SDValue N1) const
Determine if the result of the addition of 2 node can overflow.
SDValue FoldSymbolOffset(unsigned Opcode, EVT VT, const GlobalAddressSDNode *GA, const SDNode *N2)
void setBit(unsigned BitPosition)
Set a given bit to 1.
AddrSpaceCastSDNode(unsigned Order, const DebugLoc &dl, EVT VT, unsigned SrcAS, unsigned DestAS)
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void Reset()
Deallocate all but the current slab and reset the current pointer to the beginning of it...
void setHighBits(unsigned hiBits)
Set the top hiBits bits.
bool isUndef(unsigned Opcode, ArrayRef< SDValue > Ops)
Return true if the result of this operation is always undefined.
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
unsigned getPointerTypeSizeInBits(Type *) const
Layout pointer size, in bits, based on the type.
bool isNonTemporal() const
APInt shl(unsigned shiftAmt) const
Left-shift function.
Shift and rotation operations.
bool matchUnaryPredicate(SDValue Op, std::function< bool(ConstantSDNode *)> Match, bool AllowUndefs=false)
Attempt to match a unary predicate against a scalar/splat constant or every element of a constant BUI...
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
APInt zextOrSelf(unsigned width) const
Zero extend or truncate to width.
bool isBuildVectorAllZeros(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR where all of the elements are 0 or undef...
APInt rotr(unsigned rotateAmt) const
Rotate right by rotateAmt.
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth...
A Use represents the edge between a Value definition and its users.
SDValue getTargetExtractSubreg(int SRIdx, const SDLoc &DL, EVT VT, SDValue Operand)
A convenience function for creating TargetInstrInfo::EXTRACT_SUBREG nodes.
MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s), MachineInstr opcode, and operands.
static SDValue FoldBUILD_VECTOR(const SDLoc &DL, EVT VT, ArrayRef< SDValue > Ops, SelectionDAG &DAG)
static Optional< unsigned > getOpcode(ArrayRef< VPValue *> Values)
Returns the opcode of Values or ~0 if they do not all agree.
SDValue getMaskedScatter(SDVTList VTs, EVT VT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO)
CallLoweringInfo & setChain(SDValue InChain)
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
op_iterator op_end() const
unsigned getScalarValueSizeInBits() const
uint64_t getConstantOperandVal(unsigned i) const
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
bool isZEXTLoad(const SDNode *N)
Returns true if the specified node is a ZEXTLOAD.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly...
static void checkAddrSpaceIsValidForLibcall(const TargetLowering *TLI, unsigned AS)
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
void AddInteger(signed I)
The memory access is dereferenceable (i.e., doesn't trap).
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
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.
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.
APInt getHiBits(unsigned numBits) const
Compute an APInt containing numBits highbits from this APInt.
const BlockAddress * getBlockAddress() const
This is an SDNode representing atomic operations.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
void lshrInPlace(unsigned ShiftAmt)
Logical right-shift this APInt by ShiftAmt in place.
SDValue FoldSetCC(EVT VT, SDValue N1, SDValue N2, ISD::CondCode Cond, const SDLoc &dl)
Constant fold a setcc to true or false.
KnownBits zext(unsigned BitWidth)
Zero extends the underlying known Zero and One bits.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
This file implements a class to represent arbitrary precision integral constant values and operations...
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
iterator_range< allnodes_iterator > allnodes()
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())
bool isConstantSplatVector(const SDNode *N, APInt &SplatValue)
Node predicates.
virtual bool isTruncateFree(Type *FromTy, Type *ToTy) const
Return true if it's free to truncate a value of type FromTy to type ToTy.
This class is used to represent an MSTORE node.
AtomicOrdering
Atomic ordering for LLVM's memory model.
SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
static int64_t getConstant(const MachineInstr *MI)
unsigned AssignTopologicalOrder()
Topological-sort the AllNodes list and a assign a unique node id for each node in the DAG based on th...
static void VerifySDNode(SDNode *N)
VerifySDNode - Sanity check the given SDNode. Aborts if it is invalid.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
unsigned getActiveBits() const
Compute the number of active bits in the value.
int64_t getSExtValue() const
unsigned countMaxPopulation() const
Returns the maximum number of bits that could be one.
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...
void ashrInPlace(unsigned ShiftAmt)
Arithmetic right-shift this APInt by ShiftAmt in place.
void dumprFull(const SelectionDAG *G=nullptr) const
printrFull to dbgs().
Fast - This calling convention attempts to make calls as fast as possible (e.g.
static SDValue getMemsetValue(SDValue Value, EVT VT, SelectionDAG &DAG, const SDLoc &dl)
getMemsetValue - Vectorized representation of the memset value operand.
unsigned getScalarSizeInBits() const
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
static SDValue getMemsetStores(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, unsigned Align, bool isVol, MachinePointerInfo DstPtrInfo)
Lower the call to 'memset' intrinsic function into a series of store operations.
Value is contents of a stack location.
void checkForCycles(const SelectionDAG *DAG, bool force=false)
Type * getType() const
All values are typed, get the type of this value.
bool getBoolValue() const
Convert APInt to a boolean value.
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 isOneOrOneSplat(SDValue V)
Return true if the value is a constant 1 integer or a splatted vector of a constant 1 integer (with n...
const ConstantDataArray * Array
ConstantDataArray pointer.
opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
void clearMemRefs()
Clear out the memory reference descriptor list.
SDValue getRegisterMask(const uint32_t *RegMask)
DAGUpdateListener *const Next
int64_t getOffset() const
bool isKnownNeverZero(SDValue Op) const
Test whether the given SDValue is known to contain non-zero value(s).
static cl::opt< int > MaxLdStGlue("ldstmemcpy-glue-max", cl::desc("Number limit for gluing ld/st of memcpy."), cl::Hidden, cl::init(0))
SDNode * mutateStrictFPToFP(SDNode *Node)
Mutate the specified strict FP node to its non-strict equivalent, unlinking the node from its chain a...
const TargetMachine & getTarget() 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...
void clearBit(unsigned BitPosition)
Set a given bit to 0.
SDValue peekThroughBitcasts(SDValue V)
Return the non-bitcasted source operand of V if it exists.
APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
Simple integer binary arithmetic operators.
bool isOperandOf(const SDNode *N) const
Return true if this node is an operand of N.
int32_t exactLogBase2() const
APInt extractBits(unsigned numBits, unsigned bitPosition) const
Return an APInt with the extracted bits [bitPosition,bitPosition+numBits).
virtual EVT getOptimalMemOpType(uint64_t, unsigned, unsigned, bool, bool, bool, MachineFunction &) const
Returns the target specific optimal type for load and store operations as a result of memset...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const APInt & getValue() const
Return the constant as an APInt value reference.
bool isLittleEndian() const
Layout endianness...
opStatus subtract(const APFloat &RHS, roundingMode RM)
virtual SDValue EmitTargetCodeForMemmove(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, unsigned Align, bool isVolatile, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const
Emit target-specific code that performs a memmove.
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
cmpResult
IEEE-754R 5.11: Floating Point Comparison Relations.
bool isKnownNeverNaN(SDValue Op, bool SNaN=false, unsigned Depth=0) const
Test whether the given SDValue is known to never be NaN.
SDDbgValue * getVRegDbgValue(DIVariable *Var, DIExpression *Expr, unsigned VReg, bool IsIndirect, const DebugLoc &DL, unsigned O)
Creates a VReg SDDbgValue node.
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
static const fltSemantics & IEEEdouble() LLVM_READNONE
TargetConstant* - Like Constant*, but the DAG does not do any folding, simplification, or lowering of the constant.
bool isKnownNeverZeroFloat(SDValue Op) const
Test whether the given floating point SDValue is known to never be positive or negative zero...
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op)
Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all elements. ...
ArrayRef< SDUse > ops() const
SDValue getLabelNode(unsigned Opcode, const SDLoc &dl, SDValue Root, MCSymbol *Label)
void setIROrder(unsigned Order)
Set the node ordering.
bool getHasDebugValue() const
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
Expected< const typename ELFT::Sym * > getSymbol(typename ELFT::SymRange Symbols, uint32_t Index)
APInt reverseBits() const
SDNodeBitfields SDNodeBits
SDValue GetDemandedBits(SDValue V, const APInt &Mask)
See if the specified operand can be simplified with the knowledge that only the bits specified by Mas...
Analysis containing CSE Info
std::pair< EVT, EVT > GetSplitDestVTs(const EVT &VT) const
Compute the VTs needed for the low/hi parts of a type which is split (or expanded) into two not neces...
const char * getSymbol() 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.
static void AddNodeIDValueTypes(FoldingSetNodeID &ID, SDVTList VTList)
AddNodeIDValueTypes - Value type lists are intern'd so we can represent them solely with their pointe...
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the specified, possibly variable...
bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
This corresponds to the llvm.lifetime.
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
bool isNegative() const
Returns true if this value is known to be negative.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Get a value with high bits set.
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
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...
bool getConstantDataArrayInfo(const Value *V, ConstantDataArraySlice &Slice, unsigned ElementSize, uint64_t Offset=0)
Returns true if the value V is a pointer into a ConstantDataArray.
bool isZero() const
Return true if the value is positive or negative zero.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
The memory access is volatile.
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.
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
SDDbgValue * getConstantDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, const DebugLoc &DL, unsigned O)
Creates a constant SDDbgValue node.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
void insertBits(const APInt &SubBits, unsigned bitPosition)
Insert the bits from a smaller APInt starting at bitPosition.
SDValue getMDNode(const MDNode *MD)
Return an MDNodeSDNode which holds an MDNode.
bool isNegative() const
Determine sign of this APInt.
const SDValue & getBasePtr() const
static void chainLoadsAndStoresForMemcpy(SelectionDAG &DAG, const SDLoc &dl, SmallVector< SDValue, 32 > &OutChains, unsigned From, unsigned To, SmallVector< SDValue, 16 > &OutLoadChains, SmallVector< SDValue, 16 > &OutStoreChains)
initializer< Ty > init(const Ty &Val)
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
int64_t getOffset() const
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
static SDValue getMemmoveLoadsAndStores(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, unsigned Align, bool isVol, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
SDValue getCommutedVectorShuffle(const ShuffleVectorSDNode &SV)
Returns an ISD::VECTOR_SHUFFLE node semantically equivalent to the shuffle node in input but with swa...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
APInt urem(const APInt &RHS) const
Unsigned remainder operation.
bool SignBitIsZero(SDValue Op, unsigned Depth=0) const
Return true if the sign bit of Op is known to be zero.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
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...
unsigned countPopulation() const
Count the number of bits set.
use_iterator use_begin() const
Provide iteration support to walk over all uses of an SDNode.
SelectionDAG(const TargetMachine &TM, CodeGenOpt::Level)
static void AddNodeIDNode(FoldingSetNodeID &ID, unsigned short OpC, SDVTList VTList, ArrayRef< SDValue > OpList)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
Simple binary floating point operators.
PowerPC Reduce CR logical Operation
bool hasAnyUseOfValue(unsigned Value) const
Return true if there are any use of the indicated value.
static bool doNotCSE(SDNode *N)
doNotCSE - Return true if CSE should not be performed for this node.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
void DropOperands()
Release the operands and set this node to have zero operands.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool ult(const APInt &RHS) const
Unsigned less than comparison.
size_t size() const
size - Get the array size.
PointerUnion< const Value *, const PseudoSourceValue * > V
This is the IR pointer value for the access, or it is null if unknown.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
void resetAll()
Resets the known state of all bits.
virtual bool shouldConvertConstantLoadToIntImm(const APInt &Imm, Type *Ty) const
Return true if it is beneficial to convert a load of a constant to just the constant itself...
iterator_range< value_op_iterator > op_values() const
LLVM_NODISCARD bool empty() const
static SDValue getMemsetStringVal(EVT VT, const SDLoc &dl, SelectionDAG &DAG, const TargetLowering &TLI, const ConstantDataArraySlice &Slice)
getMemsetStringVal - Similar to getMemsetValue.
const SDValue & getOperand(unsigned Num) const
Libcall getMEMMOVE_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize)
getMEMMOVE_ELEMENT_UNORDERED_ATOMIC - Return MEMMOVE_ELEMENT_UNORDERED_ATOMIC_* value for the given e...
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...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
bool isPointerTy() const
True if this is an instance of PointerType.
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
SDValue getSplatValue(BitVector *UndefElements=nullptr) const
Returns the splatted value or a null value if this is not a splat.
Carry-using nodes for multiple precision addition and subtraction.
bool matchBinaryPredicate(SDValue LHS, SDValue RHS, std::function< bool(ConstantSDNode *, ConstantSDNode *)> Match, bool AllowUndefs=false)
Attempt to match a binary predicate against a pair of scalar/splat constants or every element of a pa...
bool isKnownNeverSNaN(SDValue Op, unsigned Depth=0) const
ConstantFP - Floating Point Values [float, double].
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
unsigned char getTargetFlags() const
SDValue getAddrSpaceCast(const SDLoc &dl, EVT VT, SDValue Ptr, unsigned SrcAS, unsigned DestAS)
Return an AddrSpaceCastSDNode.
DAGUpdateListener(SelectionDAG &D)
virtual void computeKnownBitsForFrameIndex(const SDValue FIOp, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const
Determine which of the bits of FrameIndex FIOp are known to be 0.
bool isOperandOf(const SDNode *N) const
Return true if this node is an operand of N.
const SDValue & getOffset() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
void RemoveDeadNodes()
This method deletes all unreachable nodes in the SelectionDAG.
static void AddNodeIDOperands(FoldingSetNodeID &ID, ArrayRef< SDValue > Ops)
AddNodeIDOperands - Various routines for adding operands to the NodeID data.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static Type * getVoidTy(LLVMContext &C)
This class provides iterator support for SDUse operands that use a specific SDNode.
bool isExactlyValue(double V) const
We don't rely on operator== working on double values, as it returns true for things that are clearly ...
BumpPtrAllocator & getAlloc()
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
bool isBaseWithConstantOffset(SDValue Op) const
Return true if the specified operand is an ISD::ADD with a ConstantSDNode on the right-hand side...
bool optForSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
static ManagedStatic< std::set< EVT, EVT::compareRawBits > > EVTs
unsigned getAddressSpace() const
KnownBits trunc(unsigned BitWidth)
Truncate the underlying known Zero and One bits.
virtual SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, unsigned Align, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const
Emit target-specific code that performs a memcpy.
void ReplaceAllUsesWith(SDValue From, SDValue To)
Modify anything using 'From' to use 'To' instead.
opStatus multiply(const APFloat &RHS, roundingMode RM)
const APInt & getAPIntValue() const
TargetIndex - Like a constant pool entry, but with completely target-dependent semantics.
static cl::opt< bool > EnableMemCpyDAGOpt("enable-memcpy-dag-opt", cl::Hidden, cl::init(true), cl::desc("Gang up loads and stores generated by inlining of memcpy"))
const Triple & getTargetTriple() const
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
Base class for variables.
void RemoveDeadNode(SDNode *N)
Remove the specified node from the system.
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again...
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
self_iterator getIterator()
SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, unsigned Align=0, MachineMemOperand::Flags Flags=MachineMemOperand::MOLoad|MachineMemOperand::MOStore, unsigned Size=0)
Creates a MemIntrinsicNode that may produce a result and takes a list of operands.
bool hasNUsesOfValue(unsigned NUses, unsigned Value) const
Return true if there are exactly NUSES uses of the indicated value.
CondCode getSetCCSwappedOperands(CondCode Operation)
Return the operation corresponding to (Y op X) when given the operation for (X op Y)...
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
Represents offset+length into a ConstantDataArray.
SDValue getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Mask, SDValue Src0, EVT MemVT, MachineMemOperand *MMO, ISD::LoadExtType, bool IsExpanding=false)
void clearSignBit()
Set the sign bit to 0.
static bool isValueValidForType(EVT VT, const APFloat &Val)
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...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
unsigned char getTargetFlags() const
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
virtual bool hasVectorBlend() const
Return true if the target has a vector blend instruction.
static ManagedStatic< sys::SmartMutex< true > > VTMutex
std::vector< ArgListEntry > ArgListTy
unsigned getAlignment() const
bool haveNoCommonBitsSet(SDValue A, SDValue B) const
Return true if A and B have no common bits set.
static const APInt * getValidShiftAmountConstant(SDValue V)
If a SHL/SRA/SRL node has a constant or splat constant shift amount that is less than the element bit...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Libcall getMEMCPY_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize)
getMEMCPY_ELEMENT_UNORDERED_ATOMIC - Return MEMCPY_ELEMENT_UNORDERED_ATOMIC_* value for the given ele...
Abstract base class for all machine specific constantpool value subclasses.
This structure contains all information that is necessary for lowering calls.
SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget=false, bool IsOpaque=false)
This class contains a discriminated union of information about pointers in memory operands...
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode...
APInt ssub_sat(const APInt &RHS) const
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.
HANDLENODE node - Used as a handle for various purposes.
void copySign(const APFloat &RHS)
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...
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
SDValue getBoolConstant(bool V, const SDLoc &DL, EVT VT, EVT OpVT)
Create a true or false constant of type VT using the target's BooleanContent for type OpVT...
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.
ConstantFPSDNode * getConstantFPSplatNode(BitVector *UndefElements=nullptr) const
Returns the splatted constant FP or null if this is not a constant FP splat.
unsigned getMaxStoresPerMemcpy(bool OptSize) const
Get maximum # of store operations permitted for llvm.memcpy.
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
ConstantFPSDNode * isConstOrConstSplatFP(SDValue N, bool AllowUndefs=false)
Returns the SDNode if it is a constant splat BuildVector or constant float.
MachineMemOperand * MMO
Memory reference information.
void sort(IteratorTy Start, IteratorTy End)
static const char *const Magic
unsigned getAddressSpace() const
The memory access writes data.
SDDbgValue * getDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R, bool IsIndirect, const DebugLoc &DL, unsigned O)
Creates a SDDbgValue node.
SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type...
bool use_empty() const
Return true if there are no uses of this node.
SDNode * getNode() const
Convenience function for get().getNode().
static APInt getSignMask(unsigned BitWidth)
Get the SignMask for a specific bit width.
APInt ashr(unsigned ShiftAmt) const
Arithmetic right-shift function.
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...
bool areNonVolatileConsecutiveLoads(LoadSDNode *LD, LoadSDNode *Base, unsigned Bytes, int Dist) const
Return true if loads are next to each other and can be merged.
SDValue expandVACopy(SDNode *Node)
Expand the specified ISD::VACOPY node as the Legalize pass would.
bool isBuildVectorAllOnes(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR where all of the elements are ~0 or undef...
void dump() const
Dump this node, for debugging.
static const fltSemantics & IEEEsingle() LLVM_READNONE
const TargetLowering & getTargetLoweringInfo() const
Iterator for intrusive lists based on ilist_node.
unsigned countMaxLeadingZeros() const
Returns the maximum number of leading zero bits possible.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is the shared class of boolean and integer constants.
BlockVerifier::State From
static const fltSemantics & IEEEhalf() LLVM_READNONE
Returns platform specific canonical encoding of a floating point number.
virtual void NodeDeleted(SDNode *N, SDNode *E)
The node N that was deleted and, if E is not null, an equivalent node E that replaced it...
bool erase(PtrType Ptr)
erase - If the set contains the specified pointer, remove it and return true, otherwise return false...
ilist< SDNode >::size_type allnodes_size() const
virtual bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace=0, unsigned Align=1, bool *=nullptr) const
Determine if the target supports unaligned memory accesses.
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
EVT getVectorElementType() const
Given a vector type, return the type of each element.
std::pair< SDValue, SDValue > SplitVector(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HiVT)
Split the vector with EXTRACT_SUBVECTOR using the provides VTs and return the low/high part...
SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
static MachinePointerInfo InferPointerInfo(const MachinePointerInfo &Info, SelectionDAG &DAG, SDValue Ptr, int64_t Offset=0)
InferPointerInfo - If the specified ptr/offset is a frame index, infer a MachinePointerInfo record fr...
bool hasFloatingPointExceptions() const
Return true if target supports floating point exceptions.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDDbgValue * getFrameIndexDbgValue(DIVariable *Var, DIExpression *Expr, unsigned FI, bool IsIndirect, const DebugLoc &DL, unsigned O)
Creates a FrameIndex SDDbgValue node.
X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and rounds it to a floating point val...
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...
ADDRSPACECAST - This operator converts between pointers of different address spaces.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
uint64_t Length
Length of the slice.
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
Provides information about what library functions are available for the current target.
static APInt getSplat(unsigned NewLen, const APInt &V)
Return a value containing V broadcasted over NewLen bits.
const DebugLoc & getDebugLoc() const
SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
bool allOperandsUndef(const SDNode *N)
Return true if the node has at least one operand and all operands of the specified node are ISD::UNDE...
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimum or maximum on two values, following the IEEE-754 2008 definition.
An SDNode that represents everything that will be needed to construct a MachineInstr.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Byte Swap and Counting operators.
APInt rotl(unsigned rotateAmt) const
Rotate left by rotateAmt.
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
LLVM_NODISCARD T pop_back_val()
This is an abstract virtual class for memory operations.
const Constant * getConstVal() const
SDValue getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
void ExtractVectorElements(SDValue Op, SmallVectorImpl< SDValue > &Args, unsigned Start=0, unsigned Count=0)
Append the extracted elements from Start to Count out of the vector Op in Args.
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.
static const int FIRST_TARGET_MEMORY_OPCODE
FIRST_TARGET_MEMORY_OPCODE - Target-specific pre-isel operations which do not reference a specific me...
Represents one node in the SelectionDAG.
void computeKnownBitsFromRangeMetadata(const MDNode &Ranges, KnownBits &Known)
Compute known bits from the range metadata.
virtual void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const
Determine which of the bits specified in Mask are known to be either zero or one and return them in t...
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
CondCode getSetCCInverse(CondCode Operation, bool isInteger)
Return the operation corresponding to !(X op Y), where 'op' is a valid SetCC operation.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
static BaseIndexOffset match(const LSBaseSDNode *N, const SelectionDAG &DAG)
Parses tree in Ptr for base, index, offset addresses.
allnodes_const_iterator allnodes_begin() const
SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a bitwise NOT operation as (XOR Val, -1).
unsigned getEVTAlignment(EVT MemoryVT) const
Compute the default alignment value for the given type.
static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, unsigned Align, bool isVol, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
unsigned char getTargetFlags() const
const Function & getFunction() const
Return the LLVM function that this machine code represents.
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.
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
SDNode * isConstantIntBuildVectorOrConstantInt(SDValue N)
Test whether the given value is a constant int or similar node.
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.
bool isBuildVectorOfConstantFPSDNodes(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR node of all ConstantFPSDNode or undef...
SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, bool isTarget=false)
Create a ConstantFPSDNode wrapping a constant value.
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
iterator_range< use_iterator > uses()
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
SDValue FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT, SDNode *Cst1, SDNode *Cst2)
A "pseudo-class" with methods for operating on BUILD_VECTORs.
Select(COND, TRUEVAL, FALSEVAL).
SDValue peekThroughOneUseBitcasts(SDValue V)
Return the non-bitcasted and one-use source operand of V if it exists.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
bool sge(const APInt &RHS) const
Signed greater or equal comparison.
static use_iterator use_end()
bool isNullFPConstant(SDValue V)
Returns true if V is an FP constant with a value of positive zero.
ZERO_EXTEND - Used for integer types, zeroing the new bits.
void AddDbgLabel(SDDbgLabel *DB)
Add a dbg_label SDNode.
ANY_EXTEND - Used for integer types. The high bits are undefined.
opStatus mod(const APFloat &RHS)
iterator insert(iterator I, T &&Elt)
CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger)
Return the result of a logical OR between different comparisons of identical values: ((X op1 Y) | (X ...
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
unsigned countMinLeadingOnes() const
Returns the minimum number of leading one bits.
int getMaskElt(unsigned Idx) const
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
SDValue getShiftAmountOperand(EVT LHSTy, SDValue Op)
Return the specified value casted to the target's desired shift amount type.
SDValue FoldConstantVectorArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDValue > Ops, const SDNodeFlags Flags=SDNodeFlags())
SDValue getBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, bool isTarget=false, unsigned char TargetFlags=0)
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
Flags
Flags values. These may be or'd together.
bool isUnknown() const
Returns true if we don't know any bits.
The memory access reads data.
bool none() const
none - Returns true if none of the bits are set.
int getNodeId() const
Return the unique node id.
SDDbgLabel * getDbgLabel(DILabel *Label, const DebugLoc &DL, unsigned O)
Creates a SDDbgLabel node.
bool isConstantValueOfAnyType(SDValue N)
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
CallLoweringInfo & setTailCall(bool Value=true)
opStatus add(const APFloat &RHS, roundingMode RM)
bool ugt(const APInt &RHS) const
Unsigned greather than comparison.
SDValue getStackArgumentTokenFactor(SDValue Chain)
Compute a TokenFactor to force all the incoming stack arguments to be loaded from the stack...
opStatus
IEEE-754R 7: Default exception handling.
These are IR-level optimization flags that may be propagated to SDNodes.
allnodes_const_iterator allnodes_end() const
Represents a use of a SDNode.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
ConstantSDNode * isConstOrConstSplat(SDValue N, bool AllowUndefs=false)
Returns the SDNode if it is a constant splat BuildVector or constant int.
const MachinePointerInfo & getPointerInfo() const
bool isVector() const
Return true if this is a vector value type.
static void checkForCyclesHelper(const SDNode *N, SmallPtrSetImpl< const SDNode *> &Visited, SmallPtrSetImpl< const SDNode *> &Checked, const llvm::SelectionDAG *DAG)
const SDValue & getValue() const
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.
Value is the result of an expression.
Holds the information from a dbg_label node through SDISel.
bool isOnlyUserOf(const SDNode *N) const
Return true if this node is the only use of N.
static bool shouldLowerMemFuncForSize(const MachineFunction &MF)
int32_t getConstantFPSplatPow2ToLog2Int(BitVector *UndefElements, uint32_t BitWidth) const
If this is a constant FP splat and the splatted constant FP is an exact power or 2, return the log base 2 integer value.
virtual bool isSDNodeSourceOfDivergence(const SDNode *N, FunctionLoweringInfo *FLI, LegacyDivergenceAnalysis *DA) const
LLVM_NODISCARD bool empty() const
bool isKnownToBeAPowerOfTwo(SDValue Val) const
Test if the given value is known to have exactly one bit set.
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
virtual bool isKnownNeverNaNForTargetNode(SDValue Op, const SelectionDAG &DAG, bool SNaN=false, unsigned Depth=0) const
If SNaN is false,.
static bool isMemSrcFromConstant(SDValue Src, ConstantDataArraySlice &Slice)
Returns true if memcpy source is constant data.
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
APInt srem(const APInt &RHS) const
Function for signed remainder operation.
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 ...
int64_t getOffset() const
const ConstantInt * getConstantIntValue() const
const TargetSubtargetInfo & getSubtarget() const
Flags getFlags() const
Return the raw flags of the source value,.
bool optForMinSize() const
Optimize this function for minimum size (-Oz).
The memory access always returns the same value (or traps).
bool isDereferenceable() const
unsigned InferPtrAlignment(SDValue Ptr) const
Infer alignment of a load / store address.
static std::pair< APInt, bool > FoldValue(unsigned Opcode, const APInt &C1, const APInt &C2)
static void NewSDValueDbgMsg(SDValue V, StringRef Msg, SelectionDAG *G)
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 ...
SDValue matchBinOpReduction(SDNode *Extract, ISD::NodeType &BinOp, ArrayRef< ISD::NodeType > CandidateBinOps)
Match a binop + shuffle pyramid that represents a horizontal reduction over the elements of a vector ...
MemSDNode(unsigned Opc, unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT memvt, MachineMemOperand *MMO)
void Profile(FoldingSetNodeID &ID) const
Gather unique data for the node.
unsigned getOpcode() const
SDValue getValue(unsigned R) const
static int isSignedOp(ISD::CondCode Opcode)
For an integer comparison, return 1 if the comparison is a signed operation and 2 if the result is an...
Type * getType() const
getType - get type of this MachineConstantPoolValue.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
This class is used to represent an MSCATTER node.
bool reachesChainWithoutSideEffects(SDValue Dest, unsigned Depth=2) const
Return true if this operand (which must be a chain) reaches the specified operand without crossing an...
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
SDValue getAtomicMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst, unsigned DstAlign, SDValue Src, unsigned SrcAlign, SDValue Size, Type *SizeTy, unsigned ElemSz, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
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)
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...
unsigned getMaxStoresPerMemmove(bool OptSize) const
Get maximum # of store operations permitted for llvm.memmove.
const MachinePointerInfo & getPointerInfo() const
ConstantSDNode * getConstantSplatNode(BitVector *UndefElements=nullptr) const
Returns the splatted constant or null if this is not a constant splat.
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
MachineConstantPoolValue * getMachineCPVal() const
static bool FindOptimalMemOpLowering(std::vector< EVT > &MemOps, unsigned Limit, uint64_t Size, unsigned DstAlign, unsigned SrcAlign, bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc, bool AllowOverlap, unsigned DstAS, unsigned SrcAS, SelectionDAG &DAG, const TargetLowering &TLI)
Determines the optimal series of memory ops to replace the memset / memcpy.
bool isSplatValue(SDValue V, const APInt &DemandedElts, APInt &UndefElts)
Test whether V has a splatted value for all the demanded elements.
SDValue getJumpTable(int JTI, EVT VT, bool isTarget=false, unsigned char TargetFlags=0)
This class is used to form a handle around another node that is persistent and is updated across invo...
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())
opStatus fusedMultiplyAdd(const APFloat &Multiplicand, const APFloat &Addend, roundingMode RM)
SDValue simplifySelect(SDValue Cond, SDValue TVal, SDValue FVal)
Try to simplify a select/vselect into 1 of its operands or a constant.
bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
This class is used to represent an MLOAD node.
unsigned getRawSubclassData() const
Return the SubclassData value, without HasDebugValue.
bool operator<(int64_t V1, const APSInt &V2)
unsigned getNumSignBits() const
Computes the number of leading bits of this APInt that are equal to its sign bit. ...
A raw_ostream that writes to an std::string.
SDValue getSymbolFunctionGlobalAddress(SDValue Op, Function **TargetFunction=nullptr)
Returs an GlobalAddress of the function from the current module with name matching the given External...
ArrayRef< int > getMask() const
Module * getParent()
Get the module that this global value is contained inside of...
bool needsStackRealignment(const MachineFunction &MF) const
True if storage within the function requires the stack pointer to be aligned more than the normal cal...
LLVM Value Representation.
uint64_t getConstantOperandVal(unsigned Num) const
Helper method returns the integer value of a ConstantSDNode operand.
FMA - Perform a * b + c with no intermediate rounding step.
SDValue getLogicalNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a logical NOT operation as (XOR Val, BooleanOne).
SDValue getRegister(unsigned Reg, EVT VT)
unsigned getResNo() const
get the index which selects a specific result in the SDNode
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...
const MDNode * getRanges() const
Returns the Ranges that describes the dereference.
MemSDNodeBitfields MemSDNodeBits
static ConstantSDNode * isConstOrDemandedConstSplat(SDValue N, const APInt &DemandedElts)
Helper function that checks to see if a node is a constant or a build vector of splat constants at le...
bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
void setDebugLoc(DebugLoc dl)
Set source location info.
This class is used to represent an MGATHER node.
intptr_t getRawBits() const
SDValue getValueType(EVT)
KnownBits sext(unsigned BitWidth)
Sign extends the underlying known Zero and One bits.
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.
SDValue getFPExtendOrRound(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of float type, to the float type VT, by either extending or rounding (by tr...
PREFETCH - This corresponds to a prefetch intrinsic.
bool isDereferenceable(unsigned Size, LLVMContext &C, const DataLayout &DL) const
Return true if memory region [V, V+Offset+Size) is known to be dereferenceable.
void setHasDebugValue(bool b)
bool isUndef() const
Return true if the type of the node type undefined.
MVT getFrameIndexTy(const DataLayout &DL) const
Return the type for frame index, which is determined by the alloca address space specified through th...
void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.getNode() alone...
SDValue getEHLabel(const SDLoc &dl, SDValue Root, MCSymbol *Label)
Primary interface to the complete machine description for the target machine.
unsigned countMinLeadingZeros() const
Returns the minimum number of leading zero bits.
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
SDValue getSrcValue(const Value *v)
Construct a node to track a Value* through the backend.
print Print MemDeps of function
ArrayRef< SDDbgValue * > GetDbgValues(const SDNode *SD) const
Get the debug values which reference the given SDNode.
APInt usub_sat(const APInt &RHS) const
virtual const SelectionDAGTargetInfo * getSelectionDAGInfo() const
StringRef - Represent a constant reference to a string, i.e.
FMAD - Perform a * b + c, while getting the same result as the separately rounded operations...
bool isNonNegative() const
Returns true if this value is known to be non-negative.
SetCC operator - This evaluates to a true value iff the condition is true.
virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const
Return true if folding a constant offset with the given GlobalAddress is legal.
APInt bitcastToAPInt() const
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
void salvageDebugInfo(SDNode &N)
To be invoked on an SDNode that is slated to be erased.
unsigned countLeadingZeros() const
The APInt version of the countLeadingZeros functions in MathExtras.h.
void move(uint64_t Delta)
Moves the Offset and adjusts Length accordingly.
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...
unsigned getNumOperands() const
BooleanContent
Enum that describes how the target represents true/false values.
static void AddNodeIDOpcode(FoldingSetNodeID &ID, unsigned OpC)
AddNodeIDOpcode - Add the node opcode to the NodeID data.
static APInt getNullValue(unsigned numBits)
Get the '0' value.
const SDValue & getOperand(unsigned i) const
static ManagedStatic< EVTArray > SimpleVTArray
OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val) This corresponds to "store atomic" instruction.
uint64_t getZExtValue() const
SDValue getTargetInsertSubreg(int SRIdx, const SDLoc &DL, EVT VT, SDValue Operand, SDValue Subreg)
A convenience function for creating TargetInstrInfo::INSERT_SUBREG nodes.
SDNode * getNodeIfExists(unsigned Opcode, SDVTList VTList, ArrayRef< SDValue > Ops, const SDNodeFlags Flags=SDNodeFlags())
Get the specified node if it's already available, or else return NULL.
TRUNCATE - Completely drop the high bits.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
bool hasPredecessor(const SDNode *N) const
Return true if N is a predecessor of this node.
APInt sadd_sat(const APInt &RHS) const
Libcall getMEMSET_ELEMENT_UNORDERED_ATOMIC(uint64_t ElementSize)
getMEMSET_ELEMENT_UNORDERED_ATOMIC - Return MEMSET_ELEMENT_UNORDERED_ATOMIC_* value for the given ele...
void setNodeMemRefs(MachineSDNode *N, ArrayRef< MachineMemOperand *> NewMemRefs)
Mutate the specified machine node's memory references to the provided list.
void erase(const SDNode *Node)
Invalidate all DbgValues attached to the node and remove it from the Node-to-DbgValues map...
OutputIt copy(R &&Range, OutputIt Out)
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
unsigned getMinStackArgumentAlignment() const
Return the minimum stack alignment of an argument.
Holds the information from a dbg_value node through SDISel.
virtual unsigned getMaxGluedStoresPerMemcpy() const
Get maximum # of store operations to be glued together.
Perform various unary floating-point operations inspired by libm.
void setObjectAlignment(int ObjectIdx, unsigned Align)
setObjectAlignment - Change the alignment of the specified stack object.
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.
static void AddNodeIDCustom(FoldingSetNodeID &ID, const SDNode *N)
If this is an SDNode with special info, add this info to the NodeID data.
virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast between SrcAS and DestAS is a noop.
static IntegerType * getInt8Ty(LLVMContext &C)
SDValue getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool isTailCall, MachinePointerInfo DstPtrInfo)
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
bool isExtended() const
Test if the given EVT is extended (as opposed to being simple).
LLVMContext * getContext() const
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
static bool isSplatMask(const int *Mask, EVT VT)
virtual bool isSDNodeAlwaysUniform(const SDNode *N) const
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
void setLowBits(unsigned loBits)
Set the bottom loBits bits.
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL, bool LegalTypes=true) const
PointerType * getType() const
Global values are always pointers.
Carry-using nodes for multiple precision addition and subtraction.
bool empty() const
empty - Check if the array is empty.
unsigned getIROrder() const
static Optional< DIExpression * > createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits)
Create a DIExpression to describe one part of an aggregate variable that is fragmented across multipl...
SDValue expandVAArg(SDNode *Node)
Expand the specified ISD::VAARG node as the Legalize pass would.
This file describes how to lower LLVM code to machine code.
virtual bool isLegalStoreImmediate(int64_t Value) const
Return true if the specified immediate is legal for the value input of a store instruction.
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
static SDVTList makeVTList(const EVT *VTs, unsigned NumVTs)
makeVTList - Return an instance of the SDVTList struct initialized with the specified members...
SRCVALUE - This is a node type that holds a Value* that is used to make reference to a value in the L...
This class is used to represent ISD::LOAD nodes.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.