aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/translate
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2017-02-17 06:55:21 +0100
committerTristan Gingold <tgingold@free.fr>2017-02-17 22:09:54 +0100
commit6ca409f3359d31ddd2815f5bf42973901923c59d (patch)
treeb2e6a14b0c1cbeebec04848909f75355f74769f4 /src/vhdl/translate
parentd5b802ac3d13375378c3ef66ea178a803d5e33b3 (diff)
downloadghdl-6ca409f3359d31ddd2815f5bf42973901923c59d.tar.gz
ghdl-6ca409f3359d31ddd2815f5bf42973901923c59d.tar.bz2
ghdl-6ca409f3359d31ddd2815f5bf42973901923c59d.zip
vhdl08: unbounded records - WIP
Diffstat (limited to 'src/vhdl/translate')
-rw-r--r--src/vhdl/translate/trans-chap4.adb9
-rw-r--r--src/vhdl/translate/trans-chap7.adb28
-rw-r--r--src/vhdl/translate/trans-chap8.adb2
-rw-r--r--src/vhdl/translate/trans-foreach_non_composite.adb9
4 files changed, 28 insertions, 20 deletions
diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb
index 669f83d25..142b8c7a0 100644
--- a/src/vhdl/translate/trans-chap4.adb
+++ b/src/vhdl/translate/trans-chap4.adb
@@ -44,7 +44,8 @@ package body Trans.Chap4 is
begin
if Is_Complex_Type (Tinfo) then
case Tinfo.Type_Mode is
- when Type_Mode_Fat_Array =>
+ when Type_Mode_Unbounded_Array
+ | Type_Mode_Unbounded_Record =>
return Tinfo.Ortho_Type (Kind);
when Type_Mode_Record
| Type_Mode_Array
@@ -302,7 +303,7 @@ package body Trans.Chap4 is
Targ : Mnode;
begin
-- Cannot allocate unconstrained object (since size is unknown).
- pragma Assert (Type_Info.Type_Mode /= Type_Mode_Fat_Array);
+ pragma Assert (Type_Info.Type_Mode not in Type_Mode_Unbounded);
if not Is_Complex_Type (Type_Info) then
-- Object is not complex.
@@ -487,7 +488,7 @@ package body Trans.Chap4 is
end if;
if Is_Complex_Type (Type_Info)
- and then Type_Info.Type_Mode /= Type_Mode_Fat_Array
+ and then Type_Info.Type_Mode not in Type_Mode_Unbounded
then
-- FIXME: avoid allocation if the value is a string and
-- the object is a constant
@@ -541,7 +542,7 @@ package body Trans.Chap4 is
else
Value_Node := Chap7.Translate_Expression (Value, Obj_Type);
- if Type_Info.Type_Mode = Type_Mode_Fat_Array then
+ if Type_Info.Type_Mode in Type_Mode_Unbounded then
declare
S : Mnode;
begin
diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb
index 5102e4cb3..3c597f12c 100644
--- a/src/vhdl/translate/trans-chap7.adb
+++ b/src/vhdl/translate/trans-chap7.adb
@@ -769,7 +769,7 @@ package body Trans.Chap7 is
end Convert_Constrained_To_Unconstrained;
-- Innert procedure for Convert_Unconstrained_To_Constrained.
- procedure Convert_Unconstrained_To_Constrained_Check
+ procedure Convert_To_Constrained_Check
(Bounds : Mnode; Expr_Type : Iir; Atype : Iir; Failure_Label : O_Snode)
is
Stable_Bounds : Mnode;
@@ -813,7 +813,7 @@ package body Trans.Chap7 is
Expr_El_Type := Get_Type (Expr_El);
Atype_El_Type := Get_Type (Atype_El);
if Expr_El_Type /= Atype_El_Type then
- Convert_Unconstrained_To_Constrained_Check
+ Convert_To_Constrained_Check
(Chap3.Bounds_To_Element_Bounds
(Stable_Bounds, Expr_El),
Expr_El_Type, Atype_El_Type, Failure_Label);
@@ -825,9 +825,9 @@ package body Trans.Chap7 is
Expr_Type);
end case;
Close_Temp;
- end Convert_Unconstrained_To_Constrained_Check;
+ end Convert_To_Constrained_Check;
- function Convert_Unconstrained_To_Constrained
+ function Convert_To_Constrained
(Expr : Mnode; Expr_Type : Iir; Atype : Iir; Loc : Iir) return Mnode
is
Expr_Stable : Mnode;
@@ -841,7 +841,7 @@ package body Trans.Chap7 is
Start_Loop_Stmt (Success_Label);
Start_Loop_Stmt (Failure_Label);
- Convert_Unconstrained_To_Constrained_Check
+ Convert_To_Constrained_Check
(Chap3.Get_Array_Bounds (Expr_Stable), Expr_Type,
Atype, Failure_Label);
@@ -852,8 +852,18 @@ package body Trans.Chap7 is
Finish_Loop_Stmt (Success_Label);
Close_Temp;
- return Chap3.Get_Composite_Base (Expr_Stable);
- end Convert_Unconstrained_To_Constrained;
+ declare
+ Ainfo : constant Type_Info_Acc := Get_Info (Atype);
+ Kind : constant Object_Kind_Type := Get_Object_Kind (Expr);
+ Nptr : O_Enode;
+ begin
+ -- Pointer to the array.
+ Nptr := M2E (Chap3.Get_Composite_Base (Expr_Stable));
+ -- Convert it to pointer to the constrained type.
+ Nptr := New_Convert_Ov (Nptr, Ainfo.Ortho_Ptr_Type (Kind));
+ return E2M (Nptr, Ainfo, Kind);
+ end;
+ end Convert_To_Constrained;
function Translate_Implicit_Array_Conversion
(Expr : Mnode; Expr_Type : Iir; Res_Type : Iir; Loc : Iir) return Mnode
@@ -899,7 +909,7 @@ package body Trans.Chap7 is
return Expr;
else
-- Unbounded/bounded array to bounded array.
- return Convert_Unconstrained_To_Constrained
+ return Convert_To_Constrained
(Expr, Expr_Type, Res_Type, Loc);
end if;
when others =>
@@ -937,7 +947,7 @@ package body Trans.Chap7 is
case Einfo.Type_Mode is
when Type_Mode_Unbounded_Record =>
-- unbounded to bounded.
- return Convert_Unconstrained_To_Constrained
+ return Convert_To_Constrained
(Expr, Expr_Type, Res_Type, Loc);
when Type_Mode_Record =>
-- bounded to bounded.
diff --git a/src/vhdl/translate/trans-chap8.adb b/src/vhdl/translate/trans-chap8.adb
index 9fdb5852e..d37b2bad1 100644
--- a/src/vhdl/translate/trans-chap8.adb
+++ b/src/vhdl/translate/trans-chap8.adb
@@ -2564,7 +2564,7 @@ package body Trans.Chap8 is
Res_Info : constant Type_Info_Acc := Get_Info (Res_Type);
begin
Res := Create_Temp (Res_Info);
- if Res_Info.Type_Mode /= Type_Mode_Fat_Array then
+ if Res_Info.Type_Mode not in Type_Mode_Unbounded then
Chap4.Allocate_Complex_Object (Res_Type, Alloc_Stack, Res);
end if;
end;
diff --git a/src/vhdl/translate/trans-foreach_non_composite.adb b/src/vhdl/translate/trans-foreach_non_composite.adb
index 15a21a059..91e90fb5e 100644
--- a/src/vhdl/translate/trans-foreach_non_composite.adb
+++ b/src/vhdl/translate/trans-foreach_non_composite.adb
@@ -26,9 +26,8 @@ procedure Trans.Foreach_Non_Composite (Targ : Mnode;
is
use Trans.Helpers;
- Type_Info : Type_Info_Acc;
+ Type_Info : constant Type_Info_Acc := Get_Info (Targ_Type);
begin
- Type_Info := Get_Info (Targ_Type);
case Type_Info.Type_Mode is
when Type_Mode_Scalar =>
Do_Non_Composite (Targ, Targ_Type, Data);
@@ -89,13 +88,11 @@ begin
Var_Record := Stabilize (Targ);
Composite_Data :=
Prepare_Data_Record (Var_Record, Targ_Type, Data);
- List := Get_Elements_Declaration_List
- (Get_Base_Type (Targ_Type));
+ List := Get_Elements_Declaration_List (Targ_Type);
for I in Natural loop
El := Get_Nth_Element (List, I);
exit when El = Null_Iir;
- Sub_Data := Update_Data_Record
- (Composite_Data, Targ_Type, El);
+ Sub_Data := Update_Data_Record (Composite_Data, Targ_Type, El);
Foreach_Non_Composite
(Chap6.Translate_Selected_Element (Var_Record, El),
Get_Type (El),