about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorDan Liew <daniel.liew@imperial.ac.uk>2016-01-14 16:59:08 +0000
committerDan Liew <daniel.liew@imperial.ac.uk>2016-02-10 20:56:22 +0000
commit37694e11c7a767105244ec563b061d13f0779f05 (patch)
tree8948d430d72373221eb0c34a85a1127d033efab7
parente6ba74cf608cf733916f0df2471c6a5fc5a804cf (diff)
downloadklee-37694e11c7a767105244ec563b061d13f0779f05.tar.gz
Add some of the basic plumbing required to support a Z3 solver in KLEE.
-rw-r--r--Makefile.common4
-rw-r--r--include/klee/CommandLine.h2
-rw-r--r--lib/Basic/CmdLineOptions.cpp10
-rw-r--r--lib/Solver/CoreSolver.cpp9
-rw-r--r--tools/kleaver/Makefile4
-rw-r--r--tools/klee/Makefile4
-rw-r--r--unittests/Solver/Makefile4
7 files changed, 36 insertions, 1 deletions
diff --git a/Makefile.common b/Makefile.common
index 4ec1d4c6..9bc850ba 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -66,6 +66,10 @@ ifneq ($(ENABLE_STP),0)
   CXX.Flags += -DEXT_HASH_MAP
 endif
 
+ifneq ($(ENABLE_Z3),0)
+  CXX.Flags += $(Z3_CFLAGS)
+endif
+
 CXX.Flags += -DKLEE_DIR=\"$(PROJ_OBJ_ROOT)\" -DKLEE_INSTALL_BIN_DIR=\"$(PROJ_bindir)\"
 CXX.Flags += -DKLEE_INSTALL_RUNTIME_DIR=\"$(BYTECODE_DESTINATION)\"
 
diff --git a/include/klee/CommandLine.h b/include/klee/CommandLine.h
index dc0f135a..00cdeebb 100644
--- a/include/klee/CommandLine.h
+++ b/include/klee/CommandLine.h
@@ -44,7 +44,7 @@ enum QueryLoggingSolverType
  */
 extern llvm::cl::list<QueryLoggingSolverType> queryLoggingOptions;
 
-enum CoreSolverType { STP_SOLVER, METASMT_SOLVER, DUMMY_SOLVER };
+enum CoreSolverType { STP_SOLVER, METASMT_SOLVER, DUMMY_SOLVER, Z3_SOLVER };
 extern llvm::cl::opt<CoreSolverType> CoreSolverToUse;
 
 #ifdef ENABLE_METASMT
diff --git a/lib/Basic/CmdLineOptions.cpp b/lib/Basic/CmdLineOptions.cpp
index b7502023..70ee736e 100644
--- a/lib/Basic/CmdLineOptions.cpp
+++ b/lib/Basic/CmdLineOptions.cpp
@@ -92,11 +92,19 @@ llvm::cl::opt<klee::MetaSMTBackendType> MetaSMTBackend(
 #ifdef ENABLE_STP
 #define STP_IS_DEFAULT_STR " (default)"
 #define METASMT_IS_DEFAULT_STR ""
+#define Z3_IS_DEFAULT_STR ""
 #define DEFAULT_CORE_SOLVER STP_SOLVER
+#elif ENABLE_Z3
+#define STP_IS_DEFAULT_STR ""
+#define METASMT_IS_DEFAULT_STR ""
+#define Z3_IS_DEFAULT_STR " (default)"
+#define DEFAULT_CORE_SOLVER Z3_SOLVER
 #elif ENABLE_METASMT
 #define STP_IS_DEFAULT_STR ""
 #define METASMT_IS_DEFAULT_STR " (default)"
+#define Z3_IS_DEFAULT_STR ""
 #define DEFAULT_CORE_SOLVER METASMT_SOLVER
+#define Z3_IS_DEFAULT_STR ""
 #else
 #error "Unsupported solver configuration"
 #endif
@@ -105,11 +113,13 @@ llvm::cl::opt<CoreSolverType> CoreSolverToUse(
     llvm::cl::values(clEnumValN(STP_SOLVER, "stp", "stp" STP_IS_DEFAULT_STR),
                      clEnumValN(METASMT_SOLVER, "metasmt", "metaSMT" METASMT_IS_DEFAULT_STR),
                      clEnumValN(DUMMY_SOLVER, "dummy", "Dummy solver"),
+                     clEnumValN(Z3_SOLVER, "z3", "Z3" Z3_IS_DEFAULT_STR),
                      clEnumValEnd),
     llvm::cl::init(DEFAULT_CORE_SOLVER));
 }
 #undef STP_IS_DEFAULT_STR
 #undef METASMT_IS_DEFAULT_STR
+#undef Z3_IS_DEFAULT_STR
 #undef DEFAULT_CORE_SOLVER
 
 
diff --git a/lib/Solver/CoreSolver.cpp b/lib/Solver/CoreSolver.cpp
index 9248f3d3..26842d31 100644
--- a/lib/Solver/CoreSolver.cpp
+++ b/lib/Solver/CoreSolver.cpp
@@ -86,6 +86,15 @@ Solver *createCoreSolver(CoreSolverType cst) {
 #endif
   case DUMMY_SOLVER:
     return createDummySolver();
+  case Z3_SOLVER:
+#ifdef ENABLE_Z3
+    // TODO
+    llvm::report_fatal_error("Z3 support not implemented");
+    return NULL;
+#else
+    llvm::errs() << "Not compiled with Z3 support\n";
+    return NULL;
+#endif
   default:
     llvm_unreachable("Unsupported CoreSolverType");
   }
diff --git a/tools/kleaver/Makefile b/tools/kleaver/Makefile
index ece2b799..08249444 100644
--- a/tools/kleaver/Makefile
+++ b/tools/kleaver/Makefile
@@ -23,4 +23,8 @@ ifneq ($(ENABLE_STP),0)
   LIBS += $(STP_LDFLAGS)
 endif
 
+ifneq ($(ENABLE_Z3),0)
+  LIBS += $(Z3_LDFLAGS)
+endif
+
 include $(PROJ_SRC_ROOT)/MetaSMT.mk
diff --git a/tools/klee/Makefile b/tools/klee/Makefile
index d807350d..e3364e77 100644
--- a/tools/klee/Makefile
+++ b/tools/klee/Makefile
@@ -24,4 +24,8 @@ ifneq ($(ENABLE_STP),0)
   LIBS += $(STP_LDFLAGS)
 endif
 
+ifneq ($(ENABLE_Z3),0)
+  LIBS += $(Z3_LDFLAGS)
+endif
+
 include $(PROJ_SRC_ROOT)/MetaSMT.mk
diff --git a/unittests/Solver/Makefile b/unittests/Solver/Makefile
index 1d3d609e..4b58628f 100644
--- a/unittests/Solver/Makefile
+++ b/unittests/Solver/Makefile
@@ -13,4 +13,8 @@ ifneq ($(ENABLE_STP),0)
   LIBS += $(STP_LDFLAGS)
 endif
 
+ifneq ($(ENABLE_Z3),0)
+  LIBS += $(Z3_LDFLAGS)
+endif
+
 include $(PROJ_SRC_ROOT)/MetaSMT.mk