88 enum BaseKind { RegBase, FrameIndexBase };
91 BaseKind Kind = RegBase;
103 void setKind(BaseKind K) { Kind =
K; }
104 BaseKind getKind()
const {
return Kind; }
105 bool isRegBase()
const {
return Kind == RegBase; }
106 bool isFIBase()
const {
return Kind == FrameIndexBase; }
109 assert(isRegBase() &&
"Invalid base register access!");
114 assert(isRegBase() &&
"Invalid base register access!");
119 assert(isFIBase() &&
"Invalid base frame index access!");
124 assert(isFIBase() &&
"Invalid base frame index access!");
128 void setOffset(
int O) { Offset =
O; }
132class ARMFastISel final :
public FastISel {
135 const ARMSubtarget *Subtarget;
137 const ARMBaseInstrInfo &TII;
138 const ARMTargetLowering &TLI;
139 ARMFunctionInfo *AFI;
143 LLVMContext *Context;
146 explicit ARMFastISel(FunctionLoweringInfo &funcInfo,
147 const TargetLibraryInfo *libInfo,
148 const LibcallLoweringInfo *libcallLowering)
149 : FastISel(funcInfo, libInfo, libcallLowering),
150 Subtarget(&funcInfo.MF->getSubtarget<ARMSubtarget>()),
152 TII(*Subtarget->getInstrInfo()),
153 TLI(*Subtarget->getTargetLowering()) {
154 AFI = funcInfo.
MF->
getInfo<ARMFunctionInfo>();
155 isThumb2 = AFI->isThumbFunction();
162 Register fastEmitInst_r(
unsigned MachineInstOpcode,
164 Register fastEmitInst_rr(
unsigned MachineInstOpcode,
167 Register fastEmitInst_ri(
unsigned MachineInstOpcode,
170 Register fastEmitInst_i(
unsigned MachineInstOpcode,
175 bool fastSelectInstruction(
const Instruction *
I)
override;
176 Register fastMaterializeConstant(
const Constant *
C)
override;
177 Register fastMaterializeAlloca(
const AllocaInst *AI)
override;
178 bool tryToFoldLoadIntoMI(MachineInstr *
MI,
unsigned OpNo,
179 const LoadInst *LI)
override;
180 bool fastLowerArguments()
override;
182#include "ARMGenFastISel.inc"
186 bool SelectLoad(
const Instruction *
I);
187 bool SelectStore(
const Instruction *
I);
188 bool SelectBranch(
const Instruction *
I);
189 bool SelectIndirectBr(
const Instruction *
I);
190 bool SelectCmp(
const Instruction *
I);
191 bool SelectFPExt(
const Instruction *
I);
192 bool SelectFPTrunc(
const Instruction *
I);
193 bool SelectBinaryIntOp(
const Instruction *
I,
unsigned ISDOpcode);
194 bool SelectBinaryFPOp(
const Instruction *
I,
unsigned ISDOpcode);
195 bool SelectIToFP(
const Instruction *
I,
bool isSigned);
196 bool SelectFPToI(
const Instruction *
I,
bool isSigned);
197 bool SelectDiv(
const Instruction *
I,
bool isSigned);
198 bool SelectRem(
const Instruction *
I,
bool isSigned);
199 bool SelectCall(
const Instruction *
I,
const char *IntrMemName);
200 bool SelectIntrinsicCall(
const IntrinsicInst &
I);
201 bool SelectSelect(
const Instruction *
I);
202 bool SelectRet(
const Instruction *
I);
203 bool SelectTrunc(
const Instruction *
I);
204 bool SelectIntExt(
const Instruction *
I);
209 bool isPositionIndependent()
const;
210 bool isTypeLegal(
Type *Ty, MVT &VT);
211 bool isLoadTypeLegal(
Type *Ty, MVT &VT);
212 bool ARMEmitCmp(
const Value *Src1Value,
const Value *Src2Value,
215 MaybeAlign Alignment = std::nullopt,
bool isZExt =
true,
216 bool allocReg =
true);
218 MaybeAlign Alignment = std::nullopt);
219 bool ARMComputeAddress(
const Value *Obj,
Address &Addr);
220 void ARMSimplifyAddress(
Address &Addr, MVT VT,
bool useAM3);
221 bool ARMIsMemCpySmall(
uint64_t Len);
223 MaybeAlign Alignment);
224 Register ARMEmitIntExt(MVT SrcVT,
Register SrcReg, MVT DestVT,
bool isZExt);
225 Register ARMMaterializeFP(
const ConstantFP *CFP, MVT VT);
226 Register ARMMaterializeInt(
const Constant *
C, MVT VT);
227 Register ARMMaterializeGV(
const GlobalValue *GV, MVT VT);
230 unsigned ARMSelectCallOp(
bool UseReg);
231 Register ARMLowerPICELF(
const GlobalValue *GV, MVT VT);
233 const TargetLowering *getTargetLowering() {
return &TLI; }
240 bool ProcessCallArgs(SmallVectorImpl<Value*> &Args,
241 SmallVectorImpl<Register> &ArgRegs,
242 SmallVectorImpl<MVT> &ArgVTs,
243 SmallVectorImpl<ISD::ArgFlagsTy> &ArgFlags,
244 SmallVectorImpl<Register> &RegArgs,
248 Register getLibcallReg(
const Twine &Name);
249 bool FinishCall(MVT RetVT, SmallVectorImpl<Register> &UsedRegs,
250 const Instruction *
I, CallingConv::ID
CC,
251 unsigned &NumBytes,
bool isVarArg);
252 bool ARMEmitLibcall(
const Instruction *
I, RTLIB::Libcall
Call);
256 bool isARMNEONPred(
const MachineInstr *
MI);
257 bool DefinesOptionalPredicate(MachineInstr *
MI,
bool *CPSR);
258 const MachineInstrBuilder &AddOptionalDefs(
const MachineInstrBuilder &MIB);
259 void AddLoadStoreOperands(MVT VT,
Address &Addr,
260 const MachineInstrBuilder &MIB,
269bool ARMFastISel::DefinesOptionalPredicate(
MachineInstr *
MI,
bool *CPSR) {
270 if (!
MI->hasOptionalDef())
274 for (
const MachineOperand &MO :
MI->operands()) {
275 if (!MO.isReg() || !MO.isDef())
continue;
276 if (MO.getReg() == ARM::CPSR)
282bool ARMFastISel::isARMNEONPred(
const MachineInstr *
MI) {
283 const MCInstrDesc &MCID =
MI->getDesc();
288 return MI->isPredicable();
290 for (
const MCOperandInfo &opInfo : MCID.
operands())
291 if (opInfo.isPredicate())
302const MachineInstrBuilder &
303ARMFastISel::AddOptionalDefs(
const MachineInstrBuilder &MIB) {
304 MachineInstr *
MI = &*MIB;
309 if (isARMNEONPred(
MI))
315 if (DefinesOptionalPredicate(
MI, &CPSR))
320Register ARMFastISel::fastEmitInst_r(
unsigned MachineInstOpcode,
323 Register ResultReg = createResultReg(RC);
324 const MCInstrDesc &
II =
TII.get(MachineInstOpcode);
329 if (
II.getNumDefs() >= 1) {
330 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
II,
333 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
II)
335 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
336 TII.get(TargetOpcode::COPY), ResultReg)
342Register ARMFastISel::fastEmitInst_rr(
unsigned MachineInstOpcode,
345 Register ResultReg = createResultReg(RC);
346 const MCInstrDesc &
II =
TII.get(MachineInstOpcode);
353 if (
II.getNumDefs() >= 1) {
355 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
II, ResultReg)
359 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
II)
362 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
363 TII.get(TargetOpcode::COPY), ResultReg)
369Register ARMFastISel::fastEmitInst_ri(
unsigned MachineInstOpcode,
372 Register ResultReg = createResultReg(RC);
373 const MCInstrDesc &
II =
TII.get(MachineInstOpcode);
378 if (
II.getNumDefs() >= 1) {
380 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
II, ResultReg)
384 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
II)
387 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
388 TII.get(TargetOpcode::COPY), ResultReg)
394Register ARMFastISel::fastEmitInst_i(
unsigned MachineInstOpcode,
397 Register ResultReg = createResultReg(RC);
398 const MCInstrDesc &
II =
TII.get(MachineInstOpcode);
400 if (
II.getNumDefs() >= 1) {
401 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
II,
404 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
II)
406 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
407 TII.get(TargetOpcode::COPY), ResultReg)
420 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
421 TII.get(ARM::VMOVSR), MoveReg)
431 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
432 TII.get(ARM::VMOVRS), MoveReg)
440Register ARMFastISel::ARMMaterializeFP(
const ConstantFP *CFP, MVT VT) {
441 if (VT != MVT::f32 && VT != MVT::f64)
445 bool is64bit = VT == MVT::f64;
460 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
466 if (!
Subtarget->hasVFP2Base())
return false;
472 unsigned Opc = is64bit ? ARM::VLDRD : ARM::VLDRS;
476 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(
Opc), DestReg)
482Register ARMFastISel::ARMMaterializeInt(
const Constant *
C, MVT VT) {
483 if (VT != MVT::i32 && VT != MVT::i16 && VT != MVT::i8 && VT != MVT::i1)
490 unsigned Opc = isThumb2 ? ARM::t2MOVi16 : ARM::MOVi16;
493 Register ImmReg = createResultReg(RC);
494 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
506 unsigned Opc = isThumb2 ? ARM::t2MVNi : ARM::MVNi;
509 Register ImmReg = createResultReg(RC);
510 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
530 unsigned Idx = MCP.getConstantPoolIndex(
C, Alignment);
533 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
534 TII.get(ARM::t2LDRpci), ResultReg)
539 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
540 TII.get(ARM::LDRcp), ResultReg)
547bool ARMFastISel::isPositionIndependent()
const {
551Register ARMFastISel::ARMMaterializeGV(
const GlobalValue *GV, MVT VT) {
560 bool IsIndirect =
Subtarget->isGVIndirectSymbol(GV);
563 Register DestReg = createResultReg(RC);
571 bool IsPositionIndependent = isPositionIndependent();
577 unsigned char TF = 0;
581 if (IsPositionIndependent)
582 Opc = isThumb2 ? ARM::t2MOV_ga_pcrel : ARM::MOV_ga_pcrel;
584 Opc = isThumb2 ? ARM::t2MOVi32imm : ARM::MOVi32imm;
585 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
592 return ARMLowerPICELF(GV, VT);
595 unsigned PCAdj = IsPositionIndependent ? (
Subtarget->isThumb() ? 4 : 8) : 0;
600 unsigned Idx = MCP.getConstantPoolIndex(CPV, Alignment);
603 MachineInstrBuilder MIB;
605 unsigned Opc = IsPositionIndependent ? ARM::t2LDRpci_pic : ARM::t2LDRpci;
606 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(
Opc),
608 if (IsPositionIndependent)
610 AddOptionalDefs(MIB);
614 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
615 TII.get(ARM::LDRcp), DestReg)
618 AddOptionalDefs(MIB);
620 if (IsPositionIndependent) {
621 unsigned Opc = IsIndirect ? ARM::PICLDR : ARM::PICADD;
624 MachineInstrBuilder MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt,
625 MIMD,
TII.get(
Opc), NewDestReg)
628 AddOptionalDefs(MIB);
636 MachineInstrBuilder MIB;
639 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
640 TII.get(ARM::t2LDRi12), NewDestReg)
644 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
645 TII.get(ARM::LDRi12), NewDestReg)
648 DestReg = NewDestReg;
649 AddOptionalDefs(MIB);
655Register ARMFastISel::fastMaterializeConstant(
const Constant *
C) {
664 return ARMMaterializeFP(CFP, VT);
666 return ARMMaterializeGV(GV, VT);
668 return ARMMaterializeInt(
C, VT);
675Register ARMFastISel::fastMaterializeAlloca(
const AllocaInst *AI) {
677 if (!FuncInfo.StaticAllocaMap.count(AI))
681 if (!isLoadTypeLegal(AI->
getType(), VT))
684 auto SI = FuncInfo.StaticAllocaMap.find(AI);
688 if (SI != FuncInfo.StaticAllocaMap.end()) {
689 unsigned Opc = isThumb2 ? ARM::t2ADDri : ARM::ADDri;
691 Register ResultReg = createResultReg(RC);
694 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
704bool ARMFastISel::isTypeLegal(
Type *Ty, MVT &VT) {
708 if (evt == MVT::Other || !evt.
isSimple())
return false;
716bool ARMFastISel::isLoadTypeLegal(
Type *Ty, MVT &VT) {
717 if (isTypeLegal(Ty, VT))
return true;
721 if (VT == MVT::i1 || VT == MVT::i8 || VT == MVT::i16)
728bool ARMFastISel::ARMComputeAddress(
const Value *Obj,
Address &Addr) {
730 const User *
U =
nullptr;
731 unsigned Opcode = Instruction::UserOp1;
735 if (FuncInfo.StaticAllocaMap.count(
static_cast<const AllocaInst *
>(Obj)) ||
736 FuncInfo.getMBB(
I->getParent()) == FuncInfo.MBB) {
737 Opcode =
I->getOpcode();
741 Opcode =
C->getOpcode();
746 if (Ty->getAddressSpace() > 255)
754 case Instruction::BitCast:
756 return ARMComputeAddress(
U->getOperand(0), Addr);
757 case Instruction::IntToPtr:
761 return ARMComputeAddress(
U->getOperand(0), Addr);
763 case Instruction::PtrToInt:
766 return ARMComputeAddress(
U->getOperand(0), Addr);
768 case Instruction::GetElementPtr: {
770 int TmpOffset = Addr.getOffset();
776 i != e; ++i, ++GTI) {
779 const StructLayout *SL =
DL.getStructLayout(STy);
790 if (canFoldAddIntoGEP(U,
Op)) {
800 goto unsupported_gep;
806 Addr.setOffset(TmpOffset);
807 if (ARMComputeAddress(
U->getOperand(0), Addr))
return true;
815 case Instruction::Alloca: {
817 auto SI = FuncInfo.StaticAllocaMap.find(AI);
818 if (SI != FuncInfo.StaticAllocaMap.end()) {
819 Addr.setKind(Address::FrameIndexBase);
820 Addr.setFI(
SI->second);
829 Addr.setReg(getRegForValue(Obj));
830 return Addr.getReg();
833void ARMFastISel::ARMSimplifyAddress(
Address &Addr, MVT VT,
bool useAM3) {
834 bool needsLowering =
false;
843 needsLowering = ((Addr.getOffset() & 0xfff) != Addr.getOffset());
845 if (needsLowering && isThumb2)
846 needsLowering = !(
Subtarget->hasV6T2Ops() && Addr.getOffset() < 0 &&
847 Addr.getOffset() > -256);
850 needsLowering = (Addr.getOffset() > 255 || Addr.getOffset() < -255);
856 needsLowering = ((Addr.getOffset() & 0xff) != Addr.getOffset());
863 if (needsLowering && Addr.isFIBase()) {
866 Register ResultReg = createResultReg(RC);
867 unsigned Opc = isThumb2 ? ARM::t2ADDri : ARM::ADDri;
869 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(
Opc), ResultReg)
872 Addr.setKind(Address::RegBase);
873 Addr.setReg(ResultReg);
879 Addr.setReg(fastEmit_ri_(MVT::i32,
ISD::ADD, Addr.getReg(),
880 Addr.getOffset(), MVT::i32));
885void ARMFastISel::AddLoadStoreOperands(MVT VT,
Address &Addr,
886 const MachineInstrBuilder &MIB,
892 Addr.setOffset(Addr.getOffset() / 4);
895 if (Addr.isFIBase()) {
896 int FI = Addr.getFI();
897 int Offset = Addr.getOffset();
898 MachineMemOperand *MMO = FuncInfo.MF->getMachineMemOperand(
900 MFI.getObjectSize(FI), MFI.getObjectAlign(FI));
907 int Imm = (Addr.getOffset() < 0) ? (0x100 | -Addr.getOffset())
912 MIB.
addImm(Addr.getOffset());
917 MIB.
addReg(Addr.getReg());
922 int Imm = (Addr.getOffset() < 0) ? (0x100 | -Addr.getOffset())
927 MIB.
addImm(Addr.getOffset());
930 AddOptionalDefs(MIB);
933bool ARMFastISel::ARMEmitLoad(MVT VT,
Register &ResultReg,
Address &Addr,
934 MaybeAlign Alignment,
bool isZExt,
938 bool needVMOV =
false;
942 default:
return false;
946 if (Addr.getOffset() < 0 && Addr.getOffset() > -256 &&
948 Opc = isZExt ? ARM::t2LDRBi8 : ARM::t2LDRSBi8;
950 Opc = isZExt ? ARM::t2LDRBi12 : ARM::t2LDRSBi12;
959 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
962 if (Alignment && *Alignment <
Align(2) &&
967 if (Addr.getOffset() < 0 && Addr.getOffset() > -256 &&
969 Opc = isZExt ? ARM::t2LDRHi8 : ARM::t2LDRSHi8;
971 Opc = isZExt ? ARM::t2LDRHi12 : ARM::t2LDRSHi12;
973 Opc = isZExt ? ARM::LDRH : ARM::LDRSH;
976 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
979 if (Alignment && *Alignment <
Align(4) &&
984 if (Addr.getOffset() < 0 && Addr.getOffset() > -256 &&
992 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
995 if (!
Subtarget->hasVFP2Base())
return false;
997 if (Alignment && *Alignment <
Align(4)) {
1000 Opc = isThumb2 ? ARM::t2LDRi12 : ARM::LDRi12;
1001 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
1009 if (!
Subtarget->hasVFP2Base())
return false;
1012 if (Alignment && *Alignment <
Align(4))
1020 ARMSimplifyAddress(Addr, VT, useAM3);
1024 ResultReg = createResultReg(RC);
1025 assert(ResultReg.
isVirtual() &&
"Expected an allocated virtual register.");
1026 MachineInstrBuilder MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1027 TII.get(
Opc), ResultReg);
1034 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1035 TII.get(ARM::VMOVSR), MoveReg)
1042bool ARMFastISel::SelectLoad(
const Instruction *
I) {
1047 const Value *
SV =
I->getOperand(0);
1052 if (Arg->hasSwiftErrorAttr())
1057 if (Alloca->isSwiftError())
1064 if (!isLoadTypeLegal(
I->getType(), VT))
1069 if (!ARMComputeAddress(
I->getOperand(0), Addr))
return false;
1074 updateValueMap(
I, ResultReg);
1079 MaybeAlign Alignment) {
1081 bool useAM3 =
false;
1084 default:
return false;
1086 Register Res = createResultReg(isThumb2 ? &ARM::tGPRRegClass
1087 : &ARM::GPRRegClass);
1088 unsigned Opc = isThumb2 ? ARM::t2ANDri : ARM::ANDri;
1090 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1098 if (Addr.getOffset() < 0 && Addr.getOffset() > -256 &&
1100 StrOpc = ARM::t2STRBi8;
1102 StrOpc = ARM::t2STRBi12;
1104 StrOpc = ARM::STRBi12;
1108 if (Alignment && *Alignment <
Align(2) &&
1113 if (Addr.getOffset() < 0 && Addr.getOffset() > -256 &&
1115 StrOpc = ARM::t2STRHi8;
1117 StrOpc = ARM::t2STRHi12;
1124 if (Alignment && *Alignment <
Align(4) &&
1129 if (Addr.getOffset() < 0 && Addr.getOffset() > -256 &&
1131 StrOpc = ARM::t2STRi8;
1133 StrOpc = ARM::t2STRi12;
1135 StrOpc = ARM::STRi12;
1139 if (!
Subtarget->hasVFP2Base())
return false;
1141 if (Alignment && *Alignment <
Align(4)) {
1143 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1144 TII.get(ARM::VMOVRS), MoveReg)
1148 StrOpc = isThumb2 ? ARM::t2STRi12 : ARM::STRi12;
1150 StrOpc = ARM::VSTRS;
1155 if (!
Subtarget->hasVFP2Base())
return false;
1158 if (Alignment && *Alignment <
Align(4))
1161 StrOpc = ARM::VSTRD;
1165 ARMSimplifyAddress(Addr, VT, useAM3);
1169 MachineInstrBuilder MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1176bool ARMFastISel::SelectStore(
const Instruction *
I) {
1177 Value *Op0 =
I->getOperand(0);
1184 const Value *PtrV =
I->getOperand(1);
1189 if (Arg->hasSwiftErrorAttr())
1194 if (Alloca->isSwiftError())
1201 if (!isLoadTypeLegal(
I->getOperand(0)->getType(), VT))
1205 SrcReg = getRegForValue(Op0);
1211 if (!ARMComputeAddress(
I->getOperand(1), Addr))
1266bool ARMFastISel::SelectBranch(
const Instruction *
I) {
1269 MachineBasicBlock *FBB = FuncInfo.getMBB(BI->
getSuccessor(1));
1276 if (CI->
hasOneUse() && (CI->getParent() ==
I->getParent())) {
1280 if (FuncInfo.MBB->isLayoutSuccessor(
TBB)) {
1294 unsigned BrOpc = isThumb2 ? ARM::t2Bcc : ARM::Bcc;
1295 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(BrOpc))
1302 if (TI->hasOneUse() && TI->getParent() ==
I->getParent() &&
1303 (isLoadTypeLegal(TI->getOperand(0)->getType(), SourceVT))) {
1304 unsigned TstOpc = isThumb2 ? ARM::t2TSTri : ARM::TSTri;
1305 Register OpReg = getRegForValue(TI->getOperand(0));
1307 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1312 if (FuncInfo.MBB->isLayoutSuccessor(
TBB)) {
1317 unsigned BrOpc = isThumb2 ? ARM::t2Bcc : ARM::Bcc;
1318 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(BrOpc))
1324 }
else if (
const ConstantInt *CI =
1328 fastEmitBranch(Target, MIMD.getDL());
1343 unsigned TstOpc = isThumb2 ? ARM::t2TSTri : ARM::TSTri;
1346 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(TstOpc))
1351 if (FuncInfo.MBB->isLayoutSuccessor(
TBB)) {
1356 unsigned BrOpc = isThumb2 ? ARM::t2Bcc : ARM::Bcc;
1357 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(BrOpc))
1363bool ARMFastISel::SelectIndirectBr(
const Instruction *
I) {
1364 Register AddrReg = getRegForValue(
I->getOperand(0));
1368 unsigned Opc = isThumb2 ? ARM::tBRIND : ARM::BX;
1371 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1375 for (
const BasicBlock *SuccBB :
IB->successors())
1376 FuncInfo.MBB->addSuccessor(FuncInfo.getMBB(SuccBB));
1381bool ARMFastISel::ARMEmitCmp(
const Value *Src1Value,
const Value *Src2Value,
1385 if (!SrcEVT.
isSimple())
return false;
1397 bool UseImm =
false;
1398 bool isNegativeImm =
false;
1402 if (SrcVT == MVT::i32 || SrcVT == MVT::i16 || SrcVT == MVT::i8 ||
1404 const APInt &CIVal = ConstInt->getValue();
1409 if (
Imm < 0 &&
Imm != (
int)0x80000000) {
1410 isNegativeImm =
true;
1417 if (SrcVT == MVT::f32 || SrcVT == MVT::f64)
1418 if (ConstFP->isZero() && !ConstFP->isNegative())
1424 bool needsExt =
false;
1426 default:
return false;
1430 CmpOpc = UseImm ? ARM::VCMPZS : ARM::VCMPS;
1434 CmpOpc = UseImm ? ARM::VCMPZD : ARM::VCMPD;
1444 CmpOpc = ARM::t2CMPrr;
1446 CmpOpc = isNegativeImm ? ARM::t2CMNri : ARM::t2CMPri;
1449 CmpOpc = ARM::CMPrr;
1451 CmpOpc = isNegativeImm ? ARM::CMNri : ARM::CMPri;
1456 Register SrcReg1 = getRegForValue(Src1Value);
1462 SrcReg2 = getRegForValue(Src2Value);
1469 SrcReg1 = ARMEmitIntExt(SrcVT, SrcReg1, MVT::i32, isZExt);
1473 SrcReg2 = ARMEmitIntExt(SrcVT, SrcReg2, MVT::i32, isZExt);
1479 const MCInstrDesc &
II =
TII.get(CmpOpc);
1483 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
II)
1486 MachineInstrBuilder MIB;
1487 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
II)
1493 AddOptionalDefs(MIB);
1499 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1500 TII.get(ARM::FMSTAT)));
1504bool ARMFastISel::SelectCmp(
const Instruction *
I) {
1519 unsigned MovCCOpc = isThumb2 ? ARM::t2MOVCCi : ARM::MOVCCi;
1521 : &ARM::GPRRegClass;
1522 Register DestReg = createResultReg(RC);
1526 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(MovCCOpc), DestReg)
1530 updateValueMap(
I, DestReg);
1534bool ARMFastISel::SelectFPExt(
const Instruction *
I) {
1539 if (!
I->getType()->isDoubleTy() ||
1540 !
V->getType()->isFloatTy())
return false;
1547 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1548 TII.get(ARM::VCVTDS), Result)
1550 updateValueMap(
I, Result);
1554bool ARMFastISel::SelectFPTrunc(
const Instruction *
I) {
1559 if (!(
I->getType()->isFloatTy() &&
1560 V->getType()->isDoubleTy()))
return false;
1567 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1568 TII.get(ARM::VCVTSD), Result)
1570 updateValueMap(
I, Result);
1574bool ARMFastISel::SelectIToFP(
const Instruction *
I,
bool isSigned) {
1576 if (!
Subtarget->hasVFP2Base())
return false;
1579 Type *Ty =
I->getType();
1580 if (!isTypeLegal(Ty, DstVT))
1583 Value *Src =
I->getOperand(0);
1588 if (SrcVT != MVT::i32 && SrcVT != MVT::i16 && SrcVT != MVT::i8)
1591 Register SrcReg = getRegForValue(Src);
1596 if (SrcVT == MVT::i16 || SrcVT == MVT::i8) {
1597 SrcReg = ARMEmitIntExt(SrcVT, SrcReg, MVT::i32,
1605 Register FP = ARMMoveToFPReg(MVT::f32, SrcReg);
1616 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1618 updateValueMap(
I, ResultReg);
1622bool ARMFastISel::SelectFPToI(
const Instruction *
I,
bool isSigned) {
1624 if (!
Subtarget->hasVFP2Base())
return false;
1627 Type *RetTy =
I->getType();
1628 if (!isTypeLegal(RetTy, DstVT))
1636 Type *OpTy =
I->getOperand(0)->getType();
1644 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1649 Register IntReg = ARMMoveToIntReg(DstVT, ResultReg);
1653 updateValueMap(
I, IntReg);
1657bool ARMFastISel::SelectSelect(
const Instruction *
I) {
1659 if (!isTypeLegal(
I->getType(), VT))
1663 if (VT != MVT::i32)
return false;
1665 Register CondReg = getRegForValue(
I->getOperand(0));
1668 Register Op1Reg = getRegForValue(
I->getOperand(1));
1674 bool UseImm =
false;
1675 bool isNegativeImm =
false;
1677 assert(VT == MVT::i32 &&
"Expecting an i32.");
1678 Imm = (int)ConstInt->getValue().getZExtValue();
1680 isNegativeImm =
true;
1689 Op2Reg = getRegForValue(
I->getOperand(2));
1694 unsigned TstOpc = isThumb2 ? ARM::t2TSTri : ARM::TSTri;
1697 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(TstOpc))
1704 RC = isThumb2 ? &ARM::tGPRRegClass : &ARM::GPRRegClass;
1705 MovCCOpc = isThumb2 ? ARM::t2MOVCCr : ARM::MOVCCr;
1707 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRRegClass;
1709 MovCCOpc = isThumb2 ? ARM::t2MOVCCi : ARM::MOVCCi;
1711 MovCCOpc = isThumb2 ? ARM::t2MVNCCi : ARM::MVNCCi;
1713 Register ResultReg = createResultReg(RC);
1717 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(MovCCOpc),
1725 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(MovCCOpc),
1732 updateValueMap(
I, ResultReg);
1736bool ARMFastISel::SelectDiv(
const Instruction *
I,
bool isSigned) {
1738 Type *Ty =
I->getType();
1739 if (!isTypeLegal(Ty, VT))
1749 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
1751 LC =
isSigned ? RTLIB::SDIV_I8 : RTLIB::UDIV_I8;
1752 else if (VT == MVT::i16)
1753 LC =
isSigned ? RTLIB::SDIV_I16 : RTLIB::UDIV_I16;
1754 else if (VT == MVT::i32)
1755 LC =
isSigned ? RTLIB::SDIV_I32 : RTLIB::UDIV_I32;
1756 else if (VT == MVT::i64)
1757 LC =
isSigned ? RTLIB::SDIV_I64 : RTLIB::UDIV_I64;
1758 else if (VT == MVT::i128)
1759 LC =
isSigned ? RTLIB::SDIV_I128 : RTLIB::UDIV_I128;
1760 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SDIV!");
1762 return ARMEmitLibcall(
I, LC);
1765bool ARMFastISel::SelectRem(
const Instruction *
I,
bool isSigned) {
1767 Type *Ty =
I->getType();
1768 if (!isTypeLegal(Ty, VT))
1778 RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
1780 LC =
isSigned ? RTLIB::SREM_I8 : RTLIB::UREM_I8;
1781 else if (VT == MVT::i16)
1782 LC =
isSigned ? RTLIB::SREM_I16 : RTLIB::UREM_I16;
1783 else if (VT == MVT::i32)
1784 LC =
isSigned ? RTLIB::SREM_I32 : RTLIB::UREM_I32;
1785 else if (VT == MVT::i64)
1786 LC =
isSigned ? RTLIB::SREM_I64 : RTLIB::UREM_I64;
1787 else if (VT == MVT::i128)
1788 LC =
isSigned ? RTLIB::SREM_I128 : RTLIB::UREM_I128;
1789 assert(LC != RTLIB::UNKNOWN_LIBCALL &&
"Unsupported SREM!");
1791 return ARMEmitLibcall(
I, LC);
1794bool ARMFastISel::SelectBinaryIntOp(
const Instruction *
I,
unsigned ISDOpcode) {
1799 if (DestVT != MVT::i16 && DestVT != MVT::i8 && DestVT != MVT::i1)
1803 switch (ISDOpcode) {
1804 default:
return false;
1806 Opc = isThumb2 ? ARM::t2ADDrr : ARM::ADDrr;
1809 Opc = isThumb2 ? ARM::t2ORRrr : ARM::ORRrr;
1812 Opc = isThumb2 ? ARM::t2SUBrr : ARM::SUBrr;
1816 Register SrcReg1 = getRegForValue(
I->getOperand(0));
1822 Register SrcReg2 = getRegForValue(
I->getOperand(1));
1826 Register ResultReg = createResultReg(&ARM::GPRnopcRegClass);
1829 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1832 updateValueMap(
I, ResultReg);
1836bool ARMFastISel::SelectBinaryFPOp(
const Instruction *
I,
unsigned ISDOpcode) {
1838 if (!FPVT.
isSimple())
return false;
1849 Type *Ty =
I->getType();
1856 bool is64bit = VT == MVT::f64 || VT == MVT::i64;
1857 switch (ISDOpcode) {
1858 default:
return false;
1860 Opc = is64bit ? ARM::VADDD : ARM::VADDS;
1863 Opc = is64bit ? ARM::VSUBD : ARM::VSUBS;
1866 Opc = is64bit ? ARM::VMULD : ARM::VMULS;
1869 Register Op1 = getRegForValue(
I->getOperand(0));
1873 Register Op2 = getRegForValue(
I->getOperand(1));
1878 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
1881 updateValueMap(
I, ResultReg);
1889CCAssignFn *ARMFastISel::CCAssignFnForCall(CallingConv::ID
CC,
1895 case CallingConv::Fast:
1896 if (
Subtarget->hasFPRegs() && !isVarArg) {
1903 case CallingConv::C:
1904 case CallingConv::CXX_FAST_TLS:
1914 case CallingConv::ARM_AAPCS_VFP:
1915 case CallingConv::Swift:
1916 case CallingConv::SwiftTail:
1922 case CallingConv::ARM_AAPCS:
1924 case CallingConv::ARM_APCS:
1926 case CallingConv::GHC:
1931 case CallingConv::CFGuard_Check:
1936bool ARMFastISel::ProcessCallArgs(SmallVectorImpl<Value*> &Args,
1937 SmallVectorImpl<Register> &ArgRegs,
1938 SmallVectorImpl<MVT> &ArgVTs,
1939 SmallVectorImpl<ISD::ArgFlagsTy> &ArgFlags,
1940 SmallVectorImpl<Register> &RegArgs,
1946 for (
Value *Arg : Args)
1948 CCState CCInfo(
CC, isVarArg, *FuncInfo.MF, ArgLocs, *
Context);
1949 CCInfo.AnalyzeCallOperands(ArgVTs, ArgFlags, OrigTys,
1950 CCAssignFnForCall(
CC,
false, isVarArg));
1954 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
1955 CCValAssign &VA = ArgLocs[i];
1969 !VA.
isRegLoc() || !ArgLocs[++i].isRegLoc())
1995 NumBytes = CCInfo.getStackSize();
1998 unsigned AdjStackDown =
TII.getCallFrameSetupOpcode();
1999 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
2000 TII.get(AdjStackDown))
2004 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
2005 CCValAssign &VA = ArgLocs[i];
2011 "We don't handle NEON/vector parameters yet.");
2018 Arg = ARMEmitIntExt(ArgVT, Arg, DestVT,
false);
2019 assert(Arg &&
"Failed to emit a sext");
2027 Arg = ARMEmitIntExt(ArgVT, Arg, DestVT,
true);
2028 assert(Arg &&
"Failed to emit a zext");
2034 assert(BC &&
"Failed to emit a bitcast!");
2044 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
2050 "Custom lowering for v2f64 args not available");
2053 CCValAssign &NextVA = ArgLocs[++i];
2056 "We only handle register args!");
2062 if (
DL.isBigEndian())
2064 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
2065 TII.get(ARM::VMOVRRD),
Lo)
2079 Addr.setKind(Address::RegBase);
2080 Addr.setReg(ARM::SP);
2083 bool EmitRet = ARMEmitStore(ArgVT, Arg, Addr); (void)EmitRet;
2084 assert(EmitRet &&
"Could not emit a store for argument!");
2091bool ARMFastISel::FinishCall(MVT RetVT, SmallVectorImpl<Register> &UsedRegs,
2092 const Instruction *
I, CallingConv::ID
CC,
2093 unsigned &NumBytes,
bool isVarArg) {
2095 unsigned AdjStackUp =
TII.getCallFrameDestroyOpcode();
2096 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
2097 TII.get(AdjStackUp))
2101 if (RetVT != MVT::isVoid) {
2103 CCState CCInfo(
CC, isVarArg, *FuncInfo.MF, RVLocs, *
Context);
2104 CCInfo.AnalyzeCallResult(RetVT,
I->getType(),
2105 CCAssignFnForCall(
CC,
true, isVarArg));
2108 if (RVLocs.
size() == 2 && RetVT == MVT::f64) {
2111 MVT DestVT = RVLocs[0].getValVT();
2113 Register ResultReg = createResultReg(DstRC);
2118 if (
DL.isBigEndian())
2120 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
2121 TII.get(ARM::VMOVDRR), ResultReg)
2125 UsedRegs.
push_back(RVLocs[0].getLocReg());
2126 UsedRegs.
push_back(RVLocs[1].getLocReg());
2129 updateValueMap(
I, ResultReg);
2131 assert(RVLocs.
size() == 1 &&
"Can't handle non-double multi-reg retvals!");
2132 MVT CopyVT = RVLocs[0].getValVT();
2135 if (RetVT == MVT::i1 || RetVT == MVT::i8 || RetVT == MVT::i16)
2140 Register ResultReg = createResultReg(DstRC);
2141 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
2142 TII.get(TargetOpcode::COPY),
2143 ResultReg).
addReg(RVLocs[0].getLocReg());
2144 UsedRegs.
push_back(RVLocs[0].getLocReg());
2147 updateValueMap(
I, ResultReg);
2154bool ARMFastISel::SelectRet(
const Instruction *
I) {
2156 const Function &
F = *
I->getParent()->getParent();
2157 const bool IsCmseNSEntry =
F.hasFnAttribute(
"cmse_nonsecure_entry");
2159 if (!FuncInfo.CanLowerReturn)
2163 F.getAttributes().hasAttrSomewhere(Attribute::SwiftError))
2172 CallingConv::ID
CC =
F.getCallingConv();
2179 CCState CCInfo(
CC,
F.isVarArg(), *FuncInfo.MF, ValLocs,
I->getContext());
2180 CCInfo.AnalyzeReturn(Outs, CCAssignFnForCall(
CC,
true ,
2189 if (ValLocs.
size() != 1)
2192 CCValAssign &VA = ValLocs[0];
2203 if (!RVEVT.
isSimple())
return false;
2207 if (RVVT != DestVT) {
2208 if (RVVT != MVT::i1 && RVVT != MVT::i8 && RVVT != MVT::i16)
2211 assert(DestVT == MVT::i32 &&
"ARM should always ext to i32");
2215 if (Outs[0].
Flags.isZExt() || Outs[0].Flags.isSExt()) {
2216 SrcReg = ARMEmitIntExt(RVVT, SrcReg, DestVT, Outs[0].
Flags.isZExt());
2228 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
2229 TII.get(TargetOpcode::COPY), DstReg).
addReg(SrcReg);
2238 RetOpc = ARM::tBXNS_RET;
2244 MachineInstrBuilder MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
2246 AddOptionalDefs(MIB);
2248 MIB.
addReg(R, RegState::Implicit);
2252unsigned ARMFastISel::ARMSelectCallOp(
bool UseReg) {
2256 return isThumb2 ? ARM::tBL : ARM::BL;
2259Register ARMFastISel::getLibcallReg(
const Twine &Name) {
2266 GlobalValue *GV =
M.getNamedGlobal(
Name.str());
2268 GV =
new GlobalVariable(M, Type::getInt32Ty(*
Context),
false,
2271 return ARMMaterializeGV(GV, LCREVT.
getSimpleVT());
2281bool ARMFastISel::ARMEmitLibcall(
const Instruction *
I, RTLIB::Libcall
Call) {
2282 RTLIB::LibcallImpl LCImpl = LibcallLowering->getLibcallImpl(
Call);
2283 if (LCImpl == RTLIB::Unsupported)
2287 Type *RetTy =
I->getType();
2290 RetVT = MVT::isVoid;
2291 else if (!isTypeLegal(RetTy, RetVT))
2294 CallingConv::ID
CC = LibcallLowering->getLibcallImplCallingConv(LCImpl);
2297 if (RetVT != MVT::isVoid && RetVT != MVT::i32) {
2299 CCState CCInfo(
CC,
false, *FuncInfo.MF, RVLocs, *
Context);
2300 CCInfo.AnalyzeCallResult(RetVT, RetTy, CCAssignFnForCall(
CC,
true,
false));
2301 if (RVLocs.
size() >= 2 && RetVT != MVT::f64)
2306 SmallVector<Value*, 8>
Args;
2310 Args.reserve(
I->getNumOperands());
2311 ArgRegs.
reserve(
I->getNumOperands());
2312 ArgVTs.
reserve(
I->getNumOperands());
2313 ArgFlags.
reserve(
I->getNumOperands());
2319 Type *ArgTy =
Op->getType();
2321 if (!isTypeLegal(ArgTy, ArgVT))
return false;
2323 ISD::ArgFlagsTy
Flags;
2324 Flags.setOrigAlign(
DL.getABITypeAlign(ArgTy));
2335 if (!ProcessCallArgs(Args, ArgRegs, ArgVTs, ArgFlags,
2336 RegArgs,
CC, NumBytes,
false))
2343 CalleeReg = getLibcallReg(FuncName);
2349 unsigned CallOpc = ARMSelectCallOp(
Subtarget->genLongCalls());
2350 MachineInstrBuilder MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt,
2351 MIMD,
TII.get(CallOpc));
2364 MIB.
addReg(R, RegState::Implicit);
2372 if (!FinishCall(RetVT, UsedRegs,
I,
CC, NumBytes,
false))
return false;
2375 static_cast<MachineInstr *
>(MIB)->setPhysRegsDeadExcept(UsedRegs,
TRI);
2380bool ARMFastISel::SelectCall(
const Instruction *
I,
2381 const char *IntrMemName =
nullptr) {
2397 bool isVarArg = FTy->isVarArg();
2400 Type *RetTy =
I->getType();
2403 RetVT = MVT::isVoid;
2404 else if (!isTypeLegal(RetTy, RetVT) && RetVT != MVT::i16 &&
2405 RetVT != MVT::i8 && RetVT != MVT::i1)
2409 if (RetVT != MVT::isVoid && RetVT != MVT::i1 && RetVT != MVT::i8 &&
2410 RetVT != MVT::i16 && RetVT != MVT::i32) {
2412 CCState CCInfo(
CC, isVarArg, *FuncInfo.MF, RVLocs, *
Context);
2413 CCInfo.AnalyzeCallResult(RetVT, RetTy,
2414 CCAssignFnForCall(
CC,
true, isVarArg));
2415 if (RVLocs.
size() >= 2 && RetVT != MVT::f64)
2420 SmallVector<Value*, 8>
Args;
2424 unsigned arg_size = CI->
arg_size();
2425 Args.reserve(arg_size);
2429 for (
auto ArgI = CI->
arg_begin(), ArgE = CI->
arg_end(); ArgI != ArgE; ++ArgI) {
2432 if (IntrMemName && ArgE - ArgI <= 1)
2435 ISD::ArgFlagsTy
Flags;
2436 unsigned ArgIdx = ArgI - CI->
arg_begin();
2451 Type *ArgTy = (*ArgI)->getType();
2453 if (!isTypeLegal(ArgTy, ArgVT) && ArgVT != MVT::i16 && ArgVT != MVT::i8 &&
2457 Register Arg = getRegForValue(*ArgI);
2461 Flags.setOrigAlign(
DL.getABITypeAlign(ArgTy));
2463 Args.push_back(*ArgI);
2472 if (!ProcessCallArgs(Args, ArgRegs, ArgVTs, ArgFlags,
2473 RegArgs,
CC, NumBytes, isVarArg))
2483 CalleeReg = getLibcallReg(IntrMemName);
2485 CalleeReg = getRegForValue(Callee);
2492 unsigned CallOpc = ARMSelectCallOp(
UseReg);
2493 MachineInstrBuilder MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt,
2494 MIMD,
TII.get(CallOpc));
2503 }
else if (!IntrMemName)
2510 MIB.
addReg(R, RegState::Implicit);
2518 if (!FinishCall(RetVT, UsedRegs,
I,
CC, NumBytes, isVarArg))
2522 static_cast<MachineInstr *
>(MIB)->setPhysRegsDeadExcept(UsedRegs,
TRI);
2528bool ARMFastISel::ARMIsMemCpySmall(
uint64_t Len) {
2533 MaybeAlign Alignment) {
2535 if (!ARMIsMemCpySmall(Len))
2540 if (!Alignment || *Alignment >= 4) {
2546 assert(Len == 1 &&
"Expected a length of 1!");
2550 assert(Alignment &&
"Alignment is set in this branch");
2552 if (Len >= 2 && *Alignment == 2)
2561 RV = ARMEmitLoad(VT, ResultReg, Src);
2562 assert(RV &&
"Should be able to handle this load.");
2563 RV = ARMEmitStore(VT, ResultReg, Dest);
2564 assert(RV &&
"Should be able to handle this store.");
2569 Dest.setOffset(Dest.getOffset() +
Size);
2570 Src.setOffset(Src.getOffset() +
Size);
2576bool ARMFastISel::SelectIntrinsicCall(
const IntrinsicInst &
I) {
2578 switch (
I.getIntrinsicID()) {
2579 default:
return false;
2580 case Intrinsic::frameaddress: {
2581 MachineFrameInfo &MFI = FuncInfo.MF->getFrameInfo();
2584 unsigned LdrOpc = isThumb2 ? ARM::t2LDRi12 : ARM::LDRi12;
2586 : &ARM::GPRRegClass;
2600 DestReg = createResultReg(RC);
2601 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
2602 TII.get(LdrOpc), DestReg)
2606 updateValueMap(&
I, SrcReg);
2609 case Intrinsic::memcpy:
2610 case Intrinsic::memmove: {
2618 bool isMemCpy = (
I.getIntrinsicID() == Intrinsic::memcpy);
2623 if (ARMIsMemCpySmall(Len)) {
2625 if (!ARMComputeAddress(MTI.
getRawDest(), Dest) ||
2632 if (ARMTryEmitSmallMemCpy(Dest, Src, Len, Alignment))
2644 return SelectCall(&
I, IntrMemName);
2646 case Intrinsic::memset: {
2658 return SelectCall(&
I,
"memset");
2660 case Intrinsic::trap: {
2661 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
2662 TII.get(
Subtarget->isThumb() ? ARM::tTRAP : ARM::TRAP));
2668bool ARMFastISel::SelectTrunc(
const Instruction *
I) {
2677 if (SrcVT != MVT::i32 && SrcVT != MVT::i16 && SrcVT != MVT::i8)
2679 if (DestVT != MVT::i16 && DestVT != MVT::i8 && DestVT != MVT::i1)
2683 if (!SrcReg)
return false;
2687 updateValueMap(
I, SrcReg);
2693 if (DestVT != MVT::i32 && DestVT != MVT::i16 && DestVT != MVT::i8)
2695 if (SrcVT != MVT::i16 && SrcVT != MVT::i8 && SrcVT != MVT::i1)
2700 static const uint8_t isSingleInstrTbl[3][2][2][2] = {
2704 { { { 0, 1 }, { 0, 1 } }, { { 0, 0 }, { 0, 1 } } },
2705 { { { 0, 1 }, { 1, 1 } }, { { 0, 0 }, { 1, 1 } } },
2706 { { { 0, 0 }, { 1, 1 } }, { { 0, 0 }, { 1, 1 } } }
2715 { &ARM::GPRnopcRegClass, &ARM::GPRnopcRegClass },
2716 { &ARM::tGPRRegClass, &ARM::rGPRRegClass }
2720 static const struct InstructionTable {
2725 }
IT[2][2][3][2] = {
2767 assert((SrcBits < DestBits) &&
"can only extend to larger types");
2768 assert((DestBits == 32 || DestBits == 16 || DestBits == 8) &&
2769 "other sizes unimplemented");
2770 assert((SrcBits == 16 || SrcBits == 8 || SrcBits == 1) &&
2771 "other sizes unimplemented");
2774 unsigned Bitness = SrcBits / 8;
2775 assert((Bitness < 3) &&
"sanity-check table bounds");
2777 bool isSingleInstr = isSingleInstrTbl[Bitness][isThumb2][hasV6Ops][isZExt];
2779 const InstructionTable *ITP = &
IT[isSingleInstr][isThumb2][Bitness][isZExt];
2780 unsigned Opc = ITP->Opc;
2781 assert(ARM::KILL !=
Opc &&
"Invalid table entry");
2782 unsigned hasS = ITP->hasS;
2785 "only MOVsi has shift operand addressing mode");
2786 unsigned Imm = ITP->Imm;
2789 bool setsCPSR = &ARM::tGPRRegClass == RC;
2790 unsigned LSLOpc = isThumb2 ? ARM::tLSLri : ARM::MOVsi;
2805 unsigned NumInstrsEmitted = isSingleInstr ? 1 : 2;
2806 for (
unsigned Instr = 0;
Instr != NumInstrsEmitted; ++
Instr) {
2807 ResultReg = createResultReg(RC);
2808 bool isLsl = (0 ==
Instr) && !isSingleInstr;
2809 unsigned Opcode = isLsl ? LSLOpc :
Opc;
2812 MachineInstrBuilder MIB =
BuildMI(
2813 *FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(Opcode), ResultReg);
2815 MIB.
addReg(ARM::CPSR, RegState::Define | RegState::Dead);
2829bool ARMFastISel::SelectIntExt(
const Instruction *
I) {
2832 Type *DestTy =
I->getType();
2833 Value *Src =
I->getOperand(0);
2834 Type *SrcTy = Src->getType();
2837 Register SrcReg = getRegForValue(Src);
2838 if (!SrcReg)
return false;
2840 EVT SrcEVT, DestEVT;
2843 if (!SrcEVT.
isSimple())
return false;
2844 if (!DestEVT.
isSimple())
return false;
2848 Register ResultReg = ARMEmitIntExt(SrcVT, SrcReg, DestVT, isZExt);
2851 updateValueMap(
I, ResultReg);
2855bool ARMFastISel::SelectShift(
const Instruction *
I,
2864 if (DestVT != MVT::i32)
2867 unsigned Opc = ARM::MOVsr;
2869 Value *Src2Value =
I->getOperand(1);
2871 ShiftImm = CI->getZExtValue();
2875 if (ShiftImm == 0 || ShiftImm >=32)
2881 Value *Src1Value =
I->getOperand(0);
2882 Register Reg1 = getRegForValue(Src1Value);
2887 if (
Opc == ARM::MOVsr) {
2888 Reg2 = getRegForValue(Src2Value);
2893 Register ResultReg = createResultReg(&ARM::GPRnopcRegClass);
2897 MachineInstrBuilder MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
2901 if (
Opc == ARM::MOVsi)
2903 else if (
Opc == ARM::MOVsr) {
2908 AddOptionalDefs(MIB);
2909 updateValueMap(
I, ResultReg);
2914bool ARMFastISel::fastSelectInstruction(
const Instruction *
I) {
2915 switch (
I->getOpcode()) {
2916 case Instruction::Load:
2917 return SelectLoad(
I);
2918 case Instruction::Store:
2919 return SelectStore(
I);
2920 case Instruction::CondBr:
2921 return SelectBranch(
I);
2922 case Instruction::IndirectBr:
2923 return SelectIndirectBr(
I);
2924 case Instruction::ICmp:
2925 case Instruction::FCmp:
2926 return SelectCmp(
I);
2927 case Instruction::FPExt:
2928 return SelectFPExt(
I);
2929 case Instruction::FPTrunc:
2930 return SelectFPTrunc(
I);
2931 case Instruction::SIToFP:
2932 return SelectIToFP(
I,
true);
2933 case Instruction::UIToFP:
2934 return SelectIToFP(
I,
false);
2935 case Instruction::FPToSI:
2936 return SelectFPToI(
I,
true);
2937 case Instruction::FPToUI:
2938 return SelectFPToI(
I,
false);
2939 case Instruction::Add:
2941 case Instruction::Or:
2942 return SelectBinaryIntOp(
I,
ISD::OR);
2943 case Instruction::Sub:
2945 case Instruction::FAdd:
2947 case Instruction::FSub:
2949 case Instruction::FMul:
2951 case Instruction::SDiv:
2952 return SelectDiv(
I,
true);
2953 case Instruction::UDiv:
2954 return SelectDiv(
I,
false);
2955 case Instruction::SRem:
2956 return SelectRem(
I,
true);
2957 case Instruction::URem:
2958 return SelectRem(
I,
false);
2959 case Instruction::Call:
2961 return SelectIntrinsicCall(*
II);
2962 return SelectCall(
I);
2963 case Instruction::Select:
2964 return SelectSelect(
I);
2965 case Instruction::Ret:
2966 return SelectRet(
I);
2967 case Instruction::Trunc:
2968 return SelectTrunc(
I);
2969 case Instruction::ZExt:
2970 case Instruction::SExt:
2971 return SelectIntExt(
I);
2972 case Instruction::Shl:
2974 case Instruction::LShr:
2976 case Instruction::AShr:
2993 { { ARM::SXTH, ARM::t2SXTH }, 0, 0, MVT::i16 },
2994 { { ARM::UXTH, ARM::t2UXTH }, 0, 1, MVT::i16 },
2995 { { ARM::ANDri, ARM::t2ANDri }, 255, 1, MVT::i8 },
2996 { { ARM::SXTB, ARM::t2SXTB }, 0, 0, MVT::i8 },
2997 { { ARM::UXTB, ARM::t2UXTB }, 0, 1, MVT::i8 }
3004bool ARMFastISel::tryToFoldLoadIntoMI(MachineInstr *
MI,
unsigned OpNo,
3005 const LoadInst *LI) {
3008 if (!isLoadTypeLegal(LI->
getType(), VT))
3015 if (
MI->getNumOperands() < 3 || !
MI->getOperand(2).isImm())
3022 if (FLE.Opc[isThumb2] ==
MI->getOpcode() &&
3026 isZExt = FLE.isZExt;
3029 if (!Found)
return false;
3033 if (!ARMComputeAddress(LI->
getOperand(0), Addr))
return false;
3035 Register ResultReg =
MI->getOperand(0).getReg();
3036 if (!ARMEmitLoad(VT, ResultReg, Addr, LI->
getAlign(), isZExt,
false))
3039 removeDeadCode(
I, std::next(
I));
3043Register ARMFastISel::ARMLowerPICELF(
const GlobalValue *GV, MVT VT) {
3045 LLVMContext *
Context = &MF->getFunction().getContext();
3047 unsigned PCAdj =
Subtarget->isThumb() ? 4 : 8;
3054 MF->getDataLayout().getPrefTypeAlign(PointerType::get(*
Context, 0));
3055 unsigned Idx = MF->getConstantPool()->getConstantPoolIndex(CPV, ConstAlign);
3056 MachineMemOperand *CPMMO =
3060 Register TempReg = MF->getRegInfo().createVirtualRegister(&ARM::rGPRRegClass);
3061 unsigned Opc = isThumb2 ? ARM::t2LDRpci : ARM::LDRcp;
3062 MachineInstrBuilder MIB =
3063 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(
Opc), TempReg)
3066 if (
Opc == ARM::LDRcp)
3072 Opc =
Subtarget->isThumb() ? ARM::tPICADD : UseGOT_PREL ? ARM::PICLDR
3075 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(
Opc), DestReg)
3077 .
addImm(ARMPCLabelIndex);
3082 if (UseGOT_PREL &&
Subtarget->isThumb()) {
3084 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
3085 TII.get(ARM::t2LDRi12), NewDestReg)
3088 DestReg = NewDestReg;
3089 AddOptionalDefs(MIB);
3094bool ARMFastISel::fastLowerArguments() {
3095 if (!FuncInfo.CanLowerReturn)
3102 CallingConv::ID
CC =
F->getCallingConv();
3106 case CallingConv::Fast:
3107 case CallingConv::C:
3108 case CallingConv::ARM_AAPCS_VFP:
3109 case CallingConv::ARM_AAPCS:
3110 case CallingConv::ARM_APCS:
3111 case CallingConv::Swift:
3112 case CallingConv::SwiftTail:
3118 for (
const Argument &Arg :
F->args()) {
3119 if (Arg.getArgNo() >= 4)
3122 if (Arg.hasAttribute(Attribute::InReg) ||
3123 Arg.hasAttribute(Attribute::StructRet) ||
3124 Arg.hasAttribute(Attribute::SwiftSelf) ||
3125 Arg.hasAttribute(Attribute::SwiftError) ||
3126 Arg.hasAttribute(Attribute::ByVal))
3129 Type *ArgTy = Arg.getType();
3134 if (!ArgVT.
isSimple())
return false;
3146 ARM::R0, ARM::R1, ARM::R2, ARM::R3
3150 for (
const Argument &Arg :
F->args()) {
3151 unsigned ArgNo = Arg.getArgNo();
3153 Register DstReg = FuncInfo.MF->addLiveIn(SrcReg, RC);
3157 Register ResultReg = createResultReg(RC);
3158 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD,
TII.get(TargetOpcode::COPY),
3161 updateValueMap(&Arg, ResultReg);
3173 return new ARMFastISel(funcInfo, libInfo, libcallLowering);
static const MCPhysReg GPRArgRegs[]
const AArch64Subtarget & Subtarget
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
static ARMCC::CondCodes getComparePred(CmpInst::Predicate Pred)
static const struct FoldableLoadExtendsStruct FoldableLoadExtends[]
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
This file contains the simple types necessary to represent the attributes associated with functions a...
static const Function * getParent(const Value *V)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseMap class.
static bool isSigned(unsigned Opcode)
This file defines the FastISel class.
static Register UseReg(const MachineOperand &MO)
const HexagonInstrInfo * TII
static MaybeAlign getAlign(Value *Ptr)
Module.h This file contains the declarations for the Module class.
static bool isAtomic(MachineBasicBlock::iterator I)
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static MCRegister getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
uint64_t IntrinsicInst * II
MachineRegisterInfo & MRI
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
This file defines the SmallVector class.
This file describes how to lower LLVM code to machine code.
static const unsigned FramePtr
const AArch64RegisterInfo * getRegisterInfo() const override
bool isTargetMachO() const
uint64_t getZExtValue() const
Get zero extended value.
int64_t getSExtValue() const
Get sign extended value.
Register getFrameRegister(const MachineFunction &MF) const override
static ARMConstantPoolConstant * Create(const Constant *C, unsigned ID)
bool isThumb2Function() const
unsigned createPICLabelUId()
bool useFastISel() const
True if fast-isel is used.
PointerType * getType() const
Overload to return most specific pointer type.
Register getLocReg() const
LocInfo getLocInfo() const
int64_t getLocMemOffset() const
unsigned getValNo() const
CallingConv::ID getCallingConv() const
LLVM_ABI bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
Value * getCalledOperand() const
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
FunctionType * getFunctionType() const
unsigned arg_size() const
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ ICMP_SLT
signed less than
@ ICMP_SLE
signed less or equal
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ ICMP_UGE
unsigned greater or equal
@ ICMP_UGT
unsigned greater than
@ ICMP_SGT
signed greater than
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ ICMP_ULT
unsigned less than
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ ICMP_SGE
signed greater or equal
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ ICMP_ULE
unsigned less or equal
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE,...
Predicate getPredicate() const
Return the predicate for this instruction.
Value * getCondition() const
BasicBlock * getSuccessor(unsigned i) const
const APFloat & getValueAPF() const
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
PointerType * getType() const
Global values are always pointers.
@ ExternalLinkage
Externally visible function.
Tracks which library functions to use for a particular subtarget or function.
Align getAlign() const
Return the alignment of the access that is being performed.
ArrayRef< MCOperandInfo > operands() const
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
bool isVector() const
Return true if this is a vector value type.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
MachineInstrBundleIterator< MachineInstr > iterator
void setFrameAddressIsTaken(bool T)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned TargetFlags=0) const
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & addConstantPoolIndex(unsigned Idx, int Offset=0, unsigned TargetFlags=0) const
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned TargetFlags=0) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
Representation of each machine instruction.
Flags
Flags values. These may be or'd together.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
Value * getLength() const
Value * getRawDest() const
MaybeAlign getDestAlign() const
unsigned getDestAddressSpace() const
Value * getRawSource() const
Return the arguments to the instruction.
unsigned getSourceAddressSpace() const
MaybeAlign getSourceAlign() const
constexpr bool isValid() const
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
constexpr unsigned id() const
void reserve(size_type N)
void push_back(const T &Elt)
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
TypeSize getElementOffset(unsigned Idx) const
Provides information about what library functions are available for the current target.
virtual bool hasStandaloneRem(EVT VT) const
Return true if the target can handle a standalone remainder operation.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
virtual const TargetRegisterClass * getRegClassFor(MVT VT, bool isDivergent=false) const
Return the register class that should be used for the specified value type.
bool isFPImmLegal(const APFloat &Imm, EVT VT, bool ForCodeSize=false) const
Returns true if the specified FP immediate can be materialized without a load from the constant pool.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
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...
virtual bool supportSwiftError() const
Return true if the target supports swifterror attribute.
bool isPositionIndependent() 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...
bool isVectorTy() const
True if this is an instance of VectorType.
bool isArrayTy() const
True if this is an instance of ArrayType.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
bool isStructTy() const
True if this is an instance of StructType.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
bool isVoidTy() const
Return true if this is 'void'.
const Use * const_op_iterator
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
Type * getType() const
All values are typed, get the type of this value.
bool hasOneUse() const
Return true if there is exactly one use of this value.
StructType * getStructTypeOrNull() const
TypeSize getSequentialElementStride(const DataLayout &DL) const
const ParentTy * getParent() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
@ GOT_PREL
Thread Local Storage (General Dynamic Mode)
@ MO_NONLAZY
MO_NONLAZY - This is an independent flag, on a symbol operand "FOO" it represents a symbol which,...
int getSOImmVal(unsigned Arg)
getSOImmVal - Given a 32-bit immediate, if it is something that can fit into an shifter_operand immed...
int getFP32Imm(const APInt &Imm)
getFP32Imm - Return an 8-bit floating-point version of the 32-bit floating-point value.
int getT2SOImmVal(unsigned Arg)
getT2SOImmVal - Given a 32-bit immediate, if it is something that can fit into a Thumb-2 shifter_oper...
int getFP64Imm(const APInt &Imm)
getFP64Imm - Return an 8-bit floating-point version of the 64-bit floating-point value.
unsigned getSORegOpc(ShiftOpc ShOp, unsigned Imm)
FastISel * createFastISel(FunctionLoweringInfo &funcInfo, const TargetLibraryInfo *libInfo, const LibcallLoweringInfo *libcallLowering)
@ ADD
Simple integer binary arithmetic operators.
@ FADD
Simple binary floating point operators.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
@ User
could "use" a pointer
NodeAddr< InstrNode * > Instr
This is an optimization pass for GlobalISel generic memory operations.
bool RetFastCC_ARM_APCS(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
LLVM_ABI Register constrainOperandRegClass(const MachineFunction &MF, const TargetRegisterInfo &TRI, MachineRegisterInfo &MRI, const TargetInstrInfo &TII, const RegisterBankInfo &RBI, MachineInstr &InsertPt, const TargetRegisterClass &RegClass, MachineOperand &RegMO)
Constrain the Register operand OpIdx, so that it is now constrained to the TargetRegisterClass passed...
LLVM_ABI 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,...
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change.
LLVM_ABI void diagnoseDontCall(const CallInst &CI)
bool CC_ARM_AAPCS(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
bool RetCC_ARM_AAPCS_VFP(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
bool RetCC_ARM_APCS(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
bool RetCC_ARM_AAPCS(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
bool CC_ARM_APCS_GHC(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
static std::array< MachineOperand, 2 > predOps(ARMCC::CondCodes Pred, unsigned PredReg=0)
Get the operands corresponding to the given Pred value.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
static Error getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
bool FastCC_ARM_APCS(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
bool CC_ARM_Win32_CFGuard_Check(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
generic_gep_type_iterator<> gep_type_iterator
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
DWARFExpression::Operation Op
static MachineOperand t1CondCodeOp(bool isDead=false)
Get the operand corresponding to the conditional code result for Thumb1.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
gep_type_iterator gep_type_begin(const User *GEP)
static MachineOperand condCodeOp(unsigned CCReg=0)
Get the operand corresponding to the conditional code result.
unsigned gettBLXrOpcode(const MachineFunction &MF)
bool CC_ARM_APCS(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
unsigned getBLXOpcode(const MachineFunction &MF)
bool CC_ARM_AAPCS_VFP(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
MCRegisterClass TargetRegisterClass
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static LLVM_ABI MachinePointerInfo getConstantPool(MachineFunction &MF)
Return a MachinePointerInfo record that refers to the constant pool.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
static StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl)
Get the libcall routine name for the specified libcall implementation.