This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch to make 'thenan' a shared const variable.


Hi Guys,

  I would like to submit the following patch for approval.  It changes
  libgcc.a so that the function nan() uses a global variable instead
  of a local one.  This saves space in the resulting executable when
  it is running.

  The patch also marks the variable as const so that it will be placed
  in the read only data section instead of the .bss section, and it
  also explicitly initialises it with a class of CLASS_SNAN, rather
  than allowing this to happen by magic (since CLASS_SNAN as an enum
  value of 0).

  One final aspect of the patch is that it creates two versions of the
  variable, one called _thenan_sf which is used by the single precsion
  floating point routines and one called _thenan_df which is used by
  the double precision routines.  Both variables are placed in their
  own object files so they will only linked in if they are actually
  needed.

Cheers
	Nick

Fri Sep 10 10:34:06 1999  Nick Clifton  <nickc@cygnus.com>

	* config/fp-bit.c: Define L_thenan_sf or L_thenan_df (as
	appropriate) if FINE_GRAINED_LIBRARIES is not defined.
	(nan): Return _thenan_sf or _thenan_df as appropriate.
	(L_thenan_sf): Define _thenan_sf.
	(L_thenan_df): Define _thenan_df.

	* Makefile.in (FPBIT_FUNCS): Add _thenan_sf.
	(DPBIT_FUNCS): Add _thenan_df.

Index: gcc/config/fp-bit.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/config/fp-bit.c,v
retrieving revision 1.58
diff -p -r1.58 fp-bit.c
*** fp-bit.c	1999/08/29 03:43:52	1.58
--- fp-bit.c	1999/09/10 09:29:42
*************** Boston, MA 02111-1307, USA.  */
*** 90,95 ****
--- 90,100 ----
  #define L_make_df
  #define L_sf_to_df
  #define L_df_to_sf
+ #ifdef FLOAT
+ #define L_thenan_sf
+ #else
+ #define L_thenan_df
+ #endif
  #endif
  
  /* The following macros can be defined to change the behaviour of this file:
*************** FLO_union_type;
*** 389,401 ****
  #define isinf(x) 0
  #else
  
  INLINE
  static fp_number_type *
  nan ()
  {
!   static fp_number_type thenan;
! 
!   return &thenan;
  }
  
  INLINE
--- 394,419 ----
  #define isinf(x) 0
  #else
  
+ #if   defined L_thenan_sf
+ const fp_number_type _thenan_sf = { CLASS_SNAN };
+ #elif defined L_thenan_df
+ const fp_number_type _thenan_df = { CLASS_SNAN };
+ #elif defined FLOAT
+ extern const fp_number_type _thenan_sf;
+ #else
+ extern const fp_number_type _thenan_df;
+ #endif
+ 
  INLINE
  static fp_number_type *
  nan ()
  {
!   /* Discard the const qualifier... */
! #ifdef FLOAT  
!   return (fp_number_type *) (& _thenan_sf);
! #else
!   return (fp_number_type *) (& _thenan_df);
! #endif
  }
  
  INLINE

Index: gcc/Makefile.in
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/Makefile.in,v
retrieving revision 1.787
diff -p -r1.787 Makefile.in
*** Makefile.in	1999/09/09 04:42:14	1.787
--- Makefile.in	1999/09/10 09:29:43
*************** LIB2FUNCS_EH = _eh
*** 774,785 ****
  FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \
      _fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \
      _lt_sf _le_sf _si_to_sf _sf_to_si _negate_sf _make_sf \
!     _sf_to_df
  
  DPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \
      _fpcmp_parts_df _compare_df _eq_df _ne_df _gt_df _ge_df \
      _lt_df _le_df _si_to_df _df_to_si _negate_df _make_df \
!     _df_to_sf
  
  # The files that "belong" in CONFIG_H are deliberately omitted
  # because having them there would not be useful in actual practice.
--- 774,785 ----
  FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \
      _fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \
      _lt_sf _le_sf _si_to_sf _sf_to_si _negate_sf _make_sf \
!     _sf_to_df _thenan_sf
  
  DPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \
      _fpcmp_parts_df _compare_df _eq_df _ne_df _gt_df _ge_df \
      _lt_df _le_df _si_to_df _df_to_si _negate_df _make_df \
!     _df_to_sf _thenan_df
  
  # The files that "belong" in CONFIG_H are deliberately omitted
  # because having them there would not be useful in actual practice.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]