aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2011-09-06 10:07:27 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2011-09-06 10:07:27 +0200
commiteaed0c37779f8cf403921cda1f63d14c1f14a914 (patch)
tree5e667f993d72f235c5c58d8362da36397fa74144 /gcc
parentb8a93198c2286edd6954930696ff8c1a6607785b (diff)
downloadgcc-eaed0c37779f8cf403921cda1f63d14c1f14a914.zip
gcc-eaed0c37779f8cf403921cda1f63d14c1f14a914.tar.gz
gcc-eaed0c37779f8cf403921cda1f63d14c1f14a914.tar.bz2
[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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog19
-rw-r--r--gcc/ada/exp_ch4.adb30
-rw-r--r--gcc/ada/exp_ch7.adb79
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 <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>
* 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,