Re: PATCH: Add -mlong-double-128 and make it default for 64-bit Bionic
On Fri, Jan 31, 2014 at 10:19:12AM -0800, H.J. Lu wrote: On Fri, Jan 31, 2014 at 10:12 AM, Joseph S. Myers jos...@codesourcery.com wrote: On Fri, 31 Jan 2014, Andrew Pinski wrote: On Fri, Jan 31, 2014 at 5:59 AM, H.J. Lu hongjiu...@intel.com wrote: Hi, For 64-bit Android, long double is 128-bit IEEE-754 floating point type. This patch adds -mlong-double-128 to i386 and makes it default for 64-bit Bionic. I only added MASK_LONG_DOUBLE_128. I made -mlong-double-128, -mlong-double-64 and -mlong-double-80 negate each other so that the last one on command line wins. It os OK since we don't support -mlong-double-xxx in target attribute. I added some testcases to verify it works correctly. OK for trunk? I don't see any where in the documentation that explains the difference between -mlong-double-128 and -m128bit-long-double. Can you please add that -mlong-double-128 causes soft-floating point. I will update it together with -m128bit-long-double clarification. Also what about the interactions between these two options. They have nothing to do with each other. -m128bit-long-double controls the storage size of __float80 amd -mlong-double-XXX controls the size of long double, 64, 80 and 128 bits. I checked in my patch. Here is a patch to update invoke.texi. OK for trunk? Thanks. H.J. --- 2014-02-03 H.J. Lu hongjiu...@intel.com * doc/invoke.texi: Document -m96bit-long-double/-m128bit-long-double for the storage size of 80-bit long double. Mention software floating-point for __float128. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 89e80ac..e2193a9 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -15027,28 +15027,28 @@ without that switch. @itemx -m128bit-long-double @opindex m96bit-long-double @opindex m128bit-long-double -These switches control the size of @code{long double} type. The i386 -application binary interface specifies the size to be 96 bits, +These switches control the storage size of 80-bit @code{long double} type. +The i386 application binary interface specifies the size to be 96 bits, so @option{-m96bit-long-double} is the default in 32-bit mode. -Modern architectures (Pentium and newer) prefer @code{long double} +Modern architectures (Pentium and newer) prefer 80-bit @code{long double} to be aligned to an 8- or 16-byte boundary. In arrays or structures conforming to the ABI, this is not possible. So specifying -@option{-m128bit-long-double} aligns @code{long double} -to a 16-byte boundary by padding the @code{long double} with an additional -32-bit zero. +@option{-m128bit-long-double} aligns 80-bit @code{long double} +to a 16-byte boundary by padding the 80-bit @code{long double} with an +additional 32-bit zero. In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as -its ABI specifies that @code{long double} is aligned on 16-byte boundary. +its ABI specifies that 80-bit @code{long double} is aligned on 16-byte boundary. Notice that neither of these options enable any extra precision over the x87 -standard of 80 bits for a @code{long double}. +standard of 80 bits for an 80-bit @code{long double}. @strong{Warning:} if you override the default value for your target ABI, this changes the size of -structures and arrays containing @code{long double} variables, +structures and arrays containing 80-bit @code{long double} variables, as well as modifying the function calling convention for functions taking -@code{long double}. Hence they are not binary-compatible +80-bit @code{long double}. Hence they are not binary-compatible with code compiled without that switch. @item -mlong-double-64 @@ -15061,7 +15061,8 @@ These switches control the size of @code{long double} type. A size of 64 bits makes the @code{long double} type equivalent to the @code{double} type. This is the default for 32-bit Bionic C library. A size of 128 bits makes the @code{long double} type equivalent to the -@code{__float128} type. This is the default for 64-bit Bionic C library. +@code{__float128} type, which is implemented with software floating-point +support. This is the default for 64-bit Bionic C library. @strong{Warning:} if you override the default value for your target ABI, this changes the size of
Re: PATCH: Add -mlong-double-128 and make it default for 64-bit Bionic
On Fri, Jan 31, 2014 at 2:59 PM, H.J. Lu hongjiu...@intel.com wrote: For 64-bit Android, long double is 128-bit IEEE-754 floating point type. This patch adds -mlong-double-128 to i386 and makes it default for 64-bit Bionic. I only added MASK_LONG_DOUBLE_128. I made -mlong-double-128, -mlong-double-64 and -mlong-double-80 negate each other so that the last one on command line wins. It os OK since we don't support -mlong-double-xxx in target attribute. I added some testcases to verify it works correctly. OK for trunk? Thanks. H.J. --- gcc/ 2014-01-30 H.J. Lu hongjiu...@intel.com * config/i386/i386.c (flag_opts): Add -mlong-double-128. (ix86_option_override_internal): Default long double to 64-bit for 32-bit Bionic and to 128-bit for 64-bit Bionic. * config/i386/i386.h (LONG_DOUBLE_TYPE_SIZE): Use 128 if TARGET_LONG_DOUBLE_128 is true. (LIBGCC2_LONG_DOUBLE_TYPE_SIZE): Likewise. * config/i386/i386.opt (mlong-double-80): Negate -mlong-double-64. (mlong-double-64): Negate -mlong-double-128. (mlong-double-128): New option. * config/i386/i386-c.c (ix86_target_macros): Define __LONG_DOUBLE_128__ for TARGET_LONG_DOUBLE_128. * doc/invoke.texi: Document -mlong-double-128. gcc/testsuite/ 2014-01-30 H.J. Lu hongjiu...@intel.com * gcc.target/i386/long-double-64-1.c: Verify __multf3 isn't used. * gcc.target/i386/long-double-64-4.c: Likewise. * gcc.target/i386/long-double-80-1.c: Likewise. * gcc.target/i386/long-double-80-2.c: Likewise. * gcc.target/i386/long-double-80-3.c: Likewise. * gcc.target/i386/long-double-80-4.c: Likewise. * gcc.target/i386/long-double-80-5.c: Likewise. * gcc.target/i386/long-double-64-2.c: Limit to ia32. Verify __multf3 isn't used. * gcc.target/i386/long-double-64-3.c: Likewise. * gcc.target/i386/long-double-128-1.c: New test. * gcc.target/i386/long-double-128-2.c: Likewise. * gcc.target/i386/long-double-128-3.c: Likewise. * gcc.target/i386/long-double-128-4.c: Likewise. * gcc.target/i386/long-double-128-5.c: Likewise. * gcc.target/i386/long-double-128-6.c: Likewise. * gcc.target/i386/long-double-128-7.c: Likewise. * gcc.target/i386/long-double-128-8.c: Likewise. * gcc.target/i386/long-double-128-9.c: Likewise. * gcc.target/i386/long-double-64-5.c: Likewise. * gcc.target/i386/long-double-64-6.c: Likewise. * gcc.target/i386/long-double-64-7.c: Likewise. * gcc.target/i386/long-double-64-8.c: Likewise. * gcc.target/i386/long-double-64-9.c: Likewise. * gcc.target/i386/long-double-80-10.c: Likewise. * gcc.target/i386/long-double-80-8.c: Likewise. * gcc.target/i386/long-double-80-9.c: Likewise. OK for mainline as far as x86 is concerned, but please check if you also need Android maintainer approval. Thanks, Uros.
Re: PATCH: Add -mlong-double-128 and make it default for 64-bit Bionic
On Fri, Jan 31, 2014 at 5:59 AM, H.J. Lu hongjiu...@intel.com wrote: Hi, For 64-bit Android, long double is 128-bit IEEE-754 floating point type. This patch adds -mlong-double-128 to i386 and makes it default for 64-bit Bionic. I only added MASK_LONG_DOUBLE_128. I made -mlong-double-128, -mlong-double-64 and -mlong-double-80 negate each other so that the last one on command line wins. It os OK since we don't support -mlong-double-xxx in target attribute. I added some testcases to verify it works correctly. OK for trunk? I don't see any where in the documentation that explains the difference between -mlong-double-128 and -m128bit-long-double. Can you please add that -mlong-double-128 causes soft-floating point. Also what about the interactions between these two options. Thanks, Andrew Thanks. H.J. --- gcc/ 2014-01-30 H.J. Lu hongjiu...@intel.com * config/i386/i386.c (flag_opts): Add -mlong-double-128. (ix86_option_override_internal): Default long double to 64-bit for 32-bit Bionic and to 128-bit for 64-bit Bionic. * config/i386/i386.h (LONG_DOUBLE_TYPE_SIZE): Use 128 if TARGET_LONG_DOUBLE_128 is true. (LIBGCC2_LONG_DOUBLE_TYPE_SIZE): Likewise. * config/i386/i386.opt (mlong-double-80): Negate -mlong-double-64. (mlong-double-64): Negate -mlong-double-128. (mlong-double-128): New option. * config/i386/i386-c.c (ix86_target_macros): Define __LONG_DOUBLE_128__ for TARGET_LONG_DOUBLE_128. * doc/invoke.texi: Document -mlong-double-128. gcc/testsuite/ 2014-01-30 H.J. Lu hongjiu...@intel.com * gcc.target/i386/long-double-64-1.c: Verify __multf3 isn't used. * gcc.target/i386/long-double-64-4.c: Likewise. * gcc.target/i386/long-double-80-1.c: Likewise. * gcc.target/i386/long-double-80-2.c: Likewise. * gcc.target/i386/long-double-80-3.c: Likewise. * gcc.target/i386/long-double-80-4.c: Likewise. * gcc.target/i386/long-double-80-5.c: Likewise. * gcc.target/i386/long-double-64-2.c: Limit to ia32. Verify __multf3 isn't used. * gcc.target/i386/long-double-64-3.c: Likewise. * gcc.target/i386/long-double-128-1.c: New test. * gcc.target/i386/long-double-128-2.c: Likewise. * gcc.target/i386/long-double-128-3.c: Likewise. * gcc.target/i386/long-double-128-4.c: Likewise. * gcc.target/i386/long-double-128-5.c: Likewise. * gcc.target/i386/long-double-128-6.c: Likewise. * gcc.target/i386/long-double-128-7.c: Likewise. * gcc.target/i386/long-double-128-8.c: Likewise. * gcc.target/i386/long-double-128-9.c: Likewise. * gcc.target/i386/long-double-64-5.c: Likewise. * gcc.target/i386/long-double-64-6.c: Likewise. * gcc.target/i386/long-double-64-7.c: Likewise. * gcc.target/i386/long-double-64-8.c: Likewise. * gcc.target/i386/long-double-64-9.c: Likewise. * gcc.target/i386/long-double-80-10.c: Likewise. * gcc.target/i386/long-double-80-8.c: Likewise. * gcc.target/i386/long-double-80-9.c: Likewise. diff --git a/gcc/config/i386/i386-c.c b/gcc/config/i386/i386-c.c index ee83de6..0c50720 100644 --- a/gcc/config/i386/i386-c.c +++ b/gcc/config/i386/i386-c.c @@ -513,6 +513,9 @@ ix86_target_macros (void) if (TARGET_LONG_DOUBLE_64) cpp_define (parse_in, __LONG_DOUBLE_64__); + if (TARGET_LONG_DOUBLE_128) +cpp_define (parse_in, __LONG_DOUBLE_128__); + cpp_define_formatted (parse_in, __ATOMIC_HLE_ACQUIRE=%d, IX86_HLE_ACQUIRE); cpp_define_formatted (parse_in, __ATOMIC_HLE_RELEASE=%d, IX86_HLE_RELEASE); diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 1e65743..3a01b6e 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2628,6 +2628,7 @@ ix86_target_string (HOST_WIDE_INT isa, int flags, const char *arch, static struct ix86_target_opts flag_opts[] = { { -m128bit-long-double, MASK_128BIT_LONG_DOUBLE }, +{ -mlong-double-128, MASK_LONG_DOUBLE_128 }, { -mlong-double-64, MASK_LONG_DOUBLE_64 }, { -m80387, MASK_80387 }, { -maccumulate-outgoing-args,MASK_ACCUMULATE_OUTGOING_ARGS }, @@ -4195,10 +4196,18 @@ ix86_option_override_internal (bool main_args_p, else if (opts_set-x_target_flags MASK_RECIP) opts-x_recip_mask = ~(RECIP_MASK_ALL ~opts-x_recip_mask_explicit); - /* Default long double to 64-bit for Bionic. */ + /* Default long double to 64-bit for 32-bit Bionic and to __float128 + for 64-bit Bionic. */ if (TARGET_HAS_BIONIC - !(opts_set-x_target_flags MASK_LONG_DOUBLE_64)) -opts-x_target_flags |= MASK_LONG_DOUBLE_64; + !(opts_set-x_target_flags + (MASK_LONG_DOUBLE_64 | MASK_LONG_DOUBLE_128))) +opts-x_target_flags |= (TARGET_64BIT +
Re: PATCH: Add -mlong-double-128 and make it default for 64-bit Bionic
On Fri, Jan 31, 2014 at 8:52 AM, Uros Bizjak ubiz...@gmail.com wrote: On Fri, Jan 31, 2014 at 2:59 PM, H.J. Lu hongjiu...@intel.com wrote: For 64-bit Android, long double is 128-bit IEEE-754 floating point type. This patch adds -mlong-double-128 to i386 and makes it default for 64-bit Bionic. I only added MASK_LONG_DOUBLE_128. I made -mlong-double-128, -mlong-double-64 and -mlong-double-80 negate each other so that the last one on command line wins. It os OK since we don't support -mlong-double-xxx in target attribute. I added some testcases to verify it works correctly. OK for trunk? Thanks. H.J. --- gcc/ 2014-01-30 H.J. Lu hongjiu...@intel.com * config/i386/i386.c (flag_opts): Add -mlong-double-128. (ix86_option_override_internal): Default long double to 64-bit for 32-bit Bionic and to 128-bit for 64-bit Bionic. * config/i386/i386.h (LONG_DOUBLE_TYPE_SIZE): Use 128 if TARGET_LONG_DOUBLE_128 is true. (LIBGCC2_LONG_DOUBLE_TYPE_SIZE): Likewise. * config/i386/i386.opt (mlong-double-80): Negate -mlong-double-64. (mlong-double-64): Negate -mlong-double-128. (mlong-double-128): New option. * config/i386/i386-c.c (ix86_target_macros): Define __LONG_DOUBLE_128__ for TARGET_LONG_DOUBLE_128. * doc/invoke.texi: Document -mlong-double-128. gcc/testsuite/ 2014-01-30 H.J. Lu hongjiu...@intel.com * gcc.target/i386/long-double-64-1.c: Verify __multf3 isn't used. * gcc.target/i386/long-double-64-4.c: Likewise. * gcc.target/i386/long-double-80-1.c: Likewise. * gcc.target/i386/long-double-80-2.c: Likewise. * gcc.target/i386/long-double-80-3.c: Likewise. * gcc.target/i386/long-double-80-4.c: Likewise. * gcc.target/i386/long-double-80-5.c: Likewise. * gcc.target/i386/long-double-64-2.c: Limit to ia32. Verify __multf3 isn't used. * gcc.target/i386/long-double-64-3.c: Likewise. * gcc.target/i386/long-double-128-1.c: New test. * gcc.target/i386/long-double-128-2.c: Likewise. * gcc.target/i386/long-double-128-3.c: Likewise. * gcc.target/i386/long-double-128-4.c: Likewise. * gcc.target/i386/long-double-128-5.c: Likewise. * gcc.target/i386/long-double-128-6.c: Likewise. * gcc.target/i386/long-double-128-7.c: Likewise. * gcc.target/i386/long-double-128-8.c: Likewise. * gcc.target/i386/long-double-128-9.c: Likewise. * gcc.target/i386/long-double-64-5.c: Likewise. * gcc.target/i386/long-double-64-6.c: Likewise. * gcc.target/i386/long-double-64-7.c: Likewise. * gcc.target/i386/long-double-64-8.c: Likewise. * gcc.target/i386/long-double-64-9.c: Likewise. * gcc.target/i386/long-double-80-10.c: Likewise. * gcc.target/i386/long-double-80-8.c: Likewise. * gcc.target/i386/long-double-80-9.c: Likewise. OK for mainline as far as x86 is concerned, but please check if you also need Android maintainer approval. Hi Maxim, Can you take a look at this? BTW, 64-bit Android psABI is on hjl/android branch at https://github.com/hjl-tools/x86-64-psABI Thanks. -- H.J.
Re: PATCH: Add -mlong-double-128 and make it default for 64-bit Bionic
On Fri, Jan 31, 2014 at 5:58 PM, Andrew Pinski pins...@gmail.com wrote: On Fri, Jan 31, 2014 at 5:59 AM, H.J. Lu hongjiu...@intel.com wrote: Hi, For 64-bit Android, long double is 128-bit IEEE-754 floating point type. This patch adds -mlong-double-128 to i386 and makes it default for 64-bit Bionic. I only added MASK_LONG_DOUBLE_128. I made -mlong-double-128, -mlong-double-64 and -mlong-double-80 negate each other so that the last one on command line wins. It os OK since we don't support -mlong-double-xxx in target attribute. I added some testcases to verify it works correctly. OK for trunk? I don't see any where in the documentation that explains the difference between -mlong-double-128 and -m128bit-long-double. Can you please add that -mlong-double-128 causes soft-floating point. Also what about the interactions between these two options. The -m128bit-long-double has no effect on TFmode. The names are similar by coincidence, but it is a good idea to mention the difference in the documentation. Uros.
Re: PATCH: Add -mlong-double-128 and make it default for 64-bit Bionic
On Fri, Jan 31, 2014 at 9:04 AM, Uros Bizjak ubiz...@gmail.com wrote: On Fri, Jan 31, 2014 at 5:58 PM, Andrew Pinski pins...@gmail.com wrote: On Fri, Jan 31, 2014 at 5:59 AM, H.J. Lu hongjiu...@intel.com wrote: Hi, For 64-bit Android, long double is 128-bit IEEE-754 floating point type. This patch adds -mlong-double-128 to i386 and makes it default for 64-bit Bionic. I only added MASK_LONG_DOUBLE_128. I made -mlong-double-128, -mlong-double-64 and -mlong-double-80 negate each other so that the last one on command line wins. It os OK since we don't support -mlong-double-xxx in target attribute. I added some testcases to verify it works correctly. OK for trunk? I don't see any where in the documentation that explains the difference between -mlong-double-128 and -m128bit-long-double. Can you please add that -mlong-double-128 causes soft-floating point. Also what about the interactions between these two options. The -m128bit-long-double has no effect on TFmode. The names are similar by coincidence, but it is a good idea to mention the difference in the documentation. I will come up with something after -mlong-double-128 is checked in. Thanks. -- H.J.
Re: PATCH: Add -mlong-double-128 and make it default for 64-bit Bionic
On Fri, 31 Jan 2014, Andrew Pinski wrote: On Fri, Jan 31, 2014 at 5:59 AM, H.J. Lu hongjiu...@intel.com wrote: Hi, For 64-bit Android, long double is 128-bit IEEE-754 floating point type. This patch adds -mlong-double-128 to i386 and makes it default for 64-bit Bionic. I only added MASK_LONG_DOUBLE_128. I made -mlong-double-128, -mlong-double-64 and -mlong-double-80 negate each other so that the last one on command line wins. It os OK since we don't support -mlong-double-xxx in target attribute. I added some testcases to verify it works correctly. OK for trunk? I don't see any where in the documentation that explains the difference between -mlong-double-128 and -m128bit-long-double. Can you please add that -mlong-double-128 causes soft-floating point. Also what about the interactions between these two options. Yes, I think the invoke.texi documentation for each of these options needs to cross-reference the other one of the options and explain the difference explicitly. I would add: to confirm, does __float80 remain available on 64-bit Android and provide access to XFmode there? (If not, the documentation of __float80 needs updating.) If in future we implement TS 18661-3 in GCC, it will be necessary to work out in cases such as this whether _Float64x should have the representation of __float80 or __float128 (I'd guess __float80 would be better). -- Joseph S. Myers jos...@codesourcery.com
Re: PATCH: Add -mlong-double-128 and make it default for 64-bit Bionic
On Fri, Jan 31, 2014 at 10:12 AM, Joseph S. Myers jos...@codesourcery.com wrote: On Fri, 31 Jan 2014, Andrew Pinski wrote: On Fri, Jan 31, 2014 at 5:59 AM, H.J. Lu hongjiu...@intel.com wrote: Hi, For 64-bit Android, long double is 128-bit IEEE-754 floating point type. This patch adds -mlong-double-128 to i386 and makes it default for 64-bit Bionic. I only added MASK_LONG_DOUBLE_128. I made -mlong-double-128, -mlong-double-64 and -mlong-double-80 negate each other so that the last one on command line wins. It os OK since we don't support -mlong-double-xxx in target attribute. I added some testcases to verify it works correctly. OK for trunk? I don't see any where in the documentation that explains the difference between -mlong-double-128 and -m128bit-long-double. Can you please add that -mlong-double-128 causes soft-floating point. I will update it together with -m128bit-long-double clarification. Also what about the interactions between these two options. They have nothing to do with each other. -m128bit-long-double controls the storage size of __float80 amd -mlong-double-XXX controls the size of long double, 64, 80 and 128 bits. Yes, I think the invoke.texi documentation for each of these options needs to cross-reference the other one of the options and explain the difference explicitly. I would add: to confirm, does __float80 remain available on 64-bit Android Yes, it does. There is a testcase for it: [hjl@gnu-6 testsuite]$ cat gcc.target/i386/long-double-80-5.c /* { dg-do compile } */ /* { dg-options -O2 -mlong-double-64 } */ __float80 foo (__float80 x) { return x * x; } /* { dg-final { scan-assembler fldt } } */ [hjl@gnu-6 testsuite]$ and provide access to XFmode there? (If not, the documentation of __float80 needs updating.) If in future we implement TS 18661-3 in GCC, it will be necessary to work out in cases such as this whether _Float64x should have the representation of __float80 or __float128 (I'd guess __float80 would be better). -- H.J.