[all-commits] [llvm/llvm-project] bc9d7c: [mlir-c] Add 1:N TypeConverter conversion and mate...

Maksim Levental via All-commits all-commits at lists.llvm.org
Sat Jul 18 11:56:38 PDT 2026


  Branch: refs/heads/users/makslevental/mlir-c-typeconverter-1ton
  Home:   https://github.com/llvm/llvm-project
  Commit: bc9d7cc86ad7bb55ee5042c8e3d604c51b3e3c67
      https://github.com/llvm/llvm-project/commit/bc9d7cc86ad7bb55ee5042c8e3d604c51b3e3c67
  Author: makslevental <maksim.levental at gmail.com>
  Date:   2026-07-17 (Fri, 17 Jul 2026)

  Changed paths:
    M mlir/include/mlir-c/Rewrite.h
    M mlir/lib/CAPI/Transforms/Rewrite.cpp
    M mlir/test/CAPI/rewrite.c

  Log Message:
  -----------
  [mlir-c] Add 1:N TypeConverter conversion and materialization bindings

Builds on the source/target materialization C bindings:

- Target materialization callbacks now receive `originalType` (split from the
  previously-shared source/target callback typedef), exposing a documented C++
  capability that was otherwise unreachable from C.
- 1:N type conversion: `mlirTypeConverterAdd1ToNConversion` plus an opaque
  results accumulator (`MlirTypeConverterConversionResults` /
  `mlirTypeConverterConversionResultsAppend`). A declining callback's appended
  types are rolled back so the driver's "try the next conversion" invariant
  holds.
- 1:N target materialization: `mlirTypeConverterAdd1ToNTargetMaterialization`,
  whose callback fills a caller-allocated `outputs` buffer. A success that
  leaves any output null is treated as a decline rather than handing the driver
  a null-containing result.
- `mlirConversionPatternRewriterReplaceOpWithMultiple` for 1:N value
  replacement, which can drive a source materialization with nInputs > 1.
- An optional `matchAndRewrite1ToN` callback on `MlirConversionPatternCallbacks`
  for patterns consuming 1:N-remapped operands; when null the driver falls back
  to the 1:1 dispatch.

Adds end-to-end tests in mlir/test/CAPI/rewrite.c covering originalType
observation, source/target materialization decline paths, 1:N conversion
(including append-then-decline rollback and erasure), 1:N target
materialization (including the unfilled-outputs decline), multi-input source
materialization, multi-range replaceOpWithMultiple, and the 1:1-only-pattern
vs 1:N-operand failure.


  Commit: 185b7b747d8a497204f5cc6fcaf159c32734e18d
      https://github.com/llvm/llvm-project/commit/185b7b747d8a497204f5cc6fcaf159c32734e18d
  Author: makslevental <maksim.levental at gmail.com>
  Date:   2026-07-17 (Fri, 17 Jul 2026)

  Changed paths:
    M mlir/test/CAPI/rewrite.c

  Log Message:
  -----------
  [mlir-c] Fix -Wmissing-field-initializers in rewrite.c test

The new matchAndRewrite1ToN field left three existing
MlirConversionPatternCallbacks initializers under-initialized, which
fails the CI build under -Werror=-Wmissing-field-initializers.


  Commit: 3a029cd0dd427826c5ed1125fd21f007a3c98493
      https://github.com/llvm/llvm-project/commit/3a029cd0dd427826c5ed1125fd21f007a3c98493
  Author: makslevental <maksim.levental at gmail.com>
  Date:   2026-07-17 (Fri, 17 Jul 2026)

  Changed paths:
    M mlir/lib/Bindings/Python/Rewrite.cpp

  Log Message:
  -----------
  [mlir-c] Value-initialize MlirConversionPatternCallbacks in Python bindings

The Python conversion-pattern binding left the struct default-initialized,
so the newly-added optional matchAndRewrite1ToN field held an indeterminate
pointer. The driver's null check then read garbage and jumped into it,
segfaulting mlir/test/python/rewrite.py. Value-initialize the struct so
optional callbacks default to null.


  Commit: f698e79019a9b89f2e944b4540947f861dc3b32d
      https://github.com/llvm/llvm-project/commit/f698e79019a9b89f2e944b4540947f861dc3b32d
  Author: makslevental <maksim.levental at gmail.com>
  Date:   2026-07-17 (Fri, 17 Jul 2026)

  Changed paths:
    M mlir/test/CAPI/rewrite.c

  Log Message:
  -----------
  pre-increment


  Commit: e4b62b0279fad81a1d2969822e9f009f31d8f04d
      https://github.com/llvm/llvm-project/commit/e4b62b0279fad81a1d2969822e9f009f31d8f04d
  Author: makslevental <maksim.levental at gmail.com>
  Date:   2026-07-17 (Fri, 17 Jul 2026)

  Changed paths:
    M mlir/include/mlir-c/Rewrite.h
    M mlir/lib/CAPI/Transforms/Rewrite.cpp

  Log Message:
  -----------
  cleanup comments


  Commit: 9ca3e179bcbde4d602478858749a5ab9ebeca23d
      https://github.com/llvm/llvm-project/commit/9ca3e179bcbde4d602478858749a5ab9ebeca23d
  Author: makslevental <maksim.levental at gmail.com>
  Date:   2026-07-18 (Sat, 18 Jul 2026)

  Changed paths:
    M mlir/include/mlir-c/Rewrite.h
    M mlir/lib/CAPI/Transforms/Rewrite.cpp
    M mlir/test/CAPI/rewrite.c

  Log Message:
  -----------
  [mlir-c] Expose hard-failure state in 1:N type conversion callback

The 1:N conversion callback returned MlirLogicalResult, which the binding
could only map to success or nullopt (try-another), leaving the C++
failure() state (fail without trying another conversion) unreachable.

Return a MlirTypeConverterConversionStatus enum instead, with Success,
Failure, and Declined states mapped to success(), failure(), and
std::nullopt respectively. Add a test covering the hard-failure path.


Compare: https://github.com/llvm/llvm-project/compare/3480c9d80cd3...9ca3e179bcbd

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