Skip to content

Commit 7598a8e

Browse files
authored
[circt-lec] Port to SMT dialect based compiler pipeline (#6908)
1 parent da900a2 commit 7598a8e

31 files changed

+484
-1430
lines changed

CMakeLists.txt

+6-8
Original file line numberDiff line numberDiff line change
@@ -464,13 +464,13 @@ endif()
464464
llvm_canonicalize_cmake_booleans(CIRCT_LLHD_SIM_ENABLED)
465465

466466
#-------------------------------------------------------------------------------
467-
# circt-lec Configuration
467+
# Z3Lib Configuration (for circt-lec and SMT dialect integration tests)
468468
#-------------------------------------------------------------------------------
469469

470-
# If circt-lec hasn't been explicitly disabled, find it.
471-
option(CIRCT_LEC_DISABLE "Disable the Logical Equivalence Checker" OFF)
472-
if(CIRCT_LEC_DISABLE)
473-
message(STATUS "Disabling circt-lec")
470+
# If z3 hasn't been explicitly disabled, find it.
471+
option(Z3_DISABLE "Disable the z3 tests.")
472+
if (Z3_DISABLE)
473+
message(STATUS "Disabling tests requiring z3.")
474474
else()
475475
if(Z3_DIR)
476476
# Search and load the package configuration file in the specified directory.
@@ -485,15 +485,13 @@ else()
485485
# Attempt initialising Z3 according to LLVM's `FindZ3` CMake module.
486486
find_package(Z3)
487487
endif()
488-
488+
489489
if(Z3_FOUND)
490490
SET(CIRCT_LEC_Z3_VER 4.8.11)
491491
if(Z3_VERSION_STRING VERSION_LESS ${CIRCT_LEC_Z3_VER})
492492
message(WARNING "Cannot build circt-lec with outdated Z3 version ${Z3_VERSION_STRING}, requires ${CIRCT_LEC_Z3_VER}.")
493493
else()
494494
message(STATUS "Z3 identified as a logical backend.")
495-
# Signal to proceed building circt-lec.
496-
set(CIRCT_LEC_ENABLED ON)
497495
endif()
498496
endif()
499497
endif()

include/circt/Conversion/Passes.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def ConvertCombToSMT : Pass<"convert-comb-to-smt", "mlir::ModuleOp"> {
701701

702702
def ConvertHWToSMT : Pass<"convert-hw-to-smt", "mlir::ModuleOp"> {
703703
let summary = "Convert HW ops and constants to SMT ops";
704-
let dependentDialects = ["smt::SMTDialect"];
704+
let dependentDialects = ["smt::SMTDialect", "mlir::func::FuncDialect"];
705705
}
706706

707707
//===----------------------------------------------------------------------===//

include/circt/Dialect/SMT/SMTAttributes.h

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
#include "mlir/IR/BuiltinAttributeInterfaces.h"
1414
#include "mlir/IR/BuiltinAttributes.h"
1515

16+
namespace circt {
17+
namespace smt {
18+
namespace detail {
19+
20+
struct BitVectorAttrStorage;
21+
22+
} // namespace detail
23+
} // namespace smt
24+
} // namespace circt
25+
1626
#define GET_ATTRDEF_CLASSES
1727
#include "circt/Dialect/SMT/SMTAttributes.h.inc"
1828

include/circt/Dialect/SMT/SMTAttributes.td

+10
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ def BitVectorAttr : AttrDef<SMTDialect, "BitVector", [
5050
let hasCustomAssemblyFormat = true;
5151
let genVerifyDecl = true;
5252

53+
// We need to manually define the storage class because the generated one is
54+
// buggy (because the APInt asserts matching bitwidth in the `==` operator and
55+
// the generated storage uses that directly.
56+
// Alternatively: add a type parameter to redundantly store the bitwidth of
57+
// of the attribute type, it it's in the order before the 'value' it will be
58+
// checked before the APInt equality (this is the reason it works for the
59+
// builtin integer attribute), but would be more fragile (and we'd store
60+
// duplicate data).
61+
let genStorageClass = false;
62+
5363
let builders = [
5464
AttrBuilder<(ins "llvm::StringRef":$value)>,
5565
AttrBuilder<(ins "uint64_t":$value, "unsigned":$width)>,

include/circt/LogicalEquivalence/Circuit.h

-119
This file was deleted.

include/circt/LogicalEquivalence/LogicExporter.h

-57
This file was deleted.

include/circt/LogicalEquivalence/Solver.h

-79
This file was deleted.

0 commit comments

Comments
 (0)