From 9e519b977314ee6ae132c297c1a53ea4e1b417b4 Mon Sep 17 00:00:00 2001 From: law Date: Wed, 25 Nov 1998 10:31:24 +0000 Subject: [PATCH] * toplev.c (no_new_pseudos): Define. (rest_of_compilation): Set no_new_pseudos as needed. * emit-rtl.c (gen_reg_rtx): Abort if we try to create a new pseudo if no_new_pseudos is set. * rtl.h (no_new_pseudos): Declare it. * reload1.c (reload): Update comments. * md.texi: Corresponding changes. * reload1.c (reg_used_in_insn): Renamed from reg_used_by_pseudo. (choose_reload_regs): Rename it here as well. When computing it, also merge in used hardregs. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@23855 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 16 ++++++++++++++++ gcc/emit-rtl.c | 8 +++----- gcc/md.texi | 10 ++++++++-- gcc/reload1.c | 26 +++++++++++++++++--------- gcc/rtl.h | 4 ++++ gcc/toplev.c | 8 ++++++++ 6 files changed, 56 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b5dbe80..fdf4b63 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +Wed Nov 25 11:26:19 1998 Jeffrey A Law (law@cygnus.com) + + * toplev.c (no_new_pseudos): Define. + (rest_of_compilation): Set no_new_pseudos as needed. + * emit-rtl.c (gen_reg_rtx): Abort if we try to create a new pseudo + if no_new_pseudos is set. + * rtl.h (no_new_pseudos): Declare it. + * reload1.c (reload): Update comments. + * md.texi: Corresponding changes. + +Wed Nov 25 11:26:17 1998 Bernd Schmidt + + * reload1.c (reg_used_in_insn): Renamed from reg_used_by_pseudo. + (choose_reload_regs): Rename it here as well. When computing it, + also merge in used hardregs. + 1998-11-25 07:51 -0500 Zack Weinberg * gcc.c: Split out Objective-C specs to... diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index a8bbfe4..9a19de1 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -505,11 +505,9 @@ gen_reg_rtx (mode) { register rtx val; - /* Don't let anything called by or after reload create new registers - (actually, registers can't be created after flow, but this is a good - approximation). */ - - if (reload_in_progress || reload_completed) + /* Don't let anything called after initial flow analysis create new + registers. */ + if (no_new_pseudos) abort (); if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT diff --git a/gcc/md.texi b/gcc/md.texi index f3f6cd6..6177ac2 100644 --- a/gcc/md.texi +++ b/gcc/md.texi @@ -1746,14 +1746,20 @@ pseudo registers that did not get hard registers, while on other machines explicit memory references will get optional reloads. If a scratch register is required to move an object to or from memory, -it can be allocated using @code{gen_reg_rtx} prior to reload. But this -is impossible during and after reload. If there are cases needing +it can be allocated using @code{gen_reg_rtx} prior to life analysis. + +If there are cases needing scratch registers after reload, you must define @code{SECONDARY_INPUT_RELOAD_CLASS} and perhaps also @code{SECONDARY_OUTPUT_RELOAD_CLASS} to detect them, and provide patterns @samp{reload_in@var{m}} or @samp{reload_out@var{m}} to handle them. @xref{Register Classes}. +@findex no_new_pseudos +The global variable @code{no_new_pseudos} can be used to determine if it +is unsafe to create new pseudo registers. If this variable is nonzero, then +it is unsafe to call @code{gen_reg_rtx} to allocate a new pseudo. + The constraints on a @samp{mov@var{m}} must permit moving any hard register to any other hard register provided that @code{HARD_REGNO_MODE_OK} permits mode @var{m} in both registers and diff --git a/gcc/reload1.c b/gcc/reload1.c index fb7e5cf..e4dee18 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -815,7 +815,9 @@ reload (first, global, dumpfile) #endif finish_spills (global, dumpfile); - /* From now on, we need to emit any moves without making new pseudos. */ + /* From now on, we may need to generate moves differently. We may also + allow modifications of insns which cause them to not be recognized. + Any such modifications will be cleaned up during reload itself. */ reload_in_progress = 1; /* This loop scans the entire function each go-round @@ -4487,9 +4489,9 @@ static HARD_REG_SET reload_reg_used_at_all; in the group. */ static HARD_REG_SET reload_reg_used_for_inherit; -/* Records which hard regs are allocated to a pseudo during any point of the - current insn. */ -static HARD_REG_SET reg_used_by_pseudo; +/* Records which hard regs are used in any way, either as explicit use or + by being allocated to a pseudo during any point of the current insn. */ +static HARD_REG_SET reg_used_in_insn; /* Mark reg REGNO as in use for a reload of the sort spec'd by OPNUM and TYPE. MODE is used to indicate how many consecutive regs are @@ -5522,10 +5524,16 @@ choose_reload_regs (chain) CLEAR_HARD_REG_SET (reload_reg_used_in_insn); CLEAR_HARD_REG_SET (reload_reg_used_in_other_addr); - CLEAR_HARD_REG_SET (reg_used_by_pseudo); - compute_use_by_pseudos (®_used_by_pseudo, chain->live_before); - compute_use_by_pseudos (®_used_by_pseudo, chain->live_after); - + CLEAR_HARD_REG_SET (reg_used_in_insn); + { + HARD_REG_SET tmp; + REG_SET_TO_HARD_REG_SET (tmp, chain->live_before); + IOR_HARD_REG_SET (reg_used_in_insn, tmp); + REG_SET_TO_HARD_REG_SET (tmp, chain->live_after); + IOR_HARD_REG_SET (reg_used_in_insn, tmp); + compute_use_by_pseudos (®_used_in_insn, chain->live_before); + compute_use_by_pseudos (®_used_in_insn, chain->live_after); + } for (i = 0; i < reload_n_operands; i++) { CLEAR_HARD_REG_SET (reload_reg_used_in_output[i]); @@ -5838,7 +5846,7 @@ choose_reload_regs (chain) (i, reload_opnum[r], reload_when_needed[r], reload_in[r], reload_out[r], r, 1)) /* Don't use it if we'd clobber a pseudo reg. */ - || (TEST_HARD_REG_BIT (reg_used_by_pseudo, i) + || (TEST_HARD_REG_BIT (reg_used_in_insn, i) && reload_out[r] && ! TEST_HARD_REG_BIT (reg_reloaded_dead, i)) /* Don't really use the inherited spill reg diff --git a/gcc/rtl.h b/gcc/rtl.h index 6c47f2f..c5b816d 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1222,6 +1222,10 @@ extern int reload_in_progress; the same indirect address eventually. */ extern int cse_not_expected; +/* Set to nonzero before life analysis to indicate that it is unsafe to + generate any new pseudo registers. */ +extern int no_new_pseudos; + /* Indexed by pseudo register number, gives the rtx for that pseudo. Allocated in parallel with regno_pointer_flag. */ extern rtx *regno_reg_rtx; diff --git a/gcc/toplev.c b/gcc/toplev.c index da28bda..5fa7f22 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -242,6 +242,9 @@ char *main_input_filename; int lineno; +/* Nonzero if it is unsafe to create any new pseudo registers. */ +int no_new_pseudos; + /* Stack of currently pending input files. */ struct file_stack *input_file_stack; @@ -3862,6 +3865,10 @@ rest_of_compilation (decl) print_rtl_graph_with_bb (dump_base_name, ".flow", insns); } + /* The first life analysis pass has finished. From now on we can not + generate any new pseudos. */ + no_new_pseudos = 1; + /* If -opt, try combining insns through substitution. */ if (optimize > 0) @@ -4170,6 +4177,7 @@ rest_of_compilation (decl) reload_completed = 0; flow2_completed = 0; + no_new_pseudos = 0; TIMEVAR (final_time, { -- 2.7.4