[llvm] [SPIR-V] Add support for inline SPIR-V types (PR #125316)

Vyacheslav Levytskyy via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 14 06:16:21 PST 2025


================
@@ -260,6 +260,32 @@ parameters of its underlying image type, so that a sampled image for the
 previous type has the representation
 ``target("spirv.SampledImage, void, 1, 1, 0, 0, 0, 0, 0)``.
 
+.. _inline-spirv-types:
+
+Inline SPIR-V Types
+-------------------
+
+HLSL allows users to create types representing specific SPIR-V types, using ``vk::SpirvType`` and
+``vk::SpirvOpaqueType``. These are specified in the `Inline SPIR-V`_ proposal. They may be
+represented using target extension types:
+
+.. _Inline SPIR-V: https://microsoft.github.io/hlsl-specs/proposals/0011-inline-spirv.html#types
+
+  .. table:: Inline SPIR-V Types
+
+  ========================== =================== ==============================
+     LLVM type name          LLVM type arguments LLVM integer arguments
+  ========================== =================== ==============================
+  ``spirv.Type``             SPIR-V operands     opcode, size, alignment
+  ``spirv.IntegralConstant`` integral type       value
+  ``spirv.Literal``          (none)              value
+  ========================== =================== ==============================
+
+The operand arguments to ``spirv.Type`` may be either a ``spirv.IntegralConstant`` type,
+representing an ``OpConstant`` id operand, a ``spirv.Literal`` type, representing an immediate
+literal operand, or any other type, representing the id of that type as an operand.
+``spirv.IntegralConstant`` and ``spirv.Literal`` may not be used outside of this context.
+
----------------
VyacheslavLevytskyy wrote:

I think the doc may benefit from a very small example of how LLVM IR inline SPIR-V types look like and what would be a relevant SPIR-V output fragment. That would demonstrate the concept at one glance. Hopefully it should also keep the doc more self-contained and reader may easier catch the idea without referring to an external source.
Just as an idea. @s-perron @cassiebeckley What you think?

https://github.com/llvm/llvm-project/pull/125316


More information about the llvm-commits mailing list