2020-11-22 14:08:48 +08:00
|
|
|
##===- CMakeLists.txt - CIRCT cmake root ----------------------*- cmake -*-===//
|
|
|
|
##
|
|
|
|
## Configure the CIRCT build.
|
|
|
|
##
|
|
|
|
##===----------------------------------------------------------------------===//
|
|
|
|
|
2021-07-29 23:49:58 +08:00
|
|
|
cmake_minimum_required(VERSION 3.13.4)
|
2020-03-06 07:16:55 +08:00
|
|
|
|
2020-06-18 04:27:14 +08:00
|
|
|
if(POLICY CMP0068)
|
|
|
|
cmake_policy(SET CMP0068 NEW)
|
|
|
|
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
|
|
|
|
endif()
|
2020-03-06 07:16:55 +08:00
|
|
|
|
2020-06-18 04:27:14 +08:00
|
|
|
if(POLICY CMP0075)
|
|
|
|
cmake_policy(SET CMP0075 NEW)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(POLICY CMP0077)
|
|
|
|
cmake_policy(SET CMP0077 NEW)
|
|
|
|
endif()
|
2020-03-06 07:16:55 +08:00
|
|
|
|
2022-04-13 09:20:37 +08:00
|
|
|
# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
|
|
|
|
# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
|
|
|
|
if(POLICY CMP0116)
|
|
|
|
cmake_policy(SET CMP0116 OLD)
|
|
|
|
endif()
|
|
|
|
|
2021-07-30 01:16:46 +08:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
|
|
|
|
2020-11-11 08:33:25 +08:00
|
|
|
# If we are not building as a part of LLVM, build Circt as an
|
|
|
|
# standalone project, using LLVM as an external library:
|
|
|
|
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
|
2021-07-29 23:49:58 +08:00
|
|
|
if (CIRCT_BINDINGS_PYTHON_ENABLED)
|
|
|
|
message(FATAL_ERROR "CIRCT Python bindings require a unified build. \
|
|
|
|
See docs/PythonBindings.md.")
|
|
|
|
endif()
|
2020-12-29 10:24:08 +08:00
|
|
|
|
2021-09-06 04:36:46 +08:00
|
|
|
# Generate a CompilationDatabase (compile_commands.json file) for our build,
|
|
|
|
# for use by clang_complete, YouCompleteMe, etc.
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
|
|
|
|
2020-12-29 10:24:08 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Project setup and globals
|
|
|
|
#-------------------------------------------------------------------------------
|
2020-11-11 08:33:25 +08:00
|
|
|
project(circt LANGUAGES CXX C)
|
2022-04-13 09:20:37 +08:00
|
|
|
|
2020-12-29 10:24:08 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Options and settings
|
|
|
|
#-------------------------------------------------------------------------------
|
2022-04-13 09:20:37 +08:00
|
|
|
|
2020-11-11 08:33:25 +08:00
|
|
|
option(LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON)
|
|
|
|
option(LLVM_BUILD_TOOLS "Build the LLVM tools. If OFF, just generate build targets." ON)
|
2021-02-14 10:56:01 +08:00
|
|
|
|
|
|
|
if (MSVC)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHs-c- /GR-")
|
|
|
|
else ()
|
2020-12-29 10:24:08 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
|
2021-02-14 10:56:01 +08:00
|
|
|
endif ()
|
2022-04-13 09:20:37 +08:00
|
|
|
|
2020-12-29 10:24:08 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# MLIR/LLVM Configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
2022-04-13 09:20:37 +08:00
|
|
|
|
2020-11-11 08:33:25 +08:00
|
|
|
find_package(MLIR REQUIRED CONFIG)
|
2022-04-13 09:20:37 +08:00
|
|
|
|
2020-11-11 08:33:25 +08:00
|
|
|
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
|
|
|
|
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
|
2022-04-13 09:20:37 +08:00
|
|
|
|
2020-11-11 08:33:25 +08:00
|
|
|
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
|
|
|
|
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
|
2022-04-13 09:20:37 +08:00
|
|
|
|
2020-11-11 08:33:25 +08:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
|
2022-04-13 09:20:37 +08:00
|
|
|
|
2020-11-11 08:33:25 +08:00
|
|
|
include(TableGen)
|
|
|
|
include(AddLLVM)
|
|
|
|
include(AddMLIR)
|
|
|
|
include(HandleLLVMOptions)
|
|
|
|
|
|
|
|
set(CIRCT_BUILT_STANDALONE 1)
|
|
|
|
set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}")
|
[Moore] Add SystemVerilog types (#2699)
Add an implementation of the SystemVerilog type system to the Moore
dialect, modeled after the one in Moore's Rust codebase:
https://github.com/fabianschuiki/moore/blob/master/src/svlog/ty.rs
This is the first step towards migrating a larger chunk of the Moore
codebase into CIRCT, as it allows Moore's codegen to start emitting
higher-level operations (e.g., `moore.mir.concat`, to be added later)
instead of directly dropping to LLHD/HW. Doing so will allow us to
eventually move the codegen over into CIRCT, and start work on
implementing the type checking and type inference on the higher-level
operations.
My hope is that we might eventually be able to reconcile the Moore types
and some of the higher-level operations with the SV dialect, since both
work with SystemVerilog, albeit for two diametrically opposed purposes.
The types are designed to very clearly distinguish between packed and
unpacked types, and provide a certain level of guarantees about the
structure of nested types through C++ types. For example, struct
aggregate types and typedefs/decltype constructs come in a packed and
unpacked flavor to enforce proper nesting of these types.
Where user-defined types are involved, for example through structs and
typedefs/decltype, the MLIR types aim to capture enough information to
faithfully reconstruct the type as it was originally formulated by the
user. This helps provide good and understandable diagnostics. As a
concrete example, integer types capture whether their sign was provided
explicitly by the user, in order to distinguish `int` and `int signed`,
despite those two types being semantically identical.
This commit also adds a `unittests` directory as seen in LLVM and MLIR,
to test the human-readable serialization of the Moore types and other
type attributes.
2022-03-04 15:48:45 +08:00
|
|
|
|
|
|
|
# Handle unittests when building out-of-tree against an installed version of
|
|
|
|
# LLVM/MLIR (not a build tree). Adapted from `llvm/flang/CMakeLists.txt`.
|
|
|
|
set(CIRCT_GTEST_AVAILABLE 0)
|
|
|
|
set(UNITTEST_DIR ${LLVM_BUILD_MAIN_SRC_DIR}/utils/unittest)
|
|
|
|
if (NOT EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h)
|
|
|
|
set(UNITTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/llvm/llvm/utils/unittest)
|
|
|
|
endif()
|
|
|
|
if (EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h)
|
2022-03-14 21:13:45 +08:00
|
|
|
if (NOT TARGET llvm_gtest)
|
[Moore] Add SystemVerilog types (#2699)
Add an implementation of the SystemVerilog type system to the Moore
dialect, modeled after the one in Moore's Rust codebase:
https://github.com/fabianschuiki/moore/blob/master/src/svlog/ty.rs
This is the first step towards migrating a larger chunk of the Moore
codebase into CIRCT, as it allows Moore's codegen to start emitting
higher-level operations (e.g., `moore.mir.concat`, to be added later)
instead of directly dropping to LLHD/HW. Doing so will allow us to
eventually move the codegen over into CIRCT, and start work on
implementing the type checking and type inference on the higher-level
operations.
My hope is that we might eventually be able to reconcile the Moore types
and some of the higher-level operations with the SV dialect, since both
work with SystemVerilog, albeit for two diametrically opposed purposes.
The types are designed to very clearly distinguish between packed and
unpacked types, and provide a certain level of guarantees about the
structure of nested types through C++ types. For example, struct
aggregate types and typedefs/decltype constructs come in a packed and
unpacked flavor to enforce proper nesting of these types.
Where user-defined types are involved, for example through structs and
typedefs/decltype, the MLIR types aim to capture enough information to
faithfully reconstruct the type as it was originally formulated by the
user. This helps provide good and understandable diagnostics. As a
concrete example, integer types capture whether their sign was provided
explicitly by the user, in order to distinguish `int` and `int signed`,
despite those two types being semantically identical.
This commit also adds a `unittests` directory as seen in LLVM and MLIR,
to test the human-readable serialization of the Moore types and other
type attributes.
2022-03-04 15:48:45 +08:00
|
|
|
find_package(Threads)
|
2022-03-14 21:13:45 +08:00
|
|
|
add_llvm_library(llvm_gtest
|
[Moore] Add SystemVerilog types (#2699)
Add an implementation of the SystemVerilog type system to the Moore
dialect, modeled after the one in Moore's Rust codebase:
https://github.com/fabianschuiki/moore/blob/master/src/svlog/ty.rs
This is the first step towards migrating a larger chunk of the Moore
codebase into CIRCT, as it allows Moore's codegen to start emitting
higher-level operations (e.g., `moore.mir.concat`, to be added later)
instead of directly dropping to LLHD/HW. Doing so will allow us to
eventually move the codegen over into CIRCT, and start work on
implementing the type checking and type inference on the higher-level
operations.
My hope is that we might eventually be able to reconcile the Moore types
and some of the higher-level operations with the SV dialect, since both
work with SystemVerilog, albeit for two diametrically opposed purposes.
The types are designed to very clearly distinguish between packed and
unpacked types, and provide a certain level of guarantees about the
structure of nested types through C++ types. For example, struct
aggregate types and typedefs/decltype constructs come in a packed and
unpacked flavor to enforce proper nesting of these types.
Where user-defined types are involved, for example through structs and
typedefs/decltype, the MLIR types aim to capture enough information to
faithfully reconstruct the type as it was originally formulated by the
user. This helps provide good and understandable diagnostics. As a
concrete example, integer types capture whether their sign was provided
explicitly by the user, in order to distinguish `int` and `int signed`,
despite those two types being semantically identical.
This commit also adds a `unittests` directory as seen in LLVM and MLIR,
to test the human-readable serialization of the Moore types and other
type attributes.
2022-03-04 15:48:45 +08:00
|
|
|
${UNITTEST_DIR}/googletest/src/gtest-all.cc
|
|
|
|
${UNITTEST_DIR}/googlemock/src/gmock-all.cc
|
|
|
|
LINK_LIBS pthread
|
|
|
|
LINK_COMPONENTS Support # llvm::raw_ostream
|
|
|
|
BUILDTREE_ONLY
|
|
|
|
)
|
2022-03-14 21:13:45 +08:00
|
|
|
target_include_directories(llvm_gtest
|
[Moore] Add SystemVerilog types (#2699)
Add an implementation of the SystemVerilog type system to the Moore
dialect, modeled after the one in Moore's Rust codebase:
https://github.com/fabianschuiki/moore/blob/master/src/svlog/ty.rs
This is the first step towards migrating a larger chunk of the Moore
codebase into CIRCT, as it allows Moore's codegen to start emitting
higher-level operations (e.g., `moore.mir.concat`, to be added later)
instead of directly dropping to LLHD/HW. Doing so will allow us to
eventually move the codegen over into CIRCT, and start work on
implementing the type checking and type inference on the higher-level
operations.
My hope is that we might eventually be able to reconcile the Moore types
and some of the higher-level operations with the SV dialect, since both
work with SystemVerilog, albeit for two diametrically opposed purposes.
The types are designed to very clearly distinguish between packed and
unpacked types, and provide a certain level of guarantees about the
structure of nested types through C++ types. For example, struct
aggregate types and typedefs/decltype constructs come in a packed and
unpacked flavor to enforce proper nesting of these types.
Where user-defined types are involved, for example through structs and
typedefs/decltype, the MLIR types aim to capture enough information to
faithfully reconstruct the type as it was originally formulated by the
user. This helps provide good and understandable diagnostics. As a
concrete example, integer types capture whether their sign was provided
explicitly by the user, in order to distinguish `int` and `int signed`,
despite those two types being semantically identical.
This commit also adds a `unittests` directory as seen in LLVM and MLIR,
to test the human-readable serialization of the Moore types and other
type attributes.
2022-03-04 15:48:45 +08:00
|
|
|
PUBLIC
|
|
|
|
"${UNITTEST_DIR}/googletest/include"
|
|
|
|
"${UNITTEST_DIR}/googlemock/include"
|
|
|
|
PRIVATE
|
|
|
|
"${UNITTEST_DIR}/googletest"
|
|
|
|
"${UNITTEST_DIR}/googlemock"
|
|
|
|
)
|
2022-03-14 21:13:45 +08:00
|
|
|
add_llvm_library(llvm_gtest_main
|
[Moore] Add SystemVerilog types (#2699)
Add an implementation of the SystemVerilog type system to the Moore
dialect, modeled after the one in Moore's Rust codebase:
https://github.com/fabianschuiki/moore/blob/master/src/svlog/ty.rs
This is the first step towards migrating a larger chunk of the Moore
codebase into CIRCT, as it allows Moore's codegen to start emitting
higher-level operations (e.g., `moore.mir.concat`, to be added later)
instead of directly dropping to LLHD/HW. Doing so will allow us to
eventually move the codegen over into CIRCT, and start work on
implementing the type checking and type inference on the higher-level
operations.
My hope is that we might eventually be able to reconcile the Moore types
and some of the higher-level operations with the SV dialect, since both
work with SystemVerilog, albeit for two diametrically opposed purposes.
The types are designed to very clearly distinguish between packed and
unpacked types, and provide a certain level of guarantees about the
structure of nested types through C++ types. For example, struct
aggregate types and typedefs/decltype constructs come in a packed and
unpacked flavor to enforce proper nesting of these types.
Where user-defined types are involved, for example through structs and
typedefs/decltype, the MLIR types aim to capture enough information to
faithfully reconstruct the type as it was originally formulated by the
user. This helps provide good and understandable diagnostics. As a
concrete example, integer types capture whether their sign was provided
explicitly by the user, in order to distinguish `int` and `int signed`,
despite those two types being semantically identical.
This commit also adds a `unittests` directory as seen in LLVM and MLIR,
to test the human-readable serialization of the Moore types and other
type attributes.
2022-03-04 15:48:45 +08:00
|
|
|
${UNITTEST_DIR}/UnitTestMain/TestMain.cpp
|
2022-03-14 21:13:45 +08:00
|
|
|
LINK_LIBS llvm_gtest
|
[Moore] Add SystemVerilog types (#2699)
Add an implementation of the SystemVerilog type system to the Moore
dialect, modeled after the one in Moore's Rust codebase:
https://github.com/fabianschuiki/moore/blob/master/src/svlog/ty.rs
This is the first step towards migrating a larger chunk of the Moore
codebase into CIRCT, as it allows Moore's codegen to start emitting
higher-level operations (e.g., `moore.mir.concat`, to be added later)
instead of directly dropping to LLHD/HW. Doing so will allow us to
eventually move the codegen over into CIRCT, and start work on
implementing the type checking and type inference on the higher-level
operations.
My hope is that we might eventually be able to reconcile the Moore types
and some of the higher-level operations with the SV dialect, since both
work with SystemVerilog, albeit for two diametrically opposed purposes.
The types are designed to very clearly distinguish between packed and
unpacked types, and provide a certain level of guarantees about the
structure of nested types through C++ types. For example, struct
aggregate types and typedefs/decltype constructs come in a packed and
unpacked flavor to enforce proper nesting of these types.
Where user-defined types are involved, for example through structs and
typedefs/decltype, the MLIR types aim to capture enough information to
faithfully reconstruct the type as it was originally formulated by the
user. This helps provide good and understandable diagnostics. As a
concrete example, integer types capture whether their sign was provided
explicitly by the user, in order to distinguish `int` and `int signed`,
despite those two types being semantically identical.
This commit also adds a `unittests` directory as seen in LLVM and MLIR,
to test the human-readable serialization of the Moore types and other
type attributes.
2022-03-04 15:48:45 +08:00
|
|
|
LINK_COMPONENTS Support # llvm::cl
|
|
|
|
BUILDTREE_ONLY
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
set(CIRCT_GTEST_AVAILABLE 1)
|
|
|
|
else()
|
|
|
|
message(WARNING "Skipping unittests since LLVM install does not include \
|
|
|
|
gtest headers and libraries")
|
|
|
|
set(CIRCT_GTEST_AVAILABLE 0)
|
|
|
|
endif()
|
|
|
|
|
2020-11-11 08:33:25 +08:00
|
|
|
else()
|
2021-07-30 05:24:57 +08:00
|
|
|
# CMake library generation settings.
|
|
|
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Default to building a static mondo-lib")
|
|
|
|
set(CMAKE_PLATFORM_NO_VERSIONED_SONAME ON CACHE BOOL
|
|
|
|
"Python soname linked libraries are bad")
|
|
|
|
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON CACHE BOOL "Hide inlines")
|
|
|
|
|
|
|
|
# The -fvisibility=hidden option only works for static builds.
|
2021-08-12 05:09:30 +08:00
|
|
|
if (BUILD_SHARED_LIBS AND (CMAKE_CXX_VISIBILITY_PRESET STREQUAL "hidden"))
|
|
|
|
message(FATAL_ERROR "CMAKE_CXX_VISIBILITY_PRESET=hidden is incompatible \
|
|
|
|
with BUILD_SHARED_LIBS.")
|
2021-07-30 05:24:57 +08:00
|
|
|
endif()
|
|
|
|
|
2021-03-10 11:03:40 +08:00
|
|
|
set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir ) # --src-root
|
|
|
|
set(MLIR_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include ) # --includedir
|
2021-08-09 01:18:10 +08:00
|
|
|
set(MLIR_TABLEGEN_OUTPUT_DIR ${LLVM_BINARY_DIR}/tools/mlir/include)
|
2020-11-11 08:33:25 +08:00
|
|
|
set(MLIR_TABLEGEN_EXE $<TARGET_FILE:mlir-tblgen>)
|
|
|
|
include_directories(SYSTEM ${MLIR_INCLUDE_DIR})
|
|
|
|
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
|
|
|
|
|
|
|
|
set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}")
|
|
|
|
endif()
|
2020-06-18 04:27:14 +08:00
|
|
|
|
|
|
|
# Define the default arguments to use with 'lit', and an option for the user to
|
|
|
|
# override.
|
|
|
|
set(LIT_ARGS_DEFAULT "-sv")
|
|
|
|
if (MSVC_IDE OR XCODE)
|
|
|
|
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
|
|
|
|
endif()
|
|
|
|
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
|
|
|
|
|
2020-12-29 10:24:08 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# CIRCT configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2020-06-18 04:27:14 +08:00
|
|
|
# CIRCT project.
|
2020-12-11 02:12:00 +08:00
|
|
|
set(CIRCT_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # --src-root
|
|
|
|
set(CIRCT_MAIN_INCLUDE_DIR ${CIRCT_MAIN_SRC_DIR}/include)
|
2020-06-18 04:27:14 +08:00
|
|
|
|
|
|
|
set(CIRCT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
2020-12-11 02:12:00 +08:00
|
|
|
set(CIRCT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
2022-01-13 17:00:57 +08:00
|
|
|
set(CIRCT_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
|
|
|
|
set(CIRCT_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib)
|
2020-06-18 04:27:14 +08:00
|
|
|
set(CIRCT_TOOLS_DIR ${CMAKE_BINARY_DIR}/bin)
|
2021-09-21 04:35:37 +08:00
|
|
|
set(CIRCT_UTILS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/utils)
|
2021-07-29 23:49:58 +08:00
|
|
|
set(CIRCT_PYTHON_PACKAGES_DIR ${CIRCT_BINARY_DIR}/python_packages)
|
2020-03-06 07:16:55 +08:00
|
|
|
|
2021-03-10 11:03:40 +08:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${MLIR_MAIN_SRC_DIR}/cmake/modules")
|
2021-01-07 05:21:07 +08:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
2020-12-11 03:53:04 +08:00
|
|
|
include(AddCIRCT)
|
|
|
|
|
2020-03-06 07:16:55 +08:00
|
|
|
# Installing the headers and docs needs to depend on generating any public
|
|
|
|
# tablegen'd targets.
|
2020-06-18 01:19:08 +08:00
|
|
|
add_custom_target(circt-headers)
|
|
|
|
set_target_properties(circt-headers PROPERTIES FOLDER "Misc")
|
|
|
|
add_custom_target(circt-doc)
|
2020-03-06 07:16:55 +08:00
|
|
|
|
2020-12-11 02:12:00 +08:00
|
|
|
# Add MLIR and LLVM headers to the include path
|
2020-06-18 04:27:14 +08:00
|
|
|
include_directories(${LLVM_INCLUDE_DIRS})
|
|
|
|
include_directories(${MLIR_INCLUDE_DIRS})
|
2020-12-11 02:12:00 +08:00
|
|
|
|
|
|
|
# Add CIRCT files to the include path
|
|
|
|
include_directories(${CIRCT_MAIN_INCLUDE_DIR})
|
2020-11-11 08:33:25 +08:00
|
|
|
include_directories(${CIRCT_INCLUDE_DIR})
|
2020-03-06 07:16:55 +08:00
|
|
|
|
2022-05-24 01:31:08 +08:00
|
|
|
# Set the release tag.
|
|
|
|
option(CIRCT_RELEASE_TAG_ENABLED "Emit the release tag to output." ON)
|
|
|
|
set(CIRCT_RELEASE_TAG "circtorg" CACHE STRING
|
|
|
|
"Prefix of the release tag (e.g. circtorg, pycde and sifive).")
|
|
|
|
|
2020-12-29 10:24:08 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Verilator Configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
2021-09-22 08:52:26 +08:00
|
|
|
|
2020-11-22 14:08:48 +08:00
|
|
|
# If Verilator hasn't been explicitly disabled, find it.
|
|
|
|
option(VERILATOR_DISABLE "Disable the Verilator tests.")
|
|
|
|
if (VERILATOR_DISABLE)
|
|
|
|
message(STATUS "Disabling Verilator tests.")
|
|
|
|
else()
|
|
|
|
# Detect if Verilator is present.
|
|
|
|
if (NOT DEFINED VERILATOR_PATH)
|
|
|
|
find_program(VERILATOR_PATH "verilator" PATHS
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/ext/bin" NO_DEFAULT_PATH)
|
|
|
|
find_program(VERILATOR_PATH "verilator")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EXISTS ${VERILATOR_PATH})
|
|
|
|
message(STATUS "Found Verilator at ${VERILATOR_PATH}.")
|
|
|
|
|
|
|
|
# Find Verilator version.
|
|
|
|
execute_process(COMMAND ${VERILATOR_PATH} --version
|
|
|
|
OUTPUT_VARIABLE VERILATOR_VERSION)
|
|
|
|
string(REGEX MATCH "Verilator (([0-9]+)\.([0-9]+)) \.*"
|
|
|
|
MATCH ${VERILATOR_VERSION})
|
2021-04-03 09:21:22 +08:00
|
|
|
# It's gotta be at least v4.110.
|
|
|
|
if (${CMAKE_MATCH_1} LESS 4.110)
|
|
|
|
message(FATAL_ERROR "CIRCT only supports Verilator version 4.110 and up. \
|
2020-11-22 14:08:48 +08:00
|
|
|
Found version: ${CMAKE_MATCH_1}. You can disable \
|
|
|
|
the Verilator tests with '-DVERILATOR_DISABLE=ON'.")
|
|
|
|
set(VERILATOR_PATH "")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(VERILATOR_PATH "")
|
|
|
|
message(STATUS "Did not find Verilator.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-03-03 23:56:45 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Vivado Configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# If vivado hasn't been explicitly disabled, find it.
|
|
|
|
option(VIVADO_DISABLE "Disable the vivado synthesis tests.")
|
|
|
|
if (VIVADO_DISABLE)
|
|
|
|
message(STATUS "Disabling vivado tests.")
|
|
|
|
else()
|
|
|
|
if (EXISTS ${VIVADO_PATH})
|
2021-04-13 11:50:24 +08:00
|
|
|
get_filename_component(VIVADO_PATH ${VIVADO_PATH} DIRECTORY)
|
2021-03-03 23:56:45 +08:00
|
|
|
message(STATUS "Setting vivado path to ${VIVADO_PATH}.")
|
|
|
|
else()
|
|
|
|
# Search for vivado's `vivado` command.
|
|
|
|
find_program(VIVADO_PATH "vivado")
|
|
|
|
if(EXISTS ${VIVADO_PATH})
|
|
|
|
# Then strip the filename.
|
|
|
|
get_filename_component(VIVADO_PATH ${VIVADO_PATH} DIRECTORY)
|
|
|
|
message(STATUS "Found vivado at ${VIVADO_PATH}.")
|
|
|
|
else()
|
|
|
|
set(VIVADO_PATH "")
|
|
|
|
message(STATUS "Did not find vivado.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-02-26 22:36:10 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Quartus Configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# If Quartus hasn't been explicitly disabled, find it.
|
|
|
|
option(QUARTUS_DISABLE "Disable the Quartus synthesis tests.")
|
|
|
|
if (QUARTUS_DISABLE)
|
|
|
|
message(STATUS "Disabling Quartus tests.")
|
|
|
|
else()
|
|
|
|
if (EXISTS ${QUARTUS_PATH})
|
|
|
|
message(STATUS "Setting Quartus path to ${QUARTUS_PATH}.")
|
|
|
|
else()
|
|
|
|
# Search for Quartus's `quartus` command.
|
|
|
|
find_program(QUARTUS_PATH "quartus")
|
|
|
|
if(EXISTS ${QUARTUS_PATH})
|
|
|
|
# Then strip the filename.
|
|
|
|
get_filename_component(QUARTUS_PATH ${QUARTUS_PATH} DIRECTORY)
|
|
|
|
message(STATUS "Found Quartus at ${QUARTUS_PATH}.")
|
|
|
|
else()
|
|
|
|
set(QUARTUS_PATH "")
|
|
|
|
message(STATUS "Did not find Quartus.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-12-29 10:24:08 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Questa Configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2020-12-23 06:30:25 +08:00
|
|
|
# If Questa hasn't been explicitly disabled, find it.
|
|
|
|
option(QUESTA_DISABLE "Disable the Questa simulation tests.")
|
|
|
|
if (QUESTA_DISABLE)
|
|
|
|
message(STATUS "Disabling Questa tests.")
|
|
|
|
else()
|
|
|
|
if (EXISTS ${QUESTA_PATH})
|
|
|
|
message(STATUS "Setting Questa path to ${QUESTA_PATH}.")
|
|
|
|
else()
|
|
|
|
# Search for Questa's `vsim` command.
|
|
|
|
find_program(QUESTA_PATH "vsim")
|
|
|
|
if(EXISTS ${QUESTA_PATH})
|
|
|
|
# Then strip the filename.
|
|
|
|
get_filename_component(QUESTA_PATH ${QUESTA_PATH} DIRECTORY)
|
|
|
|
message(STATUS "Found Questa at ${QUESTA_PATH}.")
|
|
|
|
else()
|
|
|
|
set(QUESTA_PATH "")
|
|
|
|
message(STATUS "Did not find Questa.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-12-29 10:24:08 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Yosys Configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2020-12-03 04:18:23 +08:00
|
|
|
# If Yosys hasn't been explicitly disabled, find it.
|
|
|
|
option(YOSYS_DISABLE "Disable the yosys tests.")
|
|
|
|
if (YOSYS_DISABLE)
|
|
|
|
message(STATUS "Disabling yosys tests.")
|
|
|
|
else()
|
|
|
|
find_program(YOSYS_PATH "yosys")
|
|
|
|
if(EXISTS ${YOSYS_PATH})
|
|
|
|
message(STATUS "Found yosys at ${YOSYS_PATH}.")
|
|
|
|
else()
|
|
|
|
set(YOSYS_PATH "")
|
|
|
|
message(STATUS "Did not find yosys.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2022-03-26 16:21:20 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Icarus Verilog Configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# If Icarus Verilog hasn't been explicitly disabled, find it.
|
|
|
|
option(IVERILOG_DISABLE "Disable the Icarus Verilog tests.")
|
|
|
|
if (IVERILOG_DISABLE)
|
|
|
|
message(STATUS "Disabling Icarus Verilog tests.")
|
|
|
|
else()
|
|
|
|
find_program(IVERILOG_PATH "iverilog")
|
|
|
|
if(EXISTS ${IVERILOG_PATH})
|
|
|
|
message(STATUS "Found iverilog at ${IVERILOG_PATH}.")
|
|
|
|
else()
|
|
|
|
set(IVERILOG_PATH "")
|
|
|
|
message(STATUS "Did not find iverilog.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-12-29 10:24:08 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# capnp Configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2020-11-22 14:08:48 +08:00
|
|
|
# If capnp hasn't been explicitly disabled, find it.
|
|
|
|
option(CAPNP_DISABLE "Disable Cap'nProto (needed for cosimulation).")
|
|
|
|
if (CAPNP_DISABLE)
|
|
|
|
message (STATUS "Disabling Cap'nProto.")
|
2020-10-31 04:12:15 +08:00
|
|
|
else()
|
2020-11-22 14:08:48 +08:00
|
|
|
if(DEFINED CAPNP_PATH)
|
|
|
|
set(ENV{PKG_CONFIG_PATH}
|
|
|
|
"${CAPNP_PATH}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}")
|
|
|
|
find_package(CapnProto CONFIG PATHS ${CAPNP_PATH})
|
|
|
|
else()
|
|
|
|
set(ENV{PKG_CONFIG_PATH}
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/ext/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}")
|
2021-09-08 13:28:15 +08:00
|
|
|
find_package(CapnProto CONFIG PATHS "${CMAKE_CURRENT_SOURCE_DIR}/ext")
|
2020-11-22 14:08:48 +08:00
|
|
|
endif()
|
2020-12-31 15:20:03 +08:00
|
|
|
|
|
|
|
if(CapnProto_FOUND)
|
|
|
|
set(CMAKE_INSTALL_RPATH ${capnp_LIBDIR})
|
|
|
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
endif()
|
2020-10-31 04:12:15 +08:00
|
|
|
endif()
|
|
|
|
|
2022-01-18 17:55:15 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# OR-Tools Configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
option(OR_TOOLS_DISABLE "Disable OR-Tools.")
|
|
|
|
if (OR_TOOLS_DISABLE)
|
|
|
|
message(STATUS "Disabling OR-Tools.")
|
|
|
|
else()
|
|
|
|
if(DEFINED OR_TOOLS_PATH)
|
2022-04-13 02:31:37 +08:00
|
|
|
list(APPEND CMAKE_PREFIX_PATH ${OR_TOOLS_PATH})
|
2022-01-18 17:55:15 +08:00
|
|
|
endif()
|
|
|
|
|
2022-04-13 02:31:37 +08:00
|
|
|
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/ext)
|
|
|
|
|
2022-01-18 17:55:15 +08:00
|
|
|
find_package(ortools CONFIG)
|
|
|
|
|
|
|
|
if (ortools_FOUND)
|
2022-04-13 02:31:37 +08:00
|
|
|
get_filename_component(ortools_CMAKEDIR ${ortools_DIR} DIRECTORY)
|
|
|
|
get_filename_component(ortools_LIBDIR ${ortools_CMAKEDIR} DIRECTORY)
|
2022-01-18 17:55:15 +08:00
|
|
|
list(APPEND CMAKE_INSTALL_RPATH ${ortools_LIBDIR})
|
|
|
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-03-10 11:03:40 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
2021-07-15 06:42:45 +08:00
|
|
|
# llhd-sim Configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
if(NOT WIN32)
|
|
|
|
option(CIRCT_LLHD_SIM_ENABLED "Enables LLHD sim." ON)
|
|
|
|
else()
|
|
|
|
option(CIRCT_LLHD_SIM_ENABLED "Enables LLHD sim." OFF)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CIRCT_LLHD_SIM_ENABLED)
|
|
|
|
message(STATUS "llhd-sim is enabled.")
|
|
|
|
else()
|
|
|
|
message(STATUS "llhd-sim is disabled.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
llvm_canonicalize_cmake_booleans(CIRCT_LLHD_SIM_ENABLED)
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
2021-03-10 11:03:40 +08:00
|
|
|
# Python Configuration
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
option(CIRCT_BINDINGS_PYTHON_ENABLED "Enables CIRCT Python bindings." OFF)
|
|
|
|
|
|
|
|
if(CIRCT_BINDINGS_PYTHON_ENABLED)
|
|
|
|
message(STATUS "CIRCT Python bindings are enabled.")
|
|
|
|
include(MLIRDetectPythonEnv)
|
2022-02-18 07:01:28 +08:00
|
|
|
mlir_configure_python_dev_packages()
|
2021-03-10 11:03:40 +08:00
|
|
|
else()
|
|
|
|
message(STATUS "CIRCT Python bindings are disabled.")
|
|
|
|
endif()
|
|
|
|
|
2020-12-29 10:24:08 +08:00
|
|
|
#-------------------------------------------------------------------------------
|
2021-08-10 21:36:46 +08:00
|
|
|
# Tcl bindings
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
option(CIRCT_BINDINGS_TCL_ENABLED "Enables CIRCT Tcl bindings." OFF)
|
|
|
|
|
|
|
|
llvm_canonicalize_cmake_booleans(CIRCT_BINDINGS_TCL_ENABLED)
|
|
|
|
if(CIRCT_BINDINGS_TCL_ENABLED)
|
|
|
|
message(STATUS "CIRCT Tcl bindings are enabled")
|
|
|
|
find_package(TCL 8.6 REQUIRED)
|
2021-11-03 00:06:19 +08:00
|
|
|
find_package(TclStub 8.6 REQUIRED)
|
2021-08-10 21:36:46 +08:00
|
|
|
message(STATUS "Found TCL include path: ${TCL_INCLUDE_PATH}")
|
|
|
|
message(STATUS "Found TCL library: ${TCL_LIBRARY}")
|
|
|
|
message(STATUS "Found TCL executable: ${TCL_TCLSH}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
2020-12-29 10:24:08 +08:00
|
|
|
# Directory setup
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2020-06-18 01:19:08 +08:00
|
|
|
add_subdirectory(include/circt)
|
2020-03-08 07:47:08 +08:00
|
|
|
add_subdirectory(lib)
|
2020-03-06 07:16:55 +08:00
|
|
|
add_subdirectory(tools)
|
[Moore] Add SystemVerilog types (#2699)
Add an implementation of the SystemVerilog type system to the Moore
dialect, modeled after the one in Moore's Rust codebase:
https://github.com/fabianschuiki/moore/blob/master/src/svlog/ty.rs
This is the first step towards migrating a larger chunk of the Moore
codebase into CIRCT, as it allows Moore's codegen to start emitting
higher-level operations (e.g., `moore.mir.concat`, to be added later)
instead of directly dropping to LLHD/HW. Doing so will allow us to
eventually move the codegen over into CIRCT, and start work on
implementing the type checking and type inference on the higher-level
operations.
My hope is that we might eventually be able to reconcile the Moore types
and some of the higher-level operations with the SV dialect, since both
work with SystemVerilog, albeit for two diametrically opposed purposes.
The types are designed to very clearly distinguish between packed and
unpacked types, and provide a certain level of guarantees about the
structure of nested types through C++ types. For example, struct
aggregate types and typedefs/decltype constructs come in a packed and
unpacked flavor to enforce proper nesting of these types.
Where user-defined types are involved, for example through structs and
typedefs/decltype, the MLIR types aim to capture enough information to
faithfully reconstruct the type as it was originally formulated by the
user. This helps provide good and understandable diagnostics. As a
concrete example, integer types capture whether their sign was provided
explicitly by the user, in order to distinguish `int` and `int signed`,
despite those two types being semantically identical.
This commit also adds a `unittests` directory as seen in LLVM and MLIR,
to test the human-readable serialization of the Moore types and other
type attributes.
2022-03-04 15:48:45 +08:00
|
|
|
if (CIRCT_GTEST_AVAILABLE)
|
|
|
|
add_subdirectory(unittests)
|
|
|
|
endif()
|
2020-03-06 07:16:55 +08:00
|
|
|
add_subdirectory(test)
|
2020-11-04 08:46:17 +08:00
|
|
|
add_subdirectory(integration_test)
|
2021-06-04 00:43:02 +08:00
|
|
|
add_subdirectory(frontends)
|
2020-03-06 07:16:55 +08:00
|
|
|
|
2020-12-27 12:14:58 +08:00
|
|
|
option(CIRCT_INCLUDE_DOCS "Generate build targets for the CIRCT docs.")
|
|
|
|
if (CIRCT_INCLUDE_DOCS)
|
|
|
|
add_subdirectory(docs)
|
|
|
|
endif()
|
2020-03-06 07:16:55 +08:00
|
|
|
|
2022-01-13 16:01:07 +08:00
|
|
|
install(DIRECTORY include/circt include/circt-c
|
2020-03-06 07:16:55 +08:00
|
|
|
DESTINATION include
|
2020-06-18 01:19:08 +08:00
|
|
|
COMPONENT circt-headers
|
2020-03-06 07:16:55 +08:00
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.def"
|
|
|
|
PATTERN "*.h"
|
|
|
|
PATTERN "*.inc"
|
|
|
|
PATTERN "*.td"
|
2020-11-12 07:35:10 +08:00
|
|
|
PATTERN "*.sv"
|
2020-03-06 07:16:55 +08:00
|
|
|
PATTERN "LICENSE.TXT"
|
|
|
|
)
|
|
|
|
|
2022-01-13 16:01:07 +08:00
|
|
|
install(DIRECTORY ${CIRCT_INCLUDE_DIR}/circt ${CIRCT_INCLUDE_DIR}/circt-c
|
2020-03-06 07:16:55 +08:00
|
|
|
DESTINATION include
|
2020-06-18 01:19:08 +08:00
|
|
|
COMPONENT circt-headers
|
2020-03-06 07:16:55 +08:00
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.def"
|
|
|
|
PATTERN "*.h"
|
|
|
|
PATTERN "*.gen"
|
|
|
|
PATTERN "*.inc"
|
|
|
|
PATTERN "*.td"
|
|
|
|
PATTERN "CMakeFiles" EXCLUDE
|
|
|
|
PATTERN "config.h" EXCLUDE
|
|
|
|
)
|
|
|
|
|
|
|
|
if (NOT LLVM_ENABLE_IDE)
|
2020-06-18 01:19:08 +08:00
|
|
|
add_llvm_install_targets(install-circt-headers
|
|
|
|
DEPENDS circt-headers
|
|
|
|
COMPONENT circt-headers)
|
2020-03-06 07:16:55 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_subdirectory(cmake/modules)
|
2021-03-19 06:07:24 +08:00
|
|
|
|
|
|
|
# Set RPATH to $ORIGIN on all targets.
|
|
|
|
function(set_rpath_all_targets dir)
|
|
|
|
get_property(subdirectories DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
|
|
|
|
foreach(subdir ${subdirectories})
|
|
|
|
set_rpath_all_targets(${subdir})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
get_directory_property(LCL_TARGETS DIRECTORY ${dir} BUILDSYSTEM_TARGETS)
|
|
|
|
set_property(TARGET ${LCL_TARGETS} PROPERTY INSTALL_RPATH "$ORIGIN/../lib")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
option(STANDALONE_INSTALL "Create an 'install' for packaging which doesn't \
|
|
|
|
require installation" off)
|
|
|
|
if (STANDALONE_INSTALL)
|
|
|
|
message(STATUS "Setting an $ORIGIN-based RPATH on all executables")
|
|
|
|
set_rpath_all_targets(${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
endif()
|