This adds support for __builtin_prefetch in Ada.

Tested on x86_64-suse-linux, applied on the mainline.


2019-05-28  Eric Botcazou  <ebotca...@adacore.com>

        * gcc-interface/decl.c (intrin_arglists_compatible_p): Do not return
        false if the internal builtin uses a variable list.


2019-05-28  Eric Botcazou  <ebotca...@adacore.com>

        * gnat.dg/prefetch1.ad[sb]: New test.

-- 
Eric Botcazou
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c	(revision 271528)
+++ gcc-interface/decl.c	(working copy)
@@ -9174,9 +9174,9 @@ intrin_arglists_compatible_p (intrin_bin
       if (!ada_type && !btin_type)
 	break;
 
-      /* If one list is shorter than the other, they fail to match.  */
-      if (!ada_type || !btin_type)
-	return false;
+      /* If the internal builtin uses a variable list, accept anything.  */
+      if (!btin_type)
+	break;
 
       /* If we're done with the Ada args and not with the internal builtin
 	 args, or the other way around, complain.  */
with System;

package Prefetch1 is

  procedure My_Proc1 (Addr : System.Address);
  procedure My_Proc2 (Addr : System.Address);
  procedure My_Proc3 (Addr : System.Address);

end Prefetch1;
-- { dg-do compile }

package body Prefetch1 is

  procedure Prefetch_1 (Addr : System.Address);
  pragma Import (Intrinsic, Prefetch_1, "__builtin_prefetch");

  procedure Prefetch_2 (Addr : System.Address; RW : Integer);
  pragma Import (Intrinsic, Prefetch_2, "__builtin_prefetch");

  procedure Prefetch_3 (Addr : System.Address; RW : Integer; Locality : Integer);
  pragma Import (Intrinsic, Prefetch_3, "__builtin_prefetch");

  procedure My_Proc1 (Addr : System.Address) is
  begin
    Prefetch_1 (Addr);
  end;

  procedure My_Proc2 (Addr : System.Address) is
  begin
    Prefetch_2 (Addr, 1);
  end;

  procedure My_Proc3 (Addr : System.Address) is
  begin
    Prefetch_3 (Addr, 1, 1);
  end;

end Prefetch1;

Reply via email to