public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* New langhook: lang_get_callee_fndecl
@ 2003-10-03 16:18 Andrew Haley
  2003-10-03 20:56 ` Richard Henderson
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Haley @ 2003-10-03 16:18 UTC (permalink / raw)
  To: gcc

Java wraps the target of some CALL_EXPRs in a indirection via a method
table, which makes get_callee_fndecl() fail and so we don't vreate a
proper call graph.  This new langhook allows front ends to retrieve
the target of a call if the middle can't do it straightforwardly.

Andrew.

2003-10-03  Andrew Haley  <aph@redhat.com>

	* tree.c (get_callee_fndecl): Call
	lang_hooks.lang_get_callee_fndecl.
	* langhooks-def.h (LANG_HOOKS_GET_CALLEE_FNDECL): New.
	(lhd_get_callee_fndecl): New.

Index: langhooks-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks-def.h,v
retrieving revision 1.68
diff -c -2 -p -r1.68 langhooks-def.h
*** langhooks-def.h	17 Sep 2003 20:52:40 -0000	1.68
--- langhooks-def.h	3 Oct 2003 16:16:16 -0000
*************** extern bool lhd_decl_ok_for_sibcall (tre
*** 68,71 ****
--- 68,72 ----
  extern tree lhd_expr_size (tree);
  extern bool lhd_decl_uninit (tree);
+ extern tree lhd_get_callee_fndecl (tree);
  extern size_t lhd_tree_size (enum tree_code);
  
*************** extern tree lhd_callgraph_analyze_expr (
*** 120,123 ****
--- 121,125 ----
  #define LANG_HOOKS_PRINT_ERROR_FUNCTION lhd_print_error_function
  #define LANG_HOOKS_DECL_PRINTABLE_NAME	lhd_decl_printable_name
+ #define LANG_HOOKS_GET_CALLEE_FNDECL	lhd_return_null_tree
  #define LANG_HOOKS_EXPR_SIZE		lhd_expr_size
  #define LANG_HOOKS_DECL_UNINIT		lhd_decl_uninit
*************** extern int lhd_tree_dump_type_quals (tre
*** 298,301 ****
--- 300,304 ----
    LANG_HOOKS_PRINT_IDENTIFIER, \
    LANG_HOOKS_DECL_PRINTABLE_NAME, \
+   LANG_HOOKS_GET_CALLEE_FNDECL, \
    LANG_HOOKS_PRINT_ERROR_FUNCTION, \
    LANG_HOOKS_EXPR_SIZE, \
Index: langhooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.h,v
retrieving revision 1.75
diff -c -2 -p -r1.75 langhooks.h
*** langhooks.h	17 Sep 2003 20:52:40 -0000	1.75
--- langhooks.h	3 Oct 2003 16:16:17 -0000
*************** struct lang_hooks
*** 379,382 ****
--- 379,385 ----
    const char *(*decl_printable_name) (tree decl, int verbosity);
  
+   /* Given a CALL_EXPR, return a function decl that is its target.  */
+   tree (*lang_get_callee_fndecl) (tree);
+ 
    /* Called by report_error_function to print out function name.  */
    void (*print_error_function) (struct diagnostic_context *, const char *);
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.330
diff -c -2 -p -r1.330 tree.c
*** tree.c	22 Sep 2003 05:09:12 -0000	1.330
--- tree.c	3 Oct 2003 16:16:18 -0000
*************** get_callee_fndecl (tree call)
*** 4440,4446 ****
        && TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL)
      return TREE_OPERAND (addr, 0);
! 
!   /* We couldn't figure out what was being called.  */
!   return NULL_TREE;
  }
  
--- 4440,4447 ----
        && TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL)
      return TREE_OPERAND (addr, 0);
!   
!   /* We couldn't figure out what was being called.  Maybe the front
!      end has some idea.  */
!   return (*lang_hooks.lang_get_callee_fndecl) (call);
  }
  

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: New langhook: lang_get_callee_fndecl
  2003-10-03 16:18 New langhook: lang_get_callee_fndecl Andrew Haley
@ 2003-10-03 20:56 ` Richard Henderson
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2003-10-03 20:56 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc

On Fri, Oct 03, 2003 at 05:17:58PM +0100, Andrew Haley wrote:
> 	* tree.c (get_callee_fndecl): Call
> 	lang_hooks.lang_get_callee_fndecl.
> 	* langhooks-def.h (LANG_HOOKS_GET_CALLEE_FNDECL): New.
> 	(lhd_get_callee_fndecl): New.

Ok.

For tree-ssa we probably should be using a METHOD_CALL_EXPR or
some such, so that we don't lower this information immediately.


r~

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-10-03 20:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-03 16:18 New langhook: lang_get_callee_fndecl Andrew Haley
2003-10-03 20:56 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).