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 {
195 const bool IsWave32 =
ST.isWave32();
196 const unsigned CondReg =
TRI->getVCC();
197 const unsigned ExecReg = IsWave32 ? AMDGPU::EXEC_LO : AMDGPU::EXEC;
198 const unsigned And = IsWave32 ? AMDGPU::S_AND_B32 : AMDGPU::S_AND_B64;
199 const unsigned AndN2 = IsWave32 ? AMDGPU::S_ANDN2_B32 : AMDGPU::S_ANDN2_B64;
200 const unsigned Mov = IsWave32 ? AMDGPU::S_MOV_B32 : AMDGPU::S_MOV_B64;
204 bool ReadsCond =
false;
205 unsigned Threshold = 5;
206 for (++
A;
A !=
E; ++
A) {
209 if (
A->modifiesRegister(ExecReg,
TRI))
211 if (
A->modifiesRegister(CondReg,
TRI)) {
212 if (!
A->definesRegister(CondReg,
TRI) ||
213 (
A->getOpcode() !=
And &&
A->getOpcode() != AndN2))
217 ReadsCond |=
A->readsRegister(CondReg,
TRI);
222 MachineOperand &Op1 =
A->getOperand(1);
223 MachineOperand &Op2 =
A->getOperand(2);
225 Op2.
getReg() == ExecReg) {
226 TII->commuteInstruction(*
A);
234 int64_t MaskValue = 0;
238 auto M = std::next(
A);
239 bool ReadsSreg =
false;
240 bool ModifiesExec =
false;
241 for (;
M !=
E; ++
M) {
242 if (
M->definesRegister(SReg,
TRI))
244 if (
M->modifiesRegister(SReg,
TRI))
246 ReadsSreg |=
M->readsRegister(SReg,
TRI);
247 ModifiesExec |=
M->modifiesRegister(ExecReg,
TRI);
256 if (
A->getOpcode() ==
And && SReg == CondReg && !ModifiesExec &&
257 TII->isVOPC(*M) &&
A->allImplicitDefsAreDead()) {
258 A->eraseFromParent();
262 if (!
M->isMoveImmediate() || !
M->getOperand(1).isImm() ||
263 (
M->getOperand(1).getImm() != -1 &&
M->getOperand(1).getImm() != 0))
265 MaskValue =
M->getOperand(1).getImm();
268 if (!ReadsSreg && Op2.
isKill()) {
269 A->getOperand(2).ChangeToImmediate(MaskValue);
270 M->eraseFromParent();
272 }
else if (Op2.
isImm()) {
279 assert(MaskValue == 0 || MaskValue == -1);
280 if (
A->getOpcode() == AndN2)
281 MaskValue = ~MaskValue;
283 if (!ReadsCond &&
A->registerDefIsDead(AMDGPU::SCC,
nullptr)) {
284 if (!
MI.killsRegister(CondReg,
TRI)) {
286 if (MaskValue == 0) {
287 BuildMI(*
A->getParent(), *
A,
A->getDebugLoc(),
TII->get(Mov), CondReg)
290 BuildMI(*
A->getParent(), *
A,
A->getDebugLoc(),
TII->get(Mov), CondReg)
295 A->eraseFromParent();
298 bool IsVCCZ =
MI.getOpcode() == AMDGPU::S_CBRANCH_VCCZ;
299 if (SReg == ExecReg) {
302 MI.eraseFromParent();
305 MI.setDesc(
TII->get(AMDGPU::S_BRANCH));
306 }
else if (IsVCCZ && MaskValue == 0) {
309 MachineBasicBlock *Parent =
MI.getParent();
310 SmallVector<MachineInstr *, 4>
ToRemove;
317 Found =
Term.isIdenticalTo(
MI);
320 assert(Found &&
"conditional branch is not terminator");
322 MachineOperand &Dst = BranchMI->getOperand(0);
323 assert(Dst.isMBB() &&
"destination is not basic block");
324 updateMLIBeforeRemovingEdge(Parent, Dst.getMBB());
326 BranchMI->eraseFromParent();
330 updateMLIBeforeRemovingEdge(Parent, Succ);
335 MI.setDesc(
TII->get(AMDGPU::S_BRANCH));
336 }
else if (!IsVCCZ && MaskValue == 0) {
338 MachineOperand &Dst =
MI.getOperand(0);
339 assert(Dst.isMBB() &&
"destination is not basic block");
341 updateMLIBeforeRemovingEdge(Parent, Dst.getMBB());
343 MI.eraseFromParent();
345 }
else if (MaskValue == -1) {
348 TII->get(IsVCCZ ? AMDGPU::S_CBRANCH_EXECZ : AMDGPU::S_CBRANCH_EXECNZ));
351 MI.removeOperand(
MI.findRegisterUseOperandIdx(CondReg,
TRI,
false ));
357bool SIPreEmitPeephole::optimizeSetGPR(MachineInstr &
First,
358 MachineInstr &
MI)
const {
361 const MachineRegisterInfo &MRI = MF.
getRegInfo();
362 MachineOperand *Idx =
TII->getNamedOperand(
MI, AMDGPU::OpName::src0);
364 SmallVector<MachineInstr *, 4>
ToRemove;
372 E =
MI.getIterator();
374 if (
I->isBundle() ||
I->isDebugInstr())
376 switch (
I->getOpcode()) {
377 case AMDGPU::S_SET_GPR_IDX_MODE:
379 case AMDGPU::S_SET_GPR_IDX_OFF:
384 if (
I->modifiesRegister(AMDGPU::M0,
TRI))
386 if (IdxReg &&
I->modifiesRegister(IdxReg,
TRI))
388 if (
llvm::any_of(
I->operands(), [&MRI,
this](
const MachineOperand &MO) {
389 return MO.isReg() && TRI->isVectorRegister(MRI, MO.getReg());
393 if (!IdxOn || !(
I->getOpcode() == AMDGPU::V_MOV_B32_indirect_write ||
394 I->getOpcode() == AMDGPU::V_MOV_B32_indirect_read))
400 MI.eraseFromBundle();
402 RI->eraseFromBundle();
406bool SIPreEmitPeephole::getBlockDestinations(
407 MachineBasicBlock &SrcMBB, MachineBasicBlock *&TrueMBB,
408 MachineBasicBlock *&FalseMBB, SmallVectorImpl<MachineOperand> &
Cond) {
419class BranchWeightCostModel {
420 const SIInstrInfo &
TII;
421 const TargetSchedModel &SchedModel;
422 BranchProbability BranchProb;
423 static constexpr uint64_t BranchNotTakenCost = 1;
428 BranchWeightCostModel(
const SIInstrInfo &
TII,
const MachineInstr &Branch,
429 const MachineBasicBlock &Succ)
430 :
TII(
TII), SchedModel(
TII.getSchedModel()) {
431 const MachineBasicBlock &Head = *
Branch.getParent();
438 BranchTakenCost = SchedModel.computeInstrLatency(&Branch);
442 if (
TII.isWaitcnt(
MI.getOpcode()))
445 ThenCyclesCost += SchedModel.computeInstrLatency(&
MI);
457 return (Denominator - Numerator) * ThenCyclesCost <=
458 ((Denominator - Numerator) * BranchTakenCost +
459 Numerator * BranchNotTakenCost);
463bool SIPreEmitPeephole::mustRetainExeczBranch(
464 const MachineInstr &Branch,
const MachineBasicBlock &From,
465 const MachineBasicBlock &To)
const {
467 BranchWeightCostModel CostModel{*
TII,
Branch, From};
472 const MachineBasicBlock &
MBB = *
MBBI;
474 for (
const MachineInstr &
MI :
MBB) {
478 if (
MI.isConditionalBranch())
481 if (
MI.isUnconditionalBranch() &&
485 if (
MI.isMetaInstruction())
488 if (
TII->hasUnwantedEffectsWhenEXECEmpty(
MI))
491 if (!CostModel.isProfitable(
MI))
501bool SIPreEmitPeephole::removeExeczBranch(MachineInstr &
MI,
502 MachineBasicBlock &SrcMBB) {
504 if (!
TII->getSchedModel().hasInstrSchedModel())
507 MachineBasicBlock *TrueMBB =
nullptr;
508 MachineBasicBlock *FalseMBB =
nullptr;
511 if (!getBlockDestinations(SrcMBB, TrueMBB, FalseMBB,
Cond))
519 if (mustRetainExeczBranch(
MI, *FalseMBB, *TrueMBB))
523 MI.eraseFromParent();
540bool SIPreEmitPeephole::removeRedundantModeWrites(
541 MachineBasicBlock &SrcMBB)
const {
543 ModeFieldState DenormMode;
544 ModeFieldState RoundMode;
547 if (
MI.isDebugInstr())
550 unsigned Opc =
MI.getOpcode();
551 if (
Opc == AMDGPU::S_DENORM_MODE ||
Opc == AMDGPU::S_ROUND_MODE) {
552 ModeFieldState &
Field =
553 Opc == AMDGPU::S_DENORM_MODE ? DenormMode : RoundMode;
554 int64_t NewValue =
MI.getOperand(0).getImm();
556 if (
Field.PendingWrite) {
558 << *
Field.PendingWrite);
559 Field.PendingWrite->eraseFromParent();
560 ++NumModeWritesRemoved;
562 Field.PendingWrite =
nullptr;
566 if (
Field.Value == NewValue) {
568 MI.eraseFromParent();
569 ++NumModeWritesRemoved;
576 Field.Value = NewValue;
581 if (!DenormMode.isTracked() && !RoundMode.isTracked())
585 if (
MI.isInlineAsm() ||
MI.modifiesRegister(AMDGPU::MODE,
TRI)) {
586 DenormMode = ModeFieldState();
587 RoundMode = ModeFieldState();
591 if (
MI.readsRegister(AMDGPU::MODE,
TRI) ||
MI.hasUnmodeledSideEffects()) {
592 DenormMode.PendingWrite =
nullptr;
593 RoundMode.PendingWrite =
nullptr;
599bool SIPreEmitPeephole::canUnpackingClobberRegister(
const MachineInstr &
MI) {
609 Register UnpackedDstReg =
TRI->getSubReg(DstReg, AMDGPU::sub0);
611 const MachineOperand *Src0MO =
TII->getNamedOperand(
MI, AMDGPU::OpName::src0);
612 if (Src0MO && Src0MO->
isReg()) {
615 TII->getNamedOperand(
MI, AMDGPU::OpName::src0_modifiers)->getImm();
617 ?
TRI->getSubReg(SrcReg0, AMDGPU::sub1)
618 :
TRI->getSubReg(SrcReg0, AMDGPU::sub0);
621 if (
TRI->regsOverlap(UnpackedDstReg, HiSrc0Reg))
625 const MachineOperand *Src1MO =
TII->getNamedOperand(
MI, AMDGPU::OpName::src1);
626 if (Src1MO && Src1MO->
isReg()) {
629 TII->getNamedOperand(
MI, AMDGPU::OpName::src1_modifiers)->getImm();
631 ?
TRI->getSubReg(SrcReg1, AMDGPU::sub1)
632 :
TRI->getSubReg(SrcReg1, AMDGPU::sub0);
633 if (
TRI->regsOverlap(UnpackedDstReg, HiSrc1Reg))
640 const MachineOperand *Src2MO =
641 TII->getNamedOperand(
MI, AMDGPU::OpName::src2);
642 if (Src2MO && Src2MO->
isReg()) {
645 TII->getNamedOperand(
MI, AMDGPU::OpName::src2_modifiers)->getImm();
647 ?
TRI->getSubReg(SrcReg2, AMDGPU::sub1)
648 :
TRI->getSubReg(SrcReg2, AMDGPU::sub0);
649 if (
TRI->regsOverlap(UnpackedDstReg, HiSrc2Reg))
656uint32_t SIPreEmitPeephole::mapToUnpackedOpcode(MachineInstr &
I) {
657 unsigned Opcode =
I.getOpcode();
662 case AMDGPU::V_PK_ADD_F32:
663 case AMDGPU::V_PK_ADD_F32_gfx1250:
664 return AMDGPU::V_ADD_F32_e64;
665 case AMDGPU::V_PK_MUL_F32:
666 case AMDGPU::V_PK_MUL_F32_gfx1250:
667 return AMDGPU::V_MUL_F32_e64;
668 case AMDGPU::V_PK_FMA_F32:
669 case AMDGPU::V_PK_FMA_F32_gfx1250:
670 return AMDGPU::V_FMA_F32_e64;
672 return std::numeric_limits<uint32_t>::max();
677void SIPreEmitPeephole::addOperandAndMods(MachineInstrBuilder &NewMI,
678 unsigned SrcMods,
bool IsHiBits,
679 const MachineOperand &SrcMO) {
680 unsigned NewSrcMods = 0;
692 if (SrcMods & NegModifier)
703 Register UnpackedSrcReg = (SrcMods & OpSelModifier)
704 ?
TRI->getSubReg(SrcMO.
getReg(), AMDGPU::sub1)
705 :
TRI->getSubReg(SrcMO.
getReg(), AMDGPU::sub0);
707 MachineOperand UnpackedSrcMO =
724 bool KillState =
true;
725 if ((OpSel == OpSelHi) && !IsHiBits)
729 NewMI.
add(UnpackedSrcMO);
732void SIPreEmitPeephole::collectUnpackingCandidates(
733 MachineInstr &BeginMI, SetVector<MachineInstr *> &InstrsToUnpack,
734 uint16_t NumMFMACycles) {
737 int TotalCyclesBetweenCandidates = 0;
738 auto SchedModel =
TII->getSchedModel();
743 uint32_t UnpackedOpCode = mapToUnpackedOpcode(Instr);
745 !(UnpackedOpCode == std::numeric_limits<uint32_t>::max());
746 if (
Instr.isMetaInstruction())
748 if ((
Instr.isTerminator()) ||
749 (
TII->isNeverCoissue(Instr) && !IsUnpackable) ||
751 Instr.modifiesRegister(AMDGPU::EXEC,
TRI)))
754 const MCSchedClassDesc *InstrSchedClassDesc =
758 TotalCyclesBetweenCandidates +=
Latency;
760 if (TotalCyclesBetweenCandidates >= NumMFMACycles - 1)
767 for (
const MachineOperand &InstrMO :
Instr.operands()) {
768 if (!InstrMO.isReg() || !InstrMO.getReg().isValid())
770 if (
TRI->regsOverlap(MFMADef, InstrMO.getReg()))
776 if (canUnpackingClobberRegister(Instr))
781 TotalCyclesBetweenCandidates -=
Latency;
783 TotalCyclesBetweenCandidates += 2;
785 if (TotalCyclesBetweenCandidates < NumMFMACycles - 1)
786 InstrsToUnpack.
insert(&Instr);
790void SIPreEmitPeephole::performF32Unpacking(MachineInstr &
I) {
791 const MachineOperand &DstOp =
I.getOperand(0);
793 uint32_t UnpackedOpcode = mapToUnpackedOpcode(
I);
794 assert(UnpackedOpcode != std::numeric_limits<uint32_t>::max() &&
795 "Unsupported Opcode");
797 MachineInstrBuilder Op0LOp1L =
798 createUnpackedMI(
I, UnpackedOpcode,
false);
799 MachineOperand LoDstOp = Op0LOp1L->
getOperand(0);
803 MachineInstrBuilder Op0HOp1H =
804 createUnpackedMI(
I, UnpackedOpcode,
true);
805 MachineOperand HiDstOp = Op0HOp1H->
getOperand(0);
807 uint32_t
IFlags =
I.getFlags();
816MachineInstrBuilder SIPreEmitPeephole::createUnpackedMI(MachineInstr &
I,
817 uint32_t UnpackedOpcode,
821 const MachineOperand *SrcMO0 =
TII->getNamedOperand(
I, AMDGPU::OpName::src0);
822 const MachineOperand *SrcMO1 =
TII->getNamedOperand(
I, AMDGPU::OpName::src1);
823 Register DstReg =
I.getOperand(0).getReg();
824 unsigned OpCode =
I.getOpcode();
825 Register UnpackedDstReg = IsHiBits ?
TRI->getSubReg(DstReg, AMDGPU::sub1)
826 :
TRI->getSubReg(DstReg, AMDGPU::sub0);
828 int64_t ClampVal =
TII->getNamedOperand(
I, AMDGPU::OpName::clamp)->getImm();
830 TII->getNamedOperand(
I, AMDGPU::OpName::src0_modifiers)->getImm();
832 TII->getNamedOperand(
I, AMDGPU::OpName::src1_modifiers)->getImm();
835 NewMI.
addDef(UnpackedDstReg);
836 addOperandAndMods(NewMI, Src0Mods, IsHiBits, *SrcMO0);
837 addOperandAndMods(NewMI, Src1Mods, IsHiBits, *SrcMO1);
840 const MachineOperand *SrcMO2 =
841 TII->getNamedOperand(
I, AMDGPU::OpName::src2);
843 TII->getNamedOperand(
I, AMDGPU::OpName::src2_modifiers)->getImm();
844 addOperandAndMods(NewMI, Src2Mods, IsHiBits, *SrcMO2);
857 SIPreEmitPeephole Impl;
859 if (Impl.run(MF, MLI)) {
870 TII = ST.getInstrInfo();
871 TRI = &
TII->getRegisterInfo();
882 if (TermI !=
MBB.end()) {
884 switch (
MI.getOpcode()) {
885 case AMDGPU::S_CBRANCH_VCCZ:
886 case AMDGPU::S_CBRANCH_VCCNZ:
889 case AMDGPU::S_CBRANCH_EXECZ:
895 if (!
ST.hasVGPRIndexMode())
898 MachineInstr *SetGPRMI =
nullptr;
899 const unsigned Threshold = 20;
907 if (
Count == Threshold)
912 if (
MI.getOpcode() != AMDGPU::S_SET_GPR_IDX_ON)
921 if (optimizeSetGPR(*SetGPRMI,
MI))
932 if (!
ST.hasGFX940Insts())
934 for (MachineBasicBlock &
MBB : MF) {
937 auto SchedModel =
TII->getSchedModel();
938 SetVector<MachineInstr *> InstrsToUnpack;
942 const MCSchedClassDesc *SchedClassDesc =
944 uint16_t NumMFMACycles =
946 collectUnpackingCandidates(
MI, InstrsToUnpack, NumMFMACycles);
948 for (MachineInstr *
MI : InstrsToUnpack) {
949 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)
DXILDebugInfoMap run(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 ...