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/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp
index ce3e2c3..20cbe8d 100644
--- a/lib/CodeGen/InstrSelection/InstrForest.cpp
+++ b/lib/CodeGen/InstrSelection/InstrForest.cpp
@@ -31,6 +31,9 @@
 #include "llvm/BasicBlock.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "Support/STLExtras.h"
+#include <iostream>
+using std::cerr;
+using std::vector;
 
 //------------------------------------------------------------------------ 
 // class InstrTreeNode
@@ -119,21 +122,21 @@
 InstructionNode::dumpNode(int indent) const
 {
   for (int i=0; i < indent; i++)
-    cout << "    ";
+    cerr << "    ";
   
-  cout << getInstruction()->getOpcodeName();
+  cerr << getInstruction()->getOpcodeName();
   
   const vector<MachineInstr*> &mvec = getInstruction()->getMachineInstrVec();
   if (mvec.size() > 0)
-    cout << "\tMachine Instructions:  ";
+    cerr << "\tMachine Instructions:  ";
   for (unsigned int i=0; i < mvec.size(); i++)
     {
       mvec[i]->dump(0);
       if (i < mvec.size() - 1)
-	cout << ";  ";
+	cerr << ";  ";
     }
   
-  cout << endl;
+  cerr << "\n";
 }
 
 
@@ -141,9 +144,9 @@
 VRegListNode::dumpNode(int indent) const
 {
   for (int i=0; i < indent; i++)
-    cout << "    ";
+    cerr << "    ";
   
-  cout << "List" << endl;
+  cerr << "List" << "\n";
 }
 
 
@@ -151,29 +154,29 @@
 VRegNode::dumpNode(int indent) const
 {
   for (int i=0; i < indent; i++)
-    cout << "    ";
+    cerr << "    ";
   
-  cout << "VReg " << getValue() << "\t(type "
-       << (int) getValue()->getValueType() << ")" << endl;
+  cerr << "VReg " << getValue() << "\t(type "
+       << (int) getValue()->getValueType() << ")" << "\n";
 }
 
 void
 ConstantNode::dumpNode(int indent) const
 {
   for (int i=0; i < indent; i++)
-    cout << "    ";
+    cerr << "    ";
   
-  cout << "Constant " << getValue() << "\t(type "
-       << (int) getValue()->getValueType() << ")" << endl;
+  cerr << "Constant " << getValue() << "\t(type "
+       << (int) getValue()->getValueType() << ")" << "\n";
 }
 
 void
 LabelNode::dumpNode(int indent) const
 {
   for (int i=0; i < indent; i++)
-    cout << "    ";
+    cerr << "    ";
   
-  cout << "Label " << getValue() << endl;
+  cerr << "Label " << getValue() << "\n";
 }
 
 //------------------------------------------------------------------------
@@ -190,7 +193,7 @@
 
 InstrForest::~InstrForest()
 {
-  for (hash_map<const Instruction*, InstructionNode*>:: iterator I = begin();
+  for (std::hash_map<const Instruction*,InstructionNode*>::iterator I = begin();
        I != end(); ++I)
       delete (*I).second;
 }
@@ -198,7 +201,7 @@
 void
 InstrForest::dump() const
 {
-  for (hash_set<InstructionNode*>::const_iterator I = treeRoots.begin();
+  for (std::hash_set<InstructionNode*>::const_iterator I = treeRoots.begin();
        I != treeRoots.end(); ++I)
     (*I)->dump(/*dumpChildren*/ 1, /*indent*/ 0);
 }
diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp
index b959c90..ab489c5 100644
--- a/lib/CodeGen/InstrSelection/InstrSelection.cpp
+++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp
@@ -23,8 +23,8 @@
 #include "llvm/iPHINode.h"
 #include "llvm/Target/MachineRegInfo.h"
 #include "Support/CommandLine.h"
-#include <string.h>
-
+#include <iostream>
+using std::cerr;
 
 //******************** Internal Data Declarations ************************/
 
@@ -84,17 +84,17 @@
   
   if (SelectDebugLevel >= Select_DebugInstTrees)
     {
-      cout << "\n\n*** Instruction trees for method "
+      cerr << "\n\n*** Instruction trees for method "
 	   << (method->hasName()? method->getName() : "")
-	   << endl << endl;
+	   << "\n\n";
       instrForest.dump();
     }
   
   //
   // Invoke BURG instruction selection for each tree
   // 
-  const hash_set<InstructionNode*> &treeRoots = instrForest.getRootSet();
-  for (hash_set<InstructionNode*>::const_iterator
+  const std::hash_set<InstructionNode*> &treeRoots = instrForest.getRootSet();
+  for (std::hash_set<InstructionNode*>::const_iterator
 	 treeRootIter = treeRoots.begin(); treeRootIter != treeRoots.end();
        ++treeRootIter)
     {
@@ -138,8 +138,7 @@
   
   if (SelectDebugLevel >= Select_PrintMachineCode)
     {
-      cout << endl
-           << "*** Machine instructions after INSTRUCTION SELECTION" << endl;
+      cerr << "\n*** Machine instructions after INSTRUCTION SELECTION\n";
       MachineCodeForMethod::get(method).dump();
     }
   
@@ -210,7 +209,7 @@
 
 	  // insert the copy instruction to the predecessor BB
 
-	  vector<MachineInstr*> CopyInstVec;
+	  std::vector<MachineInstr*> CopyInstVec;
 
 	  MachineInstr *CpMI =
 	    target.getRegInfo().cpValue2Value(PN->getIncomingValue(i), PN);
@@ -250,25 +249,18 @@
 
 	PHINode *PN = (PHINode *) (*IIt);
 
-	Value *PhiCpRes = new Value(PN->getType(), PN->getValueType());
-
-	string *Name = new string("PhiCp:");
-	(*Name) += (int) PhiCpRes;
-	PhiCpRes->setName( *Name );
-  
+	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) {
 
 	  // insert the copy instruction to the predecessor BB
-
 	  MachineInstr *CpMI =
 	    target.getRegInfo().cpValue2Value(PN->getIncomingValue(i),
 					      PhiCpRes);
 
 	  InsertPhiElimInst(PN->getIncomingBlock(i), CpMI);
-
 	}
 
 	
@@ -279,8 +271,6 @@
 	MachineCodeForBasicBlock& bbMvec = BB->getMachineInstrVec();
 
 	bbMvec.insert( bbMvec.begin(),  CpMI2);
-	
-
       }
       else break;   // since PHI nodes can only be at the top
       
@@ -338,7 +328,7 @@
   MachineCodeForVMInstr& mvec = vmInstr->getMachineInstrVec();
   for (int i = (int) mvec.size()-1; i >= 0; i--)
     {
-      vector<MachineInstr*> loadConstVec =
+      std::vector<MachineInstr*> loadConstVec =
         FixConstantOperandsForInstr(vmInstr, mvec[i], target);
       
       if (loadConstVec.size() > 0)
@@ -372,7 +362,7 @@
   
   if (ruleForNode == 0)
     {
-      cerr << "Could not match instruction tree for instr selection" << endl;
+      cerr << "Could not match instruction tree for instr selection\n";
       assert(0);
       return true;
     }
diff --git a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp
index 30d9c7e..34dd83b 100644
--- a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp
+++ b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp
@@ -22,7 +22,7 @@
 #include "llvm/Instruction.h"
 #include "llvm/Type.h"
 #include "llvm/iMemory.h"
-
+using std::vector;
 
 //*************************** Local Functions ******************************/