about summary refs log tree commit diff homepage
path: root/lib/SMT/SMTParser.cpp
diff options
context:
space:
mode:
authorCristian Cadar <cristic@cs.stanford.edu>2009-07-08 02:35:55 +0000
committerCristian Cadar <cristic@cs.stanford.edu>2009-07-08 02:35:55 +0000
commit65319873a052826cbea5198815316f676bb86a84 (patch)
treedf2663e838a8ae608c96b373a3197a508c652b47 /lib/SMT/SMTParser.cpp
parentef6e35242fefee2a3bbbd3c247a3b2291b5965d4 (diff)
downloadklee-65319873a052826cbea5198815316f676bb86a84.tar.gz
Added support for bitvector variables to the SMTLIB parser (currently
widths have to be multiples of 8).



git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@74990 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/SMT/SMTParser.cpp')
-rw-r--r--lib/SMT/SMTParser.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/SMT/SMTParser.cpp b/lib/SMT/SMTParser.cpp
index 6e40978a..619d7ff6 100644
--- a/lib/SMT/SMTParser.cpp
+++ b/lib/SMT/SMTParser.cpp
@@ -77,6 +77,28 @@ int SMTParser::StringToInt(const std::string& s) {
 }
 
 
+void SMTParser::DeclareExpr(std::string name, Expr::Width w) {
+  // for now, only allow variables which are multiples of 8
+  if (w % 8 != 0) {
+    cout << "BitVec not multiple of 8 (" << w << ").  Need to update code.\n";
+    exit(1);
+  }
+  
+  std::cout << "Declaring " << name << " of width " << w << "\n";
+  
+  Array *arr = new Array(name, w / 8);
+  
+  ref<Expr> *kids = new ref<Expr>[w/8];
+  for (unsigned i=0; i < w/8; i++)
+    kids[i] = ReadExpr::create(UpdateList(arr, NULL), 
+			       ConstantExpr::create(i, 32));
+  ref<Expr> var = ConcatExpr::createN(w/8, kids);
+  delete [] kids;
+  
+  AddVar(name, var);
+}
+
+
 ExprHandle SMTParser::GetConstExpr(std::string val, uint8_t base, klee::Expr::Width w) {
   cerr << "In GetConstExpr(): val=" << val << ", base=" << (unsigned)base << ", width=" << w << "\n";
   assert(base == 2 || base == 10 || base == 16);