From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95521 invoked by alias); 25 Apr 2017 13:05:44 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 95137 invoked by uid 89); 25 Apr 2017 13:05:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Tristan, tristan, Deadline X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 25 Apr 2017 13:05:34 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CDF1636A0; Tue, 25 Apr 2017 09:05:34 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id jKNGxCXLqkCa; Tue, 25 Apr 2017 09:05:34 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id BAD0A29DD4; Tue, 25 Apr 2017 09:05:34 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id B669A3F0; Tue, 25 Apr 2017 09:05:34 -0400 (EDT) Date: Tue, 25 Apr 2017 13:06:00 -0000 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Tristan Gingold Subject: [Ada] Add GNAT_Ravenscar_EDF profile Message-ID: <20170425130534.GA69570@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="KsGdsel6WgEHnImy" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2017-04/txt/msg01190.txt.bz2 --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1027 This is an experimental profile to test EDF scheduling on bareboard platforms. No test as no runtime yet. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-04-25 Tristan Gingold * exp_ch9.adb (Expand_N_Task_Type_Declaration): Add relative_deadline to task record on edf profile. (Make_Initialize_Protection): Pass deadline_floor value on edf profile. (Make_Task_Create_Call): Pass relative_deadline value. * par-prag.adb (Prag): Handle Pragma_Deadline_Floor. * s-rident.ads (Profile_Name): Add GNAT_Ravenscar_EDF. (Profile_Info): Add info for GNAT_Ravenscar_EDF. * sem_prag.adb (Set_Ravenscar_Profile): Handle GNAT_Ravenscar_EDF (set scheduling policy). (Analyze_Pragma): Handle GNAT_Ravenscar_EDF profile and Deadline_Floor pragma. (Sig_Flags): Add choice for Pragma_Deadline_Floor. * snames.ads-tmpl (Name_Deadline_Floor, Name_Gnat_Ravenscar_EDF): New names. (Pragma_Deadline_Floor): New pragma. * targparm.adb (Get_Target_Parameters): Recognize GNAT_Ravenscar_EDF profile. --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=difs Content-length: 19714 Index: exp_ch9.adb =================================================================== --- exp_ch9.adb (revision 247177) +++ exp_ch9.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -12026,9 +12026,11 @@ -- Add the _Relative_Deadline component if a Relative_Deadline pragma is -- present. If we are using a restricted run time this component will - -- not be added (deadlines are not allowed by the Ravenscar profile). + -- not be added (deadlines are not allowed by the Ravenscar profile), + -- unless the task dispatching policy is EDF (for GNAT_Ravenscar_EDF + -- profile). - if not Restricted_Profile + if (not Restricted_Profile or else Task_Dispatching_Policy = 'E') and then Present (Taskdef) and then Has_Relative_Deadline_Pragma (Taskdef) then @@ -13822,6 +13824,46 @@ New_Occurrence_Of (RTE (RE_Unspecified_Priority), Loc)); end if; + -- Deadline_Floor parameter for GNAT_Ravenscar_EDF runtimes + + if Restricted_Profile and Task_Dispatching_Policy = 'E' then + Deadline_Floor : declare + Item : constant Node_Id := + Get_Rep_Item + (Ptyp, Name_Deadline_Floor, Check_Parents => False); + + Deadline : Node_Id; + + begin + if Present (Item) then + + -- Pragma Deadline_Floor + + if Nkind (Item) = N_Pragma then + Deadline := + Expression + (First (Pragma_Argument_Associations (Item))); + + -- Attribute definition clause Deadline_Floor + + else + pragma Assert + (Nkind (Item) = N_Attribute_Definition_Clause); + + Deadline := Expression (Item); + end if; + + Append_To (Args, Deadline); + + -- Unusual case: default deadline + + else + Append_To (Args, + New_Occurrence_Of (RTE (RE_Time_Span_Zero), Loc)); + end if; + end Deadline_Floor; + end if; + -- Test for Compiler_Info parameter. This parameter allows entry body -- procedures and barrier functions to be called from the runtime. It -- is a pointer to the record generated by the compiler to represent @@ -14127,15 +14169,18 @@ -- Priority parameter. Set to Unspecified_Priority unless there is a -- Priority rep item, in which case we take the value from the rep item. + -- Not used on Ravenscar_EDF profile. - if Has_Rep_Item (Ttyp, Name_Priority, Check_Parents => False) then - Append_To (Args, - Make_Selected_Component (Loc, - Prefix => Make_Identifier (Loc, Name_uInit), - Selector_Name => Make_Identifier (Loc, Name_uPriority))); - else - Append_To (Args, - New_Occurrence_Of (RTE (RE_Unspecified_Priority), Loc)); + if not (Restricted_Profile and then Task_Dispatching_Policy = 'E') then + if Has_Rep_Item (Ttyp, Name_Priority, Check_Parents => False) then + Append_To (Args, + Make_Selected_Component (Loc, + Prefix => Make_Identifier (Loc, Name_uInit), + Selector_Name => Make_Identifier (Loc, Name_uPriority))); + else + Append_To (Args, + New_Occurrence_Of (RTE (RE_Unspecified_Priority), Loc)); + end if; end if; -- Optional Stack parameter @@ -14231,7 +14276,7 @@ New_Occurrence_Of (RTE (RE_Unspecified_CPU), Loc)); end if; - if not Restricted_Profile then + if not Restricted_Profile or else Task_Dispatching_Policy = 'E' then -- Deadline parameter. If no Relative_Deadline pragma is present, -- then the deadline is Time_Span_Zero. If a pragma is present, then @@ -14255,7 +14300,10 @@ Append_To (Args, New_Occurrence_Of (RTE (RE_Time_Span_Zero), Loc)); end if; + end if; + if not Restricted_Profile then + -- Dispatching_Domain parameter. If no Dispatching_Domain rep item is -- present, then the dispatching domain is null. If a rep item is -- present, then the dispatching domain is taken from the Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 247212) +++ sem_prag.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -3998,9 +3998,10 @@ procedure Set_Ravenscar_Profile (Profile : Profile_Name; N : Node_Id); -- Activate the set of configuration pragmas and restrictions that make - -- up the Profile. Profile must be either GNAT_Extended_Ravencar or - -- Ravenscar. N is the corresponding pragma node, which is used for - -- error messages on any constructs violating the profile. + -- up the Profile. Profile must be either GNAT_Extended_Ravencar, + -- GNAT_Ravenscar_EDF or Ravenscar. N is the corresponding pragma node, + -- which is used for error messages on any constructs violating the + -- profile. ---------------------------------- -- Acquire_Warning_Match_String -- @@ -10322,6 +10323,9 @@ -- Set required policies -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities) + -- (For Ravenscar and GNAT_Extended_Ravenscar profiles) + -- pragma Task_Dispatching_Policy (EDF_Across_Priorities) + -- (For GNAT_Ravenscar_EDF profile) -- pragma Locking_Policy (Ceiling_Locking) -- Set Detect_Blocking mode @@ -10364,13 +10368,24 @@ Pref_Id : Node_Id; Sel_Id : Node_Id; + Profile_Dispatching_Policy : Character; + -- Start of processing for Set_Ravenscar_Profile begin + -- pragma Task_Dispatching_Policy (EDF_Across_Priorities) + + if Profile = GNAT_Ravenscar_EDF then + Profile_Dispatching_Policy := 'E'; + -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities) + else + Profile_Dispatching_Policy := 'F'; + end if; + if Task_Dispatching_Policy /= ' ' - and then Task_Dispatching_Policy /= 'F' + and then Task_Dispatching_Policy /= Profile_Dispatching_Policy then Error_Msg_Sloc := Task_Dispatching_Policy_Sloc; Set_Error_Msg_To_Profile_Name; @@ -10381,7 +10396,7 @@ -- name. else - Task_Dispatching_Policy := 'F'; + Task_Dispatching_Policy := Profile_Dispatching_Policy; if Task_Dispatching_Policy_Sloc /= System_Location then Task_Dispatching_Policy_Sloc := Loc; @@ -13818,6 +13833,45 @@ Record_Rep_Item (Ent, N); end CPU; + -------------------- + -- Deadline_Floor -- + -------------------- + + -- pragma Deadline_Floor (time_span_EXPRESSION); + + when Pragma_Deadline_Floor => Deadline_Floor : declare + P : constant Node_Id := Parent (N); + Arg : Node_Id; + Ent : Entity_Id; + + begin + GNAT_Pragma; + Check_No_Identifiers; + Check_Arg_Count (1); + + Arg := Get_Pragma_Arg (Arg1); + + -- The expression must be analyzed in the special manner described + -- in "Handling of Default and Per-Object Expressions" in sem.ads. + + Preanalyze_Spec_Expression (Arg, RTE (RE_Time_Span)); + + -- Only protected types allowed + + if Nkind (P) /= N_Protected_Definition then + Pragma_Misplaced; + + else + Ent := Defining_Identifier (Parent (P)); + + -- Check duplicate pragma before we chain the pragma in the Rep + -- Item chain of Ent. + + Check_Duplicate_Pragma (Ent); + Record_Rep_Item (Ent, N); + end if; + end Deadline_Floor; + ----------- -- Debug -- ----------- @@ -19928,6 +19982,9 @@ elsif Chars (Argx) = Name_Gnat_Extended_Ravenscar then Set_Ravenscar_Profile (GNAT_Extended_Ravenscar, N); + elsif Chars (Argx) = Name_Gnat_Ravenscar_EDF then + Set_Ravenscar_Profile (GNAT_Ravenscar_EDF, N); + elsif Chars (Argx) = Name_Restricted then Set_Profile_Restrictions (Restricted, @@ -29110,6 +29167,7 @@ Pragma_Controlled => 0, Pragma_Convention => 0, Pragma_Convention_Identifier => 0, + Pragma_Deadline_Floor => -1, Pragma_Debug => -1, Pragma_Debug_Policy => 0, Pragma_Detect_Blocking => 0, Index: targparm.adb =================================================================== --- targparm.adb (revision 247177) +++ targparm.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1999-2015, Free Software Foundation, Inc. -- +-- Copyright (C) 1999-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -304,9 +304,20 @@ Set_Profile_Restrictions (GNAT_Extended_Ravenscar); Opt.Task_Dispatching_Policy := 'F'; Opt.Locking_Policy := 'C'; - P := P + 27; + P := P + 41; goto Line_Loop_Continue; + -- Test for pragma Profile (GNAT_Ravenscar_EDF); + + elsif System_Text (P .. P + 35) = + "pragma Profile (GNAT_Ravenscar_EDF);" + then + Set_Profile_Restrictions (GNAT_Ravenscar_EDF); + Opt.Task_Dispatching_Policy := 'E'; + Opt.Locking_Policy := 'C'; + P := P + 36; + goto Line_Loop_Continue; + -- Test for pragma Profile (Restricted); elsif System_Text (P .. P + 27) = Index: par-prag.adb =================================================================== --- par-prag.adb (revision 247177) +++ par-prag.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1334,6 +1334,7 @@ | Pragma_Component_Alignment | Pragma_Controlled | Pragma_Convention + | Pragma_Deadline_Floor | Pragma_Debug_Policy | Pragma_Depends | Pragma_Detect_Blocking Index: s-rident.ads =================================================================== --- s-rident.ads (revision 247177) +++ s-rident.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -381,7 +381,8 @@ Restricted_Tasking, Restricted, Ravenscar, - GNAT_Extended_Ravenscar); + GNAT_Extended_Ravenscar, + GNAT_Ravenscar_EDF); -- Names of recognized profiles. No_Profile is used to indicate that a -- restriction came from pragma Restrictions[_Warning], as opposed to -- pragma Profile[_Warning]. Restricted_Tasking is a non-user profile that @@ -390,7 +391,7 @@ -- that also restrict protected types. subtype Profile_Name_Actual is Profile_Name - range No_Implementation_Extensions .. GNAT_Extended_Ravenscar; + range No_Implementation_Extensions .. Profile_Name'Last; -- Actual used profile names type Profile_Data is record @@ -583,6 +584,59 @@ (Max_Asynchronous_Select_Nesting => 0, Max_Select_Alternatives => 0, Max_Task_Entries => 0, + others => 0)), + + -- GNAT_Ravenscar_EDF Profile + + -- Note: the table entries here only represent the + -- required restriction profile for GNAT_Ravenscar_EDF. + -- The full GNAT_Ravenscar_EDF profile also requires: + + -- pragma Dispatching_Policy (EDF_Across_Priorities); + -- pragma Locking_Policy (Ceiling_Locking); + -- pragma Detect_Blocking; + + GNAT_Ravenscar_EDF => + + -- Restrictions for Ravenscar = Restricted profile .. + + (Set => + (No_Abort_Statements => True, + No_Asynchronous_Control => True, + No_Dynamic_Attachment => True, + No_Dynamic_Priorities => True, + No_Entry_Queue => True, + No_Local_Protected_Objects => True, + No_Protected_Type_Allocators => True, + No_Requeue_Statements => True, + No_Task_Allocators => True, + No_Task_Attributes_Package => True, + No_Task_Hierarchy => True, + No_Terminate_Alternatives => True, + Max_Asynchronous_Select_Nesting => True, + Max_Protected_Entries => True, + Max_Select_Alternatives => True, + Max_Task_Entries => True, + + -- plus these additional restrictions: + + No_Calendar => True, + No_Implicit_Heap_Allocations => True, + No_Local_Timing_Events => True, + No_Relative_Delay => True, + No_Select_Statements => True, + No_Specific_Termination_Handlers => True, + No_Task_Termination => True, + Simple_Barriers => True, + others => False), + + -- Value settings for Ravenscar (same as Restricted) + + Value => + (Max_Asynchronous_Select_Nesting => 0, + Max_Protected_Entries => 1, + Max_Select_Alternatives => 0, + Max_Task_Entries => 0, others => 0))); end System.Rident; Index: snames.ads-tmpl =================================================================== --- snames.ads-tmpl (revision 247202) +++ snames.ads-tmpl (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -513,6 +513,7 @@ -- correctly recognize and process CPU. CPU is a standard Ada 2012 -- pragma. + Name_Deadline_Floor : constant Name_Id := N + $; -- GNAT Name_Debug : constant Name_Id := N + $; -- GNAT Name_Default_Initial_Condition : constant Name_Id := N + $; -- GNAT Name_Depends : constant Name_Id := N + $; -- GNAT @@ -748,6 +749,7 @@ Name_General : constant Name_Id := N + $; Name_Gnat : constant Name_Id := N + $; Name_Gnat_Extended_Ravenscar : constant Name_Id := N + $; + Name_Gnat_Ravenscar_EDF : constant Name_Id := N + $; Name_Gnatprove : constant Name_Id := N + $; Name_GPL : constant Name_Id := N + $; Name_High_Order_First : constant Name_Id := N + $; @@ -1871,6 +1873,7 @@ Pragma_CPP_Constructor, Pragma_CPP_Virtual, Pragma_CPP_Vtable, + Pragma_Deadline_Floor, Pragma_Debug, Pragma_Default_Initial_Condition, Pragma_Depends, --KsGdsel6WgEHnImy--