summaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/Interpreter
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-08-23 04:37:46 +0000
committerChris Lattner <sabre@nondot.org>2009-08-23 04:37:46 +0000
commitbdff548e4dd577a72094d57b282de4e765643b96 (patch)
tree71c6617214b134968352b854c8f82ce8c89e1282 /lib/ExecutionEngine/Interpreter
parent405ce8db96f7a3a5a4c3da0f71d2ca54d30316f0 (diff)
downloadllvm-bdff548e4dd577a72094d57b282de4e765643b96.tar.gz
llvm-bdff548e4dd577a72094d57b282de4e765643b96.tar.bz2
llvm-bdff548e4dd577a72094d57b282de4e765643b96.tar.xz
eliminate the "Value" printing methods that print to a std::ostream.
This required converting a bunch of stuff off DOUT and other cleanups. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79819 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/Interpreter')
-rw-r--r--lib/ExecutionEngine/Interpreter/Execution.cpp82
-rw-r--r--lib/ExecutionEngine/Interpreter/Interpreter.h8
2 files changed, 44 insertions, 46 deletions
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index 45180c91f0..31210a7eab 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -26,7 +26,6 @@
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#include <cmath>
-#include <cstring>
using namespace llvm;
STATISTIC(NumDynamicInsts, "Number of dynamic instructions executed");
@@ -57,7 +56,7 @@ static void executeFAddInst(GenericValue &Dest, GenericValue Src1,
IMPLEMENT_BINARY_OPERATOR(+, Float);
IMPLEMENT_BINARY_OPERATOR(+, Double);
default:
- cerr << "Unhandled type for FAdd instruction: " << *Ty << "\n";
+ errs() << "Unhandled type for FAdd instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
}
@@ -68,7 +67,7 @@ static void executeFSubInst(GenericValue &Dest, GenericValue Src1,
IMPLEMENT_BINARY_OPERATOR(-, Float);
IMPLEMENT_BINARY_OPERATOR(-, Double);
default:
- cerr << "Unhandled type for FSub instruction: " << *Ty << "\n";
+ errs() << "Unhandled type for FSub instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
}
@@ -79,7 +78,7 @@ static void executeFMulInst(GenericValue &Dest, GenericValue Src1,
IMPLEMENT_BINARY_OPERATOR(*, Float);
IMPLEMENT_BINARY_OPERATOR(*, Double);
default:
- cerr << "Unhandled type for FMul instruction: " << *Ty << "\n";
+ errs() << "Unhandled type for FMul instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
}
@@ -90,7 +89,7 @@ static void executeFDivInst(GenericValue &Dest, GenericValue Src1,
IMPLEMENT_BINARY_OPERATOR(/, Float);
IMPLEMENT_BINARY_OPERATOR(/, Double);
default:
- cerr << "Unhandled type for FDiv instruction: " << *Ty << "\n";
+ errs() << "Unhandled type for FDiv instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
}
@@ -105,7 +104,7 @@ static void executeFRemInst(GenericValue &Dest, GenericValue Src1,
Dest.DoubleVal = fmod(Src1.DoubleVal, Src2.DoubleVal);
break;
default:
- cerr << "Unhandled type for Rem instruction: " << *Ty << "\n";
+ errs() << "Unhandled type for Rem instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
}
@@ -132,7 +131,7 @@ static GenericValue executeICMP_EQ(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(eq,Ty);
IMPLEMENT_POINTER_ICMP(==);
default:
- cerr << "Unhandled type for ICMP_EQ predicate: " << *Ty << "\n";
+ errs() << "Unhandled type for ICMP_EQ predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -145,7 +144,7 @@ static GenericValue executeICMP_NE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(ne,Ty);
IMPLEMENT_POINTER_ICMP(!=);
default:
- cerr << "Unhandled type for ICMP_NE predicate: " << *Ty << "\n";
+ errs() << "Unhandled type for ICMP_NE predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -158,7 +157,7 @@ static GenericValue executeICMP_ULT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(ult,Ty);
IMPLEMENT_POINTER_ICMP(<);
default:
- cerr << "Unhandled type for ICMP_ULT predicate: " << *Ty << "\n";
+ errs() << "Unhandled type for ICMP_ULT predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -171,7 +170,7 @@ static GenericValue executeICMP_SLT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(slt,Ty);
IMPLEMENT_POINTER_ICMP(<);
default:
- cerr << "Unhandled type for ICMP_SLT predicate: " << *Ty << "\n";
+ errs() << "Unhandled type for ICMP_SLT predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -184,7 +183,7 @@ static GenericValue executeICMP_UGT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(ugt,Ty);
IMPLEMENT_POINTER_ICMP(>);
default:
- cerr << "Unhandled type for ICMP_UGT predicate: " << *Ty << "\n";
+ errs() << "Unhandled type for ICMP_UGT predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -197,7 +196,7 @@ static GenericValue executeICMP_SGT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(sgt,Ty);
IMPLEMENT_POINTER_ICMP(>);
default:
- cerr << "Unhandled type for ICMP_SGT predicate: " << *Ty << "\n";
+ errs() << "Unhandled type for ICMP_SGT predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -210,7 +209,7 @@ static GenericValue executeICMP_ULE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(ule,Ty);
IMPLEMENT_POINTER_ICMP(<=);
default:
- cerr << "Unhandled type for ICMP_ULE predicate: " << *Ty << "\n";
+ errs() << "Unhandled type for ICMP_ULE predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -223,7 +222,7 @@ static GenericValue executeICMP_SLE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(sle,Ty);
IMPLEMENT_POINTER_ICMP(<=);
default:
- cerr << "Unhandled type for ICMP_SLE predicate: " << *Ty << "\n";
+ errs() << "Unhandled type for ICMP_SLE predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -236,7 +235,7 @@ static GenericValue executeICMP_UGE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(uge,Ty);
IMPLEMENT_POINTER_ICMP(>=);
default:
- cerr << "Unhandled type for ICMP_UGE predicate: " << *Ty << "\n";
+ errs() << "Unhandled type for ICMP_UGE predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -249,7 +248,7 @@ static GenericValue executeICMP_SGE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(sge,Ty);
IMPLEMENT_POINTER_ICMP(>=);
default:
- cerr << "Unhandled type for ICMP_SGE predicate: " << *Ty << "\n";
+ errs() << "Unhandled type for ICMP_SGE predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -274,7 +273,7 @@ void Interpreter::visitICmpInst(ICmpInst &I) {
case ICmpInst::ICMP_UGE: R = executeICMP_UGE(Src1, Src2, Ty); break;
case ICmpInst::ICMP_SGE: R = executeICMP_SGE(Src1, Src2, Ty); break;
default:
- cerr << "Don't know how to handle this ICmp predicate!\n-->" << I;
+ errs() << "Don't know how to handle this ICmp predicate!\n-->" << I;
llvm_unreachable(0);
}
@@ -293,7 +292,7 @@ static GenericValue executeFCMP_OEQ(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(==, Float);
IMPLEMENT_FCMP(==, Double);
default:
- cerr << "Unhandled type for FCmp EQ instruction: " << *Ty << "\n";
+ errs() << "Unhandled type for FCmp EQ instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -307,7 +306,7 @@ static GenericValue executeFCMP_ONE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(!=, Double);
default:
- cerr << "Unhandled type for FCmp NE instruction: " << *Ty << "\n";
+ errs() << "Unhandled type for FCmp NE instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -320,7 +319,7 @@ static GenericValue executeFCMP_OLE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(<=, Float);
IMPLEMENT_FCMP(<=, Double);
default:
- cerr << "Unhandled type for FCmp LE instruction: " << *Ty << "\n";
+ errs() << "Unhandled type for FCmp LE instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -333,7 +332,7 @@ static GenericValue executeFCMP_OGE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(>=, Float);
IMPLEMENT_FCMP(>=, Double);
default:
- cerr << "Unhandled type for FCmp GE instruction: " << *Ty << "\n";
+ errs() << "Unhandled type for FCmp GE instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -346,7 +345,7 @@ static GenericValue executeFCMP_OLT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(<, Float);
IMPLEMENT_FCMP(<, Double);
default:
- cerr << "Unhandled type for FCmp LT instruction: " << *Ty << "\n";
+ errs() << "Unhandled type for FCmp LT instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -359,7 +358,7 @@ static GenericValue executeFCMP_OGT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(>, Float);
IMPLEMENT_FCMP(>, Double);
default:
- cerr << "Unhandled type for FCmp GT instruction: " << *Ty << "\n";
+ errs() << "Unhandled type for FCmp GT instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -468,7 +467,7 @@ void Interpreter::visitFCmpInst(FCmpInst &I) {
case FCmpInst::FCMP_UGE: R = executeFCMP_UGE(Src1, Src2, Ty); break;
case FCmpInst::FCMP_OGE: R = executeFCMP_OGE(Src1, Src2, Ty); break;
default:
- cerr << "Don't know how to handle this FCmp predicate!\n-->" << I;
+ errs() << "Don't know how to handle this FCmp predicate!\n-->" << I;
llvm_unreachable(0);
}
@@ -514,7 +513,7 @@ static GenericValue executeCmpInst(unsigned predicate, GenericValue Src1,
return Result;
}
default:
- cerr << "Unhandled Cmp predicate\n";
+ errs() << "Unhandled Cmp predicate\n";
llvm_unreachable(0);
}
}
@@ -543,7 +542,7 @@ void Interpreter::visitBinaryOperator(BinaryOperator &I) {
case Instruction::Or: R.IntVal = Src1.IntVal | Src2.IntVal; break;
case Instruction::Xor: R.IntVal = Src1.IntVal ^ Src2.IntVal; break;
default:
- cerr << "Don't know how to handle this binary operator!\n-->" << I;
+ errs() << "Don't know how to handle this binary operator!\n-->" << I;
llvm_unreachable(0);
}
@@ -814,7 +813,7 @@ void Interpreter::visitLoadInst(LoadInst &I) {
LoadValueFromMemory(Result, Ptr, I.getType());
SetValue(&I, Result, SF);
if (I.isVolatile() && PrintVolatile)
- cerr << "Volatile load " << I;
+ errs() << "Volatile load " << I;
}
void Interpreter::visitStoreInst(StoreInst &I) {
@@ -824,7 +823,7 @@ void Interpreter::visitStoreInst(StoreInst &I) {
StoreValueToMemory(Val, (GenericValue *)GVTOP(SRC),
I.getOperand(0)->getType());
if (I.isVolatile() && PrintVolatile)
- cerr << "Volatile store: " << I;
+ errs() << "Volatile store: " << I;
}
//===----------------------------------------------------------------------===//
@@ -1178,7 +1177,7 @@ void Interpreter::visitVAArgInst(VAArgInst &I) {
IMPLEMENT_VAARG(Float);
IMPLEMENT_VAARG(Double);
default:
- cerr << "Unhandled dest type for vaarg instruction: " << *Ty << "\n";
+ errs() << "Unhandled dest type for vaarg instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
@@ -1265,7 +1264,7 @@ GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE,
Dest.IntVal = Op0.IntVal.ashr(Op1.IntVal.getZExtValue());
break;
default:
- cerr << "Unhandled ConstantExpr: " << *CE << "\n";
+ errs() << "Unhandled ConstantExpr: " << *CE << "\n";
llvm_unreachable(0);
return GenericValue();
}
@@ -1338,30 +1337,29 @@ void Interpreter::run() {
// Track the number of dynamic instructions executed.
++NumDynamicInsts;
- DOUT << "About to interpret: " << I;
+ DEBUG(errs() << "About to interpret: " << I);
visit(I); // Dispatch to one of the visit* methods...
#if 0
// This is not safe, as visiting the instruction could lower it and free I.
-#ifndef NDEBUG
+DEBUG(
if (!isa<CallInst>(I) && !isa<InvokeInst>(I) &&
I.getType() != Type::VoidTy) {
- DOUT << " --> ";
+ errs() << " --> ";
const GenericValue &Val = SF.Values[&I];
switch (I.getType()->getTypeID()) {
default: llvm_unreachable("Invalid GenericValue Type");
- case Type::VoidTyID: DOUT << "void"; break;
- case Type::FloatTyID: DOUT << "float " << Val.FloatVal; break;
- case Type::DoubleTyID: DOUT << "double " << Val.DoubleVal; break;
- case Type::PointerTyID: DOUT << "void* " << intptr_t(Val.PointerVal);
+ case Type::VoidTyID: errs() << "void"; break;
+ case Type::FloatTyID: errs() << "float " << Val.FloatVal; break;
+ case Type::DoubleTyID: errs() << "double " << Val.DoubleVal; break;
+ case Type::PointerTyID: errs() << "void* " << intptr_t(Val.PointerVal);
break;
case Type::IntegerTyID:
- DOUT << "i" << Val.IntVal.getBitWidth() << " "
- << Val.IntVal.toStringUnsigned(10)
- << " (0x" << Val.IntVal.toStringUnsigned(16) << ")\n";
+ errs() << "i" << Val.IntVal.getBitWidth() << " "
+ << Val.IntVal.toStringUnsigned(10)
+ << " (0x" << Val.IntVal.toStringUnsigned(16) << ")\n";
break;
}
- }
-#endif
+ });
#endif
}
}
diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h
index 10e53e9a14..e026287bb5 100644
--- a/lib/ExecutionEngine/Interpreter/Interpreter.h
+++ b/lib/ExecutionEngine/Interpreter/Interpreter.h
@@ -17,12 +17,12 @@
#include "llvm/Function.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/GenericValue.h"
-#include "llvm/Support/InstVisitor.h"
-#include "llvm/Support/CallSite.h"
#include "llvm/Target/TargetData.h"
+#include "llvm/Support/CallSite.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/ErrorHandling.h"
-
+#include "llvm/Support/InstVisitor.h"
+#include "llvm/Support/raw_ostream.h"
namespace llvm {
class IntrinsicLowering;
@@ -174,7 +174,7 @@ public:
void visitVAArgInst(VAArgInst &I);
void visitInstruction(Instruction &I) {
- cerr << I;
+ errs() << I;
llvm_unreachable("Instruction not interpretable yet!");
}