aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-01-20 22:54:45 +0000
committerChris Lattner <sabre@nondot.org>2002-01-20 22:54:45 +0000
commit697954c15da58bd8b186dbafdedd8b06db770201 (patch)
treee119a71f09b5c2513c8c270161ae2a858c6f3b96 /lib
parent13c4659220bc78a0a3529f4d9e57546e898088e3 (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/Expressions.cpp7
-rw-r--r--lib/Analysis/IPA/CallGraph.cpp8
-rw-r--r--lib/Analysis/IPA/FindUnsafePointerTypes.cpp8
-rw-r--r--lib/Analysis/IPA/FindUsedTypes.cpp10
-rw-r--r--lib/Analysis/InductionVariable.cpp4
-rw-r--r--lib/Analysis/IntervalPartition.cpp1
-rw-r--r--lib/Analysis/LiveVar/BBLiveVar.cpp13
-rw-r--r--lib/Analysis/LiveVar/BBLiveVar.h2
-rw-r--r--lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp12
-rw-r--r--lib/Analysis/LiveVar/ValueSet.cpp21
-rw-r--r--lib/Analysis/LoopDepth.cpp4
-rw-r--r--lib/Analysis/LoopInfo.cpp6
-rw-r--r--lib/Analysis/ModuleAnalyzer.cpp6
-rw-r--r--lib/Analysis/PostDominators.cpp2
-rw-r--r--lib/Analysis/Writer.cpp30
-rw-r--r--lib/AsmParser/Parser.cpp3
-rw-r--r--lib/AsmParser/ParserInternals.h19
-rw-r--r--lib/AsmParser/llvmAsmParser.y47
-rw-r--r--lib/Bytecode/Reader/ConstantReader.cpp17
-rw-r--r--lib/Bytecode/Reader/InstructionReader.cpp7
-rw-r--r--lib/Bytecode/Reader/Reader.cpp32
-rw-r--r--lib/Bytecode/Reader/ReaderInternals.h26
-rw-r--r--lib/Bytecode/Writer/ConstantWriter.cpp4
-rw-r--r--lib/Bytecode/Writer/InstructionWriter.cpp10
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.cpp5
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.h8
-rw-r--r--lib/Bytecode/Writer/Writer.cpp14
-rw-r--r--lib/Bytecode/Writer/WriterInternals.h8
-rw-r--r--lib/CodeGen/InstrSched/InstrScheduling.cpp43
-rw-r--r--lib/CodeGen/InstrSched/SchedGraph.cpp92
-rw-r--r--lib/CodeGen/InstrSched/SchedGraph.h85
-rw-r--r--lib/CodeGen/InstrSched/SchedPriorities.cpp62
-rw-r--r--lib/CodeGen/InstrSched/SchedPriorities.h58
-rw-r--r--lib/CodeGen/InstrSelection/InstrForest.cpp37
-rw-r--r--lib/CodeGen/InstrSelection/InstrSelection.cpp32
-rw-r--r--lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp2
-rw-r--r--lib/CodeGen/MachineInstr.cpp53
-rw-r--r--lib/CodeGen/RegAlloc/IGNode.cpp24
-rw-r--r--lib/CodeGen/RegAlloc/IGNode.h13
-rw-r--r--lib/CodeGen/RegAlloc/InterferenceGraph.cpp76
-rw-r--r--lib/CodeGen/RegAlloc/InterferenceGraph.h12
-rw-r--r--lib/CodeGen/RegAlloc/LiveRange.h5
-rw-r--r--lib/CodeGen/RegAlloc/LiveRangeInfo.cpp124
-rw-r--r--lib/CodeGen/RegAlloc/LiveRangeInfo.h10
-rw-r--r--lib/CodeGen/RegAlloc/PhyRegAlloc.cpp170
-rw-r--r--lib/CodeGen/RegAlloc/PhyRegAlloc.h18
-rw-r--r--lib/CodeGen/RegAlloc/RegClass.cpp25
-rw-r--r--lib/CodeGen/RegAlloc/RegClass.h16
-rw-r--r--lib/ExecutionEngine/Interpreter/Execution.cpp85
-rw-r--r--lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h2
-rw-r--r--lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp25
-rw-r--r--lib/ExecutionEngine/Interpreter/Interpreter.h31
-rw-r--r--lib/ExecutionEngine/Interpreter/Support.cpp22
-rw-r--r--lib/ExecutionEngine/Interpreter/UserInput.cpp27
-rw-r--r--lib/Linker/LinkModules.cpp32
-rw-r--r--lib/Support/Annotation.cpp4
-rw-r--r--lib/Support/CommandLine.cpp40
-rw-r--r--lib/Target/SparcV9/InstrSched/InstrScheduling.cpp43
-rw-r--r--lib/Target/SparcV9/InstrSched/SchedGraph.cpp92
-rw-r--r--lib/Target/SparcV9/InstrSched/SchedGraph.h85
-rw-r--r--lib/Target/SparcV9/InstrSched/SchedPriorities.cpp62
-rw-r--r--lib/Target/SparcV9/InstrSched/SchedPriorities.h58
-rw-r--r--lib/Target/SparcV9/InstrSelection/InstrForest.cpp37
-rw-r--r--lib/Target/SparcV9/InstrSelection/InstrSelection.cpp32
-rw-r--r--lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp2
-rw-r--r--lib/Target/SparcV9/LiveVar/BBLiveVar.cpp13
-rw-r--r--lib/Target/SparcV9/LiveVar/BBLiveVar.h2
-rw-r--r--lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp12
-rw-r--r--lib/Target/SparcV9/LiveVar/ValueSet.cpp21
-rw-r--r--lib/Target/SparcV9/RegAlloc/IGNode.cpp24
-rw-r--r--lib/Target/SparcV9/RegAlloc/IGNode.h13
-rw-r--r--lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp76
-rw-r--r--lib/Target/SparcV9/RegAlloc/InterferenceGraph.h12
-rw-r--r--lib/Target/SparcV9/RegAlloc/LiveRange.h5
-rw-r--r--lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp124
-rw-r--r--lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h10
-rw-r--r--lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp170
-rw-r--r--lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h18
-rw-r--r--lib/Target/SparcV9/RegAlloc/RegClass.cpp25
-rw-r--r--lib/Target/SparcV9/RegAlloc/RegClass.h16
-rw-r--r--lib/Target/SparcV9/SparcV9AsmPrinter.cpp68
-rw-r--r--lib/Target/SparcV9/SparcV9InstrInfo.cpp34
-rw-r--r--lib/Target/SparcV9/SparcV9InstrSelection.cpp23
-rw-r--r--lib/Target/SparcV9/SparcV9InstrSelectionSupport.h2
-rw-r--r--lib/Target/SparcV9/SparcV9Internals.h40
-rw-r--r--lib/Target/SparcV9/SparcV9RegClassInfo.cpp19
-rw-r--r--lib/Target/SparcV9/SparcV9RegClassInfo.h16
-rw-r--r--lib/Target/SparcV9/SparcV9RegInfo.cpp86
-rw-r--r--lib/Target/SparcV9/SparcV9TargetMachine.cpp12
-rw-r--r--lib/Target/TargetData.cpp6
-rw-r--r--lib/Target/TargetSchedInfo.cpp14
-rw-r--r--lib/Transforms/ExprTypeConvert.cpp40
-rw-r--r--lib/Transforms/HoistPHIConstants.cpp10
-rw-r--r--lib/Transforms/IPO/ConstantMerge.cpp8
-rw-r--r--lib/Transforms/IPO/DeadTypeElimination.cpp22
-rw-r--r--lib/Transforms/IPO/GlobalDCE.cpp8
-rw-r--r--lib/Transforms/IPO/InlineSimple.cpp13
-rw-r--r--lib/Transforms/IPO/MutateStructTypes.cpp16
-rw-r--r--lib/Transforms/IPO/SimpleStructMutation.cpp14
-rw-r--r--lib/Transforms/Instrumentation/TraceValues.cpp15
-rw-r--r--lib/Transforms/LevelRaise.cpp8
-rw-r--r--lib/Transforms/Scalar/ADCE.cpp20
-rw-r--r--lib/Transforms/Scalar/ConstantProp.cpp2
-rw-r--r--lib/Transforms/Scalar/DCE.cpp4
-rw-r--r--lib/Transforms/Scalar/IndVarSimplify.cpp10
-rw-r--r--lib/Transforms/Scalar/InductionVars.cpp18
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp4
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp14
-rw-r--r--lib/Transforms/Scalar/SymbolStripping.cpp2
-rw-r--r--lib/Transforms/TransformInternals.cpp4
-rw-r--r--lib/Transforms/TransformInternals.h15
-rw-r--r--lib/Transforms/Utils/Linker.cpp32
-rw-r--r--lib/Transforms/Utils/LowerAllocations.cpp2
-rw-r--r--lib/Transforms/Utils/UnifyFunctionExitNodes.cpp1
-rw-r--r--lib/VMCore/AsmWriter.cpp16
-rw-r--r--lib/VMCore/BasicBlock.cpp4
-rw-r--r--lib/VMCore/Constants.cpp53
-rw-r--r--lib/VMCore/Dominators.cpp2
-rw-r--r--lib/VMCore/Function.cpp8
-rw-r--r--lib/VMCore/InstrTypes.cpp6
-rw-r--r--lib/VMCore/Instruction.cpp6
-rw-r--r--lib/VMCore/Linker.cpp32
-rw-r--r--lib/VMCore/Module.cpp6
-rw-r--r--lib/VMCore/SlotCalculator.cpp5
-rw-r--r--lib/VMCore/SymbolTable.cpp15
-rw-r--r--lib/VMCore/Type.cpp8
-rw-r--r--lib/VMCore/Value.cpp8
-rw-r--r--lib/VMCore/Verifier.cpp3
-rw-r--r--lib/VMCore/iBranch.cpp3
-rw-r--r--lib/VMCore/iCall.cpp9
-rw-r--r--lib/VMCore/iMemory.cpp18
-rw-r--r--lib/VMCore/iOperators.cpp16
132 files changed, 1584 insertions, 1747 deletions
diff --git a/lib/Analysis/Expressions.cpp b/lib/Analysis/Expressions.cpp
index a35e37a963..e94c796059 100644
--- a/lib/Analysis/Expressions.cpp
+++ b/lib/Analysis/Expressions.cpp
@@ -11,6 +11,7 @@
#include "llvm/Optimizations/ConstantHandling.h"
#include "llvm/Method.h"
#include "llvm/BasicBlock.h"
+#include <iostream>
using namespace opt; // Get all the constant handling stuff
using namespace analysis;
@@ -178,7 +179,7 @@ inline const ConstantInt *operator*(const DefZero &L, const DefOne &R) {
static ExprType handleAddition(ExprType Left, ExprType Right, Value *V) {
const Type *Ty = V->getType();
if (Left.ExprTy > Right.ExprTy)
- swap(Left, Right); // Make left be simpler than right
+ std::swap(Left, Right); // Make left be simpler than right
switch (Left.ExprTy) {
case ExprType::Constant:
@@ -229,7 +230,7 @@ ExprType analysis::ClassifyExpression(Value *Expr) {
case Value::TypeVal: case Value::BasicBlockVal:
case Value::MethodVal: case Value::ModuleVal: default:
//assert(0 && "Unexpected expression type to classify!");
- cerr << "Bizarre thing to expr classify: " << Expr << endl;
+ std::cerr << "Bizarre thing to expr classify: " << Expr << "\n";
return Expr;
case Value::GlobalVariableVal: // Global Variable & Method argument:
case Value::MethodArgumentVal: // nothing known, return variable itself
@@ -280,7 +281,7 @@ ExprType analysis::ClassifyExpression(Value *Expr) {
ExprType Left (ClassifyExpression(I->getOperand(0)));
ExprType Right(ClassifyExpression(I->getOperand(1)));
if (Left.ExprTy > Right.ExprTy)
- swap(Left, Right); // Make left be simpler than right
+ std::swap(Left, Right); // Make left be simpler than right
if (Left.ExprTy != ExprType::Constant) // RHS must be > constant
return I; // Quadratic eqn! :(
diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp
index d77064cf35..e48cf7fa38 100644
--- a/lib/Analysis/IPA/CallGraph.cpp
+++ b/lib/Analysis/IPA/CallGraph.cpp
@@ -29,7 +29,7 @@ cfg::CallGraphNode *cfg::CallGraph::getNodeFor(Method *M) {
assert(M->getParent() == Mod && "Method not in current module!");
CallGraphNode *New = new CallGraphNode(M);
- MethodMap.insert(pair<const Method*, CallGraphNode*>(M, New));
+ MethodMap.insert(std::make_pair(M, New));
return New;
}
@@ -71,7 +71,7 @@ cfg::CallGraph::~CallGraph() {
}
-void cfg::WriteToOutput(const CallGraphNode *CGN, ostream &o) {
+void cfg::WriteToOutput(const CallGraphNode *CGN, std::ostream &o) {
if (CGN->getMethod())
o << "Call graph node for method: '" << CGN->getMethod()->getName() <<"'\n";
else
@@ -79,10 +79,10 @@ void cfg::WriteToOutput(const CallGraphNode *CGN, ostream &o) {
for (unsigned i = 0; i < CGN->size(); ++i)
o << " Calls method '" << (*CGN)[i]->getMethod()->getName() << "'\n";
- o << endl;
+ o << "\n";
}
-void cfg::WriteToOutput(const CallGraph &CG, ostream &o) {
+void cfg::WriteToOutput(const CallGraph &CG, std::ostream &o) {
WriteToOutput(CG.getRoot(), o);
for (CallGraph::const_iterator I = CG.begin(), E = CG.end(); I != E; ++I)
o << I->second;
diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp
index 50fb8ea7b6..1058e6ed39 100644
--- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp
+++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp
@@ -60,7 +60,7 @@ bool FindUnsafePointerTypes::doPerMethodWork(Method *Meth) {
UnsafeTypes.insert((PointerType*)ITy);
if (PrintFailures) {
- CachedWriter CW(M->getParent(), cerr);
+ CachedWriter CW(M->getParent(), std::cerr);
CW << "FindUnsafePointerTypes: Type '" << ITy
<< "' marked unsafe in '" << Meth->getName() << "' by:\n" << Inst;
}
@@ -74,7 +74,7 @@ bool FindUnsafePointerTypes::doPerMethodWork(Method *Meth) {
// printResults - Loop over the results of the analysis, printing out unsafe
// types.
//
-void FindUnsafePointerTypes::printResults(const Module *M, ostream &o) {
+void FindUnsafePointerTypes::printResults(const Module *M, std::ostream &o) {
if (UnsafeTypes.empty()) {
o << "SafePointerAccess Analysis: No unsafe types found!\n";
return;
@@ -84,9 +84,9 @@ void FindUnsafePointerTypes::printResults(const Module *M, ostream &o) {
CW << "SafePointerAccess Analysis: Found these unsafe types:\n";
unsigned Counter = 1;
- for (set<PointerType*>::const_iterator I = getUnsafeTypes().begin(),
+ for (std::set<PointerType*>::const_iterator I = getUnsafeTypes().begin(),
E = getUnsafeTypes().end(); I != E; ++I, ++Counter) {
- CW << " #" << Counter << ". " << (Value*)*I << endl;
+ CW << " #" << Counter << ". " << (Value*)*I << "\n";
}
}
diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp
index 6f8049abad..1d98983115 100644
--- a/lib/Analysis/IPA/FindUsedTypes.cpp
+++ b/lib/Analysis/IPA/FindUsedTypes.cpp
@@ -78,15 +78,15 @@ bool FindUsedTypes::doPerMethodWork(Method *m) {
// passed in, then the types are printed symbolically if possible, using the
// symbol table from the module.
//
-void FindUsedTypes::printTypes(ostream &o, const Module *M = 0) const {
+void FindUsedTypes::printTypes(std::ostream &o, const Module *M = 0) const {
o << "Types in use by this module:\n";
if (M) {
CachedWriter CW(M, o);
- for (set<const Type *>::const_iterator I = UsedTypes.begin(),
+ for (std::set<const Type *>::const_iterator I = UsedTypes.begin(),
E = UsedTypes.end(); I != E; ++I)
- CW << " " << *I << endl;
+ CW << " " << *I << "\n";
} else
- for (set<const Type *>::const_iterator I = UsedTypes.begin(),
+ for (std::set<const Type *>::const_iterator I = UsedTypes.begin(),
E = UsedTypes.end(); I != E; ++I)
- o << " " << *I << endl;
+ o << " " << *I << "\n";
}
diff --git a/lib/Analysis/InductionVariable.cpp b/lib/Analysis/InductionVariable.cpp
index d88c9cfc68..045c932332 100644
--- a/lib/Analysis/InductionVariable.cpp
+++ b/lib/Analysis/InductionVariable.cpp
@@ -88,7 +88,7 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) {
ExprType E2 = analysis::ClassifyExpression(V2);
if (E1.ExprTy > E2.ExprTy) // Make E1 be the simpler expression
- swap(E1, E2);
+ std::swap(E1, E2);
// E1 must be a constant incoming value, and E2 must be a linear expression
// with respect to the PHI node.
@@ -109,7 +109,7 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) {
// Make sure that V1 is the incoming value, and V2 is from the backedge of
// the loop.
if (L->contains(Phi->getIncomingBlock(0))) // Wrong order. Swap now.
- swap(V1, V2);
+ std::swap(V1, V2);
Start = V1; // We know that Start has to be loop invariant...
Step = 0;
diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp
index 8616cb721c..fff8d224e2 100644
--- a/lib/Analysis/IntervalPartition.cpp
+++ b/lib/Analysis/IntervalPartition.cpp
@@ -9,6 +9,7 @@
#include "Support/STLExtras.h"
using namespace cfg;
+using std::make_pair;
//===----------------------------------------------------------------------===//
// IntervalPartition Implementation
diff --git a/lib/Analysis/LiveVar/BBLiveVar.cpp b/lib/Analysis/LiveVar/BBLiveVar.cpp
index d7e036b256..0ecf96cf13 100644
--- a/lib/Analysis/LiveVar/BBLiveVar.cpp
+++ b/lib/Analysis/LiveVar/BBLiveVar.cpp
@@ -1,8 +1,13 @@
#include "llvm/Analysis/LiveVar/BBLiveVar.h"
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
+
+/// BROKEN: Should not include sparc stuff directly into here
#include "../../Target/Sparc/SparcInternals.h" // Only for PHI defn
+using std::cerr;
+using std::endl;
+using std::pair;
//-----------------------------------------------------------------------------
// Constructor
@@ -39,7 +44,7 @@ void BBLiveVar::calcDefUseSets()
if( DEBUG_LV > 1) { // debug msg
cerr << " *Iterating over machine instr ";
MInst->dump();
- cerr << endl;
+ cerr << "\n";
}
// iterate over MI operands to find defs
@@ -85,9 +90,9 @@ void BBLiveVar::calcDefUseSets()
if( DEBUG_LV > 1) { // debug msg of level 2
cerr << " - phi operand ";
printValue( ArgVal );
- cerr << " came from BB ";
+ cerr << " came from BB ";
printValue( PhiArgMap[ ArgVal ]);
- cerr<<endl;
+ cerr << "\n";
}
} // if( IsPhi )
@@ -123,7 +128,7 @@ void BBLiveVar::addDef(const Value *Op)
InSetChanged = true;
if( DEBUG_LV > 1) {
- cerr << " +Def: "; printValue( Op ); cerr << endl;
+ cerr << " +Def: "; printValue( Op ); cerr << "\n";
}
}
diff --git a/lib/Analysis/LiveVar/BBLiveVar.h b/lib/Analysis/LiveVar/BBLiveVar.h
index 6d7d4eb533..9ce56a88f6 100644
--- a/lib/Analysis/LiveVar/BBLiveVar.h
+++ b/lib/Analysis/LiveVar/BBLiveVar.h
@@ -28,7 +28,7 @@ class BBLiveVar
// map that contains phi args->BB they came
// set by calcDefUseSets & used by setPropagate
- hash_map<const Value *, const BasicBlock *, hashFuncValue> PhiArgMap;
+ std::hash_map<const Value *, const BasicBlock *> PhiArgMap;
// method to propogate an InSet to OutSet of a predecessor
bool setPropagate( LiveVarSet *const OutSetOfPred,
diff --git a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
index 636359d1d0..5de35ff1be 100644
--- a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
+++ b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
@@ -12,15 +12,15 @@
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "Support/PostOrderIterator.h"
-
+#include <iostream>
+using std::cout;
+using std::endl;
//************************** Constructor/Destructor ***************************
-MethodLiveVarInfo::MethodLiveVarInfo(const Method *const M) : Meth(M),
- BB2BBLVMap()
-{
- assert(! M->isExternal() ); // cannot be a prototype decleration
+MethodLiveVarInfo::MethodLiveVarInfo(const Method *const M) : Meth(M) {
+ assert(!M->isExternal() && "Cannot be a prototype declaration");
HasAnalyzed = false; // still we haven't called analyze()
}
@@ -55,8 +55,6 @@ MethodLiveVarInfo:: ~MethodLiveVarInfo()
if( (*MI).first ) // delete all LiveVarSets in MInst2LVSetBI
delete (*MI).second;
}
-
-
}
diff --git a/lib/Analysis/LiveVar/ValueSet.cpp b/lib/Analysis/LiveVar/ValueSet.cpp
index 6806d1c563..d176d9e53c 100644
--- a/lib/Analysis/LiveVar/ValueSet.cpp
+++ b/lib/Analysis/LiveVar/ValueSet.cpp
@@ -1,11 +1,14 @@
#include "llvm/Analysis/LiveVar/ValueSet.h"
#include "llvm/ConstantVals.h"
-
+#include <iostream>
+using std::cerr;
+using std::endl;
+using std::pair;
+using std::hash_set;
void printValue( const Value *const v) // func to print a Value
{
-
if (v->hasName())
cerr << v << "(" << ((*v).getName()) << ") ";
else if (Constant *C = dyn_cast<Constant>(v))
@@ -16,17 +19,13 @@ void printValue( const Value *const v) // func to print a Value
//---------------- Method implementations --------------------------
-
-
-ValueSet:: ValueSet() : hash_set<const Value *, hashFuncValue> () { }
-
// for performing two set unions
bool ValueSet::setUnion( const ValueSet *const set1) {
const_iterator set1it;
pair<iterator, bool> result;
bool changed = false;
- for( set1it = set1->begin() ; set1it != set1->end(); set1it++) {
+ for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) {
// for all all elements in set1
result = insert( *set1it ); // insert to this set
if( result.second == true) changed = true;
@@ -41,7 +40,7 @@ void ValueSet::setDifference( const ValueSet *const set1,
const ValueSet *const set2) {
const_iterator set1it, set2it;
- for( set1it = set1->begin() ; set1it != set1->end(); set1it++) {
+ for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) {
// for all elements in set1
iterator set2it = set2->find( *set1it ); // find wether the elem is in set2
if( set2it == set2->end() ) // if the element is not in set2
@@ -53,7 +52,7 @@ void ValueSet::setDifference( const ValueSet *const set1,
// for performing set subtraction
void ValueSet::setSubtract( const ValueSet *const set1) {
const_iterator set1it;
- for( set1it = set1->begin() ; set1it != set1->end(); set1it++)
+ for( set1it = set1->begin() ; set1it != set1->end(); ++set1it)
// for all elements in set1
erase( *set1it ); // erase that element from this set
}
@@ -62,7 +61,5 @@ void ValueSet::setSubtract( const ValueSet *const set1) {
void ValueSet::printSet() const { // for printing a live variable set
- const_iterator it;
- for( it = begin() ; it != end(); it++)
- printValue( *it );
+ for_each(begin(), end(), printValue);
}
diff --git a/lib/Analysis/LoopDepth.cpp b/lib/Analysis/LoopDepth.cpp
index ed96bd4f57..994b7cd3c9 100644
--- a/lib/Analysis/LoopDepth.cpp
+++ b/lib/Analysis/LoopDepth.cpp
@@ -22,8 +22,6 @@ inline void LoopDepthCalculator::ProcessInterval(cfg::Interval *I) {
}
LoopDepthCalculator::LoopDepthCalculator(Method *M) {
- //map<const BasicBlock*, unsigned> LoopDepth;
-
cfg::IntervalPartition *IP = new cfg::IntervalPartition(M);
while (!IP->isDegeneratePartition()) {
for_each(IP->begin(), IP->end(),
@@ -34,7 +32,7 @@ LoopDepthCalculator::LoopDepthCalculator(Method *M) {
//
cfg::IntervalPartition *NewIP = new cfg::IntervalPartition(*IP, true);
if (NewIP->size() == IP->size()) {
- cerr << "IRREDUCIBLE GRAPH FOUND!!!\n";
+ assert(0 && "IRREDUCIBLE GRAPH FOUND!!!\n");
// TODO: fix irreducible graph
return;
}
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index 40a195b042..ed91ca8bd5 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -33,7 +33,7 @@ cfg::Loop *cfg::LoopInfo::ConsiderForLoop(const BasicBlock *BB,
const DominatorSet &DS) {
if (BBMap.find(BB) != BBMap.end()) return 0; // Havn't processed this node?
- vector<const BasicBlock *> TodoStack;
+ std::vector<const BasicBlock *> TodoStack;
// Scan the predecessors of BB, checking to see if BB dominates any of
// them.
@@ -64,7 +64,7 @@ cfg::Loop *cfg::LoopInfo::ConsiderForLoop(const BasicBlock *BB,
// loop can be found for them. Also check subsidary basic blocks to see if
// they start subloops of their own.
//
- for (vector<const BasicBlock*>::reverse_iterator I = L->Blocks.rbegin(),
+ for (std::vector<const BasicBlock*>::reverse_iterator I = L->Blocks.rbegin(),
E = L->Blocks.rend(); I != E; ++I) {
// Check to see if this block starts a new loop
@@ -74,7 +74,7 @@ cfg::Loop *cfg::LoopInfo::ConsiderForLoop(const BasicBlock *BB,
}
if (BBMap.find(*I) == BBMap.end())
- BBMap.insert(make_pair(*I, L));
+ BBMap.insert(std::make_pair(*I, L));
}
return L;
diff --git a/lib/Analysis/ModuleAnalyzer.cpp b/lib/Analysis/ModuleAnalyzer.cpp
index 129fb3b862..dc07512cb5 100644
--- a/lib/Analysis/ModuleAnalyzer.cpp
+++ b/lib/Analysis/ModuleAnalyzer.cpp
@@ -13,6 +13,8 @@
#include "llvm/DerivedTypes.h"
#include "Support/STLExtras.h"
#include <map>
+#include <iostream>
+using std::set;
// processModule - Driver function to call all of my subclasses virtual methods.
//
@@ -59,8 +61,8 @@ inline bool ModuleAnalyzer::handleType(set<const Type *> &TypeSet,
break;
default:
- cerr << "ModuleAnalyzer::handleType, type unknown: '"
- << T->getName() << "'\n";
+ std::cerr << "ModuleAnalyzer::handleType, type unknown: '"
+ << T->getName() << "'\n";
break;
}
diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp
index 2ed02dbed2..2e4f6e4df1 100644
--- a/lib/Analysis/PostDominators.cpp
+++ b/lib/Analysis/PostDominators.cpp
@@ -10,6 +10,8 @@
#include "Support/DepthFirstIterator.h"
#include "Support/STLExtras.h"
#include <algorithm>
+using std::set;
+
//===----------------------------------------------------------------------===//
// Helper Template
diff --git a/lib/Analysis/Writer.cpp b/lib/Analysis/Writer.cpp
index 3d9134f0dc..1e873bfa52 100644
--- a/lib/Analysis/Writer.cpp
+++ b/lib/Analysis/Writer.cpp
@@ -12,6 +12,10 @@
#include "llvm/Analysis/InductionVariable.h"
#include <iterator>
#include <algorithm>
+using std::ostream;
+using std::set;
+using std::vector;
+using std::string;
//===----------------------------------------------------------------------===//
// Interval Printing Routines
@@ -23,19 +27,19 @@ void cfg::WriteToOutput(const Interval *I, ostream &o) {
// Print out all of the basic blocks in the interval...
copy(I->Nodes.begin(), I->Nodes.end(),
- ostream_iterator<BasicBlock*>(o, "\n"));
+ std::ostream_iterator<BasicBlock*>(o, "\n"));
o << "Interval Predecessors:\n";
copy(I->Predecessors.begin(), I->Predecessors.end(),
- ostream_iterator<BasicBlock*>(o, "\n"));
+ std::ostream_iterator<BasicBlock*>(o, "\n"));
o << "Interval Successors:\n";
copy(I->Successors.begin(), I->Successors.end(),
- ostream_iterator<BasicBlock*>(o, "\n"));
+ std::ostream_iterator<BasicBlock*>(o, "\n"));
}
void cfg::WriteToOutput(const IntervalPartition &IP, ostream &o) {
- copy(IP.begin(), IP.end(), ostream_iterator<const Interval *>(o, "\n"));
+ copy(IP.begin(), IP.end(), std::ostream_iterator<const Interval *>(o, "\n"));
}
@@ -45,7 +49,7 @@ void cfg::WriteToOutput(const IntervalPartition &IP, ostream &o) {
//===----------------------------------------------------------------------===//
ostream &operator<<(ostream &o, const set<const BasicBlock*> &BBs) {
- copy(BBs.begin(), BBs.end(), ostream_iterator<const BasicBlock*>(o, "\n"));
+ copy(BBs.begin(),BBs.end(), std::ostream_iterator<const BasicBlock*>(o,"\n"));
return o;
}
@@ -53,7 +57,7 @@ void cfg::WriteToOutput(const DominatorSet &DS, ostream &o) {
for (DominatorSet::const_iterator I = DS.begin(), E = DS.end(); I != E; ++I) {
o << "=============================--------------------------------\n"
<< "\nDominator Set For Basic Block\n" << I->first
- << "-------------------------------\n" << I->second << endl;
+ << "-------------------------------\n" << I->second << "\n";
}
}
@@ -63,7 +67,7 @@ void cfg::WriteToOutput(const ImmediateDominators &ID, ostream &o) {
I != E; ++I) {
o << "=============================--------------------------------\n"
<< "\nImmediate Dominator For Basic Block\n" << I->first
- << "is: \n" << I->second << endl;
+ << "is: \n" << I->second << "\n";
}
}
@@ -93,7 +97,7 @@ void cfg::WriteToOutput(const DominanceFrontier &DF, ostream &o) {
I != E; ++I) {
o << "=============================--------------------------------\n"
<< "\nDominance Frontier For Basic Block\n" << I->first
- << "is: \n" << I->second << endl;
+ << "is: \n" << I->second << "\n";
}
}
@@ -109,15 +113,15 @@ void cfg::WriteToOutput(const Loop *L, ostream &o) {
if (i) o << ",";
WriteAsOperand(o, (const Value*)L->getBlocks()[i]);
}
- o << endl;
+ o << "\n";
copy(L->getSubLoops().begin(), L->getSubLoops().end(),
- ostream_iterator<const Loop*>(o, "\n"));
+ std::ostream_iterator<const Loop*>(o, "\n"));
}
void cfg::WriteToOutput(const LoopInfo &LI, ostream &o) {
copy(LI.getTopLevelLoops().begin(), LI.getTopLevelLoops().end(),
- ostream_iterator<const Loop*>(o, "\n"));
+ std::ostream_iterator<const Loop*>(o, "\n"));
}
@@ -138,11 +142,11 @@ void WriteToOutput(const InductionVariable &IV, ostream &o) {
WriteAsOperand(o, (const Value*)IV.Phi);
o << ":\n" << (const Value*)IV.Phi;
} else {
- o << endl;
+ o << "\n";
}
if (IV.InductionType == InductionVariable::Unknown) return;
o << " Start ="; WriteAsOperand(o, IV.Start);
o << " Step =" ; WriteAsOperand(o, IV.Step);
- o << endl;
+ o << "\n";
}
diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp
index b487042bcb..4b280efd7d 100644
--- a/lib/AsmParser/Parser.cpp
+++ b/lib/AsmParser/Parser.cpp
@@ -8,6 +8,7 @@
#include "llvm/Module.h"
#include "ParserInternals.h"
#include <stdio.h> // for sprintf
+using std::string;
// The useful interface defined by this file... Parse an ascii file, and return
// the internal representation in a nice slice'n'dice'able representation.
@@ -30,7 +31,7 @@ Module *ParseAssemblyFile(const string &Filename) { // throw (ParseException)
fclose(F);
if (Result) { // Check to see that it is valid...
- vector<string> Errors;
+ std::vector<string> Errors;
if (verify(Result, Errors)) {
delete Result; Result = 0;
string Message;
diff --git a/lib/AsmParser/ParserInternals.h b/lib/AsmParser/ParserInternals.h
index 750833fae8..e1e2c4954c 100644
--- a/lib/AsmParser/ParserInternals.h
+++ b/lib/AsmParser/ParserInternals.h
@@ -23,12 +23,12 @@
class Module;
// Global variables exported from the lexer...
-extern FILE *llvmAsmin;
+extern std::FILE *llvmAsmin;
extern int llvmAsmlineno;
// Globals exported by the parser...
-extern string CurFilename;
-Module *RunVMAsmParser(const string &Filename, FILE *F);
+extern std::string CurFilename;
+Module *RunVMAsmParser(const std::string &Filename, FILE *F);
// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
@@ -47,7 +47,7 @@ char *UnEscapeLexed(char *Buffer, bool AllowNull = false);
// This also helps me because I keep typing 'throw new ParseException' instead
// of just 'throw ParseException'... sigh...
//
-static inline void ThrowException(const string &message,
+static inline void ThrowException(const std::string &message,
int LineNo = -1) {
if (LineNo == -1) LineNo = llvmAsmlineno;
// TODO: column number in exception
@@ -116,18 +116,19 @@ struct ValID {
return Result;
}
- inline string getName() const {
+ inline std::string getName() const {
switch (Type) {
- case NumberVal : return string("#") + itostr(Num);
+ case NumberVal : return std::string("#") + itostr(Num);
case NameVal : return Name;
- case ConstStringVal: return string("\"") + Name + string("\"");
+ case ConstStringVal: return std::string("\"") + Name + std::string("\"");
case ConstFPVal : return ftostr(ConstPoolFP);
case ConstNullVal : return "null";
case ConstUIntVal :
- case ConstSIntVal : return string("%") + itostr(ConstPool64);
+ case ConstSIntVal : return std::string("%") + itostr(ConstPool64);
default:
assert(0 && "Unknown value!");
abort();
+ return "";
}
}
@@ -163,7 +164,7 @@ public:
struct InstPlaceHolderHelper : public Instruction {
InstPlaceHolderHelper(const Type *Ty) : Instruction(Ty, UserOp1, "") {}
- virtual Instruction *clone() const { abort(); }
+ virtual Instruction *clone() const { abort(); return 0; }
virtual const char *getOpcodeName() const { return "placeholder"; }
};
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index 285e78acef..aab868abb9 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -22,6 +22,15 @@
#include <utility> // Get definition of pair class
#include <algorithm>
#include <stdio.h> // This embarasment is due to our flex lexer...
+#include <iostream>
+using std::list;
+using std::vector;
+using std::pair;
+using std::map;
+using std::pair;
+using std::make_pair;
+using std::cerr;
+using std::string;
int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
int yylex(); // declaration" of xxx warnings.
@@ -46,7 +55,6 @@ string CurFilename;
typedef vector<Value *> ValueList; // Numbered defs
static void ResolveDefinitions(vector<ValueList> &LateResolvers,
vector<ValueList> *FutureLateResolvers = 0);
-static void ResolveTypes (vector<PATypeHolder<Type> > &LateResolveTypes);
static struct PerModuleInfo {
Module *CurrentModule;
@@ -425,22 +433,6 @@ static void ResolveDefinitions(vector<ValueList> &LateResolvers,
LateResolvers.clear();
}
-// ResolveType - Take a specified unresolved type and resolve it. If there is
-// nothing to resolve it to yet, return true. Otherwise resolve it and return
-// false.
-//
-static bool ResolveType(PATypeHolder<Type> &T) {
- const Type *Ty = T;
- ValID &DID = getValIDFromPlaceHolder(Ty);
-
- const Type *TheRealType = getTypeVal(DID, true);
- if (TheRealType == 0 || TheRealType == Ty) return true;
-
- // Refine the opaque type we had to the new type we are getting.
- cast<DerivedType>(Ty)->refineAbstractTypeTo(TheRealType);
- return false;
-}
-
// ResolveTypeTo - A brand new type was just declared. This means that (if
// name is not null) things referencing Name can be resolved. Otherwise, things
// refering to the number can be resolved. Do this now.
@@ -641,12 +633,13 @@ Module *RunVMAsmParser(const string &Filename, FILE *F) {
PATypeHolder<Type> *TypeVal;
Value *ValueVal;
- list<MethodArgument*> *MethodArgList;
- vector<Value*> *ValueList;
- list<PATypeHolder<Type> > *TypeList;
- list<pair<Value*, BasicBlock*> > *PHIList; // Represent the RHS of PHI node
- list<pair<Constant*, BasicBlock*> > *JumpTable;
- vector<Constant*> *ConstVector;
+ std::list<MethodArgument*> *MethodArgList;
+ std::vector<Value*> *ValueList;
+ std::list<PATypeHolder<Type> > *TypeList;
+ std::list<std::pair<Value*,
+ BasicBlock*> > *PHIList; // Represent the RHS of PHI node
+ std::list<std::pair<Constant*, BasicBlock*> > *JumpTable;
+ std::vector<Constant*> *ConstVector;
int64_t SInt64Val;
uint64_t UInt64Val;
@@ -812,8 +805,8 @@ UpRTypes : '\\' EUINT64VAL { // Type UpReference
}
| UpRTypesV '(' ArgTypeListI ')' { // Method derived type?
vector<const Type*> Params;
- mapto($3->begin(), $3->end(), back_inserter(Params),
- mem_fun_ref(&PATypeHandle<Type>::get));
+ mapto($3->begin(), $3->end(), std::back_inserter(Params),
+ std::mem_fun_ref(&PATypeHandle<Type>::get));
bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
if (isVarArg) Params.pop_back();
@@ -827,8 +820,8 @@ UpRTypes : '\\' EUINT64VAL { // Type UpReference
}
| '{' TypeListI '}' { // Structure type?
vector<const Type*> Elements;
- mapto($2->begin(), $2->end(), back_inserter(Elements),
- mem_fun_ref(&PATypeHandle<Type>::get));
+ mapto($2->begin(), $2->end(), std::back_inserter(Elements),
+ std::mem_fun_ref(&PATypeHandle<Type>::get));
$$ = newTH<Type>(HandleUpRefs(StructType::get(Elements)));
delete $2;
diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp
index 78da567f01..d5833dbeed 100644
--- a/lib/Bytecode/Reader/ConstantReader.cpp
+++ b/lib/Bytecode/Reader/ConstantReader.cpp
@@ -14,8 +14,9 @@
#include "llvm/ConstantVals.h"
#include "llvm/GlobalVariable.h"
#include <algorithm>
-
-
+#include <iostream>
+using std::make_pair;
+using std::cerr;
const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf,
const uchar *EndBuf) {
@@ -36,7 +37,7 @@ const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf,
unsigned NumParams;
if (read_vbr(Buf, EndBuf, NumParams)) return failure(Val);
- vector<const Type*> Params;
+ std::vector<const Type*> Params;
while (NumParams--) {
if (read_vbr(Buf, EndBuf, Typ)) return failure(Val);
const Type *Ty = getType(Typ);
@@ -59,12 +60,12 @@ const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf,
if (read_vbr(Buf, EndBuf, NumElements)) return failure(Val);
BCR_TRACE(5, "Array Type Constant #" << ElTyp << " size="
- << NumElements << endl);
+ << NumElements << "\n");
return ArrayType::get(ElementType, NumElements);
}
case Type::StructTyID: {
unsigned Typ;
- vector<const Type*> Elements;
+ std::vector<const Type*> Elements;
if (read_vbr(Buf, EndBuf, Typ)) return failure(Val);
while (Typ) { // List is terminated by void/0 typeid
@@ -80,7 +81,7 @@ const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf,
case Type::PointerTyID: {
unsigned ElTyp;
if (read_vbr(Buf, EndBuf, ElTyp)) return failure(Val);
- BCR_TRACE(5, "Pointer Type Constant #" << (ElTyp-14) << endl);
+ BCR_TRACE(5, "Pointer Type Constant #" << (ElTyp-14) << "\n");
const Type *ElementType = getType(ElTyp);
if (ElementType == 0) return failure(Val);
return PointerType::get(ElementType);
@@ -241,7 +242,7 @@ bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf,
const ArrayType *AT = cast<const ArrayType>(Ty);
unsigned NumElements = AT->getNumElements();
- vector<Constant*> Elements;
+ std::vector<Constant*> Elements;
while (NumElements--) { // Read all of the elements of the constant.
unsigned Slot;
if (read_vbr(Buf, EndBuf, Slot)) return failure(true);
@@ -257,7 +258,7 @@ bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf,
const StructType *ST = cast<StructType>(Ty);
const StructType::ElementTypes &ET = ST->getElementTypes();
- vector<Constant *> Elements;
+ std::vector<Constant *> Elements;
for (unsigned i = 0; i < ET.size(); ++i) {
unsigned Slot;
if (read_vbr(Buf, EndBuf, Slot)) return failure(true);
diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp
index b498ac90c1..8402db5e82 100644
--- a/lib/Bytecode/Reader/InstructionReader.cpp
+++ b/lib/Bytecode/Reader/InstructionReader.cpp
@@ -16,6 +16,9 @@
#include "llvm/iMemory.h"
#include "llvm/iPHINode.h"
#include "llvm/iOther.h"
+#include <iostream>
+using std::vector;
+using std::cerr;
bool BytecodeParser::ParseRawInst(const uchar *&Buf, const uchar *EndBuf,
RawInst &Result) {
@@ -107,7 +110,7 @@ bool BytecodeParser::ParseRawInst(const uchar *&Buf, const uchar *EndBuf,
#if 0
cerr << "NO: " << Result.NumOperands << " opcode: " << Result.Opcode
<< " Ty: " << Result.Ty->getDescription() << " arg1: " << Result.Arg1
- << " arg2: " << Result.Arg2 << " arg3: " << Result.Arg3 << endl;
+ << " arg2: " << Result.Arg2 << " arg3: " << Result.Arg3 << "\n";
#endif
return false;
}
@@ -441,6 +444,6 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
} // end switch(Raw.Opcode)
cerr << "Unrecognized instruction! " << Raw.Opcode
- << " ADDR = 0x" << (void*)Buf << endl;
+ << " ADDR = 0x" << (void*)Buf << "\n";
return failure(true);
}
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index c8be36845a..d0c4d7a5ae 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -20,11 +20,15 @@
#include "llvm/iPHINode.h"
#include "llvm/iOther.h"
#include <sys/types.h>
-#include <sys/mman.h>
+typedef int blksize_t;
#include <sys/stat.h>
+#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <algorithm>
+#include <iostream>
+using std::cerr;
+using std::make_pair;
bool BytecodeParser::getTypeSlot(const Type *Ty, unsigned &Slot) {
if (Ty->isPrimitiveType()) {
@@ -42,7 +46,7 @@ bool BytecodeParser::getTypeSlot(const Type *Ty, unsigned &Slot) {
Slot = FirstDerivedTyID + (&*I - &ModuleTypeValues[0]);
}
}
- //cerr << "getTypeSlot '" << Ty->getName() << "' = " << Slot << endl;
+ //cerr << "getTypeSlot '" << Ty->getName() << "' = " << Slot << "\n";
return false;
}
@@ -50,7 +54,7 @@ const Type *BytecodeParser::getType(unsigned ID) {
const Type *T = Type::getPrimitiveType((Type::PrimitiveID)ID);
if (T) return T;
- //cerr << "Looking up Type ID: " << ID << endl;
+ //cerr << "Looking up Type ID: " << ID << "\n";
const Value *D = getValue(Type::TypeTy, ID, false);
if (D == 0) return failure<const Type*>(0);
@@ -58,7 +62,7 @@ const Type *BytecodeParser::getType(unsigned ID) {
return cast<Type>(D);
}
-int BytecodeParser::insertValue(Value *Val, vector<ValueList> &ValueTab) {
+int BytecodeParser::insertValue(Value *Val, std::vector<ValueList> &ValueTab) {
unsigned type;
if (getTypeSlot(Val->getType(), type)) return failure<int>(-1);
assert(type != Type::TypeTyID && "Types should never be insertValue'd!");
@@ -67,7 +71,7 @@ int BytecodeParser::insertValue(Value *Val, vector<ValueList> &ValueTab) {
ValueTab.resize(type+1, ValueList());
//cerr << "insertValue Values[" << type << "][" << ValueTab[type].size()
- // << "] = " << Val << endl;
+ // << "] = " << Val << "\n";
ValueTab[type].push_back(Val);
return ValueTab[type].size()-1;
@@ -115,7 +119,7 @@ Value *BytecodeParser::getValue(const Type *Ty, unsigned oNum, bool Create) {
case Type::LabelTyID: d = new BBPHolder(Ty, oNum); break;
case Type::MethodTyID:
cerr << "Creating method pholder! : " << type << ":" << oNum << " "
- << Ty->getName() << endl;
+ << Ty->getName() << "\n";
d = new MethPHolder(Ty, oNum);
if (insertValue(d, LateResolveModuleValues) ==-1) return failure<Value*>(0);
return d;
@@ -196,17 +200,17 @@ bool BytecodeParser::ParseSymbolTable(const uchar *&Buf, const uchar *EndBuf,
// Symtab entry: [def slot #][name]
unsigned slot;
if (read_vbr(Buf, EndBuf, slot)) return failure(true);
- string Name;
+ std::string Name;
if (read(Buf, EndBuf, Name, false)) // Not aligned...
return failure(true);
Value *D = getValue(Ty, slot, false); // Find mapping...
if (D == 0) {
- BCR_TRACE(3, "FAILED LOOKUP: Slot #" << slot << endl);
+ BCR_TRACE(3, "FAILED LOOKUP: Slot #" << slot << "\n");
return failure(true);
}
BCR_TRACE(4, "Map: '" << Name << "' to #" << slot << ":" << D;
- if (!isa<Instruction>(D)) cerr << endl);
+ if (!isa<Instruction>(D)) cerr << "\n");
D->setName(Name, ST);
}
@@ -272,7 +276,7 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
MethodSignatureList.pop_front();
Method *M = new Method(MTy, isInternal != 0);
- BCR_TRACE(2, "METHOD TYPE: " << MTy << endl);
+ BCR_TRACE(2, "METHOD TYPE: " << MTy << "\n");
const MethodType::ParamTypes &Params = MTy->getParamTypes();
for (MethodType::ParamTypes::const_iterator It = Params.begin();
@@ -418,7 +422,7 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End,
DeclareNewGlobalValue(GV, unsigned(DestSlot));
BCR_TRACE(2, "Global Variable of type: " << PTy->getDescription()
- << " into slot #" << DestSlot << endl);
+ << " into slot #" << DestSlot << "\n");
if (read_vbr(Buf, End, VarType)) return failure(true);
}
@@ -459,7 +463,7 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End,
MethodSignatureList.push_back(
make_pair(cast<const PointerType>(Val->getType()), SlotNo));
if (read_vbr(Buf, End, MethSignature)) return failure(true);
- BCR_TRACE(2, "Method of type: " << Ty << endl);
+ BCR_TRACE(2, "Method of type: " << Ty << "\n");
}
if (align32(Buf, End)) return failure(true);
@@ -566,11 +570,11 @@ Module *ParseBytecodeBuffer(const uchar *Buffer, unsigned Length) {
// Parse and return a class file...
//
-Module *ParseBytecodeFile(const string &Filename, string *ErrorStr) {
+Module *ParseBytecodeFile(const std::string &Filename, std::string *ErrorStr) {
struct stat StatBuf;
Module *Result = 0;
- if (Filename != string("-")) { // Read from a file...
+ if (Filename != std::string("-")) { // Read from a file...
int FD = open(Filename.c_str(), O_RDONLY);
if (FD == -1) {
if (ErrorStr) *ErrorStr = "Error opening file!";
diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h
index 6abaa2e56b..8a7297a8b3 100644
--- a/lib/Bytecode/Reader/ReaderInternals.h
+++ b/lib/Bytecode/Reader/ReaderInternals.h
@@ -21,7 +21,7 @@
#if TRACE_LEVEL // ByteCodeReading_TRACEer
#include "llvm/Assembly/Writer.h"
-#define BCR_TRACE(n, X) if (n < TRACE_LEVEL) cerr << string(n*2, ' ') << X
+#define BCR_TRACE(n, X) if (n < TRACE_LEVEL) cerr << std::string(n*2, ' ') << X
#else
#define BCR_TRACE(n, X)
#endif
@@ -41,12 +41,12 @@ struct RawInst { // The raw fields out of the bytecode stream...
unsigned Arg1, Arg2;
union {
unsigned Arg3;
- vector<unsigned> *VarArgs; // Contains arg #3,4,5... if NumOperands > 3
+ std::vector<unsigned> *VarArgs; // Contains arg #3,4,5... if NumOperands > 3
};
};
class BytecodeParser : public AbstractTypeUser {
- string Error; // Error message string goes here...
+ std::string Error; // Error message string goes here...
public:
BytecodeParser() {
// Define this in case we don't see a ModuleGlobalInfo block.
@@ -55,13 +55,13 @@ public:
Module *ParseBytecode(const uchar *Buf, const uchar *EndBuf);
- string getError() const { return Error; }
+ std::string getError() const { return Error; }
private: // All of this data is transient across calls to ParseBytecode
Module *TheModule; // Current Module being read into...
- typedef vector<Value *> ValueList;
- typedef vector<ValueList> ValueTable;
+ typedef std::vector<Value *> ValueList;
+ typedef std::vector<ValueList> ValueTable;
ValueTable Values, LateResolveValues;
ValueTable ModuleValues, LateResolveModuleValues;
@@ -70,14 +70,14 @@ private: // All of this data is transient across calls to ParseBytecode
// are defined, and if so, the temporary object that they represent is held
// here.
//
- typedef map<pair<const PointerType *, unsigned>, GlobalVariable*>
- GlobalRefsType;
+ typedef std::map<std::pair<const PointerType *, unsigned>,
+ GlobalVariable*> GlobalRefsType;
GlobalRefsType GlobalRefs;
// TypesLoaded - This vector mirrors the Values[TypeTyID] plane. It is used
// to deal with forward references to types.
//
- typedef vector<PATypeHandle<Type> > TypeValuesListTy;
+ typedef std::vector<PATypeHandle<Type> > TypeValuesListTy;
TypeValuesListTy ModuleTypeValues;
TypeValuesListTy MethodTypeValues;
@@ -89,11 +89,11 @@ private: // All of this data is transient across calls to ParseBytecode
// into its slot to reserve it. When the method is loaded, this placeholder
// is replaced.
//
- list<pair<const PointerType *, unsigned> > MethodSignatureList;
+ std::list<std::pair<const PointerType *, unsigned> > MethodSignatureList;
private:
- bool ParseModule (const uchar * Buf, const uchar *End, Module *&);
- bool ParseModuleGlobalInfo (const uchar *&Buf, const uchar *End, Module *);
+ bool ParseModule (const uchar * Buf, const uchar *End, Module *&);
+ bool ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End, Module *);
bool ParseSymbolTable (const uchar *&Buf, const uchar *End, SymbolTable *);
bool ParseMethod (const uchar *&Buf, const uchar *End, Module *);
bool ParseBasicBlock (const uchar *&Buf, const uchar *End, BasicBlock *&);
@@ -111,7 +111,7 @@ private:
Value *getValue(const Type *Ty, unsigned num, bool Create = true);
const Type *getType(unsigned ID);
- int insertValue(Value *D, vector<ValueList> &D); // -1 = Failure
+ int insertValue(Value *D, std::vector<ValueList> &D); // -1 = Failure
bool postResolveValues(ValueTable &ValTab);
bool getTypeSlot(const Type *Ty, unsigned &Slot);
diff --git a/lib/Bytecode/Writer/ConstantWriter.cpp b/lib/Bytecode/Writer/ConstantWriter.cpp
index bcfa976573..73130f3ee8 100644
--- a/lib/Bytecode/Writer/ConstantWriter.cpp
+++ b/lib/Bytecode/Writer/ConstantWriter.cpp
@@ -13,6 +13,8 @@
#include "llvm/ConstantVals.h"
#include "llvm/SymbolTable.h"
#include "llvm/DerivedTypes.h"
+#include <iostream>
+using std::cerr;
void BytecodeWriter::outputType(const Type *T) {
output_vbr((unsigned)T->getPrimitiveID(), Out);
@@ -134,7 +136,7 @@ bool BytecodeWriter::outputConstant(const Constant *CPV) {
case Type::StructTyID: {
const ConstantStruct *CPS = cast<const ConstantStruct>(CPV);
- const vector<Use> &Vals = CPS->getValues();
+ const std::vector<Use> &Vals = CPS->getValues();
for (unsigned i = 0; i < Vals.size(); ++i) {
int Slot = Table.getValSlot(Vals[i]);
diff --git a/lib/Bytecode/Writer/InstructionWriter.cpp b/lib/Bytecode/Writer/InstructionWriter.cpp
index 825fde6a16..f047ab5e1c 100644
--- a/lib/Bytecode/Writer/InstructionWriter.cpp
+++ b/lib/Bytecode/Writer/InstructionWriter.cpp
@@ -28,7 +28,7 @@ typedef unsigned char uchar;
//
static void outputInstructionFormat0(const Instruction *I,
const SlotCalculator &Table,
- unsigned Type, deque<uchar> &Out) {
+ unsigned Type, std::deque<uchar> &Out) {
// Opcode must have top two bits clear...
output_vbr(I->getOpcode() << 2, Out); // Instruction Opcode ID
output_vbr(Type, Out); // Result type
@@ -63,7 +63,7 @@ static void outputInstructionFormat0(const Instruction *I,
//
static void outputInstrVarArgsCall(const Instruction *I,
const SlotCalculator &Table, unsigned Type,
- deque<uchar> &Out) {
+ std::deque<uchar> &Out) {
assert(isa<CallInst>(I) || isa<InvokeInst>(I));
// Opcode must have top two bits clear...
output_vbr(I->getOpcode() << 2, Out); // Instruction Opcode ID
@@ -106,7 +106,7 @@ static void outputInstrVarArgsCall(const Instruction *I,
//
static void outputInstructionFormat1(const Instruction *I,
const SlotCalculator &Table, int *Slots,
- unsigned Type, deque<uchar> &Out) {
+ unsigned Type, std::deque<uchar> &Out) {
unsigned Opcode = I->getOpcode(); // Instruction Opcode ID
// bits Instruction format:
@@ -127,7 +127,7 @@ static void outputInstructionFormat1(const Instruction *I,
//
static void outputInstructionFormat2(const Instruction *I,
const SlotCalculator &Table, int *Slots,
- unsigned Type, deque<uchar> &Out) {
+ unsigned Type, std::deque<uchar> &Out) {
unsigned Opcode = I->getOpcode(); // Instruction Opcode ID
// bits Instruction format:
@@ -151,7 +151,7 @@ static void outputInstructionFormat2(const Instruction *I,
//
static void outputInstructionFormat3(const Instruction *I,
const SlotCalculator &Table, int *Slots,
- unsigned Type, deque<uchar> &Out) {
+ unsigned Type, std::deque<uchar> &Out) {
unsigned Opcode = I->getOpcode(); // Instruction Opcode ID
// bits Instruction format:
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index ede822846d..4738f712a1 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -196,7 +196,8 @@ void SlotCalculator::purgeMethod() {
while (CurPlane.size() != ModuleSize) {
//SC_DEBUG(" Removing [" << i << "] Value=" << CurPlane.back() << "\n");
- map<const Value *, unsigned>::iterator NI = NodeMap.find(CurPlane.back());
+ std::map<const Value *, unsigned>::iterator NI =
+ NodeMap.find(CurPlane.back());
assert(NI != NodeMap.end() && "Node not in nodemap?");
NodeMap.erase(NI); // Erase from nodemap
CurPlane.pop_back(); // Shrink plane
@@ -223,7 +224,7 @@ void SlotCalculator::purgeMethod() {
}
int SlotCalculator::getValSlot(const Value *D) const {
- map<const Value*, unsigned>::const_iterator I = NodeMap.find(D);
+ std::map<const Value*, unsigned>::const_iterator I = NodeMap.find(D);
if (I == NodeMap.end()) return -1;
return (int)I->second;
diff --git a/lib/Bytecode/Writer/SlotCalculator.h b/lib/Bytecode/Writer/SlotCalculator.h
index c7b3149054..95282447a5 100644
--- a/lib/Bytecode/Writer/SlotCalculator.h
+++ b/lib/Bytecode/Writer/SlotCalculator.h
@@ -23,14 +23,14 @@ class SlotCalculator {
const Module *TheModule;
bool IgnoreNamedNodes; // Shall we not count named nodes?
- typedef vector<const Value*> TypePlane;
- vector<TypePlane> Table;
- map<const Value *, unsigned> NodeMap;
+ typedef std::vector<const Value*> TypePlane;
+ std::vector<TypePlane> Table;
+ std::map<const Value *, unsigned> NodeMap;
// ModuleLevel - Used to keep track of which values belong to the module,
// and which values belong to the currently incorporated method.
//
- vector<unsigned> ModuleLevel;
+ std::vector<unsigned> ModuleLevel;
public:
SlotCalculator(const Module *M, bool IgnoreNamed);
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index 3091384722..9ea5d37451 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/lib/Bytecode/Writer/Writer.cpp
@@ -34,7 +34,7 @@
#include <string.h>
#include <algorithm>
-BytecodeWriter::BytecodeWriter(deque<unsigned char> &o, const Module *M)
+BytecodeWriter::BytecodeWriter(std::deque<unsigned char> &o, const Module *M)
: Out(o), Table(M, false) {
outputSignature();
@@ -66,7 +66,7 @@ void BytecodeWriter::outputConstants(bool isMethod) {
unsigned NumPlanes = Table.getNumPlanes();
for (unsigned pno = 0; pno < NumPlanes; pno++) {
- const vector<const Value*> &Plane = Table.getPlane(pno);
+ const std::vector<const Value*> &Plane = Table.getPlane(pno);
if (Plane.empty()) continue; // Skip empty type planes...
unsigned ValNo = 0;
@@ -95,8 +95,8 @@ void BytecodeWriter::outputConstants(bool isMethod) {
assert (Slot != -1 && "Type in constant pool but not in method!!");
output_vbr((unsigned)Slot, Out);
- //cout << "Emitting " << NC << " constants of type '"
- // << Plane.front()->getType()->getName() << "' = Slot #" << Slot << endl;
+ //cerr << "Emitting " << NC << " constants of type '"
+ // << Plane.front()->getType()->getName() << "' = Slot #" << Slot << "\n";
for (unsigned i = ValNo; i < ValNo+NC; ++i) {
const Value *V = Plane[i];
@@ -211,7 +211,7 @@ void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) {
void WriteBytecodeToFile(const Module *C, ostream &Out) {
assert(C && "You can't write a null module!!");
- deque<unsigned char> Buffer;
+ std::deque<unsigned char> Buffer;
// This object populates buffer for us...
BytecodeWriter BCW(Buffer, C);
@@ -220,7 +220,7 @@ void WriteBytecodeToFile(const Module *C, ostream &Out) {
// sequential in memory, however, so write out as much as possible in big
// chunks, until we're done.
//
- deque<unsigned char>::const_iterator I = Buffer.begin(), E = Buffer.end();
+ std::deque<unsigned char>::const_iterator I = Buffer.begin(),E = Buffer.end();
while (I != E) { // Loop until it's all written
// Scan to see how big this chunk is...
const unsigned char *ChunkPtr = &*I;
@@ -235,7 +235,7 @@ void WriteBytecodeToFile(const Module *C, ostream &Out) {
}
// Write out the chunk...
- Out.write(ChunkPtr, LastPtr-ChunkPtr);
+ Out.write((char*)ChunkPtr, LastPtr-ChunkPtr);
}
Out.flush();
diff --git a/lib/Bytecode/Writer/WriterInternals.h b/lib/Bytecode/Writer/WriterInternals.h
index 8a929870f4..10170305b3 100644
--- a/lib/Bytecode/Writer/WriterInternals.h
+++ b/lib/Bytecode/Writer/WriterInternals.h
@@ -20,10 +20,10 @@
#include <deque>
class BytecodeWriter {
- deque<unsigned char> &Out;
+ std::deque<unsigned char> &Out;
SlotCalculator Table;
public:
- BytecodeWriter(deque<unsigned char> &o, const Module *M);
+ BytecodeWriter(std::deque<unsigned char> &o, const Module *M);
protected:
void outputConstants(bool isMethod);
@@ -51,12 +51,12 @@ private :
//
class BytecodeBlock {
unsigned Loc;
- deque<unsigned char> &Out;
+ std::deque<unsigned char> &Out;
BytecodeBlock(const BytecodeBlock &); // do not implement
void operator=(const BytecodeBlock &); // do not implement
public:
- inline BytecodeBlock(unsigned ID, deque<unsigned char> &o) : Out(o) {
+ inline BytecodeBlock(unsigned ID, std::deque<unsigned char> &o) : Out(o) {
output(ID, Out);
output((unsigned)0, Out); // Reserve the space for the block size...
Loc = Out.size();
diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp
index 528e5abdd3..ea41b6f822 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 @@ private:
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 @@ public:
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 @@ public:
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 @@ SchedulingManager::updateEarliestStartTimes(const SchedGraphNode* node,
{
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 @@ AssignInstructionsToSlots(class SchedulingManager& S, unsigned maxIssue)
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 @@ FindSlotChoices(SchedulingManager& S,
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 @@ FindSlotChoices(SchedulingManager& S,
// 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 @@ ChooseOneGroup(SchedulingManager& S)
{
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 @@ ForwardListSchedule(SchedulingManager& S)
// 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 @@ ScheduleInstructionsWithSSA(Method* method,
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 @@ ScheduleInstructionsWithSSA(Method* method,
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 @@ ScheduleInstructionsWithSSA(Method* method,
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 9e9af5b80d..7c83e1a58c 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 @@ SchedGraphEdge::~SchedGraphEdge()
}
void SchedGraphEdge::dump(int indent=0) const {
- cout << string(indent*2, ' ') << *this;
+ cerr << std::string(indent*2, ' ') << *this;
}
@@ -168,7 +174,7 @@ SchedGraphNode::~SchedGraphNode()
}
void SchedGraphNode::dump(int indent=0) const {
- cout << string(indent*2, ' ') << *this;
+ cerr << std::string(indent*2, ' ') << *this;
}
@@ -222,21 +228,20 @@ SchedGraph::SchedGraph(const BasicBlock* bb,
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 @@ SchedGraph::~SchedGraph()
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 @@ SchedGraph::addNonSSAEdgesForValue(const Instruction* instr,
// 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 @@ SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target,
{
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 @@ SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target,
&& "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 @@ SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target,
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 @@ SchedGraph::buildNodesforBB(const TargetMachine& target,
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(const Method* _method,
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 @@ SchedGraphSet::buildGraphsForMethod(const Method *method,
-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 @@ operator<<(ostream& os, const SchedGraphEdge& edge)
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 a4567a5198..2890241d59 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 @@ public:
//
// 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 @@ private:
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 @@ public:
//
// 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 @@ private:
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 @@ public:
// 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 @@ private:
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 @@ private:
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 @@ private:
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 @@ public:
//
// 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 @@ template <> struct GraphTraits<const SchedGraph*> {
};
-//************************ 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 1769707238..8cde252115 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 @@ SchedPriorities::computeDelays(const SchedGraph* graph)
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 @@ SchedPriorities::initializeReadyHeap(const SchedGraph* graph)
#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 @@ SchedPriorities::issuedReadyNodeAt(cycles_t curTime,
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 @@ SchedPriorities::issuedReadyNodeAt(cycles_t curTime,
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 @@ SchedPriorities::issuedReadyNodeAt(cycles_t curTime,
//----------------------------------------------------------------------
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 @@ SchedPriorities::chooseByRule2(vector<candIndex>& mcands)
}
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 @@ SchedPriorities::getNextHighest(const SchedulingManager& S,
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 @@ SchedPriorities::findSetWithMaxDelay(vector<candIndex>& mcands,
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 @@ SchedPriorities::instructionHasLastUse(MethodLiveVarInfo& methodLiveVarInfo,
{
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 81a2e6a053..a8b3e23397 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 @@ struct NodeDelayPair {
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 @@ public:
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 @@ private:
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 @@ private:
};
-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
diff --git a/lib/CodeGen/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp
index ce3e2c3a3f..20cbe8d71b 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 @@ void
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 @@ void
VRegListNode::dumpNode(int indent) const
{
for (int i=0; i < indent; i++)
- cout << " ";
+ cerr << " ";
- cout << "List" << endl;
+ cerr << "List" << "\n";
}
@@ -151,29 +154,29 @@ void
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(Method *M)
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 @@ InstrForest::~InstrForest()
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 b959c90ca3..ab489c507e 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 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
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 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
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 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) {
// 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 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) {
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 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) {
MachineCodeForBasicBlock& bbMvec = BB->getMachineInstrVec();
bbMvec.insert( bbMvec.begin(), CpMI2);
-
-
}
else break; // since PHI nodes can only be at the top
@@ -338,7 +328,7 @@ PostprocessMachineCodeForTree(InstructionNode* instrNode,
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 @@ SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
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 30d9c7eb78..34dd83b49e 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 ******************************/
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index 5832b8ed18..ccb52c2c98 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -20,6 +20,8 @@
#include "llvm/Method.h"
#include "llvm/iOther.h"
#include "llvm/Instruction.h"
+#include <iostream>
+using std::cerr;
AnnotationID MachineCodeForMethod::AID(
AnnotationManager::getID("MachineCodeForMethodAnnotation"));
@@ -83,13 +85,12 @@ void
MachineInstr::dump(unsigned int indent) const
{
for (unsigned i=0; i < indent; i++)
- cout << " ";
+ cerr << " ";
- cout << *this;
+ cerr << *this;
}
-ostream&
-operator<< (ostream& os, const MachineInstr& minstr)
+std::ostream &operator<<(std::ostream& os, const MachineInstr& minstr)
{
os << TargetInstrDescriptors[minstr.opCode].opCodeString;
@@ -101,7 +102,7 @@ operator<< (ostream& os, const MachineInstr& minstr)
#undef DEBUG_VAL_OP_ITERATOR
#ifdef DEBUG_VAL_OP_ITERATOR
- os << endl << "\tValue operands are: ";
+ os << "\n\tValue operands are: ";
for (MachineInstr::val_const_op_iterator vo(&minstr); ! vo.done(); ++vo)
{
const Value* val = *vo;
@@ -127,15 +128,11 @@ operator<< (ostream& os, const MachineInstr& minstr)
}
#endif
-
-
- os << endl;
-
- return os;
+ return os << "\n";
}
-static inline ostream&
-OutputOperand(ostream &os, const MachineOperand &mop)
+static inline std::ostream &OutputOperand(std::ostream &os,
+ const MachineOperand &mop)
{
Value* val;
switch (mop.getOperandType())
@@ -145,7 +142,7 @@ OutputOperand(ostream &os, const MachineOperand &mop)
val = mop.getVRegValue();
os << "(val ";
if (val && val->hasName())
- os << val->getName().c_str();
+ os << val->getName();
else
os << val;
return os << ")";
@@ -158,8 +155,7 @@ OutputOperand(ostream &os, const MachineOperand &mop)
}
-ostream&
-operator<<(ostream &os, const MachineOperand &mop)
+std::ostream &operator<<(std::ostream &os, const MachineOperand &mop)
{
switch(mop.opType)
{
@@ -171,16 +167,16 @@ operator<<(ostream &os, const MachineOperand &mop)
os << "%ccreg";
return OutputOperand(os, mop);
case MachineOperand::MO_SignExtendedImmed:
- return os << mop.immedVal;
+ return os << (long)mop.immedVal;
case MachineOperand::MO_UnextendedImmed:
- return os << mop.immedVal;
+ return os << (long)mop.immedVal;
case MachineOperand::MO_PCRelativeDisp:
{
const Value* opVal = mop.getVRegValue();
bool isLabel = isa<Method>(opVal) || isa<BasicBlock>(opVal);
os << "%disp(" << (isLabel? "label " : "addr-of-val ");
if (opVal->hasName())
- os << opVal->getName().c_str();
+ os << opVal->getName();
else
os << opVal;
return os << ")";
@@ -403,8 +399,7 @@ MachineCodeForMethod::pushTempValue(const TargetMachine& target,
size += align - mod;
}
- offset = growUp? firstTmpOffset + offset
- : firstTmpOffset - offset;
+ offset = growUp ? firstTmpOffset + offset : firstTmpOffset - offset;
currentTmpValuesSize += size;
return offset;
@@ -419,28 +414,26 @@ MachineCodeForMethod::popAllTempValues(const TargetMachine& target)
int
MachineCodeForMethod::getOffset(const Value* val) const
{
- hash_map<const Value*, int>::const_iterator pair = offsets.find(val);
- return (pair == offsets.end())? INVALID_FRAME_OFFSET : (*pair).second;
+ std::hash_map<const Value*, int>::const_iterator pair = offsets.find(val);
+ return (pair == offsets.end())? INVALID_FRAME_OFFSET : pair->second;
}
void
MachineCodeForMethod::dump() const
{
- cout << "\n" << method->getReturnType()
- << " \"" << method->getName() << "\"" << endl;
+ cerr << "\n" << method->getReturnType()
+ << " \"" << method->getName() << "\"\n";
for (Method::const_iterator BI = method->begin(); BI != method->end(); ++BI)
{
BasicBlock* bb = *BI;
- cout << "\n"
+ cerr << "\n"
<< (bb->hasName()? bb->getName() : "Label")
- << " (" << bb << ")" << ":"
- << endl;
+ << " (" << bb << ")" << ":\n";
MachineCodeForBasicBlock& mvec = bb->getMachineInstrVec();
for (unsigned i=0; i < mvec.size(); i++)
- cout << "\t" << *mvec[i];
+ cerr << "\t" << *mvec[i];
}
- cout << endl << "End method \"" << method->getName() << "\""
- << endl << endl;
+ cerr << "\nEnd method \"" << method->getName() << "\"\n\n";
}
diff --git a/lib/CodeGen/RegAlloc/IGNode.cpp b/lib/CodeGen/RegAlloc/IGNode.cpp
index 4e66d9a762..a225742052 100644
--- a/lib/CodeGen/RegAlloc/IGNode.cpp
+++ b/lib/CodeGen/RegAlloc/IGNode.cpp
@@ -1,12 +1,13 @@
#include "llvm/CodeGen/IGNode.h"
-
+#include <algorithm>
+#include <iostream>
+using std::cerr;
//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
-IGNode::IGNode(LiveRange *const PLR, unsigned int Ind): Index(Ind),
- AdjList(),
- ParentLR(PLR)
+IGNode::IGNode(LiveRange *const PLR, unsigned int Ind) : Index(Ind),
+ ParentLR(PLR)
{
OnStack = false;
CurDegree = -1 ;
@@ -23,11 +24,12 @@ void IGNode::pushOnStack()
int neighs = AdjList.size();
if( neighs < 0) {
- cout << "\nAdj List size = " << neighs;
+ cerr << "\nAdj List size = " << neighs;
assert(0 && "Invalid adj list size");
}
- for(int i=0; i < neighs; i++) (AdjList[i])->decCurDegree();
+ for(int i=0; i < neighs; i++)
+ AdjList[i]->decCurDegree();
}
//-----------------------------------------------------------------------------
@@ -35,11 +37,9 @@ void IGNode::pushOnStack()
// two IGNodes together.
//-----------------------------------------------------------------------------
void IGNode::delAdjIGNode(const IGNode *const Node) {
- vector <IGNode *>::iterator It = AdjList.begin();
-
- // find Node
- for( ; It != AdjList.end() && (*It != Node); It++ ) ;
+ std::vector<IGNode *>::iterator It =
+ find(AdjList.begin(), AdjList.end(), Node);
assert( It != AdjList.end() ); // the node must be there
-
- AdjList.erase( It );
+
+ AdjList.erase(It);
}
diff --git a/lib/CodeGen/RegAlloc/IGNode.h b/lib/CodeGen/RegAlloc/IGNode.h
index 0f4cf9c82a..b89aea32b1 100644
--- a/lib/CodeGen/RegAlloc/IGNode.h
+++ b/lib/CodeGen/RegAlloc/IGNode.h
@@ -29,8 +29,6 @@
#include "llvm/CodeGen/RegAllocCommon.h"
#include "llvm/CodeGen/LiveRange.h"
-
-
//----------------------------------------------------------------------------
// Class IGNode
//
@@ -39,13 +37,11 @@
class IGNode
{
- private:
-
const int Index; // index within IGNodeList
bool OnStack; // this has been pushed on to stack for coloring
- vector<IGNode *> AdjList; // adjacency list for this live range
+ std::vector<IGNode *> AdjList; // adjacency list for this live range
int CurDegree;
//
@@ -54,7 +50,6 @@ class IGNode
// Decremented when a neighbor is pushed on to the stack.
// After that, never incremented/set again nor used.
-
LiveRange *const ParentLR; // parent LR (cannot be a const)
@@ -152,10 +147,4 @@ class IGNode
};
-
-
-
-
-
-
#endif
diff --git a/lib/CodeGen/RegAlloc/InterferenceGraph.cpp b/lib/CodeGen/RegAlloc/InterferenceGraph.cpp
index e18c9a7a34..0de7275acf 100644
--- a/lib/CodeGen/RegAlloc/InterferenceGraph.cpp
+++ b/lib/CodeGen/RegAlloc/InterferenceGraph.cpp
@@ -1,4 +1,7 @@
#include "llvm/CodeGen/InterferenceGraph.h"
+#include "Support/STLExtras.h"
+#include <iostream>
+using std::cerr;
//-----------------------------------------------------------------------------
// Constructor: Records the RegClass and initalizes IGNodeList.
@@ -11,7 +14,7 @@ InterferenceGraph::InterferenceGraph(RegClass *const RC) : RegCl(RC),
IG = NULL;
Size = 0;
if( DEBUG_RA) {
- cout << "Interference graph created!" << endl;
+ cerr << "Interference graph created!\n";
}
}
@@ -22,19 +25,12 @@ InterferenceGraph::InterferenceGraph(RegClass *const RC) : RegCl(RC),
InterferenceGraph:: ~InterferenceGraph() {
// delete the matrix
- //
- if( IG )
- delete []IG;
+ for(unsigned int r=0; r < IGNodeList.size(); ++r)
+ delete[] IG[r];
+ delete[] IG;
// delete all IGNodes in the IGNodeList
- //
- vector<IGNode *>::const_iterator IGIt = IGNodeList.begin();
- for(unsigned i=0; i < IGNodeList.size() ; ++i) {
-
- const IGNode *const Node = IGNodeList[i];
- if( Node ) delete Node;
- }
-
+ for_each(IGNodeList.begin(), IGNodeList.end(), deleter<IGNode>);
}
@@ -46,13 +42,13 @@ InterferenceGraph:: ~InterferenceGraph() {
void InterferenceGraph::createGraph()
{
Size = IGNodeList.size();
- IG = (char **) new char *[Size];
+ IG = new char*[Size];
for( unsigned int r=0; r < Size; ++r)
IG[r] = new char[Size];
// init IG matrix
for(unsigned int i=0; i < Size; i++)
- for( unsigned int j=0; j < Size ; j++)
+ for(unsigned int j=0; j < Size; j++)
IG[i][j] = 0;
}
@@ -61,9 +57,7 @@ void InterferenceGraph::createGraph()
//-----------------------------------------------------------------------------
void InterferenceGraph::addLRToIG(LiveRange *const LR)
{
- IGNode *Node = new IGNode(LR, IGNodeList.size() );
- IGNodeList.push_back( Node );
-
+ IGNodeList.push_back(new IGNode(LR, IGNodeList.size()));
}
@@ -92,12 +86,11 @@ void InterferenceGraph::setInterference(const LiveRange *const LR1,
char *val;
if( DEBUG_RA > 1)
- cout << "setting intf for: [" << row << "][" << col << "]" << endl;
+ cerr << "setting intf for: [" << row << "][" << col << "]\n";
( row > col) ? val = &IG[row][col]: val = &IG[col][row];
if( ! (*val) ) { // if this interf is not previously set
-
*val = 1; // add edges between nodes
IGNode1->addAdjIGNode( IGNode2 );
IGNode2->addAdjIGNode( IGNode1 );
@@ -123,7 +116,10 @@ unsigned InterferenceGraph::getInterference(const LiveRange *const LR1,
const unsigned int col = LR2->getUserIGNode()->getIndex();
char ret;
- ( row > col) ? (ret = IG[row][col]) : (ret = IG[col][row]) ;
+ if (row > col)
+ ret = IG[row][col];
+ else
+ ret = IG[col][row];
return ret;
}
@@ -148,9 +144,9 @@ void InterferenceGraph::mergeIGNodesOfLRs(const LiveRange *const LR1,
assertIGNode( SrcNode );
if( DEBUG_RA > 1) {
- cout << "Merging LRs: \""; LR1->printSet();
- cout << "\" and \""; LR2->printSet();
- cout << "\"" << endl;
+ cerr << "Merging LRs: \""; LR1->printSet();
+ cerr << "\" and \""; LR2->printSet();
+ cerr << "\"\n";
}
unsigned SrcDegree = SrcNode->getNumOfNeighbors();
@@ -217,17 +213,16 @@ void InterferenceGraph::printIG() const
for(unsigned int i=0; i < Size; i++) {
const IGNode *const Node = IGNodeList[i];
- if( ! Node )
- continue; // skip empty rows
-
- cout << " [" << i << "] ";
+ if(Node) {
+ cerr << " [" << i << "] ";
- for( unsigned int j=0; j < Size; j++) {
- if( j >= i) break;
- if( IG[i][j] ) cout << "(" << i << "," << j << ") ";
+ for( unsigned int j=0; j < i; j++) {
+ if(IG[i][j])
+ cerr << "(" << i << "," << j << ") ";
}
- cout << endl;
+ cerr << "\n";
}
+ }
}
//----------------------------------------------------------------------------
@@ -235,21 +230,14 @@ void InterferenceGraph::printIG() const
//----------------------------------------------------------------------------
void InterferenceGraph::printIGNodeList() const
{
- vector<IGNode *>::const_iterator IGIt = IGNodeList.begin(); // hash map iter
-
for(unsigned i=0; i < IGNodeList.size() ; ++i) {
-
const IGNode *const Node = IGNodeList[i];
- if( ! Node )
- continue;
-
- cout << " [" << Node->getIndex() << "] ";
- (Node->getParentLR())->printSet();
- //int Deg = Node->getCurDegree();
- cout << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">" << endl;
-
+ if (Node) {
+ cerr << " [" << Node->getIndex() << "] ";
+ Node->getParentLR()->printSet();
+ //int Deg = Node->getCurDegree();
+ cerr << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">\n";
+ }
}
}
-
-
diff --git a/lib/CodeGen/RegAlloc/InterferenceGraph.h b/lib/CodeGen/RegAlloc/InterferenceGraph.h
index 99dea8fbe0..408bee4558 100644
--- a/lib/CodeGen/RegAlloc/InterferenceGraph.h
+++ b/lib/CodeGen/RegAlloc/InterferenceGraph.h
@@ -1,4 +1,4 @@
-/* Title: InterferenceGraph.h
+/* Title: InterferenceGraph.h -*- C++ -*-
Author: Ruchira Sasanka
Date: July 20, 01
Purpose: Interference Graph used for register coloring.
@@ -24,7 +24,7 @@
#include "llvm/CodeGen/IGNode.h"
-typedef vector <IGNode *> IGNodeListType;
+typedef std::vector <IGNode *> IGNodeListType;
class InterferenceGraph
@@ -47,6 +47,8 @@ class InterferenceGraph
// to create it after adding all IGNodes to the IGNodeList
InterferenceGraph(RegClass *const RC);
+ ~InterferenceGraph();
+
void createGraph();
void addLRToIG(LiveRange *const LR);
@@ -65,12 +67,6 @@ class InterferenceGraph
void printIG() const;
void printIGNodeList() const;
-
- ~InterferenceGraph();
-
-
};
-
#endif
-
diff --git a/lib/CodeGen/RegAlloc/LiveRange.h b/lib/CodeGen/RegAlloc/LiveRange.h
index 778e070046..8034751da9 100644
--- a/lib/CodeGen/RegAlloc/LiveRange.h
+++ b/lib/CodeGen/RegAlloc/LiveRange.h
@@ -1,4 +1,4 @@
-/* Title: LiveRange.h
+/* Title: LiveRange.h -*- C++ -*-
Author: Ruchira Sasanka
Date: July 25, 01
Purpose: To keep info about a live range.
@@ -13,6 +13,7 @@
#include "llvm/Analysis/LiveVar/ValueSet.h"
#include "llvm/Type.h"
+#include <iostream>
class RegClass;
class IGNode;
@@ -176,7 +177,7 @@ class LiveRange : public ValueSet
if(SuggestedColor == -1 )
SuggestedColor = Col;
else if (DEBUG_RA)
- cerr << "Already has a suggested color " << Col << endl;
+ std::cerr << "Already has a suggested color " << Col << "\n";
}
inline unsigned getSuggestedColor() const {
diff --git a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
index 7fb688f55e..b66e6ef308 100644
--- a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
+++ b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
@@ -1,15 +1,15 @@
#include "llvm/CodeGen/LiveRangeInfo.h"
+#include <iostream>
+using std::cerr;
//---------------------------------------------------------------------------
// Constructor
//---------------------------------------------------------------------------
LiveRangeInfo::LiveRangeInfo(const Method *const M,
const TargetMachine& tm,
- vector<RegClass *> &RCL)
- : Meth(M), LiveRangeMap(),
- TM(tm), RegClassList(RCL),
- MRI( tm.getRegInfo()),
- CallRetInstrList()
+ std::vector<RegClass *> &RCL)
+ : Meth(M), LiveRangeMap(), TM(tm),
+ RegClassList(RCL), MRI(tm.getRegInfo())
{ }
@@ -17,33 +17,25 @@ LiveRangeInfo::LiveRangeInfo(const Method *const M,
// Destructor: Deletes all LiveRanges in the LiveRangeMap
//---------------------------------------------------------------------------
LiveRangeInfo::~LiveRangeInfo() {
-
LiveRangeMapType::iterator MI = LiveRangeMap.begin();
for( ; MI != LiveRangeMap.end() ; ++MI) {
- if( (*MI).first ) {
-
- LiveRange *LR = (*MI).second;
-
- if( LR ) {
-
- // we need to be careful in deleting LiveRanges in LiveRangeMap
- // since two/more Values in the live range map can point to the same
- // live range. We have to make the other entries NULL when we delete
- // a live range.
-
- LiveRange::iterator LI = LR->begin();
-
- for( ; LI != LR->end() ; ++LI) {
- LiveRangeMap[*LI] = NULL;
- }
+ if (MI->first && MI->second) {
+ LiveRange *LR = MI->second;
- delete LR;
+ // we need to be careful in deleting LiveRanges in LiveRangeMap
+ // since two/more Values in the live range map can point to the same
+ // live range. We have to make the other entries NULL when we delete
+ // a live range.
- }
+ LiveRange::iterator LI = LR->begin();
+
+ for( ; LI != LR->end() ; ++LI)
+ LiveRangeMap[*LI] = 0;
+
+ delete LR;
}
}
-
}
@@ -82,7 +74,7 @@ void LiveRangeInfo::unionAndUpdateLRs(LiveRange *const L1, LiveRange *L2)
L1->addSpillCost( L2->getSpillCost() ); // add the spill costs
- delete ( L2 ); // delete L2 as it is no longer needed
+ delete L2; // delete L2 as it is no longer needed
}
@@ -96,7 +88,7 @@ void LiveRangeInfo::constructLiveRanges()
{
if( DEBUG_RA)
- cout << "Consturcting Live Ranges ..." << endl;
+ cerr << "Consturcting Live Ranges ...\n";
// first find the live ranges for all incoming args of the method since
// those LRs start from the start of the method
@@ -108,14 +100,13 @@ void LiveRangeInfo::constructLiveRanges()
for( ; ArgIt != ArgList.end() ; ++ArgIt) { // for each argument
-
LiveRange * ArgRange = new LiveRange(); // creates a new LR and
const Value *const Val = (const Value *) *ArgIt;
assert( Val);
- ArgRange->add( Val ); // add the arg (def) to it
- LiveRangeMap[ Val ] = ArgRange;
+ ArgRange->add(Val); // add the arg (def) to it
+ LiveRangeMap[Val] = ArgRange;
// create a temp machine op to find the register class of value
//const MachineOperand Op(MachineOperand::MO_VirtualRegister);
@@ -125,8 +116,8 @@ void LiveRangeInfo::constructLiveRanges()
if( DEBUG_RA > 1) {
- cout << " adding LiveRange for argument ";
- printValue( (const Value *) *ArgIt); cout << endl;
+ cerr << " adding LiveRange for argument ";
+ printValue((const Value *) *ArgIt); cerr << "\n";
}
}
@@ -140,7 +131,6 @@ void LiveRangeInfo::constructLiveRanges()
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
-
for( ; BBI != Meth->end(); ++BBI) { // go thru BBs in random order
// Now find all LRs for machine the instructions. A new LR will be created
@@ -150,8 +140,7 @@ void LiveRangeInfo::constructLiveRanges()
// get the iterator for machine instructions
const MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
- MachineCodeForBasicBlock::const_iterator
- MInstIterator = MIVec.begin();
+ MachineCodeForBasicBlock::const_iterator MInstIterator = MIVec.begin();
// iterate over all the machine instructions in BB
for( ; MInstIterator != MIVec.end(); MInstIterator++) {
@@ -161,53 +150,46 @@ void LiveRangeInfo::constructLiveRanges()
// Now if the machine instruction is a call/return instruction,
// add it to CallRetInstrList for processing its implicit operands
- if( (TM.getInstrInfo()).isReturn( MInst->getOpCode()) ||
- (TM.getInstrInfo()).isCall( MInst->getOpCode()) )
+ if(TM.getInstrInfo().isReturn(MInst->getOpCode()) ||
+ TM.getInstrInfo().isCall(MInst->getOpCode()))
CallRetInstrList.push_back( MInst );
// iterate over MI operands to find defs
- for( MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done(); ++OpI) {
-
- if( DEBUG_RA) {
+ for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
+ if(DEBUG_RA) {
MachineOperand::MachineOperandType OpTyp =
OpI.getMachineOperand().getOperandType();
- if ( OpTyp == MachineOperand::MO_CCRegister) {
- cout << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:";
+ if (OpTyp == MachineOperand::MO_CCRegister) {
+ cerr << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:";
printValue( OpI.getMachineOperand().getVRegValue() );
- cout << endl;
+ cerr << "\n";
}
}
// create a new LR iff this operand is a def
if( OpI.isDef() ) {
-
const Value *const Def = *OpI;
-
// Only instruction values are accepted for live ranges here
-
if( Def->getValueType() != Value::InstructionVal ) {
- cout << "\n**%%Error: Def is not an instruction val. Def=";
- printValue( Def ); cout << endl;
+ cerr << "\n**%%Error: Def is not an instruction val. Def=";
+ printValue( Def ); cerr << "\n";
continue;
}
-
LiveRange *DefRange = LiveRangeMap[Def];
// see LR already there (because of multiple defs)
-
if( !DefRange) { // if it is not in LiveRangeMap
-
DefRange = new LiveRange(); // creates a new live range and
DefRange->add( Def ); // add the instruction (def) to it
LiveRangeMap[ Def ] = DefRange; // update the map
if( DEBUG_RA > 1) {
- cout << " creating a LR for def: ";
- printValue(Def); cout << endl;
+ cerr << " creating a LR for def: ";
+ printValue(Def); cerr << "\n";
}
// set the register class of the new live range
@@ -221,7 +203,7 @@ void LiveRangeInfo::constructLiveRanges()
if(isCC && DEBUG_RA) {
- cout << "\a**created a LR for a CC reg:";
+ cerr << "\a**created a LR for a CC reg:";
printValue( OpI.getMachineOperand().getVRegValue() );
}
@@ -235,8 +217,8 @@ void LiveRangeInfo::constructLiveRanges()
LiveRangeMap[ Def ] = DefRange;
if( DEBUG_RA > 1) {
- cout << " added to an existing LR for def: ";
- printValue( Def ); cout << endl;
+ cerr << " added to an existing LR for def: ";
+ printValue( Def ); cerr << "\n";
}
}
@@ -256,7 +238,7 @@ void LiveRangeInfo::constructLiveRanges()
suggestRegs4CallRets();
if( DEBUG_RA)
- cout << "Initial Live Ranges constructed!" << endl;
+ cerr << "Initial Live Ranges constructed!\n";
}
@@ -312,11 +294,8 @@ void LiveRangeInfo::suggestRegs4CallRets()
//---------------------------------------------------------------------------
void LiveRangeInfo::coalesceLRs()
{
-
-
-
if( DEBUG_RA)
- cout << endl << "Coalscing LRs ..." << endl;
+ cerr << "\nCoalscing LRs ...\n";
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
@@ -324,8 +303,7 @@ void LiveRangeInfo::coalesceLRs()
// get the iterator for machine instructions
const MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
- MachineCodeForBasicBlock::const_iterator
- MInstIterator = MIVec.begin();
+ MachineCodeForBasicBlock::const_iterator MInstIterator = MIVec.begin();
// iterate over all the machine instructions in BB
for( ; MInstIterator != MIVec.end(); ++MInstIterator) {
@@ -333,9 +311,9 @@ void LiveRangeInfo::coalesceLRs()
const MachineInstr * MInst = *MInstIterator;
if( DEBUG_RA > 1) {
- cout << " *Iterating over machine instr ";
+ cerr << " *Iterating over machine instr ";
MInst->dump();
- cout << endl;
+ cerr << "\n";
}
@@ -357,8 +335,8 @@ void LiveRangeInfo::coalesceLRs()
//don't warn about labels
if (!((*UseI)->getType())->isLabelType() && DEBUG_RA) {
- cout<<" !! Warning: No LR for use "; printValue(*UseI);
- cout << endl;
+ cerr<<" !! Warning: No LR for use "; printValue(*UseI);
+ cerr << "\n";
}
continue; // ignore and continue
}
@@ -407,7 +385,7 @@ void LiveRangeInfo::coalesceLRs()
} // for all BBs
if( DEBUG_RA)
- cout << endl << "Coalscing Done!" << endl;
+ cerr << "\nCoalscing Done!\n";
}
@@ -421,11 +399,11 @@ void LiveRangeInfo::coalesceLRs()
void LiveRangeInfo::printLiveRanges()
{
LiveRangeMapType::iterator HMI = LiveRangeMap.begin(); // hash map iterator
- cout << endl << "Printing Live Ranges from Hash Map:" << endl;
- for( ; HMI != LiveRangeMap.end() ; HMI ++ ) {
- if( (*HMI).first && (*HMI).second ) {
- cout <<" "; printValue((*HMI).first); cout << "\t: ";
- ((*HMI).second)->printSet(); cout << endl;
+ cerr << "\nPrinting Live Ranges from Hash Map:\n";
+ for( ; HMI != LiveRangeMap.end() ; ++HMI) {
+ if( HMI->first && HMI->second ) {
+ cerr <<" "; printValue((*HMI).first); cerr << "\t: ";
+ HMI->second->printSet(); cerr << "\n";
}
}
}
diff --git a/lib/CodeGen/RegAlloc/LiveRangeInfo.h b/lib/CodeGen/RegAlloc/LiveRangeInfo.h
index 1eee1aea5e..9e7ef06fe2 100644
--- a/lib/CodeGen/RegAlloc/LiveRangeInfo.h
+++ b/lib/CodeGen/RegAlloc/LiveRangeInfo.h
@@ -1,4 +1,4 @@
-/* Title: LiveRangeInfo.h
+/* Title: LiveRangeInfo.h -*- C++ -*-
Author: Ruchira Sasanka
Date: Jun 30, 01
Purpose:
@@ -34,8 +34,8 @@
#include "llvm/CodeGen/RegClass.h"
-typedef hash_map <const Value *, LiveRange *, hashFuncValue> LiveRangeMapType;
-typedef vector <const MachineInstr *> CallRetInstrListType;
+typedef std::hash_map<const Value*, LiveRange*> LiveRangeMapType;
+typedef std::vector<const MachineInstr*> CallRetInstrListType;
@@ -59,7 +59,7 @@ private:
const TargetMachine& TM; // target machine description
- vector<RegClass *> & RegClassList;// a vector containing register classess
+ std::vector<RegClass *> & RegClassList;// vector containing register classess
const MachineRegInfo& MRI; // machine reg info
@@ -82,7 +82,7 @@ public:
LiveRangeInfo(const Method *const M,
const TargetMachine& tm,
- vector<RegClass *> & RCList);
+ std::vector<RegClass *> & RCList);
// Destructor to destroy all LiveRanges in the LiveRange Map
diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
index 7d6fbb7cc9..e2d455bad9 100644
--- a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
+++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
@@ -14,7 +14,9 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/MachineFrameInfo.h"
+#include <iostream>
#include <math.h>
+using std::cerr;
// ***TODO: There are several places we add instructions. Validate the order
@@ -35,18 +37,16 @@ cl::Enum<RegAllocDebugLevel_t> DEBUG_RA("dregalloc", cl::NoFlags,
PhyRegAlloc::PhyRegAlloc(Method *M,
const TargetMachine& tm,
MethodLiveVarInfo *const Lvi)
- : RegClassList(),
- TM(tm),
- Meth(M),
+ : TM(tm), Meth(M),
mcInfo(MachineCodeForMethod::get(M)),
LVI(Lvi), LRI(M, tm, RegClassList),
MRI( tm.getRegInfo() ),
NumOfRegClasses(MRI.getNumOfRegClasses()),
- AddedInstrMap(), LoopDepthCalc(M), ResColList() {
+ LoopDepthCalc(M) {
// create each RegisterClass and put in RegClassList
//
- for( unsigned int rc=0; rc < NumOfRegClasses; rc++)
+ for(unsigned int rc=0; rc < NumOfRegClasses; rc++)
RegClassList.push_back( new RegClass(M, MRI.getMachineRegClass(rc),
&ResColList) );
}
@@ -69,7 +69,7 @@ PhyRegAlloc::~PhyRegAlloc() {
//----------------------------------------------------------------------------
void PhyRegAlloc::createIGNodeListsAndIGs()
{
- if(DEBUG_RA ) cout << "Creating LR lists ..." << endl;
+ if(DEBUG_RA ) cerr << "Creating LR lists ...\n";
// hash map iterator
LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin();
@@ -85,8 +85,8 @@ void PhyRegAlloc::createIGNodeListsAndIGs()
if( !L) {
if( DEBUG_RA) {
- cout << "\n*?!?Warning: Null liver range found for: ";
- printValue( (*HMI).first) ; cout << endl;
+ cerr << "\n*?!?Warning: Null liver range found for: ";
+ printValue(HMI->first); cerr << "\n";
}
continue;
}
@@ -108,7 +108,7 @@ void PhyRegAlloc::createIGNodeListsAndIGs()
RegClassList[ rc ]->createInterferenceGraph();
if( DEBUG_RA)
- cout << "LRLists Created!" << endl;
+ cerr << "LRLists Created!\n";
}
@@ -140,8 +140,8 @@ void PhyRegAlloc::addInterference(const Value *const Def,
for( ; LIt != LVSet->end(); ++LIt) {
if( DEBUG_RA > 1) {
- cout << "< Def="; printValue(Def);
- cout << ", Lvar="; printValue( *LIt); cout << "> ";
+ cerr << "< Def="; printValue(Def);
+ cerr << ", Lvar="; printValue( *LIt); cerr << "> ";
}
// get the live range corresponding to live var
@@ -166,8 +166,8 @@ void PhyRegAlloc::addInterference(const Value *const Def,
else if(DEBUG_RA > 1) {
// we will not have LRs for values not explicitly allocated in the
// instruction stream (e.g., constants)
- cout << " warning: no live range for " ;
- printValue( *LIt); cout << endl; }
+ cerr << " warning: no live range for " ;
+ printValue(*LIt); cerr << "\n"; }
}
@@ -203,7 +203,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst,
}
if( DEBUG_RA)
- cout << "\n For call inst: " << *MInst;
+ cerr << "\n For call inst: " << *MInst;
LiveVarSet::const_iterator LIt = LVSetAft->begin();
@@ -216,7 +216,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst,
LiveRange *const LR = LRI.getLiveRangeForValue(*LIt );
if( LR && DEBUG_RA) {
- cout << "\n\tLR Aft Call: ";
+ cerr << "\n\tLR Aft Call: ";
LR->printSet();
}
@@ -227,7 +227,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst,
if( LR && (LR != RetValLR) ) {
LR->setCallInterference();
if( DEBUG_RA) {
- cout << "\n ++Added call interf for LR: " ;
+ cerr << "\n ++Added call interf for LR: " ;
LR->printSet();
}
}
@@ -247,7 +247,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst,
void PhyRegAlloc::buildInterferenceGraphs()
{
- if(DEBUG_RA) cout << "Creating interference graphs ..." << endl;
+ if(DEBUG_RA) cerr << "Creating interference graphs ...\n";
unsigned BBLoopDepthCost;
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
@@ -333,7 +333,7 @@ void PhyRegAlloc::buildInterferenceGraphs()
addInterferencesForArgs();
if( DEBUG_RA)
- cout << "Interference graphs calculted!" << endl;
+ cerr << "Interference graphs calculted!\n";
}
@@ -411,8 +411,8 @@ void PhyRegAlloc::addInterferencesForArgs()
addInterference( *ArgIt, InSet, false ); // add interferences between
// args and LVars at start
if( DEBUG_RA > 1) {
- cout << " - %% adding interference for argument ";
- printValue( (const Value *) *ArgIt); cout << endl;
+ cerr << " - %% adding interference for argument ";
+ printValue((const Value *)*ArgIt); cerr << "\n";
}
}
}
@@ -510,7 +510,7 @@ void PhyRegAlloc::updateMachineCode()
// delete this condition checking later (must assert if Val is null)
if( !Val) {
if (DEBUG_RA)
- cout << "Warning: NULL Value found for operand" << endl;
+ cerr << "Warning: NULL Value found for operand\n";
continue;
}
assert( Val && "Value is NULL");
@@ -522,9 +522,9 @@ void PhyRegAlloc::updateMachineCode()
// nothing to worry if it's a const or a label
if (DEBUG_RA) {
- cout << "*NO LR for operand : " << Op ;
- cout << " [reg:" << Op.getAllocatedRegNum() << "]";
- cout << " in inst:\t" << *MInst << endl;
+ cerr << "*NO LR for operand : " << Op ;
+ cerr << " [reg:" << Op.getAllocatedRegNum() << "]";
+ cerr << " in inst:\t" << *MInst << "\n";
}
// if register is not allocated, mark register as invalid
@@ -563,18 +563,16 @@ void PhyRegAlloc::updateMachineCode()
// instruction, add them now.
//
if( AddedInstrMap[ MInst ] ) {
-
- deque<MachineInstr *> &IBef = (AddedInstrMap[MInst])->InstrnsBefore;
+ std::deque<MachineInstr *> &IBef = AddedInstrMap[MInst]->InstrnsBefore;
if( ! IBef.empty() ) {
-
- deque<MachineInstr *>::iterator AdIt;
+ std::deque<MachineInstr *>::iterator AdIt;
for( AdIt = IBef.begin(); AdIt != IBef.end() ; ++AdIt ) {
if( DEBUG_RA) {
cerr << "For inst " << *MInst;
- cerr << " PREPENDed instr: " << **AdIt << endl;
+ cerr << " PREPENDed instr: " << **AdIt << "\n";
}
MInstIterator = MIVec.insert( MInstIterator, *AdIt );
@@ -600,7 +598,7 @@ void PhyRegAlloc::updateMachineCode()
if((delay=TM.getInstrInfo().getNumDelaySlots(MInst->getOpCode())) >0){
move2DelayedInstr(MInst, *(MInstIterator+delay) );
- if(DEBUG_RA) cout<< "\nMoved an added instr after the delay slot";
+ if(DEBUG_RA) cerr<< "\nMoved an added instr after the delay slot";
}
else {
@@ -609,11 +607,11 @@ void PhyRegAlloc::updateMachineCode()
// Here we can add the "instructions after" to the current
// instruction since there are no delay slots for this instruction
- deque<MachineInstr *> &IAft = (AddedInstrMap[MInst])->InstrnsAfter;
+ std::deque<MachineInstr *> &IAft = AddedInstrMap[MInst]->InstrnsAfter;
if( ! IAft.empty() ) {
- deque<MachineInstr *>::iterator AdIt;
+ std::deque<MachineInstr *>::iterator AdIt;
++MInstIterator; // advance to the next instruction
@@ -621,7 +619,7 @@ void PhyRegAlloc::updateMachineCode()
if(DEBUG_RA) {
cerr << "For inst " << *MInst;
- cerr << " APPENDed instr: " << **AdIt << endl;
+ cerr << " APPENDed instr: " << **AdIt << "\n";
}
MInstIterator = MIVec.insert( MInstIterator, *AdIt );
@@ -669,9 +667,7 @@ void PhyRegAlloc::insertCode4SpilledLR(const LiveRange *LR,
RegClass *RC = LR->getRegClass();
const LiveVarSet *LVSetBef = LVI->getLiveVarSetBeforeMInst(MInst, BB);
-
- int TmpOff =
- mcInfo.pushTempValue(TM, MRI.getSpilledRegSize(RegType) );
+ mcInfo.pushTempValue(TM, MRI.getSpilledRegSize(RegType) );
MachineInstr *MIBef=NULL, *AdIMid=NULL, *MIAft=NULL;
@@ -854,13 +850,10 @@ int PhyRegAlloc::getUniRegNotUsedByThisInst(RegClass *RC,
return MRI.getUnifiedRegNum(RC->getID(), c);
else
assert( 0 && "FATAL: No free register could be found in reg class!!");
-
+ return 0;
}
-
-
-
//----------------------------------------------------------------------------
// This method modifies the IsColorUsedArr of the register class passed to it.
// It sets the bits corresponding to the registers used by this machine
@@ -909,14 +902,10 @@ void PhyRegAlloc::setRelRegsUsedByThisInst(RegClass *RC,
LiveRange *const LRofImpRef =
LRI.getLiveRangeForValue( MInst->getImplicitRef(z) );
-
- if( LRofImpRef )
- if( LRofImpRef->hasColor() )
- IsColorUsedArr[ LRofImpRef->getColor() ] = true;
+
+ if(LRofImpRef && LRofImpRef->hasColor())
+ IsColorUsedArr[LRofImpRef->getColor()] = true;
}
-
-
-
}
@@ -936,9 +925,8 @@ void PhyRegAlloc::setRelRegsUsedByThisInst(RegClass *RC,
void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI,
const MachineInstr *DelayedMI) {
-
// "added after" instructions of the original instr
- deque<MachineInstr *> &OrigAft = (AddedInstrMap[OrigMI])->InstrnsAfter;
+ std::deque<MachineInstr *> &OrigAft = AddedInstrMap[OrigMI]->InstrnsAfter;
// "added instructions" of the delayed instr
AddedInstrns *DelayAdI = AddedInstrMap[DelayedMI];
@@ -949,21 +937,15 @@ void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI,
}
// "added after" instructions of the delayed instr
- deque<MachineInstr *> &DelayedAft = DelayAdI->InstrnsAfter;
+ std::deque<MachineInstr *> &DelayedAft = DelayAdI->InstrnsAfter;
// go thru all the "added after instructions" of the original instruction
// and append them to the "addded after instructions" of the delayed
// instructions
-
- deque<MachineInstr *>::iterator OrigAdIt;
-
- for( OrigAdIt = OrigAft.begin(); OrigAdIt != OrigAft.end() ; ++OrigAdIt ) {
- DelayedAft.push_back( *OrigAdIt );
- }
+ DelayedAft.insert(DelayedAft.end(), OrigAft.begin(), OrigAft.end());
// empty the "added after instructions" of the original instruction
OrigAft.clear();
-
}
//----------------------------------------------------------------------------
@@ -973,14 +955,14 @@ void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI,
void PhyRegAlloc::printMachineCode()
{
- cout << endl << ";************** Method ";
- cout << Meth->getName() << " *****************" << endl;
+ cerr << "\n;************** Method " << Meth->getName()
+ << " *****************\n";
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
for( ; BBI != Meth->end(); ++BBI) { // traverse BBs in random order
- cout << endl ; printLabel( *BBI); cout << ": ";
+ cerr << "\n"; printLabel( *BBI); cerr << ": ";
// get the iterator for machine instructions
MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
@@ -992,8 +974,8 @@ void PhyRegAlloc::printMachineCode()
MachineInstr *const MInst = *MInstIterator;
- cout << endl << "\t";
- cout << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
+ cerr << "\n\t";
+ cerr << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
//for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) {
@@ -1009,41 +991,39 @@ void PhyRegAlloc::printMachineCode()
const Value *const Val = Op.getVRegValue () ;
// ****this code is temporary till NULL Values are fixed
if( ! Val ) {
- cout << "\t<*NULL*>";
+ cerr << "\t<*NULL*>";
continue;
}
// if a label or a constant
- if( (Val->getValueType() == Value::BasicBlockVal) ) {
-
- cout << "\t"; printLabel( Op.getVRegValue () );
- }
- else {
+ if(isa<BasicBlock>(Val) {
+ cerr << "\t"; printLabel( Op.getVRegValue () );
+ } else {
// else it must be a register value
const int RegNum = Op.getAllocatedRegNum();
- cout << "\t" << "%" << MRI.getUnifiedRegName( RegNum );
+ cerr << "\t" << "%" << MRI.getUnifiedRegName( RegNum );
if (Val->hasName() )
- cout << "(" << Val->getName() << ")";
+ cerr << "(" << Val->getName() << ")";
else
- cout << "(" << Val << ")";
+ cerr << "(" << Val << ")";
if( Op.opIsDef() )
- cout << "*";
+ cerr << "*";
const LiveRange *LROfVal = LRI.getLiveRangeForValue(Val);
if( LROfVal )
if( LROfVal->hasSpillOffset() )
- cout << "$";
+ cerr << "$";
}
}
else if(Op.getOperandType() == MachineOperand::MO_MachineRegister) {
- cout << "\t" << "%" << MRI.getUnifiedRegName(Op.getMachineRegNum());
+ cerr << "\t" << "%" << MRI.getUnifiedRegName(Op.getMachineRegNum());
}
else
- cout << "\t" << Op; // use dump field
+ cerr << "\t" << Op; // use dump field
}
@@ -1051,23 +1031,22 @@ void PhyRegAlloc::printMachineCode()
unsigned NumOfImpRefs = MInst->getNumImplicitRefs();
if( NumOfImpRefs > 0 ) {
- cout << "\tImplicit:";
+ cerr << "\tImplicit:";
for(unsigned z=0; z < NumOfImpRefs; z++) {
printValue( MInst->getImplicitRef(z) );
- cout << "\t";
+ cerr << "\t";
}
}
} // for all machine instructions
-
- cout << endl;
+ cerr << "\n";
} // for all BBs
- cout << endl;
+ cerr << "\n";
}
@@ -1125,9 +1104,9 @@ void PhyRegAlloc::colorIncomingArgs()
assert( FirstMI && "No machine instruction in entry BB");
AddedInstrns *AI = AddedInstrMap[ FirstMI ];
- if ( !AI ) {
+ if (!AI) {
AI = new AddedInstrns();
- AddedInstrMap[ FirstMI ] = AI;
+ AddedInstrMap[FirstMI] = AI;
}
MRI.colorMethodArgs(Meth, LRI, AI );
@@ -1137,12 +1116,11 @@ void PhyRegAlloc::colorIncomingArgs()
//----------------------------------------------------------------------------
// Used to generate a label for a basic block
//----------------------------------------------------------------------------
-void PhyRegAlloc::printLabel(const Value *const Val)
-{
- if( Val->hasName() )
- cout << Val->getName();
+void PhyRegAlloc::printLabel(const Value *const Val) {
+ if (Val->hasName())
+ cerr << Val->getName();
else
- cout << "Label" << Val;
+ cerr << "Label" << Val;
}
@@ -1155,7 +1133,7 @@ void PhyRegAlloc::printLabel(const Value *const Val)
void PhyRegAlloc::markUnusableSugColors()
{
- if(DEBUG_RA ) cout << "\nmarking unusable suggested colors ..." << endl;
+ if(DEBUG_RA ) cerr << "\nmarking unusable suggested colors ...\n";
// hash map iterator
LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin();
@@ -1193,22 +1171,18 @@ void PhyRegAlloc::markUnusableSugColors()
void PhyRegAlloc::allocateStackSpace4SpilledLRs()
{
- if(DEBUG_RA ) cout << "\nsetting LR stack offsets ..." << endl;
+ if(DEBUG_RA ) cerr << "\nsetting LR stack offsets ...\n";
// hash map iterator
LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin();
LiveRangeMapType::const_iterator HMIEnd = (LRI.getLiveRangeMap())->end();
for( ; HMI != HMIEnd ; ++HMI ) {
- if( (*HMI).first ) {
- LiveRange *L = (*HMI).second; // get the LiveRange
- if(L)
- if( ! L->hasColor() )
-
- // NOTE: ** allocating the size of long Type **
- L->setSpillOffFromFP(mcInfo.allocateSpilledValue(TM,
- Type::LongTy));
-
+ if(HMI->first && HMI->second) {
+ LiveRange *L = HMI->second; // get the LiveRange
+ if( ! L->hasColor() )
+ // NOTE: ** allocating the size of long Type **
+ L->setSpillOffFromFP(mcInfo.allocateSpilledValue(TM, Type::LongTy));
}
} // for all LR's in hash map
}
diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.h b/lib/CodeGen/RegAlloc/PhyRegAlloc.h
index 9d34557b01..6871b2d28a 100644
--- a/lib/CodeGen/RegAlloc/PhyRegAlloc.h
+++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.h
@@ -1,4 +1,4 @@
-/* Title: PhyRegAlloc.h
+/* Title: PhyRegAlloc.h -*- C++ -*-
Author: Ruchira Sasanka
Date: Aug 20, 01
Purpose: This is the main entry point for register allocation.
@@ -54,13 +54,11 @@
class AddedInstrns
{
public:
- deque<MachineInstr *> InstrnsBefore; // Added insts BEFORE an existing inst
- deque<MachineInstr *> InstrnsAfter; // Added insts AFTER an existing inst
-
- AddedInstrns() : InstrnsBefore(), InstrnsAfter() { }
+ std::deque<MachineInstr*> InstrnsBefore;// Added insts BEFORE an existing inst
+ std::deque<MachineInstr*> InstrnsAfter; // Added insts AFTER an existing inst
};
-typedef hash_map<const MachineInstr *, AddedInstrns *> AddedInstrMapType;
+typedef std::hash_map<const MachineInstr *, AddedInstrns *> AddedInstrMapType;
@@ -74,7 +72,7 @@ typedef hash_map<const MachineInstr *, AddedInstrns *> AddedInstrMapType;
class PhyRegAlloc: public NonCopyable
{
- vector<RegClass *> RegClassList ; // vector of register classes
+ std::vector<RegClass *> RegClassList; // vector of register classes
const TargetMachine &TM; // target machine
const Method* Meth; // name of the method we work on
MachineCodeForMethod& mcInfo; // descriptor for method's native code
@@ -115,8 +113,7 @@ class PhyRegAlloc: public NonCopyable
const BasicBlock *BB,
const unsigned OpNum);
- inline void constructLiveRanges()
- { LRI.constructLiveRanges(); }
+ inline void constructLiveRanges() { LRI.constructLiveRanges(); }
void colorIncomingArgs();
void colorCallRetArgs();
@@ -141,12 +138,9 @@ class PhyRegAlloc: public NonCopyable
void addInterf4PseudoInstr(const MachineInstr *MInst);
-
public:
-
PhyRegAlloc(Method *const M, const TargetMachine& TM,
MethodLiveVarInfo *const Lvi);
-
~PhyRegAlloc();
// main method called for allocating registers
diff --git a/lib/CodeGen/RegAlloc/RegClass.cpp b/lib/CodeGen/RegAlloc/RegClass.cpp
index 3918871d69..8ba6a15ad1 100644
--- a/lib/CodeGen/RegAlloc/RegClass.cpp
+++ b/lib/CodeGen/RegAlloc/RegClass.cpp
@@ -1,5 +1,6 @@
#include "llvm/CodeGen/RegClass.h"
-
+#include <iostream>
+using std::cerr;
//----------------------------------------------------------------------------
// This constructor inits IG. The actual matrix is created by a call to
@@ -11,7 +12,7 @@ RegClass::RegClass(const Method *const M,
: Meth(M), MRC(Mrc), RegClassID( Mrc->getRegClassID() ),
IG(this), IGNodeStack(), ReservedColorList(RCL) {
if( DEBUG_RA)
- cout << "Created Reg Class: " << RegClassID << endl;
+ cerr << "Created Reg Class: " << RegClassID << "\n";
IsColorUsedArr = new bool[ Mrc->getNumOfAllRegs() ];
}
@@ -23,7 +24,7 @@ RegClass::RegClass(const Method *const M,
//----------------------------------------------------------------------------
void RegClass::colorAllRegs()
{
- if(DEBUG_RA) cout << "Coloring IG of reg class " << RegClassID << " ...\n";
+ if(DEBUG_RA) cerr << "Coloring IG of reg class " << RegClassID << " ...\n";
// pre-color IGNodes
pushAllIGNodes(); // push all IG Nodes
@@ -57,9 +58,9 @@ void RegClass::pushAllIGNodes()
bool PushedAll = pushUnconstrainedIGNodes();
if( DEBUG_RA) {
- cout << " Puhsed all-unconstrained IGNodes. ";
- if( PushedAll ) cout << " No constrained nodes left.";
- cout << endl;
+ cerr << " Puhsed all-unconstrained IGNodes. ";
+ if( PushedAll ) cerr << " No constrained nodes left.";
+ cerr << "\n";
}
if( PushedAll ) // if NO constrained nodes left
@@ -129,8 +130,8 @@ bool RegClass::pushUnconstrainedIGNodes()
IGNode->pushOnStack(); // set OnStack and dec deg of neighs
if (DEBUG_RA > 1) {
- cout << " pushed un-constrained IGNode " << IGNode->getIndex() ;
- cout << " on to stack" << endl;
+ cerr << " pushed un-constrained IGNode " << IGNode->getIndex() ;
+ cerr << " on to stack\n";
}
}
else pushedall = false; // we didn't push all live ranges
@@ -215,16 +216,16 @@ void RegClass::colorIGNode(IGNode *const Node)
}
else {
if( DEBUG_RA ) {
- cout << " Node " << Node->getIndex();
- cout << " already colored with color " << Node->getColor() << endl;
+ cerr << " Node " << Node->getIndex();
+ cerr << " already colored with color " << Node->getColor() << "\n";
}
}
if( !Node->hasColor() ) {
if( DEBUG_RA ) {
- cout << " Node " << Node->getIndex();
- cout << " - could not find a color (needs spilling)" << endl;
+ cerr << " Node " << Node->getIndex();
+ cerr << " - could not find a color (needs spilling)\n";
}
}
diff --git a/lib/CodeGen/RegAlloc/RegClass.h b/lib/CodeGen/RegAlloc/RegClass.h
index d6cbaf892b..fe25986f40 100644
--- a/lib/CodeGen/RegAlloc/RegClass.h
+++ b/lib/CodeGen/RegAlloc/RegClass.h
@@ -13,8 +13,9 @@
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/MachineRegInfo.h"
#include <stack>
+#include <iostream>
-typedef vector<unsigned int> ReservedColorListType;
+typedef std::vector<unsigned int> ReservedColorListType;
//-----------------------------------------------------------------------------
@@ -46,7 +47,7 @@ class RegClass
InterferenceGraph IG; // Interference graph - constructed by
// buildInterferenceGraph
- stack <IGNode *> IGNodeStack; // the stack used for coloring
+ std::stack<IGNode *> IGNodeStack; // the stack used for coloring
const ReservedColorListType *const ReservedColorList;
//
@@ -117,21 +118,14 @@ class RegClass
inline void printIGNodeList() const {
- cerr << "IG Nodes for Register Class " << RegClassID << ":" << endl;
+ std::cerr << "IG Nodes for Register Class " << RegClassID << ":" << "\n";
IG.printIGNodeList();
}
inline void printIG() {
- cerr << "IG for Register Class " << RegClassID << ":" << endl;
+ std::cerr << "IG for Register Class " << RegClassID << ":" << "\n";
IG.printIG();
}
-
};
-
-
-
-
-
-
#endif
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index c48ec92b3e..d92764e49a 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -19,6 +19,10 @@
#include <math.h> // For fmod
#include <signal.h>
#include <setjmp.h>
+#include <iostream>
+using std::vector;
+using std::cout;
+using std::cerr;
cl::Flag QuietMode ("quiet" , "Do not emit any non-program output");
cl::Alias QuietModeA("q" , "Alias for -quiet", cl::NoFlags, QuietMode);
@@ -35,7 +39,7 @@ CachedWriter CW; // Object to accelerate printing of LLVM
static cl::Flag ProfileStructureFields("profilestructfields",
"Profile Structure Field Accesses");
#include <map>
-static map<const StructType *, vector<unsigned> > FieldAccessCounts;
+static std::map<const StructType *, vector<unsigned> > FieldAccessCounts;
#endif
sigjmp_buf SignalRecoverBuffer;
@@ -91,14 +95,14 @@ static GenericValue getOperandValue(Value *V, ExecutionContext &SF) {
case Type::PointerTyID:
if (isa<ConstantPointerNull>(CPV)) {
Result.PointerVal = 0;
- } else if (ConstantPointerRef *CPR =dyn_cast<ConstantPointerRef>(CPV)) {
+ } else if (isa<ConstantPointerRef>(CPV)) {
assert(0 && "Not implemented!");
} else {
assert(0 && "Unknown constant pointer type!");
}
break;
default:
- cout << "ERROR: Constant unimp for type: " << CPV->getType() << endl;
+ cout << "ERROR: Constant unimp for type: " << CPV->getType() << "\n";
}
return Result;
} else if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
@@ -134,7 +138,7 @@ static void printOperandInfo(Value *V, ExecutionContext &SF) {
cout << ( Cur >= 160? char((Cur>>4)+'A'-10) : char((Cur>>4) + '0'))
<< ((Cur&15) >= 10? char((Cur&15)+'A'-10) : char((Cur&15) + '0'));
}
- cout << endl;
+ cout << "\n";
}
}
@@ -143,7 +147,7 @@ static void printOperandInfo(Value *V, ExecutionContext &SF) {
static void SetValue(Value *V, GenericValue Val, ExecutionContext &SF) {
unsigned TyP = V->getType()->getUniqueID(); // TypePlane for value
- //cout << "Setting value: " << &SF.Values[TyP][getOperandSlot(V)] << endl;
+ //cout << "Setting value: " << &SF.Values[TyP][getOperandSlot(V)] << "\n";
SF.Values[TyP][getOperandSlot(V)] = Val;
}
@@ -217,7 +221,7 @@ static void InitializeMemory(Constant *Init, char *Addr) {
return;
default:
- CW << "Bad Type: " << Init->getType() << endl;
+ CW << "Bad Type: " << Init->getType() << "\n";
assert(0 && "Unknown constant type to initialize memory with!");
}
}
@@ -277,7 +281,7 @@ static GenericValue executeAddInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(+, Double);
IMPLEMENT_BINARY_OPERATOR(+, Pointer);
default:
- cout << "Unhandled type for Add instruction: " << Ty << endl;
+ cout << "Unhandled type for Add instruction: " << Ty << "\n";
}
return Dest;
}
@@ -298,7 +302,7 @@ static GenericValue executeSubInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(-, Double);
IMPLEMENT_BINARY_OPERATOR(-, Pointer);
default:
- cout << "Unhandled type for Sub instruction: " << Ty << endl;
+ cout << "Unhandled type for Sub instruction: " << Ty << "\n";
}
return Dest;
}
@@ -319,7 +323,7 @@ static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(*, Double);
IMPLEMENT_BINARY_OPERATOR(*, Pointer);
default:
- cout << "Unhandled type for Mul instruction: " << Ty << endl;
+ cout << "Unhandled type for Mul instruction: " << Ty << "\n";
}
return Dest;
}
@@ -340,7 +344,7 @@ static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(/, Double);
IMPLEMENT_BINARY_OPERATOR(/, Pointer);
default:
- cout << "Unhandled type for Div instruction: " << Ty << endl;
+ cout << "Unhandled type for Div instruction: " << Ty << "\n";
}
return Dest;
}
@@ -365,7 +369,7 @@ static GenericValue executeRemInst(GenericValue Src1, GenericValue Src2,
Dest.DoubleVal = fmod(Src1.DoubleVal, Src2.DoubleVal);
break;
default:
- cout << "Unhandled type for Rem instruction: " << Ty << endl;
+ cout << "Unhandled type for Rem instruction: " << Ty << "\n";
}
return Dest;
}
@@ -384,7 +388,7 @@ static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(&, Long);
IMPLEMENT_BINARY_OPERATOR(&, Pointer);
default:
- cout << "Unhandled type for And instruction: " << Ty << endl;
+ cout << "Unhandled type for And instruction: " << Ty << "\n";
}
return Dest;
}
@@ -404,7 +408,7 @@ static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(|, Long);
IMPLEMENT_BINARY_OPERATOR(|, Pointer);
default:
- cout << "Unhandled type for Or instruction: " << Ty << endl;
+ cout << "Unhandled type for Or instruction: " << Ty << "\n";
}
return Dest;
}
@@ -424,7 +428,7 @@ static GenericValue executeXorInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(^, Long);
IMPLEMENT_BINARY_OPERATOR(^, Pointer);
default:
- cout << "Unhandled type for Xor instruction: " << Ty << endl;
+ cout << "Unhandled type for Xor instruction: " << Ty << "\n";
}
return Dest;
}
@@ -449,7 +453,7 @@ static GenericValue executeSetEQInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(==, Double);
IMPLEMENT_SETCC(==, Pointer);
default:
- cout << "Unhandled type for SetEQ instruction: " << Ty << endl;
+ cout << "Unhandled type for SetEQ instruction: " << Ty << "\n";
}
return Dest;
}
@@ -471,7 +475,7 @@ static GenericValue executeSetNEInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(!=, Pointer);
default:
- cout << "Unhandled type for SetNE instruction: " << Ty << endl;
+ cout << "Unhandled type for SetNE instruction: " << Ty << "\n";
}
return Dest;
}
@@ -492,7 +496,7 @@ static GenericValue executeSetLEInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(<=, Double);
IMPLEMENT_SETCC(<=, Pointer);
default:
- cout << "Unhandled type for SetLE instruction: " << Ty << endl;
+ cout << "Unhandled type for SetLE instruction: " << Ty << "\n";
}
return Dest;
}
@@ -513,7 +517,7 @@ static GenericValue executeSetGEInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(>=, Double);
IMPLEMENT_SETCC(>=, Pointer);
default:
- cout << "Unhandled type for SetGE instruction: " << Ty << endl;
+ cout << "Unhandled type for SetGE instruction: " << Ty << "\n";
}
return Dest;
}
@@ -534,7 +538,7 @@ static GenericValue executeSetLTInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(<, Double);
IMPLEMENT_SETCC(<, Pointer);
default:
- cout << "Unhandled type for SetLT instruction: " << Ty << endl;
+ cout << "Unhandled type for SetLT instruction: " << Ty << "\n";
}
return Dest;
}
@@ -555,7 +559,7 @@ static GenericValue executeSetGTInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(>, Double);
IMPLEMENT_SETCC(>, Pointer);
default:
- cout << "Unhandled type for SetGT instruction: " << Ty << endl;
+ cout << "Unhandled type for SetGT instruction: " << Ty << "\n";
}
return Dest;
}
@@ -598,7 +602,7 @@ static void PerformExitStuff() {
// Print out structure field accounting information...
if (!FieldAccessCounts.empty()) {
CW << "Profile Field Access Counts:\n";
- map<const StructType *, vector<unsigned> >::iterator
+ std::map<const StructType *, vector<unsigned> >::iterator
I = FieldAccessCounts.begin(), E = FieldAccessCounts.end();
for (; I != E; ++I) {
vector<unsigned> &OfC = I->second;
@@ -613,9 +617,9 @@ static void PerformExitStuff() {
if (i) CW << ", ";
CW << OfC[i];
}
- CW << endl;
+ CW << "\n";
}
- CW << endl;
+ CW << "\n";
CW << "Profile Field Access Percentages:\n";
cout.precision(3);
@@ -630,9 +634,9 @@ static void PerformExitStuff() {
if (i) CW << ", ";
CW << double(OfC[i])/Sum;
}
- CW << endl;
+ CW << "\n";
}
- CW << endl;
+ CW << "\n";
FieldAccessCounts.clear();
}
@@ -673,7 +677,7 @@ void Interpreter::executeRetInst(ReturnInst *I, ExecutionContext &SF) {
CW << "Method " << M->getType() << " \"" << M->getName()
<< "\" returned ";
print(RetTy, Result);
- cout << endl;
+ cout << "\n";
}
if (RetTy->isIntegral())
@@ -701,7 +705,7 @@ void Interpreter::executeRetInst(ReturnInst *I, ExecutionContext &SF) {
CW << "Method " << M->getType() << " \"" << M->getName()
<< "\" returned ";
print(RetTy, Result);
- cout << endl;
+ cout << "\n";
}
}
@@ -930,7 +934,7 @@ static void executeShlInst(ShiftInst *I, ExecutionContext &SF) {
IMPLEMENT_SHIFT(<<, ULong);
IMPLEMENT_SHIFT(<<, Long);
default:
- cout << "Unhandled type for Shl instruction: " << Ty << endl;
+ cout << "Unhandled type for Shl instruction: " << Ty << "\n";
}
SetValue(I, Dest, SF);
}
@@ -951,7 +955,7 @@ static void executeShrInst(ShiftInst *I, ExecutionContext &SF) {
IMPLEMENT_SHIFT(>>, ULong);
IMPLEMENT_SHIFT(>>, Long);
default:
- cout << "Unhandled type for Shr instruction: " << Ty << endl;
+ cout << "Unhandled type for Shr instruction: " << Ty << "\n";
}
SetValue(I, Dest, SF);
}
@@ -977,7 +981,7 @@ static void executeShrInst(ShiftInst *I, ExecutionContext &SF) {
IMPLEMENT_CAST(DESTTY, DESTCTY, Double)
#define IMPLEMENT_CAST_CASE_END() \
- default: cout << "Unhandled cast: " << SrcTy << " to " << Ty << endl; \
+ default: cout << "Unhandled cast: " << SrcTy << " to " << Ty << "\n"; \
break; \
} \
break
@@ -1006,7 +1010,7 @@ static void executeCastInst(CastInst *I, ExecutionContext &SF) {
IMPLEMENT_CAST_CASE(Float , (float));
IMPLEMENT_CAST_CASE(Double , (double));
default:
- cout << "Unhandled dest type for cast instruction: " << Ty << endl;
+ cout << "Unhandled dest type for cast instruction: " << Ty << "\n";
}
SetValue(I, Dest, SF);
}
@@ -1060,7 +1064,6 @@ void Interpreter::callMethod(Method *M, const vector<GenericValue> &ArgVals) {
if (RetTy != Type::VoidTy) {
if (!ECStack.empty() && ECStack.back().Caller) {
ExecutionContext &SF = ECStack.back();
- CallInst *Caller = SF.Caller;
SetValue(SF.Caller, Result, SF);
SF.Caller = 0; // We returned from the call...
@@ -1069,7 +1072,7 @@ void Interpreter::callMethod(Method *M, const vector<GenericValue> &ArgVals) {
CW << "Method " << M->getType() << " \"" << M->getName()
<< "\" returned ";
print(RetTy, Result);
- cout << endl;
+ cout << "\n";
if (RetTy->isIntegral())
ExitCode = Result.SByteVal; // Capture the exit code of the program
@@ -1290,8 +1293,8 @@ void Interpreter::printValue(const Type *Ty, GenericValue V) {
case Type::UShortTyID: cout << V.UShortVal; break;
case Type::IntTyID: cout << V.IntVal; break;
case Type::UIntTyID: cout << V.UIntVal; break;
- case Type::LongTyID: cout << V.LongVal; break;
- case Type::ULongTyID: cout << V.ULongVal; break;
+ case Type::LongTyID: cout << (long)V.LongVal; break;
+ case Type::ULongTyID: cout << (unsigned long)V.ULongVal; break;
case Type::FloatTyID: cout << V.FloatVal; break;
case Type::DoubleTyID: cout << V.DoubleVal; break;
case Type::PointerTyID:cout << (void*)V.PointerVal; break;
@@ -1306,31 +1309,31 @@ void Interpreter::print(const Type *Ty, GenericValue V) {
printValue(Ty, V);
}
-void Interpreter::print(const string &Name) {
+void Interpreter::print(const std::string &Name) {
Value *PickedVal = ChooseOneOption(Name, LookupMatchingNames(Name));
if (!PickedVal) return;
if (const Method *M = dyn_cast<const Method>(PickedVal)) {
CW << M; // Print the method
} else if (const Type *Ty = dyn_cast<const Type>(PickedVal)) {
- CW << "type %" << Name << " = " << Ty->getDescription() << endl;
+ CW << "type %" << Name << " = " << Ty->getDescription() << "\n";
} else if (const BasicBlock *BB = dyn_cast<const BasicBlock>(PickedVal)) {
CW << BB; // Print the basic block
} else { // Otherwise there should be an annotation for the slot#
print(PickedVal->getType(),
getOperandValue(PickedVal, ECStack[CurFrame]));
- cout << endl;
+ cout << "\n";
}
}
-void Interpreter::infoValue(const string &Name) {
+void Interpreter::infoValue(const std::string &Name) {
Value *PickedVal = ChooseOneOption(Name, LookupMatchingNames(Name));
if (!PickedVal) return;
cout << "Value: ";
print(PickedVal->getType(),
getOperandValue(PickedVal, ECStack[CurFrame]));
- cout << endl;
+ cout << "\n";
printOperandInfo(PickedVal, ECStack[CurFrame]);
}
@@ -1353,7 +1356,7 @@ void Interpreter::printStackFrame(int FrameNo = -1) {
printValue(Args[i]->getType(), getOperandValue(Args[i], ECStack[FrameNo]));
}
- cout << ")" << endl;
+ cout << ")\n";
CW << *(ECStack[FrameNo].CurInst-(FrameNo != int(ECStack.size()-1)));
}
diff --git a/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h b/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h
index f6a27265f0..12717ec48e 100644
--- a/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h
+++ b/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h
@@ -23,7 +23,7 @@ static AnnotationID MethodInfoAID(
struct MethodInfo : public Annotation {
MethodInfo(Method *M);
- vector<unsigned> NumPlaneElements;
+ std::vector<unsigned> NumPlaneElements;
// Create - Factory function to allow MethodInfo annotations to be
diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
index a54a6f1ced..bcff5e5795 100644
--- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
+++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
@@ -13,26 +13,29 @@
#include "llvm/DerivedTypes.h"
#include <map>
#include <dlfcn.h>
+#include <iostream>
#include <link.h>
#include <math.h>
#include <stdio.h>
+using std::vector;
+using std::cout;
typedef GenericValue (*ExFunc)(MethodType *, const vector<GenericValue> &);
-static map<const Method *, ExFunc> Functions;
-static map<string, ExFunc> FuncNames;
+static std::map<const Method *, ExFunc> Functions;
+static std::map<std::string, ExFunc> FuncNames;
static Interpreter *TheInterpreter;
// getCurrentExecutablePath() - Return the directory that the lli executable
// lives in.
//
-string Interpreter::getCurrentExecutablePath() const {
+std::string Interpreter::getCurrentExecutablePath() const {
Dl_info Info;
if (dladdr(&TheInterpreter, &Info) == 0) return "";
- string LinkAddr(Info.dli_fname);
+ std::string LinkAddr(Info.dli_fname);
unsigned SlashPos = LinkAddr.rfind('/');
- if (SlashPos != string::npos)
+ if (SlashPos != std::string::npos)
LinkAddr.resize(SlashPos); // Trim the executable name off...
return LinkAddr;
@@ -65,7 +68,7 @@ static char getTypeID(const Type *Ty) {
static ExFunc lookupMethod(const Method *M) {
// Function not found, look it up... start by figuring out what the
// composite function name should be.
- string ExtName = "lle_";
+ std::string ExtName = "lle_";
const MethodType *MT = M->getMethodType();
for (unsigned i = 0; const Type *Ty = MT->getContainedType(i); ++i)
ExtName += getTypeID(Ty);
@@ -80,7 +83,7 @@ static ExFunc lookupMethod(const Method *M) {
if (FnPtr == 0) // Try calling a generic function... if it exists...
FnPtr = (ExFunc)dlsym(RTLD_DEFAULT, ("lle_X_"+M->getName()).c_str());
if (FnPtr != 0)
- Functions.insert(make_pair(M, FnPtr)); // Cache for later
+ Functions.insert(std::make_pair(M, FnPtr)); // Cache for later
return FnPtr;
}
@@ -90,11 +93,11 @@ GenericValue Interpreter::callExternalMethod(Method *M,
// Do a lookup to see if the method is in our cache... this should just be a
// defered annotation!
- map<const Method *, ExFunc>::iterator FI = Functions.find(M);
+ std::map<const Method *, ExFunc>::iterator FI = Functions.find(M);
ExFunc Fn = (FI == Functions.end()) ? lookupMethod(M) : FI->second;
if (Fn == 0) {
cout << "Tried to execute an unknown external method: "
- << M->getType()->getDescription() << " " << M->getName() << endl;
+ << M->getType()->getDescription() << " " << M->getName() << "\n";
return GenericValue();
}
@@ -177,13 +180,13 @@ GenericValue lle_Vb_putchar(MethodType *M, const vector<GenericValue> &Args) {
// int "putchar"(int)
GenericValue lle_ii_putchar(MethodType *M, const vector<GenericValue> &Args) {
- cout << ((char)Args[0].IntVal) << flush;
+ cout << ((char)Args[0].IntVal) << std::flush;
return Args[0];
}
// void "putchar"(ubyte)
GenericValue lle_VB_putchar(MethodType *M, const vector<GenericValue> &Args) {
- cout << Args[0].SByteVal << flush;
+ cout << Args[0].SByteVal << std::flush;
return Args[0];
}
diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h
index 44b382bd9f..ffe1001597 100644
--- a/lib/ExecutionEngine/Interpreter/Interpreter.h
+++ b/lib/ExecutionEngine/Interpreter/Interpreter.h
@@ -41,7 +41,7 @@ union GenericValue {
PointerTy PointerVal;
};
-typedef vector<GenericValue> ValuePlaneTy;
+typedef std::vector<GenericValue> ValuePlaneTy;
// ExecutionContext struct - This struct represents one stack frame currently
// executing.
@@ -51,7 +51,7 @@ struct ExecutionContext {
BasicBlock *CurBB; // The currently executing BB
BasicBlock::iterator CurInst; // The next instruction to execute
MethodInfo *MethInfo; // The MethInfo annotation for the method
- vector<ValuePlaneTy> Values; // ValuePlanes for each type
+ std::vector<ValuePlaneTy> Values;// ValuePlanes for each type
BasicBlock *PrevBB; // The previous BB or null if in first BB
CallInst *Caller; // Holds the call that called subframes.
@@ -69,7 +69,7 @@ class Interpreter {
// The runtime stack of executing code. The top of the stack is the current
// method record.
- vector<ExecutionContext> ECStack;
+ std::vector<ExecutionContext> ECStack;
public:
Interpreter();
@@ -86,24 +86,24 @@ public:
void handleUserInput();
// User Interation Methods...
- void loadModule(const string &Filename);
+ void loadModule(const std::string &Filename);
bool flushModule();
- bool callMethod(const string &Name); // return true on failure
- void setBreakpoint(const string &Name);
- void infoValue(const string &Name);
- void print(const string &Name);
+ bool callMethod(const std::string &Name); // return true on failure
+ void setBreakpoint(const std::string &Name);
+ void infoValue(const std::string &Name);
+ void print(const std::string &Name);
static void print(const Type *Ty, GenericValue V);
static void printValue(const Type *Ty, GenericValue V);
// Hack until we can parse command line args...
- bool callMainMethod(const string &MainName,
- const vector<string> &InputFilename);
+ bool callMainMethod(const std::string &MainName,
+ const std::vector<std::string> &InputFilename);
void list(); // Do the 'list' command
void printStackTrace(); // Do the 'backtrace' command
// Code execution methods...
- void callMethod (Method *Meth, const vector<GenericValue> &ArgVals);
+ void callMethod(Method *Meth, const std::vector<GenericValue> &ArgVals);
bool executeInstruction(); // Execute one instruction...
void stepInstruction(); // Do the 'step' command
@@ -117,7 +117,7 @@ public:
void executeBrInst(BranchInst *I, ExecutionContext &SF);
void executeAllocInst(AllocationInst *I, ExecutionContext &SF);
GenericValue callExternalMethod(Method *Meth,
- const vector<GenericValue> &ArgVals);
+ const std::vector<GenericValue> &ArgVals);
void exitCalled(GenericValue GV);
// getCurrentMethod - Return the currently executing method
@@ -134,7 +134,7 @@ private: // Helper functions
// getCurrentExecutablePath() - Return the directory that the lli executable
// lives in.
//
- string getCurrentExecutablePath() const;
+ std::string getCurrentExecutablePath() const;
// printCurrentInstruction - Print out the instruction that the virtual PC is
// at, or fail silently if no program is running.
@@ -151,13 +151,14 @@ private: // Helper functions
// matches to that name. This is obviously slow, and should only be used for
// user interaction.
//
- vector<Value*> LookupMatchingNames(const string &Name);
+ std::vector<Value*> LookupMatchingNames(const std::string &Name);
// ChooseOneOption - Prompt the user to choose among the specified options to
// pick one value. If no options are provided, emit an error. If a single
// option is provided, just return that option.
//
- Value *ChooseOneOption(const string &Name, const vector<Value*> &Opts);
+ Value *ChooseOneOption(const std::string &Name,
+ const std::vector<Value*> &Opts);
void initializeExecutionEngine();
diff --git a/lib/ExecutionEngine/Interpreter/Support.cpp b/lib/ExecutionEngine/Interpreter/Support.cpp
index a619304c62..ca89ae3333 100644
--- a/lib/ExecutionEngine/Interpreter/Support.cpp
+++ b/lib/ExecutionEngine/Interpreter/Support.cpp
@@ -7,13 +7,15 @@
#include "Interpreter.h"
#include "llvm/SymbolTable.h"
#include "llvm/Assembly/Writer.h"
+#include <iostream>
+using std::cout;
//===----------------------------------------------------------------------===//
//
// LookupMatchingNames helper - Search a symbol table for values matching Name.
//
-static inline void LookupMatchingNames(const string &Name, SymTabValue &STV,
- vector<Value*> &Results) {
+static inline void LookupMatchingNames(const std::string &Name,SymTabValue &STV,
+ std::vector<Value*> &Results) {
SymbolTable *SymTab = STV.getSymbolTable();
if (SymTab == 0) return; // No symbolic values :(
@@ -34,8 +36,8 @@ static inline void LookupMatchingNames(const string &Name, SymTabValue &STV,
// matches to that name. This is obviously slow, and should only be used for
// user interaction.
//
-vector<Value*> Interpreter::LookupMatchingNames(const string &Name) {
- vector<Value*> Results;
+std::vector<Value*> Interpreter::LookupMatchingNames(const std::string &Name) {
+ std::vector<Value*> Results;
Method *CurMeth = getCurrentMethod();
if (CurMeth) ::LookupMatchingNames(Name, *CurMeth, Results);
@@ -47,8 +49,8 @@ vector<Value*> Interpreter::LookupMatchingNames(const string &Name) {
// pick one value. If no options are provided, emit an error. If a single
// option is provided, just return that option.
//
-Value *Interpreter::ChooseOneOption(const string &Name,
- const vector<Value*> &Opts) {
+Value *Interpreter::ChooseOneOption(const std::string &Name,
+ const std::vector<Value*> &Opts) {
switch (Opts.size()) {
case 1: return Opts[0];
case 0:
@@ -61,16 +63,16 @@ Value *Interpreter::ChooseOneOption(const string &Name,
cout << " 0. Cancel operation\n";
for (unsigned i = 0; i < Opts.size(); ++i) {
cout << " " << (i+1) << ".";
- WriteAsOperand(cout, Opts[i]) << endl;
+ WriteAsOperand(cout, Opts[i]) << "\n";
}
unsigned Option;
do {
- cout << "lli> " << flush;
- cin >> Option;
+ cout << "lli> " << std::flush;
+ std::cin >> Option;
if (Option > Opts.size())
cout << "Invalid selection: Please choose from 0 to " << Opts.size()
- << endl;
+ << "\n";
} while (Option > Opts.size());
if (Option == 0) return 0;
diff --git a/lib/ExecutionEngine/Interpreter/UserInput.cpp b/lib/ExecutionEngine/Interpreter/UserInput.cpp
index 179b97d277..1cd8b08c1f 100644
--- a/lib/ExecutionEngine/Interpreter/UserInput.cpp
+++ b/lib/ExecutionEngine/Interpreter/UserInput.cpp
@@ -10,6 +10,9 @@
#include "llvm/DerivedTypes.h"
#include "llvm/Transforms/Linker.h"
#include <algorithm>
+using std::string;
+using std::cout;
+using std::cin;
enum CommandID {
Quit, Help, // Basics
@@ -69,14 +72,14 @@ void Interpreter::handleUserInput() {
bool UserQuit = false;
// Sort the table...
- sort(CommandTable, CommandTableEnd);
+ std::sort(CommandTable, CommandTableEnd);
// Print the instruction that we are stopped at...
printCurrentInstruction();
do {
string Command;
- cout << "lli> " << flush;
+ cout << "lli> " << std::flush;
cin >> Command;
CommandTableElement *E = find(CommandTable, CommandTableEnd, Command);
@@ -164,11 +167,11 @@ void Interpreter::loadModule(const string &Filename) {
if (Module *SupportLib = ParseBytecodeFile(RuntimeLib, &ErrorMsg)) {
if (LinkModules(CurMod, SupportLib, &ErrorMsg))
- cerr << "Error Linking runtime library into current module: "
- << ErrorMsg << endl;
+ std::cerr << "Error Linking runtime library into current module: "
+ << ErrorMsg << "\n";
} else {
- cerr << "Error loading runtime library '"+RuntimeLib+"': "
- << ErrorMsg << "\n";
+ std::cerr << "Error loading runtime library '"+RuntimeLib+"': "
+ << ErrorMsg << "\n";
}
}
@@ -208,7 +211,7 @@ void Interpreter::setBreakpoint(const string &Name) {
// callMethod - Enter the specified method...
//
bool Interpreter::callMethod(const string &Name) {
- vector<Value*> Options = LookupMatchingNames(Name);
+ std::vector<Value*> Options = LookupMatchingNames(Name);
for (unsigned i = 0; i < Options.size(); ++i) { // Remove nonmethod matches...
if (!isa<Method>(Options[i])) {
@@ -223,7 +226,7 @@ bool Interpreter::callMethod(const string &Name) {
Method *M = cast<Method>(PickedMeth);
- vector<GenericValue> Args;
+ std::vector<GenericValue> Args;
// TODO, get args from user...
callMethod(M, Args); // Start executing it...
@@ -234,7 +237,7 @@ bool Interpreter::callMethod(const string &Name) {
return false;
}
-static void *CreateArgv(const vector<string> &InputArgv) {
+static void *CreateArgv(const std::vector<string> &InputArgv) {
// Pointers are 64 bits...
uint64_t *Result = new PointerTy[InputArgv.size()+1];
@@ -255,8 +258,8 @@ static void *CreateArgv(const vector<string> &InputArgv) {
// callMethod can parse command line options and stuff for us.
//
bool Interpreter::callMainMethod(const string &Name,
- const vector<string> &InputArgv) {
- vector<Value*> Options = LookupMatchingNames(Name);
+ const std::vector<string> &InputArgv) {
+ std::vector<Value*> Options = LookupMatchingNames(Name);
for (unsigned i = 0; i < Options.size(); ++i) { // Remove nonmethod matches...
if (!isa<Method>(Options[i])) {
@@ -272,7 +275,7 @@ bool Interpreter::callMainMethod(const string &Name,
Method *M = cast<Method>(PickedMeth);
const MethodType *MT = M->getMethodType();
- vector<GenericValue> Args;
+ std::vector<GenericValue> Args;
switch (MT->getParamTypes().size()) {
default:
cout << "Unknown number of arguments to synthesize for '" << Name << "'!\n";
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index f04c8a46a3..e1622529c2 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -17,6 +17,10 @@
#include "llvm/DerivedTypes.h"
#include "llvm/iOther.h"
#include "llvm/ConstantVals.h"
+#include <iostream>
+using std::cerr;
+using std::string;
+using std::map;
// Error - Simple wrapper function to conditionally assign to E and return true.
// This just makes error return conditions a little bit simpler...
@@ -70,7 +74,7 @@ static void PrintMap(const map<const Value*, Value*> &M) {
for (map<const Value*, Value*>::const_iterator I = M.begin(), E = M.end();
I != E; ++I) {
cerr << " Fr: " << (void*)I->first << " " << I->first
- << " To: " << (void*)I->second << " " << I->second << endl;
+ << " To: " << (void*)I->second << " " << I->second << "\n";
}
}
@@ -97,15 +101,15 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
Constant *Result = 0;
if (ConstantArray *CPA = dyn_cast<ConstantArray>(CPV)) {
- const vector<Use> &Ops = CPA->getValues();
- vector<Constant*> Operands(Ops.size());
+ const std::vector<Use> &Ops = CPA->getValues();
+ std::vector<Constant*> Operands(Ops.size());
for (unsigned i = 0; i < Ops.size(); ++i)
Operands[i] =
cast<Constant>(RemapOperand(Ops[i], LocalMap, GlobalMap));
Result = ConstantArray::get(cast<ArrayType>(CPA->getType()), Operands);
} else if (ConstantStruct *CPS = dyn_cast<ConstantStruct>(CPV)) {
- const vector<Use> &Ops = CPS->getValues();
- vector<Constant*> Operands(Ops.size());
+ const std::vector<Use> &Ops = CPS->getValues();
+ std::vector<Constant*> Operands(Ops.size());
for (unsigned i = 0; i < Ops.size(); ++i)
Operands[i] =
cast<Constant>(RemapOperand(Ops[i], LocalMap, GlobalMap));
@@ -120,7 +124,7 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
}
// Cache the mapping in our local map structure...
- LocalMap.insert(make_pair(In, CPV));
+ LocalMap.insert(std::make_pair(In, CPV));
return Result;
}
@@ -132,7 +136,7 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
PrintMap(*GlobalMap);
}
- cerr << "Couldn't remap value: " << (void*)In << " " << In << endl;
+ cerr << "Couldn't remap value: " << (void*)In << " " << In << "\n";
assert(0 && "Couldn't remap value!");
return 0;
}
@@ -172,7 +176,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
" - Global variables differ in const'ness");
// Okay, everything is cool, remember the mapping...
- ValueMap.insert(make_pair(SGV, DGV));
+ ValueMap.insert(std::make_pair(SGV, DGV));
} else {
// No linking to be performed, simply create an identical version of the
// symbol over in the dest module... the initializer will be filled in
@@ -186,7 +190,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
Dest->getGlobalList().push_back(DGV);
// Make sure to remember this mapping...
- ValueMap.insert(make_pair(SGV, DGV));
+ ValueMap.insert(std::make_pair(SGV, DGV));
}
}
return false;
@@ -262,7 +266,7 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src,
SM->getName() + "\" - Method is already defined!");
// Otherwise, just remember this mapping...
- ValueMap.insert(make_pair(SM, DM));
+ ValueMap.insert(std::make_pair(SM, DM));
} else {
// Method does not already exist, simply insert an external method
// signature identical to SM into the dest module...
@@ -273,7 +277,7 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src,
Dest->getMethodList().push_back(DM);
// ... and remember this mapping...
- ValueMap.insert(make_pair(SM, DM));
+ ValueMap.insert(std::make_pair(SM, DM));
}
}
return false;
@@ -300,7 +304,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src,
Dest->getArgumentList().push_back(DMA);
// Add a mapping to our local map
- LocalMap.insert(make_pair(SMA, DMA));
+ LocalMap.insert(std::make_pair(SMA, DMA));
}
// Loop over all of the basic blocks, copying the instructions over...
@@ -310,7 +314,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src,
// Create new basic block and add to mapping and the Dest method...
BasicBlock *DBB = new BasicBlock(SBB->getName(), Dest);
- LocalMap.insert(make_pair(SBB, DBB));
+ LocalMap.insert(std::make_pair(SBB, DBB));
// Loop over all of the instructions in the src basic block, copying them
// over. Note that this is broken in a strict sense because the cloned
@@ -324,7 +328,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src,
Instruction *DI = SI->clone();
DI->setName(SI->getName());
DBB->getInstList().push_back(DI);
- LocalMap.insert(make_pair(SI, DI));
+ LocalMap.insert(std::make_pair(SI, DI));
}
}
diff --git a/lib/Support/Annotation.cpp b/lib/Support/Annotation.cpp
index 65a049d42d..d0d13cda86 100644
--- a/lib/Support/Annotation.cpp
+++ b/lib/Support/Annotation.cpp
@@ -6,6 +6,10 @@
#include <map>
#include "llvm/Annotation.h"
+using std::string;
+using std::map;
+using std::pair;
+using std::make_pair;
typedef map<const string, unsigned> IDMapType;
static unsigned IDCounter = 0; // Unique ID counter
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index f6938169da..549f42c4e3 100644
--- a/lib/Support/CommandLine.cpp
+++ b/lib/Support/CommandLine.cpp
@@ -15,7 +15,13 @@
#include <algorithm>
#include <map>
#include <set>
+#include <iostream>
using namespace cl;
+using std::map;
+using std::pair;
+using std::vector;
+using std::string;
+using std::cerr;
// Return the global command line option vector. Making it a function scoped
// static ensures that it will be initialized correctly before its first use.
@@ -31,7 +37,7 @@ static void AddArgument(const string &ArgName, Option *Opt) {
<< "' specified more than once!\n";
} else {
// Add argument to the argument map!
- getOpts().insert(make_pair(ArgName, Opt));
+ getOpts().insert(std::make_pair(ArgName, Opt));
}
}
@@ -59,7 +65,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
break;
case ValueOptional: break;
default: cerr << "Bad ValueMask flag! CommandLine usage error:"
- << Handler->getValueExpectedFlag() << endl; abort();
+ << Handler->getValueExpectedFlag() << "\n"; abort();
}
// Run the handler now!
@@ -210,7 +216,7 @@ Option::Option(const char *argStr, const char *helpStr, int flags)
bool Option::error(string Message, const char *ArgName = 0) {
if (ArgName == 0) ArgName = ArgStr;
- cerr << "-" << ArgName << " option" << Message << endl;
+ cerr << "-" << ArgName << " option" << Message << "\n";
return true;
}
@@ -244,7 +250,7 @@ void Option::printOptionInfo(unsigned GlobalWidth) const {
unsigned L = std::strlen(ArgStr);
if (L == 0) return; // Don't print the empty arg like this!
cerr << " -" << ArgStr << string(GlobalWidth-L-6, ' ') << " - "
- << HelpStr << endl;
+ << HelpStr << "\n";
}
@@ -301,8 +307,8 @@ void EnumBase::processValues(va_list Vals) {
while (const char *EnumName = va_arg(Vals, const char *)) {
int EnumVal = va_arg(Vals, int);
const char *EnumDesc = va_arg(Vals, const char *);
- ValueMap.push_back(make_pair(EnumName, // Add value to value map
- make_pair(EnumVal, EnumDesc)));
+ ValueMap.push_back(std::make_pair(EnumName, // Add value to value map
+ std::make_pair(EnumVal, EnumDesc)));
}
}
@@ -339,7 +345,7 @@ bool EnumValueBase::handleOccurance(const char *ArgName, const string &Arg) {
unsigned EnumValueBase::getOptionWidth() const {
unsigned BaseSize = Option::getOptionWidth();
for (unsigned i = 0; i < ValueMap.size(); ++i)
- BaseSize = max(BaseSize, std::strlen(ValueMap[i].first)+8);
+ BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+8);
return BaseSize;
}
@@ -354,7 +360,7 @@ void EnumValueBase::printOptionInfo(unsigned GlobalWidth) const {
<< ValueMap[i].second.second;
if (i == 0) cerr << " (default)";
- cerr << endl;
+ cerr << "\n";
}
}
@@ -369,7 +375,7 @@ bool EnumFlagsBase::handleOccurance(const char *ArgName, const string &Arg) {
unsigned EnumFlagsBase::getOptionWidth() const {
unsigned BaseSize = 0;
for (unsigned i = 0; i < ValueMap.size(); ++i)
- BaseSize = max(BaseSize, std::strlen(ValueMap[i].first)+6);
+ BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+6);
return BaseSize;
}
@@ -379,7 +385,7 @@ void EnumFlagsBase::printOptionInfo(unsigned GlobalWidth) const {
cerr << " -" << ValueMap[i].first << string(GlobalWidth-L-6, ' ') << " - "
<< ValueMap[i].second.second;
if (i == 0) cerr << " (default)";
- cerr << endl;
+ cerr << "\n";
}
}
@@ -402,7 +408,7 @@ bool EnumListBase::handleOccurance(const char *ArgName, const string &Arg) {
unsigned EnumListBase::getOptionWidth() const {
unsigned BaseSize = 0;
for (unsigned i = 0; i < ValueMap.size(); ++i)
- BaseSize = max(BaseSize, std::strlen(ValueMap[i].first)+6);
+ BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+6);
return BaseSize;
}
@@ -414,7 +420,7 @@ void EnumListBase::printOptionInfo(unsigned GlobalWidth) const {
for (unsigned i = 0; i < ValueMap.size(); ++i) {
unsigned L = std::strlen(ValueMap[i].first);
cerr << " -" << ValueMap[i].first << string(GlobalWidth-L-6, ' ') << " - "
- << ValueMap[i].second.second << endl;
+ << ValueMap[i].second.second << "\n";
}
}
@@ -440,15 +446,15 @@ class Help : public Option {
virtual bool handleOccurance(const char *ArgName, const string &Arg) {
// Copy Options into a vector so we can sort them as we like...
vector<pair<string, Option*> > Options;
- copy(getOpts().begin(), getOpts().end(), back_inserter(Options));
+ copy(getOpts().begin(), getOpts().end(), std::back_inserter(Options));
// Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden
Options.erase(remove_if(Options.begin(), Options.end(),
- ptr_fun(ShowHidden ? isReallyHidden : isHidden)),
+ std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)),
Options.end());
// Eliminate duplicate entries in table (from enum flags options, f.e.)
- set<Option*> OptionSet;
+ std::set<Option*> OptionSet;
for (unsigned i = 0; i < Options.size(); )
if (OptionSet.count(Options[i].second) == 0)
OptionSet.insert(Options[i++].second); // Add to set
@@ -457,7 +463,7 @@ class Help : public Option {
if (ProgramOverview)
- cerr << "OVERVIEW:" << ProgramOverview << endl;
+ cerr << "OVERVIEW:" << ProgramOverview << "\n";
// TODO: Sort options by some criteria
cerr << "USAGE: " << ProgramName << " [options]\n\n";
@@ -478,7 +484,7 @@ class Help : public Option {
void getMaxArgLen(pair<string, Option *> OptPair) {
const Option *Opt = OptPair.second;
if (Opt->ArgStr[0] == 0) EmptyArg = Opt; // Capture the empty arg if exists
- MaxArgLen = max(MaxArgLen, Opt->getOptionWidth());
+ MaxArgLen = std::max(MaxArgLen, Opt->getOptionWidth());
}
void printOption(pair<string, Option *> OptPair) {
diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp
index 528e5abdd3..ea41b6f822 100644
--- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp
+++ b/lib/Target/SparcV9/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 @@ private:
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 @@ public:
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 @@ public:
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 @@ SchedulingManager::updateEarliestStartTimes(const SchedGraphNode* node,
{
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 @@ AssignInstructionsToSlots(class SchedulingManager& S, unsigned maxIssue)
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 @@ FindSlotChoices(SchedulingManager& S,
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 @@ FindSlotChoices(SchedulingManager& S,
// 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 @@ ChooseOneGroup(SchedulingManager& S)
{
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 @@ ForwardListSchedule(SchedulingManager& S)
// 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 @@ ScheduleInstructionsWithSSA(Method* method,
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 @@ ScheduleInstructionsWithSSA(Method* method,
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 @@ ScheduleInstructionsWithSSA(Method* method,
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/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp
index 9e9af5b80d..7c83e1a58c 100644
--- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp
+++ b/lib/Target/SparcV9/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 @@ SchedGraphEdge::~SchedGraphEdge()
}
void SchedGraphEdge::dump(int indent=0) const {
- cout << string(indent*2, ' ') << *this;
+ cerr << std::string(indent*2, ' ') << *this;
}
@@ -168,7 +174,7 @@ SchedGraphNode::~SchedGraphNode()
}
void SchedGraphNode::dump(int indent=0) const {
- cout << string(indent*2, ' ') << *this;
+ cerr << std::string(indent*2, ' ') << *this;
}
@@ -222,21 +228,20 @@ SchedGraph::SchedGraph(const BasicBlock* bb,
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 @@ SchedGraph::~SchedGraph()
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 @@ SchedGraph::addNonSSAEdgesForValue(const Instruction* instr,
// 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 @@ SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target,
{
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 @@ SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target,
&& "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 @@ SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target,
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 @@ SchedGraph::buildNodesforBB(const TargetMachine& target,
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(const Method* _method,
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 @@ SchedGraphSet::buildGraphsForMethod(const Method *method,
-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 @@ operator<<(ostream& os, const SchedGraphEdge& edge)
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/Target/SparcV9/InstrSched/SchedGraph.h b/lib/Target/SparcV9/InstrSched/SchedGraph.h
index a4567a5198..2890241d59 100644
--- a/lib/Target/SparcV9/InstrSched/SchedGraph.h
+++ b/lib/Target/SparcV9/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 @@ public:
//
// 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 @@ private:
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 @@ public:
//
// 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 @@ private:
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 @@ public:
// 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 @@ private:
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 @@ private:
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 @@ private:
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 @@ public:
//
// 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 @@ template <> struct GraphTraits<const SchedGraph*> {
};
-//************************ 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/Target/SparcV9/InstrSched/SchedPriorities.cpp b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp
index 1769707238..8cde252115 100644
--- a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp
+++ b/lib/Target/SparcV9/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 @@ SchedPriorities::computeDelays(const SchedGraph* graph)
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 @@ SchedPriorities::initializeReadyHeap(const SchedGraph* graph)
#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 @@ SchedPriorities::issuedReadyNodeAt(cycles_t curTime,
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 @@ SchedPriorities::issuedReadyNodeAt(cycles_t curTime,
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 @@ SchedPriorities::issuedReadyNodeAt(cycles_t curTime,
//----------------------------------------------------------------------
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 @@ SchedPriorities::chooseByRule2(vector<candIndex>& mcands)
}
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 @@ SchedPriorities::getNextHighest(const SchedulingManager& S,
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 @@ SchedPriorities::findSetWithMaxDelay(vector<candIndex>& mcands,
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 @@ SchedPriorities::instructionHasLastUse(MethodLiveVarInfo& methodLiveVarInfo,
{
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/Target/SparcV9/InstrSched/SchedPriorities.h b/lib/Target/SparcV9/InstrSched/SchedPriorities.h
index 81a2e6a053..a8b3e23397 100644
--- a/lib/Target/SparcV9/InstrSched/SchedPriorities.h
+++ b/lib/Target/SparcV9/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 @@ struct NodeDelayPair {
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 @@ public:
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 @@ private:
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 @@ private:
};
-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
diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
index ce3e2c3a3f..20cbe8d71b 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
+++ b/lib/Target/SparcV9/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 @@ void
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 @@ void
VRegListNode::dumpNode(int indent) const
{
for (int i=0; i < indent; i++)
- cout << " ";
+ cerr << " ";
- cout << "List" << endl;
+ cerr << "List" << "\n";
}
@@ -151,29 +154,29 @@ void
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(Method *M)
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 @@ InstrForest::~InstrForest()
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/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
index b959c90ca3..ab489c507e 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
+++ b/lib/Target/SparcV9/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 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
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 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
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 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) {
// 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 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) {
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 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) {
MachineCodeForBasicBlock& bbMvec = BB->getMachineInstrVec();
bbMvec.insert( bbMvec.begin(), CpMI2);
-
-
}
else break; // since PHI nodes can only be at the top
@@ -338,7 +328,7 @@ PostprocessMachineCodeForTree(InstructionNode* instrNode,
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 @@ SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt,
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/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
index 30d9c7eb78..34dd83b49e 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
+++ b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
@@ -22,7 +22,7 @@
#include "llvm/Instruction.h"
#include "llvm/Type.h"
#include "llvm/iMemory.h"
-
+using std::vector;
//*************************** Local Functions ******************************/
diff --git a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp
index d7e036b256..0ecf96cf13 100644
--- a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp
+++ b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp
@@ -1,8 +1,13 @@
#include "llvm/Analysis/LiveVar/BBLiveVar.h"
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
+
+/// BROKEN: Should not include sparc stuff directly into here
#include "../../Target/Sparc/SparcInternals.h" // Only for PHI defn
+using std::cerr;
+using std::endl;
+using std::pair;
//-----------------------------------------------------------------------------
// Constructor
@@ -39,7 +44,7 @@ void BBLiveVar::calcDefUseSets()
if( DEBUG_LV > 1) { // debug msg
cerr << " *Iterating over machine instr ";
MInst->dump();
- cerr << endl;
+ cerr << "\n";
}
// iterate over MI operands to find defs
@@ -85,9 +90,9 @@ void BBLiveVar::calcDefUseSets()
if( DEBUG_LV > 1) { // debug msg of level 2
cerr << " - phi operand ";
printValue( ArgVal );
- cerr << " came from BB ";
+ cerr << " came from BB ";
printValue( PhiArgMap[ ArgVal ]);
- cerr<<endl;
+ cerr << "\n";
}
} // if( IsPhi )
@@ -123,7 +128,7 @@ void BBLiveVar::addDef(const Value *Op)
InSetChanged = true;
if( DEBUG_LV > 1) {
- cerr << " +Def: "; printValue( Op ); cerr << endl;
+ cerr << " +Def: "; printValue( Op ); cerr << "\n";
}
}
diff --git a/lib/Target/SparcV9/LiveVar/BBLiveVar.h b/lib/Target/SparcV9/LiveVar/BBLiveVar.h
index 6d7d4eb533..9ce56a88f6 100644
--- a/lib/Target/SparcV9/LiveVar/BBLiveVar.h
+++ b/lib/Target/SparcV9/LiveVar/BBLiveVar.h
@@ -28,7 +28,7 @@ class BBLiveVar
// map that contains phi args->BB they came
// set by calcDefUseSets & used by setPropagate
- hash_map<const Value *, const BasicBlock *, hashFuncValue> PhiArgMap;
+ std::hash_map<const Value *, const BasicBlock *> PhiArgMap;
// method to propogate an InSet to OutSet of a predecessor
bool setPropagate( LiveVarSet *const OutSetOfPred,
diff --git a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
index 636359d1d0..5de35ff1be 100644
--- a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
+++ b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
@@ -12,15 +12,15 @@
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "Support/PostOrderIterator.h"
-
+#include <iostream>
+using std::cout;
+using std::endl;
//************************** Constructor/Destructor ***************************
-MethodLiveVarInfo::MethodLiveVarInfo(const Method *const M) : Meth(M),
- BB2BBLVMap()
-{
- assert(! M->isExternal() ); // cannot be a prototype decleration
+MethodLiveVarInfo::MethodLiveVarInfo(const Method *const M) : Meth(M) {
+ assert(!M->isExternal() && "Cannot be a prototype declaration");
HasAnalyzed = false; // still we haven't called analyze()
}
@@ -55,8 +55,6 @@ MethodLiveVarInfo:: ~MethodLiveVarInfo()
if( (*MI).first ) // delete all LiveVarSets in MInst2LVSetBI
delete (*MI).second;
}
-
-
}
diff --git a/lib/Target/SparcV9/LiveVar/ValueSet.cpp b/lib/Target/SparcV9/LiveVar/ValueSet.cpp
index 6806d1c563..d176d9e53c 100644
--- a/lib/Target/SparcV9/LiveVar/ValueSet.cpp
+++ b/lib/Target/SparcV9/LiveVar/ValueSet.cpp
@@ -1,11 +1,14 @@
#include "llvm/Analysis/LiveVar/ValueSet.h"
#include "llvm/ConstantVals.h"
-
+#include <iostream>
+using std::cerr;
+using std::endl;
+using std::pair;
+using std::hash_set;
void printValue( const Value *const v) // func to print a Value
{
-
if (v->hasName())
cerr << v << "(" << ((*v).getName()) << ") ";
else if (Constant *C = dyn_cast<Constant>(v))
@@ -16,17 +19,13 @@ void printValue( const Value *const v) // func to print a Value
//---------------- Method implementations --------------------------
-
-
-ValueSet:: ValueSet() : hash_set<const Value *, hashFuncValue> () { }
-
// for performing two set unions
bool ValueSet::setUnion( const ValueSet *const set1) {
const_iterator set1it;
pair<iterator, bool> result;
bool changed = false;
- for( set1it = set1->begin() ; set1it != set1->end(); set1it++) {
+ for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) {
// for all all elements in set1
result = insert( *set1it ); // insert to this set
if( result.second == true) changed = true;
@@ -41,7 +40,7 @@ void ValueSet::setDifference( const ValueSet *const set1,
const ValueSet *const set2) {
const_iterator set1it, set2it;
- for( set1it = set1->begin() ; set1it != set1->end(); set1it++) {
+ for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) {
// for all elements in set1
iterator set2it = set2->find( *set1it ); // find wether the elem is in set2
if( set2it == set2->end() ) // if the element is not in set2
@@ -53,7 +52,7 @@ void ValueSet::setDifference( const ValueSet *const set1,
// for performing set subtraction
void ValueSet::setSubtract( const ValueSet *const set1) {
const_iterator set1it;
- for( set1it = set1->begin() ; set1it != set1->end(); set1it++)
+ for( set1it = set1->begin() ; set1it != set1->end(); ++set1it)
// for all elements in set1
erase( *set1it ); // erase that element from this set
}
@@ -62,7 +61,5 @@ void ValueSet::setSubtract( const ValueSet *const set1) {
void ValueSet::printSet() const { // for printing a live variable set
- const_iterator it;
- for( it = begin() ; it != end(); it++)
- printValue( *it );
+ for_each(begin(), end(), printValue);
}
diff --git a/lib/Target/SparcV9/RegAlloc/IGNode.cpp b/lib/Target/SparcV9/RegAlloc/IGNode.cpp
index 4e66d9a762..a225742052 100644
--- a/lib/Target/SparcV9/RegAlloc/IGNode.cpp
+++ b/lib/Target/SparcV9/RegAlloc/IGNode.cpp
@@ -1,12 +1,13 @@
#include "llvm/CodeGen/IGNode.h"
-
+#include <algorithm>
+#include <iostream>
+using std::cerr;
//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
-IGNode::IGNode(LiveRange *const PLR, unsigned int Ind): Index(Ind),
- AdjList(),
- ParentLR(PLR)
+IGNode::IGNode(LiveRange *const PLR, unsigned int Ind) : Index(Ind),
+ ParentLR(PLR)
{
OnStack = false;
CurDegree = -1 ;
@@ -23,11 +24,12 @@ void IGNode::pushOnStack()
int neighs = AdjList.size();
if( neighs < 0) {
- cout << "\nAdj List size = " << neighs;
+ cerr << "\nAdj List size = " << neighs;
assert(0 && "Invalid adj list size");
}
- for(int i=0; i < neighs; i++) (AdjList[i])->decCurDegree();
+ for(int i=0; i < neighs; i++)
+ AdjList[i]->decCurDegree();
}
//-----------------------------------------------------------------------------
@@ -35,11 +37,9 @@ void IGNode::pushOnStack()
// two IGNodes together.
//-----------------------------------------------------------------------------
void IGNode::delAdjIGNode(const IGNode *const Node) {
- vector <IGNode *>::iterator It = AdjList.begin();
-
- // find Node
- for( ; It != AdjList.end() && (*It != Node); It++ ) ;
+ std::vector<IGNode *>::iterator It =
+ find(AdjList.begin(), AdjList.end(), Node);
assert( It != AdjList.end() ); // the node must be there
-
- AdjList.erase( It );
+
+ AdjList.erase(It);
}
diff --git a/lib/Target/SparcV9/RegAlloc/IGNode.h b/lib/Target/SparcV9/RegAlloc/IGNode.h
index 0f4cf9c82a..b89aea32b1 100644
--- a/lib/Target/SparcV9/RegAlloc/IGNode.h
+++ b/lib/Target/SparcV9/RegAlloc/IGNode.h
@@ -29,8 +29,6 @@
#include "llvm/CodeGen/RegAllocCommon.h"
#include "llvm/CodeGen/LiveRange.h"
-
-
//----------------------------------------------------------------------------
// Class IGNode
//
@@ -39,13 +37,11 @@
class IGNode
{
- private:
-
const int Index; // index within IGNodeList
bool OnStack; // this has been pushed on to stack for coloring
- vector<IGNode *> AdjList; // adjacency list for this live range
+ std::vector<IGNode *> AdjList; // adjacency list for this live range
int CurDegree;
//
@@ -54,7 +50,6 @@ class IGNode
// Decremented when a neighbor is pushed on to the stack.
// After that, never incremented/set again nor used.
-
LiveRange *const ParentLR; // parent LR (cannot be a const)
@@ -152,10 +147,4 @@ class IGNode
};
-
-
-
-
-
-
#endif
diff --git a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp
index e18c9a7a34..0de7275acf 100644
--- a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp
+++ b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp
@@ -1,4 +1,7 @@
#include "llvm/CodeGen/InterferenceGraph.h"
+#include "Support/STLExtras.h"
+#include <iostream>
+using std::cerr;
//-----------------------------------------------------------------------------
// Constructor: Records the RegClass and initalizes IGNodeList.
@@ -11,7 +14,7 @@ InterferenceGraph::InterferenceGraph(RegClass *const RC) : RegCl(RC),
IG = NULL;
Size = 0;
if( DEBUG_RA) {
- cout << "Interference graph created!" << endl;
+ cerr << "Interference graph created!\n";
}
}
@@ -22,19 +25,12 @@ InterferenceGraph::InterferenceGraph(RegClass *const RC) : RegCl(RC),
InterferenceGraph:: ~InterferenceGraph() {
// delete the matrix
- //
- if( IG )
- delete []IG;
+ for(unsigned int r=0; r < IGNodeList.size(); ++r)
+ delete[] IG[r];
+ delete[] IG;
// delete all IGNodes in the IGNodeList
- //
- vector<IGNode *>::const_iterator IGIt = IGNodeList.begin();
- for(unsigned i=0; i < IGNodeList.size() ; ++i) {
-
- const IGNode *const Node = IGNodeList[i];
- if( Node ) delete Node;
- }
-
+ for_each(IGNodeList.begin(), IGNodeList.end(), deleter<IGNode>);
}
@@ -46,13 +42,13 @@ InterferenceGraph:: ~InterferenceGraph() {
void InterferenceGraph::createGraph()
{
Size = IGNodeList.size();
- IG = (char **) new char *[Size];
+ IG = new char*[Size];
for( unsigned int r=0; r < Size; ++r)
IG[r] = new char[Size];
// init IG matrix
for(unsigned int i=0; i < Size; i++)
- for( unsigned int j=0; j < Size ; j++)
+ for(unsigned int j=0; j < Size; j++)
IG[i][j] = 0;
}
@@ -61,9 +57,7 @@ void InterferenceGraph::createGraph()
//-----------------------------------------------------------------------------
void InterferenceGraph::addLRToIG(LiveRange *const LR)
{
- IGNode *Node = new IGNode(LR, IGNodeList.size() );
- IGNodeList.push_back( Node );
-
+ IGNodeList.push_back(new IGNode(LR, IGNodeList.size()));
}
@@ -92,12 +86,11 @@ void InterferenceGraph::setInterference(const LiveRange *const LR1,
char *val;
if( DEBUG_RA > 1)
- cout << "setting intf for: [" << row << "][" << col << "]" << endl;
+ cerr << "setting intf for: [" << row << "][" << col << "]\n";
( row > col) ? val = &IG[row][col]: val = &IG[col][row];
if( ! (*val) ) { // if this interf is not previously set
-
*val = 1; // add edges between nodes
IGNode1->addAdjIGNode( IGNode2 );
IGNode2->addAdjIGNode( IGNode1 );
@@ -123,7 +116,10 @@ unsigned InterferenceGraph::getInterference(const LiveRange *const LR1,
const unsigned int col = LR2->getUserIGNode()->getIndex();
char ret;
- ( row > col) ? (ret = IG[row][col]) : (ret = IG[col][row]) ;
+ if (row > col)
+ ret = IG[row][col];
+ else
+ ret = IG[col][row];
return ret;
}
@@ -148,9 +144,9 @@ void InterferenceGraph::mergeIGNodesOfLRs(const LiveRange *const LR1,
assertIGNode( SrcNode );
if( DEBUG_RA > 1) {
- cout << "Merging LRs: \""; LR1->printSet();
- cout << "\" and \""; LR2->printSet();
- cout << "\"" << endl;
+ cerr << "Merging LRs: \""; LR1->printSet();
+ cerr << "\" and \""; LR2->printSet();
+ cerr << "\"\n";
}
unsigned SrcDegree = SrcNode->getNumOfNeighbors();
@@ -217,17 +213,16 @@ void InterferenceGraph::printIG() const
for(unsigned int i=0; i < Size; i++) {
const IGNode *const Node = IGNodeList[i];
- if( ! Node )
- continue; // skip empty rows
-
- cout << " [" << i << "] ";
+ if(Node) {
+ cerr << " [" << i << "] ";
- for( unsigned int j=0; j < Size; j++) {
- if( j >= i) break;
- if( IG[i][j] ) cout << "(" << i << "," << j << ") ";
+ for( unsigned int j=0; j < i; j++) {
+ if(IG[i][j])
+ cerr << "(" << i << "," << j << ") ";
}
- cout << endl;
+ cerr << "\n";
}
+ }
}
//----------------------------------------------------------------------------
@@ -235,21 +230,14 @@ void InterferenceGraph::printIG() const
//----------------------------------------------------------------------------
void InterferenceGraph::printIGNodeList() const
{
- vector<IGNode *>::const_iterator IGIt = IGNodeList.begin(); // hash map iter
-
for(unsigned i=0; i < IGNodeList.size() ; ++i) {
-
const IGNode *const Node = IGNodeList[i];
- if( ! Node )
- continue;
-
- cout << " [" << Node->getIndex() << "] ";
- (Node->getParentLR())->printSet();
- //int Deg = Node->getCurDegree();
- cout << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">" << endl;
-
+ if (Node) {
+ cerr << " [" << Node->getIndex() << "] ";
+ Node->getParentLR()->printSet();
+ //int Deg = Node->getCurDegree();
+ cerr << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">\n";
+ }
}
}
-
-
diff --git a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.h b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.h
index 99dea8fbe0..408bee4558 100644
--- a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.h
+++ b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.h
@@ -1,4 +1,4 @@
-/* Title: InterferenceGraph.h
+/* Title: InterferenceGraph.h -*- C++ -*-
Author: Ruchira Sasanka
Date: July 20, 01
Purpose: Interference Graph used for register coloring.
@@ -24,7 +24,7 @@
#include "llvm/CodeGen/IGNode.h"
-typedef vector <IGNode *> IGNodeListType;
+typedef std::vector <IGNode *> IGNodeListType;
class InterferenceGraph
@@ -47,6 +47,8 @@ class InterferenceGraph
// to create it after adding all IGNodes to the IGNodeList
InterferenceGraph(RegClass *const RC);
+ ~InterferenceGraph();
+
void createGraph();
void addLRToIG(LiveRange *const LR);
@@ -65,12 +67,6 @@ class InterferenceGraph
void printIG() const;
void printIGNodeList() const;
-
- ~InterferenceGraph();
-
-
};
-
#endif
-
diff --git a/lib/Target/SparcV9/RegAlloc/LiveRange.h b/lib/Target/SparcV9/RegAlloc/LiveRange.h
index 778e070046..8034751da9 100644
--- a/lib/Target/SparcV9/RegAlloc/LiveRange.h
+++ b/lib/Target/SparcV9/RegAlloc/LiveRange.h
@@ -1,4 +1,4 @@
-/* Title: LiveRange.h
+/* Title: LiveRange.h -*- C++ -*-
Author: Ruchira Sasanka
Date: July 25, 01
Purpose: To keep info about a live range.
@@ -13,6 +13,7 @@
#include "llvm/Analysis/LiveVar/ValueSet.h"
#include "llvm/Type.h"
+#include <iostream>
class RegClass;
class IGNode;
@@ -176,7 +177,7 @@ class LiveRange : public ValueSet
if(SuggestedColor == -1 )
SuggestedColor = Col;
else if (DEBUG_RA)
- cerr << "Already has a suggested color " << Col << endl;
+ std::cerr << "Already has a suggested color " << Col << "\n";
}
inline unsigned getSuggestedColor() const {
diff --git a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp
index 7fb688f55e..b66e6ef308 100644
--- a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp
+++ b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp
@@ -1,15 +1,15 @@
#include "llvm/CodeGen/LiveRangeInfo.h"
+#include <iostream>
+using std::cerr;
//---------------------------------------------------------------------------
// Constructor
//---------------------------------------------------------------------------
LiveRangeInfo::LiveRangeInfo(const Method *const M,
const TargetMachine& tm,
- vector<RegClass *> &RCL)
- : Meth(M), LiveRangeMap(),
- TM(tm), RegClassList(RCL),
- MRI( tm.getRegInfo()),
- CallRetInstrList()
+ std::vector<RegClass *> &RCL)
+ : Meth(M), LiveRangeMap(), TM(tm),
+ RegClassList(RCL), MRI(tm.getRegInfo())
{ }
@@ -17,33 +17,25 @@ LiveRangeInfo::LiveRangeInfo(const Method *const M,
// Destructor: Deletes all LiveRanges in the LiveRangeMap
//---------------------------------------------------------------------------
LiveRangeInfo::~LiveRangeInfo() {
-
LiveRangeMapType::iterator MI = LiveRangeMap.begin();
for( ; MI != LiveRangeMap.end() ; ++MI) {
- if( (*MI).first ) {
-
- LiveRange *LR = (*MI).second;
-
- if( LR ) {
-
- // we need to be careful in deleting LiveRanges in LiveRangeMap
- // since two/more Values in the live range map can point to the same
- // live range. We have to make the other entries NULL when we delete
- // a live range.
-
- LiveRange::iterator LI = LR->begin();
-
- for( ; LI != LR->end() ; ++LI) {
- LiveRangeMap[*LI] = NULL;
- }
+ if (MI->first && MI->second) {
+ LiveRange *LR = MI->second;
- delete LR;
+ // we need to be careful in deleting LiveRanges in LiveRangeMap
+ // since two/more Values in the live range map can point to the same
+ // live range. We have to make the other entries NULL when we delete
+ // a live range.
- }
+ LiveRange::iterator LI = LR->begin();
+
+ for( ; LI != LR->end() ; ++LI)
+ LiveRangeMap[*LI] = 0;
+
+ delete LR;
}
}
-
}
@@ -82,7 +74,7 @@ void LiveRangeInfo::unionAndUpdateLRs(LiveRange *const L1, LiveRange *L2)
L1->addSpillCost( L2->getSpillCost() ); // add the spill costs
- delete ( L2 ); // delete L2 as it is no longer needed
+ delete L2; // delete L2 as it is no longer needed
}
@@ -96,7 +88,7 @@ void LiveRangeInfo::constructLiveRanges()
{
if( DEBUG_RA)
- cout << "Consturcting Live Ranges ..." << endl;
+ cerr << "Consturcting Live Ranges ...\n";
// first find the live ranges for all incoming args of the method since
// those LRs start from the start of the method
@@ -108,14 +100,13 @@ void LiveRangeInfo::constructLiveRanges()
for( ; ArgIt != ArgList.end() ; ++ArgIt) { // for each argument
-
LiveRange * ArgRange = new LiveRange(); // creates a new LR and
const Value *const Val = (const Value *) *ArgIt;
assert( Val);
- ArgRange->add( Val ); // add the arg (def) to it
- LiveRangeMap[ Val ] = ArgRange;
+ ArgRange->add(Val); // add the arg (def) to it
+ LiveRangeMap[Val] = ArgRange;
// create a temp machine op to find the register class of value
//const MachineOperand Op(MachineOperand::MO_VirtualRegister);
@@ -125,8 +116,8 @@ void LiveRangeInfo::constructLiveRanges()
if( DEBUG_RA > 1) {
- cout << " adding LiveRange for argument ";
- printValue( (const Value *) *ArgIt); cout << endl;
+ cerr << " adding LiveRange for argument ";
+ printValue((const Value *) *ArgIt); cerr << "\n";
}
}
@@ -140,7 +131,6 @@ void LiveRangeInfo::constructLiveRanges()
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
-
for( ; BBI != Meth->end(); ++BBI) { // go thru BBs in random order
// Now find all LRs for machine the instructions. A new LR will be created
@@ -150,8 +140,7 @@ void LiveRangeInfo::constructLiveRanges()
// get the iterator for machine instructions
const MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
- MachineCodeForBasicBlock::const_iterator
- MInstIterator = MIVec.begin();
+ MachineCodeForBasicBlock::const_iterator MInstIterator = MIVec.begin();
// iterate over all the machine instructions in BB
for( ; MInstIterator != MIVec.end(); MInstIterator++) {
@@ -161,53 +150,46 @@ void LiveRangeInfo::constructLiveRanges()
// Now if the machine instruction is a call/return instruction,
// add it to CallRetInstrList for processing its implicit operands
- if( (TM.getInstrInfo()).isReturn( MInst->getOpCode()) ||
- (TM.getInstrInfo()).isCall( MInst->getOpCode()) )
+ if(TM.getInstrInfo().isReturn(MInst->getOpCode()) ||
+ TM.getInstrInfo().isCall(MInst->getOpCode()))
CallRetInstrList.push_back( MInst );
// iterate over MI operands to find defs
- for( MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done(); ++OpI) {
-
- if( DEBUG_RA) {
+ for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) {
+ if(DEBUG_RA) {
MachineOperand::MachineOperandType OpTyp =
OpI.getMachineOperand().getOperandType();
- if ( OpTyp == MachineOperand::MO_CCRegister) {
- cout << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:";
+ if (OpTyp == MachineOperand::MO_CCRegister) {
+ cerr << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:";
printValue( OpI.getMachineOperand().getVRegValue() );
- cout << endl;
+ cerr << "\n";
}
}
// create a new LR iff this operand is a def
if( OpI.isDef() ) {
-
const Value *const Def = *OpI;
-
// Only instruction values are accepted for live ranges here
-
if( Def->getValueType() != Value::InstructionVal ) {
- cout << "\n**%%Error: Def is not an instruction val. Def=";
- printValue( Def ); cout << endl;
+ cerr << "\n**%%Error: Def is not an instruction val. Def=";
+ printValue( Def ); cerr << "\n";
continue;
}
-
LiveRange *DefRange = LiveRangeMap[Def];
// see LR already there (because of multiple defs)
-
if( !DefRange) { // if it is not in LiveRangeMap
-
DefRange = new LiveRange(); // creates a new live range and
DefRange->add( Def ); // add the instruction (def) to it
LiveRangeMap[ Def ] = DefRange; // update the map
if( DEBUG_RA > 1) {
- cout << " creating a LR for def: ";
- printValue(Def); cout << endl;
+ cerr << " creating a LR for def: ";
+ printValue(Def); cerr << "\n";
}
// set the register class of the new live range
@@ -221,7 +203,7 @@ void LiveRangeInfo::constructLiveRanges()
if(isCC && DEBUG_RA) {
- cout << "\a**created a LR for a CC reg:";
+ cerr << "\a**created a LR for a CC reg:";
printValue( OpI.getMachineOperand().getVRegValue() );
}
@@ -235,8 +217,8 @@ void LiveRangeInfo::constructLiveRanges()
LiveRangeMap[ Def ] = DefRange;
if( DEBUG_RA > 1) {
- cout << " added to an existing LR for def: ";
- printValue( Def ); cout << endl;
+ cerr << " added to an existing LR for def: ";
+ printValue( Def ); cerr << "\n";
}
}
@@ -256,7 +238,7 @@ void LiveRangeInfo::constructLiveRanges()
suggestRegs4CallRets();
if( DEBUG_RA)
- cout << "Initial Live Ranges constructed!" << endl;
+ cerr << "Initial Live Ranges constructed!\n";
}
@@ -312,11 +294,8 @@ void LiveRangeInfo::suggestRegs4CallRets()
//---------------------------------------------------------------------------
void LiveRangeInfo::coalesceLRs()
{
-
-
-
if( DEBUG_RA)
- cout << endl << "Coalscing LRs ..." << endl;
+ cerr << "\nCoalscing LRs ...\n";
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
@@ -324,8 +303,7 @@ void LiveRangeInfo::coalesceLRs()
// get the iterator for machine instructions
const MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
- MachineCodeForBasicBlock::const_iterator
- MInstIterator = MIVec.begin();
+ MachineCodeForBasicBlock::const_iterator MInstIterator = MIVec.begin();
// iterate over all the machine instructions in BB
for( ; MInstIterator != MIVec.end(); ++MInstIterator) {
@@ -333,9 +311,9 @@ void LiveRangeInfo::coalesceLRs()
const MachineInstr * MInst = *MInstIterator;
if( DEBUG_RA > 1) {
- cout << " *Iterating over machine instr ";
+ cerr << " *Iterating over machine instr ";
MInst->dump();
- cout << endl;
+ cerr << "\n";
}
@@ -357,8 +335,8 @@ void LiveRangeInfo::coalesceLRs()
//don't warn about labels
if (!((*UseI)->getType())->isLabelType() && DEBUG_RA) {
- cout<<" !! Warning: No LR for use "; printValue(*UseI);
- cout << endl;
+ cerr<<" !! Warning: No LR for use "; printValue(*UseI);
+ cerr << "\n";
}
continue; // ignore and continue
}
@@ -407,7 +385,7 @@ void LiveRangeInfo::coalesceLRs()
} // for all BBs
if( DEBUG_RA)
- cout << endl << "Coalscing Done!" << endl;
+ cerr << "\nCoalscing Done!\n";
}
@@ -421,11 +399,11 @@ void LiveRangeInfo::coalesceLRs()
void LiveRangeInfo::printLiveRanges()
{
LiveRangeMapType::iterator HMI = LiveRangeMap.begin(); // hash map iterator
- cout << endl << "Printing Live Ranges from Hash Map:" << endl;
- for( ; HMI != LiveRangeMap.end() ; HMI ++ ) {
- if( (*HMI).first && (*HMI).second ) {
- cout <<" "; printValue((*HMI).first); cout << "\t: ";
- ((*HMI).second)->printSet(); cout << endl;
+ cerr << "\nPrinting Live Ranges from Hash Map:\n";
+ for( ; HMI != LiveRangeMap.end() ; ++HMI) {
+ if( HMI->first && HMI->second ) {
+ cerr <<" "; printValue((*HMI).first); cerr << "\t: ";
+ HMI->second->printSet(); cerr << "\n";
}
}
}
diff --git a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h
index 1eee1aea5e..9e7ef06fe2 100644
--- a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h
+++ b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h
@@ -1,4 +1,4 @@
-/* Title: LiveRangeInfo.h
+/* Title: LiveRangeInfo.h -*- C++ -*-
Author: Ruchira Sasanka
Date: Jun 30, 01
Purpose:
@@ -34,8 +34,8 @@
#include "llvm/CodeGen/RegClass.h"
-typedef hash_map <const Value *, LiveRange *, hashFuncValue> LiveRangeMapType;
-typedef vector <const MachineInstr *> CallRetInstrListType;
+typedef std::hash_map<const Value*, LiveRange*> LiveRangeMapType;
+typedef std::vector<const MachineInstr*> CallRetInstrListType;
@@ -59,7 +59,7 @@ private:
const TargetMachine& TM; // target machine description
- vector<RegClass *> & RegClassList;// a vector containing register classess
+ std::vector<RegClass *> & RegClassList;// vector containing register classess
const MachineRegInfo& MRI; // machine reg info
@@ -82,7 +82,7 @@ public:
LiveRangeInfo(const Method *const M,
const TargetMachine& tm,
- vector<RegClass *> & RCList);
+ std::vector<RegClass *> & RCList);
// Destructor to destroy all LiveRanges in the LiveRange Map
diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
index 7d6fbb7cc9..e2d455bad9 100644
--- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
+++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
@@ -14,7 +14,9 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/MachineFrameInfo.h"
+#include <iostream>
#include <math.h>
+using std::cerr;
// ***TODO: There are several places we add instructions. Validate the order
@@ -35,18 +37,16 @@ cl::Enum<RegAllocDebugLevel_t> DEBUG_RA("dregalloc", cl::NoFlags,
PhyRegAlloc::PhyRegAlloc(Method *M,
const TargetMachine& tm,
MethodLiveVarInfo *const Lvi)
- : RegClassList(),
- TM(tm),
- Meth(M),
+ : TM(tm), Meth(M),
mcInfo(MachineCodeForMethod::get(M)),
LVI(Lvi), LRI(M, tm, RegClassList),
MRI( tm.getRegInfo() ),
NumOfRegClasses(MRI.getNumOfRegClasses()),
- AddedInstrMap(), LoopDepthCalc(M), ResColList() {
+ LoopDepthCalc(M) {
// create each RegisterClass and put in RegClassList
//
- for( unsigned int rc=0; rc < NumOfRegClasses; rc++)
+ for(unsigned int rc=0; rc < NumOfRegClasses; rc++)
RegClassList.push_back( new RegClass(M, MRI.getMachineRegClass(rc),
&ResColList) );
}
@@ -69,7 +69,7 @@ PhyRegAlloc::~PhyRegAlloc() {
//----------------------------------------------------------------------------
void PhyRegAlloc::createIGNodeListsAndIGs()
{
- if(DEBUG_RA ) cout << "Creating LR lists ..." << endl;
+ if(DEBUG_RA ) cerr << "Creating LR lists ...\n";
// hash map iterator
LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin();
@@ -85,8 +85,8 @@ void PhyRegAlloc::createIGNodeListsAndIGs()
if( !L) {
if( DEBUG_RA) {
- cout << "\n*?!?Warning: Null liver range found for: ";
- printValue( (*HMI).first) ; cout << endl;
+ cerr << "\n*?!?Warning: Null liver range found for: ";
+ printValue(HMI->first); cerr << "\n";
}
continue;
}
@@ -108,7 +108,7 @@ void PhyRegAlloc::createIGNodeListsAndIGs()
RegClassList[ rc ]->createInterferenceGraph();
if( DEBUG_RA)
- cout << "LRLists Created!" << endl;
+ cerr << "LRLists Created!\n";
}
@@ -140,8 +140,8 @@ void PhyRegAlloc::addInterference(const Value *const Def,
for( ; LIt != LVSet->end(); ++LIt) {
if( DEBUG_RA > 1) {
- cout << "< Def="; printValue(Def);
- cout << ", Lvar="; printValue( *LIt); cout << "> ";
+ cerr << "< Def="; printValue(Def);
+ cerr << ", Lvar="; printValue( *LIt); cerr << "> ";
}
// get the live range corresponding to live var
@@ -166,8 +166,8 @@ void PhyRegAlloc::addInterference(const Value *const Def,
else if(DEBUG_RA > 1) {
// we will not have LRs for values not explicitly allocated in the
// instruction stream (e.g., constants)
- cout << " warning: no live range for " ;
- printValue( *LIt); cout << endl; }
+ cerr << " warning: no live range for " ;
+ printValue(*LIt); cerr << "\n"; }
}
@@ -203,7 +203,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst,
}
if( DEBUG_RA)
- cout << "\n For call inst: " << *MInst;
+ cerr << "\n For call inst: " << *MInst;
LiveVarSet::const_iterator LIt = LVSetAft->begin();
@@ -216,7 +216,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst,
LiveRange *const LR = LRI.getLiveRangeForValue(*LIt );
if( LR && DEBUG_RA) {
- cout << "\n\tLR Aft Call: ";
+ cerr << "\n\tLR Aft Call: ";
LR->printSet();
}
@@ -227,7 +227,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst,
if( LR && (LR != RetValLR) ) {
LR->setCallInterference();
if( DEBUG_RA) {
- cout << "\n ++Added call interf for LR: " ;
+ cerr << "\n ++Added call interf for LR: " ;
LR->printSet();
}
}
@@ -247,7 +247,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst,
void PhyRegAlloc::buildInterferenceGraphs()
{
- if(DEBUG_RA) cout << "Creating interference graphs ..." << endl;
+ if(DEBUG_RA) cerr << "Creating interference graphs ...\n";
unsigned BBLoopDepthCost;
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
@@ -333,7 +333,7 @@ void PhyRegAlloc::buildInterferenceGraphs()
addInterferencesForArgs();
if( DEBUG_RA)
- cout << "Interference graphs calculted!" << endl;
+ cerr << "Interference graphs calculted!\n";
}
@@ -411,8 +411,8 @@ void PhyRegAlloc::addInterferencesForArgs()
addInterference( *ArgIt, InSet, false ); // add interferences between
// args and LVars at start
if( DEBUG_RA > 1) {
- cout << " - %% adding interference for argument ";
- printValue( (const Value *) *ArgIt); cout << endl;
+ cerr << " - %% adding interference for argument ";
+ printValue((const Value *)*ArgIt); cerr << "\n";
}
}
}
@@ -510,7 +510,7 @@ void PhyRegAlloc::updateMachineCode()
// delete this condition checking later (must assert if Val is null)
if( !Val) {
if (DEBUG_RA)
- cout << "Warning: NULL Value found for operand" << endl;
+ cerr << "Warning: NULL Value found for operand\n";
continue;
}
assert( Val && "Value is NULL");
@@ -522,9 +522,9 @@ void PhyRegAlloc::updateMachineCode()
// nothing to worry if it's a const or a label
if (DEBUG_RA) {
- cout << "*NO LR for operand : " << Op ;
- cout << " [reg:" << Op.getAllocatedRegNum() << "]";
- cout << " in inst:\t" << *MInst << endl;
+ cerr << "*NO LR for operand : " << Op ;
+ cerr << " [reg:" << Op.getAllocatedRegNum() << "]";
+ cerr << " in inst:\t" << *MInst << "\n";
}
// if register is not allocated, mark register as invalid
@@ -563,18 +563,16 @@ void PhyRegAlloc::updateMachineCode()
// instruction, add them now.
//
if( AddedInstrMap[ MInst ] ) {
-
- deque<MachineInstr *> &IBef = (AddedInstrMap[MInst])->InstrnsBefore;
+ std::deque<MachineInstr *> &IBef = AddedInstrMap[MInst]->InstrnsBefore;
if( ! IBef.empty() ) {
-
- deque<MachineInstr *>::iterator AdIt;
+ std::deque<MachineInstr *>::iterator AdIt;
for( AdIt = IBef.begin(); AdIt != IBef.end() ; ++AdIt ) {
if( DEBUG_RA) {
cerr << "For inst " << *MInst;
- cerr << " PREPENDed instr: " << **AdIt << endl;
+ cerr << " PREPENDed instr: " << **AdIt << "\n";
}
MInstIterator = MIVec.insert( MInstIterator, *AdIt );
@@ -600,7 +598,7 @@ void PhyRegAlloc::updateMachineCode()
if((delay=TM.getInstrInfo().getNumDelaySlots(MInst->getOpCode())) >0){
move2DelayedInstr(MInst, *(MInstIterator+delay) );
- if(DEBUG_RA) cout<< "\nMoved an added instr after the delay slot";
+ if(DEBUG_RA) cerr<< "\nMoved an added instr after the delay slot";
}
else {
@@ -609,11 +607,11 @@ void PhyRegAlloc::updateMachineCode()
// Here we can add the "instructions after" to the current
// instruction since there are no delay slots for this instruction
- deque<MachineInstr *> &IAft = (AddedInstrMap[MInst])->InstrnsAfter;
+ std::deque<MachineInstr *> &IAft = AddedInstrMap[MInst]->InstrnsAfter;
if( ! IAft.empty() ) {
- deque<MachineInstr *>::iterator AdIt;
+ std::deque<MachineInstr *>::iterator AdIt;
++MInstIterator; // advance to the next instruction
@@ -621,7 +619,7 @@ void PhyRegAlloc::updateMachineCode()
if(DEBUG_RA) {
cerr << "For inst " << *MInst;
- cerr << " APPENDed instr: " << **AdIt << endl;
+ cerr << " APPENDed instr: " << **AdIt << "\n";
}
MInstIterator = MIVec.insert( MInstIterator, *AdIt );
@@ -669,9 +667,7 @@ void PhyRegAlloc::insertCode4SpilledLR(const LiveRange *LR,
RegClass *RC = LR->getRegClass();
const LiveVarSet *LVSetBef = LVI->getLiveVarSetBeforeMInst(MInst, BB);
-
- int TmpOff =
- mcInfo.pushTempValue(TM, MRI.getSpilledRegSize(RegType) );
+ mcInfo.pushTempValue(TM, MRI.getSpilledRegSize(RegType) );
MachineInstr *MIBef=NULL, *AdIMid=NULL, *MIAft=NULL;
@@ -854,13 +850,10 @@ int PhyRegAlloc::getUniRegNotUsedByThisInst(RegClass *RC,
return MRI.getUnifiedRegNum(RC->getID(), c);
else
assert( 0 && "FATAL: No free register could be found in reg class!!");
-
+ return 0;
}
-
-
-
//----------------------------------------------------------------------------
// This method modifies the IsColorUsedArr of the register class passed to it.
// It sets the bits corresponding to the registers used by this machine
@@ -909,14 +902,10 @@ void PhyRegAlloc::setRelRegsUsedByThisInst(RegClass *RC,
LiveRange *const LRofImpRef =
LRI.getLiveRangeForValue( MInst->getImplicitRef(z) );
-
- if( LRofImpRef )
- if( LRofImpRef->hasColor() )
- IsColorUsedArr[ LRofImpRef->getColor() ] = true;
+
+ if(LRofImpRef && LRofImpRef->hasColor())
+ IsColorUsedArr[LRofImpRef->getColor()] = true;
}
-
-
-
}
@@ -936,9 +925,8 @@ void PhyRegAlloc::setRelRegsUsedByThisInst(RegClass *RC,
void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI,
const MachineInstr *DelayedMI) {
-
// "added after" instructions of the original instr
- deque<MachineInstr *> &OrigAft = (AddedInstrMap[OrigMI])->InstrnsAfter;
+ std::deque<MachineInstr *> &OrigAft = AddedInstrMap[OrigMI]->InstrnsAfter;
// "added instructions" of the delayed instr
AddedInstrns *DelayAdI = AddedInstrMap[DelayedMI];
@@ -949,21 +937,15 @@ void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI,
}
// "added after" instructions of the delayed instr
- deque<MachineInstr *> &DelayedAft = DelayAdI->InstrnsAfter;
+ std::deque<MachineInstr *> &DelayedAft = DelayAdI->InstrnsAfter;
// go thru all the "added after instructions" of the original instruction
// and append them to the "addded after instructions" of the delayed
// instructions
-
- deque<MachineInstr *>::iterator OrigAdIt;
-
- for( OrigAdIt = OrigAft.begin(); OrigAdIt != OrigAft.end() ; ++OrigAdIt ) {
- DelayedAft.push_back( *OrigAdIt );
- }
+ DelayedAft.insert(DelayedAft.end(), OrigAft.begin(), OrigAft.end());
// empty the "added after instructions" of the original instruction
OrigAft.clear();
-
}
//----------------------------------------------------------------------------
@@ -973,14 +955,14 @@ void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI,
void PhyRegAlloc::printMachineCode()
{
- cout << endl << ";************** Method ";
- cout << Meth->getName() << " *****************" << endl;
+ cerr << "\n;************** Method " << Meth->getName()
+ << " *****************\n";
Method::const_iterator BBI = Meth->begin(); // random iterator for BBs
for( ; BBI != Meth->end(); ++BBI) { // traverse BBs in random order
- cout << endl ; printLabel( *BBI); cout << ": ";
+ cerr << "\n"; printLabel( *BBI); cerr << ": ";
// get the iterator for machine instructions
MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
@@ -992,8 +974,8 @@ void PhyRegAlloc::printMachineCode()
MachineInstr *const MInst = *MInstIterator;
- cout << endl << "\t";
- cout << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
+ cerr << "\n\t";
+ cerr << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
//for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) {
@@ -1009,41 +991,39 @@ void PhyRegAlloc::printMachineCode()
const Value *const Val = Op.getVRegValue () ;
// ****this code is temporary till NULL Values are fixed
if( ! Val ) {
- cout << "\t<*NULL*>";
+ cerr << "\t<*NULL*>";
continue;
}
// if a label or a constant
- if( (Val->getValueType() == Value::BasicBlockVal) ) {
-
- cout << "\t"; printLabel( Op.getVRegValue () );
- }
- else {
+ if(isa<BasicBlock>(Val) {
+ cerr << "\t"; printLabel( Op.getVRegValue () );
+ } else {
// else it must be a register value
const int RegNum = Op.getAllocatedRegNum();
- cout << "\t" << "%" << MRI.getUnifiedRegName( RegNum );
+ cerr << "\t" << "%" << MRI.getUnifiedRegName( RegNum );
if (Val->hasName() )
- cout << "(" << Val->getName() << ")";
+ cerr << "(" << Val->getName() << ")";
else
- cout << "(" << Val << ")";
+ cerr << "(" << Val << ")";
if( Op.opIsDef() )
- cout << "*";
+ cerr << "*";
const LiveRange *LROfVal = LRI.getLiveRangeForValue(Val);
if( LROfVal )
if( LROfVal->hasSpillOffset() )
- cout << "$";
+ cerr << "$";
}
}
else if(Op.getOperandType() == MachineOperand::MO_MachineRegister) {
- cout << "\t" << "%" << MRI.getUnifiedRegName(Op.getMachineRegNum());
+ cerr << "\t" << "%" << MRI.getUnifiedRegName(Op.getMachineRegNum());
}
else
- cout << "\t" << Op; // use dump field
+ cerr << "\t" << Op; // use dump field
}
@@ -1051,23 +1031,22 @@ void PhyRegAlloc::printMachineCode()
unsigned NumOfImpRefs = MInst->getNumImplicitRefs();
if( NumOfImpRefs > 0 ) {
- cout << "\tImplicit:";
+ cerr << "\tImplicit:";
for(unsigned z=0; z < NumOfImpRefs; z++) {
printValue( MInst->getImplicitRef(z) );
- cout << "\t";
+ cerr << "\t";
}
}
} // for all machine instructions
-
- cout << endl;
+ cerr << "\n";
} // for all BBs
- cout << endl;
+ cerr << "\n";
}
@@ -1125,9 +1104,9 @@ void PhyRegAlloc::colorIncomingArgs()
assert( FirstMI && "No machine instruction in entry BB");
AddedInstrns *AI = AddedInstrMap[ FirstMI ];
- if ( !AI ) {
+ if (!AI) {
AI = new AddedInstrns();
- AddedInstrMap[ FirstMI ] = AI;
+ AddedInstrMap[FirstMI] = AI;
}
MRI.colorMethodArgs(Meth, LRI, AI );
@@ -1137,12 +1116,11 @@ void PhyRegAlloc::colorIncomingArgs()
//----------------------------------------------------------------------------
// Used to generate a label for a basic block
//----------------------------------------------------------------------------
-void PhyRegAlloc::printLabel(const Value *const Val)
-{
- if( Val->hasName() )
- cout << Val->getName();
+void PhyRegAlloc::printLabel(const Value *const Val) {
+ if (Val->hasName())
+ cerr << Val->getName();
else
- cout << "Label" << Val;
+ cerr << "Label" << Val;
}
@@ -1155,7 +1133,7 @@ void PhyRegAlloc::printLabel(const Value *const Val)
void PhyRegAlloc::markUnusableSugColors()
{
- if(DEBUG_RA ) cout << "\nmarking unusable suggested colors ..." << endl;
+ if(DEBUG_RA ) cerr << "\nmarking unusable suggested colors ...\n";
// hash map iterator
LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin();
@@ -1193,22 +1171,18 @@ void PhyRegAlloc::markUnusableSugColors()
void PhyRegAlloc::allocateStackSpace4SpilledLRs()
{
- if(DEBUG_RA ) cout << "\nsetting LR stack offsets ..." << endl;
+ if(DEBUG_RA ) cerr << "\nsetting LR stack offsets ...\n";
// hash map iterator
LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin();
LiveRangeMapType::const_iterator HMIEnd = (LRI.getLiveRangeMap())->end();
for( ; HMI != HMIEnd ; ++HMI ) {
- if( (*HMI).first ) {
- LiveRange *L = (*HMI).second; // get the LiveRange
- if(L)
- if( ! L->hasColor() )
-
- // NOTE: ** allocating the size of long Type **
- L->setSpillOffFromFP(mcInfo.allocateSpilledValue(TM,
- Type::LongTy));
-
+ if(HMI->first && HMI->second) {
+ LiveRange *L = HMI->second; // get the LiveRange
+ if( ! L->hasColor() )
+ // NOTE: ** allocating the size of long Type **
+ L->setSpillOffFromFP(mcInfo.allocateSpilledValue(TM, Type::LongTy));
}
} // for all LR's in hash map
}
diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h
index 9d34557b01..6871b2d28a 100644
--- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h
+++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h
@@ -1,4 +1,4 @@
-/* Title: PhyRegAlloc.h
+/* Title: PhyRegAlloc.h -*- C++ -*-
Author: Ruchira Sasanka
Date: Aug 20, 01
Purpose: This is the main entry point for register allocation.
@@ -54,13 +54,11 @@
class AddedInstrns
{
public:
- deque<MachineInstr *> InstrnsBefore; // Added insts BEFORE an existing inst
- deque<MachineInstr *> InstrnsAfter; // Added insts AFTER an existing inst
-
- AddedInstrns() : InstrnsBefore(), InstrnsAfter() { }
+ std::deque<MachineInstr*> InstrnsBefore;// Added insts BEFORE an existing inst
+ std::deque<MachineInstr*> InstrnsAfter; // Added insts AFTER an existing inst
};
-typedef hash_map<const MachineInstr *, AddedInstrns *> AddedInstrMapType;
+typedef std::hash_map<const MachineInstr *, AddedInstrns *> AddedInstrMapType;
@@ -74,7 +72,7 @@ typedef hash_map<const MachineInstr *, AddedInstrns *> AddedInstrMapType;
class PhyRegAlloc: public NonCopyable
{
- vector<RegClass *> RegClassList ; // vector of register classes
+ std::vector<RegClass *> RegClassList; // vector of register classes
const TargetMachine &TM; // target machine
const Method* Meth; // name of the method we work on
MachineCodeForMethod& mcInfo; // descriptor for method's native code
@@ -115,8 +113,7 @@ class PhyRegAlloc: public NonCopyable
const BasicBlock *BB,
const unsigned OpNum);
- inline void constructLiveRanges()
- { LRI.constructLiveRanges(); }
+ inline void constructLiveRanges() { LRI.constructLiveRanges(); }
void colorIncomingArgs();
void colorCallRetArgs();
@@ -141,12 +138,9 @@ class PhyRegAlloc: public NonCopyable
void addInterf4PseudoInstr(const MachineInstr *MInst);
-
public:
-
PhyRegAlloc(Method *const M, const TargetMachine& TM,
MethodLiveVarInfo *const Lvi);
-
~PhyRegAlloc();
// main method called for allocating registers
diff --git a/lib/Target/SparcV9/RegAlloc/RegClass.cpp b/lib/Target/SparcV9/RegAlloc/RegClass.cpp
index 3918871d69..8ba6a15ad1 100644
--- a/lib/Target/SparcV9/RegAlloc/RegClass.cpp
+++ b/lib/Target/SparcV9/RegAlloc/RegClass.cpp
@@ -1,5 +1,6 @@
#include "llvm/CodeGen/RegClass.h"
-
+#include <iostream>
+using std::cerr;
//----------------------------------------------------------------------------
// This constructor inits IG. The actual matrix is created by a call to
@@ -11,7 +12,7 @@ RegClass::RegClass(const Method *const M,
: Meth(M), MRC(Mrc), RegClassID( Mrc->getRegClassID() ),
IG(this), IGNodeStack(), ReservedColorList(RCL) {
if( DEBUG_RA)
- cout << "Created Reg Class: " << RegClassID << endl;
+ cerr << "Created Reg Class: " << RegClassID << "\n";
IsColorUsedArr = new bool[ Mrc->getNumOfAllRegs() ];
}
@@ -23,7 +24,7 @@ RegClass::RegClass(const Method *const M,
//----------------------------------------------------------------------------
void RegClass::colorAllRegs()
{
- if(DEBUG_RA) cout << "Coloring IG of reg class " << RegClassID << " ...\n";
+ if(DEBUG_RA) cerr << "Coloring IG of reg class " << RegClassID << " ...\n";
// pre-color IGNodes
pushAllIGNodes(); // push all IG Nodes
@@ -57,9 +58,9 @@ void RegClass::pushAllIGNodes()
bool PushedAll = pushUnconstrainedIGNodes();
if( DEBUG_RA) {
- cout << " Puhsed all-unconstrained IGNodes. ";
- if( PushedAll ) cout << " No constrained nodes left.";
- cout << endl;
+ cerr << " Puhsed all-unconstrained IGNodes. ";
+ if( PushedAll ) cerr << " No constrained nodes left.";
+ cerr << "\n";
}
if( PushedAll ) // if NO constrained nodes left
@@ -129,8 +130,8 @@ bool RegClass::pushUnconstrainedIGNodes()
IGNode->pushOnStack(); // set OnStack and dec deg of neighs
if (DEBUG_RA > 1) {
- cout << " pushed un-constrained IGNode " << IGNode->getIndex() ;
- cout << " on to stack" << endl;
+ cerr << " pushed un-constrained IGNode " << IGNode->getIndex() ;
+ cerr << " on to stack\n";
}
}
else pushedall = false; // we didn't push all live ranges
@@ -215,16 +216,16 @@ void RegClass::colorIGNode(IGNode *const Node)
}
else {
if( DEBUG_RA ) {
- cout << " Node " << Node->getIndex();
- cout << " already colored with color " << Node->getColor() << endl;
+ cerr << " Node " << Node->getIndex();
+ cerr << " already colored with color " << Node->getColor() << "\n";
}
}
if( !Node->hasColor() ) {
if( DEBUG_RA ) {
- cout << " Node " << Node->getIndex();
- cout << " - could not find a color (needs spilling)" << endl;
+ cerr << " Node " << Node->getIndex();
+ cerr << " - could not find a color (needs spilling)\n";
}
}
diff --git a/lib/Target/SparcV9/RegAlloc/RegClass.h b/lib/Target/SparcV9/RegAlloc/RegClass.h
index d6cbaf892b..fe25986f40 100644
--- a/lib/Target/SparcV9/RegAlloc/RegClass.h
+++ b/lib/Target/SparcV9/RegAlloc/RegClass.h
@@ -13,8 +13,9 @@
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/MachineRegInfo.h"
#include <stack>
+#include <iostream>
-typedef vector<unsigned int> ReservedColorListType;
+typedef std::vector<unsigned int> ReservedColorListType;
//-----------------------------------------------------------------------------
@@ -46,7 +47,7 @@ class RegClass
InterferenceGraph IG; // Interference graph - constructed by
// buildInterferenceGraph
- stack <IGNode *> IGNodeStack; // the stack used for coloring
+ std::stack<IGNode *> IGNodeStack; // the stack used for coloring
const ReservedColorListType *const ReservedColorList;
//
@@ -117,21 +118,14 @@ class RegClass
inline void printIGNodeList() const {
- cerr << "IG Nodes for Register Class " << RegClassID << ":" << endl;
+ std::cerr << "IG Nodes for Register Class " << RegClassID << ":" << "\n";
IG.printIGNodeList();
}
inline void printIG() {
- cerr << "IG for Register Class " << RegClassID << ":" << endl;
+ std::cerr << "IG for Register Class " << RegClassID << ":" << "\n";
IG.printIG();
}
-
};
-
-
-
-
-
-
#endif
diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
index fb2888b05d..098da9074e 100644
--- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
+++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
@@ -22,16 +22,17 @@
#include "Support/StringExtras.h"
#include "Support/HashExtras.h"
#include <locale.h>
+using std::string;
namespace {
class SparcAsmPrinter {
- typedef hash_map<const Value*, int> ValIdMap;
+ typedef std::hash_map<const Value*, int> ValIdMap;
typedef ValIdMap:: iterator ValIdMapIterator;
typedef ValIdMap::const_iterator ValIdMapConstIterator;
- ostream &toAsm;
+ std::ostream &toAsm;
SlotCalculator Table; // map anonymous values to unique integer IDs
ValIdMap valToIdMap; // used for values not handled by SlotCalculator
const UltraSparc &Target;
@@ -45,7 +46,7 @@ class SparcAsmPrinter {
} CurSection;
public:
- inline SparcAsmPrinter(ostream &o, const Module *M, const UltraSparc &t)
+ inline SparcAsmPrinter(std::ostream &o, const Module *M, const UltraSparc &t)
: toAsm(o), Table(SlotCalculator(M, true)), Target(t), CurSection(Unknown) {
emitModule(M);
}
@@ -61,7 +62,7 @@ private :
void printGlobalVariable( const GlobalVariable* GV);
void printSingleConstant( const Constant* CV);
void printConstantValueOnly(const Constant* CV);
- void printConstant( const Constant* CV, string valID=string(""));
+ void printConstant( const Constant* CV, std::string valID = "");
unsigned int printOperands(const MachineInstr *MI, unsigned int opNum);
void printOneOperand(const MachineOperand &Op);
@@ -88,7 +89,7 @@ private :
toAsm << "\n";
}
- string getValidSymbolName(const string &S) {
+ std::string getValidSymbolName(const string &S) {
string Result;
// Symbol names in Sparc assembly language have these rules:
@@ -318,7 +319,7 @@ SparcAsmPrinter::printOneOperand(const MachineOperand &op)
case MachineOperand::MO_SignExtendedImmed:
case MachineOperand::MO_UnextendedImmed:
- toAsm << op.getImmedValue();
+ toAsm << (long)op.getImmedValue();
break;
default:
@@ -351,7 +352,7 @@ SparcAsmPrinter::emitMachineInst(const MachineInstr *MI)
else
N = 1;
- toAsm << endl;
+ toAsm << "\n";
}
void
@@ -393,7 +394,7 @@ SparcAsmPrinter::emitMethod(const Method *M)
// Output a .size directive so the debugger knows the extents of the function
toAsm << ".EndOf_" << methName << ":\n\t.size "
<< methName << ", .EndOf_"
- << methName << "-" << methName << endl;
+ << methName << "-" << methName << "\n";
// Put some spaces between the methods
toAsm << "\n\n";
@@ -487,7 +488,6 @@ TypeToAlignment(const Type* type, const TargetMachine& target)
inline unsigned int
ConstantToAlignment(const Constant* CV, const TargetMachine& target)
{
- unsigned int constantSize;
if (ConstantArray* CPA = dyn_cast<ConstantArray>(CV))
if (ArrayTypeIsString(cast<ArrayType>(CPA->getType())))
return SizeToAlignment(1 + CPA->getNumOperands(), target);
@@ -515,16 +515,15 @@ SparcAsmPrinter::printSingleConstant(const Constant* CV)
{
if (CV->getType() == Type::FloatTy || CV->getType() == Type::DoubleTy)
toAsm << "0r"; // FP constants must have this prefix
- toAsm << CV->getStrValue() << endl;
+ toAsm << CV->getStrValue() << "\n";
}
else if (ConstantPointer* CPP = dyn_cast<ConstantPointer>(CV))
{
- if (! CPP->isNullValue())
- assert(0 && "Cannot yet print non-null pointer constants to assembly");
- else
- toAsm << (void*) NULL << endl;
+ assert(CPP->isNullValue() &&
+ "Cannot yet print non-null pointer constants to assembly");
+ toAsm << "0\n";
}
- else if (ConstantPointerRef* CPRef = dyn_cast<ConstantPointerRef>(CV))
+ else if (isa<ConstantPointerRef>(CV))
{
assert(0 && "Cannot yet initialize pointer refs in assembly");
}
@@ -543,17 +542,17 @@ SparcAsmPrinter::printConstantValueOnly(const Constant* CV)
if (CPA && isStringCompatible(CPA))
{ // print the string alone and return
- toAsm << "\t" << ".ascii" << "\t" << getAsCString(CPA) << endl;
+ toAsm << "\t" << ".ascii" << "\t" << getAsCString(CPA) << "\n";
}
else if (CPA)
{ // Not a string. Print the values in successive locations
- const vector<Use>& constValues = CPA->getValues();
+ const std::vector<Use> &constValues = CPA->getValues();
for (unsigned i=1; i < constValues.size(); i++)
this->printConstantValueOnly(cast<Constant>(constValues[i].get()));
}
else if (ConstantStruct *CPS = dyn_cast<ConstantStruct>(CV))
{ // Print the fields in successive locations
- const vector<Use>& constValues = CPS->getValues();
+ const std::vector<Use>& constValues = CPS->getValues();
for (unsigned i=1; i < constValues.size(); i++)
this->printConstantValueOnly(cast<Constant>(constValues[i].get()));
}
@@ -571,25 +570,25 @@ SparcAsmPrinter::printConstant(const Constant* CV, string valID)
valID = getID(CV);
toAsm << "\t.align\t" << ConstantToAlignment(CV, Target)
- << endl;
+ << "\n";
// Print .size and .type only if it is not a string.
ConstantArray *CPA = dyn_cast<ConstantArray>(CV);
if (CPA && isStringCompatible(CPA))
{ // print it as a string and return
- toAsm << valID << ":" << endl;
- toAsm << "\t" << ".ascii" << "\t" << getAsCString(CPA) << endl;
+ toAsm << valID << ":\n";
+ toAsm << "\t" << ".ascii" << "\t" << getAsCString(CPA) << "\n";
return;
}
- toAsm << "\t.type" << "\t" << valID << ",#object" << endl;
+ toAsm << "\t.type" << "\t" << valID << ",#object\n";
unsigned int constSize = ConstantToSize(CV, Target);
if (constSize)
toAsm << "\t.size" << "\t" << valID << ","
- << constSize << endl;
+ << constSize << "\n";
- toAsm << valID << ":" << endl;
+ toAsm << valID << ":\n";
this->printConstantValueOnly(CV);
}
@@ -598,29 +597,29 @@ SparcAsmPrinter::printConstant(const Constant* CV, string valID)
void
SparcAsmPrinter::printGlobalVariable(const GlobalVariable* GV)
{
- toAsm << "\t.global\t" << getID(GV) << endl;
+ toAsm << "\t.global\t" << getID(GV) << "\n";
if (GV->hasInitializer())
printConstant(GV->getInitializer(), getID(GV));
else {
toAsm << "\t.align\t"
- << TypeToAlignment(GV->getType()->getElementType(), Target) << endl;
- toAsm << "\t.type\t" << getID(GV) << ",#object" << endl;
+ << TypeToAlignment(GV->getType()->getElementType(), Target) << "\n";
+ toAsm << "\t.type\t" << getID(GV) << ",#object\n";
toAsm << "\t.reserve\t" << getID(GV) << ","
<< TypeToSize(GV->getType()->getElementType(), Target)
- << endl;
+ << "\n";
}
}
static void
FoldConstants(const Module *M,
- hash_set<const Constant*>& moduleConstants)
+ std::hash_set<const Constant*>& moduleConstants)
{
for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
if (! (*I)->isExternal())
{
- const hash_set<const Constant*>& pool =
+ const std::hash_set<const Constant*>& pool =
MachineCodeForMethod::get(*I).getConstantPoolValues();
moduleConstants.insert(pool.begin(), pool.end());
}
@@ -636,7 +635,7 @@ SparcAsmPrinter::emitGlobalsAndConstants(const Module *M)
// lets force these constants into the slot table so that we can get
// unique names for unnamed constants also.
//
- hash_set<const Constant*> moduleConstants;
+ std::hash_set<const Constant*> moduleConstants;
FoldConstants(M, moduleConstants);
// Now, emit the three data sections separately; the cost of I/O should
@@ -654,7 +653,8 @@ SparcAsmPrinter::emitGlobalsAndConstants(const Module *M)
}
}
- for (hash_set<const Constant*>::const_iterator I = moduleConstants.begin(),
+ for (std::hash_set<const Constant*>::const_iterator
+ I = moduleConstants.begin(),
E = moduleConstants.end(); I != E; ++I)
printConstant(*I);
@@ -682,7 +682,7 @@ SparcAsmPrinter::emitGlobalsAndConstants(const Module *M)
}
}
- toAsm << endl;
+ toAsm << "\n";
}
@@ -705,7 +705,7 @@ SparcAsmPrinter::emitModule(const Module *M)
// used.
//
void
-UltraSparc::emitAssembly(const Module *M, ostream &toAsm) const
+UltraSparc::emitAssembly(const Module *M, std::ostream &toAsm) const
{
SparcAsmPrinter Print(toAsm, M, *this);
}
diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp
index 99bb14d12e..e00c871545 100644
--- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp
+++ b/lib/Target/SparcV9/SparcV9InstrInfo.cpp
@@ -27,7 +27,7 @@
static inline MachineInstr*
CreateIntSetInstruction(int64_t C, Value* dest,
- vector<TmpInstruction*>& tempVec)
+ std::vector<TmpInstruction*>& tempVec)
{
MachineInstr* minstr;
uint64_t absC = (C >= 0)? C : -C;
@@ -55,7 +55,7 @@ CreateIntSetInstruction(int64_t C, Value* dest,
static inline MachineInstr*
CreateUIntSetInstruction(uint64_t C, Value* dest,
- vector<TmpInstruction*>& tempVec)
+ std::vector<TmpInstruction*>& tempVec)
{
MachineInstr* minstr;
if (C > (unsigned int) ~0)
@@ -109,9 +109,9 @@ UltraSparcInstrInfo::UltraSparcInstrInfo(const TargetMachine& tgt)
//
void
UltraSparcInstrInfo::CreateCodeToLoadConst(Value* val,
- Instruction* dest,
- vector<MachineInstr*>& minstrVec,
- vector<TmpInstruction*>& tempVec) const
+ Instruction* dest,
+ std::vector<MachineInstr*>& minstrVec,
+ std::vector<TmpInstruction*>& tempVec) const
{
MachineInstr* minstr;
@@ -200,19 +200,17 @@ UltraSparcInstrInfo::CreateCodeToLoadConst(Value* val,
//
void
UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(Method* method,
- Value* val,
- Instruction* dest,
- vector<MachineInstr*>& minstrVec,
- vector<TmpInstruction*>& tempVec,
- TargetMachine& target) const
+ Value* val,
+ Instruction* dest,
+ std::vector<MachineInstr*>& minstrVec,
+ std::vector<TmpInstruction*>& tempVec,
+ TargetMachine& target) const
{
assert((val->getType()->isIntegral() || val->getType()->isPointerType())
&& "Source type must be integral");
assert((dest->getType() ==Type::FloatTy || dest->getType() ==Type::DoubleTy)
&& "Dest type must be float/double");
- const MachineFrameInfo& frameInfo = ((UltraSparc&) target).getFrameInfo();
-
MachineCodeForMethod& mcinfo = MachineCodeForMethod::get(method);
int offset = mcinfo.allocateLocalVar(target, val);
@@ -246,19 +244,17 @@ UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(Method* method,
//
void
UltraSparcInstrInfo::CreateCodeToCopyFloatToInt(Method* method,
- Value* val,
- Instruction* dest,
- vector<MachineInstr*>& minstrVec,
- vector<TmpInstruction*>& tempVec,
- TargetMachine& target) const
+ Value* val,
+ Instruction* dest,
+ std::vector<MachineInstr*>& minstrVec,
+ std::vector<TmpInstruction*>& tempVec,
+ TargetMachine& target) const
{
assert((val->getType() ==Type::FloatTy || val->getType() ==Type::DoubleTy)
&& "Source type must be float/double");
assert((dest->getType()->isIntegral() || dest->getType()->isPointerType())
&& "Dest type must be integral");
- const MachineFrameInfo& frameInfo = ((UltraSparc&) target).getFrameInfo();
-
MachineCodeForMethod& mcinfo = MachineCodeForMethod::get(method);
int offset = mcinfo.allocateLocalVar(target, val);
diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp
index c4fe735672..c20c65a5ce 100644
--- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp
+++ b/lib/Target/SparcV9/SparcV9InstrSelection.cpp
@@ -25,7 +25,7 @@
#include "llvm/ConstantVals.h"
#include "Support/MathExtras.h"
#include <math.h>
-
+using std::vector;
//************************* Forward Declarations ***************************/
@@ -34,7 +34,7 @@ static void SetMemOperands_Internal (MachineInstr* minstr,
const InstructionNode* vmInstrNode,
Value* ptrVal,
Value* arrayOffsetVal,
- const vector<Value*>& idxVec,
+ const std::vector<Value*>& idxVec,
const TargetMachine& target);
@@ -143,7 +143,7 @@ ChooseBFpccInstruction(const InstructionNode* instrNode,
static TmpInstruction*
GetTmpForCC(Value* boolVal, const Method* method, const Type* ccType)
{
- typedef hash_map<const Value*, TmpInstruction*> BoolTmpCache;
+ typedef std::hash_map<const Value*, TmpInstruction*> BoolTmpCache;
static BoolTmpCache boolToTmpCache; // Map boolVal -> TmpInstruction*
static const Method* lastMethod = NULL; // Use to flush cache between methods
@@ -519,7 +519,6 @@ CreateMulConstInstruction(TargetMachine &target,
{
MachineInstr* minstr = NULL; // return NULL if we cannot exploit constant
getMinstr2 = NULL; // to create a cheaper instruction
- bool needNeg = false;
Value* constOp = ((InstrTreeNode*) instrNode->rightChild())->getValue();
assert(isa<Constant>(constOp));
@@ -1011,8 +1010,6 @@ GetInstructionsForProlog(BasicBlock* entryBB,
TargetMachine &target,
MachineInstr** mvec)
{
- int64_t s0=0; // used to avoid overloading ambiguity below
-
const MachineFrameInfo& frameInfo = target.getFrameInfo();
// The second operand is the stack size. If it does not fit in the
@@ -1048,11 +1045,10 @@ GetInstructionsForEpilog(BasicBlock* anExitBB,
TargetMachine &target,
MachineInstr** mvec)
{
- int64_t s0=0; // used to avoid overloading ambiguity below
-
mvec[0] = new MachineInstr(RESTORE);
mvec[0]->SetMachineOperand(0, target.getRegInfo().getZeroRegNum());
- mvec[0]->SetMachineOperand(1, MachineOperand::MO_SignExtendedImmed, s0);
+ mvec[0]->SetMachineOperand(1, MachineOperand::MO_SignExtendedImmed,
+ (int64_t)0);
mvec[0]->SetMachineOperand(2, target.getRegInfo().getZeroRegNum());
return 1;
@@ -1118,8 +1114,6 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
bool checkCast = false; // initialize here to use fall-through
int nextRule;
int forwardOperandNum = -1;
- int64_t s0=0, s8=8; // variables holding constants to avoid
- uint64_t u0=0; // overloading ambiguities below
for (unsigned i=0; i < MAX_INSTR_PER_VMINSTR; i++)
mvec[i] = NULL;
@@ -1162,7 +1156,8 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
mvec[0] = new MachineInstr(JMPLRET);
mvec[0]->SetMachineOperand(0, MachineOperand::MO_VirtualRegister,
returnReg);
- mvec[0]->SetMachineOperand(1, MachineOperand::MO_SignExtendedImmed,s8);
+ mvec[0]->SetMachineOperand(1, MachineOperand::MO_SignExtendedImmed,
+ (int64_t)8);
mvec[0]->SetMachineOperand(2, target.getRegInfo().getZeroRegNum());
if (returnInstr->getReturnValue() != NULL)
@@ -1775,7 +1770,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
int n = numInstr++;
mvec[n] = new MachineInstr(SETHI);
mvec[n]->SetMachineOperand(0,MachineOperand::MO_UnextendedImmed,
- s0);
+ (int64_t)0);
mvec[n]->SetMachineOperand(1,MachineOperand::MO_VirtualRegister,
setCCInstr);
}
@@ -2021,7 +2016,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
phi->getOperand(i));
break;
}
-#endif NEED_PHI_MACHINE_INSTRS
+#endif // NEED_PHI_MACHINE_INSTRS
case 71: // reg: VReg
case 72: // reg: Constant
diff --git a/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h b/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h
index f62457cb49..848ddddd38 100644
--- a/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h
+++ b/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h
@@ -58,4 +58,4 @@ ChooseStoreInstruction(const Type *DestTy)
return 0;
}
-#endif SPARC_INSTR_SELECTION_SUPPORT_h
+#endif
diff --git a/lib/Target/SparcV9/SparcV9Internals.h b/lib/Target/SparcV9/SparcV9Internals.h
index 51609f683f..a82d122336 100644
--- a/lib/Target/SparcV9/SparcV9Internals.h
+++ b/lib/Target/SparcV9/SparcV9Internals.h
@@ -128,8 +128,8 @@ public:
//
virtual void CreateCodeToLoadConst(Value* val,
Instruction* dest,
- vector<MachineInstr*>& minstrVec,
- vector<TmpInstruction*>& tempVec) const;
+ std::vector<MachineInstr*>& minstrVec,
+ std::vector<TmpInstruction*>& tmp) const;
// Create an instruction sequence to copy an integer value `val'
@@ -141,8 +141,8 @@ public:
virtual void CreateCodeToCopyIntToFloat(Method* method,
Value* val,
Instruction* dest,
- vector<MachineInstr*>& minstrVec,
- vector<TmpInstruction*>& tempVec,
+ std::vector<MachineInstr*>& minstr,
+ std::vector<TmpInstruction*>& temp,
TargetMachine& target) const;
// Similarly, create an instruction sequence to copy an FP value
@@ -152,8 +152,8 @@ public:
virtual void CreateCodeToCopyFloatToInt(Method* method,
Value* val,
Instruction* dest,
- vector<MachineInstr*>& minstrVec,
- vector<TmpInstruction*>& tempVec,
+ std::vector<MachineInstr*>& minstr,
+ std::vector<TmpInstruction*>& temp,
TargetMachine& target) const;
// create copy instruction(s)
@@ -161,7 +161,7 @@ public:
CreateCopyInstructionsByType(const TargetMachine& target,
Value* src,
Instruction* dest,
- vector<MachineInstr*>& minstrVec) const;
+ std::vector<MachineInstr*>& minstr) const;
};
@@ -245,7 +245,7 @@ class UltraSparcRegInfo : public MachineRegInfo
LiveRangeInfo& LRI) const;
void suggestReg4CallAddr(const MachineInstr * CallMI, LiveRangeInfo& LRI,
- vector<RegClass *> RCList) const;
+ std::vector<RegClass *> RCList) const;
@@ -348,12 +348,13 @@ class UltraSparcRegInfo : public MachineRegInfo
// the register allocator in association with method calling. See
// SparcRegInfo.cpp for more details
//
- void moveInst2OrdVec(vector<MachineInstr *> &OrdVec, MachineInstr *UnordInst,
- PhyRegAlloc &PRA ) const;
+ void moveInst2OrdVec(std::vector<MachineInstr *> &OrdVec,
+ MachineInstr *UnordInst,
+ PhyRegAlloc &PRA) const;
- void OrderAddedInstrns( vector<MachineInstr *> &UnordVec,
- vector<MachineInstr *> &OrdVec,
- PhyRegAlloc &PRA) const;
+ void OrderAddedInstrns(std::vector<MachineInstr *> &UnordVec,
+ std::vector<MachineInstr *> &OrdVec,
+ PhyRegAlloc &PRA) const;
// To find whether a particular call is to a var arg method
@@ -410,7 +411,7 @@ class UltraSparcRegInfo : public MachineRegInfo
else if( ty <= Type::DoubleTyID)
res = FloatRegClassID; // sparc float reg class
else {
- cerr << "TypeID: " << ty << endl;
+ std::cerr << "TypeID: " << ty << "\n";
assert(0 && "Cannot resolve register class for type");
return 0;
}
@@ -449,10 +450,11 @@ class UltraSparcRegInfo : public MachineRegInfo
LiveRangeInfo& LRI) const;
void suggestRegs4CallArgs(const MachineInstr *const CallMI,
- LiveRangeInfo& LRI, vector<RegClass *> RCL) const;
+ LiveRangeInfo& LRI,
+ std::vector<RegClass *> RCL) const;
void suggestReg4RetValue(const MachineInstr *const RetMI,
- LiveRangeInfo& LRI ) const;
+ LiveRangeInfo& LRI) const;
void colorMethodArgs(const Method *const Meth, LiveRangeInfo& LRI,
@@ -493,7 +495,7 @@ class UltraSparcRegInfo : public MachineRegInfo
// given the unified register number, this gives the name
// for generating assembly code or debugging.
//
- inline const string getUnifiedRegName(int reg) const {
+ inline const std::string getUnifiedRegName(int reg) const {
if( reg < 32 )
return SparcIntRegOrder::getRegName(reg);
else if ( reg < (64 + 32) )
@@ -513,7 +515,7 @@ class UltraSparcRegInfo : public MachineRegInfo
// The fllowing methods are used by instruction selection
//
- inline unsigned int getRegNumInCallersWindow(int reg) {
+ inline unsigned getRegNumInCallersWindow(int reg) {
if (reg == InvalidRegNum || reg >= 32)
return reg;
return SparcIntRegOrder::getRegNumInCallersWindow(reg);
@@ -1433,7 +1435,7 @@ public:
// module. The specified module must have been compiled before this may be
// used.
//
- virtual void emitAssembly(const Module *M, ostream &OutStr) const;
+ virtual void emitAssembly(const Module *M, std::ostream &OutStr) const;
};
diff --git a/lib/Target/SparcV9/SparcV9RegClassInfo.cpp b/lib/Target/SparcV9/SparcV9RegClassInfo.cpp
index 6b39d61f5e..709a8f4c7f 100644
--- a/lib/Target/SparcV9/SparcV9RegClassInfo.cpp
+++ b/lib/Target/SparcV9/SparcV9RegClassInfo.cpp
@@ -1,7 +1,8 @@
-#include "llvm/CodeGen/IGNode.h"
#include "SparcInternals.h"
-
+#include "llvm/CodeGen/IGNode.h"
#include "llvm/Target/Sparc.h"
+#include <iostream>
+using std::cerr;
//-----------------------------------------------------------------------------
// Int Register Class - method for coloring a node in the interference graph.
@@ -37,7 +38,7 @@ void SparcIntRegClass::colorIGNode(IGNode * Node, bool IsColorUsedArr[]) const
}
if( DEBUG_RA ) {
- cout << "\nColoring LR [CallInt=" << LR->isCallInterference() <<"]:";
+ cerr << "\nColoring LR [CallInt=" << LR->isCallInterference() <<"]:";
LR->printSet();
}
@@ -53,18 +54,18 @@ void SparcIntRegClass::colorIGNode(IGNode * Node, bool IsColorUsedArr[]) const
// there are no call interferences. Otherwise, it will get spilled.
if (DEBUG_RA)
- cout << "\n -Coloring with sug color: " << SugCol;
+ cerr << "\n -Coloring with sug color: " << SugCol;
LR->setColor( LR->getSuggestedColor() );
return;
}
else if(DEBUG_RA)
- cout << "\n Couldn't alloc Sug col - LR voloatile & calls interf";
+ cerr << "\n Couldn't alloc Sug col - LR voloatile & calls interf";
}
else if ( DEBUG_RA ) { // can't allocate the suggested col
cerr << " \n Could NOT allocate the suggested color (already used) ";
- LR->printSet(); cerr << endl;
+ LR->printSet(); cerr << "\n";
}
}
@@ -91,7 +92,7 @@ void SparcIntRegClass::colorIGNode(IGNode * Node, bool IsColorUsedArr[]) const
if( ColorFound) {
LR->setColor(c); // first color found in preffered order
- if (DEBUG_RA) cout << "\n Colored after first search with col " << c ;
+ if (DEBUG_RA) cerr << "\n Colored after first search with col " << c ;
}
// if color is not found because of call interference
@@ -113,7 +114,7 @@ void SparcIntRegClass::colorIGNode(IGNode * Node, bool IsColorUsedArr[]) const
// since LR span across calls, must save across calls
//
LR->markForSaveAcrossCalls();
- if(DEBUG_RA) cout << "\n Colored after SECOND search with col " << c ;
+ if(DEBUG_RA) cerr << "\n Colored after SECOND search with col " << c ;
}
}
@@ -193,7 +194,7 @@ void SparcFloatRegClass::colorIGNode(IGNode * Node,bool IsColorUsedArr[]) const
}
else if (DEBUG_RA) { // can't allocate the suggested col
cerr << " Could NOT allocate the suggested color for LR ";
- LR->printSet(); cerr << endl;
+ LR->printSet(); cerr << "\n";
}
}
diff --git a/lib/Target/SparcV9/SparcV9RegClassInfo.h b/lib/Target/SparcV9/SparcV9RegClassInfo.h
index 0a5f5169d1..9127ffdaf6 100644
--- a/lib/Target/SparcV9/SparcV9RegClassInfo.h
+++ b/lib/Target/SparcV9/SparcV9RegClassInfo.h
@@ -17,7 +17,7 @@
// Int register names in same order as enum in class SparcIntRegOrder
-static string const IntRegNames[] =
+static const std::string IntRegNames[] =
{
"o0", "o1", "o2", "o3", "o4", "o5", "o7",
"l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
@@ -75,7 +75,7 @@ class SparcIntRegOrder{
static unsigned int const NumOfAllRegs = o6 + 1;
- static const string getRegName(const unsigned reg) {
+ static const std::string getRegName(const unsigned reg) {
assert( reg < NumOfAllRegs );
return IntRegNames[reg];
}
@@ -119,7 +119,7 @@ class SparcIntRegClass : public MachineRegClassInfo
// Float Register Class
//-----------------------------------------------------------------------------
-static string const FloatRegNames[] =
+static const std::string FloatRegNames[] =
{
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9",
"f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19",
@@ -157,7 +157,7 @@ class SparcFloatRegOrder{
static unsigned int const StartOfAllRegs = f0;
- static const string getRegName(const unsigned reg) {
+ static const std::string getRegName(const unsigned reg) {
assert( reg < NumOfAllRegs );
return FloatRegNames[reg];
}
@@ -203,7 +203,7 @@ class SparcFloatRegClass : public MachineRegClassInfo
//-----------------------------------------------------------------------------
-static string const IntCCRegNames[] =
+static const std::string IntCCRegNames[] =
{
"xcc", "ccr"
};
@@ -218,7 +218,7 @@ class SparcIntCCRegOrder{
xcc, ccr // only one is available - see the note above
};
- static const string getRegName(const unsigned reg) {
+ static const std::string getRegName(const unsigned reg) {
assert( reg < 2 );
return IntCCRegNames[reg];
}
@@ -253,7 +253,7 @@ public:
//-----------------------------------------------------------------------------
-static string const FloatCCRegNames[] =
+static const std::string FloatCCRegNames[] =
{
"fcc0", "fcc1", "fcc2", "fcc3"
};
@@ -268,7 +268,7 @@ class SparcFloatCCRegOrder{
fcc0, fcc1, fcc2, fcc3
};
- static const string getRegName(const unsigned reg) {
+ static const std::string getRegName(const unsigned reg) {
assert( reg < 4 );
return FloatCCRegNames[reg];
}
diff --git a/lib/Target/SparcV9/SparcV9RegInfo.cpp b/lib/Target/SparcV9/SparcV9RegInfo.cpp
index 6543397957..dcfc5fa378 100644
--- a/lib/Target/SparcV9/SparcV9RegInfo.cpp
+++ b/lib/Target/SparcV9/SparcV9RegInfo.cpp
@@ -8,6 +8,8 @@
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
#include "llvm/CodeGen/PhyRegAlloc.h"
#include "llvm/DerivedTypes.h"
+#include <iostream>
+using std::cerr;
//---------------------------------------------------------------------------
// Purpose:
@@ -21,11 +23,10 @@
//---------------------------------------------------------------------------
const Value *
UltraSparcRegInfo::getCallInstRetVal(const MachineInstr *CallMI) const {
-
unsigned OpCode = CallMI->getOpCode();
- unsigned NumOfImpRefs = CallMI->getNumImplicitRefs();
+ unsigned NumOfImpRefs = CallMI->getNumImplicitRefs();
- if( OpCode == CALL ) {
+ if (OpCode == CALL) {
// The one before the last implicit operand is the return value of
// a CALL instr
@@ -34,14 +35,13 @@ UltraSparcRegInfo::getCallInstRetVal(const MachineInstr *CallMI) const {
if( CallMI->implicitRefIsDefined(NumOfImpRefs-2) )
return CallMI->getImplicitRef(NumOfImpRefs-2);
- }
- else if( OpCode == JMPLCALL) {
+ } else if (OpCode == JMPLCALL) {
// The last implicit operand is the return value of a JMPL
//
- if( NumOfImpRefs > 0 )
- if( CallMI->implicitRefIsDefined(NumOfImpRefs-1) )
- return CallMI->getImplicitRef(NumOfImpRefs-1);
+ if(NumOfImpRefs > 0)
+ if (CallMI->implicitRefIsDefined(NumOfImpRefs-1))
+ return CallMI->getImplicitRef(NumOfImpRefs-1);
}
else
assert(0 && "OpCode must be CALL/JMPL for a call instr");
@@ -189,7 +189,7 @@ void UltraSparcRegInfo::suggestReg4RetAddr(const MachineInstr * RetMI,
//---------------------------------------------------------------------------
void UltraSparcRegInfo::suggestReg4CallAddr(const MachineInstr * CallMI,
LiveRangeInfo& LRI,
- vector<RegClass *> RCList) const {
+ std::vector<RegClass *> RCList) const {
const Value *RetAddrVal = getCallInstRetAddr( CallMI );
@@ -361,10 +361,8 @@ void UltraSparcRegInfo::colorMethodArgs(const Method *const Meth,
// that on to the stack pos of LR
if( isArgInReg ) {
-
- MachineInstr *AdIBef =
- cpReg2MemMI(UniArgReg, getFramePointer(),
- LR->getSpillOffFromFP(), RegType );
+ cpReg2MemMI(UniArgReg, getFramePointer(),
+ LR->getSpillOffFromFP(), RegType );
FirstAI->InstrnsBefore.push_back( AdMI );
}
@@ -404,7 +402,7 @@ void UltraSparcRegInfo::colorMethodArgs(const Method *const Meth,
//---------------------------------------------------------------------------
void UltraSparcRegInfo::suggestRegs4CallArgs(const MachineInstr *const CallMI,
LiveRangeInfo& LRI,
- vector<RegClass *> RCList) const {
+ std::vector<RegClass *> RCList) const {
assert ( (UltraSparcInfo->getInstrInfo()).isCall(CallMI->getOpCode()) );
@@ -469,7 +467,7 @@ void UltraSparcRegInfo::suggestRegs4CallArgs(const MachineInstr *const CallMI,
if( !LR ) {
if( DEBUG_RA) {
cerr << " ERROR: In call instr, no LR for arg: " ;
- printValue(CallArg); cerr << endl;
+ printValue(CallArg); cerr << "\n";
}
assert(0 && "NO LR for call arg");
// continue;
@@ -485,7 +483,7 @@ void UltraSparcRegInfo::suggestRegs4CallArgs(const MachineInstr *const CallMI,
else if (DEBUG_RA)
// Do NOTHING as this will be colored as a normal value.
- cerr << " Regr not suggested for int call arg" << endl;
+ cerr << " Regr not suggested for int call arg\n";
}
else if( RegType == FPSingleRegType && (argNo*2 +1)< NumOfFloatArgRegs)
@@ -535,7 +533,7 @@ void UltraSparcRegInfo::colorCallArgs(const MachineInstr *const CallMI,
if( !RetValLR ) {
cerr << "\nNo LR for:";
printValue( RetVal );
- cerr << endl;
+ cerr << "\n";
assert( RetValLR && "ERR:No LR for non-void return value");
//return;
}
@@ -601,7 +599,7 @@ void UltraSparcRegInfo::colorCallArgs(const MachineInstr *const CallMI,
// Now color all args of the call instruction
//-------------------------------------------
- vector <MachineInstr *> AddedInstrnsBefore;
+ std::vector<MachineInstr *> AddedInstrnsBefore;
unsigned NumOfCallArgs = getCallInstNumArgs( CallMI );
@@ -662,7 +660,7 @@ void UltraSparcRegInfo::colorCallArgs(const MachineInstr *const CallMI,
if( !LR ) {
if( DEBUG_RA) {
cerr << " ERROR: In call instr, no LR for arg: " ;
- printValue(CallArg); cerr << endl;
+ printValue(CallArg); cerr << "\n";
}
assert(0 && "NO LR for call arg");
// continue;
@@ -812,7 +810,7 @@ void UltraSparcRegInfo::colorCallArgs(const MachineInstr *const CallMI,
cerr << *(AddedInstrnsBefore[i]);
}
- vector <MachineInstr *> TmpVec;
+ std::vector<MachineInstr *> TmpVec;
OrderAddedInstrns(AddedInstrnsBefore, TmpVec, PRA);
if( DEBUG_RA ) {
@@ -855,13 +853,12 @@ void UltraSparcRegInfo::suggestReg4RetValue(const MachineInstr *const RetMI,
// The first implicit operand is the return value of a return instr
const Value *RetVal = RetMI->getImplicitRef(0);
- MachineInstr *AdMI;
LiveRange *const LR = LRI.getLiveRangeForValue( RetVal );
if( !LR ) {
cerr << "\nNo LR for:";
printValue( RetVal );
- cerr << endl;
+ cerr << "\n";
assert( LR && "No LR for return value of non-void method");
//return;
}
@@ -898,13 +895,12 @@ void UltraSparcRegInfo::colorRetValue(const MachineInstr *const RetMI,
// The first implicit operand is the return value of a return instr
const Value *RetVal = RetMI->getImplicitRef(0);
- MachineInstr *AdMI;
LiveRange *const LR = LRI.getLiveRangeForValue( RetVal );
if( ! LR ) {
cerr << "\nNo LR for:";
printValue( RetVal );
- cerr << endl;
+ cerr << "\n";
// assert( LR && "No LR for return value of non-void method");
return;
}
@@ -941,16 +937,14 @@ void UltraSparcRegInfo::colorRetValue(const MachineInstr *const RetMI,
// the LR received UniLRReg but must be colored with UniRetReg
// to pass as the return value
-
- AdMI = cpReg2RegMI( UniLRReg, UniRetReg, RegType);
- RetAI->InstrnsBefore.push_back( AdMI );
+ RetAI->InstrnsBefore.push_back(cpReg2RegMI(UniLRReg, UniRetReg, RegType));
}
else { // if the LR is spilled
-
- AdMI = cpMem2RegMI(getFramePointer(), LR->getSpillOffFromFP(),
- UniRetReg, RegType);
- RetAI->InstrnsBefore.push_back( AdMI );
- cout << "\nCopied the return value from stack";
+ MachineInstr *AdMI = cpMem2RegMI(getFramePointer(),
+ LR->getSpillOffFromFP(),
+ UniRetReg, RegType);
+ RetAI->InstrnsBefore.push_back(AdMI);
+ cerr << "\nCopied the return value from stack\n";
}
} // if there is a return value
@@ -1179,9 +1173,7 @@ void UltraSparcRegInfo::insertCallerSavingCode(const MachineInstr *MInst,
// has set to record which registers were saved/restored
//
- hash_set<unsigned> PushedRegSet;
-
-
+ std::hash_set<unsigned> PushedRegSet;
// Now find the LR of the return value of the call
// The last *implicit operand* is the return value of a call
@@ -1394,7 +1386,7 @@ void UltraSparcRegInfo::printReg(const LiveRange *const LR) {
cerr << " *Node " << (LR->getUserIGNode())->getIndex();
if( ! LR->hasColor() ) {
- cerr << " - could not find a color" << endl;
+ cerr << " - could not find a color\n";
return;
}
@@ -1403,15 +1395,13 @@ void UltraSparcRegInfo::printReg(const LiveRange *const LR) {
cerr << " colored with color "<< LR->getColor();
if( RegClassID == IntRegClassID ) {
+ cerr<< " [" << SparcIntRegOrder::getRegName(LR->getColor()) << "]\n";
- cerr<< " [" << SparcIntRegOrder::getRegName(LR->getColor()) ;
- cerr << "]" << endl;
- }
- else if ( RegClassID == FloatRegClassID) {
+ } else if ( RegClassID == FloatRegClassID) {
cerr << "[" << SparcFloatRegOrder::getRegName(LR->getColor());
if( LR->getTypeID() == Type::DoubleTyID )
cerr << "+" << SparcFloatRegOrder::getRegName(LR->getColor()+1);
- cerr << "]" << endl;
+ cerr << "]\n";
}
}
@@ -1436,9 +1426,9 @@ void UltraSparcRegInfo::printReg(const LiveRange *const LR) {
//---------------------------------------------------------------------------
-void UltraSparcRegInfo::OrderAddedInstrns( vector<MachineInstr *> &UnordVec,
- vector<MachineInstr *> &OrdVec,
- PhyRegAlloc &PRA) const{
+void UltraSparcRegInfo::OrderAddedInstrns(std::vector<MachineInstr *> &UnordVec,
+ std::vector<MachineInstr *> &OrdVec,
+ PhyRegAlloc &PRA) const{
/*
Problem: We can have instructions inserted by RegAlloc like
@@ -1476,7 +1466,7 @@ void UltraSparcRegInfo::OrderAddedInstrns( vector<MachineInstr *> &UnordVec,
CouldMoveAll = true;
- vector<MachineInstr *>::iterator DefIt = UnordVec.begin();
+ std::vector<MachineInstr *>::iterator DefIt = UnordVec.begin();
for( ; DefIt != UnordVec.end(); ++DefIt ) {
@@ -1498,7 +1488,7 @@ void UltraSparcRegInfo::OrderAddedInstrns( vector<MachineInstr *> &UnordVec,
bool DefEqUse = false;
- vector<MachineInstr *>::iterator UseIt = DefIt;
+ std::vector<MachineInstr *>::iterator UseIt = DefIt;
UseIt++;
for( ; UseIt != UnordVec.end(); ++UseIt ) {
@@ -1572,7 +1562,7 @@ void UltraSparcRegInfo::OrderAddedInstrns( vector<MachineInstr *> &UnordVec,
-void UltraSparcRegInfo::moveInst2OrdVec(vector<MachineInstr *> &OrdVec,
+void UltraSparcRegInfo::moveInst2OrdVec(std::vector<MachineInstr *> &OrdVec,
MachineInstr *UnordInst,
PhyRegAlloc &PRA ) const {
@@ -1585,7 +1575,7 @@ void UltraSparcRegInfo::moveInst2OrdVec(vector<MachineInstr *> &OrdVec,
// before in the OrdVec
bool DefEqUse = false;
- vector<MachineInstr *>::iterator OrdIt = OrdVec.begin();
+ std::vector<MachineInstr *>::iterator OrdIt = OrdVec.begin();
for( ; OrdIt != OrdVec.end(); ++OrdIt ) {
diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.cpp b/lib/Target/SparcV9/SparcV9TargetMachine.cpp
index 9524e80515..dd9e330474 100644
--- a/lib/Target/SparcV9/SparcV9TargetMachine.cpp
+++ b/lib/Target/SparcV9/SparcV9TargetMachine.cpp
@@ -17,7 +17,8 @@
#include "llvm/CodeGen/PhyRegAlloc.h"
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
#include "llvm/Method.h"
-
+#include <iostream>
+using std::cerr;
// Build the MachineInstruction Description Array...
const MachineInstrDescriptor SparcMachineInstrDesc[] = {
@@ -47,10 +48,9 @@ void AllocateRegisters(Method *M, TargetMachine &target)
if ( (M)->isExternal() ) // don't process prototypes
return;
- if( DEBUG_RA ) {
- cerr << endl << "******************** Method "<< (M)->getName();
- cerr << " ********************" <<endl;
- }
+ if( DEBUG_RA )
+ cerr << "\n******************** Method "<< M->getName()
+ << " ********************\n";
MethodLiveVarInfo LVI(M ); // Analyze live varaibles
LVI.analyze();
@@ -60,7 +60,7 @@ void AllocateRegisters(Method *M, TargetMachine &target)
PRA.allocateRegisters();
- if( DEBUG_RA ) cerr << endl << "Register allocation complete!" << endl;
+ if( DEBUG_RA ) cerr << "\nRegister allocation complete!\n";
}
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index b290f29b85..0df60fde67 100644
--- a/lib/Target/TargetData.cpp
+++ b/lib/Target/TargetData.cpp
@@ -40,7 +40,7 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD)
StructSize = (StructSize/TyAlign + 1) * TyAlign; // Add padding...
// Keep track of maximum alignment constraint
- StructAlignment = max(TyAlign, StructAlignment);
+ StructAlignment = std::max(TyAlign, StructAlignment);
MemberOffsets.push_back(StructSize);
StructSize += TySize; // Consume space for this data item...
@@ -71,7 +71,7 @@ Annotation *TargetData::TypeAnFactory(AnnotationID AID, const Annotable *T,
// TargetData Class Implementation
//===----------------------------------------------------------------------===//
-TargetData::TargetData(const string &TargetName, unsigned char PtrSize = 8,
+TargetData::TargetData(const std::string &TargetName, unsigned char PtrSize = 8,
unsigned char PtrAl = 8, unsigned char DoubleAl = 8,
unsigned char FloatAl = 4, unsigned char LongAl = 8,
unsigned char IntAl = 4, unsigned char ShortAl = 2,
@@ -146,7 +146,7 @@ unsigned char TargetData::getTypeAlignment(const Type *Ty) const {
}
unsigned TargetData::getIndexedOffset(const Type *ptrTy,
- const vector<Value*> &Idx) const {
+ const std::vector<Value*> &Idx) const {
const PointerType *PtrTy = cast<const PointerType>(ptrTy);
unsigned Result = 0;
diff --git a/lib/Target/TargetSchedInfo.cpp b/lib/Target/TargetSchedInfo.cpp
index f9dca290b0..c02654f03b 100644
--- a/lib/Target/TargetSchedInfo.cpp
+++ b/lib/Target/TargetSchedInfo.cpp
@@ -21,8 +21,8 @@ resourceId_t MachineResource::nextId = 0;
// (stl_algo.h).
//
inline static bool
-RUConflict(const vector<resourceId_t>& fromRVec,
- const vector<resourceId_t>& toRVec)
+RUConflict(const std::vector<resourceId_t>& fromRVec,
+ const std::vector<resourceId_t>& toRVec)
{
unsigned fN = fromRVec.size(), tN = toRVec.size();
@@ -57,7 +57,7 @@ ComputeMinGap(const InstrRUsage &fromRU,
{
// check if instr. #2 can start executing `gap' cycles after #1
// by checking for resource conflicts in each overlapping cycle
- cycles_t numOverlap = min(fromRU.numCycles - gap, toRU.numCycles);
+ cycles_t numOverlap =std::min(fromRU.numCycles - gap, toRU.numCycles);
for (cycles_t c = 0; c <= numOverlap-1; c++)
if (RUConflict(fromRU.resourcesByCycle[gap + c],
toRU.resourcesByCycle[c]))
@@ -102,7 +102,7 @@ MachineSchedInfo::initializeResources()
// most instructions will probably behave the same as their class.
// Cannot allocate a vector of InstrRUsage so new each one.
//
- vector<InstrRUsage> instrRUForClasses;
+ std::vector<InstrRUsage> instrRUForClasses;
instrRUForClasses.resize(numSchedClasses);
for (InstrSchedClass sc = 0; sc < numSchedClasses; sc++) {
// instrRUForClasses.push_back(new InstrRUsage);
@@ -116,7 +116,7 @@ MachineSchedInfo::initializeResources()
void
-MachineSchedInfo::computeInstrResources(const vector<InstrRUsage>&
+MachineSchedInfo::computeInstrResources(const std::vector<InstrRUsage>&
instrRUForClasses)
{
int numOpCodes = mii->getNumRealOpCodes();
@@ -146,7 +146,7 @@ MachineSchedInfo::computeInstrResources(const vector<InstrRUsage>&
void
-MachineSchedInfo::computeIssueGaps(const vector<InstrRUsage>&
+MachineSchedInfo::computeIssueGaps(const std::vector<InstrRUsage>&
instrRUForClasses)
{
int numOpCodes = mii->getNumRealOpCodes();
@@ -186,7 +186,7 @@ MachineSchedInfo::computeIssueGaps(const vector<InstrRUsage>&
{
issueGaps[OpCodePair(fromOp,toOp)] = instrPairGap;
conflictLists[fromOp].push_back(toOp);
- longestIssueConflict = max(longestIssueConflict, instrPairGap);
+ longestIssueConflict = std::max(longestIssueConflict, instrPairGap);
}
}
}
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index 02e14b6caa..7f33fe280b 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -18,6 +18,8 @@
#include "Support/STLExtras.h"
#include <map>
#include <algorithm>
+#include <iostream>
+using std::cerr;
#include "llvm/Assembly/Writer.h"
@@ -96,7 +98,8 @@ static bool MallocConvertableToType(MallocInst *MI, const Type *Ty,
}
static Instruction *ConvertMallocToType(MallocInst *MI, const Type *Ty,
- const string &Name, ValueMapCache &VMC){
+ const std::string &Name,
+ ValueMapCache &VMC){
BasicBlock *BB = MI->getParent();
BasicBlock::iterator It = BB->end();
@@ -270,7 +273,7 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty,
// index array. If there are, check to see if removing them causes us to
// get to the right type...
//
- vector<Value*> Indices = GEP->copyIndices();
+ std::vector<Value*> Indices = GEP->copyIndices();
const Type *BaseType = GEP->getPointerOperand()->getType();
const Type *ElTy = 0;
@@ -302,7 +305,7 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty,
// Check to see if 'N' is an expression that can be converted to
// the appropriate size... if so, allow it.
//
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
const Type *ElTy = ConvertableToGEP(PTy, I->getOperand(1), Indices);
if (ElTy) {
assert(ElTy == PVTy && "Internal error, setup wrong!");
@@ -378,7 +381,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
BasicBlock *BB = I->getParent();
BasicBlock::InstListType &BIL = BB->getInstList();
- string Name = I->getName(); if (!Name.empty()) I->setName("");
+ std::string Name = I->getName(); if (!Name.empty()) I->setName("");
Instruction *Res; // Result of conversion
ValueHandle IHandle(VMC, I); // Prevent I from being removed!
@@ -460,7 +463,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
// index array. If there are, check to see if removing them causes us to
// get to the right type...
//
- vector<Value*> Indices = GEP->copyIndices();
+ std::vector<Value*> Indices = GEP->copyIndices();
const Type *BaseType = GEP->getPointerOperand()->getType();
const Type *PVTy = cast<PointerType>(Ty)->getElementType();
Res = 0;
@@ -491,7 +494,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
// Check to see if 'N' is an expression that can be converted to
// the appropriate size... if so, allow it.
//
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
const Type *ElTy = ConvertableToGEP(NewSrcTy, I->getOperand(1),
Indices, &It);
if (ElTy) {
@@ -634,7 +637,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
case Instruction::Add:
if (isa<PointerType>(Ty)) {
Value *IndexVal = I->getOperand(V == I->getOperand(0) ? 1 : 0);
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
if (const Type *ETy = ConvertableToGEP(Ty, IndexVal, Indices)) {
const Type *RetTy = PointerType::get(ETy);
@@ -685,7 +688,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
// They could be loading the first element of a composite type...
if (const CompositeType *CT = dyn_cast<CompositeType>(LoadedTy)) {
unsigned Offset = 0; // No offset, get first leaf.
- vector<Value*> Indices; // Discarded...
+ std::vector<Value*> Indices; // Discarded...
LoadedTy = getStructOffsetType(CT, Offset, Indices, false);
assert(Offset == 0 && "Offset changed from zero???");
}
@@ -751,7 +754,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
// Check to see if the second argument is an expression that can
// be converted to the appropriate size... if so, allow it.
//
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
const Type *ElTy = ConvertableToGEP(Ty, Index, Indices);
delete TempScale; // Free our temporary multiply if we made it
@@ -823,7 +826,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
BasicBlock *BB = I->getParent();
BasicBlock::InstListType &BIL = BB->getInstList();
- string Name = I->getName(); if (!Name.empty()) I->setName("");
+ std::string Name = I->getName(); if (!Name.empty()) I->setName("");
Instruction *Res; // Result of conversion
//cerr << endl << endl << "Type:\t" << Ty << "\nInst: " << I << "BB Before: " << BB << endl;
@@ -844,12 +847,12 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
case Instruction::Add:
if (isa<PointerType>(NewTy)) {
Value *IndexVal = I->getOperand(OldVal == I->getOperand(0) ? 1 : 0);
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
BasicBlock::iterator It = find(BIL.begin(), BIL.end(), I);
if (const Type *ETy = ConvertableToGEP(NewTy, IndexVal, Indices, &It)) {
// If successful, convert the add to a GEP
- const Type *RetTy = PointerType::get(ETy);
+ //const Type *RetTy = PointerType::get(ETy);
// First operand is actually the given pointer...
Res = new GetElementPtrInst(NewVal, Indices, Name);
assert(cast<PointerType>(Res->getType())->getElementType() == ETy &&
@@ -892,7 +895,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
const Type *LoadedTy =
cast<PointerType>(NewVal->getType())->getElementType();
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
if (const CompositeType *CT = dyn_cast<CompositeType>(LoadedTy)) {
@@ -914,7 +917,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
Res->setOperand(1, ConvertExpressionToType(I->getOperand(1), NewPT, VMC));
} else { // Replace the source pointer
const Type *ValTy = cast<PointerType>(NewTy)->getElementType();
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
#if 0
Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
while (ArrayType *AT = dyn_cast<ArrayType>(ValTy)) {
@@ -948,7 +951,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
// Perform the conversion now...
//
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
const Type *ElTy = ConvertableToGEP(NewVal->getType(), Index, Indices, &It);
assert(ElTy != 0 && "GEP Conversion Failure!");
Res = new GetElementPtrInst(NewVal, Indices, Name);
@@ -965,7 +968,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
// Check to see if the second argument is an expression that can
// be converted to the appropriate size... if so, allow it.
//
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
const Type *ElTy = ConvertableToGEP(NewVal->getType(), I->getOperand(1),
Indices, &It);
assert(ElTy != 0 && "GEP Conversion Failure!");
@@ -1001,9 +1004,10 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
case Instruction::Call: {
Value *Meth = I->getOperand(0);
- vector<Value*> Params(I->op_begin()+1, I->op_end());
+ std::vector<Value*> Params(I->op_begin()+1, I->op_end());
- vector<Value*>::iterator OI = find(Params.begin(), Params.end(), OldVal);
+ std::vector<Value*>::iterator OI =
+ find(Params.begin(), Params.end(), OldVal);
assert (OI != Params.end() && "Not using value!");
*OI = NewVal;
diff --git a/lib/Transforms/HoistPHIConstants.cpp b/lib/Transforms/HoistPHIConstants.cpp
index e28e8a2fe4..43ed725d94 100644
--- a/lib/Transforms/HoistPHIConstants.cpp
+++ b/lib/Transforms/HoistPHIConstants.cpp
@@ -14,8 +14,8 @@
#include <map>
#include <vector>
-typedef pair<BasicBlock *, Value*> BBConstTy;
-typedef map<BBConstTy, CastInst *> CachedCopyMap;
+typedef std::pair<BasicBlock *, Value*> BBConstTy;
+typedef std::map<BBConstTy, CastInst *> CachedCopyMap;
static Value *NormalizePhiOperand(PHINode *PN, Value *CPV,
BasicBlock *Pred, CachedCopyMap &CopyCache) {
@@ -33,7 +33,7 @@ static Value *NormalizePhiOperand(PHINode *PN, Value *CPV,
// Create a copy instruction and add it to the cache...
CastInst *Inst = new CastInst(CPV, CPV->getType());
- CopyCache.insert(make_pair(BBConstTy(Pred, CPV), Inst));
+ CopyCache.insert(std::make_pair(BBConstTy(Pred, CPV), Inst));
// Insert the copy just before the terminator inst of the predecessor BB
assert(Pred->getTerminator() && "Degenerate BB encountered!");
@@ -52,7 +52,7 @@ bool HoistPHIConstants::doHoistPHIConstants(Method *M) {
bool Changed = false;
for (Method::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI) {
- vector<PHINode*> phis; // normalizing invalidates BB iterator
+ std::vector<PHINode*> phis; // normalizing invalidates BB iterator
for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II) {
if (PHINode *PN = dyn_cast<PHINode>(*II))
@@ -61,7 +61,7 @@ bool HoistPHIConstants::doHoistPHIConstants(Method *M) {
break; // All PHIs occur at top of BB!
}
- for (vector<PHINode*>::iterator PI=phis.begin(); PI != phis.end(); ++PI)
+ for (std::vector<PHINode*>::iterator PI=phis.begin(); PI != phis.end();++PI)
for (unsigned i = 0; i < (*PI)->getNumIncomingValues(); ++i) {
Value *Op = (*PI)->getIncomingValue(i);
diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp
index 70e3437bb9..ff2442d2b6 100644
--- a/lib/Transforms/IPO/ConstantMerge.cpp
+++ b/lib/Transforms/IPO/ConstantMerge.cpp
@@ -23,7 +23,7 @@
//
static inline
bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo,
- map<Constant*, GlobalVariable*> &CMap) {
+ std::map<Constant*, GlobalVariable*> &CMap) {
Module::GlobalListType &GList = M->getGlobalList();
if (GList.size() <= ConstantNo) return false; // No new constants
bool MadeChanges = false;
@@ -35,10 +35,10 @@ bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo,
Constant *Init = GV->getInitializer();
// Check to see if the initializer is already known...
- map<Constant*, GlobalVariable*>::iterator I = CMap.find(Init);
+ std::map<Constant*, GlobalVariable*>::iterator I = CMap.find(Init);
if (I == CMap.end()) { // Nope, add it to the map
- CMap.insert(make_pair(Init, GV));
+ CMap.insert(std::make_pair(Init, GV));
} else { // Yup, this is a duplicate!
// Make all uses of the duplicate constant use the cannonical version...
GV->replaceAllUsesWith(I->second);
@@ -59,7 +59,7 @@ bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo,
// deal with passes.
//
bool ConstantMerge::mergeDuplicateConstants(Module *M) {
- map<Constant*, GlobalVariable*> Constants;
+ std::map<Constant*, GlobalVariable*> Constants;
unsigned LastConstantSeen = 0;
return ::mergeDuplicateConstants(M, LastConstantSeen, Constants);
}
diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp
index ec4c3fd66e..d5e9ea07bd 100644
--- a/lib/Transforms/IPO/DeadTypeElimination.cpp
+++ b/lib/Transforms/IPO/DeadTypeElimination.cpp
@@ -23,6 +23,10 @@
#include "llvm/iTerminators.h"
#include "llvm/iOther.h"
#include <algorithm>
+#include <iostream>
+using std::vector;
+using std::string;
+using std::cerr;
static const Type *PtrSByte = 0; // 'sbyte*' type
@@ -78,7 +82,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) {
SymbolTable *ST = M->getSymbolTable();
if (!ST) return false;
- map<string, vector<Method*> > Methods;
+ std::map<string, vector<Method*> > Methods;
// Loop over the entries in the symbol table. If an entry is a method pointer,
// then add it to the Methods map. We do a two pass algorithm here to avoid
@@ -86,7 +90,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) {
//
for (SymbolTable::iterator I = ST->begin(), E = ST->end(); I != E; ++I)
if (const PointerType *PT = dyn_cast<PointerType>(I->first))
- if (const MethodType *MT = dyn_cast<MethodType>(PT->getElementType())) {
+ if (isa<MethodType>(PT->getElementType())) {
SymbolTable::VarMap &Plane = I->second;
for (SymbolTable::type_iterator PI = Plane.begin(), PE = Plane.end();
PI != PE; ++PI) {
@@ -101,7 +105,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) {
// Now we have a list of all methods with a particular name. If there is more
// than one entry in a list, merge the methods together.
//
- for (map<string, vector<Method*> >::iterator I = Methods.begin(),
+ for (std::map<string, vector<Method*> >::iterator I = Methods.begin(),
E = Methods.end(); I != E; ++I) {
vector<Method*> &Methods = I->second;
Method *Implementation = 0; // Find the implementation
@@ -145,7 +149,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) {
cerr << "Warning: Found methods types that are not compatible:\n";
for (unsigned i = 0; i < Methods.size(); ++i) {
cerr << "\t" << Methods[i]->getType()->getDescription() << " %"
- << Methods[i]->getName() << endl;
+ << Methods[i]->getName() << "\n";
}
cerr << " No linkage of methods named '" << Methods[0]->getName()
<< "' performed!\n";
@@ -185,7 +189,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) {
++i;
}
} else {
- cerr << "Cannot convert use of method: " << U << endl;
+ cerr << "Cannot convert use of method: " << U << "\n";
++i;
}
}
@@ -201,7 +205,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) {
// ShouldNukSymtabEntry - Return true if this module level symbol table entry
// should be eliminated.
//
-static inline bool ShouldNukeSymtabEntry(const pair<string, Value*> &E) {
+static inline bool ShouldNukeSymtabEntry(const std::pair<string, Value*> &E) {
// Nuke all names for primitive types!
if (cast<Type>(E.second)->isPrimitiveType()) return true;
@@ -357,8 +361,8 @@ static inline bool FixCastsAndPHIs(BasicBlock *BB) {
Value *Src = CI->getOperand(0);
// Move the cast instruction to the current insert position...
- --InsertPos; // New position for cast to go...
- swap(*InsertPos, *I); // Cast goes down, PHI goes up
+ --InsertPos; // New position for cast to go...
+ std::swap(*InsertPos, *I); // Cast goes down, PHI goes up
if (isa<PHINode>(Src) && // Handle case #1
cast<PHINode>(Src)->getParent() == BB) {
@@ -561,7 +565,7 @@ bool CleanupGCCOutput::doPassFinalization(Module *M) {
if (M->hasSymbolTable()) {
SymbolTable *ST = M->getSymbolTable();
- const set<const Type *> &UsedTypes = FUT.getTypes();
+ const std::set<const Type *> &UsedTypes = FUT.getTypes();
// Check the symbol table for superfluous type entries that aren't used in
// the program
diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp
index 7395bab803..dacd3295ef 100644
--- a/lib/Transforms/IPO/GlobalDCE.cpp
+++ b/lib/Transforms/IPO/GlobalDCE.cpp
@@ -18,14 +18,14 @@ static bool RemoveUnreachableMethods(Module *M, cfg::CallGraph *CG) {
// Calculate which methods are reachable from the external methods in the call
// graph.
//
- set<cfg::CallGraphNode*> ReachableNodes(df_begin(&CallGraph),
- df_end(&CallGraph));
+ std::set<cfg::CallGraphNode*> ReachableNodes(df_begin(&CallGraph),
+ df_end(&CallGraph));
// Loop over the methods in the module twice. The first time is used to drop
// references that methods have to each other before they are deleted. The
// second pass removes the methods that need to be removed.
//
- vector<cfg::CallGraphNode*> MethodsToDelete; // Track unused methods
+ std::vector<cfg::CallGraphNode*> MethodsToDelete; // Track unused methods
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
cfg::CallGraphNode *N = CallGraph[*I];
if (!ReachableNodes.count(N)) { // Not reachable??
@@ -45,7 +45,7 @@ static bool RemoveUnreachableMethods(Module *M, cfg::CallGraph *CG) {
// Unreachables methods have been found and should have no references to them,
// delete them now.
//
- for (vector<cfg::CallGraphNode*>::iterator I = MethodsToDelete.begin(),
+ for (std::vector<cfg::CallGraphNode*>::iterator I = MethodsToDelete.begin(),
E = MethodsToDelete.end(); I != E; ++I)
delete CallGraph.removeMethodFromModule(*I);
diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp
index 40b98bd67d..9d86c86895 100644
--- a/lib/Transforms/IPO/InlineSimple.cpp
+++ b/lib/Transforms/IPO/InlineSimple.cpp
@@ -27,6 +27,8 @@
#include "llvm/iOther.h"
#include <algorithm>
#include <map>
+#include <iostream>
+using std::cerr;
#include "llvm/Assembly/Writer.h"
@@ -36,7 +38,7 @@ using namespace opt;
// current values into those specified by ValueMap.
//
static inline void RemapInstruction(Instruction *I,
- map<const Value *, Value*> &ValueMap) {
+ std::map<const Value *, Value*> &ValueMap) {
for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) {
const Value *Op = I->getOperand(op);
@@ -45,8 +47,8 @@ static inline void RemapInstruction(Instruction *I,
continue; // Globals and constants don't get relocated
if (!V) {
- cerr << "Val = " << endl << Op << "Addr = " << (void*)Op << endl;
- cerr << "Inst = " << I;
+ cerr << "Val = \n" << Op << "Addr = " << (void*)Op;
+ cerr << "\nInst = " << I;
}
assert(V && "Referenced value not in value map!");
I->setOperand(op, V);
@@ -72,10 +74,9 @@ bool opt::InlineMethod(BasicBlock::iterator CIIt) {
const Method *CalledMeth = CI->getCalledMethod();
if (CalledMeth == 0 || // Can't inline external method or indirect call!
CalledMeth->isExternal()) return false;
- Method *CurrentMeth = CI->getParent()->getParent();
//cerr << "Inlining " << CalledMeth->getName() << " into "
- // << CurrentMeth->getName() << endl;
+ // << CurrentMeth->getName() << "\n";
BasicBlock *OrigBB = CI->getParent();
@@ -111,7 +112,7 @@ bool opt::InlineMethod(BasicBlock::iterator CIIt) {
// code's values. This includes all of: Method arguments, instruction values,
// constant pool entries, and basic blocks.
//
- map<const Value *, Value*> ValueMap;
+ std::map<const Value *, Value*> ValueMap;
// Add the method arguments to the mapping: (start counting at 1 to skip the
// method reference itself)
diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp
index c91c00c647..df2b67ef41 100644
--- a/lib/Transforms/IPO/MutateStructTypes.cpp
+++ b/lib/Transforms/IPO/MutateStructTypes.cpp
@@ -21,6 +21,9 @@
#include "llvm/iTerminators.h"
#include "llvm/iOther.h"
#include <algorithm>
+using std::map;
+using std::make_pair;
+using std::vector;
// To enable debugging, uncomment this...
//#define DEBUG_MST(x) x
@@ -37,7 +40,7 @@
struct ValuePlaceHolder : public Instruction {
ValuePlaceHolder(const Type *Ty) : Instruction(Ty, UserOp1, "") {}
- virtual Instruction *clone() const { abort(); }
+ virtual Instruction *clone() const { abort(); return 0; }
virtual const char *getOpcodeName() const { return "placeholder"; }
};
@@ -291,8 +294,8 @@ bool MutateStructTypes::doPassInitialization(Module *M) {
// of the methods and global variables that we no longer need.
bool MutateStructTypes::doPassFinalization(Module *M) {
// The first half of the methods in the module have to go.
- unsigned NumMethods = M->size();
- unsigned NumGVars = M->gsize();
+ //unsigned NumMethods = M->size();
+ //unsigned NumGVars = M->gsize();
// Prepare for deletion of globals by dropping their interdependencies...
for(Module::iterator I = M->begin(); I != M->end(); ++I) {
@@ -436,12 +439,11 @@ bool MutateStructTypes::doPerMethodWork(Method *m) {
AdjustIndices(cast<CompositeType>(PTy), Indices);
}
- if (const LoadInst *LI = dyn_cast<LoadInst>(I)) {
+ if (isa<LoadInst>(I)) {
NewI = new LoadInst(NewPtr, Indices);
- } else if (const StoreInst *SI = dyn_cast<StoreInst>(I)) {
+ } else if (isa<StoreInst>(I)) {
NewI = new StoreInst(ConvertValue(I->getOperand(0)), NewPtr, Indices);
- } else if (const GetElementPtrInst *GEP =
- dyn_cast<GetElementPtrInst>(I)) {
+ } else if (isa<GetElementPtrInst>(I)) {
NewI = new GetElementPtrInst(NewPtr, Indices);
} else {
assert(0 && "Unknown memory access inst!!!");
diff --git a/lib/Transforms/IPO/SimpleStructMutation.cpp b/lib/Transforms/IPO/SimpleStructMutation.cpp
index d9385453e8..d0b8bb2807 100644
--- a/lib/Transforms/IPO/SimpleStructMutation.cpp
+++ b/lib/Transforms/IPO/SimpleStructMutation.cpp
@@ -12,9 +12,14 @@
#include "llvm/Analysis/FindUnsafePointerTypes.h"
#include "TransformInternals.h"
#include <algorithm>
+#include <iostream>
+using std::vector;
+using std::set;
+using std::pair;
#include "llvm/Assembly/Writer.h"
+
// PruneTypes - Given a type Ty, make sure that neither it, or one of its
// subtypes, occur in TypesToModify.
//
@@ -26,7 +31,7 @@ static void PruneTypes(const Type *Ty, set<const StructType*> &TypesToModify,
// If the element is in TypesToModify, remove it now...
if (const StructType *ST = dyn_cast<StructType>(Ty)) {
TypesToModify.erase(ST); // This doesn't fail if the element isn't present
- cerr << "Unable to swap type: " << ST << endl;
+ std::cerr << "Unable to swap type: " << ST << "\n";
}
// Remove all types that this type contains as well... do not remove types
@@ -69,7 +74,8 @@ static inline void GetTransformation(const StructType *ST,
// Build mapping from index to size
for (unsigned i = 0; i < NumElements; ++i)
- ElList.push_back(make_pair(i, TD.getTypeSize(ST->getElementTypes()[i])));
+ ElList.push_back(
+ std::make_pair(i, TD.getTypeSize(ST->getElementTypes()[i])));
sort(ElList.begin(), ElList.end(), ptr_fun(FirstLess));
@@ -118,14 +124,14 @@ PrebuiltStructMutation::TransformsType
set<const Type*> ProcessedTypes;
for (set<PointerType*>::const_iterator I = UnsafePTys.begin(),
E = UnsafePTys.end(); I != E; ++I) {
- //cerr << "Pruning type: " << *I << endl;
+ //cerr << "Pruning type: " << *I << "\n";
PruneTypes(*I, TypesToModify, ProcessedTypes);
}
// Build up a set of structure types that we are going to modify, and
// information describing how to modify them.
- map<const StructType*, vector<int> > Transforms;
+ std::map<const StructType*, vector<int> > Transforms;
for (set<const StructType*>::iterator I = TypesToModify.begin(),
E = TypesToModify.end(); I != E; ++I) {
diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp
index 7948266c25..00acac8d1f 100644
--- a/lib/Transforms/Instrumentation/TraceValues.cpp
+++ b/lib/Transforms/Instrumentation/TraceValues.cpp
@@ -18,7 +18,8 @@
#include "llvm/Assembly/Writer.h"
#include "Support/StringExtras.h"
#include <sstream>
-
+using std::vector;
+using std::string;
// Add a prototype for printf if it is not already in the program.
//
@@ -110,8 +111,6 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, BasicBlock::iterator &BBI,
// Escape Message by replacing all % characters with %% chars.
unsigned Offset = 0;
while ((Offset = Message.find('%', Offset)) != string::npos) {
- string::iterator Offs = Message.begin()+Offset;
- //Message.replace(Offs, Offs+1, "%%");
Message.replace(Offset, 2, "%%");
Offset += 2; // Skip over the new %'s
}
@@ -140,7 +139,7 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, BasicBlock::iterator &BBI,
static void InsertVerbosePrintInst(Value *V, BasicBlock *BB,
BasicBlock::iterator &BBI,
const string &Message, Method *Printf) {
- ostringstream OutStr;
+ std::ostringstream OutStr;
if (V) WriteAsOperand(OutStr, V);
InsertPrintInst(V, BB, BBI, Message+OutStr.str()+" = ", Printf);
}
@@ -184,7 +183,7 @@ static void TraceValuesAtBBExit(BasicBlock *BB, Method *Printf,
// Copy all of the instructions into a vector to avoid problems with Setcc
const vector<Instruction*> Insts(BB->begin(), InsertPos);
- ostringstream OutStr;
+ std::ostringstream OutStr;
WriteAsOperand(OutStr, BB, false);
InsertPrintInst(0, BB, InsertPos, "LEAVING BB:" + OutStr.str(), Printf);
@@ -211,7 +210,7 @@ static inline void InsertCodeToShowMethodEntry(Method *M, Method *Printf) {
BasicBlock *BB = M->getEntryNode();
BasicBlock::iterator BBI = BB->begin();
- ostringstream OutStr;
+ std::ostringstream OutStr;
WriteAsOperand(OutStr, M, true);
InsertPrintInst(0, BB, BBI, "ENTERING METHOD: " + OutStr.str(), Printf);
@@ -231,7 +230,7 @@ static inline void InsertCodeToShowMethodExit(BasicBlock *BB, Method *Printf) {
BasicBlock::iterator BBI = BB->end()-1;
ReturnInst *Ret = cast<ReturnInst>(*BBI);
- ostringstream OutStr;
+ std::ostringstream OutStr;
WriteAsOperand(OutStr, BB->getParent(), true);
InsertPrintInst(0, BB, BBI, "LEAVING METHOD: " + OutStr.str(), Printf);
@@ -249,8 +248,6 @@ bool InsertTraceCode::doit(Method *M, bool traceBasicBlockExits,
vector<Instruction*> valuesStoredInMethod;
vector<BasicBlock*> exitBlocks;
- Module *module = M->getParent();
-
if (traceMethodEvents)
InsertCodeToShowMethodEntry(M, Printf);
diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp
index e47eb90642..f140676937 100644
--- a/lib/Transforms/LevelRaise.cpp
+++ b/lib/Transforms/LevelRaise.cpp
@@ -75,7 +75,7 @@ static bool HandleCastToPointer(BasicBlock::iterator BI,
}
}
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
Value *Src = CI->getOperand(0);
const Type *Result = ConvertableToGEP(DestPTy, Src, Indices, &BI);
if (Result == 0) return false; // Not convertable...
@@ -137,7 +137,7 @@ static bool PeepholeOptimizeAddCast(BasicBlock *BB, BasicBlock::iterator &BI,
if (!CompTy || !SrcPtr || !OffsetVal->getType()->isIntegral())
return false;
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
if (!ConvertableToGEP(SrcPtr->getType(), OffsetVal, Indices, &BI))
return false; // Not convertable... perhaps next time
@@ -174,7 +174,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
PRINT_PEEPHOLE1("cast-of-self-ty", CI);
CI->replaceAllUsesWith(Src);
if (!Src->hasName() && CI->hasName()) {
- string Name = CI->getName();
+ std::string Name = CI->getName();
CI->setName("");
Src->setName(Name, BB->getParent()->getSymbolTable());
}
@@ -299,7 +299,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
const Type *ElTy = 0;
// Build the index vector, full of all zeros
- vector<Value*> Indices;
+ std::vector<Value*> Indices;
Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
while (CurCTy && !isa<PointerType>(CurCTy)) {
if (const StructType *CurSTy = dyn_cast<StructType>(CurCTy)) {
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp
index a38dbc5617..45a57a2f43 100644
--- a/lib/Transforms/Scalar/ADCE.cpp
+++ b/lib/Transforms/Scalar/ADCE.cpp
@@ -17,6 +17,8 @@
#include "Support/DepthFirstIterator.h"
#include <set>
#include <algorithm>
+#include <iostream>
+using std::cerr;
#define DEBUG_ADCE 1
@@ -28,8 +30,8 @@
//
class ADCE {
Method *M; // The method that we are working on...
- vector<Instruction*> WorkList; // Instructions that just became live
- set<Instruction*> LiveSet; // The set of live instructions
+ std::vector<Instruction*> WorkList; // Instructions that just became live
+ std::set<Instruction*> LiveSet; // The set of live instructions
bool MadeChanges;
//===--------------------------------------------------------------------===//
@@ -66,8 +68,8 @@ private:
// fixupCFG - Walk the CFG in depth first order, eliminating references to
// dead blocks.
//
- BasicBlock *fixupCFG(BasicBlock *Head, set<BasicBlock*> &VisitedBlocks,
- const set<BasicBlock*> &AliveBlocks);
+ BasicBlock *fixupCFG(BasicBlock *Head, std::set<BasicBlock*> &VisitedBlocks,
+ const std::set<BasicBlock*> &AliveBlocks);
};
@@ -121,7 +123,7 @@ bool ADCE::doADCE() {
// AliveBlocks - Set of basic blocks that we know have instructions that are
// alive in them...
//
- set<BasicBlock*> AliveBlocks;
+ std::set<BasicBlock*> AliveBlocks;
// Process the work list of instructions that just became live... if they
// became live, then that means that all of their operands are neccesary as
@@ -169,7 +171,7 @@ bool ADCE::doADCE() {
// After the worklist is processed, recursively walk the CFG in depth first
// order, patching up references to dead blocks...
//
- set<BasicBlock*> VisitedBlocks;
+ std::set<BasicBlock*> VisitedBlocks;
BasicBlock *EntryBlock = fixupCFG(M->front(), VisitedBlocks, AliveBlocks);
if (EntryBlock && EntryBlock != M->front()) {
if (isa<PHINode>(EntryBlock->front())) {
@@ -194,7 +196,7 @@ bool ADCE::doADCE() {
} else {
// We need to move the new entry block to be the first bb of the method.
Method::iterator EBI = find(M->begin(), M->end(), EntryBlock);
- swap(*EBI, *M->begin()); // Exchange old location with start of method
+ std::swap(*EBI, *M->begin());// Exchange old location with start of method
MadeChanges = true;
}
}
@@ -242,8 +244,8 @@ bool ADCE::doADCE() {
// been in the alive set).
// 3. Return the nonnull child, or 0 if no non-null children.
//
-BasicBlock *ADCE::fixupCFG(BasicBlock *BB, set<BasicBlock*> &VisitedBlocks,
- const set<BasicBlock*> &AliveBlocks) {
+BasicBlock *ADCE::fixupCFG(BasicBlock *BB, std::set<BasicBlock*> &VisitedBlocks,
+ const std::set<BasicBlock*> &AliveBlocks) {
if (VisitedBlocks.count(BB)) return 0; // Revisiting a node? No update.
VisitedBlocks.insert(BB); // We have now visited this node!
diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp
index c267d95ea4..a961bad927 100644
--- a/lib/Transforms/Scalar/ConstantProp.cpp
+++ b/lib/Transforms/Scalar/ConstantProp.cpp
@@ -159,7 +159,7 @@ bool opt::ConstantFoldTerminator(TerminatorInst *T) {
bool opt::ConstantPropogation::doConstantPropogation(BasicBlock *BB,
BasicBlock::iterator &II) {
Instruction *Inst = *II;
- if (BinaryOperator *BInst = dyn_cast<BinaryOperator>(Inst)) {
+ if (isa<BinaryOperator>(Inst)) {
Constant *D1 = dyn_cast<Constant>(Inst->getOperand(0));
Constant *D2 = dyn_cast<Constant>(Inst->getOperand(1));
diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp
index 6c4e3d2a20..eadf7b18e0 100644
--- a/lib/Transforms/Scalar/DCE.cpp
+++ b/lib/Transforms/Scalar/DCE.cpp
@@ -117,7 +117,7 @@ static bool PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
// If there is more than one predecessor, and there are PHI nodes in
// the successor, then we need to add incoming edges for the PHI nodes
//
- const vector<BasicBlock*> BBPreds(BB->pred_begin(), BB->pred_end());
+ const std::vector<BasicBlock*> BBPreds(BB->pred_begin(), BB->pred_end());
// Check to see if one of the predecessors of BB is already a predecessor of
// Succ. If so, we cannot do the transformation!
@@ -134,7 +134,7 @@ static bool PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
Value *OldVal = PN->removeIncomingValue(BB);
assert(OldVal && "No entry in PHI for Pred BB!");
- for (vector<BasicBlock*>::const_iterator PredI = BBPreds.begin(),
+ for (std::vector<BasicBlock*>::const_iterator PredI = BBPreds.begin(),
End = BBPreds.end(); PredI != End; ++PredI) {
// Add an incoming value for each of the new incoming values...
PN->addIncoming(OldVal, *PredI);
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp
index d03b4f3f40..35844cadb6 100644
--- a/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -35,7 +35,7 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) {
// Transform all subloops before this loop...
bool Changed = reduce_apply_bool(Loop->getSubLoops().begin(),
Loop->getSubLoops().end(),
- std::bind1st(ptr_fun(TransformLoop), Loops));
+ std::bind1st(std::ptr_fun(TransformLoop), Loops));
// Get the header node for this loop. All of the phi nodes that could be
// induction variables must live in this basic block.
BasicBlock *Header = (BasicBlock*)Loop->getBlocks().front();
@@ -44,7 +44,7 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) {
// induction variables that they represent... stuffing the induction variable
// info into a vector...
//
- vector<InductionVariable> IndVars; // Induction variables for block
+ std::vector<InductionVariable> IndVars; // Induction variables for block
for (BasicBlock::iterator I = Header->begin();
PHINode *PN = dyn_cast<PHINode>(*I); ++I)
IndVars.push_back(InductionVariable(PN, Loops));
@@ -133,7 +133,7 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) {
Instruction *Val = IterCount;
if (!isa<ConstantInt>(IV->Step) || // If the step != 1
!cast<ConstantInt>(IV->Step)->equalsInt(1)) {
- string Name; // Create a scale by the step value...
+ std::string Name; // Create a scale by the step value...
if (IV->Phi->hasName()) Name = IV->Phi->getName()+"-scale";
// If the types are not compatible, insert a cast now...
@@ -148,7 +148,7 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) {
if (!isa<Constant>(IV->Start) || // If the start != 0
!cast<Constant>(IV->Start)->isNullValue()) {
- string Name; // Create a offset by the start value...
+ std::string Name; // Create a offset by the start value...
if (IV->Phi->hasName()) Name = IV->Phi->getName()+"-offset";
// If the types are not compatible, insert a cast now...
@@ -170,7 +170,7 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) {
IV->Phi->replaceAllUsesWith(Val);
// Move the PHI name to it's new equivalent value...
- string OldName = IV->Phi->getName();
+ std::string OldName = IV->Phi->getName();
IV->Phi->setName("");
Val->setName(OldName);
diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp
index d4b7bc5010..93ab189dee 100644
--- a/lib/Transforms/Scalar/InductionVars.cpp
+++ b/lib/Transforms/Scalar/InductionVars.cpp
@@ -27,6 +27,8 @@
#include "llvm/iPHINode.h"
#include "Support/STLExtras.h"
#include <algorithm>
+#include <iostream>
+using std::cerr;
#include "llvm/Analysis/LoopDepth.h"
@@ -176,7 +178,7 @@ static inline bool isSimpleInductionVar(PHINode *PN) {
// present induction variables (instead of always using uint)
//
static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) {
- string PHIName, AddName;
+ std::string PHIName, AddName;
BasicBlock *Header = Int->getHeaderNode();
Method *M = Header->getParent();
@@ -205,7 +207,7 @@ static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) {
assert(++PI == Header->pred_end() && "Header node should have 2 preds!");
// Make Pred1 be the loop entrance predecessor, Pred2 be the Loop predecessor
- if (Int->contains(Pred1)) swap(Pred1, Pred2);
+ if (Int->contains(Pred1)) std::swap(Pred1, Pred2);
assert(!Int->contains(Pred1) && "Pred1 should be loop entrance!");
assert( Int->contains(Pred2) && "Pred2 should be looping edge!");
@@ -250,7 +252,7 @@ static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) {
static bool ProcessInterval(cfg::Interval *Int) {
if (!Int->isLoop()) return false; // Not a loop? Ignore it!
- vector<PHINode *> InductionVars;
+ std::vector<PHINode *> InductionVars;
BasicBlock *Header = Int->getHeaderNode();
// Loop over all of the PHI nodes in the interval header...
@@ -278,7 +280,7 @@ static bool ProcessInterval(cfg::Interval *Int) {
if (isLoopInvariant(Int, V2)) {
// They *are* loop invariant. Exchange BB1/BB2 and V1/V2 so that
// V1 is always the loop invariant computation.
- swap(V1, V2); swap(BB1, BB2);
+ std::swap(V1, V2); std::swap(BB1, BB2);
} else {
// Neither value is loop invariant. Must not be an induction variable.
// This case can happen if there is an unreachable loop in the CFG that
@@ -292,7 +294,7 @@ static bool ProcessInterval(cfg::Interval *Int) {
// anything about BB2/V2. Check now to see if V2 is a linear induction
// variable.
//
- cerr << "Found loop invariant computation: " << V1 << endl;
+ cerr << "Found loop invariant computation: " << V1 << "\n";
if (!isLinearInductionVariable(Int, V2, PN))
continue; // No, it is not a linear ind var, ignore the PHI node.
@@ -308,7 +310,7 @@ static bool ProcessInterval(cfg::Interval *Int) {
if (InductionVars.empty()) return false;
// Search to see if there is already a "simple" induction variable.
- vector<PHINode*>::iterator It =
+ std::vector<PHINode*>::iterator It =
find_if(InductionVars.begin(), InductionVars.end(), isSimpleInductionVar);
PHINode *PrimaryIndVar;
@@ -329,7 +331,7 @@ static bool ProcessInterval(cfg::Interval *Int) {
"How could Primary IndVar not be in the header!?!!?");
if (i != Header->begin())
- iter_swap(i, Header->begin());
+ std::iter_swap(i, Header->begin());
}
// Now we know that there is a simple induction variable PrimaryIndVar.
@@ -364,7 +366,7 @@ static bool ProcessIntervalPartition(cfg::IntervalPartition &IP) {
// variables in intervals that represent loops.
//
return reduce_apply(IP.begin(), IP.end(), bitwise_or<bool>(), false,
- ptr_fun(ProcessInterval));
+ std::ptr_fun(ProcessInterval));
}
// DoInductionVariableCannonicalize - Simplify induction variables in loops.
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 87f8ed1897..795418f939 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -76,7 +76,7 @@ static Instruction *CombineIndicies(MemAccessInst *MAI) {
dyn_cast<GetElementPtrInst>(MAI->getPointerOperand());
if (!Src) return 0;
- vector<Value *> Indices;
+ std::vector<Value *> Indices;
// Only special case we have to watch out for is pointer arithmetic on the
// 0th index of MAI.
@@ -128,7 +128,7 @@ bool InstructionCombining::CombineInstruction(Instruction *I) {
bool InstructionCombining::doit(Method *M) {
// Start the worklist out with all of the instructions in the method in it.
- vector<Instruction*> WorkList(M->inst_begin(), M->inst_end());
+ std::vector<Instruction*> WorkList(M->inst_begin(), M->inst_end());
while (!WorkList.empty()) {
Instruction *I = WorkList.back(); // Get an instruction from the worklist
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index 26a52d61bf..68be844095 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -30,6 +30,8 @@
#include <algorithm>
#include <map>
#include <set>
+#include <iostream>
+using std::cerr;
// InstVal class - This class represents the different lattice values that an
// instruction may occupy. It is a simple class with value semantics. The
@@ -84,13 +86,13 @@ public:
// It's public interface consists of a constructor and a doSCCP() method.
//
class SCCP {
- Method *M; // The method that we are working on...
+ Method *M; // The method that we are working on...
- set<BasicBlock*> BBExecutable; // The basic blocks that are executable
- map<Value*, InstVal> ValueState; // The state each value is in...
+ std::set<BasicBlock*> BBExecutable;// The basic blocks that are executable
+ std::map<Value*, InstVal> ValueState; // The state each value is in...
- vector<Instruction*> InstWorkList; // The instruction work list
- vector<BasicBlock*> BBWorkList; // The BasicBlock work list
+ std::vector<Instruction*> InstWorkList;// The instruction work list
+ std::vector<BasicBlock*> BBWorkList; // The BasicBlock work list
//===--------------------------------------------------------------------===//
// The public interface for this class
@@ -144,7 +146,7 @@ private:
// Instruction object, then use this accessor to get its value from the map.
//
inline InstVal &getValueState(Value *V) {
- map<Value*, InstVal>::iterator I = ValueState.find(V);
+ std::map<Value*, InstVal>::iterator I = ValueState.find(V);
if (I != ValueState.end()) return I->second; // Common case, in the map
if (Constant *CPV = dyn_cast<Constant>(V)) { // Constants are constant
diff --git a/lib/Transforms/Scalar/SymbolStripping.cpp b/lib/Transforms/Scalar/SymbolStripping.cpp
index bb4f01c90b..417376b89d 100644
--- a/lib/Transforms/Scalar/SymbolStripping.cpp
+++ b/lib/Transforms/Scalar/SymbolStripping.cpp
@@ -24,7 +24,7 @@ static bool StripSymbolTable(SymbolTable *SymTab) {
bool RemovedSymbol = false;
for (SymbolTable::iterator I = SymTab->begin(); I != SymTab->end(); ++I) {
- map<const string, Value *> &Plane = I->second;
+ std::map<const std::string, Value *> &Plane = I->second;
SymbolTable::type_iterator B;
while ((B = Plane.begin()) != Plane.end()) { // Found nonempty type plane!
diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp
index cd6288540a..6c7f856619 100644
--- a/lib/Transforms/TransformInternals.cpp
+++ b/lib/Transforms/TransformInternals.cpp
@@ -82,7 +82,7 @@ void ReplaceInstWithInst(Instruction *From, Instruction *To) {
// false if you want a leaf
//
const Type *getStructOffsetType(const Type *Ty, unsigned &Offset,
- vector<Value*> &Offsets,
+ std::vector<Value*> &Offsets,
bool StopEarly = true) {
if (Offset == 0 && StopEarly && !Offsets.empty())
return Ty; // Return the leaf type
@@ -130,7 +130,7 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset,
// instruction. The type returned is the root type that the GEP would point to
//
const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal,
- vector<Value*> &Indices,
+ std::vector<Value*> &Indices,
BasicBlock::iterator *BI = 0) {
const CompositeType *CompTy = dyn_cast<CompositeType>(Ty);
if (CompTy == 0) return 0;
diff --git a/lib/Transforms/TransformInternals.h b/lib/Transforms/TransformInternals.h
index 200a4d7b98..7bc3df4fc3 100644
--- a/lib/Transforms/TransformInternals.h
+++ b/lib/Transforms/TransformInternals.h
@@ -24,7 +24,7 @@
//
extern const TargetData TD;
-static int getConstantValue(const ConstantInt *CPI) {
+static inline int getConstantValue(const ConstantInt *CPI) {
if (const ConstantSInt *CSI = dyn_cast<ConstantSInt>(CPI))
return CSI->getValue();
return cast<ConstantUInt>(CPI)->getValue();
@@ -65,25 +65,26 @@ void ReplaceInstWithInst(Instruction *From, Instruction *To);
// If BI is nonnull, cast instructions are inserted as appropriate for the
// arguments of the getelementptr.
//
-const Type *ConvertableToGEP(const Type *Ty, Value *V, vector<Value*> &Indices,
+const Type *ConvertableToGEP(const Type *Ty, Value *V,
+ std::vector<Value*> &Indices,
BasicBlock::iterator *BI = 0);
// ------------- Expression Conversion ---------------------
-typedef map<const Value*, const Type*> ValueTypeCache;
+typedef std::map<const Value*, const Type*> ValueTypeCache;
struct ValueMapCache {
// Operands mapped - Contains an entry if the first value (the user) has had
// the second value (the operand) mapped already.
//
- set<const User*> OperandsMapped;
+ std::set<const User*> OperandsMapped;
// Expression Map - Contains an entry from the old value to the new value of
// an expression that has been converted over.
//
- map<const Value *, Value *> ExprMap;
- typedef map<const Value *, Value *> ExprMapTy;
+ std::map<const Value *, Value *> ExprMap;
+ typedef std::map<const Value *, Value *> ExprMapTy;
};
@@ -137,7 +138,7 @@ public:
// false if you want a leaf
//
const Type *getStructOffsetType(const Type *Ty, unsigned &Offset,
- vector<Value*> &Offsets,
+ std::vector<Value*> &Offsets,
bool StopEarly = true);
#endif
diff --git a/lib/Transforms/Utils/Linker.cpp b/lib/Transforms/Utils/Linker.cpp
index f04c8a46a3..e1622529c2 100644
--- a/lib/Transforms/Utils/Linker.cpp
+++ b/lib/Transforms/Utils/Linker.cpp
@@ -17,6 +17,10 @@
#include "llvm/DerivedTypes.h"
#include "llvm/iOther.h"
#include "llvm/ConstantVals.h"
+#include <iostream>
+using std::cerr;
+using std::string;
+using std::map;
// Error - Simple wrapper function to conditionally assign to E and return true.
// This just makes error return conditions a little bit simpler...
@@ -70,7 +74,7 @@ static void PrintMap(const map<const Value*, Value*> &M) {
for (map<const Value*, Value*>::const_iterator I = M.begin(), E = M.end();
I != E; ++I) {
cerr << " Fr: " << (void*)I->first << " " << I->first
- << " To: " << (void*)I->second << " " << I->second << endl;
+ << " To: " << (void*)I->second << " " << I->second << "\n";
}
}
@@ -97,15 +101,15 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
Constant *Result = 0;
if (ConstantArray *CPA = dyn_cast<ConstantArray>(CPV)) {
- const vector<Use> &Ops = CPA->getValues();
- vector<Constant*> Operands(Ops.size());
+ const std::vector<Use> &Ops = CPA->getValues();
+ std::vector<Constant*> Operands(Ops.size());
for (unsigned i = 0; i < Ops.size(); ++i)
Operands[i] =
cast<Constant>(RemapOperand(Ops[i], LocalMap, GlobalMap));
Result = ConstantArray::get(cast<ArrayType>(CPA->getType()), Operands);
} else if (ConstantStruct *CPS = dyn_cast<ConstantStruct>(CPV)) {
- const vector<Use> &Ops = CPS->getValues();
- vector<Constant*> Operands(Ops.size());
+ const std::vector<Use> &Ops = CPS->getValues();
+ std::vector<Constant*> Operands(Ops.size());
for (unsigned i = 0; i < Ops.size(); ++i)
Operands[i] =
cast<Constant>(RemapOperand(Ops[i], LocalMap, GlobalMap));
@@ -120,7 +124,7 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
}
// Cache the mapping in our local map structure...
- LocalMap.insert(make_pair(In, CPV));
+ LocalMap.insert(std::make_pair(In, CPV));
return Result;
}
@@ -132,7 +136,7 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
PrintMap(*GlobalMap);
}
- cerr << "Couldn't remap value: " << (void*)In << " " << In << endl;
+ cerr << "Couldn't remap value: " << (void*)In << " " << In << "\n";
assert(0 && "Couldn't remap value!");
return 0;
}
@@ -172,7 +176,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
" - Global variables differ in const'ness");
// Okay, everything is cool, remember the mapping...
- ValueMap.insert(make_pair(SGV, DGV));
+ ValueMap.insert(std::make_pair(SGV, DGV));
} else {
// No linking to be performed, simply create an identical version of the
// symbol over in the dest module... the initializer will be filled in
@@ -186,7 +190,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
Dest->getGlobalList().push_back(DGV);
// Make sure to remember this mapping...
- ValueMap.insert(make_pair(SGV, DGV));
+ ValueMap.insert(std::make_pair(SGV, DGV));
}
}
return false;
@@ -262,7 +266,7 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src,
SM->getName() + "\" - Method is already defined!");
// Otherwise, just remember this mapping...
- ValueMap.insert(make_pair(SM, DM));
+ ValueMap.insert(std::make_pair(SM, DM));
} else {
// Method does not already exist, simply insert an external method
// signature identical to SM into the dest module...
@@ -273,7 +277,7 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src,
Dest->getMethodList().push_back(DM);
// ... and remember this mapping...
- ValueMap.insert(make_pair(SM, DM));
+ ValueMap.insert(std::make_pair(SM, DM));
}
}
return false;
@@ -300,7 +304,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src,
Dest->getArgumentList().push_back(DMA);
// Add a mapping to our local map
- LocalMap.insert(make_pair(SMA, DMA));
+ LocalMap.insert(std::make_pair(SMA, DMA));
}
// Loop over all of the basic blocks, copying the instructions over...
@@ -310,7 +314,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src,
// Create new basic block and add to mapping and the Dest method...
BasicBlock *DBB = new BasicBlock(SBB->getName(), Dest);
- LocalMap.insert(make_pair(SBB, DBB));
+ LocalMap.insert(std::make_pair(SBB, DBB));
// Loop over all of the instructions in the src basic block, copying them
// over. Note that this is broken in a strict sense because the cloned
@@ -324,7 +328,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src,
Instruction *DI = SI->clone();
DI->setName(SI->getName());
DBB->getInstList().push_back(DI);
- LocalMap.insert(make_pair(SI, DI));
+ LocalMap.insert(std::make_pair(SI, DI));
}
}
diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp
index 666b6d976e..ca1085e3ed 100644
--- a/lib/Transforms/Utils/LowerAllocations.cpp
+++ b/lib/Transforms/Utils/LowerAllocations.cpp
@@ -14,6 +14,8 @@
#include "llvm/iOther.h"
#include "llvm/SymbolTable.h"
#include "llvm/ConstantVals.h"
+using std::vector;
+
// doPassInitialization - For the lower allocations pass, this ensures that a
// module contains a declaration for a malloc and a free function.
diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
index efc7676bb7..56c4b204ca 100644
--- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
+++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
@@ -11,6 +11,7 @@
#include "llvm/iTerminators.h"
#include "llvm/iPHINode.h"
#include "llvm/Type.h"
+using std::vector;
// UnifyAllExitNodes - Unify all exit nodes of the CFG by creating a new
// BasicBlock, and converting all returns to unconditional branches to this
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index 2b3a1c4c22..c218c0fcd0 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -26,6 +26,10 @@
#include "Support/STLExtras.h"
#include <algorithm>
#include <map>
+using std::string;
+using std::map;
+using std::vector;
+using std::ostream;
static const Module *getModuleFromVal(const Value *V) {
if (const MethodArgument *MA =dyn_cast<const MethodArgument>(V))
@@ -112,7 +116,7 @@ static void fillTypeNameTable(const Module *M,
const Type *Ty = cast<const Type>(I->second);
if (!isa<PointerType>(Ty) ||
!cast<PointerType>(Ty)->getElementType()->isPrimitiveType())
- TypeNames.insert(make_pair(Ty, "%"+I->first));
+ TypeNames.insert(std::make_pair(Ty, "%"+I->first));
}
}
}
@@ -215,7 +219,7 @@ static ostream &printTypeInt(ostream &Out, const Type *Ty,
//
vector<const Type *> TypeStack;
string TypeName = calcTypeName(Ty, TypeStack, TypeNames);
- TypeNames.insert(make_pair(Ty, TypeName)); // Cache type name for later use
+ TypeNames.insert(std::make_pair(Ty, TypeName));//Cache type name for later use
return Out << TypeName;
}
@@ -331,7 +335,7 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
writeOperand(GV->getInitializer(), false, false);
printInfoComment(GV);
- Out << endl;
+ Out << "\n";
}
@@ -348,7 +352,7 @@ void AssemblyWriter::printSymbolTable(const SymbolTable &ST) {
if (const Constant *CPV = dyn_cast<const Constant>(V)) {
printConstant(CPV);
} else if (const Type *Ty = dyn_cast<const Type>(V)) {
- Out << "\t%" << I->first << " = type " << Ty->getDescription() << endl;
+ Out << "\t%" << I->first << " = type " << Ty->getDescription() << "\n";
}
}
}
@@ -378,7 +382,7 @@ void AssemblyWriter::printConstant(const Constant *CPV) {
else Out << "<badref>";
}
- Out << endl;
+ Out << "\n";
}
// printMethod - Print all aspects of a method.
@@ -614,7 +618,7 @@ void AssemblyWriter::printInstruction(const Instruction *I) {
}
printInfoComment(I);
- Out << endl;
+ Out << "\n";
}
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp
index 861aea43c2..df999b84bf 100644
--- a/lib/VMCore/BasicBlock.cpp
+++ b/lib/VMCore/BasicBlock.cpp
@@ -18,7 +18,7 @@
//
template class ValueHolder<Instruction, BasicBlock, Method>;
-BasicBlock::BasicBlock(const string &name, Method *Parent)
+BasicBlock::BasicBlock(const std::string &name, Method *Parent)
: Value(Type::LabelTy, Value::BasicBlockVal, name), InstList(this, 0),
machineInstrVec(new MachineCodeForBasicBlock) {
if (Parent)
@@ -32,7 +32,7 @@ BasicBlock::~BasicBlock() {
}
// Specialize setName to take care of symbol table majik
-void BasicBlock::setName(const string &name, SymbolTable *ST) {
+void BasicBlock::setName(const std::string &name, SymbolTable *ST) {
Method *P;
assert((ST == 0 || (!getParent() || ST == getParent()->getSymbolTable())) &&
"Invalid symtab argument!");
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 257bd7622c..d9a2fa7431 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -15,6 +15,10 @@
#include <algorithm>
#include <assert.h>
+using std::map;
+using std::pair;
+using std::make_pair;
+
ConstantBool *ConstantBool::True = new ConstantBool(true);
ConstantBool *ConstantBool::False = new ConstantBool(false);
@@ -24,7 +28,7 @@ ConstantBool *ConstantBool::False = new ConstantBool(false);
//===----------------------------------------------------------------------===//
// Specialize setName to take care of symbol table majik
-void Constant::setName(const string &Name, SymbolTable *ST) {
+void Constant::setName(const std::string &Name, SymbolTable *ST) {
assert(ST && "Type::setName - Must provide symbol table argument!");
if (Name.size()) ST->insert(Name, this);
@@ -56,6 +60,7 @@ Constant *Constant::getNullConstant(const Type *Ty) {
#ifndef NDEBUG
#include "llvm/Assembly/Writer.h"
+using std::cerr;
#endif
void Constant::destroyConstantImpl() {
@@ -70,8 +75,8 @@ void Constant::destroyConstantImpl() {
Value *V = use_back();
#ifndef NDEBUG // Only in -g mode...
if (!isa<Constant>(V)) {
- cerr << "While deleting: " << this << endl;
- cerr << "Use still stuck around after Def is destroyed: " << V << endl;
+ cerr << "While deleting: " << this << "\n";
+ cerr << "Use still stuck around after Def is destroyed: " << V << "\n";
}
#endif
assert(isa<Constant>(V) && "References remain to ConstantPointerRef!");
@@ -115,7 +120,7 @@ ConstantFP::ConstantFP(const Type *Ty, double V) : Constant(Ty) {
}
ConstantArray::ConstantArray(const ArrayType *T,
- const vector<Constant*> &V) : Constant(T) {
+ const std::vector<Constant*> &V) : Constant(T) {
for (unsigned i = 0; i < V.size(); i++) {
assert(V[i]->getType() == T->getElementType());
Operands.push_back(Use(V[i], this));
@@ -123,7 +128,7 @@ ConstantArray::ConstantArray(const ArrayType *T,
}
ConstantStruct::ConstantStruct(const StructType *T,
- const vector<Constant*> &V) : Constant(T) {
+ const std::vector<Constant*> &V) : Constant(T) {
const StructType::ElementTypes &ETypes = T->getElementTypes();
for (unsigned i = 0; i < V.size(); i++) {
@@ -142,24 +147,24 @@ ConstantPointerRef::ConstantPointerRef(GlobalValue *GV)
//===----------------------------------------------------------------------===//
// getStrValue implementations
-string ConstantBool::getStrValue() const {
+std::string ConstantBool::getStrValue() const {
return Val ? "true" : "false";
}
-string ConstantSInt::getStrValue() const {
+std::string ConstantSInt::getStrValue() const {
return itostr(Val.Signed);
}
-string ConstantUInt::getStrValue() const {
+std::string ConstantUInt::getStrValue() const {
return utostr(Val.Unsigned);
}
-string ConstantFP::getStrValue() const {
+std::string ConstantFP::getStrValue() const {
return ftostr(Val);
}
-string ConstantArray::getStrValue() const {
- string Result;
+std::string ConstantArray::getStrValue() const {
+ std::string Result;
// As a special case, print the array as a string if it is an array of
// ubytes or an array of sbytes with positive values.
@@ -208,8 +213,8 @@ string ConstantArray::getStrValue() const {
return Result;
}
-string ConstantStruct::getStrValue() const {
- string Result = "{";
+std::string ConstantStruct::getStrValue() const {
+ std::string Result = "{";
if (Operands.size()) {
Result += " " + Operands[0]->getType()->getDescription() +
" " + cast<Constant>(Operands[0])->getStrValue();
@@ -221,11 +226,11 @@ string ConstantStruct::getStrValue() const {
return Result + " }";
}
-string ConstantPointerNull::getStrValue() const {
+std::string ConstantPointerNull::getStrValue() const {
return "null";
}
-string ConstantPointerRef::getStrValue() const {
+std::string ConstantPointerRef::getStrValue() const {
const GlobalValue *V = getValue();
if (V->hasName()) return "%" + V->getName();
@@ -233,7 +238,7 @@ string ConstantPointerRef::getStrValue() const {
int Slot = Table->getValSlot(V);
delete Table;
- if (Slot >= 0) return string(" %") + itostr(Slot);
+ if (Slot >= 0) return std::string(" %") + itostr(Slot);
else return "<pointer reference badref>";
}
@@ -337,7 +342,7 @@ unsigned ConstantFP::hash(const Type *Ty, double V) {
}
unsigned ConstantArray::hash(const ArrayType *Ty,
- const vector<Constant*> &V) {
+ const std::vector<Constant*> &V) {
unsigned Result = (Ty->getUniqueID() << 5) ^ (Ty->getUniqueID() * 7);
for (unsigned i = 0; i < V.size(); ++i)
Result ^= V[i]->getHash() << (i & 7);
@@ -345,7 +350,7 @@ unsigned ConstantArray::hash(const ArrayType *Ty,
}
unsigned ConstantStruct::hash(const StructType *Ty,
- const vector<Constant*> &V) {
+ const std::vector<Constant*> &V) {
unsigned Result = (Ty->getUniqueID() << 5) ^ (Ty->getUniqueID() * 7);
for (unsigned i = 0; i < V.size(); ++i)
Result ^= V[i]->getHash() << (i & 7);
@@ -418,10 +423,10 @@ ConstantFP *ConstantFP::get(const Type *Ty, double V) {
//---- ConstantArray::get() implementation...
//
-static ValueMap<vector<Constant*>, ConstantArray> ArrayConstants;
+static ValueMap<std::vector<Constant*>, ConstantArray> ArrayConstants;
ConstantArray *ConstantArray::get(const ArrayType *Ty,
- const vector<Constant*> &V) {
+ const std::vector<Constant*> &V) {
ConstantArray *Result = ArrayConstants.get(Ty, V);
if (!Result) // If no preexisting value, create one now...
ArrayConstants.add(Ty, V, Result = new ConstantArray(Ty, V));
@@ -432,8 +437,8 @@ ConstantArray *ConstantArray::get(const ArrayType *Ty,
// contain the specified string. A null terminator is added to the specified
// string so that it may be used in a natural way...
//
-ConstantArray *ConstantArray::get(const string &Str) {
- vector<Constant*> ElementVals;
+ConstantArray *ConstantArray::get(const std::string &Str) {
+ std::vector<Constant*> ElementVals;
for (unsigned i = 0; i < Str.length(); ++i)
ElementVals.push_back(ConstantSInt::get(Type::SByteTy, Str[i]));
@@ -455,10 +460,10 @@ void ConstantArray::destroyConstant() {
//---- ConstantStruct::get() implementation...
//
-static ValueMap<vector<Constant*>, ConstantStruct> StructConstants;
+static ValueMap<std::vector<Constant*>, ConstantStruct> StructConstants;
ConstantStruct *ConstantStruct::get(const StructType *Ty,
- const vector<Constant*> &V) {
+ const std::vector<Constant*> &V) {
ConstantStruct *Result = StructConstants.get(Ty, V);
if (!Result) // If no preexisting value, create one now...
StructConstants.add(Ty, V, Result = new ConstantStruct(Ty, V));
diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp
index 2ed02dbed2..2e4f6e4df1 100644
--- a/lib/VMCore/Dominators.cpp
+++ b/lib/VMCore/Dominators.cpp
@@ -10,6 +10,8 @@
#include "Support/DepthFirstIterator.h"
#include "Support/STLExtras.h"
#include <algorithm>
+using std::set;
+
//===----------------------------------------------------------------------===//
// Helper Template
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index 4b38ce1196..e7d10c1496 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -25,7 +25,7 @@
template class ValueHolder<MethodArgument, Method, Method>;
template class ValueHolder<BasicBlock , Method, Method>;
-Method::Method(const MethodType *Ty, bool isInternal, const string &name)
+Method::Method(const MethodType *Ty, bool isInternal, const std::string &name)
: GlobalValue(PointerType::get(Ty), Value::MethodVal, isInternal, name),
SymTabValue(this), BasicBlocks(this), ArgumentList(this, this) {
assert(::isa<MethodType>(Ty) && "Method signature must be of method type!");
@@ -45,7 +45,7 @@ Method::~Method() {
}
// Specialize setName to take care of symbol table majik
-void Method::setName(const string &name, SymbolTable *ST) {
+void Method::setName(const std::string &name, SymbolTable *ST) {
Module *P;
assert((ST == 0 || (!getParent() || ST == getParent()->getSymbolTable())) &&
"Invalid symtab argument!");
@@ -87,14 +87,14 @@ void Method::dropAllReferences() {
GlobalVariable::GlobalVariable(const Type *Ty, bool constant, bool isIntern,
Constant *Initializer = 0,
- const string &Name = "")
+ const std::string &Name = "")
: GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, isIntern, Name),
isConstantGlobal(constant) {
if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
}
// Specialize setName to take care of symbol table majik
-void GlobalVariable::setName(const string &name, SymbolTable *ST) {
+void GlobalVariable::setName(const std::string &name, SymbolTable *ST) {
Module *P;
assert((ST == 0 || (!getParent() || ST == getParent()->getSymbolTable())) &&
"Invalid symtab argument!");
diff --git a/lib/VMCore/InstrTypes.cpp b/lib/VMCore/InstrTypes.cpp
index 69a703c0c7..a4c8212632 100644
--- a/lib/VMCore/InstrTypes.cpp
+++ b/lib/VMCore/InstrTypes.cpp
@@ -21,7 +21,7 @@ TerminatorInst::TerminatorInst(Instruction::TermOps iType)
}
TerminatorInst::TerminatorInst(const Type *Ty, Instruction::TermOps iType,
- const string &Name = "")
+ const std::string &Name = "")
: Instruction(Ty, iType, Name) {
}
@@ -31,7 +31,7 @@ TerminatorInst::TerminatorInst(const Type *Ty, Instruction::TermOps iType,
//===----------------------------------------------------------------------===//
// Specialize setName to take care of symbol table majik
-void MethodArgument::setName(const string &name, SymbolTable *ST) {
+void MethodArgument::setName(const std::string &name, SymbolTable *ST) {
Method *P;
assert((ST == 0 || (!getParent() || ST == getParent()->getSymbolTable())) &&
"Invalid symtab argument!");
@@ -45,7 +45,7 @@ void MethodArgument::setName(const string &name, SymbolTable *ST) {
// PHINode Class
//===----------------------------------------------------------------------===//
-PHINode::PHINode(const Type *Ty, const string &name)
+PHINode::PHINode(const Type *Ty, const std::string &name)
: Instruction(Ty, Instruction::PHINode, name) {
}
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index 8b37510d35..186c85007e 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -10,7 +10,7 @@
#include "llvm/SymbolTable.h"
#include "llvm/CodeGen/MachineInstr.h"
-Instruction::Instruction(const Type *ty, unsigned it, const string &Name)
+Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name)
: User(ty, Value::InstructionVal, Name),
machineInstrVec(new MachineCodeForVMInstr) {
Parent = 0;
@@ -23,7 +23,7 @@ Instruction::~Instruction() {
}
// Specialize setName to take care of symbol table majik
-void Instruction::setName(const string &name, SymbolTable *ST) {
+void Instruction::setName(const std::string &name, SymbolTable *ST) {
BasicBlock *P = 0; Method *PP = 0;
assert((ST == 0 || !getParent() || !getParent()->getParent() ||
ST == getParent()->getParent()->getSymbolTable()) &&
@@ -44,7 +44,7 @@ void Instruction::addMachineInstruction(MachineInstr* minstr) {
// sequence of forward declarations. Trying to fix that will
// cause a serious circularity in link order.
//
-const vector<Value*> &Instruction::getTempValuesForMachineCode() const {
+const std::vector<Value*> &Instruction::getTempValuesForMachineCode() const {
return machineInstrVec->getTempValues();
}
#endif
diff --git a/lib/VMCore/Linker.cpp b/lib/VMCore/Linker.cpp
index f04c8a46a3..e1622529c2 100644
--- a/lib/VMCore/Linker.cpp
+++ b/lib/VMCore/Linker.cpp
@@ -17,6 +17,10 @@
#include "llvm/DerivedTypes.h"
#include "llvm/iOther.h"
#include "llvm/ConstantVals.h"
+#include <iostream>
+using std::cerr;
+using std::string;
+using std::map;
// Error - Simple wrapper function to conditionally assign to E and return true.
// This just makes error return conditions a little bit simpler...
@@ -70,7 +74,7 @@ static void PrintMap(const map<const Value*, Value*> &M) {
for (map<const Value*, Value*>::const_iterator I = M.begin(), E = M.end();
I != E; ++I) {
cerr << " Fr: " << (void*)I->first << " " << I->first
- << " To: " << (void*)I->second << " " << I->second << endl;
+ << " To: " << (void*)I->second << " " << I->second << "\n";
}
}
@@ -97,15 +101,15 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
Constant *Result = 0;
if (ConstantArray *CPA = dyn_cast<ConstantArray>(CPV)) {
- const vector<Use> &Ops = CPA->getValues();
- vector<Constant*> Operands(Ops.size());
+ const std::vector<Use> &Ops = CPA->getValues();
+ std::vector<Constant*> Operands(Ops.size());
for (unsigned i = 0; i < Ops.size(); ++i)
Operands[i] =
cast<Constant>(RemapOperand(Ops[i], LocalMap, GlobalMap));
Result = ConstantArray::get(cast<ArrayType>(CPA->getType()), Operands);
} else if (ConstantStruct *CPS = dyn_cast<ConstantStruct>(CPV)) {
- const vector<Use> &Ops = CPS->getValues();
- vector<Constant*> Operands(Ops.size());
+ const std::vector<Use> &Ops = CPS->getValues();
+ std::vector<Constant*> Operands(Ops.size());
for (unsigned i = 0; i < Ops.size(); ++i)
Operands[i] =
cast<Constant>(RemapOperand(Ops[i], LocalMap, GlobalMap));
@@ -120,7 +124,7 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
}
// Cache the mapping in our local map structure...
- LocalMap.insert(make_pair(In, CPV));
+ LocalMap.insert(std::make_pair(In, CPV));
return Result;
}
@@ -132,7 +136,7 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
PrintMap(*GlobalMap);
}
- cerr << "Couldn't remap value: " << (void*)In << " " << In << endl;
+ cerr << "Couldn't remap value: " << (void*)In << " " << In << "\n";
assert(0 && "Couldn't remap value!");
return 0;
}
@@ -172,7 +176,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
" - Global variables differ in const'ness");
// Okay, everything is cool, remember the mapping...
- ValueMap.insert(make_pair(SGV, DGV));
+ ValueMap.insert(std::make_pair(SGV, DGV));
} else {
// No linking to be performed, simply create an identical version of the
// symbol over in the dest module... the initializer will be filled in
@@ -186,7 +190,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
Dest->getGlobalList().push_back(DGV);
// Make sure to remember this mapping...
- ValueMap.insert(make_pair(SGV, DGV));
+ ValueMap.insert(std::make_pair(SGV, DGV));
}
}
return false;
@@ -262,7 +266,7 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src,
SM->getName() + "\" - Method is already defined!");
// Otherwise, just remember this mapping...
- ValueMap.insert(make_pair(SM, DM));
+ ValueMap.insert(std::make_pair(SM, DM));
} else {
// Method does not already exist, simply insert an external method
// signature identical to SM into the dest module...
@@ -273,7 +277,7 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src,
Dest->getMethodList().push_back(DM);
// ... and remember this mapping...
- ValueMap.insert(make_pair(SM, DM));
+ ValueMap.insert(std::make_pair(SM, DM));
}
}
return false;
@@ -300,7 +304,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src,
Dest->getArgumentList().push_back(DMA);
// Add a mapping to our local map
- LocalMap.insert(make_pair(SMA, DMA));
+ LocalMap.insert(std::make_pair(SMA, DMA));
}
// Loop over all of the basic blocks, copying the instructions over...
@@ -310,7 +314,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src,
// Create new basic block and add to mapping and the Dest method...
BasicBlock *DBB = new BasicBlock(SBB->getName(), Dest);
- LocalMap.insert(make_pair(SBB, DBB));
+ LocalMap.insert(std::make_pair(SBB, DBB));
// Loop over all of the instructions in the src basic block, copying them
// over. Note that this is broken in a strict sense because the cloned
@@ -324,7 +328,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src,
Instruction *DI = SI->clone();
DI->setName(SI->getName());
DBB->getInstList().push_back(DI);
- LocalMap.insert(make_pair(SI, DI));
+ LocalMap.insert(std::make_pair(SI, DI));
}
}
diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp
index a42535580b..606d3aef14 100644
--- a/lib/VMCore/Module.cpp
+++ b/lib/VMCore/Module.cpp
@@ -24,7 +24,7 @@ template class ValueHolder<Method, Module, Module>;
// Define the GlobalValueRefMap as a struct that wraps a map so that we don't
// have Module.h depend on <map>
//
-struct GlobalValueRefMap : public map<GlobalValue*, ConstantPointerRef*>{
+struct GlobalValueRefMap : public std::map<GlobalValue*, ConstantPointerRef*>{
};
@@ -97,7 +97,7 @@ ConstantPointerRef *Module::getConstantPointerRef(GlobalValue *V){
if (I != GVRefMap->end()) return I->second;
ConstantPointerRef *Ref = new ConstantPointerRef(V);
- GVRefMap->insert(make_pair(V, Ref));
+ GVRefMap->insert(std::make_pair(V, Ref));
return Ref;
}
@@ -112,5 +112,5 @@ void Module::mutateConstantPointerRef(GlobalValue *OldGV, GlobalValue *NewGV) {
GVRefMap->erase(I);
// Insert the new entry...
- GVRefMap->insert(make_pair(NewGV, Ref));
+ GVRefMap->insert(std::make_pair(NewGV, Ref));
}
diff --git a/lib/VMCore/SlotCalculator.cpp b/lib/VMCore/SlotCalculator.cpp
index ede822846d..4738f712a1 100644
--- a/lib/VMCore/SlotCalculator.cpp
+++ b/lib/VMCore/SlotCalculator.cpp
@@ -196,7 +196,8 @@ void SlotCalculator::purgeMethod() {
while (CurPlane.size() != ModuleSize) {
//SC_DEBUG(" Removing [" << i << "] Value=" << CurPlane.back() << "\n");
- map<const Value *, unsigned>::iterator NI = NodeMap.find(CurPlane.back());
+ std::map<const Value *, unsigned>::iterator NI =
+ NodeMap.find(CurPlane.back());
assert(NI != NodeMap.end() && "Node not in nodemap?");
NodeMap.erase(NI); // Erase from nodemap
CurPlane.pop_back(); // Shrink plane
@@ -223,7 +224,7 @@ void SlotCalculator::purgeMethod() {
}
int SlotCalculator::getValSlot(const Value *D) const {
- map<const Value*, unsigned>::const_iterator I = NodeMap.find(D);
+ std::map<const Value*, unsigned>::const_iterator I = NodeMap.find(D);
if (I == NodeMap.end()) return -1;
return (int)I->second;
diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp
index dd6329fc97..ab98a73184 100644
--- a/lib/VMCore/SymbolTable.cpp
+++ b/lib/VMCore/SymbolTable.cpp
@@ -10,6 +10,14 @@
#include "llvm/Module.h"
#include "llvm/Method.h"
#include "Support/StringExtras.h"
+#include <iostream>
+
+using std::string;
+using std::pair;
+using std::make_pair;
+using std::map;
+using std::cerr;
+using std::cout;
#define DEBUG_SYMBOL_TABLE 0
#define DEBUG_ABSTYPE 0
@@ -35,7 +43,8 @@ SymbolTable::~SymbolTable() {
for (type_iterator I = i->second.begin(); I != i->second.end(); ++I)
if (!isa<Constant>(I->second) && !isa<Type>(I->second)) {
cerr << "Value still in symbol table! Type = '"
- << i->first->getDescription() << "' Name = '" << I->first << "'\n";
+ << i->first->getDescription() << "' Name = '"
+ << I->first << "'\n";
LeftoverValues = false;
}
}
@@ -305,11 +314,11 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType,
#include <algorithm>
static void DumpVal(const pair<const string, Value *> &V) {
- cout << " '" << V.first << "' = " << V.second << endl;
+ cout << " '" << V.first << "' = " << V.second << "\n";
}
static void DumpPlane(const pair<const Type *, map<const string, Value *> >&P) {
- cout << " Plane: " << P.first << endl;
+ cout << " Plane: " << P.first << "\n";
for_each(P.second.begin(), P.second.end(), DumpVal);
}
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index cbcdf3f37d..316f97d439 100644
--- a/lib/VMCore/Type.cpp
+++ b/lib/VMCore/Type.cpp
@@ -8,6 +8,14 @@
#include "llvm/SymbolTable.h"
#include "Support/StringExtras.h"
#include "Support/STLExtras.h"
+#include <iostream>
+
+using std::vector;
+using std::string;
+using std::map;
+using std::swap;
+using std::make_pair;
+using std::cerr;
// DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are
// created and later destroyed, all in an effort to make sure that there is only
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp
index 0ac7205104..af9d2e4f62 100644
--- a/lib/VMCore/Value.cpp
+++ b/lib/VMCore/Value.cpp
@@ -11,6 +11,8 @@
#include "llvm/Type.h"
#ifndef NDEBUG // Only in -g mode...
#include "llvm/Assembly/Writer.h"
+#include <iostream>
+using std::cerr;
#endif
#include <algorithm>
@@ -23,7 +25,7 @@ static inline const Type *checkType(const Type *Ty) {
return Ty;
}
-Value::Value(const Type *ty, ValueTy vty, const string &name = "")
+Value::Value(const Type *ty, ValueTy vty, const std::string &name = "")
: Name(name), Ty(checkType(ty), this) {
VTy = vty;
}
@@ -39,7 +41,7 @@ Value::~Value() {
if (Uses.begin() != Uses.end()) {
cerr << "While deleting: " << this;
for (use_const_iterator I = Uses.begin(); I != Uses.end(); ++I)
- cerr << "Use still stuck around after Def is destroyed:" << *I << endl;
+ cerr << "Use still stuck around after Def is destroyed:" << *I << "\n";
}
#endif
assert(Uses.begin() == Uses.end());
@@ -98,7 +100,7 @@ void Value::dump() const {
// User Class
//===----------------------------------------------------------------------===//
-User::User(const Type *Ty, ValueTy vty, const string &name)
+User::User(const Type *Ty, ValueTy vty, const std::string &name)
: Value(Ty, vty, name) {
}
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 55424fc478..0702e85f0e 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -34,6 +34,9 @@
#include "llvm/Module.h"
#include "llvm/BasicBlock.h"
#include "llvm/Type.h"
+using std::string;
+using std::vector;
+
// Error - Define a macro to do the common task of pushing a message onto the
// end of the error list and setting Bad to true.
diff --git a/lib/VMCore/iBranch.cpp b/lib/VMCore/iBranch.cpp
index d0f437e293..f020ab6213 100644
--- a/lib/VMCore/iBranch.cpp
+++ b/lib/VMCore/iBranch.cpp
@@ -10,6 +10,7 @@
#ifndef NDEBUG
#include "llvm/Type.h" // Only used for assertions...
#include "llvm/Assembly/Writer.h"
+#include <iostream>
#endif
BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond)
@@ -27,7 +28,7 @@ BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond)
#ifndef NDEBUG
if (Cond != 0 && Cond->getType() != Type::BoolTy)
- cerr << "Bad Condition: " << Cond << endl;
+ std::cerr << "Bad Condition: " << Cond << "\n";
#endif
assert((Cond == 0 || Cond->getType() == Type::BoolTy) &&
"May only branch on boolean predicates!!!!");
diff --git a/lib/VMCore/iCall.cpp b/lib/VMCore/iCall.cpp
index 7f4efaf7b2..37eb24e86c 100644
--- a/lib/VMCore/iCall.cpp
+++ b/lib/VMCore/iCall.cpp
@@ -13,8 +13,8 @@
// CallInst Implementation
//===----------------------------------------------------------------------===//
-CallInst::CallInst(Value *Meth, const vector<Value*> &params,
- const string &Name)
+CallInst::CallInst(Value *Meth, const std::vector<Value*> &params,
+ const std::string &Name)
: Instruction(cast<MethodType>(cast<PointerType>(Meth->getType())
->getElementType())->getReturnType(),
Instruction::Call, Name) {
@@ -44,8 +44,9 @@ CallInst::CallInst(const CallInst &CI)
//===----------------------------------------------------------------------===//
InvokeInst::InvokeInst(Value *Meth, BasicBlock *IfNormal, \
- BasicBlock *IfException, const vector<Value*>&params,
- const string &Name)
+ BasicBlock *IfException,
+ const std::vector<Value*> &params,
+ const std::string &Name)
: TerminatorInst(cast<MethodType>(cast<PointerType>(Meth->getType())
->getElementType())->getReturnType(),
Instruction::Invoke, Name) {
diff --git a/lib/VMCore/iMemory.cpp b/lib/VMCore/iMemory.cpp
index c845fd9936..4226a69615 100644
--- a/lib/VMCore/iMemory.cpp
+++ b/lib/VMCore/iMemory.cpp
@@ -22,7 +22,7 @@ static inline const Type *checkType(const Type *Ty) {
// pointer type.
//
const Type* MemAccessInst::getIndexedType(const Type *Ptr,
- const vector<Value*> &Idx,
+ const std::vector<Value*> &Idx,
bool AllowCompositeLeaf = false) {
if (!Ptr->isPointerType()) return 0; // Type isn't a pointer type!
@@ -48,8 +48,8 @@ const Type* MemAccessInst::getIndexedType(const Type *Ptr,
// LoadInst Implementation
//===----------------------------------------------------------------------===//
-LoadInst::LoadInst(Value *Ptr, const vector<Value*> &Idx,
- const string &Name = "")
+LoadInst::LoadInst(Value *Ptr, const std::vector<Value*> &Idx,
+ const std::string &Name = "")
: MemAccessInst(checkType(getIndexedType(Ptr->getType(), Idx)), Load, Name) {
assert(getIndexedType(Ptr->getType(), Idx) && "Load operands invalid!");
Operands.reserve(1+Idx.size());
@@ -60,7 +60,7 @@ LoadInst::LoadInst(Value *Ptr, const vector<Value*> &Idx,
}
-LoadInst::LoadInst(Value *Ptr, const string &Name = "")
+LoadInst::LoadInst(Value *Ptr, const std::string &Name = "")
: MemAccessInst(cast<PointerType>(Ptr->getType())->getElementType(),
Load, Name) {
Operands.reserve(1);
@@ -72,8 +72,8 @@ LoadInst::LoadInst(Value *Ptr, const string &Name = "")
// StoreInst Implementation
//===----------------------------------------------------------------------===//
-StoreInst::StoreInst(Value *Val, Value *Ptr, const vector<Value*> &Idx,
- const string &Name = "")
+StoreInst::StoreInst(Value *Val, Value *Ptr, const std::vector<Value*> &Idx,
+ const std::string &Name = "")
: MemAccessInst(Type::VoidTy, Store, Name) {
assert(getIndexedType(Ptr->getType(), Idx) && "Store operands invalid!");
@@ -85,7 +85,7 @@ StoreInst::StoreInst(Value *Val, Value *Ptr, const vector<Value*> &Idx,
Operands.push_back(Use(Idx[i], this));
}
-StoreInst::StoreInst(Value *Val, Value *Ptr, const string &Name = "")
+StoreInst::StoreInst(Value *Val, Value *Ptr, const std::string &Name = "")
: MemAccessInst(Type::VoidTy, Store, Name) {
Operands.reserve(2);
@@ -98,8 +98,8 @@ StoreInst::StoreInst(Value *Val, Value *Ptr, const string &Name = "")
// GetElementPtrInst Implementation
//===----------------------------------------------------------------------===//
-GetElementPtrInst::GetElementPtrInst(Value *Ptr, const vector<Value*> &Idx,
- const string &Name = "")
+GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
+ const std::string &Name = "")
: MemAccessInst(PointerType::get(checkType(getIndexedType(Ptr->getType(),
Idx, true))),
GetElementPtr, Name) {
diff --git a/lib/VMCore/iOperators.cpp b/lib/VMCore/iOperators.cpp
index cb53d5e034..c2fe1bc04a 100644
--- a/lib/VMCore/iOperators.cpp
+++ b/lib/VMCore/iOperators.cpp
@@ -6,6 +6,8 @@
#include "llvm/iOperators.h"
#include "llvm/Type.h"
+#include <iostream>
+using std::cerr;
//===----------------------------------------------------------------------===//
// UnaryOperator Class
@@ -15,7 +17,7 @@ UnaryOperator *UnaryOperator::create(UnaryOps Op, Value *Source) {
switch (Op) {
case Not: return new GenericUnaryInst(Op, Source);
default:
- cerr << "Don't know how to Create UnaryOperator " << Op << endl;
+ cerr << "Don't know how to Create UnaryOperator " << Op << "\n";
return 0;
}
}
@@ -30,9 +32,10 @@ const char *GenericUnaryInst::getOpcodeName() const {
case Not: return "not";
case Cast: return "cast";
default:
- cerr << "Invalid unary operator type!" << getOpcode() << endl;
+ cerr << "Invalid unary operator type!" << getOpcode() << "\n";
abort();
}
+ return 0;
}
@@ -41,7 +44,7 @@ const char *GenericUnaryInst::getOpcodeName() const {
//===----------------------------------------------------------------------===//
BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2,
- const string &Name) {
+ const std::string &Name) {
switch (Op) {
// Binary comparison operators...
case SetLT: case SetGT: case SetLE:
@@ -75,7 +78,7 @@ bool BinaryOperator::swapOperands() {
default:
return true;
}
- swap(Operands[0], Operands[1]);
+ std::swap(Operands[0], Operands[1]);
return false;
}
@@ -98,9 +101,10 @@ const char *GenericBinaryInst::getOpcodeName() const {
case Or : return "or";
case Xor: return "xor";
default:
- cerr << "Invalid binary operator type!" << getOpcode() << endl;
+ cerr << "Invalid binary operator type!" << getOpcode() << "\n";
abort();
}
+ return 0;
}
@@ -109,7 +113,7 @@ const char *GenericBinaryInst::getOpcodeName() const {
//===----------------------------------------------------------------------===//
SetCondInst::SetCondInst(BinaryOps opType, Value *S1, Value *S2,
- const string &Name)
+ const std::string &Name)
: BinaryOperator(opType, S1, S2, Name) {
OpType = opType;