From fa809d8e8fa496ecae313cd76f267d59963b6517 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 5 Jun 2009 05:32:15 +0000 Subject: (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 --- lib/Core/Executor.cpp | 76 ++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 34 deletions(-) (limited to 'lib/Core') 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(i); ref left = eval(ki, 0, state).value; ref 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(i); ref left = eval(ki, 0, state).value; ref 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(i); ref left = eval(ki, 0, state).value; ref 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(i); + ref left = eval(ki, 0, state).value; + ref 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(i); + ref left = eval(ki, 0, state).value; + ref 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(i); + ref left = eval(ki, 0, state).value; + ref 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(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; } } -- cgit 1.4.1