diff options
author | Dale Johannesen <dalej@apple.com> | 2005-04-13 19:28:31 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@gcc.gnu.org> | 2005-04-13 19:28:31 +0000 |
commit | 43f479d63f975ff0cf56b54ce5fc78e35a6c8d3c (patch) | |
tree | ef7ffb91458818196375fa47f24e3c65567c411e /gcc/objc | |
parent | f3b2c50692aa4ed501968c09e74fdb4a7474c589 (diff) | |
download | gcc-43f479d63f975ff0cf56b54ce5fc78e35a6c8d3c.zip gcc-43f479d63f975ff0cf56b54ce5fc78e35a6c8d3c.tar.gz gcc-43f479d63f975ff0cf56b54ce5fc78e35a6c8d3c.tar.bz2 |
Make-lang.in (objc-lang.o): Depend on tree-gimple.h.
2005-04-13 Dale Johannesen <dalej@apple.com>
* objc/Make-lang.in (objc-lang.o): Depend on tree-gimple.h.
(objc-act.o): Ditto.
* objc/objc-act.c (objc_gimplify_expr): New.
(objc_get_callee_fndecl): New.
* objc/objc-act.h: Include tree-gimple.h. Declare new functions.
* objc/objc-lang.c (LANG_HOOKS_GIMPLIFY_EXPR): Define.
(LANG_HOOKS_GET_CALLEE_FNDECL): Define.
From-SVN: r98105
Diffstat (limited to 'gcc/objc')
-rw-r--r-- | gcc/objc/Make-lang.in | 4 | ||||
-rw-r--r-- | gcc/objc/objc-act.c | 49 | ||||
-rw-r--r-- | gcc/objc/objc-act.h | 5 | ||||
-rw-r--r-- | gcc/objc/objc-lang.c | 4 |
4 files changed, 60 insertions, 2 deletions
diff --git a/gcc/objc/Make-lang.in b/gcc/objc/Make-lang.in index 56fad72..10496c4 100644 --- a/gcc/objc/Make-lang.in +++ b/gcc/objc/Make-lang.in @@ -60,13 +60,13 @@ objc/objc-lang.o : objc/objc-lang.c \ $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ $(C_TREE_H) $(C_PRETTY_PRINT_H) $(DIAGNOSTIC_H) \ $(GGC_H) langhooks.h $(LANGHOOKS_DEF_H) $(C_COMMON_H) gtype-objc.h \ - c-objc-common.h objc/objc-act.h + c-objc-common.h objc/objc-act.h tree-gimple.h objc/objc-act.o : objc/objc-act.c \ $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_H) $(TM_P_H) \ $(EXPR_H) $(TARGET_H) $(C_TREE_H) diagnostic.h toplev.h flags.h \ objc/objc-act.h input.h function.h output.h debug.h langhooks.h \ - $(LANGHOOKS_DEF_H) $(HASHTAB_H) c-pragma.h gt-objc-objc-act.h + $(LANGHOOKS_DEF_H) $(HASHTAB_H) c-pragma.h gt-objc-objc-act.h tree-gimple.h objc.srcextra: diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 2c8a738..986fb9f 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -8569,4 +8569,53 @@ objc_lookup_ivar (tree other, tree id) return build_ivar_reference (id); } +/* Look for the special case of OBJC_TYPE_REF with the address of + a function in OBJ_TYPE_REF_EXPR (presumably objc_msgSend or one + of its cousins). */ + +enum gimplify_status objc_gimplify_expr (tree *expr_p, tree *pre_p, + tree *post_p) +{ + enum gimplify_status r0, r1; + if (TREE_CODE (*expr_p) == OBJ_TYPE_REF + && TREE_CODE (OBJ_TYPE_REF_EXPR (*expr_p)) == ADDR_EXPR + && TREE_CODE (TREE_OPERAND (OBJ_TYPE_REF_EXPR (*expr_p), 0)) + == FUNCTION_DECL) + { + /* Postincrements in OBJ_TYPE_REF_OBJECT don't affect the + value of the OBJ_TYPE_REF, so force them to be emitted + during subexpression evaluation rather than after the + OBJ_TYPE_REF. This permits objc_msgSend calls in Objective + C to use direct rather than indirect calls when the + object expression has a postincrement. */ + r0 = gimplify_expr (&OBJ_TYPE_REF_OBJECT (*expr_p), pre_p, NULL, + is_gimple_val, fb_rvalue); + r1 = gimplify_expr (&OBJ_TYPE_REF_EXPR (*expr_p), pre_p, post_p, + is_gimple_val, fb_rvalue); + return MIN (r0, r1); + } + return c_gimplify_expr (expr_p, pre_p, post_p); +} + +/* Given a CALL expression, find the function being called. The ObjC + version looks for the OBJ_TYPE_REF_EXPR which is used for objc_msgSend. */ + +tree +objc_get_callee_fndecl (tree call_expr) +{ + tree addr = TREE_OPERAND (call_expr, 0); + if (TREE_CODE (addr) != OBJ_TYPE_REF) + return 0; + + addr = OBJ_TYPE_REF_EXPR (addr); + + /* If the address is just `&f' for some function `f', then we know + that `f' is being called. */ + if (TREE_CODE (addr) == ADDR_EXPR + && TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL) + return TREE_OPERAND (addr, 0); + + return 0; +} + #include "gt-objc-objc-act.h" diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h index 9925d96..4050303 100644 --- a/gcc/objc/objc-act.h +++ b/gcc/objc/objc-act.h @@ -22,13 +22,18 @@ Boston, MA 02111-1307, USA. */ #ifndef GCC_OBJC_ACT_H #define GCC_OBJC_ACT_H +/* For enum gimplify_status */ +#include "tree-gimple.h" + /*** Language hooks ***/ bool objc_init (void); const char *objc_printable_name (tree, int); +tree objc_get_callee_fndecl (tree); void objc_finish_file (void); tree objc_fold_obj_type_ref (tree, tree); int objc_types_compatible_p (tree, tree); +enum gimplify_status objc_gimplify_expr (tree *, tree *, tree *); /* NB: The remaining public functions are prototyped in c-common.h, for the benefit of stub-objc.c and objc-act.c. */ diff --git a/gcc/objc/objc-lang.c b/gcc/objc/objc-lang.c index 375bed9..0d64dbd 100644 --- a/gcc/objc/objc-lang.c +++ b/gcc/objc/objc-lang.c @@ -47,6 +47,10 @@ enum c_language_kind c_language = clk_objc; #define LANG_HOOKS_DECL_PRINTABLE_NAME objc_printable_name #undef LANG_HOOKS_TYPES_COMPATIBLE_P #define LANG_HOOKS_TYPES_COMPATIBLE_P objc_types_compatible_p +#undef LANG_HOOKS_GIMPLIFY_EXPR +#define LANG_HOOKS_GIMPLIFY_EXPR objc_gimplify_expr +#undef LANG_HOOKS_GET_CALLEE_FNDECL +#define LANG_HOOKS_GET_CALLEE_FNDECL objc_get_callee_fndecl /* Each front end provides its own lang hook initializer. */ const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; |