24 #include "llvm/IR/IntrinsicsS390.h" 31 #define DEBUG_TYPE "systemz-lower" 37 : Op0(Op0In), Op1(Op1In), Chain(ChainIn),
38 Opcode(0), ICmpType(0), CCValid(0), CCMask(0) {}
712 uint64_t Byte = IntBits.lshr(I * 8).trunc(8).getZExtValue();
718 if (I == SystemZ::VectorBytes) {
720 OpVals.push_back(Mask);
725 if (SplatBitSize > 64)
728 auto tryValue = [&](uint64_t
Value) ->
bool {
732 OpVals.push_back(((
unsigned) SignedValue));
744 OpVals.push_back(Start - (64 - SplatBitSize));
745 OpVals.push_back(End - (64 - SplatBitSize));
758 uint64_t SplatBitsZ = SplatBits.getZExtValue();
759 uint64_t SplatUndefZ = SplatUndef.getZExtValue();
761 (SplatUndefZ & ((uint64_t(1) <<
findFirstSet(SplatBitsZ)) - 1));
763 (SplatUndefZ & ~((uint64_t(1) <<
findLastSet(SplatBitsZ)) - 1));
764 if (tryValue(SplatBitsZ | Upper | Lower))
770 uint64_t Middle = SplatUndefZ & ~Upper & ~Lower;
771 return tryValue(SplatBitsZ | Middle);
780 unsigned Width = SplatBits.getBitWidth();
782 unsigned HalfSize = Width / 2;
787 if (HighValue != LowValue || 8 > HalfSize)
790 SplatBits = HighValue;
794 SplatBitSize =
Width;
802 BVN->
isConstantSplat(IntBits, SplatUndef, SplatBitSize, HasAnyUndefs, 128,
806 BVN->
isConstantSplat(SplatBits, SplatUndef, SplatBitSize, HasAnyUndefs, 8,
811 bool ForCodeSize)
const {
848 LongDisplacement(LongDispl), IndexReg(IdxReg) {}
871 switch (II->getIntrinsicID()) {
873 case Intrinsic::memset:
874 case Intrinsic::memmove:
875 case Intrinsic::memcpy:
880 if (isa<LoadInst>(I) && I->
hasOneUse()) {
881 auto *SingleUser = cast<Instruction>(*I->
user_begin());
882 if (SingleUser->getParent() == I->
getParent()) {
883 if (isa<ICmpInst>(SingleUser)) {
884 if (
auto *
C = dyn_cast<ConstantInt>(SingleUser->getOperand(1)))
885 if (
C->getBitWidth() <= 64 &&
889 }
else if (isa<StoreInst>(SingleUser))
893 }
else if (
auto *StoreI = dyn_cast<StoreInst>(I)) {
894 if (
auto *LoadI = dyn_cast<LoadInst>(StoreI->getValueOperand()))
895 if (LoadI->hasOneUse() && LoadI->getParent() == I->
getParent())
900 if (HasVector && (isa<LoadInst>(I) || isa<StoreInst>(I))) {
911 bool IsVectorAccess = MemAccessTy->
isVectorTy();
915 if (!IsVectorAccess && isa<StoreInst>(I)) {
917 if (isa<ExtractElementInst>(DataOp))
918 IsVectorAccess =
true;
923 if (!IsVectorAccess && isa<LoadInst>(I) && I->
hasOneUse()) {
925 if (isa<InsertElementInst>(LoadUser))
926 IsVectorAccess =
true;
929 if (IsFPAccess || IsVectorAccess)
956 return AM.
Scale == 0;
967 return FromBits > ToBits;
975 return FromBits > ToBits;
984 if (Constraint.
size() == 1) {
985 switch (Constraint[0]) {
1017 const char *constraint)
const {
1022 if (!CallOperandVal)
1026 switch (*constraint) {
1046 Subtarget.hasVector())
1051 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
1057 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
1058 if (isUInt<12>(
C->getZExtValue()))
1063 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
1069 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
1070 if (isInt<20>(
C->getSExtValue()))
1075 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
1076 if (
C->getZExtValue() == 0x7fffffff)
1086 static std::pair<unsigned, const TargetRegisterClass *>
1088 const unsigned *Map,
unsigned Size) {
1089 assert(*(Constraint.
end()-1) ==
'}' &&
"Missing '}'");
1090 if (isdigit(Constraint[2])) {
1093 Constraint.
slice(2, Constraint.
size() - 1).getAsInteger(10, Index);
1094 if (!Failed && Index < Size && Map[Index])
1095 return std::make_pair(Map[Index], RC);
1097 return std::make_pair(0U,
nullptr);
1100 std::pair<unsigned, const TargetRegisterClass *>
1103 if (Constraint.
size() == 1) {
1105 switch (Constraint[0]) {
1110 return std::make_pair(0U, &SystemZ::GR64BitRegClass);
1112 return std::make_pair(0U, &SystemZ::GR128BitRegClass);
1113 return std::make_pair(0U, &SystemZ::GR32BitRegClass);
1117 return std::make_pair(0U, &SystemZ::ADDR64BitRegClass);
1119 return std::make_pair(0U, &SystemZ::ADDR128BitRegClass);
1120 return std::make_pair(0U, &SystemZ::ADDR32BitRegClass);
1123 return std::make_pair(0U, &SystemZ::GRH32BitRegClass);
1127 return std::make_pair(0U, &SystemZ::FP64BitRegClass);
1129 return std::make_pair(0U, &SystemZ::FP128BitRegClass);
1130 return std::make_pair(0U, &SystemZ::FP32BitRegClass);
1133 if (Subtarget.hasVector()) {
1135 return std::make_pair(0U, &SystemZ::VR32BitRegClass);
1137 return std::make_pair(0U, &SystemZ::VR64BitRegClass);
1138 return std::make_pair(0U, &SystemZ::VR128BitRegClass);
1143 if (Constraint.
size() > 0 && Constraint[0] ==
'{') {
1148 if (Constraint[1] ==
'r') {
1158 if (Constraint[1] ==
'f') {
1168 if (Constraint[1] ==
'v') {
1184 std::vector<SDValue> &Ops,
1187 if (Constraint.length() == 1) {
1188 switch (Constraint[0]) {
1190 if (
auto *
C = dyn_cast<ConstantSDNode>(Op))
1197 if (
auto *
C = dyn_cast<ConstantSDNode>(Op))
1198 if (isUInt<12>(
C->getZExtValue()))
1204 if (
auto *
C = dyn_cast<ConstantSDNode>(Op))
1211 if (
auto *
C = dyn_cast<ConstantSDNode>(Op))
1212 if (isInt<20>(
C->getSExtValue()))
1218 if (
auto *
C = dyn_cast<ConstantSDNode>(Op))
1219 if (
C->getZExtValue() == 0x7fffffff)
1232 #include "SystemZGenCallingConv.inc" 1236 static const MCPhysReg ScratchRegs[] = { SystemZ::R0D, SystemZ::R1D,
1242 Type *ToType)
const {
1259 for (
unsigned i = 0; i < Ins.
size(); ++i)
1264 for (
unsigned i = 0; i < Outs.
size(); ++i)
1338 if (Subtarget.hasVector())
1346 unsigned NumFixedGPRs = 0;
1347 unsigned NumFixedFPRs = 0;
1348 for (
unsigned I = 0,
E = ArgLocs.
size();
I !=
E; ++
I) {
1361 RC = &SystemZ::GR32BitRegClass;
1365 RC = &SystemZ::GR64BitRegClass;
1369 RC = &SystemZ::FP32BitRegClass;
1373 RC = &SystemZ::FP64BitRegClass;
1381 RC = &SystemZ::VR128BitRegClass;
1402 ArgValue = DAG.
getLoad(LocVT, DL, Chain, FIN,
1413 unsigned ArgIndex = Ins[
I].OrigArgIndex;
1414 assert (Ins[
I].PartOffset == 0);
1415 while (
I + 1 !=
E && Ins[
I + 1].OrigArgIndex == ArgIndex) {
1417 unsigned PartOffset = Ins[
I + 1].PartOffset;
1435 int64_t StackSize = CCInfo.getNextStackOffset();
1453 &SystemZ::FP64BitRegClass);
1461 SystemZ::NumArgFPRs-NumFixedFPRs));
1474 for (
unsigned I = 0,
E = ArgLocs.
size();
I !=
E; ++
I) {
1481 if (Reg == SystemZ::R6H || Reg == SystemZ::R6L || Reg == SystemZ::R6D)
1483 if (Outs[
I].Flags.isSwiftSelf() || Outs[
I].Flags.isSwiftError())
1506 if (Subtarget.hasVector()) {
1522 unsigned NumBytes = ArgCCInfo.getNextStackOffset();
1532 for (
unsigned I = 0,
E = ArgLocs.
size();
I !=
E; ++
I) {
1539 int FI = cast<FrameIndexSDNode>(SpillSlot)->getIndex();
1541 DAG.
getStore(Chain, DL, ArgValue, SpillSlot,
1545 unsigned ArgIndex = Outs[
I].OrigArgIndex;
1546 assert (Outs[
I].PartOffset == 0);
1547 while (
I + 1 !=
E && Outs[
I + 1].OrigArgIndex == ArgIndex) {
1548 SDValue PartValue = OutVals[
I + 1];
1549 unsigned PartOffset = Outs[
I + 1].PartOffset;
1553 DAG.
getStore(Chain, DL, PartValue, Address,
1557 ArgValue = SpillSlot;
1584 if (!MemOpChains.
empty())
1591 if (
auto *
G = dyn_cast<GlobalAddressSDNode>(Callee)) {
1594 }
else if (
auto *
E = dyn_cast<ExternalSymbolSDNode>(Callee)) {
1597 }
else if (IsTailCall) {
1598 Chain = DAG.
getCopyToReg(Chain, DL, SystemZ::R1D, Callee, Glue);
1604 for (
unsigned I = 0,
E = RegsToPass.
size();
I !=
E; ++
I) {
1617 for (
unsigned I = 0,
E = RegsToPass.
size();
I !=
E; ++
I)
1619 RegsToPass[I].second.getValueType()));
1624 assert(Mask &&
"Missing call preserved mask for calling convention");
1651 for (
unsigned I = 0,
E = RetLocs.
size(); I !=
E; ++
I) {
1674 if (Subtarget.hasVector())
1679 for (
auto &Out : Outs)
1684 CCState RetCCInfo(CallConv, isVarArg, MF, RetLocs, Context);
1685 return RetCCInfo.
CheckReturn(Outs, RetCC_SystemZ);
1697 if (Subtarget.hasVector())
1706 if (RetLocs.
empty())
1716 for (
unsigned I = 0,
E = RetLocs.
size();
I !=
E; ++
I) {
1728 Chain = DAG.
getCopyToReg(Chain, DL, Reg, RetValue, Glue);
1745 unsigned &CCValid) {
1746 unsigned Id = cast<ConstantSDNode>(Op.
getOperand(1))->getZExtValue();
1748 case Intrinsic::s390_tbegin:
1753 case Intrinsic::s390_tbegin_nofloat:
1758 case Intrinsic::s390_tend:
1772 unsigned Id = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
1774 case Intrinsic::s390_vpkshs:
1775 case Intrinsic::s390_vpksfs:
1776 case Intrinsic::s390_vpksgs:
1781 case Intrinsic::s390_vpklshs:
1782 case Intrinsic::s390_vpklsfs:
1783 case Intrinsic::s390_vpklsgs:
1788 case Intrinsic::s390_vceqbs:
1789 case Intrinsic::s390_vceqhs:
1790 case Intrinsic::s390_vceqfs:
1791 case Intrinsic::s390_vceqgs:
1796 case Intrinsic::s390_vchbs:
1797 case Intrinsic::s390_vchhs:
1798 case Intrinsic::s390_vchfs:
1799 case Intrinsic::s390_vchgs:
1804 case Intrinsic::s390_vchlbs:
1805 case Intrinsic::s390_vchlhs:
1806 case Intrinsic::s390_vchlfs:
1807 case Intrinsic::s390_vchlgs:
1812 case Intrinsic::s390_vtm:
1817 case Intrinsic::s390_vfaebs:
1818 case Intrinsic::s390_vfaehs:
1819 case Intrinsic::s390_vfaefs:
1824 case Intrinsic::s390_vfaezbs:
1825 case Intrinsic::s390_vfaezhs:
1826 case Intrinsic::s390_vfaezfs:
1831 case Intrinsic::s390_vfeebs:
1832 case Intrinsic::s390_vfeehs:
1833 case Intrinsic::s390_vfeefs:
1838 case Intrinsic::s390_vfeezbs:
1839 case Intrinsic::s390_vfeezhs:
1840 case Intrinsic::s390_vfeezfs:
1845 case Intrinsic::s390_vfenebs:
1846 case Intrinsic::s390_vfenehs:
1847 case Intrinsic::s390_vfenefs:
1852 case Intrinsic::s390_vfenezbs:
1853 case Intrinsic::s390_vfenezhs:
1854 case Intrinsic::s390_vfenezfs:
1859 case Intrinsic::s390_vistrbs:
1860 case Intrinsic::s390_vistrhs:
1861 case Intrinsic::s390_vistrfs:
1866 case Intrinsic::s390_vstrcbs:
1867 case Intrinsic::s390_vstrchs:
1868 case Intrinsic::s390_vstrcfs:
1873 case Intrinsic::s390_vstrczbs:
1874 case Intrinsic::s390_vstrczhs:
1875 case Intrinsic::s390_vstrczfs:
1880 case Intrinsic::s390_vstrsb:
1881 case Intrinsic::s390_vstrsh:
1882 case Intrinsic::s390_vstrsf:
1887 case Intrinsic::s390_vstrszb:
1888 case Intrinsic::s390_vstrszh:
1889 case Intrinsic::s390_vstrszf:
1894 case Intrinsic::s390_vfcedbs:
1895 case Intrinsic::s390_vfcesbs:
1900 case Intrinsic::s390_vfchdbs:
1901 case Intrinsic::s390_vfchsbs:
1906 case Intrinsic::s390_vfchedbs:
1907 case Intrinsic::s390_vfchesbs:
1912 case Intrinsic::s390_vftcidb:
1913 case Intrinsic::s390_vftcisb:
1918 case Intrinsic::s390_tdc:
1936 for (
unsigned I = 2;
I < NumOps; ++
I)
1955 for (
unsigned I = 1;
I < NumOps; ++
I)
1969 case ISD::SET##X: return SystemZ::CCMASK_CMP_##X; \ 1970 case ISD::SETO##X: return SystemZ::CCMASK_CMP_##X; \ 1971 case ISD::SETU##X: return SystemZ::CCMASK_CMP_UO | SystemZ::CCMASK_CMP_##X 2000 int64_t
Value = ConstOp1->getSExtValue();
2006 C.Op1 = DAG.
getConstant(0, DL, C.Op1.getValueType());
2016 if (!C.Op0.hasOneUse() ||
2022 auto *
Load = cast<LoadSDNode>(C.Op0);
2023 unsigned NumBits =
Load->getMemoryVT().getStoreSizeInBits();
2024 if (NumBits != 8 && NumBits != 16)
2029 auto *ConstOp1 = cast<ConstantSDNode>(C.Op1);
2030 uint64_t
Value = ConstOp1->getZExtValue();
2031 uint64_t
Mask = (1 << NumBits) - 1;
2034 int64_t SignedValue = ConstOp1->getSExtValue();
2035 if (uint64_t(SignedValue) + (uint64_t(1) << (NumBits - 1)) > Mask)
2041 }
else if (NumBits == 8) {
2067 if (C.Op0.getValueType() !=
MVT::i32 ||
2070 Load->getBasePtr(),
Load->getPointerInfo(),
2071 Load->getMemoryVT(),
Load->getAlignment(),
2072 Load->getMemOperand()->getFlags());
2078 if (C.Op1.getValueType() !=
MVT::i32 ||
2079 Value != ConstOp1->getZExtValue())
2092 switch (
Load->getExtensionType()) {
2115 if (isa<ConstantFPSDNode>(C.Op1))
2121 if (ConstOp1 && ConstOp1->getZExtValue() == 0)
2150 unsigned Opcode0 = C.Op0.getOpcode();
2158 cast<ConstantSDNode>(C.Op0.getOperand(1))->getZExtValue() == 0xffffffff)
2180 for (
auto I = C.Op0->use_begin(),
E = C.Op0->use_end();
I !=
E; ++
I) {
2203 if (C1 && C1->isZero()) {
2204 for (
auto I = C.Op0->use_begin(),
E = C.Op0->use_end();
I !=
E; ++
I) {
2223 if (C.Op0.getOpcode() ==
ISD::SHL &&
2224 C.Op0.getValueType() ==
MVT::i64 &&
2226 cast<ConstantSDNode>(C.Op1)->getZExtValue() == 0) {
2228 if (C1 && C1->getZExtValue() == 32) {
2229 SDValue ShlOp0 = C.Op0.getOperand(0);
2249 C.Op0.getOperand(0).getOpcode() ==
ISD::LOAD &&
2251 cast<ConstantSDNode>(C.Op1)->getZExtValue() == 0) {
2252 auto *L = cast<LoadSDNode>(C.Op0.getOperand(0));
2253 if (L->getMemoryVT().getStoreSizeInBits() <= C.Op0.getValueSizeInBits()) {
2254 unsigned Type = L->getExtensionType();
2257 C.Op0 = C.Op0.getOperand(0);
2258 C.Op1 = DAG.
getConstant(0, DL, C.Op0.getValueType());
2286 uint64_t
Mask, uint64_t CmpVal,
2287 unsigned ICmpType) {
2288 assert(Mask != 0 &&
"ANDs with zero should have been removed by now");
2297 uint64_t
High = uint64_t(1) << HighShift;
2311 if (EffectivelyUnsigned && CmpVal > 0 && CmpVal <= Low) {
2317 if (EffectivelyUnsigned && CmpVal < Low) {
2325 if (CmpVal == Mask) {
2331 if (EffectivelyUnsigned && CmpVal >= Mask - Low && CmpVal < Mask) {
2337 if (EffectivelyUnsigned && CmpVal > Mask - Low && CmpVal <= Mask) {
2345 if (EffectivelyUnsigned && CmpVal >= Mask - High && CmpVal < High) {
2351 if (EffectivelyUnsigned && CmpVal > Mask - High && CmpVal <= High) {
2360 if (Mask == Low + High) {
2389 if (C.Op0.getOpcode() ==
ISD::AND) {
2390 NewC.Op0 = C.Op0.getOperand(0);
2391 NewC.Op1 = C.Op0.getOperand(1);
2400 if (NewC.Op0.getValueType() !=
MVT::i64 ||
2408 if (CmpVal == uint64_t(-1))
2415 MaskVal = -(CmpVal & -CmpVal);
2423 unsigned BitSize = NewC.Op0.getValueSizeInBits();
2424 unsigned NewCCMask, ShiftVal;
2426 NewC.Op0.getOpcode() ==
ISD::SHL &&
2428 (MaskVal >> ShiftVal != 0) &&
2429 ((CmpVal >> ShiftVal) << ShiftVal) == CmpVal &&
2431 MaskVal >> ShiftVal,
2434 NewC.Op0 = NewC.Op0.getOperand(0);
2435 MaskVal >>= ShiftVal;
2437 NewC.Op0.getOpcode() ==
ISD::SRL &&
2439 (MaskVal << ShiftVal != 0) &&
2440 ((CmpVal << ShiftVal) >> ShiftVal) == CmpVal &&
2442 MaskVal << ShiftVal,
2445 NewC.Op0 = NewC.Op0.getOperand(0);
2446 MaskVal <<= ShiftVal;
2460 C.Op1 = DAG.
getConstant(MaskVal, DL, C.Op0.getValueType());
2462 C.CCMask = NewCCMask;
2476 if ((~Known.
Zero).getZExtValue() & ~
Mask->getZExtValue())
2479 C.Op0 = C.Op0.getOperand(0);
2487 SDValue Call,
unsigned CCValid, uint64_t CC,
2491 C.CCValid = CCValid;
2494 C.CCMask = CC < 4 ? 1 << (3 - CC) : 0;
2497 C.CCMask = CC < 4 ? ~(1 << (3 - CC)) : -1;
2501 C.CCMask = CC < 4 ? ~0U << (4 - CC) : -1;
2504 C.CCMask = CC < 4 ? ~(~0U << (4 - CC)) : 0;
2508 C.CCMask = CC < 4 ? ~0U << (3 - CC) : -1;
2511 C.CCMask = CC < 4 ? ~(~0U << (3 - CC)) : 0;
2514 C.CCMask &= CCValid;
2522 bool IsSignaling =
false) {
2525 uint64_t
Constant = cast<ConstantSDNode>(CmpOp1)->getZExtValue();
2526 unsigned Opcode, CCValid;
2536 Comparison
C(CmpOp0, CmpOp1, Chain);
2538 if (C.Op0.getValueType().isFloatingPoint()) {
2542 else if (!IsSignaling)
2584 if (!C.Op1.getNode()) {
2586 switch (C.Op0.getOpcode()) {
2608 return DAG.
getNode(C.Opcode, DL, VTs, C.Chain, C.Op0, C.Op1);
2645 unsigned CCValid,
unsigned CCMask) {
2728 int Mask[] = { Start, -1, Start + 1, -1 };
2748 !Subtarget.hasVectorEnhancements1()) {
2762 SDValue Ops[2] = { Res, NewChain };
2771 return DAG.
getNode(Opcode, DL, VTs, Chain, CmpOp0, CmpOp1);
2773 return DAG.
getNode(Opcode, DL, VT, CmpOp0, CmpOp1);
2786 bool IsSignaling)
const {
2789 assert (!IsSignaling || Chain);
2792 bool Invert =
false;
2800 assert(IsFP &&
"Unexpected integer comparison");
2802 DL, VT, CmpOp1, CmpOp0, Chain);
2804 DL, VT, CmpOp0, CmpOp1, Chain);
2817 assert(IsFP &&
"Unexpected integer comparison");
2819 DL, VT, CmpOp1, CmpOp0, Chain);
2821 DL, VT, CmpOp0, CmpOp1, Chain);
2834 Cmp = getVectorCmp(DAG, Opcode, DL, VT, CmpOp0, CmpOp1, Chain);
2838 Cmp = getVectorCmp(DAG, Opcode, DL, VT, CmpOp1, CmpOp0, Chain);
2852 SDValue Ops[2] = { Cmp, Chain };
2866 return lowerVectorSETCC(DAG, DL, VT, CC, CmpOp0, CmpOp1);
2868 Comparison
C(
getCmp(DAG, CmpOp0, CmpOp1, CC, DL));
2870 return emitSETCC(DAG, DL, CCReg, C.CCValid, C.CCMask);
2875 bool IsSignaling)
const {
2883 SDValue Res = lowerVectorSETCC(DAG, DL, VT, CC, CmpOp0, CmpOp1,
2884 Chain, IsSignaling);
2888 Comparison
C(
getCmp(DAG, CmpOp0, CmpOp1, CC, DL, Chain, IsSignaling));
2903 Comparison
C(
getCmp(DAG, CmpOp0, CmpOp1, CC, DL));
2916 cast<ConstantSDNode>(Neg.
getOperand(0))->getZExtValue() == 0 &&
2920 Pos.getOperand(0) == CmpOp)));
2942 Comparison
C(
getCmp(DAG, CmpOp0, CmpOp1, CC, DL));
2951 cast<ConstantSDNode>(C.Op1)->getZExtValue() == 0) {
2959 SDValue Ops[] = {TrueOp, FalseOp,
2975 if (Subtarget.isPC32DBLSymbol(GV, CM)) {
2978 uint64_t Anchor = Offset & ~uint64_t(0xfff);
2985 if (Offset != 0 && (Offset & 1) == 0) {
3028 Chain = DAG.
getCopyToReg(Chain, DL, SystemZ::R12D, GOT, Glue);
3030 Chain = DAG.
getCopyToReg(Chain, DL, SystemZ::R2D, GOTOffset, Glue);
3049 assert(Mask &&
"Missing call preserved mask for calling convention");
3057 Chain = DAG.
getNode(Opcode, DL, NodeTys, Ops);
3064 SDValue SystemZTargetLowering::lowerThreadPointer(
const SDLoc &DL,
3096 SDValue TP = lowerThreadPointer(DL, DAG);
3222 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
3249 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
3258 unsigned LinkReg = MF.
addLiveIn(SystemZ::R14D, &SystemZ::GR64BitRegClass);
3272 if (
auto *LoadN = dyn_cast<LoadSDNode>(In))
3275 LoadN->getBasePtr(), LoadN->getMemOperand());
3283 if (Subtarget.hasHighWord()) {
3302 if (Subtarget.hasHighWord())
3325 const unsigned NumFields = 4;
3336 for (
unsigned I = 0;
I < NumFields; ++
I) {
3341 MemOps[
I] = DAG.
getStore(Chain, DL, Fields[
I], FieldAddr,
3353 const Value *DstSV = cast<SrcValueSDNode>(Op.
getOperand(3))->getValue();
3354 const Value *SrcSV = cast<SrcValueSDNode>(Op.
getOperand(4))->getValue();
3363 SDValue SystemZTargetLowering::
3377 uint64_t AlignVal = (RealignOpt ?
3381 uint64_t RequiredAlign =
std::max(AlignVal, StackAlign);
3382 uint64_t ExtraAlignSpace = RequiredAlign - StackAlign;
3396 if (ExtraAlignSpace)
3413 if (RequiredAlign > StackAlign) {
3425 SDValue Ops[2] = { Result, Chain };
3429 SDValue SystemZTargetLowering::lowerGET_DYNAMIC_AREA_OFFSET(
3446 else if (Subtarget.hasMiscellaneousExtensions2())
3475 LL, RL, Ops[1], Ops[0]);
3551 if ((Masks[0] >> 32) == 0xffffffff &&
uint32_t(Masks[1]) == 0xffffffff)
3553 else if ((Masks[1] >> 32) == 0xffffffff &&
uint32_t(Masks[0]) == 0xffffffff)
3568 int64_t
Value = int32_t(cast<ConstantSDNode>(LowOp)->getZExtValue());
3578 uint64_t
Mask = cast<ConstantSDNode>(HighOp.
getOperand(1))->getZExtValue();
3600 unsigned BaseOp = 0;
3601 unsigned CCValid = 0;
3602 unsigned CCMask = 0;
3665 unsigned BaseOp = 0;
3666 unsigned CCValid = 0;
3667 unsigned CCMask = 0;
3747 if (NumSignificantBits == 0)
3752 int64_t BitSize = (int64_t)1 <<
Log2_32_Ceil(NumSignificantBits);
3753 BitSize = std::min(BitSize, OrigBitSize);
3762 for (int64_t
I = BitSize / 2;
I >= 8;
I =
I / 2) {
3764 if (BitSize != OrigBitSize)
3766 DAG.
getConstant(((uint64_t)1 << BitSize) - 1, DL, VT));
3782 cast<ConstantSDNode>(Op.
getOperand(1))->getZExtValue());
3784 cast<ConstantSDNode>(Op.
getOperand(2))->getZExtValue());
3802 auto *Node = cast<AtomicSDNode>(Op.
getNode());
3804 Node->getChain(), Node->getBasePtr(),
3805 Node->getMemoryVT(), Node->getMemOperand());
3811 auto *Node = cast<AtomicSDNode>(Op.
getNode());
3813 Node->getBasePtr(), Node->getMemoryVT(),
3814 Node->getMemOperand());
3827 unsigned Opcode)
const {
3828 auto *Node = cast<AtomicSDNode>(Op.
getNode());
3831 EVT NarrowVT = Node->getMemoryVT();
3833 if (NarrowVT == WideVT)
3836 int64_t BitSize = NarrowVT.getSizeInBits();
3837 SDValue ChainIn = Node->getChain();
3838 SDValue Addr = Node->getBasePtr();
3839 SDValue Src2 = Node->getVal();
3846 if (
auto *Const = dyn_cast<ConstantSDNode>(Src2)) {
3881 SDValue Ops[] = { ChainIn, AlignedAddr, Src2, BitShift, NegBitShift,
3901 auto *Node = cast<AtomicSDNode>(Op.
getNode());
3902 EVT MemVT = Node->getMemoryVT();
3906 SDValue Src2 = Node->getVal();
3910 if (
auto *Op2 = dyn_cast<ConstantSDNode>(Src2)) {
3913 int64_t
Value = (-Op2->getAPIntValue()).getSExtValue();
3914 if (
isInt<32>(Value) || Subtarget.hasInterlockedAccess1())
3916 }
else if (Subtarget.hasInterlockedAccess1())
3923 Node->getChain(), Node->getBasePtr(), NegSrc2,
3924 Node->getMemOperand());
3936 auto *Node = cast<AtomicSDNode>(Op.
getNode());
3946 EVT NarrowVT = Node->getMemoryVT();
3948 if (NarrowVT == WideVT) {
3950 SDValue Ops[] = { ChainIn, Addr, CmpVal, SwapVal };
3952 DL, Tys, Ops, NarrowVT, MMO);
3984 SDValue Ops[] = { ChainIn, AlignedAddr, CmpVal, SwapVal, BitShift,
3985 NegBitShift, DAG.
getConstant(BitSize, DL, WideVT) };
3987 VTList, Ops, NarrowVT, MMO);
3998 SystemZTargetLowering::getMMOFlags(
const Instruction &
I)
const {
4003 if (
auto *
SI = dyn_cast<StoreInst>(&I))
4006 if (
auto *LI = dyn_cast<LoadInst>(&I))
4009 if (
auto *AI = dyn_cast<AtomicRMWInst>(&I))
4012 if (
auto *AI = dyn_cast<AtomicCmpXchgInst>(&I))
4024 "in GHC calling convention");
4037 "in GHC calling convention");
4044 if (StoreBackchain) {
4049 Chain = DAG.
getCopyToReg(Chain, DL, SystemZ::R15D, NewSP);
4059 bool IsData = cast<ConstantSDNode>(Op.
getOperand(4))->getZExtValue();
4065 bool IsWrite = cast<ConstantSDNode>(Op.
getOperand(2))->getZExtValue();
4067 auto *Node = cast<MemIntrinsicSDNode>(Op.
getNode());
4072 Node->getMemoryVT(), Node->getMemOperand());
4084 SystemZTargetLowering::lowerINTRINSIC_W_CHAIN(
SDValue Op,
4086 unsigned Opcode, CCValid;
4099 SystemZTargetLowering::lowerINTRINSIC_WO_CHAIN(
SDValue Op,
4101 unsigned Opcode, CCValid;
4111 unsigned Id = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
4113 case Intrinsic::thread_pointer:
4114 return lowerThreadPointer(
SDLoc(Op), DAG);
4116 case Intrinsic::s390_vpdi:
4120 case Intrinsic::s390_vperm:
4124 case Intrinsic::s390_vuphb:
4125 case Intrinsic::s390_vuphh:
4126 case Intrinsic::s390_vuphf:
4130 case Intrinsic::s390_vuplhb:
4131 case Intrinsic::s390_vuplhh:
4132 case Intrinsic::s390_vuplhf:
4136 case Intrinsic::s390_vuplb:
4137 case Intrinsic::s390_vuplhw:
4138 case Intrinsic::s390_vuplf:
4142 case Intrinsic::s390_vupllb:
4143 case Intrinsic::s390_vupllh:
4144 case Intrinsic::s390_vupllf:
4148 case Intrinsic::s390_vsumb:
4149 case Intrinsic::s390_vsumh:
4150 case Intrinsic::s390_vsumgh:
4151 case Intrinsic::s390_vsumgf:
4152 case Intrinsic::s390_vsumqf:
4153 case Intrinsic::s390_vsumqg:
4176 { 0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 20, 21, 22, 23 } },
4179 { 0, 1, 2, 3, 16, 17, 18, 19, 4, 5, 6, 7, 20, 21, 22, 23 } },
4182 { 0, 1, 16, 17, 2, 3, 18, 19, 4, 5, 20, 21, 6, 7, 22, 23 } },
4185 { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 } },
4188 { 8, 9, 10, 11, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31 } },
4191 { 8, 9, 10, 11, 24, 25, 26, 27, 12, 13, 14, 15, 28, 29, 30, 31 } },
4194 { 8, 9, 24, 25, 10, 11, 26, 27, 12, 13, 28, 29, 14, 15, 30, 31 } },
4197 { 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31 } },
4200 { 4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31 } },
4203 { 2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31 } },
4206 { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31 } },
4209 { 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 } },
4212 { 0, 1, 2, 3, 4, 5, 6, 7, 24, 25, 26, 27, 28, 29, 30, 31 } }
4226 OpNo0 = OpNo1 = OpNos[1];
4227 }
else if (OpNos[1] < 0) {
4228 OpNo0 = OpNo1 = OpNos[0];
4246 unsigned &OpNo0,
unsigned &OpNo1) {
4247 int OpNos[] = { -1, -1 };
4254 if ((Elt ^ P.Bytes[I]) & (SystemZ::VectorBytes - 1))
4260 if (OpNos[ModelOpNo] == 1 - RealOpNo)
4262 OpNos[ModelOpNo] = RealOpNo;
4270 unsigned &OpNo0,
unsigned &OpNo1) {
4271 for (
auto &
P : PermuteForms)
4287 int Elt = Bytes[
From];
4290 Transform[
From] = -1;
4292 while (P.Bytes[To] != Elt) {
4294 if (To == SystemZ::VectorBytes)
4297 Transform[
From] = To;
4306 for (
auto &
P : PermuteForms)
4320 if (
auto *VSN = dyn_cast<ShuffleVectorSDNode>(ShuffleOp)) {
4321 Bytes.
resize(NumElements * BytesPerElement, -1);
4322 for (
unsigned I = 0; I < NumElements; ++
I) {
4323 int Index = VSN->getMaskElt(I);
4325 for (
unsigned J = 0; J < BytesPerElement; ++J)
4326 Bytes[I * BytesPerElement + J] = Index * BytesPerElement + J;
4331 isa<ConstantSDNode>(ShuffleOp.
getOperand(1))) {
4333 Bytes.
resize(NumElements * BytesPerElement, -1);
4334 for (
unsigned I = 0; I < NumElements; ++
I)
4335 for (
unsigned J = 0; J < BytesPerElement; ++J)
4336 Bytes[I * BytesPerElement + J] = Index * BytesPerElement + J;
4347 unsigned BytesPerElement,
int &
Base) {
4349 for (
unsigned I = 0; I < BytesPerElement; ++
I) {
4350 if (Bytes[Start + I] >= 0) {
4351 unsigned Elem = Bytes[Start +
I];
4355 if (
unsigned(Base) % Bytes.
size() + BytesPerElement > Bytes.
size())
4357 }
else if (
unsigned(Base) != Elem -
I)
4370 unsigned &StartIndex,
unsigned &OpNo0,
4372 int OpNos[] = { -1, -1 };
4374 for (
unsigned I = 0; I < 16; ++
I) {
4381 Shift = ExpectedShift;
4382 else if (Shift != ExpectedShift)
4386 if (OpNos[ModelOpNo] == 1 - RealOpNo)
4388 OpNos[ModelOpNo] = RealOpNo;
4418 Op = DAG.
getNode(P.Opcode, DL, InVT, Op0, Op1);
4429 for (
unsigned I = 0; I < 2; ++
I)
4433 unsigned StartIndex, OpNo0, OpNo1;
4452 struct GeneralShuffle {
4453 GeneralShuffle(
EVT vt) : VT(vt) {}
4472 void GeneralShuffle::addUndef() {
4474 for (
unsigned I = 0; I < BytesPerElement; ++
I)
4475 Bytes.push_back(-1);
4495 if (FromBytesPerElement < BytesPerElement)
4499 (FromBytesPerElement - BytesPerElement));
4529 for (; OpNo < Ops.size(); ++OpNo)
4530 if (Ops[OpNo] == Op)
4532 if (OpNo == Ops.size())
4537 for (
unsigned I = 0; I < BytesPerElement; ++
I)
4538 Bytes.push_back(Base + I);
4547 if (Ops.size() == 0)
4551 if (Ops.size() == 1)
4563 unsigned Stride = 1;
4564 for (; Stride * 2 < Ops.size(); Stride *= 2) {
4565 for (
unsigned I = 0; I < Ops.size() - Stride; I += Stride * 2) {
4566 SDValue SubOps[] = { Ops[
I], Ops[I + Stride] };
4575 else if (OpNo == I + Stride)
4576 NewBytes[J] = SystemZ::VectorBytes + Byte;
4586 if (NewBytes[J] >= 0) {
4587 assert(
unsigned(NewBytesMap[J]) < SystemZ::VectorBytes &&
4588 "Invalid double permute");
4589 Bytes[J] = I * SystemZ::VectorBytes + NewBytesMap[J];
4591 assert(NewBytesMap[J] < 0 &&
"Invalid double permute");
4597 if (NewBytes[J] >= 0)
4598 Bytes[J] = I * SystemZ::VectorBytes + J;
4605 Ops[1] = Ops[Stride];
4607 if (Bytes[I] >=
int(SystemZ::VectorBytes))
4608 Bytes[
I] -= (Stride - 1) * SystemZ::VectorBytes;
4613 unsigned OpNo0, OpNo1;
4694 GeneralShuffle
GS(VT);
4696 bool FoundOne =
false;
4697 for (
unsigned I = 0; I < NumElements; ++
I) {
4703 unsigned Elem = cast<ConstantSDNode>(Op.
getOperand(1))->getZExtValue();
4721 if (!ResidueOps.
empty()) {
4722 while (ResidueOps.
size() < NumElements)
4724 for (
auto &Op : GS.Ops) {
4731 return GS.getNode(DAG,
SDLoc(BVN));
4734 bool SystemZTargetLowering::isVectorElementLoad(
SDValue Op)
const {
4748 unsigned int NumElements = Elems.
size();
4749 unsigned int Count = 0;
4750 for (
auto Elem : Elems) {
4751 if (!Elem.isUndef()) {
4754 else if (Elem != Single) {
4774 if (Single.
getNode() && (Count > 1 || isVectorElementLoad(Single)))
4778 bool AllLoads =
true;
4779 for (
auto Elem : Elems)
4780 if (!isVectorElementLoad(Elem)) {
4787 return joinDwords(DAG, DL, Elems[0], Elems[1]);
4822 unsigned NumConstants = 0;
4823 for (
unsigned I = 0; I < NumElements; ++
I) {
4828 Constants[
I] = Elem;
4837 if (NumConstants > 0) {
4838 for (
unsigned I = 0; I < NumElements; ++
I)
4839 if (!Constants[I].getNode())
4840 Constants[I] = DAG.
getUNDEF(Elems[I].getValueType());
4849 std::map<const SDNode*, unsigned> UseCounts;
4850 SDNode *LoadMaxUses =
nullptr;
4851 for (
unsigned I = 0; I < NumElements; ++
I)
4852 if (isVectorElementLoad(Elems[I])) {
4853 SDNode *Ld = Elems[
I].getNode();
4855 if (LoadMaxUses ==
nullptr || UseCounts[LoadMaxUses] < UseCounts[Ld])
4858 if (LoadMaxUses !=
nullptr) {
4859 ReplicatedVal =
SDValue(LoadMaxUses, 0);
4863 unsigned I1 = NumElements / 2 - 1;
4864 unsigned I2 = NumElements - 1;
4865 bool Def1 = !Elems[I1].
isUndef();
4866 bool Def2 = !Elems[I2].isUndef();
4868 SDValue Elem1 = Elems[Def1 ? I1 : I2];
4869 SDValue Elem2 = Elems[Def2 ? I2 : I1];
4880 for (
unsigned I = 0; I < NumElements; ++
I)
4881 if (!Done[I] && !Elems[I].
isUndef() && Elems[I] != ReplicatedVal)
4889 auto *BVN = cast<BuildVectorSDNode>(Op.
getNode());
4893 if (BVN->isConstant()) {
4912 for (
unsigned I = 0; I < NumElements; ++
I)
4914 return buildVector(DAG, DL, VT, Ops);
4919 auto *VSN = cast<ShuffleVectorSDNode>(Op.
getNode());
4924 if (VSN->isSplat()) {
4926 unsigned Index = VSN->getSplatIndex();
4928 "Splat index should be defined and in first operand");
4938 GeneralShuffle
GS(VT);
4939 for (
unsigned I = 0; I < NumElements; ++
I) {
4940 int Elt = VSN->getMaskElt(I);
4943 else if (!GS.add(Op.
getOperand(
unsigned(Elt) / NumElements),
4947 return GS.getNode(DAG,
SDLoc(VSN));
4959 SDValue SystemZTargetLowering::lowerINSERT_VECTOR_ELT(
SDValue Op,
4975 uint64_t
Index = cast<ConstantSDNode>(Op2)->getZExtValue();
4991 SystemZTargetLowering::lowerEXTRACT_VECTOR_ELT(
SDValue Op,
5001 if (
auto *CIndexN = dyn_cast<ConstantSDNode>(Op1)) {
5002 uint64_t
Index = CIndexN->getZExtValue();
5018 unsigned UnpackHigh)
const {
5028 PackedOp = DAG.
getNode(UnpackHigh,
SDLoc(PackedOp), OutVT, PackedOp);
5029 }
while (FromBits != ToBits);
5034 unsigned ByScalar)
const {
5043 if (
auto *BVN = dyn_cast<BuildVectorSDNode>(Op1)) {
5044 APInt SplatBits, SplatUndef;
5045 unsigned SplatBitSize;
5049 if (BVN->isConstantSplat(SplatBits, SplatUndef, SplatBitSize, HasAnyUndefs,
5050 ElemBitSize,
true) &&
5051 SplatBitSize == ElemBitSize) {
5054 return DAG.
getNode(ByScalar, DL, VT, Op0, Shift);
5058 SDValue Splat = BVN->getSplatValue(&UndefElements);
5063 return DAG.
getNode(ByScalar, DL, VT, Op0, Shift);
5069 if (
auto *VSN = dyn_cast<ShuffleVectorSDNode>(Op1)) {
5070 if (VSN->isSplat()) {
5072 unsigned Index = VSN->getSplatIndex();
5074 "Splat index should be defined and in first operand");
5081 return DAG.
getNode(ByScalar, DL, VT, Op0, Shift);
5094 return lowerFRAMEADDR(Op, DAG);
5096 return lowerRETURNADDR(Op, DAG);
5098 return lowerBR_CC(Op, DAG);
5100 return lowerSELECT_CC(Op, DAG);
5102 return lowerSETCC(Op, DAG);
5104 return lowerSTRICT_FSETCC(Op, DAG,
false);
5106 return lowerSTRICT_FSETCC(Op, DAG,
true);
5108 return lowerGlobalAddress(cast<GlobalAddressSDNode>(Op), DAG);
5110 return lowerGlobalTLSAddress(cast<GlobalAddressSDNode>(Op), DAG);
5112 return lowerBlockAddress(cast<BlockAddressSDNode>(Op), DAG);
5114 return lowerJumpTable(cast<JumpTableSDNode>(Op), DAG);
5116 return lowerConstantPool(cast<ConstantPoolSDNode>(Op), DAG);
5118 return lowerBITCAST(Op, DAG);
5120 return lowerVASTART(Op, DAG);
5122 return lowerVACOPY(Op, DAG);
5124 return lowerDYNAMIC_STACKALLOC(Op, DAG);
5126 return lowerGET_DYNAMIC_AREA_OFFSET(Op, DAG);
5128 return lowerSMUL_LOHI(Op, DAG);
5130 return lowerUMUL_LOHI(Op, DAG);
5132 return lowerSDIVREM(Op, DAG);
5134 return lowerUDIVREM(Op, DAG);
5139 return lowerXALUO(Op, DAG);
5142 return lowerADDSUBCARRY(Op, DAG);
5144 return lowerOR(Op, DAG);
5146 return lowerCTPOP(Op, DAG);
5148 return lowerATOMIC_FENCE(Op, DAG);
5152 return lowerATOMIC_STORE(Op, DAG);
5154 return lowerATOMIC_LOAD(Op, DAG);
5158 return lowerATOMIC_LOAD_SUB(Op, DAG);
5176 return lowerATOMIC_CMP_SWAP(Op, DAG);
5178 return lowerSTACKSAVE(Op, DAG);
5180 return lowerSTACKRESTORE(Op, DAG);
5182 return lowerPREFETCH(Op, DAG);
5184 return lowerINTRINSIC_W_CHAIN(Op, DAG);
5186 return lowerINTRINSIC_WO_CHAIN(Op, DAG);
5188 return lowerBUILD_VECTOR(Op, DAG);
5190 return lowerVECTOR_SHUFFLE(Op, DAG);
5192 return lowerSCALAR_TO_VECTOR(Op, DAG);
5194 return lowerINSERT_VECTOR_ELT(Op, DAG);
5196 return lowerEXTRACT_VECTOR_ELT(Op, DAG);
5262 if (cast<AtomicSDNode>(N)->getOrdering() ==
5299 #define OPCODE(NAME) case SystemZISD::NAME: return "SystemZISD::" #NAME 5433 bool SystemZTargetLowering::canTreatAsByteVector(
EVT VT)
const {
5434 if (!Subtarget.hasVector())
5445 SDValue SystemZTargetLowering::combineExtract(
const SDLoc &DL,
EVT ResVT,
5470 BytesPerElement, First))
5477 if (Byte % BytesPerElement != 0)
5480 Index = Byte / BytesPerElement;
5489 if (OpBytesPerElement < BytesPerElement)
5493 unsigned End = (Index + 1) * BytesPerElement;
5494 if (End % OpBytesPerElement != 0)
5497 Op = Op.
getOperand(End / OpBytesPerElement - 1);
5520 unsigned Byte = Index * BytesPerElement;
5521 unsigned SubByte = Byte % ExtBytesPerElement;
5522 unsigned MinSubByte = ExtBytesPerElement - OpBytesPerElement;
5523 if (SubByte < MinSubByte ||
5524 SubByte + BytesPerElement > ExtBytesPerElement)
5527 Byte = Byte / ExtBytesPerElement * OpBytesPerElement;
5529 Byte += SubByte - MinSubByte;
5530 if (Byte % BytesPerElement != 0)
5533 Index = Byte / BytesPerElement;
5551 SDValue SystemZTargetLowering::combineTruncateExtract(
5560 if (canTreatAsByteVector(VecVT)) {
5561 if (
auto *IndexN = dyn_cast<ConstantSDNode>(Op.
getOperand(1))) {
5564 if (BytesPerElement % TruncBytes == 0) {
5570 unsigned Scale = BytesPerElement / TruncBytes;
5571 unsigned NewIndex = (IndexN->getZExtValue() + 1) * Scale - 1;
5577 EVT ResVT = (TruncBytes < 4 ?
MVT::i32 : TruncVT);
5578 return combineExtract(DL, ResVT, VecVT, Vec, NewIndex, DCI,
true);
5586 SDValue SystemZTargetLowering::combineZERO_EXTEND(
5595 if (TrueOp && FalseOp) {
5613 SDValue SystemZTargetLowering::combineSIGN_EXTEND_INREG(
5634 SDValue SystemZTargetLowering::combineSIGN_EXTEND(
5645 if (SraAmt && Inner.hasOneUse() && Inner.getOpcode() ==
ISD::SHL) {
5646 if (
auto *ShlAmt = dyn_cast<ConstantSDNode>(Inner.getOperand(1))) {
5648 unsigned NewShlAmt = ShlAmt->getZExtValue() + Extra;
5649 unsigned NewSraAmt = SraAmt->getZExtValue() + Extra;
5652 Inner.getOperand(0));
5664 SDValue SystemZTargetLowering::combineMERGE(
5680 if (ElemBytes <= 4) {
5698 SDValue SystemZTargetLowering::combineLOAD(
5719 else if (UI.getUse().getResNo() == 0)
5722 if (!Replicate || OtherUses.
empty())
5729 for (
SDNode *U : OtherUses) {
5738 bool SystemZTargetLowering::canLoadStoreByteSwapped(
EVT VT)
const {
5741 if (Subtarget.hasVectorEnhancements2())
5754 for (
unsigned i = 0; i < NumElts; ++i) {
5755 if (M[i] < 0)
continue;
5756 if ((
unsigned) M[i] != NumElts - 1 - i)
5763 SDValue SystemZTargetLowering::combineSTORE(
5764 SDNode *N, DAGCombinerInfo &DCI)
const {
5766 auto *SN = cast<StoreSDNode>(
N);
5768 EVT MemVT = SN->getMemoryVT();
5773 if (MemVT.
isInteger() && SN->isTruncatingStore()) {
5775 combineTruncateExtract(
SDLoc(N), MemVT, SN->getValue(), DCI)) {
5776 DCI.AddToWorklist(
Value.getNode());
5780 SN->getBasePtr(), SN->getMemoryVT(),
5781 SN->getMemOperand());
5785 if (!SN->isTruncatingStore() &&
5787 Op1.getNode()->hasOneUse() &&
5788 canLoadStoreByteSwapped(Op1.getValueType())) {
5801 Ops, MemVT, SN->getMemOperand());
5804 if (!SN->isTruncatingStore() &&
5806 Op1.getNode()->hasOneUse() &&
5807 Subtarget.hasVectorEnhancements2()) {
5817 Ops, MemVT, SN->getMemOperand());
5824 SDValue SystemZTargetLowering::combineVECTOR_SHUFFLE(
5825 SDNode *N, DAGCombinerInfo &DCI)
const {
5830 Subtarget.hasVectorEnhancements2()) {
5849 DCI.CombineTo(N, ESLoad);
5863 SDValue SystemZTargetLowering::combineEXTRACT_VECTOR_ELT(
5864 SDNode *N, DAGCombinerInfo &DCI)
const {
5867 if (!Subtarget.hasVector())
5885 DCI.AddToWorklist(Op.
getNode());
5888 DCI.AddToWorklist(Op.
getNode());
5895 if (
auto *IndexN = dyn_cast<ConstantSDNode>(N->
getOperand(1))) {
5899 IndexN->getZExtValue(), DCI,
false);
5904 SDValue SystemZTargetLowering::combineJOIN_DWORDS(
5905 SDNode *N, DAGCombinerInfo &DCI)
const {
5919 if (Chain1 == Chain2)
5927 SDValue SystemZTargetLowering::combineFP_ROUND(
5928 SDNode *N, DAGCombinerInfo &DCI)
const {
5930 if (!Subtarget.hasVector())
5947 cast<ConstantSDNode>(Op0.
getOperand(1))->getZExtValue() == 0) {
5949 for (
auto *U : Vec->
uses()) {
5953 U->getOperand(0) == Vec &&
5955 cast<ConstantSDNode>(U->getOperand(1))->getZExtValue() == 1) {
5971 DCI.AddToWorklist(VRound.
getNode());
5975 DCI.AddToWorklist(Extract1.
getNode());
5993 SDValue SystemZTargetLowering::combineFP_EXTEND(
5994 SDNode *N, DAGCombinerInfo &DCI)
const {
5996 if (!Subtarget.hasVector())
6013 cast<ConstantSDNode>(Op0.
getOperand(1))->getZExtValue() == 0) {
6015 for (
auto *U : Vec->
uses()) {
6019 U->getOperand(0) == Vec &&
6021 cast<ConstantSDNode>(U->getOperand(1))->getZExtValue() == 2) {
6037 DCI.AddToWorklist(VExtend.
getNode());
6041 DCI.AddToWorklist(Extract1.
getNode());
6059 SDValue SystemZTargetLowering::combineBSWAP(
6060 SDNode *N, DAGCombinerInfo &DCI)
const {
6089 DCI.CombineTo(N, ResVal);
6124 DCI.AddToWorklist(Vec.
getNode());
6128 DCI.AddToWorklist(Elt.
getNode());
6131 DCI.AddToWorklist(Vec.
getNode());
6133 DCI.AddToWorklist(Elt.
getNode());
6152 DCI.AddToWorklist(Op0.
getNode());
6156 DCI.AddToWorklist(Op1.
getNode());
6159 DCI.AddToWorklist(Op0.
getNode());
6161 DCI.AddToWorklist(Op1.
getNode());
6190 bool Invert =
false;
6203 if (CompareRHS->getZExtValue() == FalseVal->getZExtValue())
6205 else if (CompareRHS->getZExtValue() != TrueVal->getZExtValue())
6211 if (!NewCCValid || !NewCCMask)
6214 CCMask = NewCCMask->getZExtValue();
6224 if (CompareLHS->getOpcode() ==
ISD::SRA) {
6226 if (!SRACount || SRACount->getZExtValue() != 30)
6228 auto *
SHL = CompareLHS->getOperand(0).getNode();
6234 auto *
IPM =
SHL->getOperand(0).getNode();
6239 if (!CompareLHS->hasOneUse())
6242 if (CompareRHS->getZExtValue() != 0)
6253 default:
return false;
6257 CCReg =
IPM->getOperand(0);
6264 SDValue SystemZTargetLowering::combineBR_CCMASK(
6265 SDNode *N, DAGCombinerInfo &DCI)
const {
6271 if (!CCValid || !CCMask)
6274 int CCValidVal = CCValid->getZExtValue();
6275 int CCMaskVal = CCMask->getZExtValue();
6288 SDValue SystemZTargetLowering::combineSELECT_CCMASK(
6289 SDNode *N, DAGCombinerInfo &DCI)
const {
6295 if (!CCValid || !CCMask)
6298 int CCValidVal = CCValid->getZExtValue();
6299 int CCMaskVal = CCMask->getZExtValue();
6312 SDValue SystemZTargetLowering::combineGET_CCMASK(
6313 SDNode *N, DAGCombinerInfo &DCI)
const {
6318 if (!CCValid || !CCMask)
6320 int CCValidVal = CCValid->getZExtValue();
6321 int CCMaskVal = CCMask->getZExtValue();
6329 if (!SelectCCValid || !SelectCCMask)
6331 int SelectCCValidVal = SelectCCValid->getZExtValue();
6332 int SelectCCMaskVal = SelectCCMask->getZExtValue();
6336 if (!TrueVal || !FalseVal)
6338 if (TrueVal->getZExtValue() != 0 && FalseVal->getZExtValue() == 0)
6340 else if (TrueVal->getZExtValue() == 0 && FalseVal->getZExtValue() != 0)
6341 SelectCCMaskVal ^= SelectCCValidVal;
6345 if (SelectCCValidVal & ~CCValidVal)
6347 if (SelectCCMaskVal != (CCMaskVal & SelectCCValidVal))
6353 SDValue SystemZTargetLowering::combineIntDIVREM(
6354 SDNode *N, DAGCombinerInfo &DCI)
const {
6385 case ISD::LOAD:
return combineLOAD(N, DCI);
6386 case ISD::STORE:
return combineSTORE(N, DCI);
6394 case ISD::BSWAP:
return combineBSWAP(N, DCI);
6401 case ISD::UREM:
return combineIntDIVREM(N, DCI);
6416 unsigned Id = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
6418 case Intrinsic::s390_vpksh:
6419 case Intrinsic::s390_vpksf:
6420 case Intrinsic::s390_vpksg:
6421 case Intrinsic::s390_vpkshs:
6422 case Intrinsic::s390_vpksfs:
6423 case Intrinsic::s390_vpksgs:
6424 case Intrinsic::s390_vpklsh:
6425 case Intrinsic::s390_vpklsf:
6426 case Intrinsic::s390_vpklsg:
6427 case Intrinsic::s390_vpklshs:
6428 case Intrinsic::s390_vpklsfs:
6429 case Intrinsic::s390_vpklsgs:
6431 SrcDemE = DemandedElts;
6434 SrcDemE = SrcDemE.
trunc(NumElts / 2);
6437 case Intrinsic::s390_vuphb:
6438 case Intrinsic::s390_vuphh:
6439 case Intrinsic::s390_vuphf:
6440 case Intrinsic::s390_vuplhb:
6441 case Intrinsic::s390_vuplhh:
6442 case Intrinsic::s390_vuplhf:
6443 SrcDemE =
APInt(NumElts * 2, 0);
6446 case Intrinsic::s390_vuplb:
6447 case Intrinsic::s390_vuplhw:
6448 case Intrinsic::s390_vuplf:
6449 case Intrinsic::s390_vupllb:
6450 case Intrinsic::s390_vupllh:
6451 case Intrinsic::s390_vupllf:
6452 SrcDemE =
APInt(NumElts * 2, 0);
6455 case Intrinsic::s390_vpdi: {
6457 SrcDemE =
APInt(NumElts, 0);
6458 if (!DemandedElts[OpNo - 1])
6460 unsigned Mask = cast<ConstantSDNode>(Op.
getOperand(3))->getZExtValue();
6461 unsigned MaskBit = ((OpNo - 1) ? 1 : 4);
6463 SrcDemE.
setBit((Mask & MaskBit)? 1 : 0);
6466 case Intrinsic::s390_vsldb: {
6469 unsigned FirstIdx = cast<ConstantSDNode>(Op.
getOperand(3))->getZExtValue();
6470 assert (FirstIdx > 0 && FirstIdx < 16 &&
"Unused operand.");
6471 unsigned NumSrc0Els = 16 - FirstIdx;
6472 SrcDemE =
APInt(NumElts, 0);
6474 APInt DemEls = DemandedElts.
trunc(NumSrc0Els);
6477 APInt DemEls = DemandedElts.
lshr(NumSrc0Els);
6482 case Intrinsic::s390_vperm:
6483 SrcDemE =
APInt(NumElts, 1);
6493 SrcDemE =
APInt(1, 1);
6496 SrcDemE = DemandedElts;
6507 const APInt &DemandedElts,
6517 Known.
One = LHSKnown.
One & RHSKnown.
One;
6523 const APInt &DemandedElts,
6525 unsigned Depth)
const {
6529 unsigned tmp0, tmp1;
6538 "KnownBits does not match VT in bitwidth");
6541 "DemandedElts does not match VT number of elements");
6546 unsigned Id = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
6548 case Intrinsic::s390_vpksh:
6549 case Intrinsic::s390_vpksf:
6550 case Intrinsic::s390_vpksg:
6551 case Intrinsic::s390_vpkshs:
6552 case Intrinsic::s390_vpksfs:
6553 case Intrinsic::s390_vpksgs:
6554 case Intrinsic::s390_vpklsh:
6555 case Intrinsic::s390_vpklsf:
6556 case Intrinsic::s390_vpklsg:
6557 case Intrinsic::s390_vpklshs:
6558 case Intrinsic::s390_vpklsfs:
6559 case Intrinsic::s390_vpklsgs:
6560 case Intrinsic::s390_vpdi:
6561 case Intrinsic::s390_vsldb:
6562 case Intrinsic::s390_vperm:
6565 case Intrinsic::s390_vuplhb:
6566 case Intrinsic::s390_vuplhh:
6567 case Intrinsic::s390_vuplhf:
6568 case Intrinsic::s390_vupllb:
6569 case Intrinsic::s390_vupllh:
6570 case Intrinsic::s390_vupllf:
6573 case Intrinsic::s390_vuphb:
6574 case Intrinsic::s390_vuphh:
6575 case Intrinsic::s390_vuphf:
6576 case Intrinsic::s390_vuplb:
6577 case Intrinsic::s390_vuplhw:
6578 case Intrinsic::s390_vuplf: {
6583 Known = Known.
zext(BitWidth,
true);
6585 Known = Known.
sext(BitWidth);
6600 if (Known.
getBitWidth() < BitWidth && isa<ConstantSDNode>(SrcOp))
6601 Known = Known.
sext(BitWidth);
6620 if (LHS == 1)
return 1;
6623 if (RHS == 1)
return 1;
6624 unsigned Common = std::min(LHS, RHS);
6628 if (SrcBitWidth > VTBits) {
6629 unsigned SrcExtraBits = SrcBitWidth - VTBits;
6630 if (Common > SrcExtraBits)
6631 return (Common - SrcExtraBits);
6634 assert (SrcBitWidth == VTBits &&
"Expected operands of same bitwidth.");
6641 unsigned Depth)
const {
6646 unsigned Id = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
6648 case Intrinsic::s390_vpksh:
6649 case Intrinsic::s390_vpksf:
6650 case Intrinsic::s390_vpksg:
6651 case Intrinsic::s390_vpkshs:
6652 case Intrinsic::s390_vpksfs:
6653 case Intrinsic::s390_vpksgs:
6654 case Intrinsic::s390_vpklsh:
6655 case Intrinsic::s390_vpklsf:
6656 case Intrinsic::s390_vpklsg:
6657 case Intrinsic::s390_vpklshs:
6658 case Intrinsic::s390_vpklsfs:
6659 case Intrinsic::s390_vpklsgs:
6660 case Intrinsic::s390_vpdi:
6661 case Intrinsic::s390_vsldb:
6662 case Intrinsic::s390_vperm:
6664 case Intrinsic::s390_vuphb:
6665 case Intrinsic::s390_vuphh:
6666 case Intrinsic::s390_vuphf:
6667 case Intrinsic::s390_vuplb:
6668 case Intrinsic::s390_vuplhw:
6669 case Intrinsic::s390_vuplf: {
6759 if (miI == MBB->
end()) {
6761 if ((*SI)->isLiveIn(SystemZ::CC))
6773 case SystemZ::Select32:
6774 case SystemZ::Select64:
6775 case SystemZ::SelectF32:
6776 case SystemZ::SelectF64:
6777 case SystemZ::SelectF128:
6778 case SystemZ::SelectVR32:
6779 case SystemZ::SelectVR64:
6780 case SystemZ::SelectVR128:
6812 for (
auto MI : Selects) {
6813 Register DestReg =
MI->getOperand(0).getReg();
6814 Register TrueReg =
MI->getOperand(1).getReg();
6815 Register FalseReg =
MI->getOperand(2).getReg();
6820 if (
MI->getOperand(4).getImm() == (CCValid ^ CCMask))
6823 if (RegRewriteTable.
find(TrueReg) != RegRewriteTable.
end())
6824 TrueReg = RegRewriteTable[TrueReg].
first;
6826 if (RegRewriteTable.
find(FalseReg) != RegRewriteTable.
end())
6827 FalseReg = RegRewriteTable[FalseReg].
second;
6830 BuildMI(*SinkMBB, SinkInsertionPoint, DL, TII->
get(SystemZ::PHI), DestReg)
6831 .addReg(TrueReg).
addMBB(TrueMBB)
6835 RegRewriteTable[DestReg] = std::make_pair(TrueReg, FalseReg);
6861 NextMIIt != MBB->
end(); ++NextMIIt) {
6863 assert(NextMIIt->getOperand(3).getImm() == CCValid &&
6864 "Bad CCValid operands since CC was not redefined.");
6865 if (NextMIIt->getOperand(4).getImm() == CCMask ||
6866 NextMIIt->getOperand(4).getImm() == (CCValid ^ CCMask)) {
6872 if (NextMIIt->definesRegister(SystemZ::CC) ||
6873 NextMIIt->usesCustomInsertionHook())
6876 for (
auto SelMI : Selects)
6877 if (NextMIIt->readsVirtualRegister(SelMI->getOperand(0).getReg())) {
6881 if (NextMIIt->isDebugInstr()) {
6883 assert(NextMIIt->isDebugValue() &&
"Unhandled debug opcode.");
6887 else if (User || ++Count > 20)
6924 for (
auto SelMI : Selects)
6925 SelMI->eraseFromParent();
6928 for (
auto DbgMI : DbgValues)
6929 MBB->
splice(InsertPos, StartMBB, DbgMI);
6940 unsigned StoreOpcode,
6941 unsigned STOCOpcode,
6942 bool Invert)
const {
6959 if (STOCOpcode && !IndexReg && Subtarget.hasLoadStoreOnCond()) {
6972 BuildMI(*MBB, MI, DL, TII->get(STOCOpcode))
7003 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
7012 BuildMI(MBB, DL, TII->get(StoreOpcode))
7032 unsigned BitSize,
bool Invert)
const {
7037 bool IsSubWord = (BitSize < 32);
7053 &SystemZ::GR32BitRegClass :
7054 &SystemZ::GR64BitRegClass);
7055 unsigned LOpcode = BitSize <= 32 ? SystemZ::L : SystemZ::LG;
7056 unsigned CSOpcode = BitSize <= 32 ? SystemZ::CS : SystemZ::CSG;
7061 assert(LOpcode && CSOpcode &&
"Displacement out of range");
7066 Register NewVal = (BinOpcode || IsSubWord ?
7081 BuildMI(MBB, DL, TII->get(LOpcode), OrigVal).
add(Base).addImm(Disp).addReg(0);
7093 BuildMI(MBB, DL, TII->get(SystemZ::PHI), OldVal)
7094 .addReg(OrigVal).
addMBB(StartMBB)
7097 BuildMI(MBB, DL, TII->get(SystemZ::RLL), RotatedOldVal)
7102 BuildMI(MBB, DL, TII->get(BinOpcode), Tmp).addReg(RotatedOldVal).
add(Src2);
7105 BuildMI(MBB, DL, TII->get(SystemZ::XILF), RotatedNewVal)
7106 .addReg(Tmp).
addImm(-1U << (32 - BitSize));
7111 BuildMI(MBB, DL, TII->get(SystemZ::LCGR), Tmp2).addReg(Tmp);
7112 BuildMI(MBB, DL, TII->get(SystemZ::AGHI), RotatedNewVal)
7113 .addReg(Tmp2).
addImm(-1);
7115 }
else if (BinOpcode)
7117 BuildMI(MBB, DL, TII->get(BinOpcode), RotatedNewVal)
7118 .addReg(RotatedOldVal)
7123 BuildMI(MBB, DL, TII->get(SystemZ::RISBG32), RotatedNewVal)
7127 BuildMI(MBB, DL, TII->get(SystemZ::RLL), NewVal)
7129 BuildMI(MBB, DL, TII->get(CSOpcode), Dest)
7134 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
7151 unsigned KeepOldMask,
unsigned BitSize)
const {
7156 bool IsSubWord = (BitSize < 32);
7171 &SystemZ::GR32BitRegClass :
7172 &SystemZ::GR64BitRegClass);
7173 unsigned LOpcode = BitSize <= 32 ? SystemZ::L : SystemZ::LG;
7174 unsigned CSOpcode = BitSize <= 32 ? SystemZ::CS : SystemZ::CSG;
7179 assert(LOpcode && CSOpcode &&
"Displacement out of range");
7201 BuildMI(MBB, DL, TII->get(LOpcode), OrigVal).
add(Base).addImm(Disp).addReg(0);
7210 BuildMI(MBB, DL, TII->get(SystemZ::PHI), OldVal)
7211 .addReg(OrigVal).
addMBB(StartMBB)
7214 BuildMI(MBB, DL, TII->get(SystemZ::RLL), RotatedOldVal)
7216 BuildMI(MBB, DL, TII->get(CompareOpcode))
7217 .addReg(RotatedOldVal).
addReg(Src2);
7218 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
7228 BuildMI(MBB, DL, TII->get(SystemZ::RISBG32), RotatedAltVal)
7229 .addReg(RotatedOldVal).
addReg(Src2)
7241 BuildMI(MBB, DL, TII->get(SystemZ::PHI), RotatedNewVal)
7242 .addReg(RotatedOldVal).
addMBB(LoopMBB)
7245 BuildMI(MBB, DL, TII->get(SystemZ::RLL), NewVal)
7247 BuildMI(MBB, DL, TII->get(CSOpcode), Dest)
7252 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
7264 SystemZTargetLowering::emitAtomicCmpSwapW(
MachineInstr &MI,
7288 assert(LOpcode && CSOpcode &&
"Displacement out of range");
7311 BuildMI(MBB, DL, TII->get(LOpcode), OrigOldVal)
7332 BuildMI(MBB, DL, TII->get(SystemZ::PHI), OldVal)
7333 .addReg(OrigOldVal).
addMBB(StartMBB)
7335 BuildMI(MBB, DL, TII->get(SystemZ::PHI), CmpVal)
7336 .addReg(OrigCmpVal).
addMBB(StartMBB)
7338 BuildMI(MBB, DL, TII->get(SystemZ::PHI), SwapVal)
7339 .addReg(OrigSwapVal).
addMBB(StartMBB)
7341 BuildMI(MBB, DL, TII->get(SystemZ::RLL), Dest)
7343 BuildMI(MBB, DL, TII->get(SystemZ::RISBG32), RetryCmpVal)
7345 BuildMI(MBB, DL, TII->get(SystemZ::CR))
7346 .addReg(Dest).
addReg(RetryCmpVal);
7347 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
7363 BuildMI(MBB, DL, TII->get(SystemZ::RISBG32), RetrySwapVal)
7365 BuildMI(MBB, DL, TII->get(SystemZ::RLL), StoreVal)
7366 .addReg(RetrySwapVal).
addReg(NegBitShift).
addImm(-BitSize);
7367 BuildMI(MBB, DL, TII->get(CSOpcode), RetryOldVal)
7372 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
7403 BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::IMPLICIT_DEF), Tmp1);
7404 BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::INSERT_SUBREG), Tmp2)
7406 BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::INSERT_SUBREG), Dest)
7418 bool ClearEven)
const {
7429 BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::IMPLICIT_DEF), In128);
7434 BuildMI(*MBB, MI, DL, TII->get(SystemZ::LLILL), Zero64)
7436 BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::INSERT_SUBREG), NewIn128)
7437 .addReg(In128).
addReg(Zero64).
addImm(SystemZ::subreg_h64);
7440 BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::INSERT_SUBREG), Dest)
7441 .addReg(In128).
addReg(Src).
addImm(SystemZ::subreg_l64);
7472 Register StartDestReg = (HaveSingleBase ? StartSrcReg :
7477 Register ThisDestReg = (HaveSingleBase ? ThisSrcReg :
7480 Register NextDestReg = (HaveSingleBase ? NextSrcReg :
7483 RC = &SystemZ::GR64BitRegClass;
7510 BuildMI(MBB, DL, TII->get(SystemZ::PHI), ThisDestReg)
7511 .addReg(StartDestReg).
addMBB(StartMBB)
7513 if (!HaveSingleBase)
7514 BuildMI(MBB, DL, TII->get(SystemZ::PHI), ThisSrcReg)
7515 .addReg(StartSrcReg).
addMBB(StartMBB)
7517 BuildMI(MBB, DL, TII->get(SystemZ::PHI), ThisCountReg)
7518 .addReg(StartCountReg).
addMBB(StartMBB)
7521 BuildMI(MBB, DL, TII->get(SystemZ::PFD))
7524 BuildMI(MBB, DL, TII->get(Opcode))
7528 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
7546 BuildMI(MBB, DL, TII->get(SystemZ::LA), NextDestReg)
7548 if (!HaveSingleBase)
7549 BuildMI(MBB, DL, TII->get(SystemZ::LA), NextSrcReg)
7551 BuildMI(MBB, DL, TII->get(SystemZ::AGHI), NextCountReg)
7552 .addReg(ThisCountReg).
addImm(-1);
7553 BuildMI(MBB, DL, TII->get(SystemZ::CGHI))
7554 .addReg(NextCountReg).
addImm(0);
7555 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
7564 if (EndMBB && !Length)
7571 while (Length > 0) {
7572 uint64_t ThisLength = std::min(Length, uint64_t(256));
7575 if (!isUInt<12>(DestDisp)) {
7584 if (!isUInt<12>(SrcDisp)) {
7593 BuildMI(*MBB, MI, DL, TII->get(Opcode))
7600 DestDisp += ThisLength;
7601 SrcDisp += ThisLength;
7602 Length -= ThisLength;
7605 if (EndMBB && Length > 0) {
7607 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
7664 BuildMI(MBB, DL, TII->get(SystemZ::PHI), This1Reg)
7665 .addReg(Start1Reg).
addMBB(StartMBB)
7667 BuildMI(MBB, DL, TII->get(SystemZ::PHI), This2Reg)
7668 .addReg(Start2Reg).
addMBB(StartMBB)
7670 BuildMI(MBB, DL, TII->get(TargetOpcode::COPY), SystemZ::R0L).addReg(CharReg);
7671 BuildMI(MBB, DL, TII->get(Opcode))
7674 BuildMI(MBB, DL, TII->get(SystemZ::BRC))
7688 bool NoFloat)
const {
7699 static const unsigned GPRControlBit[16] = {
7700 0x8000, 0x8000, 0x4000, 0x4000, 0x2000, 0x2000, 0x1000, 0x1000,
7701 0x0800, 0x0800, 0x0400, 0x0400, 0x0200, 0x0200, 0x0100, 0x0100
7703 Control |= GPRControlBit[15];
7705 Control |= GPRControlBit[11];
7709 for (
int I = 0; I < 16; I++) {
7710 if ((Control & GPRControlBit[I]) == 0) {
7717 if (!NoFloat && (Control & 4) != 0) {
7718 if (Subtarget.hasVector()) {
7719 for (
int I = 0; I < 32; I++) {
7724 for (
int I = 0; I < 16; I++) {
7750 BuildMI(*MBB, MI, DL, TII->get(Opcode), DstReg)
7761 case SystemZ::Select32:
7762 case SystemZ::Select64:
7763 case SystemZ::SelectF32:
7764 case SystemZ::SelectF64:
7765 case SystemZ::SelectF128:
7766 case SystemZ::SelectVR32:
7767 case SystemZ::SelectVR64:
7768 case SystemZ::SelectVR128:
7769 return emitSelect(MI, MBB);
7771 case SystemZ::CondStore8Mux:
7772 return emitCondStore(MI, MBB, SystemZ::STCMux, 0,
false);
7773 case SystemZ::CondStore8MuxInv:
7774 return emitCondStore(MI, MBB, SystemZ::STCMux, 0,
true);
7775 case SystemZ::CondStore16Mux:
7776 return emitCondStore(MI, MBB, SystemZ::STHMux, 0,
false);
7777 case SystemZ::CondStore16MuxInv:
7778 return emitCondStore(MI, MBB, SystemZ::STHMux, 0,
true);
7779 case SystemZ::CondStore32Mux:
7780 return emitCondStore(MI, MBB, SystemZ::STMux, SystemZ::STOCMux,
false);
7781 case SystemZ::CondStore32MuxInv:
7782 return emitCondStore(MI, MBB, SystemZ::STMux, SystemZ::STOCMux,
true);
7783 case SystemZ::CondStore8:
7784 return emitCondStore(MI, MBB, SystemZ::STC, 0,
false);
7785 case SystemZ::CondStore8Inv:
7786 return emitCondStore(MI, MBB, SystemZ::STC, 0,
true);
7787 case SystemZ::CondStore16:
7788 return emitCondStore(MI, MBB, SystemZ::STH, 0,
false);
7789 case SystemZ::CondStore16Inv:
7790 return emitCondStore(MI, MBB, SystemZ::STH, 0,
true);
7791 case SystemZ::CondStore32:
7792 return emitCondStore(MI, MBB,
SystemZ::ST, SystemZ::STOC,
false);
7793 case SystemZ::CondStore32Inv:
7794 return emitCondStore(MI, MBB,
SystemZ::ST, SystemZ::STOC,
true);
7795 case SystemZ::CondStore64:
7796 return emitCondStore(MI, MBB,
SystemZ::STG, SystemZ::STOCG,
false);
7797 case SystemZ::CondStore64Inv:
7798 return emitCondStore(MI, MBB,
SystemZ::STG, SystemZ::STOCG,
true);
7799 case SystemZ::CondStoreF32:
7800 return emitCondStore(MI, MBB, SystemZ::STE, 0,
false);
7801 case SystemZ::CondStoreF32Inv:
7802 return emitCondStore(MI, MBB, SystemZ::STE, 0,
true);
7803 case SystemZ::CondStoreF64:
7804 return emitCondStore(MI, MBB, SystemZ::STD, 0,
false);
7805 case SystemZ::CondStoreF64Inv:
7806 return emitCondStore(MI, MBB, SystemZ::STD, 0,
true);
7808 case SystemZ::PAIR128:
7809 return emitPair128(MI, MBB);
7810 case SystemZ::AEXT128:
7811 return emitExt128(MI, MBB,
false);
7812 case SystemZ::ZEXT128:
7813 return emitExt128(MI, MBB,
true);
7816 return emitAtomicLoadBinary(MI, MBB, 0, 0);
7817 case SystemZ::ATOMIC_SWAP_32:
7818 return emitAtomicLoadBinary(MI, MBB, 0, 32);
7819 case SystemZ::ATOMIC_SWAP_64:
7820 return emitAtomicLoadBinary(MI, MBB, 0, 64);
7822 case SystemZ::ATOMIC_LOADW_AR:
7823 return emitAtomicLoadBinary(MI, MBB, SystemZ::AR, 0);
7824 case SystemZ::ATOMIC_LOADW_AFI:
7825 return emitAtomicLoadBinary(MI, MBB, SystemZ::AFI, 0);
7826 case SystemZ::ATOMIC_LOAD_AR:
7827 return emitAtomicLoadBinary(MI, MBB, SystemZ::AR, 32);
7828 case SystemZ::ATOMIC_LOAD_AHI:
7829 return emitAtomicLoadBinary(MI, MBB, SystemZ::AHI, 32);
7830 case SystemZ::ATOMIC_LOAD_AFI:
7831 return emitAtomicLoadBinary(MI, MBB, SystemZ::AFI, 32);
7832 case SystemZ::ATOMIC_LOAD_AGR:
7833 return emitAtomicLoadBinary(MI, MBB, SystemZ::AGR, 64);
7834 case SystemZ::ATOMIC_LOAD_AGHI:
7835 return emitAtomicLoadBinary(MI, MBB, SystemZ::AGHI, 64);
7836 case SystemZ::ATOMIC_LOAD_AGFI:
7837 return emitAtomicLoadBinary(MI, MBB, SystemZ::AGFI, 64);
7839 case SystemZ::ATOMIC_LOADW_SR:
7840 return emitAtomicLoadBinary(MI, MBB, SystemZ::SR, 0);
7841 case SystemZ::ATOMIC_LOAD_SR:
7842 return emitAtomicLoadBinary(MI, MBB, SystemZ::SR, 32);
7843 case SystemZ::ATOMIC_LOAD_SGR:
7844 return emitAtomicLoadBinary(MI, MBB, SystemZ::SGR, 64);
7846 case SystemZ::ATOMIC_LOADW_NR:
7847 return emitAtomicLoadBinary(MI, MBB, SystemZ::NR, 0);
7848 case SystemZ::ATOMIC_LOADW_NILH:
7849 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILH, 0);
7850 case SystemZ::ATOMIC_LOAD_NR:
7851 return emitAtomicLoadBinary(MI, MBB, SystemZ::NR, 32);
7852 case SystemZ::ATOMIC_LOAD_NILL:
7853 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILL, 32);
7854 case SystemZ::ATOMIC_LOAD_NILH:
7855 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILH, 32);
7856 case SystemZ::ATOMIC_LOAD_NILF:
7857 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILF, 32);
7858 case SystemZ::ATOMIC_LOAD_NGR:
7859 return emitAtomicLoadBinary(MI, MBB, SystemZ::NGR, 64);
7860 case SystemZ::ATOMIC_LOAD_NILL64:
7861 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILL64, 64);
7862 case SystemZ::ATOMIC_LOAD_NILH64:
7863 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILH64, 64);
7864 case SystemZ::ATOMIC_LOAD_NIHL64:
7865 return emitAtomicLoadBinary(MI, MBB, SystemZ::NIHL64, 64);
7866 case SystemZ::ATOMIC_LOAD_NIHH64:
7867 return emitAtomicLoadBinary(MI, MBB, SystemZ::NIHH64, 64);
7868 case SystemZ::ATOMIC_LOAD_NILF64:
7869 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILF64, 64);
7870 case SystemZ::ATOMIC_LOAD_NIHF64:
7871 return emitAtomicLoadBinary(MI, MBB, SystemZ::NIHF64, 64);
7874 return emitAtomicLoadBinary(MI, MBB,
SystemZ::OR, 0);
7875 case SystemZ::ATOMIC_LOADW_OILH:
7876 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILH, 0);
7878 return emitAtomicLoadBinary(MI, MBB,
SystemZ::OR, 32);
7879 case SystemZ::ATOMIC_LOAD_OILL:
7880 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILL, 32);
7881 case SystemZ::ATOMIC_LOAD_OILH:
7882 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILH, 32);
7883 case SystemZ::ATOMIC_LOAD_OILF:
7884 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILF, 32);
7885 case SystemZ::ATOMIC_LOAD_OGR:
7886 return emitAtomicLoadBinary(MI, MBB, SystemZ::OGR, 64);
7887 case SystemZ::ATOMIC_LOAD_OILL64:
7888 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILL64, 64);
7889 case SystemZ::ATOMIC_LOAD_OILH64:
7890 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILH64, 64);
7891 case SystemZ::ATOMIC_LOAD_OIHL64:
7892 return emitAtomicLoadBinary(MI, MBB, SystemZ::OIHL64, 64);
7893 case SystemZ::ATOMIC_LOAD_OIHH64:
7894 return emitAtomicLoadBinary(MI, MBB, SystemZ::OIHH64, 64);
7895 case SystemZ::ATOMIC_LOAD_OILF64:
7896 return emitAtomicLoadBinary(MI, MBB, SystemZ::OILF64, 64);
7897 case SystemZ::ATOMIC_LOAD_OIHF64:
7898 return emitAtomicLoadBinary(MI, MBB, SystemZ::OIHF64, 64);
7900 case SystemZ::ATOMIC_LOADW_XR:
7901 return emitAtomicLoadBinary(MI, MBB, SystemZ::XR, 0);
7902 case SystemZ::ATOMIC_LOADW_XILF:
7903 return emitAtomicLoadBinary(MI, MBB, SystemZ::XILF, 0);
7904 case SystemZ::ATOMIC_LOAD_XR:
7905 return emitAtomicLoadBinary(MI, MBB, SystemZ::XR, 32);
7906 case SystemZ::ATOMIC_LOAD_XILF:
7907 return emitAtomicLoadBinary(MI, MBB, SystemZ::XILF, 32);
7908 case SystemZ::ATOMIC_LOAD_XGR:
7909 return emitAtomicLoadBinary(MI, MBB, SystemZ::XGR, 64);
7910 case SystemZ::ATOMIC_LOAD_XILF64:
7911 return emitAtomicLoadBinary(MI, MBB, SystemZ::XILF64, 64);
7912 case SystemZ::ATOMIC_LOAD_XIHF64:
7913 return emitAtomicLoadBinary(MI, MBB, SystemZ::XIHF64, 64);
7915 case SystemZ::ATOMIC_LOADW_NRi:
7916 return emitAtomicLoadBinary(MI, MBB, SystemZ::NR, 0,
true);
7917 case SystemZ::ATOMIC_LOADW_NILHi:
7918 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILH, 0,
true);
7919 case SystemZ::ATOMIC_LOAD_NRi:
7920 return emitAtomicLoadBinary(MI, MBB, SystemZ::NR, 32,
true);
7921 case SystemZ::ATOMIC_LOAD_NILLi:
7922 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILL, 32,
true);
7923 case SystemZ::ATOMIC_LOAD_NILHi:
7924 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILH, 32,
true);
7925 case SystemZ::ATOMIC_LOAD_NILFi:
7926 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILF, 32,
true);
7927 case SystemZ::ATOMIC_LOAD_NGRi:
7928 return emitAtomicLoadBinary(MI, MBB, SystemZ::NGR, 64,
true);
7929 case SystemZ::ATOMIC_LOAD_NILL64i:
7930 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILL64, 64,
true);
7931 case SystemZ::ATOMIC_LOAD_NILH64i:
7932 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILH64, 64,
true);
7933 case SystemZ::ATOMIC_LOAD_NIHL64i:
7934 return emitAtomicLoadBinary(MI, MBB, SystemZ::NIHL64, 64,
true);
7935 case SystemZ::ATOMIC_LOAD_NIHH64i:
7936 return emitAtomicLoadBinary(MI, MBB, SystemZ::NIHH64, 64,
true);
7937 case SystemZ::ATOMIC_LOAD_NILF64i:
7938 return emitAtomicLoadBinary(MI, MBB, SystemZ::NILF64, 64,
true);
7939 case SystemZ::ATOMIC_LOAD_NIHF64i:
7940 return emitAtomicLoadBinary(MI, MBB, SystemZ::NIHF64, 64,
true);
7943 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CR,
7945 case SystemZ::ATOMIC_LOAD_MIN_32:
7946 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CR,
7948 case SystemZ::ATOMIC_LOAD_MIN_64:
7949 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CGR,
7953 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CR,
7955 case SystemZ::ATOMIC_LOAD_MAX_32:
7956 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CR,
7958 case SystemZ::ATOMIC_LOAD_MAX_64:
7959 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CGR,
7963 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CLR,
7965 case SystemZ::ATOMIC_LOAD_UMIN_32:
7966 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CLR,
7968 case SystemZ::ATOMIC_LOAD_UMIN_64:
7969 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CLGR,
7973 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CLR,
7975 case SystemZ::ATOMIC_LOAD_UMAX_32:
7976 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CLR,
7978 case SystemZ::ATOMIC_LOAD_UMAX_64:
7979 return emitAtomicLoadMinMax(MI, MBB, SystemZ::CLGR,
7983 return emitAtomicCmpSwapW(MI, MBB);
7984 case SystemZ::MVCSequence:
7985 case SystemZ::MVCLoop:
7987 case SystemZ::NCSequence:
7988 case SystemZ::NCLoop:
7990 case SystemZ::OCSequence:
7991 case SystemZ::OCLoop:
7993 case SystemZ::XCSequence:
7994 case SystemZ::XCLoop:
7996 case SystemZ::CLCSequence:
7997 case SystemZ::CLCLoop:
7999 case SystemZ::CLSTLoop:
8000 return emitStringWrapper(MI, MBB, SystemZ::CLST);
8001 case SystemZ::MVSTLoop:
8002 return emitStringWrapper(MI, MBB, SystemZ::MVST);
8003 case SystemZ::SRSTLoop:
8004 return emitStringWrapper(MI, MBB, SystemZ::SRST);
8007 case SystemZ::TBEGIN_nofloat:
8009 case SystemZ::TBEGINC:
8010 return emitTransactionBegin(MI, MBB, SystemZ::TBEGINC,
true);
8011 case SystemZ::LTEBRCompare_VecPseudo:
8012 return emitLoadAndTestCmp0(MI, MBB, SystemZ::LTEBR);
8013 case SystemZ::LTDBRCompare_VecPseudo:
8014 return emitLoadAndTestCmp0(MI, MBB, SystemZ::LTDBR);
8015 case SystemZ::LTXBRCompare_VecPseudo:
8016 return emitLoadAndTestCmp0(MI, MBB, SystemZ::LTXBR);
8018 case TargetOpcode::STACKMAP:
8019 case TargetOpcode::PATCHPOINT:
8030 SystemZTargetLowering::getRepRegClassFor(
MVT VT)
const {
8032 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)
bool isMachineConstantPoolEntry() const
static unsigned computeNumSignBitsBinOp(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth, unsigned OpNo)
static unsigned CCMaskForCondCode(ISD::CondCode CC)
void setFrameAddressIsTaken(bool T)
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 const fltSemantics & IEEEquad() LLVM_READNONE
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...
const MachineInstrBuilder & add(const MachineOperand &MO) const
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
BUILTIN_OP_END - This must be the last enum value in this list.
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
EVT getValueType() const
Return the ValueType of the referenced return value.
static bool getShuffleInput(const SmallVectorImpl< int > &Bytes, unsigned Start, unsigned BytesPerElement, int &Base)
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...
static SDValue expandV4F32ToV2F64(SelectionDAG &DAG, int Start, const SDLoc &DL, SDValue Op, SDValue Chain)
void setFlags(SDNodeFlags NewFlags)
const unsigned CCMASK_ARITH
Constrained versions of libm-equivalent floating point intrinsics.
T findLastSet(T Val, ZeroBehavior ZB=ZB_Max)
Get the index of the last set bit starting from the least significant bit.
const GlobalValue * getGlobal() const
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant, which is required to be operand #1) half of the integer or float value specified as operand #0.
uint64_t getZExtValue() const
Get zero extended value.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
const unsigned GR32Regs[16]
static bool isIntrinsicWithCCAndChain(SDValue Op, unsigned &Opcode, unsigned &CCValid)
SDValue UnrollVectorOp(SDNode *N, unsigned ResNE=0)
Utility function used by legalize and lowering to "unroll" a vector operation by splitting out the sc...
const int64_t CallFrameSize
SDValue CombineTo(SDNode *N, ArrayRef< SDValue > To, bool AddTo=true)
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.
bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef, unsigned &SplatBitSize, bool &HasAnyUndefs, unsigned MinSplatBits=0, bool isBigEndian=false) const
Check if this is a constant splat, and if so, find the smallest element size that splats the vector...
static SDValue getAbsolute(SelectionDAG &DAG, const SDLoc &DL, SDValue Op, bool IsNegative)
CondCode getSetCCInverse(CondCode Operation, EVT Type)
Return the operation corresponding to !(X op Y), where 'op' is a valid SetCC operation.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
BR_CC - Conditional branch.
This class represents lattice values for constants.
static SDValue buildScalarToVector(SelectionDAG &DAG, const SDLoc &DL, EVT VT, SDValue Value)
MachineFunctionProperties & reset(Property P)
static const Permute PermuteForms[]
Register getLocReg() const
void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
const MCPhysReg ArgFPRs[NumArgFPRs]
static MVT getVectorVT(MVT VT, unsigned NumElements)
FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0 as less than 0...
const unsigned CCMASK_FCMP
const unsigned FP128Regs[16]
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
unsigned odd128(bool Is32bit)
virtual const TargetRegisterClass * getRepRegClassFor(MVT VT) const
Return the 'representative' register class for the specified value type.
static bool checkCCKill(MachineInstr &MI, MachineBasicBlock *MBB)
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...
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS, Instruction *I=nullptr) const override
Return true if the addressing mode represented by AM is legal for this target, for a load/store of th...
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
static void adjustForRedundantAnd(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
bool isVector() const
Return true if this is a vector value type.
void addLiveIn(unsigned Reg, unsigned vreg=0)
addLiveIn - Add the specified register as a live-in.
const SDValue & getBasePtr() const
static bool isImmHH(uint64_t Val)
static SDValue tryBuildVectorShuffle(SelectionDAG &DAG, BuildVectorSDNode *BVN)
const MachineFunctionProperties & getProperties() const
Get the function properties.
unsigned ComputeNumSignBitsForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth) const override
Determine the number of bits in the operation that are sign bits.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
void push_back(const T &Elt)
virtual void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
Lower the specified operand into the Ops vector.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
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...
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain...
SDVTList getVTList() const
This class represents a function call, abstracting a target machine's calling convention.
unsigned getRegSaveFrameIndex() const
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static void adjustZeroCmp(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
const SDValue & getChain() const
Function Alias Analysis Results
static unsigned getVectorComparisonOrInvert(ISD::CondCode CC, CmpMode Mode, bool &Invert)
static Comparison getIntrinsicCmp(SelectionDAG &DAG, unsigned Opcode, SDValue Call, unsigned CCValid, uint64_t CC, ISD::CondCode Cond)
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
static std::pair< unsigned, const TargetRegisterClass * > parseRegisterNumber(StringRef Constraint, const TargetRegisterClass *RC, const unsigned *Map, unsigned Size)
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
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.
C - The default llvm calling convention, compatible with C.
APInt trunc(unsigned width) const
Truncate to new width.
Constrained versions of the binary floating point operators.
constexpr bool isInt< 16 >(int64_t x)
bool isLegalAddImmediate(int64_t Imm) const override
Return true if the specified immediate is legal add immediate, that is the target has add instruction...
unsigned const TargetRegisterInfo * TRI
MVT getSimpleValueType(unsigned ResNo) const
Return the type of a specified result as a simple type.
bool isInteger() const
Return true if this is an integer or a vector integer type.
static SDValue joinDwords(SelectionDAG &DAG, const SDLoc &DL, SDValue Op0, SDValue Op1)
TypeSize getScalarValueSizeInBits() const
const fltSemantics & getSemantics() const
const unsigned FP32Regs[16]
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
const SDNodeFlags getFlags() const
SDNode * getNode() const
get the SDNode which holds the desired result
void setBitsFrom(unsigned loBit)
Set the top bits starting from loBit.
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
bool isVectorTy() const
True if this is an instance of VectorType.
static void createPHIsForSelects(SmallVector< MachineInstr *, 8 > &Selects, MachineBasicBlock *TrueMBB, MachineBasicBlock *FalseMBB, MachineBasicBlock *SinkMBB)
SDValue getConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offs=0, bool isT=false, unsigned TargetFlags=0)
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...
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
static bool chooseShuffleOpNos(int *OpNos, unsigned &OpNo0, unsigned &OpNo1)
const unsigned CCMASK_CS_EQ
const unsigned CCMASK_LOGICAL_CARRY
unsigned getBitWidth() const
Get the bit width of this value.
virtual SDValue LowerToTLSEmulatedModel(const GlobalAddressSDNode *GA, SelectionDAG &DAG) const
Lower TLS global address SDNode for target independent emulated TLS model.
static bool shouldSwapCmpOperands(const Comparison &C)
const unsigned CCMASK_ICMP
OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope) This corresponds to the fence instruction.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
TargetLowering::ConstraintType getConstraintType(StringRef Constraint) const override
Given a constraint, return the type of constraint it is for this target.
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...
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node.
unsigned getBitWidth() const
Return the number of bits in the APInt.
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
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.
const unsigned VR64Regs[32]
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
unsigned 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 isFloatingPoint() const
Return true if this is a FP or a vector FP type.
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations...
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
The address of a basic block.
bool hasOneUse() const
Return true if there is exactly one use of this node.
A description of a memory reference used in the backend.
static bool matchDoublePermute(const SmallVectorImpl< int > &Bytes, const Permute &P, SmallVectorImpl< int > &Transform)
void setBit(unsigned BitPosition)
Set a given bit to 1.
static MachineBasicBlock * splitBlockAfter(MachineBasicBlock::iterator MI, MachineBasicBlock *MBB)
const HexagonInstrInfo * TII
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
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
APInt zextOrSelf(unsigned width) const
Zero extend or truncate to width.
bool isBuildVectorAllZeros(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR where all of the elements are 0 or undef...
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.
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
SystemZVectorConstantInfo(APFloat FPImm)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
bool isIntegerTy() const
True if this is an instance of IntegerType.
uint64_t getConstantOperandVal(unsigned i) const
static Register forceReg(MachineInstr &MI, MachineOperand &Base, const SystemZInstrInfo *TII)
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags=0)
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.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
LLVM_NODISCARD StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
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...
TypeSize getValueSizeInBits() const
Returns the size of the value in bits.
const DataLayout & getDataLayout() const
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG...
static void lowerMUL_LOHI32(SelectionDAG &DAG, const SDLoc &DL, unsigned Extend, SDValue Op0, SDValue Op1, SDValue &Hi, SDValue &Lo)
const BlockAddress * getBlockAddress() const
LocInfo getLocInfo() const
void lshrInPlace(unsigned ShiftAmt)
Logical right-shift this APInt by ShiftAmt in place.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
static mvt_range integer_fixedlen_vector_valuetypes()
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())
KnownBits zextOrTrunc(unsigned BitWidth, bool ExtendedBitsAreKnownZero) const
Extends or truncates the underlying known Zero and One bits.
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.
static bool isScalarToVector(SDValue Op)
unsigned getActiveBits() const
Compute the number of active bits in the value.
bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF, EVT VT) const override
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
static bool isAddCarryChain(SDValue Carry)
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only...
Type * getType() const
All values are typed, get the type of this value.
MachineFunction & getMachineFunction() 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...
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.
const TargetMachine & getTarget() const
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
static SDNode * emitIntrinsicWithCC(SelectionDAG &DAG, SDValue Op, unsigned Opcode)
void setMinFunctionAlignment(Align Alignment)
Set the target's minimum function alignment.
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.
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
const unsigned CCMASK_TBEGIN
SmallVector< ISD::OutputArg, 32 > Outs
static SDValue MergeInputChains(SDNode *N1, SDNode *N2)
static AddressingMode getLoadStoreAddrMode(bool HasVector, Type *Ty)
const unsigned NumArgFPRs
static bool matchPermute(const SmallVectorImpl< int > &Bytes, const Permute &P, unsigned &OpNo0, unsigned &OpNo1)
LLVM_NODISCARD size_t size() const
size - Get the string size.
void incNumLocalDynamicTLSAccesses()
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
TLSModel::Model getTLSModel(const GlobalValue *GV) const
Returns the TLS model which should be used for the given global variable.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
const unsigned CCMASK_ANY
X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
virtual const TargetInstrInfo * getInstrInfo() const
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.
ArrayRef< SDUse > ops() const
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op)
Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all elements. ...
const unsigned CCMASK_CS_NE
const unsigned CCMASK_TM_SOME_0
bool hasMiscellaneousExtensions3() const
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.
SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Val, MachineMemOperand *MMO)
Gets a node for an atomic op, produces result (if relevant) and chain and takes 2 operands...
Value * getOperand(unsigned i) const
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
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.
UNDEF - An undefined node.
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
void setPrefFunctionAlignment(Align Alignment)
Set the target's preferred function alignment.
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the specified, possibly variable...
TargetInstrInfo - Interface to description of machine instruction set.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
iterator find(const_arg_type_t< KeyT > Val)
bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
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...
SystemZTargetLowering(const TargetMachine &TM, const SystemZSubtarget &STI)
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
The memory access is volatile.
const unsigned CCMASK_LOGICAL
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
const unsigned CCMASK_LOGICAL_BORROW
static Comparison getCmp(SelectionDAG &DAG, SDValue CmpOp0, SDValue CmpOp1, ISD::CondCode Cond, const SDLoc &DL, SDValue Chain=SDValue(), bool IsSignaling=false)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
void insertBits(const APInt &SubBits, unsigned bitPosition)
Insert the bits from a smaller APInt starting at bitPosition.
static void adjustForLTGFR(Comparison &C)
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...
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.
int64_t getOffset() const
constexpr bool isUInt< 8 >(uint64_t x)
unsigned const MachineRegisterInfo * MRI
bool SignBitIsZero(SDValue Op, unsigned Depth=0) const
Return true if the sign bit of Op is known to be zero.
use_iterator use_begin() const
Provide iteration support to walk over all uses of an SDNode.
ArrayRef< MachineMemOperand * > memoperands() const
Access to memory operands of the instruction.
const unsigned CCMASK_VCMP
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
bool killsRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr kills the specified register.
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...
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
Simple binary floating point operators.
KnownBits zext(unsigned BitWidth, bool ExtendedBitsAreKnownZero) const
Extends the underlying known Zero and One bits.
void setTargetDAGCombine(ISD::NodeType NT)
Targets should invoke this method for each target independent node that they want to provide a custom...
const MCPhysReg * getScratchRegisters(CallingConv::ID CC) const override
Returns a 0 terminated array of registers that can be safely used as scratch registers.
static bool isNaturalMemoryOperand(SDValue Op, unsigned ICmpType)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
void resetAll()
Resets the known state of all bits.
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE...
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
unsigned getOpcodeForOffset(unsigned Opcode, int64_t Offset) const
const SDValue & getOperand(unsigned Num) const
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
static SDValue lowerGR128ToI128(SelectionDAG &DAG, SDValue In)
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL...
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 void adjustICmpTruncate(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
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 ...
static bool getVPermMask(SDValue ShuffleOp, SmallVectorImpl< int > &Bytes)
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.
void AddToWorklist(SDNode *N)
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()
This class provides iterator support for SDUse operands that use a specific SDNode.
bool definesRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr fully defines the specified register.
virtual ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &info, const char *constraint) const
Examine constraint string and operand type and determine a weight value.
void setRegSaveFrameIndex(unsigned FI)
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setImm(int64_t immVal)
const unsigned CCMASK_TM_MSB_1
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
TRAP - Trapping instruction.
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...
bool hasNUsesOfValue(unsigned NUses, unsigned Value) const
Return true if there are exactly NUSES uses of the indicated value.
CondCode getSetCCSwappedOperands(CondCode Operation)
Return the operation corresponding to (Y op X) when given the operation for (X op Y)...
const unsigned CCMASK_TDC
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS, unsigned Align, MachineMemOperand::Flags Flags, bool *Fast) const override
Determine if the target supports unaligned memory accesses.
int getOrCreateFramePointerSaveIndex(MachineFunction &MF) const
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo...
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
bool hasVectorEnhancements2() const
static MachineOperand CreateReg(Register 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, bool isRenamable=false)
virtual 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...
succ_iterator succ_begin()
unsigned getAlignment() const
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)
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
unsigned 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...
This structure contains all information that is necessary for lowering calls.
static bool combineCCMask(SDValue &CCReg, int &CCValid, int &CCMask)
static bool isVectorElementSwap(ArrayRef< int > M, EVT VT)
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...
This class contains a discriminated union of information about pointers in memory operands...
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
bool hasVectorEnhancements1() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
AddressingMode(bool LongDispl, bool IdxReg)
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
This struct is a compact representation of a valid (non-zero power of two) alignment.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
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.
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned TargetFlags=0)
const SystemZInstrInfo * getInstrInfo() const override
Synchronized with respect to all concurrently executing threads.
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)
unsigned getPointerSize(unsigned AS) const
Get the pointer size for this target.
static bool isUndef(ArrayRef< int > Mask)
TokenFactor - This node takes multiple tokens as input and produces a single token result...
bool readsRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr reads the specified register.
const TargetLowering & getTargetLoweringInfo() const
SDValue getTargetConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offset=0, unsigned TargetFlags=0)
Iterator for intrusive lists based on ilist_node.
static APInt getDemandedSrcElements(SDValue Op, const APInt &DemandedElts, unsigned OpNo)
CCState - This class holds information needed while lowering arguments and return values...
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
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)
BlockVerifier::State From
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
unsigned getVarArgsFrameIndex() const
Align max(MaybeAlign Lhs, Align Rhs)
void setVarArgsFrameIndex(unsigned FI)
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
void ReplaceNodeResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
This callback is invoked when a node result type is illegal for the target, and the operation was reg...
unsigned getVarArgsFirstGPR() const
EVT getVectorElementType() const
Given a vector type, return the type of each element.
testing::Matcher< const detail::ErrorHolder & > Failed()
SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
static SDNode * emitIntrinsicWithCCAndChain(SelectionDAG &DAG, SDValue Op, unsigned Opcode)
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
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
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)
EVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
BRCOND - Conditional branch.
Information about stack frame layout on the target.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
static SDValue convertValVTToLocVT(SelectionDAG &DAG, const SDLoc &DL, CCValAssign &VA, SDValue Value)
Promote Memory to Register
Byte Swap and Counting operators.
const unsigned CCMASK_CMP_O
const unsigned GR128Regs[16]
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...
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
const Constant * getConstVal() const
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.
static SDValue lowerI128ToGR128(SelectionDAG &DAG, SDValue In)
const unsigned GR64Regs[16]
KnownBits sext(unsigned BitWidth) const
Sign extends the underlying known Zero and One bits.
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
static mvt_range integer_valuetypes()
const unsigned CCMASK_TM_MIXED_MSB_1
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
SDNode * isConstantIntBuildVectorOrConstantInt(SDValue N)
Test whether the given value is a constant int or similar node.
EVT getMemoryVT() const
Return the type of the in-memory value.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
Class for arbitrary precision integers.
CodeModel::Model getCodeModel() const
Returns the code model.
void LowerOperationWrapper(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
This callback is invoked by the type legalizer to legalize nodes with an illegal operand type but leg...
const unsigned VectorBytes
iterator_range< use_iterator > uses()
amdgpu Simplify well known AMD library false FunctionCallee Callee
A "pseudo-class" with methods for operating on BUILD_VECTORs.
Select(COND, TRUEVAL, FALSEVAL).
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 unsigned CCMASK_CMP_GE
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
static MachineOperand earlyUseOperand(MachineOperand Op)
static void adjustForTestUnderMask(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const override
Determine which of the bits specified in Mask are known to be either zero or one and return them in t...
static SDValue emitSETCC(SelectionDAG &DAG, const SDLoc &DL, SDValue CCReg, unsigned CCValid, unsigned CCMask)
Flags
Flags values. These may be or'd together.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
static bool isSubBorrowChain(SDValue Carry)
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.
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.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
SmallVector< SDValue, 32 > OutVals
static bool isAbsolute(SDValue CmpOp, SDValue Pos, SDValue Neg)
bool CheckReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
CheckReturn - Analyze the return values of a function, returning true if the return can be performed ...
bool isVector() const
Return true if this is a vector value type.
static MachineBasicBlock * emitBlockAfter(MachineBasicBlock *MBB)
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Bitwise operators - logical and, logical or, logical xor.
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.
unsigned getLocMemOffset() const
static void adjustForSubtraction(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
LLVM_NODISCARD bool empty() const
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
static bool is32Bit(EVT VT)
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
int64_t getOffset() 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...
unsigned MaxStoresPerMemcpyOptSize
Likewise for functions with the OptSize attribute.
void setStackPointerRegisterToSaveRestore(unsigned R)
If set to a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save and restore.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
const unsigned VR32Regs[32]
X = STRICT_FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision ...
static bool isSelectPseudo(MachineInstr &MI)
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
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)
unsigned getOpcode() const
FSINCOS - Compute both fsin and fcos as a single operation.
SDValue getValue(unsigned R) const
unsigned MaxStoresPerMemcpy
Specify maximum number 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.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
uint16_t getFlags() const
Return the MI flags bitvector.
static unsigned getTestUnderMaskCond(unsigned BitSize, unsigned CCMask, uint64_t Mask, uint64_t CmpVal, unsigned ICmpType)
SDValue getGLOBAL_OFFSET_TABLE(EVT VT)
Return a GLOBAL_OFFSET_TABLE node. This does not have a useful SDLoc.
SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, unsigned Align=0, MachineMemOperand::Flags Flags=MachineMemOperand::MOLoad|MachineMemOperand::MOStore, uint64_t Size=0, const AAMDNodes &AAInfo=AAMDNodes())
Creates a MemIntrinsicNode that may produce a result and takes a list of operands.
bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
MachineConstantPoolValue * getMachineCPVal() const
bool isVectorConstantLegal(const SystemZSubtarget &Subtarget)
bool registerDefIsDead(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Returns true if the register is dead in this machine instruction.
static SDValue emitCmp(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
user_iterator user_begin()
void insert(iterator MBBI, MachineBasicBlock *MBB)
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
bool hasFPExtension() const
void setReturnAddressIsTaken(bool s)
TypeSize getScalarSizeInBits() const
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.
ArrayRef< int > getMask() const
LLVM Value Representation.
FMA - Perform a * b + c with no intermediate rounding step.
SDValue getRegister(unsigned Reg, EVT VT)
unsigned getResNo() const
get the index which selects a specific result in the SDNode
Fast - This calling convention attempts to make calls as fast as possible (e.g.
unsigned even128(bool Is32bit)
static void lowerGR128Binary(SelectionDAG &DAG, const SDLoc &DL, EVT VT, unsigned Opcode, SDValue Op0, SDValue Op1, SDValue &Even, SDValue &Odd)
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
unsigned getStackPointerRegisterToSaveRestore() const
If a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save...
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)
static SDValue getCCResult(SelectionDAG &DAG, SDValue CCReg)
void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.getNode() alone...
const unsigned CCMASK_ARITH_OVERFLOW
static bool isImmLL(uint64_t Val)
Primary interface to the complete machine description for the target machine.
A SystemZ-specific constant pool value.
bool isRxSBGMask(uint64_t Mask, unsigned BitSize, unsigned &Start, unsigned &End) const
static mvt_range fixedlen_vector_valuetypes()
unsigned getVarArgsFirstFPR() const
bool hasOneUse() const
Return true if there is exactly one user of this value.
StringRef - Represent a constant reference to a string, i.e.
SetCC operator - This evaluates to a true value iff the condition is true.
APInt bitcastToAPInt() const
APInt getMaxValue() const
Return the maximal value possible given these KnownBits.
unsigned MaxStoresPerMemset
Specify maximum number of store instructions per memset call.
unsigned MaxStoresPerMemsetOptSize
Likewise for functions with the OptSize attribute.
KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
unsigned getNumOperands() const
Register getReg() const
getReg - Returns the register number.
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
const SDValue & getOperand(unsigned i) const
bool verifyReturnAddressArgumentIsConstant(SDValue Op, SelectionDAG &DAG) const
static void adjustForFNeg(Comparison &C)
OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val) This corresponds to "store atomic" instruction.
static void computeKnownBitsBinOp(const SDValue Op, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth, unsigned OpNo)
const unsigned CCMASK_TM_ALL_0
uint64_t getZExtValue() const
SDValue getTargetInsertSubreg(int SRIdx, const SDLoc &DL, EVT VT, SDValue Operand, SDValue Subreg)
A convenience function for creating TargetInstrInfo::INSERT_SUBREG nodes.
TRUNCATE - Completely drop the high bits.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
const unsigned CCMASK_TEND
const MachineOperand & getOperand(unsigned i) const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
static AddressingMode supportedAddressingMode(Instruction *I, bool HasVector)
Perform various unary floating-point operations inspired by libm.
bool hasPopulationCount() const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const unsigned VR128Regs[32]
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
const SystemZRegisterInfo * getRegisterInfo() const override
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
LLVMContext * getContext() const
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
const unsigned CCMASK_TM_SOME_1
bool isFPImmLegal(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns true if the target can instruction select the specified FP immediate natively.
Carry-using nodes for multiple precision addition and subtraction.
static unsigned getVectorComparison(ISD::CondCode CC, CmpMode Mode)
Wrapper class representing virtual and physical registers.
A wrapper class for inspecting calls to intrinsic functions.
const BasicBlock * getParent() const
static SystemZConstantPoolValue * Create(const GlobalValue *GV, SystemZCP::SystemZCPModifier Modifier)
const unsigned CCMASK_CMP_UO
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
MachineBasicBlock * emitPatchPoint(MachineInstr &MI, MachineBasicBlock *MBB) const
Replace/modify any TargetFrameIndex operands with a targte-dependent sequence of memory operands that...
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)