[spirv] Add script to auto-generate SPIR-V op template from spec
authorLei Zhang <antiagainst@google.com>
Fri, 12 Jul 2019 17:00:13 +0000 (10:00 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Sat, 13 Jul 2019 00:42:30 +0000 (17:42 -0700)
commitbd484f17a0f073c0b26459149a3d6a75539e5e34
tree5bbc3da4666d86c81d680d1fc9304f259fe0b8c7
parent60a2983779b56d1930e59143e03faf6fb9f85a79
[spirv] Add script to auto-generate SPIR-V op template from spec

SPIR-V has a JSON grammar file that defines the syntax of SPIR-V
instructions. However, its lacks fine-grained constraints on
instruction operands; those information is only available as
natural language sentences in the SPIR-V spec, which also contains
the detailed documentation for each SPIR-V instruction.

This CL pulls information from both the JSON grammar and HTML
spec. It right now uses the former to deduce the arguments and
results (with coarse-grained constraints) and the latter for
documentation. In the future we can add the functionality to
match certain natural language sentences for more fine-grained
constraints, but right now the developer is expected to update
the generated op definition. This should serve as a nice
bootstrap step to save efforts.

PiperOrigin-RevId: 257821205
mlir/include/mlir/SPIRV/SPIRVOps.td
mlir/utils/spirv/define_inst.sh [new file with mode: 0755]
mlir/utils/spirv/gen_spirv_dialect.py