[COMMITTED] tilegx: enable wordsize-64 support for ieee745 dbl-64.

Chris Metcalf cmetcalf@ezchip.com
Tue Dec 23 21:39:00 GMT 2014


On 12/23/2014 4:21 PM, H.J. Lu wrote:
> On Tue, Dec 23, 2014 at 1:11 PM, Chris Metcalf <cmetcalf@ezchip.com> wrote:
>> On 12/23/2014 3:47 PM, Chris Metcalf wrote:
>>> On 12/23/2014 3:06 PM, Joseph Myers wrote:
>>>> I take it that the ABI on tilegx32 allows the lround alias to llround
>>>
>>> No, it doesn't - I missed this possibility.
>>
>> Actually, it is, of course, a little trickier than that, since
>> we have to prevent s_llround.c from setting up the alias for
>> lround() as well.  But I think it may make sense to use global
>> conditional logic to do this.  The current users of dbl-64/wordsize-64
>> are aarch64, alpha, sparc64, and x86_64.  So as far as I know, the
>> question is whether the forthcoming ILP32 version of aarch64 would
>> benefit from this hack (probably yes) and whether the existing x32
>> version of x86_64 would (not clear to me, but plausibly better to clean
>> up the high bits of the returned value).
> Please make sure that x32 version is unchanged where
> lround is an alias of llround.

How about this version?  We only need to #define the symbol for the rare
case of !_LP64, but still using dbl-64/wordsize-64.  Not yet tested, so just
hoping for guidance with the model.

By the way, I could simplify the #if/#else body duplication if it's OK to
use an alias as the "source" of another alias, e.g. alias __llround to
__lround, then alias __lround to lround.  Is that OK?

diff --git a/sysdeps/tile/sysdep.h b/sysdeps/tile/sysdep.h
index 32aca49ff104..d56566ddcbfd 100644
--- a/sysdeps/tile/sysdep.h
+++ b/sysdeps/tile/sysdep.h
@@ -66,6 +66,10 @@
  #define REGSIZE                4
  #endif

+/* On tilegx, 32-bit values must have their high 32 bits sign extended;
+   random values are not allowed.  */
+#define USE_32BIT_NORMALIZE 1
+
  /* Support a limited form of shared assembly between tilepro and tilegx.
     The presumption is that LD/ST are used for manipulating registers.
     Since opcode parsing is case-insensitive, we don't need to provide
diff --git a/sysdeps/x86_64/x32/sysdep.h b/sysdeps/x86_64/x32/sysdep.h
index 7461827c83a8..c3ebc50be8c4 100644
--- a/sysdeps/x86_64/x32/sysdep.h
+++ b/sysdeps/x86_64/x32/sysdep.h
@@ -90,3 +90,7 @@
  # define R15_LP        "r15d"

  #endif /* __ASSEMBLER__ */
+
+/* On x32, it is not required to normalize a 64-bit value before using
+   it as a 32-bit value.  */
+#define USE_32BIT_NORMALIZE 0
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
index da180fef55cf..0cbc2d31588c 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
@@ -64,16 +64,31 @@ __llround (double x)

  weak_alias (__llround, llround)
  #ifdef NO_LONG_DOUBLE
-strong_alias (__llround, __lroundl)
-weak_alias (__llround, lroundl)
+strong_alias (__llround, __llroundl)
+weak_alias (__llround, llroundl)
  #endif

-/* long has the same width as long long on 64-bit machines.  */
  #undef lround
  #undef __lround
+/* long has the same width as long long on LP64 machines, so use an alias.
+   If building for ILP32 on a machine with 64-bit registers, however,
+   use a cast if necessary.  */
+#if !defined (_LP64) && USE_32BIT_NORMALIZE
+long int
+__lround (double x)
+{
+  return __llround (x);
+}
+weak_alias (__lround, lround)
+# ifdef NO_LONG_DOUBLE
+strong_alias (__lround, __lroundl)
+weak_alias (__lround, lroundl)
+# endif
+#else
  strong_alias (__llround, __lround)
  weak_alias (__llround, lround)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__llround, __llroundl)
-weak_alias (__llround, llroundl)
+# ifdef NO_LONG_DOUBLE
+strong_alias (__llround, __lroundl)
+weak_alias (__llround, lroundl)
+# endif
  #endif

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com



More information about the Libc-alpha mailing list