public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [AARCH64][ACLE] Implement __ARM_FP_FENV_ROUNDING in aarch64 backend.
@ 2016-01-11  8:12 Bilyan Borisov
  2016-01-11 10:28 ` Marcus Shawcroft
  2016-01-11 11:41 ` Szabolcs Nagy
  0 siblings, 2 replies; 5+ messages in thread
From: Bilyan Borisov @ 2016-01-11  8:12 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]

This patch implements the __ARM_FP_FENV_ROUNDING macro in the aarch64 
backend.
AArch64 supports configurable rounding modes, which can be set using the
standard C fesetround() function. According to the ACLE 2.0 specification,
__ARM_FP_FENV_ROUNDING is defined to 1 only when fesetround() is provided.
Since newlib doesn't provide this function, and since armv8 aarch64 hardware
provides support for configurable rounding modes for scalar and simd, we 
only
define the macro when we are building a compiler targeting glibc (i.e. 
target
aarch64-none-linux-gnu), which does provide fesetround().

Cross tested on aarch64-none-elf and aarch64-none-linux-gnu. 
Bootstrapped and
tested on aarch64-none-linux-gnu.

---

gcc/

2015-XX-XX  Bilyan Borisov  <bilyan.borisov@foss.arm.com>

	* config/aarch64/aarch64-c.c (aarch64_update_cpp_builtins): New macro
	definition.

gcc/testsuite/

2015-XX-XX  Bilyan Borisov  <bilyan.borisov@foss.arm.com>

	* gcc.target/aarch64/fesetround-checking-baremetal.c: New.
	* gcc.target/aarch64/fesetround-checking-linux.c: Likewise.

[-- Attachment #2: rb5128.patch --]
[-- Type: text/x-patch, Size: 2899 bytes --]

diff --git a/gcc/config/aarch64/aarch64-c.c b/gcc/config/aarch64/aarch64-c.c
index ad95c78b9895a33da3e5a0ec6328219b887ade37..0e07d74639340176f51587e37e5ea91b57fdeee1 100644
--- a/gcc/config/aarch64/aarch64-c.c
+++ b/gcc/config/aarch64/aarch64-c.c
@@ -97,8 +97,15 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
 
   aarch64_def_or_undef (TARGET_SIMD, "__ARM_FEATURE_NUMERIC_MAXMIN", pfile);
   aarch64_def_or_undef (TARGET_SIMD, "__ARM_NEON", pfile);
-
-
+  /* Since fesetround () is not present in newlib, but it's present in glibc, we
+     only define the __ARM_FP_FENV_ROUNDING macro to 1 when glibc is used
+     i.e. on aarch64-none-linux-gnu.  The OPTION_GLIBC macro is undefined on
+     aarch64-none-elf, and is defined on aarch64-none-linux-gnu to an expression
+     that evaluates to 1 when targetting glibc.  The musl, bionic, and uclibc
+     cases haven't been investigated, so don't do any action in that case.  */
+#ifdef OPTION_GLIBC
+    aarch64_def_or_undef (OPTION_GLIBC, "__ARM_FP_FENV_ROUNDING", pfile);
+#endif
   aarch64_def_or_undef (TARGET_CRC32, "__ARM_FEATURE_CRC32", pfile);
 
   cpp_undef (pfile, "__AARCH64_CMODEL_TINY__");
diff --git a/gcc/testsuite/gcc.target/aarch64/fesetround-checking-baremetal.c b/gcc/testsuite/gcc.target/aarch64/fesetround-checking-baremetal.c
new file mode 100644
index 0000000000000000000000000000000000000000..1202dfa2e81923f0d2c9b6be1eb71e3192d5d974
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/fesetround-checking-baremetal.c
@@ -0,0 +1,18 @@
+/* { dg-do compile { target { aarch64*-*-elf* } } } */
+
+extern void abort ();
+
+int
+main ()
+{
+  /* According to ACLE 2.0, __ARM_FP_FENV_ROUNDING macro should be defined to 1
+     when fesetround () is supported.  Since aarch64-none-elf which uses newlib
+     doesn't support this, we error if the macro is defined to 1.
+   */
+#if defined (__ARM_FP_FENV_ROUNDING)
+#error "According to ACLE 2.0, __ARM_FP_FENV_ROUNDING macro should be defined \
+to 1 only when fesetround () is supported."
+#else
+  return 0;
+#endif
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/fesetround-checking-linux.c b/gcc/testsuite/gcc.target/aarch64/fesetround-checking-linux.c
new file mode 100644
index 0000000000000000000000000000000000000000..d79f384d672bf8d0847b41ab8cc2cc594a805dca
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/fesetround-checking-linux.c
@@ -0,0 +1,18 @@
+/* { dg-do compile { target { aarch64*-*-linux* } } } */
+
+extern void abort ();
+
+int
+main ()
+{
+  /* According to ACLE 2.0, __ARM_FP_FENV_ROUNDING macro should be defined to 1
+     when fesetround () is supported.  In our case, this is on
+     aarch64-none-linux-gnu.
+   */
+#if defined (__ARM_FP_FENV_ROUNDING) && (__ARM_FP_FENV_ROUNDING == 1)
+  return 0;
+#else
+#error "According to ACLE 2.0, __ARM_FP_FENV_ROUNDING macro should be defined \
+to 1 when fesetround () is supported."
+#endif
+}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [AARCH64][ACLE] Implement __ARM_FP_FENV_ROUNDING in aarch64 backend.
  2016-01-11  8:12 [AARCH64][ACLE] Implement __ARM_FP_FENV_ROUNDING in aarch64 backend Bilyan Borisov
@ 2016-01-11 10:28 ` Marcus Shawcroft
  2016-01-11 10:46   ` Alan Lawrence
  2016-01-11 11:41 ` Szabolcs Nagy
  1 sibling, 1 reply; 5+ messages in thread
From: Marcus Shawcroft @ 2016-01-11 10:28 UTC (permalink / raw)
  To: Bilyan Borisov; +Cc: gcc-patches

On 11 January 2016 at 08:12, Bilyan Borisov <bilyan.borisov@foss.arm.com> wrote:

> 2015-XX-XX  Bilyan Borisov  <bilyan.borisov@foss.arm.com>
>
>         * config/aarch64/aarch64-c.c (aarch64_update_cpp_builtins): New
> macro
>         definition.
>
> gcc/testsuite/
>
> 2015-XX-XX  Bilyan Borisov  <bilyan.borisov@foss.arm.com>
>
>         * gcc.target/aarch64/fesetround-checking-baremetal.c: New.
>         * gcc.target/aarch64/fesetround-checking-linux.c: Likewise.

for new test cases in gcc.target/aarch64 use the name convention here
https://gcc.gnu.org/wiki/TestCaseWriting, in this case:

fesetround_checking_baremetal_1.c
fesetround_checking_linux_1.c

If we are distinguishing between glibc/musl/bionic/uclibc then the use
of the name "linux" in the last test case would seem to be
inappropriate (all of glibc/musl/bionic and uclibc can be used on top
of a linux kernel). Suggest s/linux/glibc/ in the test case name.

Cheers
/Marcus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [AARCH64][ACLE] Implement __ARM_FP_FENV_ROUNDING in aarch64 backend.
  2016-01-11 10:28 ` Marcus Shawcroft
@ 2016-01-11 10:46   ` Alan Lawrence
  2016-01-11 12:15     ` Marcus Shawcroft
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Lawrence @ 2016-01-11 10:46 UTC (permalink / raw)
  To: Marcus Shawcroft, Bilyan Borisov; +Cc: gcc-patches

On 11/01/16 10:28, Marcus Shawcroft wrote:
> On 11 January 2016 at 08:12, Bilyan Borisov <bilyan.borisov@foss.arm.com> wrote:
>
>> 2015-XX-XX  Bilyan Borisov  <bilyan.borisov@foss.arm.com>
>>
>>          * config/aarch64/aarch64-c.c (aarch64_update_cpp_builtins): New
>> macro
>>          definition.
>>
>> gcc/testsuite/
>>
>> 2015-XX-XX  Bilyan Borisov  <bilyan.borisov@foss.arm.com>
>>
>>          * gcc.target/aarch64/fesetround-checking-baremetal.c: New.
>>          * gcc.target/aarch64/fesetround-checking-linux.c: Likewise.
>
> for new test cases in gcc.target/aarch64 use the name convention here
> https://gcc.gnu.org/wiki/TestCaseWriting, in this case:
>
> fesetround_checking_baremetal_1.c
> fesetround_checking_linux_1.c
>
> If we are distinguishing between glibc/musl/bionic/uclibc then the use
> of the name "linux" in the last test case would seem to be
> inappropriate (all of glibc/musl/bionic and uclibc can be used on top
> of a linux kernel). Suggest s/linux/glibc/ in the test case name.
>
> Cheers
> /Marcus

However, the test doesn't really look at whether we're using glibc vs 
musl/bionic/uclibc, only at whether we are targeting -linux-gnu or -none-elf.

Indeed, IIUC, the test would fail, if one (somehow) built a gcc using 
musl/bionic/glibc, as I'm not aware of us having a mechanism to detect that from 
the testsuite...

Just my two cents!

Alan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [AARCH64][ACLE] Implement __ARM_FP_FENV_ROUNDING in aarch64 backend.
  2016-01-11  8:12 [AARCH64][ACLE] Implement __ARM_FP_FENV_ROUNDING in aarch64 backend Bilyan Borisov
  2016-01-11 10:28 ` Marcus Shawcroft
@ 2016-01-11 11:41 ` Szabolcs Nagy
  1 sibling, 0 replies; 5+ messages in thread
From: Szabolcs Nagy @ 2016-01-11 11:41 UTC (permalink / raw)
  To: Bilyan Borisov, gcc-patches; +Cc: nd

On 11/01/16 08:12, Bilyan Borisov wrote:
> +  /* Since fesetround () is not present in newlib, but it's present in glibc, we
> +     only define the __ARM_FP_FENV_ROUNDING macro to 1 when glibc is used
> +     i.e. on aarch64-none-linux-gnu.  The OPTION_GLIBC macro is undefined on
> +     aarch64-none-elf, and is defined on aarch64-none-linux-gnu to an expression
> +     that evaluates to 1 when targetting glibc.  The musl, bionic, and uclibc
> +     cases haven't been investigated, so don't do any action in that case.  */
> +#ifdef OPTION_GLIBC
> +    aarch64_def_or_undef (OPTION_GLIBC, "__ARM_FP_FENV_ROUNDING", pfile);
> +#endif
>     aarch64_def_or_undef (TARGET_CRC32, "__ARM_FEATURE_CRC32", pfile);
>

musl, bionic and uclibc all have working fesetround
(but uclibc does not yet support aarch64 i think)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [AARCH64][ACLE] Implement __ARM_FP_FENV_ROUNDING in aarch64 backend.
  2016-01-11 10:46   ` Alan Lawrence
@ 2016-01-11 12:15     ` Marcus Shawcroft
  0 siblings, 0 replies; 5+ messages in thread
From: Marcus Shawcroft @ 2016-01-11 12:15 UTC (permalink / raw)
  To: Alan Lawrence; +Cc: Bilyan Borisov, gcc-patches

On 11 January 2016 at 10:46, Alan Lawrence <alan.lawrence@foss.arm.com> wrote:

> However, the test doesn't really look at whether we're using glibc vs
> musl/bionic/uclibc, only at whether we are targeting -linux-gnu or
> -none-elf.

Fair point, the test case is not aligned with the implementation.
Rather than hang the test on a target triple the other approach would
be to try and write a test that uses the functionality that is gated
by the predefine.

Cheers
/Marcus

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-01-11 12:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-11  8:12 [AARCH64][ACLE] Implement __ARM_FP_FENV_ROUNDING in aarch64 backend Bilyan Borisov
2016-01-11 10:28 ` Marcus Shawcroft
2016-01-11 10:46   ` Alan Lawrence
2016-01-11 12:15     ` Marcus Shawcroft
2016-01-11 11:41 ` Szabolcs Nagy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).