Alexander Johnston 3142e3ab15
[HLSL] Implement ddx and ddy HLSL intrinsics (#168887)
Implements the ddx and ddy HLSL intrinsics. The DXIL intrinsics call the
ddx_coarse and ddy_builtins as they lower to the coarse variants.
The SPIRV intrinsics lower to their own opcodes OpDPdx and OpDPdy. Tests
are added to ensure the SPIRV builtins are not available outside of
shaders stage.

Closes https://github.com/llvm/llvm-project/issues/99096
Closes https://github.com/llvm/llvm-project/issues/99099
2025-12-11 10:04:35 -08:00

13 lines
497 B
LLVM

; RUN: not llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o /dev/null 2>&1 | FileCheck %s
; RUN: not llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o /dev/null 2>&1 | FileCheck %s
; CHECK: LLVM ERROR: %{{.*}} = G_INTRINSIC intrinsic(@llvm.spv.ddx), %{{.*}} is only supported in shaders.
define noundef float @ddx(float noundef %a) {
entry:
%spv.ddx = call float @llvm.spv.ddx.f32(float %a)
ret float %spv.ddx
}
declare float @llvm.spv.ddx.f32(float)