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]
Other format: [Raw text]

[lto] PATCH: CALL_EXPR changes to gcc/fortran/trans-array.c


Already committed as "obvious".

-Sandra

2006-07-21 Sandra Loosemore <sandra@codesourcery.com>

	* gcc/fortran/trans-array.c (gfc_trans_allocate_array_storage):
	Use build_call_expr.
	(gfc_grow_array): Likewise.
	(gfc_trans_array_ctor_element): Likewise.
	(gfc_trans_array_constructor_value): Likewise.
	(gfc_array_allocate): Likewise.
	(gfc_array_deallocate): Likewise.
	(gfc_trans_auto_array_allocation): Likewise.
	(gfc_trans_dummy_array_bias): Likewise.
	(gfc_conv_array_parameter): Likewise.

Index: gcc/fortran/trans-array.c
===================================================================
*** gcc/fortran/trans-array.c	(revision 115645)
--- gcc/fortran/trans-array.c	(working copy)
*************** gfc_trans_allocate_array_storage (stmtbl
*** 493,499 ****
                                    bool dynamic, bool dealloc)
  {
    tree tmp;
-   tree args;
    tree desc;
    bool onstack;
  
--- 493,498 ----
*************** gfc_trans_allocate_array_storage (stmtbl
*** 526,540 ****
        else
  	{
  	  /* Allocate memory to hold the data.  */
- 	  args = gfc_chainon_list (NULL_TREE, size);
- 
  	  if (gfc_index_integer_kind == 4)
  	    tmp = gfor_fndecl_internal_malloc;
  	  else if (gfc_index_integer_kind == 8)
  	    tmp = gfor_fndecl_internal_malloc64;
  	  else
  	    gcc_unreachable ();
! 	  tmp = build_function_call_expr (tmp, args);
  	  tmp = gfc_evaluate_now (tmp, pre);
  	  gfc_conv_descriptor_data_set (pre, desc, tmp);
  	}
--- 525,537 ----
        else
  	{
  	  /* Allocate memory to hold the data.  */
  	  if (gfc_index_integer_kind == 4)
  	    tmp = gfor_fndecl_internal_malloc;
  	  else if (gfc_index_integer_kind == 8)
  	    tmp = gfor_fndecl_internal_malloc64;
  	  else
  	    gcc_unreachable ();
! 	  tmp = build_call_expr (tmp, 1, size);
  	  tmp = gfc_evaluate_now (tmp, pre);
  	  gfc_conv_descriptor_data_set (pre, desc, tmp);
  	}
*************** gfc_trans_allocate_array_storage (stmtbl
*** 551,558 ****
        /* Free the temporary.  */
        tmp = gfc_conv_descriptor_data_get (desc);
        tmp = fold_convert (pvoid_type_node, tmp);
!       tmp = gfc_chainon_list (NULL_TREE, tmp);
!       tmp = build_function_call_expr (gfor_fndecl_internal_free, tmp);
        gfc_add_expr_to_block (post, tmp);
      }
  }
--- 548,554 ----
        /* Free the temporary.  */
        tmp = gfc_conv_descriptor_data_get (desc);
        tmp = fold_convert (pvoid_type_node, tmp);
!       tmp = build_call_expr (gfor_fndecl_internal_free, 1, tmp);
        gfc_add_expr_to_block (post, tmp);
      }
  }
*************** gfc_get_iteration_count (tree start, tre
*** 794,800 ****
  static void
  gfc_grow_array (stmtblock_t * pblock, tree desc, tree extra)
  {
!   tree args;
    tree tmp;
    tree size;
    tree ubound;
--- 790,796 ----
  static void
  gfc_grow_array (stmtblock_t * pblock, tree desc, tree extra)
  {
!   tree arg0, arg1;
    tree tmp;
    tree size;
    tree ubound;
*************** gfc_grow_array (stmtblock_t * pblock, tr
*** 809,822 ****
    gfc_add_modify_expr (pblock, ubound, tmp);
  
    /* Get the value of the current data pointer.  */
!   tmp = gfc_conv_descriptor_data_get (desc);
!   args = gfc_chainon_list (NULL_TREE, tmp);
  
    /* Calculate the new array size.  */
    size = TYPE_SIZE_UNIT (gfc_get_element_type (TREE_TYPE (desc)));
    tmp = build2 (PLUS_EXPR, gfc_array_index_type, ubound, gfc_index_one_node);
!   tmp = build2 (MULT_EXPR, gfc_array_index_type, tmp, size);
!   args = gfc_chainon_list (args, tmp);
  
    /* Pick the appropriate realloc function.  */
    if (gfc_index_integer_kind == 4)
--- 805,816 ----
    gfc_add_modify_expr (pblock, ubound, tmp);
  
    /* Get the value of the current data pointer.  */
!   arg0 = gfc_conv_descriptor_data_get (desc);
  
    /* Calculate the new array size.  */
    size = TYPE_SIZE_UNIT (gfc_get_element_type (TREE_TYPE (desc)));
    tmp = build2 (PLUS_EXPR, gfc_array_index_type, ubound, gfc_index_one_node);
!   arg1 = build2 (MULT_EXPR, gfc_array_index_type, tmp, size);
  
    /* Pick the appropriate realloc function.  */
    if (gfc_index_integer_kind == 4)
*************** gfc_grow_array (stmtblock_t * pblock, tr
*** 827,833 ****
      gcc_unreachable ();
  
    /* Set the new data pointer.  */
!   tmp = build_function_call_expr (tmp, args);
    gfc_conv_descriptor_data_set (pblock, desc, tmp);
  }
  
--- 821,827 ----
      gcc_unreachable ();
  
    /* Set the new data pointer.  */
!   tmp = build_call_expr (tmp, 2, arg0, arg1);
    gfc_conv_descriptor_data_set (pblock, desc, tmp);
  }
  
*************** gfc_trans_array_ctor_element (stmtblock_
*** 936,942 ****
  			      tree offset, gfc_se * se, gfc_expr * expr)
  {
    tree tmp;
-   tree args;
  
    gfc_conv_expr (se, expr);
  
--- 930,935 ----
*************** gfc_trans_array_ctor_element (stmtblock_
*** 958,968 ****
  	  tmp = gfc_build_addr_expr (pchar_type_node, tmp);
  	  /* We know the temporary and the value will be the same length,
  	     so can use memcpy.  */
! 	  args = gfc_chainon_list (NULL_TREE, tmp);
! 	  args = gfc_chainon_list (args, se->expr);
! 	  args = gfc_chainon_list (args, se->string_length);
! 	  tmp = built_in_decls[BUILT_IN_MEMCPY];
! 	  tmp = build_function_call_expr (tmp, args);
  	  gfc_add_expr_to_block (&se->pre, tmp);
  	}
      }
--- 951,958 ----
  	  tmp = gfc_build_addr_expr (pchar_type_node, tmp);
  	  /* We know the temporary and the value will be the same length,
  	     so can use memcpy.  */
! 	  tmp = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], 3,
! 				 tmp, se->expr, se->string_length);
  	  gfc_add_expr_to_block (&se->pre, tmp);
  	}
      }
*************** gfc_trans_array_constructor_value (stmtb
*** 1170,1180 ****
  
  	      size = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type));
  	      bound = build_int_cst (NULL_TREE, n * size);
! 	      tmp = gfc_chainon_list (NULL_TREE, tmp);
! 	      tmp = gfc_chainon_list (tmp, init);
! 	      tmp = gfc_chainon_list (tmp, bound);
! 	      tmp = build_function_call_expr (built_in_decls[BUILT_IN_MEMCPY],
! 					     tmp);
  	      gfc_add_expr_to_block (&body, tmp);
  
  	      *poffset = fold_build2 (PLUS_EXPR, gfc_array_index_type,
--- 1160,1167 ----
  
  	      size = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type));
  	      bound = build_int_cst (NULL_TREE, n * size);
! 	      tmp = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], 3,
! 				     tmp, init, bound);
  	      gfc_add_expr_to_block (&body, tmp);
  
  	      *poffset = fold_build2 (PLUS_EXPR, gfc_array_index_type,
*************** gfc_array_allocate (gfc_se * se, gfc_exp
*** 3146,3155 ****
    else
      gcc_unreachable ();
  
!   tmp = gfc_chainon_list (NULL_TREE, pointer);
!   tmp = gfc_chainon_list (tmp, size);
!   tmp = gfc_chainon_list (tmp, pstat);
!   tmp = build_function_call_expr (allocate, tmp);
    gfc_add_expr_to_block (&se->pre, tmp);
  
    tmp = gfc_conv_descriptor_offset (se->expr);
--- 3133,3139 ----
    else
      gcc_unreachable ();
  
!   tmp = build_call_expr (allocate, 3, pointer, size, pstat);
    gfc_add_expr_to_block (&se->pre, tmp);
  
    tmp = gfc_conv_descriptor_offset (se->expr);
*************** gfc_array_deallocate (tree descriptor, t
*** 3176,3184 ****
    var = gfc_evaluate_now (tmp, &block);
  
    /* Parameter is the address of the data component.  */
!   tmp = gfc_chainon_list (NULL_TREE, var);
!   tmp = gfc_chainon_list (tmp, pstat);
!   tmp = build_function_call_expr (gfor_fndecl_deallocate, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
    return gfc_finish_block (&block);
--- 3160,3166 ----
    var = gfc_evaluate_now (tmp, &block);
  
    /* Parameter is the address of the data component.  */
!   tmp = build_call_expr (gfor_fndecl_deallocate, 2, var, pstat);
    gfc_add_expr_to_block (&block, tmp);
  
    return gfc_finish_block (&block);
*************** gfc_trans_auto_array_allocation (tree de
*** 3453,3467 ****
    size = fold_build2 (MULT_EXPR, gfc_array_index_type, size, tmp);
  
    /* Allocate memory to hold the data.  */
-   tmp = gfc_chainon_list (NULL_TREE, size);
- 
    if (gfc_index_integer_kind == 4)
      fndecl = gfor_fndecl_internal_malloc;
    else if (gfc_index_integer_kind == 8)
      fndecl = gfor_fndecl_internal_malloc64;
    else
      gcc_unreachable ();
!   tmp = build_function_call_expr (fndecl, tmp);
    tmp = fold (convert (TREE_TYPE (decl), tmp));
    gfc_add_modify_expr (&block, decl, tmp);
  
--- 3435,3447 ----
    size = fold_build2 (MULT_EXPR, gfc_array_index_type, size, tmp);
  
    /* Allocate memory to hold the data.  */
    if (gfc_index_integer_kind == 4)
      fndecl = gfor_fndecl_internal_malloc;
    else if (gfc_index_integer_kind == 8)
      fndecl = gfor_fndecl_internal_malloc64;
    else
      gcc_unreachable ();
!   tmp = build_call_expr (fndecl, 1, size);
    tmp = fold (convert (TREE_TYPE (decl), tmp));
    gfc_add_modify_expr (&block, decl, tmp);
  
*************** gfc_trans_auto_array_allocation (tree de
*** 3477,3484 ****
  
    /* Free the temporary.  */
    tmp = convert (pvoid_type_node, decl);
!   tmp = gfc_chainon_list (NULL_TREE, tmp);
!   tmp = build_function_call_expr (gfor_fndecl_internal_free, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
    return gfc_finish_block (&block);
--- 3457,3463 ----
  
    /* Free the temporary.  */
    tmp = convert (pvoid_type_node, decl);
!   tmp = build_call_expr (gfor_fndecl_internal_free, 1, tmp);
    gfc_add_expr_to_block (&block, tmp);
  
    return gfc_finish_block (&block);
*************** gfc_trans_dummy_array_bias (gfc_symbol *
*** 3638,3645 ****
        gcc_assert (integer_onep (GFC_TYPE_ARRAY_STRIDE (type, 0)));
        /* A library call to repack the array if necessary.  */
        tmp = GFC_DECL_SAVED_DESCRIPTOR (tmpdesc);
!       tmp = gfc_chainon_list (NULL_TREE, tmp);
!       stmt_unpacked = build_function_call_expr (gfor_fndecl_in_pack, tmp);
  
        stride = gfc_index_one_node;
      }
--- 3617,3623 ----
        gcc_assert (integer_onep (GFC_TYPE_ARRAY_STRIDE (type, 0)));
        /* A library call to repack the array if necessary.  */
        tmp = GFC_DECL_SAVED_DESCRIPTOR (tmpdesc);
!       stmt_unpacked = build_call_expr (gfor_fndecl_in_pack, 1, tmp);
  
        stride = gfc_index_one_node;
      }
*************** gfc_trans_dummy_array_bias (gfc_symbol *
*** 3817,3831 ****
        if (sym->attr.intent != INTENT_IN)
  	{
  	  /* Copy the data back.  */
! 	  tmp = gfc_chainon_list (NULL_TREE, dumdesc);
! 	  tmp = gfc_chainon_list (tmp, tmpdesc);
! 	  tmp = build_function_call_expr (gfor_fndecl_in_unpack, tmp);
  	  gfc_add_expr_to_block (&cleanup, tmp);
  	}
  
        /* Free the temporary.  */
!       tmp = gfc_chainon_list (NULL_TREE, tmpdesc);
!       tmp = build_function_call_expr (gfor_fndecl_internal_free, tmp);
        gfc_add_expr_to_block (&cleanup, tmp);
  
        stmt = gfc_finish_block (&cleanup);
--- 3795,3806 ----
        if (sym->attr.intent != INTENT_IN)
  	{
  	  /* Copy the data back.  */
! 	  tmp = build_call_expr (gfor_fndecl_in_unpack, 2, dumdesc, tmpdesc);
  	  gfc_add_expr_to_block (&cleanup, tmp);
  	}
  
        /* Free the temporary.  */
!       tmp = build_call_expr (gfor_fndecl_internal_free, 1, tmpdesc);
        gfc_add_expr_to_block (&cleanup, tmp);
  
        stmt = gfc_finish_block (&cleanup);
*************** gfc_conv_array_parameter (gfc_se * se, g
*** 4340,4362 ****
      {
        desc = se->expr;
        /* Repack the array.  */
!       tmp = gfc_chainon_list (NULL_TREE, desc);
!       ptr = build_function_call_expr (gfor_fndecl_in_pack, tmp);
        ptr = gfc_evaluate_now (ptr, &se->pre);
        se->expr = ptr;
  
        gfc_start_block (&block);
  
        /* Copy the data back.  */
!       tmp = gfc_chainon_list (NULL_TREE, desc);
!       tmp = gfc_chainon_list (tmp, ptr);
!       tmp = build_function_call_expr (gfor_fndecl_in_unpack, tmp);
        gfc_add_expr_to_block (&block, tmp);
  
        /* Free the temporary.  */
        tmp = convert (pvoid_type_node, ptr);
!       tmp = gfc_chainon_list (NULL_TREE, tmp);
!       tmp = build_function_call_expr (gfor_fndecl_internal_free, tmp);
        gfc_add_expr_to_block (&block, tmp);
  
        stmt = gfc_finish_block (&block);
--- 4315,4333 ----
      {
        desc = se->expr;
        /* Repack the array.  */
!       ptr = build_call_expr (gfor_fndecl_in_pack, 1, desc);
        ptr = gfc_evaluate_now (ptr, &se->pre);
        se->expr = ptr;
  
        gfc_start_block (&block);
  
        /* Copy the data back.  */
!       tmp = build_call_expr (gfor_fndecl_in_unpack, 2, desc, ptr);
        gfc_add_expr_to_block (&block, tmp);
  
        /* Free the temporary.  */
        tmp = convert (pvoid_type_node, ptr);
!       tmp = build_call_expr (gfor_fndecl_internal_free, 1, tmp);
        gfc_add_expr_to_block (&block, tmp);
  
        stmt = gfc_finish_block (&block);

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