about summary refs log tree commit diff homepage
path: root/lib/Expr
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-25 01:01:27 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-25 01:01:27 +0000
commit16df16b7295819b788570998baa9ab30dabde0e5 (patch)
tree1bf8e2979d4ffc30145433e4f11eab96863de368 /lib/Expr
parent69a7598ab92a5fcd3573487677d7681552c1ba4c (diff)
downloadklee-16df16b7295819b788570998baa9ab30dabde0e5.tar.gz
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
Diffstat (limited to 'lib/Expr')
-rw-r--r--lib/Expr/Expr.cpp18
1 files changed, 8 insertions, 10 deletions
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> ConstantExpr::Concat(const ref<ConstantExpr> &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> 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> ConstantExpr::ZExt(Width W) {