108 class ARMFastISel final :
public FastISel {
129 TM(funcInfo.MF->getTarget()), TII(*Subtarget->getInstrInfo()),
130 TLI(*Subtarget->getTargetLowering()) {
139 unsigned fastEmitInst_r(
unsigned MachineInstOpcode,
141 unsigned Op0,
bool Op0IsKill);
142 unsigned fastEmitInst_rr(
unsigned MachineInstOpcode,
144 unsigned Op0,
bool Op0IsKill,
145 unsigned Op1,
bool Op1IsKill);
146 unsigned fastEmitInst_ri(
unsigned MachineInstOpcode,
148 unsigned Op0,
bool Op0IsKill,
150 unsigned fastEmitInst_i(
unsigned MachineInstOpcode,
156 bool fastSelectInstruction(
const Instruction *
I)
override;
157 unsigned fastMaterializeConstant(
const Constant *
C)
override;
158 unsigned fastMaterializeAlloca(
const AllocaInst *AI)
override;
161 bool fastLowerArguments()
override;
163 #include "ARMGenFastISel.inc" 174 bool SelectBinaryIntOp(
const Instruction *
I,
unsigned ISDOpcode);
175 bool SelectBinaryFPOp(
const Instruction *
I,
unsigned ISDOpcode);
180 bool SelectCall(
const Instruction *
I,
const char *IntrMemName);
190 bool isPositionIndependent()
const;
191 bool isTypeLegal(
Type *Ty,
MVT &VT);
192 bool isLoadTypeLegal(
Type *Ty,
MVT &VT);
193 bool ARMEmitCmp(
const Value *Src1Value,
const Value *Src2Value,
196 unsigned Alignment = 0,
bool isZExt =
true,
197 bool allocReg =
true);
198 bool ARMEmitStore(
MVT VT,
unsigned SrcReg,
Address &Addr,
199 unsigned Alignment = 0);
200 bool ARMComputeAddress(
const Value *Obj,
Address &Addr);
201 void ARMSimplifyAddress(
Address &Addr,
MVT VT,
bool useAM3);
202 bool ARMIsMemCpySmall(uint64_t Len);
203 bool ARMTryEmitSmallMemCpy(
Address Dest,
Address Src, uint64_t Len,
205 unsigned ARMEmitIntExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
bool isZExt);
209 unsigned ARMMoveToFPReg(
MVT VT,
unsigned SrcReg);
210 unsigned ARMMoveToIntReg(
MVT VT,
unsigned SrcReg);
211 unsigned ARMSelectCallOp(
bool UseReg);
229 unsigned getLibcallReg(
const Twine &
Name);
232 unsigned &NumBytes,
bool isVarArg);
240 void AddLoadStoreOperands(
MVT VT,
Address &Addr,
250 bool ARMFastISel::DefinesOptionalPredicate(
MachineInstr *
MI,
bool *CPSR) {
256 if (!MO.isReg() || !MO.isDef())
continue;
257 if (MO.getReg() == ARM::CPSR)
263 bool ARMFastISel::isARMNEONPred(
const MachineInstr *MI) {
272 if (opInfo.isPredicate())
290 if (isARMNEONPred(MI))
296 if (DefinesOptionalPredicate(MI, &CPSR))
301 unsigned ARMFastISel::fastEmitInst_r(
unsigned MachineInstOpcode,
303 unsigned Op0,
bool Op0IsKill) {
304 Register ResultReg = createResultReg(RC);
311 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II,
314 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
316 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
317 TII.
get(TargetOpcode::COPY), ResultReg)
323 unsigned ARMFastISel::fastEmitInst_rr(
unsigned MachineInstOpcode,
325 unsigned Op0,
bool Op0IsKill,
326 unsigned Op1,
bool Op1IsKill) {
327 unsigned ResultReg = createResultReg(RC);
337 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, ResultReg)
338 .
addReg(Op0, Op0IsKill * RegState::Kill)
339 .
addReg(Op1, Op1IsKill * RegState::Kill));
341 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
342 .
addReg(Op0, Op0IsKill * RegState::Kill)
343 .
addReg(Op1, Op1IsKill * RegState::Kill));
344 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
345 TII.
get(TargetOpcode::COPY), ResultReg)
351 unsigned ARMFastISel::fastEmitInst_ri(
unsigned MachineInstOpcode,
353 unsigned Op0,
bool Op0IsKill,
355 unsigned ResultReg = createResultReg(RC);
363 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, ResultReg)
364 .
addReg(Op0, Op0IsKill * RegState::Kill)
367 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
368 .
addReg(Op0, Op0IsKill * RegState::Kill)
370 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
371 TII.
get(TargetOpcode::COPY), ResultReg)
377 unsigned ARMFastISel::fastEmitInst_i(
unsigned MachineInstOpcode,
380 unsigned ResultReg = createResultReg(RC);
384 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II,
387 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
389 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
390 TII.
get(TargetOpcode::COPY), ResultReg)
398 unsigned ARMFastISel::ARMMoveToFPReg(
MVT VT,
unsigned SrcReg) {
402 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
408 unsigned ARMFastISel::ARMMoveToIntReg(
MVT VT,
unsigned SrcReg) {
412 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
421 unsigned ARMFastISel::ARMMaterializeFP(
const ConstantFP *CFP,
MVT VT) {
438 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
439 TII.
get(Opc), DestReg).addImm(Imm));
444 if (!Subtarget->hasVFP2Base())
return false;
447 unsigned Align = DL.getPrefTypeAlignment(CFP->
getType());
450 Align = DL.getTypeAllocSize(CFP->
getType());
452 unsigned Idx = MCP.getConstantPoolIndex(cast<Constant>(CFP), Align);
454 unsigned Opc = is64bit ? ARM::VLDRD : ARM::VLDRS;
458 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(Opc), DestReg)
459 .addConstantPoolIndex(Idx)
464 unsigned ARMFastISel::ARMMaterializeInt(
const Constant *
C,
MVT VT) {
472 unsigned Opc = isThumb2 ? ARM::t2MOVi16 : ARM::MOVi16;
475 unsigned ImmReg = createResultReg(RC);
476 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
477 TII.
get(Opc), ImmReg)
488 unsigned Opc = isThumb2 ? ARM::t2MVNi : ARM::MVNi;
491 unsigned ImmReg = createResultReg(RC);
492 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
493 TII.
get(Opc), ImmReg)
499 unsigned ResultReg = 0;
500 if (Subtarget->useMovt())
511 unsigned Align = DL.getPrefTypeAlignment(C->
getType());
514 Align = DL.getTypeAllocSize(C->
getType());
516 unsigned Idx = MCP.getConstantPoolIndex(C, Align);
519 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
520 TII.
get(ARM::t2LDRpci), ResultReg)
521 .addConstantPoolIndex(Idx));
525 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
526 TII.
get(ARM::LDRcp), ResultReg)
527 .addConstantPoolIndex(Idx)
533 bool ARMFastISel::isPositionIndependent()
const {
537 unsigned ARMFastISel::ARMMaterializeGV(
const GlobalValue *GV,
MVT VT) {
542 if (Subtarget->isROPI() || Subtarget->isRWPI())
545 bool IsIndirect = Subtarget->isGVIndirectSymbol(GV);
548 unsigned DestReg = createResultReg(RC);
553 if (!Subtarget->isTargetMachO() && IsThreadLocal)
return 0;
555 bool IsPositionIndependent = isPositionIndependent();
558 if (Subtarget->useMovt() &&
559 (Subtarget->isTargetMachO() || !IsPositionIndependent)) {
561 unsigned char TF = 0;
562 if (Subtarget->isTargetMachO())
565 if (IsPositionIndependent)
566 Opc = isThumb2 ? ARM::t2MOV_ga_pcrel : ARM::MOV_ga_pcrel;
568 Opc = isThumb2 ? ARM::t2MOVi32imm : ARM::MOVi32imm;
569 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
570 TII.
get(Opc), DestReg).addGlobalAddress(GV, 0, TF));
573 unsigned Align = DL.getPrefTypeAlignment(GV->
getType());
576 Align = DL.getTypeAllocSize(GV->
getType());
579 if (Subtarget->isTargetELF() && IsPositionIndependent)
580 return ARMLowerPICELF(GV, Align, VT);
583 unsigned PCAdj = IsPositionIndependent ? (Subtarget->isThumb() ? 4 : 8) : 0;
588 unsigned Idx = MCP.getConstantPoolIndex(CPV, Align);
593 unsigned Opc = IsPositionIndependent ? ARM::t2LDRpci_pic : ARM::t2LDRpci;
594 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(Opc),
595 DestReg).addConstantPoolIndex(Idx);
596 if (IsPositionIndependent)
598 AddOptionalDefs(MIB);
602 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
603 TII.
get(ARM::LDRcp), DestReg)
604 .addConstantPoolIndex(Idx)
606 AddOptionalDefs(MIB);
608 if (IsPositionIndependent) {
609 unsigned Opc = IsIndirect ? ARM::PICLDR : ARM::PICADD;
613 DbgLoc, TII.
get(Opc), NewDestReg)
616 AddOptionalDefs(MIB);
626 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
627 TII.
get(ARM::t2LDRi12), NewDestReg)
631 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
632 TII.
get(ARM::LDRi12), NewDestReg)
635 DestReg = NewDestReg;
636 AddOptionalDefs(MIB);
642 unsigned ARMFastISel::fastMaterializeConstant(
const Constant *C) {
649 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(C))
650 return ARMMaterializeFP(CFP, VT);
651 else if (
const GlobalValue *GV = dyn_cast<GlobalValue>(C))
652 return ARMMaterializeGV(GV, VT);
653 else if (isa<ConstantInt>(C))
654 return ARMMaterializeInt(C, VT);
661 unsigned ARMFastISel::fastMaterializeAlloca(
const AllocaInst *AI) {
663 if (!FuncInfo.StaticAllocaMap.count(AI))
return 0;
666 if (!isLoadTypeLegal(AI->
getType(), VT))
return 0;
669 FuncInfo.StaticAllocaMap.find(AI);
673 if (SI != FuncInfo.StaticAllocaMap.
end()) {
674 unsigned Opc = isThumb2 ? ARM::t2ADDri : ARM::ADDri;
676 unsigned ResultReg = createResultReg(RC);
679 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
680 TII.
get(Opc), ResultReg)
681 .addFrameIndex(SI->second)
689 bool ARMFastISel::isTypeLegal(
Type *Ty,
MVT &VT) {
701 bool ARMFastISel::isLoadTypeLegal(
Type *Ty,
MVT &VT) {
702 if (isTypeLegal(Ty, VT))
return true;
713 bool ARMFastISel::ARMComputeAddress(
const Value *Obj,
Address &Addr) {
715 const User *U =
nullptr;
716 unsigned Opcode = Instruction::UserOp1;
717 if (
const Instruction *
I = dyn_cast<Instruction>(Obj)) {
720 if (FuncInfo.StaticAllocaMap.count(static_cast<const AllocaInst *>(Obj)) ||
721 FuncInfo.MBBMap[
I->getParent()] == FuncInfo.MBB) {
722 Opcode =
I->getOpcode();
725 }
else if (
const ConstantExpr *C = dyn_cast<ConstantExpr>(Obj)) {
726 Opcode = C->getOpcode();
731 if (Ty->getAddressSpace() > 255)
739 case Instruction::BitCast:
741 return ARMComputeAddress(U->
getOperand(0), Addr);
742 case Instruction::IntToPtr:
746 return ARMComputeAddress(U->
getOperand(0), Addr);
748 case Instruction::PtrToInt:
751 return ARMComputeAddress(U->
getOperand(0), Addr);
753 case Instruction::GetElementPtr: {
755 int TmpOffset = Addr.Offset;
761 i !=
e; ++i, ++GTI) {
765 unsigned Idx = cast<ConstantInt>(
Op)->getZExtValue();
770 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(Op)) {
775 if (canFoldAddIntoGEP(U, Op)) {
778 cast<ConstantInt>(cast<AddOperator>(
Op)->getOperand(1));
781 Op = cast<AddOperator>(
Op)->getOperand(0);
785 goto unsupported_gep;
791 Addr.Offset = TmpOffset;
792 if (ARMComputeAddress(U->
getOperand(0), Addr))
return true;
800 case Instruction::Alloca: {
803 FuncInfo.StaticAllocaMap.
find(AI);
804 if (SI != FuncInfo.StaticAllocaMap.end()) {
805 Addr.BaseType = Address::FrameIndexBase;
806 Addr.Base.FI = SI->second;
814 if (Addr.Base.Reg == 0) Addr.Base.Reg = getRegForValue(Obj);
815 return Addr.Base.Reg != 0;
818 void ARMFastISel::ARMSimplifyAddress(
Address &Addr,
MVT VT,
bool useAM3) {
819 bool needsLowering =
false;
828 needsLowering = ((Addr.Offset & 0xfff) != Addr.Offset);
830 if (needsLowering && isThumb2)
831 needsLowering = !(Subtarget->hasV6T2Ops() && Addr.Offset < 0 &&
835 needsLowering = (Addr.Offset > 255 || Addr.Offset < -255);
841 needsLowering = ((Addr.Offset & 0xff) != Addr.Offset);
848 if (needsLowering && Addr.BaseType == Address::FrameIndexBase) {
851 unsigned ResultReg = createResultReg(RC);
852 unsigned Opc = isThumb2 ? ARM::t2ADDri : ARM::ADDri;
853 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
854 TII.
get(Opc), ResultReg)
855 .addFrameIndex(Addr.Base.FI)
857 Addr.Base.Reg = ResultReg;
858 Addr.BaseType = Address::RegBase;
870 void ARMFastISel::AddLoadStoreOperands(
MVT VT,
Address &Addr,
880 if (Addr.BaseType == Address::FrameIndexBase) {
881 int FI = Addr.Base.FI;
885 MFI.getObjectSize(FI), MFI.getObjectAlignment(FI));
892 int Imm = (Addr.Offset < 0) ? (0x100 | -Addr.Offset) : Addr.Offset;
901 MIB.
addReg(Addr.Base.Reg);
906 int Imm = (Addr.Offset < 0) ? (0x100 | -Addr.Offset) : Addr.Offset;
913 AddOptionalDefs(MIB);
917 unsigned Alignment,
bool isZExt,
bool allocReg) {
920 bool needVMOV =
false;
924 default:
return false;
928 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
929 Opc = isZExt ? ARM::t2LDRBi8 : ARM::t2LDRSBi8;
931 Opc = isZExt ? ARM::t2LDRBi12 : ARM::t2LDRSBi12;
940 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
943 if (Alignment && Alignment < 2 && !Subtarget->allowsUnalignedMem())
947 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
948 Opc = isZExt ? ARM::t2LDRHi8 : ARM::t2LDRSHi8;
950 Opc = isZExt ? ARM::t2LDRHi12 : ARM::t2LDRSHi12;
952 Opc = isZExt ? ARM::LDRH : ARM::LDRSH;
955 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
958 if (Alignment && Alignment < 4 && !Subtarget->allowsUnalignedMem())
962 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
969 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
972 if (!Subtarget->hasVFP2Base())
return false;
974 if (Alignment && Alignment < 4) {
977 Opc = isThumb2 ? ARM::t2LDRi12 : ARM::LDRi12;
978 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
986 if (!Subtarget->hasVFP2Base())
return false;
989 if (Alignment && Alignment < 4)
997 ARMSimplifyAddress(Addr, VT, useAM3);
1001 ResultReg = createResultReg(RC);
1002 assert(ResultReg > 255 &&
"Expected an allocated virtual register.");
1004 TII.
get(Opc), ResultReg);
1011 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1013 .addReg(ResultReg));
1028 if (
const Argument *
Arg = dyn_cast<Argument>(SV)) {
1029 if (
Arg->hasSwiftErrorAttr())
1033 if (
const AllocaInst *Alloca = dyn_cast<AllocaInst>(SV)) {
1034 if (Alloca->isSwiftError())
1041 if (!isLoadTypeLegal(I->
getType(), VT))
1046 if (!ARMComputeAddress(I->
getOperand(0), Addr))
return false;
1049 if (!ARMEmitLoad(VT, ResultReg, Addr, cast<LoadInst>(I)->getAlignment()))
1051 updateValueMap(I, ResultReg);
1055 bool ARMFastISel::ARMEmitStore(
MVT VT,
unsigned SrcReg,
Address &Addr,
1056 unsigned Alignment) {
1058 bool useAM3 =
false;
1061 default:
return false;
1063 unsigned Res = createResultReg(isThumb2 ? &ARM::tGPRRegClass
1064 : &ARM::GPRRegClass);
1065 unsigned Opc = isThumb2 ? ARM::t2ANDri : ARM::ANDri;
1067 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1069 .addReg(SrcReg).
addImm(1));
1075 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
1076 StrOpc = ARM::t2STRBi8;
1078 StrOpc = ARM::t2STRBi12;
1080 StrOpc = ARM::STRBi12;
1084 if (Alignment && Alignment < 2 && !Subtarget->allowsUnalignedMem())
1088 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
1089 StrOpc = ARM::t2STRHi8;
1091 StrOpc = ARM::t2STRHi12;
1098 if (Alignment && Alignment < 4 && !Subtarget->allowsUnalignedMem())
1102 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
1103 StrOpc = ARM::t2STRi8;
1105 StrOpc = ARM::t2STRi12;
1107 StrOpc = ARM::STRi12;
1111 if (!Subtarget->hasVFP2Base())
return false;
1113 if (Alignment && Alignment < 4) {
1115 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1120 StrOpc = isThumb2 ? ARM::t2STRi12 : ARM::STRi12;
1122 StrOpc = ARM::VSTRS;
1127 if (!Subtarget->hasVFP2Base())
return false;
1130 if (Alignment && Alignment < 4)
1133 StrOpc = ARM::VSTRD;
1137 ARMSimplifyAddress(Addr, VT, useAM3);
1148 bool ARMFastISel::SelectStore(
const Instruction *I) {
1150 unsigned SrcReg = 0;
1153 if (cast<StoreInst>(I)->
isAtomic())
1160 if (
const Argument *
Arg = dyn_cast<Argument>(PtrV)) {
1161 if (
Arg->hasSwiftErrorAttr())
1165 if (
const AllocaInst *Alloca = dyn_cast<AllocaInst>(PtrV)) {
1166 if (Alloca->isSwiftError())
1177 SrcReg = getRegForValue(Op0);
1178 if (SrcReg == 0)
return false;
1182 if (!ARMComputeAddress(I->
getOperand(1), Addr))
1185 if (!ARMEmitStore(VT, SrcReg, Addr, cast<StoreInst>(I)->getAlignment()))
1237 bool ARMFastISel::SelectBranch(
const Instruction *I) {
1251 if (FuncInfo.MBB->isLayoutSuccessor(TBB)) {
1265 unsigned BrOpc = isThumb2 ? ARM::t2Bcc : ARM::Bcc;
1266 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(BrOpc))
1268 finishCondBranch(BI->
getParent(), TBB, FBB);
1273 if (TI->hasOneUse() && TI->getParent() == I->
getParent() &&
1274 (isLoadTypeLegal(TI->getOperand(0)->getType(), SourceVT))) {
1275 unsigned TstOpc = isThumb2 ? ARM::t2TSTri : ARM::TSTri;
1276 unsigned OpReg = getRegForValue(TI->getOperand(0));
1278 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1280 .addReg(OpReg).
addImm(1));
1283 if (FuncInfo.MBB->isLayoutSuccessor(TBB)) {
1288 unsigned BrOpc = isThumb2 ? ARM::t2Bcc : ARM::Bcc;
1289 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(BrOpc))
1292 finishCondBranch(BI->
getParent(), TBB, FBB);
1299 fastEmitBranch(Target, DbgLoc);
1304 if (CmpReg == 0)
return false;
1313 unsigned TstOpc = isThumb2 ? ARM::t2TSTri : ARM::TSTri;
1316 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(TstOpc))
1321 if (FuncInfo.MBB->isLayoutSuccessor(TBB)) {
1326 unsigned BrOpc = isThumb2 ? ARM::t2Bcc : ARM::Bcc;
1327 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(BrOpc))
1329 finishCondBranch(BI->
getParent(), TBB, FBB);
1333 bool ARMFastISel::SelectIndirectBr(
const Instruction *I) {
1334 unsigned AddrReg = getRegForValue(I->
getOperand(0));
1335 if (AddrReg == 0)
return false;
1337 unsigned Opc = isThumb2 ? ARM::tBRIND : ARM::BX;
1338 assert(isThumb2 || Subtarget->hasV4TOps());
1340 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1341 TII.
get(Opc)).addReg(AddrReg));
1344 for (
const BasicBlock *SuccBB : IB->successors())
1345 FuncInfo.MBB->addSuccessor(FuncInfo.MBBMap[SuccBB]);
1350 bool ARMFastISel::ARMEmitCmp(
const Value *Src1Value,
const Value *Src2Value,
1354 if (!SrcEVT.
isSimple())
return false;
1357 if (Ty->
isFloatTy() && !Subtarget->hasVFP2Base())
1360 if (Ty->
isDoubleTy() && (!Subtarget->hasVFP2Base() || !Subtarget->hasFP64()))
1366 bool UseImm =
false;
1367 bool isNegativeImm =
false;
1370 if (
const ConstantInt *ConstInt = dyn_cast<ConstantInt>(Src2Value)) {
1373 const APInt &CIVal = ConstInt->getValue();
1378 if (Imm < 0 && Imm != (
int)0x80000000) {
1379 isNegativeImm =
true;
1385 }
else if (
const ConstantFP *ConstFP = dyn_cast<ConstantFP>(Src2Value)) {
1387 if (ConstFP->isZero() && !ConstFP->isNegative())
1393 bool needsExt =
false;
1395 default:
return false;
1399 CmpOpc = UseImm ? ARM::VCMPZS : ARM::VCMPS;
1403 CmpOpc = UseImm ? ARM::VCMPZD : ARM::VCMPD;
1413 CmpOpc = ARM::t2CMPrr;
1415 CmpOpc = isNegativeImm ? ARM::t2CMNri : ARM::t2CMPri;
1418 CmpOpc = ARM::CMPrr;
1420 CmpOpc = isNegativeImm ? ARM::CMNri : ARM::CMPri;
1425 unsigned SrcReg1 = getRegForValue(Src1Value);
1426 if (SrcReg1 == 0)
return false;
1428 unsigned SrcReg2 = 0;
1430 SrcReg2 = getRegForValue(Src2Value);
1431 if (SrcReg2 == 0)
return false;
1436 SrcReg1 = ARMEmitIntExt(SrcVT, SrcReg1,
MVT::i32, isZExt);
1437 if (SrcReg1 == 0)
return false;
1439 SrcReg2 = ARMEmitIntExt(SrcVT, SrcReg2,
MVT::i32, isZExt);
1440 if (SrcReg2 == 0)
return false;
1448 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
1452 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
1458 AddOptionalDefs(MIB);
1464 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1469 bool ARMFastISel::SelectCmp(
const Instruction *I) {
1470 const CmpInst *CI = cast<CmpInst>(
I);
1484 unsigned MovCCOpc = isThumb2 ? ARM::t2MOVCCi : ARM::MOVCCi;
1486 : &ARM::GPRRegClass;
1487 unsigned DestReg = createResultReg(RC);
1489 unsigned ZeroReg = fastMaterializeConstant(Zero);
1491 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(MovCCOpc), DestReg)
1492 .addReg(ZeroReg).
addImm(1)
1495 updateValueMap(I, DestReg);
1499 bool ARMFastISel::SelectFPExt(
const Instruction *I) {
1501 if (!Subtarget->hasVFP2Base() || !Subtarget->hasFP64())
return false;
1507 unsigned Op = getRegForValue(V);
1508 if (Op == 0)
return false;
1510 unsigned Result = createResultReg(&ARM::DPRRegClass);
1511 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1512 TII.
get(ARM::VCVTDS), Result)
1514 updateValueMap(I, Result);
1518 bool ARMFastISel::SelectFPTrunc(
const Instruction *I) {
1520 if (!Subtarget->hasVFP2Base() || !Subtarget->hasFP64())
return false;
1526 unsigned Op = getRegForValue(V);
1527 if (Op == 0)
return false;
1529 unsigned Result = createResultReg(&ARM::SPRRegClass);
1530 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1531 TII.
get(ARM::VCVTSD), Result)
1533 updateValueMap(I, Result);
1537 bool ARMFastISel::SelectIToFP(
const Instruction *I,
bool isSigned) {
1539 if (!Subtarget->hasVFP2Base())
return false;
1543 if (!isTypeLegal(Ty, DstVT))
1554 unsigned SrcReg = getRegForValue(Src);
1555 if (SrcReg == 0)
return false;
1559 SrcReg = ARMEmitIntExt(SrcVT, SrcReg,
MVT::i32,
1561 if (SrcReg == 0)
return false;
1566 unsigned FP = ARMMoveToFPReg(
MVT::f32, SrcReg);
1567 if (FP == 0)
return false;
1570 if (Ty->
isFloatTy()) Opc = isSigned ? ARM::VSITOS : ARM::VUITOS;
1571 else if (Ty->
isDoubleTy() && Subtarget->hasFP64())
1572 Opc = isSigned ? ARM::VSITOD : ARM::VUITOD;
1576 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1577 TII.
get(Opc), ResultReg).addReg(FP));
1578 updateValueMap(I, ResultReg);
1582 bool ARMFastISel::SelectFPToI(
const Instruction *I,
bool isSigned) {
1584 if (!Subtarget->hasVFP2Base())
return false;
1588 if (!isTypeLegal(RetTy, DstVT))
1591 unsigned Op = getRegForValue(I->
getOperand(0));
1592 if (Op == 0)
return false;
1596 if (OpTy->
isFloatTy()) Opc = isSigned ? ARM::VTOSIZS : ARM::VTOUIZS;
1597 else if (OpTy->
isDoubleTy() && Subtarget->hasFP64())
1598 Opc = isSigned ? ARM::VTOSIZD : ARM::VTOUIZD;
1603 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1604 TII.
get(Opc), ResultReg).addReg(Op));
1608 unsigned IntReg = ARMMoveToIntReg(DstVT, ResultReg);
1609 if (IntReg == 0)
return false;
1611 updateValueMap(I, IntReg);
1615 bool ARMFastISel::SelectSelect(
const Instruction *I) {
1617 if (!isTypeLegal(I->
getType(), VT))
1623 unsigned CondReg = getRegForValue(I->
getOperand(0));
1624 if (CondReg == 0)
return false;
1625 unsigned Op1Reg = getRegForValue(I->
getOperand(1));
1626 if (Op1Reg == 0)
return false;
1630 bool UseImm =
false;
1631 bool isNegativeImm =
false;
1634 Imm = (int)ConstInt->getValue().getZExtValue();
1636 isNegativeImm =
true;
1643 unsigned Op2Reg = 0;
1646 if (Op2Reg == 0)
return false;
1649 unsigned TstOpc = isThumb2 ? ARM::t2TSTri : ARM::TSTri;
1652 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(TstOpc))
1659 RC = isThumb2 ? &ARM::tGPRRegClass : &ARM::GPRRegClass;
1660 MovCCOpc = isThumb2 ? ARM::t2MOVCCr : ARM::MOVCCr;
1662 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRRegClass;
1664 MovCCOpc = isThumb2 ? ARM::t2MOVCCi : ARM::MOVCCi;
1666 MovCCOpc = isThumb2 ? ARM::t2MVNCCi : ARM::MVNCCi;
1668 unsigned ResultReg = createResultReg(RC);
1672 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(MovCCOpc),
1680 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(MovCCOpc),
1687 updateValueMap(I, ResultReg);
1691 bool ARMFastISel::SelectDiv(
const Instruction *I,
bool isSigned) {
1694 if (!isTypeLegal(Ty, VT))
1700 if (Subtarget->hasDivideInThumbMode())
1706 LC = isSigned ? RTLIB::SDIV_I8 : RTLIB::UDIV_I8;
1708 LC = isSigned ? RTLIB::SDIV_I16 : RTLIB::UDIV_I16;
1710 LC = isSigned ? RTLIB::SDIV_I32 : RTLIB::UDIV_I32;
1712 LC = isSigned ? RTLIB::SDIV_I64 : RTLIB::UDIV_I64;
1714 LC = isSigned ? RTLIB::SDIV_I128 : RTLIB::UDIV_I128;
1715 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
1717 return ARMEmitLibcall(I, LC);
1720 bool ARMFastISel::SelectRem(
const Instruction *I,
bool isSigned) {
1723 if (!isTypeLegal(Ty, VT))
1735 LC = isSigned ? RTLIB::SREM_I8 : RTLIB::UREM_I8;
1737 LC = isSigned ? RTLIB::SREM_I16 : RTLIB::UREM_I16;
1739 LC = isSigned ? RTLIB::SREM_I32 : RTLIB::UREM_I32;
1741 LC = isSigned ? RTLIB::SREM_I64 : RTLIB::UREM_I64;
1743 LC = isSigned ? RTLIB::SREM_I128 : RTLIB::UREM_I128;
1744 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
1746 return ARMEmitLibcall(I, LC);
1749 bool ARMFastISel::SelectBinaryIntOp(
const Instruction *I,
unsigned ISDOpcode) {
1758 switch (ISDOpcode) {
1759 default:
return false;
1761 Opc = isThumb2 ? ARM::t2ADDrr : ARM::ADDrr;
1764 Opc = isThumb2 ? ARM::t2ORRrr : ARM::ORRrr;
1767 Opc = isThumb2 ? ARM::t2SUBrr : ARM::SUBrr;
1771 unsigned SrcReg1 = getRegForValue(I->
getOperand(0));
1772 if (SrcReg1 == 0)
return false;
1776 unsigned SrcReg2 = getRegForValue(I->
getOperand(1));
1777 if (SrcReg2 == 0)
return false;
1779 unsigned ResultReg = createResultReg(&ARM::GPRnopcRegClass);
1782 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1783 TII.
get(Opc), ResultReg)
1784 .addReg(SrcReg1).
addReg(SrcReg2));
1785 updateValueMap(I, ResultReg);
1789 bool ARMFastISel::SelectBinaryFPOp(
const Instruction *I,
unsigned ISDOpcode) {
1791 if (!FPVT.
isSimple())
return false;
1803 if (Ty->
isFloatTy() && !Subtarget->hasVFP2Base())
1805 if (Ty->
isDoubleTy() && (!Subtarget->hasVFP2Base() || !Subtarget->hasFP64()))
1810 switch (ISDOpcode) {
1811 default:
return false;
1813 Opc = is64bit ? ARM::VADDD : ARM::VADDS;
1816 Opc = is64bit ? ARM::VSUBD : ARM::VSUBS;
1819 Opc = is64bit ? ARM::VMULD : ARM::VMULS;
1822 unsigned Op1 = getRegForValue(I->
getOperand(0));
1823 if (Op1 == 0)
return false;
1825 unsigned Op2 = getRegForValue(I->
getOperand(1));
1826 if (Op2 == 0)
return false;
1829 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1830 TII.
get(Opc), ResultReg)
1831 .addReg(Op1).
addReg(Op2));
1832 updateValueMap(I, ResultReg);
1847 if (Subtarget->hasVFP2Base() && !isVarArg) {
1848 if (!Subtarget->isAAPCS_ABI())
1857 if (Subtarget->isAAPCS_ABI()) {
1858 if (Subtarget->hasVFP2Base() &&
1896 CCState CCInfo(CC, isVarArg, *FuncInfo.MF, ArgLocs, *Context);
1898 CCAssignFnForCall(CC,
false, isVarArg));
1902 for (
unsigned i = 0,
e = ArgLocs.
size(); i !=
e; ++i) {
1917 !VA.
isRegLoc() || !ArgLocs[++i].isRegLoc())
1929 if (!Subtarget->hasVFP2Base())
1933 if (!Subtarget->hasVFP2Base())
1947 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1948 TII.
get(AdjStackDown))
1949 .addImm(NumBytes).
addImm(0));
1952 for (
unsigned i = 0,
e = ArgLocs.
size(); i !=
e; ++i) {
1959 "We don't handle NEON/vector parameters yet.");
1966 Arg = ARMEmitIntExt(ArgVT, Arg, DestVT,
false);
1967 assert(Arg != 0 &&
"Failed to emit a sext");
1975 Arg = ARMEmitIntExt(ArgVT, Arg, DestVT,
true);
1976 assert(Arg != 0 &&
"Failed to emit a zext");
1983 assert(BC != 0 &&
"Failed to emit a bitcast!");
1993 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1994 TII.
get(TargetOpcode::COPY), VA.
getLocReg()).addReg(Arg);
1999 "Custom lowering for v2f64 args not available");
2005 "We only handle register args!");
2007 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2018 if (isa<UndefValue>(ArgVal))
2022 Addr.BaseType = Address::RegBase;
2023 Addr.Base.Reg = ARM::SP;
2026 bool EmitRet = ARMEmitStore(ArgVT, Arg, Addr); (void)EmitRet;
2027 assert(EmitRet &&
"Could not emit a store for argument!");
2036 unsigned &NumBytes,
bool isVarArg) {
2039 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2040 TII.
get(AdjStackUp))
2041 .addImm(NumBytes).
addImm(0));
2046 CCState CCInfo(CC, isVarArg, *FuncInfo.MF, RVLocs, *Context);
2053 MVT DestVT = RVLocs[0].getValVT();
2055 Register ResultReg = createResultReg(DstRC);
2056 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2058 .addReg(RVLocs[0].getLocReg())
2059 .addReg(RVLocs[1].getLocReg()));
2061 UsedRegs.
push_back(RVLocs[0].getLocReg());
2062 UsedRegs.
push_back(RVLocs[1].getLocReg());
2065 updateValueMap(I, ResultReg);
2067 assert(RVLocs.
size() == 1 &&
"Can't handle non-double multi-reg retvals!");
2068 MVT CopyVT = RVLocs[0].getValVT();
2076 Register ResultReg = createResultReg(DstRC);
2077 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2078 TII.
get(TargetOpcode::COPY),
2079 ResultReg).addReg(RVLocs[0].getLocReg());
2080 UsedRegs.
push_back(RVLocs[0].getLocReg());
2083 updateValueMap(I, ResultReg);
2090 bool ARMFastISel::SelectRet(
const Instruction *I) {
2094 if (!FuncInfo.CanLowerReturn)
2098 F.getAttributes().hasAttrSomewhere(Attribute::SwiftError))
2110 GetReturnInfo(CC, F.getReturnType(), F.getAttributes(), Outs, TLI, DL);
2119 unsigned Reg = getRegForValue(RV);
2124 if (ValLocs.size() != 1)
2136 unsigned SrcReg = Reg + VA.
getValNo();
2137 EVT RVEVT = TLI.getValueType(DL, RV->
getType());
2138 if (!RVEVT.
isSimple())
return false;
2142 if (RVVT != DestVT) {
2150 if (Outs[0].Flags.isZExt() || Outs[0].Flags.isSExt()) {
2151 SrcReg = ARMEmitIntExt(RVVT, SrcReg, DestVT, Outs[0].Flags.isZExt());
2152 if (SrcReg == 0)
return false;
2162 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2163 TII.
get(TargetOpcode::COPY), DstReg).addReg(SrcReg);
2170 TII.
get(Subtarget->getReturnOpcode()));
2171 AddOptionalDefs(MIB);
2172 for (
unsigned R : RetRegs)
2177 unsigned ARMFastISel::ARMSelectCallOp(
bool UseReg) {
2179 return isThumb2 ? ARM::tBLXr : ARM::BLX;
2181 return isThumb2 ? ARM::tBL :
ARM::BL;
2184 unsigned ARMFastISel::getLibcallReg(
const Twine &
Name) {
2193 assert(GV->
getType() == GVTy &&
"We miscomputed the type for the global!");
2194 return ARMMaterializeGV(GV, LCREVT.
getSimpleVT());
2212 else if (!isTypeLegal(RetTy, RetVT))
2218 CCState CCInfo(CC,
false, *FuncInfo.MF, RVLocs, *Context);
2234 unsigned Arg = getRegForValue(Op);
2235 if (Arg == 0)
return false;
2239 if (!isTypeLegal(ArgTy, ArgVT))
return false;
2253 if (!ProcessCallArgs(Args, ArgRegs, ArgVTs, ArgFlags,
2254 RegArgs, CC, NumBytes,
false))
2258 if (Subtarget->genLongCalls()) {
2260 if (CalleeReg == 0)
return false;
2264 unsigned CallOpc = ARMSelectCallOp(Subtarget->genLongCalls());
2266 DbgLoc, TII.
get(CallOpc));
2270 if (Subtarget->genLongCalls())
2285 if (!FinishCall(RetVT, UsedRegs, I, CC, NumBytes,
false))
return false;
2288 static_cast<MachineInstr *
>(MIB)->setPhysRegsDeadExcept(UsedRegs,
TRI);
2293 bool ARMFastISel::SelectCall(
const Instruction *I,
2294 const char *IntrMemName =
nullptr) {
2299 if (isa<InlineAsm>(Callee))
return false;
2318 else if (!isTypeLegal(RetTy, RetVT) && RetVT !=
MVT::i16 &&
2326 CCState CCInfo(CC, isVarArg, *FuncInfo.MF, RVLocs, *Context);
2346 if (IntrMemName &&
e - i <= 1)
2365 Type *ArgTy = (*i)->getType();
2367 if (!isTypeLegal(ArgTy, ArgVT) && ArgVT !=
MVT::i16 && ArgVT !=
MVT::i8 &&
2386 if (!ProcessCallArgs(Args, ArgRegs, ArgVTs, ArgFlags,
2387 RegArgs, CC, NumBytes, isVarArg))
2390 bool UseReg =
false;
2392 if (!GV || Subtarget->genLongCalls()) UseReg =
true;
2397 CalleeReg = getLibcallReg(IntrMemName);
2399 CalleeReg = getRegForValue(Callee);
2401 if (CalleeReg == 0)
return false;
2405 unsigned CallOpc = ARMSelectCallOp(UseReg);
2407 DbgLoc, TII.
get(CallOpc));
2414 else if (!IntrMemName)
2429 if (!FinishCall(RetVT, UsedRegs, I, CC, NumBytes, isVarArg))
2433 static_cast<MachineInstr *
>(MIB)->setPhysRegsDeadExcept(UsedRegs,
TRI);
2438 bool ARMFastISel::ARMIsMemCpySmall(uint64_t Len) {
2442 bool ARMFastISel::ARMTryEmitSmallMemCpy(
Address Dest,
Address Src,
2443 uint64_t Len,
unsigned Alignment) {
2445 if (!ARMIsMemCpySmall(Len))
2450 if (!Alignment || Alignment >= 4) {
2456 assert(Len == 1 &&
"Expected a length of 1!");
2461 if (Len >= 2 && Alignment == 2)
2470 RV = ARMEmitLoad(VT, ResultReg, Src);
2471 assert(RV &&
"Should be able to handle this load.");
2472 RV = ARMEmitStore(VT, ResultReg, Dest);
2473 assert(RV &&
"Should be able to handle this store.");
2478 Dest.Offset +=
Size;
2485 bool ARMFastISel::SelectIntrinsicCall(
const IntrinsicInst &I) {
2488 default:
return false;
2489 case Intrinsic::frameaddress: {
2493 unsigned LdrOpc = isThumb2 ? ARM::t2LDRi12 : ARM::LDRi12;
2495 : &ARM::GPRRegClass;
2500 unsigned SrcReg = FramePtr;
2510 DestReg = createResultReg(RC);
2511 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2512 TII.
get(LdrOpc), DestReg)
2513 .addReg(SrcReg).
addImm(0));
2516 updateValueMap(&I, SrcReg);
2519 case Intrinsic::memcpy:
2520 case Intrinsic::memmove: {
2529 if (isa<ConstantInt>(MTI.
getLength()) && isMemCpy) {
2532 uint64_t Len = cast<ConstantInt>(MTI.
getLength())->getZExtValue();
2533 if (ARMIsMemCpySmall(Len)) {
2535 if (!ARMComputeAddress(MTI.
getRawDest(), Dest) ||
2540 if (ARMTryEmitSmallMemCpy(Dest, Src, Len, Alignment))
2551 const char *IntrMemName = isa<MemCpyInst>(
I) ?
"memcpy" :
"memmove";
2552 return SelectCall(&I, IntrMemName);
2554 case Intrinsic::memset: {
2566 return SelectCall(&I,
"memset");
2568 case Intrinsic::trap: {
2570 if (Subtarget->isThumb())
2571 Opcode = ARM::tTRAP;
2573 Opcode = Subtarget->useNaClTrap() ? ARM::TRAPNaCl :
ARM::TRAP;
2574 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(Opcode));
2580 bool ARMFastISel::SelectTrunc(
const Instruction *I) {
2594 unsigned SrcReg = getRegForValue(Op);
2595 if (!SrcReg)
return false;
2599 updateValueMap(I, SrcReg);
2603 unsigned ARMFastISel::ARMEmitIntExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
2612 static const uint8_t isSingleInstrTbl[3][2][2][2] = {
2616 { { { 0, 1 }, { 0, 1 } }, { { 0, 0 }, { 0, 1 } } },
2617 { { { 0, 1 }, { 1, 1 } }, { { 0, 0 }, { 1, 1 } } },
2618 { { { 0, 0 }, { 1, 1 } }, { { 0, 0 }, { 1, 1 } } }
2627 { &ARM::GPRnopcRegClass, &ARM::GPRnopcRegClass },
2628 { &ARM::tGPRRegClass, &ARM::rGPRRegClass }
2632 static const struct InstructionTable {
2637 }
IT[2][2][3][2] = {
2679 assert((SrcBits < DestBits) &&
"can only extend to larger types");
2680 assert((DestBits == 32 || DestBits == 16 || DestBits == 8) &&
2681 "other sizes unimplemented");
2682 assert((SrcBits == 16 || SrcBits == 8 || SrcBits == 1) &&
2683 "other sizes unimplemented");
2685 bool hasV6Ops = Subtarget->hasV6Ops();
2686 unsigned Bitness = SrcBits / 8;
2687 assert((Bitness < 3) &&
"sanity-check table bounds");
2689 bool isSingleInstr = isSingleInstrTbl[Bitness][isThumb2][hasV6Ops][isZExt];
2691 const InstructionTable *ITP = &
IT[isSingleInstr][isThumb2][Bitness][isZExt];
2692 unsigned Opc = ITP->Opc;
2694 unsigned hasS = ITP->hasS;
2697 "only MOVsi has shift operand addressing mode");
2698 unsigned Imm = ITP->Imm;
2701 bool setsCPSR = &ARM::tGPRRegClass == RC;
2702 unsigned LSLOpc = isThumb2 ? ARM::tLSLri : ARM::MOVsi;
2717 unsigned NumInstrsEmitted = isSingleInstr ? 1 : 2;
2718 for (
unsigned Instr = 0; Instr != NumInstrsEmitted; ++Instr) {
2719 ResultReg = createResultReg(RC);
2720 bool isLsl = (0 == Instr) && !isSingleInstr;
2721 unsigned Opcode = isLsl ? LSLOpc : Opc;
2724 bool isKill = 1 == Instr;
2726 *FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(Opcode), ResultReg);
2730 MIB.
addReg(SrcReg, isKill * RegState::Kill)
2742 bool ARMFastISel::SelectIntExt(
const Instruction *I) {
2749 bool isZExt = isa<ZExtInst>(
I);
2750 unsigned SrcReg = getRegForValue(Src);
2751 if (!SrcReg)
return false;
2753 EVT SrcEVT, DestEVT;
2756 if (!SrcEVT.
isSimple())
return false;
2757 if (!DestEVT.
isSimple())
return false;
2761 unsigned ResultReg = ARMEmitIntExt(SrcVT, SrcReg, DestVT, isZExt);
2762 if (ResultReg == 0)
return false;
2763 updateValueMap(I, ResultReg);
2767 bool ARMFastISel::SelectShift(
const Instruction *I,
2779 unsigned Opc = ARM::MOVsr;
2782 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(Src2Value)) {
2787 if (ShiftImm == 0 || ShiftImm >=32)
2794 unsigned Reg1 = getRegForValue(Src1Value);
2795 if (Reg1 == 0)
return false;
2798 if (Opc == ARM::MOVsr) {
2799 Reg2 = getRegForValue(Src2Value);
2800 if (Reg2 == 0)
return false;
2803 unsigned ResultReg = createResultReg(&ARM::GPRnopcRegClass);
2804 if(ResultReg == 0)
return false;
2807 TII.
get(Opc), ResultReg)
2810 if (Opc == ARM::MOVsi)
2812 else if (Opc == ARM::MOVsr) {
2817 AddOptionalDefs(MIB);
2818 updateValueMap(I, ResultReg);
2823 bool ARMFastISel::fastSelectInstruction(
const Instruction *I) {
2826 return SelectLoad(I);
2828 return SelectStore(I);
2829 case Instruction::Br:
2830 return SelectBranch(I);
2831 case Instruction::IndirectBr:
2832 return SelectIndirectBr(I);
2833 case Instruction::ICmp:
2834 case Instruction::FCmp:
2835 return SelectCmp(I);
2836 case Instruction::FPExt:
2837 return SelectFPExt(I);
2838 case Instruction::FPTrunc:
2839 return SelectFPTrunc(I);
2840 case Instruction::SIToFP:
2841 return SelectIToFP(I,
true);
2842 case Instruction::UIToFP:
2843 return SelectIToFP(I,
false);
2844 case Instruction::FPToSI:
2845 return SelectFPToI(I,
true);
2846 case Instruction::FPToUI:
2847 return SelectFPToI(I,
false);
2849 return SelectBinaryIntOp(I,
ISD::ADD);
2850 case Instruction::Or:
2851 return SelectBinaryIntOp(I,
ISD::OR);
2852 case Instruction::Sub:
2853 return SelectBinaryIntOp(I,
ISD::SUB);
2854 case Instruction::FAdd:
2856 case Instruction::FSub:
2858 case Instruction::FMul:
2860 case Instruction::SDiv:
2861 return SelectDiv(I,
true);
2862 case Instruction::UDiv:
2863 return SelectDiv(I,
false);
2864 case Instruction::SRem:
2865 return SelectRem(I,
true);
2866 case Instruction::URem:
2867 return SelectRem(I,
false);
2870 return SelectIntrinsicCall(*II);
2871 return SelectCall(I);
2873 return SelectSelect(I);
2875 return SelectRet(I);
2876 case Instruction::Trunc:
2877 return SelectTrunc(I);
2878 case Instruction::ZExt:
2879 case Instruction::SExt:
2880 return SelectIntExt(I);
2881 case Instruction::Shl:
2883 case Instruction::LShr:
2885 case Instruction::AShr:
2903 { {
ARM::UXTH, ARM::t2UXTH }, 0, 1, MVT::i16 },
2904 { { ARM::ANDri, ARM::t2ANDri }, 255, 1,
MVT::i8 },
2905 { {
ARM::SXTB, ARM::t2SXTB }, 0, 0, MVT::i8 },
2906 { {
ARM::UXTB, ARM::t2UXTB }, 0, 1, MVT::i8 }
2913 bool ARMFastISel::tryToFoldLoadIntoMI(
MachineInstr *MI,
unsigned OpNo,
2917 if (!isLoadTypeLegal(LI->
getType(), VT))
2931 if (FLE.Opc[isThumb2] == MI->
getOpcode() &&
2932 (uint64_t)FLE.ExpectedImm == Imm &&
2935 isZExt = FLE.isZExt;
2938 if (!Found)
return false;
2942 if (!ARMComputeAddress(LI->
getOperand(0), Addr))
return false;
2945 if (!ARMEmitLoad(VT, ResultReg, Addr, LI->
getAlignment(), isZExt,
false))
2948 removeDeadCode(I, std::next(I));
2952 unsigned ARMFastISel::ARMLowerPICELF(
const GlobalValue *GV,
2953 unsigned Align,
MVT VT) {
2956 LLVMContext *Context = &MF->getFunction().getContext();
2958 unsigned PCAdj = Subtarget->isThumb() ? 4 : 8;
2964 unsigned ConstAlign =
2966 unsigned Idx = MF->getConstantPool()->getConstantPoolIndex(CPV, ConstAlign);
2971 Register TempReg = MF->getRegInfo().createVirtualRegister(&ARM::rGPRRegClass);
2972 unsigned Opc = isThumb2 ? ARM::t2LDRpci : ARM::LDRcp;
2974 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(Opc), TempReg)
2975 .addConstantPoolIndex(Idx)
2977 if (Opc == ARM::LDRcp)
2983 Opc = Subtarget->isThumb() ? ARM::tPICADD : UseGOT_PREL ? ARM::PICLDR
2986 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(Opc), DestReg)
2988 .
addImm(ARMPCLabelIndex);
2990 if (!Subtarget->isThumb())
2993 if (UseGOT_PREL && Subtarget->isThumb()) {
2995 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2996 TII.
get(ARM::t2LDRi12), NewDestReg)
2999 DestReg = NewDestReg;
3000 AddOptionalDefs(MIB);
3005 bool ARMFastISel::fastLowerArguments() {
3006 if (!FuncInfo.CanLowerReturn)
3029 if (
Arg.getArgNo() >= 4)
3032 if (
Arg.hasAttribute(Attribute::InReg) ||
3033 Arg.hasAttribute(Attribute::StructRet) ||
3034 Arg.hasAttribute(Attribute::SwiftSelf) ||
3035 Arg.hasAttribute(Attribute::SwiftError) ||
3036 Arg.hasAttribute(Attribute::ByVal))
3044 if (!ArgVT.
isSimple())
return false;
3056 ARM::R0, ARM::R1,
ARM::R2, ARM::R3
3061 unsigned ArgNo =
Arg.getArgNo();
3062 unsigned SrcReg = GPRArgRegs[ArgNo];
3063 unsigned DstReg = FuncInfo.MF->addLiveIn(SrcReg, RC);
3067 unsigned ResultReg = createResultReg(RC);
3068 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
3069 TII.
get(TargetOpcode::COPY),
3071 updateValueMap(&
Arg, ResultReg);
3082 return new ARMFastISel(funcInfo, libInfo);
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
void setFrameAddressIsTaken(bool T)
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
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...
const MachineInstrBuilder & add(const MachineOperand &MO) const
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
This class is the base class for the comparison instructions.
bool RetFastCC_ARM_APCS(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
uint64_t getZExtValue() const
Get zero extended value.
This class represents an incoming formal argument to a Function.
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
unsigned constrainOperandRegClass(const MachineFunction &MF, const TargetRegisterInfo &TRI, MachineRegisterInfo &MRI, const TargetInstrInfo &TII, const RegisterBankInfo &RBI, MachineInstr &InsertPt, const TargetRegisterClass &RegClass, const MachineOperand &RegMO, unsigned OpIdx)
Constrain the Register operand OpIdx, so that it is now constrained to the TargetRegisterClass passed...
bool CC_ARM_AAPCS(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
Register getLocReg() const
A Module instance is used to store all the information related to an LLVM module. ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
bool isVector() const
Return true if this is a vector value type.
bool useFastISel() const
True if fast-isel is used.
void push_back(const T &Elt)
ARMConstantPoolValue - ARM specific constantpool value.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
Describe properties that are true of each instruction in the target description file.
This class represents a function call, abstracting a target machine's calling convention.
static PointerType * getInt32PtrTy(LLVMContext &C, unsigned AS=0)
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit...
unsigned getSourceAlignment() const
FIXME: Remove this function once transition to Align is over.
Register getFrameRegister(const MachineFunction &MF) const override
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...
bool isPredicable(QueryType Type=AllInBundle) const
Return true if this instruction has a predicate operand that controls execution.
0 1 0 0 True if ordered and less than
unsigned getSourceAddressSpace() const
Externally visible function.
unsigned getValNo() const
LLVMContext & getContext() const
All values hold a context through their type.
1 1 1 0 True if unordered or not equal
int getFP64Imm(const APInt &Imm)
getFP64Imm - Return an 8-bit floating-point version of the 64-bit floating-point value.
This class wraps the llvm.memset intrinsic.
C - The default llvm calling convention, compatible with C.
BasicBlock * getSuccessor(unsigned i) const
unsigned const TargetRegisterInfo * TRI
unsigned getCallFrameDestroyOpcode() const
An instruction for reading from memory.
Value * getCondition() const
bool isVectorTy() const
True if this is an instance of VectorType.
void reserve(size_type N)
iterator_range< mop_iterator > operands()
Value * getLength() const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
unsigned createPICLabelUId()
FunctionType * getFunctionType() const
CallingConv::ID getCallingConv() const
Get the calling convention of the call.
1 0 0 1 True if unordered or equal
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.
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const HexagonInstrInfo * TII
PointerType * getType() const
Overload to return most specific pointer type.
unsigned getNumOperands() const
Retuns the total number of operands.
Class to represent struct types.
static ARMCC::CondCodes getComparePred(CmpInst::Predicate Pred)
A Use represents the edge between a Value definition and its users.
bool isIntegerTy() const
True if this is an instance of IntegerType.
0 1 0 1 True if ordered and less than or equal
This file contains the simple types necessary to represent the attributes associated with functions a...
bool CC_ARM_APCS_GHC(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
unsigned getDestAlignment() const
FIXME: Remove this function once transition to Align is over.
LocInfo getLocInfo() const
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
This file implements a class to represent arbitrary precision integral constant values and operations...
bool CC_ARM_APCS(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
Class to represent function types.
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.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
Type * getType() const
All values are typed, get the type of this value.
static std::array< MachineOperand, 2 > predOps(ARMCC::CondCodes Pred, unsigned PredReg=0)
Get the operands corresponding to the given Pred value.
bool RetCC_ARM_AAPCS(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
virtual const TargetRegisterClass * getRegClassFor(MVT VT, bool isDivergent=false) const
Return the register class that should be used for the specified value type.
virtual bool supportSwiftError() const
Return true if the target supports swifterror attribute.
CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const
Get the CallingConv that should be used for the specified libcall.
Simple integer binary arithmetic operators.
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned TargetFlags=0) const
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the call or the callee has the given attribute.
bool isThumb2Function() const
static const MCPhysReg GPRArgRegs[]
static const struct FoldableLoadExtendsStruct FoldableLoadExtends[]
This class represents a truncation of integer types.
Value * getOperand(unsigned i) const
Class to represent pointers.
unsigned getKillRegState(bool B)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
TargetInstrInfo - Interface to description of machine instruction set.
iterator find(const_arg_type_t< KeyT > Val)
bool isVoidTy() const
Return true if this is 'void'.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
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 shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const
Value * getCalledValue() const
LLVM Basic Block Representation.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
Simple binary floating point operators.
Conditional or Unconditional Branch instruction.
This is an important base class in LLVM.
static Register UseReg(const MachineOperand &MO)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Indirect Branch Instruction.
ARM_AAPCS - ARM Architecture Procedure Calling Standard calling convention (aka EABI).
ConstantFP - Floating Point Values [float, double].
const MCPhysReg * ImplicitDefs
unsigned getCallFrameSetupOpcode() const
These methods return the opcode of the frame setup/destroy instructions if they exist (-1 otherwise)...
This file declares a class to represent arbitrary precision floating point values and provide a varie...
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
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...
int getT2SOImmVal(unsigned Arg)
getT2SOImmVal - Given a 32-bit immediate, if it is something that can fit into a Thumb-2 shifter_oper...
TRAP - Trapping instruction.
Thread Local Storage (General Dynamic Mode)
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
0 1 1 1 True if ordered (no nans)
const MachineInstrBuilder & addFrameIndex(int Idx) const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
bool RetCC_ARM_AAPCS_VFP(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
Type * getIndexedType() const
bool isPositionIndependent() 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.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
This struct is a compact representation of a valid (non-zero power of two) alignment.
The memory access writes data.
const APFloat & getValueAPF() const
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
bool RetCC_ARM_APCS(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
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
void setOrigAlign(Align A)
unsigned getNumOperands() const
StructType * getStructTypeOrNull() const
virtual bool supportSplitCSR(MachineFunction *MF) const
Return true if the target supports that a subset of CSRs for the given machine function is handled ex...
CCState - This class holds information needed while lowering arguments and return values...
int getSOImmVal(unsigned Arg)
getSOImmVal - Given a 32-bit immediate, if it is something that can fit into an shifter_operand immed...
This is the shared class of boolean and integer constants.
static MachineOperand t1CondCodeOp(bool isDead=false)
Get the operand corresponding to the conditional code result for Thumb1.
ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
ARM_APCS - ARM Procedure Calling Standard calling convention (obsolete, but still used on some target...
MachineOperand class - Representation of each machine instruction operand.
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
Module.h This file contains the declarations for the Module class.
Provides information about what library functions are available for the current target.
CCValAssign - Represent assignment of one arg/retval to a location.
unsigned arg_size() const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
unsigned getSORegOpc(ShiftOpc ShOp, unsigned Imm)
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
Value * getRawSource() const
Return the arguments to the instruction.
User::const_op_iterator arg_iterator
The type of iterator to use when looping over actual arguments at this call site. ...
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Target - Wrapper for Target specific information.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
Class for arbitrary precision integers.
amdgpu Simplify well known AMD library false FunctionCallee Callee
This file defines the FastISel class.
bool CC_ARM_Win32_CFGuard_Check(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed v...
Flags
Flags values. These may be or'd together.
The memory access reads data.
virtual bool hasStandaloneRem(EVT VT) const
Return true if the target can handle a standalone remainder operation.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::ZeroOrMore, cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate IT block based on arch"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow deprecated IT based on ARMv8"), clEnumValN(NoRestrictedIT, "arm-no-restrict-it", "Allow IT blocks based on ARMv7")))
Representation of each machine instruction.
virtual bool isFPImmLegal(const APFloat &, EVT, bool ForCodeSize=false) const
Returns true if the target can instruction select the specified FP immediate natively.
Predicate getPredicate() const
Return the predicate for this instruction.
This class wraps the llvm.memcpy/memmove intrinsics.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
unsigned getDestAddressSpace() const
uint64_t getElementOffset(unsigned Idx) const
unsigned getAlignment() const
Return the alignment of the access that is being performed.
static MachineOperand condCodeOp(unsigned CCReg=0)
Get the operand corresponding to the conditional code result.
static IntegerType * getInt32Ty(LLVMContext &C)
unsigned getLocMemOffset() const
unsigned greater or equal
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
Establish a view to a call site for examination.
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...
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)
iterator_range< const_opInfo_iterator > operands() const
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.
bool hasOptionalDef(QueryType Type=IgnoreBundle) const
Set if this instruction has an optional definition, e.g.
bool CC_ARM_AAPCS_VFP(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Special calling convention on Windows for calling the Control Guard Check ICall funtion.
int getFP32Imm(const APInt &Imm)
getFP32Imm - Return an 8-bit floating-point version of the 32-bit floating-point value.
FastISel * createFastISel(FunctionLoweringInfo &funcInfo, const TargetLibraryInfo *libInfo)
0 0 0 1 True if ordered and equal
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
1 0 1 1 True if unordered, greater than, or equal
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
static const Function * getParent(const Value *V)
MO_NONLAZY - This is an independent flag, on a symbol operand "FOO" it represents a symbol which...
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.
bool hasOneUse() const
Return true if there is exactly one user of this value.
Register getReg() const
getReg - Returns the register number.
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
This holds information about one operand of a machine instruction, indicating the register class for ...
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
bool FastCC_ARM_APCS(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
const MachineOperand & getOperand(unsigned i) const
0 0 1 1 True if ordered and greater than or equal
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool isThumbFunction() const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Value * getRawDest() const
static ARMConstantPoolConstant * Create(const Constant *C, unsigned ID)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
PointerType * getType() const
Global values are always pointers.
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned TargetFlags=0) const
iterator_range< arg_iterator > args()
Wrapper class representing virtual and physical registers.
bool isStructTy() const
True if this is an instance of StructType.
bool isArrayTy() const
True if this is an instance of ArrayType.
A wrapper class for inspecting calls to intrinsic functions.
This file describes how to lower LLVM code to machine code.
const BasicBlock * getParent() const
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
an instruction to allocate memory on the stack
gep_type_iterator gep_type_begin(const User *GEP)
FloatABI::ABIType FloatABIType
FloatABIType - This setting is set by -float-abi=xxx option is specfied on the command line...