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
;
13 extern unsigned int ui
;
14 extern unsigned long long ull
;
16 extern unsigned long ula
;
18 void test_trap(void) {
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]}}
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() {
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}}
33 res
= __builtin_ppc_rldimi(ull
, ull
, 64, 0xFFFF000000000000); // expected-error {{argument value 64 is outside the valid range [0, 63]}}
36 void test_builtin_ppc_rlwimi() {
39 unsigned int res
= __builtin_ppc_rlwimi(ui
, ui
, shift
, 7); // expected-error {{argument to '__builtin_ppc_rlwimi' must be a constant integer}}
40 res
= __builtin_ppc_rlwimi(ui
, ui
, 31, mask
); // expected-error {{argument to '__builtin_ppc_rlwimi' must be a constant integer}}
41 res
= __builtin_ppc_rlwimi(ui
, ui
, 31, 0xFFFF0F00); // expected-error {{argument 3 value should represent a contiguous bit field}}
44 void test_builtin_ppc_rlwnm() {
46 unsigned int res
= __builtin_ppc_rlwnm(ui
, 31, mask
); // expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
47 res
= __builtin_ppc_rlwnm(ui
, 31, 0xFF0F0F00); // expected-error {{argument 2 value should represent a contiguous bit field}}
50 extern unsigned int usi
;
54 void testMathBuiltin(void) {
55 __mtfsb0(usi
); //expected-error {{argument to '__builtin_ppc_mtfsb0' must be a constant integer}}
56 __mtfsb0(32); //expected-error {{argument value 32 is outside the valid range [0, 31]}}
57 __mtfsb1(usi
); //expected-error {{argument to '__builtin_ppc_mtfsb1' must be a constant integer}}
58 __mtfsb1(45); //expected-error {{argument value 45 is outside the valid range [0, 31]}}
59 __mtfsf(usi
, usi
); //expected-error {{argument to '__builtin_ppc_mtfsf' must be a constant integer}}
60 __mtfsf(350, usi
); //expected-error {{argument value 350 is outside the valid range [0, 255]}}
61 __mtfsfi(usi
, 0); //expected-error {{argument to '__builtin_ppc_mtfsfi' must be a constant integer}}
62 __mtfsfi(0, usi
); //expected-error {{argument to '__builtin_ppc_mtfsfi' must be a constant integer}}
63 __mtfsfi(8, 0); //expected-error {{argument value 8 is outside the valid range [0, 7]}}
64 __mtfsfi(5, 24); //expected-error {{argument value 24 is outside the valid range [0, 15]}}
67 unsigned long long testrdlam(unsigned long long rs
, unsigned int shift
, unsigned int not_const
) {
68 // The third parameter is a mask that must be a constant that represents a
69 // contiguous bit field.
70 unsigned long long Return
;
71 // Third parameter is not a constant.
72 Return
= __rdlam(rs
, shift
, not_const
); //expected-error {{argument to '__builtin_ppc_rdlam' must be a constant integer}}
73 // Third parameter is a constant but not a contiguous bit field.
74 return __rdlam(rs
, shift
, 0xF4) + Return
; //expected-error {{argument 2 value should represent a contiguous bit field}}
77 void testalignx(const void *pointer
, unsigned int alignment
) {
78 // The alignment must be an immediate.
79 __alignx(alignment
, pointer
); //expected-error {{argument to '__builtin_ppc_alignx' must be a constant integer}}
80 // The alignment must be a power of 2.
81 __alignx(0x0, pointer
); //expected-error {{argument should be a power of 2}}
82 // The alignment must be a power of 2.
83 __alignx(0xFF, pointer
); //expected-error {{argument should be a power of 2}}
87 long long testbpermd(long long bit_selector
, long long source
) {
88 return __bpermd(bit_selector
, source
); //expected-error {{this builtin is only available on 64-bit targets}}
91 long long testdivde(long long dividend
, long long divisor
) {
92 return __divde(dividend
, divisor
); //expected-error {{this builtin is only available on 64-bit targets}}
95 unsigned long long testdivdeu(unsigned long long dividend
, unsigned long long divisor
) {
96 return __divdeu(dividend
, divisor
); //expected-error {{this builtin is only available on 64-bit targets}}
100 return __darn(); //expected-error {{this builtin is only available on 64-bit targets}}
103 int test_darn_raw() {
104 return __darn_raw(); //expected-error {{this builtin is only available on 64-bit targets}}
107 int test_builtin_ppc_compare_and_swaplp(long a
, long b
, long c
) {
108 return __compare_and_swaplp(&a
, &b
, c
); // expected-error {{this builtin is only available on 64-bit targets}}
111 void test_builtin_ppc_fetch_and_addlp(long a
, long b
) {
112 __fetch_and_addlp(&a
, b
); // expected-error {{this builtin is only available on 64-bit targets}}
115 void test_builtin_ppc_fetch_and_andlp(unsigned long a
, unsigned long b
) {
116 __fetch_and_andlp(&a
, b
); // expected-error {{this builtin is only available on 64-bit targets}}
118 void test_builtin_ppc_fetch_and_orlp(unsigned long a
, unsigned long b
) {
119 __fetch_and_orlp(&a
, b
); // expected-error {{this builtin is only available on 64-bit targets}}
122 void test_builtin_ppc_fetch_and_swaplp(unsigned long a
, unsigned long b
) {
123 __fetch_and_swaplp(&a
, b
); // expected-error {{this builtin is only available on 64-bit targets}}
127 unsigned long test_mfspr(void) {
128 return __mfspr(cia
); //expected-error {{argument to '__builtin_ppc_mfspr' must be a constant integer}}
131 void test_mtspr(void) {
132 __mtspr(cia
, ula
); //expected-error {{argument to '__builtin_ppc_mtspr' must be a constant integer}}