1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 --mattr=+f --verify-machineinstrs < %s | FileCheck %s
3 ; RUN: llc --mtriple=loongarch64 --mattr=+f --verify-machineinstrs < %s | FileCheck %s
5 declare void @llvm.loongarch.dbar(i32)
6 declare void @llvm.loongarch.ibar(i32)
7 declare void @llvm.loongarch.break(i32)
8 declare void @llvm.loongarch.movgr2fcsr(i32, i32)
9 declare i32 @llvm.loongarch.movfcsr2gr(i32)
10 declare void @llvm.loongarch.syscall(i32)
11 declare i32 @llvm.loongarch.csrrd.w(i32 immarg)
12 declare i32 @llvm.loongarch.csrwr.w(i32, i32 immarg)
13 declare i32 @llvm.loongarch.csrxchg.w(i32, i32, i32 immarg)
14 declare i32 @llvm.loongarch.iocsrrd.b(i32)
15 declare i32 @llvm.loongarch.iocsrrd.h(i32)
16 declare i32 @llvm.loongarch.iocsrrd.w(i32)
17 declare void @llvm.loongarch.iocsrwr.b(i32, i32)
18 declare void @llvm.loongarch.iocsrwr.h(i32, i32)
19 declare void @llvm.loongarch.iocsrwr.w(i32, i32)
20 declare i32 @llvm.loongarch.cpucfg(i32)
22 define void @foo() nounwind {
24 ; CHECK: # %bb.0: # %entry
28 call void @llvm.loongarch.dbar(i32 0)
32 define void @ibar() nounwind {
34 ; CHECK: # %bb.0: # %entry
38 call void @llvm.loongarch.ibar(i32 0)
42 define void @break() nounwind {
44 ; CHECK: # %bb.0: # %entry
48 call void @llvm.loongarch.break(i32 1)
52 define void @movgr2fcsr(i32 %a) nounwind {
53 ; CHECK-LABEL: movgr2fcsr:
54 ; CHECK: # %bb.0: # %entry
55 ; CHECK-NEXT: movgr2fcsr $fcsr1, $a0
58 call void @llvm.loongarch.movgr2fcsr(i32 1, i32 %a)
62 define i32 @movfcsr2gr() nounwind {
63 ; CHECK-LABEL: movfcsr2gr:
64 ; CHECK: # %bb.0: # %entry
65 ; CHECK-NEXT: movfcsr2gr $a0, $fcsr1
68 %res = call i32 @llvm.loongarch.movfcsr2gr(i32 1)
72 ;; TODO: Optimize out `movfcsr2gr` without data-dependency.
73 define void @movfcsr2gr_noret() nounwind {
74 ; CHECK-LABEL: movfcsr2gr_noret:
75 ; CHECK: # %bb.0: # %entry
76 ; CHECK-NEXT: movfcsr2gr $zero, $fcsr1
79 %res = call i32 @llvm.loongarch.movfcsr2gr(i32 1)
83 define void @syscall() nounwind {
84 ; CHECK-LABEL: syscall:
85 ; CHECK: # %bb.0: # %entry
86 ; CHECK-NEXT: syscall 1
89 call void @llvm.loongarch.syscall(i32 1)
93 define i32 @csrrd_w() {
94 ; CHECK-LABEL: csrrd_w:
95 ; CHECK: # %bb.0: # %entry
96 ; CHECK-NEXT: csrrd $a0, 1
99 %0 = tail call i32 @llvm.loongarch.csrrd.w(i32 1)
103 define void @csrrd_w_noret() {
104 ; CHECK-LABEL: csrrd_w_noret:
105 ; CHECK: # %bb.0: # %entry
106 ; CHECK-NEXT: csrrd $zero, 1
109 %0 = tail call i32 @llvm.loongarch.csrrd.w(i32 1)
113 define i32 @csrwr_w(i32 signext %a) {
114 ; CHECK-LABEL: csrwr_w:
115 ; CHECK: # %bb.0: # %entry
116 ; CHECK-NEXT: csrwr $a0, 1
119 %0 = tail call i32 @llvm.loongarch.csrwr.w(i32 %a, i32 1)
123 ;; Check that csrwr is emitted even if the return value of the intrinsic is not used.
124 define void @csrwr_w_noret(i32 signext %a) {
125 ; CHECK-LABEL: csrwr_w_noret:
126 ; CHECK: # %bb.0: # %entry
127 ; CHECK-NEXT: csrwr $a0, 1
130 %0 = tail call i32 @llvm.loongarch.csrwr.w(i32 %a, i32 1)
134 define i32 @csrxchg_w(i32 signext %a, i32 signext %b) {
135 ; CHECK-LABEL: csrxchg_w:
136 ; CHECK: # %bb.0: # %entry
137 ; CHECK-NEXT: csrxchg $a0, $a1, 1
140 %0 = tail call i32 @llvm.loongarch.csrxchg.w(i32 %a, i32 %b, i32 1)
144 ;; Check that csrxchg is emitted even if the return value of the intrinsic is not used.
145 define void @csrxchg_w_noret(i32 signext %a, i32 signext %b) {
146 ; CHECK-LABEL: csrxchg_w_noret:
147 ; CHECK: # %bb.0: # %entry
148 ; CHECK-NEXT: csrxchg $a0, $a1, 1
151 %0 = tail call i32 @llvm.loongarch.csrxchg.w(i32 %a, i32 %b, i32 1)
155 define i32 @iocsrrd_b(i32 %a) {
156 ; CHECK-LABEL: iocsrrd_b:
157 ; CHECK: # %bb.0: # %entry
158 ; CHECK-NEXT: iocsrrd.b $a0, $a0
161 %0 = tail call i32 @llvm.loongarch.iocsrrd.b(i32 %a)
165 define i32 @iocsrrd_h(i32 %a) {
166 ; CHECK-LABEL: iocsrrd_h:
167 ; CHECK: # %bb.0: # %entry
168 ; CHECK-NEXT: iocsrrd.h $a0, $a0
171 %0 = tail call i32 @llvm.loongarch.iocsrrd.h(i32 %a)
175 define i32 @iocsrrd_w(i32 %a) {
176 ; CHECK-LABEL: iocsrrd_w:
177 ; CHECK: # %bb.0: # %entry
178 ; CHECK-NEXT: iocsrrd.w $a0, $a0
181 %0 = tail call i32 @llvm.loongarch.iocsrrd.w(i32 %a)
185 define void @iocsrrd_b_noret(i32 %a) {
186 ; CHECK-LABEL: iocsrrd_b_noret:
187 ; CHECK: # %bb.0: # %entry
188 ; CHECK-NEXT: iocsrrd.b $zero, $a0
191 %0 = tail call i32 @llvm.loongarch.iocsrrd.b(i32 %a)
195 define void @iocsrrd_h_noret(i32 %a) {
196 ; CHECK-LABEL: iocsrrd_h_noret:
197 ; CHECK: # %bb.0: # %entry
198 ; CHECK-NEXT: iocsrrd.h $zero, $a0
201 %0 = tail call i32 @llvm.loongarch.iocsrrd.h(i32 %a)
205 define void @iocsrrd_w_noret(i32 %a) {
206 ; CHECK-LABEL: iocsrrd_w_noret:
207 ; CHECK: # %bb.0: # %entry
208 ; CHECK-NEXT: iocsrrd.w $zero, $a0
211 %0 = tail call i32 @llvm.loongarch.iocsrrd.w(i32 %a)
215 define void @iocsrwr_b(i32 %a, i32 %b) {
216 ; CHECK-LABEL: iocsrwr_b:
217 ; CHECK: # %bb.0: # %entry
218 ; CHECK-NEXT: iocsrwr.b $a0, $a1
221 tail call void @llvm.loongarch.iocsrwr.b(i32 %a, i32 %b)
225 define void @iocsrwr_h(i32 %a, i32 %b) {
226 ; CHECK-LABEL: iocsrwr_h:
227 ; CHECK: # %bb.0: # %entry
228 ; CHECK-NEXT: iocsrwr.h $a0, $a1
231 tail call void @llvm.loongarch.iocsrwr.h(i32 %a, i32 %b)
235 define void @iocsrwr_w(i32 %a, i32 %b) {
236 ; CHECK-LABEL: iocsrwr_w:
237 ; CHECK: # %bb.0: # %entry
238 ; CHECK-NEXT: iocsrwr.w $a0, $a1
241 tail call void @llvm.loongarch.iocsrwr.w(i32 %a, i32 %b)
245 define i32 @cpucfg(i32 %a) {
246 ; CHECK-LABEL: cpucfg:
247 ; CHECK: # %bb.0: # %entry
248 ; CHECK-NEXT: cpucfg $a0, $a0
251 %0 = tail call i32 @llvm.loongarch.cpucfg(i32 %a)
255 define void @cpucfg_noret(i32 %a) {
256 ; CHECK-LABEL: cpucfg_noret:
257 ; CHECK: # %bb.0: # %entry
260 %0 = tail call i32 @llvm.loongarch.cpucfg(i32 %a)