summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-06-25 16:13:21 +0000
committerChris Lattner <sabre@nondot.org>2002-06-25 16:13:21 +0000
commit7076ff29ed02c3472e82575594386739a4bb3e34 (patch)
tree2e5e31bf8db609442dc4894bdaa7e9eb31189c00 /llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp
parentfda72b1aad8c70686418b2a7dfa8adbc20435b0e (diff)
downloadbcm5719-llvm-7076ff29ed02c3472e82575594386739a4bb3e34.tar.gz
bcm5719-llvm-7076ff29ed02c3472e82575594386739a4bb3e34.zip
MEGAPATCH checkin.
For details, See: docs/2002-06-25-MegaPatchInfo.txt llvm-svn: 2778
Diffstat (limited to 'llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp')
-rw-r--r--llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp79
1 files changed, 32 insertions, 47 deletions
diff --git a/llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp b/llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp
index 614c5f67731..b27f9022bba 100644
--- a/llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp
+++ b/llvm/lib/CodeGen/InstrSelection/InstrSelection.cpp
@@ -123,14 +123,10 @@ SelectInstructionsForMethod(Function *F, TargetMachine &target)
// Record instructions in the vector for each basic block
//
for (Function::iterator BI = F->begin(), BE = F->end(); BI != BE; ++BI)
- {
- MachineCodeForBasicBlock& bbMvec = (*BI)->getMachineInstrVec();
- for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II)
- {
- MachineCodeForInstruction &mvec =MachineCodeForInstruction::get(*II);
- for (unsigned i=0; i < mvec.size(); i++)
- bbMvec.push_back(mvec[i]);
- }
+ for (BasicBlock::iterator II = BI->begin(); II != BI->end(); ++II) {
+ MachineCodeForInstruction &mvec =MachineCodeForInstruction::get(II);
+ for (unsigned i=0; i < mvec.size(); i++)
+ BI->getMachineInstrVec().push_back(mvec[i]);
}
// Insert phi elimination code -- added by Ruchira
@@ -191,49 +187,38 @@ InsertCode4AllPhisInMeth(Function *F, TargetMachine &target)
{
// for all basic blocks in function
//
- for (Function::iterator BI = F->begin(); BI != F->end(); ++BI) {
-
- BasicBlock *BB = *BI;
- const BasicBlock::InstListType &InstList = BB->getInstList();
- BasicBlock::InstListType::const_iterator IIt = InstList.begin();
-
- // for all instructions in the basic block
- //
- for( ; IIt != InstList.end(); ++IIt ) {
-
- if (PHINode *PN = dyn_cast<PHINode>(*IIt)) {
- // FIXME: This is probably wrong...
- Value *PhiCpRes = new PHINode(PN->getType(), "PhiCp:");
-
- // for each incoming value of the phi, insert phi elimination
- //
- for (unsigned i = 0; i < PN->getNumIncomingValues(); ++i)
- { // insert the copy instruction to the predecessor BB
- vector<MachineInstr*> mvec, CpVec;
- target.getRegInfo().cpValue2Value(PN->getIncomingValue(i), PhiCpRes,
- mvec);
- for (vector<MachineInstr*>::iterator MI=mvec.begin();
- MI != mvec.end(); ++MI)
- {
- vector<MachineInstr*> CpVec2 =
- FixConstantOperandsForInstr(PN, *MI, target);
- CpVec2.push_back(*MI);
- CpVec.insert(CpVec.end(), CpVec2.begin(), CpVec2.end());
- }
-
- InsertPhiElimInstructions(PN->getIncomingBlock(i), CpVec);
- }
+ for (Function::iterator BB = F->begin(); BB != F->end(); ++BB) {
+ BasicBlock::InstListType &InstList = BB->getInstList();
+ for (BasicBlock::iterator IIt = InstList.begin();
+ PHINode *PN = dyn_cast<PHINode>(&*IIt); ++IIt) {
+ // FIXME: This is probably wrong...
+ Value *PhiCpRes = new PHINode(PN->getType(), "PhiCp:");
- vector<MachineInstr*> mvec;
- target.getRegInfo().cpValue2Value(PhiCpRes, PN, mvec);
+ // for each incoming value of the phi, insert phi elimination
+ //
+ for (unsigned i = 0; i < PN->getNumIncomingValues(); ++i) {
+ // insert the copy instruction to the predecessor BB
+ vector<MachineInstr*> mvec, CpVec;
+ target.getRegInfo().cpValue2Value(PN->getIncomingValue(i), PhiCpRes,
+ mvec);
+ for (vector<MachineInstr*>::iterator MI=mvec.begin();
+ MI != mvec.end(); ++MI) {
+ vector<MachineInstr*> CpVec2 =
+ FixConstantOperandsForInstr(PN, *MI, target);
+ CpVec2.push_back(*MI);
+ CpVec.insert(CpVec.end(), CpVec2.begin(), CpVec2.end());
+ }
- // get an iterator to machine instructions in the BB
- MachineCodeForBasicBlock& bbMvec = BB->getMachineInstrVec();
-
- bbMvec.insert( bbMvec.begin(), mvec.begin(), mvec.end());
+ InsertPhiElimInstructions(PN->getIncomingBlock(i), CpVec);
}
- else break; // since PHI nodes can only be at the top
+ vector<MachineInstr*> mvec;
+ target.getRegInfo().cpValue2Value(PhiCpRes, PN, mvec);
+
+ // get an iterator to machine instructions in the BB
+ MachineCodeForBasicBlock& bbMvec = BB->getMachineInstrVec();
+
+ bbMvec.insert(bbMvec.begin(), mvec.begin(), mvec.end());
} // for each Phi Instr in BB
} // for all BBs in function
}
OpenPOWER on IntegriCloud