From 6cde4876448a38c9f47f6a92a72efab9848d7482 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Thu, 13 Jun 2002 10:14:55 -0600 Subject: emit-rtl.c (static_regno_reg_rtx): Define. * emit-rtl.c (static_regno_reg_rtx): Define. (init_emit_once): Initialize static_regno_reg_rtx. (init_emit): Copy static_regno_reg_rtx into regno_reg_rtx instead of building new hard reg objects once per function. (gen_rtx_REG): Try to share hard regs. * regclass.c (init_fake_stack_mems): New function broken out from init_regs. * rtl.h (init_fake_stack_mems): Declare. * toplev.c (lang_independent_init): Call init_regs before init_emit_once. Call init_fake_stack_mems after init_emit_once. From-SVN: r54588 --- gcc/ChangeLog | 11 +++++++++++ gcc/emit-rtl.c | 27 +++++++++++++++++++++++---- gcc/regclass.c | 9 +++++++-- gcc/rtl.h | 1 + gcc/toplev.c | 5 ++++- 5 files changed, 46 insertions(+), 7 deletions(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2fffb42..1136809 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -19,6 +19,17 @@ 2002-06-13 Jeffrey Law + * emit-rtl.c (static_regno_reg_rtx): Define. + (init_emit_once): Initialize static_regno_reg_rtx. + (init_emit): Copy static_regno_reg_rtx into regno_reg_rtx instead + of building new hard reg objects once per function. + (gen_rtx_REG): Try to share hard regs. + * regclass.c (init_fake_stack_mems): New function broken out from + init_regs. + * rtl.h (init_fake_stack_mems): Declare. + * toplev.c (lang_independent_init): Call init_regs before + init_emit_once. Call init_fake_stack_mems after init_emit_once. + * i386.md (extenddfxf2, extenddftf2): Fix typo/thinko. * alias.c (argument_registers): Remove. diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 27a511f..5186c85 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -92,6 +92,12 @@ static int no_line_numbers; rtx global_rtl[GR_MAX]; +/* Commonly used RTL for hard registers. These objects are not necessarily + unique, so we allocate them separately from global_rtl. They are + initialized once per compilation unit, then copied into regno_reg_rtx + at the beginning of each function. */ +static GTY(()) rtx static_regno_reg_rtx[FIRST_PSEUDO_REGISTER]; + /* We record floating-point CONST_DOUBLEs in each floating-point mode for the values of 0, 1, and 2. For the integer entries and VOIDmode, we record a copy of const[012]_rtx. */ @@ -527,6 +533,15 @@ gen_rtx_REG (mode, regno) return stack_pointer_rtx; } + /* If the per-function register table has been set up, try to re-use + an existing entry in that table to avoid useless generation of RTL. */ + if (cfun + && cfun->emit + && regno_reg_rtx + && regno < FIRST_PSEUDO_REGISTER + && reg_raw_mode[regno] == mode) + return regno_reg_rtx[regno]; + return gen_raw_REG (mode, regno); } @@ -5067,7 +5082,6 @@ void init_emit () { struct function *f = cfun; - int i; f->emit = (struct emit_status *) ggc_alloc (sizeof (struct emit_status)); first_insn = NULL; @@ -5098,13 +5112,13 @@ init_emit () * sizeof (tree)); /* Put copies of all the hard registers into regno_reg_rtx. */ - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - regno_reg_rtx[i] = gen_raw_REG (reg_raw_mode[i], i); + memcpy (regno_reg_rtx, + static_regno_reg_rtx, + FIRST_PSEUDO_REGISTER * sizeof (rtx)); /* Put copies of all the virtual register rtx into regno_reg_rtx. */ init_virtual_regs (f->emit); - /* Indicate that the virtual registers and stack locations are all pointers. */ REG_POINTER (stack_pointer_rtx) = 1; @@ -5238,6 +5252,11 @@ init_emit_once (line_numbers) gen_raw_REG (Pmode, VIRTUAL_OUTGOING_ARGS_REGNUM); virtual_cfa_rtx = gen_raw_REG (Pmode, VIRTUAL_CFA_REGNUM); + /* Initialize RTL for commonly used hard registers. These are + copied into regno_reg_rtx as we begin to compile each function. */ + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) + static_regno_reg_rtx[i] = gen_raw_REG (reg_raw_mode[i], i); + #ifdef INIT_EXPANDERS /* This is to initialize {init|mark|free}_machine_status before the first call to push_function_context_to. This is needed by the Chill front diff --git a/gcc/regclass.c b/gcc/regclass.c index 84c7ba3..6a7acb9 100644 --- a/gcc/regclass.c +++ b/gcc/regclass.c @@ -601,11 +601,16 @@ init_regs () init_reg_sets_1 (); init_reg_modes (); +} + +/* Initialize some fake stack-frame MEM references for use in + memory_move_secondary_cost. */ +void +init_fake_stack_mems () +{ #ifdef HAVE_SECONDARY_RELOADS { - /* Make some fake stack-frame MEM references for use in - memory_move_secondary_cost. */ int i; for (i = 0; i < MAX_MACHINE_MODE; i++) diff --git a/gcc/rtl.h b/gcc/rtl.h index 57a0be4..f198c8d 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -2026,6 +2026,7 @@ extern int reg_classes_intersect_p PARAMS ((enum reg_class, enum reg_class)); extern int reg_class_subset_p PARAMS ((enum reg_class, enum reg_class)); extern void globalize_reg PARAMS ((int)); extern void init_regs PARAMS ((void)); +extern void init_fake_stack_mems PARAMS ((void)); extern void init_reg_sets PARAMS ((void)); extern void regset_release_memory PARAMS ((void)); extern void regclass_init PARAMS ((void)); diff --git a/gcc/toplev.c b/gcc/toplev.c index 5105ec8..388954e 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -5035,6 +5035,9 @@ lang_independent_init () init_stringpool (); init_obstacks (); + /* init_emit_once uses reg_raw_mode and therefore must be called + after init_regs which initialized reg_raw_mode. */ + init_regs (); init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL || debug_info_level == DINFO_LEVEL_VERBOSE #ifdef VMS_DEBUGGING_INFO @@ -5043,7 +5046,7 @@ lang_independent_init () #endif || flag_test_coverage || warn_notreached); - init_regs (); + init_fake_stack_mems (); init_alias_once (); init_loop (); init_reload (); -- cgit v1.1