Re: [Patch 1/11] Add a new target hook for describing excess precision intentions
On Wed, 2 Nov 2016, James Greenhalgh wrote: > 2016-11-02 James Greenhalgh > > * target.def (excess_precision): New hook. > * target.h (flt_eval_method): New. > (excess_precision_type): Likewise. > * targhooks.c (default_excess_precision): New. > * targhooks.h (default_excess_precision): New. > * doc/tm.texi.in (TARGET_C_EXCESS_PRECISION): New. > * doc/tm.texi: Regenerate. OK. -- Joseph S. Myers jos...@codesourcery.com
Re: [Patch 1/11] Add a new target hook for describing excess precision intentions
On Fri, Oct 28, 2016 at 09:12:11PM +, Joseph Myers wrote: > On Fri, 14 Oct 2016, James Greenhalgh wrote: > > > + value set for @code{-fexcess-precision=[standard|fast]}.", > > I think the correct markup for the option here is: > > @option{-fexcess-precision=@r{[}standard@r{|}fast@r{]}} > > (that is, using @option not @code, and with the [ | ] not in a fixed-width > font because they aren't part of the option name). > Thanks, I've updated that line in this revision of the patch following your suggestion. James --- gcc/ 2016-11-02 James Greenhalgh * target.def (excess_precision): New hook. * target.h (flt_eval_method): New. (excess_precision_type): Likewise. * targhooks.c (default_excess_precision): New. * targhooks.h (default_excess_precision): New. * doc/tm.texi.in (TARGET_C_EXCESS_PRECISION): New. * doc/tm.texi: Regenerate. diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 869f858..09f8213 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -331,6 +331,24 @@ enum symbol_visibility VISIBILITY_INTERNAL }; +/* enums used by the targetm.excess_precision hook. */ + +enum flt_eval_method +{ + FLT_EVAL_METHOD_UNPREDICTABLE = -1, + FLT_EVAL_METHOD_PROMOTE_TO_FLOAT = 0, + FLT_EVAL_METHOD_PROMOTE_TO_DOUBLE = 1, + FLT_EVAL_METHOD_PROMOTE_TO_LONG_DOUBLE = 2, + FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16 = 16 +}; + +enum excess_precision_type +{ + EXCESS_PRECISION_TYPE_IMPLICIT, + EXCESS_PRECISION_TYPE_STANDARD, + EXCESS_PRECISION_TYPE_FAST +}; + /* Support for user-provided GGC and PCH markers. The first parameter is a pointer to a pointer, the second a cookie. */ typedef void (*gt_pointer_operator) (void *, void *); diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 0aed3d4..d1d1e76 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -947,6 +947,10 @@ sign-extend the result to 64 bits. On such machines, set Do not define this macro if it would never modify @var{m}. @end defmac +@deftypefn {Target Hook} {enum flt_eval_method} TARGET_C_EXCESS_PRECISION (enum excess_precision_type @var{type}) +Return a value, with the same meaning as @code{FLT_EVAL_METHOD} C that describes which excess precision should be applied. @var{type} is either @code{EXCESS_PRECISION_TYPE_IMPLICIT}, @code{EXCESS_PRECISION_TYPE_FAST}, or @code{EXCESS_PRECISION_TYPE_STANDARD}. For @code{EXCESS_PRECISION_TYPE_IMPLICIT}, the target should return which precision and range operations will be implictly evaluated in regardless of the excess precision explicitly added. For @code{EXCESS_PRECISION_TYPE_STANDARD} and @code{EXCESS_PRECISION_TYPE_FAST}, the target should return the explicit excess precision that should be added depending on the value set for @option{-fexcess-precision=@r{[}standard@r{|}fast@r{]}}. +@end deftypefn + @deftypefn {Target Hook} machine_mode TARGET_PROMOTE_FUNCTION_MODE (const_tree @var{type}, machine_mode @var{mode}, int *@var{punsignedp}, const_tree @var{funtype}, int @var{for_return}) Like @code{PROMOTE_MODE}, but it is applied to outgoing function arguments or function return values. The target hook should return the new mode diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 9e5b456..12f6bc0 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -921,6 +921,8 @@ sign-extend the result to 64 bits. On such machines, set Do not define this macro if it would never modify @var{m}. @end defmac +@hook TARGET_C_EXCESS_PRECISION + @hook TARGET_PROMOTE_FUNCTION_MODE @defmac PARM_BOUNDARY diff --git a/gcc/target.def b/gcc/target.def index c3c87b0..9fc31b3 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -5430,6 +5430,23 @@ DEFHOOK_UNDOC machine_mode, (char c), default_mode_for_suffix) +DEFHOOK +(excess_precision, + "Return a value, with the same meaning as @code{FLT_EVAL_METHOD} C that\ + describes which excess precision should be applied. @var{type} is\ + either @code{EXCESS_PRECISION_TYPE_IMPLICIT},\ + @code{EXCESS_PRECISION_TYPE_FAST}, or\ + @code{EXCESS_PRECISION_TYPE_STANDARD}. For\ + @code{EXCESS_PRECISION_TYPE_IMPLICIT}, the target should return which\ + precision and range operations will be implictly evaluated in regardless\ + of the excess precision explicitly added. For\ + @code{EXCESS_PRECISION_TYPE_STANDARD} and\ + @code{EXCESS_PRECISION_TYPE_FAST}, the target should return the\ + explicit excess precision that should be added depending on the\ + value set for @option{-fexcess-precision=@r{[}standard@r{|}fast@r{]}}.", + enum flt_eval_method, (enum excess_precision_type type), + default_excess_precision) + HOOK_VECTOR_END (c) /* Functions specific to the C++ frontend. */ diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 866747a..73e1c25 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -2135,4 +2135,12 @@ default_min_arithmetic_precision (void) return WORD_REGISTER_OPERATIONS ? BITS_PER_WORD : BITS_PER_UNIT; } +/* Default implementation of TARGET_C_EXCESS_PRECISION. */ +
Re: [Patch 1/11] Add a new target hook for describing excess precision intentions
On Fri, 14 Oct 2016, James Greenhalgh wrote: > + value set for @code{-fexcess-precision=[standard|fast]}.", I think the correct markup for the option here is: @option{-fexcess-precision=@r{[}standard@r{|}fast@r{]}} (that is, using @option not @code, and with the [ | ] not in a fixed-width font because they aren't part of the option name). -- Joseph S. Myers jos...@codesourcery.com
Re: [Patch 1/11] Add a new target hook for describing excess precision intentions
On Fri, Sep 30, 2016 at 05:56:53PM +0100, James Greenhalgh wrote: > > This patch introduces TARGET_C_EXCESS_PRECISION. This hook takes a tri-state > argument, one of EXCESS_PRECISION_TYPE_IMPLICIT, > EXCESS_PRECISION_TYPE_STANDARD, EXCESS_PRECISION_TYPE_FAST. Which relate to > the implicit extra precision added by the target, the excess precision that > should be guaranteed for -fexcess-precision=standard, and the excess > precision that should be added for performance under -fexcess-precision=fast . > > Bootstrapped and tested in sequence with the other patches in this series > on Arch64, and as a standalone patch on x86_64. > Hi, This version of this patch has no major changes, simply updating the comment above default_excess_precision to use the newer TARGET_C_EXCESS_PRECISION name for this target hook, rather than TARGET_EXCESS_PRECISION as it was in an earlier patch revision. Bootstrapped and tested in sequence with the other patches in this series on Arch64, and as a standalone patch on x86_64. OK? Thanks James --- gcc/ 2016-10-14 James Greenhalgh * target.def (excess_precision): New hook. * target.h (flt_eval_method): New. (excess_precision_type): Likewise. * targhooks.c (default_excess_precision): New. * targhooks.h (default_excess_precision): New. * doc/tm.texi.in (TARGET_C_EXCESS_PRECISION): New. * doc/tm.texi: Regenerate. diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 70f909d..c4b00b0 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -331,6 +331,24 @@ enum symbol_visibility VISIBILITY_INTERNAL }; +/* enums used by the targetm.excess_precision hook. */ + +enum flt_eval_method +{ + FLT_EVAL_METHOD_UNPREDICTABLE = -1, + FLT_EVAL_METHOD_PROMOTE_TO_FLOAT = 0, + FLT_EVAL_METHOD_PROMOTE_TO_DOUBLE = 1, + FLT_EVAL_METHOD_PROMOTE_TO_LONG_DOUBLE = 2, + FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16 = 16 +}; + +enum excess_precision_type +{ + EXCESS_PRECISION_TYPE_IMPLICIT, + EXCESS_PRECISION_TYPE_STANDARD, + EXCESS_PRECISION_TYPE_FAST +}; + /* Support for user-provided GGC and PCH markers. The first parameter is a pointer to a pointer, the second a cookie. */ typedef void (*gt_pointer_operator) (void *, void *); diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index a4a8e49..c21a772 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -947,6 +947,10 @@ sign-extend the result to 64 bits. On such machines, set Do not define this macro if it would never modify @var{m}. @end defmac +@deftypefn {Target Hook} {enum flt_eval_method} TARGET_C_EXCESS_PRECISION (enum excess_precision_type @var{type}) +Return a value, with the same meaning as @code{FLT_EVAL_METHOD} C that describes which excess precision should be applied. @var{type} is either @code{EXCESS_PRECISION_TYPE_IMPLICIT}, @code{EXCESS_PRECISION_TYPE_FAST}, or @code{EXCESS_PRECISION_TYPE_STANDARD}. For @code{EXCESS_PRECISION_TYPE_IMPLICIT}, the target should return which precision and range operations will be implictly evaluated in regardless of the excess precision explicitly added. For @code{EXCESS_PRECISION_TYPE_STANDARD} and @code{EXCESS_PRECISION_TYPE_FAST}, the target should return the explicit excess precision that should be added depending on the value set for @code{-fexcess-precision=[standard|fast]}. +@end deftypefn + @deftypefn {Target Hook} machine_mode TARGET_PROMOTE_FUNCTION_MODE (const_tree @var{type}, machine_mode @var{mode}, int *@var{punsignedp}, const_tree @var{funtype}, int @var{for_return}) Like @code{PROMOTE_MODE}, but it is applied to outgoing function arguments or function return values. The target hook should return the new mode diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 265f1be..19b381b 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -921,6 +921,8 @@ sign-extend the result to 64 bits. On such machines, set Do not define this macro if it would never modify @var{m}. @end defmac +@hook TARGET_C_EXCESS_PRECISION + @hook TARGET_PROMOTE_FUNCTION_MODE @defmac PARM_BOUNDARY diff --git a/gcc/target.def b/gcc/target.def index b6968f7..3b17c62 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -5402,6 +5402,23 @@ DEFHOOK_UNDOC machine_mode, (char c), default_mode_for_suffix) +DEFHOOK +(excess_precision, + "Return a value, with the same meaning as @code{FLT_EVAL_METHOD} C that\ + describes which excess precision should be applied. @var{type} is\ + either @code{EXCESS_PRECISION_TYPE_IMPLICIT},\ + @code{EXCESS_PRECISION_TYPE_FAST}, or\ + @code{EXCESS_PRECISION_TYPE_STANDARD}. For\ + @code{EXCESS_PRECISION_TYPE_IMPLICIT}, the target should return which\ + precision and range operations will be implictly evaluated in regardless\ + of the excess precision explicitly added. For\ + @code{EXCESS_PRECISION_TYPE_STANDARD} and\ + @code{EXCESS_PRECISION_TYPE_FAST}, the target should return the\ + explicit excess precision that should be added depending on the\ + value set for @code{-fexcess-precision=[standard|f