[all-commits] [llvm/llvm-project] 4e5636: [mlir] Use GenericAdaptor to simplify 1:N type con...

Ingo Müller via All-commits all-commits at lists.llvm.org
Fri Mar 31 03:43:23 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4e563616a5fffa1204286a9aa03604a68a7db835
      https://github.com/llvm/llvm-project/commit/4e563616a5fffa1204286a9aa03604a68a7db835
  Author: Ingo Müller <ingomueller at google.com>
  Date:   2023-03-31 (Fri, 31 Mar 2023)

  Changed paths:
    M mlir/include/mlir/Transforms/OneToNTypeConversion.h
    M mlir/lib/Dialect/Func/Transforms/OneToNFuncConversions.cpp
    M mlir/lib/Dialect/SCF/Transforms/OneToNTypeConversion.cpp
    M mlir/test/lib/Conversion/OneToNTypeConversion/TestOneToNTypeConversionPass.cpp

  Log Message:
  -----------
  [mlir] Use GenericAdaptor to simplify 1:N type conversion API.

For 1:N type conversion, there is a 1:N relationship between the
original operands and the converted operands. The same is true for the
results. The previous design passed an instance of a "mapping" class
into each pattern that helped with handling this 1:N correspondance.
However, this was still rather manual and, in particular, it required
the use of magic constants for the indices of the different operands.

This commits uses the generated GenericAdaptor class that is generated
for each op class in order to simplify this relationship further. The
GenericAdaptor allows to wrap around a list of arbitrary types for each
operand (via templating); for 1:N type conversion, this allows the
operand accessors of the adaptor class to return a ValueRange that
corresponds to the N values in the converted types. Patterns can thus
use the named accessors instead of magic constants, which eliminates a
common class of errors.

This commit further simplifies the API that patterns need to implement
by making the operand and result type mappings part of the adaptor.
Since many patterns only need one of the two (or even neither), this
reduces the number of unnecessary arguments in many cases.

Reviewed By: springerm

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




More information about the All-commits mailing list