diff options
Diffstat (limited to 'gcc/testsuite/gcc.apple')
108 files changed, 5134 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.apple/Wextra-tokens.c b/gcc/testsuite/gcc.apple/Wextra-tokens.c new file mode 100644 index 00000000000..08b3cb7745c --- /dev/null +++ b/gcc/testsuite/gcc.apple/Wextra-tokens.c @@ -0,0 +1,21 @@ +/* APPLE LOCAL file -Wextra-tokens */ +/* Lifted from gcc.dg/cpp/extratokens2.c. */ +/* Copyright (C) 2002 Free Software Foundation, Inc. */ + +/* { dg-do preprocess } */ +/* { dg-options "-fno-show-column -Wextra-tokens" } */ + +/* Tests that -Wextra-tokens correctly enables the checks + that are disabled by default. */ + +#if 1 +#if 0 +#else foo /* { dg-warning "extra tokens" "bad warning" } */ +#endif / /* { dg-warning "extra tokens" "bad warning" } */ +#endif + +# 36 "file.c" 3 + +/* ... but in a system header, it's acceptable. */ +#ifdef KERNEL +#endif KERNEL /* { dg-bogus "extra tokens" "bad warning" } */ diff --git a/gcc/testsuite/gcc.apple/Wfour-char-constants-1.c b/gcc/testsuite/gcc.apple/Wfour-char-constants-1.c new file mode 100644 index 00000000000..536396454b7 --- /dev/null +++ b/gcc/testsuite/gcc.apple/Wfour-char-constants-1.c @@ -0,0 +1,12 @@ +/* APPLE LOCAL file -Wfour-char-constants */ +/* We warn by default on Darwin, so no specific option needed. */ + +/* { dg-do compile { target "*-*-darwin*" } } */ +/* { dg-options "" } */ + +int glob1 = 'a'; +int glob2 = 'ab'; /* { dg-warning "multi-character character constant" } */ +int glob3 = 'abc'; /* { dg-warning "multi-character character constant" } */ +int glob4 = 'abcd'; /* say nothing */ +int glob5 = 'abcde'; /* { dg-warning "character constant too long" } */ + diff --git a/gcc/testsuite/gcc.apple/Wfour-char-constants-2.c b/gcc/testsuite/gcc.apple/Wfour-char-constants-2.c new file mode 100644 index 00000000000..14115ba6fea --- /dev/null +++ b/gcc/testsuite/gcc.apple/Wfour-char-constants-2.c @@ -0,0 +1,12 @@ +/* APPLE LOCAL file -Wfour-char-constants */ +/* Explicitly enable the warning. */ + +/* { dg-do compile } */ +/* { dg-options "-Wfour-char-constants" } */ + +int glob1 = 'a'; +int glob2 = 'ab'; /* { dg-warning "multi-character character constant" } */ +int glob3 = 'abc'; /* { dg-warning "multi-character character constant" } */ +int glob4 = 'abcd'; /* { dg-warning "multi-character character constant" } */ +int glob5 = 'abcde'; /* { dg-warning "character constant too long" } */ + diff --git a/gcc/testsuite/gcc.apple/Wmost.c b/gcc/testsuite/gcc.apple/Wmost.c new file mode 100644 index 00000000000..6e1d3342539 --- /dev/null +++ b/gcc/testsuite/gcc.apple/Wmost.c @@ -0,0 +1,19 @@ +/* APPLE LOCAL file -Wmost */ + +/* { dg-do compile } */ +/* { dg-options "-Wmost" } */ + +int baz (void); + +int +foo () +{ + int loc; + + bar (); /* { dg-warning "implicit declaration" } */ + + if (loc = baz ()) /* be quiet about this */ + return 1; + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/Wno-newline-1.c b/gcc/testsuite/gcc.apple/Wno-newline-1.c new file mode 100644 index 00000000000..44eab6e533c --- /dev/null +++ b/gcc/testsuite/gcc.apple/Wno-newline-1.c @@ -0,0 +1,3 @@ +/* Test no newline at eof warning. */ +/* { dg-do compile } */ +int main() { return 0; }
\ No newline at end of file diff --git a/gcc/testsuite/gcc.apple/Wno-newline-2.c b/gcc/testsuite/gcc.apple/Wno-newline-2.c new file mode 100644 index 00000000000..74acf1afa68 --- /dev/null +++ b/gcc/testsuite/gcc.apple/Wno-newline-2.c @@ -0,0 +1,4 @@ +/* Test no newline at eof warning. */ +/* { dg-do compile } */ +/* { dg-options "-Wnewline-eof" } */ +int main() { return 0; } /* { dg-warning "no newline" } */
\ No newline at end of file diff --git a/gcc/testsuite/gcc.apple/align-test-1.c b/gcc/testsuite/gcc.apple/align-test-1.c new file mode 100644 index 00000000000..e8493c0e260 --- /dev/null +++ b/gcc/testsuite/gcc.apple/align-test-1.c @@ -0,0 +1,613 @@ +/* APPLE LOCAL file Macintosh alignment */ + +/* { dg-do run } */ +/* { dg-options "-Wno-long-long" } */ + +/* + * Macintosh compiler alignment test for C. + * Fred Forsman + * Apple Computer, Inc. + */ + +#include <stdio.h> +#include <stddef.h> +#include <string.h> + +#define Q(x) #x, x + +typedef unsigned char UINT8; + +static int bad_option = 0; +static int flag_verbose = 0; +static int nbr_failures = 0; + +/* === basic types === */ + +typedef struct B1 { + char f1; + UINT8 f2; +} B1; + +typedef struct B2 { + short f1; + UINT8 f2; +} B2; + +typedef struct B3 { + long f1; + UINT8 f2; +} B3; + +typedef struct B4 { + int f1; + UINT8 f2; +} B4; + +typedef struct B5 { + float f1; + UINT8 f2; +} B5; + +/* doubles, long longs, and vectors are treated separately below. */ + +/* === enums === */ + +typedef enum E1 { + e1_b = 0, + e1_e = 255 +} E1; + +typedef enum E2 { + e2_b = -256, + e2_e = 255 +} E2; + +typedef enum E3 { + e3_b = 0, + e3_e = 32767 +} E3; + +typedef enum E4 { + e4_b = 0, + e4_e = 65536 +} E4; + +/* === pointers === */ + +typedef struct P1 { + char * f1; + UINT8 f2; +} P1; + +typedef struct P2 { + long * f1; + UINT8 f2; +} P2; + +typedef struct P3 { + double * f1; + UINT8 f2; +} P3; + +typedef struct P4 { + long long * f1; + UINT8 f2; +} P4; + +typedef struct P5 { + void (* f1) (void); + UINT8 f2; +} P5; + +#ifdef __VEC__ +typedef struct P61 { + vector signed short * f1; + UINT8 f2; +} P6; +#endif + +/* === vectors === */ + +#ifdef __VEC__ +typedef struct V1 { + vector signed short f1; + UINT8 f2; +} V1; + +typedef struct V2 { + V1 f1; + UINT8 f2; +} V2; + +typedef struct V3 { + UINT8 f1; + vector signed short f2; +} V3; + +typedef struct V4 { + V3 f1; + UINT8 f2; +} V4; +#endif + +/* === doubles === */ + +typedef struct D1 { + double f1; + UINT8 f2; +} D1; + +typedef struct D2 { + D1 f1; + UINT8 f2; +} D2; + +typedef struct D3 { + UINT8 f1; + double f2; +} D3; + +typedef struct D4 { + D3 f1; + UINT8 f2; +} D4; + +typedef struct D5 { + UINT8 f1; + D3 f2; +} D5; + +typedef struct D6 { + double f1; + UINT8 f2; + double f3; +} D6; + +typedef struct D7 { + UINT8 f1; + D1 f2; +} D7; + +/* === long longs === */ + +typedef struct LL1 { + long long f1; + UINT8 f2; +} LL1; + +typedef struct LL2 { + LL1 f1; + UINT8 f2; +} LL2; + +typedef struct LL3 { + UINT8 f1; + long long f2; +} LL3; + +typedef struct LL4 { + LL3 f1; + UINT8 f2; +} LL4; + +typedef struct LL5 { + UINT8 f1; + LL3 f2; +} LL5; + +/* === arrays === */ + +typedef struct A1 { + short f1[4]; + UINT8 f2; +} A1; + +typedef struct A2 { + A1 f1; + UINT8 f2; +} A2; + +typedef struct A3 { + double f1[4]; + UINT8 f2; +} A3; + +typedef struct A4 { + A3 f1; + UINT8 f2; +} A4; + +typedef struct A5 { + long long f1[4]; + UINT8 f2; +} A5; + +typedef struct A6 { + A5 f1; + UINT8 f2; +} A6; + +#ifdef __VEC__ +typedef struct A7 { + vector signed short f1[4]; + UINT8 f2; +} A7; + +typedef struct A8 { + A7 f1; + UINT8 f2; +} A8; +#endif + +typedef struct A9 { + D1 f1[4]; + UINT8 f2; +} A9; + +typedef struct A10 { + A9 f1; + UINT8 f2; +} A10; + +/* === unions === */ + +typedef union U1 { + UINT8 f1; + double f2; +} U1; + +typedef struct U2 { + U1 f1; + UINT8 f2; +} U2; + +typedef union U3 { + UINT8 f1; + long long f2; +} U3; + +typedef struct U4 { + U3 f1; + UINT8 f2; +} U4; + +#ifdef __VEC__ +typedef union U5 { + UINT8 f1; + vector signed short f2; +} U5; + +typedef struct U6 { + U5 f1; + UINT8 f2; +} U6; +#endif + +typedef union U7 { + UINT8 f1; + short f2[4]; +} U7; + +typedef struct U8 { + U7 f1; + UINT8 f2; +} U8; + +/* === misc === */ + +typedef struct { /* unnamed struct */ + long long f1; + UINT8 f2; +} M0; + +typedef struct M1 { + UINT8 f1[8]; +} M1; + +typedef struct M2 { + M1 f1; + UINT8 f2; +} M2; + +typedef struct M3 { + UINT8 f1; + M1 f2; +} M3; + +typedef struct M4 { /* M4 & M5: see corresponding mac68k tests (M68K11 & M68K12) */ + UINT8 f1[9]; +} M4; + +typedef struct M5 { + UINT8 f1; + M4 f2; +} M5; + +/* === mac68k === */ + +#ifndef __LP64__ +#pragma options align=mac68k + +typedef struct M68K0 { + long f1; + UINT8 f2; +} M68K0; + +typedef struct M68K1 { + double f1; + UINT8 f2; +} M68K1; + +#pragma options align=reset + +typedef struct M68K2 { + M68K1 f1; + UINT8 f2; +} M68K2; + +#ifdef __VEC__ +#pragma options align=mac68k + +typedef struct M68K3 { + vector signed short f1; + UINT8 f2; +} M68K3; + +typedef struct M68K4 { + M68K3 f1; + UINT8 f2; +} M68K4; + +#pragma options align=reset + +typedef struct M68K5 { + M68K3 f1; + UINT8 f2; +} M68K5; + +#pragma options align=mac68k + +typedef struct M68K6 { + UINT8 f1; + vector signed short f2; +} M68K6; + +#pragma options align=reset +#endif /* __VEC__ */ + +#pragma options align=mac68k + +typedef struct M68K7 { + UINT8 f1; +} M68K7; + +typedef union M68K8 { + UINT8 f1; +} M68K8; + +typedef struct M68K9 { + UINT8 f1; + int f2; + UINT8 f3; +} M68K9; + +#pragma options align=reset + +typedef struct M68K10 { + UINT8 f1; + M68K9 f2; +} M68K10; + +#pragma options align=mac68k + +typedef struct M68K11 { /* M68K11 & M68K12: see corresponding power tests (M4 & M5) */ + UINT8 f1[9]; +} M68K11; + +typedef struct M68K12 { + UINT8 f1; + M68K11 f2; +} M68K12; + +typedef struct M68K13 { + UINT8 f1; + UINT8 f2[5]; +} M68K13; + +#pragma options align=reset +#endif /* n __LP64__ */ + +static void check(char * rec_name, int actual, int expected32, int expected64, + int expected_ia32, char * comment) +{ + int expected; +#ifdef __i386__ + expected = expected_ia32; +#else + expected = ((sizeof(char *) == 8) ? expected64 : expected32); +#endif + if (flag_verbose || (actual != expected)) { + printf("%-20s = %2d (%2d) ", rec_name, actual, expected); + if (actual != expected) { + printf("*** FAIL"); + nbr_failures++; + } else + printf(" PASS"); + printf(": %s\n", comment); + } +} + +static void check_option(char *option) +{ + if (*option == '-') { + if (strcmp(option, "-v") == 0) + flag_verbose = 1; + else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } + } else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } +} + +int main(int argc, char *argv[]) +{ + int i; + + for (i = 1; i < argc; i++) + check_option(argv[i]); + + if (bad_option) + return 1; + + /* === basic data types === */ + + check(Q(sizeof(char)), 1, 1, 1, "char data type"); + check(Q(sizeof(signed char)), 1, 1, 1, "signed char data type"); + check(Q(sizeof(unsigned char)), 1, 1, 1, "unsigned char data type"); + check(Q(sizeof(short)), 2, 2, 2, "short data type"); + check(Q(sizeof(signed short)), 2, 2, 2, "signed short data type"); + check(Q(sizeof(unsigned short)), 2, 2, 2, "unsigned short data type"); + check(Q(sizeof(long)), 4, 8, 4, "short long type"); + check(Q(sizeof(signed long)), 4, 8, 4, "signed long data type"); + check(Q(sizeof(unsigned long)), 4, 8, 4, "unsigned long data type"); + check(Q(sizeof(int)), 4, 4, 4, "short int type"); + check(Q(sizeof(signed int)), 4, 4, 4, "signed int data type"); + check(Q(sizeof(unsigned int)), 4, 4, 4, "unsigned int data type"); + check(Q(sizeof(float)), 4, 4, 4, "float type"); + check(Q(sizeof(double)), 8, 8, 8, "double data type"); + check(Q(sizeof(long long)), 8, 8, 8, "long long data type"); + check(Q(sizeof(signed long long)), 8, 8, 8, "signed long long data type"); + check(Q(sizeof(unsigned long long)), 8, 8, 8, "unsigned long long data type"); + + check(Q(sizeof(B1)), 2, 2, 2, "char as 1st field"); + check(Q(sizeof(B2)), 4, 4, 4, "short as 1st field"); + check(Q(sizeof(B3)), 8, 16, 8, "long as 1st field"); + check(Q(sizeof(B4)), 8, 8, 8, "int as 1st field"); + check(Q(sizeof(B5)), 8, 8, 8, "float as 1st field"); + + /* === enums === */ + + check(Q(sizeof(E1)), 4, 4, 4, "enum with range 0..255"); + check(Q(sizeof(E2)), 4, 4, 4, "enum with range -256..255"); + check(Q(sizeof(E3)), 4, 4, 4, "enum with range 0..32767"); + check(Q(sizeof(E4)), 4, 4, 4, "enum with range 0..65536"); + + /* === pointers === */ + + check(Q(sizeof(P1)), 8, 16, 8, "char * as 1st field"); + check(Q(sizeof(P2)), 8, 16, 8, "long * as 1st field"); + check(Q(sizeof(P3)), 8, 16, 8, "double * as 1st field"); + check(Q(sizeof(P4)), 8, 16, 8, "long long * as 1st field"); + check(Q(sizeof(P5)), 8, 16, 8, "function * as 1st field"); + +#ifdef __VEC__ + check(Q(sizeof(P6)), 8, 16, 8, "vector signed short * as 1st field"); +#endif + +#ifdef __VEC__ + /* === vectors === */ + + /* ??? Do we want to test all the possible vector data types? ??? */ + check(Q(sizeof(vector signed short)), 16, 16, 16, "vector signed short data type"); + + check(Q(sizeof(V1)), 32, 32, 32, "vector as 1st field"); + check(Q(sizeof(V2)), 48, 48, 48, "embedding struct with vector as 1st field"); + check(Q(sizeof(V3)), 32, 32, 32, "vector as 2nd field"); + check(Q(offsetof(V3, f2)), 16, 16, 16, "offset of vector as 2nd field"); + check(Q(sizeof(V4)), 48, 48, 48, "embedding struct with vector as 2nd field"); +#endif + + /* === doubles === */ + + check(Q(sizeof(D1)), 16, 16, 12, "double as 1st field"); + check(Q(sizeof(D2)), 24, 24, 16, "embedding struct with double as 1st field"); + check(Q(sizeof(D3)), 12, 16, 12, "double as 2nd field"); + check(Q(offsetof(D3, f2)), 4, 8, 4, "offset of double as 2nd field"); + check(Q(sizeof(D4)), 16, 24, 16, "embedding struct with double as 2nd field"); + check(Q(sizeof(D5)), 16, 24, 16, "struct with double as 2nd field"); + check(Q(offsetof(D5, f2)), 4, 8, 4, "offset of struct with double as 2nd field"); + check(Q(sizeof(D6)), 24, 24, 20, "struct with double, char, double"); + check(Q(offsetof(D6, f3)), 12, 16, 12, "offset of 2nd double in struct with double, char, double"); + check(Q(sizeof(D7)), 20, 24, 16, "struct with double as 2nd field of another struct"); + check(Q(offsetof(D7, f2)), 4, 8, 4, "offset of struct with double as 2nd field of another struct"); + + /* === long longs === */ + + check(Q(sizeof(LL1)), 16, 16, 12, "long long as 1st field"); + check(Q(sizeof(LL2)), 24, 24, 16, "embedding struct with long long as 1st field"); + check(Q(sizeof(LL3)), 12, 16, 12, "long long as 2nd field"); + check(Q(offsetof(LL3, f2)), 4, 8, 4, "offset of long long as 2nd field"); + check(Q(sizeof(LL4)), 16, 24, 16, "embedding struct with long long as 2nd field"); + check(Q(sizeof(LL5)), 16, 24, 16, "struct with long long as 2nd field"); + check(Q(offsetof(LL5, f2)), 4, 8, 4, "offset of struct with long long as 2nd field"); + + /* === arrays === */ + + check(Q(sizeof(A1)), 10, 10, 10, "array of shorts as 1st field"); + check(Q(sizeof(A2)), 12, 12, 12, "embedding struct with array of shorts as 1st field"); + check(Q(sizeof(A3)), 40, 40, 36, "array of doubles as 1st field"); + check(Q(sizeof(A4)), 48, 48, 40, "embedding struct with array of doubles as 1st field"); + check(Q(sizeof(A5)), 40, 40, 36, "array of long longs as 1st field"); + check(Q(sizeof(A6)), 48, 48, 40, "embedding struct with array of long longs as 1st field"); +#ifdef __VEC__ + check(Q(sizeof(A7)), 80, 80, 80, "array of vectors as 1st field"); + check(Q(sizeof(A8)), 96, 96, 96, "embedding struct with array of vectors as 1st field"); +#endif + check(Q(sizeof(A9)), 72, 72, 52, "array of structs as 1st field"); + check(Q(sizeof(A10)), 80, 80, 56, "embedding struct with array of structs as 1st field"); + + /* === unions === */ + + check(Q(sizeof(U1)), 8, 8, 8, "union with double"); + check(Q(sizeof(U2)), 16, 16, 12, "embedding union with double"); + check(Q(sizeof(U3)), 8, 8, 8, "union with long long"); + check(Q(sizeof(U4)), 16, 16, 12, "embedding union with long long"); +#if __VEC__ + check(Q(sizeof(U5)), 16, 16, 16, "union with vector"); + check(Q(sizeof(U6)), 32, 32, 32, "embedding union with vector"); +#endif + check(Q(sizeof(U7)), 8, 8, 8, "union with array of shorts"); + check(Q(sizeof(U8)), 10, 10, 10, "embedding union with array of shorts"); + + /* === misc === */ + + check(Q(sizeof(M0)), 16, 16, 12, "untagged struct with long long as 1st field"); + check(Q(sizeof(M1)), 8, 8, 8, "array[8] of char"); + check(Q(sizeof(M2)), 9, 9, 9, "embedding struct with array[8] of char as 1st field"); + check(Q(sizeof(M3)), 9, 9, 9, "embedding struct with array[8] of char as 2nd field"); + check(Q(offsetof(M3, f2)), 1, 1, 1, "offset of struct with array[8] of char as 2nd field"); + check(Q(sizeof(M4)), 9, 9, 9, "odd size struct: array[9] of char"); + check(Q(sizeof(M5)), 10, 10, 10, "embedding odd size struct"); + + /* === mac68k mode === */ + +#ifndef __LP64__ + check(Q(sizeof(M68K0)), 6, 6, 6, "mac68k struct with long"); + check(Q(sizeof(M68K1)), 10, 10, 10, "mac68k struct with double as 1st field"); + check(Q(sizeof(M68K2)), 12, 12, 12, "embedding mac68k struct with double as 1st field"); +#ifdef __VEC__ + check(Q(sizeof(M68K3)), 32, 32, 32, "mac68k struct with vector as 1st field"); + check(Q(sizeof(M68K4)), 48, 48, 48, "embedding mac68k struct with vector as 1st field in a mac68k struct"); + check(Q(sizeof(M68K5)), 48, 48, 48, "embedding mac68k struct with vector as 1st field in a power struct"); + check(Q(offsetof(M68K6, f2)), 16, 16, 16, "offset of vector as 2nd field in a mac68k struct"); +#endif + check(Q(sizeof(M68K7)), 2, 2, 2, "padding of mac68k struct with one char"); + check(Q(sizeof(M68K8)), 2, 2, 2, "padding of mac68k union with one char"); + check(Q(sizeof(M68K9)), 8, 8, 8, "padding of mac68k struct"); + check(Q(offsetof(M68K9, f2)), 2, 2, 2, "offset of int as 2nd field in a mac68k struct"); + check(Q(sizeof(M68K10)), 10, 10, 10, "power struct with embedded mac68k struct"); + check(Q(offsetof(M68K10, f2)), 2, 2, 2, "offset of mac68k struct as 2nd field in a power struct"); + check(Q(sizeof(M68K11)), 10, 10, 10, "odd size struct (before padding): array[9] of char"); + check(Q(sizeof(M68K12)), 12, 12, 12, "embedding odd size struct (before padding)"); + check(Q(sizeof(M68K13)), 6, 6, 6, "array of char at odd addr in mac68k struct"); + check(Q(offsetof(M68K13, f2)), 1, 1, 1, "offset of array of char at odd addr in mac68k struct"); +#endif + + if (nbr_failures > 0) + return 1; + else + return 0; +} diff --git a/gcc/testsuite/gcc.apple/align-test-2.c b/gcc/testsuite/gcc.apple/align-test-2.c new file mode 100644 index 00000000000..c78b8e390a4 --- /dev/null +++ b/gcc/testsuite/gcc.apple/align-test-2.c @@ -0,0 +1,163 @@ +/* APPLE LOCAL file Macintosh alignment */ + +/* { dg-do run } */ +/* { dg-options "-Wno-long-long" } */ + +/* + * Macintosh compiler alignment test for alignment extensions in GCC 3. + * Fred Forsman + * Apple Computer, Inc. + */ + + /* Check whether we are testing GCC 3 or later. */ +#ifdef __GNUC__ +#if __GNUC__ >= 3 + #define GCC3 1 +#endif +#endif + +#include <stdio.h> +#include <stddef.h> +#include <string.h> + +#define Q(x) #x, x + +typedef unsigned char UINT8; +typedef unsigned long UINT32; + +static int bad_option = 0; +static int flag_verbose = 0; +static int nbr_failures = 0; + +/* === alignment modes === */ + +typedef struct S1 { + UINT8 f1; +} S1; + +#ifndef __LP64__ +#pragma options align=mac68k + +typedef struct S2 { + UINT8 f1; +} S2; +#endif + +#pragma options align=native + +typedef struct S3 { + UINT8 f1; +} S3; + +#pragma options align=reset +/* Should be mac68k mode here. */ + +#ifndef __LP64__ +#pragma options align=reset +#endif +/* Should be power mode here. */ + +typedef struct S4 { + UINT8 f1; + double f2; +} S4; + +#pragma options align=natural + +typedef struct S5 { + UINT8 f1; + double f2; +} S5; + +typedef struct S6 { + UINT8 f1; + double f2; + UINT8 f3; +} S6; + +#pragma options align=reset +/* Should be power mode here. */ + +#pragma options align=packed + +typedef struct S7 { + UINT8 f1; + UINT32 f2; +} S7; + +#pragma options align=reset +/* Should be power mode here. */ + +typedef struct S8 { + UINT8 f1; + UINT32 f2; +} S8; + +static void check(char * rec_name, int actual, int expected32, int expected64, + int expected_ia32, char * comment) +{ + int expected; +#ifdef __i386__ + expected = expected_ia32; +#else + expected = ((sizeof(char *) == 8) ? expected64 : expected32); +#endif + if (flag_verbose || (actual != expected)) { + printf("%-20s = %2d (%2d) ", rec_name, actual, expected); + if (actual != expected) { + printf("*** FAIL"); + nbr_failures++; + } else + printf(" PASS"); + printf(": %s\n", comment); + } +} + +static void check_option(char *option) +{ + if (*option == '-') { + if (strcmp(option, "-v") == 0) + flag_verbose = 1; + else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } + } else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } +} + +int main(int argc, char *argv[]) +{ + int i; + + for (i = 1; i < argc; i++) + check_option(argv[i]); + + if (bad_option) + return 1; + +#ifndef GCC3 + printf("This test requires GCC 3"); + return 1; +#endif + + check(Q(sizeof(S1)), 1, 1, 1, "struct with 1 char; power mode"); +#ifndef __LP64__ + check(Q(sizeof(S2)), 2, 2, 2, "struct with 1 char; mac68k mode"); +#endif + check(Q(sizeof(S3)), 1, 1, 1, "struct with 1 char; native mode"); + check(Q(sizeof(S4)), 12, 16, 12, "struct with char, double; power/natural mode"); + check(Q(offsetof(S4, f2)), 4, 8, 4, "offset of double in a struct with char, double; power/natural mode"); + check(Q(sizeof(S5)), 16, 16, 12, "struct with char, double; natural mode"); + check(Q(offsetof(S5, f2)), 8, 8, 4, "offset of double in a struct with char, double; natural mode"); + check(Q(sizeof(S6)), 24, 24, 16, "struct with char, double, char; natural mode"); + check(Q(sizeof(S7)), 5, 9, 5, "struct with char, long; packed mode"); + check(Q(sizeof(S8)), 8, 16, 8, "struct with char, long; power/natural mode"); + + if (nbr_failures > 0) + return 1; + else + return 0; +} diff --git a/gcc/testsuite/gcc.apple/align-test-3.c b/gcc/testsuite/gcc.apple/align-test-3.c new file mode 100644 index 00000000000..ef806238508 --- /dev/null +++ b/gcc/testsuite/gcc.apple/align-test-3.c @@ -0,0 +1,136 @@ +/* APPLE LOCAL file Macintosh alignment */ + +/* { dg-do run } */ +/* { dg-options "-Wno-long-long" } */ + +/* + * GCC alignment test for alignment problems due to interactions + * between FSF and Macintosh alignment modes. + * Fred Forsman + * Apple Computer, Inc. + */ + +#ifdef __LP64__ +int main() +{ + return 0; +} +#else /* 32-bit */ + + /* Check whether we are testing GCC 3 or later. */ +#ifdef __GNUC__ +#if __GNUC__ >= 3 +#define GCC3 1 +#else +#define GCC3 0 +#endif +#endif + +#include <stdio.h> +#include <stddef.h> +#include <string.h> + +#define Q(x) #x, x + +typedef unsigned char UINT8; +typedef unsigned long UINT32; + +static int bad_option = 0; +static int flag_verbose = 0; +static int nbr_failures = 0; + +/* === alignment modes === */ + +#pragma options align=power +#pragma options align=mac68k +#pragma pack(1) + +typedef struct S0 { + UINT32 f1; + UINT8 f2; +} S0; + +#pragma options align=reset + +/* We should be back in mac68k alignment, if #pragma option align=reset + can rest a #pragma pack(n). So check for mac68k alignment. */ + +typedef struct S1 { + UINT32 f1; + UINT8 f2; +} S1; + +#if GCC3 +#pragma options align=power +#pragma options align=mac68k +//#pragma pack(push, 1) +//#pragma pack(pop) +#pragma pack(1) +#pragma pack() + +/* We should be back in mac68k alignment, if #pragma pack() + can reset a #pragma pack(n). So check for mac68k alignment. */ + +typedef struct S2 { + UINT32 f1; + UINT8 f2; +} S2; +#endif /* GCC3 */ + +static void check(char * rec_name, int actual, int expected_ppc32, int expected_ia32, char * comment) +{ + int expected; +#ifdef __i386__ + expected = expected_ia32; +#else + expected = expected_ppc32; +#endif + if (flag_verbose || (actual != expected)) { + printf("%-20s = %2d (%2d) ", rec_name, actual, expected); + if (actual != expected) { + printf("*** FAIL"); + nbr_failures++; + } else + printf(" PASS"); + printf(": %s\n", comment); + } +} + +static void check_option(char *option) +{ + if (*option == '-') { + if (strcmp(option, "-v") == 0) + flag_verbose = 1; + else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } + } else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } +} + +int main(int argc, char *argv[]) +{ + int i; + + for (i = 1; i < argc; i++) + check_option(argv[i]); + + if (bad_option) + return 1; + + check(Q(sizeof(S0)), 5, 5, "struct with 1 long, 1 char; pack(1) mode"); + check(Q(sizeof(S1)), 6, 6, "struct with 1 long, 1 char; should be mac68k mode"); +#if GCC3 + check(Q(sizeof(S2)), 6, 6, "struct with 1 long, 1 char; should be mac68k mode"); +#endif + + if (nbr_failures > 0) + return 1; + else + return 0; +} + +#endif /* 32-bit */ diff --git a/gcc/testsuite/gcc.apple/align-test-4.c b/gcc/testsuite/gcc.apple/align-test-4.c new file mode 100644 index 00000000000..dec805161f4 --- /dev/null +++ b/gcc/testsuite/gcc.apple/align-test-4.c @@ -0,0 +1,233 @@ +/* APPLE LOCAL file Macintosh alignment */ + +/* { dg-do run } */ +/* { dg-options "-Wno-long-long" } */ + +/* + * GCC alignment test for bit-fields. + * This came up initially as an alignment problem in the kernel. + * Fred Forsman + * Apple Computer, Inc. + */ + + /* Check whether we are testing GCC 3 or later. */ +#ifdef __GNUC__ +#if __GNUC__ >= 3 +#define GCC3 1 +#else +#define GCC3 0 +#endif +#endif + +#include <stdio.h> +#include <stddef.h> +#include <string.h> + +/* + * The following defined determines whether we should compare against + * the values produced by GCC 2.95 or against the values I expect given + * my understanding of the alignment rules. + */ +#define USE_GCC2_VALUES 1 + +#define NAME2(name,mode) mode##_##name +#define NAME(name,mode) NAME2(name,mode) + +#define STR(s) #s +#define SIZEOF3(name) STR(sizeof(name)), sizeof(name) +#define SIZEOF2(name,mode) SIZEOF3(mode##_##name) +#define SIZEOF(name,mode) SIZEOF2(name,mode) + +#define OFFSETOF3(name,field) STR(offsetof(name,field)), offsetof(name,field) +#define OFFSETOF2(name,mode,field) OFFSETOF3(mode##_##name,field) +#define OFFSETOF(name,mode,field) OFFSETOF2(name,mode,field) + +typedef unsigned char UINT8; +typedef unsigned long UINT32; + +static int bad_option = 0; +static int flag_verbose = 0; +static int nbr_failures = 0; + +/* === mac68k alignment problem in kernel === */ + +typedef unsigned PEF_UBits32, ByteCount; +typedef short SInt16; + +/* === power === */ +#pragma options align=power +#define MODE power +#include "align-test-4.h" + +#ifndef __LP64__ +/* === mac68k === */ +#pragma options align=mac68k +#undef MODE +#define MODE mac68k +#include "align-test-4.h" +#endif + +/* === pack(2) === */ +#pragma pack(2) +#undef MODE +#define MODE pack2 +#include "align-test-4.h" + + +static void check(char * rec_name, int actual, int expected32, int expected64, + int expected_ia32, char * comment) +{ + int expected; +#ifdef __i386__ + expected = expected_ia32; +#else + expected = ((sizeof(char *) == 8) ? expected64 : expected32); +#endif + if (flag_verbose || (actual != expected)) { + printf("%-30s = %2d (%2d) ", rec_name, actual, expected); + if (actual != expected) { + printf("*** FAIL"); + nbr_failures++; + } else + printf(" PASS"); + printf(": %s\n", comment); + } +} + +static void check_option(char *option) +{ + if (*option == '-') { + if (strcmp(option, "-v") == 0) + flag_verbose = 1; + else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } + } else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } +} + +int main(int argc, char *argv[]) +{ + int i; + + for (i = 1; i < argc; i++) + check_option(argv[i]); + + if (bad_option) + return 1; + +#undef MODE +#define MODE power + +#if USE_GCC2_VALUES + check(SIZEOF(LoaderExport, MODE), 12, 12, 12, "kernel struct"); + check(OFFSETOF(LoaderExport, MODE, offset), 4, 4, 4, "offset of offset"); + check(OFFSETOF(LoaderExport, MODE, sectionNumber), 8, 8, 8, "offset of sectionNumber"); + check(SIZEOF(S1, MODE), 8, 8, 8, "bitfields & char"); + check(SIZEOF(S2, MODE), 8, 8, 8, "int & char"); + check(SIZEOF(S3, MODE), 12, 12, 12, "char, bitfields(32), char"); + check(OFFSETOF(S3, MODE, f3), 8, 8, 8, "offset of 2nd char"); + check(SIZEOF(S4, MODE), 8, 8, 8, "char, bitfields(32), char"); + check(OFFSETOF(S4, MODE, f3), 7, 7, 7, "offset of 2nd char"); + check(SIZEOF(S5, MODE), 4, 4, 4, "char, bitfields(16), char"); + check(OFFSETOF(S5, MODE, f3), 3, 3, 3, "offset of 2nd char"); + check(SIZEOF(S6, MODE), 4, 4, 4, "char, bitfields(8), char"); + check(OFFSETOF(S6, MODE, f3), 2, 2, 2, "offset of 2nd char"); +#else + check(SIZEOF(LoaderExport, MODE), 12, 12, "kernel struct"); + check(OFFSETOF(LoaderExport, MODE, offset), 4, 4, "offset of offset"); + check(OFFSETOF(LoaderExport, MODE, sectionNumber), 8, 8, "offset of sectionNumber"); + check(SIZEOF(S1, MODE), 8, 8, "bitfields & char"); + check(SIZEOF(S2, MODE), 8, 8, "int & char"); + check(SIZEOF(S3, MODE), 12, 12, "char, bitfields(32), char"); + check(OFFSETOF(S3, MODE, f3), 8, 8, "offset of 2nd char"); + check(SIZEOF(S4, MODE), 12, 12, "char, bitfields(32), char"); + check(OFFSETOF(S4, MODE, f3), 8, 8, "offset of 2nd char"); + check(SIZEOF(S5, MODE), 12, 12, "char, bitfields(16), char"); + check(OFFSETOF(S5, MODE, f3), 8, 8, "offset of 2nd char"); + check(SIZEOF(S6, MODE), 12, 12, "char, bitfields(8), char"); + check(OFFSETOF(S6, MODE, f3), 8, 8, "offset of 2nd char"); +#endif + +#ifndef __LP64__ +#undef MODE +#define MODE mac68k + +#if USE_GCC2_VALUES + check(SIZEOF(LoaderExport, MODE), 10, 10, 10, "kernel struct"); + check(OFFSETOF(LoaderExport, MODE, offset), 4, 4, 4, "offset of offset"); + check(OFFSETOF(LoaderExport, MODE, sectionNumber), 8, 8, 8, "offset of sectionNumber"); +#if 1 + // GCC 2 is wrong on the following. + check(SIZEOF(S1, MODE), 6, 6, 6, "bitfields & char"); +#else + check(SIZEOF(S1, MODE), 8, 8, "bitfields & char"); +#endif + check(SIZEOF(S2, MODE), 6, 6, 6, "int & char"); + check(SIZEOF(S3, MODE), 6, 6, 6, "char, bitfields(32), char"); + check(OFFSETOF(S3, MODE, f3), 5, 5, 5, "offset of 2nd char"); + check(SIZEOF(S4, MODE), 6, 6, 6, "char, bitfields(32), char"); + check(OFFSETOF(S4, MODE, f3), 5, 5, 5, "offset of 2nd char"); + check(SIZEOF(S5, MODE), 4, 4, 4, "char, bitfields(16), char"); + check(OFFSETOF(S5, MODE, f3), 3, 3, 3, "offset of 2nd char"); + check(SIZEOF(S6, MODE), 4, 4, 4, "char, bitfields(8), char"); + check(OFFSETOF(S6, MODE, f3), 2, 2, 2, "offset of 2nd char"); +#else + check(SIZEOF(LoaderExport, MODE), 10, 10, "kernel struct"); + check(OFFSETOF(LoaderExport, MODE, offset), 4, 4, "offset of offset"); + check(OFFSETOF(LoaderExport, MODE, sectionNumber), 8, 8, "offset of sectionNumber"); + check(SIZEOF(S1, MODE), 6, 6, "bitfields & char"); + check(SIZEOF(S2, MODE), 6, 6, "int & char"); + check(SIZEOF(S3, MODE), 8, 8, "char, bitfields(32), char"); + check(OFFSETOF(S3, MODE, f3), 6, 6, "offset of 2nd char"); + check(SIZEOF(S4, MODE), 8, 8, "char, bitfields(32), char"); + check(OFFSETOF(S4, MODE, f3), 6, 6, "offset of 2nd char"); + check(SIZEOF(S5, MODE), 6, 6, "char, bitfields(16), char"); + check(OFFSETOF(S5, MODE, f3), 4, 4, "offset of 2nd char"); + check(SIZEOF(S6, MODE), 4, 4, "char, bitfields(8), char"); + check(OFFSETOF(S6, MODE, f3), 2, 2, "offset of 2nd char"); +#endif +#endif /* n __LP64__ */ + +#undef MODE +#define MODE pack2 + +#if USE_GCC2_VALUES + check(SIZEOF(LoaderExport, MODE), 10, 10, 10, "kernel struct"); + check(OFFSETOF(LoaderExport, MODE, offset), 4, 4, 4, "offset of offset"); + check(OFFSETOF(LoaderExport, MODE, sectionNumber), 8, 8, 8, "offset of sectionNumber"); + /* GCC2 used to have this as '8', but it should really be 6. */ + check(SIZEOF(S1, MODE), 6, 6, 6, "bitfields & char"); + check(SIZEOF(S2, MODE), 6, 6, 6, "int & char"); + check(SIZEOF(S3, MODE), 6, 6, 6, "char, bitfields(32), char"); + check(OFFSETOF(S3, MODE, f3), 5, 5, 5, "offset of 2nd char"); + check(SIZEOF(S4, MODE), 6, 6, 6, "char, bitfields(32), char"); + check(OFFSETOF(S4, MODE, f3), 5, 5, 5, "offset of 2nd char"); + check(SIZEOF(S5, MODE), 4, 4, 4, "char, bitfields(16), char"); + check(OFFSETOF(S5, MODE, f3), 3, 3, 3, "offset of 2nd char"); + check(SIZEOF(S6, MODE), 4, 4, 4, "char, bitfields(8), char"); + check(OFFSETOF(S6, MODE, f3), 2, 2, 2, "offset of 2nd char"); +#else + check(SIZEOF(LoaderExport, MODE), 10, 10, "kernel struct"); + check(OFFSETOF(LoaderExport, MODE, offset), 4, 4, "offset of offset"); + check(OFFSETOF(LoaderExport, MODE, sectionNumber), 8, 8, "offset of sectionNumber"); + check(SIZEOF(S1, MODE), 6, 6, "bitfields & char"); + check(SIZEOF(S2, MODE), 6, 6, "int & char"); + check(SIZEOF(S3, MODE), 8, 8, "char, bitfields(32), char"); + check(OFFSETOF(S3, MODE, f3), 6, 6, "offset of 2nd char"); + check(SIZEOF(S4, MODE), 8, 8, "char, bitfields(32), char"); + check(OFFSETOF(S4, MODE, f3), 6, 6, "offset of 2nd char"); + check(SIZEOF(S5, MODE), 6, 6, "char, bitfields(16), char"); + check(OFFSETOF(S5, MODE, f3), 4, 4, "offset of 2nd char"); + check(SIZEOF(S6, MODE), 4, 4, "char, bitfields(8), char"); + check(OFFSETOF(S6, MODE, f3), 2, 2, "offset of 2nd char"); +#endif + + if (nbr_failures > 0) + return 1; + else + return 0; +} diff --git a/gcc/testsuite/gcc.apple/align-test-4.h b/gcc/testsuite/gcc.apple/align-test-4.h new file mode 100644 index 00000000000..f7c18727fee --- /dev/null +++ b/gcc/testsuite/gcc.apple/align-test-4.h @@ -0,0 +1,43 @@ +/* APPLE LOCAL file Macintosh alignment */ + +typedef struct { + PEF_UBits32 symClass : 8; + PEF_UBits32 nameOffset : 24; + ByteCount offset; + SInt16 sectionNumber; +} NAME(LoaderExport, MODE); + +typedef struct { + unsigned f1 : 32; + char f2; +} NAME(S1, MODE); + +typedef struct { + unsigned f1; + char f2; +} NAME(S2, MODE); + +typedef struct { + char f1; + unsigned f2 : 32; + char f3; +} NAME(S3, MODE); + +typedef struct { + char f1; + unsigned f2_1 : 8; + unsigned f2_2 : 24; + char f3; +} NAME(S4, MODE); + +typedef struct { + char f1; + unsigned f2 : 16; + char f3; +} NAME(S5, MODE); + +typedef struct { + char f1; + unsigned f2 : 8; + char f3; +} NAME(S6, MODE); diff --git a/gcc/testsuite/gcc.apple/align-test-5a.c b/gcc/testsuite/gcc.apple/align-test-5a.c new file mode 100644 index 00000000000..10c7d8ad7c3 --- /dev/null +++ b/gcc/testsuite/gcc.apple/align-test-5a.c @@ -0,0 +1,87 @@ +/* APPLE LOCAL file Macintosh alignment */ +/* align-test-5*.c are all the same code but with different options. */ + +/* { dg-do run { target "powerpc-*-darwin*" } } */ +/* { dg-options "-malign-natural -DSIZE=16" } */ + +/* + * GCC alignment test for command line options for setting alignment modes. + * Fred Forsman + * Apple Computer, Inc. + * (C) 2000-2002. + * Last modified 2002-2-18. + * + */ + + /* Check whether we are testing GCC 3 or later. */ +#ifdef __GNUC__ +#if __GNUC__ >= 3 +#define GCC3 1 +#else +#define GCC3 0 +#endif +#endif + +#include <stdio.h> +#include <stddef.h> +#include <string.h> + +#define Q(x) #x, x + +typedef unsigned char UINT8; +typedef unsigned long UINT32; + +static int bad_option = 0; +static int flag_verbose = 0; +static int nbr_failures = 0; + +typedef struct S0 { + UINT8 f1; + double f2; +} S0; + +static void check(char * rec_name, int actual, int expected, char * comment) +{ + if (flag_verbose || (actual != expected)) { + printf("%-20s = %2d (%2d) ", rec_name, actual, expected); + if (actual != expected) { + printf("*** FAIL"); + nbr_failures++; + } else + printf(" PASS"); + printf(": %s\n", comment); + } +} + +static void check_option(char *option) +{ + if (*option == '-') { + if (strcmp(option, "-v") == 0) + flag_verbose = 1; + else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } + } else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } +} + +int main(int argc, char *argv[]) +{ + int i; + + for (i = 1; i < argc; i++) + check_option(argv[i]); + + if (bad_option) + return 1; + + check(Q(sizeof(S0)), SIZE, "struct with 1 char, 1 double"); + + if (nbr_failures > 0) + return 1; + else + return 0; +} diff --git a/gcc/testsuite/gcc.apple/align-test-5b.c b/gcc/testsuite/gcc.apple/align-test-5b.c new file mode 100644 index 00000000000..a44d8cb4d8f --- /dev/null +++ b/gcc/testsuite/gcc.apple/align-test-5b.c @@ -0,0 +1,87 @@ +/* APPLE LOCAL file Macintosh alignment */ +/* align-test-5*.c are all the same code but with different options. */ + +/* { dg-do run } */ +/* { dg-options "-malign-power -DSIZE=12" } */ + +/* We have a different test to pick up the warning from 64-bit case. */ +/* { dg-xfail-if "" { powerpc*-*-darwin* } { "-m64" } { "" } } */ + +/* + * GCC alignment test for command line options for setting alignment modes. + * Fred Forsman + * Apple Computer, Inc. + */ + + /* Check whether we are testing GCC 3 or later. */ +#ifdef __GNUC__ +#if __GNUC__ >= 3 +#define GCC3 1 +#else +#define GCC3 0 +#endif +#endif + +#include <stdio.h> +#include <stddef.h> +#include <string.h> + +#define Q(x) #x, x + +typedef unsigned char UINT8; +typedef unsigned long UINT32; + +static int bad_option = 0; +static int flag_verbose = 0; +static int nbr_failures = 0; + +typedef struct S0 { + UINT8 f1; + double f2; +} S0; + +static void check(char * rec_name, int actual, int expected, char * comment) +{ + if (flag_verbose || (actual != expected)) { + printf("%-20s = %2d (%2d) ", rec_name, actual, expected); + if (actual != expected) { + printf("*** FAIL"); + nbr_failures++; + } else + printf(" PASS"); + printf(": %s\n", comment); + } +} + +static void check_option(char *option) +{ + if (*option == '-') { + if (strcmp(option, "-v") == 0) + flag_verbose = 1; + else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } + } else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } +} + +int main(int argc, char *argv[]) +{ + int i; + + for (i = 1; i < argc; i++) + check_option(argv[i]); + + if (bad_option) + return 1; + + check(Q(sizeof(S0)), SIZE, "struct with 1 char, 1 double"); + + if (nbr_failures > 0) + return 1; + else + return 0; +} diff --git a/gcc/testsuite/gcc.apple/align-test-5c.c b/gcc/testsuite/gcc.apple/align-test-5c.c new file mode 100644 index 00000000000..707a9c6a215 --- /dev/null +++ b/gcc/testsuite/gcc.apple/align-test-5c.c @@ -0,0 +1,87 @@ +/* APPLE LOCAL file Macintosh alignment */ +/* align-test-5*.c are all the same code but with different options. */ + +/* { dg-do run } */ +/* { dg-options "-malign-mac68k -DSIZE=10" } */ + +/* dg-skip-if would be better, should be in the next merge after 2004-01. */ +/* { dg-xfail-if "" { powerpc*-*-darwin* } { "-m64" } { "" } } */ + +/* + * GCC alignment test for command line options for setting alignment modes. + * Fred Forsman + * Apple Computer, Inc. + */ + + /* Check whether we are testing GCC 3 or later. */ +#ifdef __GNUC__ +#if __GNUC__ >= 3 +#define GCC3 1 +#else +#define GCC3 0 +#endif +#endif + +#include <stdio.h> +#include <stddef.h> +#include <string.h> + +#define Q(x) #x, x + +typedef unsigned char UINT8; +typedef unsigned long UINT32; + +static int bad_option = 0; +static int flag_verbose = 0; +static int nbr_failures = 0; + +typedef struct S0 { + UINT8 f1; + double f2; +} S0; + +static void check(char * rec_name, int actual, int expected, char * comment) +{ + if (flag_verbose || (actual != expected)) { + printf("%-20s = %2d (%2d) ", rec_name, actual, expected); + if (actual != expected) { + printf("*** FAIL"); + nbr_failures++; + } else + printf(" PASS"); + printf(": %s\n", comment); + } +} + +static void check_option(char *option) +{ + if (*option == '-') { + if (strcmp(option, "-v") == 0) + flag_verbose = 1; + else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } + } else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } +} + +int main(int argc, char *argv[]) +{ + int i; + + for (i = 1; i < argc; i++) + check_option(argv[i]); + + if (bad_option) + return 1; + + check(Q(sizeof(S0)), SIZE, "struct with 1 char, 1 double"); + + if (nbr_failures > 0) + return 1; + else + return 0; +} diff --git a/gcc/testsuite/gcc.apple/align-test-5d.c b/gcc/testsuite/gcc.apple/align-test-5d.c new file mode 100644 index 00000000000..fbbe60f7aa2 --- /dev/null +++ b/gcc/testsuite/gcc.apple/align-test-5d.c @@ -0,0 +1,90 @@ +/* APPLE LOCAL file Macintosh alignment */ +/* align-test-5*.c are all the same code but with different options. */ + +/* { dg-do run { target "i?86-*-darwin*" } } */ +/* { dg-options "-malign-natural -DSIZE=12" } */ + +/* This is for Intel only. */ +/* { dg-xfail-if "" { powerpc*-*-darwin* } { "" } { "" } } */ + +/* + * GCC alignment test for command line options for setting alignment modes. + * Fred Forsman + * Apple Computer, Inc. + * (C) 2000-2002. + * Last modified 2002-2-18. + * + */ + + /* Check whether we are testing GCC 3 or later. */ +#ifdef __GNUC__ +#if __GNUC__ >= 3 +#define GCC3 1 +#else +#define GCC3 0 +#endif +#endif + +#include <stdio.h> +#include <stddef.h> +#include <string.h> + +#define Q(x) #x, x + +typedef unsigned char UINT8; +typedef unsigned long UINT32; + +static int bad_option = 0; +static int flag_verbose = 0; +static int nbr_failures = 0; + +typedef struct S0 { + UINT8 f1; + double f2; +} S0; + +static void check(char * rec_name, int actual, int expected, char * comment) +{ + if (flag_verbose || (actual != expected)) { + printf("%-20s = %2d (%2d) ", rec_name, actual, expected); + if (actual != expected) { + printf("*** FAIL"); + nbr_failures++; + } else + printf(" PASS"); + printf(": %s\n", comment); + } +} + +static void check_option(char *option) +{ + if (*option == '-') { + if (strcmp(option, "-v") == 0) + flag_verbose = 1; + else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } + } else { + fprintf(stderr, "*** unrecognized option '%s'.\n", option); + bad_option = 1; + } +} + +int main(int argc, char *argv[]) +{ + int i; + + for (i = 1; i < argc; i++) + check_option(argv[i]); + + if (bad_option) + return 1; + + check(Q(sizeof(S0)), SIZE, "struct with 1 char, 1 double"); + + if (nbr_failures > 0) + return 1; + else + return 0; +} diff --git a/gcc/testsuite/gcc.apple/altivec-1.c b/gcc/testsuite/gcc.apple/altivec-1.c new file mode 100644 index 00000000000..c8df7f026b9 --- /dev/null +++ b/gcc/testsuite/gcc.apple/altivec-1.c @@ -0,0 +1,124 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-faltivec" } */ + +/* Test for correct handling of AltiVec constants passed + through '...' (va_arg). */ + +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> + +#define CHECK_INVARIANT(expr) \ + if (!(expr)) { \ + printf ("ASSERT FAILED: %d: %s\n", __LINE__, #expr); \ + abort (); \ + } + +struct foo { int x; int y; }; +struct vfoo { int x; __vector signed int v; int y; }; +union u { __vector signed int v; signed int i[4]; }; + +struct foo x_g = { 3, 4}; +struct vfoo vx_g = { 10, (vector signed int)(11, 12, 13, 14), 15 }; +__vector signed int v_g = (vector signed int) (22, 23, 24, 25); +struct vfoo vx2_g = { 30, (vector signed int)(31, 32, 33, 34), 35 }; +__vector signed int v2_g = (vector signed int)(40, 41, 42, 43); +int i_1 = 99, i_2 = 33; +double d_2 = 1.5, d_3 = 1.75; +long double ld_1 = 1.25; + +void bar (int i, ... ) +{ + struct foo xi; + double d; + long double ld; + float f; + char c; + short s; + va_list ap; + va_start(ap, i); + xi = va_arg(ap, struct foo); + s = (short)va_arg(ap, int); + f = (float)va_arg(ap, double); + ld = va_arg(ap, long double); + c = (char)va_arg(ap, int); + d = va_arg(ap, double); + va_end(ap); + + CHECK_INVARIANT (xi.x == x_g.x && xi.y == x_g.y); + CHECK_INVARIANT (s == (short)i_2); + CHECK_INVARIANT (f == (float)d_2); + CHECK_INVARIANT (ld == ld_1); + CHECK_INVARIANT (c == (char)i_1); + CHECK_INVARIANT (d == d_3); +} + +void baz (int i, ... ) +{ + struct vfoo vx, vx2; + __vector signed int v_i, v2_i; + int j, k, l; + va_list ap; + va_start(ap, i); + v_i = va_arg(ap, __vector signed int); + j = va_arg(ap, int); + vx = va_arg(ap, struct vfoo); + k = va_arg(ap, int); + v2_i = va_arg(ap, __vector signed int); + l = va_arg(ap, int); + vx2 = va_arg(ap, struct vfoo); + va_end(ap); + + CHECK_INVARIANT (vec_all_eq (v_i, v_g)); + CHECK_INVARIANT (j == i_1); + CHECK_INVARIANT (vx.x == vx_g.x && vec_all_eq(vx.v, vx_g.v) && vx.y == vx_g.y); + CHECK_INVARIANT (k == i_1); + CHECK_INVARIANT (vec_all_eq (v2_i, v2_g)); + CHECK_INVARIANT (l == i_1); + CHECK_INVARIANT (vx2.x == vx2_g.x && vec_all_eq(vx2.v, vx2_g.v) && vx2.y == vx2_g.y); +} + +void quux (int i, ... ) +{ + __vector signed int v_i, v2_i; + union u vi, v2i; + va_list ap; + va_start(ap, i); + v_i = va_arg(ap, __vector signed int); + v2_i = va_arg(ap, __vector signed int); + va_end(ap); + vi.v = v_i; + v2i.v = v2_i; + + CHECK_INVARIANT (vec_all_eq (v_i, v_g)); + CHECK_INVARIANT (vec_all_eq (v2_i, v_g)); + CHECK_INVARIANT (vec_all_eq (vi.v, v_g)); + CHECK_INVARIANT (vec_all_eq (v2i.v, v_g)); +} + +void baz2 (int i, ... ) +{ + struct vfoo vx; + union u vxi; + va_list ap; + va_start(ap, i); + vx = va_arg(ap, struct vfoo); + va_end(ap); + vxi.v = vx.v; + + CHECK_INVARIANT (vx.x == vx_g.x && vec_all_eq(vx.v, vx_g.v) && vx.y == vx_g.y); + CHECK_INVARIANT (vec_all_eq (vxi.v, vx_g.v)); +} + +int main(void) +{ + CHECK_INVARIANT (sizeof(struct foo) == 8 && sizeof(struct vfoo) == 48); + + bar(i_1, x_g, (short)i_2, (float)d_2, ld_1, (char)i_1, d_3); + baz(i_1, v_g, i_1, vx_g, i_1, v2_g, i_1, vx2_g); + quux(i_1, v_g, v_g); + baz2(i_1, vx_g); + + return 0; +} diff --git a/gcc/testsuite/gcc.apple/altivec-19.c b/gcc/testsuite/gcc.apple/altivec-19.c new file mode 100644 index 00000000000..857962f9f2e --- /dev/null +++ b/gcc/testsuite/gcc.apple/altivec-19.c @@ -0,0 +1,15 @@ +/* APPLE LOCAL entire file */ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-maltivec -pedantic" } */ + +int main() + { + typedef unsigned char UC; + typedef vector unsigned char VUC; + + const UC kBar = 7; + VUC vBar1 = (VUC)(kBar); + VUC vBar2 = {kBar}; + VUC vBar3 = (VUC){kBar}; + return 0; + } diff --git a/gcc/testsuite/gcc.apple/altivec-2.c b/gcc/testsuite/gcc.apple/altivec-2.c new file mode 100644 index 00000000000..23eaf3d230d --- /dev/null +++ b/gcc/testsuite/gcc.apple/altivec-2.c @@ -0,0 +1,22 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-faltivec" } */ + +/* Check whether AltiVec allows for 'bool' + and 'pixel' to be #defined to mean other things. */ + +extern void abort (void); +#define CHECK_IF(E) if(!(E)) abort() + +#define bool char +#define pixel unsigned char + +int main(void) { + bool x1; + pixel x2; + + CHECK_IF(sizeof(x1) == 1); + CHECK_IF(sizeof(x2) == 1); + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/altivec-20.c b/gcc/testsuite/gcc.apple/altivec-20.c new file mode 100644 index 00000000000..63cc2dba6d8 --- /dev/null +++ b/gcc/testsuite/gcc.apple/altivec-20.c @@ -0,0 +1,7 @@ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-options "-maltivec" } */ + +#define vector __attribute__((vector_size(16))) + +vector long long vbl; /* { dg-error "use of 'long long' in AltiVec types is invalid" } */ + diff --git a/gcc/testsuite/gcc.apple/altivec-3.c b/gcc/testsuite/gcc.apple/altivec-3.c new file mode 100644 index 00000000000..09579468c9b --- /dev/null +++ b/gcc/testsuite/gcc.apple/altivec-3.c @@ -0,0 +1,14 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-options "-faltivec" } */ + +int main(void) +{ + bool b; /* { dg-error ".bool. undeclared" } */ + /* { dg-error "is reported only once" "" { target *-*-* } 7 } */ + /* { dg-error "function it appears in" "" { target *-*-* } 7 } */ + /* { dg-error "(parse|syntax) error" "" { target *-*-* } 7 } */ + + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/altivec-4.c b/gcc/testsuite/gcc.apple/altivec-4.c new file mode 100644 index 00000000000..c81cc7676aa --- /dev/null +++ b/gcc/testsuite/gcc.apple/altivec-4.c @@ -0,0 +1,23 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-options "-faltivec" } */ + +extern void abort(); + +#include <stdio.h> +int main() +{ + int i; + union u { + vector signed short uv; + signed short val[8]; + } v; + + vector signed short SpecialConstants = (vector signed short)( 1, 2, 3, 4, 5, 6,7,8); + v.uv = SpecialConstants; + for (i=0; i < 8; i++) + if (v.val[i] != i+1) + abort(); + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/altivec-5.c b/gcc/testsuite/gcc.apple/altivec-5.c new file mode 100644 index 00000000000..cd9e1888af2 --- /dev/null +++ b/gcc/testsuite/gcc.apple/altivec-5.c @@ -0,0 +1,33 @@ +/* APPLE LOCAL file AltiVec 3840704 */ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-options "-faltivec" } */ +/* { dg-final { scan-assembler-not "stvx" } } */ + +void *memset(void *, int, unsigned long int); + +struct tm +{ + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; + long tm_gmtoff; + char *tm_zone; +}; + + +int asl_send() +{ + char *str, *out; + unsigned int i, len, level, outstatus; + struct tm gtime; + + memset(>ime, 0, sizeof(struct tm)); /* { dg-warning "disabled" } */ + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/altivec-faltivec-1.c b/gcc/testsuite/gcc.apple/altivec-faltivec-1.c new file mode 100644 index 00000000000..f624187d56e --- /dev/null +++ b/gcc/testsuite/gcc.apple/altivec-faltivec-1.c @@ -0,0 +1,135 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-options "-O3 -finline-limit=9999 -faltivec -Wa,-force_cpusubtype_ALL -fdump-ipa-cgraph -S" } */ +/* Inliner should not inline AltiVec(tm) functions when -faltivec is on. */ +/* <rdar://problem/3837835> Selective inlining of functions that use Altivec */ +#include <Carbon/Carbon.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +/* #include <altivec.h> */ + +#define N 400 +#define N4 ((N+3)/4) +#define N8 ((N+7)/8) + +typedef union +{ + signed short sInt[8]; + vector signed short vInt; +} IntegerToVector; + +static signed long vIntDotProduct (vector signed short [], vector signed short [], long int); +static int mainInt(); +static Ptr getMemory (size_t); + +static int +mainInt() +{ + long int n = N, n8 = N8, m, i, j; + signed long vDotProduct, sDotProduct; + signed short *sx, *sy; + vector signed short *x, *y; + IntegerToVector *sX, *sY; + + sx = (short *) getMemory( 4*(n+3) ); + if (sx == nil) + return 0; + sy = (short *) getMemory( 4*(n+3) ); + if (sy == nil) + return 0; + + x = (vector signed short *) getMemory( n8*16 ); + if ( x == nil) + return 0; + y = (vector signed short *) getMemory( n8*16 ); + if ( y == nil) + return 0; + + sX = (IntegerToVector *) getMemory( n8*16 ); + if (sX == nil) + return 0; + sY = (IntegerToVector *) getMemory( n8*16 ); + if (sY == nil) + return 0; + + for ( i = 0; i < n; i++ ) + { + sx[i] = ( signed short ) scalb(( M_PI * ( double ) ( i ) / ( double ) n ), 8) + 0.5; + sy[i] = ( signed short ) scalb(( M_PI * ( double ) ( n - i ) / ( double ) n ), 8) + 0.5; + } + + m = n % 8; + if (m != 0) + for (i = n; i < n + 8 - m; i++) + { + sx[i] = 0.0; + sy[i] = 0.0; + } + + for ( i = 0; i < n8; i++ ) + for ( j = 0; j < 8; j++ ) + { + sX[i].sInt[j] = sx[i*8+j]; + sY[i].sInt[j] = sy[i*8+j]; + } + + for ( i = 0; i < n8; i++ ) + { + x[i] = sX[i].vInt; + y[i] = sY[i].vInt; + } + + vDotProduct = vIntDotProduct ( x, y, n8 ); + + printf ( "\nVector dot product = %10d\n", (int) vDotProduct ); + + return 0; +} + +static Ptr +getMemory ( size_t amount ) +{ + Ptr ptr; + + ptr = malloc(amount); + if (ptr == nil) + printf ("\nUnable to allocate sufficient memory."); + return (ptr); +} + +signed long +vIntDotProduct ( vector signed short x[], vector signed short y[], long int n ) +{ + + typedef union + { + signed long xElem[4]; + vector signed int vWord; + } WordToVector; + + long int i; + + vector signed int partialProduct, zero = ( vector signed int ) { 0,0,0,0 }; + WordToVector sum; + + partialProduct = zero; + + for ( i = 0; i < n ; i++ ) + partialProduct = vec_msums ( x[i], y[i], partialProduct ); + + sum.vWord = vec_sums( partialProduct, zero); + + return sum.xElem[3]; +} + +int +main() +{ + mainInt(); + exit(0); +} + +/* { dg-final { scan-tree-dump-times "callee has AltiVec" 2 "cgraph" } } */ +/* { dg-final { scan-assembler-not "vIntDotProduct" } } */ +/* { dg-final { scan-assembler "mainInt" } } */ diff --git a/gcc/testsuite/gcc.apple/altivec-faltivec-2.c b/gcc/testsuite/gcc.apple/altivec-faltivec-2.c new file mode 100644 index 00000000000..fe376397d6c --- /dev/null +++ b/gcc/testsuite/gcc.apple/altivec-faltivec-2.c @@ -0,0 +1,135 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-options "-O3 -finline-limit=9999 -faltivec -Wa,-force_cpusubtype_ALL -fdump-ipa-cgraph -S" } */ +/* Inliner should inline always-inline AltiVec(tm) functions when -faltivec is on. */ +/* <rdar://problem/3837835> Selective inlining of functions that use Altivec */ +#include <Carbon/Carbon.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +/* #include <altivec.h> */ + +#define N 400 +#define N4 ((N+3)/4) +#define N8 ((N+7)/8) + +typedef union +{ + signed short sInt[8]; + vector signed short vInt; +} IntegerToVector; + +static signed long __attribute__ ((always_inline)) vIntDotProduct (vector signed short [], vector signed short [], long int); +static int __attribute__ ((always_inline)) mainInt(); +static Ptr getMemory (size_t); + +static int __attribute__ ((always_inline)) +mainInt() +{ + long int n = N, n8 = N8, m, i, j; + signed long vDotProduct, sDotProduct; + signed short *sx, *sy; + vector signed short *x, *y; + IntegerToVector *sX, *sY; + + sx = (short *) getMemory( 4*(n+3) ); + if (sx == nil) + return 0; + sy = (short *) getMemory( 4*(n+3) ); + if (sy == nil) + return 0; + + x = (vector signed short *) getMemory( n8*16 ); + if ( x == nil) + return 0; + y = (vector signed short *) getMemory( n8*16 ); + if ( y == nil) + return 0; + + sX = (IntegerToVector *) getMemory( n8*16 ); + if (sX == nil) + return 0; + sY = (IntegerToVector *) getMemory( n8*16 ); + if (sY == nil) + return 0; + + for ( i = 0; i < n; i++ ) + { + sx[i] = ( signed short ) scalb(( M_PI * ( double ) ( i ) / ( double ) n ), 8) + 0.5; + sy[i] = ( signed short ) scalb(( M_PI * ( double ) ( n - i ) / ( double ) n ), 8) + 0.5; + } + + m = n % 8; + if (m != 0) + for (i = n; i < n + 8 - m; i++) + { + sx[i] = 0.0; + sy[i] = 0.0; + } + + for ( i = 0; i < n8; i++ ) + for ( j = 0; j < 8; j++ ) + { + sX[i].sInt[j] = sx[i*8+j]; + sY[i].sInt[j] = sy[i*8+j]; + } + + for ( i = 0; i < n8; i++ ) + { + x[i] = sX[i].vInt; + y[i] = sY[i].vInt; + } + + vDotProduct = vIntDotProduct ( x, y, n8 ); + + printf ( "\nVector dot product = %10d\n", (int) vDotProduct ); + + return 0; +} + +static Ptr +getMemory ( size_t amount ) +{ + Ptr ptr; + + ptr = malloc(amount); + if (ptr == nil) + printf ("\nUnable to allocate sufficient memory."); + return (ptr); +} + +signed long __attribute__ ((always_inline)) +vIntDotProduct ( vector signed short x[], vector signed short y[], long int n ) +{ + + typedef union + { + signed long xElem[4]; + vector signed int vWord; + } WordToVector; + + long int i; + + vector signed int partialProduct, zero = ( vector signed int ) { 0,0,0,0 }; + WordToVector sum; + + partialProduct = zero; + + for ( i = 0; i < n ; i++ ) + partialProduct = vec_msums ( x[i], y[i], partialProduct ); + + sum.vWord = vec_sums( partialProduct, zero); + + return sum.xElem[3]; +} + +int +main() +{ + mainInt(); + exit(0); +} + +/* { dg-final { scan-tree-dump-times "callee has AltiVec" 0 "cgraph" } } */ +/* { dg-final { scan-assembler-not "vIntDotProduct" } } */ +/* { dg-final { scan-assembler-not "mainInt" } } */ diff --git a/gcc/testsuite/gcc.apple/altivec-maltivec-1.c b/gcc/testsuite/gcc.apple/altivec-maltivec-1.c new file mode 100644 index 00000000000..52181bde5be --- /dev/null +++ b/gcc/testsuite/gcc.apple/altivec-maltivec-1.c @@ -0,0 +1,135 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-options "-O3 -finline-limit=9999 -maltivec -Wa,-force_cpusubtype_ALL -fdump-ipa-cgraph -S" } */ +/* Inliner should inline AltiVec(tm) functions normally when -maltivec is on. */ +/* <rdar://problem/3837835> Selective inlining of functions that use Altivec */ +#include <Carbon/Carbon.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <altivec.h> + +#define N 400 +#define N4 ((N+3)/4) +#define N8 ((N+7)/8) + +typedef union +{ + signed short sInt[8]; + vector signed short vInt; +} IntegerToVector; + +static signed long vIntDotProduct (vector signed short [], vector signed short [], long int); +static int mainInt(); +static Ptr getMemory ( size_t amount ); + +static int +mainInt() +{ + long int n = N, n8 = N8, m, i, j; + signed long vDotProduct, sDotProduct; + signed short *sx, *sy; + vector signed short *x, *y; + IntegerToVector *sX, *sY; + + sx = (short *) getMemory( 4*(n+3) ); + if (sx == nil) + return 0; + sy = (short *) getMemory( 4*(n+3) ); + if (sy == nil) + return 0; + + x = (vector signed short *) getMemory( n8*16 ); + if ( x == nil) + return 0; + y = (vector signed short *) getMemory( n8*16 ); + if ( y == nil) + return 0; + + sX = (IntegerToVector *) getMemory( n8*16 ); + if (sX == nil) + return 0; + sY = (IntegerToVector *) getMemory( n8*16 ); + if (sY == nil) + return 0; + + for ( i = 0; i < n; i++ ) + { + sx[i] = ( signed short ) scalb(( M_PI * ( double ) ( i ) / ( double ) n ), 8) + 0.5; + sy[i] = ( signed short ) scalb(( M_PI * ( double ) ( n - i ) / ( double ) n ), 8) + 0.5; + } + + m = n % 8; + if (m != 0) + for (i = n; i < n + 8 - m; i++) + { + sx[i] = 0.0; + sy[i] = 0.0; + } + + for ( i = 0; i < n8; i++ ) + for ( j = 0; j < 8; j++ ) + { + sX[i].sInt[j] = sx[i*8+j]; + sY[i].sInt[j] = sy[i*8+j]; + } + + for ( i = 0; i < n8; i++ ) + { + x[i] = sX[i].vInt; + y[i] = sY[i].vInt; + } + + vDotProduct = vIntDotProduct ( x, y, n8 ); + + printf ( "\nVector dot product = %10d\n", (int) vDotProduct ); + + return 0; +} + +static Ptr +getMemory ( size_t amount ) +{ + Ptr ptr; + + ptr = malloc(amount); + if (ptr == nil) + printf ("\nUnable to allocate sufficient memory."); + return (ptr); +} + +static signed long +vIntDotProduct ( vector signed short x[], vector signed short y[], long int n ) +{ + + typedef union + { + signed long xElem[4]; + vector signed int vWord; + } WordToVector; + + long int i; + + vector signed int partialProduct, zero = ( vector signed int ) { 0,0,0,0 }; + WordToVector sum; + + partialProduct = zero; + + for ( i = 0; i < n ; i++ ) + partialProduct = vec_msums ( x[i], y[i], partialProduct ); + + sum.vWord = vec_sums( partialProduct, zero); + + return sum.xElem[3]; +} + +int +main() +{ + mainInt(); + exit(0); +} + +/* { dg-final { scan-tree-dump-times "callee has AltiVec" 0 "cgraph" } } */ +/* { dg-final { scan-assembler-not "vIntDotProduct" } } */ +/* { dg-final { scan-assembler-not "mainInt" } } */ diff --git a/gcc/testsuite/gcc.apple/altivec-test-macro.c b/gcc/testsuite/gcc.apple/altivec-test-macro.c new file mode 100644 index 00000000000..6d5a2dc894d --- /dev/null +++ b/gcc/testsuite/gcc.apple/altivec-test-macro.c @@ -0,0 +1,30 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-maltivec" } */ + +#include <altivec.h> + +#define TYPE unsigned int +union U { + TYPE ui[4]; + vector TYPE uv; +} data; + +extern void abort(); + +int main( void ) +{ + vector unsigned int v = {1,2,3,4}; + vector TYPE UUUUUU = {10,10,10,10}; + int i; + + v = vec_add( v, UUUUUU ); + + data.uv = v; + + for (i=0; i < 4; i++) + if (data.ui[i] != (10+i+1)) + abort(); + + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/apple-altivec-1.c b/gcc/testsuite/gcc.apple/apple-altivec-1.c new file mode 100644 index 00000000000..81a5bc1beab --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-1.c @@ -0,0 +1,64 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do compile { target powerpc*-*-darwin* } } */ +/* { dg-options "-faltivec" } */ + +static vector int x, y; + +static vector signed int i,j; +static vector signed short s,t; +static vector signed char c,d; +static vector float f,g; +static vector unsigned short us; + +static vector unsigned char uc; + +static vector signed int *pi; + +static int int1, int2; + +void +b() +{ + vec_add (x, y); + + /* Make sure the predicates accept correct argument types. */ + + int1 = vec_all_in (f, g); + int1 = vec_all_ne (f, g); + int1 = vec_all_ne (c, d); + int1 = vec_all_ne (s, t); + int1 = vec_all_ne (i, j); + int1 = vec_all_nge (f, g); + int1 = vec_all_ngt (f, g); + int1 = vec_all_ge (c, d); + int1 = vec_all_ge (s, t); + int1 = vec_all_ge (i, j); + int1 = vec_all_ge (c, d); + int1 = vec_all_ge (s, t); + int1 = vec_all_ge (i, j); + + vec_mtvscr (i); + vec_dssall (); + us = vec_mfvscr (); + vec_dss (3); + + vec_dst (pi, int1 + int2, 3); + vec_dstst (pi, int1 + int2, 3); + vec_dststt (pi, int1 + int2, 3); + vec_dstt (pi, int1 + int2, 3); + + uc = vec_lvsl (int1 + 69, pi); + uc = vec_lvsr (int1 + 69, pi); + + c = vec_lde (int1, (vector bool char *)pi); + s = vec_lde (int1, (vector pixel *)pi); + i = vec_lde (int1, pi); + i = vec_ldl (int1, pi); + i = vec_ld (int1, pi); + + vec_st (i, int2, pi); + vec_ste (c, int2, (vector unsigned char *)pi); + vec_ste (s, int2, (vector bool short *)pi); + vec_ste (i, int2, pi); + vec_stl (i, int2, pi); +} diff --git a/gcc/testsuite/gcc.apple/apple-altivec-10.c b/gcc/testsuite/gcc.apple/apple-altivec-10.c new file mode 100644 index 00000000000..12afefa4c1c --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-10.c @@ -0,0 +1,81 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-faltivec" } */ +extern void abort(); + +#include <stdio.h> + +int main() +{ + char str[128]; + vector unsigned char + vuchar = (vector unsigned char)((vector unsigned int)(0x001f001d, 0x001f001d, 0x001f001d, 0x001f001d)); + + vector unsigned short + vushort = (vector unsigned short)((vector unsigned int)(0x001f001d, 0x001f001d, 0x001f001d, 0x001f001d)); + + vector unsigned char + vushort_to_char = (vector unsigned char) + ((vector unsigned short)(0x001f,0x001d, 0x001f,0x001d, 0x001f,0x001d, 0x001f,0x001d)); + + vector signed char + vschar = (vector signed char)((vector signed int)(0x001f001d, 0x001f001d, 0x001f001d, 0x001f001d)); + + vector signed short + vsshort = (vector signed short)((vector signed int)(0x001f001d, 0x001f001d, 0x001f001d, 0x001f001d)); + + vector signed char + vsshort_to_char = (vector signed char) + ((vector signed short)(0x001f,0x001d, 0x001f,0x001d, 0x001f,0x001d, 0x001f,0x001d)); + + vector unsigned int + vui = (vector unsigned int)((vector unsigned short)(0x011f,0x021d, 0x031f,0x041d, 0x051f,0x061d, 0x071f,0x081d)); + + vector unsigned int + vui1 = (vector unsigned int) + ((vector unsigned char)(0x01,0x1f,0x02,0x1d, 0x03,0x1f,0x04,0x1d, + 0x05,0x1f,0x06,0x1d, 0x07,0x1f,0x08,0x1d)); + + vector unsigned short + vus = (vector unsigned short) + ((vector unsigned char)(0x01,0x1f,0x02,0x1d, 0x03,0x1f,0x04,0x1d, + 0x05,0x1f,0x06,0x1d, 0x07,0x1f,0x08,0x1d)); + + vector float + vf = (vector float) + ((vector unsigned int)(0x001f001d, 0x001f001d, 0x001f001d, 0x001f001d)); + + sprintf(str, "%vhu", vuchar); + if (strcmp (str, "31 29 31 29 31 29 31 29")) + abort(); + sprintf(str, "%vhu", vushort); + if (strcmp (str, "31 29 31 29 31 29 31 29")) + abort(); + sprintf(str, "%vhu", vushort_to_char); + if (strcmp (str, "31 29 31 29 31 29 31 29")) + abort(); + sprintf(str, "%vhu", vschar); + if (strcmp (str, "31 29 31 29 31 29 31 29")) + abort(); + sprintf(str, "%vhu", vsshort); + if (strcmp (str, "31 29 31 29 31 29 31 29")) + abort(); + sprintf(str, "%vhu", vsshort_to_char); + if (strcmp (str, "31 29 31 29 31 29 31 29")) + abort(); + sprintf(str, "%vd", vui); + if (strcmp (str, "1 31 2 29 3 31 4 29 5 31 6 29 7 31 8 29")) + abort(); + sprintf(str, "%vd", vui1); + if (strcmp (str, "1 31 2 29 3 31 4 29 5 31 6 29 7 31 8 29")) + abort(); + sprintf(str, "%vd", vus); + if (strcmp (str, "1 31 2 29 3 31 4 29 5 31 6 29 7 31 8 29")) + abort(); + sprintf(str, "%vhu", vf); + if (strcmp (str, "31 29 31 29 31 29 31 29")) + abort(); + return 0; +} + + diff --git a/gcc/testsuite/gcc.apple/apple-altivec-11.c b/gcc/testsuite/gcc.apple/apple-altivec-11.c new file mode 100644 index 00000000000..6224923c1be --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-11.c @@ -0,0 +1,23 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-faltivec" } */ + +extern void abort(); + +vector signed int +vandc(vector signed int a, vector signed int b) +{ + return vec_andc(a, b); +} + +int main () +{ + char buf [1024]; + vector signed int a1 = (vector signed int) (0XFFFFFFFF); + vector signed int b1 = (vector signed int) (0X0); + + if (!vec_all_eq (vandc (a1, b1), a1)) + abort(); + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/apple-altivec-12.c b/gcc/testsuite/gcc.apple/apple-altivec-12.c new file mode 100644 index 00000000000..c4553368fdd --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-12.c @@ -0,0 +1,395 @@ +/* APPLE LOCAL file AltiVec */ +/* Check for presence of AltiVec PIM "specific operations". */ + +/* { dg-do compile { target powerpc*-*-darwin* } } */ +/* { dg-options "-faltivec -Wall" } */ + +vector signed int +specific_operations( signed int *p) +{ + vector unsigned int vui1, vui2; + vector unsigned short vus1, vus2; + vector unsigned char vuc1, vuc2; + vector signed int vsi1, vsi2; + vector signed short vss1, vss2; + vector signed char vsc1, vsc2; + vector bool int vbi1, vbi2; + vector bool short vbs1, vbs2; + vector bool char vbc1, vbc2; + vector float vf1, vf2; + vector pixel vp1, vp2; + + vuc1 = vec_lvebx (8, (unsigned char *)p); + vss1 = vec_lvehx (4, (short *)p); + vf1 = vec_lvewx (2, (float *)p); + + vsi1 = vec_lvx (1, (vector signed int *)p); + vp1 = vec_lvxl (16, (vector pixel *)p); + + vec_stvebx (vuc1, 2, (char *)p); + vec_stvehx (vp1, 4, (unsigned short *)p); + vec_stvewx (vf1, 1, (float *)p); + + vec_stvx (vbi1, 12, (vector int bool *)p); + vec_stvxl (vp1, 11, (vector pixel *)p); + + vui1 = vec_vaddcuw (vui1, vui2); + vf1 = vec_vaddfp (vf1, vf2); + + vsc1 = vec_vaddsbs (vsc1, vsc2); + vss1 = vec_vaddshs (vss1, vss2); + vsi1 = vec_vaddsws (vsi1, vsi2); + vuc1 = vec_vaddubs (vuc1, vuc2); + vus1 = vec_vadduhs (vus1, vus2); + vui1 = vec_vadduws (vui1, vui2); + vuc1 = vec_vaddubm (vuc1, vuc2); + vus1 = vec_vadduhm (vus1, vus2); + vui1 = vec_vadduwm (vui1, vui2); + + vsc1 = vec_vand (vsc1, vsc2); + vss1 = vec_vandc (vss1, vss2); + + vsc1 = vec_vavgsb (vsc1, vsc2); + vss1 = vec_vavgsh (vss1, vss2); + vsi1 = vec_vavgsw (vsi1, vsi2); + vuc1 = vec_vavgub (vuc1, vuc2); + vus1 = vec_vavguh (vus1, vus2); + vui1 = vec_vavguw (vui1, vui2); + + vf1 = vec_vcfsx (vsi1, 4); + vf2 = vec_vcfux (vui1, 3); + + vsi1 = vec_vcmpbfp (vf1, vf2); + vbi1 = vec_vcmpeqfp (vf1, vf2); + + vbc1 = vec_vcmpequb (vuc1, vuc2); + vbs2 = vec_vcmpequh (vus1, vus2); + vbi1 = vec_vcmpequw (vui1, vui2); + + vbi1 = vec_vcmpgefp (vf1, vf2); + vbi2 = vec_vcmpgtfp (vf1, vf2); + + vbc1 = vec_vcmpgtsb (vsc1, vsc2); + vbs1 = vec_vcmpgtsh (vss1, vss2); + vbi1 = vec_vcmpgtsw (vsi1, vsi2); + + vbc1 = vec_vcmpgtub (vuc1, vuc2); + vbs1 = vec_vcmpgtuh (vus1, vus2); + vbi1 = vec_vcmpgtuw (vui1, vui2); + + vsi1 = vec_vctsxs (vf1, 22); + vui1 = vec_vctuxs (vf2, 30); + + vf2 = vec_vexptefp (vf1); + vf1 = vec_vlogefp (vf2); + vf2 = vec_vmaddfp (vf1, vf2, vf2); + + vf1 = vec_vmaxfp (vf1, vf2); + vsc1 = vec_vmaxsb (vsc1, vsc2); + vss1 = vec_vmaxsh (vss1, vss2); + vsi1 = vec_vmaxsw (vsi1, vsi2); + vuc1 = vec_vmaxub (vuc1, vuc2); + vus1 = vec_vmaxuh (vus1, vus2); + vui1 = vec_vmaxuw (vui1, vui2); + + vbc1 = vec_vmrghb (vbc1, vbc2); + vp1 = vec_vmrghh (vp1, vp2); + vf2 = vec_vmrghw (vf2, vf1); + + vbc1 = vec_vmrglb (vbc1, vbc2); + vp1 = vec_vmrglh (vp1, vp2); + vf2 = vec_vmrglw (vf2, vf1); + + vf1 = vec_vminfp (vf1, vf2); + vsc1 = vec_vminsb (vsc1, vsc2); + vss1 = vec_vminsh (vss1, vss2); + vsi1 = vec_vminsw (vsi1, vsi2); + vuc1 = vec_vminub (vuc1, vuc2); + vus1 = vec_vminuh (vus1, vus2); + vui1 = vec_vminuw (vui1, vui2); + + vss1 = vec_vmhaddshs (vss1, vss2, vss2); + vss2 = vec_vmhraddshs (vss1, vss2, vss2); + vus1 = vec_vmladduhm (vus1, vus1, vus2); + vui1 = vec_vmsumubm (vuc1, vuc2, vui1); + vsi1 = vec_vmsummbm (vsc1, vuc2, vsi1); + vsi2 = vec_vmsumshm (vss1, vss2, vsi1); + vui1 = vec_vmsumuhm (vus1, vus2, vui2); + vui2 = vec_vmsumuhs (vus1, vus2, vui1); + vsi2 = vec_vmsumshs (vss1, vss1, vsi2); + + vus1 = vec_vmuleub (vuc1, vuc2); + vss1 = vec_vmulesb (vsc1, vsc2); + vui1 = vec_vmuleuh (vus1, vus2); + vsi1 = vec_vmulesh (vss1, vss2); + + vus2 = vec_vmuloub (vuc1, vuc2); + vss2 = vec_vmulosb (vsc1, vsc2); + vui2 = vec_vmulouh (vus1, vus2); + vsi2 = vec_vmulosh (vss1, vss2); + + vf1 = vec_vnmsubfp (vf1, vf2, vf1); + + vp1 = vec_vnor (vp1, vp2); + vf2 = vec_vor (vf2, vbi1); + vf2 = vec_vxor (vf2, vbi1); + + vsc1 = vec_vpkuhum (vss1, vss2); + vbs1 = vec_vpkuwum (vbi1, vbi2); + vp1 = vec_vpkpx (vui1, vui2); + vuc1 = vec_vpkuhus (vus1, vus1); + vsc1 = vec_vpkshss (vss1, vss2); + vus1 = vec_vpkuwus (vui1, vui2); + vss2 = vec_vpkswss (vsi1, vsi1); + vuc1 = vec_vpkshus (vss1, vss2); + vus1 = vec_vpkswus (vsi1, vsi1); + + vp1 = vec_vperm (vp1, vp2, vuc1); + + vf1 = vec_vrefp (vf2); + vf2 = vec_vrfin (vf1); + vf1 = vec_vrsqrtefp (vf2); + + vuc1 = vec_vrlb (vuc1, vuc2); + vss1 = vec_vrlh (vss2, vss1); + vui2 = vec_vrlw (vui2, vui1); + + vf1 = vec_vsel (vf2, vf1, vbi1); + + vuc1 = vec_vslb (vuc1, vuc2); + vss1 = vec_vslh (vss2, vss1); + vui2 = vec_vslw (vui2, vui1); + + vp1 = vec_vsldoi (vp2, vp1, 14); + vp2 = vec_vsl (vp1, vuc1); + vp1 = vec_vslo (vp2, vuc1); + + vbc1 = vec_vspltb (vbc1, 9); + vp2 = vec_vsplth (vp1, 7); + vf1 = vec_vspltw (vf2, 31); + vsc2 = vec_vspltisb (30); + vss1 = vec_vspltish (29); + vsi1 = vec_vspltisw (28); + + vuc1 = vec_vsrb (vuc1, vuc2); + vss1 = vec_vsrh (vss2, vss1); + vui2 = vec_vsrw (vui2, vui1); + vuc2 = vec_vsrab (vuc1, vuc2); + vss2 = vec_vsrah (vss2, vss1); + vui1 = vec_vsraw (vui2, vui1); + vp2 = vec_vsr (vp1, vuc1); + vp1 = vec_vsro (vp2, vuc1); + + vui1 = vec_vsubcuw (vui1, vui2); + vf1 = vec_vsubfp (vf1, vf2); + vsc1 = vec_vsubsbs (vsc1, vsc2); + vss1 = vec_vsubshs (vss1, vss2); + vsi1 = vec_vsubsws (vsi1, vsi2); + vuc1 = vec_vsububs (vuc1, vuc2); + vus1 = vec_vsubuhs (vus1, vus2); + vui1 = vec_vsubuws (vui1, vui2); + vuc1 = vec_vsububm (vuc1, vuc2); + vus1 = vec_vsubuhm (vus1, vus2); + vui1 = vec_vsubuwm (vui1, vui2); + + vui2 = vec_vsum4ubs (vuc1, vui1); + vsi1 = vec_vsum4sbs (vsc2, vsi1); + vsi1 = vec_vsum2sws (vsi1, vsi1); + vsi2 = vec_vsumsws (vsi2, vsi1); + + vf2 = vec_vrfiz (vf1); + + vbs1 = vec_vupkhsb (vbc1); + vui1 = vec_vupkhpx (vp1); + vbi1 = vec_vupkhsh (vbs1); + + vss1 = vec_vupklsb (vsc1); + vui1 = vec_vupklpx (vp2); + vbi1 = vec_vupklsh (vbs1); + + return vsi1; +} + +/* { dg-final { scan-assembler "\tlvebx " } } */ +/* { dg-final { scan-assembler "\tlvehx " } } */ +/* { dg-final { scan-assembler "\tlvewx " } } */ +/* { dg-final { scan-assembler "\tlvx " } } */ +/* { dg-final { scan-assembler "\tlvxl " } } */ +/* { dg-final { scan-assembler "\tstvebx " } } */ +/* { dg-final { scan-assembler "\tstvehx " } } */ +/* { dg-final { scan-assembler "\tstvewx " } } */ +/* { dg-final { scan-assembler "\tstvx " } } */ +/* { dg-final { scan-assembler "\tstvxl " } } */ + +/* { dg-final { scan-assembler "\tvaddcuw " } } */ +/* { dg-final { scan-assembler "\tvaddfp " } } */ +/* { dg-final { scan-assembler "\tvaddsbs " } } */ +/* { dg-final { scan-assembler "\tvaddshs " } } */ +/* { dg-final { scan-assembler "\tvaddsws " } } */ +/* { dg-final { scan-assembler "\tvaddubs " } } */ +/* { dg-final { scan-assembler "\tvadduhs " } } */ +/* { dg-final { scan-assembler "\tvadduws " } } */ +/* { dg-final { scan-assembler "\tvaddubm " } } */ +/* { dg-final { scan-assembler "\tvadduhm " } } */ +/* { dg-final { scan-assembler "\tvadduwm " } } */ + +/* { dg-final { scan-assembler "\tvand " } } */ +/* { dg-final { scan-assembler "\tvandc " } } */ + +/* { dg-final { scan-assembler "\tvavgsb " } } */ +/* { dg-final { scan-assembler "\tvavgsh " } } */ +/* { dg-final { scan-assembler "\tvavgsw " } } */ +/* { dg-final { scan-assembler "\tvavgub " } } */ +/* { dg-final { scan-assembler "\tvavguh " } } */ +/* { dg-final { scan-assembler "\tvavguw " } } */ + +/* { dg-final { scan-assembler "\tvcfsx " } } */ +/* { dg-final { scan-assembler "\tvcfux " } } */ + +/* { dg-final { scan-assembler "\tvcmpbfp " } } */ +/* { dg-final { scan-assembler "\tvcmpeqfp " } } */ + +/* { dg-final { scan-assembler "\tvcmpequb " } } */ +/* { dg-final { scan-assembler "\tvcmpequh " } } */ +/* { dg-final { scan-assembler "\tvcmpequw " } } */ + +/* { dg-final { scan-assembler "\tvcmpgefp " } } */ +/* { dg-final { scan-assembler "\tvcmpgtfp " } } */ + +/* { dg-final { scan-assembler "\tvcmpgtsb " } } */ +/* { dg-final { scan-assembler "\tvcmpgtsh " } } */ +/* { dg-final { scan-assembler "\tvcmpgtsw " } } */ + +/* { dg-final { scan-assembler "\tvcmpgtub " } } */ +/* { dg-final { scan-assembler "\tvcmpgtuh " } } */ +/* { dg-final { scan-assembler "\tvcmpgtuw " } } */ + +/* { dg-final { scan-assembler "\tvctsxs " } } */ +/* { dg-final { scan-assembler "\tvctuxs " } } */ + +/* { dg-final { scan-assembler "\tvexptefp " } } */ +/* { dg-final { scan-assembler "\tvlogefp " } } */ +/* { dg-final { scan-assembler "\tvmaddfp " } } */ + +/* { dg-final { scan-assembler "\tvmaxfp " } } */ +/* { dg-final { scan-assembler "\tvmaxsb " } } */ +/* { dg-final { scan-assembler "\tvmaxsh " } } */ +/* { dg-final { scan-assembler "\tvmaxsw " } } */ +/* { dg-final { scan-assembler "\tvmaxub " } } */ +/* { dg-final { scan-assembler "\tvmaxuh " } } */ +/* { dg-final { scan-assembler "\tvmaxuw " } } */ + +/* { dg-final { scan-assembler "\tvmrghb " } } */ +/* { dg-final { scan-assembler "\tvmrghh " } } */ +/* { dg-final { scan-assembler "\tvmrghw " } } */ + +/* { dg-final { scan-assembler "\tvmrglb " } } */ +/* { dg-final { scan-assembler "\tvmrglh " } } */ +/* { dg-final { scan-assembler "\tvmrglw " } } */ + +/* { dg-final { scan-assembler "\tvminfp " } } */ +/* { dg-final { scan-assembler "\tvminsb " } } */ +/* { dg-final { scan-assembler "\tvminsh " } } */ +/* { dg-final { scan-assembler "\tvminsw " } } */ +/* { dg-final { scan-assembler "\tvminub " } } */ +/* { dg-final { scan-assembler "\tvminuh " } } */ +/* { dg-final { scan-assembler "\tvminuw " } } */ + +/* { dg-final { scan-assembler "\tvmhaddshs " } } */ +/* { dg-final { scan-assembler "\tvmhraddshs " } } */ +/* { dg-final { scan-assembler "\tvmladduhm " } } */ +/* { dg-final { scan-assembler "\tvmsumubm " } } */ +/* { dg-final { scan-assembler "\tvmsummbm " } } */ +/* { dg-final { scan-assembler "\tvmsumshm " } } */ +/* { dg-final { scan-assembler "\tvmsumuhm " } } */ +/* { dg-final { scan-assembler "\tvmsumuhs " } } */ +/* { dg-final { scan-assembler "\tvmsumshs " } } */ + +/* { dg-final { scan-assembler "\tvmuleub " } } */ +/* { dg-final { scan-assembler "\tvmulesb " } } */ +/* { dg-final { scan-assembler "\tvmuleuh " } } */ +/* { dg-final { scan-assembler "\tvmulesh " } } */ + +/* { dg-final { scan-assembler "\tvmuloub " } } */ +/* { dg-final { scan-assembler "\tvmulosb " } } */ +/* { dg-final { scan-assembler "\tvmulouh " } } */ +/* { dg-final { scan-assembler "\tvmulosh " } } */ + +/* { dg-final { scan-assembler "\tvnmsubfp " } } */ + +/* { dg-final { scan-assembler "\tvnor " } } */ +/* { dg-final { scan-assembler "\tvor " } } */ +/* { dg-final { scan-assembler "\tvxor " } } */ + +/* { dg-final { scan-assembler "\tvpkuhum " } } */ +/* { dg-final { scan-assembler "\tvpkuwum " } } */ +/* { dg-final { scan-assembler "\tvpkpx " } } */ +/* { dg-final { scan-assembler "\tvpkuhus " } } */ +/* { dg-final { scan-assembler "\tvpkshss " } } */ +/* { dg-final { scan-assembler "\tvpkuwus " } } */ +/* { dg-final { scan-assembler "\tvpkswss " } } */ +/* { dg-final { scan-assembler "\tvpkshus " } } */ +/* { dg-final { scan-assembler "\tvpkswus " } } */ + +/* { dg-final { scan-assembler "\tvperm " } } */ + +/* { dg-final { scan-assembler "\tvrefp " } } */ +/* { dg-final { scan-assembler "\tvrfin " } } */ +/* { dg-final { scan-assembler "\tvrsqrtefp " } } */ + +/* { dg-final { scan-assembler "\tvrlb " } } */ +/* { dg-final { scan-assembler "\tvrlh " } } */ +/* { dg-final { scan-assembler "\tvrlw " } } */ + +/* { dg-final { scan-assembler "\tvsel " } } */ + +/* { dg-final { scan-assembler "\tvslb " } } */ +/* { dg-final { scan-assembler "\tvslh " } } */ +/* { dg-final { scan-assembler "\tvslw " } } */ + +/* { dg-final { scan-assembler "\tvsldoi " } } */ +/* { dg-final { scan-assembler "\tvsl " } } */ +/* { dg-final { scan-assembler "\tvslo " } } */ + +/* { dg-final { scan-assembler "\tvspltb " } } */ +/* { dg-final { scan-assembler "\tvsplth " } } */ +/* { dg-final { scan-assembler "\tvspltw " } } */ +/* { dg-final { scan-assembler "\tvspltisb " } } */ +/* { dg-final { scan-assembler "\tvspltish " } } */ +/* { dg-final { scan-assembler "\tvspltisw " } } */ + +/* { dg-final { scan-assembler "\tvsrb " } } */ +/* { dg-final { scan-assembler "\tvsrh " } } */ +/* { dg-final { scan-assembler "\tvsrw " } } */ +/* { dg-final { scan-assembler "\tvsrab " } } */ +/* { dg-final { scan-assembler "\tvsrah " } } */ +/* { dg-final { scan-assembler "\tvsraw " } } */ +/* { dg-final { scan-assembler "\tvsr " } } */ +/* { dg-final { scan-assembler "\tvsro " } } */ + +/* { dg-final { scan-assembler "\tvsubcuw " } } */ +/* { dg-final { scan-assembler "\tvsubfp " } } */ +/* { dg-final { scan-assembler "\tvsubsbs " } } */ +/* { dg-final { scan-assembler "\tvsubshs " } } */ +/* { dg-final { scan-assembler "\tvsubsws " } } */ +/* { dg-final { scan-assembler "\tvsububs " } } */ +/* { dg-final { scan-assembler "\tvsubuhs " } } */ +/* { dg-final { scan-assembler "\tvsubuws " } } */ +/* { dg-final { scan-assembler "\tvsububm " } } */ +/* { dg-final { scan-assembler "\tvsubuhm " } } */ +/* { dg-final { scan-assembler "\tvsubuwm " } } */ + +/* { dg-final { scan-assembler "\tvsum4ubs " } } */ +/* { dg-final { scan-assembler "\tvsum4sbs " } } */ +/* { dg-final { scan-assembler "\tvsum2sws " } } */ +/* { dg-final { scan-assembler "\tvsumsws " } } */ + +/* { dg-final { scan-assembler "\tvrfiz " } } */ + +/* { dg-final { scan-assembler "\tvupkhsb " } } */ +/* { dg-final { scan-assembler "\tvupkhpx " } } */ +/* { dg-final { scan-assembler "\tvupkhsh " } } */ + +/* { dg-final { scan-assembler "\tvupklsb " } } */ +/* { dg-final { scan-assembler "\tvupklpx " } } */ +/* { dg-final { scan-assembler "\tvupklsh " } } */ diff --git a/gcc/testsuite/gcc.apple/apple-altivec-13.c b/gcc/testsuite/gcc.apple/apple-altivec-13.c new file mode 100644 index 00000000000..f680d20eb7a --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-13.c @@ -0,0 +1,43 @@ +/* APPLE LOCAL file AltiVec */ +/* Additional AltiVec PIM argument type combinations. */ + +/* { dg-do compile { target powerpc*-*-darwin* } } */ +/* { dg-options "-faltivec -Wall" } */ + +vector signed int +LoadUnalignedSI( signed int *p) +{ + vector signed int vload1 = vec_ld( 0, (vector signed int *)p); + if ( ((int)p) * 0xF){ + vector signed int vload2 = vec_ld( 16, (vector signed int *)p); + vector unsigned char vperm = vec_ldl( 0, p); + + vload1 = vec_perm(vload1, vload2, vperm); + } + return vload1; +} + +inline vector float Reciprocal( vector float v ) +{ + + vector float estimate = vec_re( v ); + + return vec_madd( vec_nmsub( estimate, v, (vector float) (1.0) ), estimate, estimate ); +} + +void foo(void) { + vector bool char vbc1 = (vector bool char)(255); + vector pixel vp1, vp2; + vector float vf1, vf2; + vector unsigned char vuc1; + vector unsigned short vus1, vus2; + vector bool short vbs1, vbs2; + vector signed short vss1; + vector signed int vsi1, vsi2; + vbc1 = vec_splat (vbc1, 9); + vp2 = vec_splat (vp1, 7); + vf1 = vec_splat (vf2, 31); + vuc1 = vec_pack (vus1, vus2); + vbc1 = vec_pack (vbs1, vbs2); + vss1 = vec_pack (vsi1, vsi2); +} diff --git a/gcc/testsuite/gcc.apple/apple-altivec-14.c b/gcc/testsuite/gcc.apple/apple-altivec-14.c new file mode 100644 index 00000000000..0bb1dcd1d3a --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-14.c @@ -0,0 +1,15 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-options "-faltivec" } */ +/* Existing AltiVec PIM implementations allow numeric literals with + any number of bits, so long as the value is within allowed range. */ +int foo(void) +{ + vector unsigned char amask = vec_splat_u8 ( 0xFFFFFFF3L ); + vector signed short bmask = vec_splat_s16 ( 0xFFFFFFFFFFFFFFF1LL ); +} + + +/* { dg-final { scan-assembler "vspltisb.+\\-13" } } */ +/* { dg-final { scan-assembler "vspltish.+\\-15" } } */ + diff --git a/gcc/testsuite/gcc.apple/apple-altivec-15.c b/gcc/testsuite/gcc.apple/apple-altivec-15.c new file mode 100644 index 00000000000..96bee290c9b --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-15.c @@ -0,0 +1,39 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-options "-faltivec" } */ + +union agg_def { + vector unsigned int v ; + unsigned int i; +}; + +extern void abort(); + +int my_vec_all_eq(union agg_def a, union agg_def b); +int compare(int d1, int d2); + +int main() { + union agg_def a, b, d1, d2; + + d1.i = 0; + d2.i = 1; + a.v = (vector unsigned int) (2,3,4,5); + b.v = (vector unsigned int) (2,3,4,5); + + d1.i = my_vec_all_eq(a, b); + d2.i = vec_all_eq(a.v, b.v); + + if (compare(d1.i, d2.i)) + return 0; + else + abort(); +} + +int my_vec_all_eq(union agg_def a, union agg_def b) { + return vec_all_eq(a.v, b.v); +} + +int compare(int d1, int d2) { + return (d1 == d2); +} + diff --git a/gcc/testsuite/gcc.apple/apple-altivec-2.c b/gcc/testsuite/gcc.apple/apple-altivec-2.c new file mode 100644 index 00000000000..dddf761b670 --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-2.c @@ -0,0 +1,95 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do run { target powerpc*-*-darwin* } } */ +/* { dg-options "-faltivec" } */ + +/* Program to test PowerPC AltiVec instructions. */ + +#include "../gcc.dg/altivec_check.h" + +extern void abort (void); +#define CHECK_IF(E) if(!(E)) abort() + +vector int a1 = (vector int)( 100, 200, 300, 400 ); +vector int a2 = (vector int)( 500, 600, 700, 800 ); +vector int addi = (vector int)( 600, 800, 1000, 1200 ); +vector int avgi = (vector int)( 300, 400, 500, 600 ); + +vector float f1 = (vector float)( 1.0, 2.0, 3.0, 4.0 ); +vector float f2 = (vector float)( 5.0, 6.0, 7.0, 8.0 ); +vector float f3; +vector float addf1 = (vector float)( 6.0, 8.0, 10.0, 12.0 ); +vector float addf2 = (vector float)( 6.1, 8.1, 10.1, 12.1 ); +vector float addf3 = (vector float)( 6.0, 8.0, 9.9, 12.1 ); +vector int k; +vector float f, g, h; + +int main () +{ + + altivec_check(); /* Exit if AltiVec not available. */ + + k = vec_add (a1, a2); + CHECK_IF (vec_all_eq (addi, k)); + CHECK_IF (vec_all_ge (addi, k)); + CHECK_IF (vec_all_le (addi, k)); + CHECK_IF (vec_any_eq (addi, k)); + CHECK_IF (vec_any_ge (addi, k)); + CHECK_IF (vec_any_le (addi, k)); + CHECK_IF (!vec_any_ne (addi, k)); + CHECK_IF (!vec_any_lt (addi, k)); + CHECK_IF (!vec_any_gt (addi, k)); + CHECK_IF (!vec_any_ne (addi, k)); + CHECK_IF (!vec_any_lt (addi, k)); + CHECK_IF (!vec_any_gt (addi, k)); + + k = vec_avg (a1, a2); + CHECK_IF (vec_all_eq (k, avgi)); + + h = vec_add (f1, f2); + CHECK_IF (vec_all_eq (h, addf1)); + CHECK_IF (vec_all_ge (h, addf1)); + CHECK_IF (vec_all_le (h, addf1)); + CHECK_IF (vec_any_eq (h, addf1)); + CHECK_IF (vec_any_ge (h, addf1)); + CHECK_IF (vec_any_le (h, addf1)); + CHECK_IF (!vec_any_ne (h, addf1)); + CHECK_IF (!vec_any_lt (h, addf1)); + CHECK_IF (!vec_any_gt (h, addf1)); + CHECK_IF (!vec_any_ne (h, addf1)); + CHECK_IF (!vec_any_lt (h, addf1)); + CHECK_IF (!vec_any_gt (h, addf1)); + + CHECK_IF (vec_all_gt (addf2, addf1)); + CHECK_IF (vec_any_gt (addf2, addf1)); + CHECK_IF (vec_all_ge (addf2, addf1)); + CHECK_IF (vec_any_ge (addf2, addf1)); + CHECK_IF (vec_all_ne (addf2, addf1)); + CHECK_IF (vec_any_ne (addf2, addf1)); + CHECK_IF (!vec_all_lt (addf2, addf1)); + CHECK_IF (!vec_any_lt (addf2, addf1)); + CHECK_IF (!vec_all_le (addf2, addf1)); + CHECK_IF (!vec_any_le (addf2, addf1)); + CHECK_IF (!vec_all_eq (addf2, addf1)); + CHECK_IF (!vec_any_eq (addf2, addf1)); + + CHECK_IF (vec_any_eq (addf3, addf1)); + CHECK_IF (vec_any_ne (addf3, addf1)); + CHECK_IF (vec_any_lt (addf3, addf1)); + CHECK_IF (vec_any_le (addf3, addf1)); + CHECK_IF (vec_any_gt (addf3, addf1)); + CHECK_IF (vec_any_ge (addf3, addf1)); + CHECK_IF (!vec_all_eq (addf3, addf1)); + CHECK_IF (!vec_all_ne (addf3, addf1)); + CHECK_IF (!vec_all_lt (addf3, addf1)); + CHECK_IF (!vec_all_le (addf3, addf1)); + CHECK_IF (!vec_all_gt (addf3, addf1)); + CHECK_IF (!vec_all_ge (addf3, addf1)); + + CHECK_IF (vec_all_numeric (addf3)); + CHECK_IF (vec_all_in (addf1, addf2)); + + CHECK_IF (vec_step (vector bool char) == 16); + CHECK_IF (vec_step (addf3) == 4); + + return 0; +} diff --git a/gcc/testsuite/gcc.apple/apple-altivec-3.c b/gcc/testsuite/gcc.apple/apple-altivec-3.c new file mode 100644 index 00000000000..1112913de1b --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-3.c @@ -0,0 +1,14 @@ +/* APPLE LOCAL file AltiVec */ +/* Providing '-maltivec' should ensure that AltiVec codegen for block copies is enabled, + even if '-faltivec' is also specified. */ +/* { dg-do compile { target powerpc*-*-darwin* } } */ +/* { dg-options "-faltivec -maltivec" } */ +typedef struct { vector int a; vector int b; } Scld1; + +void testvaScld1 (int n, Scld1); + +void foo () +{ + Scld1 g1sScld1; + testvaScld1 (1, g1sScld1); /* { dg-bogus "disabled" } */ +} diff --git a/gcc/testsuite/gcc.apple/apple-altivec-4.c b/gcc/testsuite/gcc.apple/apple-altivec-4.c new file mode 100644 index 00000000000..d05aac5fedc --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-4.c @@ -0,0 +1,20 @@ +/* APPLE LOCAL file AltiVec */ +/* Additional AltiVec PIM argument type combinations. */ + +/* { dg-do compile { target powerpc*-*-darwin* } } */ +/* { dg-options "-faltivec" } */ + +typedef float R; +typedef vector float V; +V gV = (vector float)(0.3, 0.4, 0.5, 0.6); + +void foo(int ovs) { + vector float vFGravity1, vFGravity2, vCombined1OverR_12 = (vector float)(0.3); + V v; R *x = (R *)&gV; + + vFGravity1 = vec_mergeh(vCombined1OverR_12, vCombined1OverR_12); + vFGravity2 = vec_mergel(vCombined1OverR_12, vCombined1OverR_12); + + vec_ste (v, 0, x); + vec_ste (v, 4 + ovs, x); +} diff --git a/gcc/testsuite/gcc.apple/apple-altivec-5.c b/gcc/testsuite/gcc.apple/apple-altivec-5.c new file mode 100644 index 00000000000..0c7dd9bcb60 --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-5.c @@ -0,0 +1,31 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-maltivec" } */ + +#include <altivec.h> + +extern void abort(); + +int main() +{ + vector float tiny = (vector float) ((vector unsigned int) (0x00800000, 0xBF800000, 0x3E800000, 0)); + unsigned int af[4] = { + (unsigned int)(unsigned int)0x00800000, + (unsigned int)(unsigned int)0xBF800000, + (unsigned int)(unsigned int)0x3E800000, + (unsigned int)(unsigned int)0}; + + union u { + vector float vf; + unsigned int ai[4]; + }vu; + int i; + + vu.vf = tiny; + + for (i=0; i < 4; i++) + if (af[i] != vu.ai[i]) + abort(); + + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/apple-altivec-6.c b/gcc/testsuite/gcc.apple/apple-altivec-6.c new file mode 100644 index 00000000000..09e1f6861bf --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-6.c @@ -0,0 +1,31 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-maltivec" } */ + +#include <altivec.h> + +extern void abort(); + +int main() +{ + vector unsigned int tiny = (vector unsigned int) ((vector signed int) (0x00800000, 0xBF800000, 0x3E800000, 0)); + unsigned int af[4] = { + (signed int)0x00800000, + (signed int)0xBF800000, + (signed int)0x3E800000, + (signed int)0}; + + union u { + vector unsigned int vf; + unsigned int ai[4]; + }vu; + int i; + + vu.vf = tiny; + + for (i=0; i < 4; i++) + if (af[i] != vu.ai[i]) + abort(); + + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/apple-altivec-7.c b/gcc/testsuite/gcc.apple/apple-altivec-7.c new file mode 100644 index 00000000000..ffbb408aadd --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-7.c @@ -0,0 +1,34 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-maltivec" } */ + +#include <altivec.h> + +extern void abort(); + +int main() +{ + + static vector float vINF = + ( vector float ) ( ( vector unsigned int ) ( 0x7F800000, 0x7F800000, 0x7F800000, 0x7F800000 ) ); + + unsigned int af[4] = { + (unsigned int)0x7F800000, + (unsigned int)0x7F800000, + (unsigned int)0x7F800000, + (unsigned int)0x7F800000}; + + union u { + vector float vf; + unsigned int ai[4]; + }vu; + + int i; + + vu.vf = vINF; + + for (i=0; i < 4; i++) + if (af[i] != vu.ai[i]) + abort(); + + return 0; +} diff --git a/gcc/testsuite/gcc.apple/apple-altivec-8.c b/gcc/testsuite/gcc.apple/apple-altivec-8.c new file mode 100644 index 00000000000..fb2389526d2 --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-8.c @@ -0,0 +1,36 @@ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-maltivec -O2" } */ + +/* ICEs at -O1 or more */ + +#include <altivec.h> + +extern void abort(); + +int main() +{ + + const static vector float vINF = + ( vector float ) ( ( vector unsigned int ) ( 0x7F800000, 0x7F800000, 0x7F800000, 0x7F800000 ) ); + + unsigned int af[4] = { + (unsigned int)0x7F800000, + (unsigned int)0x7F800000, + (unsigned int)0x7F800000, + (unsigned int)0x7F800000}; + + union u { + vector float vf; + unsigned int ai[4]; + }vu; + + int i; + + vu.vf = vINF; + + for (i=0; i < 4; i++) + if (af[i] != vu.ai[i]) + abort(); + + return 0; +} diff --git a/gcc/testsuite/gcc.apple/apple-altivec-9.c b/gcc/testsuite/gcc.apple/apple-altivec-9.c new file mode 100644 index 00000000000..938baca5356 --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-9.c @@ -0,0 +1,9 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-options "-faltivec -ftrapping-math" } */ + +int vConvert_PlanarFtoPlanar16F( ) +{ + vector float twoP10 = (vector float) (0x1.0p+10f, 0x1.0p+24f, 0x1.0p+102f, 1.0f/0.0f ); + return 0; +} diff --git a/gcc/testsuite/gcc.apple/apple-altivec-abi-test.c b/gcc/testsuite/gcc.apple/apple-altivec-abi-test.c new file mode 100644 index 00000000000..5361cc7d314 --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-abi-test.c @@ -0,0 +1,39 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do compile { target powerpc*-*-darwin* } } */ +/* { dg-options "-O -faltivec" } */ +/* { dg-final { scan-assembler "vspltisw v2,1" } } */ +/* { dg-final { scan-assembler "vspltisw v3,2" } } */ +/* { dg-final { scan-assembler "vspltisw v4,3" } } */ +/* { dg-final { scan-assembler "vspltisw v5,4" } } */ +/* { dg-final { scan-assembler "vspltisw v6,5" } } */ +/* { dg-final { scan-assembler "vspltisw v7,6" } } */ +/* { dg-final { scan-assembler "vspltisw v8,7" } } */ +/* { dg-final { scan-assembler "vspltisw v9,8" } } */ +/* { dg-final { scan-assembler "vspltisw v10,9" } } */ +/* { dg-final { scan-assembler "vspltisw v11,10" } } */ +/* { dg-final { scan-assembler "vspltisw v12,11" } } */ +/* { dg-final { scan-assembler "vspltisw v13,12" } } */ + +void +foo (vector signed int v0, vector signed int v1, vector signed int v2, + vector signed int v3, vector signed int v4, vector signed int v5, + vector signed int v6, vector signed int v7, vector signed int v8, + vector signed int v9, vector signed int v10, vector signed int v11, + vector signed int v12, + int z, double u); + +int main(void) +{ + foo ((vector signed int) ( 1 ), (vector signed int) ( 2 ), + (vector signed int) ( 3 ), + (vector signed int) ( 4 ), (vector signed int) ( 5 ), + (vector signed int) ( 6 ), (vector signed int) ( 7 ), + (vector signed int) ( 8 ), (vector signed int) ( 9 ), + (vector signed int) ( 10 ), (vector signed int) ( 11 ), + (vector signed int) ( 12 ), (vector signed int) ( 13 ), + 20, 3.0); +} + + + + diff --git a/gcc/testsuite/gcc.apple/apple-altivec-abi.c b/gcc/testsuite/gcc.apple/apple-altivec-abi.c new file mode 100644 index 00000000000..264791801c9 --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-abi.c @@ -0,0 +1,66 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-faltivec" } */ + +#include <stdio.h> + +typedef vector signed int VSI; + +VSI VI( + VSI v2, + int gpr3, + VSI v3, + int gpr4, + VSI v4, + int gpr5, + VSI v5, + int gpr6, + int gpr7, + int gpr8, + int gpr9, + VSI v6, + int gpr10, /* gpr3-gpr10 in registers */ + VSI v7, + VSI v8, + VSI v9, + VSI v10, + VSI v11, + VSI v12, + VSI v13, /* All in v2-v13 */ + volatile VSI v14, + int gpr11, + int gpr12, + int gpr13, + int gpr14, + VSI v15, + VSI v16, int* sum) +{ + *sum = gpr3 + gpr4 + gpr5 + gpr6 + gpr7 + gpr8 + gpr9 + gpr10 + gpr11 + gpr12 + gpr13 + gpr14; + return v2+v3+v4+v5+v6+v7+v8+v9+v10+v11+v12+v13+v14+v15+v16; +} + +extern void abort(); + +int main() +{ + union u { + VSI uv; + int val[4]; + } union_var; + + int i; + + int sum; + union_var.uv = + VI((VSI){1,1,1,1},3,(VSI){1,1,1,1},4,(VSI){1,1,1,1},5,(VSI){1,1,1,1},6,7,8,9, + (VSI){1,1,1,1},10,(VSI){1,1,1,1},(VSI){1,1,1,1},(VSI){1,1,1,1},(VSI){1,1,1,1}, + (VSI){1,1,1,1},(VSI){1,1,1,1},(VSI){1,1,1,1},(VSI){1,1,1,1},11,12,13,14, + (VSI){1,1,1,1},(VSI){1,1,1,1}, &sum); + if (sum != 102) + abort(); + + for (i=0; i < 4; i++) + if (union_var.val[i] != 15) + abort(); + return 0; +} diff --git a/gcc/testsuite/gcc.apple/apple-altivec-builtin-nanf.c b/gcc/testsuite/gcc.apple/apple-altivec-builtin-nanf.c new file mode 100644 index 00000000000..fb9253929f2 --- /dev/null +++ b/gcc/testsuite/gcc.apple/apple-altivec-builtin-nanf.c @@ -0,0 +1,8 @@ +/* APPLE LOCAL file AltiVec */ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-options "-faltivec" } */ + +void _sqrt() +{ + __vector float vNAN = (__vector float)(__builtin_nanf("0x7fc00000")); +} diff --git a/gcc/testsuite/gcc.apple/applecc.c b/gcc/testsuite/gcc.apple/applecc.c new file mode 100644 index 00000000000..757ad573272 --- /dev/null +++ b/gcc/testsuite/gcc.apple/applecc.c @@ -0,0 +1,14 @@ +/* APPLE LOCAL file Apple version */ +/* { dg-do compile } */ + +#if __APPLE_CC__ < 1000 +#error build number too small +#endif +#if __APPLE_CC__ > 32768 +#error build number too big +#endif +#if ! ( __APPLE_CC__ > 1000) +#error build number not really a number +#endif + +int x = __APPLE_CC__; diff --git a/gcc/testsuite/gcc.apple/asm-block-1.c b/gcc/testsuite/gcc.apple/asm-block-1.c new file mode 100644 index 00000000000..3ad73fb12f7 --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-block-1.c @@ -0,0 +1,75 @@ +/* APPLE LOCAL file CW asm blocks */ +/* Test asm-syntax blocks within functions. */ + +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks" } */ + +void abort(void); + +int +foo (int argx, int argy) +{ + register int locx = argx, locy = argy, rslt; + asm { + add rslt,locx,locy + } + return rslt; +} + +/* Exercise corners of syntax. */ + +int +bar () +{ + register int rslt = 100; + asm { + // Combos of instructions on a line + + nop + ; + nop + nop ; + ; nop + nop ; nop + ; nop ;;; li r3,95 ; nop ; + // '.' in an opcode + add. r6,r6,r5 + } + return rslt; +} + +int baz () +{ + register int rslt = 1; + asm { + li r8,29+(2 * 3); + add rslt,rslt,r8; + b @192 + @34 + nop + ble+ @34 + b forward + abc: + b abc + @abc: + b @abc + forward: ; @192: + nop + ; + sameline: nop + x1: @x2 @x3: nop ; @x4 x5: + } + return rslt; +} + +int +main () +{ + if (foo (22, 23) != 45) + abort (); + if (bar () != 100) + abort (); + if (baz () != 36) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.apple/asm-block-2.c b/gcc/testsuite/gcc.apple/asm-block-2.c new file mode 100644 index 00000000000..586f2c73357 --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-block-2.c @@ -0,0 +1,88 @@ +/* APPLE LOCAL file CW asm blocks */ +/* Test structure refs in asm-syntax blocks within functions. */ + +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks -O2" } */ + +void abort(void); + + +typedef struct astruct { + int arr[40]; + char charfield; + int fieldx; + int fieldy; +} atypedef; + +union aunion { + int field1; + int field2; +}; + +int fun1 (struct astruct *x) +{ + int loc; + asm { + lwz loc, astruct.fieldx(x) + addi loc, loc, 42 + stw loc, astruct.fieldx+4(x) + } + return loc; +} + +int fun2 (atypedef *x) +{ + int loc; + + asm { + lwz loc, atypedef.fieldx(r3) + addi loc, loc, 43 + stw loc, 4 + astruct.fieldx(x) + } + return loc; +} + +int fun3(int arg) +{ + int loc; + + asm { + mr loc, r3 + addi loc, loc, aunion.field1 + } + return loc; +} + +int fun4 (struct astruct *arg) +{ + int loc; + asm { + lbz loc, arg->charfield + addi loc, loc, 1 + } + return loc; +} + +struct astruct glob; +union uglob; + +int +main () +{ + glob.charfield = 'b'; + glob.fieldx = 22; + if (fun1 (&glob) != 64) + abort (); + if (glob.fieldy != 64) + abort (); + if (fun2 (&glob) != 65) + abort (); + if (glob.fieldy != 65) + abort (); + if (fun3 (89) != 89) + abort (); + if (fun4 (&glob) != 'c') + abort (); + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/asm-block-3.c b/gcc/testsuite/gcc.apple/asm-block-3.c new file mode 100644 index 00000000000..c3071dceaf2 --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-block-3.c @@ -0,0 +1,11 @@ +/* APPLE LOCAL file CW asm blocks */ +/* Test single line asms */ + +/* { dg-do compile } */ +/* { dg-options "-fasm-blocks" } */ + +void +bar () +{ + asm { nop }; +} diff --git a/gcc/testsuite/gcc.apple/asm-function-1.c b/gcc/testsuite/gcc.apple/asm-function-1.c new file mode 100644 index 00000000000..9a031f27386 --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-1.c @@ -0,0 +1,51 @@ +/* APPLE LOCAL file CW asm blocks */ +/* Test whole asm functions. */ + +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks -O2" } */ + +void abort(void); + +asm int +foo (register int argx, register int argy) +{ + add r3, argx, argy +} + +#define rsltreg r3 + +asm int +foo1 (register int argx, register int argy) +{ + register int loc1, loc2; + nop + li loc1, 100 + li rsltreg,0 + b @a34 + add rsltreg, argx, argy +@a34 + add rsltreg, rsltreg, loc1 + blr +} + +extern asm int foo2(int x, float y) +{ +#pragma unused(x) +#pragma unused(x,y) + li rsltreg, 48; +#pragma unused(y) + nop +#pragma unused(x) +} + +int +main () +{ + if (foo (22, 23) != 45) + abort (); + if (foo1 (1, 2) != 100) + abort (); + if (foo2 (100, 1.2) != 48) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.apple/asm-function-10.c b/gcc/testsuite/gcc.apple/asm-function-10.c new file mode 100644 index 00000000000..46c5cb09591 --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-10.c @@ -0,0 +1,16 @@ +/* APPLE LOCAL file CW asm blocks */ +/* { dg-do assemble { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks" } */ + +asm void foo() +{ + lis r1,(kUndefindedConstant<<10)|(3<<5)|(7) + rlwinm r0,r2,16+kUndefindedConstant,31 /* { dg-error "block assembly operand not recognized" } */ + cmpwi cr7,r1,kUndefindedConstant-1 /* { dg-error "block assembly operand not recognized" } */ +} /* { dg-error "block assembly operand not recognized" } */ + +int main (int argc, char * const argv[]) +{ + foo(); +} + diff --git a/gcc/testsuite/gcc.apple/asm-function-11.c b/gcc/testsuite/gcc.apple/asm-function-11.c new file mode 100644 index 00000000000..e75f3c132f8 --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-11.c @@ -0,0 +1,24 @@ +/* APPLE LOCAL file CW asm blocks */ +/* { dg-do assemble { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks" } */ + +struct tDummyStruct +{ + unsigned long fDummy; + unsigned long fSample; +}; + +asm void foo() +{ + lwz r1,-8+tDummyStruct.fSample(r2) + stw r1,-8+tDummyStruct.fSample(r2) + lwz r1,-8-(tDummyStruct.fSample-tDummyStruct.fDummy)(r2) + stw r1,-8-(tDummyStruct.fSample-tDummyStruct.fDummy)(r2) +} + +int main (int argc, char * const argv[]) +{ + foo(); +} + + diff --git a/gcc/testsuite/gcc.apple/asm-function-12.c b/gcc/testsuite/gcc.apple/asm-function-12.c new file mode 100644 index 00000000000..5a1a3d6af55 --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-12.c @@ -0,0 +1,18 @@ +/* APPLE LOCAL file CW asm blocks */ +/* { dg-do assemble { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks" } */ + +asm void foo() +{ + b .+8 + bl .+24 + b .-8 + bl .-32 + andi. r1,r0,2 +} + +int main (int argc, char * const argv[]) +{ + foo(); +} + diff --git a/gcc/testsuite/gcc.apple/asm-function-13.c b/gcc/testsuite/gcc.apple/asm-function-13.c new file mode 100644 index 00000000000..ace3cba12ef --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-13.c @@ -0,0 +1,26 @@ +/* APPLE LOCAL file CW asm blocks */ +/* { dg-do assemble { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks" } */ + +asm void foo() +{ + .align 15 + andi. r1,r2, 3 + .align 10 + b .+8 + .align 4 + b .-16 + .align 3 + lha r1, 4(r3) + .align 4 + add r1,r2,r3 + .align 3 + .align 4 +} + +int main (int argc, char * const argv[]) +{ + foo(); +} + + diff --git a/gcc/testsuite/gcc.apple/asm-function-14.c b/gcc/testsuite/gcc.apple/asm-function-14.c new file mode 100644 index 00000000000..56458390f4c --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-14.c @@ -0,0 +1,11 @@ +/* APPLE LOCAL file CW asm blocks */ +/* { dg-do assemble { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks" } */ + +asm void foo() +{ + dcbst r0,r5 /* { dg-error "r0 not allowed for parameter 1" } */ + + li r1, kUndefindedConstant /* { dg-error "expression must be absolute" } */ + +} diff --git a/gcc/testsuite/gcc.apple/asm-function-2.c b/gcc/testsuite/gcc.apple/asm-function-2.c new file mode 100644 index 00000000000..9ac177eff08 --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-2.c @@ -0,0 +1,73 @@ +/* APPLE LOCAL file CW asm blocks */ +/* Test whole asm functions. */ + +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks -O2" } */ + +void abort(void); + +asm void normal_fn () +{ + nop +} + +asm void nofralloc_fn () +{ + nofralloc + nop + blr +} + +asm void fralloc_fn () +{ + fralloc + nop +} + +asm int fralloc_fn_1 () +{ + fralloc + mr r4,r1 + frfree + sub r3,r4,r1 + blr +} + +asm int fralloc_fn_2 () +{ + fralloc 1000 + nop + frfree + blr +} + +asm int fralloc_fn_3 () +{ + int loc1, loc2; + fralloc 41 + nop + mr r3, loc2 + frfree + mr r3, loc1 + blr +} + +asm int f6 () +{ + opword 0x386004d2 /* li r3,1234 */ +} + +main() +{ + normal_fn (); + nofralloc_fn (); + fralloc_fn (); + /* + fralloc_fn_1 (); + fralloc_fn_2 (); + fralloc_fn_3 (); + */ + if (f6 () != 1234) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.apple/asm-function-3.c b/gcc/testsuite/gcc.apple/asm-function-3.c new file mode 100644 index 00000000000..944900fb75b --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-3.c @@ -0,0 +1,26 @@ +/* APPLE LOCAL file CW asm blocks */ +/* More tests of asm functions. */ + +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks -O2" } */ + +void abort(void); + +/* Return 0 if xer and spr1 both have the same data. */ + +asm int +test_spr () +{ + mfspr r5,xer + mfspr r4,spr1 + sub r3,r4,r5 +} + +int +main () +{ + if (test_spr ()) + abort (); + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/asm-function-4.c b/gcc/testsuite/gcc.apple/asm-function-4.c new file mode 100644 index 00000000000..f3889a413bd --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-4.c @@ -0,0 +1,62 @@ +/* APPLE LOCAL file CW asm blocks */ +/* Test asm with macros. */ + +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks -O2" } */ + +void abort(void); + +#define mac1 add r3, argx, argy + +asm int +foo (register int argx, register int argy) +{ + mac1 +} + +#define rsltreg r3 +#define mac2(x,y) add rsltreg,x,y + +asm int +foo1 (register int argx, register int argy) +{ + register int loc1, loc2; + nop + li loc1, 100 + li rsltreg,0 + b @a34 + mac2(argx,argy) +@a34 + mac2(rsltreg,loc1) + blr +} + +#define limac li +#define num 48 + +asm int foo2(int x, float y) +{ +#pragma unused(x) +#pragma unused(x,y) + limac rsltreg, num; +#define mac3(zzz) \ + limac r4, zzz +#pragma unused(y) + nop + mac3(num) +#pragma unused(x) + add r3,r3,r4 +} + +int +main () +{ + if (foo (22, 23) != 45) + abort (); + if (foo1 (1, 2) != 100) + abort (); + if (foo2 (100, 1.2) != 2 * num) + abort (); + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/asm-function-5.c b/gcc/testsuite/gcc.apple/asm-function-5.c new file mode 100644 index 00000000000..7808daaa81b --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-5.c @@ -0,0 +1,49 @@ +/* APPLE LOCAL file CW asm blocks */ +/* Test function calls in asm functions. */ + +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks -O2" } */ + +void abort(void); + +int glob = 0; + +int other (); +int stubfn (); +int localfn () { return other (); } + +asm void foo(int arg) +{ + nofralloc + mflr r0 + stmw r30,-8(r1) + stw r0,8(r1) + stwu r1,-80(r1) + bl stubfn + /* bl L_stubfn$stub */ + lwz r0,88(r1) + addi r1,r1,80 + mtlr r0 + lmw r30,-8(r1) + b localfn +} + +void bar (int arg) +{ + stubfn (); + localfn (); +} + +int stubfn () { return other(); } + +int other () { return ++glob; } + +int main () +{ + bar(34); + foo(92); + if (glob != 4) + abort (); + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/asm-function-6.c b/gcc/testsuite/gcc.apple/asm-function-6.c new file mode 100644 index 00000000000..1ff272e183e --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-6.c @@ -0,0 +1,33 @@ +/* APPLE LOCAL file CW asm blocks */ +/* Test entry points in asm functions. */ + +/* { dg-do run { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks -O2" } */ + +void abort(void); + +int entry1(int); +int entry2(int); +int entry3(int); + +asm int foo(int x) +{ + addi r3,r3,45 + entry entry1 + addi r3,r3,1 + entry static entry2 + addi r3,r3,1 + entry extern entry3 + addi r3,r3,1 +} + +int main () +{ + if (entry1(0) != 3) + abort(); + if (entry2(89) != 91) + abort(); + if (entry3(100) != 101) + abort(); + return 0; +} diff --git a/gcc/testsuite/gcc.apple/asm-function-7.c b/gcc/testsuite/gcc.apple/asm-function-7.c new file mode 100644 index 00000000000..c182fd05c1e --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-7.c @@ -0,0 +1,17 @@ +/* APPLE LOCAL file CW asm blocks */ +/* Test la16(TABLE), lo16(TABLE), and bdnz+. */ + +/* { dg-do assemble { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks" } */ + +double TABLE[4]={2.0, 1./2., 3., 1.}; + +asm void SQRT() +{ + lis r3,ha16(TABLE) + addi r3,r3,lo16(TABLE) +@cycle: + fmul fp6,fp1,fp1 + bdnz+ @cycle + blr +} diff --git a/gcc/testsuite/gcc.apple/asm-function-8.c b/gcc/testsuite/gcc.apple/asm-function-8.c new file mode 100644 index 00000000000..2e559043308 --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-8.c @@ -0,0 +1,14 @@ +/* APPLE LOCAL file CW asm blocks */ +/* Test lo16(foo)(v) and ha16(foo). */ + +/* { dg-do assemble { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks" } */ + +int foo; + +asm int fun1 () +{ + int v; + addis v,0,ha16(foo) + lwz r3,lo16(foo)(v) +} diff --git a/gcc/testsuite/gcc.apple/asm-function-9.c b/gcc/testsuite/gcc.apple/asm-function-9.c new file mode 100644 index 00000000000..7b5e3101b68 --- /dev/null +++ b/gcc/testsuite/gcc.apple/asm-function-9.c @@ -0,0 +1,12 @@ +/* APPLE LOCAL file CW asm blocks */ +/* Test macros with . in the opcode. */ + +/* { dg-do assemble { target powerpc*-*-* } } */ +/* { dg-options "-fasm-blocks" } */ + +#define foodef() rlwinm. r4,r4,31,16,31 + +asm void foo (void) +{ + foodef() +} diff --git a/gcc/testsuite/gcc.apple/const-cfstring-1.c b/gcc/testsuite/gcc.apple/const-cfstring-1.c new file mode 100644 index 00000000000..3e8c1194d20 --- /dev/null +++ b/gcc/testsuite/gcc.apple/const-cfstring-1.c @@ -0,0 +1,29 @@ +/* APPLE LOCAL file constant CFStrings */ +/* Test whether the __builtin__CFStringMakeConstantString + "function" fails gracefully when handed a non-constant + argument. This will only work on MacOS X 10.1.2 and later. */ +/* Developed by Ziemowit Laski <zlaski@apple.com>. */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-fconstant-cfstrings" } */ + +typedef const struct __CFString *CFStringRef; + +#ifdef __CONSTANT_CFSTRINGS__ +#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR)) +#else +#error __CONSTANT_CFSTRINGS__ not defined +#endif + +extern int cond; +extern const char *func(void); + +const CFStringRef s0 = CFSTR("Hello" "there"); + +int main(void) { + CFStringRef s1 = CFSTR("Str1"); + CFStringRef s2 = CFSTR(cond? "Str2": "Str3"); /* { dg-error "literal expression is not constant" } */ + CFStringRef s3 = CFSTR(func()); /* { dg-error "literal expression is not constant" } */ + + return 0; +} diff --git a/gcc/testsuite/gcc.apple/const-cfstring-2.c b/gcc/testsuite/gcc.apple/const-cfstring-2.c new file mode 100644 index 00000000000..cbf09d3a977 --- /dev/null +++ b/gcc/testsuite/gcc.apple/const-cfstring-2.c @@ -0,0 +1,13 @@ +/* APPLE LOCAL file constant CFStrings */ +/* Test whether the __builtin__CFStringMakeConstantString + "function" fails gracefully when used without the + -fconstant-cfstrings flag. */ +/* Developed by Ziemowit Laski <zlaski@apple.com>. */ + +/* { dg-options "-fno-constant-cfstrings" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +typedef const struct __CFString *CFStringRef; + +const CFStringRef S = ((CFStringRef)__builtin___CFStringMakeConstantString("Testing")); +/* { dg-error "built-in" "built-in function .* requires .* flag" { target *-*-* } 12 } */ diff --git a/gcc/testsuite/gcc.apple/const-cfstring-3.c b/gcc/testsuite/gcc.apple/const-cfstring-3.c new file mode 100644 index 00000000000..aba558b1f8b --- /dev/null +++ b/gcc/testsuite/gcc.apple/const-cfstring-3.c @@ -0,0 +1,29 @@ +/* APPLE LOCAL file constant CFStrings */ +/* Test whether the __builtin__CFStringMakeConstantString + "function" generates compile-time objects with the correct layout. */ +/* Developed by Ziemowit Laski <zlaski@apple.com>. */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-fconstant-cfstrings" } */ + +typedef const struct __CFString *CFStringRef; + +#ifdef __CONSTANT_CFSTRINGS__ +#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR)) +#else +#error __CONSTANT_CFSTRINGS__ not defined +#endif + +extern int cond; +extern const char *func(void); + +CFStringRef s0 = CFSTR("Hello" "there"); + +void foo(void) { + const CFStringRef s1 = CFSTR("Str1"); + + s0 = s1; +} + +/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+4\n" } } */ +/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+10\n" } } */ diff --git a/gcc/testsuite/gcc.apple/const-cfstring-4.c b/gcc/testsuite/gcc.apple/const-cfstring-4.c new file mode 100644 index 00000000000..0c7c326100e --- /dev/null +++ b/gcc/testsuite/gcc.apple/const-cfstring-4.c @@ -0,0 +1,30 @@ +/* APPLE LOCAL file */ +/* Test constant cfstring and writabe strings interaction. + Radar 3978580. */ +/* Developed by Devang Patel <dpatel@apple.com>. */ + +/* { dg-do assemble { target *-*-darwin* } } */ +/* { dg-options "-fconstant-cfstrings -fwritable-strings" } */ + +typedef const struct __CFString *CFStringRef; + +#ifdef __CONSTANT_CFSTRINGS__ +#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR)) +#else +#error __CONSTANT_CFSTRINGS__ not defined +#endif + +extern void bar (const void **); + +static void foo() +{ + CFStringRef keys[] = + { + CFSTR("blah1"), + CFSTR("blah2") + }; + int count = sizeof(keys) / sizeof(keys[0]); + + bar ((const void **)keys); +} + diff --git a/gcc/testsuite/gcc.apple/cw-altivec-asm-block.c b/gcc/testsuite/gcc.apple/cw-altivec-asm-block.c new file mode 100644 index 00000000000..1b3baaa6e2f --- /dev/null +++ b/gcc/testsuite/gcc.apple/cw-altivec-asm-block.c @@ -0,0 +1,35 @@ +/* APPLE LOCAL file CW asm blocks with AltiVec insn. */ +/* Test asm-syntax blocks within functions. */ + +/* { dg-do run { target powerpc*-*-darwin* } } */ +/* { dg-options "-faltivec -fasm-blocks" } */ + +extern void abort(); + +int main( void ) +{ + int i; + register vector float a = (vector float) (1.0f); + register vector float b = (vector float) (2.0f); + register vector float c = (vector float) (3.0f); + float result[4] = {5.00, 5.00, 5.00, 5.00}; + union u { + vector float v; + float fv[4]; + } uv; + + asm + { + vmaddfp c, a, c, b + } + + uv.v = c; + + for (i=0; i < 4; i++) + if (uv.fv[i] != result[i]) + abort(); + + return 0; +} + + diff --git a/gcc/testsuite/gcc.apple/darwin-fsel-3.c b/gcc/testsuite/gcc.apple/darwin-fsel-3.c new file mode 100644 index 00000000000..3c7b19e0453 --- /dev/null +++ b/gcc/testsuite/gcc.apple/darwin-fsel-3.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target powerpc*-*-darwin* } } */ +/* { dg-options "-O -mpowerpc-gfxopt" } */ +/* { dg-final { scan-assembler "fsub" } } */ + +/* This is the same as gcc.dg/ppc-fsel-3.c, which is checking to see + that this optimization is *not* done, that is, that + -fno-trapping-math is the default. They can't both pass. */ + +double foo(double a, double b, double c, double d) +{ + return a < b ? c : d; +} diff --git a/gcc/testsuite/gcc.apple/dg.exp b/gcc/testsuite/gcc.apple/dg.exp new file mode 100644 index 00000000000..83910af8ac8 --- /dev/null +++ b/gcc/testsuite/gcc.apple/dg.exp @@ -0,0 +1,40 @@ +# APPLE LOCAL file testsuite +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Apple-specific GCC testsuite driver. +# Note that this is basically a clone of gcc.dg/dg.exp, updated +# whenever the original file changes (which is not very often). + +# Load support procs. +load_lib gcc-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " -ansi -pedantic-errors" +} + +# Initialize `dg'. +dg-init + +# Main loop. +# APPLE LOCAL preprocess .s files +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cSs\]]] \ + "" $DEFAULT_CFLAGS + +# All done. +dg-finish diff --git a/gcc/testsuite/gcc.apple/execute/bitfield-1.c b/gcc/testsuite/gcc.apple/execute/bitfield-1.c new file mode 100644 index 00000000000..bd472d28ccb --- /dev/null +++ b/gcc/testsuite/gcc.apple/execute/bitfield-1.c @@ -0,0 +1,52 @@ +/* { dg-do run { target *-*-darwin* } } */ +/* { dg-options "-O2 -fss-const-prop" } */ +/* APPLE LOCAL file bitfield zero initialization */ +/* <rdar://problem/3366203>:Setup Assistant crashes in SetModificationDateToPasteboard */ +/* <rdar://problem/3379022>:GCC compiler error in bitfield handling */ + + +typedef struct +{ + unsigned int b01 : 1; + unsigned int b02 : 2; + unsigned int b03 : 1; + unsigned int b04 : 1; + unsigned int b05 : 1; + unsigned int b06 : 1; + unsigned int b07 : 3; + unsigned int b08 : 3; + unsigned int b09 : 3; + unsigned int b10 : 3; + unsigned int b11 : 8; + unsigned int b12 : 1; + unsigned int b13 : 4; +} test_struct; + +void func( test_struct* s, int t ) +{ + s->b12 = 0; + s->b02 = 0; +} + +main() +{ + test_struct r = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; + + func (&r, 42); + + if (r.b01 != 1 + || r.b03 != 1 + || r.b04 != 1 + || r.b05 != 1 + || r.b06 != 1 + || r.b07 != 1 + || r.b08 != 1 + || r.b09 != 1 + || r.b10 != 1 + || r.b11 != 1 + || r.b13 != 1) + { + abort(); + } + exit (0); +} diff --git a/gcc/testsuite/gcc.apple/execute/execute.exp b/gcc/testsuite/gcc.apple/execute/execute.exp new file mode 100644 index 00000000000..f7b1f5b5eeb --- /dev/null +++ b/gcc/testsuite/gcc.apple/execute/execute.exp @@ -0,0 +1,43 @@ +# Copyright (C) 1991, 1992, 1993, 1995, 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This file was written by Rob Savoye. (rob@cygnus.com) +# Modified and maintained by Jeffrey Wheat (cassidy@cygnus.com) + +# +# These tests come from Torbjorn Granlund (tege@cygnus.com) +# C torture test suite. +# + +if $tracelevel then { + strace $tracelevel +} + +# load support procs +load_lib c-torture.exp + +# +# main test loop +# + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + + c-torture-execute $src +} diff --git a/gcc/testsuite/gcc.apple/fenv-minmax-1.c b/gcc/testsuite/gcc.apple/fenv-minmax-1.c new file mode 100644 index 00000000000..4385ae3ced6 --- /dev/null +++ b/gcc/testsuite/gcc.apple/fenv-minmax-1.c @@ -0,0 +1,11 @@ +/* APPLE LOCAL file Radar 3943021 */ +/* { dg-do compile { target powerpc-*-darwin* } } */ +/* { dg-options "-ffast-math" } */ +#pragma GCC fenv +float size[2], tex_size; +void +test_of_pragma_fenv () +{ + size[0] = ((size[0]) < (tex_size) ? (size[0]) : (tex_size)); +} + diff --git a/gcc/testsuite/gcc.apple/framework1.c b/gcc/testsuite/gcc.apple/framework1.c new file mode 100644 index 00000000000..bd0203669c2 --- /dev/null +++ b/gcc/testsuite/gcc.apple/framework1.c @@ -0,0 +1,12 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. */ + +/* { dg-do preprocess } */ +/* { dg-options "-nostdinc -c -F${srcdir}/gcc.apple" } */ + +/* Contributed by Devang Patel <dpatel@apple.com> */ + +#include <one/one.h> +int main() +{ + return 0; +} diff --git a/gcc/testsuite/gcc.apple/fwritable-strings.c b/gcc/testsuite/gcc.apple/fwritable-strings.c new file mode 100644 index 00000000000..4cf335a0db3 --- /dev/null +++ b/gcc/testsuite/gcc.apple/fwritable-strings.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-fwritable-strings" } */ + +/*#include <stdio.h>*/ +void foo( void *dst) +{ + char *ucdst; + + ucdst = (char *)dst; + ucdst++; + *ucdst = 'X'; +} + +int main() +{ + char *a = "Hello"; + foo ((void *) a); + return 0; +} diff --git a/gcc/testsuite/gcc.apple/import.c b/gcc/testsuite/gcc.apple/import.c new file mode 100644 index 00000000000..110a2d249ed --- /dev/null +++ b/gcc/testsuite/gcc.apple/import.c @@ -0,0 +1,9 @@ +/* APPLE LOCAL file #import not deprecated */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +#import "importee.h" + +#import "importee.h" + +void foo (bar x) {} diff --git a/gcc/testsuite/gcc.apple/importee.h b/gcc/testsuite/gcc.apple/importee.h new file mode 100644 index 00000000000..86fbd11da4d --- /dev/null +++ b/gcc/testsuite/gcc.apple/importee.h @@ -0,0 +1,3 @@ +/* APPLE LOCAL file #import not deprecated */ + +typedef int bar; diff --git a/gcc/testsuite/gcc.apple/inttypes-1.c b/gcc/testsuite/gcc.apple/inttypes-1.c new file mode 100644 index 00000000000..40404e2995b --- /dev/null +++ b/gcc/testsuite/gcc.apple/inttypes-1.c @@ -0,0 +1,21 @@ +/* APPLE LOCAL file test of inttypes.h formatter macros */ + +/* { dg-do compile } */ +/* { dg-options "-Wall -W" } */ + +#include <stdio.h> +#include <inttypes.h> +#include <stdint.h> + +int main () +{ + uint32_t x = 12; + int32_t y = 15; + printf("x = %" PRIo32 "\n", x); + printf("x = %" PRIu32 "\n", x); + printf("x = %" PRIx32 "\n", x); + printf("x = %" PRIX32 "\n", x); + printf("y = %" PRId32 "\n", y); + printf("y = %" PRIi32 "\n", y); + return 0; +} diff --git a/gcc/testsuite/gcc.apple/inttypes-2.c b/gcc/testsuite/gcc.apple/inttypes-2.c new file mode 100644 index 00000000000..7ea63badc58 --- /dev/null +++ b/gcc/testsuite/gcc.apple/inttypes-2.c @@ -0,0 +1,45 @@ +/* APPLE LOCAL file test of inttypes.h [U]INT*_C macros */ + +/* { dg-do compile } */ +/* { dg-options "-Wall -W" } */ + +#include <stdio.h> +#include <inttypes.h> +#include <stdint.h> + +#if INT8_C(3) != 3 +#error int8 comparison failed +#endif + +#if INT16_C(-3) != -3 +#error int16 comparison failed +#endif + +#if INT32_C(536870912) != 536870912L +#error int32 comparison failed +#endif + +#if INT64_C(536870912) != 536870912LL +#error int64 comparison failed +#endif + +#if UINT8_C(3) != 3 +#error int8 comparison failed +#endif + +#if UINT16_C(3) != 3 +#error int16 comparison failed +#endif + +#if UINT32_C(536870912) != 536870912UL +#error int32 comparison failed +#endif + +#if UINT64_C(536870912) != 536870912ULL +#error int64 comparison failed +#endif + +int main() +{ + return INT32_C(0); +} diff --git a/gcc/testsuite/gcc.apple/inttypes-3.c b/gcc/testsuite/gcc.apple/inttypes-3.c new file mode 100644 index 00000000000..14fcd0805e0 --- /dev/null +++ b/gcc/testsuite/gcc.apple/inttypes-3.c @@ -0,0 +1,51 @@ +/* APPLE LOCAL file test of inttypes.h SCN* and PRI* macros */ + +/* { dg-do compile } */ +/* { dg-options "-Wall -W" } */ + +#include <stdint.h> +#include <stdio.h> +#include <inttypes.h> + +#define TEST(tn, scn, pri) \ +do { \ + tn x; \ + scanf ("%" scn "\n", &x); \ + printf ("%" pri "\n", x); \ +} while (0) + +void foo(void) +{ + TEST (int8_t, SCNd8, PRId8); + TEST (uint8_t, SCNu8, PRIu8); + TEST (int16_t, SCNd16, PRId16); + TEST (uint16_t, SCNu16, PRIu16); + TEST (int32_t, SCNd32, PRId32); + TEST (uint32_t, SCNu32, PRIu32); + TEST (int64_t, SCNd64, PRId64); + TEST (uint64_t, SCNu64, PRIu64); + + TEST (int_least8_t, SCNdLEAST8, PRIdLEAST8); + TEST (uint_least8_t, SCNuLEAST8, PRIuLEAST8); + TEST (int_least16_t, SCNdLEAST16, PRIdLEAST16); + TEST (uint_least16_t, SCNuLEAST16, PRIuLEAST16); + TEST (int_least32_t, SCNdLEAST32, PRIdLEAST32); + TEST (uint_least32_t, SCNuLEAST32, PRIuLEAST32); + TEST (int_least64_t, SCNdLEAST64, PRIdLEAST64); + TEST (uint_least64_t, SCNuLEAST64, PRIuLEAST64); + + TEST (int_fast8_t, SCNdFAST8, PRIdFAST8); + TEST (uint_fast8_t, SCNuFAST8, PRIuFAST8); + TEST (int_fast16_t, SCNdFAST16, PRIdFAST16); + TEST (uint_fast16_t, SCNuFAST16, PRIuFAST16); + TEST (int_fast32_t, SCNdFAST32, PRIdFAST32); + TEST (uint_fast32_t, SCNuFAST32, PRIuFAST32); + TEST (int_fast64_t, SCNdFAST64, PRIdFAST64); + TEST (uint_fast64_t, SCNuFAST64, PRIuFAST64); + + TEST (intptr_t, SCNdPTR, PRIdPTR); + TEST (uintptr_t, SCNuPTR, PRIuPTR); + + TEST (intmax_t, SCNdMAX, PRIdMAX); + TEST (uintmax_t, SCNuMAX, PRIuMAX); +} diff --git a/gcc/testsuite/gcc.apple/inttypes-4.c b/gcc/testsuite/gcc.apple/inttypes-4.c new file mode 100644 index 00000000000..4f1029981bb --- /dev/null +++ b/gcc/testsuite/gcc.apple/inttypes-4.c @@ -0,0 +1,43 @@ +/* APPLE LOCAL file stdint.h */ + +/* { dg-do run } */ +/* { dg-options "-Wall -W" } */ + +/* Check SIG_ATOMIC_{MIN,MAX}, WINT_{MIN,MAX}. Also check that + stdint.h and sys/types.h can be included simultaneously. */ + +#include <stdint.h> +#include <sys/types.h> +#include <signal.h> +#include <wchar.h> +#include <stdlib.h> + +int main(void) +{ + sig_atomic_t s_a; + wint_t wi; + + s_a = SIG_ATOMIC_MIN; + if (s_a != SIG_ATOMIC_MIN) + abort (); + if (s_a > 0) + abort (); + s_a--; + if (s_a != SIG_ATOMIC_MAX) + abort (); + if (s_a <= 0) + abort (); + + wi = WINT_MIN; + if (wi != WINT_MIN) + abort (); + if (wi > 0) + abort (); + wi--; + if (wi != WINT_MAX) + abort (); + if (wi <= 0) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.apple/inttypes-wchar-1.c b/gcc/testsuite/gcc.apple/inttypes-wchar-1.c new file mode 100644 index 00000000000..6799c59c5eb --- /dev/null +++ b/gcc/testsuite/gcc.apple/inttypes-wchar-1.c @@ -0,0 +1,26 @@ +/* APPLE LOCAL file test of wchar_t's definition in inttypes.h */ + +/* { dg-do run } */ +/* { dg-options "-Wall -W" } */ + +#include <inttypes.h> +#include <stdint.h> + +/* Verify that WCHAR_MAX is the largest positive 32-bit integer */ +#if WCHAR_MAX != 0x7fffffff +# error WCHAR_MAX has incorrect value +#endif + +/* Verify that WCHAR_MIN is negative and consistent with WCHAR_MAX. */ +#if WCHAR_MIN != (-WCHAR_MAX-1) +# error WCHAR_MIN has incorrect value +#endif + +int dummy1[5 - sizeof(wchar_t)] = { 0 }; +int dummy2[sizeof(wchar_t) - 3] = { 0 }; + +int main () +{ + /* Verify that wchar_t is a 32-bit type. */ + return (sizeof(wchar_t) == 4) ? 0 : 1; +} diff --git a/gcc/testsuite/gcc.apple/inttypes-wchar-2.c b/gcc/testsuite/gcc.apple/inttypes-wchar-2.c new file mode 100644 index 00000000000..0021b3dc0fc --- /dev/null +++ b/gcc/testsuite/gcc.apple/inttypes-wchar-2.c @@ -0,0 +1,26 @@ +/* APPLE LOCAL file test that the definition of wchar_t in + inttypes.h gives sizeof(wchar_t) == 2 when using -fshort-wchar. */ + +/* { dg-do run } */ +/* { dg-options "-Wall -W -fshort-wchar" } */ + +#include <inttypes.h> +#include <stdint.h> + +/* Verify that WCHAR_MAX is the largest unsigned 16-bit integer. */ +#if WCHAR_MAX != 0xffffU +# error WCHAR_MAX has incorrect value +#endif + +/* Verify that WCHAR_MIN is 0 */ +#if WCHAR_MIN != 0 +# error WCHAR_MIN has incorrect value +#endif + +int dummy1[3 - sizeof(wchar_t)] = { 0 }; +int dummy2[sizeof(wchar_t) - 1] = { 0 }; + +int main () +{ + return (sizeof(wchar_t) == 2) ? 0 : 1; +} diff --git a/gcc/testsuite/gcc.apple/lazy-ptr-test.c b/gcc/testsuite/gcc.apple/lazy-ptr-test.c new file mode 100644 index 00000000000..da66b518ff0 --- /dev/null +++ b/gcc/testsuite/gcc.apple/lazy-ptr-test.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target powerpc*-apple-darwin* } } */ +/* { dg-options "-S" } */ + +void f () __attribute__((weak_import)); + +typedef void PF (void); + +void f(void){}; + +PF* g (void) { return f; } + +int main() +{ + (*g())(); + return 0; +} + +/* { dg-final { scan-assembler "non_lazy_ptr" } } */ diff --git a/gcc/testsuite/gcc.apple/mac68k-align-unsup.c b/gcc/testsuite/gcc.apple/mac68k-align-unsup.c new file mode 100644 index 00000000000..52c0b2e2573 --- /dev/null +++ b/gcc/testsuite/gcc.apple/mac68k-align-unsup.c @@ -0,0 +1,9 @@ +/* APPLE LOCAL file 64-bit */ +/* Darwin (Mac OS X) alignment exercises. */ + +/* { dg-do compile { target powerpc-*-darwin[89]* } } */ +/* { dg-options "-m64 -malign-mac68k" } */ + +/* { dg-error "-malign-mac68k is not allowed for 64-bit Darwin" "" { target *-*-* } 1 } */ + +main() {} diff --git a/gcc/testsuite/gcc.apple/no-math-errno.c b/gcc/testsuite/gcc.apple/no-math-errno.c new file mode 100644 index 00000000000..cad9edf8be2 --- /dev/null +++ b/gcc/testsuite/gcc.apple/no-math-errno.c @@ -0,0 +1,8 @@ +/* APPLE LOCAL math-errno off by default 3619824 */ +/* { dg-do compile { target powerpc*-*-darwin* } } */ +/* { dg-options "-mpowerpc-gpopt -O2" } */ +/* { dg-final { scan-assembler-not "fcmpu" } } */ +extern double sqrt(double); +float foo(float y) { + return sqrt(y); +} diff --git a/gcc/testsuite/gcc.apple/no-warning.c b/gcc/testsuite/gcc.apple/no-warning.c new file mode 100644 index 00000000000..9b71d722239 --- /dev/null +++ b/gcc/testsuite/gcc.apple/no-warning.c @@ -0,0 +1,8 @@ +/* APPLE LOCAL file -Wno-#warnings */ + +/* { dg-do compile } */ +/* { dg-options "-Wno-#warnings" } */ + +#warning "suppress this warning" + +int a; diff --git a/gcc/testsuite/gcc.apple/non-lazy-ptr-test.c b/gcc/testsuite/gcc.apple/non-lazy-ptr-test.c new file mode 100644 index 00000000000..e496784d32b --- /dev/null +++ b/gcc/testsuite/gcc.apple/non-lazy-ptr-test.c @@ -0,0 +1,40 @@ +/* { dg-do compile { target powerpc*-apple-darwin* } } */ +/* { dg-options "-S" } */ + +typedef void PF (void); + +static void f(void) { +} + +void f1(void) { +} + +extern void f2(void) { +} + +static void f3(void); + +__private_extern__ void pe(void) +{ +} + +PF* g (void) { f(); return f; } +PF* x (void) { return f1; } +PF* y (void) { f2(); return f2; } +PF* z (void) { return f3; } +PF* w (void) { pe(); return pe; } + +int main() +{ + (*g())(); + (*x())(); + (*y())(); + (*z())(); + (*w())(); + return 0; +} + +void f3(void) { +} + +/* { dg-final { scan-assembler-not "non_lazy_ptr" } } */ diff --git a/gcc/testsuite/gcc.apple/notailcall-1.c b/gcc/testsuite/gcc.apple/notailcall-1.c new file mode 100644 index 00000000000..ee072d283fd --- /dev/null +++ b/gcc/testsuite/gcc.apple/notailcall-1.c @@ -0,0 +1,73 @@ +/* APPLE LOCAL file Radar 3830232 */ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\(jmp|b\)\[ \\t\]+_*init_iconv_desc" } } */ +/* Contributed by Andrew Pinski 26 Oct 2004 <pinskia@gcc.gnu.org> */ + +struct cset_converter { int func; int cd; }; +void abort(void); int puts(const char*); +int f(int i){return i;} +void g(void){puts("hi");} +struct conversion +{ + int pair; + int func; + int fake_cd; +}; +static const struct conversion conversion_tab[] = { + { 2, 2, 2 }, + { 3, 3, 3 } +}; +static struct cset_converter +init_iconv_desc (int i) +{ + struct cset_converter ret; + unsigned i1; + char *pair; + if (!i) + { + ret.func = 0; + ret.cd = 0; + return ret; + } + pair = __builtin_alloca(i*3); + for (i1 = 0; i1 < (sizeof (conversion_tab) / sizeof ((conversion_tab)[0])); i1++) + if (i == conversion_tab[i1].pair) + { + ret.func = conversion_tab[i1].func; + ret.cd = conversion_tab[i1].fake_cd; + return ret; + } + + ret.func = 2; + ret.cd = f(i); + if (ret.cd == 4) + { + g(); + ret.func = 4; + } + return ret; +} +struct f +{ + struct cset_converter a; + struct cset_converter b; +}; + +void ff(struct f *a) +{ + a->a = init_iconv_desc(0); + /* Compiler was illegally optimizing this call into a tailcall (jmp). Radar 3830232 */ + a->b = init_iconv_desc(1); +} + +int main(void) +{ + struct f a; + ff (&a); + if (a.a.func!=0 || a.a.cd !=0) + abort(); + if (a.b.func!=2 || a.b.cd !=1) + abort(); + return 0; +} diff --git a/gcc/testsuite/gcc.apple/objcpp.c b/gcc/testsuite/gcc.apple/objcpp.c new file mode 100644 index 00000000000..64728306efd --- /dev/null +++ b/gcc/testsuite/gcc.apple/objcpp.c @@ -0,0 +1,6 @@ +/* { dg-options "-x objc++-cpp-output $srcdir/gcc.apple/objcpp.c" } */ + +/* Radar 3981486 */ + +int main() { +} diff --git a/gcc/testsuite/gcc.apple/one.framework/Headers/one.h b/gcc/testsuite/gcc.apple/one.framework/Headers/one.h new file mode 100644 index 00000000000..50c24d3e6c5 --- /dev/null +++ b/gcc/testsuite/gcc.apple/one.framework/Headers/one.h @@ -0,0 +1,3 @@ +/* Contributed by Devang Patel <dpatel@apple.com> */ + +/* Empty header */ diff --git a/gcc/testsuite/gcc.apple/pascal-strings-1.c b/gcc/testsuite/gcc.apple/pascal-strings-1.c new file mode 100644 index 00000000000..c4e2d86ddc9 --- /dev/null +++ b/gcc/testsuite/gcc.apple/pascal-strings-1.c @@ -0,0 +1,46 @@ +/* APPLE LOCAL file pascal strings */ +/* Positive C test cases. */ +/* Origin: Ziemowit Laski <zlaski@apple.com> */ +/* { dg-do run } */ +/* { dg-options "-std=iso9899:1999 -fpascal-strings" } */ + +typedef __WCHAR_TYPE__ wchar_t; +typedef __SIZE_TYPE__ size_t; + +extern void abort (void); +extern size_t strlen (const char *s); + +const unsigned char *pascalStr1 = "\pHello, World!"; +const unsigned char *concat1 = "\pConcatenated" "string" "\pliteral"; + +const unsigned char msg1[] = "\pHello"; /* ok */ +const unsigned char *msg2 = "\pHello"; /* ok */ +const signed char msg3[] = "\pHello"; /* ok */ +const char msg4[] = "\pHello"; /* ok */ +unsigned char msg5[] = "\pHello"; /* ok */ +signed char msg7[] = "\pHello"; /* ok */ +char msg8[] = "\pHello"; /* ok */ + +int +main (void) +{ + const unsigned char *pascalStr2 = "\pGood-bye!"; + + if (strlen ((const char *)pascalStr1) != 14) + abort (); + if (*pascalStr1 != 13) + abort (); /* the length byte does not include trailing null */ + + if (strlen ((const char *)pascalStr2) != 10) + abort (); + if (*pascalStr2 != 9) + abort (); + + if (strlen ((const char *)concat1) != 26) + abort (); + if (*concat1 != 25) + abort (); + + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/pascal-strings-2.c b/gcc/testsuite/gcc.apple/pascal-strings-2.c new file mode 100644 index 00000000000..b25c6cf8013 --- /dev/null +++ b/gcc/testsuite/gcc.apple/pascal-strings-2.c @@ -0,0 +1,45 @@ +/* APPLE LOCAL file pascal strings */ +/* Negative C test cases. */ +/* Origin: Ziemowit Laski <zlaski@apple.com> */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -Wwrite-strings -fpascal-strings" } */ + +typedef __WCHAR_TYPE__ wchar_t; + +const wchar_t *pascalStr1 = L"\pHi!"; /* { dg-warning "unknown escape sequence" } */ +const wchar_t *pascalStr2 = L"Bye\p!"; /* { dg-warning "unknown escape sequence" } */ + +const wchar_t *initErr0 = "\pHi"; /* { dg-warning "incompatible pointer type" } */ +const wchar_t initErr0a[] = "\pHi"; /* { dg-error "initialized from non-wide string" } */ +const wchar_t *initErr1 = "Bye"; /* { dg-warning "incompatible pointer type" } */ +const wchar_t initErr1a[] = "Bye"; /* { dg-error "initialized from non-wide string" } */ + +const char *initErr2 = L"Hi"; /* { dg-warning "incompatible pointer type" } */ +const char initErr2a[] = L"Hi"; /* { dg-error "initialized from wide string" } */ +const signed char *initErr3 = L"Hi"; /* { dg-warning "incompatible pointer type" } */ +const signed char initErr3a[] = L"Hi"; /* { dg-error "initialized from wide string" } */ +const unsigned char *initErr4 = L"Hi"; /* { dg-warning "incompatible pointer type" } */ +const unsigned char initErr4a[] = L"Hi"; /* { dg-error "initialized from wide string" } */ + +const char *pascalStr3 = "Hello\p, World!"; /* { dg-warning "unknown escape sequence" } */ + +const char *concat2 = "Hi" "\pthere"; /* { dg-warning "unknown escape sequence" } */ +const char *concat3 = "Hi" "there\p"; /* { dg-warning "unknown escape sequence" } */ + +const unsigned char *s2 = "\pGoodbye!"; /* ok */ +unsigned char *s3 = "\pHi!"; /* { dg-warning "initialization discards qualifiers" } */ +char *s4 = "\pHi"; /* { dg-warning "initialization discards qualifiers" } */ +signed char *s5 = "\pHi"; /* { dg-warning "initialization discards qualifiers" } */ +const signed char *s6 = "\pHi"; /* { dg-warning "differ in signedness" } */ + +/* the maximum length of a Pascal literal is 255. */ +const unsigned char *almostTooLong = + "\p12345678901234567890123456789012345678901234567890123456789012345678901234567890" + "12345678901234567890123456789012345678901234567890123456789012345678901234567890" + "12345678901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345"; /* ok */ +const unsigned char *definitelyTooLong = + "\p12345678901234567890123456789012345678901234567890123456789012345678901234567890" + "12345678901234567890123456789012345678901234567890123456789012345678901234567890" + "12345678901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456"; /* { dg-error "too long" } */ diff --git a/gcc/testsuite/gcc.apple/pascal-strings-3.c b/gcc/testsuite/gcc.apple/pascal-strings-3.c new file mode 100644 index 00000000000..477b94bbff2 --- /dev/null +++ b/gcc/testsuite/gcc.apple/pascal-strings-3.c @@ -0,0 +1,20 @@ +/* APPLE LOCAL file pascal strings */ +/* Ensure that there are no warnings or errors issued when a Pascal string is used to + initialize an array and the NUL terminator does not fit. */ +/* Author: Ziemowit Laski <zlaski@apple.com> */ + +/* { dg-do compile } */ +/* { dg-options "-fpascal-strings" } */ + +typedef unsigned char Str15[16]; + +Str15 ggg = "\p012345678901234"; +Str15 hhh = "\p0123456789012345"; /* { dg-warning "initializer.string for array of chars is too long" } */ + +int foo(void) +{ + Str15 sss = "\p012345678901234"; + Str15 ttt = "\p0123456789012345"; /* { dg-warning "initializer.string for array of chars is too long" } */ + + return 0; +} diff --git a/gcc/testsuite/gcc.apple/power-align-unsup.c b/gcc/testsuite/gcc.apple/power-align-unsup.c new file mode 100644 index 00000000000..63d86853a97 --- /dev/null +++ b/gcc/testsuite/gcc.apple/power-align-unsup.c @@ -0,0 +1,8 @@ +/* Darwin (Mac OS X) alignment exercises. */ + +/* { dg-do compile { target powerpc-*-darwin[89]* } } */ +/* { dg-options "-m64 -malign-power" } */ + +/* { dg-error "-malign-power is not supported for 64-bit Darwin" "" { target *-*-* } 1 } */ + +main() {} diff --git a/gcc/testsuite/gcc.apple/ppc-ignored-options.c b/gcc/testsuite/gcc.apple/ppc-ignored-options.c new file mode 100644 index 00000000000..e08634f4fe5 --- /dev/null +++ b/gcc/testsuite/gcc.apple/ppc-ignored-options.c @@ -0,0 +1,11 @@ +/* Test options to ignore. */ + +/* { dg-do run { target powerpc-*-darwin* } } */ +/* { dg-options "-msse -msse2 -march=pentium4 -mcpu=pentium4" } */ + +int +main () +{ + return 0; +} + diff --git a/gcc/testsuite/gcc.apple/ppc_intrinsics-1.c b/gcc/testsuite/gcc.apple/ppc_intrinsics-1.c new file mode 100644 index 00000000000..3df118853ca --- /dev/null +++ b/gcc/testsuite/gcc.apple/ppc_intrinsics-1.c @@ -0,0 +1,35 @@ +/* { dg-options "-I ${srcdir}/../../more-hdrs" } */ +/* { dg-do compile { target "powerpc*-*-darwin*" } } */ +/* Radar 3208244 */ +#include "ppc_intrinsics.h" +#include <stdlib.h> + +int main( void ) +{ + int i,j; + int value; + register int temp; + double a,b,c,d; + a = 1.;b=2.;c=3.; + + d = __fmadd(a,b,c); + a = __fmadd(c,b,d); + d = __fmadd(a,b,c); + + __lwsync(); + __nop(); + __lwsync(); + __nop(); + d = __fctidz(a); + d = __fctidz(d); + b = __fctid(a); + b = __fctid(b); + c = __fcfid(a); + c = __fcfid(c); + __dcbzl(32,&value); + __dcbzl(&value,0); + + return a+b+c+d; +} + + diff --git a/gcc/testsuite/gcc.apple/ppc_intrinsics-2.c b/gcc/testsuite/gcc.apple/ppc_intrinsics-2.c new file mode 100644 index 00000000000..2f5698fc685 --- /dev/null +++ b/gcc/testsuite/gcc.apple/ppc_intrinsics-2.c @@ -0,0 +1,66 @@ +/* { dg-options "-I ${srcdir}/../../more-hdrs -Wshorten-64-to-32 -Wno-long-long" } */ +/* { dg-do run { target "powerpc*-*-darwin*" } } */ +#include "ppc_intrinsics.h" +#include <stdlib.h> + +int main( void ) +{ + int intconst = 0x5; + long long longlongconst = 0x5; + int intloc, intloc1, intloc2; + unsigned int uintloc, uintloc1, uintloc2; + long longloc; + long long longlongloc; + int fails = 0; + + intloc = __cntlzw(intconst); + if (intloc != 29) + ++fails; + + longlongloc = __cntlzd(longlongconst); + if (longlongloc != 61) + ++fails; + + intloc = 0xffff; + __rlwimi(intloc, 0x21876543, 8, 0, 23); + if (intloc != 0x876543ff) + ++fails; + + intloc = __rlwinm(0x21876543, 8, 0, 31); + if (intloc != 0x87654321) + ++fails; + + longloc = __rlwinm(0x45, 5, 24, 31); + if (longloc != 0xa0) + ++fails; + + longloc = __rlwnm(0x47, 5, 24, 31); + if (longloc != 0xe0) + ++fails; + + intloc1 = 1 << 20; + intloc2 = 1 << 21; + intloc = __mulhw (intloc1, intloc2); + if (intloc != (1 << 9)) + ++fails; + + intloc1 = 0xfffe0000; + intloc2 = 0xfffc0000; + intloc = __mulhw (intloc1, intloc2); + if (intloc != 8) + ++fails; + + uintloc1 = 0xffffffff; + uintloc2 = 0xfffffffe; + uintloc = __mulhwu (uintloc1, uintloc2); + if (uintloc != 0xfffffffd) + ++fails; + + uintloc1 = 0xfffe0000; + uintloc2 = 0xfffc0000; + uintloc = __mulhwu (uintloc1, uintloc2); + if (uintloc != 0xfffa0008) + ++fails; + + return fails; +} diff --git a/gcc/testsuite/gcc.apple/preprocess.s b/gcc/testsuite/gcc.apple/preprocess.s new file mode 100644 index 00000000000..897f2a7d6b1 --- /dev/null +++ b/gcc/testsuite/gcc.apple/preprocess.s @@ -0,0 +1,16 @@ +/* APPLE LOCAL file preprocess .s files */ + +/* Regression test - in assembly language, # may have some significance + other than 'stringize macro argument' and therefore must be preserved + in the output, and should not be warned about. */ + +/* { dg-do preprocess } */ + +#define foo() mov r0, #5 /* { dg-bogus "not followed" "spurious warning" } */ + +entry: + foo() + +/* Check we don't EOF on an unknown directive. */ +#unknown directive +#error a later diagnostic /* { dg-error "diagnostic" } */ diff --git a/gcc/testsuite/gcc.apple/shorten.c b/gcc/testsuite/gcc.apple/shorten.c new file mode 100644 index 00000000000..842979b4ed9 --- /dev/null +++ b/gcc/testsuite/gcc.apple/shorten.c @@ -0,0 +1,20 @@ +/* APPLE LOCAL file 64bit shorten warning 3865314 */ +/* { dg-do compile } */ +/* { dg-options "-Wshorten-64-to-32" } */ +/* Radar 3865314 */ + +long long ll; +int i; +char c; + +void bar (int); + +void foo() { + c = i; + c = ll; + i = (int) ll; + i = ll; /* { dg-warning "implicit conversion shortens 64-bit value into a 32-bit value" } */ + i += ll; /* { dg-warning "implicit conversion shortens 64-bit value into a 32-bit value" } */ + i = i ? ll : i;/* { dg-warning "implicit conversion shortens 64-bit value into a 32-bit value" } */ + bar (ll); /* { dg-warning "implicit conversion shortens 64-bit value into a 32-bit value" } */ +} diff --git a/gcc/testsuite/gcc.apple/special/liblongcall.c b/gcc/testsuite/gcc.apple/special/liblongcall.c new file mode 100644 index 00000000000..6a952281ecd --- /dev/null +++ b/gcc/testsuite/gcc.apple/special/liblongcall.c @@ -0,0 +1,10 @@ +/* { dg-do compile { target powerpc*-*-darwin* } } */ +/* { dg-options "-mlongcall" } */ +#include <stdio.h> + +int +dy_foo (char *str, int i) +{ + printf ("dy_foo (\"%s\", %d)\n", str, i); + return i + 1; +} diff --git a/gcc/testsuite/gcc.apple/special/longcall-prog.c b/gcc/testsuite/gcc.apple/special/longcall-prog.c new file mode 100644 index 00000000000..5cbb8c0e4ee --- /dev/null +++ b/gcc/testsuite/gcc.apple/special/longcall-prog.c @@ -0,0 +1,18 @@ +#include <stdlib.h> +#include <stdio.h> + +/* declare all externally visible functions in libweak.c */ +int dy_foo (char *, int); + +main () +{ + int answer, x=41; + char *str = "foostr"; + printf ("%s begins:\n", __FILE__); + answer = dy_foo (str, x); + printf ("dy_foo (\"%s\", %d) = %d", str, x, answer); + if (answer != 42) + printf (" (error!)"); + printf ("\n%s done.\n", __FILE__); + exit (answer != 42); +} diff --git a/gcc/testsuite/gcc.apple/special/longcall.exp b/gcc/testsuite/gcc.apple/special/longcall.exp new file mode 100644 index 00000000000..d9ebd1270ea --- /dev/null +++ b/gcc/testsuite/gcc.apple/special/longcall.exp @@ -0,0 +1,69 @@ +# APPLE LOCAL file testsuite +# Copyright (C) 2002 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +# Load support procs. +load_lib gcc-dg.exp + +# Initialize `dg'. +dg-init + +set timeout 30 + +set prms_id 0 +set bug_id 0 + +set testfile "longcall-prog" +set binfile ${objdir}/${subdir}/${testfile} +set srcfile ${srcdir}/${subdir}/${testfile}.c + +set libfilestem "longcall" +set libfile "lib${libfilestem}" +set libbinfile ${objdir}/${subdir}/${libfile}.dylib +set libsrcfile ${srcdir}/${subdir}/${libfile}.c + +file mkdir ${objdir}/${subdir} + +set test "longcall/dylib" + +proc note_result {success diagnostic} { + set verb [expr {($success) ? "pass" : "fail"}] + eval {$verb $diagnostic} +} + +set whine "building $test library" +set additional_flags "additional_flags=-dynamiclib -mlongcall" +set result [expr {[gcc_target_compile "${libsrcfile}" "${libbinfile}" executable [list debug $additional_flags]] == ""}] +note_result $result $whine + +set whine "building $test test program" +set additional_flags "additional_flags=-L${objdir}/${subdir} -l${libfilestem}" +set result [expr {[gcc_target_compile "${srcfile}" "${binfile}" executable [list debug $additional_flags]] == ""}] +note_result $result $whine + +set result [gcc_load "$binfile" "" ""] +set status [lindex $result 0] +set output [lindex $result 1]; +if {$status == "pass" } { + pass $test + file delete $libbinfile $binfile +} else { + fail $test +} + +# All done. +dg-finish diff --git a/gcc/testsuite/gcc.apple/special/special.exp b/gcc/testsuite/gcc.apple/special/special.exp new file mode 100644 index 00000000000..5344a4817b7 --- /dev/null +++ b/gcc/testsuite/gcc.apple/special/special.exp @@ -0,0 +1,42 @@ +# APPLE LOCAL file testsuite +# Copyright (C) 2002 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +# Load support procs. +load_lib gcc-dg.exp + +# Initialize `dg'. +dg-init + +# Test the zerofill support by seeing if a file with a large array +# compiled -fno-common has a small size on disk. + +gcc_target_compile "$srcdir/$subdir/zerofill.c" "zerofill.o" object \ + "additional_flags=-fno-common" + +set size [ exec wc -c < zerofill.o ] + +if { $size < 100000 } { + pass "zerofill" +} else { + fail "zerofill" +} + +file delete zerofill.o + +# All done. +dg-finish diff --git a/gcc/testsuite/gcc.apple/special/zerofill.c b/gcc/testsuite/gcc.apple/special/zerofill.c new file mode 100644 index 00000000000..e4bd84c816f --- /dev/null +++ b/gcc/testsuite/gcc.apple/special/zerofill.c @@ -0,0 +1,5 @@ +/* APPLE LOCAL file zerofill */ + +int arr[40000]; + +foo() {} diff --git a/gcc/testsuite/gcc.apple/string-insns.c b/gcc/testsuite/gcc.apple/string-insns.c new file mode 100644 index 00000000000..aee058d5548 --- /dev/null +++ b/gcc/testsuite/gcc.apple/string-insns.c @@ -0,0 +1,9 @@ +/* APPLE LOCAL Disable string insns with -Os on Darwin (radar 3509006) */ +/* { dg-do compile { target powerpc*-apple-darwin* } } */ +/* { dg-options "-Os" } */ +/* On ppc at Apple, -Os should not use string instructions. 3509006. */ +struct s { int a; int b; int c; }; +int foo (struct s* p, struct s* q) { + *p = *q; +} +/* { dg-final { scan-assembler-not "lswi" } } */ diff --git a/gcc/testsuite/gcc.apple/test-ldouble.c b/gcc/testsuite/gcc.apple/test-ldouble.c new file mode 100644 index 00000000000..fe85d86e0e1 --- /dev/null +++ b/gcc/testsuite/gcc.apple/test-ldouble.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ + +extern void __inline_x80told(long double *x); +extern double rint( double ); + +extern unsigned long AECreateDesc(const void * dataPtr); + +unsigned long aeCoercePtrToMagnitude() +{ + unsigned long err = 0; + unsigned long magValue; + double doubleValue; + long double longDoubleValue; + + __inline_x80told(&longDoubleValue); + doubleValue = longDoubleValue; + if (doubleValue < 0) + err = 2; + else + magValue = (unsigned long) rint(doubleValue); + err = AECreateDesc(&magValue); + return err; +} diff --git a/gcc/testsuite/gcc.apple/test-local-static-longlong.c b/gcc/testsuite/gcc.apple/test-local-static-longlong.c new file mode 100644 index 00000000000..19afa53c016 --- /dev/null +++ b/gcc/testsuite/gcc.apple/test-local-static-longlong.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-Wno-long-long" } */ + +#include <stdlib.h> + +long long foo() +{ + static long long rat = (1LL<<62); + return rat; +} + +int main() +{ + + if (foo() != (1LL<<62)) + abort(); + exit(0); +} + diff --git a/gcc/testsuite/gcc.apple/x86-ignored-options.c b/gcc/testsuite/gcc.apple/x86-ignored-options.c new file mode 100644 index 00000000000..d48919758bf --- /dev/null +++ b/gcc/testsuite/gcc.apple/x86-ignored-options.c @@ -0,0 +1,11 @@ +/* Test options to ignore. */ + +/* { dg-do run { target i?86-*-darwin* } } */ +/* { dg-options "-faltivec -mno-fused-madd -mlong-branch -mlongcall -mcpu=G4 -mcpu=G5" } */ + +int +main () +{ + return 0; +} + |