aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/Core
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-05 05:32:15 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-05 05:32:15 +0000
commitfa809d8e8fa496ecae313cd76f267d59963b6517 (patch)
treec27937c4080ebab0f9988fac99bbefff692a32d6 /lib/Core
parent4203dcc7637fce437af56e51ed7d9fef8f1ceeca (diff)
downloadklee-fa809d8e8fa496ecae313cd76f267d59963b6517.tar.gz
(llvm up) Update klee for introduction of f{add,sub,mul} instructions.
- Please update & rebuild LLVM. git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@72919 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Core')
-rw-r--r--lib/Core/Executor.cpp76
1 files changed, 42 insertions, 34 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index 21356af9..fece4af9 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -1584,53 +1584,25 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
break;
// Arithmetic / logical
-#define FP_CONSTANT_BINOP(op, type, l, r, target, state) \
- bindLocal(target, state, \
- ConstantExpr::alloc(op(toConstant(state, l, "floating point")->getConstantValue(), \
- toConstant(state, r, "floating point")->getConstantValue(), \
- type), type))
+
case Instruction::Add: {
- BinaryOperator *bi = cast<BinaryOperator>(i);
ref<Expr> left = eval(ki, 0, state).value;
ref<Expr> right = eval(ki, 1, state).value;
-
- if( bi->getType()->getTypeID() == llvm::Type::IntegerTyID ) {
- bindLocal(ki, state, AddExpr::create(left, right));
- } else {
- Expr::Width type = Expr::getWidthForLLVMType(bi->getType());
- FP_CONSTANT_BINOP(floats::add, type, left, right, ki, state);
- }
-
+ bindLocal(ki, state, AddExpr::create(left, right));
break;
}
case Instruction::Sub: {
- BinaryOperator *bi = cast<BinaryOperator>(i);
ref<Expr> left = eval(ki, 0, state).value;
ref<Expr> right = eval(ki, 1, state).value;
-
- if( bi->getType()->getTypeID() == llvm::Type::IntegerTyID ) {
- bindLocal(ki, state, SubExpr::create(left, right));
- } else {
- Expr::Width type = Expr::getWidthForLLVMType(bi->getType());
- FP_CONSTANT_BINOP(floats::sub, type, left, right, ki, state);
- }
-
+ bindLocal(ki, state, SubExpr::create(left, right));
break;
}
case Instruction::Mul: {
- BinaryOperator *bi = cast<BinaryOperator>(i);
ref<Expr> left = eval(ki, 0, state).value;
ref<Expr> right = eval(ki, 1, state).value;
-
- if( bi->getType()->getTypeID() == llvm::Type::IntegerTyID ) {
- bindLocal(ki, state, MulExpr::create(left, right));
- } else {
- Expr::Width type = Expr::getWidthForLLVMType(bi->getType());
- FP_CONSTANT_BINOP(floats::mul, type, left, right, ki, state);
- }
-
+ bindLocal(ki, state, MulExpr::create(left, right));
break;
}
@@ -1905,7 +1877,43 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
break;
}
- // Floating Point specific instructions
+ // Floating point specific instructions
+
+#define FP_CONSTANT_BINOP(op, type, l, r, target, state) \
+ bindLocal(target, state, \
+ ConstantExpr::alloc(op(toConstant(state, l, \
+ "floating point")->getConstantValue(), \
+ toConstant(state, r, \
+ "floating point")->getConstantValue(), \
+ type), type))
+
+ case Instruction::FAdd: {
+ BinaryOperator *bi = cast<BinaryOperator>(i);
+ ref<Expr> left = eval(ki, 0, state).value;
+ ref<Expr> right = eval(ki, 1, state).value;
+ Expr::Width type = Expr::getWidthForLLVMType(bi->getType());
+ FP_CONSTANT_BINOP(floats::add, type, left, right, ki, state);
+ break;
+ }
+
+ case Instruction::FSub: {
+ BinaryOperator *bi = cast<BinaryOperator>(i);
+ ref<Expr> left = eval(ki, 0, state).value;
+ ref<Expr> right = eval(ki, 1, state).value;
+ Expr::Width type = Expr::getWidthForLLVMType(bi->getType());
+ FP_CONSTANT_BINOP(floats::sub, type, left, right, ki, state);
+ break;
+ }
+
+ case Instruction::FMul: {
+ BinaryOperator *bi = cast<BinaryOperator>(i);
+ ref<Expr> left = eval(ki, 0, state).value;
+ ref<Expr> right = eval(ki, 1, state).value;
+ Expr::Width type = Expr::getWidthForLLVMType(bi->getType());
+ FP_CONSTANT_BINOP(floats::mul, type, left, right, ki, state);
+ break;
+ }
+
case Instruction::FPTrunc: {
FPTruncInst *fi = cast<FPTruncInst>(i);
Expr::Width resultType = Expr::getWidthForLLVMType(fi->getType());
@@ -2116,7 +2124,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
break;
default:
- terminateStateOnExecError(state, "invalid instruction");
+ terminateStateOnExecError(state, "illegal instruction");
break;
}
}