xref: /llvm-project/clang/test/CodeGenHLSL/semantics/GroupIndex-codegen.hlsl (revision c2063de1593610eda0f4de33c3b89324642ed54c)
1f2bb6c44SNatalie Chouinard// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -emit-llvm -disable-llvm-passes -o - -hlsl-entry main %s | FileCheck %s
222c477f9SChris Bieneman
322c477f9SChris Bieneman[numthreads(1,1,1)]
422c477f9SChris Bienemanvoid main(unsigned GI : SV_GroupIndex) {
522c477f9SChris Bieneman  main(GI - 1);
622c477f9SChris Bieneman}
722c477f9SChris Bieneman
822c477f9SChris Bieneman// For HLSL entry functions, we are generating a C-export function that wraps
922c477f9SChris Bieneman// the C++-mangled entry function. The wrapper function can be used to populate
1022c477f9SChris Bieneman// semantic parameters and provides the expected void(void) signature that
1122c477f9SChris Bieneman// drivers expect for entry points.
1222c477f9SChris Bieneman
13f2bb6c44SNatalie Chouinard//CHECK: define void @main() #[[#ENTRY_ATTR:]] {
1422c477f9SChris Bieneman//CHECK-NEXT: entry:
1522c477f9SChris Bieneman//CHECK-NEXT:   %0 = call i32 @llvm.dx.flattened.thread.id.in.group()
16*c2063de1SGreg Roth//CHECK-NEXT:   call void @_Z4mainj(i32 %0)
1722c477f9SChris Bieneman//CHECK-NEXT:   ret void
1822c477f9SChris Bieneman//CHECK-NEXT: }
1922c477f9SChris Bieneman
2022c477f9SChris Bieneman// Verify that the entry had the expected dx.shader attribute
2122c477f9SChris Bieneman
22f2bb6c44SNatalie Chouinard//CHECK: attributes #[[#ENTRY_ATTR]] = { {{.*}}"hlsl.shader"="compute"{{.*}} }
23