summaryrefslogtreecommitdiff
path: root/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp
AgeCommit message (Collapse)Author
2025-11-15[mlir][MemRef] Add UB as a dependent dialect and use `ub.poison` for Mem2Reg ↵Fabian Mora
(#168066) This patch adds `ub` as a dependent dialect to `memref`, and uses `ub.poison` as the default value in `AllocaOp::getDefaultValue` for the mem2reg pass. This aligns the behavior of `mem2reg` with LLVM, where loading a value before having a value should be poison. --------- Signed-off-by: Fabian Mora <fabian.mora-cordero@amd.com>
2025-07-12[llvm] Remove unused includes (NFC) (#148342)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-06-23[MLIR][NFC] Declare RuntimeVerifiableOpInterface for memref ops that have an ↵Artemiy Bulavin
implementation (#145230) Previously running `-generate-runtime-verification` on an IR containing `memref.reinterpret_cast` would crash because its implementation of the `RuntimeVerifiableOpInterface` was removed in https://github.com/llvm/llvm-project/pull/132547 but its associated entry in `declarePromisedInterface` was never removed. This causes an error when you try and run `-generate-runtime-verification` on an IR containing `memref.reinterpret_cast` that looks like ``` LLVM ERROR: checking for an interface (`mlir::RuntimeVerifiableOpInterface`) that was promised by dialect 'memref' but never implemented. This is generally an indication that the dialect extension implementing the interface was never registered. ``` as reported in https://github.com/llvm/llvm-project/issues/144028. In this PR I also added all the ops that do have implementations of this interface in `mlir/lib/Dialect/MemRef/Transforms/RuntimeOpVerification.cpp` to the `declarePromisedInterface` for consistency. Fixes https://github.com/llvm/llvm-project/issues/144028
2025-05-01[mlir][EmitC] Add pass that combines all available emitc conversions (#117549)Simon Camphausen
2024-03-27[NFC][mlir] Reorder `declarePromisedInterface()` operands (#86628)Justin Fargnoli
Reorder the template operands of `declarePromisedInterface()` to match `declarePromisedInterfaces()`.
2024-03-15[mlir] Declare promised interfaces for all dialects (#78368)Justin Fargnoli
This PR adds promised interface declarations for all interfaces declared in `InitAllDialects.h`. Promised interfaces allow a dialect to declare that it will have an implementation of a particular interface, crashing the program if one isn't provided when the interface is used.
2024-01-08[mlir] Declare promised interfaces for the ConvertToLLVM extension (#76341)Justin Fargnoli
This PR adds promised interface declarations for `ConvertToLLVMPatternInterface` in all the dialects that support the `ConvertToLLVM` dialect extension. Promised interfaces allow a dialect to declare that it will have an implementation of a particular interface, crashing the program if one isn't provided when the interface is used.
2023-07-11[MLIR][MemRef] Avoid returning ReallocOp from findDeallocAlexander Shaposhnikov
This diff makes findDealloc return nullopt if the list of users contains "realloc". Fixes https://github.com/llvm/llvm-project/issues/60726 (In particular, in SimplifyClones (uses findDealloc) treating "realloc" as "dealloc" breaks the assumption that "dealloc" has no users) Test plan: ninja check-mlir check-all Differential revision: https://reviews.llvm.org/D154892
2023-01-14[mlir] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-13[mlir] Add #include <optional> (NFC)Kazu Hirata
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-12[mlir] Add operations to BlockAndValueMapping and rename it to IRMappingJeff Niu
The patch adds operations to `BlockAndValueMapping` and renames it to `IRMapping`. When operations are cloned, old operations are mapped to the cloned operations. This allows mapping from an operation to a cloned operation. Example: ``` Operation *opWithRegion = ... Operation *opInsideRegion = &opWithRegion->front().front(); IRMapping map Operation *newOpWithRegion = opWithRegion->clone(map); Operation *newOpInsideRegion = map.lookupOrNull(opInsideRegion); ``` Migration instructions: All includes to `mlir/IR/BlockAndValueMapping.h` should be replaced with `mlir/IR/IRMapping.h`. All uses of `BlockAndValueMapping` need to be renamed to `IRMapping`. Reviewed By: rriddle, mehdi_amini Differential Revision: https://reviews.llvm.org/D139665
2022-12-04[mlir] Use std::nullopt instead of None in comments (NFC)Kazu Hirata
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-03[mlir] Use std::nullopt instead of None (NFC)Kazu Hirata
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-09-29[mlir][arith] Change dialect name from Arithmetic to ArithJakub Kuderski
Suggested by @lattner in https://discourse.llvm.org/t/rfc-define-precise-arith-semantics/65507/22. Tested with: `ninja check-mlir check-mlir-integration check-mlir-mlir-spirv-cpu-runner check-mlir-mlir-vulkan-runner check-mlir-examples` and `bazel build --config=generic_clang @llvm-project//mlir:all`. Reviewed By: lattner, Mogball, rriddle, jpienaar, mehdi_amini Differential Revision: https://reviews.llvm.org/D134762
2022-09-07[MLIR] NFC. Introduce mlir::hasEffect and refactor usages dialect utilUday Bondhugula
Introduce mlir::hasEffect and refactor existing usage to use utility. NFC. Reviewed By: rriddle, mehdi_amini Differential Revision: https://reviews.llvm.org/D132117
2022-04-23[mlir][NFC] Shift a bunch of dialect includes from the .h to the .cppRiver Riddle
Now that dialect constructors are generated in the .cpp file, we can drop all of the dependent dialect includes from the .h file. Differential Revision: https://reviews.llvm.org/D124298
2022-03-09NFC. Clean up memref utils libraryUday Bondhugula
NFC. Clean up memref utils library. This library had a single function that was completely misplaced. MemRefUtils is expected to be (also per its comment) a library providing analysis/transforms utilities on memref dialect ops or memref types. However, in reality it had a helper that was depended upon by the MemRef dialect, i.e., it was a helper for the dialect ops library and couldn't contain anything that itself depends on the MemRef dialect. Move the single method to the memref dialect that will now allow actual utilities depending on the memref dialect to be placed in it. Put findDealloc in the `memref` namespace. This is a pure move. Differential Revision: https://reviews.llvm.org/D121273
2021-12-08Adjust "end namespace" comment in MLIR to match new agree'd coding styleMehdi Amini
See D115115 and this mailing list discussion: https://lists.llvm.org/pipermail/llvm-dev/2021-December/154199.html Differential Revision: https://reviews.llvm.org/D115309
2021-11-25[mlir] Move memref.[tensor_load|buffer_cast|clone] to "bufferization" dialect.Alexander Belyaev
https://llvm.discourse.group/t/rfc-dialect-for-bufferization-related-ops/4712 Differential Revision: https://reviews.llvm.org/D114552
2021-09-24[mlir:MemRef] Move DmaStartOp/DmaWaitOp to ODSRiver Riddle
These are among the last operations still defined explicitly in C++. I've tried to keep this commit as NFC as possible, but these ops definitely need a non-NFC cleanup at some point. Differential Revision: https://reviews.llvm.org/D110440
2021-07-05[mlir][NFC] MemRef cleanup: Remove helper functionsMatthias Springer
Remove `getDynOperands` and `createOrFoldDimOp` from MemRef.h to decouple MemRef a bit from Tensor. These two functions are used in other dialects/transforms. Differential Revision: https://reviews.llvm.org/D105260
2021-07-01[mlir][tensor] Add tensor.dim operationMatthias Springer
* Split memref.dim into two operations: memref.dim and tensor.dim. Both ops have the same builder interface and op argument names, so that they can be used with templates in patterns that apply to both tensors and memrefs (e.g., some patterns in Linalg). * Add constant materializer to TensorDialect (needed for folding in affine.apply etc.). * Remove some MemRefDialect dependencies, make some explicit. Differential Revision: https://reviews.llvm.org/D105165
2021-06-29[mlir] Generare .cpp.inc files for dialects.Stella Laurenzo
* Previously, we were only generating .h.inc files. We foresee the need to also generate implementations and this is a step towards that. * Discussed in https://llvm.discourse.group/t/generating-cpp-inc-files-for-dialects/3732/2 * Deviates from the discussion above by generating a default constructor in the .cpp.inc file (and adding a tablegen bit that disables this in case if this is user provided). * Generating the destructor started as a way to flush out the missing includes (produces a link error), but it is a strict improvement on its own that is worth doing (i.e. by emitting key methods in the .cpp file, we root vtables in one translation unit, which is a non-controversial improvement). Differential Revision: https://reviews.llvm.org/D105070
2021-03-15[mlir] fix shared-lib build fallout of e2310704d890ad252aeb1ca28b4b84d29514b1d1Alex Zinenko
The patch in question broke the build with shared libraries due to missing dependencies, one of which would have been circular between MLIRStandard and MLIRMemRef if added. Fix this by moving more code around and swapping the dependency direction. MLIRMemRef now depends on MLIRStandard, but MLIRStandard does _not_ depend on MLIRMemRef. Arguably, this is the right direction anyway since numerous libraries depend on MLIRStandard and don't necessarily need to depend on MLIRMemref. Other otable changes include: - some EDSC code is moved inline to MemRef/EDSC/Intrinsics.h because it creates MemRef dialect operations; - a utility function related to shape moved to BuiltinTypes.h/cpp because it only realtes to shaped types and not any particular dialect (standard dialect is erroneously believed to contain MemRefType); - a Python test for the standard dialect is disabled completely because the ops it tests moved to the new MemRef dialect, but it is not exposed to Python bindings, and the change for that is non-trivial.
2021-03-15[MLIR] Create memref dialect and move dialect-specific ops from std.Julian Gross
Create the memref dialect and move dialect-specific ops from std dialect to this dialect. Moved ops: AllocOp -> MemRef_AllocOp AllocaOp -> MemRef_AllocaOp AssumeAlignmentOp -> MemRef_AssumeAlignmentOp DeallocOp -> MemRef_DeallocOp DimOp -> MemRef_DimOp MemRefCastOp -> MemRef_CastOp MemRefReinterpretCastOp -> MemRef_ReinterpretCastOp GetGlobalMemRefOp -> MemRef_GetGlobalOp GlobalMemRefOp -> MemRef_GlobalOp LoadOp -> MemRef_LoadOp PrefetchOp -> MemRef_PrefetchOp ReshapeOp -> MemRef_ReshapeOp StoreOp -> MemRef_StoreOp SubViewOp -> MemRef_SubViewOp TransposeOp -> MemRef_TransposeOp TensorLoadOp -> MemRef_TensorLoadOp TensorStoreOp -> MemRef_TensorStoreOp TensorToMemRefOp -> MemRef_BufferCastOp ViewOp -> MemRef_ViewOp The roadmap to split the memref dialect from std is discussed here: https://llvm.discourse.group/t/rfc-split-the-memref-dialect-from-std/2667 Differential Revision: https://reviews.llvm.org/D98041
2021-02-18Revert "[MLIR] Create memref dialect and move several dialect-specific ops ↵Alexander Belyaev
from std." This commit introduced a cyclic dependency: Memref dialect depends on Standard because it used ConstantIndexOp. Std depends on the MemRef dialect in its EDSC/Intrinsics.h Working on a fix. This reverts commit 8aa6c3765b924d86f623d452777eb76b83bf2787.
2021-02-18[MLIR] Create memref dialect and move several dialect-specific ops from std.Julian Gross
Create the memref dialect and move several dialect-specific ops without dependencies to other ops from std dialect to this dialect. Moved ops: AllocOp -> MemRef_AllocOp AllocaOp -> MemRef_AllocaOp DeallocOp -> MemRef_DeallocOp MemRefCastOp -> MemRef_CastOp GetGlobalMemRefOp -> MemRef_GetGlobalOp GlobalMemRefOp -> MemRef_GlobalOp PrefetchOp -> MemRef_PrefetchOp ReshapeOp -> MemRef_ReshapeOp StoreOp -> MemRef_StoreOp TransposeOp -> MemRef_TransposeOp ViewOp -> MemRef_ViewOp The roadmap to split the memref dialect from std is discussed here: https://llvm.discourse.group/t/rfc-split-the-memref-dialect-from-std/2667 Differential Revision: https://reviews.llvm.org/D96425