1 // RUN: %clang_cc1 -triple loongarch64 -emit-llvm -verify %s -o /dev/null
2 // RUN: not %clang_cc1 -triple loongarch64 -DFEATURE_CHECK -emit-llvm %s -o /dev/null 2>&1 \
5 #include <larchintrin.h>
8 void test_feature(unsigned long *v_ul
, int *v_i
, float a
, double b
) {
9 // CHECK: error: '__builtin_loongarch_cacop_w' needs target feature 32bit
10 __builtin_loongarch_cacop_w(1, v_ul
[0], 1024);
11 // CHECK: error: '__builtin_loongarch_movfcsr2gr' needs target feature f
12 v_i
[0] = __builtin_loongarch_movfcsr2gr(1);
13 // CHECK: error: '__builtin_loongarch_movgr2fcsr' needs target feature f
14 __builtin_loongarch_movgr2fcsr(1, v_i
[1]);
15 // CHECK: error: '__builtin_loongarch_frecipe_s' needs target feature f,frecipe
16 float f1
= __builtin_loongarch_frecipe_s(a
);
17 // CHECK: error: '__builtin_loongarch_frsqrte_s' needs target feature f,frecipe
18 float f2
= __builtin_loongarch_frsqrte_s(a
);
19 // CHECK: error: '__builtin_loongarch_frecipe_d' needs target feature d,frecipe
20 double d1
= __builtin_loongarch_frecipe_d(b
);
21 // CHECK: error: '__builtin_loongarch_frsqrte_d' needs target feature d,frecipe
22 double d2
= __builtin_loongarch_frsqrte_d(b
);
27 __builtin_loongarch_csrrd_d(16384); // expected-error {{argument value 16384 is outside the valid range [0, 16383]}}
28 __builtin_loongarch_csrrd_d(-1); // expected-error {{argument value 4294967295 is outside the valid range [0, 16383]}}
29 __builtin_loongarch_csrrd_d(a
); // expected-error {{argument to '__builtin_loongarch_csrrd_d' must be a constant integer}}
32 void csrwr_d(unsigned long int a
) {
33 __builtin_loongarch_csrwr_d(a
, 16384); // expected-error {{argument value 16384 is outside the valid range [0, 16383]}}
34 __builtin_loongarch_csrwr_d(a
, -1); // expected-error {{argument value 4294967295 is outside the valid range [0, 16383]}}
35 __builtin_loongarch_csrwr_d(a
, a
); // expected-error {{argument to '__builtin_loongarch_csrwr_d' must be a constant integer}}
38 void csrxchg_d(unsigned long int a
, unsigned long int b
) {
39 __builtin_loongarch_csrxchg_d(a
, b
, 16384); // expected-error {{argument value 16384 is outside the valid range [0, 16383]}}
40 __builtin_loongarch_csrxchg_d(a
, b
, -1); // expected-error {{argument value 4294967295 is outside the valid range [0, 16383]}}
41 __builtin_loongarch_csrxchg_d(a
, b
, b
); // expected-error {{argument to '__builtin_loongarch_csrxchg_d' must be a constant integer}}
44 void lddir_d(long int a
, int b
) {
45 __builtin_loongarch_lddir_d(a
, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
46 __builtin_loongarch_lddir_d(a
, -1); // expected-error {{argument value 18446744073709551615 is outside the valid range [0, 31]}}
47 __builtin_loongarch_lddir_d(a
, b
); // expected-error {{argument to '__builtin_loongarch_lddir_d' must be a constant integer}}
50 void ldpte_d(long int a
, int b
) {
51 __builtin_loongarch_ldpte_d(a
, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}}
52 __builtin_loongarch_ldpte_d(a
, -1); // expected-error {{argument value 18446744073709551615 is outside the valid range [0, 31]}}
53 __builtin_loongarch_ldpte_d(a
, b
); // expected-error {{argument to '__builtin_loongarch_ldpte_d' must be a constant integer}}
56 int movfcsr2gr_out_of_lo_range(int a
) {
57 int b
= __builtin_loongarch_movfcsr2gr(-1); // expected-error {{argument value 4294967295 is outside the valid range [0, 3]}}
58 int c
= __builtin_loongarch_movfcsr2gr(32); // expected-error {{argument value 32 is outside the valid range [0, 3]}}
59 int d
= __builtin_loongarch_movfcsr2gr(a
); // expected-error {{argument to '__builtin_loongarch_movfcsr2gr' must be a constant integer}}
63 void movgr2fcsr(int a
, int b
) {
64 __builtin_loongarch_movgr2fcsr(-1, b
); // expected-error {{argument value 4294967295 is outside the valid range [0, 3]}}
65 __builtin_loongarch_movgr2fcsr(32, b
); // expected-error {{argument value 32 is outside the valid range [0, 3]}}
66 __builtin_loongarch_movgr2fcsr(a
, b
); // expected-error {{argument to '__builtin_loongarch_movgr2fcsr' must be a constant integer}}