t-hardfp 3.9 KB

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