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]

[PATCH][4.5 pre-approved] Kill expand_expr langhook


This patch, which basically makes COMPOUND_LITERAL_EXPR a GENERIC node
instead of making it C front-end specific was approved by Diego and has
been for a few months in LTO branch.

Besides the updates, this is just a little variant that does not
eliminate c-common.def; it just leaves an empty file because anyway
Joseph is going to add a C-specific tree code to it for the constant
expressions patch.  The only difference between the patch and what is
already in LTO is in Makefile.in.

Bootstrapped/regtested i686-pc-linux-gnu.

Paolo
2009-02-02  Paolo Bonzini  <bonzini@gnu.org>

	* c-common.c (c_expand_expr, c_staticp): Remove.
	* c-common.def (COMPOUND_LITERAL_EXPR): Delete.
	* c-common.h (emit_local_var, c_staticp, COMPOUND_LITERAL_EXPR_DECL,
	COMPOUND_LITERAL_EXPR_DECL_EXPR): Remove.
	* c-gimplify.c (gimplify_compound_literal_expr,
	optimize_compound_literals_in_ctor): Remove.
	(c_gimplify_expr): Remove COMPOUND_LITERAL_EXPR handling.
	* c-objc-common.h (LANG_HOOKS_STATICP): Remove.
	* c-semantics.c (emit_local_var): Remove.

	* langhooks-def.h (lhd_expand_expr): Remove.
	* langhooks.c (lhd_expand_expr): Remove.
	* langhooks.h (LANG_HOOKS_DEF): Remove LANG_HOOKS_EXPAND_EXPR.

	* expr.c (expand_expr_real_1): Move COMPOUND_LITERAL_EXPR
	handling from c-semantics.c; don't call into langhook.
	(expand_expr_addr_expr_1): Check that we don't get non-GENERIC trees.
	* gimplify.c (gimplify_compound_literal_expr,
	optimize_compound_literals_in_ctor): Move from c-gimplify.c.
	(gimplify_init_constructor): Call optimize_compound_literals_in_ctor.
	(gimplify_modify_expr_rhs, gimplify_expr): Handle COMPOUND_LITERAL_EXPR
	as was done in c-gimplify.c.
	* tree.c (staticp): Move COMPOUND_LITERAL_EXPR handling from c_staticp.
	* tree.h (COMPOUND_LITERAL_EXPR_DECL, COMPOUND_LITERAL_EXPR_DECL_EXPR):
	Move from c-common.h.
	* tree.def (COMPOUND_LITERAL_EXPR): Move from c-common.def.

	* doc/c-tree.texi (Expression nodes): Refer to DECL_EXPRs
	instead of DECL_STMTs.

cp:
2008-09-09  Paolo Bonzini  <bonzini@gnu.org>

	* cp-objcp-common.c (cxx_staticp): Change BASELINK case to unreachable.

Index: gcc/doc/c-tree.texi
===================================================================
--- gcc/doc/c-tree.texi	(revision 143864)
+++ gcc/doc/c-tree.texi	(working copy)
@@ -2636,10 +2636,10 @@ declaration order.  You should not assum
 represented.  Unrepresented fields will be set to zero.
 
 @item COMPOUND_LITERAL_EXPR
-@findex COMPOUND_LITERAL_EXPR_DECL_STMT
+@findex COMPOUND_LITERAL_EXPR_DECL_EXPR
 @findex COMPOUND_LITERAL_EXPR_DECL
 These nodes represent ISO C99 compound literals.  The
-@code{COMPOUND_LITERAL_EXPR_DECL_STMT} is a @code{DECL_STMT}
+@code{COMPOUND_LITERAL_EXPR_DECL_EXPR} is a @code{DECL_EXPR}
 containing an anonymous @code{VAR_DECL} for
 the unnamed object represented by the compound literal; the
 @code{DECL_INITIAL} of that @code{VAR_DECL} is a @code{CONSTRUCTOR}
Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 143864)
+++ gcc/tree.c	(working copy)
@@ -2098,8 +2098,7 @@ staticp (tree arg)
     case COMPONENT_REF:
       /* If the thing being referenced is not a field, then it is
 	 something language specific.  */
-      if (TREE_CODE (TREE_OPERAND (arg, 1)) != FIELD_DECL)
-	return (*lang_hooks.staticp) (arg);
+      gcc_assert (TREE_CODE (TREE_OPERAND (arg, 1)) == FIELD_DECL);
 
       /* If we are referencing a bitfield, we can't evaluate an
 	 ADDR_EXPR at compile time and so it isn't a constant.  */
@@ -2122,14 +2121,14 @@ staticp (tree arg)
 	  && TREE_CODE (TREE_OPERAND (arg, 1)) == INTEGER_CST)
 	return staticp (TREE_OPERAND (arg, 0));
       else
-	return false;
+	return NULL;
+
+    case COMPOUND_LITERAL_EXPR:
+      return TREE_STATIC (COMPOUND_LITERAL_EXPR_DECL (arg)) ? arg : NULL;
 
     default:
-      if ((unsigned int) TREE_CODE (arg)
-	  >= (unsigned int) LAST_AND_UNUSED_TREE_CODE)
-	return lang_hooks.staticp (arg);
-      else
-	return NULL;
+      gcc_assert (lang_hooks.staticp (arg) == NULL);
+      return NULL;
     }
 }
 
Index: gcc/tree.h
===================================================================
--- gcc/tree.h	(revision 143864)
+++ gcc/tree.h	(working copy)
@@ -1591,6 +1591,12 @@ extern void protected_set_expr_location 
 
 #define EXIT_EXPR_COND(NODE)	     TREE_OPERAND (EXIT_EXPR_CHECK (NODE), 0)
 
+/* COMPOUND_LITERAL_EXPR accessors.  */
+#define COMPOUND_LITERAL_EXPR_DECL_EXPR(NODE)		\
+  TREE_OPERAND (COMPOUND_LITERAL_EXPR_CHECK (NODE), 0)
+#define COMPOUND_LITERAL_EXPR_DECL(NODE)			\
+  DECL_EXPR_DECL (COMPOUND_LITERAL_EXPR_DECL_EXPR (NODE))
+
 /* SWITCH_EXPR accessors. These give access to the condition, body and
    original condition type (before any compiler conversions)
    of the switch statement, respectively.  */
Index: gcc/cp/cp-objcp-common.c
===================================================================
--- gcc/cp/cp-objcp-common.c	(revision 143864)
+++ gcc/cp/cp-objcp-common.c	(working copy)
@@ -194,7 +194,7 @@ cxx_staticp (tree arg)
   switch (TREE_CODE (arg))
     {
     case BASELINK:
-      return staticp (BASELINK_FUNCTIONS (arg));
+      gcc_unreachable ();
 
     default:
       break;
Index: gcc/c-objc-common.h
===================================================================
--- gcc/c-objc-common.h	(revision 143864)
+++ gcc/c-objc-common.h	(working copy)
@@ -51,8 +51,6 @@ extern void c_initialize_diagnostics (di
 #define LANG_HOOKS_PARSE_FILE c_common_parse_file
 #undef LANG_HOOKS_FINISH_INCOMPLETE_DECL
 #define LANG_HOOKS_FINISH_INCOMPLETE_DECL c_finish_incomplete_decl
-#undef LANG_HOOKS_STATICP
-#define LANG_HOOKS_STATICP c_staticp
 #undef LANG_HOOKS_NO_BODY_BLOCKS
 #define LANG_HOOKS_NO_BODY_BLOCKS true
 #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
Index: gcc/c-semantics.c
===================================================================
--- gcc/c-semantics.c	(revision 143864)
+++ gcc/c-semantics.c	(working copy)
@@ -1,6 +1,4 @@
-/* This file contains the definitions and documentation for the common
-   tree codes used in the GNU C and C++ compilers (see c-common.def
-   for the standard codes).
+/* This file contains subroutine used by the C front-end to construct GENERIC.
    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007
    Free Software Foundation, Inc.
    Written by Benjamin Chelf (chelf@codesourcery.com).
@@ -145,23 +143,6 @@ build_stmt (enum tree_code code, ...)
   return ret;
 }
 
-/* Let the back-end know about DECL.  */
-
-void
-emit_local_var (tree decl)
-{
-  /* Create RTL for this variable.  */
-  if (!DECL_RTL_SET_P (decl))
-    {
-      if (DECL_HARD_REGISTER (decl))
-	/* The user specified an assembler name for this variable.
-	   Set that up now.  */
-	rest_of_decl_compilation (decl, 0, 0);
-      else
-	expand_decl (decl);
-    }
-}
-
 /* Create a CASE_LABEL_EXPR tree node and return it.  */
 
 tree
Index: gcc/expr.c
===================================================================
--- gcc/expr.c	(revision 143864)
+++ gcc/expr.c	(working copy)
@@ -6821,9 +6821,10 @@ expand_expr_addr_expr_1 (tree exp, rtx t
 	 CONSTRUCTORs too, which should yield a memory reference for the
 	 constructor's contents.  Assume language specific tree nodes can
 	 be expanded in some interesting way.  */
+      gcc_assert (TREE_CODE (exp) < LAST_AND_UNUSED_TREE_CODE);
       if (DECL_P (exp)
 	  || TREE_CODE (exp) == CONSTRUCTOR
-	  || TREE_CODE (exp) >= LAST_AND_UNUSED_TREE_CODE)
+	  || TREE_CODE (exp) == COMPOUND_LITERAL_EXPR)
 	{
 	  result = expand_expr (exp, target, tmode,
 				modifier == EXPAND_INITIALIZER
@@ -8068,11 +8069,8 @@ expand_expr_real_1 (tree exp, rtx target
 	/* Check for a built-in function.  */
 	if (fndecl && DECL_BUILT_IN (fndecl))
 	  {
-	    if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_FRONTEND)
-	      return lang_hooks.expand_expr (exp, original_target,
-					     tmode, modifier, alt_rtl);
-	    else
-	      return expand_builtin (exp, target, subtarget, tmode, ignore);
+	    gcc_assert (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_FRONTEND);
+	    return expand_builtin (exp, target, subtarget, tmode, ignore);
 	  }
       }
       return expand_call (exp, target, ignore);
@@ -9459,9 +9457,29 @@ expand_expr_real_1 (tree exp, rtx target
       mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)));
       goto binop;
 
+    case COMPOUND_LITERAL_EXPR:
+      {
+	/* Initialize the anonymous variable declared in the compound
+	   literal, then return the variable.  */
+	tree decl = COMPOUND_LITERAL_EXPR_DECL (exp);
+
+	/* Create RTL for this variable.  */
+	if (!DECL_RTL_SET_P (decl))
+	  {
+	    if (DECL_HARD_REGISTER (decl))
+	      /* The user specified an assembler name for this variable.
+	         Set that up now.  */
+	      rest_of_decl_compilation (decl, 0, 0);
+	    else
+	      expand_decl (decl);
+	  }
+
+	return expand_expr_real (decl, original_target, tmode,
+				 modifier, alt_rtl);
+      }
+
     default:
-      return lang_hooks.expand_expr (exp, original_target, tmode,
-				     modifier, alt_rtl);
+      gcc_unreachable ();
     }
 
   /* Here to do an ordinary binary operator.  */
Index: gcc/langhooks.c
===================================================================
--- gcc/langhooks.c	(revision 143864)
+++ gcc/langhooks.c	(working copy)
@@ -216,17 +216,6 @@ lhd_get_alias_set (tree ARG_UNUSED (t))
   return -1;
 }
 
-/* This is the default expand_expr function.  */
-
-rtx
-lhd_expand_expr (tree ARG_UNUSED (t), rtx ARG_UNUSED (r),
-		 enum machine_mode ARG_UNUSED (mm),
-		 int ARG_UNUSED (em),
-		 rtx * ARG_UNUSED (a))
-{
-  gcc_unreachable ();
-}
-
 /* This is the default decl_printable_name function.  */
 
 const char *
Index: gcc/langhooks.h
===================================================================
--- gcc/langhooks.h	(revision 143864)
+++ gcc/langhooks.h	(working copy)
@@ -290,10 +290,6 @@ struct lang_hooks
      Returns -1 if the language does nothing special for it.  */
   alias_set_type (*get_alias_set) (tree);
 
-  /* Called by expand_expr for language-specific tree codes.
-     Fourth argument is actually an enum expand_modifier.  */
-  rtx (*expand_expr) (tree, rtx, enum machine_mode, int, rtx *);
-
   /* Function to finish handling an incomplete decl at the end of
      compilation.  Default hook is does nothing.  */
   void (*finish_incomplete_decl) (tree);
Index: gcc/gimplify.c
===================================================================
--- gcc/gimplify.c	(revision 143864)
+++ gcc/gimplify.c	(working copy)
@@ -3453,6 +3453,83 @@ rhs_predicate_for (tree lhs)
     return is_gimple_mem_or_call_rhs;
 }
 
+/* Gimplify a C99 compound literal expression.  This just means adding
+   the DECL_EXPR before the current statement and using its anonymous
+   decl instead.  */
+
+static enum gimplify_status
+gimplify_compound_literal_expr (tree *expr_p, gimple_seq *pre_p)
+{
+  tree decl_s = COMPOUND_LITERAL_EXPR_DECL_EXPR (*expr_p);
+  tree decl = DECL_EXPR_DECL (decl_s);
+  /* Mark the decl as addressable if the compound literal
+     expression is addressable now, otherwise it is marked too late
+     after we gimplify the initialization expression.  */
+  if (TREE_ADDRESSABLE (*expr_p))
+    TREE_ADDRESSABLE (decl) = 1;
+
+  /* Preliminarily mark non-addressed complex variables as eligible
+     for promotion to gimple registers.  We'll transform their uses
+     as we find them.  */
+  if ((TREE_CODE (TREE_TYPE (decl)) == COMPLEX_TYPE
+       || TREE_CODE (TREE_TYPE (decl)) == VECTOR_TYPE)
+      && !TREE_THIS_VOLATILE (decl)
+      && !needs_to_live_in_memory (decl))
+    DECL_GIMPLE_REG_P (decl) = 1;
+
+  /* This decl isn't mentioned in the enclosing block, so add it to the
+     list of temps.  FIXME it seems a bit of a kludge to say that
+     anonymous artificial vars aren't pushed, but everything else is.  */
+  if (DECL_NAME (decl) == NULL_TREE && !DECL_SEEN_IN_BIND_EXPR_P (decl))
+    gimple_add_tmp_var (decl);
+
+  gimplify_and_add (decl_s, pre_p);
+  *expr_p = decl;
+  return GS_OK;
+}
+
+/* Optimize embedded COMPOUND_LITERAL_EXPRs within a CONSTRUCTOR,
+   return a new CONSTRUCTOR if something changed.  */
+
+static tree
+optimize_compound_literals_in_ctor (tree orig_ctor)
+{
+  tree ctor = orig_ctor;
+  VEC(constructor_elt,gc) *elts = CONSTRUCTOR_ELTS (ctor);
+  unsigned int idx, num = VEC_length (constructor_elt, elts);
+
+  for (idx = 0; idx < num; idx++)
+    {
+      tree value = VEC_index (constructor_elt, elts, idx)->value;
+      tree newval = value;
+      if (TREE_CODE (value) == CONSTRUCTOR)
+	newval = optimize_compound_literals_in_ctor (value);
+      else if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR)
+	{
+	  tree decl_s = COMPOUND_LITERAL_EXPR_DECL_EXPR (value);
+	  tree decl = DECL_EXPR_DECL (decl_s);
+	  tree init = DECL_INITIAL (decl);
+
+	  if (!TREE_ADDRESSABLE (value)
+	      && !TREE_ADDRESSABLE (decl)
+	      && init)
+	    newval = optimize_compound_literals_in_ctor (init);
+	}
+      if (newval == value)
+	continue;
+
+      if (ctor == orig_ctor)
+	{
+	  ctor = copy_node (orig_ctor);
+	  CONSTRUCTOR_ELTS (ctor) = VEC_copy (constructor_elt, gc, elts);
+	  elts = CONSTRUCTOR_ELTS (ctor);
+	}
+      VEC_index (constructor_elt, elts, idx)->value = newval;
+    }
+  return ctor;
+}
+
+
 
 /* A subroutine of gimplify_modify_expr.  Break out elements of a
    CONSTRUCTOR used as an initializer into separate MODIFY_EXPRs.
@@ -3471,7 +3548,7 @@ static enum gimplify_status
 gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 			   bool want_value, bool notify_temp_creation)
 {
-  tree object;
+  tree object, new_ctor;
   tree ctor = TREE_OPERAND (*expr_p, 1);
   tree type = TREE_TYPE (ctor);
   enum gimplify_status ret;
@@ -3489,7 +3566,8 @@ gimplify_init_constructor (tree *expr_p,
     }
 
   object = TREE_OPERAND (*expr_p, 0);
-  elts = CONSTRUCTOR_ELTS (ctor);
+  new_ctor = optimize_compound_literals_in_ctor (ctor);
+  elts = CONSTRUCTOR_ELTS (new_ctor);
   ret = GS_ALL_DONE;
 
   switch (TREE_CODE (type))
@@ -4096,6 +4174,26 @@ gimplify_modify_expr_rhs (tree *expr_p, 
 	  return GS_OK;
 	}
 	
+      case COMPOUND_LITERAL_EXPR:
+	{
+	  tree complit = TREE_OPERAND (*expr_p, 1);
+	  tree decl_s = COMPOUND_LITERAL_EXPR_DECL_EXPR (complit);
+	  tree decl = DECL_EXPR_DECL (decl_s);
+	  tree init = DECL_INITIAL (decl);
+
+	  /* struct T x = (struct T) { 0, 1, 2 } can be optimized
+	     into struct T x = { 0, 1, 2 } if the address of the
+	     compound literal has never been taken.  */
+	  if (!TREE_ADDRESSABLE (complit)
+	      && !TREE_ADDRESSABLE (decl)
+	      && init)
+	    {
+	      *expr_p = copy_node (*expr_p);
+	      TREE_OPERAND (*expr_p, 1) = init;
+	      return GS_OK;
+	    }
+	}
+
       default:
 	ret = GS_UNHANDLED;
 	break;
@@ -6329,6 +6427,10 @@ gimplify_expr (tree *expr_p, gimple_seq 
 	  ret = gimplify_compound_expr (expr_p, pre_p, fallback != fb_none);
 	  break;
 
+	case COMPOUND_LITERAL_EXPR:
+	  ret = gimplify_compound_literal_expr (expr_p, pre_p);
+	  break;
+
 	case MODIFY_EXPR:
 	case INIT_EXPR:
 	  ret = gimplify_modify_expr (expr_p, pre_p, post_p,
Index: gcc/tree.def
===================================================================
--- gcc/tree.def	(revision 143864)
+++ gcc/tree.def	(working copy)
@@ -786,6 +786,13 @@ DEFTREECODE (NON_LVALUE_EXPR, "non_lvalu
    generating insns.  */
 DEFTREECODE (VIEW_CONVERT_EXPR, "view_convert_expr", tcc_reference, 1)
 
+/* A COMPOUND_LITERAL_EXPR represents a literal that is placed in a DECL.  The
+   COMPOUND_LITERAL_EXPR_DECL_EXPR is the a DECL_EXPR containing the decl
+   for the anonymous object represented by the COMPOUND_LITERAL;
+   the DECL_INITIAL of that decl is the CONSTRUCTOR that initializes
+   the compound literal.  */
+DEFTREECODE (COMPOUND_LITERAL_EXPR, "compound_literal_expr", tcc_expression, 1)
+
 /* Represents something we computed once and will use multiple times.
    First operand is that expression.  After it is evaluated once, it
    will be replaced by the temporary variable that holds the value.  */
Index: gcc/explow.c
===================================================================
--- gcc/explow.c	(revision 143864)
+++ gcc/explow.c	(working copy)
@@ -248,7 +248,7 @@ expr_size (tree exp)
     {
       size = lang_hooks.expr_size (exp);
       gcc_assert (size);
-      size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, exp);
+      gcc_assert (size == SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, exp));
     }
 
   return expand_expr (size, NULL_RTX, TYPE_MODE (sizetype), EXPAND_NORMAL);
Index: gcc/c-gimplify.c
===================================================================
--- gcc/c-gimplify.c	(revision 143864)
+++ gcc/c-gimplify.c	(working copy)
@@ -176,145 +176,25 @@ c_build_bind_expr (tree block, tree body
 
 /* Gimplification of expression trees.  */
 
-/* Gimplify a C99 compound literal expression.  This just means adding
-   the DECL_EXPR before the current statement and using its anonymous
-   decl instead.  */
-
-static enum gimplify_status
-gimplify_compound_literal_expr (tree *expr_p, gimple_seq *pre_p)
-{
-  tree decl_s = COMPOUND_LITERAL_EXPR_DECL_STMT (*expr_p);
-  tree decl = DECL_EXPR_DECL (decl_s);
-  /* Mark the decl as addressable if the compound literal
-     expression is addressable now, otherwise it is marked too late
-     after we gimplify the initialization expression.  */
-  if (TREE_ADDRESSABLE (*expr_p))
-    TREE_ADDRESSABLE (decl) = 1;
-
-  /* Preliminarily mark non-addressed complex variables as eligible
-     for promotion to gimple registers.  We'll transform their uses
-     as we find them.  */
-  if ((TREE_CODE (TREE_TYPE (decl)) == COMPLEX_TYPE
-       || TREE_CODE (TREE_TYPE (decl)) == VECTOR_TYPE)
-      && !TREE_THIS_VOLATILE (decl)
-      && !needs_to_live_in_memory (decl))
-    DECL_GIMPLE_REG_P (decl) = 1;
-
-  /* This decl isn't mentioned in the enclosing block, so add it to the
-     list of temps.  FIXME it seems a bit of a kludge to say that
-     anonymous artificial vars aren't pushed, but everything else is.  */
-  if (DECL_NAME (decl) == NULL_TREE && !DECL_SEEN_IN_BIND_EXPR_P (decl))
-    gimple_add_tmp_var (decl);
-
-  gimplify_and_add (decl_s, pre_p);
-  *expr_p = decl;
-  return GS_OK;
-}
-
-/* Optimize embedded COMPOUND_LITERAL_EXPRs within a CONSTRUCTOR,
-   return a new CONSTRUCTOR if something changed.  */
-
-static tree
-optimize_compound_literals_in_ctor (tree orig_ctor)
-{
-  tree ctor = orig_ctor;
-  VEC(constructor_elt,gc) *elts = CONSTRUCTOR_ELTS (ctor);
-  unsigned int idx, num = VEC_length (constructor_elt, elts);
-
-  for (idx = 0; idx < num; idx++)
-    {
-      tree value = VEC_index (constructor_elt, elts, idx)->value;
-      tree newval = value;
-      if (TREE_CODE (value) == CONSTRUCTOR)
-	newval = optimize_compound_literals_in_ctor (value);
-      else if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR)
-	{
-	  tree decl_s = COMPOUND_LITERAL_EXPR_DECL_STMT (value);
-	  tree decl = DECL_EXPR_DECL (decl_s);
-	  tree init = DECL_INITIAL (decl);
-
-	  if (!TREE_ADDRESSABLE (value)
-	      && !TREE_ADDRESSABLE (decl)
-	      && init)
-	    newval = init;
-	}
-      if (newval == value)
-	continue;
-
-      if (ctor == orig_ctor)
-	{
-	  ctor = copy_node (orig_ctor);
-	  CONSTRUCTOR_ELTS (ctor) = VEC_copy (constructor_elt, gc, elts);
-	  elts = CONSTRUCTOR_ELTS (ctor);
-	}
-      VEC_index (constructor_elt, elts, idx)->value = newval;
-    }
-  return ctor;
-}
-
 /* Do C-specific gimplification on *EXPR_P.  PRE_P and POST_P are as in
    gimplify_expr.  */
 
 int
-c_gimplify_expr (tree *expr_p, gimple_seq *pre_p,
+c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
 		 gimple_seq *post_p ATTRIBUTE_UNUSED)
 {
   enum tree_code code = TREE_CODE (*expr_p);
 
-  switch (code)
-    {
-    case DECL_EXPR:
-      /* This is handled mostly by gimplify.c, but we have to deal with
-	 not warning about int x = x; as it is a GCC extension to turn off
-	 this warning but only if warn_init_self is zero.  */
-      if (TREE_CODE (DECL_EXPR_DECL (*expr_p)) == VAR_DECL
-	  && !DECL_EXTERNAL (DECL_EXPR_DECL (*expr_p))
-	  && !TREE_STATIC (DECL_EXPR_DECL (*expr_p))
-	  && (DECL_INITIAL (DECL_EXPR_DECL (*expr_p))
-	      == DECL_EXPR_DECL (*expr_p))
-	  && !warn_init_self)
-	TREE_NO_WARNING (DECL_EXPR_DECL (*expr_p)) = 1;
-      return GS_UNHANDLED;
-
-    case COMPOUND_LITERAL_EXPR:
-      return gimplify_compound_literal_expr (expr_p, pre_p);
-
-    case INIT_EXPR:
-    case MODIFY_EXPR:
-      if (TREE_CODE (TREE_OPERAND (*expr_p, 1)) == COMPOUND_LITERAL_EXPR)
-	{
-	  tree complit = TREE_OPERAND (*expr_p, 1);
-	  tree decl_s = COMPOUND_LITERAL_EXPR_DECL_STMT (complit);
-	  tree decl = DECL_EXPR_DECL (decl_s);
-	  tree init = DECL_INITIAL (decl);
-
-	  /* struct T x = (struct T) { 0, 1, 2 } can be optimized
-	     into struct T x = { 0, 1, 2 } if the address of the
-	     compound literal has never been taken.  */
-	  if (!TREE_ADDRESSABLE (complit)
-	      && !TREE_ADDRESSABLE (decl)
-	      && init)
-	    {
-	      *expr_p = copy_node (*expr_p);
-	      TREE_OPERAND (*expr_p, 1) = init;
-	      return GS_OK;
-	    }
-	}
-      else if (TREE_CODE (TREE_OPERAND (*expr_p, 1)) == CONSTRUCTOR)
-	{
-	  tree ctor
-	    = optimize_compound_literals_in_ctor (TREE_OPERAND (*expr_p, 1));
-
-	  if (ctor != TREE_OPERAND (*expr_p, 1))
-	    {
-	      *expr_p = copy_node (*expr_p);
-	      TREE_OPERAND (*expr_p, 1) = ctor;
-	      return GS_OK;
-	    }
-	}
-      return GS_UNHANDLED;
+  /* This is handled mostly by gimplify.c, but we have to deal with
+     not warning about int x = x; as it is a GCC extension to turn off
+     this warning but only if warn_init_self is zero.  */
+  if (code == DECL_EXPR
+      && TREE_CODE (DECL_EXPR_DECL (*expr_p)) == VAR_DECL
+      && !DECL_EXTERNAL (DECL_EXPR_DECL (*expr_p))
+      && !TREE_STATIC (DECL_EXPR_DECL (*expr_p))
+      && (DECL_INITIAL (DECL_EXPR_DECL (*expr_p)) == DECL_EXPR_DECL (*expr_p))
+      && !warn_init_self)
+    TREE_NO_WARNING (DECL_EXPR_DECL (*expr_p)) = 1;
 
-    default:
-      return GS_UNHANDLED;
-    }
+  return GS_UNHANDLED;
 }
Index: gcc/c-common.c
===================================================================
--- gcc/c-common.c	(revision 143864)
+++ gcc/c-common.c	(working copy)
@@ -4981,43 +4981,6 @@ finish_label_address_expr (tree label, l
 
   return result;
 }
-
-/* Hook used by expand_expr to expand language-specific tree codes.  */
-/* The only things that should go here are bits needed to expand
-   constant initializers.  Everything else should be handled by the
-   gimplification routines.  */
-
-rtx
-c_expand_expr (tree exp, rtx target, enum machine_mode tmode,
-	       int modifiera /* Actually enum expand_modifier.  */,
-	       rtx *alt_rtl)
-{
-  enum expand_modifier modifier = (enum expand_modifier) modifiera;
-  switch (TREE_CODE (exp))
-    {
-    case COMPOUND_LITERAL_EXPR:
-      {
-	/* Initialize the anonymous variable declared in the compound
-	   literal, then return the variable.  */
-	tree decl = COMPOUND_LITERAL_EXPR_DECL (exp);
-	emit_local_var (decl);
-	return expand_expr_real (decl, target, tmode, modifier, alt_rtl);
-      }
-
-    default:
-      gcc_unreachable ();
-    }
-}
-
-/* Hook used by staticp to handle language-specific tree codes.  */
-
-tree
-c_staticp (tree exp)
-{
-  return (TREE_CODE (exp) == COMPOUND_LITERAL_EXPR
-	  && TREE_STATIC (COMPOUND_LITERAL_EXPR_DECL (exp))
-	  ? exp : NULL);
-}
 
 
 /* Given a boolean expression ARG, return a tree representing an increment
Index: gcc/c-common.h
===================================================================
--- gcc/c-common.h	(revision 143864)
+++ gcc/c-common.h	(working copy)
@@ -792,12 +792,6 @@ extern void finish_file	(void);
 #define STATEMENT_LIST_HAS_LABEL(NODE) \
   TREE_LANG_FLAG_3 (STATEMENT_LIST_CHECK (NODE))
 
-/* COMPOUND_LITERAL_EXPR accessors.  */
-#define COMPOUND_LITERAL_EXPR_DECL_STMT(NODE)		\
-  TREE_OPERAND (COMPOUND_LITERAL_EXPR_CHECK (NODE), 0)
-#define COMPOUND_LITERAL_EXPR_DECL(NODE)			\
-  DECL_EXPR_DECL (COMPOUND_LITERAL_EXPR_DECL_STMT (NODE))
-
 /* In a FIELD_DECL, nonzero if the decl was originally a bitfield.  */
 #define DECL_C_BIT_FIELD(NODE) \
   (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) == 1)
@@ -806,7 +800,6 @@ extern void finish_file	(void);
 #define CLEAR_DECL_C_BIT_FIELD(NODE) \
   (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) = 0)
 
-extern void emit_local_var (tree);
 extern tree do_case (tree, tree);
 extern tree build_stmt (enum tree_code, ...);
 extern tree build_case_label (tree, tree, tree);
@@ -855,8 +848,6 @@ extern bool vector_types_convertible_p (
 
 extern rtx c_expand_expr (tree, rtx, enum machine_mode, int, rtx *);
 
-extern tree c_staticp (tree);
-
 extern void init_c_lex (void);
 
 extern void c_cpp_builtins (cpp_reader *);
Index: gcc/c-common.def
===================================================================
--- gcc/c-common.def	(revision 143864)
+++ gcc/c-common.def	(working copy)
@@ -24,13 +24,6 @@ along with GCC; see the file COPYING3.  
 /* Tree nodes used in the C frontend.  These are also shared with the
    C++ and Objective C frontends.  */
 
-/* A COMPOUND_LITERAL_EXPR represents a C99 compound literal.  The
-   COMPOUND_LITERAL_EXPR_DECL_STMT is the a DECL_STMT containing the decl
-   for the anonymous object represented by the COMPOUND_LITERAL;
-   the DECL_INITIAL of that decl is the CONSTRUCTOR that initializes
-   the compound literal.  */
-DEFTREECODE (COMPOUND_LITERAL_EXPR, "compound_literal_expr", tcc_expression, 1)
-
 /*
 Local variables:
 mode:c
Index: gcc/langhooks-def.h
===================================================================
--- gcc/langhooks-def.h	(revision 143864)
+++ gcc/langhooks-def.h	(working copy)
@@ -50,7 +50,6 @@ extern void lhd_print_tree_nothing (FILE
 extern const char *lhd_decl_printable_name (tree, int);
 extern const char *lhd_dwarf_name (tree, int);
 extern int lhd_types_compatible_p (tree, tree);
-extern rtx lhd_expand_expr (tree, rtx, enum machine_mode, int, rtx *);
 extern void lhd_print_error_function (struct diagnostic_context *,
 				      const char *, struct diagnostic_info *);
 extern void lhd_set_decl_assembler_name (tree);
@@ -91,7 +90,6 @@ extern void lhd_omp_firstprivatize_type_
 #define LANG_HOOKS_POST_OPTIONS		lhd_post_options
 #define LANG_HOOKS_MISSING_NORETURN_OK_P hook_bool_tree_true
 #define LANG_HOOKS_GET_ALIAS_SET	lhd_get_alias_set
-#define LANG_HOOKS_EXPAND_EXPR		lhd_expand_expr
 #define LANG_HOOKS_FINISH_INCOMPLETE_DECL lhd_do_nothing_t
 #define LANG_HOOKS_STATICP		lhd_staticp
 #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL lhd_do_nothing_t
@@ -239,7 +237,6 @@ extern tree lhd_make_node (enum tree_cod
   LANG_HOOKS_PARSE_FILE, \
   LANG_HOOKS_MISSING_NORETURN_OK_P, \
   LANG_HOOKS_GET_ALIAS_SET, \
-  LANG_HOOKS_EXPAND_EXPR, \
   LANG_HOOKS_FINISH_INCOMPLETE_DECL, \
   LANG_HOOKS_MARK_ADDRESSABLE, \
   LANG_HOOKS_STATICP, \

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