brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.9 KiB · 89ce005 Raw
121 lines · c
1// RUN: %clang_cc1 -triple loongarch32 -emit-llvm -verify %s -o /dev/null2// RUN: not %clang_cc1 -triple loongarch32 -DFEATURE_CHECK -emit-llvm %s -o /dev/null 2>&1 \3// RUN:   | FileCheck %s4 5#include <larchintrin.h>6 7#ifdef FEATURE_CHECK8void test_feature(long *v_l, unsigned long *v_ul, int *v_i, unsigned ui, char c, short s) {9// CHECK: error: '__builtin_loongarch_cacop_d' needs target feature 64bit10  __builtin_loongarch_cacop_d(1, v_ul[0], 1024);11 12// CHECK: error: '__builtin_loongarch_crc_w_b_w' needs target feature 64bit13  v_i[0] = __builtin_loongarch_crc_w_b_w(c, v_i[0]);14// CHECK: error: '__builtin_loongarch_crc_w_h_w' needs target feature 64bit15  v_i[1] =  __builtin_loongarch_crc_w_h_w(c, v_i[0]);16// CHECK: error: '__builtin_loongarch_crc_w_w_w' needs target feature 64bit17  v_i[2] = __builtin_loongarch_crc_w_w_w(c, v_i[0]);18// CHECK: error: '__builtin_loongarch_crc_w_d_w' needs target feature 64bit19  v_i[3] = __builtin_loongarch_crc_w_d_w(c, v_i[0]);20 21// CHECK: error: '__builtin_loongarch_crcc_w_b_w' needs target feature 64bit22  v_i[4] = __builtin_loongarch_crcc_w_b_w(c, v_i[0]);23// CHECK: error: '__builtin_loongarch_crcc_w_h_w' needs target feature 64bit24  v_i[5] = __builtin_loongarch_crcc_w_h_w(s, v_i[0]);25// CHECK: error: '__builtin_loongarch_crcc_w_w_w' needs target feature 64bit26  v_i[6] = __builtin_loongarch_crcc_w_w_w(v_i[0], v_i[1]);27// CHECK: error: '__builtin_loongarch_crcc_w_d_w' needs target feature 64bit28  v_i[7] = __builtin_loongarch_crcc_w_d_w(v_l[0], v_i[0]);29 30// CHECK: error: '__builtin_loongarch_csrrd_d' needs target feature 64bit31  v_ul[0] = __builtin_loongarch_csrrd_d(1);32// CHECK: error: '__builtin_loongarch_csrwr_d' needs target feature 64bit33  v_ul[1] = __builtin_loongarch_csrwr_d(v_ul[0], 1);34// CHECK: error: '__builtin_loongarch_csrxchg_d' needs target feature 64bit35  v_ul[2] = __builtin_loongarch_csrxchg_d(v_ul[0], v_ul[1], 1);36 37 38// CHECK: error: '__builtin_loongarch_iocsrrd_d' needs target feature 64bit39  v_ul[3] = __builtin_loongarch_iocsrrd_d(ui);40// CHECK: error: '__builtin_loongarch_iocsrwr_d' needs target feature 64bit41  __builtin_loongarch_iocsrwr_d(v_ul[0], ui);42 43// CHECK: error: '__builtin_loongarch_asrtle_d' needs target feature 64bit44  __builtin_loongarch_asrtle_d(v_l[0], v_l[1]);45// CHECK: error: '__builtin_loongarch_asrtgt_d' needs target feature 64bit46  __builtin_loongarch_asrtgt_d(v_l[0], v_l[1]);47 48// CHECK: error: '__builtin_loongarch_lddir_d' needs target feature 64bit49  v_ul[4] = __builtin_loongarch_lddir_d(v_l[0], 1);50// CHECK: error: '__builtin_loongarch_ldpte_d' needs target feature 64bit51  __builtin_loongarch_ldpte_d(v_l[0], 1);52}53#endif54 55void cacop_w(unsigned long int a) {56  __builtin_loongarch_cacop_w(-1, a, 1024); // expected-error {{argument value -1 is outside the valid range [0, 31]}}57  __builtin_loongarch_cacop_w(32, a, 1024); // expected-error {{argument value 32 is outside the valid range [0, 31]}}58  __builtin_loongarch_cacop_w(1, a, -4096); // expected-error {{argument value -4096 is outside the valid range [-2048, 2047]}}59  __builtin_loongarch_cacop_w(1, a, 4096); // expected-error {{argument value 4096 is outside the valid range [-2048, 2047]}}60  __builtin_loongarch_cacop_w(-2, a, 5000); // expected-error {{argument value -2 is outside the valid range [0, 31]}}61}62 63void dbar(int a) {64  __builtin_loongarch_dbar(32768); // expected-error {{argument value 32768 is outside the valid range [0, 32767]}}65  __builtin_loongarch_dbar(-1); // expected-error {{argument value 4294967295 is outside the valid range [0, 32767]}}66  __builtin_loongarch_dbar(a); // expected-error {{argument to '__builtin_loongarch_dbar' must be a constant integer}}67}68 69void ibar(int a) {70  __builtin_loongarch_ibar(32769); // expected-error {{argument value 32769 is outside the valid range [0, 32767]}}71  __builtin_loongarch_ibar(-1); // expected-error {{argument value 4294967295 is outside the valid range [0, 32767]}}72  __builtin_loongarch_ibar(a); // expected-error {{argument to '__builtin_loongarch_ibar' must be a constant integer}}73}74 75void loongarch_break(int a) {76  __builtin_loongarch_break(32769); // expected-error {{argument value 32769 is outside the valid range [0, 32767]}}77  __builtin_loongarch_break(-1); // expected-error {{argument value 4294967295 is outside the valid range [0, 32767]}}78  __builtin_loongarch_break(a); // expected-error {{argument to '__builtin_loongarch_break' must be a constant integer}}79}80 81int movfcsr2gr_out_of_lo_range(int a) {82  int b =  __builtin_loongarch_movfcsr2gr(-1); // expected-error {{argument value 4294967295 is outside the valid range [0, 3]}}83  int c = __builtin_loongarch_movfcsr2gr(32); // expected-error {{argument value 32 is outside the valid range [0, 3]}}84  int d = __builtin_loongarch_movfcsr2gr(a); // expected-error {{argument to '__builtin_loongarch_movfcsr2gr' must be a constant integer}}85  return 0;86}87 88void movgr2fcsr(int a, int b) {89  __builtin_loongarch_movgr2fcsr(-1, b); // expected-error {{argument value 4294967295 is outside the valid range [0, 3]}}90  __builtin_loongarch_movgr2fcsr(32, b); // expected-error {{argument value 32 is outside the valid range [0, 3]}}91  __builtin_loongarch_movgr2fcsr(a, b); // expected-error {{argument to '__builtin_loongarch_movgr2fcsr' must be a constant integer}}92}93 94void syscall(int a) {95  __builtin_loongarch_syscall(32769); // expected-error {{argument value 32769 is outside the valid range [0, 32767]}}96  __builtin_loongarch_syscall(-1); // expected-error {{argument value 4294967295 is outside the valid range [0, 32767]}}97  __builtin_loongarch_syscall(a); // expected-error {{argument to '__builtin_loongarch_syscall' must be a constant integer}}98}99 100void csrrd_w(int a) {101    __builtin_loongarch_csrrd_w(16384); // expected-error {{argument value 16384 is outside the valid range [0, 16383]}}102    __builtin_loongarch_csrrd_w(-1); // expected-error {{argument value 4294967295 is outside the valid range [0, 16383]}}103    __builtin_loongarch_csrrd_w(a); // expected-error {{argument to '__builtin_loongarch_csrrd_w' must be a constant integer}}104}105 106void csrwr_w(unsigned int a) {107    __builtin_loongarch_csrwr_w(a, 16384); // expected-error {{argument value 16384 is outside the valid range [0, 16383]}}108    __builtin_loongarch_csrwr_w(a, -1); // expected-error {{argument value 4294967295 is outside the valid range [0, 16383]}}109    __builtin_loongarch_csrwr_w(a, a); // expected-error {{argument to '__builtin_loongarch_csrwr_w' must be a constant integer}}110}111 112void csrxchg_w(unsigned int a, unsigned int b) {113    __builtin_loongarch_csrxchg_w(a, b, 16384); // expected-error {{argument value 16384 is outside the valid range [0, 16383]}}114    __builtin_loongarch_csrxchg_w(a, b, -1); // expected-error {{argument value 4294967295 is outside the valid range [0, 16383]}}115    __builtin_loongarch_csrxchg_w(a, b, b); // expected-error {{argument to '__builtin_loongarch_csrxchg_w' must be a constant integer}}116}117 118void rdtime_d() {119  __rdtime_d(); // expected-error {{call to undeclared function '__rdtime_d'}}120}121