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