49 #define DEBUG_TYPE "X86-isel" 55 #define GET_GLOBALISEL_PREDICATE_BITSET 56 #include "X86GenGlobalISel.inc" 57 #undef GET_GLOBALISEL_PREDICATE_BITSET 73 unsigned getLoadStoreOp(
const LLT &Ty,
const RegisterBank &RB,
unsigned Opc,
74 uint64_t Alignment)
const;
108 const unsigned DstReg,
110 const unsigned SrcReg,
121 bool emitInsertSubreg(
unsigned DstReg,
unsigned SrcReg,
MachineInstr &I,
124 bool emitExtractSubreg(
unsigned DstReg,
unsigned SrcReg,
MachineInstr &I,
137 #define GET_GLOBALISEL_PREDICATES_DECL 138 #include "X86GenGlobalISel.inc" 139 #undef GET_GLOBALISEL_PREDICATES_DECL 141 #define GET_GLOBALISEL_TEMPORARIES_DECL 142 #include "X86GenGlobalISel.inc" 143 #undef GET_GLOBALISEL_TEMPORARIES_DECL 148 #define GET_GLOBALISEL_IMPL 149 #include "X86GenGlobalISel.inc" 150 #undef GET_GLOBALISEL_IMPL 156 TRI(*STI.getRegisterInfo()), RBI(RBI),
158 #include
"X86GenGlobalISel.inc" 161 #include
"X86GenGlobalISel.inc" 170 if (RB.
getID() == X86::GPRRegBankID) {
172 return &X86::GR8RegClass;
174 return &X86::GR16RegClass;
176 return &X86::GR32RegClass;
178 return &X86::GR64RegClass;
180 if (RB.
getID() == X86::VECRRegBankID) {
182 return STI.hasAVX512() ? &X86::FR32XRegClass : &X86::FR32RegClass;
184 return STI.hasAVX512() ? &X86::FR64XRegClass : &X86::FR64RegClass;
186 return STI.hasAVX512() ? &X86::VR128XRegClass : &X86::VR128RegClass;
188 return STI.hasAVX512() ? &X86::VR256XRegClass : &X86::VR256RegClass;
190 return &X86::VR512RegClass;
204 unsigned SubIdx = X86::NoSubRegister;
205 if (RC == &X86::GR32RegClass) {
206 SubIdx = X86::sub_32bit;
207 }
else if (RC == &X86::GR16RegClass) {
208 SubIdx = X86::sub_16bit;
209 }
else if (RC == &X86::GR8RegClass) {
210 SubIdx = X86::sub_8bit;
217 assert(TargetRegisterInfo::isPhysicalRegister(Reg));
218 if (X86::GR64RegClass.
contains(Reg))
219 return &X86::GR64RegClass;
220 if (X86::GR32RegClass.
contains(Reg))
221 return &X86::GR32RegClass;
222 if (X86::GR16RegClass.
contains(Reg))
223 return &X86::GR16RegClass;
225 return &X86::GR8RegClass;
234 const unsigned DstSize = RBI.getSizeInBits(DstReg, MRI,
TRI);
238 const unsigned SrcSize = RBI.getSizeInBits(SrcReg, MRI,
TRI);
241 if (TargetRegisterInfo::isPhysicalRegister(DstReg)) {
242 assert(I.
isCopy() &&
"Generic operators do not allow physical registers");
244 if (DstSize > SrcSize && SrcRegBank.
getID() == X86::GPRRegBankID &&
245 DstRegBank.
getID() == X86::GPRRegBankID) {
251 if (SrcRC != DstRC) {
255 TII.get(TargetOpcode::SUBREG_TO_REG))
259 .
addImm(getSubRegIndex(SrcRC));
268 assert((!TargetRegisterInfo::isPhysicalRegister(SrcReg) || I.
isCopy()) &&
269 "No phys reg on generic operators");
270 assert((DstSize == SrcSize ||
273 (TargetRegisterInfo::isPhysicalRegister(SrcReg) &&
274 DstSize <= RBI.getSizeInBits(SrcReg, MRI,
TRI))) &&
275 "Copy with different width?!");
280 if (SrcRegBank.
getID() == X86::GPRRegBankID &&
281 DstRegBank.
getID() == X86::GPRRegBankID && SrcSize > DstSize &&
282 TargetRegisterInfo::isPhysicalRegister(SrcReg)) {
287 if (DstRC != SrcRC) {
298 if (!RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) {
321 if (Opcode == TargetOpcode::LOAD_STACK_GUARD)
331 "Generic instruction has unexpected implicit operands\n");
333 if (selectImpl(I, CoverageInfo))
342 case TargetOpcode::G_STORE:
343 case TargetOpcode::G_LOAD:
344 return selectLoadStoreOp(I, MRI, MF);
345 case TargetOpcode::G_GEP:
346 case TargetOpcode::G_FRAME_INDEX:
347 return selectFrameIndexOrGep(I, MRI, MF);
348 case TargetOpcode::G_GLOBAL_VALUE:
349 return selectGlobalValue(I, MRI, MF);
350 case TargetOpcode::G_CONSTANT:
351 return selectConstant(I, MRI, MF);
352 case TargetOpcode::G_FCONSTANT:
353 return materializeFP(I, MRI, MF);
354 case TargetOpcode::G_PTRTOINT:
355 case TargetOpcode::G_TRUNC:
356 return selectTruncOrPtrToInt(I, MRI, MF);
357 case TargetOpcode::G_INTTOPTR:
359 case TargetOpcode::G_ZEXT:
360 return selectZext(I, MRI, MF);
361 case TargetOpcode::G_ANYEXT:
362 return selectAnyext(I, MRI, MF);
363 case TargetOpcode::G_ICMP:
364 return selectCmp(I, MRI, MF);
365 case TargetOpcode::G_UADDE:
366 return selectUadde(I, MRI, MF);
367 case TargetOpcode::G_UNMERGE_VALUES:
369 case TargetOpcode::G_MERGE_VALUES:
371 case TargetOpcode::G_EXTRACT:
372 return selectExtract(I, MRI, MF);
373 case TargetOpcode::G_INSERT:
374 return selectInsert(I, MRI, MF);
375 case TargetOpcode::G_BRCOND:
376 return selectCondBranch(I, MRI, MF);
377 case TargetOpcode::G_IMPLICIT_DEF:
378 case TargetOpcode::G_PHI:
379 return selectImplicitDefOrPHI(I, MRI);
380 case TargetOpcode::G_SHL:
381 case TargetOpcode::G_ASHR:
382 case TargetOpcode::G_LSHR:
383 return selectShift(I, MRI, MF);
384 case TargetOpcode::G_SDIV:
385 return selectSDiv(I, MRI, MF);
391 unsigned X86InstructionSelector::getLoadStoreOp(
const LLT &Ty,
394 uint64_t Alignment)
const {
395 bool Isload = (Opc == TargetOpcode::G_LOAD);
396 bool HasAVX = STI.hasAVX();
397 bool HasAVX512 = STI.hasAVX512();
398 bool HasVLX = STI.hasVLX();
400 if (Ty == LLT::scalar(8)) {
401 if (X86::GPRRegBankID == RB.
getID())
402 return Isload ? X86::MOV8rm : X86::MOV8mr;
403 }
else if (Ty == LLT::scalar(16)) {
404 if (X86::GPRRegBankID == RB.
getID())
405 return Isload ? X86::MOV16rm : X86::MOV16mr;
406 }
else if (Ty == LLT::scalar(32) || Ty == LLT::pointer(0, 32)) {
407 if (X86::GPRRegBankID == RB.
getID())
408 return Isload ? X86::MOV32rm : X86::MOV32mr;
409 if (X86::VECRRegBankID == RB.
getID())
410 return Isload ? (HasAVX512 ? X86::VMOVSSZrm
411 : HasAVX ? X86::VMOVSSrm : X86::MOVSSrm)
412 : (HasAVX512 ? X86::VMOVSSZmr
413 : HasAVX ? X86::VMOVSSmr : X86::MOVSSmr);
414 }
else if (Ty == LLT::scalar(64) || Ty == LLT::pointer(0, 64)) {
415 if (X86::GPRRegBankID == RB.
getID())
416 return Isload ? X86::MOV64rm : X86::MOV64mr;
417 if (X86::VECRRegBankID == RB.
getID())
418 return Isload ? (HasAVX512 ? X86::VMOVSDZrm
419 : HasAVX ? X86::VMOVSDrm : X86::MOVSDrm)
420 : (HasAVX512 ? X86::VMOVSDZmr
421 : HasAVX ? X86::VMOVSDmr : X86::MOVSDmr);
424 return Isload ? (HasVLX ? X86::VMOVAPSZ128rm
426 ? X86::VMOVAPSZ128rm_NOVLX
427 : HasAVX ? X86::VMOVAPSrm : X86::MOVAPSrm)
428 : (HasVLX ? X86::VMOVAPSZ128mr
430 ? X86::VMOVAPSZ128mr_NOVLX
431 : HasAVX ? X86::VMOVAPSmr : X86::MOVAPSmr);
433 return Isload ? (HasVLX ? X86::VMOVUPSZ128rm
435 ? X86::VMOVUPSZ128rm_NOVLX
436 : HasAVX ? X86::VMOVUPSrm : X86::MOVUPSrm)
437 : (HasVLX ? X86::VMOVUPSZ128mr
439 ? X86::VMOVUPSZ128mr_NOVLX
440 : HasAVX ? X86::VMOVUPSmr : X86::MOVUPSmr);
443 return Isload ? (HasVLX ? X86::VMOVAPSZ256rm
444 : HasAVX512 ? X86::VMOVAPSZ256rm_NOVLX
446 : (HasVLX ? X86::VMOVAPSZ256mr
447 : HasAVX512 ? X86::VMOVAPSZ256mr_NOVLX
450 return Isload ? (HasVLX ? X86::VMOVUPSZ256rm
451 : HasAVX512 ? X86::VMOVUPSZ256rm_NOVLX
453 : (HasVLX ? X86::VMOVUPSZ256mr
454 : HasAVX512 ? X86::VMOVUPSZ256mr_NOVLX
458 return Isload ? X86::VMOVAPSZrm : X86::VMOVAPSZmr;
460 return Isload ? X86::VMOVUPSZrm : X86::VMOVUPSZmr;
471 "unsupported type.");
473 if (I.
getOpcode() == TargetOpcode::G_GEP) {
477 AM.
Disp =
static_cast<int32_t
>(Imm);
482 }
else if (I.
getOpcode() == TargetOpcode::G_FRAME_INDEX) {
484 AM.
BaseType = X86AddressMode::FrameIndexBase;
492 bool X86InstructionSelector::selectLoadStoreOp(
MachineInstr &I,
497 assert((Opc == TargetOpcode::G_STORE || Opc == TargetOpcode::G_LOAD) &&
498 "unexpected instruction");
505 if (MemOp.getOrdering() != AtomicOrdering::NotAtomic) {
510 unsigned NewOpc = getLoadStoreOp(Ty, RB, Opc, MemOp.getAlignment());
519 if (Opc == TargetOpcode::G_LOAD) {
532 if (Ty == LLT::pointer(0, 64))
534 else if (Ty == LLT::pointer(0, 32))
540 bool X86InstructionSelector::selectFrameIndexOrGep(
MachineInstr &I,
545 assert((Opc == TargetOpcode::G_FRAME_INDEX || Opc == TargetOpcode::G_GEP) &&
546 "unexpected instruction");
552 unsigned NewOpc =
getLeaOP(Ty, STI);
556 if (Opc == TargetOpcode::G_FRAME_INDEX) {
568 bool X86InstructionSelector::selectGlobalValue(
MachineInstr &I,
572 "unexpected instruction");
575 if (GV->isThreadLocal()) {
585 AM.
GVOpFlags = STI.classifyGlobalReference(GV);
595 if (STI.isPICStyleRIPRel()) {
603 unsigned NewOpc =
getLeaOP(Ty, STI);
614 bool X86InstructionSelector::selectConstant(
MachineInstr &I,
618 "unexpected instruction");
623 if (RBI.getRegBank(DefReg, MRI,
TRI)->getID() != X86::GPRRegBankID)
638 NewOpc = X86::MOV8ri;
641 NewOpc = X86::MOV16ri;
644 NewOpc = X86::MOV32ri;
649 NewOpc = X86::MOV64ri32;
651 NewOpc = X86::MOV64ri;
666 return (DstRC == &X86::FR32RegClass || DstRC == &X86::FR32XRegClass ||
667 DstRC == &X86::FR64RegClass || DstRC == &X86::FR64XRegClass) &&
668 (SrcRC == &X86::VR128RegClass || SrcRC == &X86::VR128XRegClass);
671 bool X86InstructionSelector::selectTurnIntoCOPY(
676 if (!RBI.constrainGenericRegister(SrcReg, *SrcRC, MRI) ||
677 !RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) {
686 bool X86InstructionSelector::selectTruncOrPtrToInt(
MachineInstr &I,
690 I.
getOpcode() == TargetOpcode::G_PTRTOINT) &&
691 "unexpected instruction");
704 <<
" input/output on different banks\n");
711 if (!DstRC || !SrcRC)
718 return selectTurnIntoCOPY(I, MRI, DstReg, DstRC, SrcReg, SrcRC);
720 if (DstRB.
getID() != X86::GPRRegBankID)
724 if (DstRC == SrcRC) {
726 SubIdx = X86::NoSubRegister;
727 }
else if (DstRC == &X86::GR32RegClass) {
728 SubIdx = X86::sub_32bit;
729 }
else if (DstRC == &X86::GR16RegClass) {
730 SubIdx = X86::sub_16bit;
731 }
else if (DstRC == &X86::GR8RegClass) {
732 SubIdx = X86::sub_8bit;
737 SrcRC =
TRI.getSubClassWithSubReg(SrcRC, SubIdx);
739 if (!RBI.constrainGenericRegister(SrcReg, *SrcRC, MRI) ||
740 !RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) {
752 bool X86InstructionSelector::selectZext(
MachineInstr &I,
755 assert((I.
getOpcode() == TargetOpcode::G_ZEXT) &&
"unexpected instruction");
763 assert(!(SrcTy == LLT::scalar(8) && DstTy == LLT::scalar(32)) &&
764 "8=>32 Zext is handled by tablegen");
765 assert(!(SrcTy == LLT::scalar(16) && DstTy == LLT::scalar(32)) &&
766 "16=>32 Zext is handled by tablegen");
768 const static struct ZextEntry {
772 bool NeedSubregToReg;
774 {LLT::scalar(8), LLT::scalar(16), X86::MOVZX16rr8,
false},
775 {LLT::scalar(8), LLT::scalar(64), X86::MOVZX32rr8,
true},
776 {LLT::scalar(16), LLT::scalar(64), X86::MOVZX32rr16,
true},
777 {LLT::scalar(32), LLT::scalar(64), 0,
true}
782 [SrcTy, DstTy](
const ZextEntry &El) {
783 return El.DstTy == DstTy && El.SrcTy == SrcTy;
787 if (ZextEntryIt !=
std::end(OpTable)) {
793 if (!RBI.constrainGenericRegister(SrcReg, *SrcRC, MRI) ||
794 !RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) {
800 unsigned TransitRegTo = DstReg;
801 unsigned TransitRegFrom = SrcReg;
802 if (ZextEntryIt->MovOp) {
805 if (ZextEntryIt->NeedSubregToReg) {
808 TransitRegTo = TransitRegFrom;
812 .addDef(TransitRegTo)
815 if (ZextEntryIt->NeedSubregToReg) {
817 TII.get(TargetOpcode::SUBREG_TO_REG))
827 if (SrcTy != LLT::scalar(1))
831 if (DstTy == LLT::scalar(8))
832 AndOpc = X86::AND8ri;
833 else if (DstTy == LLT::scalar(16))
834 AndOpc = X86::AND16ri8;
835 else if (DstTy == LLT::scalar(32))
836 AndOpc = X86::AND32ri8;
837 else if (DstTy == LLT::scalar(64))
838 AndOpc = X86::AND64ri8;
842 unsigned DefReg = SrcReg;
843 if (DstTy != LLT::scalar(8)) {
846 TII.get(TargetOpcode::SUBREG_TO_REG), DefReg)
863 bool X86InstructionSelector::selectAnyext(
MachineInstr &I,
866 assert((I.
getOpcode() == TargetOpcode::G_ANYEXT) &&
"unexpected instruction");
878 "G_ANYEXT input/output on different banks\n");
881 "G_ANYEXT incorrect operand size");
890 return selectTurnIntoCOPY(I, MRI, SrcReg, SrcRC, DstReg, DstRC);
892 if (DstRB.
getID() != X86::GPRRegBankID)
895 if (!RBI.constrainGenericRegister(SrcReg, *SrcRC, MRI) ||
896 !RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) {
902 if (SrcRC == DstRC) {
908 TII.get(TargetOpcode::SUBREG_TO_REG))
912 .
addImm(getSubRegIndex(SrcRC));
921 assert((I.
getOpcode() == TargetOpcode::G_ICMP) &&
"unexpected instruction");
945 OpCmp = X86::CMP16rr;
948 OpCmp = X86::CMP32rr;
951 OpCmp = X86::CMP64rr;
970 bool X86InstructionSelector::selectUadde(
MachineInstr &I,
973 assert((I.
getOpcode() == TargetOpcode::G_UADDE) &&
"unexpected instruction");
983 if (DstTy != LLT::scalar(32))
988 while (Def->
getOpcode() == TargetOpcode::G_TRUNC) {
994 if (Def->
getOpcode() == TargetOpcode::G_UADDE) {
1000 if (!RBI.constrainGenericRegister(CarryInReg, X86::GR32RegClass, MRI))
1003 Opcode = X86::ADC32rr;
1009 Opcode = X86::ADD32rr;
1019 .addReg(X86::EFLAGS);
1022 !RBI.constrainGenericRegister(CarryOutReg, X86::GR32RegClass, MRI))
1029 bool X86InstructionSelector::selectExtract(
MachineInstr &I,
1033 "unexpected instruction");
1051 if (!emitExtractSubreg(DstReg, SrcReg, I, MRI, MF))
1058 bool HasAVX = STI.hasAVX();
1059 bool HasAVX512 = STI.hasAVX512();
1060 bool HasVLX = STI.hasVLX();
1064 I.
setDesc(
TII.get(X86::VEXTRACTF32x4Z256rr));
1086 bool X86InstructionSelector::emitExtractSubreg(
unsigned DstReg,
unsigned SrcReg,
1092 unsigned SubIdx = X86::NoSubRegister;
1098 "Incorrect Src/Dst register size");
1101 SubIdx = X86::sub_xmm;
1103 SubIdx = X86::sub_ymm;
1110 SrcRC =
TRI.getSubClassWithSubReg(SrcRC, SubIdx);
1112 if (!RBI.constrainGenericRegister(SrcReg, *SrcRC, MRI) ||
1113 !RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) {
1119 .addReg(SrcReg, 0, SubIdx);
1124 bool X86InstructionSelector::emitInsertSubreg(
unsigned DstReg,
unsigned SrcReg,
1130 unsigned SubIdx = X86::NoSubRegister;
1137 "Incorrect Src/Dst register size");
1140 SubIdx = X86::sub_xmm;
1142 SubIdx = X86::sub_ymm;
1149 if (!RBI.constrainGenericRegister(SrcReg, *SrcRC, MRI) ||
1150 !RBI.constrainGenericRegister(DstReg, *DstRC, MRI)) {
1162 bool X86InstructionSelector::selectInsert(
MachineInstr &I,
1165 assert((I.
getOpcode() == TargetOpcode::G_INSERT) &&
"unexpected instruction");
1173 const LLT InsertRegTy = MRI.
getType(InsertReg);
1184 if (!emitInsertSubreg(DstReg, InsertReg, I, MRI, MF))
1191 bool HasAVX = STI.hasAVX();
1192 bool HasAVX512 = STI.hasAVX512();
1193 bool HasVLX = STI.hasVLX();
1224 "unexpected instruction");
1231 for (
unsigned Idx = 0; Idx < NumDefs; ++Idx) {
1238 if (!select(ExtrInst, CoverageInfo))
1250 "unexpected instruction");
1269 unsigned Tmp = MRI.createGenericVirtualRegister(DstTy);
1270 MRI.setRegBank(Tmp, RegBank);
1273 TII.get(TargetOpcode::G_INSERT), Tmp)
1276 .addImm((Idx - 1) * SrcSize);
1280 if (!select(InsertInst, CoverageInfo))
1285 TII.get(TargetOpcode::COPY), DstReg)
1288 if (!select(CopyInst, CoverageInfo))
1295 bool X86InstructionSelector::selectCondBranch(
MachineInstr &I,
1298 assert((I.
getOpcode() == TargetOpcode::G_BRCOND) &&
"unexpected instruction");
1316 bool X86InstructionSelector::materializeFP(
MachineInstr &I,
1320 "unexpected instruction");
1333 unsigned Opc = getLoadStoreOp(DstTy, RegBank, TargetOpcode::G_LOAD, Align);
1339 unsigned char OpFlag = STI.classifyLocalReference(
nullptr);
1347 .addConstantPoolIndex(CPI, 0, OpFlag);
1350 MachinePointerInfo::getConstantPool(MF), MachineMemOperand::MOLoad,
1363 unsigned PICBase = 0;
1382 bool X86InstructionSelector::selectImplicitDefOrPHI(
1385 I.
getOpcode() == TargetOpcode::G_PHI) &&
1386 "unexpected instruction");
1394 if (!RBI.constrainGenericRegister(DstReg, *RC, MRI)) {
1401 if (I.
getOpcode() == TargetOpcode::G_IMPLICIT_DEF)
1413 bool X86InstructionSelector::selectShift(
MachineInstr &I,
1418 I.
getOpcode() == TargetOpcode::G_ASHR ||
1419 I.
getOpcode() == TargetOpcode::G_LSHR) &&
1420 "unexpected instruction");
1426 const static struct ShiftEntry {
1427 unsigned SizeInBits;
1433 {8, X86::CL, X86::SHR8rCL, X86::SAR8rCL, X86::SHL8rCL},
1434 {16, X86::CX, X86::SHR16rCL, X86::SAR16rCL, X86::SHL16rCL},
1435 {32,
X86::ECX, X86::SHR32rCL, X86::SAR32rCL, X86::SHL32rCL},
1436 {64, X86::RCX, X86::SHR64rCL, X86::SAR64rCL, X86::SHL64rCL}
1439 if (DstRB.
getID() != X86::GPRRegBankID)
1446 if (ShiftEntryIt ==
std::end(OpTable))
1449 unsigned CReg = ShiftEntryIt->CReg;
1450 unsigned Opcode = 0;
1452 case TargetOpcode::G_SHL:
1453 Opcode = ShiftEntryIt->OpSHL;
1455 case TargetOpcode::G_ASHR:
1456 Opcode = ShiftEntryIt->OpASHR;
1458 case TargetOpcode::G_LSHR:
1459 Opcode = ShiftEntryIt->OpLSHR;
1474 if (CReg != X86::CL)
1488 bool X86InstructionSelector::selectSDiv(
MachineInstr &I,
1492 assert(I.
getOpcode() == TargetOpcode::G_SDIV &&
"unexpected instruction");
1500 RegTy == MRI.
getType(DiviserReg) &&
1501 "Arguments and return value types must match");
1513 const static struct SDivEntry {
1514 unsigned SizeInBits;
1515 unsigned QuotientReg;
1516 unsigned DividentRegUpper;
1517 unsigned DividentRegLower;
1518 unsigned OpSignExtend;
1522 {8,
X86::AL, X86::NoRegister, X86::AX, 0, X86::MOVSX16rr8,
1524 {16, X86::AX, X86::DX, X86::AX, X86::CWD, TargetOpcode::COPY,
1528 {64, X86::RAX, X86::RDX, X86::RAX, X86::CQO, TargetOpcode::COPY,
1532 if (RegRB.getID() != X86::GPRRegBankID)
1540 if (SDivEntryIt ==
std::end(OpTable))
1544 if (!RBI.constrainGenericRegister(DividentReg, *RegRC, MRI) ||
1545 !RBI.constrainGenericRegister(DiviserReg, *RegRC, MRI) ||
1546 !RBI.constrainGenericRegister(DstReg, *RegRC, MRI)) {
1553 SDivEntryIt->DividentRegLower)
1554 .addReg(DividentReg);
1555 if (SDivEntryIt->DividentRegUpper != X86::NoRegister)
1557 TII.get(SDivEntryIt->OpSignExtend));
1559 .addReg(DiviserReg);
1562 .addReg(SDivEntryIt->QuotientReg);
1572 return new X86InstructionSelector(TM, Subtarget, RBI);
const_iterator end(StringRef path)
Get end iterator over path.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
This class is the base class for the comparison instructions.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
MachineBasicBlock * getMBB() const
Atomic ordering constants.
static bool selectMergeValues(MachineInstrBuilder &MIB, const ARMBaseInstrInfo &TII, MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI)
Compute iterated dominance frontiers using a linear time algorithm.
static const MachineInstrBuilder & addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI, unsigned GlobalBaseReg, unsigned char OpFlags)
addConstantPoolReference - This function is used to add a reference to the base of a constant value s...
enum llvm::X86AddressMode::@470 BaseType
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
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
An instruction for reading from memory.
void setRegBank(unsigned Reg, const RegisterBank &RegBank)
Set the register bank to RegBank for Reg.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
static const TargetRegisterClass * getRegClassFromGRPhysReg(unsigned Reg)
return AArch64::GPR64RegClass contains(Reg)
A description of a memory reference used in the backend.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
const HexagonInstrInfo * TII
const ConstantFP * getFPImm() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
This class provides the information for the target register banks.
const MachineInstrBuilder & addUse(unsigned RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
static bool isGlobalStubReference(unsigned char TargetFlag)
isGlobalStubReference - Return true if the specified TargetFlag operand is a reference to a stub for ...
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
static StringRef getName(Value *V)
static int getRegClass(RegisterKind Is, unsigned RegWidth)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
static bool isGlobalRelativeToPICBase(unsigned char TargetFlag)
isGlobalRelativeToPICBase - Return true if the specified global value reference is relative to a 32-b...
static bool canTurnIntoCOPY(const TargetRegisterClass *DstRC, const TargetRegisterClass *SrcRC)
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
std::pair< CondCode, bool > getX86ConditionCode(CmpInst::Predicate Predicate)
Return a pair of condition code for the given predicate and whether the instruction operands should b...
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
unsigned const MachineRegisterInfo * MRI
#define GET_GLOBALISEL_PREDICATES_INIT
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
const GlobalValue * getGlobal() const
ConstantFP - Floating Point Values [float, double].
bool isCImm() const
isCImm - Test if this is a MO_CImmediate operand.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
int64_t addOffset(int64_t LHS, int64_t RHS)
void substPhysReg(unsigned Reg, const TargetRegisterInfo &)
substPhysReg - Substitute the current register with the physical register Reg, taking any existing Su...
void setImm(int64_t immVal)
static bool selectUnmergeValues(MachineInstrBuilder &MIB, const ARMBaseInstrInfo &TII, MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI)
void print(raw_ostream &OS, bool IsStandalone=true, bool SkipOpers=false, bool SkipDebugLoc=false, bool AddNewLine=true, const TargetInstrInfo *TII=nullptr) const
Print this MI to OS.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
static void X86SelectAddress(const MachineInstr &I, const MachineRegisterInfo &MRI, X86AddressMode &AM)
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
unsigned getSETFromCond(CondCode CC, bool HasMemoryOperand=false)
Return a set opcode for the given condition and whether it has a memory operand.
bool isImplicitDef() const
#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.
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
This file declares the targeting of the RegisterBankInfo class for X86.
unsigned createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
constexpr bool isInt< 32 >(int64_t x)
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.
MachineOperand class - Representation of each machine instruction operand.
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...
InstructionSelector * createX86InstructionSelector(const X86TargetMachine &TM, X86Subtarget &, X86RegisterBankInfo &)
This class implements the register bank concept.
bool isTarget64BitILP32() const
Is this x86_64 with the ILP32 programming model (x32 ABI)?
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
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.
MO_GOTOFF - On a symbol operand this indicates that the immediate is the offset to the location of th...
static const MachineInstrBuilder & addDirectMem(const MachineInstrBuilder &MIB, unsigned Reg)
addDirectMem - This function is used to add a direct memory reference to the current instruction – t...
static unsigned getLeaOP(LLT Ty, const X86Subtarget &STI)
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
void setReg(unsigned Reg)
Change the register this operand corresponds to.
void setSubReg(unsigned subReg)
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
#define GET_GLOBALISEL_TEMPORARIES_INIT
const TargetRegisterClass * getRegClassOrNull(unsigned Reg) const
Return the register class of Reg, or null if Reg has not been assigned a register class yet...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isPreISelGenericOpcode(unsigned Opcode)
Check whether the given Opcode is a generic opcode that is not supposed to appear after ISel...
unsigned getSizeInBits(unsigned Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const
Get the size in bits of Reg.
MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the immediate should get the value of th...
void RemoveOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
union llvm::X86AddressMode::@471 Base
X86AddressMode - This struct holds a generalized full x86 address mode.
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
static const MachineInstrBuilder & addFullAddress(const MachineInstrBuilder &MIB, const X86AddressMode &AM)
unsigned getConstantPoolIndex(const Constant *C, unsigned Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one...
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
unsigned getID() const
Get the identifier of this register bank.
unsigned getPredicate() const