blob: f6870539c637b2bc22fed9c5fd5fa0223b46b5c4 [file] [log] [blame]
Stanislav Mekhanoshind9930d42019-05-13 19:30:06 +00001;RUN: llc -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=SI -check-prefix=SIVI %s
2;RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=VIPLUS -check-prefix=SIVI %s
3;RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=VIPLUS -check-prefix=GFX9 %s
Matt Arsenaulta78ca622017-02-15 22:17:09 +00004
5; GCN-LABEL: {{^}}test_interrupt:
6; GCN: s_mov_b32 m0, 0
7; GCN-NOT: s_mov_b32 m0
8; GCN: s_sendmsg sendmsg(MSG_INTERRUPT)
Matt Arsenault3dbeefa2017-03-21 21:39:51 +00009define amdgpu_kernel void @test_interrupt() {
Matt Arsenaulta78ca622017-02-15 22:17:09 +000010body:
11 call void @llvm.amdgcn.s.sendmsg(i32 1, i32 0);
12 ret void
13}
14
15; GCN-LABEL: {{^}}test_gs_emit:
16; GCN: s_mov_b32 m0, 0
17; GCN-NOT: s_mov_b32 m0
18; GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 0)
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000019define amdgpu_kernel void @test_gs_emit() {
Matt Arsenaulta78ca622017-02-15 22:17:09 +000020body:
21 call void @llvm.amdgcn.s.sendmsg(i32 34, i32 0);
22 ret void
23}
24
25; GCN-LABEL: {{^}}test_gs_cut:
26; GCN: s_mov_b32 m0, 0
27; GCN-NOT: s_mov_b32 m0
28; GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 1)
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000029define amdgpu_kernel void @test_gs_cut() {
Matt Arsenaulta78ca622017-02-15 22:17:09 +000030body:
31 call void @llvm.amdgcn.s.sendmsg(i32 274, i32 0);
32 ret void
33}
34
35; GCN-LABEL: {{^}}test_gs_emit_cut:
36; GCN: s_mov_b32 m0, 0
37; GCN-NOT: s_mov_b32 m0
38; GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2)
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000039define amdgpu_kernel void @test_gs_emit_cut() {
Matt Arsenaulta78ca622017-02-15 22:17:09 +000040body:
41 call void @llvm.amdgcn.s.sendmsg(i32 562, i32 0)
42 ret void
43}
44
45; GCN-LABEL: {{^}}test_gs_done:
46; GCN: s_mov_b32 m0, 0
47; GCN-NOT: s_mov_b32 m0
48; GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP)
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000049define amdgpu_kernel void @test_gs_done() {
Matt Arsenaulta78ca622017-02-15 22:17:09 +000050body:
51 call void @llvm.amdgcn.s.sendmsg(i32 3, i32 0)
52 ret void
53}
54
Stanislav Mekhanoshind9930d42019-05-13 19:30:06 +000055; GCN-LABEL: {{^}}test_gs_alloc_req:
56; GCN: s_mov_b32 m0, s0
57; GCN-NOT: s_mov_b32 m0
58; VIPLUS-NEXT: s_nop 0
Dmitry Preobrazhensky1d572ce2019-06-28 14:14:02 +000059; SIVI: s_sendmsg sendmsg(9, 0, 0)
Stanislav Mekhanoshind9930d42019-05-13 19:30:06 +000060; GFX9: s_sendmsg sendmsg(MSG_GS_ALLOC_REQ)
61define amdgpu_kernel void @test_gs_alloc_req(i32 inreg %a) {
62body:
63 call void @llvm.amdgcn.s.sendmsg(i32 9, i32 %a)
64 ret void
65}
66
Matt Arsenaulta78ca622017-02-15 22:17:09 +000067; GCN-LABEL: {{^}}sendmsg:
68; GCN: s_mov_b32 m0, s0
Stanislav Mekhanoshind9930d42019-05-13 19:30:06 +000069; VIPLUS-NEXT: s_nop 0
Matt Arsenaulta78ca622017-02-15 22:17:09 +000070; GCN-NEXT: sendmsg(MSG_GS_DONE, GS_OP_NOP)
71; GCN-NEXT: s_endpgm
72define amdgpu_gs void @sendmsg(i32 inreg %a) #0 {
73 call void @llvm.amdgcn.s.sendmsg(i32 3, i32 %a)
74 ret void
75}
76
77; GCN-LABEL: {{^}}sendmsghalt:
78; GCN: s_mov_b32 m0, s0
Stanislav Mekhanoshind9930d42019-05-13 19:30:06 +000079; VIPLUS-NEXT: s_nop 0
Matt Arsenaulta78ca622017-02-15 22:17:09 +000080; GCN-NEXT: s_sendmsghalt sendmsg(MSG_INTERRUPT)
81; GCN-NEXT: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000082define amdgpu_kernel void @sendmsghalt(i32 inreg %a) #0 {
Matt Arsenaulta78ca622017-02-15 22:17:09 +000083 call void @llvm.amdgcn.s.sendmsghalt(i32 1, i32 %a)
84 ret void
85}
86
87; GCN-LABEL: {{^}}test_interrupt_halt:
88; GCN: s_mov_b32 m0, 0
89; GCN-NOT: s_mov_b32 m0
90; GCN: s_sendmsghalt sendmsg(MSG_INTERRUPT)
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000091define amdgpu_kernel void @test_interrupt_halt() {
Matt Arsenaulta78ca622017-02-15 22:17:09 +000092body:
93 call void @llvm.amdgcn.s.sendmsghalt(i32 1, i32 0)
94 ret void
95}
96
97; GCN-LABEL: {{^}}test_gs_emit_halt:
98; GCN: s_mov_b32 m0, 0
99; GCN-NOT: s_mov_b32 m0
100; GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 0)
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000101define amdgpu_kernel void @test_gs_emit_halt() {
Matt Arsenaulta78ca622017-02-15 22:17:09 +0000102body:
103 call void @llvm.amdgcn.s.sendmsghalt(i32 34, i32 0)
104 ret void
105}
106
107; GCN-LABEL: {{^}}test_gs_cut_halt:
108; GCN: s_mov_b32 m0, 0
109; GCN-NOT: s_mov_b32 m0
110; GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_CUT, 1)
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000111define amdgpu_kernel void @test_gs_cut_halt() {
Matt Arsenaulta78ca622017-02-15 22:17:09 +0000112body:
113 call void @llvm.amdgcn.s.sendmsghalt(i32 274, i32 0)
114 ret void
115}
116
117; GCN-LABEL: {{^}}test_gs_emit_cut_halt:
118; GCN: s_mov_b32 m0, 0
119; GCN-NOT: s_mov_b32 m0
120; GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2)
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000121define amdgpu_kernel void @test_gs_emit_cut_halt() {
Matt Arsenaulta78ca622017-02-15 22:17:09 +0000122body:
123 call void @llvm.amdgcn.s.sendmsghalt(i32 562, i32 0)
124 ret void
125}
126
127; GCN-LABEL: {{^}}test_gs_done_halt:
128; GCN: s_mov_b32 m0, 0
129; GCN-NOT: s_mov_b32 m0
130; GCN: s_sendmsghalt sendmsg(MSG_GS_DONE, GS_OP_NOP)
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000131define amdgpu_kernel void @test_gs_done_halt() {
Matt Arsenaulta78ca622017-02-15 22:17:09 +0000132body:
133 call void @llvm.amdgcn.s.sendmsghalt(i32 3, i32 0)
134 ret void
135}
136
Nicolai Haehnle7a879772018-04-20 07:14:25 +0000137; TODO: This should use s_mul_i32 instead of v_mul_u32_u24 + v_readfirstlane!
138;
139; GCN-LABEL: {{^}}test_mul24:
140; GCN: v_mul_u32_u24_e32
141; GCN: v_readfirstlane_b32
142; GCN: s_mov_b32 m0,
143; GCN: s_sendmsg sendmsg(MSG_INTERRUPT)
144define amdgpu_gs void @test_mul24(i32 inreg %arg) {
145body:
146 %tmp1 = and i32 %arg, 511
147 %tmp2 = mul nuw nsw i32 %tmp1, 12288
148 call void @llvm.amdgcn.s.sendmsg(i32 1, i32 %tmp2)
149 ret void
150}
151
Nicolai Haehnle7f0d05d2018-07-30 09:23:59 +0000152; GCN-LABEL: {{^}}if_sendmsg:
153; GCN: s_cbranch_execz
154; GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP)
155define amdgpu_gs void @if_sendmsg(i32 %flag) #0 {
156 %cc = icmp eq i32 %flag, 0
157 br i1 %cc, label %sendmsg, label %end
158
159sendmsg:
160 call void @llvm.amdgcn.s.sendmsg(i32 3, i32 0)
161 br label %end
162
163end:
164 ret void
165}
166
Matt Arsenaulta78ca622017-02-15 22:17:09 +0000167declare void @llvm.amdgcn.s.sendmsg(i32, i32) #0
168declare void @llvm.amdgcn.s.sendmsghalt(i32, i32) #0
Matt Arsenaulta78ca622017-02-15 22:17:09 +0000169
170attributes #0 = { nounwind }