summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.target/powerpc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.target/powerpc')
-rw-r--r--gcc/testsuite/g++.target/powerpc/const2.C6
-rw-r--r--gcc/testsuite/g++.target/powerpc/darwin-minversion-1.C10
-rw-r--r--gcc/testsuite/g++.target/powerpc/ppc64-sighandle-cr.C54
-rw-r--r--gcc/testsuite/g++.target/powerpc/simd-4.C70
-rw-r--r--gcc/testsuite/g++.target/powerpc/simd-5.C44
-rw-r--r--gcc/testsuite/g++.target/powerpc/spu2vmx-1.C15
-rw-r--r--gcc/testsuite/g++.target/powerpc/uncaught3.C85
7 files changed, 284 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.target/powerpc/const2.C b/gcc/testsuite/g++.target/powerpc/const2.C
new file mode 100644
index 00000000000..27f4c265851
--- /dev/null
+++ b/gcc/testsuite/g++.target/powerpc/const2.C
@@ -0,0 +1,6 @@
+/* { dg-do compile { target powerpc_altivec_ok } } */
+/* { dg-options "-O -gdwarf-2 -dA -maltivec" } */
+/* { dg-final { scan-assembler "DW_AT_const_value" } } */
+
+typedef float FloatVect __attribute__((__vector_size__(16)));
+const FloatVect Foo = { 250000000.0, 0.0, 0.0, 0.0 };
diff --git a/gcc/testsuite/g++.target/powerpc/darwin-minversion-1.C b/gcc/testsuite/g++.target/powerpc/darwin-minversion-1.C
new file mode 100644
index 00000000000..cbf5ff1d20b
--- /dev/null
+++ b/gcc/testsuite/g++.target/powerpc/darwin-minversion-1.C
@@ -0,0 +1,10 @@
+/* Test for -mmacosx-version-min default on powerpc-darwin. */
+/* { dg-do compile { target powerpc-*-darwin* } } */
+
+int main(void)
+{
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1030
+ fail me;
+#endif
+ return 0;
+}
diff --git a/gcc/testsuite/g++.target/powerpc/ppc64-sighandle-cr.C b/gcc/testsuite/g++.target/powerpc/ppc64-sighandle-cr.C
new file mode 100644
index 00000000000..32561736077
--- /dev/null
+++ b/gcc/testsuite/g++.target/powerpc/ppc64-sighandle-cr.C
@@ -0,0 +1,54 @@
+// { dg-do run { target { powerpc64*-*-linux* } } }
+// { dg-options "-fexceptions -fnon-call-exceptions" }
+
+#include <signal.h>
+#include <stdlib.h>
+#include <fenv.h>
+
+#define SET_CR(R,V) __asm__ __volatile__ ("mtcrf %0,%1" : : "n" (1<<(7-R)), "r" (V<<(4*(7-R))) : "cr" #R)
+#define GET_CR(R) ({ int tmp; __asm__ __volatile__ ("mfcr %0" : "=r" (tmp)); (tmp >> 4*(7-R)) & 15; })
+
+void sighandler (int signo, siginfo_t * si, void * uc)
+{
+ SET_CR(2, 3);
+ SET_CR(3, 2);
+ SET_CR(4, 1);
+
+ throw 0;
+}
+
+float test (float a, float b) __attribute__ ((__noinline__));
+float test (float a, float b)
+{
+ float x;
+ asm ("mtcrf %1,%2" : "=f" (x) : "n" (1 << (7-3)), "r" (0), "0" (b) : "cr3");
+ return a / x;
+}
+
+int main ()
+{
+ struct sigaction sa;
+ int status;
+
+ sa.sa_sigaction = sighandler;
+ sa.sa_flags = SA_SIGINFO;
+
+ status = sigaction (SIGFPE, & sa, NULL);
+
+ feenableexcept (FE_DIVBYZERO);
+
+ SET_CR(2, 6);
+ SET_CR(3, 9);
+ SET_CR(4, 12);
+
+ try {
+ test (1, 0);
+ }
+ catch (...) {
+ return GET_CR(2) != 6 || GET_CR(3) != 9 || GET_CR(4) != 12;
+ }
+
+ return 1;
+}
+
+
diff --git a/gcc/testsuite/g++.target/powerpc/simd-4.C b/gcc/testsuite/g++.target/powerpc/simd-4.C
new file mode 100644
index 00000000000..a01f19c2736
--- /dev/null
+++ b/gcc/testsuite/g++.target/powerpc/simd-4.C
@@ -0,0 +1,70 @@
+/* { dg-do run { target *-*-darwin* } } */
+/* { dg-options "-fexceptions -fnon-call-exceptions -O -maltivec" } */
+
+#include <cstdlib>
+#include <cstring>
+#include <signal.h>
+
+typedef int __attribute__((vector_size(16))) v;
+
+v vv[32];
+volatile v vt = { 1, 2, 3, 4 };
+
+void clobber_vrs(void) { };
+
+void (*volatile fp)() = clobber_vrs;
+
+void thrower(int sig)
+{
+ v v00 = vv[ 0];
+ v v01 = vv[ 1];
+ v v02 = vv[ 2];
+ v v03 = vv[ 3];
+ v v04 = vv[ 4];
+ v v05 = vv[ 5];
+ v v06 = vv[ 6];
+ v v07 = vv[ 7];
+ v v08 = vv[ 8];
+ v v09 = vv[ 9];
+ v v10 = vv[10];
+ v v11 = vv[11];
+ v v12 = vv[12];
+
+ fp();
+
+ vv[ 0] = v00;
+ vv[ 1] = v01;
+ vv[ 2] = v02;
+ vv[ 3] = v03;
+ vv[ 4] = v04;
+ vv[ 5] = v05;
+ vv[ 6] = v06;
+ vv[ 7] = v07;
+ vv[ 8] = v08;
+ vv[ 9] = v09;
+ vv[10] = v10;
+ vv[11] = v11;
+ vv[12] = v12;
+
+ throw 3;
+}
+
+v v2;
+
+int main(void)
+{
+ v v1 = vt;
+ if (signal (SIGBUS, thrower) == SIG_ERR)
+ abort ();
+ if (signal (SIGSEGV, thrower) == SIG_ERR)
+ abort ();
+ try {
+ *(volatile int *)0 = 0;
+ abort ();
+ } catch (int x) {
+ }
+ v2 = v1;
+ if (memcmp (&v2, (v *)&vt, sizeof (v2)) != 0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/g++.target/powerpc/simd-5.C b/gcc/testsuite/g++.target/powerpc/simd-5.C
new file mode 100644
index 00000000000..71e117ead2a
--- /dev/null
+++ b/gcc/testsuite/g++.target/powerpc/simd-5.C
@@ -0,0 +1,44 @@
+// Test EH with V2SI SIMD registers actually restores correct values.
+// Origin: Joseph Myers <joseph@codesourcery.com>
+// { dg-options "-O" }
+// { dg-do run { target { powerpc_spe && { ! *-*-vxworks* } } } }
+
+extern "C" void abort (void);
+extern "C" int memcmp (const void *, const void *, __SIZE_TYPE__);
+typedef int __attribute__((vector_size (8))) v2si;
+
+v2si a = { 1, 2 };
+v2si b = { 3, 4 };
+v2si c = { 4, 6 };
+volatile v2si r;
+v2si r2;
+
+void
+f ()
+{
+ register v2si v asm("r15");
+ v = __builtin_spe_evaddw (b, c);
+ asm volatile ("" : "+r" (v));
+ r = v;
+ throw 1;
+}
+
+int
+main ()
+{
+ register v2si v asm("r15");
+ v = __builtin_spe_evaddw (a, b);
+ asm volatile ("" : "+r" (v));
+ try
+ {
+ f ();
+ }
+ catch (int)
+ {
+ r = v;
+ r2 = r;
+ if (memcmp (&r2, &c, sizeof (v2si)))
+ abort ();
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/g++.target/powerpc/spu2vmx-1.C b/gcc/testsuite/g++.target/powerpc/spu2vmx-1.C
new file mode 100644
index 00000000000..496b46c22c9
--- /dev/null
+++ b/gcc/testsuite/g++.target/powerpc/spu2vmx-1.C
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_spu } */
+/* { dg-options "-maltivec" } */
+
+#include <altivec.h>
+#include <spu2vmx.h>
+
+vec_uint4 f(vec_uint4 a, vec_uint4 b)
+{
+ return spu_add(a, b);
+}
+vec_float4 f(vec_float4 a, vec_float4 b)
+{
+ return spu_add(a, b);
+}
diff --git a/gcc/testsuite/g++.target/powerpc/uncaught3.C b/gcc/testsuite/g++.target/powerpc/uncaught3.C
new file mode 100644
index 00000000000..f891401584e
--- /dev/null
+++ b/gcc/testsuite/g++.target/powerpc/uncaught3.C
@@ -0,0 +1,85 @@
+// { dg-do compile { target *-*-darwin* } }
+// { dg-final { scan-assembler-not "__cxa_get_exception" } }
+// { dg-options "-mmacosx-version-min=10.4" }
+// { dg-additional-options "-Wno-deprecated" { target c++17 } }
+
+#include <exception>
+#include <cstdlib>
+
+
+struct Check {
+ int obj1, obj2;
+ bool state;
+};
+
+static Check const data[] = {
+ { 0, 0, false }, // construct [0]
+ { 1, 0, true }, // [1] = [0]
+ { 0, 0, true }, // destruct [0]
+ { 2, 1, true }, // [2] = [1]
+ { 2, 2, true }, // destruct [2]
+ { 3, 1, true }, // [3] = [1]
+ { 3, 3, false }, // destruct [3]
+ { 1, 1, false }, // destruct [1]
+ { 9, 9, false } // end-of-data
+};
+
+static int pos = 0;
+
+static void test(int obj1, int obj2, bool state)
+{
+ if (obj1 != data[pos].obj1) abort ();
+ if (obj2 != data[pos].obj2) abort ();
+ if (state != data[pos].state) abort ();
+ pos++;
+}
+
+
+struct S {
+ int id;
+ S ();
+ S (const S &);
+ ~S ();
+};
+
+static int next_id = 0;
+
+S::S()
+ : id (next_id++)
+{
+ test (id, id, std::uncaught_exception ());
+}
+
+S::S(const S &x)
+ : id (next_id++)
+{
+ test (id, x.id, std::uncaught_exception ());
+}
+
+S::~S()
+{
+ test (id, id, std::uncaught_exception ());
+}
+
+extern void foo (S *);
+
+int main()
+{
+ try
+ {
+ try
+ {
+ S s0;
+ throw s0; // s1 is the exception object
+ }
+ catch (S s2)
+ {
+ throw;
+ }
+ }
+ catch (S s3)
+ {
+ }
+
+ return 0;
+}