[llvm-commits] CVS: llvm/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp ModuloScheduling.cpp ModuloScheduling.h
Tanya Brethour
tbrethou at cs.uiuc.edu
Mon Nov 22 12:41:40 PST 2004
Changes in directory llvm/lib/Target/SparcV9/ModuloScheduling:
MSSchedule.cpp updated: 1.8 -> 1.9
ModuloScheduling.cpp updated: 1.34 -> 1.35
ModuloScheduling.h updated: 1.19 -> 1.20
---
Log message:
Fixed a bug where I was trying to ModuloSchedule a loop with no instructions but a terminator.
Fixed a bug in the schedule generation that was always using the start cycle.
---
Diffs of the changes: (+32 -9)
Index: llvm/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp
diff -u llvm/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp:1.8 llvm/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp:1.9
--- llvm/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp:1.8 Fri Oct 29 19:39:07 2004
+++ llvm/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp Mon Nov 22 14:41:23 2004
@@ -54,6 +54,9 @@
int currentCycle = cycle;
bool success = true;
+ //map for easy backtracking, resource num at a certain cycle
+ //std::map<int, int> backtrackMap;
+
//Get resource usage for this instruction
InstrRUsage rUsage = msi->getInstrRUsage(node->getInst()->getOpcode());
std::vector<std::vector<resourceId_t> > resources = rUsage.resourcesByCycle;
@@ -74,8 +77,11 @@
std::map<int, int>::iterator resourceUse = resourcesForCycle->second.find(resourceNum);
if(resourceUse != resourcesForCycle->second.end()) {
//Check if there are enough of this resource and if so, increase count and move on
- if(resourceUse->second < CPUResource::getCPUResource(resourceNum)->maxNumUsers)
+ if(resourceUse->second < CPUResource::getCPUResource(resourceNum)->maxNumUsers) {
++resourceUse->second;
+ //Document that we increased the usage count for this resource at this cycle
+
+ }
else {
success = false;
}
@@ -89,7 +95,8 @@
//Create a new map and put in our resource
std::map<int, int> resourceMap;
resourceMap[resourceNum] = 1;
- resourceNumPerCycle[cycle] = resourceMap;
+ resourceNumPerCycle[currentCycle] = resourceMap;
+
}
if(!success)
break;
Index: llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp
diff -u llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp:1.34 llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp:1.35
--- llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp:1.34 Tue Nov 16 15:31:37 2004
+++ llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp Mon Nov 22 14:41:24 2004
@@ -1,4 +1,3 @@
-
//===-- ModuloScheduling.cpp - ModuloScheduling ----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
@@ -25,6 +24,7 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/Statistic.h"
#include <cmath>
#include <algorithm>
#include <fstream>
@@ -62,6 +62,9 @@
//Graph Traits for printing out the dependence graph
namespace llvm {
+ Statistic<> ValidLoops("modulosched-validLoops", "Number of candidate loops modulo-scheduled");
+ Statistic<> MSLoops("modulosched-schedLoops", "Number of loops successfully modulo-scheduled");
+ Statistic<> IncreasedII("modulosched-increasedII", "Number of times we had to increase II");
template<>
struct DOTGraphTraits<MSchedGraph*> : public DefaultDOTGraphTraits {
@@ -136,8 +139,10 @@
//Iterate over BasicBlocks and put them into our worklist if they are valid
for (MachineFunction::iterator BI = MF.begin(); BI != MF.end(); ++BI)
- if(MachineBBisValid(BI))
+ if(MachineBBisValid(BI)) {
Worklist.push_back(&*BI);
+ ++ValidLoops;
+ }
defaultInst = 0;
@@ -217,7 +222,7 @@
//stage > 0
if(schedule.getMaxStage() != 0) {
reconstructLoop(*BI);
- numMS++;
+ ++MSLoops;
Changed = true;
}
else
@@ -241,9 +246,6 @@
//delete(*BI);
}
-
- DEBUG(std::cerr << "Number of Loop Candidates: " << Worklist.size() << "\n Number ModuloScheduled: " << numMS << "\n");
-
return Changed;
}
@@ -254,6 +256,10 @@
for(unsigned opNum = 0; opNum < I->getNumOperands(); ++opNum) {
const MachineOperand &mOp = I->getOperand(opNum);
if(mOp.getType() == MachineOperand::MO_VirtualRegister && mOp.isDef()) {
+ //assert if this is the second def we have seen
+ DEBUG(std::cerr << "Putting " << *(mOp.getVRegValue()) << " into map\n");
+ assert(!defMap.count(mOp.getVRegValue()) && "Def already in the map");
+
defMap[mOp.getVRegValue()] = &*I;
}
@@ -265,6 +271,7 @@
}
}
}
+
assert(defaultInst && "We must have a default instruction to use as our main point to add to machine code for instruction\n");
}
@@ -286,6 +293,10 @@
if(!isLoop)
return false;
+ //Check size of our basic block.. make sure we have more then just the terminator in it
+ if(BI->getBasicBlock()->size() == 1)
+ return false;
+
//Get Target machine instruction info
const TargetInstrInfo *TMI = target.getInstrInfo();
@@ -705,7 +716,7 @@
//Get final distance calc
distance += node->getInEdge(last).getIteDiff();
-
+ DEBUG(std::cerr << "Reccurrence Distance: " << distance << "\n");
//Adjust II until we get close to the inequality delay - II*distance <= 0
@@ -1187,6 +1198,7 @@
success = scheduleNode(*I, EarlyStart, EarlyStart + II - 1);
if(!success) {
+ ++IncreasedII;
++II;
schedule.clear();
break;
@@ -1199,6 +1211,7 @@
success = schedule.constructKernel(II);
DEBUG(std::cerr << "Done Constructing Schedule Kernel\n");
if(!success) {
+ ++IncreasedII;
++II;
schedule.clear();
}
@@ -1267,6 +1280,8 @@
MSchedGraphNode *branch = 0;
MSchedGraphNode *BAbranch = 0;
+ schedule.print(std::cerr);
+
for(MSSchedule::kernel_iterator I = schedule.kernel_begin(), E = schedule.kernel_end(); I != E; ++I) {
maxStageCount = std::max(maxStageCount, I->second);
Index: llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h
diff -u llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h:1.19 llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h:1.20
--- llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h:1.19 Tue Nov 16 15:31:37 2004
+++ llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.h Mon Nov 22 14:41:24 2004
@@ -113,6 +113,7 @@
public:
ModuloSchedulingPass(TargetMachine &targ) : target(targ) {}
virtual bool runOnFunction(Function &F);
+ virtual const char* getPassName() const { return "ModuloScheduling"; }
};
}
More information about the llvm-commits
mailing list