summaryrefslogtreecommitdiff
path: root/mlir/lib/Conversion/ConvertToLLVM
AgeCommit message (Collapse)Author
2025-09-03[mlir][ToLLVM] Fix the index bitwidth handling for the dynamic case of ↵Fabian Mora
`convert-to-llvm` (#156557) This patch changes the behavior of `convert-to-llvm{dynamic=true}` so that the nearest `DataLayout` is used to configure LowerToLLVMOptions and LLVMTypeConverter. Example: ```mlir module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<index, 16>>} { func.func private @test_16bit_index(%arg0: index) -> index } // mlir-opt --convert-to-llvm="dynamic=true" module attributes {dlti.dl_spec = #dlti.dl_spec<index = 16 : i64>} { llvm.func @test_16bit_index(i16) -> i16 attributes {sym_visibility = "private"} } ```
2025-08-20[MLIR] Adopt LDBG() debug macro in ConvertToLLVMPass (NFC) (#154616)Mehdi Amini
2025-08-13[mlir][Transforms] Dialect Conversion Driver without Rollback (#151865)Matthias Springer
This commit improves the `allowPatternRollback` flag handling in the dialect conversion driver. Previously, this flag was used to merely detect cases that are incompatible with the new One-Shot Dialect Conversion driver. This commit implements the driver itself: when the flag is set to "false", all IR changes are materialized immediately, bypassing the `IRRewrite` and `ConversionValueMapping` infrastructure. A few selected test cases now run with both the old and the new driver. RFC: https://discourse.llvm.org/t/rfc-a-new-one-shot-dialect-conversion-driver/79083
2025-07-24[mlir] Remove unused includes (NFC) (#150476)Kazu Hirata
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-07-04[mlir] Remove unused includes (NFC) (#147101)Kazu Hirata
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-02-17[MLIR][NFC] Retire `let constructor` for passes in Conversion directory ↵lorenzo chelini
(part1) (#127403) `let constructor` is deprecated since the table gen backend emits most of the glue logic to build a pass. This PR retires the td method for most (I need another pass) passes in the Conversion directory.
2024-11-24[mlir][LLVM] Add the `ConvertToLLVMAttrInterface` and ↵Fabian Mora
`ConvertToLLVMOpInterface` interfaces (#99566) This patch adds the `ConvertToLLVMAttrInterface` and `ConvertToLLVMOpInterface` interfaces. It also modifies the `convert-to-llvm` pass to use these interfaces when available. The `ConvertToLLVMAttrInterface` interfaces allows attributes to configure conversion to LLVM, including the conversion target, LLVM type converter, and populating conversion patterns. See the `NVVMTargetAttr` implementation of this interface for an example of how this interface can be used to configure conversion to LLVM. The `ConvertToLLVMOpInterface` interface collects all convert to LLVM attributes stored in an operation. Finally, the `convert-to-llvm` pass was modified to use these interfaces when available. This allows applying `convert-to-llvm` to GPU modules and letting the `NVVMTargetAttr` decide which patterns to populate.
2024-10-07[CMake]: Remove unnecessary dependencies on LLVM/MLIR (#111255)BARRET
Previous https://github.com/llvm/llvm-project/pull/110362 (reverted) caused breakage. Here is the PR with fix. My build cmdline: ``` cmake ../llvm \ -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=install \ -DCMAKE_C_COMPILER=gcc-9 \ -DCMAKE_CXX_COMPILER=g++-9 \ -DCMAKE_CUDA_COMPILER=$(which nvcc) \ -DLLVM_ENABLE_LLD=OFF \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_BUILD_EXAMPLES=ON \ -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \ -DLLVM_CCACHE_BUILD=ON \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ -DBUILD_SHARED_LIBS=ON \ -DLLVM_ENABLE_PROJECTS='llvm;mlir' ```
2024-10-01Revert "CMake: Remove unnecessary dependencies on LLVM/MLIR" (#110594)Mehdi Amini
Reverts llvm/llvm-project#110362 Multiple bots are broken.
2024-09-30CMake: Remove unnecessary dependencies on LLVM/MLIR (#110362)BARRET
There are some spurious libraries which can be removed. I'm trying to bundle MLIR/LLVM library dependencies for our own libraries. We're utilizing cmake function to recursively collect MLIR/LLVM related dependencies. However, we identified certain library dependencies as redundant and safe for removal.
2024-08-06[mlir] Support DialectRegistry extension comparison (#101119)Nikhil Kalra
`PassManager::run` loads the dependent dialects for each pass into the current context prior to invoking the individual passes. If the dependent dialect is already loaded into the context, this should be a no-op. However, if there are extensions registered in the `DialectRegistry`, the dependent dialects are unconditionally registered into the context. This poses a problem for dynamic pass pipelines, however, because they will likely be executing while the context is in an immutable state (because of the parent pass pipeline being run). To solve this, we'll update the extension registration API on `DialectRegistry` to require a type ID for each extension that is registered. Then, instead of unconditionally registered dialects into a context if extensions are present, we'll check against the extension type IDs already present in the context's internal `DialectRegistry`. The context will only be marked as dirty if there are net-new extension types present in the `DialectRegistry` populated by `PassManager::getDependentDialects`. Note: this PR removes the `addExtension` overload that utilizes `std::function` as the parameter. This is because `std::function` is copyable and potentially allocates memory for the contained function so we can't use the function pointer as the unique type ID for the extension. Downstream changes required: - Existing `DialectExtension` subclasses will need a type ID to be registered for each subclass. More details on how to register a type ID can be found here: https://github.com/llvm/llvm-project/blob/8b68e06731e0033ed3f8d6fe6292ae671611cfa1/mlir/include/mlir/Support/TypeID.h#L30 - Existing uses of the `std::function` overload of `addExtension` will need to be refactored into dedicated `DialectExtension` classes with associated type IDs. The attached `std::function` can either be inlined into or called directly from `DialectExtension::apply`. --------- Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
2023-11-29[mlir] Adopt `ConvertToLLVMPatternInterface` GpuToLLVMConversionPass to ↵Mehdi Amini
align with `convert-to-llvm` (#73761) This is a follow-up to the introduction of `convert-to-llvm`: it is supposed to be a unifying pass through the `ConvertToLLVMPatternInterface`, but some specific conversion (like the GPU target) aren't vanilla LLVM target. Instead they need extra customizations that are specific to LLVM-on-GPUs and our custom runtime wrappers. This change make the GpuToLLVMConversionPass just as pluggable as the `convert-to-llvm` by using the same mechanism.
2023-11-20Apply clang-tidy fixes for llvm-qualified-auto in ToLLVMInterface.cpp (NFC)Mehdi Amini
2023-11-20Apply clang-tidy fixes for llvm-qualified-auto in ConvertToLLVMPass.cpp (NFC)Mehdi Amini
2023-08-14[mlir] Apply ClangTidy fix (NFC)Adrian Kuegel
virtual is redundant if method is final.
2023-08-11[mlir][Conversion] Implement ConvertToLLVMPatternInterface for FuncDialectMatthias Springer
Also a new pass option `ConvertToLLVMPass` to populate only patterns from the specified dialects. This is needed because the existing test cases expect that only ops from certain dialects are lowered. (E.g., "arith-to-llvm" expects that only "arith" ops are lowered but not "func" ops.) Differential Revision: https://reviews.llvm.org/D157627
2023-08-09[mlir][Conversion] Add type converter parameter to ConvertToLLVMPatternInterfaceMatthias Springer
Most `*-to-llvm` conversion patterns require a type converter. This revision adds a type converter to the `populateConvertToLLVMConversionPatterns` function and implements the interface for the MemRef dialect. Differential Revision: https://reviews.llvm.org/D157387
2023-08-07Add missing libraries dependencies to ConvertToLLVMPass to fix the shared ↵Mehdi Amini
library build (NFC)
2023-08-07Add a generic "convert-to-llvm" pass delegating to an interfaceMehdi Amini
The multiple -convert-XXX-to-llvm passes are really nice testing tools for individual dialects, but the expectation is that a proper conversion should assemble the conversion patterns using `populateXXXToLLVMConversionPatterns() APIs. However most customers just chain the conversion passes by convenience. This pass makes it composable more transparently to assemble the required patterns for conversion to LLVM dialect by using an interface. The Pass will scan the input and collect all the dialect present, and for those who implement the `ConvertToLLVMPatternInterface` it will use it to populate the conversion pattern, and possible the conversion target. Since these conversions can involve intermediate dialects, or target other dialects than LLVM (for example AVX or NVVM), this pass can't statically declare the required `getDependentDialects()` before the pass pipeline begins. This is worked around by using an extension in the dialectRegistry that will be invoked for every new loaded dialects in the context. This allows to lookup the interface ahead of time and use it to query the dependent dialects. Differential Revision: https://reviews.llvm.org/D157183