1# Copyright (C) 2014-2020 Free Software Foundation, Inc. 2 3# This file is part of GCC. 4 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. 9 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. 14 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/>. 18 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. 23# 24# The following variables should be set up before including this file: 25# 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 35# 36# If some functions that would otherwise be defined should not be 37# defined by this file (typically because the target would compile 38# certain operations into a call to the libgcc function, which thus 39# needs to be defined elsewhere to use software floating point), also 40# define hardfp_exclusions to be a list of those functions, 41# e.g. unorddf2. 42 43# Functions parameterized by a floating-point mode M. 44hardfp_func_bases := addM3 subM3 negM2 mulM3 divM3 45hardfp_func_bases += eqM2 neM2 geM2 gtM2 leM2 ltM2 unordM2 46 47# Functions parameterized by both a floating-point mode M and an integer mode N. 48hardfp_int_func_bases := fixMN floatNM floatunNM 49hardfp_func_bases += $(foreach n, $(hardfp_int_modes), \ 50 $(subst N,$(n),$(hardfp_int_func_bases))) 51 52# Get the full list of functions. 53hardfp_func_list := $(foreach m, $(hardfp_float_modes), \ 54 $(subst M,$(m),$(hardfp_func_bases))) 55hardfp_func_list += $(foreach pair, $(hardfp_extensions), \ 56 $(subst M,$(pair),extendM2)) 57hardfp_func_list += $(foreach pair, $(hardfp_truncations), \ 58 $(subst M,$(pair),truncM2)) 59 60hardfp_func_list := $(filter-out $(hardfp_exclusions),$(hardfp_func_list)) 61 62# Regexp for matching a floating-point mode. 63hardfp_mode_regexp := $(shell echo $(hardfp_float_modes) | sed 's/ /\\|/g') 64 65# Regexp for matching the end of a function name, after the last 66# floating-point mode. 67hardfp_suffix_regexp := $(shell echo $(hardfp_int_modes) 2 3 | sed 's/ /\\|/g') 68 69# Add -D options to define: 70# FUNC: the function name (e.g. __addsf3) 71# OP: the function name without the leading __ and with the last 72# floating-point mode removed (e.g. add3) 73# TYPE: the last floating-point mode (e.g. sf) 74hardfp_defines_for = \ 75 $(shell echo $1 | \ 76 sed 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/') 77 78hardfp-o = $(patsubst %,%$(objext),$(hardfp_func_list)) 79$(hardfp-o): %$(objext): $(srcdir)/config/hardfp.c 80 @echo "Mode = $(hardfp_mode_regexp)" 81 @echo "Suffix = $(hardfp_suffix_regexp)" 82 $(gcc_compile) $(call hardfp_defines_for, $*) -c $< $(vis_hide) -Wno-missing-prototypes 83libgcc-objects += $(hardfp-o) 84 85ifeq ($(enable_shared),yes) 86hardfp-s-o = $(patsubst %,%_s$(objext),$(hardfp_func_list)) 87$(hardfp-s-o): %_s$(objext): $(srcdir)/config/hardfp.c 88 $(gcc_s_compile) $(call hardfp_defines_for, $*) -c $< -Wno-missing-prototypes 89libgcc-s-objects += $(hardfp-s-o) 90endif 91