about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-14 21:20:11 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-14 21:20:11 +0000
commit2ad9c2b4a298c04bcbddc80b50f681e712dfbeba (patch)
treed10917056c1d76bf8cffba92d7d0a89af135e9ac /lib
parentc753b579533997ba1ebc4c1aeeb22d474681ea94 (diff)
downloadklee-2ad9c2b4a298c04bcbddc80b50f681e712dfbeba.tar.gz
Kill off ExtractExpr::createByteOff.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@73348 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Core/Executor.cpp6
-rw-r--r--lib/Core/Memory.cpp116
-rw-r--r--lib/Expr/Expr.cpp9
3 files changed, 63 insertions, 68 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index 88ced236..005499eb 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -1854,9 +1854,9 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
     // Conversion
   case Instruction::Trunc: {
     CastInst *ci = cast<CastInst>(i);
-    ref<Expr> result = ExtractExpr::createByteOff(eval(ki, 0, state).value,
-						  0,
-						  Expr::getWidthForLLVMType(ci->getType()));
+    ref<Expr> result = ExtractExpr::create(eval(ki, 0, state).value,
+                                           0,
+                                           Expr::getWidthForLLVMType(ci->getType()));
     bindLocal(ki, state, result);
     break;
   }
diff --git a/lib/Core/Memory.cpp b/lib/Core/Memory.cpp
index 05c226d3..d2c1dd0e 100644
--- a/lib/Core/Memory.cpp
+++ b/lib/Core/Memory.cpp
@@ -455,11 +455,11 @@ ref<Expr> ObjectState::read(unsigned offset, Expr::Width width) const {
 }
 
 ref<Expr> ObjectState::read1(unsigned offset) const {
-  return ExtractExpr::createByteOff(read8(offset), 0, Expr::Bool);
+  return ExtractExpr::create(read8(offset), 0, Expr::Bool);
 }
 
 ref<Expr> ObjectState::read1(ref<Expr> offset) const {
-  return ExtractExpr::createByteOff(read8(offset), 0, Expr::Bool);
+  return ExtractExpr::create(read8(offset), 0, Expr::Bool);
 }
 
 ref<Expr> ObjectState::read16(unsigned offset) const {
@@ -676,11 +676,11 @@ void ObjectState::write16(unsigned offset, uint16_t value) {
 
 void ObjectState::write16(unsigned offset, ref<Expr> value) {
   if (kMachineByteOrder == machine::MSB) {
-    write8(offset+0, ExtractExpr::createByteOff(value, 1));
-    write8(offset+1, ExtractExpr::createByteOff(value, 0));
+    write8(offset+0, ExtractExpr::create(value, 8, Expr::Int8));
+    write8(offset+1, ExtractExpr::create(value, 0, Expr::Int8));
   } else {
-    write8(offset+1, ExtractExpr::createByteOff(value, 1));
-    write8(offset+0, ExtractExpr::createByteOff(value, 0));
+    write8(offset+1, ExtractExpr::create(value, 8, Expr::Int8));
+    write8(offset+0, ExtractExpr::create(value, 0, Expr::Int8));
   }
 }
 
@@ -689,17 +689,17 @@ void ObjectState::write16(ref<Expr> offset, ref<Expr> value) {
   if (kMachineByteOrder == machine::MSB) {
     write8(AddExpr::create(offset,
                            ConstantExpr::create(0, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,1));
+           ExtractExpr::create(value, 8, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(0, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,0));
+           ExtractExpr::create(value, 0, Expr::Int8));
   } else {
     write8(AddExpr::create(offset,
                            ConstantExpr::create(1, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,1));
+           ExtractExpr::create(value, 8, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(0, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,0));
+           ExtractExpr::create(value, 0, Expr::Int8));
   }
 }
 
@@ -719,15 +719,15 @@ void ObjectState::write32(unsigned offset, uint32_t value) {
 
 void ObjectState::write32(unsigned offset, ref<Expr> value) {
   if (kMachineByteOrder == machine::MSB) {
-    write8(offset+0, ExtractExpr::createByteOff(value, 3));
-    write8(offset+1, ExtractExpr::createByteOff(value, 2));
-    write8(offset+2, ExtractExpr::createByteOff(value, 1));
-    write8(offset+3, ExtractExpr::createByteOff(value, 0));
+    write8(offset+0, ExtractExpr::create(value, 24, Expr::Int8));
+    write8(offset+1, ExtractExpr::create(value, 16, Expr::Int8));
+    write8(offset+2, ExtractExpr::create(value, 8, Expr::Int8));
+    write8(offset+3, ExtractExpr::create(value, 0, Expr::Int8));
   } else {
-    write8(offset+3, ExtractExpr::createByteOff(value, 3));
-    write8(offset+2, ExtractExpr::createByteOff(value, 2));
-    write8(offset+1, ExtractExpr::createByteOff(value, 1));
-    write8(offset+0, ExtractExpr::createByteOff(value, 0));
+    write8(offset+3, ExtractExpr::create(value, 24, Expr::Int8));
+    write8(offset+2, ExtractExpr::create(value, 16, Expr::Int8));
+    write8(offset+1, ExtractExpr::create(value, 8, Expr::Int8));
+    write8(offset+0, ExtractExpr::create(value, 0, Expr::Int8));
   }
 }
 
@@ -735,29 +735,29 @@ void ObjectState::write32(ref<Expr> offset, ref<Expr> value) {
   if (kMachineByteOrder == machine::MSB) {
     write8(AddExpr::create(offset,
                            ConstantExpr::create(0, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,3));
+           ExtractExpr::create(value, 24, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(1, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,2));
+           ExtractExpr::create(value, 16, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(2, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,1));
+           ExtractExpr::create(value, 8, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(3, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,0));
+           ExtractExpr::create(value, 0, Expr::Int8));
   } else {
     write8(AddExpr::create(offset,
                            ConstantExpr::create(3, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,3));
+           ExtractExpr::create(value, 24, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(2, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,2));
+           ExtractExpr::create(value, 16, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(1, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,1));
+           ExtractExpr::create(value, 8, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(0, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,0));
+           ExtractExpr::create(value, 0, Expr::Int8));
   }
 }
 
@@ -785,23 +785,23 @@ void ObjectState::write64(unsigned offset, uint64_t value) {
 
 void ObjectState::write64(unsigned offset, ref<Expr> value) {
   if (kMachineByteOrder == machine::MSB) {
-    write8(offset+0, ExtractExpr::createByteOff(value, 7));
-    write8(offset+1, ExtractExpr::createByteOff(value, 6));
-    write8(offset+2, ExtractExpr::createByteOff(value, 5));
-    write8(offset+3, ExtractExpr::createByteOff(value, 4));
-    write8(offset+4, ExtractExpr::createByteOff(value, 3));
-    write8(offset+5, ExtractExpr::createByteOff(value, 2));
-    write8(offset+6, ExtractExpr::createByteOff(value, 1));
-    write8(offset+7, ExtractExpr::createByteOff(value, 0));
+    write8(offset+0, ExtractExpr::create(value, 56, Expr::Int8));
+    write8(offset+1, ExtractExpr::create(value, 48, Expr::Int8));
+    write8(offset+2, ExtractExpr::create(value, 40, Expr::Int8));
+    write8(offset+3, ExtractExpr::create(value, 32, Expr::Int8));
+    write8(offset+4, ExtractExpr::create(value, 24, Expr::Int8));
+    write8(offset+5, ExtractExpr::create(value, 16, Expr::Int8));
+    write8(offset+6, ExtractExpr::create(value, 8, Expr::Int8));
+    write8(offset+7, ExtractExpr::create(value, 0, Expr::Int8));
   } else {
-    write8(offset+7, ExtractExpr::createByteOff(value, 7));
-    write8(offset+6, ExtractExpr::createByteOff(value, 6));
-    write8(offset+5, ExtractExpr::createByteOff(value, 5));
-    write8(offset+4, ExtractExpr::createByteOff(value, 4));
-    write8(offset+3, ExtractExpr::createByteOff(value, 3));
-    write8(offset+2, ExtractExpr::createByteOff(value, 2));
-    write8(offset+1, ExtractExpr::createByteOff(value, 1));
-    write8(offset+0, ExtractExpr::createByteOff(value, 0));
+    write8(offset+7, ExtractExpr::create(value, 56, Expr::Int8));
+    write8(offset+6, ExtractExpr::create(value, 48, Expr::Int8));
+    write8(offset+5, ExtractExpr::create(value, 40, Expr::Int8));
+    write8(offset+4, ExtractExpr::create(value, 32, Expr::Int8));
+    write8(offset+3, ExtractExpr::create(value, 24, Expr::Int8));
+    write8(offset+2, ExtractExpr::create(value, 16, Expr::Int8));
+    write8(offset+1, ExtractExpr::create(value, 8, Expr::Int8));
+    write8(offset+0, ExtractExpr::create(value, 0, Expr::Int8));
   }
 }
 
@@ -809,53 +809,53 @@ void ObjectState::write64(ref<Expr> offset, ref<Expr> value) {
   if (kMachineByteOrder == machine::MSB) {
     write8(AddExpr::create(offset,
                            ConstantExpr::create(0, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,7));
+           ExtractExpr::create(value, 56, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(1, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,6));
+           ExtractExpr::create(value, 48, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(2, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,5));
+           ExtractExpr::create(value, 40, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(3, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,4));
+           ExtractExpr::create(value, 32, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(4, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,3));
+           ExtractExpr::create(value, 24, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(5, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,2));
+           ExtractExpr::create(value, 16, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(6, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,1));
+           ExtractExpr::create(value, 8, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(7, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,0));
+           ExtractExpr::create(value, 0, Expr::Int8));
   } else {
     write8(AddExpr::create(offset,
                            ConstantExpr::create(7, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,7));
+           ExtractExpr::create(value, 56, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(6, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,6));
+           ExtractExpr::create(value, 48, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(5, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,5));
+           ExtractExpr::create(value, 40, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(4, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,4));
+           ExtractExpr::create(value, 32, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(3, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,3));
+           ExtractExpr::create(value, 24, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(2, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,2));
+           ExtractExpr::create(value, 16, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(1, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,1));
+           ExtractExpr::create(value, 8, Expr::Int8));
     write8(AddExpr::create(offset,
                            ConstantExpr::create(0, kMachinePointerType)), 
-           ExtractExpr::createByteOff(value,0));
+           ExtractExpr::create(value, 0, Expr::Int8));
   }
 }
 
diff --git a/lib/Expr/Expr.cpp b/lib/Expr/Expr.cpp
index e82285dd..5ef71d8c 100644
--- a/lib/Expr/Expr.cpp
+++ b/lib/Expr/Expr.cpp
@@ -669,11 +669,6 @@ ref<Expr> ExtractExpr::create(ref<Expr> expr, unsigned off, Width w) {
   return ExtractExpr::alloc(expr, off, w);
 }
 
-
-ref<Expr> ExtractExpr::createByteOff(ref<Expr> expr, unsigned offset, Width bits) {
-  return ExtractExpr::create(expr, 8*offset, bits);
-}
-
 /***/
 
 ref<Expr> ZExtExpr::create(const ref<Expr> &e, Width w) {
@@ -681,7 +676,7 @@ ref<Expr> ZExtExpr::create(const ref<Expr> &e, Width w) {
   if (w == kBits) {
     return e;
   } else if (w < kBits) { // trunc
-    return ExtractExpr::createByteOff(e, 0, w);
+    return ExtractExpr::create(e, 0, w);
   } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(e)) {
     return CE->ZExt(w);
   } else {
@@ -694,7 +689,7 @@ ref<Expr> SExtExpr::create(const ref<Expr> &e, Width w) {
   if (w == kBits) {
     return e;
   } else if (w < kBits) { // trunc
-    return ExtractExpr::createByteOff(e, 0, w);
+    return ExtractExpr::create(e, 0, w);
   } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(e)) {
     return CE->SExt(w);
   } else {