1 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx803 < %s | FileCheck --check-prefixes=ALL-ASM,OSABI-AMDHSA-ASM %s
2 ; RUN: llc -filetype=obj -mtriple=amdgcn-amd-amdhsa -mcpu=gfx803 < %s | llvm-readelf -S -r -s --notes - | FileCheck --check-prefix=OSABI-AMDHSA-ELF %s
4 ; ALL-ASM-LABEL: {{^}}fadd:
6 ; OSABI-AMDHSA-ASM-NOT: .hsa_code_object_version
7 ; OSABI-AMDHSA-ASM-NOT: .hsa_code_object_isa
8 ; OSABI-AMDHSA-ASM-NOT: .amdgpu_hsa_kernel
9 ; OSABI-AMDHSA-ASM-NOT: .amd_kernel_code_t
11 ; OSABI-AMDHSA-ASM: s_endpgm
12 ; OSABI-AMDHSA-ASM: .section .rodata,#alloc
13 ; OSABI-AMDHSA-ASM: .p2align 6
14 ; OSABI-AMDHSA-ASM: .amdhsa_kernel fadd
15 ; OSABI-AMDHSA-ASM: .amdhsa_user_sgpr_count 6
16 ; OSABI-AMDHSA-ASM: .amdhsa_user_sgpr_private_segment_buffer 1
17 ; OSABI-AMDHSA-ASM: .amdhsa_user_sgpr_kernarg_segment_ptr 1
18 ; OSABI-AMDHSA-ASM: .amdhsa_next_free_vgpr 3
19 ; OSABI-AMDHSA-ASM: .amdhsa_next_free_sgpr 8
20 ; OSABI-AMDHSA-ASM: .amdhsa_reserve_vcc 0
21 ; OSABI-AMDHSA-ASM: .amdhsa_reserve_flat_scratch 0
22 ; OSABI-AMDHSA-ASM: .end_amdhsa_kernel
23 ; OSABI-AMDHSA-ASM: .text
25 ; ALL-ASM-LABEL: {{^}}fsub:
27 ; OSABI-AMDHSA-ASM-NOT: .amdgpu_hsa_kernel
28 ; OSABI-AMDHSA-ASM-NOT: .amd_kernel_code_t
30 ; OSABI-AMDHSA-ASM: s_endpgm
31 ; OSABI-AMDHSA-ASM: .section .rodata,#alloc
32 ; OSABI-AMDHSA-ASM: .p2align 6
33 ; OSABI-AMDHSA-ASM: .amdhsa_kernel fsub
34 ; OSABI-AMDHSA-ASM: .amdhsa_user_sgpr_count 6
35 ; OSABI-AMDHSA-ASM: .amdhsa_user_sgpr_private_segment_buffer 1
36 ; OSABI-AMDHSA-ASM: .amdhsa_user_sgpr_kernarg_segment_ptr 1
37 ; OSABI-AMDHSA-ASM: .amdhsa_next_free_vgpr 3
38 ; OSABI-AMDHSA-ASM: .amdhsa_next_free_sgpr 8
39 ; OSABI-AMDHSA-ASM: .amdhsa_reserve_vcc 0
40 ; OSABI-AMDHSA-ASM: .amdhsa_reserve_flat_scratch 0
41 ; OSABI-AMDHSA-ASM: .end_amdhsa_kernel
42 ; OSABI-AMDHSA-ASM: .text
44 ; OSABI-AMDHSA-ASM-NOT: .hsa_code_object_version
45 ; OSABI-AMDHSA-ASM-NOT: .hsa_code_object_isa
46 ; OSABI-AMDHSA-ASM-NOT: .amd_amdgpu_isa
47 ; OSABI-AMDHSA-ASM-NOT: .amd_amdgpu_hsa_metadata
48 ; OSABI-AMDHSA-ASM-NOT: .amd_amdgpu_pal_metadata
50 ; OSABI-AMDHSA-ELF: Section Headers
51 ; OSABI-AMDHSA-ELF: .text PROGBITS {{[0-9]+}} {{[0-9]+}} {{[0-9a-f]+}} {{[0-9]+}} AX {{[0-9]+}} {{[0-9]+}} 256
52 ; OSABI-AMDHSA-ELF: .rodata PROGBITS {{[0-9]+}} {{[0-9]+}} {{[0-9a-f]+}} {{[0-9]+}} A {{[0-9]+}} {{[0-9]+}} 64
54 ; OSABI-AMDHSA-ELF: Relocation section '.rela.rodata' at offset
55 ; OSABI-AMDHSA-ELF: R_AMDGPU_REL64 0000000000000000 fadd + 10
56 ; OSABI-AMDHSA-ELF: R_AMDGPU_REL64 0000000000000100 fsub + 10
57 ; OSABI-AMDHSA-ELF: R_AMDGPU_REL64 0000000000000200 empty + 10
59 ; OSABI-AMDHSA-ELF: Symbol table '.symtab' contains {{[0-9]+}} entries
60 ; OSABI-AMDHSA-ELF: {{[0-9]+}}: 0000000000000000 {{[0-9]+}} FUNC GLOBAL PROTECTED {{[0-9]+}} fadd
61 ; OSABI-AMDHSA-ELF: {{[0-9]+}}: 0000000000000000 64 OBJECT GLOBAL DEFAULT {{[0-9]+}} fadd.kd
62 ; OSABI-AMDHSA-ELF: {{[0-9]+}}: 0000000000000100 {{[0-9]+}} FUNC GLOBAL PROTECTED {{[0-9]+}} fsub
63 ; OSABI-AMDHSA-ELF: {{[0-9]+}}: 0000000000000040 64 OBJECT GLOBAL DEFAULT {{[0-9]+}} fsub.kd
65 ; OSABI-AMDHSA-ELF: Displaying notes found in: .note
66 ; OSABI-AMDHSA-ELF: AMDGPU 0x{{[0-9a-f]+}} NT_AMDGPU_METADATA (AMDGPU Metadata)
68 define amdgpu_kernel void @fadd(
71 ptr addrspace(1) %b) {
73 %a.val = load float, ptr addrspace(1) %a
74 %b.val = load float, ptr addrspace(1) %b
75 %r.val = fadd float %a.val, %b.val
76 store float %r.val, ptr addrspace(1) %r
80 define amdgpu_kernel void @fsub(
83 ptr addrspace(1) %b) {
85 %a.val = load float, ptr addrspace(1) %a
86 %b.val = load float, ptr addrspace(1) %b
87 %r.val = fsub float %a.val, %b.val
88 store float %r.val, ptr addrspace(1) %r
92 ; Make sure kernel arguments do not count towards the number of
95 ; ALL-ASM-LABEL: {{^}}empty:
96 ; ALL-ASM: .amdhsa_next_free_vgpr 1
97 ; ALL-ASM: .amdhsa_next_free_sgpr 1
98 define amdgpu_kernel void @empty(
102 ptr addrspace(1) %b) {