From 2495e8793f096d9911419aa2fa105e32205644bc Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Sat, 11 Sep 2004 06:45:44 +0000 Subject: [PATCH] * gcc.target/frv: New directory of FR-V-specific tests. From-SVN: r87345 --- gcc/testsuite/ChangeLog | 4 ++ gcc/testsuite/gcc.target/frv/all-accs-1.c | 65 +++++++++++++++++ gcc/testsuite/gcc.target/frv/all-mclracca-1.c | 24 +++++++ .../gcc.target/frv/fr400-builtins-1.c | 28 ++++++++ .../gcc.target/frv/fr400-builtins-2.c | 10 +++ .../gcc.target/frv/fr405-builtins-1.c | 39 +++++++++++ .../gcc.target/frv/fr405-builtins-2.c | 69 +++++++++++++++++++ .../gcc.target/frv/fr405-builtins-3.c | 58 ++++++++++++++++ .../gcc.target/frv/fr450-builtins-1.c | 27 ++++++++ .../gcc.target/frv/fr450-builtins-2.c | 27 ++++++++ .../gcc.target/frv/fr450-builtins-3.c | 25 +++++++ .../gcc.target/frv/fr450-builtins-4.c | 25 +++++++ .../gcc.target/frv/fr450-builtins-5.c | 35 ++++++++++ .../gcc.target/frv/fr450-builtins-6.c | 23 +++++++ .../gcc.target/frv/fr450-builtins-7.c | 24 +++++++ .../gcc.target/frv/fr450-builtins-8.c | 22 ++++++ .../gcc.target/frv/fr450-builtins-9.c | 23 +++++++ .../gcc.target/frv/fr550-builtins-1.c | 42 +++++++++++ .../gcc.target/frv/fr550-builtins-2.c | 9 +++ .../gcc.target/frv/fr550-builtins-3.c | 13 ++++ .../gcc.target/frv/fr550-builtins-4.c | 48 +++++++++++++ .../gcc.target/frv/fr550-builtins-5.c | 25 +++++++ gcc/testsuite/gcc.target/frv/frv.exp | 35 ++++++++++ 23 files changed, 700 insertions(+) create mode 100644 gcc/testsuite/gcc.target/frv/all-accs-1.c create mode 100644 gcc/testsuite/gcc.target/frv/all-mclracca-1.c create mode 100644 gcc/testsuite/gcc.target/frv/fr400-builtins-1.c create mode 100644 gcc/testsuite/gcc.target/frv/fr400-builtins-2.c create mode 100644 gcc/testsuite/gcc.target/frv/fr405-builtins-1.c create mode 100644 gcc/testsuite/gcc.target/frv/fr405-builtins-2.c create mode 100644 gcc/testsuite/gcc.target/frv/fr405-builtins-3.c create mode 100644 gcc/testsuite/gcc.target/frv/fr450-builtins-1.c create mode 100644 gcc/testsuite/gcc.target/frv/fr450-builtins-2.c create mode 100644 gcc/testsuite/gcc.target/frv/fr450-builtins-3.c create mode 100644 gcc/testsuite/gcc.target/frv/fr450-builtins-4.c create mode 100644 gcc/testsuite/gcc.target/frv/fr450-builtins-5.c create mode 100644 gcc/testsuite/gcc.target/frv/fr450-builtins-6.c create mode 100644 gcc/testsuite/gcc.target/frv/fr450-builtins-7.c create mode 100644 gcc/testsuite/gcc.target/frv/fr450-builtins-8.c create mode 100644 gcc/testsuite/gcc.target/frv/fr450-builtins-9.c create mode 100644 gcc/testsuite/gcc.target/frv/fr550-builtins-1.c create mode 100644 gcc/testsuite/gcc.target/frv/fr550-builtins-2.c create mode 100644 gcc/testsuite/gcc.target/frv/fr550-builtins-3.c create mode 100644 gcc/testsuite/gcc.target/frv/fr550-builtins-4.c create mode 100644 gcc/testsuite/gcc.target/frv/fr550-builtins-5.c create mode 100644 gcc/testsuite/gcc.target/frv/frv.exp diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5257ba5e068..36d777da600 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-09-11 Richard Sandiford + + * gcc.target/frv: New directory of FR-V-specific tests. + 2004-09-10 James E Wilson * gcc.dg/convert-vec-1.c: New test. diff --git a/gcc/testsuite/gcc.target/frv/all-accs-1.c b/gcc/testsuite/gcc.target/frv/all-accs-1.c new file mode 100644 index 00000000000..cb4232b3c3b --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/all-accs-1.c @@ -0,0 +1,65 @@ +/* Check that ACCs and ACCGs are treated as global variables even if + media.h isn't included. */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +void +set () +{ +#define SET(X) __MWTACC (X, (X) | 0x100), __MWTACCG (X, X) + SET (0); + SET (1); + SET (2); + SET (3); +#if defined (__CPU_FR450__) + SET (8); + SET (9); + SET (10); + SET (11); +#elif __FRV_ACC__ > 4 + SET (4); + SET (5); + SET (6); + SET (7); +#endif +#undef SET +} + +void +check () +{ + int diff1, diff2; + + diff1 = diff2 = 0; + +#define CHECK(X) \ + (diff1 |= (__MRDACC (X) ^ (X | 0x100)), \ + diff2 |= (__MRDACCG (X) ^ X)) + CHECK (0); + CHECK (1); + CHECK (2); + CHECK (3); +#if defined (__CPU_FR450__) + CHECK (8); + CHECK (9); + CHECK (10); + CHECK (11); +#elif __FRV_ACC__ > 4 + CHECK (4); + CHECK (5); + CHECK (6); + CHECK (7); +#endif +#undef CHECK + if ((diff1 | diff2) != 0) + abort (); +} + +int +main () +{ + set (); + check (); + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/all-mclracca-1.c b/gcc/testsuite/gcc.target/frv/all-mclracca-1.c new file mode 100644 index 00000000000..28ab497caee --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/all-mclracca-1.c @@ -0,0 +1,24 @@ +/* GCSE used to reuse the value of __MRDACC. */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +void foo (int *z) +{ + __MWTACC (3, 1); + if (__MRDACC (3) != 1) + *z = 1; + __MCLRACCA (); + if (__MRDACC (3) != 1) + *z = 2; +} + +int main () +{ + int z = 3; + + foo (&z); + if (z != 2) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr400-builtins-1.c b/gcc/testsuite/gcc.target/frv/fr400-builtins-1.c new file mode 100644 index 00000000000..85ca7cfbf0a --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr400-builtins-1.c @@ -0,0 +1,28 @@ +/* Test prefetch support. */ +/* { dg-options "-mcpu=fr400" } */ +/* { dg-do run } */ + +unsigned char global[64]; + +int foo (unsigned int *x, int n) +{ + unsigned short local[16]; + + __data_prefetch0 (x); + __data_prefetch0 (&x[8]); + __data_prefetch0 (&x[n]); + __data_prefetch0 (local); + __data_prefetch0 (&local[16]); + __data_prefetch0 (&local[n]); + __data_prefetch0 (global); + __data_prefetch0 (&global[32]); + __data_prefetch0 (&global[n]); +} + +int main () +{ + unsigned int i[16]; + + foo (i, 2); + return 0; +} diff --git a/gcc/testsuite/gcc.target/frv/fr400-builtins-2.c b/gcc/testsuite/gcc.target/frv/fr400-builtins-2.c new file mode 100644 index 00000000000..66f30055e85 --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr400-builtins-2.c @@ -0,0 +1,10 @@ +/* Test prefetch support. */ +/* { dg-options "-mcpu=fr400" } */ +/* { dg-do compile } */ + +void foo (void *x) +{ + __data_prefetch0 (x); +} + +/* { dg-final { scan-assembler "\tdcpl " } } */ diff --git a/gcc/testsuite/gcc.target/frv/fr405-builtins-1.c b/gcc/testsuite/gcc.target/frv/fr405-builtins-1.c new file mode 100644 index 00000000000..98e304e278a --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr405-builtins-1.c @@ -0,0 +1,39 @@ +/* Test the IACC multiply/accumulate instructions. Also test the IACC + read/write functions. */ +/* { dg-options "-mcpu=fr405" } */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +int main () +{ + long long res, res1, res2, res3; + + __SMU (0x12345678, 0x40004000); + __SMASS (0x12000000, 0x11223344); + __SMSSS (0x01020304, 0x54321000); + + res = __IACCreadll (0); + res1 = 0x12345678LL * 0x40004000LL; + res2 = 0x12000000LL * 0x11223344LL; + res3 = 0x01020304LL * 0x54321000LL; + if (res != res1 + res2 - res3) + abort (); + + __IACCsetll (0, 0x7ffffffffffffff0LL); + __SMASS (0x100, 0x100); + if (__IACCreadll (0) != 0x7fffffffffffffffLL) + abort (); + + __IACCsetl (0, -0x7ffffffe); + __IACCsetl (1, 0); + __SMSSS (0x10001, 0x10000); + if (__IACCreadl (0) != -0x7fffffff - 1 || __IACCreadl (1) != -0x10000) + abort (); + + __SMSSS (0x10001, 0x10000); + if (__IACCreadl (0) != -0x7fffffff - 1 || __IACCreadl (1) != 0) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr405-builtins-2.c b/gcc/testsuite/gcc.target/frv/fr405-builtins-2.c new file mode 100644 index 00000000000..778547c4dc0 --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr405-builtins-2.c @@ -0,0 +1,69 @@ +/* Test the SCUTSS instruction. */ +/* { dg-options "-mcpu=fr405" } */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +int main () +{ + struct { + long long value; + int cut_point; + int result; + } values[] = { + /* Non-saturating values */ + + { +0x0000000000001234LL, 44, +0x01234000 }, + { ~0x0000000000001234LL, 44, ~0x01234fff }, + + { +0x0000011223300fffLL, 20, +0x11223301 }, + { ~0x0000011223300fffLL, 20, ~0x11223300 }, + { +0x0000011223300800LL, 20, +0x11223301 }, + { ~0x0000011223300800LL, 20, ~0x11223300 }, + { +0x00000112233007ffLL, 20, +0x11223300 }, + { ~0x00000112233007ffLL, 20, ~0x112232ff }, + { +0x0000011223300000LL, 20, +0x11223300 }, + { ~0x0000011223300000LL, 20, ~0x112232ff }, + + { +0x1234567fffffffffLL, -4, +0x01234568 }, + { ~0x1234567fffffffffLL, -4, ~0x01234567 }, + { +0x1234567800000000LL, -4, +0x01234568 }, + { ~0x1234567800000000LL, -4, ~0x01234567 }, + { +0x12345677ffffffffLL, -4, +0x01234567 }, + { ~0x12345677ffffffffLL, -4, ~0x01234566 }, + { +0x1234567000000000LL, -4, +0x01234567 }, + { ~0x1234567000000000LL, -4, ~0x01234566 }, + + /* Saturation tests */ + + { +0x4000000000000000LL, 44, +0x7fffffff }, + { ~0x4000000000000000LL, 44, ~0x7fffffff }, + { +0x0000000000080000LL, 44, +0x7fffffff }, + { ~0x0000000000080000LL, 44, ~0x7fffffff }, + { +0x000000000007ffffLL, 44, +0x7ffff000 }, + { ~0x000000000007ffffLL, 44, ~0x7fffffff }, + { +0x000000000007fffeLL, 44, +0x7fffe000 }, + { ~0x000000000007fffeLL, 44, ~0x7fffefff }, + + { +0x4000000000000000LL, 20, +0x7fffffff }, + { ~0x4000000000000000LL, 20, ~0x7fffffff }, + { +0x0000080000000000LL, 20, +0x7fffffff }, + { ~0x0000080000000000LL, 20, ~0x7fffffff }, + { +0x000007ffffffffffLL, 20, +0x7fffffff }, + { ~0x000007ffffffffffLL, 20, ~0x7fffffff }, + { +0x000007fffffff000LL, 20, +0x7fffffff }, + { ~0x000007fffffff000LL, 20, ~0x7ffffffe }, + { +0x000007ffffffe000LL, 20, +0x7ffffffe }, + { ~0x000007ffffffefffLL, 20, ~0x7ffffffe } + }; + + unsigned int i; + + for (i = 0; i < sizeof (values) / sizeof (values[0]); i++) + { + __IACCsetll (0, values[i].value); + if (__SCUTSS (values[i].cut_point) != values[i].result) + abort (); + } + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr405-builtins-3.c b/gcc/testsuite/gcc.target/frv/fr405-builtins-3.c new file mode 100644 index 00000000000..91fd96d7f62 --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr405-builtins-3.c @@ -0,0 +1,58 @@ +/* Test the remaining integer instructions. */ +/* { dg-options "-mcpu=fr405" } */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +int main () +{ + if (__SLASS (0x112233, 4) != 0x1122330) + abort (); + + if (__SLASS (0x7ffff, 12) != 0x7ffff000) + abort (); + + if (__SLASS (0x80000, 12) != 0x7fffffff) + abort (); + + if (__SLASS (-0x7ffff, 12) != -0x7ffff000) + abort (); + + if (__SLASS (-0x80000, 12) != -0x7fffffff - 1) + abort (); + + if (__SLASS (-0x80001, 12) != -0x7fffffff - 1) + abort (); + + if (__ADDSS (0x7fffffff, 1) != 0x7fffffff) + abort (); + + if (__ADDSS (0x7ffffffd, 1) != 0x7ffffffe) + abort (); + + if (__ADDSS (-0x7fffffff, -2) != -0x7fffffff - 1) + abort (); + + if (__ADDSS (-0x7ffffffd, -2) != -0x7fffffff) + abort (); + + if (__SUBSS (0x7fffffff, -1) != 0x7fffffff) + abort (); + + if (__SUBSS (0x7ffffffd, -1) != 0x7ffffffe) + abort (); + + if (__SUBSS (-0x7fffffff, 2) != -0x7fffffff - 1) + abort (); + + if (__SUBSS (-0x7ffffffd, 2) != -0x7fffffff) + abort (); + + if (__SCAN (0x12345678, 0) != 3) + abort (); + + if (__SCAN (0x12345678, 0x24680000) != 17) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr450-builtins-1.c b/gcc/testsuite/gcc.target/frv/fr450-builtins-1.c new file mode 100644 index 00000000000..cb7986ddb96 --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr450-builtins-1.c @@ -0,0 +1,27 @@ +/* Test __MQLCLRHS. */ +/* { dg-options "-mcpu=fr450" } */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +int main () +{ + struct { unsigned long long a, b, c; } entries[] = { + { 0x10002000e800d800ULL, 0x0800080008000800ULL, 0x10002000e800d800ULL }, + { 0x10002000e800d800ULL, 0xf800f800f800f800ULL, 0xf000e00018002800ULL }, + { 0x1000100010001000ULL, 0xf000f80008001000ULL, 0x0000f00010000000ULL }, + { 0xf000f000f000f000ULL, 0xf000f80008001000ULL, 0x00001000f0000000ULL }, + { 0x8000800080008000ULL, 0x80007fff80010000ULL, 0x000080007fff8000ULL }, + { 0x7fff7fff7fff7fffULL, 0x80007fff80010000ULL, 0x0000000000007fffULL }, + { 0x8001800180018001ULL, 0x80007fff80010000ULL, 0x0000000000008001ULL }, + { 0x800080000001ffffULL, 0x0001ffff80008000ULL, 0x80007fff00000000ULL } + }; + + unsigned int i; + + for (i = 0; i < sizeof (entries) / sizeof (entries[0]); i++) + if (__MQLCLRHS (entries[i].a, entries[i].b) != entries[i].c) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr450-builtins-2.c b/gcc/testsuite/gcc.target/frv/fr450-builtins-2.c new file mode 100644 index 00000000000..663d735cf0b --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr450-builtins-2.c @@ -0,0 +1,27 @@ +/* Test __MLMTHS. */ +/* { dg-options "-mcpu=fr450" } */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +int main () +{ + struct { unsigned long long a, b, c; } entries[] = { + { 0x10002000e800d800ULL, 0x0800080008000800ULL, 0x08000800f800f800ULL }, + { 0x10002000e800d800ULL, 0xf800f800f800f800ULL, 0xf800f80008000800ULL }, + { 0x1000100010001000ULL, 0xe800f80008001800ULL, 0x1000f80008001000ULL }, + { 0xf000f000f000f000ULL, 0xe800f80008001800ULL, 0xf0000800f800f000ULL }, + { 0x8000800080008000ULL, 0x80007fff80010000ULL, 0x7fff80017fff0000ULL }, + { 0x7fff7fff7fff7fffULL, 0x80007fff80010000ULL, 0x7fff7fff80010000ULL }, + { 0x8001800180018001ULL, 0x80007fff80010000ULL, 0x800180017fff0000ULL }, + { 0x800080000001ffffULL, 0x0001ffff80008000ULL, 0xffff00010001ffffULL } + }; + + unsigned int i; + + for (i = 0; i < sizeof (entries) / sizeof (entries[0]); i++) + if (__MQLMTHS (entries[i].a, entries[i].b) != entries[i].c) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr450-builtins-3.c b/gcc/testsuite/gcc.target/frv/fr450-builtins-3.c new file mode 100644 index 00000000000..00478a4ae49 --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr450-builtins-3.c @@ -0,0 +1,25 @@ +/* Test __MQSLLHI. */ +/* { dg-options "-mcpu=fr450" } */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +int main () +{ + if (__MQSLLHI (0x0001000200030004ULL, 1) != 0x0002000400060008ULL) + abort (); + + if (__MQSLLHI (0xfffffffefffcfff8ULL, 1) != 0xfffefffcfff8fff0ULL) + abort (); + + if (__MQSLLHI (0xfffffffefffcfff8ULL, 12) != 0xf000e000c0008000ULL) + abort (); + + if (__MQSLLHI (0x123456789abcdef0ULL, 12) != 0x40008000c0000000ULL) + abort (); + + if (__MQSLLHI (0x123456789abcdef0ULL, 16) != 0x123456789abcdef0ULL) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr450-builtins-4.c b/gcc/testsuite/gcc.target/frv/fr450-builtins-4.c new file mode 100644 index 00000000000..1eee1861ae5 --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr450-builtins-4.c @@ -0,0 +1,25 @@ +/* Test __MQSRAHI. */ +/* { dg-options "-mcpu=fr450" } */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +int main () +{ + if (__MQSRAHI (0x0001000200030004ULL, 1) != 0x0000000100010002ULL) + abort (); + + if (__MQSRAHI (0xfffffffefffcfff8ULL, 1) != 0xfffffffffffefffcULL) + abort (); + + if (__MQSRAHI (0x8000c000e000f000ULL, 12) != 0xfff8fffcfffeffffULL) + abort (); + + if (__MQSRAHI (0x123456789abcdef0ULL, 12) != 0x00010005fff9fffdULL) + abort (); + + if (__MQSRAHI (0x123456789abcdef0ULL, 16) != 0x123456789abcdef0ULL) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr450-builtins-5.c b/gcc/testsuite/gcc.target/frv/fr450-builtins-5.c new file mode 100644 index 00000000000..c94e8ff80ff --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr450-builtins-5.c @@ -0,0 +1,35 @@ +/* Test that all accumulator registers are accessible. */ +/* { dg-options "-mcpu=fr450" } */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +#define TEST_ACC(X) \ + (__MWTACC (X, 0x11220000 | X), __MRDACC (X) ^ (0x11220000 | X)) + +#define TEST_ACCG(X) \ + (__MWTACCG (X, X), __MRDACCG (X) ^ X) + +#define ZERO_ACC(X) \ + (__MRDACC (X) | __MRDACCG (X)) + +int +main () +{ + if (TEST_ACC (0) | TEST_ACC (1) | TEST_ACC (2) | TEST_ACC (3)) + abort (); + if (TEST_ACC (8) | TEST_ACC (9) | TEST_ACC (10) | TEST_ACC (11)) + abort (); + if (TEST_ACCG (0) | TEST_ACCG (1) | TEST_ACCG (2) | TEST_ACCG (3)) + abort (); + if (TEST_ACCG (8) | TEST_ACCG (9) | TEST_ACCG (10) | TEST_ACCG (11)) + abort (); + + __MCLRACCA (); + if (ZERO_ACC (0) | ZERO_ACC (1) | ZERO_ACC (2) | ZERO_ACC (3)) + abort (); + if (ZERO_ACC (8) | ZERO_ACC (9) | ZERO_ACC (10) | ZERO_ACC (11)) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr450-builtins-6.c b/gcc/testsuite/gcc.target/frv/fr450-builtins-6.c new file mode 100644 index 00000000000..0624eb1f599 --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr450-builtins-6.c @@ -0,0 +1,23 @@ +/* Test a situation in which an M5 instruction (mrdacc) and M4 instruction + (mqmulhu) can be issued together. */ +/* { dg-options "-mcpu=fr450" } */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +int +main () +{ + __MQMULHU (0, 0x0011002200330044ULL, 0x0002000300040001ULL); + __MQMULHU (8, 0x0100020003000400ULL, 0x0001000200030004ULL); + + /* 0x22 + 0x66 + 0xcc + 0x44 = 0x198 */ + /* 0x100 + 0x400 + 0x900 + 0x1000 = 0x1e00 */ + if (__MRDACC (0) + __MRDACC (1) + + __MRDACC (2) + __MRDACC (3) + + __MRDACC (8) + __MRDACC (9) + + __MRDACC (10) + __MRDACC (11) != 0x1f98) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr450-builtins-7.c b/gcc/testsuite/gcc.target/frv/fr450-builtins-7.c new file mode 100644 index 00000000000..dbba44a85ca --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr450-builtins-7.c @@ -0,0 +1,24 @@ +/* Test that the code from fr450-builtins-6.c packs together an + M4 and M5 instruction. */ +/* { dg-options "-O2 -mcpu=fr450" } */ +/* { dg-do compile } */ +/* { dg-final { scan-assembler "mqmulhu.p\[^\t\]*\t*mrdacc" } } */ +extern void abort (void); +extern void exit (int); + +int +main () +{ + __MQMULHU (0, 0x0011002200330044ULL, 0x0002000300040001ULL); + __MQMULHU (8, 0x0100020003000400ULL, 0x0001000200030004ULL); + + /* 0x22 + 0x66 + 0xcc + 0x44 = 0x198 */ + /* 0x100 + 0x400 + 0x900 + 0x1000 = 0x1e00 */ + if (__MRDACC (0) + __MRDACC (1) + + __MRDACC (2) + __MRDACC (3) + + __MRDACC (8) + __MRDACC (9) + + __MRDACC (10) + __MRDACC (11) != 0x1f98) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr450-builtins-8.c b/gcc/testsuite/gcc.target/frv/fr450-builtins-8.c new file mode 100644 index 00000000000..2c23f8cd879 --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr450-builtins-8.c @@ -0,0 +1,22 @@ +/* Test a situation in which an M6 instruction (mdcutssi) and M4 instruction + (mqmulhu) can be issued together. */ +/* { dg-options "-mcpu=fr450" } */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +int +main () +{ + __MQMULHU (0, 0x0001001101111111ULL, 0x0001000200030004ULL); + __MQMULHU (8, 0x0002002202222222ULL, 0x0004000400040004ULL); + if (__MDCUTSSI (0, 8) + + __MDCUTSSI (2, 8) + + __MDCUTSSI (8, 8) + + __MDCUTSSI (10, 8) + != (0x0000000100000022ULL + 0x0000033300004444ULL + + 0x0000000800000088ULL + 0x0000088800008888ULL)) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr450-builtins-9.c b/gcc/testsuite/gcc.target/frv/fr450-builtins-9.c new file mode 100644 index 00000000000..5f32ba2818f --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr450-builtins-9.c @@ -0,0 +1,23 @@ +/* Test a situation in which an M6 instruction (mdcutssi) and M4 instruction + (mqmulhu) can be issued together. */ +/* { dg-options "-O2 -mcpu=fr450" } */ +/* { dg-do compile } */ +/* { dg-final { scan-assembler "mqmulhu.p\[^\t\]*\t*mdcutssi" } } */ +extern void abort (void); +extern void exit (int); + +int +main () +{ + __MQMULHU (0, 0x0001001101111111ULL, 0x0001000200030004ULL); + __MQMULHU (8, 0x0002002202222222ULL, 0x0004000400040004ULL); + if (__MDCUTSSI (0, 8) + + __MDCUTSSI (2, 8) + + __MDCUTSSI (8, 8) + + __MDCUTSSI (10, 8) + != (0x0000000100000022ULL + 0x0000033300004444ULL + + 0x0000000800000088ULL + 0x0000088800008888ULL)) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr550-builtins-1.c b/gcc/testsuite/gcc.target/frv/fr550-builtins-1.c new file mode 100644 index 00000000000..d728f12a4fc --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr550-builtins-1.c @@ -0,0 +1,42 @@ +/* Test prefetch support. */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +unsigned char global[64]; + +void +foo (unsigned int *x, int n) +{ + unsigned short local[16]; + + __data_prefetch0 (x); + __data_prefetch0 (&x[8]); + __data_prefetch0 (&x[n]); + __data_prefetch0 (local); + __data_prefetch0 (&local[16]); + __data_prefetch0 (&local[n]); + __data_prefetch0 (global); + __data_prefetch0 (&global[32]); + __data_prefetch0 (&global[n]); + +#if __FRV_VLIW__ > 1 + __data_prefetch (x); + __data_prefetch (&x[8]); + __data_prefetch (&x[n]); + __data_prefetch (local); + __data_prefetch (&local[16]); + __data_prefetch (&local[n]); + __data_prefetch (global); + __data_prefetch (&global[32]); + __data_prefetch (&global[n]); +#endif +} + +int main () +{ + unsigned int i[16]; + + foo (i, 2); + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr550-builtins-2.c b/gcc/testsuite/gcc.target/frv/fr550-builtins-2.c new file mode 100644 index 00000000000..ce39f462c7e --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr550-builtins-2.c @@ -0,0 +1,9 @@ +/* Test prefetch support. */ +/* { dg-do compile } */ + +void foo (void *x) +{ + __data_prefetch0 (x); +} + +/* { dg-final { scan-assembler "\tdcpl " } } */ diff --git a/gcc/testsuite/gcc.target/frv/fr550-builtins-3.c b/gcc/testsuite/gcc.target/frv/fr550-builtins-3.c new file mode 100644 index 00000000000..b5347de7452 --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr550-builtins-3.c @@ -0,0 +1,13 @@ +/* Test prefetch support. */ +/* { dg-do compile } */ + +#if __FRV_VLIW__ > 1 +void foo (void *x) +{ + __data_prefetch (x); +} +#else +asm (";\tnop.p\n;\tnldub "); +#endif + +/* { dg-final { scan-assembler "\tnop.p.*\tnldub " } } */ diff --git a/gcc/testsuite/gcc.target/frv/fr550-builtins-4.c b/gcc/testsuite/gcc.target/frv/fr550-builtins-4.c new file mode 100644 index 00000000000..801dfee207d --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr550-builtins-4.c @@ -0,0 +1,48 @@ +/* Test the __M{,D}{ADD,SUB}ACC functions. */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +int +main () +{ + __MWTACC (6, 10); + __MWTACC (7, 25); + __MADDACCS (5, 6); + if (__MRDACC (5) != 35) + abort (); + __MSUBACCS (4, 6); + if (__MRDACC (4) != -15) + abort (); + __MASACCS (4, 6); + if (__MRDACC (4) != 35 || __MRDACC (5) != -15) + abort (); + + __MWTACC (0, 100); + __MWTACC (1, 150); + __MWTACC (2, 1000); + __MWTACC (3, 1500); + __MDADDACCS (2, 0); + if (__MRDACC (2) != 250 || __MRDACC (3) != 2500) + abort (); + + __MWTACC (0, 100); + __MWTACC (1, 150); + __MWTACC (2, 1000); + __MWTACC (3, 1500); + __MDSUBACCS (2, 0); + if (__MRDACC (2) != -50 || __MRDACC (3) != -500) + abort (); + + __MWTACC (0, 100); + __MWTACC (1, 150); + __MWTACC (2, 1000); + __MWTACC (3, 1500); + __MDASACCS (0, 0); + if (__MRDACC (0) != 250 || __MRDACC (1) != -50) + abort (); + if (__MRDACC (2) != 2500 || __MRDACC (3) != -500) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/fr550-builtins-5.c b/gcc/testsuite/gcc.target/frv/fr550-builtins-5.c new file mode 100644 index 00000000000..ff75ea17dfe --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/fr550-builtins-5.c @@ -0,0 +1,25 @@ +/* Test that __MADDACC only changes the registers it's supposed to. */ +/* { dg-do run } */ +extern void abort (void); +extern void exit (int); + +int +main () +{ + __MWTACC (0, 1); + __MWTACC (1, 1); + __MWTACC (2, 1); + __MWTACC (3, 1); + __MWTACC (4, 1); + __MWTACC (5, 1); + __MWTACC (6, 1); + __MWTACC (7, 1); + __MADDACCS (0, 2); + __MADDACCS (4, 6); + if ((__MRDACC (0) - 2) + | (__MRDACC (1) - 1) + | (__MRDACC (4) - 2) + | (__MRDACC (5) - 1)) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.target/frv/frv.exp b/gcc/testsuite/gcc.target/frv/frv.exp new file mode 100644 index 00000000000..f2c4359b426 --- /dev/null +++ b/gcc/testsuite/gcc.target/frv/frv.exp @@ -0,0 +1,35 @@ +# The name of each test starts with the architecture it requires. Tests that +# work on all variants start with "all". + +if {![istarget frv-*-*]} { + return 0 +} + +load_lib gcc-dg.exp + +# Find out which architecture is used by default. +set mainarch "fr500" +foreach flag [target_info multilib_flags] { + regexp "^-mcpu=(.*)" $flag dummy mainarch + if {$flag == "-mno-pack"} { + # -mno-pack disables media intrinsics. + return 0 + } +} + +# Set $archs to "all" plus the list of architectures we can test. +set archs [list "all" $mainarch] +switch $mainarch { + fr405 { lappend archs fr400 } + fr450 { lappend archs fr405 fr400 } +} + +# Set $files to the list of files we can test. +set files "" +foreach arch $archs { + lappend files [lsort [glob -nocomplain $srcdir/$subdir/${arch}*.c]] +} + +dg-init +gcc-dg-runtest [eval concat $files] "" +dg-finish -- 2.30.2