Commit eaed0c37 by Arnaud Charlet

[multiple changes]

2011-09-06  Ed Schonberg  <schonberg@adacore.com>

	* 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  <kirtchev@adacore.com>

	* 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.

From-SVN: r178570
parent b8a93198
2011-09-06 Ed Schonberg <schonberg@adacore.com>
* 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 <kirtchev@adacore.com>
* 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 <baird@adacore.com> 2011-09-06 Steve Baird <baird@adacore.com>
* einfo.ads (Extra_Accessibility): Update associated comment to use * einfo.ads (Extra_Accessibility): Update associated comment to use
......
...@@ -4149,14 +4149,13 @@ package body Exp_Ch4 is ...@@ -4149,14 +4149,13 @@ package body Exp_Ch4 is
Alt := First (Alternatives (N)); Alt := First (Alternatives (N));
while Present (Alt) loop while Present (Alt) loop
declare declare
Aexp : Node_Id := Expression (Alt); Aexp : Node_Id := Expression (Alt);
Aloc : constant Source_Ptr := Sloc (Aexp); Aloc : constant Source_Ptr := Sloc (Aexp);
Stats : List_Id;
begin begin
-- Propagate declarations inserted in the node by Insert_Actions -- As described above, take Unrestricted_Access for case of non-
-- (for example, temporaries generated to remove side effects). -- scalar types, to avoid big copies, and special cases.
Append_List_To (Actions, Sinfo.Actions (Alt));
if not Is_Scalar_Type (Typ) then if not Is_Scalar_Type (Typ) then
Aexp := Aexp :=
...@@ -4165,14 +4164,25 @@ package body Exp_Ch4 is ...@@ -4165,14 +4164,25 @@ package body Exp_Ch4 is
Attribute_Name => Name_Unrestricted_Access); Attribute_Name => Name_Unrestricted_Access);
end if; 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 Append_To
(Alternatives (Cstmt), (Alternatives (Cstmt),
Make_Case_Statement_Alternative (Sloc (Alt), Make_Case_Statement_Alternative (Sloc (Alt),
Discrete_Choices => Discrete_Choices (Alt), Discrete_Choices => Discrete_Choices (Alt),
Statements => New_List ( Statements => Stats));
Make_Assignment_Statement (Aloc,
Name => New_Occurrence_Of (Tnn, Loc),
Expression => Aexp))));
end; end;
Next (Alt); Next (Alt);
......
...@@ -41,7 +41,6 @@ with Exp_Disp; use Exp_Disp; ...@@ -41,7 +41,6 @@ with Exp_Disp; use Exp_Disp;
with Exp_Tss; use Exp_Tss; with Exp_Tss; use Exp_Tss;
with Exp_Util; use Exp_Util; with Exp_Util; use Exp_Util;
with Freeze; use Freeze; with Freeze; use Freeze;
with Get_Targ; use Get_Targ;
with Lib; use Lib; with Lib; use Lib;
with Nlists; use Nlists; with Nlists; use Nlists;
with Nmake; use Nmake; with Nmake; use Nmake;
...@@ -1808,10 +1807,10 @@ package body Exp_Ch7 is ...@@ -1808,10 +1807,10 @@ package body Exp_Ch7 is
(Available_View (Designated_Type (Obj_Typ))) (Available_View (Designated_Type (Obj_Typ)))
and then Present (Expr) and then Present (Expr)
and then and then
(Is_Null_Access_BIP_Func_Call (Expr) (Is_Null_Access_BIP_Func_Call (Expr)
or else (Is_Non_BIP_Func_Call (Expr) or else
and then not (Is_Non_BIP_Func_Call (Expr)
Is_Related_To_Func_Return (Obj_Id))) and then not Is_Related_To_Func_Return (Obj_Id)))
then then
Processing_Actions (Has_No_Init => True); Processing_Actions (Has_No_Init => True);
...@@ -7039,10 +7038,15 @@ package body Exp_Ch7 is ...@@ -7039,10 +7038,15 @@ package body Exp_Ch7 is
-- --
-- Typ'Alignment -- 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: -- Subsidiary routine, generate the following expression:
-- --
-- 2 * Typ'Alignment -- 2 * Typ'Size / Storage_Unit
------------------ ------------------
-- Alignment_Of -- -- Alignment_Of --
...@@ -7050,31 +7054,39 @@ package body Exp_Ch7 is ...@@ -7050,31 +7054,39 @@ package body Exp_Ch7 is
function Alignment_Of (Typ : Entity_Id) return Node_Id is function Alignment_Of (Typ : Entity_Id) return Node_Id is
begin begin
-- Strict alignment targets such as SPARC ignore the alignment of the return
-- index type and use the system allocator alignment instead. 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 function Size_Of (Typ : Entity_Id) return Node_Id is
return begin
Make_Attribute_Reference (Loc, return
Prefix => New_Reference_To (Typ, Loc), Make_Op_Divide (Loc,
Attribute_Name => Name_Alignment); Left_Opnd =>
end if; Make_Attribute_Reference (Loc,
end Alignment_Of; 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 begin
return return
Make_Op_Multiply (Loc, Make_Op_Multiply (Loc,
Left_Opnd => Make_Integer_Literal (Loc, 2), Left_Opnd => Make_Integer_Literal (Loc, 2),
Right_Opnd => Alignment_Of (Typ)); Right_Opnd => Size_Of (Typ));
end Double_Alignment_Of; end Double_Size_Of;
-- Start of processing for Make_Finalize_Address_Stmts -- Start of processing for Make_Finalize_Address_Stmts
...@@ -7183,28 +7195,31 @@ package body Exp_Ch7 is ...@@ -7183,28 +7195,31 @@ package body Exp_Ch7 is
For_First := False; For_First := False;
-- Generate: -- 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 else
-- Generate: -- Generate:
-- Dope_Expr + 2 * Index_Typ'Alignment -- Dope_Expr + 2 * Index_Typ'Size / Storage_Unit
Dope_Expr := Dope_Expr :=
Make_Op_Add (Loc, Make_Op_Add (Loc,
Left_Opnd => Dope_Expr, Left_Opnd => Dope_Expr,
Right_Opnd => Double_Alignment_Of (Index_Typ)); Right_Opnd => Double_Size_Of (Index_Typ));
end if; end if;
Next_Index (Index); Next_Index (Index);
end loop; end loop;
-- Round the cumulative alignment to the next higher multiple of -- Dope_Expr calculates the optimum size of the dope, as if the
-- the array alignment. Generate: -- 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) -- ((Dope_Expr + Typ'Alignment - 1) / Typ'Alignment) *
-- * Typ'Alignment -- Typ'Alignment
Dope_Expr := Dope_Expr :=
Make_Op_Multiply (Loc, Make_Op_Multiply (Loc,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment