1 // RUN
: llvm-mc
-triple amdgcn-amd-amdhsa
-mcpu
=gfx904
--amdhsa-code-object-version
=5 -mattr
=+xnack
< %s | FileCheck
--check-prefix
=ASM
%s
2 // RUN
: llvm-mc
-triple amdgcn-amd-amdhsa
-mcpu
=gfx904
--amdhsa-code-object-version
=5 -mattr
=+xnack
-filetype
=obj
< %s
> %t
3 // RUN
: llvm-readelf
-S
-r
-s
%t | FileCheck
--check-prefix
=READOBJ
%s
4 // RUN
: llvm-objdump
-s
-j
.rodata %t | FileCheck --check-prefix=OBJDUMP %s
6 // READOBJ
: Section Headers
7 // READOBJ
: .text PROGBITS {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9]+}} AX {{[0-9]+}} {{[0-9]+}} 256
8 // READOBJ
: .rodata PROGBITS {{[0-9a-f]+}} {{[0-9a-f]+}} 000100 {{[0-9]+}} A {{[0-9]+}} {{[0-9]+}} 64
10 // READOBJ
: Relocation section
'.rela.rodata' at offset
11 // READOBJ
: 0000000000000010 {{[0-9a-f
]+}}00000005 R_AMDGPU_REL64
0000000000000000 .text + 10
12 // READOBJ
: 0000000000000050 {{[0-9a-f
]+}}00000005 R_AMDGPU_REL64
0000000000000000 .text + 110
13 // READOBJ
: 0000000000000090 {{[0-9a-f
]+}}00000005 R_AMDGPU_REL64
0000000000000000 .text + 210
14 // READOBJ
: 00000000000000d0
{{[0-9a-f
]+}}00000005 R_AMDGPU_REL64
0000000000000000 .text + 310
16 // READOBJ
: Symbol table
'.symtab' contains
{{[0-9]+}} entries
:
17 // READOBJ
: 0000000000000000 0 FUNC LOCAL PROTECTED
2 minimal
18 // READOBJ-NEXT
: 0000000000000100 0 FUNC LOCAL PROTECTED
2 complete
19 // READOBJ-NEXT
: 0000000000000200 0 FUNC LOCAL PROTECTED
2 special_sgpr
20 // READOBJ-NEXT
: 0000000000000300 0 FUNC LOCAL PROTECTED
2 disabled_user_sgpr
21 // READOBJ-NEXT
: 0000000000000000 64 OBJECT LOCAL DEFAULT
3 minimal.kd
22 // READOBJ-NEXT
: 0000000000000040 64 OBJECT LOCAL DEFAULT
3 complete.kd
23 // READOBJ-NEXT
: 0000000000000080 64 OBJECT LOCAL DEFAULT
3 special_sgpr.kd
24 // READOBJ-NEXT
: 00000000000000c0
64 OBJECT LOCAL DEFAULT
3 disabled_user_sgpr.kd
26 // OBJDUMP
: Contents of section
.rodata
27 // Note
, relocation for KERNEL_CODE_ENTRY_BYTE_OFFSET is
not resolved here.
29 // OBJDUMP-NEXT
: 0000 00000000 00000000 00000000 00000000
30 // OBJDUMP-NEXT
: 0010 00000000 00000000 00000000 00000000
31 // OBJDUMP-NEXT
: 0020 00000000 00000000 00000000 00000000
32 // OBJDUMP-NEXT
: 0030 0000ac00
80000000 00000000 00000000
34 // OBJDUMP-NEXT
: 0040 01000000 01000000 08000000 00000000
35 // OBJDUMP-NEXT
: 0050 00000000 00000000 00000000 00000000
36 // OBJDUMP-NEXT
: 0060 00000000 00000000 00000000 00000000
37 // OBJDUMP-NEXT
: 0070 c2500104
1f0f007f
7f080000
00000000
39 // OBJDUMP-NEXT
: 0080 00000000 00000000 00000000 00000000
40 // OBJDUMP-NEXT
: 0090 00000000 00000000 00000000 00000000
41 // OBJDUMP-NEXT
: 00a0
00000000 00000000 00000000 00000000
42 // OBJDUMP-NEXT
: 00b0
00010000 80000000 00000000 00000000
44 // OBJDUMP-NEXT
: 00c0
00000000 00000000 00000000 00000000
45 // OBJDUMP-NEXT
: 00d0
00000000 00000000 00000000 00000000
46 // OBJDUMP-NEXT
: 00e0
00000000 00000000 00000000 00000000
47 // OBJDUMP-NEXT
: 00f0 0000ac00
80000000 00000000 00000000
52 .amdgcn_target "amdgcn-amd-amdhsa--gfx904:xnack+"
53 // ASM
: .amdgcn_target "amdgcn-amd-amdhsa--gfx904:xnack+"
56 .type minimal,@function
61 .type complete,@function
66 .type special_sgpr,@function
71 .type disabled_user_sgpr,@function
78 // Test that only specifying required directives is allowed
, and that defaulted
79 // values are omitted.
81 .amdhsa_kernel minimal
82 .amdhsa_next_free_vgpr 0
83 .amdhsa_next_free_sgpr 0
86 // ASM
: .amdhsa_kernel minimal
87 // ASM
: .amdhsa_next_free_vgpr 0
88 // ASM-NEXT
: .amdhsa_next_free_sgpr 0
89 // ASM
: .end_amdhsa_kernel
91 // Test that we can specify all available directives with non-default values.
93 .amdhsa_kernel complete
94 .amdhsa_group_segment_fixed_size 1
95 .amdhsa_private_segment_fixed_size 1
96 .amdhsa_kernarg_size 8
97 .amdhsa_user_sgpr_count 15
98 .amdhsa_user_sgpr_private_segment_buffer 1
99 .amdhsa_user_sgpr_dispatch_ptr 1
100 .amdhsa_user_sgpr_queue_ptr 1
101 .amdhsa_user_sgpr_kernarg_segment_ptr 1
102 .amdhsa_user_sgpr_dispatch_id 1
103 .amdhsa_user_sgpr_flat_scratch_init 1
104 .amdhsa_user_sgpr_private_segment_size 1
105 .amdhsa_uses_dynamic_stack 1
106 .amdhsa_system_sgpr_private_segment_wavefront_offset 1
107 .amdhsa_system_sgpr_workgroup_id_x 0
108 .amdhsa_system_sgpr_workgroup_id_y 1
109 .amdhsa_system_sgpr_workgroup_id_z 1
110 .amdhsa_system_sgpr_workgroup_info 1
111 .amdhsa_system_vgpr_workitem_id 1
112 .amdhsa_next_free_vgpr 9
113 .amdhsa_next_free_sgpr 27
114 .amdhsa_reserve_vcc 0
115 .amdhsa_reserve_flat_scratch 0
116 .amdhsa_reserve_xnack_mask 1
117 .amdhsa_float_round_mode_32 1
118 .amdhsa_float_round_mode_16_64 1
119 .amdhsa_float_denorm_mode_32 1
120 .amdhsa_float_denorm_mode_16_64 0
123 .amdhsa_fp16_overflow 1
124 .amdhsa_exception_fp_ieee_invalid_op 1
125 .amdhsa_exception_fp_denorm_src 1
126 .amdhsa_exception_fp_ieee_div_zero 1
127 .amdhsa_exception_fp_ieee_overflow 1
128 .amdhsa_exception_fp_ieee_underflow 1
129 .amdhsa_exception_fp_ieee_inexact 1
130 .amdhsa_exception_int_div_zero 1
133 // ASM
: .amdhsa_kernel complete
134 // ASM-NEXT
: .amdhsa_group_segment_fixed_size 1
135 // ASM-NEXT
: .amdhsa_private_segment_fixed_size 1
136 // ASM-NEXT
: .amdhsa_kernarg_size 8
137 // ASM-NEXT
: .amdhsa_user_sgpr_count 15
138 // ASM-NEXT
: .amdhsa_user_sgpr_private_segment_buffer 1
139 // ASM-NEXT
: .amdhsa_user_sgpr_dispatch_ptr 1
140 // ASM-NEXT
: .amdhsa_user_sgpr_queue_ptr 1
141 // ASM-NEXT
: .amdhsa_user_sgpr_kernarg_segment_ptr 1
142 // ASM-NEXT
: .amdhsa_user_sgpr_dispatch_id 1
143 // ASM-NEXT
: .amdhsa_user_sgpr_flat_scratch_init 1
144 // ASM-NEXT
: .amdhsa_user_sgpr_private_segment_size 1
145 // ASM-NEXT
: .amdhsa_uses_dynamic_stack 1
146 // ASM-NEXT
: .amdhsa_system_sgpr_private_segment_wavefront_offset 1
147 // ASM-NEXT
: .amdhsa_system_sgpr_workgroup_id_x 0
148 // ASM-NEXT
: .amdhsa_system_sgpr_workgroup_id_y 1
149 // ASM-NEXT
: .amdhsa_system_sgpr_workgroup_id_z 1
150 // ASM-NEXT
: .amdhsa_system_sgpr_workgroup_info 1
151 // ASM-NEXT
: .amdhsa_system_vgpr_workitem_id 1
152 // ASM-NEXT
: .amdhsa_next_free_vgpr 9
153 // ASM-NEXT
: .amdhsa_next_free_sgpr 27
154 // ASM-NEXT
: .amdhsa_reserve_vcc 0
155 // ASM-NEXT
: .amdhsa_reserve_flat_scratch 0
156 // ASM-NEXT
: .amdhsa_reserve_xnack_mask 1
157 // ASM-NEXT
: .amdhsa_float_round_mode_32 1
158 // ASM-NEXT
: .amdhsa_float_round_mode_16_64 1
159 // ASM-NEXT
: .amdhsa_float_denorm_mode_32 1
160 // ASM-NEXT
: .amdhsa_float_denorm_mode_16_64 0
161 // ASM-NEXT
: .amdhsa_dx10_clamp 0
162 // ASM-NEXT
: .amdhsa_ieee_mode 0
163 // ASM-NEXT
: .amdhsa_fp16_overflow 1
164 // ASM-NEXT
: .amdhsa_exception_fp_ieee_invalid_op 1
165 // ASM-NEXT
: .amdhsa_exception_fp_denorm_src 1
166 // ASM-NEXT
: .amdhsa_exception_fp_ieee_div_zero 1
167 // ASM-NEXT
: .amdhsa_exception_fp_ieee_overflow 1
168 // ASM-NEXT
: .amdhsa_exception_fp_ieee_underflow 1
169 // ASM-NEXT
: .amdhsa_exception_fp_ieee_inexact 1
170 // ASM-NEXT
: .amdhsa_exception_int_div_zero 1
171 // ASM-NEXT
: .end_amdhsa_kernel
173 // Test that we are including special SGPR usage in the granulated count.
175 .amdhsa_kernel special_sgpr
176 // Same next_free_sgpr as
"complete", but.
..
177 .amdhsa_next_free_sgpr 27
178 // ...on GFX9 this should require an additional 6 SGPRs, pushing us from
180 .amdhsa_reserve_flat_scratch 1
182 .amdhsa_reserve_vcc 0
183 .amdhsa_reserve_xnack_mask 1
185 .amdhsa_float_denorm_mode_16_64 0
188 .amdhsa_next_free_vgpr 0
191 // ASM
: .amdhsa_kernel special_sgpr
192 // ASM
: .amdhsa_next_free_vgpr 0
193 // ASM-NEXT
: .amdhsa_next_free_sgpr 27
194 // ASM-NEXT
: .amdhsa_reserve_vcc 0
195 // ASM-NEXT
: .amdhsa_reserve_xnack_mask 1
196 // ASM
: .amdhsa_float_denorm_mode_16_64 0
197 // ASM-NEXT
: .amdhsa_dx10_clamp 0
198 // ASM-NEXT
: .amdhsa_ieee_mode 0
199 // ASM
: .end_amdhsa_kernel
201 // Test that explicitly disabling user_sgpr
's does not affect the user_sgpr
202 // count, i.e. this should produce the same descriptor as minimal.
204 .amdhsa_kernel disabled_user_sgpr
205 .amdhsa_user_sgpr_private_segment_buffer 0
206 .amdhsa_next_free_vgpr 0
207 .amdhsa_next_free_sgpr 0
210 // ASM: .amdhsa_kernel disabled_user_sgpr
211 // ASM: .amdhsa_next_free_vgpr 0
212 // ASM-NEXT: .amdhsa_next_free_sgpr 0
213 // ASM: .end_amdhsa_kernel
217 .byte .amdgcn.gfx_generation_number
220 .byte .amdgcn.gfx_generation_minor
223 .byte .amdgcn.gfx_generation_stepping
226 .byte .amdgcn.next_free_vgpr
228 .byte .amdgcn.next_free_sgpr
231 v_mov_b32_e32 v7, s10
233 .byte .amdgcn.next_free_vgpr
235 .byte .amdgcn.next_free_sgpr
238 .set .amdgcn.next_free_vgpr, 0
239 .set .amdgcn.next_free_sgpr, 0
241 .byte .amdgcn.next_free_vgpr
243 .byte .amdgcn.next_free_sgpr
246 v_mov_b32_e32 v16, s3
248 .byte .amdgcn.next_free_vgpr
250 .byte .amdgcn.next_free_sgpr
260 - .name: amd_kernel_code_t_test_all
261 .symbol: amd_kernel_code_t_test_all@kd
262 .kernarg_segment_size: 8
263 .group_segment_fixed_size: 16
264 .private_segment_fixed_size: 32
265 .uses_dynamic_stack: true
266 .kernarg_segment_align: 64
270 .max_flat_workgroup_size: 256
271 - .name: amd_kernel_code_t_minimal
272 .symbol: amd_kernel_code_t_minimal@kd
273 .kernarg_segment_size: 8
274 .group_segment_fixed_size: 16
275 .private_segment_fixed_size: 32
276 .uses_dynamic_stack: true
277 .kernarg_segment_align: 64
281 .max_flat_workgroup_size: 256
284 // ASM: .amdgpu_metadata
285 // ASM: amdhsa.kernels:
286 // ASM: - .group_segment_fixed_size: 16
287 // ASM: .kernarg_segment_align: 64
288 // ASM: .kernarg_segment_size: 8
289 // ASM: .max_flat_workgroup_size: 256
290 // ASM: .name: amd_kernel_code_t_test_all
291 // ASM: .private_segment_fixed_size: 32
292 // ASM: .sgpr_count: 14
293 // ASM: .symbol: 'amd_kernel_code_t_test_all@kd
'
294 // ASM: .uses_dynamic_stack: true
295 // ASM: .vgpr_count: 40
296 // ASM: .wavefront_size: 128
297 // ASM: - .group_segment_fixed_size: 16
298 // ASM: .kernarg_segment_align: 64
299 // ASM: .kernarg_segment_size: 8
300 // ASM: .max_flat_workgroup_size: 256
301 // ASM: .name: amd_kernel_code_t_minimal
302 // ASM: .private_segment_fixed_size: 32
303 // ASM: .sgpr_count: 14
304 // ASM: .symbol: 'amd_kernel_code_t_minimal@kd
'
305 // ASM: .uses_dynamic_stack: true
306 // ASM: .vgpr_count: 40
307 // ASM: .wavefront_size: 128
308 // ASM: amdhsa.version:
311 // ASM: .end_amdgpu_metadata