Abstract
This RFC introduces a tool for refactoring MLIR, based on clang, aimed at simplifying and accelerating the refactoring process within the MLIR codebase. By marking deprecated interfaces with [[deprecated]], the tool helps achieve clarity and maintainability in the MLIR codebase. Furthermore, it offers the capability to seamlessly refactor downstream projects to ensure they can easily adapt to changes in MLIR.
Background
Recently, the MLIR project has undergone a series of refactoring efforts involving extensive changes to files and interfaces. To streamline this process, we have developed a clang-based refactoring tool. The main goals of the tool are:
- Assisted Refactoring: The tool provides a set of custom rules for automatically performing common refactoring operations, easing the burden on developers.
- Support for Downstream Projects: We designed the tool’s interface to enable downstream projects to effortlessly apply the same refactoring standards, ensuring their code stays in sync with the latest MLIR version.
Detailed Description
Tool Features
Key features of the tool include:
- Deprecation Interface Marking: Automatically recognizes and marks interfaces slated for deprecation with [[deprecated]], allowing developers to identify areas in need of updating.
- Custom Rules Engine: Supports user-defined refactoring rules to accommodate the requirements of different projects.
- Downstream Project Support: Provides API and documentation to allow downstream projects to integrate the tool and apply the latest MLIR refactoring.
Usage Example
Here are basic examples of using the tool:
llvm-project/build/bin/mlir-member-cast-rewriter --target-type=AffineExpr -p build llvm-project/mlir/lib/IR/AffineMap.cpp
Future Work
We plan to expand the tool’s capabilities in the future, including:
- More Custom Rules: Continuously extend the rules engine to support additional common refactoring patterns.
Conclusion
The MLIR Refactoring Tool is designed to simplify refactoring within the MLIR codebase while also offering support for downstream projects. We encourage community members to try it out and provide feedback for ongoing improvements and expansions.