* tree.def (SWITCH_EXPR): Change from 3 operand to 2 operand tree.
Adjust comment.
* tree.h (SWITCH_LABELS): Remove.
* gimplify.c (gimplify_switch_expr): Don't test SWITCH_LABELS,
assert SWITCH_BODY is non-NULL.
* tree-pretty-print.c (dump_generic_node): Remove SWITCH_LABELS
handling.
* tree.c (block_may_fallthru): Always return true; for SWITCH_EXPR.
c/
* c-typeck.c (c_start_case): Build SWITCH_EXPR using build2 instead
of build3.
cp/
* cp-gimplify.c (genericize_switch_stmt): Build SWITCH_EXPR using
build2_loc instead of build3_loc.
ada/
* gcc-interface/trans.c (Case_Statement_to_gnu): Build SWITCH_EXPR
using build2 instead of build3.
jit/
* jit-playback.c (add_switch): Build SWITCH_EXPR using build2 instead
of build3. Formatting fixes. Adjust funciton comment.
fortran/
* trans-decl.c (gfc_trans_entry_master_switch): Build SWITCH_EXPR
using fold_build2_loc instead of fold_build3_loc.
* trans-io.c (io_result): Likewise.
* trans-stmt.c (gfc_trans_integer_select, gfc_trans_character_select):
Likewise.
go/
* go-gcc.cc (Gcc_backend::switch_statement): Build SWITCH_EXPR using
build2_loc instead of build3_loc.
brig/
* brigfrontend/brig-branch-inst-handler.cc
(brig_branch_inst_handler::operator): Build SWITCH_EXPR using build2
instead of build3.
From-SVN: r255192
2017-11-28 Jakub Jelinek <jakub@redhat.com>
+ * tree.def (SWITCH_EXPR): Change from 3 operand to 2 operand tree.
+ Adjust comment.
+ * tree.h (SWITCH_LABELS): Remove.
+ * gimplify.c (gimplify_switch_expr): Don't test SWITCH_LABELS,
+ assert SWITCH_BODY is non-NULL.
+ * tree-pretty-print.c (dump_generic_node): Remove SWITCH_LABELS
+ handling.
+ * tree.c (block_may_fallthru): Always return true; for SWITCH_EXPR.
+
PR tree-optimization/80788
* match.pd (X +- C1 CMP C2 -> X CMP C2 -+ C1): If res
has TREE_OVERFLOW set, call drop_tree_overflow.
+2017-11-28 Jakub Jelinek <jakub@redhat.com>
+
+ * gcc-interface/trans.c (Case_Statement_to_gnu): Build SWITCH_EXPR
+ using build2 instead of build3.
+
2017-11-23 Eric Botcazou <ebotcazou@adacore.com>
PR ada/83091
/* Now emit a definition of the label the cases branch to, if any. */
if (may_fallthru)
add_stmt (build1 (LABEL_EXPR, void_type_node, gnu_label));
- gnu_result
- = build3 (SWITCH_EXPR, gnu_type, gnu_expr, end_stmt_group (), NULL_TREE);
+ gnu_result = build2 (SWITCH_EXPR, gnu_type, gnu_expr, end_stmt_group ());
return gnu_result;
}
+2017-11-28 Jakub Jelinek <jakub@redhat.com>
+
+ * brigfrontend/brig-branch-inst-handler.cc
+ (brig_branch_inst_handler::operator): Build SWITCH_EXPR using build2
+ instead of build3.
+
2017-11-17 Henry Linjamäki <henry.linjamaki@parmance.com>
* brigfrontend/brig-util.cc: Fix sprintf format string type mismatch
tree select = operands[0];
tree cases = operands[1];
- tree switch_expr = build3 (SWITCH_EXPR, TREE_TYPE (select), select,
- NULL_TREE, NULL_TREE);
+ tree switch_expr = build2 (SWITCH_EXPR, TREE_TYPE (select), select,
+ NULL_TREE);
tree default_case
= build_case_label (NULL_TREE, NULL_TREE,
+2017-11-28 Jakub Jelinek <jakub@redhat.com>
+
+ * c-typeck.c (c_start_case): Build SWITCH_EXPR using build2 instead
+ of build3.
+
2017-11-14 Boris Kolpackov <boris@codesynthesis.com>
* Make-lang.in (c.install-plugin): Install backend import library.
/* Add this new SWITCH_EXPR to the stack. */
cs = XNEW (struct c_switch);
- cs->switch_expr = build3 (SWITCH_EXPR, orig_type, exp, NULL_TREE, NULL_TREE);
+ cs->switch_expr = build2 (SWITCH_EXPR, orig_type, exp, NULL_TREE);
SET_EXPR_LOCATION (cs->switch_expr, switch_loc);
cs->orig_type = orig_type;
cs->cases = splay_tree_new (case_compare, NULL, NULL);
+2017-11-28 Jakub Jelinek <jakub@redhat.com>
+
+ * cp-gimplify.c (genericize_switch_stmt): Build SWITCH_EXPR using
+ build2_loc instead of build3_loc.
+
2017-11-27 Martin Sebor <msebor@redhat.com>
PR c++/83058
cp_walk_tree (&type, cp_genericize_r, data, NULL);
*walk_subtrees = 0;
- *stmt_p = build3_loc (stmt_locus, SWITCH_EXPR, type, cond, body, NULL_TREE);
+ *stmt_p = build2_loc (stmt_locus, SWITCH_EXPR, type, cond, body);
finish_bc_block (stmt_p, bc_break, break_block);
}
+2017-11-28 Jakub Jelinek <jakub@redhat.com>
+
+ * trans-decl.c (gfc_trans_entry_master_switch): Build SWITCH_EXPR
+ using fold_build2_loc instead of fold_build3_loc.
+ * trans-io.c (io_result): Likewise.
+ * trans-stmt.c (gfc_trans_integer_select, gfc_trans_character_select):
+ Likewise.
+
2017-11-24 Jakub Jelinek <jakub@redhat.com>
PR fortran/81304
tmp = gfc_finish_block (&block);
/* The first argument selects the entry point. */
val = DECL_ARGUMENTS (current_function_decl);
- tmp = fold_build3_loc (input_location, SWITCH_EXPR, NULL_TREE,
- val, tmp, NULL_TREE);
+ tmp = fold_build2_loc (input_location, SWITCH_EXPR, NULL_TREE, val, tmp);
return tmp;
}
rc, build_int_cst (TREE_TYPE (rc),
IOPARM_common_libreturn_mask));
- tmp = fold_build3_loc (input_location, SWITCH_EXPR, NULL_TREE,
- rc, tmp, NULL_TREE);
+ tmp = fold_build2_loc (input_location, SWITCH_EXPR, NULL_TREE, rc, tmp);
gfc_add_expr_to_block (block, tmp);
}
}
tmp = gfc_finish_block (&body);
- tmp = fold_build3_loc (input_location, SWITCH_EXPR, NULL_TREE,
- se.expr, tmp, NULL_TREE);
+ tmp = fold_build2_loc (input_location, SWITCH_EXPR, NULL_TREE, se.expr, tmp);
gfc_add_expr_to_block (&block, tmp);
tmp = build1_v (LABEL_EXPR, end_label);
gfc_add_block_to_block (&block, &expr1se.post);
tmp = gfc_finish_block (&body);
- tmp = fold_build3_loc (input_location, SWITCH_EXPR, NULL_TREE,
- case_num, tmp, NULL_TREE);
+ tmp = fold_build2_loc (input_location, SWITCH_EXPR, NULL_TREE,
+ case_num, tmp);
gfc_add_expr_to_block (&block, tmp);
tmp = build1_v (LABEL_EXPR, end_label);
gfc_add_block_to_block (&block, &expr1se.post);
tmp = gfc_finish_block (&body);
- tmp = fold_build3_loc (input_location, SWITCH_EXPR, NULL_TREE,
- case_num, tmp, NULL_TREE);
+ tmp = fold_build2_loc (input_location, SWITCH_EXPR, NULL_TREE,
+ case_num, tmp);
gfc_add_expr_to_block (&block, tmp);
tmp = build1_v (LABEL_EXPR, end_label);
tree default_case = NULL_TREE;
gswitch *switch_stmt;
- /* If someone can be bothered to fill in the labels, they can
- be bothered to null out the body too. */
- gcc_assert (!SWITCH_LABELS (switch_expr));
-
/* Save old labels, get new ones from body, then restore the old
labels. Save all the things from the switch body to append after. */
saved_labels = gimplify_ctxp->case_labels;
labels.release ();
}
else
- gcc_assert (SWITCH_LABELS (switch_expr));
+ gcc_unreachable ();
return GS_ALL_DONE;
}
+2017-11-28 Jakub Jelinek <jakub@redhat.com>
+
+ * go-gcc.cc (Gcc_backend::switch_statement): Build SWITCH_EXPR using
+ build2_loc instead of build3_loc.
+
2017-11-14 Than McIntosh <thanm@google.com>
* go-gcc.cc (var_expression): Remove Varexpr_context parameter.
tree tv = value->get_tree();
if (tv == error_mark_node)
return this->error_statement();
- tree t = build3_loc(switch_location.gcc_location(), SWITCH_EXPR,
- NULL_TREE, tv, stmt_list, NULL_TREE);
+ tree t = build2_loc(switch_location.gcc_location(), SWITCH_EXPR,
+ NULL_TREE, tv, stmt_list);
return this->make_statement(t);
}
+2017-11-28 Jakub Jelinek <jakub@redhat.com>
+
+ * jit-playback.c (add_switch): Build SWITCH_EXPR using build2 instead
+ of build3. Formatting fixes. Adjust funciton comment.
+
2017-11-23 Tom de Vries <tom@codesourcery.com>
* libgccjit.c (RETURN_NULL_IF_FAIL_NONNULL_NUMERIC_TYPE): Wrap in
/* Add a switch statement to the function's statement list.
- My initial attempt at implementing this constructed a TREE_VEC
- of the cases and set it as SWITCH_LABELS (switch_expr). However,
- gimplify.c:gimplify_switch_expr is set up to deal with SWITCH_BODY, and
- doesn't have any logic for gimplifying SWITCH_LABELS.
-
- Hence we create a switch body, and populate it with case labels, each
+ We create a switch body, and populate it with case labels, each
followed by a goto to the desired block. */
void
{
tree t_low_value = c->m_min_value->as_tree ();
tree t_high_value = c->m_max_value->as_tree ();
- add_case (&t_switch_body,
- t_low_value,
- t_high_value,
- c->m_dest_block);
+ add_case (&t_switch_body, t_low_value, t_high_value, c->m_dest_block);
}
/* Default label. */
- add_case (&t_switch_body,
- NULL_TREE, NULL_TREE,
- default_block);
+ add_case (&t_switch_body, NULL_TREE, NULL_TREE, default_block);
- tree switch_stmt = build3 (SWITCH_EXPR, t_type, t_expr,
- t_switch_body, NULL_TREE);
+ tree switch_stmt = build2 (SWITCH_EXPR, t_type, t_expr, t_switch_body);
if (loc)
set_tree_location (switch_stmt, loc);
add_stmt (switch_stmt);
dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
true);
}
- else
- {
- tree vec = SWITCH_LABELS (node);
- size_t i, n = TREE_VEC_LENGTH (vec);
- for (i = 0; i < n; ++i)
- {
- tree elt = TREE_VEC_ELT (vec, i);
- newline_and_indent (pp, spc+4);
- if (elt)
- {
- dump_generic_node (pp, elt, spc+4, flags, false);
- pp_string (pp, " goto ");
- dump_generic_node (pp, CASE_LABEL (elt), spc+4,
- flags, true);
- pp_semicolon (pp);
- }
- else
- pp_string (pp, "case ???: goto ???;");
- }
- }
newline_and_indent (pp, spc+2);
pp_right_brace (pp);
}
return false;
case SWITCH_EXPR:
- /* If SWITCH_LABELS is set, this is lowered, and represents a
- branch to a selected label and hence can not fall through.
- Otherwise SWITCH_BODY is set, and the switch can fall
- through. */
- return SWITCH_LABELS (stmt) == NULL_TREE;
+ return true;
case COND_EXPR:
if (block_may_fallthru (COND_EXPR_THEN (stmt)))
Operand 0 is the expression used to perform the branch,
Operand 1 is the body of the switch, which probably contains
CASE_LABEL_EXPRs. It may also be NULL, in which case operand 2
- must not be NULL.
- Operand 2 is either NULL_TREE or a TREE_VEC of the CASE_LABEL_EXPRs
- of all the cases. */
-DEFTREECODE (SWITCH_EXPR, "switch_expr", tcc_statement, 3)
+ must not be NULL. */
+DEFTREECODE (SWITCH_EXPR, "switch_expr", tcc_statement, 2)
/* Used to represent a case label.
#define COMPOUND_LITERAL_EXPR_DECL(NODE) \
DECL_EXPR_DECL (COMPOUND_LITERAL_EXPR_DECL_EXPR (NODE))
-/* SWITCH_EXPR accessors. These give access to the condition, body and
- original condition type (before any compiler conversions)
- of the switch statement, respectively. */
+/* SWITCH_EXPR accessors. These give access to the condition and body. */
#define SWITCH_COND(NODE) TREE_OPERAND (SWITCH_EXPR_CHECK (NODE), 0)
#define SWITCH_BODY(NODE) TREE_OPERAND (SWITCH_EXPR_CHECK (NODE), 1)
-#define SWITCH_LABELS(NODE) TREE_OPERAND (SWITCH_EXPR_CHECK (NODE), 2)
/* CASE_LABEL_EXPR accessors. These give access to the high and low values
of a case label, respectively. */