Suggestion Description
Summary
Suggest refactoring the Conversion pass infrastructure so that each backend has its own TableGen definition and generated .inc files (e.g. flydsl/Conversion/FlyToROCDL/Passes.td and flydsl/Conversion/FlyToROCDL/Passes.h.inc), instead of a single shared Conversion/Passes.td and Conversion/Passes.h.inc. This would make it easier to add and maintain additional backends (e.g. FlyToNVVM, FlyToSPIRV) without touching a global Conversion tablegen setup.
Current design
- Single TableGen source:
include/flydsl/Conversion/Passes.td defines all conversion passes (currently only FlyToROCDLConversionPass).
- Single generated header: TableGen produces one
Conversion/Passes.h.inc used by:
Conversion/FlyToROCDL/FlyToROCDL.h (pass declaration)
Conversion/Passes.h (pass registration)
lib/Conversion/FlyToROCDL/FlyToROCDL.cpp (pass definition)
Adding a new backend (e.g. FlyToNVVM) would require editing this shared Passes.td and sharing the same Passes.h.inc, which mixes all backends in one place and can make ownership and code review less clear.
Proposed design
-
Per-backend TableGen: Each conversion backend has its own directory with:
Passes.td – defines only that backend’s pass(es)
CMakeLists.txt – runs TableGen to generate Passes.h.inc (and optionally C API .inc files) in that directory
- A dedicated tablegen target (e.g.
FlyToROCDLPassIncGen)
-
Include path: Backend code includes its own generated header, e.g.
#include "flydsl/Conversion/FlyToROCDL/Passes.h.inc"
instead of
#include "flydsl/Conversion/Passes.h.inc".
-
Conversion layer: Conversion/CMakeLists.txt only adds subdirectories (e.g. add_subdirectory(FlyToROCDL)). A central Conversion/Passes.h can still aggregate registration by including each backend’s Passes.h.inc with GEN_PASS_REGISTRATION.
Benefits
- Extensibility: Adding a new backend (e.g. FlyToNVVM) is a self-contained change: new directory, own
Passes.td and CMake, plus one line in Conversion/Passes.h and in Conversion/CMakeLists.txt. No edits to existing backend TableGen or shared .inc files.
- Clear ownership: Each backend’s pass definition and generated code live under that backend’s folder, which simplifies reviews and navigation.
- Consistency: Aligns with the idea of one conversion target per directory (e.g.
FlyToROCDL/, future FlyToNVVM/), and matches patterns used elsewhere (e.g. Dialect/Fly/Transforms/ with its own Passes.td and Passes.h.inc).
Suggested directory layout (after refactor)
include/flydsl/Conversion/
├── CMakeLists.txt # add_subdirectory(FlyToROCDL), add_subdirectory(FlyToNVVM), ...
├── Passes.h # Central registration: include each backend's Passes.h.inc + GEN_PASS_REGISTRATION
└── FlyToROCDL/
├── CMakeLists.txt # TableGen for this backend → Passes.h.inc (and capi if needed)
├── Passes.td
└── FlyToROCDL.h # include "flydsl/Conversion/FlyToROCDL/Passes.h.inc"
Migration steps (for FlyToROCDL)
- Add
Conversion/FlyToROCDL/Passes.td with the FlyToROCDLConversionPass definition (moved from Conversion/Passes.td).
- Add
Conversion/FlyToROCDL/CMakeLists.txt to run TableGen for this backend and add a target (e.g. FlyToROCDLPassIncGen).
- Update
Conversion/CMakeLists.txt to add_subdirectory(FlyToROCDL) and remove the previous single-file TableGen for Conversion/Passes.td.
- Update
FlyToROCDL.h, Conversion/Passes.h, and lib/Conversion/FlyToROCDL/FlyToROCDL.cpp to include flydsl/Conversion/FlyToROCDL/Passes.h.inc.
- Update
lib/Conversion/FlyToROCDL/CMakeLists.txt to depend on FlyToROCDLPassIncGen instead of the old Conversion-wide tablegen target.
- Remove the now-unused
Conversion/Passes.td.
Optional
If the project already uses a single Conversion C API tablegen, that can be moved to each backend (e.g. generate Passes.capi.*.inc from FlyToROCDL/Passes.td with the same prefix) so C API and pass layout stay consistent per backend.
I can contribute a patch for the FlyToROCDL refactor if this direction is acceptable to the maintainers.
Operating System
No response
GPU
No response
ROCm Component
No response
Suggestion Description
Summary
Suggest refactoring the Conversion pass infrastructure so that each backend has its own TableGen definition and generated
.incfiles (e.g.flydsl/Conversion/FlyToROCDL/Passes.tdandflydsl/Conversion/FlyToROCDL/Passes.h.inc), instead of a single sharedConversion/Passes.tdandConversion/Passes.h.inc. This would make it easier to add and maintain additional backends (e.g. FlyToNVVM, FlyToSPIRV) without touching a global Conversion tablegen setup.Current design
include/flydsl/Conversion/Passes.tddefines all conversion passes (currently onlyFlyToROCDLConversionPass).Conversion/Passes.h.incused by:Conversion/FlyToROCDL/FlyToROCDL.h(pass declaration)Conversion/Passes.h(pass registration)lib/Conversion/FlyToROCDL/FlyToROCDL.cpp(pass definition)Adding a new backend (e.g. FlyToNVVM) would require editing this shared
Passes.tdand sharing the samePasses.h.inc, which mixes all backends in one place and can make ownership and code review less clear.Proposed design
Per-backend TableGen: Each conversion backend has its own directory with:
Passes.td– defines only that backend’s pass(es)CMakeLists.txt– runs TableGen to generatePasses.h.inc(and optionally C API.incfiles) in that directoryFlyToROCDLPassIncGen)Include path: Backend code includes its own generated header, e.g.
#include "flydsl/Conversion/FlyToROCDL/Passes.h.inc"instead of
#include "flydsl/Conversion/Passes.h.inc".Conversion layer:
Conversion/CMakeLists.txtonly adds subdirectories (e.g.add_subdirectory(FlyToROCDL)). A centralConversion/Passes.hcan still aggregate registration by including each backend’sPasses.h.incwithGEN_PASS_REGISTRATION.Benefits
Passes.tdand CMake, plus one line inConversion/Passes.hand inConversion/CMakeLists.txt. No edits to existing backend TableGen or shared.incfiles.FlyToROCDL/, futureFlyToNVVM/), and matches patterns used elsewhere (e.g.Dialect/Fly/Transforms/with its ownPasses.tdandPasses.h.inc).Suggested directory layout (after refactor)
Migration steps (for FlyToROCDL)
Conversion/FlyToROCDL/Passes.tdwith theFlyToROCDLConversionPassdefinition (moved fromConversion/Passes.td).Conversion/FlyToROCDL/CMakeLists.txtto run TableGen for this backend and add a target (e.g.FlyToROCDLPassIncGen).Conversion/CMakeLists.txttoadd_subdirectory(FlyToROCDL)and remove the previous single-file TableGen forConversion/Passes.td.FlyToROCDL.h,Conversion/Passes.h, andlib/Conversion/FlyToROCDL/FlyToROCDL.cppto includeflydsl/Conversion/FlyToROCDL/Passes.h.inc.lib/Conversion/FlyToROCDL/CMakeLists.txtto depend onFlyToROCDLPassIncGeninstead of the old Conversion-wide tablegen target.Conversion/Passes.td.Optional
If the project already uses a single Conversion C API tablegen, that can be moved to each backend (e.g. generate
Passes.capi.*.incfromFlyToROCDL/Passes.tdwith the same prefix) so C API and pass layout stay consistent per backend.I can contribute a patch for the FlyToROCDL refactor if this direction is acceptable to the maintainers.
Operating System
No response
GPU
No response
ROCm Component
No response