gofast.h revision 169690
1255332Scy/* US Software GOFAST floating point library support.
2255332Scy   Copyright (C) 1994, 1998, 1999, 2002, 2003, 2004
3254219Scy   Free Software Foundation, Inc.
4254219Scy
5254219ScyThis file is part of GCC.
6254219Scy
7254219ScyGCC is free software; you can redistribute it and/or modify
8254219Scyit under the terms of the GNU General Public License as published by
9254219Scythe Free Software Foundation; either version 2, or (at your option)
10254219Scyany later version.
11254219Scy
12254219ScyGCC is distributed in the hope that it will be useful,
13254219Scybut WITHOUT ANY WARRANTY; without even the implied warranty of
14254219ScyMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15254219ScyGNU General Public License for more details.
16254219Scy
17254219ScyYou should have received a copy of the GNU General Public License
18254219Scyalong with GCC; see the file COPYING.  If not, write to
19254219Scythe Free Software Foundation, 51 Franklin Street, Fifth Floor,
20254219ScyBoston, MA 02110-1301, USA.  */
21254219Scy
22254219Scy/* The US Software GOFAST library requires special optabs support.
23254219Scy   This file is intended to be included by config/ARCH/ARCH.c.  It
24254219Scy   defines one function, gofast_maybe_init_libfuncs, which should be
25254219Scy   called from the TARGET_INIT_LIBFUNCS hook.  When tm.h has defined
26254219Scy   US_SOFTWARE_GOFAST, this function will adjust all the optabs and
27254219Scy   libfuncs appropriately.  Otherwise it will do nothing.  */
28254219Scy
29254219Scystatic void
30254219Scygofast_maybe_init_libfuncs (void)
31254219Scy{
32254219Scy#ifdef US_SOFTWARE_GOFAST
33254219Scy  int mode;
34254219Scy
35254219Scy  set_optab_libfunc (add_optab, SFmode, "fpadd");
36254219Scy  set_optab_libfunc (add_optab, DFmode, "dpadd");
37254219Scy  set_optab_libfunc (sub_optab, SFmode, "fpsub");
38254219Scy  set_optab_libfunc (sub_optab, DFmode, "dpsub");
39254219Scy  set_optab_libfunc (smul_optab, SFmode, "fpmul");
40254219Scy  set_optab_libfunc (smul_optab, DFmode, "dpmul");
41254219Scy  set_optab_libfunc (sdiv_optab, SFmode, "fpdiv");
42254219Scy  set_optab_libfunc (sdiv_optab, DFmode, "dpdiv");
43254219Scy  set_optab_libfunc (cmp_optab, SFmode, "fpcmp");
44254219Scy  set_optab_libfunc (cmp_optab, DFmode, "dpcmp");
45254219Scy
46254219Scy  /* GOFAST does not provide libfuncs for negation, so we use the
47254219Scy     standard names.  */
48254219Scy
49254219Scy  /* GCC does not use fpcmp/dpcmp for gt or ge because its own
50254219Scy     FP-emulation library returns +1 for both > and unord.  So we
51254219Scy     leave gt and ge unset, such that, instead of fpcmp(a,b) >[=], we
52254219Scy     generate fpcmp(b,a) <[=] 0, which is unambiguous.  For unord
53254219Scy     libfuncs, we use our own functions, since GOFAST doesn't supply
54254219Scy     them.  */
55254219Scy
56254219Scy  set_optab_libfunc (eq_optab, SFmode, "fpcmp");
57254219Scy  set_optab_libfunc (ne_optab, SFmode, "fpcmp");
58254219Scy  set_optab_libfunc (gt_optab, SFmode, 0);
59254219Scy  set_optab_libfunc (ge_optab, SFmode, 0);
60254219Scy  set_optab_libfunc (lt_optab, SFmode, "fpcmp");
61254219Scy  set_optab_libfunc (le_optab, SFmode, "fpcmp");
62254219Scy
63254219Scy  set_optab_libfunc (eq_optab, DFmode, "dpcmp");
64254219Scy  set_optab_libfunc (ne_optab, DFmode, "dpcmp");
65254219Scy  set_optab_libfunc (gt_optab, DFmode, 0);
66254219Scy  set_optab_libfunc (ge_optab, DFmode, 0);
67254219Scy  set_optab_libfunc (lt_optab, DFmode, "dpcmp");
68254219Scy  set_optab_libfunc (le_optab, DFmode, "dpcmp");
69254219Scy
70254219Scy  set_conv_libfunc (sext_optab,   DFmode, SFmode, "fptodp");
71254219Scy  set_conv_libfunc (trunc_optab,  SFmode, DFmode, "dptofp");
72254219Scy
73254219Scy  set_conv_libfunc (sfix_optab,   SImode, SFmode, "fptosi");
74254219Scy  set_conv_libfunc (sfix_optab,   SImode, DFmode, "dptoli");
75254219Scy  set_conv_libfunc (ufix_optab,   SImode, SFmode, "fptoui");
76254219Scy  set_conv_libfunc (ufix_optab,   SImode, DFmode, "dptoul");
77254219Scy
78254219Scy  set_conv_libfunc (sfloat_optab, SFmode, SImode, "sitofp");
79254219Scy  set_conv_libfunc (sfloat_optab, DFmode, SImode, "litodp");
80254219Scy#endif
81254219Scy}
82254219Scy