Changes to build successfully with GCC 3.02


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1503 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp
index 528e5ab..ea41b6f 100644
--- a/lib/CodeGen/InstrSched/InstrScheduling.cpp
+++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp
@@ -18,10 +18,12 @@
 #include "llvm/Instruction.h"
 #include "Support/CommandLine.h"
 #include "SchedPriorities.h"
-#include <hash_set>
 #include <algorithm>
 #include <iterator>
-
+#include <ext/hash_set>
+#include <iostream>
+using std::cerr;
+using std::vector;
 
 //************************* External Data Types *****************************/
 
@@ -353,11 +355,11 @@
   unsigned int totalInstrCount;
   cycles_t curTime;
   cycles_t nextEarliestIssueTime;		// next cycle we can issue
-  vector<hash_set<const SchedGraphNode*> > choicesForSlot; // indexed by slot#
+  vector<std::hash_set<const SchedGraphNode*> > choicesForSlot; // indexed by slot#
   vector<const SchedGraphNode*> choiceVec;	// indexed by node ptr
   vector<int> numInClass;			// indexed by sched class
   vector<cycles_t> nextEarliestStartTime;	// indexed by opCode
-  hash_map<const SchedGraphNode*, DelaySlotInfo*> delaySlotInfoForBranches;
+  std::hash_map<const SchedGraphNode*, DelaySlotInfo*> delaySlotInfoForBranches;
 						// indexed by branch node ptr 
   
 public:
@@ -419,7 +421,7 @@
     return choiceVec[i];
   }
   
-  inline hash_set<const SchedGraphNode*>& getChoicesForSlot(unsigned slotNum) {
+  inline std::hash_set<const SchedGraphNode*>& getChoicesForSlot(unsigned slotNum) {
     assert(slotNum < nslots);
     return choicesForSlot[slotNum];
   }
@@ -495,7 +497,7 @@
 						 bool createIfMissing=false)
   {
     DelaySlotInfo* dinfo;
-    hash_map<const SchedGraphNode*, DelaySlotInfo* >::const_iterator
+    std::hash_map<const SchedGraphNode*, DelaySlotInfo* >::const_iterator
       I = delaySlotInfoForBranches.find(bn);
     if (I == delaySlotInfoForBranches.end())
       {
@@ -552,7 +554,7 @@
 {
   if (schedInfo.numBubblesAfter(node->getOpCode()) > 0)
     { // Update next earliest time before which *nothing* can issue.
-      nextEarliestIssueTime = max(nextEarliestIssueTime,
+      nextEarliestIssueTime = std::max(nextEarliestIssueTime,
 		  curTime + 1 + schedInfo.numBubblesAfter(node->getOpCode()));
     }
   
@@ -603,7 +605,7 @@
   unsigned numIssued;
   for (numIssued = 0; numIssued < maxIssue; numIssued++)
     {
-      int chosenSlot = -1, chosenNodeIndex = -1;
+      int chosenSlot = -1;
       for (unsigned s=startSlot; s < S.nslots; s++)
 	if ((*igroup)[s] == NULL && S.getChoicesForSlot(s).size() == 1)
 	  {
@@ -877,7 +879,7 @@
 	  
 	  assert(s < S.nslots && "No feasible slot for instruction?");
 	  
-	  highestSlotUsed = max(highestSlotUsed, (int) s);
+	  highestSlotUsed = std::max(highestSlotUsed, (int) s);
 	}
       
       assert(highestSlotUsed <= (int) S.nslots-1 && "Invalid slot used?");
@@ -961,7 +963,6 @@
       // Otherwise, just ignore the instruction.
       for (unsigned i=indexForBreakingNode+1; i < S.getNumChoices(); i++)
 	{
-	  bool foundLowerSlot = false;
 	  MachineOpCode opCode = S.getChoice(i)->getOpCode();
 	  for (unsigned int s=startSlot; s < nslotsToUse; s++)
 	    if (S.schedInfo.instrCanUseSlot(opCode, s))
@@ -1001,15 +1002,15 @@
     {
       for (cycles_t c = firstCycle; c <= S.getTime(); c++)
         {
-          cout << "    Cycle " << c << " : Scheduled instructions:\n";
+          cerr << "    Cycle " << (long)c << " : Scheduled instructions:\n";
           const InstrGroup* igroup = S.isched.getIGroup(c);
           for (unsigned int s=0; s < S.nslots; s++)
             {
-              cout << "        ";
+              cerr << "        ";
               if ((*igroup)[s] != NULL)
-                cout << * ((*igroup)[s])->getMachineInstr() << endl;
+                cerr << * ((*igroup)[s])->getMachineInstr() << "\n";
               else
-                cout << "<none>" << endl;
+                cerr << "<none>\n";
             }
         }
     }
@@ -1056,9 +1057,9 @@
       // an instruction can be issued, or the next earliest in which
       // one will be ready, or to the next cycle, whichever is latest.
       // 
-      S.updateTime(max(S.getTime() + 1,
-		       max(S.getEarliestIssueTime(),
-			   S.schedPrio.getEarliestReadyTime())));
+      S.updateTime(std::max(S.getTime() + 1,
+                            std::max(S.getEarliestIssueTime(),
+                                     S.schedPrio.getEarliestReadyTime())));
     }
 }
 
@@ -1499,8 +1500,7 @@
   
   if (SchedDebugLevel >= Sched_PrintSchedGraphs)
     {
-      cout << endl << "*** SCHEDULING GRAPHS FOR INSTRUCTION SCHEDULING"
-	   << endl;
+      cerr << "\n*** SCHEDULING GRAPHS FOR INSTRUCTION SCHEDULING\n";
       graphSet.dump();
     }
   
@@ -1513,7 +1513,7 @@
       const BasicBlock* bb = bbvec[0];
       
       if (SchedDebugLevel >= Sched_PrintSchedTrace)
-	cout << endl << "*** TRACE OF INSTRUCTION SCHEDULING OPERATIONS\n\n";
+	cerr << "\n*** TRACE OF INSTRUCTION SCHEDULING OPERATIONS\n\n";
       
       SchedPriorities schedPrio(method, graph);	     // expensive!
       SchedulingManager S(target, graph, schedPrio);
@@ -1527,8 +1527,7 @@
   
   if (SchedDebugLevel >= Sched_PrintMachineCode)
     {
-      cout << endl
-	   << "*** Machine instructions after INSTRUCTION SCHEDULING" << endl;
+      cerr << "\n*** Machine instructions after INSTRUCTION SCHEDULING\n";
       MachineCodeForMethod::get(method).dump();
     }
   
diff --git a/lib/CodeGen/InstrSched/SchedGraph.cpp b/lib/CodeGen/InstrSched/SchedGraph.cpp
index 9e9af5b..7c83e1a 100644
--- a/lib/CodeGen/InstrSched/SchedGraph.cpp
+++ b/lib/CodeGen/InstrSched/SchedGraph.cpp
@@ -23,10 +23,16 @@
 #include "llvm/Target/MachineRegInfo.h"
 #include "llvm/iOther.h"
 #include "Support/StringExtras.h"
+#include "Support/STLExtras.h"
 #include <algorithm>
-#include <hash_map>
 #include <vector>
+#include <iostream>
+#include <ext/hash_map>
 
+using std::vector;
+using std::pair;
+using std::hash_map;
+using std::cerr;
 
 //*********************** Internal Data Structures *************************/
 
@@ -132,7 +138,7 @@
 }
 
 void SchedGraphEdge::dump(int indent=0) const {
-  cout << string(indent*2, ' ') << *this; 
+  cerr << std::string(indent*2, ' ') << *this; 
 }
 
 
@@ -168,7 +174,7 @@
 }
 
 void SchedGraphNode::dump(int indent=0) const {
-  cout << string(indent*2, ' ') << *this; 
+  cerr << std::string(indent*2, ' ') << *this; 
 }
 
 
@@ -222,21 +228,20 @@
 		       const TargetMachine& target)
 {
   bbVec.push_back(bb);
-  this->buildGraph(target);
+  buildGraph(target);
 }
 
 
 /*dtor*/
 SchedGraph::~SchedGraph()
 {
-  for (iterator I=begin(); I != end(); ++I)
+  for (const_iterator I = begin(); I != end(); ++I)
     {
-      SchedGraphNode* node = (*I).second;
+      SchedGraphNode *node = I->second;
       
       // for each node, delete its out-edges
-      for (SchedGraphNode::iterator I = node->beginOutEdges();
-	   I != node->endOutEdges(); ++I)
-	delete *I;
+      std::for_each(node->beginOutEdges(), node->endOutEdges(),
+                    deleter<SchedGraphEdge>);
       
       // then delete the node itself.
       delete node;
@@ -247,24 +252,24 @@
 void
 SchedGraph::dump() const
 {
-  cout << "  Sched Graph for Basic Blocks: ";
+  cerr << "  Sched Graph for Basic Blocks: ";
   for (unsigned i=0, N=bbVec.size(); i < N; i++)
     {
-      cout << (bbVec[i]->hasName()? bbVec[i]->getName() : "block")
+      cerr << (bbVec[i]->hasName()? bbVec[i]->getName() : "block")
 	   << " (" << bbVec[i] << ")"
 	   << ((i == N-1)? "" : ", ");
     }
   
-  cout << endl << endl << "    Actual Root nodes : ";
+  cerr << "\n\n    Actual Root nodes : ";
   for (unsigned i=0, N=graphRoot->outEdges.size(); i < N; i++)
-    cout << graphRoot->outEdges[i]->getSink()->getNodeId()
+    cerr << graphRoot->outEdges[i]->getSink()->getNodeId()
 	 << ((i == N-1)? "" : ", ");
   
-  cout << endl << "    Graph Nodes:" << endl;
+  cerr << "\n    Graph Nodes:\n";
   for (const_iterator I=begin(); I != end(); ++I)
-    cout << endl << * (*I).second;
+    cerr << "\n" << *I->second;
   
-  cout << endl;
+  cerr << "\n";
 }
 
 
@@ -690,7 +695,7 @@
 	    // this operand is a definition or use of value `instr'
 	    SchedGraphNode* node = this->getGraphNodeForInstr(mvec[i]);
             assert(node && "No node for machine instruction in this BB?");
-            refVec.push_back(make_pair(node, o));
+            refVec.push_back(std::make_pair(node, o));
           }
       }
   
@@ -747,8 +752,8 @@
         {
           int regNum = mop.getMachineRegNum();
 	  if (regNum != target.getRegInfo().getZeroRegNum())
-            regToRefVecMap[mop.getMachineRegNum()].push_back(make_pair(node,
-                                                                       i));
+            regToRefVecMap[mop.getMachineRegNum()].push_back(
+                                                  std::make_pair(node, i));
           continue;                     // nothing more to do
 	}
       
@@ -762,7 +767,7 @@
              && "Do not expect any other kind of operand to be defined!");
       
       const Instruction* defInstr = cast<Instruction>(mop.getVRegValue());
-      valueToDefVecMap[defInstr].push_back(make_pair(node, i)); 
+      valueToDefVecMap[defInstr].push_back(std::make_pair(node, i)); 
     }
   
   // 
@@ -774,7 +779,7 @@
       if (const Instruction* defInstr =
           dyn_cast_or_null<Instruction>(minstr.getImplicitRef(i)))
         {
-          valueToDefVecMap[defInstr].push_back(make_pair(node, -i)); 
+          valueToDefVecMap[defInstr].push_back(std::make_pair(node, -i)); 
         }
 }
 
@@ -860,7 +865,6 @@
 void
 SchedGraph::buildGraph(const TargetMachine& target)
 {
-  const MachineInstrInfo& mii = target.getInstrInfo();
   const BasicBlock* bb = bbVec[0];
   
   assert(bbVec.size() == 1 && "Only handling a single basic block here");
@@ -966,24 +970,22 @@
 SchedGraphSet::~SchedGraphSet()
 {
   // delete all the graphs
-  for (iterator I=begin(); I != end(); ++I)
-    delete (*I).second;
+  for (const_iterator I = begin(); I != end(); ++I)
+    delete I->second;
 }
 
 
 void
 SchedGraphSet::dump() const
 {
-  cout << "======== Sched graphs for method `"
-       << (method->hasName()? method->getName() : "???")
-       << "' ========" << endl << endl;
+  cerr << "======== Sched graphs for method `" << method->getName()
+       << "' ========\n\n";
   
   for (const_iterator I=begin(); I != end(); ++I)
-    (*I).second->dump();
+    I->second->dump();
   
-  cout << endl << "====== End graphs for method `"
-       << (method->hasName()? method->getName() : "")
-       << "' ========" << endl << endl;
+  cerr << "\n====== End graphs for method `" << method->getName()
+       << "' ========\n\n";
 }
 
 
@@ -1000,8 +1002,7 @@
 
 
 
-ostream&
-operator<<(ostream& os, const SchedGraphEdge& edge)
+std::ostream &operator<<(std::ostream &os, const SchedGraphEdge& edge)
 {
   os << "edge [" << edge.src->getNodeId() << "] -> ["
      << edge.sink->getNodeId() << "] : ";
@@ -1015,33 +1016,30 @@
   default: assert(0); break;
   }
   
-  os << " : delay = " << edge.minDelay << endl;
+  os << " : delay = " << edge.minDelay << "\n";
   
   return os;
 }
 
-ostream&
-operator<<(ostream& os, const SchedGraphNode& node)
+std::ostream &operator<<(std::ostream &os, const SchedGraphNode& node)
 {
-  os << string(8, ' ')
+  os << std::string(8, ' ')
      << "Node " << node.nodeId << " : "
-     << "latency = " << node.latency << endl << string(12, ' ');
+     << "latency = " << node.latency << "\n" << std::string(12, ' ');
   
   if (node.getMachineInstr() == NULL)
-    os << "(Dummy node)" << endl;
+    os << "(Dummy node)\n";
   else
     {
-      os << *node.getMachineInstr() << endl << string(12, ' ');
-      os << node.inEdges.size() << " Incoming Edges:" << endl;
+      os << *node.getMachineInstr() << "\n" << std::string(12, ' ');
+      os << node.inEdges.size() << " Incoming Edges:\n";
       for (unsigned i=0, N=node.inEdges.size(); i < N; i++)
-	  os << string(16, ' ') << *node.inEdges[i];
+	  os << std::string(16, ' ') << *node.inEdges[i];
   
-      os << string(12, ' ') << node.outEdges.size()
-         << " Outgoing Edges:" << endl;
+      os << std::string(12, ' ') << node.outEdges.size()
+         << " Outgoing Edges:\n";
       for (unsigned i=0, N=node.outEdges.size(); i < N; i++)
-	{
-	  os << string(16, ' ') << * node.outEdges[i];
-	}
+        os << std::string(16, ' ') << *node.outEdges[i];
     }
   
   return os;
diff --git a/lib/CodeGen/InstrSched/SchedGraph.h b/lib/CodeGen/InstrSched/SchedGraph.h
index a4567a5..2890241 100644
--- a/lib/CodeGen/InstrSched/SchedGraph.h
+++ b/lib/CodeGen/InstrSched/SchedGraph.h
@@ -24,7 +24,7 @@
 #include "Support/NonCopyable.h"
 #include "Support/HashExtras.h"
 #include "Support/GraphTraits.h"
-#include <hash_map>
+#include <ext/hash_map>
 
 class Value;
 class Instruction;
@@ -128,7 +128,7 @@
   // 
   // Debugging support
   // 
-  friend ostream& operator<<(ostream& os, const SchedGraphEdge& edge);
+  friend std::ostream& operator<<(std::ostream& os, const SchedGraphEdge& edge);
   
   void		dump	(int indent=0) const;
     
@@ -144,16 +144,16 @@
   unsigned int nodeId;
   const BasicBlock* bb;
   const MachineInstr* minstr;
-  vector<SchedGraphEdge*> inEdges;
-  vector<SchedGraphEdge*> outEdges;
+  std::vector<SchedGraphEdge*> inEdges;
+  std::vector<SchedGraphEdge*> outEdges;
   int origIndexInBB;            // original position of machine instr in BB
   int latency;
   
 public:
-  typedef vector<SchedGraphEdge*>::      iterator	        iterator;
-  typedef vector<SchedGraphEdge*>::const_iterator         const_iterator;
-  typedef vector<SchedGraphEdge*>::      reverse_iterator reverse_iterator;
-  typedef vector<SchedGraphEdge*>::const_reverse_iterator const_reverse_iterator;
+  typedef std::vector<SchedGraphEdge*>::      iterator	       iterator;
+  typedef std::vector<SchedGraphEdge*>::const_iterator         const_iterator;
+  typedef std::vector<SchedGraphEdge*>::      reverse_iterator reverse_iterator;
+  typedef std::vector<SchedGraphEdge*>::const_reverse_iterator const_reverse_iterator;
   
 public:
   //
@@ -186,7 +186,7 @@
   //
   // Debugging support
   // 
-  friend ostream& operator<<(ostream& os, const SchedGraphNode& node);
+  friend std::ostream& operator<<(std::ostream& os, const SchedGraphNode& node);
   
   void		dump	(int indent=0) const;
   
@@ -214,22 +214,23 @@
 
 class SchedGraph :
   public NonCopyable,
-  private hash_map<const MachineInstr*, SchedGraphNode*>
+  private std::hash_map<const MachineInstr*, SchedGraphNode*>
 {
 private:
-  vector<const BasicBlock*> bbVec;	// basic blocks included in the graph
+  std::vector<const BasicBlock*> bbVec; // basic blocks included in the graph
   SchedGraphNode* graphRoot;		// the root and leaf are not inserted
   SchedGraphNode* graphLeaf;		//  in the hash_map (see getNumNodes())
   
+  typedef std::hash_map<const MachineInstr*, SchedGraphNode*> map_base;
 public:
-  typedef hash_map<const MachineInstr*, SchedGraphNode*>::iterator iterator;
-  typedef hash_map<const MachineInstr*, SchedGraphNode*>::const_iterator const_iterator;
+  using map_base::iterator;
+  using map_base::const_iterator;
   
 public:
   //
   // Accessor methods
   //
-  const vector<const BasicBlock*>& getBasicBlocks() const { return bbVec; }
+  const std::vector<const BasicBlock*>& getBasicBlocks() const { return bbVec; }
   const unsigned int		   getNumNodes()    const { return size()+2; }
   SchedGraphNode*		   getRoot()	    const { return graphRoot; }
   SchedGraphNode*		   getLeaf()	    const { return graphLeaf; }
@@ -257,19 +258,9 @@
   // Unordered iterators.
   // Return values is pair<const MachineIntr*,SchedGraphNode*>.
   //
-  iterator	begin()	{
-    return hash_map<const MachineInstr*, SchedGraphNode*>::begin();
-  }
-  iterator	end() {
-    return hash_map<const MachineInstr*, SchedGraphNode*>::end();
-  }
-  const_iterator begin() const {
-    return hash_map<const MachineInstr*, SchedGraphNode*>::begin();
-  }
-  const_iterator end()	const {
-    return hash_map<const MachineInstr*, SchedGraphNode*>::end();
-  }
-  
+  using map_base::begin;
+  using map_base::end;
+
   //
   // Ordered iterators.
   // Return values is pair<const MachineIntr*,SchedGraphNode*>.
@@ -308,13 +299,13 @@
   
   void          buildNodesforBB         (const TargetMachine& target,
                                          const BasicBlock* bb,
-                                         vector<SchedGraphNode*>& memNodeVec,
+                                         std::vector<SchedGraphNode*>& memNod,
                                          RegToRefVecMap& regToRefVecMap,
                                          ValueToDefVecMap& valueToDefVecMap);
   
   void          findDefUseInfoAtInstr   (const TargetMachine& target,
                                          SchedGraphNode* node,
-                                         vector<SchedGraphNode*>& memNodeVec,
+                                         std::vector<SchedGraphNode*>& memNode,
                                          RegToRefVecMap& regToRefVecMap,
                                          ValueToDefVecMap& valueToDefVecMap);
                                          
@@ -325,10 +316,10 @@
   void		addCDEdges		(const TerminatorInst* term,
 					 const TargetMachine& target);
   
-  void		addMemEdges         (const vector<SchedGraphNode*>& memNodeVec,
+  void		addMemEdges         (const std::vector<SchedGraphNode*>& memNod,
                                      const TargetMachine& target);
   
-  void          addCallCCEdges      (const vector<SchedGraphNode*>& memNodeVec,
+  void          addCallCCEdges      (const std::vector<SchedGraphNode*>& memNod,
                                      MachineCodeForBasicBlock& bbMvec,
                                      const TargetMachine& target);
     
@@ -347,14 +338,15 @@
 
 class SchedGraphSet :  
   public NonCopyable,
-  private hash_map<const BasicBlock*, SchedGraph*>
+  private std::hash_map<const BasicBlock*, SchedGraph*>
 {
 private:
   const Method* method;
   
 public:
-  typedef hash_map<const BasicBlock*, SchedGraph*>::iterator iterator;
-  typedef hash_map<const BasicBlock*, SchedGraph*>::const_iterator const_iterator;
+  typedef std::hash_map<const BasicBlock*, SchedGraph*> map_base;
+  using map_base::iterator;
+  using map_base::const_iterator;
   
 public:
   /*ctor*/	SchedGraphSet		(const Method* _method,
@@ -372,18 +364,8 @@
   //
   // Iterators
   //
-  iterator	begin()	{
-    return hash_map<const BasicBlock*, SchedGraph*>::begin();
-  }
-  iterator	end() {
-    return hash_map<const BasicBlock*, SchedGraph*>::end();
-  }
-  const_iterator begin() const {
-    return hash_map<const BasicBlock*, SchedGraph*>::begin();
-  }
-  const_iterator end()	const {
-    return hash_map<const BasicBlock*, SchedGraph*>::end();
-  }
+  using map_base::begin;
+  using map_base::end;
   
   //
   // Debugging support
@@ -544,14 +526,7 @@
 };
 
 
-//************************ External Functions *****************************/
-
-
-ostream& operator<<(ostream& os, const SchedGraphEdge& edge);
-
-ostream& operator<<(ostream& os, const SchedGraphNode& node);
-
-
-/***************************************************************************/
+std::ostream &operator<<(std::ostream& os, const SchedGraphEdge& edge);
+std::ostream &operator<<(std::ostream &os, const SchedGraphNode& node);
 
 #endif
diff --git a/lib/CodeGen/InstrSched/SchedPriorities.cpp b/lib/CodeGen/InstrSched/SchedPriorities.cpp
index 1769707..8cde252 100644
--- a/lib/CodeGen/InstrSched/SchedPriorities.cpp
+++ b/lib/CodeGen/InstrSched/SchedPriorities.cpp
@@ -20,20 +20,17 @@
 
 #include "SchedPriorities.h"
 #include "Support/PostOrderIterator.h"
-
+#include <iostream>
+using std::cerr;
 
 SchedPriorities::SchedPriorities(const Method* method,
 				 const SchedGraph* _graph)
   : curTime(0),
     graph(_graph),
-    methodLiveVarInfo(method),				 // expensive!
-    lastUseMap(),
-    nodeDelayVec(_graph->getNumNodes(),INVALID_LATENCY), //make errors obvious
+    methodLiveVarInfo(method),	                          // expensive!
+    nodeDelayVec(_graph->getNumNodes(), INVALID_LATENCY), // make errors obvious
     earliestForNode(_graph->getNumNodes(), 0),
     earliestReadyTime(0),
-    candsAsHeap(),
-    candsAsSet(),
-    mcands(),
     nextToTry(candsAsHeap.begin())
 {
   methodLiveVarInfo.analyze();
@@ -66,7 +63,7 @@
 	       E != node->endOutEdges(); ++E)
 	    {
 	      cycles_t sinkDelay = getNodeDelayRef((*E)->getSink());
-	      nodeDelay = max(nodeDelay, sinkDelay + (*E)->getMinDelay());
+	      nodeDelay = std::max(nodeDelay, sinkDelay + (*E)->getMinDelay());
 	    }
 	}
       getNodeDelayRef(node) = nodeDelay;
@@ -87,20 +84,37 @@
   
 #undef TEST_HEAP_CONVERSION
 #ifdef TEST_HEAP_CONVERSION
-  cout << "Before heap conversion:" << endl;
+  cerr << "Before heap conversion:\n";
   copy(candsAsHeap.begin(), candsAsHeap.end(),
-       ostream_iterator<NodeDelayPair*>(cout,"\n"));
+       ostream_iterator<NodeDelayPair*>(cerr,"\n"));
 #endif
   
   candsAsHeap.makeHeap();
   
 #ifdef TEST_HEAP_CONVERSION
-  cout << "After heap conversion:" << endl;
+  cerr << "After heap conversion:\n";
   copy(candsAsHeap.begin(), candsAsHeap.end(),
-       ostream_iterator<NodeDelayPair*>(cout,"\n"));
+       ostream_iterator<NodeDelayPair*>(cerr,"\n"));
 #endif
 }
 
+void
+SchedPriorities::insertReady(const SchedGraphNode* node)
+{
+  candsAsHeap.insert(node, nodeDelayVec[node->getNodeId()]);
+  candsAsSet.insert(node);
+  mcands.clear(); // ensure reset choices is called before any more choices
+  earliestReadyTime = std::min(earliestReadyTime,
+                               earliestForNode[node->getNodeId()]);
+  
+  if (SchedDebugLevel >= Sched_PrintSchedTrace)
+    {
+      cerr << "    Cycle " << (long)getTime() << ": "
+	   << " Node " << node->getNodeId() << " is ready; "
+	   << " Delay = " << (long)getNodeDelayRef(node) << "; Instruction: \n";
+      cerr << "        " << *node->getMachineInstr() << "\n";
+    }
+}
 
 void
 SchedPriorities::issuedReadyNodeAt(cycles_t curTime,
@@ -116,7 +130,7 @@
       for (NodeHeap::const_iterator I=candsAsHeap.begin();
 	   I != candsAsHeap.end(); ++I)
 	if (candsAsHeap.getNode(I))
-	  earliestReadyTime = min(earliestReadyTime, 
+	  earliestReadyTime = std::min(earliestReadyTime, 
 				getEarliestForNodeRef(candsAsHeap.getNode(I)));
     }
   
@@ -125,7 +139,7 @@
        E != node->endOutEdges(); ++E)
     {
       cycles_t& etime = getEarliestForNodeRef((*E)->getSink());
-      etime = max(etime, curTime + (*E)->getMinDelay());
+      etime = std::max(etime, curTime + (*E)->getMinDelay());
     }    
 }
 
@@ -140,14 +154,14 @@
 //----------------------------------------------------------------------
 
 inline int
-SchedPriorities::chooseByRule1(vector<candIndex>& mcands)
+SchedPriorities::chooseByRule1(std::vector<candIndex>& mcands)
 {
   return (mcands.size() == 1)? 0	// only one choice exists so take it
 			     : -1;	// -1 indicates multiple choices
 }
 
 inline int
-SchedPriorities::chooseByRule2(vector<candIndex>& mcands)
+SchedPriorities::chooseByRule2(std::vector<candIndex>& mcands)
 {
   assert(mcands.size() >= 1 && "Should have at least one candidate here.");
   for (unsigned i=0, N = mcands.size(); i < N; i++)
@@ -158,7 +172,7 @@
 }
 
 inline int
-SchedPriorities::chooseByRule3(vector<candIndex>& mcands)
+SchedPriorities::chooseByRule3(std::vector<candIndex>& mcands)
 {
   assert(mcands.size() >= 1 && "Should have at least one candidate here.");
   int maxUses = candsAsHeap.getNode(mcands[0])->getNumOutEdges();	
@@ -224,7 +238,7 @@
 
 
 void
-SchedPriorities::findSetWithMaxDelay(vector<candIndex>& mcands,
+SchedPriorities::findSetWithMaxDelay(std::vector<candIndex>& mcands,
 				     const SchedulingManager& S)
 {
   if (mcands.size() == 0 && nextToTry != candsAsHeap.end())
@@ -240,12 +254,12 @@
       
       if (SchedDebugLevel >= Sched_PrintSchedTrace)
 	{
-	  cout << "    Cycle " << this->getTime() << ": "
-	       << "Next highest delay = " << maxDelay << " : "
+	  cerr << "    Cycle " << (long)getTime() << ": "
+	       << "Next highest delay = " << (long)maxDelay << " : "
 	       << mcands.size() << " Nodes with this delay: ";
 	  for (unsigned i=0; i < mcands.size(); i++)
-	    cout << candsAsHeap.getNode(mcands[i])->getNodeId() << ", ";
-	  cout << endl;
+	    cerr << candsAsHeap.getNode(mcands[i])->getNodeId() << ", ";
+	  cerr << "\n";
 	}
     }
 }
@@ -257,10 +271,10 @@
 {
   const MachineInstr* minstr = graphNode->getMachineInstr();
   
-  hash_map<const MachineInstr*, bool>::const_iterator
+  std::hash_map<const MachineInstr*, bool>::const_iterator
     ui = lastUseMap.find(minstr);
   if (ui != lastUseMap.end())
-    return (*ui).second;
+    return ui->second;
   
   // else check if instruction is a last use and save it in the hash_map
   bool hasLastUse = false;
diff --git a/lib/CodeGen/InstrSched/SchedPriorities.h b/lib/CodeGen/InstrSched/SchedPriorities.h
index 81a2e6a..a8b3e23 100644
--- a/lib/CodeGen/InstrSched/SchedPriorities.h
+++ b/lib/CodeGen/InstrSched/SchedPriorities.h
@@ -26,6 +26,7 @@
 #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
 #include "llvm/Target/MachineSchedInfo.h"
 #include <list>
+#include <ostream>
 
 class Method;
 class MachineInstr;
@@ -36,22 +37,22 @@
   const SchedGraphNode* node;
   cycles_t delay;
   NodeDelayPair(const SchedGraphNode* n, cycles_t d) :  node(n), delay(d) {}
-  inline bool operator< (const NodeDelayPair& np) { return delay < np.delay; }
+  inline bool operator<(const NodeDelayPair& np) { return delay < np.delay; }
 };
 
 inline bool
 NDPLessThan(const NodeDelayPair* np1, const NodeDelayPair* np2)
 {
-  return (np1->delay < np2->delay);
+  return np1->delay < np2->delay;
 }
 
-class NodeHeap: public list<NodeDelayPair*>, public NonCopyable {
+class NodeHeap: public std::list<NodeDelayPair*>, public NonCopyable {
 public:
-  typedef list<NodeDelayPair*>::iterator iterator;
-  typedef list<NodeDelayPair*>::const_iterator const_iterator;
+  typedef std::list<NodeDelayPair*>::iterator iterator;
+  typedef std::list<NodeDelayPair*>::const_iterator const_iterator;
   
 public:
-  /*ctor*/	  NodeHeap	() : list<NodeDelayPair*>(), _size(0) {}
+  /*ctor*/	  NodeHeap	() : std::list<NodeDelayPair*>(), _size(0) {}
   /*dtor*/	  ~NodeHeap	() {}
   
   inline unsigned int	size	() const { return _size; }
@@ -89,7 +90,7 @@
 	iterator I=begin();
 	for ( ; I != end() && getDelay(I) >= delay; ++I)
 	  ;
-	list<NodeDelayPair*>::insert(I, ndp);
+	std::list<NodeDelayPair*>::insert(I, ndp);
       }
     _size++;
   }
@@ -131,22 +132,22 @@
   cycles_t curTime;
   const SchedGraph* graph;
   MethodLiveVarInfo methodLiveVarInfo;
-  hash_map<const MachineInstr*, bool> lastUseMap;
-  vector<cycles_t> nodeDelayVec;
-  vector<cycles_t> earliestForNode;
+  std::hash_map<const MachineInstr*, bool> lastUseMap;
+  std::vector<cycles_t> nodeDelayVec;
+  std::vector<cycles_t> earliestForNode;
   cycles_t earliestReadyTime;
   NodeHeap candsAsHeap;				// candidate nodes, ready to go
-  hash_set<const SchedGraphNode*> candsAsSet;	// same entries as candsAsHeap,
+  std::hash_set<const SchedGraphNode*> candsAsSet;//same entries as candsAsHeap,
 						//   but as set for fast lookup
-  vector<candIndex> mcands;			// holds pointers into cands
+  std::vector<candIndex> mcands;                // holds pointers into cands
   candIndex nextToTry;				// next cand after the last
 						//   one tried in this cycle
   
-  int		chooseByRule1		(vector<candIndex>& mcands);
-  int		chooseByRule2		(vector<candIndex>& mcands);
-  int		chooseByRule3		(vector<candIndex>& mcands);
+  int		chooseByRule1		(std::vector<candIndex>& mcands);
+  int		chooseByRule2		(std::vector<candIndex>& mcands);
+  int		chooseByRule3		(std::vector<candIndex>& mcands);
   
-  void		findSetWithMaxDelay	(vector<candIndex>& mcands,
+  void		findSetWithMaxDelay	(std::vector<candIndex>& mcands,
 					 const SchedulingManager& S);
   
   void		computeDelays		(const SchedGraph* graph);
@@ -169,36 +170,15 @@
 };
 
 
-inline void
-SchedPriorities::insertReady(const SchedGraphNode* node)
-{
-  candsAsHeap.insert(node, nodeDelayVec[node->getNodeId()]);
-  candsAsSet.insert(node);
-  mcands.clear(); // ensure reset choices is called before any more choices
-  earliestReadyTime = min(earliestReadyTime,
-			  earliestForNode[node->getNodeId()]);
-  
-  if (SchedDebugLevel >= Sched_PrintSchedTrace)
-    {
-      cout << "    Cycle " << this->getTime() << ": "
-	   << " Node " << node->getNodeId() << " is ready; "
-	   << " Delay = " << this->getNodeDelayRef(node) << "; Instruction: "
-	   << endl;
-      cout << "        " << *node->getMachineInstr() << endl;
-    }
-}
-
 inline void SchedPriorities::updateTime(cycles_t c) {
   curTime = c;
   nextToTry = candsAsHeap.begin();
   mcands.clear();
 }
 
-inline ostream& operator<< (ostream& os, const NodeDelayPair* nd) {
+inline std::ostream &operator<<(std::ostream &os, const NodeDelayPair* nd) {
   return os << "Delay for node " << nd->node->getNodeId()
-	    << " = " << nd->delay << endl;
+	    << " = " << (long)nd->delay << "\n";
 }
 
-/***************************************************************************/
-
 #endif