diff options
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 37 | ||||
-rw-r--r-- | gcc/ada/Make-lang.in | 4 | ||||
-rw-r--r-- | gcc/ada/ada-tree.h | 2 | ||||
-rw-r--r-- | gcc/ada/gigi.h | 12 | ||||
-rw-r--r-- | gcc/ada/trans.c | 49 | ||||
-rw-r--r-- | gcc/ada/utils.c | 21 |
6 files changed, 77 insertions, 48 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index fb57909e895..a4859fd744e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,40 @@ +2008-07-28 Richard Guenther <rguenther@suse.de> + + Merge from gimple-tuples-branch. + + 2008-07-22 Olivier Hainque <hainque@adacore.com> + + * gigi.h (end_subprog_body): New ELAB_P argument, saying if + this is called for an elab proc to be discarded if empty. + * utils.c (end_subprog_body): Honor ELAB_P. + (build_function_stub): Adjust call to end_subprog_body. + * trans.c (Subprogram_Body_to_gnu): Likewise. + (gigi): Reorganize processing of elab procs to prevent + gimplifying twice, using the new end_subprog_body argument. + + 2008-07-19 Richard Guenther <rguenther@suse.de> + + * Make-lang.in (trans.o): Add tree-iterator.h dependency. + (utils.o): Likewise. + * trans.c: Include tree-iterator.h. + (gnat_gimplify_expr): Adjust prototype. Fix typo. + (gnat_gimplify_stmt): Use SET_EXPR_LOCATION. + (set_expr_location_from_node): Likewise. + (gigi): Tuplify. + * ada-tree.h (union lang_tree_node): Use TREE_CHAIN instead + of GENERIC_NEXT. + * utils.c: Include tree-iterator.h. + * gigi.h (gnat_gimplify_expr): Adjust prototype. + + 2008-07-18 Aldy Hernandez <aldyh@redhat.com> + + * trans.c: Include gimple.h instead of tree-gimple.h. + * utils.c: Same. + + 2008-07-14 Aldy Hernandez <aldyh@redhat.com> + + * trans.c (gnat_gimplify_expr): Use gimplify_assign. + 2008-07-25 Jan Hubicka <jh@suse.cz> * utils.c (end_subprog_body): Remove inline trees check. diff --git a/gcc/ada/Make-lang.in b/gcc/ada/Make-lang.in index 4136ebe5dca..268fa7031fc 100644 --- a/gcc/ada/Make-lang.in +++ b/gcc/ada/Make-lang.in @@ -1106,13 +1106,13 @@ ada/trans.o : ada/trans.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(TREE_H) $(RTL_H) $(EXPR_H) $(FLAGS_H) $(FUNCTION_H) ada/ada.h except.h \ ada/types.h ada/atree.h ada/nlists.h ada/elists.h ada/uintp.h ada/sinfo.h \ ada/einfo.h ada/namet.h ada/snames.h ada/stringt.h ada/urealp.h ada/fe.h \ - $(ADA_TREE_H) ada/gigi.h gt-ada-trans.h + $(ADA_TREE_H) ada/gigi.h gt-ada-trans.h tree-iterator.h ada/utils.o : ada/utils.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(TREE_H) $(FLAGS_H) $(EXPR_H) convert.h defaults.h langhooks.h \ ada/ada.h ada/types.h ada/atree.h ada/nlists.h ada/elists.h ada/sinfo.h \ ada/einfo.h ada/namet.h ada/stringt.h ada/uintp.h ada/fe.h $(ADA_TREE_H) \ - ada/gigi.h gt-ada-utils.h gtype-ada.h $(TARGET_H) + ada/gigi.h gt-ada-utils.h gtype-ada.h $(TARGET_H) tree-iterator.h ada/utils2.o : ada/utils2.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(TREE_H) $(FLAGS_H) ada/ada.h ada/types.h ada/atree.h ada/nlists.h \ diff --git a/gcc/ada/ada-tree.h b/gcc/ada/ada-tree.h index 044cea811b3..9c31e46f267 100644 --- a/gcc/ada/ada-tree.h +++ b/gcc/ada/ada-tree.h @@ -26,7 +26,7 @@ /* Ada uses the lang_decl and lang_type fields to hold a tree. */ union lang_tree_node GTY((desc ("0"), - chain_next ("(union lang_tree_node *)GENERIC_NEXT (&%h.t)"))) + chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.t)"))) { union tree_node GTY((tag ("0"))) t; }; diff --git a/gcc/ada/gigi.h b/gcc/ada/gigi.h index 86ff090fdb0..aaf5e7f8d8f 100644 --- a/gcc/ada/gigi.h +++ b/gcc/ada/gigi.h @@ -233,8 +233,8 @@ extern tree gnat_to_gnu (Node_Id gnat_node); extern void gnat_expand_stmt (tree gnu_stmt); /* ??? missing documentation */ -extern int gnat_gimplify_expr (tree *expr_p, tree *pre_p, - tree *post_p ATTRIBUTE_UNUSED); +extern int gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p, + gimple_seq *post_p ATTRIBUTE_UNUSED); /* Do the processing for the declaration of a GNAT_ENTITY, a type. If a separate Freeze node exists, delay the bulk of the processing. Otherwise @@ -668,10 +668,10 @@ extern tree create_label_decl (tree label_name); appearing in the subprogram. */ extern void begin_subprog_body (tree subprog_decl); -/* Finish the definition of the current subprogram and compile it all the way - to assembler language output. BODY is the tree corresponding to - the subprogram. */ -extern void end_subprog_body (tree body); +/* Finish the definition of the current subprogram BODY and compile it all the + way to assembler language output. ELAB_P tells if this is called for an + elaboration routine, to be entirely discarded if empty. */ +extern void end_subprog_body (tree body, bool elab_p); /* Build a template of type TEMPLATE_TYPE from the array bounds of ARRAY_TYPE. EXPR is an expression that we can use to locate any PLACEHOLDER_EXPRs. diff --git a/gcc/ada/trans.c b/gcc/ada/trans.c index 89b10c695da..abc71f5e53e 100644 --- a/gcc/ada/trans.c +++ b/gcc/ada/trans.c @@ -40,7 +40,8 @@ #include "except.h" #include "debug.h" #include "output.h" -#include "tree-gimple.h" +#include "tree-iterator.h" +#include "gimple.h" #include "ada.h" #include "types.h" #include "atree.h" @@ -356,7 +357,6 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name, for (info = elab_info_list; info; info = info->next) { tree gnu_body = DECL_SAVED_TREE (info->elab_proc); - tree gnu_stmts; /* Unshare SAVE_EXPRs between subprograms. These are not unshared by the gimplifier for obvious reasons, but it turns out that we need to @@ -368,30 +368,14 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name, an upstream bug for which we would not change the outcome. */ walk_tree_without_duplicates (&gnu_body, unshare_save_expr, NULL); - /* Set the current function to be the elaboration procedure and gimplify - what we have. */ - current_function_decl = info->elab_proc; - gimplify_body (&gnu_body, info->elab_proc, true); + /* Process the function as others, but for indicating this is an + elab proc, to be discarded if empty, then propagate the status + up to the GNAT tree node. */ + begin_subprog_body (info->elab_proc); + end_subprog_body (gnu_body, true); - /* We should have a BIND_EXPR, but it may or may not have any statements - in it. If it doesn't have any, we have nothing to do. */ - gnu_stmts = gnu_body; - if (TREE_CODE (gnu_stmts) == BIND_EXPR) - gnu_stmts = BIND_EXPR_BODY (gnu_stmts); - - /* If there are no statements, there is no elaboration code. */ - if (!gnu_stmts || !STATEMENT_LIST_HEAD (gnu_stmts)) - { - Set_Has_No_Elaboration_Code (info->gnat_node, 1); - cgraph_remove_node (cgraph_node (info->elab_proc)); - } - else - { - /* Otherwise, compile the function. Note that we'll be gimplifying - it twice, but that's fine for the nodes we use. */ - begin_subprog_body (info->elab_proc); - end_subprog_body (gnu_body); - } + if (empty_body_p (gimple_body (info->elab_proc))) + Set_Has_No_Elaboration_Code (info->gnat_node, 1); } /* We cannot track the location of errors past this point. */ @@ -2003,7 +1987,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) : Sloc (gnat_node)), &DECL_STRUCT_FUNCTION (gnu_subprog_decl)->function_end_locus); - end_subprog_body (gnu_result); + end_subprog_body (gnu_result, false); /* Disconnect the trees for parameters that we made variables for from the GNAT entities since these are unusable after we end the function. */ @@ -5334,7 +5318,8 @@ pop_stack (tree *gnu_stack_ptr) /* Generate GIMPLE in place for the expression at *EXPR_P. */ int -gnat_gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p ATTRIBUTE_UNUSED) +gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p, + gimple_seq *post_p ATTRIBUTE_UNUSED) { tree expr = *expr_p; tree op; @@ -5419,14 +5404,14 @@ gnat_gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p ATTRIBUTE_UNUSED) && TREE_CODE_CLASS (TREE_CODE (op)) != tcc_constant) { tree new_var = create_tmp_var (TREE_TYPE (op), "A"); - tree mod = build2 (GIMPLE_MODIFY_STMT, TREE_TYPE (op), new_var, op); + gimple stmt; TREE_ADDRESSABLE (new_var) = 1; + stmt = gimplify_assign (new_var, op, pre_p); if (EXPR_HAS_LOCATION (op)) - SET_EXPR_LOCUS (mod, EXPR_LOCUS (op)); + gimple_set_location (stmt, *EXPR_LOCUS (op)); - gimplify_and_add (mod, pre_p); TREE_OPERAND (expr, 0) = new_var; recompute_tree_invariant_for_addr_expr (expr); return GS_ALL_DONE; @@ -5494,7 +5479,7 @@ gnat_gimplify_stmt (tree *stmt_p) append_to_statement_list (LOOP_STMT_UPDATE (stmt), stmt_p); t = build1 (GOTO_EXPR, void_type_node, gnu_start_label); - set_expr_location (t, DECL_SOURCE_LOCATION (gnu_end_label)); + SET_EXPR_LOCATION (t, DECL_SOURCE_LOCATION (gnu_end_label)); append_to_statement_list (t, stmt_p); append_to_statement_list (build1 (LABEL_EXPR, void_type_node, @@ -6913,7 +6898,7 @@ set_expr_location_from_node (tree node, Node_Id gnat_node) if (!Sloc_to_locus (Sloc (gnat_node), &locus)) return; - set_expr_location (node, locus); + SET_EXPR_LOCATION (node, locus); } /* Return a colon-separated list of encodings contained in encoded Ada diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c index 4668fa21c36..cde8d4dd2f3 100644 --- a/gcc/ada/utils.c +++ b/gcc/ada/utils.c @@ -43,7 +43,8 @@ #include "function.h" #include "cgraph.h" #include "tree-inline.h" -#include "tree-gimple.h" +#include "tree-iterator.h" +#include "gimple.h" #include "tree-dump.h" #include "pointer-set.h" #include "langhooks.h" @@ -2199,12 +2200,12 @@ gnat_genericize (tree fndecl) pointer_set_destroy (p_set); } -/* Finish the definition of the current subprogram and compile it all the way - to assembler language output. BODY is the tree corresponding to - the subprogram. */ +/* Finish the definition of the current subprogram BODY and compile it all the + way to assembler language output. ELAB_P tells if this is called for an + elaboration routine, to be entirely discarded if empty. */ void -end_subprog_body (tree body) +end_subprog_body (tree body, bool elab_p) { tree fndecl = current_function_decl; @@ -2246,7 +2247,13 @@ end_subprog_body (tree body) if (!DECL_CONTEXT (fndecl)) { gnat_gimplify_function (fndecl); - cgraph_finalize_function (fndecl, false); + + /* If this is an empty elaboration proc, just discard the node. + Otherwise, compile further. */ + if (elab_p && empty_body_p (gimple_body (fndecl))) + cgraph_remove_node (cgraph_node (fndecl)); + else + cgraph_finalize_function (fndecl, false); } else /* Register this function with cgraph just far enough to get it @@ -3117,7 +3124,7 @@ build_function_stub (tree gnu_subprog, Entity_Id gnat_subprog) gnat_poplevel (); allocate_struct_function (gnu_stub_decl, false); - end_subprog_body (gnu_body); + end_subprog_body (gnu_body, false); } /* Build a type to be used to represent an aliased object whose nominal |