From 95f2be29446f6d04e4b221b228eac190057d839b Mon Sep 17 00:00:00 2001 From: Olivier Hainque Date: Wed, 26 Sep 2018 09:17:46 +0000 Subject: [Ada] Front-end support for OpenACC pragmas This patch introduces the upper part of the Ada front-end support for a first set of OpenACC directives (Acc_Kernels, Acc_Loop, Acc_Parallel, Acc_Data) and their clauses. The pragmas syntax is documented, pragmas are recognized and checked for syntactic correctness, keyed on -fopenacc. A couple of new flags are defined on loop statements in the GNAT tree. 2018-09-26 Olivier Hainque gcc/ada/ * opt.ads (OpenAcc_Enabled): New flag. False by default. True when OpenACC pragmas are requested to be honored, when -fopenacc is found on the command line. * back_end.adb (Scan_Compiler_Arguments): Set OpenACC_Enabled if -fopenacc is seen on the command line. * sinfo.adb, sinfo.ads (Is_OpenAcc_Environment): New flag/predicate on Loop statements which embed an Acc_Kernels, Acc_Parallel or Acc_Data pragma. (Is_OpenAcc_Loop): New flag/predicate on Loop statements which embed an Acc_Loop pragma. (Set_Is_OpenAcc_Environment, Set_Is_OpenAcc_Loop): Setters for the new flags. * par-prag.adb (Prag): Handle Acc_Data, Acc_Loop, Acc_Parallel and Acc_Kernels pragmas. Nothing to do here, all handled by sem_prag. * sem_prag.adb (Acc_First, Acc_Next, Validate_Acc_Condition_Clause, Validate_Acc_Data_Clause, Validate_Acc_Int_Expr_Clause, Validate_Acc_Int_Expr_List_Clause, Validate_Acc_Loop_Collapse, Validate_Acc_Loop_Gang, Validate_Acc_Loop_Vector, Validate_Acc_Loop_Worker, Validate_Acc_Name_Reduction, Validate_Acc_Size_Expressions): New helper for Analyze_Pragma, to handle OpenACC pragmas. (Analyze_Pragma): Handle Acc_Data, Acc_Loop, Acc_Parallel and Acc_Kernels pragmas. * sem_ch5.adb (Disable_Constant): Unset Is_True_Constant on variable entity, action for ... (Disable_Constants): Helper for Analyze_Loop_Statement, to ... (Analyze_Loop_Statement): Disable True_Constant on variables referenced within an OpenACC environment. * snames.ads-tmpl: Declare Name_Ids for the OpenACC directives and clauses we can handle. Remove an exraneous whitespace before columns, preventing line length overflow in the generated spec with Ids now reaching beyond 999. * doc/gnat_rm/implementation_defined_pragmas.rst: Document pragma Acc_Parallel, Acc_Loop, Acc_Kernels and Acc_Data. * gnat_rm.texi: Regenerate. From-SVN: r264617 --- gcc/ada/sinfo.adb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'gcc/ada/sinfo.adb') diff --git a/gcc/ada/sinfo.adb b/gcc/ada/sinfo.adb index e6ff0e7..5444441 100644 --- a/gcc/ada/sinfo.adb +++ b/gcc/ada/sinfo.adb @@ -2069,6 +2069,22 @@ package body Sinfo is return Flag16 (N); end Is_Null_Loop; + function Is_OpenAcc_Environment + (N : Node_Id) return Boolean is + begin + pragma Assert (False + or else NT (N).Nkind = N_Loop_Statement); + return Flag13 (N); + end Is_OpenAcc_Environment; + + function Is_OpenAcc_Loop + (N : Node_Id) return Boolean is + begin + pragma Assert (False + or else NT (N).Nkind = N_Loop_Statement); + return Flag14 (N); + end Is_OpenAcc_Loop; + function Is_Overloaded (N : Node_Id) return Boolean is begin @@ -5527,6 +5543,22 @@ package body Sinfo is Set_Flag16 (N, Val); end Set_Is_Null_Loop; + procedure Set_Is_OpenAcc_Environment + (N : Node_Id; Val : Boolean := True) is + begin + pragma Assert (False + or else NT (N).Nkind = N_Loop_Statement); + Set_Flag13 (N, Val); + end Set_Is_OpenAcc_Environment; + + procedure Set_Is_OpenAcc_Loop + (N : Node_Id; Val : Boolean := True) is + begin + pragma Assert (False + or else NT (N).Nkind = N_Loop_Statement); + Set_Flag14 (N, Val); + end Set_Is_OpenAcc_Loop; + procedure Set_Is_Overloaded (N : Node_Id; Val : Boolean := True) is begin -- cgit v1.1