[PATCH] Cray Pointers

Asher Langton langton2@llnl.gov
Thu Aug 4 01:30:00 GMT 2005


Here's take two of the Cray pointer patch.  I've made most of the 
changes that Paul suggested (exceptions noted below), added 
documentation, attribute checking, and modified the test program to 
be dejagnu-compatible.   Things I didn't (completely) change:

At 4:20 PM +0100 7/31/05, Paul Brook wrote:
>On Friday 29 July 2005 23:27, Asher Langton wrote:
>
>  > *************** gfc_conv_array_parameter (gfc_se * se, g
>  > <snip>
>
>This code should probably be moved into gfc_get_symbol_decl.
>
>  > *************** gfc_finish_var_decl (tree decl, gfc_symb
>  > <snip>
>  > !    /* We don't want real declarations for Cray Pointees */
>>  !    if (sym->attr.cray_pointee)
>>  !      return;
>
>This shouldn't be necessary. We shouldn't be creating the decl in the first
>place.  We may want to do something for debug info, but this almost certainly
>isn't it.

I moved the pointee translation code into a new method, but not into 
gfc_get_symbol_decl.  In the implementation, it was useful to create 
a backend_decl for each pointee symbol, which makes it easier to do 
type conversion.  The bail-out code in gfc_finish_var_decl lets us 
create the backend_decl for the pointee gfc_symbol, but still not 
pass a real declaration to the backend.

>  > +    se->expr = convert (gfc_unsigned_type(long_integer_type_node),
>se->expr);
>>  +
>>  +    /* Create a temporary variable for loc return value. We need to make
>sure
>>  +     * that the result isn't cast to the wrong integer kind along the
>>  +     * way.  (This was an issue on Alphas and Itaniums.)  We assume
>>  +     * that sizeof (void *) <= size (long int) */
>  > +    temp_var = gfc_create_var(gfc_unsigned_type(long_integer_type_node),
>NULL);
>>  +    gfc_add_modify_expr (&se->pre, temp_var, se->expr);
>>  +    se->expr = temp_var;
>
>The LOC expression should already have been resolved to the correct type. Use
>that.

My comment there wasn't really accurate.  I've cleaned up this code a 
bit, but I wasn't able to remove the gfc_add_modify_expr.  Without 
it, I run into problems in expand_expr_addr_expr_1() (gcc/expr.c).

-Asher


2005-08-03  Asher Langton  <langton2@llnl.gov>

	PR fortran/17031
	PR fortran/22282
	* check.c (gfc_check_loc) : New function

	* decl.c (variable_decl): New variables cp_as and sym.  Added 
a check for variables that
	have already been declared as Cray Pointers, so we can get 
the necessary attributes
	without adding a new symbol.
	(attr_decl1):  Added code to catch pointee symbols and "fix" 
their array specs
	(cray_pointer_decl): New method
	(gfc_match_cray_pointer): New method
	(gfc_mod_pointee_as): New method

	* expr.c (gfc_check_assign): added a check to catch 
vector-type assignments
  	to pointees with an unspecified final dimension.

	* gfortran.h: (GFC_ISYM_LOC): New
	(symbol_attribute): Added cray_pointer and cray_pointee bits
	(gfc_array_spec): Added cray_pointee and cp_was_assumed bools
	(gfc_symbol): Added gfc_symbol *cp_pointer
	(gfc_option): Added flag_cray_pointer
	(gfc_add_cray_pointee): Declare
	(gfc_add_cray_pointer ): Declare
	(gfc_mod_pointee_as): Declare

	*gfortran.texi: Added section on Cray pointers, removed Cray 
pointers from list of proposed
	extensions

	* intrinsic.c (add_functions): add code for loc() intrinsic

	* intrinsic.h (gfc_check_loc): Declare
	(gfc_resolve_loc): Declare

	* intrinsic.texi: Added documentation for loc intrinsic

	* invoke.texi: Documented -fcray-pointer flag

	* iresolve.c (gfc_resolve_loc): New

	* lang.opt: Added fcray-pointer flag and fbyte-type flags

	* match.h (gfc_match_cray_pointer): Declare

	* options.c (gfc_init_options): Intialized 
gfc_match_option.flag_cray_pointer
	(gfc_handle_option): deal with -fcray-pointer

	* parse.c: Added do...while(0) and braces around match() 
macro to avoid the if/else
	ambiguity
	(decode_statement): added code to detect statements starting with
	 "pointer ("
	(resolve_equivalence): Added code prohibiting Cray pointees 
in equivalence statements.

	* resolve.c (check_dimension): added code to prevent bounds 
checking for Cray
  	Pointee arrays.

	* symbol.c (check_conflict): Added Cray pointer/pointee 
attribute checking
	(gfc_add_cray_pointer): New
	(gfc_add_cray_pointee): New
	(gfc_copy_attr): New code for Cray pointers and pointees

	* trans-array.c (gfc_trans_auto_array_allocation): added code 
to prevent space from
  	being allocated for pointees
	(gfc_conv_array_parameter): added code to catch pointees and
  	correctly set their base address.

	* trans-decl.c (gfc_finish_var_decl):  added code to prevent 
pointee declarations from making
	it to the back end.
	(gfc_create_module_variable):  same

	* trans-expr.c (gfc_conv_variable): added code to detect and 
translate pointees
	(gfc_conv_cray_pointee): New

	* trans-intrinsic.c (gfc_conv_intrinsic_loc): New
	(gfc_conv_intrinsic_function): added entry point for loc translation

	* trans.h (gfc_conv_cray_pointee): Declare
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cp_patch_8_03c.diff
Type: application/octet-stream
Size: 43910 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050804/702d22b4/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: craytest.f90
Type: application/octet-stream
Size: 89843 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050804/702d22b4/attachment-0001.obj>


More information about the Fortran mailing list