[Patch 1/17] Add a new target hook for describing excess precision intentions
authorJames Greenhalgh <james.greenhalgh@arm.com>
Wed, 23 Nov 2016 17:14:07 +0000 (17:14 +0000)
committerJames Greenhalgh <jgreenhalgh@gcc.gnu.org>
Wed, 23 Nov 2016 17:14:07 +0000 (17:14 +0000)
gcc/

* 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.

From-SVN: r242771

gcc/ChangeLog
gcc/coretypes.h
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/target.def
gcc/targhooks.c
gcc/targhooks.h

index 98678e2f30641837f577c746c6ebf8ceb1b22f68..7cf97207916fd3e6523d5fd36337619ff04071a0 100644 (file)
@@ -1,3 +1,13 @@
+2016-11-23  James Greenhalgh  <james.greenhalgh@arm.com>
+
+       * 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.
+
 2016-11-23  Martin Sebor  <msebor@redhat.com>
 
        PR middle-end/78461
index 6d78a25c9719743c37b13848625c32efdbaa77c1..706b9d2f95c4c734f365573852069cb94d453512 100644 (file)
@@ -332,6 +332,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 *);
index 7bf09d1544f79a343d183037573355e1d0b29a36..144e63f4ccf5a71ef469e582879c5d2e96a32777 100644 (file)
@@ -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
index 58d1e638aff7adc3046309a32d97ae7c2610c34d..7d8dcff14ea8efb75b3b0df5e1a42b9a97cfbde2 100644 (file)
@@ -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
index c24b4cf5ee2f267432481ea9d426cc1678324d45..efcc336593b04bcfeb7712dbd9c154f1a440f193 100644 (file)
@@ -5464,6 +5464,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.  */
index 866747a9ddf57d71afdb8882bcc1edf683497fa8..73e1c2584ae7abe58af3e65a04cee4caf57f7789 100644 (file)
@@ -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.  */
+
+enum flt_eval_method
+default_excess_precision (enum excess_precision_type ATTRIBUTE_UNUSED)
+{
+  return FLT_EVAL_METHOD_PROMOTE_TO_FLOAT;
+}
+
 #include "gt-targhooks.h"
index 94f5e31f80f7d66bc963dfc657b05c9cf7eea74a..e00da602ec76d8101ecd529dd939262c6265cf5b 100644 (file)
@@ -263,4 +263,7 @@ extern bool default_optab_supported_p (int, machine_mode, machine_mode,
 extern unsigned int default_max_noce_ifcvt_seq_cost (edge);
 extern unsigned int default_min_arithmetic_precision (void);
 
+extern enum flt_eval_method
+default_excess_precision (enum excess_precision_type ATTRIBUTE_UNUSED);
+
 #endif /* GCC_TARGHOOKS_H */