63 #define DEBUG_TYPE "ppcfastisel" 87 class PPCFastISel final :
public FastISel {
108 bool fastSelectInstruction(
const Instruction *
I)
override;
109 unsigned fastMaterializeConstant(
const Constant *
C)
override;
110 unsigned fastMaterializeAlloca(
const AllocaInst *AI)
override;
113 bool fastLowerArguments()
override;
114 unsigned fastEmit_i(
MVT Ty,
MVT RetTy,
unsigned Opc, uint64_t Imm)
override;
115 unsigned fastEmitInst_ri(
unsigned MachineInstOpcode,
117 unsigned Op0,
bool Op0IsKill,
119 unsigned fastEmitInst_r(
unsigned MachineInstOpcode,
121 unsigned Op0,
bool Op0IsKill);
122 unsigned fastEmitInst_rr(
unsigned MachineInstOpcode,
124 unsigned Op0,
bool Op0IsKill,
125 unsigned Op1,
bool Op1IsKill);
127 bool fastLowerCall(CallLoweringInfo &CLI)
override;
137 bool SelectIToFP(
const Instruction *I,
bool IsSigned);
138 bool SelectFPToI(
const Instruction *I,
bool IsSigned);
139 bool SelectBinaryIntOp(
const Instruction *I,
unsigned ISDOpcode);
146 bool isTypeLegal(
Type *Ty,
MVT &VT);
147 bool isLoadTypeLegal(
Type *Ty,
MVT &VT);
148 bool isValueAvailable(
const Value *V)
const;
150 return RC->
getID() == PPC::VSFRCRegClassID;
153 return RC->
getID() == PPC::VSSRCRegClassID;
155 bool PPCEmitCmp(
const Value *Src1Value,
const Value *Src2Value,
156 bool isZExt,
unsigned DestReg,
158 bool PPCEmitLoad(
MVT VT,
unsigned &ResultReg,
Address &Addr,
160 unsigned FP64LoadOpc = PPC::LFD);
161 bool PPCEmitStore(
MVT VT,
unsigned SrcReg,
Address &Addr);
162 bool PPCComputeAddress(
const Value *Obj,
Address &Addr);
163 void PPCSimplifyAddress(
Address &Addr,
bool &UseOffset,
165 bool PPCEmitIntExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
166 unsigned DestReg,
bool IsZExt);
170 bool UseSExt =
true);
171 unsigned PPCMaterialize32BitInt(int64_t Imm,
173 unsigned PPCMaterialize64BitInt(int64_t Imm,
176 unsigned SrcReg,
bool IsSigned);
177 unsigned PPCMoveToFPReg(
MVT VT,
unsigned SrcReg,
bool IsSigned);
189 bool finishCall(
MVT RetVT, CallLoweringInfo &CLI,
unsigned &NumBytes);
193 #include "PPCGenFastISel.inc" 199 #include "PPCGenCallingConv.inc" 205 return CC_PPC32_SVR4;
207 return CC_PPC32_SVR4_ByVal;
209 return CC_PPC32_SVR4_VarArg;
211 return RetCC_PPC_Cold;
285 bool PPCFastISel::isTypeLegal(
Type *Ty,
MVT &VT) {
286 EVT Evt = TLI.getValueType(DL, Ty,
true);
294 return TLI.isTypeLegal(VT);
299 bool PPCFastISel::isLoadTypeLegal(
Type *Ty,
MVT &VT) {
300 if (isTypeLegal(Ty, VT))
return true;
311 bool PPCFastISel::isValueAvailable(
const Value *V)
const {
312 if (!isa<Instruction>(V))
315 const auto *
I = cast<Instruction>(V);
316 return FuncInfo.MBBMap[
I->getParent()] == FuncInfo.MBB;
321 bool PPCFastISel::PPCComputeAddress(
const Value *Obj,
Address &Addr) {
322 const User *U =
nullptr;
323 unsigned Opcode = Instruction::UserOp1;
324 if (
const Instruction *
I = dyn_cast<Instruction>(Obj)) {
327 if (FuncInfo.StaticAllocaMap.count(static_cast<const AllocaInst *>(Obj)) ||
328 FuncInfo.MBBMap[
I->getParent()] == FuncInfo.MBB) {
329 Opcode =
I->getOpcode();
332 }
else if (
const ConstantExpr *
C = dyn_cast<ConstantExpr>(Obj)) {
340 case Instruction::BitCast:
342 return PPCComputeAddress(U->
getOperand(0), Addr);
343 case Instruction::IntToPtr:
346 TLI.getPointerTy(DL))
347 return PPCComputeAddress(U->
getOperand(0), Addr);
349 case Instruction::PtrToInt:
351 if (TLI.getValueType(DL, U->
getType()) == TLI.getPointerTy(DL))
352 return PPCComputeAddress(U->
getOperand(0), Addr);
354 case Instruction::GetElementPtr: {
356 long TmpOffset = Addr.Offset;
362 II !=
IE; ++II, ++GTI) {
366 unsigned Idx = cast<ConstantInt>(
Op)->getZExtValue();
371 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(Op)) {
373 TmpOffset += CI->getSExtValue() * S;
376 if (canFoldAddIntoGEP(U, Op)) {
379 cast<ConstantInt>(cast<AddOperator>(
Op)->getOperand(1));
382 Op = cast<AddOperator>(
Op)->getOperand(0);
386 goto unsupported_gep;
392 Addr.Offset = TmpOffset;
393 if (PPCComputeAddress(U->
getOperand(0), Addr))
return true;
401 case Instruction::Alloca: {
404 FuncInfo.StaticAllocaMap.find(AI);
405 if (SI != FuncInfo.StaticAllocaMap.end()) {
406 Addr.BaseType = Address::FrameIndexBase;
407 Addr.Base.FI = SI->second;
421 if (Addr.Base.Reg == 0)
422 Addr.Base.Reg = getRegForValue(Obj);
426 if (Addr.Base.Reg != 0)
427 MRI.setRegClass(Addr.Base.Reg, &PPC::G8RC_and_G8RC_NOX0RegClass);
429 return Addr.Base.Reg != 0;
435 void PPCFastISel::PPCSimplifyAddress(
Address &Addr,
bool &UseOffset,
436 unsigned &IndexReg) {
445 if (!UseOffset && Addr.BaseType == Address::FrameIndexBase) {
446 unsigned ResultReg = createResultReg(&PPC::G8RC_and_G8RC_NOX0RegClass);
447 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::ADDI8),
448 ResultReg).addFrameIndex(Addr.Base.FI).
addImm(0);
449 Addr.Base.Reg = ResultReg;
450 Addr.BaseType = Address::RegBase;
457 IndexReg = PPCMaterializeInt(Offset,
MVT::i64);
458 assert(IndexReg &&
"Unexpected error in PPCMaterializeInt!");
465 bool PPCFastISel::PPCEmitLoad(
MVT VT,
unsigned &ResultReg,
Address &Addr,
467 bool IsZExt,
unsigned FP64LoadOpc) {
469 bool UseOffset =
true;
470 bool HasSPE = PPCSubTarget->hasSPE();
480 (ResultReg ?
MRI.getRegClass(ResultReg) :
482 (VT ==
MVT::f64 ? (HasSPE ? &PPC::SPERCRegClass : &PPC::F8RCRegClass) :
483 (VT ==
MVT::f32 ? (HasSPE ? &PPC::SPE4RCRegClass : &PPC::F4RCRegClass) :
484 (VT ==
MVT::i64 ? &PPC::G8RC_and_G8RC_NOX0RegClass :
485 &PPC::GPRC_and_GPRC_NOR0RegClass)))));
493 Opc = Is32BitInt ? PPC::LBZ : PPC::LBZ8;
496 Opc = (IsZExt ? (Is32BitInt ? PPC::LHZ : PPC::LHZ8)
497 : (Is32BitInt ? PPC::LHA : PPC::LHA8));
500 Opc = (IsZExt ? (Is32BitInt ? PPC::LWZ : PPC::LWZ8)
501 : (Is32BitInt ? PPC::LWA_32 : PPC::LWA));
502 if ((Opc == PPC::LWA || Opc == PPC::LWA_32) && ((Addr.Offset & 3) != 0))
508 "64-bit load with 32-bit target??");
509 UseOffset = ((Addr.Offset & 3) == 0);
512 Opc = PPCSubTarget->hasSPE() ? PPC::SPELWZ : PPC::LFS;
521 unsigned IndexReg = 0;
522 PPCSimplifyAddress(Addr, UseOffset, IndexReg);
526 bool IsVSSRC = isVSSRCRegClass(UseRC);
527 bool IsVSFRC = isVSFRCRegClass(UseRC);
528 bool Is32VSXLoad = IsVSSRC && Opc == PPC::LFS;
529 bool Is64VSXLoad = IsVSFRC && Opc == PPC::LFD;
530 if ((Is32VSXLoad || Is64VSXLoad) &&
531 (Addr.BaseType != Address::FrameIndexBase) && UseOffset &&
532 (Addr.Offset == 0)) {
537 ResultReg = createResultReg(UseRC);
542 if (Addr.BaseType == Address::FrameIndexBase) {
544 if (Is32VSXLoad || Is64VSXLoad)
return false;
550 MFI.getObjectAlignment(Addr.Base.FI));
552 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), ResultReg)
556 }
else if (UseOffset) {
558 if (Is32VSXLoad || Is64VSXLoad)
return false;
560 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), ResultReg)
561 .addImm(Addr.Offset).
addReg(Addr.Base.Reg);
570 case PPC::LBZ: Opc = PPC::LBZX;
break;
571 case PPC::LBZ8: Opc = PPC::LBZX8;
break;
572 case PPC::LHZ: Opc = PPC::LHZX;
break;
573 case PPC::LHZ8: Opc = PPC::LHZX8;
break;
574 case PPC::LHA: Opc = PPC::LHAX;
break;
575 case PPC::LHA8: Opc = PPC::LHAX8;
break;
576 case PPC::LWZ: Opc = PPC::LWZX;
break;
577 case PPC::LWZ8: Opc = PPC::LWZX8;
break;
578 case PPC::LWA: Opc = PPC::LWAX;
break;
579 case PPC::LWA_32: Opc = PPC::LWAX_32;
break;
580 case PPC::LD: Opc = PPC::LDX;
break;
581 case PPC::LFS: Opc = IsVSSRC ? PPC::LXSSPX : PPC::LFSX;
break;
582 case PPC::LFD: Opc = IsVSFRC ? PPC::LXSDX : PPC::LFDX;
break;
583 case PPC::EVLDD: Opc = PPC::EVLDDX;
break;
584 case PPC::SPELWZ: Opc = PPC::SPELWZX;
break;
587 auto MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc),
611 if (!isLoadTypeLegal(I->
getType(), VT))
616 if (!PPCComputeAddress(I->
getOperand(0), Addr))
622 unsigned AssignedReg = FuncInfo.ValueMap[
I];
624 AssignedReg ?
MRI.getRegClass(AssignedReg) :
nullptr;
626 unsigned ResultReg = 0;
627 if (!PPCEmitLoad(VT, ResultReg, Addr, RC,
true,
628 PPCSubTarget->hasSPE() ? PPC::EVLDD : PPC::LFD))
630 updateValueMap(I, ResultReg);
635 bool PPCFastISel::PPCEmitStore(
MVT VT,
unsigned SrcReg,
Address &Addr) {
636 assert(SrcReg &&
"Nothing to store!");
638 bool UseOffset =
true;
647 Opc = Is32BitInt ? PPC::STB : PPC::STB8;
650 Opc = Is32BitInt ? PPC::STH : PPC::STH8;
653 assert(Is32BitInt &&
"Not GPRC for i32??");
658 UseOffset = ((Addr.Offset & 3) == 0);
661 Opc = PPCSubTarget->hasSPE() ? PPC::SPESTW : PPC::STFS;
664 Opc = PPCSubTarget->hasSPE() ? PPC::EVSTDD : PPC::STFD;
670 unsigned IndexReg = 0;
671 PPCSimplifyAddress(Addr, UseOffset, IndexReg);
675 bool IsVSSRC = isVSSRCRegClass(RC);
676 bool IsVSFRC = isVSFRCRegClass(RC);
677 bool Is32VSXStore = IsVSSRC && Opc == PPC::STFS;
678 bool Is64VSXStore = IsVSFRC && Opc == PPC::STFD;
679 if ((Is32VSXStore || Is64VSXStore) &&
680 (Addr.BaseType != Address::FrameIndexBase) && UseOffset &&
681 (Addr.Offset == 0)) {
688 if (Addr.BaseType == Address::FrameIndexBase) {
690 if (Is32VSXStore || Is64VSXStore)
return false;
696 MFI.getObjectAlignment(Addr.Base.FI));
698 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc))
705 }
else if (UseOffset) {
707 if (Is32VSXStore || Is64VSXStore)
710 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc))
711 .addReg(SrcReg).
addImm(Addr.Offset).
addReg(Addr.Base.Reg);
720 case PPC::STB: Opc = PPC::STBX;
break;
721 case PPC::STH : Opc = PPC::STHX;
break;
722 case PPC::STW : Opc = PPC::STWX;
break;
723 case PPC::STB8: Opc = PPC::STBX8;
break;
724 case PPC::STH8: Opc = PPC::STHX8;
break;
725 case PPC::STW8: Opc = PPC::STWX8;
break;
726 case PPC::STD: Opc = PPC::STDX;
break;
727 case PPC::STFS: Opc = IsVSSRC ? PPC::STXSSPX : PPC::STFSX;
break;
728 case PPC::STFD: Opc = IsVSFRC ? PPC::STXSDX : PPC::STFDX;
break;
729 case PPC::EVSTDD: Opc = PPC::EVSTDDX;
break;
730 case PPC::SPESTW: Opc = PPC::SPESTWX;
break;
733 auto MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc))
741 MIB.addReg(Addr.Base.Reg).addReg(IndexReg);
743 MIB.addReg(PPC::ZERO8).addReg(Addr.Base.Reg);
750 bool PPCFastISel::SelectStore(
const Instruction *I) {
760 if (!isLoadTypeLegal(Op0->
getType(), VT))
764 SrcReg = getRegForValue(Op0);
770 if (!PPCComputeAddress(I->
getOperand(1), Addr))
773 if (!PPCEmitStore(VT, SrcReg, Addr))
780 bool PPCFastISel::SelectBranch(
const Instruction *I) {
788 if (isValueAvailable(CI)) {
796 if (FuncInfo.MBB->isLayoutSuccessor(TBB)) {
801 unsigned CondReg = createResultReg(&PPC::CRRCRegClass);
803 if (!PPCEmitCmp(CI->getOperand(0), CI->getOperand(1), CI->isUnsigned(),
807 BuildMI(*BrBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::BCC))
809 .addReg(CondReg).
addMBB(TBB);
810 finishCondBranch(BI->
getParent(), TBB, FBB);
815 uint64_t Imm = CI->getZExtValue();
817 fastEmitBranch(Target, DbgLoc);
832 bool PPCFastISel::PPCEmitCmp(
const Value *SrcValue1,
const Value *SrcValue2,
833 bool IsZExt,
unsigned DestReg,
836 EVT SrcEVT = TLI.getValueType(DL, Ty,
true);
841 if (SrcVT ==
MVT::i1 && PPCSubTarget->useCRBits())
850 const bool HasSPE = PPCSubTarget->hasSPE();
854 if (
const ConstantInt *ConstInt = dyn_cast<ConstantInt>(SrcValue2)) {
857 const APInt &CIVal = ConstInt->getValue();
864 unsigned SrcReg1 = getRegForValue(SrcValue1);
868 unsigned SrcReg2 = 0;
870 SrcReg2 = getRegForValue(SrcValue2);
876 bool NeedsExt =
false;
877 auto RC =
MRI.getRegClass(SrcReg1);
879 default:
return false;
883 default:
return false;
885 CmpOpc = PPC::EFSCMPEQ;
888 CmpOpc = PPC::EFSCMPLT;
891 CmpOpc = PPC::EFSCMPGT;
895 CmpOpc = PPC::FCMPUS;
896 if (isVSSRCRegClass(RC)) {
897 unsigned TmpReg = createResultReg(&PPC::F4RCRegClass);
898 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
899 TII.get(TargetOpcode::COPY), TmpReg).addReg(SrcReg1);
907 default:
return false;
909 CmpOpc = PPC::EFDCMPEQ;
912 CmpOpc = PPC::EFDCMPLT;
915 CmpOpc = PPC::EFDCMPGT;
918 }
else if (isVSFRCRegClass(RC)) {
919 CmpOpc = PPC::XSCMPUDP;
921 CmpOpc = PPC::FCMPUD;
931 CmpOpc = IsZExt ? PPC::CMPLW : PPC::CMPW;
933 CmpOpc = IsZExt ? PPC::CMPLWI : PPC::CMPWI;
937 CmpOpc = IsZExt ? PPC::CMPLD : PPC::CMPD;
939 CmpOpc = IsZExt ? PPC::CMPLDI : PPC::CMPDI;
944 unsigned ExtReg = createResultReg(&PPC::GPRCRegClass);
945 if (!PPCEmitIntExt(SrcVT, SrcReg1,
MVT::i32, ExtReg, IsZExt))
950 unsigned ExtReg = createResultReg(&PPC::GPRCRegClass);
951 if (!PPCEmitIntExt(SrcVT, SrcReg2,
MVT::i32, ExtReg, IsZExt))
958 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(CmpOpc), DestReg)
959 .addReg(SrcReg1).
addReg(SrcReg2);
961 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(CmpOpc), DestReg)
962 .addReg(SrcReg1).
addImm(Imm);
968 bool PPCFastISel::SelectFPExt(
const Instruction *I) {
970 EVT SrcVT = TLI.getValueType(DL, Src->
getType(),
true);
971 EVT DestVT = TLI.getValueType(DL, I->
getType(),
true);
976 unsigned SrcReg = getRegForValue(Src);
981 updateValueMap(I, SrcReg);
986 bool PPCFastISel::SelectFPTrunc(
const Instruction *I) {
988 EVT SrcVT = TLI.getValueType(DL, Src->
getType(),
true);
989 EVT DestVT = TLI.getValueType(DL, I->
getType(),
true);
994 unsigned SrcReg = getRegForValue(Src);
1001 if (PPCSubTarget->hasSPE()) {
1002 DestReg = createResultReg(&PPC::SPE4RCRegClass);
1003 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1004 TII.get(PPC::EFSCFD), DestReg)
1007 DestReg = createResultReg(&PPC::F4RCRegClass);
1008 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1009 TII.get(PPC::FRSP), DestReg)
1013 updateValueMap(I, DestReg);
1024 unsigned PPCFastISel::PPCMoveToFPReg(
MVT SrcVT,
unsigned SrcReg,
1029 unsigned TmpReg = createResultReg(&PPC::G8RCRegClass);
1037 Addr.BaseType = Address::FrameIndexBase;
1038 Addr.Base.FI = MFI.CreateStackObject(8, 8,
false);
1041 if (!PPCEmitStore(
MVT::i64, SrcReg, Addr))
1046 unsigned LoadOpc = PPC::LFD;
1051 Addr.Offset = (PPCSubTarget->isLittleEndian()) ? 0 : 4;
1052 }
else if (PPCSubTarget->hasLFIWAX()) {
1054 Addr.Offset = (PPCSubTarget->isLittleEndian()) ? 0 : 4;
1059 unsigned ResultReg = 0;
1060 if (!PPCEmitLoad(
MVT::f64, ResultReg, Addr, RC, !IsSigned, LoadOpc))
1069 bool PPCFastISel::SelectIToFP(
const Instruction *I,
bool IsSigned) {
1072 if (!isTypeLegal(DstTy, DstVT))
1079 EVT SrcEVT = TLI.getValueType(DL, Src->
getType(),
true);
1089 unsigned SrcReg = getRegForValue(Src);
1094 if (PPCSubTarget->hasSPE()) {
1097 Opc = IsSigned ? PPC::EFSCFSI : PPC::EFSCFUI;
1099 Opc = IsSigned ? PPC::EFDCFSI : PPC::EFDCFUI;
1101 unsigned DestReg = createResultReg(&PPC::SPERCRegClass);
1103 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
1105 updateValueMap(I, DestReg);
1111 if (!IsSigned && !PPCSubTarget->hasFPCVT())
1119 if (DstVT ==
MVT::f32 && !PPCSubTarget->hasFPCVT())
1124 unsigned TmpReg = createResultReg(&PPC::G8RCRegClass);
1125 if (!PPCEmitIntExt(SrcVT, SrcReg,
MVT::i64, TmpReg, !IsSigned))
1132 unsigned FPReg = PPCMoveToFPReg(SrcVT, SrcReg, IsSigned);
1138 unsigned DestReg = createResultReg(RC);
1147 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
1150 updateValueMap(I, DestReg);
1159 unsigned PPCFastISel::PPCMoveToIntReg(
const Instruction *I,
MVT VT,
1160 unsigned SrcReg,
bool IsSigned) {
1166 Addr.BaseType = Address::FrameIndexBase;
1167 Addr.Base.FI = MFI.CreateStackObject(8, 8,
false);
1170 if (!PPCEmitStore(
MVT::f64, SrcReg, Addr))
1176 Addr.Offset = (PPCSubTarget->isLittleEndian()) ? 0 : 4;
1180 unsigned AssignedReg = FuncInfo.ValueMap[
I];
1182 AssignedReg ?
MRI.getRegClass(AssignedReg) :
nullptr;
1184 unsigned ResultReg = 0;
1185 if (!PPCEmitLoad(VT, ResultReg, Addr, RC, !IsSigned))
1194 bool PPCFastISel::SelectFPToI(
const Instruction *I,
bool IsSigned) {
1197 if (!isTypeLegal(DstTy, DstVT))
1204 if (DstVT ==
MVT::i64 && !IsSigned &&
1205 !PPCSubTarget->hasFPCVT() && !PPCSubTarget->hasSPE())
1210 if (!isTypeLegal(SrcTy, SrcVT))
1216 unsigned SrcReg = getRegForValue(Src);
1223 if (InRC == &PPC::F4RCRegClass) {
1224 unsigned TmpReg = createResultReg(&PPC::F8RCRegClass);
1225 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1226 TII.get(TargetOpcode::COPY), TmpReg)
1236 if (PPCSubTarget->hasSPE()) {
1237 DestReg = createResultReg(&PPC::GPRCRegClass);
1239 Opc = InRC == &PPC::SPE4RCRegClass ? PPC::EFSCTSIZ : PPC::EFDCTSIZ;
1241 Opc = InRC == &PPC::SPE4RCRegClass ? PPC::EFSCTUIZ : PPC::EFDCTUIZ;
1243 DestReg = createResultReg(&PPC::F8RCRegClass);
1254 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
1258 unsigned IntReg = PPCSubTarget->hasSPE() ? DestReg :
1259 PPCMoveToIntReg(I, DstVT, DestReg, IsSigned);
1264 updateValueMap(I, IntReg);
1270 bool PPCFastISel::SelectBinaryIntOp(
const Instruction *I,
unsigned ISDOpcode) {
1271 EVT DestVT = TLI.getValueType(DL, I->
getType(),
true);
1281 unsigned AssignedReg = FuncInfo.ValueMap[
I];
1283 (AssignedReg ?
MRI.getRegClass(AssignedReg) :
1284 &PPC::GPRC_and_GPRC_NOR0RegClass);
1288 switch (ISDOpcode) {
1289 default:
return false;
1291 Opc = IsGPRC ? PPC::ADD4 : PPC::ADD8;
1294 Opc = IsGPRC ?
PPC::OR : PPC::OR8;
1297 Opc = IsGPRC ? PPC::SUBF : PPC::SUBF8;
1301 unsigned ResultReg = createResultReg(RC ? RC : &PPC::G8RCRegClass);
1302 unsigned SrcReg1 = getRegForValue(I->
getOperand(0));
1303 if (SrcReg1 == 0)
return false;
1307 const APInt &CIVal = ConstInt->getValue();
1316 MRI.setRegClass(SrcReg1, &PPC::GPRC_and_GPRC_NOR0RegClass);
1320 MRI.setRegClass(SrcReg1, &PPC::G8RC_and_G8RC_NOX0RegClass);
1333 MRI.setRegClass(SrcReg1, &PPC::GPRC_and_GPRC_NOR0RegClass);
1342 MRI.setRegClass(SrcReg1, &PPC::G8RC_and_G8RC_NOX0RegClass);
1349 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc),
1353 updateValueMap(I, ResultReg);
1360 unsigned SrcReg2 = getRegForValue(I->
getOperand(1));
1361 if (SrcReg2 == 0)
return false;
1367 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), ResultReg)
1368 .addReg(SrcReg1).
addReg(SrcReg2);
1369 updateValueMap(I, ResultReg);
1387 unsigned LinkageSize = PPCSubTarget->getFrameLowering()->getLinkageSize();
1393 for (
unsigned I = 0,
E = ArgLocs.
size(); I !=
E; ++
I) {
1417 NumBytes =
std::max(NumBytes, LinkageSize + 64);
1420 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1421 TII.get(
TII.getCallFrameSetupOpcode()))
1427 unsigned NextGPR = PPC::X3;
1428 unsigned NextFPR = PPC::F1;
1431 for (
unsigned I = 0,
E = ArgLocs.
size(); I !=
E; ++
I) {
1445 (DestVT ==
MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
1446 unsigned TmpReg = createResultReg(RC);
1447 if (!PPCEmitIntExt(ArgVT, Arg, DestVT, TmpReg,
false))
1457 (DestVT ==
MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
1458 unsigned TmpReg = createResultReg(RC);
1459 if (!PPCEmitIntExt(ArgVT, Arg, DestVT, TmpReg,
true))
1481 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1482 TII.get(TargetOpcode::COPY), ArgReg).addReg(Arg);
1491 bool PPCFastISel::finishCall(
MVT RetVT, CallLoweringInfo &CLI,
unsigned &NumBytes) {
1495 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1496 TII.get(
TII.getCallFrameDestroyOpcode()))
1507 assert(RVLocs.
size() == 1 &&
"No support for multi-reg return values!");
1511 MVT CopyVT = DestVT;
1518 unsigned SourcePhysReg = VA.
getLocReg();
1519 unsigned ResultReg = 0;
1521 if (RetVT == CopyVT) {
1523 ResultReg = createResultReg(CpyRC);
1525 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1526 TII.get(TargetOpcode::COPY), ResultReg)
1527 .addReg(SourcePhysReg);
1531 ResultReg = createResultReg(TLI.getRegClassFor(RetVT));
1532 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::FRSP),
1533 ResultReg).addReg(SourcePhysReg);
1540 ResultReg = createResultReg(&PPC::GPRCRegClass);
1542 SourcePhysReg -= PPC::X0 - PPC::R0;
1543 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1544 TII.get(TargetOpcode::COPY), ResultReg)
1545 .addReg(SourcePhysReg);
1548 assert(ResultReg &&
"ResultReg unset!");
1549 CLI.InRegs.push_back(SourcePhysReg);
1550 CLI.ResultReg = ResultReg;
1551 CLI.NumResultRegs = 1;
1557 bool PPCFastISel::fastLowerCall(CallLoweringInfo &CLI) {
1559 bool IsTailCall = CLI.IsTailCall;
1560 bool IsVarArg = CLI.IsVarArg;
1564 if (!Callee && !Symbol)
1577 Type *RetTy = CLI.RetTy;
1581 else if (!isTypeLegal(RetTy, RetVT) && RetVT !=
MVT::i16 &&
1584 else if (RetVT ==
MVT::i1 && PPCSubTarget->useCRBits())
1595 if (RVLocs.
size() > 1)
1601 unsigned NumArgs = CLI.OutVals.size();
1616 for (
unsigned i = 0, ie = NumArgs; i != ie; ++i) {
1624 Value *ArgValue = CLI.OutVals[i];
1627 if (!isTypeLegal(ArgTy, ArgVT) && ArgVT !=
MVT::i16 && ArgVT !=
MVT::i8)
1633 unsigned Arg = getRegForValue(ArgValue);
1647 if (!processCallArgs(Args, ArgRegs, ArgVTs, ArgFlags,
1648 RegArgs, CC, NumBytes, IsVarArg))
1661 if (CLI.IsPatchPoint)
1662 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::NOP));
1668 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1669 TII.get(PPC::BL8_NOP));
1675 for (
unsigned II = 0,
IE = RegArgs.
size(); II !=
IE; ++II)
1680 PPCFuncInfo->setUsesTOCBasePtr();
1690 return finishCall(RetVT, CLI, NumBytes);
1694 bool PPCFastISel::SelectRet(
const Instruction *I) {
1696 if (!FuncInfo.CanLowerReturn)
1699 if (TLI.supportSplitCSR(FuncInfo.MF))
1711 GetReturnInfo(CC, F.getReturnType(), F.getAttributes(), Outs, TLI, DL);
1715 CCState CCInfo(CC, F.isVarArg(), *FuncInfo.MF, ValLocs, *
Context);
1720 if (ValLocs.size() > 1)
1725 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(RV)) {
1736 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1737 TII.get(TargetOpcode::COPY), RetReg).addReg(SrcReg);
1742 unsigned Reg = getRegForValue(RV);
1748 for (
unsigned i = 0; i < ValLocs.size(); ++i) {
1753 unsigned SrcReg = Reg + VA.
getValNo();
1755 EVT RVEVT = TLI.getValueType(DL, RV->
getType());
1761 if (RVVT != DestVT && RVVT !=
MVT::i8 &&
1765 if (RVVT != DestVT) {
1774 (DestVT ==
MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
1775 unsigned TmpReg = createResultReg(RC);
1776 if (!PPCEmitIntExt(RVVT, SrcReg, DestVT, TmpReg,
true))
1783 (DestVT ==
MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
1784 unsigned TmpReg = createResultReg(RC);
1785 if (!PPCEmitIntExt(RVVT, SrcReg, DestVT, TmpReg,
false))
1793 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1794 TII.get(TargetOpcode::COPY), RetRegs[i])
1801 TII.get(PPC::BLR8));
1803 for (
unsigned i = 0, e = RetRegs.
size(); i != e; ++i)
1812 bool PPCFastISel::PPCEmitIntExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
1813 unsigned DestReg,
bool IsZExt) {
1823 Opc = (DestVT ==
MVT::i32) ? PPC::EXTSB : PPC::EXTSB8_32_64;
1825 Opc = (DestVT ==
MVT::i32) ? PPC::EXTSH : PPC::EXTSH8_32_64;
1828 Opc = PPC::EXTSW_32_64;
1830 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
1839 assert(SrcVT ==
MVT::i16 &&
"Unsigned extend from i32 to i32??");
1842 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::RLWINM),
1855 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1856 TII.get(PPC::RLDICL_32_64), DestReg)
1864 bool PPCFastISel::SelectIndirectBr(
const Instruction *I) {
1865 unsigned AddrReg = getRegForValue(I->
getOperand(0));
1869 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::MTCTR8))
1871 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::BCTR8));
1874 for (
const BasicBlock *SuccBB : IB->successors())
1875 FuncInfo.MBB->addSuccessor(FuncInfo.MBBMap[SuccBB]);
1881 bool PPCFastISel::SelectTrunc(
const Instruction *I) {
1883 EVT SrcVT = TLI.getValueType(DL, Src->
getType(),
true);
1884 EVT DestVT = TLI.getValueType(DL, I->
getType(),
true);
1892 unsigned SrcReg = getRegForValue(Src);
1898 unsigned ResultReg = createResultReg(&PPC::GPRCRegClass);
1899 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1900 TII.get(TargetOpcode::COPY),
1901 ResultReg).addReg(SrcReg, 0, PPC::sub_32);
1905 updateValueMap(I, SrcReg);
1910 bool PPCFastISel::SelectIntExt(
const Instruction *I) {
1915 bool IsZExt = isa<ZExtInst>(
I);
1916 unsigned SrcReg = getRegForValue(Src);
1917 if (!SrcReg)
return false;
1919 EVT SrcEVT, DestEVT;
1920 SrcEVT = TLI.getValueType(DL, SrcTy,
true);
1921 DestEVT = TLI.getValueType(DL, DestTy,
true);
1934 unsigned AssignedReg = FuncInfo.ValueMap[
I];
1936 (AssignedReg ?
MRI.getRegClass(AssignedReg) :
1937 (DestVT ==
MVT::i64 ? &PPC::G8RC_and_G8RC_NOX0RegClass :
1938 &PPC::GPRC_and_GPRC_NOR0RegClass));
1939 unsigned ResultReg = createResultReg(RC);
1941 if (!PPCEmitIntExt(SrcVT, SrcReg, DestVT, ResultReg, IsZExt))
1944 updateValueMap(I, ResultReg);
1950 bool PPCFastISel::fastSelectInstruction(
const Instruction *I) {
1954 return SelectLoad(I);
1956 return SelectStore(I);
1957 case Instruction::Br:
1958 return SelectBranch(I);
1959 case Instruction::IndirectBr:
1960 return SelectIndirectBr(I);
1961 case Instruction::FPExt:
1962 return SelectFPExt(I);
1963 case Instruction::FPTrunc:
1964 return SelectFPTrunc(I);
1965 case Instruction::SIToFP:
1966 return SelectIToFP(I,
true);
1967 case Instruction::UIToFP:
1968 return SelectIToFP(I,
false);
1969 case Instruction::FPToSI:
1970 return SelectFPToI(I,
true);
1971 case Instruction::FPToUI:
1972 return SelectFPToI(I,
false);
1974 return SelectBinaryIntOp(I,
ISD::ADD);
1975 case Instruction::Or:
1976 return SelectBinaryIntOp(I,
ISD::OR);
1977 case Instruction::Sub:
1978 return SelectBinaryIntOp(I,
ISD::SUB);
1980 return selectCall(I);
1982 return SelectRet(I);
1983 case Instruction::Trunc:
1984 return SelectTrunc(I);
1985 case Instruction::ZExt:
1986 case Instruction::SExt:
1987 return SelectIntExt(I);
1999 unsigned PPCFastISel::PPCMaterializeFP(
const ConstantFP *CFP,
MVT VT) {
2005 unsigned Align = DL.getPrefTypeAlignment(CFP->
getType());
2006 assert(Align > 0 &&
"Unexpectedly missing alignment information!");
2007 unsigned Idx = MCP.getConstantPoolIndex(cast<Constant>(CFP), Align);
2008 const bool HasSPE = PPCSubTarget->hasSPE();
2011 RC = ((VT ==
MVT::f32) ? &PPC::SPE4RCRegClass : &PPC::SPERCRegClass);
2013 RC = ((VT ==
MVT::f32) ? &PPC::F4RCRegClass : &PPC::F8RCRegClass);
2015 unsigned DestReg = createResultReg(RC);
2025 Opc = ((VT ==
MVT::f32) ? PPC::SPELWZ : PPC::EVLDD);
2027 Opc = ((VT ==
MVT::f32) ? PPC::LFS : PPC::LFD);
2029 unsigned TmpReg = createResultReg(&PPC::G8RC_and_G8RC_NOX0RegClass);
2031 PPCFuncInfo->setUsesTOCBasePtr();
2034 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::LDtocCPT),
2036 .addConstantPoolIndex(Idx).
addReg(PPC::X2);
2037 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
2041 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::ADDIStocHA),
2046 unsigned TmpReg2 = createResultReg(&PPC::G8RC_and_G8RC_NOX0RegClass);
2047 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::LDtocL),
2048 TmpReg2).addConstantPoolIndex(Idx).
addReg(TmpReg);
2049 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
2053 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
2064 unsigned PPCFastISel::PPCMaterializeGV(
const GlobalValue *GV,
MVT VT) {
2067 unsigned DestReg = createResultReg(RC);
2082 PPCFuncInfo->setUsesTOCBasePtr();
2085 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::LDtoc),
2087 .addGlobalAddress(GV)
2098 unsigned HighPartReg = createResultReg(RC);
2099 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::ADDIStocHA),
2102 unsigned char GVFlags = PPCSubTarget->classifyGlobalReference(GV);
2104 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::LDtocL),
2105 DestReg).addGlobalAddress(GV).
addReg(HighPartReg);
2108 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::ADDItocL),
2118 unsigned PPCFastISel::PPCMaterialize32BitInt(int64_t Imm,
2120 unsigned Lo = Imm & 0xFFFF;
2121 unsigned Hi = (Imm >> 16) & 0xFFFF;
2123 unsigned ResultReg = createResultReg(RC);
2127 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2128 TII.get(IsGPRC ? PPC::LI : PPC::LI8), ResultReg)
2132 unsigned TmpReg = createResultReg(RC);
2133 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2134 TII.get(IsGPRC ? PPC::LIS : PPC::LIS8), TmpReg)
2136 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2137 TII.get(IsGPRC ? PPC::ORI : PPC::ORI8), ResultReg)
2138 .addReg(TmpReg).
addImm(Lo);
2141 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2142 TII.get(IsGPRC ? PPC::LIS : PPC::LIS8), ResultReg)
2150 unsigned PPCFastISel::PPCMaterialize64BitInt(int64_t Imm,
2152 unsigned Remainder = 0;
2158 Shift = countTrailingZeros<uint64_t>(Imm);
2159 int64_t ImmSh =
static_cast<uint64_t
>(Imm) >> Shift;
2172 unsigned TmpReg1 = PPCMaterialize32BitInt(Imm, RC);
2180 TmpReg2 = createResultReg(RC);
2181 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::RLDICR),
2182 TmpReg2).addReg(TmpReg1).
addImm(Shift).
addImm(63 - Shift);
2186 unsigned TmpReg3,
Hi,
Lo;
2187 if ((Hi = (Remainder >> 16) & 0xFFFF)) {
2188 TmpReg3 = createResultReg(RC);
2189 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::ORIS8),
2190 TmpReg3).addReg(TmpReg2).
addImm(Hi);
2194 if ((Lo = Remainder & 0xFFFF)) {
2195 unsigned ResultReg = createResultReg(RC);
2196 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::ORI8),
2197 ResultReg).addReg(TmpReg3).
addImm(Lo);
2206 unsigned PPCFastISel::PPCMaterializeInt(
const ConstantInt *CI,
MVT VT,
2210 if (VT ==
MVT::i1 && PPCSubTarget->useCRBits()) {
2211 unsigned ImmReg = createResultReg(&PPC::CRBITRCRegClass);
2212 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2213 TII.get(CI->
isZero() ? PPC::CRUNSET : PPC::CRSET), ImmReg);
2222 ((VT ==
MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass);
2230 unsigned Opc = (VT ==
MVT::i64) ? PPC::LI8 : PPC::LI;
2231 unsigned ImmReg = createResultReg(RC);
2232 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), ImmReg)
2239 return PPCMaterialize64BitInt(Imm, RC);
2241 return PPCMaterialize32BitInt(Imm, RC);
2248 unsigned PPCFastISel::fastMaterializeConstant(
const Constant *
C) {
2249 EVT CEVT = TLI.getValueType(DL, C->
getType(),
true);
2255 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(C))
2256 return PPCMaterializeFP(CFP, VT);
2257 else if (
const GlobalValue *GV = dyn_cast<GlobalValue>(C))
2258 return PPCMaterializeGV(GV, VT);
2259 else if (
const ConstantInt *CI = dyn_cast<ConstantInt>(C))
2265 return PPCMaterializeInt(CI, VT,
false);
2272 unsigned PPCFastISel::fastMaterializeAlloca(
const AllocaInst *AI) {
2274 if (!FuncInfo.StaticAllocaMap.count(AI))
return 0;
2277 if (!isLoadTypeLegal(AI->
getType(), VT))
return 0;
2280 FuncInfo.StaticAllocaMap.find(AI);
2282 if (SI != FuncInfo.StaticAllocaMap.
end()) {
2283 unsigned ResultReg = createResultReg(&PPC::G8RC_and_G8RC_NOX0RegClass);
2284 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::ADDI8),
2285 ResultReg).addFrameIndex(SI->second).
addImm(0);
2300 bool PPCFastISel::tryToFoldLoadIntoMI(
MachineInstr *
MI,
unsigned OpNo,
2304 if (!isLoadTypeLegal(LI->
getType(), VT))
2308 bool IsZExt =
false;
2314 case PPC::RLDICL_32_64: {
2317 if ((VT ==
MVT::i8 && MB <= 56) ||
2325 case PPC::RLWINM8: {
2328 if ((VT ==
MVT::i8 && MB <= 24) ||
2336 case PPC::EXTSB8_32_64:
2342 case PPC::EXTSH8_32_64: {
2350 case PPC::EXTSW_32_64: {
2359 if (!PPCComputeAddress(LI->
getOperand(0), Addr))
2364 if (!PPCEmitLoad(VT, ResultReg, Addr,
nullptr, IsZExt,
2365 PPCSubTarget->hasSPE() ? PPC::EVLDD : PPC::LFD))
2369 removeDeadCode(I, std::next(I));
2375 bool PPCFastISel::fastLowerArguments() {
2385 unsigned PPCFastISel::fastEmit_i(
MVT Ty,
MVT VT,
unsigned Opc, uint64_t Imm) {
2392 if (VT ==
MVT::i1 && PPCSubTarget->useCRBits()) {
2393 unsigned ImmReg = createResultReg(&PPC::CRBITRCRegClass);
2394 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2395 TII.get(Imm == 0 ? PPC::CRUNSET : PPC::CRSET), ImmReg);
2404 &PPC::GPRCRegClass);
2406 return PPCMaterialize64BitInt(Imm, RC);
2408 return PPCMaterialize32BitInt(Imm, RC);
2422 unsigned PPCFastISel::fastEmitInst_ri(
unsigned MachineInstOpcode,
2424 unsigned Op0,
bool Op0IsKill,
2426 if (MachineInstOpcode == PPC::ADDI)
2427 MRI.setRegClass(Op0, &PPC::GPRC_and_GPRC_NOR0RegClass);
2428 else if (MachineInstOpcode == PPC::ADDI8)
2429 MRI.setRegClass(Op0, &PPC::G8RC_and_G8RC_NOX0RegClass);
2432 (RC == &PPC::GPRCRegClass ? &PPC::GPRC_and_GPRC_NOR0RegClass :
2433 (RC == &PPC::G8RCRegClass ? &PPC::G8RC_and_G8RC_NOX0RegClass : RC));
2436 Op0, Op0IsKill, Imm);
2442 unsigned PPCFastISel::fastEmitInst_r(
unsigned MachineInstOpcode,
2444 unsigned Op0,
bool Op0IsKill) {
2446 (RC == &PPC::GPRCRegClass ? &PPC::GPRC_and_GPRC_NOR0RegClass :
2447 (RC == &PPC::G8RCRegClass ? &PPC::G8RC_and_G8RC_NOX0RegClass : RC));
2455 unsigned PPCFastISel::fastEmitInst_rr(
unsigned MachineInstOpcode,
2457 unsigned Op0,
bool Op0IsKill,
2458 unsigned Op1,
bool Op1IsKill) {
2460 (RC == &PPC::GPRCRegClass ? &PPC::GPRC_and_GPRC_NOR0RegClass :
2461 (RC == &PPC::G8RCRegClass ? &PPC::G8RC_and_G8RC_NOX0RegClass : RC));
2474 return new PPCFastISel(FuncInfo, LibInfo);
Return a value (possibly void), from a function.
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values i...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
FastISel * createFastISel(FunctionLoweringInfo &FuncInfo, const TargetLibraryInfo *LibInfo)
This class is the base class for the comparison instructions.
Newer FCTI[D,W]UZ floating-point-to-integer conversion instructions for unsigned integers with round ...
uint64_t getZExtValue() const
Get zero extended value.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool isPPC64() const
isPPC64 - Return true if we are generating code for 64-bit pointer mode.
bool isVector() const
Return true if this is a vector value type.
void push_back(const T &Elt)
unsigned getReg() const
getReg - Returns the register number.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change...
0 1 0 0 True if ordered and less than
unsigned getValNo() const
1 1 1 0 True if unordered or not equal
BasicBlock * getSuccessor(unsigned i) const
constexpr bool isInt< 16 >(int64_t x)
unsigned const TargetRegisterInfo * TRI
An instruction for reading from memory.
static IntegerType * getInt64Ty(LLVMContext &C)
Value * getCondition() const
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned char TargetFlags=0) const
void reserve(size_type N)
Newer FCFID[US] integer-to-floating-point conversion instructions for unsigned integers and single-pr...
1 0 0 1 True if unordered or equal
unsigned fastEmitInst_ri(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, uint64_t Imm)
Emit a MachineInstr with a register operand, an immediate, and a result register in the given registe...
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
A description of a memory reference used in the backend.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
PPCFunctionInfo - This class is derived from MachineFunction private PowerPC target-specific informat...
const HexagonInstrInfo * TII
PointerType * getType() const
Overload to return most specific pointer type.
Class to represent struct types.
A Use represents the edge between a Value definition and its users.
unsigned fastEmitInst_r(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill)
Emit a MachineInstr with one register operand and a result register in the given register class...
0 1 0 1 True if ordered and less than or equal
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
LocInfo getLocInfo() const
unsigned getID() const
Return the register class ID number.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
unsigned getSizeInBits() const
Fast - This calling convention attempts to make calls as fast as possible (e.g.
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
A constant value that is initialized with an expression using other constant values.
unsigned getNextStackOffset() const
getNextStackOffset - Return the next stack offset such that all stack slots satisfy their alignment r...
int64_t getSExtValue() const
Get sign extended value.
Type * getType() const
All values are typed, get the type of this value.
const T & getValue() const LLVM_LVALUE_FUNCTION
Simple integer binary arithmetic operators.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
amdgpu Simplify well known AMD library false Value * Callee
Value * getOperand(unsigned i) const
Flag
These should be considered private to the implementation of the MCInstrDesc class.
TargetInstrInfo - Interface to description of machine instruction set.
bool isVoidTy() const
Return true if this is 'void'.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
unsigned const MachineRegisterInfo * MRI
bool hasSuperClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This is an important class for using LLVM in a threaded context.
Conditional or Unconditional Branch instruction.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
MO_NLP_FLAG - If this bit is set, the symbol reference is actually to the non_lazy_ptr for the global...
Indirect Branch Instruction.
static ManagedStatic< OptionRegistry > OR
ConstantFP - Floating Point Values [float, double].
FCFID - The FCFID instruction, taking an f64 operand and producing and f64 value containing the FP re...
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
const PPCTargetLowering * getTargetLowering() const override
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
0 1 1 1 True if ordered (no nans)
GPRC, CHAIN = LFIWAX CHAIN, Ptr - This is a floating-point load which sign-extends from a 32-bit inte...
Class to represent integer types.
const MachineInstrBuilder & addFrameIndex(int Idx) const
1 1 1 1 Always true (always folded)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Type * getIndexedType() const
static bool isAtomic(Instruction *I)
1 1 0 1 True if unordered, less than, or equal
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
The memory access writes data.
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
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...
0 0 1 0 True if ordered and greater than
unsigned getNumOperands() const
StructType * getStructTypeOrNull() const
CCState - This class holds information needed while lowering arguments and return values...
This is the shared class of boolean and integer constants.
constexpr bool isInt< 32 >(int64_t x)
const PPCInstrInfo * getInstrInfo() const override
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
1 1 0 0 True if unordered or less than
Provides information about what library functions are available for the current target.
CCValAssign - Represent assignment of one arg/retval to a location.
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
const MachineInstrBuilder & addConstantPoolIndex(unsigned Idx, int Offset=0, unsigned char TargetFlags=0) const
unsigned fastEmitInst_rr(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill)
Emit a MachineInstr with two register operands and a result register in the given register class...
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Target - Wrapper for Target specific information.
Class for arbitrary precision integers.
This file defines the FastISel class.
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed v...
amdgpu Simplify well known AMD library false Value Value * Arg
The memory access reads data.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
Representation of each machine instruction.
Predicate InvertPredicate(Predicate Opcode)
Invert the specified predicate. != -> ==, < -> >=.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
uint64_t getElementOffset(unsigned Idx) const
unsigned greater or equal
const Function * getParent() const
Return the enclosing method, or null if none.
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values i...
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
0 1 1 0 True if ordered and operands are unequal
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
1 0 1 0 True if unordered or greater than
constexpr bool isUInt< 16 >(uint64_t x)
static MachinePointerInfo getConstantPool(MachineFunction &MF)
Return a MachinePointerInfo record that refers to the constant pool.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
0 0 0 1 True if ordered and equal
LLVM Value Representation.
1 0 1 1 True if unordered, greater than, or equal
Primary interface to the complete machine description for the target machine.
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
#define LLVM_ATTRIBUTE_UNUSED
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
unsigned getLocReg() const
FCTI[D,W]Z - The FCTIDZ and FCTIWZ instructions, taking an f32 or f64 operand, producing an f64 value...
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
static Optional< PPC::Predicate > getComparePred(CmpInst::Predicate Pred)
const MachineOperand & getOperand(unsigned i) const
0 0 1 1 True if ordered and greater than or equal
unsigned AllocateStack(unsigned Size, unsigned Align)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
GPRC, CHAIN = LFIWZX CHAIN, Ptr - This is a floating-point load which zero-extends from a 32-bit inte...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
0 0 0 0 Always false (always folded)
This file describes how to lower LLVM code to machine code.
const BasicBlock * getParent() const
an instruction to allocate memory on the stack
gep_type_iterator gep_type_begin(const User *GEP)