More bundle related API additions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148465 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng 2012-01-19 07:47:03 +00:00
parent 3f9c251e40
commit ef2887d348
4 changed files with 62 additions and 1 deletions

View File

@ -37,6 +37,10 @@ void finalizeBundle(MachineBasicBlock &MBB,
MachineBasicBlock::instr_iterator finalizeBundle(MachineBasicBlock &MBB,
MachineBasicBlock::instr_iterator FirstMI);
/// finalizeBundles - Finalize instruction bundles in the specified
/// MachineFunction. Return true if any bundles are finalized.
bool finalizeBundles(MachineFunction &MF);
} // End llvm namespace
#endif

View File

@ -249,6 +249,11 @@ namespace llvm {
///
FunctionPass *createUnpackMachineBundlesPass();
/// createFinalizeMachineBundles - This pass finalize machine instruction
/// bundles (created earlier, e.g. during pre-RA scheduling).
///
FunctionPass *createFinalizeMachineBundlesPass();
} // End llvm namespace
#endif

View File

@ -235,6 +235,7 @@ void initializeVerifierPass(PassRegistry&);
void initializeVirtRegMapPass(PassRegistry&);
void initializeInstSimplifierPass(PassRegistry&);
void initializeUnpackMachineBundlesPass(PassRegistry&);
void initializeFinalizeMachineBundlesPass(PassRegistry&);
}

View File

@ -31,7 +31,7 @@ namespace {
} // end anonymous namespace
char UnpackMachineBundles::ID = 0;
INITIALIZE_PASS(UnpackMachineBundles, "unpack-mi-bundle",
INITIALIZE_PASS(UnpackMachineBundles, "unpack-mi-bundles",
"Unpack machine instruction bundles", false, false)
FunctionPass *llvm::createUnpackMachineBundlesPass() {
@ -71,6 +71,32 @@ bool UnpackMachineBundles::runOnMachineFunction(MachineFunction &MF) {
return Changed;
}
namespace {
class FinalizeMachineBundles : public MachineFunctionPass {
public:
static char ID; // Pass identification
FinalizeMachineBundles() : MachineFunctionPass(ID) {
initializeFinalizeMachineBundlesPass(*PassRegistry::getPassRegistry());
}
virtual bool runOnMachineFunction(MachineFunction &MF);
};
} // end anonymous namespace
char FinalizeMachineBundles::ID = 0;
INITIALIZE_PASS(FinalizeMachineBundles, "finalize-mi-bundles",
"Finalize machine instruction bundles", false, false)
FunctionPass *llvm::createFinalizeMachineBundlesPass() {
return new FinalizeMachineBundles();
}
bool FinalizeMachineBundles::runOnMachineFunction(MachineFunction &MF) {
return llvm::finalizeBundles(MF);
}
/// finalizeBundle - Finalize a machine instruction bundle which includes
/// a sequence of instructions starting from FirstMI to LastMI (exclusive).
/// This routine adds a BUNDLE instruction to represent the bundle, it adds
@ -196,3 +222,28 @@ llvm::finalizeBundle(MachineBasicBlock &MBB,
finalizeBundle(MBB, FirstMI, LastMI);
return LastMI;
}
/// finalizeBundles - Finalize instruction bundles in the specified
/// MachineFunction. Return true if any bundles are finalized.
bool llvm::finalizeBundles(MachineFunction &MF) {
bool Changed = false;
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
MachineBasicBlock &MBB = *I;
MachineBasicBlock::instr_iterator MII = MBB.instr_begin();
assert(!MII->isInsideBundle() &&
"First instr cannot be inside bundle before finalization!");
MachineBasicBlock::instr_iterator MIE = MBB.instr_end();
for (++MII; MII != MIE; ) {
if (!MII->isInsideBundle())
++MII;
else {
MII = finalizeBundle(MBB, llvm::prior(MII));
Changed = true;
}
}
}
return Changed;
}