26#include "llvm/IR/IntrinsicsS390.h"
35#define DEBUG_TYPE "systemz-lower"
41 : Op0(Op0In), Op1(Op1In), Chain(ChainIn),
42 Opcode(0), ICmpType(0), CCValid(0), CCMask(0) {}
92 if (Subtarget.hasHighWord())
98 if (Subtarget.hasVector()) {
105 if (Subtarget.hasVectorEnhancements1())
110 if (Subtarget.hasVector()) {
119 if (Subtarget.hasVector())
146 for (
unsigned I = MVT::FIRST_INTEGER_VALUETYPE;
147 I <= MVT::LAST_FP_VALUETYPE;
173 for (
unsigned I = MVT::FIRST_INTEGER_VALUETYPE;
174 I <= MVT::LAST_INTEGER_VALUETYPE;
205 if (Subtarget.hasPopulationCount())
224 if (!Subtarget.hasFPExtension())
230 if (Subtarget.hasFPExtension())
235 if (Subtarget.hasFPExtension())
304 {MVT::i8, MVT::i16, MVT::i32},
Legal);
306 {MVT::i8, MVT::i16},
Legal);
323 if (!Subtarget.hasFPExtension()) {
336 if (Subtarget.hasMiscellaneousExtensions3()) {
429 if (VT != MVT::v2i64)
435 if (Subtarget.hasVectorEnhancements1())
466 if (Subtarget.hasVector()) {
488 if (Subtarget.hasVectorEnhancements2()) {
509 for (
unsigned I = MVT::FIRST_FP_VALUETYPE;
510 I <= MVT::LAST_FP_VALUETYPE;
518 if (Subtarget.hasFPExtension()) {
546 if (Subtarget.hasFPExtension()) {
557 if (Subtarget.hasVector()) {
603 if (Subtarget.hasVectorEnhancements1()) {
610 if (Subtarget.hasVectorEnhancements1()) {
664 for (
auto VT : { MVT::f32, MVT::f64, MVT::f128,
665 MVT::v4f32, MVT::v2f64 }) {
674 if (!Subtarget.hasVectorEnhancements1()) {
680 if (Subtarget.hasVectorEnhancements1())
690 if (Subtarget.hasVectorEnhancements1()) {
702 if (!Subtarget.hasVector()) {
757 struct RTLibCallMapping {
761 static RTLibCallMapping RTLibCallCommon[] = {
762#define HANDLE_LIBCALL(code, name) {RTLIB::code, name},
763#include "ZOSLibcallNames.def"
765 for (
auto &E : RTLibCallCommon)
771 return Subtarget.hasSoftFloat();
793 return Subtarget.hasVectorEnhancements1();
806 if (!Subtarget.hasVector() ||
807 (isFP128 && !Subtarget.hasVectorEnhancements1()))
829 if (SplatBitSize > 64)
835 if (isInt<16>(SignedValue)) {
844 if (
TII->isRxSBGMask(
Value, SplatBitSize, Start,
End)) {
866 uint64_t Lower = SplatUndefZ & maskTrailingOnes<uint64_t>(LowerBits);
867 uint64_t Upper = SplatUndefZ & maskLeadingOnes<uint64_t>(UpperBits);
874 uint64_t Middle = SplatUndefZ & ~Upper & ~Lower;
875 return tryValue(SplatBitsZ | Middle);
890 unsigned HalfSize = Width / 2;
895 if (HighValue != LowValue || 8 > HalfSize)
898 SplatBits = HighValue;
902 SplatBitSize = Width;
910 BVN->
isConstantSplat(IntBits, SplatUndef, SplatBitSize, HasAnyUndefs, 128,
914 BVN->
isConstantSplat(SplatBits, SplatUndef, SplatBitSize, HasAnyUndefs, 8,
919 bool ForCodeSize)
const {
921 if (Imm.isZero() || Imm.isNegZero())
953 if (Subtarget.hasInterlockedAccess1() &&
967 return isInt<32>(Imm) || isUInt<32>(Imm);
972 return isUInt<32>(Imm) || isUInt<32>(-Imm);
994 LongDisplacement(LongDispl), IndexReg(IdxReg) {}
1017 switch (
II->getIntrinsicID()) {
1019 case Intrinsic::memset:
1020 case Intrinsic::memmove:
1021 case Intrinsic::memcpy:
1026 if (isa<LoadInst>(
I) &&
I->hasOneUse()) {
1027 auto *SingleUser = cast<Instruction>(*
I->user_begin());
1028 if (SingleUser->getParent() ==
I->getParent()) {
1029 if (isa<ICmpInst>(SingleUser)) {
1030 if (
auto *
C = dyn_cast<ConstantInt>(SingleUser->getOperand(1)))
1031 if (
C->getBitWidth() <= 64 &&
1032 (isInt<16>(
C->getSExtValue()) || isUInt<16>(
C->getZExtValue())))
1035 }
else if (isa<StoreInst>(SingleUser))
1039 }
else if (
auto *StoreI = dyn_cast<StoreInst>(
I)) {
1040 if (
auto *LoadI = dyn_cast<LoadInst>(StoreI->getValueOperand()))
1041 if (LoadI->hasOneUse() && LoadI->getParent() ==
I->getParent())
1046 if (HasVector && (isa<LoadInst>(
I) || isa<StoreInst>(
I))) {
1054 Type *MemAccessTy = (isa<LoadInst>(
I) ?
I->getType() :
1055 I->getOperand(0)->getType());
1057 bool IsVectorAccess = MemAccessTy->
isVectorTy();
1061 if (!IsVectorAccess && isa<StoreInst>(
I)) {
1062 Value *DataOp =
I->getOperand(0);
1063 if (isa<ExtractElementInst>(DataOp))
1064 IsVectorAccess =
true;
1069 if (!IsVectorAccess && isa<LoadInst>(
I) &&
I->hasOneUse()) {
1070 User *LoadUser = *
I->user_begin();
1071 if (isa<InsertElementInst>(LoadUser))
1072 IsVectorAccess =
true;
1075 if (IsFPAccess || IsVectorAccess)
1104 return AM.
Scale == 0;
1111 std::vector<EVT> &MemOps,
unsigned Limit,
const MemOp &
Op,
unsigned DstAS,
1112 unsigned SrcAS,
const AttributeList &FuncAttributes)
const {
1113 const int MVCFastLen = 16;
1115 if (Limit != ~
unsigned(0)) {
1117 if (
Op.isMemcpy() &&
Op.allowOverlap() &&
Op.size() <= MVCFastLen)
1119 if (
Op.isMemset() &&
Op.size() - 1 <= MVCFastLen)
1121 if (
Op.isZeroMemset())
1126 SrcAS, FuncAttributes);
1131 return Subtarget.hasVector() ? MVT::v2i64 : MVT::Other;
1135 if (!FromType->isIntegerTy() || !ToType->
isIntegerTy())
1137 unsigned FromBits = FromType->getPrimitiveSizeInBits().getFixedValue();
1139 return FromBits > ToBits;
1147 return FromBits > ToBits;
1156 if (Constraint.
size() == 1) {
1157 switch (Constraint[0]) {
1183 }
else if (Constraint.
size() == 2 && Constraint[0] ==
'Z') {
1184 switch (Constraint[1]) {
1200 const char *constraint)
const {
1202 Value *CallOperandVal =
info.CallOperandVal;
1205 if (!CallOperandVal)
1209 switch (*constraint) {
1227 if (Subtarget.hasVector())
1233 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
1234 if (isUInt<8>(
C->getZExtValue()))
1239 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
1240 if (isUInt<12>(
C->getZExtValue()))
1245 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
1246 if (isInt<16>(
C->getSExtValue()))
1251 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
1252 if (isInt<20>(
C->getSExtValue()))
1257 if (
auto *
C = dyn_cast<ConstantInt>(CallOperandVal))
1258 if (
C->getZExtValue() == 0x7fffffff)
1268static std::pair<unsigned, const TargetRegisterClass *>
1270 const unsigned *Map,
unsigned Size) {
1271 assert(*(Constraint.
end()-1) ==
'}' &&
"Missing '}'");
1272 if (isdigit(Constraint[2])) {
1277 return std::make_pair(Map[
Index], RC);
1279 return std::make_pair(0U,
nullptr);
1282std::pair<unsigned, const TargetRegisterClass *>
1285 if (Constraint.
size() == 1) {
1287 switch (Constraint[0]) {
1292 return std::make_pair(0U, &SystemZ::GR64BitRegClass);
1294 return std::make_pair(0U, &SystemZ::GR128BitRegClass);
1295 return std::make_pair(0U, &SystemZ::GR32BitRegClass);
1299 return std::make_pair(0U, &SystemZ::ADDR64BitRegClass);
1300 else if (VT == MVT::i128)
1301 return std::make_pair(0U, &SystemZ::ADDR128BitRegClass);
1302 return std::make_pair(0U, &SystemZ::ADDR32BitRegClass);
1305 return std::make_pair(0U, &SystemZ::GRH32BitRegClass);
1310 return std::make_pair(0U, &SystemZ::FP64BitRegClass);
1312 return std::make_pair(0U, &SystemZ::FP128BitRegClass);
1313 return std::make_pair(0U, &SystemZ::FP32BitRegClass);
1318 if (Subtarget.hasVector()) {
1320 return std::make_pair(0U, &SystemZ::VR32BitRegClass);
1322 return std::make_pair(0U, &SystemZ::VR64BitRegClass);
1323 return std::make_pair(0U, &SystemZ::VR128BitRegClass);
1332 auto getVTSizeInBits = [&VT]() {
1340 if (Constraint[1] ==
'r') {
1341 if (getVTSizeInBits() == 32)
1344 if (getVTSizeInBits() == 128)
1350 if (Constraint[1] ==
'f') {
1352 return std::make_pair(
1354 if (getVTSizeInBits() == 32)
1357 if (getVTSizeInBits() == 128)
1363 if (Constraint[1] ==
'v') {
1364 if (!Subtarget.hasVector())
1365 return std::make_pair(
1367 if (getVTSizeInBits() == 32)
1370 if (getVTSizeInBits() == 64)
1397 const Constant *PersonalityFn)
const {
1402 const Constant *PersonalityFn)
const {
1410 if (Constraint.
size() == 1) {
1411 switch (Constraint[0]) {
1413 if (
auto *
C = dyn_cast<ConstantSDNode>(
Op))
1414 if (isUInt<8>(
C->getZExtValue()))
1416 Op.getValueType()));
1420 if (
auto *
C = dyn_cast<ConstantSDNode>(
Op))
1421 if (isUInt<12>(
C->getZExtValue()))
1423 Op.getValueType()));
1427 if (
auto *
C = dyn_cast<ConstantSDNode>(
Op))
1428 if (isInt<16>(
C->getSExtValue()))
1430 Op.getValueType()));
1434 if (
auto *
C = dyn_cast<ConstantSDNode>(
Op))
1435 if (isInt<20>(
C->getSExtValue()))
1437 Op.getValueType()));
1441 if (
auto *
C = dyn_cast<ConstantSDNode>(
Op))
1442 if (
C->getZExtValue() == 0x7fffffff)
1444 Op.getValueType()));
1455#include "SystemZGenCallingConv.inc"
1459 static const MCPhysReg ScratchRegs[] = { SystemZ::R0D, SystemZ::R1D,
1465 Type *ToType)
const {
1528 if (BitCastToType == MVT::v2i64)
1555 MVT::Untyped,
Hi,
Lo);
1579 unsigned NumParts,
MVT PartVT, std::optional<CallingConv::ID>
CC)
const {
1581 if (ValueVT.
getSizeInBits() == 128 && NumParts == 1 && PartVT == MVT::Untyped) {
1592 MVT PartVT,
EVT ValueVT, std::optional<CallingConv::ID>
CC)
const {
1593 if (ValueVT.
getSizeInBits() == 128 && NumParts == 1 && PartVT == MVT::Untyped) {
1620 unsigned NumFixedGPRs = 0;
1621 unsigned NumFixedFPRs = 0;
1622 for (
unsigned I = 0, E = ArgLocs.
size();
I != E; ++
I) {
1635 RC = &SystemZ::GR32BitRegClass;
1639 RC = &SystemZ::GR64BitRegClass;
1643 RC = &SystemZ::FP32BitRegClass;
1647 RC = &SystemZ::FP64BitRegClass;
1651 RC = &SystemZ::FP128BitRegClass;
1659 RC = &SystemZ::VR128BitRegClass;
1688 ArgValue = DAG.
getLoad(LocVT,
DL, Chain, FIN,
1699 unsigned ArgIndex = Ins[
I].OrigArgIndex;
1700 assert (Ins[
I].PartOffset == 0);
1701 while (
I + 1 != E && Ins[
I + 1].OrigArgIndex == ArgIndex) {
1703 unsigned PartOffset = Ins[
I + 1].PartOffset;
1726 int64_t VarArgOffset = CCInfo.
getStackSize() + Regs->getCallFrameSize();
1744 int64_t RegSaveOffset =
1759 &SystemZ::FP64BitRegClass);
1777 MRI.addLiveIn(Regs->getADARegister(), ADAvReg);
1789 for (
unsigned I = 0, E = ArgLocs.
size();
I != E; ++
I) {
1796 if (Reg == SystemZ::R6H || Reg == SystemZ::R6L || Reg == SystemZ::R6D)
1798 if (Outs[
I].Flags.isSwiftSelf() || Outs[
I].Flags.isSwiftError())
1805 unsigned Offset,
bool LoadAdr =
false) {
1828 bool LoadAddr =
false;
1829 const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV);
1850 unsigned ADADelta = 0;
1851 unsigned EPADelta = 8;
1856 if (
auto *
G = dyn_cast<GlobalAddressSDNode>(Callee)) {
1857 bool IsInternal = (
G->getGlobal()->hasInternalLinkage() ||
1858 G->getGlobal()->hasPrivateLinkage());
1873 }
else if (
auto *E = dyn_cast<ExternalSymbolSDNode>(Callee)) {
1935 for (
unsigned I = 0, E = ArgLocs.
size();
I != E; ++
I) {
1941 unsigned ArgIndex = Outs[
I].OrigArgIndex;
1943 if (
I + 1 != E && Outs[
I + 1].OrigArgIndex == ArgIndex) {
1945 Type *OrigArgType = CLI.
Args[Outs[
I].OrigArgIndex].Ty;
1951 SlotVT = Outs[
I].VT;
1954 int FI = cast<FrameIndexSDNode>(SpillSlot)->getIndex();
1960 assert (Outs[
I].PartOffset == 0);
1961 while (
I + 1 != E && Outs[
I + 1].OrigArgIndex == ArgIndex) {
1962 SDValue PartValue = OutVals[
I + 1];
1963 unsigned PartOffset = Outs[
I + 1].PartOffset;
1970 SlotVT.
getStoreSize()) &&
"Not enough space for argument part!");
1973 ArgValue = SpillSlot;
1990 if (!StackPtr.getNode())
2012 RegsToPass.
push_back(std::make_pair(SystemZ::R3D, ShadowArgValue));
2018 if (!MemOpChains.
empty())
2031 ->getAddressOfCalleeRegister();
2034 Callee = DAG.
getRegister(CalleeReg, Callee.getValueType());
2039 if (
auto *
G = dyn_cast<GlobalAddressSDNode>(Callee)) {
2042 }
else if (
auto *E = dyn_cast<ExternalSymbolSDNode>(Callee)) {
2045 }
else if (IsTailCall) {
2048 Callee = DAG.
getRegister(SystemZ::R1D, Callee.getValueType());
2053 for (
unsigned I = 0, E = RegsToPass.
size();
I != E; ++
I) {
2055 RegsToPass[
I].second, Glue);
2066 for (
unsigned I = 0, E = RegsToPass.
size();
I != E; ++
I)
2068 RegsToPass[
I].second.getValueType()));
2072 const uint32_t *Mask =
TRI->getCallPreservedMask(MF, CallConv);
2073 assert(Mask &&
"Missing call preserved mask for calling convention");
2097 CCState RetCCInfo(CallConv, IsVarArg, MF, RetLocs, Ctx);
2104 VA.getLocVT(), Glue);
2121 bool DoesNotReturn,
bool IsReturnValueUsed)
const {
2123 Args.reserve(Ops.
size());
2128 Entry.Ty = Entry.Node.getValueType().getTypeForEVT(*DAG.
getContext());
2131 Args.push_back(Entry);
2157 for (
auto &Out : Outs)
2158 if (Out.ArgVT == MVT::i128)
2162 CCState RetCCInfo(CallConv, isVarArg, MF, RetLocs, Context);
2163 return RetCCInfo.
CheckReturn(Outs, RetCC_SystemZ);
2180 if (RetLocs.
empty())
2190 for (
unsigned I = 0, E = RetLocs.
size();
I != E; ++
I) {
2219 unsigned &CCValid) {
2220 unsigned Id =
Op.getConstantOperandVal(1);
2222 case Intrinsic::s390_tbegin:
2227 case Intrinsic::s390_tbegin_nofloat:
2232 case Intrinsic::s390_tend:
2246 unsigned Id =
Op.getConstantOperandVal(0);
2248 case Intrinsic::s390_vpkshs:
2249 case Intrinsic::s390_vpksfs:
2250 case Intrinsic::s390_vpksgs:
2255 case Intrinsic::s390_vpklshs:
2256 case Intrinsic::s390_vpklsfs:
2257 case Intrinsic::s390_vpklsgs:
2262 case Intrinsic::s390_vceqbs:
2263 case Intrinsic::s390_vceqhs:
2264 case Intrinsic::s390_vceqfs:
2265 case Intrinsic::s390_vceqgs:
2270 case Intrinsic::s390_vchbs:
2271 case Intrinsic::s390_vchhs:
2272 case Intrinsic::s390_vchfs:
2273 case Intrinsic::s390_vchgs:
2278 case Intrinsic::s390_vchlbs:
2279 case Intrinsic::s390_vchlhs:
2280 case Intrinsic::s390_vchlfs:
2281 case Intrinsic::s390_vchlgs:
2286 case Intrinsic::s390_vtm:
2291 case Intrinsic::s390_vfaebs:
2292 case Intrinsic::s390_vfaehs:
2293 case Intrinsic::s390_vfaefs:
2298 case Intrinsic::s390_vfaezbs:
2299 case Intrinsic::s390_vfaezhs:
2300 case Intrinsic::s390_vfaezfs:
2305 case Intrinsic::s390_vfeebs:
2306 case Intrinsic::s390_vfeehs:
2307 case Intrinsic::s390_vfeefs:
2312 case Intrinsic::s390_vfeezbs:
2313 case Intrinsic::s390_vfeezhs:
2314 case Intrinsic::s390_vfeezfs:
2319 case Intrinsic::s390_vfenebs:
2320 case Intrinsic::s390_vfenehs:
2321 case Intrinsic::s390_vfenefs:
2326 case Intrinsic::s390_vfenezbs:
2327 case Intrinsic::s390_vfenezhs:
2328 case Intrinsic::s390_vfenezfs:
2333 case Intrinsic::s390_vistrbs:
2334 case Intrinsic::s390_vistrhs:
2335 case Intrinsic::s390_vistrfs:
2340 case Intrinsic::s390_vstrcbs:
2341 case Intrinsic::s390_vstrchs:
2342 case Intrinsic::s390_vstrcfs:
2347 case Intrinsic::s390_vstrczbs:
2348 case Intrinsic::s390_vstrczhs:
2349 case Intrinsic::s390_vstrczfs:
2354 case Intrinsic::s390_vstrsb:
2355 case Intrinsic::s390_vstrsh:
2356 case Intrinsic::s390_vstrsf:
2361 case Intrinsic::s390_vstrszb:
2362 case Intrinsic::s390_vstrszh:
2363 case Intrinsic::s390_vstrszf:
2368 case Intrinsic::s390_vfcedbs:
2369 case Intrinsic::s390_vfcesbs:
2374 case Intrinsic::s390_vfchdbs:
2375 case Intrinsic::s390_vfchsbs:
2380 case Intrinsic::s390_vfchedbs:
2381 case Intrinsic::s390_vfchesbs:
2386 case Intrinsic::s390_vftcidb:
2387 case Intrinsic::s390_vftcisb:
2392 case Intrinsic::s390_tdc:
2410 for (
unsigned I = 2;
I < NumOps; ++
I)
2413 assert(
Op->getNumValues() == 2 &&
"Expected only CC result and chain");
2419 return Intr.getNode();
2429 for (
unsigned I = 1;
I < NumOps; ++
I)
2433 return Intr.getNode();
2443 case ISD::SET##X: return SystemZ::CCMASK_CMP_##X; \
2444 case ISD::SETO##X: return SystemZ::CCMASK_CMP_##X; \
2445 case ISD::SETU##X: return SystemZ::CCMASK_CMP_UO | SystemZ::CCMASK_CMP_##X
2470 auto *ConstOp1 = dyn_cast<ConstantSDNode>(
C.Op1.getNode());
2471 if (!ConstOp1 || ConstOp1->getValueSizeInBits(0) > 64)
2474 int64_t
Value = ConstOp1->getSExtValue();
2490 if (!
C.Op0.hasOneUse() ||
2496 auto *Load = cast<LoadSDNode>(
C.Op0);
2497 unsigned NumBits = Load->getMemoryVT().getSizeInBits();
2498 if ((NumBits != 8 && NumBits != 16) ||
2499 NumBits != Load->getMemoryVT().getStoreSizeInBits())
2504 auto *ConstOp1 = cast<ConstantSDNode>(
C.Op1);
2505 if (!ConstOp1 || ConstOp1->getValueSizeInBits(0) > 64)
2508 uint64_t Mask = (1 << NumBits) - 1;
2511 int64_t SignedValue = ConstOp1->getSExtValue();
2518 }
else if (NumBits == 8) {
2544 if (
C.Op0.getValueType() != MVT::i32 ||
2545 Load->getExtensionType() != ExtType) {
2547 Load->getBasePtr(), Load->getPointerInfo(),
2548 Load->getMemoryVT(), Load->getAlign(),
2549 Load->getMemOperand()->getFlags());
2555 if (
C.Op1.getValueType() != MVT::i32 ||
2556 Value != ConstOp1->getZExtValue())
2563 auto *Load = dyn_cast<LoadSDNode>(
Op.getNode());
2566 if (Load->getMemoryVT() == MVT::i8)
2569 switch (Load->getExtensionType()) {
2586 if (
C.Op0.getValueType() == MVT::i128)
2588 if (
C.Op0.getValueType() == MVT::f128)
2594 if (isa<ConstantFPSDNode>(
C.Op1))
2599 auto *ConstOp1 = dyn_cast<ConstantSDNode>(
C.Op1);
2600 if (ConstOp1 && ConstOp1->getZExtValue() == 0)
2618 isUInt<16>(ConstOp1->getZExtValue()))
2623 isInt<16>(ConstOp1->getSExtValue()))
2629 unsigned Opcode0 =
C.Op0.getOpcode();
2636 C.Op0.getConstantOperandVal(1) == 0xffffffff)
2651 ((
N->getOperand(0) ==
C.Op0 &&
N->getOperand(1) ==
C.Op1) ||
2652 (
N->getOperand(0) ==
C.Op1 &&
N->getOperand(1) ==
C.Op0))) {
2656 Flags.setNoSignedWrap(
false);
2657 Flags.setNoUnsignedWrap(
false);
2676 auto *C1 = dyn_cast<ConstantFPSDNode>(
C.Op1);
2677 if (C1 && C1->isZero()) {
2696 if (
C.Op0.getOpcode() ==
ISD::SHL &&
C.Op0.getValueType() == MVT::i64 &&
2698 auto *C1 = dyn_cast<ConstantSDNode>(
C.Op0.getOperand(1));
2699 if (C1 && C1->getZExtValue() == 32) {
2700 SDValue ShlOp0 =
C.Op0.getOperand(0);
2704 cast<VTSDNode>(
N->getOperand(1))->getVT() == MVT::i32) {
2719 C.Op0.getOperand(0).getOpcode() ==
ISD::LOAD &&
2721 cast<ConstantSDNode>(
C.Op1)->getValueSizeInBits(0) <= 64 &&
2722 C.Op1->getAsZExtVal() == 0) {
2723 auto *L = cast<LoadSDNode>(
C.Op0.getOperand(0));
2724 if (L->getMemoryVT().getStoreSizeInBits().getFixedValue() <=
2725 C.Op0.getValueSizeInBits().getFixedValue()) {
2726 unsigned Type = L->getExtensionType();
2729 C.Op0 =
C.Op0.getOperand(0);
2739 auto *Shift = dyn_cast<ConstantSDNode>(
N.getOperand(1));
2743 uint64_t Amount = Shift->getZExtValue();
2744 if (Amount >=
N.getValueSizeInBits())
2759 unsigned ICmpType) {
2760 assert(Mask != 0 &&
"ANDs with zero should have been removed by now");
2782 if (EffectivelyUnsigned && CmpVal > 0 && CmpVal <=
Low) {
2788 if (EffectivelyUnsigned && CmpVal <
Low) {
2796 if (CmpVal == Mask) {
2802 if (EffectivelyUnsigned && CmpVal >= Mask -
Low && CmpVal < Mask) {
2808 if (EffectivelyUnsigned && CmpVal > Mask -
Low && CmpVal <= Mask) {
2816 if (EffectivelyUnsigned && CmpVal >= Mask -
High && CmpVal <
High) {
2822 if (EffectivelyUnsigned && CmpVal > Mask -
High && CmpVal <=
High) {
2851 if (
C.Op0.getValueType() == MVT::i128) {
2856 auto *Mask = dyn_cast<ConstantSDNode>(
C.Op1);
2857 if (Mask && Mask->getAPIntValue() == 0) {
2872 auto *ConstOp1 = dyn_cast<ConstantSDNode>(
C.Op1);
2875 uint64_t CmpVal = ConstOp1->getZExtValue();
2882 NewC.Op0 =
C.Op0.getOperand(0);
2883 NewC.Op1 =
C.Op0.getOperand(1);
2884 Mask = dyn_cast<ConstantSDNode>(NewC.Op1);
2887 MaskVal = Mask->getZExtValue();
2892 if (NewC.Op0.getValueType() != MVT::i64 ||
2907 MaskVal = -(CmpVal & -CmpVal);
2915 unsigned BitSize = NewC.Op0.getValueSizeInBits();
2916 unsigned NewCCMask, ShiftVal;
2918 NewC.Op0.getOpcode() ==
ISD::SHL &&
2920 (MaskVal >> ShiftVal != 0) &&
2921 ((CmpVal >> ShiftVal) << ShiftVal) == CmpVal &&
2923 MaskVal >> ShiftVal,
2926 NewC.Op0 = NewC.Op0.getOperand(0);
2927 MaskVal >>= ShiftVal;
2929 NewC.Op0.getOpcode() ==
ISD::SRL &&
2931 (MaskVal << ShiftVal != 0) &&
2932 ((CmpVal << ShiftVal) >> ShiftVal) == CmpVal &&
2934 MaskVal << ShiftVal,
2937 NewC.Op0 = NewC.Op0.getOperand(0);
2938 MaskVal <<= ShiftVal;
2949 if (Mask && Mask->getZExtValue() == MaskVal)
2954 C.CCMask = NewCCMask;
2962 if (
C.Op0.getValueType() != MVT::i128)
2980 bool Swap =
false, Invert =
false;
2999 C.CCMask ^=
C.CCValid;
3009 auto *Mask = dyn_cast<ConstantSDNode>(
C.Op0.getOperand(1));
3010 if (!Mask || Mask->getValueSizeInBits(0) > 64)
3013 if ((~Known.
Zero).getZExtValue() & ~Mask->getZExtValue())
3016 C.Op0 =
C.Op0.getOperand(0);
3028 C.CCValid = CCValid;
3031 C.CCMask =
CC < 4 ? 1 << (3 -
CC) : 0;
3034 C.CCMask =
CC < 4 ? ~(1 << (3 -
CC)) : -1;
3038 C.CCMask =
CC < 4 ? ~0U << (4 -
CC) : -1;
3041 C.CCMask =
CC < 4 ? ~(~0U << (4 -
CC)) : 0;
3045 C.CCMask =
CC < 4 ? ~0U << (3 -
CC) : -1;
3048 C.CCMask =
CC < 4 ? ~(~0U << (3 -
CC)) : 0;
3051 C.CCMask &= CCValid;
3059 bool IsSignaling =
false) {
3062 unsigned Opcode, CCValid;
3074 Comparison
C(CmpOp0, CmpOp1, Chain);
3076 if (
C.Op0.getValueType().isFloatingPoint()) {
3080 else if (!IsSignaling)
3102 C.CCMask &= ~SystemZ::CCMASK_CMP_UO;
3123 if (!
C.Op1.getNode()) {
3125 switch (
C.Op0.getOpcode()) {
3152 return DAG.
getNode(
C.Opcode,
DL, VTs,
C.Chain,
C.Op0,
C.Op1);
3154 return DAG.
getNode(
C.Opcode,
DL, MVT::i32,
C.Op0,
C.Op1);
3163 Op0 = DAG.
getNode(Extend,
DL, MVT::i64, Op0);
3164 Op1 = DAG.
getNode(Extend,
DL, MVT::i64, Op1);
3189 unsigned CCValid,
unsigned CCMask) {
3218 case CmpMode::Int:
return 0;
3238 case CmpMode::FP:
return 0;
3239 case CmpMode::StrictFP:
return 0;
3240 case CmpMode::SignalingFP:
return 0;
3272 int Mask[] = { Start, -1, Start + 1, -1 };
3292 !Subtarget.hasVectorEnhancements1()) {
3306 SDValue Ops[2] = { Res, NewChain };
3315 return DAG.
getNode(Opcode,
DL, VTs, Chain, CmpOp0, CmpOp1);
3317 return DAG.
getNode(Opcode,
DL, VT, CmpOp0, CmpOp1);
3330 bool IsSignaling)
const {
3333 assert (!IsSignaling || Chain);
3334 CmpMode Mode = IsSignaling ? CmpMode::SignalingFP :
3335 Chain ? CmpMode::StrictFP : IsFP ? CmpMode::FP : CmpMode::Int;
3336 bool Invert =
false;
3344 assert(IsFP &&
"Unexpected integer comparison");
3346 DL, VT, CmpOp1, CmpOp0, Chain);
3348 DL, VT, CmpOp0, CmpOp1, Chain);
3352 LT.getValue(1),
GE.getValue(1));
3361 assert(IsFP &&
"Unexpected integer comparison");
3363 DL, VT, CmpOp1, CmpOp0, Chain);
3365 DL, VT, CmpOp0, CmpOp1, Chain);
3369 LT.getValue(1),
GT.getValue(1));
3378 Cmp = getVectorCmp(DAG, Opcode,
DL, VT, CmpOp0, CmpOp1, Chain);
3382 Cmp = getVectorCmp(DAG, Opcode,
DL, VT, CmpOp1, CmpOp0, Chain);
3387 Chain =
Cmp.getValue(1);
3395 if (Chain && Chain.
getNode() !=
Cmp.getNode()) {
3408 EVT VT =
Op.getValueType();
3410 return lowerVectorSETCC(DAG,
DL, VT,
CC, CmpOp0, CmpOp1);
3419 bool IsSignaling)
const {
3425 EVT VT =
Op.getNode()->getValueType(0);
3427 SDValue Res = lowerVectorSETCC(DAG,
DL, VT,
CC, CmpOp0, CmpOp1,
3428 Chain, IsSignaling);
3492 cast<ConstantSDNode>(
C.Op1)->getValueSizeInBits(0) <= 64 &&
3493 C.Op1->getAsZExtVal() == 0) {
3501 SDValue Ops[] = {TrueOp, FalseOp,
3575 Chain = DAG.
getCopyToReg(Chain,
DL, SystemZ::R2D, GOTOffset, Glue);
3582 Node->getValueType(0),
3594 assert(Mask &&
"Missing call preserved mask for calling convention");
3602 Chain = DAG.
getNode(Opcode,
DL, NodeTys, Ops);
3609SDValue SystemZTargetLowering::lowerThreadPointer(
const SDLoc &
DL,
3641 SDValue TP = lowerThreadPointer(
DL, DAG);
3749 if (
CP->isMachineConstantPoolEntry())
3768 unsigned Depth =
Op.getConstantOperandVal(0);
3775 int BackChainIdx = TFL->getOrCreateFramePointerSaveIndex(MF);
3804 unsigned Depth =
Op.getConstantOperandVal(0);
3812 SDValue FrameAddr = lowerFRAMEADDR(
Op, DAG);
3814 int Offset = TFL->getReturnAddressOffset(MF);
3825 &SystemZ::GR64BitRegClass);
3833 EVT InVT =
In.getValueType();
3834 EVT ResVT =
Op.getValueType();
3839 if (
auto *LoadN = dyn_cast<LoadSDNode>(In))
3842 LoadN->getBasePtr(), LoadN->getMemOperand());
3848 if (InVT == MVT::i32 && ResVT == MVT::f32) {
3850 if (Subtarget.hasHighWord()) {
3854 MVT::i64,
SDValue(U64, 0), In);
3862 DL, MVT::f32, Out64);
3864 if (InVT == MVT::f32 && ResVT == MVT::i32) {
3867 MVT::f64,
SDValue(U64, 0), In);
3869 if (Subtarget.hasHighWord())
3883 return lowerVASTART_XPLINK(
Op, DAG);
3885 return lowerVASTART_ELF(
Op, DAG);
3900 const Value *SV = cast<SrcValueSDNode>(
Op.getOperand(2))->getValue();