104 class ARMFastISel final :
public FastISel {
125 TM(funcInfo.MF->getTarget()),
TII(*Subtarget->getInstrInfo()),
126 TLI(*Subtarget->getTargetLowering()) {
135 unsigned fastEmitInst_r(
unsigned MachineInstOpcode,
137 unsigned Op0,
bool Op0IsKill);
138 unsigned fastEmitInst_rr(
unsigned MachineInstOpcode,
140 unsigned Op0,
bool Op0IsKill,
141 unsigned Op1,
bool Op1IsKill);
142 unsigned fastEmitInst_ri(
unsigned MachineInstOpcode,
144 unsigned Op0,
bool Op0IsKill,
146 unsigned fastEmitInst_i(
unsigned MachineInstOpcode,
152 bool fastSelectInstruction(
const Instruction *
I)
override;
153 unsigned fastMaterializeConstant(
const Constant *
C)
override;
154 unsigned fastMaterializeAlloca(
const AllocaInst *AI)
override;
157 bool fastLowerArguments()
override;
159 #include "ARMGenFastISel.inc"
170 bool SelectBinaryIntOp(
const Instruction *
I,
unsigned ISDOpcode);
171 bool SelectBinaryFPOp(
const Instruction *
I,
unsigned ISDOpcode);
176 bool SelectCall(
const Instruction *
I,
const char *IntrMemName);
186 bool isPositionIndependent()
const;
187 bool isTypeLegal(
Type *Ty,
MVT &VT);
188 bool isLoadTypeLegal(
Type *Ty,
MVT &VT);
189 bool ARMEmitCmp(
const Value *Src1Value,
const Value *Src2Value,
190 bool isZExt,
bool isEquality);
191 bool ARMEmitLoad(
MVT VT,
unsigned &ResultReg,
Address &Addr,
192 unsigned Alignment = 0,
bool isZExt =
true,
193 bool allocReg =
true);
194 bool ARMEmitStore(
MVT VT,
unsigned SrcReg,
Address &Addr,
195 unsigned Alignment = 0);
196 bool ARMComputeAddress(
const Value *Obj,
Address &Addr);
197 void ARMSimplifyAddress(
Address &Addr,
MVT VT,
bool useAM3);
198 bool ARMIsMemCpySmall(uint64_t Len);
199 bool ARMTryEmitSmallMemCpy(
Address Dest,
Address Src, uint64_t Len,
201 unsigned ARMEmitIntExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
bool isZExt);
205 unsigned ARMMoveToFPReg(
MVT VT,
unsigned SrcReg);
206 unsigned ARMMoveToIntReg(
MVT VT,
unsigned SrcReg);
207 unsigned ARMSelectCallOp(
bool UseReg);
225 unsigned getLibcallReg(
const Twine &
Name);
228 unsigned &NumBytes,
bool isVarArg);
236 void AddLoadStoreOperands(
MVT VT,
Address &Addr,
243 #include "ARMGenCallingConv.inc"
248 bool ARMFastISel::DefinesOptionalPredicate(
MachineInstr *
MI,
bool *CPSR) {
254 if (!MO.isReg() || !MO.isDef())
continue;
255 if (MO.getReg() == ARM::CPSR)
261 bool ARMFastISel::isARMNEONPred(
const MachineInstr *MI) {
266 AFI->isThumb2Function())
270 if (opInfo.isPredicate())
288 if (isARMNEONPred(MI))
294 if (DefinesOptionalPredicate(MI, &CPSR))
299 unsigned ARMFastISel::fastEmitInst_r(
unsigned MachineInstOpcode,
301 unsigned Op0,
bool Op0IsKill) {
302 unsigned ResultReg = createResultReg(RC);
309 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II,
312 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
314 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
315 TII.get(TargetOpcode::COPY), ResultReg)
321 unsigned ARMFastISel::fastEmitInst_rr(
unsigned MachineInstOpcode,
323 unsigned Op0,
bool Op0IsKill,
324 unsigned Op1,
bool Op1IsKill) {
325 unsigned ResultReg = createResultReg(RC);
335 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, ResultReg)
336 .
addReg(Op0, Op0IsKill * RegState::Kill)
337 .
addReg(Op1, Op1IsKill * RegState::Kill));
339 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
340 .
addReg(Op0, Op0IsKill * RegState::Kill)
341 .
addReg(Op1, Op1IsKill * RegState::Kill));
342 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
343 TII.get(TargetOpcode::COPY), ResultReg)
349 unsigned ARMFastISel::fastEmitInst_ri(
unsigned MachineInstOpcode,
351 unsigned Op0,
bool Op0IsKill,
353 unsigned ResultReg = createResultReg(RC);
361 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, ResultReg)
362 .
addReg(Op0, Op0IsKill * RegState::Kill)
365 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
366 .
addReg(Op0, Op0IsKill * RegState::Kill)
368 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
369 TII.get(TargetOpcode::COPY), ResultReg)
375 unsigned ARMFastISel::fastEmitInst_i(
unsigned MachineInstOpcode,
378 unsigned ResultReg = createResultReg(RC);
382 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II,
385 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
387 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
388 TII.get(TargetOpcode::COPY), ResultReg)
396 unsigned ARMFastISel::ARMMoveToFPReg(
MVT VT,
unsigned SrcReg) {
399 unsigned MoveReg = createResultReg(TLI.getRegClassFor(VT));
400 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
401 TII.get(ARM::VMOVSR), MoveReg)
406 unsigned ARMFastISel::ARMMoveToIntReg(
MVT VT,
unsigned SrcReg) {
409 unsigned MoveReg = createResultReg(TLI.getRegClassFor(VT));
410 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
411 TII.get(ARM::VMOVRS), MoveReg)
419 unsigned ARMFastISel::ARMMaterializeFP(
const ConstantFP *CFP,
MVT VT) {
425 if (TLI.isFPImmLegal(Val, VT)) {
435 unsigned DestReg = createResultReg(TLI.getRegClassFor(VT));
436 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
437 TII.get(Opc), DestReg).addImm(Imm));
442 if (!Subtarget->hasVFP2())
return false;
450 unsigned Idx = MCP.getConstantPoolIndex(cast<Constant>(CFP), Align);
451 unsigned DestReg = createResultReg(TLI.getRegClassFor(VT));
452 unsigned Opc = is64bit ? ARM::VLDRD : ARM::VLDRS;
456 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
457 .addConstantPoolIndex(Idx)
462 unsigned ARMFastISel::ARMMaterializeInt(
const Constant *
C,
MVT VT) {
470 unsigned Opc = isThumb2 ? ARM::t2MOVi16 : ARM::MOVi16;
473 unsigned ImmReg = createResultReg(RC);
474 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
475 TII.get(Opc), ImmReg)
486 unsigned Opc = isThumb2 ? ARM::t2MVNi : ARM::MVNi;
489 unsigned ImmReg = createResultReg(RC);
490 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
491 TII.get(Opc), ImmReg)
497 unsigned ResultReg = 0;
498 if (Subtarget->useMovt(*FuncInfo.MF))
514 unsigned Idx = MCP.getConstantPoolIndex(C, Align);
515 ResultReg = createResultReg(TLI.getRegClassFor(VT));
517 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
518 TII.get(ARM::t2LDRpci), ResultReg)
519 .addConstantPoolIndex(Idx));
523 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
524 TII.get(ARM::LDRcp), ResultReg)
525 .addConstantPoolIndex(Idx)
531 bool ARMFastISel::isPositionIndependent()
const {
532 return TLI.isPositionIndependent();
535 unsigned ARMFastISel::ARMMaterializeGV(
const GlobalValue *GV,
MVT VT) {
540 if (Subtarget->isROPI() || Subtarget->isRWPI())
543 bool IsIndirect = Subtarget->isGVIndirectSymbol(GV);
546 unsigned DestReg = createResultReg(RC);
551 if (!Subtarget->isTargetMachO() && IsThreadLocal)
return 0;
553 bool IsPositionIndependent = isPositionIndependent();
556 if (Subtarget->useMovt(*FuncInfo.MF) &&
557 (Subtarget->isTargetMachO() || !IsPositionIndependent)) {
559 unsigned char TF = 0;
560 if (Subtarget->isTargetMachO())
563 if (IsPositionIndependent)
564 Opc = isThumb2 ? ARM::t2MOV_ga_pcrel : ARM::MOV_ga_pcrel;
566 Opc = isThumb2 ? ARM::t2MOVi32imm : ARM::MOVi32imm;
567 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
568 TII.get(Opc), DestReg).addGlobalAddress(GV, 0, TF));
577 if (Subtarget->isTargetELF() && IsPositionIndependent)
578 return ARMLowerPICELF(GV, Align, VT);
581 unsigned PCAdj = IsPositionIndependent ? (Subtarget->isThumb() ? 4 : 8) : 0;
582 unsigned Id = AFI->createPICLabelUId();
586 unsigned Idx = MCP.getConstantPoolIndex(CPV, Align);
591 unsigned Opc = IsPositionIndependent ? ARM::t2LDRpci_pic : ARM::t2LDRpci;
592 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc),
593 DestReg).addConstantPoolIndex(Idx);
594 if (IsPositionIndependent)
596 AddOptionalDefs(MIB);
600 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
601 TII.get(ARM::LDRcp), DestReg)
602 .addConstantPoolIndex(Idx)
604 AddOptionalDefs(MIB);
606 if (IsPositionIndependent) {
607 unsigned Opc = IsIndirect ? ARM::PICLDR : ARM::PICADD;
608 unsigned NewDestReg = createResultReg(TLI.getRegClassFor(VT));
611 DbgLoc,
TII.get(Opc), NewDestReg)
614 AddOptionalDefs(MIB);
622 unsigned NewDestReg = createResultReg(TLI.getRegClassFor(VT));
624 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
625 TII.get(ARM::t2LDRi12), NewDestReg)
629 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
630 TII.get(ARM::LDRi12), NewDestReg)
633 DestReg = NewDestReg;
634 AddOptionalDefs(MIB);
640 unsigned ARMFastISel::fastMaterializeConstant(
const Constant *C) {
647 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(C))
648 return ARMMaterializeFP(CFP, VT);
649 else if (
const GlobalValue *GV = dyn_cast<GlobalValue>(C))
650 return ARMMaterializeGV(GV, VT);
651 else if (isa<ConstantInt>(C))
652 return ARMMaterializeInt(C, VT);
659 unsigned ARMFastISel::fastMaterializeAlloca(
const AllocaInst *AI) {
661 if (!FuncInfo.StaticAllocaMap.count(AI))
return 0;
664 if (!isLoadTypeLegal(AI->
getType(), VT))
return 0;
667 FuncInfo.StaticAllocaMap.find(AI);
671 if (SI != FuncInfo.StaticAllocaMap.
end()) {
672 unsigned Opc = isThumb2 ? ARM::t2ADDri : ARM::ADDri;
674 unsigned ResultReg = createResultReg(RC);
677 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
678 TII.get(Opc), ResultReg)
679 .addFrameIndex(SI->second)
687 bool ARMFastISel::isTypeLegal(
Type *Ty,
MVT &VT) {
688 EVT evt = TLI.getValueType(
DL, Ty,
true);
696 return TLI.isTypeLegal(VT);
699 bool ARMFastISel::isLoadTypeLegal(
Type *Ty,
MVT &VT) {
700 if (isTypeLegal(Ty, VT))
return true;
711 bool ARMFastISel::ARMComputeAddress(
const Value *Obj,
Address &Addr) {
713 const User *U =
nullptr;
714 unsigned Opcode = Instruction::UserOp1;
715 if (
const Instruction *
I = dyn_cast<Instruction>(Obj)) {
718 if (FuncInfo.StaticAllocaMap.count(static_cast<const AllocaInst *>(Obj)) ||
719 FuncInfo.MBBMap[
I->getParent()] == FuncInfo.MBB) {
720 Opcode =
I->getOpcode();
723 }
else if (
const ConstantExpr *C = dyn_cast<ConstantExpr>(Obj)) {
724 Opcode = C->getOpcode();
729 if (Ty->getAddressSpace() > 255)
737 case Instruction::BitCast:
739 return ARMComputeAddress(U->
getOperand(0), Addr);
740 case Instruction::IntToPtr:
743 TLI.getPointerTy(
DL))
744 return ARMComputeAddress(U->
getOperand(0), Addr);
746 case Instruction::PtrToInt:
748 if (TLI.getValueType(
DL, U->
getType()) == TLI.getPointerTy(
DL))
749 return ARMComputeAddress(U->
getOperand(0), Addr);
751 case Instruction::GetElementPtr: {
753 int TmpOffset = Addr.Offset;
759 i != e; ++i, ++GTI) {
763 unsigned Idx = cast<ConstantInt>(
Op)->getZExtValue();
768 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(Op)) {
773 if (canFoldAddIntoGEP(U, Op)) {
776 cast<ConstantInt>(cast<AddOperator>(
Op)->getOperand(1));
779 Op = cast<AddOperator>(
Op)->getOperand(0);
783 goto unsupported_gep;
789 Addr.Offset = TmpOffset;
790 if (ARMComputeAddress(U->
getOperand(0), Addr))
return true;
798 case Instruction::Alloca: {
801 FuncInfo.StaticAllocaMap.
find(AI);
802 if (SI != FuncInfo.StaticAllocaMap.end()) {
803 Addr.BaseType = Address::FrameIndexBase;
804 Addr.Base.FI = SI->second;
812 if (Addr.Base.Reg == 0) Addr.Base.Reg = getRegForValue(Obj);
813 return Addr.Base.Reg != 0;
816 void ARMFastISel::ARMSimplifyAddress(
Address &Addr,
MVT VT,
bool useAM3) {
817 bool needsLowering =
false;
826 needsLowering = ((Addr.Offset & 0xfff) != Addr.Offset);
828 if (needsLowering && isThumb2)
829 needsLowering = !(Subtarget->hasV6T2Ops() && Addr.Offset < 0 &&
833 needsLowering = (Addr.Offset > 255 || Addr.Offset < -255);
839 needsLowering = ((Addr.Offset & 0xff) != Addr.Offset);
846 if (needsLowering && Addr.BaseType == Address::FrameIndexBase) {
849 unsigned ResultReg = createResultReg(RC);
850 unsigned Opc = isThumb2 ? ARM::t2ADDri : ARM::ADDri;
851 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
852 TII.get(Opc), ResultReg)
853 .addFrameIndex(Addr.Base.FI)
855 Addr.Base.Reg = ResultReg;
856 Addr.BaseType = Address::RegBase;
868 void ARMFastISel::AddLoadStoreOperands(
MVT VT,
Address &Addr,
878 if (Addr.BaseType == Address::FrameIndexBase) {
879 int FI = Addr.Base.FI;
883 MFI.getObjectSize(FI), MFI.getObjectAlignment(FI));
890 int Imm = (Addr.Offset < 0) ? (0x100 | -Addr.Offset) : Addr.Offset;
899 MIB.
addReg(Addr.Base.Reg);
904 int Imm = (Addr.Offset < 0) ? (0x100 | -Addr.Offset) : Addr.Offset;
911 AddOptionalDefs(MIB);
914 bool ARMFastISel::ARMEmitLoad(
MVT VT,
unsigned &ResultReg,
Address &Addr,
915 unsigned Alignment,
bool isZExt,
bool allocReg) {
918 bool needVMOV =
false;
922 default:
return false;
926 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
927 Opc = isZExt ? ARM::t2LDRBi8 : ARM::t2LDRSBi8;
929 Opc = isZExt ? ARM::t2LDRBi12 : ARM::t2LDRSBi12;
938 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
941 if (Alignment && Alignment < 2 && !Subtarget->allowsUnalignedMem())
945 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
946 Opc = isZExt ? ARM::t2LDRHi8 : ARM::t2LDRSHi8;
948 Opc = isZExt ? ARM::t2LDRHi12 : ARM::t2LDRSHi12;
950 Opc = isZExt ? ARM::LDRH : ARM::LDRSH;
953 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
956 if (Alignment && Alignment < 4 && !Subtarget->allowsUnalignedMem())
960 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
967 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
970 if (!Subtarget->hasVFP2())
return false;
972 if (Alignment && Alignment < 4) {
975 Opc = isThumb2 ? ARM::t2LDRi12 : ARM::LDRi12;
976 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
979 RC = TLI.getRegClassFor(VT);
983 if (!Subtarget->hasVFP2())
return false;
986 if (Alignment && Alignment < 4)
990 RC = TLI.getRegClassFor(VT);
994 ARMSimplifyAddress(Addr, VT, useAM3);
998 ResultReg = createResultReg(RC);
999 assert(ResultReg > 255 &&
"Expected an allocated virtual register.");
1001 TII.get(Opc), ResultReg);
1007 unsigned MoveReg = createResultReg(TLI.getRegClassFor(
MVT::f32));
1008 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1009 TII.get(ARM::VMOVSR), MoveReg)
1010 .addReg(ResultReg));
1011 ResultReg = MoveReg;
1022 if (TLI.supportSwiftError()) {
1025 if (
const Argument *Arg = dyn_cast<Argument>(SV)) {
1026 if (Arg->hasSwiftErrorAttr())
1030 if (
const AllocaInst *Alloca = dyn_cast<AllocaInst>(SV)) {
1031 if (Alloca->isSwiftError())
1038 if (!isLoadTypeLegal(I->
getType(), VT))
1043 if (!ARMComputeAddress(I->
getOperand(0), Addr))
return false;
1046 if (!ARMEmitLoad(VT, ResultReg, Addr, cast<LoadInst>(I)->getAlignment()))
1048 updateValueMap(I, ResultReg);
1052 bool ARMFastISel::ARMEmitStore(
MVT VT,
unsigned SrcReg,
Address &Addr,
1053 unsigned Alignment) {
1055 bool useAM3 =
false;
1058 default:
return false;
1060 unsigned Res = createResultReg(isThumb2 ? &ARM::tGPRRegClass
1061 : &ARM::GPRRegClass);
1062 unsigned Opc = isThumb2 ? ARM::t2ANDri : ARM::ANDri;
1064 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1066 .addReg(SrcReg).
addImm(1));
1072 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
1073 StrOpc = ARM::t2STRBi8;
1075 StrOpc = ARM::t2STRBi12;
1077 StrOpc = ARM::STRBi12;
1081 if (Alignment && Alignment < 2 && !Subtarget->allowsUnalignedMem())
1085 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
1086 StrOpc = ARM::t2STRHi8;
1088 StrOpc = ARM::t2STRHi12;
1095 if (Alignment && Alignment < 4 && !Subtarget->allowsUnalignedMem())
1099 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
1100 StrOpc = ARM::t2STRi8;
1102 StrOpc = ARM::t2STRi12;
1104 StrOpc = ARM::STRi12;
1108 if (!Subtarget->hasVFP2())
return false;
1110 if (Alignment && Alignment < 4) {
1111 unsigned MoveReg = createResultReg(TLI.getRegClassFor(
MVT::i32));
1112 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1113 TII.get(ARM::VMOVRS), MoveReg)
1117 StrOpc = isThumb2 ? ARM::t2STRi12 : ARM::STRi12;
1119 StrOpc = ARM::VSTRS;
1123 if (!Subtarget->hasVFP2())
return false;
1126 if (Alignment && Alignment < 4)
1129 StrOpc = ARM::VSTRD;
1133 ARMSimplifyAddress(Addr, VT, useAM3);
1144 bool ARMFastISel::SelectStore(
const Instruction *I) {
1146 unsigned SrcReg = 0;
1149 if (cast<StoreInst>(I)->
isAtomic())
1153 if (TLI.supportSwiftError()) {
1156 if (
const Argument *Arg = dyn_cast<Argument>(PtrV)) {
1157 if (Arg->hasSwiftErrorAttr())
1161 if (
const AllocaInst *Alloca = dyn_cast<AllocaInst>(PtrV)) {
1162 if (Alloca->isSwiftError())
1173 SrcReg = getRegForValue(Op0);
1174 if (SrcReg == 0)
return false;
1178 if (!ARMComputeAddress(I->
getOperand(1), Addr))
1181 if (!ARMEmitStore(VT, SrcReg, Addr, cast<StoreInst>(I)->getAlignment()))
1233 bool ARMFastISel::SelectBranch(
const Instruction *I) {
1247 if (FuncInfo.MBB->isLayoutSuccessor(TBB)) {
1262 unsigned BrOpc = isThumb2 ? ARM::t2Bcc : ARM::Bcc;
1263 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(BrOpc))
1265 finishCondBranch(BI->
getParent(), TBB, FBB);
1270 if (TI->hasOneUse() && TI->getParent() == I->
getParent() &&
1271 (isLoadTypeLegal(TI->getOperand(0)->getType(), SourceVT))) {
1272 unsigned TstOpc = isThumb2 ? ARM::t2TSTri : ARM::TSTri;
1273 unsigned OpReg = getRegForValue(TI->getOperand(0));
1275 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1277 .addReg(OpReg).
addImm(1));
1280 if (FuncInfo.MBB->isLayoutSuccessor(TBB)) {
1285 unsigned BrOpc = isThumb2 ? ARM::t2Bcc : ARM::Bcc;
1286 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(BrOpc))
1289 finishCondBranch(BI->
getParent(), TBB, FBB);
1296 fastEmitBranch(Target, DbgLoc);
1301 if (CmpReg == 0)
return false;
1310 unsigned TstOpc = isThumb2 ? ARM::t2TSTri : ARM::TSTri;
1313 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(TstOpc))
1318 if (FuncInfo.MBB->isLayoutSuccessor(TBB)) {
1323 unsigned BrOpc = isThumb2 ? ARM::t2Bcc : ARM::Bcc;
1324 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(BrOpc))
1326 finishCondBranch(BI->
getParent(), TBB, FBB);
1330 bool ARMFastISel::SelectIndirectBr(
const Instruction *I) {
1331 unsigned AddrReg = getRegForValue(I->
getOperand(0));
1332 if (AddrReg == 0)
return false;
1334 unsigned Opc = isThumb2 ? ARM::tBRIND : ARM::BX;
1335 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1336 TII.get(Opc)).addReg(AddrReg));
1339 for (
const BasicBlock *SuccBB : IB->successors())
1340 FuncInfo.MBB->addSuccessor(FuncInfo.MBBMap[SuccBB]);
1345 bool ARMFastISel::ARMEmitCmp(
const Value *Src1Value,
const Value *Src2Value,
1346 bool isZExt,
bool isEquality) {
1348 EVT SrcEVT = TLI.getValueType(
DL, Ty,
true);
1349 if (!SrcEVT.
isSimple())
return false;
1352 if (Ty->
isFloatTy() && !Subtarget->hasVFP2())
1355 if (Ty->
isDoubleTy() && (!Subtarget->hasVFP2() || Subtarget->isFPOnlySP()))
1361 bool UseImm =
false;
1362 bool isNegativeImm =
false;
1365 if (
const ConstantInt *ConstInt = dyn_cast<ConstantInt>(Src2Value)) {
1368 const APInt &CIVal = ConstInt->getValue();
1373 if (Imm < 0 && Imm != (
int)0x80000000) {
1374 isNegativeImm =
true;
1380 }
else if (
const ConstantFP *ConstFP = dyn_cast<ConstantFP>(Src2Value)) {
1382 if (ConstFP->isZero() && !ConstFP->isNegative())
1388 bool needsExt =
false;
1390 default:
return false;
1396 CmpOpc = UseImm ? ARM::VCMPZS : ARM::VCMPS;
1398 CmpOpc = UseImm ? ARM::VCMPEZS : ARM::VCMPES;
1404 CmpOpc = UseImm ? ARM::VCMPZD : ARM::VCMPD;
1406 CmpOpc = UseImm ? ARM::VCMPEZD : ARM::VCMPED;
1416 CmpOpc = ARM::t2CMPrr;
1418 CmpOpc = isNegativeImm ? ARM::t2CMNri : ARM::t2CMPri;
1421 CmpOpc = ARM::CMPrr;
1423 CmpOpc = isNegativeImm ? ARM::CMNri : ARM::CMPri;
1428 unsigned SrcReg1 = getRegForValue(Src1Value);
1429 if (SrcReg1 == 0)
return false;
1431 unsigned SrcReg2 = 0;
1433 SrcReg2 = getRegForValue(Src2Value);
1434 if (SrcReg2 == 0)
return false;
1439 SrcReg1 = ARMEmitIntExt(SrcVT, SrcReg1,
MVT::i32, isZExt);
1440 if (SrcReg1 == 0)
return false;
1442 SrcReg2 = ARMEmitIntExt(SrcVT, SrcReg2,
MVT::i32, isZExt);
1443 if (SrcReg2 == 0)
return false;
1451 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
1455 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
1461 AddOptionalDefs(MIB);
1467 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1472 bool ARMFastISel::SelectCmp(
const Instruction *I) {
1473 const CmpInst *CI = cast<CmpInst>(
I);
1488 unsigned MovCCOpc = isThumb2 ? ARM::t2MOVCCi : ARM::MOVCCi;
1490 : &ARM::GPRRegClass;
1491 unsigned DestReg = createResultReg(RC);
1493 unsigned ZeroReg = fastMaterializeConstant(Zero);
1495 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(MovCCOpc), DestReg)
1496 .addReg(ZeroReg).
addImm(1)
1499 updateValueMap(I, DestReg);
1503 bool ARMFastISel::SelectFPExt(
const Instruction *I) {
1505 if (!Subtarget->hasVFP2() || Subtarget->isFPOnlySP())
return false;
1511 unsigned Op = getRegForValue(V);
1512 if (Op == 0)
return false;
1514 unsigned Result = createResultReg(&ARM::DPRRegClass);
1515 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1516 TII.get(ARM::VCVTDS), Result)
1518 updateValueMap(I, Result);
1522 bool ARMFastISel::SelectFPTrunc(
const Instruction *I) {
1524 if (!Subtarget->hasVFP2() || Subtarget->isFPOnlySP())
return false;
1530 unsigned Op = getRegForValue(V);
1531 if (Op == 0)
return false;
1533 unsigned Result = createResultReg(&ARM::SPRRegClass);
1534 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1535 TII.get(ARM::VCVTSD), Result)
1537 updateValueMap(I, Result);
1541 bool ARMFastISel::SelectIToFP(
const Instruction *I,
bool isSigned) {
1543 if (!Subtarget->hasVFP2())
return false;
1547 if (!isTypeLegal(Ty, DstVT))
1551 EVT SrcEVT = TLI.getValueType(
DL, Src->
getType(),
true);
1558 unsigned SrcReg = getRegForValue(Src);
1559 if (SrcReg == 0)
return false;
1563 SrcReg = ARMEmitIntExt(SrcVT, SrcReg,
MVT::i32,
1565 if (SrcReg == 0)
return false;
1570 unsigned FP = ARMMoveToFPReg(
MVT::f32, SrcReg);
1571 if (FP == 0)
return false;
1574 if (Ty->
isFloatTy()) Opc = isSigned ? ARM::VSITOS : ARM::VUITOS;
1575 else if (Ty->
isDoubleTy() && !Subtarget->isFPOnlySP())
1576 Opc = isSigned ? ARM::VSITOD : ARM::VUITOD;
1579 unsigned ResultReg = createResultReg(TLI.getRegClassFor(DstVT));
1580 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1581 TII.get(Opc), ResultReg).addReg(FP));
1582 updateValueMap(I, ResultReg);
1586 bool ARMFastISel::SelectFPToI(
const Instruction *I,
bool isSigned) {
1588 if (!Subtarget->hasVFP2())
return false;
1592 if (!isTypeLegal(RetTy, DstVT))
1595 unsigned Op = getRegForValue(I->
getOperand(0));
1596 if (Op == 0)
return false;
1600 if (OpTy->
isFloatTy()) Opc = isSigned ? ARM::VTOSIZS : ARM::VTOUIZS;
1601 else if (OpTy->
isDoubleTy() && !Subtarget->isFPOnlySP())
1602 Opc = isSigned ? ARM::VTOSIZD : ARM::VTOUIZD;
1606 unsigned ResultReg = createResultReg(TLI.getRegClassFor(
MVT::f32));
1607 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1608 TII.get(Opc), ResultReg).addReg(Op));
1612 unsigned IntReg = ARMMoveToIntReg(DstVT, ResultReg);
1613 if (IntReg == 0)
return false;
1615 updateValueMap(I, IntReg);
1619 bool ARMFastISel::SelectSelect(
const Instruction *I) {
1621 if (!isTypeLegal(I->
getType(), VT))
1627 unsigned CondReg = getRegForValue(I->
getOperand(0));
1628 if (CondReg == 0)
return false;
1629 unsigned Op1Reg = getRegForValue(I->
getOperand(1));
1630 if (Op1Reg == 0)
return false;
1634 bool UseImm =
false;
1635 bool isNegativeImm =
false;
1638 Imm = (int)ConstInt->getValue().getZExtValue();
1640 isNegativeImm =
true;
1647 unsigned Op2Reg = 0;
1650 if (Op2Reg == 0)
return false;
1653 unsigned TstOpc = isThumb2 ? ARM::t2TSTri : ARM::TSTri;
1656 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(TstOpc))
1663 RC = isThumb2 ? &ARM::tGPRRegClass : &ARM::GPRRegClass;
1664 MovCCOpc = isThumb2 ? ARM::t2MOVCCr : ARM::MOVCCr;
1666 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRRegClass;
1668 MovCCOpc = isThumb2 ? ARM::t2MOVCCi : ARM::MOVCCi;
1670 MovCCOpc = isThumb2 ? ARM::t2MVNCCi : ARM::MVNCCi;
1672 unsigned ResultReg = createResultReg(RC);
1676 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(MovCCOpc),
1684 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(MovCCOpc),
1691 updateValueMap(I, ResultReg);
1695 bool ARMFastISel::SelectDiv(
const Instruction *I,
bool isSigned) {
1698 if (!isTypeLegal(Ty, VT))
1704 if (Subtarget->hasDivideInThumbMode())
1721 return ARMEmitLibcall(I, LC);
1724 bool ARMFastISel::SelectRem(
const Instruction *I,
bool isSigned) {
1727 if (!isTypeLegal(Ty, VT))
1733 if (!TLI.hasStandaloneRem(VT)) {
1750 return ARMEmitLibcall(I, LC);
1753 bool ARMFastISel::SelectBinaryIntOp(
const Instruction *I,
unsigned ISDOpcode) {
1762 switch (ISDOpcode) {
1763 default:
return false;
1765 Opc = isThumb2 ? ARM::t2ADDrr : ARM::ADDrr;
1768 Opc = isThumb2 ? ARM::t2ORRrr : ARM::ORRrr;
1771 Opc = isThumb2 ? ARM::t2SUBrr : ARM::SUBrr;
1775 unsigned SrcReg1 = getRegForValue(I->
getOperand(0));
1776 if (SrcReg1 == 0)
return false;
1780 unsigned SrcReg2 = getRegForValue(I->
getOperand(1));
1781 if (SrcReg2 == 0)
return false;
1783 unsigned ResultReg = createResultReg(&ARM::GPRnopcRegClass);
1786 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1787 TII.get(Opc), ResultReg)
1788 .addReg(SrcReg1).
addReg(SrcReg2));
1789 updateValueMap(I, ResultReg);
1793 bool ARMFastISel::SelectBinaryFPOp(
const Instruction *I,
unsigned ISDOpcode) {
1795 if (!FPVT.
isSimple())
return false;
1807 if (Ty->
isFloatTy() && !Subtarget->hasVFP2())
1809 if (Ty->
isDoubleTy() && (!Subtarget->hasVFP2() || Subtarget->isFPOnlySP()))
1814 switch (ISDOpcode) {
1815 default:
return false;
1817 Opc = is64bit ? ARM::VADDD : ARM::VADDS;
1820 Opc = is64bit ? ARM::VSUBD : ARM::VSUBS;
1823 Opc = is64bit ? ARM::VMULD : ARM::VMULS;
1826 unsigned Op1 = getRegForValue(I->
getOperand(0));
1827 if (Op1 == 0)
return false;
1829 unsigned Op2 = getRegForValue(I->
getOperand(1));
1830 if (Op2 == 0)
return false;
1832 unsigned ResultReg = createResultReg(TLI.getRegClassFor(VT.
SimpleTy));
1833 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1834 TII.get(Opc), ResultReg)
1835 .addReg(Op1).
addReg(Op2));
1836 updateValueMap(I, ResultReg);
1851 if (Subtarget->hasVFP2() && !isVarArg) {
1852 if (!Subtarget->isAAPCS_ABI())
1853 return (Return ? RetFastCC_ARM_APCS : FastCC_ARM_APCS);
1855 return (Return ? RetCC_ARM_AAPCS_VFP : CC_ARM_AAPCS_VFP);
1861 if (Subtarget->isAAPCS_ABI()) {
1862 if (Subtarget->hasVFP2() &&
1864 return (Return ? RetCC_ARM_AAPCS_VFP: CC_ARM_AAPCS_VFP);
1866 return (Return ? RetCC_ARM_AAPCS: CC_ARM_AAPCS);
1868 return (Return ? RetCC_ARM_APCS: CC_ARM_APCS);
1873 return (Return ? RetCC_ARM_AAPCS_VFP: CC_ARM_AAPCS_VFP);
1878 return (Return ? RetCC_ARM_AAPCS: CC_ARM_AAPCS);
1880 return (Return ? RetCC_ARM_APCS: CC_ARM_APCS);
1885 return CC_ARM_APCS_GHC;
1899 CCInfo.AnalyzeCallOperands(ArgVTs, ArgFlags,
1900 CCAssignFnForCall(CC,
false, isVarArg));
1904 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
1919 !VA.
isRegLoc() || !ArgLocs[++i].isRegLoc())
1931 if (!Subtarget->hasVFP2())
1935 if (!Subtarget->hasVFP2())
1945 NumBytes = CCInfo.getNextStackOffset();
1948 unsigned AdjStackDown =
TII.getCallFrameSetupOpcode();
1949 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1950 TII.get(AdjStackDown))
1951 .addImm(NumBytes).
addImm(0));
1954 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
1957 unsigned Arg = ArgRegs[VA.
getValNo()];
1961 "We don't handle NEON/vector parameters yet.");
1968 Arg = ARMEmitIntExt(ArgVT, Arg, DestVT,
false);
1969 assert(Arg != 0 &&
"Failed to emit a sext");
1977 Arg = ARMEmitIntExt(ArgVT, Arg, DestVT,
true);
1978 assert(Arg != 0 &&
"Failed to emit a zext");
1985 assert(BC != 0 &&
"Failed to emit a bitcast!");
1995 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1996 TII.get(TargetOpcode::COPY), VA.
getLocReg()).addReg(Arg);
2001 "Custom lowering for v2f64 args not available");
2007 "We only handle register args!");
2009 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2020 if (isa<UndefValue>(ArgVal))
2024 Addr.BaseType = Address::RegBase;
2025 Addr.Base.Reg = ARM::SP;
2028 bool EmitRet = ARMEmitStore(ArgVT, Arg, Addr); (void)EmitRet;
2029 assert(EmitRet &&
"Could not emit a store for argument!");
2038 unsigned &NumBytes,
bool isVarArg) {
2040 unsigned AdjStackUp =
TII.getCallFrameDestroyOpcode();
2041 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2042 TII.get(AdjStackUp))
2043 .addImm(NumBytes).
addImm(0));
2049 CCInfo.AnalyzeCallResult(RetVT, CCAssignFnForCall(CC,
true, isVarArg));
2055 MVT DestVT = RVLocs[0].getValVT();
2057 unsigned ResultReg = createResultReg(DstRC);
2058 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2060 .addReg(RVLocs[0].getLocReg())
2061 .addReg(RVLocs[1].getLocReg()));
2063 UsedRegs.
push_back(RVLocs[0].getLocReg());
2064 UsedRegs.
push_back(RVLocs[1].getLocReg());
2067 updateValueMap(I, ResultReg);
2069 assert(RVLocs.
size() == 1 &&
"Can't handle non-double multi-reg retvals!");
2070 MVT CopyVT = RVLocs[0].getValVT();
2078 unsigned ResultReg = createResultReg(DstRC);
2079 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2080 TII.get(TargetOpcode::COPY),
2081 ResultReg).addReg(RVLocs[0].getLocReg());
2082 UsedRegs.
push_back(RVLocs[0].getLocReg());
2085 updateValueMap(I, ResultReg);
2092 bool ARMFastISel::SelectRet(
const Instruction *I) {
2096 if (!FuncInfo.CanLowerReturn)
2099 if (TLI.supportSwiftError() &&
2100 F.getAttributes().hasAttrSomewhere(Attribute::SwiftError))
2103 if (TLI.supportSplitCSR(FuncInfo.MF))
2121 unsigned Reg = getRegForValue(RV);
2126 if (ValLocs.size() != 1)
2138 unsigned SrcReg = Reg + VA.
getValNo();
2140 if (!RVEVT.
isSimple())
return false;
2144 if (RVVT != DestVT) {
2152 if (Outs[0].Flags.isZExt() || Outs[0].Flags.isSExt()) {
2153 SrcReg = ARMEmitIntExt(RVVT, SrcReg, DestVT, Outs[0].Flags.isZExt());
2154 if (SrcReg == 0)
return false;
2164 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2165 TII.get(TargetOpcode::COPY), DstReg).addReg(SrcReg);
2171 unsigned RetOpc = isThumb2 ? ARM::tBX_RET : ARM::BX_RET;
2174 AddOptionalDefs(MIB);
2175 for (
unsigned R : RetRegs)
2180 unsigned ARMFastISel::ARMSelectCallOp(
bool UseReg) {
2182 return isThumb2 ? ARM::tBLXr : ARM::BLX;
2184 return isThumb2 ? ARM::tBL : ARM::BL;
2187 unsigned ARMFastISel::getLibcallReg(
const Twine &
Name) {
2190 EVT LCREVT = TLI.getValueType(
DL, GVTy);
2196 assert(GV->
getType() == GVTy &&
"We miscomputed the type for the global!");
2197 return ARMMaterializeGV(GV, LCREVT.
getSimpleVT());
2215 else if (!isTypeLegal(RetTy, RetVT))
2222 CCInfo.AnalyzeCallResult(RetVT, CCAssignFnForCall(CC,
true,
false));
2237 unsigned Arg = getRegForValue(Op);
2238 if (Arg == 0)
return false;
2240 Type *ArgTy = Op->getType();
2242 if (!isTypeLegal(ArgTy, ArgVT))
return false;
2257 if (!ProcessCallArgs(Args, ArgRegs, ArgVTs, ArgFlags,
2258 RegArgs, CC, NumBytes,
false))
2261 unsigned CalleeReg = 0;
2262 if (Subtarget->genLongCalls()) {
2263 CalleeReg = getLibcallReg(TLI.getLibcallName(Call));
2264 if (CalleeReg == 0)
return false;
2268 unsigned CallOpc = ARMSelectCallOp(Subtarget->genLongCalls());
2270 DbgLoc,
TII.get(CallOpc));
2274 if (Subtarget->genLongCalls())
2280 for (
unsigned R : RegArgs)
2285 MIB.
addRegMask(TRI.getCallPreservedMask(*FuncInfo.MF, CC));
2289 if (!FinishCall(RetVT, UsedRegs, I, CC, NumBytes,
false))
return false;
2292 static_cast<MachineInstr *
>(MIB)->setPhysRegsDeadExcept(UsedRegs, TRI);
2297 bool ARMFastISel::SelectCall(
const Instruction *I,
2298 const char *IntrMemName =
nullptr) {
2303 if (isa<InlineAsm>(Callee))
return false;
2322 else if (!isTypeLegal(RetTy, RetVT) && RetVT !=
MVT::i16 &&
2331 CCInfo.AnalyzeCallResult(RetVT, CCAssignFnForCall(CC,
true, isVarArg));
2341 unsigned arg_size =
CS.arg_size();
2350 if (IntrMemName && e-i <= 2)
2354 unsigned ArgIdx = i -
CS.arg_begin();
2355 if (
CS.paramHasAttr(ArgIdx, Attribute::SExt))
2357 if (
CS.paramHasAttr(ArgIdx, Attribute::ZExt))
2361 if (
CS.paramHasAttr(ArgIdx, Attribute::InReg) ||
2362 CS.paramHasAttr(ArgIdx, Attribute::StructRet) ||
2363 CS.paramHasAttr(ArgIdx, Attribute::SwiftSelf) ||
2364 CS.paramHasAttr(ArgIdx, Attribute::SwiftError) ||
2365 CS.paramHasAttr(ArgIdx, Attribute::Nest) ||
2366 CS.paramHasAttr(ArgIdx, Attribute::ByVal))
2369 Type *ArgTy = (*i)->getType();
2371 if (!isTypeLegal(ArgTy, ArgVT) && ArgVT !=
MVT::i16 && ArgVT !=
MVT::i8 &&
2375 unsigned Arg = getRegForValue(*i);
2391 if (!ProcessCallArgs(Args, ArgRegs, ArgVTs, ArgFlags,
2392 RegArgs, CC, NumBytes, isVarArg))
2395 bool UseReg =
false;
2397 if (!GV || Subtarget->genLongCalls()) UseReg =
true;
2399 unsigned CalleeReg = 0;
2402 CalleeReg = getLibcallReg(IntrMemName);
2404 CalleeReg = getRegForValue(Callee);
2406 if (CalleeReg == 0)
return false;
2410 unsigned CallOpc = ARMSelectCallOp(UseReg);
2412 DbgLoc,
TII.get(CallOpc));
2419 else if (!IntrMemName)
2425 for (
unsigned R : RegArgs)
2430 MIB.
addRegMask(TRI.getCallPreservedMask(*FuncInfo.MF, CC));
2434 if (!FinishCall(RetVT, UsedRegs, I, CC, NumBytes, isVarArg))
2438 static_cast<MachineInstr *
>(MIB)->setPhysRegsDeadExcept(UsedRegs, TRI);
2443 bool ARMFastISel::ARMIsMemCpySmall(uint64_t Len) {
2447 bool ARMFastISel::ARMTryEmitSmallMemCpy(
Address Dest,
Address Src,
2448 uint64_t Len,
unsigned Alignment) {
2450 if (!ARMIsMemCpySmall(Len))
2455 if (!Alignment || Alignment >= 4) {
2461 assert(Len == 1 &&
"Expected a length of 1!");
2466 if (Len >= 2 && Alignment == 2)
2475 RV = ARMEmitLoad(VT, ResultReg, Src);
2476 assert(RV &&
"Should be able to handle this load.");
2477 RV = ARMEmitStore(VT, ResultReg, Dest);
2478 assert(RV &&
"Should be able to handle this store.");
2483 Dest.Offset +=
Size;
2490 bool ARMFastISel::SelectIntrinsicCall(
const IntrinsicInst &I) {
2493 default:
return false;
2494 case Intrinsic::frameaddress: {
2498 unsigned LdrOpc = isThumb2 ? ARM::t2LDRi12 : ARM::LDRi12;
2500 : &ARM::GPRRegClass;
2515 DestReg = createResultReg(RC);
2516 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2517 TII.get(LdrOpc), DestReg)
2518 .addReg(SrcReg).
addImm(0));
2521 updateValueMap(&I, SrcReg);
2524 case Intrinsic::memcpy:
2525 case Intrinsic::memmove: {
2534 if (isa<ConstantInt>(MTI.
getLength()) && isMemCpy) {
2537 uint64_t Len = cast<ConstantInt>(MTI.
getLength())->getZExtValue();
2538 if (ARMIsMemCpySmall(Len)) {
2540 if (!ARMComputeAddress(MTI.
getRawDest(), Dest) ||
2544 if (ARMTryEmitSmallMemCpy(Dest, Src, Len, Alignment))
2555 const char *IntrMemName = isa<MemCpyInst>(
I) ?
"memcpy" :
"memmove";
2556 return SelectCall(&I, IntrMemName);
2558 case Intrinsic::memset: {
2570 return SelectCall(&I,
"memset");
2572 case Intrinsic::trap: {
2573 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(
2574 Subtarget->useNaClTrap() ? ARM::TRAPNaCl :
ARM::TRAP));
2580 bool ARMFastISel::SelectTrunc(
const Instruction *I) {
2586 SrcVT = TLI.getValueType(
DL, Op->
getType(),
true);
2587 DestVT = TLI.getValueType(
DL, I->
getType(),
true);
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;
2754 SrcEVT = TLI.getValueType(
DL, SrcTy,
true);
2755 DestEVT = TLI.getValueType(
DL, DestTy,
true);
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)) {
2783 ShiftImm = CI->getZExtValue();
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)
2811 MIB.
addImm(ARM_AM::getSORegOpc(ShiftTy, ShiftImm));
2812 else if (Opc == ARM::MOVsr) {
2814 MIB.
addImm(ARM_AM::getSORegOpc(ShiftTy, 0));
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:
2898 const struct FoldableLoadExtendsStruct {
2900 uint8_t ExpectedImm;
2902 uint8_t ExpectedVT : 7;
2903 } FoldableLoadExtends[] = {
2906 { { ARM::ANDri, ARM::t2ANDri }, 255, 1,
MVT::i8 },
2917 bool ARMFastISel::tryToFoldLoadIntoMI(
MachineInstr *MI,
unsigned OpNo,
2921 if (!isLoadTypeLegal(LI->
getType(), VT))
2934 for (
const FoldableLoadExtendsStruct &FLE : FoldableLoadExtends) {
2935 if (FLE.Opc[isThumb2] == MI->
getOpcode() &&
2936 (uint64_t)FLE.ExpectedImm == Imm &&
2939 isZExt = FLE.isZExt;
2942 if (!Found)
return false;
2946 if (!ARMComputeAddress(LI->
getOperand(0), Addr))
return false;
2949 if (!ARMEmitLoad(VT, ResultReg, Addr, LI->
getAlignment(), isZExt,
false))
2955 unsigned ARMFastISel::ARMLowerPICELF(
const GlobalValue *GV,
2956 unsigned Align,
MVT VT) {
2957 bool UseGOT_PREL = !
TM.shouldAssumeDSOLocal(*GV->
getParent(), GV);
2960 unsigned ARMPCLabelIndex = AFI->createPICLabelUId();
2961 unsigned PCAdj = Subtarget->isThumb() ? 4 : 8;
2967 unsigned ConstAlign =
2969 unsigned Idx = MF->getConstantPool()->getConstantPoolIndex(CPV, ConstAlign);
2971 unsigned 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);
2976 if (Opc == ARM::LDRcp)
2981 unsigned DestReg = createResultReg(TLI.getRegClassFor(VT));
2982 Opc = Subtarget->isThumb() ? ARM::tPICADD : UseGOT_PREL ? ARM::PICLDR
2985 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), DestReg)
2987 .
addImm(ARMPCLabelIndex);
2988 if (!Subtarget->isThumb())
2991 if (UseGOT_PREL && Subtarget->isThumb()) {
2992 unsigned NewDestReg = createResultReg(TLI.getRegClassFor(VT));
2993 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
2994 TII.get(ARM::t2LDRi12), NewDestReg)
2997 DestReg = NewDestReg;
2998 AddOptionalDefs(MIB);
3003 bool ARMFastISel::fastLowerArguments() {
3004 if (!FuncInfo.CanLowerReturn)
3027 if (Arg.getArgNo() >= 4)
3030 if (Arg.hasAttribute(Attribute::InReg) ||
3031 Arg.hasAttribute(Attribute::StructRet) ||
3032 Arg.hasAttribute(Attribute::SwiftSelf) ||
3033 Arg.hasAttribute(Attribute::SwiftError) ||
3034 Arg.hasAttribute(Attribute::ByVal))
3037 Type *ArgTy = Arg.getType();
3041 EVT ArgVT = TLI.getValueType(
DL, ArgTy);
3042 if (!ArgVT.
isSimple())
return false;
3054 ARM::R0, ARM::R1,
ARM::R2, ARM::R3
3059 unsigned ArgNo = Arg.getArgNo();
3060 unsigned SrcReg = GPRArgRegs[ArgNo];
3061 unsigned DstReg = FuncInfo.MF->addLiveIn(SrcReg, RC);
3065 unsigned ResultReg = createResultReg(RC);
3066 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
3067 TII.get(TargetOpcode::COPY),
3069 updateValueMap(&Arg, ResultReg);
3080 return new ARMFastISel(funcInfo, libInfo);
unsigned getAlignment() const
void setFrameAddressIsTaken(bool T)
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")))
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.
User::const_op_iterator arg_iterator
The type of iterator to use when looping over actual arguments at this call site. ...
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
void push_back(const T &Elt)
Type * getIndexedType() const
This class is the base class for the comparison instructions.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
This class represents an incoming formal argument to a Function.
uint64_t getZExtValue() const
Get zero extended value.
LocInfo getLocInfo() const
unsigned constrainOperandRegClass(const MachineFunction &MF, const TargetRegisterInfo &TRI, MachineRegisterInfo &MRI, const TargetInstrInfo &TII, const RegisterBankInfo &RBI, MachineInstr &InsertPt, const MCInstrDesc &II, unsigned Reg, unsigned OpIdx)
Try to constrain Reg so that it is usable by argument OpIdx of the provided MCInstrDesc II...
A Module instance is used to store all the information related to an LLVM module. ...
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
static unsigned getSORegOpc(ShiftOpc ShOp, unsigned Imm)
unsigned getNumOperands() const
ARMConstantPoolValue - ARM specific constantpool value.
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
Describe properties that are true of each instruction in the target description file.
const MachineInstrBuilder & add(const MachineOperand &MO) const
This class represents a function call, abstracting a target machine's calling convention.
static PointerType * getInt32PtrTy(LLVMContext &C, unsigned AS=0)
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit...
bool isPredicable(QueryType Type=AllInBundle) const
Return true if this instruction has a predicate operand that controls execution.
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 useFastISel() const
True if fast-isel is used.
0 1 0 0 True if ordered and less than
unsigned getSizeInBits() const
Externally visible function.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
1 1 1 0 True if unordered or not equal
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
This class wraps the llvm.memset intrinsic.
const Function * getParent() const
Return the enclosing method, or null if none.
bool isThumbFunction() const
An instruction for reading from memory.
void reserve(size_type N)
iterator_range< mop_iterator > operands()
unsigned getValNo() const
bool isEquality() const
This is just a convenience that dispatches to the subclasses.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI.
1 0 0 1 True if unordered or equal
StructType * getStructTypeOrNull() const
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.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Class to represent struct types.
static ARMCC::CondCodes getComparePred(CmpInst::Predicate Pred)
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
A Use represents the edge between a Value definition and its users.
unsigned getFrameRegister(const MachineFunction &MF) const override
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
ARM_APCS - ARM Procedure Calling Standard calling convention (obsolete, but still used on some target...
Reg
All possible values of the reg field in the ModR/M byte.
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...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
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...
unsigned getNumOperands() const
Access to explicit operands of the instruction.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
unsigned getLocReg() const
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.
iterator_range< const_opInfo_iterator > operands() const
static std::array< MachineOperand, 2 > predOps(ARMCC::CondCodes Pred, unsigned PredReg=0)
Get the operands corresponding to the given Pred value.
Simple integer binary arithmetic operators.
static int getT2SOImmVal(unsigned Arg)
getT2SOImmVal - Given a 32-bit immediate, if it is something that can fit into a Thumb-2 shifter_oper...
BasicBlock * getSuccessor(unsigned i) const
bool isArrayTy() const
True if this is an instance of ArrayType.
static int getFP32Imm(const APInt &Imm)
getFP32Imm - Return an 8-bit floating-point version of the 32-bit floating-point value.
static const MCPhysReg GPRArgRegs[]
void setOrigAlign(unsigned A)
This class represents a truncation of integer types.
Class to represent pointers.
unsigned getKillRegState(bool B)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
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)
uint64_t getElementOffset(unsigned Idx) const
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned const MachineRegisterInfo * MRI
LLVM Basic Block Representation.
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.
bool isVectorTy() const
True if this is an instance of VectorType.
This is an important base class in LLVM.
PointerType * getType() const
Overload to return most specific pointer type.
bool isVector() const
Return true if this is a vector value type.
int64_t getSExtValue() const
Get sign extended value.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const MachineOperand & getOperand(unsigned i) const
Indirect Branch Instruction.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
ConstantFP - Floating Point Values [float, double].
const MCPhysReg * ImplicitDefs
Value * getRawDest() const
This file declares a class to represent arbitrary precision floating point values and provide a varie...
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...
TRAP - Trapping instruction.
Thread Local Storage (General Dynamic Mode)
Value * getOperand(unsigned i) const
0 1 1 1 True if ordered (no nans)
Predicate getPredicate() const
Return the predicate for this instruction.
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
LLVMContext & getContext() const
All values hold a context through their type.
static bool isAtomic(Instruction *I)
1 1 0 1 True if unordered, less than, or equal
ARM_AAPCS - ARM Architecture Procedure Calling Standard calling convention (aka EABI).
The memory access writes data.
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
0 0 1 0 True if ordered and greater than
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
static int getFP64Imm(const APInt &Imm)
getFP64Imm - Return an 8-bit floating-point version of the 64-bit floating-point value.
CCState - This class holds information needed while lowering arguments and return values...
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.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
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.
Type * getType() const
All values are typed, get the type of this value.
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.
Value * getLength() const
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.
const MachineInstrBuilder & addFrameIndex(int Idx) const
C - The default llvm calling convention, compatible with C.
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.
bool isIntegerTy() const
True if this is an instance of IntegerType.
This file defines the FastISel class.
static int getSOImmVal(unsigned Arg)
getSOImmVal - Given a 32-bit immediate, if it is something that can fit into an shifter_operand immed...
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned char TargetFlags=0) const
Flags
Flags values. These may be or'd together.
llvm_unreachable("Unknown RegBank!")
bool isStructTy() const
True if this is an instance of StructType.
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.
static std::vector< std::string > Flags
Representation of each machine instruction.
PointerType * getType() const
Global values are always pointers.
This class wraps the llvm.memcpy/memmove intrinsics.
Value * getCondition() const
static MachineOperand condCodeOp(unsigned CCReg=0)
Get the operand corresponding to the conditional code result.
static IntegerType * getInt32Ty(LLVMContext &C)
unsigned greater or equal
unsigned getAlignment() const
Return the alignment of the access that is being performed.
static unsigned UseReg(const MachineOperand &MO)
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned char TargetFlags=0) const
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
Establish a view to a call site for examination.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values i...
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
bool hasOneUse() const
Return true if there is exactly one user of this value.
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
0 1 1 0 True if ordered and operands are unequal
Fast - This calling convention attempts to make calls as fast as possible (e.g.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
1 0 1 0 True if unordered or greater than
constexpr bool isUInt< 16 >(uint64_t x)
const APFloat & getValueAPF() const
Value * getRawSource() const
Return the arguments to the instruction.
unsigned getReg() const
getReg - Returns the register number.
bool isUnsigned() const
Determine if this instruction is using an unsigned comparison.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void GetReturnInfo(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...
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
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.
1 0 1 1 True if unordered, greater than, or equal
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
unsigned getDestAddressSpace() const
static const Function * getParent(const Value *V)
MO_NONLAZY - This is an independent flag, on a symbol operand "FOO" it represents a symbol which...
static const unsigned FramePtr
Primary interface to the complete machine description for the target machine.
bool hasOptionalDef(QueryType Type=IgnoreBundle) const
Set if this instruction has an optional definition, e.g.
unsigned getLocMemOffset() const
This holds information about one operand of a machine instruction, indicating the register class for ...
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
0 0 1 1 True if ordered and greater than or equal
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
unsigned getSourceAddressSpace() const
const BasicBlock * getParent() const
static ARMConstantPoolConstant * Create(const Constant *C, unsigned ID)
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
iterator_range< arg_iterator > args()
A wrapper class for inspecting calls to intrinsic functions.
This file describes how to lower LLVM code to machine code.
bool isVoidTy() const
Return true if this is 'void'.
an instruction to allocate memory on the stack
gep_type_iterator gep_type_begin(const User *GEP)
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.