logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>

gcc-10-mlong-double.patch (9001B)


  1. SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
  2. SPDX-FileCopyrightText: 2012 H.J. Lu <hongjiu.lu@intel.com>
  3. SPDX-License-Identifier: GPL-3.0-or-later
  4. Backport of the commit:
  5. [PATCH] Add -mlong-double-64/-mlong-double-80 to i386
  6. to GCC 4.7.
  7. GCC 10 uses this argument to ensure some files are compiled with long
  8. double length = 80. This is almost universally true for i386, so it
  9. could be patched out; but the use of this flag is rather extensive,
  10. and if removed will break future added architectures anyway, so it
  11. makes more sense to simply add in support to GCC 4.7.
  12. diff --git gcc/config/i386/i386-c.c gcc/config/i386/i386-c.c
  13. index d00e0ba54b939..edd64ff7ae388 100644
  14. --- gcc-4.7.4/gcc/config/i386/i386-c.c
  15. +++ gcc-4.7.4/gcc/config/i386/i386-c.c
  16. @@ -418,6 +418,9 @@
  17. builtin_define_std ("i386");
  18. }
  19. + if (TARGET_LONG_DOUBLE_64)
  20. + cpp_define (parse_in, "__LONG_DOUBLE_64__");
  21. +
  22. ix86_target_macros_internal (ix86_isa_flags,
  23. ix86_arch,
  24. ix86_tune,
  25. diff --git gcc/config/i386/i386.c gcc/config/i386/i386.c
  26. index a6fc45b047a94..da931ee153745 100644
  27. --- gcc-4.7.4/gcc/config/i386/i386.c
  28. +++ gcc-4.7.4/gcc/config/i386/i386.c
  29. @@ -2786,6 +2786,7 @@ ix86_target_string (HOST_WIDE_INT isa, int flags, const char *arch,
  30. static struct ix86_target_opts flag_opts[] =
  31. {
  32. { "-m128bit-long-double", MASK_128BIT_LONG_DOUBLE },
  33. + { "-mlong-double-64", MASK_LONG_DOUBLE_64 },
  34. { "-m80387", MASK_80387 },
  35. { "-maccumulate-outgoing-args", MASK_ACCUMULATE_OUTGOING_ARGS },
  36. { "-malign-double", MASK_ALIGN_DOUBLE },
  37. @@ -4084,6 +4085,11 @@ ix86_option_override_internal (bool main_args_p)
  38. else if (target_flags_explicit & MASK_RECIP)
  39. recip_mask &= ~(RECIP_MASK_ALL & ~recip_mask_explicit);
  40. + /* Default long double to 64-bit for Bionic. */
  41. + if (TARGET_HAS_BIONIC
  42. + && !(target_flags_explicit & MASK_LONG_DOUBLE_64))
  43. + target_flags |= MASK_LONG_DOUBLE_64;
  44. +
  45. /* Save the initial options in case the user does function specific
  46. options. */
  47. if (main_args_p)
  48. diff --git gcc/config/i386/i386.h gcc/config/i386/i386.h
  49. index 11f79e3f670af..3a41a43e308bf 100644
  50. --- gcc-4.7.4/gcc/config/i386/i386.h
  51. +++ gcc-4.7.4/gcc/config/i386/i386.h
  52. @@ -671,9 +671,17 @@ enum target_cpu_default
  53. #define LONG_LONG_TYPE_SIZE 64
  54. #define FLOAT_TYPE_SIZE 32
  55. #define DOUBLE_TYPE_SIZE 64
  56. -#define LONG_DOUBLE_TYPE_SIZE 80
  57. +#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_64 ? 64 : 80)
  58. -#define WIDEST_HARDWARE_FP_SIZE LONG_DOUBLE_TYPE_SIZE
  59. +/* Define this to set long double type size to use in libgcc2.c, which can
  60. + not depend on target_flags. */
  61. +#ifdef __LONG_DOUBLE_64__
  62. +#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
  63. +#else
  64. +#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 80
  65. +#endif
  66. +
  67. +#define WIDEST_HARDWARE_FP_SIZE 80
  68. #if defined (TARGET_BI_ARCH) || TARGET_64BIT_DEFAULT
  69. #define MAX_BITS_PER_WORD 64
  70. diff --git gcc/config/i386/i386.opt gcc/config/i386/i386.opt
  71. index e4f78f3ce50f3..6a389947d904e 100644
  72. --- gcc-4.7.4/gcc/config/i386/i386.opt
  73. +++ gcc-4.7.4/gcc/config/i386/i386.opt
  74. @@ -86,6 +86,14 @@ m96bit-long-double
  75. Target RejectNegative Report InverseMask(128BIT_LONG_DOUBLE) Save
  76. sizeof(long double) is 12
  77. +mlong-double-80
  78. +Target Report RejectNegative InverseMask(LONG_DOUBLE_64) Save
  79. +Use 80-bit long double
  80. +
  81. +mlong-double-64
  82. +Target Report RejectNegative Mask(LONG_DOUBLE_64) Save
  83. +Use 64-bit long double
  84. +
  85. maccumulate-outgoing-args
  86. Target Report Mask(ACCUMULATE_OUTGOING_ARGS) Save
  87. Reserve space for outgoing arguments in the function prologue
  88. diff --git gcc/testsuite/gcc.target/i386/long-double-64-1.c gcc/testsuite/gcc.target/i386/long-double-64-1.c
  89. new file mode 100644
  90. index 0000000000000..cf933796f8aea
  91. --- /dev/null
  92. +++ gcc-4.7.4/gcc/testsuite/gcc.target/i386/long-double-64-1.c
  93. @@ -0,0 +1,10 @@
  94. +/* { dg-do compile } */
  95. +/* { dg-options "-O2 -mlong-double-64" } */
  96. +
  97. +long double
  98. +foo (long double x)
  99. +{
  100. + return x * x;
  101. +}
  102. +
  103. +/* { dg-final { scan-assembler-not "fldt" } } */
  104. diff --git gcc/testsuite/gcc.target/i386/long-double-64-2.c gcc/testsuite/gcc.target/i386/long-double-64-2.c
  105. new file mode 100644
  106. index 0000000000000..ddf4fe656d099
  107. --- /dev/null
  108. +++ gcc-4.7.4/gcc/testsuite/gcc.target/i386/long-double-64-2.c
  109. @@ -0,0 +1,10 @@
  110. +/* { dg-do compile { target *-*-linux* } } */
  111. +/* { dg-options "-O2 -mbionic" } */
  112. +
  113. +long double
  114. +foo (long double x)
  115. +{
  116. + return x * x;
  117. +}
  118. +
  119. +/* { dg-final { scan-assembler-not "fldt" } } */
  120. diff --git gcc/testsuite/gcc.target/i386/long-double-64-3.c gcc/testsuite/gcc.target/i386/long-double-64-3.c
  121. new file mode 100644
  122. index 0000000000000..e748fab2edd3c
  123. --- /dev/null
  124. +++ gcc-4.7.4/gcc/testsuite/gcc.target/i386/long-double-64-3.c
  125. @@ -0,0 +1,10 @@
  126. +/* { dg-do compile { target *-*-linux* } } */
  127. +/* { dg-options "-O2 -mandroid" } */
  128. +
  129. +long double
  130. +foo (long double x)
  131. +{
  132. + return x * x;
  133. +}
  134. +
  135. +/* { dg-final { scan-assembler-not "fldt" } } */
  136. diff --git gcc/testsuite/gcc.target/i386/long-double-64-4.c gcc/testsuite/gcc.target/i386/long-double-64-4.c
  137. new file mode 100644
  138. index 0000000000000..d9c25aaec080c
  139. --- /dev/null
  140. +++ gcc-4.7.4/gcc/testsuite/gcc.target/i386/long-double-64-4.c
  141. @@ -0,0 +1,10 @@
  142. +/* { dg-do compile } */
  143. +/* { dg-options "-O2 -mlong-double-80 -mlong-double-64" } */
  144. +
  145. +long double
  146. +foo (long double x)
  147. +{
  148. + return x * x;
  149. +}
  150. +
  151. +/* { dg-final { scan-assembler-not "fldt" } } */
  152. diff --git gcc/testsuite/gcc.target/i386/long-double-80-1.c gcc/testsuite/gcc.target/i386/long-double-80-1.c
  153. new file mode 100644
  154. index 0000000000000..d3b75a0be21de
  155. --- /dev/null
  156. +++ gcc-4.7.4/gcc/testsuite/gcc.target/i386/long-double-80-1.c
  157. @@ -0,0 +1,10 @@
  158. +/* { dg-do compile } */
  159. +/* { dg-options "-O2 -mlong-double-80" } */
  160. +
  161. +long double
  162. +foo (long double x)
  163. +{
  164. + return x * x;
  165. +}
  166. +
  167. +/* { dg-final { scan-assembler "fldt" } } */
  168. diff --git gcc/testsuite/gcc.target/i386/long-double-80-2.c gcc/testsuite/gcc.target/i386/long-double-80-2.c
  169. new file mode 100644
  170. index 0000000000000..954dfd15d4271
  171. --- /dev/null
  172. +++ gcc-4.7.4/gcc/testsuite/gcc.target/i386/long-double-80-2.c
  173. @@ -0,0 +1,10 @@
  174. +/* { dg-do compile { target *-*-linux* } } */
  175. +/* { dg-options "-O2 -mlong-double-80 -mbionic" } */
  176. +
  177. +long double
  178. +foo (long double x)
  179. +{
  180. + return x * x;
  181. +}
  182. +
  183. +/* { dg-final { scan-assembler "fldt" } } */
  184. diff --git gcc/testsuite/gcc.target/i386/long-double-80-3.c gcc/testsuite/gcc.target/i386/long-double-80-3.c
  185. new file mode 100644
  186. index 0000000000000..e0e8365e32c4a
  187. --- /dev/null
  188. +++ gcc-4.7.4/gcc/testsuite/gcc.target/i386/long-double-80-3.c
  189. @@ -0,0 +1,10 @@
  190. +/* { dg-do compile { target *-*-linux* } } */
  191. +/* { dg-options "-O2 -mlong-double-80 -mandroid" } */
  192. +
  193. +long double
  194. +foo (long double x)
  195. +{
  196. + return x * x;
  197. +}
  198. +
  199. +/* { dg-final { scan-assembler "fldt" } } */
  200. diff --git gcc/testsuite/gcc.target/i386/long-double-80-4.c gcc/testsuite/gcc.target/i386/long-double-80-4.c
  201. new file mode 100644
  202. index 0000000000000..cac2d55bc166c
  203. --- /dev/null
  204. +++ gcc-4.7.4/gcc/testsuite/gcc.target/i386/long-double-80-4.c
  205. @@ -0,0 +1,10 @@
  206. +/* { dg-do compile } */
  207. +/* { dg-options "-O2 -mlong-double-64 -mlong-double-80" } */
  208. +
  209. +long double
  210. +foo (long double x)
  211. +{
  212. + return x * x;
  213. +}
  214. +
  215. +/* { dg-final { scan-assembler "fldt" } } */
  216. diff --git gcc/testsuite/gcc.target/i386/long-double-80-5.c gcc/testsuite/gcc.target/i386/long-double-80-5.c
  217. new file mode 100644
  218. index 0000000000000..4aa606fd1ba05
  219. --- /dev/null
  220. +++ gcc-4.7.4/gcc/testsuite/gcc.target/i386/long-double-80-5.c
  221. @@ -0,0 +1,10 @@
  222. +/* { dg-do compile } */
  223. +/* { dg-options "-O2 -mlong-double-64" } */
  224. +
  225. +__float80
  226. +foo (__float80 x)
  227. +{
  228. + return x * x;
  229. +}
  230. +
  231. +/* { dg-final { scan-assembler "fldt" } } */
  232. diff --git gcc/testsuite/gcc.target/i386/long-double-80-6.c gcc/testsuite/gcc.target/i386/long-double-80-6.c
  233. new file mode 100644
  234. index 0000000000000..a395a265942c1
  235. --- /dev/null
  236. +++ gcc-4.7.4/gcc/testsuite/gcc.target/i386/long-double-80-6.c
  237. @@ -0,0 +1,11 @@
  238. +/* { dg-do run } */
  239. +/* { dg-options "-O0 -mlong-double-64 -mfpmath=387" } */
  240. +
  241. +int
  242. +main ()
  243. +{
  244. + __float80 a = -0.23456789;
  245. + if ((double) a >= 0)
  246. + __builtin_abort ();
  247. + return 0;
  248. +}
  249. diff --git gcc/testsuite/gcc.target/i386/long-double-80-7.c gcc/testsuite/gcc.target/i386/long-double-80-7.c
  250. new file mode 100644
  251. index 0000000000000..9b30fe8856786
  252. --- /dev/null
  253. +++ gcc-4.7.4/gcc/testsuite/gcc.target/i386/long-double-80-7.c
  254. @@ -0,0 +1,13 @@
  255. +/* { dg-do run } */
  256. +/* { dg-options "-O0 -mlong-double-64 -mfpmath=sse" } */
  257. +/* { dg-require-effective-target sse2 } */
  258. +
  259. +#include "sse2-check.h"
  260. +
  261. +static void
  262. +sse2_test (void)
  263. +{
  264. + __float80 a = -0.23456789;
  265. + if ((double) a >= 0)
  266. + __builtin_abort ();
  267. +}
  268. diff --git libgcc/config/i386/t-linux libgcc/config/i386/t-linux
  269. index 29b4c22398346..4f47f7bfa59cf 100644
  270. --- gcc-4.7.4/libgcc/config/i386/t-linux
  271. +++ gcc-4.7.4/libgcc/config/i386/t-linux
  272. @@ -2,3 +2,5 @@
  273. # Need to support TImode for x86. Override the settings from
  274. # t-slibgcc-elf-ver and t-linux
  275. SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver
  276. +
  277. +HOST_LIBGCC2_CFLAGS += -mlong-double-80