diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-10-22 13:49:27 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-10-22 13:49:27 +0000 |
commit | fb8c0533b46309296a3c404d58f6b5d7c337f0f1 (patch) | |
tree | ac557b5d5ff508440b048a6c7e6402c28360a0fd /lib/CodeGen/InstrSched/InstrScheduling.cpp | |
parent | c5d0322d98078fa1bbb62f123722080b32640f61 (diff) |
Modify code that processes delay slots so that it preserves any
useful instructions already inserted into delay slots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@945 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/InstrSched/InstrScheduling.cpp')
-rw-r--r-- | lib/CodeGen/InstrSched/InstrScheduling.cpp | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp index 79c8941035..5de987b3b5 100644 --- a/lib/CodeGen/InstrSched/InstrScheduling.cpp +++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp @@ -1223,24 +1223,49 @@ ReplaceNopsWithUsefulInstr(SchedulingManager& S, vector<SchedGraphNode*> sdelayNodeVec, SchedGraph* graph) { - vector<SchedGraphNode*> nopNodeVec; + vector<SchedGraphNode*> nopNodeVec; // this will hold unused NOPs const MachineInstrInfo& mii = S.getInstrInfo(); - unsigned ndelays= mii.getNumDelaySlots(node->getMachineInstr()->getOpCode()); + const MachineInstr* brInstr = node->getMachineInstr(); + unsigned ndelays= mii.getNumDelaySlots(brInstr->getOpCode()); assert(ndelays > 0 && "Unnecessary call to replace NOPs"); // Remove the NOPs currently in delay slots from the graph. // If not enough useful instructions were found, use the NOPs to // fill delay slots, otherwise, just discard them. - for (sg_succ_iterator I=succ_begin(node); I != succ_end(node); ++I) - if (! (*I)->isDummyNode() - && mii.isNop((*I)->getMachineInstr()->getOpCode())) + // + MachineCodeForVMInstr& termMvec = node->getInstr()->getMachineInstrVec(); + unsigned int firstDelaySlotIdx; + for (unsigned i=0; i < termMvec.size(); ++i) + if (termMvec[i] == brInstr) { - if (sdelayNodeVec.size() < ndelays) - sdelayNodeVec.push_back(*I); - else - nopNodeVec.push_back(*I); + firstDelaySlotIdx = i+1; + break; } - assert(sdelayNodeVec.size() == ndelays); + assert(firstDelaySlotIdx <= termMvec.size()-1 && + "This sucks! Where's that delay slot instruction?"); + + // First find all useful instructions already in the delay slots + // and USE THEM. We'll throw away the unused alternatives below + // + for (unsigned i=firstDelaySlotIdx; i < firstDelaySlotIdx + ndelays; ++i) + if (! mii.isNop(termMvec[i]->getOpCode())) + sdelayNodeVec.insert(sdelayNodeVec.begin(), + graph->getGraphNodeForInstr(termMvec[i])); + + // Then find the NOPs and keep only as many as are needed. + // Put the rest in nopNodeVec to be deleted. + for (unsigned i=firstDelaySlotIdx; i < firstDelaySlotIdx + ndelays; ++i) + if (mii.isNop(termMvec[i]->getOpCode())) + if (sdelayNodeVec.size() < ndelays) + sdelayNodeVec.push_back(graph->getGraphNodeForInstr(termMvec[i])); + else + nopNodeVec.push_back(graph->getGraphNodeForInstr(termMvec[i])); + + assert(sdelayNodeVec.size() >= ndelays); + + // If some delay slots were already filled, throw away that many new choices + if (sdelayNodeVec.size() > ndelays) + sdelayNodeVec.resize(ndelays); // Mark the nodes chosen for delay slots. This removes them from the graph. for (unsigned i=0; i < sdelayNodeVec.size(); i++) @@ -1512,7 +1537,7 @@ ScheduleInstructionsWithSSA(Method* method, { cout << endl << "*** Machine instructions after INSTRUCTION SCHEDULING" << endl; - PrintMachineInstructions(method); + method->getMachineCode().dump(); } return false; // no reason to fail yet |