public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] Add -ffake-hybrid-init
@ 2022-05-05 12:05 Matthew Malcomson
0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2022-05-05 12:05 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:272ae0194290f681d19acffa2d03f4e1ea8b355d
commit 272ae0194290f681d19acffa2d03f4e1ea8b355d
Author: Richard Sandiford <richard.sandiford@arm.com>
Date: Thu Mar 3 16:06:50 2022 +0000
Add -ffake-hybrid-init
This patch adds -ffake-hybrid-init=N, to go with -ffake-hybrid=M.
When both options are present, the semantics are:
use __capability for decl i (counting from 0) if (N + i) % M == 0
Otherwise the semantics of -ffake-hybrid=M are unchanged:
randomly use __capability, with a probability of 1/M
Diff:
---
gcc/c/c-decl.c | 23 +++++++++++++++++++++--
gcc/common.opt | 4 ++++
gcc/config/aarch64/aarch64.c | 4 ++--
3 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 1c30003d0d4..fc05a0163c6 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -5970,6 +5970,26 @@ smallest_type_quals_location (const location_t *locations,
return loc;
}
+/* Return true if -ffake-hybrid says that we should automatically
+ modify a piece of code. */
+
+static bool
+test_fake_hybrid (void)
+{
+ static int fake_hybrid_counter;
+
+ if (!flag_fake_hybrid)
+ return false;
+
+ if (flag_fake_hybrid_init < flag_fake_hybrid)
+ {
+ int count = flag_fake_hybrid_init + fake_hybrid_counter++;
+ return (count % flag_fake_hybrid) == 0;
+ }
+
+ return (rand() % flag_fake_hybrid) == 0;
+}
+
/* Given declspecs and a declarator,
determine the name and type of the object declared
and construct a ..._DECL node for it.
@@ -6983,8 +7003,7 @@ grokdeclarator (const struct c_declarator *declarator,
type_quals = declarator->u.pointer_quals;
declarator = declarator->declarator;
- if (flag_fake_hybrid
- && (rand() % flag_fake_hybrid) == 0)
+ if (test_fake_hybrid ())
{
capability_levels_in_declarator++;
tree attr_name = get_identifier ("cheri_capability");
diff --git a/gcc/common.opt b/gcc/common.opt
index a874b24842a..43581eb6d62 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1227,6 +1227,10 @@ Choose to do some fake hybrid capability stuff.
This is largely in order to explore whether using hybrid capabilities will
cause a lot of problems or not.
+ffake-hybrid-init=
+Common Joined RejectNegative UInteger Var(flag_fake_hybrid_init) Init(INT_MAX)
+Use a round-robin counter for -ffake-hybrid and specify its initial value.
+
fdebug-prefix-map=
Common Joined RejectNegative Var(common_deferred_options) Defer
-fdebug-prefix-map=<old>=<new> Map one directory name to another in debug information.
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 5f8419cfca0..6d159dec463 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -15157,8 +15157,8 @@ aarch64_override_options_internal (struct gcc_options *opts)
error ("MORELLO TODO OpenACC has not been implemented for Morello");
if (!flag_inline_atomics && TARGET_CAPABILITY_ANY)
error ("MORELLO TODO -fno-inline-atomics has not been implemented for Morello");
- if (flag_fake_hybrid)
- srand(get_random_seed(false));
+ if (flag_fake_hybrid >= flag_fake_hybrid_init)
+ srand (get_random_seed (false));
if (TARGET_CAPABILITY_ANY && TARGET_SVE)
error ("SVE is not supported with capabilities");
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-05 12:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 12:05 [gcc(refs/vendors/ARM/heads/morello)] Add -ffake-hybrid-init Matthew Malcomson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).