* [PATCH] x86: Reject target("no-general-regs-only")
@ 2020-08-26 19:39 H.J. Lu
2020-08-27 8:46 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2020-08-26 19:39 UTC (permalink / raw)
To: gcc-patches
Reject target("no-general-regs-only") pragma and attribute.
gcc/
PR target/96802
* config/i386/i386-options.c (ix86_valid_target_attribute_inner_p):
Reject target("no-general-regs-only").
gcc/testsuite/
PR target/96802
* gcc.target/i386/pr96802-1.c: New test.
* gcc.target/i386/pr96802-2.c: Likewise.
---
gcc/config/i386/i386-options.c | 7 +++++++
gcc/testsuite/gcc.target/i386/pr96802-1.c | 12 ++++++++++++
gcc/testsuite/gcc.target/i386/pr96802-2.c | 16 ++++++++++++++++
3 files changed, 35 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/i386/pr96802-1.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr96802-2.c
diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c
index e0fc68c27bf..b93c338346f 100644
--- a/gcc/config/i386/i386-options.c
+++ b/gcc/config/i386/i386-options.c
@@ -1189,6 +1189,13 @@ ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[],
{
if (mask == OPTION_MASK_GENERAL_REGS_ONLY)
{
+ if (!opt_set_p)
+ {
+ error_at (loc, "pragma or attribute %<target(\"%s\")%> "
+ "does not allow a negated form", p);
+ return false;
+ }
+
if (type != ix86_opt_ix86_yes)
gcc_unreachable ();
diff --git a/gcc/testsuite/gcc.target/i386/pr96802-1.c b/gcc/testsuite/gcc.target/i386/pr96802-1.c
new file mode 100644
index 00000000000..e6ceb95d238
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr96802-1.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+/* Reject the negated form of non-negatable attributes. */
+
+__attribute__ ((target ("no-general-regs-only")))
+int
+foo (int a)
+{
+ return a + 1;
+}
+
+/* { dg-error "does not allow a negated form" "" { target *-*-* } 0 } */
diff --git a/gcc/testsuite/gcc.target/i386/pr96802-2.c b/gcc/testsuite/gcc.target/i386/pr96802-2.c
new file mode 100644
index 00000000000..515f5673777
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr96802-2.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+/* Reject the negated form of non-negatable pragma target. */
+
+#pragma GCC push_options
+#pragma GCC target("no-general-regs-only")
+
+int
+foo (int a)
+{
+ return a + 1;
+}
+
+#pragma GCC pop_options
+
+/* { dg-error "does not allow a negated form" "" { target *-*-* } 0 } */
--
2.26.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86: Reject target("no-general-regs-only")
2020-08-26 19:39 [PATCH] x86: Reject target("no-general-regs-only") H.J. Lu
@ 2020-08-27 8:46 ` Richard Biener
2020-08-27 10:36 ` H.J. Lu
0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2020-08-27 8:46 UTC (permalink / raw)
To: H.J. Lu; +Cc: GCC Patches
On Wed, Aug 26, 2020 at 9:40 PM H.J. Lu via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Reject target("no-general-regs-only") pragma and attribute.
mgeneral-regs-only
Target Report RejectNegative Mask(GENERAL_REGS_ONLY) Var(ix86_target_flags) Save
Generate code which uses only the general registers.
it has already RejectNegative - why's that not honored? Is this a general
issue?
Richard.
> gcc/
>
> PR target/96802
> * config/i386/i386-options.c (ix86_valid_target_attribute_inner_p):
> Reject target("no-general-regs-only").
>
> gcc/testsuite/
>
> PR target/96802
> * gcc.target/i386/pr96802-1.c: New test.
> * gcc.target/i386/pr96802-2.c: Likewise.
> ---
> gcc/config/i386/i386-options.c | 7 +++++++
> gcc/testsuite/gcc.target/i386/pr96802-1.c | 12 ++++++++++++
> gcc/testsuite/gcc.target/i386/pr96802-2.c | 16 ++++++++++++++++
> 3 files changed, 35 insertions(+)
> create mode 100644 gcc/testsuite/gcc.target/i386/pr96802-1.c
> create mode 100644 gcc/testsuite/gcc.target/i386/pr96802-2.c
>
> diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c
> index e0fc68c27bf..b93c338346f 100644
> --- a/gcc/config/i386/i386-options.c
> +++ b/gcc/config/i386/i386-options.c
> @@ -1189,6 +1189,13 @@ ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[],
> {
> if (mask == OPTION_MASK_GENERAL_REGS_ONLY)
> {
> + if (!opt_set_p)
> + {
> + error_at (loc, "pragma or attribute %<target(\"%s\")%> "
> + "does not allow a negated form", p);
> + return false;
> + }
> +
> if (type != ix86_opt_ix86_yes)
> gcc_unreachable ();
>
> diff --git a/gcc/testsuite/gcc.target/i386/pr96802-1.c b/gcc/testsuite/gcc.target/i386/pr96802-1.c
> new file mode 100644
> index 00000000000..e6ceb95d238
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr96802-1.c
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +
> +/* Reject the negated form of non-negatable attributes. */
> +
> +__attribute__ ((target ("no-general-regs-only")))
> +int
> +foo (int a)
> +{
> + return a + 1;
> +}
> +
> +/* { dg-error "does not allow a negated form" "" { target *-*-* } 0 } */
> diff --git a/gcc/testsuite/gcc.target/i386/pr96802-2.c b/gcc/testsuite/gcc.target/i386/pr96802-2.c
> new file mode 100644
> index 00000000000..515f5673777
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr96802-2.c
> @@ -0,0 +1,16 @@
> +/* { dg-do compile } */
> +
> +/* Reject the negated form of non-negatable pragma target. */
> +
> +#pragma GCC push_options
> +#pragma GCC target("no-general-regs-only")
> +
> +int
> +foo (int a)
> +{
> + return a + 1;
> +}
> +
> +#pragma GCC pop_options
> +
> +/* { dg-error "does not allow a negated form" "" { target *-*-* } 0 } */
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86: Reject target("no-general-regs-only")
2020-08-27 8:46 ` Richard Biener
@ 2020-08-27 10:36 ` H.J. Lu
0 siblings, 0 replies; 4+ messages in thread
From: H.J. Lu @ 2020-08-27 10:36 UTC (permalink / raw)
To: Richard Biener; +Cc: GCC Patches
On Thu, Aug 27, 2020 at 1:47 AM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Wed, Aug 26, 2020 at 9:40 PM H.J. Lu via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> >
> > Reject target("no-general-regs-only") pragma and attribute.
>
> mgeneral-regs-only
> Target Report RejectNegative Mask(GENERAL_REGS_ONLY) Var(ix86_target_flags) Save
> Generate code which uses only the general registers.
>
> it has already RejectNegative - why's that not honored? Is this a general
> issue?
>
target("no-general-regs-only") needs to be handled separately.
--
H.J.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86: Reject target("no-general-regs-only")
@ 2020-08-26 19:54 Uros Bizjak
0 siblings, 0 replies; 4+ messages in thread
From: Uros Bizjak @ 2020-08-26 19:54 UTC (permalink / raw)
To: gcc-patches
> Reject target("no-general-regs-only") pragma and attribute.
>
> gcc/
>
> PR target/96802
> * config/i386/i386-options.c (ix86_valid_target_attribute_inner_p):
> Reject target("no-general-regs-only").
>
> gcc/testsuite/
>
> PR target/96802
> * gcc.target/i386/pr96802-1.c: New test.
> * gcc.target/i386/pr96802-2.c: Likewise.
OK.
Thanks,
Uros.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-27 10:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 19:39 [PATCH] x86: Reject target("no-general-regs-only") H.J. Lu
2020-08-27 8:46 ` Richard Biener
2020-08-27 10:36 ` H.J. Lu
2020-08-26 19:54 Uros Bizjak
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).