public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR33396 - add --enable-intermodule for libgcc
@ 2007-11-19 23:10 Bernhard Fischer
  2007-11-20 16:05 ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Bernhard Fischer @ 2007-11-19 23:10 UTC (permalink / raw)
  To: gcc-patches; +Cc: ian, rep.dot.nop

[-- Attachment #1: Type: text/plain, Size: 871 bytes --]

:ADDPATCH libgcc:

Hi,

The attached patch adds an optional IMA mode to libgcc's configury as
per PR33396. Included are some small fixes exposed by IMA. A few warnings
exposed by it are left unfixed for now, help on those is very welcome.
It is currently regtesting on i686-linux-gnu.

Ok for trunk when regtesting passes fine?

thanks,

libgcc/ChangeLog:
2007-11-19  Bernhard Fischer  <>

        * configure.ac: Add option --enable-intermodule for onestep
        compile.
        * Makefile.in: Use onestep.

gcc/ChangeLog:
2007-11-19  Bernhard Fischer  <>

        * gbl-ctors.h: Add header guard.
        * libgcc2.c: Avoid redefinition of FUNC, use FUNCU for
        __floatundi?f
        * config/libbid/bid64_div.c: Extern decls of
        __bid_{convert_table,factors,packed_10000_zeros} have to be const.
        * libgcc/config/libbid/bid128_div.c: Likewise.


[-- Attachment #2: gcc-4.3-libgcc-enable-intermodule.02.diff --]
[-- Type: text/x-diff, Size: 11097 bytes --]

Index: gcc-4.3/libgcc/Makefile.in
===================================================================
--- gcc-4.3/libgcc/Makefile.in	(revision 130291)
+++ gcc-4.3/libgcc/Makefile.in	(working copy)
@@ -326,8 +326,27 @@
 		       $(LIB2_DIVMOD_FUNCS))
 
 # Build "libgcc1" (assembly) components.
+
+lib1asmfuncs-onestep-sources += $(gcc_srcdir)/config/$(LIB1ASMSRC)
+lib1asmfuncs-onestep-defines += $(patsubst %,-DL%,$(LIB1ASMFUNCS))
+libgcc-objects-onestep += $(if $(LIB1ASMSRC),lib1asmfuncs_onestep.o)
+
 ifeq ($(enable_shared),yes)
 
+libgcc-objects-onestep += $(if $(LIB1ASMSRC),lib1asmfuncs_s_onestep.o)
+#libgcc-objects-onestep += $(lib1asmfuncs-o) $(lib1asmfuncs-s-o)
+
+lib1asmfuncs-onestep-prereq += $(patsubst %,%.vis,$(LIB1ASMFUNCS))
+
+lib1asmfuncs_onestep.o: $(lib1asmfuncs-onestep-sources) \
+			$(lib1asmfuncs-onestep-prereq)
+	$(gcc_compile) $(lib1asmfuncs-onestep-defines) -xassembler-with-cpp \
+	  -c $(gcc_srcdir)/config/$(LIB1ASMSRC) \
+	  $(patsubst %,-include %,$(lib1asmfuncs-onestep-prereq)) -combine
+lib1asmfuncs_s_onestep.o: $(lib1asmfuncs-onestep-sources)
+	$(gcc_s_compile) $(lib1asmfuncs-onestep-defines) -xassembler-with-cpp \
+	  -c $(gcc_srcdir)/config/$(LIB1ASMSRC) -combine
+
 lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS))
 $(lib1asmfuncs-o): %$(objext): $(gcc_srcdir)/config/$(LIB1ASMSRC) %.vis
 	$(gcc_compile) -DL$* -xassembler-with-cpp \
@@ -344,6 +363,11 @@
 
 else
 
+#libgcc-objects-onestep += $(lib1asmfuncs-o)
+lib1asmfuncs_onestep.o: $(lib1asmfuncs-onestep-sources)
+	$(gcc_compile) $(lib1asmfuncs-onestep-defines) -xassembler-with-cpp \
+	  -c $(gcc_srcdir)/config/$(LIB1ASMSRC) -combine
+
 lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS))
 $(lib1asmfuncs-o): %$(objext): $(gcc_srcdir)/config/$(LIB1ASMSRC)
 	$(gcc_compile) -DL$* -xassembler-with-cpp \
@@ -358,6 +382,8 @@
 	$(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c \
 	  $(vis_hide)
 libgcc-objects += $(lib2funcs-o)
+libgcc-onestep-sources += $(gcc_srcdir)/libgcc2.c
+libgcc-onestep-defines += $(patsubst %,-DL%,$(lib2funcs) $(LIB2FUNCS_ST))
 
 ifeq ($(enable_shared),yes)
 lib2funcs-s-o = $(patsubst %,%_s$(objext),$(lib2funcs))
@@ -394,6 +420,8 @@
 	$(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c \
 	  -fexceptions -fnon-call-exceptions $(vis_hide)
 libgcc-objects += $(lib2-divmod-o)
+libgcc-onestep-sources += $(gcc_srcdir)/libgcc2.c
+libgcc-onestep-defines += $(patsubst %,-DL%,$(LIB2_DIVMOD_FUNCS))
 
 ifeq ($(enable_shared),yes)
 lib2-divmod-s-o = $(patsubst %,%_s$(objext),$(LIB2_DIVMOD_FUNCS))
@@ -426,6 +454,8 @@
 $(fpbit-o): %$(objext): $(FPBIT)
 	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(FPBIT) $(vis_hide)
 libgcc-objects += $(fpbit-o)
+libgcc-onestep-sources += $(FPBIT)
+libgcc-onestep-defines += $(patsubst %,-DL%,$(FPBIT_FUNCS))
 
 ifeq ($(enable_shared),yes)
 fpbit-s-o = $(patsubst %,%_s$(objext),$(FPBIT_FUNCS))
@@ -441,6 +471,8 @@
 $(dpbit-o): %$(objext): $(DPBIT)
 	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(DPBIT) $(vis_hide)
 libgcc-objects += $(dpbit-o)
+libgcc-onestep-sources += $(DPBIT)
+libgcc-onestep-defines += $(patsubst %,-DL%,$(DPBIT_FUNCS))
 
 ifeq ($(enable_shared),yes)
 dpbit-s-o = $(patsubst %,%_s$(objext),$(DPBIT_FUNCS))
@@ -456,6 +488,8 @@
 $(tpbit-o): %$(objext): $(TPBIT)
 	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -c $(TPBIT) $(vis_hide)
 libgcc-objects += $(tpbit-o)
+libgcc-onestep-sources += $(TPBIT)
+libgcc-onestep-defines += $(patsubst %,-DL%,$(TPBIT_FUNCS))
 
 ifeq ($(enable_shared),yes)
 tpbit-s-o = $(patsubst %,%_s$(objext),$(TPBIT_FUNCS))
@@ -496,8 +530,10 @@
 
 dfp-objects = $(patsubst %,%$(objext),$(dfp-filenames))
 ifeq ($(enable_decimal_float),bid)
+libgcc-onestep-sources += $(patsubst %,$(srcdir)/config/libbid/%.c,$(dfp-filenames))
 $(dfp-objects): %$(objext): $(srcdir)/config/libbid/%.c
 else
+libgcc-onestep-sources += $(patsubst %,$(srcdir)/../libdecnumber/%.c,$(dfp-filenames))
 $(dfp-objects): %$(objext): $(srcdir)/../libdecnumber/%.c
 endif
 	$(gcc_compile) -c $<
@@ -520,8 +556,10 @@
 
 decbits-objects = $(patsubst %,%$(objext),$(decbits-filenames))
 ifeq ($(enable_decimal_float),bid)
+libgcc-onestep-sources += $(patsubst %,$(srcdir)/config/libbid/%.c,$(decbits-filenames))
 $(decbits-objects): %$(objext): $(srcdir)/config/libbid/%.c
 else
+libgcc-onestep-sources += $(patsubst %,$(srcdir)/../libdecnumber/$(enable_decimal_float)/%.c,$(decbits-filenames))
 $(decbits-objects): %$(objext): $(srcdir)/../libdecnumber/$(enable_decimal_float)/%.c
 endif
 	$(gcc_compile) -c $<
@@ -543,36 +581,49 @@
 endif
 
 ifneq ($(D32PBIT),)
+libgcc-objects-onestep += libgcc_32_onestep.o
 d32pbit-o = $(patsubst %,%$(objext),$(D32PBIT_FUNCS))
 ifeq ($(enable_decimal_float),bid)
+libgcc-32-onestep-sources += $(patsubst %,$(srcdir)/config/libbid/%.c,$(D32PBIT_FUNCS))
 $(d32pbit-o): %$(objext): $(srcdir)/config/libbid/%.c
 else
+libgcc-32-onestep-sources += $(gcc_srcdir)/config/dfp-bit.c
 $(d32pbit-o): %$(objext): $(gcc_srcdir)/config/dfp-bit.c
 endif
 	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=32 -c $<
 libgcc-objects += $(d32pbit-o)
+libgcc-32-onestep-defines += $(patsubst %,-DL%,$(D32PBIT_FUNCS)) -DWIDTH=32
 endif
 
 ifneq ($(D64PBIT),)
+libgcc-objects-onestep += libgcc_64_onestep.o
 d64pbit-o = $(patsubst %,%$(objext),$(D64PBIT_FUNCS))
 ifeq ($(enable_decimal_float),bid)
+libgcc-64-onestep-sources += $(patsubst %,$(srcdir)/config/libbid/%.c,$(D64PBIT_FUNCS))
 $(d64pbit-o): %$(objext): $(srcdir)/config/libbid/%.c
 else
+libgcc-64-onestep-sources += $(gcc_srcdir)/config/dfp-bit.c
 $(d64pbit-o): %$(objext): $(gcc_srcdir)/config/dfp-bit.c
+
 endif
 	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=64 -c $<
 libgcc-objects += $(d64pbit-o)
+libgcc-64-onestep-defines += $(patsubst %,-DL%,$(D64PBIT_FUNCS)) -DWIDTH=64
 endif
 
 ifneq ($(D128PBIT),)
+libgcc-objects-onestep += libgcc_128_onestep.o
 d128pbit-o = $(patsubst %,%$(objext),$(D128PBIT_FUNCS))
 ifeq ($(enable_decimal_float),bid)
+libgcc-128-onestep-sources += $(patsubst %,$(srcdir)/config/libbid/%.c,$(D128PBIT_FUNCS))
 $(d128pbit-o): %$(objext): $(srcdir)/config/libbid/%.c
 else
+libgcc-128-onestep-sources += $(gcc_srcdir)/config/dfp-bit.c
 $(d128pbit-o): %$(objext): $(gcc_srcdir)/config/dfp-bit.c
 endif
 	$(gcc_compile) -DFINE_GRAINED_LIBRARIES -DL$* -DWIDTH=128 -c $<
 libgcc-objects += $(d128pbit-o)
+libgcc-128-onestep-defines += $(patsubst %,-DL%,$(D128PBIT_FUNCS)) -DWIDTH=128
 endif
 
 endif
@@ -623,7 +674,9 @@
 ifneq ($(filter-out %.c %.S %.asm,$(LIB2ADD) $(LIB2ADD_ST)),)
 $(error Unsupported files in LIB2ADD or LIB2ADD_ST.)
 endif
-
+ifneq (@onestep@,)
+libgcc-objects:=# reset, empty
+endif
 libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD))))
 libgcc-objects += $(addsuffix $(objext),$(basename $(notdir $(LIB2ADD_ST))))
 
@@ -678,8 +731,29 @@
 	$(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcov.c
 
 
+libgcc-objects-onestep += libgcc_onestep.o
+ifneq (@onestep@,)
+# add the rest
+libgcc-objects-onestep += $(libgcc-objects)
+endif
+
+libgcc_onestep.o: $(libgcc-onestep-sources)
+	$(gcc_compile) $^ $(libgcc-onestep-defines) \
+		-DFINE_GRAINED_LIBRARIES $(vis_hide) -c -combine 
+
+libgcc_32_onestep.o: $(libgcc-32-onestep-sources)
+	$(gcc_compile) $^ $(libgcc-32-onestep-defines) \
+		-DFINE_GRAINED_LIBRARIES -c -combine
+libgcc_64_onestep.o: $(libgcc-64-onestep-sources)
+	$(gcc_compile) $^ $(libgcc-64-onestep-defines) \
+		-DFINE_GRAINED_LIBRARIES -c -combine
+libgcc_128_onestep.o: $(libgcc-128-onestep-sources)
+	$(gcc_compile) $^ $(libgcc-128-onestep-defines) \
+		-DFINE_GRAINED_LIBRARIES -c -combine
+
+
 # Static libraries.
-libgcc.a: $(libgcc-objects)
+libgcc.a: $(libgcc-objects@onestep@)
 libgcov.a: $(libgcov-objects)
 libunwind.a: $(libunwind-objects)
 libgcc_eh.a: $(libgcc-eh-objects)
Index: gcc-4.3/libgcc/configure.ac
===================================================================
--- gcc-4.3/libgcc/configure.ac	(revision 130291)
+++ gcc-4.3/libgcc/configure.ac	(working copy)
@@ -77,6 +77,18 @@
 fi)
 AC_SUBST(slibdir)
 
+# Build with intermodule optimisations
+AC_MSG_CHECKING([for --enable-intermodule])
+AC_ARG_ENABLE(intermodule,
+[  --enable-intermodule    build the library in one step],
+[case "$enable_intermodule" in
+  yes) onestep="-onestep";;
+    *) onestep="";;
+esac],
+[onestep=""])
+AC_MSG_RESULT($enable_intermodule)
+AC_SUBST(onestep)
+
 AC_PROG_INSTALL
 
 AC_PROG_AWK
Index: gcc-4.3/libgcc/config/libbid/bid128_div.c
===================================================================
--- gcc-4.3/libgcc/config/libbid/bid128_div.c	(revision 130291)
+++ gcc-4.3/libgcc/config/libbid/bid128_div.c	(working copy)
@@ -34,9 +34,9 @@
 #define FE_ALL_FLAGS FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT
 #endif
 
-extern UINT32 convert_table[5][128][2];
-extern SINT8 factors[][2];
-extern UINT8 packed_10000_zeros[];
+extern const UINT32 convert_table[5][128][2];
+extern const SINT8 factors[][2];
+extern const UINT8 packed_10000_zeros[];
 
 BID128_FUNCTION_ARG2 (bid128_div, x, y)
 
Index: gcc-4.3/libgcc/config/libbid/bid64_div.c
===================================================================
--- gcc-4.3/libgcc/config/libbid/bid64_div.c	(revision 130291)
+++ gcc-4.3/libgcc/config/libbid/bid64_div.c	(working copy)
@@ -66,9 +66,9 @@
 #define FE_ALL_FLAGS FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT
 #endif
 
-extern UINT32 convert_table[5][128][2];
-extern SINT8 factors[][2];
-extern UINT8 packed_10000_zeros[];
+extern const UINT32 convert_table[5][128][2];
+extern const SINT8 factors[][2];
+extern const UINT8 packed_10000_zeros[];
 
 
 #if DECIMAL_CALL_BY_REFERENCE
@@ -1366,11 +1366,6 @@
 
 //#define LEAVE_TRAILING_ZEROS
 
-extern UINT32 convert_table[5][128][2];
-extern SINT8 factors[][2];
-extern UINT8 packed_10000_zeros[];
-
-
 //UINT64* bid64_div128x128(UINT64 res, UINT128 *px, UINT128 *py, unsigned rnd_mode, unsigned *pfpsf) 
 
 TYPE0_FUNCTION_ARG128_ARG128 (UINT64, bid64qq_div, x, y)
Index: gcc-4.3/gcc/gbl-ctors.h
===================================================================
--- gcc-4.3/gcc/gbl-ctors.h	(revision 130291)
+++ gcc-4.3/gcc/gbl-ctors.h	(working copy)
@@ -38,6 +38,8 @@
 	Note that this file should only be compiled with GCC.
 */
 
+#ifndef GCC_GBL_CTORS_H
+#define GCC_GBL_CTORS_H
 /*  Declare a pointer to void function type.  */
 
 typedef void (*func_ptr) (void);
@@ -84,3 +86,4 @@
 } while (0)
 #endif
 
+#endif /* GCC_GBL_CTORS_H */
Index: gcc-4.3/gcc/libgcc2.c
===================================================================
--- gcc-4.3/gcc/libgcc2.c	(revision 130291)
+++ gcc-4.3/gcc/libgcc2.c	(working copy)
@@ -1538,17 +1538,17 @@
    && SIZE > (DI_SIZE - SIZE + FSSIZE)					\
    && !AVOID_FP_TYPE_CONVERSION(SIZE))
 #if defined(L_floatundisf)
-#define FUNC __floatundisf
+#define FUNCU __floatundisf
 #define FSTYPE SFtype
 #define FSSIZE SF_SIZE
 #else
-#define FUNC __floatundidf
+#define FUNCU __floatundidf
 #define FSTYPE DFtype
 #define FSSIZE DF_SIZE
 #endif
 
 FSTYPE
-FUNC (UDWtype u)
+FUNCU (UDWtype u)
 {
 #if FSSIZE >= W_TYPE_SIZE
   /* When the word size is small, we never get any rounding error.  */

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PR33396 - add --enable-intermodule for libgcc
  2007-11-19 23:10 [PATCH] PR33396 - add --enable-intermodule for libgcc Bernhard Fischer
@ 2007-11-20 16:05 ` Paolo Bonzini
       [not found]   ` <20071121153910.GA2187@aon.at>
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2007-11-20 16:05 UTC (permalink / raw)
  To: GCC Patches, Bernhard Fischer

Bernhard Fischer wrote:
> :ADDPATCH libgcc:
> 
> Hi,
> 
> The attached patch adds an optional IMA mode to libgcc's configury as
> per PR33396. Included are some small fixes exposed by IMA. A few warnings
> exposed by it are left unfixed for now, help on those is very welcome.
> It is currently regtesting on i686-linux-gnu.

Nice work, but I want to be sure I understand it well before approving
the build parts (the others are pretty obvious but I cannot approve them).

First, here you have this:

>  libgcc-objects += $(lib2funcs-o)
> +libgcc-onestep-sources += $(gcc_srcdir)/libgcc2.c

and later on, this:

> +ifneq (@onestep@,)
> +# add the rest
> +libgcc-objects-onestep += $(libgcc-objects)
> +endif

Does this mean that everything is included twice in libgcc?  Also, isn't
the ifneq redundant?  libgcc-objects-onestep should be unused if
@onestep@ is empty.


I am not sure what happens if you pass combine for many assembly source
codes, as in this:

> +lib1asmfuncs_onestep.o: $(lib1asmfuncs-onestep-sources) \
> +			$(lib1asmfuncs-onestep-prereq)
> +	$(gcc_compile) $(lib1asmfuncs-onestep-defines) -xassembler-with-cpp \
> +	  -c $(gcc_srcdir)/config/$(LIB1ASMSRC) \
> +	  $(patsubst %,-include %,$(lib1asmfuncs-onestep-prereq)) -combine

Also, why are these commented?

> +#libgcc-objects-onestep += $(lib1asmfuncs-o)

Thanks for your work,

Paolo


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PR33396 - add --enable-intermodule for libgcc
       [not found]   ` <20071121153910.GA2187@aon.at>
@ 2007-11-21 18:28     ` Paolo Bonzini
  2008-01-24 17:50       ` Bernhard Fischer
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2007-11-21 18:28 UTC (permalink / raw)
  To: Bernhard Fischer, GCC Patches


>> I am not sure what happens if you pass combine for many assembly source
>> codes, as in this:
> 
> I only checked on i386 (which doesn't seem to have any LIB1ASMFUNCS),
> but i guess it should work fine.

You can try it on the command line, using -### to see what is passed 
actually to gas and ld.

> Looks like it would be the least intrusive approach to add
> libgcc/*-obj*-onestep.mk that mimmic the normal *-obj*.mk
> Alternatively i'd have to add 'ifneq ($(onestep),)' to the iterator *.mk.
> What do you think?

I suggest you try both on one iterator makefile, and see what looks nicer.

Thanks!

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PR33396 - add --enable-intermodule for libgcc
  2007-11-21 18:28     ` Paolo Bonzini
@ 2008-01-24 17:50       ` Bernhard Fischer
  0 siblings, 0 replies; 4+ messages in thread
From: Bernhard Fischer @ 2008-01-24 17:50 UTC (permalink / raw)
  To: bonzini; +Cc: GCC Patches

On Wed, Nov 21, 2007 at 04:48:49PM +0100, Paolo Bonzini wrote:
>
>>> I am not sure what happens if you pass combine for many assembly source
>>> codes, as in this:
>>
>> I only checked on i386 (which doesn't seem to have any LIB1ASMFUNCS),
>> but i guess it should work fine.
>
> You can try it on the command line, using -### to see what is passed 
> actually to gas and ld.
>
>> Looks like it would be the least intrusive approach to add
>> libgcc/*-obj*-onestep.mk that mimmic the normal *-obj*.mk
>> Alternatively i'd have to add 'ifneq ($(onestep),)' to the iterator *.mk.
>> What do you think?
>
> I suggest you try both on one iterator makefile, and see what looks nicer.

This is still not yet done, fwiw.

I have updated the generic libgcc part against trunk and have added it
to the PR. My last comment shows some statistics about the size-savings
i got from building libgcc with -combine -- about 70% smaller.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-01-24 16:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-19 23:10 [PATCH] PR33396 - add --enable-intermodule for libgcc Bernhard Fischer
2007-11-20 16:05 ` Paolo Bonzini
     [not found]   ` <20071121153910.GA2187@aon.at>
2007-11-21 18:28     ` Paolo Bonzini
2008-01-24 17:50       ` Bernhard Fischer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).