mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 16:17:17 +00:00
Cosmetic changes to Machine LICM. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55578 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -34,7 +34,6 @@ namespace {
|
|||||||
class VISIBILITY_HIDDEN MachineLICM : public MachineFunctionPass {
|
class VISIBILITY_HIDDEN MachineLICM : public MachineFunctionPass {
|
||||||
const TargetMachine *TM;
|
const TargetMachine *TM;
|
||||||
const TargetInstrInfo *TII;
|
const TargetInstrInfo *TII;
|
||||||
MachineFunction *CurMF; // Current MachineFunction
|
|
||||||
|
|
||||||
// Various analyses that we use...
|
// Various analyses that we use...
|
||||||
MachineLoopInfo *LI; // Current MachineLoopInfo
|
MachineLoopInfo *LI; // Current MachineLoopInfo
|
||||||
@@ -112,30 +111,7 @@ namespace {
|
|||||||
///
|
///
|
||||||
void MoveInstToEndOfBlock(MachineBasicBlock *ToMBB,
|
void MoveInstToEndOfBlock(MachineBasicBlock *ToMBB,
|
||||||
MachineBasicBlock *FromMBB,
|
MachineBasicBlock *FromMBB,
|
||||||
MachineInstr *MI) {
|
MachineInstr *MI);
|
||||||
DEBUG({
|
|
||||||
DOUT << "Hoisting " << *MI;
|
|
||||||
if (ToMBB->getBasicBlock())
|
|
||||||
DOUT << " to MachineBasicBlock "
|
|
||||||
<< ToMBB->getBasicBlock()->getName();
|
|
||||||
if (FromMBB->getBasicBlock())
|
|
||||||
DOUT << " from MachineBasicBlock "
|
|
||||||
<< FromMBB->getBasicBlock()->getName();
|
|
||||||
DOUT << "\n";
|
|
||||||
});
|
|
||||||
|
|
||||||
MachineBasicBlock::iterator WhereIter = ToMBB->getFirstTerminator();
|
|
||||||
MachineBasicBlock::iterator To, From = FromMBB->begin();
|
|
||||||
|
|
||||||
while (&*From != MI)
|
|
||||||
++From;
|
|
||||||
|
|
||||||
assert(From != FromMBB->end() && "Didn't find instr in BB!");
|
|
||||||
|
|
||||||
To = From;
|
|
||||||
ToMBB->splice(WhereIter, FromMBB, From, ++To);
|
|
||||||
++NumHoisted;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// HoistRegion - Walk the specified region of the CFG (defined by all
|
/// HoistRegion - Walk the specified region of the CFG (defined by all
|
||||||
/// blocks dominated by the specified block, and that are in the current
|
/// blocks dominated by the specified block, and that are in the current
|
||||||
@@ -166,10 +142,9 @@ bool MachineLICM::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
DOUT << "******** Machine LICM ********\n";
|
DOUT << "******** Machine LICM ********\n";
|
||||||
|
|
||||||
Changed = false;
|
Changed = false;
|
||||||
CurMF = &MF;
|
TM = &MF.getTarget();
|
||||||
TM = &CurMF->getTarget();
|
|
||||||
TII = TM->getInstrInfo();
|
TII = TM->getInstrInfo();
|
||||||
RegInfo = &CurMF->getRegInfo();
|
RegInfo = &MF.getRegInfo();
|
||||||
|
|
||||||
// Get our Loop information...
|
// Get our Loop information...
|
||||||
LI = &getAnalysis<MachineLoopInfo>();
|
LI = &getAnalysis<MachineLoopInfo>();
|
||||||
@@ -303,6 +278,36 @@ bool MachineLICM::IsLoopInvariantInst(MachineInstr &I) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// MoveInstToEndOfBlock - Moves the machine instruction to the bottom of the
|
||||||
|
/// predecessor basic block (but before the terminator instructions).
|
||||||
|
///
|
||||||
|
void MachineLICM::MoveInstToEndOfBlock(MachineBasicBlock *ToMBB,
|
||||||
|
MachineBasicBlock *FromMBB,
|
||||||
|
MachineInstr *MI) {
|
||||||
|
DEBUG({
|
||||||
|
DOUT << "Hoisting " << *MI;
|
||||||
|
if (ToMBB->getBasicBlock())
|
||||||
|
DOUT << " to MachineBasicBlock "
|
||||||
|
<< ToMBB->getBasicBlock()->getName();
|
||||||
|
if (FromMBB->getBasicBlock())
|
||||||
|
DOUT << " from MachineBasicBlock "
|
||||||
|
<< FromMBB->getBasicBlock()->getName();
|
||||||
|
DOUT << "\n";
|
||||||
|
});
|
||||||
|
|
||||||
|
MachineBasicBlock::iterator WhereIter = ToMBB->getFirstTerminator();
|
||||||
|
MachineBasicBlock::iterator To, From = FromMBB->begin();
|
||||||
|
|
||||||
|
while (&*From != MI)
|
||||||
|
++From;
|
||||||
|
|
||||||
|
assert(From != FromMBB->end() && "Didn't find instr in BB!");
|
||||||
|
|
||||||
|
To = From;
|
||||||
|
ToMBB->splice(WhereIter, FromMBB, From, ++To);
|
||||||
|
++NumHoisted;
|
||||||
|
}
|
||||||
|
|
||||||
/// Hoist - When an instruction is found to use only loop invariant operands
|
/// Hoist - When an instruction is found to use only loop invariant operands
|
||||||
/// that are safe to hoist, this instruction is called to do the dirty work.
|
/// that are safe to hoist, this instruction is called to do the dirty work.
|
||||||
///
|
///
|
||||||
@@ -318,9 +323,9 @@ void MachineLICM::Hoist(MachineInstr &MI) {
|
|||||||
// is forbidden.
|
// is forbidden.
|
||||||
if (Preds.empty() || Preds.size() != 1) return;
|
if (Preds.empty() || Preds.size() != 1) return;
|
||||||
|
|
||||||
// Check that the predecessor is qualified to take the hoisted
|
// Check that the predecessor is qualified to take the hoisted instruction.
|
||||||
// instruction. I.e., there is only one edge from the predecessor, and it's to
|
// I.e., there is only one edge from the predecessor, and it's to the loop
|
||||||
// the loop header.
|
// header.
|
||||||
MachineBasicBlock *MBB = Preds.front();
|
MachineBasicBlock *MBB = Preds.front();
|
||||||
|
|
||||||
// FIXME: We are assuming at first that the basic block coming into this loop
|
// FIXME: We are assuming at first that the basic block coming into this loop
|
||||||
|
Reference in New Issue
Block a user