78 for (
unsigned I = 0,
E = ArgLocs.
size();
I !=
E; ++
I) {
118 std::pair<SDValue, SDValue>
121 const SDLoc &dl,
bool doesNotReturn,
122 bool isReturnValueUsed)
const {
124 Args.reserve(Ops.
size());
132 Args.push_back(Entry);
146 .setNoReturn(doesNotReturn)
150 return LowerCallTo(CLI);
158 const SDLoc &dl)
const {
160 &&
"Unsupported setcc type!");
164 bool ShouldInvertCC =
false;
231 ShouldInvertCC =
true;
259 SDValue Ops[2] = {NewLHS, NewRHS};
260 NewLHS = makeLibCall(DAG, LC1, RetVT, Ops,
false ,
273 NewLHS = makeLibCall(DAG, LC2, RetVT, Ops,
false,
288 if (!isPositionIndependent())
302 unsigned JTEncoding = getJumpTableEncoding();
331 if (isPositionIndependent())
352 if (targetShrinkDemandedConstant(Op, Demanded, TLO))
367 const APInt &
C = Op1C->getAPIntValue();
389 const APInt &Demanded,
392 "ShrinkDemandedOp only supports binary operators!");
394 "ShrinkDemandedOp only supports nodes with one result!");
412 unsigned SmallVTBits = DemandedSize;
415 for (; SmallVTBits < BitWidth; SmallVTBits =
NextPowerOf2(SmallVTBits)) {
424 bool NeedZext = DemandedSize > SmallVTBits;
435 const APInt &Demanded,
441 if (!SimplifyDemandedBits(Op, Demanded, Known, TLO, 0,
true))
491 bool Simplified = SimplifyDemandedBits(Op, DemandedMask, Known, TLO);
505 const APInt &DemandedMask,
509 bool AssumeSingleUse)
const {
512 "Mask size mismatches value type size!");
513 APInt NewMask = DemandedMask;
531 }
else if (DemandedMask == 0) {
536 }
else if (Depth == 6) {
544 Known.
One = cast<ConstantSDNode>(
Op)->getAPIntValue();
551 if (!isa<ConstantSDNode>(SrcOp)) {
556 Known2.
One = cast<ConstantSDNode>(SrcOp)->getAPIntValue();
562 "Expected BUILD_VECTOR implicit truncation");
563 Known2 = Known2.
trunc(BitWidth);
583 if ((LHSKnown.
Zero & NewMask) == (~RHSC->getAPIntValue() & NewMask))
597 LHSKnown.
One == ~RHSC->getAPIntValue()) {
604 if (SimplifyDemandedBits(Op.
getOperand(1), NewMask, Known, TLO, Depth+1))
606 assert(!Known.hasConflict() &&
"Bits known to be one AND zero?");
607 if (SimplifyDemandedBits(Op.
getOperand(0), ~Known.Zero & NewMask,
608 Known2, TLO, Depth+1))
610 assert(!Known2.hasConflict() &&
"Bits known to be one AND zero?");
614 if (NewMask.isSubsetOf(Known2.Zero | Known.One))
616 if (NewMask.isSubsetOf(Known.Zero | Known2.One))
619 if (NewMask.isSubsetOf(Known.Zero | Known2.Zero))
620 return TLO.CombineTo(Op, TLO.DAG.getConstant(0, dl, Op.
getValueType()));
625 if (ShrinkDemandedOp(Op, BitWidth, NewMask, TLO))
629 Known.One &= Known2.One;
631 Known.Zero |= Known2.Zero;
634 if (SimplifyDemandedBits(Op.
getOperand(1), NewMask, Known, TLO, Depth+1))
636 assert(!Known.hasConflict() &&
"Bits known to be one AND zero?");
637 if (SimplifyDemandedBits(Op.
getOperand(0), ~Known.One & NewMask,
638 Known2, TLO, Depth+1))
640 assert(!Known2.hasConflict() &&
"Bits known to be one AND zero?");
644 if (NewMask.isSubsetOf(Known2.One | Known.Zero))
646 if (NewMask.isSubsetOf(Known.One | Known2.Zero))
652 if (ShrinkDemandedOp(Op, BitWidth, NewMask, TLO))
656 Known.Zero &= Known2.Zero;
658 Known.One |= Known2.One;
661 if (SimplifyDemandedBits(Op.
getOperand(1), NewMask, Known, TLO, Depth+1))
663 assert(!Known.hasConflict() &&
"Bits known to be one AND zero?");
664 if (SimplifyDemandedBits(Op.
getOperand(0), NewMask, Known2, TLO, Depth+1))
666 assert(!Known2.hasConflict() &&
"Bits known to be one AND zero?");
670 if (NewMask.isSubsetOf(Known.Zero))
672 if (NewMask.isSubsetOf(Known2.Zero))
675 if (ShrinkDemandedOp(Op, BitWidth, NewMask, TLO))
681 if ((NewMask & ~Known.Zero & ~Known2.Zero) == 0)
687 KnownOut.
Zero = (Known.Zero & Known2.Zero) | (Known.One & Known2.One);
689 KnownOut.
One = (Known.Zero & Known2.One) | (Known.One & Known2.Zero);
696 if (NewMask.isSubsetOf(Known.Zero|Known.One)) {
697 if (Known.One == Known2.One) {
699 SDValue ANDC = TLO.DAG.getConstant(~Known.One & NewMask, dl, VT);
713 return TLO.CombineTo(Op, New);
720 Known = std::move(KnownOut);
724 if (SimplifyDemandedBits(Op.
getOperand(2), NewMask, Known, TLO, Depth+1))
726 if (SimplifyDemandedBits(Op.
getOperand(1), NewMask, Known2, TLO, Depth+1))
728 assert(!Known.hasConflict() &&
"Bits known to be one AND zero?");
729 assert(!Known2.hasConflict() &&
"Bits known to be one AND zero?");
736 Known.One &= Known2.One;
737 Known.Zero &= Known2.Zero;
740 if (SimplifyDemandedBits(Op.
getOperand(3), NewMask, Known, TLO, Depth+1))
742 if (SimplifyDemandedBits(Op.
getOperand(2), NewMask, Known2, TLO, Depth+1))
744 assert(!Known.hasConflict() &&
"Bits known to be one AND zero?");
745 assert(!Known2.hasConflict() &&
"Bits known to be one AND zero?");
752 Known.One &= Known2.One;
753 Known.Zero &= Known2.Zero;
764 BooleanContent::ZeroOrNegativeOneBooleanContent) {
771 return TLO.CombineTo(Op, Op0);
779 Known.Zero.setBitsFrom(1);
784 unsigned ShAmt = SA->getZExtValue();
788 if (ShAmt >= BitWidth)
797 unsigned C1= cast<ConstantSDNode>(InOp.
getOperand(1))->getZExtValue();
808 return TLO.CombineTo(Op, TLO.DAG.
getNode(Opc, dl, VT,
813 if (SimplifyDemandedBits(InOp, NewMask.lshr(ShAmt), Known, TLO, Depth+1))
822 if (ShAmt < InnerBits && NewMask.getActiveBits() <= InnerBits &&
823 isTypeDesirableForOp(
ISD::SHL, InnerVT)) {
829 TLO.DAG.getConstant(ShAmt, dl, ShTy));
844 unsigned InnerShAmt = cast<ConstantSDNode>(InnerOp.
getOperand(1))
846 if (InnerShAmt < ShAmt &&
847 InnerShAmt < InnerBits &&
848 NewMask.getActiveBits() <= (InnerBits - InnerShAmt + ShAmt) &&
849 NewMask.countTrailingZeros() >= ShAmt) {
851 TLO.DAG.getConstant(ShAmt - InnerShAmt, dl,
862 Known.Zero <<= SA->getZExtValue();
863 Known.One <<= SA->getZExtValue();
865 Known.Zero.setLowBits(SA->getZExtValue());
871 unsigned ShAmt = SA->getZExtValue();
876 if (ShAmt >= BitWidth)
879 APInt InDemandedMask = (NewMask << ShAmt);
892 unsigned C1= cast<ConstantSDNode>(InOp.
getOperand(1))->getZExtValue();
902 return TLO.CombineTo(Op, TLO.DAG.
getNode(Opc, dl, VT,
908 if (SimplifyDemandedBits(InOp, InDemandedMask, Known, TLO, Depth+1))
910 assert(!Known.hasConflict() &&
"Bits known to be one AND zero?");
911 Known.Zero.lshrInPlace(ShAmt);
912 Known.One.lshrInPlace(ShAmt);
914 Known.Zero.setHighBits(ShAmt);
922 if (NewMask.isOneValue())
923 return TLO.CombineTo(Op,
929 unsigned ShAmt = SA->getZExtValue();
932 if (ShAmt >= BitWidth)
935 APInt InDemandedMask = (NewMask << ShAmt);
944 if (NewMask.countLeadingZeros() < ShAmt)
947 if (SimplifyDemandedBits(Op.
getOperand(0), InDemandedMask, Known, TLO,
950 assert(!Known.hasConflict() &&
"Bits known to be one AND zero?");
951 Known.Zero.lshrInPlace(ShAmt);
952 Known.One.lshrInPlace(ShAmt);
956 if (Known.Zero[BitWidth - ShAmt - 1] ||
957 NewMask.countLeadingZeros() >= ShAmt) {
960 return TLO.CombineTo(Op,
965 int Log2 = NewMask.exactLogBase2();
969 TLO.DAG.getConstant(BitWidth - 1 - Log2, dl,
975 if (Known.One[BitWidth - ShAmt - 1])
977 Known.One.setHighBits(ShAmt);
985 if (MsbMask == NewMask) {
989 bool AlreadySignExtended =
990 TLO.DAG.ComputeNumSignBits(InOp) >= VTBits-ShAmt+1;
993 if (!AlreadySignExtended) {
997 if (TLO.LegalTypes() && !ShiftAmtTy.
isVector())
1000 SDValue ShiftAmt = TLO.DAG.getConstant(BitWidth - ShAmt, dl,
1015 if ((NewBits & NewMask) == 0)
1020 APInt InputDemandedBits =
1027 InputDemandedBits |= InSignBit;
1029 if (SimplifyDemandedBits(Op.
getOperand(0), InputDemandedBits,
1030 Known, TLO, Depth+1))
1032 assert(!Known.hasConflict() &&
"Bits known to be one AND zero?");
1038 if (Known.Zero.intersects(InSignBit))
1039 return TLO.CombineTo(Op, TLO.DAG.getZeroExtendInReg(
1042 if (Known.One.intersects(InSignBit)) {
1043 Known.One |= NewBits;
1044 Known.Zero &= ~NewBits;
1046 Known.Zero &= ~NewBits;
1047 Known.One &= ~NewBits;
1060 if (SimplifyDemandedBits(Op.
getOperand(0), MaskLo, KnownLo, TLO, Depth + 1))
1063 if (SimplifyDemandedBits(Op.
getOperand(1), MaskHi, KnownHi, TLO, Depth + 1))
1066 Known.
Zero = KnownLo.Zero.
zext(BitWidth) |
1067 KnownHi.Zero.
zext(BitWidth).
shl(HalfBitWidth);
1069 Known.One = KnownLo.One.
zext(BitWidth) |
1070 KnownHi.One.
zext(BitWidth).
shl(HalfBitWidth);
1075 APInt InMask = NewMask.
trunc(OperandBitWidth);
1085 if (SimplifyDemandedBits(Op.
getOperand(0), InMask, Known, TLO, Depth+1))
1087 assert(!Known.hasConflict() &&
"Bits known to be one AND zero?");
1088 Known = Known.zext(BitWidth);
1089 Known.Zero |= NewBits;
1097 APInt NewBits = ~InMask & NewMask;
1107 APInt InDemandedBits = InMask & NewMask;
1108 InDemandedBits |= InSignBit;
1109 InDemandedBits = InDemandedBits.
trunc(InBits);
1111 if (SimplifyDemandedBits(Op.
getOperand(0), InDemandedBits, Known, TLO,
1114 Known = Known.
zext(BitWidth);
1117 if (Known.Zero.intersects(InSignBit))
1123 if (Known.One.intersects(InSignBit)) {
1124 Known.One |= NewBits;
1125 assert((Known.Zero & NewBits) == 0);
1127 assert((Known.One & NewBits) == 0);
1128 assert((Known.Zero & NewBits) == 0);
1134 APInt InMask = NewMask.
trunc(OperandBitWidth);
1135 if (SimplifyDemandedBits(Op.
getOperand(0), InMask, Known, TLO, Depth+1))
1137 assert(!Known.hasConflict() &&
"Bits known to be one AND zero?");
1138 Known = Known.zext(BitWidth);
1145 APInt TruncMask = NewMask.
zext(OperandBitWidth);
1146 if (SimplifyDemandedBits(Op.
getOperand(0), TruncMask, Known, TLO, Depth+1))
1148 Known = Known.
trunc(BitWidth);
1159 if (TLO.LegalTypes() &&
1168 if (TLO.LegalTypes()) {
1170 Shift = TLO.DAG.getConstant(ShVal, dl,
1176 OperandBitWidth - BitWidth);
1178 HighBits = HighBits.
trunc(BitWidth);
1180 if (!(HighBits & NewMask)) {
1196 assert(!Known.hasConflict() &&
"Bits known to be one AND zero?");
1205 if (SimplifyDemandedBits(Op.
getOperand(0), ~InMask | NewMask,
1206 Known, TLO, Depth+1))
1208 assert(!Known.hasConflict() &&
"Bits known to be one AND zero?");
1210 Known.Zero |= ~InMask;
1216 if (!TLO.LegalOperations() &&
1231 if (!OpVTLegal && OpVTSizeInBits > 32)
1247 BitWidth - NewMask.countLeadingZeros());
1248 if (SimplifyDemandedBits(Op.
getOperand(0), LoMask, Known2, TLO, Depth+1) ||
1249 SimplifyDemandedBits(Op.
getOperand(1), LoMask, Known2, TLO, Depth+1) ||
1251 ShrinkDemandedOp(Op, BitWidth, NewMask, TLO)) {
1261 return TLO.CombineTo(Op, NewOp);
1269 TLO.DAG.computeKnownBits(Op, Known, Depth);
1275 if (NewMask.isSubsetOf(Known.
Zero|Known.
One)) {
1296 const APInt &DemandedElts,
1298 unsigned Depth)
const {
1303 "Should use MaskedValueIsZero if you don't know whether Op"
1304 " is a target node!");
1313 unsigned Depth)
const {
1318 "Should use ComputeNumSignBits if you don't know whether Op"
1319 " is a target node!");
1331 if (
auto *CN = dyn_cast<ConstantSDNode>(N)) {
1332 CVal = CN->getAPIntValue();
1333 }
else if (
auto *BV = dyn_cast<BuildVectorSDNode>(N)) {
1334 auto *CN = BV->getConstantSplatNode();
1340 unsigned BVEltWidth = BV->getValueType(0).getScalarSizeInBits();
1341 CVal = CN->getAPIntValue();
1343 CVal = CVal.
trunc(BVEltWidth);
1365 ?
APInt(ElementWidth, 1)
1416 DAGCombinerInfo &DCI,
1448 if (DCI.isBeforeLegalizeOps() ||
1450 return DAG.
getSetCC(DL, VT, N0, Zero, Cond);
1461 if (YConst && YConst->isNullValue())
1467 return DAG.
getSetCC(DL, VT, NewAnd, Zero, Cond);
1478 const SDLoc &dl)
const {
1498 if (isa<ConstantSDNode>(N0.
getNode()) &&
1501 return DAG.
getSetCC(dl, VT, N1, N0, SwappedCC);
1503 if (
auto *N1C = dyn_cast<ConstantSDNode>(N1.
getNode())) {
1504 const APInt &C1 = N1C->getAPIntValue();
1513 = cast<ConstantSDNode>(N0.
getOperand(1))->getAPIntValue();
1564 MinBits = N0->getOperand(0).getValueSizeInBits();
1566 }
else if (N0->getOpcode() ==
ISD::AND) {
1568 if (
auto *
C = dyn_cast<ConstantSDNode>(N0->getOperand(1)))
1569 if ((
C->getAPIntValue()+1).isPowerOf2()) {
1570 MinBits =
C->getAPIntValue().countTrailingOnes();
1575 MinBits = N0->getOperand(0).getValueSizeInBits();
1578 }
else if (
auto *LN0 = dyn_cast<LoadSDNode>(N0)) {
1581 MinBits = LN0->getMemoryVT().getSizeInBits();
1585 MinBits = LN0->getMemoryVT().getSizeInBits();
1591 unsigned ReqdBits = Signed ?
1598 MinBits >= ReqdBits) {
1600 if (isTypeDesirableForOp(
ISD::SETCC, MinVT)) {
1603 if (MinBits == 1 && C1 == 1)
1608 return DAG.
getSetCC(dl, VT, Trunc, C, Cond);
1625 (isConstFalseVal(N1C) ||
1626 isExtendedTrueVal(N1C, N0->getValueType(0), SExt))) {
1635 cast<CondCodeSDNode>(TopSetCC.
getOperand(2))->
get(),
1649 N0.getOpcode() ==
ISD::AND && C1 == 0 &&
1650 N0.getNode()->hasOneUse() &&
1651 isa<LoadSDNode>(N0.getOperand(0)) &&
1652 N0.getOperand(0).getNode()->hasOneUse() &&
1653 isa<ConstantSDNode>(N0.getOperand(1))) {
1654 LoadSDNode *Lod = cast<LoadSDNode>(N0.getOperand(0));
1656 unsigned bestWidth = 0, bestOffset = 0;
1658 unsigned origWidth = N0.getValueSizeInBits();
1659 unsigned maskWidth = origWidth;
1665 cast<ConstantSDNode>(N0.getOperand(1))->getAPIntValue();
1666 for (
unsigned width = origWidth / 2; width>=8; width /= 2) {
1668 for (
unsigned offset=0; offset<origWidth/width; offset++) {
1671 bestOffset = (uint64_t)offset * (width/8);
1673 bestOffset = (origWidth/width - offset - 1) * (width/8);
1674 bestMask = Mask.
lshr(offset * (width/8) * 8);
1687 if (bestOffset != 0)
1710 C1.getBitWidth() - InSize))) {
1727 return DAG.
getConstant(C1.isNonNegative(), dl, VT);
1741 EVT newVT = N0.getOperand(0).getValueType();
1760 EVT ExtSrcTy = cast<VTSDNode>(N0.getOperand(1))->getVT();
1762 EVT ExtDstTy = N0.getValueType();
1767 if (C1.getMinSignedBits() > ExtSrcTyBits)
1771 EVT Op0Ty = N0.getOperand(0).getValueType();
1772 if (Op0Ty == ExtSrcTy) {
1782 return DAG.
getSetCC(dl, VT, ZextOp,
1788 }
else if ((N1C->isNullValue() || N1C->isOne()) &&
1793 bool TrueWhenTrue = (Cond ==
ISD::SETEQ) ^ (!N1C->isOne());
1797 ISD::CondCode CC = cast<CondCodeSDNode>(N0.getOperand(2))->
get();
1799 N0.getOperand(0).getValueType().isInteger());
1802 return DAG.
getSetCC(dl, VT, N0.getOperand(0), N0.getOperand(1), CC);
1807 N0.getOperand(0).getOpcode() ==
ISD::XOR &&
1808 N0.getOperand(1) == N0.getOperand(0).getOperand(1))) &&
1809 isa<ConstantSDNode>(N0.getOperand(1)) &&
1810 cast<ConstantSDNode>(N0.getOperand(1))->isOne()) {
1823 N0.getOperand(0).getOpcode() ==
ISD::XOR);
1826 N0.getOperand(0).getOperand(0),
1830 return DAG.
getSetCC(dl, VT, Val, N1,
1833 }
else if (N1C->isOne() &&
1851 cast<ConstantSDNode>(Op0.
getOperand(1))->isOne()) {
1874 APInt MinVal, MaxVal;
1875 unsigned OperandBitSize = N1C->getValueType(0).getSizeInBits();
1895 (!N1C->isOpaque() || (N1C->isOpaque() && C.
getBitWidth() <= 64 &&
1913 (!N1C->isOpaque() || (N1C->isOpaque() && C.
getBitWidth() <= 64 &&
1969 (VT == N0.getValueType() ||
1973 if (
auto *AndRHS = dyn_cast<ConstantSDNode>(N0.getOperand(1))) {
1979 if (AndRHS->getAPIntValue().isPowerOf2()) {
1982 DAG.
getConstant(AndRHS->getAPIntValue().logBase2(), dl,
1985 }
else if (Cond ==
ISD::SETEQ && C1 == AndRHS->getAPIntValue()) {
1988 if (C1.isPowerOf2()) {
1998 if (C1.getMinSignedBits() <= 64 &&
2002 N0.getOpcode() ==
ISD::AND && N0.hasOneUse()) {
2003 if (
auto *AndRHS = dyn_cast<ConstantSDNode>(N0.getOperand(1))) {
2004 const APInt &AndRHSC = AndRHS->getAPIntValue();
2005 if ((-AndRHSC).isPowerOf2() && (AndRHSC & C1) == C1) {
2011 EVT CmpTy = N0.getValueType();
2016 return DAG.
getSetCC(dl, VT, Shift, CmpRHS, Cond);
2030 ShiftBits = C1.countTrailingOnes();
2034 ShiftBits = C1.countTrailingZeros();
2043 EVT CmpTy = N0.getValueType();
2047 return DAG.
getSetCC(dl, VT, Shift, CmpRHS, NewCond);
2053 if (isa<ConstantFPSDNode>(N0.
getNode())) {
2057 }
else if (
auto *CFP = dyn_cast<ConstantFPSDNode>(N1.
getNode())) {
2060 if (CFP->getValueAPF().isNaN()) {
2078 return DAG.
getSetCC(dl, VT, N0, N0, Cond);
2096 if (CFP->getValueAPF().isInfinity()) {
2097 if (CFP->getValueAPF().isNegative()) {
2156 return DAG.
getSetCC(dl, VT, N0, N1, NewCond);
2182 bool LegalRHSImm =
false;
2184 if (
auto *RHSC = dyn_cast<ConstantSDNode>(N1)) {
2185 if (
auto *LHSR = dyn_cast<ConstantSDNode>(N0.
getOperand(1))) {
2190 LHSR->getAPIntValue(),
2202 RHSC->getAPIntValue(),
2213 RHSC->getAPIntValue(),
2220 if (RHSC->getValueType(0).getSizeInBits() <= 64)
2277 if (
SDValue V = simplifySetCCWithAnd(VT, N0, N1, Cond, DCI, dl))
2339 if (
auto *GASD = dyn_cast<GlobalAddressSDNode>(N)) {
2340 GA = GASD->getGlobal();
2341 Offset += GASD->getOffset();
2349 if (
auto *V = dyn_cast<ConstantSDNode>(N2)) {
2350 Offset += V->getSExtValue();
2354 if (
auto *V = dyn_cast<ConstantSDNode>(N1)) {
2355 Offset += V->getSExtValue();
2376 unsigned S = Constraint.
size();
2379 switch (Constraint[0]) {
2381 case 'r':
return C_RegisterClass;
2407 if (S > 1 && Constraint[0] ==
'{' && Constraint[S-1] ==
'}') {
2408 if (S == 8 && Constraint.
substr(1, 6) ==
"memory")
2429 std::string &Constraint,
2430 std::vector<SDValue> &Ops,
2433 if (Constraint.length() > 1)
return;
2435 char ConstraintLetter = Constraint[0];
2436 switch (ConstraintLetter) {
2470 if (ConstraintLetter !=
'n') {
2471 int64_t Offs = GA->getOffset();
2474 C ?
SDLoc(C) : SDLoc(),
2481 if (ConstraintLetter !=
's') {
2495 std::pair<unsigned, const TargetRegisterClass *>
2499 if (Constraint.
empty() || Constraint[0] !=
'{')
2500 return std::make_pair(0u, static_cast<TargetRegisterClass*>(
nullptr));
2501 assert(*(Constraint.
end()-1) ==
'}' &&
"Not a brace enclosed constraint?");
2506 std::pair<unsigned, const TargetRegisterClass*> R =
2507 std::make_pair(0u, static_cast<const TargetRegisterClass*>(
nullptr));
2519 std::pair<unsigned, const TargetRegisterClass*> S =
2520 std::make_pair(*
I, RC);
2542 assert(!ConstraintCode.empty() &&
"No known constraint!");
2543 return isdigit(static_cast<unsigned char>(ConstraintCode[0]));
2549 assert(!ConstraintCode.empty() &&
"No known constraint!");
2550 return atoi(ConstraintCode.c_str());
2565 unsigned maCount = 0;
2573 ConstraintOperands.emplace_back(std::move(CI));
2583 switch (OpInfo.
Type) {
2599 assert(ResNo == 0 &&
"Asm only has one result!");
2622 if (
StructType *STy = dyn_cast<StructType>(OpTy))
2623 if (STy->getNumElements() == 1)
2624 OpTy = STy->getElementType(0);
2642 }
else if (
PointerType *PT = dyn_cast<PointerType>(OpTy)) {
2652 if (!ConstraintOperands.empty()) {
2654 unsigned bestMAIndex = 0;
2655 int bestWeight = -1;
2661 for (maIndex = 0; maIndex < maCount; ++maIndex) {
2663 for (
unsigned cIndex = 0, eIndex = ConstraintOperands.size();
2664 cIndex != eIndex; ++cIndex) {
2685 weight = getMultipleConstraintMatchWeight(OpInfo, maIndex);
2690 weightSum += weight;
2693 if (weightSum > bestWeight) {
2694 bestWeight = weightSum;
2695 bestMAIndex = maIndex;
2700 for (
unsigned cIndex = 0, eIndex = ConstraintOperands.size();
2701 cIndex != eIndex; ++cIndex) {
2711 for (
unsigned cIndex = 0, eIndex = ConstraintOperands.size();
2712 cIndex != eIndex; ++cIndex) {
2723 std::pair<unsigned, const TargetRegisterClass *> MatchRC =
2726 std::pair<unsigned, const TargetRegisterClass *> InputRC =
2731 (MatchRC.second != InputRC.second)) {
2733 " with a matching output constraint of"
2734 " incompatible type!");
2740 return ConstraintOperands;
2767 rCodes = &info.
Codes;
2773 for (
unsigned i = 0, e = rCodes->size(); i != e; ++i) {
2775 getSingleConstraintMatchWeight(info, (*rCodes)[i].
c_str());
2776 if (weight > BestWeight)
2777 BestWeight = weight;
2793 if (!CallOperandVal)
2796 switch (*constraint) {
2799 if (isa<ConstantInt>(CallOperandVal))
2800 weight = CW_Constant;
2803 if (isa<GlobalValue>(CallOperandVal))
2804 weight = CW_Constant;
2808 if (isa<ConstantFP>(CallOperandVal))
2809 weight = CW_Constant;
2822 weight = CW_Register;
2826 weight = CW_Default;
2855 assert(OpInfo.
Codes.size() > 1 &&
"Doesn't have multiple constraint options");
2856 unsigned BestIdx = 0;
2858 int BestGenerality = -1;
2861 for (
unsigned i = 0, e = OpInfo.
Codes.size(); i != e; ++i) {
2871 "Unhandled multi-letter 'other' constraint");
2872 std::vector<SDValue> ResultOps;
2875 if (!ResultOps.empty()) {
2889 if (Generality > BestGenerality) {
2892 BestGenerality = Generality;
2905 assert(!OpInfo.
Codes.empty() &&
"Must have at least one constraint");
2908 if (OpInfo.
Codes.size() == 1) {
2921 if (isa<BasicBlock>(v) || isa<ConstantInt>(v) || isa<Function>(v)) {
2928 if (
const char *Repl = LowerXConstraint(OpInfo.
ConstraintVT)) {
2939 std::vector<SDNode *> &Created) {
2940 assert(d != 0 &&
"Division by zero!");
2952 Created.push_back(Op1.
getNode());
2958 while ((t = d*xn) != 1)
2963 Created.push_back(Mul.
getNode());
2969 std::vector<SDNode *> *Created)
const {
2983 std::vector<SDNode *> *Created)
const {
2984 assert(Created &&
"No vector to hold sdiv ops.");
3006 DAG.getConstant(magics.
m, dl, VT));
3011 DAG.getConstant(magics.
m, dl, VT)).getNode(), 1);
3017 Created->push_back(Q.
getNode());
3022 Created->push_back(Q.
getNode());
3024 auto &DL = DAG.getDataLayout();
3030 Created->push_back(Q.
getNode());
3037 Created->push_back(T.
getNode());
3038 return DAG.getNode(
ISD::ADD, dl, VT, Q, T);
3047 std::vector<SDNode *> *Created)
const {
3048 assert(Created &&
"No vector to hold udiv ops.");
3067 if (magics.
a != 0 && !Divisor[0]) {
3072 Created->push_back(Q.
getNode());
3076 assert(magics.
a == 0 &&
"Should use cheap fixup now");
3091 Created->push_back(Q.
getNode());
3093 if (magics.
a == 0) {
3095 "We shouldn't generate an undefined shift!");
3101 Created->push_back(NPQ.
getNode());
3105 Created->push_back(NPQ.
getNode());
3107 Created->push_back(NPQ.
getNode());
3117 if (!isa<ConstantSDNode>(Op.
getOperand(0))) {
3119 "be a constant integer");
3148 if (!HasMULHU && !HasMULHS && !HasUMUL_LOHI && !HasSMUL_LOHI)
3163 if ((
Signed && HasSMUL_LOHI) || (!
Signed && HasUMUL_LOHI)) {
3165 Hi =
SDValue(Lo.getNode(), 1);
3191 if (MakeMUL_LOHI(LL, RL, Lo, Hi,
false)) {
3204 RHSSB > InnerBitSize) {
3207 if (MakeMUL_LOHI(LL, RL, Lo, Hi,
true)) {
3214 unsigned ShiftAmount = OuterBitSize - InnerBitSize;
3236 if (!MakeMUL_LOHI(LL, RL, Lo, Hi,
false))
3259 if (!MakeMUL_LOHI(LL, RH, Lo, Hi,
false))
3266 if (!MakeMUL_LOHI(LH, RL, Lo, Hi,
false))
3307 DAG,
Kind, LL, LH, RL, RH);
3359 dl, Exponent, ExponentLoBit,
3400 for (
unsigned Idx = 0; Idx < NumElem; ++Idx) {
3402 DAG.
getExtLoad(ExtType, SL, DstEltVT, Chain, BasePTR,
3449 for (
unsigned Idx = 0; Idx < NumElem; ++Idx) {
3468 std::pair<SDValue, SDValue>
3471 "unaligned indexed loads not implemented!");
3482 SDValue Scalarized = scalarizeVectorLoad(LD, DAG);
3495 return std::make_pair(Result, newLoad.
getValue(1));
3503 unsigned NumRegs = (LoadedBytes + RegBytes - 1) / RegBytes;
3519 for (
unsigned i = 1; i < NumRegs; i++) {
3537 8 * (LoadedBytes -
Offset));
3557 return std::make_pair(Load, TF);
3561 "Unaligned load of unsupported type.");
3571 unsigned IncrementSize = NumBits / 8;
3586 Hi = DAG.
getExtLoad(HiExtType, dl, VT, Chain, Ptr,
3588 NewLoadedVT,
MinAlign(Alignment, IncrementSize),
3598 NewLoadedVT,
MinAlign(Alignment, IncrementSize),
3612 return std::make_pair(Result, TF);
3618 "unaligned indexed stores not implemented!");
3632 SDValue Result = scalarizeVectorStore(ST, DAG);
3654 unsigned NumRegs = (StoredBytes + RegBytes - 1) / RegBytes;
3671 for (
unsigned i = 1; i < NumRegs; i++) {
3683 StackPtr, StackPtrIncrement);
3691 8 * (StoredBytes -
Offset));
3709 "Unaligned store of unknown type.");
3713 int IncrementSize = NumBits / 8;
3729 EVT PtrVT = Ptr.getValueType();
3732 Alignment =
MinAlign(Alignment, IncrementSize);
3747 bool IsCompressedMemory)
const {
3752 "Incompatible types of Data and Mask");
3753 if (IsCompressedMemory) {
3779 if (isa<ConstantSDNode>(Idx))
3807 "Converting bits to bytes lost precision");
3811 EVT IdxVT = Index.getValueType();
3832 std::string NameString = (
"__emutls_v." + GA->
getGlobal()->
getName()).str();
3836 assert(EmuTlsVar &&
"Cannot find EmuTlsVar ");
3838 Entry.
Ty = VoidPtrType;
3839 Args.push_back(Entry);
3846 std::pair<SDValue, SDValue> CallResult = LowerCallTo(CLI);
3855 "Emulated TLS must have zero offset in GlobalAddressSDNode");
3856 return CallResult.first;
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
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.
bool hasNoUnsignedWrap() const
bool parametersInCSRMatch(const MachineRegisterInfo &MRI, const uint32_t *CallerPreservedMask, const SmallVectorImpl< CCValAssign > &ArgLocs, const SmallVectorImpl< SDValue > &OutVals) const
Check whether parameters to a call that are passed in callee saved registers are the same as from the...
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
SDValue getGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, bool isTargetGA=false, unsigned char TargetFlags=0)
static MVT getIntegerVT(unsigned BitWidth)
void push_back(const T &Elt)
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
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. ...
CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const
Get the CallingConv that should be used for the specified libcall.
mu magicu(unsigned LeadingZeros=0) const
Calculate the magic numbers required to implement an unsigned integer division by a constant as a seq...
SDValue getValue(unsigned R) const
void setSignBit()
Set the sign bit to 1.
virtual bool isCtlzFast() const
Return true if ctlz instruction is fast.
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...
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 ...
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
Flags getFlags() const
Return the raw flags of the source value,.
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
LLVMContext * getContext() const
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...
SDValue scalarizeVectorStore(StoreSDNode *ST, SelectionDAG &DAG) const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
virtual StringRef getRegAsmName(unsigned Reg) const
Return the assembly name for Reg.
bool hasOneUse() const
Return true if there is exactly one use of this node.
virtual bool hasAndNotCompare(SDValue Y) const
Return true if the target should transform: (X & Y) == Y —> (~X & Y) == 0 (X & Y) != Y —> (~X & Y) !=...
A Module instance is used to store all the information related to an LLVM module. ...
bool isOneValue() const
Determine if this is a value of 1.
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node.
const TargetMachine & getTargetMachine() const
bool isCalledByLegalizer() const
SDValue lowerCmpEqZeroToCtlzSrl(SDValue Op, SelectionDAG &DAG) const
Carry-setting nodes for multiple precision addition and subtraction.
bool isConstTrueVal(const SDNode *N) const
Return if the N is a constant or constant vector equal to the true value from getBooleanContents().
bool isKnownToBeAPowerOfTwo(SDValue Val) const
Test if the given value is known to have exactly one bit set.
MVT getSimpleValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the MVT corresponding to this LLVM type. See getValueType.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Get a value with low bits set.
const GlobalValue * getGlobal() const
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit...
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
bool verifyReturnAddressArgumentIsConstant(SDValue Op, SelectionDAG &DAG) const
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
unsigned getSizeInBits() const
static SDValue BuildExactSDIV(const TargetLowering &TLI, SDValue Op1, APInt d, const SDLoc &dl, SelectionDAG &DAG, std::vector< SDNode * > &Created)
Given an exact SDIV by a constant, create a multiplication with the multiplicative inverse of the con...
bool isUnindexed() const
Return true if this is NOT a pre/post inc/dec load/store.
virtual bool isLegalICmpImmediate(int64_t) const
Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructi...
bool isBitwiseNot(SDValue V)
Returns true if V is a bitwise not operation.
unsigned getNumOperands() const
Return the number of values used by this operation.
void setAllBits()
Set every bit to 1.
unsigned getNumOperands() const
unsigned getValueSizeInBits() const
Returns the size of the value in bits.
const SDValue & getOperand(unsigned Num) const
The two locations do not alias at all.
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
ms magic() const
Calculate the magic numbers required to implement a signed integer division by a constant as a sequen...
bool expandFP_TO_SINT(SDNode *N, SDValue &Result, SelectionDAG &DAG) const
Expand float(f32) to SINT(i64) conversion.
SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT TVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
ConstantSDNode * getConstantSplatNode(BitVector *UndefElements=nullptr) const
Returns the splatted constant or null if this is not a constant splat.
Type * getElementType() const
SDValue scalarizeVectorLoad(LoadSDNode *LD, SelectionDAG &DAG) const
Turn load of vector type into a load of the individual elements.
Value * CallOperandVal
If this is the result output operand or a clobber, this is null, otherwise it is the incoming operand...
unsigned getNumSignBits() const
Computes the number of leading bits of this APInt that are equal to its sign bit. ...
bool isTrueWhenEqual(CondCode Cond)
Return true if the specified condition returns true if the two operands to the condition are equal...
const SDValue & getBasePtr() const
CallLoweringInfo & setDiscardResult(bool Value=true)
SDValue BuildUDIV(SDNode *N, const APInt &Divisor, SelectionDAG &DAG, bool IsAfterLegalization, std::vector< SDNode * > *Created) const
Given an ISD::UDIV node expressing a divide by constant, return a DAG expression to select that will ...
Magic data for optimising unsigned division by a constant.
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
SDValue getConstTrueVal(SelectionDAG &DAG, EVT VT, const SDLoc &DL) const
Return a constant of type VT that contains a true value that respects getBooleanContents() ...
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
bool bitsLT(EVT VT) const
Return true if this has less bits than VT.
INT = FGETSIGN(FP) - Return the sign bit of the specified floating point value as an integer 0/1 valu...
bool isAllOnesValue() const
SDValue getExternalSymbol(const char *Sym, EVT VT)
ConstraintCodeVector Codes
Code - The constraint code, either the register name (in braces) or the constraint letter/number...
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
StringRef getName() const
Return a constant reference to the value's name.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
virtual bool isCommutativeBinOp(unsigned Opcode) const
Returns true if the opcode is a commutative binary operation.
bool ShrinkDemandedConstant(SDValue Op, const APInt &Demanded, TargetLoweringOpt &TLO) const
Check to see if the specified operand of the specified instruction is a constant integer.
A convenience struct that encapsulates a DAG, and two SDValues for returning information from TargetL...
AttributeList getAttributes() const
Return the attribute list for this Function.
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
bool isNegative() const
Determine sign of this APInt.
SDValue expandUnalignedStore(StoreSDNode *ST, SelectionDAG &DAG) const
Expands an unaligned store to 2 half-size stores for integer values, and possibly more for vectors...
bool isVector() const
Return true if this is a vector value type.
virtual const char * LowerXConstraint(EVT ConstraintVT) const
Try to replace an X constraint, which matches anything, with another that has more specific requireme...
void setNoSignedWrap(bool b)
iterator_range< regclass_iterator > regclasses() const
virtual bool isIntDivCheap(EVT VT, AttributeList Attr) const
Return true if integer divide is usually cheaper than a sequence of several shifts, adds, and multiplies for this target.
std::vector< std::string > ConstraintCodeVector
virtual const char * getTargetNodeName(unsigned Opcode) const
This method returns the name of a target specific DAG node.
bool isRound() const
Return true if the size is a power-of-two number of bytes.
virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const
This method will be invoked for all target nodes and for any target-independent nodes that the target...
static SDValue clampDynamicVectorIndex(SelectionDAG &DAG, SDValue Idx, EVT VecVT, const SDLoc &dl)
bool ShrinkDemandedOp(SDValue Op, unsigned BitWidth, const APInt &Demanded, TargetLoweringOpt &TLO) const
Convert x+y to (VT)((SmallVT)x+(SmallVT)y) if the casts are free.
int64_t getOffset() const
Shift and rotation operations.
const GlobalVariable * getNamedGlobal(StringRef Name) const
Return the global variable in the module with the specified name, of arbitrary type.
Class to represent struct types.
bool isBuildVectorAllZeros(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR where all of the elements are 0 or undef...
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
MachineFunction & getMachineFunction() const
ValTy * getCalledValue() const
Return the pointer to function that is being called.
TargetLowering::ConstraintType ConstraintType
Information about the constraint code, e.g.
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...
Base class for the full range of assembler expressions which are needed for parsing.
Reg
All possible values of the reg field in the ModR/M byte.
MachinePointerInfo getWithOffset(int64_t O) const
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
SDValue IncrementMemoryAddress(SDValue Addr, SDValue Mask, const SDLoc &DL, EVT DataVT, SelectionDAG &DAG, bool IsCompressedMemory) const
Increments memory address Addr according to the type of the value DataVT that should be stored...
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
bool isPositionIndependent() const
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.
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 ...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
zlib-gnu style compression
bool isInteger() const
Return true if this is an integer or a vector integer type.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
virtual MVT getVectorIdxTy(const DataLayout &DL) const
Returns the type to be used for the index operand of: ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT...
EVT getVectorElementType() const
Given a vector type, return the type of each element.
Context object for machine code objects.
void emitError(unsigned LocCookie, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
APInt shl(unsigned shiftAmt) const
Left-shift function.
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.
unsigned getLocReg() const
virtual bool isUsedByReturnOnly(SDNode *, SDValue &) const
Return true if result of the specified node is used by a return node only.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static SDNodeIterator begin(const SDNode *N)
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table...
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...
SDValue SimplifySetCC(EVT VT, SDValue N0, SDValue N1, ISD::CondCode Cond, bool foldBooleans, DAGCombinerInfo &DCI, const SDLoc &dl) const
Try to simplify a setcc built with the specified operands and cc.
bool isLegalRC(const TargetRegisterInfo &TRI, const TargetRegisterClass &RC) const
Return true if the value types that can be represented by the specified register class are all legal...
bool isExtendedTrueVal(const ConstantSDNode *N, EVT VT, bool Signed) const
Return if N is a True value when extended to VT.
This contains information for each constraint that we are lowering.
Simple integer binary arithmetic operators.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
EK_BlockAddress - Each entry is a plain address of block, e.g.
unsigned getActiveBits() const
Compute the number of active bits in the value.
CallLoweringInfo & setZExtResult(bool Value=true)
bool isLittleEndian() const
Layout endianness...
signed char MatchingInput
MatchingInput - If this is not -1, this is an output constraint where an input constraint is required...
const SDValue & getBasePtr() const
EVT getHalfSizedIntegerVT(LLVMContext &Context) const
Finds the smallest simple value type that is greater than or equal to half the width of this EVT...
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
const APInt & getAPIntValue() const
EVT getMemoryVT() const
Return the type of the in-memory value.
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
unsigned getBitWidth() const
Get the bit width of this value.
ConstraintPrefix Type
Type - The basic type of the constraint: input/output/clobber.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
bool isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
unsigned getMinSignedBits() const
Get the minimum bit size for this signed APInt.
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
size_t size() const
size - Get the array size.
SDValue getVectorElementPointer(SelectionDAG &DAG, SDValue VecPtr, EVT VecVT, SDValue Idx) const
Get a pointer to vector element Idx located in memory for a vector of type VecVT starting at a base a...
const DataLayout & getDataLayout() const
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
Class to represent pointers.
This class is used to represent ISD::STORE nodes.
unsigned getParamAlignment(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the specified, possibly variable...
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Get a value with high bits set.
void softenSetCCOperands(SelectionDAG &DAG, EVT VT, SDValue &NewLHS, SDValue &NewRHS, ISD::CondCode &CCCode, const SDLoc &DL) const
Soften the operands of a comparison.
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
void setAttributes(ImmutableCallSite *CS, unsigned ArgIdx)
Set CallLoweringInfo attribute flags based on a call instruction and called function attributes...
SDNode * getNode() const
get the SDNode which holds the desired result
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
virtual SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG, std::vector< SDNode * > *Created) const
Targets may override this function to provide custom SDIV lowering for power-of-2 denominators...
unsigned getScalarSizeInBits() const
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
bool isMatchingInputConstraint() const
Return true of this is an input operand that is a matching constraint like "4".
EK_GPRel64BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
std::vector< AsmOperandInfo > AsmOperandInfoVector
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
bool isInteger() const
Return true if this is an integer or a vector integer type.
std::pair< SDValue, SDValue > expandUnalignedLoad(LoadSDNode *LD, SelectionDAG &DAG) const
Expands an unaligned load to 2 half-size loads for an integer, and possibly more for vectors...
unsigned const MachineRegisterInfo * MRI
bool intersects(const APInt &RHS) const
This operation tests if there are any pairs of corresponding bits between this APInt and RHS that are...
APInt trunc(unsigned width) const
Truncate to new width.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
const SDValue & getOperand(unsigned i) const
The instances of the Type class are immutable: once they are created, they are never changed...
bool isIndirect
isIndirect - True if this operand is an indirect operand.
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...
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
void resetAll()
Resets the known state of all bits.
const SDNodeFlags getFlags() const
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
int64_t getSExtValue() const
Get sign extended value.
unsigned getMatchedOperand() const
If this is an input matching constraint, this method returns the output operand it matches...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
bool isBeforeLegalizeOps() const
Carry-using nodes for multiple precision addition and subtraction.
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
static void ChooseConstraint(TargetLowering::AsmOperandInfo &OpInfo, const TargetLowering &TLI, SDValue Op, SelectionDAG *DAG)
If there are multiple different constraints that we could pick for this operand (e.g.
unsigned getScalarValueSizeInBits() const
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
void AddToWorklist(SDNode *N)
SubConstraintInfoVector multipleAlternatives
multipleAlternatives - If there are multiple alternative constraints, this array will contain them...
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
APInt getLoBits(unsigned numBits) const
Compute an APInt containing numBits lowbits from this APInt.
bool expandMUL_LOHI(unsigned Opcode, EVT VT, SDLoc dl, SDValue LHS, SDValue RHS, SmallVectorImpl< SDValue > &Result, EVT HiLoVT, SelectionDAG &DAG, MulExpansionKind Kind, SDValue LL=SDValue(), SDValue LH=SDValue(), SDValue RL=SDValue(), SDValue RH=SDValue()) const
Expand a MUL or [US]MUL_LOHI of n-bit values into two or four nodes, respectively, each computing an n/2-bit part of the result.
bool isBeforeLegalize() const
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
KnownBits trunc(unsigned BitWidth)
Truncate the underlying known Zero and One bits.
bool isPositionIndependent() const
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool CombineTo(SDValue O, SDValue N)
bool expandMUL(SDNode *N, SDValue &Lo, SDValue &Hi, EVT HiLoVT, SelectionDAG &DAG, MulExpansionKind Kind, SDValue LL=SDValue(), SDValue LH=SDValue(), SDValue RL=SDValue(), SDValue RH=SDValue()) const
Expand a MUL into two nodes.
unsigned getOpcode() const
for(unsigned i=0, e=MI->getNumOperands();i!=e;++i)
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
unsigned getUnorderedFlavor(CondCode Cond)
This function returns 0 if the condition is always false if an operand is a NaN, 1 if the condition i...
CondCode getSetCCSwappedOperands(CondCode Operation)
Return the operation corresponding to (Y op X) when given the operation for (X op Y)...
static MVT getVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
const SDValue & getValue() const
ConstantSDNode * isConstOrConstSplat(SDValue V)
Returns the SDNode if it is a constant splat BuildVector or constant int.
bool isConstFalseVal(const SDNode *N) const
Return if the N is a constant or constant vector equal to the false value from getBooleanContents().
bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
SDValue BuildSDIV(SDNode *N, const APInt &Divisor, SelectionDAG &DAG, bool IsAfterLegalization, std::vector< SDNode * > *Created) const
Given an ISD::SDIV node expressing a divide by constant, return a DAG expression to select that will ...
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
std::vector< ArgListEntry > ArgListTy
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
Type * getType() const
Return the type of the instruction that generated this call site.
uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This structure contains all information that is necessary for lowering calls.
bool shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const
BooleanContent getBooleanContents(bool isVec, bool isFloat) const
For targets without i1 registers, this gives the nature of the high-bits of boolean values held in ty...
ISD::MemIndexedMode getAddressingMode() const
Return the addressing mode for this load or store: unindexed, pre-inc, pre-dec, post-inc, or post-dec.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
unsigned countTrailingZeros() const
Count the number of trailing zero bits.
std::pair< SDValue, SDValue > makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, ArrayRef< SDValue > Ops, bool isSigned, const SDLoc &dl, bool doesNotReturn=false, bool isReturnValueUsed=true) const
Returns a pair of (return value, chain).
This class contains a discriminated union of information about pointers in memory operands...
std::string ConstraintCode
This contains the actual string for the code, like "m".
virtual SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG) const
Returns relocation base for the given PIC jumptable.
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.
virtual void ComputeConstraintToUse(AsmOperandInfo &OpInfo, SDValue Op, SelectionDAG *DAG=nullptr) const
Determines the constraint code and constraint type to use for the specific AsmOperandInfo, setting OpInfo.ConstraintCode and OpInfo.ConstraintType.
const MachinePointerInfo & getPointerInfo() const
This base class for TargetLowering contains the SelectionDAG-independent parts that can be used from ...
ISD::CondCode getCmpLibcallCC(RTLIB::Libcall Call) const
Get the CondCode that's to be used to test the result of the comparison libcall against zero...
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type...
static APInt getSignMask(unsigned BitWidth)
Get the SignMask for a specific bit width.
TokenFactor - This node takes multiple tokens as input and produces a single token result...
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
static void Merge(const std::string &Input, const std::vector< std::string > Result, size_t NumNewFeatures)
void setNoUnsignedWrap(bool b)
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
virtual unsigned getJumpTableEncoding() const
Return the entry encoding for a jump table in the current function.
APInt getHiBits(unsigned numBits) const
Compute an APInt containing numBits highbits from this APInt.
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
void computeKnownBits(SDValue Op, KnownBits &Known, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
double Log2(double Value)
Return the log base 2 of the specified value.
ValTy * getArgument(unsigned ArgNo) const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Type * getType() const
All values are typed, get the type of this value.
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const
Return the ValueType of the result of SETCC operations.
CCValAssign - Represent assignment of one arg/retval to a location.
const SDValue & getChain() const
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
bool hasMatchingInput() const
hasMatchingInput - Return true if this is an output constraint that has a matching input constraint...
bool isStrictlyPositive() const
Determine if this APInt Value is positive.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
CallLoweringInfo & setSExtResult(bool Value=true)
virtual const MCExpr * getPICJumpTableRelocBaseExpr(const MachineFunction *MF, unsigned JTI, MCContext &Ctx) const
This returns the relocation base for the given PIC jumptable, the same as getPICJumpTableRelocBase, but as an MCExpr.
virtual bool isGAPlusOffset(SDNode *N, const GlobalValue *&GA, int64_t &Offset) const
Returns true (and the GlobalValue and the offset) if the node is a GlobalAddress + offset...
bool hasNoSignedWrap() const
Represents one node in the SelectionDAG.
CondCode getSetCCInverse(CondCode Operation, bool isInteger)
Return the operation corresponding to !(X op Y), where 'op' is a valid SetCC operation.
virtual bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const
Returns true if arguments should be sign-extended in lib calls.
void setAdjustsStack(bool V)
SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a bitwise NOT operation as (XOR Val, -1).
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
bool isInTailCallPosition(SelectionDAG &DAG, SDNode *Node, SDValue &Chain) const
Check whether a given call node is in tail position within its function.
C - The default llvm calling convention, compatible with C.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
Class for arbitrary precision integers.
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
A "pseudo-class" with methods for operating on BUILD_VECTORs.
Select(COND, TRUEVAL, FALSEVAL).
int64_t getSExtValue() const
bool isIntegerTy() const
True if this is an instance of IntegerType.
ZERO_EXTEND - Used for integer types, zeroing the new bits.
ANY_EXTEND - Used for integer types. The high bits are undefined.
MulExpansionKind
Enum that specifies when a multiplication should be expanded.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
const MCPhysReg * iterator
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
virtual MVT::SimpleValueType getCmpLibcallReturnType() const
Return the ValueType for comparison libcalls.
static std::vector< std::string > Flags
bool isAllOnesValue() const
Determine if all bits are set.
These are IR-level optimization flags that may be propagated to SDNodes.
Magic data for optimising signed division by a constant.
Bitwise operators - logical and, logical or, logical xor.
virtual void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
Lower the specified operand into the Ops vector.
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the call or the callee has the given attribute.
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
Establish a view to a call site for examination.
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
ArrayRef< SDUse > ops() const
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static unsigned getConstraintGenerality(TargetLowering::ConstraintType CT)
Return an integer indicating how general CT is.
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
EVT getValueType() const
Return the ValueType of the referenced return value.
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
SDValue getCondCode(ISD::CondCode Cond)
SDValue getGLOBAL_OFFSET_TABLE(EVT VT)
Return a GLOBAL_OFFSET_TABLE node. This does not have a useful SDLoc.
virtual bool isTruncateFree(Type *FromTy, Type *ToTy) const
Return true if it's free to truncate a value of type FromTy to type ToTy.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
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...
TargetLowering(const TargetLowering &)=delete
bool isTypeLegalForClass(const TargetRegisterClass &RC, MVT T) const
Return true if the given TargetRegisterClass has the ValueType T.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
static SDNodeIterator end(const SDNode *N)
bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
SDValue getSelectCC(const SDLoc &DL, SDValue LHS, SDValue RHS, SDValue True, SDValue False, ISD::CondCode Cond)
Helper function to make it easier to build SelectCC's if you just have an ISD::CondCode instead of an...
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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.
static bool ShrinkDemandedConstant(Instruction *I, unsigned OpNo, const APInt &Demanded)
Check to see if the specified operand of the specified instruction is a constant integer.
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...
virtual ConstraintWeight getMultipleConstraintMatchWeight(AsmOperandInfo &info, int maIndex) const
Examine constraint type and operand type and determine a weight value.
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
const TargetLowering & getTargetLoweringInfo() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
unsigned countLeadingZeros() const
The APInt version of the countLeadingZeros functions in MathExtras.h.
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
APInt zext(unsigned width) const
Zero extend to a new width.
SetCC operator - This evaluates to a true value iff the condition is true.
virtual SDValue LowerToTLSEmulatedModel(const GlobalAddressSDNode *GA, SelectionDAG &DAG) const
Lower TLS global address SDNode for target independent emulated TLS model.
EK_GPRel32BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative...
bool isNullValue() const
Determine if all bits are clear.
virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const
Return true if folding a constant offset with the given GlobalAddress is legal.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
MVT ConstraintVT
The ValueType for the operand value.
BooleanContent
Enum that describes how the target represents true/false values.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
TRUNCATE - Completely drop the high bits.
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL) const
unsigned getAlignment() const
bool isCondCodeLegal(ISD::CondCode CC, MVT VT) const
Return true if the specified condition code is legal on this target.
virtual ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &info, const char *constraint) const
Examine constraint string and operand type and determine a weight value.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, FLOG, FLOG2, FLOG10, FEXP, FEXP2, FCEIL, FTRUNC, FRINT, FNEARBYINT, FROUND, FFLOOR - Perform various unary floating point operations.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
bool SimplifyDemandedBits(SDNode *User, unsigned OpIdx, const APInt &Demanded, DAGCombinerInfo &DCI, TargetLoweringOpt &TLO) const
Helper for SimplifyDemandedBits that can simplify an operation with multiple uses.
virtual AsmOperandInfoVector ParseConstraints(const DataLayout &DL, const TargetRegisterInfo *TRI, ImmutableCallSite CS) const
Split up the constraint string from the inline assembly value into the specific constraints and their...
void setLowBits(unsigned loBits)
Set the bottom loBits bits.
LegalizeAction getCondCodeAction(ISD::CondCode CC, MVT VT) const
Return how the condition code should be treated: either it is legal, needs to be expanded to some oth...
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static ConstraintInfoVector ParseConstraints(StringRef ConstraintString)
ParseConstraints - Split up the constraint string into the specific constraints and their prefixes...
This file describes how to lower LLVM code to machine code.
void CommitTargetLoweringOpt(const TargetLoweringOpt &TLO)
bool isVoidTy() const
Return true if this is 'void'.
unsigned getLiveInPhysReg(unsigned VReg) const
getLiveInPhysReg - If VReg is a live-in virtual register, return the corresponding live-in physical r...
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned char TargetFlags=0)
void selectAlternative(unsigned index)
selectAlternative - Point this constraint to the alternative constraint indicated by the index...
uint64_t getZExtValue() const
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
This class is used to represent ISD::LOAD nodes.