-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mlir][spirv] Modernize op assembly formats and syntax docs #73359
Comments
@llvm/issue-subscribers-mlir-spirv Author: Jakub Kuderski (kuhar)
The SPIR-V dialect predates the `assemblyFormat` definitions in TableGen and some of the SPRI-V ops needlessly use handwritten parsers. We should go over the ops in the dialect and update to `assemblyFormat` wherever possible.
With |
Hi! This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
For more instructions on how to submit a patch to LLVM, see our documentation. If you have any further questions about this issue, don't hesitate to ask via a comment on this Github issue. |
@llvm/issue-subscribers-good-first-issue Author: Jakub Kuderski (kuhar)
The SPIR-V dialect predates the `assemblyFormat` definitions in TableGen and some of the SPRI-V ops needlessly use handwritten parsers. We should go over the ops in the dialect and update to `assemblyFormat` wherever possible.
With |
Some operations defined their syntax both in the documentation and via `assemblyFormat`. This leads to two syntax descriptions in the documentation for SPIR-V, see for example the documentation for [`spirv.mlir.yield`](https://mlir.llvm.org/docs/Dialects/SPIR-V/#spirvmliryield-spirvyieldop). Since the `assemblyFormat` is used to generate the actual parsers and printer implementations, this PR removes the manual syntax descriptions. (Similar to #73343.) The strategy that I used to find the duplicates was pretty uncomplicated. I scrolled through the [SPIR-V Dialect](https://mlir.llvm.org/docs/Dialects/SPIR-V) to find all duplicates and then remove the duplicate text from the `td` file. Note that the `Syntax:` block in the docs is a good proxy for whether `assemblyFormat` is defined because it will only be generated if the op has defined `assemblyFormat` (`op.hasAssemblyFormat()`): https://github.com/llvm/llvm-project/blob/e970652776bd07dbe42be557bf98722749230653/mlir/tools/mlir-tblgen/OpDocGen.cpp#L108-L124 https://github.com/llvm/llvm-project/blob/e970652776bd07dbe42be557bf98722749230653/mlir/tools/mlir-tblgen/OpDocGen.cpp#L197-L199 Related issue #73359.
Hi, I'd like to work on this as my first issue |
Sure @alexbeloi. Feel free to ping me if you need some pointers. Also happy to have a chat on discord or a call. |
I don't see any duplicate |
@alexbeloi These duplicate ones have already been removed from the SPIR-V dialect: #73386. The remaining part of the task is to use You can find these by running something like |
Hey Jakub, I'm updating some of the SPIRV parsing to use assemblyFormat and have a couple questions. It seems like the change may require more than just a small It seems that assemblyFormat has some general requirements (AFAIU) to generate the builders
For example syntax:
Just replacing the quotes with angle brackets doesn't work, it seems to require something like
This would be added here, to replace the print/parse here. A bunch of handwritten parsers don't use
|
There are a few options here. In general, we should be fine with updating op syntax as long as the new syntax is not too different and we converge towards uniformity within the dialect.
The result type can often be inferred from ODS type constraints, e.g.,
We have some examples of ops with attributes that use
Here the format is optional and uses the Also, I'm personally not a fan of the parentheses introduced by
I'd argue that in the specific case of %0 = spirv.AtomicAnd <Device> <None> %ptr, %value : !spirv.ptr<i32, StorageBuffer> -> i32 |
llvm-project/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td Lines 1026 to 1056 in b26c0ed
|
see #73359 Declarative assemblyFormat ODS is more concise and requires less boilerplate than filling out CPP interfaces. Changes: * updates the Ops defined in `SPIRVAtomicOps.td` to use assemblyFormat. * Removes print/parse from`AtomcOps.cpp` which is now generated by assemblyFormat * Adds `Trait` to verify that a pointer operand `foo`'s pointee type matches operand `bar`'s type * * Updates error message expected in tests from new Trait * Updates tests to updated format (largely using <operand> in place of "operand")
…6323) see llvm#73359 Declarative assemblyFormat ODS is more concise and requires less boilerplate than filling out CPP interfaces. Changes: * updates the Ops defined in `SPIRVAtomicOps.td` to use assemblyFormat. * Removes print/parse from`AtomcOps.cpp` which is now generated by assemblyFormat * Adds `Trait` to verify that a pointer operand `foo`'s pointee type matches operand `bar`'s type * * Updates error message expected in tests from new Trait * Updates tests to updated format (largely using <operand> in place of "operand")
I'm currently looking for a good first issue to work on and noticed this one. It seems like the issue has already been resolved. |
@hahacyd I think there are still a lot of places that need updating. You can take this issue over if you'd like. |
@alexbeloi Thank you for your response! I apologize for mistakenly thinking the issue was resolved because I noticed it was unassigned. I still need to gain a deeper understanding of this issue, so I won't be taking it over for now. However, as I learn more, I'll be sure to offer help where I can. Thanks again for your guidance! |
@hahacyd yes, this is far from being done. Feel free to ask questions if you are not sure about something along the way. |
Hi, I found that most operations in SPIRVGroupOps.td both have |
SGTM, @hahacyd. Also feel free to ping me on discord if you have questions. |
see llvm#73359 Declarative assemblyFormat ODS is more concise and requires less boilerplate than filling out CPP interfaces. Changes: * updates the Ops defined in `SPIRVNonUniformOps.td and SPIRVGroupOps.td` to use assemblyFormat. * Removes print/parse from `GroupOps.cpp` which is now generated by assemblyFormat * Updates tests to updated format (largely using <operand> in place of "operand" and complementing type information)
see llvm#73359 Declarative assemblyFormat ODS is more concise and requires less boilerplate than filling out CPP interfaces. Changes: * updates the Ops defined in `SPIRVNonUniformOps.td and SPIRVGroupOps.td` to use assemblyFormat. * Removes print/parse from `GroupOps.cpp` which is now generated by assemblyFormat * Updates tests to updated format (largely using <operand> in place of "operand" and complementing type information)
#115662) Declarative assemblyFormat ODS is more concise and requires less boilerplate than filling out CPP interfaces. Changes: * updates the Ops defined in `SPIRVNonUniformOps.td and SPIRVGroupOps.td` to use assemblyFormat. * Removes print/parse from `GroupOps.cpp` which is now generated by assemblyFormat * Updates tests to updated format (largely using <operand> in place of "operand" and complementing type information) Issue: #73359
see llvm#73359 Declarative assemblyFormat ODS is more concise and requires less boilerplate than filling out cpp interfaces. Changes: updates the AccessChainOp defined in SPIRVMemoryOps.td to use assemblyFormat. Removes part print/parse from MemoryOps.cpp which is now generated by assemblyFormat Updates tests to updated format
see llvm#73359 Declarative assemblyFormat ODS is more concise and requires less boilerplate than filling out cpp interfaces. Changes: updates the AccessChainOp defined in SPIRVMemoryOps.td to use assemblyFormat. Removes part print/parse from MemoryOps.cpp which is now generated by assemblyFormat Updates tests to updated format
…16545) see #73359 Declarative assemblyFormat ODS is more concise and requires less boilerplate than filling out cpp interfaces. Changes: - updates the AccessChainOp defined in SPIRVMemoryOps.td to use assemblyFormat. - Removes part print/parse from MemoryOps.cpp which is now generated by assemblyFormat - Updates tests to updated format
…ndPtrAccessChainOp assembly see llvm#73359 Declarative assemblyFormat ODS is more concise and requires less boilerplate than filling out cpp interfaces. Changes: updates the PtrAccessChainOp and InBoundPtrAccessChainOp defined in SPIRVMemoryOps.td to use assemblyFormat. Removes part print/parse from MemoryOps.cpp which is now generated by assemblyFormat Updates tests to updated format
…assembly (#116943) Declarative assemblyFormat ODS is more concise and requires less boilerplate than filling out cpp interfaces. Changes: updates the PtrAccessChainOp and InBoundPtrAccessChainOp defined in SPIRVMemoryOps.td to use assemblyFormat. Removes part print/parse from MemoryOps.cpp which is now generated by assemblyFormat Updates tests to updated format Issue: #73359
The SPIR-V dialect predates the
assemblyFormat
definitions in TableGen and some of the SPRI-V ops needlessly use handwritten parsers. We should go over the ops in the dialect and update toassemblyFormat
wherever possible.With
assemblyFormat
in place, we can also drop the handwritten syntax docs, since the latter is redundant in the presence ofassemblyFormat
. This way the two can't possibly diverge and become confusing. This is similar to the cleanup done in #73343.The text was updated successfully, but these errors were encountered: