Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / PowerPC / builtins-ppc-xlcompat-error.c
blob5f57d7575c859abba0b8fc083d38ceb397bc11be
1 // REQUIRES: powerpc-registered-target
2 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -fsyntax-only \
3 // RUN: -Wall -Werror -verify %s
4 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -fsyntax-only \
5 // RUN: -Wall -Werror -verify %s
6 // RUN: %clang_cc1 -triple powerpc64-unknown-aix -fsyntax-only \
7 // RUN: -Wall -Werror -verify %s
8 // RUN: %clang_cc1 -triple powerpc-unknown-aix -fsyntax-only \
9 // RUN: -Wall -Werror -verify %s
11 extern long long lla, llb;
12 extern int ia, ib;
13 extern unsigned int ui;
14 extern unsigned long long ull;
15 extern const int cia;
16 extern unsigned long ula;
18 void test_trap(void) {
19 #ifdef __PPC64__
20 __tdw(lla, llb, 50); //expected-error {{argument value 50 is outside the valid range [1, 31]}}
21 __tdw(lla, llb, 0); //expected-error {{argument value 0 is outside the valid range [1, 31]}}
22 #endif
23 __tw(ia, ib, 50); //expected-error {{argument value 50 is outside the valid range [1, 31]}}
24 __tw(ia, ib, 0); //expected-error {{argument value 0 is outside the valid range [1, 31]}}
27 void test_builtin_ppc_rldimi() {
28 unsigned int shift;
29 unsigned long long mask;
30 unsigned long long res = __builtin_ppc_rldimi(ull, ull, shift, 7); // expected-error {{argument to '__builtin_ppc_rldimi' must be a constant integer}}
31 res = __builtin_ppc_rldimi(ull, ull, 63, mask); // expected-error {{argument to '__builtin_ppc_rldimi' must be a constant integer}}
32 res = __builtin_ppc_rldimi(ull, ull, 63, 0xFFFF000000000F00); // expected-error {{argument 3 value should represent a contiguous bit field}}
35 void test_builtin_ppc_rlwimi() {
36 unsigned int shift;
37 unsigned int mask;
38 unsigned int res = __builtin_ppc_rlwimi(ui, ui, shift, 7); // expected-error {{argument to '__builtin_ppc_rlwimi' must be a constant integer}}
39 res = __builtin_ppc_rlwimi(ui, ui, 31, mask); // expected-error {{argument to '__builtin_ppc_rlwimi' must be a constant integer}}
40 res = __builtin_ppc_rlwimi(ui, ui, 31, 0xFFFF0F00); // expected-error {{argument 3 value should represent a contiguous bit field}}
43 void test_builtin_ppc_rlwnm() {
44 unsigned int mask;
45 unsigned int res = __builtin_ppc_rlwnm(ui, 31, mask); // expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
46 res = __builtin_ppc_rlwnm(ui, 31, 0xFF0F0F00); // expected-error {{argument 2 value should represent a contiguous bit field}}
49 extern unsigned int usi;
50 extern double d;
51 extern float f;
53 void testMathBuiltin(void) {
54 __mtfsb0(usi); //expected-error {{argument to '__builtin_ppc_mtfsb0' must be a constant integer}}
55 __mtfsb0(32); //expected-error {{argument value 32 is outside the valid range [0, 31]}}
56 __mtfsb1(usi); //expected-error {{argument to '__builtin_ppc_mtfsb1' must be a constant integer}}
57 __mtfsb1(45); //expected-error {{argument value 45 is outside the valid range [0, 31]}}
58 __mtfsf(usi, usi); //expected-error {{argument to '__builtin_ppc_mtfsf' must be a constant integer}}
59 __mtfsf(350, usi); //expected-error {{argument value 350 is outside the valid range [0, 255]}}
60 __mtfsfi(usi, 0); //expected-error {{argument to '__builtin_ppc_mtfsfi' must be a constant integer}}
61 __mtfsfi(0, usi); //expected-error {{argument to '__builtin_ppc_mtfsfi' must be a constant integer}}
62 __mtfsfi(8, 0); //expected-error {{argument value 8 is outside the valid range [0, 7]}}
63 __mtfsfi(5, 24); //expected-error {{argument value 24 is outside the valid range [0, 15]}}
66 unsigned long long testrdlam(unsigned long long rs, unsigned int shift, unsigned int not_const) {
67 // The third parameter is a mask that must be a constant that represents a
68 // contiguous bit field.
69 unsigned long long Return;
70 // Third parameter is not a constant.
71 Return = __rdlam(rs, shift, not_const); //expected-error {{argument to '__builtin_ppc_rdlam' must be a constant integer}}
72 // Third parameter is a constant but not a contiguous bit field.
73 return __rdlam(rs, shift, 0xF4) + Return; //expected-error {{argument 2 value should represent a contiguous bit field}}
76 void testalignx(const void *pointer, unsigned int alignment) {
77 // The alignment must be an immediate.
78 __alignx(alignment, pointer); //expected-error {{argument to '__builtin_ppc_alignx' must be a constant integer}}
79 // The alignment must be a power of 2.
80 __alignx(0x0, pointer); //expected-error {{argument should be a power of 2}}
81 // The alignment must be a power of 2.
82 __alignx(0xFF, pointer); //expected-error {{argument should be a power of 2}}
85 #ifndef __PPC64__
86 long long testbpermd(long long bit_selector, long long source) {
87 return __bpermd(bit_selector, source); //expected-error {{this builtin is only available on 64-bit targets}}
90 long long testdivde(long long dividend, long long divisor) {
91 return __divde(dividend, divisor); //expected-error {{this builtin is only available on 64-bit targets}}
94 unsigned long long testdivdeu(unsigned long long dividend, unsigned long long divisor) {
95 return __divdeu(dividend, divisor); //expected-error {{this builtin is only available on 64-bit targets}}
98 int test_darn() {
99 return __darn(); //expected-error {{this builtin is only available on 64-bit targets}}
102 int test_darn_raw() {
103 return __darn_raw(); //expected-error {{this builtin is only available on 64-bit targets}}
106 int test_builtin_ppc_compare_and_swaplp(long a, long b, long c) {
107 return __compare_and_swaplp(&a, &b, c); // expected-error {{this builtin is only available on 64-bit targets}}
110 void test_builtin_ppc_fetch_and_addlp(long a, long b) {
111 __fetch_and_addlp(&a, b); // expected-error {{this builtin is only available on 64-bit targets}}
114 void test_builtin_ppc_fetch_and_andlp(unsigned long a, unsigned long b) {
115 __fetch_and_andlp(&a, b); // expected-error {{this builtin is only available on 64-bit targets}}
117 void test_builtin_ppc_fetch_and_orlp(unsigned long a, unsigned long b) {
118 __fetch_and_orlp(&a, b); // expected-error {{this builtin is only available on 64-bit targets}}
121 void test_builtin_ppc_fetch_and_swaplp(unsigned long a, unsigned long b) {
122 __fetch_and_swaplp(&a, b); // expected-error {{this builtin is only available on 64-bit targets}}
124 #endif
126 unsigned long test_mfspr(void) {
127 return __mfspr(cia); //expected-error {{argument to '__builtin_ppc_mfspr' must be a constant integer}}
130 void test_mtspr(void) {
131 __mtspr(cia, ula); //expected-error {{argument to '__builtin_ppc_mtspr' must be a constant integer}}