36 #define DEBUG_TYPE "aarch64-isel" 42 #define GET_GLOBALISEL_PREDICATE_BITSET 43 #include "AArch64GenGlobalISel.inc" 44 #undef GET_GLOBALISEL_PREDICATE_BITSET 73 ComplexRendererFns selectAddrModeUnscaled8(
MachineOperand &Root)
const {
74 return selectAddrModeUnscaled(Root, 1);
76 ComplexRendererFns selectAddrModeUnscaled16(
MachineOperand &Root)
const {
77 return selectAddrModeUnscaled(Root, 2);
79 ComplexRendererFns selectAddrModeUnscaled32(
MachineOperand &Root)
const {
80 return selectAddrModeUnscaled(Root, 4);
82 ComplexRendererFns selectAddrModeUnscaled64(
MachineOperand &Root)
const {
83 return selectAddrModeUnscaled(Root, 8);
85 ComplexRendererFns selectAddrModeUnscaled128(
MachineOperand &Root)
const {
86 return selectAddrModeUnscaled(Root, 16);
92 ComplexRendererFns selectAddrModeIndexed(
MachineOperand &Root)
const {
93 return selectAddrModeIndexed(Root, Width / 8);
100 unsigned char OpFlags)
const;
108 #define GET_GLOBALISEL_PREDICATES_DECL 109 #include "AArch64GenGlobalISel.inc" 110 #undef GET_GLOBALISEL_PREDICATES_DECL 114 #define GET_GLOBALISEL_TEMPORARIES_DECL 115 #include "AArch64GenGlobalISel.inc" 116 #undef GET_GLOBALISEL_TEMPORARIES_DECL 121 #define GET_GLOBALISEL_IMPL 122 #include "AArch64GenGlobalISel.inc" 123 #undef GET_GLOBALISEL_IMPL 125 AArch64InstructionSelector::AArch64InstructionSelector(
129 TRI(*STI.getRegisterInfo()), RBI(RBI),
131 #include
"AArch64GenGlobalISel.inc" 134 #include
"AArch64GenGlobalISel.inc" 144 bool GetAllRegSet =
false) {
145 if (RB.
getID() == AArch64::GPRRegBankID) {
147 return GetAllRegSet ? &AArch64::GPR32allRegClass
148 : &AArch64::GPR32RegClass;
150 return GetAllRegSet ? &AArch64::GPR64allRegClass
151 : &AArch64::GPR64RegClass;
155 if (RB.
getID() == AArch64::FPRRegBankID) {
157 return &AArch64::FPR16RegClass;
159 return &AArch64::FPR32RegClass;
161 return &AArch64::FPR64RegClass;
163 return &AArch64::FPR128RegClass;
190 LLVM_DEBUG(
dbgs() <<
"Generic inst non-reg operands are unsupported\n");
198 if (!TargetRegisterInfo::isVirtualRegister(MO.getReg())) {
199 LLVM_DEBUG(
dbgs() <<
"Generic inst has physical register operand\n");
209 if (PrevOpBank && OpBank != PrevOpBank) {
210 LLVM_DEBUG(
dbgs() <<
"Generic inst operands have different banks\n");
225 case AArch64::GPRRegBankID:
227 switch (GenericOpc) {
228 case TargetOpcode::G_SHL:
229 return AArch64::LSLVWr;
230 case TargetOpcode::G_LSHR:
231 return AArch64::LSRVWr;
232 case TargetOpcode::G_ASHR:
233 return AArch64::ASRVWr;
237 }
else if (OpSize == 64) {
238 switch (GenericOpc) {
239 case TargetOpcode::G_GEP:
240 return AArch64::ADDXrr;
241 case TargetOpcode::G_SHL:
242 return AArch64::LSLVXr;
243 case TargetOpcode::G_LSHR:
244 return AArch64::LSRVXr;
245 case TargetOpcode::G_ASHR:
246 return AArch64::ASRVXr;
252 case AArch64::FPRRegBankID:
255 switch (GenericOpc) {
256 case TargetOpcode::G_FADD:
257 return AArch64::FADDSrr;
258 case TargetOpcode::G_FSUB:
259 return AArch64::FSUBSrr;
260 case TargetOpcode::G_FMUL:
261 return AArch64::FMULSrr;
262 case TargetOpcode::G_FDIV:
263 return AArch64::FDIVSrr;
268 switch (GenericOpc) {
269 case TargetOpcode::G_FADD:
270 return AArch64::FADDDrr;
271 case TargetOpcode::G_FSUB:
272 return AArch64::FSUBDrr;
273 case TargetOpcode::G_FMUL:
274 return AArch64::FMULDrr;
275 case TargetOpcode::G_FDIV:
276 return AArch64::FDIVDrr;
277 case TargetOpcode::G_OR:
278 return AArch64::ORRv8i8;
295 const bool isStore = GenericOpc == TargetOpcode::G_STORE;
297 case AArch64::GPRRegBankID:
300 return isStore ? AArch64::STRBBui : AArch64::LDRBBui;
302 return isStore ? AArch64::STRHHui : AArch64::LDRHHui;
304 return isStore ? AArch64::STRWui : AArch64::LDRWui;
306 return isStore ? AArch64::STRXui : AArch64::LDRXui;
309 case AArch64::FPRRegBankID:
312 return isStore ? AArch64::STRBui : AArch64::LDRBui;
314 return isStore ? AArch64::STRHui : AArch64::LDRHui;
316 return isStore ? AArch64::STRSui : AArch64::LDRSui;
318 return isStore ? AArch64::STRDui : AArch64::LDRDui;
335 .
addUse(CopyReg, 0, AArch64::hsub);
349 if (TargetRegisterInfo::isPhysicalRegister(DstReg)) {
351 !TargetRegisterInfo::isPhysicalRegister(SrcReg)) {
354 MRI.
getType(SrcReg), RegBank, RBI,
true);
355 if (SrcRC == &AArch64::GPR32allRegClass)
358 assert(I.
isCopy() &&
"Generic operators do not allow physical registers");
365 const unsigned SrcSize = RBI.getSizeInBits(SrcReg, MRI, TRI);
367 assert((!TargetRegisterInfo::isPhysicalRegister(SrcReg) || I.
isCopy()) &&
368 "No phys reg on generic operators");
370 (DstSize == SrcSize ||
373 (TargetRegisterInfo::isPhysicalRegister(SrcReg) &&
374 DstSize <= RBI.getSizeInBits(SrcReg, MRI, TRI)) ||
378 (((DstSize + 31) / 32 == (SrcSize + 31) / 32) && DstSize > SrcSize)) &&
379 "Copy with different width?!");
380 assert((DstSize <= 64 || RegBank.
getID() == AArch64::FPRRegBankID) &&
381 "GPRs cannot get more than 64-bit width values");
384 MRI.
getType(DstReg), RegBank, RBI,
true);
386 LLVM_DEBUG(
dbgs() <<
"Unexpected bitcast size " << DstSize <<
'\n');
390 if (!TargetRegisterInfo::isPhysicalRegister(SrcReg)) {
397 SrcRC = getRegClassForTypeOnBank(MRI.
getType(SrcReg), *RB, RBI,
true);
400 if (RC == &AArch64::GPR32allRegClass && SrcRC == &AArch64::FPR16RegClass) {
403 TII.
get(AArch64::SUBREG_TO_REG))
410 }
else if (RC == &AArch64::FPR16RegClass &&
411 SrcRC == &AArch64::GPR32allRegClass) {
419 if (!RBI.constrainGenericRegister(DstReg, *RC, MRI)) {
439 switch (GenericOpc) {
440 case TargetOpcode::G_SITOFP:
441 return AArch64::SCVTFUWSri;
442 case TargetOpcode::G_UITOFP:
443 return AArch64::UCVTFUWSri;
444 case TargetOpcode::G_FPTOSI:
445 return AArch64::FCVTZSUWSr;
446 case TargetOpcode::G_FPTOUI:
447 return AArch64::FCVTZUUWSr;
452 switch (GenericOpc) {
453 case TargetOpcode::G_SITOFP:
454 return AArch64::SCVTFUXSri;
455 case TargetOpcode::G_UITOFP:
456 return AArch64::UCVTFUXSri;
457 case TargetOpcode::G_FPTOSI:
458 return AArch64::FCVTZSUWDr;
459 case TargetOpcode::G_FPTOUI:
460 return AArch64::FCVTZUUWDr;
470 switch (GenericOpc) {
471 case TargetOpcode::G_SITOFP:
472 return AArch64::SCVTFUWDri;
473 case TargetOpcode::G_UITOFP:
474 return AArch64::UCVTFUWDri;
475 case TargetOpcode::G_FPTOSI:
476 return AArch64::FCVTZSUXSr;
477 case TargetOpcode::G_FPTOUI:
478 return AArch64::FCVTZUUXSr;
483 switch (GenericOpc) {
484 case TargetOpcode::G_SITOFP:
485 return AArch64::SCVTFUXDri;
486 case TargetOpcode::G_UITOFP:
487 return AArch64::UCVTFUXDri;
488 case TargetOpcode::G_FPTOSI:
489 return AArch64::FCVTZSUXDr;
490 case TargetOpcode::G_FPTOUI:
491 return AArch64::FCVTZUUXDr;
508 case CmpInst::ICMP_NE:
510 case CmpInst::ICMP_EQ:
512 case CmpInst::ICMP_SGT:
514 case CmpInst::ICMP_SGE:
516 case CmpInst::ICMP_SLT:
518 case CmpInst::ICMP_SLE:
520 case CmpInst::ICMP_UGT:
522 case CmpInst::ICMP_UGE:
524 case CmpInst::ICMP_ULT:
526 case CmpInst::ICMP_ULE:
538 case CmpInst::FCMP_OEQ:
541 case CmpInst::FCMP_OGT:
544 case CmpInst::FCMP_OGE:
547 case CmpInst::FCMP_OLT:
550 case CmpInst::FCMP_OLE:
553 case CmpInst::FCMP_ONE:
557 case CmpInst::FCMP_ORD:
560 case CmpInst::FCMP_UNO:
563 case CmpInst::FCMP_UEQ:
567 case CmpInst::FCMP_UGT:
570 case CmpInst::FCMP_UGE:
573 case CmpInst::FCMP_ULT:
576 case CmpInst::FCMP_ULE:
579 case CmpInst::FCMP_UNE:
585 bool AArch64InstructionSelector::selectCompareBranch(
591 if (CCMI->
getOpcode() == TargetOpcode::G_TRUNC)
593 if (CCMI->
getOpcode() != TargetOpcode::G_ICMP)
602 if (!RHSImm || *RHSImm != 0)
606 if (RB.
getID() != AArch64::GPRRegBankID)
610 if (Pred != CmpInst::ICMP_NE && Pred != CmpInst::ICMP_EQ)
616 CBOpc = (Pred == CmpInst::ICMP_EQ ? AArch64::CBZW : AArch64::CBNZW);
617 else if (CmpWidth == 64)
618 CBOpc = (Pred == CmpInst::ICMP_EQ ? AArch64::CBZX : AArch64::CBNZX);
631 bool AArch64InstructionSelector::selectVaStartAAPCS(
636 bool AArch64InstructionSelector::selectVaStartDarwin(
663 void AArch64InstructionSelector::materializeLargeCMVal(
670 auto MovZ = MIB.
buildInstr(AArch64::MOVZXi, &AArch64::GPR64RegClass);
674 MovZ->addOperand(MF, MachineOperand::CreateImm(0));
677 auto BuildMovK = [&](
unsigned SrcReg,
unsigned char Flags,
unsigned Offset,
678 unsigned ForceDstReg) {
679 unsigned DstReg = ForceDstReg
683 if (
auto *GV = dyn_cast<GlobalValue>(V)) {
684 MovI->
addOperand(MF, MachineOperand::CreateGA(
685 GV, MovZ->getOperand(1).getOffset(), Flags));
688 MF, MachineOperand::CreateBA(cast<BlockAddress>(V),
689 MovZ->getOperand(1).getOffset(), Flags));
691 MovI->addOperand(MF, MachineOperand::CreateImm(Offset));
695 unsigned DstReg = BuildMovK(MovZ->getOperand(0).getReg(),
702 bool AArch64InstructionSelector::select(
MachineInstr &I,
716 if (Opcode == TargetOpcode::LOAD_STACK_GUARD)
719 if (Opcode == TargetOpcode::PHI || Opcode == TargetOpcode::G_PHI) {
724 if (TargetRegisterInfo::isPhysicalRegister(DefReg)) {
725 DefRC =
TRI.getRegClass(DefReg);
737 DefRC = getRegClassForTypeOnBank(DefTy, RB, RBI);
758 dbgs() <<
"Generic instruction has unexpected implicit operands\n");
762 if (selectImpl(I, CoverageInfo))
769 case TargetOpcode::G_BRCOND: {
775 <<
", expected at most 32-bits");
782 if (selectCompareBranch(I, MF, MRI))
794 case TargetOpcode::G_BRINDIRECT: {
799 case TargetOpcode::G_FCONSTANT:
800 case TargetOpcode::G_CONSTANT: {
801 const bool isFP = Opcode == TargetOpcode::G_FCONSTANT;
803 const LLT s32 = LLT::scalar(32);
804 const LLT s64 = LLT::scalar(64);
805 const LLT p0 = LLT::pointer(0, 64);
814 if (Ty != s32 && Ty != s64) {
816 <<
" constant, expected: " << s32 <<
" or " << s64
821 if (RB.
getID() != AArch64::FPRRegBankID) {
823 <<
" constant on bank: " << RB
824 <<
", expected: FPR\n");
836 <<
" constant, expected: " << s32 <<
", " << s64
837 <<
", or " << p0 <<
'\n');
841 if (RB.
getID() != AArch64::GPRRegBankID) {
843 <<
" constant on bank: " << RB
844 <<
", expected: GPR\n");
849 const unsigned MovOpc =
850 DefSize == 32 ? AArch64::MOVi32imm : AArch64::MOVi64imm;
856 DefSize == 32 ? AArch64::GPR32RegClass : AArch64::GPR64RegClass;
858 DefSize == 32 ? AArch64::FPR32RegClass : AArch64::FPR64RegClass;
865 TII.get(AArch64::COPY))
870 LLVM_DEBUG(
dbgs() <<
"Failed to constrain G_FCONSTANT def operand\n");
889 case TargetOpcode::G_EXTRACT: {
899 I.
setDesc(
TII.get(SrcSize == 64 ? AArch64::UBFMXri : AArch64::UBFMWri));
905 "unexpected G_EXTRACT types");
911 TII.get(AArch64::COPY))
913 .addUse(DstReg, 0, AArch64::sub_32);
915 AArch64::GPR32RegClass,
MRI);
921 case TargetOpcode::G_INSERT: {
930 I.
setDesc(
TII.get(DstSize == 64 ? AArch64::BFMXri : AArch64::BFMWri));
938 "unexpected G_INSERT types");
944 TII.get(AArch64::SUBREG_TO_REG))
948 .addImm(AArch64::sub_32);
950 AArch64::GPR32RegClass,
MRI);
955 case TargetOpcode::G_FRAME_INDEX: {
957 if (Ty != LLT::pointer(0, 64)) {
959 <<
", expected: " << LLT::pointer(0, 64) <<
'\n');
971 case TargetOpcode::G_GLOBAL_VALUE: {
973 if (GV->isThreadLocal()) {
977 unsigned char OpFlags = STI.ClassifyGlobalReference(GV,
TM);
983 materializeLargeCMVal(I, GV, OpFlags);
996 case TargetOpcode::G_LOAD:
997 case TargetOpcode::G_STORE: {
1000 if (PtrTy != LLT::pointer(0, 64)) {
1002 <<
", expected: " << LLT::pointer(0, 64) <<
'\n');
1007 if (MemOp.getOrdering() != AtomicOrdering::NotAtomic) {
1011 unsigned MemSizeInBits = MemOp.getSize() * 8;
1016 if (Opcode == TargetOpcode::G_LOAD && MemOp.isVolatile())
1024 "Load/Store pointer operand isn't a GPR");
1026 "Load/Store pointer operand isn't a pointer");
1032 const unsigned NewOpc =
1043 if (PtrMI->getOpcode() == TargetOpcode::G_GEP) {
1045 int64_t Imm = *COff;
1046 const unsigned Size = MemSizeInBits / 8;
1047 const unsigned Scale =
Log2_32(Size);
1048 if ((Imm & (Size - 1)) == 0 && Imm >= 0 && Imm < (0x1000 << Scale)) {
1049 unsigned Ptr2Reg = PtrMI->getOperand(1).getReg();
1052 Offset = Imm /
Size;
1059 if (!Offset && PtrMI->getOpcode() == TargetOpcode::G_FRAME_INDEX)
1062 I.
addOperand(MachineOperand::CreateImm(Offset));
1066 if (*CVal == 0 && Opcode == TargetOpcode::G_STORE) {
1069 else if (I.
getOpcode() == AArch64::STRXui)
1077 case TargetOpcode::G_SMULH:
1078 case TargetOpcode::G_UMULH: {
1086 if (RB.
getID() != AArch64::GPRRegBankID) {
1087 LLVM_DEBUG(
dbgs() <<
"G_[SU]MULH on bank: " << RB <<
", expected: GPR\n");
1091 if (Ty != LLT::scalar(64)) {
1093 <<
", expected: " << LLT::scalar(64) <<
'\n');
1097 unsigned NewOpc = I.
getOpcode() == TargetOpcode::G_SMULH ? AArch64::SMULHrr
1105 case TargetOpcode::G_FADD:
1106 case TargetOpcode::G_FSUB:
1107 case TargetOpcode::G_FMUL:
1108 case TargetOpcode::G_FDIV:
1110 case TargetOpcode::G_OR:
1111 case TargetOpcode::G_SHL:
1112 case TargetOpcode::G_LSHR:
1113 case TargetOpcode::G_ASHR:
1114 case TargetOpcode::G_GEP: {
1136 case TargetOpcode::G_PTR_MASK: {
1138 if (Align >= 64 || Align == 0)
1147 case TargetOpcode::G_PTRTOINT:
1148 case TargetOpcode::G_TRUNC: {
1160 dbgs() <<
"G_TRUNC/G_PTRTOINT input/output on different banks\n");
1164 if (DstRB.
getID() == AArch64::GPRRegBankID) {
1166 getRegClassForTypeOnBank(DstTy, DstRB, RBI);
1171 getRegClassForTypeOnBank(SrcTy, SrcRB, RBI);
1177 LLVM_DEBUG(
dbgs() <<
"Failed to constrain G_TRUNC/G_PTRTOINT\n");
1181 if (DstRC == SrcRC) {
1183 }
else if (Opcode == TargetOpcode::G_TRUNC && DstTy == LLT::scalar(32) &&
1184 SrcTy == LLT::scalar(64)) {
1187 }
else if (DstRC == &AArch64::GPR32RegClass &&
1188 SrcRC == &AArch64::GPR64RegClass) {
1192 dbgs() <<
"Unhandled mismatched classes in G_TRUNC/G_PTRTOINT\n");
1198 }
else if (DstRB.
getID() == AArch64::FPRRegBankID) {
1199 if (DstTy == LLT::vector(4, 16) && SrcTy == LLT::vector(4, 32)) {
1209 case TargetOpcode::G_ANYEXT: {
1214 if (RBDst.
getID() != AArch64::GPRRegBankID) {
1216 <<
", expected: GPR\n");
1221 if (RBSrc.
getID() != AArch64::GPRRegBankID) {
1223 <<
", expected: GPR\n");
1230 LLVM_DEBUG(
dbgs() <<
"G_ANYEXT operand has no size, not a gvreg?\n");
1234 if (DstSize != 64 && DstSize > 32) {
1236 <<
", expected: 32 or 64\n");
1247 .
addImm(AArch64::sub_32);
1253 case TargetOpcode::G_ZEXT:
1254 case TargetOpcode::G_SEXT: {
1258 const bool isSigned = Opcode == TargetOpcode::G_SEXT;
1263 if (RB.
getID() != AArch64::GPRRegBankID) {
1265 <<
", expected: GPR\n");
1270 if (DstTy == LLT::scalar(64)) {
1278 const unsigned SrcXReg =
1284 .
addImm(AArch64::sub_32);
1286 const unsigned NewOpc = isSigned ? AArch64::SBFMXri : AArch64::UBFMXri;
1291 .
addImm(SrcTy.getSizeInBits() - 1);
1293 const unsigned NewOpc = isSigned ? AArch64::SBFMWri : AArch64::UBFMWri;
1298 .
addImm(SrcTy.getSizeInBits() - 1);
1309 case TargetOpcode::G_SITOFP:
1310 case TargetOpcode::G_UITOFP:
1311 case TargetOpcode::G_FPTOSI:
1312 case TargetOpcode::G_FPTOUI: {
1316 if (NewOpc == Opcode)
1326 case TargetOpcode::G_INTTOPTR:
1331 case TargetOpcode::G_BITCAST:
1340 case TargetOpcode::G_SELECT: {
1343 <<
", expected: " << LLT::scalar(1) <<
'\n');
1351 unsigned CSelOpc = 0;
1353 if (Ty == LLT::scalar(32)) {
1354 CSelOpc = AArch64::CSELWr;
1355 }
else if (Ty == LLT::scalar(64) || Ty == LLT::pointer(0, 64)) {
1356 CSelOpc = AArch64::CSELXr;
1363 .addDef(AArch64::WZR)
1379 case TargetOpcode::G_ICMP: {
1380 if (Ty != LLT::scalar(32)) {
1382 <<
", expected: " << LLT::scalar(32) <<
'\n');
1386 unsigned CmpOpc = 0;
1390 if (CmpTy == LLT::scalar(32)) {
1391 CmpOpc = AArch64::SUBSWrr;
1392 ZReg = AArch64::WZR;
1393 }
else if (CmpTy == LLT::scalar(64) || CmpTy.
isPointer()) {
1394 CmpOpc = AArch64::SUBSXrr;
1395 ZReg = AArch64::XZR;
1415 .addUse(AArch64::WZR)
1426 case TargetOpcode::G_FCMP: {
1427 if (Ty != LLT::scalar(32)) {
1429 <<
", expected: " << LLT::scalar(32) <<
'\n');
1433 unsigned CmpOpc = 0;
1435 if (CmpTy == LLT::scalar(32)) {
1436 CmpOpc = AArch64::FCMPSrr;
1437 }
else if (CmpTy == LLT::scalar(64)) {
1438 CmpOpc = AArch64::FCMPDrr;
1454 unsigned Def1Reg = DefReg;
1488 case TargetOpcode::G_VASTART:
1489 return STI.isTargetDarwin() ? selectVaStartDarwin(I, MF, MRI)
1490 : selectVaStartAAPCS(I, MF, MRI);
1491 case TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS:
1500 case TargetOpcode::G_IMPLICIT_DEF: {
1501 I.
setDesc(
TII.get(TargetOpcode::IMPLICIT_DEF));
1506 getRegClassForTypeOnBank(DstTy, DstRB, RBI);
1510 case TargetOpcode::G_BLOCK_ADDR: {
1537 AArch64InstructionSelector::selectArithImmed(
MachineOperand &Root)
const {
1553 else if (Root.
isReg()) {
1555 if (Def->
getOpcode() != TargetOpcode::G_CONSTANT)
1566 if (Immed >> 12 == 0) {
1568 }
else if ((Immed & 0xfff) == 0 && Immed >> 24 == 0) {
1570 Immed = Immed >> 12;
1587 AArch64InstructionSelector::selectAddrModeUnscaled(
MachineOperand &Root,
1588 unsigned Size)
const {
1595 if (!isBaseWithConstantOffset(Root, MRI))
1603 if (!OffImm.
isReg())
1606 if (!RHS || RHS->
getOpcode() != TargetOpcode::G_CONSTANT)
1615 if ((RHSC & (Size - 1)) == 0 && RHSC >= 0 && RHSC < (0x1000 <<
Log2_32(Size)))
1617 if (RHSC >= -256 && RHSC < 256) {
1631 AArch64InstructionSelector::selectAddrModeIndexed(
MachineOperand &Root,
1632 unsigned Size)
const {
1643 if (RootDef->
getOpcode() == TargetOpcode::G_FRAME_INDEX) {
1650 if (isBaseWithConstantOffset(Root, MRI)) {
1655 if (LHSDef && RHSDef) {
1657 unsigned Scale =
Log2_32(Size);
1658 if ((RHSC & (Size - 1)) == 0 && RHSC >= 0 && RHSC < (0x1000 << Scale)) {
1659 if (LHSDef->
getOpcode() == TargetOpcode::G_FRAME_INDEX)
1675 if (selectAddrModeUnscaled(Root, Size).hasValue())
1687 assert(MI.
getOpcode() == TargetOpcode::G_CONSTANT &&
"Expected G_CONSTANT");
1689 assert(CstVal &&
"Expected constant value");
1690 MIB.
addImm(CstVal.getValue());
1698 return new AArch64InstructionSelector(TM, Subtarget, RBI);
static bool selectFP16CopyFromGPR32(MachineInstr &I, const TargetInstrInfo &TII, MachineRegisterInfo &MRI, unsigned SrcReg)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
MO_G3 - A symbol operand with this flag (granule 3) represents the high 16-bits of a 64-bit address...
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
uint64_t getZExtValue() const
Get zero extended value.
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
MachineBasicBlock * getMBB() const
Compute iterated dominance frontiers using a linear time algorithm.
MO_PAGE - A symbol operand with this flag represents the pc-relative offset of the 4K page containing...
void setTargetFlags(unsigned F)
int getVarArgsStackIndex() const
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
static CondCode getInvertedCondCode(CondCode Code)
unsigned getReg() const
getReg - Returns the register number.
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
unsigned const TargetRegisterInfo * TRI
MO_G0 - A symbol operand with this flag (granule 0) represents the bits 0-15 of a 64-bit address...
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned char TargetFlags=0) const
iterator_range< mop_iterator > operands()
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
unsigned getBitWidth() const
getBitWidth - Return the bitwidth of this constant.
const TargetRegisterClass * getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
MO_G2 - A symbol operand with this flag (granule 2) represents the bits 32-47 of a 64-bit address...
This file declares the targeting of the RegisterBankInfo class for AArch64.
bool isIntrinsicID() const
Holds all the information related to register banks.
const HexagonInstrInfo * TII
const ConstantFP * getFPImm() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
static StringRef getName(Value *V)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
MO_GOT - This flag indicates that a symbol operand represents the address of the GOT entry for the sy...
const RegClassOrRegBank & getRegClassOrRegBank(unsigned Reg) const
Return the register bank or register class of Reg.
static bool isStore(int Opcode)
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
static unsigned getShifterImm(AArch64_AM::ShiftExtendType ST, unsigned Imm)
getShifterImm - Encode the shift type and amount: imm: 6-bit shift amount shifter: 000 ==> lsl 001 ==...
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
TargetInstrInfo - Interface to description of machine instruction set.
static unsigned selectBinaryOp(unsigned GenericOpc, unsigned RegBankID, unsigned OpSize)
Select the AArch64 opcode for the basic binary operation GenericOpc (such as G_OR or G_SDIV)...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
Control flow instructions. These all have token chains.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
MO_G1 - A symbol operand with this flag (granule 1) represents the bits 16-31 of a 64-bit address...
unsigned const MachineRegisterInfo * MRI
static unsigned selectLoadStoreUIOp(unsigned GenericOpc, unsigned RegBankID, unsigned OpSize)
Select the AArch64 opcode for the G_LOAD or G_STORE operation GenericOpc, appropriate for the (value)...
static unsigned selectFPConvOpc(unsigned GenericOpc, LLT DstTy, LLT SrcTy)
const GlobalValue * getGlobal() const
bool isCImm() const
isCImm - Test if this is a MO_CImmediate operand.
bool isExactlyValue(double V) const
We don't rely on operator== working on double values, as it returns true for things that are clearly ...
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setImm(int64_t immVal)
self_iterator getIterator()
const MachineInstrBuilder & addFrameIndex(int Idx) const
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwises returns null...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
StringRef getName(unsigned Opcode) const
Returns the name for the instructions with the given opcode.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
#define GET_GLOBALISEL_TEMPORARIES_INIT
const APFloat & getValueAPF() const
unsigned createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
static uint64_t encodeLogicalImmediate(uint64_t imm, unsigned regSize)
encodeLogicalImmediate - Return the encoded immediate value for a logical immediate instruction of th...
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
MachineOperand class - Representation of each machine instruction operand.
Intrinsic::ID getIntrinsicID() const
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
bool constrainSelectedInstRegOperands(MachineInstr &I, const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI)
Mutate the newly-selected instruction I to constrain its (possibly generic) virtual register operands...
This class implements the register bank concept.
This file declares the MachineIRBuilder class.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Optional< int64_t > getConstantVRegVal(unsigned VReg, const MachineRegisterInfo &MRI)
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Provides the logic to select generic machine instructions.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
This class provides the information for the target register banks.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static AArch64CC::CondCode changeICMPPredToAArch64CC(CmpInst::Predicate P)
InstructionSelector * createAArch64InstructionSelector(const AArch64TargetMachine &, AArch64Subtarget &, AArch64RegisterBankInfo &)
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
static bool isSigned(Value *V)
Can the given value generate sign bits.
int64_t getOffset() const
Return the offset from the symbol in this operand.
const BlockAddress * getBlockAddress() const
void setReg(unsigned Reg)
Change the register this operand corresponds to.
MO_PAGEOFF - A symbol operand with this flag represents the offset of that symbol within a 4K page...
void setSubReg(unsigned subReg)
static const TargetRegisterClass * constrainGenericRegister(unsigned Reg, const TargetRegisterClass &RC, MachineRegisterInfo &MRI)
Constrain the (possibly generic) virtual register Reg to RC.
#define GET_GLOBALISEL_PREDICATES_INIT
bool isReg() const
isReg - Tests if this is a MO_Register operand.
T get() const
Returns the value of the specified pointer type.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void changeFCMPPredToAArch64CC(CmpInst::Predicate P, AArch64CC::CondCode &CondCode, AArch64CC::CondCode &CondCode2)
bool isPreISelGenericOpcode(unsigned Opcode)
Check whether the given Opcode is a generic opcode that is not supposed to appear after ISel...
LLVM Value Representation.
unsigned getSizeInBits(unsigned Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
void ChangeToFrameIndex(int Idx)
Replace this operand with a frame index.
MachineInstrBuilder buildInstr(unsigned Opc, DstTy &&Ty, UseArgsTy &&... Args)
DAG like Generic method for building arbitrary instructions as above.
static bool unsupportedBinOp(const MachineInstr &I, const AArch64RegisterBankInfo &RBI, const MachineRegisterInfo &MRI, const AArch64RegisterInfo &TRI)
Check whether I is a currently unsupported binary operation:
MO_NC - Indicates whether the linker is expected to check the symbol reference for overflow...
APInt bitcastToAPInt() const
const MachineInstrBuilder & addDef(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
static bool selectCopy(MachineInstr &I, const TargetInstrInfo &TII, MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI)
const MachineOperand & getOperand(unsigned i) const
const ConstantInt * getCImm() const
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool constrainAllUses(const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI) const
unsigned getID() const
Get the identifier of this register bank.
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...
unsigned getPredicate() const