[all-commits] [llvm/llvm-project] 59a9bb: [mlir][Transforms] Dialect Conversion: Simplify ma...

Matthias Springer via All-commits all-commits at lists.llvm.org
Wed Oct 23 07:16:45 PDT 2024


  Branch: refs/heads/users/matthias-springer/mat_remove_optional
  Home:   https://github.com/llvm/llvm-project
  Commit: 59a9bbb19f7cf35260d9e9511409936cd73cfbf2
      https://github.com/llvm/llvm-project/commit/59a9bbb19f7cf35260d9e9511409936cd73cfbf2
  Author: Matthias Springer <mspringer at nvidia.com>
  Date:   2024-10-23 (Wed, 23 Oct 2024)

  Changed paths:
    M mlir/include/mlir/Transforms/DialectConversion.h
    M mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
    M mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
    M mlir/lib/Dialect/EmitC/Transforms/TypeConversions.cpp
    M mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/SparseIterationToScf.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp
    M mlir/lib/Dialect/Tensor/TransformOps/TensorTransformOps.cpp
    M mlir/lib/Dialect/Tosa/Transforms/TosaTypeConverters.cpp
    M mlir/lib/Transforms/Utils/DialectConversion.cpp
    M mlir/test/lib/Conversion/OneToNTypeConversion/TestOneToNTypeConversionPass.cpp
    M mlir/test/lib/Dialect/Arith/TestEmulateWideInt.cpp
    M mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp
    M mlir/test/lib/Dialect/Test/TestPatterns.cpp
    M mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
    M mlir/test/lib/Transforms/TestDialectConversion.cpp

  Log Message:
  -----------
  [mlir][Transforms] Dialect Conversion: Simplify materialization fn result type

This commit simplifies the result type of materialization functions.

Previously: `std::optional<Value>`
Now: `Value`

The previous implementation allowed 3 possible return values:
- Non-null value: The materialization function produced a valid materialization.
- `std::nullopt`: The materialization function failed, but another materialization can be attempted.
- `Value()`: The materialization failed and so should the dialect conversion. (Previously: Dialect conversion can roll back.)

This commit removes the last variant. It is not particularly useful because the dialect conversion will fail anyway if all other materialization functions produced `std::nullopt`. In contrast to type conversions, at least one materialization callback is expected to succeed. In case of a failing type conversion, the current dialect conversion can roll back and try a different pattern. This also used to be the case for materializations, but that functionality was removed with #112669: failed materializations can no longer trigger a rollback. (They can just make the entire dialect conversion fail immediately without rollback.) With this in mind, it is even less useful to have an additional error state for materialization functions.

This commit is in preparation of merging the 1:1 and 1:N type converters. Target materializations will have to return multiple values instead of a single one. With this commit, we can keep the API simple: `SmallVector<Value>` instead of `std::optional<SmallVector<Value>>`.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list