1; RUN: llc -march=amdgcn -mtriple=amdgcn-unknown-amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=ALL -check-prefix=CO-V2 -check-prefix=CI-HSA  %s
2; RUN: llc -march=amdgcn -mtriple=amdgcn-unknown-amdhsa -mcpu=carrizo -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=ALL -check-prefix=CO-V2 -check-prefix=VI-HSA  %s
3; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefix=ALL -check-prefix=MESA -check-prefix=SI-MESA %s
4; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=ALL -check-prefix=MESA -check-prefix=VI-MESA %s
5; RUN: llc -mtriple=amdgcn-unknown-mesa3d -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefixes=ALL,CO-V2,SI-MESA %s
6; RUN: llc -mtriple=amdgcn-unknown-mesa3d -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefixes=ALL,CO-V2,VI-MESA %s
7
8declare i32 @llvm.amdgcn.workitem.id.x() #0
9declare i32 @llvm.amdgcn.workitem.id.y() #0
10declare i32 @llvm.amdgcn.workitem.id.z() #0
11
12; MESA: .section .AMDGPU.config
13; MESA: .long 47180
14; MESA-NEXT: .long 132{{$}}
15
16; ALL-LABEL {{^}}test_workitem_id_x:
17; CO-V2: enable_vgpr_workitem_id = 0
18
19; ALL-NOT: v0
20; ALL: {{buffer|flat}}_store_dword {{.*}}v0
21define amdgpu_kernel void @test_workitem_id_x(i32 addrspace(1)* %out) #1 {
22  %id = call i32 @llvm.amdgcn.workitem.id.x()
23  store i32 %id, i32 addrspace(1)* %out
24  ret void
25}
26
27; MESA: .section .AMDGPU.config
28; MESA: .long 47180
29; MESA-NEXT: .long 2180{{$}}
30
31; ALL-LABEL {{^}}test_workitem_id_y:
32; CO-V2: enable_vgpr_workitem_id = 1
33
34; ALL-NOT: v1
35; ALL: {{buffer|flat}}_store_dword {{.*}}v1
36define amdgpu_kernel void @test_workitem_id_y(i32 addrspace(1)* %out) #1 {
37  %id = call i32 @llvm.amdgcn.workitem.id.y()
38  store i32 %id, i32 addrspace(1)* %out
39  ret void
40}
41
42; MESA: .section .AMDGPU.config
43; MESA: .long 47180
44; MESA-NEXT: .long 4228{{$}}
45
46; ALL-LABEL {{^}}test_workitem_id_z:
47; CO-V2: enable_vgpr_workitem_id = 2
48
49; ALL-NOT: v2
50; ALL: {{buffer|flat}}_store_dword {{.*}}v2
51define amdgpu_kernel void @test_workitem_id_z(i32 addrspace(1)* %out) #1 {
52  %id = call i32 @llvm.amdgcn.workitem.id.z()
53  store i32 %id, i32 addrspace(1)* %out
54  ret void
55}
56
57attributes #0 = { nounwind readnone }
58attributes #1 = { nounwind }
59