100 #define DEBUG_TYPE "ppc-lowering" 106 cl::desc(
"disable setting the node scheduling preference to ILP on PPC"),
cl::Hidden);
117 STATISTIC(NumTailCalls,
"Number of tail calls");
118 STATISTIC(NumSiblingCalls,
"Number of sibling calls");
134 bool isPPC64 = Subtarget.
isPPC64();
175 if (!Subtarget.
hasSPE()) {
184 for (
MVT VT : ScalarIntVTs) {
194 if (isPPC64 || Subtarget.
hasFPCVT()) {
200 isPPC64 ? MVT::i64 : MVT::i32);
1185 unsigned MaxMaxAlign) {
1186 if (MaxAlign == MaxMaxAlign)
1188 if (
VectorType *VTy = dyn_cast<VectorType>(Ty)) {
1189 if (MaxMaxAlign >= 32 && VTy->getBitWidth() >= 256)
1191 else if (VTy->getBitWidth() >= 128 && MaxAlign < 16)
1193 }
else if (
ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
1194 unsigned EltAlign = 0;
1196 if (EltAlign > MaxAlign)
1197 MaxAlign = EltAlign;
1198 }
else if (
StructType *STy = dyn_cast<StructType>(Ty)) {
1199 for (
auto *EltTy : STy->elements()) {
1200 unsigned EltAlign = 0;
1202 if (EltAlign > MaxAlign)
1203 MaxAlign = EltAlign;
1204 if (MaxAlign == MaxMaxAlign)
1247 return Subtarget.
hasSPE();
1263 return "PPCISD::FP_TO_UINT_IN_VSR,";
1265 return "PPCISD::FP_TO_SINT_IN_VSR";
1320 return "PPCISD::ST_VSR_SCAL_INT";
1385 return CFP->getValueAPF().isZero();
1389 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
CP->getConstVal()))
1390 return CFP->getValueAPF().isZero();
1398 return Op < 0 || Op == Val;
1410 if (ShuffleKind == 0) {
1413 for (
unsigned i = 0; i != 16; ++i)
1416 }
else if (ShuffleKind == 2) {
1419 for (
unsigned i = 0; i != 16; ++i)
1422 }
else if (ShuffleKind == 1) {
1423 unsigned j = IsLE ? 0 : 1;
1424 for (
unsigned i = 0; i != 8; ++i)
1441 if (ShuffleKind == 0) {
1444 for (
unsigned i = 0; i != 16; i += 2)
1448 }
else if (ShuffleKind == 2) {
1451 for (
unsigned i = 0; i != 16; i += 2)
1455 }
else if (ShuffleKind == 1) {
1456 unsigned j = IsLE ? 0 : 2;
1457 for (
unsigned i = 0; i != 8; i += 2)
1483 if (ShuffleKind == 0) {
1486 for (
unsigned i = 0; i != 16; i += 4)
1492 }
else if (ShuffleKind == 2) {
1495 for (
unsigned i = 0; i != 16; i += 4)
1501 }
else if (ShuffleKind == 1) {
1502 unsigned j = IsLE ? 0 : 4;
1503 for (
unsigned i = 0; i != 8; i += 4)
1520 unsigned LHSStart,
unsigned RHSStart) {
1523 assert((UnitSize == 1 || UnitSize == 2 || UnitSize == 4) &&
1524 "Unsupported merge size!");
1526 for (
unsigned i = 0; i != 8/UnitSize; ++i)
1527 for (
unsigned j = 0; j != UnitSize; ++j) {
1529 LHSStart+j+i*UnitSize) ||
1531 RHSStart+j+i*UnitSize))
1546 if (ShuffleKind == 1)
1547 return isVMerge(N, UnitSize, 0, 0);
1548 else if (ShuffleKind == 2)
1549 return isVMerge(N, UnitSize, 0, 16);
1553 if (ShuffleKind == 1)
1554 return isVMerge(N, UnitSize, 8, 8);
1555 else if (ShuffleKind == 0)
1556 return isVMerge(N, UnitSize, 8, 24);
1571 if (ShuffleKind == 1)
1572 return isVMerge(N, UnitSize, 8, 8);
1573 else if (ShuffleKind == 2)
1574 return isVMerge(N, UnitSize, 8, 24);
1578 if (ShuffleKind == 1)
1579 return isVMerge(N, UnitSize, 0, 0);
1580 else if (ShuffleKind == 0)
1581 return isVMerge(N, UnitSize, 0, 16);
1630 unsigned RHSStartValue) {
1634 for (
unsigned i = 0; i < 2; ++i)
1635 for (
unsigned j = 0; j < 4; ++j)
1637 i*RHSStartValue+j+IndexOffset) ||
1639 i*RHSStartValue+j+IndexOffset+8))
1661 unsigned indexOffset = CheckEven ? 4 : 0;
1662 if (ShuffleKind == 1)
1663 return isVMerge(N, indexOffset, 0);
1664 else if (ShuffleKind == 2)
1665 return isVMerge(N, indexOffset, 16);
1670 unsigned indexOffset = CheckEven ? 0 : 4;
1671 if (ShuffleKind == 1)
1672 return isVMerge(N, indexOffset, 0);
1673 else if (ShuffleKind == 0)
1674 return isVMerge(N, indexOffset, 16);
1696 for (i = 0; i != 16 && SVOp->
getMaskElt(i) < 0; ++i)
1699 if (i == 16)
return -1;
1704 if (ShiftAmt < i)
return -1;
1709 if ((ShuffleKind == 0 && !isLE) || (ShuffleKind == 2 && isLE)) {
1711 for (++i; i != 16; ++i)
1714 }
else if (ShuffleKind == 1) {
1716 for (++i; i != 16; ++i)
1723 ShiftAmt = 16 - ShiftAmt;
1733 (EltSize == 1 || EltSize == 2 || EltSize == 4));
1745 if (ElementBase >= 16)
1750 for (
unsigned i = 1; i != EltSize; ++i)
1754 for (
unsigned i = EltSize, e = 16; i != e; i += EltSize) {
1756 for (
unsigned j = 0; j != EltSize; ++j)
1774 assert((Width == 2 || Width == 4 || Width == 8 || Width == 16) &&
1775 "Unexpected element width.");
1776 assert((StepLen == 1 || StepLen == -1) &&
"Unexpected element width.");
1778 unsigned NumOfElem = 16 / Width;
1779 unsigned MaskVal[16];
1780 for (
unsigned i = 0; i < NumOfElem; ++i) {
1782 if ((StepLen == 1) && (MaskVal[0] % Width)) {
1784 }
else if ((StepLen == -1) && ((MaskVal[0] + 1) % Width)) {
1788 for (
unsigned int j = 1; j < Width; ++j) {
1790 if (MaskVal[j] != MaskVal[j-1] + StepLen) {
1800 unsigned &InsertAtByte,
bool &Swap,
bool IsLE) {
1809 unsigned LittleEndianShifts[] = { 2, 1, 0, 3 };
1810 unsigned BigEndianShifts[] = { 3, 0, 1, 2 };
1815 if ((M0 > 3 && M1 == 1 && M2 == 2 && M3 == 3) ||
1816 (M0 < 4 && M1 == 5 && M2 == 6 && M3 == 7)) {
1817 ShiftElts = IsLE ? LittleEndianShifts[M0 & 0x3] : BigEndianShifts[M0 & 0x3];
1818 InsertAtByte = IsLE ? 12 : 0;
1823 if ((M1 > 3 && M0 == 0 && M2 == 2 && M3 == 3) ||
1824 (M1 < 4 && M0 == 4 && M2 == 6 && M3 == 7)) {
1825 ShiftElts = IsLE ? LittleEndianShifts[M1 & 0x3] : BigEndianShifts[M1 & 0x3];
1826 InsertAtByte = IsLE ? 8 : 4;
1831 if ((M2 > 3 && M0 == 0 && M1 == 1 && M3 == 3) ||
1832 (M2 < 4 && M0 == 4 && M1 == 5 && M3 == 7)) {
1833 ShiftElts = IsLE ? LittleEndianShifts[M2 & 0x3] : BigEndianShifts[M2 & 0x3];
1834 InsertAtByte = IsLE ? 4 : 8;
1839 if ((M3 > 3 && M0 == 0 && M1 == 1 && M2 == 2) ||
1840 (M3 < 4 && M0 == 4 && M1 == 5 && M2 == 6)) {
1841 ShiftElts = IsLE ? LittleEndianShifts[M3 & 0x3] : BigEndianShifts[M3 & 0x3];
1842 InsertAtByte = IsLE ? 0 : 12;
1852 unsigned XXINSERTWSrcElem = IsLE ? 2 : 1;
1853 if (M0 == XXINSERTWSrcElem && M1 == 1 && M2 == 2 && M3 == 3) {
1854 InsertAtByte = IsLE ? 12 : 0;
1857 if (M0 == 0 && M1 == XXINSERTWSrcElem && M2 == 2 && M3 == 3) {
1858 InsertAtByte = IsLE ? 8 : 4;
1861 if (M0 == 0 && M1 == 1 && M2 == XXINSERTWSrcElem && M3 == 3) {
1862 InsertAtByte = IsLE ? 4 : 8;
1865 if (M0 == 0 && M1 == 1 && M2 == 2 && M3 == XXINSERTWSrcElem) {
1866 InsertAtByte = IsLE ? 0 : 12;
1875 bool &Swap,
bool IsLE) {
1890 assert(M0 < 4 &&
"Indexing into an undef vector?");
1891 if (M1 != (M0 + 1) % 4 || M2 != (M1 + 1) % 4 || M3 != (M2 + 1) % 4)
1894 ShiftElts = IsLE ? (4 - M0) % 4 : M0;
1900 if (M1 != (M0 + 1) % 8 || M2 != (M1 + 1) % 8 || M3 != (M2 + 1) % 8)
1904 if (M0 == 0 || M0 == 7 || M0 == 6 || M0 == 5) {
1909 ShiftElts = (8 - M0) % 8;
1910 }
else if (M0 == 4 || M0 == 3 || M0 == 2 || M0 == 1) {
1915 ShiftElts = (4 - M0) % 4;
1920 if (M0 == 0 || M0 == 1 || M0 == 2 || M0 == 3) {
1925 }
else if (M0 == 4 || M0 == 5 || M0 == 6 || M0 == 7) {
1942 for (
int i = 0; i < 16; i += Width)
1974 bool &Swap,
bool IsLE) {
1983 assert(((M0 | M1) < 4) &&
"A mask element out of bounds?");
1988 if ((M0 | M1) < 2) {
1989 DM = IsLE ? (((~M1) & 1) << 1) + ((~M0) & 1) : (M0 << 1) + (M1 & 1);
1997 if (M0 > 1 && M1 < 2) {
1999 }
else if (M0 < 2 && M1 > 1) {
2007 DM = (((~M1) & 1) << 1) + ((~M0) & 1);
2010 if (M0 < 2 && M1 > 1) {
2012 }
else if (M0 > 1 && M1 < 2) {
2020 DM = (M0 << 1) + (M1 & 1);
2033 return (16 / EltSize) - 1 - (SVOp->
getMaskElt(0) / EltSize);
2050 if (EltSize < ByteSize) {
2051 unsigned Multiple = ByteSize/EltSize;
2053 assert(Multiple > 1 && Multiple <= 4 &&
"How can this happen?");
2061 if (!UniquedVals[i&(Multiple-1)].getNode())
2062 UniquedVals[i&(Multiple-1)] = N->
getOperand(i);
2063 else if (UniquedVals[i&(Multiple-1)] != N->
getOperand(i))
2073 bool LeadingZero =
true;
2074 bool LeadingOnes =
true;
2075 for (
unsigned i = 0; i != Multiple-1; ++i) {
2076 if (!UniquedVals[i].getNode())
continue;
2083 if (!UniquedVals[Multiple-1].getNode())
2085 int Val = cast<ConstantSDNode>(UniquedVals[Multiple-1])->getZExtValue();
2090 if (!UniquedVals[Multiple-1].getNode())
2092 int Val =cast<ConstantSDNode>(UniquedVals[Multiple-1])->getSExtValue();
2111 unsigned ValSizeInBytes = EltSize;
2114 Value = CN->getZExtValue();
2116 assert(CN->getValueType(0) ==
MVT::f32 &&
"Only one legal FP vector type!");
2117 Value =
FloatToBits(CN->getValueAPF().convertToFloat());
2123 if (ValSizeInBytes < ByteSize)
return SDValue();
2127 if (!
APInt(ValSizeInBytes * 8, Value).
isSplat(ByteSize * 8))
2134 if (MaskVal == 0)
return SDValue();
2137 if (SignExtend32<5>(MaskVal) == MaskVal)
2153 for (i = 0; i != 4 && SVOp->
getMaskElt(i) < 0; ++i)
2156 if (i == 4)
return -1;
2161 if (ShiftAmt < i)
return -1;
2165 for (++i; i != 4; ++i)
2181 if (!isa<ConstantSDNode>(N))
2184 Imm = (int16_t)cast<ConstantSDNode>(N)->getZExtValue();
2186 return Imm == (int32_t)cast<ConstantSDNode>(
N)->getZExtValue();
2188 return Imm == (int64_t)cast<ConstantSDNode>(N)->getZExtValue();
2224 if (~(LHSKnown.
Zero | RHSKnown.
Zero) == 0) {
2282 unsigned Alignment)
const {
2292 (!Alignment || (imm % Alignment) == 0)) {
2304 &&
"Cannot handle constant offsets yet!");
2316 (!Alignment || (imm % Alignment) == 0)) {
2327 dyn_cast<FrameIndexSDNode>(N.
getOperand(0))) {
2346 CN->getValueType(0));
2351 if ((CN->getValueType(0) ==
MVT::i32 ||
2352 (int64_t)CN->getZExtValue() == (int)CN->getZExtValue()) &&
2353 (!Alignment || (CN->getZExtValue() % Alignment) == 0)) {
2354 int Addr = (int)CN->getZExtValue();
2422 Ptr =
LD->getBasePtr();
2423 VT =
LD->getMemoryVT();
2424 Alignment =
LD->getAlignment();
2426 Ptr =
ST->getBasePtr();
2427 VT =
ST->getMemoryVT();
2428 Alignment =
ST->getAlignment();
2451 if (isa<FrameIndexSDNode>(Base) || isa<RegisterSDNode>(Base))
2454 SDValue Val = cast<StoreSDNode>(
N)->getValue();
2484 isa<ConstantSDNode>(
Offset))
2499 unsigned &HiOpFlags,
unsigned &LoOpFlags,
2516 if (GV->hasHiddenVisibility()) {
2578 unsigned MOHiFlag, MOLoFlag;
2654 unsigned MOHiFlag, MOLoFlag;
2684 unsigned MOHiFlag, MOLoFlag;
2705 bool is64bit = Subtarget.
isPPC64();
2732 PtrVT, GOTReg, TGA);
2736 PtrVT, TGA, GOTPtr);
2773 PtrVT, GOTPtr, TGA, TGA);
2775 PtrVT, TLSAddr, TGA);
2797 unsigned MOHiFlag, MOLoFlag;
2857 if (
C->isAllOnesValue() ||
C->isNullValue())
2882 const Value *SV = cast<SrcValueSDNode>(Node->
getOperand(2))->getValue();
2923 InChain = OverflowArea.
getValue(1);
2969 InChain = DAG.
getTruncStore(InChain, dl, OverflowArea, OverflowAreaPtr,
2976 assert(!Subtarget.
isPPC64() &&
"LowerVACOPY is PPC32 only");
3000 bool isPPC64 = (PtrVT ==
MVT::i64);
3006 Entry.
Ty = IntPtrTy;
3007 Entry.
Node = Trmp; Args.push_back(Entry);
3012 Args.push_back(Entry);
3014 Entry.
Node = FPtr; Args.push_back(Entry);
3015 Entry.
Node = Nest; Args.push_back(Entry);
3023 std::pair<SDValue, SDValue> CallResult =
LowerCallTo(CLI);
3024 return CallResult.second;
3074 uint64_t FrameOffset = PtrVT.getSizeInBits()/8;
3077 uint64_t StackOffset = PtrVT.getSizeInBits()/8 - 1;
3080 uint64_t FPROffset = 1;
3089 uint64_t nextOffset = FPROffset;
3097 nextOffset += StackOffset;
3098 nextPtr = DAG.
getNode(
ISD::ADD, dl, PtrVT, nextPtr, ConstStackOffset);
3101 SDValue thirdStore = DAG.
getStore(secondStore, dl, StackOffsetFI, nextPtr,
3103 nextOffset += FrameOffset;
3104 nextPtr = DAG.
getNode(
ISD::ADD, dl, PtrVT, nextPtr, ConstFrameOffset);
3107 return DAG.
getStore(thirdStore, dl, FR, nextPtr,
3111 #include "PPCGenCallingConv.inc" 3115 CCAssignFn *PPCTargetLowering::useFastISelCCs(
unsigned Flag)
const {
3116 return Flag ? CC_PPC64_ELF_FIS : RetCC_PPC64_ELF_FIS;
3133 PPC::R7, PPC::R8, PPC::R9, PPC::R10,
3143 if (RegNum != NumArgRegs && RegNum % 2 == 1) {
3161 PPC::R7, PPC::R8, PPC::R9, PPC::R10,
3166 int RegsLeft = NumArgRegs - RegNum;
3170 if (RegNum != NumArgRegs && RegsLeft < 4) {
3171 for (
int i = 0; i < RegsLeft; i++) {
3185 PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5, PPC::F6, PPC::F7,
3195 if (RegNum != NumArgRegs && ArgRegs[RegNum] == PPC::F8) {
3208 static const MCPhysReg FPR[] = {PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5,
3209 PPC::F6, PPC::F7, PPC::F8, PPC::F9, PPC::F10,
3210 PPC::F11, PPC::F12, PPC::F13};
3214 PPC::QF1, PPC::QF2, PPC::QF3, PPC::QF4, PPC::QF5, PPC::QF6, PPC::QF7,
3215 PPC::QF8, PPC::QF9, PPC::QF10, PPC::QF11, PPC::QF12, PPC::QF13};
3220 unsigned PtrByteSize) {
3228 ArgSize = ((ArgSize + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
3237 unsigned PtrByteSize) {
3238 unsigned Align = PtrByteSize;
3254 if (BVAlign > PtrByteSize) {
3255 if (BVAlign % PtrByteSize != 0)
3257 "ByVal alignment is not a multiple of the pointer size");
3283 unsigned PtrByteSize,
3284 unsigned LinkageSize,
3285 unsigned ParamAreaSize,
3286 unsigned &ArgOffset,
3287 unsigned &AvailableFPRs,
3288 unsigned &AvailableVRs,
bool HasQPX) {
3289 bool UseMemory =
false;
3294 ArgOffset = ((ArgOffset + Align - 1) / Align) *
Align;
3297 if (ArgOffset >= LinkageSize + ParamAreaSize)
3303 ArgOffset = ((ArgOffset + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
3306 if (ArgOffset > LinkageSize + ParamAreaSize)
3317 if (AvailableFPRs > 0) {
3325 if (AvailableVRs > 0) {
3337 unsigned NumBytes) {
3339 unsigned AlignMask = TargetAlign - 1;
3340 NumBytes = (NumBytes + AlignMask) & ~AlignMask;
3344 SDValue PPCTargetLowering::LowerFormalArguments(
3350 return LowerFormalArguments_64SVR4(Chain, CallConv, isVarArg, Ins,
3353 return LowerFormalArguments_32SVR4(Chain, CallConv, isVarArg, Ins,
3356 return LowerFormalArguments_Darwin(Chain, CallConv, isVarArg, Ins,
3361 SDValue PPCTargetLowering::LowerFormalArguments_32SVR4(
3403 unsigned PtrByteSize = 4;
3412 CCInfo.AllocateStack(LinkageSize, PtrByteSize);
3414 CCInfo.PreAnalyzeFormalArguments(Ins);
3416 CCInfo.AnalyzeFormalArguments(Ins, CC_PPC32_SVR4);
3417 CCInfo.clearWasPPCF128();
3419 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
3432 RC = &PPC::GPRCRegClass;
3436 RC = &PPC::VSSRCRegClass;
3437 else if (Subtarget.
hasSPE())
3438 RC = &PPC::SPE4RCRegClass;
3440 RC = &PPC::F4RCRegClass;
3444 RC = &PPC::VSFRCRegClass;
3445 else if (Subtarget.
hasSPE())
3446 RC = &PPC::SPERCRegClass;
3448 RC = &PPC::F8RCRegClass;
3453 RC = &PPC::VRRCRegClass;
3456 RC = Subtarget.
hasQPX() ? &PPC::QSRCRegClass : &PPC::VRRCRegClass;
3460 RC = &PPC::VRRCRegClass;
3463 RC = &PPC::QFRCRegClass;
3466 RC = &PPC::QBRCRegClass;
3502 CCByValInfo.
AllocateStack(CCInfo.getNextStackOffset(), PtrByteSize);
3504 CCByValInfo.AnalyzeFormalArguments(Ins, CC_PPC32_SVR4_ByVal);
3507 unsigned MinReservedArea = CCByValInfo.getNextStackOffset();
3508 MinReservedArea =
std::max(MinReservedArea, LinkageSize);
3525 PPC::R7, PPC::R8, PPC::R9, PPC::R10,
3530 PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5, PPC::F6, PPC::F7,
3542 int Depth = NumGPArgRegs * PtrVT.getSizeInBits()/8 +
3547 CCInfo.getNextStackOffset(),
true));
3555 for (
unsigned GPRIndex = 0; GPRIndex != NumGPArgRegs; ++GPRIndex) {
3559 VReg = MF.
addLiveIn(GPArgRegs[GPRIndex], &PPC::GPRCRegClass);
3574 for (
unsigned FPRIndex = 0; FPRIndex != NumFPArgRegs; ++FPRIndex) {
3578 VReg = MF.
addLiveIn(FPArgRegs[FPRIndex], &PPC::F8RCRegClass);
3591 if (!MemOps.
empty())
3602 const SDLoc &dl)
const {
3613 SDValue PPCTargetLowering::LowerFormalArguments_64SVR4(
3626 "fastcc not supported on varargs functions");
3632 unsigned PtrByteSize = 8;
3636 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
3637 PPC::X7, PPC::X8, PPC::X9, PPC::X10,
3640 PPC::V2, PPC::V3, PPC::V4, PPC::V5, PPC::V6, PPC::V7, PPC::V8,
3641 PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13
3647 const unsigned Num_QFPR_Regs = Num_FPR_Regs;
3655 bool HasParameterArea = !isELFv2ABI || isVarArg;
3656 unsigned ParamAreaSize = Num_GPR_Regs * PtrByteSize;
3657 unsigned NumBytes = LinkageSize;
3658 unsigned AvailableFPRs = Num_FPR_Regs;
3659 unsigned AvailableVRs = Num_VR_Regs;
3660 for (
unsigned i = 0, e = Ins.
size(); i != e; ++i) {
3661 if (Ins[i].Flags.
isNest())
3665 PtrByteSize, LinkageSize, ParamAreaSize,
3666 NumBytes, AvailableFPRs, AvailableVRs,
3668 HasParameterArea =
true;
3675 unsigned ArgOffset = LinkageSize;
3676 unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0;
3677 unsigned &QFPR_idx = FPR_idx;
3680 unsigned CurArgIdx = 0;
3681 for (
unsigned ArgNo = 0, e = Ins.
size(); ArgNo != e; ++ArgNo) {
3683 bool needsLoad =
false;
3684 EVT ObjectVT = Ins[ArgNo].VT;
3685 EVT OrigVT = Ins[ArgNo].ArgVT;
3687 unsigned ArgSize = ObjSize;
3689 if (Ins[ArgNo].isOrigArg()) {
3690 std::advance(FuncArg, Ins[ArgNo].getOrigArgIndex() - CurArgIdx);
3691 CurArgIdx = Ins[ArgNo].getOrigArgIndex();
3696 unsigned CurArgOffset,
Align;
3697 auto ComputeArgOffset = [&]() {
3700 ArgOffset = ((ArgOffset + Align - 1) / Align) *
Align;
3701 CurArgOffset = ArgOffset;
3708 GPR_idx = (ArgOffset - LinkageSize) / PtrByteSize;
3709 GPR_idx = std::min(GPR_idx, Num_GPR_Regs);
3715 assert(Ins[ArgNo].isOrigArg() &&
"Byval arguments cannot be implicit");
3722 ArgSize = ((ObjSize + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
3744 if (HasParameterArea ||
3745 ArgSize + ArgOffset > LinkageSize + Num_GPR_Regs * PtrByteSize)
3752 if (ObjSize < PtrByteSize) {
3756 if (!isLittleEndian) {
3762 if (GPR_idx != Num_GPR_Regs) {
3763 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx++], &PPC::G8RCRegClass);
3768 if (ObjSize==1 || ObjSize==2 || ObjSize==4) {
3785 ArgOffset += PtrByteSize;
3794 for (
unsigned j = 0; j < ArgSize; j += PtrByteSize) {
3795 if (GPR_idx == Num_GPR_Regs)
3798 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::G8RCRegClass);
3811 ArgOffset += ArgSize;
3822 unsigned VReg = MF.
addLiveIn(PPC::X11, &PPC::G8RCRegClass);
3826 ArgVal = extendArgForPPC64(Flags, ObjectVT, DAG, ArgVal, dl);
3834 if (GPR_idx != Num_GPR_Regs) {
3835 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx++], &PPC::G8RCRegClass);
3842 ArgVal = extendArgForPPC64(Flags, ObjectVT, DAG, ArgVal, dl);
3848 ArgSize = PtrByteSize;
3859 if (FPR_idx != Num_FPR_Regs) {
3865 ? &PPC::VSSRCRegClass
3866 : &PPC::F4RCRegClass);
3869 ? &PPC::VSFRCRegClass
3870 : &PPC::F8RCRegClass);
3881 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx++], &PPC::G8RCRegClass);
3886 if ((ArgOffset % PtrByteSize) == (isLittleEndian ? 4 : 0))
3905 ArgOffset += ArgSize;
3907 ArgOffset = ((ArgOffset + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
3918 if (!Subtarget.
hasQPX()) {
3922 if (VR_idx != Num_VR_Regs) {
3923 unsigned VReg = MF.
addLiveIn(VR[VR_idx], &PPC::VRRCRegClass);
3937 "Invalid QPX parameter type");
3945 if (QFPR_idx != Num_QFPR_Regs) {
3948 case MVT::v4f64: RC = &PPC::QFRCRegClass;
break;
3949 case MVT::v4f32: RC = &PPC::QSRCRegClass;
break;
3950 default: RC = &PPC::QBRCRegClass;
break;
3953 unsigned VReg = MF.
addLiveIn(QFPR[QFPR_idx], RC);
3969 if (ObjSize < ArgSize && !isLittleEndian)
3970 CurArgOffset += ArgSize - ObjSize;
3980 unsigned MinReservedArea;
3981 if (HasParameterArea)
3982 MinReservedArea =
std::max(ArgOffset, LinkageSize + 8 * PtrByteSize);
3984 MinReservedArea = LinkageSize;
3997 int Depth = ArgOffset;
4006 for (GPR_idx = (ArgOffset - LinkageSize) / PtrByteSize;
4007 GPR_idx < Num_GPR_Regs; ++GPR_idx) {
4008 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::G8RCRegClass);
4019 if (!MemOps.
empty())
4025 SDValue PPCTargetLowering::LowerFormalArguments_Darwin(
4040 unsigned PtrByteSize = isPPC64 ? 8 : 4;
4042 unsigned ArgOffset = LinkageSize;
4044 unsigned MinReservedArea = ArgOffset;
4048 PPC::R7, PPC::R8, PPC::R9, PPC::R10,
4051 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
4052 PPC::X7, PPC::X8, PPC::X9, PPC::X10,
4055 PPC::V2, PPC::V3, PPC::V4, PPC::V5, PPC::V6, PPC::V7, PPC::V8,
4056 PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13
4063 unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0;
4074 unsigned VecArgOffset = ArgOffset;
4075 if (!isVarArg && !isPPC64) {
4076 for (
unsigned ArgNo = 0, e = Ins.
size(); ArgNo != e;
4078 EVT ObjectVT = Ins[ArgNo].VT;
4085 ((ObjSize + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
4086 VecArgOffset += ArgSize;
4114 VecArgOffset = ((VecArgOffset+15)/16)*16;
4115 VecArgOffset += 12*16;
4122 unsigned nAltivecParamsAtEnd = 0;
4124 unsigned CurArgIdx = 0;
4125 for (
unsigned ArgNo = 0, e = Ins.
size(); ArgNo != e; ++ArgNo) {
4127 bool needsLoad =
false;
4128 EVT ObjectVT = Ins[ArgNo].VT;
4130 unsigned ArgSize = ObjSize;
4132 if (Ins[ArgNo].isOrigArg()) {
4133 std::advance(FuncArg, Ins[ArgNo].getOrigArgIndex() - CurArgIdx);
4134 CurArgIdx = Ins[ArgNo].getOrigArgIndex();
4136 unsigned CurArgOffset = ArgOffset;
4141 if (isVarArg || isPPC64) {
4142 MinReservedArea = ((MinReservedArea+15)/16)*16;
4146 }
else nAltivecParamsAtEnd++;
4156 assert(Ins[ArgNo].isOrigArg() &&
"Byval arguments cannot be implicit");
4160 ArgSize = ((ObjSize + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
4163 if (ObjSize==1 || ObjSize==2) {
4164 CurArgOffset = CurArgOffset + (4 - ObjSize);
4170 if (ObjSize==1 || ObjSize==2) {
4171 if (GPR_idx != Num_GPR_Regs) {
4174 VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::G8RCRegClass);
4176 VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::GPRCRegClass);
4186 ArgOffset += PtrByteSize;
4190 for (
unsigned j = 0; j < ArgSize; j += PtrByteSize) {
4194 if (GPR_idx != Num_GPR_Regs) {
4197 VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::G8RCRegClass);
4199 VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::GPRCRegClass);
4207 ArgOffset += PtrByteSize;
4209 ArgOffset += ArgSize - (ArgOffset-CurArgOffset);
4221 if (GPR_idx != Num_GPR_Regs) {
4222 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::GPRCRegClass);
4231 ArgSize = PtrByteSize;
4234 ArgOffset += PtrByteSize;
4239 if (GPR_idx != Num_GPR_Regs) {
4240 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::G8RCRegClass);
4246 ArgVal = extendArgForPPC64(Flags, ObjectVT, DAG, ArgVal, dl);
4251 ArgSize = PtrByteSize;
4261 if (GPR_idx != Num_GPR_Regs) {
4263 if (ObjSize == 8 && GPR_idx != Num_GPR_Regs && !isPPC64)
4266 if (FPR_idx != Num_FPR_Regs) {
4270 VReg = MF.
addLiveIn(FPR[FPR_idx], &PPC::F4RCRegClass);
4272 VReg = MF.
addLiveIn(FPR[FPR_idx], &PPC::F8RCRegClass);
4281 ArgOffset += isPPC64 ? 8 : ObjSize;
4289 if (VR_idx != Num_VR_Regs) {
4290 unsigned VReg = MF.
addLiveIn(VR[VR_idx], &PPC::VRRCRegClass);
4293 while ((ArgOffset % 16) != 0) {
4294 ArgOffset += PtrByteSize;
4295 if (GPR_idx != Num_GPR_Regs)
4299 GPR_idx = std::min(GPR_idx+4, Num_GPR_Regs);
4303 if (!isVarArg && !isPPC64) {
4305 CurArgOffset = VecArgOffset;
4309 ArgOffset = ((ArgOffset+15)/16)*16;
4310 CurArgOffset = ArgOffset;
4322 CurArgOffset + (ArgSize - ObjSize),
4332 if (nAltivecParamsAtEnd) {
4333 MinReservedArea = ((MinReservedArea+15)/16)*16;
4334 MinReservedArea += 16*nAltivecParamsAtEnd;
4338 MinReservedArea =
std::max(MinReservedArea, LinkageSize + 8 * PtrByteSize);
4351 int Depth = ArgOffset;
4361 for (; GPR_idx != Num_GPR_Regs; ++GPR_idx) {
4365 VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::G8RCRegClass);
4367 VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::GPRCRegClass);
4379 if (!MemOps.
empty())
4388 unsigned ParamSize) {
4390 if (!isTailCall)
return 0;
4394 int SPDiff = (int)CallerMinReservedArea - (
int)ParamSize;
4396 if (SPDiff < FI->getTailCallSPDelta())
4434 if (
const auto *
F = dyn_cast<Function>(GV)) {
4467 const unsigned PtrByteSize = 8;
4471 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
4472 PPC::X7, PPC::X8, PPC::X9, PPC::X10,
4475 PPC::V2, PPC::V3, PPC::V4, PPC::V5, PPC::V6, PPC::V7, PPC::V8,
4476 PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13
4480 const unsigned NumFPRs = 13;
4482 const unsigned ParamAreaSize = NumGPRs * PtrByteSize;
4484 unsigned NumBytes = LinkageSize;
4485 unsigned AvailableFPRs = NumFPRs;
4486 unsigned AvailableVRs = NumVRs;
4489 if (Param.Flags.isNest())
continue;
4492 PtrByteSize, LinkageSize, ParamAreaSize,
4493 NumBytes, AvailableFPRs, AvailableVRs,
4509 for (; CalleeArgIter != CalleeArgEnd; ++CalleeArgIter, ++CallerArgIter) {
4510 const Value* CalleeArg = *CalleeArgIter;
4511 const Value* CallerArg = &(*CallerArgIter);
4512 if (CalleeArg == CallerArg)
4520 isa<UndefValue>(CalleeArg))
4538 if (!isTailCallableCC(CallerCC) || !isTailCallableCC(CalleeCC))
4549 PPCTargetLowering::IsEligibleForTailCallOptimization_64SVR4(
4559 if (
DisableSCO && !TailCallOpt)
return false;
4562 if (isVarArg)
return false;
4594 if (Caller.getCallingConv() != CalleeCC &&
4600 !isa<ExternalSymbolSDNode>(
Callee))
4630 PPCTargetLowering::IsEligibleForTailCallOptimization(
SDValue Callee,
4646 for (
unsigned i = 0; i != Ins.
size(); i++) {
4648 if (Flags.
isByVal())
return false;
4658 return G->getGlobal()->hasHiddenVisibility()
4659 ||
G->getGlobal()->hasProtectedVisibility();
4669 if (!C)
return nullptr;
4672 if ((Addr & 3) != 0 ||
4673 SignExtend32<26>(Addr) != Addr)
4685 struct TailCallArgumentInfo {
4690 TailCallArgumentInfo() =
default;
4700 for (
unsigned i = 0, e = TailCallArgs.
size(); i != e; ++i) {
4702 SDValue FIN = TailCallArgs[i].FrameIdxOp;
4703 int FI = TailCallArgs[i].FrameIdx;
4706 Chain, dl, Arg, FIN,
4715 int SPDiff,
const SDLoc &dl) {
4721 bool isPPC64 = Subtarget.
isPPC64();
4722 int SlotSize = isPPC64 ? 8 : 4;
4723 int NewRetAddrLoc = SPDiff + FL->getReturnSaveOffset();
4725 NewRetAddrLoc,
true);
4728 Chain = DAG.
getStore(Chain, dl, OldRetAddr, NewRetAddrFrIdx,
4734 int NewFPLoc = SPDiff + FL->getFramePointerSaveOffset();
4738 Chain = DAG.
getStore(Chain, dl, OldFP, NewFramePtrIdx,
4752 int Offset = ArgOffset + SPDiff;
4757 TailCallArgumentInfo Info;
4759 Info.FrameIdxOp = FIN;
4767 SDValue PPCTargetLowering::EmitTailCallLoadFPAndRetAddr(
4773 LROpOut = getReturnAddrFrameIndex(DAG);
4779 if (Subtarget.isDarwinABI()) {
4780 FPOpOut = getFramePointerFrameIndex(DAG);
4807 SDValue PtrOff,
int SPDiff,
unsigned ArgOffset,
bool isPPC64,
4830 const SDLoc &dl,
int SPDiff,
unsigned NumBytes,
SDValue LROp,
4840 if (!MemOpChains2.
empty())
4860 return G->getGlobal()->getValueType()->isFunctionTy();
4868 SDValue CallSeqStart,
const SDLoc &dl,
int SPDiff,
bool isTailCall,
4869 bool isPatchPoint,
bool hasNest,
4873 bool isPPC64 = Subtarget.
isPPC64();
4883 bool needIndirectCall =
true;
4884 if (!isSVR4ABI || !isPPC64)
4888 needIndirectCall =
false;
4897 if (
auto *
G = dyn_cast<GlobalAddressSDNode>(Callee))
4898 GV =
G->getGlobal();
4900 bool UsePlt = !Local && Subtarget.
isTargetELF() && !isPPC64;
4906 unsigned OpFlags = 0;
4915 needIndirectCall =
false;
4919 unsigned char OpFlags = 0;
4926 needIndirectCall =
false;
4936 needIndirectCall =
false;
4939 if (needIndirectCall) {
4944 if (isSVR4ABI && isPPC64 && !isELFv2ABI) {
5016 MTCTROps[0] = Chain;
5017 MTCTROps[1] = LoadFuncPtr;
5018 MTCTROps[2] = InFlag;
5032 if (isSVR4ABI && isPPC64 && !isELFv2ABI && !hasNest)
5050 for (
unsigned i = 0, e = RegsToPass.size(); i != e; ++i)
5052 RegsToPass[i].second.getValueType()));
5056 if (isSVR4ABI && isPPC64 && !isPatchPoint) {
5064 SDValue PPCTargetLowering::LowerCallResult(
5078 for (
unsigned i = 0, e = RVLocs.
size(); i != e; ++i) {
5111 SDValue PPCTargetLowering::FinishCall(
5118 std::vector<EVT> NodeTys;
5120 unsigned CallOpc =
PrepareCall(DAG, Callee, InFlag, Chain, CallSeqStart, dl,
5121 SPDiff, isTailCall, isPatchPoint, hasNest,
5122 RegsToPass, Ops, NodeTys, CS, Subtarget);
5125 if (isVarArg && Subtarget.isSVR4ABI() && !Subtarget.isPPC64())
5131 int BytesCalleePops =
5139 assert(Mask &&
"Missing call preserved mask for calling convention");
5151 isa<ConstantSDNode>(
Callee)) &&
5152 "Expecting an global address, external symbol, absolute value or register");
5168 if (!isTailCall && Subtarget.isSVR4ABI()&& Subtarget.isPPC64() &&
5184 unsigned TOCSaveOffset = Subtarget.getFrameLowering()->getTOCSaveOffset();
5198 Chain = DAG.
getNode(CallOpc, dl, NodeTys, Ops);
5207 return LowerCallResult(Chain, InFlag, CallConv, isVarArg,
5208 Ins, dl, DAG, InVals);
5230 else if (Subtarget.isSVR4ABI() && Subtarget.isPPC64())
5232 IsEligibleForTailCallOptimization_64SVR4(Callee, CallConv, CS,
5233 isVarArg, Outs, Ins, DAG);
5235 isTailCall = IsEligibleForTailCallOptimization(Callee, CallConv, isVarArg,
5242 assert(isa<GlobalAddressSDNode>(Callee) &&
5243 "Callee should be an llvm::Function object.");
5246 cast<GlobalAddressSDNode>(Callee)->getGlobal();
5247 const unsigned Width =
5248 80 - strlen(
"TCO caller: ") - strlen(
", callee linkage: 0, 0");
5249 dbgs() <<
"TCO caller: " 5251 <<
", callee linkage: " << GV->getVisibility() <<
", " 5252 << GV->getLinkage() <<
"\n");
5258 "site marked musttail");
5263 if (Subtarget.useLongCalls() && isa<GlobalAddressSDNode>(
Callee) &&
5265 Callee = LowerGlobalAddress(Callee, DAG);
5267 if (Subtarget.isSVR4ABI()) {
5268 if (Subtarget.isPPC64())
5269 return LowerCall_64SVR4(Chain, Callee, CallConv, isVarArg,
5270 isTailCall, isPatchPoint, Outs, OutVals, Ins,
5271 dl, DAG, InVals, CS);
5273 return LowerCall_32SVR4(Chain, Callee, CallConv, isVarArg,
5274 isTailCall, isPatchPoint, Outs, OutVals, Ins,
5275 dl, DAG, InVals, CS);
5278 return LowerCall_Darwin(Chain, Callee, CallConv, isVarArg,
5279 isTailCall, isPatchPoint, Outs, OutVals, Ins,
5280 dl, DAG, InVals, CS);
5283 SDValue PPCTargetLowering::LowerCall_32SVR4(
5285 bool isTailCall,
bool isPatchPoint,
5298 unsigned PtrByteSize = 4;
5320 CCInfo.
AllocateStack(Subtarget.getFrameLowering()->getLinkageSize(),
5323 CCInfo.PreAnalyzeCallOperands(Outs);
5329 unsigned NumArgs = Outs.
size();
5331 for (
unsigned i = 0; i != NumArgs; ++i) {
5332 MVT ArgVT = Outs[i].VT;
5336 if (Outs[i].IsFixed) {
5346 errs() <<
"Call operand #" << i <<
" has unhandled type " 5354 CCInfo.AnalyzeCallOperands(Outs, CC_PPC32_SVR4);
5356 CCInfo.clearWasPPCF128();
5363 CCByValInfo.
AllocateStack(CCInfo.getNextStackOffset(), PtrByteSize);
5365 CCByValInfo.AnalyzeCallOperands(Outs, CC_PPC32_SVR4_ByVal);
5370 unsigned NumBytes = CCByValInfo.getNextStackOffset();
5384 Chain = EmitTailCallLoadFPAndRetAddr(DAG, SPDiff, Chain, LROp, FPOp, dl);
5395 bool seenFloatArg =
false;
5397 for (
unsigned i = 0, j = 0, e = ArgLocs.
size();
5409 assert((j < ByValArgLocs.
size()) &&
"Index out of bounds!");
5428 SDValue NewCallSeqStart = DAG.getCALLSEQ_START(MemcpyCall, NumBytes, 0,
5430 DAG.ReplaceAllUsesWith(CallSeqStart.
getNode(),
5431 NewCallSeqStart.getNode());
5432 Chain = CallSeqStart = NewCallSeqStart;
5467 if (!MemOpChains.
empty())
5473 for (
unsigned i = 0, e = RegsToPass.
size(); i != e; ++i) {
5475 RegsToPass[i].
second, InFlag);
5483 SDValue Ops[] = { Chain, InFlag };
5495 return FinishCall(CallConv, dl, isTailCall, isVarArg, isPatchPoint,
5497 RegsToPass, InFlag, Chain, CallSeqStart, Callee, SPDiff,
5498 NumBytes, Ins, InVals, CS);
5503 SDValue PPCTargetLowering::createMemcpyOutsideCallSeq(
5511 SDValue NewCallSeqStart = DAG.getCALLSEQ_START(MemcpyCall, FrameSize, 0,
5513 DAG.ReplaceAllUsesWith(CallSeqStart.
getNode(),
5515 return NewCallSeqStart;
5518 SDValue PPCTargetLowering::LowerCall_64SVR4(
5520 bool isTailCall,
bool isPatchPoint,
5526 bool isELFv2ABI = Subtarget.isELFv2ABI();
5527 bool isLittleEndian = Subtarget.isLittleEndian();
5528 unsigned NumOps = Outs.
size();
5529 bool hasNest =
false;
5530 bool IsSibCall =
false;
5533 unsigned PtrByteSize = 8;
5550 "fastcc not supported on varargs functions");
5556 unsigned LinkageSize = Subtarget.getFrameLowering()->getLinkageSize();
5557 unsigned NumBytes = LinkageSize;
5558 unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0;
5559 unsigned &QFPR_idx = FPR_idx;
5562 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
5563 PPC::X7, PPC::X8, PPC::X9, PPC::X10,
5566 PPC::V2, PPC::V3, PPC::V4, PPC::V5, PPC::V6, PPC::V7, PPC::V8,
5567 PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13
5573 const unsigned NumQFPRs = NumFPRs;
5579 bool HasParameterArea = !isELFv2ABI || isVarArg || CallConv ==
CallingConv::Fast;
5580 if (!HasParameterArea) {
5581 unsigned ParamAreaSize = NumGPRs * PtrByteSize;
5582 unsigned AvailableFPRs = NumFPRs;
5583 unsigned AvailableVRs = NumVRs;
5584 unsigned NumBytesTmp = NumBytes;
5585 for (
unsigned i = 0; i != NumOps; ++i) {
5586 if (Outs[i].Flags.
isNest())
continue;
5588 PtrByteSize, LinkageSize, ParamAreaSize,
5589 NumBytesTmp, AvailableFPRs, AvailableVRs,
5590 Subtarget.hasQPX()))
5591 HasParameterArea =
true;
5597 unsigned NumGPRsUsed = 0, NumFPRsUsed = 0, NumVRsUsed = 0;
5602 HasParameterArea =
false;
5605 for (
unsigned i = 0; i != NumOps; ++i) {
5607 EVT ArgVT = Outs[i].VT;
5608 EVT OrigVT = Outs[i].ArgVT;
5616 if (NumGPRsUsed > NumGPRs)
5617 HasParameterArea =
true;
5624 if (++NumGPRsUsed <= NumGPRs)
5634 if (++NumVRsUsed <= NumVRs)
5640 if (Subtarget.hasQPX()) {
5641 if (++NumFPRsUsed <= NumFPRs)
5644 if (++NumVRsUsed <= NumVRs)
5652 if (++NumFPRsUsed <= NumFPRs)
5656 HasParameterArea =
true;
5663 NumBytes = ((NumBytes + Align - 1) / Align) *
Align;
5667 NumBytes = ((NumBytes + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
5670 unsigned NumBytesActuallyUsed = NumBytes;
5680 if (HasParameterArea)
5681 NumBytes =
std::max(NumBytes, LinkageSize + 8 * PtrByteSize);
5683 NumBytes = LinkageSize;
5711 Chain = EmitTailCallLoadFPAndRetAddr(DAG, SPDiff, Chain, LROp, FPOp, dl);
5722 unsigned ArgOffset = LinkageSize;
5728 for (
unsigned i = 0; i != NumOps; ++i) {
5731 EVT ArgVT = Outs[i].VT;
5732 EVT OrigVT = Outs[i].ArgVT;
5741 auto ComputePtrOff = [&]() {
5745 ArgOffset = ((ArgOffset + Align - 1) / Align) *
Align;
5756 GPR_idx = (ArgOffset - LinkageSize) / PtrByteSize;
5757 GPR_idx = std::min(GPR_idx, NumGPRs);
5787 if (Size==1 || Size==2 || Size==4) {
5789 if (GPR_idx != NumGPRs) {
5793 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
5795 ArgOffset += PtrByteSize;
5800 if (GPR_idx == NumGPRs && Size < 8) {
5802 if (!isLittleEndian) {
5807 Chain = CallSeqStart = createMemcpyOutsideCallSeq(Arg, AddPtr,
5810 ArgOffset += PtrByteSize;
5827 Chain = CallSeqStart = createMemcpyOutsideCallSeq(Arg, PtrOff,
5832 if (Size < 8 && GPR_idx != NumGPRs) {
5842 if (!isLittleEndian) {
5846 Chain = CallSeqStart = createMemcpyOutsideCallSeq(Arg, AddPtr,
5854 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
5857 ArgOffset += PtrByteSize;
5863 for (
unsigned j=0; j<
Size; j+=PtrByteSize) {
5866 if (GPR_idx != NumGPRs) {
5870 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
5871 ArgOffset += PtrByteSize;
5873 ArgOffset += ((Size - j + PtrByteSize-1)/PtrByteSize)*PtrByteSize;
5887 RegsToPass.
push_back(std::make_pair(PPC::X11, Arg));
5895 if (GPR_idx != NumGPRs) {
5896 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Arg));
5901 assert(HasParameterArea &&
5902 "Parameter area must exist to pass an argument in memory.");
5904 true, isTailCall,
false, MemOpChains,
5905 TailCallArguments, dl);
5907 ArgOffset += PtrByteSize;
5910 ArgOffset += PtrByteSize;
5923 bool NeedGPROrStack = isVarArg || FPR_idx == NumFPRs;
5924 bool NeededLoad =
false;
5927 if (FPR_idx != NumFPRs)
5928 RegsToPass.
push_back(std::make_pair(FPR[FPR_idx++], Arg));
5931 if (!NeedGPROrStack)
5953 }
else if (ArgOffset % PtrByteSize != 0) {
5957 if (!isLittleEndian)
5965 if (!isLittleEndian)
5975 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], ArgVal));
5988 assert(HasParameterArea &&
5989 "Parameter area must exist to pass an argument in memory.");
5991 true, isTailCall,
false, MemOpChains,
5992 TailCallArguments, dl);
6003 ArgOffset = ((ArgOffset + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
6015 if (!Subtarget.hasQPX()) {
6025 assert(HasParameterArea &&
6026 "Parameter area must exist if we have a varargs call.");
6032 if (VR_idx != NumVRs) {
6036 RegsToPass.
push_back(std::make_pair(VR[VR_idx++], Load));
6039 for (
unsigned i=0; i<16; i+=PtrByteSize) {
6040 if (GPR_idx == NumGPRs)
6047 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6053 if (VR_idx != NumVRs) {
6054 RegsToPass.
push_back(std::make_pair(VR[VR_idx++], Arg));
6059 assert(HasParameterArea &&
6060 "Parameter area must exist to pass an argument in memory.");
6062 true, isTailCall,
true, MemOpChains,
6063 TailCallArguments, dl);
6074 "Invalid QPX parameter type");
6081 assert(HasParameterArea &&
6082 "Parameter area must exist if we have a varargs call.");
6088 if (QFPR_idx != NumQFPRs) {
6092 RegsToPass.
push_back(std::make_pair(QFPR[QFPR_idx++], Load));
6094 ArgOffset += (IsF32 ? 16 : 32);
6095 for (
unsigned i = 0; i < (IsF32 ? 16U : 32U); i += PtrByteSize) {
6096 if (GPR_idx == NumGPRs)
6103 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6109 if (QFPR_idx != NumQFPRs) {
6110 RegsToPass.
push_back(std::make_pair(QFPR[QFPR_idx++], Arg));
6115 assert(HasParameterArea &&
6116 "Parameter area must exist to pass an argument in memory.");
6118 true, isTailCall,
true, MemOpChains,
6119 TailCallArguments, dl);
6121 ArgOffset += (IsF32 ? 16 : 32);
6125 ArgOffset += (IsF32 ? 16 : 32);
6131 assert((!HasParameterArea || NumBytesActuallyUsed == ArgOffset) &&
6132 "mismatch in size of parameter area");
6133 (void)NumBytesActuallyUsed;
6135 if (!MemOpChains.
empty())
6141 if (!isTailCall && !isPatchPoint &&
6143 !isa<ExternalSymbolSDNode>(Callee)) {
6148 unsigned TOCSaveOffset = Subtarget.getFrameLowering()->getTOCSaveOffset();
6157 if (isELFv2ABI && !isPatchPoint)
6158 RegsToPass.
push_back(std::make_pair((
unsigned)PPC::X12, Callee));
6164 for (
unsigned i = 0, e = RegsToPass.
size(); i != e; ++i) {
6166 RegsToPass[i].
second, InFlag);
6170 if (isTailCall && !IsSibCall)
6174 return FinishCall(CallConv, dl, isTailCall, isVarArg, isPatchPoint, hasNest,
6175 DAG, RegsToPass, InFlag, Chain, CallSeqStart, Callee,
6176 SPDiff, NumBytes, Ins, InVals, CS);
6179 SDValue PPCTargetLowering::LowerCall_Darwin(
6181 bool isTailCall,
bool isPatchPoint,
6187 unsigned NumOps = Outs.
size();
6191 unsigned PtrByteSize = isPPC64 ? 8 : 4;
6207 unsigned LinkageSize = Subtarget.getFrameLowering()->getLinkageSize();
6208 unsigned NumBytes = LinkageSize;
6216 unsigned nAltivecParamsAtEnd = 0;
6217 for (
unsigned i = 0; i != NumOps; ++i) {
6219 EVT ArgVT = Outs[i].VT;
6224 if (!isVarArg && !isPPC64) {
6227 nAltivecParamsAtEnd++;
6231 NumBytes = ((NumBytes+15)/16)*16;
6237 if (nAltivecParamsAtEnd) {
6238 NumBytes = ((NumBytes+15)/16)*16;
6239 NumBytes += 16*nAltivecParamsAtEnd;
6247 NumBytes =
std::max(NumBytes, LinkageSize + 8 * PtrByteSize);
6271 Chain = EmitTailCallLoadFPAndRetAddr(DAG, SPDiff, Chain, LROp, FPOp, dl);
6286 unsigned ArgOffset = LinkageSize;
6287 unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0;
6291 PPC::R7, PPC::R8, PPC::R9, PPC::R10,
6294 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
6295 PPC::X7, PPC::X8, PPC::X9, PPC::X10,
6298 PPC::V2, PPC::V3, PPC::V4, PPC::V5, PPC::V6, PPC::V7, PPC::V8,
6299 PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13
6302 const unsigned NumFPRs = 13;
6311 for (
unsigned i = 0; i != NumOps; ++i) {
6337 if (Size==1 || Size==2) {
6339 if (GPR_idx != NumGPRs) {
6343 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6345 ArgOffset += PtrByteSize;
6350 Chain = CallSeqStart = createMemcpyOutsideCallSeq(Arg, AddPtr,
6353 ArgOffset += PtrByteSize;
6360 Chain = CallSeqStart = createMemcpyOutsideCallSeq(Arg, PtrOff,
6367 for (
unsigned j=0; j<
Size; j+=PtrByteSize) {
6370 if (GPR_idx != NumGPRs) {
6374 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6375 ArgOffset += PtrByteSize;
6377 ArgOffset += ((Size - j + PtrByteSize-1)/PtrByteSize)*PtrByteSize;
6389 if (GPR_idx != NumGPRs) {
6393 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Arg));
6396 isPPC64, isTailCall,
false, MemOpChains,
6397 TailCallArguments, dl);
6399 ArgOffset += PtrByteSize;
6403 if (FPR_idx != NumFPRs) {
6404 RegsToPass.
push_back(std::make_pair(FPR[FPR_idx++], Arg));
6412 if (GPR_idx != NumGPRs) {
6416 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6424 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6430 if (GPR_idx != NumGPRs)
6438 isPPC64, isTailCall,
false, MemOpChains,
6439 TailCallArguments, dl);
6455 while (ArgOffset % 16 !=0) {
6456 ArgOffset += PtrByteSize;
6457 if (GPR_idx != NumGPRs)
6467 if (VR_idx != NumVRs) {
6471 RegsToPass.
push_back(std::make_pair(VR[VR_idx++], Load));
6474 for (
unsigned i=0; i<16; i+=PtrByteSize) {
6475 if (GPR_idx == NumGPRs)
6482 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6489 if (VR_idx != NumVRs) {
6491 RegsToPass.
push_back(std::make_pair(VR[VR_idx++], Arg));
6492 }
else if (nAltivecParamsAtEnd==0) {
6495 isPPC64, isTailCall,
true, MemOpChains,
6496 TailCallArguments, dl);
6507 if (!isVarArg && nAltivecParamsAtEnd > NumVRs) {
6510 ArgOffset = ((ArgOffset+15)/16)*16;
6512 for (
unsigned i = 0; i != NumOps; ++i) {
6514 EVT ArgType = Outs[i].VT;
6521 isPPC64, isTailCall,
true, MemOpChains,
6522 TailCallArguments, dl);
6529 if (!MemOpChains.
empty())
6537 !isa<ExternalSymbolSDNode>(Callee) &&
6539 RegsToPass.
push_back(std::make_pair((
unsigned)(isPPC64 ? PPC::X12 :
6540 PPC::R12), Callee));
6545 for (
unsigned i = 0, e = RegsToPass.
size(); i != e; ++i) {
6547 RegsToPass[i].
second, InFlag);
6555 return FinishCall(CallConv, dl, isTailCall, isVarArg, isPatchPoint,
6557 RegsToPass, InFlag, Chain, CallSeqStart, Callee, SPDiff,
6558 NumBytes, Ins, InVals, CS);
6567 CCState CCInfo(CallConv, isVarArg, MF, RVLocs, Context);
6592 for (
unsigned i = 0; i != RVLocs.
size(); ++i) {
6623 if (PPC::G8RCRegClass.
contains(*I))
6625 else if (PPC::F8RCRegClass.
contains(*I))
6627 else if (PPC::CRRCRegClass.
contains(*I))
6629 else if (PPC::VRRCRegClass.
contains(*I))
6646 PPCTargetLowering::LowerGET_DYNAMIC_AREA_OFFSET(
SDValue Op,
6655 SDValue FPSIdx = getFramePointerFrameIndex(DAG);
6657 SDValue Ops[2] = {Chain, FPSIdx};
6671 bool isPPC64 = Subtarget.isPPC64();
6672 unsigned SP = isPPC64 ? PPC::X1 : PPC::R1;
6692 bool isPPC64 = Subtarget.isPPC64();
6703 int LROffset = Subtarget.getFrameLowering()->getReturnSaveOffset();
6707 FI->setReturnAddrSaveIndex(RASI);
6713 PPCTargetLowering::getFramePointerFrameIndex(
SelectionDAG & DAG)
const {
6715 bool isPPC64 = Subtarget.isPPC64();
6726 int FPOffset = Subtarget.getFrameLowering()->getFramePointerSaveOffset();
6730 FI->setFramePointerSaveIndex(FPSI);
6748 SDValue FPSIdx = getFramePointerFrameIndex(DAG);
6750 SDValue Ops[3] = { Chain, NegSize, FPSIdx };
6759 bool isPPC64 = Subtarget.isPPC64();
6783 return LowerVectorLoad(Op, DAG);
6786 "Custom lowering only for i1 loads");
6808 return LowerVectorStore(Op, DAG);
6811 "Custom lowering only for i1 stores");
6831 "Custom lowering only for i1 results");
6946 void PPCTargetLowering::LowerFP_TO_INTForReuse(
SDValue Op, ReuseLoadInfo &RLI,
6948 const SDLoc &dl)
const {
6951 if (Src.getValueType() ==
MVT::f32)
6966 "i64 FP_TO_UINT is supported only with FPCVT");
6977 int FI = cast<FrameIndexSDNode>(FIPtr)->getIndex();
6998 MPI = MPI.
getWithOffset(Subtarget.isLittleEndian() ? 0 : 4);
7011 const SDLoc &dl)
const {
7015 if (Src.getValueType() ==
MVT::f32)
7031 "i64 FP_TO_UINT is supported only with FPCVT");
7042 const SDLoc &dl)
const {
7067 const uint64_t TwoE31[] = {0x41e0000000000000LL, 0};
7088 if (Subtarget.hasDirectMove() && Subtarget.isPPC64())
7089 return LowerFP_TO_INTDirectMove(Op, DAG, dl);
7092 LowerFP_TO_INTForReuse(Op, RLI, DAG, dl);
7095 RLI.Alignment, RLI.MMOFlags(), RLI.AAInfo, RLI.Ranges);
7106 bool PPCTargetLowering::canReuseLoadAddress(
SDValue Op,
EVT MemVT,
7117 LowerFP_TO_INTForReuse(Op, RLI, DAG, dl);
7131 "Non-pre-inc AM on PPC?");
7152 void PPCTargetLowering::spliceIntoChain(
SDValue ResChain,
7158 SDLoc dl(NewResChain);
7163 "A new TF really is required here");
7172 bool PPCTargetLowering::directMoveIsProfitable(
const SDValue &Op)
const {
7180 if (!Subtarget.hasP9Vector() && MMO->
getSize() <= 2)
7188 if (UI.getUse().get().getResNo() != 0)
7204 const SDLoc &dl)
const {
7207 "Invalid floating point type as target of conversion");
7208 assert(Subtarget.hasFPCVT() &&
7209 "Int to FP conversions with direct moves require FPCVT");
7271 if (Subtarget.hasDirectMove() && directMoveIsProfitable(Op) &&
7272 Subtarget.isPPC64() && Subtarget.hasFPCVT())
7273 return LowerINT_TO_FPDirectMove(Op, DAG, dl);
7276 "UINT_TO_FP is supported only with FPCVT");
7302 !Subtarget.hasFPCVT() &&
7341 if (canReuseLoadAddress(SINT,
MVT::i64, RLI, DAG)) {
7343 RLI.Alignment, RLI.MMOFlags(), RLI.AAInfo, RLI.Ranges);
7344 spliceIntoChain(RLI.ResChain, Bits.
getValue(1), DAG);
7345 }
else if (Subtarget.hasLFIWAX() &&
7349 RLI.Alignment, RLI.AAInfo, RLI.Ranges);
7350 SDValue Ops[] = { RLI.Chain, RLI.Ptr };
7354 spliceIntoChain(RLI.ResChain, Bits.
getValue(1), DAG);
7355 }
else if (Subtarget.hasFPCVT() &&
7359 RLI.Alignment, RLI.AAInfo, RLI.Ranges);
7360 SDValue Ops[] = { RLI.Chain, RLI.Ptr };
7364 spliceIntoChain(RLI.ResChain, Bits.
getValue(1), DAG);
7365 }
else if (((Subtarget.hasLFIWAX() &&
7367 (Subtarget.hasFPCVT() &&
7382 "Expected an i32 store");
7392 RLI.Alignment, RLI.AAInfo, RLI.Ranges);
7393 SDValue Ops[] = { RLI.Chain, RLI.Ptr };
7410 "Unhandled INT_TO_FP type in custom expander!");
7420 if (Subtarget.hasLFIWAX() || Subtarget.hasFPCVT()) {
7434 "Expected an i32 store");
7445 RLI.Alignment, RLI.AAInfo, RLI.Ranges);
7446 SDValue Ops[] = { RLI.Chain, RLI.Ptr };
7452 spliceIntoChain(RLI.ResChain, Ld.getValue(1), DAG);
7454 assert(Subtarget.isPPC64() &&
7455 "i32->FP without LFIWAX supported only on PPC64");
7570 SDValue OutOps[] = { OutLo, OutHi };
7599 SDValue OutOps[] = { OutLo, OutHi };
7628 SDValue OutOps[] = { OutLo, OutHi };
7640 assert(Val >= -16 && Val <= 15 &&
"vsplti is out of range!");
7642 static const MVT VTys[] = {
7652 EVT CanonicalVT = VTys[SplatSize-1];
7696 for (
unsigned i = 0; i != 16; ++i)
7724 bool IsSplat =
true;
7725 bool IsLoad =
false;
7752 return !(IsSplat && IsLoad);
7781 assert(BVN &&
"Expected a BuildVectorSDNode in LowerBUILD_VECTOR");
7795 "BUILD_VECTOR for v4i1 does not have 4 operands");
7798 for (
unsigned i = 0; i < 4; ++i) {
7800 if (!isa<ConstantSDNode>(BVN->
getOperand(i))) {
7813 for (
unsigned i = 0; i < 4; ++i) {
7834 for (
unsigned i = 0; i < 4; ++i) {
7842 if (StoreSize > 4) {
7857 if (!Stores.
empty())
7884 if (Subtarget.hasQPX())
7888 APInt APSplatBits, APSplatUndef;
7889 unsigned SplatBitSize;
7892 HasAnyUndefs, 0, !Subtarget.isLittleEndian()) ||
7893 SplatBitSize > 32) {
7897 if (Subtarget.hasVSX() &&
7899 Subtarget.hasP8Vector()))
7906 unsigned SplatSize = SplatBitSize / 8;
7911 if (SplatBits == 0) {
7921 if (Subtarget.hasP9Vector() && SplatSize == 1) {
7946 int32_t SextVal= (int32_t(SplatBits << (32-SplatBitSize)) >>
7948 if (SextVal >= -16 && SextVal <= 15)
7960 if (SextVal >= -32 && SextVal <= 31) {
7978 if (SplatSize == 4 && SplatBits == (0x7FFFFFFF&~SplatUndef)) {
7992 static const signed char SplatCsts[] = {
7993 -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7,
7994 -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, 14, -14, 15, -15, -16
8000 int i = SplatCsts[idx];
8004 unsigned TypeShiftAmt = i & (SplatBitSize-1);
8007 if (SextVal == (
int)((
unsigned)i << TypeShiftAmt)) {
8009 static const unsigned IIDs[] = {
8010 Intrinsic::ppc_altivec_vslb, Intrinsic::ppc_altivec_vslh, 0,
8011 Intrinsic::ppc_altivec_vslw
8018 if (SextVal == (
int)((
unsigned)i >> TypeShiftAmt)) {
8020 static const unsigned IIDs[] = {
8021 Intrinsic::ppc_altivec_vsrb, Intrinsic::ppc_altivec_vsrh, 0,
8022 Intrinsic::ppc_altivec_vsrw
8029 if (SextVal == (
int)((
unsigned)i >> TypeShiftAmt)) {
8031 static const unsigned IIDs[] = {
8032 Intrinsic::ppc_altivec_vsrab, Intrinsic::ppc_altivec_vsrah, 0,
8033 Intrinsic::ppc_altivec_vsraw
8040 if (SextVal == (
int)(((
unsigned)i << TypeShiftAmt) |
8041 ((
unsigned)i >> (SplatBitSize-TypeShiftAmt)))) {
8043 static const unsigned IIDs[] = {
8044 Intrinsic::ppc_altivec_vrlb, Intrinsic::ppc_altivec_vrlh, 0,
8045 Intrinsic::ppc_altivec_vrlw
8052 if (SextVal == (
int)(((
unsigned)i << 8) | (i < 0 ? 0xFF : 0))) {
8054 unsigned Amt = Subtarget.isLittleEndian() ? 15 : 1;
8058 if (SextVal == (
int)(((
unsigned)i << 16) | (i < 0 ? 0xFFFF : 0))) {
8060 unsigned Amt = Subtarget.isLittleEndian() ? 14 : 2;
8064 if (SextVal == (
int)(((
unsigned)i << 24) | (i < 0 ? 0xFFFFFF : 0))) {
8066 unsigned Amt = Subtarget.isLittleEndian() ? 13 : 3;
8079 unsigned OpNum = (PFEntry >> 26) & 0x0F;
8080 unsigned LHSID = (PFEntry >> 13) & ((1 << 13)-1);
8081 unsigned RHSID = (PFEntry >> 0) & ((1 << 13)-1);
8096 if (OpNum == OP_COPY) {
8097 if (LHSID == (1*9+2)*9+3)
return LHS;
8098 assert(LHSID == ((4*9+5)*9+6)*9+7 &&
"Illegal OP_COPY!");
8110 ShufIdxs[ 0] = 0; ShufIdxs[ 1] = 1; ShufIdxs[ 2] = 2; ShufIdxs[ 3] = 3;
8111 ShufIdxs[ 4] = 16; ShufIdxs[ 5] = 17; ShufIdxs[ 6] = 18; ShufIdxs[ 7] = 19;
8112 ShufIdxs[ 8] = 4; ShufIdxs[ 9] = 5; ShufIdxs[10] = 6; ShufIdxs[11] = 7;
8113 ShufIdxs[12] = 20; ShufIdxs[13] = 21; ShufIdxs[14] = 22; ShufIdxs[15] = 23;
8116 ShufIdxs[ 0] = 8; ShufIdxs[ 1] = 9; ShufIdxs[ 2] = 10; ShufIdxs[ 3] = 11;
8117 ShufIdxs[ 4] = 24; ShufIdxs[ 5] = 25; ShufIdxs[ 6] = 26; ShufIdxs[ 7] = 27;
8118 ShufIdxs[ 8] = 12; ShufIdxs[ 9] = 13; ShufIdxs[10] = 14; ShufIdxs[11] = 15;
8119 ShufIdxs[12] = 28; ShufIdxs[13] = 29; ShufIdxs[14] = 30; ShufIdxs[15] = 31;
8122 for (
unsigned i = 0; i != 16; ++i)
8123 ShufIdxs[i] = (i&3)+0;
8126 for (
unsigned i = 0; i != 16; ++i)
8127 ShufIdxs[i] = (i&3)+4;
8130 for (
unsigned i = 0; i != 16; ++i)
8131 ShufIdxs[i] = (i&3)+8;
8134 for (
unsigned i = 0; i != 16; ++i)
8135 ShufIdxs[i] = (i&3)+12;
8156 const unsigned BytesInVector = 16;
8157 bool IsLE = Subtarget.isLittleEndian();
8161 unsigned ShiftElts = 0, InsertAtByte = 0;
8165 unsigned LittleEndianShifts[] = {8, 7, 6, 5, 4, 3, 2, 1,
8166 0, 15, 14, 13, 12, 11, 10, 9};
8167 unsigned BigEndianShifts[] = {9, 10, 11, 12, 13, 14, 15, 0,
8168 1, 2, 3, 4, 5, 6, 7, 8};
8171 int OriginalOrder[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
8183 bool FoundCandidate =
false;
8187 unsigned VINSERTBSrcElem = IsLE ? 8 : 7;
8190 for (
unsigned i = 0; i < BytesInVector; ++i) {
8191 unsigned CurrentElement = Mask[i];
8194 if (V2.
isUndef() && CurrentElement != VINSERTBSrcElem)
8197 bool OtherElementsInOrder =
true;
8200 for (
unsigned j = 0; j < BytesInVector; ++j) {
8207 (!V2.
isUndef() && CurrentElement < BytesInVector) ? BytesInVector : 0;
8208 if (Mask[j] != OriginalOrder[j] + MaskOffset) {
8209 OtherElementsInOrder =
false;
8216 if (OtherElementsInOrder) {
8223 ShiftElts = IsLE ? LittleEndianShifts[CurrentElement & 0xF]
8224 : BigEndianShifts[CurrentElement & 0xF];
8225 Swap = CurrentElement < BytesInVector;
8227 InsertAtByte = IsLE ? BytesInVector - (i + 1) : i;
8228 FoundCandidate =
true;
8233 if (!FoundCandidate)
8257 const unsigned NumHalfWords = 8;
8258 const unsigned BytesInVector = NumHalfWords * 2;
8263 bool IsLE = Subtarget.isLittleEndian();
8267 unsigned ShiftElts = 0, InsertAtByte = 0;
8271 unsigned LittleEndianShifts[] = {4, 3, 2, 1, 0, 7, 6, 5};
8272 unsigned BigEndianShifts[] = {5, 6, 7, 0, 1, 2, 3, 4};
8275 uint32_t OriginalOrderLow = 0x1234567;
8276 uint32_t OriginalOrderHigh = 0x89ABCDEF;
8279 for (
unsigned i = 0; i < NumHalfWords; ++i) {
8280 unsigned MaskShift = (NumHalfWords - 1 - i) * 4;
8297 bool FoundCandidate =
false;
8300 for (
unsigned i = 0; i < NumHalfWords; ++i) {
8301 unsigned MaskShift = (NumHalfWords - 1 - i) * 4;
8302 uint32_t MaskOneElt = (Mask >> MaskShift) & 0xF;
8303 uint32_t MaskOtherElts = ~(0xF << MaskShift);
8311 unsigned VINSERTHSrcElem = IsLE ? 4 : 3;
8312 TargetOrder = OriginalOrderLow;
8316 if (MaskOneElt == VINSERTHSrcElem &&
8317 (Mask & MaskOtherElts) == (TargetOrder & MaskOtherElts)) {
8318 InsertAtByte = IsLE ? BytesInVector - (i + 1) * 2 : i * 2;
8319 FoundCandidate =
true;
8325 (MaskOneElt < NumHalfWords) ? OriginalOrderHigh : OriginalOrderLow;
8327 if ((Mask & MaskOtherElts) == (TargetOrder & MaskOtherElts)) {
8329 ShiftElts = IsLE ? LittleEndianShifts[MaskOneElt & 0x7]
8330 : BigEndianShifts[MaskOneElt & 0x7];
8331 InsertAtByte = IsLE ? BytesInVector - (i + 1) * 2 : i * 2;
8332 Swap = MaskOneElt < NumHalfWords;
8333 FoundCandidate =
true;
8339 if (!FoundCandidate)
8375 bool isLittleEndian = Subtarget.isLittleEndian();
8377 unsigned ShiftElts, InsertAtByte;
8379 if (Subtarget.hasP9Vector() &&
8398 if (Subtarget.hasP9Altivec()) {
8400 if ((NewISDNode = lowerToVINSERTH(SVOp, DAG)))
8403 if ((NewISDNode = lowerToVINSERTB(SVOp, DAG)))
8407 if (Subtarget.hasVSX() &&
8420 if (Subtarget.hasVSX() &&
8433 if (Subtarget.hasP9Vector()) {
8453 if (Subtarget.hasVSX()) {
8459 if (Subtarget.hasP9Vector() &&
8460 ((isLittleEndian && SplatIdx == 3) ||
8461 (!isLittleEndian && SplatIdx == 0))) {
8482 if (Subtarget.hasQPX()) {
8483 if (VT.getVectorNumElements() != 4)
8489 if (AlignIdx != -1) {
8494 if (SplatIdx >= 4) {
8507 for (
unsigned i = 0; i < 4; ++i) {
8509 unsigned mm = m >= 0 ? (
unsigned) m : i;
8510 idx |= mm << (3-i)*3;
8534 (Subtarget.hasP8Altivec() && (
8545 unsigned int ShuffleKind = isLittleEndian ? 2 : 0;
8555 (Subtarget.hasP8Altivec() && (
8565 unsigned PFIndexes[4];
8566 bool isFourElementShuffle =
true;
8567 for (
unsigned i = 0; i != 4 && isFourElementShuffle; ++i) {
8569 for (
unsigned j = 0; j != 4; ++j) {
8570 if (PermMask[i*4+j] < 0)
8573 unsigned ByteSource = PermMask[i*4+j];
8574 if ((ByteSource & 3) != j) {
8575 isFourElementShuffle =
false;
8580 EltNo = ByteSource/4;
8581 }
else if (EltNo != ByteSource/4) {
8582 isFourElementShuffle =
false;
8586 PFIndexes[i] = EltNo;
8594 if (isFourElementShuffle && !isLittleEndian) {
8596 unsigned PFTableIndex =
8597 PFIndexes[0]*9*9*9+PFIndexes[1]*9*9+PFIndexes[2]*9+PFIndexes[3];
8600 unsigned Cost = (PFEntry >> 30);
8632 for (
unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) {
8633 unsigned SrcElt = PermMask[i] < 0 ? 0 : PermMask[i];
8635 for (
unsigned j = 0; j != BytesPerElement; ++j)
8658 unsigned IntrinsicID =
8659 cast<ConstantSDNode>(Intrin.
getOperand(0))->getZExtValue();
8662 switch (IntrinsicID) {
8666 case Intrinsic::ppc_altivec_vcmpbfp_p:
8670 case Intrinsic::ppc_altivec_vcmpeqfp_p:
8674 case Intrinsic::ppc_altivec_vcmpequb_p:
8678 case Intrinsic::ppc_altivec_vcmpequh_p:
8682 case Intrinsic::ppc_altivec_vcmpequw_p:
8686 case Intrinsic::ppc_altivec_vcmpequd_p:
8693 case Intrinsic::ppc_altivec_vcmpneb_p:
8694 case Intrinsic::ppc_altivec_vcmpneh_p:
8695 case Intrinsic::ppc_altivec_vcmpnew_p:
8696 case Intrinsic::ppc_altivec_vcmpnezb_p:
8697 case Intrinsic::ppc_altivec_vcmpnezh_p:
8698 case Intrinsic::ppc_altivec_vcmpnezw_p:
8700 switch (IntrinsicID) {
8703 case Intrinsic::ppc_altivec_vcmpneb_p:
8706 case Intrinsic::ppc_altivec_vcmpneh_p:
8709 case Intrinsic::ppc_altivec_vcmpnew_p:
8712 case Intrinsic::ppc_altivec_vcmpnezb_p:
8715 case Intrinsic::ppc_altivec_vcmpnezh_p:
8718 case Intrinsic::ppc_altivec_vcmpnezw_p:
8726 case Intrinsic::ppc_altivec_vcmpgefp_p:
8730 case Intrinsic::ppc_altivec_vcmpgtfp_p:
8734 case Intrinsic::ppc_altivec_vcmpgtsb_p:
8738 case Intrinsic::ppc_altivec_vcmpgtsh_p:
8742 case Intrinsic::ppc_altivec_vcmpgtsw_p:
8746 case Intrinsic::ppc_altivec_vcmpgtsd_p:
8753 case Intrinsic::ppc_altivec_vcmpgtub_p:
8757 case Intrinsic::ppc_altivec_vcmpgtuh_p:
8761 case Intrinsic::ppc_altivec_vcmpgtuw_p:
8765 case Intrinsic::ppc_altivec_vcmpgtud_p:
8774 case Intrinsic::ppc_vsx_xvcmpeqdp_p:
8775 case Intrinsic::ppc_vsx_xvcmpgedp_p:
8776 case Intrinsic::ppc_vsx_xvcmpgtdp_p:
8777 case Intrinsic::ppc_vsx_xvcmpeqsp_p:
8778 case Intrinsic::ppc_vsx_xvcmpgesp_p:
8779 case Intrinsic::ppc_vsx_xvcmpgtsp_p:
8780 if (Subtarget.
hasVSX()) {
8781 switch (IntrinsicID) {
8782 case Intrinsic::ppc_vsx_xvcmpeqdp_p:
8785 case Intrinsic::ppc_vsx_xvcmpgedp_p:
8788 case Intrinsic::ppc_vsx_xvcmpgtdp_p:
8791 case Intrinsic::ppc_vsx_xvcmpeqsp_p:
8794 case Intrinsic::ppc_vsx_xvcmpgesp_p:
8797 case Intrinsic::ppc_vsx_xvcmpgtsp_p:
8807 case Intrinsic::ppc_altivec_vcmpbfp:
8810 case Intrinsic::ppc_altivec_vcmpeqfp:
8813 case Intrinsic::ppc_altivec_vcmpequb:
8816 case Intrinsic::ppc_altivec_vcmpequh:
8819 case Intrinsic::ppc_altivec_vcmpequw:
8822 case Intrinsic::ppc_altivec_vcmpequd:
8828 case Intrinsic::ppc_altivec_vcmpneb:
8829 case Intrinsic::ppc_altivec_vcmpneh:
8830 case Intrinsic::ppc_altivec_vcmpnew:
8831 case Intrinsic::ppc_altivec_vcmpnezb:
8832 case Intrinsic::ppc_altivec_vcmpnezh:
8833 case Intrinsic::ppc_altivec_vcmpnezw:
8835 switch (IntrinsicID) {
8838 case Intrinsic::ppc_altivec_vcmpneb:
8841 case Intrinsic::ppc_altivec_vcmpneh:
8844 case Intrinsic::ppc_altivec_vcmpnew:
8847 case Intrinsic::ppc_altivec_vcmpnezb:
8850 case Intrinsic::ppc_altivec_vcmpnezh:
8853 case Intrinsic::ppc_altivec_vcmpnezw:
8860 case Intrinsic::ppc_altivec_vcmpgefp:
8863 case Intrinsic::ppc_altivec_vcmpgtfp:
8866 case Intrinsic::ppc_altivec_vcmpgtsb:
8869 case Intrinsic::ppc_altivec_vcmpgtsh:
8872 case Intrinsic::ppc_altivec_vcmpgtsw:
8875 case Intrinsic::ppc_altivec_vcmpgtsd:
8881 case Intrinsic::ppc_altivec_vcmpgtub:
8884 case Intrinsic::ppc_altivec_vcmpgtuh:
8887 case Intrinsic::ppc_altivec_vcmpgtuw:
8890 case Intrinsic::ppc_altivec_vcmpgtud:
8904 unsigned IntrinsicID =
8905 cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
8909 if (IntrinsicID == Intrinsic::thread_pointer) {
8911 if (Subtarget.isPPC64())
8919 if (Subtarget.hasP9Vector() &&
8920 (IntrinsicID == Intrinsic::ppc_altivec_vmaxsw ||
8921 IntrinsicID == Intrinsic::ppc_altivec_vmaxsh ||
8922 IntrinsicID == Intrinsic::ppc_altivec_vmaxsb)) {
8978 switch (cast<ConstantSDNode>(Op.
getOperand(1))->getZExtValue()) {
8981 BitNo = 0; InvertBit =
false;
8984 BitNo = 0; InvertBit =
true;
8987 BitNo = 2; InvertBit =
false;
8990 BitNo = 2; InvertBit =
true;
9012 int ArgStart = isa<ConstantSDNode>(Op.
getOperand(0)) ? 0 : 1;
9014 switch (cast<ConstantSDNode>(Op.
getOperand(ArgStart))->getZExtValue()) {
9015 case Intrinsic::ppc_cfence: {
9016 assert(ArgStart == 1 &&
"llvm.ppc.cfence must carry a chain argument.");
9017 assert(Subtarget.isPPC64() &&
"Only 64-bit is supported for now.");
9051 int VectorIndex = 0;
9052 if (Subtarget.isLittleEndian())
9064 "Expecting an atomic compare-and-swap here.");
9066 auto *AtomicNode = cast<AtomicSDNode>(Op.
getNode());
9067 EVT MemVT = AtomicNode->getMemoryVT();
9068 if (MemVT.getSizeInBits() >= 32)
9078 unsigned MaskVal = (1 << MemVT.getSizeInBits()) - 1;
9085 for (
int i = 0, e = AtomicNode->getNumOperands(); i < e; i++)
9086 Ops.
push_back(AtomicNode->getOperand(i));
9138 "Should only be called for ISD::INSERT_VECTOR_ELT");
9153 unsigned InsertAtElement = C->getZExtValue();
9154 unsigned InsertAtByte = InsertAtElement * BytesInEachElement;
9155 if (Subtarget.isLittleEndian()) {
9156 InsertAtByte = (16 - BytesInEachElement) - InsertAtByte;
9170 "Unknown extract_vector_elt type");
9210 unsigned Offset = 4*cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue();
9217 if (!Subtarget.useCRBits())
9244 SDValue Vals[4], LoadChains[4];
9245 for (
unsigned Idx = 0; Idx < 4; ++Idx) {
9247 if (ScalarVT != ScalarMemVT)
9251 ScalarMemVT,
MinAlign(Alignment, Idx * Stride),
9254 Load = DAG.
getLoad(ScalarVT, dl, LoadChain, BasePtr,
9261 "Unknown addressing mode on vector load");
9267 LoadChains[Idx] = Load.
getValue(1);
9271 BasePtr.getValueType()));
9282 SDValue RetOps[] = { Value, TF };
9292 SDValue VectElmts[4], VectElmtChains[4];
9293 for (
unsigned i = 0; i < 4; ++i) {
9301 VectElmtChains[i] = VectElmts[i].
getValue(1);
9307 SDValue RVals[] = { Value, LoadChain };
9334 for (
unsigned Idx = 0; Idx < 4; ++Idx) {
9339 if (ScalarVT != ScalarMemVT)
9343 ScalarMemVT,
MinAlign(Alignment, Idx * Stride),
9346 Store = DAG.
getStore(StoreChain, dl, Ex, BasePtr,
9353 "Unknown addressing mode on vector store");
9361 Stores[Idx] =
Store;
9409 SDValue Loads[4], LoadChains[4];
9410 for (
unsigned i = 0; i < 4; ++i) {
9417 LoadChains[i] = Loads[i].
getValue(1);
9423 for (
unsigned i = 0; i < 4; ++i) {
9471 LHS, RHS, Zero, DAG, dl);
9474 bool isLittleEndian = Subtarget.isLittleEndian();
9491 for (
unsigned i = 0; i != 8; ++i) {
9492 if (isLittleEndian) {
9494 Ops[i*2+1] = 2*i+16;
9497 Ops[i*2+1] = 2*i+1+16;
9531 return LowerGET_DYNAMIC_AREA_OFFSET(Op, DAG);
9538 case ISD::LOAD:
return LowerLOAD(Op, DAG);
9561 case ISD::MUL:
return LowerMUL(Op, DAG);
9573 return LowerINTRINSIC_VOID(Op, DAG);
9576 return LowerREM(Op, DAG);
9578 return LowerBSWAP(Op, DAG);
9580 return LowerATOMIC_CMP_SWAP(Op, DAG);
9590 llvm_unreachable(
"Do not know how to custom type legalize this operation!");
9601 if (cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue() !=
9602 Intrinsic::ppc_is_decremented_ctr_nonzero)
9606 "Unexpected result type for CTR decrement intrinsic");
9618 if (!Subtarget.isSVR4ABI() || Subtarget.isPPC64())
9670 if (isa<LoadInst>(Inst) && Subtarget.isPPC64())
9674 Intrinsic::ppc_cfence, {Inst->
getType()}),
9684 unsigned AtomicSize,
9687 unsigned CmpPred)
const {
9691 auto LoadMnemonic = PPC::LDARX;
9692 auto StoreMnemonic = PPC::STDCX;
9693 switch (AtomicSize) {
9697 LoadMnemonic = PPC::LBARX;
9698 StoreMnemonic = PPC::STBCX;
9699 assert(Subtarget.hasPartwordAtomics() &&
"Call this only with size >=4");
9702 LoadMnemonic = PPC::LHARX;
9703 StoreMnemonic = PPC::STHCX;
9704 assert(Subtarget.hasPartwordAtomics() &&
"Call this only with size >=4");
9707 LoadMnemonic = PPC::LWARX;
9708 StoreMnemonic = PPC::STWCX;
9711 LoadMnemonic = PPC::LDARX;
9712 StoreMnemonic = PPC::STDCX;
9739 unsigned TmpReg = (!BinOpcode) ? incr :
9741 : &PPC::GPRCRegClass);
9766 BuildMI(BB, dl, TII->
get(LoadMnemonic), dest)
9767 .addReg(ptrA).
addReg(ptrB);
9772 if (CmpOpcode == PPC::CMPW && AtomicSize < 4) {
9774 BuildMI(BB, dl, TII->
get(AtomicSize == 1 ? PPC::EXTSB : PPC::EXTSH),
9775 ExtReg).addReg(dest);
9776 BuildMI(BB, dl, TII->
get(CmpOpcode), PPC::CR0)
9777 .addReg(incr).
addReg(ExtReg);
9779 BuildMI(BB, dl, TII->
get(CmpOpcode), PPC::CR0)
9780 .addReg(incr).
addReg(dest);
9807 unsigned CmpPred)
const {
9809 if (Subtarget.hasPartwordAtomics())
9811 CmpOpcode, CmpPred);
9819 bool is64bit = Subtarget.isPPC64();
9820 bool isLittleEndian = Subtarget.isLittleEndian();
9821 unsigned ZeroReg = is64bit ? PPC::ZERO8 : PPC::ZERO;
9847 : &PPC::GPRCRegClass;
9887 if (ptrA != ZeroReg) {
9889 BuildMI(BB, dl, TII->
get(is64bit ? PPC::ADD8 : PPC::ADD4), Ptr1Reg)
9890 .addReg(ptrA).
addReg(ptrB);
9894 BuildMI(BB, dl, TII->
get(PPC::RLWINM), Shift1Reg).addReg(Ptr1Reg)
9896 if (!isLittleEndian)
9897 BuildMI(BB, dl, TII->
get(is64bit ? PPC::XORI8 : PPC::XORI), ShiftReg)
9898 .addReg(Shift1Reg).
addImm(is8bit ? 24 : 16);
9900 BuildMI(BB, dl, TII->
get(PPC::RLDICR), PtrReg)
9903 BuildMI(BB, dl, TII->
get(PPC::RLWINM), PtrReg)
9905 BuildMI(BB, dl, TII->
get(PPC::SLW), Incr2Reg)
9906 .addReg(incr).
addReg(ShiftReg);
9908 BuildMI(BB, dl, TII->
get(PPC::LI), Mask2Reg).addImm(255);
9910 BuildMI(BB, dl, TII->
get(PPC::LI), Mask3Reg).addImm(0);
9911 BuildMI(BB, dl, TII->
get(PPC::ORI),Mask2Reg).addReg(Mask3Reg).
addImm(65535);
9914 .addReg(Mask2Reg).
addReg(ShiftReg);
9917 BuildMI(BB, dl, TII->
get(PPC::LWARX), TmpDestReg)
9918 .addReg(ZeroReg).
addReg(PtrReg);
9921 .addReg(Incr2Reg).
addReg(TmpDestReg);
9922 BuildMI(BB, dl, TII->
get(is64bit ? PPC::ANDC8 : PPC::ANDC), Tmp2Reg)
9923 .addReg(TmpDestReg).
addReg(MaskReg);
9925 .addReg(TmpReg).
addReg(MaskReg);
9930 BuildMI(BB, dl, TII->
get(is64bit ? PPC::AND8 : PPC::AND), SReg)
9931 .addReg(TmpDestReg).
addReg(MaskReg);
9932 unsigned ValueReg = SReg;
9933 unsigned CmpReg = Incr2Reg;
9934 if (CmpOpcode == PPC::CMPW) {
9936 BuildMI(BB, dl, TII->
get(PPC::SRW), ValueReg)
9937 .addReg(SReg).
addReg(ShiftReg);
9939 BuildMI(BB, dl, TII->
get(is8bit ? PPC::EXTSB : PPC::EXTSH), ValueSReg)
9941 ValueReg = ValueSReg;
9944 BuildMI(BB, dl, TII->
get(CmpOpcode), PPC::CR0)
9945 .addReg(CmpReg).
addReg(ValueReg);
9953 .addReg(Tmp3Reg).
addReg(Tmp2Reg);
9964 BuildMI(*BB, BB->
begin(), dl, TII->
get(PPC::SRW), dest).addReg(TmpDestReg)
9988 assert(TRI->isTypeLegalForClass(*RC,
MVT::i32) &&
"Invalid destination!");
9994 "Invalid Pointer Size!");
10045 if (Subtarget.isPPC64() && Subtarget.isSVR4ABI()) {
10047 MIB =
BuildMI(*thisMBB, MI, DL, TII->
get(PPC::STD))
10058 BaseReg = Subtarget.isPPC64() ? PPC::X1 : PPC::R1;
10060 BaseReg = Subtarget.isPPC64() ? PPC::BP8 : PPC::BP;
10062 MIB =
BuildMI(*thisMBB, MI, DL,
10063 TII->
get(Subtarget.isPPC64() ? PPC::STD : PPC::STW))
10070 MIB =
BuildMI(*thisMBB, MI, DL, TII->
get(PPC::BCLalways)).addMBB(mainMBB);
10073 BuildMI(*thisMBB, MI, DL, TII->
get(PPC::LI), restoreDstReg).addImm(1);
10075 MIB =
BuildMI(*thisMBB, MI, DL, TII->
get(PPC::EH_SjLj_Setup))
10086 TII->
get(Subtarget.isPPC64() ? PPC::MFLR8 : PPC::MFLR), LabelReg);
10089 if (Subtarget.isPPC64()) {
10090 MIB =
BuildMI(mainMBB, DL, TII->
get(PPC::STD))
10095 MIB =
BuildMI(mainMBB, DL, TII->
get(PPC::STW))
10103 BuildMI(mainMBB, DL, TII->
get(PPC::LI), mainDstReg).addImm(0);
10108 TII->
get(PPC::PHI), DstReg)
10109 .addReg(mainDstReg).
addMBB(mainMBB)
10131 "Invalid Pointer Size!");
10134 (PVT ==
MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
10137 unsigned FP = (PVT ==
MVT::i64) ? PPC::X31 : PPC::R31;
10138 unsigned SP = (PVT ==
MVT::i64) ? PPC::X1 : PPC::R1;
10162 MIB =
BuildMI(*MBB, MI, DL, TII->
get(PPC::LWZ), FP)
10171 .addImm(LabelOffset)
10174 MIB =
BuildMI(*MBB, MI, DL, TII->
get(PPC::LWZ), Tmp)
10175 .addImm(LabelOffset)
10186 MIB =
BuildMI(*MBB, MI, DL, TII->
get(PPC::LWZ), SP)
10198 MIB =
BuildMI(*MBB, MI, DL, TII->
get(PPC::LWZ), BP)
10205 if (PVT ==
MVT::i64 && Subtarget.isSVR4ABI()) {
10226 if (MI.
getOpcode() == TargetOpcode::STACKMAP ||
10227 MI.
getOpcode() == TargetOpcode::PATCHPOINT) {
10228 if (Subtarget.isPPC64() && Subtarget.isSVR4ABI() &&
10229 MI.
getOpcode() == TargetOpcode::PATCHPOINT) {
10242 if (MI.
getOpcode() == PPC::EH_SjLj_SetJmp32 ||
10243 MI.
getOpcode() == PPC::EH_SjLj_SetJmp64) {
10245 }
else if (MI.
getOpcode() == PPC::EH_SjLj_LongJmp32 ||
10246 MI.
getOpcode() == PPC::EH_SjLj_LongJmp64) {
10259 if (MI.
getOpcode() == PPC::SELECT_CC_I4 ||
10263 if (MI.
getOpcode() == PPC::SELECT_CC_I4 ||
10273 }
else if (MI.
getOpcode() == PPC::SELECT_CC_I4 ||
10277 MI.
getOpcode() == PPC::SELECT_CC_F16 ||
10278 MI.
getOpcode() == PPC::SELECT_CC_QFRC ||
10279 MI.
getOpcode() == PPC::SELECT_CC_QSRC ||
10280 MI.
getOpcode() == PPC::SELECT_CC_QBRC ||
10281 MI.
getOpcode() == PPC::SELECT_CC_VRRC ||
10282 MI.
getOpcode() == PPC::SELECT_CC_VSFRC ||
10283 MI.
getOpcode() == PPC::SELECT_CC_VSSRC ||
10284 MI.
getOpcode() == PPC::SELECT_CC_VSRC ||
10285 MI.
getOpcode() == PPC::SELECT_CC_SPE4 ||
10286 MI.
getOpcode() == PPC::SELECT_CC_SPE ||
10315 F->
insert(It, copy0MBB);
10345 .addImm(SelectPred)
10367 }
else if (MI.
getOpcode() == PPC::ReadTB) {
10399 BuildMI(BB, dl, TII->
get(PPC::MFSPR), HiReg).addImm(269);
10400 BuildMI(BB, dl, TII->
get(PPC::MFSPR), LoReg).addImm(268);
10401 BuildMI(BB, dl, TII->
get(PPC::MFSPR), ReadAgainReg).addImm(269);
10405 BuildMI(BB, dl, TII->
get(PPC::CMPW), CmpReg)
10406 .addReg(HiReg).
addReg(ReadAgainReg);
10412 }
else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_ADD_I8)
10414 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_ADD_I16)
10416 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_ADD_I32)
10418 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_ADD_I64)
10421 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_AND_I8)
10423 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_AND_I16)
10425 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_AND_I32)
10427 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_AND_I64)
10430 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_OR_I8)
10432 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_OR_I16)
10434 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_OR_I32)
10436 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_OR_I64)
10439 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_XOR_I8)
10441 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_XOR_I16)
10443 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_XOR_I32)
10445 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_XOR_I64)
10448 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_NAND_I8)
10450 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_NAND_I16)
10452 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_NAND_I32)
10454 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_NAND_I64)
10457 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_SUB_I8)
10459 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_SUB_I16)
10461 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_SUB_I32)
10463 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_SUB_I64)
10466 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MIN_I8)
10468 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MIN_I16)
10470 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MIN_I32)
10472 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MIN_I64)
10475 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MAX_I8)
10477 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MAX_I16)
10479 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MAX_I32)
10481 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MAX_I64)
10484 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMIN_I8)
10486 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMIN_I16)
10488 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMIN_I32)
10490 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMIN_I64)
10493 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMAX_I8)
10495 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMAX_I16)
10497 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMAX_I32)
10499 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMAX_I64)
10502 else if (MI.
getOpcode() == PPC::ATOMIC_SWAP_I8)
10504 else if (MI.
getOpcode() == PPC::ATOMIC_SWAP_I16)
10506 else if (MI.
getOpcode() == PPC::ATOMIC_SWAP_I32)
10508 else if (MI.
getOpcode() == PPC::ATOMIC_SWAP_I64)
10510 else if (MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I32 ||
10511 MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I64 ||
10512 (Subtarget.hasPartwordAtomics() &&
10513 MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I8) ||
10514 (Subtarget.hasPartwordAtomics() &&
10515 MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I16)) {
10516 bool is64bit = MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I64;
10518 auto LoadMnemonic = PPC::LDARX;
10519 auto StoreMnemonic = PPC::STDCX;
10523 case PPC::ATOMIC_CMP_SWAP_I8:
10524 LoadMnemonic = PPC::LBARX;
10525 StoreMnemonic = PPC::STBCX;
10526 assert(Subtarget.hasPartwordAtomics() &&
"No support partword atomics.");
10528 case PPC::ATOMIC_CMP_SWAP_I16:
10529 LoadMnemonic = PPC::LHARX;
10530 StoreMnemonic = PPC::STHCX;
10531 assert(Subtarget.hasPartwordAtomics() &&
"No support partword atomics.");
10533 case PPC::ATOMIC_CMP_SWAP_I32:
10534 LoadMnemonic = PPC::LWARX;
10535 StoreMnemonic = PPC::STWCX;
10537 case PPC::ATOMIC_CMP_SWAP_I64:
10538 LoadMnemonic = PPC::LDARX;
10539 StoreMnemonic = PPC::STDCX;
10553 F->
insert(It, loop1MBB);
10554 F->
insert(It, loop2MBB);
10578 BuildMI(BB, dl, TII->
get(LoadMnemonic), dest)
10579 .addReg(ptrA).
addReg(ptrB);
10580 BuildMI(BB, dl, TII->
get(is64bit ? PPC::CMPD : PPC::CMPW), PPC::CR0)
10581 .addReg(oldval).
addReg(dest);
10604 }
else if (MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I8 ||
10605 MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I16) {
10609 bool is64bit = Subtarget.isPPC64();
10610 bool isLittleEndian = Subtarget.isLittleEndian();
10611 bool is8bit = MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I8;
10624 F->
insert(It, loop1MBB);
10625 F->
insert(It, loop2MBB);
10634 : &PPC::GPRCRegClass;
10637 unsigned ShiftReg =
10651 unsigned ZeroReg = is64bit ? PPC::ZERO8 : PPC::ZERO;
10684 if (ptrA != ZeroReg) {
10686 BuildMI(BB, dl, TII->
get(is64bit ? PPC::ADD8 : PPC::ADD4), Ptr1Reg)
10687 .addReg(ptrA).
addReg(ptrB);
10691 BuildMI(BB, dl, TII->
get(PPC::RLWINM), Shift1Reg).addReg(Ptr1Reg)
10693 if (!isLittleEndian)
10694 BuildMI(BB, dl, TII->
get(is64bit ? PPC::XORI8 : PPC::XORI), ShiftReg)
10695 .addReg(Shift1Reg).
addImm(is8bit ? 24 : 16);
10697 BuildMI(BB, dl, TII->
get(PPC::RLDICR), PtrReg)
10700 BuildMI(BB, dl, TII->
get(PPC::RLWINM), PtrReg)
10702 BuildMI(BB, dl, TII->
get(PPC::SLW), NewVal2Reg)
10703 .addReg(newval).
addReg(ShiftReg);
10704 BuildMI(BB, dl, TII->
get(PPC::SLW), OldVal2Reg)
10705 .addReg(oldval).
addReg(ShiftReg);
10707 BuildMI(BB, dl, TII->
get(PPC::LI), Mask2Reg).addImm(255);
10709 BuildMI(BB, dl, TII->
get(PPC::LI), Mask3Reg).addImm(0);
10710 BuildMI(BB, dl, TII->
get(PPC::ORI), Mask2Reg)
10711 .addReg(Mask3Reg).
addImm(65535);
10713 BuildMI(BB, dl, TII->
get(PPC::SLW), MaskReg)
10714 .addReg(Mask2Reg).
addReg(ShiftReg);
10716 .addReg(NewVal2Reg).
addReg(MaskReg);
10718 .addReg(OldVal2Reg).
addReg(MaskReg);
10721 BuildMI(BB, dl, TII->
get(PPC::LWARX), TmpDestReg)
10722 .addReg(ZeroReg).
addReg(PtrReg);
10724 .addReg(TmpDestReg).
addReg(MaskReg);
10725 BuildMI(BB, dl, TII->
get(PPC::CMPW), PPC::CR0)
10726 .addReg(TmpReg).
addReg(OldVal3Reg);
10733 BuildMI(BB, dl, TII->
get(PPC::ANDC),Tmp2Reg)
10734 .addReg(TmpDestReg).
addReg(MaskReg);
10736 .addReg(Tmp2Reg).
addReg(NewVal3Reg);
10737 BuildMI(BB, dl, TII->
get(PPC::STWCX)).addReg(Tmp4Reg)
10746 BuildMI(BB, dl, TII->
get(PPC::STWCX)).addReg(TmpDestReg)
10753 BuildMI(*BB, BB->
begin(), dl, TII->
get(PPC::SRW),dest).addReg(TmpReg)
10755 }
else if (MI.
getOpcode() == PPC::FADDrtz) {
10771 BuildMI(*BB, MI, dl, TII->
get(PPC::MTFSB1)).addImm(31);
10772 BuildMI(*BB, MI, dl, TII->
get(PPC::MTFSB0)).addImm(30);
10781 MI.
getOpcode() == PPC::ANDIo_1_EQ_BIT8 ||
10782 MI.
getOpcode() == PPC::ANDIo_1_GT_BIT8) {
10783 unsigned Opcode = (MI.
getOpcode() == PPC::ANDIo_1_EQ_BIT8 ||
10784 MI.
getOpcode() == PPC::ANDIo_1_GT_BIT8)
10788 MI.
getOpcode() == PPC::ANDIo_1_EQ_BIT8);
10792 &PPC::GPRCRegClass :
10793 &PPC::G8RCRegClass);
10796 BuildMI(*BB, MI, dl, TII->
get(Opcode), Dest)
10799 BuildMI(*BB, MI, dl, TII->
get(TargetOpcode::COPY),
10801 .addReg(isEQ ? PPC::CR0EQ : PPC::CR0GT);
10802 }
else if (MI.
getOpcode() == PPC::TCHECK_RET) {
10806 BuildMI(*BB, MI, Dl, TII->
get(PPC::TCHECK), CRReg);
10825 int RefinementSteps = Subtarget.
hasRecipPrec() ? 1 : 3;
10828 return RefinementSteps;
10832 int Enabled,
int &RefinementSteps,
10833 bool &UseOneConstNR,
10834 bool Reciprocal)
const {
10836 if ((VT ==
MVT::f32 && Subtarget.hasFRSQRTES()) ||
10837 (VT ==
MVT::f64 && Subtarget.hasFRSQRTE()) ||
10838 (VT ==
MVT::v4f32 && Subtarget.hasAltivec()) ||
10842 if (RefinementSteps == ReciprocalEstimate::Unspecified)
10845 UseOneConstNR =
true;
10853 int &RefinementSteps)
const {
10855 if ((VT ==
MVT::f32 && Subtarget.hasFRES()) ||
10856 (VT ==
MVT::f64 && Subtarget.hasFRE()) ||
10857 (VT ==
MVT::v4f32 && Subtarget.hasAltivec()) ||
10861 if (RefinementSteps == ReciprocalEstimate::Unspecified)
10868 unsigned PPCTargetLowering::combineRepeatedFPDivisors()
const {
10879 switch (Subtarget.getDarwinDirective()) {
10897 Offset += cast<ConstantSDNode>(Loc.
getOperand(1))->getSExtValue();
10906 unsigned Bytes,
int Dist,
10916 int FI = cast<FrameIndexSDNode>(Loc)->getIndex();
10917 int BFI = cast<FrameIndexSDNode>(BaseLoc)->getIndex();
10920 if (FS != BFS || FS != (
int)Bytes)
return false;
10924 SDValue Base1 = Loc, Base2 = BaseLoc;
10925 int64_t Offset1 = 0, Offset2 = 0;
10928 if (Base1 == Base2 && Offset1 == (Offset2 + Dist * Bytes))
10938 if (isGA1 && isGA2 && GV1 == GV2)
10939 return Offset1 == (Offset2 + Dist*Bytes);
10946 unsigned Bytes,
int Dist,
10949 EVT VT =
LS->getMemoryVT();
10956 switch (cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue()) {
10957 default:
return false;
10958 case Intrinsic::ppc_qpx_qvlfd:
10959 case Intrinsic::ppc_qpx_qvlfda:
10962 case Intrinsic::ppc_qpx_qvlfs:
10963 case Intrinsic::ppc_qpx_qvlfsa:
10966 case Intrinsic::ppc_qpx_qvlfcd:
10967 case Intrinsic::ppc_qpx_qvlfcda:
10970 case Intrinsic::ppc_qpx_qvlfcs:
10971 case Intrinsic::ppc_qpx_qvlfcsa:
10974 case Intrinsic::ppc_qpx_qvlfiwa:
10975 case Intrinsic::ppc_qpx_qvlfiwz:
10976 case Intrinsic::ppc_altivec_lvx:
10977 case Intrinsic::ppc_altivec_lvxl:
10978 case Intrinsic::ppc_vsx_lxvw4x:
10979 case Intrinsic::ppc_vsx_lxvw4x_be:
10982 case Intrinsic::ppc_vsx_lxvd2x:
10983 case Intrinsic::ppc_vsx_lxvd2x_be:
10986 case Intrinsic::ppc_altivec_lvebx:
10989 case Intrinsic::ppc_altivec_lvehx:
10992 case Intrinsic::ppc_altivec_lvewx:
11002 switch (cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue()) {
11003 default:
return false;
11004 case Intrinsic::ppc_qpx_qvstfd:
11005 case Intrinsic::ppc_qpx_qvstfda:
11008 case Intrinsic::ppc_qpx_qvstfs:
11009 case Intrinsic::ppc_qpx_qvstfsa:
11012 case Intrinsic::ppc_qpx_qvstfcd:
11013 case Intrinsic::ppc_qpx_qvstfcda:
11016 case Intrinsic::ppc_qpx_qvstfcs:
11017 case Intrinsic::ppc_qpx_qvstfcsa:
11020 case Intrinsic::ppc_qpx_qvstfiw:
11021 case Intrinsic::ppc_qpx_qvstfiwa:
11022 case Intrinsic::ppc_altivec_stvx:
11023 case Intrinsic::ppc_altivec_stvxl:
11024 case Intrinsic::ppc_vsx_stxvw4x:
11027 case Intrinsic::ppc_vsx_stxvd2x:
11030 case Intrinsic::ppc_vsx_stxvw4x_be:
11033 case Intrinsic::ppc_vsx_stxvd2x_be:
11036 case Intrinsic::ppc_altivec_stvebx:
11039 case Intrinsic::ppc_altivec_stvehx:
11042 case Intrinsic::ppc_altivec_stvewx:
11069 while (!Queue.empty()) {
11070 SDNode *ChainNext = Queue.pop_back_val();
11071 if (!Visited.
insert(ChainNext).second)
11074 if (
MemSDNode *ChainLD = dyn_cast<MemSDNode>(ChainNext)) {
11078 if (!Visited.count(ChainLD->getChain().getNode()))
11079 Queue.push_back(ChainLD->getChain().getNode());
11081 for (
const SDUse &
O : ChainNext->
ops())
11082 if (!Visited.count(
O.getNode()))
11083 Queue.push_back(
O.getNode());
11085 LoadRoots.
insert(ChainNext);
11098 Queue.push_back(*
I);
11100 while (!Queue.empty()) {
11101 SDNode *LoadRoot = Queue.pop_back_val();
11102 if (!Visited.
insert(LoadRoot).second)
11105 if (
MemSDNode *ChainLD = dyn_cast<MemSDNode>(LoadRoot))
11110 UE = LoadRoot->
use_end(); UI != UE; ++UI)
11111 if (((isa<MemSDNode>(*UI) &&
11112 cast<MemSDNode>(*UI)->getChain().getNode() == LoadRoot) ||
11114 Queue.push_back(*UI);
11147 auto Final = Shifted;
11157 SDValue PPCTargetLowering::ConvertSETCCToSubtract(
SDNode *N,
11158 DAGCombinerInfo &DCI)
const {
11166 if (!DCI.isAfterLegalizeDAG())
11172 UE = N->
use_end(); UI != UE; ++UI) {
11180 unsigned Size = DAG.getDataLayout().getLargestLegalIntTypeSizeInBits();
11182 if (OpSize < Size) {
11199 SDValue PPCTargetLowering::DAGCombineTruncBoolExt(
SDNode *N,
11200 DAGCombinerInfo &DCI)
const {
11204 assert(Subtarget.useCRBits() &&
"Expecting to be tracking CR bits");
11254 if (Op1Known.
Zero != Op2Known.
Zero || Op1Known.
One != Op2Known.
One)
11289 for (
unsigned i = 0; i < 2; ++i) {
11305 while (!BinOps.
empty()) {
11314 for (
unsigned i = 0, ie = BinOp.
getNumOperands(); i != ie; ++i) {
11348 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
11349 if (isa<ConstantSDNode>(Inputs[i]))
11353 UE = Inputs[i].getNode()->use_end();
11356 if (User != N && !Visited.
count(User))
11375 for (
unsigned i = 0, ie = PromOps.
size(); i != ie; ++i) {
11377 UE = PromOps[i].getNode()->use_end();
11380 if (User != N && !Visited.
count(User))
11400 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
11403 if (isa<ConstantSDNode>(Inputs[i]))
11409 std::list<HandleSDNode> PromOpHandles;
11410 for (
auto &PromOp : PromOps)
11411 PromOpHandles.emplace_back(PromOp);
11418 while (!PromOpHandles.empty()) {
11420 PromOpHandles.pop_back();
11426 if (!isa<ConstantSDNode>(PromOp.
getOperand(0)) &&
11429 PromOpHandles.emplace_front(PromOp);
11434 if (isa<ConstantSDNode>(RepValue))
11443 default: C = 0;
break;
11448 if ((!isa<ConstantSDNode>(PromOp.
getOperand(C)) &&
11450 (!isa<ConstantSDNode>(PromOp.
getOperand(C+1)) &&
11456 PromOpHandles.emplace_front(PromOp);
11464 for (
unsigned i = 0; i < 2; ++i)
11465 if (isa<ConstantSDNode>(Ops[C+i]))
11481 SDValue PPCTargetLowering::DAGCombineExtBoolTrunc(
SDNode *N,
11482 DAGCombinerInfo &DCI)
const {
11521 while (!BinOps.empty()) {
11522 SDValue BinOp = BinOps.back();
11528 PromOps.push_back(BinOp);
11530 for (
unsigned i = 0, ie = BinOp.
getNumOperands(); i != ie; ++i) {
11561 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
11562 if (isa<ConstantSDNode>(Inputs[i]))
11566 UE = Inputs[i].getNode()->use_end();
11569 if (User != N && !Visited.count(User))
11576 SelectTruncOp[0].insert(std::make_pair(User,
11580 SelectTruncOp[0].insert(std::make_pair(User,
11583 SelectTruncOp[1].insert(std::make_pair(User,
11589 for (
unsigned i = 0, ie = PromOps.size(); i != ie; ++i) {
11591 UE = PromOps[i].getNode()->
use_end();
11594 if (User != N && !Visited.count(User))
11601 SelectTruncOp[0].insert(std::make_pair(User,
11605 SelectTruncOp[0].insert(std::make_pair(User,
11608 SelectTruncOp[1].insert(std::make_pair(User,
11615 bool ReallyNeedsExt =
false;
11619 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
11620 if (isa<ConstantSDNode>(Inputs[i]))
11624 Inputs[i].getOperand(0).getValueSizeInBits();
11625 assert(PromBits < OpBits &&
"Truncation not to a smaller bit count?");
11630 OpBits-PromBits))) ||
11633 (OpBits-(PromBits-1)))) {
11634 ReallyNeedsExt =
true;
11642 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
11646 if (isa<ConstantSDNode>(Inputs[i]))
11649 SDValue InSrc = Inputs[i].getOperand(0);
11663 std::list<HandleSDNode> PromOpHandles;
11664 for (
auto &PromOp : PromOps)
11665 PromOpHandles.emplace_back(PromOp);
11671 while (!PromOpHandles.empty()) {
11673 PromOpHandles.pop_back();
11677 default: C = 0;
break;
11682 if ((!isa<ConstantSDNode>(PromOp.
getOperand(C)) &&
11684 (!isa<ConstantSDNode>(PromOp.
getOperand(C+1)) &&
11690 PromOpHandles.emplace_front(PromOp);
11702 PromOpHandles.emplace_front(PromOp);
11711 for (
unsigned i = 0; i < 2; ++i) {
11712 if (!isa<ConstantSDNode>(Ops[C+i]))
11729 auto SI0 = SelectTruncOp[0].
find(PromOp.
getNode());
11730 if (SI0 != SelectTruncOp[0].
end())
11732 auto SI1 = SelectTruncOp[1].
find(PromOp.
getNode());
11733 if (SI1 != SelectTruncOp[1].
end())
11742 if (!ReallyNeedsExt)
11754 "Invalid extension type");
11780 combineElementTruncationToVectorTruncation(
SDNode *N,
11781 DAGCombinerInfo &DCI)
const {
11783 "Should be called with a BUILD_VECTOR node");
11790 "The input operand must be an fp-to-int conversion.");
11799 bool IsSplat =
true;
11810 if (NextConversion != FirstConversion)
11839 DAG.getIntPtrConstant(1, dl));
11854 SDValue BV = DAG.getBuildVector(NewVT, dl, Ops);
11855 return DAG.
getNode(Opcode, dl, TargetVT, BV);
11868 "Should be called with a BUILD_VECTOR node");
11871 bool InputsAreConsecutiveLoads =
true;
11872 bool InputsAreReverseConsecutive =
true;
11875 bool IsRoundOfExtLoad =
false;
11902 if (IsRoundOfExtLoad && LD2->getExtensionType() !=
ISD::EXTLOAD)
11906 InputsAreConsecutiveLoads =
false;
11908 InputsAreReverseConsecutive =
false;
11911 if (!InputsAreConsecutiveLoads && !InputsAreReverseConsecutive)
11915 assert(!(InputsAreConsecutiveLoads && InputsAreReverseConsecutive) &&
11916 "The loads cannot be both consecutive and reverse consecutive.");
11919 IsRoundOfExtLoad ? FirstInput.
getOperand(0) : FirstInput;
11926 if (InputsAreConsecutiveLoads) {
11927 assert(LD1 &&
"Input needs to be a LoadSDNode.");
11932 if (InputsAreReverseConsecutive) {
11933 assert(LDL &&
"Input needs to be a LoadSDNode.");
11935 LDL->getBasePtr(), LDL->getPointerInfo(),
11936 LDL->getAlignment());
11951 SDValue Input, uint64_t Elems,
11952 uint64_t CorrectElems) {
11963 ShuffleMask[CorrectElems & 0xF] = Elems & 0xF;
11965 ShuffleMask[(CorrectElems & 0xF0) >> 4] = (Elems & 0xF0) >> 4;
11966 CorrectElems = CorrectElems >> 8;
11967 Elems = Elems >> 8;
11972 DAG.
getUNDEF(Input.getValueType()), ShuffleMask);
11995 uint64_t TargetElems[] = {
12003 uint64_t Elems = 0;
12007 auto isSExtOfVecExtract = [&](
SDValue Op) ->
bool {
12027 if (Input && Input != Extract.
getOperand(0))
12033 Elems = Elems << 8;
12043 if (!isSExtOfVecExtract(N->
getOperand(i))) {
12050 int TgtElemArrayIdx;
12053 if (InputSize + OutputSize == 40)
12054 TgtElemArrayIdx = 0;
12055 else if (InputSize + OutputSize == 72)
12056 TgtElemArrayIdx = 1;
12057 else if (InputSize + OutputSize == 48)
12058 TgtElemArrayIdx = 2;
12059 else if (InputSize + OutputSize == 80)
12060 TgtElemArrayIdx = 3;
12061 else if (InputSize + OutputSize == 96)
12062 TgtElemArrayIdx = 4;
12066 uint64_t CorrectElems = TargetElems[TgtElemArrayIdx];
12068 ? CorrectElems & 0x0F0F0F0F0F0F0F0F
12069 : CorrectElems & 0xF0F0F0F0F0F0F0F0;
12070 if (Elems != CorrectElems) {
12078 SDValue PPCTargetLowering::DAGCombineBuildVector(
SDNode *N,
12079 DAGCombinerInfo &DCI)
const {
12081 "Should be called with a BUILD_VECTOR node");
12086 if (!Subtarget.hasVSX())
12094 SDValue Reduced = combineElementTruncationToVectorTruncation(N, DCI);
12109 if (Subtarget.hasP9Altivec() && !DCI.isBeforeLegalize()) {
12138 if (!Ext1Op || !Ext2Op)
12146 int SecondElem = Ext2Op->getZExtValue();
12148 if (FirstElem == 0 && SecondElem == 1)
12149 SubvecIdx = Subtarget.isLittleEndian() ? 1 : 0;
12150 else if (FirstElem == 2 && SecondElem == 3)
12151 SubvecIdx = Subtarget.isLittleEndian() ? 0 : 1;
12159 SrcVec, DAG.getIntPtrConstant(SubvecIdx, dl));
12163 DAGCombinerInfo &DCI)
const {
12166 "Need an int -> FP conversion node here");
12185 (FirstOperand.getValueType() ==
MVT::i8 ||
12186 FirstOperand.getValueType() ==
MVT::i16);
12187 if (Subtarget.hasP9Vector() && Subtarget.hasP9Altivec() && SubWordLoad) {
12190 unsigned ConvOp = Signed ?
12196 LoadSDNode *LDN = cast<LoadSDNode>(FirstOperand.getNode());
12204 SDValue ExtOps[] = { Ld, WidthConst };
12220 "UINT_TO_FP is supported only with FPCVT");
12236 Subtarget.hasFPCVT()) ||
12241 DCI.AddToWorklist(Src.
getNode());
12257 DCI.AddToWorklist(FP.
getNode());
12306 if (Subtarget.needsSwapsForVSXMemOps() && !(MMO->
getAlignment()%16)
12311 SDValue LoadOps[] = { Chain, Base };
12323 if (VecTy != MVT::v2f64) {
12377 if (Subtarget.needsSwapsForVSXMemOps() && !(MMO->
getAlignment()%16)
12392 SDValue StoreOps[] = { Chain, Swap, Base };
12395 StoreOps, VecTy, MMO);
12409 &&
"Not a FP_TO_INT Instruction!");
12420 bool ValidTypeForStoreFltAsInt =
12422 (Subtarget.hasP9Vector() && (Op1VT ==
MVT::i16 || Op1VT ==
MVT::i8)));
12424 if (ResVT ==
MVT::ppcf128 || !Subtarget.hasP8Altivec() ||
12425 cast<StoreSDNode>(
N)->isTruncatingStore() || !ValidTypeForStoreFltAsInt)
12439 Val = DAG.
getNode(ConvOpcode,
12451 cast<StoreSDNode>(
N)->getMemoryVT(),
12452 cast<StoreSDNode>(
N)->getMemOperand());
12465 return combineSHL(N, DCI);
12467 return combineSRA(N, DCI);
12469 return combineSRL(N, DCI);
12480 if (
C->isNullValue() ||
12481 C->isAllOnesValue())
12488 return DAGCombineExtBoolTrunc(N, DCI);
12492 return DAGCombineTruncBoolExt(N, DCI);
12495 return combineFPToIntToFP(N, DCI);
12502 SDValue Val= combineStoreFPToInt(N, DCI);
12508 if (cast<StoreSDNode>(N)->isUnindexed() && Opcode ==
ISD::BSWAP &&
12511 (Subtarget.hasLDBRX() && Subtarget.isPPC64() && Op1VT ==
MVT::i64))) {
12514 EVT mVT = cast<StoreSDNode>(
N)->getMemoryVT();
12525 if (Op1VT.
bitsGT(mVT)) {
12539 Ops, cast<StoreSDNode>(
N)->getMemoryVT(),
12540 cast<StoreSDNode>(
N)->getMemOperand());
12548 EVT MemVT = cast<StoreSDNode>(
N)->getMemoryVT();
12558 cast<StoreSDNode>(
N)->setTruncatingStore(
true);
12566 if (Subtarget.needsSwapsForVSXMemOps() &&
12579 if (VT.isSimple()) {
12580 MVT LoadVT = VT.getSimpleVT();
12581 if (Subtarget.needsSwapsForVSXMemOps() &&
12594 auto ReplaceTwoFloatLoad = [&]() {
12614 while (UI.getUse().getResNo() != 0) ++UI;
12616 while (UI.getUse().getResNo() != 0) ++UI;
12617 SDNode *RightShift = *UI;
12626 !isa<ConstantSDNode>(RightShift->
getOperand(1)) ||
12647 if (Subtarget.isLittleEndian())
12656 "Non-pre-inc AM on PPC?");
12689 if (ReplaceTwoFloatLoad())
12708 bool isLittleEndian = Subtarget.isLittleEndian();
12735 MVT PermCntlTy, PermTy, LDTy;
12736 if (Subtarget.hasAltivec()) {
12737 Intr = isLittleEndian ? Intrinsic::ppc_altivec_lvsr :
12738 Intrinsic::ppc_altivec_lvsl;
12739 IntrLD = Intrinsic::ppc_altivec_lvx;
12740 IntrPerm = Intrinsic::ppc_altivec_vperm;
12745 Intr = MemVT ==
MVT::v4f64 ? Intrinsic::ppc_qpx_qvlpcld :
12746 Intrinsic::ppc_qpx_qvlpcls;
12747 IntrLD = MemVT ==
MVT::v4f64 ? Intrinsic::ppc_qpx_qvlfd :
12748 Intrinsic::ppc_qpx_qvlfs;
12749 IntrPerm = Intrinsic::ppc_qpx_qvfperm;
12771 SDValue BaseLoadOps[] = { Chain, LDXIntID, Ptr };
12775 BaseLoadOps, LDTy, BaseMMO);
12783 int IncOffset = VT.getSizeInBits() / 8;
12784 int IncValue = IncOffset;
12801 SDValue ExtraLoadOps[] = { Chain, LDXIntID, Ptr };
12805 ExtraLoadOps, LDTy, ExtraMMO);
12816 if (isLittleEndian)
12818 ExtraLoad, BaseLoad, PermCntl, DAG, dl);
12821 BaseLoad, ExtraLoad, PermCntl, DAG, dl);
12824 Perm = Subtarget.hasAltivec() ?
12839 bool isLittleEndian = Subtarget.isLittleEndian();
12840 unsigned IID = cast<ConstantSDNode>(N->
getOperand(0))->getZExtValue();
12842 : Intrinsic::ppc_altivec_lvsl);
12843 if ((IID == Intr ||
12844 IID == Intrinsic::ppc_qpx_qvlpcld ||
12845 IID == Intrinsic::ppc_qpx_qvlpcls) &&
12849 int Bits = IID == Intrinsic::ppc_qpx_qvlpcld ?
12860 cast<ConstantSDNode>(UI->getOperand(0))->getZExtValue() == IID) {
12870 if (isa<ConstantSDNode>(Add->
getOperand(1))) {
12873 UE = BasePtr->
use_end(); UI != UE; ++UI) {
12874 if (UI->getOpcode() ==
ISD::ADD &&
12875 isa<ConstantSDNode>(UI->getOperand(1)) &&
12876 (cast<ConstantSDNode>(Add->
getOperand(1))->getZExtValue() -
12877 cast<ConstantSDNode>(UI->getOperand(1))->getZExtValue()) %
12878 (1ULL << Bits) == 0) {
12883 cast<ConstantSDNode>(
VI->getOperand(0))->getZExtValue() == IID) {
12897 if (Subtarget.needsSwapsForVSXMemOps()) {
12898 switch (cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue()) {
12901 case Intrinsic::ppc_vsx_lxvw4x:
12902 case Intrinsic::ppc_vsx_lxvd2x:
12910 if (Subtarget.needsSwapsForVSXMemOps()) {
12911 switch (cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue()) {
12914 case Intrinsic::ppc_vsx_stxvw4x:
12915 case Intrinsic::ppc_vsx_stxvd2x:
12925 (Subtarget.hasLDBRX() && Subtarget.isPPC64() &&
12968 SDNode *VCMPoNode =
nullptr;
12989 SDNode *FlagUser =
nullptr;
12991 FlagUser ==
nullptr; ++UI) {
12994 for (
unsigned i = 0, e = User->getNumOperands(); i != e; ++i) {
12995 if (User->getOperand(i) ==
SDValue(VCMPoNode, 1)) {
13005 return SDValue(VCMPoNode, 0);
13013 cast<ConstantSDNode>(Cond.
getOperand(1))->getZExtValue() ==
13014 Intrinsic::ppc_is_decremented_ctr_nonzero) {
13020 "Counter decrement has more than one use");
13040 Intrinsic::ppc_is_decremented_ctr_nonzero &&
13046 cast<ConstantSDNode>(LHS.
getOperand(1))->getZExtValue() ==
13047 Intrinsic::ppc_is_decremented_ctr_nonzero &&
13048 isa<ConstantSDNode>(RHS)) {
13050 "Counter decrement comparison is not EQ or NE");
13052 unsigned Val = cast<ConstantSDNode>(RHS)->getZExtValue();
13060 "Counter decrement has more than one use");
13072 assert(isDot &&
"Can't compare against a vector result!");
13076 unsigned Val = cast<ConstantSDNode>(RHS)->getZExtValue();
13077 if (Val != 0 && Val != 1) {
13085 bool BranchOnWhenPredTrue = (CC ==
ISD::SETEQ) ^ (Val == 0);
13098 switch (cast<ConstantSDNode>(LHS.
getOperand(1))->getZExtValue()) {
13122 return DAGCombineBuildVector(N, DCI);
13134 if (VT ==
MVT::i64 && !Subtarget.isPPC64())
13137 !(Divisor.
isPowerOf2() || (-Divisor).isPowerOf2()))
13143 bool IsNegPow2 = (-Divisor).isPowerOf2();
13164 const APInt &DemandedElts,
13166 unsigned Depth)
const {
13173 Known.
Zero = 0xFFFF0000;
13177 switch (cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue()) {
13179 case Intrinsic::ppc_altivec_vcmpbfp_p:
13180 case Intrinsic::ppc_altivec_vcmpeqfp_p:
13181 case Intrinsic::ppc_altivec_vcmpequb_p:
13182 case Intrinsic::ppc_altivec_vcmpequh_p:
13183 case Intrinsic::ppc_altivec_vcmpequw_p:
13184 case Intrinsic::ppc_altivec_vcmpequd_p:
13185 case Intrinsic::ppc_altivec_vcmpgefp_p:
13186 case Intrinsic::ppc_altivec_vcmpgtfp_p:
13187 case Intrinsic::ppc_altivec_vcmpgtsb_p:
13188 case Intrinsic::ppc_altivec_vcmpgtsh_p:
13189 case Intrinsic::ppc_altivec_vcmpgtsw_p:
13190 case Intrinsic::ppc_altivec_vcmpgtsd_p:
13191 case Intrinsic::ppc_altivec_vcmpgtub_p:
13192 case Intrinsic::ppc_altivec_vcmpgtuh_p:
13193 case Intrinsic::ppc_altivec_vcmpgtuw_p:
13194 case Intrinsic::ppc_altivec_vcmpgtud_p:
13203 switch (Subtarget.getDarwinDirective()) {
13221 uint64_t LoopSize = 0;
13223 for (
auto J = (*I)->begin(), JE = (*I)->end(); J != JE; ++J) {
13229 if (LoopSize > 16 && LoopSize <= 32)
13243 if (Constraint.
size() == 1) {
13244 switch (Constraint[0]) {
13262 }
else if (Constraint ==
"wc") {
13264 }
else if (Constraint ==
"wa" || Constraint ==
"wd" ||
13265 Constraint ==
"wf" || Constraint ==
"ws") {
13281 if (!CallOperandVal)
13288 else if ((
StringRef(constraint) ==
"wa" ||
13296 switch (*constraint) {
13326 std::pair<unsigned, const TargetRegisterClass *>
13330 if (Constraint.
size() == 1) {
13332 switch (Constraint[0]) {
13334 if (VT ==
MVT::i64 && Subtarget.isPPC64())
13335 return std::make_pair(0U, &PPC::G8RC_NOX0RegClass);
13336 return std::make_pair(0U, &PPC::GPRC_NOR0RegClass);
13338 if (VT ==
MVT::i64 && Subtarget.isPPC64())
13339 return std::make_pair(0U, &PPC::G8RCRegClass);
13340 return std::make_pair(0U, &PPC::GPRCRegClass);
13346 if (Subtarget.hasSPE()) {
13348 return std::make_pair(0U, &PPC::SPE4RCRegClass);
13350 return std::make_pair(0U, &PPC::SPERCRegClass);
13353 return std::make_pair(0U, &PPC::F4RCRegClass);
13355 return std::make_pair(0U, &PPC::F8RCRegClass);
13357 return std::make_pair(0U, &PPC::QFRCRegClass);
13359 return std::make_pair(0U, &PPC::QSRCRegClass);
13364 return std::make_pair(0U, &PPC::QFRCRegClass);
13366 return std::make_pair(0U, &PPC::QSRCRegClass);
13367 if (Subtarget.hasAltivec())
13368 return std::make_pair(0U, &PPC::VRRCRegClass);
13371 return std::make_pair(0U, &PPC::CRRCRegClass);
13373 }
else if (Constraint ==
"wc" && Subtarget.useCRBits()) {
13375 return std::make_pair(0U, &PPC::CRBITRCRegClass);
13376 }
else if ((Constraint ==
"wa" || Constraint ==
"wd" ||
13377 Constraint ==
"wf") && Subtarget.hasVSX()) {
13378 return std::make_pair(0U, &PPC::VSRCRegClass);
13379 }
else if (Constraint ==
"ws" && Subtarget.hasVSX()) {
13380 if (VT ==
MVT::f32 && Subtarget.hasP8Vector())
13381 return std::make_pair(0U, &PPC::VSSRCRegClass);
13383 return std::make_pair(0U, &PPC::VSFRCRegClass);
13386 std::pair<unsigned, const TargetRegisterClass *> R =
13395 if (R.first && VT ==
MVT::i64 && Subtarget.isPPC64() &&
13396 PPC::GPRCRegClass.contains(R.first))
13398 PPC::sub_32, &PPC::G8RCRegClass),
13399 &PPC::G8RCRegClass);
13403 R.first = PPC::CR0;
13404 R.second = &PPC::CRRCRegClass;
13413 std::string &Constraint,
13414 std::vector<SDValue>&Ops,
13419 if (Constraint.length() > 1)
return;
13421 char Letter = Constraint[0];
13445 if (isShiftedUInt<16, 16>(Value))
13449 if (isShiftedInt<16, 16>(Value))
13478 Ops.push_back(Result);
13504 switch (AM.
Scale) {
13535 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
13541 bool isPPC64 = Subtarget.isPPC64();
13545 SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);
13547 DAG.
getConstant(Subtarget.getFrameLowering()->getReturnSaveOffset(), dl,
13555 SDValue RetAddrFI = getReturnAddrFrameIndex(DAG);
13563 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
13576 FrameReg = isPPC64 ? PPC::X1 : PPC::R1;
13578 FrameReg = isPPC64 ? PPC::FP8 : PPC::FP;
13592 bool isPPC64 = Subtarget.isPPC64();
13593 bool isDarwinABI = Subtarget.isDarwinABI();
13601 .Case(
"r1", is64Bit ? PPC::X1 : PPC::R1)
13602 .
Case(
"r2", (isDarwinABI || isPPC64) ? 0 :
PPC::R2)
13603 .
Case(
"r13", (!isPPC64 && isDarwinABI) ? 0 :
13604 (is64Bit ? PPC::X13 : PPC::R13))
13621 unsigned Intrinsic)
const {
13622 switch (Intrinsic) {
13623 case Intrinsic::ppc_qpx_qvlfd:
13624 case Intrinsic::ppc_qpx_qvlfs:
13625 case Intrinsic::ppc_qpx_qvlfcd:
13626 case Intrinsic::ppc_qpx_qvlfcs:
13627 case Intrinsic::ppc_qpx_qvlfiwa:
13628 case Intrinsic::ppc_qpx_qvlfiwz:
13629 case Intrinsic::ppc_altivec_lvx:
13630 case Intrinsic::ppc_altivec_lvxl:
13631 case Intrinsic::ppc_altivec_lvebx:
13632 case Intrinsic::ppc_altivec_lvehx:
13633 case Intrinsic::ppc_altivec_lvewx:
13634 case Intrinsic::ppc_vsx_lxvd2x:
13635 case Intrinsic::ppc_vsx_lxvw4x: {
13637 switch (Intrinsic) {
13638 case Intrinsic::ppc_altivec_lvebx:
13641 case Intrinsic::ppc_altivec_lvehx:
13644 case Intrinsic::ppc_altivec_lvewx:
13647 case Intrinsic::ppc_vsx_lxvd2x:
13650 case Intrinsic::ppc_qpx_qvlfd:
13653 case Intrinsic::ppc_qpx_qvlfs:
13656 case Intrinsic::ppc_qpx_qvlfcd:
13659 case Intrinsic::ppc_qpx_qvlfcs:
13676 case Intrinsic::ppc_qpx_qvlfda:
13677 case Intrinsic::ppc_qpx_qvlfsa:
13678 case Intrinsic::ppc_qpx_qvlfcda:
13679 case Intrinsic::ppc_qpx_qvlfcsa:
13680 case Intrinsic::ppc_qpx_qvlfiwaa:
13681 case Intrinsic::ppc_qpx_qvlfiwza: {
13683 switch (Intrinsic) {
13684 case Intrinsic::ppc_qpx_qvlfda:
13687 case Intrinsic::ppc_qpx_qvlfsa:
13690 case Intrinsic::ppc_qpx_qvlfcda:
13693 case Intrinsic::ppc_qpx_qvlfcsa:
13710 case Intrinsic::ppc_qpx_qvstfd:
13711 case Intrinsic::ppc_qpx_qvstfs:
13712 case Intrinsic::ppc_qpx_qvstfcd:
13713 case Intrinsic::ppc_qpx_qvstfcs:
13714 case Intrinsic::ppc_qpx_qvstfiw:
13715 case Intrinsic::ppc_altivec_stvx:
13716 case Intrinsic::ppc_altivec_stvxl:
13717 case Intrinsic::ppc_altivec_stvebx:
13718 case Intrinsic::ppc_altivec_stvehx:
13719 case Intrinsic::ppc_altivec_stvewx:
13720 case Intrinsic::ppc_vsx_stxvd2x:
13721 case Intrinsic::ppc_vsx_stxvw4x: {
13723 switch (Intrinsic) {
13724 case Intrinsic::ppc_altivec_stvebx:
13727 case Intrinsic::ppc_altivec_stvehx:
13730 case Intrinsic::ppc_altivec_stvewx:
13733 case Intrinsic::ppc_vsx_stxvd2x:
13736 case Intrinsic::ppc_qpx_qvstfd:
13739 case Intrinsic::ppc_qpx_qvstfs:
13742 case Intrinsic::ppc_qpx_qvstfcd:
13745 case Intrinsic::ppc_qpx_qvstfcs:
13762 case Intrinsic::ppc_qpx_qvstfda:
13763 case Intrinsic::ppc_qpx_qvstfsa:
13764 case Intrinsic::ppc_qpx_qvstfcda:
13765 case Intrinsic::ppc_qpx_qvstfcsa:
13766 case Intrinsic::ppc_qpx_qvstfiwa: {
13768 switch (Intrinsic) {
13769 case Intrinsic::ppc_qpx_qvstfda:
13772 case Intrinsic::ppc_qpx_qvstfsa:
13775 case Intrinsic::ppc_qpx_qvstfcda:
13778 case Intrinsic::ppc_qpx_qvstfcsa:
13814 unsigned DstAlign,
unsigned SrcAlign,
13815 bool IsMemset,
bool ZeroMemset,
13822 if (Subtarget.hasQPX() && Size >= 32 && (!IsMemset || Size >= 64) &&
13823 (!SrcAlign || SrcAlign >= 32) && (!DstAlign || DstAlign >= 32) &&
13830 if (Subtarget.hasAltivec() && Size >= 16 &&
13831 (((!SrcAlign || SrcAlign >= 16) && (!DstAlign || DstAlign >= 16)) ||
13832 ((IsMemset && Subtarget.hasVSX()) || Subtarget.hasP8Vector())))
13836 if (Subtarget.isPPC64()) {
13850 return !(BitSize == 0 || BitSize > 64);
13858 return NumBits1 == 64 && NumBits2 == 32;
13866 return NumBits1 == 64 && NumBits2 == 32;
13873 EVT MemVT =
LD->getMemoryVT();
13875 (Subtarget.isPPC64() && MemVT ==
MVT::i32)) &&
13891 "invalid fpext types");
13909 bool *
Fast)
const {
13923 if (Subtarget.hasVSX()) {
13966 static const MCPhysReg ScratchRegs[] = {
13967 PPC::X12, PPC::LR8, PPC::CTR8, 0
13970 return ScratchRegs;
13974 const Constant *PersonalityFn)
const {
13975 return Subtarget.isPPC64() ? PPC::X3 : PPC::R3;
13979 const Constant *PersonalityFn)
const {
13980 return Subtarget.isPPC64() ? PPC::X4 :
PPC::R4;
13985 EVT VT ,
unsigned DefinedValues)
const {
13987 return Subtarget.hasDirectMove();
13989 if (Subtarget.hasVSX() || Subtarget.hasQPX())
14010 if (Subtarget.isDarwinABI())
return;
14011 if (!Subtarget.isPPC64())
return;
14032 RC = &PPC::G8RCRegClass;
14033 else if (PPC::F8RCRegClass.
contains(*
I))
14034 RC = &PPC::F8RCRegClass;
14035 else if (PPC::CRRCRegClass.
contains(*
I))
14036 RC = &PPC::CRRCRegClass;
14037 else if (PPC::VRRCRegClass.
contains(*
I))
14038 RC = &PPC::VRRCRegClass;
14049 Attribute::NoUnwind) &&
14050 "Function should be nounwind in insertCopiesSplitCSR!");
14056 for (
auto *Exit : Exits)
14058 TII->
get(TargetOpcode::COPY), *
I)
14065 if (!Subtarget.isTargetLinux())
14072 if (!Subtarget.isTargetLinux())
14077 if (!VT.
isSimple() || !Subtarget.hasVSX())
14101 unsigned TargetOpcode;
14120 if (
Mask->getZExtValue() == OpSizeInBits - 1)
14126 SDValue PPCTargetLowering::combineSHL(
SDNode *N, DAGCombinerInfo &DCI)
const {
14133 SDValue PPCTargetLowering::combineSRA(
SDNode *N, DAGCombinerInfo &DCI)
const {
14140 SDValue PPCTargetLowering::combineSRL(
SDNode *N, DAGCombinerInfo &DCI)
const {
14147 bool PPCTargetLowering::mayBeEmittedAsTailCall(
const CallInst *CI)
const {
14149 if (!Subtarget.isSVR4ABI() || !Subtarget.isPPC64())
14159 if (Attr.getValueAsString() ==
"true")
14165 if (!TM.Options.GuaranteedTailCallOpt &&
DisableSCO)
14170 if (!Callee || Callee->
isVarArg())
14182 bool PPCTargetLowering::
14183 isMaskAndCmp0FoldingBeneficial(
const Instruction &AndI)
const {
14186 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(Mask)) {
14188 if (CI->getBitWidth() > 64)
14190 int64_t ConstVal = CI->getZExtValue();
14192 (
isUInt<16>(ConstVal >> 16) && !(ConstVal & 0xFFFF));
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
PPCTargetLowering(const PPCTargetMachine &TM, const PPCSubtarget &STI)
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
ADJUST_TRAMPOLINE - This corresponds to the adjust_trampoline intrinsic.
G8RC = ADDI_TLSLD_L_ADDR G8RReg, Symbol, Symbol - Op that combines ADDI_TLSLD_L and GET_TLSLD_ADDR un...
cl::opt< bool > ANDIGlueBug
x3 = ADDI_TLSLD_L G8RReg, Symbol - For the local-dynamic TLS model, produces an ADDI8 instruction tha...
void setFrameAddressIsTaken(bool T)
virtual bool isJumpTableRelative() const
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
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...
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
User::const_op_iterator arg_iterator
The type of iterator to use when looping over actual arguments at this call site. ...
StringRef getSection() const
Get the custom section of this global if it has one.
unsigned getFirstUnallocated(ArrayRef< MCPhysReg > Regs) const
getFirstUnallocated - Return the index of the first unallocated register in the set, or Regs.size() if they are all allocated.
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values i...
void push_back(const T &Elt)
SDValue expandVSXLoadForLE(SDNode *N, DAGCombinerInfo &DCI) const
SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor, SelectionDAG &DAG, SmallVectorImpl< SDNode *> &Created) const override
Targets may override this function to provide custom SDIV lowering for power-of-2 denominators...
A parsed version of the target data layout string in and methods for querying it. ...
const_iterator end(StringRef path)
Get end iterator over path.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
virtual MVT getVectorIdxTy(const DataLayout &DL) const
Returns the type to be used for the index operand of: ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT...
EVT getValueType() const
Return the ValueType of the referenced return value.
Function * getCalledFunction() const
Return the function called, or null if this is an indirect function invocation.
static unsigned PrepareCall(SelectionDAG &DAG, SDValue &Callee, SDValue &InFlag, SDValue &Chain, SDValue CallSeqStart, const SDLoc &dl, int SPDiff, bool isTailCall, bool isPatchPoint, bool hasNest, SmallVectorImpl< std::pair< unsigned, SDValue >> &RegsToPass, SmallVectorImpl< SDValue > &Ops, std::vector< EVT > &NodeTys, ImmutableCallSite CS, const PPCSubtarget &Subtarget)
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg If BaseGV is null...
FastISel * createFastISel(FunctionLoweringInfo &FuncInfo, const TargetLibraryInfo *LibInfo)
static SDValue BuildVSLDOI(SDValue LHS, SDValue RHS, unsigned Amt, EVT VT, SelectionDAG &DAG, const SDLoc &dl)
BuildVSLDOI - Return a VECTOR_SHUFFLE that is a vsldoi of the specified amount.
FormattedString left_justify(StringRef Str, unsigned Width)
left_justify - append spaces after string so total output is Width characters.
Return with a flag operand, matched by 'blr'.
Newer FCTI[D,W]UZ floating-point-to-integer conversion instructions for unsigned integers with round ...
SDValue get_VSPLTI_elt(SDNode *N, unsigned ByteSize, SelectionDAG &DAG)
get_VSPLTI_elt - If this is a build_vector of constants which can be formed by using a vspltis[bhw] i...
static Instruction * callIntrinsic(IRBuilder<> &Builder, Intrinsic::ID Id)
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...
const SDValue & getOffset() const
GPRC, CHAIN = LBRX CHAIN, Ptr, Type - This is a byte-swapping load instruction.
void setVarArgsNumGPR(unsigned Num)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
This SDNode is used for target intrinsics that touch memory and need an associated MachineMemOperand...
const GlobalValue * getGlobal() const
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant, which is required to be operand #1) half of the integer or float value specified as operand #0.
unsigned getRegisterByName(const char *RegName, EVT VT, SelectionDAG &DAG) const override
Return the register ID of the name passed in.
uint64_t getZExtValue() const
Get zero extended value.
unsigned MaxLoadsPerMemcmpOptSize
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
unsigned getByValTypeAlignment(Type *Ty, const DataLayout &DL) const override
getByValTypeAlignment - Return the desired alignment for ByVal aggregate function arguments in the ca...
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
This class represents an incoming formal argument to a Function.
static cl::opt< bool > DisableSCO("disable-ppc-sco", cl::desc("disable sibling call optimization on ppc"), cl::Hidden)
QVFPERM = This corresponds to the QPX qvfperm instruction.
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond)
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
unsigned arg_size() const
virtual void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const
Insert a select instruction into MBB before I that will copy TrueReg to DstReg when Cond is true...
bool isIndexed() const
Return true if this is a pre/post inc/dec load/store.
SDValue CombineTo(SDNode *N, ArrayRef< SDValue > To, bool AddTo=true)
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, SDValue InGlue, const SDLoc &DL)
Return a new CALLSEQ_END node, which always must have a glue result (to ensure it's not CSE'd)...
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
static cl::opt< bool > DisablePPCUnaligned("disable-ppc-unaligned", cl::desc("disable unaligned load/store generation on PPC"), cl::Hidden)
Atomic ordering constants.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
SDValue getIndexedLoad(SDValue OrigLoad, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
C - The default llvm calling convention, compatible with C.
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...
int getFramePointerSaveIndex() const
ConstantSDNode * isConstOrConstSplat(SDValue N)
Returns the SDNode if it is a constant splat BuildVector or constant int.
static SDValue LowerLabelRef(SDValue HiPart, SDValue LoPart, bool isPIC, SelectionDAG &DAG)
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an vector value) starting with the ...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
BR_CC - Conditional branch.
Compute iterated dominance frontiers using a linear time algorithm.
unsigned getExceptionSelectorRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception typeid on entry to a la...
GPRC = address of GLOBAL_OFFSET_TABLE.
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
G8RC = ADDI_DTPREL_L G8RReg, Symbol - For the local-dynamic TLS model, produces an ADDI8 instruction ...
LLVM_NODISCARD bool equals_lower(StringRef RHS) const
equals_lower - Check for string equality, ignoring case.
int getVarArgsStackOffset() const
A Module instance is used to store all the information related to an LLVM module. ...
bool isPPC64() const
isPPC64 - Return true if we are generating code for 64-bit pointer mode.
bool CC_PPC32_SVR4_Custom_AlignFPArgRegs(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, ISD::ArgFlagsTy &ArgFlags, CCState &State)
bool CC_PPC32_SVR4_Custom_SkipLastArgRegsPPCF128(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, ISD::ArgFlagsTy &ArgFlags, CCState &State)
int getSplatIndex() const
MachineBasicBlock * EmitPartwordAtomicBinary(MachineInstr &MI, MachineBasicBlock *MBB, bool is8bit, unsigned Opcode, unsigned CmpOpcode=0, unsigned CmpPred=0) const
bool isVector() const
Return true if this is a vector value type.
Sched::Preference getSchedulingPreference() const
Return target scheduling preference.
class llvm::RegisterBankInfo GPR
bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I, MachineFunction &MF, unsigned Intrinsic) const override
Given an intrinsic, checks if on the target the intrinsic will need to map to a MemIntrinsicNode (tou...
const SDValue & getBasePtr() const
ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &info, const char *constraint) const override
Examine constraint string and operand type and determine a weight value.
static void LowerMemOpCallTo(SelectionDAG &DAG, MachineFunction &MF, SDValue Chain, SDValue Arg, SDValue PtrOff, int SPDiff, unsigned ArgOffset, bool isPPC64, bool isTailCall, bool isVector, SmallVectorImpl< SDValue > &MemOpChains, SmallVectorImpl< TailCallArgumentInfo > &TailCallArguments, const SDLoc &dl)
LowerMemOpCallTo - Store the argument to the stack or remember it in case of tail calls...
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS, Instruction *I=nullptr) const override
isLegalAddressingMode - Return true if the addressing mode represented by AM is legal for this target...
Carry-setting nodes for multiple precision addition and subtraction.
virtual unsigned getJumpTableEncoding() const
Return the entry encoding for a jump table in the current function.
void setLRStoreRequired()
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
virtual void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
Lower the specified operand into the Ops vector.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
unsigned addLiveIn(unsigned PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
unsigned getReg() const
getReg - Returns the register number.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
The following two target-specific nodes are used for calls through function pointers in the 64-bit SV...
VRRC = VADD_SPLAT Elt, EltSize - Temporary node to be expanded during instruction selection to optimi...
APInt zext(unsigned width) const
Zero extend to a new width.
bool isXXINSERTWMask(ShuffleVectorSDNode *N, unsigned &ShiftElts, unsigned &InsertAtByte, bool &Swap, bool IsLE)
isXXINSERTWMask - Return true if this VECTOR_SHUFFLE can be handled by the XXINSERTW instruction intr...
MachineMemOperand::Flags flags
MO_LO, MO_HA - lo16(symbol) and ha16(symbol)
const SDValue & getValue() const
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain...
This class represents a function call, abstracting a target machine's calling convention.
static bool findConsecutiveLoad(LoadSDNode *LD, SelectionDAG &DAG)
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Get a value with low bits set.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
QBRC, CHAIN = QVLFSb CHAIN, Ptr The 4xf32 load used for v4i1 constants.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change...
SDValue expandVSXStoreForLE(SDNode *N, DAGCombinerInfo &DCI) const
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *MBB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
static MVT getFloatingPointVT(unsigned BitWidth)
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
MachineBasicBlock * emitEHSjLjSetJmp(MachineInstr &MI, MachineBasicBlock *MBB) const
bool isXXSLDWIShuffleMask(ShuffleVectorSDNode *N, unsigned &ShiftElts, bool &Swap, bool IsLE)
isXXSLDWIShuffleMask - Return true if this is a shuffle mask suitable for a XXSLDWI instruction...
const SDValue & getChain() const
Function Alias Analysis Results
uint64_t getSize() const
Return the size in bytes of the memory reference.
static SDValue getTOCEntry(SelectionDAG &DAG, const SDLoc &dl, bool Is64Bit, SDValue GA)
ISD::MemIndexedMode getAddressingMode() const
Return the addressing mode for this load or store: unindexed, pre-inc, pre-dec, post-inc, or post-dec.
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
unsigned getValNo() const
bool hasAtomicLoad() const
Return true if this atomic instruction loads from memory.
CHAIN = RFEBB CHAIN, State - Return from event-based branch.
unsigned getAlignment() const
unsigned getValueSizeInBits(unsigned ResNo) const
Returns MVT::getSizeInBits(getValueType(ResNo)).
VEXTS, ByteWidth - takes an input in VSFRC and produces an output in VSFRC that is sign-extended from...
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
static unsigned CalculateStackSlotAlignment(EVT ArgVT, EVT OrigVT, ISD::ArgFlagsTy Flags, unsigned PtrByteSize)
CalculateStackSlotAlignment - Calculates the alignment of this argument on the stack.
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...
SDValue getIndexedStore(SDValue OrigStore, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
virtual const TargetRegisterClass * getRegClassFor(MVT VT) const
Return the register class that should be used for the specified value type.
constexpr bool isInt< 16 >(int64_t x)
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
bool isInteger() const
Return true if this is an integer or a vector integer type.
bool shouldExpandBuildVectorWithShuffles(EVT VT, unsigned DefinedValues) const override
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
CALL - A direct function call.
CHAIN,FLAG = BCTRL(CHAIN, INFLAG) - Directly corresponds to a BCTRL instruction.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned char TargetFlags=0)
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
bool isVectorTy() const
True if this is an instance of VectorType.
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - Get or set the calling convention of this function call...
static BranchProbability getOne()
virtual bool isZExtFree(Type *FromTy, Type *ToTy) const
Return true if any actual instruction that defines a value of type FromTy implicitly zero-extends the...
This defines the Use class.
Value * CallOperandVal
If this is the result output operand or a clobber, this is null, otherwise it is the incoming operand...
bool isOperationLegalOrCustom(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
SDValue getConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offs=0, bool isT=false, unsigned char TargetFlags=0)
void setVarArgsNumFPR(unsigned Num)
bool isVPKUDUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind, SelectionDAG &DAG)
isVPKUDUMShuffleMask - Return true if this is the shuffle mask for a VPKUDUM instruction.
virtual SDValue LowerToTLSEmulatedModel(const GlobalAddressSDNode *GA, SelectionDAG &DAG) const
Lower TLS global address SDNode for target independent emulated TLS model.
bool getPreIndexedAddressParts(SDNode *N, SDValue &Base, SDValue &Offset, ISD::MemIndexedMode &AM, SelectionDAG &DAG) const override
getPreIndexedAddressParts - returns true by value, base pointer and offset pointer and addressing mod...
Floating-point-to-interger conversion instructions.
static void PrepareTailCall(SelectionDAG &DAG, SDValue &InFlag, SDValue &Chain, const SDLoc &dl, int SPDiff, unsigned NumBytes, SDValue LROp, SDValue FPOp, SmallVectorImpl< TailCallArgumentInfo > &TailCallArguments)
unsigned getValueSizeInBits() const
Returns the size of the value in bits.
Newer FCFID[US] integer-to-floating-point conversion instructions for unsigned integers and single-pr...
unsigned getVarArgsNumGPR() const
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
int getReturnAddrSaveIndex() const
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node.
bool isLegalICmpImmediate(int64_t Imm) const override
isLegalICmpImmediate - Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructions which can compare a register against the immediate without having to materialize the immediate into a register.
bool isUnsignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs an unsigned comparison when used with intege...
INT = FGETSIGN(FP) - Return the sign bit of the specified floating point value as an integer 0/1 valu...
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
return AArch64::GPR64RegClass contains(Reg)
SDValue getExternalSymbol(const char *Sym, EVT VT)
Instruction * emitLeadingFence(IRBuilder<> &Builder, Instruction *Inst, AtomicOrdering Ord) const override
Inserts in the IR a target-specific intrinsic specifying a fence.
bool isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind, SelectionDAG &DAG)
isVPKUHUMShuffleMask - Return true if this is the shuffle mask for a VPKUHUM instruction.
static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
static unsigned EnsureStackAlignment(const PPCFrameLowering *Lowering, unsigned NumBytes)
EnsureStackAlignment - Round stack frame size up from NumBytes to ensure minimum alignment required f...
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
GlobalBaseReg - On Darwin, this node represents the result of the mflr at function entry...
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace, unsigned Align=1, bool *Fast=nullptr) const override
Is unaligned memory access allowed for the given type, and is it fast relative to software emulation...
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
OUTCHAIN = EH_SJLJ_LONGJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.longjmp intrinsic...
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations...
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
The address of a basic block.
void setVarArgsStackOffset(int Offset)
bool hasOneUse() const
Return true if there is exactly one use of this node.
bool isBeforeLegalize() const
A description of a memory reference used in the backend.
virtual bool isGAPlusOffset(SDNode *N, const GlobalValue *&GA, int64_t &Offset) const
Returns true (and the GlobalValue and the offset) if the node is a GlobalAddress + offset...
const_iterator begin() const
PPCFunctionInfo - This class is derived from MachineFunction private PowerPC target-specific informat...
const HexagonInstrInfo * TII
static Type * getFloatTy(LLVMContext &C)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
G8RC = ADDI_TLSGD_L_ADDR G8RReg, Symbol, Symbol - Op that combines ADDI_TLSGD_L and GET_TLS_ADDR unti...
Shift and rotation operations.
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
Class to represent struct types.
static cl::opt< bool > DisablePPCPreinc("disable-ppc-preinc", cl::desc("disable preincrement load/store generation on PPC"), cl::Hidden)
Base class for LoadSDNode and StoreSDNode.
bool isBuildVectorAllZeros(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR where all of the elements are 0 or undef...
bool hasDirectMove() const
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth...
MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s), MachineInstr opcode, and operands.
static void getMaxByValAlign(Type *Ty, unsigned &MaxAlign, unsigned MaxMaxAlign)
getMaxByValAlign - Helper for getByValTypeAlignment to determine the desired ByVal argument alignment...
static cl::opt< bool > EnableQuadPrecision("enable-ppc-quad-precision", cl::desc("enable quad precision float support on ppc"), cl::Hidden)
CallLoweringInfo & setChain(SDValue InChain)
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
static bool isLoad(int Opcode)
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
Base class for the full range of assembler expressions which are needed for parsing.
bool isIntegerTy() const
True if this is an instance of IntegerType.
op_iterator op_end() const
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
unsigned getScalarValueSizeInBits() const
uint64_t getConstantOperandVal(unsigned i) const
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
FLT_ROUNDS_ - Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest 2 Round to ...
virtual bool useLoadStackGuardNode() const
If this function returns true, SelectionDAGBuilder emits a LOAD_STACK_GUARD node when it is lowering ...
void setCondCodeAction(ISD::CondCode CC, MVT VT, LegalizeAction Action)
Indicate that the specified condition code is or isn't supported on the target and indicate what to d...
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isInConsecutiveRegs() const
EH_DWARF_CFA - This node represents the pointer to the DWARF Canonical Frame Address (CFA)...
The memory access is dereferenceable (i.e., doesn't trap).
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
Direct move from a GPR to a VSX register (algebraic)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
x3 = ADDI_TLSGD_L G8RReg, Symbol - For the general-dynamic TLS model, produces an ADDI8 instruction t...
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...
const DataLayout & getDataLayout() const
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
ATOMIC_CMP_SWAP - the exact same as the target-independent nodes except they ensure that the compare ...
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG...
const BlockAddress * getBlockAddress() const
void setJumpIsExpensive(bool isExpensive=true)
Tells the code generator not to expand logic operations on comparison predicates into separate sequen...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(T Value)
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
LocInfo getLocInfo() const
QVALIGNI = This corresponds to the QPX qvaligni instruction.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
zlib-gnu style compression
This file implements a class to represent arbitrary precision integral constant values and operations...
OutputArg - This struct carries flags and a value for a single outgoing (actual) argument or outgoing...
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
bool useSoftFloat() const
SmallVector< ISD::InputArg, 32 > Ins
AtomicOrdering
Atomic ordering for LLVM's memory model.
STACKSAVE - STACKSAVE has one operand, an input chain.
static void fixupFuncForFI(SelectionDAG &DAG, int FrameIdx, EVT VT)
SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
unsigned getSizeInBits() const
unsigned getPrefLoopAlignment(MachineLoop *ML) const override
Return the preferred loop alignment.
Context object for machine code objects.
static const unsigned PerfectShuffleTable[6561+1]
ValTy * getCalledValue() const
Return the pointer to function that is being called.
int64_t getSExtValue() const
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...
bool isSplatShuffleMask(ShuffleVectorSDNode *N, unsigned EltSize)
isSplatShuffleMask - Return true if the specified VECTOR_SHUFFLE operand specifies a splat of a singl...
unsigned getScalarSizeInBits() const
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
unsigned NoNaNsFPMath
NoNaNsFPMath - This flag is enabled when the -enable-no-nans-fp-math flag is specified on the command...
Type * getType() const
All values are typed, get the type of this value.
static bool isVMerge(ShuffleVectorSDNode *N, unsigned UnitSize, unsigned LHSStart, unsigned RHSStart)
isVMerge - Common function, used to match vmrg* shuffles.
bool getBoolValue() const
Convert APInt to a boolean value.
MachineFunction & getMachineFunction() const
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose...
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
SDValue getRegisterMask(const uint32_t *RegMask)
unsigned MaxLoadsPerMemcmp
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table...
SDValue getTargetFrameIndex(int FI, EVT VT)
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
LowerOperation - Provide custom lowering hooks for some operations.
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const override
getSetCCResultType - Return the ISD::SETCC ValueType
CHAIN = BDNZ CHAIN, DESTBB - These are used to create counter-based loops.
bool has64BitSupport() const
has64BitSupport - Return true if the selected CPU supports 64-bit instructions, regardless of whether...
const TargetMachine & getTarget() const
BasicBlock * GetInsertBlock() const
bool SelectAddressRegReg(SDValue N, SDValue &Base, SDValue &Index, SelectionDAG &DAG) const
SelectAddressRegReg - Given the specified addressed, check to see if it can be represented as an inde...
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
R32 = MFOCRF(CRREG, INFLAG) - Represents the MFOCRF instruction.
void clearBit(unsigned BitPosition)
Set a given bit to 0.
G8RC = ADDIS_TLSGD_HA x2, Symbol - For the general-dynamic TLS model, produces an ADDIS8 instruction ...
Class to represent array types.
This contains information for each constraint that we are lowering.
Simple integer binary arithmetic operators.
MO_NLP_HIDDEN_FLAG - If this bit is set, the symbol reference is to a symbol with hidden visibility...
bool shouldConvertConstantLoadToIntImm(const APInt &Imm, Type *Ty) const override
Returns true if it is beneficial to convert a load of a constant to just the constant itself...
SmallVector< ISD::OutputArg, 32 > Outs
CHAIN = STXVD2X CHAIN, VSRC, Ptr - Occurs only for little endian.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool isLittleEndian() const
Layout endianness...
static SDValue combineBVOfConsecutiveLoads(SDNode *N, SelectionDAG &DAG)
Reduce the number of loads when building a vector.
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
TLSModel::Model getTLSModel(const GlobalValue *GV) const
Returns the TLS model which should be used for the given global variable.
static const MCPhysReg FPR[]
FPR - The set of FP registers that should be allocated for arguments, on Darwin.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc, MachineFunction &MF) const override
getOptimalMemOpType - Returns the target specific optimal type for load and store operations as a res...
op_iterator op_begin() const
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
ArrayRef< SDUse > ops() const
static bool isFloatingPointZero(SDValue Op)
isFloatingPointZero - Return true if this is 0.0 or -0.0.
bool isVMRGLShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize, unsigned ShuffleKind, SelectionDAG &DAG)
isVMRGLShuffleMask - Return true if this is a shuffle mask suitable for a VRGL* instruction with the ...
static void getBaseWithConstantOffset(SDValue Loc, SDValue &Base, int64_t &Offset, SelectionDAG &DAG)
bool isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
bool CC_PPC32_SVR4_Custom_AlignArgRegs(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, ISD::ArgFlagsTy &ArgFlags, CCState &State)
const_iterator end() const
bool isFMAFasterThanFMulAndFAdd(EVT VT) const override
isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster than a pair of fmul and fadd i...
bool hasInvariantFunctionDescriptors() const
amdgpu Simplify well known AMD library false Value * Callee
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
void ReplaceNodeResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
ReplaceNodeResults - Replace the results of node with an illegal result type with new values built ou...
Value * getOperand(unsigned i) const
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
This instruction is lowered in PPCRegisterInfo::eliminateFrameIndex to compute an offset from native ...
unsigned getByValSize() const
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
This class is used to represent ISD::STORE nodes.
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
bool isXXBRWShuffleMask(ShuffleVectorSDNode *N)
isXXBRWShuffleMask - Return true if this is a shuffle mask suitable for a XXBRW instruction.
uint32_t FloatToBits(float Float)
This function takes a float and returns the bit equivalent 32-bit integer.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Flag
These should be considered private to the implementation of the MCInstrDesc class.
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the specified, possibly variable...
TargetInstrInfo - Interface to description of machine instruction set.
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
iterator find(const_arg_type_t< KeyT > Val)
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Get a value with high bits set.
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
void setTailCallSPDelta(int size)
static int getEstimateRefinementSteps(EVT VT, const PPCSubtarget &Subtarget)
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...
VSRC, CHAIN = LXVD2X_LE CHAIN, Ptr - Occurs only for little endian.
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
bool getFunctionSections() const
Return true if functions should be emitted into their own section, corresponding to -ffunction-sectio...
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
const SDValue & getBasePtr() const
A switch()-like statement whose cases are string literals.
virtual const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const
Return a mask of call-preserved registers for the given calling convention on the current function...
SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
int64_t getOffset() const
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const override
Determine which of the bits specified in Mask are known to be either zero or one and return them in t...
static bool isNByteElemShuffleMask(ShuffleVectorSDNode *, unsigned, int)
Check that the mask is shuffling N byte elements.
Control flow instructions. These all have token chains.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static SDValue stripModuloOnShift(const TargetLowering &TLI, SDNode *N, SelectionDAG &DAG)
unsigned const MachineRegisterInfo * MRI
std::size_t countTrailingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the least significant bit to the most stopping at the first 1...
MachineBasicBlock * EmitAtomicBinary(MachineInstr &MI, MachineBasicBlock *MBB, unsigned AtomicSize, unsigned BinOpcode, unsigned CmpOpcode=0, unsigned CmpPred=0) const
MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
FSEL - Traditional three-operand fsel node.
bool shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const
use_iterator use_begin() const
Provide iteration support to walk over all uses of an SDNode.
bool isXXBRQShuffleMask(ShuffleVectorSDNode *N)
isXXBRQShuffleMask - Return true if this is a shuffle mask suitable for a XXBRQ instruction.
LLVM Basic Block Representation.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type...
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
Simple binary floating point operators.
ch, gl = CR6[UN]SET ch, inglue - Toggle CR bit 6 for SVR4 vararg calls
void setTargetDAGCombine(ISD::NodeType NT)
Targets should invoke this method for each target independent node that they want to provide a custom...
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
unsigned getScalarSizeInBits() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
void resetAll()
Resets the known state of all bits.
MO_NLP_FLAG - If this bit is set, the symbol reference is actually to the non_lazy_ptr for the global...
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE...
G8RC = ADDIS_DTPREL_HA x3, Symbol - For the local-dynamic TLS model, produces an ADDIS8 instruction t...
SExtVElems, takes an input vector of a smaller type and sign extends to an output vector of a larger ...
VECINSERT - The PPC vector insert instruction.
Direct move from a VSX register to a GPR.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
static bool is64Bit(const char *name)
const SDValue & getOperand(unsigned Num) const
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL...
CHAIN,FLAG = MTCTR(VAL, CHAIN[, INFLAG]) - Directly corresponds to a MTCTR instruction.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Carry-using nodes for multiple precision addition and subtraction.
static int CalculateTailCallSPDiff(SelectionDAG &DAG, bool isTailCall, unsigned ParamSize)
CalculateTailCallSPDiff - Get the amount the stack pointer has to be adjusted to accommodate the argu...
static ManagedStatic< OptionRegistry > OR
ConstantFP - Floating Point Values [float, double].
unsigned getVSPLTImmediate(SDNode *N, unsigned EltSize, SelectionDAG &DAG)
getVSPLTImmediate - Return the appropriate VSPLT* immediate to splat the specified isSplatShuffleMask...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
virtual unsigned getPrefLoopAlignment(MachineLoop *ML=nullptr) const
Return the preferred loop alignment.
SDValue getCALLSEQ_START(SDValue Chain, uint64_t InSize, uint64_t OutSize, const SDLoc &DL)
Return a new CALLSEQ_START node, that starts new call frame, in which InSize bytes are set up inside ...
static bool isConsecutiveLSLoc(SDValue Loc, EVT VT, LSBaseSDNode *Base, unsigned Bytes, int Dist, SelectionDAG &DAG)
STFIWX - The STFIWX instruction.
ConstraintType getConstraintType(StringRef Constraint) const override
getConstraintType - Given a constraint, return the type of constraint it is for this target...
FCFID - The FCFID instruction, taking an f64 operand and producing and f64 value containing the FP re...
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
bool isAcquireOrStronger(AtomicOrdering ao)
static SDValue GeneratePerfectShuffle(unsigned PFEntry, SDValue LHS, SDValue RHS, SelectionDAG &DAG, const SDLoc &dl)
GeneratePerfectShuffle - Given an entry in the perfect-shuffle table, emit the specified operations t...
bool useLoadStackGuardNode() const override
Override to support customized stack guard loading.
const SDValue & getOffset() const
void AddToWorklist(SDNode *N)
static mvt_range fp_valuetypes()
const PPCFrameLowering * getFrameLowering() const override
static bool haveEfficientBuildVectorPattern(BuildVectorSDNode *V, bool HasDirectMove, bool HasP8Vector)
Do we have an efficient pattern in a .td file for this node?
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static Type * getVoidTy(LLVMContext &C)
Store scalar integers from VSR.
This class provides iterator support for SDUse operands that use a specific SDNode.
static void CalculateTailCallArgDest(SelectionDAG &DAG, MachineFunction &MF, bool isPPC64, SDValue Arg, int SPDiff, unsigned ArgOffset, SmallVectorImpl< TailCallArgumentInfo > &TailCallArguments)
CalculateTailCallArgDest - Remember Argument for later processing.
bool SelectAddressRegImm(SDValue N, SDValue &Disp, SDValue &Base, SelectionDAG &DAG, unsigned Alignment) const
SelectAddressRegImm - Returns true if the address N can be represented by a base register plus a sign...
bool isVPKUWUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind, SelectionDAG &DAG)
isVPKUWUMShuffleMask - Return true if this is the shuffle mask for a VPKUWUM instruction.
INIT_TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
bool any_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
bool isBaseWithConstantOffset(SDValue Op) const
Return true if the specified operand is an ISD::ADD with a ConstantSDNode on the right-hand side...
static SDValue EmitTailCallStoreFPAndRetAddr(SelectionDAG &DAG, SDValue Chain, SDValue OldRetAddr, SDValue OldFP, int SPDiff, const SDLoc &dl)
EmitTailCallStoreFPAndRetAddr - Move the frame pointer and return address to the appropriate stack sl...
void insertCopiesSplitCSR(MachineBasicBlock *Entry, const SmallVectorImpl< MachineBasicBlock *> &Exits) const override
Insert explicit copies in entry and exit blocks.
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
virtual ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &info, const char *constraint) const
Examine constraint string and operand type and determine a weight value.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setVarArgsFrameIndex(int Index)
TRAP - Trapping instruction.
std::string getEVTString() const
This function returns value type as a string, e.g. "i32".
static const MCPhysReg QFPR[]
QFPR - The set of QPX registers that should be allocated for arguments.
unsigned GuaranteedTailCallOpt
GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is specified on the commandline...
CHAIN = CLRBHRB CHAIN - Clear branch history rolling buffer.
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
void setPrefFunctionAlignment(unsigned Align)
Set the target's preferred function alignment.
GPRC, CHAIN = LFIWAX CHAIN, Ptr - This is a floating-point load which sign-extends from a 32-bit inte...
static mvt_range vector_valuetypes()
static bool getVectorCompareInfo(SDValue Intrin, int &CompareOpc, bool &isDot, const PPCSubtarget &Subtarget)
getVectorCompareInfo - Given an intrinsic, return false if it is not a vector comparison.
bool SelectAddressRegRegOnly(SDValue N, SDValue &Base, SDValue &Index, SelectionDAG &DAG) const
SelectAddressRegRegOnly - Given the specified addressed, force it to be represented as an indexed [r+...
G8RC = ADDIS_TLSLD_HA x2, Symbol - For the local-dynamic TLS model, produces an ADDIS8 instruction th...
Optional< StringRef > getSectionPrefix() const
Get the section prefix for this function.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
self_iterator getIterator()
SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, unsigned Align=0, MachineMemOperand::Flags Flags=MachineMemOperand::MOLoad|MachineMemOperand::MOStore, unsigned Size=0)
Creates a MemIntrinsicNode that may produce a result and takes a list of operands.
bool hasNUsesOfValue(unsigned NUses, unsigned Value) const
Return true if there are exactly NUSES uses of the indicated value.
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
G8RC = LD_GOT_TPREL_L Symbol, G8RReg - Used by the initial-exec TLS model, produces a LD instruction ...
QVESPLATI = This corresponds to the QPX qvesplati instruction.
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
void AddPromotedToType(unsigned Opc, MVT OrigVT, MVT DestVT)
If Opc/OrigVT is specified as being promoted, the promotion code defaults to trying a larger integer/...
unsigned NoInfsFPMath
NoInfsFPMath - This flag is enabled when the -enable-no-infs-fp-math flag is specified on the command...
Common code between 32-bit and 64-bit PowerPC targets.
unsigned MaxStoresPerMemmove
Specify maximum bytes of store instructions per memmove call.
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo...
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
int isVSLDOIShuffleMask(SDNode *N, unsigned ShuffleKind, SelectionDAG &DAG)
isVSLDOIShuffleMask - If this is a vsldoi shuffle mask, return the shift amount, otherwise return -1...
std::vector< ArgListEntry > ArgListTy
unsigned getAlignment() const
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
void initializeSplitCSR(MachineBasicBlock *Entry) const override
Perform necessary initialization to handle a subset of CSRs explicitly via copies.
void setMinReservedArea(unsigned size)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool isLittleEndian() const
This structure contains all information that is necessary for lowering calls.
bool isPositionIndependent() const
unsigned getDarwinDirective() const
getDarwinDirective - Returns the -m directive specified for the cpu.
const TargetMachine & getTargetMachine() const
StringRef getSection() const
This class contains a discriminated union of information about pointers in memory operands...
unsigned getNumOperands() const
Return the number of values used by this operation.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
void setUseUnderscoreLongJmp(bool Val)
Indicate whether this target prefers to use _longjmp to implement llvm.longjmp or the version without...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
MachineBasicBlock * emitEHSjLjLongJmp(MachineInstr &MI, MachineBasicBlock *MBB) const
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
static SDValue addShuffleForVecExtend(SDNode *N, SelectionDAG &DAG, SDValue Input, uint64_t Elems, uint64_t CorrectElems)
uint64_t getAlignment() const
Return the minimum known alignment in bytes of the actual memory reference.
bool isXXBRDShuffleMask(ShuffleVectorSDNode *N)
isXXBRDShuffleMask - Return true if this is a shuffle mask suitable for a XXBRD instruction.
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands...
CHAIN,FLAG = BCTRL(CHAIN, ADDR, INFLAG) - The combination of a bctrl instruction and the TOC reload r...
const uint32_t * getNoPreservedMask() const override
SDValue CreateStackTemporary(EVT VT, unsigned minAlign=1)
Create a stack temporary, suitable for holding the specified value type.
bool isUnindexed() const
Return true if this is NOT a pre/post inc/dec load/store.
bool isEXTLoad(const SDNode *N)
Returns true if the specified node is a EXTLOAD.
unsigned getExceptionPointerRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception address on entry to an ...
void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const override
LowerAsmOperandForConstraint - Lower the specified operand into the Ops vector.
GPRC, CHAIN = LXSIZX, CHAIN, Ptr, ByteWidth - This is a load of an integer smaller than 64 bits into ...
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
The memory access writes data.
bool isReleaseOrStronger(AtomicOrdering ao)
Extract a subvector from unsigned integer vector and convert to FP.
SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type...
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
SDValue getTargetConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offset=0, unsigned char TargetFlags=0)
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned char TargetFlags=0)
TokenFactor - This node takes multiple tokens as input and produces a single token result...
QBFLT = Access the underlying QPX floating-point boolean representation.
bool isBuildVectorAllOnes(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR where all of the elements are ~0 or undef...
const PPCRegisterInfo * getRegisterInfo() const override
void addLiveInAttr(unsigned VReg, ISD::ArgFlagsTy Flags)
This function associates attributes for each live-in virtual register.
const TargetLowering & getTargetLoweringInfo() const
Iterator for intrusive lists based on ilist_node.
static bool CalculateStackSlotUsed(EVT ArgVT, EVT OrigVT, ISD::ArgFlagsTy Flags, unsigned PtrByteSize, unsigned LinkageSize, unsigned ParamAreaSize, unsigned &ArgOffset, unsigned &AvailableFPRs, unsigned &AvailableVRs, bool HasQPX)
CalculateStackSlotUsed - Return whether this argument will use its stack slot (instead of being passe...
CCState - This class holds information needed while lowering arguments and return values...
x3 = GET_TLSLD_ADDR x3, Symbol - For the local-dynamic TLS model, produces a call to __tls_get_addr(s...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
This is the shared class of boolean and integer constants.
GPRC = TOC_ENTRY GA, TOC Loads the entry for GA from the TOC, where the TOC base is given by the last...
bool isFPImmLegal(const APFloat &Imm, EVT VT) const override
Returns true if the target can instruction select the specified FP immediate natively.
void setNode(SDNode *N)
set the SDNode
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
SDValue lowerCmpEqZeroToCtlzSrl(SDValue Op, SelectionDAG &DAG) const
static bool needStackSlotPassParameters(const PPCSubtarget &Subtarget, const SmallVectorImpl< ISD::OutputArg > &Outs)
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
bool isJumpTableRelative() const override
EVT getVectorElementType() const
Given a vector type, return the type of each element.
void setIsSplitCSR(bool s)
XXSPLT - The PPC VSX splat instructions.
bool CC_PPC32_SVR4_Custom_Dummy(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, ISD::ArgFlagsTy &ArgFlags, CCState &State)
SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
static bool isConsecutiveLS(SDNode *N, LSBaseSDNode *Base, unsigned Bytes, int Dist, SelectionDAG &DAG)
VECSHL - The PPC vector shift left instruction.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and rounds it to a floating point val...
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...
virtual SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG) const
Returns relocation base for the given PIC jumptable.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
G8RC = ADD_TLS G8RReg, Symbol - Used by the initial-exec TLS model, produces an ADD instruction that ...
Module.h This file contains the declarations for the Module class.
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
Provides information about what library functions are available for the current target.
bool isVector(MCInstrInfo const &MCII, MCInst const &MCI)
CCValAssign - Represent assignment of one arg/retval to a location.
SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
EVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
BRCOND - Conditional branch.
static unsigned CalculateStackSlotSize(EVT ArgVT, ISD::ArgFlagsTy Flags, unsigned PtrByteSize)
CalculateStackSlotSize - Calculates the size reserved for this argument on the stack.
Byte Swap and Counting operators.
static SDValue BuildSplatI(int Val, unsigned SplatSize, EVT VT, SelectionDAG &DAG, const SDLoc &dl)
BuildSplatI - Build a canonical splati of Val with an element size of SplatSize.
static SDValue BuildIntrinsicOp(unsigned IID, SDValue Op, SelectionDAG &DAG, const SDLoc &dl, EVT DestVT=MVT::Other)
BuildIntrinsicOp - Return a unary operator intrinsic node with the specified intrinsic ID...
CHAIN = SC CHAIN, Imm128 - System call.
This is an abstract virtual class for memory operations.
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
const char * getTargetNodeName(unsigned Opcode) const override
getTargetNodeName() - This method returns the name of a target specific DAG node. ...
const Constant * getConstVal() const
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
bool enableAggressiveFMAFusion(EVT VT) const override
Return true if target always beneficiates from combining into FMA for a given value type...
void setHasMultipleConditionRegisters(bool hasManyRegs=true)
Tells the code generator that the target has multiple (allocatable) condition registers that can be u...
x3 = GET_TLS_ADDR x3, Symbol - For the general-dynamic TLS model, produces a call to __tls_get_addr(s...
void insertSSPDeclarations(Module &M) const override
Inserts necessary declarations for SSP (stack protection) purpose.
static SDNode * isBLACompatibleAddress(SDValue Op, SelectionDAG &DAG)
isCallCompatibleAddress - Return the immediate to use if the specified 32-bit value is representable ...
Represents one node in the SelectionDAG.
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
VPERM - The PPC VPERM Instruction.
bool isXXPERMDIShuffleMask(ShuffleVectorSDNode *N, unsigned &ShiftElts, bool &Swap, bool IsLE)
isXXPERMDIShuffleMask - Return true if this is a shuffle mask suitable for a XXPERMDI instruction...
bool hasP8Altivec() const
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
STXSIX - The STXSI[bh]X instruction.
unsigned getMinReservedArea() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static mvt_range integer_valuetypes()
The access may modify the value stored in memory.
i1 = ANDIo_1_[EQ|GT]_BIT(i32 or i64 x) - Represents the result of the eq or gt bit of CR0 after execu...
MachinePointerInfo getWithOffset(int64_t O) const
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
bool isDereferenceable() const
G8RC = ADDIS_GOT_TPREL_HA x2, Symbol - Used by the initial-exec TLS model, produces an ADDIS8 instruc...
Class to represent vector types.
bool hasP9Altivec() const
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...
void setIndexedLoadAction(unsigned IdxMode, MVT VT, LegalizeAction Action)
Indicate that the specified indexed load does or does not work with the specified type and indicate w...
EVT getMemoryVT() const
Return the type of the in-memory value.
Target - Wrapper for Target specific information.
Class for arbitrary precision integers.
unsigned getByValAlign() const
CodeModel::Model getCodeModel() const
Returns the code model.
bool hasRecipPrec() const
SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, bool isTarget=false)
Create a ConstantFPSDNode wrapping a constant value.
QVGPCI = This corresponds to the QPX qvgpci instruction.
iterator_range< use_iterator > uses()
bool isLegalAddImmediate(int64_t Imm) const override
isLegalAddImmediate - Return true if the specified immediate is legal add immediate, that is the target has add instructions which can add a register and the immediate without having to materialize the immediate into a register.
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
A "pseudo-class" with methods for operating on BUILD_VECTORs.
Select(COND, TRUEVAL, FALSEVAL).
void setMinFunctionAlignment(unsigned Align)
Set the target's minimum function alignment (in log2(bytes))
int getVarArgsFrameIndex() const
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
static use_iterator use_end()
void setPrefLoopAlignment(unsigned Align)
Set the target's preferred loop alignment.
ZERO_EXTEND - Used for integer types, zeroing the new bits.
ANY_EXTEND - Used for integer types. The high bits are undefined.
The combination of sra[wd]i and addze used to implemented signed integer division by a power of 2...
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(StringLiteral S, T Value)
static SDValue generateEquivalentSub(SDNode *N, int Size, bool Complement, bool Swap, SDLoc &DL, SelectionDAG &DAG)
This function is called when we have proved that a SETCC node can be replaced by subtraction (and oth...
bool use64BitRegs() const
use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit registers in 32-bit mode when...
iterator insert(iterator I, T &&Elt)
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
int getMaskElt(unsigned Idx) const
bool enableMachineScheduler() const override
amdgpu Simplify well known AMD library false Value Value * Arg
GPRC = address of GLOBAL_OFFSET_TABLE.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
const MCExpr * getPICJumpTableRelocBaseExpr(const MachineFunction *MF, unsigned JTI, MCContext &Ctx) const override
This returns the relocation base for the given PIC jumptable, the same as getPICJumpTableRelocBase, but as an MCExpr.
GET_DYNAMIC_AREA_OFFSET - get offset from native SP to the address of the most recent dynamic alloca...
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
BR_JT - Jumptable branch.
Representation of each machine instruction.
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the source.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
SDValue getStackArgumentTokenFactor(SDValue Chain)
Compute a TokenFactor to force all the incoming stack arguments to be loaded from the stack...
These are IR-level optimization flags that may be propagated to SDNodes.
Represents a use of a SDNode.
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned char TargetFlags=0)
SmallVector< SDValue, 32 > OutVals
GPRC, CHAIN = MFBHRBE CHAIN, Entry, Dummy - Move from branch history rolling buffer entry...
bool CheckReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
CheckReturn - Analyze the return values of a function, returning true if the return can be performed ...
bool isVector() const
Return true if this is a vector value type.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MCPhysReg * getScratchRegisters(CallingConv::ID CC) const override
Returns a 0 terminated array of registers that can be safely used as scratch registers.
Bitwise operators - logical and, logical or, logical xor.
bool isOnlyUserOf(const SDNode *N) const
Return true if this node is the only use of N.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT)
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
unsigned getLocMemOffset() const
Reciprocal estimate instructions (unary FP ops).
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
LLVM_NODISCARD bool empty() const
static bool isFPExtLoad(SDValue Op)
unsigned getMatchingSuperReg(unsigned Reg, unsigned SubIdx, const TargetRegisterClass *RC) const
Return a super-register of the specified register Reg so its sub-register of index SubIdx is Reg...
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
static bool isXXBRShuffleMaskHelper(ShuffleVectorSDNode *N, int Width)
bool isInConsecutiveRegsLast() const
void computeKnownBits(SDValue Op, KnownBits &Known, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
bool isVMRGEOShuffleMask(ShuffleVectorSDNode *N, bool CheckEven, unsigned ShuffleKind, SelectionDAG &DAG)
isVMRGEOShuffleMask - Return true if this is a shuffle mask suitable for a VMRGEW or VMRGOW instructi...
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
bool hasLazyResolverStub(const GlobalValue *GV) const
hasLazyResolverStub - Return true if accesses to the specified global have to go through a dyld lazy ...
bool isFPExtFree(EVT DestVT, EVT SrcVT) const override
Return true if an fpext operation is free (for instance, because single-precision floating-point numb...
F8RC = MFFS - This moves the FPSCR (not modeled) into the register.
PointerUnion< const Value *, const PseudoSourceValue * > ptrVal
Establish a view to a call site for examination.
int64_t getOffset() const
const Function * getParent() const
Return the enclosing method, or null if none.
static MachineOperand CreateImm(int64_t Val)
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values i...
Direct move from a GPR to a VSX register (zero)
static bool callsShareTOCBase(const Function *Caller, SDValue Callee, const TargetMachine &TM)
const TargetSubtargetInfo & getSubtarget() const
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
Flags getFlags() const
Return the raw flags of the source value,.
The CMPB instruction (takes two operands of i32 or i64).
The memory access always returns the same value (or traps).
unsigned MaxStoresPerMemmoveOptSize
Maximum number of store instructions that may be substituted for a call to memmove, used for functions with OptSize attribute.
unsigned MaxStoresPerMemcpyOptSize
Maximum number of store operations that may be substituted for a call to memcpy, used for functions w...
void setStackPointerRegisterToSaveRestore(unsigned R)
If set to a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save and restore.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
CHAIN = STBRX CHAIN, GPRC, Ptr, Type - This is a byte-swapping store instruction. ...
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Return the number of bytes of code the specified instruction may be.
void setLibcallName(RTLIB::Libcall Call, const char *Name)
Rename the default libcall routine name for the specified libcall.
unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Certain targets require unusual breakdowns of certain types.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
block_iterator block_end() const
constexpr int32_t SignExtend32(uint32_t X)
Sign-extend the number in the bottom B bits of X to a 32-bit integer.
static void setUsesTOCBasePtr(MachineFunction &MF)
TC_RETURN - A tail call return.
constexpr char IsConst[]
Key for Kernel::Arg::Metadata::mIsConst.
bool isNON_EXTLoad(const SDNode *N)
Returns true if the specified node is a non-extending load.
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool useCRBits() const
useCRBits - Return true if we should store and manipulate i1 values in the individual condition regis...
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...
unsigned getOpcode() const
FSINCOS - Compute both fsin and fcos as a single operation.
SDValue getValue(unsigned R) const
unsigned MaxStoresPerMemcpy
Specify maximum bytes of store instructions per memcpy call.
constexpr bool isUInt< 16 >(uint64_t x)
bool isDarwin() const
isDarwin - True if this is any darwin platform.
unsigned getNumRegisters(LLVMContext &Context, EVT VT) const
Return the number of registers that this ValueType will eventually require.
static MachinePointerInfo getConstantPool(MachineFunction &MF)
Return a MachinePointerInfo record that refers to the constant pool.
RESULT, OUTCHAIN = EH_SJLJ_SETJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.setjmp intrinsic.
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
static bool isConstantOrUndef(int Op, int Val)
isConstantOrUndef - Op is either an undef node or a ConstantSDNode.
static bool isFunctionGlobalAddress(SDValue Callee)
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
const MachinePointerInfo & getPointerInfo() const
VSRC, CHAIN = XXSWAPD CHAIN, VSRC - Occurs only for little endian.
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
unsigned getLinkageSize() const
getLinkageSize - Return the size of the PowerPC ABI linkage area.
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
XXREVERSE - The PPC VSX reverse instruction.
SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
void insert(iterator MBBI, MachineBasicBlock *MBB)
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
static SDValue combineBVOfVecSExt(SDNode *N, SelectionDAG &DAG)
void setReturnAddressIsTaken(bool s)
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
bool isPredecessorOf(const SDNode *N) const
Return true if this node is a predecessor of N.
void setMinStackArgumentAlignment(unsigned Align)
Set the minimum stack alignment of an argument (in log2(bytes)).
Direct move of 2 consective GPR to a VSX register.
POPCNTDKind hasPOPCNTD() const
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
static MachinePointerInfo getGOT(MachineFunction &MF)
Return a MachinePointerInfo record that refers to a GOT entry.
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override
Return true if folding a constant offset with the given GlobalAddress is legal.
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
ArrayRef< int > getMask() const
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
uint64_t getConstantOperandVal(unsigned Num) const
Helper method returns the integer value of a ConstantSDNode operand.
FMA - Perform a * b + c with no intermediate rounding step.
static void StoreTailCallArgumentsToStackSlot(SelectionDAG &DAG, SDValue Chain, const SmallVectorImpl< TailCallArgumentInfo > &TailCallArgs, SmallVectorImpl< SDValue > &MemOpChains, const SDLoc &dl)
StoreTailCallArgumentsToStackSlot - Stores arguments to their stack slot.
SDValue getRegister(unsigned Reg, EVT VT)
void setUseUnderscoreSetJmp(bool Val)
Indicate whether this target prefers to use _setjmp to implement llvm.setjmp or the version without _...
SDValue getAnyExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either any-extending or truncat...
unsigned getSizeInBits(unsigned Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
bool isTruncateFree(Type *Ty1, Type *Ty2) const override
isTruncateFree - Return true if it's free to truncate a value of type Ty1 to type Ty2...
CHAIN = COND_BRANCH CHAIN, CRRC, OPC, DESTBB [, INFLAG] - This corresponds to the COND_BRANCH pseudo ...
const MDNode * getRanges() const
Returns the Ranges that describes the dereference.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
Instruction * emitTrailingFence(IRBuilder<> &Builder, Instruction *Inst, AtomicOrdering Ord) const override
virtual void insertSSPDeclarations(Module &M) const
Inserts necessary declarations for SSP (stack protection) purpose.
bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
SDValue getSelectCC(const SDLoc &DL, SDValue LHS, SDValue RHS, SDValue True, SDValue False, ISD::CondCode Cond)
Helper function to make it easier to build SelectCC's if you just have an ISD::CondCode instead of an...
SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG) const override
Returns relocation base for the given PIC jumptable.
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
SDValue getValueType(EVT)
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
PREFETCH - This corresponds to a prefetch intrinsic.
static cl::opt< bool > DisableILPPref("disable-ppc-ilp-pref", cl::desc("disable setting the node scheduling preference to ILP on PPC"), cl::Hidden)
bool isNonTemporal() const
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
These nodes represent PPC shifts.
static bool areCallingConvEligibleForTCO_64SVR4(CallingConv::ID CallerCC, CallingConv::ID CalleeCC)
virtual bool shouldExpandBuildVectorWithShuffles(EVT, unsigned DefinedValues) const
void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.getNode() alone...
Primary interface to the complete machine description for the target machine.
PICLevel::Level getPICLevel() const
Returns the PIC level (small or large model)
static void getLabelAccessInfo(bool IsPIC, const PPCSubtarget &Subtarget, unsigned &HiOpFlags, unsigned &LoOpFlags, const GlobalValue *GV=nullptr)
Return true if we should reference labels using a PICBase, set the HiOpFlags and LoOpFlags to the tar...
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
static MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset, uint8_t ID=0)
Stack pointer relative access.
StringRef - Represent a constant reference to a string, i.e.
SetCC operator - This evaluates to a true value iff the condition is true.
static bool isSplat(ArrayRef< Value *> VL)
unsigned MaxStoresPerMemset
Specify maximum number of store instructions per memset call.
unsigned MaxStoresPerMemsetOptSize
Maximum number of stores operations that may be substituted for the call to memset, used for functions with OptSize attribute.
static BranchProbability getZero()
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
unsigned getNumOperands() const
Extract a subvector from signed integer vector and convert to FP.
const SDValue & getOperand(unsigned i) const
bool verifyReturnAddressArgumentIsConstant(SDValue Op, SelectionDAG &DAG) const
OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val) This corresponds to "store atomic" instruction.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
unsigned getLocReg() const
const MachineInstrBuilder & setMemRefs(MachineInstr::mmo_iterator b, MachineInstr::mmo_iterator e) const
uint64_t getZExtValue() const
RESVEC = VCMP(LHS, RHS, OPC) - Represents one of the altivec VCMP* instructions.
TRUNCATE - Completely drop the high bits.
FCTI[D,W]Z - The FCTIDZ and FCTIWZ instructions, taking an f32 or f64 operand, producing an f64 value...
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
Hi/Lo - These represent the high and low 16-bit parts of a global address respectively.
unsigned AllocateReg(unsigned Reg)
AllocateReg - Attempt to allocate one register.
unsigned getLiveInVirtReg(unsigned PReg) const
getLiveInVirtReg - If PReg is a live-in physical register, return the corresponding live-in physical ...
const MachineOperand & getOperand(unsigned i) const
bool isXXBRHShuffleMask(ShuffleVectorSDNode *N)
isXXBRHShuffleMask - Return true if this is a shuffle mask suitable for a XXBRH instruction.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
bool isMustTailCall() const
Tests if this call site must be tail call optimized.
On a symbol operand "FOO", this indicates that the reference is actually to "FOO@plt".
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
unsigned getVarArgsNumFPR() const
FastISel * createFastISel(FunctionLoweringInfo &FuncInfo, const TargetLibraryInfo *LibInfo) const override
createFastISel - This method returns a target-specific FastISel object, or null if the target does no...
block_iterator block_begin() const
FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, FLOG, FLOG2, FLOG10, FEXP, FEXP2, FCEIL, FTRUNC, FRINT, FNEARBYINT, FROUND, FFLOOR - Perform various unary floating point operations.
unsigned getJumpTableEncoding() const override
Return the entry encoding for a jump table in the current function.
F8RC = FADDRTZ F8RC, F8RC - This is an FADD done with rounding towards zero.
An SDNode for swaps that are not associated with any loads/stores and thereby have no chain...
unsigned AllocateStack(unsigned Size, unsigned Align)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
RESVEC, OUTFLAG = VCMPo(LHS, RHS, OPC) - Represents one of the altivec VCMP*o instructions.
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
GPRC, CHAIN = LFIWZX CHAIN, Ptr - This is a floating-point load which zero-extends from a 32-bit inte...
bool isExtended() const
Test if the given EVT is extended (as opposed to being simple).
const SDValue & getBasePtr() const
virtual const MCExpr * getPICJumpTableRelocBaseExpr(const MachineFunction *MF, unsigned JTI, MCContext &Ctx) const
This returns the relocation base for the given PIC jumptable, the same as getPICJumpTableRelocBase, but as an MCExpr.
LLVMContext * getContext() const
bool isIntS16Immediate(SDNode *N, int16_t &Imm)
isIntS16Immediate - This method tests to see if the node is either a 32-bit or 64-bit immediate...
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
static Constant * get(ArrayRef< Constant *> V)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
MO_PIC_FLAG - If this bit is set, the symbol reference is relative to the function's picbase...
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
bool isVMRGHShuffleMask(ShuffleVectorSDNode *N, unsigned UnitSize, unsigned ShuffleKind, SelectionDAG &DAG)
isVMRGHShuffleMask - Return true if this is a shuffle mask suitable for a VRGH* instruction with the ...
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL, bool LegalTypes=true) const
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
static bool hasSameArgumentList(const Function *CallerFn, ImmutableCallSite CS)
static SDValue CreateCopyOfByValArgument(SDValue Src, SDValue Dst, SDValue Chain, ISD::ArgFlagsTy Flags, SelectionDAG &DAG, const SDLoc &dl)
CreateCopyOfByValArgument - Make a copy of an aggregate at address specified by "Src" to address "Dst...
XXPERMDI - The PPC XXPERMDI instruction.
This file describes how to lower LLVM code to machine code.
const BasicBlock * getParent() const
mmo_iterator memoperands_end() const
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned char TargetFlags=0)
void setIndexedStoreAction(unsigned IdxMode, MVT VT, LegalizeAction Action)
Indicate that the specified indexed store does or does not work with the specified type and indicate ...
CallInst * CreateCall(Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
bool isZExtFree(SDValue Val, EVT VT2) const override
Return true if zero-extending the specific node Val to type VT2 is free (either because it's implicit...
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
int isQVALIGNIShuffleMask(SDNode *N)
If this is a qvaligni shuffle mask, return the shift amount, otherwise return -1. ...
MachineBasicBlock * emitPatchPoint(MachineInstr &MI, MachineBasicBlock *MBB) const
Replace/modify any TargetFrameIndex operands with a targte-dependent sequence of memory operands that...
This class is used to represent ISD::LOAD nodes.
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary...
bool useSoftFloat() const override