SPIR instruction database / spreadsheet

Is there a more machine-readable list of SPIR instructions around anywhere?

If not, I plan to make a spreadsheet so that I can autogenerate code.

  • It’ll basically be lines of: Op[NAME], Param1Type, Param1Name, Param1Mode, Param2Type …
  • Types will be from a manual list, eg: ‘SourceLanguage’, ‘id-def’, ‘nts’ (null-terminated-string), optional-word.
  • Not fussed about the encoded opcode value, as I can get that from the header.
1 Like

The SPIR-V registry contains a JSON file that has every opcode and its associated parameters and information about them. The file itself is part of the SPIR-V Headers GitHub repo. Surprisingly, it even has documentation explaining the format :wink:

Perfect, thankyou. Sorry I should’ve figured that out.
I looked at the list and ignored the JSON - my mistake was assuming that the JSON grammar files were for letting people write SPIR-V in JSON, rather than the JSON actually describing the instruction metadata.

I guess there’s no official instruction categorization hierarchy (apart from the structure of opcode names, like OpType[]).

1 Like

Yes, the JSON file is the source of truth for the instruction list and list of enums for various operand kinds.

Correct, there is no official categorization of instructions beyond that.

1 Like

The specification does put instructions into categories (subsections of the Instructions section) and these are sometimes referred to normatively. It’s a future plan to declare those categories in the JSON file, but for now, they are explicitly enumerated when building the specification.

This has rolled out now.
E.g. OpIAdd is classified as an “Arithmetic” instruction. see here

The categories are listed at the top of the grammar file. See here

1 Like