1; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=GCN -check-prefix=SI-NOHSA -check-prefix=GCN-NOHSA -check-prefix=FUNC %s 2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=VI -check-prefix=VI-NOHSA -check-prefix=GCN -check-prefix=GCN-NOHSA -check-prefix=FUNC %s 3 4 5; FUNC-LABEL: {{^}}workdim: 6 7; SI-NOHSA: s_load_dword [[VAL:s[0-9]+]], s[0:1], 0xb 8; VI-NOHSA: s_load_dword [[VAL:s[0-9]+]], s[0:1], 0x2c 9; GCN-NOHSA: v_mov_b32_e32 [[VVAL:v[0-9]+]], [[VAL]] 10; GCN-NOHSA: buffer_store_dword [[VVAL]] 11 12define void @workdim (i32 addrspace(1)* %out) { 13entry: 14 %0 = call i32 @llvm.amdgcn.read.workdim() #0 15 store i32 %0, i32 addrspace(1)* %out 16 ret void 17} 18 19; The workgroup.id values are stored in sgprs offset by the number of user 20; sgprs. 21 22; FUNC-LABEL: {{^}}workgroup_id_x: 23; GCN-NOHSA: v_mov_b32_e32 [[VVAL:v[0-9]+]], s2{{$}} 24; GCN-NOHSA: buffer_store_dword [[VVAL]] 25 26; GCN-NOHSA: COMPUTE_PGM_RSRC2:USER_SGPR: 2 27; GCN: COMPUTE_PGM_RSRC2:TGID_X_EN: 1 28; GCN: COMPUTE_PGM_RSRC2:TGID_Y_EN: 0 29; GCN: COMPUTE_PGM_RSRC2:TGID_Z_EN: 0 30; GCN: COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0 31define void @workgroup_id_x(i32 addrspace(1)* %out) { 32entry: 33 %0 = call i32 @llvm.amdgcn.workgroup.id.x() #0 34 store i32 %0, i32 addrspace(1)* %out 35 ret void 36} 37 38; FUNC-LABEL: {{^}}workgroup_id_y: 39; GCN-NOHSA: v_mov_b32_e32 [[VVAL:v[0-9]+]], s3 40; GCN-NOHSA: buffer_store_dword [[VVAL]] 41 42; GCN-NOHSA: COMPUTE_PGM_RSRC2:USER_SGPR: 2 43define void @workgroup_id_y(i32 addrspace(1)* %out) { 44entry: 45 %0 = call i32 @llvm.amdgcn.workgroup.id.y() #0 46 store i32 %0, i32 addrspace(1)* %out 47 ret void 48} 49 50; FUNC-LABEL: {{^}}workgroup_id_z: 51; GCN-NOHSA: v_mov_b32_e32 [[VVAL:v[0-9]+]], s3{{$}} 52; GCN-NOHSA: buffer_store_dword [[VVAL]] 53 54; GCN-NOHSA: COMPUTE_PGM_RSRC2:USER_SGPR: 2 55; GCN: COMPUTE_PGM_RSRC2:TGID_X_EN: 1 56; GCN: COMPUTE_PGM_RSRC2:TGID_Y_EN: 0 57; GCN: COMPUTE_PGM_RSRC2:TGID_Z_EN: 1 58; GCN: COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0 59define void @workgroup_id_z(i32 addrspace(1)* %out) { 60entry: 61 %0 = call i32 @llvm.amdgcn.workgroup.id.z() #0 62 store i32 %0, i32 addrspace(1)* %out 63 ret void 64} 65 66; GCN-NOHSA: .section .AMDGPU.config 67; GCN-NOHSA: .long 47180 68; GCN-NOHSA-NEXT: .long 132{{$}} 69 70; FUNC-LABEL: {{^}}workitem_id_x: 71; GCN-NOHSA: buffer_store_dword v0 72define void @workitem_id_x(i32 addrspace(1)* %out) { 73entry: 74 %0 = call i32 @llvm.amdgcn.workitem.id.x() #0 75 store i32 %0, i32 addrspace(1)* %out 76 ret void 77} 78 79; GCN-NOHSA: .section .AMDGPU.config 80; GCN-NOHSA: .long 47180 81; GCN-NOHSA-NEXT: .long 2180{{$}} 82 83; FUNC-LABEL: {{^}}workitem_id_y: 84 85; GCN-NOHSA: buffer_store_dword v1 86define void @workitem_id_y(i32 addrspace(1)* %out) { 87entry: 88 %0 = call i32 @llvm.amdgcn.workitem.id.y() #0 89 store i32 %0, i32 addrspace(1)* %out 90 ret void 91} 92 93; GCN-NOHSA: .section .AMDGPU.config 94; GCN-NOHSA: .long 47180 95; GCN-NOHSA-NEXT: .long 4228{{$}} 96 97; FUNC-LABEL: {{^}}workitem_id_z: 98; GCN-NOHSA: buffer_store_dword v2 99define void @workitem_id_z(i32 addrspace(1)* %out) { 100entry: 101 %0 = call i32 @llvm.amdgcn.workitem.id.z() #0 102 store i32 %0, i32 addrspace(1)* %out 103 ret void 104} 105 106declare i32 @llvm.amdgcn.workgroup.id.x() #0 107declare i32 @llvm.amdgcn.workgroup.id.y() #0 108declare i32 @llvm.amdgcn.workgroup.id.z() #0 109 110declare i32 @llvm.amdgcn.workitem.id.x() #0 111declare i32 @llvm.amdgcn.workitem.id.y() #0 112declare i32 @llvm.amdgcn.workitem.id.z() #0 113 114declare i32 @llvm.amdgcn.read.workdim() #0 115