[all-commits] [llvm/llvm-project] 50ea17: [mlir][MemRef] Add option to `-finalize-memref-to-...
zero9178 via All-commits
all-commits at lists.llvm.org
Wed Feb 8 01:15:28 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 50ea17b849a601bad634d98186155e7526cd4b5c
https://github.com/llvm/llvm-project/commit/50ea17b849a601bad634d98186155e7526cd4b5c
Author: Markus Böck <markus.boeck02 at gmail.com>
Date: 2023-02-08 (Wed, 08 Feb 2023)
Changed paths:
M mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h
M mlir/include/mlir/Conversion/LLVMCommon/MemRefBuilder.h
M mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h
M mlir/include/mlir/Conversion/Passes.td
M mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h
M mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
M mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp
M mlir/lib/Conversion/LLVMCommon/MemRefBuilder.cpp
M mlir/lib/Conversion/LLVMCommon/Pattern.cpp
M mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
M mlir/lib/Conversion/MemRefToLLVM/AllocLikeConversion.cpp
M mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
M mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp
M mlir/test/Conversion/MemRefToLLVM/convert-alloca-scope.mlir
M mlir/test/Conversion/MemRefToLLVM/convert-dynamic-memref-ops.mlir
M mlir/test/Conversion/MemRefToLLVM/convert-static-memref-ops.mlir
M mlir/test/Conversion/MemRefToLLVM/expand-then-convert-to-llvm.mlir
M mlir/test/Conversion/MemRefToLLVM/generic-functions.mlir
M mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir
A mlir/test/Conversion/MemRefToLLVM/typed-pointers.mlir
Log Message:
-----------
[mlir][MemRef] Add option to `-finalize-memref-to-llvm` to emit opaque pointers
This is the first patch in a series of patches part of this RFC: https://discourse.llvm.org/t/rfc-switching-the-llvm-dialect-and-dialect-lowerings-to-opaque-pointers/68179
This patch adds the ability to lower the memref dialect to the LLVM Dialect with the use of opaque pointers instead of typed pointers. The latter are being phased out of LLVM and this patch is part of an effort to phase them out of MLIR as well. To do this, we'll need to support both typed and opaque pointers in lowering passes, to allow downstream projects to change without breakage.
The gist of changes required to change a conversion pass are:
* Change any `LLVM::LLVMPointerType::get` calls to NOT use an element type if opaque pointers are to be used.
* Use the `build` method of `llvm.load` with the explicit result type. Since the pointer does not have an element type anymore it has to be specified explicitly.
* Use the `build` method of `llvm.getelementptr` with the explicit `basePtrType`. Ditto to above, we have to now specify what the element type is so that GEP can do its indexing calculations
* Use the `build` method of `llvm.alloca` with the explicit `elementType`. Ditto to the above, alloca needs to know how many bytes to allocate through the element type.
* Get rid of any `llvm.bitcast`s
* Adapt the tests to the above. Note that `llvm.store` changes syntax as well when using opaque pointers
I'd like to note that the 3 `build` method changes work for both opaque and typed pointers, so unconditionally using the explicit element type form is always correct.
For the testsuite a practical approach suggested by @ftynse was taken: I created a separate test file for testing the typed pointer lowering of Ops. This mostly comes down to checking that bitcasts have been created at the appropiate places, since these are required for typed pointer support.
Differential Revision: https://reviews.llvm.org/D143268
More information about the All-commits
mailing list