void genrtl_switch_stmt (tree t) { tree cond; genrtl_do_pushlevel (); cond = expand_cond (SWITCH_COND (t)); if (cond == error_mark_node) /* The code is in error, but we don't want expand_end_case to crash. */ cond = truthvalue_false_node; emit_line_note (input_location); expand_start_case (1, cond, TREE_TYPE (cond), "switch statement"); expand_stmt (expand_unreachable_stmt (SWITCH_BODY (t), warn_notreached)); expand_end_case_type (cond, SWITCH_TYPE (t)); }
static enum gimplify_status gimplify_switch_stmt (tree *stmt_p) { tree stmt = *stmt_p; tree break_block, body; location_t stmt_locus = input_location; break_block = begin_bc_block (bc_break); body = SWITCH_BODY (stmt); if (!body) body = build_empty_stmt (); *stmt_p = build3 (SWITCH_EXPR, SWITCH_TYPE (stmt), SWITCH_COND (stmt), body, NULL_TREE); SET_EXPR_LOCATION (*stmt_p, stmt_locus); gimplify_stmt (stmt_p); *stmt_p = finish_bc_block (break_block, *stmt_p); return GS_ALL_DONE; }
static tree fix_conditional_array_notations_1 (tree stmt) { vec<tree, va_gc> *array_list = NULL, *array_operand = NULL; size_t list_size = 0; tree cond = NULL_TREE, builtin_loop = NULL_TREE, new_var = NULL_TREE; size_t rank = 0, ii = 0; tree loop_init; location_t location = EXPR_LOCATION (stmt); tree body = NULL_TREE, loop_with_init = alloc_stmt_list (); vec<vec<an_parts> > an_info = vNULL; vec<an_loop_parts> an_loop_info = vNULL; if (TREE_CODE (stmt) == COND_EXPR) cond = COND_EXPR_COND (stmt); else if (TREE_CODE (stmt) == SWITCH_EXPR) cond = SWITCH_COND (stmt); else if (truth_value_p (TREE_CODE (stmt))) cond = TREE_OPERAND (stmt, 0); else /* Otherwise dont even touch the statement. */ return stmt; if (!find_rank (location, cond, cond, false, &rank)) return error_mark_node; extract_array_notation_exprs (stmt, false, &array_list); loop_init = push_stmt_list (); for (ii = 0; ii < vec_safe_length (array_list); ii++) { tree array_node = (*array_list)[ii]; if (TREE_CODE (array_node) == CALL_EXPR) { builtin_loop = fix_builtin_array_notation_fn (array_node, &new_var); if (builtin_loop == error_mark_node) { add_stmt (error_mark_node); pop_stmt_list (loop_init); return loop_init; } else if (builtin_loop) { vec <tree, va_gc>* sub_list = NULL, *new_var_list = NULL; vec_safe_push (sub_list, array_node); vec_safe_push (new_var_list, new_var); add_stmt (builtin_loop); replace_array_notations (&stmt, false, sub_list, new_var_list); } } } if (!find_rank (location, stmt, stmt, true, &rank)) { pop_stmt_list (loop_init); return error_mark_node; } if (rank == 0) { add_stmt (stmt); pop_stmt_list (loop_init); return loop_init; } extract_array_notation_exprs (stmt, true, &array_list); if (vec_safe_length (array_list) == 0) return stmt; list_size = vec_safe_length (array_list); an_loop_info.safe_grow_cleared (rank); for (ii = 0; ii < list_size; ii++) if ((*array_list)[ii] && TREE_CODE ((*array_list)[ii]) == ARRAY_NOTATION_REF) { tree array_node = (*array_list)[ii]; make_triplet_val_inv (location, &ARRAY_NOTATION_START (array_node)); make_triplet_val_inv (location, &ARRAY_NOTATION_LENGTH (array_node)); make_triplet_val_inv (location, &ARRAY_NOTATION_STRIDE (array_node)); } cilkplus_extract_an_triplets (array_list, list_size, rank, &an_info); for (ii = 0; ii < rank; ii++) { an_loop_info[ii].var = create_tmp_var (integer_type_node); an_loop_info[ii].ind_init = build_modify_expr (location, an_loop_info[ii].var, TREE_TYPE (an_loop_info[ii].var), NOP_EXPR, location, build_int_cst (TREE_TYPE (an_loop_info[ii].var), 0), TREE_TYPE (an_loop_info[ii].var)); } array_operand = create_array_refs (location, an_info, an_loop_info, list_size, rank); replace_array_notations (&stmt, true, array_list, array_operand); create_cmp_incr (location, &an_loop_info, rank, an_info); loop_init = pop_stmt_list (loop_init); body = stmt; append_to_statement_list_force (loop_init, &loop_with_init); for (ii = 0; ii < rank; ii++) { tree new_loop = push_stmt_list (); add_stmt (an_loop_info[ii].ind_init); c_finish_loop (location, an_loop_info[ii].cmp, an_loop_info[ii].incr, body, NULL_TREE, NULL_TREE, true); body = pop_stmt_list (new_loop); } append_to_statement_list_force (body, &loop_with_init); an_loop_info.release (); an_info.release (); return loop_with_init; }
bool c_dump_tree (void *dump_info, tree t) { enum tree_code code; dump_info_p di = (dump_info_p) dump_info; /* Figure out what kind of node this is. */ code = TREE_CODE (t); switch (code) { case FIELD_DECL: if (DECL_C_BIT_FIELD (t)) dump_string (di, "bitfield"); break; case BREAK_STMT: case CONTINUE_STMT: dump_stmt (di, t); break; case DO_STMT: dump_stmt (di, t); dump_child ("body", DO_BODY (t)); dump_child ("cond", DO_COND (t)); break; case EXPR_STMT: dump_stmt (di, t); dump_child ("expr", EXPR_STMT_EXPR (t)); break; case FOR_STMT: dump_stmt (di, t); dump_child ("init", FOR_INIT_STMT (t)); dump_child ("cond", FOR_COND (t)); dump_child ("expr", FOR_EXPR (t)); dump_child ("body", FOR_BODY (t)); break; case SWITCH_STMT: dump_stmt (di, t); dump_child ("cond", SWITCH_COND (t)); dump_child ("body", SWITCH_BODY (t)); break; case WHILE_STMT: dump_stmt (di, t); dump_child ("cond", WHILE_COND (t)); dump_child ("body", WHILE_BODY (t)); break; case STMT_EXPR: dump_child ("stmt", STMT_EXPR_STMT (t)); break; default: break; } return false; }