diff mbox series

[003/nnn] poly_int: MACRO_MODE

Message ID 87lgk1u7ez.fsf@linaro.org
State New
Headers show
Series [003/nnn] poly_int: MACRO_MODE | expand

Commit Message

Richard Sandiford Oct. 23, 2017, 4:59 p.m. UTC
This patch uses a MACRO_MODE wrapper for the target macro invocations
in targhooks.c and address.h, so that macros for non-AArch64 targets
can continue to treat modes as fixed-size.

It didn't seem worth converting the address macros to hooks since
(a) they're heavily used, (b) they should be probably be replaced
with a different interface rather than converted to hooks as-is,
and most importantly (c) addresses.h already localises the problem.


2017-10-23  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* machmode.h (MACRO_MODE): New macro.
	* addresses.h (base_reg_class, ok_for_base_p_1): Use it.
	* targhooks.c (default_libcall_value, default_secondary_reload)
	(default_memory_move_cost, default_register_move_cost)
	(default_class_max_nregs): Likewise.

Comments

Jeff Law Nov. 17, 2017, 3:32 a.m. UTC | #1
On 10/23/2017 10:59 AM, Richard Sandiford wrote:
> This patch uses a MACRO_MODE wrapper for the target macro invocations

> in targhooks.c and address.h, so that macros for non-AArch64 targets

> can continue to treat modes as fixed-size.

> 

> It didn't seem worth converting the address macros to hooks since

> (a) they're heavily used, (b) they should be probably be replaced

> with a different interface rather than converted to hooks as-is,

> and most importantly (c) addresses.h already localises the problem.

> 

> 

> 2017-10-23  Richard Sandiford  <richard.sandiford@linaro.org>

> 	    Alan Hayward  <alan.hayward@arm.com>

> 	    David Sherwood  <david.sherwood@arm.com>

> 

> gcc/

> 	* machmode.h (MACRO_MODE): New macro.

> 	* addresses.h (base_reg_class, ok_for_base_p_1): Use it.

> 	* targhooks.c (default_libcall_value, default_secondary_reload)

> 	(default_memory_move_cost, default_register_move_cost)

> 	(default_class_max_nregs): Likewise.

OK.
jeff
diff mbox series

Patch

Index: gcc/machmode.h
===================================================================
--- gcc/machmode.h	2017-10-23 16:52:20.675923636 +0100
+++ gcc/machmode.h	2017-10-23 17:00:49.664349224 +0100
@@ -685,6 +685,17 @@  fixed_size_mode::includes_p (machine_mod
   return true;
 }
 
+/* Wrapper for mode arguments to target macros, so that if a target
+   doesn't need polynomial-sized modes, its header file can continue
+   to treat everything as fixed_size_mode.  This should go away once
+   macros are moved to target hooks.  It shouldn't be used in other
+   contexts.  */
+#if NUM_POLY_INT_COEFFS == 1
+#define MACRO_MODE(MODE) (as_a <fixed_size_mode> (MODE))
+#else
+#define MACRO_MODE(MODE) (MODE)
+#endif
+
 extern opt_machine_mode mode_for_size (unsigned int, enum mode_class, int);
 
 /* Return the machine mode to use for a MODE_INT of SIZE bits, if one
Index: gcc/addresses.h
===================================================================
--- gcc/addresses.h	2017-10-23 16:52:20.675923636 +0100
+++ gcc/addresses.h	2017-10-23 17:00:49.663350133 +0100
@@ -31,14 +31,15 @@  base_reg_class (machine_mode mode ATTRIB
 		enum rtx_code index_code ATTRIBUTE_UNUSED)
 {
 #ifdef MODE_CODE_BASE_REG_CLASS
-  return MODE_CODE_BASE_REG_CLASS (mode, as, outer_code, index_code);
+  return MODE_CODE_BASE_REG_CLASS (MACRO_MODE (mode), as, outer_code,
+				   index_code);
 #else
 #ifdef MODE_BASE_REG_REG_CLASS
   if (index_code == REG)
-    return MODE_BASE_REG_REG_CLASS (mode);
+    return MODE_BASE_REG_REG_CLASS (MACRO_MODE (mode));
 #endif
 #ifdef MODE_BASE_REG_CLASS
-  return MODE_BASE_REG_CLASS (mode);
+  return MODE_BASE_REG_CLASS (MACRO_MODE (mode));
 #else
   return BASE_REG_CLASS;
 #endif
@@ -58,15 +59,15 @@  ok_for_base_p_1 (unsigned regno ATTRIBUT
 		 enum rtx_code index_code ATTRIBUTE_UNUSED)
 {
 #ifdef REGNO_MODE_CODE_OK_FOR_BASE_P
-  return REGNO_MODE_CODE_OK_FOR_BASE_P (regno, mode, as,
+  return REGNO_MODE_CODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode), as,
 					outer_code, index_code);
 #else
 #ifdef REGNO_MODE_OK_FOR_REG_BASE_P
   if (index_code == REG)
-    return REGNO_MODE_OK_FOR_REG_BASE_P (regno, mode);
+    return REGNO_MODE_OK_FOR_REG_BASE_P (regno, MACRO_MODE (mode));
 #endif
 #ifdef REGNO_MODE_OK_FOR_BASE_P
-  return REGNO_MODE_OK_FOR_BASE_P (regno, mode);
+  return REGNO_MODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode));
 #else
   return REGNO_OK_FOR_BASE_P (regno);
 #endif
Index: gcc/targhooks.c
===================================================================
--- gcc/targhooks.c	2017-10-23 17:00:20.920834919 +0100
+++ gcc/targhooks.c	2017-10-23 17:00:49.664349224 +0100
@@ -941,7 +941,7 @@  default_libcall_value (machine_mode mode
 		       const_rtx fun ATTRIBUTE_UNUSED)
 {
 #ifdef LIBCALL_VALUE
-  return LIBCALL_VALUE (mode);
+  return LIBCALL_VALUE (MACRO_MODE (mode));
 #else
   gcc_unreachable ();
 #endif
@@ -1071,11 +1071,13 @@  default_secondary_reload (bool in_p ATTR
     }
 #ifdef SECONDARY_INPUT_RELOAD_CLASS
   if (in_p)
-    rclass = SECONDARY_INPUT_RELOAD_CLASS (reload_class, reload_mode, x);
+    rclass = SECONDARY_INPUT_RELOAD_CLASS (reload_class,
+					   MACRO_MODE (reload_mode), x);
 #endif
 #ifdef SECONDARY_OUTPUT_RELOAD_CLASS
   if (! in_p)
-    rclass = SECONDARY_OUTPUT_RELOAD_CLASS (reload_class, reload_mode, x);
+    rclass = SECONDARY_OUTPUT_RELOAD_CLASS (reload_class,
+					    MACRO_MODE (reload_mode), x);
 #endif
   if (rclass != NO_REGS)
     {
@@ -1603,7 +1605,7 @@  default_memory_move_cost (machine_mode m
 #ifndef MEMORY_MOVE_COST
     return (4 + memory_move_secondary_cost (mode, (enum reg_class) rclass, in));
 #else
-    return MEMORY_MOVE_COST (mode, (enum reg_class) rclass, in);
+    return MEMORY_MOVE_COST (MACRO_MODE (mode), (enum reg_class) rclass, in);
 #endif
 }
 
@@ -1618,7 +1620,8 @@  default_register_move_cost (machine_mode
 #ifndef REGISTER_MOVE_COST
   return 2;
 #else
-  return REGISTER_MOVE_COST (mode, (enum reg_class) from, (enum reg_class) to);
+  return REGISTER_MOVE_COST (MACRO_MODE (mode),
+			     (enum reg_class) from, (enum reg_class) to);
 #endif
 }
 
@@ -1807,7 +1810,8 @@  default_class_max_nregs (reg_class_t rcl
 			 machine_mode mode ATTRIBUTE_UNUSED)
 {
 #ifdef CLASS_MAX_NREGS
-  return (unsigned char) CLASS_MAX_NREGS ((enum reg_class) rclass, mode);
+  return (unsigned char) CLASS_MAX_NREGS ((enum reg_class) rclass,
+					  MACRO_MODE (mode));
 #else
   return ((GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD);
 #endif