From cb39358d2032fa3f6d5a4957e416ee0e20401710 Mon Sep 17 00:00:00 2001 From: charlet Date: Tue, 6 Sep 2011 08:07:27 +0000 Subject: [PATCH] 2011-09-06 Ed Schonberg * exp_ch4.adb (Expand_N_Case_Expression): Actions created for the expression in a given case alternative must be attached to the statement list of the ccrresponding case statement alternative They cannot be propagated ahead of the case statement, because the validity of the expression that generated the action may hold only for that alternative. 2011-09-06 Hristian Kirtchev * exp_ch7.adb: Remove with and use clauses for Get_Targ. (Alignment_Of): Remove the code for strict alignment targets. (Double_Alignment_Of): Removed. (Double_Size_Of): New routine. (Make_Finalize_Address_Stmts): Change the calculation of the dope's size. Update relevant comments. (Size_Of): New routine. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178570 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/ChangeLog | 19 +++++++++++++ gcc/ada/exp_ch4.adb | 30 +++++++++++++------- gcc/ada/exp_ch7.adb | 79 +++++++++++++++++++++++++++++++---------------------- 3 files changed, 86 insertions(+), 42 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index b887ead..bb3a5b6 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,22 @@ +2011-09-06 Ed Schonberg + + * exp_ch4.adb (Expand_N_Case_Expression): Actions created for the + expression in a given case alternative must be attached to the + statement list of the ccrresponding case statement alternative + They cannot be propagated ahead of the case statement, because + the validity of the expression that generated the action may + hold only for that alternative. + +2011-09-06 Hristian Kirtchev + + * exp_ch7.adb: Remove with and use clauses for Get_Targ. + (Alignment_Of): Remove the code for strict alignment targets. + (Double_Alignment_Of): Removed. + (Double_Size_Of): New routine. + (Make_Finalize_Address_Stmts): Change the + calculation of the dope's size. Update relevant comments. + (Size_Of): New routine. + 2011-09-06 Steve Baird * einfo.ads (Extra_Accessibility): Update associated comment to use diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 2b9ab01..8555883 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -4149,14 +4149,13 @@ package body Exp_Ch4 is Alt := First (Alternatives (N)); while Present (Alt) loop declare - Aexp : Node_Id := Expression (Alt); - Aloc : constant Source_Ptr := Sloc (Aexp); + Aexp : Node_Id := Expression (Alt); + Aloc : constant Source_Ptr := Sloc (Aexp); + Stats : List_Id; begin - -- Propagate declarations inserted in the node by Insert_Actions - -- (for example, temporaries generated to remove side effects). - - Append_List_To (Actions, Sinfo.Actions (Alt)); + -- As described above, take Unrestricted_Access for case of non- + -- scalar types, to avoid big copies, and special cases. if not Is_Scalar_Type (Typ) then Aexp := @@ -4165,14 +4164,25 @@ package body Exp_Ch4 is Attribute_Name => Name_Unrestricted_Access); end if; + Stats := New_List ( + Make_Assignment_Statement (Aloc, + Name => New_Occurrence_Of (Tnn, Loc), + Expression => Aexp)); + + -- Propagate declarations inserted in the node by Insert_Actions + -- (for example, temporaries generated to remove side effects). + -- These actions must remain attached to the alternative, given + -- that they are generated by the corresponding expression. + + if Present (Sinfo.Actions (Alt)) then + Prepend_List (Sinfo.Actions (Alt), Stats); + end if; + Append_To (Alternatives (Cstmt), Make_Case_Statement_Alternative (Sloc (Alt), Discrete_Choices => Discrete_Choices (Alt), - Statements => New_List ( - Make_Assignment_Statement (Aloc, - Name => New_Occurrence_Of (Tnn, Loc), - Expression => Aexp)))); + Statements => Stats)); end; Next (Alt); diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index eebb79d..6975f3e 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -41,7 +41,6 @@ with Exp_Disp; use Exp_Disp; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Freeze; use Freeze; -with Get_Targ; use Get_Targ; with Lib; use Lib; with Nlists; use Nlists; with Nmake; use Nmake; @@ -1808,10 +1807,10 @@ package body Exp_Ch7 is (Available_View (Designated_Type (Obj_Typ))) and then Present (Expr) and then - (Is_Null_Access_BIP_Func_Call (Expr) - or else (Is_Non_BIP_Func_Call (Expr) - and then not - Is_Related_To_Func_Return (Obj_Id))) + (Is_Null_Access_BIP_Func_Call (Expr) + or else + (Is_Non_BIP_Func_Call (Expr) + and then not Is_Related_To_Func_Return (Obj_Id))) then Processing_Actions (Has_No_Init => True); @@ -7039,10 +7038,15 @@ package body Exp_Ch7 is -- -- Typ'Alignment - function Double_Alignment_Of (Typ : Entity_Id) return Node_Id; + function Size_Of (Typ : Entity_Id) return Node_Id; + -- Subsidiary routine, generate the following attribute reference: + -- + -- Typ'Size / Storage_Unit + + function Double_Size_Of (Typ : Entity_Id) return Node_Id; -- Subsidiary routine, generate the following expression: -- - -- 2 * Typ'Alignment + -- 2 * Typ'Size / Storage_Unit ------------------ -- Alignment_Of -- @@ -7050,31 +7054,39 @@ package body Exp_Ch7 is function Alignment_Of (Typ : Entity_Id) return Node_Id is begin - -- Strict alignment targets such as SPARC ignore the alignment of the - -- index type and use the system allocator alignment instead. + return + Make_Attribute_Reference (Loc, + Prefix => New_Reference_To (Typ, Loc), + Attribute_Name => Name_Alignment); + end Alignment_Of; - if Target_Strict_Alignment then - return Make_Integer_Literal (Loc, Get_System_Allocator_Alignment); + ------------- + -- Size_Of -- + ------------- - else - return - Make_Attribute_Reference (Loc, - Prefix => New_Reference_To (Typ, Loc), - Attribute_Name => Name_Alignment); - end if; - end Alignment_Of; + function Size_Of (Typ : Entity_Id) return Node_Id is + begin + return + Make_Op_Divide (Loc, + Left_Opnd => + Make_Attribute_Reference (Loc, + Prefix => New_Reference_To (Typ, Loc), + Attribute_Name => Name_Size), + Right_Opnd => + Make_Integer_Literal (Loc, System_Storage_Unit)); + end Size_Of; - ------------------------- - -- Double_Alignment_Of -- - ------------------------- + -------------------- + -- Double_Size_Of -- + -------------------- - function Double_Alignment_Of (Typ : Entity_Id) return Node_Id is + function Double_Size_Of (Typ : Entity_Id) return Node_Id is begin return Make_Op_Multiply (Loc, Left_Opnd => Make_Integer_Literal (Loc, 2), - Right_Opnd => Alignment_Of (Typ)); - end Double_Alignment_Of; + Right_Opnd => Size_Of (Typ)); + end Double_Size_Of; -- Start of processing for Make_Finalize_Address_Stmts @@ -7183,28 +7195,31 @@ package body Exp_Ch7 is For_First := False; -- Generate: - -- 2 * Index_Typ'Alignment + -- 2 * Index_Typ'Size / Storage_Unit - Dope_Expr := Double_Alignment_Of (Index_Typ); + Dope_Expr := Double_Size_Of (Index_Typ); else -- Generate: - -- Dope_Expr + 2 * Index_Typ'Alignment + -- Dope_Expr + 2 * Index_Typ'Size / Storage_Unit Dope_Expr := Make_Op_Add (Loc, Left_Opnd => Dope_Expr, - Right_Opnd => Double_Alignment_Of (Index_Typ)); + Right_Opnd => Double_Size_Of (Index_Typ)); end if; Next_Index (Index); end loop; - -- Round the cumulative alignment to the next higher multiple of - -- the array alignment. Generate: + -- Dope_Expr calculates the optimum size of the dope, as if the + -- dope was "packed". Since the alignment of the component type + -- dictates the underlying layout of the array, round the size + -- of the dope to the next higher multiple of the component + -- alignment. Generate: - -- ((Dope_Expr + Typ'Alignment - 1) / Typ'Alignment) - -- * Typ'Alignment + -- ((Dope_Expr + Typ'Alignment - 1) / Typ'Alignment) * + -- Typ'Alignment Dope_Expr := Make_Op_Multiply (Loc, -- 2.7.4