aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl
diff options
context:
space:
mode:
Diffstat (limited to 'src/vhdl')
-rw-r--r--src/vhdl/translate/trans-chap1.adb9
-rw-r--r--src/vhdl/translate/trans-chap3.adb20
-rw-r--r--src/vhdl/translate/trans-chap7.adb104
-rw-r--r--src/vhdl/translate/trans-chap7.ads11
-rw-r--r--src/vhdl/translate/trans.adb1
5 files changed, 64 insertions, 81 deletions
diff --git a/src/vhdl/translate/trans-chap1.adb b/src/vhdl/translate/trans-chap1.adb
index 38bfba695..40d6fce45 100644
--- a/src/vhdl/translate/trans-chap1.adb
+++ b/src/vhdl/translate/trans-chap1.adb
@@ -651,7 +651,6 @@ package body Trans.Chap1 is
declare
Rng : Mnode;
Slice : O_Dnode;
- Slice_Ptr : O_Dnode;
Left, Right : O_Dnode;
Index : O_Dnode;
High : O_Dnode;
@@ -661,10 +660,10 @@ package body Trans.Chap1 is
Open_Temp;
Rng := Stabilize (Chap3.Type_To_Range (Iter_Type));
Slice := Create_Temp (Type_Info.T.Range_Type);
- Slice_Ptr := Create_Temp_Ptr
- (Type_Info.T.Range_Ptr_Type, New_Obj (Slice));
- Chap7.Translate_Discrete_Range_Ptr
- (Slice_Ptr, Get_Suffix (Spec));
+ Chap7.Translate_Discrete_Range
+ (Dv2M (Slice, Type_Info, Mode_Value,
+ Type_Info.T.Range_Type, Type_Info.T.Range_Ptr_Type),
+ Get_Suffix (Spec));
Left := Create_Temp_Init
(Ghdl_Index_Type,
Chap6.Translate_Index_To_Offset
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb
index 5afbd0a9b..7b0c7a459 100644
--- a/src/vhdl/translate/trans-chap3.adb
+++ b/src/vhdl/translate/trans-chap3.adb
@@ -971,8 +971,11 @@ package body Trans.Chap3 is
D := Create_Temp_Ptr
(Index_Info.T.Range_Ptr_Type,
New_Selected_Element (M2Lv (Targ),
- Base_Index_Info.Index_Field));
- Chap7.Translate_Discrete_Range_Ptr (D, Index);
+ Base_Index_Info.Index_Field));
+ Chap7.Translate_Discrete_Range
+ (Dp2M (D, Index_Info, Mode_Value,
+ Index_Info.T.Range_Type, Index_Info.T.Range_Ptr_Type),
+ Index);
Close_Temp;
end;
end loop;
@@ -1661,15 +1664,12 @@ package body Trans.Chap3 is
-- Create a type_range structure.
procedure Create_Scalar_Type_Range (Def : Iir; Target : O_Lnode)
is
- Base_Type : constant Iir := Get_Base_Type (Def);
- T_Info : constant Type_Info_Acc := Get_Info (Base_Type);
- Expr : constant Iir := Get_Range_Constraint (Def);
- V : O_Dnode;
+ T_Info : constant Type_Info_Acc := Get_Info (Get_Base_Type (Def));
begin
- Open_Temp;
- V := Create_Temp_Ptr (T_Info.T.Range_Ptr_Type, Target);
- Chap7.Translate_Range_Ptr (V, Expr, Def);
- Close_Temp;
+ Chap7.Translate_Range
+ (Lv2M (Target, T_Info, Mode_Value,
+ T_Info.T.Range_Type, T_Info.T.Range_Ptr_Type),
+ Get_Range_Constraint (Def), Def);
end Create_Scalar_Type_Range;
function Create_Static_Scalar_Type_Range (Def : Iir) return O_Cnode is
diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb
index 858d5a94c..7c8ee261f 100644
--- a/src/vhdl/translate/trans-chap7.adb
+++ b/src/vhdl/translate/trans-chap7.adb
@@ -2778,34 +2778,26 @@ package body Trans.Chap7 is
-- Dynamic range, must evaluate it.
Open_Temp;
declare
- A_Range : O_Dnode;
- Rng_Ptr : O_Dnode;
+ A_Range : Mnode;
begin
-- Evaluate the range.
Chap3.Translate_Anonymous_Type_Definition
(Subaggr_Type, True);
- A_Range := Create_Temp (Rinfo.T.Range_Type);
- Rng_Ptr := Create_Temp_Ptr
- (Rinfo.T.Range_Ptr_Type, New_Obj (A_Range));
- Chap7.Translate_Range_Ptr
- (Rng_Ptr,
- Get_Range_Constraint (Subaggr_Type),
- Subaggr_Type);
+ A_Range :=
+ Dv2M (Create_Temp (Rinfo.T.Range_Type), Rinfo, Mode_Value,
+ Rinfo.T.Range_Type, Rinfo.T.Range_Ptr_Type);
+ Chap7.Translate_Range
+ (A_Range, Get_Range_Constraint (Subaggr_Type), Subaggr_Type);
-- Check range length VS target length.
Chap6.Check_Bound_Error
(New_Compare_Op
(ON_Neq,
+ M2E (Chap3.Range_To_Length (A_Range)),
M2E (Chap3.Range_To_Length
- (Dv2M (A_Range,
- Rinfo,
- Mode_Value,
- Rinfo.T.Range_Type,
- Rinfo.T.Range_Ptr_Type))),
- M2E (Chap3.Range_To_Length
- (Chap3.Bounds_To_Range
- (Bounds, Target_Type, I + 1))),
+ (Chap3.Bounds_To_Range
+ (Bounds, Target_Type, I + 1))),
Ghdl_Bool_Type),
Aggr, I);
end;
@@ -3864,33 +3856,30 @@ package body Trans.Chap7 is
Close_Temp;
end Translate_Reverse_Range;
- procedure Copy_Range (Dest_Ptr : O_Dnode;
- Src_Ptr : O_Dnode;
- Info : Type_Info_Acc) is
+ procedure Copy_Range (Dest : Mnode; Src : Mnode)
+ is
+ Info : constant Type_Info_Acc := Get_Type_Info (Dest);
+ Dest1 : Mnode;
+ Src1 : Mnode;
begin
- New_Assign_Stmt
- (New_Selected_Acc_Value (New_Obj (Dest_Ptr), Info.T.Range_Left),
- New_Value_Selected_Acc_Value (New_Obj (Src_Ptr),
- Info.T.Range_Left));
- New_Assign_Stmt
- (New_Selected_Acc_Value (New_Obj (Dest_Ptr), Info.T.Range_Right),
- New_Value_Selected_Acc_Value (New_Obj (Src_Ptr),
- Info.T.Range_Right));
- New_Assign_Stmt
- (New_Selected_Acc_Value (New_Obj (Dest_Ptr), Info.T.Range_Dir),
- New_Value_Selected_Acc_Value (New_Obj (Src_Ptr),
- Info.T.Range_Dir));
+ Open_Temp;
+ Dest1 := Stabilize (Dest);
+ Src1 := Stabilize (Src);
+ New_Assign_Stmt (M2Lv (Chap3.Range_To_Left (Dest1)),
+ M2E (Chap3.Range_To_Left (Src1)));
+ New_Assign_Stmt (M2Lv (Chap3.Range_To_Right (Dest1)),
+ M2E (Chap3.Range_To_Right (Src1)));
+ New_Assign_Stmt (M2Lv (Chap3.Range_To_Dir (Dest1)),
+ M2E (Chap3.Range_To_Dir (Src1)));
if Info.T.Range_Length /= O_Fnode_Null then
- New_Assign_Stmt
- (New_Selected_Acc_Value (New_Obj (Dest_Ptr),
- Info.T.Range_Length),
- New_Value_Selected_Acc_Value (New_Obj (Src_Ptr),
- Info.T.Range_Length));
+ New_Assign_Stmt (M2Lv (Chap3.Range_To_Length (Dest1)),
+ M2E (Chap3.Range_To_Length (Src1)));
end if;
+ Close_Temp;
end Copy_Range;
- procedure Translate_Range_Ptr
- (Res_Ptr : O_Dnode; Arange : Iir; Range_Type : Iir)
+ procedure Translate_Range
+ (Res : Mnode; Arange : Iir; Range_Type : Iir)
is
Rinfo : constant Type_Info_Acc :=
Get_Info (Get_Base_Type (Range_Type));
@@ -3904,26 +3893,23 @@ package body Trans.Chap7 is
Ptr := Create_Temp_Ptr
(Rinfo.T.Range_Ptr_Type,
Chap14.Translate_Range_Array_Attribute (Arange));
- Copy_Range (Res_Ptr, Ptr, Rinfo);
+ Copy_Range (Res,
+ Dp2M (Ptr, Rinfo, Mode_Value,
+ Rinfo.T.Range_Type, Rinfo.T.Range_Ptr_Type));
Close_Temp;
end;
when Iir_Kind_Reverse_Range_Array_Attribute =>
Translate_Reverse_Range
- (Dp2M (Res_Ptr, Rinfo, Mode_Value,
- Rinfo.T.Range_Type, Rinfo.T.Range_Ptr_Type),
- Chap14.Translate_Range_Array_Attribute (Arange),
+ (Res, Chap14.Translate_Range_Array_Attribute (Arange),
Range_Type);
when Iir_Kind_Range_Expression =>
- Translate_Range_Expression
- (Dp2M (Res_Ptr, Rinfo, Mode_Value,
- Rinfo.T.Range_Type, Rinfo.T.Range_Ptr_Type),
- Arange, Range_Type);
+ Translate_Range_Expression (Res, Arange, Range_Type);
when others =>
Error_Kind ("translate_range_ptr", Arange);
end case;
- end Translate_Range_Ptr;
+ end Translate_Range;
- procedure Translate_Discrete_Range_Ptr (Res_Ptr : O_Dnode; Arange : Iir) is
+ procedure Translate_Discrete_Range (Res : Mnode; Arange : Iir) is
begin
case Get_Kind (Arange) is
when Iir_Kind_Integer_Subtype_Definition
@@ -3931,27 +3917,25 @@ package body Trans.Chap7 is
if not Is_Anonymous_Type_Definition (Arange) then
declare
Rinfo : constant Type_Info_Acc := Get_Info (Arange);
- Ptr : O_Dnode;
begin
- Open_Temp;
- Ptr := Create_Temp_Ptr
- (Rinfo.T.Range_Ptr_Type, Get_Var (Rinfo.T.Range_Var));
- Copy_Range (Res_Ptr, Ptr, Rinfo);
- Close_Temp;
+ Copy_Range (Res, Lv2M (Get_Var (Rinfo.T.Range_Var),
+ Rinfo, Mode_Value,
+ Rinfo.T.Range_Type,
+ Rinfo.T.Range_Ptr_Type));
end;
else
- Translate_Range_Ptr (Res_Ptr,
- Get_Range_Constraint (Arange),
- Get_Base_Type (Arange));
+ Translate_Range (Res,
+ Get_Range_Constraint (Arange),
+ Get_Base_Type (Arange));
end if;
when Iir_Kind_Range_Array_Attribute
| Iir_Kind_Reverse_Range_Array_Attribute
| Iir_Kind_Range_Expression =>
- Translate_Range_Ptr (Res_Ptr, Arange, Get_Type (Arange));
+ Translate_Range (Res, Arange, Get_Type (Arange));
when others =>
Error_Kind ("translate_discrete_range_ptr", Arange);
end case;
- end Translate_Discrete_Range_Ptr;
+ end Translate_Discrete_Range;
function Translate_Range (Arange : Iir; Range_Type : Iir) return O_Lnode is
begin
diff --git a/src/vhdl/translate/trans-chap7.ads b/src/vhdl/translate/trans-chap7.ads
index 0527a4d28..5e038da3a 100644
--- a/src/vhdl/translate/trans-chap7.ads
+++ b/src/vhdl/translate/trans-chap7.ads
@@ -53,16 +53,15 @@ package Trans.Chap7 is
-- The node returned can be used only one time.
function Translate_Range (Arange : Iir; Range_Type : Iir) return O_Lnode;
- -- Translate range expression EXPR and store the result into the node
- -- pointed by RES_PTR, of type RANGE_TYPE.
- procedure Translate_Range_Ptr
- (Res_Ptr : O_Dnode; Arange : Iir; Range_Type : Iir);
+ -- Translate range expression ARANGE and store the result into RES, of
+ -- type RANGE_TYPE.
+ procedure Translate_Range (Res : Mnode; Arange : Iir; Range_Type : Iir);
function Translate_Static_Range (Arange : Iir; Range_Type : Iir)
return O_Cnode;
- -- Same as Translate_Range_Ptr, but for a discrete range (ie: ARANGE
+ -- Same as Translate_Range, but for a discrete range (ie: ARANGE
-- can be a discrete subtype indication).
- procedure Translate_Discrete_Range_Ptr (Res_Ptr : O_Dnode; Arange : Iir);
+ procedure Translate_Discrete_Range (Res : Mnode; Arange : Iir);
-- Return TRUE iff constant declaration DECL can be staticly defined.
-- This is of course true if its expression is a locally static literal,
diff --git a/src/vhdl/translate/trans.adb b/src/vhdl/translate/trans.adb
index f099a9075..393497935 100644
--- a/src/vhdl/translate/trans.adb
+++ b/src/vhdl/translate/trans.adb
@@ -1913,6 +1913,7 @@ package body Trans is
T : Temp_Level_Acc;
begin
if Temp_Level /= null then
+ -- Missing Close_Temp.
raise Internal_Error;
end if;
loop