From 1e8f9642efb0962bf13a68670ee5ebe3d2255e02 Mon Sep 17 00:00:00 2001 From: rearnsha Date: Tue, 31 Jul 2018 17:36:36 +0000 Subject: [PATCH] targhooks - provide an alternative hook for targets that never execute speculatively This hook adds an alternative implementation for the target hook TARGET_HAVE_SPECULATION_SAFE_VALUE; it can be used by targets that have no CPU implementations that execute code speculatively. All that is needed for such targets now is to add: #undef TARGET_HAVE_SPECULATION_SAFE_VALUE #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed. to where you have your other target hooks and you're done. gcc: * targhooks.h (speculation_safe_value_not_needed): New prototype. * targhooks.c (speculation_safe_value_not_needed): New function. * target.def (have_speculation_safe_value): Update documentation. * doc/tm.texi: Regenerated. (backported 3e3448a9ae57194db317a72e68a3266a4cbdb39d) Change-Id: I4532e9bc21029d5e452868dbe95c25a41d1f4a5c git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263175 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/doc/tm.texi | 5 +++++ gcc/target.def | 7 ++++++- gcc/targhooks.c | 7 +++++++ gcc/targhooks.h | 1 + 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 81c7432..50fe0d4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2018-07-31 Richard Earnshaw + * targhooks.h (speculation_safe_value_not_needed): New prototype. + * targhooks.c (speculation_safe_value_not_needed): New function. + * target.def (have_speculation_safe_value): Update documentation. + * doc/tm.texi: Regenerated. + +2018-07-31 Richard Earnshaw + * config/aarch64/iterators.md (ALLI_TI): New iterator. * config/aarch64/aarch64.md (despeculate_copy): New expand. diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index e8166b8..e3bb4d3 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -11690,6 +11690,11 @@ This hook is used to determine the level of target support for a pattern named @code{speculation_barrier}. Else it returns true for the first case and whether the pattern is enabled for the current compilation for the second case. + + For targets that have no processors that can execute instructions + speculatively an alternative implemenation of this hook is available: + simply redefine this hook to @code{speculation_safe_value_not_needed} + along with your other target hooks. @end deftypefn @deftypefn {Target Hook} rtx TARGET_SPECULATION_SAFE_VALUE (machine_mode @var{mode}, rtx @var{result}, rtx @var{val}, rtx @var{failval}) diff --git a/gcc/target.def b/gcc/target.def index a4f21ad..af368a3 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -3952,7 +3952,12 @@ DEFHOOK The default implementation returns false if the target does not define\n\ a pattern named @code{speculation_barrier}. Else it returns true\n\ for the first case and whether the pattern is enabled for the current\n\ - compilation for the second case.", + compilation for the second case.\n\ + \n\ + For targets that have no processors that can execute instructions\n\ + speculatively an alternative implemenation of this hook is available:\n\ + simply redefine this hook to @code{speculation_safe_value_not_needed}\n\ + along with your other target hooks.", bool, (bool active), default_have_speculation_safe_value) DEFHOOK diff --git a/gcc/targhooks.c b/gcc/targhooks.c index d9db06f..58c9068 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -1975,6 +1975,13 @@ default_have_speculation_safe_value (bool active) return false; #endif } +/* Alternative implementation of TARGET_HAVE_SPECULATION_SAFE_VALUE + that can be used on targets that never have speculative execution. */ +bool +speculation_safe_value_not_needed (bool active) +{ + return !active; +} /* Default implementation of the speculation-safe-load builtin. This implementation simply copies val to result and generates a diff --git a/gcc/targhooks.h b/gcc/targhooks.h index 01501b2..102ebb5 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -255,6 +255,7 @@ extern bool default_optab_supported_p (int, machine_mode, machine_mode, optimization_type); extern bool default_have_speculation_safe_value (bool); +extern bool speculation_safe_value_not_needed (bool); extern rtx default_speculation_safe_value (machine_mode, rtx, rtx, rtx); #endif /* GCC_TARGHOOKS_H */ -- 2.7.4