25#include "llvm/IR/IntrinsicsS390.h"
36#define DEBUG_TYPE "systemz-lower"
42 : Op0(Op0In), Op1(Op1In), Chain(ChainIn),
43 Opcode(0), ICmpType(0), CCValid(0), CCMask(0) {}
93 if (Subtarget.hasHighWord())
99 if (Subtarget.hasVector()) {
108 if (Subtarget.hasVectorEnhancements1())
113 if (Subtarget.hasVector()) {
123 if (Subtarget.hasVector())
128 if (!Subtarget.hasVector())
154 for (
unsigned I = MVT::FIRST_INTEGER_VALUETYPE;
155 I <= MVT::LAST_FP_VALUETYPE;
181 for (
unsigned I = MVT::FIRST_INTEGER_VALUETYPE;
182 I <= MVT::LAST_INTEGER_VALUETYPE;
213 if (Subtarget.hasPopulationCount())
239 (!Subtarget.hasFPExtension() && VT == MVT::i32) ?
Promote :
Custom;
260 if (!Subtarget.hasVectorEnhancements3()) {
287 if (Subtarget.hasVectorEnhancements3()) {
312 {MVT::i8, MVT::i16},
Custom);
324 {MVT::i8, MVT::i16, MVT::i32},
Legal);
326 {MVT::i8, MVT::i16},
Legal);
347 if (Subtarget.hasMiscellaneousExtensions4()) {
356 if (Subtarget.hasMiscellaneousExtensions3()) {
441 if (!Subtarget.hasVector()) {
459 if (VT != MVT::v2i64 || Subtarget.hasVectorEnhancements3()) {
464 if (Subtarget.hasVectorEnhancements3() &&
465 VT != MVT::v16i8 && VT != MVT::v8i16) {
475 if (Subtarget.hasVectorEnhancements1())
509 if (Subtarget.hasVector()) {
531 if (Subtarget.hasVectorEnhancements2()) {
557 for (
MVT VT : {MVT::f32, MVT::f64, MVT::f128}) {
571 for (
unsigned I = MVT::FIRST_FP_VALUETYPE;
572 I <= MVT::LAST_FP_VALUETYPE;
580 if (Subtarget.hasFPExtension()) {
608 if (Subtarget.hasFPExtension()) {
624 if (Subtarget.hasVector()) {
675 if (Subtarget.hasVectorEnhancements1()) {
682 if (Subtarget.hasVectorEnhancements1()) {
699 for (
MVT Type : {MVT::f64, MVT::v2f64, MVT::f32, MVT::v4f32, MVT::f128}) {
724 for (
auto VT : { MVT::f32, MVT::f64, MVT::f128,
725 MVT::v4f32, MVT::v2f64 }) {
736 if (!Subtarget.hasVectorEnhancements1()) {
742 if (Subtarget.hasVectorEnhancements1())
752 if (Subtarget.hasVectorEnhancements1()) {
764 if (!Subtarget.hasVector()) {
775 if (Subtarget.isTargetzOS()) {
840 return Subtarget.hasSoftFloat();
861 if (!Subtarget.hasVector() || VT.
getScalarType() == MVT::f16)
871 unsigned &NumIntermediates,
MVT &RegisterVT)
const {
873 if (Subtarget.hasVector() && VT.
isVectorOf(MVT::f16)) {
874 IntermediateVT = RegisterVT = MVT::v8f16;
875 return NumIntermediates =
879 Context,
CC, VT, IntermediateVT, NumIntermediates, RegisterVT);
882 if (RegisterVT == MVT::v2i64 && !Subtarget.hasVector()) {
883 IntermediateVT = RegisterVT = MVT::i64;
884 NumIntermediates *= 2;
899 if (Subtarget.hasVector() && VT.
isVectorOf(MVT::f16))
903 if (RegisterVT == MVT::v2i64 && !Subtarget.hasVector())
911 if (Subtarget.hasVector() && VT.
isVectorOf(MVT::f16))
917 if (RegisterVT == MVT::v2i64 && !Subtarget.hasVector())
944 return Subtarget.hasVectorEnhancements1();
958 (isFP128 && !
Subtarget.hasVectorEnhancements1()))
967 uint64_t Byte = IntBits.lshr(
I * 8).trunc(8).getZExtValue();
974 Opcode = SystemZISD::BYTE_MASK;
980 if (SplatBitSize > 64)
983 auto TryValue = [&](uint64_t
Value) ->
bool {
987 OpVals.push_back(((
unsigned) SignedValue));
988 Opcode = SystemZISD::REPLICATE;
995 if (
TII->isRxSBGMask(
Value, SplatBitSize, Start,
End)) {
999 OpVals.push_back(Start - (64 - SplatBitSize));
1000 OpVals.push_back(
End - (64 - SplatBitSize));
1001 Opcode = SystemZISD::ROTATE_MASK;
1013 uint64_t SplatBitsZ = SplatBits.getZExtValue();
1014 uint64_t SplatUndefZ = SplatUndef.getZExtValue();
1026 return TryValue(SplatBitsZ | Middle);
1035 assert(IntBits.getBitWidth() == 128 &&
"Unsupported APInt.");
1041 unsigned HalfSize = Width / 2;
1046 if (HighValue != LowValue || 8 > HalfSize)
1049 SplatBits = HighValue;
1053 SplatBitSize = Width;
1061 BVN->
isConstantSplat(IntBits, SplatUndef, SplatBitSize, HasAnyUndefs, 128,
1065 BVN->
isConstantSplat(SplatBits, SplatUndef, SplatBitSize, HasAnyUndefs, 8,
1071 bool ForCodeSize)
const {
1073 if (
Imm.isZero() ||
Imm.isNegZero())
1096 assert(
TRI->isTypeLegalForClass(*RC, MVT::i32) &&
"Invalid destination!");
1098 Register MainDstReg =
MRI.createVirtualRegister(RC);
1099 Register RestoreDstReg =
MRI.createVirtualRegister(RC);
1102 assert((PVT == MVT::i64 || PVT == MVT::i32) &&
"Invalid Pointer Size!");
1155 const int64_t FPOffset = 0;
1164 Register LabelReg =
MRI.createVirtualRegister(PtrRC);
1176 auto *SpecialRegs = Subtarget.getSpecialRegisters();
1177 bool HasFP = Subtarget.getFrameLowering()->hasFP(*MF);
1180 .
addReg(SpecialRegs->getFramePointerRegister())
1188 .
addReg(SpecialRegs->getStackPointerRegister())
1196 Register BCReg =
MRI.createVirtualRegister(PtrRC);
1199 .
addReg(SpecialRegs->getStackPointerRegister())
1200 .
addImm(TFL->getBackchainOffset(*MF))
1211 MIB =
BuildMI(*ThisMBB,
MI,
DL,
TII->get(SystemZ::EH_SjLj_Setup))
1215 MIB.
addRegMask(RegInfo->getNoPreservedMask());
1236 MI.eraseFromParent();
1252 assert((PVT == MVT::i64 || PVT == MVT::i32) &&
"Invalid Pointer Size!");
1255 auto *SpecialRegs = Subtarget.getSpecialRegisters();
1262 const int64_t FPOffset = 0;
1274 SpecialRegs->getFramePointerRegister())
1296 SpecialRegs->getStackPointerRegister())
1305 .
addReg(SpecialRegs->getStackPointerRegister())
1306 .
addImm(TFL->getBackchainOffset(*MF))
1312 MI.eraseFromParent();
1319 return MemVT != MVT::v2i64 || Subtarget.hasVector();
1325 return !Subtarget.hasVector();
1355 if (Subtarget.hasInterlockedAccess1() &&
1388 EVT VT =
Y.getValueType();
1391 if (VT == MVT::i32 || VT == MVT::i64)
1392 return Subtarget.hasMiscellaneousExtensions3();
1395 if (VT.
isVector() || VT == MVT::i128)
1396 return Subtarget.hasVector();
1424 bool MVC = Ty->isIntegerTy(8);
1430static AddressingMode
1433 switch (
II->getIntrinsicID()) {
1435 case Intrinsic::memset:
1436 case Intrinsic::memmove:
1437 case Intrinsic::memcpy:
1444 if (SingleUser->getParent() ==
I->getParent()) {
1447 if (
C->getBitWidth() <= 64 &&
1457 if (LoadI->hasOneUse() && LoadI->getParent() ==
I->getParent())
1471 I->getOperand(0)->getType());
1473 bool IsVectorAccess = MemAccessTy->isVectorTy();
1478 Value *DataOp =
I->getOperand(0);
1480 IsVectorAccess =
true;
1486 User *LoadUser = *
I->user_begin();
1488 IsVectorAccess =
true;
1491 if (IsFPAccess || IsVectorAccess)
1510 Subtarget.hasVector() && (Ty->isVectorTy() || Ty->isIntegerTy(128));
1520 return AM.
Scale == 0;
1527 LLVMContext &Context, std::vector<EVT> &MemOps,
unsigned Limit,
1528 const MemOp &
Op,
unsigned DstAS,
unsigned SrcAS,
1532 "Expected EmitTargetCodeForMemXXX() to handle AlwaysInline cases.");
1534 if (
Op.isZeroMemset())
1537 const int MVCFastLen = 16;
1540 if (
Op.isMemcpy() &&
Op.size() <= MVCFastLen)
1542 if (
Op.isMemset() &&
Op.size() - 1 <= MVCFastLen)
1546 if ((
Op.size() >= 16 && !
Op.isAligned(
Align(8))) ||
1547 (
Op.size() >= 25 &&
Op.size() <= 31))
1551 Context, MemOps, Limit,
Op, DstAS, SrcAS, FuncAttributes, LargestVT);
1557 return Subtarget.hasVector() ? MVT::v2i64 : MVT::Other;
1561 if (!FromType->isIntegerTy() || !ToType->
isIntegerTy())
1563 unsigned FromBits = FromType->getPrimitiveSizeInBits().getFixedValue();
1565 return FromBits > ToBits;
1573 return FromBits > ToBits;
1577 unsigned Opc =
N->getOpcode();
1590 if (Constraint.
size() == 1) {
1591 switch (Constraint[0]) {
1617 }
else if (Constraint.
size() == 2 && Constraint[0] ==
'Z') {
1618 switch (Constraint[1]) {
1629 if (
StringRef(
"{@cc}").compare(Constraint) == 0)
1639 Value *CallOperandVal = Info.CallOperandVal;
1642 if (!CallOperandVal)
1646 switch (*Constraint) {
1665 if (Subtarget.hasVector())
1696 if (
C->getZExtValue() == 0x7fffffff)
1706static std::pair<unsigned, const TargetRegisterClass *>
1708 const unsigned *Map,
unsigned Size) {
1709 assert(*(Constraint.
end()-1) ==
'}' &&
"Missing '}'");
1710 if (isdigit(Constraint[2])) {
1715 return std::make_pair(Map[Index], RC);
1717 return std::make_pair(0U,
nullptr);
1720std::pair<unsigned, const TargetRegisterClass *>
1723 if (Constraint.
size() == 1) {
1725 switch (Constraint[0]) {
1731 if (VT == MVT::Other)
1734 return std::make_pair(0U, &SystemZ::GR64BitRegClass);
1736 return std::make_pair(0U, &SystemZ::GR128BitRegClass);
1737 return std::make_pair(0U, &SystemZ::GR32BitRegClass);
1741 return std::make_pair(0U, &SystemZ::ADDR64BitRegClass);
1742 else if (VT == MVT::i128)
1743 return std::make_pair(0U, &SystemZ::ADDR128BitRegClass);
1744 return std::make_pair(0U, &SystemZ::ADDR32BitRegClass);
1747 return std::make_pair(0U, &SystemZ::GRH32BitRegClass);
1751 if (VT == MVT::Other)
1754 return std::make_pair(0U, &SystemZ::FP16BitRegClass);
1756 return std::make_pair(0U, &SystemZ::FP64BitRegClass);
1758 return std::make_pair(0U, &SystemZ::FP128BitRegClass);
1759 return std::make_pair(0U, &SystemZ::FP32BitRegClass);
1764 if (Subtarget.hasVector()) {
1765 if (VT == MVT::Other)
1768 return std::make_pair(0U, &SystemZ::VR16BitRegClass);
1770 return std::make_pair(0U, &SystemZ::VR32BitRegClass);
1772 return std::make_pair(0U, &SystemZ::VR64BitRegClass);
1773 return std::make_pair(0U, &SystemZ::VR128BitRegClass);
1782 auto getVTSizeInBits = [&VT]() {
1790 if (Constraint[1] ==
'r') {
1791 if (getVTSizeInBits() == 32)
1794 if (getVTSizeInBits() == 128)
1800 if (Constraint[1] ==
'f') {
1802 return std::make_pair(
1804 if (getVTSizeInBits() == 16)
1807 if (getVTSizeInBits() == 32)
1810 if (getVTSizeInBits() == 128)
1816 if (Constraint[1] ==
'v') {
1817 if (!Subtarget.hasVector())
1818 return std::make_pair(
1820 if (getVTSizeInBits() == 16)
1823 if (getVTSizeInBits() == 32)
1826 if (getVTSizeInBits() == 64)
1832 if (Constraint[1] ==
'@') {
1833 if (
StringRef(
"{@cc}").compare(Constraint) == 0)
1834 return std::make_pair(SystemZ::CC, &SystemZ::CCRRegClass);
1847 .
Case(
"r4", Subtarget.isTargetXPLINK64() ? SystemZ::R4D
1848 : SystemZ::NoRegister)
1850 Subtarget.isTargetELF() ? SystemZ::R15D : SystemZ::NoRegister)
1858 return Subtarget.isTargetXPLINK64() ? SystemZ::R1D : SystemZ::R6D;
1863 return Subtarget.isTargetXPLINK64() ? SystemZ::R2D : SystemZ::R7D;
1878 if (
StringRef(
"{@cc}").compare(OpInfo.ConstraintCode) != 0)
1882 if (OpInfo.ConstraintVT.isVector() || !OpInfo.ConstraintVT.isInteger() ||
1883 OpInfo.ConstraintVT.getSizeInBits() < 8)
1898 if (Constraint.
size() == 1) {
1899 switch (Constraint[0]) {
1904 Op.getValueType()));
1911 Op.getValueType()));
1918 C->getSExtValue(),
SDLoc(
Op),
Op.getValueType()));
1925 C->getSExtValue(),
SDLoc(
Op),
Op.getValueType()));
1930 if (
C->getZExtValue() == 0x7fffffff)
1932 Op.getValueType()));
1943#define GET_CALLING_CONV_IMPL
1944#include "SystemZGenCallingConv.inc"
1948 static const MCPhysReg ScratchRegs[] = { SystemZ::R0D, SystemZ::R1D,
1954 Type *ToType)
const {
2017 if (BitCastToType == MVT::v2i64)
2041 return DAG.
getNode(SystemZISD::PAIR128,
DL, MVT::v2i64,
Hi,
Lo);
2064 unsigned NumParts,
MVT PartVT, std::optional<CallingConv::ID>
CC)
const {
2077 MVT PartVT,
EVT ValueVT, std::optional<CallingConv::ID>
CC)
const {
2089template <
class ArgTy>
2093 if (!Args[
I].Flags.isSplit())
2097 PartVT = ArgLocs[
I].getValVT();
2099 for (
unsigned PartIdx =
I + 1;; ++PartIdx) {
2100 assert(PartIdx != ArgLocs.
size() &&
"SplitEnd not found.");
2101 assert(ArgLocs[PartIdx].getValVT() == PartVT &&
"Unsupported split.");
2103 if (Args[PartIdx].Flags.isSplitEnd())
2121 ADAvReg =
MRI.createVirtualRegister(&SystemZ::ADDR64BitRegClass);
2124 MRI.addLiveIn(Regs->getADARegister(), ADAvReg);
2147 unsigned NumFixedGPRs = 0;
2148 unsigned NumFixedFPRs = 0;
2149 for (
unsigned I = 0, E = ArgLocs.
size();
I != E; ++
I) {
2162 RC = &SystemZ::GR32BitRegClass;
2166 RC = &SystemZ::GR64BitRegClass;
2170 RC = &SystemZ::FP16BitRegClass;
2174 RC = &SystemZ::FP32BitRegClass;
2178 RC = &SystemZ::FP64BitRegClass;
2182 RC = &SystemZ::FP128BitRegClass;
2191 RC = &SystemZ::VR128BitRegClass;
2205 if (Subtarget.isTargetXPLINK64()) {
2208 ArgSPOffset += XPRegs.getCallFrameSize();
2219 unsigned SlotOffs = VA.
getLocVT() == MVT::f16 ? 6 : 4;
2223 ArgValue = DAG.
getLoad(LocVT,
DL, Chain, FIN,
2237 for (
unsigned PartIdx = 1; PartIdx <
NumParts; ++PartIdx) {
2240 unsigned PartOffset = Ins[
I].PartOffset;
2245 assert(PartOffset &&
"Offset should be non-zero.");
2248 }
else if (Subtarget.isTargetXPLINK64() &&
2251 Ins[
I].ArgVT.isSimple()) {
2256 MVT OrigVT = Ins[
I].ArgVT.getSimpleVT();
2262 if (IsVarArg && Subtarget.isTargetXPLINK64()) {
2268 Subtarget.getSpecialRegisters());
2274 int64_t VarArgOffset = CCInfo.
getStackSize() + Regs->getCallFrameSize();
2279 if (IsVarArg && Subtarget.isTargetELF()) {
2292 int64_t RegSaveOffset =
2307 &SystemZ::FP64BitRegClass);
2328 for (
unsigned I = 0,
E = ArgLocs.
size();
I !=
E; ++
I) {
2335 if (
Reg == SystemZ::R6H ||
Reg == SystemZ::R6L ||
Reg == SystemZ::R6D)
2337 if (Outs[
I].Flags.isSwiftSelf() || Outs[
I].Flags.isSwiftError())
2344 unsigned Offset,
bool LoadAdr =
false) {
2366 bool LoadAddr =
false;
2388 unsigned ADADelta = 0;
2389 unsigned EPADelta = 8;
2395 bool IsInternal = (
G->getGlobal()->hasInternalLinkage() ||
2396 G->getGlobal()->hasPrivateLinkage());
2401 Callee = DAG.
getNode(SystemZISD::PCREL_WRAPPER,
DL, PtrVT, Callee);
2447 if (Subtarget.isTargetXPLINK64()) {
2454 verifyNarrowIntegerArgs_Call(CLI, Outs, &MF.
getFunction(), Callee);
2458 CCState ArgCCInfo(CallConv, IsVarArg, MF, ArgLocs, Ctx);
2468 "site marked musttail");
2481 for (
unsigned I = 0, E = ArgLocs.
size();
I != E; ++
I) {
2493 SlotVT = Outs[
I].VT;
2500 DAG.
getStore(Chain,
DL, ArgValue, SpillSlot, StackPtrInfo));
2503 assert(Outs[
I].PartOffset == 0);
2504 for (
unsigned PartIdx = 1; PartIdx <
NumParts; ++PartIdx) {
2507 unsigned PartOffset = Outs[
I].PartOffset;
2513 assert(PartOffset &&
"Offset should be non-zero.");
2515 SlotVT.
getStoreSize()) &&
"Not enough space for argument part!");
2517 ArgValue = SpillSlot;
2534 if (!StackPtr.getNode())
2541 else if (VA.
getLocVT() == MVT::f16)
2554 if (Subtarget.isTargetXPLINK64() && VA.
needsCustom()) {
2558 RegsToPass.
push_back(std::make_pair(SystemZ::R3D, ShadowArgValue));
2564 if (!MemOpChains.
empty())
2572 if (Subtarget.isTargetXPLINK64()) {
2577 ->getAddressOfCalleeRegister();
2580 Callee = DAG.
getRegister(CalleeReg, Callee.getValueType());
2587 Callee = DAG.
getNode(SystemZISD::PCREL_WRAPPER,
DL, PtrVT, Callee);
2590 Callee = DAG.
getNode(SystemZISD::PCREL_WRAPPER,
DL, PtrVT, Callee);
2591 }
else if (IsTailCall) {
2594 Callee = DAG.
getRegister(SystemZ::R1D, Callee.getValueType());
2599 for (
const auto &[Reg,
N] : RegsToPass) {
2606 Ops.push_back(Chain);
2607 Ops.push_back(Callee);
2611 for (
const auto &[Reg,
N] : RegsToPass)
2616 const uint32_t *Mask =
TRI->getCallPreservedMask(MF, CallConv);
2617 assert(Mask &&
"Missing call preserved mask for calling convention");
2622 Ops.push_back(Glue);
2631 Chain = DAG.
getNode(SystemZISD::CALL,
DL, NodeTys,
Ops);
2641 CCState RetCCInfo(CallConv, IsVarArg, MF, RetLocs, Ctx);
2648 VA.getLocVT(), Glue);
2665 bool DoesNotReturn,
bool IsReturnValueUsed)
const {
2667 Args.reserve(
Ops.size());
2673 Entry.IsZExt = !Entry.IsSExt;
2674 Args.push_back(Entry);
2685 .
setCallee(CallConv, RetTy, Callee, std::move(Args))
2696 const Type *RetTy)
const {
2699 for (
auto &Out : Outs)
2700 if (Out.ArgVT.isScalarInteger() && Out.ArgVT.getSizeInBits() > 64)
2704 CCState RetCCInfo(CallConv, IsVarArg, MF, RetLocs, Context);
2705 return RetCCInfo.
CheckReturn(Outs, RetCC_SystemZ);
2717 verifyNarrowIntegerArgs_Ret(CallConv, Outs, &MF.
getFunction());
2725 if (RetLocs.
empty())
2726 return DAG.
getNode(SystemZISD::RET_GLUE,
DL, MVT::Other, Chain);
2735 for (
unsigned I = 0, E = RetLocs.
size();
I != E; ++
I) {
2757 return DAG.
getNode(SystemZISD::RET_GLUE,
DL, MVT::Other, RetOps);
2764 unsigned &CCValid) {
2765 unsigned Id =
Op.getConstantOperandVal(1);
2767 case Intrinsic::s390_tbegin:
2768 Opcode = SystemZISD::TBEGIN;
2772 case Intrinsic::s390_tbegin_nofloat:
2773 Opcode = SystemZISD::TBEGIN_NOFLOAT;
2777 case Intrinsic::s390_tend:
2778 Opcode = SystemZISD::TEND;
2791 unsigned Id =
Op.getConstantOperandVal(0);
2793 case Intrinsic::s390_vpkshs:
2794 case Intrinsic::s390_vpksfs:
2795 case Intrinsic::s390_vpksgs:
2796 Opcode = SystemZISD::PACKS_CC;
2800 case Intrinsic::s390_vpklshs:
2801 case Intrinsic::s390_vpklsfs:
2802 case Intrinsic::s390_vpklsgs:
2803 Opcode = SystemZISD::PACKLS_CC;
2807 case Intrinsic::s390_vceqbs:
2808 case Intrinsic::s390_vceqhs:
2809 case Intrinsic::s390_vceqfs:
2810 case Intrinsic::s390_vceqgs:
2811 case Intrinsic::s390_vceqqs:
2812 Opcode = SystemZISD::VICMPES;
2816 case Intrinsic::s390_vchbs:
2817 case Intrinsic::s390_vchhs:
2818 case Intrinsic::s390_vchfs:
2819 case Intrinsic::s390_vchgs:
2820 case Intrinsic::s390_vchqs:
2821 Opcode = SystemZISD::VICMPHS;
2825 case Intrinsic::s390_vchlbs:
2826 case Intrinsic::s390_vchlhs:
2827 case Intrinsic::s390_vchlfs:
2828 case Intrinsic::s390_vchlgs:
2829 case Intrinsic::s390_vchlqs:
2830 Opcode = SystemZISD::VICMPHLS;
2834 case Intrinsic::s390_vtm:
2835 Opcode = SystemZISD::VTM;
2839 case Intrinsic::s390_vfaebs:
2840 case Intrinsic::s390_vfaehs:
2841 case Intrinsic::s390_vfaefs:
2842 Opcode = SystemZISD::VFAE_CC;
2846 case Intrinsic::s390_vfaezbs:
2847 case Intrinsic::s390_vfaezhs:
2848 case Intrinsic::s390_vfaezfs:
2849 Opcode = SystemZISD::VFAEZ_CC;
2853 case Intrinsic::s390_vfeebs:
2854 case Intrinsic::s390_vfeehs:
2855 case Intrinsic::s390_vfeefs:
2856 Opcode = SystemZISD::VFEE_CC;
2860 case Intrinsic::s390_vfeezbs:
2861 case Intrinsic::s390_vfeezhs:
2862 case Intrinsic::s390_vfeezfs:
2863 Opcode = SystemZISD::VFEEZ_CC;
2867 case Intrinsic::s390_vfenebs:
2868 case Intrinsic::s390_vfenehs:
2869 case Intrinsic::s390_vfenefs:
2870 Opcode = SystemZISD::VFENE_CC;
2874 case Intrinsic::s390_vfenezbs:
2875 case Intrinsic::s390_vfenezhs:
2876 case Intrinsic::s390_vfenezfs:
2877 Opcode = SystemZISD::VFENEZ_CC;
2881 case Intrinsic::s390_vistrbs:
2882 case Intrinsic::s390_vistrhs:
2883 case Intrinsic::s390_vistrfs:
2884 Opcode = SystemZISD::VISTR_CC;
2888 case Intrinsic::s390_vstrcbs:
2889 case Intrinsic::s390_vstrchs:
2890 case Intrinsic::s390_vstrcfs:
2891 Opcode = SystemZISD::VSTRC_CC;
2895 case Intrinsic::s390_vstrczbs:
2896 case Intrinsic::s390_vstrczhs:
2897 case Intrinsic::s390_vstrczfs:
2898 Opcode = SystemZISD::VSTRCZ_CC;
2902 case Intrinsic::s390_vstrsb:
2903 case Intrinsic::s390_vstrsh:
2904 case Intrinsic::s390_vstrsf:
2905 Opcode = SystemZISD::VSTRS_CC;
2909 case Intrinsic::s390_vstrszb:
2910 case Intrinsic::s390_vstrszh:
2911 case Intrinsic::s390_vstrszf:
2912 Opcode = SystemZISD::VSTRSZ_CC;
2916 case Intrinsic::s390_vfcedbs:
2917 case Intrinsic::s390_vfcesbs:
2918 Opcode = SystemZISD::VFCMPES;
2922 case Intrinsic::s390_vfchdbs:
2923 case Intrinsic::s390_vfchsbs:
2924 Opcode = SystemZISD::VFCMPHS;
2928 case Intrinsic::s390_vfchedbs:
2929 case Intrinsic::s390_vfchesbs:
2930 Opcode = SystemZISD::VFCMPHES;
2934 case Intrinsic::s390_vftcidb:
2935 case Intrinsic::s390_vftcisb:
2936 Opcode = SystemZISD::VFTCI;
2940 case Intrinsic::s390_tdc:
2941 Opcode = SystemZISD::TDC;
2954 unsigned NumOps =
Op.getNumOperands();
2957 Ops.push_back(
Op.getOperand(0));
2959 Ops.push_back(
Op.getOperand(
I));
2961 assert(
Op->getNumValues() == 2 &&
"Expected only CC result and chain");
2975 unsigned NumOps =
Op.getNumOperands();
2981 assert((
Op.getConstantOperandVal(0) == Intrinsic::s390_tdc &&
I == 1) &&
2982 "Unhandled intrinsic with f16 operand.");
2985 Ops.push_back(CurrOper);
2999 case ISD::SET##X: return SystemZ::CCMASK_CMP_##X; \
3000 case ISD::SETO##X: return SystemZ::CCMASK_CMP_##X; \
3001 case ISD::SETU##X: return SystemZ::CCMASK_CMP_UO | SystemZ::CCMASK_CMP_##X
3027 if (!ConstOp1 || ConstOp1->getValueSizeInBits(0) > 64)
3030 int64_t
Value = ConstOp1->getSExtValue();
3046 if (!
C.Op0.hasOneUse() ||
3053 unsigned NumBits =
Load->getMemoryVT().getSizeInBits();
3054 if ((NumBits != 8 && NumBits != 16) ||
3055 NumBits !=
Load->getMemoryVT().getStoreSizeInBits())
3061 if (!ConstOp1 || ConstOp1->getValueSizeInBits(0) > 64)
3064 uint64_t Mask = (1 << NumBits) - 1;
3067 int64_t SignedValue = ConstOp1->getSExtValue();
3074 }
else if (NumBits == 8) {
3100 if (
C.Op0.getValueType() != MVT::i32 ||
3101 Load->getExtensionType() != ExtType) {
3103 Load->getBasePtr(),
Load->getPointerInfo(),
3104 Load->getMemoryVT(),
Load->getAlign(),
3105 Load->getMemOperand()->getFlags());
3111 if (
C.Op1.getValueType() != MVT::i32 ||
3112 Value != ConstOp1->getZExtValue())
3122 if (
Load->getMemoryVT() == MVT::i8)
3125 switch (
Load->getExtensionType()) {
3143 if (
C.Op0.isMachineOpcode() &&
3144 (
C.Op0.getMachineOpcode() == SystemZ::LOAD_STACK_GUARD))
3148 if (
C.Op0.getValueType() == MVT::i128)
3150 if (
C.Op0.getValueType() == MVT::f128)
3162 if (ConstOp1 && ConstOp1->getZExtValue() == 0)
3191 unsigned Opcode0 =
C.Op0.getOpcode();
3198 C.Op0.getConstantOperandVal(1) == 0xffffffff)
3213 ((
N->getOperand(0) ==
C.Op0 &&
N->getOperand(1) ==
C.Op1) ||
3214 (
N->getOperand(0) ==
C.Op1 &&
N->getOperand(1) ==
C.Op0))) {
3236 if (
C1 &&
C1->isZero()) {
3255 if (
C.Op0.getOpcode() ==
ISD::SHL &&
C.Op0.getValueType() == MVT::i64 &&
3258 if (
C1 &&
C1->getZExtValue() == 32) {
3259 SDValue ShlOp0 =
C.Op0.getOperand(0);
3278 C.Op0.getOperand(0).getOpcode() ==
ISD::LOAD &&
3281 C.Op1->getAsZExtVal() == 0) {
3283 if (L->getMemoryVT().getStoreSizeInBits().getFixedValue() <=
3284 C.Op0.getValueSizeInBits().getFixedValue()) {
3285 unsigned Type = L->getExtensionType();
3288 C.Op0 =
C.Op0.getOperand(0);
3304 if (
C.Opcode != SystemZISD::ICMP)
3314 if (!
C.Op1.isMachineOpcode() ||
3315 C.Op1.getMachineOpcode() != SystemZ::LOAD_STACK_GUARD)
3320 C.Opcode = SystemZISD::CMP_STACKGUARD;
3331 uint64_t Amount = Shift->getZExtValue();
3332 if (Amount >=
N.getValueSizeInBits())
3347 unsigned ICmpType) {
3348 assert(Mask != 0 &&
"ANDs with zero should have been removed by now");
3370 if (EffectivelyUnsigned && CmpVal > 0 && CmpVal <=
Low) {
3376 if (EffectivelyUnsigned && CmpVal <
Low) {
3384 if (CmpVal == Mask) {
3390 if (EffectivelyUnsigned && CmpVal >= Mask -
Low && CmpVal < Mask) {
3396 if (EffectivelyUnsigned && CmpVal > Mask -
Low && CmpVal <= Mask) {
3404 if (EffectivelyUnsigned && CmpVal >= Mask -
High && CmpVal <
High) {
3410 if (EffectivelyUnsigned && CmpVal > Mask -
High && CmpVal <=
High) {
3439 if (
C.Op0.getValueType() == MVT::i128) {
3445 if (Mask && Mask->getAPIntValue() == 0) {
3446 C.Opcode = SystemZISD::VTM;
3463 uint64_t CmpVal = ConstOp1->getZExtValue();
3470 NewC.Op0 =
C.Op0.getOperand(0);
3471 NewC.Op1 =
C.Op0.getOperand(1);
3475 MaskVal = Mask->getZExtValue();
3495 MaskVal = -(CmpVal & -CmpVal);
3504 unsigned NewCCMask, ShiftVal;
3508 (MaskVal >> ShiftVal != 0) &&
3509 ((CmpVal >> ShiftVal) << ShiftVal) == CmpVal &&
3511 MaskVal >> ShiftVal,
3515 MaskVal >>= ShiftVal;
3519 (MaskVal << ShiftVal != 0) &&
3520 ((CmpVal << ShiftVal) >> ShiftVal) == CmpVal &&
3522 MaskVal << ShiftVal,
3526 MaskVal <<= ShiftVal;
3535 C.Opcode = SystemZISD::TM;
3537 if (Mask && Mask->getZExtValue() == MaskVal)
3542 C.CCMask = NewCCMask;
3548 if (
C.Opcode != SystemZISD::ICMP)
3550 if (
C.Op0.getValueType() != MVT::i128)
3561 Src = Src.getOperand(0);
3564 unsigned Opcode = 0;
3565 if (Src.hasOneUse()) {
3566 switch (Src.getOpcode()) {
3567 case SystemZISD::VICMPE: Opcode = SystemZISD::VICMPES;
break;
3568 case SystemZISD::VICMPH: Opcode = SystemZISD::VICMPHS;
break;
3569 case SystemZISD::VICMPHL: Opcode = SystemZISD::VICMPHLS;
break;
3570 case SystemZISD::VFCMPE: Opcode = SystemZISD::VFCMPES;
break;
3571 case SystemZISD::VFCMPH: Opcode = SystemZISD::VFCMPHS;
break;
3572 case SystemZISD::VFCMPHE: Opcode = SystemZISD::VFCMPHES;
break;
3578 C.Op0 = Src->getOperand(0);
3579 C.Op1 = Src->getOperand(1);
3583 C.CCMask ^=
C.CCValid;
3595 C.Opcode = SystemZISD::VICMPES;
3607 bool Swap =
false, Invert =
false;
3619 C.Opcode = SystemZISD::UCMP128HI;
3621 C.Opcode = SystemZISD::SCMP128HI;
3626 C.CCMask ^=
C.CCValid;
3637 if (!Mask || Mask->getValueSizeInBits(0) > 64)
3640 if ((~
Known.Zero).getZExtValue() & ~Mask->getZExtValue())
3643 C.Op0 =
C.Op0.getOperand(0);
3655 C.CCValid = CCValid;
3658 C.CCMask =
CC < 4 ? 1 << (3 -
CC) : 0;
3661 C.CCMask =
CC < 4 ? ~(1 << (3 -
CC)) : -1;
3665 C.CCMask =
CC < 4 ? ~0U << (4 -
CC) : -1;
3668 C.CCMask =
CC < 4 ? ~(~0U << (4 -
CC)) : 0;
3672 C.CCMask =
CC < 4 ? ~0U << (3 -
CC) : -1;
3675 C.CCMask =
CC < 4 ? ~(~0U << (3 -
CC)) : 0;
3678 C.CCMask &= CCValid;
3686 bool IsSignaling =
false) {
3689 unsigned Opcode, CCValid;
3701 Comparison
C(CmpOp0, CmpOp1, Chain);
3703 if (
C.Op0.getValueType().isFloatingPoint()) {
3706 C.Opcode = SystemZISD::FCMP;
3707 else if (!IsSignaling)
3708 C.Opcode = SystemZISD::STRICT_FCMP;
3710 C.Opcode = SystemZISD::STRICT_FCMPS;
3715 C.Opcode = SystemZISD::ICMP;
3751 if (!
C.Op1.getNode()) {
3752 if (
C.Opcode == SystemZISD::CMP_STACKGUARD)
3753 return DAG.
getNode(SystemZISD::CMP_STACKGUARD,
DL, MVT::i32,
C.Op0);
3755 switch (
C.Op0.getOpcode()) {
3766 if (
C.Opcode == SystemZISD::ICMP)
3767 return DAG.
getNode(SystemZISD::ICMP,
DL, MVT::i32,
C.Op0,
C.Op1,
3769 if (
C.Opcode == SystemZISD::TM) {
3772 return DAG.
getNode(SystemZISD::TM,
DL, MVT::i32,
C.Op0,
C.Op1,
3775 if (
C.Opcode == SystemZISD::VICMPES ||
3776 C.Opcode == SystemZISD::VICMPHS ||
3777 C.Opcode == SystemZISD::VICMPHLS ||
3778 C.Opcode == SystemZISD::VFCMPES ||
3779 C.Opcode == SystemZISD::VFCMPHS ||
3780 C.Opcode == SystemZISD::VFCMPHES) {
3781 EVT IntVT =
C.Op0.getValueType().changeVectorElementTypeToInteger();
3788 return DAG.
getNode(
C.Opcode,
DL, VTs,
C.Chain,
C.Op0,
C.Op1);
3790 return DAG.
getNode(
C.Opcode,
DL, MVT::i32,
C.Op0,
C.Op1);
3799 Op0 = DAG.
getNode(Extend,
DL, MVT::i64, Op0);
3800 Op1 = DAG.
getNode(Extend,
DL, MVT::i64, Op1);
3825 unsigned CCValid,
unsigned CCMask) {
3830 return DAG.
getNode(SystemZISD::SELECT_CCMASK,
DL, MVT::i32,
Ops);
3908 int Mask[] = { Start, -1, Start + 1, -1 };
3912 return DAG.
getNode(SystemZISD::STRICT_VEXTEND,
DL, VTs, Chain,
Op);
3914 return DAG.
getNode(SystemZISD::VEXTEND,
DL, MVT::v2f64,
Op);
3928 !Subtarget.hasVectorEnhancements1()) {
3934 SDVTList VTs = DAG.
getVTList(MVT::v2i64, MVT::Other);
3947 return DAG.
getNode(SystemZISD::PACK,
DL, VT, HRes, LRes);
3950 SDVTList VTs = DAG.
getVTList(VT, MVT::Other);
3951 return DAG.
getNode(Opcode,
DL, VTs, Chain, CmpOp0, CmpOp1);
3953 return DAG.
getNode(Opcode,
DL, VT, CmpOp0, CmpOp1);
3966 bool IsSignaling)
const {
3969 assert (!IsSignaling || Chain);
3972 bool Invert =
false;
3980 assert(IsFP &&
"Unexpected integer comparison");
3982 DL, VT, CmpOp1, CmpOp0, Chain);
3984 DL, VT, CmpOp0, CmpOp1, Chain);
3988 LT.getValue(1),
GE.getValue(1));
3997 assert(IsFP &&
"Unexpected integer comparison");
3999 DL, VT, CmpOp1, CmpOp0, Chain);
4001 DL, VT, CmpOp0, CmpOp1, Chain);
4005 LT.getValue(1),
GT.getValue(1));
4026 Cmp = getVectorCmp(DAG, Opcode,
DL, VT, CmpOp0, CmpOp1, Chain);
4030 Cmp = getVectorCmp(DAG, Opcode,
DL, VT, CmpOp1, CmpOp0, Chain);
4035 Chain =
Cmp.getValue(1);
4043 if (Chain && Chain.
getNode() !=
Cmp.getNode()) {
4056 EVT VT =
Op.getValueType();
4058 return lowerVectorSETCC(DAG,
DL, VT,
CC, CmpOp0, CmpOp1);
4067 bool IsSignaling)
const {
4073 EVT VT =
Op.getNode()->getValueType(0);
4075 SDValue Res = lowerVectorSETCC(DAG,
DL, VT,
CC, CmpOp0, CmpOp1,
4076 Chain, IsSignaling);
4098 SystemZISD::BR_CCMASK,
DL,
Op.getValueType(),
Op.getOperand(0),
4132 C.CCMask ^=
C.CCValid;
4140 Op = SystemZISD::VICMPE;
4144 Op = SystemZISD::VICMPHL;
4146 Op = SystemZISD::VICMPH;
4185 C.Op1->getAsZExtVal() == 0) {
4192 if (Subtarget.hasVectorEnhancements3() &&
4193 C.Opcode == SystemZISD::ICMP &&
4194 C.Op0.getValueType() == MVT::i128 &&
4204 return DAG.
getNode(SystemZISD::SELECT_CCMASK,
DL,
Op.getValueType(),
Ops);
4210 const GlobalValue *GV =
Node->getGlobal();
4216 if (Subtarget.isPC32DBLSymbol(GV, CM)) {
4238 }
else if (Subtarget.isTargetELF()) {
4243 }
else if (Subtarget.isTargetzOS()) {
4274 Chain = DAG.
getCopyToReg(Chain,
DL, SystemZ::R2D, GOTOffset, Glue);
4279 Ops.push_back(Chain);
4281 Node->getValueType(0),
4290 const TargetRegisterInfo *
TRI = Subtarget.getRegisterInfo();
4291 const uint32_t *
Mask =
4293 assert(Mask &&
"Missing call preserved mask for calling convention");
4297 Ops.push_back(Glue);
4300 SDVTList NodeTys = DAG.
getVTList(MVT::Other, MVT::Glue);
4308SDValue SystemZTargetLowering::lowerThreadPointer(
const SDLoc &
DL,
4332 const GlobalValue *GV =
Node->getGlobal();
4340 SDValue TP = lowerThreadPointer(
DL, DAG);
4347 SystemZConstantPoolValue *CPV =
4356 Offset = lowerTLSGetOffset(Node, DAG, SystemZISD::TLS_GDCALL,
Offset);
4362 SystemZConstantPoolValue *CPV =
4371 Offset = lowerTLSGetOffset(Node, DAG, SystemZISD::TLS_LDCALL,
Offset);
4376 SystemZMachineFunctionInfo* MFI =
4405 SystemZConstantPoolValue *CPV =
4439 return DAG.
getNode(SystemZISD::PCREL_WRAPPER,
DL, PtrVT, Result);
4456 return DAG.
getNode(SystemZISD::PCREL_WRAPPER,
DL, PtrVT, Result);
4461 auto *TFL = Subtarget.getFrameLowering<SystemZFrameLowering>();
4463 MachineFrameInfo &MFI = MF.getFrameInfo();
4467 unsigned Depth =
Op.getConstantOperandVal(0);
4474 int BackChainIdx = TFL->getOrCreateFramePointerSaveIndex(MF);
4479 if (!MF.getSubtarget<SystemZSubtarget>().hasBackChain())
4485 MachinePointerInfo());
4500 unsigned Depth =
Op.getConstantOperandVal(0);
4505 if (!MF.
getSubtarget<SystemZSubtarget>().hasBackChain())
4508 SDValue FrameAddr = lowerFRAMEADDR(
Op, DAG);
4509 const auto *TFL = Subtarget.getFrameLowering<SystemZFrameLowering>();
4510 int Offset = TFL->getReturnAddressOffset(MF);
4514 MachinePointerInfo());
4519 SystemZCallingConventionRegisters *CCR = Subtarget.getSpecialRegisters();
4521 &SystemZ::GR64BitRegClass);
4529 EVT InVT =
In.getValueType();
4530 EVT ResVT =
Op.getValueType();
4538 LoadN->getBasePtr(), LoadN->getMemOperand());
4544 if (InVT == MVT::i32 && ResVT == MVT::f32) {
4546 if (Subtarget.hasHighWord()) {
4550 MVT::i64,
SDValue(U64, 0), In);
4558 DL, MVT::f32, Out64);
4560 if (InVT == MVT::f32 && ResVT == MVT::i32) {
4563 MVT::f64,
SDValue(U64, 0), In);
4565 if (Subtarget.hasHighWord())
4578 if (Subtarget.isTargetXPLINK64())
4579 return lowerVASTART_XPLINK(
Op, DAG);
4581 return lowerVASTART_ELF(
Op, DAG);
4587 SystemZMachineFunctionInfo *FuncInfo =
4588 MF.
getInfo<SystemZMachineFunctionInfo>();
4598 MachinePointerInfo(SV));
4604 SystemZMachineFunctionInfo *FuncInfo =
4605 MF.
getInfo<SystemZMachineFunctionInfo>();
4614 const unsigned NumFields = 4;
4625 for (
unsigned I = 0;
I < NumFields; ++
I) {
4630 MemOps[
I] = DAG.
getStore(Chain,
DL, Fields[
I], FieldAddr,
4631 MachinePointerInfo(SV,
Offset));
4651 nullptr, std::nullopt, MachinePointerInfo(DstSV),
4652 MachinePointerInfo(SrcSV));
4656SystemZTargetLowering::lowerDYNAMIC_STACKALLOC(
SDValue Op,
4658 if (Subtarget.isTargetXPLINK64())
4659 return lowerDYNAMIC_STACKALLOC_XPLINK(
Op, DAG);
4661 return lowerDYNAMIC_STACKALLOC_ELF(
Op, DAG);
4665SystemZTargetLowering::lowerDYNAMIC_STACKALLOC_XPLINK(
SDValue Op,
4667 const TargetFrameLowering *TFI = Subtarget.getFrameLowering();
4677 uint64_t AlignVal = (RealignOpt ?
Align->getAsZExtVal() : 0);
4680 uint64_t RequiredAlign = std::max(AlignVal, StackAlign);
4681 uint64_t ExtraAlignSpace = RequiredAlign - StackAlign;
4687 if (ExtraAlignSpace)
4691 bool IsSigned =
false;
4692 bool DoesNotReturn =
false;
4693 bool IsReturnValueUsed =
false;
4694 EVT VT =
Op.getValueType();
4704 auto &Regs = Subtarget.getSpecialRegisters<SystemZXPLINK64Registers>();
4716 if (ExtraAlignSpace) {
4728SystemZTargetLowering::lowerDYNAMIC_STACKALLOC_ELF(
SDValue Op,
4730 const TargetFrameLowering *TFI = Subtarget.getFrameLowering();
4733 bool StoreBackchain = MF.
getSubtarget<SystemZSubtarget>().hasBackChain();
4742 uint64_t AlignVal = (RealignOpt ?
Align->getAsZExtVal() : 0);
4745 uint64_t RequiredAlign = std::max(AlignVal, StackAlign);
4746 uint64_t ExtraAlignSpace = RequiredAlign - StackAlign;
4757 Backchain = DAG.
getLoad(MVT::i64,
DL, Chain, getBackchainAddress(OldSP, DAG),
4758 MachinePointerInfo());
4761 if (ExtraAlignSpace)
4768 NewSP = DAG.
getNode(SystemZISD::PROBED_ALLOCA,
DL,
4769 DAG.
getVTList(MVT::i64, MVT::Other), Chain, OldSP, NeededSpace);
4785 if (RequiredAlign > StackAlign) {
4795 Chain = DAG.
getStore(Chain,
DL, Backchain, getBackchainAddress(NewSP, DAG),
4796 MachinePointerInfo());
4802SDValue SystemZTargetLowering::lowerGET_DYNAMIC_AREA_OFFSET(
4806 return DAG.
getNode(SystemZISD::ADJDYNALLOC,
DL, MVT::i64);
4811 unsigned Opcode)
const {
4812 EVT VT =
Op.getValueType();
4818 assert(Subtarget.hasMiscellaneousExtensions2());
4823 Op.getOperand(0),
Op.getOperand(1), Even, Odd);
4829 EVT VT =
Op.getValueType();
4837 else if (Subtarget.hasMiscellaneousExtensions2())
4842 Op.getOperand(0),
Op.getOperand(1),
Ops[1],
Ops[0]);
4877 EVT VT =
Op.getValueType();
4890 Op.getOperand(0),
Op.getOperand(1),
Ops[1],
Ops[0]);
4898 EVT VT =
Op.getValueType();
4918 EVT VT =
Op.getValueType();
4925 Op.getOperand(0),
Op.getOperand(1),
Ops[1],
Ops[0]);
4930 assert(
Op.getValueType() == MVT::i64 &&
"Should be 64-bit operation");
4940 Known[1].Zero.getZExtValue() };
4942 if ((Masks[0] >> 32) == 0xffffffff && uint32_t(Masks[1]) == 0xffffffff)
4944 else if ((Masks[1] >> 32) == 0xffffffff && uint32_t(Masks[0]) == 0xffffffff)
4981 MVT::i64, HighOp, Low32);
4987 SDNode *
N =
Op.getNode();
4992 if (
N->getValueType(0) == MVT::i128) {
4993 unsigned BaseOp = 0;
4994 unsigned FlagOp = 0;
4995 bool IsBorrow =
false;
4996 switch (
Op.getOpcode()) {
5000 FlagOp = SystemZISD::VACC;
5004 FlagOp = SystemZISD::VSCBI;
5019 unsigned BaseOp = 0;
5020 unsigned CCValid = 0;
5021 unsigned CCMask = 0;
5023 switch (
Op.getOpcode()) {
5026 BaseOp = SystemZISD::SADDO;
5031 BaseOp = SystemZISD::SSUBO;
5036 BaseOp = SystemZISD::UADDO;
5041 BaseOp = SystemZISD::USUBO;
5047 SDVTList VTs = DAG.
getVTList(
N->getValueType(0), MVT::i32);
5051 if (
N->getValueType(1) == MVT::i1)
5077 SDNode *
N =
Op.getNode();
5078 MVT VT =
N->getSimpleValueType(0);
5089 if (VT == MVT::i128) {
5090 unsigned BaseOp = 0;
5091 unsigned FlagOp = 0;
5092 bool IsBorrow =
false;
5093 switch (
Op.getOpcode()) {
5096 BaseOp = SystemZISD::VAC;
5097 FlagOp = SystemZISD::VACCC;
5100 BaseOp = SystemZISD::VSBI;
5101 FlagOp = SystemZISD::VSBCBI;
5120 unsigned BaseOp = 0;
5121 unsigned CCValid = 0;
5122 unsigned CCMask = 0;
5124 switch (
Op.getOpcode()) {
5130 BaseOp = SystemZISD::ADDCARRY;
5138 BaseOp = SystemZISD::SUBCARRY;
5149 SDVTList VTs = DAG.
getVTList(VT, MVT::i32);
5153 if (
N->getValueType(1) == MVT::i1)
5161 assert(
Op.getValueType() == MVT::i64 &&
"Expected i64 PDEP");
5166 unsigned PopCount = MaskC->getAPIntValue().popcount();
5192 assert(
Op.getValueType() == MVT::i64 &&
"Expected i64 PEXT");
5201 unsigned PopCount = MaskC->getAPIntValue().popcount();
5219 EVT VT =
Op.getValueType();
5221 Op =
Op.getOperand(0);
5244 Op = DAG.
getNode(SystemZISD::VSRL_BY_SCALAR,
DL, VT,
Op, Shift);
5256 Op = DAG.
getNode(SystemZISD::VSUM,
DL, MVT::v4i32,
Op, Tmp);
5270 if (NumSignificantBits == 0)
5276 BitSize = std::min(BitSize, OrigBitSize);
5285 for (int64_t
I = BitSize / 2;
I >= 8;
I =
I / 2) {
5287 if (BitSize != OrigBitSize)
5324 EVT RegVT =
Op.getValueType();
5326 return lowerATOMIC_LDST_I128(
Op, DAG);
5327 return lowerLoadF16(
Op, DAG);
5333 if (
Node->getMemoryVT().getSizeInBits() == 128)
5334 return lowerATOMIC_LDST_I128(
Op, DAG);
5335 return lowerStoreF16(
Op, DAG);
5342 (
Node->getMemoryVT() == MVT::i128 ||
Node->getMemoryVT() == MVT::f128) &&
5343 "Only custom lowering i128 or f128.");
5356 EVT WideVT = MVT::i32;
5377void SystemZTargetLowering::lowerATOMIC_LOAD_OP(
5379 unsigned Opcode)
const {
5382 EVT NarrowVT =
Node->getMemoryVT();
5383 EVT WideVT = MVT::i32;
5388 MachineMemOperand *MMO =
Node->getMemOperand();
5392 if (Opcode == SystemZISD::ATOMIC_LOADW_SUB)
5394 Opcode = SystemZISD::ATOMIC_LOADW_ADD;
5398 SDValue AlignedAddr, BitShift, NegBitShift;
5407 if (Opcode != SystemZISD::ATOMIC_SWAPW)
5410 if (Opcode == SystemZISD::ATOMIC_LOADW_AND ||
5411 Opcode == SystemZISD::ATOMIC_LOADW_NAND)
5416 SDVTList VTList = DAG.
getVTList(WideVT, MVT::Other);
5417 SDValue Ops[] = { ChainIn, AlignedAddr,
Src2, BitShift, NegBitShift,
5436 EVT MemVT =
Node->getMemoryVT();
5437 assert(
Op.getValueType() == MemVT &&
"Mismatched VTs");
5438 assert(Subtarget.hasInterlockedAccess1() &&
5439 "Should have been expanded by AtomicExpand pass.");
5445 Node->getBasePtr(), NegSrc2,
Node->getMemOperand());
5456 MachineMemOperand *MMO =
Node->getMemOperand();
5459 if (
Node->getMemoryVT() == MVT::i128) {
5468 EVT NarrowVT =
Node->getMemoryVT();
5469 EVT WideVT = NarrowVT == MVT::i64 ? MVT::i64 : MVT::i32;
5470 if (NarrowVT == WideVT) {
5471 SDVTList Tys = DAG.
getVTList(WideVT, MVT::i32, MVT::Other);
5472 SDValue Ops[] = { ChainIn, Addr, CmpVal, SwapVal };
5474 DL, Tys,
Ops, NarrowVT, MMO);
5488 SDValue AlignedAddr, BitShift, NegBitShift;
5492 SDVTList VTList = DAG.
getVTList(WideVT, MVT::i32, MVT::Other);
5493 SDValue Ops[] = { ChainIn, AlignedAddr, CmpVal, SwapVal, BitShift,
5496 VTList,
Ops, NarrowVT, MMO);
5510SystemZTargetLowering::getTargetMMOFlags(
const Instruction &
I)
const {
5533 auto *Regs = Subtarget.getSpecialRegisters();
5536 "in GHC calling convention");
5538 Regs->getStackPointerRegister(),
Op.getValueType());
5544 auto *Regs = Subtarget.getSpecialRegisters();
5548 "in GHC calling convention");
5563 if (Subtarget.isTargetXPLINK64()) {
5567 return DAG.
getNode(SystemZISD::XPLINK_STACKRESTORE,
DL, MVT::Other, Chain,
5571 bool StoreBackchain = MF.
getSubtarget<SystemZSubtarget>().hasBackChain();
5573 if (StoreBackchain) {
5575 Chain,
DL, Regs->getStackPointerRegister(), MVT::i64);
5577 DAG.
getLoad(MVT::i64,
DL, Chain, getBackchainAddress(OldSP, DAG),
5578 MachinePointerInfo());
5581 Chain = DAG.
getCopyToReg(Chain,
DL, Regs->getStackPointerRegister(), NewSP);
5584 Chain = DAG.
getStore(Chain,
DL, Backchain, getBackchainAddress(NewSP, DAG),
5585 MachinePointerInfo());
5592 bool IsData =
Op.getConstantOperandVal(4);
5595 return Op.getOperand(0);
5598 bool IsWrite =
Op.getConstantOperandVal(2);
5605 Node->getMemoryVT(),
Node->getMemOperand());
5609SystemZTargetLowering::lowerINTRINSIC_W_CHAIN(
SDValue Op,
5611 unsigned Opcode, CCValid;
5613 assert(
Op->getNumValues() == 2 &&
"Expected only CC result and chain");
5624SystemZTargetLowering::lowerINTRINSIC_WO_CHAIN(
SDValue Op,
5626 unsigned Opcode, CCValid;
5629 if (
Op->getNumValues() == 1)
5631 assert(
Op->getNumValues() == 2 &&
"Expected a CC and non-CC result");
5636 unsigned Id =
Op.getConstantOperandVal(0);
5638 case Intrinsic::thread_pointer:
5639 return lowerThreadPointer(SDLoc(
Op), DAG);
5641 case Intrinsic::s390_vpdi:
5642 return DAG.
getNode(SystemZISD::PERMUTE_DWORDS, SDLoc(
Op),
Op.getValueType(),
5643 Op.getOperand(1),
Op.getOperand(2),
Op.getOperand(3));
5645 case Intrinsic::s390_vperm:
5646 return DAG.
getNode(SystemZISD::PERMUTE, SDLoc(
Op),
Op.getValueType(),
5647 Op.getOperand(1),
Op.getOperand(2),
Op.getOperand(3));
5649 case Intrinsic::s390_vuphb:
5650 case Intrinsic::s390_vuphh:
5651 case Intrinsic::s390_vuphf:
5652 case Intrinsic::s390_vuphg:
5653 return DAG.
getNode(SystemZISD::UNPACK_HIGH, SDLoc(
Op),
Op.getValueType(),
5656 case Intrinsic::s390_vuplhb:
5657 case Intrinsic::s390_vuplhh:
5658 case Intrinsic::s390_vuplhf:
5659 case Intrinsic::s390_vuplhg:
5660 return DAG.
getNode(SystemZISD::UNPACKL_HIGH, SDLoc(
Op),
Op.getValueType(),
5663 case Intrinsic::s390_vuplb:
5664 case Intrinsic::s390_vuplhw:
5665 case Intrinsic::s390_vuplf:
5666 case Intrinsic::s390_vuplg:
5667 return DAG.
getNode(SystemZISD::UNPACK_LOW, SDLoc(
Op),
Op.getValueType(),
5670 case Intrinsic::s390_vupllb:
5671 case Intrinsic::s390_vupllh:
5672 case Intrinsic::s390_vupllf:
5673 case Intrinsic::s390_vupllg:
5674 return DAG.
getNode(SystemZISD::UNPACKL_LOW, SDLoc(
Op),
Op.getValueType(),
5677 case Intrinsic::s390_vsumb:
5678 case Intrinsic::s390_vsumh:
5679 case Intrinsic::s390_vsumgh:
5680 case Intrinsic::s390_vsumgf:
5681 case Intrinsic::s390_vsumqf:
5682 case Intrinsic::s390_vsumqg:
5683 return DAG.
getNode(SystemZISD::VSUM, SDLoc(
Op),
Op.getValueType(),
5684 Op.getOperand(1),
Op.getOperand(2));
5686 case Intrinsic::s390_vaq:
5688 Op.getOperand(1),
Op.getOperand(2));
5689 case Intrinsic::s390_vaccb:
5690 case Intrinsic::s390_vacch:
5691 case Intrinsic::s390_vaccf:
5692 case Intrinsic::s390_vaccg:
5693 case Intrinsic::s390_vaccq:
5694 return DAG.
getNode(SystemZISD::VACC, SDLoc(
Op),
Op.getValueType(),
5695 Op.getOperand(1),
Op.getOperand(2));
5696 case Intrinsic::s390_vacq:
5697 return DAG.
getNode(SystemZISD::VAC, SDLoc(
Op),
Op.getValueType(),
5698 Op.getOperand(1),
Op.getOperand(2),
Op.getOperand(3));
5699 case Intrinsic::s390_vacccq:
5700 return DAG.
getNode(SystemZISD::VACCC, SDLoc(
Op),
Op.getValueType(),
5701 Op.getOperand(1),
Op.getOperand(2),
Op.getOperand(3));
5703 case Intrinsic::s390_vsq:
5705 Op.getOperand(1),
Op.getOperand(2));
5706 case Intrinsic::s390_vscbib:
5707 case Intrinsic::s390_vscbih:
5708 case Intrinsic::s390_vscbif:
5709 case Intrinsic::s390_vscbig:
5710 case Intrinsic::s390_vscbiq:
5711 return DAG.
getNode(SystemZISD::VSCBI, SDLoc(
Op),
Op.getValueType(),
5712 Op.getOperand(1),
Op.getOperand(2));
5713 case Intrinsic::s390_vsbiq:
5714 return DAG.
getNode(SystemZISD::VSBI, SDLoc(
Op),
Op.getValueType(),
5715 Op.getOperand(1),
Op.getOperand(2),
Op.getOperand(3));
5716 case Intrinsic::s390_vsbcbiq:
5717 return DAG.
getNode(SystemZISD::VSBCBI, SDLoc(
Op),
Op.getValueType(),
5718 Op.getOperand(1),
Op.getOperand(2),
Op.getOperand(3));
5720 case Intrinsic::s390_vmhb:
5721 case Intrinsic::s390_vmhh:
5722 case Intrinsic::s390_vmhf:
5723 case Intrinsic::s390_vmhg:
5724 case Intrinsic::s390_vmhq:
5726 Op.getOperand(1),
Op.getOperand(2));
5727 case Intrinsic::s390_vmlhb:
5728 case Intrinsic::s390_vmlhh:
5729 case Intrinsic::s390_vmlhf:
5730 case Intrinsic::s390_vmlhg:
5731 case Intrinsic::s390_vmlhq:
5733 Op.getOperand(1),
Op.getOperand(2));
5735 case Intrinsic::s390_vmahb:
5736 case Intrinsic::s390_vmahh:
5737 case Intrinsic::s390_vmahf:
5738 case Intrinsic::s390_vmahg:
5739 case Intrinsic::s390_vmahq:
5740 return DAG.
getNode(SystemZISD::VMAH, SDLoc(
Op),
Op.getValueType(),
5741 Op.getOperand(1),
Op.getOperand(2),
Op.getOperand(3));
5742 case Intrinsic::s390_vmalhb:
5743 case Intrinsic::s390_vmalhh:
5744 case Intrinsic::s390_vmalhf:
5745 case Intrinsic::s390_vmalhg:
5746 case Intrinsic::s390_vmalhq:
5747 return DAG.
getNode(SystemZISD::VMALH, SDLoc(
Op),
Op.getValueType(),
5748 Op.getOperand(1),
Op.getOperand(2),
Op.getOperand(3));
5750 case Intrinsic::s390_vmeb:
5751 case Intrinsic::s390_vmeh:
5752 case Intrinsic::s390_vmef:
5753 case Intrinsic::s390_vmeg:
5754 return DAG.
getNode(SystemZISD::VME, SDLoc(
Op),
Op.getValueType(),
5755 Op.getOperand(1),
Op.getOperand(2));
5756 case Intrinsic::s390_vmleb:
5757 case Intrinsic::s390_vmleh:
5758 case Intrinsic::s390_vmlef:
5759 case Intrinsic::s390_vmleg:
5760 return DAG.
getNode(SystemZISD::VMLE, SDLoc(
Op),
Op.getValueType(),
5761 Op.getOperand(1),
Op.getOperand(2));
5762 case Intrinsic::s390_vmob:
5763 case Intrinsic::s390_vmoh:
5764 case Intrinsic::s390_vmof:
5765 case Intrinsic::s390_vmog:
5766 return DAG.
getNode(SystemZISD::VMO, SDLoc(
Op),
Op.getValueType(),
5767 Op.getOperand(1),
Op.getOperand(2));
5768 case Intrinsic::s390_vmlob:
5769 case Intrinsic::s390_vmloh:
5770 case Intrinsic::s390_vmlof:
5771 case Intrinsic::s390_vmlog:
5772 return DAG.
getNode(SystemZISD::VMLO, SDLoc(
Op),
Op.getValueType(),
5773 Op.getOperand(1),
Op.getOperand(2));
5775 case Intrinsic::s390_vmaeb:
5776 case Intrinsic::s390_vmaeh:
5777 case Intrinsic::s390_vmaef:
5778 case Intrinsic::s390_vmaeg:
5780 DAG.
getNode(SystemZISD::VME, SDLoc(
Op),
Op.getValueType(),
5781 Op.getOperand(1),
Op.getOperand(2)),
5783 case Intrinsic::s390_vmaleb:
5784 case Intrinsic::s390_vmaleh:
5785 case Intrinsic::s390_vmalef:
5786 case Intrinsic::s390_vmaleg:
5788 DAG.
getNode(SystemZISD::VMLE, SDLoc(
Op),
Op.getValueType(),
5789 Op.getOperand(1),
Op.getOperand(2)),
5791 case Intrinsic::s390_vmaob:
5792 case Intrinsic::s390_vmaoh:
5793 case Intrinsic::s390_vmaof:
5794 case Intrinsic::s390_vmaog:
5796 DAG.
getNode(SystemZISD::VMO, SDLoc(
Op),
Op.getValueType(),
5797 Op.getOperand(1),
Op.getOperand(2)),
5799 case Intrinsic::s390_vmalob:
5800 case Intrinsic::s390_vmaloh:
5801 case Intrinsic::s390_vmalof:
5802 case Intrinsic::s390_vmalog:
5804 DAG.
getNode(SystemZISD::VMLO, SDLoc(
Op),
Op.getValueType(),
5805 Op.getOperand(1),
Op.getOperand(2)),
5826 { SystemZISD::MERGE_HIGH, 8,
5827 { 0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 20, 21, 22, 23 } },
5829 { SystemZISD::MERGE_HIGH, 4,
5830 { 0, 1, 2, 3, 16, 17, 18, 19, 4, 5, 6, 7, 20, 21, 22, 23 } },
5832 { SystemZISD::MERGE_HIGH, 2,
5833 { 0, 1, 16, 17, 2, 3, 18, 19, 4, 5, 20, 21, 6, 7, 22, 23 } },
5835 { SystemZISD::MERGE_HIGH, 1,
5836 { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 } },
5838 { SystemZISD::MERGE_LOW, 8,
5839 { 8, 9, 10, 11, 12, 13, 14, 15, 24, 25, 26, 27, 28, 29, 30, 31 } },
5841 { SystemZISD::MERGE_LOW, 4,
5842 { 8, 9, 10, 11, 24, 25, 26, 27, 12, 13, 14, 15, 28, 29, 30, 31 } },
5844 { SystemZISD::MERGE_LOW, 2,
5845 { 8, 9, 24, 25, 10, 11, 26, 27, 12, 13, 28, 29, 14, 15, 30, 31 } },
5847 { SystemZISD::MERGE_LOW, 1,
5848 { 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31 } },
5850 { SystemZISD::PACK, 4,
5851 { 4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31 } },
5853 { SystemZISD::PACK, 2,
5854 { 2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31 } },
5856 { SystemZISD::PACK, 1,
5857 { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31 } },
5859 { SystemZISD::PERMUTE_DWORDS, 4,
5860 { 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 } },
5862 { SystemZISD::PERMUTE_DWORDS, 1,
5863 { 0, 1, 2, 3, 4, 5, 6, 7, 24, 25, 26, 27, 28, 29, 30, 31 } }
5877 OpNo0 = OpNo1 = OpNos[1];
5878 }
else if (OpNos[1] < 0) {
5879 OpNo0 = OpNo1 = OpNos[0];
5897 unsigned &OpNo0,
unsigned &OpNo1) {
5898 int OpNos[] = { -1, -1 };
5911 if (OpNos[ModelOpNo] == 1 - RealOpNo)
5913 OpNos[ModelOpNo] = RealOpNo;
5921 unsigned &OpNo0,
unsigned &OpNo1) {
5938 int Elt = Bytes[From];
5941 Transform[From] = -1;
5943 while (
P.Bytes[To] != Elt) {
5948 Transform[From] = To;
5972 Bytes.
resize(NumElements * BytesPerElement, -1);
5973 for (
unsigned I = 0;
I < NumElements; ++
I) {
5974 int Index = VSN->getMaskElt(
I);
5976 for (
unsigned J = 0; J < BytesPerElement; ++J)
5977 Bytes[
I * BytesPerElement + J] = Index * BytesPerElement + J;
5981 if (SystemZISD::SPLAT == ShuffleOp.
getOpcode() &&
5984 Bytes.
resize(NumElements * BytesPerElement, -1);
5985 for (
unsigned I = 0;
I < NumElements; ++
I)
5986 for (
unsigned J = 0; J < BytesPerElement; ++J)
5987 Bytes[
I * BytesPerElement + J] = Index * BytesPerElement + J;
5998 unsigned BytesPerElement,
int &
Base) {
6000 for (
unsigned I = 0;
I < BytesPerElement; ++
I) {
6001 if (Bytes[Start +
I] >= 0) {
6002 unsigned Elem = Bytes[Start +
I];
6006 if (
unsigned(
Base) % Bytes.
size() + BytesPerElement > Bytes.
size())
6008 }
else if (
unsigned(
Base) != Elem -
I)
6021 unsigned &StartIndex,
unsigned &OpNo0,
6023 int OpNos[] = { -1, -1 };
6025 for (
unsigned I = 0;
I < 16; ++
I) {
6026 int Index = Bytes[
I];
6032 Shift = ExpectedShift;
6033 else if (Shift != ExpectedShift)
6037 if (OpNos[ModelOpNo] == 1 - RealOpNo)
6039 OpNos[ModelOpNo] = RealOpNo;
6052 unsigned InBytes = (
P.Opcode == SystemZISD::PERMUTE_DWORDS ? 8 :
6053 P.Opcode == SystemZISD::PACK ?
P.Operand * 2 :
6061 if (
P.Opcode == SystemZISD::PERMUTE_DWORDS) {
6063 Op = DAG.
getNode(SystemZISD::PERMUTE_DWORDS,
DL, InVT, Op0, Op1, Op2);
6064 }
else if (
P.Opcode == SystemZISD::PACK) {
6067 Op = DAG.
getNode(SystemZISD::PACK,
DL, OutVT, Op0, Op1);
6076 N =
N->getOperand(0);
6079 return Op->getZExtValue() == 0;
6085 for (
unsigned I = 0;
I < Num ;
I++)
6097 for (
unsigned I = 0;
I < 2; ++
I)
6101 unsigned StartIndex, OpNo0, OpNo1;
6103 return DAG.
getNode(SystemZISD::SHL_DOUBLE,
DL, MVT::v16i8,
Ops[OpNo0],
6110 if (ZeroVecIdx != UINT32_MAX) {
6111 bool MaskFirst =
true;
6116 if (OpNo == ZeroVecIdx &&
I == 0) {
6121 if (OpNo != ZeroVecIdx && Byte == 0) {
6128 if (ZeroIdx != -1) {
6131 if (Bytes[
I] >= 0) {
6134 if (OpNo == ZeroVecIdx)
6146 return DAG.
getNode(SystemZISD::PERMUTE,
DL, MVT::v16i8, Mask, Src,
6149 return DAG.
getNode(SystemZISD::PERMUTE,
DL, MVT::v16i8, Src, Mask,
6161 return DAG.
getNode(SystemZISD::PERMUTE,
DL, MVT::v16i8,
Ops[0],
6167struct GeneralShuffle {
6168 GeneralShuffle(EVT vt)
6169 : VT(vt), UnpackFromEltSize(UINT_MAX), UnpackLow(
false) {}
6173 void tryPrepareForUnpack();
6174 bool unpackWasPrepared() {
return UnpackFromEltSize <= 4; }
6189 unsigned UnpackFromEltSize;
6196void GeneralShuffle::addUndef() {
6198 for (
unsigned I = 0;
I < BytesPerElement; ++
I)
6199 Bytes.push_back(-1);
6208bool GeneralShuffle::add(
SDValue Op,
unsigned Elem) {
6214 EVT FromVT =
Op.getNode() ?
Op.getValueType() : VT;
6219 if (FromBytesPerElement < BytesPerElement)
6223 (FromBytesPerElement - BytesPerElement));
6226 while (
Op.getNode()) {
6228 Op =
Op.getOperand(0);
6244 }
else if (
Op.isUndef()) {
6253 for (; OpNo <
Ops.size(); ++OpNo)
6254 if (
Ops[OpNo] ==
Op)
6256 if (OpNo ==
Ops.size())
6261 for (
unsigned I = 0;
I < BytesPerElement; ++
I)
6262 Bytes.push_back(
Base +
I);
6271 if (
Ops.size() == 0)
6275 tryPrepareForUnpack();
6278 if (
Ops.size() == 1)
6290 unsigned Stride = 1;
6291 for (; Stride * 2 <
Ops.size(); Stride *= 2) {
6292 for (
unsigned I = 0;
I <
Ops.size() - Stride;
I += Stride * 2) {
6302 else if (OpNo ==
I + Stride)
6313 if (NewBytes[J] >= 0) {
6315 "Invalid double permute");
6318 assert(NewBytesMap[J] < 0 &&
"Invalid double permute");
6324 if (NewBytes[J] >= 0)
6340 unsigned OpNo0, OpNo1;
6344 else if (
const Permute *
P =
matchPermute(Bytes, OpNo0, OpNo1))
6349 Op = insertUnpackIfPrepared(DAG,
DL,
Op);
6356 dbgs() <<
Msg.c_str() <<
" { ";
6357 for (
unsigned I = 0;
I < Bytes.
size();
I++)
6358 dbgs() << Bytes[
I] <<
" ";
6366void GeneralShuffle::tryPrepareForUnpack() {
6368 if (ZeroVecOpNo == UINT32_MAX ||
Ops.size() == 1)
6373 if (
Ops.size() > 2 &&
6378 UnpackFromEltSize = 1;
6379 for (; UnpackFromEltSize <= 4; UnpackFromEltSize *= 2) {
6380 bool MatchUnpack =
true;
6383 unsigned ToEltSize = UnpackFromEltSize * 2;
6384 bool IsZextByte = (Elt % ToEltSize) < UnpackFromEltSize;
6387 if (Bytes[Elt] != -1) {
6389 if (IsZextByte != (OpNo == ZeroVecOpNo)) {
6390 MatchUnpack =
false;
6396 if (
Ops.size() == 2) {
6398 bool CanUseUnpackLow =
true, CanUseUnpackHigh =
true;
6400 if (SrcBytes[i] == -1)
6402 if (SrcBytes[i] % 16 !=
int(i))
6403 CanUseUnpackHigh =
false;
6405 CanUseUnpackLow =
false;
6406 if (!CanUseUnpackLow && !CanUseUnpackHigh) {
6407 UnpackFromEltSize = UINT_MAX;
6411 if (!CanUseUnpackHigh)
6417 if (UnpackFromEltSize > 4)
6420 LLVM_DEBUG(
dbgs() <<
"Preparing for final unpack of element size "
6421 << UnpackFromEltSize <<
". Zero vector is Op#" << ZeroVecOpNo
6423 dumpBytes(Bytes,
"Original Bytes vector:"););
6432 Elt += UnpackFromEltSize;
6433 for (
unsigned i = 0; i < UnpackFromEltSize; i++, Elt++,
B++)
6434 Bytes[
B] = Bytes[Elt];
6442 Ops.erase(&
Ops[ZeroVecOpNo]);
6444 if (Bytes[
I] >= 0) {
6446 if (OpNo > ZeroVecOpNo)
6457 if (!unpackWasPrepared())
6459 unsigned InBits = UnpackFromEltSize * 8;
6463 unsigned OutBits = InBits * 2;
6466 return DAG.
getNode(UnpackLow ? SystemZISD::UNPACKL_LOW
6467 : SystemZISD::UNPACKL_HIGH,
6468 DL, OutVT, PackedOp);
6473 for (
unsigned I = 1,
E =
Op.getNumOperands();
I !=
E; ++
I)
6474 if (!
Op.getOperand(
I).isUndef())
6490 if (
Value.isUndef())
6502 return DAG.
getNode(SystemZISD::REPLICATE,
DL, VT, Op1);
6505 return DAG.
getNode(SystemZISD::REPLICATE,
DL, VT, Op0);
6506 return DAG.
getNode(SystemZISD::MERGE_HIGH,
DL, VT,
6527 return DAG.
getNode(SystemZISD::JOIN_DWORDS,
DL, MVT::v2i64, Op0, Op1);
6543 GeneralShuffle GS(VT);
6545 bool FoundOne =
false;
6546 for (
unsigned I = 0;
I < NumElements; ++
I) {
6549 Op =
Op.getOperand(0);
6552 unsigned Elem =
Op.getConstantOperandVal(1);
6553 if (!GS.add(
Op.getOperand(0), Elem))
6556 }
else if (
Op.isUndef()) {
6570 if (!ResidueOps.
empty()) {
6571 while (ResidueOps.
size() < NumElements)
6573 for (
auto &
Op : GS.Ops) {
6574 if (!
Op.getNode()) {
6580 return GS.getNode(DAG,
SDLoc(BVN));
6583bool SystemZTargetLowering::isVectorElementLoad(
SDValue Op)
const {
6589 if (Subtarget.hasVectorEnhancements2() &&
Op.getOpcode() == SystemZISD::LRV)
6600 "Handling full vectors only.");
6620 if (Op01.
getOpcode() == SystemZISD::REPLICATE && Op01 == Op23)
6632 unsigned int NumElements = Elems.
size();
6633 unsigned int Count = 0;
6634 for (
auto Elem : Elems) {
6635 if (!Elem.isUndef()) {
6638 else if (Elem !=
Single) {
6662 bool AllLoads =
true;
6663 for (
auto Elem : Elems)
6664 if (!isVectorElementLoad(Elem)) {
6670 if (VT == MVT::v2i64 && !AllLoads)
6674 if (VT == MVT::v2f64 && !AllLoads)
6684 if (VT == MVT::v4f32 && !AllLoads)
6688 if (VT == MVT::v8f16 && !AllLoads) {
6697 if (Op0123.
getOpcode() == SystemZISD::REPLICATE && Op0123 == Op4567)
6706 unsigned NumConstants = 0;
6707 for (
unsigned I = 0;
I < NumElements; ++
I) {
6721 if (NumConstants > 0) {
6722 for (
unsigned I = 0;
I < NumElements; ++
I)
6733 std::map<const SDNode*, unsigned> UseCounts;
6734 SDNode *LoadMaxUses =
nullptr;
6735 for (
unsigned I = 0;
I < NumElements; ++
I)
6736 if (isVectorElementLoad(Elems[
I])) {
6737 SDNode *Ld = Elems[
I].getNode();
6738 unsigned Count = ++UseCounts[Ld];
6739 if (LoadMaxUses ==
nullptr || UseCounts[LoadMaxUses] <
Count)
6742 if (LoadMaxUses !=
nullptr) {
6743 ReplicatedVal =
SDValue(LoadMaxUses, 0);
6747 unsigned I1 = NumElements / 2 - 1;
6748 unsigned I2 = NumElements - 1;
6749 bool Def1 = !Elems[
I1].isUndef();
6750 bool Def2 = !Elems[I2].isUndef();
6764 for (
unsigned I = 0;
I < NumElements; ++
I)
6765 if (!
Done[
I] && !Elems[
I].
isUndef() && Elems[
I] != ReplicatedVal)
6775 EVT VT =
Op.getValueType();
6777 if (BVN->isConstant()) {
6778 if (SystemZVectorConstantInfo(BVN).isVectorConstantLegal(Subtarget))
6796 for (
unsigned I = 0;
I < NumElements; ++
I)
6798 return buildVector(DAG,
DL, VT,
Ops);
6805 EVT VT =
Op.getValueType();
6808 if (VSN->isSplat()) {
6810 unsigned Index = VSN->getSplatIndex();
6812 "Splat index should be defined and in first operand");
6818 return DAG.
getNode(SystemZISD::SPLAT,
DL, VT,
Op.getOperand(0),
6822 GeneralShuffle
GS(VT);
6823 for (
unsigned I = 0;
I < NumElements; ++
I) {
6824 int Elt = VSN->getMaskElt(
I);
6827 else if (!
GS.add(
Op.getOperand(
unsigned(Elt) / NumElements),
6828 unsigned(Elt) % NumElements))
6831 return GS.getNode(DAG, SDLoc(VSN));
6846 assert(
Op.getSimpleValueType() == MVT::i64 &&
6847 "Expexted to convert i64 to f16.");
6859 assert(
Op.getSimpleValueType() == MVT::f16 &&
6860 "Expected to convert f16 to i64.");
6882 EVT VT =
Op.getValueType();
6885 if (!Subtarget.hasVector())
6910SystemZTargetLowering::lowerEXTRACT_VECTOR_ELT(
SDValue Op,
6916 EVT VT =
Op.getValueType();
6923 if (!Subtarget.hasVector())
6929 MVT ExtrVT = IntVT == MVT::i16 ? MVT::i32 : IntVT;
6937SDValue SystemZTargetLowering::
6940 EVT OutVT =
Op.getValueType();
6944 unsigned StartOffset = 0;
6951 ArrayRef<int> ShuffleMask = SVN->
getMask();
6956 if (ToBits == 64 && OutNumElts == 2) {
6957 int NumElem = ToBits / FromBits;
6958 if (ShuffleMask[0] == NumElem - 1 && ShuffleMask[1] == 2 * NumElem - 1)
6964 int StartOffsetCandidate = -1;
6965 for (
int Elt = 0; Elt < OutNumElts; Elt++) {
6966 if (ShuffleMask[Elt] == -1)
6968 if (ShuffleMask[Elt] % OutNumElts == Elt) {
6969 if (StartOffsetCandidate == -1)
6970 StartOffsetCandidate = ShuffleMask[Elt] - Elt;
6971 if (StartOffsetCandidate == ShuffleMask[Elt] - Elt)
6974 StartOffsetCandidate = -1;
6977 if (StartOffsetCandidate != -1) {
6981 unsigned Offset = StartOffsetCandidate;
6982 unsigned OpNo =
Offset >= InNumElts ? 1 : 0;
6983 StartOffset =
Offset - OpNo * InNumElts;
6992 unsigned Opcode = SystemZISD::UNPACK_HIGH;
6993 if (StartOffset >= OutNumElts) {
6994 Opcode = SystemZISD::UNPACK_LOW;
6995 StartOffset -= OutNumElts;
6997 PackedOp = DAG.
getNode(Opcode, SDLoc(PackedOp), OutVT, PackedOp);
6998 }
while (FromBits != ToBits);
7003SDValue SystemZTargetLowering::
7007 EVT OutVT =
Op.getValueType();
7011 unsigned NumInPerOut = InNumElts / OutNumElts;
7016 SmallVector<int, 16>
Mask(InNumElts);
7017 unsigned ZeroVecElt = InNumElts;
7018 for (
unsigned PackedElt = 0; PackedElt < OutNumElts; PackedElt++) {
7019 unsigned MaskElt = PackedElt * NumInPerOut;
7020 unsigned End = MaskElt + NumInPerOut - 1;
7021 for (; MaskElt <
End; MaskElt++)
7022 Mask[MaskElt] = ZeroVecElt++;
7023 Mask[MaskElt] = PackedElt;
7030 unsigned ByScalar)
const {
7035 EVT VT =
Op.getValueType();
7040 APInt SplatBits, SplatUndef;
7041 unsigned SplatBitSize;
7045 if (BVN->isConstantSplat(SplatBits, SplatUndef, SplatBitSize, HasAnyUndefs,
7046 ElemBitSize,
true) &&
7047 SplatBitSize == ElemBitSize) {
7050 return DAG.
getNode(ByScalar,
DL, VT, Op0, Shift);
7053 BitVector UndefElements;
7059 return DAG.
getNode(ByScalar,
DL, VT, Op0, Shift);
7066 if (VSN->isSplat()) {
7067 SDValue VSNOp0 = VSN->getOperand(0);
7068 unsigned Index = VSN->getSplatIndex();
7070 "Splat index should be defined and in first operand");
7077 return DAG.
getNode(ByScalar,
DL, VT, Op0, Shift);
7095 uint64_t ShiftAmt = ShiftAmtNode->getZExtValue() & 127;
7096 if ((ShiftAmt & 7) == 0 || Subtarget.hasVectorEnhancements2()) {
7099 if (ShiftAmt > 120) {
7103 DAG.
getNode(SystemZISD::SHR_DOUBLE_BIT,
DL, MVT::v16i8, Op0, Op1,
7107 SmallVector<int, 16>
Mask(16);
7108 for (
unsigned Elt = 0; Elt < 16; Elt++)
7109 Mask[Elt] = (ShiftAmt >> 3) + Elt;
7111 if ((ShiftAmt & 7) == 0)
7115 DAG.
getNode(SystemZISD::SHL_DOUBLE_BIT,
DL, MVT::v16i8, Shuf1, Shuf2,
7133 uint64_t ShiftAmt = ShiftAmtNode->getZExtValue() & 127;
7134 if ((ShiftAmt & 7) == 0 || Subtarget.hasVectorEnhancements2()) {
7137 if (ShiftAmt > 120) {
7141 DAG.
getNode(SystemZISD::SHL_DOUBLE_BIT,
DL, MVT::v16i8, Op0, Op1,
7145 SmallVector<int, 16>
Mask(16);
7146 for (
unsigned Elt = 0; Elt < 16; Elt++)
7147 Mask[Elt] = 16 - (ShiftAmt >> 3) + Elt;
7149 if ((ShiftAmt & 7) == 0)
7153 DAG.
getNode(SystemZISD::SHR_DOUBLE_BIT,
DL, MVT::v16i8, Shuf2, Shuf1,
7165 MVT DstVT =
Op.getSimpleValueType();
7168 unsigned SrcAS =
N->getSrcAddressSpace();
7170 assert(SrcAS !=
N->getDestAddressSpace() &&
7171 "addrspacecast must be between different address spaces");
7179 }
else if (DstVT == MVT::i32) {
7193 if (
In.getSimpleValueType() != MVT::f16)
7200 SDValue Chain,
bool IsStrict)
const {
7201 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unexpected request for libcall!");
7204 std::tie(Result, Chain) =
7213 bool IsStrict =
Op->isStrictFPOpcode();
7215 MVT VT =
Op.getSimpleValueType();
7216 SDValue InOp =
Op.getOperand(IsStrict ? 1 : 0);
7224 if (!
Subtarget.hasFPExtension() && !IsSigned)
7235 if (VT == MVT::i128) {
7238 return useLibCall(DAG, LC, VT, InOp,
DL, Chain, IsStrict);
7248 bool IsStrict =
Op->isStrictFPOpcode();
7250 MVT VT =
Op.getSimpleValueType();
7251 SDValue InOp =
Op.getOperand(IsStrict ? 1 : 0);
7256 if (VT == MVT::f16) {
7263 if (!Subtarget.hasFPExtension() && !IsSigned)
7266 if (InVT == MVT::i128) {
7269 return useLibCall(DAG, LC, VT, InOp,
DL, Chain, IsStrict);
7278 EVT RegVT =
Op.getValueType();
7279 assert(RegVT == MVT::f16 &&
"Expected to lower an f16 load.");
7286 assert(EVT(RegVT) == AtomicLd->getMemoryVT() &&
"Unhandled f16 load");
7288 AtomicLd->getChain(), AtomicLd->getBasePtr(),
7289 AtomicLd->getMemOperand());
7292 assert(EVT(RegVT) == Ld->getMemoryVT() &&
"Unhandled f16 load");
7294 Ld->getBasePtr(), Ld->getPointerInfo(), MVT::i16,
7295 Ld->getBaseAlign(), Ld->getMemOperand()->getFlags());
7309 Shft, AtomicSt->getBasePtr(),
7310 AtomicSt->getMemOperand());
7313 return DAG.
getTruncStore(St->getChain(),
DL, Shft, St->getBasePtr(), MVT::i16,
7314 St->getMemOperand());
7320 MVT ResultVT =
Op.getSimpleValueType();
7322 unsigned Check =
Op.getConstantOperandVal(1);
7324 unsigned TDCMask = 0;
7359 MachinePointerInfo MPI =
7365 SystemZISD::STCKF,
DL, DAG.
getVTList(MVT::Other), StoreOps, MVT::i64,
7369 return DAG.
getLoad(MVT::i64,
DL, Chain, StackPtr, MPI);
7374 switch (
Op.getOpcode()) {
7376 return lowerFRAMEADDR(
Op, DAG);
7378 return lowerRETURNADDR(
Op, DAG);
7380 return lowerBR_CC(
Op, DAG);
7382 return lowerSELECT_CC(
Op, DAG);
7384 return lowerSETCC(
Op, DAG);
7386 return lowerSTRICT_FSETCC(
Op, DAG,
false);
7388 return lowerSTRICT_FSETCC(
Op, DAG,
true);
7400 return lowerBITCAST(
Op, DAG);
7402 return lowerVASTART(
Op, DAG);
7404 return lowerVACOPY(
Op, DAG);
7406 return lowerDYNAMIC_STACKALLOC(
Op, DAG);
7408 return lowerGET_DYNAMIC_AREA_OFFSET(
Op, DAG);
7410 return lowerMULH(
Op, DAG, SystemZISD::SMUL_LOHI);
7412 return lowerMULH(
Op, DAG, SystemZISD::UMUL_LOHI);
7414 return lowerSMUL_LOHI(
Op, DAG);
7416 return lowerUMUL_LOHI(
Op, DAG);
7418 return lowerSDIVREM(
Op, DAG);
7420 return lowerUDIVREM(
Op, DAG);
7425 return lowerXALUO(
Op, DAG);
7428 return lowerUADDSUBO_CARRY(
Op, DAG);
7430 return lowerOR(
Op, DAG);
7432 return lowerCTPOP(
Op, DAG);
7434 return lowerPDEP(
Op, DAG);
7436 return lowerPEXT(
Op, DAG);
7438 return lowerVECREDUCE_ADD(
Op, DAG);
7440 return lowerATOMIC_FENCE(
Op, DAG);
7442 return lowerATOMIC_STORE(
Op, DAG);
7444 return lowerATOMIC_LOAD(
Op, DAG);
7446 return lowerATOMIC_LOAD_SUB(
Op, DAG);
7448 return lowerATOMIC_CMP_SWAP(
Op, DAG);
7450 return lowerSTACKSAVE(
Op, DAG);
7452 return lowerSTACKRESTORE(
Op, DAG);
7454 return lowerPREFETCH(
Op, DAG);
7456 return lowerINTRINSIC_W_CHAIN(
Op, DAG);
7458 return lowerINTRINSIC_WO_CHAIN(
Op, DAG);
7460 return lowerBUILD_VECTOR(
Op, DAG);
7462 return lowerVECTOR_SHUFFLE(
Op, DAG);
7464 return lowerSCALAR_TO_VECTOR(
Op, DAG);
7466 return lowerINSERT_VECTOR_ELT(
Op, DAG);
7468 return lowerEXTRACT_VECTOR_ELT(
Op, DAG);
7470 return lowerSIGN_EXTEND_VECTOR_INREG(
Op, DAG);
7472 return lowerZERO_EXTEND_VECTOR_INREG(
Op, DAG);
7474 return lowerShift(
Op, DAG, SystemZISD::VSHL_BY_SCALAR);
7476 return lowerShift(
Op, DAG, SystemZISD::VSRL_BY_SCALAR);
7478 return lowerShift(
Op, DAG, SystemZISD::VSRA_BY_SCALAR);
7482 return lowerShift(
Op, DAG, SystemZISD::VROTL_BY_SCALAR);
7484 return lowerFSHL(
Op, DAG);
7486 return lowerFSHR(
Op, DAG);
7489 return lowerFP_EXTEND(
Op, DAG);
7494 return lower_FP_TO_INT(
Op, DAG);
7499 return lower_INT_TO_FP(
Op, DAG);
7501 return lowerLoadF16(
Op, DAG);
7503 return lowerStoreF16(
Op, DAG);
7505 return lowerIS_FPCLASS(
Op, DAG);
7507 return lowerGET_ROUNDING(
Op, DAG);
7509 return lowerREADCYCLECOUNTER(
Op, DAG);
7531 &SystemZ::FP128BitRegClass);
7540 SystemZ::REG_SEQUENCE, SL, MVT::f128,
7555 &SystemZ::FP128BitRegClass);
7572 switch (
N->getOpcode()) {
7576 SDValue Ops[] = {
N->getOperand(0),
N->getOperand(1) };
7579 DL, Tys,
Ops, MVT::i128, MMO);
7582 if (
N->getValueType(0) == MVT::f128)
7596 SDValue Ops[] = {
N->getOperand(0), Val,
N->getOperand(2)};
7599 DL, Tys,
Ops, MVT::i128, MMO);
7605 MVT::Other, Res), 0);
7617 DL, Tys,
Ops, MVT::i128, MMO);
7631 EVT SrcVT = Src.getValueType();
7632 EVT ResVT =
N->getValueType(0);
7633 if (ResVT == MVT::i128 && SrcVT == MVT::f128)
7635 else if (SrcVT == MVT::i16 && ResVT == MVT::f16) {
7636 if (Subtarget.hasVector()) {
7644 }
else if (SrcVT == MVT::f16 && ResVT == MVT::i16) {
7646 Subtarget.hasVector()
7660 bool IsStrict =
N->isStrictFPOpcode();
7662 SDValue InOp =
N->getOperand(IsStrict ? 1 : 0);
7663 EVT ResVT =
N->getValueType(0);
7665 if (ResVT == MVT::f16) {
7688 bool IsStrict =
N->isStrictFPOpcode();
7690 EVT ResVT =
N->getValueType(0);
7691 SDValue InOp =
N->getOperand(IsStrict ? 1 : 0);
7694 if (InVT == MVT::f16) {
7700 std::tie(InF32, Chain) =
7712 lowerATOMIC_LOAD_OP(
N,
Results, DAG, SystemZISD::ATOMIC_SWAPW);
7715 lowerATOMIC_LOAD_OP(
N,
Results, DAG, SystemZISD::ATOMIC_LOADW_ADD);
7718 lowerATOMIC_LOAD_OP(
N,
Results, DAG, SystemZISD::ATOMIC_LOADW_SUB);
7721 lowerATOMIC_LOAD_OP(
N,
Results, DAG, SystemZISD::ATOMIC_LOADW_AND);
7724 lowerATOMIC_LOAD_OP(
N,
Results, DAG, SystemZISD::ATOMIC_LOADW_OR);
7727 lowerATOMIC_LOAD_OP(
N,
Results, DAG, SystemZISD::ATOMIC_LOADW_XOR);
7730 lowerATOMIC_LOAD_OP(
N,
Results, DAG, SystemZISD::ATOMIC_LOADW_NAND);
7733 lowerATOMIC_LOAD_OP(
N,
Results, DAG, SystemZISD::ATOMIC_LOADW_MIN);
7736 lowerATOMIC_LOAD_OP(
N,
Results, DAG, SystemZISD::ATOMIC_LOADW_MAX);
7739 lowerATOMIC_LOAD_OP(
N,
Results, DAG, SystemZISD::ATOMIC_LOADW_UMIN);
7742 lowerATOMIC_LOAD_OP(
N,
Results, DAG, SystemZISD::ATOMIC_LOADW_UMAX);
7758bool SystemZTargetLowering::canTreatAsByteVector(
EVT VT)
const {
7773 DAGCombinerInfo &DCI,
7781 unsigned Opcode =
Op.getOpcode();
7784 Op =
Op.getOperand(0);
7786 canTreatAsByteVector(
Op.getValueType())) {
7795 BytesPerElement,
First))
7802 if (Byte % BytesPerElement != 0)
7805 Index = Byte / BytesPerElement;
7809 canTreatAsByteVector(
Op.getValueType())) {
7812 EVT OpVT =
Op.getValueType();
7814 if (OpBytesPerElement < BytesPerElement)
7818 unsigned End = (
Index + 1) * BytesPerElement;
7819 if (
End % OpBytesPerElement != 0)
7822 Op =
Op.getOperand(
End / OpBytesPerElement - 1);
7826 if (!
Op.getValueType().isInteger()) {
7831 DCI.AddToWorklist(
Op.getNode());
7834 if (ResIntVT != ResVT) {
7835 DCI.AddToWorklist(
Op.getNode());
7842 canTreatAsByteVector(
Op.getValueType()) &&
7843 canTreatAsByteVector(
Op.getOperand(0).getValueType())) {
7845 EVT ExtVT =
Op.getValueType();
7846 EVT OpVT =
Op.getOperand(0).getValueType();
7849 unsigned Byte =
Index * BytesPerElement;
7850 unsigned SubByte =
Byte % ExtBytesPerElement;
7851 unsigned MinSubByte = ExtBytesPerElement - OpBytesPerElement;
7852 if (SubByte < MinSubByte ||
7853 SubByte + BytesPerElement > ExtBytesPerElement)
7856 Byte =
Byte / ExtBytesPerElement * OpBytesPerElement;
7858 Byte += SubByte - MinSubByte;
7859 if (Byte % BytesPerElement != 0)
7861 Op =
Op.getOperand(0);
7868 if (
Op.getValueType() != VecVT) {
7870 DCI.AddToWorklist(
Op.getNode());
7880SDValue SystemZTargetLowering::combineTruncateExtract(
7889 if (canTreatAsByteVector(VecVT)) {
7893 if (BytesPerElement % TruncBytes == 0) {
7899 unsigned Scale = BytesPerElement / TruncBytes;
7900 unsigned NewIndex = (IndexN->getZExtValue() + 1) * Scale - 1;
7907 EVT ResVT = (TruncBytes < 4 ? MVT::i32 : TruncVT);
7908 return combineExtract(
DL, ResVT, VecVT, Vec, NewIndex, DCI,
true);
7916SDValue SystemZTargetLowering::combineZERO_EXTEND(
7917 SDNode *
N, DAGCombinerInfo &DCI)
const {
7919 SelectionDAG &DAG = DCI.DAG;
7921 EVT VT =
N->getValueType(0);
7922 if (N0.
getOpcode() == SystemZISD::SELECT_CCMASK) {
7925 if (TrueOp && FalseOp) {
7935 DCI.CombineTo(N0.
getNode(), TruncSelect);
7978 return DAG.
getNode(SystemZISD::VSCBI, SDLoc(N0), VT, Op0, Op1);
7996SDValue SystemZTargetLowering::combineSIGN_EXTEND_INREG(
7997 SDNode *
N, DAGCombinerInfo &DCI)
const {
8001 SelectionDAG &DAG = DCI.DAG;
8003 EVT VT =
N->getValueType(0);
8017SDValue SystemZTargetLowering::combineSIGN_EXTEND(
8018 SDNode *
N, DAGCombinerInfo &DCI)
const {
8022 SelectionDAG &DAG = DCI.DAG;
8024 EVT VT =
N->getValueType(0);
8031 unsigned NewShlAmt = ShlAmt->getZExtValue() + Extra;
8032 unsigned NewSraAmt = SraAmt->getZExtValue() + Extra;
8048SDValue SystemZTargetLowering::combineMERGE(
8049 SDNode *
N, DAGCombinerInfo &DCI)
const {
8050 SelectionDAG &DAG = DCI.DAG;
8051 unsigned Opcode =
N->getOpcode();
8059 if (Op1 ==
N->getOperand(0))
8064 if (ElemBytes <= 4) {
8065 Opcode = (Opcode == SystemZISD::MERGE_HIGH ?
8066 SystemZISD::UNPACKL_HIGH : SystemZISD::UNPACKL_LOW);
8072 DCI.AddToWorklist(Op1.
getNode());
8075 DCI.AddToWorklist(
Op.getNode());
8084 LoPart = HiPart =
nullptr;
8089 if (
Use.getResNo() != 0)
8094 bool IsLoPart =
true;
8119 LoPart = HiPart =
nullptr;
8124 if (
Use.getResNo() != 0)
8130 User->getMachineOpcode() != TargetOpcode::EXTRACT_SUBREG)
8133 switch (
User->getConstantOperandVal(1)) {
8134 case SystemZ::subreg_l64:
8139 case SystemZ::subreg_h64:
8151SDValue SystemZTargetLowering::combineLOAD(
8152 SDNode *
N, DAGCombinerInfo &DCI)
const {
8153 SelectionDAG &DAG = DCI.DAG;
8154 EVT LdVT =
N->getValueType(0);
8158 MVT LoadNodeVT = LN->getBasePtr().getSimpleValueType();
8159 if (PtrVT != LoadNodeVT) {
8163 return DAG.
getExtLoad(LN->getExtensionType(),
DL, LN->getValueType(0),
8164 LN->getChain(), AddrSpaceCast, LN->getMemoryVT(),
8165 LN->getMemOperand());
8175 SDNode *LoPart, *HiPart;
8183 LD->getPointerInfo(),
LD->getBaseAlign(),
8184 LD->getMemOperand()->getFlags(),
LD->getAAInfo());
8186 DCI.CombineTo(HiPart, EltLoad,
true);
8193 LD->getPointerInfo().getWithOffset(8),
LD->getBaseAlign(),
8194 LD->getMemOperand()->getFlags(),
LD->getAAInfo());
8196 DCI.CombineTo(LoPart, EltLoad,
true);
8203 DCI.AddToWorklist(Chain.
getNode());
8218 for (SDUse &Use :
N->uses()) {
8219 if (
Use.getUser()->getOpcode() == SystemZISD::REPLICATE) {
8223 }
else if (
Use.getResNo() == 0)
8226 if (!Replicate || OtherUses.
empty())
8232 for (SDNode *U : OtherUses) {
8235 Ops.push_back((
Op.getNode() ==
N &&
Op.getResNo() == 0) ? Extract0 :
Op);
8241bool SystemZTargetLowering::canLoadStoreByteSwapped(
EVT VT)
const {
8242 if (VT == MVT::i16 || VT == MVT::i32 || VT == MVT::i64)
8244 if (Subtarget.hasVectorEnhancements2())
8245 if (VT == MVT::v8i16 || VT == MVT::v4i32 || VT == MVT::v2i64 || VT == MVT::i128)
8257 for (
unsigned i = 0; i < NumElts; ++i) {
8258 if (M[i] < 0)
continue;
8259 if ((
unsigned) M[i] != NumElts - 1 - i)
8267 for (
auto *U : StoredVal->
users()) {
8269 EVT CurrMemVT = ST->getMemoryVT().getScalarType();
8328SDValue SystemZTargetLowering::combineSTORE(
8329 SDNode *
N, DAGCombinerInfo &DCI)
const {
8330 SelectionDAG &DAG = DCI.DAG;
8333 EVT MemVT = SN->getMemoryVT();
8337 MVT StoreNodeVT = SN->getBasePtr().getSimpleValueType();
8338 if (PtrVT != StoreNodeVT) {
8342 return DAG.
getStore(SN->getChain(),
DL, SN->getValue(), AddrSpaceCast,
8343 SN->getPointerInfo(), SN->getBaseAlign(),
8344 SN->getMemOperand()->getFlags(), SN->getAAInfo());
8352 if (MemVT.
isInteger() && SN->isTruncatingStore()) {
8354 combineTruncateExtract(SDLoc(
N), MemVT, SN->getValue(), DCI)) {
8355 DCI.AddToWorklist(
Value.getNode());
8359 SN->getBasePtr(), SN->getMemoryVT(),
8360 SN->getMemOperand());
8371 return DAG.
getNode(SystemZISD::MOV_STACKGUARD, SDLoc(SN), MVT::Other,
Ops);
8375 if (!SN->isTruncatingStore() &&
8391 Ops, MemVT, SN->getMemOperand());
8394 if (!SN->isTruncatingStore() &&
8397 Subtarget.hasVectorEnhancements2()) {
8399 ArrayRef<int> ShuffleMask = SVN->
getMask();
8407 Ops, MemVT, SN->getMemOperand());
8412 if (!SN->isTruncatingStore() &&
8415 N->getOperand(0).reachesChainWithoutSideEffects(
SDValue(Op1.
getNode(), 1))) {
8419 Ops, MemVT, SN->getMemOperand());
8429 SN->getChain(),
DL, HiPart, SN->getBasePtr(), SN->getPointerInfo(),
8430 SN->getBaseAlign(), SN->getMemOperand()->getFlags(), SN->getAAInfo());
8432 SN->getChain(),
DL, LoPart,
8434 SN->getPointerInfo().getWithOffset(8), SN->getBaseAlign(),
8435 SN->getMemOperand()->
getFlags(), SN->getAAInfo());
8453 auto FindReplicatedImm = [&](ConstantSDNode *
C,
unsigned TotBytes) {
8455 if (
C->getAPIntValue().getBitWidth() > 64 ||
C->isAllOnes() ||
8459 APInt Val =
C->getAPIntValue();
8462 assert(SN->isTruncatingStore() &&
8463 "Non-truncating store and immediate value does not fit?");
8464 Val = Val.
trunc(TotBytes * 8);
8467 SystemZVectorConstantInfo VCI(APInt(TotBytes * 8, Val.
getZExtValue()));
8468 if (VCI.isVectorConstantLegal(Subtarget) &&
8469 VCI.Opcode == SystemZISD::REPLICATE) {
8477 auto FindReplicatedReg = [&](
SDValue MulOp) {
8478 EVT MulVT = MulOp.getValueType();
8479 if (MulOp->getOpcode() ==
ISD::MUL &&
8480 (MulVT == MVT::i16 || MulVT == MVT::i32 || MulVT == MVT::i64)) {
8484 WordVT =
LHS->getOperand(0).getValueType();
8491 SystemZVectorConstantInfo VCI(
8493 if (VCI.isVectorConstantLegal(Subtarget) &&
8494 VCI.Opcode == SystemZISD::REPLICATE && VCI.OpVals[0] == 1 &&
8495 WordVT == VCI.VecVT.getScalarType())
8507 FindReplicatedReg(SplatVal);
8512 FindReplicatedReg(Op1);
8517 "Bad type handling");
8521 return DAG.
getStore(SN->getChain(), SDLoc(SN), SplatVal,
8522 SN->getBasePtr(), SN->getMemOperand());
8529SDValue SystemZTargetLowering::combineVECTOR_SHUFFLE(
8530 SDNode *
N, DAGCombinerInfo &DCI)
const {
8531 SelectionDAG &DAG = DCI.DAG;
8534 N->getOperand(0).hasOneUse() &&
8535 Subtarget.hasVectorEnhancements2()) {
8537 ArrayRef<int> ShuffleMask = SVN->
getMask();
8550 Ops,
LD->getMemoryVT(),
LD->getMemOperand());
8554 DCI.CombineTo(
N, ESLoad);
8558 DCI.CombineTo(
Load.getNode(), ESLoad, ESLoad.
getValue(1));
8568SDValue SystemZTargetLowering::combineEXTRACT_VECTOR_ELT(
8569 SDNode *
N, DAGCombinerInfo &DCI)
const {
8570 SelectionDAG &DAG = DCI.DAG;
8572 if (!Subtarget.hasVector())
8578 Op.getValueType().isVector() &&
8579 Op.getOperand(0).getValueType().isVector() &&
8580 Op.getValueType().getVectorNumElements() ==
8581 Op.getOperand(0).getValueType().getVectorNumElements())
8582 Op =
Op.getOperand(0);
8586 EVT VecVT =
Op.getValueType();
8589 Op.getOperand(0),
N->getOperand(1));
8590 DCI.AddToWorklist(
Op.getNode());
8592 if (EltVT !=
N->getValueType(0)) {
8593 DCI.AddToWorklist(
Op.getNode());
8603 if (canTreatAsByteVector(VecVT))
8604 return combineExtract(SDLoc(
N),
N->getValueType(0), VecVT, Op0,
8605 IndexN->getZExtValue(), DCI,
false);
8610SDValue SystemZTargetLowering::combineJOIN_DWORDS(
8611 SDNode *
N, DAGCombinerInfo &DCI)
const {
8612 SelectionDAG &DAG = DCI.DAG;
8614 if (
N->getOperand(0) ==
N->getOperand(1))
8615 return DAG.
getNode(SystemZISD::REPLICATE, SDLoc(
N),
N->getValueType(0),
8625 if (Chain1 == Chain2)
8633SDValue SystemZTargetLowering::combineFP_ROUND(
8634 SDNode *
N, DAGCombinerInfo &DCI)
const {
8636 if (!Subtarget.hasVector())
8645 unsigned OpNo =
N->isStrictFPOpcode() ? 1 : 0;
8646 SelectionDAG &DAG = DCI.DAG;
8648 if (
N->getValueType(0) == MVT::f32 && Op0.
hasOneUse() &&
8654 for (
auto *U : Vec->
users()) {
8655 if (U != Op0.
getNode() &&
U->hasOneUse() &&
8657 U->getOperand(0) == Vec &&
8659 U->getConstantOperandVal(1) == 1) {
8661 if (OtherRound.
getOpcode() ==
N->getOpcode() &&
8665 if (
N->isStrictFPOpcode()) {
8669 VRound = DAG.
getNode(SystemZISD::STRICT_VROUND, SDLoc(
N),
8670 {MVT::v4f32, MVT::Other}, {Chain, Vec});
8673 VRound = DAG.
getNode(SystemZISD::VROUND, SDLoc(
N),
8675 DCI.AddToWorklist(VRound.
getNode());
8679 DCI.AddToWorklist(Extract1.
getNode());
8685 VRound, DAG.
getConstant(0, SDLoc(Op0), MVT::i32));
8688 N->getVTList(), Extract0, Chain);
8697SDValue SystemZTargetLowering::combineFP_EXTEND(
8698 SDNode *
N, DAGCombinerInfo &DCI)
const {
8700 if (!Subtarget.hasVector())
8709 unsigned OpNo =
N->isStrictFPOpcode() ? 1 : 0;
8710 SelectionDAG &DAG = DCI.DAG;
8712 if (
N->getValueType(0) == MVT::f64 && Op0.
hasOneUse() &&
8718 for (
auto *U : Vec->
users()) {
8719 if (U != Op0.
getNode() &&
U->hasOneUse() &&
8721 U->getOperand(0) == Vec &&
8723 U->getConstantOperandVal(1) == 2) {
8725 if (OtherExtend.
getOpcode() ==
N->getOpcode() &&
8729 if (
N->isStrictFPOpcode()) {
8733 VExtend = DAG.
getNode(SystemZISD::STRICT_VEXTEND, SDLoc(
N),
8734 {MVT::v2f64, MVT::Other}, {Chain, Vec});
8737 VExtend = DAG.
getNode(SystemZISD::VEXTEND, SDLoc(
N),
8739 DCI.AddToWorklist(VExtend.
getNode());
8743 DCI.AddToWorklist(Extract1.
getNode());
8749 VExtend, DAG.
getConstant(0, SDLoc(Op0), MVT::i32));
8752 N->getVTList(), Extract0, Chain);
8761SDValue SystemZTargetLowering::combineINT_TO_FP(
8762 SDNode *
N, DAGCombinerInfo &DCI)
const {
8765 SelectionDAG &DAG = DCI.DAG;
8767 unsigned Opcode =
N->getOpcode();
8768 EVT OutVT =
N->getValueType(0);
8772 unsigned InScalarBits =
Op->getValueType(0).getScalarSizeInBits();
8778 if (OutLLVMTy->
isVectorTy() && OutScalarBits > InScalarBits &&
8779 OutScalarBits <= 64) {
8783 unsigned ExtOpcode =
8786 return DAG.
getNode(Opcode, SDLoc(
N), OutVT, ExtOp);
8791SDValue SystemZTargetLowering::combineFCOPYSIGN(
8792 SDNode *
N, DAGCombinerInfo &DCI)
const {
8793 SelectionDAG &DAG = DCI.DAG;
8794 EVT VT =
N->getValueType(0);
8807SDValue SystemZTargetLowering::combineBSWAP(
8808 SDNode *
N, DAGCombinerInfo &DCI)
const {
8809 SelectionDAG &DAG = DCI.DAG;
8812 N->getOperand(0).hasOneUse() &&
8813 canLoadStoreByteSwapped(
N->getValueType(0))) {
8822 EVT LoadVT =
N->getValueType(0);
8823 if (LoadVT == MVT::i16)
8828 Ops,
LD->getMemoryVT(),
LD->getMemOperand());
8832 if (
N->getValueType(0) == MVT::i16)
8837 DCI.CombineTo(
N, ResVal);
8841 DCI.CombineTo(
Load.getNode(), ResVal, BSLoad.
getValue(1));
8850 Op.getValueType().isVector() &&
8851 Op.getOperand(0).getValueType().isVector() &&
8852 Op.getValueType().getVectorNumElements() ==
8853 Op.getOperand(0).getValueType().getVectorNumElements())
8854 Op =
Op.getOperand(0);
8866 (canLoadStoreByteSwapped(
N->getValueType(0)) &&
8868 EVT VecVT =
N->getValueType(0);
8872 DCI.AddToWorklist(Vec.
getNode());
8876 DCI.AddToWorklist(Elt.
getNode());
8879 DCI.AddToWorklist(Vec.
getNode());
8881 DCI.AddToWorklist(Elt.
getNode());
8889 if (SV &&
Op.hasOneUse()) {
8897 EVT VecVT =
N->getValueType(0);
8900 DCI.AddToWorklist(Op0.
getNode());
8904 DCI.AddToWorklist(Op1.
getNode());
8907 DCI.AddToWorklist(Op0.
getNode());
8909 DCI.AddToWorklist(Op1.
getNode());
8917SDValue SystemZTargetLowering::combineSETCC(
8918 SDNode *
N, DAGCombinerInfo &DCI)
const {
8919 SelectionDAG &DAG = DCI.DAG;
8925 EVT VT =
N->getValueType(0);
8935 Src.getValueType().isFixedLengthVector() &&
8936 Src.getValueType().getScalarType() == MVT::i1) {
8937 EVT CmpVT = Src.getOperand(0).getValueType();
8954 unsigned Depth = 0) {
8962 case SystemZISD::IPM:
8967 case SystemZISD::SELECT_CCMASK: {
8969 if (Op4CCReg.
getOpcode() == SystemZISD::ICMP ||
8970 Op4CCReg.
getOpcode() == SystemZISD::TM) {
8973 return std::make_pair(OpCC, OpCCValid);
8978 int CCValidVal = CCValid->getZExtValue();
8979 return std::make_pair(Op4CCReg, CCValidVal);
8990 return std::make_pair(Op0CC, Op0CCValid);
9006 return {Val, Val, Val, Val};
9007 case SystemZISD::IPM: {
9012 for (
auto CC : {0, 1, 2, 3})
9015 return ShiftedCCVals;
9017 case SystemZISD::SELECT_CCMASK: {
9021 if (!CCValid || !CCMask)
9024 int CCValidVal = CCValid->getZExtValue();
9025 int CCMaskVal = CCMask->getZExtValue();
9035 if (TrueSDVals.empty() || FalseSDVals.empty())
9038 for (
auto &CCVal : {0, 1, 2, 3})
9039 MergedSDVals.
emplace_back(((CCMaskVal & (1 << (3 - CCVal))) != 0)
9041 : FalseSDVals[CCVal]);
9042 return MergedSDVals;
9059 if (Op0SDVals.empty() || Op1SDVals.empty())
9062 for (
auto CCVal : {0, 1, 2, 3})
9064 Opcode,
DL, Val.
getValueType(), Op0SDVals[CCVal], Op1SDVals[CCVal]));
9065 return BinaryOpSDVals;
9076 auto *CCNode = CCReg.
getNode();
9080 if (CCNode->getOpcode() == SystemZISD::TM) {
9083 auto emulateTMCCMask = [](
const SDValue &Op0Val,
const SDValue &Op1Val) {
9086 if (!Op0Node || !Op1Node)
9088 auto Op0APVal = Op0Node->getAPIntValue();
9089 auto Op1APVal = Op1Node->getAPIntValue();
9090 auto Result = Op0APVal & Op1APVal;
9091 bool AllOnes = Result == Op1APVal;
9092 bool AllZeros = Result == 0;
9093 bool IsLeftMostBitSet = Result[Op1APVal.getActiveBits() - 1] != 0;
9094 return AllZeros ? 0 :
AllOnes ? 3 : IsLeftMostBitSet ? 2 : 1;
9098 auto [Op0CC, Op0CCValid] =
findCCUse(Op0);
9103 if (Op0SDVals.empty() || Op1SDVals.empty())
9106 for (
auto CC : {0, 1, 2, 3}) {
9107 auto CCVal = emulateTMCCMask(Op0SDVals[
CC], Op1SDVals[
CC]);
9111 NewCCMask |= (CCMask & (1 << (3 - CCVal))) != 0;
9113 NewCCMask &= Op0CCValid;
9116 CCValid = Op0CCValid;
9119 if (CCNode->getOpcode() != SystemZISD::ICMP ||
9126 auto [Op0CC, Op0CCValid] =
findCCUse(CmpOp0);
9130 if (Op0SDVals.empty() || Op1SDVals.empty())
9134 auto CmpTypeVal = CmpType->getZExtValue();
9135 const auto compareCCSigned = [&CmpTypeVal](
const SDValue &Op0Val,
9139 if (!Op0Node || !Op1Node)
9141 auto Op0APVal = Op0Node->getAPIntValue();
9142 auto Op1APVal = Op1Node->getAPIntValue();
9144 return Op0APVal == Op1APVal ? 0 : Op0APVal.slt(Op1APVal) ? 1 : 2;
9145 return Op0APVal == Op1APVal ? 0 : Op0APVal.ult(Op1APVal) ? 1 : 2;
9148 for (
auto CC : {0, 1, 2, 3}) {
9149 auto CCVal = compareCCSigned(Op0SDVals[
CC], Op1SDVals[
CC]);
9153 NewCCMask |= (CCMask & (1 << (3 - CCVal))) != 0;
9155 NewCCMask &= Op0CCValid;
9158 CCValid = Op0CCValid;
9171 const auto isFlagOutOpCC = [](
const Value *V) {
9173 const Value *RHSVal;
9180 if (CB->isInlineAsm()) {
9182 return IA && IA->getConstraintString().contains(
"{@cc}");
9193 if (isFlagOutOpCC(Lhs) && isFlagOutOpCC(Rhs))
9196 return {-1, -1, -1};
9200 DAGCombinerInfo &DCI)
const {
9206 if (!CCValid || !CCMask)
9209 int CCValidVal = CCValid->getZExtValue();
9210 int CCMaskVal = CCMask->getZExtValue();
9217 if (
combineCCMask(CCReg, CCValidVal, CCMaskVal, DAG) && CCMaskVal != 0 &&
9218 CCMaskVal != CCValidVal)
9219 return DAG.
getNode(SystemZISD::BR_CCMASK,
SDLoc(
N),
N->getValueType(0),
9223 N->getOperand(3), CCReg);
9227SDValue SystemZTargetLowering::combineSELECT_CCMASK(
9228 SDNode *
N, DAGCombinerInfo &DCI)
const {
9234 if (!CCValid || !CCMask)
9237 int CCValidVal = CCValid->getZExtValue();
9238 int CCMaskVal = CCMask->getZExtValue();
9241 bool IsCombinedCCReg =
combineCCMask(CCReg, CCValidVal, CCMaskVal, DAG);
9245 const auto constructCCSDValsFromSELECT = [&CCReg](
SDValue &Val) {
9246 if (Val.getOpcode() == SystemZISD::SELECT_CCMASK) {
9248 if (Val.getOperand(4) != CCReg)
9255 int CCMaskVal = CCMask->getZExtValue();
9256 for (
auto &
CC : {0, 1, 2, 3})
9271 if (TrueSDVals.empty())
9272 TrueSDVals = constructCCSDValsFromSELECT(TrueVal);
9273 if (FalseSDVals.empty())
9274 FalseSDVals = constructCCSDValsFromSELECT(FalseVal);
9275 if (!TrueSDVals.empty() && !FalseSDVals.empty()) {
9276 SmallSet<SDValue, 4> MergedSDValsSet;
9278 for (
auto CC : {0, 1, 2, 3}) {
9279 if ((CCValidVal & ((1 << (3 -
CC)))) != 0)
9280 MergedSDValsSet.
insert(((CCMaskVal & (1 << (3 -
CC))) != 0)
9284 if (MergedSDValsSet.
size() == 1)
9285 return *MergedSDValsSet.
begin();
9286 if (MergedSDValsSet.
size() == 2) {
9287 auto BeginIt = MergedSDValsSet.
begin();
9288 SDValue NewTrueVal = *BeginIt, NewFalseVal = *next(BeginIt);
9289 if (NewTrueVal == FalseVal || NewFalseVal == TrueVal)
9292 for (
auto CC : {0, 1, 2, 3}) {
9294 NewCCMask |= ((CCMaskVal & (1 << (3 -
CC))) != 0)
9295 ? (TrueSDVals[
CC] == NewTrueVal)
9296 : (FalseSDVals[
CC] == NewTrueVal);
9298 CCMaskVal = NewCCMask;
9299 CCMaskVal &= CCValidVal;
9302 IsCombinedCCReg =
true;
9310 if (CCMaskVal == CCValidVal)
9313 if (IsCombinedCCReg)
9315 SystemZISD::SELECT_CCMASK, SDLoc(
N),
N->getValueType(0), TrueVal,
9322SDValue SystemZTargetLowering::combineGET_CCMASK(
9323 SDNode *
N, DAGCombinerInfo &DCI)
const {
9328 if (!CCValid || !CCMask)
9330 int CCValidVal = CCValid->getZExtValue();
9331 int CCMaskVal = CCMask->getZExtValue();
9336 if (
Select->getOpcode() != SystemZISD::SELECT_CCMASK)
9341 if (!SelectCCValid || !SelectCCMask)
9343 int SelectCCValidVal = SelectCCValid->getZExtValue();
9344 int SelectCCMaskVal = SelectCCMask->getZExtValue();
9348 if (!TrueVal || !FalseVal)
9352 else if (
TrueVal->getZExtValue() == 0 &&
FalseVal->getZExtValue() == 1)
9353 SelectCCMaskVal ^= SelectCCValidVal;
9357 if (SelectCCValidVal & ~CCValidVal)
9359 if (SelectCCMaskVal != (CCMaskVal & SelectCCValidVal))
9362 return Select->getOperand(4);
9365SDValue SystemZTargetLowering::combineIntDIVREM(
9366 SDNode *
N, DAGCombinerInfo &DCI)
const {
9367 SelectionDAG &DAG = DCI.DAG;
9368 EVT VT =
N->getValueType(0);
9385SDValue SystemZTargetLowering::combineShiftToMulAddHigh(
9386 SDNode *
N, DAGCombinerInfo &DCI)
const {
9387 SelectionDAG &DAG = DCI.DAG;
9391 "SRL or SRA node is required here!");
9393 if (!Subtarget.hasVector())
9403 SDValue ShiftOperand =
N->getOperand(0);
9423 if (!IsSignExt && !IsZeroExt)
9431 unsigned ActiveBits = IsSignExt
9432 ?
Constant->getAPIntValue().getSignificantBits()
9433 :
Constant->getAPIntValue().getActiveBits();
9434 if (ActiveBits > NarrowVTSize)
9450 unsigned ActiveBits = IsSignExt
9451 ?
Constant->getAPIntValue().getSignificantBits()
9452 :
Constant->getAPIntValue().getActiveBits();
9453 if (ActiveBits > NarrowVTSize)
9470 "Cannot have a multiply node with two different operand types.");
9472 "Cannot have an add node with two different operand types.");
9483 if (ShiftAmt != NarrowVTSize)
9487 if (!(NarrowVT == MVT::v16i8 || NarrowVT == MVT::v8i16 ||
9488 NarrowVT == MVT::v4i32 ||
9489 (Subtarget.hasVectorEnhancements3() &&
9490 (NarrowVT == MVT::v2i64 || NarrowVT == MVT::i128))))
9496 MulhRightOp, MulhAddOp);
9497 bool IsSigned =
N->getOpcode() ==
ISD::SRA;
9508 EVT VT =
Op.getValueType();
9517 Op =
Op.getOperand(0);
9518 if (
Op.getValueType().getVectorNumElements() == 2 * NumElts &&
9522 bool CanUseEven =
true, CanUseOdd =
true;
9523 for (
unsigned Elt = 0; Elt < NumElts; Elt++) {
9524 if (ShuffleMask[Elt] == -1)
9526 if (
unsigned(ShuffleMask[Elt]) != 2 * Elt)
9528 if (
unsigned(ShuffleMask[Elt]) != 2 * Elt + 1)
9531 Op =
Op.getOperand(0);
9533 return IsSigned ? SystemZISD::VME : SystemZISD::VMLE;
9535 return IsSigned ? SystemZISD::VMO : SystemZISD::VMLO;
9541 if (VT == MVT::i128 &&
Subtarget.hasVectorEnhancements3() &&
9545 Op =
Op.getOperand(0);
9547 Op.getOperand(0).getValueType() == MVT::v2i64 &&
9549 unsigned Elem =
Op.getConstantOperandVal(1);
9550 Op =
Op.getOperand(0);
9552 return IsSigned ? SystemZISD::VME : SystemZISD::VMLE;
9554 return IsSigned ? SystemZISD::VMO : SystemZISD::VMLO;
9561SDValue SystemZTargetLowering::combineMUL(
9562 SDNode *
N, DAGCombinerInfo &DCI)
const {
9563 SelectionDAG &DAG = DCI.DAG;
9570 if (OpcodeCand0 && OpcodeCand0 == OpcodeCand1)
9571 return DAG.
getNode(OpcodeCand0, SDLoc(
N),
N->getValueType(0), Op0, Op1);
9576SDValue SystemZTargetLowering::combineINTRINSIC(
9577 SDNode *
N, DAGCombinerInfo &DCI)
const {
9578 SelectionDAG &DAG = DCI.DAG;
9580 unsigned Id =
N->getConstantOperandVal(1);
9584 case Intrinsic::s390_vll:
9585 case Intrinsic::s390_vlrl:
9587 if (
C->getZExtValue() >= 15)
9588 return DAG.
getLoad(
N->getValueType(0), SDLoc(
N),
N->getOperand(0),
9589 N->getOperand(3), MachinePointerInfo());
9592 case Intrinsic::s390_vstl:
9593 case Intrinsic::s390_vstrl:
9595 if (
C->getZExtValue() >= 15)
9596 return DAG.
getStore(
N->getOperand(0), SDLoc(
N),
N->getOperand(2),
9597 N->getOperand(4), MachinePointerInfo());
9605 if (
N->getOpcode() == SystemZISD::PCREL_WRAPPER)
9612 switch(
N->getOpcode()) {
9617 case SystemZISD::MERGE_HIGH:
9618 case SystemZISD::MERGE_LOW:
return combineMERGE(
N, DCI);
9623 case SystemZISD::JOIN_DWORDS:
return combineJOIN_DWORDS(
N, DCI);
9633 case SystemZISD::BR_CCMASK:
return combineBR_CCMASK(
N, DCI);
9634 case SystemZISD::SELECT_CCMASK:
return combineSELECT_CCMASK(
N, DCI);
9637 case ISD::SRA:
return combineShiftToMulAddHigh(
N, DCI);
9638 case ISD::MUL:
return combineMUL(
N, DCI);
9642 case ISD::UREM:
return combineIntDIVREM(
N, DCI);
9654 EVT VT =
Op.getValueType();
9657 unsigned Opcode =
Op.getOpcode();
9659 unsigned Id =
Op.getConstantOperandVal(0);
9661 case Intrinsic::s390_vpksh:
9662 case Intrinsic::s390_vpksf:
9663 case Intrinsic::s390_vpksg:
9664 case Intrinsic::s390_vpkshs:
9665 case Intrinsic::s390_vpksfs:
9666 case Intrinsic::s390_vpksgs:
9667 case Intrinsic::s390_vpklsh:
9668 case Intrinsic::s390_vpklsf:
9669 case Intrinsic::s390_vpklsg:
9670 case Intrinsic::s390_vpklshs:
9671 case Intrinsic::s390_vpklsfs:
9672 case Intrinsic::s390_vpklsgs:
9674 SrcDemE = DemandedElts;
9677 SrcDemE = SrcDemE.
trunc(NumElts / 2);
9680 case Intrinsic::s390_vuphb:
9681 case Intrinsic::s390_vuphh:
9682 case Intrinsic::s390_vuphf:
9683 case Intrinsic::s390_vuplhb:
9684 case Intrinsic::s390_vuplhh:
9685 case Intrinsic::s390_vuplhf:
9686 SrcDemE =
APInt(NumElts * 2, 0);
9689 case Intrinsic::s390_vuplb:
9690 case Intrinsic::s390_vuplhw:
9691 case Intrinsic::s390_vuplf:
9692 case Intrinsic::s390_vupllb:
9693 case Intrinsic::s390_vupllh:
9694 case Intrinsic::s390_vupllf:
9695 SrcDemE =
APInt(NumElts * 2, 0);
9698 case Intrinsic::s390_vpdi: {
9700 SrcDemE =
APInt(NumElts, 0);
9701 if (!DemandedElts[OpNo - 1])
9703 unsigned Mask =
Op.getConstantOperandVal(3);
9704 unsigned MaskBit = ((OpNo - 1) ? 1 : 4);
9706 SrcDemE.
setBit((Mask & MaskBit)? 1 : 0);
9709 case Intrinsic::s390_vsldb: {
9711 assert(VT == MVT::v16i8 &&
"Unexpected type.");
9712 unsigned FirstIdx =
Op.getConstantOperandVal(3);
9713 assert (FirstIdx > 0 && FirstIdx < 16 &&
"Unused operand.");
9714 unsigned NumSrc0Els = 16 - FirstIdx;
9715 SrcDemE =
APInt(NumElts, 0);
9717 APInt DemEls = DemandedElts.
trunc(NumSrc0Els);
9720 APInt DemEls = DemandedElts.
lshr(NumSrc0Els);
9725 case Intrinsic::s390_vperm:
9734 case SystemZISD::JOIN_DWORDS:
9736 SrcDemE =
APInt(1, 1);
9738 case SystemZISD::SELECT_CCMASK:
9739 SrcDemE = DemandedElts;
9750 const APInt &DemandedElts,
9765 const APInt &DemandedElts,
9767 unsigned Depth)
const {
9771 unsigned Tmp0, Tmp1;
9773 Known.Zero.setBitsFrom(2);
9776 [[maybe_unused]]
EVT VT =
Op.getValueType();
9777 if (
Op.getResNo() != 0)
9780 "KnownBits does not match VT in bitwidth");
9783 "DemandedElts does not match VT number of elements");
9785 unsigned Opcode =
Op.getOpcode();
9787 bool IsLogical =
false;
9788 unsigned Id =
Op.getConstantOperandVal(0);
9790 case Intrinsic::s390_vpksh:
9791 case Intrinsic::s390_vpksf:
9792 case Intrinsic::s390_vpksg:
9793 case Intrinsic::s390_vpkshs:
9794 case Intrinsic::s390_vpksfs:
9795 case Intrinsic::s390_vpksgs:
9796 case Intrinsic::s390_vpklsh:
9797 case Intrinsic::s390_vpklsf:
9798 case Intrinsic::s390_vpklsg:
9799 case Intrinsic::s390_vpklshs:
9800 case Intrinsic::s390_vpklsfs:
9801 case Intrinsic::s390_vpklsgs:
9802 case Intrinsic::s390_vpdi:
9803 case Intrinsic::s390_vsldb:
9804 case Intrinsic::s390_vperm:
9807 case Intrinsic::s390_vuplhb:
9808 case Intrinsic::s390_vuplhh:
9809 case Intrinsic::s390_vuplhf:
9810 case Intrinsic::s390_vupllb:
9811 case Intrinsic::s390_vupllh:
9812 case Intrinsic::s390_vupllf:
9815 case Intrinsic::s390_vuphb:
9816 case Intrinsic::s390_vuphh:
9817 case Intrinsic::s390_vuphf:
9818 case Intrinsic::s390_vuplb:
9819 case Intrinsic::s390_vuplhw:
9820 case Intrinsic::s390_vuplf: {
9835 case SystemZISD::JOIN_DWORDS:
9836 case SystemZISD::SELECT_CCMASK:
9839 case SystemZISD::REPLICATE: {
9862 if (
LHS == 1)
return 1;
9865 if (
RHS == 1)
return 1;
9866 unsigned Common = std::min(
LHS,
RHS);
9867 unsigned SrcBitWidth =
Op.getOperand(OpNo).getScalarValueSizeInBits();
9868 EVT VT =
Op.getValueType();
9870 if (SrcBitWidth > VTBits) {
9871 unsigned SrcExtraBits = SrcBitWidth - VTBits;
9872 if (Common > SrcExtraBits)
9873 return (Common - SrcExtraBits);
9876 assert (SrcBitWidth == VTBits &&
"Expected operands of same bitwidth.");
9883 unsigned Depth)
const {
9884 if (
Op.getResNo() != 0)
9886 unsigned Opcode =
Op.getOpcode();
9888 unsigned Id =
Op.getConstantOperandVal(0);
9890 case Intrinsic::s390_vpksh:
9891 case Intrinsic::s390_vpksf:
9892 case Intrinsic::s390_vpksg:
9893 case Intrinsic::s390_vpkshs:
9894 case Intrinsic::s390_vpksfs:
9895 case Intrinsic::s390_vpksgs:
9896 case Intrinsic::s390_vpklsh:
9897 case Intrinsic::s390_vpklsf:
9898 case Intrinsic::s390_vpklsg:
9899 case Intrinsic::s390_vpklshs:
9900 case Intrinsic::s390_vpklsfs:
9901 case Intrinsic::s390_vpklsgs:
9902 case Intrinsic::s390_vpdi:
9903 case Intrinsic::s390_vsldb:
9904 case Intrinsic::s390_vperm:
9906 case Intrinsic::s390_vuphb:
9907 case Intrinsic::s390_vuphh:
9908 case Intrinsic::s390_vuphf:
9909 case Intrinsic::s390_vuplb:
9910 case Intrinsic::s390_vuplhw:
9911 case Intrinsic::s390_vuplf: {
9915 EVT VT =
Op.getValueType();
9925 case SystemZISD::SELECT_CCMASK:
9938 switch (
Op->getOpcode()) {
9939 case SystemZISD::PCREL_WRAPPER:
9940 case SystemZISD::PCREL_OFFSET:
9951 "Unexpected stack alignment");
9954 unsigned StackProbeSize =
9957 StackProbeSize &= ~(StackAlign - 1);
9958 return StackProbeSize ? StackProbeSize : StackAlign;
9975 Register Reg =
MRI.createVirtualRegister(&SystemZ::ADDR64BitRegClass);
9981 Register Reg =
MRI.createVirtualRegister(&SystemZ::ADDR64BitRegClass);
9997 if (
MI.readsRegister(SystemZ::CC,
nullptr))
9999 if (
MI.definesRegister(SystemZ::CC,
nullptr))
10005 if (miI ==
MBB->end()) {
10007 if (Succ->isLiveIn(SystemZ::CC))
10018 switch (
MI.getOpcode()) {
10019 case SystemZ::Select32:
10020 case SystemZ::Select64:
10021 case SystemZ::Select128:
10022 case SystemZ::SelectF32:
10023 case SystemZ::SelectF64:
10024 case SystemZ::SelectF128:
10025 case SystemZ::SelectVR32:
10026 case SystemZ::SelectVR64:
10027 case SystemZ::SelectVR128:
10059 for (
auto *
MI : Selects) {
10060 Register DestReg =
MI->getOperand(0).getReg();
10061 Register TrueReg =
MI->getOperand(1).getReg();
10062 Register FalseReg =
MI->getOperand(2).getReg();
10067 if (
MI->getOperand(4).getImm() == (CCValid ^ CCMask))
10070 if (
auto It = RegRewriteTable.
find(TrueReg); It != RegRewriteTable.
end())
10071 TrueReg = It->second.first;
10073 if (
auto It = RegRewriteTable.
find(FalseReg); It != RegRewriteTable.
end())
10074 FalseReg = It->second.second;
10077 BuildMI(*SinkMBB, SinkInsertionPoint,
DL,
TII->get(SystemZ::PHI), DestReg)
10082 RegRewriteTable[DestReg] = std::make_pair(TrueReg, FalseReg);
10093 auto *TFL = Subtarget.getFrameLowering<SystemZFrameLowering>();
10094 assert(TFL->hasReservedCallFrame(MF) &&
10095 "ADJSTACKDOWN and ADJSTACKUP should be no-ops");
10100 uint32_t NumBytes =
MI.getOperand(0).getImm();
10105 MI.eraseFromParent();
10114 const SystemZInstrInfo *
TII = Subtarget.getInstrInfo();
10116 unsigned CCValid =
MI.getOperand(3).getImm();
10117 unsigned CCMask =
MI.getOperand(4).getImm();
10122 SmallVector<MachineInstr*, 8> Selects;
10123 SmallVector<MachineInstr*, 8> DbgValues;
10125 unsigned Count = 0;
10129 assert(NextMI.getOperand(3).getImm() == CCValid &&
10130 "Bad CCValid operands since CC was not redefined.");
10131 if (NextMI.getOperand(4).getImm() == CCMask ||
10132 NextMI.getOperand(4).getImm() == (CCValid ^ CCMask)) {
10138 if (NextMI.definesRegister(SystemZ::CC,
nullptr) ||
10139 NextMI.usesCustomInsertionHook())
10142 for (
auto *SelMI : Selects)
10143 if (NextMI.readsVirtualRegister(SelMI->getOperand(0).getReg())) {
10147 if (NextMI.isDebugInstr()) {
10149 assert(NextMI.isDebugValue() &&
"Unhandled debug opcode.");
10152 }
else if (User || ++
Count > 20)
10156 MachineInstr *LastMI = Selects.back();
10157 bool CCKilled = (LastMI->
killsRegister(SystemZ::CC,
nullptr) ||
10159 MachineBasicBlock *StartMBB =
MBB;
10189 for (
auto *SelMI : Selects)
10190 SelMI->eraseFromParent();
10193 for (
auto *DbgMI : DbgValues)
10194 MBB->
splice(InsertPos, StartMBB, DbgMI);
10205 unsigned StoreOpcode,
10206 unsigned STOCOpcode,
10207 bool Invert)
const {
10208 const SystemZInstrInfo *
TII = Subtarget.getInstrInfo();
10210 Register SrcReg =
MI.getOperand(0).getReg();
10211 MachineOperand
Base =
MI.getOperand(1);
10212 int64_t Disp =
MI.getOperand(2).getImm();
10213 Register IndexReg =
MI.getOperand(3).getReg();
10214 unsigned CCValid =
MI.getOperand(4).getImm();
10215 unsigned CCMask =
MI.getOperand(5).getImm();
10218 StoreOpcode =
TII->getOpcodeForOffset(StoreOpcode, Disp);
10222 MachineMemOperand *MMO =
nullptr;
10223 for (
auto *
I :
MI.memoperands())
10224 if (
I->isStore()) {
10232 if (STOCOpcode && !IndexReg && Subtarget.hasLoadStoreOnCond()) {
10244 MI.eraseFromParent();
10252 MachineBasicBlock *StartMBB =
MBB;
10258 if (!
MI.killsRegister(SystemZ::CC,
nullptr) &&
10285 MI.eraseFromParent();
10295 const SystemZInstrInfo *
TII = Subtarget.getInstrInfo();
10303 MachineBasicBlock *StartMBB =
MBB;
10321 int HiOpcode =
Unsigned? SystemZ::VECLG : SystemZ::VECG;
10348 MI.eraseFromParent();
10359 bool Invert)
const {
10361 const SystemZInstrInfo *
TII = Subtarget.getInstrInfo();
10368 int64_t Disp =
MI.getOperand(2).getImm();
10370 Register BitShift =
MI.getOperand(4).getReg();
10371 Register NegBitShift =
MI.getOperand(5).getReg();
10372 unsigned BitSize =
MI.getOperand(6).getImm();
10376 unsigned LOpcode =
TII->getOpcodeForOffset(SystemZ::L, Disp);
10377 unsigned CSOpcode =
TII->getOpcodeForOffset(SystemZ::CS, Disp);
10378 assert(LOpcode && CSOpcode &&
"Displacement out of range");
10388 MachineBasicBlock *StartMBB =
MBB;
10424 .
addImm(-1U << (32 - BitSize))
10426 }
else if (BinOpcode)
10454 MI.eraseFromParent();
10465 unsigned KeepOldMask)
const {
10467 const SystemZInstrInfo *
TII = Subtarget.getInstrInfo();
10473 int64_t Disp =
MI.getOperand(2).getImm();
10475 Register BitShift =
MI.getOperand(4).getReg();
10476 Register NegBitShift =
MI.getOperand(5).getReg();
10477 unsigned BitSize =
MI.getOperand(6).getImm();
10481 unsigned LOpcode =
TII->getOpcodeForOffset(SystemZ::L, Disp);
10482 unsigned CSOpcode =
TII->getOpcodeForOffset(SystemZ::CS, Disp);
10483 assert(LOpcode && CSOpcode &&
"Displacement out of range");
10494 MachineBasicBlock *StartMBB =
MBB;
10562 MI.eraseFromParent();
10572 const SystemZInstrInfo *
TII = Subtarget.getInstrInfo();
10578 int64_t Disp =
MI.getOperand(2).getImm();
10579 Register CmpVal =
MI.getOperand(3).getReg();
10580 Register OrigSwapVal =
MI.getOperand(4).getReg();
10581 Register BitShift =
MI.getOperand(5).getReg();
10582 Register NegBitShift =
MI.getOperand(6).getReg();
10583 int64_t BitSize =
MI.getOperand(7).getImm();
10589 unsigned LOpcode =
TII->getOpcodeForOffset(SystemZ::L, Disp);
10590 unsigned CSOpcode =
TII->getOpcodeForOffset(SystemZ::CS, Disp);
10591 unsigned ZExtOpcode = BitSize == 8 ? SystemZ::LLCR : SystemZ::LLHR;
10592 assert(LOpcode && CSOpcode &&
"Displacement out of range");
10604 MachineBasicBlock *StartMBB =
MBB;
10681 if (!
MI.registerDefIsDead(SystemZ::CC,
nullptr))
10684 MI.eraseFromParent();
10691 unsigned Opcode,
bool IsMemset)
const {
10693 const SystemZInstrInfo *
TII = Subtarget.getInstrInfo();
10698 uint64_t DestDisp =
MI.getOperand(1).getImm();
10703 auto foldDisplIfNeeded = [&](MachineOperand &
Base,
uint64_t &Disp) ->
void {
10706 unsigned Opcode =
TII->getOpcodeForOffset(SystemZ::LA, Disp);
10716 SrcDisp =
MI.getOperand(3).getImm();
10718 SrcBase = DestBase;
10719 SrcDisp = DestDisp++;
10720 foldDisplIfNeeded(DestBase, DestDisp);
10723 MachineOperand &LengthMO =
MI.getOperand(IsMemset ? 2 : 4);
10724 bool IsImmForm = LengthMO.
isImm();
10725 bool IsRegForm = !IsImmForm;
10728 auto insertMemMemOp = [&](MachineBasicBlock *InsMBB,
10730 MachineOperand DBase,
uint64_t DDisp,
10732 unsigned Length) ->
void {
10736 if (ByteMO.
isImm())
10751 bool NeedsLoop =
false;
10753 Register LenAdjReg = SystemZ::NoRegister;
10755 ImmLength = LengthMO.
getImm();
10756 ImmLength += IsMemset ? 2 : 1;
10757 if (ImmLength == 0) {
10758 MI.eraseFromParent();
10761 if (Opcode == SystemZ::CLC) {
10762 if (ImmLength > 3 * 256)
10772 }
else if (ImmLength > 6 * 256)
10780 LenAdjReg = LengthMO.
getReg();
10785 MachineBasicBlock *EndMBB =
10786 (Opcode == SystemZ::CLC && (ImmLength > 256 || NeedsLoop)
10794 TII->loadImmediate(*
MBB,
MI, StartCountReg, ImmLength / 256);
10804 auto loadZeroAddress = [&]() -> MachineOperand {
10809 if (DestBase.
isReg() && DestBase.
getReg() == SystemZ::NoRegister)
10810 DestBase = loadZeroAddress();
10811 if (SrcBase.
isReg() && SrcBase.
getReg() == SystemZ::NoRegister)
10812 SrcBase = HaveSingleBase ? DestBase : loadZeroAddress();
10814 MachineBasicBlock *StartMBB =
nullptr;
10815 MachineBasicBlock *LoopMBB =
nullptr;
10816 MachineBasicBlock *NextMBB =
nullptr;
10817 MachineBasicBlock *DoneMBB =
nullptr;
10818 MachineBasicBlock *AllDoneMBB =
nullptr;
10822 (HaveSingleBase ? StartSrcReg :
forceReg(
MI, DestBase,
TII));
10831 RC = &SystemZ::GR64BitRegClass;
10859 MBB = MemsetOneCheckMBB;
10870 MBB = MemsetOneMBB;
10902 if (EndMBB && !ImmLength)
10924 if (!HaveSingleBase)
10931 if (Opcode == SystemZ::MVC)
10958 if (!HaveSingleBase)
10983 Register RemDestReg = HaveSingleBase ? RemSrcReg
10988 if (!HaveSingleBase)
10996 MachineInstrBuilder EXRL_MIB =
11004 if (Opcode != SystemZ::MVC) {
11014 while (ImmLength > 0) {
11018 foldDisplIfNeeded(DestBase, DestDisp);
11019 foldDisplIfNeeded(SrcBase, SrcDisp);
11020 insertMemMemOp(
MBB,
MI, DestBase, DestDisp, SrcBase, SrcDisp, ThisLength);
11021 DestDisp += ThisLength;
11022 SrcDisp += ThisLength;
11023 ImmLength -= ThisLength;
11026 if (EndMBB && ImmLength > 0) {
11042 MI.eraseFromParent();
11049 const SystemZInstrInfo *
TII = Subtarget.getInstrInfo();
11055 assert(Len > 0 && Len <= 256 &&
"Memmove of of unsupported constant length.");
11084 MI.eraseFromParent();
11093 const SystemZInstrInfo *
TII = Subtarget.getInstrInfo();
11097 uint64_t End1Reg =
MI.getOperand(0).getReg();
11098 uint64_t Start1Reg =
MI.getOperand(1).getReg();
11099 uint64_t Start2Reg =
MI.getOperand(2).getReg();
11100 uint64_t CharReg =
MI.getOperand(3).getReg();
11107 MachineBasicBlock *StartMBB =
MBB;
11143 MI.eraseFromParent();
11150 bool NoFloat)
const {
11152 const TargetFrameLowering *TFI = Subtarget.getFrameLowering();
11153 const SystemZInstrInfo *
TII = Subtarget.getInstrInfo();
11156 MI.setDesc(
TII->get(Opcode));
11160 uint64_t Control =
MI.getOperand(2).getImm();
11161 static const unsigned GPRControlBit[16] = {
11162 0x8000, 0x8000, 0x4000, 0x4000, 0x2000, 0x2000, 0x1000, 0x1000,
11163 0x0800, 0x0800, 0x0400, 0x0400, 0x0200, 0x0200, 0x0100, 0x0100
11165 Control |= GPRControlBit[15];
11166 if (TFI->
hasFP(MF))
11167 Control |= GPRControlBit[11];
11168 MI.getOperand(2).setImm(Control);
11171 for (
int I = 0;
I < 16;
I++) {
11172 if ((Control & GPRControlBit[
I]) == 0) {
11179 if (!NoFloat && (Control & 4) != 0) {
11180 if (Subtarget.hasVector()) {
11198 const SystemZInstrInfo *
TII = Subtarget.getInstrInfo();
11201 Register SrcReg =
MI.getOperand(0).getReg();
11212 MI.eraseFromParent();
11221 const SystemZInstrInfo *
TII = Subtarget.getInstrInfo();
11224 Register DstReg =
MI.getOperand(0).getReg();
11225 Register SizeReg =
MI.getOperand(2).getReg();
11227 MachineBasicBlock *StartMBB =
MBB;
11314 MI.eraseFromParent();
11318SDValue SystemZTargetLowering::
11321 auto *TFL = Subtarget.getFrameLowering<SystemZELFFrameLowering>();
11333 const SystemZInstrInfo *
TII = Subtarget.getInstrInfo();
11338 .
addImm(
MI.getOperand(1).getImm());
11339 MI.eraseFromParent();
11345 switch (
MI.getOpcode()) {
11346 case SystemZ::ADJCALLSTACKDOWN:
11347 case SystemZ::ADJCALLSTACKUP:
11348 return emitAdjCallStack(
MI,
MBB);
11350 case SystemZ::Select32:
11351 case SystemZ::Select64:
11352 case SystemZ::Select128:
11353 case SystemZ::SelectF32:
11354 case SystemZ::SelectF64:
11355 case SystemZ::SelectF128:
11356 case SystemZ::SelectVR32:
11357 case SystemZ::SelectVR64:
11358 case SystemZ::SelectVR128:
11359 return emitSelect(
MI,
MBB);
11361 case SystemZ::CondStore8Mux:
11362 return emitCondStore(
MI,
MBB, SystemZ::STCMux, 0,
false);
11363 case SystemZ::CondStore8MuxInv:
11364 return emitCondStore(
MI,
MBB, SystemZ::STCMux, 0,
true);
11365 case SystemZ::CondStore16Mux:
11366 return emitCondStore(
MI,
MBB, SystemZ::STHMux, 0,
false);
11367 case SystemZ::CondStore16MuxInv:
11368 return emitCondStore(
MI,
MBB, SystemZ::STHMux, 0,
true);
11369 case SystemZ::CondStore32Mux:
11370 return emitCondStore(
MI,
MBB, SystemZ::STMux, SystemZ::STOCMux,
false);
11371 case SystemZ::CondStore32MuxInv:
11372 return emitCondStore(
MI,
MBB, SystemZ::STMux, SystemZ::STOCMux,
true);
11373 case SystemZ::CondStore8:
11374 return emitCondStore(
MI,
MBB, SystemZ::STC, 0,
false);
11375 case SystemZ::CondStore8Inv:
11376 return emitCondStore(
MI,
MBB, SystemZ::STC, 0,
true);
11377 case SystemZ::CondStore16:
11378 return emitCondStore(
MI,
MBB, SystemZ::STH, 0,
false);
11379 case SystemZ::CondStore16Inv:
11380 return emitCondStore(
MI,
MBB, SystemZ::STH, 0,
true);
11381 case SystemZ::CondStore32:
11382 return emitCondStore(
MI,
MBB, SystemZ::ST, SystemZ::STOC,
false);
11383 case SystemZ::CondStore32Inv:
11384 return emitCondStore(
MI,
MBB, SystemZ::ST, SystemZ::STOC,
true);
11385 case SystemZ::CondStore64:
11386 return emitCondStore(
MI,
MBB, SystemZ::STG, SystemZ::STOCG,
false);
11387 case SystemZ::CondStore64Inv:
11388 return emitCondStore(
MI,
MBB, SystemZ::STG, SystemZ::STOCG,
true);
11389 case SystemZ::CondStoreF32:
11390 return emitCondStore(
MI,
MBB, SystemZ::STE, 0,
false);
11391 case SystemZ::CondStoreF32Inv:
11392 return emitCondStore(
MI,
MBB, SystemZ::STE, 0,
true);
11393 case SystemZ::CondStoreF64:
11394 return emitCondStore(
MI,
MBB, SystemZ::STD, 0,
false);
11395 case SystemZ::CondStoreF64Inv:
11396 return emitCondStore(
MI,
MBB, SystemZ::STD, 0,
true);
11398 case SystemZ::SCmp128Hi:
11399 return emitICmp128Hi(
MI,
MBB,
false);
11400 case SystemZ::UCmp128Hi:
11401 return emitICmp128Hi(
MI,
MBB,
true);
11404 case SystemZ::ATOMIC_SWAPW:
11405 return emitAtomicLoadBinary(
MI,
MBB, 0);
11407 case SystemZ::ATOMIC_LOADW_AR:
11408 return emitAtomicLoadBinary(
MI,
MBB, SystemZ::AR);
11409 case SystemZ::ATOMIC_LOADW_AFI:
11410 return emitAtomicLoadBinary(
MI,
MBB, SystemZ::AFI);
11412 case SystemZ::ATOMIC_LOADW_SR:
11413 return emitAtomicLoadBinary(
MI,
MBB, SystemZ::SR);
11415 case SystemZ::ATOMIC_LOADW_NR:
11416 return emitAtomicLoadBinary(
MI,
MBB, SystemZ::NR);
11417 case SystemZ::ATOMIC_LOADW_NILH:
11418 return emitAtomicLoadBinary(
MI,
MBB, SystemZ::NILH);
11420 case SystemZ::ATOMIC_LOADW_OR:
11421 return emitAtomicLoadBinary(
MI,
MBB, SystemZ::OR);
11422 case SystemZ::ATOMIC_LOADW_OILH:
11423 return emitAtomicLoadBinary(
MI,
MBB, SystemZ::OILH);
11425 case SystemZ::ATOMIC_LOADW_XR:
11426 return emitAtomicLoadBinary(
MI,
MBB, SystemZ::XR);
11427 case SystemZ::ATOMIC_LOADW_XILF:
11428 return emitAtomicLoadBinary(
MI,
MBB, SystemZ::XILF);
11430 case SystemZ::ATOMIC_LOADW_NRi:
11431 return emitAtomicLoadBinary(
MI,
MBB, SystemZ::NR,
true);
11432 case SystemZ::ATOMIC_LOADW_NILHi:
11433 return emitAtomicLoadBinary(
MI,
MBB, SystemZ::NILH,
true);
11435 case SystemZ::ATOMIC_LOADW_MIN:
11437 case SystemZ::ATOMIC_LOADW_MAX:
11439 case SystemZ::ATOMIC_LOADW_UMIN:
11441 case SystemZ::ATOMIC_LOADW_UMAX:
11444 case SystemZ::ATOMIC_CMP_SWAPW:
11445 return emitAtomicCmpSwapW(
MI,
MBB);
11446 case SystemZ::MVCImm:
11447 case SystemZ::MVCReg:
11448 return emitMemMemWrapper(
MI,
MBB, SystemZ::MVC);
11449 case SystemZ::NCImm:
11450 return emitMemMemWrapper(
MI,
MBB, SystemZ::NC);
11451 case SystemZ::OCImm:
11452 return emitMemMemWrapper(
MI,
MBB, SystemZ::OC);
11453 case SystemZ::XCImm:
11454 case SystemZ::XCReg:
11455 return emitMemMemWrapper(
MI,
MBB, SystemZ::XC);
11456 case SystemZ::CLCImm:
11457 case SystemZ::CLCReg:
11458 return emitMemMemWrapper(
MI,
MBB, SystemZ::CLC);
11459 case SystemZ::MemsetImmImm:
11460 case SystemZ::MemsetImmReg:
11461 case SystemZ::MemsetRegImm:
11462 case SystemZ::MemsetRegReg:
11463 return emitMemMemWrapper(
MI,
MBB, SystemZ::MVC,
true);
11464 case SystemZ::MemmoveImm:
11465 return emitMemmoveImm(
MI,
MBB);
11466 case SystemZ::CLSTLoop:
11467 return emitStringWrapper(
MI,
MBB, SystemZ::CLST);
11468 case SystemZ::MVSTLoop:
11469 return emitStringWrapper(
MI,
MBB, SystemZ::MVST);
11470 case SystemZ::SRSTLoop:
11471 return emitStringWrapper(
MI,
MBB, SystemZ::SRST);
11472 case SystemZ::TBEGIN:
11473 return emitTransactionBegin(
MI,
MBB, SystemZ::TBEGIN,
false);
11474 case SystemZ::TBEGIN_nofloat:
11475 return emitTransactionBegin(
MI,
MBB, SystemZ::TBEGIN,
true);
11476 case SystemZ::TBEGINC:
11477 return emitTransactionBegin(
MI,
MBB, SystemZ::TBEGINC,
true);
11478 case SystemZ::LTEBRCompare_Pseudo:
11479 return emitLoadAndTestCmp0(
MI,
MBB, SystemZ::LTEBR);
11480 case SystemZ::LTDBRCompare_Pseudo:
11481 return emitLoadAndTestCmp0(
MI,
MBB, SystemZ::LTDBR);
11482 case SystemZ::LTXBRCompare_Pseudo:
11483 return emitLoadAndTestCmp0(
MI,
MBB, SystemZ::LTXBR);
11485 case SystemZ::PROBED_ALLOCA:
11486 return emitProbedAlloca(
MI,
MBB);
11487 case SystemZ::EH_SjLj_SetJmp:
11489 case SystemZ::EH_SjLj_LongJmp:
11492 case TargetOpcode::STACKMAP:
11493 case TargetOpcode::PATCHPOINT:
11496 case SystemZ::MOV_STACKGUARD_DAG:
11497 return emitStackGuardPseudo(
MI,
MBB, SystemZ::MOV_STACKGUARD);
11499 case SystemZ::CMP_STACKGUARD_DAG:
11500 return emitStackGuardPseudo(
MI,
MBB, SystemZ::CMP_STACKGUARD);
11529 DAG.
getMachineNode(SystemZ::EFPC, dl, {MVT::i32, MVT::Other}, Chain), 0);
11549 EVT VT =
Op.getValueType();
11550 Op =
Op.getOperand(0);
11551 EVT OpVT =
Op.getValueType();
11553 assert(OpVT.
isVector() &&
"Operand type for VECREDUCE_ADD is not a vector.");
11585 if (Attrs.hasRetAttrs())
11586 OS << Attrs.getAsString(AttributeList::ReturnIndex) <<
" ";
11587 OS << *
F->getReturnType() <<
" @" <<
F->getName() <<
"(";
11588 for (
unsigned I = 0,
E = FT->getNumParams();
I !=
E; ++
I) {
11591 OS << *FT->getParamType(
I);
11593 for (
auto A : {Attribute::SExt, Attribute::ZExt, Attribute::NoExt})
11602bool SystemZTargetLowering::isInternal(
const Function *Fn)
const {
11603 std::map<const Function *, bool>::iterator Itr = IsInternalCache.find(Fn);
11604 if (Itr == IsInternalCache.end())
11605 Itr = IsInternalCache
11606 .insert(std::pair<const Function *, bool>(
11609 return Itr->second;
11612bool SystemZTargetLowering::enableNarrowIntArgsVerification()
const {
11613 if (!Subtarget.isTargetELF())
11616 if (
auto V =
toOptional(Subtarget.getCLOpts().argext_abi_check))
11626void SystemZTargetLowering::verifyNarrowIntegerArgs_Call(
11629 if (!enableNarrowIntArgsVerification())
11631 bool IsInternal =
false;
11632 const Function *CalleeFn =
nullptr;
11635 IsInternal = isInternal(CalleeFn);
11637 if (!verifyNarrowIntegerArgs(C_ABI, Outs, CalleeFn,
false)) {
11638 errs() <<
"Callee: ";
11639 if (CalleeFn !=
nullptr)
11643 errs() <<
"Caller: ";
11646 errs() <<
" " << *CLI.CB;
11649 LLVM_DEBUG(
dbgs() <<
"Outgoing call arguments verified as ABI compliant: ";
11651 else dbgs() <<
"-\n";);
11654void SystemZTargetLowering::verifyNarrowIntegerArgs_Ret(
11657 if (!enableNarrowIntArgsVerification())
11660 if (!verifyNarrowIntegerArgs(C_ABI, Outs,
F,
true)) {
11661 errs() <<
"Returning from function: ";
11665 LLVM_DEBUG(
dbgs() <<
"Return argument verified as ABI compliant : ";
11672bool SystemZTargetLowering::verifyNarrowIntegerArgs(
11674 const Function *FunHeader,
bool IsRet)
const {
11675 if (IsRet && Outs.
size() != 1)
11678 for (
unsigned i = 0; i < Outs.
size(); ++i) {
11679 EVT OrigArgVT = Outs[i].ArgVT;
11682 assert(Outs[i].VT == MVT::i32 &&
"Unexpected integer argument VT.");
11683 ISD::ArgFlagsTy
Flags = Outs[i].Flags;
11684 unsigned OrigIdx = Outs[i].OrigArgIndex;
11687 if (C_ABI && !
Flags.isSExt() && !
Flags.isZExt() && !
Flags.isNoExt()) {
11688 errs() <<
"ERROR: (C ABI violation) missing extension attribute on "
11689 << (IsRet ?
"return value" : Twine(
"arg ") + Twine(OrigIdx))
11696 const AttributeList &FunAttrs = FunHeader->
getAttributes();
11697 const AttributeSet
Attrs =
11698 IsRet ? FunAttrs.getRetAttrs() : FunAttrs.getParamAttrs(OrigIdx);
11699 if (
Attrs.hasAttribute(Attribute::SExt) && !
Flags.isSExt()) {
11700 errs() <<
"ERROR: Missing SExt on arg " << OrigIdx <<
".\n";
11703 if (
Attrs.hasAttribute(Attribute::ZExt) && !
Flags.isZExt()) {
11704 errs() <<
"ERROR: Missing ZExt on arg " << OrigIdx <<
".\n";
11715 StringRef GuardMode = M.getStackProtectorGuard();
11718 if (GuardMode ==
"tls" || GuardMode.
empty())
const AArch64Subtarget & Subtarget
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static msgpack::DocNode getNode(msgpack::DocNode DN, msgpack::Type Type, MCValue Val)
AMDGPU Register Bank Select
static bool isZeroVector(SDValue N)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis false
Function Alias Analysis Results
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static SDValue convertValVTToLocVT(SelectionDAG &DAG, SDValue Val, const CCValAssign &VA, const SDLoc &DL)
static SDValue convertLocVTToValVT(SelectionDAG &DAG, SDValue Val, const CCValAssign &VA, const SDLoc &DL)
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static bool isSelectPseudo(MachineInstr &MI)
static bool isUndef(const MachineInstr &MI)
Register const TargetRegisterInfo * TRI
Promote Memory to Register
uint64_t IntrinsicInst * II
static constexpr MCPhysReg SPReg
SmallVector< MachineOperand, 4 > Cond
MachineRegisterInfo & MRI
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
This file defines the SmallSet class.
static SDValue getI128Select(SelectionDAG &DAG, const SDLoc &DL, Comparison C, SDValue TrueOp, SDValue FalseOp)
static SmallVector< SDValue, 4 > simplifyAssumingCCVal(SDValue &Val, SDValue &CC, SelectionDAG &DAG)
static void adjustForTestUnderMask(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
static void adjustForLTGFR(Comparison &C)
static void adjustSubwordCmp(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
static SDValue joinDwords(SelectionDAG &DAG, const SDLoc &DL, SDValue Op0, SDValue Op1)
static bool isOnlyUsedByStores(SDValue StoredVal, SelectionDAG &DAG)
static void lowerGR128Binary(SelectionDAG &DAG, const SDLoc &DL, EVT VT, unsigned Opcode, SDValue Op0, SDValue Op1, SDValue &Even, SDValue &Odd)
static void adjustForRedundantAnd(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
static SDValue lowerAddrSpaceCast(SDValue Op, SelectionDAG &DAG)
static SDValue buildScalarToVector(SelectionDAG &DAG, const SDLoc &DL, EVT VT, SDValue Value)
static SDValue lowerI128ToGR128(SelectionDAG &DAG, SDValue In)
static bool isSimpleShift(SDValue N, unsigned &ShiftVal)
static SDValue mergeHighParts(SelectionDAG &DAG, const SDLoc &DL, unsigned MergedBits, EVT VT, SDValue Op0, SDValue Op1)
static bool isI128MovedToParts(LoadSDNode *LD, SDNode *&LoPart, SDNode *&HiPart)
static bool chooseShuffleOpNos(int *OpNos, unsigned &OpNo0, unsigned &OpNo1)
static uint32_t findZeroVectorIdx(SDValue *Ops, unsigned Num)
static bool isVectorElementSwap(ArrayRef< int > M, EVT VT)
static void getCSAddressAndShifts(SDValue Addr, SelectionDAG &DAG, SDLoc DL, SDValue &AlignedAddr, SDValue &BitShift, SDValue &NegBitShift)
static bool isShlDoublePermute(const SmallVectorImpl< int > &Bytes, unsigned &StartIndex, unsigned &OpNo0, unsigned &OpNo1)
static SDValue getPermuteNode(SelectionDAG &DAG, const SDLoc &DL, const Permute &P, SDValue Op0, SDValue Op1)
static SDNode * emitIntrinsicWithCCAndChain(SelectionDAG &DAG, SDValue Op, unsigned Opcode)
static SDValue getCCResult(SelectionDAG &DAG, SDValue CCReg)
static void adjustForStackGuardCompare(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
static bool isIntrinsicWithCCAndChain(SDValue Op, unsigned &Opcode, unsigned &CCValid)
static void lowerMUL_LOHI32(SelectionDAG &DAG, const SDLoc &DL, unsigned Extend, SDValue Op0, SDValue Op1, SDValue &Hi, SDValue &Lo)
static bool isF128MovedToParts(LoadSDNode *LD, SDNode *&LoPart, SDNode *&HiPart)
static void createPHIsForSelects(SmallVector< MachineInstr *, 8 > &Selects, MachineBasicBlock *TrueMBB, MachineBasicBlock *FalseMBB, MachineBasicBlock *SinkMBB)
static SDValue getGeneralPermuteNode(SelectionDAG &DAG, const SDLoc &DL, SDValue *Ops, const SmallVectorImpl< int > &Bytes)
static unsigned getVectorComparisonOrInvert(ISD::CondCode CC, CmpMode Mode, bool &Invert)
static unsigned CCMaskForCondCode(ISD::CondCode CC)
static void adjustICmpTruncate(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
static void adjustForFNeg(Comparison &C)
static bool isScalarToVector(SDValue Op)
static SDValue emitSETCC(SelectionDAG &DAG, const SDLoc &DL, SDValue CCReg, unsigned CCValid, unsigned CCMask)
static bool matchPermute(const SmallVectorImpl< int > &Bytes, const Permute &P, unsigned &OpNo0, unsigned &OpNo1)
static bool isAddCarryChain(SDValue Carry)
static SDValue emitCmp(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
static MachineOperand earlyUseOperand(MachineOperand Op)
static bool canUseSiblingCall(const CCState &ArgCCInfo, SmallVectorImpl< CCValAssign > &ArgLocs, SmallVectorImpl< ISD::OutputArg > &Outs)
static bool getzOSCalleeAndADA(SelectionDAG &DAG, SDValue &Callee, SDValue &ADA, SDLoc &DL, SDValue &Chain)
static SDValue convertToF16(SDValue Op, SelectionDAG &DAG)
static bool combineCCMask(SDValue &CCReg, int &CCValid, int &CCMask, SelectionDAG &DAG)
static bool shouldSwapCmpOperands(const Comparison &C)
static bool isNaturalMemoryOperand(SDValue Op, unsigned ICmpType)
static SDValue getADAEntry(SelectionDAG &DAG, SDValue Val, SDLoc DL, unsigned Offset, bool LoadAdr=false)
static SDNode * emitIntrinsicWithCC(SelectionDAG &DAG, SDValue Op, unsigned Opcode)
static void adjustForSubtraction(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
static bool getVPermMask(SDValue ShuffleOp, SmallVectorImpl< int > &Bytes)
static const Permute PermuteForms[]
static bool isI128MovedFromParts(SDValue Val, SDValue &LoPart, SDValue &HiPart)
static std::pair< SDValue, int > findCCUse(const SDValue &Val, unsigned Depth=0)
static bool isSubBorrowChain(SDValue Carry)
static void adjustICmp128(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
static bool analyzeArgSplit(const SmallVectorImpl< ArgTy > &Args, SmallVector< CCValAssign, 16 > &ArgLocs, unsigned I, MVT &PartVT, unsigned &NumParts)
static bool isInBoundsConstantVectorIndex(EVT VecVT, SDValue Idx)
static APInt getDemandedSrcElements(SDValue Op, const APInt &DemandedElts, unsigned OpNo)
static SDValue getAbsolute(SelectionDAG &DAG, const SDLoc &DL, SDValue Op, bool IsNegative)
static unsigned computeNumSignBitsBinOp(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth, unsigned OpNo)
static SDValue expandBitCastI128ToF128(SelectionDAG &DAG, SDValue Src, const SDLoc &SL)
static SDValue tryBuildVectorShuffle(SelectionDAG &DAG, BuildVectorSDNode *BVN)
static SDValue convertFromF16(SDValue Op, SDLoc DL, SelectionDAG &DAG)
static unsigned getVectorComparison(ISD::CondCode CC, CmpMode Mode)
static SDValue lowerGR128ToI128(SelectionDAG &DAG, SDValue In)
static SDValue MergeInputChains(SDNode *N1, SDNode *N2)
static SDValue expandBitCastF128ToI128(SelectionDAG &DAG, SDValue Src, const SDLoc &SL)
static unsigned getTestUnderMaskCond(unsigned BitSize, unsigned CCMask, uint64_t Mask, uint64_t CmpVal, unsigned ICmpType)
static bool isIntrinsicWithCC(SDValue Op, unsigned &Opcode, unsigned &CCValid)
static SDValue expandV4F32ToV2F64(SelectionDAG &DAG, int Start, const SDLoc &DL, SDValue Op, SDValue Chain)
static Comparison getCmp(SelectionDAG &DAG, SDValue CmpOp0, SDValue CmpOp1, ISD::CondCode Cond, const SDLoc &DL, SDValue Chain=SDValue(), bool IsSignaling=false)
static bool checkCCKill(MachineInstr &MI, MachineBasicBlock *MBB)
static Register forceReg(MachineInstr &MI, MachineOperand &Base, const SystemZInstrInfo *TII)
static bool is32Bit(EVT VT)
static std::pair< unsigned, const TargetRegisterClass * > parseRegisterNumber(StringRef Constraint, const TargetRegisterClass *RC, const unsigned *Map, unsigned Size)
static unsigned detectEvenOddMultiplyOperand(const SelectionDAG &DAG, const SystemZSubtarget &Subtarget, SDValue &Op)
static bool matchDoublePermute(const SmallVectorImpl< int > &Bytes, const Permute &P, SmallVectorImpl< int > &Transform)
static Comparison getIntrinsicCmp(SelectionDAG &DAG, unsigned Opcode, SDValue Call, unsigned CCValid, uint64_t CC, ISD::CondCode Cond)
static Register getOrCreateADAVirtualRegister(MachineFunction &MF)
static SDValue buildFPVecFromScalars4(SelectionDAG &DAG, const SDLoc &DL, EVT VT, SmallVectorImpl< SDValue > &Elems, unsigned Pos)
static bool isAbsolute(SDValue CmpOp, SDValue Pos, SDValue Neg)
static AddressingMode getLoadStoreAddrMode(bool HasVector, Type *Ty)
static void printFunctionArgExts(const Function *F, raw_ostream &OS)
static SDValue buildMergeScalars(SelectionDAG &DAG, const SDLoc &DL, EVT VT, SDValue Op0, SDValue Op1)
static void computeKnownBitsBinOp(const SDValue Op, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth, unsigned OpNo)
static bool getShuffleInput(const SmallVectorImpl< int > &Bytes, unsigned Start, unsigned BytesPerElement, int &Base)
static AddressingMode supportedAddressingMode(Instruction *I, bool HasVector)
static bool isF128MovedFromParts(SDValue Val, SDValue &LoPart, SDValue &HiPart)
static void adjustZeroCmp(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
LLVM_ABI APInt zext(unsigned width) const
Zero extend to a new width.
static APInt getSignMask(unsigned BitWidth)
Get the SignMask for a specific bit width.
uint64_t getZExtValue() const
Get zero extended value.
unsigned getActiveBits() const
Compute the number of active bits in the value.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool isSingleWord() const
Determine if this APInt just has one word to store value.
LLVM_ABI void insertBits(const APInt &SubBits, unsigned bitPosition)
Insert the bits from a smaller APInt starting at bitPosition.
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
void lshrInPlace(unsigned ShiftAmt)
Logical right-shift this APInt by ShiftAmt in place.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
an instruction that atomically reads a memory location, combines it with another value,...
BinOp getOperation() const
This class holds the attributes for a particular argument, parameter, function, or return value.
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
static LLVM_ABI StringRef getNameFromAttrKind(Attribute::AttrKind AttrKind)
LLVM Basic Block Representation.
A "pseudo-class" with methods for operating on BUILD_VECTORs.
LLVM_ABI 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.
LLVM_ABI bool isConstant() const
CCState - This class holds information needed while lowering arguments and return values.
LLVM_ABI void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values i...
LLVM_ABI 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 ...
LLVM_ABI void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values i...
LLVM_ABI void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed v...
uint64_t getStackSize() const
Returns the size of the currently allocated portion of the stack.
LLVM_ABI void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeFormalArguments - Analyze an array of argument values, incorporating info about the formals in...
CCValAssign - Represent assignment of one arg/retval to a location.
Register getLocReg() const
LocInfo getLocInfo() const
int64_t getLocMemOffset() const
LLVM_ABI bool isMustTailCall() const
Tests if this call site must be tail call optimized.
This class represents a function call, abstracting a target machine's calling convention.
MachineConstantPoolValue * getMachineCPVal() const
bool isMachineConstantPoolEntry() const
const Constant * getConstVal() const
uint64_t getZExtValue() const
This is an important base class in LLVM.
uint64_t getNumOperands() const
A parsed version of the target data layout string in and methods for querying it.
LLVM_ABI unsigned getPointerSize(unsigned AS=0) const
The pointer representation size in bytes, rounded up to a whole number of bytes.
iterator find(const_arg_type_t< KeyT > Val)
constexpr bool isScalar() const
Exactly one element.
bool hasAddressTaken(const User **=nullptr, bool IgnoreCallbackUses=false, bool IgnoreAssumeLikeCalls=true, bool IngoreLLVMUsed=false, bool IgnoreARCAttachedCall=false, bool IgnoreCastedDirectCall=false) const
hasAddressTaken - returns true if there are any uses of this function other than direct calls or invo...
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
uint64_t getFnAttributeAsParsedInteger(StringRef Kind, uint64_t Default=0) const
For a string attribute Kind, parse attribute as an integer.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
AttributeList getAttributes() const
Return the attribute list for this Function.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
LLVM_ABI const GlobalObject * getAliaseeObject() const
bool hasLocalLinkage() const
bool hasPrivateLinkage() const
bool hasInternalLinkage() const
A wrapper class for inspecting calls to intrinsic functions.
This is an important class for using LLVM in a threaded context.
Tracks which library functions to use for a particular subtarget or function.
An instruction for reading from memory.
This class is used to represent ISD::LOAD nodes.
static auto integer_fixedlen_vector_valuetypes()
uint64_t getScalarSizeInBits() const
bool isVector() const
Return true if this is a vector value type.
static auto integer_valuetypes()
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static auto fixedlen_vector_valuetypes()
ElementCount getVectorElementCount() const
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
static MVT getVectorVT(MVT VT, unsigned NumElements)
static MVT getIntegerVT(unsigned BitWidth)
static auto fp_valuetypes()
MVT getScalarType() const
If this is a vector, return the element type, otherwise return this.
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
LLVM_ABI iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
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 '...
MachineInstrBundleIterator< MachineInstr > iterator
void setMachineBlockAddressTaken()
Set this block to indicate that its address is used as something other than the target of a terminato...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
void setMaxCallFrameSize(uint64_t S)
LLVM_ABI int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
void setAdjustsStack(bool V)
void setFrameAddressIsTaken(bool T)
uint64_t getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call.
void setReturnAddressIsTaken(bool s)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
void push_back(MachineBasicBlock *MBB)
reverse_iterator rbegin()
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Function & getFunction()
Return the LLVM function that this machine code represents.
BasicBlockListType::iterator iterator
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineFunctionProperties & getProperties() const
Get the function properties.
Register addLiveIn(MCRegister PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LLT MemTy, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineInstr - Allocate a new MachineInstr.
void insert(iterator MBBI, MachineBasicBlock *MBB)
const MachineInstrBuilder & setMemRefs(ArrayRef< MachineMemOperand * > MMOs) const
const MachineInstrBuilder & setOperandDead(unsigned OpIdx) const
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
Representation of each machine instruction.
bool killsRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr kills the specified register.
const MachineOperand & getOperand(unsigned i) const
A description of a memory reference used in the backend.
Flags
Flags values. These may be or'd together.
@ MOVolatile
The memory access is volatile.
@ MODereferenceable
The memory access is dereferenceable (i.e., doesn't trap).
@ MOLoad
The memory access reads data.
@ MOInvariant
The memory access always returns the same value (or traps).
@ MOStore
The memory access writes data.
MachineOperand class - Representation of each machine instruction operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
Register getReg() const
getReg - Returns the register number.
LLVM_ABI bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
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)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
A Module instance is used to store all the information related to an LLVM module.
Wrapper class representing virtual and physical registers.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
bool hasOneUse() const
Return true if there is exactly one use of this node.
SDNodeFlags getFlags() const
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
unsigned getNumOperands() const
Return the number of values used by this operation.
unsigned getMachineOpcode() const
This may only be called if isMachineOpcode returns true.
const SDValue & getOperand(unsigned Num) const
bool hasNUsesOfValue(unsigned NUses, unsigned Value) const
Return true if there are exactly NUSES uses of the indicated value.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
iterator_range< user_iterator > users()
void setFlags(SDNodeFlags NewFlags)
Represents a use of a SDNode.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node, in exactly one operand.
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
bool isMachineOpcode() const
TypeSize getValueSizeInBits() const
Returns the size of the value in bits.
const SDValue & getOperand(unsigned i) const
ISD::CondCode getOperandCondCode(unsigned i) const
const APInt & getConstantOperandAPInt(unsigned i) const
uint64_t getScalarValueSizeInBits() const
unsigned getResNo() const
get the index which selects a specific result in the SDNode
uint64_t getConstantOperandVal(unsigned i) const
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
unsigned getMachineOpcode() const
unsigned getOpcode() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
SDValue getExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT, unsigned Opcode)
Convert Op, which must be of integer type, to the integer type VT, by either any/sign/zero-extending ...
const TargetSubtargetInfo & getSubtarget() const
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, Register Reg, SDValue N)
LLVM_ABI SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
LLVM_ABI SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
LLVM_ABI SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget=false, bool IsOpaque=false)
LLVM_ABI 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),...
LLVM_ABI SDValue getAtomicLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT MemVT, EVT VT, SDValue Chain, SDValue Ptr, MachineMemOperand *MMO)
LLVM_ABI SDValue getConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offs=0, bool isT=false, unsigned TargetFlags=0)
LLVM_ABI bool isConstantIntBuildVectorOrConstantInt(SDValue N, bool AllowOpaques=true) const
Test whether the given value is a constant int or similar node.
LLVM_ABI SDValue UnrollVectorOp(SDNode *N, unsigned ResNE=0)
Utility function used by legalize and lowering to "unroll" a vector operation by splitting out the sc...
LLVM_ABI SDValue getAddrSpaceCast(const SDLoc &dl, EVT VT, SDValue Ptr, unsigned SrcAS, unsigned DestAS, const SDNodeFlags Flags=SDNodeFlags())
Return an AddrSpaceCastSDNode.
LLVM_ABI SDValue getRegister(Register Reg, EVT VT)
SDValue getGLOBAL_OFFSET_TABLE(EVT VT)
Return a GLOBAL_OFFSET_TABLE node. This does not have a useful SDLoc.
LLVM_ABI SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags Flags=MachineMemOperand::MOLoad|MachineMemOperand::MOStore, LocationSize Size=LocationSize::precise(0), const AAMDNodes &AAInfo=AAMDNodes())
Creates a MemIntrinsicNode that may produce a result and takes a list of operands.
LLVM_ABI 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.
void addNoMergeSiteInfo(const SDNode *Node, bool NoMerge)
Set NoMergeSiteInfo to be associated with Node if NoMerge is true.
LLVM_ABI SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a bitwise NOT operation as (XOR Val, -1).
LLVM_ABI SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align DstAlign, Align SrcAlign, bool isVol, bool AlwaysInline, const CallInst *CI, std::optional< bool > OverrideTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo=AAMDNodes(), BatchAAResults *BatchAA=nullptr)
const TargetLowering & getTargetLoweringInfo() const
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags=0)
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
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).
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
LLVM_ABI bool isSplatValue(SDValue V, const APInt &DemandedElts, APInt &UndefElts, unsigned Depth=0) const
Test whether V has a splatted value for all the demanded elements.
LLVM_ABI SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Offset, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
LLVM_ABI SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type.
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, Register Reg, EVT VT)
LLVM_ABI SDValue getNegative(SDValue Val, const SDLoc &DL, EVT VT)
Create negative operation as (SUB 0, Val).
const DataLayout & getDataLayout() const
SDValue getTargetFrameIndex(int FI, EVT VT)
LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Helper function to build ISD::STORE nodes.
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
SDValue getSignedTargetConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
LLVM_ABI SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
LLVM_ABI SDValue getSignedConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
SDValue getSplatVector(EVT VT, const SDLoc &DL, SDValue Op)
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 ...
LLVM_ABI bool SignBitIsZero(SDValue Op, unsigned Depth=0) const
Return true if the sign bit of Op is known to be zero.
LLVM_ABI SDValue getTargetExtractSubreg(int SRIdx, const SDLoc &DL, EVT VT, SDValue Operand)
A convenience function for creating TargetInstrInfo::EXTRACT_SUBREG nodes.
LLVM_ABI SDValue getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign-extending or trunca...
LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Loads are not normal binary operators: their result type is not determined by their operands,...
LLVM_ABI SDValue getExternalSymbol(const char *Sym, EVT VT)
const TargetMachine & getTarget() const
LLVM_ABI std::pair< SDValue, SDValue > getStrictFPExtendOrRound(SDValue Op, SDValue Chain, const SDLoc &DL, EVT VT)
Convert Op, which must be a STRICT operation of float type, to the float type VT, by either extending...
LLVM_ABI SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI SDValue getValueType(EVT)
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVM_ABI SDValue getFPExtendOrRound(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of float type, to the float type VT, by either extending or rounding (by tr...
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
LLVM_ABI 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.
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned TargetFlags=0)
LLVM_ABI void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.getNode() alone.
MachineFunction & getMachineFunction() const
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op)
Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all elements.
LLVM_ABI SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
LLVM_ABI 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.
LLVM_ABI SDValue getRegisterMask(const uint32_t *RegMask)
LLVM_ABI 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...
LLVM_ABI bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, TypeSize Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object.
LLVMContext * getContext() const
LLVM_ABI SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
LLVM_ABI SDValue CreateStackTemporary(TypeSize Bytes, Align Alignment)
Create a stack temporary based on the size in bytes and the alignment.
LLVM_ABI SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
SDValue getTargetConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offset=0, unsigned TargetFlags=0)
LLVM_ABI SDValue getTargetInsertSubreg(int SRIdx, const SDLoc &DL, EVT VT, SDValue Operand, SDValue Subreg)
A convenience function for creating TargetInstrInfo::INSERT_SUBREG nodes.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
LLVM_ABI std::pair< SDValue, SDValue > SplitScalar(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HiVT)
Split the scalar node with EXTRACT_ELEMENT using the provided VTs and return the low/high part.
LLVM_ABI SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
ArrayRef< int > getMask() const
const_iterator begin() const
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
This class is used to represent ISD::STORE nodes.
Represent a constant reference to a string, i.e.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
Check if the string is empty.
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
constexpr size_t size() const
Get the string size.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
A SystemZ-specific class detailing special use registers particular for calling conventions.
virtual int getStackPointerBias()=0
virtual int getReturnFunctionAddressRegister()=0
virtual int getCallFrameSize()=0
virtual int getStackPointerRegister()=0
static SystemZConstantPoolValue * Create(const GlobalValue *GV, SystemZCP::SystemZCPModifier Modifier)
unsigned getVarArgsFrameIndex() const
void setVarArgsFrameIndex(unsigned FI)
void setRegSaveFrameIndex(unsigned FI)
void incNumLocalDynamicTLSAccesses()
Register getVarArgsFirstGPR() const
void setADAVirtualRegister(Register Reg)
void setVarArgsFirstGPR(Register GPR)
Register getADAVirtualRegister() const
void setSizeOfFnParams(unsigned Size)
void setVarArgsFirstFPR(Register FPR)
unsigned getRegSaveFrameIndex() const
Register getVarArgsFirstFPR() const
SystemZCallingConventionRegisters * getSpecialRegisters() const
AtomicExpansionKind shouldExpandAtomicRMWInIR(const AtomicRMWInst *RMW) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
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...
EVT getOptimalMemOpType(LLVMContext &Context, const MemOp &Op, const AttributeList &FuncAttributes) const override
Returns the target specific optimal type for load and store operations as a result of memset,...
bool hasInlineStackProbe(const MachineFunction &MF) const override
Returns true if stack probing through inline assembly is requested.
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
MachineBasicBlock * emitEHSjLjSetJmp(MachineInstr &MI, MachineBasicBlock *MBB) const
AtomicExpansionKind shouldCastAtomicLoadInIR(LoadInst *LI) const override
Returns how the given (atomic) load should be cast by the IR-level AtomicExpand pass.
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &, EVT) const override
Return the ValueType of the result of SETCC operations.
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 ...
SDValue LowerAsmOutputForConstraint(SDValue &Chain, SDValue &Flag, const SDLoc &DL, const AsmOperandInfo &Constraint, SelectionDAG &DAG) const override
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,...
MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
MachineBasicBlock * emitEHSjLjLongJmp(MachineInstr &MI, MachineBasicBlock *MBB) const
bool useSoftFloat() const override
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, LLVMContext &Context, const Type *RetTy) const override
This hook should be implemented to check whether the return values described by the Outs array can fi...
bool canMergeStoresTo(unsigned AS, EVT MemVT, const MachineFunction &MF) const override
Returns if it's reasonable to merge stores to MemVT size.
std::pair< SDValue, SDValue > makeExternalCall(SDValue Chain, SelectionDAG &DAG, const char *CalleeName, EVT RetVT, ArrayRef< SDValue > Ops, CallingConv::ID CallConv, bool IsSigned, SDLoc DL, bool DoesNotReturn, bool IsReturnValueUsed) const
void insertSSPDeclarations(Module &M, const LibcallLoweringInfo &Libcalls) const override
Insert SSP declaration if global stack protector is used.
bool mayBeEmittedAsTailCall(const CallInst *CI) const override
Return true if the target may be able emit the call instruction as a tail call.
bool splitValueIntoRegisterParts(SelectionDAG &DAG, const SDLoc &DL, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, std::optional< CallingConv::ID > CC) const override
Target-specific splitting of values into parts that fit a register storing a legal type.
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...
unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Certain targets require unusual breakdowns of certain types.
bool isGuaranteedNotToBeUndefOrPoisonForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, UndefPoisonKind Kind, unsigned Depth) const override
Return true if this function can prove that Op is never poison and, Kind can be used to track poison ...
SystemZTargetLowering(const TargetMachine &TM, const SystemZSubtarget &STI)
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.
FPImmAction getFPImmAction(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns how the legalizer should materialize the specified FP immediate.
bool isLegalICmpImmediate(int64_t Imm) const override
Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructi...
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
bool isTypeDesirableForOp(SDNode *N, EVT VT) const override
Overload that takes the specific node being optimized.
TargetLowering::ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &info, const char *constraint) const override
Examine constraint string and operand type and determine a weight value.
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS, Align Alignment, MachineMemOperand::Flags Flags, unsigned *Fast) const override
Determine if the target supports unaligned memory accesses.
const MCPhysReg * getScratchRegisters(CallingConv::ID CC) const override
Returns a 0 terminated array of registers that can be safely used as scratch registers.
TargetLowering::ConstraintType getConstraintType(StringRef Constraint) const override
Given a constraint, return the type of constraint it is for this target.
Register getExceptionSelectorRegister(ExceptionHandling EH, const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception typeid on entry to a la...
SDValue joinRegisterPartsIntoValue(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts, unsigned NumParts, MVT PartVT, EVT ValueVT, std::optional< CallingConv::ID > CC) const override
Target-specific combining of register parts into its original value.
bool isTruncateFree(Type *, Type *) const override
Return true if it's free to truncate a value of type FromTy to type ToTy.
SDValue useLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, MVT VT, SDValue Arg, SDLoc DL, SDValue Chain, bool IsStrict) const
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.
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...
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...
SDValue LowerCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower calls into the specified DAG.
bool isLegalAddImmediate(int64_t Imm) const override
Return true if the specified immediate is legal add immediate, that is the target has add instruction...
CondMergingParams getJumpConditionMergingParams(Instruction::BinaryOps Opc, const Value *Lhs, const Value *Rhs, const Function *F) const override
TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT) const override
Return the preferred vector type legalization action.
bool findOptimalMemOpLowering(LLVMContext &Context, std::vector< EVT > &MemOps, unsigned Limit, const MemOp &Op, unsigned DstAS, unsigned SrcAS, const AttributeList &FuncAttributes, EVT *LargestVT=nullptr) const override
Determines the optimal series of memory ops to replace the memset / memcpy.
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...
void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const override
Lower the specified operand into the Ops vector.
Register getExceptionPointerRegister(ExceptionHandling EH, const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception address on entry to an ...
unsigned getVectorTypeBreakdownForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const override
Certain targets such as MIPS require that some types such as vectors are always broken down into scal...
bool aggressivelyPreferBuildVectorSources(EVT VecVT) const override
AtomicExpansionKind shouldCastAtomicStoreInIR(StoreInst *SI) const override
Returns how the given (atomic) store should be cast by the IR-level AtomicExpand pass into.
Register getRegisterByName(const char *RegName, LLT VT, const MachineFunction &MF) const override
Return the register ID of the name passed in.
bool hasAndNot(SDValue Y) const override
Return true if the target has a bitwise and-not operation: X = ~A & B This can be used to simplify se...
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,...
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...
unsigned getStackProbeSize(const MachineFunction &MF) const
XPLINK64 calling convention specific use registers Particular to z/OS when in 64 bit mode.
Information about stack frame layout on the target.
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
bool hasFP(const MachineFunction &MF) const
hasFP - Return true if the specified function should have a dedicated frame pointer register.
TargetInstrInfo - Interface to description of machine instruction set.
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...
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...
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
unsigned MaxStoresPerMemcpyOptSize
Likewise for functions with the OptSize attribute.
MachineBasicBlock * emitPatchPoint(MachineInstr &MI, MachineBasicBlock *MBB) const
Replace/modify any TargetFrameIndex operands with a targte-dependent sequence of memory operands that...
virtual const TargetRegisterClass * getRegClassFor(MVT VT, bool isDivergent=false) const
Return the register class that should be used for the specified value type.
const TargetMachine & getTargetMachine() const
virtual unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain targets require unusual breakdowns of certain types.
virtual MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
virtual void insertSSPDeclarations(Module &M, const LibcallLoweringInfo &Libcalls) const
Inserts necessary declarations for SSP (stack protection) purpose.
void setMaxAtomicSizeInBitsSupported(unsigned SizeInBits)
Set the maximum atomic operation size supported by the backend.
virtual TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT) const
Return the preferred vector type legalization action.
void setAtomicLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT, LegalizeAction Action)
Let target indicate that an extending atomic load of the specified type is legal.
virtual unsigned getVectorTypeBreakdownForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const
Certain targets such as MIPS require that some types such as vectors are always broken down into scal...
Register getStackPointerRegisterToSaveRestore() const
If a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save...
void setMinFunctionAlignment(Align Alignment)
Set the target's minimum function alignment.
unsigned MaxStoresPerMemsetOptSize
Likewise for functions with the OptSize attribute.
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
unsigned MaxStoresPerMemmove
Specify maximum number of store instructions per memmove call.
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose.
unsigned MaxStoresPerMemmoveOptSize
Likewise for functions with the OptSize attribute.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
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...
void setPrefFunctionAlignment(Align Alignment)
Set the target's preferred function alignment.
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
unsigned MaxStoresPerMemset
Specify maximum number of store instructions per memset call.
FPImmAction
How the legalizer should materialize a floating-point immediate.
@ ConstantPool
Load the immediate from the constant pool.
@ Legal
The target can instruction select the immediate natively.
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
@ ZeroOrOneBooleanContent
@ ZeroOrNegativeOneBooleanContent
virtual const TargetRegisterClass * getRepRegClassFor(MVT VT) const
Return the 'representative' register class for the specified value type.
void setStackPointerRegisterToSaveRestore(Register R)
If set to a physical register, this specifies the register that llvm.savestack/llvm....
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
void setTargetDAGCombine(ArrayRef< ISD::NodeType > NTs)
Targets should invoke this method for each target independent node that they want to provide a custom...
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...
virtual bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const
Returns true if arguments should be sign-extended in lib calls.
std::vector< ArgListEntry > ArgListTy
unsigned MaxStoresPerMemcpy
Specify maximum number of store instructions per memcpy call.
virtual MVT getPointerMemTy(const DataLayout &DL, uint32_t AS=0) const
Return the in-memory pointer type for the given address space, defaults to the pointer type from the ...
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
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...
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
virtual bool findOptimalMemOpLowering(LLVMContext &Context, std::vector< EVT > &MemOps, unsigned Limit, const MemOp &Op, unsigned DstAS, unsigned SrcAS, const AttributeList &FuncAttributes, EVT *LargestVT=nullptr) const
Determines the optimal series of memory ops to replace the memset / memcpy.
virtual SDValue LowerToTLSEmulatedModel(const GlobalAddressSDNode *GA, SelectionDAG &DAG) const
Lower TLS global address SDNode for target independent emulated TLS model.
virtual bool isTypeDesirableForOp(unsigned, EVT VT) const
Return true if the target has native support for the specified value type and it is 'desirable' to us...
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
virtual ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &info, const char *constraint) const
Examine constraint string and operand type and determine a weight value.
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
TargetLowering(const TargetLowering &)=delete
virtual void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
Lower the specified operand into the Ops vector.
std::pair< SDValue, SDValue > makeLibCall(SelectionDAG &DAG, RTLIB::LibcallImpl LibcallImpl, EVT RetVT, ArrayRef< SDValue > Ops, MakeLibCallOptions CallOptions, const SDLoc &dl, SDValue Chain=SDValue()) const
Returns a pair of (return value, chain).
Primary interface to the complete machine description for the target machine.
TLSModel::Model getTLSModel(const GlobalValue *GV) const
Returns the TLS model which should be used for the given global variable.
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
CodeModel::Model getCodeModel() const
Returns the code model.
unsigned VerifyArgABICompliance
When set to true, call/return argument extensions of narrow integers are verified in the target backe...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetInstrInfo * getInstrInfo() const
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
bool isVectorTy() const
True if this is an instance of VectorType.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
bool isIntegerTy() const
True if this is an instance of IntegerType.
A Use represents the edge between a Value definition and its users.
User * getUser() const
Returns the User that contains this Use.
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
user_iterator user_begin()
bool hasOneUse() const
Return true if there is exactly one use of this value.
constexpr ScalarTy getFixedValue() const
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ GHC
Used by the Glasgow Haskell Compiler (GHC).
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI bool isConstantSplatVector(SDValue V, APInt &SplatValue)
Node predicates.
bool isNON_EXTLoad(const SDNode *N)
Returns true if the specified node is a non-extending load.
LLVM_ABI bool isConstantSplatVectorAllZeros(SDValue V, bool BuildVectorOnly=false)
Return true if the specified value is a BUILD_VECTOR or SPLAT_VECTOR where all of the elements are 0 ...
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ MERGE_VALUES
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
@ STACKRESTORE
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain.
@ STACKSAVE
STACKSAVE - STACKSAVE has one operand, an input chain.
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
@ POISON
POISON - A poison node.
@ EH_SJLJ_LONGJMP
OUTCHAIN = EH_SJLJ_LONGJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.longjmp intrinsic.
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ BSWAP
Byte Swap and Counting operators.
@ VAEND
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE.
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, val, ptr) This corresponds to "store atomic" instruction.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ FMA
FMA - Perform a * b + c with no intermediate rounding step.
@ PSEUDO_FMIN
PSEUDO_FMIN is strictly equivalent to op0 olt op1 ?
@ INTRINSIC_VOID
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ FADD
Simple binary floating point operators.
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ MEMBARRIER
MEMBARRIER - Compiler barrier only; generate a no-op.
@ ATOMIC_FENCE
OUTCHAIN = ATOMIC_FENCE(INCHAIN, ordering, scope) This corresponds to the fence instruction.
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ STRICT_FSQRT
Constrained versions of libm-equivalent floating point intrinsics.
@ BUILTIN_OP_END
BUILTIN_OP_END - This must be the last enum value in this list.
@ SIGN_EXTEND
Conversion operators.
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ PREFETCH
PREFETCH - This corresponds to a prefetch intrinsic.
@ FSINCOS
FSINCOS - Compute both fsin and fcos as a single operation.
@ FNEG
Perform various unary floating-point operations inspired by libm.
@ BR_CC
BR_CC - Conditional branch.
@ SSUBO
Same for subtraction.
@ BR_JT
BR_JT - Jumptable branch.
@ IS_FPCLASS
Performs a check of floating point class property, defined by IEEE-754.
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ ATOMIC_LOAD
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
@ UNDEF
UNDEF - An undefined node.
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ VACOPY
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer,...
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ VECREDUCE_ADD
Integer reductions may have a result type larger than the vector element type.
@ GET_ROUNDING
Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest, ties to even 2 Round to ...
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ FMINNUM
FMINNUM/FMAXNUM - Same semantics as the llvm.minnum/maxnum intrinsics.
@ DYNAMIC_STACKALLOC
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary.
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ STRICT_SINT_TO_FP
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ PEXT
Parallel bit extract (compress) and parallel bit deposit (expand).
@ STRICT_FP_ROUND
X = STRICT_FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision ...
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FMINIMUM
FMINIMUM/FMAXIMUM - Same semantics as the llvm.minimum/maximum intrinsics.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
@ STRICT_FP_EXTEND
X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ TRAP
TRAP - Trapping instruction.
@ INTRINSIC_WO_CHAIN
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
@ STRICT_FADD
Constrained versions of the binary floating point operators.
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
@ CTTZ_ZERO_POISON
Bit counting operators with a poisoned result for zero inputs.
@ FP_ROUND
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
@ ZERO_EXTEND_VECTOR_INREG
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
@ ADDRSPACECAST
ADDRSPACECAST - This operator converts between pointers of different address spaces.
@ EH_SJLJ_SETJMP
RESULT, OUTCHAIN = EH_SJLJ_SETJMP(INCHAIN, buffer) This corresponds to the eh.sjlj....
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ BRCOND
BRCOND - Conditional branch.
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ FCOPYSIGN
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
@ GET_DYNAMIC_AREA_OFFSET
GET_DYNAMIC_AREA_OFFSET - get offset from native SP to the address of the most recent dynamic alloca.
@ FMINIMUMNUM
FMINIMUMNUM/FMAXIMUMNUM - Same semantics as the llvm.minimumnum/maximumnum intrinsics.
@ INTRINSIC_W_CHAIN
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
LLVM_ABI CondCode getSetCCInverse(CondCode Operation, EVT Type)
Return the operation corresponding to !(X op Y), where 'op' is a valid SetCC operation.
LLVM_ABI CondCode getSetCCSwappedOperands(CondCode Operation)
Return the operation corresponding to (Y op X) when given the operation for (X op Y).
LLVM_ABI bool isBuildVectorAllZeros(SDValue V)
Return true if the specified value is a BUILD_VECTOR where all of the elements are 0 or undef.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
auto m_Cmp()
Matches any compare instruction and ignore it.
ap_match< APInt > m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt.
bool match(Val *V, const Pattern &P)
auto m_Value()
Match an arbitrary value and ignore it.
LLVM_ABI Libcall getSINTTOFP(EVT OpVT, EVT RetVT)
getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getUINTTOFP(EVT OpVT, EVT RetVT)
getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
LLVM_ABI Libcall getFPTOSINT(EVT OpVT, EVT RetVT)
getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or UNKNOWN_LIBCALL if there is none.
@ System
Synchronized with respect to all concurrently executing threads.
@ MO_ADA_DATA_SYMBOL_ADDR
@ MO_ADA_DIRECT_FUNC_DESC
@ MO_ADA_INDIRECT_FUNC_DESC
const unsigned GR64Regs[16]
const unsigned VR128Regs[32]
const unsigned VR16Regs[32]
const unsigned GR128Regs[16]
const unsigned FP32Regs[16]
const unsigned FP16Regs[16]
const unsigned GR32Regs[16]
const unsigned FP64Regs[16]
const int64_t ELFCallFrameSize
const unsigned VR64Regs[32]
const unsigned FP128Regs[16]
const unsigned VR32Regs[32]
unsigned odd128(bool Is32bit)
const unsigned CCMASK_CMP_GE
static bool isImmHH(uint64_t Val)
const unsigned CCMASK_TEND
const unsigned CCMASK_CS_EQ
const unsigned CCMASK_TBEGIN
const MCPhysReg ELFArgFPRs[ELFNumArgFPRs]
MachineBasicBlock * splitBlockBefore(MachineBasicBlock::iterator MI, MachineBasicBlock *MBB)
const unsigned CCMASK_TM_SOME_1
const unsigned CCMASK_LOGICAL_CARRY
const unsigned TDCMASK_NORMAL_MINUS
const unsigned CCMASK_TDC
const unsigned CCMASK_FCMP
const unsigned CCMASK_TM_SOME_0
static bool isImmHL(uint64_t Val)
const unsigned TDCMASK_SUBNORMAL_MINUS
const unsigned TDCMASK_NORMAL_PLUS
const unsigned CCMASK_CMP_GT
const unsigned TDCMASK_QNAN_MINUS
const unsigned CCMASK_ANY
const unsigned CCMASK_ARITH
const unsigned CCMASK_TM_MIXED_MSB_0
const unsigned TDCMASK_SUBNORMAL_PLUS
static bool isImmLL(uint64_t Val)
const unsigned VectorBits
static bool isImmLH(uint64_t Val)
MachineBasicBlock * emitBlockAfter(MachineBasicBlock *MBB)
const unsigned TDCMASK_INFINITY_PLUS
unsigned reverseCCMask(unsigned CCMask)
const unsigned CCMASK_TM_ALL_0
const unsigned CCMASK_CMP_LE
const unsigned CCMASK_CMP_O
const unsigned CCMASK_CMP_EQ
const unsigned VectorBytes
const unsigned TDCMASK_INFINITY_MINUS
const unsigned CCMASK_ICMP
const unsigned CCMASK_VCMP_ALL
const unsigned CCMASK_VCMP_NONE
MachineBasicBlock * splitBlockAfter(MachineBasicBlock::iterator MI, MachineBasicBlock *MBB)
const unsigned CCMASK_VCMP
const unsigned CCMASK_TM_MIXED_MSB_1
const unsigned CCMASK_TM_MSB_0
const unsigned CCMASK_ARITH_OVERFLOW
const unsigned CCMASK_CS_NE
const unsigned TDCMASK_SNAN_PLUS
const unsigned CCMASK_NONE
const unsigned CCMASK_CMP_LT
const unsigned CCMASK_CMP_NE
const unsigned TDCMASK_ZERO_PLUS
const unsigned TDCMASK_QNAN_PLUS
const unsigned TDCMASK_ZERO_MINUS
unsigned even128(bool Is32bit)
const unsigned CCMASK_TM_ALL_1
const unsigned CCMASK_LOGICAL_BORROW
const unsigned ELFNumArgFPRs
const unsigned CCMASK_CMP_UO
const unsigned CCMASK_LOGICAL
const unsigned CCMASK_TM_MSB_1
const unsigned TDCMASK_SNAN_MINUS
support::ulittle32_t Word
@ User
could "use" a pointer
NodeAddr< UseNode * > Use
NodeAddr< NodeBase * > Node
NodeAddr< CodeNode * > Code
This is an optimization pass for GlobalISel generic memory operations.
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
@ Known
Known to have no common set bits.
@ Define
Register definition.
LLVM_ABI SDValue peekThroughBitcasts(SDValue V)
Return the non-bitcasted source operand of V if it exists.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
@ Load
The value being inserted comes from a load (InsertElement only).
testing::Matcher< const detail::ErrorHolder & > Failed()
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
constexpr T maskLeadingOnes(unsigned N)
Create a bitmask with the N left-most bits set to 1, and all other bits set to 0.
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
LLVM_ABI void dumpBytes(ArrayRef< uint8_t > Bytes, raw_ostream &OS)
Convert ‘Bytes’ to a hex string and output to ‘OS’.
T bit_ceil(T Value)
Returns the smallest integral power of two no smaller than Value if Value is nonzero.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
int countl_zero(T Val)
Count number of 0's from the most significant bit to the least stopping at the first 1.
LLVM_ABI bool isBitwiseNot(SDValue V, bool AllowUndefs=false)
Returns true if V is a bitwise not operation.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Success
The lock was released successfully.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
AtomicOrdering
Atomic ordering for LLVM's memory model.
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
@ Fast
Assign the register banks as fast as possible (default).
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
DWARFExpression::Operation Op
constexpr std::optional< bool > toOptional(BoolOrDefault X)
ArrayRef(const T &OneElt) -> ArrayRef< T >
LLVM_ABI ConstantSDNode * isConstOrConstSplat(SDValue N, bool AllowUndefs=false, bool AllowTruncation=false)
Returns the SDNode if it is a constant splat BuildVector or constant int.
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
UndefPoisonKind
Enumeration to track whether we are interested in Undef, Poison, or both.
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
constexpr T maskTrailingOnes(unsigned N)
Create a bitmask with the N right-most bits set to 1, and all other bits set to 0.
T bit_floor(T Value)
Returns the largest integral power of two no greater than Value if Value is nonzero.
@ End
Run the machine verifier once, at the end of the pipeline.
LLVM_ABI bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
MCRegisterClass TargetRegisterClass
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
AddressingMode(bool LongDispl, bool IdxReg)
This struct is a compact representation of a valid (non-zero power of two) alignment.
EVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
uint64_t getScalarSizeInBits() const
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
uint64_t getFixedSizeInBits() const
Return the size of the specified fixed width value type in bits.
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
bool isRound() const
Return true if the size is a power-of-two number of bytes.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
bool isVectorOf(EVT EltVT) const
Return true if this is a vector with matching element type.
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool isInteger() const
Return true if this is an integer or a vector integer type.
KnownBits intersectWith(const KnownBits &RHS) const
Returns KnownBits information that is known to be true for both this and RHS.
APInt getMaxValue() const
Return the maximal unsigned value possible given these KnownBits.
This class contains a discriminated union of information about pointers in memory operands,...
static LLVM_ABI MachinePointerInfo getConstantPool(MachineFunction &MF)
Return a MachinePointerInfo record that refers to the constant pool.
MachinePointerInfo getWithOffset(int64_t O) const
static LLVM_ABI MachinePointerInfo getGOT(MachineFunction &MF)
Return a MachinePointerInfo record that refers to a GOT entry.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
SystemZVectorConstantInfo(APInt IntImm)
SmallVector< unsigned, 2 > OpVals
bool isVectorConstantLegal(const SystemZSubtarget &Subtarget)
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg + ScalableOffset*...
This contains information for each constraint that we are lowering.
This structure contains all information that is necessary for lowering calls.
SmallVector< ISD::InputArg, 32 > Ins
CallLoweringInfo & setDiscardResult(bool Value=true)
CallLoweringInfo & setZExtResult(bool Value=true)
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
CallLoweringInfo & setSExtResult(bool Value=true)
CallLoweringInfo & setNoReturn(bool Value=true)
SmallVector< ISD::OutputArg, 32 > Outs
SmallVector< SDValue, 32 > OutVals
CallLoweringInfo & setChain(SDValue InChain)
CallLoweringInfo & setCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList, AttributeSet ResultAttrs={})
This structure is used to pass arguments to makeLibCall function.