aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2004-12-03 05:25:22 +0000
committerTanya Lattner <tonic@nondot.org>2004-12-03 05:25:22 +0000
commitf3fa55f9795c82feef7049f176c0267096f0ffc9 (patch)
tree4fe959cb216a2b8c8b7bf85732afd6c44fd6a35f
parent223d4c4b3a040e57bab65185f77e3212fae2b922 (diff)
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18450 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp b/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp
index 7a3f267450..2c4919f0ef 100644
--- a/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp
+++ b/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp
@@ -1542,11 +1542,21 @@ void ModuloSchedulingPass::writeKernel(BasicBlock *llvmBB, MachineBasicBlock *ma
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 @@ void ModuloSchedulingPass::writeKernel(BasicBlock *llvmBB, MachineBasicBlock *ma
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 @@ void ModuloSchedulingPass::writeKernel(BasicBlock *llvmBB, MachineBasicBlock *ma
}
+ //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));