gcc/testsuite/
[official-gcc.git] / libgcc / config / t-hardfp
blobfe02f8e3dde9717060ab99b08d2684a1c3d6ff3f
1 # Copyright (C) 2014 Free Software Foundation, Inc.
3 # This file is part of GCC.
5 # GCC is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3, or (at your option)
8 # any later version.
10 # GCC is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with GCC; see the file COPYING3.  If not see
17 # <http://www.gnu.org/licenses/>.
19 # For historical reasons, some targets provide a full set of FP routines
20 # even if there is native hardware support for some of them.  This file
21 # is used to define functions that can be implemented directly in hardware.
22 # For example, an __adddf3 defined by this file will use an FPU addition.
24 # The following variables should be set up before including this file:
26 # hardfp_float_modes: a list of hardware floating-point modes.
27 #                     e.g. sf df
28 # hardfp_int_modes: a list of integer modes for which to define conversions;
29 #                   usually this is "si", since libgcc2.c provides routines
30 #                   for wider modes
31 # hardfp_extensions: a list of extensions between hardware floating-point modes,
32 #                    e.g. sfdf
33 # hardfp_truncations: a list of truncations between hardware floating-point
34 #                     modes, e.g. dfsf
36 # Functions parameterized by a floating-point mode M.
37 hardfp_func_bases := addM3 subM3 negM2 mulM3 divM3
38 hardfp_func_bases += eqM2 neM2 geM2 gtM2 leM2 ltM2 unordM2
40 # Functions parameterized by both a floating-point mode M and an integer mode N.
41 hardfp_int_func_bases := fixMN floatNM floatunNM
42 hardfp_func_bases += $(foreach n, $(hardfp_int_modes), \
43                                $(subst N,$(n),$(hardfp_int_func_bases)))
45 # Get the full list of functions.
46 hardfp_func_list := $(foreach m, $(hardfp_float_modes), \
47                               $(subst M,$(m),$(hardfp_func_bases)))
48 hardfp_func_list += $(foreach pair, $(hardfp_extensions), \
49                               $(subst M,$(pair),extendM2))
50 hardfp_func_list += $(foreach pair, $(hardfp_truncations), \
51                               $(subst M,$(pair),truncM2))
53 # Regexp for matching a floating-point mode.
54 hardfp_mode_regexp := $(shell echo $(hardfp_float_modes) | sed 's/ /\\|/g')
56 # Regexp for matching the end of a function name, after the last
57 # floating-point mode.
58 hardfp_suffix_regexp := $(shell echo $(hardfp_int_modes) 2 3 | sed 's/ /\\|/g')
60 # Add -D options to define:
61 #   FUNC: the function name (e.g. __addsf3)
62 #   OP:   the function name without the leading __ and with the last
63 #            floating-point mode removed (e.g. add3)
64 #   TYPE: the last floating-point mode (e.g. sf)
65 hardfp_defines_for = \
66   $(shell echo $1 | \
67     sed 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/')
69 hardfp-o = $(patsubst %,%$(objext),$(hardfp_func_list))
70 $(hardfp-o): %$(objext): $(srcdir)/config/hardfp.c
71         @echo "Mode = $(hardfp_mode_regexp)"
72         @echo "Suffix = $(hardfp_suffix_regexp)"
73         $(gcc_compile) $(call hardfp_defines_for, $*) -c $< $(vis_hide) -Wno-missing-prototypes
74 libgcc-objects += $(hardfp-o)
76 ifeq ($(enable_shared),yes)
77 hardfp-s-o = $(patsubst %,%_s$(objext),$(hardfp_func_list))
78 $(hardfp-s-o): %_s$(objext): $(srcdir)/config/hardfp.c
79         $(gcc_s_compile) $(call hardfp_defines_for, $*) -c $< -Wno-missing-prototypes
80 libgcc-s-objects += $(hardfp-s-o)
81 endif