Hello.
The patch is about supporting target attribute values like "no-avx, sse2 ".
I'm planning doing the same change for aarch64 and other archs as well once
this one is accepted.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Thanks,
Martin
PR target/102374
gcc/ChangeLog:
* config/i386/i386-options.c (ix86_valid_target_attribute_inner_p):
* system.h (strip_spaces):
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr102374.c: New test.
---
gcc/config/i386/i386-options.c | 2 ++
gcc/system.h | 21 +++++++++++++++++++++
gcc/testsuite/gcc.target/i386/pr102374.c | 3 +++
3 files changed, 26 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/i386/pr102374.c
diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c
index e7a3bd4aaea..c88bc77b04d 100644
--- a/gcc/config/i386/i386-options.c
+++ b/gcc/config/i386/i386-options.c
@@ -1146,6 +1146,8 @@ ix86_valid_target_attribute_inner_p (tree fndecl, tree
args, char *p_strings[],
next_optstr = NULL;
}
+ p = strip_spaces (p, &len);
+
/* Recognize no-xxx. */
if (len > 3 && p[0] == 'n' && p[1] == 'o' && p[2] == '-')
{
diff --git a/gcc/system.h b/gcc/system.h
index adde3e264b6..35b15203a96 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -1305,4 +1305,25 @@ startswith (const char *str, const char *prefix)
return strncmp (str, prefix, strlen (prefix)) == 0;
}
+/* Strip spaces from STRING with LEN length.
+ A stripped string is returned and LEN is updated accordingly. */
+
+static inline char *
+strip_spaces (char *string, size_t *len)
+{
+ while (string[0] == ' ')
+ {
+ --(*len);
+ ++string;
+ }
+
+ while (string[*len - 1] == ' ')
+ {
+ string[*len - 1] = '\0';
+ --(*len);
+ }
+
+ return string;
+}
+
#endif /* ! GCC_SYSTEM_H */
diff --git a/gcc/testsuite/gcc.target/i386/pr102374.c
b/gcc/testsuite/gcc.target/i386/pr102374.c
new file mode 100644
index 00000000000..db84aeed9a5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr102374.c
@@ -0,0 +1,3 @@
+/* PR target/102374 */
+
+void calculate_sse(void) __attribute__ ((__target__ ("no-avx, sse2 ")));
--
2.33.0