37 Tooling
MLIR tooling is how a compiler author turns opaque IR into a debuggable artifact. The central tools parse, verify, print, transform, and inspect IR; the important habit is to observe each pipeline boundary rather than only the final output.
37.1 A Practical Inspection Loop
Use an optimizer tool or project driver to run a small pass pipeline, print IR before and after a suspicious pass, and enable verification. Reduce failures to the smallest module that still reproduces the issue. Generic operation printing is especially useful when custom syntax hides attributes or types.
Tests should encode both positive transformations and refusal cases. A lowering test needs illegal source IR, the expected legal target IR, and cases such as dynamic types or unknown effects that must take a different path. FileCheck-style tests are useful when they assert stable semantic properties rather than every incidental formatting choice.
37.2 Tools Need Registration
A tool can only parse registered dialects and execute registered passes. An unknown dialect error and an unknown pass error are separate integration problems. Keep project tool registration near the dialect/pass definition so users can reproduce the same pipeline outside a larger application.