257 Commits

Author SHA1 Message Date
Matthias Springer
3c862b4ba3
[mlir] Expose optional PatternBenefit to function / SCF populate functions (NFC) (#159752)
Pattern benefit allows users to give priority to a pattern.
2025-09-19 13:46:04 +02:00
Matthias Springer
04320c0d24
[mlir][Transforms][NFC] Remove reconcileUnrealizedCasts forward-declaration (#158291)
This is a follow-up to
https://github.com/llvm/llvm-project/pull/158067/files#r2343711946.
2025-09-12 15:57:11 +01:00
Matthias Springer
da82d72a3d
[mlir][Transforms] Fix crash in reconcile-unrealized-casts (#158298)
The `reconcile-unrealized-casts` pass used to crash when the input
contains circular chains of `unrealized_conversion_cast` ops.

Furthermore, the `reconcileUnrealizedCasts` helper functions used to
erase ops that were not passed via the `castOps` operand. Such ops are
now preserved. That's why some integration tests had to be changed.

Also avoid copying the set of all unresolved materializations in
`convertOperations`.

This commit is in preparation of turning `RewriterBase::replaceOp` into
a non-virtual function.

This is a re-upload of #158067, which was reverted due to CI failures.

Note for LLVM integration: If you are seeing tests that are failing with
`error: LLVM Translation failed for operation:
builtin.unrealized_conversion_cast`, you may have to add the
`-reconcile-unrealized-casts` pass to your pass pipeline. (Or switch to
the `-convert-to-llvm` pass instead of combining the various
`-convert-*-to-llvm` passes.)

---------

Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
2025-09-12 14:28:02 +00:00
Mehdi Amini
b39da343a2
Revert "[mlir][Transforms] Fix crash in reconcile-unrealized-casts" (#158295)
Reverts llvm/llvm-project#158067

Buildbot is broken.
2025-09-12 14:51:18 +01:00
Matthias Springer
03e3ce82b9
[mlir][Transforms] Fix crash in reconcile-unrealized-casts (#158067)
The `reconcile-unrealized-casts` pass used to crash when the input
contains circular chains of `unrealized_conversion_cast` ops.

Furthermore, the `reconcileUnrealizedCasts` helper functions used to
erase ops that were not passed via the `castOps` operand. Such ops are
now preserved. That's why some integration tests had to be changed.

Also avoid copying the set of all unresolved materializations in
`convertOperations`.

This commit is in preparation of turning `RewriterBase::replaceOp` into
a non-virtual function.

---------

Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
2025-09-12 14:32:42 +01:00
Mehdi Amini
b22f94dcc5
[MLIR] Enable caching of type conversion in the presence of context-aware conversion (#158072)
The current implementation is overly conservative and disable all
possible caching as soon as a context-aware conversion is present.
However the context-aware conversion only affects subsequent converters,
we can cache the previous ones.

This isn't NFC because if fixed a bug where we use to unconditionally
cache when using the `convertType(Type t, ...` API, while now all APIs
are aware of context-aware conversions.
2025-09-11 14:17:10 +00:00
Matthias Springer
216bf6e065
[mlir][Transforms][NFC] Delete dead code (#157491) 2025-09-08 15:43:00 +00:00
Matthias Springer
2929a2978c
[mlir][Transforms] Add support for ConversionPatternRewriter::replaceAllUsesWith (#155244)
This commit generalizes `replaceUsesOfBlockArgument` to
`replaceAllUsesWith`. In rollback mode, the same restrictions keep
applying: a value cannot be replaced multiple times and a call to
`replaceAllUsesWith` will replace all current and future uses of the
`from` value.

`replaceAllUsesWith` is now fully supported and its behavior is
consistent with the remaining dialect conversion API. Before this
commit, `replaceAllUsesWith` was immediately reflected in the IR when
running in rollback mode. After this commit, `replaceAllUsesWith`
changes are materialized in a delayed fashion, at the end of the dialect
conversion. This is consistent with the `replaceUsesOfBlockArgument` and
`replaceOp` APIs.

`replaceAllUsesExcept` etc. are still not supported and will be
deactivated on the `ConversionPatternRewriter` (when running in rollback
mode) in a follow-up commit.

Note for LLVM integration: Replace `replaceUsesOfBlockArgument` with
`replaceAllUsesWith`. If you are seeing failures, you may have patterns
that use `replaceAllUsesWith` incorrectly (e.g., being called multiple
times on the same value) or bypass the rewriter API entirely. E.g., such
failures were mitigated in Flang by switching to the walk-patterns
driver (#156171).

You can temporarily reactivate the old behavior by calling
`RewriterBase::replaceAllUsesWith`. However, note that that behavior is
faulty in a dialect conversion. E.g., the base
`RewriterBase::replaceAllUsesWith` implementation does not see uses of
the `from` value that have not materialized yet and will, therefore, not
replace them.
2025-09-06 11:17:55 +02:00
Kazu Hirata
7c57e21a65 [mlir] Fix a warning
This patch fixes:

  mlir/lib/Transforms/Utils/DialectConversion.cpp:2761:9: error:
  unused variable 'impl' [-Werror,-Wunused-variable]
2025-08-29 09:08:52 -07:00
Matthias Springer
49f39b349d
[mlir][Transforms][NFC] Simplify function signatures (#155997)
Many internal functions take a `ConversionPatternRewriter &` or
`ConversionPatternRewriterImpl &` as a parameter. There's only a single
instance of these classes, so it's better to store the reference in a
field. This commit is in preparation of another PR that will require
access to `ConversionPatternRewriter` in additional helper functions.

Note: Public API does not change.
2025-08-29 15:16:18 +02:00
Matthias Springer
fe4ac5084b
[mlir][Transforms][NFC] Remove unused function parameter (#155985) 2025-08-29 08:32:27 +00:00
Matthias Springer
337707a541
[mlir][Transforms] Dialect conversion: Context-aware type conversions (#140434)
This commit adds support for context-aware type conversions: type
conversion rules that can return different types depending on the IR.

There is no change for existing (context-unaware) type conversion rules:
```c++
// Example: Conversion any integer type to f32.
converter.addConversion([](IntegerType t) {
  return Float32Type::get(t.getContext());
}
```

There is now an additional overload to register context-aware type
conversion rules:
```c++
// Example: Type conversion rule for integers, depending on the context:
// Get the defining op of `v`, read its "increment" attribute and return an
// integer with a bitwidth that is increased by "increment".
converter.addConversion([](Value v) -> std::optional<Type> {
  auto intType = dyn_cast<IntegerType>(v.getType());
  if (!intType)
    return std::nullopt;
  Operation *op = v.getDefiningOp();
  if (!op)
    return std::nullopt;
  auto incrementAttr = op->getAttrOfType<IntegerAttr>("increment");
  if (!incrementAttr)
    return std::nullopt;
  return IntegerType::get(v.getContext(),
                          intType.getWidth() + incrementAttr.getInt());
});
```

For performance reasons, the type converter caches the result of type
conversions. This is no longer possible when there context-aware type
conversions because each conversion could compute a different type
depending on the context. There is no performance degradation when there
are only context-unaware type conversions.

Note: This commit just adds context-aware type conversions to the
dialect conversion framework. There are many existing patterns that
still call `converter.convertType(someValue.getType())`. These should be
gradually updated in subsequent commits to call
`converter.convertType(someValue)`.

Co-authored-by: Markus Böck <markus.boeck02@gmail.com>
2025-08-27 09:13:52 +02:00
Matthias Springer
3db6011074
[mlir][Transforms] Tighten replaceUsesOfBlockArgument (#155227)
Improve the documentation of `replaceUsesOfBlockArgument` to clarify its
semantics is rollback mode. Add an assertion to make sure that the same
block argument is not replaced multiple times. That's an API violation
and messes with the internal state of the conversion driver.

This commit is in preparation of adding full support for
`RewriterBase::replaceAllUsesWith`.
2025-08-25 14:47:12 +02:00
Mehdi Amini
89abccc9a6
[MLIR] Update GreedyRewriter to use the LDBG() debug log mechanism (NFC) (#153961)
Also improve a bit the LDBG() implementation
2025-08-18 21:05:34 +00:00
Matthias Springer
f84aaa6eaa
[mlir][Transforms] Dialect conversion: Add flag to dump materialization kind (#119532)
Add a debugging flag to the dialect conversion to dump the
materialization kind. This flag is useful to find out whether a missing
materialization rule is for source or target materializations.

Also add missing test coverage for the `buildMaterializations` flag.
2025-08-18 13:25:18 +00:00
Markus Böck
8582025f1f
[mlir][Transforms] Turn 1:N -> 1:1 dispatch fatal error into match failure (#153605)
Prior to this PR, the default behaviour of a conversion pattern which
receives operands of a 1:N is to abort the compilation. This has
historically been useful when the 1:N type conversion got merged into
the dialect conversion as it allowed us to easily find patterns that
should be capable of handling 1:N type conversions but didn't.

However, this behaviour has the disadvantage of being non-composable:
While the pattern in question cannot handle the 1:N type conversion,
another pattern part of the set might, but doesn't get the chance as
compilation is aborted.

This PR fixes this behaviour by failing to match and instead of
aborting, giving other patterns the chance to legalize an op. The
implementation uses a reusable function called `dispatchTo1To1` to allow
derived conversion patterns to also implement the behaviour.
2025-08-15 11:45:25 +02:00
Matthias Springer
c888addc9f
[mlir][Transforms] Fix build (#153447)
Fix build after #151865.
2025-08-13 18:21:45 +02:00
Matthias Springer
7e7c9d975e
[mlir][Transforms] Dialect Conversion Driver without Rollback (#151865)
This commit improves the `allowPatternRollback` flag handling in the
dialect conversion driver. Previously, this flag was used to merely
detect cases that are incompatible with the new One-Shot Dialect
Conversion driver. This commit implements the driver itself: when the
flag is set to "false", all IR changes are materialized immediately,
bypassing the `IRRewrite` and `ConversionValueMapping` infrastructure.

A few selected test cases now run with both the old and the new driver.

RFC:
https://discourse.llvm.org/t/rfc-a-new-one-shot-dialect-conversion-driver/79083
2025-08-13 17:40:55 +02:00
Jacques Pienaar
6ec0985ad0
[mlir] Enable disabling folding in dialect conversion (#152890)
Previously this only happened post checking if the op is legal, but was
done unconditionally post (and before other legalization patterns). Add
option to not attempt folding and one to do so as last resort.

Did consider but did not add a always attempt to fold option (which
would have folded whether or not legal), but removed TODO about it.
2025-08-10 18:00:31 +02:00
Matthias Springer
a3e0685529
[mlir][Transforms] More detailed error message when new IR cannot be legalized (#152297)
Print a more detailed error message when new/modified IR could not be
legalized with `allowPatternRollback = false`. This is useful to
understand why a pattern is incompatible with the new One-Shot Dialect
Conversion driver.

---------

Co-authored-by: Jeremy Kun <jkun@google.com>
2025-08-07 09:14:24 +02:00
Matthias Springer
71832a3139
[mlir][Transforms] Make lookup without type converter unambiguous (#151747)
When a conversion pattern is initialized without a type converter, the
driver implementation currently looks up the most recently mapped value.
This is undesirable because the most recently mapped value could be a
materialization. I.e., the type of the value being looked up could
depend on which other patterns have run before. Such an implementation
makes the type conversion infrastructure fragile and unpredictable.

The current implementation also contradicts the documentation in the
markdown file. According to that documentation, the values provided by
the adaptor should match the types of the operands of the match
operation when running without a type converter. This mechanism is not
desirable, either, for two reasons:

1. Some patterns have started to rely on receiving the most recently
mapped value. Changing the behavior to the documented behavior will
cause regressions. (And there would be no easy way to fix those without
forcing the use of a type converter or extending the `getRemappedValue`
API.)
2. It is more useful to receive the most recently mapped value. A value
of the original operand type can be retrieved by using the operand of
the matched operation. The adaptor is not needed at all in that case.

To implement the new behavior, materializations are now annotated with a
marker attribute. The marker is needed because not all
`unrealized_conversion_cast` ops are materializations that act as "pure
type conversions". E.g., when erasing an operation, its results are
mapped to newly-created "out-of-thin-air values", which are
materializations (with no input) that should be treated like regular
replacement values during a lookup. This marker-based lookup strategy is
also compatible with the One-Shot Dialect Conversion implementation
strategy, which does not utilize the mapping infrastructure anymore and
queries all necessary information by examining the IR.
2025-08-07 08:41:28 +02:00
Matthias Springer
0a72e6ddac
[mlir][Transforms] ConversionPatternRewriter: Add config getter (#152310)
Add a helper function to `ConversionPatternRewriter` that returns the
dialect conversion configuration. This flag is useful when migrating
conversion patterns to the new One-Shot Conversion Driver: patterns can
check if they are running in rollback mode or not. They can then work
around API changes and makes sure that the pattern keeps working with
both the old and new driver.

Also remove the `config` field from `OperationLegalizer`. That field was
never needed.
2025-08-07 08:33:24 +02:00
Mehdi Amini
c569c1f15f
[MLIR] Migrate pattern application / dialect conversion to the LDBG logging format (#150991)
This prefix the output with the DEBUG_TYPE.
Dialect conversion is using a ScopedPrinter, we insert the
raw_ldbg_ostream to consistently prefix each new line.
2025-08-01 14:28:58 +02:00
Matthias Springer
c639475974
[mlir][Transforms] Dialect Conversion: Fix folder implementation (#150775)
Operation folders can do two things:

1. Modify IR (in-place op modification). Failing to legalize an in-place
folded operation does not trigger an immediate rollback. This happens
only if the driver decides to try a different lowering path, requiring
it to roll back a bunch of modifications, including the application of
the folder.
2. Create new IR (constant op materialization of a folded attribute).
Failing to legalize a newly created constant op triggers an immediate
rollback.

In-place op modifications should be guarded by
`startOpModification`/`finalizeOpModification` because they are no
different from other in-place op modifications. (They just happen
outside of a pattern, but that does not mean that we should not track
those changes; we are tracking everything else.) This commit adds those
two function calls.

This commit also moves the `rewriter.replaceOp(op, replacementValues);`
function call before the loop nest that legalizes the newly created
constant ops (and therefore `replacementValues`). Conceptually, the
folded op must be replaced before attempting to legalize the constants
because the constant ops may themselves be replaced as part of their own
legalization process. The previous implementation happened to work in
the current conversion driver, but is incompatible with the One-Shot
Dialect Conversion driver, which expects to see the most recent IR at
all time.

From an end-user perspective, this commit should be NFC. A common
folder-rollback pattern that is exercised by multiple tests cases: A
`memref.dim` is folded to `arith.constant`, but `arith.constant` is not
marked as legal as per the conversion target, triggering a rollback.

Note: Folding is generally unsafe in a dialect conversion (see #92683),
but that's a different issue. (In a One-Shot Dialect Conversion, it will
no longer be unsafe.)
2025-07-27 12:01:01 +02:00
Matthias Springer
a7c9563995
[mlir][IR] Set insertion point when erasing an operation (#146955)
Erasing the operation to which the current insertion point is set,
leaves the insertion point in an invalid state. This commit resets the
insertion point to the following operation.

Also adjust the insertion point when inlining a block.
2025-07-27 10:27:27 +02:00
Kazu Hirata
ea6106b2e2 [mlir] Fix a warning
This patch fixes:

  mlir/lib/Transforms/Utils/DialectConversion.cpp:1686:14: error:
  unused variable 'newParentOp' [-Werror,-Wunused-variable]
2025-07-27 00:59:41 -07:00
Matthias Springer
0c804270d1
[mlir][Transforms][NFC] Dialect Conversion: Improve insert callbacks (#150753)
This commit makes some minor NFC-style improvements to the
`notifyBlockInserted` and `notifyOperationInserted` implementations:

* Rename some variables.
* Add more comments and document the fact the current mechanism has a
bug when running in "rollback allowed" mode.
* Move some code from the `notify...` functions into the constructor of
the respective `IRRewrite` objects. This is in preparation of the
One-Shot Dialect Conversion refactoring. The moved pieces of code are
not needed in "no rollback" mode and properly encapsulated inside of
`IRRewrite`, which is also not needed in "no rollback" mode.
* Slightly improve `-debug` output.
2025-07-26 16:29:56 +02:00
Matthias Springer
08e101e274
[mlir][Transforms] Dialect Conversion: check for "failure" after modification (#150748)
Add a new "expensive check" when running with `allowPatternRollback =
false`: returning "failure" after modifying IR is no longer allowed.
This check detects a few more API violations in addition to the check
`undoRewrites`. The latter check will be removed soon. (Because the
One-Shot Dialect Conversion will no longer maintain the stack of IR
rewrites.)

Also fix a build error when expensive checks are enabled.
2025-07-26 16:28:00 +02:00
Matthias Springer
5ec6ac882c
[mlir][Transforms][NFC] Dialect Conversion: Move lookup functions (#150743)
Add `lookupOrDefault` / `lookupOrNull` wrappers to
`ConversionPatternRewriterImpl` and call those wrappers throughout the
code base.

This commit is in preparation of the One-Shot Dialect Conversion
refactoring. In future, the implementation will bypass the `mapping`
when rollback is disabled. The switch will be made in those wrapper
functions.
2025-07-26 11:07:21 +02:00
Mehdi Amini
f26db3f3ec
[MLIR] Add a OpWithFlags class that acts as a "stream modifier" to customize Operation streaming (#150636) 2025-07-25 20:58:14 +02:00
Maksim Levental
2736fbd832
[mlir][NFC] update mlir/lib create APIs (26/n) (#149933)
See https://github.com/llvm/llvm-project/pull/147168 for more info.

---------

Co-authored-by: Tobias Gysi <tobias.gysi@nextsilicon.com>
2025-07-22 08:40:42 -04:00
Matthias Springer
8ee32c7b36
[mlir][Transforms][NFC] Dialect Conversion: Store materialization metadata separately (#148415)
Store metadata about unresolved materializations in a separate data
structure. This is in preparation of the One-Shot Dialect Conversion
refactoring, which no longer maintains a stack of `IRRewrite` objects.
Therefore, metadata about unresolved materializations can no longer be
retrieved from `UnresolvedMaterializationRewrite` objects.

This commit also removes a pointer indirection and may slightly improve
the performance of the existing driver.
2025-07-15 10:14:37 +02:00
Matthias Springer
1db33f1034
[mlir][Transforms] Report all allowPatternRollback violations as fatal errors (#148416)
Report all `allowPatternRollback` API violations as fatal errors. If
violated, the IR is potentially in an invalid/inconsistent state from
which the driver cannot recover.
2025-07-13 17:41:21 +02:00
Matthias Springer
58c0bd196e
[mlir][Transforms] Dialect Conversion: allowPatternRollback to check foldings (#148394)
When an operation is folded to an attribute, the attribute must be
materialized as a constant operation. That operation must then be
legalized. If such a legalization fails, the entire folding is rolled
back. This is not supported in a One-Shot Dialect Conversion. (Support
for rolling back foldings could be added at a later point of time.)

This commit improves the `allowPatternRollback` flag handling, such that
a fatal error is reported when a folder is attempted to be rolled back.
2025-07-13 10:06:07 +02:00
Matthias Springer
67db34863c
[mlir][Transforms][NFC] Dialect Conversion: Earlier isIgnored check (#148360)
When legalizing an operation, the conversion driver skips "ignored" ops.
Ops are ignored if they are inside of a recursively legal operation or
if they were erased.

This commit moves the "is ignored" check a bit earlier: it is now
checked before checking if the op is recursively legal. This is in
preparation of the One-Shot Dialect Conversion refactoring: erased ops
should not be accessed, not even for checking recursive legality.

This commit is NFC: When an op is erased, it is added to the set of
ignored ops and we don't want to process it, regardless of legality.
Nested ops are also added to the set of ignored ops when erasing an
enclosing op.
2025-07-12 16:46:42 +02:00
Matthias Springer
ad20dc0a87
[mlir][Transforms] Add ApplyConversionAction for profiling purposes (#146208)
Add a new `ApplyConversionAction` so that users can profile the time
that is spent in the conversion driver.
2025-07-04 14:58:49 +02:00
Kazu Hirata
b5cd49eff0
[mlir] Remove unused includes (NFC) (#146278)
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
2025-06-29 12:13:12 -07:00
Matthias Springer
9ccf613b34
[mlir][Transforms][NFC] Store per-pattern IR modifications in separate state (#145319)
This commit adds extra state to `ConversionPatternRewriterImpl` to store
all modified / newly-created operations and moved / newly-created blocks
in separate lists on a per-pattern basis.

This is in preparation of the One-Shot Dialect Conversion refactoring:
the new driver will no longer maintain a list of all IR rewrites, so
information about newly-created operations (which is needed to trigger
recursive legalization) must be retained in a different data structure.

This commit is also expected to improve the performance of the existing
driver. The previous implementation iterated over all new IR
modifications and then filtered them by type. It also required an
additional pointer indirection (through `std::unique_ptr<IRRewrite>`) to
retrieve the operation/block pointer.
2025-06-26 08:54:39 +02:00
Matthias Springer
c5972da34a
[mlir][Transforms] Dialect Conversion: Simplify block-inline handling (#145308)
When a block is getting inlined, the destination block does not have to
be legalized. That's because the signature of the destination block does
not change by inlining.

This commit makes the implementation consistent with this comment:
```
  // If the pattern moved or created any blocks, make sure the types of block
  // arguments get legalized.
```
2025-06-24 08:52:13 +02:00
Matthias Springer
b1b8f67eab
[mlir][Transforms] Add 1:N support to replaceUsesOfBlockArgument (#145171)
This commit adds 1:N support to
`ConversionPatternRewriter::replaceUsesOfBlockArgument`. This was one of
the few remaining dialect conversion APIs that does not support 1:N
conversions yet.

This commit also reuses `replaceUsesOfBlockArgument` in the
implementation of `applySignatureConversion`. This is in preparation of
the One-Shot Dialect Conversion refactoring. The goal is to bring the
`applySignatureConversion` implementation into a state where it works
both with and without rollbacks. To that end, `applySignatureConversion`
should not directly access the `mapping`.
2025-06-23 12:07:00 +02:00
Matthias Springer
b9c979d369
[mlir][Transforms] Dialect conversion: Simplify replaceOp implementation (#145155)
Since #145030, `ConversionPatternRewriter::eraseBlock` no longer calls
`ConversionPatternRewriter::eraseOp`. This now happens in the rewriter
impl (during the cleanup phase). Therefore, a safety check in
`replaceOp` can now be simplified.
2025-06-23 11:06:14 +02:00
Matthias Springer
0921bfd81d
[mlir][Transforms] Dialect conversion: Add missing erasure notifications (#145030)
Add missing listener notifications when erasing nested
blocks/operations.

This commit also moves some of the functionality from
`ConversionPatternRewriter` to `ConversionPatternRewriterImpl`. This is
in preparation of the One-Shot Dialect Conversion refactoring: The
implementations in `ConversionPatternRewriter` should be as simple as
possible, so that a switch between "rollback allowed" and "rollback not
allowed" can be inserted at that level. (In the latter case,
`ConversionPatternRewriterImpl` can be bypassed to some degree, and
`PatternRewriter::eraseBlock` etc. can be used.)

Depends on #145018.
2025-06-21 10:44:54 +02:00
Matthias Springer
32dbaf12be
[mlir][Transforms][NFC] Dialect conversion: Rename internal functions (#145018)
Rename a few internal functions: drop the `notify` prefix, which
incorrectly suggests that the function is a listener callback function.
2025-06-21 09:43:34 +02:00
Matthias Springer
a4e4527c4b
[mlir][Transforms] Fix replaceUsesOfBlockArgument API (#144706)
Before this PR, users had to pass the "old" block argument when
replacing the uses of a block argument in a newly converted block. Users
can now pass the actual block argument that should be replaced.

Note for LLVM integration: Make sure to pass the current block argument
instead of the old one.
2025-06-19 15:39:06 +02:00
Matthias Springer
66580f77b8
[mlir][Transforms][NFC] Dialect Conversion: Keep unresolvedMaterializations up to date (#144254)
`unresolvedMaterializations` is a mapping from
`UnrealizedConversionCastOp` to `UnresolvedMaterializationRewrite`. This
mapping is needed to find the correct type converter for an unresolved
materialization.

With this commit, `unresolvedMaterializations` is updated immediately
when an op is being erased. This also cleans up the code base a bit:
`SingleEraseRewriter` is now used only during the "cleanup" phase and no
longer needed as a field of `ConversionRewriterImpl`.

This commit is in preparation of the One-Shot Dialect Conversion
refactoring: `allowPatternRollback = false` will in the future trigger
immediate materialization of all IR changes.
2025-06-18 14:42:09 +02:00
Alex Denisov
da4958ae2b
[MLIR] Add a missing newline to debug output. NFC (#141531)
Before:

```
** Erase   : 'scf.yield'(0x6000037b1630)
** Insert Block into detached Region (nullptr parent op)'        ** Insert Block into detached Region (nullptr parent op)'        ** Insert  : 'scf.if'(0x6000025b8140)
** Erase   : 'scf.if'(0x600003ab0780)
```

After:

```
** Erase   : 'scf.yield'(0x600003128b90)
** Insert Block into detached Region (nullptr parent op)'
** Insert Block into detached Region (nullptr parent op)'
** Insert  : 'scf.if'(0x6000023206e0)
```
2025-05-26 15:42:54 -07:00
Kazu Hirata
6464238dc0
[mlir] Use llvm::stable_sort (NFC) (#141186) 2025-05-22 22:36:32 -07:00
Matthias Springer
751e6c08b2
[mlir][Transforms] Check for correct type converter rule implementation (#140347)
If a type conversion rule fails to apply, it should not append any types
to the result. This commit just adds an assertion to detect such cases
of incorrect API usage.
2025-05-18 09:05:02 +09:00
Matthias Springer
fc8484f0e3
[mlir][Transforms][NFC] Rename MaterializationCallbackFn (#138814)
There are two kind of materialization callbacks: one for target
materializations and one for source materializations. The callback type
for target materializations is `TargetMaterializationCallbackFn`. This
commit renames the one for source materializations from
`MaterializationCallbackFn` to `SourceMaterializationCallbackFn`, for
consistency.

There used to be a single callback type for both kind of
materializations, but the materialization function signatures have
changed over time.

Also clean up a few places in the documentation that still referred to
argument materializations.
2025-05-08 08:22:38 +02:00
Kazu Hirata
d1e85a0ea0
[mlir] Use range constructors of *Set (NFC) (#137563) 2025-04-27 17:52:41 -07:00