diff mbox

ARM fixed-point support [4/6]: allow overriding of fixed-point helper function names

Message ID 20110513145800.447aee1f@rex.config
State New
Headers show

Commit Message

Julian Brown May 13, 2011, 1:58 p.m. UTC
This patch allows the decoration of helper function names for
fixed-point support to be changed from the default "__foo" to a
different scheme, as required by the ARM EABI (these are
"vendor-specific" helpers, so should go in a particular namespace).
These are only the machine-independent changes: the ARM-specific bits
come later.

Tested alongside other patches in the series. OK to apply?

Julian

ChangeLog

    gcc/
    * config/fixed-bit.h (fixed-bit-machine.h): Include.
    (DECORATE_FIXED_NAME): Conditionally define if undefined. Use
    throughout file to decorate function names.
    * config/fixed-bit-mach-generic.h: New.

    libgcc/
    * Makefile.in (FIXED_BIT_MACHINE): New rule. Include
    target-specific or generic fixed_bit_machine_header to decorate the
    names of fixed-point helper functions.
    * fixed-obj.mk ($(o)_s$(objext)): Depend on $(FIXED_BIT_MACHINE).

Comments

Richard Earnshaw June 30, 2011, 1:26 p.m. UTC | #1
On 13/05/11 14:58, Julian Brown wrote:
> This patch allows the decoration of helper function names for
> fixed-point support to be changed from the default "__foo" to a
> different scheme, as required by the ARM EABI (these are
> "vendor-specific" helpers, so should go in a particular namespace).
> These are only the machine-independent changes: the ARM-specific bits
> come later.
> 
> Tested alongside other patches in the series. OK to apply?
> 
> Julian
> 
> ChangeLog
> 
>     gcc/
>     * config/fixed-bit.h (fixed-bit-machine.h): Include.
>     (DECORATE_FIXED_NAME): Conditionally define if undefined. Use
>     throughout file to decorate function names.
>     * config/fixed-bit-mach-generic.h: New.
> 
>     libgcc/
>     * Makefile.in (FIXED_BIT_MACHINE): New rule. Include
>     target-specific or generic fixed_bit_machine_header to decorate the
>     names of fixed-point helper functions.
>     * fixed-obj.mk ($(o)_s$(objext)): Depend on $(FIXED_BIT_MACHINE).
> 
> 

OK.

R.
Bernd Schmidt June 30, 2011, 1:47 p.m. UTC | #2
On 05/13/11 15:58, Julian Brown wrote:
> This patch allows the decoration of helper function names for
> fixed-point support to be changed from the default "__foo" to a
> different scheme, as required by the ARM EABI (these are
> "vendor-specific" helpers, so should go in a particular namespace).
> These are only the machine-independent changes: the ARM-specific bits
> come later.

I think you'll find that this no longer applies. However, there's
support for renaming these to __gnu_foo, and looking at your patch 6/6
that's exactly what you need? You'll probably have to change the
granularity so that a target can choose to apply it only to the
fixed-point functions.


Bernd
diff mbox

Patch

commit 3a3866071a8525ef21ffd66119419a4239797f8a
Author: Julian Brown <julian@henry8.codesourcery.com>
Date:   Fri May 13 05:51:54 2011 -0700

    Machine-independent configuration changes for ARM fixed-point support

diff --git a/gcc/config/fixed-bit-mach-generic.h b/gcc/config/fixed-bit-mach-generic.h
new file mode 100644
index 0000000..8bfbf53
--- /dev/null
+++ b/gcc/config/fixed-bit-mach-generic.h
@@ -0,0 +1,23 @@ 
+/* Null machine-specific override for fixed-point support routine names.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
diff --git a/gcc/config/fixed-bit.h b/gcc/config/fixed-bit.h
index 562772d..1cce4ef 100644
--- a/gcc/config/fixed-bit.h
+++ b/gcc/config/fixed-bit.h
@@ -25,6 +25,13 @@  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #ifndef _FIXED_BIT_H
 #define _FIXED_BIT_H
 
+#include "fixed-bit-machine.h"
+
+/* This macro may be overridden for a given target in fixed-bit-machine.h.  */
+#ifndef DECORATE_FIXED_NAME
+#define DECORATE_FIXED_NAME(X) __ ## X
+#endif
+
 /* To use this file we need to define one of the following:
    QQ_MODE, UQQ_MODE, HQ_MODE, UHQ_MODE, SQ_MODE, USQ_MODE, DQ_MODE, UDQ_MODE,
    TQ_MODE, UTQ_MODE, HA_MODE, UHA_MODE, SA_MODE, USA_MODE, DA_MODE, UDA_MODE,
@@ -445,35 +452,37 @@  typedef union
 #define IBITS		IBITS2(MODE_NAME)
 #define I_F_BITS	(FBITS + IBITS)
 
-#define FIXED_OP(OP,MODE,NUM)	OP ## MODE ## NUM
-
-#define FIXED_SATURATE1_TEMP(NAME)	FIXED_OP(__saturate1,NAME,)
-#define FIXED_SATURATE2_TEMP(NAME)	FIXED_OP(__saturate2,NAME,)
-#define FIXED_MULHELPER_TEMP(NAME)	FIXED_OP(__mulhelper,NAME,)
-#define FIXED_DIVHELPER_TEMP(NAME)	FIXED_OP(__divhelper,NAME,)
-#define FIXED_ASHLHELPER_TEMP(NAME)	FIXED_OP(__ashlhelper,NAME,)
-#define FIXED_ADD_TEMP(NAME)	FIXED_OP(__add,NAME,3)
-#define FIXED_SSADD_TEMP(NAME)	FIXED_OP(__ssadd,NAME,3)
-#define FIXED_USADD_TEMP(NAME)	FIXED_OP(__usadd,NAME,3)
-#define FIXED_SUB_TEMP(NAME)	FIXED_OP(__sub,NAME,3)
-#define FIXED_SSSUB_TEMP(NAME)	FIXED_OP(__sssub,NAME,3)
-#define FIXED_USSUB_TEMP(NAME)	FIXED_OP(__ussub,NAME,3)
-#define FIXED_MUL_TEMP(NAME)	FIXED_OP(__mul,NAME,3)
-#define FIXED_SSMUL_TEMP(NAME)	FIXED_OP(__ssmul,NAME,3)
-#define FIXED_USMUL_TEMP(NAME)	FIXED_OP(__usmul,NAME,3)
-#define FIXED_DIV_TEMP(NAME)	FIXED_OP(__div,NAME,3)
-#define FIXED_UDIV_TEMP(NAME)	FIXED_OP(__udiv,NAME,3)
-#define FIXED_SSDIV_TEMP(NAME)	FIXED_OP(__ssdiv,NAME,3)
-#define FIXED_USDIV_TEMP(NAME)	FIXED_OP(__usdiv,NAME,3)
-#define FIXED_NEG_TEMP(NAME)	FIXED_OP(__neg,NAME,2)
-#define FIXED_SSNEG_TEMP(NAME)	FIXED_OP(__ssneg,NAME,2)
-#define FIXED_USNEG_TEMP(NAME)	FIXED_OP(__usneg,NAME,2)
-#define FIXED_ASHL_TEMP(NAME)	FIXED_OP(__ashl,NAME,3)
-#define FIXED_ASHR_TEMP(NAME)	FIXED_OP(__ashr,NAME,3)
-#define FIXED_LSHR_TEMP(NAME)	FIXED_OP(__lshr,NAME,3)
-#define FIXED_SSASHL_TEMP(NAME)	FIXED_OP(__ssashl,NAME,3)
-#define FIXED_USASHL_TEMP(NAME)	FIXED_OP(__usashl,NAME,3)
-#define FIXED_CMP_TEMP(NAME)	FIXED_OP(__cmp,NAME,2)
+#define FIXED_OP3(OP,MODE,NUM)	OP ## MODE ## NUM
+#define FIXED_OP2(OP,MODE,NUM)	FIXED_OP3 (OP, MODE, NUM)
+#define FIXED_OP(OP,MODE,NUM)	FIXED_OP2 (DECORATE_FIXED_NAME (OP), MODE, NUM)
+
+#define FIXED_SATURATE1_TEMP(NAME)	FIXED_OP(saturate1,NAME,)
+#define FIXED_SATURATE2_TEMP(NAME)	FIXED_OP(saturate2,NAME,)
+#define FIXED_MULHELPER_TEMP(NAME)	FIXED_OP(mulhelper,NAME,)
+#define FIXED_DIVHELPER_TEMP(NAME)	FIXED_OP(divhelper,NAME,)
+#define FIXED_ASHLHELPER_TEMP(NAME)	FIXED_OP(ashlhelper,NAME,)
+#define FIXED_ADD_TEMP(NAME)	FIXED_OP(add,NAME,3)
+#define FIXED_SSADD_TEMP(NAME)	FIXED_OP(ssadd,NAME,3)
+#define FIXED_USADD_TEMP(NAME)	FIXED_OP(usadd,NAME,3)
+#define FIXED_SUB_TEMP(NAME)	FIXED_OP(sub,NAME,3)
+#define FIXED_SSSUB_TEMP(NAME)	FIXED_OP(sssub,NAME,3)
+#define FIXED_USSUB_TEMP(NAME)	FIXED_OP(ussub,NAME,3)
+#define FIXED_MUL_TEMP(NAME)	FIXED_OP(mul,NAME,3)
+#define FIXED_SSMUL_TEMP(NAME)	FIXED_OP(ssmul,NAME,3)
+#define FIXED_USMUL_TEMP(NAME)	FIXED_OP(usmul,NAME,3)
+#define FIXED_DIV_TEMP(NAME)	FIXED_OP(div,NAME,3)
+#define FIXED_UDIV_TEMP(NAME)	FIXED_OP(udiv,NAME,3)
+#define FIXED_SSDIV_TEMP(NAME)	FIXED_OP(ssdiv,NAME,3)
+#define FIXED_USDIV_TEMP(NAME)	FIXED_OP(usdiv,NAME,3)
+#define FIXED_NEG_TEMP(NAME)	FIXED_OP(neg,NAME,2)
+#define FIXED_SSNEG_TEMP(NAME)	FIXED_OP(ssneg,NAME,2)
+#define FIXED_USNEG_TEMP(NAME)	FIXED_OP(usneg,NAME,2)
+#define FIXED_ASHL_TEMP(NAME)	FIXED_OP(ashl,NAME,3)
+#define FIXED_ASHR_TEMP(NAME)	FIXED_OP(ashr,NAME,3)
+#define FIXED_LSHR_TEMP(NAME)	FIXED_OP(lshr,NAME,3)
+#define FIXED_SSASHL_TEMP(NAME)	FIXED_OP(ssashl,NAME,3)
+#define FIXED_USASHL_TEMP(NAME)	FIXED_OP(usashl,NAME,3)
+#define FIXED_CMP_TEMP(NAME)	FIXED_OP(cmp,NAME,2)
 
 #if defined (MODE_NAME)
 #if defined (DINT_C_TYPE)
@@ -1146,14 +1155,22 @@  extern FIXED_C_TYPE FIXED_USASHL (FIXED_C_TYPE, word_type);
 #define TO_HAVE_PADDING_BITS	(TO_PADDING_BITS > 0)
 #endif /* TO_TYPE == 4  */
 
-#define FIXED_CONVERT_OP(OP,FROM,TO)	OP ## FROM ## TO
-#define FIXED_CONVERT_OP2(OP,FROM,TO)	OP ## FROM ## TO ## 2
-#define FRACT_TEMP(N1,N2)		FIXED_CONVERT_OP(__fract,N1,N2)
-#define FRACT2_TEMP(N1,N2)		FIXED_CONVERT_OP2(__fract,N1,N2)
-#define SATFRACT_TEMP(N1,N2)		FIXED_CONVERT_OP(__satfract,N1,N2)
-#define SATFRACT2_TEMP(N1,N2)		FIXED_CONVERT_OP2(__satfract,N1,N2)
-#define FRACTUNS_TEMP(N1,N2)		FIXED_CONVERT_OP(__fractuns,N1,N2)
-#define SATFRACTUNS_TEMP(N1,N2)		FIXED_CONVERT_OP(__satfractuns,N1,N2)
+#define FIXED_CONVERT_OP_B(OP,FROM,TO)	OP ## FROM ## TO
+#define FIXED_CONVERT_OP_A(OP,FROM,TO)	FIXED_CONVERT_OP_B(OP, FROM, TO)
+#define FIXED_CONVERT_OP(OP,FROM,TO) \
+  FIXED_CONVERT_OP_A (DECORATE_FIXED_NAME (OP), FROM, TO)
+
+#define FIXED_CONVERT_OP2_B(OP,FROM,TO)	OP ## FROM ## TO ## 2
+#define FIXED_CONVERT_OP2_A(OP,FROM,TO)	FIXED_CONVERT_OP2_B (OP, FROM, TO)
+#define FIXED_CONVERT_OP2(OP,FROM,TO) \
+  FIXED_CONVERT_OP2_A (DECORATE_FIXED_NAME (OP), FROM, TO)
+
+#define FRACT_TEMP(N1,N2)		FIXED_CONVERT_OP(fract,N1,N2)
+#define FRACT2_TEMP(N1,N2)		FIXED_CONVERT_OP2(fract,N1,N2)
+#define SATFRACT_TEMP(N1,N2)		FIXED_CONVERT_OP(satfract,N1,N2)
+#define SATFRACT2_TEMP(N1,N2)		FIXED_CONVERT_OP2(satfract,N1,N2)
+#define FRACTUNS_TEMP(N1,N2)		FIXED_CONVERT_OP(fractuns,N1,N2)
+#define SATFRACTUNS_TEMP(N1,N2)		FIXED_CONVERT_OP(satfractuns,N1,N2)
 
 /* Define conversions from fixed-point to fixed-point.  */
 #if FROM_TYPE == 4 && TO_TYPE == 4
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index 7e2ab93..5874267 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -647,6 +647,16 @@  endif
 # Build fixed-point support.
 ifeq ($(fixed_point),yes)
 
+FIXED_BIT_MACHINE := fixed-bit-machine.h
+
+# Use default header if a machine-specific one is not defined.
+ifeq ($(fixed_bit_machine_header),)
+fixed_bit_machine_header := fixed-bit-mach-generic.h
+endif
+
+$(FIXED_BIT_MACHINE): $(gcc_srcdir)/config/$(fixed_bit_machine_header)
+	cp $(gcc_srcdir)/config/$(fixed_bit_machine_header) $(FIXED_BIT_MACHINE)
+
 # Generate permutations of function name and mode
 fixed-labels := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith labels)
 fixed-funcs := $(shell $(SHELL) $(srcdir)/gen-fixed.sh arith funcs)
diff --git a/libgcc/fixed-obj.mk b/libgcc/fixed-obj.mk
index 3c7c2f3..1bc8220 100644
--- a/libgcc/fixed-obj.mk
+++ b/libgcc/fixed-obj.mk
@@ -22,10 +22,10 @@  endif
 
 #$(info $o$(objext): -DL$($o-label) $($o-opt))
 
-$o$(objext): %$(objext): $(gcc_srcdir)/config/fixed-bit.c
+$o$(objext): %$(objext): $(gcc_srcdir)/config/fixed-bit.c $(FIXED_BIT_MACHINE)
 	$(gcc_compile) -DL$($*-label) $($*-opt) -c $(gcc_srcdir)/config/fixed-bit.c $(vis_hide)
 
 ifeq ($(enable_shared),yes)
-$(o)_s$(objext): %_s$(objext): $(gcc_srcdir)/config/fixed-bit.c
+$(o)_s$(objext): %_s$(objext): $(gcc_srcdir)/config/fixed-bit.c $(FIXED_BIT_MACHINE)
 	$(gcc_s_compile) -DL$($*-label) $($*-opt) -c $(gcc_srcdir)/config/fixed-bit.c
 endif