33 if (Preheader == Loop)
47 auto InsertPt = NewBB->
end();
50 NewBB->insert(InsertPt, NewMI);
65 if (
Use.getParent()->getParent() != Loop)
67 for (
auto *
Use : Uses) {
75 for (
auto I = NewBB->getFirstNonPHI();
I != NewBB->end(); ++
I)
77 if (MO.isReg() && Remaps.
count(MO.getReg()))
78 MO.setReg(Remaps[MO.getReg()]);
80 for (
auto I = NewBB->begin();
I->isPHI(); ++
I) {
82 unsigned LoopRegIdx = 3, InitRegIdx = 1;
85 MachineInstr &OrigPhi = findEquivalentInstruction(MI, Loop);
109 NewBB->addSuccessor(Loop);
110 Loop->replacePhiUsesWith(Preheader, NewBB);
116 Loop->replaceSuccessor(Exit, NewBB);
117 Exit->replacePhiUsesWith(Loop, NewBB);
118 NewBB->addSuccessor(Exit);
122 bool CanAnalyzeBr = !TII->
analyzeBranch(*Loop, TBB, FBB, Cond);
124 assert(CanAnalyzeBr &&
"Must be able to analyze the loop branch!");
127 FBB == Exit ? NewBB : FBB, Cond, DL);
139 for (
auto *MBB : ExitBlocks)
140 if (MBB->isLiveIn(PhysReg))
instr_iterator instr_begin()
MachineBasicBlock * getMBB() const
This class represents lattice values for constants.
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
void push_back(const T &Elt)
virtual unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const
Insert branch code into the end of the specified MachineBasicBlock.
bool isRegLiveInExitBlocks(MachineLoop *Loop, int PhysReg)
Return true if PhysReg is live outside the loop, i.e.
Peel the first iteration of the loop.
virtual unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const
Remove the branching code at the end of the specific MBB.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
const HexagonInstrInfo * TII
A Use represents the edge between a Value definition and its users.
Direction
An enum for the direction of the loop.
void getExitBlocks(SmallVectorImpl< BlockT *> &ExitBlocks) const
Return all of the successor blocks of this loop.
bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
void setReg(Register Reg)
Change the register this operand corresponds to.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
TargetInstrInfo - Interface to description of machine instruction set.
unsigned const MachineRegisterInfo * MRI
iterator_range< mop_iterator > defs()
Returns a range over all explicit operands that are register definitions.
self_iterator getIterator()
succ_iterator succ_begin()
virtual bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e...
pred_iterator pred_begin()
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
iterator_range< use_iterator > use_operands(unsigned Reg) const
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Peel the last iteration of the loop.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
void replaceSuccessor(MachineBasicBlock *Old, MachineBasicBlock *New)
Replace successor OLD with NEW and update probability info.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
Represents a single loop in the control flow graph.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Instructions::iterator instr_iterator
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void insert(iterator MBBI, MachineBasicBlock *MBB)
void RemoveOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
MachineBasicBlock * PeelSingleBlockLoop(LoopPeelDirection Direction, MachineBasicBlock *Loop, MachineRegisterInfo &MRI, const TargetInstrInfo *TII)
Peels a single block loop.
Wrapper class representing virtual and physical registers.