[PATCH] D75875: [mlir][spirv] Support querying type extension/capability requirements

Lei Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 11 13:35:22 PDT 2020


antiagainst added a comment.

In D75875#1915667 <https://reviews.llvm.org/D75875#1915667>, @mravishankar wrote:

> This is really great. I see there is a lot of complexity involved in deciding the extensions and capability, and storage class, etc. Wondering if most of the logic could be put in a single place for all types. So instead of querying the type to get the extension/capability info, have a single method that has all the logic...


You can have availability information on many things in SPIR-V, including types, ops, and enum cases, and these information are available from SPIR-V's human-readable grammar.  So it's quite suitable for auto-generation. The way it works right now is we generate utility functions for each enum to return its requirements on version/extension/capabilities and also auto-generate the methods for ops to synthesize the availability info (note that for an op, the opcode itself has availability constraints, but it **should also** consider the enum attributes it has. Types are a bit different because we don't have the information readily available in the grammar. We can probably include that in the grammar too but it seems fine for now to manually write the C++ code given there are just a few types.

Hope the above clarifies things. I plan to write it down in the doc afterwards. Putting in a single place means we will have a gigantic method and it involves recursively calling into itself and goes through switch table all the time, which I don't think is a good practice.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75875/new/

https://reviews.llvm.org/D75875





More information about the llvm-commits mailing list