• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -march=amdgcn -mcpu=bonaire -verify-machineinstrs < %s | FileCheck %s
2
3declare i32 @llvm.read_register.i32(metadata) #0
4declare i64 @llvm.read_register.i64(metadata) #0
5
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]]
12define 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
16  ret void
17}
18
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]]{{\]}}
23define 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
26  ret void
27}
28
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]]{{\]}}
33define 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
36  ret void
37}
38
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]]
42define 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
45  ret void
46}
47
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]]
51define 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
54  ret void
55}
56
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]]
60define 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
63  ret void
64}
65
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]]
69define 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
72  ret void
73}
74
75attributes #0 = { nounwind }
76
77!0 = !{!"m0"}
78!1 = !{!"exec"}
79!2 = !{!"flat_scratch"}
80!3 = !{!"flat_scratch_lo"}
81!4 = !{!"flat_scratch_hi"}
82!5 = !{!"exec_lo"}
83!6 = !{!"exec_hi"}
84