xref: /llvm-project/clang/test/CodeGenHLSL/semantics/GroupIndex-codegen.hlsl (revision c2063de1593610eda0f4de33c3b89324642ed54c)
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -emit-llvm -disable-llvm-passes -o - -hlsl-entry main %s | FileCheck %s
2
3[numthreads(1,1,1)]
4void main(unsigned GI : SV_GroupIndex) {
5  main(GI - 1);
6}
7
8// For HLSL entry functions, we are generating a C-export function that wraps
9// the C++-mangled entry function. The wrapper function can be used to populate
10// semantic parameters and provides the expected void(void) signature that
11// drivers expect for entry points.
12
13//CHECK: define void @main() #[[#ENTRY_ATTR:]] {
14//CHECK-NEXT: entry:
15//CHECK-NEXT:   %0 = call i32 @llvm.dx.flattened.thread.id.in.group()
16//CHECK-NEXT:   call void @_Z4mainj(i32 %0)
17//CHECK-NEXT:   ret void
18//CHECK-NEXT: }
19
20// Verify that the entry had the expected dx.shader attribute
21
22//CHECK: attributes #[[#ENTRY_ATTR]] = { {{.*}}"hlsl.shader"="compute"{{.*}} }
23