[llvm-commits] CVS: llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp

Tanya Brethour tbrethou at cs.uiuc.edu
Thu Dec 2 21:25:38 PST 2004



Changes in directory llvm/lib/Target/SparcV9/ModuloScheduling:

ModuloScheduling.cpp updated: 1.38 -> 1.39
---
Log message:

When writing kernel, save the branches til the end. They are still put in the "right place" in the schedule, but sometimes when folding to make a kernel instructions are added between branches. This is wrong. To avoid this, we handle branches special.


---
Diffs of the changes:  (+17 -5)

Index: llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp
diff -u llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp:1.38 llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp:1.39
--- llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp:1.38	Thu Dec  2 01:22:15 2004
+++ llvm/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp	Thu Dec  2 23:25:22 2004
@@ -1542,11 +1542,21 @@
   std::map<Value*, Value*> finalPHIValue;
   std::map<Value*, Value*> kernelValue;
 
+  //Branches are a special case
+  std::vector<MachineInstr*> branches;
+
     //Create TmpInstructions for the final phis
  for(MSSchedule::kernel_iterator I = schedule.kernel_begin(), E = schedule.kernel_end(); I != E; ++I) {
 
    DEBUG(std::cerr << "Stage: " << I->second << " Inst: " << *(I->first->getInst()) << "\n";);
 
+   if(I->first->isBranch()) {
+     //Clone instruction
+     const MachineInstr *inst = I->first->getInst();
+     MachineInstr *instClone = inst->clone();
+     branches.push_back(instClone);
+   }
+   
    //Clone instruction
    const MachineInstr *inst = I->first->getInst();
    MachineInstr *instClone = inst->clone();
@@ -1556,11 +1566,6 @@
 
    DEBUG(std::cerr <<  "Cloned Inst: " << *instClone << "\n");
 
-   if(I->first->isBranch()) {
-     //Add kernel noop
-     BuildMI(machineBB, V9::NOP, 0);
-   }
-   
    //Loop over Machine Operands
    for(unsigned i=0; i < inst->getNumOperands(); ++i) {
      //get machine operand
@@ -1623,6 +1628,13 @@
    
  }
 
+ //Add branches
+ for(std::vector<MachineInstr*>::iterator I = branches.begin(), E = branches.end(); I != E; ++I) {
+   machineBB->push_back(*I);
+   BuildMI(machineBB, V9::NOP, 0);
+ }
+
+
   DEBUG(std::cerr << "KERNEL before PHIs\n");
   DEBUG(machineBB->print(std::cerr));
 






More information about the llvm-commits mailing list