aboutsummaryrefslogtreecommitdiff
path: root/gcc/reload.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-09-13 17:05:16 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-09-13 17:05:16 +0000
commitf15643d4ea7103ad1bd9ef893f4c211624e1614d (patch)
tree794d8c949f2b13fdb15f7c1b2d4cacb4b7a6f2e8 /gcc/reload.c
parent94e23f53d700769c453d31881c089d06cde823dd (diff)
downloadgcc-f15643d4ea7103ad1bd9ef893f4c211624e1614d.zip
gcc-f15643d4ea7103ad1bd9ef893f4c211624e1614d.tar.gz
gcc-f15643d4ea7103ad1bd9ef893f4c211624e1614d.tar.bz2
Turn SECONDARY_MEMORY_NEEDED into a hook
Since the patch is going through all the definitions anyway, it seemed like a good opportunity to put the mode argument first, to match the order for register_move_cost. 2017-09-13 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * target.def (secondary_memory_needed): New hook. (secondary_reload): Refer to TARGET_SECONDARY_MEMORY_NEEDED instead of SECONDARY_MEMORY_NEEDED. (secondary_memory_needed_mode): Likewise. * hooks.h (hook_bool_mode_reg_class_t_reg_class_t_false): Declare. * hooks.c (hook_bool_mode_reg_class_t_reg_class_t_false): New function. * doc/tm.texi.in (SECONDARY_MEMORY_NEEDED): Replace with... (TARGET_SECONDARY_MEMORY_NEEDED): ...this. (SECONDARY_MEMORY_NEEDED_RTX): Update reference accordingly. * doc/tm.texi: Regenerate. * config/alpha/alpha.h (SECONDARY_MEMORY_NEEDED): Delete. * config/alpha/alpha.c (alpha_secondary_memory_needed): New function. (TARGET_SECONDARY_MEMORY_NEEDED): Redefine. * config/i386/i386.h (SECONDARY_MEMORY_NEEDED): Delete. * config/i386/i386-protos.h (ix86_secondary_memory_needed): Delete. * config/i386/i386.c (inline_secondary_memory_needed): Put the mode argument first and change the reg_class arguments to reg_class_t. (ix86_secondary_memory_needed): Likewise. Remove the strict parameter. Make static. Update the call to inline_secondary_memory_needed. (ix86_register_move_cost): Update the call to inline_secondary_memory_needed. (TARGET_SECONDARY_MEMORY_NEEDED): Redefine. * config/ia64/ia64.h (SECONDARY_MEMORY_NEEDED): Delete commented-out definition. * config/ia64/ia64.c (spill_xfmode_rfmode_operand): Refer to TARGET_SECONDARY_MEMORY_NEEDED rather than SECONDARY_MEMORY_NEEDED in comment. * config/mips/mips.h (SECONDARY_MEMORY_NEEDED): Delete. * config/mips/mips-protos.h (mips_secondary_memory_needed): Delete. * config/mips/mips.c (mips_secondary_memory_needed): Make static and match hook interface. Add comment from mips.h. (TARGET_SECONDARY_MEMORY_NEEDED): Redefine. * config/mmix/mmix.md (truncdfsf2): Refer to TARGET_SECONDARY_MEMORY_NEEDED rather than SECONDARY_MEMORY_NEEDED in comment. * config/pa/pa-64.h (SECONDARY_MEMORY_NEEDED): Rename to... (PA_SECONDARY_MEMORY_NEEDED): ...this, and put the mode argument first. * config/pa/pa.c (TARGET_SECONDARY_MEMORY_NEEDED): Redefine. (pa_secondary_memory_needed): New function. * config/pdp11/pdp11.h (SECONDARY_MEMORY_NEEDED): Delete. * config/pdp11/pdp11-protos.h (pdp11_secondary_memory_needed): Delete. * config/pdp11/pdp11.c (TARGET_SECONDARY_MEMORY_NEEDED): Redefine. (pdp11_secondary_memory_needed): Make static and match hook interface. * config/powerpcspe/powerpcspe.h (SECONDARY_MEMORY_NEEDED): Delete. * config/powerpcspe/powerpcspe-protos.h (rs6000_secondary_memory_needed_ptr): Delete. * config/powerpcspe/powerpcspe.c (rs6000_secondary_memory_needed_ptr): Delete. (TARGET_SECONDARY_MEMORY_NEEDED): Redefine. (rs6000_option_override_internal): Assign to targetm.secondary_memory_needed rather than rs6000_secondary_memory_needed_ptr. (rs6000_secondary_memory_needed): Match hook interface. (rs6000_debug_secondary_memory_needed): Likewise. * config/riscv/riscv.h (SECONDARY_MEMORY_NEEDED): Delete. * config/riscv/riscv.c (riscv_secondary_memory_needed): New function. (riscv_register_move_cost): Use it instead of SECONDARY_MEMORY_NEEDED. (TARGET_SECONDARY_MEMORY_NEEDED): Redefine. * config/rs6000/rs6000.h (SECONDARY_MEMORY_NEEDED): Delete. * config/rs6000/rs6000-protos.h (rs6000_secondary_memory_needed_ptr): Delete. * config/rs6000/rs6000.c (rs6000_secondary_memory_needed_ptr): Delete. (TARGET_SECONDARY_MEMORY_NEEDED): Redefine. (rs6000_option_override_internal): Assign to targetm.secondary_memory_needed rather than rs6000_secondary_memory_needed_ptr. (rs6000_secondary_memory_needed): Match hook interface. (rs6000_debug_secondary_memory_needed): Likewise. * config/s390/s390.h (SECONDARY_MEMORY_NEEDED): Delete. * config/s390/s390.c (s390_secondary_memory_needed): New function. (TARGET_SECONDARY_MEMORY_NEEDED): Redefine. * config/sparc/sparc.h (SECONDARY_MEMORY_NEEDED): Delete. * config/sparc/sparc.c (TARGET_SECONDARY_MEMORY_NEEDED): Redefine. (sparc_secondary_memory_needed): New function. * lra-constraints.c (check_and_process_move): Refer to TARGET_SECONDARY_MEMORY_NEEDED rather than SECONDARY_MEMORY_NEEDED in comment. (curr_insn_transform): Likewise. (process_alt_operands): Use targetm.secondary_memory_needed instead of TARGET_SECONDARY_MEMORY_NEEDED. (check_secondary_memory_needed_p): Likewise. (choose_split_class): Likewise. * reload.c: Unconditionally include code that was previously conditional on SECONDARY_MEMORY_NEEDED. (push_secondary_reload): Use targetm.secondary_memory_needed instead of TARGET_SECONDARY_MEMORY_NEEDED. (push_reload): Likewise. * reload1.c: Unconditionally include code that was previously conditional on SECONDARY_MEMORY_NEEDED. (choose_reload_regs): Use targetm.secondary_memory_needed instead of TARGET_SECONDARY_MEMORY_NEEDED. (gen_reload): Likewise. * system.h (SECONDARY_MEMORY_NEEDED): Poison. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r252461
Diffstat (limited to 'gcc/reload.c')
-rw-r--r--gcc/reload.c31
1 files changed, 5 insertions, 26 deletions
diff --git a/gcc/reload.c b/gcc/reload.c
index d0061e5..c9b9461 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -172,8 +172,6 @@ struct decomposition
HOST_WIDE_INT end; /* Ending offset or register number. */
};
-#ifdef SECONDARY_MEMORY_NEEDED
-
/* Save MEMs needed to copy from one class of registers to another. One MEM
is used per mode, but normally only one or two modes are ever used.
@@ -185,7 +183,6 @@ struct decomposition
static rtx secondary_memlocs[NUM_MACHINE_MODES];
static rtx secondary_memlocs_elim[NUM_MACHINE_MODES][MAX_RECOG_OPERANDS];
static int secondary_memlocs_elim_used = 0;
-#endif
/* The instruction we are doing reloads for;
so we can test whether a register dies in it. */
@@ -456,14 +453,13 @@ push_secondary_reload (int in_p, rtx x, int opnum, int optional,
if (s_reload == n_reloads)
{
-#ifdef SECONDARY_MEMORY_NEEDED
/* If we need a memory location to copy between the two reload regs,
set it up now. Note that we do the input case before making
the reload and the output case after. This is due to the
way reloads are output. */
if (in_p && icode == CODE_FOR_nothing
- && SECONDARY_MEMORY_NEEDED (rclass, reload_class, mode))
+ && targetm.secondary_memory_needed (mode, rclass, reload_class))
{
get_secondary_mem (x, reload_mode, opnum, type);
@@ -471,7 +467,6 @@ push_secondary_reload (int in_p, rtx x, int opnum, int optional,
the new reload at the end. */
s_reload = n_reloads;
}
-#endif
/* We need to make a new secondary reload for this register class. */
rld[s_reload].in = rld[s_reload].out = 0;
@@ -497,11 +492,9 @@ push_secondary_reload (int in_p, rtx x, int opnum, int optional,
n_reloads++;
-#ifdef SECONDARY_MEMORY_NEEDED
if (! in_p && icode == CODE_FOR_nothing
- && SECONDARY_MEMORY_NEEDED (reload_class, rclass, mode))
+ && targetm.secondary_memory_needed (mode, reload_class, rclass))
get_secondary_mem (x, mode, opnum, type);
-#endif
}
*picode = icode;
@@ -556,8 +549,6 @@ scratch_reload_class (enum insn_code icode)
return rclass;
}
-#ifdef SECONDARY_MEMORY_NEEDED
-
/* Return a memory location that will be used to copy X in mode MODE.
If we haven't already made a location for this mode in this insn,
call find_reloads_address on the location being returned. */
@@ -634,7 +625,6 @@ clear_secondary_mem (void)
{
memset (secondary_memlocs, 0, sizeof secondary_memlocs);
}
-#endif /* SECONDARY_MEMORY_NEEDED */
/* Find the largest class which has at least one register valid in
@@ -1353,7 +1343,6 @@ push_reload (rtx in, rtx out, rtx *inloc, rtx *outloc,
/* We found no existing reload suitable for re-use.
So add an additional reload. */
-#ifdef SECONDARY_MEMORY_NEEDED
if (subreg_in_class == NO_REGS
&& in != 0
&& (REG_P (in)
@@ -1362,9 +1351,8 @@ push_reload (rtx in, rtx out, rtx *inloc, rtx *outloc,
subreg_in_class = REGNO_REG_CLASS (reg_or_subregno (in));
/* If a memory location is needed for the copy, make one. */
if (subreg_in_class != NO_REGS
- && SECONDARY_MEMORY_NEEDED (subreg_in_class, rclass, inmode))
+ && targetm.secondary_memory_needed (inmode, subreg_in_class, rclass))
get_secondary_mem (in, inmode, opnum, type);
-#endif
i = n_reloads;
rld[i].in = in;
@@ -1388,16 +1376,13 @@ push_reload (rtx in, rtx out, rtx *inloc, rtx *outloc,
n_reloads++;
-#ifdef SECONDARY_MEMORY_NEEDED
if (out != 0
&& (REG_P (out)
|| (GET_CODE (out) == SUBREG && REG_P (SUBREG_REG (out))))
&& reg_or_subregno (out) < FIRST_PSEUDO_REGISTER
- && SECONDARY_MEMORY_NEEDED (rclass,
- REGNO_REG_CLASS (reg_or_subregno (out)),
- outmode))
+ && (targetm.secondary_memory_needed
+ (outmode, rclass, REGNO_REG_CLASS (reg_or_subregno (out)))))
get_secondary_mem (out, outmode, opnum, type);
-#endif
}
else
{
@@ -1797,14 +1782,12 @@ combine_reloads (void)
[(int) rld[output_reload].outmode])
&& rld[i].inc == 0
&& rld[i].reg_rtx == 0
-#ifdef SECONDARY_MEMORY_NEEDED
/* Don't combine two reloads with different secondary
memory locations. */
&& (secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[i].opnum] == 0
|| secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[output_reload].opnum] == 0
|| rtx_equal_p (secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[i].opnum],
secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[output_reload].opnum]))
-#endif
&& (targetm.small_register_classes_for_mode_p (VOIDmode)
? (rld[i].rclass == rld[output_reload].rclass)
: (reg_class_subset_p (rld[i].rclass,
@@ -1854,12 +1837,10 @@ combine_reloads (void)
= rld[output_reload].secondary_out_icode;
}
-#ifdef SECONDARY_MEMORY_NEEDED
/* Copy any secondary MEM. */
if (secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[output_reload].opnum] != 0)
secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[i].opnum]
= secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[output_reload].opnum];
-#endif
/* If required, minimize the register class. */
if (reg_class_subset_p (rld[output_reload].rclass,
rld[i].rclass))
@@ -2668,7 +2649,6 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known,
if (HAVE_cc0 && reg_set_p (cc0_rtx, PATTERN (insn)))
no_output_reloads = 1;
-#ifdef SECONDARY_MEMORY_NEEDED
/* The eliminated forms of any secondary memory locations are per-insn, so
clear them out here. */
@@ -2678,7 +2658,6 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known,
sizeof (secondary_memlocs_elim[0]) * secondary_memlocs_elim_used);
secondary_memlocs_elim_used = 0;
}
-#endif
/* Dispose quickly of (set (reg..) (reg..)) if both have hard regs and it
is cheap to move between them. If it is not, there may not be an insn