1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2 // RUN: %clang_cc1 -triple loongarch32 -target-feature +f -O2 -emit-llvm %s -o - \
3 // RUN: | FileCheck %s -check-prefix=LA32
5 #include <larchintrin.h>
9 // LA32-NEXT: tail call void @llvm.loongarch.dbar(i32 0)
10 // LA32-NEXT: tail call void @llvm.loongarch.dbar(i32 0)
11 // LA32-NEXT: ret void
15 __builtin_loongarch_dbar(0);
20 // LA32-NEXT: tail call void @llvm.loongarch.ibar(i32 0)
21 // LA32-NEXT: tail call void @llvm.loongarch.ibar(i32 0)
22 // LA32-NEXT: ret void
26 __builtin_loongarch_ibar(0);
29 // LA32-LABEL: @loongarch_break(
31 // LA32-NEXT: tail call void @llvm.loongarch.break(i32 1)
32 // LA32-NEXT: tail call void @llvm.loongarch.break(i32 1)
33 // LA32-NEXT: ret void
35 void loongarch_break() {
37 __builtin_loongarch_break(1);
40 // LA32-LABEL: @syscall(
42 // LA32-NEXT: tail call void @llvm.loongarch.syscall(i32 1)
43 // LA32-NEXT: tail call void @llvm.loongarch.syscall(i32 1)
44 // LA32-NEXT: ret void
48 __builtin_loongarch_syscall(1);
51 // LA32-LABEL: @csrrd_w(
53 // LA32-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.csrrd.w(i32 1)
54 // LA32-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.csrrd.w(i32 1)
55 // LA32-NEXT: ret i32 0
57 unsigned int csrrd_w() {
58 unsigned int a
= __csrrd_w(1);
59 unsigned int b
= __builtin_loongarch_csrrd_w(1);
63 // LA32-LABEL: @csrwr_w(
65 // LA32-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.csrwr.w(i32 [[A:%.*]], i32 1)
66 // LA32-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.csrwr.w(i32 [[A]], i32 1)
67 // LA32-NEXT: ret i32 0
69 unsigned int csrwr_w(unsigned int a
) {
70 unsigned int b
= __csrwr_w(a
, 1);
71 unsigned int c
= __builtin_loongarch_csrwr_w(a
, 1);
75 // LA32-LABEL: @csrxchg_w(
77 // LA32-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.csrxchg.w(i32 [[A:%.*]], i32 [[B:%.*]], i32 1)
78 // LA32-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.csrxchg.w(i32 [[A]], i32 [[B]], i32 1)
79 // LA32-NEXT: ret i32 0
81 unsigned int csrxchg_w(unsigned int a
, unsigned int b
) {
82 unsigned int c
= __csrxchg_w(a
, b
, 1);
83 unsigned int d
= __builtin_loongarch_csrxchg_w(a
, b
, 1);
87 // LA32-LABEL: @iocsrrd_b(
89 // LA32-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.b(i32 [[A:%.*]])
90 // LA32-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.b(i32 [[A]])
91 // LA32-NEXT: ret i8 0
93 unsigned char iocsrrd_b(unsigned int a
) {
94 unsigned char b
= __iocsrrd_b(a
);
95 unsigned char c
= __builtin_loongarch_iocsrrd_b(a
);
99 // LA32-LABEL: @iocsrrd_h(
101 // LA32-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A:%.*]])
102 // LA32-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A]])
103 // LA32-NEXT: ret i16 0
105 unsigned short iocsrrd_h(unsigned int a
) {
106 unsigned short b
= __iocsrrd_h(a
);
107 unsigned short c
= __builtin_loongarch_iocsrrd_h(a
);
111 // LA32-LABEL: @iocsrrd_w(
113 // LA32-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.w(i32 [[A:%.*]])
114 // LA32-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.w(i32 [[A]])
115 // LA32-NEXT: ret i32 0
117 unsigned int iocsrrd_w(unsigned int a
) {
118 unsigned int b
= __iocsrrd_w(a
);
119 unsigned int c
= __builtin_loongarch_iocsrrd_w(a
);
123 // LA32-LABEL: @iocsrwr_b(
125 // LA32-NEXT: [[CONV_I:%.*]] = zext i8 [[A:%.*]] to i32
126 // LA32-NEXT: tail call void @llvm.loongarch.iocsrwr.b(i32 [[CONV_I]], i32 [[B:%.*]])
127 // LA32-NEXT: tail call void @llvm.loongarch.iocsrwr.b(i32 [[CONV_I]], i32 [[B]])
128 // LA32-NEXT: ret void
130 void iocsrwr_b(unsigned char a
, unsigned int b
) {
132 __builtin_loongarch_iocsrwr_b(a
, b
);
135 // LA32-LABEL: @iocsrwr_h(
137 // LA32-NEXT: [[CONV_I:%.*]] = zext i16 [[A:%.*]] to i32
138 // LA32-NEXT: tail call void @llvm.loongarch.iocsrwr.h(i32 [[CONV_I]], i32 [[B:%.*]])
139 // LA32-NEXT: tail call void @llvm.loongarch.iocsrwr.h(i32 [[CONV_I]], i32 [[B]])
140 // LA32-NEXT: ret void
142 void iocsrwr_h(unsigned short a
, unsigned int b
) {
144 __builtin_loongarch_iocsrwr_h(a
, b
);
147 // LA32-LABEL: @iocsrwr_w(
149 // LA32-NEXT: tail call void @llvm.loongarch.iocsrwr.w(i32 [[A:%.*]], i32 [[B:%.*]])
150 // LA32-NEXT: tail call void @llvm.loongarch.iocsrwr.w(i32 [[A]], i32 [[B]])
151 // LA32-NEXT: ret void
153 void iocsrwr_w(unsigned int a
, unsigned int b
) {
155 __builtin_loongarch_iocsrwr_w(a
, b
);
158 // LA32-LABEL: @cpucfg(
160 // LA32-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.cpucfg(i32 [[A:%.*]])
161 // LA32-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.cpucfg(i32 [[A]])
162 // LA32-NEXT: ret i32 0
164 unsigned int cpucfg(unsigned int a
) {
165 unsigned int b
= __cpucfg(a
);
166 unsigned int c
= __builtin_loongarch_cpucfg(a
);
170 // LA32-LABEL: @rdtime(
172 // LA32-NEXT: [[TMP0:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimeh.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1:[0-9]+]], !srcloc !2
173 // LA32-NEXT: [[TMP1:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimel.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc !3
174 // LA32-NEXT: ret void
181 // LA32-LABEL: @loongarch_movfcsr2gr(
183 // LA32-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.movfcsr2gr(i32 1)
184 // LA32-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.movfcsr2gr(i32 1)
185 // LA32-NEXT: ret i32 0
187 int loongarch_movfcsr2gr() {
188 int a
= __movfcsr2gr(1);
189 int b
= __builtin_loongarch_movfcsr2gr(1);
193 // LA32-LABEL: @loongarch_movgr2fcsr(
195 // LA32-NEXT: tail call void @llvm.loongarch.movgr2fcsr(i32 1, i32 [[A:%.*]])
196 // LA32-NEXT: tail call void @llvm.loongarch.movgr2fcsr(i32 1, i32 [[A]])
197 // LA32-NEXT: ret void
199 void loongarch_movgr2fcsr(int a
) {
201 __builtin_loongarch_movgr2fcsr(1, a
);
204 // CHECK-LABEL: @cacop_w(
205 // CHECK-NEXT: entry:
206 // CHECK-NEXT: tail call void @llvm.loongarch.cacop.w(i32 1, i32 [[A:%.*]], i32 1024)
207 // CHECK-NEXT: tail call void @llvm.loongarch.cacop.w(i32 1, i32 [[A]], i32 1024)
208 // CHECK-NEXT: ret void
210 void cacop_w(unsigned long int a
) {
211 __cacop_w(1, a
, 1024);
212 __builtin_loongarch_cacop_w(1, a
, 1024);