aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vhdl/translate/trans-chap3.adb10
-rw-r--r--src/vhdl/translate/trans-chap3.ads2
-rw-r--r--src/vhdl/translate/trans-chap4.adb3
-rw-r--r--src/vhdl/translate/trans-chap7.adb37
-rw-r--r--src/vhdl/translate/trans-chap7.ads4
-rw-r--r--src/vhdl/translate/trans-chap8.adb46
-rw-r--r--src/vhdl/translate/trans-chap9.adb2
7 files changed, 62 insertions, 42 deletions
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb
index 3bb10630f..7d2db0b70 100644
--- a/src/vhdl/translate/trans-chap3.adb
+++ b/src/vhdl/translate/trans-chap3.adb
@@ -3121,11 +3121,10 @@ package body Trans.Chap3 is
-- Copy SRC to DEST.
-- Both have the same type, OTYPE.
procedure Translate_Object_Copy (Dest : Mnode;
- Src : O_Enode;
+ Src : Mnode;
Obj_Type : Iir)
is
Info : constant Type_Info_Acc := Get_Info (Obj_Type);
- Kind : constant Object_Kind_Type := Get_Object_Kind (Dest);
D : Mnode;
begin
case Info.Type_Mode is
@@ -3134,18 +3133,19 @@ package body Trans.Chap3 is
| Type_Mode_Bounds_Acc
| Type_Mode_File =>
-- Scalar or thin pointer.
- New_Assign_Stmt (M2Lv (Dest), Src);
+ New_Assign_Stmt (M2Lv (Dest), M2E (Src));
when Type_Mode_Unbounded_Array
| Type_Mode_Unbounded_Record =>
-- a fat array.
D := Stabilize (Dest);
Gen_Memcpy (M2Addr (Get_Composite_Base (D)),
- M2Addr (Get_Composite_Base (E2M (Src, Info, Kind))),
+ M2Addr (Get_Composite_Base (Src)),
Get_Object_Size (D, Obj_Type));
when Type_Mode_Bounded_Arrays
| Type_Mode_Bounded_Records =>
D := Stabilize (Dest);
- Gen_Memcpy (M2Addr (D), Src, Get_Object_Size (D, Obj_Type));
+ Gen_Memcpy (M2Addr (D), M2Addr (Src),
+ Get_Object_Size (D, Obj_Type));
when Type_Mode_Unknown
| Type_Mode_Protected =>
raise Internal_Error;
diff --git a/src/vhdl/translate/trans-chap3.ads b/src/vhdl/translate/trans-chap3.ads
index 783e1ae90..7b5600b9c 100644
--- a/src/vhdl/translate/trans-chap3.ads
+++ b/src/vhdl/translate/trans-chap3.ads
@@ -250,7 +250,7 @@ package Trans.Chap3 is
-- Low level copy of SRC to DEST. Both have the same type, OBJ_TYPE.
-- There is no length check, so arrays must be of the same length.
procedure Translate_Object_Copy
- (Dest : Mnode; Src : O_Enode; Obj_Type : Iir);
+ (Dest : Mnode; Src : Mnode; Obj_Type : Iir);
-- Get size (in bytes with type ghdl_index_type) of subtype ATYPE.
-- For an unconstrained array, BOUNDS must be set, otherwise it may be a
diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb
index 0814f4974..c1599472c 100644
--- a/src/vhdl/translate/trans-chap4.adb
+++ b/src/vhdl/translate/trans-chap4.adb
@@ -542,8 +542,7 @@ package body Trans.Chap4 is
Chap3.Translate_Object_Allocation
(Name_Node, Alloc_Kind, Obj_Type,
Chap3.Get_Composite_Bounds (S));
- Chap3.Translate_Object_Copy
- (Name_Node, M2Addr (S), Obj_Type);
+ Chap3.Translate_Object_Copy (Name_Node, S, Obj_Type);
end if;
end;
else
diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb
index 848c524f3..fbee6e01d 100644
--- a/src/vhdl/translate/trans-chap7.adb
+++ b/src/vhdl/translate/trans-chap7.adb
@@ -1426,7 +1426,7 @@ package body Trans.Chap7 is
New_Obj_Value (Var_Off))));
-- Copy
- Chap3.Translate_Object_Copy (Var_Sub_Arr, M2E (M), Expr_Type);
+ Chap3.Translate_Object_Copy (Var_Sub_Arr, M, Expr_Type);
-- Increase offset
New_Assign_Stmt
@@ -1764,7 +1764,7 @@ package body Trans.Chap7 is
El := Create_Temp (Res_Otype);
Arr := Stabilize (E2M (Translate_Expression (Left),
- Get_Info (Left_Type), Mode_Value));
+ Get_Info (Left_Type), Mode_Value));
Len := Create_Temp_Init
(Ghdl_Index_Type,
M2E (Chap3.Range_To_Length
@@ -2742,22 +2742,22 @@ package body Trans.Chap7 is
declare
T : Mnode;
E : O_Dnode;
+ EM : Mnode;
begin
T := Stabilize (Target);
E := Create_Temp_Init
(T_Info.Ortho_Ptr_Type (Mode_Value), Val);
+ EM := Dp2M (E, T_Info, Mode_Value);
Chap3.Check_Array_Match
- (Target_Type, T,
- Get_Type (Expr), Dp2M (E, T_Info, Mode_Value), Loc);
- Chap3.Translate_Object_Copy
- (T, New_Obj_Value (E), Target_Type);
+ (Target_Type, T, Get_Type (Expr), EM, Loc);
+ Chap3.Translate_Object_Copy (T, EM, Target_Type);
end;
- when Type_Mode_Bounded_Arrays =>
+ when Type_Mode_Bounded_Arrays
+ | Type_Mode_Bounded_Records =>
-- Source is of type TARGET_TYPE, so no length check is
-- necessary.
- Chap3.Translate_Object_Copy (Target, Val, Target_Type);
- when Type_Mode_Bounded_Records =>
- Chap3.Translate_Object_Copy (Target, Val, Target_Type);
+ Chap3.Translate_Object_Copy
+ (Target, E2M (Val, T_Info, Mode_Value), Target_Type);
when Type_Mode_Unbounded_Record =>
-- TODO
raise Internal_Error;
@@ -3516,7 +3516,8 @@ package body Trans.Chap7 is
D_Info, Mode_Value);
Chap3.Translate_Object_Allocation
(R, Alloc_Heap, D_Type, Mnode_Null);
- Chap3.Translate_Object_Copy (R, Val, D_Type);
+ Chap3.Translate_Object_Copy
+ (R, E2M (Val, D_Info, Mode_Value), D_Type);
return New_Convert_Ov (M2Addr (R), A_Info.Ortho_Type (Mode_Value));
when others =>
raise Internal_Error;
@@ -3919,6 +3920,20 @@ package body Trans.Chap7 is
end Translate_Overflow_Literal;
function Translate_Expression (Expr : Iir; Rtype : Iir := Null_Iir)
+ return Mnode
+ is
+ Res_Type : Iir;
+ begin
+ if Rtype = Null_Iir then
+ Res_Type := Get_Type (Expr);
+ else
+ Res_Type := Rtype;
+ end if;
+ return E2M (Translate_Expression (Expr, Res_Type),
+ Get_Info (Res_Type), Mode_Value);
+ end Translate_Expression;
+
+ function Translate_Expression (Expr : Iir; Rtype : Iir := Null_Iir)
return O_Enode
is
Imp : Iir;
diff --git a/src/vhdl/translate/trans-chap7.ads b/src/vhdl/translate/trans-chap7.ads
index 7cb5662b2..18b849de4 100644
--- a/src/vhdl/translate/trans-chap7.ads
+++ b/src/vhdl/translate/trans-chap7.ads
@@ -33,7 +33,9 @@ package Trans.Chap7 is
-- Translate expression EXPR into ortho tree.
function Translate_Expression (Expr : Iir; Rtype : Iir := Null_Iir)
- return O_Enode;
+ return O_Enode;
+ function Translate_Expression (Expr : Iir; Rtype : Iir := Null_Iir)
+ return Mnode;
-- Translate range and return an lvalue containing the range.
-- The node returned can be used only one time.
diff --git a/src/vhdl/translate/trans-chap8.adb b/src/vhdl/translate/trans-chap8.adb
index 490a104bc..705617ac7 100644
--- a/src/vhdl/translate/trans-chap8.adb
+++ b/src/vhdl/translate/trans-chap8.adb
@@ -254,13 +254,11 @@ package body Trans.Chap8 is
begin
Area := Dp2M (Subprg_Info.Res_Interface,
Ret_Info, Mode_Value);
- Val := Stabilize
- (E2M (Chap7.Translate_Expression (Expr, Ret_Type),
- Ret_Info, Mode_Value));
+ Val := Stabilize (Chap7.Translate_Expression (Expr, Ret_Type));
Chap3.Translate_Object_Allocation
(Area, Alloc_Return, Ret_Type,
Chap3.Get_Composite_Bounds (Val));
- Chap3.Translate_Object_Copy (Area, M2Addr (Val), Ret_Type);
+ Chap3.Translate_Object_Copy (Area, Val, Ret_Type);
Gen_Return;
end;
when Type_Mode_Bounded_Records
@@ -955,7 +953,7 @@ package body Trans.Chap8 is
Targ_Node : Mnode;
begin
Targ_Node := Chap6.Translate_Name (Targ, Mode_Value);
- Chap3.Translate_Object_Copy (Targ_Node, M2E (Val), Targ_Type);
+ Chap3.Translate_Object_Copy (Targ_Node, Val, Targ_Type);
end;
end if;
end Translate_Variable_Aggregate_Assignment;
@@ -970,7 +968,7 @@ package body Trans.Chap8 is
begin
if Get_Kind (Target) = Iir_Kind_Aggregate then
declare
- E : O_Enode;
+ E : Mnode;
Temp : Mnode;
begin
Chap3.Translate_Anonymous_Subtype_Definition (Targ_Type, False);
@@ -1007,13 +1005,12 @@ package body Trans.Chap8 is
-- Translate aggregate
Chap7.Translate_Aggregate (Val, Targ_Type, Expr);
-- Assign
- Chap3.Translate_Object_Copy
- (Targ_Node, M2Addr (Val), Targ_Type);
+ Chap3.Translate_Object_Copy (Targ_Node, Val, Targ_Type);
end;
else
-- In case of overlap: be sure to use an intermediate variable.
declare
- E : O_Enode;
+ E : Mnode;
begin
E := Chap7.Translate_Expression (Expr, Targ_Type);
Chap3.Translate_Object_Copy (Targ_Node, E, Targ_Type);
@@ -2631,8 +2628,7 @@ package body Trans.Chap8 is
-- Individual association: assign the individual actual of
-- the whole actual.
- procedure Trans_Individual_Assign
- (Assoc : Iir; Val : O_Enode; Sig : O_Enode)
+ procedure Trans_Individual_Assign (Assoc : Iir; Val : Mnode; Sig : Mnode)
is
Formal : constant Iir := Get_Formal (Assoc);
Formal_Type : constant Iir := Get_Type (Formal);
@@ -2648,7 +2644,7 @@ package body Trans.Chap8 is
(Formal, Formal_Info, Params (Last_Individual),
Formal_Object_Kind);
if Formal_Object_Kind = Mode_Value then
- Chap7.Translate_Assign (Param, Val, Act, Formal_Type, Assoc);
+ Chap7.Translate_Assign (Param, M2E (Val), Act, Formal_Type, Assoc);
else
Chap3.Translate_Object_Copy (Param, Sig, Formal_Type);
if Is_Suspendable then
@@ -2657,7 +2653,7 @@ package body Trans.Chap8 is
Assoc_Info := Get_Info (Assoc);
New_Assign_Stmt
(Get_Var (Assoc_Info.Call_Assoc_Value (Mode_Value)),
- Val);
+ M2E (Val));
else
-- Assign the value to the whole object, as there is
-- only one call.
@@ -2692,6 +2688,7 @@ package body Trans.Chap8 is
Val : O_Enode;
Sig : O_Enode;
Mval : Mnode;
+ Msig : Mnode;
Mode : Iir_Mode;
Bounds : Mnode;
Next_Assoc : Iir;
@@ -2965,11 +2962,10 @@ package body Trans.Chap8 is
Next_Assoc := Get_Chain (Next_Assoc);
if Formal_Object_Kind = Mode_Signal then
Trans_Individual_Assign
- (Next_Assoc,
- M2E (Saved_Val (I)), M2E (Saved_Sig (I)));
+ (Next_Assoc, Saved_Val (I), Saved_Sig (I));
else
Trans_Individual_Assign
- (Next_Assoc, M2E (Saved_Val (I)), O_Enode_Null);
+ (Next_Assoc, Saved_Val (I), Mnode_Null);
end if;
end loop;
@@ -2979,7 +2975,13 @@ package body Trans.Chap8 is
else
-- Individual association: assign the individual actual of
-- the whole actual.
- Trans_Individual_Assign (Assoc, Val, Sig);
+ if Sig = O_Enode_Null then
+ Msig := Mnode_Null;
+ else
+ Msig := E2M (Sig, Get_Info (Formal_Type), Mode_Signal);
+ end if;
+ Trans_Individual_Assign
+ (Assoc, E2M (Val, Get_Info (Formal_Type), Mode_Value), Msig);
end if;
elsif Assoc_Info /= null then
-- For suspendable caller, write the actual to the state
@@ -3060,8 +3062,7 @@ package body Trans.Chap8 is
(Formal_Type, Alloc_Return, Param);
Assign_Params_Field (M2Addr (Param), Mode);
end if;
- Chap3.Translate_Object_Copy
- (Param, M2E (Mval), Formal_Type);
+ Chap3.Translate_Object_Copy (Param, Mval, Formal_Type);
end if;
end;
end loop;
@@ -3083,7 +3084,10 @@ package body Trans.Chap8 is
-- Not for signals.
pragma Assert (Sig = O_Enode_Null);
- Chap3.Translate_Object_Copy (Inout_Params (Pos), Val, Formal_Type);
+ Chap3.Translate_Object_Copy
+ (Inout_Params (Pos),
+ E2M (Val, Get_Info (Formal_Type), Mode_Value),
+ Formal_Type);
E_Params (Pos) := M2Addr (Inout_Params (Pos));
else
E_Params (Pos) := Val;
@@ -4070,7 +4074,7 @@ package body Trans.Chap8 is
end;
else
Src := Chap6.Translate_Name (Target, Mode_Signal);
- Chap3.Translate_Object_Copy (Aggr, M2E (Src), Target_Type);
+ Chap3.Translate_Object_Copy (Aggr, Src, Target_Type);
end if;
end Translate_Signal_Target_Aggr;
diff --git a/src/vhdl/translate/trans-chap9.adb b/src/vhdl/translate/trans-chap9.adb
index 1fbd4e8e6..eb4668f7b 100644
--- a/src/vhdl/translate/trans-chap9.adb
+++ b/src/vhdl/translate/trans-chap9.adb
@@ -1701,7 +1701,7 @@ package body Trans.Chap9 is
-- From the port default value.
if Is_Valid (Get_Default_Value (Base)) then
Chap3.Translate_Object_Copy
- (Drv_Node, M2E (Chap6.Get_Port_Init_Value (Base)),
+ (Drv_Node, Chap6.Get_Port_Init_Value (Base),
Base_Type);
else
Chap4.Init_Object (Drv_Node, Base_Type);