diff options
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r-- | gcc/tree-cfg.c | 407 |
1 files changed, 225 insertions, 182 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 71a828c37aa..e78554f5721 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -164,7 +164,7 @@ static void make_blocks (gimple_seq); static void make_edges (void); static void assign_discriminators (void); static void make_cond_expr_edges (basic_block); -static void make_gimple_switch_edges (basic_block); +static void make_gimple_switch_edges (gswitch *, basic_block); static bool make_goto_expr_edges (basic_block); static void make_gimple_asm_edges (basic_block); static edge gimple_redirect_edge_and_branch (edge, basic_block); @@ -175,7 +175,7 @@ static inline bool stmt_starts_bb_p (gimple, gimple); static int gimple_verify_flow_info (void); static void gimple_make_forwarder_block (edge); static gimple first_non_label_stmt (basic_block); -static bool verify_gimple_transaction (gimple); +static bool verify_gimple_transaction (gtransaction *); static bool call_can_make_abnormal_goto (gimple); /* Flowgraph optimization and cleanup. */ @@ -184,8 +184,8 @@ static bool gimple_can_merge_blocks_p (basic_block, basic_block); static void remove_bb (basic_block); static edge find_taken_edge_computed_goto (basic_block, tree); static edge find_taken_edge_cond_expr (basic_block, tree); -static edge find_taken_edge_switch_expr (basic_block, tree); -static tree find_case_label_for_value (gimple, tree); +static edge find_taken_edge_switch_expr (gswitch *, basic_block, tree); +static tree find_case_label_for_value (gswitch *, tree); void init_empty_tree_cfg_for_function (struct function *fn) @@ -623,13 +623,16 @@ fold_cond_expr_cond (void) if (stmt && gimple_code (stmt) == GIMPLE_COND) { + gcond *cond_stmt = as_a <gcond *> (stmt); location_t loc = gimple_location (stmt); tree cond; bool zerop, onep; fold_defer_overflow_warnings (); - cond = fold_binary_loc (loc, gimple_cond_code (stmt), boolean_type_node, - gimple_cond_lhs (stmt), gimple_cond_rhs (stmt)); + cond = fold_binary_loc (loc, gimple_cond_code (cond_stmt), + boolean_type_node, + gimple_cond_lhs (cond_stmt), + gimple_cond_rhs (cond_stmt)); if (cond) { zerop = integer_zerop (cond); @@ -642,9 +645,9 @@ fold_cond_expr_cond (void) stmt, WARN_STRICT_OVERFLOW_CONDITIONAL); if (zerop) - gimple_cond_make_false (stmt); + gimple_cond_make_false (cond_stmt); else if (onep) - gimple_cond_make_true (stmt); + gimple_cond_make_true (cond_stmt); } } } @@ -836,7 +839,7 @@ make_edges (void) fallthru = false; break; case GIMPLE_SWITCH: - make_gimple_switch_edges (bb); + make_gimple_switch_edges (as_a <gswitch *> (last), bb); fallthru = false; break; case GIMPLE_RESX: @@ -844,7 +847,7 @@ make_edges (void) fallthru = false; break; case GIMPLE_EH_DISPATCH: - fallthru = make_eh_dispatch_edges (last); + fallthru = make_eh_dispatch_edges (as_a <geh_dispatch *> (last)); break; case GIMPLE_CALL: @@ -891,7 +894,8 @@ make_edges (void) case GIMPLE_TRANSACTION: { - tree abort_label = gimple_transaction_label (last); + tree abort_label + = gimple_transaction_label (as_a <gtransaction *> (last)); if (abort_label) make_edge (bb, label_to_block (abort_label), EDGE_TM_ABORT); fallthru = true; @@ -939,10 +943,10 @@ make_edges (void) { for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple label_stmt = gsi_stmt (gsi); + glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (gsi)); tree target; - if (gimple_code (label_stmt) != GIMPLE_LABEL) + if (!label_stmt) break; target = gimple_label_label (label_stmt); @@ -1074,7 +1078,7 @@ assign_discriminators (void) static void make_cond_expr_edges (basic_block bb) { - gimple entry = last_stmt (bb); + gcond *entry = as_a <gcond *> (last_stmt (bb)); gimple then_stmt, else_stmt; basic_block then_bb, else_bb; tree then_label, else_label; @@ -1159,7 +1163,7 @@ end_recording_case_labels (void) { gimple stmt = last_stmt (bb); if (stmt && gimple_code (stmt) == GIMPLE_SWITCH) - group_case_labels_stmt (stmt); + group_case_labels_stmt (as_a <gswitch *> (stmt)); } } BITMAP_FREE (touched_switch_bbs); @@ -1171,7 +1175,7 @@ end_recording_case_labels (void) Otherwise return NULL. */ static tree -get_cases_for_edge (edge e, gimple t) +get_cases_for_edge (edge e, gswitch *t) { tree *slot; size_t i, n; @@ -1210,9 +1214,8 @@ get_cases_for_edge (edge e, gimple t) /* Create the edges for a GIMPLE_SWITCH starting at block BB. */ static void -make_gimple_switch_edges (basic_block bb) +make_gimple_switch_edges (gswitch *entry, basic_block bb) { - gimple entry = last_stmt (bb); size_t i, n; n = gimple_switch_num_labels (entry); @@ -1280,7 +1283,7 @@ make_goto_expr_edges (basic_block bb) static void make_gimple_asm_edges (basic_block bb) { - gimple stmt = last_stmt (bb); + gasm *stmt = as_a <gasm *> (last_stmt (bb)); int i, n = gimple_asm_nlabels (stmt); for (i = 0; i < n; ++i) @@ -1404,12 +1407,12 @@ cleanup_dead_labels (void) for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i)) { tree label; - gimple stmt = gsi_stmt (i); + glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (i)); - if (gimple_code (stmt) != GIMPLE_LABEL) + if (!label_stmt) break; - label = gimple_label_label (stmt); + label = gimple_label_label (label_stmt); /* If we have not yet seen a label for the current block, remember this one and see if there are more labels. */ @@ -1444,31 +1447,35 @@ cleanup_dead_labels (void) switch (gimple_code (stmt)) { case GIMPLE_COND: - label = gimple_cond_true_label (stmt); - if (label) - { - new_label = main_block_label (label); - if (new_label != label) - gimple_cond_set_true_label (stmt, new_label); - } + { + gcond *cond_stmt = as_a <gcond *> (stmt); + label = gimple_cond_true_label (cond_stmt); + if (label) + { + new_label = main_block_label (label); + if (new_label != label) + gimple_cond_set_true_label (cond_stmt, new_label); + } - label = gimple_cond_false_label (stmt); - if (label) - { - new_label = main_block_label (label); - if (new_label != label) - gimple_cond_set_false_label (stmt, new_label); - } + label = gimple_cond_false_label (cond_stmt); + if (label) + { + new_label = main_block_label (label); + if (new_label != label) + gimple_cond_set_false_label (cond_stmt, new_label); + } + } break; case GIMPLE_SWITCH: { - size_t i, n = gimple_switch_num_labels (stmt); + gswitch *switch_stmt = as_a <gswitch *> (stmt); + size_t i, n = gimple_switch_num_labels (switch_stmt); /* Replace all destination labels. */ for (i = 0; i < n; ++i) { - tree case_label = gimple_switch_label (stmt, i); + tree case_label = gimple_switch_label (switch_stmt, i); label = CASE_LABEL (case_label); new_label = main_block_label (label); if (new_label != label) @@ -1479,11 +1486,12 @@ cleanup_dead_labels (void) case GIMPLE_ASM: { - int i, n = gimple_asm_nlabels (stmt); + gasm *asm_stmt = as_a <gasm *> (stmt); + int i, n = gimple_asm_nlabels (asm_stmt); for (i = 0; i < n; ++i) { - tree cons = gimple_asm_label_op (stmt, i); + tree cons = gimple_asm_label_op (asm_stmt, i); tree label = main_block_label (TREE_VALUE (cons)); TREE_VALUE (cons) = label; } @@ -1495,21 +1503,23 @@ cleanup_dead_labels (void) case GIMPLE_GOTO: if (!computed_goto_p (stmt)) { - label = gimple_goto_dest (stmt); + ggoto *goto_stmt = as_a <ggoto *> (stmt); + label = gimple_goto_dest (goto_stmt); new_label = main_block_label (label); if (new_label != label) - gimple_goto_set_dest (stmt, new_label); + gimple_goto_set_dest (goto_stmt, new_label); } break; case GIMPLE_TRANSACTION: { - tree label = gimple_transaction_label (stmt); + gtransaction *trans_stmt = as_a <gtransaction *> (stmt); + tree label = gimple_transaction_label (trans_stmt); if (label) { tree new_label = main_block_label (label); if (new_label != label) - gimple_transaction_set_label (stmt, new_label); + gimple_transaction_set_label (trans_stmt, new_label); } } break; @@ -1540,12 +1550,12 @@ cleanup_dead_labels (void) for (i = gsi_start_bb (bb); !gsi_end_p (i); ) { tree label; - gimple stmt = gsi_stmt (i); + glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (i)); - if (gimple_code (stmt) != GIMPLE_LABEL) + if (!label_stmt) break; - label = gimple_label_label (stmt); + label = gimple_label_label (label_stmt); if (label == label_for_this_bb || !DECL_ARTIFICIAL (label) @@ -1565,7 +1575,7 @@ cleanup_dead_labels (void) Eg. three separate entries 1: 2: 3: become one entry 1..3: */ void -group_case_labels_stmt (gimple stmt) +group_case_labels_stmt (gswitch *stmt) { int old_size = gimple_switch_num_labels (stmt); int i, j, new_size = old_size; @@ -1653,7 +1663,7 @@ group_case_labels (void) { gimple stmt = last_stmt (bb); if (stmt && gimple_code (stmt) == GIMPLE_SWITCH) - group_case_labels_stmt (stmt); + group_case_labels_stmt (as_a <gswitch *> (stmt)); } } @@ -1663,7 +1673,6 @@ static bool gimple_can_merge_blocks_p (basic_block a, basic_block b) { gimple stmt; - gimple_stmt_iterator gsi; if (!single_succ_p (a)) return false; @@ -1687,19 +1696,20 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b) return false; /* Do not allow a block with only a non-local label to be merged. */ - if (stmt - && gimple_code (stmt) == GIMPLE_LABEL - && DECL_NONLOCAL (gimple_label_label (stmt))) - return false; + if (stmt) + if (glabel *label_stmt = dyn_cast <glabel *> (stmt)) + if (DECL_NONLOCAL (gimple_label_label (label_stmt))) + return false; /* Examine the labels at the beginning of B. */ - for (gsi = gsi_start_bb (b); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (b); !gsi_end_p (gsi); + gsi_next (&gsi)) { tree lab; - stmt = gsi_stmt (gsi); - if (gimple_code (stmt) != GIMPLE_LABEL) + glabel *label_stmt = dyn_cast <glabel *> (gsi_stmt (gsi)); + if (!label_stmt) break; - lab = gimple_label_label (stmt); + lab = gimple_label_label (label_stmt); /* Do not remove user forced labels or for -O0 any user labels. */ if (!DECL_ARTIFICIAL (lab) && (!optimize || FORCED_LABEL (lab))) @@ -1717,9 +1727,10 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b) /* It must be possible to eliminate all phi nodes in B. If ssa form is not up-to-date and a name-mapping is registered, we cannot eliminate any phis. Symbols marked for renaming are never a problem though. */ - for (gsi = gsi_start_phis (b); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gphi_iterator gsi = gsi_start_phis (b); !gsi_end_p (gsi); + gsi_next (&gsi)) { - gimple phi = gsi_stmt (gsi); + gphi *phi = gsi.phi (); /* Technically only new names matter. */ if (name_registered_for_update_p (PHI_RESULT (phi))) return false; @@ -1768,7 +1779,8 @@ replace_uses_by (tree name, tree val) if (gimple_code (stmt) == GIMPLE_PHI) { - e = gimple_phi_arg_edge (stmt, PHI_ARG_INDEX_FROM_USE (use)); + e = gimple_phi_arg_edge (as_a <gphi *> (stmt), + PHI_ARG_INDEX_FROM_USE (use)); if (e->flags & EDGE_ABNORMAL) { /* This can only occur for virtual operands, since @@ -1830,7 +1842,8 @@ replace_uses_by (tree name, tree val) static void gimple_merge_blocks (basic_block a, basic_block b) { - gimple_stmt_iterator last, gsi, psi; + gimple_stmt_iterator last, gsi; + gphi_iterator psi; if (dump_file) fprintf (dump_file, "Merging blocks %d and %d\n", a->index, b->index); @@ -1902,9 +1915,9 @@ gimple_merge_blocks (basic_block a, basic_block b) for (gsi = gsi_start_bb (b); !gsi_end_p (gsi);) { gimple stmt = gsi_stmt (gsi); - if (gimple_code (stmt) == GIMPLE_LABEL) + if (glabel *label_stmt = dyn_cast <glabel *> (stmt)) { - tree label = gimple_label_label (stmt); + tree label = gimple_label_label (label_stmt); int lp_nr; gsi_remove (&gsi, false); @@ -1988,7 +2001,7 @@ single_noncomplex_succ (basic_block bb) /* T is CALL_EXPR. Set current_function_calls_* flags. */ void -notice_special_calls (gimple call) +notice_special_calls (gcall *call) { int flags = gimple_call_flags (call); @@ -2062,9 +2075,10 @@ remove_bb (basic_block bb) for (i = gsi_last_bb (bb); !gsi_end_p (i);) { gimple stmt = gsi_stmt (i); - if (gimple_code (stmt) == GIMPLE_LABEL - && (FORCED_LABEL (gimple_label_label (stmt)) - || DECL_NONLOCAL (gimple_label_label (stmt)))) + glabel *label_stmt = dyn_cast <glabel *> (stmt); + if (label_stmt + && (FORCED_LABEL (gimple_label_label (label_stmt)) + || DECL_NONLOCAL (gimple_label_label (label_stmt)))) { basic_block new_bb; gimple_stmt_iterator new_gsi; @@ -2072,10 +2086,10 @@ remove_bb (basic_block bb) /* A non-reachable non-local label may still be referenced. But it no longer needs to carry the extra semantics of non-locality. */ - if (DECL_NONLOCAL (gimple_label_label (stmt))) + if (DECL_NONLOCAL (gimple_label_label (label_stmt))) { - DECL_NONLOCAL (gimple_label_label (stmt)) = 0; - FORCED_LABEL (gimple_label_label (stmt)) = 1; + DECL_NONLOCAL (gimple_label_label (label_stmt)) = 0; + FORCED_LABEL (gimple_label_label (label_stmt)) = 1; } new_bb = bb->prev_bb; @@ -2132,7 +2146,7 @@ find_taken_edge (basic_block bb, tree val) return find_taken_edge_cond_expr (bb, val); if (gimple_code (stmt) == GIMPLE_SWITCH) - return find_taken_edge_switch_expr (bb, val); + return find_taken_edge_switch_expr (as_a <gswitch *> (stmt), bb, val); if (computed_goto_p (stmt)) { @@ -2191,14 +2205,13 @@ find_taken_edge_cond_expr (basic_block bb, tree val) NULL if any edge may be taken. */ static edge -find_taken_edge_switch_expr (basic_block bb, tree val) +find_taken_edge_switch_expr (gswitch *switch_stmt, basic_block bb, + tree val) { basic_block dest_bb; edge e; - gimple switch_stmt; tree taken_case; - switch_stmt = last_stmt (bb); taken_case = find_case_label_for_value (switch_stmt, val); dest_bb = label_to_block (CASE_LABEL (taken_case)); @@ -2213,7 +2226,7 @@ find_taken_edge_switch_expr (basic_block bb, tree val) sorted: We can do a binary search for a case matching VAL. */ static tree -find_case_label_for_value (gimple switch_stmt, tree val) +find_case_label_for_value (gswitch *switch_stmt, tree val) { size_t low, high, n = gimple_switch_num_labels (switch_stmt); tree default_case = gimple_switch_default_label (switch_stmt); @@ -2451,7 +2464,7 @@ is_ctrl_altering_stmt (gimple t) return true; case GIMPLE_ASM: - if (gimple_asm_nlabels (t) > 0) + if (gimple_asm_nlabels (as_a <gasm *> (t)) > 0) return true; break; @@ -2498,16 +2511,17 @@ stmt_starts_bb_p (gimple stmt, gimple prev_stmt) /* Labels start a new basic block only if the preceding statement wasn't a label of the same type. This prevents the creation of consecutive blocks that have nothing but a single label. */ - if (gimple_code (stmt) == GIMPLE_LABEL) + if (glabel *label_stmt = dyn_cast <glabel *> (stmt)) { /* Nonlocal and computed GOTO targets always start a new block. */ - if (DECL_NONLOCAL (gimple_label_label (stmt)) - || FORCED_LABEL (gimple_label_label (stmt))) + if (DECL_NONLOCAL (gimple_label_label (label_stmt)) + || FORCED_LABEL (gimple_label_label (label_stmt))) return true; if (prev_stmt && gimple_code (prev_stmt) == GIMPLE_LABEL) { - if (DECL_NONLOCAL (gimple_label_label (prev_stmt))) + if (DECL_NONLOCAL (gimple_label_label ( + as_a <glabel *> (prev_stmt)))) return true; cfg_stats.num_merged_labels++; @@ -2625,7 +2639,7 @@ reinstall_phi_args (edge new_edge, edge old_edge) { edge_var_map *vm; int i; - gimple_stmt_iterator phis; + gphi_iterator phis; vec<edge_var_map> *v = redirect_edge_var_map_vector (old_edge); if (!v) @@ -2635,7 +2649,7 @@ reinstall_phi_args (edge new_edge, edge old_edge) v->iterate (i, &vm) && !gsi_end_p (phis); i++, gsi_next (&phis)) { - gimple phi = gsi_stmt (phis); + gphi *phi = phis.phi (); tree result = redirect_edge_var_map_result (vm); tree arg = redirect_edge_var_map_def (vm); @@ -3241,7 +3255,7 @@ valid_fixed_convert_types_p (tree type1, tree type2) is a problem, otherwise false. */ static bool -verify_gimple_call (gimple stmt) +verify_gimple_call (gcall *stmt) { tree fn = gimple_call_fn (stmt); tree fntype, fndecl; @@ -3452,7 +3466,7 @@ verify_gimple_comparison (tree type, tree op0, tree op1) Returns true if anything is wrong. */ static bool -verify_gimple_assign_unary (gimple stmt) +verify_gimple_assign_unary (gassign *stmt) { enum tree_code rhs_code = gimple_assign_rhs_code (stmt); tree lhs = gimple_assign_lhs (stmt); @@ -3614,7 +3628,7 @@ verify_gimple_assign_unary (gimple stmt) Returns true if anything is wrong. */ static bool -verify_gimple_assign_binary (gimple stmt) +verify_gimple_assign_binary (gassign *stmt) { enum tree_code rhs_code = gimple_assign_rhs_code (stmt); tree lhs = gimple_assign_lhs (stmt); @@ -3855,7 +3869,7 @@ verify_gimple_assign_binary (gimple stmt) Returns true if anything is wrong. */ static bool -verify_gimple_assign_ternary (gimple stmt) +verify_gimple_assign_ternary (gassign *stmt) { enum tree_code rhs_code = gimple_assign_rhs_code (stmt); tree lhs = gimple_assign_lhs (stmt); @@ -4028,7 +4042,7 @@ verify_gimple_assign_ternary (gimple stmt) Returns true if anything is wrong. */ static bool -verify_gimple_assign_single (gimple stmt) +verify_gimple_assign_single (gassign *stmt) { enum tree_code rhs_code = gimple_assign_rhs_code (stmt); tree lhs = gimple_assign_lhs (stmt); @@ -4242,7 +4256,7 @@ verify_gimple_assign_single (gimple stmt) is a problem, otherwise false. */ static bool -verify_gimple_assign (gimple stmt) +verify_gimple_assign (gassign *stmt) { switch (gimple_assign_rhs_class (stmt)) { @@ -4267,7 +4281,7 @@ verify_gimple_assign (gimple stmt) is a problem, otherwise false. */ static bool -verify_gimple_return (gimple stmt) +verify_gimple_return (greturn *stmt) { tree op = gimple_return_retval (stmt); tree restype = TREE_TYPE (TREE_TYPE (cfun->decl)); @@ -4309,7 +4323,7 @@ verify_gimple_return (gimple stmt) is a problem, otherwise false. */ static bool -verify_gimple_goto (gimple stmt) +verify_gimple_goto (ggoto *stmt) { tree dest = gimple_goto_dest (stmt); @@ -4330,7 +4344,7 @@ verify_gimple_goto (gimple stmt) is a problem, otherwise false. */ static bool -verify_gimple_switch (gimple stmt) +verify_gimple_switch (gswitch *stmt) { unsigned int i, n; tree elt, prev_upper_bound = NULL_TREE; @@ -4434,7 +4448,7 @@ verify_gimple_debug (gimple stmt ATTRIBUTE_UNUSED) Returns true if anything is wrong. */ static bool -verify_gimple_label (gimple stmt) +verify_gimple_label (glabel *stmt) { tree decl = gimple_label_label (stmt); int uid; @@ -4472,6 +4486,31 @@ verify_gimple_label (gimple stmt) return err; } +/* Verify a gimple cond statement STMT. + Returns true if anything is wrong. */ + +static bool +verify_gimple_cond (gcond *stmt) +{ + if (TREE_CODE_CLASS (gimple_cond_code (stmt)) != tcc_comparison) + { + error ("invalid comparison code in gimple cond"); + return true; + } + if (!(!gimple_cond_true_label (stmt) + || TREE_CODE (gimple_cond_true_label (stmt)) == LABEL_DECL) + || !(!gimple_cond_false_label (stmt) + || TREE_CODE (gimple_cond_false_label (stmt)) == LABEL_DECL)) + { + error ("invalid labels in gimple cond"); + return true; + } + + return verify_gimple_comparison (boolean_type_node, + gimple_cond_lhs (stmt), + gimple_cond_rhs (stmt)); +} + /* Verify the GIMPLE statement STMT. Returns true if there is an error, otherwise false. */ @@ -4481,47 +4520,31 @@ verify_gimple_stmt (gimple stmt) switch (gimple_code (stmt)) { case GIMPLE_ASSIGN: - return verify_gimple_assign (stmt); + return verify_gimple_assign (as_a <gassign *> (stmt)); case GIMPLE_LABEL: - return verify_gimple_label (stmt); + return verify_gimple_label (as_a <glabel *> (stmt)); case GIMPLE_CALL: - return verify_gimple_call (stmt); + return verify_gimple_call (as_a <gcall *> (stmt)); case GIMPLE_COND: - if (TREE_CODE_CLASS (gimple_cond_code (stmt)) != tcc_comparison) - { - error ("invalid comparison code in gimple cond"); - return true; - } - if (!(!gimple_cond_true_label (stmt) - || TREE_CODE (gimple_cond_true_label (stmt)) == LABEL_DECL) - || !(!gimple_cond_false_label (stmt) - || TREE_CODE (gimple_cond_false_label (stmt)) == LABEL_DECL)) - { - error ("invalid labels in gimple cond"); - return true; - } - - return verify_gimple_comparison (boolean_type_node, - gimple_cond_lhs (stmt), - gimple_cond_rhs (stmt)); + return verify_gimple_cond (as_a <gcond *> (stmt)); case GIMPLE_GOTO: - return verify_gimple_goto (stmt); + return verify_gimple_goto (as_a <ggoto *> (stmt)); case GIMPLE_SWITCH: - return verify_gimple_switch (stmt); + return verify_gimple_switch (as_a <gswitch *> (stmt)); case GIMPLE_RETURN: - return verify_gimple_return (stmt); + return verify_gimple_return (as_a <greturn *> (stmt)); case GIMPLE_ASM: return false; case GIMPLE_TRANSACTION: - return verify_gimple_transaction (stmt); + return verify_gimple_transaction (as_a <gtransaction *> (stmt)); /* Tuples that do not have tree operands. */ case GIMPLE_NOP: @@ -4627,7 +4650,8 @@ verify_gimple_in_seq_2 (gimple_seq stmts) switch (gimple_code (stmt)) { case GIMPLE_BIND: - err |= verify_gimple_in_seq_2 (gimple_bind_body (stmt)); + err |= verify_gimple_in_seq_2 ( + gimple_bind_body (as_a <gbind *> (stmt))); break; case GIMPLE_TRY: @@ -4640,16 +4664,20 @@ verify_gimple_in_seq_2 (gimple_seq stmts) break; case GIMPLE_EH_ELSE: - err |= verify_gimple_in_seq_2 (gimple_eh_else_n_body (stmt)); - err |= verify_gimple_in_seq_2 (gimple_eh_else_e_body (stmt)); + { + geh_else *eh_else = as_a <geh_else *> (stmt); + err |= verify_gimple_in_seq_2 (gimple_eh_else_n_body (eh_else)); + err |= verify_gimple_in_seq_2 (gimple_eh_else_e_body (eh_else)); + } break; case GIMPLE_CATCH: - err |= verify_gimple_in_seq_2 (gimple_catch_handler (stmt)); + err |= verify_gimple_in_seq_2 (gimple_catch_handler ( + as_a <gcatch *> (stmt))); break; case GIMPLE_TRANSACTION: - err |= verify_gimple_transaction (stmt); + err |= verify_gimple_transaction (as_a <gtransaction *> (stmt)); break; default: @@ -4669,7 +4697,7 @@ verify_gimple_in_seq_2 (gimple_seq stmts) is a problem, otherwise false. */ static bool -verify_gimple_transaction (gimple stmt) +verify_gimple_transaction (gtransaction *stmt) { tree lab = gimple_transaction_label (stmt); if (lab != NULL && TREE_CODE (lab) != LABEL_DECL) @@ -4872,9 +4900,11 @@ verify_gimple_in_cfg (struct function *fn, bool verify_nothrow) { gimple_stmt_iterator gsi; - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gphi_iterator gpi = gsi_start_phis (bb); + !gsi_end_p (gpi); + gsi_next (&gpi)) { - gimple phi = gsi_stmt (gsi); + gphi *phi = gpi.phi (); bool err2 = false; unsigned i; @@ -5073,7 +5103,7 @@ gimple_verify_flow_info (void) if (gimple_code (stmt) != GIMPLE_LABEL) break; - label = gimple_label_label (stmt); + label = gimple_label_label (as_a <glabel *> (stmt)); if (prev_stmt && DECL_NONLOCAL (label)) { error ("nonlocal label "); @@ -5126,10 +5156,10 @@ gimple_verify_flow_info (void) if (stmt_ends_bb_p (stmt)) found_ctrl_stmt = true; - if (gimple_code (stmt) == GIMPLE_LABEL) + if (glabel *label_stmt = dyn_cast <glabel *> (stmt)) { error ("label "); - print_generic_expr (stderr, gimple_label_label (stmt), 0); + print_generic_expr (stderr, gimple_label_label (label_stmt), 0); fprintf (stderr, " in the middle of basic block %d", bb->index); err = 1; } @@ -5239,26 +5269,27 @@ gimple_verify_flow_info (void) case GIMPLE_SWITCH: { + gswitch *switch_stmt = as_a <gswitch *> (stmt); tree prev; edge e; size_t i, n; - n = gimple_switch_num_labels (stmt); + n = gimple_switch_num_labels (switch_stmt); /* Mark all the destination basic blocks. */ for (i = 0; i < n; ++i) { - tree lab = CASE_LABEL (gimple_switch_label (stmt, i)); + tree lab = CASE_LABEL (gimple_switch_label (switch_stmt, i)); basic_block label_bb = label_to_block (lab); gcc_assert (!label_bb->aux || label_bb->aux == (void *)1); label_bb->aux = (void *)1; } /* Verify that the case labels are sorted. */ - prev = gimple_switch_label (stmt, 0); + prev = gimple_switch_label (switch_stmt, 0); for (i = 1; i < n; ++i) { - tree c = gimple_switch_label (stmt, i); + tree c = gimple_switch_label (switch_stmt, i); if (!CASE_LOW (c)) { error ("found default case not at the start of " @@ -5304,7 +5335,7 @@ gimple_verify_flow_info (void) /* Check that we have all of them. */ for (i = 0; i < n; ++i) { - tree lab = CASE_LABEL (gimple_switch_label (stmt, i)); + tree lab = CASE_LABEL (gimple_switch_label (switch_stmt, i)); basic_block label_bb = label_to_block (lab); if (label_bb->aux != (void *)2) @@ -5320,7 +5351,7 @@ gimple_verify_flow_info (void) break; case GIMPLE_EH_DISPATCH: - err |= verify_eh_dispatch_edge (stmt); + err |= verify_eh_dispatch_edge (as_a <geh_dispatch *> (stmt)); break; default: @@ -5345,7 +5376,7 @@ gimple_make_forwarder_block (edge fallthru) edge_iterator ei; basic_block dummy, bb; tree var; - gimple_stmt_iterator gsi; + gphi_iterator gsi; dummy = fallthru->src; bb = fallthru->dest; @@ -5357,9 +5388,9 @@ gimple_make_forwarder_block (edge fallthru) start of BB. */ for (gsi = gsi_start_phis (dummy); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple phi, new_phi; + gphi *phi, *new_phi; - phi = gsi_stmt (gsi); + phi = gsi.phi (); var = gimple_phi_result (phi); new_phi = create_phi_node (var, bb); gimple_phi_set_result (phi, copy_ssa_name (var, phi)); @@ -5387,12 +5418,12 @@ gimple_block_label (basic_block bb) gimple_stmt_iterator i, s = gsi_start_bb (bb); bool first = true; tree label; - gimple stmt; + glabel *stmt; for (i = s; !gsi_end_p (i); first = false, gsi_next (&i)) { - stmt = gsi_stmt (i); - if (gimple_code (stmt) != GIMPLE_LABEL) + stmt = dyn_cast <glabel *> (gsi_stmt (i)); + if (!stmt) break; label = gimple_label_label (stmt); if (!DECL_NONLOCAL (label)) @@ -5492,8 +5523,9 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest) case GIMPLE_SWITCH: { + gswitch *switch_stmt = as_a <gswitch *> (stmt); tree label = gimple_block_label (dest); - tree cases = get_cases_for_edge (e, stmt); + tree cases = get_cases_for_edge (e, switch_stmt); /* If we have a list of cases associated with E, then use it as it's a lot faster than walking the entire case vector. */ @@ -5514,7 +5546,7 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest) to move all the cases associated with E to E2. */ if (e2) { - tree cases2 = get_cases_for_edge (e2, stmt); + tree cases2 = get_cases_for_edge (e2, switch_stmt); CASE_CHAIN (last) = CASE_CHAIN (cases2); CASE_CHAIN (cases2) = first; @@ -5523,11 +5555,11 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest) } else { - size_t i, n = gimple_switch_num_labels (stmt); + size_t i, n = gimple_switch_num_labels (switch_stmt); for (i = 0; i < n; i++) { - tree elt = gimple_switch_label (stmt, i); + tree elt = gimple_switch_label (switch_stmt, i); if (label_to_block (CASE_LABEL (elt)) == e->dest) CASE_LABEL (elt) = label; } @@ -5537,12 +5569,13 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest) case GIMPLE_ASM: { - int i, n = gimple_asm_nlabels (stmt); + gasm *asm_stmt = as_a <gasm *> (stmt); + int i, n = gimple_asm_nlabels (asm_stmt); tree label = NULL; for (i = 0; i < n; ++i) { - tree cons = gimple_asm_label_op (stmt, i); + tree cons = gimple_asm_label_op (asm_stmt, i); if (label_to_block (TREE_VALUE (cons)) == e->dest) { if (!label) @@ -5572,14 +5605,15 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest) case GIMPLE_EH_DISPATCH: if (!(e->flags & EDGE_FALLTHRU)) - redirect_eh_dispatch_edge (stmt, e, dest); + redirect_eh_dispatch_edge (as_a <geh_dispatch *> (stmt), e, dest); break; case GIMPLE_TRANSACTION: /* The ABORT edge has a stored label associated with it, otherwise the edges are simply redirectable. */ if (e->flags == 0) - gimple_transaction_set_label (stmt, gimple_block_label (dest)); + gimple_transaction_set_label (as_a <gtransaction *> (stmt), + gimple_block_label (dest)); break; default: @@ -5748,17 +5782,18 @@ static basic_block gimple_duplicate_bb (basic_block bb) { basic_block new_bb; - gimple_stmt_iterator gsi, gsi_tgt; - gimple_seq phis = phi_nodes (bb); - gimple phi, stmt, copy; + gimple_stmt_iterator gsi_tgt; new_bb = create_empty_bb (EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb); /* Copy the PHI nodes. We ignore PHI node arguments here because the incoming edges have not been setup yet. */ - for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gphi_iterator gpi = gsi_start_phis (bb); + !gsi_end_p (gpi); + gsi_next (&gpi)) { - phi = gsi_stmt (gsi); + gphi *phi, *copy; + phi = gpi.phi (); copy = create_phi_node (NULL_TREE, new_bb); create_new_def_for (gimple_phi_result (phi), copy, gimple_phi_result_ptr (copy)); @@ -5766,11 +5801,14 @@ gimple_duplicate_bb (basic_block bb) } gsi_tgt = gsi_start_bb (new_bb); - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); + !gsi_end_p (gsi); + gsi_next (&gsi)) { def_operand_p def_p; ssa_op_iter op_iter; tree lhs; + gimple stmt, copy; stmt = gsi_stmt (gsi); if (gimple_code (stmt) == GIMPLE_LABEL) @@ -5825,9 +5863,9 @@ add_phi_args_after_copy_edge (edge e_copy) basic_block bb, bb_copy = e_copy->src, dest; edge e; edge_iterator ei; - gimple phi, phi_copy; + gphi *phi, *phi_copy; tree def; - gimple_stmt_iterator psi, psi_copy; + gphi_iterator psi, psi_copy; if (gimple_seq_empty_p (phi_nodes (e_copy->dest))) return; @@ -5860,8 +5898,8 @@ add_phi_args_after_copy_edge (edge e_copy) !gsi_end_p (psi); gsi_next (&psi), gsi_next (&psi_copy)) { - phi = gsi_stmt (psi); - phi_copy = gsi_stmt (psi_copy); + phi = psi.phi (); + phi_copy = psi_copy.phi (); def = PHI_ARG_DEF_FROM_EDGE (phi, e); add_phi_arg (phi_copy, def, e_copy, gimple_phi_arg_location_from_edge (phi, e)); @@ -6123,8 +6161,8 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU gimple cond_stmt; edge sorig, snew; basic_block exit_bb; - gimple_stmt_iterator psi; - gimple phi; + gphi_iterator psi; + gphi *phi; tree def; struct loop *target, *aloop, *cloop; @@ -6244,7 +6282,7 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU !gsi_end_p (psi); gsi_next (&psi)) { - phi = gsi_stmt (psi); + phi = psi.phi (); def = PHI_ARG_DEF (phi, nexits[0]->dest_idx); add_phi_arg (phi, def, e, gimple_phi_arg_location_from_edge (phi, e)); } @@ -6517,17 +6555,19 @@ move_stmt_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p, case GIMPLE_RESX: { - int r = gimple_resx_region (stmt); + gresx *resx_stmt = as_a <gresx *> (stmt); + int r = gimple_resx_region (resx_stmt); r = move_stmt_eh_region_nr (r, p); - gimple_resx_set_region (stmt, r); + gimple_resx_set_region (resx_stmt, r); } break; case GIMPLE_EH_DISPATCH: { - int r = gimple_eh_dispatch_region (stmt); + geh_dispatch *eh_dispatch_stmt = as_a <geh_dispatch *> (stmt); + int r = gimple_eh_dispatch_region (eh_dispatch_stmt); r = move_stmt_eh_region_nr (r, p); - gimple_eh_dispatch_set_region (stmt, r); + gimple_eh_dispatch_set_region (eh_dispatch_stmt, r); } break; @@ -6619,9 +6659,10 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb, (*cfg->x_basic_block_info)[bb->index] = bb; /* Remap the variables in phi nodes. */ - for (si = gsi_start_phis (bb); !gsi_end_p (si); ) + for (gphi_iterator psi = gsi_start_phis (bb); + !gsi_end_p (psi); ) { - gimple phi = gsi_stmt (si); + gphi *phi = psi.phi (); use_operand_p use; tree op = PHI_RESULT (phi); ssa_op_iter oi; @@ -6631,7 +6672,7 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb, { /* Remove the phi nodes for virtual operands (alias analysis will be run for the new function, anyway). */ - remove_phi_node (&si, true); + remove_phi_node (&psi, true); continue; } @@ -6661,7 +6702,7 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb, } } - gsi_next (&si); + gsi_next (&psi); } for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) @@ -6673,9 +6714,9 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb, wi.info = d; walk_gimple_stmt (&si, move_stmt_r, move_stmt_op, &wi); - if (gimple_code (stmt) == GIMPLE_LABEL) + if (glabel *label_stmt = dyn_cast <glabel *> (stmt)) { - tree label = gimple_label_label (stmt); + tree label = gimple_label_label (label_stmt); int uid = LABEL_DECL_UID (label); gcc_assert (uid > -1); @@ -7569,9 +7610,9 @@ need_fake_edge_p (gimple t) return true; } - if (gimple_code (t) == GIMPLE_ASM - && (gimple_asm_volatile_p (t) || gimple_asm_input_p (t))) - return true; + if (gasm *asm_stmt = dyn_cast <gasm *> (t)) + if (gimple_asm_volatile_p (asm_stmt) || gimple_asm_input_p (asm_stmt)) + return true; return false; } @@ -7969,8 +8010,8 @@ static void gimple_lv_adjust_loop_header_phi (basic_block first, basic_block second, basic_block new_head, edge e) { - gimple phi1, phi2; - gimple_stmt_iterator psi1, psi2; + gphi *phi1, *phi2; + gphi_iterator psi1, psi2; tree def; edge e2 = find_edge (new_head, second); @@ -7986,8 +8027,8 @@ gimple_lv_adjust_loop_header_phi (basic_block first, basic_block second, !gsi_end_p (psi2) && !gsi_end_p (psi1); gsi_next (&psi2), gsi_next (&psi1)) { - phi1 = gsi_stmt (psi1); - phi2 = gsi_stmt (psi2); + phi1 = psi1.phi (); + phi2 = psi2.phi (); def = PHI_ARG_DEF (phi2, e2->dest_idx); add_phi_arg (phi1, def, e, gimple_phi_arg_location_from_edge (phi2, e2)); } @@ -8353,8 +8394,9 @@ pass_warn_function_return::execute (function *fun) FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (fun)->preds) { gimple last = last_stmt (e->src); - if (gimple_code (last) == GIMPLE_RETURN - && gimple_return_retval (last) == NULL + greturn *return_stmt = dyn_cast <greturn *> (last); + if (return_stmt + && gimple_return_retval (return_stmt) == NULL && !gimple_no_warning_p (last)) { location = gimple_location (last); @@ -8394,14 +8436,15 @@ do_warn_unused_result (gimple_seq seq) switch (gimple_code (g)) { case GIMPLE_BIND: - do_warn_unused_result (gimple_bind_body (g)); + do_warn_unused_result (gimple_bind_body (as_a <gbind *>(g))); break; case GIMPLE_TRY: do_warn_unused_result (gimple_try_eval (g)); do_warn_unused_result (gimple_try_cleanup (g)); break; case GIMPLE_CATCH: - do_warn_unused_result (gimple_catch_handler (g)); + do_warn_unused_result (gimple_catch_handler ( + as_a <gcatch *> (g))); break; case GIMPLE_EH_FILTER: do_warn_unused_result (gimple_eh_filter_failure (g)); |