34 #define DEBUG_TYPE "aarch64-isel"
40 #ifndef LLVM_BUILD_GLOBAL_ISEL
41 #error "You shouldn't build this"
46 #define GET_GLOBALISEL_PREDICATE_BITSET
47 #include "AArch64GenGlobalISel.inc"
48 #undef GET_GLOBALISEL_PREDICATE_BITSET
79 #define GET_GLOBALISEL_PREDICATES_DECL
80 #include "AArch64GenGlobalISel.inc"
81 #undef GET_GLOBALISEL_PREDICATES_DECL
85 #define GET_GLOBALISEL_TEMPORARIES_DECL
86 #include "AArch64GenGlobalISel.inc"
87 #undef GET_GLOBALISEL_TEMPORARIES_DECL
92 #define GET_GLOBALISEL_IMPL
93 #include "AArch64GenGlobalISel.inc"
94 #undef GET_GLOBALISEL_IMPL
96 AArch64InstructionSelector::AArch64InstructionSelector(
100 TRI(*STI.getRegisterInfo()), RBI(RBI),
102 #include
"AArch64GenGlobalISel.inc"
105 #include
"AArch64GenGlobalISel.inc"
115 if (RB.
getID() == AArch64::GPRRegBankID) {
117 return &AArch64::GPR32RegClass;
119 return &AArch64::GPR64RegClass;
123 if (RB.
getID() == AArch64::FPRRegBankID) {
125 return &AArch64::FPR32RegClass;
127 return &AArch64::FPR64RegClass;
129 return &AArch64::FPR128RegClass;
148 DEBUG(
dbgs() <<
"Generic binop register should be typed\n");
156 DEBUG(
dbgs() <<
"Generic inst non-reg operands are unsupported\n");
164 if (!TargetRegisterInfo::isVirtualRegister(MO.getReg())) {
165 DEBUG(
dbgs() <<
"Generic inst has physical register operand\n");
171 DEBUG(
dbgs() <<
"Generic register has no bank or class\n");
175 if (PrevOpBank && OpBank != PrevOpBank) {
176 DEBUG(
dbgs() <<
"Generic inst operands have different banks\n");
191 case AArch64::GPRRegBankID:
193 switch (GenericOpc) {
194 case TargetOpcode::G_SHL:
195 return AArch64::LSLVWr;
196 case TargetOpcode::G_LSHR:
197 return AArch64::LSRVWr;
198 case TargetOpcode::G_ASHR:
199 return AArch64::ASRVWr;
203 }
else if (OpSize == 64) {
204 switch (GenericOpc) {
205 case TargetOpcode::G_GEP:
206 return AArch64::ADDXrr;
207 case TargetOpcode::G_SHL:
208 return AArch64::LSLVXr;
209 case TargetOpcode::G_LSHR:
210 return AArch64::LSRVXr;
211 case TargetOpcode::G_ASHR:
212 return AArch64::ASRVXr;
218 case AArch64::FPRRegBankID:
221 switch (GenericOpc) {
222 case TargetOpcode::G_FADD:
223 return AArch64::FADDSrr;
224 case TargetOpcode::G_FSUB:
225 return AArch64::FSUBSrr;
226 case TargetOpcode::G_FMUL:
227 return AArch64::FMULSrr;
228 case TargetOpcode::G_FDIV:
229 return AArch64::FDIVSrr;
234 switch (GenericOpc) {
235 case TargetOpcode::G_FADD:
236 return AArch64::FADDDrr;
237 case TargetOpcode::G_FSUB:
238 return AArch64::FSUBDrr;
239 case TargetOpcode::G_FMUL:
240 return AArch64::FMULDrr;
241 case TargetOpcode::G_FDIV:
242 return AArch64::FDIVDrr;
243 case TargetOpcode::G_OR:
244 return AArch64::ORRv8i8;
261 const bool isStore = GenericOpc == TargetOpcode::G_STORE;
263 case AArch64::GPRRegBankID:
266 return isStore ? AArch64::STRBBui : AArch64::LDRBBui;
268 return isStore ? AArch64::STRHHui : AArch64::LDRHHui;
270 return isStore ? AArch64::STRWui : AArch64::LDRWui;
272 return isStore ? AArch64::STRXui : AArch64::LDRXui;
275 case AArch64::FPRRegBankID:
278 return isStore ? AArch64::STRBui : AArch64::LDRBui;
280 return isStore ? AArch64::STRHui : AArch64::LDRHui;
282 return isStore ? AArch64::STRSui : AArch64::LDRSui;
284 return isStore ? AArch64::STRDui : AArch64::LDRDui;
296 if (TargetRegisterInfo::isPhysicalRegister(DstReg)) {
297 assert(I.
isCopy() &&
"Generic operators do not allow physical registers");
304 const unsigned SrcSize = RBI.getSizeInBits(SrcReg, MRI, TRI);
306 assert((!TargetRegisterInfo::isPhysicalRegister(SrcReg) || I.
isCopy()) &&
307 "No phys reg on generic operators");
309 (DstSize == SrcSize ||
312 (TargetRegisterInfo::isPhysicalRegister(SrcReg) &&
313 DstSize <= RBI.getSizeInBits(SrcReg, MRI, TRI)) ||
317 (((DstSize + 31) / 32 == (SrcSize + 31) / 32) && DstSize > SrcSize)) &&
318 "Copy with different width?!");
319 assert((DstSize <= 64 || RegBank.
getID() == AArch64::FPRRegBankID) &&
320 "GPRs cannot get more than 64-bit width values");
323 if (RegBank.
getID() == AArch64::FPRRegBankID) {
325 RC = &AArch64::FPR32RegClass;
326 else if (DstSize <= 64)
327 RC = &AArch64::FPR64RegClass;
328 else if (DstSize <= 128)
329 RC = &AArch64::FPR128RegClass;
331 DEBUG(
dbgs() <<
"Unexpected bitcast size " << DstSize <<
'\n');
336 "Bitcast for the flags?");
338 DstSize <= 32 ? &AArch64::GPR32allRegClass : &AArch64::GPR64allRegClass;
364 switch (GenericOpc) {
365 case TargetOpcode::G_SITOFP:
366 return AArch64::SCVTFUWSri;
367 case TargetOpcode::G_UITOFP:
368 return AArch64::UCVTFUWSri;
369 case TargetOpcode::G_FPTOSI:
370 return AArch64::FCVTZSUWSr;
371 case TargetOpcode::G_FPTOUI:
372 return AArch64::FCVTZUUWSr;
377 switch (GenericOpc) {
378 case TargetOpcode::G_SITOFP:
379 return AArch64::SCVTFUXSri;
380 case TargetOpcode::G_UITOFP:
381 return AArch64::UCVTFUXSri;
382 case TargetOpcode::G_FPTOSI:
383 return AArch64::FCVTZSUWDr;
384 case TargetOpcode::G_FPTOUI:
385 return AArch64::FCVTZUUWDr;
395 switch (GenericOpc) {
396 case TargetOpcode::G_SITOFP:
397 return AArch64::SCVTFUWDri;
398 case TargetOpcode::G_UITOFP:
399 return AArch64::UCVTFUWDri;
400 case TargetOpcode::G_FPTOSI:
401 return AArch64::FCVTZSUXSr;
402 case TargetOpcode::G_FPTOUI:
403 return AArch64::FCVTZUUXSr;
408 switch (GenericOpc) {
409 case TargetOpcode::G_SITOFP:
410 return AArch64::SCVTFUXDri;
411 case TargetOpcode::G_UITOFP:
412 return AArch64::UCVTFUXDri;
413 case TargetOpcode::G_FPTOSI:
414 return AArch64::FCVTZSUXDr;
415 case TargetOpcode::G_FPTOUI:
416 return AArch64::FCVTZUUXDr;
433 case CmpInst::ICMP_NE:
435 case CmpInst::ICMP_EQ:
437 case CmpInst::ICMP_SGT:
439 case CmpInst::ICMP_SGE:
441 case CmpInst::ICMP_SLT:
443 case CmpInst::ICMP_SLE:
445 case CmpInst::ICMP_UGT:
447 case CmpInst::ICMP_UGE:
449 case CmpInst::ICMP_ULT:
451 case CmpInst::ICMP_ULE:
463 case CmpInst::FCMP_OEQ:
466 case CmpInst::FCMP_OGT:
469 case CmpInst::FCMP_OGE:
472 case CmpInst::FCMP_OLT:
475 case CmpInst::FCMP_OLE:
478 case CmpInst::FCMP_ONE:
482 case CmpInst::FCMP_ORD:
485 case CmpInst::FCMP_UNO:
488 case CmpInst::FCMP_UEQ:
492 case CmpInst::FCMP_UGT:
495 case CmpInst::FCMP_UGE:
498 case CmpInst::FCMP_ULT:
501 case CmpInst::FCMP_ULE:
504 case CmpInst::FCMP_UNE:
510 bool AArch64InstructionSelector::selectCompareBranch(
516 if (CCMI->
getOpcode() != TargetOpcode::G_ICMP)
525 if (!RHSImm || *RHSImm != 0)
529 if (RB.
getID() != AArch64::GPRRegBankID)
533 if (Pred != CmpInst::ICMP_NE && Pred != CmpInst::ICMP_EQ)
539 CBOpc = (Pred == CmpInst::ICMP_EQ ? AArch64::CBZW : AArch64::CBNZW);
540 else if (CmpWidth == 64)
541 CBOpc = (Pred == CmpInst::ICMP_EQ ? AArch64::CBZX : AArch64::CBNZX);
549 constrainSelectedInstRegOperands(*MIB.getInstr(),
TII, TRI, RBI);
554 bool AArch64InstructionSelector::selectVaStartAAPCS(
559 bool AArch64InstructionSelector::selectVaStartDarwin(
573 constrainSelectedInstRegOperands(*MIB,
TII, TRI, RBI);
581 constrainSelectedInstRegOperands(*MIB,
TII, TRI, RBI);
586 bool AArch64InstructionSelector::select(
MachineInstr &I)
const {
598 if (Opcode == TargetOpcode::LOAD_STACK_GUARD)
599 return constrainSelectedInstRegOperands(I,
TII, TRI, RBI);
601 if (Opcode == TargetOpcode::PHI) {
606 if (TargetRegisterInfo::isPhysicalRegister(DefReg)) {
607 DefRC = TRI.getRegClass(DefReg);
615 DEBUG(
dbgs() <<
"PHI operand has no type, not a gvreg?\n");
619 DefRC = getRegClassForTypeOnBank(DefTy, RB, RBI);
621 DEBUG(
dbgs() <<
"PHI operand has unexpected size/bank\n");
638 DEBUG(
dbgs() <<
"Generic instruction has unexpected implicit operands\n");
649 case TargetOpcode::G_BRCOND: {
654 DEBUG(
dbgs() <<
"G_BRCOND has type: " << Ty
655 <<
", expected at most 32-bits");
662 if (selectCompareBranch(I, MF, MRI))
671 return constrainSelectedInstRegOperands(*MIB.getInstr(),
TII, TRI, RBI);
674 case TargetOpcode::G_BRINDIRECT: {
676 return constrainSelectedInstRegOperands(I,
TII, TRI, RBI);
679 case TargetOpcode::G_FCONSTANT:
680 case TargetOpcode::G_CONSTANT: {
681 const bool isFP = Opcode == TargetOpcode::G_FCONSTANT;
683 const LLT s32 = LLT::scalar(32);
684 const LLT s64 = LLT::scalar(64);
685 const LLT p0 = LLT::pointer(0, 64);
694 if (Ty != s32 && Ty != s64) {
695 DEBUG(
dbgs() <<
"Unable to materialize FP " << Ty
696 <<
" constant, expected: " << s32 <<
" or " << s64
701 if (RB.
getID() != AArch64::FPRRegBankID) {
702 DEBUG(
dbgs() <<
"Unable to materialize FP " << Ty
703 <<
" constant on bank: " << RB <<
", expected: FPR\n");
707 if (Ty != s32 && Ty != s64 && Ty != p0) {
708 DEBUG(
dbgs() <<
"Unable to materialize integer " << Ty
709 <<
" constant, expected: " << s32 <<
", " << s64 <<
", or "
714 if (RB.
getID() != AArch64::GPRRegBankID) {
715 DEBUG(
dbgs() <<
"Unable to materialize integer " << Ty
716 <<
" constant on bank: " << RB <<
", expected: GPR\n");
721 const unsigned MovOpc =
722 DefSize == 32 ? AArch64::MOVi32imm : AArch64::MOVi64imm;
728 DefSize == 32 ? AArch64::GPR32RegClass : AArch64::GPR64RegClass;
730 DefSize == 32 ? AArch64::FPR32RegClass : AArch64::FPR64RegClass;
737 TII.get(AArch64::COPY))
742 DEBUG(
dbgs() <<
"Failed to constrain G_FCONSTANT def operand\n");
758 constrainSelectedInstRegOperands(I,
TII, TRI, RBI);
762 case TargetOpcode::G_FRAME_INDEX: {
764 if (Ty != LLT::pointer(0, 64)) {
765 DEBUG(
dbgs() <<
"G_FRAME_INDEX pointer has type: " << Ty
766 <<
", expected: " << LLT::pointer(0, 64) <<
'\n');
776 return constrainSelectedInstRegOperands(I,
TII, TRI, RBI);
779 case TargetOpcode::G_GLOBAL_VALUE: {
781 if (GV->isThreadLocal()) {
785 unsigned char OpFlags = STI.ClassifyGlobalReference(GV,
TM);
796 return constrainSelectedInstRegOperands(I,
TII, TRI, RBI);
799 case TargetOpcode::G_LOAD:
800 case TargetOpcode::G_STORE: {
804 if (PtrTy != LLT::pointer(0, 64)) {
805 DEBUG(
dbgs() <<
"Load/Store pointer has type: " << PtrTy
806 <<
", expected: " << LLT::pointer(0, 64) <<
'\n');
811 if (MemOp.getOrdering() != AtomicOrdering::NotAtomic) {
812 DEBUG(
dbgs() <<
"Atomic load/store not supported yet\n");
821 "Load/Store pointer operand isn't a GPR");
823 "Load/Store pointer operand isn't a pointer");
829 const unsigned NewOpc =
840 if (PtrMI->getOpcode() == TargetOpcode::G_GEP) {
844 const unsigned Scale =
Log2_32(Size);
845 if ((Imm & (Size - 1)) == 0 && Imm >= 0 && Imm < (0x1000 << Scale)) {
846 unsigned Ptr2Reg = PtrMI->getOperand(1).getReg();
856 if (!Offset && PtrMI->getOpcode() == TargetOpcode::G_FRAME_INDEX)
859 I.
addOperand(MachineOperand::CreateImm(Offset));
863 if (*CVal == 0 && Opcode == TargetOpcode::G_STORE) {
866 else if (I.
getOpcode() == AArch64::STRXui)
871 return constrainSelectedInstRegOperands(I,
TII, TRI, RBI);
874 case TargetOpcode::G_SMULH:
875 case TargetOpcode::G_UMULH: {
883 if (RB.
getID() != AArch64::GPRRegBankID) {
884 DEBUG(
dbgs() <<
"G_[SU]MULH on bank: " << RB <<
", expected: GPR\n");
888 if (Ty != LLT::scalar(64)) {
889 DEBUG(
dbgs() <<
"G_[SU]MULH has type: " << Ty
890 <<
", expected: " << LLT::scalar(64) <<
'\n');
894 unsigned NewOpc = I.
getOpcode() == TargetOpcode::G_SMULH ? AArch64::SMULHrr
900 return constrainSelectedInstRegOperands(I,
TII, TRI, RBI);
902 case TargetOpcode::G_FADD:
903 case TargetOpcode::G_FSUB:
904 case TargetOpcode::G_FMUL:
905 case TargetOpcode::G_FDIV:
907 case TargetOpcode::G_OR:
908 case TargetOpcode::G_SHL:
909 case TargetOpcode::G_LSHR:
910 case TargetOpcode::G_ASHR:
911 case TargetOpcode::G_GEP: {
930 return constrainSelectedInstRegOperands(I,
TII, TRI, RBI);
933 case TargetOpcode::G_PTR_MASK: {
935 if (Align >= 64 || Align == 0)
942 return constrainSelectedInstRegOperands(I,
TII, TRI, RBI);
944 case TargetOpcode::G_PTRTOINT:
945 case TargetOpcode::G_TRUNC: {
956 DEBUG(
dbgs() <<
"G_TRUNC/G_PTRTOINT input/output on different banks\n");
960 if (DstRB.
getID() == AArch64::GPRRegBankID) {
962 getRegClassForTypeOnBank(DstTy, DstRB, RBI);
967 getRegClassForTypeOnBank(SrcTy, SrcRB, RBI);
973 DEBUG(
dbgs() <<
"Failed to constrain G_TRUNC/G_PTRTOINT\n");
977 if (DstRC == SrcRC) {
979 }
else if (Opcode == TargetOpcode::G_TRUNC && DstTy == LLT::scalar(32) &&
980 SrcTy == LLT::scalar(64)) {
983 }
else if (DstRC == &AArch64::GPR32RegClass &&
984 SrcRC == &AArch64::GPR64RegClass) {
987 DEBUG(
dbgs() <<
"Unhandled mismatched classes in G_TRUNC/G_PTRTOINT\n");
993 }
else if (DstRB.
getID() == AArch64::FPRRegBankID) {
994 if (DstTy == LLT::vector(4, 16) && SrcTy == LLT::vector(4, 32)) {
996 constrainSelectedInstRegOperands(I,
TII, TRI, RBI);
1004 case TargetOpcode::G_ANYEXT: {
1009 if (RBDst.
getID() != AArch64::GPRRegBankID) {
1010 DEBUG(
dbgs() <<
"G_ANYEXT on bank: " << RBDst <<
", expected: GPR\n");
1015 if (RBSrc.
getID() != AArch64::GPRRegBankID) {
1016 DEBUG(
dbgs() <<
"G_ANYEXT on bank: " << RBSrc <<
", expected: GPR\n");
1023 DEBUG(
dbgs() <<
"G_ANYEXT operand has no size, not a gvreg?\n");
1027 if (DstSize != 64 && DstSize > 32) {
1028 DEBUG(
dbgs() <<
"G_ANYEXT to size: " << DstSize
1029 <<
", expected: 32 or 64\n");
1040 .
addImm(AArch64::sub_32);
1046 case TargetOpcode::G_ZEXT:
1047 case TargetOpcode::G_SEXT: {
1051 const bool isSigned = Opcode == TargetOpcode::G_SEXT;
1056 if (RB.
getID() != AArch64::GPRRegBankID) {
1058 <<
", expected: GPR\n");
1063 if (DstTy == LLT::scalar(64)) {
1066 DEBUG(
dbgs() <<
"Failed to constrain " <<
TII.getName(Opcode)
1071 const unsigned SrcXReg =
1077 .
addImm(AArch64::sub_32);
1079 const unsigned NewOpc = isSigned ? AArch64::SBFMXri : AArch64::UBFMXri;
1086 const unsigned NewOpc = isSigned ? AArch64::SBFMWri : AArch64::UBFMWri;
1096 constrainSelectedInstRegOperands(*ExtI,
TII, TRI, RBI);
1102 case TargetOpcode::G_SITOFP:
1103 case TargetOpcode::G_UITOFP:
1104 case TargetOpcode::G_FPTOSI:
1105 case TargetOpcode::G_FPTOUI: {
1109 if (NewOpc == Opcode)
1113 constrainSelectedInstRegOperands(I,
TII, TRI, RBI);
1119 case TargetOpcode::G_INTTOPTR:
1120 case TargetOpcode::G_BITCAST:
1123 case TargetOpcode::G_FPEXT: {
1125 DEBUG(
dbgs() <<
"G_FPEXT to type " << Ty
1126 <<
", expected: " << LLT::scalar(64) <<
'\n');
1131 DEBUG(
dbgs() <<
"G_FPEXT from type " << Ty
1132 <<
", expected: " << LLT::scalar(32) <<
'\n');
1139 if (RB.
getID() != AArch64::FPRRegBankID) {
1140 DEBUG(
dbgs() <<
"G_FPEXT on bank: " << RB <<
", expected: FPR\n");
1145 constrainSelectedInstRegOperands(I,
TII, TRI, RBI);
1150 case TargetOpcode::G_FPTRUNC: {
1152 DEBUG(
dbgs() <<
"G_FPTRUNC to type " << Ty
1153 <<
", expected: " << LLT::scalar(32) <<
'\n');
1158 DEBUG(
dbgs() <<
"G_FPTRUNC from type " << Ty
1159 <<
", expected: " << LLT::scalar(64) <<
'\n');
1166 if (RB.
getID() != AArch64::FPRRegBankID) {
1167 DEBUG(
dbgs() <<
"G_FPTRUNC on bank: " << RB <<
", expected: FPR\n");
1172 constrainSelectedInstRegOperands(I,
TII, TRI, RBI);
1177 case TargetOpcode::G_SELECT: {
1179 DEBUG(
dbgs() <<
"G_SELECT cond has type: " << Ty
1180 <<
", expected: " << LLT::scalar(1) <<
'\n');
1188 unsigned CSelOpc = 0;
1190 if (Ty == LLT::scalar(32)) {
1191 CSelOpc = AArch64::CSELWr;
1192 }
else if (Ty == LLT::scalar(64) || Ty == LLT::pointer(0, 64)) {
1193 CSelOpc = AArch64::CSELXr;
1200 .addDef(AArch64::WZR)
1210 constrainSelectedInstRegOperands(TstMI,
TII, TRI, RBI);
1211 constrainSelectedInstRegOperands(CSelMI,
TII, TRI, RBI);
1216 case TargetOpcode::G_ICMP: {
1217 if (Ty != LLT::scalar(1)) {
1218 DEBUG(
dbgs() <<
"G_ICMP result has type: " << Ty
1219 <<
", expected: " << LLT::scalar(1) <<
'\n');
1223 unsigned CmpOpc = 0;
1227 if (CmpTy == LLT::scalar(32)) {
1228 CmpOpc = AArch64::SUBSWrr;
1229 ZReg = AArch64::WZR;
1230 }
else if (CmpTy == LLT::scalar(64) || CmpTy.
isPointer()) {
1231 CmpOpc = AArch64::SUBSXrr;
1232 ZReg = AArch64::XZR;
1252 .addUse(AArch64::WZR)
1256 constrainSelectedInstRegOperands(CmpMI,
TII, TRI, RBI);
1257 constrainSelectedInstRegOperands(CSetMI,
TII, TRI, RBI);
1263 case TargetOpcode::G_FCMP: {
1264 if (Ty != LLT::scalar(1)) {
1265 DEBUG(
dbgs() <<
"G_FCMP result has type: " << Ty
1266 <<
", expected: " << LLT::scalar(1) <<
'\n');
1270 unsigned CmpOpc = 0;
1272 if (CmpTy == LLT::scalar(32)) {
1273 CmpOpc = AArch64::FCMPSrr;
1274 }
else if (CmpTy == LLT::scalar(64)) {
1275 CmpOpc = AArch64::FCMPDrr;
1291 unsigned Def1Reg = DefReg;
1315 constrainSelectedInstRegOperands(OrMI,
TII, TRI, RBI);
1316 constrainSelectedInstRegOperands(CSet2MI,
TII, TRI, RBI);
1319 constrainSelectedInstRegOperands(CmpMI,
TII, TRI, RBI);
1320 constrainSelectedInstRegOperands(CSetMI,
TII, TRI, RBI);
1325 case TargetOpcode::G_VASTART:
1326 return STI.isTargetDarwin() ? selectVaStartDarwin(I, MF, MRI)
1327 : selectVaStartAAPCS(I, MF, MRI);
1328 case TargetOpcode::G_IMPLICIT_DEF:
1329 I.
setDesc(
TII.get(TargetOpcode::IMPLICIT_DEF));
1340 AArch64InstructionSelector::selectArithImmed(
MachineOperand &Root)
const {
1356 else if (Root.
isReg()) {
1358 if (Def->
getOpcode() != TargetOpcode::G_CONSTANT)
1369 if (Immed >> 12 == 0) {
1371 }
else if ((Immed & 0xfff) == 0 && Immed >> 24 == 0) {
1373 Immed = Immed >> 12;
1386 return new AArch64InstructionSelector(TM, Subtarget, RBI);
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
const GlobalValue * getGlobal() const
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
uint64_t getZExtValue() const
Get zero extended value.
LLT getType(unsigned VReg) const
Get the low-level type of VReg or LLT{} if VReg is not a generic (target independent) virtual registe...
int getVarArgsStackIndex() const
MO_PAGE - A symbol operand with this flag represents the pc-relative offset of the 4K page containing...
void setTargetFlags(unsigned F)
const ConstantFP * getFPImm() const
MachineBasicBlock * getMBB() const
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
unsigned getBitWidth() const
getBitWidth - Return the bitwidth of this constant.
static CondCode getInvertedCondCode(CondCode Code)
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwises returns null...
iterator_range< mop_iterator > operands()
This file declares the targeting of the RegisterBankInfo class for AArch64.
Holds all the information related to register banks.
const HexagonInstrInfo * TII
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
StringRef getName(unsigned Opcode) const
Returns the name for the instructions with the given opcode.
APInt bitcastToAPInt() const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
MO_GOT - This flag indicates that a symbol operand represents the address of the GOT entry for the sy...
std::function< void(MachineInstrBuilder &)> ComplexRendererFn
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
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...
const MachineBasicBlock * getParent() const
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.
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 MachineOperand & getOperand(unsigned i) const
unsigned getID() const
Get the identifier of this register bank.
bool isCImm() const
isCImm - Test if this is a MO_CImmediate operand.
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
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)
int64_t getOffset() const
Return the offset from the symbol in this operand.
self_iterator getIterator()
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
#define GET_GLOBALISEL_TEMPORARIES_INIT
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.
T get() const
Returns the value of the specified pointer type.
RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
MachineOperand class - Representation of each machine instruction operand.
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
unsigned getPredicate() const
const MachineInstrBuilder & addFrameIndex(int Idx) const
This class implements the register bank concept.
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.
const ConstantInt * getCImm() const
static bool isPreISelGenericOpcode(unsigned Opcode)
Check whether the given Opcode is a generic opcode that is not supposed to appear after ISel...
Optional< int64_t > getConstantVRegVal(unsigned VReg, const MachineRegisterInfo &MRI)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
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.
This class provides the information for the target register banks.
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 RegClassOrRegBank & getRegClassOrRegBank(unsigned Reg) const
Return the register bank or register class of Reg.
void setReg(unsigned Reg)
Change the register this operand corresponds to.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
MO_PAGEOFF - A symbol operand with this flag represents the offset of that symbol within a 4K page...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
const APFloat & getValueAPF() const
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void changeFCMPPredToAArch64CC(CmpInst::Predicate P, AArch64CC::CondCode &CondCode, AArch64CC::CondCode &CondCode2)
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
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.
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...
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
static bool selectCopy(MachineInstr &I, const TargetInstrInfo &TII, MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI)
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.