diff options
| author | Andrew Trick <atrick@apple.com> | 2012-03-07 05:21:44 +0000 |
|---|---|---|
| committer | Andrew Trick <atrick@apple.com> | 2012-03-07 05:21:44 +0000 |
| commit | e932bb77b5a84c15b68edb8e0a4a7f820371e6cb (patch) | |
| tree | 3c92723337e09be444ca438a174e77e525e3adac /llvm/lib/CodeGen/PostRASchedulerList.cpp | |
| parent | edee68ce1ba280e4463efbf9eb88dddf53176785 (diff) | |
| download | bcm5719-llvm-e932bb77b5a84c15b68edb8e0a4a7f820371e6cb.tar.gz bcm5719-llvm-e932bb77b5a84c15b68edb8e0a4a7f820371e6cb.zip | |
misched preparation: modularize schedule emission.
ScheduleDAG has nothing to do with how the instructions are scheduled.
llvm-svn: 152206
Diffstat (limited to 'llvm/lib/CodeGen/PostRASchedulerList.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/PostRASchedulerList.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/PostRASchedulerList.cpp b/llvm/lib/CodeGen/PostRASchedulerList.cpp index 72ae6febb12..488dab72176 100644 --- a/llvm/lib/CodeGen/PostRASchedulerList.cpp +++ b/llvm/lib/CodeGen/PostRASchedulerList.cpp @@ -145,6 +145,8 @@ namespace { /// void Schedule(); + void EmitSchedule(); + /// Observe - Update liveness information to account for the current /// instruction, which will not be scheduled. /// @@ -730,3 +732,37 @@ void SchedulePostRATDList::ListScheduleTopDown() { "The number of nodes scheduled doesn't match the expected number!"); #endif // NDEBUG } + +// EmitSchedule - Emit the machine code in scheduled order. +void SchedulePostRATDList::EmitSchedule() { + Begin = InsertPos; + + // If first instruction was a DBG_VALUE then put it back. + if (FirstDbgValue) + BB->splice(InsertPos, BB, FirstDbgValue); + + // Then re-insert them according to the given schedule. + for (unsigned i = 0, e = Sequence.size(); i != e; i++) { + if (SUnit *SU = Sequence[i]) + BB->splice(InsertPos, BB, SU->getInstr()); + else + // Null SUnit* is a noop. + TII->insertNoop(*BB, InsertPos); + + // Update the Begin iterator, as the first instruction in the block + // may have been scheduled later. + if (i == 0) + Begin = prior(InsertPos); + } + + // Reinsert any remaining debug_values. + for (std::vector<std::pair<MachineInstr *, MachineInstr *> >::iterator + DI = DbgValues.end(), DE = DbgValues.begin(); DI != DE; --DI) { + std::pair<MachineInstr *, MachineInstr *> P = *prior(DI); + MachineInstr *DbgValue = P.first; + MachineBasicBlock::iterator OrigPrivMI = P.second; + BB->splice(++OrigPrivMI, BB, DbgValue); + } + DbgValues.clear(); + FirstDbgValue = NULL; +} |

