[fortran-dev] constructor work, part I

Daniel Franke franke.daniel@gmail.com
Wed Dec 23 16:37:00 GMT 2009


Hi all,

as mentioned a couple of times before, I'd like to get rid of linked lists for 
constructurs. Instead, a more suitable tree structure should be used. 

Due to some uncertainty which tree structure would be the most suitable one, 
I'd like to postpone that question for the time being and start with some 
preparations:

 (a) define an API that hides the implementation details of constructors
 (b) apply the API everywhere where the linked-list implementation is used
     directly
 (c) reimplement the API functions using a different data structure

The initial implementation of (a) would of course use the linked-list to be 
compatible with the code not transformed yet and obviously re-use what's 
already available. After (b) is complete, one may or may not hide the 
constructor-structure and make it an opaque pointer in gfc_expr (remove 
con_by_offset while at it). Then, one could initially implement (c) with a 
splay-tree, which already is provided by libiberty. If issues are found due to 
properties of the splaying, one could replace it with a red-black tree later.

The attach patch against fortran-dev starts (a) and (b) together; 
constructor.h defines an initial version of a constructor API (a smoothed out 
version of what we already have and barely use), constructor.c implements it 
with by mainly re-using the existing functions.

To see if it actually works as intended, arith.c, decl.c and expr.c were 
already transformed to use the new API. As some inserts on tail-pointers were 
replaced by list traversals from begining to end, compile-time performance 
degraded a bit (testcase gfortran.dg/initialization_21.f90 times out).


2009-12-23  Daniel Franke  <franke.daniel@gmail.com>

	* constructor.h: New.
	* constructor.c: New.
	* Make-lang.in: Add new files to F95_PARSER_OBJS.
	* arith.c (reducy_unary): Use constructor API.
	(reduce_binary_ac): Likewise.
	(reduce_binary_ca): Likewise.
	(reduce_binary_aa): Likewise.
	* decl.c (add_init_expr_to_sym): Likewise.
	(build_struct): Likewise.
	* expr.c (gfc_is_constant_expr): Likewise.
	(simplify_constructor): Likewise.
	(find_array_element): Likewise.
	(find_component_ref): Likewise.
	(find_array_section): Likewise.
	(simplify_const_ref): Likewise.
	(scalarize_intrinsic_call): Likewise.
	(check_alloc_comp_init): Likewise.
	(gfc_default_initializer): Likewise.
	(gfc_traverse_expr): Likewise.


Bootstrapped and regression tested on i686-pc-linux-gnu. One performance 
regression (gfortran.dg/initialization_21.f90). Ok for fortran-dev?

Cheers

	Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: constructor-1.diff
Type: text/x-patch
Size: 34171 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20091223/04a688a7/attachment.bin>


More information about the Fortran mailing list