about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-25 00:34:31 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-25 00:34:31 +0000
commit0a6bd94fc47543bf91a98b265e2bedbe3ccb77a3 (patch)
tree9f0d5317f3a3ef7afd2773c5a0b640011919b87b /lib
parent0e29e311c7237561af46af3584d888175e42b1cc (diff)
downloadklee-0a6bd94fc47543bf91a98b265e2bedbe3ccb77a3.tar.gz
Switch to using APInt math operations.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@74148 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Expr/Expr.cpp113
1 files changed, 32 insertions, 81 deletions
diff --git a/lib/Expr/Expr.cpp b/lib/Expr/Expr.cpp
index 1615127a..ae7bc819 100644
--- a/lib/Expr/Expr.cpp
+++ b/lib/Expr/Expr.cpp
@@ -338,11 +338,11 @@ ref<Expr> ConstantExpr::fromMemory(void *address, Width width) {
 void ConstantExpr::toMemory(void *address) {
   switch (getWidth()) {
   default: assert(0 && "invalid type");
-  case  Expr::Bool: *(( uint8_t*) address) = getConstantValue(); break;
-  case  Expr::Int8: *(( uint8_t*) address) = getConstantValue(); break;
-  case Expr::Int16: *((uint16_t*) address) = getConstantValue(); break;
-  case Expr::Int32: *((uint32_t*) address) = getConstantValue(); break;
-  case Expr::Int64: *((uint64_t*) address) = getConstantValue(); break;
+  case  Expr::Bool: *(( uint8_t*) address) = getZExtValue(1); break;
+  case  Expr::Int8: *(( uint8_t*) address) = getZExtValue(8); break;
+  case Expr::Int16: *((uint16_t*) address) = getZExtValue(16); break;
+  case Expr::Int32: *((uint32_t*) address) = getZExtValue(32); break;
+  case Expr::Int64: *((uint64_t*) address) = getZExtValue(64); break;
   }
 }
 
@@ -367,160 +367,111 @@ ref<ConstantExpr> ConstantExpr::Extract(unsigned Offset, Width W) {
 }
 
 ref<ConstantExpr> ConstantExpr::ZExt(Width W) {
-  return ConstantExpr::create(ints::zext(getConstantValue(), W, getWidth()), W);
+  return ConstantExpr::alloc(APInt(value).zextOrTrunc(W));
 }
 
 ref<ConstantExpr> ConstantExpr::SExt(Width W) {
-  return ConstantExpr::create(ints::sext(getConstantValue(), W, getWidth()), W);
+  return ConstantExpr::alloc(APInt(value).sextOrTrunc(W));
 }
 
 ref<ConstantExpr> ConstantExpr::Add(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::add(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(value + RHS->value);
 }
 
 ref<ConstantExpr> ConstantExpr::Neg() {
-  return ConstantExpr::create(ints::sub(0, 
-                                        getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(-value);
 }
 
 ref<ConstantExpr> ConstantExpr::Sub(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::sub(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(value - RHS->value);
 }
 
 ref<ConstantExpr> ConstantExpr::Mul(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::mul(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(value * RHS->value);
 }
 
 ref<ConstantExpr> ConstantExpr::UDiv(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::udiv(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(value.udiv(RHS->value));
 }
 
 ref<ConstantExpr> ConstantExpr::SDiv(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::sdiv(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(value.sdiv(RHS->value));
 }
 
 ref<ConstantExpr> ConstantExpr::URem(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::urem(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(value.urem(RHS->value));
 }
 
 ref<ConstantExpr> ConstantExpr::SRem(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::srem(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(value.srem(RHS->value));
 }
 
 ref<ConstantExpr> ConstantExpr::And(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::land(getConstantValue(), 
-                                         RHS->getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(value & RHS->value);
 }
 
 ref<ConstantExpr> ConstantExpr::Or(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::lor(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(value | RHS->value);
 }
 
 ref<ConstantExpr> ConstantExpr::Xor(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::lxor(getConstantValue(), 
-                                         RHS->getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(value ^ RHS->value);
 }
 
 ref<ConstantExpr> ConstantExpr::Shl(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::shl(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(value.shl(RHS->value));
 }
 
 ref<ConstantExpr> ConstantExpr::LShr(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::lshr(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(value.lshr(RHS->value));
 }
 
 ref<ConstantExpr> ConstantExpr::AShr(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::ashr(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              getWidth());
+  return ConstantExpr::alloc(value.ashr(RHS->value));
 }
 
 ref<ConstantExpr> ConstantExpr::Not() {
-  return ConstantExpr::create(ints::eq(getConstantValue(), 0, getWidth()),
-                              Expr::Bool);
+  return ConstantExpr::alloc(value == 0, Expr::Bool);
 }
 
 ref<ConstantExpr> ConstantExpr::Eq(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::eq(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              Expr::Bool);
+  return ConstantExpr::alloc(value == RHS->value, Expr::Bool);
 }
 
 ref<ConstantExpr> ConstantExpr::Ne(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::ne(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              Expr::Bool);
+  return ConstantExpr::alloc(value != RHS->value, Expr::Bool);
 }
 
 ref<ConstantExpr> ConstantExpr::Ult(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::ult(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              Expr::Bool);
+  return ConstantExpr::alloc(value.ult(RHS->value), Expr::Bool);
 }
 
 ref<ConstantExpr> ConstantExpr::Ule(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::ule(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              Expr::Bool);
+  return ConstantExpr::alloc(value.ule(RHS->value), Expr::Bool);
 }
 
 ref<ConstantExpr> ConstantExpr::Ugt(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::ugt(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              Expr::Bool);
+  return ConstantExpr::alloc(value.ugt(RHS->value), Expr::Bool);
 }
 
 ref<ConstantExpr> ConstantExpr::Uge(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::uge(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              Expr::Bool);
+  return ConstantExpr::alloc(value.uge(RHS->value), Expr::Bool);
 }
 
 ref<ConstantExpr> ConstantExpr::Slt(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::slt(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              Expr::Bool);
+  return ConstantExpr::alloc(value.slt(RHS->value), Expr::Bool);
 }
 
 ref<ConstantExpr> ConstantExpr::Sle(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::sle(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              Expr::Bool);
+  return ConstantExpr::alloc(value.sle(RHS->value), Expr::Bool);
 }
 
 ref<ConstantExpr> ConstantExpr::Sgt(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::sgt(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              Expr::Bool);
+  return ConstantExpr::alloc(value.sgt(RHS->value), Expr::Bool);
 }
 
 ref<ConstantExpr> ConstantExpr::Sge(const ref<ConstantExpr> &RHS) {
-  return ConstantExpr::create(ints::sge(getConstantValue(), 
-                                        RHS->getConstantValue(), getWidth()),
-                              Expr::Bool);
+  return ConstantExpr::alloc(value.sge(RHS->value), Expr::Bool);
 }
 
 /***/