71#include "llvm/IR/IntrinsicsPowerPC.h"
106#define DEBUG_TYPE "ppc-lowering"
109 "disable-p10-store-forward",
133 cl::desc(
"disable vector permute decomposition"),
137 "disable-auto-paired-vec-st",
138 cl::desc(
"disable automatically generated 32byte paired vector stores"),
143 cl::desc(
"Set minimum number of entries to use a jump table on PPC"));
147 cl::desc(
"max depth when checking alias info in GatherAllAliases()"));
151 cl::desc(
"Set inclusive limit count of TLS local-dynamic access(es) in a "
152 "function to use initial-exec"));
157 "Number of shuffles lowered to a VPERM or XXPERM");
158STATISTIC(NumDynamicAllocaProbed,
"Number of dynamic stack allocation probed");
181 initializeAddrModeMap();
184 bool isPPC64 = Subtarget.
isPPC64();
193 if (!Subtarget.hasEFPU2())
218 if (Subtarget.isISA3_0()) {
248 if (!Subtarget.hasSPE()) {
256 const MVT ScalarIntVTs[] = { MVT::i32, MVT::i64 };
257 for (
MVT VT : ScalarIntVTs) {
264 if (Subtarget.useCRBits()) {
267 if (isPPC64 || Subtarget.hasFPCVT()) {
270 isPPC64 ? MVT::i64 : MVT::i32);
273 isPPC64 ? MVT::i64 : MVT::i32);
277 isPPC64 ? MVT::i64 : MVT::i32);
280 isPPC64 ? MVT::i64 : MVT::i32);
284 isPPC64 ? MVT::i64 : MVT::i32);
287 isPPC64 ? MVT::i64 : MVT::i32);
291 isPPC64 ? MVT::i64 : MVT::i32);
294 isPPC64 ? MVT::i64 : MVT::i32);
341 if (Subtarget.isISA3_0()) {
376 if (!Subtarget.hasSPE()) {
381 if (Subtarget.hasVSX()) {
386 if (Subtarget.hasFSQRT()) {
391 if (Subtarget.hasFPRND()) {
432 if (Subtarget.hasSPE()) {
440 if (Subtarget.hasSPE())
446 if (!Subtarget.hasFSQRT() &&
447 !(TM.Options.UnsafeFPMath && Subtarget.hasFRSQRTE() &&
451 if (!Subtarget.hasFSQRT() &&
452 !(TM.Options.UnsafeFPMath && Subtarget.hasFRSQRTES() &&
453 Subtarget.hasFRES()))
456 if (Subtarget.hasFCPSGN()) {
464 if (Subtarget.hasFPRND()) {
478 if (Subtarget.isISA3_1()) {
489 if (Subtarget.isISA3_0()) {
509 if (!Subtarget.useCRBits()) {
522 if (!Subtarget.useCRBits())
525 if (Subtarget.hasFPU()) {
536 if (!Subtarget.useCRBits())
541 if (Subtarget.hasSPE()) {
565 if (Subtarget.hasDirectMove() && isPPC64) {
570 if (TM.Options.UnsafeFPMath) {
673 if (Subtarget.hasSPE()) {
695 if (Subtarget.has64BitSupport()) {
710 if (Subtarget.hasLFIWAX() || Subtarget.
isPPC64()) {
716 if (Subtarget.hasSPE()) {
726 if (Subtarget.hasFPCVT()) {
727 if (Subtarget.has64BitSupport()) {
748 if (Subtarget.use64BitRegs()) {
766 if (Subtarget.has64BitSupport()) {
773 if (Subtarget.hasVSX()) {
780 if (Subtarget.hasAltivec()) {
781 for (
MVT VT : { MVT::v16i8, MVT::v8i16, MVT::v4i32 }) {
796 if (VT.getSizeInBits() <= 128 && VT.getScalarSizeInBits() <= 64) {
809 if (Subtarget.hasVSX()) {
815 if (Subtarget.hasP8Altivec() && (VT.SimpleTy != MVT::v1i128)) {
825 if (Subtarget.hasP9Altivec() && (VT.SimpleTy != MVT::v1i128))
899 if (!Subtarget.hasP8Vector()) {
941 if (Subtarget.hasAltivec())
942 for (
auto VT : {MVT::v4i32, MVT::v8i16, MVT::v16i8})
945 if (Subtarget.hasP8Altivec())
956 if (Subtarget.hasVSX()) {
962 if (Subtarget.hasP8Altivec())
967 if (Subtarget.isISA3_1()) {
1013 if (Subtarget.hasVSX()) {
1016 if (Subtarget.hasP8Vector()) {
1020 if (Subtarget.hasDirectMove() && isPPC64) {
1034 if (TM.Options.UnsafeFPMath) {
1071 if (Subtarget.hasP8Vector())
1080 if (Subtarget.hasP8Altivec()) {
1107 if (Subtarget.isISA3_1())
1210 if (Subtarget.hasP8Altivec()) {
1215 if (Subtarget.hasP9Vector()) {
1220 if (Subtarget.useCRBits()) {
1279 }
else if (Subtarget.hasVSX()) {
1304 for (
MVT VT : {MVT::f32, MVT::f64}) {
1323 if (Subtarget.hasP9Altivec()) {
1324 if (Subtarget.isISA3_1()) {
1347 if (Subtarget.hasP10Vector()) {
1352 if (Subtarget.pairedVectorMemops()) {
1357 if (Subtarget.hasMMA()) {
1358 if (Subtarget.isISAFuture())
1367 if (Subtarget.has64BitSupport())
1370 if (Subtarget.isISA3_1())
1388 if (Subtarget.hasAltivec()) {
1405 if (Subtarget.hasFPCVT())
1408 if (Subtarget.useCRBits())
1417 if (Subtarget.useCRBits()) {
1448 setLibcallName(RTLIB::MEMCPY, isPPC64 ?
"___memmove64" :
"___memmove");
1449 setLibcallName(RTLIB::MEMMOVE, isPPC64 ?
"___memmove64" :
"___memmove");
1450 setLibcallName(RTLIB::MEMSET, isPPC64 ?
"___memset64" :
"___memset");
1451 setLibcallName(RTLIB::BZERO, isPPC64 ?
"___bzero64" :
"___bzero");
1456 if (Subtarget.useCRBits()) {
1562void PPCTargetLowering::initializeAddrModeMap() {
1613 if (MaxAlign == MaxMaxAlign)
1615 if (
VectorType *VTy = dyn_cast<VectorType>(Ty)) {
1616 if (MaxMaxAlign >= 32 &&
1617 VTy->getPrimitiveSizeInBits().getFixedValue() >= 256)
1618 MaxAlign =
Align(32);
1619 else if (VTy->getPrimitiveSizeInBits().getFixedValue() >= 128 &&
1621 MaxAlign =
Align(16);
1622 }
else if (
ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
1625 if (EltAlign > MaxAlign)
1626 MaxAlign = EltAlign;
1627 }
else if (
StructType *STy = dyn_cast<StructType>(Ty)) {
1628 for (
auto *EltTy : STy->elements()) {
1631 if (EltAlign > MaxAlign)
1632 MaxAlign = EltAlign;
1633 if (MaxAlign == MaxMaxAlign)
1646 if (Subtarget.hasAltivec())
1648 return Alignment.
value();
1656 return Subtarget.hasSPE();
1664 Type *VectorTy,
unsigned ElemSizeInBits,
unsigned &
Index)
const {
1665 if (!Subtarget.
isPPC64() || !Subtarget.hasVSX())
1668 if (
auto *VTy = dyn_cast<VectorType>(VectorTy)) {
1669 if (VTy->getScalarType()->isIntegerTy()) {
1671 if (ElemSizeInBits == 32) {
1675 if (ElemSizeInBits == 64) {
1701 return "PPCISD::FTSQRT";
1703 return "PPCISD::FSQRT";
1708 return "PPCISD::XXSPLTI_SP_TO_DP";
1710 return "PPCISD::XXSPLTI32DX";
1714 return "PPCISD::XXPERM";
1734 return "PPCISD::CALL_RM";
1736 return "PPCISD::CALL_NOP_RM";
1738 return "PPCISD::CALL_NOTOC_RM";
1743 return "PPCISD::BCTRL_RM";
1745 return "PPCISD::BCTRL_LOAD_TOC_RM";
1757 return "PPCISD::SCALAR_TO_VECTOR_PERMUTED";
1759 return "PPCISD::ANDI_rec_1_EQ_BIT";
1761 return "PPCISD::ANDI_rec_1_GT_BIT";
1776 return "PPCISD::ST_VSR_SCAL_INT";
1805 return "PPCISD::PADDI_DTPREL";
1821 return "PPCISD::TLS_DYNAMIC_MAT_PCREL_ADDR";
1823 return "PPCISD::TLS_LOCAL_EXEC_MAT_ADDR";
1833 return "PPCISD::STRICT_FADDRTZ";
1835 return "PPCISD::STRICT_FCTIDZ";
1837 return "PPCISD::STRICT_FCTIWZ";
1839 return "PPCISD::STRICT_FCTIDUZ";
1841 return "PPCISD::STRICT_FCTIWUZ";
1843 return "PPCISD::STRICT_FCFID";
1845 return "PPCISD::STRICT_FCFIDU";
1847 return "PPCISD::STRICT_FCFIDS";
1849 return "PPCISD::STRICT_FCFIDUS";
1852 return "PPCISD::STORE_COND";
1860 return Subtarget.useCRBits() ? MVT::i1 : MVT::i32;
1877 return CFP->getValueAPF().isZero();
1881 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(CP->getConstVal()))
1882 return CFP->getValueAPF().isZero();
1890 return Op < 0 ||
Op == Val;
1902 if (ShuffleKind == 0) {
1905 for (
unsigned i = 0; i != 16; ++i)
1908 }
else if (ShuffleKind == 2) {
1911 for (
unsigned i = 0; i != 16; ++i)
1914 }
else if (ShuffleKind == 1) {
1915 unsigned j = IsLE ? 0 : 1;
1916 for (
unsigned i = 0; i != 8; ++i)
1933 if (ShuffleKind == 0) {
1936 for (
unsigned i = 0; i != 16; i += 2)
1940 }
else if (ShuffleKind == 2) {
1943 for (
unsigned i = 0; i != 16; i += 2)
1947 }
else if (ShuffleKind == 1) {
1948 unsigned j = IsLE ? 0 : 2;
1949 for (
unsigned i = 0; i != 8; i += 2)
1970 if (!Subtarget.hasP8Vector())
1974 if (ShuffleKind == 0) {
1977 for (
unsigned i = 0; i != 16; i += 4)
1983 }
else if (ShuffleKind == 2) {
1986 for (
unsigned i = 0; i != 16; i += 4)
1992 }
else if (ShuffleKind == 1) {
1993 unsigned j = IsLE ? 0 : 4;
1994 for (
unsigned i = 0; i != 8; i += 4)
2011 unsigned LHSStart,
unsigned RHSStart) {
2012 if (
N->getValueType(0) != MVT::v16i8)
2014 assert((UnitSize == 1 || UnitSize == 2 || UnitSize == 4) &&
2015 "Unsupported merge size!");
2017 for (
unsigned i = 0; i != 8/UnitSize; ++i)
2018 for (
unsigned j = 0; j != UnitSize; ++j) {
2020 LHSStart+j+i*UnitSize) ||
2022 RHSStart+j+i*UnitSize))
2037 if (ShuffleKind == 1)
2039 else if (ShuffleKind == 2)
2044 if (ShuffleKind == 1)
2046 else if (ShuffleKind == 0)
2062 if (ShuffleKind == 1)
2064 else if (ShuffleKind == 2)
2069 if (ShuffleKind == 1)
2071 else if (ShuffleKind == 0)
2121 unsigned RHSStartValue) {
2122 if (
N->getValueType(0) != MVT::v16i8)
2125 for (
unsigned i = 0; i < 2; ++i)
2126 for (
unsigned j = 0; j < 4; ++j)
2128 i*RHSStartValue+j+IndexOffset) ||
2130 i*RHSStartValue+j+IndexOffset+8))
2152 unsigned indexOffset = CheckEven ? 4 : 0;
2153 if (ShuffleKind == 1)
2155 else if (ShuffleKind == 2)
2161 unsigned indexOffset = CheckEven ? 0 : 4;
2162 if (ShuffleKind == 1)
2164 else if (ShuffleKind == 0)
2180 if (
N->getValueType(0) != MVT::v16i8)
2187 for (i = 0; i != 16 && SVOp->
getMaskElt(i) < 0; ++i)
2190 if (i == 16)
return -1;
2195 if (ShiftAmt < i)
return -1;
2200 if ((ShuffleKind == 0 && !isLE) || (ShuffleKind == 2 && isLE)) {
2202 for (++i; i != 16; ++i)
2205 }
else if (ShuffleKind == 1) {
2207 for (++i; i != 16; ++i)
2214 ShiftAmt = 16 - ShiftAmt;
2223 EVT VT =
N->getValueType(0);
2224 if (VT == MVT::v2i64 || VT == MVT::v2f64)
2225 return EltSize == 8 &&
N->getMaskElt(0) ==
N->getMaskElt(1);
2228 EltSize <= 8 &&
"Can only handle 1,2,4,8 byte element sizes");
2232 if (
N->getMaskElt(0) % EltSize != 0)
2237 unsigned ElementBase =
N->getMaskElt(0);
2240 if (ElementBase >= 16)
2245 for (
unsigned i = 1; i != EltSize; ++i)
2246 if (
N->getMaskElt(i) < 0 ||
N->getMaskElt(i) != (
int)(i+ElementBase))
2249 for (
unsigned i = EltSize, e = 16; i != e; i += EltSize) {
2250 if (
N->getMaskElt(i) < 0)
continue;
2251 for (
unsigned j = 0; j != EltSize; ++j)
2252 if (
N->getMaskElt(i+j) !=
N->getMaskElt(j))
2269 assert((Width == 2 || Width == 4 || Width == 8 || Width == 16) &&
2270 "Unexpected element width.");
2271 assert((StepLen == 1 || StepLen == -1) &&
"Unexpected element width.");
2273 unsigned NumOfElem = 16 / Width;
2274 unsigned MaskVal[16];
2275 for (
unsigned i = 0; i < NumOfElem; ++i) {
2276 MaskVal[0] =
N->getMaskElt(i * Width);
2277 if ((StepLen == 1) && (MaskVal[0] % Width)) {
2279 }
else if ((StepLen == -1) && ((MaskVal[0] + 1) % Width)) {
2283 for (
unsigned int j = 1; j < Width; ++j) {
2284 MaskVal[j] =
N->getMaskElt(i * Width + j);
2285 if (MaskVal[j] != MaskVal[j-1] + StepLen) {
2295 unsigned &InsertAtByte,
bool &Swap,
bool IsLE) {
2300 unsigned M0 =
N->getMaskElt(0) / 4;
2301 unsigned M1 =
N->getMaskElt(4) / 4;
2302 unsigned M2 =
N->getMaskElt(8) / 4;
2303 unsigned M3 =
N->getMaskElt(12) / 4;
2304 unsigned LittleEndianShifts[] = { 2, 1, 0, 3 };
2305 unsigned BigEndianShifts[] = { 3, 0, 1, 2 };
2310 if ((
M0 > 3 &&
M1 == 1 && M2 == 2 && M3 == 3) ||
2311 (
M0 < 4 &&
M1 == 5 && M2 == 6 && M3 == 7)) {
2312 ShiftElts = IsLE ? LittleEndianShifts[
M0 & 0x3] : BigEndianShifts[
M0 & 0x3];
2313 InsertAtByte = IsLE ? 12 : 0;
2318 if ((
M1 > 3 &&
M0 == 0 && M2 == 2 && M3 == 3) ||
2319 (
M1 < 4 &&
M0 == 4 && M2 == 6 && M3 == 7)) {
2320 ShiftElts = IsLE ? LittleEndianShifts[
M1 & 0x3] : BigEndianShifts[
M1 & 0x3];
2321 InsertAtByte = IsLE ? 8 : 4;
2326 if ((M2 > 3 &&
M0 == 0 &&
M1 == 1 && M3 == 3) ||
2327 (M2 < 4 &&
M0 == 4 &&
M1 == 5 && M3 == 7)) {
2328 ShiftElts = IsLE ? LittleEndianShifts[M2 & 0x3] : BigEndianShifts[M2 & 0x3];
2329 InsertAtByte = IsLE ? 4 : 8;
2334 if ((M3 > 3 &&
M0 == 0 &&
M1 == 1 && M2 == 2) ||
2335 (M3 < 4 &&
M0 == 4 &&
M1 == 5 && M2 == 6)) {
2336 ShiftElts = IsLE ? LittleEndianShifts[M3 & 0x3] : BigEndianShifts[M3 & 0x3];
2337 InsertAtByte = IsLE ? 0 : 12;
2344 if (
N->getOperand(1).isUndef()) {
2347 unsigned XXINSERTWSrcElem = IsLE ? 2 : 1;
2348 if (
M0 == XXINSERTWSrcElem &&
M1 == 1 && M2 == 2 && M3 == 3) {
2349 InsertAtByte = IsLE ? 12 : 0;
2352 if (
M0 == 0 &&
M1 == XXINSERTWSrcElem && M2 == 2 && M3 == 3) {
2353 InsertAtByte = IsLE ? 8 : 4;
2356 if (
M0 == 0 &&
M1 == 1 && M2 == XXINSERTWSrcElem && M3 == 3) {
2357 InsertAtByte = IsLE ? 4 : 8;
2360 if (
M0 == 0 &&
M1 == 1 && M2 == 2 && M3 == XXINSERTWSrcElem) {
2361 InsertAtByte = IsLE ? 0 : 12;
2370 bool &Swap,
bool IsLE) {
2371 assert(
N->getValueType(0) == MVT::v16i8 &&
"Shuffle vector expects v16i8");
2377 unsigned M0 =
N->getMaskElt(0) / 4;
2378 unsigned M1 =
N->getMaskElt(4) / 4;
2379 unsigned M2 =
N->getMaskElt(8) / 4;
2380 unsigned M3 =
N->getMaskElt(12) / 4;
2384 if (
N->getOperand(1).isUndef()) {
2385 assert(
M0 < 4 &&
"Indexing into an undef vector?");
2386 if (
M1 != (
M0 + 1) % 4 || M2 != (
M1 + 1) % 4 || M3 != (M2 + 1) % 4)
2389 ShiftElts = IsLE ? (4 -
M0) % 4 :
M0;
2395 if (
M1 != (
M0 + 1) % 8 || M2 != (
M1 + 1) % 8 || M3 != (M2 + 1) % 8)
2399 if (
M0 == 0 ||
M0 == 7 ||
M0 == 6 ||
M0 == 5) {
2404 ShiftElts = (8 -
M0) % 8;
2405 }
else if (
M0 == 4 ||
M0 == 3 ||
M0 == 2 ||
M0 == 1) {
2410 ShiftElts = (4 -
M0) % 4;
2415 if (
M0 == 0 ||
M0 == 1 ||
M0 == 2 ||
M0 == 3) {
2420 }
else if (
M0 == 4 ||
M0 == 5 ||
M0 == 6 ||
M0 == 7) {
2432 assert(
N->getValueType(0) == MVT::v16i8 &&
"Shuffle vector expects v16i8");
2437 for (
int i = 0; i < 16; i += Width)
2438 if (
N->getMaskElt(i) != i + Width - 1)
2469 bool &Swap,
bool IsLE) {
2470 assert(
N->getValueType(0) == MVT::v16i8 &&
"Shuffle vector expects v16i8");
2476 unsigned M0 =
N->getMaskElt(0) / 8;
2477 unsigned M1 =
N->getMaskElt(8) / 8;
2478 assert(((
M0 |
M1) < 4) &&
"A mask element out of bounds?");
2482 if (
N->getOperand(1).isUndef()) {
2483 if ((
M0 |
M1) < 2) {
2484 DM = IsLE ? (((~M1) & 1) << 1) + ((~
M0) & 1) : (
M0 << 1) + (
M1 & 1);
2492 if (
M0 > 1 &&
M1 < 2) {
2494 }
else if (M0 < 2 && M1 > 1) {
2502 DM = (((~M1) & 1) << 1) + ((~
M0) & 1);
2505 if (M0 < 2 && M1 > 1) {
2507 }
else if (
M0 > 1 &&
M1 < 2) {
2515 DM = (
M0 << 1) + (
M1 & 1);
2530 if (VT == MVT::v2i64 || VT == MVT::v2f64)
2535 return (16 / EltSize) - 1 - (SVOp->
getMaskElt(0) / EltSize);
2551 unsigned EltSize = 16/
N->getNumOperands();
2552 if (EltSize < ByteSize) {
2553 unsigned Multiple = ByteSize/EltSize;
2555 assert(Multiple > 1 && Multiple <= 4 &&
"How can this happen?");
2558 for (
unsigned i = 0, e =
N->getNumOperands(); i != e; ++i) {
2559 if (
N->getOperand(i).isUndef())
continue;
2561 if (!isa<ConstantSDNode>(
N->getOperand(i)))
return SDValue();
2563 if (!UniquedVals[i&(Multiple-1)].
getNode())
2564 UniquedVals[i&(Multiple-1)] =
N->getOperand(i);
2565 else if (UniquedVals[i&(Multiple-1)] !=
N->getOperand(i))
2575 bool LeadingZero =
true;
2576 bool LeadingOnes =
true;
2577 for (
unsigned i = 0; i != Multiple-1; ++i) {
2578 if (!UniquedVals[i].
getNode())
continue;
2585 if (!UniquedVals[Multiple-1].
getNode())
2592 if (!UniquedVals[Multiple-1].
getNode())
2594 int Val =cast<ConstantSDNode>(UniquedVals[Multiple-1])->getSExtValue();
2603 for (
unsigned i = 0, e =
N->getNumOperands(); i != e; ++i) {
2604 if (
N->getOperand(i).isUndef())
continue;
2606 OpVal =
N->getOperand(i);
2607 else if (OpVal !=
N->getOperand(i))
2613 unsigned ValSizeInBytes = EltSize;
2616 Value = CN->getZExtValue();
2618 assert(CN->getValueType(0) == MVT::f32 &&
"Only one legal FP vector type!");
2619 Value = llvm::bit_cast<uint32_t>(CN->getValueAPF().convertToFloat());
2625 if (ValSizeInBytes < ByteSize)
return SDValue();
2636 if (MaskVal == 0)
return SDValue();
2639 if (SignExtend32<5>(MaskVal) == MaskVal)
2653 if (!isa<ConstantSDNode>(
N))
2656 Imm = (int16_t)
N->getAsZExtVal();
2657 if (
N->getValueType(0) == MVT::i32)
2658 return Imm == (int32_t)
N->getAsZExtVal();
2660 return Imm == (int64_t)
N->getAsZExtVal();
2678 return (~(LHSKnown.
Zero | RHSKnown.
Zero) == 0);
2687 if (
MemSDNode *Memop = dyn_cast<MemSDNode>(U)) {
2688 if (Memop->getMemoryVT() == MVT::f64) {
2689 Base =
N.getOperand(0);
2702 if (!isa<ConstantSDNode>(
N))
2705 Imm = (int64_t)
N->getAsZExtVal();
2706 return isInt<34>(Imm);
2733 (!EncodingAlignment ||
isAligned(*EncodingAlignment, Imm)))
2738 Base =
N.getOperand(0);
2741 }
else if (
N.getOpcode() ==
ISD::OR) {
2743 (!EncodingAlignment ||
isAligned(*EncodingAlignment, Imm)))
2755 if (~(LHSKnown.
Zero | RHSKnown.
Zero) == 0) {
2756 Base =
N.getOperand(0);
2827 (!EncodingAlignment ||
isAligned(*EncodingAlignment, imm))) {
2833 Base =
N.getOperand(0);
2836 }
else if (
N.getOperand(1).getOpcode() ==
PPCISD::Lo) {
2838 assert(!
N.getOperand(1).getConstantOperandVal(1) &&
2839 "Cannot handle constant offsets yet!");
2840 Disp =
N.getOperand(1).getOperand(0);
2845 Base =
N.getOperand(0);
2848 }
else if (
N.getOpcode() ==
ISD::OR) {
2851 (!EncodingAlignment ||
isAligned(*EncodingAlignment, imm))) {
2861 dyn_cast<FrameIndexSDNode>(
N.getOperand(0))) {
2865 Base =
N.getOperand(0);
2878 (!EncodingAlignment ||
isAligned(*EncodingAlignment, Imm))) {
2881 CN->getValueType(0));
2886 if ((CN->getValueType(0) == MVT::i32 ||
2887 (int64_t)CN->getZExtValue() == (
int)CN->getZExtValue()) &&
2888 (!EncodingAlignment ||
2889 isAligned(*EncodingAlignment, CN->getZExtValue()))) {
2890 int Addr = (int)CN->getZExtValue();
2897 unsigned Opc = CN->
getValueType(0) == MVT::i32 ? PPC::LIS : PPC::LIS8;
2918 if (
N.getValueType() != MVT::i64)
2931 Base =
N.getOperand(0);
2947 Base =
N.getOperand(0);
2980 !
N.getOperand(1).hasOneUse() || !
N.getOperand(0).hasOneUse())) {
2981 Base =
N.getOperand(0);
2994 Ty *PCRelCand = dyn_cast<Ty>(
N);
3006 if (isValidPCRelNode<ConstantPoolSDNode>(
N) ||
3007 isValidPCRelNode<GlobalAddressSDNode>(
N) ||
3008 isValidPCRelNode<JumpTableSDNode>(
N) ||
3009 isValidPCRelNode<BlockAddressSDNode>(
N))
3025 EVT MemVT = LD->getMemoryVT();
3032 if (!ST.hasP8Vector())
3037 if (!ST.hasP9Vector())
3050 if (UI.getUse().get().getResNo() == 0 &&
3072 Ptr = LD->getBasePtr();
3073 VT = LD->getMemoryVT();
3074 Alignment = LD->getAlign();
3075 }
else if (
StoreSDNode *ST = dyn_cast<StoreSDNode>(
N)) {
3076 Ptr = ST->getBasePtr();
3077 VT = ST->getMemoryVT();
3078 Alignment = ST->getAlign();
3101 if (isa<FrameIndexSDNode>(
Base) || isa<RegisterSDNode>(
Base))
3104 SDValue Val = cast<StoreSDNode>(
N)->getValue();
3117 if (VT != MVT::i64) {
3122 if (Alignment <
Align(4))
3132 if (LD->getValueType(0) == MVT::i64 && LD->getMemoryVT() == MVT::i32 &&
3134 isa<ConstantSDNode>(
Offset))
3149 unsigned &HiOpFlags,
unsigned &LoOpFlags,
3191 const bool Is64Bit = Subtarget.
isPPC64();
3192 EVT VT = Is64Bit ? MVT::i64 : MVT::i32;
3206 EVT PtrVT =
Op.getValueType();
3222 return getTOCEntry(DAG,
SDLoc(CP), GA);
3225 unsigned MOHiFlag, MOLoFlag;
3232 return getTOCEntry(DAG,
SDLoc(CP), GA);
3292 EVT PtrVT =
Op.getValueType();
3310 return getTOCEntry(DAG,
SDLoc(JT), GA);
3313 unsigned MOHiFlag, MOLoFlag;
3320 return getTOCEntry(DAG,
SDLoc(GA), GA);
3330 EVT PtrVT =
Op.getValueType();
3349 return getTOCEntry(DAG,
SDLoc(BASDN), GA);
3358 unsigned MOHiFlag, MOLoFlag;
3369 return LowerGlobalTLSAddressAIX(
Op, DAG);
3371 return LowerGlobalTLSAddressLinux(
Op, DAG);
3393 if (
I.getOpcode() == Instruction::Call)
3394 if (
const CallInst *CI = dyn_cast<const CallInst>(&
I))
3395 if (
Function *CF = CI->getCalledFunction())
3396 if (CF->isDeclaration() &&
3397 CF->getIntrinsicID() == Intrinsic::threadlocal_address)
3399 dyn_cast<GlobalValue>(
I.getOperand(0))) {
3405 unsigned TLSGVCnt = TLSGV.
size();
3415 <<
" function is using the TLS-IE model for TLS-LD access.\n");
3430 bool Is64Bit = Subtarget.
isPPC64();
3434 if (Subtarget.hasAIXShLibTLSModelOpt())
3440 bool HasAIXSmallLocalExecTLS = Subtarget.hasAIXSmallLocalExecTLS();
3441 bool HasAIXSmallTLSGlobalAttr =
false;
3444 SDValue VariableOffset = getTOCEntry(DAG, dl, VariableOffsetTGA);
3448 if (GVar->hasAttribute(
"aix-small-tls"))
3449 HasAIXSmallTLSGlobalAttr =
true;
3468 if ((HasAIXSmallLocalExecTLS || HasAIXSmallTLSGlobalAttr) &&
3469 IsTLSLocalExecModel) {
3489 if (HasAIXSmallLocalExecTLS || HasAIXSmallTLSGlobalAttr)
3491 "currently only supported on AIX (64-bit mode).");
3497 bool HasAIXSmallLocalDynamicTLS = Subtarget.hasAIXSmallLocalDynamicTLS();
3501 if (!Is64Bit && HasAIXSmallLocalDynamicTLS)
3503 "currently only supported on AIX (64-bit mode).");
3511 SDValue VariableOffset = getTOCEntry(DAG, dl, VariableOffsetTGA);
3515 dyn_cast_or_null<GlobalVariable>(
M->getOrInsertGlobal(
3518 assert(TLSGV &&
"Not able to create GV for _$TLSML.");
3521 SDValue ModuleHandleTOC = getTOCEntry(DAG, dl, ModuleHandleTGA);
3532 if (HasAIXSmallLocalDynamicTLS) {
3541 return DAG.
getNode(
ISD::ADD, dl, PtrVT, ModuleHandle, VariableOffset);
3554 SDValue VariableOffset = getTOCEntry(DAG, dl, VariableOffsetTGA);
3555 SDValue RegionHandle = getTOCEntry(DAG, dl, RegionHandleTGA);
3573 bool is64bit = Subtarget.
isPPC64();
3620 if (!
TM.isPositionIndependent())
3679 PtrVT, GOTPtr, TGA, TGA);
3681 PtrVT, TLSAddr, TGA);
3690 EVT PtrVT =
Op.getValueType();