Skip to content

Commit f50abe3

Browse files
authoredMar 29, 2022
Expand annotation-carried decoration parsing (KhronosGroup#1446)
The SPIR-V translator currently allows LLVM IR annotation intrinsics to carry a selection of INTEL extension decorations as part of the string in its second argument. These changes expand the parsing of these to allow generic parsing of decorations in annotation strings, identifying the decorations by their SPIR-V integer identifiers rather than reserved names. It is legal to have decorations with reserved named specified by their SPIR-V integer identifiers, but to allow backwards compatibility the reverse translation will use the reserved names for all decorations with them. Signed-off-by: Steffen Larsen <[email protected]>
1 parent bc94b7c commit f50abe3

File tree

3 files changed

+312
-71
lines changed

3 files changed

+312
-71
lines changed
 

‎docs/SPIRVRepresentationInLLVM.rst

+70
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,76 @@ with extra operands ``"v"`` and ``Export`` in SPIR-V.
461461
decorates the argument ``b`` of ``k`` with ``Restrict`` in SPIR-V while not
462462
adding any decoration to argument ``a``.
463463

464+
Member decoration through pointer annotations
465+
---------------------------------------------
466+
467+
Class members can be decorated using the ``llvm.ptr.annotation`` LLVM IR
468+
intrinsic. Member decorations specified in ``llvm.ptr.annotation`` must be in
469+
the second argument and must have the format ``{X}`` or ``{X:Y}`` where ``X`` is
470+
either one of the reserved names or an integer literal representing the SPIR-V
471+
decoration identifier and ``Y`` is 1 or more arguments separated by ",", where
472+
each argument must be either a word (including numbers) or a string enclosed by
473+
quotation marks. The ``llvm.ptr.annotation`` can contain any number decorations
474+
following this format.
475+
476+
For example, both ``{5835:1,2,3}`` and ``{bank_bits:1,2,3}`` will result in the
477+
``BankwidthINTEL`` decoration with literals 1, 2, and 3 attached to the
478+
annotated member.
479+
480+
The translator accepts a number of reserved names that correspond to SPIR-V
481+
member decorations.
482+
483+
+-----------------------+------------------+-----------------------------------+
484+
| Decoration | Reserved Name | Note |
485+
+=======================+==================+===================================+
486+
| RegisterINTEL | register | Additional arguments are ignored, |
487+
| | | but reverse translation will add |
488+
| | | a 1 argument, i.e. |
489+
| | | ``{register:1}``. |
490+
+-----------------------+------------------+-----------------------------------+
491+
| MemoryINTEL | memory | |
492+
+-----------------------+------------------+-----------------------------------+
493+
| NumbanksINTEL | numbanks | |
494+
+-----------------------+------------------+-----------------------------------+
495+
| BankwidthINTEL | bankwidth | |
496+
+-----------------------+------------------+-----------------------------------+
497+
| MaxPrivateCopiesINTEL | private_copies | |
498+
+-----------------------+------------------+-----------------------------------+
499+
| SinglepumpINTEL | pump | Reserved name is shared with |
500+
| | | DoublepumpINTEL. SinglepumpINTEL |
501+
| | | will be selected if the argument |
502+
| | | is 2, i.e ``{pump:1}``. |
503+
+-----------------------+------------------+-----------------------------------+
504+
| DoublepumpINTEL | pump | Reserved name is shared with |
505+
| | | SinglepumpINTEL. DoublepumpINTEL |
506+
| | | will be selected if the argument |
507+
| | | is 2, i.e ``{pump:2}``. |
508+
+-----------------------+------------------+-----------------------------------+
509+
| MaxReplicatesINTEL | max_replicates | |
510+
+-----------------------+------------------+-----------------------------------+
511+
| SimpleDualPortINTEL | simple_dual_port | Additional arguments are ignored, |
512+
| | | but reverse translation will add |
513+
| | | a 1 argument, i.e. |
514+
| | | ``{simple_dual_port:1}``. |
515+
+-----------------------+------------------+-----------------------------------+
516+
| MergeINTEL | merge | Arguments of this are separated by|
517+
| | | ":" rather than ",", i.e. |
518+
| | | ``{merge:X:Y}``. |
519+
+-----------------------+------------------+-----------------------------------+
520+
| BankBitsINTEL | bank_bits | |
521+
+-----------------------+------------------+-----------------------------------+
522+
| ForcePow2DepthINTEL | force_pow2_depth | |
523+
+-----------------------+------------------+-----------------------------------+
524+
525+
None of the special requirements imposed from using the reserved names apply to
526+
using decoration identifiers directly.
527+
528+
During reverse translation, the translator prioritizes reserved names over
529+
decoration identifiers, even if the member decoration was generated using the
530+
corresponding decoration identifier. For example, this means that translating
531+
``{5825}`` to SPIR-V and back to LLVM IR will result in ``{register:1}`` being
532+
in the annotation string argument instead of the initial value.
533+
464534
Debug information extension
465535
===========================
466536

0 commit comments

Comments
 (0)
Please sign in to comment.