30 #define DEBUG_TYPE "systemz-lower"
35 struct IPMConversion {
36 IPMConversion(
unsigned xorValue, int64_t addValue,
unsigned bit)
37 : XORValue(xorValue), AddValue(addValue),
Bit(bit) {}
47 : Op0(Op0In), Op1(Op1In), Opcode(0), ICmpType(0), CCValid(0), CCMask(0) {}
617 assert (isa<LoadInst>(I) || isa<StoreInst>(I));
621 bool IsVectorAccess = MemAccessTy->
isVectorTy();
625 if (!IsVectorAccess && isa<StoreInst>(I)) {
627 if (isa<ExtractElementInst>(DataOp))
628 IsVectorAccess =
true;
633 if (!IsVectorAccess && isa<LoadInst>(I) && I->
hasOneUse()) {
635 if (isa<InsertElementInst>(LoadUser))
636 IsVectorAccess =
true;
639 if (!isUInt<12>(Offset) && (IsFPAccess || IsVectorAccess))
650 return FromBits > ToBits;
658 return FromBits > ToBits;
667 if (Constraint.
size() == 1) {
668 switch (Constraint[0]) {
699 const char *constraint)
const {
708 switch (*constraint) {
727 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
733 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
734 if (isUInt<12>(
C->getZExtValue()))
739 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
745 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
746 if (isInt<20>(
C->getSExtValue()))
751 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
752 if (
C->getZExtValue() == 0x7fffffff)
762 static std::pair<unsigned, const TargetRegisterClass *>
764 const unsigned *Map) {
765 assert(*(Constraint.
end()-1) ==
'}' &&
"Missing '}'");
766 if (isdigit(Constraint[2])) {
769 Constraint.
slice(2, Constraint.
size() - 1).getAsInteger(10, Index);
770 if (!Failed && Index < 16 && Map[Index])
771 return std::make_pair(Map[Index], RC);
773 return std::make_pair(0U,
nullptr);
776 std::pair<unsigned, const TargetRegisterClass *>
779 if (Constraint.
size() == 1) {
781 switch (Constraint[0]) {
786 return std::make_pair(0U, &SystemZ::GR64BitRegClass);
788 return std::make_pair(0U, &SystemZ::GR128BitRegClass);
789 return std::make_pair(0U, &SystemZ::GR32BitRegClass);
793 return std::make_pair(0U, &SystemZ::ADDR64BitRegClass);
795 return std::make_pair(0U, &SystemZ::ADDR128BitRegClass);
796 return std::make_pair(0U, &SystemZ::ADDR32BitRegClass);
799 return std::make_pair(0U, &SystemZ::GRH32BitRegClass);
803 return std::make_pair(0U, &SystemZ::FP64BitRegClass);
805 return std::make_pair(0U, &SystemZ::FP128BitRegClass);
806 return std::make_pair(0U, &SystemZ::FP32BitRegClass);
809 if (Constraint.
size() > 0 && Constraint[0] ==
'{') {
814 if (Constraint[1] ==
'r') {
824 if (Constraint[1] ==
'f') {
840 std::vector<SDValue> &Ops,
843 if (Constraint.length() == 1) {
844 switch (Constraint[0]) {
846 if (
auto *
C = dyn_cast<ConstantSDNode>(Op))
853 if (
auto *
C = dyn_cast<ConstantSDNode>(Op))
854 if (isUInt<12>(
C->getZExtValue()))
860 if (
auto *
C = dyn_cast<ConstantSDNode>(Op))
867 if (
auto *
C = dyn_cast<ConstantSDNode>(Op))
868 if (isInt<20>(
C->getSExtValue()))
874 if (
auto *
C = dyn_cast<ConstantSDNode>(Op))
875 if (
C->getZExtValue() == 0x7fffffff)
888 #include "SystemZGenCallingConv.inc"
891 Type *ToType)
const {
908 for (
unsigned i = 0; i < Ins.
size(); ++i)
913 for (
unsigned i = 0; i < Outs.
size(); ++i)
995 unsigned NumFixedGPRs = 0;
996 unsigned NumFixedFPRs = 0;
997 for (
unsigned I = 0,
E = ArgLocs.
size();
I !=
E; ++
I) {
1010 RC = &SystemZ::GR32BitRegClass;
1014 RC = &SystemZ::GR64BitRegClass;
1018 RC = &SystemZ::FP32BitRegClass;
1022 RC = &SystemZ::FP64BitRegClass;
1030 RC = &SystemZ::VR128BitRegClass;
1051 ArgValue = DAG.
getLoad(LocVT, DL, Chain, FIN,
1062 unsigned ArgIndex = Ins[
I].OrigArgIndex;
1063 assert (Ins[
I].PartOffset == 0);
1064 while (
I + 1 !=
E && Ins[
I + 1].OrigArgIndex == ArgIndex) {
1066 unsigned PartOffset = Ins[
I + 1].PartOffset;
1084 int64_t StackSize = CCInfo.getNextStackOffset();
1089 int64_t RegSaveOffset = TFL->getOffsetOfLocalArea();
1102 &SystemZ::FP64BitRegClass);
1110 SystemZ::NumArgFPRs-NumFixedFPRs));
1123 for (
unsigned I = 0,
E = ArgLocs.
size();
I !=
E; ++
I) {
1130 if (Reg == SystemZ::R6H || Reg == SystemZ::R6L || Reg == SystemZ::R6D)
1132 if (Outs[
I].
Flags.isSwiftSelf() || Outs[
I].Flags.isSwiftError())
1171 unsigned NumBytes = ArgCCInfo.getNextStackOffset();
1181 for (
unsigned I = 0,
E = ArgLocs.
size();
I !=
E; ++
I) {
1188 int FI = cast<FrameIndexSDNode>(SpillSlot)->getIndex();
1190 DAG.
getStore(Chain, DL, ArgValue, SpillSlot,
1194 unsigned ArgIndex = Outs[
I].OrigArgIndex;
1195 assert (Outs[
I].PartOffset == 0);
1196 while (
I + 1 !=
E && Outs[
I + 1].OrigArgIndex == ArgIndex) {
1197 SDValue PartValue = OutVals[
I + 1];
1198 unsigned PartOffset = Outs[
I + 1].PartOffset;
1202 DAG.
getStore(Chain, DL, PartValue, Address,
1206 ArgValue = SpillSlot;
1233 if (!MemOpChains.
empty())
1240 if (
auto *
G = dyn_cast<GlobalAddressSDNode>(Callee)) {
1243 }
else if (
auto *
E = dyn_cast<ExternalSymbolSDNode>(Callee)) {
1246 }
else if (IsTailCall) {
1247 Chain = DAG.
getCopyToReg(Chain, DL, SystemZ::R1D, Callee, Glue);
1253 for (
unsigned I = 0,
E = RegsToPass.
size();
I !=
E; ++
I) {
1266 for (
unsigned I = 0,
E = RegsToPass.
size();
I !=
E; ++
I)
1268 RegsToPass[I].second.getValueType()));
1273 assert(Mask &&
"Missing call preserved mask for calling convention");
1300 for (
unsigned I = 0,
E = RetLocs.
size(); I !=
E; ++
I) {
1328 for (
auto &Out : Outs)
1333 CCState RetCCInfo(CallConv, isVarArg, MF, RetLocs, Context);
1334 return RetCCInfo.
CheckReturn(Outs, RetCC_SystemZ);
1355 if (RetLocs.
empty())
1362 for (
unsigned I = 0,
E = RetLocs.
size();
I !=
E; ++
I) {
1374 Chain = DAG.
getCopyToReg(Chain, DL, Reg, RetValue, Glue);
1391 unsigned &CCValid) {
1392 unsigned Id = cast<ConstantSDNode>(Op.
getOperand(1))->getZExtValue();
1394 case Intrinsic::s390_tbegin:
1399 case Intrinsic::s390_tbegin_nofloat:
1404 case Intrinsic::s390_tend:
1418 unsigned Id = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
1420 case Intrinsic::s390_vpkshs:
1421 case Intrinsic::s390_vpksfs:
1422 case Intrinsic::s390_vpksgs:
1427 case Intrinsic::s390_vpklshs:
1428 case Intrinsic::s390_vpklsfs:
1429 case Intrinsic::s390_vpklsgs:
1434 case Intrinsic::s390_vceqbs:
1435 case Intrinsic::s390_vceqhs:
1436 case Intrinsic::s390_vceqfs:
1437 case Intrinsic::s390_vceqgs:
1442 case Intrinsic::s390_vchbs:
1443 case Intrinsic::s390_vchhs:
1444 case Intrinsic::s390_vchfs:
1445 case Intrinsic::s390_vchgs:
1450 case Intrinsic::s390_vchlbs:
1451 case Intrinsic::s390_vchlhs:
1452 case Intrinsic::s390_vchlfs:
1453 case Intrinsic::s390_vchlgs:
1458 case Intrinsic::s390_vtm:
1463 case Intrinsic::s390_vfaebs:
1464 case Intrinsic::s390_vfaehs:
1465 case Intrinsic::s390_vfaefs:
1470 case Intrinsic::s390_vfaezbs:
1471 case Intrinsic::s390_vfaezhs:
1472 case Intrinsic::s390_vfaezfs:
1477 case Intrinsic::s390_vfeebs:
1478 case Intrinsic::s390_vfeehs:
1479 case Intrinsic::s390_vfeefs:
1484 case Intrinsic::s390_vfeezbs:
1485 case Intrinsic::s390_vfeezhs:
1486 case Intrinsic::s390_vfeezfs:
1491 case Intrinsic::s390_vfenebs:
1492 case Intrinsic::s390_vfenehs:
1493 case Intrinsic::s390_vfenefs:
1498 case Intrinsic::s390_vfenezbs:
1499 case Intrinsic::s390_vfenezhs:
1500 case Intrinsic::s390_vfenezfs:
1505 case Intrinsic::s390_vistrbs:
1506 case Intrinsic::s390_vistrhs:
1507 case Intrinsic::s390_vistrfs:
1512 case Intrinsic::s390_vstrcbs:
1513 case Intrinsic::s390_vstrchs:
1514 case Intrinsic::s390_vstrcfs:
1519 case Intrinsic::s390_vstrczbs:
1520 case Intrinsic::s390_vstrczhs:
1521 case Intrinsic::s390_vstrczfs:
1526 case Intrinsic::s390_vfcedbs:
1527 case Intrinsic::s390_vfcesbs:
1532 case Intrinsic::s390_vfchdbs:
1533 case Intrinsic::s390_vfchsbs:
1538 case Intrinsic::s390_vfchedbs:
1539 case Intrinsic::s390_vfchesbs:
1544 case Intrinsic::s390_vftcidb:
1545 case Intrinsic::s390_vftcisb:
1550 case Intrinsic::s390_tdc:
1568 for (
unsigned I = 2;
I < NumOps; ++
I)
1587 for (
unsigned I = 1;
I < NumOps; ++
I)
1604 case ISD::SET##X: return SystemZ::CCMASK_CMP_##X; \
1605 case ISD::SETO##X: return SystemZ::CCMASK_CMP_##X; \
1606 case ISD::SETU##X: return SystemZ::CCMASK_CMP_UO | SystemZ::CCMASK_CMP_##X
1643 uint64_t TopBit = uint64_t(1) << 31;
1648 if (CCMask == (CCValid & (SystemZ::CCMASK_0
1656 | SystemZ::CCMASK_3)))
1668 if (CCMask == (CCValid & (SystemZ::CCMASK_0 | SystemZ::CCMASK_3)))
1679 if (CCMask == (CCValid & (SystemZ::CCMASK_0
1681 | SystemZ::CCMASK_3)))
1683 if (CCMask == (CCValid & (SystemZ::CCMASK_0
1685 | SystemZ::CCMASK_3)))
1702 int64_t
Value = ConstOp1->getSExtValue();
1708 C.Op1 = DAG.
getConstant(0, DL, C.Op1.getValueType());
1718 if (!C.Op0.hasOneUse() ||
1724 auto *
Load = cast<LoadSDNode>(C.Op0);
1725 unsigned NumBits =
Load->getMemoryVT().getStoreSizeInBits();
1726 if (NumBits != 8 && NumBits != 16)
1731 auto *ConstOp1 = cast<ConstantSDNode>(C.Op1);
1732 uint64_t
Value = ConstOp1->getZExtValue();
1733 uint64_t
Mask = (1 << NumBits) - 1;
1736 int64_t SignedValue = ConstOp1->getSExtValue();
1737 if (uint64_t(SignedValue) + (uint64_t(1) << (NumBits - 1)) > Mask)
1743 }
else if (NumBits == 8) {
1769 if (C.Op0.getValueType() !=
MVT::i32 ||
1770 Load->getExtensionType() != ExtType)
1772 Load->getBasePtr(),
Load->getPointerInfo(),
1773 Load->getMemoryVT(),
Load->getAlignment(),
1774 Load->getMemOperand()->getFlags());
1777 if (C.Op1.getValueType() !=
MVT::i32 ||
1778 Value != ConstOp1->getZExtValue())
1791 switch (
Load->getExtensionType()) {
1814 if (isa<ConstantFPSDNode>(C.Op1))
1820 if (ConstOp1 && ConstOp1->getZExtValue() == 0)
1849 unsigned Opcode0 = C.Op0.getOpcode();
1857 cast<ConstantSDNode>(C.Op0.getOperand(1))->getZExtValue() == 0xffffffff)
1879 for (
auto I = C.Op0->use_begin(),
E = C.Op0->use_end();
I !=
E; ++
I) {
1898 if (C1 && C1->isZero()) {
1899 for (
auto I = C.Op0->use_begin(),
E = C.Op0->use_end();
I !=
E; ++
I) {
1918 if (C.Op0.getOpcode() ==
ISD::SHL &&
1919 C.Op0.getValueType() ==
MVT::i64 &&
1921 cast<ConstantSDNode>(C.Op1)->getZExtValue() == 0) {
1923 if (C1 && C1->getZExtValue() == 32) {
1924 SDValue ShlOp0 = C.Op0.getOperand(0);
1944 C.Op0.getOperand(0).getOpcode() ==
ISD::LOAD &&
1946 cast<ConstantSDNode>(C.Op1)->getZExtValue() == 0) {
1947 auto *
L = cast<LoadSDNode>(C.Op0.getOperand(0));
1948 if (
L->getMemoryVT().getStoreSizeInBits() <= C.Op0.getValueSizeInBits()) {
1949 unsigned Type =
L->getExtensionType();
1952 C.Op0 = C.Op0.getOperand(0);
1953 C.Op1 = DAG.
getConstant(0, DL, C.Op0.getValueType());
1981 uint64_t
Mask, uint64_t CmpVal,
1982 unsigned ICmpType) {
1983 assert(Mask != 0 &&
"ANDs with zero should have been removed by now");
1992 uint64_t
High = uint64_t(1) << HighShift;
2006 if (EffectivelyUnsigned && CmpVal > 0 && CmpVal <= Low) {
2012 if (EffectivelyUnsigned && CmpVal < Low) {
2020 if (CmpVal == Mask) {
2026 if (EffectivelyUnsigned && CmpVal >= Mask - Low && CmpVal < Mask) {
2032 if (EffectivelyUnsigned && CmpVal > Mask - Low && CmpVal <= Mask) {
2040 if (EffectivelyUnsigned && CmpVal >= Mask - High && CmpVal < High) {
2046 if (EffectivelyUnsigned && CmpVal > Mask - High && CmpVal <= High) {
2055 if (Mask == Low + High) {
2084 if (C.Op0.getOpcode() ==
ISD::AND) {
2085 NewC.Op0 = C.Op0.getOperand(0);
2086 NewC.Op1 = C.Op0.getOperand(1);
2095 if (NewC.Op0.getValueType() !=
MVT::i64 ||
2103 if (CmpVal == uint64_t(-1))
2110 MaskVal = -(CmpVal & -CmpVal);
2118 unsigned BitSize = NewC.Op0.getValueSizeInBits();
2119 unsigned NewCCMask, ShiftVal;
2121 NewC.Op0.getOpcode() ==
ISD::SHL &&
2123 (MaskVal >> ShiftVal != 0) &&
2125 MaskVal >> ShiftVal,
2128 NewC.Op0 = NewC.Op0.getOperand(0);
2129 MaskVal >>= ShiftVal;
2131 NewC.Op0.getOpcode() ==
ISD::SRL &&
2133 (MaskVal << ShiftVal != 0) &&
2135 MaskVal << ShiftVal,
2138 NewC.Op0 = NewC.Op0.getOperand(0);
2139 MaskVal <<= ShiftVal;
2153 C.Op1 = DAG.
getConstant(MaskVal, DL, C.Op0.getValueType());
2155 C.CCMask = NewCCMask;
2163 SDValue Call,
unsigned CCValid, uint64_t CC,
2167 C.CCValid = CCValid;
2170 C.CCMask = CC < 4 ? 1 << (3 - CC) : 0;
2173 C.CCMask = CC < 4 ? ~(1 << (3 - CC)) : -1;
2177 C.CCMask = CC < 4 ? ~0U << (4 - CC) : -1;
2180 C.CCMask = CC < 4 ? ~(~0U << (4 - CC)) : 0;
2184 C.CCMask = CC < 4 ? ~0U << (3 - CC) : -1;
2187 C.CCMask = CC < 4 ? ~(~0U << (3 - CC)) : 0;
2190 C.CCMask &= CCValid;
2198 uint64_t
Constant = cast<ConstantSDNode>(CmpOp1)->getZExtValue();
2199 unsigned Opcode, CCValid;
2209 Comparison
C(CmpOp0, CmpOp1);
2211 if (C.Op0.getValueType().isFloatingPoint()) {
2250 if (!C.Op1.getNode()) {
2252 switch (C.Op0.getOpcode()) {
2308 unsigned CCValid,
unsigned CCMask) {
2312 if (Conversion.XORValue)
2316 if (Conversion.AddValue)
2323 if (Conversion.Bit != 31)
2378 int Mask[] = { Start, -1, Start + 1, -1 };
2402 return DAG.
getNode(Opcode, DL, VT, CmpOp0, CmpOp1);
2413 bool Invert =
false;
2421 assert(IsFP &&
"Unexpected integer comparison");
2433 assert(IsFP &&
"Unexpected integer comparison");
2445 Cmp = getVectorCmp(DAG, Opcode, DL, VT, CmpOp0, CmpOp1);
2449 Cmp = getVectorCmp(DAG, Opcode, DL, VT, CmpOp1, CmpOp0);
2472 return lowerVectorSETCC(DAG, DL, VT, CC, CmpOp0, CmpOp1);
2474 Comparison
C(
getCmp(DAG, CmpOp0, CmpOp1, CC, DL));
2476 return emitSETCC(DAG, DL, Glue,
C.CCValid,
C.CCMask);
2486 Comparison
C(
getCmp(DAG, CmpOp0, CmpOp1, CC, DL));
2498 cast<ConstantSDNode>(Neg.
getOperand(0))->getZExtValue() == 0 &&
2502 Pos.getOperand(0) == CmpOp)));
2524 Comparison
C(
getCmp(DAG, CmpOp0, CmpOp1, CC, DL));
2533 cast<ConstantSDNode>(
C.Op1)->getZExtValue() == 0) {
2546 if (TrueC && FalseC) {
2548 int64_t FalseVal = FalseC->getSExtValue();
2549 if ((TrueVal == -1 && FalseVal == 0) || (TrueVal == 0 && FalseVal == -1)) {
2552 C.CCMask ^=
C.CCValid;
2583 uint64_t Anchor = Offset & ~uint64_t(0xfff);
2589 if (Offset != 0 && (Offset & 1) == 0) {
2621 Chain = DAG.
getCopyToReg(Chain, DL, SystemZ::R12D, GOT, Glue);
2623 Chain = DAG.
getCopyToReg(Chain, DL, SystemZ::R2D, GOTOffset, Glue);
2642 assert(Mask &&
"Missing call preserved mask for calling convention");
2650 Chain = DAG.
getNode(Opcode, DL, NodeTys, Ops);
2657 SDValue SystemZTargetLowering::lowerThreadPointer(
const SDLoc &DL,
2685 SDValue TP = lowerThreadPointer(DL, DAG);
2811 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
2817 if (!BackChainIdx) {
2820 FI->setFramePointerSaveIndex(BackChainIdx);
2842 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
2851 unsigned LinkReg = MF.
addLiveIn(SystemZ::R14D, &SystemZ::GR64BitRegClass);
2865 if (
auto *LoadN = dyn_cast<LoadSDNode>(In))
2867 return DAG.
getLoad(ResVT, DL, LoadN->getChain(), LoadN->getBasePtr(),
2868 LoadN->getMemOperand());
2914 const unsigned NumFields = 4;
2924 unsigned Offset = 0;
2925 for (
unsigned I = 0;
I < NumFields; ++
I) {
2930 MemOps[
I] = DAG.
getStore(Chain, DL, Fields[
I], FieldAddr,
2942 const Value *DstSV = cast<SrcValueSDNode>(Op.
getOperand(3))->getValue();
2943 const Value *SrcSV = cast<SrcValueSDNode>(Op.
getOperand(4))->getValue();
2952 SDValue SystemZTargetLowering::
2956 bool RealignOpt = !MF.
getFunction()-> hasFnAttribute(
"no-realign-stack");
2966 uint64_t AlignVal = (RealignOpt ?
2970 uint64_t RequiredAlign =
std::max(AlignVal, StackAlign);
2971 uint64_t ExtraAlignSpace = RequiredAlign - StackAlign;
2985 if (ExtraAlignSpace)
3002 if (RequiredAlign > StackAlign) {
3014 SDValue Ops[2] = { Result, Chain };
3018 SDValue SystemZTargetLowering::lowerGET_DYNAMIC_AREA_OFFSET(
3064 LL, RL, Ops[1], Ops[0]);
3141 if ((Masks[0] >> 32) == 0xffffffff &&
uint32_t(Masks[1]) == 0xffffffff)
3143 else if ((Masks[1] >> 32) == 0xffffffff &&
uint32_t(Masks[0]) == 0xffffffff)
3158 int64_t
Value = int32_t(cast<ConstantSDNode>(LowOp)->getZExtValue());
3168 uint64_t Mask = cast<ConstantSDNode>(HighOp.
getOperand(1))->getZExtValue();
3226 unsigned NumSignificantBits = (~Known.
Zero).getActiveBits();
3227 if (NumSignificantBits == 0)
3232 int64_t BitSize = (int64_t)1 <<
Log2_32_Ceil(NumSignificantBits);
3233 BitSize =
std::min(BitSize, OrigBitSize);
3242 for (int64_t I = BitSize / 2; I >= 8; I = I / 2) {
3244 if (BitSize != OrigBitSize)
3246 DAG.
getConstant(((uint64_t)1 << BitSize) - 1, DL, VT));
3262 cast<ConstantSDNode>(Op.
getOperand(1))->getZExtValue());
3264 cast<ConstantSDNode>(Op.
getOperand(2))->getZExtValue());
3283 auto *Node = cast<AtomicSDNode>(Op.
getNode());
3287 Chain, Node->getBasePtr(),
3288 Node->getMemoryVT(), Node->getMemOperand());
3295 auto *Node = cast<AtomicSDNode>(Op.
getNode());
3297 Node->getBasePtr(), Node->getMemoryVT(),
3298 Node->getMemOperand());
3307 unsigned Opcode)
const {
3308 auto *Node = cast<AtomicSDNode>(Op.
getNode());
3311 EVT NarrowVT = Node->getMemoryVT();
3313 if (NarrowVT == WideVT)
3316 int64_t BitSize = NarrowVT.getSizeInBits();
3317 SDValue ChainIn = Node->getChain();
3318 SDValue Addr = Node->getBasePtr();
3319 SDValue Src2 = Node->getVal();
3326 if (
auto *Const = dyn_cast<ConstantSDNode>(Src2)) {
3361 SDValue Ops[] = { ChainIn, AlignedAddr, Src2, BitShift, NegBitShift,
3381 auto *Node = cast<AtomicSDNode>(Op.
getNode());
3382 EVT MemVT = Node->getMemoryVT();
3386 SDValue Src2 = Node->getVal();
3390 if (
auto *Op2 = dyn_cast<ConstantSDNode>(Src2)) {
3393 int64_t Value = (-Op2->getAPIntValue()).getSExtValue();
3403 Node->getChain(), Node->getBasePtr(), NegSrc2,
3404 Node->getMemOperand());
3417 auto *Node = cast<AtomicSDNode>(Op.
getNode());
3420 EVT NarrowVT = Node->getMemoryVT();
3422 if (NarrowVT == WideVT)
3425 int64_t BitSize = NarrowVT.getSizeInBits();
3451 SDValue Ops[] = { ChainIn, AlignedAddr, CmpVal, SwapVal, BitShift,
3452 NegBitShift, DAG.
getConstant(BitSize, DL, WideVT) };
3454 VTList, Ops, NarrowVT, MMO);
3477 if (StoreBackchain) {
3482 Chain = DAG.
getCopyToReg(Chain, DL, SystemZ::R15D, NewSP);
3498 bool IsWrite = cast<ConstantSDNode>(Op.
getOperand(2))->getZExtValue();
3500 auto *Node = cast<MemIntrinsicSDNode>(Op.
getNode());
3508 Node->getMemoryVT(), Node->getMemOperand());
3522 SystemZTargetLowering::lowerINTRINSIC_W_CHAIN(
SDValue Op,
3524 unsigned Opcode, CCValid;
3537 SystemZTargetLowering::lowerINTRINSIC_WO_CHAIN(
SDValue Op,
3539 unsigned Opcode, CCValid;
3550 unsigned Id = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
3552 case Intrinsic::thread_pointer:
3553 return lowerThreadPointer(
SDLoc(Op), DAG);
3555 case Intrinsic::s390_vpdi:
3559 case Intrinsic::s390_vperm:
3563 case Intrinsic::s390_vuphb:
3564 case Intrinsic::s390_vuphh:
3565 case Intrinsic::s390_vuphf:
3569 case Intrinsic::s390_vuplhb:
3570 case Intrinsic::s390_vuplhh:
3571 case Intrinsic::s390_vuplhf:
3575 case Intrinsic::s390_vuplb:
3576 case Intrinsic::s390_vuplhw:
3577 case Intrinsic::s390_vuplf:
3581 case Intrinsic::s390_vupllb:
3582 case Intrinsic::s390_vupllh:
3583 case Intrinsic::s390_vupllf:
3587 case Intrinsic::s390_vsumb:
3588 case Intrinsic::s390_vsumh:
3589 case Intrinsic::s390_vsumgh:
3590 case Intrinsic::s390_vsumgf:
3591 case Intrinsic::s390_vsumqf:
3592 case Intrinsic::s390_vsumqg:
3615 { 0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 20, 21, 22, 23 } },
3618 { 0, 1, 2, 3, 16, 17, 18, 19, 4, 5, 6, 7, 20, 21, 22, 23 } },
3621 { 0, 1, 16, 17, 2, 3, 18, 19, 4, 5, 20, 21, 6, 7, 22, 23 } },
3624 { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 } },
3627 { 8, 9, 10, 11, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31 } },
3630 { 8, 9, 10, 11, 24, 25, 26, 27, 12, 13, 14, 15, 28, 29, 30, 31 } },
3633 { 8, 9, 24, 25, 10, 11, 26, 27, 12, 13, 28, 29, 14, 15, 30, 31 } },
3636 { 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31 } },
3639 { 4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31 } },
3642 { 2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31 } },
3645 { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31 } },
3648 { 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 } },
3651 { 0, 1, 2, 3, 4, 5, 6, 7, 24, 25, 26, 27, 28, 29, 30, 31 } }
3665 OpNo0 = OpNo1 = OpNos[1];
3666 }
else if (OpNos[1] < 0) {
3667 OpNo0 = OpNo1 = OpNos[0];
3685 unsigned &OpNo0,
unsigned &OpNo1) {
3686 int OpNos[] = { -1, -1 };
3693 if ((Elt ^ P.Bytes[I]) & (SystemZ::VectorBytes - 1))
3699 if (OpNos[ModelOpNo] == 1 - RealOpNo)
3701 OpNos[ModelOpNo] = RealOpNo;
3709 unsigned &OpNo0,
unsigned &OpNo1) {
3710 for (
auto &
P : PermuteForms)
3726 int Elt = Bytes[From];
3729 Transform[From] = -1;
3731 while (P.Bytes[To] != Elt) {
3733 if (To == SystemZ::VectorBytes)
3736 Transform[From] = To;
3745 for (
auto &
P : PermuteForms)
3758 Bytes.
resize(NumElements * BytesPerElement, -1);
3759 for (
unsigned I = 0; I < NumElements; ++
I) {
3762 for (
unsigned J = 0; J < BytesPerElement; ++J)
3763 Bytes[I * BytesPerElement + J] = Index * BytesPerElement + J;
3772 unsigned BytesPerElement,
int &
Base) {
3774 for (
unsigned I = 0; I < BytesPerElement; ++
I) {
3775 if (Bytes[Start + I] >= 0) {
3776 unsigned Elem = Bytes[Start +
I];
3780 if (
unsigned(Base) % Bytes.
size() + BytesPerElement > Bytes.
size())
3782 }
else if (
unsigned(Base) != Elem -
I)
3795 unsigned &StartIndex,
unsigned &OpNo0,
3797 int OpNos[] = { -1, -1 };
3799 for (
unsigned I = 0; I < 16; ++
I) {
3800 int Index = Bytes[
I];
3806 Shift = ExpectedShift;
3807 else if (Shift != ExpectedShift)
3811 if (OpNos[ModelOpNo] == 1 - RealOpNo)
3813 OpNos[ModelOpNo] = RealOpNo;
3843 Op = DAG.
getNode(P.Opcode, DL, InVT, Op0, Op1);
3854 for (
unsigned I = 0; I < 2; ++
I)
3858 unsigned StartIndex, OpNo0, OpNo1;
3876 struct GeneralShuffle {
3877 GeneralShuffle(
EVT vt) : VT(vt) {}
3896 void GeneralShuffle::addUndef() {
3898 for (
unsigned I = 0; I < BytesPerElement; ++
I)
3899 Bytes.push_back(-1);
3919 if (FromBytesPerElement < BytesPerElement)
3923 (FromBytesPerElement - BytesPerElement));
3952 for (; OpNo < Ops.size(); ++OpNo)
3953 if (Ops[OpNo] == Op)
3955 if (OpNo == Ops.size())
3960 for (
unsigned I = 0; I < BytesPerElement; ++
I)
3961 Bytes.push_back(Base + I);
3970 if (Ops.size() == 0)
3974 if (Ops.size() == 1)
3986 unsigned Stride = 1;
3987 for (; Stride * 2 < Ops.size(); Stride *= 2) {
3988 for (
unsigned I = 0; I < Ops.size() - Stride; I += Stride * 2) {
3989 SDValue SubOps[] = { Ops[
I], Ops[I + Stride] };
3998 else if (OpNo == I + Stride)
3999 NewBytes[J] = SystemZ::VectorBytes + Byte;
4009 if (NewBytes[J] >= 0) {
4010 assert(
unsigned(NewBytesMap[J]) < SystemZ::VectorBytes &&
4011 "Invalid double permute");
4012 Bytes[J] = I * SystemZ::VectorBytes + NewBytesMap[J];
4014 assert(NewBytesMap[J] < 0 &&
"Invalid double permute");
4020 if (NewBytes[J] >= 0)
4021 Bytes[J] = I * SystemZ::VectorBytes + J;
4028 Ops[1] = Ops[Stride];
4030 if (Bytes[I] >=
int(SystemZ::VectorBytes))
4031 Bytes[
I] -= (Stride - 1) * SystemZ::VectorBytes;
4036 unsigned OpNo0, OpNo1;
4115 Value = dyn_cast<ConstantSDNode>(Op)->getZExtValue();
4117 Value = (dyn_cast<ConstantFPSDNode>(Op)->getValueAPF().bitcastToAPInt()
4121 for (
unsigned J = 0; J < BytesPerElement; ++J) {
4122 uint64_t Byte = (Value >> (J * 8)) & 0xff;
4124 Mask |= 1ULL << ((
E - I - 1) * BytesPerElement + J);
4140 const SDLoc &DL,
EVT VT, uint64_t Value,
4141 unsigned BitsPerElement) {
4143 int64_t SignedValue =
SignExtend64(Value, BitsPerElement);
4154 unsigned Start,
End;
4155 if (TII->
isRxSBGMask(Value, BitsPerElement, Start, End)) {
4160 Start -= 64 - BitsPerElement;
4161 End -= 64 - BitsPerElement;
4185 GeneralShuffle GS(VT);
4187 bool FoundOne =
false;
4188 for (
unsigned I = 0; I < NumElements; ++
I) {
4194 unsigned Elem = cast<ConstantSDNode>(Op.
getOperand(1))->getZExtValue();
4212 if (!ResidueOps.
empty()) {
4213 while (ResidueOps.
size() < NumElements)
4215 for (
auto &Op : GS.Ops) {
4222 return GS.getNode(DAG,
SDLoc(BVN));
4230 unsigned int NumElements = Elems.
size();
4231 unsigned int Count = 0;
4232 for (
auto Elem : Elems) {
4233 if (!Elem.isUndef()) {
4236 else if (Elem != Single) {
4260 bool AllLoads =
true;
4261 for (
auto Elem : Elems)
4262 if (Elem.getOpcode() !=
ISD::LOAD || cast<LoadSDNode>(Elem)->isIndexed()) {
4269 return joinDwords(DAG, DL, Elems[0], Elems[1]);
4304 unsigned NumConstants = 0;
4305 for (
unsigned I = 0; I < NumElements; ++
I) {
4310 Constants[
I] = Elem;
4318 if (NumConstants > 0) {
4319 for (
unsigned I = 0; I < NumElements; ++
I)
4320 if (!Constants[I].getNode())
4321 Constants[I] = DAG.
getUNDEF(Elems[I].getValueType());
4329 unsigned LoadElIdx = UINT_MAX;
4330 for (
unsigned I = 0; I < NumElements; ++
I)
4331 if (Elems[I].getOpcode() ==
ISD::LOAD &&
4332 cast<LoadSDNode>(Elems[I])->isUnindexed()) {
4336 if (LoadElIdx != UINT_MAX) {
4338 Done[LoadElIdx] =
true;
4341 unsigned I1 = NumElements / 2 - 1;
4342 unsigned I2 = NumElements - 1;
4343 bool Def1 = !Elems[I1].isUndef();
4344 bool Def2 = !Elems[I2].isUndef();
4346 SDValue Elem1 = Elems[Def1 ? I1 : I2];
4347 SDValue Elem2 = Elems[Def2 ? I2 : I1];
4358 for (
unsigned I = 0; I < NumElements; ++
I)
4359 if (!Done[I] && !Elems[I].isUndef())
4369 auto *BVN = cast<BuildVectorSDNode>(Op.
getNode());
4373 if (BVN->isConstant()) {
4385 APInt SplatBits, SplatUndef;
4386 unsigned SplatBitSize;
4388 if (BVN->isConstantSplat(SplatBits, SplatUndef, SplatBitSize, HasAnyUndefs,
4390 SplatBitSize <= 64) {
4397 uint64_t
Lower = (SplatUndefZ
4399 uint64_t
Upper = (SplatUndefZ
4400 & ~((uint64_t(1) <<
findLastSet(SplatBitsZ)) - 1));
4401 uint64_t Value = SplatBitsZ | Upper |
Lower;
4410 uint64_t Middle = SplatUndefZ & ~Upper & ~
Lower;
4411 Value = SplatBitsZ | Middle;
4432 for (
unsigned I = 0; I < NumElements; ++
I)
4439 auto *VSN = cast<ShuffleVectorSDNode>(Op.
getNode());
4444 if (VSN->isSplat()) {
4446 unsigned Index = VSN->getSplatIndex();
4448 "Splat index should be defined and in first operand");
4458 GeneralShuffle
GS(VT);
4459 for (
unsigned I = 0; I < NumElements; ++
I) {
4460 int Elt = VSN->getMaskElt(I);
4463 else if (!
GS.add(Op.
getOperand(
unsigned(Elt) / NumElements),
4467 return GS.getNode(DAG,
SDLoc(VSN));
4479 SDValue SystemZTargetLowering::lowerINSERT_VECTOR_ELT(
SDValue Op,
4495 uint64_t Index =
dyn_cast<ConstantSDNode>(Op2)->getZExtValue();
4511 SystemZTargetLowering::lowerEXTRACT_VECTOR_ELT(
SDValue Op,
4521 if (
auto *CIndexN = dyn_cast<ConstantSDNode>(Op1)) {
4522 uint64_t Index = CIndexN->getZExtValue();
4538 unsigned UnpackHigh)
const {
4548 PackedOp = DAG.
getNode(UnpackHigh,
SDLoc(PackedOp), OutVT, PackedOp);
4549 }
while (FromBits != ToBits);
4554 unsigned ByScalar)
const {
4563 if (
auto *BVN = dyn_cast<BuildVectorSDNode>(Op1)) {
4564 APInt SplatBits, SplatUndef;
4565 unsigned SplatBitSize;
4569 if (BVN->isConstantSplat(SplatBits, SplatUndef, SplatBitSize, HasAnyUndefs,
4570 ElemBitSize,
true) &&
4571 SplatBitSize == ElemBitSize) {
4574 return DAG.
getNode(ByScalar, DL, VT, Op0, Shift);
4578 SDValue Splat = BVN->getSplatValue(&UndefElements);
4583 return DAG.
getNode(ByScalar, DL, VT, Op0, Shift);
4589 if (
auto *VSN = dyn_cast<ShuffleVectorSDNode>(Op1)) {
4590 if (VSN->isSplat()) {
4592 unsigned Index = VSN->getSplatIndex();
4594 "Splat index should be defined and in first operand");
4601 return DAG.
getNode(ByScalar, DL, VT, Op0, Shift);
4614 return lowerFRAMEADDR(Op, DAG);
4616 return lowerRETURNADDR(Op, DAG);
4618 return lowerBR_CC(Op, DAG);
4620 return lowerSELECT_CC(Op, DAG);
4622 return lowerSETCC(Op, DAG);
4624 return lowerGlobalAddress(cast<GlobalAddressSDNode>(Op), DAG);
4626 return lowerGlobalTLSAddress(cast<GlobalAddressSDNode>(Op), DAG);
4628 return lowerBlockAddress(cast<BlockAddressSDNode>(Op), DAG);
4630 return lowerJumpTable(cast<JumpTableSDNode>(Op), DAG);
4632 return lowerConstantPool(cast<ConstantPoolSDNode>(Op), DAG);
4634 return lowerBITCAST(Op, DAG);
4636 return lowerVASTART(Op, DAG);
4638 return lowerVACOPY(Op, DAG);
4640 return lowerDYNAMIC_STACKALLOC(Op, DAG);
4642 return lowerGET_DYNAMIC_AREA_OFFSET(Op, DAG);
4644 return lowerSMUL_LOHI(Op, DAG);
4646 return lowerUMUL_LOHI(Op, DAG);
4648 return lowerSDIVREM(Op, DAG);
4650 return lowerUDIVREM(Op, DAG);
4652 return lowerOR(Op, DAG);
4654 return lowerCTPOP(Op, DAG);
4656 return lowerATOMIC_FENCE(Op, DAG);
4660 return lowerATOMIC_STORE(Op, DAG);
4662 return lowerATOMIC_LOAD(Op, DAG);
4666 return lowerATOMIC_LOAD_SUB(Op, DAG);
4684 return lowerATOMIC_CMP_SWAP(Op, DAG);
4686 return lowerSTACKSAVE(Op, DAG);
4688 return lowerSTACKRESTORE(Op, DAG);
4690 return lowerPREFETCH(Op, DAG);
4692 return lowerINTRINSIC_W_CHAIN(Op, DAG);
4694 return lowerINTRINSIC_WO_CHAIN(Op, DAG);
4696 return lowerBUILD_VECTOR(Op, DAG);
4698 return lowerVECTOR_SHUFFLE(Op, DAG);
4700 return lowerSCALAR_TO_VECTOR(Op, DAG);
4702 return lowerINSERT_VECTOR_ELT(Op, DAG);
4704 return lowerEXTRACT_VECTOR_ELT(Op, DAG);
4721 #define OPCODE(NAME) case SystemZISD::NAME: return "SystemZISD::" #NAME
4830 bool SystemZTargetLowering::canTreatAsByteVector(
EVT VT)
const {
4842 SDValue SystemZTargetLowering::combineExtract(
const SDLoc &DL,
EVT ResVT,
4845 DAGCombinerInfo &DCI,
4866 BytesPerElement, First))
4873 if (Byte % BytesPerElement != 0)
4876 Index = Byte / BytesPerElement;
4885 if (OpBytesPerElement < BytesPerElement)
4889 unsigned End = (Index + 1) * BytesPerElement;
4890 if (End % OpBytesPerElement != 0)
4893 Op = Op.
getOperand(End / OpBytesPerElement - 1);
4897 DCI.AddToWorklist(Op.getNode());
4902 DCI.AddToWorklist(Op.getNode());
4909 canTreatAsByteVector(Op.getValueType()) &&
4910 canTreatAsByteVector(Op.getOperand(0).getValueType())) {
4912 EVT ExtVT = Op.getValueType();
4913 EVT OpVT = Op.getOperand(0).getValueType();
4916 unsigned Byte = Index * BytesPerElement;
4917 unsigned SubByte = Byte % ExtBytesPerElement;
4918 unsigned MinSubByte = ExtBytesPerElement - OpBytesPerElement;
4919 if (SubByte < MinSubByte ||
4920 SubByte + BytesPerElement > ExtBytesPerElement)
4923 Byte = Byte / ExtBytesPerElement * OpBytesPerElement;
4925 Byte += SubByte - MinSubByte;
4926 if (Byte % BytesPerElement != 0)
4928 Op = Op.getOperand(0);
4929 Index = Byte / BytesPerElement;
4935 if (Op.getValueType() != VecVT) {
4937 DCI.AddToWorklist(Op.getNode());
4947 SDValue SystemZTargetLowering::combineTruncateExtract(
4948 const SDLoc &DL,
EVT TruncVT,
SDValue Op, DAGCombinerInfo &DCI)
const {
4956 if (canTreatAsByteVector(VecVT)) {
4957 if (
auto *IndexN = dyn_cast<ConstantSDNode>(Op.
getOperand(1))) {
4960 if (BytesPerElement % TruncBytes == 0) {
4966 unsigned Scale = BytesPerElement / TruncBytes;
4967 unsigned NewIndex = (IndexN->getZExtValue() + 1) * Scale - 1;
4973 EVT ResVT = (TruncBytes < 4 ?
MVT::i32 : TruncVT);
4974 return combineExtract(DL, ResVT, VecVT, Vec, NewIndex, DCI,
true);
4982 SDValue SystemZTargetLowering::combineSIGN_EXTEND(
4983 SDNode *
N, DAGCombinerInfo &DCI)
const {
4993 if (SraAmt && Inner.hasOneUse() && Inner.getOpcode() ==
ISD::SHL) {
4994 if (
auto *ShlAmt = dyn_cast<ConstantSDNode>(Inner.getOperand(1))) {
4996 unsigned NewShlAmt = ShlAmt->getZExtValue() + Extra;
4997 unsigned NewSraAmt = SraAmt->getZExtValue() + Extra;
5000 Inner.getOperand(0));
5012 SDValue SystemZTargetLowering::combineMERGE(
5013 SDNode *N, DAGCombinerInfo &DCI)
const {
5021 cast<ConstantSDNode>(Op0.
getOperand(0))->getZExtValue() == 0) {
5029 if (ElemBytes <= 4) {
5034 SystemZ::VectorBytes / ElemBytes / 2);
5037 DCI.AddToWorklist(Op1.
getNode());
5040 DCI.AddToWorklist(Op.
getNode());
5047 SDValue SystemZTargetLowering::combineSTORE(
5048 SDNode *N, DAGCombinerInfo &DCI)
const {
5050 auto *SN = cast<StoreSDNode>(
N);
5052 EVT MemVT = SN->getMemoryVT();
5059 combineTruncateExtract(
SDLoc(N), MemVT, SN->getValue(), DCI)) {
5060 DCI.AddToWorklist(Value.getNode());
5064 SN->getBasePtr(), SN->getMemoryVT(),
5065 SN->getMemOperand());
5070 if (!SN->isVolatile() &&
5072 Op1.getNode()->hasOneUse() &&
5089 Ops, MemVT, SN->getMemOperand());
5094 SDValue SystemZTargetLowering::combineEXTRACT_VECTOR_ELT(
5095 SDNode *N, DAGCombinerInfo &DCI)
const {
5101 if (
auto *IndexN = dyn_cast<ConstantSDNode>(N->
getOperand(1))) {
5105 IndexN->getZExtValue(), DCI,
false);
5110 SDValue SystemZTargetLowering::combineJOIN_DWORDS(
5111 SDNode *N, DAGCombinerInfo &DCI)
const {
5120 SDValue SystemZTargetLowering::combineFP_ROUND(
5121 SDNode *N, DAGCombinerInfo &DCI)
const {
5135 cast<ConstantSDNode>(Op0.
getOperand(1))->getZExtValue() == 0) {
5137 for (
auto *U : Vec->
uses()) {
5141 U->getOperand(0) == Vec &&
5143 cast<ConstantSDNode>(U->getOperand(1))->getZExtValue() == 1) {
5150 DCI.AddToWorklist(VRound.
getNode());
5154 DCI.AddToWorklist(Extract1.
getNode());
5167 SDValue SystemZTargetLowering::combineBSWAP(
5168 SDNode *N, DAGCombinerInfo &DCI)
const {
5200 DCI.CombineTo(N, ResVal);
5212 SDValue SystemZTargetLowering::combineSHIFTROT(
5213 SDNode *N, DAGCombinerInfo &DCI)
const {
5228 auto *AndMask =
dyn_cast<ConstantSDNode>(AndMaskOp);
5232 auto AmtVal = AndMask->getZExtValue();
5235 if ((AmtVal & 0x3f) == 0x3f) {
5241 DCI.CombineTo(N1.
getNode(), AndOp);
5251 DCI.AddToWorklist(Replace.
getNode());
5259 }
else if (AmtVal >> 16 != 0) {
5262 auto NewMask = DAG.
getConstant(AndMask->getZExtValue() & 0x0000ffff,
5272 DCI.AddToWorklist(Replace.
getNode());
5289 case ISD::STORE:
return combineSTORE(N, DCI);
5293 case ISD::BSWAP:
return combineBSWAP(N, DCI);
5297 case ISD::ROTL:
return combineSHIFTROT(N, DCI);
5357 unsigned LOCROpcode)
const {
5370 BuildMI(*MBB, MI, DL, TII->get(LOCROpcode), DestReg)
5371 .addReg(FalseReg).
addReg(TrueReg)
5385 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
5399 BuildMI(*MBB, MI, DL, TII->get(SystemZ::PHI), DestReg)
5400 .addReg(TrueReg).
addMBB(StartMBB)
5413 unsigned StoreOpcode,
5414 unsigned STOCOpcode,
5415 bool Invert)
const {
5445 BuildMI(*MBB, MI, DL, TII->get(STOCOpcode))
5469 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
5478 BuildMI(MBB, DL, TII->get(StoreOpcode))
5498 unsigned BitSize,
bool Invert)
const {
5503 bool IsSubWord = (BitSize < 32);
5519 &SystemZ::GR32BitRegClass :
5520 &SystemZ::GR64BitRegClass);
5521 unsigned LOpcode = BitSize <= 32 ?
SystemZ::L : SystemZ::LG;
5522 unsigned CSOpcode = BitSize <= 32 ? SystemZ::CS : SystemZ::CSG;
5527 assert(LOpcode && CSOpcode &&
"Displacement out of range");
5532 unsigned NewVal = (BinOpcode || IsSubWord ?
5547 BuildMI(MBB, DL, TII->get(LOpcode), OrigVal).
add(Base).addImm(Disp).addReg(0);
5559 BuildMI(MBB, DL, TII->get(SystemZ::PHI), OldVal)
5560 .addReg(OrigVal).
addMBB(StartMBB)
5563 BuildMI(MBB, DL, TII->get(SystemZ::RLL), RotatedOldVal)
5568 BuildMI(MBB, DL, TII->get(BinOpcode), Tmp).addReg(RotatedOldVal).
add(Src2);
5571 BuildMI(MBB, DL, TII->get(SystemZ::XILF), RotatedNewVal)
5572 .addReg(Tmp).
addImm(-1U << (32 - BitSize));
5577 BuildMI(MBB, DL, TII->get(SystemZ::LCGR), Tmp2).addReg(Tmp);
5578 BuildMI(MBB, DL, TII->get(SystemZ::AGHI), RotatedNewVal)
5579 .addReg(Tmp2).
addImm(-1);
5581 }
else if (BinOpcode)
5583 BuildMI(MBB, DL, TII->get(BinOpcode), RotatedNewVal)
5584 .addReg(RotatedOldVal)
5589 BuildMI(MBB, DL, TII->get(SystemZ::RISBG32), RotatedNewVal)
5593 BuildMI(MBB, DL, TII->get(SystemZ::RLL), NewVal)
5595 BuildMI(MBB, DL, TII->get(CSOpcode), Dest)
5600 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
5617 unsigned KeepOldMask,
unsigned BitSize)
const {
5622 bool IsSubWord = (BitSize < 32);
5637 &SystemZ::GR32BitRegClass :
5638 &SystemZ::GR64BitRegClass);
5639 unsigned LOpcode = BitSize <= 32 ?
SystemZ::L : SystemZ::LG;
5640 unsigned CSOpcode = BitSize <= 32 ? SystemZ::CS : SystemZ::CSG;
5645 assert(LOpcode && CSOpcode &&
"Displacement out of range");
5667 BuildMI(MBB, DL, TII->get(LOpcode), OrigVal).
add(Base).addImm(Disp).addReg(0);
5676 BuildMI(MBB, DL, TII->get(SystemZ::PHI), OldVal)
5677 .addReg(OrigVal).
addMBB(StartMBB)
5680 BuildMI(MBB, DL, TII->get(SystemZ::RLL), RotatedOldVal)
5682 BuildMI(MBB, DL, TII->get(CompareOpcode))
5683 .addReg(RotatedOldVal).
addReg(Src2);
5684 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
5694 BuildMI(MBB, DL, TII->get(SystemZ::RISBG32), RotatedAltVal)
5695 .addReg(RotatedOldVal).
addReg(Src2)
5707 BuildMI(MBB, DL, TII->get(SystemZ::PHI), RotatedNewVal)
5708 .addReg(RotatedOldVal).
addMBB(LoopMBB)
5711 BuildMI(MBB, DL, TII->get(SystemZ::RLL), NewVal)
5713 BuildMI(MBB, DL, TII->get(CSOpcode), Dest)
5718 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
5730 SystemZTargetLowering::emitAtomicCmpSwapW(
MachineInstr &MI,
5754 assert(LOpcode && CSOpcode &&
"Displacement out of range");
5777 BuildMI(MBB, DL, TII->get(LOpcode), OrigOldVal)
5798 BuildMI(MBB, DL, TII->get(SystemZ::PHI), OldVal)
5799 .addReg(OrigOldVal).
addMBB(StartMBB)
5801 BuildMI(MBB, DL, TII->get(SystemZ::PHI), CmpVal)
5802 .addReg(OrigCmpVal).
addMBB(StartMBB)
5804 BuildMI(MBB, DL, TII->get(SystemZ::PHI), SwapVal)
5805 .addReg(OrigSwapVal).
addMBB(StartMBB)
5807 BuildMI(MBB, DL, TII->get(SystemZ::RLL), Dest)
5809 BuildMI(MBB, DL, TII->get(SystemZ::RISBG32), RetryCmpVal)
5811 BuildMI(MBB, DL, TII->get(SystemZ::CR))
5812 .addReg(Dest).
addReg(RetryCmpVal);
5813 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
5829 BuildMI(MBB, DL, TII->get(SystemZ::RISBG32), RetrySwapVal)
5831 BuildMI(MBB, DL, TII->get(SystemZ::RLL), StoreVal)
5832 .addReg(RetrySwapVal).
addReg(NegBitShift).
addImm(-BitSize);
5833 BuildMI(MBB, DL, TII->get(CSOpcode), RetryOldVal)
5838 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
5852 bool ClearEven)
const {
5863 BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::IMPLICIT_DEF), In128);
5868 BuildMI(*MBB, MI, DL, TII->get(SystemZ::LLILL), Zero64)
5870 BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::INSERT_SUBREG), NewIn128)
5871 .addReg(In128).
addReg(Zero64).
addImm(SystemZ::subreg_h64);
5874 BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::INSERT_SUBREG), Dest)
5875 .addReg(In128).
addReg(Src).
addImm(SystemZ::subreg_l64);
5905 uint64_t StartSrcReg =
forceReg(MI, SrcBase, TII);
5906 uint64_t StartDestReg = (HaveSingleBase ? StartSrcReg :
5911 uint64_t ThisDestReg = (HaveSingleBase ? ThisSrcReg :
5914 uint64_t NextDestReg = (HaveSingleBase ? NextSrcReg :
5917 RC = &SystemZ::GR64BitRegClass;
5944 BuildMI(MBB, DL, TII->get(SystemZ::PHI), ThisDestReg)
5945 .addReg(StartDestReg).
addMBB(StartMBB)
5947 if (!HaveSingleBase)
5948 BuildMI(MBB, DL, TII->get(SystemZ::PHI), ThisSrcReg)
5949 .addReg(StartSrcReg).
addMBB(StartMBB)
5951 BuildMI(MBB, DL, TII->get(SystemZ::PHI), ThisCountReg)
5952 .addReg(StartCountReg).
addMBB(StartMBB)
5955 BuildMI(MBB, DL, TII->get(SystemZ::PFD))
5958 BuildMI(MBB, DL, TII->get(Opcode))
5962 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
5980 BuildMI(MBB, DL, TII->get(SystemZ::LA), NextDestReg)
5982 if (!HaveSingleBase)
5983 BuildMI(MBB, DL, TII->get(SystemZ::LA), NextSrcReg)
5985 BuildMI(MBB, DL, TII->get(SystemZ::AGHI), NextCountReg)
5986 .addReg(ThisCountReg).
addImm(-1);
5987 BuildMI(MBB, DL, TII->get(SystemZ::CGHI))
5988 .addReg(NextCountReg).
addImm(0);
5989 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
6001 while (Length > 0) {
6002 uint64_t ThisLength =
std::min(Length, uint64_t(256));
6005 if (!isUInt<12>(DestDisp)) {
6014 if (!isUInt<12>(SrcDisp)) {
6023 BuildMI(*MBB, MI, DL, TII->get(Opcode))
6030 DestDisp += ThisLength;
6031 SrcDisp += ThisLength;
6032 Length -= ThisLength;
6035 if (EndMBB && Length > 0) {
6037 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
6094 BuildMI(MBB, DL, TII->get(SystemZ::PHI), This1Reg)
6095 .addReg(Start1Reg).
addMBB(StartMBB)
6097 BuildMI(MBB, DL, TII->get(SystemZ::PHI), This2Reg)
6098 .addReg(Start2Reg).
addMBB(StartMBB)
6100 BuildMI(MBB, DL, TII->get(TargetOpcode::COPY), SystemZ::R0L).addReg(CharReg);
6101 BuildMI(MBB, DL, TII->get(Opcode))
6104 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
6118 bool NoFloat)
const {
6129 static const unsigned GPRControlBit[16] = {
6130 0x8000, 0x8000, 0x4000, 0x4000, 0x2000, 0x2000, 0x1000, 0x1000,
6131 0x0800, 0x0800, 0x0400, 0x0400, 0x0200, 0x0200, 0x0100, 0x0100
6133 Control |= GPRControlBit[15];
6135 Control |= GPRControlBit[11];
6139 for (
int I = 0; I < 16; I++) {
6140 if ((Control & GPRControlBit[I]) == 0) {
6147 if (!NoFloat && (Control & 4) != 0) {
6149 for (
int I = 0; I < 32; I++) {
6154 for (
int I = 0; I < 16; I++) {
6180 BuildMI(*MBB, MI, DL, TII->get(Opcode), DstReg)
6190 case SystemZ::Select32Mux:
6191 return emitSelect(MI, MBB,
6193 case SystemZ::Select32:
6194 return emitSelect(MI, MBB, SystemZ::LOCR);
6195 case SystemZ::Select64:
6196 return emitSelect(MI, MBB, SystemZ::LOCGR);
6197 case SystemZ::SelectF32:
6198 case SystemZ::SelectF64:
6199 case SystemZ::SelectF128:
6200 case SystemZ::SelectVR128:
6201 return emitSelect(MI, MBB, 0);
6203 case SystemZ::CondStore8Mux:
6204 return emitCondStore(MI, MBB, SystemZ::STCMux, 0,
false);
6205 case SystemZ::CondStore8MuxInv:
6206 return emitCondStore(MI, MBB, SystemZ::STCMux, 0,
true);
6207 case SystemZ::CondStore16Mux:
6208 return emitCondStore(MI, MBB, SystemZ::STHMux, 0,
false);
6209 case SystemZ::CondStore16MuxInv:
6210 return emitCondStore(MI, MBB, SystemZ::STHMux, 0,
true);
6211 case SystemZ::CondStore32Mux:
6212 return emitCondStore(MI, MBB, SystemZ::STMux, SystemZ::STOCMux,
false);
6213 case SystemZ::CondStore32MuxInv:
6214 return emitCondStore(MI, MBB, SystemZ::STMux, SystemZ::STOCMux,
true);
6215 case SystemZ::CondStore8:
6216 return emitCondStore(MI, MBB, SystemZ::STC, 0,
false);
6217 case SystemZ::CondStore8Inv:
6218 return emitCondStore(MI, MBB, SystemZ::STC, 0,
true);
6219 case SystemZ::CondStore16:
6220 return emitCondStore(MI, MBB, SystemZ::STH, 0,
false);
6221 case SystemZ::CondStore16Inv:
6222 return emitCondStore(MI, MBB, SystemZ::STH, 0,
true);
6223 case SystemZ::CondStore32:
6224 return emitCondStore(MI, MBB,
SystemZ::ST, SystemZ::STOC,
false);
6225 case SystemZ::CondStore32Inv:
6226 return emitCondStore(MI, MBB,
SystemZ::ST, SystemZ::STOC,
true);
6227 case SystemZ::CondStore64:
6228 return emitCondStore(MI, MBB, SystemZ::STG, SystemZ::STOCG,
false);
6229 case SystemZ::CondStore64Inv:
6230 return emitCondStore(MI, MBB, SystemZ::STG, SystemZ::STOCG,
true);
6231 case SystemZ::CondStoreF32:
6232 return emitCondStore(MI, MBB, SystemZ::STE, 0,
false);
6233 case SystemZ::CondStoreF32Inv:
6234 return emitCondStore(MI, MBB, SystemZ::STE, 0,
true);
6235 case SystemZ::CondStoreF64:
6236 return emitCondStore(MI, MBB, SystemZ::STD, 0,
false);
6237 case SystemZ::CondStoreF64Inv:
6238 return emitCondStore(MI, MBB, SystemZ::STD, 0,
true);
6240 case SystemZ::AEXT128:
6241 return emitExt128(MI, MBB,
false);
6242 case SystemZ::ZEXT128:
6243 return emitExt128(MI, MBB,
true);
6246 return emitAtomicLoadBinary(MI, MBB, 0, 0);
6247 case SystemZ::ATOMIC_SWAP_32:
6248 return emitAtomicLoadBinary(MI, MBB, 0, 32);
6249 case SystemZ::ATOMIC_SWAP_64:
6250 return emitAtomicLoadBinary(MI, MBB, 0, 64);
6252 case SystemZ::ATOMIC_LOADW_AR:
6253 return emitAtomicLoadBinary(MI, MBB, SystemZ::AR, 0);
6254 case SystemZ::ATOMIC_LOADW_AFI:
6255 return emitAtomicLoadBinary(MI, MBB, SystemZ::AFI, 0);
6256 case SystemZ::ATOMIC_LOAD_AR:
6257 return emitAtomicLoadBinary(MI, MBB, SystemZ::AR, 32);
6258 case SystemZ::ATOMIC_LOAD_AHI:
6259 return emitAtomicLoadBinary(MI, MBB, SystemZ::AHI, 32);
6260 case SystemZ::ATOMIC_LOAD_AFI:
6261 return emitAtomicLoadBinary(MI, MBB, SystemZ::AFI, 32);
6262 case SystemZ::ATOMIC_LOAD_AGR:
6263 return emitAtomicLoadBinary(MI, MBB, SystemZ::AGR, 64);
6264 case SystemZ::ATOMIC_LOAD_AGHI:
6265 return emitAtomicLoadBinary(MI, MBB, SystemZ::AGHI, 64);
6266 case SystemZ::ATOMIC_LOAD_AGFI:
6267 return emitAtomicLoadBinary(MI, MBB, SystemZ::AGFI, 64);
6269 case SystemZ::ATOMIC_LOADW_SR:
6270 return emitAtomicLoadBinary(MI, MBB, SystemZ::SR, 0);
6271 case SystemZ::ATOMIC_LOAD_SR:
6272 return emitAtomicLoadBinary(MI, MBB, SystemZ::SR, 32);
6273 case SystemZ::ATOMIC_LOAD_SGR:
6274 return emitAtomicLoadBinary(MI, MBB, SystemZ::SGR, 64);
6276 case SystemZ::ATOMIC_LOADW_NR:
6277 return emitAtomicLoadBinary(MI, MBB, SystemZ::NR, 0);
6278 case SystemZ::ATOMIC_LOADW_NILH:
6279 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILH, 0);
6280 case SystemZ::ATOMIC_LOAD_NR:
6281 return emitAtomicLoadBinary(MI, MBB, SystemZ::NR, 32);
6282 case SystemZ::ATOMIC_LOAD_NILL:
6283 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILL, 32);
6284 case SystemZ::ATOMIC_LOAD_NILH:
6285 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILH, 32);
6286 case SystemZ::ATOMIC_LOAD_NILF:
6287 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILF, 32);
6288 case SystemZ::ATOMIC_LOAD_NGR:
6289 return emitAtomicLoadBinary(MI, MBB, SystemZ::NGR, 64);
6290 case SystemZ::ATOMIC_LOAD_NILL64:
6291 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILL64, 64);
6292 case SystemZ::ATOMIC_LOAD_NILH64:
6293 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILH64, 64);
6294 case SystemZ::ATOMIC_LOAD_NIHL64:
6295 return emitAtomicLoadBinary(MI, MBB, SystemZ::NIHL64, 64);
6296 case SystemZ::ATOMIC_LOAD_NIHH64:
6297 return emitAtomicLoadBinary(MI, MBB, SystemZ::NIHH64, 64);
6298 case SystemZ::ATOMIC_LOAD_NILF64:
6299 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILF64, 64);
6300 case SystemZ::ATOMIC_LOAD_NIHF64:
6301 return emitAtomicLoadBinary(MI, MBB, SystemZ::NIHF64, 64);
6304 return emitAtomicLoadBinary(MI, MBB,
SystemZ::OR, 0);
6305 case SystemZ::ATOMIC_LOADW_OILH:
6306 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILH, 0);
6308 return emitAtomicLoadBinary(MI, MBB,
SystemZ::OR, 32);
6309 case SystemZ::ATOMIC_LOAD_OILL:
6310 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILL, 32);
6311 case SystemZ::ATOMIC_LOAD_OILH:
6312 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILH, 32);
6313 case SystemZ::ATOMIC_LOAD_OILF:
6314 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILF, 32);
6315 case SystemZ::ATOMIC_LOAD_OGR:
6316 return emitAtomicLoadBinary(MI, MBB, SystemZ::OGR, 64);
6317 case SystemZ::ATOMIC_LOAD_OILL64:
6318 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILL64, 64);
6319 case SystemZ::ATOMIC_LOAD_OILH64:
6320 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILH64, 64);
6321 case SystemZ::ATOMIC_LOAD_OIHL64:
6322 return emitAtomicLoadBinary(MI, MBB, SystemZ::OIHL64, 64);
6323 case SystemZ::ATOMIC_LOAD_OIHH64:
6324 return emitAtomicLoadBinary(MI, MBB, SystemZ::OIHH64, 64);
6325 case SystemZ::ATOMIC_LOAD_OILF64:
6326 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILF64, 64);
6327 case SystemZ::ATOMIC_LOAD_OIHF64:
6328 return emitAtomicLoadBinary(MI, MBB, SystemZ::OIHF64, 64);
6330 case SystemZ::ATOMIC_LOADW_XR:
6331 return emitAtomicLoadBinary(MI, MBB, SystemZ::XR, 0);
6332 case SystemZ::ATOMIC_LOADW_XILF:
6333 return emitAtomicLoadBinary(MI, MBB, SystemZ::XILF, 0);
6334 case SystemZ::ATOMIC_LOAD_XR:
6335 return emitAtomicLoadBinary(MI, MBB, SystemZ::XR, 32);
6336 case SystemZ::ATOMIC_LOAD_XILF:
6337 return emitAtomicLoadBinary(MI, MBB, SystemZ::XILF, 32);
6338 case SystemZ::ATOMIC_LOAD_XGR:
6339 return emitAtomicLoadBinary(MI, MBB, SystemZ::XGR, 64);
6340 case SystemZ::ATOMIC_LOAD_XILF64:
6341 return emitAtomicLoadBinary(MI, MBB, SystemZ::XILF64, 64);
6342 case SystemZ::ATOMIC_LOAD_XIHF64:
6343 return emitAtomicLoadBinary(MI, MBB, SystemZ::XIHF64, 64);
6345 case SystemZ::ATOMIC_LOADW_NRi:
6346 return emitAtomicLoadBinary(MI, MBB, SystemZ::NR, 0,
true);
6347 case SystemZ::ATOMIC_LOADW_NILHi:
6348 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILH, 0,
true);
6349 case SystemZ::ATOMIC_LOAD_NRi:
6350 return emitAtomicLoadBinary(MI, MBB, SystemZ::NR, 32,
true);
6351 case SystemZ::ATOMIC_LOAD_NILLi:
6352 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILL, 32,
true);
6353 case SystemZ::ATOMIC_LOAD_NILHi:
6354 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILH, 32,
true);
6355 case SystemZ::ATOMIC_LOAD_NILFi:
6356 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILF, 32,
true);
6357 case SystemZ::ATOMIC_LOAD_NGRi:
6358 return emitAtomicLoadBinary(MI, MBB, SystemZ::NGR, 64,
true);
6359 case SystemZ::ATOMIC_LOAD_NILL64i:
6360 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILL64, 64,
true);
6361 case SystemZ::ATOMIC_LOAD_NILH64i:
6362 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILH64, 64,
true);
6363 case SystemZ::ATOMIC_LOAD_NIHL64i:
6364 return emitAtomicLoadBinary(MI, MBB, SystemZ::NIHL64, 64,
true);
6365 case SystemZ::ATOMIC_LOAD_NIHH64i:
6366 return emitAtomicLoadBinary(MI, MBB, SystemZ::NIHH64, 64,
true);
6367 case SystemZ::ATOMIC_LOAD_NILF64i:
6368 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILF64, 64,
true);
6369 case SystemZ::ATOMIC_LOAD_NIHF64i:
6370 return emitAtomicLoadBinary(MI, MBB, SystemZ::NIHF64, 64,
true);
6373 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CR,
6375 case SystemZ::ATOMIC_LOAD_MIN_32:
6376 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CR,
6378 case SystemZ::ATOMIC_LOAD_MIN_64:
6379 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CGR,
6383 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CR,
6385 case SystemZ::ATOMIC_LOAD_MAX_32:
6386 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CR,
6388 case SystemZ::ATOMIC_LOAD_MAX_64:
6389 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CGR,
6393 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CLR,
6395 case SystemZ::ATOMIC_LOAD_UMIN_32:
6396 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CLR,
6398 case SystemZ::ATOMIC_LOAD_UMIN_64:
6399 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CLGR,
6403 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CLR,
6405 case SystemZ::ATOMIC_LOAD_UMAX_32:
6406 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CLR,
6408 case SystemZ::ATOMIC_LOAD_UMAX_64:
6409 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CLGR,
6413 return emitAtomicCmpSwapW(MI, MBB);
6414 case SystemZ::MVCSequence:
6415 case SystemZ::MVCLoop:
6417 case SystemZ::NCSequence:
6418 case SystemZ::NCLoop:
6420 case SystemZ::OCSequence:
6421 case SystemZ::OCLoop:
6423 case SystemZ::XCSequence:
6424 case SystemZ::XCLoop:
6426 case SystemZ::CLCSequence:
6427 case SystemZ::CLCLoop:
6429 case SystemZ::CLSTLoop:
6430 return emitStringWrapper(MI, MBB, SystemZ::CLST);
6431 case SystemZ::MVSTLoop:
6432 return emitStringWrapper(MI, MBB, SystemZ::MVST);
6433 case SystemZ::SRSTLoop:
6434 return emitStringWrapper(MI, MBB, SystemZ::SRST);
6437 case SystemZ::TBEGIN_nofloat:
6439 case SystemZ::TBEGINC:
6440 return emitTransactionBegin(MI, MBB, SystemZ::TBEGINC,
true);
6441 case SystemZ::LTEBRCompare_VecPseudo:
6442 return emitLoadAndTestCmp0(MI, MBB, SystemZ::LTEBR);
6443 case SystemZ::LTDBRCompare_VecPseudo:
6444 return emitLoadAndTestCmp0(MI, MBB, SystemZ::LTDBR);
6445 case SystemZ::LTXBRCompare_VecPseudo:
6446 return emitLoadAndTestCmp0(MI, MBB, SystemZ::LTXBR);
6456 SystemZTargetLowering::getRepRegClassFor(
MVT VT)
const {
6458 return &SystemZ::ADDR128BitRegClass;
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.
static SDValue getPermuteNode(SelectionDAG &DAG, const SDLoc &DL, const Permute &P, SDValue Op0, SDValue Op1)
static unsigned CCMaskForCondCode(ISD::CondCode CC)
void setFrameAddressIsTaken(bool T)
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
const unsigned CCMASK_CMP_GT
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
constexpr bool isUInt< 32 >(uint64_t x)
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
static MVT getIntegerVT(unsigned BitWidth)
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values i...
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.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
A parsed version of the target data layout string in and methods for querying it. ...
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
static bool getShuffleInput(const SmallVectorImpl< int > &Bytes, unsigned Start, unsigned BytesPerElement, int &Base)
static SDValue getCCResult(SelectionDAG &DAG, SDNode *After)
SDValue getValue(unsigned R) const
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg If BaseGV is null...
static void VerifyVectorTypes(const SmallVectorImpl< ISD::InputArg > &Ins)
void setLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified load with extension does not work with the specified type and indicate wh...
T findLastSet(T Val, ZeroBehavior ZB=ZB_Max)
Get the index of the last set bit starting from the least significant bit.
int getFramePointerSaveIndex() const
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
LLVMContext * getContext() const
unsigned getVarArgsFrameIndex() const
const unsigned GR32Regs[16]
static bool isIntrinsicWithCCAndChain(SDValue Op, unsigned &Opcode, unsigned &CCValid)
uint64_t getZExtValue() const
Get zero extended value.
const int64_t CallFrameSize
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, SDValue InGlue, const SDLoc &DL)
Return a new CALLSEQ_END node, which always must have a glue result (to ensure it's not CSE'd)...
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &, EVT) const override
Return the ValueType of the result of SETCC operations.
static SDValue getAbsolute(SelectionDAG &DAG, const SDLoc &DL, SDValue Op, bool IsNegative)
static IPMConversion getIPMConversion(unsigned CCValid, unsigned CCMask)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
BR_CC - Conditional branch.
static SDValue buildScalarToVector(SelectionDAG &DAG, const SDLoc &DL, EVT VT, SDValue Value)
static const Permute PermuteForms[]
void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
LocInfo getLocInfo() const
const MCPhysReg ArgFPRs[NumArgFPRs]
static MVT getVectorVT(MVT VT, unsigned NumElements)
bool hasOneUse() const
Return true if there is exactly one use of this node.
const unsigned CCMASK_FCMP
const unsigned FP128Regs[16]
bool hasNUsesOfValue(unsigned NUses, unsigned Value) const
Return true if there are exactly NUSES uses of the indicated value.
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
unsigned odd128(bool Is32bit)
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node.
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override
This hook must be implemented to lower outgoing return values, described by the Outs array...
SDVTList getVTList() const
bool isPC32DBLSymbol(const GlobalValue *GV, CodeModel::Model CM) const
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
void addLiveIn(unsigned Reg, unsigned vreg=0)
addLiveIn - Add the specified register as a live-in.
static bool isImmHH(uint64_t Val)
static SDValue tryBuildVectorShuffle(SelectionDAG &DAG, BuildVectorSDNode *BVN)
const TargetMachine & getTarget() const
unsigned addLiveIn(unsigned PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
const MachineInstrBuilder & add(const MachineOperand &MO) const
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain...
This class represents a function call, abstracting a target machine's calling convention.
const GlobalValue * getGlobal() const
static void adjustZeroCmp(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
bool verifyReturnAddressArgumentIsConstant(SDValue Op, SelectionDAG &DAG) const
static SDValue tryBuildVectorReplicate(SelectionDAG &DAG, const SystemZInstrInfo *TII, const SDLoc &DL, EVT VT, uint64_t Value, unsigned BitsPerElement)
bool hasInterlockedAccess1() const
static Comparison getIntrinsicCmp(SelectionDAG &DAG, unsigned Opcode, SDValue Call, unsigned CCValid, uint64_t CC, ISD::CondCode Cond)
unsigned getNumOperands() const
Return the number of values used by this operation.
static bool canUseSiblingCall(const CCState &ArgCCInfo, SmallVectorImpl< CCValAssign > &ArgLocs, SmallVectorImpl< ISD::OutputArg > &Outs)
void setBooleanVectorContents(BooleanContent Ty)
Specify how the target extends the result of a vector boolean value from a vector of i1 to a wider ty...
const char * getTargetNodeName(unsigned Opcode) const override
This method returns the name of a target specific DAG node.
unsigned getNumOperands() const
unsigned getValueSizeInBits() const
Returns the size of the value in bits.
constexpr bool isInt< 16 >(int64_t x)
int64_t getOffset() const
bool isLegalAddImmediate(int64_t Imm) const override
Return true if the specified immediate is legal add immediate, that is the target has add instruction...
const SDValue & getOperand(unsigned Num) const
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
static SDValue joinDwords(SelectionDAG &DAG, const SDLoc &DL, SDValue Op0, SDValue Op1)
const unsigned FP32Regs[16]
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
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 getTargetExternalSymbol(const char *Sym, EVT VT, unsigned char TargetFlags=0)
iterator_range< mmo_iterator > memoperands()
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
bool CheckReturn(const SmallVectorImpl< ISD::OutputArg > &ArgsFlags, CCAssignFn Fn)
CheckReturn - Analyze the return values of a function, returning true if the return can be performed ...
void reserve(size_type N)
Value * CallOperandVal
If this is the result output operand or a clobber, this is null, otherwise it is the incoming operand...
LegalizeAction getOperationAction(unsigned Op, EVT VT) const
Return how this operation should be treated: either it is legal, needs to be promoted to a larger siz...
static bool chooseShuffleOpNos(int *OpNos, unsigned &OpNo0, unsigned &OpNo1)
const SDValue & getBasePtr() const
SDValue getConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offs=0, bool isT=false, unsigned char TargetFlags=0)
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...
static bool shouldSwapCmpOperands(const Comparison &C)
const unsigned CCMASK_ICMP
bool hasMiscellaneousExtensions2() const
OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope) This corresponds to the fence instruction.
TargetLowering::ConstraintType getConstraintType(StringRef Constraint) const override
Given a constraint, return the type of constraint it is for this target.
virtual const TargetRegisterClass * getRepRegClassFor(MVT VT) const
Return the 'representative' register class for the specified value type.
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, LLVMContext &Context) const override
This hook should be implemented to check whether the return values described by the Outs array can fi...
unsigned getResNo() const
get the index which selects a specific result in the SDNode
static unsigned getVectorComparison(ISD::CondCode CC, bool IsFP)
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
bool hasVectorEnhancements1() const
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const override
Lower the specified operand into the Ops vector.
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations...
bool isVector() const
Return true if this is a vector value type.
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
bool hasLoadStoreOnCond() const
The address of a basic block.
A description of a memory reference used in the backend.
static bool matchDoublePermute(const SmallVectorImpl< int > &Bytes, const Permute &P, SmallVectorImpl< int > &Transform)
int64_t getOffset() const
static MachineBasicBlock * splitBlockAfter(MachineBasicBlock::iterator MI, MachineBasicBlock *MBB)
const HexagonInstrInfo * TII
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false)
Shift and rotation operations.
static bool isShlDoublePermute(const SmallVectorImpl< int > &Bytes, unsigned &StartIndex, unsigned &OpNo0, unsigned &OpNo1)
virtual bool hasFP(const MachineFunction &MF) const =0
hasFP - Return true if the specified function should have a dedicated frame pointer register...
const unsigned CCMASK_TM_MSB_0
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
void setVarArgsFirstGPR(unsigned GPR)
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.
MachineFunction & getMachineFunction() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
Reg
All possible values of the reg field in the ModR/M byte.
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...
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.
void setOperationAction(unsigned Op, MVT VT, LegalizeAction Action)
Indicate that the specified operation does not work with the specified type and indicate what to do a...
int getMaskElt(unsigned Idx) const
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG...
static void lowerMUL_LOHI32(SelectionDAG &DAG, const SDLoc &DL, unsigned Extend, SDValue Op0, SDValue Op1, SDValue &Hi, SDValue &Lo)
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
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())
LLVM_NODISCARD bool empty() const
SmallVector< ISD::InputArg, 32 > Ins
AtomicOrdering
Atomic ordering for LLVM's memory model.
STACKSAVE - STACKSAVE has one operand, an input chain.
SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
static bool isScalarToVector(SDValue Op)
bool hasLoadStoreOnCond2() const
unsigned getLocReg() const
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose...
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
SDValue getRegisterMask(const uint32_t *RegMask)
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
bool isLegalICmpImmediate(int64_t Imm) const override
Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructi...
This contains information for each constraint that we are lowering.
Simple integer binary arithmetic operators.
const unsigned CCMASK_TBEGIN
SmallVector< ISD::OutputArg, 32 > Outs
const unsigned NumArgFPRs
static bool matchPermute(const SmallVectorImpl< int > &Bytes, const Permute &P, unsigned &OpNo0, unsigned &OpNo1)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
void incNumLocalDynamicTLSAccesses()
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
MachineConstantPoolValue * getMachineCPVal() const
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
static mvt_range integer_vector_valuetypes()
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
const unsigned CCMASK_ANY
EVT getMemoryVT() const
Return the type of the in-memory value.
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...
const unsigned VectorBits
bool isTruncateFree(Type *, Type *) const override
Return true if it's free to truncate a value of type FromTy to type ToTy.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
const unsigned CCMASK_CS_NE
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
const unsigned CCMASK_TM_SOME_0
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
const DataLayout & getDataLayout() const
const unsigned CCMASK_TM_ALL_1
SDValue LowerCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower calls into the specified DAG.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
UNDEF - An undefined node.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
const MachineBasicBlock * getParent() const
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the specified, possibly variable...
mmo_iterator memoperands_end() const
bool isFoldableMemAccessOffset(Instruction *I, int64_t Offset) const override
SystemZTargetLowering(const TargetMachine &TM, const SystemZSubtarget &STI)
SDNode * getNode() const
get the SDNode which holds the desired result
static SDValue emitIntrinsicWithChainAndGlue(SelectionDAG &DAG, SDValue Op, unsigned Opcode)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned getScalarSizeInBits() const
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
static void adjustForLTGFR(Comparison &C)
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
unsigned getOpcodeForOffset(unsigned Opcode, int64_t Offset) const
constexpr bool isUInt< 8 >(uint64_t x)
unsigned const MachineRegisterInfo * MRI
std::size_t countTrailingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the least significant bit to the most stopping at the first 1...
bool isMachineConstantPoolEntry() const
CodeModel::Model getCodeModel() const
Returns the code model.
static void getVPermMask(ShuffleVectorSDNode *VSN, SmallVectorImpl< int > &Bytes)
const unsigned CCMASK_VCMP
const SDValue & getOperand(unsigned i) const
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.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type...
Simple binary floating point operators.
void setTargetDAGCombine(ISD::NodeType NT)
Targets should invoke this method for each target independent node that they want to provide a custom...
bool isVectorTy() const
True if this is an instance of VectorType.
SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, unsigned Align=0, bool Vol=false, bool ReadMem=true, bool WriteMem=true, unsigned Size=0)
Creates a MemIntrinsicNode that may produce a result and takes a list of operands.
static bool isNaturalMemoryOperand(SDValue Op, unsigned ICmpType)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
This is an important base class in LLVM.
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE...
bool isVector() const
Return true if this is a vector value type.
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
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...
static std::pair< unsigned, const TargetRegisterClass * > parseRegisterNumber(StringRef Constraint, const TargetRegisterClass *RC, const unsigned *Map)
const Constant * getConstVal() const
const MachineOperand & getOperand(unsigned i) const
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
This callback is invoked for operations that are unsupported by the target, which are registered to u...
const unsigned CCMASK_CMP_LE
static SDValue buildVector(SelectionDAG &DAG, const SDLoc &DL, EVT VT, SmallVectorImpl< SDValue > &Elems)
static ManagedStatic< OptionRegistry > OR
static void adjustICmpTruncate(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
SDValue getCALLSEQ_START(SDValue Chain, uint64_t InSize, uint64_t OutSize, const SDLoc &DL)
Return a new CALLSEQ_START node, that starts new call frame, in which InSize bytes are set up inside ...
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
bool mayBeEmittedAsTailCall(const CallInst *CI) const override
Return true if the target may be able emit the call instruction as a tail call.
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override
This method will be invoked for all target nodes and for any target-independent nodes that the target...
static mvt_range fp_valuetypes()
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
static SDValue expandV4F32ToV2F64(SelectionDAG &DAG, int Start, const SDLoc &DL, SDValue Op)
void setRegSaveFrameIndex(unsigned FI)
static const unsigned End
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setImm(int64_t immVal)
unsigned getOpcode() const
const unsigned CCMASK_TM_MSB_1
TRAP - Trapping instruction.
Value * getOperand(unsigned i) const
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS) const override
Return true if the addressing mode represented by AM is legal for this target, for a load/store of th...
const unsigned CCMASK_CMP_LT
static SDValue buildMergeScalars(SelectionDAG &DAG, const SDLoc &DL, EVT VT, SDValue Op0, SDValue Op1)
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
static mvt_range vector_valuetypes()
CondCode getSetCCSwappedOperands(CondCode Operation)
Return the operation corresponding to (Y op X) when given the operation for (X op Y)...
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
const unsigned CCMASK_TDC
static Comparison getCmp(SelectionDAG &DAG, SDValue CmpOp0, SDValue CmpOp1, ISD::CondCode Cond, const SDLoc &DL)
use_iterator use_begin() const
Provide iteration support to walk over all uses of an SDNode.
static unsigned forceReg(MachineInstr &MI, MachineOperand &Base, const SystemZInstrInfo *TII)
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo...
bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
bool isRxSBGMask(uint64_t Mask, unsigned BitSize, unsigned &Start, unsigned &End) const
unsigned getStackPointerRegisterToSaveRestore() const
If a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static SDValue convertLocVTToValVT(SelectionDAG &DAG, const SDLoc &DL, CCValAssign &VA, SDValue Chain, SDValue Value)
This structure contains all information that is necessary for lowering calls.
static bool isImmLH(uint64_t Val)
T findFirstSet(T Val, ZeroBehavior ZB=ZB_Max)
Get the index of the first set bit starting from the least significant bit.
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower the incoming (formal) arguments, described by the Ins array...
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS, unsigned Align, bool *Fast) const override
Determine if the target supports unaligned memory accesses.
This class contains a discriminated union of information about pointers in memory operands...
const BlockAddress * getBlockAddress() const
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands...
SDValue CreateStackTemporary(EVT VT, unsigned minAlign=1)
Create a stack temporary, suitable for holding the specified value type.
const SystemZInstrInfo * getInstrInfo() const override
const unsigned CCMASK_TM_MIXED_MSB_0
bool allowTruncateForTailCall(Type *, Type *) const override
Return true if a truncation from FromTy to ToTy is permitted when deciding whether a call is in tail ...
void setIsKill(bool Val=true)
bool hasPopulationCount() const
SDValue getTargetConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offset=0, unsigned char TargetFlags=0)
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned char TargetFlags=0)
TokenFactor - This node takes multiple tokens as input and produces a single token result...
Synchronized with respect to all concurrently executing threads.
const TargetFrameLowering * getFrameLowering() const override
Iterator for intrusive lists based on ilist_node.
CCState - This class holds information needed while lowering arguments and return values...
TargetLowering::ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &info, const char *constraint) const override
Examine constraint string and operand type and determine a weight value.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
constexpr bool isInt< 32 >(int64_t x)
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
void setVarArgsFrameIndex(unsigned FI)
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...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
const unsigned CCMASK_CMP_EQ
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.
CCValAssign - Represent assignment of one arg/retval to a location.
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)
const unsigned FP64Regs[16]
static bool isSimpleShift(SDValue N, unsigned &ShiftVal)
BRCOND - Conditional branch.
Information about stack frame layout on the target.
const SDValue & getChain() const
static bool tryBuildVectorByteMask(BuildVectorSDNode *BVN, uint64_t &Mask)
static SDValue convertValVTToLocVT(SelectionDAG &DAG, const SDLoc &DL, CCValAssign &VA, SDValue Value)
Byte Swap and Counting operators.
const unsigned CCMASK_CMP_O
const unsigned GR128Regs[16]
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
const unsigned CCMASK_CMP_NE
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.
const unsigned GR64Regs[16]
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
static mvt_range integer_valuetypes()
const unsigned CCMASK_TM_MIXED_MSB_1
C - The default llvm calling convention, compatible with C.
static SDValue emitSETCC(SelectionDAG &DAG, const SDLoc &DL, SDValue Glue, unsigned CCValid, unsigned CCMask)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Class for arbitrary precision integers.
virtual const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const
Return a mask of call-preserved registers for the given calling convention on the current function...
const unsigned VectorBytes
iterator_range< use_iterator > uses()
A "pseudo-class" with methods for operating on BUILD_VECTORs.
Select(COND, TRUEVAL, FALSEVAL).
void setMinFunctionAlignment(unsigned Align)
Set the target's minimum function alignment (in log2(bytes))
int64_t getSExtValue() const
bool isIntegerTy() const
True if this is an instance of IntegerType.
unsigned EmulatedTLS
EmulatedTLS - This flag enables emulated TLS model, using emutls function in the runtime library...
void setVarArgsFirstFPR(unsigned FPR)
static use_iterator use_end()
ZERO_EXTEND - Used for integer types, zeroing the new bits.
static void VerifyVectorType(MVT VT, EVT ArgVT)
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
ANY_EXTEND - Used for integer types. The high bits are undefined.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
const unsigned CCMASK_CMP_GE
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
static MachineOperand earlyUseOperand(MachineOperand Op)
FMINNAN/FMAXNAN - Behave identically to FMINNUM/FMAXNUM, except that when a single input is NaN...
static void adjustForTestUnderMask(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
static SDValue getGeneralPermuteNode(SelectionDAG &DAG, const SDLoc &DL, SDValue *Ops, const SmallVectorImpl< int > &Bytes)
GET_DYNAMIC_AREA_OFFSET - get offset from native SP to the address of the most recent dynamic alloca...
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
BR_JT - Jumptable branch.
static std::vector< std::string > Flags
Representation of each machine instruction.
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the source.
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned char TargetFlags=0)
SmallVector< SDValue, 32 > OutVals
static bool isAbsolute(SDValue CmpOp, SDValue Pos, SDValue Neg)
static MachineBasicBlock * emitBlockAfter(MachineBasicBlock *MBB)
Bitwise operators - logical and, logical or, logical xor.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static void adjustForSubtraction(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
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...
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
static bool is32Bit(EVT VT)
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values i...
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
bool hasOneUse() const
Return true if there is exactly one user of this value.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
unsigned MaxStoresPerMemcpyOptSize
Maximum number of store operations that may be substituted for a call to memcpy, used for functions w...
void setStackPointerRegisterToSaveRestore(unsigned R)
If set to a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save and restore.
Fast - This calling convention attempts to make calls as fast as possible (e.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)
bool isNON_EXTLoad(const SDNode *N)
Returns true if the specified node is a non-extending load.
static MachineBasicBlock * splitBlockBefore(MachineBasicBlock::iterator MI, MachineBasicBlock *MBB)
FSINCOS - Compute both fsin and fcos as a single operation.
unsigned MaxStoresPerMemcpy
Specify maximum bytes of store instructions per memcpy call.
constexpr bool isUInt< 16 >(uint64_t x)
static MachinePointerInfo getConstantPool(MachineFunction &MF)
Return a MachinePointerInfo record that refers to the constant pool.
static unsigned reverseCCMask(unsigned CCMask)
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
unsigned getRegSaveFrameIndex() const
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.
static unsigned getTestUnderMaskCond(unsigned BitSize, unsigned CCMask, uint64_t Mask, uint64_t CmpVal, unsigned ICmpType)
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...
TLSModel::Model getTLSModel(const GlobalValue *GV) const
Returns the TLS model which should be used for the given global variable.
SDValue getGLOBAL_OFFSET_TABLE(EVT VT)
Return a GLOBAL_OFFSET_TABLE node. This does not have a useful SDLoc.
unsigned getPointerSize() const
Get the pointer size for this target.
unsigned getReg() const
getReg - Returns the register number.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
static SDValue emitCmp(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
void insert(iterator MBBI, MachineBasicBlock *MBB)
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
void setReturnAddressIsTaken(bool s)
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
unsigned getAlignment() const
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...
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
static MachinePointerInfo getGOT(MachineFunction &MF)
Return a MachinePointerInfo record that refers to a GOT entry.
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
LLVM Value Representation.
FMA - Perform a * b + c with no intermediate rounding step.
SDValue getRegister(unsigned Reg, EVT VT)
unsigned even128(bool Is32bit)
bool isFPImmLegal(const APFloat &Imm, EVT VT) const override
Returns true if the target can instruction select the specified FP immediate natively.
unsigned getVarArgsFirstGPR() const
static void lowerGR128Binary(SelectionDAG &DAG, const SDLoc &DL, EVT VT, unsigned Opcode, SDValue Op0, SDValue Op1, SDValue &Even, SDValue &Odd)
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
SDValue getValueType(EVT)
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
static void adjustSubwordCmp(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
PREFETCH - This corresponds to a prefetch intrinsic.
static bool isIntrinsicWithCC(SDValue Op, unsigned &Opcode, unsigned &CCValid)
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...
void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.Val alone...
static bool isImmLL(uint64_t Val)
Primary interface to the complete machine description for the target machine.
A SystemZ-specific constant pool value.
StringRef - Represent a constant reference to a string, i.e.
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.
static SDValue emitIntrinsicWithGlue(SelectionDAG &DAG, SDValue Op, unsigned Opcode)
bool hasFPExtension() const
unsigned MaxStoresPerMemset
Specify maximum number of store instructions per memset call.
unsigned MaxStoresPerMemsetOptSize
Maximum number of stores operations that may be substituted for the call to memset, used for functions with OptSize attribute.
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
unsigned getLocMemOffset() const
static bool isVolatile(Instruction *Inst)
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
static void adjustForFNeg(Comparison &C)
OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val) This corresponds to "store atomic" instruction.
bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
const unsigned CCMASK_TM_ALL_0
bool SignBitIsZero(SDValue Op, unsigned Depth=0) const
Return true if the sign bit of Op is known to be zero.
SDValue getTargetInsertSubreg(int SRIdx, const SDLoc &DL, EVT VT, SDValue Operand, SDValue Subreg)
A convenience function for creating TargetInstrInfo::INSERT_SUBREG nodes.
TRUNCATE - Completely drop the high bits.
const unsigned CCMASK_TEND
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...
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, FLOG, FLOG2, FLOG10, FEXP, FEXP2, FCEIL, FTRUNC, FRINT, FNEARBYINT, FROUND, FFLOOR - Perform various unary floating point operations.
const unsigned VR128Regs[32]
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
bool isFMAFasterThanFMulAndFAdd(EVT VT) const override
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
static unsigned getVectorComparisonOrInvert(ISD::CondCode CC, bool IsFP, bool &Invert)
const SystemZRegisterInfo * getRegisterInfo() const override
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
EVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
const unsigned CCMASK_TM_SOME_1
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
unsigned getVarArgsFirstFPR() const
static SystemZConstantPoolValue * Create(const GlobalValue *GV, SystemZCP::SystemZCPModifier Modifier)
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned char TargetFlags=0)
const unsigned CCMASK_CMP_UO
uint64_t getZExtValue() const
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
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.
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary...
static bool isImmHL(uint64_t Val)