Skip to content

core: (attr assembly fmt) add core directive classes (pt1)#5900

Merged
n-io merged 5 commits into
mainfrom
nicolai/attr-asm-fmt-pt1-core-directives
Jul 9, 2026
Merged

core: (attr assembly fmt) add core directive classes (pt1)#5900
n-io merged 5 commits into
mainfrom
nicolai/attr-asm-fmt-pt1-core-directives

Conversation

@n-io

@n-io n-io commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

Adding foundational classes for a declarative assembly format system, mirroring the implementations for op assembly format.

The existing format directives are tightly wired to operations, so this PR proposes instead to have a separate hierarchy based on AttrFormatDirective to keep the systems separate which helped keep the implementation clean. This first PR contains only the plumbing — the AttrFormatDirective base class, AttrFormatProgram, and an AttrFormatParser skeleton — and currently supports only the empty format; concrete directives follow in later PRs. The AttrFormatProgram and AttrFormatParser resemble what is implemented for operations.

This PR is the first in a stacked series to enable full support for attribute/type assembly_format. See also:

@n-io n-io self-assigned this Apr 21, 2026
@n-io n-io added the core xDSL core (ir, textual format, ...) label Apr 21, 2026
@n-io n-io marked this pull request as ready for review April 21, 2026 10:55
@codecov

codecov Bot commented Apr 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.89%. Comparing base (883c395) to head (9e157d1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5900      +/-   ##
==========================================
+ Coverage   86.88%   86.89%   +0.01%     
==========================================
  Files         431      431              
  Lines       64559    64599      +40     
  Branches     7395     7396       +1     
==========================================
+ Hits        56090    56132      +42     
+ Misses       6897     6896       -1     
+ Partials     1572     1571       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@n-io n-io changed the title core: add core directive classes for attr declarative assembly format (pt1) core: (attr assembly fmt) add core directive classes (pt1) Apr 21, 2026
Comment thread tests/irdl/test_attr_declarative_assembly_format.py Outdated
Comment thread tests/irdl/test_attr_declarative_assembly_format.py Outdated
@superlopuh

Copy link
Copy Markdown
Member

I would love for this part of the codebase to have 100% code coverage. Could you please take a look at what's not covered and add tests for it?

Also, I still feel like this first PR is bigger than ideal. Could you please try removing anything to do with parameters to start with? In theory we can test independently parsing punctuation and whitespace.

…rmat

Add the foundational classes for a declarative assembly format system for
ParametrizedAttribute types, mirroring the op-side system: the
AttrFormatDirective ABC, the structural directives (whitespace, punctuation,
keyword), AttrFormatProgram, and AttrFormatParser. Parameter and other
directives are added in follow-up PRs.
@n-io n-io force-pushed the nicolai/attr-asm-fmt-pt1-core-directives branch from 377ba90 to b8e73f1 Compare July 7, 2026 16:25
The op-side WhitespaceDirective, PunctuationDirective and KeywordDirective
now delegate their print logic to the shared _print_whitespace /
_print_punctuation / _print_keyword helpers instead of duplicating it,
matching how the attr-side directives already use them.
@n-io n-io requested a review from superlopuh July 7, 2026 17:08
@n-io

n-io commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Both done as suggested.

Comment thread tests/irdl/test_attr_declarative_assembly_format.py
Comment thread xdsl/irdl/declarative_assembly_format_parser.py Outdated
An empty format string is a valid program (no directives): it prints
nothing and parses as a no-op. Addresses review feedback on #5900.
Comment thread tests/irdl/test_attr_declarative_assembly_format.py Outdated
Per review, shrink this PR to only what is needed for an empty
assembly_format to work: drop the whitespace, punctuation and keyword
directives, and revert the shared print helpers (restoring the op-side
directives to their original inline logic). Concrete directives will
follow in later PRs.
@n-io n-io requested a review from superlopuh July 8, 2026 09:36
Comment thread xdsl/irdl/declarative_assembly_format.py Outdated
Comment thread xdsl/irdl/declarative_assembly_format.py Outdated
- Assert the format is empty in AttrFormatProgram.parse/print instead of
  iterating over stmts, removing the two uncovered loop bodies (the loop
  returns in a later PR alongside concrete directives).
- Reformat the new docstrings to start on their own line.
- Split the empty-format test into program/print-parse cases and add an
  end-to-end parse of !test_af.empty.
@n-io n-io requested a review from superlopuh July 8, 2026 13:00

@superlopuh superlopuh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@n-io n-io merged commit 175b9ec into main Jul 9, 2026
25 checks passed
@n-io n-io deleted the nicolai/attr-asm-fmt-pt1-core-directives branch July 9, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core xDSL core (ir, textual format, ...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants