1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=amdgcn -mcpu=bonaire -verify-machineinstrs < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Workerdeclare i32 @llvm.read_register.i32(metadata) #0 4*9880d681SAndroid Build Coastguard Workerdeclare i64 @llvm.read_register.i64(metadata) #0 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}test_read_m0: 7*9880d681SAndroid Build Coastguard Worker; CHECK: s_mov_b32 m0, -1 8*9880d681SAndroid Build Coastguard Worker; CHECK: v_mov_b32_e32 [[COPY:v[0-9]+]], m0 9*9880d681SAndroid Build Coastguard Worker; CHECK: buffer_store_dword [[COPY]] 10*9880d681SAndroid Build Coastguard Workerdefine void @test_read_m0(i32 addrspace(1)* %out) #0 { 11*9880d681SAndroid Build Coastguard Worker store volatile i32 0, i32 addrspace(3)* undef 12*9880d681SAndroid Build Coastguard Worker %m0 = call i32 @llvm.read_register.i32(metadata !0) 13*9880d681SAndroid Build Coastguard Worker store i32 %m0, i32 addrspace(1)* %out 14*9880d681SAndroid Build Coastguard Worker ret void 15*9880d681SAndroid Build Coastguard Worker} 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}test_read_exec: 18*9880d681SAndroid Build Coastguard Worker; CHECK: v_mov_b32_e32 v[[LO:[0-9]+]], exec_lo 19*9880d681SAndroid Build Coastguard Worker; CHECK: v_mov_b32_e32 v[[HI:[0-9]+]], exec_hi 20*9880d681SAndroid Build Coastguard Worker; CHECK: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}} 21*9880d681SAndroid Build Coastguard Workerdefine void @test_read_exec(i64 addrspace(1)* %out) #0 { 22*9880d681SAndroid Build Coastguard Worker %exec = call i64 @llvm.read_register.i64(metadata !1) 23*9880d681SAndroid Build Coastguard Worker store i64 %exec, i64 addrspace(1)* %out 24*9880d681SAndroid Build Coastguard Worker ret void 25*9880d681SAndroid Build Coastguard Worker} 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}test_read_flat_scratch: 28*9880d681SAndroid Build Coastguard Worker; CHECK: v_mov_b32_e32 v[[LO:[0-9]+]], flat_scratch_lo 29*9880d681SAndroid Build Coastguard Worker; CHECK: v_mov_b32_e32 v[[HI:[0-9]+]], flat_scratch_hi 30*9880d681SAndroid Build Coastguard Worker; CHECK: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}} 31*9880d681SAndroid Build Coastguard Workerdefine void @test_read_flat_scratch(i64 addrspace(1)* %out) #0 { 32*9880d681SAndroid Build Coastguard Worker %flat_scratch = call i64 @llvm.read_register.i64(metadata !2) 33*9880d681SAndroid Build Coastguard Worker store i64 %flat_scratch, i64 addrspace(1)* %out 34*9880d681SAndroid Build Coastguard Worker ret void 35*9880d681SAndroid Build Coastguard Worker} 36*9880d681SAndroid Build Coastguard Worker 37*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}test_read_flat_scratch_lo: 38*9880d681SAndroid Build Coastguard Worker; CHECK: v_mov_b32_e32 [[COPY:v[0-9]+]], flat_scratch_lo 39*9880d681SAndroid Build Coastguard Worker; CHECK: buffer_store_dword [[COPY]] 40*9880d681SAndroid Build Coastguard Workerdefine void @test_read_flat_scratch_lo(i32 addrspace(1)* %out) #0 { 41*9880d681SAndroid Build Coastguard Worker %flat_scratch_lo = call i32 @llvm.read_register.i32(metadata !3) 42*9880d681SAndroid Build Coastguard Worker store i32 %flat_scratch_lo, i32 addrspace(1)* %out 43*9880d681SAndroid Build Coastguard Worker ret void 44*9880d681SAndroid Build Coastguard Worker} 45*9880d681SAndroid Build Coastguard Worker 46*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}test_read_flat_scratch_hi: 47*9880d681SAndroid Build Coastguard Worker; CHECK: v_mov_b32_e32 [[COPY:v[0-9]+]], flat_scratch_hi 48*9880d681SAndroid Build Coastguard Worker; CHECK: buffer_store_dword [[COPY]] 49*9880d681SAndroid Build Coastguard Workerdefine void @test_read_flat_scratch_hi(i32 addrspace(1)* %out) #0 { 50*9880d681SAndroid Build Coastguard Worker %flat_scratch_hi = call i32 @llvm.read_register.i32(metadata !4) 51*9880d681SAndroid Build Coastguard Worker store i32 %flat_scratch_hi, i32 addrspace(1)* %out 52*9880d681SAndroid Build Coastguard Worker ret void 53*9880d681SAndroid Build Coastguard Worker} 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}test_read_exec_lo: 56*9880d681SAndroid Build Coastguard Worker; CHECK: v_mov_b32_e32 [[COPY:v[0-9]+]], exec_lo 57*9880d681SAndroid Build Coastguard Worker; CHECK: buffer_store_dword [[COPY]] 58*9880d681SAndroid Build Coastguard Workerdefine void @test_read_exec_lo(i32 addrspace(1)* %out) #0 { 59*9880d681SAndroid Build Coastguard Worker %exec_lo = call i32 @llvm.read_register.i32(metadata !5) 60*9880d681SAndroid Build Coastguard Worker store i32 %exec_lo, i32 addrspace(1)* %out 61*9880d681SAndroid Build Coastguard Worker ret void 62*9880d681SAndroid Build Coastguard Worker} 63*9880d681SAndroid Build Coastguard Worker 64*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: {{^}}test_read_exec_hi: 65*9880d681SAndroid Build Coastguard Worker; CHECK: v_mov_b32_e32 [[COPY:v[0-9]+]], exec_hi 66*9880d681SAndroid Build Coastguard Worker; CHECK: buffer_store_dword [[COPY]] 67*9880d681SAndroid Build Coastguard Workerdefine void @test_read_exec_hi(i32 addrspace(1)* %out) #0 { 68*9880d681SAndroid Build Coastguard Worker %exec_hi = call i32 @llvm.read_register.i32(metadata !6) 69*9880d681SAndroid Build Coastguard Worker store i32 %exec_hi, i32 addrspace(1)* %out 70*9880d681SAndroid Build Coastguard Worker ret void 71*9880d681SAndroid Build Coastguard Worker} 72*9880d681SAndroid Build Coastguard Worker 73*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind } 74*9880d681SAndroid Build Coastguard Worker 75*9880d681SAndroid Build Coastguard Worker!0 = !{!"m0"} 76*9880d681SAndroid Build Coastguard Worker!1 = !{!"exec"} 77*9880d681SAndroid Build Coastguard Worker!2 = !{!"flat_scratch"} 78*9880d681SAndroid Build Coastguard Worker!3 = !{!"flat_scratch_lo"} 79*9880d681SAndroid Build Coastguard Worker!4 = !{!"flat_scratch_hi"} 80*9880d681SAndroid Build Coastguard Worker!5 = !{!"exec_lo"} 81*9880d681SAndroid Build Coastguard Worker!6 = !{!"exec_hi"} 82