From: Alice Carlotti Date: Mon, 10 Nov 2025 16:15:34 +0000 (+0000) Subject: aarch64: Extend syntax for cpuinfo feature string checks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10caba3a9661d3ad8298132fde1d6a06793a2359;p=thirdparty%2Fgcc.git aarch64: Extend syntax for cpuinfo feature string checks Some SVE features in the toolchain need to be enabled when either of two different kernel HWCAPS (and corresponding cpuinfo strings) are enabled (one for non-streaming mode and one for streaming mode). Add support for using "|" to separate alternative lists of required features. gcc/ChangeLog: * config/aarch64/driver-aarch64.cc (host_detect_local_cpu): Extend feature string syntax. --- diff --git a/gcc/config/aarch64/driver-aarch64.cc b/gcc/config/aarch64/driver-aarch64.cc index 0333746ee00..be98c5b5d1b 100644 --- a/gcc/config/aarch64/driver-aarch64.cc +++ b/gcc/config/aarch64/driver-aarch64.cc @@ -368,18 +368,30 @@ host_detect_local_cpu (int argc, const char **argv) continue; } + /* This may be a multi-token feature string. We need to match + all parts in one of the "|" separated sublists. */ bool enabled = true; - - /* This may be a multi-token feature string. We need - to match all parts, which could be in any order. */ - std::set tokens; - split_words (val, tokens); - std::set::iterator it; - - /* Iterate till the first feature isn't found or all of them - are found. */ - for (it = tokens.begin (); enabled && it != tokens.end (); ++it) - enabled = enabled && features.count (*it); + size_t cur = 0; + while (cur < val.length ()) + { + size_t end = val.find_first_of (" ", cur); + if (end == std::string::npos) + end = val.length (); + std::string word = val.substr (cur, end - cur); + cur = end + 1; + + if (word == "|") + { + /* If we've matched everything in the current sublist, we + can stop now. */ + if (enabled) + break; + /* Otherwise, start again with the next sublist. */ + enabled = true; + continue; + } + enabled = enabled && features.count (word); + } if (enabled) extension_flags |= aarch64_extensions[i].flag;