Skip to content

feat: custom syntax a la TableGen#900

Draft
GZGavinZhao wants to merge 3 commits into
mainfrom
gzgz/custom-syntax
Draft

feat: custom syntax a la TableGen#900
GZGavinZhao wants to merge 3 commits into
mainfrom
gzgz/custom-syntax

Conversation

@GZGavinZhao

Copy link
Copy Markdown
Collaborator

For CI and visibility...

@GZGavinZhao GZGavinZhao self-assigned this Jun 20, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

VeIR Benchmarks

Details
Benchmark suite Current: 7dad612 Previous: fc38e7f Ratio
add-fold-worklist/create 2365000 ns (± 51193) 2227000 ns (± 44602) 1.06
add-fold-worklist/rewrite 4001000 ns (± 37151) 3985000 ns (± 90307) 1.00
add-fold-worklist-local/create 2254000 ns (± 122859) 2164000 ns (± 78738) 1.04
add-fold-worklist-local/rewrite 3353000 ns (± 155697) 3416000 ns (± 77796) 0.98
add-zero-worklist/create 2388000 ns (± 104904) 2223000 ns (± 100063) 1.07
add-zero-worklist/rewrite 2566000 ns (± 69033) 2522000 ns (± 106289) 1.02
add-zero-reuse-worklist/create 1905000 ns (± 48097) 1836000 ns (± 69049) 1.04
add-zero-reuse-worklist/rewrite 2140000 ns (± 56486) 2079000 ns (± 57582) 1.03
mul-two-worklist/create 2302000 ns (± 70059) 2236000 ns (± 102923) 1.03
mul-two-worklist/rewrite 5780000 ns (± 229132) 5561000 ns (± 111003) 1.04
add-fold-forwards/create 2311500 ns (± 113763) 2200000 ns (± 73638) 1.05
add-fold-forwards/rewrite 3055000 ns (± 97625) 3084000 ns (± 53148) 0.99
add-zero-forwards/create 2290000 ns (± 65257) 2251500 ns (± 139712) 1.02
add-zero-forwards/rewrite 1953000 ns (± 28560) 1978000 ns (± 47494) 0.99
add-zero-reuse-forwards/create 1972000 ns (± 97719) 1907500 ns (± 223419) 1.03
add-zero-reuse-forwards/rewrite 1575000 ns (± 62073) 1571500 ns (± 64613) 1.00
mul-two-forwards/create 2241000 ns (± 111495) 2270000 ns (± 141906) 0.99
mul-two-forwards/rewrite 3677000 ns (± 46874) 3747000 ns (± 113262) 0.98
add-zero-reuse-first/create 1916500 ns (± 121818) 1843500 ns (± 118926) 1.04
add-zero-reuse-first/rewrite 9000 ns (± 1734) 9500 ns (± 3036) 0.95
add-zero-lots-of-reuse-first/create 1947000 ns (± 88057) 1832000 ns (± 83852) 1.06
add-zero-lots-of-reuse-first/rewrite 776000 ns (± 13065) 801000 ns (± 40568) 0.97

This comment was automatically generated by workflow using github-action-benchmark.

Comment thread VeirOpt.lean
/-- Whether to accept ops/types/attrs from unregistered dialects. -/
allowUnregisteredDialect : Bool
/-- Whether to print operations using their custom (pretty) assembly format. -/
pretty : Bool

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We probably want to make --pretty the default and use MLIR's -mlir-print-op-generic to print the generic syntax, no?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, in a separate PR I want to remove the --pretty the default and update all the tests to use the new syntax.

The current PR still makes printing the generic syntax the default because otherwise there would be a diff for every test file due to the new syntax. I imagine that'd cause massive conflicts for everyone else's PRs, so I'm deferring flipping that switch to a future PR.

…ting

Add a TableGen-style declarative assembly-format DSL (Veir/AssemblyFormat.lean)
and use it to print operations in their custom (pretty) syntax, opt-in via a new
veir-opt --pretty flag. func.return / func.call are driven declaratively; func.func
uses a dedicated printer hook (mirroring MLIR's hasCustomAssemblyFormat). Parsing
of pretty syntax is added in a follow-up; this PR only changes printing, so the
default (generic) output and all existing tests are unaffected.
Pure, behavior-preserving refactor of the MLIR parser. Factor the verified
Rewriter.createOp + result-registration tail of parseOptionalOp into a reusable
createAndRegisterOp, and split the function-type tail out of parseOperationType
into parseFunctionTypeBody. No functional change; this isolates the verified-core
restructuring needed by the follow-up custom-syntax parser.
Accept bare-identifier op names in parseOptionalOp and dispatch to a declarative
assembly-format interpreter (func.return / func.call) or a func.func parser hook,
funnelling through the shared createAndRegisterOp. Generic parsing is unchanged;
this is purely additive on top of the refactor. Enables full generic<->pretty
round-tripping.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants