This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: struct function cleanup part I
> Jan Hubicka wrote:
>
> >OK, Would crtl variant look acceptable then?
>
> I don't mind crtl. I don't much are what it's named, and it gives us
> some kind of hook for the future. I also don't mind cfun->rtl; the only
> reason I suggested a separate function was so that we didn't have to
> waste the pointer in cfun.
>
> I'm not at all hung up on how this is organized. I'm just trying to
> suggest that we pass the RTL information around as a pointer (whether
> directly, or as something they can compute from some other parameter
> they have like a FUNCTION_DECL for the function) to the functions that
> need it, rather than having them access a single magic global object.
OK,
I guess we are set then on crtl. I've tested in meantime on i686-linux
and x86-64-linux the following patch.
OK?
Honza
* function.h (rtl): Rename to x_rtl.
(crtl): New define.
(return_label, naked_return_label, stack_slot_list, parm_birth_insn,
frame_offset, stack_check_probe_note, arg_pointer_save_area,
used_temp_slots avail_temp_slots, temp_slot_level,
nonlocal_goto_handler_labels): Update accesstors.
(rtl): New global variable.
(struct function): Move some fileds to rtl_data.
(get_arg_pointer_save_area): Update prototype.
* builtins.c (expand_builtin_setjmp_receiver): Update call of
get_arg_pointer_save_area.
* expr.c (init_expr): Update
* function.c (get_frame_size): Update
(assign_stack_local): Update
(expand_function_end): Update.
(get_art_pointer_save_area): Update
* function.h
* emit-rtl.c (rtl): Declare.
(regno_reg_rtx): Declare.
(first_insn, last_insn, cur_insn_uid, last_location, first_label_num):
Update.
(gen_reg_rtx): Update.
* varasm.c (n_deferred_constatns): Update accestor.
(init_varasm_status): Do not allocate varasm_status.
(force_const_mem, get_pool_size, output_constant_pool): Update.
* stmt.c (force_label_rtx): Do not use x_ prefixes.
(expand_nl_goto_receiver): Update get_arg_pointer_save_area.
* m32c/m32.c (m32c_leaf_function_p, m32c_function_needs_enter): Update.
* sparc/sparc.h (INIT_EXPANDERS): Update.
* ia64/ia64.h (INIT_EXPANDERS): Update.
Index: expr.c
===================================================================
*** expr.c (revision 133929)
--- expr.c (working copy)
*************** init_expr_target (void)
*** 344,350 ****
void
init_expr (void)
{
! memset (&rtl.expr, 0, sizeof (rtl.expr));
}
/* Copy data from FROM to TO, where the machine modes are not the same.
--- 344,350 ----
void
init_expr (void)
{
! memset (&crtl->expr, 0, sizeof (rtl (cfun)->expr));
}
/* Copy data from FROM to TO, where the machine modes are not the same.
Index: function.c
===================================================================
*** function.c (revision 133929)
--- function.c (working copy)
*************** free_after_compilation (struct function
*** 284,293 ****
VEC_free (int, heap, prologue);
VEC_free (int, heap, epilogue);
VEC_free (int, heap, sibcall_epilogue);
! if (rtl.emit.regno_pointer_align)
! free (rtl.emit.regno_pointer_align);
! memset (&rtl, 0, sizeof (rtl));
f->eh = NULL;
f->machine = NULL;
f->cfg = NULL;
--- 284,293 ----
VEC_free (int, heap, prologue);
VEC_free (int, heap, epilogue);
VEC_free (int, heap, sibcall_epilogue);
! if (crtl->emit.regno_pointer_align)
! free (crtl->emit.regno_pointer_align);
! memset (crtl, 0, sizeof (struct rtl_data));
f->eh = NULL;
f->machine = NULL;
f->cfg = NULL;
*************** push_struct_function (tree fndecl)
*** 3907,3913 ****
static void
prepare_function_start (void)
{
! gcc_assert (!rtl.emit.x_last_insn);
init_emit ();
init_varasm_status ();
init_expr ();
--- 3907,3913 ----
static void
prepare_function_start (void)
{
! gcc_assert (!crtl->emit.x_last_insn);
init_emit ();
init_varasm_status ();
init_expr ();
Index: function.h
===================================================================
*** function.h (revision 133929)
--- function.h (working copy)
*************** struct emit_status GTY(())
*** 87,99 ****
FIXME: We could put it into emit_status struct, but gengtype is not able to deal
with length attribute nested in top level structures. */
! extern GTY ((length ("rtl.emit.x_reg_rtx_no"))) rtx * regno_reg_rtx;
/* For backward compatibility... eventually these should all go away. */
! #define reg_rtx_no (rtl.emit.x_reg_rtx_no)
! #define seq_stack (rtl.emit.sequence_stack)
! #define REGNO_POINTER_ALIGN(REGNO) (rtl.emit.regno_pointer_align[REGNO])
struct expr_status GTY(())
{
--- 87,99 ----
FIXME: We could put it into emit_status struct, but gengtype is not able to deal
with length attribute nested in top level structures. */
! extern GTY ((length ("crtl->emit.x_reg_rtx_no"))) rtx * regno_reg_rtx;
/* For backward compatibility... eventually these should all go away. */
! #define reg_rtx_no (crtl->emit.x_reg_rtx_no)
! #define seq_stack (crtl->emit.sequence_stack)
! #define REGNO_POINTER_ALIGN(REGNO) (crtl->emit.regno_pointer_align[REGNO])
struct expr_status GTY(())
{
*************** struct expr_status GTY(())
*** 136,147 ****
rtx x_forced_labels;
};
! #define pending_stack_adjust (rtl.expr.x_pending_stack_adjust)
! #define inhibit_defer_pop (rtl.expr.x_inhibit_defer_pop)
! #define saveregs_value (rtl.expr.x_saveregs_value)
! #define apply_args_value (rtl.expr.x_apply_args_value)
! #define forced_labels (rtl.expr.x_forced_labels)
! #define stack_pointer_delta (rtl.expr.x_stack_pointer_delta)
struct gimple_df;
struct temp_slot;
--- 136,147 ----
rtx x_forced_labels;
};
! #define pending_stack_adjust (crtl->expr.x_pending_stack_adjust)
! #define inhibit_defer_pop (crtl->expr.x_inhibit_defer_pop)
! #define saveregs_value (crtl->expr.x_saveregs_value)
! #define apply_args_value (crtl->expr.x_apply_args_value)
! #define forced_labels (crtl->expr.x_forced_labels)
! #define stack_pointer_delta (crtl->expr.x_stack_pointer_delta)
struct gimple_df;
struct temp_slot;
*************** struct rtl_data GTY(())
*** 193,199 ****
rtx x_naked_return_label;
/* List (chain of EXPR_LISTs) of all stack slots in this function.
! Made for the sake of unshare_all_rtl. */
rtx x_stack_slot_list;
/* Place after which to insert the tail_recursion_label if we need one. */
--- 193,199 ----
rtx x_naked_return_label;
/* List (chain of EXPR_LISTs) of all stack slots in this function.
! Made for the sake of unshare_all_crtl-> */
rtx x_stack_slot_list;
/* Place after which to insert the tail_recursion_label if we need one. */
*************** struct rtl_data GTY(())
*** 226,244 ****
int inl_max_label_num;
};
! #define return_label (rtl.x_return_label)
! #define naked_return_label (rtl.x_naked_return_label)
! #define stack_slot_list (rtl.x_stack_slot_list)
! #define parm_birth_insn (rtl.x_parm_birth_insn)
! #define frame_offset (rtl.x_frame_offset)
! #define stack_check_probe_note (rtl.x_stack_check_probe_note)
! #define arg_pointer_save_area (rtl.x_arg_pointer_save_area)
! #define used_temp_slots (rtl.x_used_temp_slots)
! #define avail_temp_slots (rtl.x_avail_temp_slots)
! #define temp_slot_level (rtl.x_temp_slot_level)
! #define nonlocal_goto_handler_labels (rtl.x_nonlocal_goto_handler_labels)
!
! extern GTY(()) struct rtl_data rtl;
/* This structure can save all the important global and static variables
describing the status of the current function. */
--- 226,249 ----
int inl_max_label_num;
};
! #define return_label (crtl->x_return_label)
! #define naked_return_label (crtl->x_naked_return_label)
! #define stack_slot_list (crtl->x_stack_slot_list)
! #define parm_birth_insn (crtl->x_parm_birth_insn)
! #define frame_offset (crtl->x_frame_offset)
! #define stack_check_probe_note (crtl->x_stack_check_probe_note)
! #define arg_pointer_save_area (crtl->x_arg_pointer_save_area)
! #define used_temp_slots (crtl->x_used_temp_slots)
! #define avail_temp_slots (crtl->x_avail_temp_slots)
! #define temp_slot_level (crtl->x_temp_slot_level)
! #define nonlocal_goto_handler_labels (crtl->x_nonlocal_goto_handler_labels)
!
! extern GTY(()) struct rtl_data x_rtl;
!
! /* Accestor to RTL datastructures. We keep them statically allocated now since
! we never keep multiple functions. For threaded compiler we might however
! want to do differntly. */
! #define crtl (&x_rtl)
/* This structure can save all the important global and static variables
describing the status of the current function. */
Index: emit-rtl.c
===================================================================
*** emit-rtl.c (revision 133929)
--- emit-rtl.c (working copy)
*************** enum machine_mode ptr_mode; /* Mode whos
*** 68,74 ****
/* Datastructures maintained for currently processed function in RTL form. */
! struct rtl_data rtl;
/* Indexed by pseudo register number, gives the rtx for that pseudo.
Allocated in parallel with regno_pointer_align.
--- 68,74 ----
/* Datastructures maintained for currently processed function in RTL form. */
! struct rtl_data x_rtl;
/* Indexed by pseudo register number, gives the rtx for that pseudo.
Allocated in parallel with regno_pointer_align.
*************** static GTY ((if_marked ("ggc_marked_p"),
*** 172,182 ****
static GTY ((if_marked ("ggc_marked_p"), param_is (struct rtx_def)))
htab_t const_fixed_htab;
! #define first_insn (rtl.emit.x_first_insn)
! #define last_insn (rtl.emit.x_last_insn)
! #define cur_insn_uid (rtl.emit.x_cur_insn_uid)
! #define last_location (rtl.emit.x_last_location)
! #define first_label_num (rtl.emit.x_first_label_num)
static rtx make_call_insn_raw (rtx);
static rtx change_address_1 (rtx, enum machine_mode, rtx, int);
--- 172,182 ----
static GTY ((if_marked ("ggc_marked_p"), param_is (struct rtx_def)))
htab_t const_fixed_htab;
! #define first_insn (crtl->emit.x_first_insn)
! #define last_insn (crtl->emit.x_last_insn)
! #define cur_insn_uid (crtl->emit.x_cur_insn_uid)
! #define last_location (crtl->emit.x_last_location)
! #define first_label_num (crtl->emit.x_first_label_num)
static rtx make_call_insn_raw (rtx);
static rtx change_address_1 (rtx, enum machine_mode, rtx, int);
*************** gen_reg_rtx (enum machine_mode mode)
*** 887,908 ****
/* Make sure regno_pointer_align, and regno_reg_rtx are large
enough to have an element for this pseudo reg number. */
! if (reg_rtx_no == rtl.emit.regno_pointer_align_length)
{
! int old_size = rtl.emit.regno_pointer_align_length;
char *new;
rtx *new1;
! new = xrealloc (rtl.emit.regno_pointer_align, old_size * 2);
memset (new + old_size, 0, old_size);
! rtl.emit.regno_pointer_align = (unsigned char *) new;
new1 = ggc_realloc (regno_reg_rtx,
old_size * 2 * sizeof (rtx));
memset (new1 + old_size, 0, old_size * sizeof (rtx));
regno_reg_rtx = new1;
! rtl.emit.regno_pointer_align_length = old_size * 2;
}
val = gen_raw_REG (mode, reg_rtx_no);
--- 887,908 ----
/* Make sure regno_pointer_align, and regno_reg_rtx are large
enough to have an element for this pseudo reg number. */
! if (reg_rtx_no == crtl->emit.regno_pointer_align_length)
{
! int old_size = crtl->emit.regno_pointer_align_length;
char *new;
rtx *new1;
! new = xrealloc (crtl->emit.regno_pointer_align, old_size * 2);
memset (new + old_size, 0, old_size);
! crtl->emit.regno_pointer_align = (unsigned char *) new;
new1 = ggc_realloc (regno_reg_rtx,
old_size * 2 * sizeof (rtx));
memset (new1 + old_size, 0, old_size * sizeof (rtx));
regno_reg_rtx = new1;
! crtl->emit.regno_pointer_align_length = old_size * 2;
}
val = gen_raw_REG (mode, reg_rtx_no);
*************** init_emit (void)
*** 4988,5001 ****
/* Init the tables that describe all the pseudo regs. */
! rtl.emit.regno_pointer_align_length = LAST_VIRTUAL_REGISTER + 101;
! rtl.emit.regno_pointer_align
! = xmalloc (rtl.emit.regno_pointer_align_length
* sizeof (unsigned char));
regno_reg_rtx
! = ggc_alloc (rtl.emit.regno_pointer_align_length * sizeof (rtx));
/* Put copies of all the hard registers into regno_reg_rtx. */
memcpy (regno_reg_rtx,
--- 4988,5001 ----
/* Init the tables that describe all the pseudo regs. */
! crtl->emit.regno_pointer_align_length = LAST_VIRTUAL_REGISTER + 101;
! crtl->emit.regno_pointer_align
! = xmalloc (crtl->emit.regno_pointer_align_length
* sizeof (unsigned char));
regno_reg_rtx
! = ggc_alloc (crtl->emit.regno_pointer_align_length * sizeof (rtx));
/* Put copies of all the hard registers into regno_reg_rtx. */
memcpy (regno_reg_rtx,
Index: varasm.c
===================================================================
*** varasm.c (revision 133929)
--- varasm.c (working copy)
*************** struct addr_const;
*** 70,76 ****
struct constant_descriptor_rtx;
struct rtx_constant_pool;
! #define n_deferred_constants (rtl.varasm.deferred_constants)
/* Number for making the label on the next
constant that is stored in memory. */
--- 70,76 ----
struct constant_descriptor_rtx;
struct rtx_constant_pool;
! #define n_deferred_constants (crtl->varasm.deferred_constants)
/* Number for making the label on the next
constant that is stored in memory. */
*************** create_constant_pool (void)
*** 3456,3463 ****
void
init_varasm_status (void)
{
! rtl.varasm.pool = create_constant_pool ();
! rtl.varasm.deferred_constants = 0;
}
/* Given a MINUS expression, simplify it if both sides
--- 3456,3463 ----
void
init_varasm_status (void)
{
! crtl->varasm.pool = create_constant_pool ();
! crtl->varasm.deferred_constants = 0;
}
/* Given a MINUS expression, simplify it if both sides
*************** force_const_mem (enum machine_mode mode,
*** 3494,3500 ****
/* Decide which pool to use. */
pool = (targetm.use_blocks_for_constant_p (mode, x)
? shared_constant_pool
! : rtl.varasm.pool);
/* Lookup the value in the hashtable. */
tmp.constant = x;
--- 3494,3500 ----
/* Decide which pool to use. */
pool = (targetm.use_blocks_for_constant_p (mode, x)
? shared_constant_pool
! : crtl->varasm.pool);
/* Lookup the value in the hashtable. */
tmp.constant = x;
*************** get_pool_mode (const_rtx addr)
*** 3606,3612 ****
int
get_pool_size (void)
{
! return rtl.varasm.pool->offset;
}
/* Worker function for output_constant_pool_1. Emit assembly for X
--- 3606,3612 ----
int
get_pool_size (void)
{
! return crtl->varasm.pool->offset;
}
/* Worker function for output_constant_pool_1. Emit assembly for X
*************** static void
*** 3848,3854 ****
output_constant_pool (const char *fnname ATTRIBUTE_UNUSED,
tree fndecl ATTRIBUTE_UNUSED)
{
! struct rtx_constant_pool *pool = rtl.varasm.pool;
/* It is possible for gcc to call force_const_mem and then to later
discard the instructions which refer to the constant. In such a
--- 3848,3854 ----
output_constant_pool (const char *fnname ATTRIBUTE_UNUSED,
tree fndecl ATTRIBUTE_UNUSED)
{
! struct rtx_constant_pool *pool = crtl->varasm.pool;
/* It is possible for gcc to call force_const_mem and then to later
discard the instructions which refer to the constant. In such a
Index: config/m32c/m32c.c
===================================================================
*** config/m32c/m32c.c (revision 133929)
--- config/m32c/m32c.c (working copy)
*************** m32c_leaf_function_p (void)
*** 3889,3908 ****
struct sequence_stack *seq;
int rv;
! saved_first = rtl.emit.x_first_insn;
! saved_last = rtl.emit.x_last_insn;
! for (seq = rtl.emit.sequence_stack; seq && seq->next; seq = seq->next)
;
if (seq)
{
! rtl.emit.x_first_insn = seq->first;
! rtl.emit.x_last_insn = seq->last;
}
rv = leaf_function_p ();
! rtl.emit.x_first_insn = saved_first;
! rtl.emit.x_last_insn = saved_last;
return rv;
}
--- 3889,3908 ----
struct sequence_stack *seq;
int rv;
! saved_first = crtl->emit.x_first_insn;
! saved_last = crtl->emit.x_last_insn;
! for (seq = crtl->emit.sequence_stack; seq && seq->next; seq = seq->next)
;
if (seq)
{
! crtl->emit.x_first_insn = seq->first;
! crtl->emit.x_last_insn = seq->last;
}
rv = leaf_function_p ();
! crtl->emit.x_first_insn = saved_first;
! crtl->emit.x_last_insn = saved_last;
return rv;
}
*************** m32c_function_needs_enter (void)
*** 3918,3924 ****
rtx fb = gen_rtx_REG (Pmode, FB_REGNO);
insn = get_insns ();
! for (seq = rtl.emit.sequence_stack;
seq;
insn = seq->first, seq = seq->next);
--- 3918,3924 ----
rtx fb = gen_rtx_REG (Pmode, FB_REGNO);
insn = get_insns ();
! for (seq = crtl->emit.sequence_stack;
seq;
insn = seq->first, seq = seq->next);
Index: config/sparc/sparc.h
===================================================================
*** config/sparc/sparc.h (revision 133929)
--- config/sparc/sparc.h (working copy)
*************** extern int sparc_mode_class[];
*** 953,959 ****
/* Given the stack bias, the stack pointer isn't actually aligned. */
#define INIT_EXPANDERS \
do { \
! if (rtl.emit.regno_pointer_align && SPARC_STACK_BIAS) \
{ \
REGNO_POINTER_ALIGN (STACK_POINTER_REGNUM) = BITS_PER_UNIT; \
REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = BITS_PER_UNIT; \
--- 953,959 ----
/* Given the stack bias, the stack pointer isn't actually aligned. */
#define INIT_EXPANDERS \
do { \
! if (crtl->emit.regno_pointer_align && SPARC_STACK_BIAS) \
{ \
REGNO_POINTER_ALIGN (STACK_POINTER_REGNUM) = BITS_PER_UNIT; \
REGNO_POINTER_ALIGN (HARD_FRAME_POINTER_REGNUM) = BITS_PER_UNIT; \
Index: config/ia64/ia64.h
===================================================================
*** config/ia64/ia64.h (revision 133929)
--- config/ia64/ia64.h (working copy)
*************** enum reg_class
*** 982,988 ****
#define INIT_EXPANDERS \
do { \
ia64_init_expanders (); \
! if (rtl.emit.regno_pointer_align) \
REGNO_POINTER_ALIGN (ARG_POINTER_REGNUM) = 64; \
} while (0)
--- 982,988 ----
#define INIT_EXPANDERS \
do { \
ia64_init_expanders (); \
! if (crtl->emit.regno_pointer_align) \
REGNO_POINTER_ALIGN (ARG_POINTER_REGNUM) = 64; \
} while (0)