1 ; RUN: opt -mtriple=amdgcn-amd-amdhsa -mcpu=fiji -passes=amdgpu-attributor < %s | llc -global-isel -mtriple=amdgcn-amd-amdhsa -mcpu=fiji -amdgpu-ir-lower-kernel-arguments=0 -stop-after=irtranslator -o - | FileCheck -check-prefix=HSA %s
3 ; HSA-LABEL: name: default_kernel
5 ; HSA-NEXT: - { reg: '$sgpr0_sgpr1_sgpr2_sgpr3', virtual-reg: '%0' }
6 ; HSA-NEXT: - { reg: '$vgpr0', virtual-reg: '%1' }
7 ; HSA-NEXT: - { reg: '$sgpr4', virtual-reg: '%2' }
8 ; HSA-NEXT: - { reg: '$sgpr5', virtual-reg: '%3' }
10 define amdgpu_kernel void @default_kernel() {
15 ; HSA-LABEL: name: workgroup_id_x{{$}}
17 ; HSA-NEXT: - { reg: '$sgpr0_sgpr1_sgpr2_sgpr3', virtual-reg: '%0' }
18 ; HSA-NEXT: - { reg: '$vgpr0', virtual-reg: '%1' }
19 ; HSA-NEXT: - { reg: '$sgpr4', virtual-reg: '%2' }
20 ; HSA-NEXT: - { reg: '$sgpr5', virtual-reg: '%3' }
21 ; HSA-NEXT: frameInfo:
22 define amdgpu_kernel void @workgroup_id_x() {
23 %id = call i32 @llvm.amdgcn.workgroup.id.x()
24 store volatile i32 %id, ptr addrspace(1) undef
28 ; HSA-LABEL: name: workgroup_id_y{{$}}
30 ; HSA-NEXT: - { reg: '$sgpr0_sgpr1_sgpr2_sgpr3', virtual-reg: '%0' }
31 ; HSA-NEXT: - { reg: '$vgpr0', virtual-reg: '%1' }
32 ; HSA-NEXT: - { reg: '$sgpr4', virtual-reg: '%2' }
33 ; HSA-NEXT: - { reg: '$sgpr5', virtual-reg: '%3' }
34 ; HSA-NEXT: - { reg: '$sgpr6', virtual-reg: '%4' }
35 ; HSA-NEXT: frameInfo:
36 define amdgpu_kernel void @workgroup_id_y() {
37 %id = call i32 @llvm.amdgcn.workgroup.id.y()
38 store volatile i32 %id, ptr addrspace(1) undef
42 ; HSA-LABEL: name: workgroup_id_z{{$}}
44 ; HSA-NEXT: - { reg: '$sgpr0_sgpr1_sgpr2_sgpr3', virtual-reg: '%0' }
45 ; HSA-NEXT: - { reg: '$vgpr0', virtual-reg: '%1' }
46 ; HSA-NEXT: - { reg: '$sgpr4', virtual-reg: '%2' }
47 ; HSA-NEXT: - { reg: '$sgpr5', virtual-reg: '%3' }
48 ; HSA-NEXT: - { reg: '$sgpr6', virtual-reg: '%4' }
49 ; HSA-NEXT: frameInfo:
50 define amdgpu_kernel void @workgroup_id_z() {
51 %id = call i32 @llvm.amdgcn.workgroup.id.z()
52 store volatile i32 %id, ptr addrspace(1) undef
56 ; HSA-LABEL: name: workgroup_id_xy{{$}}
58 ; HSA-NEXT: - { reg: '$sgpr0_sgpr1_sgpr2_sgpr3', virtual-reg: '%0' }
59 ; HSA-NEXT: - { reg: '$vgpr0', virtual-reg: '%1' }
60 ; HSA-NEXT: - { reg: '$sgpr4', virtual-reg: '%2' }
61 ; HSA-NEXT: - { reg: '$sgpr5', virtual-reg: '%3' }
62 ; HSA-NEXT: - { reg: '$sgpr6', virtual-reg: '%4' }
63 ; HSA-NEXT: frameInfo:
64 define amdgpu_kernel void @workgroup_id_xy() {
65 %id0 = call i32 @llvm.amdgcn.workgroup.id.x()
66 store volatile i32 %id0, ptr addrspace(1) undef
67 %id1 = call i32 @llvm.amdgcn.workgroup.id.y()
68 store volatile i32 %id1, ptr addrspace(1) undef
72 ; HSA-LABEL: name: workgroup_id_xyz{{$}}
74 ; HSA-NEXT: - { reg: '$sgpr0_sgpr1_sgpr2_sgpr3', virtual-reg: '%0' }
75 ; HSA-NEXT: - { reg: '$vgpr0', virtual-reg: '%1' }
76 ; HSA-NEXT: - { reg: '$sgpr4', virtual-reg: '%2' }
77 ; HSA-NEXT: - { reg: '$sgpr5', virtual-reg: '%3' }
78 ; HSA-NEXT: - { reg: '$sgpr6', virtual-reg: '%4' }
79 ; HSA-NEXT: frameInfo:
80 define amdgpu_kernel void @workgroup_id_xyz() {
81 %id0 = call i32 @llvm.amdgcn.workgroup.id.x()
82 store volatile i32 %id0, ptr addrspace(1) undef
83 %id1 = call i32 @llvm.amdgcn.workgroup.id.y()
84 store volatile i32 %id1, ptr addrspace(1) undef
85 %id2 = call i32 @llvm.amdgcn.workgroup.id.y()
86 store volatile i32 %id2, ptr addrspace(1) undef
90 ; HSA-LABEL: name: workgroup_id_yz{{$}}
92 ; HSA-NEXT: - { reg: '$sgpr0_sgpr1_sgpr2_sgpr3', virtual-reg: '%0' }
93 ; HSA-NEXT: - { reg: '$vgpr0', virtual-reg: '%1' }
94 ; HSA-NEXT: - { reg: '$sgpr4', virtual-reg: '%2' }
95 ; HSA-NEXT: - { reg: '$sgpr5', virtual-reg: '%3' }
96 ; HSA-NEXT: - { reg: '$sgpr6', virtual-reg: '%4' }
97 ; HSA-NEXT: frameInfo:
98 define amdgpu_kernel void @workgroup_id_yz() {
99 %id0 = call i32 @llvm.amdgcn.workgroup.id.x()
100 store volatile i32 %id0, ptr addrspace(1) undef
101 %id1 = call i32 @llvm.amdgcn.workgroup.id.y()
102 store volatile i32 %id1, ptr addrspace(1) undef
106 ; HSA-LABEL: name: workgroup_id_xz{{$}}
108 ; HSA-NEXT: - { reg: '$sgpr0_sgpr1_sgpr2_sgpr3', virtual-reg: '%0' }
109 ; HSA-NEXT: - { reg: '$vgpr0', virtual-reg: '%1' }
110 ; HSA-NEXT: - { reg: '$sgpr4', virtual-reg: '%2' }
111 ; HSA-NEXT: - { reg: '$sgpr5', virtual-reg: '%3' }
112 ; HSA-NEXT: - { reg: '$sgpr6', virtual-reg: '%4' }
113 ; HSA-NEXT: frameInfo:
114 define amdgpu_kernel void @workgroup_id_xz() {
115 %id0 = call i32 @llvm.amdgcn.workgroup.id.x()
116 store volatile i32 %id0, ptr addrspace(1) undef
117 %id1 = call i32 @llvm.amdgcn.workgroup.id.z()
118 store volatile i32 %id1, ptr addrspace(1) undef
122 declare i32 @llvm.amdgcn.workgroup.id.x() #0
123 declare i32 @llvm.amdgcn.workgroup.id.y() #0
124 declare i32 @llvm.amdgcn.workgroup.id.z() #0
126 attributes #0 = { nounwind readnone speculatable }