From: Richard Sandiford Date: Sat, 16 Dec 2017 14:13:03 +0000 (+0000) Subject: poly_int: MACRO_MODE X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=05210ba63707fd3dc120f0f5a76add5ca172881e;p=gcc.git poly_int: MACRO_MODE 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-12-16 Richard Sandiford Alan Hayward David Sherwood 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. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r255744 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 841e6edace2..98f02e8bf08 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2017-12-16 Richard Sandiford + Alan Hayward + David Sherwood + + * 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. + 2017-12-16 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/addresses.h b/gcc/addresses.h index d4749fce8c4..b0103d2a3ba 100644 --- a/gcc/addresses.h +++ b/gcc/addresses.h @@ -31,14 +31,15 @@ base_reg_class (machine_mode mode ATTRIBUTE_UNUSED, 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 ATTRIBUTE_UNUSED, 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 diff --git a/gcc/machmode.h b/gcc/machmode.h index f53e7b359f7..0c5c01c0a6e 100644 --- a/gcc/machmode.h +++ b/gcc/machmode.h @@ -685,6 +685,17 @@ fixed_size_mode::includes_p (machine_mode) 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 (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 diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 6b3279e4b38..4a90e81ebe4 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -977,7 +977,7 @@ default_libcall_value (machine_mode mode ATTRIBUTE_UNUSED, const_rtx fun ATTRIBUTE_UNUSED) { #ifdef LIBCALL_VALUE - return LIBCALL_VALUE (mode); + return LIBCALL_VALUE (MACRO_MODE (mode)); #else gcc_unreachable (); #endif @@ -1107,11 +1107,13 @@ default_secondary_reload (bool in_p ATTRIBUTE_UNUSED, rtx x ATTRIBUTE_UNUSED, } #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) { @@ -1639,7 +1641,7 @@ default_memory_move_cost (machine_mode mode ATTRIBUTE_UNUSED, #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 } @@ -1654,7 +1656,8 @@ default_register_move_cost (machine_mode mode ATTRIBUTE_UNUSED, #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 } @@ -1843,7 +1846,8 @@ default_class_max_nregs (reg_class_t rclass ATTRIBUTE_UNUSED, 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