1; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx803 -mattr=+code-object-v3 < %s | FileCheck --check-prefixes=ALL-ASM,OSABI-AMDHSA-ASM %s
2; RUN: llc -filetype=obj -mtriple=amdgcn-amd-amdhsa -mcpu=gfx803 -mattr=+code-object-v3 < %s | llvm-readobj -elf-output-style=GNU -notes -relocations -sections -symbols | FileCheck --check-prefixes=ALL-ELF,OSABI-AMDHSA-ELF %s
3
4; ALL-ASM-LABEL: {{^}}fadd:
5; OSABI-AMDHSA-ASM: s_endpgm
6; OSABI-AMDHSA-ASM: .section .rodata,#alloc
7; OSABI-AMDHSA-ASM: .p2align 6
8; OSABI-AMDHSA-ASM: .amdhsa_kernel fadd
9; OSABI-AMDHSA-ASM:     .amdhsa_user_sgpr_private_segment_buffer 1
10; OSABI-AMDHSA-ASM:     .amdhsa_user_sgpr_kernarg_segment_ptr 1
11; OSABI-AMDHSA-ASM:     .amdhsa_next_free_vgpr 3
12; OSABI-AMDHSA-ASM:     .amdhsa_next_free_sgpr 8
13; OSABI-AMDHSA-ASM:     .amdhsa_reserve_vcc 0
14; OSABI-AMDHSA-ASM:     .amdhsa_reserve_flat_scratch 0
15; OSABI-AMDHSA-ASM: .end_amdhsa_kernel
16; OSABI-AMDHSA-ASM: .text
17
18; ALL-ASM-LABEL: {{^}}fsub:
19; OSABI-AMDHSA-ASM: s_endpgm
20; OSABI-AMDHSA-ASM: .section .rodata,#alloc
21; OSABI-AMDHSA-ASM: .p2align 6
22; OSABI-AMDHSA-ASM: .amdhsa_kernel fsub
23; OSABI-AMDHSA-ASM:     .amdhsa_user_sgpr_private_segment_buffer 1
24; OSABI-AMDHSA-ASM:     .amdhsa_user_sgpr_kernarg_segment_ptr 1
25; OSABI-AMDHSA-ASM:     .amdhsa_next_free_vgpr 3
26; OSABI-AMDHSA-ASM:     .amdhsa_next_free_sgpr 8
27; OSABI-AMDHSA-ASM:     .amdhsa_reserve_vcc 0
28; OSABI-AMDHSA-ASM:     .amdhsa_reserve_flat_scratch 0
29; OSABI-AMDHSA-ASM: .end_amdhsa_kernel
30; OSABI-AMDHSA-ASM: .text
31
32; OSABI-AMDHSA-ASM-NOT: .hsa_code_object_version
33; OSABI-AMDHSA-ASM-NOT: .hsa_code_object_isa
34; OSABI-AMDHSA-ASM-NOT: .amd_amdgpu_isa
35; OSABI-AMDHSA-ASM-NOT: .amd_amdgpu_hsa_metadata
36; OSABI-AMDHSA-ASM-NOT: .amd_amdgpu_pal_metadata
37
38; OSABI-AMDHSA-ELF: Section Headers
39; OSABI-AMDHSA-ELF: .text   PROGBITS {{[0-9]+}} {{[0-9]+}} {{[0-9a-f]+}} {{[0-9]+}} AX {{[0-9]+}} {{[0-9]+}} 256
40; OSABI-AMDHSA-ELF: .rodata PROGBITS {{[0-9]+}} {{[0-9]+}} {{[0-9a-f]+}} {{[0-9]+}}  A {{[0-9]+}} {{[0-9]+}} 64
41
42; OSABI-AMDHSA-ELF: Relocation section '.rela.rodata' at offset
43; OSABI-AMDHSA-ELF: 0000000000000010 0000000300000005 R_AMDGPU_REL64 0000000000000000 .text + 10
44; OSABI-AMDHSA-ELF: 0000000000000050 0000000300000005 R_AMDGPU_REL64 0000000000000000 .text + 110
45
46; OSABI-AMDHSA-ELF: Symbol table '.symtab' contains {{[0-9]+}} entries
47; OSABI-AMDHSA-ELF: {{[0-9]+}}: 0000000000000000 {{[0-9]+}} FUNC   LOCAL  DEFAULT {{[0-9]+}} fadd
48; OSABI-AMDHSA-ELF: {{[0-9]+}}: 0000000000000100 {{[0-9]+}} FUNC   LOCAL  DEFAULT {{[0-9]+}} fsub
49; OSABI-AMDHSA-ELF: {{[0-9]+}}: 0000000000000000 64         OBJECT GLOBAL DEFAULT {{[0-9]+}} fadd.kd
50; OSABI-AMDHSA-ELF: {{[0-9]+}}: 0000000000000040 64         OBJECT GLOBAL DEFAULT {{[0-9]+}} fsub.kd
51
52; OSABI-AMDHSA-ELF-NOT: Displaying notes found
53
54define amdgpu_kernel void @fadd(
55    float addrspace(1)* %r,
56    float addrspace(1)* %a,
57    float addrspace(1)* %b) {
58entry:
59  %a.val = load float, float addrspace(1)* %a
60  %b.val = load float, float addrspace(1)* %b
61  %r.val = fadd float %a.val, %b.val
62  store float %r.val, float addrspace(1)* %r
63  ret void
64}
65
66define amdgpu_kernel void @fsub(
67    float addrspace(1)* %r,
68    float addrspace(1)* %a,
69    float addrspace(1)* %b) {
70entry:
71  %a.val = load float, float addrspace(1)* %a
72  %b.val = load float, float addrspace(1)* %b
73  %r.val = fsub float %a.val, %b.val
74  store float %r.val, float addrspace(1)* %r
75  ret void
76}
77