Add a new `filter-dialects` list option to the canonicalize pass. When
provided, only canonicalization patterns from the listed dialects are
collected, and the named dialects are force-loaded via
getDependentDialects.
Loading flow: the Canonicalizer's getDependentDialects override calls
`registry.addDialectToPreload(name)` for each filter-dialect name, which
records the name in a new `dialectsToPreload` list on DialectRegistry.
The PassManager's pipeline-init then calls
`dependentDialects.preloadSelectDialects(ctx, emitError)`, which loads
each preload entry via `context->getOrLoadDialect(name)` — the real
allocator is resolved from the context's own registry (registered by
the tool) and the dialect is loaded before multi-threaded execution
begins. If a requested dialect has no registration in the context, a
diagnostic `"can't load dialect '<name>': missing registration?"` is
emitted.
DialectRegistry API changes:
- New `addDialectToPreload(StringRef)` method: records a dialect name
that should be loaded into the MLIRContext but whose allocator lives
in the context's own registry. The registry itself does not load the
dialect — it just carries the request.
- New `preloadSelectDialects(MLIRContext *,
function_ref<InFlightDiagnostic()> = {})`
method: loads every preload-registered dialect into the context,
returning failure (and optionally emitting a diagnostic) for the
first name that cannot be resolved.
- `getDialectNames()` is split into two accessors:
* `getRegisteredDialectNames()` — names of allocator-backed entries
from the registry map.
* `getDialectsToPreload()` — preload-only entries added via
`addDialectToPreload(StringRef)`.
Assisted-by: Claude Code
4.3 KiB
4.3 KiB