[Enh] Improve macro name robustness#651
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors how FlyDSL iterates over enabled backend stacks at compile time by replacing the FLYDSL_BACKENDS_TUPLE-based preprocessor iteration with a more robust FLYDSL_BACKEND_COUNT + FLYDSL_BACKEND_0..N-1 scheme generated by CMake.
Changes:
- Introduces
include/flydsl/Backend/Backend.hprovidingFLYDSL_FOR_EACH_BACKEND(...)driven byFLYDSL_BACKEND_COUNT. - Updates CMake backend configuration (
cmake/FlyDSLBackends.cmake) to emitFLYDSL_BACKEND_COUNTand per-index backend defines instead ofFLYDSL_BACKENDS_TUPLE. - Updates backend registration call sites (fly-opt and Python registration) and adjusts the unit test accordingly; removes the old
ForEachBackend.h.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/fly-opt/fly-opt.cpp | Switches backend iteration/registration to FLYDSL_FOR_EACH_BACKEND. |
| python/mlir_flydsl/FlyRegisterEverything.cpp | Switches Python-side backend registration to FLYDSL_FOR_EACH_BACKEND. |
| cmake/FlyDSLBackends.cmake | Emits FLYDSL_BACKEND_COUNT and FLYDSL_BACKEND_<i> defines; adds max-backend guard. |
| include/flydsl/Backend/Backend.h | New preprocessor iteration utility for backends. |
| include/flydsl/Backend/ForEachBackend.h | Removes the old tuple-based backend iteration utility. |
| tests/unit/test_backend_cmake_defaults.py | Updates guardrail assertions to match new CMake compile definitions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
coderfeli
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Technical Details
Test Plan
Test Result
Submission Checklist