| 1 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -finclude-default-header -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-DXIL -DTARGET=dx |
| 2 |
// RUN: %clang_cc1 -triple spirv-linux-vulkan-library -x hlsl -emit-llvm -finclude-default-header -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV -DTARGET=spv |
| 3 |
|
| 4 |
struct S0 { |
| 5 |
uint Idx : SV_DispatchThreadID; |
| 6 |
}; |
| 7 |
|
| 8 |
// CHECK: define void @main0() |
| 9 |
// CHECK-DXIL: %[[#ID:]] = call i32 @llvm.[[TARGET]].thread.id(i32 0) |
| 10 |
// CHECK-SPIRV: %[[#ID:]] = call i32 @llvm.[[TARGET]].thread.id.i32(i32 0) |
| 11 |
// CHECK: %[[#TMP:]] = insertvalue %struct.S0 poison, i32 %[[#ID:]], 0 |
| 12 |
// CHECK: %[[#ARG:]] = alloca %struct.S0, align 8 |
| 13 |
// CHECK: store %struct.S0 %[[#TMP]], ptr %[[#ARG]], align 4 |
| 14 |
// CHECK-DXIL: call void @{{.*}}main0{{.*}}(ptr %[[#ARG]]) |
| 15 |
// CHECK-SPIRV: call spir_func void @{{.*}}main0{{.*}}(ptr %[[#ARG]]) |
| 16 |
[shader("compute")] |
| 17 |
[numthreads(8,8,1)] |
| 18 |
void main0(S0 p) {} |
| 19 |
|
| 20 |
struct S1 { |
| 21 |
uint2 a : SV_DispatchThreadID; |
| 22 |
uint2 b : SV_GroupThreadID; |
| 23 |
}; |
| 24 |
|
| 25 |
// CHECK: define void @main1() |
| 26 |
// CHECK-DXIL: %[[#ID:]] = call i32 @llvm.[[TARGET]].thread.id(i32 0) |
| 27 |
// CHECK-SPIRV: %[[#ID:]] = call i32 @llvm.[[TARGET]].thread.id.i32(i32 0) |
| 28 |
// CHECK: %[[#AX_:]] = insertelement <2 x i32> poison, i32 %[[#ID]], i64 0 |
| 29 |
// CHECK-DXIL: %[[#ID:]] = call i32 @llvm.[[TARGET]].thread.id(i32 1) |
| 30 |
// CHECK-SPIRV: %[[#ID:]] = call i32 @llvm.[[TARGET]].thread.id.i32(i32 1) |
| 31 |
// CHECK: %[[#AXY:]] = insertelement <2 x i32> %[[#AX_]], i32 %[[#ID]], i64 1 |
| 32 |
// CHECK: %[[#S1A_:]] = insertvalue %struct.S1 poison, <2 x i32> %[[#AXY]], 0 |
| 33 |
// CHECK-DXIL: %[[#ID_X:]] = call i32 @llvm.[[TARGET]].thread.id.in.group(i32 0) |
| 34 |
// CHECK-SPIRV: %[[#ID_X:]] = call i32 @llvm.[[TARGET]].thread.id.in.group.i32(i32 0) |
| 35 |
// CHECK: %[[#ID_X_:]] = insertelement <2 x i32> poison, i32 %[[#ID_X]], i64 0 |
| 36 |
// CHECK-DXIL: %[[#ID_Y:]] = call i32 @llvm.[[TARGET]].thread.id.in.group(i32 1) |
| 37 |
// CHECK-SPIRV: %[[#ID_Y:]] = call i32 @llvm.[[TARGET]].thread.id.in.group.i32(i32 1) |
| 38 |
// CHECK: %[[#ID_XY:]] = insertelement <2 x i32> %[[#ID_X_]], i32 %[[#ID_Y]], i64 1 |
| 39 |
// CHECK: %[[#S1AB:]] = insertvalue %struct.S1 %[[#S1A_]], <2 x i32> %[[#ID_XYZ:]], 1 |
| 40 |
// CHECK: %[[#ARG:]] = alloca %struct.S1, align 8 |
| 41 |
// CHECK: store %struct.S1 %[[#S1AB]], ptr %[[#ARG]], align 8 |
| 42 |
// CHECK-DXIL: call void @{{.*}}main1{{.*}}(ptr %[[#ARG]]) |
| 43 |
// CHECK-SPIRV: call spir_func void @{{.*}}main1{{.*}}(ptr %[[#ARG]]) |
| 44 |
[shader("compute")] |
| 45 |
[numthreads(8,8,1)] |
| 46 |
void main1(S1 p) {} |
| 47 |
|
| 48 |
struct S2C { |
| 49 |
uint2 b : SV_GroupThreadID; |
| 50 |
}; |
| 51 |
|
| 52 |
struct S2 { |
| 53 |
uint a : SV_DispatchThreadID; |
| 54 |
S2C child; |
| 55 |
}; |
| 56 |
|
| 57 |
// CHECK: define void @main2() |
| 58 |
// CHECK-DXIL: %[[#ID:]] = call i32 @llvm.[[TARGET]].thread.id(i32 0) |
| 59 |
// CHECK-SPIRV: %[[#ID:]] = call i32 @llvm.[[TARGET]].thread.id.i32(i32 0) |
| 60 |
// CHECK: %[[#S2A_:]] = insertvalue %struct.S2 poison, i32 %[[#ID:]], 0 |
| 61 |
|
| 62 |
// CHECK-DXIL: %[[#ID_X:]] = call i32 @llvm.[[TARGET]].thread.id.in.group(i32 0) |
| 63 |
// CHECK-SPIRV: %[[#ID_X:]] = call i32 @llvm.[[TARGET]].thread.id.in.group.i32(i32 0) |
| 64 |
// CHECK: %[[#ID_X_:]] = insertelement <2 x i32> poison, i32 %[[#ID_X]], i64 0 |
| 65 |
// CHECK-DXIL: %[[#ID_Y:]] = call i32 @llvm.[[TARGET]].thread.id.in.group(i32 1) |
| 66 |
// CHECK-SPIRV: %[[#ID_Y:]] = call i32 @llvm.[[TARGET]].thread.id.in.group.i32(i32 1) |
| 67 |
// CHECK: %[[#ID_XY:]] = insertelement <2 x i32> %[[#ID_X_]], i32 %[[#ID_Y]], i64 1 |
| 68 |
// CHECK: %[[#S2C:]] = insertvalue %struct.S2C poison, <2 x i32> %[[#ID_XY:]], 0 |
| 69 |
|
| 70 |
// CHECK: %[[#S2AB:]] = insertvalue %struct.S2 %[[#S2A_]], %struct.S2C %[[#S2V:]], 1 |
| 71 |
// CHECK: %[[#ARG:]] = alloca %struct.S2, align 8 |
| 72 |
// CHECK: store %struct.S2 %[[#S2AB]], ptr %[[#ARG]], align 1 |
| 73 |
// CHECK-DXIL: call void @{{.*}}main2{{.*}}(ptr %[[#ARG]]) |
| 74 |
// CHECK-SPIRV: call spir_func void @{{.*}}main2{{.*}}(ptr %[[#ARG]]) |
| 75 |
[shader("compute")] |
| 76 |
[numthreads(8,8,1)] |
| 77 |
void main2(S2 p) {} |