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();
865 bool NeedsExt =
false;
867 default:
return false;
871 default:
return false;
873 CmpOpc = PPC::EFSCMPEQ;
876 CmpOpc = PPC::EFSCMPLT;
879 CmpOpc = PPC::EFSCMPGT;
883 CmpOpc = PPC::FCMPUS;
888 default:
return false;
890 CmpOpc = PPC::EFDCMPEQ;
893 CmpOpc = PPC::EFDCMPLT;
896 CmpOpc = PPC::EFDCMPGT;
900 CmpOpc = PPC::FCMPUD;
909 CmpOpc = IsZExt ? PPC::CMPLW : PPC::CMPW;
911 CmpOpc = IsZExt ? PPC::CMPLWI : PPC::CMPWI;
915 CmpOpc = IsZExt ? PPC::CMPLD : PPC::CMPD;
917 CmpOpc = IsZExt ? PPC::CMPLDI : PPC::CMPDI;
921 unsigned SrcReg1 = getRegForValue(SrcValue1);
925 unsigned SrcReg2 = 0;
927 SrcReg2 = getRegForValue(SrcValue2);
933 unsigned ExtReg = createResultReg(&PPC::GPRCRegClass);
934 if (!PPCEmitIntExt(SrcVT, SrcReg1,
MVT::i32, ExtReg, IsZExt))
939 unsigned ExtReg = createResultReg(&PPC::GPRCRegClass);
940 if (!PPCEmitIntExt(SrcVT, SrcReg2,
MVT::i32, ExtReg, IsZExt))
947 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(CmpOpc), DestReg)
948 .addReg(SrcReg1).
addReg(SrcReg2);
950 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(CmpOpc), DestReg)
951 .addReg(SrcReg1).
addImm(Imm);
957 bool PPCFastISel::SelectFPExt(
const Instruction *I) {
959 EVT SrcVT = TLI.getValueType(DL, Src->
getType(),
true);
960 EVT DestVT = TLI.getValueType(DL, I->
getType(),
true);
965 unsigned SrcReg = getRegForValue(Src);
970 updateValueMap(I, SrcReg);
975 bool PPCFastISel::SelectFPTrunc(
const Instruction *I) {
977 EVT SrcVT = TLI.getValueType(DL, Src->
getType(),
true);
978 EVT DestVT = TLI.getValueType(DL, I->
getType(),
true);
983 unsigned SrcReg = getRegForValue(Src);
990 if (PPCSubTarget->hasSPE()) {
991 DestReg = createResultReg(&PPC::SPE4RCRegClass);
992 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
993 TII.get(PPC::EFSCFD), DestReg)
996 DestReg = createResultReg(&PPC::F4RCRegClass);
997 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
998 TII.get(PPC::FRSP), DestReg)
1002 updateValueMap(I, DestReg);
1013 unsigned PPCFastISel::PPCMoveToFPReg(
MVT SrcVT,
unsigned SrcReg,
1018 unsigned TmpReg = createResultReg(&PPC::G8RCRegClass);
1026 Addr.BaseType = Address::FrameIndexBase;
1027 Addr.Base.FI = MFI.CreateStackObject(8, 8,
false);
1030 if (!PPCEmitStore(
MVT::i64, SrcReg, Addr))
1035 unsigned LoadOpc = PPC::LFD;
1040 Addr.Offset = (PPCSubTarget->isLittleEndian()) ? 0 : 4;
1041 }
else if (PPCSubTarget->hasLFIWAX()) {
1043 Addr.Offset = (PPCSubTarget->isLittleEndian()) ? 0 : 4;
1048 unsigned ResultReg = 0;
1049 if (!PPCEmitLoad(
MVT::f64, ResultReg, Addr, RC, !IsSigned, LoadOpc))
1058 bool PPCFastISel::SelectIToFP(
const Instruction *I,
bool IsSigned) {
1061 if (!isTypeLegal(DstTy, DstVT))
1068 EVT SrcEVT = TLI.getValueType(DL, Src->
getType(),
true);
1078 unsigned SrcReg = getRegForValue(Src);
1083 if (PPCSubTarget->hasSPE()) {
1086 Opc = IsSigned ? PPC::EFSCFSI : PPC::EFSCFUI;
1088 Opc = IsSigned ? PPC::EFDCFSI : PPC::EFDCFUI;
1090 unsigned DestReg = createResultReg(&PPC::SPERCRegClass);
1092 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
1094 updateValueMap(I, DestReg);
1100 if (!IsSigned && !PPCSubTarget->hasFPCVT())
1108 if (DstVT ==
MVT::f32 && !PPCSubTarget->hasFPCVT())
1113 unsigned TmpReg = createResultReg(&PPC::G8RCRegClass);
1114 if (!PPCEmitIntExt(SrcVT, SrcReg,
MVT::i64, TmpReg, !IsSigned))
1121 unsigned FPReg = PPCMoveToFPReg(SrcVT, SrcReg, IsSigned);
1127 unsigned DestReg = createResultReg(RC);
1136 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
1139 updateValueMap(I, DestReg);
1148 unsigned PPCFastISel::PPCMoveToIntReg(
const Instruction *I,
MVT VT,
1149 unsigned SrcReg,
bool IsSigned) {
1155 Addr.BaseType = Address::FrameIndexBase;
1156 Addr.Base.FI = MFI.CreateStackObject(8, 8,
false);
1159 if (!PPCEmitStore(
MVT::f64, SrcReg, Addr))
1165 Addr.Offset = (PPCSubTarget->isLittleEndian()) ? 0 : 4;
1169 unsigned AssignedReg = FuncInfo.ValueMap[
I];
1171 AssignedReg ?
MRI.getRegClass(AssignedReg) :
nullptr;
1173 unsigned ResultReg = 0;
1174 if (!PPCEmitLoad(VT, ResultReg, Addr, RC, !IsSigned))
1183 bool PPCFastISel::SelectFPToI(
const Instruction *I,
bool IsSigned) {
1186 if (!isTypeLegal(DstTy, DstVT))
1193 if (DstVT ==
MVT::i64 && !IsSigned &&
1194 !PPCSubTarget->hasFPCVT() && !PPCSubTarget->hasSPE())
1199 if (!isTypeLegal(SrcTy, SrcVT))
1205 unsigned SrcReg = getRegForValue(Src);
1212 if (InRC == &PPC::F4RCRegClass) {
1213 unsigned TmpReg = createResultReg(&PPC::F8RCRegClass);
1214 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1215 TII.get(TargetOpcode::COPY), TmpReg)
1225 if (PPCSubTarget->hasSPE()) {
1226 DestReg = createResultReg(&PPC::GPRCRegClass);
1228 Opc = InRC == &PPC::SPE4RCRegClass ? PPC::EFSCTSIZ : PPC::EFDCTSIZ;
1230 Opc = InRC == &PPC::SPE4RCRegClass ? PPC::EFSCTUIZ : PPC::EFDCTUIZ;
1232 DestReg = createResultReg(&PPC::F8RCRegClass);
1243 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
1247 unsigned IntReg = PPCSubTarget->hasSPE() ? DestReg :
1248 PPCMoveToIntReg(I, DstVT, DestReg, IsSigned);
1253 updateValueMap(I, IntReg);
1259 bool PPCFastISel::SelectBinaryIntOp(
const Instruction *I,
unsigned ISDOpcode) {
1260 EVT DestVT = TLI.getValueType(DL, I->
getType(),
true);
1270 unsigned AssignedReg = FuncInfo.ValueMap[
I];
1272 (AssignedReg ?
MRI.getRegClass(AssignedReg) :
1273 &PPC::GPRC_and_GPRC_NOR0RegClass);
1277 switch (ISDOpcode) {
1278 default:
return false;
1280 Opc = IsGPRC ? PPC::ADD4 : PPC::ADD8;
1283 Opc = IsGPRC ?
PPC::OR : PPC::OR8;
1286 Opc = IsGPRC ? PPC::SUBF : PPC::SUBF8;
1290 unsigned ResultReg = createResultReg(RC ? RC : &PPC::G8RCRegClass);
1291 unsigned SrcReg1 = getRegForValue(I->
getOperand(0));
1292 if (SrcReg1 == 0)
return false;
1296 const APInt &CIVal = ConstInt->getValue();
1305 MRI.setRegClass(SrcReg1, &PPC::GPRC_and_GPRC_NOR0RegClass);
1309 MRI.setRegClass(SrcReg1, &PPC::G8RC_and_G8RC_NOX0RegClass);
1322 MRI.setRegClass(SrcReg1, &PPC::GPRC_and_GPRC_NOR0RegClass);
1331 MRI.setRegClass(SrcReg1, &PPC::G8RC_and_G8RC_NOX0RegClass);
1338 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc),
1342 updateValueMap(I, ResultReg);
1349 unsigned SrcReg2 = getRegForValue(I->
getOperand(1));
1350 if (SrcReg2 == 0)
return false;
1356 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), ResultReg)
1357 .addReg(SrcReg1).
addReg(SrcReg2);
1358 updateValueMap(I, ResultReg);
1376 unsigned LinkageSize = PPCSubTarget->getFrameLowering()->getLinkageSize();
1382 for (
unsigned I = 0,
E = ArgLocs.
size(); I !=
E; ++
I) {
1406 NumBytes =
std::max(NumBytes, LinkageSize + 64);
1409 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1410 TII.get(
TII.getCallFrameSetupOpcode()))
1416 unsigned NextGPR = PPC::X3;
1417 unsigned NextFPR = PPC::F1;
1420 for (
unsigned I = 0,
E = ArgLocs.
size(); I !=
E; ++
I) {
1434 (DestVT ==
MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
1435 unsigned TmpReg = createResultReg(RC);
1436 if (!PPCEmitIntExt(ArgVT, Arg, DestVT, TmpReg,
false))
1446 (DestVT ==
MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
1447 unsigned TmpReg = createResultReg(RC);
1448 if (!PPCEmitIntExt(ArgVT, Arg, DestVT, TmpReg,
true))
1470 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1471 TII.get(TargetOpcode::COPY), ArgReg).addReg(Arg);
1480 bool PPCFastISel::finishCall(
MVT RetVT, CallLoweringInfo &CLI,
unsigned &NumBytes) {
1484 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1485 TII.get(
TII.getCallFrameDestroyOpcode()))
1496 assert(RVLocs.
size() == 1 &&
"No support for multi-reg return values!");
1500 MVT CopyVT = DestVT;
1507 unsigned SourcePhysReg = VA.
getLocReg();
1508 unsigned ResultReg = 0;
1510 if (RetVT == CopyVT) {
1512 ResultReg = createResultReg(CpyRC);
1514 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1515 TII.get(TargetOpcode::COPY), ResultReg)
1516 .addReg(SourcePhysReg);
1520 ResultReg = createResultReg(TLI.getRegClassFor(RetVT));
1521 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::FRSP),
1522 ResultReg).addReg(SourcePhysReg);
1529 ResultReg = createResultReg(&PPC::GPRCRegClass);
1531 SourcePhysReg -= PPC::X0 - PPC::R0;
1532 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1533 TII.get(TargetOpcode::COPY), ResultReg)
1534 .addReg(SourcePhysReg);
1537 assert(ResultReg &&
"ResultReg unset!");
1538 CLI.InRegs.push_back(SourcePhysReg);
1539 CLI.ResultReg = ResultReg;
1540 CLI.NumResultRegs = 1;
1546 bool PPCFastISel::fastLowerCall(CallLoweringInfo &CLI) {
1548 bool IsTailCall = CLI.IsTailCall;
1549 bool IsVarArg = CLI.IsVarArg;
1553 if (!Callee && !Symbol)
1566 Type *RetTy = CLI.RetTy;
1570 else if (!isTypeLegal(RetTy, RetVT) && RetVT !=
MVT::i16 &&
1573 else if (RetVT ==
MVT::i1 && PPCSubTarget->useCRBits())
1584 if (RVLocs.
size() > 1)
1590 unsigned NumArgs = CLI.OutVals.size();
1605 for (
unsigned i = 0, ie = NumArgs; i != ie; ++i) {
1613 Value *ArgValue = CLI.OutVals[i];
1616 if (!isTypeLegal(ArgTy, ArgVT) && ArgVT !=
MVT::i16 && ArgVT !=
MVT::i8)
1622 unsigned Arg = getRegForValue(ArgValue);
1636 if (!processCallArgs(Args, ArgRegs, ArgVTs, ArgFlags,
1637 RegArgs, CC, NumBytes, IsVarArg))
1650 if (CLI.IsPatchPoint)
1651 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::NOP));
1657 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1658 TII.get(PPC::BL8_NOP));
1664 for (
unsigned II = 0,
IE = RegArgs.
size(); II !=
IE; ++II)
1669 PPCFuncInfo->setUsesTOCBasePtr();
1679 return finishCall(RetVT, CLI, NumBytes);
1683 bool PPCFastISel::SelectRet(
const Instruction *I) {
1685 if (!FuncInfo.CanLowerReturn)
1688 if (TLI.supportSplitCSR(FuncInfo.MF))
1700 GetReturnInfo(CC, F.getReturnType(), F.getAttributes(), Outs, TLI, DL);
1704 CCState CCInfo(CC, F.isVarArg(), *FuncInfo.MF, ValLocs, *
Context);
1709 if (ValLocs.size() > 1)
1714 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(RV)) {
1725 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1726 TII.get(TargetOpcode::COPY), RetReg).addReg(SrcReg);
1731 unsigned Reg = getRegForValue(RV);
1737 for (
unsigned i = 0; i < ValLocs.size(); ++i) {
1742 unsigned SrcReg = Reg + VA.
getValNo();
1744 EVT RVEVT = TLI.getValueType(DL, RV->
getType());
1750 if (RVVT != DestVT && RVVT !=
MVT::i8 &&
1754 if (RVVT != DestVT) {
1763 (DestVT ==
MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
1764 unsigned TmpReg = createResultReg(RC);
1765 if (!PPCEmitIntExt(RVVT, SrcReg, DestVT, TmpReg,
true))
1772 (DestVT ==
MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass;
1773 unsigned TmpReg = createResultReg(RC);
1774 if (!PPCEmitIntExt(RVVT, SrcReg, DestVT, TmpReg,
false))
1782 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1783 TII.get(TargetOpcode::COPY), RetRegs[i])
1790 TII.get(PPC::BLR8));
1792 for (
unsigned i = 0, e = RetRegs.
size(); i != e; ++i)
1801 bool PPCFastISel::PPCEmitIntExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
1802 unsigned DestReg,
bool IsZExt) {
1812 Opc = (DestVT ==
MVT::i32) ? PPC::EXTSB : PPC::EXTSB8_32_64;
1814 Opc = (DestVT ==
MVT::i32) ? PPC::EXTSH : PPC::EXTSH8_32_64;
1817 Opc = PPC::EXTSW_32_64;
1819 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
1828 assert(SrcVT ==
MVT::i16 &&
"Unsigned extend from i32 to i32??");
1831 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::RLWINM),
1844 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1845 TII.get(PPC::RLDICL_32_64), DestReg)
1853 bool PPCFastISel::SelectIndirectBr(
const Instruction *I) {
1854 unsigned AddrReg = getRegForValue(I->
getOperand(0));
1858 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::MTCTR8))
1860 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::BCTR8));
1863 for (
const BasicBlock *SuccBB : IB->successors())
1864 FuncInfo.MBB->addSuccessor(FuncInfo.MBBMap[SuccBB]);
1870 bool PPCFastISel::SelectTrunc(
const Instruction *I) {
1872 EVT SrcVT = TLI.getValueType(DL, Src->
getType(),
true);
1873 EVT DestVT = TLI.getValueType(DL, I->
getType(),
true);
1881 unsigned SrcReg = getRegForValue(Src);
1887 unsigned ResultReg = createResultReg(&PPC::GPRCRegClass);
1888 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1889 TII.get(TargetOpcode::COPY),
1890 ResultReg).addReg(SrcReg, 0, PPC::sub_32);
1894 updateValueMap(I, SrcReg);
1899 bool PPCFastISel::SelectIntExt(
const Instruction *I) {
1904 bool IsZExt = isa<ZExtInst>(
I);
1905 unsigned SrcReg = getRegForValue(Src);
1906 if (!SrcReg)
return false;
1908 EVT SrcEVT, DestEVT;
1909 SrcEVT = TLI.getValueType(DL, SrcTy,
true);
1910 DestEVT = TLI.getValueType(DL, DestTy,
true);
1923 unsigned AssignedReg = FuncInfo.ValueMap[
I];
1925 (AssignedReg ?
MRI.getRegClass(AssignedReg) :
1926 (DestVT ==
MVT::i64 ? &PPC::G8RC_and_G8RC_NOX0RegClass :
1927 &PPC::GPRC_and_GPRC_NOR0RegClass));
1928 unsigned ResultReg = createResultReg(RC);
1930 if (!PPCEmitIntExt(SrcVT, SrcReg, DestVT, ResultReg, IsZExt))
1933 updateValueMap(I, ResultReg);
1939 bool PPCFastISel::fastSelectInstruction(
const Instruction *I) {
1943 return SelectLoad(I);
1945 return SelectStore(I);
1946 case Instruction::Br:
1947 return SelectBranch(I);
1948 case Instruction::IndirectBr:
1949 return SelectIndirectBr(I);
1950 case Instruction::FPExt:
1951 return SelectFPExt(I);
1952 case Instruction::FPTrunc:
1953 return SelectFPTrunc(I);
1954 case Instruction::SIToFP:
1955 return SelectIToFP(I,
true);
1956 case Instruction::UIToFP:
1957 return SelectIToFP(I,
false);
1958 case Instruction::FPToSI:
1959 return SelectFPToI(I,
true);
1960 case Instruction::FPToUI:
1961 return SelectFPToI(I,
false);
1963 return SelectBinaryIntOp(I,
ISD::ADD);
1964 case Instruction::Or:
1965 return SelectBinaryIntOp(I,
ISD::OR);
1966 case Instruction::Sub:
1967 return SelectBinaryIntOp(I,
ISD::SUB);
1969 return selectCall(I);
1971 return SelectRet(I);
1972 case Instruction::Trunc:
1973 return SelectTrunc(I);
1974 case Instruction::ZExt:
1975 case Instruction::SExt:
1976 return SelectIntExt(I);
1988 unsigned PPCFastISel::PPCMaterializeFP(
const ConstantFP *CFP,
MVT VT) {
1994 unsigned Align = DL.getPrefTypeAlignment(CFP->
getType());
1995 assert(Align > 0 &&
"Unexpectedly missing alignment information!");
1996 unsigned Idx = MCP.getConstantPoolIndex(cast<Constant>(CFP), Align);
1997 const bool HasSPE = PPCSubTarget->hasSPE();
2000 RC = ((VT ==
MVT::f32) ? &PPC::SPE4RCRegClass : &PPC::SPERCRegClass);
2002 RC = ((VT ==
MVT::f32) ? &PPC::F4RCRegClass : &PPC::F8RCRegClass);
2004 unsigned DestReg = createResultReg(RC);
2014 Opc = ((VT ==
MVT::f32) ? PPC::SPELWZ : PPC::EVLDD);
2016 Opc = ((VT ==
MVT::f32) ? PPC::LFS : PPC::LFD);
2018 unsigned TmpReg = createResultReg(&PPC::G8RC_and_G8RC_NOX0RegClass);
2020 PPCFuncInfo->setUsesTOCBasePtr();
2023 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::LDtocCPT),
2025 .addConstantPoolIndex(Idx).
addReg(PPC::X2);
2026 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
2030 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::ADDIStocHA),
2035 unsigned TmpReg2 = createResultReg(&PPC::G8RC_and_G8RC_NOX0RegClass);
2036 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::LDtocL),
2037 TmpReg2).addConstantPoolIndex(Idx).
addReg(TmpReg);
2038 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
2042 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
2053 unsigned PPCFastISel::PPCMaterializeGV(
const GlobalValue *GV,
MVT VT) {
2056 unsigned DestReg = createResultReg(RC);
2071 PPCFuncInfo->setUsesTOCBasePtr();
2074 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::LDtoc),
2076 .addGlobalAddress(GV)
2087 unsigned HighPartReg = createResultReg(RC);
2088 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::ADDIStocHA),
2091 unsigned char GVFlags = PPCSubTarget->classifyGlobalReference(GV);
2093 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::LDtocL),
2094 DestReg).addGlobalAddress(GV).
addReg(HighPartReg);
2097 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::ADDItocL),
2107 unsigned PPCFastISel::PPCMaterialize32BitInt(int64_t Imm,
2109 unsigned Lo = Imm & 0xFFFF;
2110 unsigned Hi = (Imm >> 16) & 0xFFFF;
2112 unsigned ResultReg = createResultReg(RC);
2116 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2117 TII.get(IsGPRC ? PPC::LI : PPC::LI8), ResultReg)
2121 unsigned TmpReg = createResultReg(RC);
2122 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2123 TII.get(IsGPRC ? PPC::LIS : PPC::LIS8), TmpReg)
2125 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2126 TII.get(IsGPRC ? PPC::ORI : PPC::ORI8), ResultReg)
2127 .addReg(TmpReg).
addImm(Lo);
2130 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2131 TII.get(IsGPRC ? PPC::LIS : PPC::LIS8), ResultReg)
2139 unsigned PPCFastISel::PPCMaterialize64BitInt(int64_t Imm,
2141 unsigned Remainder = 0;
2147 Shift = countTrailingZeros<uint64_t>(Imm);
2148 int64_t ImmSh =
static_cast<uint64_t
>(Imm) >> Shift;
2161 unsigned TmpReg1 = PPCMaterialize32BitInt(Imm, RC);
2169 TmpReg2 = createResultReg(RC);
2170 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::RLDICR),
2171 TmpReg2).addReg(TmpReg1).
addImm(Shift).
addImm(63 - Shift);
2175 unsigned TmpReg3,
Hi,
Lo;
2176 if ((Hi = (Remainder >> 16) & 0xFFFF)) {
2177 TmpReg3 = createResultReg(RC);
2178 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::ORIS8),
2179 TmpReg3).addReg(TmpReg2).
addImm(Hi);
2183 if ((Lo = Remainder & 0xFFFF)) {
2184 unsigned ResultReg = createResultReg(RC);
2185 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::ORI8),
2186 ResultReg).addReg(TmpReg3).
addImm(Lo);
2195 unsigned PPCFastISel::PPCMaterializeInt(
const ConstantInt *CI,
MVT VT,
2199 if (VT ==
MVT::i1 && PPCSubTarget->useCRBits()) {
2200 unsigned ImmReg = createResultReg(&PPC::CRBITRCRegClass);
2201 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2202 TII.get(CI->
isZero() ? PPC::CRUNSET : PPC::CRSET), ImmReg);
2211 ((VT ==
MVT::i64) ? &PPC::G8RCRegClass : &PPC::GPRCRegClass);
2219 unsigned Opc = (VT ==
MVT::i64) ? PPC::LI8 : PPC::LI;
2220 unsigned ImmReg = createResultReg(RC);
2221 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), ImmReg)
2228 return PPCMaterialize64BitInt(Imm, RC);
2230 return PPCMaterialize32BitInt(Imm, RC);
2237 unsigned PPCFastISel::fastMaterializeConstant(
const Constant *
C) {
2238 EVT CEVT = TLI.getValueType(DL, C->
getType(),
true);
2244 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(C))
2245 return PPCMaterializeFP(CFP, VT);
2246 else if (
const GlobalValue *GV = dyn_cast<GlobalValue>(C))
2247 return PPCMaterializeGV(GV, VT);
2248 else if (
const ConstantInt *CI = dyn_cast<ConstantInt>(C))
2254 return PPCMaterializeInt(CI, VT,
false);
2261 unsigned PPCFastISel::fastMaterializeAlloca(
const AllocaInst *AI) {
2263 if (!FuncInfo.StaticAllocaMap.count(AI))
return 0;
2266 if (!isLoadTypeLegal(AI->
getType(), VT))
return 0;
2269 FuncInfo.StaticAllocaMap.find(AI);
2271 if (SI != FuncInfo.StaticAllocaMap.
end()) {
2272 unsigned ResultReg = createResultReg(&PPC::G8RC_and_G8RC_NOX0RegClass);
2273 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(PPC::ADDI8),
2274 ResultReg).addFrameIndex(SI->second).
addImm(0);
2289 bool PPCFastISel::tryToFoldLoadIntoMI(
MachineInstr *
MI,
unsigned OpNo,
2293 if (!isLoadTypeLegal(LI->
getType(), VT))
2297 bool IsZExt =
false;
2303 case PPC::RLDICL_32_64: {
2306 if ((VT ==
MVT::i8 && MB <= 56) ||
2314 case PPC::RLWINM8: {
2317 if ((VT ==
MVT::i8 && MB <= 24) ||
2325 case PPC::EXTSB8_32_64:
2331 case PPC::EXTSH8_32_64: {
2339 case PPC::EXTSW_32_64: {
2348 if (!PPCComputeAddress(LI->
getOperand(0), Addr))
2353 if (!PPCEmitLoad(VT, ResultReg, Addr,
nullptr, IsZExt,
2354 PPCSubTarget->hasSPE() ? PPC::EVLDD : PPC::LFD))
2363 bool PPCFastISel::fastLowerArguments() {
2373 unsigned PPCFastISel::fastEmit_i(
MVT Ty,
MVT VT,
unsigned Opc, uint64_t Imm) {
2380 if (VT ==
MVT::i1 && PPCSubTarget->useCRBits()) {
2381 unsigned ImmReg = createResultReg(&PPC::CRBITRCRegClass);
2382 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2383 TII.get(Imm == 0 ? PPC::CRUNSET : PPC::CRSET), ImmReg);
2392 &PPC::GPRCRegClass);
2394 return PPCMaterialize64BitInt(Imm, RC);
2396 return PPCMaterialize32BitInt(Imm, RC);
2410 unsigned PPCFastISel::fastEmitInst_ri(
unsigned MachineInstOpcode,
2412 unsigned Op0,
bool Op0IsKill,
2414 if (MachineInstOpcode == PPC::ADDI)
2415 MRI.setRegClass(Op0, &PPC::GPRC_and_GPRC_NOR0RegClass);
2416 else if (MachineInstOpcode == PPC::ADDI8)
2417 MRI.setRegClass(Op0, &PPC::G8RC_and_G8RC_NOX0RegClass);
2420 (RC == &PPC::GPRCRegClass ? &PPC::GPRC_and_GPRC_NOR0RegClass :
2421 (RC == &PPC::G8RCRegClass ? &PPC::G8RC_and_G8RC_NOX0RegClass : RC));
2424 Op0, Op0IsKill, Imm);
2430 unsigned PPCFastISel::fastEmitInst_r(
unsigned MachineInstOpcode,
2432 unsigned Op0,
bool Op0IsKill) {
2434 (RC == &PPC::GPRCRegClass ? &PPC::GPRC_and_GPRC_NOR0RegClass :
2435 (RC == &PPC::G8RCRegClass ? &PPC::G8RC_and_G8RC_NOX0RegClass : RC));
2443 unsigned PPCFastISel::fastEmitInst_rr(
unsigned MachineInstOpcode,
2445 unsigned Op0,
bool Op0IsKill,
2446 unsigned Op1,
bool Op1IsKill) {
2448 (RC == &PPC::GPRCRegClass ? &PPC::GPRC_and_GPRC_NOR0RegClass :
2449 (RC == &PPC::G8RCRegClass ? &PPC::G8RC_and_G8RC_NOX0RegClass : RC));
2462 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...
void push_back(const T &Elt)
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)
Compute iterated dominance frontiers using a linear time algorithm.
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.
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.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
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
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
Fast - This calling convention attempts to make calls as fast as possible (e.g.
#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...
#define LLVM_ATTRIBUTE_UNUSED
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.
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.
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)