[llvm-commits] CVS: llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp ModuloScheduling.h

Guochun Shi gshi1 at cs.uiuc.edu
Tue Jun 10 15:05:00 PDT 2003


Changes in directory llvm/lib/CodeGen/ModuloScheduling:

ModuloScheduling.cpp updated: 1.8 -> 1.9
ModuloScheduling.h updated: 1.8 -> 1.9

---
Log message:

add some comments
add a function ModuloScheduling::dumpFinalSchedule() to print out final schedule


---
Diffs of the changes:

Index: llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp
diff -u llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp:1.8 llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp:1.9
--- llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp:1.8	Tue Jun 10 14:09:00 2003
+++ llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp	Tue Jun 10 15:04:30 2003
@@ -27,6 +27,7 @@
 #include <iostream>
 
 using std::endl;
+using std::cerr;
 
 //************************************************************
 // printing Debug information
@@ -52,10 +53,9 @@
 
 // Computes the schedule and inserts epilogue and prologue
 //
-void ModuloScheduling::instrScheduling()
-{
+void 
+ModuloScheduling::instrScheduling(){
 
-  printf(" instrScheduling \n");
 
   if (ModuloScheduling::printScheduleProcess())
     DEBUG_PRINT(std::cerr << "************ computing modulo schedule ***********\n");
@@ -81,10 +81,9 @@
     }
   }
 
-  //print the final schedule if necessary
-  if (ModuloScheduling::printSchedule())
-    dumpScheduling();
-
+  //print the final schedule
+  dumpFinalSchedule();
+  
   //the schedule has been computed
   //create epilogue, prologue and kernel BasicBlock
 
@@ -127,10 +126,13 @@
 
 }
 
+
 // Clear memory from the last round and initialize if necessary
 //
-void ModuloScheduling::clearInitMem(const TargetSchedInfo & msi)
-{
+
+void 
+ModuloScheduling::clearInitMem(const TargetSchedInfo & msi){
+
   unsigned numIssueSlots = msi.maxNumIssueTotal;
   // clear nodeScheduled from the last round
   if (ModuloScheduling::printScheduleProcess()) {
@@ -162,8 +164,9 @@
 
 // Compute schedule and coreSchedule with the current II
 //
-bool ModuloScheduling::computeSchedule()
-{
+bool 
+ModuloScheduling::computeSchedule(){
+
 
   if (ModuloScheduling::printScheduleProcess())
     DEBUG_PRINT(std::cerr << "start to compute schedule\n");
@@ -276,8 +279,9 @@
 
 // Get the successor of the BasicBlock
 //
-BasicBlock *ModuloScheduling::getSuccBB(BasicBlock *bb)
-{
+BasicBlock *
+ModuloScheduling::getSuccBB(BasicBlock *bb){
+
   BasicBlock *succ_bb;
   for (unsigned i = 0; i < II; ++i)
     for (unsigned j = 0; j < coreSchedule[i].size(); ++j)
@@ -310,8 +314,9 @@
 
 // Get the predecessor of the BasicBlock
 //
-BasicBlock *ModuloScheduling::getPredBB(BasicBlock *bb)
-{
+BasicBlock *
+ModuloScheduling::getPredBB(BasicBlock *bb){
+
   BasicBlock *pred_bb;
   for (unsigned i = 0; i < II; ++i)
     for (unsigned j = 0; j < coreSchedule[i].size(); ++j)
@@ -342,8 +347,9 @@
 
 // Construct the prologue
 //
-void ModuloScheduling::constructPrologue(BasicBlock *prologue)
-{
+void 
+ModuloScheduling::constructPrologue(BasicBlock *prologue){
+
   InstListType & prologue_ist = prologue->getInstList();
   vvNodeType & tempSchedule_prologue =
       *(new std::vector<std::vector<ModuloSchedGraphNode*> >(schedule));
@@ -397,10 +403,11 @@
 
 // Construct the kernel BasicBlock
 //
-void ModuloScheduling::constructKernel(BasicBlock *prologue,
+void 
+ModuloScheduling::constructKernel(BasicBlock *prologue,
                                        BasicBlock *kernel,
-                                       BasicBlock *epilogue)
-{
+                                       BasicBlock *epilogue){
+
   //*************fill instructions in the kernel****************
   InstListType & kernel_ist = kernel->getInstList();
   BranchInst *brchInst;
@@ -472,9 +479,9 @@
 
 // Construct the epilogue 
 //
-void ModuloScheduling::constructEpilogue(BasicBlock *epilogue,
-                                         BasicBlock *succ_bb)
-{
+void 
+ModuloScheduling::constructEpilogue(BasicBlock *epilogue,
+                                         BasicBlock *succ_bb){
 
   //compute the schedule for epilogue
   vvNodeType &tempSchedule_epilogue =
@@ -546,8 +553,9 @@
 //its latest clone i.e. after this function is called, the ist is not used
 //anywhere and it can be erased.
 //------------------------------------------------------------------------------
-void ModuloScheduling::updateUseWithClone(Instruction * ist)
-{
+void 
+ModuloScheduling::updateUseWithClone(Instruction * ist){
+
 
   while (ist->use_size() > 0) {
     bool destroyed = false;
@@ -587,8 +595,9 @@
 //this function clear all clone mememoy
 //i.e. set all instruction's clone memory to NULL
 //*****************************************************
-void ModuloScheduling::clearCloneMemory()
-{
+void 
+ModuloScheduling::clearCloneMemory(){
+
   for (unsigned i = 0; i < coreSchedule.size(); i++)
     for (unsigned j = 0; j < coreSchedule[i].size(); j++)
       if (coreSchedule[i][j])
@@ -603,8 +612,9 @@
 // because LLVM is in SSA form and we should use the correct value
 //this fuction also update the instruction orn's latest clone memory
 //******************************************************************************
-Instruction *ModuloScheduling::cloneInstSetMemory(Instruction * orn)
-{
+Instruction *
+ModuloScheduling::cloneInstSetMemory(Instruction * orn){
+
   // make a clone instruction
   Instruction *cln = orn->clone();
 
@@ -624,10 +634,11 @@
 
 
 
-bool ModuloScheduling::ScheduleNode(ModuloSchedGraphNode * node,
+bool 
+ModuloScheduling::ScheduleNode(ModuloSchedGraphNode * node,
                                     unsigned start, unsigned end,
-                                    NodeVec & nodeScheduled)
-{
+                                    NodeVec & nodeScheduled){
+
   const TargetSchedInfo & msi = target.getSchedInfo();
   unsigned int numIssueSlots = msi.maxNumIssueTotal;
 
@@ -734,9 +745,10 @@
 }
 
 
-void ModuloScheduling::updateResourceTable(Resources useResources,
-                                           int startCycle)
-{
+void 
+ModuloScheduling::updateResourceTable(Resources useResources,
+                                           int startCycle){
+
   for (unsigned i = 0; i < useResources.size(); i++) {
     int absCycle = startCycle + i;
     int coreCycle = absCycle % II;
@@ -752,9 +764,10 @@
   }
 }
 
-void ModuloScheduling::undoUpdateResourceTable(Resources useResources,
-                                               int startCycle)
-{
+void 
+ModuloScheduling::undoUpdateResourceTable(Resources useResources,
+                                               int startCycle){
+
   for (unsigned i = 0; i < useResources.size(); i++) {
     int absCycle = startCycle + i;
     int coreCycle = absCycle % II;
@@ -783,8 +796,9 @@
 //-----------------------------------------------------------------------
 
 
-bool ModuloScheduling::resourceTableNegative()
-{
+bool 
+ModuloScheduling::resourceTableNegative(){
+
   assert(resourceTable.size() == (unsigned) II
          && "resouceTable size must be equal to II");
   bool isNegative = false;
@@ -806,8 +820,9 @@
 //
 //------------------------------------------------------------------------
 
-void ModuloScheduling::dumpResourceUsageTable()
-{
+void 
+ModuloScheduling::dumpResourceUsageTable(){
+
   DEBUG_PRINT(std::cerr << "dumping resource usage table\n");
   for (unsigned i = 0; i < resourceTable.size(); i++) {
     for (unsigned j = 0; j < resourceTable[i].size(); j++)
@@ -824,8 +839,9 @@
 //       print out thisSchedule for debug
 //
 //-----------------------------------------------------------------------
-void ModuloScheduling::dumpSchedule(vvNodeType thisSchedule)
-{
+void 
+ModuloScheduling::dumpSchedule(vvNodeType thisSchedule){
+
   const TargetSchedInfo & msi = target.getSchedInfo();
   unsigned numIssueSlots = msi.maxNumIssueTotal;
   for (unsigned i = 0; i < numIssueSlots; i++)
@@ -850,8 +866,9 @@
 //
 //-------------------------------------------------------
 
-void ModuloScheduling::dumpScheduling()
-{
+void 
+ModuloScheduling::dumpScheduling(){
+
   DEBUG_PRINT(std::cerr << "dump schedule:" << "\n");
   const TargetSchedInfo & msi = target.getSchedInfo();
   unsigned numIssueSlots = msi.maxNumIssueTotal;
@@ -883,7 +900,47 @@
   }
 }
 
+/*
+  print out final schedule
+*/
 
+void 
+ModuloScheduling::dumpFinalSchedule(){
+
+  cerr << "dump schedule:" << endl;
+  const TargetSchedInfo & msi = target.getSchedInfo();
+  unsigned numIssueSlots = msi.maxNumIssueTotal;
+
+  for (unsigned i = 0; i < numIssueSlots; i++)
+    cerr << "\t#";
+  cerr << endl;
+
+  for (unsigned i = 0; i < schedule.size(); i++) {
+    cerr << "cycle" << i << ": ";
+    
+    for (unsigned j = 0; j < schedule[i].size(); j++)
+      if (schedule[i][j] != NULL)
+        cerr << schedule[i][j]->getNodeId() << "\t";
+      else
+        cerr << "\t";
+    cerr << endl;
+  }
+  
+  cerr << "dump coreSchedule:" << endl;
+  for (unsigned i = 0; i < numIssueSlots; i++)
+    cerr << "\t#";
+  cerr << endl;
+  
+  for (unsigned i = 0; i < coreSchedule.size(); i++) {
+    cerr << "cycle" << i << ": ";
+    for (unsigned j = 0; j < coreSchedule[i].size(); j++)
+      if (coreSchedule[i][j] != NULL)
+        cerr << coreSchedule[i][j]->getNodeId() << "\t";
+      else
+        cerr << "\t";
+    cerr << endl;
+  }
+}
 
 //---------------------------------------------------------------------------
 // Function: ModuloSchedulingPass
@@ -915,20 +972,20 @@
 }                               // end anonymous namespace
 
 
-bool ModuloSchedulingPass::runOnFunction(Function &F)
-{
-
+bool
+ModuloSchedulingPass::runOnFunction(Function &F){
+  
   ModuloSchedGraphSet *graphSet = new ModuloSchedGraphSet(&F, target);
 
   ModuloSchedulingSet ModuloSchedulingSet(*graphSet);
   
-  printf("runOnFunction  in ModuloSchedulingPass returns\n");
+  DEBUG_PRINT(cerr<<"runOnFunction  in ModuloSchedulingPass returns\n"<<endl);
   return false;
 }
 
 
-Pass *createModuloSchedulingPass(const TargetMachine & tgt)
-{
-  printf("creating modulo scheduling \n");
+Pass *
+createModuloSchedulingPass(const TargetMachine & tgt){
+  DEBUG_PRINT(cerr<<"creating modulo scheduling "<<endl);
   return new ModuloSchedulingPass(tgt);
 }


Index: llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.h
diff -u llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.h:1.8 llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.h:1.9
--- llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.h:1.8	Sun Jun  8 18:16:07 2003
+++ llvm/lib/CodeGen/ModuloScheduling/ModuloScheduling.h	Tue Jun 10 15:04:30 2003
@@ -13,7 +13,9 @@
 #include <iostream>
 #include <vector>
 
-#define DEBUG_PRINT(x) x
+//#define DEBUG_PRINT(x) x
+
+#define DEBUG_PRINT(x) 
 
 // for debug information selecton
 enum ModuloSchedDebugLevel_t { 
@@ -98,6 +100,7 @@
   // Debug functions:
   // Dump the schedule and core schedule
   void dumpScheduling();
+  void dumpFinalSchedule();
 
   // Dump the input vector of nodes
   // sch: the input vector of nodes





More information about the llvm-commits mailing list