[AIROCMLIR-390] clang-format: break .td DAG operands onto separate lines#2377
Open
bogdan-petkovic wants to merge 7 commits into
Open
[AIROCMLIR-390] clang-format: break .td DAG operands onto separate lines#2377bogdan-petkovic wants to merge 7 commits into
bogdan-petkovic wants to merge 7 commits into
Conversation
Add TableGenBreakInsideDAGArg: BreakElements and TableGenBreakingDAGArgOperators: [ins, outs] to the root and mlir/ .clang-format configs. Extend .githooks/pre-commit to run clang-format on staged .td files, and note in CONTRIBUTING.md that clang-format >= 19 is required (20 matches CI). Fixes #1936 Signed-off-by: bogdan-petkovic <bpetkovi@amd.com>
Apply clang-format-20 to all .td files under mlir/. Pure formatting change driven by the new TableGenBreakInsideDAGArg/TableGenBreakingDAGArgOperators settings; no semantic changes. Signed-off-by: bogdan-petkovic <bpetkovi@amd.com>
Signed-off-by: bogdan-petkovic <bpetkovi@amd.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2377 +/- ##
===========================================
+ Coverage 79.50% 81.53% +2.03%
===========================================
Files 100 125 +25
Lines 31016 42344 +11328
Branches 4819 6985 +2166
===========================================
+ Hits 24659 34524 +9865
- Misses 4245 5194 +949
- Partials 2112 2626 +514
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Enables clang-format's TableGen DAG-breaking options so (ins …)/(outs …) operands lay out one-per-line, wires .td files into the pre-commit hook, documents the new clang-format >= 19 requirement, and bulk-reformats 13 .td files under mlir/ (with the reformat SHA added to .git-blame-ignore-revs).
Changes:
- Add
TableGenBreakInsideDAGArg: BreakElementsandTableGenBreakingDAGArgOperators: [ins, outs]to both.clang-formatfiles; extend pre-commit hook to.td; updateCONTRIBUTING.md. - Append the bulk-reformat commit to
.git-blame-ignore-revs. - Apply
clang-format-20 -ito 13.tdfiles (NFC).
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| .clang-format | Adds TableGen DAG-break options |
| mlir/.clang-format | Same TableGen DAG-break options |
| .githooks/pre-commit | Includes .td in staged file regex |
| CONTRIBUTING.md | Documents clang-format >= 19 requirement and .td coverage |
| .git-blame-ignore-revs | Adds NFC reformat commit |
| mlir/include/mlir/Conversion/RocMLIRPasses.td | Reformatted dependentDialects/options |
| mlir/include/mlir/Dialect/MIGraphX/Passes.td | Reformatted; file header banner split across lines |
| mlir/include/mlir/Dialect/MIGraphX/IR/MIGraphX.td | Reformatted op defs; header banner split |
| mlir/include/mlir/Dialect/MIGraphX/IR/MIGraphXBase.td | License comment reflow |
| mlir/include/mlir/Dialect/MIGraphX/IR/MIGraphXTypes.td | Reformatted; header banner split |
| mlir/include/mlir/Dialect/Rock/Passes.td | Reformatted pass defs |
| mlir/include/mlir/Dialect/Rock/IR/RockOps.td | Bulk DAG-arg reflow |
| mlir/include/mlir/Dialect/Rock/IR/RockAttrDefs.td | Reformatted; header banner split |
| mlir/include/mlir/Dialect/Rock/IR/RockAcceptingViewOpInterface.td | Header banner split |
| mlir/include/mlir/Dialect/Rock/IR/RockAccelTuningParamAttrInterface.td | Class decl reflow |
| mlir/include/mlir/Dialect/Rock/IR/RockGemmWrapperInterface.td | License comment reflow |
| mlir/include/mlir/Dialect/Rock/IR/RockTuningParamAttrInterface.td | Reflow + blank-line cleanups |
| mlir/include/mlir/Dialect/Rock/IR/RockWriterOpInterface.td | License comment reflow |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: bogdan-petkovic <bpetkovi@amd.com>
Signed-off-by: bogdan-petkovic <bpetkovi@amd.com>
…ace.td Signed-off-by: bogdan-petkovic <bpetkovi@amd.com>
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
Resolves #1936.
Recent versions of
git-clang-formatinclude.td(TableGen) files in their default extension list. The repo's.clang-formatonly setsBasedOnStyle: LLVM, which uses TableGen defaults that pack multiple DAG operands onto a single line.The result is hard to read; e.g. before this PR,
commonConvArgsinmlir/include/mlir/Dialect/Rock/IR/RockOps.tdlooked like:dag commonConvArgs = (ins TensorOrMemRefOf:$filter, TensorOrMemRefOf:$input, TensorOrMemRefOf:$output, OptionalAttr<Rock_GemmFeaturesAttr>:$features, OptionalAttr:$derivedBlockSize, OptionalAttr:$gridSize, IndexArrayLength<4>:$padding, IndexArrayLength<2>:$strides, ...The goal of this PR is to make
git clang-format origin/developproduce one operand per line for(ins ...)/(outs ...)DAGs.Technical Details
Configuration changes:
.clang-formatandmlir/.clang-format: add two clang-format options introduced in clang-format 19:TableGenBreakInsideDAGArg: BreakElements— break after each DAG element, aligned to the first element.TableGenBreakingDAGArgOperators: [ins, outs]— restrict the breaking behavior to DAGs starting withinsorouts, so unrelated DAG expressions are not reflowed..githooks/pre-commit: extend the staged-file regex to include.td, so staged TableGen changes get formatted at commit time alongside C/C++.CONTRIBUTING.md: note that clang-format >= 19 is now required for this repo (CI is already on LLVM 20 viamlir/utils/jenkins/Dockerfile). Mention that.tdfiles are covered bygit clang-format origin/develop.NFC follow-up commit:
.tdfiles undermlir/that contain(ins ...)/(outs ...)DAGs, usingclang-format-20 -i. Pure formatting, no semantic changes. The commit SHA is added to.git-blame-ignore-revssogit blameskips it, in line with the existing entries in that file.Test Plan
Verified locally with
clang-format-20/git-clang-format-20:.clang-formatfiles parse with clang-format 20.clang-format-20 -ion every reformatted.tdfile produces no further changes.git-clang-format-20 --binary clang-format-20 --diff origin/developreturns "clang-format did not modify any files".commonConvArgsinRockOps.tdnow matches the layout requested in the issue exactly (one operand per line, aligned after(ins).Test Result
Submission Checklist