29#define DEBUG_TYPE "x86-pseudo"
30#define X86_EXPAND_PSEUDO_NAME "X86 pseudo instruction expansion pass"
58 return "X86 pseudo instruction expansion pass";
77 void expandVastartSaveXmmRegs(
81char X86ExpandPseudo::ID = 0;
88void X86ExpandPseudo::expandICallBranchFunnel(
97 std::vector<std::pair<MachineBasicBlock *, unsigned>> TargetMBBs;
102 auto CmpTarget = [&](
unsigned Target) {
103 if (Selector.
isReg())
117 auto CreateMBB = [&]() {
119 MBB->addSuccessor(NewMBB);
120 if (!
MBB->isLiveIn(X86::EFLAGS))
121 MBB->addLiveIn(X86::EFLAGS);
128 auto *ElseMBB = CreateMBB();
129 MF->
insert(InsPt, ElseMBB);
134 auto EmitCondJumpTarget = [&](
unsigned CC,
unsigned Target) {
135 auto *ThenMBB = CreateMBB();
136 TargetMBBs.push_back({ThenMBB,
Target});
137 EmitCondJump(CC, ThenMBB);
140 auto EmitTailCall = [&](
unsigned Target) {
145 std::function<void(
unsigned,
unsigned)> EmitBranchFunnel =
147 if (NumTargets == 1) {
152 if (NumTargets == 2) {
159 if (NumTargets < 6) {
167 auto *ThenMBB = CreateMBB();
171 EmitBranchFunnel(
FirstTarget + (NumTargets / 2) + 1,
172 NumTargets - (NumTargets / 2) - 1);
174 MF->
insert(InsPt, ThenMBB);
181 for (
auto P : TargetMBBs) {
186 JTMBB->
erase(JTInst);
195 MachineInstr *OriginalCall;
196 assert((
MI.getOperand(1).isGlobal() ||
MI.getOperand(1).isReg()) &&
197 "invalid operand for regular call");
199 if (
MI.getOpcode() == X86::CALL64m_RVMARKER)
201 else if (
MI.getOpcode() == X86::CALL64r_RVMARKER)
203 else if (
MI.getOpcode() == X86::CALL64pcrel32_RVMARKER)
204 Opc = X86::CALL64pcrel32;
209 bool RAXImplicitDead =
false;
213 if (
Op.isReg() &&
Op.isImplicit() &&
Op.isDead() &&
214 TRI->regsOverlap(
Op.getReg(), X86::RAX)) {
217 RAXImplicitDead =
true;
232 if (
MI.shouldUpdateAdditionalCallInfo())
236 const uint32_t *RegMask =
238 MachineInstr *RtCall =
247 MI.eraseFromParent();
252 if (
TM.getTargetTriple().isOSDarwin())
260bool X86ExpandPseudo::expandMI(MachineBasicBlock &
MBB,
263 unsigned Opcode =
MI.getOpcode();
265#define GET_EGPR_IF_ENABLED(OPC) (STI->hasEGPR() ? OPC##_EVEX : OPC)
269 case X86::TCRETURNdi:
270 case X86::TCRETURNdicc:
271 case X86::TCRETURNri:
272 case X86::TCRETURN_WIN64ri:
273 case X86::TCRETURN_HIPE32ri:
274 case X86::TCRETURNmi:
275 case X86::TCRETURNdi64:
276 case X86::TCRETURNdi64cc:
277 case X86::TCRETURNri64:
278 case X86::TCRETURNri64_ImpCall:
279 case X86::TCRETURNmi64:
280 case X86::TCRETURN_WINmi64: {
281 bool isMem = Opcode == X86::TCRETURNmi || Opcode == X86::TCRETURNmi64 ||
282 Opcode == X86::TCRETURN_WINmi64;
283 MachineOperand &JumpTarget =
MBBI->getOperand(0);
286 assert(StackAdjust.
isImm() &&
"Expecting immediate value.");
289 int StackAdj = StackAdjust.
getImm();
292 assert(MaxTCDelta <= 0 &&
"MaxTCDelta should never be positive");
295 Offset = StackAdj - MaxTCDelta;
296 assert(
Offset >= 0 &&
"Offset should never be negative");
298 if (Opcode == X86::TCRETURNdicc || Opcode == X86::TCRETURNdi64cc) {
299 assert(
Offset == 0 &&
"Conditional tail call cannot adjust the stack.");
311 if (Opcode == X86::TCRETURNdi || Opcode == X86::TCRETURNdicc ||
312 Opcode == X86::TCRETURNdi64 || Opcode == X86::TCRETURNdi64cc) {
315 case X86::TCRETURNdi:
318 case X86::TCRETURNdicc:
319 Op = X86::TAILJMPd_CC;
321 case X86::TCRETURNdi64cc:
323 "Conditional tail calls confuse "
324 "the Win64 unwinder.");
325 Op = X86::TAILJMPd64_CC;
330 Op = X86::TAILJMPd64;
342 if (
Op == X86::TAILJMPd_CC ||
Op == X86::TAILJMPd64_CC) {
346 }
else if (Opcode == X86::TCRETURNmi || Opcode == X86::TCRETURNmi64 ||
347 Opcode == X86::TCRETURN_WINmi64) {
348 unsigned Op = (Opcode == X86::TCRETURNmi)
350 : (IsX64 ?
X86::TAILJMPm64_REX :
X86::TAILJMPm64);
354 }
else if (Opcode == X86::TCRETURNri64 ||
355 Opcode == X86::TCRETURNri64_ImpCall ||
356 Opcode == X86::TCRETURN_WIN64ri) {
359 TII->get(IsX64 ? X86::TAILJMPr64_REX : X86::TAILJMPr64))
362 assert(!IsX64 &&
"Win64 and UEFI64 require REX for indirect jumps.");
368 MachineInstr &NewMI = *std::prev(
MBBI);
373 if (
MBBI->isCandidateForAdditionalCallInfo())
382 case X86::EH_RETURN64: {
383 MachineOperand &DestAddr =
MBBI->getOperand(0);
384 assert(DestAddr.
isReg() &&
"Offset should be in register!");
388 TII->get(Uses64BitFramePtr ? X86::MOV64rr : X86::MOV32rr), StackPtr)
395 int64_t StackAdj =
MBBI->getOperand(0).getImm();
398 unsigned RetOp = STI->is64Bit() ? X86::IRET64 : X86::IRET32;
400 if (STI->is64Bit() && STI->hasUINTR() &&
409 int64_t StackAdj =
MBBI->getOperand(0).getImm();
410 MachineInstrBuilder MIB;
413 TII->get(STI->is64Bit() ? X86::RET64 : X86::RET32));
416 TII->get(STI->is64Bit() ? X86::RETI64 : X86::RETI32))
420 "shouldn't need to do this for x86_64 targets!");
428 for (
unsigned I = 1,
E =
MBBI->getNumOperands();
I !=
E; ++
I)
433 case X86::LCMPXCHG16B_SAVE_RBX: {
440 const MachineOperand &InArg =
MBBI->getOperand(6);
452 const MachineOperand &
Base =
MBBI->getOperand(1);
453 if (
Base.getReg() == X86::RBX ||
Base.getReg() == X86::EBX)
455 Base.getReg() == X86::RBX
457 :
Register(
TRI->getSubReg(SaveRbx, X86::sub_32bit)),
479 case X86::MASKPAIR16LOAD: {
481 assert(Disp >= 0 && Disp <= INT32_MAX - 2 &&
"Unexpected displacement");
483 bool DstIsDead =
MBBI->getOperand(0).isDead();
495 MIBLo.add(
MBBI->getOperand(1 + i));
497 MIBHi.addImm(Disp + 2);
499 MIBHi.add(
MBBI->getOperand(1 + i));
503 MachineMemOperand *OldMMO =
MBBI->memoperands().
front();
508 MIBLo.setMemRefs(MMOLo);
509 MIBHi.setMemRefs(MMOHi);
515 case X86::MASKPAIR16STORE: {
517 assert(Disp >= 0 && Disp <= INT32_MAX - 2 &&
"Unexpected displacement");
529 MIBLo.add(
MBBI->getOperand(i));
531 MIBHi.addImm(Disp + 2);
533 MIBHi.add(
MBBI->getOperand(i));
539 MachineMemOperand *OldMMO =
MBBI->memoperands().
front();
544 MIBLo.setMemRefs(MMOLo);
545 MIBHi.setMemRefs(MMOHi);
551 case X86::MWAITX_SAVE_RBX: {
558 const MachineOperand &InArg =
MBBI->getOperand(1);
571 case TargetOpcode::ICALL_BRANCH_FUNNEL:
572 expandICallBranchFunnel(&
MBB,
MBBI);
574 case X86::PLDTILECFGV: {
578 case X86::PTILELOADDV:
579 case X86::PTILELOADDT1V:
580 case X86::PTILELOADDRSV:
581 case X86::PTILELOADDRST1V:
582 case X86::PTCVTROWD2PSrreV:
583 case X86::PTCVTROWD2PSrriV:
584 case X86::PTCVTROWPS2BF16HrreV:
585 case X86::PTCVTROWPS2BF16HrriV:
586 case X86::PTCVTROWPS2BF16LrreV:
587 case X86::PTCVTROWPS2BF16LrriV:
588 case X86::PTCVTROWPS2PHHrreV:
589 case X86::PTCVTROWPS2PHHrriV:
590 case X86::PTCVTROWPS2PHLrreV:
591 case X86::PTCVTROWPS2PHLrriV:
592 case X86::PTILEMOVROWrreV:
593 case X86::PTILEMOVROWrriV: {
594 for (
unsigned i = 2; i > 0; --i)
598 case X86::PTILELOADDRSV:
601 case X86::PTILELOADDRST1V:
604 case X86::PTILELOADDV:
607 case X86::PTILELOADDT1V:
610 case X86::PTCVTROWD2PSrreV:
611 Opc = X86::TCVTROWD2PSrre;
613 case X86::PTCVTROWD2PSrriV:
614 Opc = X86::TCVTROWD2PSrri;
616 case X86::PTCVTROWPS2BF16HrreV:
617 Opc = X86::TCVTROWPS2BF16Hrre;
619 case X86::PTCVTROWPS2BF16HrriV:
620 Opc = X86::TCVTROWPS2BF16Hrri;
622 case X86::PTCVTROWPS2BF16LrreV:
623 Opc = X86::TCVTROWPS2BF16Lrre;
625 case X86::PTCVTROWPS2BF16LrriV:
626 Opc = X86::TCVTROWPS2BF16Lrri;
628 case X86::PTCVTROWPS2PHHrreV:
629 Opc = X86::TCVTROWPS2PHHrre;
631 case X86::PTCVTROWPS2PHHrriV:
632 Opc = X86::TCVTROWPS2PHHrri;
634 case X86::PTCVTROWPS2PHLrreV:
635 Opc = X86::TCVTROWPS2PHLrre;
637 case X86::PTCVTROWPS2PHLrriV:
638 Opc = X86::TCVTROWPS2PHLrri;
640 case X86::PTILEMOVROWrreV:
641 Opc = X86::TILEMOVROWrre;
643 case X86::PTILEMOVROWrriV:
644 Opc = X86::TILEMOVROWrri;
657 case X86::PTILEPAIRLOAD: {
660 bool DstIsDead =
MBBI->getOperand(0).isDead();
661 Register TReg0 =
TRI->getSubReg(TReg, X86::sub_t0);
662 Register TReg1 =
TRI->getSubReg(TReg, X86::sub_t1);
663 unsigned TmmSize =
TRI->getRegSizeInBits(X86::TILERegClass) / 8;
665 MachineInstrBuilder MIBLo =
668 MachineInstrBuilder MIBHi =
673 MIBLo.
add(
MBBI->getOperand(1 + i));
675 MIBHi.
addImm(Disp + TmmSize);
677 MIBHi.
add(
MBBI->getOperand(1 + i));
681 MachineOperand &Stride =
686 MachineMemOperand *OldMMO =
MBBI->memoperands().
front();
689 MachineMemOperand *MMOHi =
704 case X86::PTILEPAIRSTORE: {
708 Register TReg0 =
TRI->getSubReg(TReg, X86::sub_t0);
709 Register TReg1 =
TRI->getSubReg(TReg, X86::sub_t1);
710 unsigned TmmSize =
TRI->getRegSizeInBits(X86::TILERegClass) / 8;
712 MachineInstrBuilder MIBLo =
714 MachineInstrBuilder MIBHi =
718 MIBLo.
add(
MBBI->getOperand(i));
720 MIBHi.
addImm(Disp + TmmSize);
722 MIBHi.
add(
MBBI->getOperand(i));
732 MachineMemOperand *OldMMO =
MBBI->memoperands().
front();
735 MachineMemOperand *MMOHi =
745 case X86::PT2RPNTLVWZ0V:
746 case X86::PT2RPNTLVWZ0T1V:
747 case X86::PT2RPNTLVWZ1V:
748 case X86::PT2RPNTLVWZ1T1V:
749 case X86::PT2RPNTLVWZ0RSV:
750 case X86::PT2RPNTLVWZ0RST1V:
751 case X86::PT2RPNTLVWZ1RSV:
752 case X86::PT2RPNTLVWZ1RST1V: {
753 for (
unsigned i = 3; i > 0; --i)
757 case X86::PT2RPNTLVWZ0V:
760 case X86::PT2RPNTLVWZ0T1V:
763 case X86::PT2RPNTLVWZ1V:
766 case X86::PT2RPNTLVWZ1T1V:
769 case X86::PT2RPNTLVWZ0RSV:
772 case X86::PT2RPNTLVWZ0RST1V:
775 case X86::PT2RPNTLVWZ1RSV:
778 case X86::PT2RPNTLVWZ1RST1V:
787 case X86::PTTRANSPOSEDV:
788 case X86::PTCONJTFP16V: {
789 for (
int i = 2; i > 0; --i)
791 MI.setDesc(
TII->get(Opcode == X86::PTTRANSPOSEDV ? X86::TTRANSPOSED
795 case X86::PTCMMIMFP16PSV:
796 case X86::PTCMMRLFP16PSV:
801 case X86::PTDPBF16PSV:
802 case X86::PTDPFP16PSV:
803 case X86::PTTDPBF16PSV:
804 case X86::PTTDPFP16PSV:
805 case X86::PTTCMMIMFP16PSV:
806 case X86::PTTCMMRLFP16PSV:
807 case X86::PTCONJTCMMIMFP16PSV:
808 case X86::PTMMULTF32PSV:
809 case X86::PTTMMULTF32PSV:
810 case X86::PTDPBF8PSV:
811 case X86::PTDPBHF8PSV:
812 case X86::PTDPHBF8PSV:
813 case X86::PTDPHF8PSV: {
814 MI.untieRegOperand(4);
815 for (
unsigned i = 3; i > 0; --i)
819 case X86::PTCMMIMFP16PSV:
Opc = X86::TCMMIMFP16PS;
break;
820 case X86::PTCMMRLFP16PSV:
Opc = X86::TCMMRLFP16PS;
break;
821 case X86::PTDPBSSDV:
Opc = X86::TDPBSSD;
break;
822 case X86::PTDPBSUDV:
Opc = X86::TDPBSUD;
break;
823 case X86::PTDPBUSDV:
Opc = X86::TDPBUSD;
break;
824 case X86::PTDPBUUDV:
Opc = X86::TDPBUUD;
break;
825 case X86::PTDPBF16PSV:
Opc = X86::TDPBF16PS;
break;
826 case X86::PTDPFP16PSV:
Opc = X86::TDPFP16PS;
break;
827 case X86::PTTDPBF16PSV:
828 Opc = X86::TTDPBF16PS;
830 case X86::PTTDPFP16PSV:
831 Opc = X86::TTDPFP16PS;
833 case X86::PTTCMMIMFP16PSV:
834 Opc = X86::TTCMMIMFP16PS;
836 case X86::PTTCMMRLFP16PSV:
837 Opc = X86::TTCMMRLFP16PS;
839 case X86::PTCONJTCMMIMFP16PSV:
840 Opc = X86::TCONJTCMMIMFP16PS;
842 case X86::PTMMULTF32PSV:
843 Opc = X86::TMMULTF32PS;
845 case X86::PTTMMULTF32PSV:
846 Opc = X86::TTMMULTF32PS;
848 case X86::PTDPBF8PSV:
851 case X86::PTDPBHF8PSV:
852 Opc = X86::TDPBHF8PS;
854 case X86::PTDPHBF8PSV:
855 Opc = X86::TDPHBF8PS;
857 case X86::PTDPHF8PSV:
865 MI.tieOperands(0, 1);
868 case X86::PTILESTOREDV: {
869 for (
int i = 1; i >= 0; --i)
874#undef GET_EGPR_IF_ENABLED
875 case X86::PTILEZEROV: {
876 for (
int i = 2; i > 0; --i)
878 MI.setDesc(
TII->get(X86::TILEZERO));
881 case X86::CALL64pcrel32_RVMARKER:
882 case X86::CALL64r_RVMARKER:
883 case X86::CALL64m_RVMARKER:
884 expandCALL_RVMARKER(
MBB,
MBBI);
886 case X86::CALL64r_ImpCall:
887 MI.setDesc(
TII->get(X86::CALL64r));
889 case X86::ADD32mi_ND:
890 case X86::ADD64mi32_ND:
891 case X86::SUB32mi_ND:
892 case X86::SUB64mi32_ND:
893 case X86::AND32mi_ND:
894 case X86::AND64mi32_ND:
896 case X86::OR64mi32_ND:
897 case X86::XOR32mi_ND:
898 case X86::XOR64mi32_ND:
899 case X86::ADC32mi_ND:
900 case X86::ADC64mi32_ND:
901 case X86::SBB32mi_ND:
902 case X86::SBB64mi32_ND: {
919 const MachineOperand &ImmOp =
920 MI.getOperand(
MI.getNumExplicitOperands() - 1);
935 if (X86MCRegisterClasses[X86::GR32RegClassID].
contains(
Base) ||
936 X86MCRegisterClasses[X86::GR32RegClassID].
contains(Index))
940 unsigned Opc, LoadOpc;
942#define MI_TO_RI(OP) \
943 case X86::OP##32mi_ND: \
944 Opc = X86::OP##32ri; \
945 LoadOpc = X86::MOV32rm; \
947 case X86::OP##64mi32_ND: \
948 Opc = X86::OP##64ri32; \
949 LoadOpc = X86::MOV64rm; \
969 for (
unsigned I =
MI.getNumImplicitOperands() + 1;
I != 0; --
I)
970 MI.removeOperand(
MI.getNumOperands() - 1);
971 MI.setDesc(
TII->get(LoadOpc));
992void X86ExpandPseudo::expandVastartSaveXmmRegs(
993 MachineBasicBlock *EntryBlk,
995 assert(VAStartPseudoInstr->getOpcode() == X86::VASTART_SAVE_XMM_REGS);
999 const DebugLoc &
DL = VAStartPseudoInstr->getDebugLoc();
1000 Register CountReg = VAStartPseudoInstr->getOperand(0).getReg();
1006 LiveRegs.addLiveIns(*EntryBlk);
1007 for (MachineInstr &
MI : EntryBlk->
instrs()) {
1008 if (
MI.getOpcode() == VAStartPseudoInstr->getOpcode())
1011 LiveRegs.stepForward(
MI, Clobbers);
1019 MachineBasicBlock *GuardedRegsBlk =
Func->CreateMachineBasicBlock(LLVMBlk);
1020 MachineBasicBlock *TailBlk =
Func->CreateMachineBasicBlock(LLVMBlk);
1021 Func->insert(EntryBlkIter, GuardedRegsBlk);
1022 Func->insert(EntryBlkIter, TailBlk);
1030 uint64_t FrameOffset = VAStartPseudoInstr->getOperand(4).getImm();
1031 uint64_t VarArgsRegsOffset = VAStartPseudoInstr->getOperand(6).getImm();
1034 unsigned MOVOpc = STI->
hasAVX() ? X86::VMOVAPSmr : X86::MOVAPSmr;
1037 for (int64_t OpndIdx = 7, RegIdx = 0;
1038 OpndIdx < VAStartPseudoInstr->getNumOperands() - 1;
1039 OpndIdx++, RegIdx++) {
1040 auto NewMI =
BuildMI(GuardedRegsBlk,
DL,
TII->get(MOVOpc));
1043 NewMI.addImm(FrameOffset + VarArgsRegsOffset + RegIdx * 16);
1045 NewMI.add(VAStartPseudoInstr->getOperand(i + 1));
1047 NewMI.addReg(VAStartPseudoInstr->getOperand(OpndIdx).getReg());
1048 assert(VAStartPseudoInstr->getOperand(OpndIdx).getReg().isPhysical());
1072 VAStartPseudoInstr->eraseFromParent();
1077bool X86ExpandPseudo::expandMBB(MachineBasicBlock &
MBB) {
1091bool X86ExpandPseudo::expandPseudosWhichAffectControlFlow(MachineFunction &MF) {
1096 if (
Instr.getOpcode() == X86::VASTART_SAVE_XMM_REGS) {
1097 expandVastartSaveXmmRegs(&(MF.
front()), Instr);
1105bool X86ExpandPseudo::runOnMachineFunction(MachineFunction &MF) {
1109 X86FI = MF.
getInfo<X86MachineFunctionInfo>();
1112 bool Modified = expandPseudosWhichAffectControlFlow(MF);
1114 for (MachineBasicBlock &
MBB : MF)
1121 return new X86ExpandPseudo();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const HexagonInstrInfo * TII
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
Register const TargetRegisterInfo * TRI
Promote Memory to Register
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static Target * FirstTarget
#define GET_EGPR_IF_ENABLED(OPC)
#define X86_EXPAND_PSEUDO_NAME
Represent the analysis usage information of a pass.
AnalysisUsage & addPreservedID(const void *ID)
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
LLVM Basic Block Representation.
FunctionPass class - This class is used to implement most global optimizations.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
Emit instructions to copy a pair of physical registers.
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
LLVM_ABI void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ABI instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineInstrBundleIterator< MachineInstr > iterator
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Properties which a MachineFunction may have at a given point in time.
void moveAdditionalCallInfo(const MachineInstr *Old, const MachineInstr *New)
Move the call site info from Old to \New call site info.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, LLT MemTy, Align 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.
BasicBlockListType::iterator iterator
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineBasicBlock & front() const
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineInstr - Allocate a new MachineInstr.
void insert(iterator MBBI, MachineBasicBlock *MBB)
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
const MachineInstrBuilder & setMemRefs(ArrayRef< MachineMemOperand * > MMOs) const
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned TargetFlags=0) const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned TargetFlags=0) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly.
Representation of each machine instruction.
LLVM_ABI void setCFIType(MachineFunction &MF, uint32_t Type)
Set the CFI type for the instruction.
unsigned getNumOperands() const
Retuns the total number of operands.
LLVM_ABI void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
LLVM_ABI void copyImplicitOps(MachineFunction &MF, const MachineInstr &MI)
Copy implicit register operands from specified instruction to this instruction.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
void setIsKill(bool Val=true)
unsigned getTargetFlags() const
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
const char * getSymbolName() const
Register getReg() const
getReg - Returns the register number.
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
int64_t getOffset() const
Return the offset from the symbol in this operand.
StringRef - Represent a constant reference to a string, i.e.
CodeModel::Model getCodeModel() const
Returns the code model.
Target - Wrapper for Target specific information.
bool isOSWindows() const
Tests whether the OS is Windows.
int64_t mergeSPAdd(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, int64_t AddOffset, bool doMergeWithPrevious) const
Equivalent to: mergeSPUpdates(MBB, MBBI, [AddOffset](int64_t Offset) { return AddOffset + Offset; }...
void emitSPUpdate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &DL, int64_t NumBytes, bool InEpilogue) const
Emit a series of instructions to increment / decrement the stack pointer by a constant value.
X86MachineFunctionInfo - This class is derived from MachineFunction and contains private X86 target-s...
int getTCReturnAddrDelta() const
bool isTargetWin64() const
bool isTarget64BitLP64() const
Is this x86_64 with the LP64 programming model (standard AMD64, no x32)?
const Triple & getTargetTriple() const
const X86InstrInfo * getInstrInfo() const override
bool isCallingConvWin64(CallingConv::ID CC) const
bool isTargetUEFI64() const
const X86RegisterInfo * getRegisterInfo() const override
const X86FrameLowering * getFrameLowering() const override
self_iterator getIterator()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ BasicBlock
Various leaf nodes.
@ Implicit
Not emitted register (e.g. carry, or temporary result).
@ Define
Register definition.
@ X86
Windows x64, Windows Itanium (IA-64)
bool needSIB(MCRegister BaseReg, MCRegister IndexReg, bool In64BitMode)
int getFirstAddrOperandIdx(const MachineInstr &MI)
Return the index of the instruction's first address operand, if it has a memory reference,...
NodeAddr< InstrNode * > Instr
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
LLVM_ABI void finalizeBundle(MachineBasicBlock &MBB, MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
finalizeBundle - Finalize a machine instruction bundle which includes a sequence of instructions star...
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
static bool isMem(const MachineInstr &MI, unsigned Op)
LLVM_ABI char & MachineDominatorsID
MachineDominators - This pass is a machine dominators analysis pass.
unsigned getDeadRegState(bool B)
LLVM_ABI char & MachineLoopInfoID
MachineLoopInfo - This pass is a loop analysis pass.
FunctionPass * createX86ExpandPseudoPass()
Return a Machine IR pass that expands X86-specific pseudo instructions into a sequence of actual inst...
FunctionAddr VTableAddr Count
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
unsigned getKillRegState(bool B)
DWARFExpression::Operation Op
void addLiveIns(MachineBasicBlock &MBB, const LivePhysRegs &LiveRegs)
Adds registers contained in LiveRegs to the block live-in list of MBB.