aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-09-15 12:56:34 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-09-15 12:56:34 +0000
commit0d803030650a6c671b295d3e7d5161e64b59b2f6 (patch)
tree854fba2d2be98f794a0e01b4efb9f6621aab2d03 /gcc/doc
parentfa0cdfb651f59951d10331b782c422baad93d3e4 (diff)
downloadgcc-0d803030650a6c671b295d3e7d5161e64b59b2f6.zip
gcc-0d803030650a6c671b295d3e7d5161e64b59b2f6.tar.gz
gcc-0d803030650a6c671b295d3e7d5161e64b59b2f6.tar.bz2
Turn CANNOT_CHANGE_MODE_CLASS into a hook
This also seemed like a good opportunity to reverse the sense of the hook to "can", to avoid the awkward double negative in !CANNOT. 2017-09-15 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayard <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * target.def (can_change_mode_class): New hook. (mode_rep_extended): Refer to it instead of CANNOT_CHANGE_MODE_CLASS. (hard_regno_nregs): Likewise. * hooks.h (hook_bool_mode_mode_reg_class_t_true): Declare. * hooks.c (hook_bool_mode_mode_reg_class_t_true): New function. * doc/tm.texi.in (CANNOT_CHANGE_MODE_CLASS): Replace with... (TARGET_CAN_CHANGE_MODE_CLASS): ...this. (LOAD_EXTEND_OP): Update accordingly. * doc/tm.texi: Regenerate. * doc/rtl.texi: Refer to TARGET_CAN_CHANGE_MODE_CLASS instead of CANNOT_CHANGE_MODE_CLASS. * hard-reg-set.h (REG_CANNOT_CHANGE_MODE_P): Replace with... (REG_CAN_CHANGE_MODE_P): ...this new macro. * combine.c (simplify_set): Update accordingly. * emit-rtl.c (validate_subreg): Likewise. * recog.c (general_operand): Likewise. * regcprop.c (mode_change_ok): Likewise. * reload1.c (choose_reload_regs): Likewise. (inherit_piecemeal_p): Likewise. * rtlanal.c (simplify_subreg_regno): Likewise. * postreload.c (reload_cse_simplify_set): Use REG_CAN_CHANGE_MODE_P instead of CANNOT_CHANGE_MODE_CLASS. (reload_cse_simplify_operands): Likewise. * reload.c (push_reload): Use targetm.can_change_mode_class instead of CANNOT_CHANGE_MODE_CLASS. (push_reload): Likewise. Also use REG_CAN_CHANGE_MODE_P instead of REG_CANNOT_CHANGE_MODE_P. * config/alpha/alpha.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/alpha/alpha.c (alpha_can_change_mode_class): New function. (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. * config/arm/arm.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/arm/arm.c (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. (arm_can_change_mode_class): New function. * config/arm/neon.md: Refer to TARGET_CAN_CHANGE_MODE_CLASS rather than CANNOT_CHANGE_MODE_CLASS in comments. * config/i386/i386.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/i386/i386-protos.h (ix86_cannot_change_mode_class): Delete. * config/i386/i386.c (ix86_cannot_change_mode_class): Replace with... (ix86_can_change_mode_class): ...this new function, inverting the sense of the return value. (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. * config/ia64/ia64.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/ia64/ia64.c (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. (ia64_can_change_mode_class): New function. * config/m32c/m32c.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/m32c/m32c-protos.h (m32c_cannot_change_mode_class): Delete. * config/m32c/m32c.c (m32c_cannot_change_mode_class): Replace with... (m32c_can_change_mode_class): ...this new function, inverting the sense of the return value. (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. * config/mips/mips.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/mips/mips-protos.h (mips_cannot_change_mode_class): Delete. * config/mips/mips.c (mips_cannot_change_mode_class): Replace with... (mips_can_change_mode_class): ...this new function, inverting the sense of the return value. (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. * config/msp430/msp430.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/msp430/msp430.c (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. (msp430_can_change_mode_class): New function. * config/nvptx/nvptx.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/nvptx/nvptx.c (nvptx_can_change_mode_class): New function. (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. * config/pa/pa32-regs.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/pa/pa64-regs.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/pa/pa-protos.h (pa_cannot_change_mode_class): Delete. * config/pa/pa.c (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. (pa_cannot_change_mode_class): Replace with... (pa_can_change_mode_class): ...this new function, inverting the sense of the return value. (pa_modes_tieable_p): Refer to TARGET_CAN_CHANGE_MODE_CLASS rather than CANNOT_CHANGE_MODE_CLASS in comments. * config/pdp11/pdp11.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/pdp11/pdp11-protos.h (pdp11_cannot_change_mode_class): Delete. * config/pdp11/pdp11.c (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. (pdp11_cannot_change_mode_class): Replace with... (pdp11_can_change_mode_class): ...this new function, inverting the sense of the return value. * config/powerpcspe/powerpcspe.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/powerpcspe/powerpcspe-protos.h (rs6000_cannot_change_mode_class_ptr): Delete. * config/powerpcspe/powerpcspe.c (rs6000_cannot_change_mode_class_ptr): Delete. (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. (rs6000_option_override_internal): Assign to targetm.can_change_mode_class instead of rs6000_cannot_change_mode_class_ptr. (rs6000_cannot_change_mode_class): Replace with... (rs6000_can_change_mode_class): ...this new function, inverting the sense of the return value. (rs6000_debug_cannot_change_mode_class): Replace with... (rs6000_debug_can_change_mode_class): ...this new function. * config/riscv/riscv.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/riscv/riscv.c (riscv_can_change_mode_class): New function. (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. * config/rs6000/rs6000.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/rs6000/rs6000-protos.h (rs6000_cannot_change_mode_class_ptr): Delete. * config/rs6000/rs6000.c (rs6000_cannot_change_mode_class_ptr): Delete. (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. (rs6000_option_override_internal): Assign to targetm.can_change_mode_class instead of rs6000_cannot_change_mode_class_ptr. (rs6000_cannot_change_mode_class): Replace with... (rs6000_can_change_mode_class): ...this new function, inverting the sense of the return value. (rs6000_debug_cannot_change_mode_class): Replace with... (rs6000_debug_can_change_mode_class): ...this new function. * config/s390/s390.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/s390/s390-protos.h (s390_cannot_change_mode_class): Delete. * config/s390/s390.c (s390_cannot_change_mode_class): Replace with... (s390_can_change_mode_class): ...this new function, inverting the sense of the return value. (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. * config/sh/sh.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/sh/sh-protos.h (sh_cannot_change_mode_class): Delete. * config/sh/sh.c (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. (sh_cannot_change_mode_class): Replace with... (sh_can_change_mode_class): ...this new function, inverting the sense of the return value. * config/sparc/sparc.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/sparc/sparc.c (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. (sparc_can_change_mode_class): New function. * config/spu/spu.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/spu/spu.c (spu_can_change_mode_class): New function. (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. * config/visium/visium.h (CANNOT_CHANGE_MODE_CLASS): Delete. * config/visium/visium.c (TARGET_CAN_CHANGE_MODE_CLASS): Redefine. (visium_can_change_mode_class): New function. * system.h (CANNOT_CHANGE_MODE_CLASS): Poison. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r252816
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/rtl.texi6
-rw-r--r--gcc/doc/tm.texi41
-rw-r--r--gcc/doc/tm.texi.in33
3 files changed, 27 insertions, 53 deletions
diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi
index 12355c2..3b2b247 100644
--- a/gcc/doc/rtl.texi
+++ b/gcc/doc/rtl.texi
@@ -2024,17 +2024,17 @@ has an unknown number of undefined bits, so the assignment:
does not guarantee that @samp{(subreg:HI (reg:PSI 0) 0)} has the
value @samp{(reg:HI 4)}.
-@cindex @code{CANNOT_CHANGE_MODE_CLASS} and subreg semantics
+@cindex @code{TARGET_CAN_CHANGE_MODE_CLASS} and subreg semantics
The rules above apply to both pseudo @var{reg}s and hard @var{reg}s.
If the semantics are not correct for particular combinations of
@var{m1}, @var{m2} and hard @var{reg}, the target-specific code
must ensure that those combinations are never used. For example:
@smallexample
-CANNOT_CHANGE_MODE_CLASS (@var{m2}, @var{m1}, @var{class})
+TARGET_CAN_CHANGE_MODE_CLASS (@var{m2}, @var{m1}, @var{class})
@end smallexample
-must be true for every class @var{class} that includes @var{reg}.
+must be false for every class @var{class} that includes @var{reg}.
@findex SUBREG_REG
@findex SUBREG_BYTE
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 0403801..5b9e2b3 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -2018,8 +2018,8 @@ This hook returns the number of consecutive hard registers, starting
at register number @var{regno}, required to hold a value of mode
@var{mode}. This hook must never return zero, even if a register
cannot hold the requested mode - indicate that with
-@code{TARGET_HARD_REGNO_MODE_OK} and/or @code{CANNOT_CHANGE_MODE_CLASS}
-instead.
+@code{TARGET_HARD_REGNO_MODE_OK} and/or
+@code{TARGET_CAN_CHANGE_MODE_CLASS} instead.
The default definition returns the number of words in @var{mode}.
@end deftypefn
@@ -2814,25 +2814,27 @@ This macro helps control the handling of multiple-word values
in the reload pass.
@end defmac
-@defmac CANNOT_CHANGE_MODE_CLASS (@var{from}, @var{to}, @var{class})
-If defined, a C expression that returns nonzero for a @var{class} for which
-a change from mode @var{from} to mode @var{to} is invalid.
+@deftypefn {Target Hook} bool TARGET_CAN_CHANGE_MODE_CLASS (machine_mode @var{from}, machine_mode @var{to}, reg_class_t @var{rclass})
+This hook returns true if it is possible to bitcast values held in
+registers of class @var{rclass} from mode @var{from} to mode @var{to}
+and if doing so preserves the low-order bits that are common to both modes.
+The result is only meaningful if @var{rclass} has registers that can hold
+both @code{from} and @code{to}. The default implementation returns true.
-For example, loading 32-bit integer or floating-point objects into
-floating-point registers on Alpha extends them to 64 bits.
-Therefore loading a 64-bit object and then storing it as a 32-bit object
-does not store the low-order 32 bits, as would be the case for a normal
-register. Therefore, @file{alpha.h} defines @code{CANNOT_CHANGE_MODE_CLASS}
-as below:
+As an example of when such bitcasting is invalid, loading 32-bit integer or
+floating-point objects into floating-point registers on Alpha extends them
+to 64 bits. Therefore loading a 64-bit object and then storing it as a
+32-bit object does not store the low-order 32 bits, as would be the case
+for a normal register. Therefore, @file{alpha.h} defines
+@code{TARGET_CAN_CHANGE_MODE_CLASS} to return:
@smallexample
-#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
- (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
- ? reg_classes_intersect_p (FLOAT_REGS, (CLASS)) : 0)
+(GET_MODE_SIZE (from) == GET_MODE_SIZE (to)
+ || !reg_classes_intersect_p (FLOAT_REGS, rclass))
@end smallexample
Even if storing from a register in mode @var{to} would be valid,
-if both @var{from} and @code{raw_reg_mode} for @var{class} are wider
+if both @var{from} and @code{raw_reg_mode} for @var{rclass} are wider
than @code{word_mode}, then we must prevent @var{to} narrowing the
mode. This happens when the middle-end assumes that it can load
or store pieces of an @var{N}-word pseudo, and that the pseudo will
@@ -2840,8 +2842,7 @@ eventually be allocated to @var{N} @code{word_mode} hard registers.
Failure to prevent this kind of mode change will result in the
entire @code{raw_reg_mode} being modified instead of the partial
value that the middle-end intended.
-
-@end defmac
+@end deftypefn
@deftypefn {Target Hook} reg_class_t TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS (int, @var{reg_class_t}, @var{reg_class_t})
A target hook which can change allocno class for given pseudo from
@@ -10695,12 +10696,12 @@ define it as the constant @code{SIGN_EXTEND} or @code{ZERO_EXTEND}.
You may return a non-@code{UNKNOWN} value even if for some hard registers
the sign extension is not performed, if for the @code{REGNO_REG_CLASS}
-of these hard registers @code{CANNOT_CHANGE_MODE_CLASS} returns nonzero
+of these hard registers @code{TARGET_CAN_CHANGE_MODE_CLASS} returns false
when the @var{from} mode is @var{mem_mode} and the @var{to} mode is any
integral mode larger than this but not larger than @code{word_mode}.
You must return @code{UNKNOWN} if for some hard registers that allow this
-mode, @code{CANNOT_CHANGE_MODE_CLASS} says that they cannot change to
+mode, @code{TARGET_CAN_CHANGE_MODE_CLASS} says that they cannot change to
@code{word_mode}, but that they can change to another integral mode that
is larger then @var{mem_mode} but still smaller than @code{word_mode}.
@end defmac
@@ -10813,7 +10814,7 @@ widest integral mode and currently we take advantage of this fact.)
Similarly to @code{LOAD_EXTEND_OP} you may return a non-@code{UNKNOWN}
value even if the extension is not performed on certain hard registers
as long as for the @code{REGNO_REG_CLASS} of these hard registers
-@code{CANNOT_CHANGE_MODE_CLASS} returns nonzero.
+@code{TARGET_CAN_CHANGE_MODE_CLASS} returns false.
Note that @code{TARGET_MODE_REP_EXTENDED} and @code{LOAD_EXTEND_OP}
describe two related properties. If you define
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index f6a0d09..57b017f 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -2334,34 +2334,7 @@ This macro helps control the handling of multiple-word values
in the reload pass.
@end defmac
-@defmac CANNOT_CHANGE_MODE_CLASS (@var{from}, @var{to}, @var{class})
-If defined, a C expression that returns nonzero for a @var{class} for which
-a change from mode @var{from} to mode @var{to} is invalid.
-
-For example, loading 32-bit integer or floating-point objects into
-floating-point registers on Alpha extends them to 64 bits.
-Therefore loading a 64-bit object and then storing it as a 32-bit object
-does not store the low-order 32 bits, as would be the case for a normal
-register. Therefore, @file{alpha.h} defines @code{CANNOT_CHANGE_MODE_CLASS}
-as below:
-
-@smallexample
-#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
- (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
- ? reg_classes_intersect_p (FLOAT_REGS, (CLASS)) : 0)
-@end smallexample
-
-Even if storing from a register in mode @var{to} would be valid,
-if both @var{from} and @code{raw_reg_mode} for @var{class} are wider
-than @code{word_mode}, then we must prevent @var{to} narrowing the
-mode. This happens when the middle-end assumes that it can load
-or store pieces of an @var{N}-word pseudo, and that the pseudo will
-eventually be allocated to @var{N} @code{word_mode} hard registers.
-Failure to prevent this kind of mode change will result in the
-entire @code{raw_reg_mode} being modified instead of the partial
-value that the middle-end intended.
-
-@end defmac
+@hook TARGET_CAN_CHANGE_MODE_CLASS
@hook TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS
@@ -7451,12 +7424,12 @@ define it as the constant @code{SIGN_EXTEND} or @code{ZERO_EXTEND}.
You may return a non-@code{UNKNOWN} value even if for some hard registers
the sign extension is not performed, if for the @code{REGNO_REG_CLASS}
-of these hard registers @code{CANNOT_CHANGE_MODE_CLASS} returns nonzero
+of these hard registers @code{TARGET_CAN_CHANGE_MODE_CLASS} returns false
when the @var{from} mode is @var{mem_mode} and the @var{to} mode is any
integral mode larger than this but not larger than @code{word_mode}.
You must return @code{UNKNOWN} if for some hard registers that allow this
-mode, @code{CANNOT_CHANGE_MODE_CLASS} says that they cannot change to
+mode, @code{TARGET_CAN_CHANGE_MODE_CLASS} says that they cannot change to
@code{word_mode}, but that they can change to another integral mode that
is larger then @var{mem_mode} but still smaller than @code{word_mode}.
@end defmac