OSDN Git Service

2009-04-09 Paolo Bonzini <bonzini@gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / java / java-gimplify.c
index 5358241..e2ad02b 100644 (file)
@@ -1,5 +1,6 @@
 /* Java(TM) language-specific gimplification routines.
-   Copyright (C) 2003, 2004, 2006, 2007, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2006, 2007, 2007, 2008
+   Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -28,12 +29,13 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "tree.h"
 #include "java-tree.h"
 #include "tree-dump.h"
-#include "tree-gimple.h"
+#include "gimple.h"
 #include "toplev.h"
 
 static tree java_gimplify_block (tree);
 static enum gimplify_status java_gimplify_modify_expr (tree *);
-static enum gimplify_status java_gimplify_self_mod_expr (tree*, tree*, tree *);
+static enum gimplify_status java_gimplify_self_mod_expr (tree *, gimple_seq *,
+                                                        gimple_seq *);
 
 static void dump_java_tree (enum tree_dump_index, tree);
 
@@ -53,8 +55,7 @@ java_genericize (tree fndecl)
 /* Gimplify a Java tree.  */
 
 int
-java_gimplify_expr (tree *expr_p, tree *pre_p ATTRIBUTE_UNUSED,
-                   tree *post_p ATTRIBUTE_UNUSED)
+java_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 {
   enum tree_code code = TREE_CODE (*expr_p);
 
@@ -68,9 +69,6 @@ java_gimplify_expr (tree *expr_p, tree *pre_p ATTRIBUTE_UNUSED,
       *expr_p = java_replace_reference (*expr_p, /* want_lvalue */ false);
       return GS_UNHANDLED;
 
-      /* We don't handle GIMPLE_MODIFY_STMT, as MODIFY_EXPRs with java
-         semantics should only be generated by the front-end, and never
-         by anything after gimplification.  */
     case MODIFY_EXPR:
       return java_gimplify_modify_expr (expr_p);
 
@@ -98,26 +96,6 @@ java_gimplify_expr (tree *expr_p, tree *pre_p ATTRIBUTE_UNUSED,
       gcc_unreachable ();
 
     default:
-      /* Java insists on strict left-to-right evaluation of expressions.
-        A problem may arise if a variable used in the LHS of a binary
-        operation is altered by an assignment to that value in the RHS
-        before we've performed the operation.  So, we always copy every
-        LHS to a temporary variable.  
-
-        FIXME: Are there any other cases where we should do this?
-        Parameter lists, maybe?  Or perhaps that's unnecessary because
-        the front end already generates SAVE_EXPRs.  */
-
-      if (TREE_CODE_CLASS (code) == tcc_binary
-         || TREE_CODE_CLASS (code) == tcc_comparison)
-       {
-         enum gimplify_status stat 
-           = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, post_p,
-                            is_gimple_formal_tmp_var, fb_rvalue);
-         if (stat == GS_ERROR)
-           return stat;
-       }
-
       return GS_UNHANDLED;
     }
 
@@ -142,7 +120,7 @@ java_gimplify_modify_expr (tree *modify_expr_p)
     {
       tree new_lhs = java_replace_reference (lhs, /* want_lvalue */ true);
       tree new_rhs = build1 (NOP_EXPR, TREE_TYPE (new_lhs), rhs);
-      modify_expr = build2 (GIMPLE_MODIFY_STMT, TREE_TYPE (new_lhs),
+      modify_expr = build2 (MODIFY_EXPR, TREE_TYPE (new_lhs),
                            new_lhs, new_rhs);
       modify_expr = build1 (NOP_EXPR, lhs_type, modify_expr);
     }
@@ -160,8 +138,8 @@ java_gimplify_modify_expr (tree *modify_expr_p)
     between the reading and the writing.  */
 
 static enum gimplify_status
-java_gimplify_self_mod_expr (tree *expr_p, tree *pre_p ATTRIBUTE_UNUSED, 
-                            tree *post_p ATTRIBUTE_UNUSED)
+java_gimplify_self_mod_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED, 
+                            gimple_seq *post_p ATTRIBUTE_UNUSED)
 {
   tree lhs = TREE_OPERAND (*expr_p, 0);
 
@@ -180,7 +158,7 @@ java_gimplify_block (tree java_block)
 {
   tree decls = BLOCK_VARS (java_block);
   tree body = BLOCK_EXPR_BODY (java_block);
-  tree outer = gimple_current_bind_expr ();
+  gimple outer = gimple_current_bind_expr ();
   tree block;
 
   /* Don't bother with empty blocks.  */
@@ -199,10 +177,10 @@ java_gimplify_block (tree java_block)
      routines generate info for the variables in that block.  */
   TREE_USED (block) = 1;
 
-  if (outer != NULL_TREE)
+  if (outer != NULL)
     {
-      outer = BIND_EXPR_BLOCK (outer);
-      BLOCK_SUBBLOCKS (outer) = chainon (BLOCK_SUBBLOCKS (outer), block);
+      tree b = gimple_bind_block (outer);
+      BLOCK_SUBBLOCKS (b) = chainon (BLOCK_SUBBLOCKS (b), block);
     }
   BLOCK_EXPR_BODY (java_block) = NULL_TREE;