summaryrefslogtreecommitdiff
path: root/mlir/CMakeLists.txt
AgeCommit message (Collapse)Author
2025-11-19[MLIR][Python] make sure stubs get installed with ↵Maksim Levental
LLVM_DISTRIBUTION_COMPONENTS (#168407) Fixes https://github.com/llvm/llvm-project/issues/168393. Also adds top-level `MLIR_PYTHON_STUBGEN_ENABLED` CMake option.
2025-08-30[MLIR][Python] fix standalone example/test (#156197)Maksim Levental
Fix some things in `standalone` in order to unblock https://github.com/llvm/llvm-project/pull/155741.
2025-08-13[MLIR][GPU][XeVM] Add XeVM target and XeVM dialect integration tests. (#148286)Sang Ik Lee
As part of XeVM dialect upsteaming, covers remaining parts required for XeVM dialect integration and testing. It has two high level components - XeVM target and serialization support - XeVM dialect integration tests using level zero runtime Co-Authored-by: Artem Kroviakov <artem.kroviakov@intel.com>
2025-08-06[mlir][ExecutionEngine] Add LevelZeroRuntimeWrapper. (#151038)Md Abdullah Shahneous Bari
Adds LevelZeroRuntime wrapper and tests. Co-authored-by: Artem Kroviakov <artem.kroviakov@intel.com> Co-authored-by: Nishant Patel <nishant.b.patel@intel.com> --------- Co-authored-by: Artem Kroviakov <artem.kroviakov@intel.com> Co-authored-by: Nishant Patel <nishant.b.patel@intel.com>
2025-06-23[mlir][python] add `MLIR_BINDINGS_PYTHON_INSTALL_PREFIX` to make bindings ↵Maksim Levental
install dir configurable (#124878) This PR parameterizes the install directory of the MLIR Python bindings in the final distribution.
2025-05-25[MLIR][IRDL] Added IRDL to C++ Translation (#141248)Ivan Ho
This PR introduces a new tool, mlir-irdl-to-cpp, that converts IRDL to C++ definitions. The C++ definitions allow use of the IRDL-defined dialect in MLIR C++ infrastructure, enabling the use of conversion patterns with IRDL dialects for example. This PR also adds CMake utilities to easily integrate the IRDL dialects into MLIR projects. Note that most IRDL features are not supported. In general, we are only able to define simple types and operations. - The only type constraint supported is irdl.any. - Variadic operands and results are not supported. - Verifiers for the IRDL constraints are not generated. - Attributes are not supported. --------- Co-authored-by: Théo Degioanni <theo.degioanni.llvm.deluge062@simplelogin.fr> Co-authored-by: Fehr Mathieu <mathieu.fehr@gmail.com>
2025-05-22[CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS in standalone builds ↵jeremyd2019
(#138587) In #138329, _GNU_SOURCE was added for Cygwin, but when building Clang standalone against an installed LLVM this definition was not picked up, resulting in undefined strnlen. Follow the documentation in https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project and add the LLVM_DEFINITIONS in standalone projects' cmakes.
2025-05-02Revert "[MLIR][IRDL] Added IRDL to C++ Translation" (#138285)Théo Degioanni
Reverts llvm/llvm-project#133982
2025-05-02[MLIR][IRDL] Added IRDL to C++ Translation (#133982)Ivan Ho
This PR introduces a new tool, mlir-irdl-to-cpp, that converts IRDL to C++ definitions. The C++ definitions allow use of the IRDL-defined dialect in MLIR C++ infrastructure, enabling the use of conversion patterns with IRDL dialects for example. This PR also adds CMake utilities to easily integrate the IRDL dialects into MLIR projects. Note that most IRDL features are not supported. In general, we are only able to define simple types and operations. - The only type constraint supported is `irdl.any`. - Variadic operands and results are not supported. - Verifiers for the IRDL constraints are not generated. - Attributes are not supported. --------- Co-authored-by: Théo Degioanni <theo.degioanni.llvm.deluge062@simplelogin.fr> Co-authored-by: Fehr Mathieu <mathieu.fehr@gmail.com>
2025-01-16[mlir][python][cmake] Allows for specifying `NB_DOMAIN` in ↵erwei-xilinx
`add_mlir_python_extension` (#122865) This PR allows the users to specify the `NB_DOMAIN` for `add_mlir_python_extension`. This allows users to avoid nanobind domain conflicts, when python bindings from multiple `mlir` projects were imported. (https://nanobind.readthedocs.io/en/latest/faq.html#how-can-i-avoid-conflicts-with-other-projects-using-nanobind)
2025-01-07Cosmetic fixes in the code and typos in Python bindings docs (#121791)vfdev
Description: - removed trailing spaces in few files - fixed markdown link definition:
2025-01-01[mlir] Prepend include directories before LLVM includes (#121223)Michał Górny
Prepend mlir's include directories before system LLVM include directories. This is particularly important for standalone builds, where system include directory may contain the previous version of mlir, and therefore various mlir targets (particularly tablegen) end up using the headers from the previous version over the fresh ones. The new logic is copied from clang.
2024-12-25[mlir] [test] Fix unittests in standalone builds (#120910)Michał Górny
Fix the logic used to run unit tests to account for `llvm_gtest` targets being installed, since 91b3ca39667b6341a8c1983a1467fae14b58318b. This involves removing a rule that would cause a duplicate `llvm_gtest` target being created, and updates the method for determining whether unittests can be run to checking whether the target is present, rather than the source directory (that is no longer actually necessary).
2024-12-25[mlir] [test] Fix missing SHLIB definition in standalone builds (#120907)Michał Górny
Define the `LLVM_SHLIB_OUTPUT_INTDIR` variable that is used by `configure_lit_site_cfg` to fill `SHLIBDIR`. This fixes tool tests that would otherwise be unable to find MLIR's runtime shared libraries (e.g. `libmlir_runner_utils.so`). The logic is copied verbatim from Clang.
2024-12-12[mlir] Add support for MLIR_LINK_MLIR_DYLIB (#119408)Nikita Popov
While MLIR currently supports building a libMLIR.so, it does not support actually linking against it for its own tools. When building with LTO, this means we have to relink the world for every tool, and the resulting binaries are large. This adds basic support for MLIR_LINK_MLIR_DYLIB, modelled after how CLANG_LINK_CLANG_DYLIB is implemented: Libraries that are part of libMLIR.so should be added via mlir_target_link_libraries instead of target_link_libraries. This will replace them with libMLIR.so if MLIR_LINK_MLIR_DYLIB is enabled. This adds basic support, I think there are two more things that can be done here: * C API unit tests should link against libMLIR-C.so. Currently these still link statically. * Linking the test libs (not part of libMLIR.so) still pulls in dependencies statically that should come from libMLIR.so.
2024-11-27[mlir] Add option to disable MLIR Python dev package configuration. (#117934)Stella Laurenzo
Adds a CMake option MLIR_DISABLE_CONFIGURE_PYTHON_DEV_PACKAGES which gates doing package discovery and configuration for Python dev packages by MLIR (this was made opt-out to preserve compatibility with find_package(MLIR) based uses which do not set the standard options). The default Python setup that MLIR does has been a problem for super-projects that include LLVM for a long time because it forces a very specific package discovery mechanism that is not uniform in all uses. When reviewing #117922, I noted that this would effectively be a break the world event for downstreams, forcing them to adapt their nanobind dep to the exact way that MLIR does it. Adding the option to just wholesale skip the built-in configuration heuristics at least gives us a mechanism to tell downstreams to migrate to, giving them complete control and not requiring packaging workarounds. This seemed a better option than (once again) creating a situation where downstreams could not integrate the dep change without doing tricky infra upgrades, and it removes the burden from the author of that patch from needing to think about how this affects super-projects that include MLIR (i.e. they can just be told to do it themselves as needed vs being in a wedged state and unable to upgrade).
2024-11-13[MLIR][NFC] Fix SYCL spelling (#113060)Ronan Keryell
See https://www.khronos.org/sycl/ for the official spelling of the Khronos Group standard. Also fix MLIR spelling in the neighborhood.
2024-10-18[mlir] Allow CXX standard to be overridden (#112957)Nikhil Kalra
MLIR previously hardcoded the CXX version to C++17. Updated to allow for the CXX version to be set by clients (mirrors other LLVM projects).
2024-10-18eliminating g++ warnings (#105520)Frank Schlimbach
Eliminating g++ warnings. Mostly declaring "[[maybe_unused]]", adding return statements where missing and fixing casts. @rengolin --------- Co-authored-by: Benjamin Maxwell <macdue@dueutil.tech> Co-authored-by: Renato Golin <rengolin@systemcall.eu>
2024-05-25[mlir] Revise IDE folder structure (#89749)Michael Kruse
Update the folder titles for targets in the monorepository that have not seen taken care of for some time. These are the folders that targets are organized in Visual Studio and XCode (`set_property(TARGET <target> PROPERTY FOLDER "<title>")`) when using the respective CMake's IDE generator. * Ensure that every target is in a folder * Use a folder hierarchy with each LLVM subproject as a top-level folder * Use consistent folder names between subprojects * When using target-creating functions from AddLLVM.cmake, automatically deduce the folder. This reduces the number of `set_property`/`set_target_property`, but are still necessary when `add_custom_target`, `add_executable`, `add_library`, etc. are used. A LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root CMakeLists.txt.
2024-05-24[mlir] Replace MLIR_ENABLE_CUDA_CONVERSIONS with LLVM_HAS_NVPTX_TARGET (#93008)tyb0807
LLVM_HAS_NVPTX_TARGET is automatically set depending on whether NVPTX was enabled when building LLVM. Use this instead of manually defining MLIR_ENABLE_CUDA_CONVERSIONS (whose name is a bit misleading btw).
2024-04-24[mlir][ods] Allow sharding of op definitions (#89423)Jeff Niu
Adds an option to `mlir-tblgen -gen-op-defs` `op-shard-count=N` that divides the op class definitions and op list into N segments, e.g. ``` // mlir-tblgen -gen-op-defs -op-shard-count=2 void FooDialect::initialize() { addOperations< >(); addOperations< >(); } ``` When split across multiple source files, this can help significantly improve dialect compile time for dialects with a large opset.
2024-03-06[mlir][cmake] Enable -Wundef. (#84011)Ingo Müller
This is another follow-up of #83004, which fixed a bug due to some macros not being defined in some situations. By raising warnings on undefined macros, this kind of bug is less likely to be introduced. Similar to #83004, the fix is probably adding an include to `mlir-config.h` (and potentially defining the macro there).
2024-03-05[mlir] Expose MLIR_ROCM_CONVERSIONS_ENABLED in mlir-config.h. (#83977)Ingo Müller
This is a follow up of #83004, which made the same change for `MLIR_CUDA_CONVERSIONS_ENABLED`. As the previous PR, this PR commit exposes mentioned CMake variable through `mlir-config.h` and uses the macro that is introduced with the same name. This replaces the macro `MLIR_ROCM_CONVERSIONS_ENABLED`, which the CMake files previously defined manually.
2024-02-28[mlir] Expose MLIR_CUDA_CONVERSIONS_ENABLED in mlir-config.h. (#83004)Ingo Müller
That macro was not defined in some cases and thus yielded warnings if compiled with `-Wundef`. In particular, they were not defined in the BUILD files, so the GPU targets were broken when built with Bazel. This commit exposes mentioned CMake variable through mlir-config.h and uses the macro that is introduced with the same name. This replaces the macro MLIR_CUDA_CONVERSIONS_ENABLED, which the CMake files previously defined manually.
2024-02-21[mlir][GPU] Remove the SerializeToCubin pass (#82486)Fabian Mora
The `SerializeToCubin` pass was deprecated in September 2023 in favor of GPU compilation attributes; see the [GPU compilation](https://mlir.llvm.org/docs/Dialects/GPU/#gpu-compilation) section in the `gpu` dialect MLIR docs. This patch removes `SerializeToCubin` from the repo.
2024-01-03[mlir] Add config for PDL (#69927)Jacques Pienaar
Make it so that PDL in pattern rewrites can be optionally disabled. PDL is still enabled by default and not optional bazel. So this should be a NOP for most folks, while enabling other to disable. This only works with tests disabled. With tests enabled this still compiles but tests fail as there is no lit config to disable tests that depend on PDL rewrites yet.
2024-01-04Revert "[mlir] Consider mlir-linalg-ods-gen as a tablegen tool in build ↵Muhammad Omair Javaid
(#75093)" This reverts commit 9191ac0bdb07643eefcc161c88b66d4e7058db9c. Breaks build on following buildbot: https://lab.llvm.org/buildbot/#/builders/177/builds/27432
2024-01-03Revert "[mlir] Add config for PDL (#69927)"max
This reverts commit 5930725c891b60f5fb94058c6c08a55a2e03d83e.
2024-01-03[mlir] Add config for PDL (#69927)Jacques Pienaar
Make it so that PDL in pattern rewrites can be optionally disabled. PDL is still enabled by default and not optional bazel. So this should be a NOP for most folks, while enabling other to disable. This is piped through mlir-tblgen invocation and that could be changed/avoided by splitting up the passes file instead. This only works with tests disabled. With tests enabled this still compiles but tests fail as there is no lit config to disable tests that depend on PDL rewrites yet.
2024-01-02[mlir] Consider mlir-linalg-ods-gen as a tablegen tool in build (#75093)Michael Holman
There is a bit of an issue with how `mlir-linalg-ods-yaml-gen` is classified in the MLIR build. Due to it being a tool, it is excluded from the install when using `-DLLVM_BUILD_TOOLS=OFF`. However, it is a necessary component of the build, so it can cause build issues with users of the installed LLVM, and so I think it should not be excluded. It is a tablegen-like tool, so my solution is to reclassify it that way in the build.
2023-10-26[MLIR] Add SyclRuntimeWrapper (#69648)Nishant Patel
2023-10-09[mlir] remove some GCC warning #68409 (#68528)long.chen
2023-09-11[mlir][gpu] Deprecate gpu::Serialization* passes. (#65857)Fabian Mora
Deprecate the `gpu-to-cubin` & `gpu-to-hsaco` passes in favor of the `TargetAttr` workflow. This patch removes remaining upstream uses of the aforementioned passes, including the option to use them in `mlir-opt`. A future patch will remove these passes entirely. The passes can be re-enabled in `mlir-opt` by adding the CMake flag: `-DMLIR_ENABLE_DEPRECATED_GPU_SERIALIZATION=1`.
2023-08-08[mlir][NVVM] Adds the NVVM target attribute.Fabian Mora
**For an explanation of these patches see D154153.** Commit message: This patch adds the NVVM target attribute for serializing GPU modules into strings containing cubin. Depends on D154113 and D154100 and D154097 Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D154117
2023-07-13[mlir] Don't make the ROCm conversions depend on the execution engineKrzysztof Drewniak
During a conversion to MLIR_ENABLE_EXECUTION_ENGINE from checking for the native target, the ROCm conversion passes (--serialize-to-hsaco) were mistakenly flagged for being disabled if the execution ending is not being built. These passes use LLVM to build binaries for AMD GPUs, and so require that backend to be enabled. However, they do not produce native code, nor do they interact with the JIT or any of the execution engine support libraries. When building MLIR into a compiler library that's intended to produce GPU binaries, we want to build only the AMDGPU backend and have the binary serialization passes available. This change makes that possible. It looks like the CUDA path might currently require a native target, it's hard to tell, so this commit leaves that if statement untouched. Reviewed By: fmorac Differential Revision: https://reviews.llvm.org/D155227
2023-06-21Revert "Define/guard MLIR_STANDALONE_BUILD LLVM_LIBRARY_OUTPUT_INTDIR var."Stella Laurenzo
This reverts commit f55fd19b6b565827af5fbf504952dcc35b8b7360. As noted on the original thread, other uses of LLVM_LIBRARY_OUTPUT_INTDIR are optional. Will make a separate patch that makes this use optional as well.
2023-06-20Define/guard MLIR_STANDALONE_BUILD LLVM_LIBRARY_OUTPUT_INTDIR var.Stella Laurenzo
It looks like MLIR is using the more modern CMAKE_LIBRARY_OUTPUT_DIRECTORY, but AddLLVM still uses this older LLVM specific alias. In the specific case I was running into, the empty variable was causing `-Wl,-rpath-link,` on the command line, causing the following argument to be swallowed. This was maddening, because the following argument was the .o file containing `main` and I was getting `main` undefined errors when it was clearly there. This is egregious enough that I chose to guard it. Differential Revision: https://reviews.llvm.org/D153373
2023-05-27Reland "[CMake] Bumps minimum version to 3.20.0.Mark de Wever
This reverts commit d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6. Adds the patch by @hans from https://github.com/llvm/llvm-project/issues/62719 This patch fixes the Windows build. d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6 reverted the reviews D144509 [CMake] Bumps minimum version to 3.20.0. This partly undoes D137724. This change has been discussed on discourse https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193 Note this does not remove work-arounds for older CMake versions, that will be done in followup patches. D150532 [OpenMP] Compile assembly files as ASM, not C Since CMake 3.20, CMake explicitly passes "-x c" (or equivalent) when compiling a file which has been set as having the language C. This behaviour change only takes place if "cmake_minimum_required" is set to 3.20 or newer, or if the policy CMP0119 is set to new. Attempting to compile assembly files with "-x c" fails, however this is workarounded in many cases, as OpenMP overrides this with "-x assembler-with-cpp", however this is only added for non-Windows targets. Thus, after increasing cmake_minimum_required to 3.20, this breaks compiling the GNU assembly for Windows targets; the GNU assembly is used for ARM and AArch64 Windows targets when building with Clang. This patch unbreaks that. D150688 [cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump The build uses other mechanism to select the runtime. Fixes #62719 Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D151344
2023-05-24[mlir][Transforms] GreedyPatternRewriteDriver debugging: Detect faulty patternsMatthias Springer
Compute operation finger prints to detect incorrect API usage in RewritePatterns. Does not work for dialect conversion patterns. Detect patterns that: * Returned `failure` but changed the IR. * Returned `success` but did not change the IR. * Inserted/removed/modified ops, bypassing the rewriter. Not all cases are detected. These new checks are quite expensive, so they are only enabled with `-DMLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON`. Failures manifest as fatal errors (`llvm::report_fatal_error`) or crashes (accessing deallocated memory). To get better debugging information, run `mlir-opt -debug` (to see which pattern is broken) with ASAN (to see where memory was deallocated). Differential Revision: https://reviews.llvm.org/D144552
2023-05-17Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""Nico Weber
This reverts commit 65429b9af6a2c99d340ab2dcddd41dab201f399c. Broke several projects, see https://reviews.llvm.org/D144509#4347562 onwards. Also reverts follow-up commit "[OpenMP] Compile assembly files as ASM, not C" This reverts commit 4072c8aee4c89c4457f4f30d01dc9bb4dfa52559. Also reverts fix attempt "[cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump" This reverts commit 7d47dac5f828efd1d378ba44a97559114f00fb64.
2023-05-13Reland "[CMake] Bumps minimum version to 3.20.0."Mark de Wever
The owner of the last two failing buildbots updated CMake. This reverts commit e8e8707b4aa6e4cc04c0cffb2de01d2de71165fc.
2023-05-06Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""Mark de Wever
Unfortunatly not all buildbots are updated. This reverts commit ffb807ab5375b3f78df198dc5d4302b3b552242f.
2023-05-06Reland "[CMake] Bumps minimum version to 3.20.0."Mark de Wever
All build bots should be updated now. This reverts commit 44d38022ab29a3156349602733b3459df5beef93.
2023-04-15Revert "Revert "Revert "[CMake] Bumps minimum version to 3.20.0."""Mark de Wever
This reverts commit 1ef4c3c859728008cf707cad8d67f45ae5070ae1. Two buildbots still haven't been updated.
2023-04-15Revert "Revert "[CMake] Bumps minimum version to 3.20.0.""Mark de Wever
This reverts commit 92523a35a827539db8557bbc3ecab7f9ea3f6ade. Reland to see whether CIs are updated.
2023-03-18Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""Mark de Wever
This reverts commit a72165e5df59032cdd54dcb18155f2630d73abd1. Some buildbots have not been updated yet.
2023-03-18Reland "[CMake] Bumps minimum version to 3.20.0."Mark de Wever
This reverts commit 92523a35a827539db8557bbc3ecab7f9ea3f6ade. Test whether all CI runners are updated.
2023-03-04Revert "[CMake] Bumps minimum version to 3.20.0."Mark de Wever
Some build bots have not been updated to the new minimal CMake version. Reverting for now and ping the buildbot owners. This reverts commit 44c6b905f8527635e49bb3ea97dea315f92d38ec.
2023-03-04[CMake] Bumps minimum version to 3.20.0.Mark de Wever
This partly undoes D137724. This change has been discussed on discourse https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193 Note this does not remove work-arounds for older CMake versions, that will be done in followup patches. Reviewed By: mehdi_amini, MaskRay, ChuanqiXu, to268, thieta, tschuett, phosek, #libunwind, #libc_vendors, #libc, #libc_abi, sivachandra, philnik, zibi Differential Revision: https://reviews.llvm.org/D144509