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 constify few functions.



Hi
Just because I am curious, I've implemented the warning informing about
functions, that can have "const" attribute to see how common they
are.

It found few functions on gcc source tree (not more than 20, most of them
empty functions).  Following ones I've considered to be usefull to declare
as const.
It saves roughly 200bytes from the binarry.

Honza
Fri Aug 20 18:26:21 EDT 1999  Jan Hubicka  <hubicka@freesoft.cz>
	* gansidecl.h (ATTRIBUTE_CONST): New macro.
	* gcse.c (hash_set): set ATTRIBUTE_CONST.
	* rtl.h (exact_log2_wide): Likewise.
	(floor_log2_wide): Likewise.
	* tree.h (exact_log2_wide): Likewise.
	(exact_log2_wide): Likewise.
	* i386.c (const1_operand): Likewise.

*** gcse.c.noconst	Fri Aug 20 17:38:17 1999
--- gcse.c	Fri Aug 20 17:38:19 1999
*************** static void insert_set_in_table       PR
*** 539,545 ****
  static unsigned int hash_expr	 PROTO ((rtx, enum machine_mode,
  					 int *, int));
  static unsigned int hash_expr_1       PROTO ((rtx, enum machine_mode, int *));
! static unsigned int hash_set	  PROTO ((int, int));
  static int expr_equiv_p	       PROTO ((rtx, rtx));
  static void record_last_reg_set_info  PROTO ((rtx, int));
  static void record_last_mem_set_info  PROTO ((rtx));
--- 539,546 ----
  static unsigned int hash_expr	 PROTO ((rtx, enum machine_mode,
  					 int *, int));
  static unsigned int hash_expr_1       PROTO ((rtx, enum machine_mode, int *));
! static unsigned int hash_set	  PROTO ((int, int))
!   ATTRIBUTE_CONST;
  static int expr_equiv_p	       PROTO ((rtx, rtx));
  static void record_last_reg_set_info  PROTO ((rtx, int));
  static void record_last_mem_set_info  PROTO ((rtx));
*** rtl.h.noconst	Fri Aug 20 17:33:21 1999
--- rtl.h	Fri Aug 20 17:34:06 1999
*************** extern char *note_insn_name[];
*** 901,908 ****
  #define exact_log2(N) exact_log2_wide ((unsigned HOST_WIDE_INT) (N))
  #define floor_log2(N) floor_log2_wide ((unsigned HOST_WIDE_INT) (N))
  #endif
! extern int exact_log2_wide		PROTO((unsigned HOST_WIDE_INT));
! extern int floor_log2_wide		PROTO((unsigned HOST_WIDE_INT));
  
  /* In expmed.c */
  extern int ceil_log2			PROTO((unsigned HOST_WIDE_INT));
--- 901,910 ----
  #define exact_log2(N) exact_log2_wide ((unsigned HOST_WIDE_INT) (N))
  #define floor_log2(N) floor_log2_wide ((unsigned HOST_WIDE_INT) (N))
  #endif
! extern int exact_log2_wide		PROTO((unsigned HOST_WIDE_INT))
!   ATTRIBUTE_CONST;
! extern int floor_log2_wide		PROTO((unsigned HOST_WIDE_INT))
!   ATTRIBUTE_CONST;
  
  /* In expmed.c */
  extern int ceil_log2			PROTO((unsigned HOST_WIDE_INT));
*** tree.h.noconst	Fri Aug 20 17:34:43 1999
--- tree.h	Fri Aug 20 17:35:01 1999
*************** union tree_node
*** 1402,1409 ****
  #define exact_log2(N) exact_log2_wide ((unsigned HOST_WIDE_INT) (N))
  #define floor_log2(N) floor_log2_wide ((unsigned HOST_WIDE_INT) (N))
  #endif
! extern int exact_log2_wide             PROTO((unsigned HOST_WIDE_INT));
! extern int floor_log2_wide             PROTO((unsigned HOST_WIDE_INT));
  
  extern char *oballoc			PROTO((int));
  extern char *permalloc			PROTO((int));
--- 1402,1411 ----
  #define exact_log2(N) exact_log2_wide ((unsigned HOST_WIDE_INT) (N))
  #define floor_log2(N) floor_log2_wide ((unsigned HOST_WIDE_INT) (N))
  #endif
! extern int exact_log2_wide             PROTO((unsigned HOST_WIDE_INT))
!   ATTRIBUTE_CONST;
! extern int floor_log2_wide             PROTO((unsigned HOST_WIDE_INT))
!   ATTRIBUTE_CONST;
  
  extern char *oballoc			PROTO((int));
  extern char *permalloc			PROTO((int));
*** gansidecl.h~	Thu Jul  8 18:45:47 1999
--- gansidecl.h	Fri Aug 20 17:16:19 1999
*************** Boston, MA 02111-1307, USA.  */
*** 67,72 ****
--- 67,76 ----
  #define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
  #endif /* ATTRIBUTE_NORETURN */
  
+ #ifndef ATTRIBUTE_CONST
+ #define ATTRIBUTE_CONST __attribute__ ((__const__))
+ #endif /* ATTRIBUTE_CONST */
+ 
  #ifndef ATTRIBUTE_PRINTF
  #define ATTRIBUTE_PRINTF(m, n) __attribute__ ((format (__printf__, m, n)))
  #define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
*** config/i386/i386.h.noconst	Fri Aug 20 17:40:28 1999
--- config/i386/i386.h	Fri Aug 20 17:40:45 1999
*************** extern int call_insn_operand XPARAMS((xr
*** 2470,2476 ****
  extern int expander_call_insn_operand XPARAMS((xrtx, xmode));
  extern int constant_call_address_operand XPARAMS((xrtx, xmode));
  extern int const0_operand XPARAMS((xrtx, xmode));
! extern int const1_operand XPARAMS((xrtx, xmode));
  extern int const248_operand XPARAMS((xrtx, xmode));
  extern int incdec_operand XPARAMS((xrtx, xmode));
  extern int reg_no_sp_operand XPARAMS((xrtx, xmode));
--- 2470,2477 ----
  extern int expander_call_insn_operand XPARAMS((xrtx, xmode));
  extern int constant_call_address_operand XPARAMS((xrtx, xmode));
  extern int const0_operand XPARAMS((xrtx, xmode));
! extern int const1_operand XPARAMS((xrtx, xmode))
!   ATTRIBUTE_CONST;
  extern int const248_operand XPARAMS((xrtx, xmode));
  extern int incdec_operand XPARAMS((xrtx, xmode));
  extern int reg_no_sp_operand XPARAMS((xrtx, xmode));


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