134 lines · c
1// REQUIRES: powerpc-registered-target2// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -fsyntax-only \3// RUN: -Wall -Werror -verify %s4// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -fsyntax-only \5// RUN: -Wall -Werror -verify %s6// RUN: %clang_cc1 -triple powerpc64-unknown-aix -fsyntax-only \7// RUN: -Wall -Werror -verify %s8// RUN: %clang_cc1 -triple powerpc-unknown-aix -fsyntax-only \9// RUN: -Wall -Werror -verify %s10 11extern long long lla, llb;12extern int ia, ib;13extern unsigned int ui;14extern unsigned long long ull;15extern const int cia;16extern unsigned long ula;17 18void 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#endif23 __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]}}25}26 27void 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}}33 res = __builtin_ppc_rldimi(ull, ull, 64, 0xFFFF000000000000); // expected-error {{argument value 64 is outside the valid range [0, 63]}}34}35 36void test_builtin_ppc_rlwimi() {37 unsigned int shift;38 unsigned int mask;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}}42}43 44void test_builtin_ppc_rlwnm() {45 unsigned int mask;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}}48}49 50extern unsigned int usi;51extern double d;52extern float f;53 54void 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]}}65}66 67unsigned 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 a69 // 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}}75}76 77void 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}}84}85 86#ifndef __PPC64__87long 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}}89}90 91long long testdivde(long long dividend, long long divisor) {92 return __divde(dividend, divisor); //expected-error {{this builtin is only available on 64-bit targets}}93}94 95unsigned 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}}97}98 99int test_darn() {100 return __darn(); //expected-error {{this builtin is only available on 64-bit targets}}101}102 103int test_darn_raw() {104 return __darn_raw(); //expected-error {{this builtin is only available on 64-bit targets}}105}106 107int 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}}109}110 111void 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}}113}114 115void 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}}117}118void 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}}120}121 122void 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}}124}125#endif126 127unsigned long test_mfspr(void) {128 return __mfspr(cia); //expected-error {{argument to '__builtin_ppc_mfspr' must be a constant integer}}129}130 131void test_mtspr(void) {132 __mtspr(cia, ula); //expected-error {{argument to '__builtin_ppc_mtspr' must be a constant integer}}133}134