From e95ce74b80c5b366abfa1f67254219bf24b05ea3 Mon Sep 17 00:00:00 2001 From: Mehwish Nagda Date: Thu, 25 Jul 2002 17:31:05 +0000 Subject: [PATCH] now removes deleted nops from MachineCodeForInstruction git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3090 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/InstrSched/InstrScheduling.cpp | 28 +++++++++++++------ .../SparcV9/InstrSched/InstrScheduling.cpp | 28 +++++++++++++------ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp index 19c6922d342..39b3dd06788 100644 --- a/lib/CodeGen/InstrSched/InstrScheduling.cpp +++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp @@ -79,7 +79,7 @@ private: //---------------------------------------------------------------------- template -class ScheduleIterator : public forward_iterator<_NodeType, ptrdiff_t> { +class ScheduleIterator: public std::forward_iterator<_NodeType, ptrdiff_t> { private: unsigned cycleNum; unsigned slotNum; @@ -352,18 +352,18 @@ private: unsigned int totalInstrCount; cycles_t curTime; cycles_t nextEarliestIssueTime; // next cycle we can issue - vector > choicesForSlot; // indexed by slot# + vector > choicesForSlot; // indexed by slot# vector choiceVec; // indexed by node ptr vector numInClass; // indexed by sched class vector nextEarliestStartTime; // indexed by opCode - hash_map delaySlotInfoForBranches; + std::hash_map delaySlotInfoForBranches; // indexed by branch node ptr public: SchedulingManager(const TargetMachine& _target, const SchedGraph* graph, SchedPriorities& schedPrio); ~SchedulingManager() { - for (hash_map::iterator I = delaySlotInfoForBranches.begin(), E = delaySlotInfoForBranches.end(); I != E; ++I) delete I->second; @@ -422,7 +422,7 @@ public: return choiceVec[i]; } - inline hash_set& getChoicesForSlot(unsigned slotNum) { + inline std::hash_set& getChoicesForSlot(unsigned slotNum) { assert(slotNum < nslots); return choicesForSlot[slotNum]; } @@ -497,7 +497,7 @@ public: inline DelaySlotInfo* getDelaySlotInfoForInstr(const SchedGraphNode* bn, bool createIfMissing=false) { - hash_map::const_iterator + std::hash_map::const_iterator I = delaySlotInfoForBranches.find(bn); if (I != delaySlotInfoForBranches.end()) return I->second; @@ -1243,8 +1243,20 @@ ReplaceNopsWithUsefulInstr(SchedulingManager& S, if (sdelayNodeVec.size() < ndelays) sdelayNodeVec.push_back(graph->getGraphNodeForInstr(bbMvec[i])); else - nopNodeVec.push_back(graph->getGraphNodeForInstr(bbMvec[i])); - + { + nopNodeVec.push_back(graph->getGraphNodeForInstr(bbMvec[i])); + + //remove the MI from the Machine Code For Instruction + MachineCodeForInstruction& llvmMvec = + MachineCodeForInstruction::get((Instruction *) + (node->getBB()->getTerminator())); + for(MachineCodeForInstruction::iterator mciI=llvmMvec.begin(), + mciE=llvmMvec.end(); mciI!=mciE; ++mciI){ + if(*mciI==bbMvec[i]) + llvmMvec.erase(mciI); + } + } + assert(sdelayNodeVec.size() >= ndelays); // If some delay slots were already filled, throw away that many new choices diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp index 19c6922d342..39b3dd06788 100644 --- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp +++ b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp @@ -79,7 +79,7 @@ private: //---------------------------------------------------------------------- template -class ScheduleIterator : public forward_iterator<_NodeType, ptrdiff_t> { +class ScheduleIterator: public std::forward_iterator<_NodeType, ptrdiff_t> { private: unsigned cycleNum; unsigned slotNum; @@ -352,18 +352,18 @@ private: unsigned int totalInstrCount; cycles_t curTime; cycles_t nextEarliestIssueTime; // next cycle we can issue - vector > choicesForSlot; // indexed by slot# + vector > choicesForSlot; // indexed by slot# vector choiceVec; // indexed by node ptr vector numInClass; // indexed by sched class vector nextEarliestStartTime; // indexed by opCode - hash_map delaySlotInfoForBranches; + std::hash_map delaySlotInfoForBranches; // indexed by branch node ptr public: SchedulingManager(const TargetMachine& _target, const SchedGraph* graph, SchedPriorities& schedPrio); ~SchedulingManager() { - for (hash_map::iterator I = delaySlotInfoForBranches.begin(), E = delaySlotInfoForBranches.end(); I != E; ++I) delete I->second; @@ -422,7 +422,7 @@ public: return choiceVec[i]; } - inline hash_set& getChoicesForSlot(unsigned slotNum) { + inline std::hash_set& getChoicesForSlot(unsigned slotNum) { assert(slotNum < nslots); return choicesForSlot[slotNum]; } @@ -497,7 +497,7 @@ public: inline DelaySlotInfo* getDelaySlotInfoForInstr(const SchedGraphNode* bn, bool createIfMissing=false) { - hash_map::const_iterator + std::hash_map::const_iterator I = delaySlotInfoForBranches.find(bn); if (I != delaySlotInfoForBranches.end()) return I->second; @@ -1243,8 +1243,20 @@ ReplaceNopsWithUsefulInstr(SchedulingManager& S, if (sdelayNodeVec.size() < ndelays) sdelayNodeVec.push_back(graph->getGraphNodeForInstr(bbMvec[i])); else - nopNodeVec.push_back(graph->getGraphNodeForInstr(bbMvec[i])); - + { + nopNodeVec.push_back(graph->getGraphNodeForInstr(bbMvec[i])); + + //remove the MI from the Machine Code For Instruction + MachineCodeForInstruction& llvmMvec = + MachineCodeForInstruction::get((Instruction *) + (node->getBB()->getTerminator())); + for(MachineCodeForInstruction::iterator mciI=llvmMvec.begin(), + mciE=llvmMvec.end(); mciI!=mciE; ++mciI){ + if(*mciI==bbMvec[i]) + llvmMvec.erase(mciI); + } + } + assert(sdelayNodeVec.size() >= ndelays); // If some delay slots were already filled, throw away that many new choices -- 2.34.1