This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tuples] declare_vars changes
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: dnovillo at google dot com, amacleod at redhat dot com, gcc-patches at gcc dot gnu dot org
- Date: Wed, 18 Jul 2007 12:05:25 -0400
- Subject: [tuples] declare_vars changes
I've enabled the calls to declare_vars and have fixed it accordingly for
tuples.
Diego, I have two questions.
First, I am grabbing what used to be BIND_EXPR_BLOCK from gimple_base,
which has a block field. Is this correct?
- block = BIND_EXPR_BLOCK (scope);
+ block = GIMPLE_BLOCK (scope);
Second, there is a call to declare_vars from within gimple_add_tmp_var
which looked dubious to me (see FIXME). It was calling declare_vars
when we didn't have a gimplify context and we didn't have cfun set. I
couldn't think of any case where that might be true, and I did a full
bootstrap of (C/C++) and didn't trigger it once. Is this used in any of
the other languages, or in some weird context I haven't thought of?
Just curious...
Committing to branch.
* tree-gimple.h (declare_vars): Update arguments.
* gimplify.c (pop_gimplify_context): Enable call to declare_vars.
(declare_vars): Convert to use tuples.
(gimple_add_tmp_var): Same.
* gimple.h (GIMPLE_BLOCK): New.
Index: tree-gimple.h
===================================================================
--- tree-gimple.h (revision 126719)
+++ tree-gimple.h (working copy)
@@ -32,7 +32,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, tree, bool);
+extern void declare_vars (tree, gimple, bool);
extern void annotate_all_with_locus (gimple_seq, location_t);
Index: gimplify.c
===================================================================
--- gimplify.c (revision 126719)
+++ gimplify.c (working copy)
@@ -185,11 +185,7 @@ pop_gimplify_context (gimple body)
DECL_GIMPLE_FORMAL_TEMP_P (t) = 0;
if (body)
- /* FIXME tuples */
- ;
-#if 0
declare_vars (c->temps, body, false);
-#endif
else
record_vars (c->temps);
@@ -648,27 +644,23 @@ get_tmp_var_for (gimple stmt)
true, generate debug info for them; otherwise don't. */
void
-declare_vars (tree vars, tree scope, bool debug_info)
+declare_vars (tree vars, gimple scope, bool debug_info)
{
tree last = vars;
if (last)
{
tree temps, block;
- /* C99 mode puts the default 'return 0;' for main outside the outer
- braces. So drill down until we find an actual scope. */
- while (TREE_CODE (scope) == COMPOUND_EXPR)
- scope = TREE_OPERAND (scope, 0);
-
- gcc_assert (TREE_CODE (scope) == BIND_EXPR);
+ gcc_assert (GIMPLE_CODE (scope) == GIMPLE_BIND);
temps = nreverse (last);
- block = BIND_EXPR_BLOCK (scope);
+ block = GIMPLE_BLOCK (scope);
+ gcc_assert (!block || TREE_CODE (block) == BLOCK);
if (!block || !debug_info)
{
- TREE_CHAIN (last) = BIND_EXPR_VARS (scope);
- BIND_EXPR_VARS (scope) = temps;
+ TREE_CHAIN (last) = gimple_bind_vars (scope);
+ gimple_bind_set_vars (scope, temps);
}
else
{
@@ -680,7 +672,8 @@ declare_vars (tree vars, tree scope, boo
BLOCK_VARS (block) = chainon (BLOCK_VARS (block), temps);
else
{
- BIND_EXPR_VARS (scope) = chainon (BIND_EXPR_VARS (scope), temps);
+ gimple_bind_set_vars (scope,
+ chainon (gimple_bind_vars (scope), temps));
BLOCK_VARS (block) = temps;
}
}
@@ -743,7 +736,16 @@ gimple_add_tmp_var (tree tmp)
else if (cfun)
record_vars (tmp);
else
- declare_vars (tmp, DECL_SAVED_TREE (current_function_decl), false);
+ {
+ gimple_seq body_seq;
+
+ /* FIXME tuples: In a full bootstrap, I've never triggered
+ this. Is this call to declare_vars() really needed? */
+ gcc_unreachable ();
+
+ body_seq = gimple_body (current_function_decl);
+ declare_vars (tmp, gimple_seq_first (body_seq), false);
+ }
}
/* Determines whether to assign a locus to the statement GS. */
Index: gimple.h
===================================================================
--- gimple.h (revision 126719)
+++ gimple.h (working copy)
@@ -40,6 +40,7 @@ enum gimple_code {
#define GIMPLE_SUBCODE_FLAGS(G) ((G)->base.subcode_flags)
#define GIMPLE_NEXT(G) ((G)->base.next)
#define GIMPLE_PREV(G) ((G)->base.prev)
+#define GIMPLE_BLOCK(G) ((G)->base.block)
#define GIMPLE_LOCUS(G) ((G)->base.locus)
#define GIMPLE_LOCUS_EMPTY_P(G) (GIMPLE_LOCUS ((G)).file == NULL \
&& GIMPLE_LOCUS ((G)).line == 0)