This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tuples] Make fortran go...
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: dnovillo at google dot com, gcc-patches at gcc dot gnu dot org
- Date: Sat, 10 Nov 2007 10:10:12 -0400
- Subject: [tuples] Make fortran go...
This patch makes fortran build. Very minor changes.
First, we need -Wno-format, because the fortran FE is used to being
compiled without -Werror and has a few warnings.
Then, I found Fortran makes use of annotate_all_with_locus at the tree
level. Since C++ does the same thing, and it makes sense to leaves
things as trees at the given point, I've resurrected tree versions of
annotate_all_with_locus and friends. Now for trees we have
tree_annotate_all_with_locus and annotate_with_locus for gimple. It
seems better than annotating manually in both these places in Fortran
and C++.
Other than that, fortran is pretty clean wrt gimple. It seems trees are
already in generic so there was nothing much to do.
Committed to branch.
On to Java and Objective C.
Aldy
* tree-gimple.h (tree_annotate_all_with_locus): New.
* gimple-dummy.c: Add omp_reduction_init and
diagnose_omp_structured_block_errors.
* gimplify.c (tree_should_carry_locus_p): New.
(tree_annotate_one_with_locus): New.
(tree_annotate_all_with_locus): New.
* cp/cp-gimplify.c (gimplify_cp_loop): Call
tree_annotate_all_with_locus instead of annotating each block
manually.
* fortran/Make-lang.in (fortran-warn): Set to -Wno-format.
* fortran/trans.c (gfc_trans_code): Update comment to say GENERIC.
Call tree_annotate_all_with_locus instead of annotate_all_with_locus.
Index: tree-gimple.h
===================================================================
--- tree-gimple.h (revision 130047)
+++ tree-gimple.h (working copy)
@@ -43,6 +43,7 @@ extern tree create_tmp_var (tree, const
extern tree get_initialized_tmp_var (tree, gimple_seq, gimple_seq);
extern tree get_formal_tmp_var (tree, gimple_seq);
extern void declare_vars (tree, gimple, bool);
+extern void tree_annotate_all_with_locus (tree *, location_t);
extern void annotate_all_with_locus (gimple_seq, location_t);
/* Validation of GIMPLE expressions. Note that these predicates only check
Index: cp/cp-gimplify.c
===================================================================
--- cp/cp-gimplify.c (revision 130047)
+++ cp/cp-gimplify.c (working copy)
@@ -252,29 +252,14 @@ gimplify_cp_loop (tree cond, tree body,
body = finish_bc_block (bc_continue, cont_block, body);
- /* Annotate the new statements individually because annotate_all_with_locus
- only works on gimple sequences. */
-
- if (top && CAN_HAVE_LOCATION_P (top))
- SET_EXPR_LOCATION (top, stmt_locus);
append_to_statement_list (top, &stmt_list);
-
- if (body && CAN_HAVE_LOCATION_P (body))
- SET_EXPR_LOCATION (body, stmt_locus);
append_to_statement_list (body, &stmt_list);
-
- if (incr && CAN_HAVE_LOCATION_P (incr))
- SET_EXPR_LOCATION (incr, stmt_locus);
append_to_statement_list (incr, &stmt_list);
-
- if (entry && CAN_HAVE_LOCATION_P (entry))
- SET_EXPR_LOCATION (entry, stmt_locus);
append_to_statement_list (entry, &stmt_list);
-
- if (exit && CAN_HAVE_LOCATION_P (exit))
- SET_EXPR_LOCATION (exit, stmt_locus);
append_to_statement_list (exit, &stmt_list);
+ tree_annotate_all_with_locus (&stmt_list, stmt_locus);
+
return finish_bc_block (bc_break, break_block, stmt_list);
}
Index: gimple-dummy.c
===================================================================
--- gimple-dummy.c (revision 130047)
+++ gimple-dummy.c (working copy)
@@ -112,3 +112,5 @@ DUMMY_FN (push_stmt_changes);
DUMMY_FN (pop_stmt_changes);
DUMMY_FN (replace_exp);
DUMMY_FN (remove_iv);
+DUMMY_FN (omp_reduction_init);
+DUMMY_FN (diagnose_omp_structured_block_errors);
Index: fortran/Make-lang.in
===================================================================
--- fortran/Make-lang.in (revision 130047)
+++ fortran/Make-lang.in (working copy)
@@ -46,6 +46,9 @@ GFORTRAN_TARGET_INSTALL_NAME := $(target
# Use strict warnings for this front end.
fortran-warn = $(STRICT_WARN)
+# FIXME tuples
+# Do not merge
+fortran-warn += -Wno-format
# These are the groups of object files we have. The F95_PARSER_OBJS are
# all the front end files, the F95_OBJS are the files for the translation
Index: fortran/trans.c
===================================================================
--- fortran/trans.c (revision 130047)
+++ fortran/trans.c (working copy)
@@ -973,7 +973,7 @@ gfc_trans_code (gfc_code * code)
gfc_start_block (&block);
- /* Translate statements one by one to GIMPLE trees until we reach
+ /* Translate statements one by one into GENERIC trees until we reach
the end of this gfc_code branch. */
for (; code; code = code->next)
{
@@ -1155,7 +1155,7 @@ gfc_trans_code (gfc_code * code)
if (res != NULL_TREE && ! IS_EMPTY_STMT (res))
{
if (TREE_CODE (res) == STATEMENT_LIST)
- annotate_all_with_locus (&res, input_location);
+ tree_annotate_all_with_locus (&res, input_location);
else
SET_EXPR_LOCATION (res, input_location);
Index: gimplify.c
===================================================================
--- gimplify.c (revision 130047)
+++ gimplify.c (working copy)
@@ -762,6 +762,26 @@ should_carry_locus_p (gimple gs)
return true;
}
+/* Same, but for a tree. */
+
+static bool
+tree_should_carry_locus_p (const_tree stmt)
+{
+ /* Don't emit a line note for a label. We particularly don't want to
+ emit one for the break label, since it doesn't actually correspond
+ to the beginning of the loop/switch. */
+ if (TREE_CODE (stmt) == LABEL_EXPR)
+ return false;
+
+ /* Do not annotate empty statements, since it confuses gcov. */
+ if (!TREE_SIDE_EFFECTS (stmt))
+ return false;
+
+ return true;
+}
+
+/* Set the location for gimple statement GS to LOCUS. */
+
static void
annotate_one_with_locus (gimple gs, location_t locus)
{
@@ -770,6 +790,18 @@ annotate_one_with_locus (gimple gs, loca
gimple_set_locus (gs, locus);
}
+/* Same, but for tree T. */
+
+static void
+tree_annotate_one_with_locus (tree t, location_t locus)
+{
+ if (CAN_HAVE_LOCATION_P (t)
+ && ! EXPR_HAS_LOCATION (t) && tree_should_carry_locus_p (t))
+ SET_EXPR_LOCATION (t, locus);
+}
+
+/* Set the location for all the statements in a sequence STMT_P to LOCUS. */
+
void
annotate_all_with_locus (gimple_seq stmt_p, location_t locus)
{
@@ -785,6 +817,30 @@ annotate_all_with_locus (gimple_seq stmt
}
}
+/* Same, but for statement or statement list in *STMT_P. */
+
+void
+tree_annotate_all_with_locus (tree *stmt_p, location_t locus)
+{
+ tree_stmt_iterator i;
+
+ if (!*stmt_p)
+ return;
+
+ for (i = tsi_start (*stmt_p); !tsi_end_p (i); tsi_next (&i))
+ {
+ tree t = tsi_stmt (i);
+
+ /* Assuming we've already been gimplified, we shouldn't
+ see nested chaining constructs anymore. */
+ gcc_assert (TREE_CODE (t) != STATEMENT_LIST
+ && TREE_CODE (t) != COMPOUND_EXPR);
+
+ tree_annotate_one_with_locus (t, locus);
+ }
+}
+
+
/* Similar to copy_tree_r() but do not copy SAVE_EXPR or TARGET_EXPR nodes.
These nodes model computations that should only be done once. If we
were to unshare something like SAVE_EXPR(i++), the gimplification