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]

lang_expand_expr langhook


This was awkward to do, because the prototype uses an enumeration
defined only in expr.h.  I took the liberty of duplicating the
declaration in tree.h, and conditionally compiling both.  If people
don't like this, I can

1) Have everything including langhooks.h also include expr.h, leaving
   the declaration there.
2) Have everything including expr.h also include tree.h with the
   declaration there.
3) Break it out into its own guarded header, and include it from both
   expr.h and tree.h.

If so, let me know which, and I'll fix it in a followup.  Meanwhile
I'd like to apply this.  OK?

Neil.

	* Makefile.in (langhooks.o): Update.
	* c-common.h (c_expand_expr): Always declare.
	* c-lang.c (LANG_HOOKS_EXPAND_EXPR): Redefine.
	* c-objc-common.c (c_objc_common_init): No global hook.
	* expr.c (expand_expr): Use langhook.
	* expr.h (enum expand_modifier): Conditionally declare.
	* langhooks-def.h (lhd_expand_expr, LANG_HOOKS_EXPAND_EXPR): New.
	(LANG_HOOKS_INITIALIZER): Update.
	* langhooks.c: Include expr.h.
	(lhd_expand_expr): New.
	* langhooks.h (struct lang_hooks): New hook.
	* toplev.c (lang_expand_expr_t, lang_expand_expr): Delete.
	(lang_independent_init): Don't default hook.
	* tree.h (enum expand_modifier): Conditionally declare.
ada:
	* misc.c (LANG_HOOKS_EXPAND_EXPR): Redefine.
	(gnat_init): Don't set hook.
cp:
	* cp-lang.c (LANG_HOOKS_EXPAND_EXPR): Redefine.
	* cp-tree.h (init_cplus_expand): Remove.
	(cxx_expand_expr): New.
	* expr.c (cplus_expand_expr): Rename cxx_expand_expr.
	Not static.
	(init_cplus_expand): Remove.
	* lex.c (cxx_init): Don't call init_cplus_expand.
java:
	* expr.c (java_lang_expand_expr): Rename java_expand_expr.
	* java-tree.h (java_lang_expand_expr): Similarly.
	* lang.c (LANG_HOOKS_EXPAND_EXPR): Redefine.
	(java_init): Don't set hook.
objc:
	* objc-lang.c (LANG_HOOKS_EXPAND_EXPR): Redefine.

============================================================
Index: gcc/Makefile.in
--- gcc/Makefile.in	2002/03/26 07:15:34	1.847
+++ gcc/Makefile.in	2002/03/26 19:57:34
@@ -1323,7 +1323,7 @@ convert.o: convert.c $(CONFIG_H) $(SYSTE
 
 langhooks.o : langhooks.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) toplev.h \
    tree-inline.h $(RTL_H) insn-config.h integrate.h langhooks.h \
-   langhooks-def.h flags.h
+   langhooks-def.h flags.h expr.h
 tree.o : tree.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) flags.h function.h toplev.h \
    $(GGC_H) $(HASHTAB_H) $(TARGET_H) output.h $(TM_P_H) langhooks.h
 tree-dump.o: tree-dump.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \
============================================================
Index: gcc/c-common.h
--- gcc/c-common.h	2002/03/24 12:27:27	1.121
+++ gcc/c-common.h	2002/03/26 19:57:37
@@ -844,10 +844,8 @@ extern tree lookup_label			PARAMS ((tree
 
 /* enum expand_modified is in expr.h, as is the macro below.  */
 
-#ifdef QUEUED_VAR
 extern rtx c_expand_expr            PARAMS ((tree, rtx, enum machine_mode,
 					     enum expand_modifier));
-#endif
 
 extern int c_safe_from_p                        PARAMS ((rtx, tree));
 
============================================================
Index: gcc/c-lang.c
--- gcc/c-lang.c	2002/03/26 07:15:35	1.79
+++ gcc/c-lang.c	2002/03/26 19:57:37
@@ -52,6 +52,8 @@ static void c_post_options PARAMS ((void
 #define LANG_HOOKS_SAFE_FROM_P c_safe_from_p
 #undef LANG_HOOKS_MARK_TREE
 #define LANG_HOOKS_MARK_TREE c_mark_tree
+#undef LANG_HOOKS_EXPAND_EXPR
+#define LANG_HOOKS_EXPAND_EXPR c_expand_expr
 #undef LANG_HOOKS_PARSE_FILE
 #define LANG_HOOKS_PARSE_FILE c_common_parse_file
 #undef LANG_HOOKS_STATICP
============================================================
Index: gcc/c-objc-common.c
--- gcc/c-objc-common.c	2002/03/24 12:27:28	1.7
+++ gcc/c-objc-common.c	2002/03/26 19:57:38
@@ -225,7 +225,6 @@ c_objc_common_init (filename)
   save_lang_status = &push_c_function_context;
   restore_lang_status = &pop_c_function_context;
   mark_lang_status = &mark_c_function_context;
-  lang_expand_expr = c_expand_expr;
   lang_expand_decl_stmt = c_expand_decl_stmt;
 
   /* These were not defined in the Objective-C front end, but I'm
============================================================
Index: gcc/expr.c
--- gcc/expr.c	2002/03/25 19:10:40	1.437
+++ gcc/expr.c	2002/03/26 19:58:05
@@ -7240,7 +7240,8 @@ expand_expr (exp, target, tmode, modifie
         {
 	  if (DECL_BUILT_IN_CLASS (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
 	      == BUILT_IN_FRONTEND)
-	    return (*lang_expand_expr) (exp, original_target, tmode, modifier);
+	    return (*lang_hooks.expand_expr)
+	      (exp, original_target, tmode, modifier);
 	  else
 	    return expand_builtin (exp, target, subtarget, tmode, ignore);
 	}
@@ -8800,7 +8801,7 @@ expand_expr (exp, target, tmode, modifie
       abort ();
 
     default:
-      return (*lang_expand_expr) (exp, original_target, tmode, modifier);
+      return (*lang_hooks.expand_expr) (exp, original_target, tmode, modifier);
     }
 
   /* Here to do an ordinary binary operator, generating an instruction
============================================================
Index: gcc/expr.h
--- gcc/expr.h	2002/03/26 09:06:11	1.111
+++ gcc/expr.h	2002/03/26 19:58:05
@@ -49,8 +49,10 @@ Software Foundation, 59 Temple Place - S
    EXPAND_CONST_ADDRESS means it is ok to return a MEM whose address
     is a constant that is not a legitimate address.
    EXPAND_WRITE means we are only going to write to the resulting rtx.  */
+#ifndef TREE_CODE
 enum expand_modifier {EXPAND_NORMAL, EXPAND_SUM, EXPAND_CONST_ADDRESS,
 			EXPAND_INITIALIZER, EXPAND_WRITE};
+#endif
 
 /* Prevent the compiler from deferring stack pops.  See
    inhibit_defer_pop for more information.  */
============================================================
Index: gcc/langhooks-def.h
--- gcc/langhooks-def.h	2002/03/26 07:15:36	1.16
+++ gcc/langhooks-def.h	2002/03/26 19:58:05
@@ -49,6 +49,8 @@ extern void lhd_clear_binding_stack PARA
 extern void lhd_print_tree_nothing PARAMS ((FILE *, tree, int));
 extern const char *lhd_decl_printable_name PARAMS ((tree, int));
 extern void lhd_set_yydebug PARAMS ((int));
+extern rtx lhd_expand_expr PARAMS ((tree, rtx, enum machine_mode,
+				    enum expand_modifier));
 
 /* Declarations of default tree inlining hooks.  */
 tree lhd_tree_inlining_walk_subtrees		PARAMS ((tree *, int *,
@@ -78,6 +80,7 @@ tree lhd_tree_inlining_convert_parm_for_
 #define LANG_HOOKS_POST_OPTIONS		lhd_do_nothing
 #define LANG_HOOKS_GET_ALIAS_SET	lhd_get_alias_set
 #define LANG_HOOKS_EXPAND_CONSTANT	lhd_return_tree
+#define LANG_HOOKS_EXPAND_EXPR		lhd_expand_expr
 #define LANG_HOOKS_SAFE_FROM_P		lhd_safe_from_p
 #define LANG_HOOKS_STATICP		lhd_staticp
 #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL lhd_do_nothing_t
@@ -174,6 +177,7 @@ int lhd_tree_dump_type_quals			PARAMS ((
   LANG_HOOKS_CLEAR_BINDING_STACK, \
   LANG_HOOKS_GET_ALIAS_SET, \
   LANG_HOOKS_EXPAND_CONSTANT, \
+  LANG_HOOKS_EXPAND_EXPR, \
   LANG_HOOKS_SAFE_FROM_P, \
   LANG_HOOKS_STATICP, \
   LANG_HOOKS_DUP_LANG_SPECIFIC_DECL, \
============================================================
Index: gcc/langhooks.c
--- gcc/langhooks.c	2002/03/25 19:10:41	1.22
+++ gcc/langhooks.c	2002/03/26 19:58:06
@@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA.  */
 #include "insn-config.h"
 #include "integrate.h"
 #include "flags.h"
+#include "expr.h"
 #include "langhooks.h"
 #include "langhooks-def.h"
 
@@ -141,6 +142,18 @@ hook_get_alias_set_0 (t)
      tree t ATTRIBUTE_UNUSED;
 {
   return 0;
+}
+
+/* This is the default expand_expr function.  */
+
+rtx
+lhd_expand_expr (t, r, mm, em)
+     tree t;
+     rtx r;
+     enum machine_mode mm;
+     enum expand_modifier em;
+{
+  return expand_expr (t, r, mm, em);
 }
 
 /* This is the default decl_printable_name function.  */
============================================================
Index: gcc/langhooks.h
--- gcc/langhooks.h	2002/03/26 07:15:36	1.23
+++ gcc/langhooks.h	2002/03/26 19:58:06
@@ -21,6 +21,8 @@ Boston, MA 02111-1307, USA.  */
 #ifndef GCC_LANG_HOOKS_H
 #define GCC_LANG_HOOKS_H
 
+/* This file should be #include-d after tree.h.  */
+
 /* A print hook for print_tree ().  */
 typedef void (*lang_print_tree_hook) PARAMS ((FILE *, tree, int indent));
 
@@ -158,6 +160,10 @@ struct lang_hooks
      Returns either the same expression or a language-independent
      constant equivalent to its input.  */
   tree (*expand_constant) PARAMS ((tree));
+
+  /* Called by expand_expr for language-specific tree codes.  */
+  rtx (*expand_expr) PARAMS ((tree, rtx, enum machine_mode,
+			      enum expand_modifier modifier));
 
   /* Hook called by safe_from_p for language-specific tree codes.  It is
      up to the language front-end to install a hook if it has any such
============================================================
Index: gcc/toplev.c
--- gcc/toplev.c	2002/03/26 15:36:35	1.604
+++ gcc/toplev.c	2002/03/26 19:58:17
@@ -349,14 +349,6 @@ tree current_function_decl;
    if none.  */
 tree current_function_func_begin_label;
 
-/* Pointer to function to compute rtl for a language-specific tree code.  */
-
-typedef rtx (*lang_expand_expr_t)
-  PARAMS ((union tree_node *, rtx, enum machine_mode,
-	  enum expand_modifier modifier));
-
-lang_expand_expr_t lang_expand_expr = 0;
-
 /* Pointer to function to finish handling an incomplete decl at the
    end of compilation.  */
 
@@ -4942,8 +4934,6 @@ process_options ()
 static void
 lang_independent_init ()
 {
-  lang_expand_expr = (lang_expand_expr_t) do_abort;
-
   /* Initialize the garbage-collector, and string pools.  */
   init_ggc ();
   ggc_add_rtx_root (&stack_limit_rtx, 1);
============================================================
Index: gcc/tree.h
--- gcc/tree.h	2002/03/25 19:10:42	1.318
+++ gcc/tree.h	2002/03/26 19:58:27
@@ -77,6 +77,17 @@ enum built_in_class
 /* Names for the above.  */
 extern const char *const built_in_class_names[4];
 
+/* This is the 4th arg to `expand_expr'.
+   EXPAND_SUM means it is ok to return a PLUS rtx or MULT rtx.
+   EXPAND_INITIALIZER is similar but also record any labels on forced_labels.
+   EXPAND_CONST_ADDRESS means it is ok to return a MEM whose address
+    is a constant that is not a legitimate address.
+   EXPAND_WRITE means we are only going to write to the resulting rtx.  */
+#ifndef QUEUED_VAR
+enum expand_modifier {EXPAND_NORMAL, EXPAND_SUM, EXPAND_CONST_ADDRESS,
+			EXPAND_INITIALIZER, EXPAND_WRITE};
+#endif
+
 /* Codes that identify the various built in functions
    so that expand_call can identify them quickly.  */
 
============================================================
Index: gcc/ada/misc.c
--- gcc/ada/misc.c	2002/03/26 07:15:51	1.26
+++ gcc/ada/misc.c	2002/03/26 19:58:29
@@ -108,6 +108,8 @@ static void gnat_mark_tree		PARAMS ((tre
 #define LANG_HOOKS_HONOR_READONLY	1
 #undef LANG_HOOKS_GET_ALIAS_SET
 #define LANG_HOOKS_GET_ALIAS_SET	gnat_get_alias_set
+#undef LANG_HOOKS_EXPAND_EXPR
+#define LANG_HOOKS_EXPAND_EXPR		gnat_expand_expr
 #undef LANG_HOOKS_PRINT_DECL
 #define LANG_HOOKS_PRINT_DECL		gnat_print_decl
 #undef LANG_HOOKS_PRINT_TYPE
@@ -361,8 +363,6 @@ gnat_init (filename)
 
      Define the additional tree codes here.  This isn't the best place to put
      it, but it's where g++ does it.  */
-
-  lang_expand_expr = gnat_expand_expr;
 
   gnat_init_decl_processing ();
 
============================================================
Index: gcc/cp/cp-lang.c
--- gcc/cp/cp-lang.c	2002/03/26 07:15:54	1.17
+++ gcc/cp/cp-lang.c	2002/03/26 19:58:31
@@ -49,6 +49,8 @@ static bool ok_to_generate_alias_set_for
 #define LANG_HOOKS_GET_ALIAS_SET cxx_get_alias_set
 #undef LANG_HOOKS_EXPAND_CONSTANT
 #define LANG_HOOKS_EXPAND_CONSTANT cplus_expand_constant
+#undef LANG_HOOKS_EXPAND_EXPR
+#define LANG_HOOKS_EXPAND_EXPR cxx_expand_expr
 #undef LANG_HOOKS_SAFE_FROM_P
 #define LANG_HOOKS_SAFE_FROM_P c_safe_from_p
 #undef LANG_HOOKS_PARSE_FILE
============================================================
Index: gcc/cp/cp-tree.h
--- gcc/cp/cp-tree.h	2002/03/26 18:16:19	1.697
+++ gcc/cp/cp-tree.h	2002/03/26 19:58:42
@@ -3907,8 +3907,11 @@ extern void check_handlers			PARAMS ((tr
 extern void choose_personality_routine		PARAMS ((enum languages));
 
 /* in expr.c */
-extern void init_cplus_expand			PARAMS ((void));
 extern int extract_init				PARAMS ((tree, tree));
+extern rtx cxx_expand_expr			PARAMS ((tree, rtx,
+							 enum machine_mode,
+							 enum expand_modifier));
+
 extern tree cplus_expand_constant               PARAMS ((tree));
 
 /* friend.c */
============================================================
Index: gcc/cp/expr.c
--- gcc/cp/expr.c	2002/01/23 14:25:56	1.63
+++ gcc/cp/expr.c	2002/03/26 19:58:43
@@ -32,9 +32,6 @@ Boston, MA 02111-1307, USA.  */
 #include "except.h"
 #include "tm_p.h"
 
-static rtx cplus_expand_expr PARAMS ((tree, rtx, enum machine_mode,
-				    enum expand_modifier));
-
 /* Hook used by output_constant to expand language-specific
    constants.  */
 
@@ -79,8 +76,8 @@ cplus_expand_constant (cst)
 
 /* Hook used by expand_expr to expand language-specific tree codes.  */
 
-static rtx
-cplus_expand_expr (exp, target, tmode, modifier)
+rtx
+cxx_expand_expr (exp, target, tmode, modifier)
      tree exp;
      rtx target;
      enum machine_mode tmode;
@@ -129,12 +126,6 @@ cplus_expand_expr (exp, target, tmode, m
   abort ();
   /* NOTREACHED */
   return NULL;
-}
-
-void
-init_cplus_expand ()
-{
-  lang_expand_expr = cplus_expand_expr;
 }
 
 int
============================================================
Index: gcc/cp/lex.c
--- gcc/cp/lex.c	2002/03/24 12:27:42	1.271
+++ gcc/cp/lex.c	2002/03/26 19:58:47
@@ -647,7 +647,6 @@ cxx_init (filename)
   init_reswords ();
   init_spew ();
   init_tree ();
-  init_cplus_expand ();
   init_cp_semantics ();
 
   lang_unsafe_for_reeval = c_unsafe_for_reeval;
============================================================
Index: gcc/java/expr.c
--- gcc/java/expr.c	2002/03/23 01:19:40	1.138
+++ gcc/java/expr.c	2002/03/26 19:58:54
@@ -2490,7 +2490,7 @@ get_primitive_array_vtable (tree elt)
 }
 
 struct rtx_def *
-java_lang_expand_expr (exp, target, tmode, modifier)
+java_expand_expr (exp, target, tmode, modifier)
      register tree exp;
      rtx target;
      enum machine_mode tmode;
============================================================
Index: gcc/java/java-tree.h
--- gcc/java/java-tree.h	2002/03/26 07:16:00	1.141
+++ gcc/java/java-tree.h	2002/03/26 19:58:59
@@ -1250,8 +1250,8 @@ extern int predefined_filename_p PARAMS 
 /* We use ARGS_SIZE_RTX to indicate that gcc/expr.h has been included
    to declare `enum expand_modifier'. */
 #if defined (TREE_CODE) && defined(RTX_CODE) && defined (HAVE_MACHINE_MODES) && defined (ARGS_SIZE_RTX)
-struct rtx_def * java_lang_expand_expr PARAMS ((tree, rtx, enum machine_mode,
-					       enum expand_modifier)); 
+struct rtx_def * java_expand_expr PARAMS ((tree, rtx, enum machine_mode,
+					   enum expand_modifier)); 
 #endif /* TREE_CODE && RTX_CODE && HAVE_MACHINE_MODES && ARGS_SIZE_RTX */
 
 #define DECL_FINAL(DECL) DECL_LANG_FLAG_3 (DECL)
============================================================
Index: gcc/java/lang.c
--- gcc/java/lang.c	2002/03/26 07:16:00	1.92
+++ gcc/java/lang.c	2002/03/26 19:59:00
@@ -225,6 +225,8 @@ static int dependency_tracking = 0;
 #define LANG_HOOKS_PARSE_FILE java_parse_file
 #undef LANG_HOOKS_MARK_TREE
 #define LANG_HOOKS_MARK_TREE java_mark_tree
+#undef LANG_HOOKS_EXPAND_EXPR
+#define LANG_HOOKS_EXPAND_EXPR java_expand_expr
 #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
 #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL java_dup_lang_specific_decl
 #undef LANG_HOOKS_DECL_PRINTABLE_NAME
@@ -511,7 +513,6 @@ java_init (filename)
   jcf_path_seal (version_flag);
 
   print_error_function = lang_print_error;
-  lang_expand_expr = java_lang_expand_expr;
 
   java_init_decl_processing ();
 
============================================================
Index: gcc/objc/objc-lang.c
--- gcc/objc/objc-lang.c	2002/03/26 07:16:01	1.8
+++ gcc/objc/objc-lang.c	2002/03/26 19:59:00
@@ -48,6 +48,8 @@ static void objc_post_options           
 #define LANG_HOOKS_PARSE_FILE c_common_parse_file
 #undef LANG_HOOKS_MARK_TREE
 #define LANG_HOOKS_MARK_TREE c_mark_tree
+#undef LANG_HOOKS_EXPAND_EXPR
+#define LANG_HOOKS_EXPAND_EXPR c_expand_expr
 #undef LANG_HOOKS_STATICP
 #define LANG_HOOKS_STATICP c_staticp
 #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL


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