1// RUN: llvm-mc -triple amdgcn--amdhsa -mcpu=kaveri -show-encoding %s | FileCheck %s --check-prefix=ASM
2// RUN: llvm-mc -filetype=obj -triple amdgcn--amdhsa -mcpu=kaveri -show-encoding %s | llvm-readobj -symbols -s -sd | FileCheck %s --check-prefix=ELF
3
4// ELF: Section {
5// ELF: Name: .hsatext
6// ELF: Type: SHT_PROGBITS (0x1)
7// ELF: Flags [ (0xC00007)
8// ELF: SHF_ALLOC (0x2)
9// ELF: SHF_AMDGPU_HSA_AGENT (0x800000)
10// ELF: SHF_AMDGPU_HSA_CODE (0x400000)
11// ELF: SHF_EXECINSTR (0x4)
12// ELF: SHF_WRITE (0x1)
13
14// ELF: SHT_NOTE
15// ELF: 0000: 04000000 08000000 01000000 414D4400
16// ELF: 0010: 01000000 00000000 04000000 1B000000
17// ELF: 0020: 03000000 414D4400 04000700 07000000
18// ELF: 0030: 00000000 00000000 414D4400 414D4447
19// ELF: 0040: 50550000
20
21// ELF: Symbol {
22// ELF: Name: amd_kernel_code_t_minimal
23// ELF: Type: AMDGPU_HSA_KERNEL (0xA)
24// ELF: Section: .hsatext
25// ELF: }
26// ELF: Symbol {
27// ELF: Name: amd_kernel_code_t_test_all
28// ELF: Type: AMDGPU_HSA_KERNEL (0xA)
29// ELF: Section: .hsatext
30// ELF: }
31
32
33.hsa_code_object_version 1,0
34// ASM: .hsa_code_object_version 1,0
35
36.hsa_code_object_isa 7,0,0,"AMD","AMDGPU"
37// ASM: .hsa_code_object_isa 7,0,0,"AMD","AMDGPU"
38
39.amdgpu_hsa_kernel amd_kernel_code_t_test_all
40.amdgpu_hsa_kernel amd_kernel_code_t_minimal
41
42.hsatext
43// ASM: .hsatext
44
45amd_kernel_code_t_test_all:
46; Test all amd_kernel_code_t members with non-default values.
47.amd_kernel_code_t
48	kernel_code_version_major = 100
49	kernel_code_version_minor = 100
50	machine_kind = 0
51	machine_version_major = 5
52	machine_version_minor = 5
53	machine_version_stepping = 5
54	kernel_code_entry_byte_offset = 512
55	kernel_code_prefetch_byte_size = 1
56	max_scratch_backing_memory_byte_size = 1
57	compute_pgm_rsrc1_vgprs = 1
58	compute_pgm_rsrc1_sgprs = 1
59	compute_pgm_rsrc1_priority = 1
60	compute_pgm_rsrc1_float_mode = 1
61	compute_pgm_rsrc1_priv = 1
62	compute_pgm_rsrc1_dx10_clamp = 1
63	compute_pgm_rsrc1_debug_mode = 1
64	compute_pgm_rsrc1_ieee_mode = 1
65	compute_pgm_rsrc2_scratch_en = 1
66	compute_pgm_rsrc2_user_sgpr = 1
67	compute_pgm_rsrc2_tgid_x_en = 1
68	compute_pgm_rsrc2_tgid_y_en = 1
69	compute_pgm_rsrc2_tgid_z_en = 1
70	compute_pgm_rsrc2_tg_size_en = 1
71	compute_pgm_rsrc2_tidig_comp_cnt = 1
72	compute_pgm_rsrc2_excp_en_msb = 1
73	compute_pgm_rsrc2_lds_size = 1
74	compute_pgm_rsrc2_excp_en = 1
75	enable_sgpr_private_segment_buffer = 1
76	enable_sgpr_dispatch_ptr = 1
77	enable_sgpr_queue_ptr = 1
78	enable_sgpr_kernarg_segment_ptr = 1
79	enable_sgpr_dispatch_id = 1
80	enable_sgpr_flat_scratch_init = 1
81	enable_sgpr_private_segment_size = 1
82	enable_sgpr_grid_workgroup_count_x = 1
83	enable_sgpr_grid_workgroup_count_y = 1
84	enable_sgpr_grid_workgroup_count_z = 1
85	enable_ordered_append_gds = 1
86	private_element_size = 1
87	is_ptr64 = 1
88	is_dynamic_callstack = 1
89	is_debug_enabled = 1
90	is_xnack_enabled = 1
91	workitem_private_segment_byte_size = 1
92	workgroup_group_segment_byte_size = 1
93	gds_segment_byte_size = 1
94	kernarg_segment_byte_size = 1
95	workgroup_fbarrier_count = 1
96	wavefront_sgpr_count = 1
97	workitem_vgpr_count = 1
98	reserved_vgpr_first = 1
99	reserved_vgpr_count = 1
100	reserved_sgpr_first = 1
101	reserved_sgpr_count = 1
102	debug_wavefront_private_segment_offset_sgpr = 1
103	debug_private_segment_buffer_sgpr = 1
104	kernarg_segment_alignment = 5
105	group_segment_alignment = 5
106	private_segment_alignment = 5
107	wavefront_size = 5
108	call_convention = 1
109	runtime_loader_kernel_symbol = 1
110.end_amd_kernel_code_t
111
112// ASM-LABEL: {{^}}amd_kernel_code_t_test_all:
113// ASM: .amd_kernel_code_t
114// ASM: kernel_code_version_major = 100
115// ASM: kernel_code_version_minor = 100
116// ASM: machine_kind = 0
117// ASM: machine_version_major = 5
118// ASM: machine_version_minor = 5
119// ASM: machine_version_stepping = 5
120// ASM: kernel_code_entry_byte_offset = 512
121// ASM: kernel_code_prefetch_byte_size = 1
122// ASM: max_scratch_backing_memory_byte_size = 1
123// ASM: compute_pgm_rsrc1_vgprs = 1
124// ASM: compute_pgm_rsrc1_sgprs = 1
125// ASM: compute_pgm_rsrc1_priority = 1
126// ASM: compute_pgm_rsrc1_float_mode = 1
127// ASM: compute_pgm_rsrc1_priv = 1
128// ASM: compute_pgm_rsrc1_dx10_clamp = 1
129// ASM: compute_pgm_rsrc1_debug_mode = 1
130// ASM: compute_pgm_rsrc1_ieee_mode = 1
131// ASM: compute_pgm_rsrc2_scratch_en = 1
132// ASM: compute_pgm_rsrc2_user_sgpr = 1
133// ASM: compute_pgm_rsrc2_tgid_x_en = 1
134// ASM: compute_pgm_rsrc2_tgid_y_en = 1
135// ASM: compute_pgm_rsrc2_tgid_z_en = 1
136// ASM: compute_pgm_rsrc2_tg_size_en = 1
137// ASM: compute_pgm_rsrc2_tidig_comp_cnt = 1
138// ASM: compute_pgm_rsrc2_excp_en_msb = 1
139// ASM: compute_pgm_rsrc2_lds_size = 1
140// ASM: compute_pgm_rsrc2_excp_en = 1
141// ASM: enable_sgpr_private_segment_buffer = 1
142// ASM: enable_sgpr_dispatch_ptr = 1
143// ASM: enable_sgpr_queue_ptr = 1
144// ASM: enable_sgpr_kernarg_segment_ptr = 1
145// ASM: enable_sgpr_dispatch_id = 1
146// ASM: enable_sgpr_flat_scratch_init = 1
147// ASM: enable_sgpr_private_segment_size = 1
148// ASM: enable_sgpr_grid_workgroup_count_x = 1
149// ASM: enable_sgpr_grid_workgroup_count_y = 1
150// ASM: enable_sgpr_grid_workgroup_count_z = 1
151// ASM: enable_ordered_append_gds = 1
152// ASM: private_element_size = 1
153// ASM: is_ptr64 = 1
154// ASM: is_dynamic_callstack = 1
155// ASM: is_debug_enabled = 1
156// ASM: is_xnack_enabled = 1
157// ASM: workitem_private_segment_byte_size = 1
158// ASM: workgroup_group_segment_byte_size = 1
159// ASM: gds_segment_byte_size = 1
160// ASM: kernarg_segment_byte_size = 1
161// ASM: workgroup_fbarrier_count = 1
162// ASM: wavefront_sgpr_count = 1
163// ASM: workitem_vgpr_count = 1
164// ASM: reserved_vgpr_first = 1
165// ASM: reserved_vgpr_count = 1
166// ASM: reserved_sgpr_first = 1
167// ASM: reserved_sgpr_count = 1
168// ASM: debug_wavefront_private_segment_offset_sgpr = 1
169// ASM: debug_private_segment_buffer_sgpr = 1
170// ASM: kernarg_segment_alignment = 5
171// ASM: group_segment_alignment = 5
172// ASM: private_segment_alignment = 5
173// ASM: wavefront_size = 5
174// ASM: call_convention = 1
175// ASM: runtime_loader_kernel_symbol = 1
176// ASM: .end_amd_kernel_code_t
177
178amd_kernel_code_t_minimal:
179.amd_kernel_code_t
180	enable_sgpr_kernarg_segment_ptr = 1
181	is_ptr64 = 1
182	compute_pgm_rsrc1_vgprs = 1
183	compute_pgm_rsrc1_sgprs = 1
184	compute_pgm_rsrc2_user_sgpr = 2
185	kernarg_segment_byte_size = 16
186	wavefront_sgpr_count = 8
187//      wavefront_sgpr_count = 7
188;	wavefront_sgpr_count = 7
189// Make sure a blank line won't break anything:
190
191// Make sure a line with whitespace won't break anything:
192
193	workitem_vgpr_count = 16
194.end_amd_kernel_code_t
195
196// ASM-LABEL: {{^}}amd_kernel_code_t_minimal:
197// ASM: .amd_kernel_code_t
198// ASM:	kernel_code_version_major = 1
199// ASM:	kernel_code_version_minor = 0
200// ASM:	machine_kind = 1
201// ASM:	machine_version_major = 7
202// ASM:	machine_version_minor = 0
203// ASM:	machine_version_stepping = 0
204// ASM:	kernel_code_entry_byte_offset = 256
205// ASM:	kernel_code_prefetch_byte_size = 0
206// ASM:	max_scratch_backing_memory_byte_size = 0
207// ASM:	compute_pgm_rsrc1_vgprs = 1
208// ASM:	compute_pgm_rsrc1_sgprs = 1
209// ASM:	compute_pgm_rsrc1_priority = 0
210// ASM:	compute_pgm_rsrc1_float_mode = 0
211// ASM:	compute_pgm_rsrc1_priv = 0
212// ASM:	compute_pgm_rsrc1_dx10_clamp = 0
213// ASM:	compute_pgm_rsrc1_debug_mode = 0
214// ASM:	compute_pgm_rsrc1_ieee_mode = 0
215// ASM:	compute_pgm_rsrc2_scratch_en = 0
216// ASM:	compute_pgm_rsrc2_user_sgpr = 2
217// ASM:	compute_pgm_rsrc2_tgid_x_en = 0
218// ASM:	compute_pgm_rsrc2_tgid_y_en = 0
219// ASM:	compute_pgm_rsrc2_tgid_z_en = 0
220// ASM:	compute_pgm_rsrc2_tg_size_en = 0
221// ASM:	compute_pgm_rsrc2_tidig_comp_cnt = 0
222// ASM:	compute_pgm_rsrc2_excp_en_msb = 0
223// ASM:	compute_pgm_rsrc2_lds_size = 0
224// ASM:	compute_pgm_rsrc2_excp_en = 0
225// ASM:	enable_sgpr_private_segment_buffer = 0
226// ASM:	enable_sgpr_dispatch_ptr = 0
227// ASM:	enable_sgpr_queue_ptr = 0
228// ASM:	enable_sgpr_kernarg_segment_ptr = 1
229// ASM:	enable_sgpr_dispatch_id = 0
230// ASM:	enable_sgpr_flat_scratch_init = 0
231// ASM:	enable_sgpr_private_segment_size = 0
232// ASM:	enable_sgpr_grid_workgroup_count_x = 0
233// ASM:	enable_sgpr_grid_workgroup_count_y = 0
234// ASM:	enable_sgpr_grid_workgroup_count_z = 0
235// ASM:	enable_ordered_append_gds = 0
236// ASM:	private_element_size = 0
237// ASM:	is_ptr64 = 1
238// ASM:	is_dynamic_callstack = 0
239// ASM:	is_debug_enabled = 0
240// ASM:	is_xnack_enabled = 0
241// ASM:	workitem_private_segment_byte_size = 0
242// ASM:	workgroup_group_segment_byte_size = 0
243// ASM:	gds_segment_byte_size = 0
244// ASM:	kernarg_segment_byte_size = 16
245// ASM:	workgroup_fbarrier_count = 0
246// ASM:	wavefront_sgpr_count = 8
247// ASM:	workitem_vgpr_count = 16
248// ASM:	reserved_vgpr_first = 0
249// ASM:	reserved_vgpr_count = 0
250// ASM:	reserved_sgpr_first = 0
251// ASM:	reserved_sgpr_count = 0
252// ASM:	debug_wavefront_private_segment_offset_sgpr = 0
253// ASM:	debug_private_segment_buffer_sgpr = 0
254// ASM:	kernarg_segment_alignment = 4
255// ASM:	group_segment_alignment = 4
256// ASM:	private_segment_alignment = 4
257// ASM:	wavefront_size = 6
258// ASM:	call_convention = 0
259// ASM:	runtime_loader_kernel_symbol = 0
260// ASM: .end_amd_kernel_code_t
261