1; RUN: llc -mtriple=amdgcn--amdpal -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=PAL %s
2; RUN: llc -mtriple=amdgcn-- -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=NOPAL %s
3; RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=NOPAL %s
4; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=NOPAL %s
5; RUN: llc -mtriple=r600-- -mcpu=cypress < %s | FileCheck -check-prefix=R600 %s
6
7@private1 = private unnamed_addr addrspace(4) constant [4 x float] [float 0.0, float 1.0, float 2.0, float 3.0]
8@private2 = private unnamed_addr addrspace(4) constant [4 x float] [float 4.0, float 5.0, float 6.0, float 7.0]
9@available_externally = available_externally addrspace(4) global [256 x i32] zeroinitializer
10
11; GCN-LABEL: {{^}}private_test:
12; GCN: s_getpc_b64 s{{\[}}[[PC0_LO:[0-9]+]]:[[PC0_HI:[0-9]+]]{{\]}}
13
14; PAL OSes use fixup into .text section.
15; PAL: s_add_u32 s{{[0-9]+}}, s[[PC0_LO]], private1
16; PAL: s_addc_u32 s{{[0-9]+}}, s[[PC0_HI]], 0
17
18; Non-PAL OSes use relocations.
19; NOPAL: s_add_u32 s{{[0-9]+}}, s[[PC0_LO]], private1@rel32@lo+4
20; NOPAL: s_addc_u32 s{{[0-9]+}}, s[[PC0_HI]], private1@rel32@hi+4
21
22; GCN: s_getpc_b64 s{{\[}}[[PC1_LO:[0-9]+]]:[[PC1_HI:[0-9]+]]{{\]}}
23
24; PAL OSes use fixup into .text section.
25; PAL: s_add_u32 s{{[0-9]+}}, s[[PC1_LO]], private2
26; PAL: s_addc_u32 s{{[0-9]+}}, s[[PC1_HI]], 0
27
28; Non-PAL OSes use relocations.
29; NOPAL: s_add_u32 s{{[0-9]+}}, s[[PC1_LO]], private2@rel32@lo+4
30; NOPAL: s_addc_u32 s{{[0-9]+}}, s[[PC1_HI]], private2@rel32@hi+4
31
32; R600-LABEL: private_test
33define amdgpu_kernel void @private_test(i32 %index, float addrspace(1)* %out) {
34  %ptr = getelementptr [4 x float], [4 x float] addrspace(4) * @private1, i32 0, i32 %index
35  %val = load float, float addrspace(4)* %ptr
36  store volatile float %val, float addrspace(1)* %out
37  %ptr2 = getelementptr [4 x float], [4 x float] addrspace(4) * @private2, i32 0, i32 %index
38  %val2 = load float, float addrspace(4)* %ptr2
39  store volatile float %val2, float addrspace(1)* %out
40  ret void
41}
42
43; NOPAL-LABEL: {{^}}available_externally_test:
44; NOPAL: s_getpc_b64 s{{\[}}[[PC0_LO:[0-9]+]]:[[PC0_HI:[0-9]+]]{{\]}}
45; NOPAL: s_add_u32 s{{[0-9]+}}, s[[PC0_LO]], available_externally@gotpcrel32@lo+4
46; NOPAL: s_addc_u32 s{{[0-9]+}}, s[[PC0_HI]], available_externally@gotpcrel32@hi+4
47; R600-LABEL: available_externally_test
48define amdgpu_kernel void @available_externally_test(i32 addrspace(1)* %out) {
49  %ptr = getelementptr [256 x i32], [256 x i32] addrspace(4)* @available_externally, i32 0, i32 1
50  %val = load i32, i32 addrspace(4)* %ptr
51  store i32 %val, i32 addrspace(1)* %out
52  ret void
53}
54
55; PAL: .text
56; NOPAL: .section .rodata
57; R600: .text
58
59; GCN: private1:
60; GCN: private2:
61; R600: private1:
62; R600: private2:
63