56 typedef struct Address {
71 : BaseType(RegBase), Offset(0) {
76 class ARMFastISel :
public FastISel {
94 TM(funcInfo.MF->getTarget()),
95 TII(*
TM.getInstrInfo()),
96 TLI(*
TM.getTargetLowering()) {
99 isThumb2 = AFI->isThumbFunction();
105 unsigned FastEmitInst_(
unsigned MachineInstOpcode,
107 unsigned FastEmitInst_r(
unsigned MachineInstOpcode,
109 unsigned Op0,
bool Op0IsKill);
110 unsigned FastEmitInst_rr(
unsigned MachineInstOpcode,
112 unsigned Op0,
bool Op0IsKill,
113 unsigned Op1,
bool Op1IsKill);
114 unsigned FastEmitInst_rrr(
unsigned MachineInstOpcode,
116 unsigned Op0,
bool Op0IsKill,
117 unsigned Op1,
bool Op1IsKill,
118 unsigned Op2,
bool Op2IsKill);
119 unsigned FastEmitInst_ri(
unsigned MachineInstOpcode,
121 unsigned Op0,
bool Op0IsKill,
123 unsigned FastEmitInst_rf(
unsigned MachineInstOpcode,
125 unsigned Op0,
bool Op0IsKill,
127 unsigned FastEmitInst_rri(
unsigned MachineInstOpcode,
129 unsigned Op0,
bool Op0IsKill,
130 unsigned Op1,
bool Op1IsKill,
132 unsigned FastEmitInst_i(
unsigned MachineInstOpcode,
135 unsigned FastEmitInst_ii(
unsigned MachineInstOpcode,
137 uint64_t Imm1, uint64_t Imm2);
139 unsigned FastEmitInst_extractsubreg(
MVT RetVT,
140 unsigned Op0,
bool Op0IsKill,
145 virtual bool TargetSelectInstruction(
const Instruction *
I);
146 virtual unsigned TargetMaterializeConstant(
const Constant *
C);
147 virtual unsigned TargetMaterializeAlloca(
const AllocaInst *AI);
150 virtual bool FastLowerArguments();
152 #include "ARMGenFastISel.inc"
163 bool SelectBinaryIntOp(
const Instruction *
I,
unsigned ISDOpcode);
164 bool SelectBinaryFPOp(
const Instruction *
I,
unsigned ISDOpcode);
169 bool SelectCall(
const Instruction *
I,
const char *IntrMemName);
179 unsigned constrainOperandRegClass(
const MCInstrDesc &II,
unsigned OpNum,
181 bool isTypeLegal(
Type *Ty,
MVT &VT);
182 bool isLoadTypeLegal(
Type *Ty,
MVT &VT);
183 bool ARMEmitCmp(
const Value *Src1Value,
const Value *Src2Value,
185 bool ARMEmitLoad(
MVT VT,
unsigned &ResultReg, Address &Addr,
186 unsigned Alignment = 0,
bool isZExt =
true,
187 bool allocReg =
true);
188 bool ARMEmitStore(
MVT VT,
unsigned SrcReg, Address &Addr,
189 unsigned Alignment = 0);
190 bool ARMComputeAddress(
const Value *Obj, Address &Addr);
191 void ARMSimplifyAddress(Address &Addr,
MVT VT,
bool useAM3);
192 bool ARMIsMemCpySmall(uint64_t Len);
193 bool ARMTryEmitSmallMemCpy(Address Dest, Address Src, uint64_t Len,
195 unsigned ARMEmitIntExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
bool isZExt);
199 unsigned ARMMoveToFPReg(
MVT VT,
unsigned SrcReg);
200 unsigned ARMMoveToIntReg(
MVT VT,
unsigned SrcReg);
201 unsigned ARMSelectCallOp(
bool UseReg);
217 unsigned getLibcallReg(
const Twine &
Name);
220 unsigned &NumBytes,
bool isVarArg);
228 void AddLoadStoreOperands(
MVT VT, Address &Addr,
230 unsigned Flags,
bool useAM3);
235 #include "ARMGenCallingConv.inc"
240 bool ARMFastISel::DefinesOptionalPredicate(
MachineInstr *
MI,
bool *CPSR) {
248 if (MO.
getReg() == ARM::CPSR)
254 bool ARMFastISel::isARMNEONPred(
const MachineInstr *MI) {
259 AFI->isThumb2Function())
281 if (isARMNEONPred(MI))
287 if (DefinesOptionalPredicate(MI, &CPSR)) {
296 unsigned ARMFastISel::constrainOperandRegClass(
const MCInstrDesc &II,
297 unsigned Op,
unsigned OpNum) {
300 TII.getRegClass(II, OpNum, &TRI, *FuncInfo.MF);
301 if (!
MRI.constrainRegClass(Op, RegClass)) {
304 unsigned NewOp = createResultReg(RegClass);
305 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
313 unsigned ARMFastISel::FastEmitInst_(
unsigned MachineInstOpcode,
315 unsigned ResultReg = createResultReg(RC);
318 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg));
322 unsigned ARMFastISel::FastEmitInst_r(
unsigned MachineInstOpcode,
324 unsigned Op0,
bool Op0IsKill) {
325 unsigned ResultReg = createResultReg(RC);
330 Op0 = constrainOperandRegClass(II, Op0, 1);
332 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
335 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
337 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
344 unsigned ARMFastISel::FastEmitInst_rr(
unsigned MachineInstOpcode,
346 unsigned Op0,
bool Op0IsKill,
347 unsigned Op1,
bool Op1IsKill) {
348 unsigned ResultReg = createResultReg(RC);
353 Op0 = constrainOperandRegClass(II, Op0, 1);
354 Op1 = constrainOperandRegClass(II, Op1, 2);
357 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
358 .
addReg(Op0, Op0IsKill * RegState::Kill)
359 .
addReg(Op1, Op1IsKill * RegState::Kill));
361 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
362 .
addReg(Op0, Op0IsKill * RegState::Kill)
363 .
addReg(Op1, Op1IsKill * RegState::Kill));
364 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
371 unsigned ARMFastISel::FastEmitInst_rrr(
unsigned MachineInstOpcode,
373 unsigned Op0,
bool Op0IsKill,
374 unsigned Op1,
bool Op1IsKill,
375 unsigned Op2,
bool Op2IsKill) {
376 unsigned ResultReg = createResultReg(RC);
381 Op0 = constrainOperandRegClass(II, Op0, 1);
382 Op1 = constrainOperandRegClass(II, Op1, 2);
383 Op2 = constrainOperandRegClass(II, Op1, 3);
386 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
387 .
addReg(Op0, Op0IsKill * RegState::Kill)
388 .
addReg(Op1, Op1IsKill * RegState::Kill)
389 .
addReg(Op2, Op2IsKill * RegState::Kill));
391 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
392 .
addReg(Op0, Op0IsKill * RegState::Kill)
393 .
addReg(Op1, Op1IsKill * RegState::Kill)
394 .
addReg(Op2, Op2IsKill * RegState::Kill));
395 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
402 unsigned ARMFastISel::FastEmitInst_ri(
unsigned MachineInstOpcode,
404 unsigned Op0,
bool Op0IsKill,
406 unsigned ResultReg = createResultReg(RC);
411 Op0 = constrainOperandRegClass(II, Op0, 1);
413 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
414 .
addReg(Op0, Op0IsKill * RegState::Kill)
417 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
418 .
addReg(Op0, Op0IsKill * RegState::Kill)
420 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
427 unsigned ARMFastISel::FastEmitInst_rf(
unsigned MachineInstOpcode,
429 unsigned Op0,
bool Op0IsKill,
431 unsigned ResultReg = createResultReg(RC);
436 Op0 = constrainOperandRegClass(II, Op0, 1);
438 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
439 .
addReg(Op0, Op0IsKill * RegState::Kill)
442 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
443 .
addReg(Op0, Op0IsKill * RegState::Kill)
445 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
452 unsigned ARMFastISel::FastEmitInst_rri(
unsigned MachineInstOpcode,
454 unsigned Op0,
bool Op0IsKill,
455 unsigned Op1,
bool Op1IsKill,
457 unsigned ResultReg = createResultReg(RC);
462 Op0 = constrainOperandRegClass(II, Op0, 1);
463 Op1 = constrainOperandRegClass(II, Op1, 2);
465 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
466 .
addReg(Op0, Op0IsKill * RegState::Kill)
467 .
addReg(Op1, Op1IsKill * RegState::Kill)
470 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
471 .
addReg(Op0, Op0IsKill * RegState::Kill)
472 .
addReg(Op1, Op1IsKill * RegState::Kill)
474 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
481 unsigned ARMFastISel::FastEmitInst_i(
unsigned MachineInstOpcode,
484 unsigned ResultReg = createResultReg(RC);
488 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
491 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
493 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
500 unsigned ARMFastISel::FastEmitInst_ii(
unsigned MachineInstOpcode,
502 uint64_t Imm1, uint64_t Imm2) {
503 unsigned ResultReg = createResultReg(RC);
507 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg)
510 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
512 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
520 unsigned ARMFastISel::FastEmitInst_extractsubreg(
MVT RetVT,
521 unsigned Op0,
bool Op0IsKill,
523 unsigned ResultReg = createResultReg(TLI.getRegClassFor(RetVT));
525 "Cannot yet extract from physregs");
527 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt,
535 unsigned ARMFastISel::ARMMoveToFPReg(
MVT VT,
unsigned SrcReg) {
538 unsigned MoveReg = createResultReg(TLI.getRegClassFor(VT));
539 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
540 TII.get(ARM::VMOVSR), MoveReg)
545 unsigned ARMFastISel::ARMMoveToIntReg(
MVT VT,
unsigned SrcReg) {
548 unsigned MoveReg = createResultReg(TLI.getRegClassFor(VT));
549 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
550 TII.get(ARM::VMOVRS), MoveReg)
558 unsigned ARMFastISel::ARMMaterializeFP(
const ConstantFP *CFP,
MVT VT) {
564 if (TLI.isFPImmLegal(Val, VT)) {
574 unsigned DestReg = createResultReg(TLI.getRegClassFor(VT));
575 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(Opc),
582 if (!Subtarget->hasVFP2())
return false;
588 Align =
TD.getTypeAllocSize(CFP->
getType());
590 unsigned Idx = MCP.getConstantPoolIndex(cast<Constant>(CFP), Align);
591 unsigned DestReg = createResultReg(TLI.getRegClassFor(VT));
592 unsigned Opc = is64bit ? ARM::VLDRD : ARM::VLDRS;
595 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(Opc),
597 .addConstantPoolIndex(Idx)
602 unsigned ARMFastISel::ARMMaterializeInt(
const Constant *
C,
MVT VT) {
611 unsigned Opc = isThumb2 ? ARM::t2MOVi16 : ARM::MOVi16;
614 unsigned ImmReg = createResultReg(RC);
615 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
616 TII.get(Opc), ImmReg)
627 unsigned Opc = isThumb2 ? ARM::t2MVNi : ARM::MVNi;
628 unsigned ImmReg = createResultReg(TLI.getRegClassFor(
MVT::i32));
629 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
630 TII.get(Opc), ImmReg)
640 unsigned DestReg = createResultReg(TLI.getRegClassFor(VT));
643 unsigned Align =
TD.getPrefTypeAlignment(C->
getType());
646 Align =
TD.getTypeAllocSize(C->
getType());
648 unsigned Idx = MCP.getConstantPoolIndex(C, Align);
651 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
652 TII.get(ARM::t2LDRpci), DestReg)
653 .addConstantPoolIndex(Idx));
656 DestReg = constrainOperandRegClass(
TII.get(ARM::LDRcp), DestReg, 0);
657 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
658 TII.get(ARM::LDRcp), DestReg)
659 .addConstantPoolIndex(Idx)
665 unsigned ARMFastISel::ARMMaterializeGV(
const GlobalValue *GV,
MVT VT) {
670 bool IsIndirect = Subtarget->GVIsIndirectSymbol(GV, RelocM);
674 unsigned DestReg = createResultReg(RC);
679 if (!Subtarget->isTargetDarwin() && IsThreadLocal)
return 0;
685 if (Subtarget->useMovt() &&
690 Opc = isThumb2 ? ARM::t2MOV_ga_pcrel : ARM::MOV_ga_pcrel;
693 Opc = isThumb2 ? ARM::t2MOV_ga_dyn : ARM::MOV_ga_dyn;
696 Opc = isThumb2 ? ARM::t2MOVi32imm : ARM::MOVi32imm;
699 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(Opc),
700 DestReg).addGlobalAddress(GV));
703 unsigned Align =
TD.getPrefTypeAlignment(GV->
getType());
706 Align =
TD.getTypeAllocSize(GV->
getType());
709 if (Subtarget->isTargetELF() && RelocM ==
Reloc::PIC_)
710 return ARMLowerPICELF(GV, Align, VT);
714 (Subtarget->isThumb() ? 4 : 8);
715 unsigned Id = AFI->createPICLabelUId();
719 unsigned Idx = MCP.getConstantPoolIndex(CPV, Align);
724 unsigned Opc = (RelocM!=
Reloc::PIC_) ? ARM::t2LDRpci : ARM::t2LDRpci_pic;
725 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(Opc), DestReg)
726 .addConstantPoolIndex(Idx);
729 AddOptionalDefs(MIB);
732 DestReg = constrainOperandRegClass(
TII.get(ARM::LDRcp), DestReg, 0);
733 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(ARM::LDRcp),
735 .addConstantPoolIndex(Idx)
737 AddOptionalDefs(MIB);
740 unsigned Opc = IsIndirect ? ARM::PICLDR : ARM::PICADD;
741 unsigned NewDestReg = createResultReg(TLI.getRegClassFor(VT));
744 DL,
TII.get(Opc), NewDestReg)
747 AddOptionalDefs(MIB);
755 unsigned NewDestReg = createResultReg(TLI.getRegClassFor(VT));
757 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
758 TII.get(ARM::t2LDRi12), NewDestReg)
762 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(ARM::LDRi12),
766 DestReg = NewDestReg;
767 AddOptionalDefs(MIB);
773 unsigned ARMFastISel::TargetMaterializeConstant(
const Constant *C) {
774 EVT CEVT = TLI.getValueType(C->
getType(),
true);
780 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(C))
781 return ARMMaterializeFP(CFP, VT);
782 else if (
const GlobalValue *GV = dyn_cast<GlobalValue>(C))
783 return ARMMaterializeGV(GV, VT);
784 else if (isa<ConstantInt>(C))
785 return ARMMaterializeInt(C, VT);
792 unsigned ARMFastISel::TargetMaterializeAlloca(
const AllocaInst *AI) {
794 if (!FuncInfo.StaticAllocaMap.count(AI))
return 0;
797 if (!isLoadTypeLegal(AI->
getType(), VT))
return 0;
800 FuncInfo.StaticAllocaMap.
find(AI);
804 if (SI != FuncInfo.StaticAllocaMap.
end()) {
806 unsigned ResultReg = createResultReg(RC);
807 unsigned Opc = isThumb2 ? ARM::t2ADDri : ARM::ADDri;
808 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
809 TII.get(Opc), ResultReg)
810 .addFrameIndex(SI->second)
818 bool ARMFastISel::isTypeLegal(
Type *Ty,
MVT &VT) {
819 EVT evt = TLI.getValueType(Ty,
true);
827 return TLI.isTypeLegal(VT);
830 bool ARMFastISel::isLoadTypeLegal(
Type *Ty,
MVT &VT) {
831 if (isTypeLegal(Ty, VT))
return true;
842 bool ARMFastISel::ARMComputeAddress(
const Value *Obj, Address &Addr) {
844 const User *U = NULL;
845 unsigned Opcode = Instruction::UserOp1;
846 if (
const Instruction *
I = dyn_cast<Instruction>(Obj)) {
849 if (FuncInfo.StaticAllocaMap.count(static_cast<const AllocaInst *>(Obj)) ||
850 FuncInfo.MBBMap[
I->getParent()] == FuncInfo.MBB) {
851 Opcode =
I->getOpcode();
854 }
else if (
const ConstantExpr *C = dyn_cast<ConstantExpr>(Obj)) {
855 Opcode = C->getOpcode();
860 if (Ty->getAddressSpace() > 255)
868 case Instruction::BitCast:
870 return ARMComputeAddress(U->
getOperand(0), Addr);
871 case Instruction::IntToPtr:
874 return ARMComputeAddress(U->
getOperand(0), Addr);
876 case Instruction::PtrToInt:
878 if (TLI.getValueType(U->
getType()) == TLI.getPointerTy())
879 return ARMComputeAddress(U->
getOperand(0), Addr);
881 case Instruction::GetElementPtr: {
882 Address SavedAddr = Addr;
883 int TmpOffset = Addr.Offset;
889 i != e; ++i, ++GTI) {
890 const Value *Op = *i;
891 if (
StructType *STy = dyn_cast<StructType>(*GTI)) {
893 unsigned Idx = cast<ConstantInt>(Op)->getZExtValue();
898 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(Op)) {
903 if (canFoldAddIntoGEP(U, Op)) {
906 cast<ConstantInt>(cast<AddOperator>(Op)->getOperand(1));
909 Op = cast<AddOperator>(Op)->getOperand(0);
913 goto unsupported_gep;
919 Addr.Offset = TmpOffset;
920 if (ARMComputeAddress(U->
getOperand(0), Addr))
return true;
928 case Instruction::Alloca: {
931 FuncInfo.StaticAllocaMap.
find(AI);
932 if (SI != FuncInfo.StaticAllocaMap.end()) {
933 Addr.BaseType = Address::FrameIndexBase;
934 Addr.Base.FI = SI->second;
942 if (Addr.Base.Reg == 0) Addr.Base.Reg = getRegForValue(Obj);
943 return Addr.Base.Reg != 0;
946 void ARMFastISel::ARMSimplifyAddress(Address &Addr,
MVT VT,
bool useAM3) {
947 bool needsLowering =
false;
956 needsLowering = ((Addr.Offset & 0xfff) != Addr.Offset);
958 if (needsLowering && isThumb2)
959 needsLowering = !(Subtarget->hasV6T2Ops() && Addr.Offset < 0 &&
963 needsLowering = (Addr.Offset > 255 || Addr.Offset < -255);
969 needsLowering = ((Addr.Offset & 0xff) != Addr.Offset);
976 if (needsLowering && Addr.BaseType == Address::FrameIndexBase) {
980 unsigned ResultReg = createResultReg(RC);
981 unsigned Opc = isThumb2 ? ARM::t2ADDri : ARM::ADDri;
982 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
983 TII.get(Opc), ResultReg)
984 .addFrameIndex(Addr.Base.FI)
986 Addr.Base.Reg = ResultReg;
987 Addr.BaseType = Address::RegBase;
999 void ARMFastISel::AddLoadStoreOperands(
MVT VT, Address &Addr,
1001 unsigned Flags,
bool useAM3) {
1008 if (Addr.BaseType == Address::FrameIndexBase) {
1009 int FI = Addr.Base.FI;
1010 int Offset = Addr.Offset;
1012 FuncInfo.MF->getMachineMemOperand(
1015 MFI.getObjectSize(FI),
1016 MFI.getObjectAlignment(FI));
1023 signed Imm = (Addr.Offset < 0) ? (0x100 | -Addr.Offset) : Addr.Offset;
1032 MIB.
addReg(Addr.Base.Reg);
1037 signed Imm = (Addr.Offset < 0) ? (0x100 | -Addr.Offset) : Addr.Offset;
1044 AddOptionalDefs(MIB);
1047 bool ARMFastISel::ARMEmitLoad(
MVT VT,
unsigned &ResultReg, Address &Addr,
1048 unsigned Alignment,
bool isZExt,
bool allocReg) {
1050 bool useAM3 =
false;
1051 bool needVMOV =
false;
1055 default:
return false;
1059 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
1060 Opc = isZExt ? ARM::t2LDRBi8 : ARM::t2LDRSBi8;
1062 Opc = isZExt ? ARM::t2LDRBi12 : ARM::t2LDRSBi12;
1071 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
1074 if (Alignment && Alignment < 2 && !Subtarget->allowsUnalignedMem())
1078 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
1079 Opc = isZExt ? ARM::t2LDRHi8 : ARM::t2LDRSHi8;
1081 Opc = isZExt ? ARM::t2LDRHi12 : ARM::t2LDRSHi12;
1083 Opc = isZExt ? ARM::LDRH : ARM::LDRSH;
1086 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
1089 if (Alignment && Alignment < 4 && !Subtarget->allowsUnalignedMem())
1093 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
1096 Opc = ARM::t2LDRi12;
1100 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
1103 if (!Subtarget->hasVFP2())
return false;
1105 if (Alignment && Alignment < 4) {
1108 Opc = isThumb2 ? ARM::t2LDRi12 : ARM::LDRi12;
1109 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRnopcRegClass;
1112 RC = TLI.getRegClassFor(VT);
1116 if (!Subtarget->hasVFP2())
return false;
1119 if (Alignment && Alignment < 4)
1123 RC = TLI.getRegClassFor(VT);
1127 ARMSimplifyAddress(Addr, VT, useAM3);
1131 ResultReg = createResultReg(RC);
1132 assert (ResultReg > 255 &&
"Expected an allocated virtual register.");
1134 TII.get(Opc), ResultReg);
1140 unsigned MoveReg = createResultReg(TLI.getRegClassFor(
MVT::f32));
1141 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
1142 TII.get(ARM::VMOVSR), MoveReg)
1143 .addReg(ResultReg));
1144 ResultReg = MoveReg;
1156 if (!isLoadTypeLegal(I->
getType(), VT))
1161 if (!ARMComputeAddress(I->
getOperand(0), Addr))
return false;
1164 if (!ARMEmitLoad(VT, ResultReg, Addr, cast<LoadInst>(I)->getAlignment()))
1166 UpdateValueMap(I, ResultReg);
1170 bool ARMFastISel::ARMEmitStore(
MVT VT,
unsigned SrcReg, Address &Addr,
1171 unsigned Alignment) {
1173 bool useAM3 =
false;
1176 default:
return false;
1178 unsigned Res = createResultReg(isThumb2 ?
1181 unsigned Opc = isThumb2 ? ARM::t2ANDri : ARM::ANDri;
1182 SrcReg = constrainOperandRegClass(
TII.get(Opc), SrcReg, 1);
1183 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
1185 .addReg(SrcReg).
addImm(1));
1190 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
1191 StrOpc = ARM::t2STRBi8;
1193 StrOpc = ARM::t2STRBi12;
1195 StrOpc = ARM::STRBi12;
1199 if (Alignment && Alignment < 2 && !Subtarget->allowsUnalignedMem())
1203 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
1204 StrOpc = ARM::t2STRHi8;
1206 StrOpc = ARM::t2STRHi12;
1213 if (Alignment && Alignment < 4 && !Subtarget->allowsUnalignedMem())
1217 if (Addr.Offset < 0 && Addr.Offset > -256 && Subtarget->hasV6T2Ops())
1218 StrOpc = ARM::t2STRi8;
1220 StrOpc = ARM::t2STRi12;
1222 StrOpc = ARM::STRi12;
1226 if (!Subtarget->hasVFP2())
return false;
1228 if (Alignment && Alignment < 4) {
1229 unsigned MoveReg = createResultReg(TLI.getRegClassFor(
MVT::i32));
1230 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
1231 TII.get(ARM::VMOVRS), MoveReg)
1235 StrOpc = isThumb2 ? ARM::t2STRi12 : ARM::STRi12;
1237 StrOpc = ARM::VSTRS;
1241 if (!Subtarget->hasVFP2())
return false;
1244 if (Alignment && Alignment < 4)
1247 StrOpc = ARM::VSTRD;
1251 ARMSimplifyAddress(Addr, VT, useAM3);
1254 SrcReg = constrainOperandRegClass(
TII.get(StrOpc), SrcReg, 0);
1262 bool ARMFastISel::SelectStore(
const Instruction *I) {
1264 unsigned SrcReg = 0;
1267 if (cast<StoreInst>(I)->
isAtomic())
1276 SrcReg = getRegForValue(Op0);
1277 if (SrcReg == 0)
return false;
1281 if (!ARMComputeAddress(I->
getOperand(1), Addr))
1284 if (!ARMEmitStore(VT, SrcReg, Addr, cast<StoreInst>(I)->getAlignment()))
1336 bool ARMFastISel::SelectBranch(
const Instruction *I) {
1351 if (FuncInfo.MBB->isLayoutSuccessor(TBB)) {
1365 unsigned BrOpc = isThumb2 ? ARM::t2Bcc : ARM::Bcc;
1366 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(BrOpc))
1368 FastEmitBranch(FBB, DL);
1369 FuncInfo.MBB->addSuccessor(TBB);
1374 if (TI->hasOneUse() && TI->getParent() == I->
getParent() &&
1375 (isLoadTypeLegal(TI->getOperand(0)->getType(), SourceVT))) {
1376 unsigned TstOpc = isThumb2 ? ARM::t2TSTri : ARM::TSTri;
1377 unsigned OpReg = getRegForValue(TI->getOperand(0));
1378 OpReg = constrainOperandRegClass(
TII.get(TstOpc), OpReg, 0);
1379 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
1381 .addReg(OpReg).
addImm(1));
1384 if (FuncInfo.MBB->isLayoutSuccessor(TBB)) {
1389 unsigned BrOpc = isThumb2 ? ARM::t2Bcc : ARM::Bcc;
1390 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(BrOpc))
1393 FastEmitBranch(FBB, DL);
1394 FuncInfo.MBB->addSuccessor(TBB);
1401 FastEmitBranch(Target, DL);
1406 if (CmpReg == 0)
return false;
1415 unsigned TstOpc = isThumb2 ? ARM::t2TSTri : ARM::TSTri;
1416 CmpReg = constrainOperandRegClass(
TII.get(TstOpc), CmpReg, 0);
1417 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(TstOpc))
1418 .addReg(CmpReg).
addImm(1));
1421 if (FuncInfo.MBB->isLayoutSuccessor(TBB)) {
1426 unsigned BrOpc = isThumb2 ? ARM::t2Bcc : ARM::Bcc;
1427 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(BrOpc))
1429 FastEmitBranch(FBB, DL);
1430 FuncInfo.MBB->addSuccessor(TBB);
1434 bool ARMFastISel::SelectIndirectBr(
const Instruction *I) {
1435 unsigned AddrReg = getRegForValue(I->
getOperand(0));
1436 if (AddrReg == 0)
return false;
1438 unsigned Opc = isThumb2 ? ARM::tBRIND : ARM::BX;
1439 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(Opc))
1443 for (
unsigned i = 0, e = IB->getNumSuccessors(); i != e; ++i)
1444 FuncInfo.MBB->addSuccessor(FuncInfo.MBBMap[IB->getSuccessor(i)]);
1449 bool ARMFastISel::ARMEmitCmp(
const Value *Src1Value,
const Value *Src2Value,
1452 EVT SrcEVT = TLI.getValueType(Ty,
true);
1453 if (!SrcEVT.
isSimple())
return false;
1457 if (isFloat && !Subtarget->hasVFP2())
1463 bool UseImm =
false;
1464 bool isNegativeImm =
false;
1467 if (
const ConstantInt *ConstInt = dyn_cast<ConstantInt>(Src2Value)) {
1470 const APInt &CIVal = ConstInt->getValue();
1475 if (Imm < 0 && Imm != (
int)0x80000000) {
1476 isNegativeImm =
true;
1482 }
else if (
const ConstantFP *ConstFP = dyn_cast<ConstantFP>(Src2Value)) {
1484 if (ConstFP->isZero() && !ConstFP->isNegative())
1490 bool needsExt =
false;
1492 default:
return false;
1496 CmpOpc = UseImm ? ARM::VCMPEZS : ARM::VCMPES;
1500 CmpOpc = UseImm ? ARM::VCMPEZD : ARM::VCMPED;
1510 CmpOpc = ARM::t2CMPrr;
1512 CmpOpc = isNegativeImm ? ARM::t2CMNri : ARM::t2CMPri;
1515 CmpOpc = ARM::CMPrr;
1517 CmpOpc = isNegativeImm ? ARM::CMNri : ARM::CMPri;
1522 unsigned SrcReg1 = getRegForValue(Src1Value);
1523 if (SrcReg1 == 0)
return false;
1525 unsigned SrcReg2 = 0;
1527 SrcReg2 = getRegForValue(Src2Value);
1528 if (SrcReg2 == 0)
return false;
1533 SrcReg1 = ARMEmitIntExt(SrcVT, SrcReg1,
MVT::i32, isZExt);
1534 if (SrcReg1 == 0)
return false;
1536 SrcReg2 = ARMEmitIntExt(SrcVT, SrcReg2,
MVT::i32, isZExt);
1537 if (SrcReg2 == 0)
return false;
1542 SrcReg1 = constrainOperandRegClass(II, SrcReg1, 0);
1544 SrcReg2 = constrainOperandRegClass(II, SrcReg2, 1);
1545 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
1549 MIB =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II)
1555 AddOptionalDefs(MIB);
1561 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
1566 bool ARMFastISel::SelectCmp(
const Instruction *I) {
1567 const CmpInst *CI = cast<CmpInst>(
I);
1581 unsigned MovCCOpc = isThumb2 ? ARM::t2MOVCCi : ARM::MOVCCi;
1585 unsigned DestReg = createResultReg(RC);
1587 unsigned ZeroReg = TargetMaterializeConstant(Zero);
1589 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(MovCCOpc), DestReg)
1590 .addReg(ZeroReg).
addImm(1)
1593 UpdateValueMap(I, DestReg);
1597 bool ARMFastISel::SelectFPExt(
const Instruction *I) {
1599 if (!Subtarget->hasVFP2())
return false;
1605 unsigned Op = getRegForValue(V);
1606 if (Op == 0)
return false;
1608 unsigned Result = createResultReg(&ARM::DPRRegClass);
1609 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
1610 TII.get(ARM::VCVTDS), Result)
1612 UpdateValueMap(I, Result);
1616 bool ARMFastISel::SelectFPTrunc(
const Instruction *I) {
1618 if (!Subtarget->hasVFP2())
return false;
1624 unsigned Op = getRegForValue(V);
1625 if (Op == 0)
return false;
1627 unsigned Result = createResultReg(&ARM::SPRRegClass);
1628 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
1629 TII.get(ARM::VCVTSD), Result)
1631 UpdateValueMap(I, Result);
1635 bool ARMFastISel::SelectIToFP(
const Instruction *I,
bool isSigned) {
1637 if (!Subtarget->hasVFP2())
return false;
1641 if (!isTypeLegal(Ty, DstVT))
1645 EVT SrcEVT = TLI.getValueType(Src->
getType(),
true);
1652 unsigned SrcReg = getRegForValue(Src);
1653 if (SrcReg == 0)
return false;
1657 SrcReg = ARMEmitIntExt(SrcVT, SrcReg,
MVT::i32,
1659 if (SrcReg == 0)
return false;
1664 unsigned FP = ARMMoveToFPReg(
MVT::f32, SrcReg);
1665 if (FP == 0)
return false;
1668 if (Ty->
isFloatTy()) Opc = isSigned ? ARM::VSITOS : ARM::VUITOS;
1669 else if (Ty->
isDoubleTy()) Opc = isSigned ? ARM::VSITOD : ARM::VUITOD;
1672 unsigned ResultReg = createResultReg(TLI.getRegClassFor(DstVT));
1673 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(Opc),
1676 UpdateValueMap(I, ResultReg);
1680 bool ARMFastISel::SelectFPToI(
const Instruction *I,
bool isSigned) {
1682 if (!Subtarget->hasVFP2())
return false;
1686 if (!isTypeLegal(RetTy, DstVT))
1689 unsigned Op = getRegForValue(I->
getOperand(0));
1690 if (Op == 0)
return false;
1694 if (OpTy->
isFloatTy()) Opc = isSigned ? ARM::VTOSIZS : ARM::VTOUIZS;
1695 else if (OpTy->
isDoubleTy()) Opc = isSigned ? ARM::VTOSIZD : ARM::VTOUIZD;
1699 unsigned ResultReg = createResultReg(TLI.getRegClassFor(
MVT::f32));
1700 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(Opc),
1706 unsigned IntReg = ARMMoveToIntReg(DstVT, ResultReg);
1707 if (IntReg == 0)
return false;
1709 UpdateValueMap(I, IntReg);
1713 bool ARMFastISel::SelectSelect(
const Instruction *I) {
1715 if (!isTypeLegal(I->
getType(), VT))
1721 unsigned CondReg = getRegForValue(I->
getOperand(0));
1722 if (CondReg == 0)
return false;
1723 unsigned Op1Reg = getRegForValue(I->
getOperand(1));
1724 if (Op1Reg == 0)
return false;
1728 bool UseImm =
false;
1729 bool isNegativeImm =
false;
1731 assert (VT ==
MVT::i32 &&
"Expecting an i32.");
1732 Imm = (int)ConstInt->getValue().getZExtValue();
1734 isNegativeImm =
true;
1741 unsigned Op2Reg = 0;
1744 if (Op2Reg == 0)
return false;
1747 unsigned CmpOpc = isThumb2 ? ARM::t2CMPri : ARM::CMPri;
1748 CondReg = constrainOperandRegClass(
TII.get(CmpOpc), CondReg, 0);
1749 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(CmpOpc))
1750 .addReg(CondReg).
addImm(0));
1755 RC = isThumb2 ? &ARM::tGPRRegClass : &ARM::GPRRegClass;
1756 MovCCOpc = isThumb2 ? ARM::t2MOVCCr : ARM::MOVCCr;
1758 RC = isThumb2 ? &ARM::rGPRRegClass : &ARM::GPRRegClass;
1760 MovCCOpc = isThumb2 ? ARM::t2MOVCCi : ARM::MOVCCi;
1762 MovCCOpc = isThumb2 ? ARM::t2MVNCCi : ARM::MVNCCi;
1764 unsigned ResultReg = createResultReg(RC);
1766 Op2Reg = constrainOperandRegClass(
TII.get(MovCCOpc), Op2Reg, 1);
1767 Op1Reg = constrainOperandRegClass(
TII.get(MovCCOpc), Op1Reg, 2);
1768 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(MovCCOpc), ResultReg)
1771 Op1Reg = constrainOperandRegClass(
TII.get(MovCCOpc), Op1Reg, 1);
1772 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(MovCCOpc), ResultReg)
1775 UpdateValueMap(I, ResultReg);
1779 bool ARMFastISel::SelectDiv(
const Instruction *I,
bool isSigned) {
1782 if (!isTypeLegal(Ty, VT))
1788 if (Subtarget->hasDivide())
return false;
1804 return ARMEmitLibcall(I, LC);
1807 bool ARMFastISel::SelectRem(
const Instruction *I,
bool isSigned) {
1810 if (!isTypeLegal(Ty, VT))
1826 return ARMEmitLibcall(I, LC);
1829 bool ARMFastISel::SelectBinaryIntOp(
const Instruction *I,
unsigned ISDOpcode) {
1830 EVT DestVT = TLI.getValueType(I->
getType(),
true);
1838 switch (ISDOpcode) {
1839 default:
return false;
1841 Opc = isThumb2 ? ARM::t2ADDrr : ARM::ADDrr;
1844 Opc = isThumb2 ? ARM::t2ORRrr : ARM::ORRrr;
1847 Opc = isThumb2 ? ARM::t2SUBrr : ARM::SUBrr;
1851 unsigned SrcReg1 = getRegForValue(I->
getOperand(0));
1852 if (SrcReg1 == 0)
return false;
1856 unsigned SrcReg2 = getRegForValue(I->
getOperand(1));
1857 if (SrcReg2 == 0)
return false;
1859 unsigned ResultReg = createResultReg(&ARM::GPRnopcRegClass);
1860 SrcReg1 = constrainOperandRegClass(
TII.get(Opc), SrcReg1, 1);
1861 SrcReg2 = constrainOperandRegClass(
TII.get(Opc), SrcReg2, 2);
1862 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
1863 TII.get(Opc), ResultReg)
1864 .addReg(SrcReg1).
addReg(SrcReg2));
1865 UpdateValueMap(I, ResultReg);
1869 bool ARMFastISel::SelectBinaryFPOp(
const Instruction *I,
unsigned ISDOpcode) {
1870 EVT FPVT = TLI.getValueType(I->
getType(),
true);
1871 if (!FPVT.
isSimple())
return false;
1880 if (isFloat && !Subtarget->hasVFP2())
1885 switch (ISDOpcode) {
1886 default:
return false;
1888 Opc = is64bit ? ARM::VADDD : ARM::VADDS;
1891 Opc = is64bit ? ARM::VSUBD : ARM::VSUBS;
1894 Opc = is64bit ? ARM::VMULD : ARM::VMULS;
1897 unsigned Op1 = getRegForValue(I->
getOperand(0));
1898 if (Op1 == 0)
return false;
1900 unsigned Op2 = getRegForValue(I->
getOperand(1));
1901 if (Op2 == 0)
return false;
1903 unsigned ResultReg = createResultReg(TLI.getRegClassFor(VT.
SimpleTy));
1904 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
1905 TII.get(Opc), ResultReg)
1906 .addReg(Op1).
addReg(Op2));
1907 UpdateValueMap(I, ResultReg);
1922 if (Subtarget->hasVFP2() && !isVarArg) {
1923 if (!Subtarget->isAAPCS_ABI())
1924 return (Return ? RetFastCC_ARM_APCS : FastCC_ARM_APCS);
1926 return (Return ? RetCC_ARM_AAPCS_VFP : CC_ARM_AAPCS_VFP);
1931 if (Subtarget->isAAPCS_ABI()) {
1932 if (Subtarget->hasVFP2() &&
1934 return (Return ? RetCC_ARM_AAPCS_VFP: CC_ARM_AAPCS_VFP);
1936 return (Return ? RetCC_ARM_AAPCS: CC_ARM_AAPCS);
1938 return (Return ? RetCC_ARM_APCS: CC_ARM_APCS);
1941 return (Return ? RetCC_ARM_AAPCS_VFP: CC_ARM_AAPCS_VFP);
1945 return (Return ? RetCC_ARM_AAPCS: CC_ARM_AAPCS);
1947 return (Return ? RetCC_ARM_APCS: CC_ARM_APCS);
1952 return CC_ARM_APCS_GHC;
1965 CCState CCInfo(CC, isVarArg, *FuncInfo.MF,
TM, ArgLocs, *Context);
1966 CCInfo.AnalyzeCallOperands(ArgVTs, ArgFlags,
1967 CCAssignFnForCall(CC,
false, isVarArg));
1971 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
1986 !VA.
isRegLoc() || !ArgLocs[++i].isRegLoc())
1998 if (!Subtarget->hasVFP2())
2002 if (!Subtarget->hasVFP2())
2012 NumBytes = CCInfo.getNextStackOffset();
2015 unsigned AdjStackDown =
TII.getCallFrameSetupOpcode();
2016 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
2017 TII.get(AdjStackDown))
2021 for (
unsigned i = 0, e = ArgLocs.
size(); i != e; ++i) {
2023 unsigned Arg = ArgRegs[VA.
getValNo()];
2027 "We don't handle NEON/vector parameters yet.");
2034 Arg = ARMEmitIntExt(ArgVT, Arg, DestVT,
false);
2035 assert (Arg != 0 &&
"Failed to emit a sext");
2043 Arg = ARMEmitIntExt(ArgVT, Arg, DestVT,
true);
2044 assert (Arg != 0 &&
"Failed to emit a zext");
2051 assert(BC != 0 &&
"Failed to emit a bitcast!");
2068 "Custom lowering for v2f64 args not available");
2072 assert(VA.
isRegLoc() && NextVA.isRegLoc() &&
2073 "We only handle register args!");
2075 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
2085 Addr.BaseType = Address::RegBase;
2086 Addr.Base.Reg = ARM::SP;
2089 bool EmitRet = ARMEmitStore(ArgVT, Arg, Addr); (void)EmitRet;
2090 assert(EmitRet &&
"Could not emit a store for argument!");
2099 unsigned &NumBytes,
bool isVarArg) {
2101 unsigned AdjStackUp =
TII.getCallFrameDestroyOpcode();
2102 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
2103 TII.get(AdjStackUp))
2104 .addImm(NumBytes).
addImm(0));
2109 CCState CCInfo(CC, isVarArg, *FuncInfo.MF,
TM, RVLocs, *Context);
2110 CCInfo.AnalyzeCallResult(RetVT, CCAssignFnForCall(CC,
true, isVarArg));
2116 MVT DestVT = RVLocs[0].getValVT();
2118 unsigned ResultReg = createResultReg(DstRC);
2119 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
2121 .addReg(RVLocs[0].getLocReg())
2122 .addReg(RVLocs[1].getLocReg()));
2124 UsedRegs.
push_back(RVLocs[0].getLocReg());
2125 UsedRegs.
push_back(RVLocs[1].getLocReg());
2128 UpdateValueMap(I, ResultReg);
2130 assert(RVLocs.
size() == 1 &&
"Can't handle non-double multi-reg retvals!");
2131 MVT CopyVT = RVLocs[0].getValVT();
2139 unsigned ResultReg = createResultReg(DstRC);
2141 ResultReg).addReg(RVLocs[0].getLocReg());
2142 UsedRegs.
push_back(RVLocs[0].getLocReg());
2145 UpdateValueMap(I, ResultReg);
2152 bool ARMFastISel::SelectRet(
const Instruction *I) {
2156 if (!FuncInfo.CanLowerReturn)
2165 GetReturnInfo(F.getReturnType(), F.getAttributes(), Outs, TLI);
2174 unsigned Reg = getRegForValue(RV);
2179 if (ValLocs.size() != 1)
2191 unsigned SrcReg = Reg + VA.
getValNo();
2193 if (!RVEVT.
isSimple())
return false;
2197 if (RVVT != DestVT) {
2201 assert(DestVT ==
MVT::i32 &&
"ARM should always ext to i32");
2205 if (Outs[0].Flags.isZExt() || Outs[0].Flags.isSExt()) {
2206 SrcReg = ARMEmitIntExt(RVVT, SrcReg, DestVT, Outs[0].Flags.isZExt());
2207 if (SrcReg == 0)
return false;
2218 DstReg).addReg(SrcReg);
2224 unsigned RetOpc = isThumb2 ? ARM::tBX_RET : ARM::BX_RET;
2227 AddOptionalDefs(MIB);
2228 for (
unsigned i = 0, e = RetRegs.
size(); i != e; ++i)
2233 unsigned ARMFastISel::ARMSelectCallOp(
bool UseReg) {
2235 return isThumb2 ? ARM::tBLXr : ARM::BLX;
2237 return isThumb2 ? ARM::tBL :
ARM::BL;
2240 unsigned ARMFastISel::getLibcallReg(
const Twine &
Name) {
2243 EVT LCREVT = TLI.getValueType(GVTy);
2248 assert(GV->
getType() == GVTy &&
"We miscomputed the type for the global!");
2249 return ARMMaterializeGV(GV, LCREVT.
getSimpleVT());
2267 else if (!isTypeLegal(RetTy, RetVT))
2273 CCState CCInfo(CC,
false, *FuncInfo.MF,
TM, RVLocs, *Context);
2274 CCInfo.AnalyzeCallResult(RetVT, CCAssignFnForCall(CC,
true,
false));
2290 unsigned Arg = getRegForValue(Op);
2291 if (Arg == 0)
return false;
2295 if (!isTypeLegal(ArgTy, ArgVT))
return false;
2298 unsigned OriginalAlignment =
TD.getABITypeAlignment(ArgTy);
2310 if (!ProcessCallArgs(Args, ArgRegs, ArgVTs, ArgFlags,
2311 RegArgs, CC, NumBytes,
false))
2314 unsigned CalleeReg = 0;
2316 CalleeReg = getLibcallReg(TLI.getLibcallName(Call));
2317 if (CalleeReg == 0)
return false;
2323 DL,
TII.get(CallOpc));
2333 for (
unsigned i = 0, e = RegArgs.
size(); i != e; ++i)
2338 MIB.
addRegMask(TRI.getCallPreservedMask(CC));
2342 if (!FinishCall(RetVT, UsedRegs, I, CC, NumBytes,
false))
return false;
2345 static_cast<MachineInstr *
>(MIB)->setPhysRegsDeadExcept(UsedRegs, TRI);
2350 bool ARMFastISel::SelectCall(
const Instruction *I,
2351 const char *IntrMemName = 0) {
2356 if (isa<InlineAsm>(Callee))
return false;
2367 PointerType *PT = cast<PointerType>(CS.getCalledValue()->getType());
2369 bool isVarArg = FTy->isVarArg();
2376 else if (!isTypeLegal(RetTy, RetVT) && RetVT !=
MVT::i16 &&
2384 CCState CCInfo(CC, isVarArg, *FuncInfo.MF,
TM, RVLocs, *Context);
2385 CCInfo.AnalyzeCallResult(RetVT, CCAssignFnForCall(CC,
true, isVarArg));
2395 unsigned arg_size = CS.arg_size();
2404 if (IntrMemName && e-i <= 2)
2408 unsigned AttrInd = i - CS.arg_begin() + 1;
2421 Type *ArgTy = (*i)->getType();
2423 if (!isTypeLegal(ArgTy, ArgVT) && ArgVT !=
MVT::i16 && ArgVT !=
MVT::i8 &&
2427 unsigned Arg = getRegForValue(*i);
2431 unsigned OriginalAlignment =
TD.getABITypeAlignment(ArgTy);
2443 if (!ProcessCallArgs(Args, ArgRegs, ArgVTs, ArgFlags,
2444 RegArgs, CC, NumBytes, isVarArg))
2447 bool UseReg =
false;
2451 unsigned CalleeReg = 0;
2454 CalleeReg = getLibcallReg(IntrMemName);
2456 CalleeReg = getRegForValue(Callee);
2458 if (CalleeReg == 0)
return false;
2462 unsigned CallOpc = ARMSelectCallOp(UseReg);
2464 DL,
TII.get(CallOpc));
2466 unsigned char OpFlags = 0;
2470 if (Subtarget->isTargetELF() &&
TM.getRelocationModel() ==
Reloc::PIC_)
2478 else if (!IntrMemName)
2484 for (
unsigned i = 0, e = RegArgs.
size(); i != e; ++i)
2489 MIB.
addRegMask(TRI.getCallPreservedMask(CC));
2493 if (!FinishCall(RetVT, UsedRegs, I, CC, NumBytes, isVarArg))
2497 static_cast<MachineInstr *
>(MIB)->setPhysRegsDeadExcept(UsedRegs, TRI);
2502 bool ARMFastISel::ARMIsMemCpySmall(uint64_t Len) {
2506 bool ARMFastISel::ARMTryEmitSmallMemCpy(Address Dest, Address Src,
2507 uint64_t Len,
unsigned Alignment) {
2509 if (!ARMIsMemCpySmall(Len))
2514 if (!Alignment || Alignment >= 4) {
2520 assert (Len == 1 &&
"Expected a length of 1!");
2525 if (Len >= 2 && Alignment == 2)
2534 RV = ARMEmitLoad(VT, ResultReg, Src);
2535 assert (RV ==
true &&
"Should be able to handle this load.");
2536 RV = ARMEmitStore(VT, ResultReg, Dest);
2537 assert (RV ==
true &&
"Should be able to handle this store.");
2542 Dest.Offset += Size;
2549 bool ARMFastISel::SelectIntrinsicCall(
const IntrinsicInst &I) {
2552 default:
return false;
2560 LdrOpc = ARM::t2LDRi12;
2563 LdrOpc = ARM::LDRi12;
2570 unsigned SrcReg = FramePtr;
2578 unsigned Depth = cast<ConstantInt>(I.
getOperand(0))->getZExtValue();
2580 DestReg = createResultReg(RC);
2581 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
2582 TII.get(LdrOpc), DestReg)
2583 .addReg(SrcReg).
addImm(0));
2586 UpdateValueMap(&I, SrcReg);
2599 if (isa<ConstantInt>(MTI.
getLength()) && isMemCpy) {
2602 uint64_t Len = cast<ConstantInt>(MTI.
getLength())->getZExtValue();
2603 if (ARMIsMemCpySmall(Len)) {
2605 if (!ARMComputeAddress(MTI.
getRawDest(), Dest) ||
2609 if (ARMTryEmitSmallMemCpy(Dest, Src, Len, Alignment))
2620 const char *IntrMemName = isa<MemCpyInst>(
I) ?
"memcpy" :
"memmove";
2621 return SelectCall(&I, IntrMemName);
2635 return SelectCall(&I,
"memset");
2638 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(
2639 Subtarget->useNaClTrap() ? ARM::TRAPNaCl :
ARM::TRAP));
2645 bool ARMFastISel::SelectTrunc(
const Instruction *I) {
2651 SrcVT = TLI.getValueType(Op->
getType(),
true);
2652 DestVT = TLI.getValueType(I->
getType(),
true);
2659 unsigned SrcReg = getRegForValue(Op);
2660 if (!SrcReg)
return false;
2664 UpdateValueMap(I, SrcReg);
2668 unsigned ARMFastISel::ARMEmitIntExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
2677 static const uint8_t isSingleInstrTbl[3][2][2][2] = {
2681 { { { 0, 1 }, { 0, 1 } }, { { 0, 0 }, { 0, 1 } } },
2682 { { { 0, 1 }, { 1, 1 } }, { { 0, 0 }, { 1, 1 } } },
2683 { { { 0, 0 }, { 1, 1 } }, { { 0, 0 }, { 1, 1 } } }
2692 { &ARM::GPRnopcRegClass, &ARM::GPRnopcRegClass },
2693 { &ARM::tGPRRegClass, &ARM::rGPRRegClass }
2697 static const struct InstructionTable {
2702 }
IT[2][2][3][2] = {
2744 assert((SrcBits < DestBits) &&
"can only extend to larger types");
2745 assert((DestBits == 32 || DestBits == 16 || DestBits == 8) &&
2746 "other sizes unimplemented");
2747 assert((SrcBits == 16 || SrcBits == 8 || SrcBits == 1) &&
2748 "other sizes unimplemented");
2750 bool hasV6Ops = Subtarget->hasV6Ops();
2751 unsigned Bitness = SrcBits / 8;
2752 assert((Bitness < 3) &&
"sanity-check table bounds");
2754 bool isSingleInstr = isSingleInstrTbl[Bitness][isThumb2][hasV6Ops][isZExt];
2756 const InstructionTable *ITP = &
IT[isSingleInstr][isThumb2][Bitness][isZExt];
2757 unsigned Opc = ITP->Opc;
2758 assert(
ARM::KILL != Opc &&
"Invalid table entry");
2759 unsigned hasS = ITP->hasS;
2762 "only MOVsi has shift operand addressing mode");
2763 unsigned Imm = ITP->Imm;
2766 bool setsCPSR = &ARM::tGPRRegClass == RC;
2767 unsigned LSLOpc = isThumb2 ? ARM::tLSLri : ARM::MOVsi;
2782 unsigned NumInstrsEmitted = isSingleInstr ? 1 : 2;
2783 for (
unsigned Instr = 0; Instr != NumInstrsEmitted; ++Instr) {
2784 ResultReg = createResultReg(RC);
2785 bool isLsl = (0 == Instr) && !isSingleInstr;
2786 unsigned Opcode = isLsl ? LSLOpc : Opc;
2789 bool isKill = 1 == Instr;
2791 *FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(Opcode), ResultReg);
2794 SrcReg = constrainOperandRegClass(
TII.get(Opcode), SrcReg, 1 + setsCPSR);
2805 bool ARMFastISel::SelectIntExt(
const Instruction *I) {
2812 bool isZExt = isa<ZExtInst>(
I);
2813 unsigned SrcReg = getRegForValue(Src);
2814 if (!SrcReg)
return false;
2816 EVT SrcEVT, DestEVT;
2817 SrcEVT = TLI.getValueType(SrcTy,
true);
2818 DestEVT = TLI.getValueType(DestTy,
true);
2819 if (!SrcEVT.
isSimple())
return false;
2820 if (!DestEVT.
isSimple())
return false;
2824 unsigned ResultReg = ARMEmitIntExt(SrcVT, SrcReg, DestVT, isZExt);
2825 if (ResultReg == 0)
return false;
2826 UpdateValueMap(I, ResultReg);
2830 bool ARMFastISel::SelectShift(
const Instruction *I,
2838 EVT DestVT = TLI.getValueType(I->
getType(),
true);
2842 unsigned Opc = ARM::MOVsr;
2845 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(Src2Value)) {
2846 ShiftImm = CI->getZExtValue();
2850 if (ShiftImm == 0 || ShiftImm >=32)
2857 unsigned Reg1 = getRegForValue(Src1Value);
2858 if (Reg1 == 0)
return false;
2861 if (Opc == ARM::MOVsr) {
2862 Reg2 = getRegForValue(Src2Value);
2863 if (Reg2 == 0)
return false;
2866 unsigned ResultReg = createResultReg(&ARM::GPRnopcRegClass);
2867 if(ResultReg == 0)
return false;
2870 TII.get(Opc), ResultReg)
2873 if (Opc == ARM::MOVsi)
2874 MIB.
addImm(ARM_AM::getSORegOpc(ShiftTy, ShiftImm));
2875 else if (Opc == ARM::MOVsr) {
2877 MIB.
addImm(ARM_AM::getSORegOpc(ShiftTy, 0));
2880 AddOptionalDefs(MIB);
2881 UpdateValueMap(I, ResultReg);
2886 bool ARMFastISel::TargetSelectInstruction(
const Instruction *I) {
2890 return SelectLoad(I);
2892 return SelectStore(I);
2893 case Instruction::Br:
2894 return SelectBranch(I);
2895 case Instruction::IndirectBr:
2896 return SelectIndirectBr(I);
2897 case Instruction::ICmp:
2898 case Instruction::FCmp:
2899 return SelectCmp(I);
2900 case Instruction::FPExt:
2901 return SelectFPExt(I);
2902 case Instruction::FPTrunc:
2903 return SelectFPTrunc(I);
2904 case Instruction::SIToFP:
2905 return SelectIToFP(I,
true);
2906 case Instruction::UIToFP:
2907 return SelectIToFP(I,
false);
2908 case Instruction::FPToSI:
2909 return SelectFPToI(I,
true);
2910 case Instruction::FPToUI:
2911 return SelectFPToI(I,
false);
2912 case Instruction::Add:
2913 return SelectBinaryIntOp(I,
ISD::ADD);
2915 return SelectBinaryIntOp(I,
ISD::OR);
2916 case Instruction::Sub:
2917 return SelectBinaryIntOp(I,
ISD::SUB);
2918 case Instruction::FAdd:
2920 case Instruction::FSub:
2922 case Instruction::FMul:
2924 case Instruction::SDiv:
2925 return SelectDiv(I,
true);
2926 case Instruction::UDiv:
2927 return SelectDiv(I,
false);
2928 case Instruction::SRem:
2929 return SelectRem(I,
true);
2930 case Instruction::URem:
2931 return SelectRem(I,
false);
2934 return SelectIntrinsicCall(*II);
2935 return SelectCall(I);
2937 return SelectSelect(I);
2939 return SelectRet(I);
2940 case Instruction::Trunc:
2941 return SelectTrunc(I);
2942 case Instruction::ZExt:
2943 case Instruction::SExt:
2944 return SelectIntExt(I);
2945 case Instruction::Shl:
2947 case Instruction::LShr:
2949 case Instruction::AShr:
2961 const struct FoldableLoadExtendsStruct {
2963 uint8_t ExpectedImm;
2965 uint8_t ExpectedVT : 7;
2966 } FoldableLoadExtends[] = {
2969 { { ARM::ANDri, ARM::t2ANDri }, 255, 1,
MVT::i8 },
2979 bool ARMFastISel::tryToFoldLoadIntoMI(
MachineInstr *MI,
unsigned OpNo,
2983 if (!isLoadTypeLegal(LI->
getType(), VT))
2998 if (FoldableLoadExtends[i].Opc[isThumb2] == MI->
getOpcode() &&
2999 (uint64_t)FoldableLoadExtends[i].ExpectedImm == Imm &&
3002 isZExt = FoldableLoadExtends[i].isZExt;
3005 if (!Found)
return false;
3009 if (!ARMComputeAddress(LI->
getOperand(0), Addr))
return false;
3012 if (!ARMEmitLoad(VT, ResultReg, Addr, LI->
getAlignment(), isZExt,
false))
3018 unsigned ARMFastISel::ARMLowerPICELF(
const GlobalValue *GV,
3019 unsigned Align,
MVT VT) {
3023 unsigned Idx = MCP.getConstantPoolIndex(CPV, Align);
3026 unsigned DestReg1 = createResultReg(TLI.getRegClassFor(VT));
3029 DestReg1 = constrainOperandRegClass(
TII.get(ARM::t2LDRpci), DestReg1, 0);
3030 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
3031 TII.get(ARM::t2LDRpci), DestReg1)
3032 .addConstantPoolIndex(Idx));
3033 Opc = UseGOTOFF ? ARM::t2ADDrr : ARM::t2LDRs;
3036 DestReg1 = constrainOperandRegClass(
TII.get(ARM::LDRcp), DestReg1, 0);
3037 AddOptionalDefs(
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt,
3038 DL,
TII.get(ARM::LDRcp), DestReg1)
3039 .addConstantPoolIndex(Idx).
addImm(0));
3040 Opc = UseGOTOFF ? ARM::ADDrr : ARM::LDRrs;
3044 if (GlobalBaseReg == 0) {
3045 GlobalBaseReg =
MRI.createVirtualRegister(TLI.getRegClassFor(VT));
3046 AFI->setGlobalBaseReg(GlobalBaseReg);
3049 unsigned DestReg2 = createResultReg(TLI.getRegClassFor(VT));
3050 DestReg2 = constrainOperandRegClass(
TII.get(Opc), DestReg2, 0);
3051 DestReg1 = constrainOperandRegClass(
TII.get(Opc), DestReg1, 1);
3054 DL,
TII.get(Opc), DestReg2)
3059 AddOptionalDefs(MIB);
3064 bool ARMFastISel::FastLowerArguments() {
3065 if (!FuncInfo.CanLowerReturn)
3088 I != E; ++
I, ++Idx) {
3101 EVT ArgVT = TLI.getValueType(ArgTy);
3102 if (!ArgVT.
isSimple())
return false;
3115 ARM::R0, ARM::R1,
ARM::R2, ARM::R3
3121 I != E; ++
I, ++Idx) {
3122 unsigned SrcReg = GPRArgRegs[Idx];
3123 unsigned DstReg = FuncInfo.MF->addLiveIn(SrcReg, RC);
3127 unsigned ResultReg = createResultReg(RC);
3130 UpdateValueMap(I, ResultReg);
3143 bool UseFastISel =
false;
3154 return new ARMFastISel(funcInfo, libInfo);
unsigned getAlignment() const
unsigned getFrameRegister(const MachineFunction &MF) const
void setFrameAddressIsTaken(bool T)
cl::opt< bool > EnableARMLongCalls
const Value * getCalledValue() const
void push_back(const T &Elt)
The memory access reads data.
Type * getIndexedType() const
Abstract base class of comparison instructions.
The memory access writes data.
LLVMContext & getContext() const
uint64_t getZExtValue() const
Get zero extended value.
Sign extended before/after call.
LocInfo getLocInfo() const
Force argument to be passed in register.
Intrinsic::ID getIntrinsicID() const
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions. Register definitions always occur...
static unsigned getSORegOpc(ShiftOpc ShOp, unsigned Imm)
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getNumOperands() const
Nested function static chain.
ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI.
static bool isVirtualRegister(unsigned Reg)
static PointerType * getInt32PtrTy(LLVMContext &C, unsigned AS=0)
Predicate getInversePredicate() const
Return the inverse of the instruction's predicate.
bool isPredicable(QueryType Type=AllInBundle) const
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
0 1 0 0 True if ordered and less than
unsigned getSizeInBits() const
Externally visible function.
bool isDoubleTy() const
isDoubleTy - 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
const Function * getParent() const
Return the enclosing method, or null if none.
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
bool isThumb1Only() const
unsigned getValNo() const
LoopInfoBase< BlockT, LoopT > * LI
CallingConv::ID getCallingConv() const
static MachinePointerInfo getFixedStack(int FI, int64_t offset=0)
1 0 0 1 True if unordered or equal
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
static const MachineInstrBuilder & AddDefaultPred(const MachineInstrBuilder &MIB)
const HexagonInstrInfo * TII
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"), clEnumValEnd))
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
static ARMCC::CondCodes getComparePred(CmpInst::Predicate Pred)
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
#define llvm_unreachable(msg)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
0 1 0 1 True if ordered and less than or equal
Abstract Stack Frame Information.
ID
LLVM Calling Convention Representation.
const MachineInstrBuilder & addImm(int64_t Val) const
Hidden pointer to structure to return.
unsigned getNumOperands() const
uint64_t getZExtValue() const
Return the zero extended value.
unsigned getLocReg() const
size_t array_lengthof(T(&)[N])
Find the length of an array.
Simple integer binary arithmetic operators.
static int getT2SOImmVal(unsigned Arg)
BasicBlock * getSuccessor(unsigned i) const
static int getFP32Imm(const APInt &Imm)
void setOrigAlign(unsigned A)
Type * getElementType() const
This class represents a truncation of integer types.
unsigned getKillRegState(bool B)
uint64_t getElementOffset(unsigned Idx) const
User::const_op_iterator arg_iterator
void GetReturnInfo(Type *ReturnType, AttributeSet attr, SmallVectorImpl< ISD::OutputArg > &Outs, const TargetLowering &TLI)
unsigned NoFramePointerElim
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
Simple binary floating point operators.
const MCRegisterClass & getRegClass(unsigned i) const
Returns the register class associated with the enumeration value. See class MCOperandInfo.
LLVM Constant Representation.
PointerType * getType() const
bool isVector() const
isVector - Return true if this is a vector value type.
bool hasHiddenVisibility() const
int64_t getSExtValue() const
Get sign extended value.
const MachineOperand & getOperand(unsigned i) const
bool isFloatTy() const
isFloatTy - Return true if this is 'float', a 32-bit IEEE fp type.
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
Value * getRawDest() const
TRAP - Trapping instruction.
Value * getOperand(unsigned i) const
Zero extended before/after call.
0 1 1 1 True if ordered (no nans)
Predicate getPredicate() const
Return the predicate for this instruction.
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
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
0 0 1 0 True if ordered and greater than
bool isTargetNaCl() const
static const MachineInstrBuilder & AddDefaultCC(const MachineInstrBuilder &MIB)
static int getFP64Imm(const APInt &Imm)
Class for constant integers.
const STC & getSubtarget() const
1 1 0 0 True if unordered or less than
Instr is a return instruction.
CCValAssign - Represent assignment of one arg/retval to a location.
Value * getLength() const
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
const MachineInstrBuilder & addFrameIndex(int Idx) const
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
AttributeSet getAttributes() const
Return the attribute list for this Function.
Class for arbitrary precision integers.
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
static int getSOImmVal(unsigned Arg)
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned char TargetFlags=0) const
PointerType * getType() const
getType - Global values are always pointers.
Value * getCondition() const
static IntegerType * getInt32Ty(LLVMContext &C)
unsigned greater or equal
unsigned getAlignment() const
bool isTargetLinux() const
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned char TargetFlags=0) const
ImmutableCallSite - establish a view to a call site for examination.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
0 1 1 0 True if ordered and operands are unequal
const TargetMachine & getTarget() const
1 0 1 0 True if unordered or greater than
bool hasLocalLinkage() const
const APFloat & getValueAPF() const
Value * getRawSource() const
unsigned getReg() const
getReg - Returns the register number.
bool isUnsigned() const
Determine if this instruction is using an unsigned comparison.
const MachineInstrBuilder & addFPImm(const ConstantFP *Val) const
const uint16_t * ImplicitDefs
FastISel * createFastISel(FunctionLoweringInfo &funcInfo, const TargetLibraryInfo *libInfo)
0 0 0 1 True if ordered and equal
LLVM Value Representation.
1 0 1 1 True if unordered, greater than, or equal
unsigned getOpcode() const
getOpcode() returns a member of one of the enums like Instruction::Add.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction. Note that variadic (isVari...
unsigned getDestAddressSpace() const
const MCOperandInfo * OpInfo
bool isUInt< 16 >(uint64_t x)
const MCRegisterInfo & MRI
bool hasOptionalDef(QueryType Type=IgnoreBundle) const
unsigned getLocMemOffset() const
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
int64_t getSExtValue() const
Return the sign extended value.
iterator find(const KeyT &Val)
0 0 1 1 True if ordered and greater than or equal
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
unsigned getSourceAddressSpace() const
static const uint16_t GPRArgRegs[]
const BasicBlock * getParent() const
static ARMConstantPoolConstant * Create(const Constant *C, unsigned ID)
INITIALIZE_PASS(GlobalMerge,"global-merge","Global Merge", false, false) bool GlobalMerge const DataLayout * TD
static const MachineInstrBuilder & AddDefaultT1CC(const MachineInstrBuilder &MIB, bool isDead=false)
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.
gep_type_iterator gep_type_begin(const User *GEP)
bool contains(unsigned Reg) const