llvm.org GIT mirror llvm / ef2887d
More bundle related API additions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148465 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 8 years ago
4 changed file(s) with 62 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
3636 MachineBasicBlock::instr_iterator finalizeBundle(MachineBasicBlock &MBB,
3737 MachineBasicBlock::instr_iterator FirstMI);
3838
39 /// finalizeBundles - Finalize instruction bundles in the specified
40 /// MachineFunction. Return true if any bundles are finalized.
41 bool finalizeBundles(MachineFunction &MF);
42
3943 } // End llvm namespace
4044
4145 #endif
248248 ///
249249 FunctionPass *createUnpackMachineBundlesPass();
250250
251 /// createFinalizeMachineBundles - This pass finalize machine instruction
252 /// bundles (created earlier, e.g. during pre-RA scheduling).
253 ///
254 FunctionPass *createFinalizeMachineBundlesPass();
255
251256 } // End llvm namespace
252257
253258 #endif
234234 void initializeVirtRegMapPass(PassRegistry&);
235235 void initializeInstSimplifierPass(PassRegistry&);
236236 void initializeUnpackMachineBundlesPass(PassRegistry&);
237 void initializeFinalizeMachineBundlesPass(PassRegistry&);
237238
238239 }
239240
3030 } // end anonymous namespace
3131
3232 char UnpackMachineBundles::ID = 0;
33 INITIALIZE_PASS(UnpackMachineBundles, "unpack-mi-bundle",
33 INITIALIZE_PASS(UnpackMachineBundles, "unpack-mi-bundles",
3434 "Unpack machine instruction bundles", false, false)
3535
3636 FunctionPass *llvm::createUnpackMachineBundlesPass() {
6969
7070 return Changed;
7171 }
72
73
74 namespace {
75 class FinalizeMachineBundles : public MachineFunctionPass {
76 public:
77 static char ID; // Pass identification
78 FinalizeMachineBundles() : MachineFunctionPass(ID) {
79 initializeFinalizeMachineBundlesPass(*PassRegistry::getPassRegistry());
80 }
81
82 virtual bool runOnMachineFunction(MachineFunction &MF);
83 };
84 } // end anonymous namespace
85
86 char FinalizeMachineBundles::ID = 0;
87 INITIALIZE_PASS(FinalizeMachineBundles, "finalize-mi-bundles",
88 "Finalize machine instruction bundles", false, false)
89
90 FunctionPass *llvm::createFinalizeMachineBundlesPass() {
91 return new FinalizeMachineBundles();
92 }
93
94 bool FinalizeMachineBundles::runOnMachineFunction(MachineFunction &MF) {
95 return llvm::finalizeBundles(MF);
96 }
97
7298
7399 /// finalizeBundle - Finalize a machine instruction bundle which includes
74100 /// a sequence of instructions starting from FirstMI to LastMI (exclusive).
195221 finalizeBundle(MBB, FirstMI, LastMI);
196222 return LastMI;
197223 }
224
225 /// finalizeBundles - Finalize instruction bundles in the specified
226 /// MachineFunction. Return true if any bundles are finalized.
227 bool llvm::finalizeBundles(MachineFunction &MF) {
228 bool Changed = false;
229 for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
230 MachineBasicBlock &MBB = *I;
231
232 MachineBasicBlock::instr_iterator MII = MBB.instr_begin();
233 assert(!MII->isInsideBundle() &&
234 "First instr cannot be inside bundle before finalization!");
235
236 MachineBasicBlock::instr_iterator MIE = MBB.instr_end();
237 for (++MII; MII != MIE; ) {
238 if (!MII->isInsideBundle())
239 ++MII;
240 else {
241 MII = finalizeBundle(MBB, llvm::prior(MII));
242 Changed = true;
243 }
244 }
245 }
246
247 return Changed;
248 }