1 ; RUN: llc -march=amdgcn -mcpu=bonaire -verify-machineinstrs < %s | FileCheck %s
3 declare i32 @llvm.read_register.i32(metadata) #0
4 declare i64 @llvm.read_register.i64(metadata) #0
6 ; FIXME: Should be able to eliminate copy
7 ; CHECK-LABEL: {{^}}test_read_m0:
8 ; CHECK: s_mov_b32 m0, -1
9 ; CHECK: s_mov_b32 [[COPY_M0:s[0-9]+]], m0
10 ; CHECK: v_mov_b32_e32 [[COPY:v[0-9]+]], [[COPY_M0]]
11 ; CHECK: buffer_store_dword [[COPY]]
12 define amdgpu_kernel void @test_read_m0(i32 addrspace(1)* %out) #0 {
13 store volatile i32 0, i32 addrspace(3)* undef
14 %m0 = call i32 @llvm.read_register.i32(metadata !0)
15 store i32 %m0, i32 addrspace(1)* %out
19 ; CHECK-LABEL: {{^}}test_read_exec:
20 ; CHECK: v_mov_b32_e32 v[[LO:[0-9]+]], exec_lo
21 ; CHECK: v_mov_b32_e32 v[[HI:[0-9]+]], exec_hi
22 ; CHECK: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
23 define amdgpu_kernel void @test_read_exec(i64 addrspace(1)* %out) #0 {
24 %exec = call i64 @llvm.read_register.i64(metadata !1)
25 store i64 %exec, i64 addrspace(1)* %out
29 ; CHECK-LABEL: {{^}}test_read_flat_scratch:
30 ; CHECK: v_mov_b32_e32 v[[LO:[0-9]+]], flat_scratch_lo
31 ; CHECK: v_mov_b32_e32 v[[HI:[0-9]+]], flat_scratch_hi
32 ; CHECK: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}
33 define amdgpu_kernel void @test_read_flat_scratch(i64 addrspace(1)* %out) #0 {
34 %flat_scratch = call i64 @llvm.read_register.i64(metadata !2)
35 store i64 %flat_scratch, i64 addrspace(1)* %out
39 ; CHECK-LABEL: {{^}}test_read_flat_scratch_lo:
40 ; CHECK: v_mov_b32_e32 [[COPY:v[0-9]+]], flat_scratch_lo
41 ; CHECK: buffer_store_dword [[COPY]]
42 define amdgpu_kernel void @test_read_flat_scratch_lo(i32 addrspace(1)* %out) #0 {
43 %flat_scratch_lo = call i32 @llvm.read_register.i32(metadata !3)
44 store i32 %flat_scratch_lo, i32 addrspace(1)* %out
48 ; CHECK-LABEL: {{^}}test_read_flat_scratch_hi:
49 ; CHECK: v_mov_b32_e32 [[COPY:v[0-9]+]], flat_scratch_hi
50 ; CHECK: buffer_store_dword [[COPY]]
51 define amdgpu_kernel void @test_read_flat_scratch_hi(i32 addrspace(1)* %out) #0 {
52 %flat_scratch_hi = call i32 @llvm.read_register.i32(metadata !4)
53 store i32 %flat_scratch_hi, i32 addrspace(1)* %out
57 ; CHECK-LABEL: {{^}}test_read_exec_lo:
58 ; CHECK: v_mov_b32_e32 [[COPY:v[0-9]+]], exec_lo
59 ; CHECK: buffer_store_dword [[COPY]]
60 define amdgpu_kernel void @test_read_exec_lo(i32 addrspace(1)* %out) #0 {
61 %exec_lo = call i32 @llvm.read_register.i32(metadata !5)
62 store i32 %exec_lo, i32 addrspace(1)* %out
66 ; CHECK-LABEL: {{^}}test_read_exec_hi:
67 ; CHECK: v_mov_b32_e32 [[COPY:v[0-9]+]], exec_hi
68 ; CHECK: buffer_store_dword [[COPY]]
69 define amdgpu_kernel void @test_read_exec_hi(i32 addrspace(1)* %out) #0 {
70 %exec_hi = call i32 @llvm.read_register.i32(metadata !6)
71 store i32 %exec_hi, i32 addrspace(1)* %out
75 attributes #0 = { nounwind }
79 !2 = !{!"flat_scratch"}
80 !3 = !{!"flat_scratch_lo"}
81 !4 = !{!"flat_scratch_hi"}