1//===---- PPCReduceCRLogicals.cpp - Reduce CR Bit Logical operations ------===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===---------------------------------------------------------------------===// 9// This pass aims to reduce the number of logical operations on bits in the CR 10// register. These instructions have a fairly high latency and only a single 11// pipeline at their disposal in modern PPC cores. Furthermore, they have a 12// tendency to occur in fairly small blocks where there's little opportunity 13// to hide the latency between the CR logical operation and its user. 15//===---------------------------------------------------------------------===// 26#include "llvm/Config/llvm-config.h" 32#define DEBUG_TYPE "ppc-reduce-cr-ops" 35"Number of single-use binary CR logical ops contained in a block");
37"Number of binary CR logical ops that can be used to split blocks");
38STATISTIC(TotalCRLogicals,
"Number of CR logical ops.");
40"Number of nullary CR logical ops (CRSET/CRUNSET).");
41STATISTIC(TotalUnaryCRLogicals,
"Number of unary CR logical ops.");
42STATISTIC(TotalBinaryCRLogicals,
"Number of CR logical ops.");
44"Number of blocks split on CR binary logical ops.");
46"Number of blocks not split due to operands being identical.");
48"Number of blocks not split due to operands being chained copies.");
50"Number of blocks not split due to the wrong opcode.");
52/// Given a basic block \p Successor that potentially contains PHIs, this 53/// function will look for any incoming values in the PHIs that are supposed to 54/// be coming from \p OrigMBB but whose definition is actually in \p NewMBB. 55/// Any such PHIs will be updated to reflect reality. 61// This is a really ugly-looking loop, but it was pillaged directly from 62// MachineBasicBlock::transferSuccessorsAndUpdatePHIs(). 63for (
unsigned i = 2, e =
MI.getNumOperands() + 1; i != e; i += 2) {
65if (MO.
getMBB() == OrigMBB) {
66// Check if the instruction is actually defined in NewMBB. 67if (
MI.getOperand(i - 1).isReg()) {
80/// Given a basic block \p Successor that potentially contains PHIs, this 81/// function will look for PHIs that have an incoming value from \p OrigMBB 82/// and will add the same incoming value from \p NewMBB. 83/// NOTE: This should only be used if \p NewMBB is an immediate dominator of 90"NewMBB must be a successor of OrigMBB");
94// This is a really ugly-looking loop, but it was pillaged directly from 95// MachineBasicBlock::transferSuccessorsAndUpdatePHIs(). 96for (
unsigned i = 2, e =
MI.getNumOperands() + 1; i != e; i += 2) {
98if (MO.
getMBB() == OrigMBB) {
131/// Splits a MachineBasicBlock to branch before \p SplitBefore. The original 132/// branch is \p OrigBranch. The target of the new branch can either be the same 133/// as the target of the original branch or the fallthrough successor of the 134/// original block as determined by \p BranchToFallThrough. The branch 135/// conditions will be inverted according to \p InvertNewBranch and 136/// \p InvertOrigBranch. If an instruction that previously fed the branch is to 137/// be deleted, it is provided in \p MIToDelete and \p NewCond will be used as 138/// the branch condition. The branch probabilities will be set if the 139/// MachineBranchProbabilityInfo isn't null. 142"All instructions must be in the same block.");
147assert(
MRI->isSSA() &&
"Can only do this while the function is in SSA form.");
150dbgs() <<
"Don't know how to handle blocks that don't have exactly" 151 <<
" two successors.\n");
157unsigned InvertedOpcode =
158 OrigBROpcode == PPC::BC
160 : OrigBROpcode == PPC::BCn
162 : OrigBROpcode == PPC::BCLR ? PPC::BCLRn : PPC::BCLR;
163unsigned NewBROpcode = BSI.
InvertNewBranch ? InvertedOpcode : OrigBROpcode;
171// It's impossible to know the precise branch probability after the split. 172// But it still needs to be reasonable, the whole probability to original 173// targets should not be changed. 174// After split NewBRTarget will get two incoming edges. Assume P0 is the 175// original branch probability to NewBRTarget, P1 and P2 are new branch 176// probabilies to NewBRTarget after split. If the two edge frequencies are 178// F * P1 = F * P0 / 2 ==> P1 = P0 / 2 179// F * (1 - P1) * P2 = F * P1 ==> P2 = P1 / (1 - P1) 187 ProbFallThrough = ProbToNewTarget.
getCompl();
188 ProbOrigFallThrough = ProbToNewTarget / ProbToNewTarget.
getCompl();
189 ProbOrigTarget = ProbOrigFallThrough.
getCompl();
192 ProbFallThrough = ProbToNewTarget.
getCompl();
193 ProbOrigTarget = ProbToNewTarget / ProbToNewTarget.
getCompl();
194 ProbOrigFallThrough = ProbOrigTarget.
getCompl();
198// Create a new basic block. 205// Move everything after SplitBefore into the new block. 206 NewMBB->
splice(NewMBB->
end(), ThisMBB, InsertPoint, ThisMBB->
end());
215// Add the two successors to ThisMBB. 219// Add the branches to ThisMBB. 221TII->get(NewBROpcode))
230// Change the condition on the original branch and invert it if requested. 233assert(FirstTerminator->getOperand(0).isReg() &&
234"Can't update condition of unconditional branch.");
238 FirstTerminator->setDesc(
TII->get(InvertedOpcode));
240// If any of the PHIs in the successors of NewMBB reference values that 241// now come from NewMBB, they need to be updated. 254returnMI.getNumOperands() == 3;
258returnMI.getNumOperands() == 1;
261/// Given a CR logical operation \p CROp, branch opcode \p BROp as well as 262/// a flag to indicate if the first operand of \p CROp is used as the 263/// SplitBefore operand, determines whether either of the branches are to be 264/// inverted as well as whether the new target should be the original 265/// fall-through block. 268bool &InvertNewBranch,
bool &InvertOrigBranch,
269bool &TargetIsFallThrough) {
270// The conditions under which each of the output operands should be [un]set 271// can certainly be written much more concisely with just 3 if statements or 272// ternary expressions. However, this provides a much clearer overview to the 273// reader as to what is set for each <CROp, BROp, OpUsed> combination. 274if (BROp == PPC::BC || BROp == PPC::BCLR) {
280 InvertNewBranch =
false;
281 InvertOrigBranch =
false;
282 TargetIsFallThrough =
false;
285 InvertNewBranch =
true;
286 InvertOrigBranch =
false;
287 TargetIsFallThrough =
true;
290 InvertNewBranch =
true;
291 InvertOrigBranch =
true;
292 TargetIsFallThrough =
false;
295 InvertNewBranch =
false;
296 InvertOrigBranch =
true;
297 TargetIsFallThrough =
true;
300 InvertNewBranch = UsingDef1;
301 InvertOrigBranch = !UsingDef1;
302 TargetIsFallThrough =
false;
305 InvertNewBranch = !UsingDef1;
306 InvertOrigBranch = !UsingDef1;
307 TargetIsFallThrough =
true;
310 }
elseif (BROp == PPC::BCn || BROp == PPC::BCLRn) {
316 InvertNewBranch =
true;
317 InvertOrigBranch =
false;
318 TargetIsFallThrough =
true;
321 InvertNewBranch =
false;
322 InvertOrigBranch =
false;
323 TargetIsFallThrough =
false;
326 InvertNewBranch =
false;
327 InvertOrigBranch =
true;
328 TargetIsFallThrough =
true;
331 InvertNewBranch =
true;
332 InvertOrigBranch =
true;
333 TargetIsFallThrough =
false;
336 InvertNewBranch = !UsingDef1;
337 InvertOrigBranch = !UsingDef1;
338 TargetIsFallThrough =
true;
341 InvertNewBranch = UsingDef1;
342 InvertOrigBranch = !UsingDef1;
343 TargetIsFallThrough =
false;
356structCRLogicalOpInfo {
358// FIXME: If chains of copies are to be handled, this should be a vector. 359 std::pair<MachineInstr*, MachineInstr*> CopyDefs;
360 std::pair<MachineInstr*, MachineInstr*> TrueDefs;
361unsigned IsBinary : 1;
362unsigned IsNullary : 1;
363unsigned ContainedInBlock : 1;
364unsigned FeedsISEL : 1;
366unsigned FeedsLogical : 1;
367unsigned SingleUse : 1;
368unsigned DefsSingleUse : 1;
371 CRLogicalOpInfo() :
MI(nullptr), IsBinary(0), IsNullary(0),
372 ContainedInBlock(0), FeedsISEL(0), FeedsBR(0),
373 FeedsLogical(0), SingleUse(0), DefsSingleUse(1),
374 SubregDef1(0), SubregDef2(0) { }
384// A vector to contain all the CR logical operations 387void collectCRLogicals();
388bool handleCROp(
unsignedIdx);
389bool splitBlockOnBinaryCROp(CRLogicalOpInfo &CRI);
391unsigned Opc =
MI.getOpcode();
392return Opc == PPC::CRAND || Opc == PPC::CRNAND || Opc == PPC::CROR ||
393 Opc == PPC::CRXOR || Opc == PPC::CRNOR || Opc == PPC::CRNOT ||
394 Opc == PPC::CREQV || Opc == PPC::CRANDC || Opc == PPC::CRORC ||
395 Opc == PPC::CRSET || Opc == PPC::CRUNSET || Opc == PPC::CR6SET ||
396 Opc == PPC::CR6UNSET;
400// Not using a range-based for loop here as the vector may grow while being 402for (
unsigned i = 0; i < AllCRLogicalOps.
size(); i++)
403 Changed |= handleCROp(i);
412MachineInstr *lookThroughCRCopy(
unsigned Reg,
unsigned &Subreg,
418// If the subtarget doesn't use CR bits, there's nothing to do. 425return simplifyCode();
435#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 437dbgs() <<
"CRLogicalOpMI: ";
439dbgs() <<
"IsBinary: " << IsBinary <<
", FeedsISEL: " << FeedsISEL;
440dbgs() <<
", FeedsBR: " << FeedsBR <<
", FeedsLogical: ";
441dbgs() << FeedsLogical <<
", SingleUse: " << SingleUse;
442dbgs() <<
", DefsSingleUse: " << DefsSingleUse;
443dbgs() <<
", SubregDef1: " << SubregDef1 <<
", SubregDef2: ";
444dbgs() << SubregDef2 <<
", ContainedInBlock: " << ContainedInBlock;
447 TrueDefs.first->dump();
450 TrueDefs.second->dump();
453dbgs() <<
"CopyDef1: ";
454 CopyDefs.first->dump();
456if (CopyDefs.second) {
457dbgs() <<
"CopyDef2: ";
458 CopyDefs.second->dump();
463PPCReduceCRLogicals::CRLogicalOpInfo
464PPCReduceCRLogicals::createCRLogicalOpInfo(
MachineInstr &MIParam) {
470Ret.TrueDefs = std::make_pair(
nullptr,
nullptr);
471Ret.CopyDefs = std::make_pair(
nullptr,
nullptr);
474Ret.SubregDef1,
Ret.CopyDefs.first);
475assert(Def1 &&
"Must be able to find a definition of operand 1.");
479MRI->hasOneNonDBGUse(
Ret.CopyDefs.first->getOperand(0).getReg());
485assert(Def2 &&
"Must be able to find a definition of operand 2.");
489MRI->hasOneNonDBGUse(
Ret.CopyDefs.second->getOperand(0).getReg());
490Ret.TrueDefs = std::make_pair(Def1, Def2);
492Ret.TrueDefs = std::make_pair(Def1,
nullptr);
493Ret.CopyDefs.second =
nullptr;
497Ret.ContainedInBlock = 1;
501unsigned Opc =
UseMI.getOpcode();
502if (Opc == PPC::ISEL || Opc == PPC::ISEL8)
504if (Opc == PPC::BC || Opc == PPC::BCn || Opc == PPC::BCLR ||
507Ret.FeedsLogical = isCRLogical(
UseMI);
509Ret.ContainedInBlock = 0;
513// We now know whether all the uses of the CR logical are in the same block. 515Ret.ContainedInBlock &=
516 (MIParam.
getParent() ==
Ret.TrueDefs.first->getParent());
518Ret.ContainedInBlock &=
519 (MIParam.
getParent() ==
Ret.TrueDefs.second->getParent());
522if (
Ret.IsBinary &&
Ret.ContainedInBlock &&
Ret.SingleUse) {
523 NumContainedSingleUseBinOps++;
524if (
Ret.FeedsBR &&
Ret.DefsSingleUse)
530/// Looks through a COPY instruction to the actual definition of the CR-bit 531/// register and returns the instruction that defines it. 532/// FIXME: This currently handles what is by-far the most common case: 533/// an instruction that defines a CR field followed by a single copy of a bit 534/// from that field into a virtual register. If chains of copies need to be 535/// handled, this should have a loop until a non-copy instruction is found. 536MachineInstr *PPCReduceCRLogicals::lookThroughCRCopy(
unsigned Reg,
547 Subreg =
Copy->getOperand(1).getSubReg();
551if (CopySrc == PPC::CR0EQ || CopySrc == PPC::CR6EQ)
552 Subreg = PPC::sub_eq;
553if (CopySrc == PPC::CR0LT || CopySrc == PPC::CR6LT)
554 Subreg = PPC::sub_lt;
555if (CopySrc == PPC::CR0GT || CopySrc == PPC::CR6GT)
556 Subreg = PPC::sub_gt;
557if (CopySrc == PPC::CR0UN || CopySrc == PPC::CR6UN)
558 Subreg = PPC::sub_un;
559// Loop backwards and return the first MI that modifies the physical CR Reg. 562if ((--Me)->modifiesRegister(CopySrc,
TRI))
566returnMRI->getVRegDef(CopySrc);
573 MBPI = &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
575 AllCRLogicalOps.
clear();
578/// Contains all the implemented transformations on CR logical operations. 579/// For example, a binary CR logical can be used to split a block on its inputs, 580/// a unary CR logical might be used to change the condition code on a 581/// comparison feeding it. A nullary CR logical might simply be removable 582/// if the user of the bit it [un]sets can be transformed. 583bool PPCReduceCRLogicals::handleCROp(
unsignedIdx) {
584// We can definitely split a block on the inputs to a binary CR operation 585// whose defs and (single) use are within the same block. 587 CRLogicalOpInfo CRI = AllCRLogicalOps[
Idx];
588if (CRI.IsBinary && CRI.ContainedInBlock && CRI.SingleUse && CRI.FeedsBR &&
590 Changed = splitBlockOnBinaryCROp(CRI);
592 NumBlocksSplitOnBinaryCROp++;
597/// Splits a block that contains a CR-logical operation that feeds a branch 598/// and whose operands are produced within the block. 600/// %vr5<def> = CMPDI %vr2, 0; CRRC:%vr5 G8RC:%vr2 601/// %vr6<def> = COPY %vr5:sub_eq; CRBITRC:%vr6 CRRC:%vr5 602/// %vr7<def> = CMPDI %vr3, 0; CRRC:%vr7 G8RC:%vr3 603/// %vr8<def> = COPY %vr7:sub_eq; CRBITRC:%vr8 CRRC:%vr7 604/// %vr9<def> = CROR %vr6<kill>, %vr8<kill>; CRBITRC:%vr9,%vr6,%vr8 605/// BC %vr9<kill>, <BB#2>; CRBITRC:%vr9 607/// %vr5<def> = CMPDI %vr2, 0; CRRC:%vr5 G8RC:%vr2 608/// %vr6<def> = COPY %vr5:sub_eq; CRBITRC:%vr6 CRRC:%vr5 609/// BC %vr6<kill>, <BB#2>; CRBITRC:%vr6 611/// %vr7<def> = CMPDI %vr3, 0; CRRC:%vr7 G8RC:%vr3 612/// %vr8<def> = COPY %vr7:sub_eq; CRBITRC:%vr8 CRRC:%vr7 613/// BC %vr9<kill>, <BB#2>; CRBITRC:%vr9 614bool PPCReduceCRLogicals::splitBlockOnBinaryCROp(CRLogicalOpInfo &CRI) {
615if (CRI.CopyDefs.first == CRI.CopyDefs.second) {
616LLVM_DEBUG(
dbgs() <<
"Unable to split as the two operands are the same\n");
617 NumNotSplitIdenticalOperands++;
620if (CRI.TrueDefs.first->isCopy() || CRI.TrueDefs.second->isCopy() ||
621 CRI.TrueDefs.first->isPHI() || CRI.TrueDefs.second->isPHI()) {
623dbgs() <<
"Unable to split because one of the operands is a PHI or " 624"chain of copies.\n");
625 NumNotSplitChainCopies++;
628// Note: keep in sync with computeBranchTargetAndInversion(). 629if (CRI.MI->getOpcode() != PPC::CROR &&
630 CRI.MI->getOpcode() != PPC::CRAND &&
631 CRI.MI->getOpcode() != PPC::CRNOR &&
632 CRI.MI->getOpcode() != PPC::CRNAND &&
633 CRI.MI->getOpcode() != PPC::CRORC &&
634 CRI.MI->getOpcode() != PPC::CRANDC) {
636 NumNotSplitWrongOpcode++;
639LLVM_DEBUG(
dbgs() <<
"Splitting the following CR op:\n"; CRI.dump());
643bool UsingDef1 =
false;
645for (
auto E = CRI.MI->getParent()->end(); Def2It != E; ++Def2It) {
646if (Def1It == Def2It) {
// Def2 comes before Def1. 647 SplitBefore = &*Def1It;
657// Get the branch instruction. 659MRI->use_nodbg_begin(CRI.MI->getOperand(0).getReg())->getParent();
661// We want the new block to have no code in it other than the definition 662// of the input to the CR logical and the CR logical itself. So we move 663// those to the bottom of the block (just before the branch). Then we 664// will split before the CR logical. 668 UsingDef1 ? CRI.TrueDefs.first : CRI.TrueDefs.second;
670 UsingDef1 ? CRI.CopyDefs.first : CRI.CopyDefs.second;
672// The instructions that need to be moved are not guaranteed to be 673// contiguous. Move them individually. 674// FIXME: If one of the operands is a chain of (single use) copies, they 675// can all be moved and we can still split. 677if (FirstInstrToMove != SecondInstrToMove)
681unsigned Opc = CRI.MI->getOpcode();
682bool InvertOrigBranch, InvertNewBranch, TargetIsFallThrough;
684 InvertNewBranch, InvertOrigBranch,
685 TargetIsFallThrough);
687 UsingDef1 ? CRI.CopyDefs.second : CRI.CopyDefs.first;
688LLVM_DEBUG(
dbgs() <<
"We will " << (InvertNewBranch ?
"invert" :
"copy"));
690 << (TargetIsFallThrough ?
"fallthrough block\n" 691 :
"orig. target block\n"));
694 InvertOrigBranch, TargetIsFallThrough, MBPI, CRI.MI,
695 UsingDef1 ? CRI.CopyDefs.first : CRI.CopyDefs.second };
697// If we've split on a CR logical that is fed by a CR logical, 698// recompute the source CR logical as it may be usable for splitting. 700bool Input1CRlogical =
701 CRI.TrueDefs.first && isCRLogical(*CRI.TrueDefs.first);
702bool Input2CRlogical =
703 CRI.TrueDefs.second && isCRLogical(*CRI.TrueDefs.second);
705 AllCRLogicalOps.
push_back(createCRLogicalOpInfo(*CRI.TrueDefs.first));
707 AllCRLogicalOps.
push_back(createCRLogicalOpInfo(*CRI.TrueDefs.second));
712void PPCReduceCRLogicals::collectCRLogicals() {
715if (isCRLogical(
MI)) {
716 AllCRLogicalOps.
push_back(createCRLogicalOpInfo(
MI));
718if (AllCRLogicalOps.
back().IsNullary)
719 TotalNullaryCRLogicals++;
720elseif (AllCRLogicalOps.
back().IsBinary)
721 TotalBinaryCRLogicals++;
723 TotalUnaryCRLogicals++;
729}
// end anonymous namespace 732"PowerPC Reduce CR logical Operation",
false,
false)
737char PPCReduceCRLogicals::
ID = 0;
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
const HexagonInstrInfo * TII
unsigned const TargetRegisterInfo * TRI
static bool isBinary(MachineInstr &MI)
PowerPC Reduce CR logical Operation
static bool isNullary(MachineInstr &MI)
static bool splitMBB(BlockSplitInfo &BSI)
Splits a MachineBasicBlock to branch before SplitBefore.
static void computeBranchTargetAndInversion(unsigned CROp, unsigned BROp, bool UsingDef1, bool &InvertNewBranch, bool &InvertOrigBranch, bool &TargetIsFallThrough)
Given a CR logical operation CROp, branch opcode BROp as well as a flag to indicate if the first oper...
static void addIncomingValuesToPHIs(MachineBasicBlock *Successor, MachineBasicBlock *OrigMBB, MachineBasicBlock *NewMBB, MachineRegisterInfo *MRI)
Given a basic block Successor that potentially contains PHIs, this function will look for PHIs that h...
static void updatePHIs(MachineBasicBlock *Successor, MachineBasicBlock *OrigMBB, MachineBasicBlock *NewMBB, MachineRegisterInfo *MRI)
Given a basic block Successor that potentially contains PHIs, this function will look for any incomin...
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
LLVM Basic Block Representation.
static BranchProbability getUnknown()
BranchProbability getCompl() const
FunctionPass class - This class is used to implement most global optimizations.
bool skipFunction(const Function &F) const
Optional passes call this function to check whether the pass should be skipped.
void transferSuccessors(MachineBasicBlock *FromMBB)
Transfers all the successors from MBB to this machine basic block (i.e., copies all the successors Fr...
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
void setSuccProbability(succ_iterator I, BranchProbability Prob)
Set successor probability of a given iterator.
succ_iterator succ_begin()
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
unsigned succ_size() const
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
succ_reverse_iterator succ_rbegin()
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
iterator_range< succ_iterator > successors()
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
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 '...
BranchProbability getEdgeProbability(const MachineBasicBlock *Src, const MachineBasicBlock *Dst) const
Analysis pass which computes a MachineDominatorTree.
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.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
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.
Function & getFunction()
Return the LLVM function that this machine code represents.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
void insert(iterator MBBI, MachineBasicBlock *MBB)
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
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
MachineBasicBlock * getMBB() const
void setMBB(MachineBasicBlock *MBB)
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
static constexpr bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
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.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
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.
void initializePPCReduceCRLogicalsPass(PassRegistry &)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createPPCReduceCRLogicalsPass()
MachineInstr * SplitBefore
MachineInstr * OrigBranch
MachineInstr * MIToDelete
bool allInstrsInSameMBB()
const MachineBranchProbabilityInfo * MBPI