summaryrefslogtreecommitdiff
path: root/gcc/ada/exp_ch9.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-04 14:51:17 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-04 14:51:17 +0000
commitfb4b35012085b8402e7ccb2f42283fd6ddb347fd (patch)
tree7394d0a56f7edb0d1590b851334f4abd92b00005 /gcc/ada/exp_ch9.adb
parent5db81a3464b015386144b428943df1b5a0d12276 (diff)
downloadgcc-fb4b35012085b8402e7ccb2f42283fd6ddb347fd.tar.gz
2004-10-04 Jose Ruiz <ruiz@act-europe.fr>
* targparm.ads, targparm.adb (Targparm_Tags): Add PAS value corresponding to the Preallocated_Stacks flags in System. (Get_Target_Parameters): Including the processing for Preallocated_Stacks. * system.ads, system-vxworks-x86.ads, system-darwin-ppc.ads, system-vms_64.ads, system-unixware.ads, system-linux-ia64.ads, system-freebsd-x86.ads, system-lynxos-ppc.ads, system-lynxos-x86.ads, system-linux-x86_64.ads, system-tru64.ads, system-aix.ads, system-vxworks-sparcv9.ads, system-vxworks-xscale.ads, system-solaris-x86.ads, system-irix-o32.ads, system-irix-n32.ads, system-hpux.ads, system-vxworks-m68k.ads, system-linux-x86.ads, system-vxworks-mips.ads, system-os2.ads, system-interix.ads, system-solaris-sparc.ads, system-solaris-sparcv9.ads, system-vms.ads, system-mingw.ads, system-vms-zcx.ads, system-vxworks-ppc.ads, system-vxworks-alpha.ads: Add the flag Preallocated_Stacks, that is used to signal whether the compiler creates the required stacks and descriptors for the different tasks (when True) or it is done by the underlying operating system at run time (when False). It is initially set to False in all targets. * exp_ch9.adb (Expand_N_Task_Type_Declaration): Create the task stack if it is supported by the target. (Make_Task_Create_Call): Pass the stack address if it has been previously created. Otherwise pass a Null_Address. * snames.adb: Add _stack. * snames.ads: Add Name_uStack. Required to allow the expander to statically allocated task stacks. * s-tarest.ads, s-tarest.adb (Create_Restricted_Task): Add Stack_Address argument. Check that its value is equal to Null_Address because this target does not support the static stack allocation. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88488 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/exp_ch9.adb')
-rw-r--r--gcc/ada/exp_ch9.adb91
1 files changed, 79 insertions, 12 deletions
diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
index 1b07efaf321..133bf555b9d 100644
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -55,10 +55,10 @@ with Sem_Util; use Sem_Util;
with Sinfo; use Sinfo;
with Snames; use Snames;
with Stand; use Stand;
+with Targparm; use Targparm;
with Tbuild; use Tbuild;
with Types; use Types;
with Uintp; use Uintp;
-with Opt;
package body Exp_Ch9 is
@@ -7141,13 +7141,16 @@ package body Exp_Ch9 is
Tasknm : constant Name_Id := Chars (Tasktyp);
Taskdef : constant Node_Id := Task_Definition (N);
- Proc_Spec : Node_Id;
- Rec_Decl : Node_Id;
- Rec_Ent : Entity_Id;
- Cdecls : List_Id;
- Elab_Decl : Node_Id;
- Size_Decl : Node_Id;
- Body_Decl : Node_Id;
+ Proc_Spec : Node_Id;
+ Rec_Decl : Node_Id;
+ Rec_Ent : Entity_Id;
+ Cdecls : List_Id;
+ Elab_Decl : Node_Id;
+ Size_Decl : Node_Id;
+ Body_Decl : Node_Id;
+ Task_Size : Node_Id;
+ Ent_Stack : Entity_Id;
+ Decl_Stack : Node_Id;
begin
-- If already expanded, nothing to do
@@ -7249,6 +7252,51 @@ package body Exp_Ch9 is
end if;
+ -- Declare static stack (that is, created by the expander) if we
+ -- are using the Restricted run time on a bare board configuration.
+
+ if Restricted_Profile
+ and then Preallocated_Stacks_On_Target
+ then
+ -- First we need to extract the appropriate stack size
+
+ Ent_Stack := Make_Defining_Identifier (Loc, Name_uStack);
+
+ if Present (Taskdef) and then Has_Storage_Size_Pragma (Taskdef) then
+ Task_Size := Relocate_Node (
+ Expression (First (
+ Pragma_Argument_Associations (
+ Find_Task_Or_Protected_Pragma
+ (Taskdef, Name_Storage_Size)))));
+ else
+ Task_Size :=
+ New_Reference_To (RTE (RE_Default_Stack_Size), Loc);
+ end if;
+
+ Decl_Stack := Make_Component_Declaration (Loc,
+ Defining_Identifier => Ent_Stack,
+
+ Component_Definition =>
+ Make_Component_Definition (Loc,
+ Aliased_Present => True,
+ Subtype_Indication => Make_Subtype_Indication (Loc,
+ Subtype_Mark =>
+ New_Occurrence_Of (RTE (RE_Storage_Array), Loc),
+
+ Constraint =>
+ Make_Index_Or_Discriminant_Constraint (Loc,
+ Constraints => New_List (Make_Range (Loc,
+ Low_Bound => Make_Integer_Literal (Loc, 1),
+ High_Bound => Convert_To (RTE (RE_Storage_Offset),
+ Task_Size)))))));
+
+ Append_To (Cdecls, Decl_Stack);
+
+ -- The appropriate alignment for the stack is ensured by the
+ -- run-time code in charge of task creation.
+
+ end if;
+
-- Add components for entry families
Collect_Entry_Families (Loc, Cdecls, Size_Decl, Tasktyp);
@@ -8381,19 +8429,38 @@ package body Exp_Ch9 is
-- Priority parameter. Set to Unspecified_Priority unless there is a
-- priority pragma, in which case we take the value from the pragma.
- if Present (Tdef)
- and then Has_Priority_Pragma (Tdef)
- then
+ if Present (Tdef) and then Has_Priority_Pragma (Tdef) 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_Reference_To (RTE (RE_Unspecified_Priority), Loc));
end if;
+ -- Optional Stack parameter
+
+ if Restricted_Profile then
+
+ -- If the stack has been preallocated by the expander then
+ -- pass its address. Otherwise, pass a null address.
+
+ if Preallocated_Stacks_On_Target then
+ Append_To (Args,
+ Make_Attribute_Reference (Loc,
+ Prefix => Make_Selected_Component (Loc,
+ Prefix => Make_Identifier (Loc, Name_uInit),
+ Selector_Name =>
+ Make_Identifier (Loc, Name_uStack)),
+ Attribute_Name => Name_Address));
+
+ else
+ Append_To (Args,
+ New_Reference_To (RTE (RE_Null_Address), Loc));
+ end if;
+ end if;
+
-- Size parameter. If no Storage_Size pragma is present, then
-- the size is taken from the taskZ variable for the type, which
-- is either Unspecified_Size, or has been reset by the use of