1169689Skan# Copyright (C) 2006 Free Software Foundation, Inc.
2169689Skan
3169689Skan# This file is part of GCC.
4169689Skan
5169689Skan# GCC is free software; you can redistribute it and/or modify
6169689Skan# it under the terms of the GNU General Public License as published by
7169689Skan# the Free Software Foundation; either version 2, or (at your option)
8169689Skan# any later version.
9169689Skan
10169689Skan# GCC is distributed in the hope that it will be useful,
11169689Skan# but WITHOUT ANY WARRANTY; without even the implied warranty of
12169689Skan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13169689Skan# GNU General Public License for more details.
14169689Skan
15169689Skan# You should have received a copy of the GNU General Public License
16169689Skan# along with GCC; see the file COPYING.  If not, write to
17169689Skan# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
18169689Skan# Boston MA 02110-1301, USA.
19169689Skan
20169689Skan# Targets using soft-fp should define the following variables:
21169689Skan#
22169689Skan# softfp_float_modes: a list of soft-float floating-point modes,
23169689Skan#                     e.g. sf df
24169689Skan# softfp_int_modes: a list of integer modes for which to define conversions,
25169689Skan#                   e.g. si di
26169689Skan# softfp_extensions: a list of extensions between floating-point modes,
27169689Skan#                    e.g. sfdf
28169689Skan# softfp_truncations: a list of truncations between floating-point modes,
29169689Skan#                     e.g. dfsf
30169689Skan# softfp_machine_header: the target sfp-machine.h file (relative to config/),
31169689Skan#                        e.g. rs6000/sfp-machine.h
32169689Skan#
33169689Skan# Extensions and truncations should include those where only one mode
34169689Skan# is a soft-float mode; for example, sftf where sf is hard-float and
35169689Skan# tf is soft-float.
36169689Skan#
37169689Skan# If the libgcc2.c functions should not be replaced, also define:
38169689Skan#
39169689Skan# softfp_exclude_libgcc2 := y
40169689Skan#
41169689Skan# Avoiding replacing the libgcc2.c functions is a temporary measure
42169689Skan# for targets with both hard-float and soft-float multilibs, since
43169689Skan# these variables apply for all multilibs.  With toplevel libgcc,
44169689Skan# soft-fp can be used conditionally on the multilib instead.
45169689Skan#
46169689Skan# If the code should not be compiled at all for some multilibs, define:
47169689Skan#
48169689Skan# softfp_wrap_start: text to put at the start of wrapper source files,
49169689Skan#                    output with echo
50169689Skan#                    e.g. '#ifndef __powerpc64__'
51169689Skan# softfp_wrap_end: text to put at the end of wrapper source files,
52169689Skan#                  e.g. '#endif'
53169689Skan#
54169689Skan# This is another temporary measure.
55169689Skan
56169689Skansoftfp_float_funcs = add$(m)3 div$(m)3 eq$(m)2 ge$(m)2 le$(m)2 mul$(m)3 \
57169689Skan  neg$(m)2 sub$(m)3 unord$(m)2
58169689Skansoftfp_floatint_funcs = fix$(m)$(i) fixuns$(m)$(i) \
59169689Skan  float$(i)$(m) floatun$(i)$(m)
60169689Skan
61169689Skansoftfp_func_list := \
62169689Skan  $(foreach m,$(softfp_float_modes), \
63169689Skan              $(softfp_float_funcs) \
64169689Skan              $(foreach i,$(softfp_int_modes), \
65169689Skan                          $(softfp_floatint_funcs))) \
66169689Skan  $(foreach e,$(softfp_extensions),extend$(e)2) \
67169689Skan  $(foreach t,$(softfp_truncations),trunc$(t)2)
68169689Skan
69169689Skanifeq ($(softfp_exclude_libgcc2),y)
70169689Skan# This list is taken from mklibgcc.in and doesn't presently allow for
71169689Skan# 64-bit targets where si should become di and di should become ti.
72169689Skansoftfp_func_list := $(filter-out floatdidf floatdisf fixunsdfsi fixunssfsi \
73169689Skan  fixunsdfdi fixdfdi fixunssfdi fixsfdi fixxfdi fixunsxfdi \
74169689Skan  floatdixf fixunsxfsi fixtfdi fixunstfdi floatditf \
75169689Skan  floatundidf floatundisf floatundixf floatunditf,$(softfp_func_list))
76169689Skanendif
77169689Skan
78169689Skanifeq ($(softfp_wrap_start),)
79169689Skansoftfp_file_list := \
80169689Skan  $(addsuffix .c,$(addprefix $(srcdir)/config/soft-fp/,$(softfp_func_list)))
81169689Skanelse
82169689Skansoftfp_file_list := $(addsuffix .c,$(softfp_func_list))
83169689Skan
84169689Skan$(softfp_file_list):
85169689Skan	echo $(softfp_wrap_start) > $@
86169689Skan	echo '#include "config/soft-fp/$@"' >> $@
87169689Skan	echo $(softfp_wrap_end) >> $@
88169689Skanendif
89169689Skan
90169689SkanLIB2FUNCS_EXTRA += $(softfp_file_list)
91169689Skan
92169689Skanifneq ($(softfp_exclude_libgcc2),y)
93169689Skan# Functions in libgcc2.c are excluded for each soft-float mode (a
94169689Skan# target may have both soft-float and hard-float modes), for the fixed
95169689Skan# list of integer modes (si and di) for which libgcc2.c defines any
96169689Skan# such functions.  Depending on the target, the si and di symbols may
97169689Skan# in fact define di and ti functions.
98169689Skan
99169689SkanLIB2FUNCS_EXCLUDE += \
100169689Skan  $(addprefix _,$(foreach m,$(softfp_float_modes), \
101169689Skan                            $(foreach i,si di, \
102169689Skan                                        $(softfp_floatint_funcs))))
103169689Skanendif
104169689Skan
105169689SkanSFP_MACHINE := sfp-machine.h
106169689Skan
107169689Skan$(SFP_MACHINE): $(srcdir)/config/$(softfp_machine_header)
108169689Skan	cp $(srcdir)/config/$(softfp_machine_header) $(SFP_MACHINE)
109