Skip to content

Commit cfdc210

Browse files
committed
Add SPIR-V Instructions Mapped to LLVM Metadata section.
1 parent 21c17d1 commit cfdc210

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

llvm/docs/SPIRVUsage.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,3 +585,31 @@ Group and Subgroup Operations
585585
For workgroup and subgroup operations, LLVM uses function calls to represent SPIR-V's
586586
group-based instructions. These builtins facilitate group synchronization, data sharing,
587587
and collective operations essential for efficient parallel computation.
588+
589+
SPIR-V Instructions Mapped to LLVM Metadata
590+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
591+
Some SPIR-V instructions don't have a direct equivalent in the LLVM IR language. To
592+
address this, the SPIR-V Target uses different specific LLVM named metadata to convey
593+
the necessary information. The SPIR-V specification allows multiple module-scope
594+
instructions, where as LLVM named metadata must be unique. Therefore, the encoding of
595+
such instructions has the following format:
596+
597+
.. code-block:: llvm
598+
599+
!spirv.<OpCodeName> = !{!<InstructionMetadata1>, !<InstructionMetadata2>, ..}
600+
!<InstructionMetadata1> = !{<Operand1>, <Operand2>, ..}
601+
!<InstructionMetadata2> = !{<Operand1>, <Operand2>, ..}
602+
603+
Below, you will find the mappings between SPIR-V instruction and their corresponding
604+
LLVM IR representations.
605+
606+
+--------------------+---------------------------------------------------------+
607+
| SPIR-V instruction | LLVM IR |
608+
+====================+=========================================================+
609+
| OpExecutionMode | .. code-block:: llvm |
610+
| | |
611+
| | !spirv.ExecutionMode = !{!0} |
612+
| | !0 = !{void @worker, i32 30, i32 262149} |
613+
| | ; Set execution mode with id 30 (VecTypeHint) and |
614+
| | ; literal `262149` operand. |
615+
+--------------------+---------------------------------------------------------+

0 commit comments

Comments
 (0)