[arm] PR target/65578: Fix builtin-bswap16-1.c and builtin-bswap-1.c
The builtin-bswap-1.c and builtin-bswap16-1.c are pretty annoying at the moment. They force an explicit armv6 option that is a thumb1 target, so if you're testing a toolchain configured with something like --with-cpu=cortex-a15 --with-float=hard --with-mode=thumb you'll get those pesky errors about Thumb1 hard-float not being implemented, even though the tests don't relate to floating-point functionality at all. I *think* this is also due to the wrong order of dg-options and dg-require-effective-target directives that might end up not doing a proper effective target check. The solution in this patch is to commonise the code and create a couple of tests for each. One tests an armv6t2 target. This allows us to test an ARM or a Thumb2 target. The second one sets an armv6-m target, which is a Thumb1 target. The dg-add-options machinery for arm_arch_v6m knows how to add the right -mfloat-abi=soft option. With this patch we end up testing all of ARM, Thumb1, Thumb2 codegen whereas before we only ever tried testing Thumb1, if the multilib options happened to line up just right, and would give an ugly error otherwise. Now, if the multilib options don't allow the test it should just appear as UNSUPPORTED. PR target/65578 * gcc.target/arm/builtin-bswap.x: New file. * gcc.target/arm/builtin-bswap-1.c: Include the above. Add checks and options for armv6t2. * gcc.target/arm/builtin-bswap-2.c: Include the above. Add checks and options for Thumb1. * gcc.target/arm/builtin-bswap16.x: New file. * gcc.target/arm/builtin-bswap16-1.c: Include the above. Add checks and options for armv6t2. * gcc.target/arm/builtin-bswap16-2.c: Include the above. Add checks and options for Thumb1. From-SVN: r256840
This commit is contained in:
parent
f2f4f2442c
commit
c5affc0451
7 changed files with 116 additions and 81 deletions
|
@ -1,3 +1,17 @@
|
|||
2018-01-18 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
|
||||
|
||||
PR target/65578
|
||||
* gcc.target/arm/builtin-bswap.x: New file.
|
||||
* gcc.target/arm/builtin-bswap-1.c: Include the above. Add checks
|
||||
and options for armv6t2.
|
||||
* gcc.target/arm/builtin-bswap-2.c: Include the above. Add checks
|
||||
and options for Thumb1.
|
||||
* gcc.target/arm/builtin-bswap16.x: New file.
|
||||
* gcc.target/arm/builtin-bswap16-1.c: Include the above. Add checks
|
||||
and options for armv6t2.
|
||||
* gcc.target/arm/builtin-bswap16-2.c: Include the above. Add checks
|
||||
and options for Thumb1.
|
||||
|
||||
2018-01-18 Christophe Lyon <christophe.lyon@linaro.org>
|
||||
|
||||
* gcc.target/arm/pr40887.c: Fix dg-options and dg-add-options
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2" } */
|
||||
/* { dg-require-effective-target arm_arch_v6_ok } */
|
||||
/* { dg-add-options arm_arch_v6 } */
|
||||
/* { dg-require-effective-target arm_arch_v6t2_ok } */
|
||||
/* { dg-add-options arm_arch_v6t2 } */
|
||||
/* This test depends on if-conversion creating the conditional forms of
|
||||
of the instructions. Add an -mtune option known to facilitate that. */
|
||||
/* { dg-additional-options "-O2 -mtune=cortex-a53" } */
|
||||
/* { dg-final { scan-assembler-not "orr\[ \t\]" } } */
|
||||
/* { dg-final { scan-assembler-times "revsh\\t" 1 { target { arm_nothumb } } } } */
|
||||
/* { dg-final { scan-assembler-times "revshne\\t" 1 { target { arm_nothumb } } } } */
|
||||
|
@ -13,69 +15,4 @@
|
|||
/* { dg-final { scan-assembler-times "revne\\t" 2 { target { arm_nothumb } } } } */
|
||||
/* { dg-final { scan-assembler-times "rev\\t" 4 { target { ! arm_nothumb } } } } */
|
||||
|
||||
/* revsh */
|
||||
short swaps16 (short x)
|
||||
{
|
||||
return __builtin_bswap16 (x);
|
||||
}
|
||||
|
||||
extern short foos16 (short);
|
||||
|
||||
/* revshne */
|
||||
short swaps16_cond (short x, int y)
|
||||
{
|
||||
short z = x;
|
||||
if (y)
|
||||
z = __builtin_bswap16 (x);
|
||||
return foos16 (z);
|
||||
}
|
||||
|
||||
/* rev16 */
|
||||
unsigned short swapu16 (unsigned short x)
|
||||
{
|
||||
return __builtin_bswap16 (x);
|
||||
}
|
||||
|
||||
extern unsigned short foou16 (unsigned short);
|
||||
|
||||
/* rev16ne */
|
||||
unsigned short swapu16_cond (unsigned short x, int y)
|
||||
{
|
||||
unsigned short z = x;
|
||||
if (y)
|
||||
z = __builtin_bswap16 (x);
|
||||
return foou16 (z);
|
||||
}
|
||||
|
||||
/* rev */
|
||||
int swaps32 (int x) {
|
||||
return __builtin_bswap32 (x);
|
||||
}
|
||||
|
||||
extern int foos32 (int);
|
||||
|
||||
/* revne */
|
||||
int swaps32_cond (int x, int y)
|
||||
{
|
||||
int z = x;
|
||||
if (y)
|
||||
z = __builtin_bswap32 (x);
|
||||
return foos32 (z);
|
||||
}
|
||||
|
||||
/* rev */
|
||||
unsigned int swapu32 (unsigned int x)
|
||||
{
|
||||
return __builtin_bswap32 (x);
|
||||
}
|
||||
|
||||
extern unsigned int foou32 (unsigned int);
|
||||
|
||||
/* revne */
|
||||
unsigned int swapsu2 (unsigned int x, int y)
|
||||
{
|
||||
int z = x;
|
||||
if (y)
|
||||
z = __builtin_bswap32 (x);
|
||||
return foou32 (z);
|
||||
}
|
||||
#include "builtin-bswap.x"
|
||||
|
|
10
gcc/testsuite/gcc.target/arm/builtin-bswap-2.c
Normal file
10
gcc/testsuite/gcc.target/arm/builtin-bswap-2.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-require-effective-target arm_arch_v6m_ok } */
|
||||
/* { dg-add-options arm_arch_v6m } */
|
||||
/* { dg-additional-options "-O2" } */
|
||||
/* { dg-final { scan-assembler-not "orr\[ \t\]" } } */
|
||||
/* { dg-final { scan-assembler-times "revsh\\t" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "rev16\\t" 2 } } */
|
||||
/* { dg-final { scan-assembler-times "rev\\t" 4 } } */
|
||||
|
||||
#include "builtin-bswap.x"
|
66
gcc/testsuite/gcc.target/arm/builtin-bswap.x
Normal file
66
gcc/testsuite/gcc.target/arm/builtin-bswap.x
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* revsh */
|
||||
short swaps16 (short x)
|
||||
{
|
||||
return __builtin_bswap16 (x);
|
||||
}
|
||||
|
||||
extern short foos16 (short);
|
||||
|
||||
/* revshne */
|
||||
short swaps16_cond (short x, int y)
|
||||
{
|
||||
short z = x;
|
||||
if (y)
|
||||
z = __builtin_bswap16 (x);
|
||||
return foos16 (z);
|
||||
}
|
||||
|
||||
/* rev16 */
|
||||
unsigned short swapu16 (unsigned short x)
|
||||
{
|
||||
return __builtin_bswap16 (x);
|
||||
}
|
||||
|
||||
extern unsigned short foou16 (unsigned short);
|
||||
|
||||
/* rev16ne */
|
||||
unsigned short swapu16_cond (unsigned short x, int y)
|
||||
{
|
||||
unsigned short z = x;
|
||||
if (y)
|
||||
z = __builtin_bswap16 (x);
|
||||
return foou16 (z);
|
||||
}
|
||||
|
||||
/* rev */
|
||||
int swaps32 (int x) {
|
||||
return __builtin_bswap32 (x);
|
||||
}
|
||||
|
||||
extern int foos32 (int);
|
||||
|
||||
/* revne */
|
||||
int swaps32_cond (int x, int y)
|
||||
{
|
||||
int z = x;
|
||||
if (y)
|
||||
z = __builtin_bswap32 (x);
|
||||
return foos32 (z);
|
||||
}
|
||||
|
||||
/* rev */
|
||||
unsigned int swapu32 (unsigned int x)
|
||||
{
|
||||
return __builtin_bswap32 (x);
|
||||
}
|
||||
|
||||
extern unsigned int foou32 (unsigned int);
|
||||
|
||||
/* revne */
|
||||
unsigned int swapsu2 (unsigned int x, int y)
|
||||
{
|
||||
int z = x;
|
||||
if (y)
|
||||
z = __builtin_bswap32 (x);
|
||||
return foou32 (z);
|
||||
}
|
|
@ -1,15 +1,7 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2" } */
|
||||
/* { dg-require-effective-target arm_arch_v6_ok } */
|
||||
/* { dg-add-options arm_arch_v6 } */
|
||||
/* { dg-require-effective-target arm_arch_v6t2_ok } */
|
||||
/* { dg-add-options arm_arch_v6t2 } */
|
||||
/* { dg-additional-options "-O2" } */
|
||||
/* { dg-final { scan-assembler-not "orr\[ \t\]" } } */
|
||||
|
||||
unsigned short swapu16_1 (unsigned short x)
|
||||
{
|
||||
return (x << 8) | (x >> 8);
|
||||
}
|
||||
|
||||
unsigned short swapu16_2 (unsigned short x)
|
||||
{
|
||||
return (x >> 8) | (x << 8);
|
||||
}
|
||||
#include "builtin-bswap16.x"
|
||||
|
|
7
gcc/testsuite/gcc.target/arm/builtin-bswap16-2.c
Normal file
7
gcc/testsuite/gcc.target/arm/builtin-bswap16-2.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-require-effective-target arm_arch_v6m_ok } */
|
||||
/* { dg-add-options arm_arch_v6m } */
|
||||
/* { dg-additional-options "-O2" } */
|
||||
/* { dg-final { scan-assembler-not "orr\[ \t\]" } } */
|
||||
|
||||
#include "builtin-bswap16.x"
|
9
gcc/testsuite/gcc.target/arm/builtin-bswap16.x
Normal file
9
gcc/testsuite/gcc.target/arm/builtin-bswap16.x
Normal file
|
@ -0,0 +1,9 @@
|
|||
unsigned short swapu16_1 (unsigned short x)
|
||||
{
|
||||
return (x << 8) | (x >> 8);
|
||||
}
|
||||
|
||||
unsigned short swapu16_2 (unsigned short x)
|
||||
{
|
||||
return (x >> 8) | (x << 8);
|
||||
}
|
Loading…
Add table
Reference in a new issue