[PATCH] printf optimization

law@redhat.com law@redhat.com
Tue Jun 4 10:56:00 GMT 2002


In message <20020604132233.90188.qmail@web13608.mail.yahoo.com>, Mark Dettinger
 writes:
 > This is a patch for GCC 3.1 that introduces a printf optimization:
 > 
 > If possible, then constant arguments are integrated into the format string
 > at compile-time.
 > 
 > Example:  printf("%d+%d=%d",1,2,x)  
 > 	    turns into  
 > 	  printf("1+2=%d",x)
 > 
 > The optimization works on the abstract syntax tree and runs directly before 
 > RTL
 > generation.
 > 
 > 
 > -Mark Dettinger
 > 
 > 
 > 2002-06-03	Mark Dettinger (mdetting@yahoo.com)
 > 
 > 	2 Modified Files:
 > 
 > 	* toplev.c: add new switches
 > 	* c-decl.c: insert call to printf optimizer
 > 
 > 	5 New Files:
 > 
 > 	* md-optimize-printf.h
 > 	* md-optimize-printf.c  printf optimizer
 > 	* md-print-tree.h       
 > 	* md-print-tree.c       outputs trees (for debugging)
 > 	* md-utilities.c        useful functions 
 > 
 > 	The functions contained in the 5 new files are included from c-decl.c.
 > 	They could also be put directly into c-decl.c, of course. 
In addition to the comments you've already received, this patch is large
enough that you will need to file a copyright assignment and possibly an
employer disclaimer with the FSF before we can accept any of the code.

jeff



More information about the Gcc-patches mailing list