Bug 45476 - libgcc should contain TCmode functions
Summary: libgcc should contain TCmode functions
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.0
: P3 enhancement
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-01 09:14 UTC by Francois-Xavier Coudert
Modified: 2010-09-03 19:58 UTC (History)
3 users (show)

See Also:
Host:
Target: x86
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-09-01 10:30:44


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Francois-Xavier Coudert 2010-09-01 09:14:34 UTC
As the Fortran front-end now uses soft-float quad precision floating-point types (__float128 and its complex counterpart), it would be nice for libgcc to contain TFmode functions on Intel/darwin.

This is present on *86*-{linux,mingw,solaris} and ia64-{linux,hpux}. It was recently introduced in *86*-freebsd, see patch at http://gcc.gnu.org/ml/gcc-patches/2010-08/msg02139.html
Comment 1 Uroš Bizjak 2010-09-01 10:12:28 UTC
Intel/darwin already supports __float128.
Comment 2 Francois-Xavier Coudert 2010-09-01 10:21:54 UTC
It partially does. But TC functions are missing:

$ cat a.c
typedef _Complex float __attribute__((mode(TC))) __complex128;

__complex128 foo (__complex128 z1, __complex128 z2) {
  return z1 * z2; }

__complex128 bar (__complex128 z1, __complex128 z2) {
  return z1 / z2; }

int main (void) {
  (void) foo (0, 0);
  return 0;
}
$ ./bin/gcc a.c -W -Wall
Undefined symbols:
  "___divtc3", referenced from:
      _bar in ccqf0ZEK.o
  "___multc3", referenced from:
      _foo in ccqf0ZEK.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

$ ./bin/gcc -v          
Using built-in specs.
COLLECT_GCC=./bin/gcc
COLLECT_LTO_WRAPPER=/Users/fx/devel/gcc/irun/libexec/gcc/x86_64-apple-darwin10.4.0/4.6.0/lto-wrapper
Target: x86_64-apple-darwin10.4.0
Configured with: ../trunk/configure --prefix=/Users/fx/devel/gcc/irun --with-gmp=/Users/fx/devel/gcc/deps --enable-languages=c,fortran --without-ppl
Thread model: posix
gcc version 4.6.0 20100901 (experimental) [trunk revision 163721] (GCC) 
Comment 3 Uroš Bizjak 2010-09-01 10:30:44 UTC
(In reply to comment #2)
> It partially does. But TC functions are missing:

Ah, I see.  Put these defines somewhere:

/* Put all *tf routines in libgcc.  */
#undef LIBGCC2_HAS_TF_MODE
#define LIBGCC2_HAS_TF_MODE 1
#define LIBGCC2_TF_CEXT q
#define TF_SIZE 113
Comment 4 Dominique d'Humieres 2010-09-01 12:31:02 UTC
(In reply to comment #3)
On x86_64-apple-darwin10 I have applied the following patch

--- ../_clean/gcc/config/i386/darwin.h	2010-07-19 11:51:25.000000000 +0200
+++ ../p_work/gcc/config/i386/darwin.h	2010-09-01 14:10:53.000000000 +0200
@@ -148,6 +148,12 @@ extern int darwin_emit_branch_islands;
 
 #define SHIFT_DOUBLE_OMITS_COUNT 0
 
+/* Put all *tf routines in libgcc.  */
+#undef LIBGCC2_HAS_TF_MODE
+#define LIBGCC2_HAS_TF_MODE 1
+#define LIBGCC2_TF_CEXT q
+#define TF_SIZE 113
+
 #undef TARGET_ASM_FILE_END
 #define TARGET_ASM_FILE_END darwin_file_end
 
and bootstrap fails at stage 1 with

ld: duplicate symbol ___fixtfdi in fixtfdi_s.o and _fixtfdi_s.o

Any idea?
Comment 5 Tobias Burnus 2010-09-01 13:31:35 UTC
Cf. patch by Uros for cygming, darwin, freebsd at
http://gcc.gnu.org/ml/gcc-patches/2010-09/msg00040.html
Comment 6 Tobias Burnus 2010-09-01 13:35:59 UTC
Uros, did you see the comment of Dominique regarding x86_64-apple-darwin10?

(In reply to comment #4)
> and bootstrap fails at stage 1 with
> ld: duplicate symbol ___fixtfdi in fixtfdi_s.o and _fixtfdi_s.o

That's with the patch from comment 2 (or comment 4) - but I think that's identical to the submitted patch (comment 5).
Comment 7 uros 2010-09-01 18:06:42 UTC
Subject: Bug 45476

Author: uros
Date: Wed Sep  1 18:06:02 2010
New Revision: 163741

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163741
Log:
        PR target/45476
        * config/i386/cygming.h (LIBGCC2_HAS_TF_MODE,
	LIBGCC2_TF_CEXT, TF_SIZE): Move from ...
        * config/i386/mingw32.h: ... here.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/cygming.h
    trunk/gcc/config/i386/mingw32.h

Comment 8 uros 2010-09-02 05:05:19 UTC
Subject: Bug 45476

Author: uros
Date: Thu Sep  2 05:05:01 2010
New Revision: 163756

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163756
Log:
	PR target/45476
	* config/i386/freebsd.h (LIBGCC2_HAS_TF_MODE,
	LIBGCC2_TF_CEXT, TF_SIZE): New defines.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/freebsd.h

Comment 9 uros 2010-09-03 14:23:46 UTC
Subject: Bug 45476

Author: uros
Date: Fri Sep  3 14:23:05 2010
New Revision: 163819

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163819
Log:
libgcc/ChangeLog:

	PR target/45476
	* Makefile.in (sifuncs, difuncs, tifuncs): Filter out
	LIB2FUNCS_EXCLUDE functions.

gcc/ChangeLog:

	PR target/45476
	* config/i386/t-darwin (LIB2FUNCS_EXCLUDE): New.
	* config/i386/darwin.h (LIBGCC2_HAS_TF_MODE,
	LIBGCC2_TF_CEXT, TF_SIZE): New defines.

gcc/testsuite/ChangeLog:

	PR target/45476
	* gcc.target/i386/float128-1.c: Enable for all x86 targets.
	* gcc.target/i386/float128-2.c: Ditto.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/darwin.h
    trunk/gcc/config/i386/t-darwin
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.target/i386/float128-1.c
    trunk/gcc/testsuite/gcc.target/i386/float128-2.c
    trunk/libgcc/ChangeLog
    trunk/libgcc/Makefile.in

Comment 10 Uroš Bizjak 2010-09-03 19:58:21 UTC
Fixed for all targets that support __float128.