[llvm] [HLSL][SPIRV][Docs] Document intrinsic lowering (PR #213185)
Suren Nihalani via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 30 18:55:12 PDT 2026
https://github.com/SurenNihalani updated https://github.com/llvm/llvm-project/pull/213185
>From 7e01ce72b72c18d8372b4342044c65d45c7c008a Mon Sep 17 00:00:00 2001
From: Suren Nihalani <suren at govtron.com>
Date: Thu, 30 Jul 2026 17:55:59 -0700
Subject: [PATCH 1/2] [HLSL][SPIRV][Docs] Document intrinsic lowering
---
llvm/docs/SPIRVUsage.md | 55 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/llvm/docs/SPIRVUsage.md b/llvm/docs/SPIRVUsage.md
index 173c0a2de5a41..5dd4f23591c72 100644
--- a/llvm/docs/SPIRVUsage.md
+++ b/llvm/docs/SPIRVUsage.md
@@ -586,6 +586,61 @@ acos_f32
represents the `acos` function from the OpenCL extended instruction set for a float32
input.
+#### HLSL Intrinsics
+
+When targeting SPIR-V, Clang lowers HLSL builtin functions to LLVM IR calls that
+the SPIR-V backend recognizes. The backend then selects the corresponding core
+SPIR-V instruction, extended instruction, or instruction sequence. The regression
+tests in `llvm/test/CodeGen/SPIRV/hlsl-intrinsics` show the currently supported
+lowerings.
+
+Some representative HLSL intrinsic mappings are:
+
+- `any` uses `llvm.spv.any.*`.
+
+ ```{list-table}
+ :widths: 35 65
+ :header-rows: 1
+
+ * - Source shape
+ - SPIR-V lowering
+ * - Scalar numeric
+ - Compares the value with zero.
+ * - Boolean vector
+ - `OpAny`
+ * - Numeric vector
+ - Compares each element with zero, then applies `OpAny`.
+ ```
+
+- `all` uses `llvm.spv.all.*`.
+
+ ```{list-table}
+ :widths: 35 65
+ :header-rows: 1
+
+ * - Source shape
+ - SPIR-V lowering
+ * - Scalar numeric
+ - Compares the value with zero.
+ * - Boolean vector
+ - `OpAll`
+ * - Numeric vector
+ - Compares each element with zero, then applies `OpAll`.
+ ```
+
+- `lerp` uses `llvm.spv.lerp.*`.
+
+ ```{list-table}
+ :widths: 35 65
+ :header-rows: 1
+
+ * - Source shape
+ - SPIR-V lowering
+ * - Floating-point scalar or vector
+ - Lowers to the GLSL extended instruction `FMix` from
+ [`GLSL.std.450`](https://registry.khronos.org/SPIR-V/specs/unified1/GLSL.std.450.html).
+ ```
+
#### Builtin Variables
SPIR-V builtin variables, which provide access to special hardware or execution model
>From 0ec629a5c00af5abd64ac5af81aa57c779610863 Mon Sep 17 00:00:00 2001
From: Suren Nihalani <suren at govtron.com>
Date: Thu, 30 Jul 2026 18:54:48 -0700
Subject: [PATCH 2/2] [HLSL][SPIRV][Docs] Trigger CI
More information about the llvm-commits
mailing list