Add mlir-emitc submodule and extend CMake configuration
This add an EmitC dialect (forked from https://reviews.llvm.org/D76571) which is available under *Apache License v2.0 with LLVM Exceptions*. The idea is to make progress on #1173 and to utilize and extend the EmitC dialect proposed by @jpienaar for this.
Building the dialect can be enabled by `IREE_ENABLE_EMITC` in CMake. A Bazel configuration is not yet available. No additional LLVM/MLIR deps are pulled in, since `IREE_ENABLE_EMITC` results in using the `tools/init_mlir_{dialects,passes}.h` headers. No dep on the IREE target itself is introduced, instead the MLIR deps are "replicated". Also not super clean, this avoids a circular dependency and allows to avoid unnecessary dependencies (eg. on AVX512 and NVVMIR).
The final goal is to push EmitC upstream or to integrate it into IREE (at least). I am further happy to grant write access to the [mlir-emitc](https://github.com/iml130/mlir-emitc/) repo for outside collaborators as long as this doesn't prevent pushing towards MLIR or to integrate it into IREE.
Closes https://github.com/google/iree/pull/2060
PiperOrigin-RevId: 314400071
diff --git a/.gitmodules b/.gitmodules
index 8733410..3ed8ebc 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -47,3 +47,6 @@
[submodule "third_party/tracy"]
path = third_party/tracy
url = https://github.com/wolfpld/tracy.git
+[submodule "third_party/mlir-emitc"]
+ path = third_party/mlir-emitc
+ url = https://github.com/iml130/mlir-emitc.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 04a3ac8..1eeeb07 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,6 +35,7 @@
option(IREE_ENABLE_RUNTIME_TRACING "Enables instrumented runtime tracing." OFF)
option(IREE_ENABLE_LLVM "Enables LLVM dependencies." ON)
+option(IREE_ENABLE_EMITC "Enables MLIR EmitC dependencies." OFF)
option(IREE_BUILD_COMPILER "Builds the IREE compiler." ON)
option(IREE_BUILD_TESTS "Builds IREE unit tests." ON)
@@ -58,6 +59,10 @@
set(IREE_ENABLE_LLVM ON CACHE BOOL "Enable LLVM dependencies if the IREE compiler is build." FORCE)
endif()
+if(${IREE_ENABLE_EMITC} AND NOT ${IREE_ENABLE_LLVM})
+ message(FATAL_ERROR "Enabling EmitC requires setting IREE_ENABLE_LLVM to ON.")
+endif()
+
#-------------------------------------------------------------------------------
# IREE-specific CMake configuration
#-------------------------------------------------------------------------------
@@ -199,6 +204,9 @@
endif()
add_subdirectory(third_party/llvm-project/llvm EXCLUDE_FROM_ALL)
+ if(${IREE_ENABLE_EMITC})
+ add_subdirectory(third_party/mlir-emitc EXCLUDE_FROM_ALL)
+ endif()
# Reset CMAKE_BUILD_TYPE to its previous setting
set(CMAKE_BUILD_TYPE "${_CMAKE_BUILD_TYPE}" CACHE STRING "Build type (default ${DEFAULT_CMAKE_BUILD_TYPE})" FORCE)
diff --git a/SUBMODULE_VERSIONS b/SUBMODULE_VERSIONS
index 7b1a6a3..b62812c 100644
--- a/SUBMODULE_VERSIONS
+++ b/SUBMODULE_VERSIONS
@@ -4,6 +4,7 @@
a5d9d0f7d368054fd1691aedf1db4116efcc233e third_party/flatbuffers
f2fb48c3b3d79a75a88a99fba6576b25d42ec528 third_party/googletest
a8ca0ec267050f9ded865a729d50c2c0eb078b7e third_party/llvm-project
+53265de20088f8b2af381c77173b22764cbfc038 third_party/mlir-emitc
80d452484c5409444b0ec19383faa84bb7a4d351 third_party/pybind11
9f53ba413e6fc879236dcaa3e008915973d67a4f third_party/ruy
b73f111094da3e380a1774b56b15f16c90ae8e23 third_party/sdl2
diff --git a/third_party/mlir-emitc b/third_party/mlir-emitc
new file mode 160000
index 0000000..53265de
--- /dev/null
+++ b/third_party/mlir-emitc
@@ -0,0 +1 @@
+Subproject commit 53265de20088f8b2af381c77173b22764cbfc038