public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Implementing real*16 in Fortran
@ 2003-08-03 12:57 Erik Schnetter
  2003-08-03 20:35 ` Jakub Jelinek
  0 siblings, 1 reply; 3+ messages in thread
From: Erik Schnetter @ 2003-08-03 12:57 UTC (permalink / raw)
  To: gcc

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I want to implement real*16 in Fortran.  For that I seem to need two 
things:

(1) For run time libraries, I need a corresponding C type.  I think the 
best thing would be to use long double for that, but it has to have a 
sizeof of 16.  On i386, the option -m128bit-long-double does just this.  
Is there a way to declare a type that does not need this option?  I 
tried

	typedef long double __attribute__((aligned(16)) real16;

but this did not work; the size is still 12.  (Such a mechanism would 
also be very useful to interface between C and Fortran in general.)

(2) In the front end, I have to declare such a type to the middle end.  
The Fortran front end uses currently

#define PUSH_TYPE(name, node) \
  pushdecl (build_decl (TYPE_DECL, get_identifier (name), node))

  gfc_real16_type_node = long_double_type_node;
  PUSH_TYPE ("real16", gfc_real16_type_node);

but this does not make sure that the size is 16 bytes.  The C front end 
has the equivalent of

  gfc_real16_type_node = make_node (REAL_TYPE);
  TYPE_PRECISION (long_double_type_node) = 128;
  layout_type (gfc_real16_type_node);
  PUSH_TYPE ("real16", gfc_real16_type_node);

but can it really be that easy?  Where is the association between the 
constant "128" and the corresponding long double assembler statements 
made?  i386.{c,h,md} still think that a long double has 96 bits.

- -erik

- -- 
Erik Schnetter <schnetter@uni-tuebingen.de>
Web: http://www.tat.physik.uni-tuebingen.de/~schnette/

My email is as private as my paper mail.  I therefore support encrypting
and signing email messages.  Get my PGP key from www.keyserver.net.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/LO9Em3uiSwno3f0RAjTOAKCr9sKzXVgJU/s+NR2qUrVs9BAP7gCeP+Ct
qnhnJiYso9O6jShvWEy+KQ4=
=o/jM
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Implementing real*16 in Fortran
  2003-08-03 12:57 Implementing real*16 in Fortran Erik Schnetter
@ 2003-08-03 20:35 ` Jakub Jelinek
  2003-08-03 21:30   ` Erik Schnetter
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2003-08-03 20:35 UTC (permalink / raw)
  To: Erik Schnetter; +Cc: gcc

On Sun, Aug 03, 2003 at 01:17:19PM +0200, Erik Schnetter wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> I want to implement real*16 in Fortran.  For that I seem to need two 
> things:
> 
> (1) For run time libraries, I need a corresponding C type.  I think the 
> best thing would be to use long double for that, but it has to have a 
> sizeof of 16.  On i386, the option -m128bit-long-double does just this.  
> Is there a way to declare a type that does not need this option?  I 

I don't think IA-32/IA-64/amd64 TFmode (ieee_extended_128)
is what you're looking for. That's still the same thing as XFmode, but
padded to 16 bytes.
Doesn't Fortran mandate IEEE quad format (TFmode on sparc and a couple
of other platforms), ie. 1 bit sign, 15 bits exponent, 112+1 bits of
mantissa?

	Jakub

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Implementing real*16 in Fortran
  2003-08-03 20:35 ` Jakub Jelinek
@ 2003-08-03 21:30   ` Erik Schnetter
  0 siblings, 0 replies; 3+ messages in thread
From: Erik Schnetter @ 2003-08-03 21:30 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday 03 August 2003 20:54, Jakub Jelinek wrote:
> On Sun, Aug 03, 2003 at 01:17:19PM +0200, Erik Schnetter wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > I want to implement real*16 in Fortran.  For that I seem to need
> > two things:
> >
> > (1) For run time libraries, I need a corresponding C type.  I think
> > the best thing would be to use long double for that, but it has to
> > have a sizeof of 16.  On i386, the option -m128bit-long-double does
> > just this. Is there a way to declare a type that does not need this
> > option?  I
>
> I don't think IA-32/IA-64/amd64 TFmode (ieee_extended_128)
> is what you're looking for. That's still the same thing as XFmode,
> but padded to 16 bytes.
> Doesn't Fortran mandate IEEE quad format (TFmode on sparc and a
> couple of other platforms), ie. 1 bit sign, 15 bits exponent, 112+1
> bits of mantissa?

Fortunately, Fortran does not mandate any kind of precision.  I want to 
choose this format because it is implemented in hardware on i386 
processors.  I think that the alternative would require a special code 
and/or out-of-line routines for floating point operations.  I have no 
experience with such libraries, and attaching them to gcc is probably 
more difficult than using the 10-byte format after extending it to 16 
bytes.

- -erik

- -- 
Erik Schnetter <schnetter@uni-tuebingen.de>
Web: http://www.tat.physik.uni-tuebingen.de/~schnette/

My email is as private as my paper mail.  I therefore support encrypting
and signing email messages.  Get my PGP key from www.keyserver.net.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/LXLYm3uiSwno3f0RAkBoAKDNkyAuOXumjl+nyjfpcvl37X0RCwCcDhjQ
eNrWoZP6Hz6k0N7IZin5AMg=
=ePex
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-08-03 20:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-03 12:57 Implementing real*16 in Fortran Erik Schnetter
2003-08-03 20:35 ` Jakub Jelinek
2003-08-03 21:30   ` Erik Schnetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).