31#define DEBUG_TYPE "si-pre-emit-peephole"
34 "Number of redundant mode register writes removed");
40struct ModeFieldState {
41 std::optional<int64_t>
Value;
42 std::optional<int64_t> ValueBeforePendingWrite;
45 bool isTracked()
const {
return PendingWrite ||
Value; }
48class SIPreEmitPeephole {
50 const SIInstrInfo *TII =
nullptr;
51 const SIRegisterInfo *TRI =
nullptr;
52 MachineLoopInfo *MLI =
nullptr;
54 bool optimizeVccBranch(MachineInstr &
MI)
const;
55 void updateMLIBeforeRemovingEdge(MachineBasicBlock *From,
56 MachineBasicBlock *To)
const;
57 bool optimizeSetGPR(MachineInstr &
First, MachineInstr &
MI)
const;
58 bool getBlockDestinations(MachineBasicBlock &SrcMBB,
59 MachineBasicBlock *&TrueMBB,
60 MachineBasicBlock *&FalseMBB,
61 SmallVectorImpl<MachineOperand> &
Cond);
62 bool mustRetainExeczBranch(
const MachineInstr &Branch,
63 const MachineBasicBlock &From,
64 const MachineBasicBlock &To)
const;
65 bool removeExeczBranch(MachineInstr &
MI, MachineBasicBlock &SrcMBB);
66 bool removeRedundantModeWrites(MachineBasicBlock &SrcMBB)
const;
69 void collectUnpackingCandidates(MachineInstr &BeginMI,
70 SetVector<MachineInstr *> &InstrsToUnpack,
71 uint16_t NumMFMACycles);
79 bool canUnpackingClobberRegister(
const MachineInstr &
MI);
83 void performF32Unpacking(MachineInstr &
I);
85 uint32_t mapToUnpackedOpcode(MachineInstr &
I);
89 MachineInstrBuilder createUnpackedMI(MachineInstr &
I, uint32_t UnpackedOpcode,
93 void addOperandAndMods(MachineInstrBuilder &NewMI,
unsigned SrcMods,
94 bool IsHiBits,
const MachineOperand &SrcMO);
104 SIPreEmitPeepholeLegacy() : MachineFunctionPass(ID) {}
106 void getAnalysisUsage(AnalysisUsage &AU)
const override {
113 auto *MLIWrapper = getAnalysisIfAvailable<MachineLoopInfoWrapperPass>();
114 MachineLoopInfo *MLI = MLIWrapper ? &MLIWrapper->getLI() :
nullptr;
115 return SIPreEmitPeephole().run(MF, MLI);
122 "SI peephole optimizations",
false,
false)
124char SIPreEmitPeepholeLegacy::ID = 0;
128void SIPreEmitPeephole::updateMLIBeforeRemovingEdge(
139 unsigned BackEdgeCount = 0;
141 if (Loop->contains(Pred))
145 if (BackEdgeCount > 1)
152 if (MLI->getLoopFor(BB) == Loop)
153 MLI->changeLoopFor(BB, ParentLoop);
158 MachineLoop *Child = Loop->removeChildLoop(std::prev(Loop->end()));
160 ParentLoop->addChildLoop(Child);
162 MLI->addTopLevelLoop(Child);
173bool SIPreEmitPeephole::optimizeVccBranch(
MachineInstr &
MI)
const {
187 const bool IsWave32 =
ST.isWave32();
188 const unsigned CondReg =
TRI->getVCC();
189 const unsigned ExecReg = IsWave32 ? AMDGPU::EXEC_LO : AMDGPU::EXEC;
190 const unsigned And = IsWave32 ? AMDGPU::S_AND_B32 : AMDGPU::S_AND_B64;
191 const unsigned AndN2 = IsWave32 ? AMDGPU::S_ANDN2_B32 : AMDGPU::S_ANDN2_B64;
192 const unsigned Mov = IsWave32 ? AMDGPU::S_MOV_B32 : AMDGPU::S_MOV_B64;
196 bool ReadsCond =
false;
197 unsigned Threshold = 5;
198 for (++
A;
A !=
E; ++
A) {
201 if (
A->modifiesRegister(ExecReg,
TRI))
203 if (
A->modifiesRegister(CondReg,
TRI)) {
204 if (!
A->definesRegister(CondReg,
TRI) ||
205 (
A->getOpcode() !=
And &&
A->getOpcode() != AndN2))
209 ReadsCond |=
A->readsRegister(CondReg,
TRI);
214 MachineOperand &Op1 =
A->getOperand(1);
215 MachineOperand &Op2 =
A->getOperand(2);
217 Op2.
getReg() == ExecReg) {
218 TII->commuteInstruction(*
A);
226 int64_t MaskValue = 0;
230 auto M = std::next(
A);
231 bool ReadsSreg =
false;
232 for (;
M !=
E; ++
M) {
233 if (
M->definesRegister(SReg,
TRI))
235 if (
M->modifiesRegister(SReg,
TRI))
237 ReadsSreg |=
M->readsRegister(SReg,
TRI);
242 if (!
M->isMoveImmediate() || !
M->getOperand(1).isImm() ||
243 (
M->getOperand(1).getImm() != -1 &&
M->getOperand(1).getImm() != 0))
245 MaskValue =
M->getOperand(1).getImm();
248 if (!ReadsSreg && Op2.
isKill()) {
249 A->getOperand(2).ChangeToImmediate(MaskValue);
250 M->eraseFromParent();
252 }
else if (Op2.
isImm()) {
259 assert(MaskValue == 0 || MaskValue == -1);
260 if (
A->getOpcode() == AndN2)
261 MaskValue = ~MaskValue;
263 if (!ReadsCond &&
A->registerDefIsDead(AMDGPU::SCC,
nullptr)) {
264 if (!
MI.killsRegister(CondReg,
TRI)) {
266 if (MaskValue == 0) {
267 BuildMI(*
A->getParent(), *
A,
A->getDebugLoc(),
TII->get(Mov), CondReg)
270 BuildMI(*
A->getParent(), *
A,
A->getDebugLoc(),
TII->get(Mov), CondReg)
275 A->eraseFromParent();
278 bool IsVCCZ =
MI.getOpcode() == AMDGPU::S_CBRANCH_VCCZ;
279 if (SReg == ExecReg) {
282 MI.eraseFromParent();
285 MI.setDesc(
TII->get(AMDGPU::S_BRANCH));
286 }
else if (IsVCCZ && MaskValue == 0) {
289 MachineBasicBlock *Parent =
MI.getParent();
290 SmallVector<MachineInstr *, 4>
ToRemove;
297 Found =
Term.isIdenticalTo(
MI);
300 assert(Found &&
"conditional branch is not terminator");
302 MachineOperand &Dst = BranchMI->getOperand(0);
303 assert(Dst.isMBB() &&
"destination is not basic block");
304 updateMLIBeforeRemovingEdge(Parent, Dst.getMBB());
306 BranchMI->eraseFromParent();
310 updateMLIBeforeRemovingEdge(Parent, Succ);
315 MI.setDesc(
TII->get(AMDGPU::S_BRANCH));
316 }
else if (!IsVCCZ && MaskValue == 0) {
318 MachineOperand &Dst =
MI.getOperand(0);
319 assert(Dst.isMBB() &&
"destination is not basic block");
321 updateMLIBeforeRemovingEdge(Parent, Dst.getMBB());
323 MI.eraseFromParent();
325 }
else if (MaskValue == -1) {
328 TII->get(IsVCCZ ? AMDGPU::S_CBRANCH_EXECZ : AMDGPU::S_CBRANCH_EXECNZ));
331 MI.removeOperand(
MI.findRegisterUseOperandIdx(CondReg,
TRI,
false ));
337bool SIPreEmitPeephole::optimizeSetGPR(MachineInstr &
First,
338 MachineInstr &
MI)
const {
341 const MachineRegisterInfo &MRI = MF.
getRegInfo();
342 MachineOperand *Idx =
TII->getNamedOperand(
MI, AMDGPU::OpName::src0);
344 SmallVector<MachineInstr *, 4>
ToRemove;
352 E =
MI.getIterator();
354 if (
I->isBundle() ||
I->isDebugInstr())
356 switch (
I->getOpcode()) {
357 case AMDGPU::S_SET_GPR_IDX_MODE:
359 case AMDGPU::S_SET_GPR_IDX_OFF:
364 if (
I->modifiesRegister(AMDGPU::M0,
TRI))
366 if (IdxReg &&
I->modifiesRegister(IdxReg,
TRI))
368 if (
llvm::any_of(
I->operands(), [&MRI,
this](
const MachineOperand &MO) {
369 return MO.isReg() && TRI->isVectorRegister(MRI, MO.getReg());
373 if (!IdxOn || !(
I->getOpcode() == AMDGPU::V_MOV_B32_indirect_write ||
374 I->getOpcode() == AMDGPU::V_MOV_B32_indirect_read))
380 MI.eraseFromBundle();
382 RI->eraseFromBundle();
386bool SIPreEmitPeephole::getBlockDestinations(
387 MachineBasicBlock &SrcMBB, MachineBasicBlock *&TrueMBB,
388 MachineBasicBlock *&FalseMBB, SmallVectorImpl<MachineOperand> &
Cond) {
399class BranchWeightCostModel {
400 const SIInstrInfo &
TII;
401 const TargetSchedModel &SchedModel;
402 BranchProbability BranchProb;
403 static constexpr uint64_t BranchNotTakenCost = 1;
408 BranchWeightCostModel(
const SIInstrInfo &
TII,
const MachineInstr &Branch,
409 const MachineBasicBlock &Succ)
410 :
TII(
TII), SchedModel(
TII.getSchedModel()) {
411 const MachineBasicBlock &Head = *
Branch.getParent();
418 BranchTakenCost = SchedModel.computeInstrLatency(&Branch);
422 if (
TII.isWaitcnt(
MI.getOpcode()))
425 ThenCyclesCost += SchedModel.computeInstrLatency(&
MI);
437 return (Denominator - Numerator) * ThenCyclesCost <=
438 ((Denominator - Numerator) * BranchTakenCost +
439 Numerator * BranchNotTakenCost);
443bool SIPreEmitPeephole::mustRetainExeczBranch(
444 const MachineInstr &Branch,
const MachineBasicBlock &From,
445 const MachineBasicBlock &To)
const {
447 BranchWeightCostModel CostModel{*
TII,
Branch, From};
452 const MachineBasicBlock &
MBB = *
MBBI;
454 for (
const MachineInstr &
MI :
MBB) {
458 if (
MI.isConditionalBranch())
461 if (
MI.isUnconditionalBranch() &&
465 if (
MI.isMetaInstruction())
468 if (
TII->hasUnwantedEffectsWhenEXECEmpty(
MI))
471 if (!CostModel.isProfitable(
MI))
481bool SIPreEmitPeephole::removeExeczBranch(MachineInstr &
MI,
482 MachineBasicBlock &SrcMBB) {
484 if (!
TII->getSchedModel().hasInstrSchedModel())
487 MachineBasicBlock *TrueMBB =
nullptr;
488 MachineBasicBlock *FalseMBB =
nullptr;
491 if (!getBlockDestinations(SrcMBB, TrueMBB, FalseMBB,
Cond))
499 if (mustRetainExeczBranch(
MI, *FalseMBB, *TrueMBB))
503 MI.eraseFromParent();
520bool SIPreEmitPeephole::removeRedundantModeWrites(
521 MachineBasicBlock &SrcMBB)
const {
523 ModeFieldState DenormMode;
524 ModeFieldState RoundMode;
527 if (
MI.isDebugInstr())
530 unsigned Opc =
MI.getOpcode();
531 if (
Opc == AMDGPU::S_DENORM_MODE ||
Opc == AMDGPU::S_ROUND_MODE) {
532 ModeFieldState &
Field =
533 Opc == AMDGPU::S_DENORM_MODE ? DenormMode : RoundMode;
534 int64_t NewValue =
MI.getOperand(0).getImm();
536 if (
Field.PendingWrite) {
538 << *
Field.PendingWrite);
539 Field.PendingWrite->eraseFromParent();
540 ++NumModeWritesRemoved;
542 Field.PendingWrite =
nullptr;
546 if (
Field.Value == NewValue) {
548 MI.eraseFromParent();
549 ++NumModeWritesRemoved;
556 Field.Value = NewValue;
561 if (!DenormMode.isTracked() && !RoundMode.isTracked())
565 if (
MI.isInlineAsm() ||
MI.modifiesRegister(AMDGPU::MODE,
TRI)) {
566 DenormMode = ModeFieldState();
567 RoundMode = ModeFieldState();
571 if (
MI.readsRegister(AMDGPU::MODE,
TRI) ||
MI.hasUnmodeledSideEffects()) {
572 DenormMode.PendingWrite =
nullptr;
573 RoundMode.PendingWrite =
nullptr;
579bool SIPreEmitPeephole::canUnpackingClobberRegister(
const MachineInstr &
MI) {
589 Register UnpackedDstReg =
TRI->getSubReg(DstReg, AMDGPU::sub0);
591 const MachineOperand *Src0MO =
TII->getNamedOperand(
MI, AMDGPU::OpName::src0);
592 if (Src0MO && Src0MO->
isReg()) {
595 TII->getNamedOperand(
MI, AMDGPU::OpName::src0_modifiers)->getImm();
597 ?
TRI->getSubReg(SrcReg0, AMDGPU::sub1)
598 :
TRI->getSubReg(SrcReg0, AMDGPU::sub0);
601 if (
TRI->regsOverlap(UnpackedDstReg, HiSrc0Reg))
605 const MachineOperand *Src1MO =
TII->getNamedOperand(
MI, AMDGPU::OpName::src1);
606 if (Src1MO && Src1MO->
isReg()) {
609 TII->getNamedOperand(
MI, AMDGPU::OpName::src1_modifiers)->getImm();
611 ?
TRI->getSubReg(SrcReg1, AMDGPU::sub1)
612 :
TRI->getSubReg(SrcReg1, AMDGPU::sub0);
613 if (
TRI->regsOverlap(UnpackedDstReg, HiSrc1Reg))
620 const MachineOperand *Src2MO =
621 TII->getNamedOperand(
MI, AMDGPU::OpName::src2);
622 if (Src2MO && Src2MO->
isReg()) {
625 TII->getNamedOperand(
MI, AMDGPU::OpName::src2_modifiers)->getImm();
627 ?
TRI->getSubReg(SrcReg2, AMDGPU::sub1)
628 :
TRI->getSubReg(SrcReg2, AMDGPU::sub0);
629 if (
TRI->regsOverlap(UnpackedDstReg, HiSrc2Reg))
636uint32_t SIPreEmitPeephole::mapToUnpackedOpcode(MachineInstr &
I) {
637 unsigned Opcode =
I.getOpcode();
642 case AMDGPU::V_PK_ADD_F32:
643 case AMDGPU::V_PK_ADD_F32_gfx1250:
644 return AMDGPU::V_ADD_F32_e64;
645 case AMDGPU::V_PK_MUL_F32:
646 case AMDGPU::V_PK_MUL_F32_gfx1250:
647 return AMDGPU::V_MUL_F32_e64;
648 case AMDGPU::V_PK_FMA_F32:
649 case AMDGPU::V_PK_FMA_F32_gfx1250:
650 return AMDGPU::V_FMA_F32_e64;
652 return std::numeric_limits<uint32_t>::max();
657void SIPreEmitPeephole::addOperandAndMods(MachineInstrBuilder &NewMI,
658 unsigned SrcMods,
bool IsHiBits,
659 const MachineOperand &SrcMO) {
660 unsigned NewSrcMods = 0;
672 if (SrcMods & NegModifier)
683 Register UnpackedSrcReg = (SrcMods & OpSelModifier)
684 ?
TRI->getSubReg(SrcMO.
getReg(), AMDGPU::sub1)
685 :
TRI->getSubReg(SrcMO.
getReg(), AMDGPU::sub0);
687 MachineOperand UnpackedSrcMO =
704 bool KillState =
true;
705 if ((OpSel == OpSelHi) && !IsHiBits)
709 NewMI.
add(UnpackedSrcMO);
712void SIPreEmitPeephole::collectUnpackingCandidates(
713 MachineInstr &BeginMI, SetVector<MachineInstr *> &InstrsToUnpack,
714 uint16_t NumMFMACycles) {
717 int TotalCyclesBetweenCandidates = 0;
718 auto SchedModel =
TII->getSchedModel();
723 uint32_t UnpackedOpCode = mapToUnpackedOpcode(Instr);
725 !(UnpackedOpCode == std::numeric_limits<uint32_t>::max());
726 if (
Instr.isMetaInstruction())
728 if ((
Instr.isTerminator()) ||
729 (
TII->isNeverCoissue(Instr) && !IsUnpackable) ||
731 Instr.modifiesRegister(AMDGPU::EXEC,
TRI)))
734 const MCSchedClassDesc *InstrSchedClassDesc =
738 TotalCyclesBetweenCandidates +=
Latency;
740 if (TotalCyclesBetweenCandidates >= NumMFMACycles - 1)
747 for (
const MachineOperand &InstrMO :
Instr.operands()) {
748 if (!InstrMO.isReg() || !InstrMO.getReg().isValid())
750 if (
TRI->regsOverlap(MFMADef, InstrMO.getReg()))
756 if (canUnpackingClobberRegister(Instr))
761 TotalCyclesBetweenCandidates -=
Latency;
763 TotalCyclesBetweenCandidates += 2;
765 if (TotalCyclesBetweenCandidates < NumMFMACycles - 1)
766 InstrsToUnpack.
insert(&Instr);
770void SIPreEmitPeephole::performF32Unpacking(MachineInstr &
I) {
771 const MachineOperand &DstOp =
I.getOperand(0);
773 uint32_t UnpackedOpcode = mapToUnpackedOpcode(
I);
774 assert(UnpackedOpcode != std::numeric_limits<uint32_t>::max() &&
775 "Unsupported Opcode");
777 MachineInstrBuilder Op0LOp1L =
778 createUnpackedMI(
I, UnpackedOpcode,
false);
779 MachineOperand LoDstOp = Op0LOp1L->
getOperand(0);
783 MachineInstrBuilder Op0HOp1H =
784 createUnpackedMI(
I, UnpackedOpcode,
true);
785 MachineOperand HiDstOp = Op0HOp1H->
getOperand(0);
787 uint32_t
IFlags =
I.getFlags();
796MachineInstrBuilder SIPreEmitPeephole::createUnpackedMI(MachineInstr &
I,
797 uint32_t UnpackedOpcode,
801 const MachineOperand *SrcMO0 =
TII->getNamedOperand(
I, AMDGPU::OpName::src0);
802 const MachineOperand *SrcMO1 =
TII->getNamedOperand(
I, AMDGPU::OpName::src1);
803 Register DstReg =
I.getOperand(0).getReg();
804 unsigned OpCode =
I.getOpcode();
805 Register UnpackedDstReg = IsHiBits ?
TRI->getSubReg(DstReg, AMDGPU::sub1)
806 :
TRI->getSubReg(DstReg, AMDGPU::sub0);
808 int64_t ClampVal =
TII->getNamedOperand(
I, AMDGPU::OpName::clamp)->getImm();
810 TII->getNamedOperand(
I, AMDGPU::OpName::src0_modifiers)->getImm();
812 TII->getNamedOperand(
I, AMDGPU::OpName::src1_modifiers)->getImm();
815 NewMI.
addDef(UnpackedDstReg);
816 addOperandAndMods(NewMI, Src0Mods, IsHiBits, *SrcMO0);
817 addOperandAndMods(NewMI, Src1Mods, IsHiBits, *SrcMO1);
820 const MachineOperand *SrcMO2 =
821 TII->getNamedOperand(
I, AMDGPU::OpName::src2);
823 TII->getNamedOperand(
I, AMDGPU::OpName::src2_modifiers)->getImm();
824 addOperandAndMods(NewMI, Src2Mods, IsHiBits, *SrcMO2);
837 SIPreEmitPeephole Impl;
839 if (Impl.run(MF, MLI)) {
850 TII = ST.getInstrInfo();
851 TRI = &
TII->getRegisterInfo();
862 if (TermI !=
MBB.end()) {
864 switch (
MI.getOpcode()) {
865 case AMDGPU::S_CBRANCH_VCCZ:
866 case AMDGPU::S_CBRANCH_VCCNZ:
869 case AMDGPU::S_CBRANCH_EXECZ:
875 if (!
ST.hasVGPRIndexMode())
878 MachineInstr *SetGPRMI =
nullptr;
879 const unsigned Threshold = 20;
887 if (
Count == Threshold)
892 if (
MI.getOpcode() != AMDGPU::S_SET_GPR_IDX_ON)
901 if (optimizeSetGPR(*SetGPRMI,
MI))
912 if (!
ST.hasGFX940Insts())
914 for (MachineBasicBlock &
MBB : MF) {
917 auto SchedModel =
TII->getSchedModel();
918 SetVector<MachineInstr *> InstrsToUnpack;
922 const MCSchedClassDesc *SchedClassDesc =
924 uint16_t NumMFMACycles =
926 collectUnpackingCandidates(
MI, InstrsToUnpack, NumMFMACycles);
928 for (MachineInstr *
MI : InstrsToUnpack) {
929 performF32Unpacking(*
MI);
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ReachingDefInfo InstSet & ToRemove
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
AMD GCN specific subclass of TargetSubtarget.
const HexagonInstrInfo * TII
Register const TargetRegisterInfo * TRI
Promote Memory to Register
OptimizedStructLayoutField Field
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
const SmallVectorImpl< MachineOperand > & Cond
static bool isProfitable(const StableFunctionMap::StableFunctionEntries &SFS)
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
AnalysisUsage & addUsedIfAvailable()
Add the specified Pass class to the set of analyses used by this pass.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static uint32_t getDenominator()
static constexpr BranchProbability getZero()
uint32_t getNumerator() const
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e....
bool contains(const LoopT *L) const
Return true if the specified loop is contained within this loop.
bool isInnermost() const
Return true if the loop does not contain any (natural) loops.
BlockT * getHeader() const
iterator_range< block_iterator > blocks() const
LoopT * getParentLoop() const
Return the parent loop if it exists or nullptr for top level loops.
LoopT * removeChildLoop(iterator I)
This removes the specified child from being a subloop of this loop.
Represents a single loop in the control flow graph.
LLVM_ABI MachineBasicBlock * getFallThrough(bool JumpToFallThrough=true)
Return the fallthrough block if the block can implicitly transfer control to the block after it by fa...
LLVM_ABI BranchProbability getSuccProbability(const_succ_iterator Succ) const
Return probability of the edge from this block to MBB.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
LLVM_ABI void removeSuccessor(MachineBasicBlock *Succ, bool NormalizeSuccProbs=false)
Remove successor from the successors list of this MachineBasicBlock.
Instructions::iterator instr_iterator
MachineInstrBundleIterator< MachineInstr, true > reverse_iterator
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
iterator_range< iterator > terminators()
iterator_range< succ_iterator > successors()
iterator_range< pred_iterator > predecessors()
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.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them.
BasicBlockListType::const_iterator const_iterator
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addDef(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
const MachineBasicBlock * getParent() const
void setFlags(unsigned flags)
const MachineOperand & getOperand(unsigned i) const
Analysis pass that exposes the MachineLoopInfo for a machine function.
LLVM_ABI void setIsRenamable(bool Val=true)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
void setIsKill(bool Val=true)
LLVM_ABI bool isRenamable() const
isRenamable - Returns true if this register may be renamed, i.e.
void setIsUndef(bool Val=true)
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)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static bool isMFMA(const MachineInstr &MI)
static bool modifiesModeRegister(const MachineInstr &MI)
Return true if the instruction modifies the mode register.q.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
bool insert(const value_type &X)
Insert a new element into the SetVector.
LLVM_ABI const MCSchedClassDesc * resolveSchedClass(const MachineInstr *MI) const
Return the MCSchedClassDesc for this instruction.
ProcResIter getWriteProcResBegin(const MCSchedClassDesc *SC) const
LLVM Value Representation.
self_iterator getIterator()
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_READONLY bool hasNamedOperand(uint64_t Opcode, OpName NamedIdx)
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
NodeAddr< InstrNode * > Instr
This is an optimization pass for GlobalISel generic memory operations.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
char & SIPreEmitPeepholeID
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
@ And
Bitwise or logical AND of integers.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
uint16_t ReleaseAtCycle
Cycle at which the resource will be released by an instruction, relatively to the cycle in which the ...