|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 |
| 2 | +; RUN: llc -global-isel -new-reg-bank-select -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 < %s | FileCheck -check-prefix=GCN %s |
| 3 | + |
| 4 | +@flat = external global i32, align 4 |
| 5 | +@global = external addrspace(1) global i32, align 4 |
| 6 | +@lds = addrspace(3) global i32 poison, align 4 |
| 7 | +@constant = external addrspace(4) constant i32, align 4 |
| 8 | +@buf = external addrspace(8) global i8 |
| 9 | + |
| 10 | +define ptr @global_value_as0_external() { |
| 11 | +; GCN-LABEL: global_value_as0_external: |
| 12 | +; GCN: ; %bb.0: |
| 13 | +; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 14 | +; GCN-NEXT: s_getpc_b64 s[4:5] |
| 15 | +; GCN-NEXT: s_add_u32 s4, s4, flat@gotpcrel32@lo+4 |
| 16 | +; GCN-NEXT: s_addc_u32 s5, s5, flat@gotpcrel32@hi+12 |
| 17 | +; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0 |
| 18 | +; GCN-NEXT: s_waitcnt lgkmcnt(0) |
| 19 | +; GCN-NEXT: v_mov_b32_e32 v0, s4 |
| 20 | +; GCN-NEXT: v_mov_b32_e32 v1, s5 |
| 21 | +; GCN-NEXT: s_setpc_b64 s[30:31] |
| 22 | + ret ptr @flat |
| 23 | +} |
| 24 | + |
| 25 | +define ptr addrspace(1) @global_value_as1_external() { |
| 26 | +; GCN-LABEL: global_value_as1_external: |
| 27 | +; GCN: ; %bb.0: |
| 28 | +; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 29 | +; GCN-NEXT: s_getpc_b64 s[4:5] |
| 30 | +; GCN-NEXT: s_add_u32 s4, s4, global@gotpcrel32@lo+4 |
| 31 | +; GCN-NEXT: s_addc_u32 s5, s5, global@gotpcrel32@hi+12 |
| 32 | +; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0 |
| 33 | +; GCN-NEXT: s_waitcnt lgkmcnt(0) |
| 34 | +; GCN-NEXT: v_mov_b32_e32 v0, s4 |
| 35 | +; GCN-NEXT: v_mov_b32_e32 v1, s5 |
| 36 | +; GCN-NEXT: s_setpc_b64 s[30:31] |
| 37 | + ret ptr addrspace(1) @global |
| 38 | +} |
| 39 | + |
| 40 | +define ptr addrspace(4) @global_value_as4_external() { |
| 41 | +; GCN-LABEL: global_value_as4_external: |
| 42 | +; GCN: ; %bb.0: |
| 43 | +; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 44 | +; GCN-NEXT: s_getpc_b64 s[4:5] |
| 45 | +; GCN-NEXT: s_add_u32 s4, s4, constant@gotpcrel32@lo+4 |
| 46 | +; GCN-NEXT: s_addc_u32 s5, s5, constant@gotpcrel32@hi+12 |
| 47 | +; GCN-NEXT: s_load_dwordx2 s[4:5], s[4:5], 0x0 |
| 48 | +; GCN-NEXT: s_waitcnt lgkmcnt(0) |
| 49 | +; GCN-NEXT: v_mov_b32_e32 v0, s4 |
| 50 | +; GCN-NEXT: v_mov_b32_e32 v1, s5 |
| 51 | +; GCN-NEXT: s_setpc_b64 s[30:31] |
| 52 | + ret ptr addrspace(4) @constant |
| 53 | +} |
| 54 | + |
| 55 | +define amdgpu_kernel void @global_value_as3_lds_kernel(ptr addrspace(1) %out) { |
| 56 | +; GCN-LABEL: global_value_as3_lds_kernel: |
| 57 | +; GCN: ; %bb.0: |
| 58 | +; GCN-NEXT: s_load_dwordx2 s[0:1], s[8:9], 0x0 |
| 59 | +; GCN-NEXT: v_mov_b32_e32 v0, 0 |
| 60 | +; GCN-NEXT: s_waitcnt lgkmcnt(0) |
| 61 | +; GCN-NEXT: global_store_dword v0, v0, s[0:1] |
| 62 | +; GCN-NEXT: s_endpgm |
| 63 | + %addr = ptrtoint ptr addrspace(3) @lds to i32 |
| 64 | + store i32 %addr, ptr addrspace(1) %out |
| 65 | + ret void |
| 66 | +} |
| 67 | + |
| 68 | +define void @global_value_as8_buffer_store(i32 %val) { |
| 69 | +; GCN-LABEL: global_value_as8_buffer_store: |
| 70 | +; GCN: ; %bb.0: |
| 71 | +; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 72 | +; GCN-NEXT: s_getpc_b64 s[8:9] |
| 73 | +; GCN-NEXT: s_add_u32 s8, s8, buf@gotpcrel32@lo+4 |
| 74 | +; GCN-NEXT: s_addc_u32 s9, s9, buf@gotpcrel32@hi+12 |
| 75 | +; GCN-NEXT: s_load_dwordx4 s[4:7], s[8:9], 0x0 |
| 76 | +; GCN-NEXT: s_waitcnt lgkmcnt(0) |
| 77 | +; GCN-NEXT: buffer_store_dword v0, off, s[4:7], 0 |
| 78 | +; GCN-NEXT: s_waitcnt vmcnt(0) |
| 79 | +; GCN-NEXT: s_setpc_b64 s[30:31] |
| 80 | + call void @llvm.amdgcn.raw.ptr.buffer.store.i32(i32 %val, ptr addrspace(8) @buf, i32 0, i32 0, i32 0) |
| 81 | + ret void |
| 82 | +} |
| 83 | + |
| 84 | +define i32 @global_value_as8_buffer_load(i32 %offset) { |
| 85 | +; GCN-LABEL: global_value_as8_buffer_load: |
| 86 | +; GCN: ; %bb.0: |
| 87 | +; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 88 | +; GCN-NEXT: s_getpc_b64 s[8:9] |
| 89 | +; GCN-NEXT: s_add_u32 s8, s8, buf@gotpcrel32@lo+4 |
| 90 | +; GCN-NEXT: s_addc_u32 s9, s9, buf@gotpcrel32@hi+12 |
| 91 | +; GCN-NEXT: s_load_dwordx4 s[4:7], s[8:9], 0x0 |
| 92 | +; GCN-NEXT: s_waitcnt lgkmcnt(0) |
| 93 | +; GCN-NEXT: buffer_load_dword v0, v0, s[4:7], 0 offen |
| 94 | +; GCN-NEXT: s_waitcnt vmcnt(0) |
| 95 | +; GCN-NEXT: s_setpc_b64 s[30:31] |
| 96 | + %val = call i32 @llvm.amdgcn.raw.ptr.buffer.load.i32(ptr addrspace(8) @buf, i32 %offset, i32 0, i32 0) |
| 97 | + ret i32 %val |
| 98 | +} |
| 99 | + |
| 100 | +declare void @llvm.amdgcn.raw.ptr.buffer.store.i32(i32, ptr addrspace(8) nocapture writeonly, i32, i32, i32 immarg) #0 |
| 101 | +declare i32 @llvm.amdgcn.raw.ptr.buffer.load.i32(ptr addrspace(8) nocapture readonly, i32, i32, i32 immarg) #1 |
| 102 | + |
| 103 | +attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: write) } |
| 104 | +attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: read) } |
0 commit comments