1 ; RUN: llc -mtriple=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck --check-prefixes=ALL,UNKNOWN-OS %s
2 ; RUN: llc -mtriple=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck --check-prefixes=ALL,UNKNOWN-OS %s
3 ; RUN: llc -mtriple=amdgcn-unknown-mesa3d -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefixes=ALL,MESA3D %s
4 ; RUN: llc -mtriple=amdgcn-unknown-mesa3d -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefixes=ALL,MESA3D %s
6 declare i32 @llvm.amdgcn.workgroup.id.x() #0
7 declare i32 @llvm.amdgcn.workgroup.id.y() #0
8 declare i32 @llvm.amdgcn.workgroup.id.z() #0
10 ; ALL-LABEL: {{^}}test_workgroup_id_x:
12 ; MESA3D: .amd_kernel_code_t
13 ; MESA3D: user_sgpr_count = 6
14 ; MESA3D: enable_sgpr_workgroup_id_x = 1
15 ; MESA3D: enable_sgpr_workgroup_id_y = 0
16 ; MESA3D: enable_sgpr_workgroup_id_z = 0
17 ; MESA3D: enable_sgpr_workgroup_info = 0
18 ; MESA3D: enable_vgpr_workitem_id = 0
19 ; MESA3D: enable_sgpr_grid_workgroup_count_x = 0
20 ; MESA3D: enable_sgpr_grid_workgroup_count_y = 0
21 ; MESA3D: enable_sgpr_grid_workgroup_count_z = 0
22 ; MESA3D: .end_amd_kernel_code_t
24 ; UNKNOWN-OS: v_mov_b32_e32 [[VCOPY:v[0-9]+]], s2{{$}}
25 ; MESA3D: v_mov_b32_e32 [[VCOPY:v[0-9]+]], s6{{$}}
27 ; ALL: {{buffer|flat}}_store_dword {{.*}}[[VCOPY]]
29 ; MESA3D: COMPUTE_PGM_RSRC2:USER_SGPR: 6
30 ; ALL-NOMESA3D: COMPUTE_PGM_RSRC2:USER_SGPR: 2
31 ; ALL: COMPUTE_PGM_RSRC2:TGID_X_EN: 1
32 ; ALL: COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
33 ; ALL: COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
34 ; ALL: COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
35 define amdgpu_kernel void @test_workgroup_id_x(ptr addrspace(1) %out) #1 {
36 %id = call i32 @llvm.amdgcn.workgroup.id.x()
37 store i32 %id, ptr addrspace(1) %out
41 ; ALL-LABEL: {{^}}test_workgroup_id_y:
42 ; MESA3D: user_sgpr_count = 6
43 ; MESA3D: enable_sgpr_workgroup_id_x = 1
44 ; MESA3D: enable_sgpr_workgroup_id_y = 1
45 ; MESA3D: enable_sgpr_workgroup_id_z = 0
46 ; MESA3D: enable_sgpr_workgroup_info = 0
47 ; MESA3D: enable_sgpr_grid_workgroup_count_x = 0
48 ; MESA3D: enable_sgpr_grid_workgroup_count_y = 0
49 ; MESA3D: enable_sgpr_grid_workgroup_count_z = 0
51 ; UNKNOWN-OS: v_mov_b32_e32 [[VCOPY:v[0-9]+]], s3{{$}}
52 ; HSA: v_mov_b32_e32 [[VCOPY:v[0-9]+]], s7{{$}}
54 ; ALL: {{buffer|flat}}_store_dword {{.*}}[[VCOPY]]
56 ; MESA3D: COMPUTE_PGM_RSRC2:USER_SGPR: 6
57 ; ALL-NOMESA3D: COMPUTE_PGM_RSRC2:USER_SGPR: 2
58 ; ALL: COMPUTE_PGM_RSRC2:TGID_X_EN: 1
59 ; ALL: COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
60 ; ALL: COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
61 ; ALL: COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
62 define amdgpu_kernel void @test_workgroup_id_y(ptr addrspace(1) %out) #1 {
63 %id = call i32 @llvm.amdgcn.workgroup.id.y()
64 store i32 %id, ptr addrspace(1) %out
68 ; ALL-LABEL: {{^}}test_workgroup_id_z:
69 ; MESA3D: user_sgpr_count = 6
70 ; MESA3D: enable_sgpr_workgroup_id_x = 1
71 ; MESA3D: enable_sgpr_workgroup_id_y = 0
72 ; MESA3D: enable_sgpr_workgroup_id_z = 1
73 ; MESA3D: enable_sgpr_workgroup_info = 0
74 ; MESA3D: enable_vgpr_workitem_id = 0
75 ; MESA3D: enable_sgpr_private_segment_buffer = 1
76 ; MESA3D: enable_sgpr_dispatch_ptr = 0
77 ; MESA3D: enable_sgpr_queue_ptr = 0
78 ; MESA3D: enable_sgpr_kernarg_segment_ptr = 1
79 ; MESA3D: enable_sgpr_dispatch_id = 0
80 ; MESA3D: enable_sgpr_flat_scratch_init = 0
81 ; MESA3D: enable_sgpr_private_segment_size = 0
82 ; MESA3D: enable_sgpr_grid_workgroup_count_x = 0
83 ; MESA3D: enable_sgpr_grid_workgroup_count_y = 0
84 ; MESA3D: enable_sgpr_grid_workgroup_count_z = 0
86 ; UNKNOWN-OS: v_mov_b32_e32 [[VCOPY:v[0-9]+]], s3{{$}}
87 ; HSA: v_mov_b32_e32 [[VCOPY:v[0-9]+]], s7{{$}}
89 ; ALL: {{buffer|flat}}_store_dword {{.*}}[[VCOPY]]
91 ; MESA3D: COMPUTE_PGM_RSRC2:USER_SGPR: 6
92 ; ALL-NOMESA3D: COMPUTE_PGM_RSRC2:USER_SGPR: 2
93 ; ALL: COMPUTE_PGM_RSRC2:TGID_X_EN: 1
94 ; ALL: COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
95 ; ALL: COMPUTE_PGM_RSRC2:TGID_Z_EN: 1
96 ; ALL: COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
97 define amdgpu_kernel void @test_workgroup_id_z(ptr addrspace(1) %out) #1 {
98 %id = call i32 @llvm.amdgcn.workgroup.id.z()
99 store i32 %id, ptr addrspace(1) %out
103 attributes #0 = { nounwind readnone }
104 attributes #1 = { nounwind }
106 !llvm.module.flags = !{!0}
107 !0 = !{i32 1, !"amdgpu_code_object_version", i32 400}