OSDN Git Service

2005-04-13 Dale Johannesen <dalej@apple.com>
authordalej <dalej@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Apr 2005 19:28:31 +0000 (19:28 +0000)
committerdalej <dalej@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 13 Apr 2005 19:28:31 +0000 (19:28 +0000)
        * 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98105 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/objc/Make-lang.in
gcc/objc/objc-act.c
gcc/objc/objc-act.h
gcc/objc/objc-lang.c

index 1665353..f2ac5bb 100644 (file)
@@ -1,3 +1,13 @@
+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.
+
 2005-04-13  Devang Patel  <dpatel@apple.com>
 
        * tree-if-conv.c (tree_if_convert_cond_expr): Do not create extra
index 56fad72..10496c4 100644 (file)
@@ -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:
 
index 2c8a738..986fb9f 100644 (file)
@@ -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"
index 9925d96..4050303 100644 (file)
@@ -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.  */
index 375bed9..0d64dbd 100644 (file)
@@ -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;