This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tuples] constructors and gs_cond
- 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: Thu, 21 Jun 2007 16:49:02 -0600
- Subject: [tuples] constructors and gs_cond
I'm working on getting constructors generating correctly. This patch
enables them, and adjusts things accordingly. I'm still ironing some
details, but the general gist is here.
I have also fixed some formatting issues, as well as some problems
resulting from Diego's patch.
Finally, I have changed the API to GS_COND's a bit. Labels are now of
type tree. This makes things more compatible with gs_build_goto().
I must say, I really like the way things are turning out wrt building
tuples. It's far more elegant than our build tree business. Yay.
* gimple-ir.c (gs_build_cond): Change order of arguments. Make labels
of type tree.
(gs_build_asm): Fix formatting.
* gimple-ir.h (gimple_statement_cond): Make labels of type tree.
(gs_build_cond): Change order and type of arguments.
(gs_build_asm): Fix formatting.
(gs_omp_build_for): Same.
(gs_assign_binary_rhs1): Remove assert.
(gs_assign_binary_set_rhs1): Same.
(gs_assign_binary_rhs2): Same.
(gs_assign_binary_set_rhs2): Same.
(gs_assign_unary_rhs): Same.
(gs_cond_true_label): Return a tree.
(gs_cond_set_true_label): Make label a tree.
(gs_cond_set_false_label): Make label a tree.
(gs_cond_false_label): Return a tree.
* gimplify.c (gimplify_init_ctor_eval_range): Build tuples.
(gimplify_init_ctor_eval): Same.
(gimplify_init_constructor): Enable. Adjust for tuples.
(gimplify_modify_expr_rhs): Uncomment call to
gimplify_init_constructor.
Index: gimple-ir.c
===================================================================
--- gimple-ir.c (revision 125929)
+++ gimple-ir.c (working copy)
@@ -163,8 +163,8 @@ gss_for_assign (enum tree_code code)
if true goto T_LABEL, else goto F_LABEL. */
gimple
-gs_build_cond (tree lhs, enum gs_cond pred, tree rhs, struct gimple_statement_label* t_label,
- struct gimple_statement_label* f_label)
+gs_build_cond (enum gs_cond pred, tree lhs, tree rhs,
+ tree t_label, tree f_label)
{
gimple p;
@@ -244,7 +244,7 @@ gs_build_bind (tree vars, gs_seq body)
...s are trees for each input, output and clobber. */
gimple
-gs_build_asm (const char* string, unsigned ni, unsigned no, unsigned nc,...)
+gs_build_asm (const char *string, unsigned ni, unsigned no, unsigned nc, ...)
{
gimple p;
unsigned i;
Index: gimple-ir.h
===================================================================
--- gimple-ir.h (revision 125929)
+++ gimple-ir.h (working copy)
@@ -175,8 +175,8 @@ struct gimple_statement_cond GTY(())
{
struct gimple_statement_with_ops with_ops;
tree op[2];
- struct gimple_statement_label *label_true;
- struct gimple_statement_label *label_false;
+ tree label_true;
+ tree label_false;
};
/* GS_GOTO */
@@ -332,13 +332,12 @@ union gimple_statement_d GTY ((desc ("gi
extern gimple gs_build_return (bool, tree);
extern gimple gs_build_assign (tree, tree);
extern gimple gs_build_call (tree, int, ...);
-extern gimple gs_build_cond (tree, enum gs_cond, tree, struct gimple_statement_label*,
- struct gimple_statement_label*);
+extern gimple gs_build_cond (enum gs_cond, tree, tree, tree, tree);
extern gimple gs_build_label (tree label);
extern gimple gs_build_goto (tree dest);
extern gimple gs_build_nop (void);
extern gimple gs_build_bind (tree, gs_seq);
-extern gimple gs_build_asm (const char*, unsigned, unsigned, unsigned, ...);
+extern gimple gs_build_asm (const char *, unsigned, unsigned, unsigned, ...);
extern gimple gs_build_catch (tree, gimple);
extern gimple gs_build_eh_filter (tree, gimple);
extern gimple gs_build_try (gimple, gimple, bool, bool);
@@ -346,8 +345,8 @@ extern gimple gs_build_phi (unsigned, un
extern gimple gs_build_resx (int);
extern gimple gs_build_switch (unsigned int, tree, tree, ...);
extern gimple gs_omp_build_parallel (struct gs_sequence, tree, tree, tree);
-extern gimple gs_omp_build_for (struct gs_sequence, tree, tree, tree, tree, tree,
- struct gs_sequence, enum gs_cond);
+extern gimple gs_omp_build_for (struct gs_sequence, tree, tree, tree, tree,
+ tree, struct gs_sequence, enum gs_cond);
extern gimple gs_omp_build_critical (struct gs_sequence, tree);
extern gimple gs_omp_build_section (struct gs_sequence);
extern gimple gs_omp_build_continue (struct gs_sequence);
@@ -454,28 +453,24 @@ gs_assign_set_lhs (gimple gs, tree lhs)
static inline tree
gs_assign_binary_rhs1 (gimple gs)
{
- gcc_assert (GS_SUBCODE_FLAGS (gs) == GSS_ASSIGN_BINARY);
return gs_assign_operand (gs, 1);
}
static inline void
gs_assign_binary_set_rhs1 (gimple gs, tree rhs)
{
- gcc_assert (GS_SUBCODE_FLAGS (gs) == GSS_ASSIGN_BINARY);
gs_assign_set_operand (gs, 1, rhs);
}
static inline tree
gs_assign_binary_rhs2 (gimple gs)
{
- gcc_assert (GS_SUBCODE_FLAGS (gs) == GSS_ASSIGN_BINARY);
return gs_assign_operand (gs, 2);
}
static inline void
gs_assign_binary_set_rhs2 (gimple gs, tree rhs)
{
- gcc_assert (GS_SUBCODE_FLAGS (gs) == GSS_ASSIGN_BINARY);
gs_assign_set_operand (gs, 2, rhs);
}
@@ -485,7 +480,6 @@ gs_assign_unary_rhs (gimple gs)
#if defined ENABLE_CHECKING
enum gimple_statement_structure_enum gss;
gss = gss_for_assign (GS_SUBCODE_FLAGS (gs));
- gcc_assert (gss = GSS_ASSIGN_UNARY_REG || gss == GSS_ASSIGN_UNARY_MEM);
#endif
return gs_assign_operand (gs, 1);
}
@@ -493,10 +487,6 @@ gs_assign_unary_rhs (gimple gs)
static inline void
gs_assign_unary_set_rhs (gimple gs, tree rhs)
{
-#if defined ENABLE_CHECKING
- enum gimple_statement_structure_enum gss = gss_for_assign (TREE_CODE (rhs));
- gcc_assert (gss = GSS_ASSIGN_UNARY_REG || gss == GSS_ASSIGN_UNARY_MEM);
-#endif
gs_assign_set_operand (gs, 1, rhs);
}
@@ -604,7 +594,7 @@ gs_cond_set_rhs (gimple gs, tree rhs)
gs->gs_cond.op[1] = rhs;
}
-static inline struct gimple_statement_label *
+static inline tree
gs_cond_true_label (gimple gs)
{
GS_CHECK (gs, GS_COND);
@@ -612,20 +602,20 @@ gs_cond_true_label (gimple gs)
}
static inline void
-gs_cond_set_true_label (gimple gs, struct gimple_statement_label * label)
+gs_cond_set_true_label (gimple gs, tree label)
{
GS_CHECK (gs, GS_COND);
gs->gs_cond.label_true = label;
}
static inline void
-gs_cond_set_false_label (gimple gs, struct gimple_statement_label * label)
+gs_cond_set_false_label (gimple gs, tree label)
{
GS_CHECK (gs, GS_COND);
gs->gs_cond.label_false = label;
}
-static inline struct gimple_statement_label *
+static inline tree
gs_cond_false_label (gimple gs)
{
GS_CHECK (gs, GS_COND);
Index: gimplify.c
===================================================================
--- gimplify.c (revision 125929)
+++ gimplify.c (working copy)
@@ -2810,11 +2810,10 @@ gimplify_init_ctor_eval_range (tree obje
/* Create and initialize the index variable. */
var_type = TREE_TYPE (upper);
var = create_tmp_var (var_type, NULL);
- gimplify_and_add (build_gimple_modify_stmt (var, lower), pre_p);
+ gs_add (gs_build_assign (var, lower), pre_p);
/* Add the loop entry label. */
- gimplify_and_add (build1 (LABEL_EXPR, void_type_node, loop_entry_label),
- pre_p);
+ gs_add (gs_build_label (loop_entry_label), pre_p);
/* Build the reference. */
cref = build4 (ARRAY_REF, array_elt_type, unshare_expr (object),
@@ -2829,30 +2828,22 @@ gimplify_init_ctor_eval_range (tree obje
gimplify_init_ctor_eval (cref, CONSTRUCTOR_ELTS (value),
pre_p, cleared);
else
- gimplify_and_add (build_gimple_modify_stmt (cref, value), pre_p);
+ gs_add (gs_build_assign (cref, value), pre_p);
/* We exit the loop when the index var is equal to the upper bound. */
- gimplify_and_add (build3 (COND_EXPR, void_type_node,
- build2 (EQ_EXPR, boolean_type_node,
- var, upper),
- build1 (GOTO_EXPR,
- void_type_node,
- loop_exit_label),
- NULL_TREE),
- pre_p);
+ gs_add (gs_build_cond (COND_EQ, var, upper, loop_exit_label, NULL_TREE),
+ pre_p);
/* Otherwise, increment the index var... */
tmp = build2 (PLUS_EXPR, var_type, var,
fold_convert (var_type, integer_one_node));
- gimplify_and_add (build_gimple_modify_stmt (var, tmp), pre_p);
+ gs_add (gs_build_assign (var, tmp), pre_p);
/* ...and jump back to the loop entry. */
- gimplify_and_add (build1 (GOTO_EXPR, void_type_node, loop_entry_label),
- pre_p);
+ gs_add (gs_build_goto (loop_entry_label), pre_p);
/* Add the loop exit label. */
- gimplify_and_add (build1 (LABEL_EXPR, void_type_node, loop_exit_label),
- pre_p);
+ gs_add (gs_build_label (loop_exit_label), pre_p);
}
/* Return true if FDECL is accessing a field that is zero sized. */
@@ -2896,7 +2887,7 @@ gimplify_init_ctor_eval (tree object, VE
FOR_EACH_CONSTRUCTOR_ELT (elts, ix, purpose, value)
{
- tree cref, init;
+ tree cref;
/* NULL values are created above for gimplification errors. */
if (value == NULL)
@@ -2953,10 +2944,7 @@ gimplify_init_ctor_eval (tree object, VE
gimplify_init_ctor_eval (cref, CONSTRUCTOR_ELTS (value),
pre_p, cleared);
else
- {
- init = build2 (INIT_EXPR, TREE_TYPE (cref), cref, value);
- gimplify_and_add (init, pre_p);
- }
+ gs_add (gs_build_assign (cref, value), pre_p);
}
}
@@ -2967,8 +2955,6 @@ gimplify_init_ctor_eval (tree object, VE
initializers, so if not all elements are initialized we keep the
original MODIFY_EXPR, we just remove all of the constructor elements. */
-#if 0
-/* FIXME tuples */
static enum gimplify_status
gimplify_init_constructor (tree *expr_p, gs_seq pre_p,
gs_seq post_p, bool want_value)
@@ -3248,14 +3234,12 @@ gimplify_init_constructor (tree *expr_p,
return GS_ERROR;
else if (want_value)
{
- append_to_statement_list (*expr_p, pre_p);
*expr_p = object;
return GS_OK;
}
else
return GS_ALL_DONE;
}
-#endif
/* Given a pointer value OP0, return a simplified version of an
indirection through OP0, or NULL_TREE if no simplification is
@@ -3382,11 +3366,7 @@ gimplify_modify_expr_rhs (tree *expr_p,
case CONSTRUCTOR:
/* If we're initializing from a CONSTRUCTOR, break this into
individual MODIFY_EXPRs. */
-#if 0
-/* FIXME tuples */
return gimplify_init_constructor (expr_p, pre_p, post_p, want_value);
-#endif
- gcc_unreachable(); return GS_ALL_DONE;
case COND_EXPR:
/* If we're assigning to a non-register type, push the assignment