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: more CALL_EXPR changes to java front end


Already committed as "obvious".

-Sandra


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


	* gcc/java/class.c (build_static_field_ref): Use build_call_expr.
	(emit_indirect_register_classes): Likewise.
	(emit_register_classes): Likewise.

* gcc/java/decl.c (finish_method): Use build_call_expr.

* gcc/java/check-init.c (check_init): Use new CALL_EXPR accessors.

	* gcc/java/resource.c (write_resource_constructor): Use
	build_call_expr.

	* gcc/java/builtins.c (builtin_creator_function): Pass entire
	CALL_EXPR as the second argument, not just the argument list.
	(max_builtin): Extract arguments from CALL_EXPR using new accessors.
	(min_builtin): Likewise.
	(abs_builtin): Likewise.
	(java_build_function_call_expr): Rewrite to use new CALL_EXPR
	constructors.
	(convert_real): Extract arguments from CALL_EXPR using new accessors.
	(check_for_builtin): Pass entire CALL_EXPR as argument to creator,
	rather than just its argument list.

	* gcc/java/lang.c (java_get_callee_fndecl): Use new CALL_EXPR
	accessors.

	* gcc/java/java-tree.h (CALL_THIS_CONSTRUCTOR_P): Use new CALL_EXPR
	accessors.
	(CALL_SUPER_CONSTRUCTOR_P): Likewise.

Index: gcc/java/class.c
===================================================================
*** gcc/java/class.c	(revision 115645)
--- gcc/java/class.c	(working copy)
*************** build_static_field_ref (tree fdecl)
*** 1172,1191 ****
  
        int cpool_index = alloc_constant_fieldref (output_class, fdecl);
        tree cache_entry = build_fieldref_cache_entry (cpool_index, fdecl);
!       tree test 
! 	= build3 (CALL_EXPR, boolean_type_node, 
! 		  build_address_of (built_in_decls[BUILT_IN_EXPECT]),
! 		  tree_cons (NULL_TREE, build2 (EQ_EXPR, boolean_type_node,
! 						cache_entry, null_pointer_node),
! 			     build_tree_list (NULL_TREE, boolean_false_node)),
! 		  NULL_TREE);
        tree cpool_index_cst = build_int_cst (NULL_TREE, cpool_index);
        tree init
! 	= build3 (CALL_EXPR, ptr_type_node,
! 		  build_address_of (soft_resolvepoolentry_node),
! 		  tree_cons (NULL_TREE, build_class_ref (output_class),
! 			     build_tree_list (NULL_TREE, cpool_index_cst)),
! 		  NULL_TREE);
        init = build2 (MODIFY_EXPR, ptr_type_node, cache_entry, init);
        init = build3 (COND_EXPR, ptr_type_node, test, init, cache_entry);
        init = fold_convert (build_pointer_type (TREE_TYPE (fdecl)), init);
--- 1172,1187 ----
  
        int cpool_index = alloc_constant_fieldref (output_class, fdecl);
        tree cache_entry = build_fieldref_cache_entry (cpool_index, fdecl);
!       tree test
!         = build_call_expr (built_in_decls[BUILT_IN_EXPECT], 2,
! 			   build2 (EQ_EXPR, boolean_type_node,
! 				   cache_entry, null_pointer_node),
! 			   boolean_false_node);
        tree cpool_index_cst = build_int_cst (NULL_TREE, cpool_index);
        tree init
! 	= build_call_expr (soft_resolvepoolentry_node, 2,
! 			   build_class_ref (output_class),
! 			   cpool_index_cst);
        init = build2 (MODIFY_EXPR, ptr_type_node, cache_entry, init);
        init = build3 (COND_EXPR, ptr_type_node, test, init, cache_entry);
        init = fold_convert (build_pointer_type (TREE_TYPE (fdecl)), init);
*************** emit_indirect_register_classes (tree *li
*** 2575,2582 ****
    TREE_PUBLIC (t) = 1;
    DECL_EXTERNAL (t) = 1;
    register_class_fn = t;
!   t = tree_cons (NULL, reg_class_list, NULL);
!   t = build_function_call_expr (register_class_fn, t);
    append_to_statement_list (t, list_p);
  }
  
--- 2571,2577 ----
    TREE_PUBLIC (t) = 1;
    DECL_EXTERNAL (t) = 1;
    register_class_fn = t;
!   t = build_call_expr (register_class_fn, 1, reg_class_list);
    append_to_statement_list (t, list_p);
  }
  
*************** emit_register_classes (tree *list_p)
*** 2641,2648 ****
        for (i = 0; VEC_iterate (tree, registered_class, i, klass); ++i)
  	{
  	  t = build_fold_addr_expr (klass);
! 	  t = tree_cons (NULL, t, NULL);
! 	  t = build_function_call_expr (register_class_fn, t);
  	  append_to_statement_list (t, list_p);
  	}
      }
--- 2636,2642 ----
        for (i = 0; VEC_iterate (tree, registered_class, i, klass); ++i)
  	{
  	  t = build_fold_addr_expr (klass);
! 	  t = build_call_expr (register_class_fn, 1, t);
  	  append_to_statement_list (t, list_p);
  	}
      }
Index: gcc/java/decl.c
===================================================================
*** gcc/java/decl.c	(revision 115645)
--- gcc/java/decl.c	(working copy)
*************** finish_method (tree fndecl)
*** 2120,2129 ****
        && ! CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (fndecl))))
      {
        tree clas = DECL_CONTEXT (fndecl);
!       tree init = build3 (CALL_EXPR, void_type_node,
! 			  build_address_of (soft_initclass_node),
! 			  build_tree_list (NULL_TREE, build_class_ref (clas)),
! 			  NULL_TREE);
        *tp = build2 (COMPOUND_EXPR, TREE_TYPE (*tp), init, *tp);
      }
  
--- 2120,2127 ----
        && ! CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (fndecl))))
      {
        tree clas = DECL_CONTEXT (fndecl);
!       tree init = build_call_expr (soft_initclass_node, 1, 
! 				   build_class_ref (clas));
        *tp = build2 (COMPOUND_EXPR, TREE_TYPE (*tp), init, *tp);
      }
  
Index: gcc/java/check-init.c
===================================================================
*** gcc/java/check-init.c	(revision 115645)
--- gcc/java/check-init.c	(working copy)
*************** check_init (tree exp, words before)
*** 903,916 ****
      case NEW_CLASS_EXPR:
      case CALL_EXPR:
        {
! 	tree func = TREE_OPERAND (exp, 0);
! 	tree x = TREE_OPERAND (exp, 1);
  	if (TREE_CODE (func) == ADDR_EXPR)
  	  func = TREE_OPERAND (func, 0);
  	check_init (func, before);
  
! 	for ( ;  x != NULL_TREE;  x = TREE_CHAIN (x))
! 	  check_init (TREE_VALUE (x), before);
  	if (func == throw_node)
  	  goto never_continues;
        }
--- 903,917 ----
      case NEW_CLASS_EXPR:
      case CALL_EXPR:
        {
! 	tree func = CALL_EXPR_FN (exp);
! 	tree arg;
! 	call_expr_arg_iterator iter;
  	if (TREE_CODE (func) == ADDR_EXPR)
  	  func = TREE_OPERAND (func, 0);
  	check_init (func, before);
  
! 	FOR_EACH_CALL_EXPR_ARG (arg, iter, exp)
! 	  check_init (arg, before);
  	if (func == throw_node)
  	  goto never_continues;
        }
Index: gcc/java/resource.c
===================================================================
*** gcc/java/resource.c	(revision 115645)
--- gcc/java/resource.c	(working copy)
*************** write_resource_constructor (tree *list_p
*** 116,123 ****
    for (iter = nreverse (resources); iter ; iter = TREE_CHAIN (iter))
      {
        t = build_fold_addr_expr (TREE_VALUE (iter));
!       t = tree_cons (NULL, t, NULL);
!       t = build_function_call_expr (register_resource_fn, t);
        append_to_statement_list (t, list_p);
      }
  }
--- 116,122 ----
    for (iter = nreverse (resources); iter ; iter = TREE_CHAIN (iter))
      {
        t = build_fold_addr_expr (TREE_VALUE (iter));
!       t = build_call_expr (register_resource_fn, 1, t);
        append_to_statement_list (t, list_p);
      }
  }
Index: gcc/java/builtins.c
===================================================================
*** gcc/java/builtins.c	(revision 115645)
--- gcc/java/builtins.c	(working copy)
*************** static tree java_build_function_call_exp
*** 48,54 ****
  /* Functions of this type are used to inline a given call.  Such a
     function should either return an expression, if the call is to be
     inlined, or NULL_TREE if a real call should be emitted.  Arguments
!    are method return type and arguments to call.  */
  typedef tree builtin_creator_function (tree, tree);
  
  /* Hold a char*, before initialization, or a tree, after
--- 48,55 ----
  /* Functions of this type are used to inline a given call.  Such a
     function should either return an expression, if the call is to be
     inlined, or NULL_TREE if a real call should be emitted.  Arguments
!    are method return type and the original CALL_EXPR containing the
!    arguments to the call.  */
  typedef tree builtin_creator_function (tree, tree);
  
  /* Hold a char*, before initialization, or a tree, after
*************** static GTY(()) struct builtin_record jav
*** 97,146 ****
  /* Internal functions which implement various builtin conversions.  */
  
  static tree
! max_builtin (tree method_return_type, tree method_arguments)
  {
    /* MAX_EXPR does not handle -0.0 in the Java style.  */
    if (TREE_CODE (method_return_type) == REAL_TYPE)
      return NULL_TREE;
    return fold_build2 (MAX_EXPR, method_return_type,
! 		      TREE_VALUE (method_arguments),
! 		      TREE_VALUE (TREE_CHAIN (method_arguments)));
  }
  
  static tree
! min_builtin (tree method_return_type, tree method_arguments)
  {
    /* MIN_EXPR does not handle -0.0 in the Java style.  */
    if (TREE_CODE (method_return_type) == REAL_TYPE)
      return NULL_TREE;
    return fold_build2 (MIN_EXPR, method_return_type,
! 		      TREE_VALUE (method_arguments),
! 		      TREE_VALUE (TREE_CHAIN (method_arguments)));
  }
  
  static tree
! abs_builtin (tree method_return_type, tree method_arguments)
  {
    return fold_build1 (ABS_EXPR, method_return_type,
! 		      TREE_VALUE (method_arguments));
  }
  
! /* Mostly copied from ../builtins.c.  */
  static tree
! java_build_function_call_expr (tree fn, tree arglist)
  {
!   tree call_expr;
! 
!   call_expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn);
!   return fold_build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (fn)),
! 		      call_expr, arglist, NULL_TREE);
  }
  
  static tree
! convert_real (tree method_return_type, tree method_arguments)
  {
    return build1 (VIEW_CONVERT_EXPR, method_return_type,
! 		 TREE_VALUE (method_arguments));
  }
  
  
--- 98,161 ----
  /* Internal functions which implement various builtin conversions.  */
  
  static tree
! max_builtin (tree method_return_type, tree orig_call)
  {
    /* MAX_EXPR does not handle -0.0 in the Java style.  */
    if (TREE_CODE (method_return_type) == REAL_TYPE)
      return NULL_TREE;
    return fold_build2 (MAX_EXPR, method_return_type,
! 		      CALL_EXPR_ARG0 (orig_call),
! 		      CALL_EXPR_ARG1 (orig_call));
  }
  
  static tree
! min_builtin (tree method_return_type, tree orig_call)
  {
    /* MIN_EXPR does not handle -0.0 in the Java style.  */
    if (TREE_CODE (method_return_type) == REAL_TYPE)
      return NULL_TREE;
    return fold_build2 (MIN_EXPR, method_return_type,
! 		      CALL_EXPR_ARG0 (orig_call),
! 		      CALL_EXPR_ARG1 (orig_call));
  }
  
  static tree
! abs_builtin (tree method_return_type, tree orig_call)
  {
    return fold_build1 (ABS_EXPR, method_return_type,
! 		      CALL_EXPR_ARG0 (orig_call));
  }
  
! /* Construct a new call to FN using the arguments from ORIG_CALL.  */
! 
  static tree
! java_build_function_call_expr (tree fn, tree orig_call)
  {
!   switch (call_expr_nargs (orig_call))
!     {
!     case 0:
!       return build_call_expr (fn, 0);
!     case 1:
!       return build_call_expr (fn, 1, CALL_EXPR_ARG0 (orig_call));
!     case 2:
!       return build_call_expr (fn, 2,
! 			      CALL_EXPR_ARG0 (orig_call),
! 			      CALL_EXPR_ARG1 (orig_call));
!     case 3:
!       return build_call_expr (fn, 3,
! 			      CALL_EXPR_ARG0 (orig_call),
! 			      CALL_EXPR_ARG1 (orig_call),
! 			      CALL_EXPR_ARG2 (orig_call));
!     default:
!       return build_function_call_expr (fn, CALL_EXPR_ARGS (orig_call));
!     }
  }
  
  static tree
! convert_real (tree method_return_type, tree orig_call)
  {
    return build1 (VIEW_CONVERT_EXPR, method_return_type,
! 		 CALL_EXPR_ARG0 (orig_call));
  }
  
  
*************** check_for_builtin (tree method, tree cal
*** 270,276 ****
    if (! flag_emit_class_files && optimize && TREE_CODE (call) == CALL_EXPR)
      {
        int i;
-       tree method_arguments = TREE_OPERAND (call, 1);
        tree method_class = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method)));
        tree method_name = DECL_NAME (method);
        tree method_return_type = TREE_TYPE (TREE_TYPE (method));
--- 285,290 ----
*************** check_for_builtin (tree method, tree cal
*** 285,298 ****
  	      if (java_builtins[i].creator != NULL)
  		{
  		  tree result
! 		    = (*java_builtins[i].creator) (method_return_type,
! 						   method_arguments);
  		  return result == NULL_TREE ? call : result;
  		}
  	      fn = built_in_decls[java_builtins[i].builtin_code];
  	      if (fn == NULL_TREE)
  		return call;
! 	      return java_build_function_call_expr (fn, method_arguments);
  	    }
  	}
      }
--- 299,311 ----
  	      if (java_builtins[i].creator != NULL)
  		{
  		  tree result
! 		    = (*java_builtins[i].creator) (method_return_type, call);
  		  return result == NULL_TREE ? call : result;
  		}
  	      fn = built_in_decls[java_builtins[i].builtin_code];
  	      if (fn == NULL_TREE)
  		return call;
! 	      return java_build_function_call_expr (fn, call);
  	    }
  	}
      }
Index: gcc/java/lang.c
===================================================================
*** gcc/java/lang.c	(revision 115645)
--- gcc/java/lang.c	(working copy)
*************** java_get_callee_fndecl (tree call_expr)
*** 1015,1021 ****
  
    if (TREE_CODE (call_expr) != CALL_EXPR)
      return NULL;
!   method = TREE_OPERAND (call_expr, 0);
    STRIP_NOPS (method);
    if (TREE_CODE (method) != ARRAY_REF)
      return NULL;
--- 1015,1021 ----
  
    if (TREE_CODE (call_expr) != CALL_EXPR)
      return NULL;
!   method = CALL_EXPR_FN (call_expr);
    STRIP_NOPS (method);
    if (TREE_CODE (method) != ARRAY_REF)
      return NULL;
Index: gcc/java/java-tree.h
===================================================================
*** gcc/java/java-tree.h	(revision 115645)
--- gcc/java/java-tree.h	(working copy)
*************** extern tree *type_map;
*** 1793,1803 ****
  
  #define CALL_THIS_CONSTRUCTOR_P(NODE)					\
    (TREE_CODE (NODE) == CALL_EXPR					\
!    && EXPR_WFL_NODE (TREE_OPERAND (NODE, 0)) == this_identifier_node)
  
  #define CALL_SUPER_CONSTRUCTOR_P(NODE)					\
    (TREE_CODE (NODE) == CALL_EXPR					\
!    && EXPR_WFL_NODE (TREE_OPERAND (NODE, 0)) == super_identifier_node)
  
  /* Using a FINALLY_EXPR node */
  #define FINALLY_EXPR_LABEL(NODE) TREE_OPERAND (FINALLY_EXPR_CHECK (NODE), 0)
--- 1793,1803 ----
  
  #define CALL_THIS_CONSTRUCTOR_P(NODE)					\
    (TREE_CODE (NODE) == CALL_EXPR					\
!    && EXPR_WFL_NODE (CALL_EXPR_FN (NODE)) == this_identifier_node)
  
  #define CALL_SUPER_CONSTRUCTOR_P(NODE)					\
    (TREE_CODE (NODE) == CALL_EXPR					\
!    && EXPR_WFL_NODE (CALL_EXPR_FN (NODE)) == super_identifier_node)
  
  /* Using a FINALLY_EXPR node */
  #define FINALLY_EXPR_LABEL(NODE) TREE_OPERAND (FINALLY_EXPR_CHECK (NODE), 0)

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