From ecc82929a44b5a046c89ba1361c354f1466b85e4 Mon Sep 17 00:00:00 2001 From: rth Date: Fri, 29 Aug 2003 22:25:19 +0000 Subject: [PATCH] * function.c (allocate_struct_function): New, split out of ... (prepare_function_start, init_function_start): ... here. * expr.c (init_expr): Use ggc_alloc_cleared. * stmt.c (init_stmt_for_function): Likewise. * tree.h (allocate_struct_function): Declare. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70929 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 8 +++ gcc/expr.c | 10 +--- gcc/function.c | 170 +++++++++++++++++---------------------------------------- gcc/stmt.c | 20 +------ gcc/tree.h | 1 + 5 files changed, 62 insertions(+), 147 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 48a24ce..d3443b5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2003-08-29 Richard Henderson + + * function.c (allocate_struct_function): New, split out of ... + (prepare_function_start, init_function_start): ... here. + * expr.c (init_expr): Use ggc_alloc_cleared. + * stmt.c (init_stmt_for_function): Likewise. + * tree.h (allocate_struct_function): Declare. + 2003-08-29 Nathanael Nerode * config.gcc: Don't use negated character class in shell case diff --git a/gcc/expr.c b/gcc/expr.c index 52cdfee..94c453d 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -338,15 +338,7 @@ init_expr_once (void) void init_expr (void) { - cfun->expr = ggc_alloc (sizeof (struct expr_status)); - - pending_chain = 0; - pending_stack_adjust = 0; - stack_pointer_delta = 0; - inhibit_defer_pop = 0; - saveregs_value = 0; - apply_args_value = 0; - forced_labels = 0; + cfun->expr = ggc_alloc_cleared (sizeof (struct expr_status)); } /* Small sanity check that the queue is empty at the end of a function. */ diff --git a/gcc/function.c b/gcc/function.c index a17ace1..6decfdf 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -284,7 +284,7 @@ static hashval_t insns_for_mem_hash (const void *); static int insns_for_mem_comp (const void *, const void *); static int insns_for_mem_walk (rtx *, void *); static void compute_insns_for_mem (rtx, rtx, htab_t); -static void prepare_function_start (void); +static void prepare_function_start (tree); static void do_clobber_return_reg (rtx, void *); static void do_use_return_reg (rtx, void *); static void instantiate_virtual_regs_lossage (rtx); @@ -6246,103 +6246,77 @@ debug_find_var_in_block_tree (tree var, tree block) return NULL_TREE; } -/* Allocate a function structure and reset its contents to the defaults. */ +/* Allocate a function structure for FNDECL and set its contents + to the defaults. */ -static void -prepare_function_start (void) +void +allocate_struct_function (tree fndecl) { - cfun = ggc_alloc_cleared (sizeof (struct function)); - - init_stmt_for_function (); - init_eh_for_function (); - - cse_not_expected = ! optimize; - - /* Caller save not needed yet. */ - caller_save_needed = 0; - - /* No stack slots have been made yet. */ - stack_slot_list = 0; + tree result; - current_function_has_nonlocal_label = 0; - current_function_has_nonlocal_goto = 0; + cfun = ggc_alloc_cleared (sizeof (struct function)); - /* There is no stack slot for handling nonlocal gotos. */ - nonlocal_goto_handler_slots = 0; - nonlocal_goto_stack_level = 0; + max_parm_reg = LAST_VIRTUAL_REGISTER + 1; - /* No labels have been declared for nonlocal use. */ - nonlocal_labels = 0; - nonlocal_goto_handler_labels = 0; + cfun->stack_alignment_needed = STACK_BOUNDARY; + cfun->preferred_stack_boundary = STACK_BOUNDARY; - /* No function calls so far in this function. */ - function_call_count = 0; + current_function_funcdef_no = funcdef_no++; - /* No parm regs have been allocated. - (This is important for output_inline_function.) */ - max_parm_reg = LAST_VIRTUAL_REGISTER + 1; + cfun->function_frequency = FUNCTION_FREQUENCY_NORMAL; - /* Initialize the RTL mechanism. */ + init_stmt_for_function (); + init_eh_for_function (); init_emit (); - - /* Initialize the queue of pending postincrement and postdecrements, - and some other info in expr.c. */ init_expr (); - - /* We haven't done register allocation yet. */ - reg_renumber = 0; - init_varasm_status (cfun); - /* Clear out data used for inlining. */ - cfun->inlinable = 0; - cfun->original_decl_initial = 0; - cfun->original_arg_vector = 0; + (*lang_hooks.function.init) (cfun); + if (init_machine_status) + cfun->machine = (*init_machine_status) (); - cfun->stack_alignment_needed = STACK_BOUNDARY; - cfun->preferred_stack_boundary = STACK_BOUNDARY; + if (fndecl == NULL) + return; - /* Set if a call to setjmp is seen. */ - current_function_calls_setjmp = 0; + DECL_SAVED_INSNS (fndecl) = cfun; + cfun->decl = fndecl; - /* Set if a call to longjmp is seen. */ - current_function_calls_longjmp = 0; + current_function_name = (*lang_hooks.decl_printable_name) (fndecl, 2); - current_function_calls_alloca = 0; - current_function_calls_eh_return = 0; - current_function_calls_constant_p = 0; - current_function_contains_functions = 0; - current_function_is_leaf = 0; - current_function_nothrow = 0; - current_function_sp_is_unchanging = 0; - current_function_uses_only_leaf_regs = 0; - current_function_has_computed_jump = 0; - current_function_is_thunk = 0; + result = DECL_RESULT (fndecl); + if (aggregate_value_p (result)) + { +#ifdef PCC_STATIC_STRUCT_RETURN + current_function_returns_pcc_struct = 1; +#endif + current_function_returns_struct = 1; + } - current_function_returns_pcc_struct = 0; - current_function_returns_struct = 0; - current_function_epilogue_delay_list = 0; - current_function_uses_const_pool = 0; - current_function_uses_pic_offset_table = 0; - current_function_cannot_inline = 0; + current_function_returns_pointer = POINTER_TYPE_P (TREE_TYPE (result)); - /* We have not yet needed to make a label to jump to for tail-recursion. */ - tail_recursion_label = 0; + current_function_needs_context + = (decl_function_context (current_function_decl) != 0 + && ! DECL_NO_STATIC_CHAIN (current_function_decl)); +} - /* We haven't had a need to make a save area for ap yet. */ - arg_pointer_save_area = 0; +/* Reset cfun, and other non-struct-function variables to defaults as + appropriate for emiiting rtl at the start of a function. */ - /* No stack slots allocated yet. */ - frame_offset = 0; +static void +prepare_function_start (tree fndecl) +{ + if (fndecl && DECL_SAVED_INSNS (fndecl)) + cfun = DECL_SAVED_INSNS (fndecl); + else + allocate_struct_function (fndecl); - /* No SAVE_EXPRs in this function yet. */ - save_expr_regs = 0; + cse_not_expected = ! optimize; - /* No RTL_EXPRs in this function yet. */ - rtl_expr_chain = 0; + /* Caller save not needed yet. */ + caller_save_needed = 0; - /* Set up to allocate temporaries. */ - init_temp_slots (); + /* We haven't done register allocation yet. */ + reg_renumber = 0; /* Indicate that we need to distinguish between the return value of the present function and the return value of a function being called. */ @@ -6356,27 +6330,6 @@ prepare_function_start (void) /* Indicate we have no need of a frame pointer yet. */ frame_pointer_needed = 0; - - /* By default assume not stdarg. */ - current_function_stdarg = 0; - - /* We haven't made any trampolines for this function yet. */ - trampoline_list = 0; - - init_pending_stack_adjust (); - inhibit_defer_pop = 0; - - current_function_outgoing_args_size = 0; - - current_function_funcdef_no = funcdef_no++; - - cfun->function_frequency = FUNCTION_FREQUENCY_NORMAL; - - cfun->max_jumptable_ents = 0; - - (*lang_hooks.function.init) (cfun); - if (init_machine_status) - cfun->machine = (*init_machine_status) (); } /* Initialize the rtl expansion mechanism so that we can do simple things @@ -6385,7 +6338,7 @@ prepare_function_start (void) void init_dummy_function_start (void) { - prepare_function_start (); + prepare_function_start (NULL); } /* Generate RTL for the start of the function SUBR (a FUNCTION_DECL tree node) @@ -6395,16 +6348,7 @@ init_dummy_function_start (void) void init_function_start (tree subr) { - prepare_function_start (); - - current_function_name = (*lang_hooks.decl_printable_name) (subr, 2); - cfun->decl = subr; - - /* Nonzero if this is a nested function that uses a static chain. */ - - current_function_needs_context - = (decl_function_context (current_function_decl) != 0 - && ! DECL_NO_STATIC_CHAIN (current_function_decl)); + prepare_function_start (subr); /* Within function body, compute a type's size as soon it is laid out. */ immediate_size_expand++; @@ -6421,23 +6365,11 @@ init_function_start (tree subr) Also, final expects a note to appear there. */ emit_note (NOTE_INSN_DELETED); - /* Set flags used by final.c. */ - if (aggregate_value_p (DECL_RESULT (subr))) - { -#ifdef PCC_STATIC_STRUCT_RETURN - current_function_returns_pcc_struct = 1; -#endif - current_function_returns_struct = 1; - } - /* Warn if this value is an aggregate type, regardless of which calling convention we are using for it. */ if (warn_aggregate_return && AGGREGATE_TYPE_P (TREE_TYPE (DECL_RESULT (subr)))) warning ("function returns an aggregate"); - - current_function_returns_pointer - = POINTER_TYPE_P (TREE_TYPE (DECL_RESULT (subr))); } /* Make sure all values used by the optimization passes have sane diff --git a/gcc/stmt.c b/gcc/stmt.c index defbb70..54c93be 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -433,25 +433,7 @@ using_eh_for_cleanups (void) void init_stmt_for_function (void) { - cfun->stmt =ggc_alloc (sizeof (struct stmt_status)); - - /* We are not currently within any block, conditional, loop or case. */ - block_stack = 0; - stack_block_stack = 0; - loop_stack = 0; - case_stack = 0; - cond_stack = 0; - nesting_stack = 0; - nesting_depth = 0; - - current_block_start_count = 0; - - /* No gotos have been expanded yet. */ - goto_fixup_chain = 0; - - /* We are not processing a ({...}) grouping. */ - expr_stmts_for_value = 0; - clear_last_expr (); + cfun->stmt = ggc_alloc_cleared (sizeof (struct stmt_status)); } /* Record the current file and line. Called from emit_line_note. */ diff --git a/gcc/tree.h b/gcc/tree.h index 7f99a51..ec60935 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -2856,6 +2856,7 @@ extern void expand_main_function (void); extern void init_dummy_function_start (void); extern void expand_dummy_function_end (void); extern void init_function_for_compilation (void); +extern void allocate_struct_function (tree); extern void init_function_start (tree); extern void assign_parms (tree); extern void put_var_into_stack (tree, int); -- 2.7.4