llvm-project/llvm/test/CodeGen/DirectX/wavesize-md-valid.ll
Finn Plummer 6312d27511
[DirectX] Emit hlsl.wavesize function attribute as entry property metadata (#165624)
This pr adds support for emitting the `hlsl.wavesize` function attribute
as an entry property metadata for a compute shader.

It follows the implementation of `hlsl.numthreads`.

- Collects the wave range information from the function attribute in
`DXILMetadataAnalysis`
- Introduce the `WaveRange` property tag
- Emit a `WaveSize` or `WaveRange` metadata (depending on shader model)
in `DXILTranslateMetadata`
- Add tests for valid/invalid scenarios
- Updates the base `PSVInfo` to reflect the min/max wave lane counts

Resolves #70118
2025-11-05 09:18:49 -08:00

97 lines
2.9 KiB
LLVM

; RUN: split-file %s %t
; RUN: opt -S --dxil-translate-metadata %t/only.ll | FileCheck %t/only.ll
; RUN: opt -S --dxil-translate-metadata %t/min.ll | FileCheck %t/min.ll
; RUN: opt -S --dxil-translate-metadata %t/max.ll | FileCheck %t/max.ll
; RUN: opt -S --dxil-translate-metadata %t/pref.ll | FileCheck %t/pref.ll
; RUN: llc --filetype=obj %t/only.ll -o - | obj2yaml | FileCheck %t/only.ll --check-prefix=OBJ
; RUN: llc --filetype=obj %t/min.ll -o - | obj2yaml | FileCheck %t/min.ll --check-prefix=OBJ
; RUN: llc --filetype=obj %t/max.ll -o - | obj2yaml | FileCheck %t/max.ll --check-prefix=OBJ
; RUN: llc --filetype=obj %t/pref.ll -o - | obj2yaml | FileCheck %t/pref.ll --check-prefix=OBJ
; Test that wave size/range metadata is correctly generated with the correct tag
;--- only.ll
; CHECK: !dx.entryPoints = !{![[#ENTRY:]]}
; CHECK: ![[#ENTRY]] = !{ptr @main, !"main", null, null, ![[#PROPS:]]}
; CHECK: ![[#PROPS]] = !{{{.*}}i32 11, ![[#WAVE_SIZE:]]{{.*}}}
; CHECK: ![[#WAVE_SIZE]] = !{i32 16}
; OBJ: - Name: PSV0
; OBJ: PSVInfo:
; OBJ: MinimumWaveLaneCount: 16
; OBJ: MaximumWaveLaneCount: 16
target triple = "dxil-unknown-shadermodel6.6-compute"
define void @main() #0 {
entry:
ret void
}
attributes #0 = { "hlsl.wavesize"="16,0,0" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
;--- min.ll
; CHECK: !dx.entryPoints = !{![[#ENTRY:]]}
; CHECK: ![[#ENTRY]] = !{ptr @main, !"main", null, null, ![[#PROPS:]]}
; CHECK: ![[#PROPS]] = !{{{.*}}i32 23, ![[#WAVE_SIZE:]]{{.*}}}
; CHECK: ![[#WAVE_SIZE]] = !{i32 16, i32 0, i32 0}
; OBJ: - Name: PSV0
; OBJ: PSVInfo:
; OBJ: MinimumWaveLaneCount: 16
; OBJ: MaximumWaveLaneCount: 16
target triple = "dxil-unknown-shadermodel6.8-compute"
define void @main() #0 {
entry:
ret void
}
attributes #0 = { "hlsl.wavesize"="16,0,0" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
;--- max.ll
; CHECK: !dx.entryPoints = !{![[#ENTRY:]]}
; CHECK: ![[#ENTRY]] = !{ptr @main, !"main", null, null, ![[#PROPS:]]}
; CHECK: ![[#PROPS]] = !{{{.*}}i32 23, ![[#WAVE_SIZE:]]{{.*}}}
; CHECK: ![[#WAVE_SIZE]] = !{i32 16, i32 32, i32 0}
; OBJ: - Name: PSV0
; OBJ: PSVInfo:
; OBJ: MinimumWaveLaneCount: 16
; OBJ: MaximumWaveLaneCount: 32
target triple = "dxil-unknown-shadermodel6.8-compute"
define void @main() #0 {
entry:
ret void
}
attributes #0 = { "hlsl.wavesize"="16,32,0" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
;--- pref.ll
; CHECK: !dx.entryPoints = !{![[#ENTRY:]]}
; CHECK: ![[#ENTRY]] = !{ptr @main, !"main", null, null, ![[#PROPS:]]}
; CHECK: ![[#PROPS]] = !{{{.*}}i32 23, ![[#WAVE_SIZE:]]{{.*}}}
; CHECK: ![[#WAVE_SIZE]] = !{i32 16, i32 64, i32 32}
; OBJ: - Name: PSV0
; OBJ: PSVInfo:
; OBJ: MinimumWaveLaneCount: 16
; OBJ: MaximumWaveLaneCount: 64
target triple = "dxil-unknown-shadermodel6.8-compute"
define void @main() #0 {
entry:
ret void
}
attributes #0 = { "hlsl.wavesize"="16,64,32" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }