--- libgcc/config/t-hardfp.orig	2014-02-07 07:46:34 UTC
+++ libgcc/config/t-hardfp
@@ -50,12 +50,16 @@ hardfp_func_list += $(foreach pair, $(hardfp_extension
 hardfp_func_list += $(foreach pair, $(hardfp_truncations), \
 		    	      $(subst M,$(pair),truncM2))
 
+hardfp_suffixes := $(hardfp_int_modes) 2 3
+
 # Regexp for matching a floating-point mode.
 hardfp_mode_regexp := $(shell echo $(hardfp_float_modes) | sed 's/ /\\|/g')
+hardfp_mode_regexp_awk := $(shell echo $(hardfp_float_modes) | sed 's/ /|/g')
 
 # Regexp for matching the end of a function name, after the last
 # floating-point mode.
-hardfp_suffix_regexp := $(shell echo $(hardfp_int_modes) 2 3 | sed 's/ /\\|/g')
+hardfp_suffix_regexp := $(shell echo $(hardfp_suffixes) | sed 's/ /\\|/g')
+hardfp_suffix_regexp_awk := $(shell echo $(hardfp_suffixes) | sed 's/ /|/g')
 
 # Add -D options to define:
 #   FUNC: the function name (e.g. __addsf3)
@@ -64,12 +68,20 @@ hardfp_suffix_regexp := $(shell echo $(hardfp_int_mode
 #   TYPE: the last floating-point mode (e.g. sf)
 hardfp_defines_for = \
   $(shell echo $1 | \
-    sed 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/')
+    $(AWK) 'BEGIN{split("$(hardfp_mode_regexp_awk)",mode,"|"); \
+                  split("$(hardfp_suffix_regexp_awk)",suffix,"|")} \
+            { sfx=""; for (s in suffix) if (match($$0, suffix[s]"$$")) { sfx=suffix[s]; break; } \
+              o=substr($$0,0,length($$0)-length(sfx)); \
+              for (m in mode) { if (match(o, mode[m]"$$")) { \
+                op=substr(o,0,length(o)-length(mode[m])); \
+                print"-DFUNC=__"$$0" -DOP_" op sfx" -DTYPE="mode[m];exit; }}}')
 
 hardfp-o = $(patsubst %,%$(objext),$(hardfp_func_list))
 $(hardfp-o): %$(objext): $(srcdir)/config/hardfp.c
 	@echo "Mode = $(hardfp_mode_regexp)"
 	@echo "Suffix = $(hardfp_suffix_regexp)"
+	$(info $(call hardfp_defines_for, $*))
+	$(info $$*=$*)
 	$(gcc_compile) $(call hardfp_defines_for, $*) -c $< $(vis_hide) -Wno-missing-prototypes
 libgcc-objects += $(hardfp-o)
 
