1 ; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri --amdhsa-code-object-version=2 -mattr=+flat-for-global < %s | FileCheck -check-prefix=HSA -check-prefix=HSA-DEFAULT -check-prefix=ALL %s
2 ; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri --amdhsa-code-object-version=2 -mattr=-flat-for-global < %s | FileCheck -check-prefix=HSA -check-prefix=HSA-NODEFAULT -check-prefix=ALL %s
3 ; RUN: llc -mtriple=amdgcn-- -mcpu=tonga < %s | FileCheck -check-prefix=HSA-NOADDR64 -check-prefix=ALL %s
4 ; RUN: llc -mtriple=amdgcn-- -mcpu=kaveri -mattr=-flat-for-global < %s | FileCheck -check-prefix=NOHSA-DEFAULT -check-prefix=ALL %s
5 ; RUN: llc -mtriple=amdgcn-- -mcpu=kaveri -mattr=+flat-for-global < %s | FileCheck -check-prefix=NOHSA-NODEFAULT -check-prefix=ALL %s
6 ; RUN: llc -mtriple=amdgcn-- -mcpu=tonga < %s | FileCheck -check-prefix=NOHSA-NOADDR64 -check-prefix=ALL %s
9 ; There are no stack objects even though flat is used by default, so
10 ; flat_scratch_init should be disabled.
12 ; ALL-LABEL: {{^}}test:
13 ; HSA: .amd_kernel_code_t
14 ; HSA: enable_sgpr_flat_scratch_init = 0
15 ; HSA: .end_amd_kernel_code_t
19 ; HSA-DEFAULT: flat_store_dword
20 ; HSA-NODEFAULT: buffer_store_dword
21 ; HSA-NOADDR64: flat_store_dword
23 ; NOHSA-DEFAULT: buffer_store_dword
24 ; NOHSA-NODEFAULT: flat_store_dword
25 ; NOHSA-NOADDR64: flat_store_dword
26 define amdgpu_kernel void @test(i32 addrspace(1)* %out) {
28 store i32 0, i32 addrspace(1)* %out
32 ; HSA-DEFAULT: flat_store_dword
33 ; HSA-NODEFAULT: buffer_store_dword
34 ; HSA-NOADDR64: flat_store_dword
36 ; NOHSA-DEFAULT: buffer_store_dword
37 ; NOHSA-NODEFAULT: flat_store_dword
38 ; NOHSA-NOADDR64: flat_store_dword
39 define amdgpu_kernel void @test_addr64(i32 addrspace(1)* %out) {
41 %out.addr = alloca i32 addrspace(1)*, align 4, addrspace(5)
43 store i32 addrspace(1)* %out, i32 addrspace(1)* addrspace(5)* %out.addr, align 4
44 %ld0 = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(5)* %out.addr, align 4
46 %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %ld0, i32 0
47 store i32 1, i32 addrspace(1)* %arrayidx, align 4
49 %ld1 = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(5)* %out.addr, align 4
50 %arrayidx1 = getelementptr inbounds i32, i32 addrspace(1)* %ld1, i32 1
51 store i32 2, i32 addrspace(1)* %arrayidx1, align 4