diff options
author | Tristan Gingold | 2014-11-15 16:52:23 +0100 |
---|---|---|
committer | Tristan Gingold | 2014-11-15 16:52:23 +0100 |
commit | 9f621e4bd1e78e533f3c57d379a32fc5f6d0e5eb (patch) | |
tree | 16e397a12efedefbfa6374cfefe6a7f067dbca09 /src/vhdl | |
parent | a67dcaa2aab0ee03efec74737f2c02101eec7adc (diff) | |
download | ghdl-9f621e4bd1e78e533f3c57d379a32fc5f6d0e5eb.tar.gz ghdl-9f621e4bd1e78e533f3c57d379a32fc5f6d0e5eb.tar.bz2 ghdl-9f621e4bd1e78e533f3c57d379a32fc5f6d0e5eb.zip |
Translate_Reverse_Range_Ptr: use mnode instead of ptr and rename.
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/translate/trans-chap3.adb | 9 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap7.adb | 95 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap7.ads | 5 |
3 files changed, 48 insertions, 61 deletions
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb index 30d24f4..5afbd0a 100644 --- a/src/vhdl/translate/trans-chap3.adb +++ b/src/vhdl/translate/trans-chap3.adb @@ -1661,14 +1661,11 @@ package body Trans.Chap3 is -- Create a type_range structure. procedure Create_Scalar_Type_Range (Def : Iir; Target : O_Lnode) is - T_Info : Type_Info_Acc; - Base_Type : Iir; - Expr : Iir; + 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; begin - Base_Type := Get_Base_Type (Def); - T_Info := Get_Info (Base_Type); - Expr := Get_Range_Constraint (Def); Open_Temp; V := Create_Temp_Ptr (T_Info.T.Range_Ptr_Type, Target); Chap7.Translate_Range_Ptr (V, Expr, Def); diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb index 99a5168..f855b58 100644 --- a/src/vhdl/translate/trans-chap7.adb +++ b/src/vhdl/translate/trans-chap7.adb @@ -3788,10 +3788,9 @@ package body Trans.Chap7 is procedure Translate_Range_Expression_Ptr (Res_Ptr : O_Dnode; Expr : Iir; Range_Type : Iir) is - T_Info : Type_Info_Acc; + T_Info : constant Type_Info_Acc := Get_Info (Range_Type); Length_Attr : Iir; begin - T_Info := Get_Info (Range_Type); Open_Temp; New_Assign_Stmt (New_Selected_Acc_Value (New_Obj (Res_Ptr), T_Info.T.Range_Left), @@ -3835,43 +3834,38 @@ package body Trans.Chap7 is end Translate_Range_Expression_Ptr; -- Reverse range ARANGE. - procedure Translate_Reverse_Range_Ptr - (Res_Ptr : O_Dnode; Arange : O_Lnode; Range_Type : Iir) + procedure Translate_Reverse_Range + (Res : Mnode; Arange : O_Lnode; Range_Type : Iir) is - Rinfo : Type_Info_Acc; - Ptr : O_Dnode; + Rinfo : constant Type_Info_Acc := Get_Info (Get_Base_Type (Range_Type)); + Res1 : Mnode; + Arange1 : Mnode; If_Blk : O_If_Block; begin - Rinfo := Get_Info (Get_Base_Type (Range_Type)); Open_Temp; - Ptr := Create_Temp_Ptr (Rinfo.T.Range_Ptr_Type, Arange); - New_Assign_Stmt - (New_Selected_Acc_Value (New_Obj (Res_Ptr), Rinfo.T.Range_Left), - New_Value_Selected_Acc_Value (New_Obj (Ptr), Rinfo.T.Range_Right)); - New_Assign_Stmt - (New_Selected_Acc_Value (New_Obj (Res_Ptr), Rinfo.T.Range_Right), - New_Value_Selected_Acc_Value (New_Obj (Ptr), Rinfo.T.Range_Left)); - New_Assign_Stmt - (New_Selected_Acc_Value (New_Obj (Res_Ptr), Rinfo.T.Range_Length), - New_Value_Selected_Acc_Value (New_Obj (Ptr), - Rinfo.T.Range_Length)); + Arange1 := Stabilize (Lv2M (Arange, Rinfo, Mode_Value, + Rinfo.T.Range_Type, + Rinfo.T.Range_Ptr_Type)); + Res1 := Stabilize (Res); + New_Assign_Stmt (M2Lv (Chap3.Range_To_Left (Res1)), + M2E (Chap3.Range_To_Right (Arange1))); + New_Assign_Stmt (M2Lv (Chap3.Range_To_Right (Res1)), + M2E (Chap3.Range_To_Left (Arange1))); + New_Assign_Stmt (M2Lv (Chap3.Range_To_Length (Res1)), + M2E (Chap3.Range_To_Length (Arange1))); Start_If_Stmt - (If_Blk, - New_Compare_Op - (ON_Eq, - New_Value_Selected_Acc_Value (New_Obj (Ptr), Rinfo.T.Range_Dir), - New_Lit (Ghdl_Dir_To_Node), - Ghdl_Bool_Type)); - New_Assign_Stmt - (New_Selected_Acc_Value (New_Obj (Res_Ptr), Rinfo.T.Range_Dir), - New_Lit (Ghdl_Dir_Downto_Node)); + (If_Blk, New_Compare_Op (ON_Eq, + M2E (Chap3.Range_To_Dir (Arange1)), + New_Lit (Ghdl_Dir_To_Node), + Ghdl_Bool_Type)); + New_Assign_Stmt (M2Lv (Chap3.Range_To_Dir (Res1)), + New_Lit (Ghdl_Dir_Downto_Node)); New_Else_Stmt (If_Blk); - New_Assign_Stmt - (New_Selected_Acc_Value (New_Obj (Res_Ptr), Rinfo.T.Range_Dir), - New_Lit (Ghdl_Dir_To_Node)); + New_Assign_Stmt (M2Lv (Chap3.Range_To_Dir (Res1)), + New_Lit (Ghdl_Dir_To_Node)); Finish_If_Stmt (If_Blk); Close_Temp; - end Translate_Reverse_Range_Ptr; + end Translate_Reverse_Range; procedure Copy_Range (Dest_Ptr : O_Dnode; Src_Ptr : O_Dnode; @@ -3905,9 +3899,9 @@ package body Trans.Chap7 is when Iir_Kind_Range_Array_Attribute => declare Ptr : O_Dnode; - Rinfo : Type_Info_Acc; + Rinfo : constant Type_Info_Acc := + Get_Info (Get_Base_Type (Range_Type)); begin - Rinfo := Get_Info (Get_Base_Type (Range_Type)); Open_Temp; Ptr := Create_Temp_Ptr (Rinfo.T.Range_Ptr_Type, @@ -3916,10 +3910,16 @@ package body Trans.Chap7 is Close_Temp; end; when Iir_Kind_Reverse_Range_Array_Attribute => - Translate_Reverse_Range_Ptr - (Res_Ptr, - Chap14.Translate_Range_Array_Attribute (Arange), - Range_Type); + declare + Rinfo : constant Type_Info_Acc := + Get_Info (Get_Base_Type (Range_Type)); + begin + Translate_Reverse_Range + (Dp2M (Res_Ptr, Rinfo, Mode_Value, + Rinfo.T.Range_Type, Rinfo.T.Range_Ptr_Type), + Chap14.Translate_Range_Array_Attribute (Arange), + Range_Type); + end; when Iir_Kind_Range_Expression => Translate_Range_Expression_Ptr (Res_Ptr, Arange, Range_Type); when others => @@ -3934,10 +3934,9 @@ package body Trans.Chap7 is | Iir_Kind_Enumeration_Subtype_Definition => if not Is_Anonymous_Type_Definition (Arange) then declare + Rinfo : constant Type_Info_Acc := Get_Info (Arange); Ptr : O_Dnode; - Rinfo : Type_Info_Acc; begin - Rinfo := Get_Info (Arange); Open_Temp; Ptr := Create_Temp_Ptr (Rinfo.T.Range_Ptr_Type, Get_Var (Rinfo.T.Range_Var)); @@ -3970,33 +3969,25 @@ package body Trans.Chap7 is return Chap14.Translate_Range_Array_Attribute (Arange); when Iir_Kind_Reverse_Range_Array_Attribute => declare + Rinfo : constant Type_Info_Acc := Get_Info (Range_Type); Res : O_Dnode; - Res_Ptr : O_Dnode; - Rinfo : Type_Info_Acc; begin - Rinfo := Get_Info (Range_Type); Res := Create_Temp (Rinfo.T.Range_Type); - Open_Temp; - Res_Ptr := Create_Temp_Ptr (Rinfo.T.Range_Ptr_Type, - New_Obj (Res)); - Translate_Reverse_Range_Ptr - (Res_Ptr, + Translate_Reverse_Range + (Dv2M (Res, Rinfo, Mode_Value), Chap14.Translate_Range_Array_Attribute (Arange), Range_Type); - Close_Temp; return New_Obj (Res); end; when Iir_Kind_Range_Expression => declare Res : O_Dnode; Ptr : O_Dnode; - T_Info : Type_Info_Acc; + T_Info : constant Type_Info_Acc := Get_Info (Range_Type); begin - T_Info := Get_Info (Range_Type); Res := Create_Temp (T_Info.T.Range_Type); Open_Temp; - Ptr := Create_Temp_Ptr (T_Info.T.Range_Ptr_Type, - New_Obj (Res)); + Ptr := Create_Temp_Ptr (T_Info.T.Range_Ptr_Type, New_Obj (Res)); Translate_Range_Expression_Ptr (Ptr, Arange, Range_Type); Close_Temp; return New_Obj (Res); diff --git a/src/vhdl/translate/trans-chap7.ads b/src/vhdl/translate/trans-chap7.ads index d3fcfee..0527a4d 100644 --- a/src/vhdl/translate/trans-chap7.ads +++ b/src/vhdl/translate/trans-chap7.ads @@ -51,15 +51,14 @@ package Trans.Chap7 is -- Translate range and return an lvalue containing the range. -- The node returned can be used only one time. - function Translate_Range (Arange : Iir; Range_Type : Iir) - return O_Lnode; + 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); function Translate_Static_Range (Arange : Iir; Range_Type : Iir) - return O_Cnode; + return O_Cnode; -- Same as Translate_Range_Ptr, but for a discrete range (ie: ARANGE -- can be a discrete subtype indication). |