69#include "llvm/IR/IntrinsicsPowerPC.h"
103#define DEBUG_TYPE "ppc-lowering"
106 "disable-p10-store-forward",
130 cl::desc(
"disable vector permute decomposition"),
134 "disable-auto-paired-vec-st",
135 cl::desc(
"disable automatically generated 32byte paired vector stores"),
140 cl::desc(
"Set minimum number of entries to use a jump table on PPC"));
144 cl::desc(
"Set minimum of largest number of comparisons to use bit test for "
149 cl::desc(
"max depth when checking alias info in GatherAllAliases()"));
153 cl::desc(
"Set inclusive limit count of TLS local-dynamic access(es) in a "
154 "function to use initial-exec"));
159 "Number of shuffles lowered to a VPERM or XXPERM");
160STATISTIC(NumDynamicAllocaProbed,
"Number of dynamic stack allocation probed");
181 initializeAddrModeMap();
184 bool isPPC64 = Subtarget.isPPC64();
186 const MVT RegVT = Subtarget.getScalarIntVT();
194 if (!Subtarget.hasEFPU2())
211 if (!Subtarget.hasP10Vector()) {
240 if (Subtarget.isISA3_0()) {
273 if (!Subtarget.hasSPE()) {
280 if (Subtarget.useCRBits()) {
283 if (isPPC64 || Subtarget.hasFPCVT()) {
349 if (Subtarget.isISA3_0()) {
384 if (!Subtarget.hasSPE()) {
389 if (Subtarget.hasVSX()) {
394 if (Subtarget.hasFSQRT()) {
399 if (Subtarget.hasFPRND()) {
440 if (Subtarget.hasSPE()) {
450 if (Subtarget.hasSPE())
454 if (!Subtarget.hasFSQRT() && !(Subtarget.hasFRSQRTE() && Subtarget.hasFRE()))
457 if (!Subtarget.hasFSQRT() &&
458 !(Subtarget.hasFRSQRTES() && Subtarget.hasFRES()))
461 if (Subtarget.hasFCPSGN()) {
469 if (Subtarget.hasFPRND()) {
483 if (Subtarget.isISA3_1()) {
489 (Subtarget.hasP9Vector() && isPPC64) ?
Custom :
Expand);
493 if (Subtarget.isISA3_0()) {
513 if (!Subtarget.useCRBits()) {
526 if (!Subtarget.useCRBits())
529 if (Subtarget.hasFPU()) {
540 if (!Subtarget.useCRBits())
545 if (Subtarget.hasSPE()) {
569 if (Subtarget.hasDirectMove() && isPPC64) {
629 if (Subtarget.is64BitELFABI()) {
640 }
else if (Subtarget.is32BitELFABI()) {
648 if (Subtarget.is32BitELFABI())
664 if (Subtarget.isISA3_0() && isPPC64) {
692 if (Subtarget.hasSPE()) {
714 if (Subtarget.has64BitSupport()) {
729 if (Subtarget.hasLFIWAX() || isPPC64) {
735 if (Subtarget.hasSPE()) {
745 if (Subtarget.hasFPCVT()) {
746 if (Subtarget.has64BitSupport()) {
767 if (Subtarget.use64BitRegs()) {
785 if (Subtarget.has64BitSupport()) {
792 if (Subtarget.hasVSX()) {
805 if (Subtarget.hasAltivec()) {
806 for (
MVT VT : { MVT::v16i8, MVT::v8i16, MVT::v4i32 }) {
823 if (VT.getSizeInBits() <= 128 && VT.getScalarSizeInBits() <= 64) {
836 if (Subtarget.hasVSX()) {
845 if (Subtarget.hasP8Altivec() && (VT.SimpleTy != MVT::v1i128)) {
855 if (Subtarget.hasP9Altivec() && (VT.SimpleTy != MVT::v1i128))
929 if (!Subtarget.hasP8Vector()) {
971 if (Subtarget.hasAltivec())
972 for (
auto VT : {MVT::v4i32, MVT::v8i16, MVT::v16i8})
975 if (Subtarget.hasP8Altivec())
986 if (Subtarget.hasVSX()) {
992 if (Subtarget.hasP8Altivec())
997 if (Subtarget.isISA3_1()) {
1043 if (Subtarget.hasVSX()) {
1046 if (Subtarget.hasP8Vector()) {
1050 if (Subtarget.hasDirectMove() && isPPC64) {
1099 if (Subtarget.hasP8Vector())
1108 if (Subtarget.hasP8Altivec()) {
1135 if (Subtarget.isISA3_1())
1238 if (Subtarget.hasP8Altivec()) {
1243 if (Subtarget.hasP9Vector()) {
1248 if (Subtarget.useCRBits()) {
1308 }
else if (Subtarget.hasVSX()) {
1333 for (
MVT VT : {MVT::f32, MVT::f64}) {
1352 if (Subtarget.hasP9Altivec()) {
1353 if (Subtarget.isISA3_1()) {
1376 if (Subtarget.hasP10Vector()) {
1381 if (Subtarget.pairedVectorMemops()) {
1386 if (Subtarget.hasMMA()) {
1387 if (Subtarget.isISAFuture()) {
1403 if (Subtarget.has64BitSupport())
1406 if (Subtarget.isISA3_1())
1424 if (Subtarget.hasAltivec()) {
1442 if (Subtarget.hasFPCVT())
1445 if (Subtarget.useCRBits())
1454 if (Subtarget.useCRBits()) {
1458 if (Subtarget.hasP8Vector())
1463 if (Subtarget.useCRBits()) {
1479 auto CPUDirective = Subtarget.getCPUDirective();
1480 switch (CPUDirective) {
1503 if (Subtarget.enableMachineScheduler())
1577void PPCTargetLowering::initializeAddrModeMap() {
1628 if (MaxAlign == MaxMaxAlign)
1631 if (MaxMaxAlign >= 32 &&
1632 VTy->getPrimitiveSizeInBits().getFixedValue() >= 256)
1633 MaxAlign =
Align(32);
1634 else if (VTy->getPrimitiveSizeInBits().getFixedValue() >= 128 &&
1636 MaxAlign =
Align(16);
1640 if (EltAlign > MaxAlign)
1641 MaxAlign = EltAlign;
1643 for (
auto *EltTy : STy->elements()) {
1646 if (EltAlign > MaxAlign)
1647 MaxAlign = EltAlign;
1648 if (MaxAlign == MaxMaxAlign)
1661 if (Subtarget.hasAltivec())
1667 return Subtarget.useSoftFloat();
1671 return Subtarget.hasSPE();
1679 Type *VectorTy,
unsigned ElemSizeInBits,
unsigned &Index)
const {
1680 if (!Subtarget.isPPC64() || !Subtarget.hasVSX())
1684 if (VTy->getScalarType()->isIntegerTy()) {
1686 if (ElemSizeInBits == 32) {
1687 Index = Subtarget.isLittleEndian() ? 2 : 1;
1690 if (ElemSizeInBits == 64) {
1691 Index = Subtarget.isLittleEndian() ? 1 : 0;
1702 return Subtarget.useCRBits() ? MVT::i1 : MVT::i32;
1719 return CFP->getValueAPF().isZero();
1724 return CFP->getValueAPF().isZero();
1732 return Op < 0 ||
Op == Val;
1744 if (ShuffleKind == 0) {
1747 for (
unsigned i = 0; i != 16; ++i)
1750 }
else if (ShuffleKind == 2) {
1753 for (
unsigned i = 0; i != 16; ++i)
1756 }
else if (ShuffleKind == 1) {
1757 unsigned j = IsLE ? 0 : 1;
1758 for (
unsigned i = 0; i != 8; ++i)
1775 if (ShuffleKind == 0) {
1778 for (
unsigned i = 0; i != 16; i += 2)
1782 }
else if (ShuffleKind == 2) {
1785 for (
unsigned i = 0; i != 16; i += 2)
1789 }
else if (ShuffleKind == 1) {
1790 unsigned j = IsLE ? 0 : 2;
1791 for (
unsigned i = 0; i != 8; i += 2)
1812 if (!Subtarget.hasP8Vector())
1816 if (ShuffleKind == 0) {
1819 for (
unsigned i = 0; i != 16; i += 4)
1825 }
else if (ShuffleKind == 2) {
1828 for (
unsigned i = 0; i != 16; i += 4)
1834 }
else if (ShuffleKind == 1) {
1835 unsigned j = IsLE ? 0 : 4;
1836 for (
unsigned i = 0; i != 8; i += 4)
1853 unsigned LHSStart,
unsigned RHSStart) {
1854 if (
N->getValueType(0) != MVT::v16i8)
1856 assert((UnitSize == 1 || UnitSize == 2 || UnitSize == 4) &&
1857 "Unsupported merge size!");
1859 for (
unsigned i = 0; i != 8/UnitSize; ++i)
1860 for (
unsigned j = 0; j != UnitSize; ++j) {
1862 LHSStart+j+i*UnitSize) ||
1864 RHSStart+j+i*UnitSize))
1879 if (ShuffleKind == 1)
1881 else if (ShuffleKind == 2)
1886 if (ShuffleKind == 1)
1888 else if (ShuffleKind == 0)
1904 if (ShuffleKind == 1)
1906 else if (ShuffleKind == 2)
1911 if (ShuffleKind == 1)
1913 else if (ShuffleKind == 0)
1963 unsigned RHSStartValue) {
1964 if (
N->getValueType(0) != MVT::v16i8)
1967 for (
unsigned i = 0; i < 2; ++i)
1968 for (
unsigned j = 0; j < 4; ++j)
1970 i*RHSStartValue+j+IndexOffset) ||
1972 i*RHSStartValue+j+IndexOffset+8))
1994 unsigned indexOffset = CheckEven ? 4 : 0;
1995 if (ShuffleKind == 1)
1997 else if (ShuffleKind == 2)
2003 unsigned indexOffset = CheckEven ? 0 : 4;
2004 if (ShuffleKind == 1)
2006 else if (ShuffleKind == 0)
2022 if (
N->getValueType(0) != MVT::v16i8)
2029 for (i = 0; i != 16 && SVOp->
getMaskElt(i) < 0; ++i)
2032 if (i == 16)
return -1;
2037 if (ShiftAmt < i)
return -1;
2042 if ((ShuffleKind == 0 && !isLE) || (ShuffleKind == 2 && isLE)) {
2044 for (++i; i != 16; ++i)
2047 }
else if (ShuffleKind == 1) {
2049 for (++i; i != 16; ++i)
2056 ShiftAmt = 16 - ShiftAmt;
2065 EVT VT =
N->getValueType(0);
2066 if (VT == MVT::v2i64 || VT == MVT::v2f64)
2067 return EltSize == 8 &&
N->getMaskElt(0) ==
N->getMaskElt(1);
2070 EltSize <= 8 &&
"Can only handle 1,2,4,8 byte element sizes");
2074 if (
N->getMaskElt(0) % EltSize != 0)
2079 unsigned ElementBase =
N->getMaskElt(0);
2082 if (ElementBase >= 16)
2087 for (
unsigned i = 1; i != EltSize; ++i)
2088 if (
N->getMaskElt(i) < 0 ||
N->getMaskElt(i) != (
int)(i+ElementBase))
2091 for (
unsigned i = EltSize, e = 16; i != e; i += EltSize) {
2093 if (
N->getMaskElt(i) < 0) {
2094 for (
unsigned j = 1; j != EltSize; ++j)
2095 if (
N->getMaskElt(i + j) >= 0)
2098 for (
unsigned j = 0; j != EltSize; ++j)
2099 if (
N->getMaskElt(i + j) !=
N->getMaskElt(j))
2116 assert((Width == 2 || Width == 4 || Width == 8 || Width == 16) &&
2117 "Unexpected element width.");
2118 assert((StepLen == 1 || StepLen == -1) &&
"Unexpected element width.");
2120 unsigned NumOfElem = 16 / Width;
2121 unsigned MaskVal[16];
2122 for (
unsigned i = 0; i < NumOfElem; ++i) {
2123 MaskVal[0] =
N->getMaskElt(i * Width);
2124 if ((StepLen == 1) && (MaskVal[0] % Width)) {
2126 }
else if ((StepLen == -1) && ((MaskVal[0] + 1) % Width)) {
2130 for (
unsigned int j = 1; j < Width; ++j) {
2131 MaskVal[j] =
N->getMaskElt(i * Width + j);
2132 if (MaskVal[j] != MaskVal[j-1] + StepLen) {
2142 unsigned &InsertAtByte,
bool &Swap,
bool IsLE) {
2147 unsigned M0 =
N->getMaskElt(0) / 4;
2148 unsigned M1 =
N->getMaskElt(4) / 4;
2149 unsigned M2 =
N->getMaskElt(8) / 4;
2150 unsigned M3 =
N->getMaskElt(12) / 4;
2151 unsigned LittleEndianShifts[] = { 2, 1, 0, 3 };
2152 unsigned BigEndianShifts[] = { 3, 0, 1, 2 };
2157 if ((
M0 > 3 &&
M1 == 1 && M2 == 2 && M3 == 3) ||
2158 (
M0 < 4 &&
M1 == 5 && M2 == 6 && M3 == 7)) {
2159 ShiftElts = IsLE ? LittleEndianShifts[
M0 & 0x3] : BigEndianShifts[
M0 & 0x3];
2160 InsertAtByte = IsLE ? 12 : 0;
2165 if ((
M1 > 3 &&
M0 == 0 && M2 == 2 && M3 == 3) ||
2166 (
M1 < 4 &&
M0 == 4 && M2 == 6 && M3 == 7)) {
2167 ShiftElts = IsLE ? LittleEndianShifts[
M1 & 0x3] : BigEndianShifts[
M1 & 0x3];
2168 InsertAtByte = IsLE ? 8 : 4;
2173 if ((M2 > 3 &&
M0 == 0 &&
M1 == 1 && M3 == 3) ||
2174 (M2 < 4 &&
M0 == 4 &&
M1 == 5 && M3 == 7)) {
2175 ShiftElts = IsLE ? LittleEndianShifts[M2 & 0x3] : BigEndianShifts[M2 & 0x3];
2176 InsertAtByte = IsLE ? 4 : 8;
2181 if ((M3 > 3 &&
M0 == 0 &&
M1 == 1 && M2 == 2) ||
2182 (M3 < 4 &&
M0 == 4 &&
M1 == 5 && M2 == 6)) {
2183 ShiftElts = IsLE ? LittleEndianShifts[M3 & 0x3] : BigEndianShifts[M3 & 0x3];
2184 InsertAtByte = IsLE ? 0 : 12;
2191 if (
N->getOperand(1).isUndef()) {
2194 unsigned XXINSERTWSrcElem = IsLE ? 2 : 1;
2195 if (
M0 == XXINSERTWSrcElem &&
M1 == 1 && M2 == 2 && M3 == 3) {
2196 InsertAtByte = IsLE ? 12 : 0;
2199 if (
M0 == 0 &&
M1 == XXINSERTWSrcElem && M2 == 2 && M3 == 3) {
2200 InsertAtByte = IsLE ? 8 : 4;
2203 if (
M0 == 0 &&
M1 == 1 && M2 == XXINSERTWSrcElem && M3 == 3) {
2204 InsertAtByte = IsLE ? 4 : 8;
2207 if (
M0 == 0 &&
M1 == 1 && M2 == 2 && M3 == XXINSERTWSrcElem) {
2208 InsertAtByte = IsLE ? 0 : 12;
2217 bool &Swap,
bool IsLE) {
2218 assert(
N->getValueType(0) == MVT::v16i8 &&
"Shuffle vector expects v16i8");
2224 unsigned M0 =
N->getMaskElt(0) / 4;
2225 unsigned M1 =
N->getMaskElt(4) / 4;
2226 unsigned M2 =
N->getMaskElt(8) / 4;
2227 unsigned M3 =
N->getMaskElt(12) / 4;
2231 if (
N->getOperand(1).isUndef()) {
2232 assert(
M0 < 4 &&
"Indexing into an undef vector?");
2233 if (
M1 != (
M0 + 1) % 4 || M2 != (
M1 + 1) % 4 || M3 != (M2 + 1) % 4)
2236 ShiftElts = IsLE ? (4 -
M0) % 4 :
M0;
2242 if (
M1 != (
M0 + 1) % 8 || M2 != (
M1 + 1) % 8 || M3 != (M2 + 1) % 8)
2246 if (
M0 == 0 ||
M0 == 7 ||
M0 == 6 ||
M0 == 5) {
2251 ShiftElts = (8 -
M0) % 8;
2252 }
else if (
M0 == 4 ||
M0 == 3 ||
M0 == 2 ||
M0 == 1) {
2257 ShiftElts = (4 -
M0) % 4;
2262 if (
M0 == 0 ||
M0 == 1 ||
M0 == 2 ||
M0 == 3) {
2267 }
else if (
M0 == 4 ||
M0 == 5 ||
M0 == 6 ||
M0 == 7) {
2279 assert(
N->getValueType(0) == MVT::v16i8 &&
"Shuffle vector expects v16i8");
2284 for (
int i = 0; i < 16; i += Width)
2285 if (
N->getMaskElt(i) != i + Width - 1)
2316 bool &Swap,
bool IsLE) {
2317 assert(
N->getValueType(0) == MVT::v16i8 &&
"Shuffle vector expects v16i8");
2323 unsigned M0 =
N->getMaskElt(0) / 8;
2324 unsigned M1 =
N->getMaskElt(8) / 8;
2325 assert(((
M0 |
M1) < 4) &&
"A mask element out of bounds?");
2329 if (
N->getOperand(1).isUndef()) {
2330 if ((
M0 |
M1) < 2) {
2331 DM = IsLE ? (((
~M1) & 1) << 1) + ((~
M0) & 1) : (
M0 << 1) + (
M1 & 1);
2339 if (
M0 > 1 &&
M1 < 2) {
2349 DM = (((
~M1) & 1) << 1) + ((~
M0) & 1);
2354 }
else if (
M0 > 1 &&
M1 < 2) {
2362 DM = (
M0 << 1) + (
M1 & 1);
2377 if (VT == MVT::v2i64 || VT == MVT::v2f64)
2382 return (16 / EltSize) - 1 - (SVOp->
getMaskElt(0) / EltSize);
2398 unsigned EltSize = 16/
N->getNumOperands();
2399 if (EltSize < ByteSize) {
2400 unsigned Multiple = ByteSize/EltSize;
2402 assert(Multiple > 1 && Multiple <= 4 &&
"How can this happen?");
2405 for (
unsigned i = 0, e =
N->getNumOperands(); i != e; ++i) {
2406 if (
N->getOperand(i).isUndef())
continue;
2410 if (!UniquedVals[i&(Multiple-1)].
getNode())
2411 UniquedVals[i&(Multiple-1)] =
N->getOperand(i);
2412 else if (UniquedVals[i&(Multiple-1)] !=
N->getOperand(i))
2422 bool LeadingZero =
true;
2423 bool LeadingOnes =
true;
2424 for (
unsigned i = 0; i != Multiple-1; ++i) {
2425 if (!UniquedVals[i].
getNode())
continue;
2432 if (!UniquedVals[Multiple-1].
getNode())
2439 if (!UniquedVals[Multiple-1].
getNode())
2450 for (
unsigned i = 0, e =
N->getNumOperands(); i != e; ++i) {
2451 if (
N->getOperand(i).isUndef())
continue;
2453 OpVal =
N->getOperand(i);
2454 else if (OpVal !=
N->getOperand(i))
2460 unsigned ValSizeInBytes = EltSize;
2463 Value = CN->getZExtValue();
2465 assert(CN->getValueType(0) == MVT::f32 &&
"Only one legal FP vector type!");
2472 if (ValSizeInBytes < ByteSize)
return SDValue();
2483 if (MaskVal == 0)
return SDValue();
2503 Imm = (int16_t)
N->getAsZExtVal();
2504 if (
N->getValueType(0) == MVT::i32)
2505 return Imm == (int32_t)
N->getAsZExtVal();
2507 return Imm == (int64_t)
N->getAsZExtVal();
2525 return (~(LHSKnown.
Zero | RHSKnown.
Zero) == 0);
2533 for (
SDNode *U :
N->users()) {
2535 if (Memop->getMemoryVT() == MVT::f64) {
2536 Base =
N.getOperand(0);
2537 Index =
N.getOperand(1);
2580 (!EncodingAlignment ||
isAligned(*EncodingAlignment, Imm)))
2582 if (
N.getOperand(1).getOpcode() == PPCISD::Lo)
2585 Base =
N.getOperand(0);
2586 Index =
N.getOperand(1);
2588 }
else if (
N.getOpcode() ==
ISD::OR) {
2590 (!EncodingAlignment ||
isAligned(*EncodingAlignment, Imm)))
2602 if (~(LHSKnown.
Zero | RHSKnown.
Zero) == 0) {
2603 Base =
N.getOperand(0);
2604 Index =
N.getOperand(1);
2674 (!EncodingAlignment ||
isAligned(*EncodingAlignment, imm))) {
2680 Base =
N.getOperand(0);
2683 }
else if (
N.getOperand(1).getOpcode() == PPCISD::Lo) {
2685 assert(!
N.getOperand(1).getConstantOperandVal(1) &&
2686 "Cannot handle constant offsets yet!");
2687 Disp =
N.getOperand(1).getOperand(0);
2692 Base =
N.getOperand(0);
2695 }
else if (
N.getOpcode() ==
ISD::OR) {
2698 (!EncodingAlignment ||
isAligned(*EncodingAlignment, imm))) {
2712 Base =
N.getOperand(0);
2725 (!EncodingAlignment ||
isAligned(*EncodingAlignment, Imm))) {
2728 CN->getValueType(0));
2733 if ((CN->getValueType(0) == MVT::i32 ||
2734 (int64_t)CN->getZExtValue() == (
int)CN->getZExtValue()) &&
2735 (!EncodingAlignment ||
2736 isAligned(*EncodingAlignment, CN->getZExtValue()))) {
2737 int Addr = (int)CN->getZExtValue();
2744 unsigned Opc = CN->getValueType(0) == MVT::i32 ? PPC::LIS : PPC::LIS8;
2765 if (
N.getValueType() != MVT::i64)
2778 Base =
N.getOperand(0);
2794 Base =
N.getOperand(0);
2827 !
N.getOperand(1).hasOneUse() || !
N.getOperand(0).hasOneUse())) {
2828 Base =
N.getOperand(0);
2829 Index =
N.getOperand(1);
2851 if (
N.getOpcode() == PPCISD::MAT_PCREL_ADDR)
2872 EVT MemVT = LD->getMemoryVT();
2879 if (!ST.hasP8Vector())
2884 if (!ST.hasP9Vector())
2896 if (
Use.getResNo() == 0 &&
2898 Use.
getUser()->getOpcode() != PPCISD::SCALAR_TO_VECTOR_PERMUTED)
2918 Ptr = LD->getBasePtr();
2919 VT = LD->getMemoryVT();
2920 Alignment = LD->getAlign();
2922 Ptr = ST->getBasePtr();
2923 VT = ST->getMemoryVT();
2924 Alignment = ST->getAlign();
2963 if (VT != MVT::i64) {
2968 if (Alignment <
Align(4))
2978 if (LD->getValueType(0) == MVT::i64 && LD->getMemoryVT() == MVT::i32 &&
2995 unsigned &HiOpFlags,
unsigned &LoOpFlags,
3037 EVT VT = Subtarget.getScalarIntVT();
3039 : Subtarget.isAIXABI()
3044 PPCISD::TOC_ENTRY, dl, DAG.
getVTList(VT, MVT::Other),
Ops, VT,
3051 EVT PtrVT =
Op.getValueType();
3057 if (Subtarget.is64BitELFABI() || Subtarget.isAIXABI()) {
3058 if (Subtarget.isUsingPCRelativeCalls()) {
3063 return DAG.
getNode(PPCISD::MAT_PCREL_ADDR,
DL, Ty, ConstPool);
3067 return getTOCEntry(DAG, SDLoc(CP), GA);
3070 unsigned MOHiFlag, MOLoFlag;
3074 if (IsPIC && Subtarget.isSVR4ABI()) {
3077 return getTOCEntry(DAG, SDLoc(CP), GA);
3100 if (Subtarget.isPPC64() || Subtarget.isAIXABI())
3107 if (!Subtarget.isPPC64() || Subtarget.isAIXABI())
3124 if (!Subtarget.isPPC64() || Subtarget.isAIXABI())
3137 EVT PtrVT =
Op.getValueType();
3155 return getTOCEntry(DAG,
SDLoc(JT), GA);
3158 unsigned MOHiFlag, MOLoFlag;
3162 if (IsPIC && Subtarget.isSVR4ABI()) {
3165 return getTOCEntry(DAG, SDLoc(GA), GA);
3175 EVT PtrVT =
Op.getValueType();
3180 if (Subtarget.isUsingPCRelativeCalls()) {
3191 if (Subtarget.is64BitELFABI() || Subtarget.isAIXABI()) {
3194 return getTOCEntry(DAG, SDLoc(BASDN), GA);
3203 unsigned MOHiFlag, MOLoFlag;
3213 if (Subtarget.isAIXABI())
3214 return LowerGlobalTLSAddressAIX(
Op, DAG);
3216 return LowerGlobalTLSAddressLinux(
Op, DAG);
3238 if (
I.getOpcode() == Instruction::Call)
3240 if (
Function *CF = CI->getCalledFunction())
3241 if (CF->isDeclaration() &&
3242 CF->getIntrinsicID() == Intrinsic::threadlocal_address)
3250 unsigned TLSGVCnt = TLSGV.
size();
3260 <<
" function is using the TLS-IE model for TLS-LD access.\n");
3273 const GlobalValue *GV = GA->
getGlobal();
3275 bool Is64Bit = Subtarget.isPPC64();
3279 if (Subtarget.hasAIXShLibTLSModelOpt())
3289 bool HasAIXSmallLocalExecTLS = Subtarget.hasAIXSmallLocalExecTLS();
3290 bool HasAIXSmallTLSGlobalAttr =
false;
3293 SDValue VariableOffset = getTOCEntry(DAG, dl, VariableOffsetTGA);
3297 if (GVar->hasAttribute(
"aix-small-tls"))
3298 HasAIXSmallTLSGlobalAttr =
true;
3317 if ((HasAIXSmallLocalExecTLS || HasAIXSmallTLSGlobalAttr) &&
3318 IsTLSLocalExecModel) {
3323 return DAG.
getNode(PPCISD::Lo, dl, PtrVT, VariableOffsetTGA, TLSReg);
3333 TLSReg = DAG.
getNode(PPCISD::GET_TPOINTER, dl, PtrVT);
3338 if (HasAIXSmallLocalExecTLS || HasAIXSmallTLSGlobalAttr)
3340 "currently only supported on AIX (64-bit mode).");
3342 return DAG.
getNode(PPCISD::ADD_TLS, dl, PtrVT, TLSReg, VariableOffset);
3346 bool HasAIXSmallLocalDynamicTLS = Subtarget.hasAIXSmallLocalDynamicTLS();
3350 if (!Is64Bit && HasAIXSmallLocalDynamicTLS)
3352 "currently only supported on AIX (64-bit mode).");
3360 SDValue VariableOffset = getTOCEntry(DAG, dl, VariableOffsetTGA);
3363 GlobalVariable *TLSGV =
3367 assert(TLSGV &&
"Not able to create GV for _$TLSML.");
3370 SDValue ModuleHandleTOC = getTOCEntry(DAG, dl, ModuleHandleTGA);
3372 DAG.
getNode(PPCISD::TLSLD_AIX, dl, PtrVT, ModuleHandleTOC);
3381 if (HasAIXSmallLocalDynamicTLS) {
3386 return DAG.
getNode(PPCISD::Lo, dl, PtrVT, VariableOffsetTGA,
3390 return DAG.
getNode(
ISD::ADD, dl, PtrVT, ModuleHandle, VariableOffset);
3403 SDValue VariableOffset = getTOCEntry(DAG, dl, VariableOffsetTGA);
3404 SDValue RegionHandle = getTOCEntry(DAG, dl, RegionHandleTGA);
3405 return DAG.
getNode(PPCISD::TLSGD_AIX, dl, PtrVT, VariableOffset,
3420 const GlobalValue *GV = GA->
getGlobal();
3422 bool is64bit = Subtarget.isPPC64();
3430 if (Subtarget.isUsingPCRelativeCalls()) {
3435 DAG.
getNode(PPCISD::TLS_LOCAL_EXEC_MAT_ADDR, dl, PtrVT, TGA);
3436 return DAG.
getNode(PPCISD::ADD_TLS, dl, PtrVT, TLSReg, MatAddr);
3447 return DAG.
getNode(PPCISD::Lo, dl, PtrVT, TGALo,
Hi);
3451 bool IsPCRel = Subtarget.isUsingPCRelativeCalls();
3458 SDValue MatPCRel = DAG.
getNode(PPCISD::MAT_PCREL_ADDR, dl, PtrVT, TGA);
3460 MachinePointerInfo());
3467 DAG.
getNode(PPCISD::ADDIS_GOT_TPREL_HA, dl, PtrVT, GOTReg, TGA);
3469 if (!TM.isPositionIndependent())
3470 GOTPtr = DAG.
getNode(PPCISD::PPC32_GOT, dl, PtrVT);
3476 TPOffset = DAG.
getNode(PPCISD::LD_GOT_TPREL_L, dl, PtrVT, TGA, GOTPtr);
3478 return DAG.
getNode(PPCISD::ADD_TLS, dl, PtrVT, TPOffset, TGATLS);
3482 if (Subtarget.isUsingPCRelativeCalls()) {
3485 return DAG.
getNode(PPCISD::TLS_DYNAMIC_MAT_PCREL_ADDR, dl, PtrVT, TGA);
3493 GOTPtr = DAG.
getNode(PPCISD::ADDIS_TLSGD_HA, dl, PtrVT,
3501 return DAG.
getNode(PPCISD::ADDI_TLSGD_L_ADDR, dl, PtrVT,
3506 if (Subtarget.isUsingPCRelativeCalls()) {
3510 DAG.
getNode(PPCISD::TLS_DYNAMIC_MAT_PCREL_ADDR, dl, PtrVT, TGA);
3511 return DAG.
getNode(PPCISD::PADDI_DTPREL, dl, PtrVT, MatPCRel, TGA);
3519 GOTPtr = DAG.
getNode(PPCISD::ADDIS_TLSLD_HA, dl, PtrVT,
3528 PtrVT, GOTPtr, TGA, TGA);
3530 PtrVT, TLSAddr, TGA);
3531 return DAG.
getNode(PPCISD::ADDI_DTPREL_L, dl, PtrVT, DtvOffsetHi, TGA);
3539 EVT PtrVT =
Op.getValueType();
3542 const GlobalValue *GV = GSDN->
getGlobal();
3546 if (Subtarget.is64BitELFABI() || Subtarget.isAIXABI()) {
3547 if (Subtarget.isUsingPCRelativeCalls()) {
3554 MachinePointerInfo());
3559 return DAG.
getNode(PPCISD::MAT_PCREL_ADDR,
DL, Ty, GA);
3564 return getTOCEntry(DAG,
DL, GA);
3567 unsigned MOHiFlag, MOLoFlag;
3571 if (IsPIC && Subtarget.isSVR4ABI()) {
3575 return getTOCEntry(DAG,
DL, GA);
3587 bool IsStrict =
Op->isStrictFPOpcode();
3593 EVT LHSVT =
LHS.getValueType();
3597 if (LHSVT == MVT::f128) {
3598 assert(!Subtarget.hasP9Vector() &&
3599 "SETCC for f128 is already legal under Power9!");
3610 assert(!IsStrict &&
"Don't know how to handle STRICT_FSETCC!");
3612 if (
Op.getValueType() == MVT::v2i64) {
3615 if (
LHS.getValueType() == MVT::v2i64) {
3623 int ShuffV[] = {1, 0, 3, 2};
3628 dl, MVT::v4i32, Shuff, SetCC32));
3645 if (
C->isAllOnes() ||
C->isZero())
3655 EVT VT =
Op.getValueType();
3663 SDNode *
Node =
Op.getNode();
3664 EVT VT =
Node->getValueType(0);
3671 assert(!Subtarget.isPPC64() &&
"LowerVAARG is PPC32 only");
3675 VAListPtr, MachinePointerInfo(SV), MVT::i8);
3678 if (VT == MVT::i64) {
3697 FprPtr, MachinePointerInfo(SV), MVT::i8);
3708 DAG.
getLoad(MVT::i32, dl, InChain, OverflowAreaPtr, MachinePointerInfo());
3709 InChain = OverflowArea.
getValue(1);
3712 DAG.
getLoad(MVT::i32, dl, InChain, RegSaveAreaPtr, MachinePointerInfo());
3742 MachinePointerInfo(SV), MVT::i8);
3755 InChain = DAG.
getTruncStore(InChain, dl, OverflowArea, OverflowAreaPtr,
3756 MachinePointerInfo(), MVT::i32);
3758 return DAG.
getLoad(VT, dl, InChain, Result, MachinePointerInfo());
3762 assert(!Subtarget.isPPC64() &&
"LowerVACOPY is PPC32 only");
3768 false,
true,
nullptr, std::nullopt,
3769 MachinePointerInfo(), MachinePointerInfo());
3774 return Op.getOperand(0);
3779 PPCFunctionInfo &MFI = *MF.
getInfo<PPCFunctionInfo>();
3783 "Expecting Inline ASM node.");
3793 if (
Op.getOperand(
NumOps - 1).getValueType() == MVT::Glue)
3798 const InlineAsm::Flag
Flags(
Op.getConstantOperandVal(i));
3799 unsigned NumVals =
Flags.getNumOperandRegisters();
3802 switch (
Flags.getKind()) {
3813 for (; NumVals; --NumVals, ++i) {
3815 if (
Reg != PPC::LR &&
Reg != PPC::LR8)
3838 if (Subtarget.isAIXABI()) {
3842 uint64_t
PointerSize = Subtarget.isPPC64() ? 8 : 4;
3843 MaybeAlign PointerAlign(PointerSize);
3844 auto MMOFlags = Subtarget.hasInvariantFunctionDescriptors()
3847 : MachineMemOperand::MONone;
3854 const Value *TrampolineAddr =
3864 DAG.
getLoad(PtrVT, dl, Chain, FPtr, MachinePointerInfo(Func, 0),
3865 PointerAlign, MMOFlags);
3867 OutChains[0] = DAG.
getStore(EPLoadChain, dl, LoadEntryPoint, Trmp,
3868 MachinePointerInfo(TrampolineAddr, 0));
3872 SDValue TOCFromDescriptorPtr =
3874 SDValue TOCReg = DAG.
getLoad(PtrVT, dl, Chain, TOCFromDescriptorPtr,
3875 MachinePointerInfo(Func, TOCPointerOffset),
3876 PointerAlign, MMOFlags);
3877 SDValue TrampolineTOCPointer =
3881 DAG.
getStore(TOCLoadChain, dl, TOCReg, TrampolineTOCPointer,
3882 MachinePointerInfo(TrampolineAddr, TOCPointerOffset));
3888 DAG.
getStore(Chain, dl, Nest, EnvPointer,
3889 MachinePointerInfo(TrampolineAddr, EnvPointerOffset));
3896 bool isPPC64 = (PtrVT == MVT::i64);
3900 Args.emplace_back(Trmp, IntPtrTy);
3903 DAG.
getConstant(isPPC64 ? 48 : 40, dl, Subtarget.getScalarIntVT()),
3905 Args.emplace_back(FPtr, IntPtrTy);
3906 Args.emplace_back(Nest, IntPtrTy);
3909 TargetLowering::CallLoweringInfo CLI(DAG);
3910 CLI.setDebugLoc(dl).setChain(Chain).setLibCallee(
3914 std::pair<SDValue, SDValue> CallResult =
LowerCallTo(CLI);
3915 return CallResult.second;
3920 PPCFunctionInfo *FuncInfo = MF.
getInfo<PPCFunctionInfo>();
3925 if (Subtarget.isPPC64() || Subtarget.isAIXABI()) {
3930 return DAG.
getStore(
Op.getOperand(0), dl, FR,
Op.getOperand(1),
3931 MachinePointerInfo(SV));
3965 uint64_t FrameOffset = PtrVT.getSizeInBits()/8;
3968 uint64_t StackOffset = PtrVT.getSizeInBits()/8 - 1;
3971 uint64_t FPROffset = 1;
3979 MachinePointerInfo(SV), MVT::i8);
3980 uint64_t nextOffset = FPROffset;
3987 MachinePointerInfo(SV, nextOffset), MVT::i8);
3988 nextOffset += StackOffset;
3989 nextPtr = DAG.
getNode(
ISD::ADD, dl, PtrVT, nextPtr, ConstStackOffset);
3992 SDValue thirdStore = DAG.
getStore(secondStore, dl, StackOffsetFI, nextPtr,
3993 MachinePointerInfo(SV, nextOffset));
3994 nextOffset += FrameOffset;
3995 nextPtr = DAG.
getNode(
ISD::ADD, dl, PtrVT, nextPtr, ConstFrameOffset);
3998 return DAG.
getStore(thirdStore, dl, FR, nextPtr,
3999 MachinePointerInfo(SV, nextOffset));
4004static const MCPhysReg FPR[] = {PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5,
4005 PPC::F6, PPC::F7, PPC::F8, PPC::F9, PPC::F10,
4006 PPC::F11, PPC::F12, PPC::F13};
4011 unsigned PtrByteSize) {
4013 if (Flags.isByVal())
4014 ArgSize = Flags.getByValSize();
4018 if (!Flags.isInConsecutiveRegs())
4019 ArgSize = ((ArgSize + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
4028 unsigned PtrByteSize) {
4029 Align Alignment(PtrByteSize);
4032 if (ArgVT == MVT::v4f32 || ArgVT == MVT::v4i32 ||
4033 ArgVT == MVT::v8i16 || ArgVT == MVT::v16i8 ||
4034 ArgVT == MVT::v2f64 || ArgVT == MVT::v2i64 ||
4035 ArgVT == MVT::v1i128 || ArgVT == MVT::f128)
4036 Alignment =
Align(16);
4039 if (Flags.isByVal()) {
4040 auto BVAlign = Flags.getNonZeroByValAlign();
4041 if (BVAlign > PtrByteSize) {
4042 if (BVAlign.value() % PtrByteSize != 0)
4044 "ByVal alignment is not a multiple of the pointer size");
4046 Alignment = BVAlign;
4051 if (Flags.isInConsecutiveRegs()) {
4055 if (Flags.isSplit() && OrigVT != MVT::ppcf128)
4069 unsigned PtrByteSize,
unsigned LinkageSize,
4070 unsigned ParamAreaSize,
unsigned &ArgOffset,
4071 unsigned &AvailableFPRs,
4072 unsigned &AvailableVRs) {
4073 bool UseMemory =
false;
4078 ArgOffset =
alignTo(ArgOffset, Alignment);
4081 if (ArgOffset >= LinkageSize + ParamAreaSize)
4086 if (Flags.isInConsecutiveRegsLast())
4087 ArgOffset = ((ArgOffset + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
4090 if (ArgOffset > LinkageSize + ParamAreaSize)
4095 if (!Flags.isByVal()) {
4096 if (ArgVT == MVT::f32 || ArgVT == MVT::f64)
4097 if (AvailableFPRs > 0) {
4101 if (ArgVT == MVT::v4f32 || ArgVT == MVT::v4i32 ||
4102 ArgVT == MVT::v8i16 || ArgVT == MVT::v16i8 ||
4103 ArgVT == MVT::v2f64 || ArgVT == MVT::v2i64 ||
4104 ArgVT == MVT::v1i128 || ArgVT == MVT::f128)
4105 if (AvailableVRs > 0) {
4117 unsigned NumBytes) {
4121SDValue PPCTargetLowering::LowerFormalArguments(
4125 if (Subtarget.isAIXABI())
4126 return LowerFormalArguments_AIX(Chain, CallConv, isVarArg, Ins, dl, DAG,
4128 if (Subtarget.is64BitELFABI())
4129 return LowerFormalArguments_64SVR4(Chain, CallConv, isVarArg, Ins, dl, DAG,
4131 assert(Subtarget.is32BitELFABI());
4132 return LowerFormalArguments_32SVR4(Chain, CallConv, isVarArg, Ins, dl, DAG,
4136SDValue PPCTargetLowering::LowerFormalArguments_32SVR4(
4172 PPCFunctionInfo *FuncInfo = MF.
getInfo<PPCFunctionInfo>();
4178 const Align PtrAlign(4);
4186 unsigned LinkageSize = Subtarget.getFrameLowering()->getLinkageSize();
4187 CCInfo.AllocateStack(LinkageSize, PtrAlign);
4190 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
4191 CCValAssign &VA = ArgLocs[i];
4195 const TargetRegisterClass *RC;
4203 RC = &PPC::GPRCRegClass;
4206 if (Subtarget.hasP8Vector())
4207 RC = &PPC::VSSRCRegClass;
4208 else if (Subtarget.hasSPE())
4209 RC = &PPC::GPRCRegClass;
4211 RC = &PPC::F4RCRegClass;
4214 if (Subtarget.hasVSX())
4215 RC = &PPC::VSFRCRegClass;
4216 else if (Subtarget.hasSPE())
4218 RC = &PPC::GPRCRegClass;
4220 RC = &PPC::F8RCRegClass;
4225 RC = &PPC::VRRCRegClass;
4228 RC = &PPC::VRRCRegClass;
4232 RC = &PPC::VRRCRegClass;
4239 if (VA.
getLocVT() == MVT::f64 && Subtarget.hasSPE()) {
4240 assert(i + 1 < e &&
"No second half of double precision argument");
4245 if (!Subtarget.isLittleEndian())
4247 ArgValue = DAG.
getNode(PPCISD::BUILD_SPE64, dl, MVT::f64, ArgValueLo,
4252 ValVT == MVT::i1 ? MVT::i32 : ValVT);
4253 if (ValVT == MVT::i1)
4268 ArgOffset += ArgSize - ObjSize;
4286 CCByValInfo.AllocateStack(CCInfo.getStackSize(), PtrAlign);
4291 unsigned MinReservedArea = CCByValInfo.getStackSize();
4292 MinReservedArea = std::max(MinReservedArea, LinkageSize);
4308 PPC::R3, PPC::R4, PPC::R5, PPC::R6,
4309 PPC::R7, PPC::R8, PPC::R9, PPC::R10,
4311 const unsigned NumGPArgRegs = std::size(GPArgRegs);
4314 PPC::F1, PPC::F2, PPC::F3, PPC::F4, PPC::F5, PPC::F6, PPC::F7,
4317 unsigned NumFPArgRegs = std::size(FPArgRegs);
4326 int Depth = NumGPArgRegs * PtrVT.getSizeInBits()/8 +
4327 NumFPArgRegs * MVT(MVT::f64).getSizeInBits()/8;
4330 PtrVT.getSizeInBits() / 8, CCInfo.getStackSize(),
true));
4343 VReg = MF.
addLiveIn(GPArgReg, &PPC::GPRCRegClass);
4358 for (
unsigned FPRIndex = 0; FPRIndex != NumFPArgRegs; ++FPRIndex) {
4362 VReg = MF.
addLiveIn(FPArgRegs[FPRIndex], &PPC::F8RCRegClass);
4375 if (!MemOps.
empty())
4386 const SDLoc &dl)
const {
4390 else if (
Flags.isZExt())
4397SDValue PPCTargetLowering::LowerFormalArguments_64SVR4(
4403 bool isELFv2ABI = Subtarget.isELFv2ABI();
4404 bool isLittleEndian = Subtarget.isLittleEndian();
4407 PPCFunctionInfo *FuncInfo = MF.
getInfo<PPCFunctionInfo>();
4410 "fastcc not supported on varargs functions");
4416 unsigned PtrByteSize = 8;
4417 unsigned LinkageSize = Subtarget.getFrameLowering()->getLinkageSize();
4420 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
4421 PPC::X7, PPC::X8, PPC::X9, PPC::X10,
4424 PPC::V2, PPC::V3, PPC::V4, PPC::V5, PPC::V6, PPC::V7, PPC::V8,
4425 PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13
4428 const unsigned Num_GPR_Regs = std::size(GPR);
4430 const unsigned Num_VR_Regs = std::size(VR);
4438 bool HasParameterArea = !isELFv2ABI || isVarArg;
4439 unsigned ParamAreaSize = Num_GPR_Regs * PtrByteSize;
4440 unsigned NumBytes = LinkageSize;
4441 unsigned AvailableFPRs = Num_FPR_Regs;
4442 unsigned AvailableVRs = Num_VR_Regs;
4443 for (
const ISD::InputArg &In : Ins) {
4444 if (
In.Flags.isNest())
4448 LinkageSize, ParamAreaSize, NumBytes,
4449 AvailableFPRs, AvailableVRs))
4450 HasParameterArea =
true;
4457 unsigned ArgOffset = LinkageSize;
4458 unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0;
4461 unsigned CurArgIdx = 0;
4462 for (
unsigned ArgNo = 0, e = Ins.size(); ArgNo != e; ++ArgNo) {
4464 bool needsLoad =
false;
4465 EVT ObjectVT = Ins[ArgNo].VT;
4466 EVT OrigVT = Ins[ArgNo].ArgVT;
4468 unsigned ArgSize = ObjSize;
4469 ISD::ArgFlagsTy
Flags = Ins[ArgNo].Flags;
4470 if (Ins[ArgNo].isOrigArg()) {
4471 std::advance(FuncArg, Ins[ArgNo].getOrigArgIndex() - CurArgIdx);
4472 CurArgIdx = Ins[ArgNo].getOrigArgIndex();
4477 unsigned CurArgOffset;
4479 auto ComputeArgOffset = [&]() {
4483 ArgOffset =
alignTo(ArgOffset, Alignment);
4484 CurArgOffset = ArgOffset;
4491 GPR_idx = (ArgOffset - LinkageSize) / PtrByteSize;
4492 GPR_idx = std::min(GPR_idx, Num_GPR_Regs);
4497 if (
Flags.isByVal()) {
4498 assert(Ins[ArgNo].isOrigArg() &&
"Byval arguments cannot be implicit");
4504 ObjSize =
Flags.getByValSize();
4505 ArgSize = ((ObjSize + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
4527 if (HasParameterArea ||
4528 ArgSize + ArgOffset > LinkageSize + Num_GPR_Regs * PtrByteSize)
4535 if (ObjSize < PtrByteSize) {
4539 if (!isLittleEndian) {
4545 if (GPR_idx != Num_GPR_Regs) {
4552 MachinePointerInfo(&*FuncArg), ObjType);
4557 ArgOffset += PtrByteSize;
4566 for (
unsigned j = 0;
j < ArgSize;
j += PtrByteSize) {
4567 if (GPR_idx == Num_GPR_Regs)
4578 unsigned StoreSizeInBits = std::min(PtrByteSize, (ObjSize - j)) * 8;
4582 MachinePointerInfo(&*FuncArg, j), ObjType);
4586 ArgOffset += ArgSize;
4595 if (
Flags.isNest()) {
4600 if (ObjectVT == MVT::i32 || ObjectVT == MVT::i1)
4601 ArgVal = extendArgForPPC64(Flags, ObjectVT, DAG, ArgVal, dl);
4609 if (GPR_idx != Num_GPR_Regs) {
4614 if (ObjectVT == MVT::i32 || ObjectVT == MVT::i1)
4617 ArgVal = extendArgForPPC64(Flags, ObjectVT, DAG, ArgVal, dl);
4623 ArgSize = PtrByteSize;
4634 if (FPR_idx != Num_FPR_Regs) {
4637 if (ObjectVT == MVT::f32)
4639 Subtarget.hasP8Vector()
4640 ? &PPC::VSSRCRegClass
4641 : &PPC::F4RCRegClass);
4644 ? &PPC::VSFRCRegClass
4645 : &PPC::F8RCRegClass);
4660 if (ObjectVT == MVT::f32) {
4661 if ((ArgOffset % PtrByteSize) == (isLittleEndian ? 4 : 0))
4679 ArgSize =
Flags.isInConsecutiveRegs() ? ObjSize : PtrByteSize;
4680 ArgOffset += ArgSize;
4681 if (
Flags.isInConsecutiveRegsLast())
4682 ArgOffset = ((ArgOffset + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
4696 if (VR_idx != Num_VR_Regs) {
4713 if (ObjSize < ArgSize && !isLittleEndian)
4714 CurArgOffset += ArgSize - ObjSize;
4717 ArgVal = DAG.
getLoad(ObjectVT, dl, Chain, FIN, MachinePointerInfo());
4724 unsigned MinReservedArea;
4725 if (HasParameterArea)
4726 MinReservedArea = std::max(ArgOffset, LinkageSize + 8 * PtrByteSize);
4728 MinReservedArea = LinkageSize;
4745 int Depth = ArgOffset;
4754 for (GPR_idx = (ArgOffset - LinkageSize) / PtrByteSize;
4755 GPR_idx < Num_GPR_Regs; ++GPR_idx) {
4767 if (!MemOps.
empty())
4776 unsigned ParamSize) {
4778 if (!isTailCall)
return 0;
4782 int SPDiff = (int)CallerMinReservedArea - (
int)ParamSize;
4784 if (SPDiff < FI->getTailCallSPDelta())
4800 "PC Relative callers do not have a TOC and cannot share a TOC Base");
4859 Caller->hasComdat() || CalleeGV->
getSection() != Caller->getSection())
4862 if (
F->getSectionPrefix() != Caller->getSectionPrefix())
4874 const unsigned PtrByteSize = 8;
4878 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
4879 PPC::X7, PPC::X8, PPC::X9, PPC::X10,
4882 PPC::V2, PPC::V3, PPC::V4, PPC::V5, PPC::V6, PPC::V7, PPC::V8,
4883 PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13
4886 const unsigned NumGPRs = std::size(GPR);
4887 const unsigned NumFPRs = 13;
4888 const unsigned NumVRs = std::size(VR);
4889 const unsigned ParamAreaSize = NumGPRs * PtrByteSize;
4891 unsigned NumBytes = LinkageSize;
4892 unsigned AvailableFPRs = NumFPRs;
4893 unsigned AvailableVRs = NumVRs;
4896 if (Param.Flags.isNest())
continue;
4899 LinkageSize, ParamAreaSize, NumBytes,
4900 AvailableFPRs, AvailableVRs))
4911 auto CalleeArgEnd = CB.
arg_end();
4914 for (; CalleeArgIter != CalleeArgEnd; ++CalleeArgIter, ++CallerArgIter) {
4915 const Value* CalleeArg = *CalleeArgIter;
4916 const Value* CallerArg = &(*CallerArgIter);
4917 if (CalleeArg == CallerArg)
4943 if (!isTailCallableCC(CallerCC) || !isTailCallableCC(CalleeCC))
4953bool PPCTargetLowering::IsEligibleForTailCallOptimization_64SVR4(
4958 bool isCalleeExternalSymbol)
const {
4961 if (
DisableSCO && !TailCallOpt)
return false;
4964 if (isVarArg)
return false;
4971 if (
any_of(Ins, [](
const ISD::InputArg &IA) {
return IA.Flags.isByVal(); }))
5007 if (!Subtarget.isUsingPCRelativeCalls() &&
5012 if (!Subtarget.isUsingPCRelativeCalls() &&
5040bool PPCTargetLowering::IsEligibleForTailCallOptimization(
5053 if (
any_of(Ins, [](
const ISD::InputArg &IA) {
return IA.Flags.isByVal(); }))
5074 if (!
C)
return nullptr;
5076 int Addr =
C->getZExtValue();
5077 if ((Addr & 3) != 0 ||
5083 (
int)
C->getZExtValue() >> 2,
SDLoc(
Op),
5090struct TailCallArgumentInfo {
5095 TailCallArgumentInfo() =
default;
5105 for (
unsigned i = 0, e = TailCallArgs.
size(); i != e; ++i) {
5106 SDValue Arg = TailCallArgs[i].Arg;
5107 SDValue FIN = TailCallArgs[i].FrameIdxOp;
5108 int FI = TailCallArgs[i].FrameIdx;
5111 Chain, dl, Arg, FIN,
5120 int SPDiff,
const SDLoc &dl) {
5126 int SlotSize = Subtarget.isPPC64() ? 8 : 4;
5127 int NewRetAddrLoc = SPDiff + FL->getReturnSaveOffset();
5129 NewRetAddrLoc,
true);
5132 Chain = DAG.
getStore(Chain, dl, OldRetAddr, NewRetAddrFrIdx,
5142 int SPDiff,
unsigned ArgOffset,
5144 int Offset = ArgOffset + SPDiff;
5147 EVT VT = IsPPC64 ? MVT::i64 : MVT::i32;
5149 TailCallArgumentInfo Info;
5151 Info.FrameIdxOp = FIN;
5159SDValue PPCTargetLowering::EmitTailCallLoadFPAndRetAddr(
5164 LROpOut = getReturnAddrFrameIndex(DAG);
5165 LROpOut = DAG.
getLoad(Subtarget.getScalarIntVT(), dl, Chain, LROpOut,
5166 MachinePointerInfo());
5183 Chain, dl, Dst, Src, SizeNode, Flags.getNonZeroByValAlign(),
false,
false,
5191 SDValue PtrOff,
int SPDiff,
unsigned ArgOffset,
bool isPPC64,
5215 const SDLoc &dl,
int SPDiff,
unsigned NumBytes,
SDValue LROp,
5225 if (!MemOpChains2.
empty())
5249SDValue PPCTargetLowering::LowerCallResult(
5257 CCRetInfo.AnalyzeCallResult(
5263 for (
unsigned i = 0, e = RVLocs.
size(); i != e; ++i) {
5264 CCValAssign &VA = RVLocs[i];
5269 if (Subtarget.hasSPE() && VA.
getLocVT() == MVT::f64) {
5279 if (!Subtarget.isLittleEndian())
5281 Val = DAG.
getNode(PPCISD::BUILD_SPE64, dl, MVT::f64,
Lo,
Hi);
5347 bool IsStrictFPCall =
false) {
5349 return PPCISD::TC_RETURN;
5351 unsigned RetOpc = 0;
5366 RetOpc = PPCISD::CALL_NOTOC;
5381 RetOpc = PPCISD::CALL;
5382 if (IsStrictFPCall) {
5386 case PPCISD::BCTRL_LOAD_TOC:
5387 RetOpc = PPCISD::BCTRL_LOAD_TOC_RM;
5390 RetOpc = PPCISD::BCTRL_RM;
5392 case PPCISD::CALL_NOTOC:
5393 RetOpc = PPCISD::CALL_NOTOC_RM;
5396 RetOpc = PPCISD::CALL_RM;
5398 case PPCISD::CALL_NOP:
5399 RetOpc = PPCISD::CALL_NOP_RM;
5413 auto isLocalCallee = [&]() {
5429 const auto getAIXFuncEntryPointSymbolSDNode = [&](
const GlobalValue *GV) {
5445 return getAIXFuncEntryPointSymbolSDNode(GV);
5452 const char *SymName = S->getSymbol();
5459 return getAIXFuncEntryPointSymbolSDNode(
F);
5465 const auto getExternalFunctionEntryPointSymbol = [&](
StringRef SymName) {
5473 SymName = getExternalFunctionEntryPointSymbol(SymName)->getName().data();
5480 assert(Callee.getNode() &&
"What no callee?");
5486 "Expected a CALLSEQ_STARTSDNode.");
5503 SDValue MTCTROps[] = {Chain, Callee, Glue};
5504 EVT ReturnTypes[] = {MVT::Other, MVT::Glue};
5505 Chain = DAG.
getNode(PPCISD::MTCTR, dl, ReturnTypes,
5545 auto MMOFlags = Subtarget.hasInvariantFunctionDescriptors()
5564 SDValue LoadFuncPtr = DAG.
getLoad(RegVT, dl, LDChain, Callee, MPI,
5565 Alignment, MMOFlags);
5572 DAG.
getLoad(RegVT, dl, LDChain, AddTOC,
5579 DAG.
getLoad(RegVT, dl, LDChain, AddPtr,
5591 "Nest parameter is not supported on AIX.");
5607 SmallVector<std::pair<unsigned, SDValue>, 8> &RegsToPass,
5610 const bool IsPPC64 = Subtarget.isPPC64();
5615 Ops.push_back(Chain);
5619 Ops.push_back(Callee);
5639 Ops.push_back(AddTOC);
5650 Ops.push_back(DAG.
getRegister(IsPPC64 ? PPC::CTR8 : PPC::CTR, RegVT));
5659 for (
const auto &[
Reg,
N] : RegsToPass)
5677 assert(Mask &&
"Missing call preserved mask for calling convention");
5682 Ops.push_back(Glue);
5685SDValue PPCTargetLowering::FinishCall(
5692 if ((Subtarget.is64BitELFABI() && !Subtarget.isUsingPCRelativeCalls()) ||
5693 Subtarget.isAIXABI())
5700 if (!CFlags.IsIndirect)
5702 else if (Subtarget.usesFunctionDescriptors())
5704 dl, CFlags.HasNest, Subtarget);
5714 if (CFlags.IsTailCall) {
5722 (CFlags.IsIndirect && Subtarget.isUsingPCRelativeCalls())) &&
5723 "Expecting a global address, external symbol, absolute value, "
5724 "register or an indirect tail call when PC Relative calls are "
5727 assert(CallOpc == PPCISD::TC_RETURN &&
5728 "Unexpected call opcode for a tail call.");
5735 std::array<EVT, 2> ReturnTypes = {{MVT::Other, MVT::Glue}};
5736 Chain = DAG.
getNode(CallOpc, dl, ReturnTypes,
Ops);
5748 Chain = DAG.
getCALLSEQ_END(Chain, NumBytes, BytesCalleePops, Glue, dl);
5751 return LowerCallResult(Chain, Glue, CFlags.CallConv, CFlags.IsVarArg, Ins, dl,
5771 return isEligibleForTCO(CalleeGV, CalleeCC, CallerCC, CB,
5772 CalleeFunc->
isVarArg(), Outs, Ins, CallerFunc,
5776bool PPCTargetLowering::isEligibleForTCO(
5781 bool isCalleeExternalSymbol)
const {
5785 if (Subtarget.
isSVR4ABI() && Subtarget.isPPC64())
5786 return IsEligibleForTailCallOptimization_64SVR4(
5787 CalleeGV, CalleeCC, CallerCC, CB, isVarArg, Outs, Ins, CallerFunc,
5788 isCalleeExternalSymbol);
5790 return IsEligibleForTailCallOptimization(CalleeGV, CalleeCC, CallerCC,
5818 isEligibleForTCO(GV, CallConv, CallerCC, CB, isVarArg, Outs, Ins,
5833 "Callee should be an llvm::Function object.");
5836 <<
"\nTCO callee: ");
5843 "site marked musttail");
5850 Callee = LowerGlobalAddress(Callee, DAG);
5853 CallConv, isTailCall, isVarArg, isPatchPoint,
5856 Subtarget.is64BitELFABI() &&
5860 if (Subtarget.isAIXABI())
5861 return LowerCall_AIX(Chain, Callee, CFlags, Outs, OutVals, Ins, dl, DAG,
5864 assert(Subtarget.isSVR4ABI());
5865 if (Subtarget.isPPC64())
5866 return LowerCall_64SVR4(Chain, Callee, CFlags, Outs, OutVals, Ins, dl, DAG,
5868 return LowerCall_32SVR4(Chain, Callee, CFlags, Outs, OutVals, Ins, dl, DAG,
5872SDValue PPCTargetLowering::LowerCall_32SVR4(
5883 const bool IsVarArg = CFlags.IsVarArg;
5884 const bool IsTailCall = CFlags.IsTailCall;
5890 const Align PtrAlign(4);
5901 MF.
getInfo<PPCFunctionInfo>()->setHasFastCall();
5909 CCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.
getContext());
5912 CCInfo.AllocateStack(Subtarget.getFrameLowering()->getLinkageSize(),
5919 unsigned NumArgs = Outs.
size();
5921 for (
unsigned i = 0; i != NumArgs; ++i) {
5922 MVT ArgVT = Outs[i].VT;
5923 ISD::ArgFlagsTy ArgFlags = Outs[i].Flags;
5928 Outs[i].OrigTy, CCInfo);
5931 ArgFlags, Outs[i].OrigTy, CCInfo);
5936 errs() <<
"Call operand #" << i <<
" has unhandled type "
5949 CCState CCByValInfo(CallConv, IsVarArg, MF, ByValArgLocs, *DAG.
getContext());
5952 CCByValInfo.AllocateStack(CCInfo.getStackSize(), PtrAlign);
5959 unsigned NumBytes = CCByValInfo.getStackSize();
5973 Chain = EmitTailCallLoadFPAndRetAddr(DAG, SPDiff, Chain, LROp, FPOp, dl);
5984 bool seenFloatArg =
false;
5989 for (
unsigned i = 0, RealArgIdx = 0, j = 0, e = ArgLocs.
size();
5991 ++i, ++RealArgIdx) {
5992 CCValAssign &VA = ArgLocs[i];
5993 SDValue Arg = OutVals[RealArgIdx];
5994 ISD::ArgFlagsTy
Flags = Outs[RealArgIdx].Flags;
5996 if (
Flags.isByVal()) {
6001 assert((j < ByValArgLocs.
size()) &&
"Index out of bounds!");
6002 CCValAssign &ByValVA = ByValArgLocs[
j++];
6024 Chain = CallSeqStart = NewCallSeqStart;
6043 if (Subtarget.hasSPE() && Arg.
getValueType() == MVT::f64) {
6044 bool IsLE = Subtarget.isLittleEndian();
6045 SDValue SVal = DAG.
getNode(PPCISD::EXTRACT_SPE, dl, MVT::i32, Arg,
6048 SVal = DAG.
getNode(PPCISD::EXTRACT_SPE, dl, MVT::i32, Arg,
6050 RegsToPass.
push_back(std::make_pair(ArgLocs[++i].getLocReg(),
6065 DAG.
getStore(Chain, dl, Arg, PtrOff, MachinePointerInfo()));
6074 if (!MemOpChains.
empty())
6080 for (
const auto &[
Reg,
N] : RegsToPass) {
6088 SDVTList VTs = DAG.
getVTList(MVT::Other, MVT::Glue);
6091 Chain = DAG.
getNode(seenFloatArg ? PPCISD::CR6SET : PPCISD::CR6UNSET, dl,
6101 return FinishCall(CFlags, dl, DAG, RegsToPass, InGlue, Chain, CallSeqStart,
6102 Callee, SPDiff, NumBytes, Ins, InVals, CB);
6107SDValue PPCTargetLowering::createMemcpyOutsideCallSeq(
6119 return NewCallSeqStart;
6122SDValue PPCTargetLowering::LowerCall_64SVR4(
6129 bool isELFv2ABI = Subtarget.isELFv2ABI();
6130 bool isLittleEndian = Subtarget.isLittleEndian();
6132 bool IsSibCall =
false;
6136 unsigned PtrByteSize = 8;
6149 MF.
getInfo<PPCFunctionInfo>()->setHasFastCall();
6151 assert(!(IsFastCall && CFlags.IsVarArg) &&
6152 "fastcc not supported on varargs functions");
6158 unsigned LinkageSize = Subtarget.getFrameLowering()->getLinkageSize();
6159 unsigned NumBytes = LinkageSize;
6160 unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0;
6163 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
6164 PPC::X7, PPC::X8, PPC::X9, PPC::X10,
6167 PPC::V2, PPC::V3, PPC::V4, PPC::V5, PPC::V6, PPC::V7, PPC::V8,
6168 PPC::V9, PPC::V10, PPC::V11, PPC::V12, PPC::V13
6171 const unsigned NumGPRs = std::size(GPR);
6173 const unsigned NumVRs = std::size(VR);
6179 bool HasParameterArea = !isELFv2ABI || CFlags.IsVarArg || IsFastCall;
6180 if (!HasParameterArea) {
6181 unsigned ParamAreaSize = NumGPRs * PtrByteSize;
6182 unsigned AvailableFPRs = NumFPRs;
6183 unsigned AvailableVRs = NumVRs;
6184 unsigned NumBytesTmp = NumBytes;
6185 for (
unsigned i = 0; i !=
NumOps; ++i) {
6186 if (Outs[i].
Flags.isNest())
continue;
6188 PtrByteSize, LinkageSize, ParamAreaSize,
6189 NumBytesTmp, AvailableFPRs, AvailableVRs))
6190 HasParameterArea =
true;
6196 unsigned NumGPRsUsed = 0, NumFPRsUsed = 0, NumVRsUsed = 0;
6201 HasParameterArea =
false;
6204 for (
unsigned i = 0; i !=
NumOps; ++i) {
6205 ISD::ArgFlagsTy
Flags = Outs[i].Flags;
6206 EVT ArgVT = Outs[i].VT;
6207 EVT OrigVT = Outs[i].ArgVT;
6213 if (
Flags.isByVal()) {
6214 NumGPRsUsed += (
Flags.getByValSize()+7)/8;
6215 if (NumGPRsUsed > NumGPRs)
6216 HasParameterArea =
true;
6223 if (++NumGPRsUsed <= NumGPRs)
6233 if (++NumVRsUsed <= NumVRs)
6237 if (++NumVRsUsed <= NumVRs)
6242 if (++NumFPRsUsed <= NumFPRs)
6246 HasParameterArea =
true;
6253 NumBytes =
alignTo(NumBytes, Alignement);
6256 if (
Flags.isInConsecutiveRegsLast())
6257 NumBytes = ((NumBytes + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
6260 unsigned NumBytesActuallyUsed = NumBytes;
6270 if (HasParameterArea)
6271 NumBytes = std::max(NumBytes, LinkageSize + 8 * PtrByteSize);
6273 NumBytes = LinkageSize;
6288 if (CFlags.IsTailCall)
6300 Chain = EmitTailCallLoadFPAndRetAddr(DAG, SPDiff, Chain, LROp, FPOp, dl);
6311 unsigned ArgOffset = LinkageSize;
6317 for (
unsigned i = 0; i !=
NumOps; ++i) {
6319 ISD::ArgFlagsTy
Flags = Outs[i].Flags;
6320 EVT ArgVT = Outs[i].VT;
6321 EVT OrigVT = Outs[i].ArgVT;
6330 auto ComputePtrOff = [&]() {
6334 ArgOffset =
alignTo(ArgOffset, Alignment);
6345 GPR_idx = (ArgOffset - LinkageSize) / PtrByteSize;
6346 GPR_idx = std::min(GPR_idx, NumGPRs);
6353 Arg = DAG.
getNode(ExtOp, dl, MVT::i64, Arg);
6359 if (
Flags.isByVal()) {
6377 EVT VT = (
Size==1) ? MVT::i8 : ((
Size==2) ? MVT::i16 : MVT::i32);
6378 if (GPR_idx != NumGPRs) {
6380 MachinePointerInfo(), VT);
6382 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6384 ArgOffset += PtrByteSize;
6389 if (GPR_idx == NumGPRs &&
Size < 8) {
6391 if (!isLittleEndian) {
6396 Chain = CallSeqStart = createMemcpyOutsideCallSeq(Arg, AddPtr,
6399 ArgOffset += PtrByteSize;
6408 if ((NumGPRs - GPR_idx) * PtrByteSize <
Size)
6409 Chain = CallSeqStart = createMemcpyOutsideCallSeq(Arg, PtrOff,
6414 if (
Size < 8 && GPR_idx != NumGPRs) {
6424 if (!isLittleEndian) {
6428 Chain = CallSeqStart = createMemcpyOutsideCallSeq(Arg, AddPtr,
6434 DAG.
getLoad(PtrVT, dl, Chain, PtrOff, MachinePointerInfo());
6436 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6439 ArgOffset += PtrByteSize;
6445 for (
unsigned j=0;
j<
Size;
j+=PtrByteSize) {
6448 if (GPR_idx != NumGPRs) {
6449 unsigned LoadSizeInBits = std::min(PtrByteSize, (
Size - j)) * 8;
6452 MachinePointerInfo(), ObjType);
6455 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6456 ArgOffset += PtrByteSize;
6458 ArgOffset += ((
Size -
j + PtrByteSize-1)/PtrByteSize)*PtrByteSize;
6470 if (
Flags.isNest()) {
6472 RegsToPass.
push_back(std::make_pair(PPC::X11, Arg));
6479 if (GPR_idx != NumGPRs) {
6480 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Arg));
6485 assert(HasParameterArea &&
6486 "Parameter area must exist to pass an argument in memory.");
6488 true, CFlags.IsTailCall,
false, MemOpChains,
6489 TailCallArguments, dl);
6491 ArgOffset += PtrByteSize;
6494 ArgOffset += PtrByteSize;
6507 bool NeedGPROrStack = CFlags.IsVarArg || FPR_idx == NumFPRs;
6508 bool NeededLoad =
false;
6511 if (FPR_idx != NumFPRs)
6512 RegsToPass.
push_back(std::make_pair(
FPR[FPR_idx++], Arg));
6515 if (!NeedGPROrStack)
6517 else if (GPR_idx != NumGPRs && !IsFastCall) {
6531 }
else if (!
Flags.isInConsecutiveRegs()) {
6537 }
else if (ArgOffset % PtrByteSize != 0) {
6541 if (!isLittleEndian)
6546 }
else if (
Flags.isInConsecutiveRegsLast()) {
6549 if (!isLittleEndian)
6559 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], ArgVal));
6567 !isLittleEndian && !
Flags.isInConsecutiveRegs()) {
6572 assert(HasParameterArea &&
6573 "Parameter area must exist to pass an argument in memory.");
6575 true, CFlags.IsTailCall,
false, MemOpChains,
6576 TailCallArguments, dl);
6583 if (!IsFastCall || NeededLoad) {
6585 Flags.isInConsecutiveRegs()) ? 4 : 8;
6586 if (
Flags.isInConsecutiveRegsLast())
6587 ArgOffset = ((ArgOffset + PtrByteSize - 1)/PtrByteSize) * PtrByteSize;
6607 if (CFlags.IsVarArg) {
6608 assert(HasParameterArea &&
6609 "Parameter area must exist if we have a varargs call.");
6613 DAG.
getStore(Chain, dl, Arg, PtrOff, MachinePointerInfo());
6615 if (VR_idx != NumVRs) {
6617 DAG.
getLoad(MVT::v4f32, dl, Store, PtrOff, MachinePointerInfo());
6619 RegsToPass.
push_back(std::make_pair(VR[VR_idx++], Load));
6622 for (
unsigned i=0; i<16; i+=PtrByteSize) {
6623 if (GPR_idx == NumGPRs)
6628 DAG.
getLoad(PtrVT, dl, Store, Ix, MachinePointerInfo());
6630 RegsToPass.
push_back(std::make_pair(GPR[GPR_idx++], Load));
6636 if (VR_idx != NumVRs) {
6637 RegsToPass.
push_back(std::make_pair(VR[VR_idx++], Arg));
6642 assert(HasParameterArea &&
6643 "Parameter area must exist to pass an argument in memory.");
6645 true, CFlags.IsTailCall,
true, MemOpChains,
6646 TailCallArguments, dl);
6657 assert((!HasParameterArea || NumBytesActuallyUsed == ArgOffset) &&
6658 "mismatch in size of parameter area");
6659 (void)NumBytesActuallyUsed;
6661 if (!MemOpChains.
empty())
6667 if (CFlags.IsIndirect) {
6671 assert(!CFlags.IsTailCall &&
"Indirect tails calls not supported");
6676 unsigned TOCSaveOffset = Subtarget.getFrameLowering()->getTOCSaveOffset();
6686 if (isELFv2ABI && !CFlags.IsPatchPoint)
6687 RegsToPass.
push_back(std::make_pair((
unsigned)PPC::X12, Callee));
6693 for (
const auto &[
Reg,
N] : RegsToPass) {
6698 if (CFlags.IsTailCall && !IsSibCall)
6702 return FinishCall(CFlags, dl, DAG, RegsToPass, InGlue, Chain, CallSeqStart,
6703 Callee, SPDiff, NumBytes, Ins, InVals, CB);
6710 "Required alignment greater than stack alignment.");
6730 return RequiredAlign <= 8;
6735 return RequiredAlign <= 4;
6743 State.getMachineFunction().getSubtarget());
6744 const bool IsPPC64 = Subtarget.isPPC64();
6745 const unsigned PtrSize = IsPPC64 ? 8 : 4;
6746 const Align PtrAlign(PtrSize);
6747 const Align StackAlign(16);
6750 if (ValVT == MVT::f128)
6754 PPC::R3, PPC::R4, PPC::R5, PPC::R6,
6755 PPC::R7, PPC::R8, PPC::R9, PPC::R10};
6757 PPC::X3, PPC::X4, PPC::X5, PPC::X6,
6758 PPC::X7, PPC::X8, PPC::X9, PPC::X10};
6761 PPC::V2, PPC::V3, PPC::V4, PPC::V5,
6762 PPC::V6, PPC::V7, PPC::V8, PPC::V9,
6763 PPC::V10, PPC::V11, PPC::V12, PPC::V13};
6768 MCRegister EnvReg = State.AllocateReg(IsPPC64 ? PPC::X11 : PPC::R11);
6777 if (ByValAlign > StackAlign)
6779 "16 are not supported.");
6782 const Align ObjAlign = ByValAlign > PtrAlign ? ByValAlign : PtrAlign;
6786 if (ByValSize == 0) {
6788 State.getStackSize(), RegVT, LocInfo));
6793 unsigned NextReg = State.getFirstUnallocated(GPRs);
6794 while (NextReg != GPRs.
size() &&
6799 State.AllocateStack(PtrSize, PtrAlign);
6800 assert(
Reg &&
"Alocating register unexpectedly failed.");
6802 NextReg = State.getFirstUnallocated(GPRs);
6805 const unsigned StackSize =
alignTo(ByValSize, ObjAlign);
6806 unsigned Offset = State.AllocateStack(StackSize, ObjAlign);
6826 assert(IsPPC64 &&
"PPC32 should have split i64 values.");
6830 const unsigned Offset = State.AllocateStack(PtrSize, PtrAlign);
6849 State.AllocateStack(IsPPC64 ? 8 : StoreSize,
Align(4));
6855 for (
unsigned I = 0;
I < StoreSize;
I += PtrSize) {
6857 assert(FReg &&
"An FPR should be available when a GPR is reserved.");
6858 if (State.isVarArg()) {
6890 const unsigned VecSize = 16;
6891 const Align VecAlign(VecSize);
6893 if (!State.isVarArg()) {
6896 if (
MCRegister VReg = State.AllocateReg(VR)) {
6903 const unsigned Offset = State.AllocateStack(VecSize, VecAlign);
6908 unsigned NextRegIndex = State.getFirstUnallocated(GPRs);
6911 while (NextRegIndex != GPRs.
size() &&
6915 State.AllocateStack(PtrSize, PtrAlign);
6916 assert(
Reg &&
"Allocating register unexpectedly failed.");
6918 NextRegIndex = State.getFirstUnallocated(GPRs);
6926 if (
MCRegister VReg = State.AllocateReg(VR)) {
6929 for (
unsigned I = 0;
I != VecSize;
I += PtrSize)
6930 State.AllocateReg(GPRs);
6931 State.AllocateStack(VecSize, VecAlign);
6935 const unsigned Offset = State.AllocateStack(VecSize, VecAlign);
6941 if (NextRegIndex == GPRs.
size()) {
6942 const unsigned Offset = State.AllocateStack(VecSize, VecAlign);
6950 if (GPRs[NextRegIndex] == PPC::R9) {
6951 const unsigned Offset = State.AllocateStack(VecSize, VecAlign);
6955 const MCRegister FirstReg = State.AllocateReg(PPC::R9);
6956 const MCRegister SecondReg = State.AllocateReg(PPC::R10);
6957 assert(FirstReg && SecondReg &&
6958 "Allocating R9 or R10 unexpectedly failed.");
6969 const unsigned Offset = State.AllocateStack(VecSize, VecAlign);
6972 for (
unsigned I = 0;
I != VecSize;
I += PtrSize) {
6974 assert(
Reg &&
"Failed to allocated register for vararg vector argument");
6989 assert((IsPPC64 || SVT != MVT::i64) &&
6990 "i64 should have been split for 32-bit codegen.");
6998 return IsPPC64 ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
7000 return HasP8Vector ? &PPC::VSSRCRegClass : &PPC::F4RCRegClass;
7002 return HasVSX ? &PPC::VSFRCRegClass : &PPC::F8RCRegClass;
7010 return &PPC::VRRCRegClass;
7023 else if (Flags.isZExt())
7035 "Reg must be a valid argument register!");
7036 return LASize + 4 * (
Reg - PPC::R3);
7041 "Reg must be a valid argument register!");
7042 return LASize + 8 * (
Reg - PPC::X3);
7088SDValue PPCTargetLowering::LowerFormalArguments_AIX(
7095 "Unexpected calling convention!");
7103 const PPCSubtarget &Subtarget = DAG.
getSubtarget<PPCSubtarget>();
7105 const bool IsPPC64 = Subtarget.isPPC64();
7106 const unsigned PtrByteSize = IsPPC64 ? 8 : 4;
7112 PPCFunctionInfo *FuncInfo = MF.
getInfo<PPCFunctionInfo>();
7113 CCState CCInfo(CallConv, isVarArg, MF, ArgLocs, *DAG.
getContext());
7117 const unsigned LinkageSize = Subtarget.getFrameLowering()->getLinkageSize();
7118 CCInfo.AllocateStack(LinkageSize,
Align(PtrByteSize));
7119 uint64_t SaveStackPos = CCInfo.getStackSize();
7121 CCInfo.AnalyzeFormalArguments(Ins,
CC_AIX);
7125 for (
size_t I = 0, End = ArgLocs.
size();
I != End; ) {
7126 CCValAssign &VA = ArgLocs[
I++];
7131 EVT ArgVT = Ins[VA.
getValNo()].ArgVT;
7132 bool ArgSignExt = Ins[VA.
getValNo()].Flags.isSExt();
7144 LocVT.
SimpleTy, IsPPC64, Subtarget.hasP8Vector(), Subtarget.hasVSX());
7146 MVT SaveVT = RegClass == &PPC::G8RCRegClass ? MVT::i64 : LocVT;
7152 MachinePointerInfo(),
Align(PtrByteSize));
7158 unsigned StoreSize =
7160 SaveStackPos =
alignTo(SaveStackPos + StoreSize, PtrByteSize);
7163 auto HandleMemLoc = [&]() {
7166 assert((ValSize <= LocSize) &&
7167 "Object size is larger than size of MemLoc");
7170 if (LocSize > ValSize)
7171 CurArgOffset += LocSize - ValSize;
7173 const bool IsImmutable =
7179 DAG.
getLoad(ValVT, dl, Chain, FIN, MachinePointerInfo());
7213 assert(isVarArg &&
"Only use custom memloc for vararg.");
7216 const unsigned OriginalValNo = VA.
getValNo();
7217 (void)OriginalValNo;
7219 auto HandleCustomVecRegLoc = [&]() {
7220 assert(
I != End && ArgLocs[
I].isRegLoc() && ArgLocs[
I].needsCustom() &&
7221 "Missing custom RegLoc.");
7224 "Unexpected Val type for custom RegLoc.");
7226 "ValNo mismatch between custom MemLoc and RegLoc.");
7230 Subtarget.hasVSX()));
7237 HandleCustomVecRegLoc();
7238 HandleCustomVecRegLoc();
7242 if (
I != End && ArgLocs[
I].isRegLoc() && ArgLocs[
I].needsCustom()) {
7244 "Only 2 custom RegLocs expected for 64-bit codegen.");
7245 HandleCustomVecRegLoc();
7246 HandleCustomVecRegLoc();
7290 const unsigned Size =
7302 if (
Flags.isByVal()) {
7306 const PPCFrameLowering *FL = Subtarget.getFrameLowering();
7308 const unsigned StackSize =
alignTo(
Flags.getByValSize(), PtrByteSize);
7316 const TargetRegisterClass *RegClass =
7317 IsPPC64 ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
7319 auto HandleRegLoc = [&, RegClass, LocVT](
const MCPhysReg PhysReg,
7332 CopyFrom.
getValue(1), dl, CopyFrom,
7342 for (;
Offset != StackSize && ArgLocs[
I].isRegLoc();
7345 "RegLocs should be for ByVal argument.");
7347 const CCValAssign RL = ArgLocs[
I++];
7352 if (
Offset != StackSize) {
7354 "Expected MemLoc for remaining bytes.");
7355 assert(ArgLocs[
I].isMemLoc() &&
"Expected MemLoc for remaining bytes.");
7369 Subtarget.hasVSX()));
7386 const unsigned MinParameterSaveArea = 8 * PtrByteSize;
7388 unsigned CallerReservedArea = std::max<unsigned>(
7389 CCInfo.getStackSize(), LinkageSize + MinParameterSaveArea);
7395 CallerReservedArea =
7400 int VAListIndex = 0;
7404 if (CCInfo.getStackSize() < (LinkageSize + MinParameterSaveArea)) {
7405 unsigned FixedStackSize =
7406 LinkageSize + MinParameterSaveArea - CCInfo.getStackSize();
7422 static const MCPhysReg GPR_32[] = {PPC::R3, PPC::R4, PPC::R5, PPC::R6,
7423 PPC::R7, PPC::R8, PPC::R9, PPC::R10};
7425 static const MCPhysReg GPR_64[] = {PPC::X3, PPC::X4, PPC::X5, PPC::X6,
7426 PPC::X7, PPC::X8, PPC::X9, PPC::X10};
7427 const unsigned NumGPArgRegs = std::size(IsPPC64 ? GPR_64 : GPR_32);
7433 GPRIndex = (CCInfo.getStackSize() - LinkageSize) / PtrByteSize,
7435 GPRIndex < NumGPArgRegs; ++GPRIndex,
Offset += PtrByteSize) {
7438 IsPPC64 ? MF.
addLiveIn(GPR_64[GPRIndex], &PPC::G8RCRegClass)
7439 : MF.
addLiveIn(GPR_32[GPRIndex], &PPC::GPRCRegClass);
7442 MachinePointerInfo MPI =
7452 if (!MemOps.
empty())
7458SDValue PPCTargetLowering::LowerCall_AIX(
7471 "Unexpected calling convention!");
7473 if (CFlags.IsPatchPoint)
7476 const PPCSubtarget &Subtarget = DAG.
getSubtarget<PPCSubtarget>();
7480 CCState CCInfo(CFlags.CallConv, CFlags.IsVarArg, MF, ArgLocs,
7487 const unsigned LinkageSize = Subtarget.getFrameLowering()->getLinkageSize();
7488 const bool IsPPC64 = Subtarget.isPPC64();
7490 const unsigned PtrByteSize = IsPPC64 ? 8 : 4;
7491 CCInfo.AllocateStack(LinkageSize,
Align(PtrByteSize));
7492 CCInfo.AnalyzeCallOperands(Outs,
CC_AIX);
7500 const unsigned MinParameterSaveAreaSize = 8 * PtrByteSize;
7501 const unsigned NumBytes = std::max<unsigned>(
7502 LinkageSize + MinParameterSaveAreaSize, CCInfo.getStackSize());
7518 for (
unsigned I = 0,
E = ArgLocs.
size();
I !=
E;) {
7519 const unsigned ValNo = ArgLocs[
I].getValNo();
7521 ISD::ArgFlagsTy
Flags = Outs[ValNo].Flags;
7523 if (
Flags.isByVal()) {
7524 const unsigned ByValSize =
Flags.getByValSize();
7532 auto GetLoad = [&](EVT VT,
unsigned LoadOffset) {
7538 MachinePointerInfo(), VT);
7541 unsigned LoadOffset = 0;
7544 while (LoadOffset + PtrByteSize <= ByValSize && ArgLocs[
I].isRegLoc()) {
7547 LoadOffset += PtrByteSize;
7548 const CCValAssign &ByValVA = ArgLocs[
I++];
7550 "Unexpected location for pass-by-value argument.");
7554 if (LoadOffset == ByValSize)
7558 assert(ArgLocs[
I].getValNo() == ValNo &&
7559 "Expected additional location for by-value argument.");
7561 if (ArgLocs[
I].isMemLoc()) {
7562 assert(LoadOffset < ByValSize &&
"Unexpected memloc for by-val arg.");
7563 const CCValAssign &ByValVA = ArgLocs[
I++];
7564 ISD::ArgFlagsTy MemcpyFlags =
Flags;
7567 Chain = CallSeqStart = createMemcpyOutsideCallSeq(
7573 CallSeqStart, MemcpyFlags, DAG, dl);
7582 const unsigned ResidueBytes = ByValSize % PtrByteSize;
7583 assert(ResidueBytes != 0 && LoadOffset + PtrByteSize > ByValSize &&
7584 "Unexpected register residue for by-value argument.");
7586 for (
unsigned Bytes = 0; Bytes != ResidueBytes;) {
7590 : ((
N == 2) ? MVT::i16 : (
N == 4 ? MVT::i32 : MVT::i64));
7600 "Unexpected load emitted during handling of pass-by-value "
7608 ResidueVal = ResidueVal ? DAG.
getNode(
ISD::OR, dl, PtrVT, ResidueVal,
7613 const CCValAssign &ByValVA = ArgLocs[
I++];
7618 CCValAssign &VA = ArgLocs[
I++];
7643 assert(CFlags.IsVarArg &&
"Custom MemLocs only used for Vector args.");
7649 DAG.
getStore(Chain, dl, Arg, PtrOff, MachinePointerInfo());
7651 const unsigned OriginalValNo = VA.
getValNo();
7653 unsigned LoadOffset = 0;
7654 auto HandleCustomVecRegLoc = [&]() {
7655 assert(
I !=
E &&
"Unexpected end of CCvalAssigns.");
7656 assert(ArgLocs[
I].isRegLoc() && ArgLocs[
I].needsCustom() &&
7657 "Expected custom RegLoc.");
7658 CCValAssign RegVA = ArgLocs[
I++];
7660 "Custom MemLoc ValNo and custom RegLoc ValNo must match.");
7666 LoadOffset += PtrByteSize;
7672 HandleCustomVecRegLoc();
7673 HandleCustomVecRegLoc();
7675 if (
I !=
E && ArgLocs[
I].isRegLoc() && ArgLocs[
I].needsCustom() &&
7676 ArgLocs[
I].getValNo() == OriginalValNo) {
7678 "Only 2 custom RegLocs expected for 64-bit codegen.");
7679 HandleCustomVecRegLoc();
7680 HandleCustomVecRegLoc();
7691 DAG.
getStore(Chain, dl, Arg, PtrOff,
7693 Subtarget.getFrameLowering()->getStackAlign()));
7700 "Unexpected register handling for calling convention.");
7706 "Custom register handling only expected for VarArg.");
7711 if (Arg.getValueType().getStoreSize() == LocVT.
getStoreSize())
7715 else if (Arg.getValueType().getFixedSizeInBits() <
7723 assert(Arg.getValueType() == MVT::f64 && CFlags.IsVarArg && !IsPPC64 &&
7724 "Unexpected custom register for argument!");
7725 CCValAssign &GPR1 = VA;
7734 CCValAssign &PeekArg = ArgLocs[
I];
7737 CCValAssign &GPR2 = ArgLocs[
I++];
7745 if (!MemOpChains.
empty())
7750 if (CFlags.IsIndirect) {
7751 assert(!CFlags.IsTailCall &&
"Indirect tail-calls not supported.");
7752 const MCRegister TOCBaseReg = Subtarget.getTOCPointerRegister();
7753 const MCRegister StackPtrReg = Subtarget.getStackPointerRegister();
7754 const MVT PtrVT = Subtarget.getScalarIntVT();
7755 const unsigned TOCSaveOffset =
7756 Subtarget.getFrameLowering()->getTOCSaveOffset();
7771 for (
auto Reg : RegsToPass) {
7776 const int SPDiff = 0;
7777 return FinishCall(CFlags, dl, DAG, RegsToPass, InGlue, Chain, CallSeqStart,
7778 Callee, SPDiff, NumBytes, Ins, InVals, CB);
7786 const Type *RetTy)
const {
7788 CCState CCInfo(CallConv, isVarArg, MF, RVLocs,
Context);
7789 return CCInfo.CheckReturn(
7804 CCInfo.AnalyzeReturn(Outs,
7813 for (
unsigned i = 0, RealResIdx = 0; i != RVLocs.
size(); ++i, ++RealResIdx) {
7814 CCValAssign &VA = RVLocs[i];
7817 SDValue Arg = OutVals[RealResIdx];
7832 if (Subtarget.hasSPE() && VA.
getLocVT() == MVT::f64) {
7833 bool isLittleEndian = Subtarget.isLittleEndian();
7836 DAG.
getNode(PPCISD::EXTRACT_SPE, dl, MVT::i32, Arg,
7840 SVal = DAG.
getNode(PPCISD::EXTRACT_SPE, dl, MVT::i32, Arg,
7855 RetOps.push_back(Glue);
7857 return DAG.
getNode(PPCISD::RET_GLUE, dl, MVT::Other, RetOps);
7861PPCTargetLowering::LowerGET_DYNAMIC_AREA_OFFSET(
SDValue Op,
7866 EVT IntVT =
Op.getValueType();
7870 SDValue FPSIdx = getFramePointerFrameIndex(DAG);
7874 return DAG.
getNode(PPCISD::DYNAREAOFFSET, dl, VTs,
Ops);
7886 bool isPPC64 = Subtarget.isPPC64();
7887 unsigned SP = isPPC64 ? PPC::X1 : PPC::R1;
7896 DAG.
getLoad(PtrVT, dl, Chain, StackPtr, MachinePointerInfo());
7902 return DAG.
getStore(Chain, dl, LoadLinkSP, StackPtr, MachinePointerInfo());
7907 bool isPPC64 = Subtarget.isPPC64();
7912 PPCFunctionInfo *FI = MF.
getInfo<PPCFunctionInfo>();
7918 int LROffset = Subtarget.getFrameLowering()->getReturnSaveOffset();
7928PPCTargetLowering::getFramePointerFrameIndex(
SelectionDAG & DAG)
const {
7930 bool isPPC64 = Subtarget.isPPC64();
7935 PPCFunctionInfo *FI = MF.
getInfo<PPCFunctionInfo>();
7941 int FPOffset = Subtarget.getFrameLowering()->getFramePointerSaveOffset();
7964 SDValue FPSIdx = getFramePointerFrameIndex(DAG);
7966 SDVTList VTs = DAG.
getVTList(PtrVT, MVT::Other);
7968 return DAG.
getNode(PPCISD::PROBED_ALLOCA, dl, VTs,
Ops);
7969 return DAG.
getNode(PPCISD::DYNALLOC, dl, VTs,
Ops);
7976 bool isPPC64 = Subtarget.isPPC64();
7986 return DAG.
getNode(PPCISD::EH_SJLJ_SETJMP,
DL,
7988 Op.getOperand(0),
Op.getOperand(1));
7994 return DAG.
getNode(PPCISD::EH_SJLJ_LONGJMP,
DL, MVT::Other,
7995 Op.getOperand(0),
Op.getOperand(1));
7999 if (
Op.getValueType().isVector())
8000 return LowerVectorLoad(
Op, DAG);
8002 assert(
Op.getValueType() == MVT::i1 &&
8003 "Custom lowering only for i1 loads");
8012 MachineMemOperand *MMO =
LD->getMemOperand();
8016 BasePtr, MVT::i8, MMO);
8024 if (
Op.getOperand(1).getValueType().isVector())
8025 return LowerVectorStore(
Op, DAG);
8027 assert(
Op.getOperand(1).getValueType() == MVT::i1 &&
8028 "Custom lowering only for i1 stores");
8038 MachineMemOperand *MMO =
ST->getMemOperand();
8047 assert(
Op.getValueType() == MVT::i1 &&
8048 "Custom lowering only for i1 results");
8076 EVT TrgVT =
Op.getValueType();
8100 if (SrcSize == 256) {
8111 Op1 = SrcSize == 128 ? N1 :
widenVec(DAG, N1,
DL);
8117 SmallVector<int, 16> ShuffV;
8118 if (Subtarget.isLittleEndian())
8119 for (
unsigned i = 0; i < TrgNumElts; ++i)
8122 for (
unsigned i = 1; i <= TrgNumElts; ++i)
8126 for (
unsigned i = TrgNumElts; i < WideNumElts; ++i)
8139 EVT ResVT =
Op.getValueType();
8140 EVT CmpVT =
Op.getOperand(0).getValueType();
8142 SDValue TV =
Op.getOperand(2), FV =
Op.getOperand(3);
8148 if (!Subtarget.hasP9Vector() && CmpVT == MVT::f128) {
8161 SDNodeFlags
Flags =
Op.getNode()->getFlags();
8165 if (Subtarget.hasP9Vector() &&
LHS == TV &&
RHS == FV) {
8182 if (!
Flags.hasNoInfs() || !
Flags.hasNoNaNs() || ResVT == MVT::f128)
8195 if (
LHS.getValueType() == MVT::f32)
8197 Sel1 = DAG.
getNode(PPCISD::FSEL, dl, ResVT,
LHS, TV, FV);
8200 return DAG.
getNode(PPCISD::FSEL, dl, ResVT,
8208 if (
LHS.getValueType() == MVT::f32)
8210 return DAG.
getNode(PPCISD::FSEL, dl, ResVT,
LHS, TV, FV);
8217 if (
LHS.getValueType() == MVT::f32)
8219 return DAG.
getNode(PPCISD::FSEL, dl, ResVT,
8231 if (
Cmp.getValueType() == MVT::f32)
8233 Sel1 = DAG.
getNode(PPCISD::FSEL, dl, ResVT, Cmp, TV, FV);
8236 return DAG.
getNode(PPCISD::FSEL, dl, ResVT,
8241 if (
Cmp.getValueType() == MVT::f32)
8243 return DAG.
getNode(PPCISD::FSEL, dl, ResVT, Cmp, FV, TV);
8247 if (
Cmp.getValueType() == MVT::f32)
8249 return DAG.
getNode(PPCISD::FSEL, dl, ResVT, Cmp, TV, FV);
8253 if (
Cmp.getValueType() == MVT::f32)
8255 return DAG.
getNode(PPCISD::FSEL, dl, ResVT, Cmp, FV, TV);
8259 if (
Cmp.getValueType() == MVT::f32)
8261 return DAG.
getNode(PPCISD::FSEL, dl, ResVT, Cmp, TV, FV);
8270 case PPCISD::FCTIDZ:
8271 return PPCISD::STRICT_FCTIDZ;
8272 case PPCISD::FCTIWZ:
8273 return PPCISD::STRICT_FCTIWZ;
8274 case PPCISD::FCTIDUZ:
8275 return PPCISD::STRICT_FCTIDUZ;
8276 case PPCISD::FCTIWUZ:
8277 return PPCISD::STRICT_FCTIWUZ;
8279 return PPCISD::STRICT_FCFID;
8280 case PPCISD::FCFIDU:
8281 return PPCISD::STRICT_FCFIDU;
8282 case PPCISD::FCFIDS:
8283 return PPCISD::STRICT_FCFIDS;
8284 case PPCISD::FCFIDUS:
8285 return PPCISD::STRICT_FCFIDUS;
8292 bool IsStrict =
Op->isStrictFPOpcode();
8301 SDValue Src =
Op.getOperand(IsStrict ? 1 : 0);
8303 MVT DestTy =
Op.getSimpleValueType();
8304 assert(Src.getValueType().isFloatingPoint() &&
8305 (DestTy == MVT::i8 || DestTy == MVT::i16 || DestTy == MVT::i32 ||
8306 DestTy == MVT::i64) &&
8307 "Invalid FP_TO_INT types");
8308 if (Src.getValueType() == MVT::f32) {
8312 DAG.
getVTList(MVT::f64, MVT::Other), {Chain, Src}, Flags);
8317 if ((DestTy == MVT::i8 || DestTy == MVT::i16) && Subtarget.hasP9Vector())
8323 Opc = IsSigned ? PPCISD::FCTIWZ
8324 : (Subtarget.hasFPCVT() ? PPCISD::FCTIWUZ : PPCISD::FCTIDZ);
8327 assert((IsSigned || Subtarget.hasFPCVT()) &&
8328 "i64 FP_TO_UINT is supported only with FPCVT");
8329 Opc = IsSigned ? PPCISD::FCTIDZ : PPCISD::FCTIDUZ;
8331 EVT ConvTy = Src.getValueType() == MVT::f128 ? MVT::f128 : MVT::f64;
8343void PPCTargetLowering::LowerFP_TO_INTForReuse(
SDValue Op, ReuseLoadInfo &RLI,
8345 const SDLoc &dl)
const {
8349 bool IsStrict =
Op->isStrictFPOpcode();
8352 bool i32Stack =
Op.getValueType() == MVT::i32 && Subtarget.hasSTFIWX() &&
8353 (IsSigned || Subtarget.hasFPCVT());
8356 MachinePointerInfo MPI =
8364 Alignment =
Align(4);
8365 MachineMemOperand *MMO =
8371 Chain = DAG.
getStore(Chain, dl, Tmp, FIPtr, MPI, Alignment);
8375 if (
Op.getValueType() == MVT::i32 && !i32Stack &&
8376 !Subtarget.isLittleEndian()) {
8385 RLI.Alignment = Alignment;
8393 const SDLoc &dl)
const {
8396 if (
Op->isStrictFPOpcode())
8403 const SDLoc &dl)
const {
8404 bool IsStrict =
Op->isStrictFPOpcode();
8407 SDValue Src =
Op.getOperand(IsStrict ? 1 : 0);
8408 EVT SrcVT = Src.getValueType();
8409 EVT DstVT =
Op.getValueType();
8412 if (SrcVT == MVT::f128)
8413 return Subtarget.hasP9Vector() ?
Op :
SDValue();
8417 if (SrcVT == MVT::ppcf128) {
8418 if (DstVT == MVT::i32) {
8423 Flags.setNoFPExcept(
Op->getFlags().hasNoFPExcept());
8434 {Op.getOperand(0), Lo, Hi}, Flags);
8437 {Res.getValue(1), Res}, Flags);
8443 const uint64_t TwoE31[] = {0x41e0000000000000LL, 0};
8467 {Chain, Src, FltOfs}, Flags);
8471 {Chain, Val}, Flags);
8474 dl, DstVT, Sel, DAG.
getConstant(0, dl, DstVT), SignMask);
8492 if (Subtarget.hasDirectMove() && Subtarget.isPPC64())
8493 return LowerFP_TO_INTDirectMove(
Op, DAG, dl);
8496 LowerFP_TO_INTForReuse(
Op, RLI, DAG, dl);
8498 return DAG.
getLoad(
Op.getValueType(), dl, RLI.Chain, RLI.Ptr, RLI.MPI,
8499 RLI.Alignment, RLI.MMOFlags(), RLI.AAInfo, RLI.Ranges);
8510bool PPCTargetLowering::canReuseLoadAddress(
SDValue Op,
EVT MemVT,
8515 if (
Op->isStrictFPOpcode())
8520 (Subtarget.hasFPCVT() ||
Op.getValueType() == MVT::i32);
8524 Op.getOperand(0).getValueType())) {
8526 LowerFP_TO_INTForReuse(
Op, RLI, DAG, dl);
8531 if (!LD ||
LD->getExtensionType() != ET ||
LD->isVolatile() ||
8532 LD->isNonTemporal())
8534 if (
LD->getMemoryVT() != MemVT)
8544 RLI.Ptr =
LD->getBasePtr();
8545 if (
LD->isIndexed() && !
LD->getOffset().isUndef()) {
8547 "Non-pre-inc AM on PPC?");
8552 RLI.Chain =
LD->getChain();
8553 RLI.MPI =
LD->getPointerInfo();
8554 RLI.IsDereferenceable =
LD->isDereferenceable();
8555 RLI.IsInvariant =
LD->isInvariant();
8556 RLI.Alignment =
LD->getAlign();
8557 RLI.AAInfo =
LD->getAAInfo();
8558 RLI.Ranges =
LD->getRanges();
8560 RLI.ResChain =
SDValue(LD,
LD->isIndexed() ? 2 : 1);
8567bool PPCTargetLowering::directMoveIsProfitable(
const SDValue &
Op)
const {
8568 SDNode *Origin =
Op.getOperand(
Op->isStrictFPOpcode() ? 1 : 0).getNode();
8575 if (!Subtarget.hasP9Vector() &&
8579 for (SDUse &Use : Origin->
uses()) {
8582 if (
Use.getResNo() != 0)
8609 bool IsSingle =
Op.getValueType() == MVT::f32 && Subtarget.hasFPCVT();
8610 unsigned ConvOpc = IsSingle ? (IsSigned ? PPCISD::FCFIDS : PPCISD::FCFIDUS)
8611 : (IsSigned ? PPCISD::FCFID : PPCISD::FCFIDU);
8612 EVT ConvTy = IsSingle ? MVT::f32 : MVT::f64;
8613 if (
Op->isStrictFPOpcode()) {
8615 Chain =
Op.getOperand(0);
8617 DAG.
getVTList(ConvTy, MVT::Other), {Chain, Src}, Flags);
8619 return DAG.
getNode(ConvOpc, dl, ConvTy, Src);
8627 const SDLoc &dl)
const {
8628 assert((
Op.getValueType() == MVT::f32 ||
8629 Op.getValueType() == MVT::f64) &&
8630 "Invalid floating point type as target of conversion");
8631 assert(Subtarget.hasFPCVT() &&
8632 "Int to FP conversions with direct moves require FPCVT");
8633 SDValue Src =
Op.getOperand(
Op->isStrictFPOpcode() ? 1 : 0);
8634 bool WordInt = Src.getSimpleValueType().SimpleTy == MVT::i32;
8637 unsigned MovOpc = (WordInt && !
Signed) ? PPCISD::MTVSRZ : PPCISD::MTVSRA;
8656 for (
unsigned i = 1; i < NumConcat; ++i)
8663 const SDLoc &dl)
const {
8664 bool IsStrict =
Op->isStrictFPOpcode();
8665 unsigned Opc =
Op.getOpcode();
8666 SDValue Src =
Op.getOperand(IsStrict ? 1 : 0);
8669 "Unexpected conversion type");
8670 assert((
Op.getValueType() == MVT::v2f64 ||
Op.getValueType() == MVT::v4f32) &&
8671 "Supports conversions to v2f64/v4f32 only.");
8675 Flags.setNoFPExcept(
Op->getFlags().hasNoFPExcept());
8678 bool FourEltRes =
Op.getValueType() == MVT::v4f32;
8683 MVT IntermediateVT = FourEltRes ? MVT::v4i32 : MVT::v2i64;
8685 SmallVector<int, 16> ShuffV;
8686 for (
unsigned i = 0; i < WideNumElts; ++i)
8689 int Stride = FourEltRes ? WideNumElts / 4 : WideNumElts / 2;
8690 int SaveElts = FourEltRes ? 4 : 2;
8691 if (Subtarget.isLittleEndian())
8692 for (
int i = 0; i < SaveElts; i++)
8693 ShuffV[i * Stride] = i;
8695 for (
int i = 1; i <= SaveElts; i++)
8696 ShuffV[i * Stride - 1] = i - 1;
8704 Arrange = DAG.
getBitcast(IntermediateVT, Arrange);
8705 EVT ExtVT = Src.getValueType();
8706 if (Subtarget.hasP9Altivec())
8717 {Op.getOperand(0), Extend}, Flags);
8719 return DAG.
getNode(
Opc, dl,
Op.getValueType(), Extend);
8727 bool IsStrict =
Op->isStrictFPOpcode();
8728 SDValue Src =
Op.getOperand(IsStrict ? 1 : 0);
8733 Flags.setNoFPExcept(
Op->getFlags().hasNoFPExcept());
8735 EVT InVT = Src.getValueType();
8736 EVT OutVT =
Op.getValueType();
8739 return LowerINT_TO_FPVector(
Op, DAG, dl);
8742 if (
Op.getValueType() == MVT::f128)
8743 return Subtarget.hasP9Vector() ?
Op :
SDValue();
8746 if (
Op.getValueType() != MVT::f32 &&
Op.getValueType() != MVT::f64)
8749 if (Src.getValueType() == MVT::i1) {
8761 if (Subtarget.hasDirectMove() && directMoveIsProfitable(
Op) &&
8762 Subtarget.isPPC64() && Subtarget.hasFPCVT())
8763 return LowerINT_TO_FPDirectMove(
Op, DAG, dl);
8765 assert((IsSigned || Subtarget.hasFPCVT()) &&
8766 "UINT_TO_FP is supported only with FPCVT");
8768 if (Src.getValueType() == MVT::i64) {
8783 if (
Op.getValueType() == MVT::f32 && !Subtarget.hasFPCVT() &&
8784 !
Op->getFlags().hasApproximateFuncs()) {
8824 if (canReuseLoadAddress(SINT, MVT::i64, RLI, DAG)) {
8825 Bits = DAG.
getLoad(MVT::f64, dl, RLI.Chain, RLI.Ptr, RLI.MPI,
8826 RLI.Alignment, RLI.MMOFlags(), RLI.AAInfo, RLI.Ranges);
8829 }
else if (Subtarget.hasLFIWAX() &&
8830 canReuseLoadAddress(SINT, MVT::i32, RLI, DAG,
ISD::SEXTLOAD)) {
8831 MachineMemOperand *MMO =
8833 RLI.Alignment, RLI.AAInfo, RLI.Ranges);
8837 Ops, MVT::i32, MMO);
8840 }
else if (Subtarget.hasFPCVT() &&
8841 canReuseLoadAddress(SINT, MVT::i32, RLI, DAG,
ISD::ZEXTLOAD)) {
8842 MachineMemOperand *MMO =
8844 RLI.Alignment, RLI.AAInfo, RLI.Ranges);
8848 Ops, MVT::i32, MMO);
8851 }
else if (((Subtarget.hasLFIWAX() &&
8853 (Subtarget.hasFPCVT() &&
8868 "Expected an i32 store");
8874 RLI.Alignment =
Align(4);
8876 MachineMemOperand *MMO =
8878 RLI.Alignment, RLI.AAInfo, RLI.Ranges);
8881 PPCISD::LFIWZX : PPCISD::LFIWAX,
8882 dl, DAG.
getVTList(MVT::f64, MVT::Other),
8883 Ops, MVT::i32, MMO);
8884 Chain =
Bits.getValue(1);
8892 if (
Op.getValueType() == MVT::f32 && !Subtarget.hasFPCVT()) {
8896 {Chain, FP, DAG.getIntPtrConstant(0, dl, true)},
8905 assert(Src.getValueType() == MVT::i32 &&
8906 "Unhandled INT_TO_FP type in custom expander!");
8916 if (Subtarget.hasLFIWAX() || Subtarget.hasFPCVT()) {
8919 if (!(ReusingLoad = canReuseLoadAddress(Src, MVT::i32, RLI, DAG))) {
8929 "Expected an i32 store");
8935 RLI.Alignment =
Align(4);
8938 MachineMemOperand *MMO =
8940 RLI.Alignment, RLI.AAInfo, RLI.Ranges);
8946 if (ReusingLoad && RLI.ResChain) {
8950 assert(Subtarget.isPPC64() &&
8951 "i32->FP without LFIWAX supported only on PPC64");
8960 Chain, dl, Ext64, FIdx,
8966 MVT::f64, dl, Chain, FIdx,
8975 if (
Op.getValueType() == MVT::f32 && !Subtarget.hasFPCVT()) {
8979 {Chain, FP, DAG.getIntPtrConstant(0, dl, true)}, Flags);
8996 uint64_t
Mode = CVal->getZExtValue();
8997 assert(
Mode < 4 &&
"Unsupported rounding mode!");
8998 unsigned InternalRnd =
Mode ^ (~(
Mode >> 1) & 1);
8999 if (Subtarget.isISA3_0())
9002 PPC::MFFSCRNI, Dl, {MVT::f64, MVT::Other},
9003 {DAG.getConstant(InternalRnd, Dl, MVT::i32, true), Chain}),
9006 (InternalRnd & 2) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
9007 {DAG.
getConstant(30, Dl, MVT::i32,
true), Chain});
9009 (InternalRnd & 1) ? PPC::MTFSB1 : PPC::MTFSB0, Dl, MVT::Other,
9027 if (!Subtarget.isISA3_0()) {
9028 MFFS = DAG.
getNode(PPCISD::MFFS, Dl, {MVT::f64, MVT::Other}, Chain);
9032 if (Subtarget.isPPC64()) {
9033 if (Subtarget.isISA3_0()) {
9038 PPC::RLDIMI, Dl, MVT::i64,
9043 NewFPSCR =
SDValue(InsertRN, 0);
9050 SDValue Addr = Subtarget.isLittleEndian()
9054 if (Subtarget.isISA3_0()) {
9055 Chain = DAG.
getStore(Chain, Dl, DstFlag, Addr, MachinePointerInfo());
9057 Chain = DAG.
getStore(Chain, Dl, MFFS, StackSlot, MachinePointerInfo());
9059 DAG.
getLoad(MVT::i32, Dl, Chain, Addr, MachinePointerInfo());
9062 PPC::RLWIMI, Dl, MVT::i32,
9063 {Tmp, DstFlag, DAG.getTargetConstant(0, Dl, MVT::i32),
9064 DAG.getTargetConstant(30, Dl, MVT::i32),
9065 DAG.getTargetConstant(31, Dl, MVT::i32)}),
9067 Chain = DAG.
getStore(Chain, Dl, Tmp, Addr, MachinePointerInfo());
9070 DAG.
getLoad(MVT::f64, Dl, Chain, StackSlot, MachinePointerInfo());
9073 if (Subtarget.isISA3_0())
9079 PPC::MTFSF, Dl, MVT::Other,
9107 EVT VT =
Op.getValueType();
9112 SDValue MFFS = DAG.
getNode(PPCISD::MFFS, dl, {MVT::f64, MVT::Other}, Chain);
9123 Chain = DAG.
getStore(Chain, dl, MFFS, StackSlot, MachinePointerInfo());
9127 "Stack slot adjustment is valid only on big endian subtargets!");
9130 CWD = DAG.
getLoad(MVT::i32, dl, Chain, Addr, MachinePointerInfo());
9157 EVT VT =
Op.getValueType();
9161 VT ==
Op.getOperand(1).getValueType() &&
9181 SDValue OutOps[] = { OutLo, OutHi };
9186 EVT VT =
Op.getValueType();
9190 VT ==
Op.getOperand(1).getValueType() &&
9210 SDValue OutOps[] = { OutLo, OutHi };
9216 EVT VT =
Op.getValueType();
9219 VT ==
Op.getOperand(1).getValueType() &&
9239 SDValue OutOps[] = { OutLo, OutHi };
9246 EVT VT =
Op.getValueType();
9253 EVT AmtVT =
Z.getValueType();
9263 X = DAG.
getNode(PPCISD::SHL, dl, VT,
X, IsFSHL ? Z : SubZ);
9264 Y = DAG.
getNode(PPCISD::SRL, dl, VT,
Y, IsFSHL ? SubZ : Z);
9276 static const MVT VTys[] = {
9277 MVT::v16i8, MVT::v8i16, MVT::Other, MVT::v4i32
9280 EVT ReqVT = VT != MVT::Other ? VT : VTys[SplatSize-1];
9283 if (Val == ((1LLU << (SplatSize * 8)) - 1)) {
9288 EVT CanonicalVT = VTys[SplatSize-1];
9301 const SDLoc &dl,
EVT DestVT = MVT::Other) {
9302 if (DestVT == MVT::Other) DestVT =
Op.getValueType();
9311 EVT DestVT = MVT::Other) {
9312 if (DestVT == MVT::Other) DestVT =
LHS.getValueType();
9321 EVT DestVT = MVT::Other) {
9324 DAG.
getConstant(IID, dl, MVT::i32), Op0, Op1, Op2);
9336 for (
unsigned i = 0; i != 16; ++i)
9357 EVT VecVT = V->getValueType(0);
9358 bool RightType = VecVT == MVT::v2f64 ||
9359 (HasP8Vector && VecVT == MVT::v4f32) ||
9360 (HasDirectMove && (VecVT == MVT::v2i64 || VecVT == MVT::v4i32));
9364 bool IsSplat =
true;
9365 bool IsLoad =
false;
9371 if (V->isConstant())
9373 for (
int i = 0, e = V->getNumOperands(); i < e; ++i) {
9374 if (V->getOperand(i).isUndef())
9378 if (V->getOperand(i).getOpcode() ==
ISD::LOAD ||
9380 V->getOperand(i).getOperand(0).getOpcode() ==
ISD::LOAD) ||
9382 V->getOperand(i).getOperand(0).getOpcode() ==
ISD::LOAD) ||
9384 V->getOperand(i).getOperand(0).getOpcode() ==
ISD::LOAD))
9388 if (V->getOperand(i) != Op0 ||
9389 (!IsLoad && !V->isOnlyUserOf(V->getOperand(i).getNode())))
9392 return !(IsSplat && IsLoad);
9402 (
Op.getValueType() != MVT::f128))
9407 if ((
Lo.getValueType() != MVT::i64) || (
Hi.getValueType() != MVT::i64))
9410 if (!Subtarget.isLittleEndian())
9413 return DAG.
getNode(PPCISD::BUILD_FP128, dl, MVT::f128,
Lo,
Hi);
9421 InputLoad->
getOpcode() == PPCISD::SCALAR_TO_VECTOR_PERMUTED) {
9422 IsPermuted = InputLoad->
getOpcode() == PPCISD::SCALAR_TO_VECTOR_PERMUTED;
9435 APFloat APFloatToConvert = ArgAPFloat;
9436 bool LosesInfo =
true;
9441 ArgAPFloat = APFloatToConvert;
9463 APFloat APFloatToConvert = ArgAPFloat;
9464 bool LosesInfo =
true;
9468 return (!LosesInfo && !APFloatToConvert.
isDenormal());
9477 EVT Ty =
Op->getValueType(0);
9480 if ((Ty == MVT::v2f64 || Ty == MVT::v4f32 || Ty == MVT::v4i32) &&
9489 if ((Ty == MVT::v8i16 || Ty == MVT::v16i8) &&
ISD::isEXTLoad(InputNode) &&
9493 if (Ty == MVT::v2i64) {
9496 if (MemVT == MVT::i32) {
9498 Opcode = PPCISD::ZEXT_LD_SPLAT;
9500 Opcode = PPCISD::SEXT_LD_SPLAT;
9508 bool IsLittleEndian) {
9514 APInt ConstValue(VTSize, 0);
9518 unsigned BitPos = 0;
9526 ConstValue.
insertBits(CN->getAPIntValue().zextOrTrunc(EltWidth),
9527 IsLittleEndian ? BitPos : VTSize - EltWidth - BitPos);
9531 for (
unsigned J = 0; J < 16; ++J) {
9533 if (ExtractValue != 0x00 && ExtractValue != 0xFF)
9535 if (ExtractValue == 0xFF)
9550 assert(BVN &&
"Expected a BuildVectorSDNode in LowerBUILD_VECTOR");
9552 if (Subtarget.hasP10Vector()) {
9553 APInt BitMask(32, 0);
9559 BitMask != 0 && BitMask != 0xffff) {
9561 MachineSDNode *MSDNode =
9573 if (
SDValue VecPat = combineBVLoadsSpecialValue(
Op, DAG))
9577 APInt APSplatBits, APSplatUndef;
9578 unsigned SplatBitSize;
9580 bool BVNIsConstantSplat =
9582 HasAnyUndefs, 0, !Subtarget.isLittleEndian());
9588 if (BVNIsConstantSplat && (SplatBitSize == 64) &&
9589 Subtarget.hasPrefixInstrs() && Subtarget.hasP10Vector()) {
9592 if ((
Op->getValueType(0) == MVT::v2f64) &&
9595 PPCISD::XXSPLTI_SP_TO_DP, dl, MVT::v2f64,
9611 PPCISD::XXSPLTI32DX, dl, MVT::v2i64, SplatNode,
9617 DAG.
getNode(PPCISD::XXSPLTI32DX, dl, MVT::v2i64, SplatNode,
9625 bool IsSplat64 =
false;
9626 uint64_t SplatBits = 0;
9627 int32_t SextVal = 0;
9628 if (BVNIsConstantSplat && SplatBitSize <= 64) {
9630 if (SplatBitSize <= 32) {
9632 }
else if (SplatBitSize == 64 && Subtarget.hasP8Altivec()) {
9633 int64_t Splat64Val =
static_cast<int64_t
>(SplatBits);
9634 bool P9Vector = Subtarget.hasP9Vector();
9635 int32_t
Hi = P9Vector ? 127 : 15;
9636 int32_t
Lo = P9Vector ? -128 : -16;
9637 IsSplat64 = Splat64Val >=
Lo && Splat64Val <=
Hi;
9638 SextVal =
static_cast<int32_t
>(SplatBits);
9642 if (!BVNIsConstantSplat || (SplatBitSize > 32 && !IsSplat64)) {
9643 unsigned NewOpcode = PPCISD::LD_SPLAT;
9649 const SDValue *InputLoad = &
Op.getOperand(0);
9654 unsigned MemorySize =
LD->getMemoryVT().getScalarSizeInBits();
9655 unsigned ElementSize =
9656 MemorySize * ((NewOpcode == PPCISD::LD_SPLAT) ? 1 : 2);
9658 assert(((ElementSize == 2 * MemorySize)
9659 ? (NewOpcode == PPCISD::ZEXT_LD_SPLAT ||
9660 NewOpcode == PPCISD::SEXT_LD_SPLAT)
9661 : (NewOpcode == PPCISD::LD_SPLAT)) &&
9662 "Unmatched element size and opcode!\n");
9667 unsigned NumUsesOfInputLD = 128 / ElementSize;
9669 if (BVInOp.isUndef())
9684 if (NumUsesOfInputLD == 1 &&
9685 (
Op->getValueType(0) == MVT::v2i64 && NewOpcode != PPCISD::LD_SPLAT &&
9686 !Subtarget.isLittleEndian() && Subtarget.hasVSX() &&
9687 Subtarget.hasLFIWAX()))
9695 if (NumUsesOfInputLD == 1 && Subtarget.isLittleEndian() &&
9696 Subtarget.isISA3_1() && ElementSize <= 16)
9699 assert(NumUsesOfInputLD > 0 &&
"No uses of input LD of a build_vector?");
9701 Subtarget.hasVSX()) {
9708 NewOpcode, dl, DAG.
getVTList(
Op.getValueType(), MVT::Other),
Ops,
9709 LD->getMemoryVT(),
LD->getMemOperand());
9721 if (Subtarget.hasVSX() && Subtarget.isPPC64() &&
9723 Subtarget.hasP8Vector()))
9729 unsigned SplatSize = SplatBitSize / 8;
9734 if (SplatBits == 0) {
9736 if (
Op.getValueType() != MVT::v4i32 || HasAnyUndefs) {
9748 if (Subtarget.hasPrefixInstrs() && Subtarget.hasP10Vector() && SplatSize == 2)
9750 Op.getValueType(), DAG, dl);
9752 if (Subtarget.hasPrefixInstrs() && Subtarget.hasP10Vector() && SplatSize == 4)
9757 if (Subtarget.hasP9Vector() && SplatSize == 1)
9763 if (SextVal >= -16 && SextVal <= 15) {
9766 unsigned UseSize = SplatSize == 8 ? 4 : SplatSize;
9776 if (Subtarget.hasP9Vector() && SextVal >= -128 && SextVal <= 127) {
9782 switch (SplatSize) {
9786 IID = Intrinsic::ppc_altivec_vupklsb;
9790 IID = Intrinsic::ppc_altivec_vextsb2w;
9794 IID = Intrinsic::ppc_altivec_vextsb2d;
9801 assert(!IsSplat64 &&
"Unhandled 64-bit splat pattern");
9810 if (SextVal >= -32 && SextVal <= 31) {
9815 EVT VT = (SplatSize == 1 ? MVT::v16i8 :
9816 (SplatSize == 2 ? MVT::v8i16 : MVT::v4i32));
9819 if (VT ==
Op.getValueType())
9828 if (SplatSize == 4 && SplatBits == (0x7FFFFFFF&~SplatUndef)) {
9842 static const signed char SplatCsts[] = {
9843 -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7,
9844 -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, 14, -14, 15, -15, -16
9847 for (
unsigned idx = 0; idx < std::size(SplatCsts); ++idx) {
9850 int i = SplatCsts[idx];
9854 unsigned TypeShiftAmt = i & (SplatBitSize-1);
9857 if (SextVal == (
int)((
unsigned)i << TypeShiftAmt)) {
9859 static const unsigned IIDs[] = {
9860 Intrinsic::ppc_altivec_vslb, Intrinsic::ppc_altivec_vslh, 0,
9861 Intrinsic::ppc_altivec_vslw
9868 if (SextVal == (
int)((
unsigned)i >> TypeShiftAmt)) {
9870 static const unsigned IIDs[] = {
9871 Intrinsic::ppc_altivec_vsrb, Intrinsic::ppc_altivec_vsrh, 0,
9872 Intrinsic::ppc_altivec_vsrw
9879 if (SextVal == (
int)(((
unsigned)i << TypeShiftAmt) |
9880 ((
unsigned)i >> (SplatBitSize-TypeShiftAmt)))) {
9882 static const unsigned IIDs[] = {
9883 Intrinsic::ppc_altivec_vrlb, Intrinsic::ppc_altivec_vrlh, 0,
9884 Intrinsic::ppc_altivec_vrlw
9891 if (SextVal == (
int)(((
unsigned)i << 8) | (i < 0 ? 0xFF : 0))) {
9893 unsigned Amt = Subtarget.isLittleEndian() ? 15 : 1;
9897 if (SextVal == (
int)(((
unsigned)i << 16) | (i < 0 ? 0xFFFF : 0))) {
9899 unsigned Amt = Subtarget.isLittleEndian() ? 14 : 2;
9903 if (SextVal == (
int)(((
unsigned)i << 24) | (i < 0 ? 0xFFFFFF : 0))) {
9905 unsigned Amt = Subtarget.isLittleEndian() ? 13 : 3;
9918 unsigned OpNum = (PFEntry >> 26) & 0x0F;
9919 unsigned LHSID = (PFEntry >> 13) & ((1 << 13)-1);
9920 unsigned RHSID = (PFEntry >> 0) & ((1 << 13)-1);
9936 if (LHSID == (1*9+2)*9+3)
return LHS;
9937 assert(LHSID == ((4*9+5)*9+6)*9+7 &&
"Illegal OP_COPY!");
9949 ShufIdxs[ 0] = 0; ShufIdxs[ 1] = 1; ShufIdxs[ 2] = 2; ShufIdxs[ 3] = 3;
9950 ShufIdxs[ 4] = 16; ShufIdxs[ 5] = 17; ShufIdxs[ 6] = 18; ShufIdxs[ 7] = 19;
9951 ShufIdxs[ 8] = 4; ShufIdxs[ 9] = 5; ShufIdxs[10] = 6; ShufIdxs[11] = 7;
9952 ShufIdxs[12] = 20; ShufIdxs[13] = 21; ShufIdxs[14] = 22; ShufIdxs[15] = 23;
9955 ShufIdxs[ 0] = 8; ShufIdxs[ 1] = 9; ShufIdxs[ 2] = 10; ShufIdxs[ 3] = 11;
9956 ShufIdxs[ 4] = 24; ShufIdxs[ 5] = 25; ShufIdxs[ 6] = 26; ShufIdxs[ 7] = 27;
9957 ShufIdxs[ 8] = 12; ShufIdxs[ 9] = 13; ShufIdxs[10] = 14; ShufIdxs[11] = 15;
9958 ShufIdxs[12] = 28; ShufIdxs[13] = 29; ShufIdxs[14] = 30; ShufIdxs[15] = 31;
9961 for (
unsigned i = 0; i != 16; ++i)
9962 ShufIdxs[i] = (i&3)+0;
9965 for (
unsigned i = 0; i != 16; ++i)
9966 ShufIdxs[i] = (i&3)+4;
9969 for (
unsigned i = 0; i != 16; ++i)
9970 ShufIdxs[i] = (i&3)+8;
9973 for (
unsigned i = 0; i != 16; ++i)
9974 ShufIdxs[i] = (i&3)+12;
9995 const unsigned BytesInVector = 16;
9996 bool IsLE = Subtarget.isLittleEndian();
10000 unsigned ShiftElts = 0, InsertAtByte = 0;
10004 unsigned LittleEndianShifts[] = {8, 7, 6, 5, 4, 3, 2, 1,
10005 0, 15, 14, 13, 12, 11, 10, 9};
10006 unsigned BigEndianShifts[] = {9, 10, 11, 12, 13, 14, 15, 0,
10007 1, 2, 3, 4, 5, 6, 7, 8};
10009 ArrayRef<int>
Mask =
N->getMask();
10010 int OriginalOrder[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
10022 bool FoundCandidate =
false;
10026 unsigned VINSERTBSrcElem = IsLE ? 8 : 7;
10029 for (
unsigned i = 0; i < BytesInVector; ++i) {
10030 unsigned CurrentElement =
Mask[i];
10033 if (V2.
isUndef() && CurrentElement != VINSERTBSrcElem)
10036 bool OtherElementsInOrder =
true;
10039 for (
unsigned j = 0;
j < BytesInVector; ++
j) {
10046 (!V2.
isUndef() && CurrentElement < BytesInVector) ? BytesInVector : 0;
10047 if (Mask[j] != OriginalOrder[j] + MaskOffset) {
10048 OtherElementsInOrder =
false;
10055 if (OtherElementsInOrder) {
10062 ShiftElts = IsLE ? LittleEndianShifts[CurrentElement & 0xF]
10063 : BigEndianShifts[CurrentElement & 0xF];
10064 Swap = CurrentElement < BytesInVector;
10066 InsertAtByte = IsLE ? BytesInVector - (i + 1) : i;
10067 FoundCandidate =
true;
10072 if (!FoundCandidate)
10082 SDValue Shl = DAG.
getNode(PPCISD::VECSHL, dl, MVT::v16i8, V2, V2,
10084 return DAG.
getNode(PPCISD::VECINSERT, dl, MVT::v16i8, V1, Shl,
10087 return DAG.
getNode(PPCISD::VECINSERT, dl, MVT::v16i8, V1, V2,
10096 const unsigned NumHalfWords = 8;
10097 const unsigned BytesInVector = NumHalfWords * 2;
10102 bool IsLE = Subtarget.isLittleEndian();
10106 unsigned ShiftElts = 0, InsertAtByte = 0;
10110 unsigned LittleEndianShifts[] = {4, 3, 2, 1, 0, 7, 6, 5};
10111 unsigned BigEndianShifts[] = {5, 6, 7, 0, 1, 2, 3, 4};
10114 uint32_t OriginalOrderLow = 0x1234567;
10115 uint32_t OriginalOrderHigh = 0x89ABCDEF;
10118 for (
unsigned i = 0; i < NumHalfWords; ++i) {
10119 unsigned MaskShift = (NumHalfWords - 1 - i) * 4;
10136 bool FoundCandidate =
false;
10139 for (
unsigned i = 0; i < NumHalfWords; ++i) {
10140 unsigned MaskShift = (NumHalfWords - 1 - i) * 4;
10142 uint32_t MaskOtherElts = ~(0xF <<
MaskShift);
10143 uint32_t TargetOrder = 0x0;
10150 unsigned VINSERTHSrcElem = IsLE ? 4 : 3;
10151 TargetOrder = OriginalOrderLow;
10155 if (MaskOneElt == VINSERTHSrcElem &&
10156 (Mask & MaskOtherElts) == (TargetOrder & MaskOtherElts)) {
10157 InsertAtByte = IsLE ? BytesInVector - (i + 1) * 2 : i * 2;
10158 FoundCandidate =
true;
10164 (MaskOneElt < NumHalfWords) ? OriginalOrderHigh : OriginalOrderLow;
10166 if ((Mask & MaskOtherElts) == (TargetOrder & MaskOtherElts)) {
10168 ShiftElts = IsLE ? LittleEndianShifts[MaskOneElt & 0x7]
10169 : BigEndianShifts[MaskOneElt & 0x7];
10170 InsertAtByte = IsLE ? BytesInVector - (i + 1) * 2 : i * 2;
10171 Swap = MaskOneElt < NumHalfWords;
10172 FoundCandidate =
true;
10178 if (!FoundCandidate)
10190 SDValue Shl = DAG.
getNode(PPCISD::VECSHL, dl, MVT::v16i8, V2, V2,
10193 SDValue Ins = DAG.
getNode(PPCISD::VECINSERT, dl, MVT::v8i16, Conv1, Conv2,
10198 SDValue Ins = DAG.
getNode(PPCISD::VECINSERT, dl, MVT::v8i16, Conv1, Conv2,
10213 auto ShuffleMask = SVN->
getMask();
10228 ShuffleMask = CommutedSV->
getMask();
10237 APInt APSplatValue, APSplatUndef;
10238 unsigned SplatBitSize;
10241 HasAnyUndefs, 0, !Subtarget.isLittleEndian()) ||
10253 bool IsLE = Subtarget.isLittleEndian();
10254 if ((ShuffleMask[0] == 0 && ShuffleMask[8] == 8) &&
10255 (ShuffleMask[4] % 4 == 0 && ShuffleMask[12] % 4 == 0 &&
10256 ShuffleMask[4] > 15 && ShuffleMask[12] > 15))
10258 else if ((ShuffleMask[4] == 4 && ShuffleMask[12] == 12) &&
10259 (ShuffleMask[0] % 4 == 0 && ShuffleMask[8] % 4 == 0 &&
10260 ShuffleMask[0] > 15 && ShuffleMask[8] > 15))
10268 for (; SplatBitSize < 32; SplatBitSize <<= 1)
10269 SplatVal |= (SplatVal << SplatBitSize);
10272 PPCISD::XXSPLTI32DX,
DL, MVT::v2i64, DAG.
getBitcast(MVT::v2i64,
LHS),
10283 assert(
Op.getValueType() == MVT::v1i128 &&
10284 "Only set v1i128 as custom, other type shouldn't reach here!");
10289 if (SHLAmt % 8 == 0) {
10290 std::array<int, 16>
Mask;
10291 std::iota(
Mask.begin(),
Mask.end(), 0);
10292 std::rotate(
Mask.begin(),
Mask.begin() + SHLAmt / 8,
Mask.end());
10321 if (
SDValue NewShuffle = combineVectorShuffle(SVOp, DAG)) {
10326 V1 =
Op.getOperand(0);
10327 V2 =
Op.getOperand(1);
10329 EVT VT =
Op.getValueType();
10330 bool isLittleEndian = Subtarget.isLittleEndian();
10332 unsigned ShiftElts, InsertAtByte;
10338 bool IsPermutedLoad =
false;
10340 if (InputLoad && Subtarget.hasVSX() && V2.
isUndef() &&
10350 if (IsPermutedLoad) {
10351 assert((isLittleEndian || IsFourByte) &&
10352 "Unexpected size for permuted load on big endian target");
10353 SplatIdx += IsFourByte ? 2 : 1;
10354 assert((SplatIdx < (IsFourByte ? 4 : 2)) &&
10355 "Splat of a value outside of the loaded memory");
10360 if ((IsFourByte && Subtarget.hasP9Vector()) || !IsFourByte) {
10363 Offset = isLittleEndian ? (3 - SplatIdx) * 4 : SplatIdx * 4;
10365 Offset = isLittleEndian ? (1 - SplatIdx) * 8 : SplatIdx * 8;
10369 if (
LD->getValueType(0).getSizeInBits() == (IsFourByte ? 32 : 64))
10382 DAG.
getVTList(IsFourByte ? MVT::v4i32 : MVT::v2i64, MVT::Other);
10385 Ops,
LD->getMemoryVT(),
LD->getMemOperand());
10394 if (VT == MVT::v2i64 || VT == MVT::v2f64)
10397 if (Subtarget.hasP9Vector() &&
10407 SDValue Shl = DAG.
getNode(PPCISD::VECSHL, dl, MVT::v4i32, Conv2, Conv2,
10409 SDValue Ins = DAG.
getNode(PPCISD::VECINSERT, dl, MVT::v4i32, Conv1, Shl,
10413 SDValue Ins = DAG.
getNode(PPCISD::VECINSERT, dl, MVT::v4i32, Conv1, Conv2,
10418 if (Subtarget.hasPrefixInstrs() && Subtarget.hasP10Vector()) {
10420 if ((SplatInsertNode = lowerToXXSPLTI32DX(SVOp, DAG)))
10421 return SplatInsertNode;
10424 if (Subtarget.hasP9Altivec()) {
10426 if ((NewISDNode = lowerToVINSERTH(SVOp, DAG)))
10429 if ((NewISDNode = lowerToVINSERTB(SVOp, DAG)))
10433 if (Subtarget.hasVSX() &&
10441 SDValue Shl = DAG.
getNode(PPCISD::VECSHL, dl, MVT::v4i32, Conv1, Conv2,
10446 if (Subtarget.hasVSX() &&
10454 SDValue PermDI = DAG.
getNode(PPCISD::XXPERMDI, dl, MVT::v2i64, Conv1, Conv2,
10459 if (Subtarget.hasP9Vector()) {
10479 if (Subtarget.hasVSX()) {
10492 SDValue Swap = DAG.
getNode(PPCISD::SWAP_NO_CHAIN, dl, MVT::v2f64, Conv);
10500 if (V2.isUndef()) {
10513 (Subtarget.hasP8Altivec() && (
10524 unsigned int ShuffleKind = isLittleEndian ? 2 : 0;
10534 (Subtarget.hasP8Altivec() && (
10542 ArrayRef<int> PermMask = SVOp->
getMask();
10545 unsigned PFIndexes[4];
10546 bool isFourElementShuffle =
true;
10547 for (
unsigned i = 0; i != 4 && isFourElementShuffle;
10549 unsigned EltNo = 8;
10550 for (
unsigned j = 0;
j != 4; ++
j) {
10551 if (PermMask[i * 4 + j] < 0)
10554 unsigned ByteSource = PermMask[i * 4 +
j];
10555 if ((ByteSource & 3) != j) {
10556 isFourElementShuffle =
false;
10561 EltNo = ByteSource / 4;
10562 }
else if (EltNo != ByteSource / 4) {
10563 isFourElementShuffle =
false;
10567 PFIndexes[i] = EltNo;
10575 if (isFourElementShuffle) {
10577 unsigned PFTableIndex = PFIndexes[0] * 9 * 9 * 9 + PFIndexes[1] * 9 * 9 +
10578 PFIndexes[2] * 9 + PFIndexes[3];
10581 unsigned Cost = (PFEntry >> 30);
10601 if (V2.isUndef()) V2 = V1;
10603 return LowerVPERM(
Op, DAG, PermMask, VT, V1, V2);
10609 unsigned Opcode = PPCISD::VPERM;
10612 bool NeedSwap =
false;
10613 bool isLittleEndian = Subtarget.isLittleEndian();
10614 bool isPPC64 = Subtarget.isPPC64();
10616 if (Subtarget.hasVSX() && Subtarget.hasP9Vector() &&
10618 LLVM_DEBUG(
dbgs() <<
"At least one of two input vectors are dead - using "
10619 "XXPERM instead\n");
10620 Opcode = PPCISD::XXPERM;
10628 NeedSwap = !NeedSwap;
10663 unsigned SrcElt = PermMask[i] < 0 ? 0 : PermMask[i];
10665 if (V1HasXXSWAPD) {
10668 else if (SrcElt < 16)
10671 if (V2HasXXSWAPD) {
10674 else if (SrcElt > 15)
10683 for (
unsigned j = 0;
j != BytesPerElement; ++
j)
10684 if (isLittleEndian)
10686 DAG.
getConstant(31 - (SrcElt * BytesPerElement + j), dl, MVT::i32));
10689 DAG.
getConstant(SrcElt * BytesPerElement + j, dl, MVT::i32));
10692 if (V1HasXXSWAPD) {
10696 if (V2HasXXSWAPD) {
10701 if (isPPC64 && (V1HasXXSWAPD || V2HasXXSWAPD)) {
10702 if (ValType != MVT::v2f64)
10708 ShufflesHandledWithVPERM++;
10712 if (Opcode == PPCISD::XXPERM) {
10713 dbgs() <<
"Emitting a XXPERM for the following shuffle:\n";
10715 dbgs() <<
"Emitting a VPERM for the following shuffle:\n";
10718 dbgs() <<
"With the following permute control vector:\n";
10722 if (Opcode == PPCISD::XXPERM)
10723 VPermMask = DAG.
getBitcast(MVT::v4i32, VPermMask);
10727 if (isLittleEndian)
10733 VPERMNode = DAG.
getBitcast(ValType, VPERMNode);
10745 switch (IntrinsicID) {
10749 case Intrinsic::ppc_altivec_vcmpbfp_p:
10753 case Intrinsic::ppc_altivec_vcmpeqfp_p:
10757 case Intrinsic::ppc_altivec_vcmpequb_p:
10761 case Intrinsic::ppc_altivec_vcmpequh_p:
10765 case Intrinsic::ppc_altivec_vcmpequw_p:
10769 case Intrinsic::ppc_altivec_vcmpequd_p:
10770 if (Subtarget.hasVSX() || Subtarget.hasP8Altivec()) {
10776 case Intrinsic::ppc_altivec_vcmpneb_p:
10777 case Intrinsic::ppc_altivec_vcmpneh_p:
10778 case Intrinsic::ppc_altivec_vcmpnew_p:
10779 case Intrinsic::ppc_altivec_vcmpnezb_p:
10780 case Intrinsic::ppc_altivec_vcmpnezh_p:
10781 case Intrinsic::ppc_altivec_vcmpnezw_p:
10782 if (Subtarget.hasP9Altivec()) {
10783 switch (IntrinsicID) {
10786 case Intrinsic::ppc_altivec_vcmpneb_p:
10789 case Intrinsic::ppc_altivec_vcmpneh_p:
10792 case Intrinsic::ppc_altivec_vcmpnew_p:
10795 case Intrinsic::ppc_altivec_vcmpnezb_p:
10798 case Intrinsic::ppc_altivec_vcmpnezh_p:
10801 case Intrinsic::ppc_altivec_vcmpnezw_p:
10809 case Intrinsic::ppc_altivec_vcmpgefp_p:
10813 case Intrinsic::ppc_altivec_vcmpgtfp_p:
10817 case Intrinsic::ppc_altivec_vcmpgtsb_p:
10821 case Intrinsic::ppc_altivec_vcmpgtsh_p:
10825 case Intrinsic::ppc_altivec_vcmpgtsw_p:
10829 case Intrinsic::ppc_altivec_vcmpgtsd_p:
10830 if (Subtarget.hasVSX() || Subtarget.hasP8Altivec()) {
10836 case Intrinsic::ppc_altivec_vcmpgtub_p:
10840 case Intrinsic::ppc_altivec_vcmpgtuh_p:
10844 case Intrinsic::ppc_altivec_vcmpgtuw_p:
10848 case Intrinsic::ppc_altivec_vcmpgtud_p:
10849 if (Subtarget.hasVSX() || Subtarget.hasP8Altivec()) {
10856 case Intrinsic::ppc_altivec_vcmpequq:
10857 case Intrinsic::ppc_altivec_vcmpgtsq:
10858 case Intrinsic::ppc_altivec_vcmpgtuq:
10859 if (!Subtarget.isISA3_1())
10861 switch (IntrinsicID) {
10864 case Intrinsic::ppc_altivec_vcmpequq:
10867 case Intrinsic::ppc_altivec_vcmpgtsq:
10870 case Intrinsic::ppc_altivec_vcmpgtuq:
10877 case Intrinsic::ppc_vsx_xvcmpeqdp_p:
10878 case Intrinsic::ppc_vsx_xvcmpgedp_p:
10879 case Intrinsic::ppc_vsx_xvcmpgtdp_p:
10880 case Intrinsic::ppc_vsx_xvcmpeqsp_p:
10881 case Intrinsic::ppc_vsx_xvcmpgesp_p:
10882 case Intrinsic::ppc_vsx_xvcmpgtsp_p:
10883 if (Subtarget.hasVSX()) {
10884 switch (IntrinsicID) {
10885 case Intrinsic::ppc_vsx_xvcmpeqdp_p:
10888 case Intrinsic::ppc_vsx_xvcmpgedp_p:
10891 case Intrinsic::ppc_vsx_xvcmpgtdp_p:
10894 case Intrinsic::ppc_vsx_xvcmpeqsp_p:
10897 case Intrinsic::ppc_vsx_xvcmpgesp_p:
10900 case Intrinsic::ppc_vsx_xvcmpgtsp_p:
10910 case Intrinsic::ppc_altivec_vcmpbfp:
10913 case Intrinsic::ppc_altivec_vcmpeqfp:
10916 case Intrinsic::ppc_altivec_vcmpequb:
10919 case Intrinsic::ppc_altivec_vcmpequh:
10922 case Intrinsic::ppc_altivec_vcmpequw:
10925 case Intrinsic::ppc_altivec_vcmpequd:
10926 if (Subtarget.hasP8Altivec())
10931 case Intrinsic::ppc_altivec_vcmpneb:
10932 case Intrinsic::ppc_altivec_vcmpneh:
10933 case Intrinsic::ppc_altivec_vcmpnew:
10934 case Intrinsic::ppc_altivec_vcmpnezb:
10935 case Intrinsic::ppc_altivec_vcmpnezh:
10936 case Intrinsic::ppc_altivec_vcmpnezw:
10937 if (Subtarget.hasP9Altivec())
10938 switch (IntrinsicID) {
10941 case Intrinsic::ppc_altivec_vcmpneb:
10944 case Intrinsic::ppc_altivec_vcmpneh:
10947 case Intrinsic::ppc_altivec_vcmpnew:
10950 case Intrinsic::ppc_altivec_vcmpnezb:
10953 case Intrinsic::ppc_altivec_vcmpnezh:
10956 case Intrinsic::ppc_altivec_vcmpnezw:
10963 case Intrinsic::ppc_altivec_vcmpgefp:
10966 case Intrinsic::ppc_altivec_vcmpgtfp:
10969 case Intrinsic::ppc_altivec_vcmpgtsb:
10972 case Intrinsic::ppc_altivec_vcmpgtsh:
10975 case Intrinsic::ppc_altivec_vcmpgtsw:
10978 case Intrinsic::ppc_altivec_vcmpgtsd:
10979 if (Subtarget.hasP8Altivec())
10984 case Intrinsic::ppc_altivec_vcmpgtub:
10987 case Intrinsic::ppc_altivec_vcmpgtuh:
10990 case Intrinsic::ppc_altivec_vcmpgtuw:
10993 case Intrinsic::ppc_altivec_vcmpgtud:
10994 if (Subtarget.hasP8Altivec())
10999 case Intrinsic::ppc_altivec_vcmpequq_p:
11000 case Intrinsic::ppc_altivec_vcmpgtsq_p:
11001 case Intrinsic::ppc_altivec_vcmpgtuq_p:
11002 if (!Subtarget.isISA3_1())
11004 switch (IntrinsicID) {
11007 case Intrinsic::ppc_altivec_vcmpequq_p:
11010 case Intrinsic::ppc_altivec_vcmpgtsq_p:
11013 case Intrinsic::ppc_altivec_vcmpgtuq_p:
11027 unsigned IntrinsicID =
Op.getConstantOperandVal(0);
11033 auto MapNodeWithSplatVector =
11034 [&](
unsigned Opcode,
11035 std::initializer_list<SDValue> ExtraOps = {}) ->
SDValue {
11040 Ops.append(ExtraOps.begin(), ExtraOps.end());
11041 return DAG.
getNode(Opcode, dl, MVT::v16i8,
Ops);
11044 switch (IntrinsicID) {
11045 case Intrinsic::thread_pointer:
11047 if (Subtarget.isPPC64())
11051 case Intrinsic::ppc_rldimi: {
11052 assert(Subtarget.isPPC64() &&
"rldimi is only available in 64-bit!");
11054 APInt
Mask =
Op.getConstantOperandAPInt(4);
11056 return Op.getOperand(2);
11057 if (
Mask.isAllOnes())
11059 uint64_t SH =
Op.getConstantOperandVal(3);
11060 unsigned MB = 0, ME = 0;
11064 if (ME < 63 - SH) {
11067 }
else if (ME > 63 - SH) {
11073 {Op.getOperand(2), Src,
11074 DAG.getTargetConstant(63 - ME, dl, MVT::i32),
11075 DAG.getTargetConstant(MB, dl, MVT::i32)}),
11079 case Intrinsic::ppc_rlwimi: {
11080 APInt
Mask =
Op.getConstantOperandAPInt(4);
11082 return Op.getOperand(2);
11083 if (
Mask.isAllOnes())
11086 unsigned MB = 0, ME = 0;
11090 PPC::RLWIMI, dl, MVT::i32,
11091 {Op.getOperand(2), Op.getOperand(1), Op.getOperand(3),
11092 DAG.getTargetConstant(MB, dl, MVT::i32),
11093 DAG.getTargetConstant(ME, dl, MVT::i32)}),
11097 case Intrinsic::ppc_bcdshift:
11098 return MapNodeWithSplatVector(PPCISD::BCDSHIFT, {
Op.getOperand(3)});
11099 case Intrinsic::ppc_bcdshiftround:
11100 return MapNodeWithSplatVector(PPCISD::BCDSHIFTROUND, {
Op.getOperand(3)});
11101 case Intrinsic::ppc_bcdtruncate:
11102 return MapNodeWithSplatVector(PPCISD::BCDTRUNC, {
Op.getOperand(3)});
11103 case Intrinsic::ppc_bcdunsignedtruncate:
11104 return MapNodeWithSplatVector(PPCISD::BCDUTRUNC);
11105 case Intrinsic::ppc_bcdunsignedshift:
11106 return MapNodeWithSplatVector(PPCISD::BCDUSHIFT);
11108 case Intrinsic::ppc_rlwnm: {
11109 if (
Op.getConstantOperandVal(3) == 0)
11111 unsigned MB = 0, ME = 0;
11116 {Op.getOperand(1), Op.getOperand(2),
11117 DAG.getTargetConstant(MB, dl, MVT::i32),
11118 DAG.getTargetConstant(ME, dl, MVT::i32)}),
11122 case Intrinsic::ppc_mma_disassemble_acc: {
11123 if (Subtarget.isISAFuture()) {
11124 EVT ReturnTypes[] = {MVT::v256i1, MVT::v256i1};
11135 PPCISD::EXTRACT_VSX_REG, dl, MVT::v16i8,
11136 Subtarget.isLittleEndian() ? Value2 :
Value,
11137 DAG.
getConstant(Subtarget.isLittleEndian() ? 1 : 0,
11141 PPCISD::EXTRACT_VSX_REG, dl, MVT::v16i8,
11142 Subtarget.isLittleEndian() ? Value2 :
Value,
11143 DAG.
getConstant(Subtarget.isLittleEndian() ? 0 : 1,
11147 PPCISD::EXTRACT_VSX_REG, dl, MVT::v16i8,
11148 Subtarget.isLittleEndian() ?
Value : Value2,
11149 DAG.
getConstant(Subtarget.isLittleEndian() ? 1 : 0,
11153 PPCISD::EXTRACT_VSX_REG, dl, MVT::v16i8,
11154 Subtarget.isLittleEndian() ?
Value : Value2,
11155 DAG.
getConstant(Subtarget.isLittleEndian() ? 0 : 1,
11162 case Intrinsic::ppc_vsx_disassemble_pair: {
11165 if (IntrinsicID == Intrinsic::ppc_mma_disassemble_acc) {
11167 WideVec = DAG.
getNode(PPCISD::XXMFACC, dl, MVT::v512i1, WideVec);
11170 for (
int VecNo = 0; VecNo < NumVecs; VecNo++) {
11172 PPCISD::EXTRACT_VSX_REG, dl, MVT::v16i8, WideVec,
11173 DAG.
getConstant(Subtarget.isLittleEndian() ? NumVecs - 1 - VecNo
11181 case Intrinsic::ppc_build_dmr: {
11184 for (
int i = 1; i < 9; i += 2) {
11192 DAG.
getNode(PPCISD::PAIR_BUILD, dl, MVT::v256i1, {Hi, Lo}));
11199 case Intrinsic::ppc_mma_dmxxextfdmr512: {
11200 assert(Subtarget.isISAFuture() &&
"dmxxextfdmr512 requires ISA Future");
11202 assert(Idx && (Idx->getSExtValue() == 0 || Idx->getSExtValue() == 1) &&
11203 "Specify P of 0 or 1 for lower or upper 512 bytes");
11204 unsigned HiLo = Idx->getSExtValue();
11208 Opcode = PPC::DMXXEXTFDMR512;
11209 Subx = PPC::sub_wacc_lo;
11211 Opcode = PPC::DMXXEXTFDMR512_HI;
11212 Subx = PPC::sub_wacc_hi;
11215 DAG.
getMachineNode(TargetOpcode::EXTRACT_SUBREG, dl, MVT::v512i1,
11219 EVT ReturnTypes[] = {MVT::v256i1, MVT::v256i1};
11223 case Intrinsic::ppc_mma_dmxxextfdmr256: {
11224 assert(Subtarget.isISAFuture() &&
"dmxxextfdmr256 requires ISA Future");
11226 assert(Idx && (Idx->getSExtValue() >= 0 || Idx->getSExtValue() <= 3) &&
11227 "Specify a dmr row pair 0-3");
11228 unsigned IdxVal = Idx->getSExtValue();
11232 Subx = PPC::sub_dmrrowp0;
11235 Subx = PPC::sub_dmrrowp1;
11238 Subx = PPC::sub_wacc_hi_then_sub_dmrrowp0;
11241 Subx = PPC::sub_wacc_hi_then_sub_dmrrowp1;
11245 DAG.
getMachineNode(TargetOpcode::EXTRACT_SUBREG, dl, MVT::v256i1,
11251 DAG.
getMachineNode(PPC::DMXXEXTFDMR256, dl, MVT::v256i1, {Subreg, P}),
11255 case Intrinsic::ppc_mma_dmxxinstdmr512: {
11256 assert(Subtarget.isISAFuture() &&
"dmxxinstdmr512 requires ISA Future");
11258 assert(Idx && (Idx->getSExtValue() == 0 || Idx->getSExtValue() == 1) &&
11259 "Specify P of 0 or 1 for lower or upper 512 bytes");
11260 unsigned HiLo = Idx->getSExtValue();
11264 Opcode = PPCISD::INST512;
11265 Subx = PPC::sub_wacc_lo;
11267 Opcode = PPCISD::INST512HI;
11268 Subx = PPC::sub_wacc_hi;
11274 Op.getOperand(1), Wacc, SubReg),
11278 case Intrinsic::ppc_mma_dmxxinstdmr256: {
11279 assert(Subtarget.isISAFuture() &&
"dmxxinstdmr256 requires ISA Future");
11281 assert(Idx && (Idx->getSExtValue() >= 0 || Idx->getSExtValue() <= 3) &&
11282 "Specify a dmr row pair 0-3");
11283 unsigned IdxVal = Idx->getSExtValue();
11287 Subx = PPC::sub_dmrrowp0;
11290 Subx = PPC::sub_dmrrowp1;
11293 Subx = PPC::sub_wacc_hi_then_sub_dmrrowp0;
11296 Subx = PPC::sub_wacc_hi_then_sub_dmrrowp1;
11302 DAG.
getNode(PPCISD::INST256, dl, MVT::v256i1,
Op.getOperand(2),
P);
11304 Op.getOperand(1), DMRRowp, SubReg),
11308 case Intrinsic::ppc_mma_xxmfacc:
11309 case Intrinsic::ppc_mma_xxmtacc: {
11311 if (!Subtarget.isISAFuture())
11322 case Intrinsic::ppc_unpack_longdouble: {
11324 assert(Idx && (Idx->getSExtValue() == 0 || Idx->getSExtValue() == 1) &&
11325 "Argument of long double unpack must be 0 or 1!");
11328 Idx->getValueType(0)));
11331 case Intrinsic::ppc_compare_exp_lt:
11332 case Intrinsic::ppc_compare_exp_gt:
11333 case Intrinsic::ppc_compare_exp_eq:
11334 case Intrinsic::ppc_compare_exp_uo: {
11336 switch (IntrinsicID) {
11337 case Intrinsic::ppc_compare_exp_lt:
11340 case Intrinsic::ppc_compare_exp_gt:
11343 case Intrinsic::ppc_compare_exp_eq:
11346 case Intrinsic::ppc_compare_exp_uo:
11352 PPC::SELECT_CC_I4, dl, MVT::i32,
11353 {SDValue(DAG.getMachineNode(PPC::XSCMPEXPDP, dl, MVT::i32,
11354 Op.getOperand(1), Op.getOperand(2)),
11356 DAG.getConstant(1, dl, MVT::i32), DAG.getConstant(0, dl, MVT::i32),
11357 DAG.getTargetConstant(Pred, dl, MVT::i32)}),
11360 case Intrinsic::ppc_test_data_class: {
11361 EVT OpVT =
Op.getOperand(1).getValueType();
11362 unsigned CmprOpc = OpVT == MVT::f128 ? PPC::XSTSTDCQP
11363 : (OpVT == MVT::f64 ? PPC::XSTSTDCDP
11376 {Op.getOperand(2), Op.getOperand(1)}),
11378 if (Subtarget.isISA3_1()) {
11385 TestDataClass, SubRegIdx),
11388 return DAG.
getNode(PPCISD::SETBC, dl, MVT::i32, CRBit);
11394 {TestDataClass, DAG.getConstant(1, dl, MVT::i32),
11395 DAG.getConstant(0, dl, MVT::i32),
11396 DAG.getTargetConstant(PPC::PRED_EQ, dl, MVT::i32)}),
11399 case Intrinsic::ppc_fnmsub: {
11400 EVT VT =
Op.getOperand(1).getValueType();
11401 if (!Subtarget.hasVSX() || (!Subtarget.hasFloat128() && VT == MVT::f128))
11406 return DAG.
getNode(PPCISD::FNMSUB, dl, VT,
Op.getOperand(1),
11407 Op.getOperand(2),
Op.getOperand(3));
11409 case Intrinsic::ppc_convert_f128_to_ppcf128:
11410 case Intrinsic::ppc_convert_ppcf128_to_f128: {
11411 RTLIB::Libcall LC = IntrinsicID == Intrinsic::ppc_convert_ppcf128_to_f128
11412 ? RTLIB::CONVERT_PPCF128_F128
11413 : RTLIB::CONVERT_F128_PPCF128;
11415 std::pair<SDValue, SDValue>
Result =
11416 makeLibCall(DAG, LC,
Op.getValueType(),
Op.getOperand(1), CallOptions,
11420 case Intrinsic::ppc_maxfe:
11421 case Intrinsic::ppc_maxfl:
11422 case Intrinsic::ppc_maxfs:
11423 case Intrinsic::ppc_minfe:
11424 case Intrinsic::ppc_minfl:
11425 case Intrinsic::ppc_minfs: {
11426 EVT VT =
Op.getValueType();
11429 [VT](
const SDUse &Use) { return Use.getValueType() == VT; }) &&
11430 "ppc_[max|min]f[e|l|s] must have uniform type arguments");
11433 if (IntrinsicID == Intrinsic::ppc_minfe ||
11434 IntrinsicID == Intrinsic::ppc_minfl ||
11435 IntrinsicID == Intrinsic::ppc_minfs)
11456 SDValue Tmp = DAG.
getNode(PPCISD::VCMP, dl,
Op.getOperand(2).getValueType(),
11457 Op.getOperand(1),
Op.getOperand(2),
11468 EVT VTs[] = {
Op.getOperand(2).getValueType(), MVT::Glue };
11476 switch (
Op.getConstantOperandVal(1)) {
11481 Bitx = PPC::sub_eq;
11482 SetOp = PPCISD::SETBC;
11487 Bitx = PPC::sub_eq;
11488 SetOp = PPCISD::SETBCR;
11493 Bitx = PPC::sub_lt;
11494 SetOp = PPCISD::SETBC;
11499 Bitx = PPC::sub_lt;
11500 SetOp = PPCISD::SETBCR;
11505 if (Subtarget.isISA3_1()) {
11510 CR6Reg, SubRegIdx, GlueOp),
11512 return DAG.
getNode(SetOp, dl, MVT::i32, CRBit);
11540 switch (
Op.getConstantOperandVal(ArgStart)) {
11541 case Intrinsic::ppc_cfence: {
11542 assert(ArgStart == 1 &&
"llvm.ppc.cfence must carry a chain argument.");
11543 SDValue Val =
Op.getOperand(ArgStart + 1);
11545 if (Ty == MVT::i128) {
11550 unsigned Opcode = Subtarget.isPPC64() ? PPC::CFENCE8 : PPC::CFENCE;
11553 Opcode,
DL, MVT::Other,
11558 case Intrinsic::ppc_disassemble_dmr: {
11560 "llvm.ppc.disassemble.dmr must carry a chain argument.");
11561 return DAG.
getStore(
Op.getOperand(0),
DL,
Op.getOperand(ArgStart + 2),
11562 Op.getOperand(ArgStart + 1), MachinePointerInfo());
11564 case Intrinsic::ppc_amo_stwat:
11565 case Intrinsic::ppc_amo_stdat: {
11568 SDValue Ptr =
Op.getOperand(ArgStart + 1);
11569 SDValue Val =
Op.getOperand(ArgStart + 2);
11572 return DAG.
getNode(PPCISD::STAT, dl, MVT::Other, Chain, Val, Ptr, FC);
11583 if (!Subtarget.isPPC64())
11591 int VectorIndex = 0;
11592 if (Subtarget.isLittleEndian())
11604 "Expecting an atomic compare-and-swap here.");
11607 EVT MemVT = AtomicNode->getMemoryVT();
11625 for (
int i = 0, e = AtomicNode->getNumOperands(); i < e; i++)
11626 Ops.push_back(AtomicNode->getOperand(i));
11628 MachineMemOperand *MMO = AtomicNode->getMemOperand();
11629 SDVTList Tys = DAG.
getVTList(MVT::i32, MVT::Other);
11631 (MemVT == MVT::i8) ? PPCISD::ATOMIC_CMP_SWAP_8 : PPCISD::ATOMIC_CMP_SWAP_16;
11638 EVT MemVT =
N->getMemoryVT();
11640 "Expect quadword atomic operations");
11642 unsigned Opc =
N->getOpcode();
11647 SDVTList Tys = DAG.
getVTList(MVT::i64, MVT::i64, MVT::Other);
11650 DAG.
getConstant(Intrinsic::ppc_atomic_load_i128, dl, MVT::i32)};
11651 for (
int I = 1,
E =
N->getNumOperands();
I <
E; ++
I)
11652 Ops.push_back(
N->getOperand(
I));
11654 Ops, MemVT,
N->getMemOperand());
11661 DAG.
getNode(
ISD::OR, dl, {MVT::i128, MVT::Other}, {ValLo, ValHi});
11668 SDVTList Tys = DAG.
getVTList(MVT::Other);
11671 DAG.
getConstant(Intrinsic::ppc_atomic_store_i128, dl, MVT::i32)};
11677 Ops.push_back(ValLo);
11678 Ops.push_back(ValHi);
11679 Ops.push_back(
N->getOperand(2));
11681 N->getMemOperand());
11693 enum DataClassMask {
11695 DC_NEG_INF = 1 << 4,
11696 DC_POS_INF = 1 << 5,
11697 DC_NEG_ZERO = 1 << 2,
11698 DC_POS_ZERO = 1 << 3,
11699 DC_NEG_SUBNORM = 1,
11700 DC_POS_SUBNORM = 1 << 1,
11703 EVT VT =
Op.getValueType();
11705 unsigned TestOp = VT == MVT::f128 ? PPC::XSTSTDCQP
11706 : VT == MVT::f64 ? PPC::XSTSTDCDP
11717 return DAG.
getNOT(Dl, Rev, MVT::i1);
11724 TestOp, Dl, MVT::i32,
11726 DC_NEG_ZERO | DC_POS_ZERO |
11727 DC_NEG_SUBNORM | DC_POS_SUBNORM,
11733 DAG.
getMachineNode(TargetOpcode::EXTRACT_SUBREG, Dl, MVT::i1, Rev,
11739 TargetOpcode::EXTRACT_SUBREG, Dl, MVT::i1, Rev,
11744 Sign = DAG.
getNOT(Dl, Sign, MVT::i1);
11757 bool IsQuiet = Mask &
fcQNan;
11763 if (VT == MVT::f128) {
11767 QuietMask = 0x8000;
11768 }
else if (VT == MVT::f64) {
11769 if (Subtarget.isPPC64()) {
11780 QuietMask = 0x80000;
11781 }
else if (VT == MVT::f32) {
11783 QuietMask = 0x400000;
11799 unsigned NativeMask = 0;
11801 NativeMask |= DC_NAN;
11803 NativeMask |= DC_NEG_INF;
11805 NativeMask |= DC_POS_INF;
11807 NativeMask |= DC_NEG_ZERO;
11809 NativeMask |= DC_POS_ZERO;
11811 NativeMask |= DC_NEG_SUBNORM;
11813 NativeMask |= DC_POS_SUBNORM;
11816 TargetOpcode::EXTRACT_SUBREG, Dl, MVT::i1,
11818 TestOp, Dl, MVT::i32,
11827 assert(Subtarget.hasP9Vector() &&
"Test data class requires Power9");
11829 uint64_t RHSC =
Op.getConstantOperandVal(1);
11832 if (
LHS.getValueType() == MVT::ppcf128) {
11856 bool Future = Subtarget.isISAFuture();
11859 "Mask predication not supported");
11862 unsigned IID = Future ? Intrinsic::ppc_vsx_lxvrl : Intrinsic::ppc_vsx_lxvl;
11863 unsigned EltBits =
Op->getValueType(0).getScalarType().getSizeInBits();
11867 SDVTList Tys = DAG.
getVTList(
Op->getValueType(0), MVT::Other);
11870 VPLD->getMemoryVT(), VPLD->getMemOperand());
11877 "Mask predication not supported");
11882 Op->getOperand(1).getValueType().getScalarType().getSizeInBits();
11883 bool Future = Subtarget.isISAFuture();
11884 unsigned IID = Future ? Intrinsic::ppc_vsx_stxvrl : Intrinsic::ppc_vsx_stxvl;
11887 VPST->getChain(), DAG.
getConstant(IID, dl, MVT::i32),
11890 SDVTList Tys = DAG.
getVTList(MVT::Other);
11893 VPST->getMemoryVT(), VPST->getMemOperand());
11904 unsigned EltSize =
Op.getValueType().getScalarSizeInBits();
11906 int64_t
IntVal =
Op.getConstantOperandVal(0);
11907 if (IntVal >= -16 && IntVal <= 15)
11913 if (Subtarget.hasLFIWAX() && Subtarget.hasVSX() &&
11918 MachineMemOperand *MMO =
11920 RLI.Alignment, RLI.AAInfo, RLI.Ranges);
11923 PPCISD::LD_SPLAT, dl, DAG.
getVTList(MVT::v4i32, MVT::Other),
Ops,
11927 return Bits.getValue(0);
11943 !Subtarget.isLittleEndian() && ValVT.
isInteger() &&
11948 64 -
Op.getValueType().getScalarSizeInBits(), dl, ShiftAmountTy);
11955 return DAG.
getLoad(
Op.getValueType(), dl, Store, FIdx,
11956 MachinePointerInfo());
11963 return DAG.
getLoad(
Op.getValueType(), dl, Store, FIdx, MachinePointerInfo());
11969 "Should only be called for ISD::INSERT_VECTOR_ELT");
11973 EVT VT =
Op.getValueType();
11978 if (VT == MVT::v2f64 &&
C)
11981 if (Subtarget.hasP9Vector()) {
11990 if ((VT == MVT::v4f32) && (V2.
getValueType() == MVT::f32) &&
11996 BitcastLoad,
Op.getOperand(2));
11997 return DAG.
getBitcast(MVT::v4f32, InsVecElt);
12001 if (Subtarget.isISA3_1()) {
12002 if ((VT == MVT::v2i64 || VT == MVT::v2f64) && !Subtarget.isPPC64())
12006 if (VT == MVT::v16i8 || VT == MVT::v8i16 || VT == MVT::v4i32 ||
12007 VT == MVT::v2i64 || VT == MVT::v4f32 || VT == MVT::v2f64)
12017 if (VT == MVT::v8i16 || VT == MVT::v16i8) {
12020 unsigned InsertAtElement =
C->getZExtValue();
12021 unsigned InsertAtByte = InsertAtElement * BytesInEachElement;
12022 if (Subtarget.isLittleEndian()) {
12023 InsertAtByte = (16 - BytesInEachElement) - InsertAtByte;
12025 return DAG.
getNode(PPCISD::VECINSERT, dl, VT, V1, Mtvsrz,
12037 EVT VT =
Op.getValueType();
12038 bool IsV1024i1 = VT == MVT::v1024i1;
12039 bool IsV2048i1 = VT == MVT::v2048i1;
12043 assert((IsV1024i1 || IsV2048i1) &&
"Unsupported type.");
12045 assert((Subtarget.hasMMA() && Subtarget.isISAFuture()) &&
12046 "Dense Math support required.");
12047 assert(Subtarget.pairedVectorMemops() &&
"Vector pair support required.");
12056 for (
unsigned Idx = 0; Idx < NumVecs; ++Idx) {
12057 MachineMemOperand *NewMMO =
12065 DAG.
getVTList(MVT::v256i1, MVT::Other),
12066 LoadOps, MVT::v256i1, NewMMO);
12071 if (Subtarget.isLittleEndian()) {
12072 std::reverse(Loads.
begin(), Loads.
end());
12073 std::reverse(LoadChains.
begin(), LoadChains.
end());
12085 SDValue Dmr1Value = DMFInsert1024(MoreLoads, dl, DAG);
12091 const SDValue DmrPOps[] = {DmrPRC,
Value, Dmr0Sub, Dmr1Value, Dmr1Sub};
12094 DAG.
getMachineNode(PPC::REG_SEQUENCE, dl, MVT::v2048i1, DmrPOps), 0);
12103 DAG.
getNode(PPCISD::INST512, dl, MVT::v512i1, Pairs[0], Pairs[1]);
12106 DAG.
getNode(PPCISD::INST512HI, dl, MVT::v512i1, Pairs[2], Pairs[3]);
12111 {RC, Lo, LoSub, Hi, HiSub}),
12121 EVT VT =
Op.getValueType();
12123 if (VT == MVT::v1024i1 || VT == MVT::v2048i1)
12124 return LowerDMFVectorLoad(
Op, DAG);
12126 if (VT != MVT::v256i1 && VT != MVT::v512i1)
12130 assert((VT != MVT::v512i1 || Subtarget.hasMMA()) &&
12131 "Type unsupported without MMA");
12132 assert((VT != MVT::v256i1 || Subtarget.pairedVectorMemops()) &&
12133 "Type unsupported without paired vector support");
12137 if (VT == MVT::v256i1 && Subtarget.isISAFuture())
12146 for (
unsigned Idx = 0; Idx < NumVecs; ++Idx) {
12148 DAG.
getLoad(MVT::v16i8, dl, LoadChain, BasePtr,
12157 if (Subtarget.isLittleEndian()) {
12158 std::reverse(Loads.
begin(), Loads.
end());
12159 std::reverse(LoadChains.
begin(), LoadChains.
end());
12163 DAG.
getNode(VT == MVT::v512i1 ? PPCISD::ACC_BUILD : PPCISD::PAIR_BUILD,
12179 bool IsV1024i1 = VT == MVT::v1024i1;
12180 bool IsV2048i1 = VT == MVT::v2048i1;
12184 assert((IsV1024i1 || IsV2048i1) &&
"Unsupported type.");
12186 assert((Subtarget.hasMMA() && Subtarget.isISAFuture()) &&
12187 "Dense Math support required.");
12188 assert(Subtarget.pairedVectorMemops() &&
"Vector pair support required.");
12190 EVT ReturnTypes[] = {MVT::v256i1, MVT::v256i1};
12193 TargetOpcode::EXTRACT_SUBREG, dl, MVT::v512i1,
12198 TargetOpcode::EXTRACT_SUBREG, dl, MVT::v512i1,
12202 MachineSDNode *ExtNode =
12206 ExtNode = DAG.
getMachineNode(PPC::DMXXEXTFDMR512_HI, dl, ReturnTypes,
Hi);
12212 DAG.
getMachineNode(TargetOpcode::EXTRACT_SUBREG, dl, MVT::v1024i1,
12218 DAG.
getMachineNode(TargetOpcode::EXTRACT_SUBREG, dl, MVT::v1024i1,
12224 TargetOpcode::EXTRACT_SUBREG, dl, MVT::v512i1, Dmr0,
12229 TargetOpcode::EXTRACT_SUBREG, dl, MVT::v512i1, Dmr0,
12234 TargetOpcode::EXTRACT_SUBREG, dl, MVT::v512i1, Dmr1,
12239 TargetOpcode::EXTRACT_SUBREG, dl, MVT::v512i1, Dmr1,
12243 MachineSDNode *ExtNode =
12244 DAG.
getMachineNode(PPC::DMXXEXTFDMR512, dl, ReturnTypes, Dmr0Lo);
12248 DAG.
getMachineNode(PPC::DMXXEXTFDMR512_HI, dl, ReturnTypes, Dmr0Hi);
12251 ExtNode = DAG.
getMachineNode(PPC::DMXXEXTFDMR512, dl, ReturnTypes, Dmr1Lo);
12255 DAG.
getMachineNode(PPC::DMXXEXTFDMR512_HI, dl, ReturnTypes, Dmr1Hi);
12260 if (Subtarget.isLittleEndian())
12261 std::reverse(Values.
begin(), Values.
end());
12263 SDVTList Tys = DAG.
getVTList(MVT::Other);
12265 StoreChain, DAG.
getConstant(Intrinsic::ppc_vsx_stxvp, dl, MVT::i32),
12269 for (
unsigned Idx = 0; Idx < NumVecs; ++Idx) {
12270 MachineMemOperand *NewMMO =
12277 Ops[2] = Values[Idx];
12279 MVT::v256i1, NewMMO);
12295 EVT StoreVT =
Value.getValueType();
12297 if (StoreVT == MVT::v1024i1 || StoreVT == MVT::v2048i1)
12298 return LowerDMFVectorStore(
Op, DAG);
12300 if (StoreVT != MVT::v256i1 && StoreVT != MVT::v512i1)
12304 assert((StoreVT != MVT::v512i1 || Subtarget.hasMMA()) &&
12305 "Type unsupported without MMA");
12306 assert((StoreVT != MVT::v256i1 || Subtarget.pairedVectorMemops()) &&
12307 "Type unsupported without paired vector support");
12311 if (StoreVT == MVT::v256i1 && Subtarget.isISAFuture() &&
12319 unsigned NumVecs = 2;
12320 if (StoreVT == MVT::v512i1) {
12321 if (Subtarget.isISAFuture()) {
12322 EVT ReturnTypes[] = {MVT::v256i1, MVT::v256i1};
12324 PPC::DMXXEXTFDMR512, dl, ReturnTypes,
Op.getOperand(1));
12327 Value2 =
SDValue(ExtNode, 1);
12332 for (
unsigned Idx = 0; Idx < NumVecs; ++Idx) {
12333 unsigned VecNum = Subtarget.isLittleEndian() ? NumVecs - 1 - Idx : Idx;
12335 if (Subtarget.isISAFuture()) {
12336 VecNum = Subtarget.isLittleEndian() ? 1 - (Idx % 2) : (Idx % 2);
12337 Elt = DAG.
getNode(PPCISD::EXTRACT_VSX_REG, dl, MVT::v16i8,
12338 Idx > 1 ? Value2 :
Value,
12341 Elt = DAG.
getNode(PPCISD::EXTRACT_VSX_REG, dl, MVT::v16i8,
Value,
12345 DAG.
getStore(StoreChain, dl, Elt, BasePtr,
12359 if (
Op.getValueType() == MVT::v4i32) {
12376 LHS,
RHS, DAG, dl, MVT::v4i32);
12379 LHS, RHSSwap, Zero, DAG, dl, MVT::v4i32);
12384 }
else if (
Op.getValueType() == MVT::v16i8) {
12386 bool isLittleEndian = Subtarget.isLittleEndian();
12390 LHS,
RHS, DAG, dl, MVT::v8i16);
12395 LHS,
RHS, DAG, dl, MVT::v8i16);
12403 for (
unsigned i = 0; i != 8; ++i) {
12404 if (isLittleEndian) {
12406 Ops[i*2+1] = 2*i+16;
12409 Ops[i*2+1] = 2*i+1+16;
12412 if (isLittleEndian)
12422 bool IsStrict =
Op->isStrictFPOpcode();
12423 if (
Op.getOperand(IsStrict ? 1 : 0).getValueType() == MVT::f128 &&
12424 !Subtarget.hasP9Vector())
12434 "Should only be called for ISD::FP_EXTEND");
12438 if (
Op.getValueType() != MVT::v2f64 ||
12439 Op.getOperand(0).getValueType() != MVT::v2f32)
12451 "Node should have 2 operands with second one being a constant!");
12463 int DWord = Idx >> 1;
12466 if (Subtarget.isLittleEndian())
12469 return DAG.
getNode(PPCISD::FP_EXTEND_HALF, dl, MVT::v2f64,
12483 SDValue LoadOps[] = {
LD->getChain(),
LD->getBasePtr()};
12485 PPCISD::LD_VSX_LH, dl, DAG.
getVTList(MVT::v4f32, MVT::Other), LoadOps,
12486 LD->getMemoryVT(),
LD->getMemOperand());
12491 return DAG.
getNode(PPCISD::FP_EXTEND_HALF, dl, MVT::v2f64, NewOp,
12496 SDValue LoadOps[] = {
LD->getChain(),
LD->getBasePtr()};
12498 PPCISD::LD_VSX_LH, dl, DAG.
getVTList(MVT::v4f32, MVT::Other), LoadOps,
12499 LD->getMemoryVT(),
LD->getMemOperand());
12500 return DAG.
getNode(PPCISD::FP_EXTEND_HALF, dl, MVT::v2f64, NewLd,
12511 if (STI.useCRBits())
12528 PPCISD::ADDE,
DL, DAG.
getVTList(SumType, MVT::i32), Zero, Zero, Flag);
12529 if (STI.useCRBits())
12537 SDNode *
N =
Op.getNode();
12538 EVT VT =
N->getValueType(0);
12539 EVT CarryType =
N->getValueType(1);
12540 unsigned Opc =
N->getOpcode();
12542 Opc = IsAdd ? PPCISD::ADDC : PPCISD::SUBC;
12544 N->getOperand(0),
N->getOperand(1));
12556 SDNode *
N =
Op.getNode();
12557 unsigned Opc =
N->getOpcode();
12558 EVT VT =
N->getValueType(0);
12559 EVT CarryType =
N->getValueType(1);
12560 SDValue CarryOp =
N->getOperand(2);
12562 Opc = IsAdd ? PPCISD::ADDE : PPCISD::SUBE;
12568 Op.getOperand(0),
Op.getOperand(1), CarryOp);
12582 EVT VT =
Op.getNode()->getValueType(0);
12608 EVT VT =
Op.getNode()->getValueType(0);
12637 EVT OpVT =
A.getValueType();
12638 EVT ResVT =
Op.getValueType();
12643 if (Subtarget.isPPC64() && OpVT == MVT::i32) {
12653 SDVTList VTs = DAG.
getVTList(OpVT, MVT::i32);
12671 switch (
Op.getOpcode()) {
12691 return LowerSSUBO(
Op, DAG);
12693 return LowerSADDO(
Op, DAG);
12705 return LowerGET_DYNAMIC_AREA_OFFSET(
Op, DAG);
12726 return LowerSET_ROUNDING(
Op, DAG);
12733 case ISD::FSHL:
return LowerFunnelShift(
Op, DAG);
12734 case ISD::FSHR:
return LowerFunnelShift(
Op, DAG);
12746 return LowerFP_ROUND(
Op, DAG);
12760 return LowerINTRINSIC_VOID(
Op, DAG);
12762 return LowerBSWAP(
Op, DAG);
12764 return LowerATOMIC_CMP_SWAP(
Op, DAG);
12766 return LowerATOMIC_LOAD_STORE(
Op, DAG);
12768 return LowerIS_FPCLASS(
Op, DAG);
12771 return LowerADDSUBO(
Op, DAG);
12774 return LowerADDSUBO_CARRY(
Op, DAG);
12776 return LowerUCMP(
Op, DAG);
12782 if (
Op->getFlags().hasNoFPExcept())
12786 return LowerVP_LOAD(
Op, DAG);
12787 case ISD::VP_STORE:
12788 return LowerVP_STORE(
Op, DAG);
12796 switch (
N->getOpcode()) {
12798 llvm_unreachable(
"Do not know how to custom type legalize this operation!");
12815 if (
N->getConstantOperandVal(1) != Intrinsic::loop_decrement)
12818 assert(
N->getValueType(0) == MVT::i1 &&
12819 "Unexpected result type for CTR decrement intrinsic");
12821 N->getValueType(0));
12831 switch (
N->getConstantOperandVal(0)) {
12832 case Intrinsic::ppc_pack_longdouble:
12834 N->getOperand(2),
N->getOperand(1)));
12836 case Intrinsic::ppc_maxfe:
12837 case Intrinsic::ppc_minfe:
12838 case Intrinsic::ppc_fnmsub:
12839 case Intrinsic::ppc_convert_f128_to_ppcf128:
12846 if (!Subtarget.isSVR4ABI() || Subtarget.isPPC64())
12849 EVT VT =
N->getValueType(0);
12851 if (VT == MVT::i64) {
12864 if (
N->getOperand(
N->isStrictFPOpcode() ? 1 : 0).getValueType() ==
12868 Results.push_back(LoweredValue);
12869 if (
N->isStrictFPOpcode())
12874 if (!
N->getValueType(0).isVector())
12907 return Builder.CreateIntrinsic(Id, {});
12913 unsigned SZ = ValueTy->getPrimitiveSizeInBits();
12915 assert((SZ == 8 || SZ == 16 || SZ == 32 || SZ == 64) &&
12916 "Only 8/16/32/64-bit atomic loads supported");
12922 IntID = Intrinsic::ppc_lbarx;
12923 assert(Subtarget.hasPartwordAtomics() &&
"No support partword atomics.");
12926 IntID = Intrinsic::ppc_lharx;
12927 assert(Subtarget.hasPartwordAtomics() &&
"No support partword atomics.");
12930 IntID = Intrinsic::ppc_lwarx;
12933 IntID = Intrinsic::ppc_ldarx;
12937 Builder.CreateIntrinsic(IntID, Addr,
nullptr,
"larx");
12939 return Builder.CreateTruncOrBitCast(
Call, ValueTy);
12950 assert((SZ == 8 || SZ == 16 || SZ == 32 || SZ == 64) &&
12951 "Only 8/16/32/64-bit atomic loads supported");
12957 IntID = Intrinsic::ppc_stbcx;
12958 assert(Subtarget.hasPartwordAtomics() &&
"No support partword atomics.");
12961 IntID = Intrinsic::ppc_sthcx;
12962 assert(Subtarget.hasPartwordAtomics() &&
"No support partword atomics.");
12965 IntID = Intrinsic::ppc_stwcx;
12968 IntID = Intrinsic::ppc_stdcx;
12972 if (SZ == 8 || SZ == 16)
12973 Val = Builder.CreateZExt(Val, Builder.getInt32Ty());
12975 Value *
Call = Builder.CreateIntrinsic(IntID, {Addr, Val},
12977 return Builder.CreateXor(
Call, Builder.getInt32(1));
13000 return Builder.CreateIntrinsic(Intrinsic::ppc_cfence, {Inst->
getType()},
13010 unsigned AtomicSize,
13011 unsigned BinOpcode,
13012 unsigned CmpOpcode,
13013 unsigned CmpPred)
const {
13017 auto LoadMnemonic = PPC::LDARX;
13018 auto StoreMnemonic = PPC::STDCX;
13019 switch (AtomicSize) {
13023 LoadMnemonic = PPC::LBARX;
13024 StoreMnemonic = PPC::STBCX;
13025 assert(Subtarget.hasPartwordAtomics() &&
"Call this only with size >=4");
13028 LoadMnemonic = PPC::LHARX;
13029 StoreMnemonic = PPC::STHCX;
13030 assert(Subtarget.hasPartwordAtomics() &&
"Call this only with size >=4");
13033 LoadMnemonic = PPC::LWARX;
13034 StoreMnemonic = PPC::STWCX;
13037 LoadMnemonic = PPC::LDARX;
13038 StoreMnemonic = PPC::STDCX;
13054 CmpOpcode ?
F->CreateMachineBasicBlock(LLVM_BB) :
nullptr;
13056 F->insert(It, loopMBB);
13058 F->insert(It, loop2MBB);
13059 F->insert(It, exitMBB);
13065 Register TmpReg = (!BinOpcode) ? incr :
13066 RegInfo.createVirtualRegister( AtomicSize == 8 ? &PPC::G8RCRegClass
13067 : &PPC::GPRCRegClass);
13092 BuildMI(BB, dl,
TII->get(LoadMnemonic), dest)
13097 Register CrReg = RegInfo.createVirtualRegister(&PPC::CRRCRegClass);
13099 if (CmpOpcode == PPC::CMPW && AtomicSize < 4) {
13100 Register ExtReg = RegInfo.createVirtualRegister(&PPC::GPRCRegClass);
13101 BuildMI(BB, dl,
TII->get(AtomicSize == 1 ? PPC::EXTSB : PPC::EXTSH),
13131 switch(
MI.getOpcode()) {
13135 return TII->isSignExtended(
MI.getOperand(1).getReg(),
13136 &
MI.getMF()->getRegInfo());
13160 case PPC::EXTSB8_32_64:
13161 case PPC::EXTSB8_rec:
13162 case PPC::EXTSB_rec:
13165 case PPC::EXTSH8_32_64:
13166 case PPC::EXTSH8_rec:
13167 case PPC::EXTSH_rec:
13169 case PPC::EXTSWSLI:
13170 case PPC::EXTSWSLI_32_64:
13171 case PPC::EXTSWSLI_32_64_rec:
13172 case PPC::EXTSWSLI_rec:
13173 case PPC::EXTSW_32:
13174 case PPC::EXTSW_32_64:
13175 case PPC::EXTSW_32_64_rec:
13176 case PPC::EXTSW_rec:
13179 case PPC::SRAWI_rec:
13180 case PPC::SRAW_rec:
13189 unsigned BinOpcode,
unsigned CmpOpcode,
unsigned CmpPred)
const {
13199 bool IsSignExtended =
13202 if (CmpOpcode == PPC::CMPW && !IsSignExtended) {
13203 Register ValueReg = RegInfo.createVirtualRegister(&PPC::GPRCRegClass);
13204 BuildMI(*BB,
MI, dl,
TII->get(is8bit ? PPC::EXTSB : PPC::EXTSH), ValueReg)
13205 .
addReg(
MI.getOperand(3).getReg());
13206 MI.getOperand(3).setReg(ValueReg);
13210 if (Subtarget.hasPartwordAtomics())
13218 bool is64bit = Subtarget.isPPC64();
13219 bool isLittleEndian = Subtarget.isLittleEndian();
13220 unsigned ZeroReg = is64bit ? PPC::ZERO8 : PPC::ZERO;
13231 CmpOpcode ?
F->CreateMachineBasicBlock(LLVM_BB) :
nullptr;
13233 F->insert(It, loopMBB);
13235 F->insert(It, loop2MBB);
13236 F->insert(It, exitMBB);
13242 is64bit ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
13245 Register PtrReg = RegInfo.createVirtualRegister(RC);
13246 Register Shift1Reg = RegInfo.createVirtualRegister(GPRC);
13248 isLittleEndian ? Shift1Reg : RegInfo.createVirtualRegister(GPRC);
13249 Register Incr2Reg = RegInfo.createVirtualRegister(GPRC);
13250 Register MaskReg = RegInfo.createVirtualRegister(GPRC);
13251 Register Mask2Reg = RegInfo.createVirtualRegister(GPRC);
13252 Register Mask3Reg = RegInfo.createVirtualRegister(GPRC);
13253 Register Tmp2Reg = RegInfo.createVirtualRegister(GPRC);
13254 Register Tmp3Reg = RegInfo.createVirtualRegister(GPRC);
13255 Register Tmp4Reg = RegInfo.createVirtualRegister(GPRC);
13256 Register TmpDestReg = RegInfo.createVirtualRegister(GPRC);
13257 Register SrwDestReg = RegInfo.createVirtualRegister(GPRC);
13260 (!BinOpcode) ? Incr2Reg : RegInfo.createVirtualRegister(GPRC);
13287 if (ptrA != ZeroReg) {
13288 Ptr1Reg = RegInfo.createVirtualRegister(RC);
13289 BuildMI(BB, dl,
TII->get(is64bit ? PPC::ADD8 : PPC::ADD4), Ptr1Reg)
13297 BuildMI(BB, dl,
TII->get(PPC::RLWINM), Shift1Reg)
13298 .
addReg(Ptr1Reg, {}, is64bit ? PPC::sub_32 : 0)
13301 .
addImm(is8bit ? 28 : 27);
13302 if (!isLittleEndian)
13303 BuildMI(BB, dl,
TII->get(PPC::XORI), ShiftReg)
13305 .
addImm(is8bit ? 24 : 16);
13307 BuildMI(BB, dl,
TII->get(PPC::RLDICR), PtrReg)
13312 BuildMI(BB, dl,
TII->get(PPC::RLWINM), PtrReg)
13322 BuildMI(BB, dl,
TII->get(PPC::ORI), Mask2Reg)
13326 BuildMI(BB, dl,
TII->get(PPC::SLW), MaskReg)
13331 BuildMI(BB, dl,
TII->get(PPC::LWARX), TmpDestReg)
13335 BuildMI(BB, dl,
TII->get(BinOpcode), TmpReg)
13338 BuildMI(BB, dl,
TII->get(PPC::ANDC), Tmp2Reg)
13345 Register SReg = RegInfo.createVirtualRegister(GPRC);
13346 Register CrReg = RegInfo.createVirtualRegister(&PPC::CRRCRegClass);
13350 unsigned ValueReg = SReg;
13351 unsigned CmpReg = Incr2Reg;
13352 if (CmpOpcode == PPC::CMPW) {
13353 ValueReg = RegInfo.createVirtualRegister(GPRC);
13354 BuildMI(BB, dl,
TII->get(PPC::SRW), ValueReg)
13357 Register ValueSReg = RegInfo.createVirtualRegister(GPRC);
13358 BuildMI(BB, dl,
TII->get(is8bit ? PPC::EXTSB : PPC::EXTSH), ValueSReg)
13360 ValueReg = ValueSReg;
13392 .
addImm(is8bit ? 24 : 16)
13413 Register DstReg =
MI.getOperand(0).getReg();
13415 assert(
TRI->isTypeLegalForClass(*RC, MVT::i32) &&
"Invalid destination!");
13420 assert((PVT == MVT::i64 || PVT == MVT::i32) &&
13421 "Invalid Pointer Size!");
13470 Register BufReg =
MI.getOperand(1).getReg();
13472 if (Subtarget.is64BitELFABI()) {
13485 BaseReg = Subtarget.isPPC64() ? PPC::X1 : PPC::R1;
13487 BaseReg = Subtarget.isPPC64() ? PPC::BP8 : PPC::BP;
13490 TII->get(Subtarget.isPPC64() ? PPC::STD : PPC::STW))
13513 TII->get(Subtarget.isPPC64() ? PPC::MFLR8 : PPC::MFLR), LabelReg);
13516 if (Subtarget.isPPC64()) {
13534 TII->get(PPC::PHI), DstReg)
13538 MI.eraseFromParent();
13552 assert((PVT == MVT::i64 || PVT == MVT::i32) &&
13553 "Invalid Pointer Size!");
13556 (PVT == MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
13559 unsigned FP = (PVT == MVT::i64) ? PPC::X31 : PPC::R31;
13560 unsigned SP = (PVT == MVT::i64) ? PPC::X1 : PPC::R1;
13574 Register BufReg =
MI.getOperand(0).getReg();
13579 if (PVT == MVT::i64) {
13591 if (PVT == MVT::i64) {
13603 if (PVT == MVT::i64) {
13615 if (PVT == MVT::i64) {
13627 if (PVT == MVT::i64 && Subtarget.isSVR4ABI()) {
13637 TII->get(PVT == MVT::i64 ? PPC::MTCTR8 : PPC::MTCTR)).
addReg(Tmp);
13640 MI.eraseFromParent();
13656 "Unexpected stack alignment");
13660 unsigned StackProbeSize =
13663 StackProbeSize &= ~(StackAlign - 1);
13664 return StackProbeSize ? StackProbeSize : StackAlign;
13676 const bool isPPC64 = Subtarget.isPPC64();
13708 MF->
insert(MBBIter, TestMBB);
13709 MF->
insert(MBBIter, BlockMBB);
13710 MF->
insert(MBBIter, TailMBB);
13715 Register DstReg =
MI.getOperand(0).getReg();
13716 Register NegSizeReg =
MI.getOperand(1).getReg();
13728 isPPC64 ? PPC::PREPARE_PROBED_ALLOCA_64 : PPC::PREPARE_PROBED_ALLOCA_32;
13734 ProbeOpc = isPPC64 ? PPC::PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64
13735 : PPC::PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_32;
13737 .
addDef(ActualNegSizeReg)
13739 .
add(
MI.getOperand(2))
13740 .
add(
MI.getOperand(3));
13746 .
addReg(ActualNegSizeReg);
13749 int64_t NegProbeSize = -(int64_t)ProbeSize;
13755 .
addImm(NegProbeSize >> 16);
13759 .
addImm(NegProbeSize & 0xFFFF);
13768 .
addReg(ActualNegSizeReg)
13777 .
addReg(ActualNegSizeReg);
13787 BuildMI(TestMBB,
DL,
TII->get(isPPC64 ? PPC::CMPD : PPC::CMPW), CmpResult)
13814 TII->get(isPPC64 ? PPC::DYNAREAOFFSET8 : PPC::DYNAREAOFFSET),
13815 MaxCallFrameSizeReg)
13816 .
add(
MI.getOperand(2))
13817 .
add(
MI.getOperand(3));
13818 BuildMI(TailMBB,
DL,
TII->get(isPPC64 ? PPC::ADD8 : PPC::ADD4), DstReg)
13820 .
addReg(MaxCallFrameSizeReg);
13826 MBB->addSuccessor(TestMBB);
13829 MI.eraseFromParent();
13831 ++NumDynamicAllocaProbed;
13836 switch (
MI.getOpcode()) {
13837 case PPC::SELECT_CC_I4:
13838 case PPC::SELECT_CC_I8:
13839 case PPC::SELECT_CC_F4:
13840 case PPC::SELECT_CC_F8:
13841 case PPC::SELECT_CC_F16:
13842 case PPC::SELECT_CC_VRRC:
13843 case PPC::SELECT_CC_VSFRC:
13844 case PPC::SELECT_CC_VSSRC:
13845 case PPC::SELECT_CC_VSRC:
13846 case PPC::SELECT_CC_SPE4:
13847 case PPC::SELECT_CC_SPE:
13855 switch (
MI.getOpcode()) {
13856 case PPC::SELECT_I4:
13857 case PPC::SELECT_I8:
13858 case PPC::SELECT_F4:
13859 case PPC::SELECT_F8:
13860 case PPC::SELECT_F16:
13861 case PPC::SELECT_SPE:
13862 case PPC::SELECT_SPE4:
13863 case PPC::SELECT_VRRC:
13864 case PPC::SELECT_VSFRC:
13865 case PPC::SELECT_VSSRC:
13866 case PPC::SELECT_VSRC:
13876 if (
MI.getOpcode() == TargetOpcode::STACKMAP ||
13877 MI.getOpcode() == TargetOpcode::PATCHPOINT) {
13878 if (Subtarget.is64BitELFABI() &&
13879 MI.getOpcode() == TargetOpcode::PATCHPOINT &&
13880 !Subtarget.isUsingPCRelativeCalls()) {
13892 if (
MI.getOpcode() == PPC::EH_SjLj_SetJmp32 ||
13893 MI.getOpcode() == PPC::EH_SjLj_SetJmp64) {
13895 }
else if (
MI.getOpcode() == PPC::EH_SjLj_LongJmp32 ||
13896 MI.getOpcode() == PPC::EH_SjLj_LongJmp64) {
13910 if (Subtarget.hasISEL() &&
13911 (
MI.getOpcode() == PPC::SELECT_CC_I4 ||
13912 MI.getOpcode() == PPC::SELECT_CC_I8 ||
13913 MI.getOpcode() == PPC::SELECT_I4 ||
MI.getOpcode() == PPC::SELECT_I8)) {
13915 if (
MI.getOpcode() == PPC::SELECT_CC_I4 ||
13916 MI.getOpcode() == PPC::SELECT_CC_I8)
13917 Cond.push_back(
MI.getOperand(4));
13920 Cond.push_back(
MI.getOperand(1));
13923 TII->insertSelect(*BB,
MI, dl,
MI.getOperand(0).getReg(),
Cond,
13924 MI.getOperand(2).getReg(),
MI.getOperand(3).getReg());
13940 F->insert(It, copy0MBB);
13941 F->insert(It, sinkMBB);
13950 unsigned CallFrameSize =
TII->getCallFrameSizeAt(
MI);
13965 .
addReg(
MI.getOperand(1).getReg())
13968 unsigned SelectPred =
MI.getOperand(4).getImm();
13971 .
addReg(
MI.getOperand(1).getReg())
13988 .
addReg(
MI.getOperand(3).getReg())
13990 .
addReg(
MI.getOperand(2).getReg())
13992 }
else if (
MI.getOpcode() == PPC::ReadTB) {
14008 F->insert(It, readMBB);
14009 F->insert(It, sinkMBB);
14020 Register ReadAgainReg = RegInfo.createVirtualRegister(&PPC::GPRCRegClass);
14028 Register CmpReg = RegInfo.createVirtualRegister(&PPC::CRRCRegClass);
14030 BuildMI(BB, dl,
TII->get(PPC::CMPW), CmpReg)
14040 }
else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_ADD_I8)
14042 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_ADD_I16)
14044 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_ADD_I32)
14046 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_ADD_I64)
14049 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_AND_I8)
14051 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_AND_I16)
14053 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_AND_I32)
14055 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_AND_I64)
14058 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_OR_I8)
14060 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_OR_I16)
14062 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_OR_I32)
14064 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_OR_I64)
14067 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_XOR_I8)
14069 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_XOR_I16)
14071 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_XOR_I32)
14073 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_XOR_I64)
14076 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_NAND_I8)
14078 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_NAND_I16)
14080 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_NAND_I32)
14082 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_NAND_I64)
14085 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_SUB_I8)
14087 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_SUB_I16)
14089 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_SUB_I32)
14091 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_SUB_I64)
14094 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_MIN_I8)
14096 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_MIN_I16)
14098 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_MIN_I32)
14100 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_MIN_I64)
14103 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_MAX_I8)
14105 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_MAX_I16)
14107 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_MAX_I32)
14109 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_MAX_I64)
14112 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_UMIN_I8)
14114 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_UMIN_I16)
14116 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_UMIN_I32)
14118 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_UMIN_I64)
14121 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_UMAX_I8)
14123 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_UMAX_I16)
14125 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_UMAX_I32)
14127 else if (
MI.getOpcode() == PPC::ATOMIC_LOAD_UMAX_I64)
14130 else if (
MI.getOpcode() == PPC::ATOMIC_SWAP_I8)
14132 else if (
MI.getOpcode() == PPC::ATOMIC_SWAP_I16)
14134 else if (
MI.getOpcode() == PPC::ATOMIC_SWAP_I32)
14136 else if (
MI.getOpcode() == PPC::ATOMIC_SWAP_I64)
14138 else if (
MI.getOpcode() == PPC::ATOMIC_CMP_SWAP_I32 ||
14139 MI.getOpcode() == PPC::ATOMIC_CMP_SWAP_I64 ||
14140 (Subtarget.hasPartwordAtomics() &&
14141 MI.getOpcode() == PPC::ATOMIC_CMP_SWAP_I8) ||
14142 (Subtarget.hasPartwordAtomics() &&
14143 MI.getOpcode() == PPC::ATOMIC_CMP_SWAP_I16)) {
14144 bool is64bit =
MI.getOpcode() == PPC::ATOMIC_CMP_SWAP_I64;
14146 auto LoadMnemonic = PPC::LDARX;
14147 auto StoreMnemonic = PPC::STDCX;
14148 switch (
MI.getOpcode()) {
14151 case PPC::ATOMIC_CMP_SWAP_I8:
14152 LoadMnemonic = PPC::LBARX;
14153 StoreMnemonic = PPC::STBCX;
14154 assert(Subtarget.hasPartwordAtomics() &&
"No support partword atomics.");
14156 case PPC::ATOMIC_CMP_SWAP_I16:
14157 LoadMnemonic = PPC::LHARX;
14158 StoreMnemonic = PPC::STHCX;
14159 assert(Subtarget.hasPartwordAtomics() &&
"No support partword atomics.");
14161 case PPC::ATOMIC_CMP_SWAP_I32:
14162 LoadMnemonic = PPC::LWARX;
14163 StoreMnemonic = PPC::STWCX;
14165 case PPC::ATOMIC_CMP_SWAP_I64:
14166 LoadMnemonic = PPC::LDARX;
14167 StoreMnemonic = PPC::STDCX;
14174 Register CrReg = RegInfo.createVirtualRegister(&PPC::CRRCRegClass);
14175 Register oldval =
MI.getOperand(3).getReg();
14176 Register newval =
MI.getOperand(4).getReg();
14182 F->insert(It, loop1MBB);
14183 F->insert(It, loop2MBB);
14184 F->insert(It, exitMBB);
14205 BuildMI(BB, dl,
TII->get(is64bit ? PPC::CMPD : PPC::CMPW), CrReg)
14231 }
else if (
MI.getOpcode() == PPC::ATOMIC_CMP_SWAP_I8 ||
14232 MI.getOpcode() == PPC::ATOMIC_CMP_SWAP_I16) {
14236 bool is64bit = Subtarget.isPPC64();
14237 bool isLittleEndian = Subtarget.isLittleEndian();
14238 bool is8bit =
MI.getOpcode() == PPC::ATOMIC_CMP_SWAP_I8;
14243 Register oldval =
MI.getOperand(3).getReg();
14244 Register newval =
MI.getOperand(4).getReg();
14250 F->insert(It, loop1MBB);
14251 F->insert(It, loop2MBB);
14252 F->insert(It, exitMBB);
14259 is64bit ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
14262 Register PtrReg = RegInfo.createVirtualRegister(RC);
14263 Register Shift1Reg = RegInfo.createVirtualRegister(GPRC);
14265 isLittleEndian ? Shift1Reg : RegInfo.createVirtualRegister(GPRC);
14266 Register NewVal2Reg = RegInfo.createVirtualRegister(GPRC);
14267 Register NewVal3Reg = RegInfo.createVirtualRegister(GPRC);
14268 Register OldVal2Reg = RegInfo.createVirtualRegister(GPRC);
14269 Register OldVal3Reg = RegInfo.createVirtualRegister(GPRC);
14270 Register MaskReg = RegInfo.createVirtualRegister(GPRC);
14271 Register Mask2Reg = RegInfo.createVirtualRegister(GPRC);
14272 Register Mask3Reg = RegInfo.createVirtualRegister(GPRC);
14273 Register Tmp2Reg = RegInfo.createVirtualRegister(GPRC);
14274 Register Tmp4Reg = RegInfo.createVirtualRegister(GPRC);
14275 Register TmpDestReg = RegInfo.createVirtualRegister(GPRC);
14277 Register TmpReg = RegInfo.createVirtualRegister(GPRC);
14278 Register ZeroReg = is64bit ? PPC::ZERO8 : PPC::ZERO;
14279 Register CrReg = RegInfo.createVirtualRegister(&PPC::CRRCRegClass);
14310 if (ptrA != ZeroReg) {
14311 Ptr1Reg = RegInfo.createVirtualRegister(RC);
14312 BuildMI(BB, dl,
TII->get(is64bit ? PPC::ADD8 : PPC::ADD4), Ptr1Reg)
14321 BuildMI(BB, dl,
TII->get(PPC::RLWINM), Shift1Reg)
14322 .
addReg(Ptr1Reg, {}, is64bit ? PPC::sub_32 : 0)
14325 .
addImm(is8bit ? 28 : 27);
14326 if (!isLittleEndian)
14327 BuildMI(BB, dl,
TII->get(PPC::XORI), ShiftReg)
14329 .
addImm(is8bit ? 24 : 16);
14331 BuildMI(BB, dl,
TII->get(PPC::RLDICR), PtrReg)
14336 BuildMI(BB, dl,
TII->get(PPC::RLWINM), PtrReg)
14341 BuildMI(BB, dl,
TII->get(PPC::SLW), NewVal2Reg)
14344 BuildMI(BB, dl,
TII->get(PPC::SLW), OldVal2Reg)
14351 BuildMI(BB, dl,
TII->get(PPC::ORI), Mask2Reg)
14355 BuildMI(BB, dl,
TII->get(PPC::SLW), MaskReg)
14358 BuildMI(BB, dl,
TII->get(PPC::AND), NewVal3Reg)
14361 BuildMI(BB, dl,
TII->get(PPC::AND), OldVal3Reg)
14366 BuildMI(BB, dl,
TII->get(PPC::LWARX), TmpDestReg)
14383 BuildMI(BB, dl,
TII->get(PPC::ANDC), Tmp2Reg)
14407 }
else if (
MI.getOpcode() == PPC::FADDrtz) {
14417 Register MFFSReg = RegInfo.createVirtualRegister(&PPC::F8RCRegClass);
14432 auto MIB =
BuildMI(*BB,
MI, dl,
TII->get(PPC::FADD), Dest)
14440 }
else if (
MI.getOpcode() == PPC::ANDI_rec_1_EQ_BIT ||
14441 MI.getOpcode() == PPC::ANDI_rec_1_GT_BIT ||
14442 MI.getOpcode() == PPC::ANDI_rec_1_EQ_BIT8 ||
14443 MI.getOpcode() == PPC::ANDI_rec_1_GT_BIT8) {
14444 unsigned Opcode = (
MI.getOpcode() == PPC::ANDI_rec_1_EQ_BIT8 ||
14445 MI.getOpcode() == PPC::ANDI_rec_1_GT_BIT8)
14448 bool IsEQ = (
MI.getOpcode() == PPC::ANDI_rec_1_EQ_BIT ||
14449 MI.getOpcode() == PPC::ANDI_rec_1_EQ_BIT8);
14452 Register Dest = RegInfo.createVirtualRegister(
14453 Opcode == PPC::ANDI_rec ? &PPC::GPRCRegClass : &PPC::G8RCRegClass);
14457 .
addReg(
MI.getOperand(1).getReg())
14460 MI.getOperand(0).getReg())
14461 .
addReg(IsEQ ? PPC::CR0EQ : PPC::CR0GT);
14462 }
else if (
MI.getOpcode() == PPC::TCHECK_RET) {
14465 Register CRReg = RegInfo.createVirtualRegister(&PPC::CRRCRegClass);
14468 MI.getOperand(0).getReg())
14470 }
else if (
MI.getOpcode() == PPC::TBEGIN_RET) {
14472 unsigned Imm =
MI.getOperand(1).getImm();
14475 MI.getOperand(0).getReg())
14477 }
else if (
MI.getOpcode() == PPC::SETRNDi) {
14479 Register OldFPSCRReg =
MI.getOperand(0).getReg();
14483 BuildMI(*BB,
MI, dl,
TII->get(TargetOpcode::IMPLICIT_DEF), OldFPSCRReg);
14485 BuildMI(*BB,
MI, dl,
TII->get(PPC::MFFS), OldFPSCRReg);
14496 unsigned Mode =
MI.getOperand(1).getImm();
14497 BuildMI(*BB,
MI, dl,
TII->get((Mode & 1) ? PPC::MTFSB1 : PPC::MTFSB0))
14501 BuildMI(*BB,
MI, dl,
TII->get((Mode & 2) ? PPC::MTFSB1 : PPC::MTFSB0))
14504 }
else if (
MI.getOpcode() == PPC::SETRND) {
14512 auto copyRegFromG8RCOrF8RC = [&] (
unsigned DestReg,
unsigned SrcReg) {
14513 if (Subtarget.hasDirectMove()) {
14514 BuildMI(*BB,
MI, dl,
TII->get(TargetOpcode::COPY), DestReg)
14518 unsigned StoreOp = PPC::STD, LoadOp = PPC::LFD;
14521 if (RC == &PPC::F8RCRegClass) {
14523 assert((RegInfo.getRegClass(DestReg) == &PPC::G8RCRegClass) &&
14524 "Unsupported RegClass.");
14526 StoreOp = PPC::STFD;
14530 assert((RegInfo.getRegClass(SrcReg) == &PPC::G8RCRegClass) &&
14531 (RegInfo.getRegClass(DestReg) == &PPC::F8RCRegClass) &&
14532 "Unsupported RegClass.");
14565 Register OldFPSCRReg =
MI.getOperand(0).getReg();
14568 BuildMI(*BB,
MI, dl,
TII->get(PPC::MFFS), OldFPSCRReg);
14580 Register OldFPSCRTmpReg = RegInfo.createVirtualRegister(&PPC::G8RCRegClass);
14582 copyRegFromG8RCOrF8RC(OldFPSCRTmpReg, OldFPSCRReg);
14584 Register ImDefReg = RegInfo.createVirtualRegister(&PPC::G8RCRegClass);
14585 Register ExtSrcReg = RegInfo.createVirtualRegister(&PPC::G8RCRegClass);
14590 BuildMI(*BB,
MI, dl,
TII->get(TargetOpcode::IMPLICIT_DEF), ImDefReg);
14591 BuildMI(*BB,
MI, dl,
TII->get(PPC::INSERT_SUBREG), ExtSrcReg)
14596 Register NewFPSCRTmpReg = RegInfo.createVirtualRegister(&PPC::G8RCRegClass);
14597 BuildMI(*BB,
MI, dl,
TII->get(PPC::RLDIMI), NewFPSCRTmpReg)
14603 Register NewFPSCRReg = RegInfo.createVirtualRegister(&PPC::F8RCRegClass);
14604 copyRegFromG8RCOrF8RC(NewFPSCRReg, NewFPSCRTmpReg);
14613 }
else if (
MI.getOpcode() == PPC::SETFLM) {
14617 Register OldFPSCRReg =
MI.getOperand(0).getReg();
14619 BuildMI(*BB,
MI, Dl,
TII->get(TargetOpcode::IMPLICIT_DEF), OldFPSCRReg);
14621 BuildMI(*BB,
MI, Dl,
TII->get(PPC::MFFS), OldFPSCRReg);
14624 Register NewFPSCRReg =
MI.getOperand(1).getReg();
14630 }
else if (
MI.getOpcode() == PPC::PROBED_ALLOCA_32 ||
14631 MI.getOpcode() == PPC::PROBED_ALLOCA_64) {
14633 }
else if (
MI.getOpcode() == PPC::SPLIT_QUADWORD) {
14640 .
addUse(Src, {}, PPC::sub_gp8_x1);
14643 .
addUse(Src, {}, PPC::sub_gp8_x0);
14644 }
else if (
MI.getOpcode() == PPC::LQX_PSEUDO ||
14645 MI.getOpcode() == PPC::STQX_PSEUDO) {
14651 F->getRegInfo().createVirtualRegister(&PPC::G8RC_and_G8RC_NOX0RegClass);
14657 MI.getOpcode() == PPC::LQX_PSEUDO ?
TII->get(PPC::LQ)
14658 :
TII->get(PPC::STQ))
14662 }
else if (
MI.getOpcode() == PPC::LWAT_PSEUDO ||
14663 MI.getOpcode() == PPC::LDAT_PSEUDO) {
14665 Register DstReg =
MI.getOperand(0).getReg();
14666 Register PtrReg =
MI.getOperand(1).getReg();
14667 Register ValReg =
MI.getOperand(2).getReg();
14668 unsigned FC =
MI.getOperand(3).getImm();
14669 bool IsLwat =
MI.getOpcode() == PPC::LWAT_PSEUDO;
14672 BuildMI(*BB,
MI,
DL,
TII->get(TargetOpcode::SUBREG_TO_REG), Val64)
14680 BuildMI(*BB,
MI,
DL,
TII->get(TargetOpcode::IMPLICIT_DEF), UndefG8r);
14683 .
addImm(PPC::sub_gp8_x0)
14685 .
addImm(PPC::sub_gp8_x1);
14688 BuildMI(*BB,
MI,
DL,
TII->get(IsLwat ? PPC::LWAT : PPC::LDAT), PairResult)
14694 .
addReg(PairResult, {}, PPC::sub_gp8_x0);
14697 .
addReg(Result64, {}, PPC::sub_32);
14701 }
else if (
MI.getOpcode() == PPC::LWAT_COND_PSEUDO ||
14702 MI.getOpcode() == PPC::LDAT_COND_PSEUDO) {
14704 Register DstReg =
MI.getOperand(0).getReg();
14705 Register PtrReg =
MI.getOperand(1).getReg();
14706 unsigned FC =
MI.getOperand(2).getImm();
14707 bool IsLwat_Cond =
MI.getOpcode() == PPC::LWAT_COND_PSEUDO;
14710 BuildMI(*BB,
MI,
DL,
TII->get(TargetOpcode::IMPLICIT_DEF), Pair);
14713 BuildMI(*BB,
MI,
DL,
TII->get(IsLwat_Cond ? PPC::LWAT : PPC::LDAT),
14720 .
addReg(PairResult, {}, PPC::sub_gp8_x0);
14723 .
addReg(Result64, {}, PPC::sub_32);
14731 MI.eraseFromParent();
14744 int RefinementSteps = Subtarget.hasRecipPrec() ? 1 : 3;
14747 return RefinementSteps;
14754 EVT VT =
Op.getValueType();
14757 ((VT != MVT::v2f64 && VT != MVT::v4f32) || !Subtarget.hasVSX())))
14781PPCTargetLowering::getSqrtResultForDenormInput(
SDValue Op,
14784 EVT VT =
Op.getValueType();
14785 if (VT != MVT::f64 &&
14786 ((VT != MVT::v2f64 && VT != MVT::v4f32) || !Subtarget.hasVSX()))
14789 return DAG.
getNode(PPCISD::FSQRT, SDLoc(
Op), VT,
Op);
14793 int Enabled,
int &RefinementSteps,
14794 bool &UseOneConstNR,
14795 bool Reciprocal)
const {
14797 if ((VT == MVT::f32 && Subtarget.hasFRSQRTES()) ||
14798 (VT == MVT::f64 && Subtarget.hasFRSQRTE()) ||
14799 (VT == MVT::v4f32 && Subtarget.hasAltivec()) ||
14800 (VT == MVT::v2f64 && Subtarget.hasVSX())) {
14806 UseOneConstNR = !Subtarget.needsTwoConstNR();
14807 return DAG.
getNode(PPCISD::FRSQRTE, SDLoc(Operand), VT, Operand);
14814 int &RefinementSteps)
const {
14816 if ((VT == MVT::f32 && Subtarget.hasFRES()) ||
14817 (VT == MVT::f64 && Subtarget.hasFRE()) ||
14818 (VT == MVT::v4f32 && Subtarget.hasAltivec()) ||
14819 (VT == MVT::v2f64 && Subtarget.hasVSX())) {
14822 return DAG.
getNode(PPCISD::FRE, SDLoc(Operand), VT, Operand);
14838 switch (Subtarget.getCPUDirective()) {
14865 unsigned Bytes,
int Dist,
14879 if (FS != BFS || FS != (
int)Bytes)
return false;
14884 int64_t Offset1 = 0, Offset2 = 0;
14887 if (Base1 == Base2 && Offset1 == (Offset2 + Dist * Bytes))
14897 if (isGA1 && isGA2 && GV1 == GV2)
14898 return Offset1 == (Offset2 + Dist*Bytes);
14905 unsigned Bytes,
int Dist,
14908 EVT VT = LS->getMemoryVT();
14915 switch (
N->getConstantOperandVal(1)) {
14916 default:
return false;
14917 case Intrinsic::ppc_altivec_lvx:
14918 case Intrinsic::ppc_altivec_lvxl:
14919 case Intrinsic::ppc_vsx_lxvw4x:
14920 case Intrinsic::ppc_vsx_lxvw4x_be:
14923 case Intrinsic::ppc_vsx_lxvd2x:
14924 case Intrinsic::ppc_vsx_lxvd2x_be:
14927 case Intrinsic::ppc_altivec_lvebx:
14930 case Intrinsic::ppc_altivec_lvehx:
14933 case Intrinsic::ppc_altivec_lvewx:
14943 switch (
N->getConstantOperandVal(1)) {
14944 default:
return false;
14945 case Intrinsic::ppc_altivec_stvx:
14946 case Intrinsic::ppc_altivec_stvxl:
14947 case Intrinsic::ppc_vsx_stxvw4x:
14950 case Intrinsic::ppc_vsx_stxvd2x:
14953 case Intrinsic::ppc_vsx_stxvw4x_be:
14956 case Intrinsic::ppc_vsx_stxvd2x_be:
14959 case Intrinsic::ppc_altivec_stvebx:
14962 case Intrinsic::ppc_altivec_stvehx:
14965 case Intrinsic::ppc_altivec_stvewx:
14982 SDValue Chain = LD->getChain();
14983 EVT VT = LD->getMemoryVT();
14992 while (!Queue.empty()) {
14993 SDNode *ChainNext = Queue.pop_back_val();
14994 if (!Visited.
insert(ChainNext).second)
15001 if (!Visited.
count(ChainLD->getChain().getNode()))
15002 Queue.push_back(ChainLD->getChain().getNode());
15004 for (
const SDUse &O : ChainNext->
ops())
15005 if (!Visited.
count(O.getNode()))
15006 Queue.push_back(O.getNode());
15008 LoadRoots.
insert(ChainNext);
15019 for (
SDNode *
I : LoadRoots) {
15020 Queue.push_back(
I);
15022 while (!Queue.empty()) {
15023 SDNode *LoadRoot = Queue.pop_back_val();
15024 if (!Visited.
insert(LoadRoot).second)
15036 Queue.push_back(U);
15069 auto Final = Shifted;
15080 DAGCombinerInfo &DCI)
const {
15083 SelectionDAG &DAG = DCI.DAG;
15088 if (!DCI.isAfterLegalizeDAG())
15093 for (
const SDNode *U :
N->users())
15098 auto OpSize =
N->getOperand(0).getValueSizeInBits();
15102 if (OpSize <
Size) {
15120 DAGCombinerInfo &DCI)
const {
15121 SelectionDAG &DAG = DCI.DAG;
15124 assert(Subtarget.useCRBits() &&
"Expecting to be tracking CR bits");
15135 N->getValueType(0) != MVT::i1)
15138 if (
N->getOperand(0).getValueType() != MVT::i32 &&
15139 N->getOperand(0).getValueType() != MVT::i64)
15149 unsigned OpBits =
N->getOperand(0).getValueSizeInBits();
15160 return (
N->getOpcode() ==
ISD::SETCC ? ConvertSETCCToSubtract(
N, DCI)
15183 if (
N->getOperand(0).getOpcode() !=
ISD::AND &&
15184 N->getOperand(0).getOpcode() !=
ISD::OR &&
15185 N->getOperand(0).getOpcode() !=
ISD::XOR &&
15195 N->getOperand(1).getOpcode() !=
ISD::AND &&
15196 N->getOperand(1).getOpcode() !=
ISD::OR &&
15197 N->getOperand(1).getOpcode() !=
ISD::XOR &&
15208 SmallPtrSet<SDNode *, 16> Visited;
15210 for (
unsigned i = 0; i < 2; ++i) {
15214 N->getOperand(i).getOperand(0).getValueType() == MVT::i1) ||
15226 while (!BinOps.
empty()) {
15234 for (
unsigned i = 0, ie = BinOp.
getNumOperands(); i != ie; ++i) {
15268 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
15272 for (
const SDNode *User : Inputs[i].
getNode()->
users()) {
15273 if (User !=
N && !Visited.
count(User))
15282 if (
User->getOperand(0) == Inputs[i])
15285 if (
User->getOperand(0) == Inputs[i] ||
15286 User->getOperand(1) == Inputs[i])
15292 for (
unsigned i = 0, ie = PromOps.
size(); i != ie; ++i) {
15293 for (
const SDNode *User : PromOps[i].
getNode()->
users()) {
15294 if (User !=
N && !Visited.
count(User))
15303 if (
User->getOperand(0) == PromOps[i])
15306 if (
User->getOperand(0) == PromOps[i] ||
15307 User->getOperand(1) == PromOps[i])
15314 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
15323 std::list<HandleSDNode> PromOpHandles;
15324 for (
auto &PromOp : PromOps)
15325 PromOpHandles.emplace_back(PromOp);
15332 while (!PromOpHandles.empty()) {
15333 SDValue PromOp = PromOpHandles.back().getValue();
15334 PromOpHandles.pop_back();
15343 PromOpHandles.emplace_front(PromOp);
15357 default:
C = 0;
break;
15370 PromOpHandles.emplace_front(PromOp);
15377 for (
unsigned i = 0; i < 2; ++i)
15387 return N->getOperand(0);
15395 DAGCombinerInfo &DCI)
const {
15396 SelectionDAG &DAG = DCI.DAG;
15413 if (
N->getValueType(0) != MVT::i32 &&
15414 N->getValueType(0) != MVT::i64)
15417 if (!((
N->getOperand(0).getValueType() == MVT::i1 && Subtarget.useCRBits()) ||
15418 (
N->getOperand(0).getValueType() == MVT::i32 && Subtarget.isPPC64())))
15421 if (
N->getOperand(0).getOpcode() !=
ISD::AND &&
15422 N->getOperand(0).getOpcode() !=
ISD::OR &&
15423 N->getOperand(0).getOpcode() !=
ISD::XOR &&
15430 SmallPtrSet<SDNode *, 16> Visited;
15434 while (!BinOps.
empty()) {
15442 for (
unsigned i = 0, ie = BinOp.
getNumOperands(); i != ie; ++i) {
15468 DenseMap<SDNode *, EVT> SelectTruncOp[2];
15473 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
15478 if (User !=
N && !Visited.
count(User))
15484 if (
User->getOperand(0) == Inputs[i])
15485 SelectTruncOp[0].
insert(std::make_pair(User,
15486 User->getOperand(0).getValueType()));
15488 if (
User->getOperand(0) == Inputs[i])
15489 SelectTruncOp[0].
insert(std::make_pair(User,
15490 User->getOperand(0).getValueType()));
15491 if (
User->getOperand(1) == Inputs[i])
15492 SelectTruncOp[1].
insert(std::make_pair(User,
15493 User->getOperand(1).getValueType()));
15498 for (
unsigned i = 0, ie = PromOps.
size(); i != ie; ++i) {
15500 if (User !=
N && !Visited.
count(User))
15506 if (
User->getOperand(0) == PromOps[i])
15507 SelectTruncOp[0].
insert(std::make_pair(User,
15508 User->getOperand(0).getValueType()));
15510 if (
User->getOperand(0) == PromOps[i])
15511 SelectTruncOp[0].
insert(std::make_pair(User,
15512 User->getOperand(0).getValueType()));
15513 if (
User->getOperand(1) == PromOps[i])
15514 SelectTruncOp[1].
insert(std::make_pair(User,
15515 User->getOperand(1).getValueType()));
15520 unsigned PromBits =
N->getOperand(0).getValueSizeInBits();
15521 bool ReallyNeedsExt =
false;
15525 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
15530 Inputs[i].getOperand(0).getValueSizeInBits();
15531 assert(PromBits < OpBits &&
"Truncation not to a smaller bit count?");
15536 OpBits-PromBits))) ||
15539 (OpBits-(PromBits-1)))) {
15540 ReallyNeedsExt =
true;
15548 std::list<HandleSDNode> PromOpHandles;
15549 for (
auto &PromOp : PromOps)
15550 PromOpHandles.emplace_back(PromOp);
15554 for (
unsigned i = 0, ie = Inputs.
size(); i != ie; ++i) {
15561 SDValue InSrc = Inputs[i].getOperand(0);
15579 while (!PromOpHandles.empty()) {
15581 PromOpHandles.pop_back();
15585 default:
C = 0;
break;
15598 PromOpHandles.emplace_front(PromOp);
15608 (SelectTruncOp[1].count(PromOp.
getNode()) &&
15610 PromOpHandles.emplace_front(PromOp);
15618 for (
unsigned i = 0; i < 2; ++i) {
15636 auto SI0 = SelectTruncOp[0].
find(PromOp.
getNode());
15637 if (SI0 != SelectTruncOp[0].
end())
15639 auto SI1 = SelectTruncOp[1].
find(PromOp.
getNode());
15640 if (SI1 != SelectTruncOp[1].
end())
15649 if (!ReallyNeedsExt)
15650 return N->getOperand(0);
15657 N->getValueSizeInBits(0), PromBits),
15658 dl,
N->getValueType(0)));
15661 "Invalid extension type");
15664 DAG.
getConstant(
N->getValueSizeInBits(0) - PromBits, dl, ShiftAmountTy);
15674 auto isValidForConvert = [](
SDValue &Operand) {
15693 if (LoadNode->isVolatile())
15714 return (isValidForConvert(
LHS) && isValidForConvert(
RHS));
15724 "CC mus be ISD::SETNE or ISD::SETEQ");
15726 auto getV16i8Load = [&](
const SDValue &Operand) {
15734 DAG.
getLoad(MVT::v16i8,
DL, LoadNode->getChain(),
15735 LoadNode->getBasePtr(), LoadNode->getMemOperand());
15776 SDValue LHSVec = getV16i8Load(
N->getOperand(0));
15777 SDValue RHSVec = getV16i8Load(
N->getOperand(1));
15780 DAG.
getConstant(Intrinsic::ppc_altivec_vcmpequb_p,
DL, MVT::i32);
15783 IntrID, CRSel, LHSVec, RHSVec);
15786 return DAG.
getSetCC(
DL,
N->getValueType(0), PredResult,
15804 auto IsAndWithOne = [](
SDValue &V) {
15815 auto IsCompareWithZero = [](
SDValue &V) {
15822 return (IsAndWithOne(
LHS) && IsCompareWithZero(
RHS)) ||
15823 (IsAndWithOne(
RHS) && IsCompareWithZero(
LHS));
15840 auto MakeXor1 = [&](
SDValue V) {
15841 EVT VT = V.getValueType();
15848 return MakeXor1(
LHS);
15851 return MakeXor1(
RHS);
15857 DAGCombinerInfo &DCI)
const {
15859 "Should be called with a SETCC node");
15881 SelectionDAG &DAG = DCI.DAG;
15882 EVT VT =
N->getValueType(0);
15883 EVT OpVT =
LHS.getValueType();
15905 return DAGCombineTruncBoolExt(
N, DCI);
15912 Op.getValueType() == MVT::f64;
15924combineElementTruncationToVectorTruncation(
SDNode *
N,
15925 DAGCombinerInfo &DCI)
const {
15927 "Should be called with a BUILD_VECTOR node");
15929 SelectionDAG &DAG = DCI.DAG;
15932 SDValue FirstInput =
N->getOperand(0);
15934 "The input operand must be an fp-to-int conversion.");
15939 if (FirstConversion == PPCISD::FCTIDZ ||
15940 FirstConversion == PPCISD::FCTIDUZ ||
15941 FirstConversion == PPCISD::FCTIWZ ||
15942 FirstConversion == PPCISD::FCTIWUZ) {
15943 bool IsSplat =
true;
15944 bool Is32Bit = FirstConversion == PPCISD::FCTIWZ ||
15945 FirstConversion == PPCISD::FCTIWUZ;
15948 EVT TargetVT =
N->getValueType(0);
15949 for (
int i = 0, e =
N->getNumOperands(); i < e; ++i) {
15950 SDValue NextOp =
N->getOperand(i);
15951 if (NextOp.
getOpcode() != PPCISD::MFVSR)
15954 if (NextConversion != FirstConversion)
15962 if (
N->getOperand(i) != FirstInput)
15973 for (
int i = 0, e =
N->getNumOperands(); i < e; ++i) {
15974 SDValue In =
N->getOperand(i).getOperand(0);
15984 Ops.push_back(Trunc);
15987 Ops.push_back(
In.isUndef() ? DAG.
getUNDEF(SrcVT) :
In.getOperand(0));
15991 if (FirstConversion == PPCISD::FCTIDZ ||
15992 FirstConversion == PPCISD::FCTIWZ)
15997 EVT NewVT = TargetVT == MVT::v2i64 ? MVT::v2f64 : MVT::v4f32;
15999 return DAG.
getNode(Opcode, dl, TargetVT, BV);
16017 static const APInt BasePattern =
APInt(128, 0x8000000000000000ULL) << 64;
16021 if (FullVal == BasePattern)
16022 return std::make_tuple(Uim,
uint8_t{0});
16025 if (FullVal ==
APInt(128, 1))
16026 return std::make_tuple(Uim,
uint8_t{127});
16028 return std::nullopt;
16048 "Expected a BuildVectorSDNode in combineBVLoadsSpecialValue");
16052 EVT VT =
Op.getValueType();
16053 if (!(VT == MVT::v8i16 || VT == MVT::v16i8 || VT == MVT::v4i32 ||
16067 for (
const SDValue &Operand :
Op.getNode()->op_values()) {
16077 for (
unsigned Index = 0;
Index < NumElems; ++
Index) {
16081 uint64_t ElemValue =
C->getZExtValue();
16085 ElemValue &= ((1ULL << ElemBits) - 1);
16089 (IsLittleEndian) ? (Index * ElemBits) : (128 - (
Index + 1) * ElemBits);
16092 APInt ElemAPInt(128, ElemValue);
16093 ElemAPInt <<= BitPos;
16096 FullVal |= ElemAPInt;
16103 const auto &[Uim, ShiftAmount] = *UIMOpt;
16107 if (ShiftAmount == 0) {
16112 <<
"combineBVLoadsSpecialValue: Instruction Emitted ";
16113 LxvkqInstr.
dump());
16117 assert(ShiftAmount == 127 &&
"Unexpected lxvkq shift amount value");
16129 DAG.
getMachineNode(PPC::VSRQ, Dl, VT, ShiftAmountVec, ShiftAmountVec),
16132 <<
"\n combineBVLoadsSpecialValue: Instruction Emitted ";
16148 "Should be called with a BUILD_VECTOR node");
16153 if (!
N->getValueType(0).getVectorElementType().isByteSized())
16156 bool InputsAreConsecutiveLoads =
true;
16157 bool InputsAreReverseConsecutive =
true;
16158 unsigned ElemSize =
N->getValueType(0).getScalarType().getStoreSize();
16159 SDValue FirstInput =
N->getOperand(0);
16160 bool IsRoundOfExtLoad =
false;
16170 N->getNumOperands() == 1)
16173 if (!IsRoundOfExtLoad)
16178 for (
int i = 1, e =
N->getNumOperands(); i < e; ++i) {
16180 if (IsRoundOfExtLoad &&
N->getOperand(i).getOpcode() !=
ISD::FP_ROUND)
16183 SDValue NextInput = IsRoundOfExtLoad ?
N->getOperand(i).getOperand(0) :
16189 IsRoundOfExtLoad ?
N->getOperand(i-1).getOperand(0) :
N->getOperand(i-1);
16200 InputsAreConsecutiveLoads =
false;
16202 InputsAreReverseConsecutive =
false;
16205 if (!InputsAreConsecutiveLoads && !InputsAreReverseConsecutive)
16210 assert(!(InputsAreConsecutiveLoads && InputsAreReverseConsecutive) &&
16211 "The loads cannot be both consecutive and reverse consecutive.");
16215 if (InputsAreConsecutiveLoads) {
16216 assert(FirstLoad &&
"Input needs to be a LoadSDNode.");
16220 ReturnSDVal = WideLoad;
16221 }
else if (InputsAreReverseConsecutive) {
16223 assert(LastLoad &&
"Input needs to be a LoadSDNode.");
16228 for (
int i =
N->getNumOperands() - 1; i >= 0; i--)
16236 for (
auto *LD : InputLoads)
16238 return ReturnSDVal;
16249 unsigned NumElems =
Input.getValueType().getVectorNumElements();
16255 for (
unsigned i = 0; i <
N->getNumOperands(); i++) {
16257 ShuffleMask[CorrectElems & 0xF] = Elems & 0xF;
16259 ShuffleMask[(CorrectElems & 0xF0) >> 4] = (Elems & 0xF0) >> 4;
16260 CorrectElems = CorrectElems >> 8;
16261 Elems = Elems >> 8;
16268 EVT VT =
N->getValueType(0);
16272 Input.getValueType().getVectorElementType(),
16306 auto isSExtOfVecExtract = [&](
SDValue Op) ->
bool {
16332 Elems = Elems << 8;
16341 for (
unsigned i = 0; i <
N->getNumOperands(); i++) {
16342 if (!isSExtOfVecExtract(
N->getOperand(i))) {
16349 int TgtElemArrayIdx;
16350 int InputSize =
Input.getValueType().getScalarSizeInBits();
16351 int OutputSize =
N->getValueType(0).getScalarSizeInBits();
16352 if (InputSize + OutputSize == 40)
16353 TgtElemArrayIdx = 0;
16354 else if (InputSize + OutputSize == 72)
16355 TgtElemArrayIdx = 1;
16356 else if (InputSize + OutputSize == 48)
16357 TgtElemArrayIdx = 2;
16358 else if (InputSize + OutputSize == 80)
16359 TgtElemArrayIdx = 3;
16360 else if (InputSize + OutputSize == 96)
16361 TgtElemArrayIdx = 4;
16365 uint64_t CorrectElems = TargetElems[TgtElemArrayIdx];
16367 ? CorrectElems & 0x0F0F0F0F0F0F0F0F
16368 : CorrectElems & 0xF0F0F0F0F0F0F0F0;
16369 if (Elems != CorrectElems) {
16385 if (
N->getValueType(0) != MVT::v1i128)
16388 SDValue Operand =
N->getOperand(0);
16395 EVT MemoryType = LD->getMemoryVT();
16399 bool ValidLDType = MemoryType == MVT::i8 || MemoryType == MVT::i16 ||
16400 MemoryType == MVT::i32 || MemoryType == MVT::i64;
16403 if (!ValidLDType ||
16409 LD->getChain(), LD->getBasePtr(),
16413 DAG.
getVTList(MVT::v1i128, MVT::Other),
16414 LoadOps, MemoryType, LD->getMemOperand());
16418 DAGCombinerInfo &DCI)
const {
16420 "Should be called with a BUILD_VECTOR node");
16422 SelectionDAG &DAG = DCI.DAG;
16425 if (!Subtarget.hasVSX())
16432 if (FirstInput.
getOpcode() == PPCISD::MFVSR) {
16433 SDValue Reduced = combineElementTruncationToVectorTruncation(
N, DCI);
16448 if (Subtarget.hasP9Altivec() && !DCI.isBeforeLegalize()) {
16457 if (Subtarget.isISA3_1()) {
16463 if (
N->getValueType(0) != MVT::v2f64)
16474 if (FirstInput.
getOpcode() !=
N->getOperand(1).getOpcode())
16485 if (!Ext1Op || !Ext2Op)
16494 if (FirstElem == 0 && SecondElem == 1)
16495 SubvecIdx = Subtarget.isLittleEndian() ? 1 : 0;
16496 else if (FirstElem == 2 && SecondElem == 3)
16497 SubvecIdx = Subtarget.isLittleEndian() ? 0 : 1;
16503 PPCISD::SINT_VEC_TO_FP : PPCISD::UINT_VEC_TO_FP;
16504 return DAG.
getNode(NodeType, dl, MVT::v2f64,
16509 DAGCombinerInfo &DCI)
const {
16512 "Need an int -> FP conversion node here");
16517 SelectionDAG &DAG = DCI.DAG;
16523 if (
Op.getValueType() != MVT::f32 &&
Op.getValueType() != MVT::f64)
16525 if (!
Op.getOperand(0).getValueType().isSimple())
16527 if (
Op.getOperand(0).getValueType().getSimpleVT() <= MVT(MVT::i1) ||
16528 Op.getOperand(0).getValueType().getSimpleVT() > MVT(MVT::i64))
16531 SDValue FirstOperand(
Op.getOperand(0));
16532 bool SubWordLoad = FirstOperand.getOpcode() ==
ISD::LOAD &&
16533 (FirstOperand.getValueType() == MVT::i8 ||
16534 FirstOperand.getValueType() == MVT::i16);
16535 if (Subtarget.hasP9Vector() && Subtarget.hasP9Altivec() && SubWordLoad) {
16537 bool DstDouble =
Op.getValueType() == MVT::f64;
16538 unsigned ConvOp =
Signed ?
16539 (DstDouble ? PPCISD::FCFID : PPCISD::FCFIDS) :
16540 (DstDouble ? PPCISD::FCFIDU : PPCISD::FCFIDUS);
16545 SDValue Ops[] = { LDN->getChain(), LDN->getBasePtr(), WidthConst };
16548 Ops, MVT::i8, LDN->getMemOperand());
16553 SDValue ExtOps[] = { Ld, WidthConst };
16555 return DAG.
getNode(ConvOp, dl, DstDouble ? MVT::f64 : MVT::f32, Ext);
16557 return DAG.
getNode(ConvOp, dl, DstDouble ? MVT::f64 : MVT::f32, Ld);
16565 if (
Op.getOperand(0).getValueType() == MVT::i32)
16569 "UINT_TO_FP is supported only with FPCVT");
16573 unsigned FCFOp = (Subtarget.hasFPCVT() &&
Op.getValueType() == MVT::f32)
16578 MVT FCFTy = (Subtarget.hasFPCVT() &&
Op.getValueType() == MVT::f32)
16585 Subtarget.hasFPCVT()) ||
16587 SDValue Src =
Op.getOperand(0).getOperand(0);
16588 if (Src.getValueType() == MVT::f32) {
16590 DCI.AddToWorklist(Src.getNode());
16591 }
else if (Src.getValueType() != MVT::f64) {
16603 if (
Op.getValueType() == MVT::f32 && !Subtarget.hasFPCVT()) {
16606 DCI.AddToWorklist(
FP.getNode());
16630 switch (
N->getOpcode()) {
16635 Chain = LD->getChain();
16636 Base = LD->getBasePtr();
16637 MMO = LD->getMemOperand();
16656 MVT VecTy =
N->getValueType(0).getSimpleVT();
16664 Chain = Load.getValue(1);
16666 PPCISD::XXSWAPD, dl, DAG.
getVTList(MVT::v2f64, MVT::Other), Chain, Load);
16670 if (VecTy != MVT::v2f64) {
16697 switch (
N->getOpcode()) {
16702 Chain = ST->getChain();
16703 Base = ST->getBasePtr();
16704 MMO = ST->getMemOperand();
16724 SDValue Src =
N->getOperand(SrcOpnd);
16725 MVT VecTy = Src.getValueType().getSimpleVT();
16728 if (VecTy != MVT::v2f64) {
16734 DAG.
getVTList(MVT::v2f64, MVT::Other), Chain, Src);
16740 StoreOps, VecTy, MMO);
16747 DAGCombinerInfo &DCI)
const {
16750 unsigned Opcode =
N->getOperand(1).getOpcode();
16752 bool Strict =
N->getOperand(1)->isStrictFPOpcode();
16756 &&
"Not a FP_TO_INT Instruction!");
16758 SDValue Val =
N->getOperand(1).getOperand(Strict ? 1 : 0);
16759 EVT Op1VT =
N->getOperand(1).getValueType();
16762 if (!Subtarget.hasVSX() || !Subtarget.hasFPCVT() || !
isTypeLegal(ResVT))
16766 bool ValidTypeForStoreFltAsInt =
16767 (Op1VT == MVT::i32 || (Op1VT == MVT::i64 && Subtarget.isPPC64()) ||
16768 (Subtarget.hasP9Vector() && (Op1VT == MVT::i16 || Op1VT == MVT::i8)));
16771 if (ResVT == MVT::ppcf128 || (ResVT == MVT::f128 && !Subtarget.hasP9Vector()))
16774 if ((Op1VT != MVT::i64 && !Subtarget.hasP8Vector()) ||
16782 SDValue Ops[] = {
N->getOperand(0), Val,
N->getOperand(2),
16797 bool PrevElemFromFirstVec = Mask[0] < NumElts;
16798 for (
int i = 1, e = Mask.size(); i < e; i++) {
16799 if (PrevElemFromFirstVec && Mask[i] < NumElts)
16801 if (!PrevElemFromFirstVec && Mask[i] >= NumElts)
16803 PrevElemFromFirstVec = !PrevElemFromFirstVec;
16814 for (
int i = 0, e =
Op.getNumOperands(); i < e; i++) {
16815 FirstOp =
Op.getOperand(i);
16821 for (
int i = 1, e =
Op.getNumOperands(); i < e; i++)
16822 if (
Op.getOperand(i) != FirstOp && !
Op.getOperand(i).isUndef())
16832 Op =
Op.getOperand(0);
16848 int RHSFirstElt,
int RHSLastElt,
int HalfVec,
unsigned LHSNumValidElts,
16849 unsigned RHSNumValidElts,
const PPCSubtarget &Subtarget) {
16851 Subtarget.
isLittleEndian() ? HalfVec : HalfVec - LHSNumValidElts;
16853 Subtarget.
isLittleEndian() ? HalfVec : HalfVec - RHSNumValidElts;
16854 for (
int I = 0,
E = ShuffV.
size();
I <
E; ++
I) {
16855 int Idx = ShuffV[
I];
16856 if (Idx >= LHSFirstElt && Idx <= LHSLastElt)
16857 ShuffV[
I] += LHSEltFixup;
16858 else if (Idx >= RHSFirstElt && Idx <= RHSLastElt)
16859 ShuffV[
I] += RHSEltFixup;
16870 SDLoc dl(OrigSToV);
16873 "Expecting a SCALAR_TO_VECTOR here");
16886 "Cannot produce a permuted scalar_to_vector for one element vector");
16888 unsigned ResultInElt = NumElts / 2;
16894 return DAG.
getNode(PPCISD::SCALAR_TO_VECTOR_PERMUTED, dl, VT,
16899 int HalfVec,
int LHSLastElementDefined,
16900 int RHSLastElementDefined) {
16901 for (
int Index : ShuffV) {
16905 if ((LHSLastElementDefined >= 0) && (Index < HalfVec) &&
16906 (Index > LHSLastElementDefined))
16909 if ((RHSLastElementDefined >= 0) &&
16910 (Index > HalfVec + RHSLastElementDefined))
16917 int ScalarSize,
uint64_t ShuffleEltWidth,
unsigned &NumValidElts,
16918 int FirstElt,
int &LastElt,
SDValue VecShuffOperand,
SDValue SToVNode,
16934 LastElt = (
uint64_t)ScalarSize > ShuffleEltWidth
16935 ? ScalarSize / ShuffleEltWidth - 1 + FirstElt
16938 if (SToVPermuted.
getValueType() != VecShuffOperandType)
16939 SToVPermuted = DAG.
getBitcast(VecShuffOperandType, SToVPermuted);
16940 return SToVPermuted;
16960 int NumElts =
LHS.getValueType().getVectorNumElements();
16963 bool IsLittleEndian = Subtarget.isLittleEndian();
16970 if (!Subtarget.hasDirectMove())
16990 SmallVector<int, 16> ShuffV(Mask);
16993 if (SToVLHS || SToVRHS) {
16996 int ShuffleNumElts = ShuffV.
size();
16997 int HalfVec = ShuffleNumElts / 2;
17003 unsigned LHSNumValidElts = HalfVec;
17004 unsigned RHSNumValidElts = HalfVec;
17009 int LHSFirstElt = 0;
17010 int RHSFirstElt = ShuffleNumElts;
17011 int LHSLastElt = -1;
17012 int RHSLastElt = -1;
17020 int LHSScalarSize = 0;
17021 int RHSScalarSize = 0;
17024 if (!IsLittleEndian && LHSScalarSize >= 64)
17029 if (!IsLittleEndian && RHSScalarSize >= 64)
17032 if (LHSScalarSize != 0)
17034 LHSScalarSize, ShuffleEltWidth, LHSNumValidElts, LHSFirstElt,
17035 LHSLastElt,
LHS, SToVLHS, DAG, Subtarget);
17036 if (RHSScalarSize != 0)
17038 RHSScalarSize, ShuffleEltWidth, RHSNumValidElts, RHSFirstElt,
17039 RHSLastElt,
RHS, SToVRHS, DAG, Subtarget);
17050 ShuffV, LHSFirstElt, LHSLastElt, RHSFirstElt, RHSLastElt, HalfVec,
17051 LHSNumValidElts, RHSNumValidElts, Subtarget);
17077 if (IsLittleEndian) {
17080 if (Mask[0] < NumElts)
17081 for (
int i = 1, e =
Mask.size(); i < e; i += 2) {
17085 ShuffV[i] = (ShuffV[i - 1] >= 0 ? ShuffV[i - 1] : 0) + NumElts;
17090 for (
int i = 0, e =
Mask.size(); i < e; i += 2) {
17094 ShuffV[i] = (ShuffV[i + 1] >= 0 ? ShuffV[i + 1] : 0) + NumElts;
17099 if (Mask[0] < NumElts)
17100 for (
int i = 0, e =
Mask.size(); i < e; i += 2) {
17104 ShuffV[i] = ShuffV[i + 1] >= 0 ? ShuffV[i + 1] - NumElts : 0;
17109 for (
int i = 1, e =
Mask.size(); i < e; i += 2) {
17113 ShuffV[i] = ShuffV[i - 1] >= 0 ? ShuffV[i - 1] - NumElts : 0;
17123 if (IsLittleEndian)
17132 DAGCombinerInfo &DCI)
const {
17134 "Not a reverse memop pattern!");
17136 auto IsElementReverse = [](
const ShuffleVectorSDNode *SVN) ->
bool {
17139 auto I =
Mask.rbegin();
17140 auto E =
Mask.rend();
17142 for (;
I !=
E; ++
I) {
17150 SelectionDAG &DAG = DCI.DAG;
17153 if (!
isTypeLegal(VT) || !Subtarget.isLittleEndian() || !Subtarget.hasVSX())
17159 if (!Subtarget.hasP9Vector())
17162 if(!IsElementReverse(SVN))
17169 for (SDUse &Use : LSBase->
uses())
17170 if (
Use.getResNo() == 0 &&
17177 PPCISD::LOAD_VEC_BE, dl, DAG.
getVTList(VT, MVT::Other), LoadOps,
17192 PPCISD::STORE_VEC_BE, dl, DAG.
getVTList(MVT::Other), StoreOps,
17201 if (IntrinsicID == Intrinsic::ppc_stdcx)
17203 else if (IntrinsicID == Intrinsic::ppc_stwcx)
17205 else if (IntrinsicID == Intrinsic::ppc_sthcx)
17207 else if (IntrinsicID == Intrinsic::ppc_stbcx)
17216 if (
N->getOpcode() == PPCISD::ADDC &&
N->hasAnyUseOfValue(1)) {
17220 if (
LHS->getOpcode() == PPCISD::ADDE &&
17240 SDValue CmpLHS =
N->getOperand(0);
17241 SDValue CmpRHS =
N->getOperand(1);
17242 SDValue TrueVal =
N->getOperand(2);
17243 SDValue FalseVal =
N->getOperand(3);
17257 if (FalseVal.getOpcode() !=
ISD::SRL || !FalseVal.hasOneUse())
17260 SDValue ShiftVal = FalseVal.getOperand(0);
17261 SDValue ShiftAmt = FalseVal.getOperand(1);
17265 if (!ShiftConst || !ShiftConst->getAPIntValue().isMinSignedValue())
17292 if (CtlzArg != CmpLHS)
17300 DAG.
getNode(PPCISD::SRL,
DL, FalseVal.getValueType(), ShiftVal, ShiftAmt);
17347 auto isZeroOrOne = [=](
SDValue &V) {
17349 V.getConstantOperandVal(0) == Intrinsic::ppc_test_data_class)
17354 if (!isZeroOrOne(NonNullConstant))
17364 EVT VType =
N->getValueType(0);
17368 return NewNonNullConstant;
17387 EVT XorVT =
N->getValueType(0);
17388 if ((XorVT != MVT::i32 && XorVT != MVT::i64))
17396 if (!XorConst || !XorConst->
isOne()) {
17398 if (!XorConst || !XorConst->
isOne())
17405 if (!
LHS.hasOneUse())
17413 SelectNode =
LHS.getOperand(0);
17427 if (MachineOpc != PPC::SELECT_CC_I4 && MachineOpc != PPC::SELECT_CC_I8)
17437 if (!ConstOp1 || !ConstOp2)
17441 if (!((ConstOp1->
isOne() && ConstOp2->
isZero()) ||
17450 MachineOpc = (XorVT == MVT::i32) ? PPC::SELECT_CC_I4 : PPC::SELECT_CC_I8;
17452 bool ConstOp1IsOne = ConstOp1->
isOne();
17455 {SelectNode.getOperand(0),
17456 DAG.getConstant(ConstOp1IsOne ? 0 : 1, DL, XorVT),
17457 DAG.getConstant(ConstOp1IsOne ? 1 : 0, DL, XorVT),
17458 SelectNode.getOperand(3)}),
17466 switch (
N->getOpcode()) {
17469 return combineADD(
N, DCI);
17501 return combineSHL(
N, DCI);
17503 return combineSRA(
N, DCI);
17505 return combineSRL(
N, DCI);
17507 return combineMUL(
N, DCI);
17509 case PPCISD::FNMSUB:
17510 return combineFMALike(
N, DCI);
17513 return N->getOperand(0);
17517 return N->getOperand(0);
17523 return N->getOperand(0);
17532 return DAGCombineExtBoolTrunc(
N, DCI);
17534 return combineTRUNCATE(
N, DCI);
17536 if (
SDValue CSCC = combineSetCC(
N, DCI))
17542 return DAGCombineTruncBoolExt(
N, DCI);
17545 return combineFPToIntToFP(
N, DCI);
17554 EVT Op1VT =
N->getOperand(1).getValueType();
17555 unsigned Opcode =
N->getOperand(1).getOpcode();
17559 SDValue Val = combineStoreFPToInt(
N, DCI);
17573 N->getOperand(1).getNode()->hasOneUse() &&
17574 (Op1VT == MVT::i32 || Op1VT == MVT::i16 ||
17575 (Subtarget.hasLDBRX() && Subtarget.isPPC64() && Op1VT == MVT::i64))) {
17583 SDValue BSwapOp =
N->getOperand(1).getOperand(0);
17590 if (Op1VT.
bitsGT(mVT)) {
17595 if (Op1VT == MVT::i64)
17600 N->getOperand(0), BSwapOp,
N->getOperand(2), DAG.
getValueType(mVT)
17620 ST->getBasePtr(), ST->getOffset(), MemVT,
17621 ST->getMemOperand(), ST->getAddressingMode(),
17625 return ST->isUnindexed()
17634 if (Subtarget.needsSwapsForVSXMemOps() &&
17635 (StoreVT == MVT::v2f64 || StoreVT == MVT::v2i64 ||
17636 StoreVT == MVT::v4f32 || StoreVT == MVT::v4i32))
17643 EVT VT = LD->getValueType(0);
17649 if (Subtarget.needsSwapsForVSXMemOps() &&
17650 (LoadVT == MVT::v2f64 || LoadVT == MVT::v2i64 ||
17651 LoadVT == MVT::v4f32 || LoadVT == MVT::v4i32))
17662 auto ReplaceTwoFloatLoad = [&]() {
17663 if (VT != MVT::i64)
17678 if (!LD->hasNUsesOfValue(2, 0))
17681 auto UI = LD->user_begin();
17682 while (UI.getUse().getResNo() != 0) ++UI;
17684 while (UI.getUse().getResNo() != 0) ++UI;
17685 SDNode *RightShift = *UI;
17693 if (RightShift->getOpcode() !=
ISD::SRL ||
17695 RightShift->getConstantOperandVal(1) != 32 ||
17696 !RightShift->hasOneUse())
17699 SDNode *Trunc2 = *RightShift->user_begin();
17709 Bitcast->getValueType(0) != MVT::f32)
17715 if (Subtarget.isLittleEndian())
17721 SDValue BasePtr = LD->getBasePtr();
17722 if (LD->isIndexed()) {
17724 "Non-pre-inc AM on PPC?");
17732 SDValue FloatLoad = DAG.
getLoad(MVT::f32, dl, LD->getChain(), BasePtr,
17733 LD->getPointerInfo(), LD->getAlign(),
17734 MMOFlags, LD->getAAInfo());
17740 LD->getPointerInfo().getWithOffset(4),
17743 if (LD->isIndexed()) {
17757 if (ReplaceTwoFloatLoad())
17760 EVT MemVT = LD->getMemoryVT();
17763 if (LD->isUnindexed() && VT.
isVector() &&
17766 !Subtarget.hasP8Vector() &&
17767 (VT == MVT::v16i8 || VT == MVT::v8i16 || VT == MVT::v4i32 ||
17768 VT == MVT::v4f32))) &&
17769 LD->getAlign() < ABIAlignment) {
17771 SDValue Chain = LD->getChain();
17772 SDValue Ptr = LD->getBasePtr();
17773 bool isLittleEndian = Subtarget.isLittleEndian();
17800 MVT PermCntlTy, PermTy, LDTy;
17801 Intr = isLittleEndian ? Intrinsic::ppc_altivec_lvsr
17802 : Intrinsic::ppc_altivec_lvsl;
17803 IntrLD = Intrinsic::ppc_altivec_lvx;
17804 IntrPerm = Intrinsic::ppc_altivec_vperm;
17805 PermCntlTy = MVT::v16i8;
17806 PermTy = MVT::v4i32;
17825 SDValue BaseLoadOps[] = { Chain, LDXIntID, Ptr };
17829 BaseLoadOps, LDTy, BaseMMO);
17838 int IncValue = IncOffset;
17855 SDValue ExtraLoadOps[] = { Chain, LDXIntID, Ptr };
17859 ExtraLoadOps, LDTy, ExtraMMO);
17870 if (isLittleEndian)
17872 ExtraLoad, BaseLoad, PermCntl, DAG, dl);
17875 BaseLoad, ExtraLoad, PermCntl, DAG, dl);
17878 Perm = Subtarget.hasAltivec()
17893 bool isLittleEndian = Subtarget.isLittleEndian();
17894 unsigned IID =
N->getConstantOperandVal(0);
17895 Intrinsic::ID Intr = (isLittleEndian ? Intrinsic::ppc_altivec_lvsr
17896 : Intrinsic::ppc_altivec_lvsl);
17897 if (IID == Intr &&
N->getOperand(1)->getOpcode() ==
ISD::ADD) {
17904 .zext(
Add.getScalarValueSizeInBits()))) {
17905 SDNode *BasePtr =
Add->getOperand(0).getNode();
17906 for (
SDNode *U : BasePtr->users()) {
17908 U->getConstantOperandVal(0) == IID) {
17919 SDNode *BasePtr =
Add->getOperand(0).getNode();
17920 for (
SDNode *U : BasePtr->users()) {
17923 (
Add->getConstantOperandVal(1) - U->getConstantOperandVal(1)) %
17929 V->getConstantOperandVal(0) == IID) {
17941 (IID == Intrinsic::ppc_altivec_vmaxsw ||
17942 IID == Intrinsic::ppc_altivec_vmaxsh ||
17943 IID == Intrinsic::ppc_altivec_vmaxsb)) {
17974 switch (
N->getConstantOperandVal(1)) {
17977 case Intrinsic::ppc_altivec_vsum4sbs:
17978 case Intrinsic::ppc_altivec_vsum4shs:
17979 case Intrinsic::ppc_altivec_vsum4ubs: {
17986 APInt APSplatBits, APSplatUndef;
17987 unsigned SplatBitSize;
17990 APSplatBits, APSplatUndef, SplatBitSize, HasAnyUndefs, 0,
17991 !Subtarget.isLittleEndian());
17993 if (BVNIsConstantSplat && APSplatBits == 0)
17998 case Intrinsic::ppc_vsx_lxvw4x:
17999 case Intrinsic::ppc_vsx_lxvd2x:
18002 if (Subtarget.needsSwapsForVSXMemOps())
18010 if (Subtarget.needsSwapsForVSXMemOps()) {
18011 switch (
N->getConstantOperandVal(1)) {
18014 case Intrinsic::ppc_vsx_stxvw4x:
18015 case Intrinsic::ppc_vsx_stxvd2x:
18024 bool Is64BitBswapOn64BitTgt =
18025 Subtarget.isPPC64() &&
N->getValueType(0) == MVT::i64;
18027 N->getOperand(0).hasOneUse();
18028 if (IsSingleUseNormalLd &&
18029 (
N->getValueType(0) == MVT::i32 ||
N->getValueType(0) == MVT::i16 ||
18030 (Subtarget.hasLDBRX() && Is64BitBswapOn64BitTgt))) {
18041 DAG.
getVTList(
N->getValueType(0) == MVT::i64 ?
18042 MVT::i64 : MVT::i32, MVT::Other),
18043 Ops, LD->getMemoryVT(), LD->getMemOperand());
18047 if (
N->getValueType(0) == MVT::i16)
18064 !IsSingleUseNormalLd)
18069 if (!LD->isSimple())
18071 SDValue BasePtr = LD->getBasePtr();
18073 LD->getPointerInfo(), LD->getAlign());
18078 LD->getMemOperand(), 4, 4);
18082 if (Subtarget.isLittleEndian())
18088 Hi.getOperand(0).getValue(1),
Lo.getOperand(0).getValue(1));
18097 if (!
N->getOperand(0).hasOneUse() &&
18098 !
N->getOperand(1).hasOneUse() &&
18099 !
N->getOperand(2).hasOneUse()) {
18102 SDNode *VCMPrecNode =
nullptr;
18104 SDNode *LHSN =
N->getOperand(0).getNode();
18106 if (
User->getOpcode() == PPCISD::VCMP_rec &&
18110 VCMPrecNode =
User;
18122 SDNode *FlagUser =
nullptr;
18124 FlagUser ==
nullptr; ++UI) {
18125 assert(UI != VCMPrecNode->
use_end() &&
"Didn't find user!");
18138 return SDValue(VCMPrecNode, 0);
18149 SDValue LHS =
N->getOperand(2), RHS =
N->getOperand(3);
18160 auto RHSAPInt = RHS->getAsAPIntVal();
18161 if (!RHSAPInt.isIntN(64))
18164 unsigned Val = RHSAPInt.getZExtValue();
18165 auto isImpossibleCompare = [&]() {
18168 if (Val != 0 && Val != 1) {
18170 return N->getOperand(0);
18173 N->getOperand(0),
N->getOperand(4));
18178 unsigned StoreWidth = 0;
18181 if (
SDValue Impossible = isImpossibleCompare())
18193 SDValue Ops[] = {LHS.getOperand(0), LHS.getOperand(2), LHS.getOperand(3),
18197 PPCISD::STORE_COND, dl,
18199 MemNode->getMemoryVT(), MemNode->getMemOperand());
18203 if (
N->getOperand(0) == LHS.getValue(1))
18214 return DAG.
getNode(PPCISD::COND_BRANCH, dl, MVT::Other, InChain,
18216 DAG.
getRegister(PPC::CR0, MVT::i32),
N->getOperand(4),
18222 assert(isDot &&
"Can't compare against a vector result!");
18224 if (
SDValue Impossible = isImpossibleCompare())
18227 bool BranchOnWhenPredTrue = (CC ==
ISD::SETEQ) ^ (Val == 0);
18234 EVT VTs[] = { LHS.getOperand(2).getValueType(), MVT::Glue };
18239 switch (LHS.getConstantOperandVal(1)) {
18255 return DAG.
getNode(PPCISD::COND_BRANCH, dl, MVT::Other,
N->getOperand(0),
18258 N->getOperand(4), CompNode.
getValue(1));
18263 return DAGCombineBuildVector(
N, DCI);
18268 return DAGCombineBitcast(
N, DCI);
18279 EVT VT =
N->getValueType(0);
18280 if (VT == MVT::i64 && !Subtarget.isPPC64())
18282 if ((VT != MVT::i32 && VT != MVT::i64) ||
18290 unsigned Lg2 = (IsNegPow2 ? -Divisor : Divisor).
countr_zero();
18310 const APInt &DemandedElts,
18312 unsigned Depth)
const {
18314 switch (
Op.getOpcode()) {
18316 case PPCISD::LBRX: {
18319 Known.
Zero = 0xFFFF0000;
18322 case PPCISD::ADDE: {
18323 if (
Op.getResNo() == 0) {
18328 Known.
Zero = ~1ULL;
18333 switch (
Op.getConstantOperandVal(0)) {
18335 case Intrinsic::ppc_altivec_vcmpbfp_p:
18336 case Intrinsic::ppc_altivec_vcmpeqfp_p:
18337 case Intrinsic::ppc_altivec_vcmpequb_p:
18338 case Intrinsic::ppc_altivec_vcmpequh_p:
18339 case Intrinsic::ppc_altivec_vcmpequw_p:
18340 case Intrinsic::ppc_altivec_vcmpequd_p:
18341 case Intrinsic::ppc_altivec_vcmpequq_p:
18342 case Intrinsic::ppc_altivec_vcmpgefp_p:
18343 case Intrinsic::ppc_altivec_vcmpgtfp_p:
18344 case Intrinsic::ppc_altivec_vcmpgtsb_p:
18345 case Intrinsic::ppc_altivec_vcmpgtsh_p:
18346 case Intrinsic::ppc_altivec_vcmpgtsw_p:
18347 case Intrinsic::ppc_altivec_vcmpgtsd_p:
18348 case Intrinsic::ppc_altivec_vcmpgtsq_p:
18349 case Intrinsic::ppc_altivec_vcmpgtub_p:
18350 case Intrinsic::ppc_altivec_vcmpgtuh_p:
18351 case Intrinsic::ppc_altivec_vcmpgtuw_p:
18352 case Intrinsic::ppc_altivec_vcmpgtud_p:
18353 case Intrinsic::ppc_altivec_vcmpgtuq_p:
18360 switch (
Op.getConstantOperandVal(1)) {
18363 case Intrinsic::ppc_load2r:
18365 Known.
Zero = 0xFFFF0000;
18374 switch (Subtarget.getCPUDirective()) {
18396 if (
ML->getLoopDepth() > 1 &&
ML->getSubLoops().empty())
18405 for (
auto I =
ML->block_begin(), IE =
ML->block_end();
I != IE; ++
I)
18407 LoopSize +=
TII->getInstSizeInBytes(J);
18412 if (LoopSize > 16 && LoopSize <= 32)
18426 if (Constraint.
size() == 1) {
18427 switch (Constraint[0]) {
18445 }
else if (Constraint ==
"wc") {
18447 }
else if (Constraint ==
"wa" || Constraint ==
"wd" ||
18448 Constraint ==
"wf" || Constraint ==
"ws" ||
18449 Constraint ==
"wi" || Constraint ==
"ww") {
18462 Value *CallOperandVal =
info.CallOperandVal;
18465 if (!CallOperandVal)
18472 else if ((
StringRef(constraint) ==
"wa" ||
18484 switch (*constraint) {
18514std::pair<unsigned, const TargetRegisterClass *>
18518 if (Constraint.
size() == 1) {
18520 switch (Constraint[0]) {
18522 if (VT == MVT::i64 && Subtarget.isPPC64())
18523 return std::make_pair(0U, &PPC::G8RC_NOX0RegClass);
18524 return std::make_pair(0U, &PPC::GPRC_NOR0RegClass);
18526 if (VT == MVT::i64 && Subtarget.isPPC64())
18527 return std::make_pair(0U, &PPC::G8RCRegClass);
18528 return std::make_pair(0U, &PPC::GPRCRegClass);
18534 if (Subtarget.hasSPE()) {
18535 if (VT == MVT::f32 || VT == MVT::i32)
18536 return std::make_pair(0U, &PPC::GPRCRegClass);
18537 if (VT == MVT::f64 || VT == MVT::i64)
18538 return std::make_pair(0U, &PPC::SPERCRegClass);
18540 if (VT == MVT::f32 || VT == MVT::i32)
18541 return std::make_pair(0U, &PPC::F4RCRegClass);
18542 if (VT == MVT::f64 || VT == MVT::i64)
18543 return std::make_pair(0U, &PPC::F8RCRegClass);
18547 if (Subtarget.hasAltivec() && VT.
isVector())
18548 return std::make_pair(0U, &PPC::VRRCRegClass);
18549 else if (Subtarget.hasVSX())
18551 return std::make_pair(0U, &PPC::VFRCRegClass);
18554 return std::make_pair(0U, &PPC::CRRCRegClass);
18556 }
else if (Constraint ==
"wc" && Subtarget.useCRBits()) {
18558 return std::make_pair(0U, &PPC::CRBITRCRegClass);
18559 }
else if ((Constraint ==
"wa" || Constraint ==
"wd" ||
18560 Constraint ==
"wf" || Constraint ==
"wi") &&
18561 Subtarget.hasVSX()) {
18565 return std::make_pair(0U, &PPC::VSRCRegClass);
18566 if (VT == MVT::f32 && Subtarget.hasP8Vector())
18567 return std::make_pair(0U, &PPC::VSSRCRegClass);
18568 return std::make_pair(0U, &PPC::VSFRCRegClass);
18569 }
else if ((Constraint ==
"ws" || Constraint ==
"ww") && Subtarget.hasVSX()) {
18570 if (VT == MVT::f32 && Subtarget.hasP8Vector())
18571 return std::make_pair(0U, &PPC::VSSRCRegClass);
18573 return std::make_pair(0U, &PPC::VSFRCRegClass);
18574 }
else if (Constraint ==
"lr") {
18575 if (VT == MVT::i64)
18576 return std::make_pair(0U, &PPC::LR8RCRegClass);
18578 return std::make_pair(0U, &PPC::LRRCRegClass);
18583 if (Constraint[0] ==
'{' && Constraint[Constraint.
size() - 1] ==
'}') {
18587 if (Constraint.
size() > 3 && Constraint[1] ==
'v' && Constraint[2] ==
's') {
18588 int VSNum = atoi(Constraint.
data() + 3);
18589 assert(VSNum >= 0 && VSNum <= 63 &&
18590 "Attempted to access a vsr out of range");
18592 return std::make_pair(PPC::VSL0 + VSNum, &PPC::VSRCRegClass);
18593 return std::make_pair(PPC::V0 + VSNum - 32, &PPC::VSRCRegClass);
18598 if (Constraint.
size() > 3 && Constraint[1] ==
'f') {
18599 int RegNum = atoi(Constraint.
data() + 2);
18600 if (RegNum > 31 || RegNum < 0)
18602 if (VT == MVT::f32 || VT == MVT::i32)
18603 return Subtarget.hasSPE()
18604 ? std::make_pair(PPC::R0 + RegNum, &PPC::GPRCRegClass)
18605 : std::make_pair(PPC::F0 + RegNum, &PPC::F4RCRegClass);
18606 if (VT == MVT::f64 || VT == MVT::i64)
18607 return Subtarget.hasSPE()
18608 ? std::make_pair(PPC::S0 + RegNum, &PPC::SPERCRegClass)
18609 : std::make_pair(PPC::F0 + RegNum, &PPC::F8RCRegClass);
18613 std::pair<unsigned, const TargetRegisterClass *> R =
18622 if (R.first && VT == MVT::i64 && Subtarget.isPPC64() &&
18623 PPC::GPRCRegClass.contains(R.first))
18624 return std::make_pair(
TRI->getMatchingSuperReg(R.first,
18625 PPC::sub_32, &PPC::G8RCRegClass),
18626 &PPC::G8RCRegClass);
18629 if (!R.second &&
StringRef(
"{cc}").equals_insensitive(Constraint)) {
18630 R.first = PPC::CR0;
18631 R.second = &PPC::CRRCRegClass;
18635 if (Subtarget.isAIXABI() && !TM.getAIXExtendedAltivecABI()) {
18636 if (((R.first >= PPC::V20 && R.first <= PPC::V31) ||
18637 (R.first >= PPC::VF20 && R.first <= PPC::VF31)) &&
18638 (R.second == &PPC::VSRCRegClass || R.second == &PPC::VSFRCRegClass))
18639 errs() <<
"warning: vector registers 20 to 32 are reserved in the "
18640 "default AIX AltiVec ABI and cannot be used\n";
18650 std::vector<SDValue> &
Ops,
18655 if (Constraint.
size() > 1)
18658 char Letter = Constraint[0];
18673 EVT TCVT = MVT::i64;
18714 if (Result.getNode()) {
18715 Ops.push_back(Result);
18726 if (
I.getNumOperands() <= 1)
18730 auto IntrinsicID =
Ops[1].getNode()->getAsZExtVal();
18731 if (IntrinsicID != Intrinsic::ppc_tdw && IntrinsicID != Intrinsic::ppc_tw &&
18732 IntrinsicID != Intrinsic::ppc_trapd && IntrinsicID != Intrinsic::ppc_trap)
18735 if (
MDNode *MDN =
I.getMetadata(LLVMContext::MD_annotation))
18751 if (Ty->isVectorTy() && AM.
BaseOffs != 0 && !Subtarget.hasP9Vector())
18763 switch (AM.
Scale) {
18791 unsigned Depth =
Op.getConstantOperandVal(0);
18815 SDValue RetAddrFI = getReturnAddrFrameIndex(DAG);
18823 unsigned Depth =
Op.getConstantOperandVal(0);
18830 bool isPPC64 = PtrVT == MVT::i64;
18836 FrameReg = isPPC64 ? PPC::X1 : PPC::R1;
18838 FrameReg = isPPC64 ? PPC::FP8 : PPC::FP;
18844 FrameAddr, MachinePointerInfo());
18848#define GET_REGISTER_MATCHER
18849#include "PPCGenAsmMatcher.inc"
18853 bool IsPPC64 = Subtarget.isPPC64();
18865 if ((IsPPC64 && Reg == PPC::R2) || Reg == PPC::R0)
18871 Reg = Reg.id() - PPC::R0 + PPC::X0;
18878 if (Subtarget.is32BitELFABI())
18883 if (Subtarget.isAIXABI())
18897 return Subtarget.isGVIndirectSymbol(
G->getGlobal());
18913 case Intrinsic::ppc_atomicrmw_xchg_i128:
18914 case Intrinsic::ppc_atomicrmw_add_i128:
18915 case Intrinsic::ppc_atomicrmw_sub_i128:
18916 case Intrinsic::ppc_atomicrmw_nand_i128:
18917 case Intrinsic::ppc_atomicrmw_and_i128:
18918 case Intrinsic::ppc_atomicrmw_or_i128:
18919 case Intrinsic::ppc_atomicrmw_xor_i128:
18920 case Intrinsic::ppc_cmpxchg_i128:
18922 Info.memVT = MVT::i128;
18923 Info.ptrVal =
I.getArgOperand(0);
18925 Info.align =
Align(16);
18930 case Intrinsic::ppc_atomic_load_i128:
18932 Info.memVT = MVT::i128;
18933 Info.ptrVal =
I.getArgOperand(0);
18935 Info.align =
Align(16);
18939 case Intrinsic::ppc_atomic_store_i128:
18941 Info.memVT = MVT::i128;
18942 Info.ptrVal =
I.getArgOperand(2);
18944 Info.align =
Align(16);
18948 case Intrinsic::ppc_altivec_lvx:
18949 case Intrinsic::ppc_altivec_lvxl:
18950 case Intrinsic::ppc_altivec_lvebx:
18951 case Intrinsic::ppc_altivec_lvehx:
18952 case Intrinsic::ppc_altivec_lvewx:
18953 case Intrinsic::ppc_vsx_lxvd2x:
18954 case Intrinsic::ppc_vsx_lxvw4x:
18955 case Intrinsic::ppc_vsx_lxvd2x_be:
18956 case Intrinsic::ppc_vsx_lxvw4x_be:
18957 case Intrinsic::ppc_vsx_lxvl:
18958 case Intrinsic::ppc_vsx_lxvll: {
18961 case Intrinsic::ppc_altivec_lvebx:
18964 case Intrinsic::ppc_altivec_lvehx:
18967 case Intrinsic::ppc_altivec_lvewx:
18970 case Intrinsic::ppc_vsx_lxvd2x:
18971 case Intrinsic::ppc_vsx_lxvd2x_be:
18981 Info.ptrVal =
I.getArgOperand(0);
18984 Info.align =
Align(1);
18989 case Intrinsic::ppc_altivec_stvx:
18990 case Intrinsic::ppc_altivec_stvxl:
18991 case Intrinsic::ppc_altivec_stvebx:
18992 case Intrinsic::ppc_altivec_stvehx:
18993 case Intrinsic::ppc_altivec_stvewx:
18994 case Intrinsic::ppc_vsx_stxvd2x:
18995 case Intrinsic::ppc_vsx_stxvw4x:
18996 case Intrinsic::ppc_vsx_stxvd2x_be:
18997 case Intrinsic::ppc_vsx_stxvw4x_be:
18998 case Intrinsic::ppc_vsx_stxvl:
18999 case Intrinsic::ppc_vsx_stxvll: {
19002 case Intrinsic::ppc_altivec_stvebx:
19005 case Intrinsic::ppc_altivec_stvehx:
19008 case Intrinsic::ppc_altivec_stvewx:
19011 case Intrinsic::ppc_vsx_stxvd2x:
19012 case Intrinsic::ppc_vsx_stxvd2x_be:
19022 Info.ptrVal =
I.getArgOperand(1);
19025 Info.align =
Align(1);
19030 case Intrinsic::ppc_stdcx:
19031 case Intrinsic::ppc_stwcx:
19032 case Intrinsic::ppc_sthcx:
19033 case Intrinsic::ppc_stbcx: {
19035 auto Alignment =
Align(8);
19037 case Intrinsic::ppc_stdcx:
19040 case Intrinsic::ppc_stwcx:
19042 Alignment =
Align(4);
19044 case Intrinsic::ppc_sthcx:
19046 Alignment =
Align(2);
19048 case Intrinsic::ppc_stbcx:
19050 Alignment =
Align(1);
19055 Info.ptrVal =
I.getArgOperand(0);
19057 Info.align = Alignment;
19071 const AttributeList &FuncAttributes)
const {
19075 if (Subtarget.hasAltivec() &&
Op.size() >= 16) {
19076 if (
Op.isMemset() && Subtarget.hasVSX()) {
19081 if (TailSize > 2 && TailSize <= 4) {
19086 if (
Op.isAligned(
Align(16)) || Subtarget.hasP8Vector())
19091 if (Subtarget.isPPC64()) {
19102 assert(Ty->isIntegerTy());
19104 unsigned BitSize = Ty->getPrimitiveSizeInBits();
19105 return !(BitSize == 0 || BitSize > 64);
19113 return NumBits1 == 64 && NumBits2 == 32;
19121 return NumBits1 == 64 && NumBits2 == 32;
19128 EVT MemVT = LD->getMemoryVT();
19129 if ((MemVT == MVT::i1 || MemVT == MVT::i8 || MemVT == MVT::i16 ||
19130 (Subtarget.isPPC64() && MemVT == MVT::i32)) &&
19146 "invalid fpext types");
19148 if (DestVT == MVT::f128)
19163 unsigned *
Fast)
const {
19177 !Subtarget.allowsUnalignedFPAccess())
19181 if (Subtarget.hasVSX()) {
19182 if (VT != MVT::v2f64 && VT != MVT::v2i64 &&
19183 VT != MVT::v4f32 && VT != MVT::v4i32)
19190 if (VT == MVT::ppcf128)
19205 if (!ConstNode->getAPIntValue().isSignedIntN(64))
19213 int64_t Imm = ConstNode->getSExtValue();
19234 if (Subtarget.hasSPE() || Subtarget.useSoftFloat())
19236 switch (Ty->getScalarType()->getTypeID()) {
19241 return Subtarget.hasP9Vector();
19249 if (!
I->hasOneUse())
19253 assert(
User &&
"A single use instruction with no uses.");
19255 switch (
I->getOpcode()) {
19256 case Instruction::FMul: {
19258 if (
User->getOpcode() != Instruction::FSub &&
19259 User->getOpcode() != Instruction::FAdd)
19266 bool AllowContract =
I->getFastMathFlags().allowContract() &&
19267 User->getFastMathFlags().allowContract();
19273 case Instruction::Load: {
19286 if (
User->getOpcode() != Instruction::Store)
19306 static const MCPhysReg ScratchRegs[] = {
19307 PPC::X12, PPC::LR8, PPC::CTR8, 0
19310 return ScratchRegs;
19314 const Constant *PersonalityFn)
const {
19315 return Subtarget.isPPC64() ? PPC::X3 : PPC::R3;
19319 const Constant *PersonalityFn)
const {
19320 return Subtarget.isPPC64() ? PPC::X4 : PPC::R4;
19325 EVT VT ,
unsigned DefinedValues)
const {
19326 if (VT == MVT::v2i64)
19327 return Subtarget.hasDirectMove();
19329 if (Subtarget.hasVSX())
19356 return PPCISD::FNMSUB;
19357 case PPCISD::FNMSUB:
19363 bool LegalOps,
bool OptForSize,
19365 unsigned Depth)
const {
19369 unsigned Opc =
Op.getOpcode();
19370 EVT VT =
Op.getValueType();
19374 case PPCISD::FNMSUB:
19394 if (Flags.hasNoSignedZeros()) {
19398 N0Cost,
Depth + 1);
19402 N1Cost,
Depth + 1);
19404 if (NegN0 && N0Cost <= N1Cost) {
19405 Cost = std::min(N0Cost, N2Cost);
19407 }
else if (NegN1) {
19408 Cost = std::min(N1Cost, N2Cost);
19428 if (M.getStackProtectorGuard() ==
"tls" || Subtarget.isTargetLinux())
19434 bool ForCodeSize)
const {
19435 if (!VT.
isSimple() || !Subtarget.hasVSX())
19445 if (Subtarget.hasPrefixInstrs() && Subtarget.hasP10Vector()) {
19450 APSInt IntResult(16,
false);
19455 if (IsExact && IntResult <= 15 && IntResult >= -16)
19457 return Imm.isZero();
19460 return Imm.isPosZero();
19472 unsigned Opcode =
N->getOpcode();
19492 if (Mask->getZExtValue() == OpSizeInBits - 1)
19499 DAGCombinerInfo &DCI)
const {
19500 EVT VT =
N->getValueType(0);
19503 unsigned Opc =
N->getOpcode();
19505 "Unexpected opcode.");
19512 if (EltTy != MVT::i64 && EltTy != MVT::i32)
19516 uint64_t SplatBits = 0;
19517 bool AddSplatCase =
false;
19521 AddSplatCase =
true;
19525 if (!AddSplatCase) {
19529 unsigned SplatBitSize;
19531 APInt APSplatBits, APSplatUndef;
19533 bool BVNIsConstantSplat =
19535 HasAnyUndefs, 0, !Subtarget.isLittleEndian());
19536 if (!BVNIsConstantSplat || SplatBitSize != EltBits)
19547 if (SplatBits == (EltBits - 1)) {
19551 NewOpc = PPCISD::SHL;
19554 NewOpc = PPCISD::SRL;
19557 NewOpc = PPCISD::SRA;
19561 return DCI.DAG.getNode(NewOpc,
DL, VT, N0, SplatOnes);
19569 if (EltTy != MVT::i64 || SplatBits != 1)
19572 return DCI.DAG.getNode(
ISD::ADD, SDLoc(
N), VT, N0, N0);
19575SDValue PPCTargetLowering::combineSHL(
SDNode *
N, DAGCombinerInfo &DCI)
const {
19579 if (
N->getValueType(0).isVector())
19580 return combineVectorShift(
N, DCI);
19584 if (!Subtarget.isISA3_0() || !Subtarget.isPPC64() ||
19587 N->getValueType(0) != MVT::i64)
19602 ShiftBy = DCI.DAG.getConstant(CN1->
getZExtValue(),
DL, MVT::i32);
19608SDValue PPCTargetLowering::combineSRA(
SDNode *
N, DAGCombinerInfo &DCI)
const {
19612 if (
N->getValueType(0).isVector())
19613 return combineVectorShift(
N, DCI);
19618SDValue PPCTargetLowering::combineSRL(
SDNode *
N, DAGCombinerInfo &DCI)
const {
19622 if (
N->getValueType(0).isVector())
19623 return combineVectorShift(
N, DCI);
19634 if (!Subtarget.isPPC64())
19640 auto isZextOfCompareWithConstant = [](
SDValue Op) {
19642 Op.getValueType() != MVT::i64)
19646 if (Cmp.getOpcode() !=
ISD::SETCC || !Cmp.hasOneUse() ||
19647 Cmp.getOperand(0).getValueType() != MVT::i64)
19651 int64_t NegConstant = 0 -
Constant->getSExtValue();
19660 bool LHSHasPattern = isZextOfCompareWithConstant(
LHS);
19661 bool RHSHasPattern = isZextOfCompareWithConstant(
RHS);
19664 if (LHSHasPattern && !RHSHasPattern)
19666 else if (!LHSHasPattern && !RHSHasPattern)
19670 EVT CarryType = Subtarget.useCRBits() ? MVT::i1 : MVT::i32;
19673 SDValue Z = Cmp.getOperand(0);
19675 int64_t NegConstant = 0 -
Constant->getSExtValue();
19688 SDValue AddOrZ = NegConstant != 0 ?
Add : Z;
19706 SDValue AddOrZ = NegConstant != 0 ?
Add : Z;
19736 if (
LHS.getOpcode() != PPCISD::MAT_PCREL_ADDR)
19739 if (
LHS.getOpcode() != PPCISD::MAT_PCREL_ADDR)
19747 if (!GSDN || !ConstNode)
19775 EVT VT =
N->getValueType(0);
19776 if (!Subtarget.hasVSX())
19780 if (!(VT == MVT::v8i16 || VT == MVT::v16i8 || VT == MVT::v4i32 ||
19792 unsigned NumOfEles =
RHS.getNumOperands();
19793 for (
unsigned i = 0; i < NumOfEles; ++i) {
19795 if (!CN || CN->getSExtValue() != 1)
19810SDValue PPCTargetLowering::combineADD(
SDNode *
N, DAGCombinerInfo &DCI)
const {
19832 DAGCombinerInfo &DCI)
const {
19834 if (Subtarget.useCRBits()) {
19836 if (
SDValue CRTruncValue = DAGCombineTruncBoolExt(
N, DCI))
19837 return CRTruncValue;
19844 if (Op0.
getValueType() != MVT::i128 ||
N->getValueType(0) != MVT::i64)
19847 int EltToExtract = DCI.DAG.getDataLayout().isBigEndian() ? 1 : 0;
19857 EltToExtract = EltToExtract ? 0 : 1;
19867 return DCI.DAG.getNode(
19869 DCI.DAG.getTargetConstant(EltToExtract, dl, MVT::i32));
19874SDValue PPCTargetLowering::combineMUL(
SDNode *
N, DAGCombinerInfo &DCI)
const {
19875 SelectionDAG &DAG = DCI.DAG;
19878 if (!ConstOpOrElement)
19886 auto IsProfitable = [
this](
bool IsNeg,
bool IsAddOne, EVT VT) ->
bool {
19887 switch (this->Subtarget.getCPUDirective()) {
19910 return IsAddOne && IsNeg ? VT.
isVector() :
true;
19914 EVT VT =
N->getValueType(0);
19919 APInt MulAmtAbs = MulAmt.
abs();
19921 if ((MulAmtAbs - 1).isPowerOf2()) {
19925 if (!IsProfitable(IsNeg,
true, VT))
19938 }
else if ((MulAmtAbs + 1).isPowerOf2()) {
19942 if (!IsProfitable(IsNeg,
false, VT))
19963 DAGCombinerInfo &DCI)
const {
19967 SDNodeFlags
Flags =
N->getFlags();
19968 EVT VT =
N->getValueType(0);
19969 SelectionDAG &DAG = DCI.DAG;
19970 unsigned Opc =
N->getOpcode();
19972 bool LegalOps = !DCI.isBeforeLegalizeOps();
19980 if (!
Flags.hasNoSignedZeros())
19996bool PPCTargetLowering::mayBeEmittedAsTailCall(
const CallInst *CI)
const {
19998 if (!Subtarget.is64BitELFABI())
20008 if (!TM.Options.GuaranteedTailCallOpt &&
DisableSCO)
20013 if (!Callee ||
Callee->isVarArg())
20026bool PPCTargetLowering::
20027isMaskAndCmp0FoldingBeneficial(
const Instruction &AndI)
const {
20032 if (CI->getBitWidth() > 64)
20034 int64_t ConstVal = CI->getZExtValue();
20036 (
isUInt<16>(ConstVal >> 16) && !(ConstVal & 0xFFFF));
20045PPC::AddrMode PPCTargetLowering::getAddrModeForFlags(
unsigned Flags)
const {
20051 if ((Flags & FlagSet) == FlagSet)
20054 if ((Flags & FlagSet) == FlagSet)
20057 if ((Flags & FlagSet) == FlagSet)
20060 if ((Flags & FlagSet) == FlagSet)
20081 if ((FrameIndexAlign % 4) != 0)
20082 FlagSet &=
~PPC::MOF_RPlusSImm16Mult4;
20083 if ((FrameIndexAlign % 16) != 0)
20084 FlagSet &=
~PPC::MOF_RPlusSImm16Mult16;
20088 if ((FrameIndexAlign % 4) == 0)
20090 if ((FrameIndexAlign % 16) == 0)
20103 auto SetAlignFlagsForImm = [&](
uint64_t Imm) {
20104 if ((Imm & 0x3) == 0)
20106 if ((Imm & 0xf) == 0)
20112 const APInt &ConstImm = CN->getAPIntValue();
20131 const APInt &ConstImm = CN->getAPIntValue();
20141 }
else if (
RHS.getOpcode() == PPCISD::Lo && !
RHS.getConstantOperandVal(1))
20152 return (
N.getOpcode() == PPCISD::MAT_PCREL_ADDR ||
20161unsigned PPCTargetLowering::computeMOFlags(
const SDNode *Parent,
SDValue N,
20166 if (!Subtarget.hasP9Vector())
20171 if (Subtarget.hasPrefixInstrs())
20174 if (Subtarget.hasSPE())
20183 unsigned ParentOp = Parent->
getOpcode();
20187 if ((
ID == Intrinsic::ppc_vsx_lxvp) || (
ID == Intrinsic::ppc_vsx_stxvp)) {
20188 SDValue IntrinOp = (
ID == Intrinsic::ppc_vsx_lxvp)
20200 if (LSB->isIndexed())
20206 assert(MN &&
"Parent should be a MemSDNode!");
20211 "Not expecting scalar integers larger than 16 bytes!");
20214 else if (
Size == 32)
20221 else if (
Size == 256) {
20222 assert(Subtarget.pairedVectorMemops() &&
20223 "256-bit vectors are only available when paired vector memops is "
20231 else if (MemVT == MVT::f128 || MemVT.
isVector())
20262 FlagSet &= ~PPC::MOF_NoExt;
20267 bool IsNonP1034BitConst =
20271 IsNonP1034BitConst)
20284 int16_t ForceXFormImm = 0;
20287 Disp =
N.getOperand(0);
20288 Base =
N.getOperand(1);
20299 !
N.getOperand(1).hasOneUse() || !
N.getOperand(0).hasOneUse())) {
20300 Disp =
N.getOperand(0);
20301 Base =
N.getOperand(1);
20306 Disp = DAG.
getRegister(Subtarget.isPPC64() ? PPC::ZERO8 : PPC::ZERO,
20315 unsigned NumParts,
MVT PartVT, std::optional<CallingConv::ID> CC)
const {
20321 if (PartVT == MVT::f64 &&
20322 (ValVT == MVT::i32 || ValVT == MVT::i16 || ValVT == MVT::i8)) {
20331SDValue PPCTargetLowering::lowerToLibCall(
const char *LibCallName,
SDValue Op,
20335 EVT RetVT =
Op.getValueType();
20342 EVT ArgVT =
N.getValueType();
20346 Entry.IsZExt = !Entry.IsSExt;
20347 Args.push_back(Entry);
20355 (RetTy ==
F.getReturnType() ||
F.getReturnType()->isVoidTy());
20368SDValue PPCTargetLowering::lowerLibCallBasedOnType(
20369 const char *LibCallFloatName,
const char *LibCallDoubleName,
SDValue Op,
20371 if (
Op.getValueType() == MVT::f32)
20372 return lowerToLibCall(LibCallFloatName,
Op, DAG);
20374 if (
Op.getValueType() == MVT::f64)
20375 return lowerToLibCall(LibCallDoubleName,
Op, DAG);
20380bool PPCTargetLowering::isLowringToMASSFiniteSafe(
SDValue Op)
const {
20381 SDNodeFlags
Flags =
Op.getNode()->getFlags();
20382 return isLowringToMASSSafe(
Op) &&
Flags.hasNoSignedZeros() &&
20386bool PPCTargetLowering::isLowringToMASSSafe(
SDValue Op)
const {
20387 return Op.getNode()->getFlags().hasApproximateFuncs();
20390bool PPCTargetLowering::isScalarMASSConversionEnabled()
const {
20394SDValue PPCTargetLowering::lowerLibCallBase(
const char *LibCallDoubleName,
20395 const char *LibCallFloatName,
20396 const char *LibCallDoubleNameFinite,
20397 const char *LibCallFloatNameFinite,
20400 if (!isScalarMASSConversionEnabled() || !isLowringToMASSSafe(
Op))
20403 if (!isLowringToMASSFiniteSafe(
Op))
20404 return lowerLibCallBasedOnType(LibCallFloatName, LibCallDoubleName,
Op,
20407 return lowerLibCallBasedOnType(LibCallFloatNameFinite,
20408 LibCallDoubleNameFinite,
Op, DAG);
20412 return lowerLibCallBase(
"__xl_pow",
"__xl_powf",
"__xl_pow_finite",
20413 "__xl_powf_finite",
Op, DAG);
20417 return lowerLibCallBase(
"__xl_sin",
"__xl_sinf",
"__xl_sin_finite",
20418 "__xl_sinf_finite",
Op, DAG);
20422 return lowerLibCallBase(
"__xl_cos",
"__xl_cosf",
"__xl_cos_finite",
20423 "__xl_cosf_finite",
Op, DAG);
20427 return lowerLibCallBase(
"__xl_log",
"__xl_logf",
"__xl_log_finite",
20428 "__xl_logf_finite",
Op, DAG);
20432 return lowerLibCallBase(
"__xl_log10",
"__xl_log10f",
"__xl_log10_finite",
20433 "__xl_log10f_finite",
Op, DAG);
20437 return lowerLibCallBase(
"__xl_exp",
"__xl_expf",
"__xl_exp_finite",
20438 "__xl_expf_finite",
Op, DAG);
20463 unsigned Flags = computeMOFlags(Parent,
N, DAG);
20474 assert(Subtarget.isUsingPCRelativeCalls() &&
20475 "Must be using PC-Relative calls when a valid PC-Relative node is "
20505 Disp =
N.getOperand(1).getOperand(0);
20510 Base =
N.getOperand(0);
20518 EVT CNType = CN->getValueType(0);
20519 uint64_t CNImm = CN->getZExtValue();
20530 if ((CNType == MVT::i32 ||
isInt<32>(CNImm)) &&
20532 int32_t Addr = (int32_t)CNImm;
20537 uint32_t LIS = CNType == MVT::i32 ? PPC::LIS : PPC::LIS8;
20553 unsigned Opcode =
N.getOpcode();
20561 Base =
N.getOperand(0);
20580 Base = FI ?
N :
N.getOperand(1);
20581 Disp = FI ? DAG.
getRegister(Subtarget.isPPC64() ? PPC::ZERO8 : PPC::ZERO,
20592 bool IsVarArg)
const {
20602 return Subtarget.isPPC64() && Subtarget.hasQuadwordAtomics();
20639 return Intrinsic::ppc_atomicrmw_xchg_i128;
20641 return Intrinsic::ppc_atomicrmw_add_i128;
20643 return Intrinsic::ppc_atomicrmw_sub_i128;
20645 return Intrinsic::ppc_atomicrmw_and_i128;
20647 return Intrinsic::ppc_atomicrmw_or_i128;
20649 return Intrinsic::ppc_atomicrmw_xor_i128;
20651 return Intrinsic::ppc_atomicrmw_nand_i128;
20659 Module *M = Builder.GetInsertBlock()->getParent()->getParent();
20663 Value *IncrLo = Builder.CreateTrunc(Incr, Int64Ty,
"incr_lo");
20665 Builder.CreateTrunc(Builder.CreateLShr(Incr, 64), Int64Ty,
"incr_hi");
20666 Value *LoHi = Builder.CreateIntrinsic(
20668 {AlignedAddr, IncrLo, IncrHi});
20669 Value *
Lo = Builder.CreateExtractValue(LoHi, 0,
"lo");
20670 Value *
Hi = Builder.CreateExtractValue(LoHi, 1,
"hi");
20671 Lo = Builder.CreateZExt(
Lo, ValTy,
"lo64");
20672 Hi = Builder.CreateZExt(
Hi, ValTy,
"hi64");
20673 return Builder.CreateOr(
20674 Lo, Builder.CreateShl(
Hi, ConstantInt::get(ValTy, 64)),
"val64");
20681 Module *M = Builder.GetInsertBlock()->getParent()->getParent();
20687 Value *CmpLo = Builder.CreateTrunc(CmpVal, Int64Ty,
"cmp_lo");
20689 Builder.CreateTrunc(Builder.CreateLShr(CmpVal, 64), Int64Ty,
"cmp_hi");
20690 Value *NewLo = Builder.CreateTrunc(NewVal, Int64Ty,
"new_lo");
20692 Builder.CreateTrunc(Builder.CreateLShr(NewVal, 64), Int64Ty,
"new_hi");
20695 Builder.CreateCall(IntCmpXchg, {AlignedAddr, CmpLo, CmpHi, NewLo, NewHi});
20697 Value *
Lo = Builder.CreateExtractValue(LoHi, 0,
"lo");
20698 Value *
Hi = Builder.CreateExtractValue(LoHi, 1,
"hi");
20699 Lo = Builder.CreateZExt(
Lo, ValTy,
"lo64");
20700 Hi = Builder.CreateZExt(
Hi, ValTy,
"hi64");
20701 return Builder.CreateOr(
20702 Lo, Builder.CreateShl(
Hi, ConstantInt::get(ValTy, 64)),
"val64");
20706 return Subtarget.useCRBits();
20711bool PPCTargetLowering::isShuffleMaskLegal(
ArrayRef<int> Mask,
EVT VT)
const {
20722 DAGCombinerInfo &DCI)
const {
20727 EVT ResVT =
N->getValueType(0);
20729 EVT SrcVT = Src.getValueType();
20734 if (ResVT != MVT::i16 && ResVT != MVT::i8)
20737 GenerateVBPERM(DAG, dl, Src, SrcVT, TruncResVT, IsLittleEndian);
20750 bool IsV16i8 = (ResVT == MVT::v16i1 && SrcVT == MVT::v16i8);
20751 bool IsV8i16 = (ResVT == MVT::v8i1 && SrcVT == MVT::v8i16);
20752 bool IsV8i8 = (ResVT == MVT::v8i1 && SrcVT == MVT::v8i8);
20754 if (!IsV16i8 && !IsV8i16 && !IsV8i8)
20762 SmallVector<int, 16> BitIndices(16, 128);
20766 BitIndices[Idx] = EltSize * (NumElts - Idx) - 1;
20767 if (IsV8i8 && IsLE)
20768 BitIndices[Idx] += 64;
20771 std::reverse(BitIndices.begin(), BitIndices.end());
20773 for (
auto Idx : BitIndices)
20778 DAG.
getConstant(Intrinsic::ppc_altivec_vbpermq, dl, MVT::i32),
static MCRegister MatchRegisterName(StringRef Name)
static unsigned getCallOpcode(const MachineFunction &CallerF, bool IsIndirect, bool IsTailCall, std::optional< CallLowering::PtrAuthInfo > &PAI, MachineRegisterInfo &MRI)
static SDValue GeneratePerfectShuffle(unsigned ID, SDValue V1, SDValue V2, 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...
static bool isSignExtended(SDValue N, SelectionDAG &DAG)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static msgpack::DocNode getNode(msgpack::DocNode DN, msgpack::Type Type, MCValue Val)
static std::pair< Register, unsigned > getBaseWithConstantOffset(MachineRegisterInfo &MRI, Register Reg)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
This file implements the APSInt class, which is a simple class that represents an arbitrary sized int...
static bool isLoad(int Opcode)
static bool isFloatingPointZero(SDValue Op)
isFloatingPointZero - Return true if this is +0.0.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
Atomic ordering constants.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static RegisterPass< DebugifyModulePass > DM("debugify", "Attach debug info to everything")
This file defines the DenseMap class.
const HexagonInstrInfo * TII
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...
Module.h This file contains the declarations for the Module class.
This defines the Use class.
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
static int getEstimateRefinementSteps(EVT VT, const LoongArchSubtarget &Subtarget)
static bool isSplat(Value *V)
Return true if V is a splat of a value (which is used when multiplying a matrix with a scalar).
Machine Check Debug Module
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static bool isConstantOrUndef(const SDValue Op)
static CodeModel::Model getCodeModel(const PPCSubtarget &S, const TargetMachine &TM, const MachineOperand &MO)
cl::opt< bool > ANDIGlueBug("expose-ppc-andi-glue-bug", cl::desc("expose the ANDI glue bug on PPC"), cl::Hidden)
static SDValue getCanonicalConstSplat(uint64_t Val, unsigned SplatSize, EVT VT, SelectionDAG &DAG, const SDLoc &dl)
getCanonicalConstSplat - Build a canonical splat immediate of Val with an element size of SplatSize.
static bool IsSelectCC(MachineInstr &MI)
static bool CC_AIX(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
static const TargetRegisterClass * getRegClassForSVT(MVT::SimpleValueType SVT, bool IsPPC64, bool HasP8Vector, bool HasVSX)
static bool isGPRShadowAligned(MCPhysReg Reg, Align RequiredAlign)
static SDValue DAGCombineAddc(SDNode *N, llvm::PPCTargetLowering::DAGCombinerInfo &DCI)
static bool needStackSlotPassParameters(const PPCSubtarget &Subtarget, const SmallVectorImpl< ISD::OutputArg > &Outs)
std::tuple< uint32_t, uint8_t > LXVKQPattern
static bool isAlternatingShuffMask(const ArrayRef< int > &Mask, int NumElts)
static bool isShuffleMaskInRange(const SmallVectorImpl< int > &ShuffV, int HalfVec, int LHSLastElementDefined, int RHSLastElementDefined)
static SDValue addShuffleForVecExtend(SDNode *N, SelectionDAG &DAG, SDValue Input, uint64_t Elems, uint64_t CorrectElems)
static cl::opt< bool > DisablePPCUnaligned("disable-ppc-unaligned", cl::desc("disable unaligned load/store generation on PPC"), cl::Hidden)
static SDValue combineADDToADDZE(SDNode *N, SelectionDAG &DAG, const PPCSubtarget &Subtarget)
static bool findConsecutiveLoad(LoadSDNode *LD, SelectionDAG &DAG)
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...
static unsigned mapArgRegToOffsetAIX(unsigned Reg, const PPCFrameLowering *FL)
static void CalculateTailCallArgDest(SelectionDAG &DAG, MachineFunction &MF, bool IsPPC64, SDValue Arg, int SPDiff, unsigned ArgOffset, SmallVectorImpl< TailCallArgumentInfo > &TailCallArguments)
CalculateTailCallArgDest - Remember Argument for later processing.
static SDValue combineADDToMAT_PCREL_ADDR(SDNode *N, SelectionDAG &DAG, const PPCSubtarget &Subtarget)
static void setAlignFlagsForFI(SDValue N, unsigned &FlagSet, SelectionDAG &DAG)
Set alignment flags based on whether or not the Frame Index is aligned.
static bool isTOCSaveRestoreRequired(const PPCSubtarget &Subtarget)
static void updateForAIXShLibTLSModelOpt(TLSModel::Model &Model, SelectionDAG &DAG, const TargetMachine &TM)
updateForAIXShLibTLSModelOpt - Helper to initialize TLS model opt settings, and then apply the update...
static bool provablyDisjointOr(SelectionDAG &DAG, const SDValue &N)
Used when computing address flags for selecting loads and stores.
static bool callsShareTOCBase(const Function *Caller, const GlobalValue *CalleeGV, const TargetMachine &TM)
static SDValue generateSToVPermutedForVecShuffle(int ScalarSize, uint64_t ShuffleEltWidth, unsigned &NumValidElts, int FirstElt, int &LastElt, SDValue VecShuffOperand, SDValue SToVNode, SelectionDAG &DAG, const PPCSubtarget &Subtarget)
constexpr uint64_t AIXSmallTlsPolicySizeLimit
static bool canConvertToVcmpequb(SDValue &LHS, SDValue &RHS)
static bool isPCRelNode(SDValue N)
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.
static cl::opt< unsigned > PPCGatherAllAliasesMaxDepth("ppc-gather-alias-max-depth", cl::init(18), cl::Hidden, cl::desc("max depth when checking alias info in GatherAllAliases()"))
static bool areCallingConvEligibleForTCO_64SVR4(CallingConv::ID CallerCC, CallingConv::ID CalleeCC)
static const MCPhysReg FPR[]
FPR - The set of FP registers that should be allocated for arguments on Darwin and AIX.
static SDNode * isBLACompatibleAddress(SDValue Op, SelectionDAG &DAG)
isCallCompatibleAddress - Return the immediate to use if the specified 32-bit value is representable ...
static Align CalculateStackSlotAlignment(EVT ArgVT, EVT OrigVT, ISD::ArgFlagsTy Flags, unsigned PtrByteSize)
CalculateStackSlotAlignment - Calculates the alignment of this argument on the stack.
static bool IsSelect(MachineInstr &MI)
static SDValue ConvertCarryFlagToCarryValue(EVT SumType, SDValue Flag, EVT CarryType, SelectionDAG &DAG, const PPCSubtarget &STI)
static bool haveEfficientBuildVectorPattern(BuildVectorSDNode *V, bool HasDirectMove, bool HasP8Vector)
Do we have an efficient pattern in a .td file for this node?
static SDValue getSToVPermuted(SDValue OrigSToV, SelectionDAG &DAG, const PPCSubtarget &Subtarget)
static void setUsesTOCBasePtr(MachineFunction &MF)
static SDValue combineXorSelectCC(SDNode *N, SelectionDAG &DAG)
static SDValue transformCallee(const SDValue &Callee, SelectionDAG &DAG, const SDLoc &dl, const PPCSubtarget &Subtarget)
static unsigned EnsureStackAlignment(const PPCFrameLowering *Lowering, unsigned NumBytes)
EnsureStackAlignment - Round stack frame size up from NumBytes to ensure minimum alignment required f...
static SDValue stripModuloOnShift(const TargetLowering &TLI, SDNode *N, SelectionDAG &DAG)
static bool isStoreConditional(SDValue Intrin, unsigned &StoreWidth)
static bool hasSameArgumentList(const Function *CallerFn, const CallBase &CB)
static bool isFPExtLoad(SDValue Op)
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.
static bool isConsecutiveLSLoc(SDValue Loc, EVT VT, LSBaseSDNode *Base, unsigned Bytes, int Dist, SelectionDAG &DAG)
static void StoreTailCallArgumentsToStackSlot(SelectionDAG &DAG, SDValue Chain, const SmallVectorImpl< TailCallArgumentInfo > &TailCallArgs, SmallVectorImpl< SDValue > &MemOpChains, const SDLoc &dl)
StoreTailCallArgumentsToStackSlot - Stores arguments to their stack slot.
static cl::opt< bool > UseAbsoluteJumpTables("ppc-use-absolute-jumptables", cl::desc("use absolute jump tables on ppc"), cl::Hidden)
static void setXFormForUnalignedFI(SDValue N, unsigned Flags, PPC::AddrMode &Mode)
static cl::opt< unsigned > PPCMinimumBitTestCmps("ppc-min-bit-test-cmps", cl::init(3), cl::Hidden, cl::desc("Set minimum of largest number of comparisons to use bit test for " "switch on PPC."))
static void getMaxByValAlign(Type *Ty, Align &MaxAlign, Align MaxMaxAlign)
getMaxByValAlign - Helper for getByValTypeAlignment to determine the desired ByVal argument alignment...
static bool isConsecutiveLS(SDNode *N, LSBaseSDNode *Base, unsigned Bytes, int Dist, SelectionDAG &DAG)
static bool isVMerge(ShuffleVectorSDNode *N, unsigned UnitSize, unsigned LHSStart, unsigned RHSStart)
isVMerge - Common function, used to match vmrg* shuffles.
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...
cl::opt< bool > DisableAutoPairedVecSt("disable-auto-paired-vec-st", cl::desc("disable automatically generated 32byte paired vector stores"), cl::init(true), cl::Hidden)
static void buildCallOperands(SmallVectorImpl< SDValue > &Ops, PPCTargetLowering::CallFlags CFlags, const SDLoc &dl, SelectionDAG &DAG, SmallVector< std::pair< unsigned, SDValue >, 8 > &RegsToPass, SDValue Glue, SDValue Chain, SDValue &Callee, int SPDiff, const PPCSubtarget &Subtarget)
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)
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),...
static SDValue getDataClassTest(SDValue Op, FPClassTest Mask, const SDLoc &Dl, SelectionDAG &DAG, const PPCSubtarget &Subtarget)
static void fixupShuffleMaskForPermutedSToV(SmallVectorImpl< int > &ShuffV, int LHSFirstElt, int LHSLastElt, int RHSFirstElt, int RHSLastElt, int HalfVec, unsigned LHSNumValidElts, unsigned RHSNumValidElts, const PPCSubtarget &Subtarget)
static SDValue AdjustLength(SDValue Val, unsigned Bits, bool Left, SelectionDAG &DAG)
static cl::opt< bool > DisableSCO("disable-ppc-sco", cl::desc("disable sibling call optimization on ppc"), cl::Hidden)
static std::optional< LXVKQPattern > getPatternInfo(const APInt &FullVal)
static void fixupFuncForFI(SelectionDAG &DAG, int FrameIdx, EVT VT)
static cl::opt< bool > DisablePPCPreinc("disable-ppc-preinc", cl::desc("disable preincrement load/store generation on PPC"), cl::Hidden)
static SDValue ConvertSETCCToXori(SDNode *N, SelectionDAG &DAG)
static Intrinsic::ID getIntrinsicForAtomicRMWBinOp128(AtomicRMWInst::BinOp BinOp)
static SDValue convertFPToInt(SDValue Op, SelectionDAG &DAG, const PPCSubtarget &Subtarget)
static unsigned CalculateStackSlotSize(EVT ArgVT, ISD::ArgFlagsTy Flags, unsigned PtrByteSize)
CalculateStackSlotSize - Calculates the size reserved for this argument on the stack.
static int CalculateTailCallSPDiff(SelectionDAG &DAG, bool isTailCall, unsigned ParamSize)
CalculateTailCallSPDiff - Get the amount the stack pointer has to be adjusted to accommodate the argu...
static Instruction * callIntrinsic(IRBuilderBase &Builder, Intrinsic::ID Id)
static void prepareIndirectCall(SelectionDAG &DAG, SDValue &Callee, SDValue &Glue, SDValue &Chain, const SDLoc &dl)
static SDValue combineSELECT_CCBitFloor(SDNode *N, SelectionDAG &DAG)
Optimize the bitfloor(X) pattern for PowerPC.
static SDValue LowerLabelRef(SDValue HiPart, SDValue LoPart, bool isPIC, SelectionDAG &DAG)
static SDValue isScalarToVec(SDValue Op)
static SDValue widenVec(SelectionDAG &DAG, SDValue Vec, const SDLoc &dl)
static cl::opt< bool > DisablePerfectShuffle("ppc-disable-perfect-shuffle", cl::desc("disable vector permute decomposition"), cl::init(true), cl::Hidden)
bool isValidMtVsrBmi(APInt &BitMask, BuildVectorSDNode &BVN, bool IsLittleEndian)
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.
static unsigned invertFMAOpcode(unsigned Opc)
static SDValue combineADDToSUB(SDNode *N, SelectionDAG &DAG, const PPCSubtarget &Subtarget)
static const SDValue * getNormalLoadInput(const SDValue &Op, bool &IsPermuted)
static bool canConvertSETCCToXori(SDNode *N)
static cl::opt< unsigned > PPCMinimumJumpTableEntries("ppc-min-jump-table-entries", cl::init(64), cl::Hidden, cl::desc("Set minimum number of entries to use a jump table on PPC"))
static bool isValidSplatLoad(const PPCSubtarget &Subtarget, const SDValue &Op, unsigned &Opcode)
static SDValue ConvertCarryValueToCarryFlag(EVT SumType, SDValue Value, SelectionDAG &DAG, const PPCSubtarget &STI)
static SDValue convertIntToFP(SDValue Op, SDValue Src, SelectionDAG &DAG, const PPCSubtarget &Subtarget, SDValue Chain=SDValue())
static void PrepareTailCall(SelectionDAG &DAG, SDValue &InGlue, SDValue &Chain, const SDLoc &dl, int SPDiff, unsigned NumBytes, SDValue LROp, SDValue FPOp, SmallVectorImpl< TailCallArgumentInfo > &TailCallArguments)
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...
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.
static SDValue combineBVZEXTLOAD(SDNode *N, SelectionDAG &DAG)
static SDValue combineZextSetccWithZero(SDNode *N, SelectionDAG &DAG)
static SDValue truncateScalarIntegerArg(ISD::ArgFlagsTy Flags, EVT ValVT, SelectionDAG &DAG, SDValue ArgValue, MVT LocVT, const SDLoc &dl)
static void computeFlagsForAddressComputation(SDValue N, unsigned &FlagSet, SelectionDAG &DAG)
Given a node, compute flags that are used for address computation when selecting load and store instr...
SDValue convertTwoLoadsAndCmpToVCMPEQUB(SelectionDAG &DAG, SDNode *N, const SDLoc &DL)
static SDValue getOutputChainFromCallSeq(SDValue CallSeqStart)
static bool CalculateStackSlotUsed(EVT ArgVT, EVT OrigVT, ISD::ArgFlagsTy Flags, unsigned PtrByteSize, unsigned LinkageSize, unsigned ParamAreaSize, unsigned &ArgOffset, unsigned &AvailableFPRs, unsigned &AvailableVRs)
CalculateStackSlotUsed - Return whether this argument will use its stack slot (instead of being passe...
static cl::opt< unsigned > PPCAIXTLSModelOptUseIEForLDLimit("ppc-aix-shared-lib-tls-model-opt-limit", cl::init(1), cl::Hidden, cl::desc("Set inclusive limit count of TLS local-dynamic access(es) in a " "function to use initial-exec"))
static unsigned getPPCStrictOpcode(unsigned Opc)
static void prepareDescriptorIndirectCall(SelectionDAG &DAG, SDValue &Callee, SDValue &Glue, SDValue &Chain, SDValue CallSeqStart, const CallBase *CB, const SDLoc &dl, bool hasNest, const PPCSubtarget &Subtarget)
static cl::opt< bool > DisableP10StoreForward("disable-p10-store-forward", cl::desc("disable P10 store forward-friendly conversion"), cl::Hidden, cl::init(false))
static bool isXXBRShuffleMaskHelper(ShuffleVectorSDNode *N, int Width)
static bool isFunctionGlobalAddress(const GlobalValue *CalleeGV)
static bool isSplatBV(SDValue Op)
static SDValue combineBVOfVecSExt(SDNode *N, SelectionDAG &DAG)
static cl::opt< bool > DisableILPPref("disable-ppc-ilp-pref", cl::desc("disable setting the node scheduling preference to ILP on PPC"), cl::Hidden)
static bool isNByteElemShuffleMask(ShuffleVectorSDNode *, unsigned, int)
Check that the mask is shuffling N byte elements.
static SDValue combineBVOfConsecutiveLoads(SDNode *N, SelectionDAG &DAG)
Reduce the number of loads when building a vector.
static bool isValidPCRelNode(SDValue N)
if(auto Err=PB.parsePassPipeline(MPM, Passes)) return wrap(std MPM run * Mod
pre isel intrinsic Pre ISel Intrinsic Lowering
static constexpr MCPhysReg SPReg
const SmallVectorImpl< MachineOperand > & Cond
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
SI optimize exec mask operations pre RA
static const MCExpr * MaskShift(const MCExpr *Val, uint32_t Mask, uint32_t Shift, MCContext &Ctx)
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
static SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG, const SparcSubtarget *Subtarget)
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This file describes how to lower LLVM code to machine code.
static std::optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
static const fltSemantics & IEEEsingle()
static constexpr roundingMode rmTowardZero
static constexpr roundingMode rmNearestTiesToEven
static const fltSemantics & PPCDoubleDouble()
LLVM_ABI opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
APInt bitcastToAPInt() const
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
void clearBit(unsigned BitPosition)
Set a given bit to 0.
bool isNegatedPowerOf2() const
Check if this APInt's negated value is a power of two greater than zero.
uint64_t getZExtValue() const
Get zero extended value.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
APInt abs() const
Get the absolute value.
bool isAllOnes() const
Determine if all bits are set. This is true for zero-width values.
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
bool isNegative() const
Determine sign of this APInt.
void clearAllBits()
Set every bit to 0.
bool isSignedIntN(unsigned N) const
Check if this APInt has an N-bits signed integer value.
LLVM_ABI void insertBits(const APInt &SubBits, unsigned bitPosition)
Insert the bits from a smaller APInt starting at bitPosition.
bool getBoolValue() const
Convert APInt to a boolean value.
double bitsToDouble() const
Converts APInt bits to a double.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
LLVM_ABI APInt extractBits(unsigned numBits, unsigned bitPosition) const
Return an APInt with the extracted bits [bitPosition,bitPosition+numBits).
An arbitrary precision integer that knows its signedness.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
An instruction that atomically checks whether a specified value is in a memory location,...
Value * getNewValOperand()
an instruction that atomically reads a memory location, combines it with another value,...
BinOp
This enumeration lists the possible modifications atomicrmw can make.
@ USubCond
Subtract only if no unsigned overflow.
@ USubSat
*p = usub.sat(old, v) usub.sat matches the behavior of llvm.usub.sat.
@ UIncWrap
Increment one up to a maximum value.
@ UDecWrap
Decrement one until a minimum value or zero.
BinOp getOperation() const
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
LLVM Basic Block Representation.
int64_t getOffset() const
const BlockAddress * getBlockAddress() const
static BranchProbability getOne()
static BranchProbability getZero()
A "pseudo-class" with methods for operating on BUILD_VECTORs.
LLVM_ABI bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef, unsigned &SplatBitSize, bool &HasAnyUndefs, unsigned MinSplatBits=0, bool isBigEndian=false) const
Check if this is a constant splat, and if so, find the smallest element size that splats the vector.
CCState - This class holds information needed while lowering arguments and return values.
Register getLocReg() const
LocInfo getLocInfo() const
static CCValAssign getReg(unsigned ValNo, MVT ValVT, MCRegister Reg, MVT LocVT, LocInfo HTP, bool IsCustom=false)
static CCValAssign getCustomReg(unsigned ValNo, MVT ValVT, MCRegister Reg, MVT LocVT, LocInfo HTP)
static CCValAssign getMem(unsigned ValNo, MVT ValVT, int64_t Offset, MVT LocVT, LocInfo HTP, bool IsCustom=false)
int64_t getLocMemOffset() const
unsigned getValNo() const
static CCValAssign getCustomMem(unsigned ValNo, MVT ValVT, int64_t Offset, MVT LocVT, LocInfo HTP)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
bool isStrictFP() const
Determine if the call requires strict floating point semantics.
CallingConv::ID getCallingConv() const
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
LLVM_ABI bool isMustTailCall() const
Tests if this call site must be tail call optimized.
Value * getCalledOperand() const
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
unsigned arg_size() const
LLVM_ABI Function * getCaller()
Helper to get the caller (the parent function).
This class represents a function call, abstracting a target machine's calling convention.
ConstantFP - Floating Point Values [float, double].
const Constant * getConstVal() const
uint64_t getZExtValue() const
const APInt & getAPIntValue() const
int64_t getSExtValue() const
This is an important base class in LLVM.
uint64_t getNumOperands() const
A parsed version of the target data layout string in and methods for querying it.
bool isLittleEndian() const
Layout endianness...
LLVM_ABI unsigned getLargestLegalIntTypeSizeInBits() const
Returns the size of largest legal integer type size, or 0 if none are set.
LLVM_ABI 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.
LLVM_ABI Align getABITypeAlign(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
LLVM_ABI TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
bool hasOptSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
const DataLayout & getDataLayout() const
Get the data layout of the module this function belongs to.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
uint64_t getFnAttributeAsParsedInteger(StringRef Kind, uint64_t Default=0) const
For a string attribute Kind, parse attribute as an integer.
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
AttributeList getAttributes() const
Return the attribute list for this Function.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Type * getReturnType() const
Returns the type of the ret val.
const Argument * const_arg_iterator
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
int64_t getOffset() const
unsigned getTargetFlags() const
const GlobalValue * getGlobal() const
LLVM_ABI const GlobalObject * getAliaseeObject() const
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
void setThreadLocalMode(ThreadLocalMode Val)
bool hasHiddenVisibility() const
LLVM_ABI StringRef getSection() const
Module * getParent()
Get the module that this global value is contained inside of...
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this global belongs to.
Type * getValueType() const
bool hasProtectedVisibility() const
Common base class shared among various IRBuilders.
LLVM_ABI bool hasAtomicLoad() const LLVM_READONLY
Return true if this atomic instruction loads from memory.
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
This is an important class for using LLVM in a threaded context.
Base class for LoadSDNode and StoreSDNode.
Tracks which library functions to use for a particular subtarget.
An instruction for reading from memory.
This class is used to represent ISD::LOAD nodes.
const SDValue & getBasePtr() const
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
TypeSize getValue() const
Context object for machine code objects.
Base class for the full range of assembler expressions which are needed for parsing.
Wrapper class representing physical registers. Should be passed by value.
MCSymbolXCOFF * getQualNameSymbol() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
@ INVALID_SIMPLE_VALUE_TYPE
uint64_t getScalarSizeInBits() const
unsigned getVectorNumElements() const
bool isVector() const
Return true if this is a vector value type.
bool isInteger() const
Return true if this is an integer or a vector integer type.
static auto integer_valuetypes()
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
static auto fixedlen_vector_valuetypes()
uint64_t getFixedSizeInBits() const
Return the size of the specified fixed width value type in bits.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isScalarInteger() const
Return true if this is an integer, not including vectors.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
static MVT getIntegerVT(unsigned BitWidth)
static auto fp_valuetypes()
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
void setCallFrameSize(unsigned N)
Set the call frame size on entry to this basic block.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineInstrBundleIterator< MachineInstr > iterator
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
LLVM_ABI int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
LLVM_ABI 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.
void setFrameAddressIsTaken(bool T)
void setHasTailCall(bool V=true)
void setReturnAddressIsTaken(bool s)
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
bool hasVAStart() const
Returns true if the function calls the llvm.va_start intrinsic.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, LLT MemTy, Align 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.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MCContext & getContext() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Function & getFunction()
Return the LLVM function that this machine code represents.
BasicBlockListType::iterator iterator
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Register addLiveIn(MCRegister PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineInstr - Allocate a new MachineInstr.
void insert(iterator MBBI, MachineBasicBlock *MBB)
const MachineInstrBuilder & addUse(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & addDef(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register definition operand.
const MachineInstrBuilder & cloneMemRefs(const MachineInstr &OtherMI) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
Representation of each machine instruction.
@ EK_LabelDifference32
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table.
A description of a memory reference used in the backend.
LocationSize getSize() const
Return the size in bytes of the memory reference.
Flags
Flags values. These may be or'd together.
@ MOVolatile
The memory access is volatile.
@ MODereferenceable
The memory access is dereferenceable (i.e., doesn't trap).
@ MOLoad
The memory access reads data.
@ MOInvariant
The memory access always returns the same value (or traps).
@ MOStore
The memory access writes data.
Flags getFlags() const
Return the raw flags of the source value,.
MachineOperand class - Representation of each machine instruction operand.
static MachineOperand CreateImm(int64_t Val)
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI bool hasOneNonDBGUse(Register RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
LLVM_ABI Register getLiveInVirtReg(MCRegister PReg) const
getLiveInVirtReg - If PReg is a live-in physical register, return the corresponding live-in virtual r...
bool use_empty(Register RegNo) const
use_empty - Return true if there are no instructions using the specified register.
This SDNode is used for target intrinsics that touch memory and need an associated MachineMemOperand.
This is an abstract virtual class for memory operations.
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
MachineMemOperand * getMemOperand() const
Return the unique MachineMemOperand object describing the memory reference performed by operation.
const SDValue & getBasePtr() const
const MachinePointerInfo & getPointerInfo() const
const SDValue & getChain() const
EVT getMemoryVT() const
Return the type of the in-memory value.
A Module instance is used to store all the information related to an LLVM module.
uint64_t getReturnSaveOffset() const
getReturnSaveOffset - Return the previous frame offset to save the return address.
unsigned getLinkageSize() const
getLinkageSize - Return the size of the PowerPC ABI linkage area.
uint64_t getTOCSaveOffset() const
getTOCSaveOffset - Return the previous frame offset to save the TOC register – 64-bit SVR4 ABI only.
PPCFunctionInfo - This class is derived from MachineFunction private PowerPC target-specific informat...
void setVarArgsNumFPR(unsigned Num)
void setReturnAddrSaveIndex(int idx)
bool isAIXFuncUseTLSIEForLD() const
int getReturnAddrSaveIndex() const
unsigned getVarArgsNumFPR() const
void setAIXFuncUseTLSIEForLD()
int getFramePointerSaveIndex() const
void setVarArgsNumGPR(unsigned Num)
void appendParameterType(ParamType Type)
int getVarArgsFrameIndex() const
void setLRStoreRequired()
bool isAIXFuncTLSModelOptInitDone() const
void setTailCallSPDelta(int size)
void setAIXFuncTLSModelOptInitDone()
bool isLRStoreRequired() const
void setMinReservedArea(unsigned size)
unsigned getVarArgsNumGPR() const
unsigned getMinReservedArea() const
void setVarArgsStackOffset(int Offset)
void setVarArgsFrameIndex(int Index)
void addLiveInAttr(Register VReg, ISD::ArgFlagsTy Flags)
This function associates attributes for each live-in virtual register.
int getVarArgsStackOffset() const
void setFramePointerSaveIndex(int Idx)
static bool hasPCRelFlag(unsigned TF)
bool is32BitELFABI() const
unsigned descriptorTOCAnchorOffset() const
MVT getScalarIntVT() const
const PPCFrameLowering * getFrameLowering() const override
bool isUsingPCRelativeCalls() const
bool usesFunctionDescriptors() const
True if the ABI is descriptor based.
MCRegister getEnvironmentPointerRegister() const
bool isLittleEndian() const
MCRegister getTOCPointerRegister() const
MCRegister getStackPointerRegister() const
bool is64BitELFABI() const
const PPCTargetMachine & getTargetMachine() const
const PPCRegisterInfo * getRegisterInfo() const override
unsigned descriptorEnvironmentPointerOffset() const
MachineBasicBlock * emitEHSjLjLongJmp(MachineInstr &MI, MachineBasicBlock *MBB) const
CCAssignFn * ccAssignFnForCall(CallingConv::ID CC, bool Return, bool IsVarArg) const
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.
Value * emitMaskedAtomicRMWIntrinsic(IRBuilderBase &Builder, AtomicRMWInst *AI, Value *AlignedAddr, Value *Incr, Value *Mask, Value *ShiftAmt, AtomicOrdering Ord) const override
Perform a masked atomicrmw using a target-specific intrinsic.
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *MBB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
bool isFPExtFree(EVT DestVT, EVT SrcVT) const override
Return true if an fpext operation is free (for instance, because single-precision floating-point numb...
PPC::AddrMode SelectForceXFormMode(SDValue N, SDValue &Disp, SDValue &Base, SelectionDAG &DAG) const
SelectForceXFormMode - Given the specified address, force it to be represented as an indexed [r+r] op...
Instruction * emitTrailingFence(IRBuilderBase &Builder, Instruction *Inst, AtomicOrdering Ord) const override
TargetLowering::AtomicExpansionKind shouldExpandAtomicRMWInIR(const AtomicRMWInst *AI) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
bool hasInlineStackProbe(const MachineFunction &MF) const override
MachineBasicBlock * emitEHSjLjSetJmp(MachineInstr &MI, MachineBasicBlock *MBB) const
bool supportsTailCallFor(const CallBase *CB) const
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override
Return true if folding a constant offset with the given GlobalAddress is legal.
MachineBasicBlock * emitProbedAlloca(MachineInstr &MI, MachineBasicBlock *MBB) const
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...
MachineBasicBlock * EmitPartwordAtomicBinary(MachineInstr &MI, MachineBasicBlock *MBB, bool is8bit, unsigned Opcode, unsigned CmpOpcode=0, unsigned CmpPred=0) const
SDValue getNegatedExpression(SDValue Op, SelectionDAG &DAG, bool LegalOps, bool OptForSize, NegatibleCost &Cost, unsigned Depth=0) const override
Return the newly negated expression if the cost is not expensive and set the cost in Cost to indicate...
bool SelectAddressRegImm(SDValue N, SDValue &Disp, SDValue &Base, SelectionDAG &DAG, MaybeAlign EncodingAlignment) const
SelectAddressRegImm - Returns true if the address N can be represented by a base register plus a sign...
SDValue expandVSXLoadForLE(SDNode *N, DAGCombinerInfo &DCI) const
bool splitValueIntoRegisterParts(SelectionDAG &DAG, const SDLoc &DL, SDValue Val, SDValue *Parts, unsigned NumParts, MVT PartVT, std::optional< CallingConv::ID > CC) const override
Target-specific splitting of values into parts that fit a register storing a legal type.
void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const override
LowerAsmOperandForConstraint - Lower the specified operand into the Ops vector.
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...
bool hasMultipleConditionRegisters(EVT VT) const override
Does the target have multiple (allocatable) condition registers that can be used to store the results...
Align getByValTypeAlignment(Type *Ty, const DataLayout &DL) const override
getByValTypeAlignment - Return the desired alignment for ByVal aggregate function arguments in the ca...
bool SelectAddressRegReg(SDValue N, SDValue &Base, SDValue &Index, SelectionDAG &DAG, MaybeAlign EncodingAlignment=std::nullopt) const
SelectAddressRegReg - Given the specified addressed, check to see if it can be more efficiently repre...
MachineBasicBlock * EmitAtomicBinary(MachineInstr &MI, MachineBasicBlock *MBB, unsigned AtomicSize, unsigned BinOpcode, unsigned CmpOpcode=0, unsigned CmpPred=0) 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.
Value * emitStoreConditional(IRBuilderBase &Builder, Value *Val, Value *Addr, AtomicOrdering Ord) const override
Perform a store-conditional operation to Addr.
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...
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+...
bool useSoftFloat() const override
SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG) const override
Returns relocation base for the given PIC jumptable.
TargetLowering::AtomicExpansionKind shouldExpandAtomicCmpXchgInIR(const AtomicCmpXchgInst *AI) const override
Returns how the given atomic cmpxchg should be expanded by the IR-level AtomicExpand pass.
Value * emitMaskedAtomicCmpXchgIntrinsic(IRBuilderBase &Builder, AtomicCmpXchgInst *CI, Value *AlignedAddr, Value *CmpVal, Value *NewVal, Value *Mask, AtomicOrdering Ord) const override
Perform a masked cmpxchg using a target-specific intrinsic.
ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &info, const char *constraint) const override
Examine constraint string and operand type and determine a weight value.
bool enableAggressiveFMAFusion(EVT VT) const override
Return true if target always benefits from combining into FMA for a given value type.
Register getRegisterByName(const char *RegName, LLT VT, const MachineFunction &MF) const override
Return the register ID of the name passed in.
bool decomposeMulByConstant(LLVMContext &Context, EVT VT, SDValue C) const override
Return true if it is profitable to transform an integer multiplication-by-constant into simpler opera...
void getTgtMemIntrinsic(SmallVectorImpl< IntrinsicInfo > &Infos, const CallBase &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...
unsigned getJumpTableEncoding() const override
Return the entry encoding for a jump table in the current function.
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...
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...
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.
const MCPhysReg * getScratchRegisters(CallingConv::ID CC) const override
Returns a 0 terminated array of registers that can be safely used as scratch registers.
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...
FastISel * createFastISel(FunctionLoweringInfo &FuncInfo, const TargetLibraryInfo *LibInfo, const LibcallLoweringInfo *LibcallLowering) const override
createFastISel - This method returns a target-specific FastISel object, or null if the target does no...
bool isProfitableToHoist(Instruction *I) const override
isProfitableToHoist - Check if it is profitable to hoist instruction I to its dominator block.
bool isFPImmLegal(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns true if the target can instruction select the specified FP immediate natively.
Value * emitLoadLinked(IRBuilderBase &Builder, Type *ValueTy, Value *Addr, AtomicOrdering Ord) const override
Perform a load-linked operation on Addr, returning a "Value *" with the corresponding pointee type.
ConstraintType getConstraintType(StringRef Constraint) const override
getConstraintType - Given a constraint, return the type of constraint it is for this target.
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,...
bool shallExtractConstSplatVectorElementToStore(Type *VectorTy, unsigned ElemSizeInBits, unsigned &Index) const override
Return true if the target shall perform extract vector element and store given that the vector is kno...
EVT getOptimalMemOpType(LLVMContext &Context, const MemOp &Op, const AttributeList &FuncAttributes) const override
It returns EVT::Other if the type should be determined using generic target-independent logic.
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override
This method will be invoked for all target nodes and for any target-independent nodes that the target...
SDValue expandVSXStoreForLE(SDNode *N, DAGCombinerInfo &DCI) const
void CollectTargetIntrinsicOperands(const CallInst &I, SmallVectorImpl< SDValue > &Ops, SelectionDAG &DAG) const override
unsigned getStackProbeSize(const MachineFunction &MF) const
PPCTargetLowering(const PPCTargetMachine &TM, const PPCSubtarget &STI)
bool useLoadStackGuardNode(const Module &M) const override
Override to support customized stack guard loading.
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...
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *Fast=nullptr) const override
Is unaligned memory access allowed for the given type, and is it fast relative to software emulation.
bool shouldExpandBuildVectorWithShuffles(EVT VT, unsigned DefinedValues) const override
bool SelectAddressRegImm34(SDValue N, SDValue &Disp, SDValue &Base, SelectionDAG &DAG) const
Similar to the 16-bit case but for instructions that take a 34-bit displacement field (prefixed loads...
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
Register getExceptionSelectorRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception typeid on entry to a la...
bool isJumpTableRelative() const override
Register getExceptionPointerRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception address on entry to an ...
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
LowerOperation - Provide custom lowering hooks for some operations.
PPC::AddrMode SelectOptimalAddrMode(const SDNode *Parent, SDValue N, SDValue &Disp, SDValue &Base, SelectionDAG &DAG, MaybeAlign Align) const
SelectOptimalAddrMode - Based on a node N and it's Parent (a MemSDNode), compute the address flags of...
bool SelectAddressPCRel(SDValue N, SDValue &Base) const
SelectAddressPCRel - Represent the specified address as pc relative to be represented as [pc+imm].
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const override
getSetCCResultType - Return the ISD::SETCC ValueType
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 isLegalICmpImmediate(int64_t Imm) const override
isLegalICmpImmediate - Return true if the specified immediate is legal icmp immediate,...
bool isAccessedAsGotIndirect(SDValue N) const
Align getPrefLoopAlignment(MachineLoop *ML) const override
Return the preferred loop alignment.
bool shouldInlineQuadwordAtomics() const
Instruction * emitLeadingFence(IRBuilderBase &Builder, Instruction *Inst, AtomicOrdering Ord) const override
Inserts in the IR a target-specific intrinsic specifying a fence.
bool isLegalAddImmediate(int64_t Imm) const override
isLegalAddImmediate - Return true if the specified immediate is legal add immediate,...
Common code between 32-bit and 64-bit PowerPC targets.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
This class provides iterator support for SDUse operands that use a specific SDNode.
Represents one node in the SelectionDAG.
ArrayRef< SDUse > ops() const
LLVM_ABI void dump() const
Dump this node, for debugging.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
bool hasOneUse() const
Return true if there is exactly one use of this node.
iterator_range< value_op_iterator > op_values() const
iterator_range< use_iterator > uses()
SDNodeFlags getFlags() const
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
unsigned getNumOperands() const
Return the number of values used by this operation.
const SDValue & getOperand(unsigned Num) const
uint64_t getConstantOperandVal(unsigned Num) const
Helper method returns the integer value of a ConstantSDNode operand.
bool hasNUsesOfValue(unsigned NUses, unsigned Value) const
Return true if there are exactly NUSES uses of the indicated value.
use_iterator use_begin() const
Provide iteration support to walk over all uses of an SDNode.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
iterator_range< user_iterator > users()
user_iterator user_begin() const
Provide iteration support to walk over all users of an SDNode.
static use_iterator use_end()
Represents a use of a SDNode.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node.
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
bool isMachineOpcode() const
TypeSize getValueSizeInBits() const
Returns the size of the value in bits.
const SDValue & getOperand(unsigned i) const
uint64_t getConstantOperandVal(unsigned i) const
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
unsigned getMachineOpcode() const
unsigned getOpcode() const
unsigned getNumOperands() const
static SectionKind getMetadata()
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
LLVM_ABI SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
LLVM_ABI SDValue getStackArgumentTokenFactor(SDValue Chain)
Compute a TokenFactor to force all the incoming stack arguments to be loaded from the stack.
const TargetSubtargetInfo & getSubtarget() const
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, Register Reg, SDValue N)
LLVM_ABI SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
LLVM_ABI SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
LLVM_ABI SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget=false, bool IsOpaque=false)
LLVM_ABI MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s),...
LLVM_ABI SDValue getFreeze(SDValue V)
Return a freeze using the SDLoc of the value operand.
LLVM_ABI SDValue makeEquivalentMemoryOrdering(SDValue OldChain, SDValue NewMemOpChain)
If an existing load has uses of its chain, create a token factor node with that chain and the new mem...
LLVM_ABI SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, bool isTarget=false)
Create a ConstantFPSDNode wrapping a constant value.
LLVM_ABI SDValue getRegister(Register Reg, EVT VT)
LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), 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,...
LLVM_ABI SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags Flags=MachineMemOperand::MOLoad|MachineMemOperand::MOStore, LocationSize Size=LocationSize::precise(0), const AAMDNodes &AAInfo=AAMDNodes())
Creates a MemIntrinsicNode that may produce a result and takes a list of operands.
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false, SDNodeFlags Flags={})
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
LLVM_ABI SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVol, bool AlwaysInline, const CallInst *CI, std::optional< bool > OverrideTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo=AAMDNodes(), BatchAAResults *BatchAA=nullptr)
LLVM_ABI Align getEVTAlign(EVT MemoryVT) const
Compute the default alignment value for the given type.
void addNoMergeSiteInfo(const SDNode *Node, bool NoMerge)
Set NoMergeSiteInfo to be associated with Node if NoMerge is true.
LLVM_ABI SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a bitwise NOT operation as (XOR Val, -1).
const TargetLowering & getTargetLoweringInfo() const
static constexpr unsigned MaxRecursionDepth
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags=0)
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, SDValue InGlue, const SDLoc &DL)
Return a new CALLSEQ_END node, which always must have a glue result (to ensure it's not CSE'd).
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
LLVM_ABI bool isSplatValue(SDValue V, const APInt &DemandedElts, APInt &UndefElts, unsigned Depth=0) const
Test whether V has a splatted value for all the demanded elements.
LLVM_ABI SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type.
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, Register Reg, EVT VT)
SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS, SDNodeFlags Flags=SDNodeFlags())
Helper function to make it easier to build Select's if you just have operands and don't want to check...
const DataLayout & getDataLayout() const
SDValue getTargetFrameIndex(int FI, EVT VT)
LLVM_ABI SDValue getTokenFactor(const SDLoc &DL, SmallVectorImpl< SDValue > &Vals)
Creates a new TokenFactor containing Vals.
LLVM_ABI bool areNonVolatileConsecutiveLoads(LoadSDNode *LD, LoadSDNode *Base, unsigned Bytes, int Dist) const
Return true if loads are next to each other and can be merged.
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
SDValue getSignedTargetConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
LLVM_ABI SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
LLVM_ABI SDValue getMDNode(const MDNode *MD)
Return an MDNodeSDNode which holds an MDNode.
LLVM_ABI void ReplaceAllUsesWith(SDValue From, SDValue To)
Modify anything using 'From' to use 'To' instead.
LLVM_ABI SDValue getCommutedVectorShuffle(const ShuffleVectorSDNode &SV)
Returns an ISD::VECTOR_SHUFFLE node semantically equivalent to the shuffle node in input but with swa...
LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
LLVM_ABI SDValue getSignedConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
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 ...
SDValue getSelectCC(const SDLoc &DL, SDValue LHS, SDValue RHS, SDValue True, SDValue False, ISD::CondCode Cond, SDNodeFlags Flags=SDNodeFlags())
Helper function to make it easier to build SelectCC's if you just have an ISD::CondCode instead of an...
LLVM_ABI SDValue getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign-extending or trunca...
LLVM_ABI SDValue getBoolExtOrTrunc(SDValue Op, const SDLoc &SL, EVT VT, EVT OpVT)
Convert Op, which must be of integer type, to the integer type VT, by using an extension appropriate ...
LLVM_ABI SDValue getExternalSymbol(const char *Sym, EVT VT)
const TargetMachine & getTarget() const
LLVM_ABI 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...
LLVM_ABI SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI SDValue getValueType(EVT)
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
LLVM_ABI unsigned ComputeNumSignBits(SDValue Op, unsigned Depth=0) const
Return the number of times the sign bit of the register is replicated into the other bits.
LLVM_ABI SDValue getBoolConstant(bool V, const SDLoc &DL, EVT VT, EVT OpVT)
Create a true or false constant of type VT using the target's BooleanContent for type OpVT.
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned TargetFlags=0)
LLVM_ABI bool isBaseWithConstantOffset(SDValue Op) const
Return true if the specified operand is an ISD::ADD with a ConstantSDNode on the right-hand side,...
LLVM_ABI SDValue getVectorIdxConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.getNode() alone.
MachineFunction & getMachineFunction() const
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op)
Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all elements.
LLVM_ABI SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
LLVM_ABI KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
LLVM_ABI SDValue getRegisterMask(const uint32_t *RegMask)
LLVM_ABI SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
LLVM_ABI SDValue getCondCode(ISD::CondCode Cond)
LLVM_ABI bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, TypeSize Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object.
LLVMContext * getContext() const
LLVM_ABI SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
LLVM_ABI SDValue getMCSymbol(MCSymbol *Sym, EVT VT)
LLVM_ABI SDValue CreateStackTemporary(TypeSize Bytes, Align Alignment)
Create a stack temporary based on the size in bytes and the alignment.
SDValue getTargetConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offset=0, unsigned TargetFlags=0)
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
LLVM_ABI std::pair< SDValue, SDValue > SplitScalar(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HiVT)
Split the scalar node with EXTRACT_ELEMENT using the provided VTs and return the low/high part.
LLVM_ABI SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
int getMaskElt(unsigned Idx) const
ArrayRef< int > getMask() const
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class is used to represent ISD::STORE nodes.
const SDValue & getBasePtr() const
const SDValue & getValue() const
StringRef - Represent a constant reference to a string, i.e.
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Class to represent struct types.
Information about stack frame layout on the target.
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
TargetInstrInfo - Interface to description of machine instruction set.
Provides information about what library functions are available for the current target.
void setBooleanVectorContents(BooleanContent Ty)
Specify how the target extends the result of a vector boolean value from a vector of i1 to a wider ty...
void setOperationAction(unsigned Op, MVT VT, LegalizeAction Action)
Indicate that the specified operation does not work with the specified type and indicate what to do a...
bool PredictableSelectIsExpensive
Tells the code generator that select is more expensive than a branch if the branch is usually predict...
virtual bool isShuffleMaskLegal(ArrayRef< int >, EVT) const
Targets can use this to indicate that they only support some VECTOR_SHUFFLE operations,...
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
virtual bool shouldExpandBuildVectorWithShuffles(EVT, unsigned DefinedValues) const
void setMinimumBitTestCmps(unsigned Val)
Set the minimum of largest of number of comparisons to generate BitTest.
unsigned MaxStoresPerMemcpyOptSize
Likewise for functions with the OptSize attribute.
MachineBasicBlock * emitPatchPoint(MachineInstr &MI, MachineBasicBlock *MBB) const
Replace/modify any TargetFrameIndex operands with a targte-dependent sequence of memory operands that...
virtual const TargetRegisterClass * getRegClassFor(MVT VT, bool isDivergent=false) const
Return the register class that should be used for the specified value type.
virtual AtomicExpansionKind shouldExpandAtomicRMWInIR(const AtomicRMWInst *RMW) const
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
void setMinStackArgumentAlignment(Align Alignment)
Set the minimum stack alignment of an argument.
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...
const TargetMachine & getTargetMachine() const
unsigned MaxLoadsPerMemcmp
Specify maximum number of load instructions per memcmp call.
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...
void setIndexedLoadAction(ArrayRef< unsigned > IdxModes, MVT VT, LegalizeAction Action)
Indicate that the specified indexed load does or does not work with the specified type and indicate w...
void setPrefLoopAlignment(Align Alignment)
Set the target's preferred loop alignment.
void setMaxAtomicSizeInBitsSupported(unsigned SizeInBits)
Set the maximum atomic operation size supported by the backend.
Sched::Preference getSchedulingPreference() const
Return target scheduling preference.
void setMinFunctionAlignment(Align Alignment)
Set the target's minimum function alignment.
bool isOperationCustom(unsigned Op, EVT VT) const
Return true if the operation uses custom lowering, regardless of whether the type is legal or not.
unsigned MaxStoresPerMemsetOptSize
Likewise for functions with the OptSize attribute.
bool hasBigEndianPartOrdering(EVT VT, const DataLayout &DL) const
When splitting a value of the specified type into parts, does the Lo or Hi part come first?
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL) const
Returns the type for the shift amount of a shift opcode.
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
unsigned MaxStoresPerMemmove
Specify maximum number of store instructions per memmove call.
virtual Align getPrefLoopAlignment(MachineLoop *ML=nullptr) const
Return the preferred loop alignment.
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose.
unsigned MaxStoresPerMemmoveOptSize
Likewise for functions with the OptSize attribute.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
void setIndexedStoreAction(ArrayRef< unsigned > IdxModes, MVT VT, LegalizeAction Action)
Indicate that the specified indexed store does or does not work with the specified type and indicate ...
virtual bool isJumpTableRelative() const
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
void setPrefFunctionAlignment(Align Alignment)
Set the target's preferred function alignment.
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
unsigned MaxStoresPerMemset
Specify maximum number of store instructions per memset call.
void setMinimumJumpTableEntries(unsigned Val)
Indicate the minimum number of blocks to generate jump tables.
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
@ ZeroOrOneBooleanContent
@ ZeroOrNegativeOneBooleanContent
bool isOperationLegalOrCustom(unsigned Op, EVT VT, bool LegalOnly=false) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
unsigned MaxLoadsPerMemcmpOptSize
Likewise for functions with the OptSize attribute.
void setMinCmpXchgSizeInBits(unsigned SizeInBits)
Sets the minimum cmpxchg or ll/sc size supported by the backend.
void setStackPointerRegisterToSaveRestore(Register R)
If set to a physical register, this specifies the register that llvm.savestack/llvm....
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/...
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
void setCondCodeAction(ArrayRef< ISD::CondCode > CCs, MVT VT, LegalizeAction Action)
Indicate that the specified condition code is or isn't supported on the target and indicate what to d...
void setTargetDAGCombine(ArrayRef< ISD::NodeType > NTs)
Targets should invoke this method for each target independent node that they want to provide a custom...
void setLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified load with extension does not work with the specified type and indicate wh...
unsigned GatherAllAliasesMaxDepth
Depth that GatherAllAliases should continue looking for chain dependencies when trying to find a more...
NegatibleCost
Enum that specifies when a float negation is beneficial.
virtual bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const
Returns true if arguments should be sign-extended in lib calls.
std::vector< ArgListEntry > ArgListTy
unsigned MaxStoresPerMemcpy
Specify maximum number of store instructions per memcpy call.
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
void setJumpIsExpensive(bool isExpensive=true)
Tells the code generator not to expand logic operations on comparison predicates into separate sequen...
virtual MCSymbol * getFunctionEntryPointSymbol(const GlobalValue *Func, const TargetMachine &TM) const
If supported, return the function entry point symbol.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
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,...
SDValue lowerCmpEqZeroToCtlzSrl(SDValue Op, SelectionDAG &DAG) const
void softenSetCCOperands(SelectionDAG &DAG, EVT VT, SDValue &NewLHS, SDValue &NewRHS, ISD::CondCode &CCCode, const SDLoc &DL, const SDValue OldLHS, const SDValue OldRHS) const
Soften the operands of a comparison.
SDValue getCheaperNegatedExpression(SDValue Op, SelectionDAG &DAG, bool LegalOps, bool OptForSize, unsigned Depth=0) const
This is the helper function to return the newly negated expression only when the cost is cheaper.
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
virtual SDValue LowerToTLSEmulatedModel(const GlobalAddressSDNode *GA, SelectionDAG &DAG) const
Lower TLS global address SDNode for target independent emulated TLS model.
std::pair< SDValue, SDValue > LowerCallTo(CallLoweringInfo &CLI) const
This function lowers an abstract call to a function into an actual call.
bool isPositionIndependent() const
virtual SDValue getNegatedExpression(SDValue Op, SelectionDAG &DAG, bool LegalOps, bool OptForSize, NegatibleCost &Cost, unsigned Depth=0) const
Return the newly negated expression if the cost is not expensive and set the cost in Cost to indicate...
virtual ConstraintWeight getSingleConstraintMatchWeight(AsmOperandInfo &info, const char *constraint) const
Examine constraint string and operand type and determine a weight value.
virtual SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG) const
Returns relocation base for the given PIC jumptable.
virtual std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const
Given a physical register constraint (e.g.
TargetLowering(const TargetLowering &)=delete
bool isInTailCallPosition(SelectionDAG &DAG, SDNode *Node, SDValue &Chain) const
Check whether a given call node is in tail position within its function.
virtual SDValue getSqrtResultForDenormInput(SDValue Operand, SelectionDAG &DAG) const
Return a target-dependent result if the input operand is not suitable for use with a square root esti...
virtual bool useLoadStackGuardNode(const Module &M) const
If this function returns true, SelectionDAGBuilder emits a LOAD_STACK_GUARD node when it is lowering ...
virtual unsigned combineRepeatedFPDivisors() const
Indicate whether this target prefers to combine FDIVs with the same divisor.
virtual void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const
Lower the specified operand into the Ops vector.
virtual SDValue getSqrtInputTest(SDValue Operand, SelectionDAG &DAG, const DenormalMode &Mode, SDNodeFlags Flags={}) const
Return a target-dependent comparison result if the input operand is suitable for use with a square ro...
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.
virtual unsigned getJumpTableEncoding() const
Return the entry encoding for a jump table in the current function.
std::pair< SDValue, SDValue > makeLibCall(SelectionDAG &DAG, RTLIB::LibcallImpl LibcallImpl, EVT RetVT, ArrayRef< SDValue > Ops, MakeLibCallOptions CallOptions, const SDLoc &dl, SDValue Chain=SDValue()) const
Returns a pair of (return value, chain).
Primary interface to the complete machine description for the target machine.
TLSModel::Model getTLSModel(const GlobalValue *GV) const
Returns the TLS model which should be used for the given global variable.
const STC & getSubtarget(const Function &F) const
This method returns a pointer to the specified type of TargetSubtargetInfo.
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
virtual TargetLoweringObjectFile * getObjFileLowering() const
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
bool shouldAssumeDSOLocal(const GlobalValue *GV) const
CodeModel::Model getCodeModel() const
Returns the code model.
bool getFunctionSections() const
Return true if functions should be emitted into their own section, corresponding to -ffunction-sectio...
unsigned PPCGenScalarMASSEntries
Enables scalar MASS conversions.
unsigned GuaranteedTailCallOpt
GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is specified on the commandline.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
LLVM_ABI bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty.
bool isVectorTy() const
True if this is an instance of VectorType.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
@ FloatTyID
32-bit floating point type
@ DoubleTyID
64-bit floating point type
@ FP128TyID
128-bit floating point type (112-bit significand)
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool isFunctionTy() const
True if this is an instance of FunctionType.
bool isIntegerTy() const
True if this is an instance of IntegerType.
A Use represents the edge between a Value definition and its users.
User * getUser() const
Returns the User that contains this Use.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
bool hasOneUse() const
Return true if there is exactly one use of this value.
const ParentTy * getParent() const
self_iterator getIterator()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ Cold
Attempts to make code in the caller as efficient as possible under the assumption that the call is no...
@ Fast
Attempts to make calls as fast as possible (e.g.
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI bool isConstantSplatVectorAllOnes(const SDNode *N, bool BuildVectorOnly=false)
Return true if the specified node is a BUILD_VECTOR or SPLAT_VECTOR where all of the elements are ~0 ...
bool isNON_EXTLoad(const SDNode *N)
Returns true if the specified node is a non-extending load.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ MERGE_VALUES
MERGE_VALUES - This node takes multiple discrete operands and returns them all as its individual resu...
@ STACKRESTORE
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain.
@ STACKSAVE
STACKSAVE - STACKSAVE has one operand, an input chain.
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
@ DELETED_NODE
DELETED_NODE - This is an illegal value that is used to catch errors.
@ EH_SJLJ_LONGJMP
OUTCHAIN = EH_SJLJ_LONGJMP(INCHAIN, buffer) This corresponds to the eh.sjlj.longjmp intrinsic.
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
@ BSWAP
Byte Swap and Counting operators.
@ VAEND
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE.
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, val, ptr) This corresponds to "store atomic" instruction.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ FMA
FMA - Perform a * b + c with no intermediate rounding step.
@ INTRINSIC_VOID
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ FADD
Simple binary floating point operators.
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ INIT_TRAMPOLINE
INIT_TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ STRICT_FSQRT
Constrained versions of libm-equivalent floating point intrinsics.
@ SET_ROUNDING
Set rounding mode.
@ SIGN_EXTEND
Conversion operators.
@ AVGCEILS
AVGCEILS/AVGCEILU - Rounding averaging add - Add two integers using an integer of type i[N+2],...
@ SCALAR_TO_VECTOR
SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a scalar value into element 0 of the...
@ BR
Control flow instructions. These all have token chains.
@ PREFETCH
PREFETCH - This corresponds to a prefetch intrinsic.
@ FSINCOS
FSINCOS - Compute both fsin and fcos as a single operation.
@ FNEG
Perform various unary floating-point operations inspired by libm.
@ BR_CC
BR_CC - Conditional branch.
@ SSUBO
Same for subtraction.
@ BR_JT
BR_JT - Jumptable branch.
@ FCANONICALIZE
Returns platform specific canonical encoding of a floating point number.
@ IS_FPCLASS
Performs a check of floating point class property, defined by IEEE-754.
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ ATOMIC_LOAD
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
@ VACOPY
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer,...
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ TargetGlobalAddress
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
@ GET_ROUNDING
Returns current rounding mode: -1 Undefined 0 Round to 0 1 Round to nearest, ties to even 2 Round to ...
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ FMINNUM_IEEE
FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimumNumber or maximumNumber on two values,...
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ ATOMIC_CMP_SWAP
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo,...
@ FMINNUM
FMINNUM/FMAXNUM - Perform floating-point minimum maximum on two values, following IEEE-754 definition...
@ DYNAMIC_STACKALLOC
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary.
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ STRICT_SINT_TO_FP
STRICT_[US]INT_TO_FP - Convert a signed or unsigned integer to a floating point value.
@ INLINEASM_BR
INLINEASM_BR - Branching version of inline asm. Used by asm-goto.
@ EH_DWARF_CFA
EH_DWARF_CFA - This node represents the pointer to the DWARF Canonical Frame Address (CFA),...
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
@ STRICT_FP_ROUND
X = STRICT_FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision ...
@ STRICT_FP_TO_SINT
STRICT_FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
@ STRICT_FP_EXTEND
X = STRICT_FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ TRAP
TRAP - Trapping instruction.
@ INTRINSIC_WO_CHAIN
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
@ STRICT_FADD
Constrained versions of the binary floating point operators.
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ FP_ROUND
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
@ INLINEASM
INLINEASM - Represents an inline asm block.
@ EH_SJLJ_SETJMP
RESULT, OUTCHAIN = EH_SJLJ_SETJMP(INCHAIN, buffer) This corresponds to the eh.sjlj....
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ VAARG
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
@ BRCOND
BRCOND - Conditional branch.
@ SHL_PARTS
SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded integer shift operations.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ FCOPYSIGN
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ CALLSEQ_START
CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of a call sequence,...
@ GET_DYNAMIC_AREA_OFFSET
GET_DYNAMIC_AREA_OFFSET - get offset from native SP to the address of the most recent dynamic alloca.
@ ABDS
ABDS/ABDU - Absolute difference - Return the absolute difference between two numbers interpreted as s...
@ ADJUST_TRAMPOLINE
ADJUST_TRAMPOLINE - This corresponds to the adjust_trampoline intrinsic.
@ INTRINSIC_W_CHAIN
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
bool isZEXTLoad(const SDNode *N)
Returns true if the specified node is a ZEXTLOAD.
bool isUNINDEXEDLoad(const SDNode *N)
Returns true if the specified node is an unindexed load.
bool isEXTLoad(const SDNode *N)
Returns true if the specified node is a EXTLOAD.
LLVM_ABI 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 isSignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs a signed comparison when used with integer o...
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
bool isSEXTLoad(const SDNode *N)
Returns true if the specified node is a SEXTLOAD.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
bool isUnsignedIntSetCC(CondCode Code)
Return true if this is a setcc instruction that performs an unsigned comparison when used with intege...
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > OverloadTys={})
Look up the Function declaration of the intrinsic id in the Module M.
@ Bitcast
Perform the operation on a different, but equivalently sized type.
@ MO_TLSLDM_FLAG
MO_TLSLDM_FLAG - on AIX the ML relocation type is only valid for a reference to a TOC symbol from the...
@ MO_PIC_LO_FLAG
MO_PIC_LO_FLAG = MO_PIC_FLAG | MO_LO.
@ MO_TPREL_PCREL_FLAG
MO_TPREL_PCREL_FLAG = MO_PCREL_FLAG | MO_TPREL_FLAG.
@ MO_GOT_TPREL_PCREL_FLAG
MO_GOT_TPREL_PCREL_FLAG - A combintaion of flags, if these bits are set they should produce the reloc...
@ MO_GOT_PCREL_FLAG
MO_GOT_PCREL_FLAG = MO_PCREL_FLAG | MO_GOT_FLAG.
@ MO_TLSGDM_FLAG
MO_TLSGDM_FLAG - If this bit is set the symbol reference is relative to the region handle of TLS Gene...
@ MO_PCREL_FLAG
MO_PCREL_FLAG - If this bit is set, the symbol reference is relative to the current instruction addre...
@ MO_TLSLD_FLAG
MO_TLSLD_FLAG - If this bit is set the symbol reference is relative to TLS Local Dynamic model.
@ MO_TLS_PCREL_FLAG
MO_TPREL_PCREL_FLAG = MO_PCREL_FLAG | MO_TLS.
@ MO_PLT
On PPC, the 12 bits are not enough for all target operand flags.
@ MO_TLS
Symbol for VK_TLS fixup attached to an ADD instruction.
@ MO_TPREL_FLAG
MO_TPREL_FLAG - If this bit is set, the symbol reference is relative to the thread pointer and the sy...
@ MO_LO
MO_LO, MO_HA - lo16(symbol) and ha16(symbol)
@ MO_GOT_TLSLD_PCREL_FLAG
MO_GOT_TLSLD_PCREL_FLAG - A combintaion of flags, if these bits are set they should produce the reloc...
@ MO_PIC_HA_FLAG
MO_PIC_HA_FLAG = MO_PIC_FLAG | MO_HA.
@ MO_TLSGD_FLAG
MO_TLSGD_FLAG - If this bit is set the symbol reference is relative to TLS General Dynamic model for ...
@ MO_GOT_TLSGD_PCREL_FLAG
MO_GOT_TLSGD_PCREL_FLAG - A combintaion of flags, if these bits are set they should produce the reloc...
@ MO_PIC_FLAG
MO_PIC_FLAG - If this bit is set, the symbol reference is relative to the function's picbase,...
@ MFOCRF
R32 = MFOCRF(CRREG, INFLAG) - Represents the MFOCRF instruction.
@ VADD_SPLAT
VRRC = VADD_SPLAT Elt, EltSize - Temporary node to be expanded during instruction selection to optimi...
@ PPC32_PICGOT
GPRC = address of GLOBAL_OFFSET_TABLE.
@ GlobalBaseReg
The result of the mflr at function entry, used for PIC code.
@ SRA_ADDZE
The combination of sra[wd]i and addze used to implemented signed integer division by a power of 2.
Define some predicates that are used for node matching.
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
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...
bool isXXBRDShuffleMask(ShuffleVectorSDNode *N)
isXXBRDShuffleMask - Return true if this is a shuffle mask suitable for a XXBRD instruction.
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 ...
bool isVPKUDUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind, SelectionDAG &DAG)
isVPKUDUMShuffleMask - Return true if this is the shuffle mask for a VPKUDUM instruction.
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...
bool isXXBRQShuffleMask(ShuffleVectorSDNode *N)
isXXBRQShuffleMask - Return true if this is a shuffle mask suitable for a XXBRQ instruction.
bool isXXBRWShuffleMask(ShuffleVectorSDNode *N)
isXXBRWShuffleMask - Return true if this is a shuffle mask suitable for a XXBRW 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 isXXBRHShuffleMask(ShuffleVectorSDNode *N)
isXXBRHShuffleMask - Return true if this is a shuffle mask suitable for a XXBRH instruction.
unsigned getSplatIdxForPPCMnemonics(SDNode *N, unsigned EltSize, SelectionDAG &DAG)
getSplatIdxForPPCMnemonics - Return the splat index as a value that is appropriate for PPC mnemonics ...
bool isXXSLDWIShuffleMask(ShuffleVectorSDNode *N, unsigned &ShiftElts, bool &Swap, bool IsLE)
isXXSLDWIShuffleMask - Return true if this is a shuffle mask suitable for a XXSLDWI instruction.
FastISel * createFastISel(FunctionLoweringInfo &FuncInfo, const TargetLibraryInfo *LibInfo, const LibcallLoweringInfo *LibcallLowering)
int isVSLDOIShuffleMask(SDNode *N, unsigned ShuffleKind, SelectionDAG &DAG)
isVSLDOIShuffleMask - If this is a vsldoi shuffle mask, return the shift amount, otherwise return -1.
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 ...
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...
bool isSplatShuffleMask(ShuffleVectorSDNode *N, unsigned EltSize)
isSplatShuffleMask - Return true if the specified VECTOR_SHUFFLE operand specifies a splat of a singl...
bool isVPKUWUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind, SelectionDAG &DAG)
isVPKUWUMShuffleMask - Return true if this is the shuffle mask for a VPKUWUM instruction.
bool isVPKUHUMShuffleMask(ShuffleVectorSDNode *N, unsigned ShuffleKind, SelectionDAG &DAG)
isVPKUHUMShuffleMask - Return true if this is the shuffle mask for a VPKUHUM instruction.
Invariant opcodes: All instruction sets have these as their low opcodes.
@ XTY_ER
External reference.
initializer< Ty > init(const Ty &Val)
constexpr uint64_t PointerSize
aarch64 pointer size.
@ User
could "use" a pointer
NodeAddr< UseNode * > Use
NodeAddr< NodeBase * > Node
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
static bool isIndirectCall(const MachineInstr &MI)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
bool checkConvertToNonDenormSingle(APFloat &ArgAPFloat)
LLVM_ABI void GetReturnInfo(CallingConv::ID CC, Type *ReturnType, AttributeList attr, SmallVectorImpl< ISD::OutputArg > &Outs, const TargetLowering &TLI, const DataLayout &DL)
Given an LLVM IR type and return type attributes, compute the return value EVTs and flags,...
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
LLVM_ABI SDValue peekThroughBitcasts(SDValue V)
Return the non-bitcasted source operand of V if it exists.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change.
bool isAligned(Align Lhs, uint64_t SizeInBytes)
Checks that SizeInBytes is a multiple of the alignment.
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,...
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
static bool isRunOfOnes64(uint64_t Val, unsigned &MB, unsigned &ME)
bool isa_and_nonnull(const Y &Val)
bool RetCC_PPC(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
bool CC_PPC64_ELF(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
unsigned M1(unsigned Val)
bool isReleaseOrStronger(AtomicOrdering AO)
auto dyn_cast_or_null(const Y &Val)
constexpr bool has_single_bit(T Value) noexcept
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
bool convertToNonDenormSingle(APInt &ArgAPInt)
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
bool CC_PPC32_SVR4_ByVal(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
constexpr uint32_t Hi_32(uint64_t Value)
Return the high 32 bits of a 64 bit value.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
bool CC_PPC32_SVR4(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
constexpr RegState getDefRegState(bool B)
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
bool RetCC_PPC_Cold(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
constexpr uint32_t Lo_32(uint64_t Value)
Return the low 32 bits of a 64 bit value.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
@ Success
The lock was released successfully.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
AtomicOrdering
Atomic ordering for LLVM's memory model.
bool isIntS34Immediate(SDNode *N, int64_t &Imm)
isIntS34Immediate - This method tests if value of node given can be accurately represented as a sign ...
To bit_cast(const From &from) noexcept
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
@ And
Bitwise or logical AND of integers.
@ Sub
Subtraction of integers.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
DWARFExpression::Operation Op
bool isPhysRegUsedAfter(Register Reg, MachineBasicBlock::iterator MBI)
Check if physical register Reg is used after MBI.
unsigned M0(unsigned Val)
ArrayRef(const T &OneElt) -> ArrayRef< T >
LLVM_ABI ConstantSDNode * isConstOrConstSplat(SDValue N, bool AllowUndefs=false, bool AllowTruncation=false)
Returns the SDNode if it is a constant splat BuildVector or constant int.
bool isAcquireOrStronger(AtomicOrdering AO)
constexpr bool isShiftedInt(int64_t x)
Checks if a signed integer is an N bit number shifted left by S.
constexpr int32_t SignExtend32(uint32_t X)
Sign-extend the number in the bottom B bits of X to a 32-bit integer.
constexpr unsigned BitWidth
bool CC_PPC32_SVR4_VarArg(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
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 isRunOfOnes(unsigned Val, unsigned &MB, unsigned &ME)
Returns true iff Val consists of one contiguous run of 1s with any number of 0s on either side.
@ Increment
Incrementally increasing token ID.
@ Enabled
Convert any .debug_str_offsets tables to DWARF64 if needed.
T bit_floor(T Value)
Returns the largest integral power of two no greater than Value if Value is nonzero.
constexpr bool isShiftedUInt(uint64_t x)
Checks if a unsigned integer is an N bit number shifted left by S.
LLVM_ABI bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
static const unsigned PerfectShuffleTable[6561+1]
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This is used by foldLoadsRecursive() to capture a Root Load node which is of type or(load,...
This struct is a compact representation of a valid (non-zero power of two) alignment.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
Represent subnormal handling kind for floating point instruction inputs and outputs.
EVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
uint64_t getScalarSizeInBits() const
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
uint64_t getFixedSizeInBits() const
Return the size of the specified fixed width value type in bits.
LLVM_ABI std::string getEVTString() const
This function returns value type as a string, e.g. "i32".
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
LLVM_ABI Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
bool isExtended() const
Test if the given EVT is extended (as opposed to being simple).
bool isScalarInteger() const
Return true if this is an integer, but not a vector.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
EVT getHalfNumVectorElementsVT(LLVMContext &Context) const
bool isInteger() const
Return true if this is an integer or a vector integer type.
unsigned getByValSize() const
void setByValSize(unsigned S)
Align getNonZeroByValAlign() const
OutputArg - This struct carries flags and a value for a single outgoing (actual) argument or outgoing...
bool isConstant() const
Returns true if we know the value of all bits.
void resetAll()
Resets the known state of all bits.
const APInt & getConstant() const
Returns the value when all bits have a known value.
This class contains a discriminated union of information about pointers in memory operands,...
static LLVM_ABI MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset, uint8_t ID=0)
Stack pointer relative access.
MachinePointerInfo getWithOffset(int64_t O) const
static LLVM_ABI MachinePointerInfo getGOT(MachineFunction &MF)
Return a MachinePointerInfo record that refers to a GOT entry.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Structure that collects some common arguments that get passed around between the functions for call l...
const CallingConv::ID CallConv
These are IR-level optimization flags that may be propagated to SDNodes.
void setNoFPExcept(bool b)
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg + ScalableOffset*...
This contains information for each constraint that we are lowering.
This structure contains all information that is necessary for lowering calls.
CallLoweringInfo & setIsPostTypeLegalization(bool Value=true)
CallLoweringInfo & setLibCallee(CallingConv::ID CC, Type *ResultType, SDValue Target, ArgListTy &&ArgsList)
SmallVector< ISD::InputArg, 32 > Ins
CallLoweringInfo & setZExtResult(bool Value=true)
CallLoweringInfo & setDebugLoc(const SDLoc &dl)
CallLoweringInfo & setTailCall(bool Value=true)
CallLoweringInfo & setSExtResult(bool Value=true)
SmallVector< ISD::OutputArg, 32 > Outs
SmallVector< SDValue, 32 > OutVals
CallLoweringInfo & setChain(SDValue InChain)
bool isBeforeLegalizeOps() const
bool isAfterLegalizeDAG() const
LLVM_ABI void AddToWorklist(SDNode *N)
bool isBeforeLegalize() const
LLVM_ABI SDValue CombineTo(SDNode *N, ArrayRef< SDValue > To, bool AddTo=true)
This structure is used to pass arguments to makeLibCall function.