[all-commits] [llvm/llvm-project] 499abb: Add generic type attribute mapping infrastructure, ...

Krzysztof Drewniak via All-commits all-commits at lists.llvm.org
Thu Feb 9 10:00:59 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 499abb243cb75262f121659b87f5a2a6a7c8a82f
      https://github.com/llvm/llvm-project/commit/499abb243cb75262f121659b87f5a2a6a7c8a82f
  Author: Krzysztof Drewniak <Krzysztof.Drewniak at amd.com>
  Date:   2023-02-09 (Thu, 09 Feb 2023)

  Changed paths:
    M mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h
    M mlir/include/mlir/Dialect/AMDGPU/AMDGPU.td
    M mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
    M mlir/include/mlir/Dialect/GPU/Transforms/Passes.td
    M mlir/include/mlir/Transforms/DialectConversion.h
    M mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
    M mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h
    M mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
    M mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.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/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp
    M mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
    M mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
    M mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp
    M mlir/lib/Dialect/AMDGPU/IR/CMakeLists.txt
    M mlir/lib/Dialect/GPU/CMakeLists.txt
    R mlir/lib/Dialect/GPU/Transforms/LowerMemorySpaceAttributes.cpp
    M mlir/lib/Transforms/Utils/DialectConversion.cpp
    A mlir/test/Conversion/GPUCommon/lower-memory-space-attrs.mlir
    A mlir/test/Conversion/MemRefToLLVM/invalid.mlir
    R mlir/test/Dialect/GPU/lower-memory-space-attrs.mlir

  Log Message:
  -----------
  Add generic type attribute mapping infrastructure, use it in GpuToX

Remapping memory spaces is a function often needed in type
conversions, most often when going to LLVM or to/from SPIR-V (a future
commit), and it is possible that such remappings may become more
common in the future as dialects take advantage of the more generic
memory space infrastructure.

Currently, memory space remappings are handled by running a
special-purpose conversion pass before the main conversion that
changes the address space attributes. In this commit, this approach is
replaced by adding a notion of type attribute conversions
TypeConverter, which is then used to convert memory space attributes.

Then, we use this infrastructure throughout the *ToLLVM conversions.
This has the advantage of loosing the requirements on the inputs to
those passes from "all address spaces must be integers" to "all
memory spaces must be convertible to integer spaces", a looser
requirement that reduces the coupling between portions of MLIR.

ON top of that, this change leads to the removal of most of the calls
to getMemorySpaceAsInt(), bringing us closer to removing it.

(A rework of the SPIR-V conversions to use this new system will be in
a folowup commit.)

As a note, one long-term motivation for this change is that I would
eventually like to add an allocaMemorySpace key to MLIR data layouts
and then call getMemRefAddressSpace(allocaMemorySpace) in the
relevant *ToLLVM in order to ensure all alloca()s, whether incoming or
produces during the LLVM lowering, have the correct address space for
a given target.

I expect that the type attribute conversion system may be useful in
other contexts.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D142159




More information about the All-commits mailing list