aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/sparc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-09-13 17:04:08 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-09-13 17:04:08 +0000
commit94e23f53d700769c453d31881c089d06cde823dd (patch)
treec40d61202954230108cceb97d333c2c34f9c4ddb /gcc/config/sparc
parentbb5d97112a8272c608b18167de9255949129890c (diff)
downloadgcc-94e23f53d700769c453d31881c089d06cde823dd.zip
gcc-94e23f53d700769c453d31881c089d06cde823dd.tar.gz
gcc-94e23f53d700769c453d31881c089d06cde823dd.tar.bz2
Turn SECONDARY_MEMORY_NEEDED_MODE into a target hook
This includes a change to LRA. Previously the code was: if (sclass == NO_REGS && dclass == NO_REGS) return false; #ifdef SECONDARY_MEMORY_NEEDED if (SECONDARY_MEMORY_NEEDED (sclass, dclass, GET_MODE (src)) #ifdef SECONDARY_MEMORY_NEEDED_MODE && ((sclass != NO_REGS && dclass != NO_REGS) || GET_MODE (src) != SECONDARY_MEMORY_NEEDED_MODE (GET_MODE (src))) #endif ) { *sec_mem_p = true; return false; } #endif in which the positioning of the second ifdef meant that defining SECONDARY_MEMORY_NEEDED_MODE to its default value was not a no-op: without a definition, we would consider using secondary reloads for mem<-reg and reg<-mem reloads even if the secondary memory has the same mode as the original mem, while defining it would avoid this. The latter behaviour seems correct. The default is different for reload and LRA. For LRA the default is to use the original mode, while reload promotes smaller-than-word integral modes to word mode: if (GET_MODE_BITSIZE (mode) < BITS_PER_WORD && INTEGRAL_MODE_P (mode)) mode = mode_for_size (BITS_PER_WORD, GET_MODE_CLASS (mode), 0).require (); Some of the ports that have switched to LRA seemed to have SECONDARY_MEMORY_NEEDED_MDOEs based on the old reload definition, and still referred to the reload.c:get_secondary_mem function in the comments. The patch just keeps them as-is. 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_mode): New hook: * targhooks.c (default_secondary_memory_needed_mode): Declare. * targhooks.h (default_secondary_memory_needed_mode): New function. * doc/tm.texi.in (SECONDARY_MEMORY_NEEDED_MODE): Replace with... (TARGET_SECONDARY_MEMORY_NEEDED_MODE): ...this. * doc/tm.texi: Regenerate. * lra-constraints.c (check_and_process_move): Use targetm.secondary_memory_needed_mode instead of TARGET_SECONDARY_MEMORY_NEEDED_MODE. (curr_insn_transform): Likewise. * reload.c (get_secondary_mem): Likewise. * config/alpha/alpha.h (SECONDARY_MEMORY_NEEDED_MODE): Delete. * config/alpha/alpha.c (alpha_secondary_memory_needed_mode): New function. (TARGET_SECONDARY_MEMORY_NEEDED_MODE): Redefine. * config/i386/i386.h (SECONDARY_MEMORY_NEEDED_MODE): Delete. * config/i386/i386.c (ix86_secondary_memory_needed_mode): New function. (TARGET_SECONDARY_MEMORY_NEEDED_MODE): Redefine. * config/powerpcspe/powerpcspe.h (SECONDARY_MEMORY_NEEDED_MODE): Delete. * config/powerpcspe/powerpcspe-protos.h (rs6000_secondary_memory_needed_mode): Delete. * config/powerpcspe/powerpcspe.c (TARGET_SECONDARY_MEMORY_NEEDED_MODE): Redefine. (rs6000_secondary_memory_needed_mode): Make static. * config/rs6000/rs6000.h (SECONDARY_MEMORY_NEEDED_MODE): Delete. * config/rs6000/rs6000-protos.h (rs6000_secondary_memory_needed_mode): Delete. * config/rs6000/rs6000.c (TARGET_SECONDARY_MEMORY_NEEDED_MODE): Redefine. (rs6000_secondary_memory_needed_mode): Make static. * config/s390/s390.h (SECONDARY_MEMORY_NEEDED_MODE): Delete. * config/s390/s390.c (s390_secondary_memory_needed_mode): New function. (TARGET_SECONDARY_MEMORY_NEEDED_MODE): Redefine. * config/sparc/sparc.h (SECONDARY_MEMORY_NEEDED_MODE): Delete. * config/sparc/sparc.c (TARGET_SECONDARY_MEMORY_NEEDED_MODE): Redefine. (sparc_secondary_memory_needed_mode): New function. * system.h (TARGET_SECONDARY_MEMORY_NEEDED_MODE): Poison. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r252455
Diffstat (limited to 'gcc/config/sparc')
-rw-r--r--gcc/config/sparc/sparc.c27
-rw-r--r--gcc/config/sparc/sparc.h12
2 files changed, 27 insertions, 12 deletions
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 9a7e467..469b03d 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -672,6 +672,7 @@ static void sparc_print_operand_address (FILE *, machine_mode, rtx);
static reg_class_t sparc_secondary_reload (bool, rtx, reg_class_t,
machine_mode,
secondary_reload_info *);
+static machine_mode sparc_secondary_memory_needed_mode (machine_mode);
static scalar_int_mode sparc_cstore_mode (enum insn_code icode);
static void sparc_atomic_assign_expand_fenv (tree *, tree *, tree *);
static bool sparc_fixed_condition_code_regs (unsigned int *, unsigned int *);
@@ -859,6 +860,8 @@ char sparc_hard_reg_printed[8];
#undef TARGET_SECONDARY_RELOAD
#define TARGET_SECONDARY_RELOAD sparc_secondary_reload
+#undef TARGET_SECONDARY_MEMORY_NEEDED_MODE
+#define TARGET_SECONDARY_MEMORY_NEEDED_MODE sparc_secondary_memory_needed_mode
#undef TARGET_CONDITIONAL_REGISTER_USAGE
#define TARGET_CONDITIONAL_REGISTER_USAGE sparc_conditional_register_usage
@@ -13050,6 +13053,30 @@ sparc_secondary_reload (bool in_p, rtx x, reg_class_t rclass_i,
return NO_REGS;
}
+/* Implement TARGET_SECONDARY_MEMORY_NEEDED_MODE.
+
+ get_secondary_mem widens its argument to BITS_PER_WORD which loses on v9
+ because the movsi and movsf patterns don't handle r/f moves.
+ For v8 we copy the default definition. */
+
+static machine_mode
+sparc_secondary_memory_needed_mode (machine_mode mode)
+{
+ if (TARGET_ARCH64)
+ {
+ if (GET_MODE_BITSIZE (mode) < 32)
+ return mode_for_size (32, GET_MODE_CLASS (mode), 0).require ();
+ return mode;
+ }
+ else
+ {
+ if (GET_MODE_BITSIZE (mode) < BITS_PER_WORD)
+ return mode_for_size (BITS_PER_WORD,
+ GET_MODE_CLASS (mode), 0).require ();
+ return mode;
+ }
+}
+
/* Emit code to conditionally move either OPERANDS[2] or OPERANDS[3] into
OPERANDS[0] in MODE. OPERANDS[1] is the operator of the condition. */
diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h
index e037897..51bc318 100644
--- a/gcc/config/sparc/sparc.h
+++ b/gcc/config/sparc/sparc.h
@@ -1055,18 +1055,6 @@ extern char leaf_reg_remap[];
|| GET_MODE_SIZE (MODE) > 8 \
|| GET_MODE_SIZE (MODE) < 4))
-/* Get_secondary_mem widens its argument to BITS_PER_WORD which loses on v9
- because the movsi and movsf patterns don't handle r/f moves.
- For v8 we copy the default definition. */
-#define SECONDARY_MEMORY_NEEDED_MODE(MODE) \
- (TARGET_ARCH64 \
- ? (GET_MODE_BITSIZE (MODE) < 32 \
- ? mode_for_size (32, GET_MODE_CLASS (MODE), 0).require () \
- : MODE) \
- : (GET_MODE_BITSIZE (MODE) < BITS_PER_WORD \
- ? mode_for_size (BITS_PER_WORD, GET_MODE_CLASS (MODE), 0).require () \
- : MODE))
-
/* Return the maximum number of consecutive registers
needed to represent mode MODE in a register of class CLASS. */
/* On SPARC, this is the size of MODE in words. */