aboutsummaryrefslogtreecommitdiff
path: root/meta-linaro-toolchain/recipes-devtools/gcc/gcc-arm-8.3/0034-libgcc-Add-knob-to-use-ldbl-128-on-ppc.patch
blob: 391cda71d7cbcbd02129d8492e6803535af011e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
From faf35e26740461fe1a1da5433d5a0169a663e3b5 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 29 Apr 2016 20:03:28 +0000
Subject: [PATCH 34/39] libgcc: Add knob to use ldbl-128 on ppc

musl does not support ldbl 128 so we can not assume
that linux as a whole supports ldbl-128 bits, instead
act upon configure option passed to gcc and assume no
on musl and yes otherwise if no option is passed since
default behaviour is to assume ldbl128 it does not
change the defaults

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Pending

 libgcc/Makefile.in           |  1 +
 libgcc/config/rs6000/t-linux |  5 ++++-
 libgcc/configure             | 18 ++++++++++++++++++
 libgcc/configure.ac          | 12 ++++++++++++
 4 files changed, 35 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 libgcc/configure

diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index dd8cee99fd3..b5f478af382 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -48,6 +48,7 @@ unwind_header = @unwind_header@
 md_unwind_header = @md_unwind_header@
 sfp_machine_header = @sfp_machine_header@
 thread_header = @thread_header@
+with_ldbl128 = @with_ldbl128@
 
 host_noncanonical = @host_noncanonical@
 real_host_noncanonical = @real_host_noncanonical@
diff --git a/libgcc/config/rs6000/t-linux b/libgcc/config/rs6000/t-linux
index 4f6d4c4a4d2..c50dd94a2da 100644
--- a/libgcc/config/rs6000/t-linux
+++ b/libgcc/config/rs6000/t-linux
@@ -1,3 +1,9 @@
 SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
 
-HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-minimal-toc
+ifeq ($(with_ldbl128),yes)
+HOST_LIBGCC2_CFLAGS += -mlong-double-128
+else
+# We do not want to build ibm-ldouble.c.
+LIB2ADD := $(filter-out %ibm-ldouble.c, $(LIB2ADD))
+endif
+HOST_LIBGCC2_CFLAGS += -mno-minimal-toc
diff --git a/libgcc/config/rs6000/fixtfdi.c b/libgcc/config/rs6000/fixtfdi.c
--- a/libgcc/config/rs6000/fixtfdi.c	1969-12-31 19:00:00.000000000 -0500
+++ b/libgcc/config/rs6000/fixtfdi.c	2018-12-12 17:54:50.110755540 -0500
@@ -0,0 +1,42 @@
+/* Software floating-point emulation.
+   Convert a to 64bit signed integer
+   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Richard Henderson (rth@cygnus.com) and
+		  Jakub Jelinek (jj@ultra.linux.cz).
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   In addition to the permissions in the GNU Lesser General Public
+   License, the Free Software Foundation gives you unlimited
+   permission to link the compiled version of this file into
+   combinations with other programs, and to distribute those
+   combinations without any restriction coming from the use of this
+   file.  (The Lesser General Public License restrictions do apply in
+   other respects; for example, they cover modification of the file,
+   and distribution when not linked into a combine executable.)
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef _ARCH_PPC64
+#include "soft-fp.h"
+#include "quad-float128.h"
+
+DItype
+__fixtfdi (TFtype a)
+{
+  if (a < 0)
+    return - __fixunstfdi (-a);
+  return __fixunstfdi (a);
+}
+#endif
diff --git a/libgcc/config/rs6000/fixunstfdi.c b/libgcc/config/rs6000/fixunstfdi.c
--- a/libgcc/config/rs6000/fixunstfdi.c	1969-12-31 19:00:00.000000000 -0500
+++ b/libgcc/config/rs6000/fixunstfdi.c	2018-12-12 17:56:06.141654537 -0500
@@ -0,0 +1,58 @@
+/* Software floating-point emulation.
+   Convert a to 64bit unsigned integer
+   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Richard Henderson (rth@cygnus.com) and
+		  Jakub Jelinek (jj@ultra.linux.cz).
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   In addition to the permissions in the GNU Lesser General Public
+   License, the Free Software Foundation gives you unlimited
+   permission to link the compiled version of this file into
+   combinations with other programs, and to distribute those
+   combinations without any restriction coming from the use of this
+   file.  (The Lesser General Public License restrictions do apply in
+   other respects; for example, they cover modification of the file,
+   and distribution when not linked into a combine executable.)
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef _ARCH_PPC64
+#include "soft-fp.h"
+#include "quad-float128.h"
+
+DItype
+__fixunstfdi (TFtype a)
+{
+  if (a < 0)
+    return 0;
+
+  /* Compute high word of result, as a flonum.  */
+  const TFtype b = (a / (((UDItype) 1) << (sizeof (SItype) * 8)));
+  /* Convert that to fixed (but not to DItype!),
+     and shift it into the high word.  */
+  UDItype v = (USItype) b;
+  v <<= (sizeof (SItype) * 8);
+  /* Remove high part from the TFtype, leaving the low part as flonum.  */
+  a -= (TFtype) v;
+  /* Convert that to fixed (but not to DItype!) and add it in.
+     Sometimes A comes out negative.  This is significant, since
+     A has more bits than a long int does.  */
+  if (a < 0)
+    v -= (USItype) (-a);
+  else
+    v += (USItype) a;
+  return v;
+}
+#endif
diff --git a/libgcc/config/rs6000/floatditf.c b/libgcc/config/rs6000/floatditf.c
--- a/libgcc/config/rs6000/floatditf.c	1969-12-31 19:00:00.000000000 -0500
+++ b/libgcc/config/rs6000/floatditf.c	2018-12-12 17:57:55.852953553 -0500
@@ -0,0 +1,47 @@
+/* Software floating-point emulation.
+   Convert a 64bit signed integer to IEEE quad
+   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Richard Henderson (rth@cygnus.com) and
+		  Jakub Jelinek (jj@ultra.linux.cz).
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   In addition to the permissions in the GNU Lesser General Public
+   License, the Free Software Foundation gives you unlimited
+   permission to link the compiled version of this file into
+   combinations with other programs, and to distribute those
+   combinations without any restriction coming from the use of this
+   file.  (The Lesser General Public License restrictions do apply in
+   other respects; for example, they cover modification of the file,
+   and distribution when not linked into a combine executable.)
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef _ARCH_PPC64
+#include "soft-fp.h"
+#include "double.h"
+#include "quad-float128.h"
+
+TFtype
+__floatditf (DItype u)
+{
+  DFtype dh, dl;
+
+  dh = (SItype) (u >> (sizeof (SItype) * 8));
+  dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
+  dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
+
+  return (TFtype) dh + (TFtype) dl;
+}
+#endif
diff --git a/libgcc/config/rs6000/floatunditf.c b/libgcc/config/rs6000/floatunditf.c
--- a/libgcc/config/rs6000/floatunditf.c	1969-12-31 19:00:00.000000000 -0500
+++ b/libgcc/config/rs6000/floatunditf.c	2018-12-12 17:57:15.262473574 -0500
@@ -0,0 +1,47 @@
+/* Software floating-point emulation.
+   Convert a 64bit unsigned integer to IEEE quad
+   Copyright (C) 1997-2016 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Richard Henderson (rth@cygnus.com) and
+		  Jakub Jelinek (jj@ultra.linux.cz).
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   In addition to the permissions in the GNU Lesser General Public
+   License, the Free Software Foundation gives you unlimited
+   permission to link the compiled version of this file into
+   combinations with other programs, and to distribute those
+   combinations without any restriction coming from the use of this
+   file.  (The Lesser General Public License restrictions do apply in
+   other respects; for example, they cover modification of the file,
+   and distribution when not linked into a combine executable.)
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef _ARCH_PPC64
+#include "soft-fp.h"
+#include "double.h"
+#include "quad-float128.h"
+
+TFtype
+__floatunditf (UDItype u)
+{
+  DFtype dh, dl;
+
+  dh = (USItype) (u >> (sizeof (SItype) * 8));
+  dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
+  dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
+
+  return (TFtype) dh + (TFtype) dl;
+}
+#endif
diff --git a/libgcc/config/rs6000/ppc64-fp.c b/libgcc/config/rs6000/ppc64-fp.c
--- a/libgcc/config/rs6000/ppc64-fp.c	2018-12-12 17:53:49.540038500 -0500
+++ b/libgcc/config/rs6000/ppc64-fp.c	2018-12-12 17:49:51.897235314 -0500
@@ -25,34 +25,21 @@
 <http://www.gnu.org/licenses/>.  */
 
 #if defined(__powerpc64__) || defined (__64BIT__) || defined(__ppc64__)
-#define TMODES
 #include "fp-bit.h"
 
-extern DItype __fixtfdi (TFtype);
 extern DItype __fixdfdi (DFtype);
 extern DItype __fixsfdi (SFtype);
 extern USItype __fixunsdfsi (DFtype);
 extern USItype __fixunssfsi (SFtype);
-extern TFtype __floatditf (DItype);
-extern TFtype __floatunditf (UDItype);
 extern DFtype __floatdidf (DItype);
 extern DFtype __floatundidf (UDItype);
 extern SFtype __floatdisf (DItype);
 extern SFtype __floatundisf (UDItype);
-extern DItype __fixunstfdi (TFtype);
 
 static DItype local_fixunssfdi (SFtype);
 static DItype local_fixunsdfdi (DFtype);
 
 DItype
-__fixtfdi (TFtype a)
-{
-  if (a < 0)
-    return - __fixunstfdi (-a);
-  return __fixunstfdi (a);
-}
-
-DItype
 __fixdfdi (DFtype a)
 {
   if (a < 0)
@@ -86,30 +73,6 @@
   return (SItype) a;
 }
 
-TFtype
-__floatditf (DItype u)
-{
-  DFtype dh, dl;
-
-  dh = (SItype) (u >> (sizeof (SItype) * 8));
-  dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
-  dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
-
-  return (TFtype) dh + (TFtype) dl;
-}
-
-TFtype
-__floatunditf (UDItype u)
-{
-  DFtype dh, dl;
-
-  dh = (USItype) (u >> (sizeof (SItype) * 8));
-  dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
-  dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
-
-  return (TFtype) dh + (TFtype) dl;
-}
-
 DFtype
 __floatdidf (DItype u)
 {
@@ -183,30 +146,6 @@
   return (SFtype) f;
 }
 
-DItype
-__fixunstfdi (TFtype a)
-{
-  if (a < 0)
-    return 0;
-
-  /* Compute high word of result, as a flonum.  */
-  const TFtype b = (a / (((UDItype) 1) << (sizeof (SItype) * 8)));
-  /* Convert that to fixed (but not to DItype!),
-     and shift it into the high word.  */
-  UDItype v = (USItype) b;
-  v <<= (sizeof (SItype) * 8);
-  /* Remove high part from the TFtype, leaving the low part as flonum.  */
-  a -= (TFtype) v;
-  /* Convert that to fixed (but not to DItype!) and add it in.
-     Sometimes A comes out negative.  This is significant, since
-     A has more bits than a long int does.  */
-  if (a < 0)
-    v -= (USItype) (-a);
-  else
-    v += (USItype) a;
-  return v;
-}
-
 /* This version is needed to prevent recursion; fixunsdfdi in libgcc
    calls fixdfdi, which in turn calls calls fixunsdfdi.  */
 
diff --git a/libgcc/config/rs6000/quad-float128.h b/libgcc/config/rs6000/quad-float128.h
--- a/libgcc/config/rs6000/quad-float128.h	2018-12-12 17:53:49.540038500 -0500
+++ b/libgcc/config/rs6000/quad-float128.h	2018-12-12 17:30:19.423468244 -0500
@@ -104,6 +104,11 @@
 extern UTItype_ppc __fixunskfti (TFtype);
 extern TFtype __floattikf (TItype_ppc);
 extern TFtype __floatuntikf (UTItype_ppc);
+
+extern DItype_ppc __fixtfdi (TFtype);
+extern DItype_ppc __fixunstfdi (TFtype);
+extern TFtype __floatditf (DItype_ppc);
+extern TFtype __floatunditf (UDItype_ppc);
 #endif
 
 /* Functions using the ISA 3.0 hardware support.  If the code is compiled with
diff --git a/libgcc/config/rs6000/t-float128 b/libgcc/config/rs6000/t-float128
--- a/libgcc/config/rs6000/t-float128	2018-12-12 17:53:49.540038500 -0500
+++ b/libgcc/config/rs6000/t-float128	2018-12-12 17:45:12.233937136 -0500
@@ -24,6 +24,7 @@
 
 # New functions for software emulation
 fp128_ppc_funcs		= floattikf floatuntikf fixkfti fixunskfti \
+			  floatditf floatunditf fixtfdi fixunstfdi \
 			  extendkftf2-sw trunctfkf2-sw \
 			  sfp-exceptions _mulkc3 _divkc3 _powikf2
 

diff --git a/libgcc/configure b/libgcc/configure
old mode 100644
new mode 100755
index b2f3f870844..ed806587c17
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -619,6 +619,7 @@ build_vendor
 build_cpu
 build
 with_aix_soname
+with_ldbl128
 enable_vtable_verify
 enable_shared
 libgcc_topdir
@@ -668,6 +669,7 @@ with_cross_host
 with_ld
 enable_shared
 enable_vtable_verify
+with_long_double_128
 with_aix_soname
 enable_version_specific_runtime_libs
 with_slibdir
@@ -1329,6 +1331,7 @@ Optional Packages:
   --with-target-subdir=SUBDIR      Configuring in a subdirectory for target
   --with-cross-host=HOST           Configuring with a cross compiler
   --with-ld               arrange to use the specified ld (full pathname)
+  --with-long-double-128  use 128-bit long double by default
   --with-aix-soname=aix|svr4|both
                           shared library versioning (aka "SONAME") variant to
                           provide on AIX
@@ -2213,6 +2216,21 @@ fi
 
 
 
+# Check whether --with-long-double-128 was given.
+if test "${with_long_double_128+set}" = set; then :
+  withval=$with_long_double_128; with_ldbl128="$with_long_double_128"
+else
+  case "${host}" in
+ power*-*-musl*)
+   with_ldbl128="no";;
+ *) with_ldbl128="yes";;
+ esac
+
+fi
+
+
+
+
 # Check whether --with-aix-soname was given.
 if test "${with_aix_soname+set}" = set; then :
   withval=$with_aix_soname; case "${host}:${enable_shared}" in
diff --git a/libgcc/configure.ac b/libgcc/configure.ac
index b59aa746afc..42220a263c5 100644
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -78,6 +78,18 @@ AC_ARG_ENABLE(vtable-verify,
 [enable_vtable_verify=no])
 AC_SUBST(enable_vtable_verify)
 
+AC_ARG_WITH(long-double-128,
+[AS_HELP_STRING([--with-long-double-128],
+    [use 128-bit long double by default])],
+      with_ldbl128="$with_long_double_128",
+[case "${host}" in
+ power*-*-musl*)
+   with_ldbl128="no";;
+ *) with_ldbl128="yes";;
+ esac
+])
+AC_SUBST(with_ldbl128)
+
 AC_ARG_WITH(aix-soname,
 [AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
     [shared library versioning (aka "SONAME") variant to provide on AIX])],
-- 
2.17.0