From 16df16b7295819b788570998baa9ab30dabde0e5 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 25 Jun 2009 01:01:27 +0000 Subject: Kill off last getConstantValue uses. - ConstantExpr should now fully support arbitrary width operations. - Still numerous holes in parsing, solver, etc. to plug. git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@74151 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Expr/Expr.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'lib/Expr') diff --git a/lib/Expr/Expr.cpp b/lib/Expr/Expr.cpp index e4bde44b..d4042e3f 100644 --- a/lib/Expr/Expr.cpp +++ b/lib/Expr/Expr.cpp @@ -347,23 +347,21 @@ void ConstantExpr::toMemory(void *address) { } void ConstantExpr::toString(std::string &Res) const { - std::stringstream os; - os << *this; - Res = os.str(); + Res = value.toString(10, false); } ref ConstantExpr::Concat(const ref &RHS) { Expr::Width W = getWidth() + RHS->getWidth(); - assert(W <= 64 && "FIXME: Support arbitrary bit-widths!"); - - uint64_t res = (getConstantValue() << RHS->getWidth()) + - RHS->getConstantValue(); - return ConstantExpr::create(res, W); + APInt Tmp(value); + Tmp.zext(W); + Tmp <<= RHS->getWidth(); + Tmp |= APInt(RHS->value).zext(W); + + return ConstantExpr::alloc(Tmp); } ref ConstantExpr::Extract(unsigned Offset, Width W) { - return ConstantExpr::create(ints::trunc(getConstantValue() >> Offset, W, - getWidth()), W); + return ConstantExpr::alloc(APInt(value.ashr(Offset)).zextOrTrunc(W)); } ref ConstantExpr::ZExt(Width W) { -- cgit 1.4.1