From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1035) id 7191D3858427; Mon, 24 Jun 2024 15:51:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7191D3858427 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1719244265; bh=wozAgiLSDT006zhSkp/wFgCxHvbjIWuci3VZV+Fohag=; h=From:To:Subject:Date:From; b=HrCyP8zZcqSp5OfPn6l8S84QD0Bp5qViCLN/41XO31r7GaM+okWCPtRELa/Q8dz7N 5T0m0MzLK3jqeaaOxg3ljPur3YH+uLBkFvf6jmoHvOpcC7apBacE/ZoH1urM42l3sY 0JhiC7vb84G6CeoOjDx+UOO6wQmVQg3ojtdLlEKc= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Richard Earnshaw To: binutils-cvs@sourceware.org Subject: [binutils-gdb] aarch64: Add support for virtual features X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Carlotti X-Git-Refname: refs/heads/master X-Git-Oldrev: 92d37320d5f75804006abfb28e006ccbc24f8f52 X-Git-Newrev: 05f15256d0274b8321eec4cad4273340e1a8521f Message-Id: <20240624155105.7191D3858427@sourceware.org> Date: Mon, 24 Jun 2024 15:51:05 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D05f15256d027= 4b8321eec4cad4273340e1a8521f commit 05f15256d0274b8321eec4cad4273340e1a8521f Author: Andrew Carlotti Date: Fri Jun 21 19:31:06 2024 +0100 aarch64: Add support for virtual features =20 These features will be used to gate instructions that can be enabled by either of two (or more) different sets of command line feature flags. =20 This patch add a postprocessing step to the feature parsing code to set the value of the virtual bits. Diff: --- gas/config/tc-aarch64.c | 64 ++++++++++++++++++++++++++++++++++-----------= ---- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 1717ca7eb70..2bd87d149b8 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -10684,6 +10684,32 @@ static const struct aarch64_option_cpu_value_table= aarch64_features[] =3D { {NULL, AARCH64_NO_FEATURES, AARCH64_NO_FEATURES}, }; =20 +/* If all features in the TEST feature set are present, then every virtual + feature in the ENABLES feature set should also be enabled. */ +struct aarch64_virtual_dependency_table +{ + const aarch64_feature_set test; + const aarch64_feature_set enables; +}; + +static const struct aarch64_virtual_dependency_table aarch64_dependencies[= ] =3D { + {AARCH64_NO_FEATURES, AARCH64_NO_FEATURES} +}; + +static aarch64_feature_set +aarch64_update_virtual_dependencies (aarch64_feature_set set) +{ + unsigned int i; + for (i =3D 0; i < ARRAY_SIZE (aarch64_dependencies); i++) + AARCH64_CLEAR_FEATURES (set, set, aarch64_dependencies[i].enables); + + for (i =3D 0; i < ARRAY_SIZE (aarch64_dependencies); i++) + if (AARCH64_CPU_HAS_ALL_FEATURES (set, aarch64_dependencies[i].test)) + AARCH64_MERGE_FEATURE_SETS (set, set, aarch64_dependencies[i].enable= s); + + return set; +} + /* Transitive closure of features depending on set. */ static aarch64_feature_set aarch64_feature_disable_set (aarch64_feature_set set) @@ -10722,16 +10748,23 @@ static int aarch64_parse_features (const char *str, const aarch64_feature_set **opt_p, bool ext_only) { + /* Copy the feature set, so that we can modify it. */ + aarch64_feature_set *ext_set =3D XNEW (aarch64_feature_set); + *ext_set =3D **opt_p; + *opt_p =3D ext_set; + + if (str =3D=3D NULL) + { + /* No extensions, so just set the virtual feature bits and return. = */ + *ext_set =3D aarch64_update_virtual_dependencies (*ext_set); + return 1; + } + /* We insist on extensions being added before being removed. We achieve this by using the ADDING_VALUE variable to indicate whether we are adding an extension (1) or removing it (0) and only allowing it to change in the order -1 -> 1 -> 0. */ int adding_value =3D -1; - aarch64_feature_set *ext_set =3D XNEW (aarch64_feature_set); - - /* Copy the feature set, so that we can modify it. */ - *ext_set =3D **opt_p; - *opt_p =3D ext_set; =20 while (str !=3D NULL && *str !=3D 0) { @@ -10811,6 +10844,7 @@ aarch64_parse_features (const char *str, const aarc= h64_feature_set **opt_p, str =3D ext; }; =20 + *ext_set =3D aarch64_update_virtual_dependencies (*ext_set); return 1; } =20 @@ -10836,10 +10870,7 @@ aarch64_parse_cpu (const char *str) if (strlen (opt->name) =3D=3D optlen && strncmp (str, opt->name, optle= n) =3D=3D 0) { mcpu_cpu_opt =3D &opt->value; - if (ext !=3D NULL) - return aarch64_parse_features (ext, &mcpu_cpu_opt, false); - - return 1; + return aarch64_parse_features (ext, &mcpu_cpu_opt, false); } =20 as_bad (_("unknown cpu `%s'"), str); @@ -10868,10 +10899,7 @@ aarch64_parse_arch (const char *str) if (strlen (opt->name) =3D=3D optlen && strncmp (str, opt->name, optle= n) =3D=3D 0) { march_cpu_opt =3D &opt->value; - if (ext !=3D NULL) - return aarch64_parse_features (ext, &march_cpu_opt, false); - - return 1; + return aarch64_parse_features (ext, &march_cpu_opt, false); } =20 as_bad (_("unknown architecture `%s'\n"), str); @@ -11057,9 +11085,8 @@ s_aarch64_cpu (int ignored ATTRIBUTE_UNUSED) && strncmp (name, opt->name, optlen) =3D=3D 0) { mcpu_cpu_opt =3D &opt->value; - if (ext !=3D NULL) - if (!aarch64_parse_features (ext, &mcpu_cpu_opt, false)) - return; + if (!aarch64_parse_features (ext, &mcpu_cpu_opt, false)) + return; =20 cpu_variant =3D *mcpu_cpu_opt; =20 @@ -11102,9 +11129,8 @@ s_aarch64_arch (int ignored ATTRIBUTE_UNUSED) && strncmp (name, opt->name, optlen) =3D=3D 0) { mcpu_cpu_opt =3D &opt->value; - if (ext !=3D NULL) - if (!aarch64_parse_features (ext, &mcpu_cpu_opt, false)) - return; + if (!aarch64_parse_features (ext, &mcpu_cpu_opt, false)) + return; =20 cpu_variant =3D *mcpu_cpu_opt;