diff mbox series

Fix ptwrite64 handling with -m32 (PR target/88195)

Message ID 20181126205229.GJ12380@tucnak
State New
Headers show
Series Fix ptwrite64 handling with -m32 (PR target/88195) | expand

Commit Message

Jakub Jelinek Nov. 26, 2018, 8:52 p.m. UTC
Hi!

The following patch makes def_builtin2 behave consistently wrt.
OPTION_MASK_ISA_64BIT requirement to def_builtin.
The latter has:
  tree decl = NULL_TREE;

  if (!(mask & OPTION_MASK_ISA_64BIT) || TARGET_64BIT)
    {
...
    }

  return decl;
and so if some builtin requires TARGET_64BIT, it is never defined for -m32;
that is an option affecting the whole TU.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-11-26  Jakub Jelinek  <jakub@redhat.com>

	PR target/88195
	* config/i386/i386.c (def_builtin2): If tcode == VOID_FTYPE_UINT64
	and !TARGET_64BIT, return NULL_TREE.

	* gcc.target/i386/pr88195.c: New test.


	Jakub

Comments

Uros Bizjak Nov. 26, 2018, 9:23 p.m. UTC | #1
On Mon, Nov 26, 2018 at 9:52 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> The following patch makes def_builtin2 behave consistently wrt.
> OPTION_MASK_ISA_64BIT requirement to def_builtin.
> The latter has:
>   tree decl = NULL_TREE;
>
>   if (!(mask & OPTION_MASK_ISA_64BIT) || TARGET_64BIT)
>     {
> ...
>     }
>
>   return decl;
> and so if some builtin requires TARGET_64BIT, it is never defined for -m32;
> that is an option affecting the whole TU.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2018-11-26  Jakub Jelinek  <jakub@redhat.com>
>
>         PR target/88195
>         * config/i386/i386.c (def_builtin2): If tcode == VOID_FTYPE_UINT64
>         and !TARGET_64BIT, return NULL_TREE.
>
>         * gcc.target/i386/pr88195.c: New test.

OK.

Thanks,
Uros.

> --- gcc/config/i386/i386.c.jj   2018-11-22 22:35:05.741447372 +0100
> +++ gcc/config/i386/i386.c      2018-11-26 14:31:28.074501784 +0100
> @@ -30179,9 +30179,13 @@ def_builtin2 (HOST_WIDE_INT mask, const
>  {
>    tree decl = NULL_TREE;
>
> -  ix86_builtins_isa[(int) code].isa2 = mask;
>    if (tcode == VOID_FTYPE_UINT64)
> -    ix86_builtins_isa[(int) code].isa = OPTION_MASK_ISA_64BIT;
> +    {
> +      if (!TARGET_64BIT)
> +       return decl;
> +      ix86_builtins_isa[(int) code].isa = OPTION_MASK_ISA_64BIT;
> +    }
> +  ix86_builtins_isa[(int) code].isa2 = mask;
>
>    if (mask == 0
>        || (mask & ix86_isa_flags2) != 0
> --- gcc/testsuite/gcc.target/i386/pr88195.c.jj  2018-11-26 14:41:29.098641863 +0100
> +++ gcc/testsuite/gcc.target/i386/pr88195.c     2018-11-26 14:41:00.366113191 +0100
> @@ -0,0 +1,8 @@
> +/* PR target/88195 */
> +/* { dg-options "-mptwrite" } */
> +
> +void
> +foo (void)
> +{
> +  __builtin_ia32_ptwrite64 (1);        /* { dg-warning "implicit declaration of function" "" { target ia32 } } */
> +}
>
>         Jakub
diff mbox series

Patch

--- gcc/config/i386/i386.c.jj	2018-11-22 22:35:05.741447372 +0100
+++ gcc/config/i386/i386.c	2018-11-26 14:31:28.074501784 +0100
@@ -30179,9 +30179,13 @@  def_builtin2 (HOST_WIDE_INT mask, const
 {
   tree decl = NULL_TREE;
 
-  ix86_builtins_isa[(int) code].isa2 = mask;
   if (tcode == VOID_FTYPE_UINT64)
-    ix86_builtins_isa[(int) code].isa = OPTION_MASK_ISA_64BIT;
+    {
+      if (!TARGET_64BIT)
+	return decl;
+      ix86_builtins_isa[(int) code].isa = OPTION_MASK_ISA_64BIT;
+    }
+  ix86_builtins_isa[(int) code].isa2 = mask;
 
   if (mask == 0
       || (mask & ix86_isa_flags2) != 0
--- gcc/testsuite/gcc.target/i386/pr88195.c.jj	2018-11-26 14:41:29.098641863 +0100
+++ gcc/testsuite/gcc.target/i386/pr88195.c	2018-11-26 14:41:00.366113191 +0100
@@ -0,0 +1,8 @@ 
+/* PR target/88195 */
+/* { dg-options "-mptwrite" } */
+
+void
+foo (void)
+{
+  __builtin_ia32_ptwrite64 (1);	/* { dg-warning "implicit declaration of function" "" { target ia32 } } */
+}