From 4e7bc49b54c18440c1a5ffdffbee75c7371f857e Mon Sep 17 00:00:00 2001 From: "Vikram S. Adve" Date: Sun, 24 Mar 2002 03:36:52 +0000 Subject: [PATCH] Use deterministic iterator for treeRoots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1967 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/InstrSelection/InstrSelection.cpp | 20 +++++++++---------- .../SparcV9/InstrSelection/InstrSelection.cpp | 20 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp index b63144781dc..3efc5274700 100644 --- a/lib/CodeGen/InstrSelection/InstrSelection.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp @@ -98,12 +98,11 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target) // // Invoke BURG instruction selection for each tree // - const std::hash_set &treeRoots = instrForest.getRootSet(); - for (std::hash_set::const_iterator - treeRootIter = treeRoots.begin(); treeRootIter != treeRoots.end(); - ++treeRootIter) + for (InstrForest::const_root_iterator RI = instrForest.roots_begin(); + RI != instrForest.roots_end(); ++RI) { - InstrTreeNode* basicNode = *treeRootIter; + InstructionNode* basicNode = *RI; + assert(basicNode->parent() == NULL && "A `root' node has a parent?"); // Invoke BURM to label each tree node with a state burm_label(basicNode); @@ -131,7 +130,7 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target) MachineCodeForBasicBlock& bbMvec = (*BI)->getMachineInstrVec(); for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II) { - MachineCodeForInstruction &mvec = MachineCodeForInstruction::get(*II); + MachineCodeForInstruction &mvec =MachineCodeForInstruction::get(*II); for (unsigned i=0; i < mvec.size(); i++) bbMvec.push_back(mvec[i]); } @@ -163,7 +162,7 @@ void InsertPhiElimInstructions(BasicBlock *BB, const vector& CpVec) { Instruction *TermInst = (Instruction*)BB->getTerminator(); - MachineCodeForInstruction &MC4Term = MachineCodeForInstruction::get(TermInst); + MachineCodeForInstruction &MC4Term =MachineCodeForInstruction::get(TermInst); MachineInstr *FirstMIOfTerm = *( MC4Term.begin() ); assert( FirstMIOfTerm && "No Machine Instrs for terminator" ); @@ -209,8 +208,8 @@ InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) PHINode *PN = (PHINode *) (*IIt); - Value *PhiCpRes = new Value(PN->getType(), PN->getValueType(),"PhiCp:"); - + Value *PhiCpRes = new Value(PN->getType(),PN->getValueType(),"PhiCp:"); + // for each incoming value of the phi, insert phi elimination // for (unsigned i = 0; i < PN->getNumIncomingValues(); ++i) { @@ -219,7 +218,8 @@ InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) target.getRegInfo().cpValue2Value(PN->getIncomingValue(i), PhiCpRes); - vector CpVec = FixConstantOperandsForInstr(PN, CpMI, target); + vector CpVec = FixConstantOperandsForInstr(PN, CpMI, + target); CpVec.push_back(CpMI); InsertPhiElimInstructions(PN->getIncomingBlock(i), CpVec); diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp index b63144781dc..3efc5274700 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp @@ -98,12 +98,11 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target) // // Invoke BURG instruction selection for each tree // - const std::hash_set &treeRoots = instrForest.getRootSet(); - for (std::hash_set::const_iterator - treeRootIter = treeRoots.begin(); treeRootIter != treeRoots.end(); - ++treeRootIter) + for (InstrForest::const_root_iterator RI = instrForest.roots_begin(); + RI != instrForest.roots_end(); ++RI) { - InstrTreeNode* basicNode = *treeRootIter; + InstructionNode* basicNode = *RI; + assert(basicNode->parent() == NULL && "A `root' node has a parent?"); // Invoke BURM to label each tree node with a state burm_label(basicNode); @@ -131,7 +130,7 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target) MachineCodeForBasicBlock& bbMvec = (*BI)->getMachineInstrVec(); for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II) { - MachineCodeForInstruction &mvec = MachineCodeForInstruction::get(*II); + MachineCodeForInstruction &mvec =MachineCodeForInstruction::get(*II); for (unsigned i=0; i < mvec.size(); i++) bbMvec.push_back(mvec[i]); } @@ -163,7 +162,7 @@ void InsertPhiElimInstructions(BasicBlock *BB, const vector& CpVec) { Instruction *TermInst = (Instruction*)BB->getTerminator(); - MachineCodeForInstruction &MC4Term = MachineCodeForInstruction::get(TermInst); + MachineCodeForInstruction &MC4Term =MachineCodeForInstruction::get(TermInst); MachineInstr *FirstMIOfTerm = *( MC4Term.begin() ); assert( FirstMIOfTerm && "No Machine Instrs for terminator" ); @@ -209,8 +208,8 @@ InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) PHINode *PN = (PHINode *) (*IIt); - Value *PhiCpRes = new Value(PN->getType(), PN->getValueType(),"PhiCp:"); - + Value *PhiCpRes = new Value(PN->getType(),PN->getValueType(),"PhiCp:"); + // for each incoming value of the phi, insert phi elimination // for (unsigned i = 0; i < PN->getNumIncomingValues(); ++i) { @@ -219,7 +218,8 @@ InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) target.getRegInfo().cpValue2Value(PN->getIncomingValue(i), PhiCpRes); - vector CpVec = FixConstantOperandsForInstr(PN, CpMI, target); + vector CpVec = FixConstantOperandsForInstr(PN, CpMI, + target); CpVec.push_back(CpMI); InsertPhiElimInstructions(PN->getIncomingBlock(i), CpVec); -- 2.34.1