From 0769caf8bbf0bc6ea3c681e5af7d79291fae2e2f Mon Sep 17 00:00:00 2001 From: Julian Büning Date: Fri, 18 Sep 2020 18:14:56 +0200 Subject: implement fneg instruction --- lib/Core/Executor.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib') diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 7fac4fa4..de35710f 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -2465,6 +2465,20 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { // Floating point instructions +#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0) + case Instruction::FNeg: { + ref arg = + toConstant(state, eval(ki, 0, state).value, "floating point"); + if (!fpWidthToSemantics(arg->getWidth())) + return terminateStateOnExecError(state, "Unsupported FNeg operation"); + + llvm::APFloat Res(*fpWidthToSemantics(arg->getWidth()), arg->getAPValue()); + Res = llvm::neg(Res); + bindLocal(ki, state, ConstantExpr::alloc(Res.bitcastToAPInt())); + break; + } +#endif + case Instruction::FAdd: { ref left = toConstant(state, eval(ki, 0, state).value, "floating point"); -- cgit 1.4.1