70 #include "llvm/IR/IntrinsicsPowerPC.h" 102 using namespace llvm;
104 #define DEBUG_TYPE "ppc-lowering" 110 cl::desc(
"disable setting the node scheduling preference to ILP on PPC"),
cl::Hidden);
127 STATISTIC(NumTailCalls,
"Number of tail calls");
128 STATISTIC(NumSiblingCalls,
"Number of sibling calls");
142 bool isPPC64 = Subtarget.
isPPC64();
183 if (!Subtarget.
hasSPE()) {
192 for (
MVT VT : ScalarIntVTs) {
202 if (isPPC64 || Subtarget.
hasFPCVT()) {
208 isPPC64 ? MVT::i64 : MVT::i32);
579 if (VT.getSizeInBits() <= 128 && VT.getScalarSizeInBits() <= 64) {
1288 unsigned MaxMaxAlign) {
1289 if (MaxAlign == MaxMaxAlign)
1291 if (
VectorType *VTy = dyn_cast<VectorType>(Ty)) {
1292 if (MaxMaxAlign >= 32 && VTy->getBitWidth() >= 256)
1294 else if (VTy->getBitWidth() >= 128 && MaxAlign < 16)
1296 }
else if (
ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
1297 unsigned EltAlign = 0;
1299 if (EltAlign > MaxAlign)
1300 MaxAlign = EltAlign;
1301 }
else if (
StructType *STy = dyn_cast<StructType>(Ty)) {
1302 for (
auto *EltTy : STy->elements()) {
1303 unsigned EltAlign = 0;
1305 if (EltAlign > MaxAlign)
1306 MaxAlign = EltAlign;
1307 if (MaxAlign == MaxMaxAlign)
1334 return Subtarget.
hasSPE();
1356 return "PPCISD::FP_TO_UINT_IN_VSR,";
1358 return "PPCISD::FP_TO_SINT_IN_VSR";
1398 return "PPCISD::ANDI_rec_1_EQ_BIT";
1400 return "PPCISD::ANDI_rec_1_GT_BIT";
1416 return "PPCISD::ST_VSR_SCAL_INT";
1488 return CFP->getValueAPF().isZero();
1492 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
CP->getConstVal()))
1493 return CFP->getValueAPF().isZero();
1501 return Op < 0 || Op == Val;
1513 if (ShuffleKind == 0) {
1516 for (
unsigned i = 0; i != 16; ++i)
1519 }
else if (ShuffleKind == 2) {
1522 for (
unsigned i = 0; i != 16; ++i)
1525 }
else if (ShuffleKind == 1) {
1526 unsigned j = IsLE ? 0 : 1;
1527 for (
unsigned i = 0; i != 8; ++i)
1544 if (ShuffleKind == 0) {
1547 for (
unsigned i = 0; i != 16; i += 2)
1551 }
else if (ShuffleKind == 2) {
1554 for (
unsigned i = 0; i != 16; i += 2)
1558 }
else if (ShuffleKind == 1) {
1559 unsigned j = IsLE ? 0 : 2;
1560 for (
unsigned i = 0; i != 8; i += 2)
1586 if (ShuffleKind == 0) {
1589 for (
unsigned i = 0; i != 16; i += 4)
1595 }
else if (ShuffleKind == 2) {
1598 for (
unsigned i = 0; i != 16; i += 4)
1604 }
else if (ShuffleKind == 1) {
1605 unsigned j = IsLE ? 0 : 4;
1606 for (
unsigned i = 0; i != 8; i += 4)
1623 unsigned LHSStart,
unsigned RHSStart) {
1626 assert((UnitSize == 1 || UnitSize == 2 || UnitSize == 4) &&
1627 "Unsupported merge size!");
1629 for (
unsigned i = 0; i != 8/UnitSize; ++i)
1630 for (
unsigned j = 0; j != UnitSize; ++j) {
1632 LHSStart+j+i*UnitSize) ||
1634 RHSStart+j+i*UnitSize))
1649 if (ShuffleKind == 1)
1650 return isVMerge(N, UnitSize, 0, 0);
1651 else if (ShuffleKind == 2)
1652 return isVMerge(N, UnitSize, 0, 16);
1656 if (ShuffleKind == 1)
1657 return isVMerge(N, UnitSize, 8, 8);
1658 else if (ShuffleKind == 0)
1659 return isVMerge(N, UnitSize, 8, 24);
1674 if (ShuffleKind == 1)
1675 return isVMerge(N, UnitSize, 8, 8);
1676 else if (ShuffleKind == 2)
1677 return isVMerge(N, UnitSize, 8, 24);
1681 if (ShuffleKind == 1)
1682 return isVMerge(N, UnitSize, 0, 0);
1683 else if (ShuffleKind == 0)
1684 return isVMerge(N, UnitSize, 0, 16);
1733 unsigned RHSStartValue) {
1737 for (
unsigned i = 0; i < 2; ++i)
1738 for (
unsigned j = 0; j < 4; ++j)
1740 i*RHSStartValue+j+IndexOffset) ||
1742 i*RHSStartValue+j+IndexOffset+8))
1764 unsigned indexOffset = CheckEven ? 4 : 0;
1765 if (ShuffleKind == 1)
1766 return isVMerge(N, indexOffset, 0);
1767 else if (ShuffleKind == 2)
1768 return isVMerge(N, indexOffset, 16);
1773 unsigned indexOffset = CheckEven ? 0 : 4;
1774 if (ShuffleKind == 1)
1775 return isVMerge(N, indexOffset, 0);
1776 else if (ShuffleKind == 0)
1777 return isVMerge(N, indexOffset, 16);
1799 for (i = 0; i != 16 && SVOp->
getMaskElt(i) < 0; ++i)
1802 if (i == 16)
return -1;
1807 if (ShiftAmt < i)
return -1;
1812 if ((ShuffleKind == 0 && !isLE) || (ShuffleKind == 2 && isLE)) {
1814 for (++i; i != 16; ++i)
1817 }
else if (ShuffleKind == 1) {
1819 for (++i; i != 16; ++i)
1826 ShiftAmt = 16 - ShiftAmt;
1836 EltSize <= 8 &&
"Can only handle 1,2,4,8 byte element sizes");
1848 if (ElementBase >= 16)
1853 for (
unsigned i = 1; i != EltSize; ++i)
1857 for (
unsigned i = EltSize,
e = 16; i !=
e; i += EltSize) {
1859 for (
unsigned j = 0; j != EltSize; ++j)
1877 assert((Width == 2 || Width == 4 || Width == 8 || Width == 16) &&
1878 "Unexpected element width.");
1879 assert((StepLen == 1 || StepLen == -1) &&
"Unexpected element width.");
1881 unsigned NumOfElem = 16 /
Width;
1882 unsigned MaskVal[16];
1883 for (
unsigned i = 0; i < NumOfElem; ++i) {
1885 if ((StepLen == 1) && (MaskVal[0] % Width)) {
1887 }
else if ((StepLen == -1) && ((MaskVal[0] + 1) % Width)) {
1891 for (
unsigned int j = 1; j <
Width; ++j) {
1893 if (MaskVal[j] != MaskVal[j-1] + StepLen) {
1903 unsigned &InsertAtByte,
bool &Swap,
bool IsLE) {
1912 unsigned LittleEndianShifts[] = { 2, 1, 0, 3 };
1913 unsigned BigEndianShifts[] = { 3, 0, 1, 2 };
1918 if ((M0 > 3 && M1 == 1 && M2 == 2 && M3 == 3) ||
1919 (M0 < 4 && M1 == 5 && M2 == 6 && M3 == 7)) {
1920 ShiftElts = IsLE ? LittleEndianShifts[M0 & 0x3] : BigEndianShifts[M0 & 0x3];
1921 InsertAtByte = IsLE ? 12 : 0;
1926 if ((M1 > 3 && M0 == 0 && M2 == 2 && M3 == 3) ||
1927 (M1 < 4 && M0 == 4 && M2 == 6 && M3 == 7)) {
1928 ShiftElts = IsLE ? LittleEndianShifts[M1 & 0x3] : BigEndianShifts[M1 & 0x3];
1929 InsertAtByte = IsLE ? 8 : 4;
1934 if ((M2 > 3 && M0 == 0 && M1 == 1 && M3 == 3) ||
1935 (M2 < 4 && M0 == 4 && M1 == 5 && M3 == 7)) {
1936 ShiftElts = IsLE ? LittleEndianShifts[M2 & 0x3] : BigEndianShifts[M2 & 0x3];
1937 InsertAtByte = IsLE ? 4 : 8;
1942 if ((M3 > 3 && M0 == 0 && M1 == 1 && M2 == 2) ||
1943 (M3 < 4 && M0 == 4 && M1 == 5 && M2 == 6)) {
1944 ShiftElts = IsLE ? LittleEndianShifts[M3 & 0x3] : BigEndianShifts[M3 & 0x3];
1945 InsertAtByte = IsLE ? 0 : 12;
1955 unsigned XXINSERTWSrcElem = IsLE ? 2 : 1;
1956 if (M0 == XXINSERTWSrcElem && M1 == 1 && M2 == 2 && M3 == 3) {
1957 InsertAtByte = IsLE ? 12 : 0;
1960 if (M0 == 0 && M1 == XXINSERTWSrcElem && M2 == 2 && M3 == 3) {
1961 InsertAtByte = IsLE ? 8 : 4;
1964 if (M0 == 0 && M1 == 1 && M2 == XXINSERTWSrcElem && M3 == 3) {
1965 InsertAtByte = IsLE ? 4 : 8;
1968 if (M0 == 0 && M1 == 1 && M2 == 2 && M3 == XXINSERTWSrcElem) {
1969 InsertAtByte = IsLE ? 0 : 12;
1978 bool &Swap,
bool IsLE) {
1993 assert(M0 < 4 &&
"Indexing into an undef vector?");
1994 if (M1 != (M0 + 1) % 4 || M2 != (M1 + 1) % 4 || M3 != (M2 + 1) % 4)
1997 ShiftElts = IsLE ? (4 - M0) % 4 : M0;
2003 if (M1 != (M0 + 1) % 8 || M2 != (M1 + 1) % 8 || M3 != (M2 + 1) % 8)
2007 if (M0 == 0 || M0 == 7 || M0 == 6 || M0 == 5) {
2012 ShiftElts = (8 - M0) % 8;
2013 }
else if (M0 == 4 || M0 == 3 || M0 == 2 || M0 == 1) {
2018 ShiftElts = (4 - M0) % 4;
2023 if (M0 == 0 || M0 == 1 || M0 == 2 || M0 == 3) {
2028 }
else if (M0 == 4 || M0 == 5 || M0 == 6 || M0 == 7) {
2045 for (
int i = 0; i < 16; i +=
Width)
2077 bool &Swap,
bool IsLE) {
2086 assert(((M0 | M1) < 4) &&
"A mask element out of bounds?");
2091 if ((M0 | M1) < 2) {
2092 DM = IsLE ? (((~M1) & 1) << 1) + ((~M0) & 1) : (M0 << 1) + (M1 & 1);
2100 if (M0 > 1 && M1 < 2) {
2102 }
else if (M0 < 2 && M1 > 1) {
2110 DM = (((~M1) & 1) << 1) + ((~M0) & 1);
2113 if (M0 < 2 && M1 > 1) {
2115 }
else if (M0 > 1 && M1 < 2) {
2123 DM = (M0 << 1) + (M1 & 1);
2137 return (16 / EltSize) - 1 - (SVOp->
getMaskElt(0) / EltSize);
2154 if (EltSize < ByteSize) {
2155 unsigned Multiple = ByteSize/EltSize;
2157 assert(Multiple > 1 && Multiple <= 4 &&
"How can this happen?");
2165 if (!UniquedVals[i&(Multiple-1)].getNode())
2166 UniquedVals[i&(Multiple-1)] = N->
getOperand(i);
2167 else if (UniquedVals[i&(Multiple-1)] != N->
getOperand(i))
2177 bool LeadingZero =
true;
2178 bool LeadingOnes =
true;
2179 for (
unsigned i = 0; i != Multiple-1; ++i) {
2180 if (!UniquedVals[i].getNode())
continue;
2187 if (!UniquedVals[Multiple-1].getNode())
2189 int Val = cast<ConstantSDNode>(UniquedVals[Multiple-1])->getZExtValue();
2194 if (!UniquedVals[Multiple-1].getNode())
2196 int Val =cast<ConstantSDNode>(UniquedVals[Multiple-1])->getSExtValue();
2215 unsigned ValSizeInBytes = EltSize;
2218 Value = CN->getZExtValue();
2220 assert(CN->getValueType(0) ==
MVT::f32 &&
"Only one legal FP vector type!");
2221 Value =
FloatToBits(CN->getValueAPF().convertToFloat());
2227 if (ValSizeInBytes < ByteSize)
return SDValue();
2231 if (!
APInt(ValSizeInBytes * 8, Value).
isSplat(ByteSize * 8))
2238 if (MaskVal == 0)
return SDValue();
2241 if (SignExtend32<5>(MaskVal) == MaskVal)
2257 for (i = 0; i != 4 && SVOp->
getMaskElt(i) < 0; ++i)
2260 if (i == 4)
return -1;
2265 if (ShiftAmt < i)
return -1;
2269 for (++i; i != 4; ++i)
2285 if (!isa<ConstantSDNode>(N))
2288 Imm = (int16_t)cast<ConstantSDNode>(N)->getZExtValue();
2290 return Imm == (int32_t)cast<ConstantSDNode>(
N)->getZExtValue();
2292 return Imm == (int64_t)cast<ConstantSDNode>(N)->getZExtValue();
2306 if (
MemSDNode *Memop = dyn_cast<MemSDNode>(*UI)) {
2307 if (Memop->getMemoryVT() ==
MVT::f64) {
2325 unsigned EncodingAlignment)
const {
2333 (!EncodingAlignment || !(imm % EncodingAlignment)))
2343 (!EncodingAlignment || !(imm % EncodingAlignment)))
2355 if (~(LHSKnown.
Zero | RHSKnown.
Zero) == 0) {
2413 unsigned EncodingAlignment)
const {
2423 (!EncodingAlignment || (imm % EncodingAlignment) == 0)) {
2435 &&
"Cannot handle constant offsets yet!");
2447 (!EncodingAlignment || (imm % EncodingAlignment) == 0)) {
2457 dyn_cast<FrameIndexSDNode>(N.
getOperand(0))) {
2474 (!EncodingAlignment || (Imm % EncodingAlignment) == 0)) {
2477 CN->getValueType(0));
2482 if ((CN->getValueType(0) ==
MVT::i32 ||
2483 (int64_t)CN->getZExtValue() == (int)CN->getZExtValue()) &&
2484 (!EncodingAlignment || (CN->getZExtValue() % EncodingAlignment) == 0)) {
2485 int Addr = (int)CN->getZExtValue();
2575 if (UI.getUse().get().getResNo() == 0 &&
2596 Ptr =
LD->getBasePtr();
2597 VT =
LD->getMemoryVT();
2598 Alignment =
LD->getAlignment();
2600 Ptr =
ST->getBasePtr();
2601 VT =
ST->getMemoryVT();
2602 Alignment =
ST->getAlignment();
2632 if (isa<FrameIndexSDNode>(Base) || isa<RegisterSDNode>(Base))
2635 SDValue Val = cast<StoreSDNode>(
N)->getValue();
2665 isa<ConstantSDNode>(
Offset))
2680 unsigned &HiOpFlags,
unsigned &LoOpFlags,
2697 if (GV->hasHiddenVisibility()) {
2734 const bool Is64Bit = Subtarget.
isPPC64();
2758 return getTOCEntry(DAG,
SDLoc(CP), GA);
2761 unsigned MOHiFlag, MOLoFlag;
2768 return getTOCEntry(DAG,
SDLoc(CP), GA);
2836 return getTOCEntry(DAG,
SDLoc(JT), GA);
2839 unsigned MOHiFlag, MOLoFlag;
2846 return getTOCEntry(DAG,
SDLoc(GA), GA);
2865 return getTOCEntry(DAG,
SDLoc(BASDN), GA);
2874 unsigned MOHiFlag, MOLoFlag;
2895 bool is64bit = Subtarget.
isPPC64();
2923 PtrVT, GOTReg, TGA);
2933 PtrVT, TGA, GOTPtr);
2970 PtrVT, GOTPtr, TGA, TGA);
2972 PtrVT, TLSAddr, TGA);
2991 return getTOCEntry(DAG, DL, GA);
2994 unsigned MOHiFlag, MOLoFlag;
3002 return getTOCEntry(DAG, DL, GA);
3054 if (
C->isAllOnesValue() ||
C->isNullValue())
3079 const Value *SV = cast<SrcValueSDNode>(Node->
getOperand(2))->getValue();
3120 InChain = OverflowArea.
getValue(1);
3166 InChain = DAG.
getTruncStore(InChain, dl, OverflowArea, OverflowAreaPtr,
3173 assert(!Subtarget.
isPPC64() &&
"LowerVACOPY is PPC32 only");
3203 bool isPPC64 = (PtrVT ==
MVT::i64);
3209 Entry.
Ty = IntPtrTy;
3210 Entry.
Node = Trmp; Args.push_back(Entry);
3215 Args.push_back(Entry);
3217 Entry.
Node = FPtr; Args.push_back(Entry);
3218 Entry.
Node = Nest; Args.push_back(Entry);
3226 std::pair<SDValue, SDValue> CallResult =
LowerCallTo(CLI);
3227 return CallResult.second;
3277 uint64_t FrameOffset = PtrVT.getSizeInBits()/8;
3280 uint64_t
StackOffset = PtrVT.getSizeInBits()/8 - 1;
3283 uint64_t FPROffset = 1;
3292 uint64_t nextOffset = FPROffset;
3300 nextOffset += StackOffset;
3301 nextPtr = DAG.
getNode(
ISD::ADD, dl, PtrVT, nextPtr, ConstStackOffset);
3304 SDValue thirdStore = DAG.
getStore(secondStore, dl, StackOffsetFI, nextPtr,
3306 nextOffset += FrameOffset;
3307 nextPtr = DAG.
getNode(
ISD::ADD, dl, PtrVT, nextPtr, ConstFrameOffset);
3310 return DAG.
getStore(thirdStore, dl, FR, nextPtr,
3316 static const MCPhysReg FPR[] = {PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5,
3317 PPC::F6, PPC::F7, PPC::F8, PPC::F9, PPC::F10,
3318 PPC::F11, PPC::F12, PPC::F13};
3322 PPC::QF1, PPC::QF2, PPC::QF3, PPC::QF4, PPC::QF5, PPC::QF6, PPC::QF7,
3323 PPC::QF8, PPC::QF9, PPC::QF10, PPC::QF11, PPC::QF12, PPC::QF13};
3328 unsigned PtrByteSize) {
3336 ArgSize = ((ArgSize + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
3345 unsigned PtrByteSize) {
3346 unsigned Align = PtrByteSize;
3362 if (BVAlign > PtrByteSize) {
3363 if (BVAlign % PtrByteSize != 0)
3365 "ByVal alignment is not a multiple of the pointer size");
3391 unsigned PtrByteSize,
3392 unsigned LinkageSize,
3393 unsigned ParamAreaSize,
3394 unsigned &ArgOffset,
3395 unsigned &AvailableFPRs,
3396 unsigned &AvailableVRs,
bool HasQPX) {
3397 bool UseMemory =
false;
3402 ArgOffset = ((ArgOffset + Align - 1) / Align) *
Align;
3405 if (ArgOffset >= LinkageSize + ParamAreaSize)
3411 ArgOffset = ((ArgOffset + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
3414 if (ArgOffset > LinkageSize + ParamAreaSize)
3425 if (AvailableFPRs > 0) {
3433 if (AvailableVRs > 0) {
3445 unsigned NumBytes) {
3447 unsigned AlignMask = TargetAlign - 1;
3448 NumBytes = (NumBytes + AlignMask) & ~AlignMask;
3452 SDValue PPCTargetLowering::LowerFormalArguments(
3457 return LowerFormalArguments_AIX(Chain, CallConv, isVarArg, Ins, dl, DAG,
3460 return LowerFormalArguments_64SVR4(Chain, CallConv, isVarArg, Ins, dl, DAG,
3463 return LowerFormalArguments_32SVR4(Chain, CallConv, isVarArg, Ins, dl, DAG,
3466 return LowerFormalArguments_Darwin(Chain, CallConv, isVarArg, Ins, dl, DAG,
3470 SDValue PPCTargetLowering::LowerFormalArguments_32SVR4(
3512 unsigned PtrByteSize = 4;
3521 CCInfo.AllocateStack(LinkageSize, PtrByteSize);
3523 CCInfo.PreAnalyzeFormalArguments(Ins);
3526 CCInfo.clearWasPPCF128();
3528 for (
unsigned i = 0,
e = ArgLocs.
size(); i !=
e; ++i) {
3541 RC = &PPC::GPRCRegClass;
3545 RC = &PPC::VSSRCRegClass;
3546 else if (Subtarget.
hasSPE())
3547 RC = &PPC::GPRCRegClass;
3549 RC = &PPC::F4RCRegClass;
3553 RC = &PPC::VSFRCRegClass;
3554 else if (Subtarget.
hasSPE())
3556 RC = &PPC::GPRCRegClass;
3558 RC = &PPC::F8RCRegClass;
3563 RC = &PPC::VRRCRegClass;
3566 RC = Subtarget.
hasQPX() ? &PPC::QSRCRegClass : &PPC::VRRCRegClass;
3570 RC = &PPC::VRRCRegClass;
3573 RC = &PPC::QFRCRegClass;
3576 RC = &PPC::QBRCRegClass;
3584 assert(i + 1 <
e &&
"No second half of double precision argument");
3586 unsigned RegHi = MF.
addLiveIn(ArgLocs[++i].getLocReg(), RC);
3612 ArgOffset += ArgSize - ObjSize;
3630 CCByValInfo.
AllocateStack(CCInfo.getNextStackOffset(), PtrByteSize);
3635 unsigned MinReservedArea = CCByValInfo.getNextStackOffset();
3636 MinReservedArea =
std::max(MinReservedArea, LinkageSize);
3653 PPC::R7, PPC::R8, PPC::R9, PPC::R10,
3658 PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5, PPC::F6, PPC::F7,
3670 int Depth = NumGPArgRegs * PtrVT.getSizeInBits()/8 +
3675 CCInfo.getNextStackOffset(),
true));
3683 for (
unsigned GPRIndex = 0; GPRIndex != NumGPArgRegs; ++GPRIndex) {
3687 VReg = MF.
addLiveIn(GPArgRegs[GPRIndex], &PPC::GPRCRegClass);
3702 for (
unsigned FPRIndex = 0; FPRIndex != NumFPArgRegs; ++FPRIndex) {
3706 VReg = MF.
addLiveIn(FPArgRegs[FPRIndex], &PPC::F8RCRegClass);
3719 if (!MemOps.
empty())
3730 const SDLoc &dl)
const {
3741 SDValue PPCTargetLowering::LowerFormalArguments_64SVR4(
3754 "fastcc not supported on varargs functions");
3760 unsigned PtrByteSize = 8;
3764 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
3765 PPC::X7, PPC::X8, PPC::X9, PPC::X10,
3769 PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13
3775 const unsigned Num_QFPR_Regs = Num_FPR_Regs;
3783 bool HasParameterArea = !isELFv2ABI || isVarArg;
3784 unsigned ParamAreaSize = Num_GPR_Regs * PtrByteSize;
3785 unsigned NumBytes = LinkageSize;
3786 unsigned AvailableFPRs = Num_FPR_Regs;
3787 unsigned AvailableVRs = Num_VR_Regs;
3788 for (
unsigned i = 0,
e = Ins.
size(); i !=
e; ++i) {
3789 if (Ins[i].Flags.
isNest())
3793 PtrByteSize, LinkageSize, ParamAreaSize,
3794 NumBytes, AvailableFPRs, AvailableVRs,
3796 HasParameterArea =
true;
3803 unsigned ArgOffset = LinkageSize;
3804 unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0;
3805 unsigned &QFPR_idx = FPR_idx;
3808 unsigned CurArgIdx = 0;
3809 for (
unsigned ArgNo = 0,
e = Ins.
size(); ArgNo !=
e; ++ArgNo) {
3811 bool needsLoad =
false;
3812 EVT ObjectVT = Ins[ArgNo].VT;
3813 EVT OrigVT = Ins[ArgNo].ArgVT;
3815 unsigned ArgSize = ObjSize;
3817 if (Ins[ArgNo].isOrigArg()) {
3818 std::advance(FuncArg, Ins[ArgNo].getOrigArgIndex() - CurArgIdx);
3819 CurArgIdx = Ins[ArgNo].getOrigArgIndex();
3824 unsigned CurArgOffset,
Align;
3825 auto ComputeArgOffset = [&]() {
3828 ArgOffset = ((ArgOffset + Align - 1) / Align) *
Align;
3829 CurArgOffset = ArgOffset;
3836 GPR_idx = (ArgOffset - LinkageSize) / PtrByteSize;
3837 GPR_idx = std::min(GPR_idx, Num_GPR_Regs);
3843 assert(Ins[ArgNo].isOrigArg() &&
"Byval arguments cannot be implicit");
3850 ArgSize = ((ObjSize + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
3872 if (HasParameterArea ||
3873 ArgSize + ArgOffset > LinkageSize + Num_GPR_Regs * PtrByteSize)
3880 if (ObjSize < PtrByteSize) {
3884 if (!isLittleEndian) {
3890 if (GPR_idx != Num_GPR_Regs) {
3891 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx++], &PPC::G8RCRegClass);
3896 if (ObjSize==1 || ObjSize==2 || ObjSize==4) {
3913 ArgOffset += PtrByteSize;
3922 for (
unsigned j = 0; j < ArgSize; j += PtrByteSize) {
3923 if (GPR_idx == Num_GPR_Regs)
3926 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::G8RCRegClass);
3939 ArgOffset += ArgSize;
3950 unsigned VReg = MF.
addLiveIn(PPC::X11, &PPC::G8RCRegClass);
3954 ArgVal = extendArgForPPC64(Flags, ObjectVT, DAG, ArgVal, dl);
3962 if (GPR_idx != Num_GPR_Regs) {
3963 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx++], &PPC::G8RCRegClass);
3970 ArgVal = extendArgForPPC64(Flags, ObjectVT, DAG, ArgVal, dl);
3976 ArgSize = PtrByteSize;
3987 if (FPR_idx != Num_FPR_Regs) {
3993 ? &PPC::VSSRCRegClass
3994 : &PPC::F4RCRegClass);
3997 ? &PPC::VSFRCRegClass
3998 : &PPC::F8RCRegClass);
4009 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx++], &PPC::G8RCRegClass);
4014 if ((ArgOffset % PtrByteSize) == (isLittleEndian ? 4 : 0))
4033 ArgOffset += ArgSize;
4035 ArgOffset = ((ArgOffset + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
4046 if (!Subtarget.
hasQPX()) {
4050 if (VR_idx != Num_VR_Regs) {
4051 unsigned VReg = MF.
addLiveIn(VR[VR_idx], &PPC::VRRCRegClass);
4065 "Invalid QPX parameter type");
4073 if (QFPR_idx != Num_QFPR_Regs) {
4076 case MVT::v4f64: RC = &PPC::QFRCRegClass;
break;
4077 case MVT::v4f32: RC = &PPC::QSRCRegClass;
break;
4078 default: RC = &PPC::QBRCRegClass;
break;
4081 unsigned VReg = MF.
addLiveIn(QFPR[QFPR_idx], RC);
4097 if (ObjSize < ArgSize && !isLittleEndian)
4098 CurArgOffset += ArgSize - ObjSize;
4108 unsigned MinReservedArea;
4109 if (HasParameterArea)
4110 MinReservedArea =
std::max(ArgOffset, LinkageSize + 8 * PtrByteSize);
4112 MinReservedArea = LinkageSize;
4125 int Depth = ArgOffset;
4134 for (GPR_idx = (ArgOffset - LinkageSize) / PtrByteSize;
4135 GPR_idx < Num_GPR_Regs; ++GPR_idx) {
4136 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::G8RCRegClass);
4147 if (!MemOps.
empty())
4153 SDValue PPCTargetLowering::LowerFormalArguments_Darwin(
4168 unsigned PtrByteSize = isPPC64 ? 8 : 4;
4170 unsigned ArgOffset = LinkageSize;
4172 unsigned MinReservedArea = ArgOffset;
4176 PPC::R7, PPC::R8, PPC::R9, PPC::R10,
4179 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
4180 PPC::X7, PPC::X8, PPC::X9, PPC::X10,
4184 PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13
4191 unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0;
4202 unsigned VecArgOffset = ArgOffset;
4203 if (!isVarArg && !isPPC64) {
4204 for (
unsigned ArgNo = 0,
e = Ins.
size(); ArgNo !=
e;
4206 EVT ObjectVT = Ins[ArgNo].VT;
4213 ((ObjSize + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
4214 VecArgOffset += ArgSize;
4242 VecArgOffset = ((VecArgOffset+15)/16)*16;
4243 VecArgOffset += 12*16;
4250 unsigned nAltivecParamsAtEnd = 0;
4252 unsigned CurArgIdx = 0;
4253 for (
unsigned ArgNo = 0,
e = Ins.
size(); ArgNo !=
e; ++ArgNo) {
4255 bool needsLoad =
false;
4256 EVT ObjectVT = Ins[ArgNo].VT;
4258 unsigned ArgSize = ObjSize;
4260 if (Ins[ArgNo].isOrigArg()) {
4261 std::advance(FuncArg, Ins[ArgNo].getOrigArgIndex() - CurArgIdx);
4262 CurArgIdx = Ins[ArgNo].getOrigArgIndex();
4264 unsigned CurArgOffset = ArgOffset;
4269 if (isVarArg || isPPC64) {
4270 MinReservedArea = ((MinReservedArea+15)/16)*16;
4274 }
else nAltivecParamsAtEnd++;
4284 assert(Ins[ArgNo].isOrigArg() &&
"Byval arguments cannot be implicit");
4288 ArgSize = ((ObjSize + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
4291 if (ObjSize==1 || ObjSize==2) {
4292 CurArgOffset = CurArgOffset + (4 - ObjSize);
4298 if (ObjSize==1 || ObjSize==2) {
4299 if (GPR_idx != Num_GPR_Regs) {
4302 VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::G8RCRegClass);
4304 VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::GPRCRegClass);
4314 ArgOffset += PtrByteSize;
4318 for (
unsigned j = 0; j < ArgSize; j += PtrByteSize) {
4322 if (GPR_idx != Num_GPR_Regs) {
4325 VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::G8RCRegClass);
4327 VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::GPRCRegClass);
4335 ArgOffset += PtrByteSize;
4337 ArgOffset += ArgSize - (ArgOffset-CurArgOffset);
4349 if (GPR_idx != Num_GPR_Regs) {
4350 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::GPRCRegClass);
4359 ArgSize = PtrByteSize;
4362 ArgOffset += PtrByteSize;
4367 if (GPR_idx != Num_GPR_Regs) {
4368 unsigned VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::G8RCRegClass);
4374 ArgVal = extendArgForPPC64(Flags, ObjectVT, DAG, ArgVal, dl);
4379 ArgSize = PtrByteSize;
4389 if (GPR_idx != Num_GPR_Regs) {
4391 if (ObjSize == 8 && GPR_idx != Num_GPR_Regs && !isPPC64)
4394 if (FPR_idx != Num_FPR_Regs) {
4398 VReg = MF.
addLiveIn(FPR[FPR_idx], &PPC::F4RCRegClass);
4400 VReg = MF.
addLiveIn(FPR[FPR_idx], &PPC::F8RCRegClass);
4409 ArgOffset += isPPC64 ? 8 : ObjSize;
4417 if (VR_idx != Num_VR_Regs) {
4418 unsigned VReg = MF.
addLiveIn(VR[VR_idx], &PPC::VRRCRegClass);
4421 while ((ArgOffset % 16) != 0) {
4422 ArgOffset += PtrByteSize;
4423 if (GPR_idx != Num_GPR_Regs)
4427 GPR_idx = std::min(GPR_idx+4, Num_GPR_Regs);
4431 if (!isVarArg && !isPPC64) {
4433 CurArgOffset = VecArgOffset;
4437 ArgOffset = ((ArgOffset+15)/16)*16;
4438 CurArgOffset = ArgOffset;
4450 CurArgOffset + (ArgSize - ObjSize),
4460 if (nAltivecParamsAtEnd) {
4461 MinReservedArea = ((MinReservedArea+15)/16)*16;
4462 MinReservedArea += 16*nAltivecParamsAtEnd;
4466 MinReservedArea =
std::max(MinReservedArea, LinkageSize + 8 * PtrByteSize);
4479 int Depth = ArgOffset;
4489 for (; GPR_idx != Num_GPR_Regs; ++GPR_idx) {
4493 VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::G8RCRegClass);
4495 VReg = MF.
addLiveIn(GPR[GPR_idx], &PPC::GPRCRegClass);
4507 if (!MemOps.
empty())
4516 unsigned ParamSize) {
4518 if (!isTailCall)
return 0;
4522 int SPDiff = (int)CallerMinReservedArea - (
int)ParamSize;
4524 if (SPDiff < FI->getTailCallSPDelta())
4565 if (
const auto *
F = dyn_cast<Function>(GV)) {
4598 const unsigned PtrByteSize = 8;
4602 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
4603 PPC::X7, PPC::X8, PPC::X9, PPC::X10,
4607 PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13
4611 const unsigned NumFPRs = 13;
4613 const unsigned ParamAreaSize = NumGPRs * PtrByteSize;
4615 unsigned NumBytes = LinkageSize;
4616 unsigned AvailableFPRs = NumFPRs;
4617 unsigned AvailableVRs = NumVRs;
4620 if (Param.Flags.isNest())
continue;
4623 PtrByteSize, LinkageSize, ParamAreaSize,
4624 NumBytes, AvailableFPRs, AvailableVRs,
4640 for (; CalleeArgIter != CalleeArgEnd; ++CalleeArgIter, ++CallerArgIter) {
4641 const Value* CalleeArg = *CalleeArgIter;
4642 const Value* CallerArg = &(*CallerArgIter);
4643 if (CalleeArg == CallerArg)
4651 isa<UndefValue>(CalleeArg))
4669 if (!isTailCallableCC(CallerCC) || !isTailCallableCC(CalleeCC))
4680 PPCTargetLowering::IsEligibleForTailCallOptimization_64SVR4(
4690 if (
DisableSCO && !TailCallOpt)
return false;
4693 if (isVarArg)
return false;
4725 if (Caller.getCallingConv() != CalleeCC &&
4731 !isa<ExternalSymbolSDNode>(Callee))
4761 PPCTargetLowering::IsEligibleForTailCallOptimization(
SDValue Callee,
4777 for (
unsigned i = 0; i != Ins.
size(); i++) {
4779 if (Flags.
isByVal())
return false;
4789 return G->getGlobal()->hasHiddenVisibility()
4790 ||
G->getGlobal()->hasProtectedVisibility();
4800 if (!C)
return nullptr;
4803 if ((Addr & 3) != 0 ||
4804 SignExtend32<26>(Addr) != Addr)
4816 struct TailCallArgumentInfo {
4821 TailCallArgumentInfo() =
default;
4831 for (
unsigned i = 0,
e = TailCallArgs.
size(); i !=
e; ++i) {
4833 SDValue FIN = TailCallArgs[i].FrameIdxOp;
4834 int FI = TailCallArgs[i].FrameIdx;
4837 Chain, dl, Arg, FIN,
4846 int SPDiff,
const SDLoc &dl) {
4852 bool isPPC64 = Subtarget.
isPPC64();
4853 int SlotSize = isPPC64 ? 8 : 4;
4854 int NewRetAddrLoc = SPDiff + FL->getReturnSaveOffset();
4856 NewRetAddrLoc,
true);
4859 Chain = DAG.
getStore(Chain, dl, OldRetAddr, NewRetAddrFrIdx,
4865 int NewFPLoc = SPDiff + FL->getFramePointerSaveOffset();
4869 Chain = DAG.
getStore(Chain, dl, OldFP, NewFramePtrIdx,
4883 int Offset = ArgOffset + SPDiff;
4888 TailCallArgumentInfo
Info;
4890 Info.FrameIdxOp = FIN;
4898 SDValue PPCTargetLowering::EmitTailCallLoadFPAndRetAddr(
4904 LROpOut = getReturnAddrFrameIndex(DAG);
4910 if (Subtarget.isDarwinABI()) {
4911 FPOpOut = getFramePointerFrameIndex(DAG);
4938 SDValue PtrOff,
int SPDiff,
unsigned ArgOffset,
bool isPPC64,
4961 const SDLoc &dl,
int SPDiff,
unsigned NumBytes,
SDValue LROp,
4971 if (!MemOpChains2.
empty())
4991 return G->getGlobal()->getValueType()->isFunctionTy();
4997 SDValue PPCTargetLowering::LowerCallResult(
5011 for (
unsigned i = 0,
e = RVLocs.
size(); i !=
e; ++i) {
5027 if (!Subtarget.isLittleEndian())
5083 bool isTailCall,
const Function &Caller,
5091 if (isIndirectCall) {
5123 .Cases(
"__divdi3",
"__fixunsdfdi",
"__floatundidf",
"__floatundisf",
5124 "__moddi3",
"__udivdi3",
"__umoddi3",
true)
5125 .
Cases(
"ceil",
"floor",
"memcpy",
"memmove",
"memset",
"round",
true)
5136 auto isLocalCallee = [&]() {
5142 !dyn_cast_or_null<GlobalIFunc>(GV);
5156 const auto getAIXFuncEntryPointSymbolSDNode =
5157 [&](
StringRef FuncName,
bool IsDeclaration,
5187 assert(!isa<GlobalIFunc>(GV) &&
"IFunc is not supported on AIX.");
5196 const char *SymName = S->getSymbol();
5208 return getAIXFuncEntryPointSymbolSDNode(
F->getName(),
F->isDeclaration(),
5214 return getAIXFuncEntryPointSymbolSDNode(SymName,
true,
XCOFF::C_EXT);
5227 "Expected a CALLSEQ_STARTSDNode.");
5233 if (LastValue.getValueType() !=
MVT::Glue)
5244 SDValue MTCTROps[] = {Chain, Callee, Glue};
5302 const unsigned Alignment = Subtarget.
isPPC64() ? 8 : 4;
5305 SDValue LoadFuncPtr = DAG.
getLoad(RegVT, dl, LDChain, Callee, MPI,
5306 Alignment, MMOFlags);
5313 DAG.
getLoad(RegVT, dl, LDChain, AddTOC,
5314 MPI.getWithOffset(TOCAnchorOffset), Alignment, MMOFlags);
5320 DAG.
getLoad(RegVT, dl, LDChain, AddPtr,
5321 MPI.getWithOffset(EnvPtrOffset), Alignment, MMOFlags);
5332 "Nest parameter is not supported on AIX.");
5346 const SDLoc &dl,
bool isTailCall,
bool isVarArg,
5348 SmallVector<std::pair<unsigned, SDValue>, 8> &RegsToPass,
5351 const bool IsPPC64 = Subtarget.
isPPC64();
5362 assert(!isPatchPoint &&
"Patch point call are not indirect.");
5398 for (
unsigned i = 0,
e = RegsToPass.size(); i !=
e; ++i)
5400 RegsToPass[i].second.getValueType()));
5416 assert(Mask &&
"Missing call preserved mask for calling convention");
5424 SDValue PPCTargetLowering::FinishCall(
5432 if (Subtarget.is64BitELFABI() || Subtarget.isAIXABI())
5435 const bool isIndirect =
isIndirectCall(Callee, DAG, Subtarget, isPatchPoint);
5436 unsigned CallOpc =
getCallOpcode(isIndirect, isPatchPoint, isTailCall,
5442 else if (Subtarget.usesFunctionDescriptors())
5444 dl, hasNest, Subtarget);
5451 hasNest, DAG, RegsToPass, Glue, Chain, Callee, SPDiff,
5452 Subtarget, isIndirect);
5457 cast<RegisterSDNode>(Callee)->
getReg() == PPC::CTR) ||
5460 isa<ConstantSDNode>(Callee)) &&
5461 "Expecting a global address, external symbol, absolute value or " 5464 "Unexpected call opcode for a tail call.");
5470 Chain = DAG.
getNode(CallOpc, dl, ReturnTypes, Ops);
5486 return LowerCallResult(Chain, Glue, CallConv, isVarArg, Ins, dl, DAG, InVals);
5508 else if (Subtarget.isSVR4ABI() && Subtarget.isPPC64())
5510 IsEligibleForTailCallOptimization_64SVR4(Callee, CallConv, CS,
5511 isVarArg, Outs, Ins, DAG);
5513 isTailCall = IsEligibleForTailCallOptimization(Callee, CallConv, isVarArg,
5520 assert(isa<GlobalAddressSDNode>(Callee) &&
5521 "Callee should be an llvm::Function object.");
5524 cast<GlobalAddressSDNode>(Callee)->getGlobal();
5525 const unsigned Width =
5526 80 - strlen(
"TCO caller: ") - strlen(
", callee linkage: 0, 0");
5527 dbgs() <<
"TCO caller: " 5529 <<
", callee linkage: " << GV->getVisibility() <<
", " 5530 << GV->getLinkage() <<
"\n");
5536 "site marked musttail");
5541 if (Subtarget.useLongCalls() && isa<GlobalAddressSDNode>(Callee) &&
5543 Callee = LowerGlobalAddress(Callee, DAG);
5545 if (Subtarget.isSVR4ABI() && Subtarget.isPPC64())
5546 return LowerCall_64SVR4(Chain, Callee, CallConv, isVarArg,
5547 isTailCall, isPatchPoint, Outs, OutVals, Ins,
5548 dl, DAG, InVals, CS);
5550 if (Subtarget.isSVR4ABI())
5551 return LowerCall_32SVR4(Chain, Callee, CallConv, isVarArg,
5552 isTailCall, isPatchPoint, Outs, OutVals, Ins,
5553 dl, DAG, InVals, CS);
5555 if (Subtarget.isAIXABI())
5556 return LowerCall_AIX(Chain, Callee, CallConv, isVarArg,
5557 isTailCall, isPatchPoint, Outs, OutVals, Ins,
5558 dl, DAG, InVals, CS);
5560 return LowerCall_Darwin(Chain, Callee, CallConv, isVarArg,
5561 isTailCall, isPatchPoint, Outs, OutVals, Ins,
5562 dl, DAG, InVals, CS);
5565 SDValue PPCTargetLowering::LowerCall_32SVR4(
5567 bool isTailCall,
bool isPatchPoint,
5580 unsigned PtrByteSize = 4;
5602 CCInfo.
AllocateStack(Subtarget.getFrameLowering()->getLinkageSize(),
5605 CCInfo.PreAnalyzeCallOperands(Outs);
5611 unsigned NumArgs = Outs.
size();
5613 for (
unsigned i = 0; i != NumArgs; ++i) {
5614 MVT ArgVT = Outs[i].VT;
5618 if (Outs[i].IsFixed) {
5628 errs() <<
"Call operand #" << i <<
" has unhandled type " 5638 CCInfo.clearWasPPCF128();
5645 CCByValInfo.
AllocateStack(CCInfo.getNextStackOffset(), PtrByteSize);
5652 unsigned NumBytes = CCByValInfo.getNextStackOffset();
5666 Chain = EmitTailCallLoadFPAndRetAddr(DAG, SPDiff, Chain, LROp, FPOp, dl);
5677 bool seenFloatArg =
false;
5682 for (
unsigned i = 0, RealArgIdx = 0, j = 0,
e = ArgLocs.
size();
5684 ++i, ++RealArgIdx) {
5694 assert((j < ByValArgLocs.
size()) &&
"Index out of bounds!");
5713 SDValue NewCallSeqStart = DAG.getCALLSEQ_START(MemcpyCall, NumBytes, 0,
5715 DAG.ReplaceAllUsesWith(CallSeqStart.
getNode(),
5716 NewCallSeqStart.getNode());
5717 Chain = CallSeqStart = NewCallSeqStart;
5737 bool IsLE = Subtarget.isLittleEndian();
5743 RegsToPass.
push_back(std::make_pair(ArgLocs[++i].getLocReg(),
5767 if (!MemOpChains.
empty())
5773 for (
unsigned i = 0,
e = RegsToPass.
size(); i !=
e; ++i) {
5775 RegsToPass[i].
second, InFlag);
5783 SDValue Ops[] = { Chain, InFlag };
5795 return FinishCall(CallConv, dl, isTailCall, isVarArg, isPatchPoint,
5797 RegsToPass, InFlag, Chain, CallSeqStart, Callee, SPDiff,
5798 NumBytes, Ins, InVals, CS);
5803 SDValue PPCTargetLowering::createMemcpyOutsideCallSeq(
5811 SDValue NewCallSeqStart = DAG.getCALLSEQ_START(MemcpyCall, FrameSize, 0,
5813 DAG.ReplaceAllUsesWith(CallSeqStart.
getNode(),
5815 return NewCallSeqStart;
5818 SDValue PPCTargetLowering::LowerCall_64SVR4(
5820 bool isTailCall,
bool isPatchPoint,
5826 bool isELFv2ABI = Subtarget.isELFv2ABI();
5827 bool isLittleEndian = Subtarget.isLittleEndian();
5828 unsigned NumOps = Outs.
size();
5829 bool hasNest =
false;
5830 bool IsSibCall =
false;
5833 unsigned PtrByteSize = 8;
5850 "fastcc not supported on varargs functions");
5856 unsigned LinkageSize = Subtarget.getFrameLowering()->getLinkageSize();
5857 unsigned NumBytes = LinkageSize;
5858 unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0;
5859 unsigned &QFPR_idx = FPR_idx;
5862 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
5863 PPC::X7, PPC::X8, PPC::X9, PPC::X10,
5867 PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13
5873 const unsigned NumQFPRs = NumFPRs;
5879 bool HasParameterArea = !isELFv2ABI || isVarArg || CallConv ==
CallingConv::Fast;
5880 if (!HasParameterArea) {
5881 unsigned ParamAreaSize = NumGPRs * PtrByteSize;
5882 unsigned AvailableFPRs = NumFPRs;
5883 unsigned AvailableVRs = NumVRs;
5884 unsigned NumBytesTmp = NumBytes;
5885 for (
unsigned i = 0; i != NumOps; ++i) {
5886 if (Outs[i].Flags.
isNest())
continue;
5888 PtrByteSize, LinkageSize, ParamAreaSize,
5889 NumBytesTmp, AvailableFPRs, AvailableVRs,
5890 Subtarget.hasQPX()))
5891 HasParameterArea =
true;
5897 unsigned NumGPRsUsed = 0, NumFPRsUsed = 0, NumVRsUsed = 0;
5902 HasParameterArea =
false;
5905 for (
unsigned i = 0; i != NumOps; ++i) {
5907 EVT ArgVT = Outs[i].VT;
5908 EVT OrigVT = Outs[i].ArgVT;
5916 if (NumGPRsUsed > NumGPRs)
5917 HasParameterArea =
true;
5924 if (++NumGPRsUsed <= NumGPRs)
5934 if (++NumVRsUsed <= NumVRs)
5940 if (Subtarget.hasQPX()) {
5941 if (++NumFPRsUsed <= NumFPRs)
5944 if (++NumVRsUsed <= NumVRs)
5952 if (++NumFPRsUsed <= NumFPRs)
5956 HasParameterArea =
true;
5963 NumBytes = ((NumBytes + Align - 1) / Align) *
Align;
5967 NumBytes = ((NumBytes + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
5970 unsigned NumBytesActuallyUsed = NumBytes;
5980 if (HasParameterArea)
5981 NumBytes =
std::max(NumBytes, LinkageSize + 8 * PtrByteSize);
5983 NumBytes = LinkageSize;
6011 Chain = EmitTailCallLoadFPAndRetAddr(DAG, SPDiff, Chain, LROp, FPOp, dl);
6022 unsigned ArgOffset = LinkageSize;
6028 for (
unsigned i = 0; i != NumOps; ++i) {
6031 EVT ArgVT = Outs[i].VT;
6032 EVT OrigVT = Outs[i].ArgVT;
6041 auto ComputePtrOff = [&]() {
6045 ArgOffset = ((ArgOffset + Align - 1) / Align) *
Align;
6056 GPR_idx = (ArgOffset - LinkageSize) / PtrByteSize;
6057 GPR_idx = std::min(GPR_idx, NumGPRs);
6087 if (Size==1 || Size==2 || Size==4) {
6089 if (GPR_idx != NumGPRs) {
6093 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6095 ArgOffset += PtrByteSize;
6100 if (GPR_idx == NumGPRs && Size < 8) {
6102 if (!isLittleEndian) {
6107 Chain = CallSeqStart = createMemcpyOutsideCallSeq(Arg, AddPtr,
6110 ArgOffset += PtrByteSize;
6127 Chain = CallSeqStart = createMemcpyOutsideCallSeq(Arg, PtrOff,
6132 if (Size < 8 && GPR_idx != NumGPRs) {
6142 if (!isLittleEndian) {
6146 Chain = CallSeqStart = createMemcpyOutsideCallSeq(Arg, AddPtr,
6154 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6157 ArgOffset += PtrByteSize;
6163 for (
unsigned j=0; j<
Size; j+=PtrByteSize) {
6166 if (GPR_idx != NumGPRs) {
6170 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6171 ArgOffset += PtrByteSize;
6173 ArgOffset += ((Size - j + PtrByteSize-1)/PtrByteSize)*PtrByteSize;
6187 RegsToPass.
push_back(std::make_pair(PPC::X11, Arg));
6195 if (GPR_idx != NumGPRs) {
6196 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Arg));
6201 assert(HasParameterArea &&
6202 "Parameter area must exist to pass an argument in memory.");
6204 true, isTailCall,
false, MemOpChains,
6205 TailCallArguments, dl);
6207 ArgOffset += PtrByteSize;
6210 ArgOffset += PtrByteSize;
6223 bool NeedGPROrStack = isVarArg || FPR_idx == NumFPRs;
6224 bool NeededLoad =
false;
6227 if (FPR_idx != NumFPRs)
6228 RegsToPass.
push_back(std::make_pair(FPR[FPR_idx++], Arg));
6231 if (!NeedGPROrStack)
6253 }
else if (ArgOffset % PtrByteSize != 0) {
6257 if (!isLittleEndian)
6265 if (!isLittleEndian)
6275 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], ArgVal));
6288 assert(HasParameterArea &&
6289 "Parameter area must exist to pass an argument in memory.");
6291 true, isTailCall,
false, MemOpChains,
6292 TailCallArguments, dl);
6303 ArgOffset = ((ArgOffset + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
6315 if (!Subtarget.hasQPX()) {
6325 assert(HasParameterArea &&
6326 "Parameter area must exist if we have a varargs call.");
6332 if (VR_idx != NumVRs) {
6336 RegsToPass.
push_back(std::make_pair(VR[VR_idx++], Load));
6339 for (
unsigned i=0; i<16; i+=PtrByteSize) {
6340 if (GPR_idx == NumGPRs)
6347 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6353 if (VR_idx != NumVRs) {
6354 RegsToPass.
push_back(std::make_pair(VR[VR_idx++], Arg));
6359 assert(HasParameterArea &&
6360 "Parameter area must exist to pass an argument in memory.");
6362 true, isTailCall,
true, MemOpChains,
6363 TailCallArguments, dl);
6374 "Invalid QPX parameter type");
6381 assert(HasParameterArea &&
6382 "Parameter area must exist if we have a varargs call.");
6388 if (QFPR_idx != NumQFPRs) {
6392 RegsToPass.
push_back(std::make_pair(QFPR[QFPR_idx++], Load));
6394 ArgOffset += (IsF32 ? 16 : 32);
6395 for (
unsigned i = 0; i < (IsF32 ? 16U : 32U); i += PtrByteSize) {
6396 if (GPR_idx == NumGPRs)
6403 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6409 if (QFPR_idx != NumQFPRs) {
6410 RegsToPass.
push_back(std::make_pair(QFPR[QFPR_idx++], Arg));
6415 assert(HasParameterArea &&
6416 "Parameter area must exist to pass an argument in memory.");
6418 true, isTailCall,
true, MemOpChains,
6419 TailCallArguments, dl);
6421 ArgOffset += (IsF32 ? 16 : 32);
6425 ArgOffset += (IsF32 ? 16 : 32);
6431 assert((!HasParameterArea || NumBytesActuallyUsed == ArgOffset) &&
6432 "mismatch in size of parameter area");
6433 (void)NumBytesActuallyUsed;
6435 if (!MemOpChains.
empty())
6441 if (!isTailCall && !isPatchPoint &&
6443 !isa<ExternalSymbolSDNode>(Callee)) {
6448 unsigned TOCSaveOffset = Subtarget.getFrameLowering()->getTOCSaveOffset();
6457 if (isELFv2ABI && !isPatchPoint)
6458 RegsToPass.
push_back(std::make_pair((
unsigned)PPC::X12, Callee));
6464 for (
unsigned i = 0,
e = RegsToPass.
size(); i !=
e; ++i) {
6466 RegsToPass[i].
second, InFlag);
6470 if (isTailCall && !IsSibCall)
6474 return FinishCall(CallConv, dl, isTailCall, isVarArg, isPatchPoint, hasNest,
6475 DAG, RegsToPass, InFlag, Chain, CallSeqStart, Callee,
6476 SPDiff, NumBytes, Ins, InVals, CS);
6479 SDValue PPCTargetLowering::LowerCall_Darwin(
6481 bool isTailCall,
bool isPatchPoint,
6487 unsigned NumOps = Outs.
size();
6491 unsigned PtrByteSize = isPPC64 ? 8 : 4;
6507 unsigned LinkageSize = Subtarget.getFrameLowering()->getLinkageSize();
6508 unsigned NumBytes = LinkageSize;
6516 unsigned nAltivecParamsAtEnd = 0;
6517 for (
unsigned i = 0; i != NumOps; ++i) {
6519 EVT ArgVT = Outs[i].VT;
6524 if (!isVarArg && !isPPC64) {
6527 nAltivecParamsAtEnd++;
6531 NumBytes = ((NumBytes+15)/16)*16;
6537 if (nAltivecParamsAtEnd) {
6538 NumBytes = ((NumBytes+15)/16)*16;
6539 NumBytes += 16*nAltivecParamsAtEnd;
6547 NumBytes =
std::max(NumBytes, LinkageSize + 8 * PtrByteSize);
6571 Chain = EmitTailCallLoadFPAndRetAddr(DAG, SPDiff, Chain, LROp, FPOp, dl);
6586 unsigned ArgOffset = LinkageSize;
6587 unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0;
6591 PPC::R7, PPC::R8, PPC::R9, PPC::R10,
6594 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
6595 PPC::X7, PPC::X8, PPC::X9, PPC::X10,
6599 PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13
6602 const unsigned NumFPRs = 13;
6611 for (
unsigned i = 0; i != NumOps; ++i) {
6637 if (Size==1 || Size==2) {
6639 if (GPR_idx != NumGPRs) {
6643 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6645 ArgOffset += PtrByteSize;
6650 Chain = CallSeqStart = createMemcpyOutsideCallSeq(Arg, AddPtr,
6653 ArgOffset += PtrByteSize;
6660 Chain = CallSeqStart = createMemcpyOutsideCallSeq(Arg, PtrOff,
6667 for (
unsigned j=0; j<
Size; j+=PtrByteSize) {
6670 if (GPR_idx != NumGPRs) {
6674 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6675 ArgOffset += PtrByteSize;
6677 ArgOffset += ((Size - j + PtrByteSize-1)/PtrByteSize)*PtrByteSize;
6689 if (GPR_idx != NumGPRs) {
6693 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Arg));
6696 isPPC64, isTailCall,
false, MemOpChains,
6697 TailCallArguments, dl);
6699 ArgOffset += PtrByteSize;
6703 if (FPR_idx != NumFPRs) {
6704 RegsToPass.
push_back(std::make_pair(FPR[FPR_idx++], Arg));
6712 if (GPR_idx != NumGPRs) {
6716 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6724 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6730 if (GPR_idx != NumGPRs)
6738 isPPC64, isTailCall,
false, MemOpChains,
6739 TailCallArguments, dl);
6755 while (ArgOffset % 16 !=0) {
6756 ArgOffset += PtrByteSize;
6757 if (GPR_idx != NumGPRs)
6767 if (VR_idx != NumVRs) {
6771 RegsToPass.
push_back(std::make_pair(VR[VR_idx++], Load));
6774 for (
unsigned i=0; i<16; i+=PtrByteSize) {
6775 if (GPR_idx == NumGPRs)
6782 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6789 if (VR_idx != NumVRs) {
6791 RegsToPass.
push_back(std::make_pair(VR[VR_idx++], Arg));
6792 }
else if (nAltivecParamsAtEnd==0) {
6795 isPPC64, isTailCall,
true, MemOpChains,
6796 TailCallArguments, dl);
6807 if (!isVarArg && nAltivecParamsAtEnd > NumVRs) {
6810 ArgOffset = ((ArgOffset+15)/16)*16;
6812 for (
unsigned i = 0; i != NumOps; ++i) {
6814 EVT ArgType = Outs[i].VT;
6821 isPPC64, isTailCall,
true, MemOpChains,
6822 TailCallArguments, dl);
6829 if (!MemOpChains.
empty())
6837 !isa<ExternalSymbolSDNode>(Callee) &&
6839 RegsToPass.
push_back(std::make_pair((
unsigned)(isPPC64 ? PPC::X12 :
6840 PPC::R12), Callee));
6845 for (
unsigned i = 0,
e = RegsToPass.
size(); i !=
e; ++i) {
6847 RegsToPass[i].
second, InFlag);
6855 return FinishCall(CallConv, dl, isTailCall, isVarArg, isPatchPoint,
6857 RegsToPass, InFlag, Chain, CallSeqStart, Callee, SPDiff,
6858 NumBytes, Ins, InVals, CS);
6879 const bool IsPPC64 = Subtarget.
isPPC64();
6880 const unsigned PtrByteSize = IsPPC64 ? 8 : 4;
6884 PPC::R7, PPC::R8, PPC::R9, PPC::R10};
6886 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
6887 PPC::X7, PPC::X8, PPC::X9, PPC::X10};
6895 assert(IsPPC64 &&
"PPC32 should have split i64 values.");
6900 if (
unsigned Reg = State.
AllocateReg(IsPPC64 ? GPR_64 : GPR_32)) {
6904 LocInfo = ArgFlags.
isSExt() ? CCValAssign::LocInfo::SExt
6905 : CCValAssign::LocInfo::ZExt;
6929 for (
unsigned I = 0;
I < StoreSize;
I += PtrByteSize) {
6930 if (
unsigned Reg = State.
AllocateReg(IsPPC64 ? GPR_64 : GPR_32)) {
6953 "i64 should have been split for 32-bit codegen.");
6961 return IsPPC64 ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
6963 return &PPC::F4RCRegClass;
6965 return &PPC::F8RCRegClass;
6985 SDValue PPCTargetLowering::LowerFormalArguments_AIX(
6992 "Unexpected calling convention!");
7008 const bool IsPPC64 = Subtarget.
isPPC64();
7009 const unsigned PtrByteSize = IsPPC64 ? 8 : 4;
7019 const unsigned MinParameterSaveArea = 8 * PtrByteSize;
7020 CCInfo.AllocateStack(LinkageSize + MinParameterSaveArea, PtrByteSize);
7021 CCInfo.AnalyzeFormalArguments(Ins,
CC_AIX);
7023 for (
unsigned i = 0,
e = ArgLocs.
size(); i !=
e; ++i) {
7047 unsigned MinReservedArea = CCInfo.getNextStackOffset();
7061 SDValue PPCTargetLowering::LowerCall_AIX(
7063 bool isTailCall,
bool isPatchPoint,
7093 const bool IsPPC64 = Subtarget.
isPPC64();
7094 const unsigned PtrByteSize = IsPPC64 ? 8 : 4;
7095 CCInfo.AllocateStack(LinkageSize, PtrByteSize);
7096 CCInfo.AnalyzeCallOperands(Outs,
CC_AIX);
7104 const unsigned MinParameterSaveAreaSize = 8 * PtrByteSize;
7105 const unsigned NumBytes = LinkageSize + MinParameterSaveAreaSize;
7114 for (
unsigned I = 0,
E = ArgLocs.
size();
I !=
E;) {
7122 "Unexpected non-register location for function call argument.");
7148 "Unexpected custom register handling for calling convention.");
7165 "Unexpected custom register for argument!");
7171 assert(
I !=
E &&
"A second custom GPR is expected!");
7174 GPR2.
needsCustom() &&
"A second custom GPR is expected!");
7182 if (!isTailCall && !isPatchPoint &&
7187 const unsigned TOCSaveOffset =
7203 for (
auto Reg : RegsToPass) {
7208 const int SPDiff = 0;
7209 return FinishCall(CallConv, dl, isTailCall, isVarArg, isPatchPoint,
7210 false, DAG, RegsToPass,
7211 InFlag, Chain, CallSeqStart, Callee, SPDiff, NumBytes, Ins,
7221 CCState CCInfo(CallConv, isVarArg, MF, RVLocs, Context);
7246 for (
unsigned i = 0, RealResIdx = 0; i != RVLocs.
size(); ++i, ++RealResIdx) {
7250 SDValue Arg = OutVals[RealResIdx];
7266 bool isLittleEndian = Subtarget.isLittleEndian();
7290 if (PPC::G8RCRegClass.
contains(*I))
7292 else if (PPC::F8RCRegClass.
contains(*I))
7294 else if (PPC::CRRCRegClass.
contains(*I))
7296 else if (PPC::VRRCRegClass.
contains(*I))
7313 PPCTargetLowering::LowerGET_DYNAMIC_AREA_OFFSET(
SDValue Op,
7322 SDValue FPSIdx = getFramePointerFrameIndex(DAG);
7324 SDValue Ops[2] = {Chain, FPSIdx};
7338 bool isPPC64 = Subtarget.isPPC64();
7339 unsigned SP = isPPC64 ? PPC::X1 : PPC::R1;
7359 bool isPPC64 = Subtarget.isPPC64();
7370 int LROffset = Subtarget.getFrameLowering()->getReturnSaveOffset();
7374 FI->setReturnAddrSaveIndex(RASI);
7380 PPCTargetLowering::getFramePointerFrameIndex(
SelectionDAG & DAG)
const {
7382 bool isPPC64 = Subtarget.isPPC64();
7393 int FPOffset = Subtarget.getFrameLowering()->getFramePointerSaveOffset();
7397 FI->setFramePointerSaveIndex(FPSI);
7415 SDValue FPSIdx = getFramePointerFrameIndex(DAG);
7417 SDValue Ops[3] = { Chain, NegSize, FPSIdx };
7426 bool isPPC64 = Subtarget.isPPC64();
7450 return LowerVectorLoad(Op, DAG);
7453 "Custom lowering only for i1 loads");
7475 return LowerVectorStore(Op, DAG);
7478 "Custom lowering only for i1 stores");
7498 "Custom lowering only for i1 results");
7531 assert(SrcSize <= 128 &&
"Source must fit in an Altivec/VSX vector");
7543 if (Subtarget.isLittleEndian())
7544 for (
unsigned i = 0; i < TrgNumElts; ++i)
7547 for (
unsigned i = 1; i <= TrgNumElts; ++i)
7551 for (
unsigned i = TrgNumElts; i < WideNumElts; ++i)
7574 if (!Subtarget.hasP9Vector() && (!HasNoInfs || !HasNoNaNs))
7584 if (Subtarget.hasP9Vector() && LHS == TV && RHS == FV) {
7588 if (HasNoInfs && HasNoNaNs)
7686 void PPCTargetLowering::LowerFP_TO_INTForReuse(
SDValue Op, ReuseLoadInfo &RLI,
7688 const SDLoc &dl)
const {
7691 if (Src.getValueType() ==
MVT::f32)
7706 "i64 FP_TO_UINT is supported only with FPCVT");
7717 int FI = cast<FrameIndexSDNode>(FIPtr)->getIndex();
7738 MPI = MPI.
getWithOffset(Subtarget.isLittleEndian() ? 0 : 4);
7751 const SDLoc &dl)
const {
7755 if (Src.getValueType() ==
MVT::f32)
7771 "i64 FP_TO_UINT is supported only with FPCVT");
7782 const SDLoc &dl)
const {
7807 const uint64_t TwoE31[] = {0x41e0000000000000LL, 0};
7828 if (Subtarget.hasDirectMove() && Subtarget.isPPC64())
7829 return LowerFP_TO_INTDirectMove(Op, DAG, dl);
7832 LowerFP_TO_INTForReuse(Op, RLI, DAG, dl);
7835 RLI.Alignment, RLI.MMOFlags(), RLI.AAInfo, RLI.Ranges);
7846 bool PPCTargetLowering::canReuseLoadAddress(
SDValue Op,
EVT MemVT,
7857 LowerFP_TO_INTForReuse(Op, RLI, DAG, dl);
7871 "Non-pre-inc AM on PPC?");
7892 void PPCTargetLowering::spliceIntoChain(
SDValue ResChain,
7898 SDLoc dl(NewResChain);
7903 "A new TF really is required here");
7912 bool PPCTargetLowering::directMoveIsProfitable(
const SDValue &Op)
const {
7920 if (!Subtarget.hasP9Vector() && MMO->
getSize() <= 2)
7928 if (UI.getUse().get().getResNo() != 0)
7944 const SDLoc &dl)
const {
7947 "Invalid floating point type as target of conversion");
7948 assert(Subtarget.hasFPCVT() &&
7949 "Int to FP conversions with direct moves require FPCVT");
7985 for (
unsigned i = 1; i < NumConcat; ++i)
7992 const SDLoc &dl)
const {
7996 "Unexpected conversion type");
7998 "Supports conversions to v2f64/v4f32 only.");
8009 for (
unsigned i = 0; i < WideNumElts; ++i)
8012 int Stride = FourEltRes ? WideNumElts / 4 : WideNumElts / 2;
8013 int SaveElts = FourEltRes ? 4 : 2;
8014 if (Subtarget.isLittleEndian())
8015 for (
int i = 0; i < SaveElts; i++)
8016 ShuffV[i * Stride] = i;
8018 for (
int i = 1; i <= SaveElts; i++)
8019 ShuffV[i * Stride - 1] = i - 1;
8028 if (!Subtarget.hasP9Altivec() && SignedConv) {
8029 Arrange = DAG.
getBitcast(IntermediateVT, Arrange);
8033 Extend = DAG.
getNode(ExtendOp, dl, IntermediateVT, Arrange);
8046 return LowerINT_TO_FPVector(Op, DAG, dl);
8084 if (Subtarget.hasDirectMove() && directMoveIsProfitable(Op) &&
8085 Subtarget.isPPC64() && Subtarget.hasFPCVT())
8086 return LowerINT_TO_FPDirectMove(Op, DAG, dl);
8089 "UINT_TO_FP is supported only with FPCVT");
8115 !Subtarget.hasFPCVT() &&
8154 if (canReuseLoadAddress(SINT,
MVT::i64, RLI, DAG)) {
8156 RLI.Alignment, RLI.MMOFlags(), RLI.AAInfo, RLI.Ranges);
8157 spliceIntoChain(RLI.ResChain, Bits.
getValue(1), DAG);
8158 }
else if (Subtarget.hasLFIWAX() &&
8162 RLI.Alignment, RLI.AAInfo, RLI.Ranges);
8163 SDValue Ops[] = { RLI.Chain, RLI.Ptr };
8167 spliceIntoChain(RLI.ResChain, Bits.
getValue(1), DAG);
8168 }
else if (Subtarget.hasFPCVT() &&
8172 RLI.Alignment, RLI.AAInfo, RLI.Ranges);
8173 SDValue Ops[] = { RLI.Chain, RLI.Ptr };
8177 spliceIntoChain(RLI.ResChain, Bits.
getValue(1), DAG);
8178 }
else if (((Subtarget.hasLFIWAX() &&
8180 (Subtarget.hasFPCVT() &&
8195 "Expected an i32 store");
8205 RLI.Alignment, RLI.AAInfo, RLI.Ranges);
8206 SDValue Ops[] = { RLI.Chain, RLI.Ptr };
8223 "Unhandled INT_TO_FP type in custom expander!");
8233 if (Subtarget.hasLFIWAX() || Subtarget.hasFPCVT()) {
8247 "Expected an i32 store");
8258 RLI.Alignment, RLI.AAInfo, RLI.Ranges);
8259 SDValue Ops[] = { RLI.Chain, RLI.Ptr };
8265 spliceIntoChain(RLI.ResChain, Ld.getValue(1), DAG);
8267 assert(Subtarget.isPPC64() &&
8268 "i32->FP without LFIWAX supported only on PPC64");
8383 SDValue OutOps[] = { OutLo, OutHi };
8412 SDValue OutOps[] = { OutLo, OutHi };
8441 SDValue OutOps[] = { OutLo, OutHi };
8453 static const MVT VTys[] = {
8463 EVT CanonicalVT = VTys[SplatSize-1];
8507 for (
unsigned i = 0; i != 16; ++i)
8535 bool IsSplat =
true;
8536 bool IsLoad =
false;
8563 return !(IsSplat && IsLoad);
8604 assert(BVN &&
"Expected a BuildVectorSDNode in LowerBUILD_VECTOR");
8618 "BUILD_VECTOR for v4i1 does not have 4 operands");
8621 for (
unsigned i = 0; i < 4; ++i) {
8623 if (!isa<ConstantSDNode>(BVN->
getOperand(i))) {
8636 for (
unsigned i = 0; i < 4; ++i) {
8657 for (
unsigned i = 0; i < 4; ++i) {
8665 if (StoreSize > 4) {
8680 if (!Stores.
empty())
8707 if (Subtarget.hasQPX())
8711 APInt APSplatBits, APSplatUndef;
8712 unsigned SplatBitSize;
8715 HasAnyUndefs, 0, !Subtarget.isLittleEndian()) ||
8716 SplatBitSize > 32) {
8730 if (InputLoad->getNode()->hasNUsesOfValue(128 / ElementSize, 0) &&
8731 ((Subtarget.hasVSX() && ElementSize == 64) ||
8732 (Subtarget.hasP9Vector() && ElementSize == 32))) {
8748 if (Subtarget.hasVSX() &&
8750 Subtarget.hasP8Vector()))
8757 unsigned SplatSize = SplatBitSize / 8;
8762 if (SplatBits == 0) {
8774 if (Subtarget.hasP9Vector() && SplatSize == 1)
8778 int32_t SextVal= (int32_t(SplatBits << (32-SplatBitSize)) >>
8780 if (SextVal >= -16 && SextVal <= 15)
8792 if (SextVal >= -32 && SextVal <= 31) {
8810 if (SplatSize == 4 && SplatBits == (0x7FFFFFFF&~SplatUndef)) {
8824 static const signed char SplatCsts[] = {
8825 -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7,
8826 -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, 14, -14, 15, -15, -16
8832 int i = SplatCsts[idx];
8836 unsigned TypeShiftAmt = i & (SplatBitSize-1);
8839 if (SextVal == (
int)((
unsigned)i << TypeShiftAmt)) {
8841 static const unsigned IIDs[] = {
8842 Intrinsic::ppc_altivec_vslb, Intrinsic::ppc_altivec_vslh, 0,
8843 Intrinsic::ppc_altivec_vslw
8850 if (SextVal == (
int)((
unsigned)i >> TypeShiftAmt)) {
8852 static const unsigned IIDs[] = {
8853 Intrinsic::ppc_altivec_vsrb, Intrinsic::ppc_altivec_vsrh, 0,
8854 Intrinsic::ppc_altivec_vsrw
8861 if (SextVal == (
int)((
unsigned)i >> TypeShiftAmt)) {
8863 static const unsigned IIDs[] = {
8864 Intrinsic::ppc_altivec_vsrab, Intrinsic::ppc_altivec_vsrah, 0,
8865 Intrinsic::ppc_altivec_vsraw
8872 if (SextVal == (
int)(((
unsigned)i << TypeShiftAmt) |
8873 ((
unsigned)i >> (SplatBitSize-TypeShiftAmt)))) {
8875 static const unsigned IIDs[] = {
8876 Intrinsic::ppc_altivec_vrlb, Intrinsic::ppc_altivec_vrlh, 0,
8877 Intrinsic::ppc_altivec_vrlw
8884 if (SextVal == (
int)(((
unsigned)i << 8) | (i < 0 ? 0xFF : 0))) {
8886 unsigned Amt = Subtarget.isLittleEndian() ? 15 : 1;
8890 if (SextVal == (
int)(((
unsigned)i << 16) | (i < 0 ? 0xFFFF : 0))) {
8892 unsigned Amt = Subtarget.isLittleEndian() ? 14 : 2;
8896 if (SextVal == (
int)(((
unsigned)i << 24) | (i < 0 ? 0xFFFFFF : 0))) {
8898 unsigned Amt = Subtarget.isLittleEndian() ? 13 : 3;
8911 unsigned OpNum = (PFEntry >> 26) & 0x0F;
8912 unsigned LHSID = (PFEntry >> 13) & ((1 << 13)-1);
8913 unsigned RHSID = (PFEntry >> 0) & ((1 << 13)-1);
8929 if (LHSID == (1*9+2)*9+3)
return LHS;
8930 assert(LHSID == ((4*9+5)*9+6)*9+7 &&
"Illegal OP_COPY!");
8942 ShufIdxs[ 0] = 0; ShufIdxs[ 1] = 1; ShufIdxs[ 2] = 2; ShufIdxs[ 3] = 3;
8943 ShufIdxs[ 4] = 16; ShufIdxs[ 5] = 17; ShufIdxs[ 6] = 18; ShufIdxs[ 7] = 19;
8944 ShufIdxs[ 8] = 4; ShufIdxs[ 9] = 5; ShufIdxs[10] = 6; ShufIdxs[11] = 7;
8945 ShufIdxs[12] = 20; ShufIdxs[13] = 21; ShufIdxs[14] = 22; ShufIdxs[15] = 23;
8948 ShufIdxs[ 0] = 8; ShufIdxs[ 1] = 9; ShufIdxs[ 2] = 10; ShufIdxs[ 3] = 11;
8949 ShufIdxs[ 4] = 24; ShufIdxs[ 5] = 25; ShufIdxs[ 6] = 26; ShufIdxs[ 7] = 27;
8950 ShufIdxs[ 8] = 12; ShufIdxs[ 9] = 13; ShufIdxs[10] = 14; ShufIdxs[11] = 15;
8951 ShufIdxs[12] = 28; ShufIdxs[13] = 29; ShufIdxs[14] = 30; ShufIdxs[15] = 31;
8954 for (
unsigned i = 0; i != 16; ++i)
8955 ShufIdxs[i] = (i&3)+0;
8958 for (
unsigned i = 0; i != 16; ++i)
8959 ShufIdxs[i] = (i&3)+4;
8962 for (
unsigned i = 0; i != 16; ++i)
8963 ShufIdxs[i] = (i&3)+8;
8966 for (
unsigned i = 0; i != 16; ++i)
8967 ShufIdxs[i] = (i&3)+12;
8988 const unsigned BytesInVector = 16;
8989 bool IsLE = Subtarget.isLittleEndian();
8993 unsigned ShiftElts = 0, InsertAtByte = 0;
8997 unsigned LittleEndianShifts[] = {8, 7, 6, 5, 4, 3, 2, 1,
8998 0, 15, 14, 13, 12, 11, 10, 9};
8999 unsigned BigEndianShifts[] = {9, 10, 11, 12, 13, 14, 15, 0,
9000 1, 2, 3, 4, 5, 6, 7, 8};
9003 int OriginalOrder[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
9015 bool FoundCandidate =
false;
9019 unsigned VINSERTBSrcElem = IsLE ? 8 : 7;
9022 for (
unsigned i = 0; i < BytesInVector; ++i) {
9023 unsigned CurrentElement = Mask[i];
9026 if (V2.
isUndef() && CurrentElement != VINSERTBSrcElem)
9029 bool OtherElementsInOrder =
true;
9032 for (
unsigned j = 0; j < BytesInVector; ++j) {
9039 (!V2.
isUndef() && CurrentElement < BytesInVector) ? BytesInVector : 0;
9040 if (Mask[j] != OriginalOrder[j] + MaskOffset) {
9041 OtherElementsInOrder =
false;
9048 if (OtherElementsInOrder) {
9055 ShiftElts = IsLE ? LittleEndianShifts[CurrentElement & 0xF]
9056 : BigEndianShifts[CurrentElement & 0xF];
9057 Swap = CurrentElement < BytesInVector;
9059 InsertAtByte = IsLE ? BytesInVector - (i + 1) : i;
9060 FoundCandidate =
true;
9065 if (!FoundCandidate)
9089 const unsigned NumHalfWords = 8;
9090 const unsigned BytesInVector = NumHalfWords * 2;
9095 bool IsLE = Subtarget.isLittleEndian();
9099 unsigned ShiftElts = 0, InsertAtByte = 0;
9103 unsigned LittleEndianShifts[] = {4, 3, 2, 1, 0, 7, 6, 5};
9104 unsigned BigEndianShifts[] = {5, 6, 7, 0, 1, 2, 3, 4};
9107 uint32_t OriginalOrderLow = 0x1234567;
9108 uint32_t OriginalOrderHigh = 0x89ABCDEF;
9111 for (
unsigned i = 0; i < NumHalfWords; ++i) {
9112 unsigned MaskShift = (NumHalfWords - 1 - i) * 4;
9129 bool FoundCandidate =
false;
9132 for (
unsigned i = 0; i < NumHalfWords; ++i) {
9133 unsigned MaskShift = (NumHalfWords - 1 - i) * 4;
9134 uint32_t MaskOneElt = (Mask >> MaskShift) & 0xF;
9135 uint32_t MaskOtherElts = ~(0xF << MaskShift);
9143 unsigned VINSERTHSrcElem = IsLE ? 4 : 3;
9144 TargetOrder = OriginalOrderLow;
9148 if (MaskOneElt == VINSERTHSrcElem &&
9149 (Mask & MaskOtherElts) == (TargetOrder & MaskOtherElts)) {
9150 InsertAtByte = IsLE ? BytesInVector - (i + 1) * 2 : i * 2;
9151 FoundCandidate =
true;
9157 (MaskOneElt < NumHalfWords) ? OriginalOrderHigh : OriginalOrderLow;
9159 if ((Mask & MaskOtherElts) == (TargetOrder & MaskOtherElts)) {
9161 ShiftElts = IsLE ? LittleEndianShifts[MaskOneElt & 0x7]
9162 : BigEndianShifts[MaskOneElt & 0x7];
9163 InsertAtByte = IsLE ? BytesInVector - (i + 1) * 2 : i * 2;
9164 Swap = MaskOneElt < NumHalfWords;
9165 FoundCandidate =
true;
9171 if (!FoundCandidate)
9207 bool isLittleEndian = Subtarget.isLittleEndian();
9209 unsigned ShiftElts, InsertAtByte;
9216 if (InputLoad && Subtarget.hasVSX() && V2.
isUndef() &&
9225 if ((IsFourByte && Subtarget.hasP9Vector()) || !IsFourByte) {
9228 Offset = isLittleEndian ? (3 - SplatIdx) * 4 : SplatIdx * 4;
9230 Offset = isLittleEndian ? (1 - SplatIdx) * 8 : SplatIdx * 8;
9250 if (Subtarget.hasP9Vector() &&
9269 if (Subtarget.hasP9Altivec()) {
9271 if ((NewISDNode = lowerToVINSERTH(SVOp, DAG)))
9274 if ((NewISDNode = lowerToVINSERTB(SVOp, DAG)))
9278 if (Subtarget.hasVSX() &&
9291 if (Subtarget.hasVSX() &&
9304 if (Subtarget.hasP9Vector()) {
9324 if (Subtarget.hasVSX()) {
9342 if (Subtarget.hasQPX()) {
9343 if (VT.getVectorNumElements() != 4)
9349 if (AlignIdx != -1) {
9354 if (SplatIdx >= 4) {
9367 for (
unsigned i = 0; i < 4; ++i) {
9369 unsigned mm = m >= 0 ? (
unsigned) m : i;
9370 idx |= mm << (3-i)*3;
9394 (Subtarget.hasP8Altivec() && (
9405 unsigned int ShuffleKind = isLittleEndian ? 2 : 0;
9415 (Subtarget.hasP8Altivec() && (
9425 unsigned PFIndexes[4];
9426 bool isFourElementShuffle =
true;
9427 for (
unsigned i = 0; i != 4 && isFourElementShuffle; ++i) {
9429 for (
unsigned j = 0; j != 4; ++j) {
9430 if (PermMask[i*4+j] < 0)
9433 unsigned ByteSource = PermMask[i*4+j];
9434 if ((ByteSource & 3) != j) {
9435 isFourElementShuffle =
false;
9440 EltNo = ByteSource/4;
9441 }
else if (EltNo != ByteSource/4) {
9442 isFourElementShuffle =
false;
9446 PFIndexes[i] = EltNo;
9454 if (isFourElementShuffle && !isLittleEndian) {
9456 unsigned PFTableIndex =
9457 PFIndexes[0]*9*9*9+PFIndexes[1]*9*9+PFIndexes[2]*9+PFIndexes[3];
9460 unsigned Cost = (PFEntry >> 30);
9492 for (
unsigned i = 0,
e = VT.getVectorNumElements(); i !=
e; ++i) {
9493 unsigned SrcElt = PermMask[i] < 0 ? 0 : PermMask[i];
9495 for (
unsigned j = 0; j != BytesPerElement; ++j)
9518 unsigned IntrinsicID =
9519 cast<ConstantSDNode>(Intrin.
getOperand(0))->getZExtValue();
9522 switch (IntrinsicID) {
9526 case Intrinsic::ppc_altivec_vcmpbfp_p:
9530 case Intrinsic::ppc_altivec_vcmpeqfp_p:
9534 case Intrinsic::ppc_altivec_vcmpequb_p:
9538 case Intrinsic::ppc_altivec_vcmpequh_p:
9542 case Intrinsic::ppc_altivec_vcmpequw_p:
9546 case Intrinsic::ppc_altivec_vcmpequd_p:
9553 case Intrinsic::ppc_altivec_vcmpneb_p:
9554 case Intrinsic::ppc_altivec_vcmpneh_p:
9555 case Intrinsic::ppc_altivec_vcmpnew_p:
9556 case Intrinsic::ppc_altivec_vcmpnezb_p:
9557 case Intrinsic::ppc_altivec_vcmpnezh_p:
9558 case Intrinsic::ppc_altivec_vcmpnezw_p:
9560 switch (IntrinsicID) {
9563 case Intrinsic::ppc_altivec_vcmpneb_p:
9566 case Intrinsic::ppc_altivec_vcmpneh_p:
9569 case Intrinsic::ppc_altivec_vcmpnew_p:
9572 case Intrinsic::ppc_altivec_vcmpnezb_p:
9575 case Intrinsic::ppc_altivec_vcmpnezh_p:
9578 case Intrinsic::ppc_altivec_vcmpnezw_p:
9586 case Intrinsic::ppc_altivec_vcmpgefp_p:
9590 case Intrinsic::ppc_altivec_vcmpgtfp_p:
9594 case Intrinsic::ppc_altivec_vcmpgtsb_p:
9598 case Intrinsic::ppc_altivec_vcmpgtsh_p:
9602 case Intrinsic::ppc_altivec_vcmpgtsw_p:
9606 case Intrinsic::ppc_altivec_vcmpgtsd_p:
9613 case Intrinsic::ppc_altivec_vcmpgtub_p:
9617 case Intrinsic::ppc_altivec_vcmpgtuh_p:
9621 case Intrinsic::ppc_altivec_vcmpgtuw_p:
9625 case Intrinsic::ppc_altivec_vcmpgtud_p:
9634 case Intrinsic::ppc_vsx_xvcmpeqdp_p:
9635 case Intrinsic::ppc_vsx_xvcmpgedp_p:
9636 case Intrinsic::ppc_vsx_xvcmpgtdp_p:
9637 case Intrinsic::ppc_vsx_xvcmpeqsp_p:
9638 case Intrinsic::ppc_vsx_xvcmpgesp_p:
9639 case Intrinsic::ppc_vsx_xvcmpgtsp_p:
9640 if (Subtarget.
hasVSX()) {
9641 switch (IntrinsicID) {
9642 case Intrinsic::ppc_vsx_xvcmpeqdp_p:
9645 case Intrinsic::ppc_vsx_xvcmpgedp_p:
9648 case Intrinsic::ppc_vsx_xvcmpgtdp_p:
9651 case Intrinsic::ppc_vsx_xvcmpeqsp_p:
9654 case Intrinsic::ppc_vsx_xvcmpgesp_p:
9657 case Intrinsic::ppc_vsx_xvcmpgtsp_p:
9667 case Intrinsic::ppc_altivec_vcmpbfp:
9670 case Intrinsic::ppc_altivec_vcmpeqfp:
9673 case Intrinsic::ppc_altivec_vcmpequb:
9676 case Intrinsic::ppc_altivec_vcmpequh:
9679 case Intrinsic::ppc_altivec_vcmpequw:
9682 case Intrinsic::ppc_altivec_vcmpequd:
9688 case Intrinsic::ppc_altivec_vcmpneb:
9689 case Intrinsic::ppc_altivec_vcmpneh:
9690 case Intrinsic::ppc_altivec_vcmpnew:
9691 case Intrinsic::ppc_altivec_vcmpnezb:
9692 case Intrinsic::ppc_altivec_vcmpnezh:
9693 case Intrinsic::ppc_altivec_vcmpnezw:
9695 switch (IntrinsicID) {
9698 case Intrinsic::ppc_altivec_vcmpneb:
9701 case Intrinsic::ppc_altivec_vcmpneh:
9704 case Intrinsic::ppc_altivec_vcmpnew:
9707 case Intrinsic::ppc_altivec_vcmpnezb:
9710 case Intrinsic::ppc_altivec_vcmpnezh:
9713 case Intrinsic::ppc_altivec_vcmpnezw:
9720 case Intrinsic::ppc_altivec_vcmpgefp:
9723 case Intrinsic::ppc_altivec_vcmpgtfp:
9726 case Intrinsic::ppc_altivec_vcmpgtsb:
9729 case Intrinsic::ppc_altivec_vcmpgtsh:
9732 case Intrinsic::ppc_altivec_vcmpgtsw:
9735 case Intrinsic::ppc_altivec_vcmpgtsd:
9741 case Intrinsic::ppc_altivec_vcmpgtub:
9744 case Intrinsic::ppc_altivec_vcmpgtuh:
9747 case Intrinsic::ppc_altivec_vcmpgtuw:
9750 case Intrinsic::ppc_altivec_vcmpgtud:
9764 unsigned IntrinsicID =
9765 cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
9769 if (IntrinsicID == Intrinsic::thread_pointer) {
9771 if (Subtarget.isPPC64())
9809 switch (cast<ConstantSDNode>(Op.
getOperand(1))->getZExtValue()) {
9812 BitNo = 0; InvertBit =
false;
9815 BitNo = 0; InvertBit =
true;
9818 BitNo = 2; InvertBit =
false;
9821 BitNo = 2; InvertBit =
true;
9843 int ArgStart = isa<ConstantSDNode>(Op.
getOperand(0)) ? 0 : 1;
9845 switch (cast<ConstantSDNode>(Op.
getOperand(ArgStart))->getZExtValue()) {
9846 case Intrinsic::ppc_cfence: {
9847 assert(ArgStart == 1 &&
"llvm.ppc.cfence must carry a chain argument.");
9848 assert(Subtarget.isPPC64() &&
"Only 64-bit is supported for now.");
9882 int VectorIndex = 0;
9883 if (Subtarget.isLittleEndian())
9895 "Expecting an atomic compare-and-swap here.");
9897 auto *AtomicNode = cast<AtomicSDNode>(Op.
getNode());
9898 EVT MemVT = AtomicNode->getMemoryVT();
9899 if (MemVT.getSizeInBits() >= 32)
9909 unsigned MaskVal = (1 << MemVT.getSizeInBits()) - 1;
9916 for (
int i = 0,
e = AtomicNode->getNumOperands(); i <
e; i++)
9917 Ops.
push_back(AtomicNode->getOperand(i));
9945 "Should only be called for ISD::INSERT_VECTOR_ELT");
9960 unsigned InsertAtElement = C->getZExtValue();
9961 unsigned InsertAtByte = InsertAtElement * BytesInEachElement;
9962 if (Subtarget.isLittleEndian()) {
9963 InsertAtByte = (16 - BytesInEachElement) - InsertAtByte;
9977 "Unknown extract_vector_elt type");
10017 unsigned Offset = 4*cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue();
10024 if (!Subtarget.useCRBits())
10051 SDValue Vals[4], LoadChains[4];
10052 for (
unsigned Idx = 0; Idx < 4; ++Idx) {
10054 if (ScalarVT != ScalarMemVT)
10058 ScalarMemVT,
MinAlign(Alignment, Idx * Stride),
10061 Load = DAG.
getLoad(ScalarVT, dl, LoadChain, BasePtr,
10063 MinAlign(Alignment, Idx * Stride),
10068 "Unknown addressing mode on vector load");
10074 LoadChains[Idx] = Load.
getValue(1);
10078 BasePtr.getValueType()));
10099 SDValue VectElmts[4], VectElmtChains[4];
10100 for (
unsigned i = 0; i < 4; ++i) {
10108 VectElmtChains[i] = VectElmts[i].
getValue(1);
10141 for (
unsigned Idx = 0; Idx < 4; ++Idx) {
10146 if (ScalarVT != ScalarMemVT)
10150 ScalarMemVT,
MinAlign(Alignment, Idx * Stride),
10153 Store = DAG.
getStore(StoreChain, dl, Ex, BasePtr,
10155 MinAlign(Alignment, Idx * Stride),
10160 "Unknown addressing mode on vector store");
10168 Stores[Idx] =
Store;
10216 SDValue Loads[4], LoadChains[4];
10217 for (
unsigned i = 0; i < 4; ++i) {
10224 LoadChains[i] = Loads[i].
getValue(1);
10230 for (
unsigned i = 0; i < 4; ++i) {
10278 LHS, RHS, Zero, DAG, dl);
10281 bool isLittleEndian = Subtarget.isLittleEndian();
10298 for (
unsigned i = 0; i != 8; ++i) {
10299 if (isLittleEndian) {
10301 Ops[i*2+1] = 2*i+16;
10304 Ops[i*2+1] = 2*i+1+16;
10307 if (isLittleEndian)
10322 "Only set vector abs as custom, scalar abs shouldn't reach here!");
10325 "Unexpected vector element type!");
10327 "Current subtarget doesn't support smax v2i64!");
10345 BifID = Intrinsic::ppc_altivec_vmaxsd;
10347 BifID = Intrinsic::ppc_altivec_vmaxsh;
10349 BifID = Intrinsic::ppc_altivec_vmaxsb;
10358 "Should only be called for ISD::FP_EXTEND");
10374 "Node should have 2 operands with second one being a constant!");
10380 int Idx = cast<ConstantSDNode>(Op0.
getOperand(1))->getZExtValue();
10386 int DWord = Idx >> 1;
10389 if (Subtarget.isLittleEndian())
10440 case ISD::SETCC:
return LowerSETCC(Op, DAG);
10446 case ISD::VAARG:
return LowerVAARG(Op, DAG);
10452 return LowerGET_DYNAMIC_AREA_OFFSET(Op, DAG);
10459 case ISD::LOAD:
return LowerLOAD(Op, DAG);
10460 case ISD::STORE:
return LowerSTORE(Op, DAG);
10481 case ISD::MUL:
return LowerMUL(Op, DAG);
10482 case ISD::ABS:
return LowerABS(Op, DAG);
10495 return LowerINTRINSIC_VOID(Op, DAG);
10498 return LowerREM(Op, DAG);
10500 return LowerBSWAP(Op, DAG);
10502 return LowerATOMIC_CMP_SWAP(Op, DAG);
10512 llvm_unreachable(
"Do not know how to custom type legalize this operation!");
10523 if (cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue() !=
10524 Intrinsic::loop_decrement)
10528 "Unexpected result type for CTR decrement intrinsic");
10540 if (!Subtarget.isSVR4ABI() || Subtarget.isPPC64())
10605 if (isa<LoadInst>(Inst) && Subtarget.isPPC64())
10609 Intrinsic::ppc_cfence, {Inst->
getType()}),
10619 unsigned AtomicSize,
10620 unsigned BinOpcode,
10621 unsigned CmpOpcode,
10622 unsigned CmpPred)
const {
10626 auto LoadMnemonic = PPC::LDARX;
10627 auto StoreMnemonic = PPC::STDCX;
10628 switch (AtomicSize) {
10632 LoadMnemonic = PPC::LBARX;
10633 StoreMnemonic = PPC::STBCX;
10634 assert(Subtarget.hasPartwordAtomics() &&
"Call this only with size >=4");
10637 LoadMnemonic = PPC::LHARX;
10638 StoreMnemonic = PPC::STHCX;
10639 assert(Subtarget.hasPartwordAtomics() &&
"Call this only with size >=4");
10642 LoadMnemonic = PPC::LWARX;
10643 StoreMnemonic = PPC::STWCX;
10646 LoadMnemonic = PPC::LDARX;
10647 StoreMnemonic = PPC::STDCX;
10667 F->
insert(It, loop2MBB);
10674 Register TmpReg = (!BinOpcode) ? incr :
10676 : &PPC::GPRCRegClass);
10701 BuildMI(BB, dl, TII->
get(LoadMnemonic), dest)
10702 .addReg(ptrA).
addReg(ptrB);
10707 if (CmpOpcode == PPC::CMPW && AtomicSize < 4) {
10709 BuildMI(BB, dl, TII->
get(AtomicSize == 1 ? PPC::EXTSB : PPC::EXTSH),
10710 ExtReg).addReg(dest);
10711 BuildMI(BB, dl, TII->
get(CmpOpcode), PPC::CR0)
10712 .addReg(incr).
addReg(ExtReg);
10714 BuildMI(BB, dl, TII->
get(CmpOpcode), PPC::CR0)
10715 .addReg(incr).
addReg(dest);
10739 unsigned BinOpcode,
unsigned CmpOpcode,
unsigned CmpPred)
const {
10741 if (Subtarget.hasPartwordAtomics())
10751 bool is64bit = Subtarget.isPPC64();
10752 bool isLittleEndian = Subtarget.isLittleEndian();
10753 unsigned ZeroReg = is64bit ? PPC::ZERO8 : PPC::ZERO;
10771 F->
insert(It, loop2MBB);
10779 is64bit ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
10822 if (ptrA != ZeroReg) {
10824 BuildMI(BB, dl, TII->
get(is64bit ? PPC::ADD8 : PPC::ADD4), Ptr1Reg)
10832 BuildMI(BB, dl, TII->
get(PPC::RLWINM), Shift1Reg)
10833 .addReg(Ptr1Reg, 0, is64bit ? PPC::sub_32 : 0)
10836 .
addImm(is8bit ? 28 : 27);
10837 if (!isLittleEndian)
10838 BuildMI(BB, dl, TII->
get(PPC::XORI), ShiftReg)
10840 .
addImm(is8bit ? 24 : 16);
10842 BuildMI(BB, dl, TII->
get(PPC::RLDICR), PtrReg)
10847 BuildMI(BB, dl, TII->
get(PPC::RLWINM), PtrReg)
10852 BuildMI(BB, dl, TII->
get(PPC::SLW), Incr2Reg).addReg(incr).
addReg(ShiftReg);
10854 BuildMI(BB, dl, TII->
get(PPC::LI), Mask2Reg).addImm(255);
10856 BuildMI(BB, dl, TII->
get(PPC::LI), Mask3Reg).addImm(0);
10857 BuildMI(BB, dl, TII->
get(PPC::ORI), Mask2Reg)
10861 BuildMI(BB, dl, TII->
get(PPC::SLW), MaskReg)
10866 BuildMI(BB, dl, TII->
get(PPC::LWARX), TmpDestReg)
10870 BuildMI(BB, dl, TII->
get(BinOpcode), TmpReg)
10873 BuildMI(BB, dl, TII->
get(PPC::ANDC), Tmp2Reg)
10874 .addReg(TmpDestReg)
10882 .addReg(TmpDestReg)
10884 unsigned ValueReg = SReg;
10885 unsigned CmpReg = Incr2Reg;
10886 if (CmpOpcode == PPC::CMPW) {
10888 BuildMI(BB, dl, TII->
get(PPC::SRW), ValueReg)
10892 BuildMI(BB, dl, TII->
get(is8bit ? PPC::EXTSB : PPC::EXTSH), ValueSReg)
10894 ValueReg = ValueSReg;
10897 BuildMI(BB, dl, TII->
get(CmpOpcode), PPC::CR0)
10924 .addReg(TmpDestReg)
10944 assert(TRI->isTypeLegalForClass(*RC,
MVT::i32) &&
"Invalid destination!");
10950 "Invalid Pointer Size!");
11001 if (Subtarget.is64BitELFABI()) {
11003 MIB =
BuildMI(*thisMBB, MI, DL, TII->
get(PPC::STD))
11014 BaseReg = Subtarget.isPPC64() ? PPC::X1 : PPC::R1;
11016 BaseReg = Subtarget.isPPC64() ? PPC::BP8 : PPC::BP;
11018 MIB =
BuildMI(*thisMBB, MI, DL,
11019 TII->
get(Subtarget.isPPC64() ? PPC::STD : PPC::STW))
11026 MIB =
BuildMI(*thisMBB, MI, DL, TII->
get(PPC::BCLalways)).addMBB(mainMBB);
11029 BuildMI(*thisMBB, MI, DL, TII->
get(PPC::LI), restoreDstReg).addImm(1);
11031 MIB =
BuildMI(*thisMBB, MI, DL, TII->
get(PPC::EH_SjLj_Setup))
11042 TII->
get(Subtarget.isPPC64() ? PPC::MFLR8 : PPC::MFLR), LabelReg);
11045 if (Subtarget.isPPC64()) {
11046 MIB =
BuildMI(mainMBB, DL, TII->
get(PPC::STD))
11051 MIB =
BuildMI(mainMBB, DL, TII->
get(PPC::STW))
11058 BuildMI(mainMBB, DL, TII->
get(PPC::LI), mainDstReg).addImm(0);
11063 TII->
get(PPC::PHI), DstReg)
11064 .addReg(mainDstReg).
addMBB(mainMBB)
11082 "Invalid Pointer Size!");
11085 (PVT ==
MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
11088 unsigned FP = (PVT ==
MVT::i64) ? PPC::X31 : PPC::R31;
11089 unsigned SP = (PVT ==
MVT::i64) ? PPC::X1 : PPC::R1;
11113 MIB =
BuildMI(*MBB, MI, DL, TII->
get(PPC::LWZ), FP)
11122 .addImm(LabelOffset)
11125 MIB =
BuildMI(*MBB, MI, DL, TII->
get(PPC::LWZ), Tmp)
11126 .addImm(LabelOffset)
11137 MIB =
BuildMI(*MBB, MI, DL, TII->
get(PPC::LWZ), SP)
11149 MIB =
BuildMI(*MBB, MI, DL, TII->
get(PPC::LWZ), BP)
11156 if (PVT ==
MVT::i64 && Subtarget.isSVR4ABI()) {
11176 if (MI.
getOpcode() == TargetOpcode::STACKMAP ||
11177 MI.
getOpcode() == TargetOpcode::PATCHPOINT) {
11178 if (Subtarget.is64BitELFABI() &&
11179 MI.
getOpcode() == TargetOpcode::PATCHPOINT) {
11191 if (MI.
getOpcode() == PPC::EH_SjLj_SetJmp32 ||
11192 MI.
getOpcode() == PPC::EH_SjLj_SetJmp64) {
11194 }
else if (MI.
getOpcode() == PPC::EH_SjLj_LongJmp32 ||
11195 MI.
getOpcode() == PPC::EH_SjLj_LongJmp64) {
11208 if (MI.
getOpcode() == PPC::SELECT_CC_I4 ||
11212 if (MI.
getOpcode() == PPC::SELECT_CC_I4 ||
11222 }
else if (MI.
getOpcode() == PPC::SELECT_CC_F4 ||
11224 MI.
getOpcode() == PPC::SELECT_CC_F16 ||
11225 MI.
getOpcode() == PPC::SELECT_CC_QFRC ||
11226 MI.
getOpcode() == PPC::SELECT_CC_QSRC ||
11227 MI.
getOpcode() == PPC::SELECT_CC_QBRC ||
11228 MI.
getOpcode() == PPC::SELECT_CC_VRRC ||
11229 MI.
getOpcode() == PPC::SELECT_CC_VSFRC ||
11230 MI.
getOpcode() == PPC::SELECT_CC_VSSRC ||
11231 MI.
getOpcode() == PPC::SELECT_CC_VSRC ||
11232 MI.
getOpcode() == PPC::SELECT_CC_SPE4 ||
11233 MI.
getOpcode() == PPC::SELECT_CC_SPE ||
11260 F->
insert(It, copy0MBB);
11290 .addImm(SelectPred)
11312 }
else if (MI.
getOpcode() == PPC::ReadTB) {
11344 BuildMI(BB, dl, TII->
get(PPC::MFSPR), HiReg).addImm(269);
11345 BuildMI(BB, dl, TII->
get(PPC::MFSPR), LoReg).addImm(268);
11346 BuildMI(BB, dl, TII->
get(PPC::MFSPR), ReadAgainReg).addImm(269);
11350 BuildMI(BB, dl, TII->
get(PPC::CMPW), CmpReg)
11360 }
else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_ADD_I8)
11362 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_ADD_I16)
11364 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_ADD_I32)
11366 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_ADD_I64)
11369 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_AND_I8)
11371 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_AND_I16)
11373 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_AND_I32)
11375 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_AND_I64)
11378 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_OR_I8)
11380 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_OR_I16)
11382 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_OR_I32)
11384 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_OR_I64)
11387 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_XOR_I8)
11389 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_XOR_I16)
11391 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_XOR_I32)
11393 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_XOR_I64)
11396 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_NAND_I8)
11398 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_NAND_I16)
11400 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_NAND_I32)
11402 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_NAND_I64)
11405 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_SUB_I8)
11407 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_SUB_I16)
11409 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_SUB_I32)
11411 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_SUB_I64)
11414 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MIN_I8)
11416 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MIN_I16)
11418 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MIN_I32)
11420 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MIN_I64)
11423 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MAX_I8)
11425 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MAX_I16)
11427 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MAX_I32)
11429 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_MAX_I64)
11432 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMIN_I8)
11434 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMIN_I16)
11436 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMIN_I32)
11438 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMIN_I64)
11441 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMAX_I8)
11443 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMAX_I16)
11445 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMAX_I32)
11447 else if (MI.
getOpcode() == PPC::ATOMIC_LOAD_UMAX_I64)
11450 else if (MI.
getOpcode() == PPC::ATOMIC_SWAP_I8)
11452 else if (MI.
getOpcode() == PPC::ATOMIC_SWAP_I16)
11454 else if (MI.
getOpcode() == PPC::ATOMIC_SWAP_I32)
11456 else if (MI.
getOpcode() == PPC::ATOMIC_SWAP_I64)
11458 else if (MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I32 ||
11459 MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I64 ||
11460 (Subtarget.hasPartwordAtomics() &&
11461 MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I8) ||
11462 (Subtarget.hasPartwordAtomics() &&
11463 MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I16)) {
11464 bool is64bit = MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I64;
11466 auto LoadMnemonic = PPC::LDARX;
11467 auto StoreMnemonic = PPC::STDCX;
11471 case PPC::ATOMIC_CMP_SWAP_I8:
11472 LoadMnemonic = PPC::LBARX;
11473 StoreMnemonic = PPC::STBCX;
11474 assert(Subtarget.hasPartwordAtomics() &&
"No support partword atomics.");
11476 case PPC::ATOMIC_CMP_SWAP_I16:
11477 LoadMnemonic = PPC::LHARX;
11478 StoreMnemonic = PPC::STHCX;
11479 assert(Subtarget.hasPartwordAtomics() &&
"No support partword atomics.");
11481 case PPC::ATOMIC_CMP_SWAP_I32:
11482 LoadMnemonic = PPC::LWARX;
11483 StoreMnemonic = PPC::STWCX;
11485 case PPC::ATOMIC_CMP_SWAP_I64:
11486 LoadMnemonic = PPC::LDARX;
11487 StoreMnemonic = PPC::STDCX;
11501 F->
insert(It, loop1MBB);
11502 F->
insert(It, loop2MBB);
11527 BuildMI(BB, dl, TII->
get(is64bit ? PPC::CMPD : PPC::CMPW), PPC::CR0)
11560 }
else if (MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I8 ||
11561 MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I16) {
11565 bool is64bit = Subtarget.isPPC64();
11566 bool isLittleEndian = Subtarget.isLittleEndian();
11567 bool is8bit = MI.
getOpcode() == PPC::ATOMIC_CMP_SWAP_I8;
11580 F->
insert(It, loop1MBB);
11581 F->
insert(It, loop2MBB);
11590 is64bit ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
11609 Register ZeroReg = is64bit ? PPC::ZERO8 : PPC::ZERO;
11642 if (ptrA != ZeroReg) {
11644 BuildMI(BB, dl, TII->
get(is64bit ? PPC::ADD8 : PPC::ADD4), Ptr1Reg)
11653 BuildMI(BB, dl, TII->
get(PPC::RLWINM), Shift1Reg)
11654 .addReg(Ptr1Reg, 0, is64bit ? PPC::sub_32 : 0)
11657 .
addImm(is8bit ? 28 : 27);
11658 if (!isLittleEndian)
11659 BuildMI(BB, dl, TII->
get(PPC::XORI), ShiftReg)
11661 .
addImm(is8bit ? 24 : 16);
11663 BuildMI(BB, dl, TII->
get(PPC::RLDICR), PtrReg)
11668 BuildMI(BB, dl, TII->
get(PPC::RLWINM), PtrReg)
11673 BuildMI(BB, dl, TII->
get(PPC::SLW), NewVal2Reg)
11676 BuildMI(BB, dl, TII->
get(PPC::SLW), OldVal2Reg)
11680 BuildMI(BB, dl, TII->
get(PPC::LI), Mask2Reg).addImm(255);
11682 BuildMI(BB, dl, TII->
get(PPC::LI), Mask3Reg).addImm(0);
11683 BuildMI(BB, dl, TII->
get(PPC::ORI), Mask2Reg)
11687 BuildMI(BB, dl, TII->
get(PPC::SLW), MaskReg)
11691 .addReg(NewVal2Reg)
11694 .addReg(OldVal2Reg)
11698 BuildMI(BB, dl, TII->
get(PPC::LWARX), TmpDestReg)
11702 .addReg(TmpDestReg)
11704 BuildMI(BB, dl, TII->
get(PPC::CMPW), PPC::CR0)
11715 BuildMI(BB, dl, TII->
get(PPC::ANDC), Tmp2Reg)
11716 .addReg(TmpDestReg)
11735 .addReg(TmpDestReg)
11746 }
else if (MI.
getOpcode() == PPC::FADDrtz) {
11762 BuildMI(*BB, MI, dl, TII->
get(PPC::MTFSB1)).addImm(31);
11763 BuildMI(*BB, MI, dl, TII->
get(PPC::MTFSB0)).addImm(30);
11772 MI.
getOpcode() == PPC::ANDI_rec_1_EQ_BIT8 ||
11773 MI.
getOpcode() == PPC::ANDI_rec_1_GT_BIT8) {
11774 unsigned Opcode = (MI.
getOpcode() == PPC::ANDI_rec_1_EQ_BIT8 ||
11775 MI.
getOpcode() == PPC::ANDI_rec_1_GT_BIT8)
11779 MI.
getOpcode() == PPC::ANDI_rec_1_EQ_BIT8);
11783 Opcode == PPC::ANDI_rec ? &PPC::GPRCRegClass : &PPC::G8RCRegClass);
11786 BuildMI(*BB, MI, Dl, TII->
get(Opcode), Dest)
11789 BuildMI(*BB, MI, Dl, TII->
get(TargetOpcode::COPY),
11791 .addReg(IsEQ ? PPC::CR0EQ : PPC::CR0GT);
11792 }
else if (MI.
getOpcode() == PPC::TCHECK_RET) {
11796 BuildMI(*BB, MI, Dl, TII->
get(PPC::TCHECK), CRReg);
11797 BuildMI(*BB, MI, Dl, TII->
get(TargetOpcode::COPY),
11800 }
else if (MI.
getOpcode() == PPC::TBEGIN_RET) {
11804 BuildMI(*BB, MI, Dl, TII->
get(TargetOpcode::COPY),
11806 .addReg(PPC::CR0EQ);
11807 }
else if (MI.
getOpcode() == PPC::SETRNDi) {
11824 BuildMI(*BB, MI, dl, TII->
get((Mode & 1) ? PPC::MTFSB1 : PPC::MTFSB0))
11827 BuildMI(*BB, MI, dl, TII->
get((Mode & 2) ? PPC::MTFSB1 : PPC::MTFSB0))
11829 }
else if (MI.
getOpcode() == PPC::SETRND) {
11837 auto copyRegFromG8RCOrF8RC = [&] (
unsigned DestReg,
unsigned SrcReg) {
11838 if (Subtarget.hasDirectMove()) {
11839 BuildMI(*BB, MI, dl, TII->
get(TargetOpcode::COPY), DestReg)
11843 unsigned StoreOp = PPC::STD, LoadOp = PPC::LFD;
11846 if (RC == &PPC::F8RCRegClass) {
11849 "Unsupported RegClass.");
11851 StoreOp = PPC::STFD;
11856 (RegInfo.
getRegClass(DestReg) == &PPC::F8RCRegClass) &&
11857 "Unsupported RegClass.");
11883 BuildMI(*BB, MI, dl, TII->
get(LoadOp), DestReg)
11907 copyRegFromG8RCOrF8RC(OldFPSCRTmpReg, OldFPSCRReg);
11915 BuildMI(*BB, MI, dl, TII->
get(TargetOpcode::IMPLICIT_DEF), ImDefReg);
11916 BuildMI(*BB, MI, dl, TII->
get(PPC::INSERT_SUBREG), ExtSrcReg)
11922 BuildMI(*BB, MI, dl, TII->
get(PPC::RLDIMI), NewFPSCRTmpReg)
11923 .addReg(OldFPSCRTmpReg)
11929 copyRegFromG8RCOrF8RC(NewFPSCRReg, NewFPSCRTmpReg);
11955 int RefinementSteps = Subtarget.
hasRecipPrec() ? 1 : 3;
11958 return RefinementSteps;
11962 int Enabled,
int &RefinementSteps,
11963 bool &UseOneConstNR,
11964 bool Reciprocal)
const {
11966 if ((VT ==
MVT::f32 && Subtarget.hasFRSQRTES()) ||
11967 (VT ==
MVT::f64 && Subtarget.hasFRSQRTE()) ||
11968 (VT ==
MVT::v4f32 && Subtarget.hasAltivec()) ||
11972 if (RefinementSteps == ReciprocalEstimate::Unspecified)
11977 UseOneConstNR = !Subtarget.needsTwoConstNR();
11985 int &RefinementSteps)
const {
11987 if ((VT ==
MVT::f32 && Subtarget.hasFRES()) ||
11988 (VT ==
MVT::f64 && Subtarget.hasFRE()) ||
11989 (VT ==
MVT::v4f32 && Subtarget.hasAltivec()) ||
11993 if (RefinementSteps == ReciprocalEstimate::Unspecified)
12000 unsigned PPCTargetLowering::combineRepeatedFPDivisors()
const {
12011 switch (Subtarget.getCPUDirective()) {
12029 Offset += cast<ConstantSDNode>(Loc.
getOperand(1))->getSExtValue();
12038 unsigned Bytes,
int Dist,
12048 int FI = cast<FrameIndexSDNode>(Loc)->getIndex();
12049 int BFI = cast<FrameIndexSDNode>(BaseLoc)->getIndex();
12052 if (FS != BFS || FS != (
int)Bytes)
return false;
12056 SDValue Base1 = Loc, Base2 = BaseLoc;
12057 int64_t Offset1 = 0, Offset2 = 0;
12060 if (Base1 == Base2 && Offset1 == (Offset2 + Dist * Bytes))
12070 if (isGA1 && isGA2 && GV1 == GV2)
12071 return Offset1 == (Offset2 + Dist*Bytes);
12078 unsigned Bytes,
int Dist,
12081 EVT VT =
LS->getMemoryVT();
12088 switch (cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue()) {
12089 default:
return false;
12090 case Intrinsic::ppc_qpx_qvlfd:
12091 case Intrinsic::ppc_qpx_qvlfda:
12094 case Intrinsic::ppc_qpx_qvlfs:
12095 case Intrinsic::ppc_qpx_qvlfsa:
12098 case Intrinsic::ppc_qpx_qvlfcd:
12099 case Intrinsic::ppc_qpx_qvlfcda:
12102 case Intrinsic::ppc_qpx_qvlfcs:
12103 case Intrinsic::ppc_qpx_qvlfcsa:
12106 case Intrinsic::ppc_qpx_qvlfiwa:
12107 case Intrinsic::ppc_qpx_qvlfiwz:
12108 case Intrinsic::ppc_altivec_lvx:
12109 case Intrinsic::ppc_altivec_lvxl:
12110 case Intrinsic::ppc_vsx_lxvw4x:
12111 case Intrinsic::ppc_vsx_lxvw4x_be:
12114 case Intrinsic::ppc_vsx_lxvd2x:
12115 case Intrinsic::ppc_vsx_lxvd2x_be:
12118 case Intrinsic::ppc_altivec_lvebx:
12121 case Intrinsic::ppc_altivec_lvehx:
12124 case Intrinsic::ppc_altivec_lvewx:
12134 switch (cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue()) {
12135 default:
return false;
12136 case Intrinsic::ppc_qpx_qvstfd:
12137 case Intrinsic::ppc_qpx_qvstfda:
12140 case Intrinsic::ppc_qpx_qvstfs:
12141 case Intrinsic::ppc_qpx_qvstfsa:
12144 case Intrinsic::ppc_qpx_qvstfcd:
12145 case Intrinsic::ppc_qpx_qvstfcda:
12148 case Intrinsic::ppc_qpx_qvstfcs:
12149 case Intrinsic::ppc_qpx_qvstfcsa:
12152 case Intrinsic::ppc_qpx_qvstfiw:
12153 case Intrinsic::ppc_qpx_qvstfiwa:
12154 case Intrinsic::ppc_altivec_stvx:
12155 case Intrinsic::ppc_altivec_stvxl:
12156 case Intrinsic::ppc_vsx_stxvw4x:
12159 case Intrinsic::ppc_vsx_stxvd2x:
12162 case Intrinsic::ppc_vsx_stxvw4x_be:
12165 case Intrinsic::ppc_vsx_stxvd2x_be:
12168 case Intrinsic::ppc_altivec_stvebx:
12171 case Intrinsic::ppc_altivec_stvehx:
12174 case Intrinsic::ppc_altivec_stvewx:
12201 while (!Queue.empty()) {
12202 SDNode *ChainNext = Queue.pop_back_val();
12203 if (!Visited.
insert(ChainNext).second)
12206 if (
MemSDNode *ChainLD = dyn_cast<MemSDNode>(ChainNext)) {
12210 if (!Visited.count(ChainLD->getChain().getNode()))
12211 Queue.push_back(ChainLD->getChain().getNode());
12213 for (
const SDUse &
O : ChainNext->
ops())
12214 if (!Visited.count(
O.getNode()))
12215 Queue.push_back(
O.getNode());
12217 LoadRoots.
insert(ChainNext);
12230 Queue.push_back(*
I);
12232 while (!Queue.empty()) {
12233 SDNode *LoadRoot = Queue.pop_back_val();
12234 if (!Visited.
insert(LoadRoot).second)
12237 if (
MemSDNode *ChainLD = dyn_cast<MemSDNode>(LoadRoot))
12242 UE = LoadRoot->
use_end(); UI != UE; ++UI)
12243 if (((isa<MemSDNode>(*UI) &&
12244 cast<MemSDNode>(*UI)->getChain().getNode() == LoadRoot) ||
12246 Queue.push_back(*UI);
12279 auto Final = Shifted;
12289 SDValue PPCTargetLowering::ConvertSETCCToSubtract(
SDNode *N,
12290 DAGCombinerInfo &DCI)
const {
12298 if (!DCI.isAfterLegalizeDAG())
12304 UE = N->
use_end(); UI != UE; ++UI) {
12312 unsigned Size = DAG.getDataLayout().getLargestLegalIntTypeSizeInBits();
12314 if (OpSize < Size) {
12331 SDValue PPCTargetLowering::DAGCombineTruncBoolExt(
SDNode *N,
12332 DAGCombinerInfo &DCI)
const {
12336 assert(Subtarget.useCRBits() &&
"Expecting to be tracking CR bits");
12385 if (Op1Known.
Zero != Op2Known.
Zero || Op1Known.
One != Op2Known.
One)
12420 for (
unsigned i = 0; i < 2; ++i) {
12436 while (!BinOps.
empty()) {
12445 for (
unsigned i = 0, ie = BinOp.
getNumOperands(); i != ie; ++i) {
12479 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
12480 if (isa<ConstantSDNode>(Inputs[i]))
12484 UE = Inputs[i].getNode()->use_end();
12487 if (User != N && !Visited.
count(User))
12506 for (
unsigned i = 0, ie = PromOps.
size(); i != ie; ++i) {
12508 UE = PromOps[i].getNode()->use_end();
12511 if (User != N && !Visited.
count(User))
12531 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
12534 if (isa<ConstantSDNode>(Inputs[i]))
12540 std::list<HandleSDNode> PromOpHandles;
12541 for (
auto &PromOp : PromOps)
12542 PromOpHandles.emplace_back(PromOp);
12549 while (!PromOpHandles.empty()) {
12551 PromOpHandles.pop_back();
12557 if (!isa<ConstantSDNode>(PromOp.
getOperand(0)) &&
12560 PromOpHandles.emplace_front(PromOp);
12565 if (isa<ConstantSDNode>(RepValue))
12574 default: C = 0;
break;
12579 if ((!isa<ConstantSDNode>(PromOp.
getOperand(C)) &&
12581 (!isa<ConstantSDNode>(PromOp.
getOperand(C+1)) &&
12587 PromOpHandles.emplace_front(PromOp);
12595 for (
unsigned i = 0; i < 2; ++i)
12596 if (isa<ConstantSDNode>(Ops[C+i]))
12612 SDValue PPCTargetLowering::DAGCombineExtBoolTrunc(
SDNode *N,
12613 DAGCombinerInfo &DCI)
const {
12652 while (!BinOps.empty()) {
12653 SDValue BinOp = BinOps.back();
12659 PromOps.push_back(BinOp);
12661 for (
unsigned i = 0, ie = BinOp.
getNumOperands(); i != ie; ++i) {
12692 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
12693 if (isa<ConstantSDNode>(Inputs[i]))
12697 UE = Inputs[i].getNode()->use_end();
12700 if (User != N && !Visited.count(User))
12707 SelectTruncOp[0].insert(std::make_pair(User,
12711 SelectTruncOp[0].insert(std::make_pair(User,
12714 SelectTruncOp[1].insert(std::make_pair(User,
12720 for (
unsigned i = 0, ie = PromOps.size(); i != ie; ++i) {
12722 UE = PromOps[i].getNode()->
use_end();
12725 if (User != N && !Visited.count(User))
12732 SelectTruncOp[0].insert(std::make_pair(User,
12736 SelectTruncOp[0].insert(std::make_pair(User,
12739 SelectTruncOp[1].insert(std::make_pair(User,
12746 bool ReallyNeedsExt =
false;
12750 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
12751 if (isa<ConstantSDNode>(Inputs[i]))
12755 Inputs[i].getOperand(0).getValueSizeInBits();
12756 assert(PromBits < OpBits &&
"Truncation not to a smaller bit count?");
12761 OpBits-PromBits))) ||
12764 (OpBits-(PromBits-1)))) {
12765 ReallyNeedsExt =
true;
12773 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
12777 if (isa<ConstantSDNode>(Inputs[i]))
12780 SDValue InSrc = Inputs[i].getOperand(0);
12794 std::list<HandleSDNode> PromOpHandles;
12795 for (
auto &PromOp : PromOps)
12796 PromOpHandles.emplace_back(PromOp);
12802 while (!PromOpHandles.empty()) {
12804 PromOpHandles.pop_back();
12808 default: C = 0;
break;
12813 if ((!isa<ConstantSDNode>(PromOp.
getOperand(C)) &&
12815 (!isa<ConstantSDNode>(PromOp.
getOperand(C+1)) &&
12821 PromOpHandles.emplace_front(PromOp);
12833 PromOpHandles.emplace_front(PromOp);
12842 for (
unsigned i = 0; i < 2; ++i) {
12843 if (!isa<ConstantSDNode>(Ops[C+i]))
12860 auto SI0 = SelectTruncOp[0].
find(PromOp.
getNode());
12861 if (SI0 != SelectTruncOp[0].
end())
12863 auto SI1 = SelectTruncOp[1].
find(PromOp.
getNode());
12864 if (SI1 != SelectTruncOp[1].
end())
12873 if (!ReallyNeedsExt)
12885 "Invalid extension type");
12896 DAGCombinerInfo &DCI)
const {
12898 "Should be called with a SETCC node");
12923 return DAGCombineTruncBoolExt(N, DCI);
12942 combineElementTruncationToVectorTruncation(
SDNode *N,
12943 DAGCombinerInfo &DCI)
const {
12945 "Should be called with a BUILD_VECTOR node");
12952 "The input operand must be an fp-to-int conversion.");
12961 bool IsSplat =
true;
12972 if (NextConversion != FirstConversion)
13001 DAG.getIntPtrConstant(1, dl));
13016 SDValue BV = DAG.getBuildVector(NewVT, dl, Ops);
13017 return DAG.
getNode(Opcode, dl, TargetVT, BV);
13030 "Should be called with a BUILD_VECTOR node");
13038 bool InputsAreConsecutiveLoads =
true;
13039 bool InputsAreReverseConsecutive =
true;
13042 bool IsRoundOfExtLoad =
false;
13070 if (IsRoundOfExtLoad && LD2->getExtensionType() !=
ISD::EXTLOAD)
13074 InputsAreConsecutiveLoads =
false;
13076 InputsAreReverseConsecutive =
false;
13079 if (!InputsAreConsecutiveLoads && !InputsAreReverseConsecutive)
13083 assert(!(InputsAreConsecutiveLoads && InputsAreReverseConsecutive) &&
13084 "The loads cannot be both consecutive and reverse consecutive.");
13087 IsRoundOfExtLoad ? FirstInput.
getOperand(0) : FirstInput;
13094 if (InputsAreConsecutiveLoads) {
13095 assert(LD1 &&
"Input needs to be a LoadSDNode.");
13100 if (InputsAreReverseConsecutive) {
13101 assert(LDL &&
"Input needs to be a LoadSDNode.");
13103 LDL->getBasePtr(), LDL->getPointerInfo(),
13104 LDL->getAlignment());
13119 SDValue Input, uint64_t Elems,
13120 uint64_t CorrectElems) {
13131 ShuffleMask[CorrectElems & 0xF] = Elems & 0xF;
13133 ShuffleMask[(CorrectElems & 0xF0) >> 4] = (Elems & 0xF0) >> 4;
13134 CorrectElems = CorrectElems >> 8;
13135 Elems = Elems >> 8;
13140 DAG.
getUNDEF(Input.getValueType()), ShuffleMask);
13163 uint64_t TargetElems[] = {
13171 uint64_t Elems = 0;
13175 auto isSExtOfVecExtract = [&](
SDValue Op) ->
bool {
13195 if (Input && Input != Extract.
getOperand(0))
13201 Elems = Elems << 8;
13211 if (!isSExtOfVecExtract(N->
getOperand(i))) {
13218 int TgtElemArrayIdx;
13221 if (InputSize + OutputSize == 40)
13222 TgtElemArrayIdx = 0;
13223 else if (InputSize + OutputSize == 72)
13224 TgtElemArrayIdx = 1;
13225 else if (InputSize + OutputSize == 48)
13226 TgtElemArrayIdx = 2;
13227 else if (InputSize + OutputSize == 80)
13228 TgtElemArrayIdx = 3;
13229 else if (InputSize + OutputSize == 96)
13230 TgtElemArrayIdx = 4;
13234 uint64_t CorrectElems = TargetElems[TgtElemArrayIdx];
13236 ? CorrectElems & 0x0F0F0F0F0F0F0F0F
13237 : CorrectElems & 0xF0F0F0F0F0F0F0F0;
13238 if (Elems != CorrectElems) {
13246 SDValue PPCTargetLowering::DAGCombineBuildVector(
SDNode *N,
13247 DAGCombinerInfo &DCI)
const {
13249 "Should be called with a BUILD_VECTOR node");
13254 if (!Subtarget.hasVSX())
13262 SDValue Reduced = combineElementTruncationToVectorTruncation(N, DCI);
13277 if (Subtarget.hasP9Altivec() && !DCI.isBeforeLegalize()) {
13306 if (!Ext1Op || !Ext2Op)
13313 int SecondElem = Ext2Op->getZExtValue();
13315 if (FirstElem == 0 && SecondElem == 1)
13316 SubvecIdx = Subtarget.isLittleEndian() ? 1 : 0;
13317 else if (FirstElem == 2 && SecondElem == 3)
13318 SubvecIdx = Subtarget.isLittleEndian() ? 0 : 1;
13326 SrcVec, DAG.getIntPtrConstant(SubvecIdx, dl));
13330 DAGCombinerInfo &DCI)
const {
13333 "Need an int -> FP conversion node here");
13352 (FirstOperand.getValueType() ==
MVT::i8 ||
13353 FirstOperand.getValueType() ==
MVT::i16);
13354 if (Subtarget.hasP9Vector() && Subtarget.hasP9Altivec() && SubWordLoad) {
13357 unsigned ConvOp = Signed ?
13363 LoadSDNode *LDN = cast<LoadSDNode>(FirstOperand.getNode());
13371 SDValue ExtOps[] = { Ld, WidthConst };
13387 "UINT_TO_FP is supported only with FPCVT");
13403 Subtarget.hasFPCVT()) ||
13408 DCI.AddToWorklist(Src.
getNode());
13424 DCI.AddToWorklist(FP.
getNode());
13473 if (Subtarget.needsSwapsForVSXMemOps() && !(MMO->
getAlignment()%16)
13478 SDValue LoadOps[] = { Chain, Base };
13490 if (VecTy != MVT::v2f64) {
13544 if (Subtarget.needsSwapsForVSXMemOps() && !(MMO->
getAlignment()%16)
13559 SDValue StoreOps[] = { Chain, Swap, Base };
13562 StoreOps, VecTy, MMO);
13576 &&
"Not a FP_TO_INT Instruction!");
13587 bool ValidTypeForStoreFltAsInt =
13589 (Subtarget.hasP9Vector() && (Op1VT ==
MVT::i16 || Op1VT ==
MVT::i8)));
13591 if (ResVT ==
MVT::ppcf128 || !Subtarget.hasP8Altivec() ||
13592 cast<StoreSDNode>(
N)->isTruncatingStore() || !ValidTypeForStoreFltAsInt)
13606 Val = DAG.
getNode(ConvOpcode,
13618 cast<StoreSDNode>(
N)->getMemoryVT(),
13619 cast<StoreSDNode>(
N)->getMemOperand());
13629 "Not a reverse memop pattern!");
13634 auto I =
Mask.rbegin();
13635 auto E =
Mask.rend();
13637 for (;
I !=
E; ++
I) {
13648 if (!
isTypeLegal(VT) || !Subtarget.isLittleEndian() || !Subtarget.hasVSX())
13654 if (!Subtarget.hasP9Vector())
13657 if(!IsElementReverse(SVN))
13687 return combineADD(N, DCI);
13689 return combineSHL(N, DCI);
13691 return combineSRA(N, DCI);
13693 return combineSRL(N, DCI);
13695 return combineMUL(N, DCI);
13706 if (
C->isNullValue() ||
13707 C->isAllOnesValue())
13714 return DAGCombineExtBoolTrunc(N, DCI);
13716 return combineTRUNCATE(N, DCI);
13718 if (
SDValue CSCC = combineSetCC(N, DCI))
13722 return DAGCombineTruncBoolExt(N, DCI);
13725 return combineFPToIntToFP(N, DCI);
13729 return combineVReverseMemOP(cast<ShuffleVectorSDNode>(N), LSBase, DCI);
13738 SDValue Val= combineStoreFPToInt(N, DCI);
13745 SDValue Val= combineVReverseMemOP(SVN, cast<LSBaseSDNode>(N), DCI);
13751 if (cast<StoreSDNode>(N)->isUnindexed() && Opcode ==
ISD::BSWAP &&
13754 (Subtarget.hasLDBRX() && Subtarget.isPPC64() && Op1VT ==
MVT::i64))) {
13758 EVT mVT = cast<StoreSDNode>(
N)->getMemoryVT();
13769 if (Op1VT.
bitsGT(mVT)) {
13783 Ops, cast<StoreSDNode>(
N)->getMemoryVT(),
13784 cast<StoreSDNode>(
N)->getMemOperand());
13792 EVT MemVT = cast<StoreSDNode>(
N)->getMemoryVT();
13802 cast<StoreSDNode>(
N)->setTruncatingStore(
true);
13810 if (Subtarget.needsSwapsForVSXMemOps() &&
13823 if (VT.isSimple()) {
13824 MVT LoadVT = VT.getSimpleVT();
13825 if (Subtarget.needsSwapsForVSXMemOps() &&
13838 auto ReplaceTwoFloatLoad = [&]() {
13858 while (UI.getUse().getResNo() != 0) ++UI;
13860 while (UI.getUse().getResNo() != 0) ++UI;
13861 SDNode *RightShift = *UI;
13870 !isa<ConstantSDNode>(RightShift->
getOperand(1)) ||
13891 if (Subtarget.isLittleEndian())
13900 "Non-pre-inc AM on PPC?");
13933 if (ReplaceTwoFloatLoad())
13952 bool isLittleEndian = Subtarget.isLittleEndian();
13979 MVT PermCntlTy, PermTy, LDTy;
13980 if (Subtarget.hasAltivec()) {
13981 Intr = isLittleEndian ? Intrinsic::ppc_altivec_lvsr :
13982 Intrinsic::ppc_altivec_lvsl;
13983 IntrLD = Intrinsic::ppc_altivec_lvx;
13984 IntrPerm = Intrinsic::ppc_altivec_vperm;
13989 Intr = MemVT ==
MVT::v4f64 ? Intrinsic::ppc_qpx_qvlpcld :
13990 Intrinsic::ppc_qpx_qvlpcls;
13991 IntrLD = MemVT ==
MVT::v4f64 ? Intrinsic::ppc_qpx_qvlfd :
13992 Intrinsic::ppc_qpx_qvlfs;
13993 IntrPerm = Intrinsic::ppc_qpx_qvfperm;
14015 SDValue BaseLoadOps[] = { Chain, LDXIntID, Ptr };
14019 BaseLoadOps, LDTy, BaseMMO);
14027 int IncOffset = VT.getSizeInBits() / 8;
14028 int IncValue = IncOffset;
14045 SDValue ExtraLoadOps[] = { Chain, LDXIntID, Ptr };
14049 ExtraLoadOps, LDTy, ExtraMMO);
14060 if (isLittleEndian)
14062 ExtraLoad, BaseLoad, PermCntl, DAG, dl);
14065 BaseLoad, ExtraLoad, PermCntl, DAG, dl);
14068 Perm = Subtarget.hasAltivec() ?
14083 bool isLittleEndian = Subtarget.isLittleEndian();
14084 unsigned IID = cast<ConstantSDNode>(N->
getOperand(0))->getZExtValue();
14086 : Intrinsic::ppc_altivec_lvsl);
14087 if ((IID == Intr ||
14088 IID == Intrinsic::ppc_qpx_qvlpcld ||
14089 IID == Intrinsic::ppc_qpx_qvlpcls) &&
14093 int Bits = IID == Intrinsic::ppc_qpx_qvlpcld ?
14104 cast<ConstantSDNode>(UI->getOperand(0))->getZExtValue() == IID) {
14114 if (isa<ConstantSDNode>(Add->
getOperand(1))) {
14117 UE = BasePtr->
use_end(); UI != UE; ++UI) {
14118 if (UI->getOpcode() ==
ISD::ADD &&
14119 isa<ConstantSDNode>(UI->getOperand(1)) &&
14120 (cast<ConstantSDNode>(Add->
getOperand(1))->getZExtValue() -
14121 cast<ConstantSDNode>(UI->getOperand(1))->getZExtValue()) %
14122 (1ULL << Bits) == 0) {
14127 cast<ConstantSDNode>(
VI->getOperand(0))->getZExtValue() == IID) {
14139 (IID == Intrinsic::ppc_altivec_vmaxsw ||
14140 IID == Intrinsic::ppc_altivec_vmaxsh ||
14141 IID == Intrinsic::ppc_altivec_vmaxsb)) {
14174 if (Subtarget.needsSwapsForVSXMemOps()) {
14175 switch (cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue()) {
14178 case Intrinsic::ppc_vsx_lxvw4x:
14179 case Intrinsic::ppc_vsx_lxvd2x:
14187 if (Subtarget.needsSwapsForVSXMemOps()) {
14188 switch (cast<ConstantSDNode>(N->
getOperand(1))->getZExtValue()) {
14191 case Intrinsic::ppc_vsx_stxvw4x:
14192 case Intrinsic::ppc_vsx_stxvd2x:
14202 (Subtarget.hasLDBRX() && Subtarget.isPPC64() &&
14245 SDNode *VCMPoNode =
nullptr;
14266 SDNode *FlagUser =
nullptr;
14268 FlagUser ==
nullptr; ++UI) {
14271 for (
unsigned i = 0,
e = User->getNumOperands(); i !=
e; ++i) {
14272 if (User->getOperand(i) ==
SDValue(VCMPoNode, 1)) {
14282 return SDValue(VCMPoNode, 0);
14290 cast<ConstantSDNode>(Cond.
getOperand(1))->getZExtValue() ==
14291 Intrinsic::loop_decrement) {
14297 "Counter decrement has more than one use");
14317 Intrinsic::loop_decrement &&
14323 cast<ConstantSDNode>(LHS.
getOperand(1))->getZExtValue() ==
14324 Intrinsic::loop_decrement &&
14325 isa<ConstantSDNode>(RHS)) {
14327 "Counter decrement comparison is not EQ or NE");
14329 unsigned Val = cast<ConstantSDNode>(RHS)->getZExtValue();
14337 "Counter decrement has more than one use");
14349 assert(isDot &&
"Can't compare against a vector result!");
14353 unsigned Val = cast<ConstantSDNode>(RHS)->getZExtValue();
14354 if (Val != 0 && Val != 1) {
14362 bool BranchOnWhenPredTrue = (CC ==
ISD::SETEQ) ^ (Val == 0);
14375 switch (cast<ConstantSDNode>(LHS.
getOperand(1))->getZExtValue()) {
14399 return DAGCombineBuildVector(N, DCI);
14401 return combineABS(N, DCI);
14403 return combineVSelect(N, DCI);
14415 if (VT ==
MVT::i64 && !Subtarget.isPPC64())
14418 !(Divisor.
isPowerOf2() || (-Divisor).isPowerOf2()))
14424 bool IsNegPow2 = (-Divisor).isPowerOf2();
14445 const APInt &DemandedElts,
14447 unsigned Depth)
const {
14454 Known.
Zero = 0xFFFF0000;
14458 switch (cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue()) {
14460 case Intrinsic::ppc_altivec_vcmpbfp_p:
14461 case Intrinsic::ppc_altivec_vcmpeqfp_p:
14462 case Intrinsic::ppc_altivec_vcmpequb_p:
14463 case Intrinsic::ppc_altivec_vcmpequh_p:
14464 case Intrinsic::ppc_altivec_vcmpequw_p:
14465 case Intrinsic::ppc_altivec_vcmpequd_p:
14466 case Intrinsic::ppc_altivec_vcmpgefp_p:
14467 case Intrinsic::ppc_altivec_vcmpgtfp_p:
14468 case Intrinsic::ppc_altivec_vcmpgtsb_p:
14469 case Intrinsic::ppc_altivec_vcmpgtsh_p:
14470 case Intrinsic::ppc_altivec_vcmpgtsw_p:
14471 case Intrinsic::ppc_altivec_vcmpgtsd_p:
14472 case Intrinsic::ppc_altivec_vcmpgtub_p:
14473 case Intrinsic::ppc_altivec_vcmpgtuh_p:
14474 case Intrinsic::ppc_altivec_vcmpgtuw_p:
14475 case Intrinsic::ppc_altivec_vcmpgtud_p:
14484 switch (Subtarget.getCPUDirective()) {
14512 uint64_t LoopSize = 0;
14514 for (
auto J = (*I)->begin(), JE = (*I)->end(); J != JE; ++J) {
14520 if (LoopSize > 16 && LoopSize <= 32)
14534 if (Constraint.
size() == 1) {
14535 switch (Constraint[0]) {
14553 }
else if (Constraint ==
"wc") {
14555 }
else if (Constraint ==
"wa" || Constraint ==
"wd" ||
14556 Constraint ==
"wf" || Constraint ==
"ws" ||
14557 Constraint ==
"wi" || Constraint ==
"ww") {
14573 if (!CallOperandVal)
14580 else if ((
StringRef(constraint) ==
"wa" ||
14592 switch (*constraint) {
14622 std::pair<unsigned, const TargetRegisterClass *>
14626 if (Constraint.
size() == 1) {
14628 switch (Constraint[0]) {
14630 if (VT ==
MVT::i64 && Subtarget.isPPC64())
14631 return std::make_pair(0U, &PPC::G8RC_NOX0RegClass);
14632 return std::make_pair(0U, &PPC::GPRC_NOR0RegClass);
14634 if (VT ==
MVT::i64 && Subtarget.isPPC64())
14635 return std::make_pair(0U, &PPC::G8RCRegClass);
14636 return std::make_pair(0U, &PPC::GPRCRegClass);
14642 if (Subtarget.hasSPE()) {
14644 return std::make_pair(0U, &PPC::GPRCRegClass);
14646 return std::make_pair(0U, &PPC::SPERCRegClass);
14649 return std::make_pair(0U, &PPC::F4RCRegClass);
14651 return std::make_pair(0U, &PPC::F8RCRegClass);
14653 return std::make_pair(0U, &PPC::QFRCRegClass);
14655 return std::make_pair(0U, &PPC::QSRCRegClass);
14660 return std::make_pair(0U, &PPC::QFRCRegClass);
14662 return std::make_pair(0U, &PPC::QSRCRegClass);
14663 if (Subtarget.hasAltivec())
14664 return std::make_pair(0U, &PPC::VRRCRegClass);
14667 return std::make_pair(0U, &PPC::CRRCRegClass);
14669 }
else if (Constraint ==
"wc" && Subtarget.useCRBits()) {
14671 return std::make_pair(0U, &PPC::CRBITRCRegClass);
14672 }
else if ((Constraint ==
"wa" || Constraint ==
"wd" ||
14673 Constraint ==
"wf" || Constraint ==
"wi") &&
14674 Subtarget.hasVSX()) {
14675 return std::make_pair(0U, &PPC::VSRCRegClass);
14676 }
else if ((Constraint ==
"ws" || Constraint ==
"ww") && Subtarget.hasVSX()) {
14677 if (VT ==
MVT::f32 && Subtarget.hasP8Vector())
14678 return std::make_pair(0U, &PPC::VSSRCRegClass);
14680 return std::make_pair(0U, &PPC::VSFRCRegClass);
14686 if (Constraint.
size() > 3 && Constraint[1] ==
'v' && Constraint[2] ==
's') {
14687 int VSNum = atoi(Constraint.
data() + 3);
14688 assert(VSNum >= 0 && VSNum <= 63 &&
14689 "Attempted to access a vsr out of range");
14691 return std::make_pair(PPC::VSL0 + VSNum, &PPC::VSRCRegClass);
14692 return std::make_pair(PPC::V0 + VSNum - 32, &PPC::VSRCRegClass);
14694 std::pair<unsigned, const TargetRegisterClass *> R =
14703 if (R.first && VT ==
MVT::i64 && Subtarget.isPPC64() &&
14704 PPC::GPRCRegClass.contains(R.first))
14706 PPC::sub_32, &PPC::G8RCRegClass),
14707 &PPC::G8RCRegClass);
14711 R.first = PPC::CR0;
14712 R.second = &PPC::CRRCRegClass;
14721 std::string &Constraint,
14722 std::vector<SDValue>&Ops,
14727 if (Constraint.length() > 1)
return;
14729 char Letter = Constraint[0];
14753 if (isShiftedUInt<16, 16>(Value))
14757 if (isShiftedInt<16, 16>(Value))
14786 Ops.push_back(Result);
14812 switch (AM.
Scale) {
14843 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
14849 bool isPPC64 = Subtarget.isPPC64();
14853 SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);
14855 DAG.
getConstant(Subtarget.getFrameLowering()->getReturnSaveOffset(), dl,
14863 SDValue RetAddrFI = getReturnAddrFrameIndex(DAG);
14871 unsigned Depth = cast<ConstantSDNode>(Op.
getOperand(0))->getZExtValue();
14884 FrameReg = isPPC64 ? PPC::X1 : PPC::R1;
14886 FrameReg = isPPC64 ? PPC::FP8 : PPC::FP;
14900 bool isPPC64 = Subtarget.isPPC64();
14901 bool IsDarwinABI = Subtarget.isDarwinABI();
14908 .Case(
"r1", is64Bit ? PPC::X1 : PPC::R1)
14911 (is64Bit ? PPC::X13 : PPC::R13))
14921 if (Subtarget.is32BitELFABI())
14926 if (Subtarget.isAIXABI())
14936 if (isa<JumpTableSDNode>(GA) || isa<BlockAddressSDNode>(GA))
14940 return Subtarget.isGVIndirectSymbol(
G->getGlobal());
14954 unsigned Intrinsic)
const {
14955 switch (Intrinsic) {
14956 case Intrinsic::ppc_qpx_qvlfd:
14957 case Intrinsic::ppc_qpx_qvlfs:
14958 case Intrinsic::ppc_qpx_qvlfcd:
14959 case Intrinsic::ppc_qpx_qvlfcs:
14960 case Intrinsic::ppc_qpx_qvlfiwa:
14961 case Intrinsic::ppc_qpx_qvlfiwz:
14962 case Intrinsic::ppc_altivec_lvx:
14963 case Intrinsic::ppc_altivec_lvxl:
14964 case Intrinsic::ppc_altivec_lvebx:
14965 case Intrinsic::ppc_altivec_lvehx:
14966 case Intrinsic::ppc_altivec_lvewx:
14967 case Intrinsic::ppc_vsx_lxvd2x:
14968 case Intrinsic::ppc_vsx_lxvw4x: {
14970 switch (Intrinsic) {
14971 case Intrinsic::ppc_altivec_lvebx:
14974 case Intrinsic::ppc_altivec_lvehx:
14977 case Intrinsic::ppc_altivec_lvewx:
14980 case Intrinsic::ppc_vsx_lxvd2x:
14983 case Intrinsic::ppc_qpx_qvlfd:
14986 case Intrinsic::ppc_qpx_qvlfs:
14989 case Intrinsic::ppc_qpx_qvlfcd:
14992 case Intrinsic::ppc_qpx_qvlfcs:
15009 case Intrinsic::ppc_qpx_qvlfda:
15010 case Intrinsic::ppc_qpx_qvlfsa:
15011 case Intrinsic::ppc_qpx_qvlfcda:
15012 case Intrinsic::ppc_qpx_qvlfcsa:
15013 case Intrinsic::ppc_qpx_qvlfiwaa:
15014 case Intrinsic::ppc_qpx_qvlfiwza: {
15016 switch (Intrinsic) {
15017 case Intrinsic::ppc_qpx_qvlfda:
15020 case Intrinsic::ppc_qpx_qvlfsa:
15023 case Intrinsic::ppc_qpx_qvlfcda:
15026 case Intrinsic::ppc_qpx_qvlfcsa:
15043 case Intrinsic::ppc_qpx_qvstfd:
15044 case Intrinsic::ppc_qpx_qvstfs:
15045 case Intrinsic::ppc_qpx_qvstfcd:
15046 case Intrinsic::ppc_qpx_qvstfcs:
15047 case Intrinsic::ppc_qpx_qvstfiw:
15048 case Intrinsic::ppc_altivec_stvx:
15049 case Intrinsic::ppc_altivec_stvxl:
15050 case Intrinsic::ppc_altivec_stvebx:
15051 case Intrinsic::ppc_altivec_stvehx:
15052 case Intrinsic::ppc_altivec_stvewx:
15053 case Intrinsic::ppc_vsx_stxvd2x:
15054 case Intrinsic::ppc_vsx_stxvw4x: {
15056 switch (Intrinsic) {
15057 case Intrinsic::ppc_altivec_stvebx:
15060 case Intrinsic::ppc_altivec_stvehx:
15063 case Intrinsic::ppc_altivec_stvewx:
15066 case Intrinsic::ppc_vsx_stxvd2x:
15069 case Intrinsic::ppc_qpx_qvstfd:
15072 case Intrinsic::ppc_qpx_qvstfs:
15075 case Intrinsic::ppc_qpx_qvstfcd:
15078 case Intrinsic::ppc_qpx_qvstfcs:
15095 case Intrinsic::ppc_qpx_qvstfda:
15096 case Intrinsic::ppc_qpx_qvstfsa:
15097 case Intrinsic::ppc_qpx_qvstfcda:
15098 case Intrinsic::ppc_qpx_qvstfcsa:
15099 case Intrinsic::ppc_qpx_qvstfiwa: {
15101 switch (Intrinsic) {
15102 case Intrinsic::ppc_qpx_qvstfda:
15105 case Intrinsic::ppc_qpx_qvstfsa:
15108 case Intrinsic::ppc_qpx_qvstfcda:
15111 case Intrinsic::ppc_qpx_qvstfcsa:
15147 uint64_t
Size,
unsigned DstAlign,
unsigned SrcAlign,
bool IsMemset,
15148 bool ZeroMemset,
bool MemcpyStrSrc,
15153 if (Subtarget.hasQPX() && Size >= 32 && (!IsMemset || Size >= 64) &&
15154 (!SrcAlign || SrcAlign >= 32) && (!DstAlign || DstAlign >= 32) &&
15161 if (Subtarget.hasAltivec() && Size >= 16 &&
15162 (((!SrcAlign || SrcAlign >= 16) && (!DstAlign || DstAlign >= 16)) ||
15163 ((IsMemset && Subtarget.hasVSX()) || Subtarget.hasP8Vector())))
15167 if (Subtarget.isPPC64()) {
15181 return !(BitSize == 0 || BitSize > 64);
15189 return NumBits1 == 64 && NumBits2 == 32;
15197 return NumBits1 == 64 && NumBits2 == 32;
15204 EVT MemVT =
LD->getMemoryVT();
15206 (Subtarget.isPPC64() && MemVT ==
MVT::i32)) &&
15222 "invalid fpext types");
15241 bool *
Fast)
const {
15258 if (Subtarget.hasVSX()) {
15302 static const MCPhysReg ScratchRegs[] = {
15303 PPC::X12, PPC::LR8, PPC::CTR8, 0
15306 return ScratchRegs;
15310 const Constant *PersonalityFn)
const {
15311 return Subtarget.isPPC64() ? PPC::X3 : PPC::R3;
15315 const Constant *PersonalityFn)
const {
15316 return Subtarget.isPPC64() ? PPC::X4 :
PPC::R4;
15321 EVT VT ,
unsigned DefinedValues)
const {
15323 return Subtarget.hasDirectMove();
15325 if (Subtarget.hasVSX() || Subtarget.hasQPX())
15346 if (Subtarget.isDarwinABI())
return;
15347 if (!Subtarget.isPPC64())
return;
15368 RC = &PPC::G8RCRegClass;
15369 else if (PPC::F8RCRegClass.
contains(*
I))
15370 RC = &PPC::F8RCRegClass;
15371 else if (PPC::CRRCRegClass.
contains(*
I))
15372 RC = &PPC::CRRCRegClass;
15373 else if (PPC::VRRCRegClass.
contains(*
I))
15374 RC = &PPC::VRRCRegClass;
15385 Attribute::NoUnwind) &&
15386 "Function should be nounwind in insertCopiesSplitCSR!");
15392 for (
auto *Exit : Exits)
15394 TII->
get(TargetOpcode::COPY), *
I)
15401 if (!Subtarget.isTargetLinux())
15408 if (!Subtarget.isTargetLinux())
15413 bool ForCodeSize)
const {
15414 if (!VT.
isSimple() || !Subtarget.hasVSX())
15438 unsigned TargetOpcode;
15457 if (
Mask->getZExtValue() == OpSizeInBits - 1)
15463 SDValue PPCTargetLowering::combineSHL(
SDNode *N, DAGCombinerInfo &DCI)
const {
15469 if (!Subtarget.isISA3_0() ||
15493 SDValue PPCTargetLowering::combineSRA(
SDNode *N, DAGCombinerInfo &DCI)
const {
15500 SDValue PPCTargetLowering::combineSRL(
SDNode *N, DAGCombinerInfo &DCI)
const {
15519 auto isZextOfCompareWithConstant = [](
SDValue Op) {
15530 int64_t NegConstant = 0 -
Constant->getSExtValue();
15539 bool LHSHasPattern = isZextOfCompareWithConstant(LHS);
15540 bool RHSHasPattern = isZextOfCompareWithConstant(RHS);
15543 if (LHSHasPattern && !RHSHasPattern)
15545 else if (!LHSHasPattern && !RHSHasPattern)
15555 int64_t NegConstant = 0 -
Constant->getSExtValue();
15557 switch(cast<CondCodeSDNode>(Cmp.
getOperand(2))->
get()) {
15594 SDValue PPCTargetLowering::combineADD(
SDNode *N, DAGCombinerInfo &DCI)
const {
15611 DAGCombinerInfo &DCI)
const {
15613 if (Subtarget.useCRBits()) {
15615 if (
SDValue CRTruncValue = DAGCombineTruncBoolExt(N, DCI))
15616 return CRTruncValue;
15626 int EltToExtract = DCI.DAG.getDataLayout().isBigEndian() ? 1 : 0;
15636 EltToExtract = EltToExtract ? 0 : 1;
15646 return DCI.DAG.getNode(
15648 DCI.DAG.getTargetConstant(EltToExtract, dl,
MVT::i32));
15653 SDValue PPCTargetLowering::combineMUL(
SDNode *N, DAGCombinerInfo &DCI)
const {
15657 if (!ConstOpOrElement)
15665 auto IsProfitable = [
this](
bool IsNeg,
bool IsAddOne,
EVT VT) ->
bool {
15666 switch (this->Subtarget.getCPUDirective()) {
15687 return IsAddOne && IsNeg ? VT.isVector() :
true;
15698 if ((MulAmtAbs - 1).isPowerOf2()) {
15702 if (!IsProfitable(IsNeg,
true, VT))
15708 DAG.
getConstant((MulAmtAbs - 1).logBase2(), DL, VT));
15715 }
else if ((MulAmtAbs + 1).isPowerOf2()) {
15719 if (!IsProfitable(IsNeg,
false, VT))
15725 DAG.
getConstant((MulAmtAbs + 1).logBase2(), DL, VT));
15737 bool PPCTargetLowering::mayBeEmittedAsTailCall(
const CallInst *CI)
const {
15739 if (!Subtarget.is64BitELFABI())
15749 if (!TM.Options.GuaranteedTailCallOpt &&
DisableSCO)
15754 if (!Callee || Callee->
isVarArg())
15767 bool PPCTargetLowering::hasBitPreservingFPLogic(
EVT VT)
const {
15768 if (!Subtarget.hasVSX())
15770 if (Subtarget.hasP9Vector() && VT ==
MVT::f128)
15776 bool PPCTargetLowering::
15777 isMaskAndCmp0FoldingBeneficial(
const Instruction &AndI)
const {
15780 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(Mask)) {
15782 if (CI->getBitWidth() > 64)
15784 int64_t ConstVal = CI->getZExtValue();
15786 (
isUInt<16>(ConstVal >> 16) && !(ConstVal & 0xFFFF));
15798 SDValue PPCTargetLowering::combineABS(
SDNode *N, DAGCombinerInfo &DCI)
const {
15800 assert(Subtarget.hasP9Altivec() &&
15801 "Only combine this when P9 altivec supported!");
15842 DAGCombinerInfo &DCI)
const {
15844 assert(Subtarget.hasP9Altivec() &&
15845 "Only combine this when P9 altivec supported!");
15892 CmpOpnd1, CmpOpnd2,
15893 DAG.getTargetConstant(0, dl,
MVT::i32));
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
unsigned descriptorEnvironmentPointerOffset() const
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.
APInt abs() const
Get the absolute value;.
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...
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
StringRef getSection() const
Get the custom section of this global if it has one.
static MVT getIntegerVT(unsigned BitWidth)
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values i...
const MachineInstrBuilder & add(const MachineOperand &MO) const
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.
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg If BaseGV is null...
FastISel * createFastISel(FunctionLoweringInfo &FuncInfo, const TargetLibraryInfo *LibInfo)
bool isInteger() const
Return true if this is an integer or a vector integer type.
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)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
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...
static CCValAssign getCustomReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP)
const GlobalValue * getGlobal() const
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant, which is required to be operand #1) half of the integer or float value specified as operand #0.
uint64_t getZExtValue() const
Get zero extended value.
bool isAccessedAsGotIndirect(SDValue N) const
static void buildCallOperands(SmallVectorImpl< SDValue > &Ops, CallingConv::ID CallConv, const SDLoc &dl, bool isTailCall, bool isVarArg, bool isPatchPoint, bool hasNest, SelectionDAG &DAG, SmallVector< std::pair< unsigned, SDValue >, 8 > &RegsToPass, SDValue Glue, SDValue Chain, SDValue &Callee, int SPDiff, const PPCSubtarget &Subtarget, bool isIndirect)
unsigned MaxLoadsPerMemcmpOptSize
Likewise for functions with the OptSize attribute.
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.
StackOffset is a wrapper around scalable and non-scalable offsets and is used in several functions su...
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.
Wrapper class representing physical registers. Should be passed by value.
bool preferIncOfAddToSubOfNot(EVT VT) const override
These two forms are equivalent: sub y, (xor x, -1) add (add x, 1), y The variant with two add's is IR...
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)...
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)
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
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.
This class represents lattice values for constants.
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...
Register getLocReg() const
bool isOperationCustom(unsigned Op, EVT VT) const
Return true if the operation uses custom lowering, regardless of whether the type is legal or not...
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.
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
int getSplatIndex() const
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
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
unsigned getSizeInBits(Register Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
MCRegister getStackPointerRegister() const
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...
unsigned getLoopDepth() const
Return the nesting level of this loop.
Extract SPE register component, second argument is high or low.
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()
void push_back(const T &Elt)
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...
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
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.
static SDValue widenVec(SelectionDAG &DAG, SDValue Vec, const SDLoc &dl)
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)
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
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)
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Get a value with low bits set.
bool SelectAddressRegReg(SDValue N, SDValue &Base, SDValue &Index, SelectionDAG &DAG, unsigned EncodingAlignment=0) const
SelectAddressRegReg - Given the specified addressed, check to see if it can be more efficiently repre...
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
QBRC, CHAIN = QVLFSb CHAIN, Ptr The 4xf32 load used for v4i1 constants.
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.
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
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)
C - The default llvm calling convention, compatible with C.
bool SelectAddressRegImm(SDValue N, SDValue &Disp, SDValue &Base, SelectionDAG &DAG, unsigned EncodingAlignment) const
SelectAddressRegImm - Returns true if the address N can be represented by a base register plus a sign...
constexpr bool isInt< 16 >(int64_t x)
STATISTIC(NumFunctions, "Total number of functions")
static RegisterPass< DebugifyModulePass > DM("debugify", "Attach debug info to everything")
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
MachineModuleInfo & getMMI() const
TypeSize getScalarValueSizeInBits() const
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
CALL - A direct function call.
[US]{MIN/MAX} - Binary minimum or maximum or signed or unsigned integers.
const SDNodeFlags getFlags() const
CHAIN,FLAG = BCTRL(CHAIN, INFLAG) - Directly corresponds to a BCTRL instruction.
MachineFunction & getMachineFunction() const
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
bool isVectorTy() const
True if this is an instance of VectorType.
static 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...
SDValue getConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offs=0, bool isT=false, unsigned TargetFlags=0)
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...
bool isByteSized() const
Return true if the bit size is a multiple of 8.
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
static cl::opt< bool > DisableInnermostLoopAlign32("disable-ppc-innermost-loop-align32", cl::desc("don't always align innermost loop to 32 bytes on ppc"), cl::Hidden)
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.
static SDValue truncateScalarIntegerArg(ISD::ArgFlagsTy Flags, EVT ValVT, SelectionDAG &DAG, SDValue ArgValue, MVT LocVT, const SDLoc &dl)
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)
Newer FCFID[US] integer-to-floating-point conversion instructions for unsigned integers and single-pr...
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
unsigned getVarArgsNumGPR() const
int getReturnAddrSaveIndex() const
StringSwitch & Case(StringLiteral S, T Value)
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.
SDValue getMCSymbol(MCSymbol *Sym, EVT VT)
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...
LegalityPredicate isVector(unsigned TypeIdx)
True iff the specified type index is a vector.
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.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
bool isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind, SelectionDAG &DAG)
isVPKUHUMShuffleMask - Return true if this is the shuffle mask for a VPKUHUM instruction.
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...
BUILD_SPE64 and EXTRACT_SPE are analogous to BUILD_PAIR and EXTRACT_ELEMENT but take f64 arguments in...
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.
Value * getArgOperand(unsigned i) const
unsigned countTrailingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the least significant bit to the most stopping at the first 1...
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
static SDValue transformCallee(const SDValue &Callee, SelectionDAG &DAG, const SDLoc &dl, const PPCSubtarget &Subtarget)
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations...
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
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...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const HexagonInstrInfo * TII
ConstantSDNode * isConstOrConstSplat(SDValue N, bool AllowUndefs=false, bool AllowTruncation=false)
Returns the SDNode if it is a constant splat BuildVector or constant int.
static Type * getFloatTy(LLVMContext &C)
bool isAfterLegalizeDAG() const
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
unsigned getSplatIdxForPPCMnemonics(SDNode *N, unsigned EltSize, SelectionDAG &DAG)
getSplatIdxForPPCMnemonics - Return the splat index as a value that is appropriate for PPC mnemonics ...
G8RC = ADDI_TLSGD_L_ADDR G8RReg, Symbol, Symbol - Op that combines ADDI_TLSGD_L and GET_TLS_ADDR unti...
Shift and rotation operations.
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
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...
ValTy * getCalledValue() const
Return the pointer to function that is being called.
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.
void addLoc(const CCValAssign &V)
bool isIntegerTy() const
True if this is an instance of IntegerType.
op_iterator op_end() 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.
LLVM_NODISCARD R Default(T Value)
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 ...
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags=0)
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...
bool isInConsecutiveRegs() const
CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of a call sequence, and carry arbitrary information that target might want to know.
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...
TypeSize getValueSizeInBits() const
Returns the size of the value in bits.
const DataLayout & getDataLayout() const
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
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...
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.
bool is64BitELFABI() const
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...
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.
Context object for machine code objects.
static const unsigned PerfectShuffleTable[6561+1]
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...
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
unsigned NoNaNsFPMath
NoNaNsFPMath - This flag is enabled when the -enable-no-nans-fp-math flag is specified on the command...
An SDNode for Power9 vector absolute value difference.
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)...
virtual const TargetRegisterClass * getRegClassFor(MVT VT, bool isDivergent=false) const
Return the register class that should be used for the specified value type.
SDValue getRegisterMask(const uint32_t *RegMask)
unsigned MaxLoadsPerMemcmp
Specify maximum number of load instructions per memcmp call.
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
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
const MCContext & getContext() const
R32 = MFOCRF(CRREG, INFLAG) - Represents the MFOCRF instruction.
void setMinFunctionAlignment(Align Alignment)
Set the target's minimum function alignment.
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
bool isMustTailCall() const
Tests if this call site must be tail call optimized.
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type. ...
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false)
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
CHAIN = STXVD2X CHAIN, VSRC, Ptr - Occurs only for little endian.
LLVM_NODISCARD size_t size() const
size - Get the string size.
unsigned descriptorTOCAnchorOffset() const
bool isLittleEndian() const
Layout endianness...
static SDValue combineBVOfConsecutiveLoads(SDNode *N, SelectionDAG &DAG)
Reduce the number of loads when building a vector.
const PPCTargetMachine & getTargetMachine() const
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 and AIX...
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
op_iterator op_begin() const
Align getPrefLoopAlignment(MachineLoop *ML) const override
Return the preferred loop alignment.
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
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 isFPImmLegal(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns true if the target can instruction select the specified FP immediate natively.
bool isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
const_iterator end() const
bool hasInvariantFunctionDescriptors() const
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.
bool usesFunctionDescriptors() const
True if the ABI is descriptor based.
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
Analysis containing CSE Info
VSRC, CHAIN = LD_SPLAT, CHAIN, Ptr - a splatting load memory instructions such as LXVDSX...
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.
static void prepareIndirectCall(SelectionDAG &DAG, SDValue &Callee, SDValue &Glue, SDValue &Chain, const SDLoc &dl)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
bool CC_PPC32_SVR4_ByVal(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
void setPrefFunctionAlignment(Align Alignment)
Set the target's preferred function alignment.
static CCValAssign getReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP)
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.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
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.
void setPrefLoopAlignment(Align Alignment)
Set the target's preferred loop alignment.
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.
static SDValue combineADDToADDZE(SDNode *N, SelectionDAG &DAG, const PPCSubtarget &Subtarget)
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
bool isNegative() const
Determine sign of this APInt.
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...
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
int64_t getOffset() const
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, T Value)
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
MachineBasicBlock * EmitAtomicBinary(MachineInstr &MI, MachineBasicBlock *MBB, unsigned AtomicSize, unsigned BinOpcode, unsigned CmpOpcode=0, unsigned CmpPred=0) const
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.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
bool isXXBRQShuffleMask(ShuffleVectorSDNode *N)
isXXBRQShuffleMask - Return true if this is a shuffle mask suitable for a XXBRQ instruction.
LLVM Basic Block Representation.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
XSMAXCDP, XSMINCDP - C-type min/max instructions.
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.
static cl::opt< bool > UseAbsoluteJumpTables("ppc-use-absolute-jumptables", cl::desc("use absolute jump tables on ppc"), cl::Hidden)
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.
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.
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...
ConstantFP - Floating Point Values [float, double].
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
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 isScalarInteger() const
Return true if this is an integer, not including vectors.
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
virtual Align getPrefLoopAlignment(MachineLoop *ML=nullptr) const
Return the preferred loop alignment.
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 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...
static void prepareDescriptorIndirectCall(SelectionDAG &DAG, SDValue &Callee, SDValue &Glue, SDValue &Chain, SDValue CallSeqStart, ImmutableCallSite CS, const SDLoc &dl, bool hasNest, const PPCSubtarget &Subtarget)
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...
static bool usePartialVectorLoads(SDNode *N, const PPCSubtarget &ST)
Returns true if we should use a direct load into vector instruction (such as lxsd or lfd)...
void setVarArgsFrameIndex(int Index)
static bool isValidAIXExternalSymSDNode(StringRef SymName)
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
TRAP - Trapping instruction.
const APInt & getAPIntValue() const
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
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...
GPRC, CHAIN = LFIWAX CHAIN, Ptr - This is a floating-point load which sign-extends from a 32-bit inte...
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.
unsigned getCPUDirective() const
getCPUDirective - Returns the -m directive specified for the cpu.
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()
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.
VSRC, CHAIN = LOAD_VEC_BE CHAIN, Ptr - Occurs only for little endian.
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 number of store instructions per memmove call.
const MachineInstrBuilder & addFrameIndex(int Idx) const
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo...
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
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.
static constexpr const Align None()
Returns a default constructed Align which corresponds to no alignment.
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...
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isLittleEndian() const
This structure contains all information that is necessary for lowering calls.
bool isPositionIndependent() const
EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc, const AttributeList &FuncAttributes) const override
getOptimalMemOpType - Returns the target specific optimal type for load and store operations as a res...
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.
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
#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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
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.
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned TargetFlags=0)
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.
FP_EXTEND_HALF(VECTOR, IDX) - Custom extend upper (IDX=0) half or lower (IDX=1) half of v4f32 to v2f6...
bool CC_PPC32_SVR4(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
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.
static SDValue getOutputChainFromCallSeq(SDValue CallSeqStart)
TokenFactor - This node takes multiple tokens as input and produces a single token result...
QBFLT = Access the underlying QPX floating-point boolean representation.
EXTSWSLI = The PPC extswsli instruction, which does an extend-sign word and shift left immediate...
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
SDValue getTargetConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offset=0, unsigned TargetFlags=0)
Iterator for intrusive lists based on ilist_node.
static 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...
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
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...
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
Align max(MaybeAlign Lhs, Align Rhs)
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.
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...
SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
MachineOperand class - Representation of each machine instruction operand.
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 is32BitELFABI() const
CCValAssign - Represent assignment of one arg/retval to a location.
unsigned arg_size() const
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.
static bool CC_AIX(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
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.
FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimum or maximum on two values, following the IEEE-754 2008 definition.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
static SectionKind getMetadata()
Promote Memory to Register
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.
Register getRegisterByName(const char *RegName, LLT VT, const MachineFunction &MF) const override
Return the register ID of the name passed in.
const char * getTargetNodeName(unsigned Opcode) const override
getTargetNodeName() - This method returns the name of a target specific DAG node. ...
const Constant * getConstVal() const
TypeSize getScalarSizeInBits() 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...
User::const_op_iterator arg_iterator
The type of iterator to use when looping over actual arguments at this call site. ...
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.
MachinePointerInfo getWithOffset(int64_t O) const
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
TypeSize getValueSizeInBits(unsigned ResNo) const
Returns MVT::getSizeInBits(getValueType(ResNo)).
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
bool CC_PPC32_SVR4_VarArg(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
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.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
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()
amdgpu Simplify well known AMD library false FunctionCallee Callee
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).
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()
ZERO_EXTEND - Used for integer types, zeroing the new bits.
unsigned getTOCSaveOffset() const
getTOCSaveOffset - Return the previous frame offset to save the TOC register – 64-bit SVR4 ABI only...
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...
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
Scheduling customization.
Flags
Flags values. These may be or'd together.
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.
const std::vector< LoopT * > & getSubLoops() const
Return the loops contained entirely within this loop.
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.
bool hasContainingCsect() const
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.
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.
unsigned AllocateStack(unsigned Size, unsigned Alignment)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
MCRegister getTOCPointerRegister() const
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.
static unsigned getCallOpcode(bool isIndirectCall, bool isPatchPoint, bool isTailCall, const Function &Caller, const SDValue &Callee, const PPCSubtarget &Subtarget, const TargetMachine &TM)
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...
bool SelectAddressEVXRegReg(SDValue N, SDValue &Base, SDValue &Index, SelectionDAG &DAG) const
SelectAddressEVXRegReg - Given the specified addressed, check to see if it can be more efficiently re...
bool isPositionIndependent() const
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
CallingConv::ID getCallingConv() const
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
StringRef getName() const
Return a constant reference to the value's name.
Establish a view to a call site for examination.
int64_t getOffset() const
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
const Function * getParent() const
Return the enclosing method, or null if none.
CHAIN = STORE_VEC_BE CHAIN, VSRC, Ptr - Occurs only for little endian.
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).
const MachineInstrBuilder & cloneMemRefs(const MachineInstr &OtherMI) const
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
The memory access always returns the same value (or traps).
unsigned MaxStoresPerMemmoveOptSize
Likewise for functions with the OptSize attribute.
unsigned MaxStoresPerMemcpyOptSize
Likewise for functions with the OptSize attribute.
void setStackPointerRegisterToSaveRestore(unsigned R)
If set to a physical register, this specifies the register that llvm.savestack/llvm.restorestack should save and restore.
static const SDValue * getNormalLoadInput(const SDValue &Op)
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.
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)
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
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.
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 number of store instructions per memcpy call.
constexpr bool isUInt< 16 >(uint64_t x)
void setMinStackArgumentAlignment(Align Alignment)
Set the minimum stack alignment of an argument.
bool isDarwin() const
isDarwin - True if this is any darwin platform.
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.
MCRegister getEnvironmentPointerRegister() const
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.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
StringRef getName() const
getName - Get the symbol name.
const MachinePointerInfo & getPointerInfo() const
VSRC, CHAIN = XXSWAPD CHAIN, VSRC - Occurs only for little endian.
SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, unsigned Align=0, MachineMemOperand::Flags Flags=MachineMemOperand::MOLoad|MachineMemOperand::MOStore, uint64_t Size=0, const AAMDNodes &AAInfo=AAMDNodes())
Creates a MemIntrinsicNode that may produce a result and takes a list of operands.
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.
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
bool hasFnAttribute(Attribute::AttrKind Kind) const
Equivalent to hasAttribute(AttributeList::FunctionIndex, Kind) but may be faster. ...
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
bool isSplatValue(SDValue V, const APInt &DemandedElts, APInt &UndefElts)
Test whether V has a splatted value for all the demanded elements.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, unsigned Alignment=0, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
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.
i1 = ANDI_rec_1_[EQ|GT]_BIT(i32 or i64 x) - Represents the result of the eq or gt bit of CR0 after ex...
static SDValue combineBVOfVecSExt(SDNode *N, SelectionDAG &DAG)
void setReturnAddressIsTaken(bool s)
bool isPredecessorOf(const SDNode *N) const
Return true if this node is a predecessor of N.
int CreateStackObject(uint64_t Size, Align 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...
TypeSize getScalarSizeInBits() const
Direct move of 2 consecutive 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.
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)
Fast - This calling convention attempts to make calls as fast as possible (e.g.
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...
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 ...
bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF, EVT VT) const override
isFMAFasterThanFMulAndFAdd - Return true if an FMA operation is faster than a pair of fmul and fadd i...
const MDNode * getRanges() const
Returns the Ranges that describes the dereference.
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...
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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
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...
void setContainingCsect(MCSectionXCOFF *C)
Primary interface to the complete machine description for the target machine.
static mvt_range fixedlen_vector_valuetypes()
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...
VSRC, CHAIN = LD_VSX_LH CHAIN, Ptr - This is a floating-point load of a v2f32 value into the lower ha...
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.
static bool isIndirectCall(const SDValue &Callee, SelectionDAG &DAG, const PPCSubtarget &Subtarget, bool isPatchPoint)
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
Likewise for functions with the OptSize attribute.
static BranchProbability getZero()
KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
unsigned getNumOperands() const
Register getReg() const
getReg - Returns the register number.
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.
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.
bool RetCC_PPC_Cold(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
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.
static const TargetRegisterClass * getRegClassForSVT(MVT::SimpleValueType SVT, bool IsPPC64)
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
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
Perform various unary floating-point operations inspired by libm.
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...
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
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.
static XCOFF::StorageClass getStorageClassForGlobal(const GlobalObject *GO)
GPRC, CHAIN = LFIWZX CHAIN, Ptr - This is a floating-point load which zero-extends from a 32-bit inte...
static bool is64Bit(const char *name)
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...
bool RetCC_PPC(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
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
static bool hasSameArgumentList(const Function *CallerFn, ImmutableCallSite CS)
Wrapper class representing virtual and physical registers.
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
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 ...
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...
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace, unsigned Align=1, MachineMemOperand::Flags Flags=MachineMemOperand::MONone, bool *Fast=nullptr) const override
Is unaligned memory access allowed for the given type, and is it fast relative to software emulation...
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