Optimizing *printf implementation plan

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Sun Jan 31 23:58:00 GMT 1999

	I decided it might be a good idea to handle the printf
optimizations through creating __builtin_printf, etc.  Going with that
thought, I came up with the following implementation plan.

1.  Setup infrastructure for three new builtin functions:


	This would require changes to these files:

tree.h: enum built_in_function
c-decl.c: init_decl_processing()
expr.c: expand_builtin()
c-common.c: init_function_format_info()

	We would eventually put all the optimizing code in
expr. c:expand_builtin().

2.  Modify c-common.c:check_function_format() to accept a new
structure pointer parameter.  This would be used to pass back
information about the printf format it just checked (it avoids
duplicating all this code in expr.c.)  Call check_function_format()
from expr.c to make sure the format of the __builtin_printf is valid
before we munge it, as well as to collect vital parsing information.

3.  Add a new -W warning flag to check for places we could optimize. 
This is mainly allow programmers to visually check intl calls to gettext
since they won't be optimized because the format parameter to printf
won't be a const string. 

4.  Arrange for the special inline versions of putc/fputc to be
created by cpp or installed into stdio.h by fixincludes.  See:

5.  Write code in expr.c:expand_builtins() to do the optimizations.  I
believe all or almost all of the "reduce_printfs" optimizations I
described in: http://www.cygnus.com/ml/egcs/1999-Jan/0388.html would
be possible using this plan.


Kaveh R. Ghazi			Engagement Manager / Project Services
ghazi@caip.rutgers.edu		Icon CMT Corp.

More information about the Gcc mailing list