diff options
author | Tristan Gingold <tgingold@free.fr> | 2014-11-21 03:49:42 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2014-11-21 03:49:42 +0100 |
commit | 229103683af03c7286444aa12ec85bb2ba1bed59 (patch) | |
tree | e2598cf02a2b873acc080440841e4c8d8f31c714 /src/vhdl/translate/trans.ads | |
parent | 232f0d5f10ecd3b99774d3dda6a7ebf914b2a2e6 (diff) | |
download | ghdl-229103683af03c7286444aa12ec85bb2ba1bed59.tar.gz ghdl-229103683af03c7286444aa12ec85bb2ba1bed59.tar.bz2 ghdl-229103683af03c7286444aa12ec85bb2ba1bed59.zip |
Mnode: renaming and comments to clarify.
Diffstat (limited to 'src/vhdl/translate/trans.ads')
-rw-r--r-- | src/vhdl/translate/trans.ads | 169 |
1 files changed, 93 insertions, 76 deletions
diff --git a/src/vhdl/translate/trans.ads b/src/vhdl/translate/trans.ads index 7e4593c64..7156a488d 100644 --- a/src/vhdl/translate/trans.ads +++ b/src/vhdl/translate/trans.ads @@ -168,6 +168,21 @@ package Trans is type Allocation_Kind is (Alloc_Stack, Alloc_Return, Alloc_Heap, Alloc_System); + -- Return the value of field FIELD of lnode L that is contains + -- a pointer to a record. + -- This is equivalent to: + -- new_value (new_selected_element (new_access_element (new_value (l)), + -- field)) + function New_Value_Selected_Acc_Value (L : O_Lnode; Field : O_Fnode) + return O_Enode; + function New_Selected_Acc_Value (L : O_Lnode; Field : O_Fnode) + return O_Lnode; + + function New_Indexed_Acc_Value (L : O_Lnode; I : O_Enode) return O_Lnode; + + -- Equivalent to new_access_element (new_value (l)) + function New_Acc_Value (L : O_Lnode) return O_Lnode; + package Chap10 is -- There are three data storage kind: global, local or instance. -- For example, a constant can have: @@ -1359,8 +1374,54 @@ package Trans is subtype Design_File_Info_Acc is Ortho_Info_Acc (Kind_Design_File); subtype Library_Info_Acc is Ortho_Info_Acc (Kind_Library); - -- In order to simplify the handling of Enode/Lnode, let's introduce - -- Mnode (yes, another node). + procedure Init_Node_Infos; + procedure Update_Node_Infos; + procedure Free_Node_Infos; + + procedure Set_Info (Target : Iir; Info : Ortho_Info_Acc); + + procedure Clear_Info (Target : Iir); + + function Get_Info (Target : Iir) return Ortho_Info_Acc; + pragma Inline (Get_Info); + + -- Create an ortho_info field of kind KIND for iir node TARGET, and + -- return it. + function Add_Info (Target : Iir; Kind : Ortho_Info_Kind) + return Ortho_Info_Acc; + + procedure Free_Info (Target : Iir); + + procedure Free_Type_Info (Info : in out Type_Info_Acc); + + procedure Set_Ortho_Expr (Target : Iir; Expr : O_Cnode); + + function Get_Ortho_Expr (Target : Iir) return O_Cnode; + + function Get_Ortho_Type (Target : Iir; Is_Sig : Object_Kind_Type) + return O_Tnode; + + -- Return true is INFO is a type info for a composite type, ie: + -- * a record + -- * an array (fat or thin) + -- * a fat pointer. + function Is_Composite (Info : Type_Info_Acc) return Boolean; + pragma Inline (Is_Composite); + + function Is_Complex_Type (Tinfo : Type_Info_Acc) return Boolean; + pragma Inline (Is_Complex_Type); + + type Hexstr_Type is array (Integer range 0 .. 15) of Character; + N2hex : constant Hexstr_Type := "0123456789abcdef"; + + -- In order to unify and have a common handling of Enode/Lnode/Dnode, + -- let's introduce Mnode (yes, another node). + -- + -- Mnodes can be converted to Enode/Lnode via the M2xx functions. If + -- an Mnode are referenced more than once, they must be stabilized (this + -- will create a new variable if needed as Enode and Lnode can be + -- referenced only once). + -- -- An Mnode is a typed union, containing either an Lnode or a Enode. -- See Mstate for a description of the union. -- The real data is contained insisde a record, so that the discriminant @@ -1399,7 +1460,7 @@ package Trans is type Mnode1 (State : Mstate := Mstate_Bad) is record -- True if the object is composite (its value cannot be read directly). - Comp : Boolean; + Is_Composite : Boolean; -- Additionnal informations about the objects: kind and type. K : Object_Kind_Type; @@ -1435,7 +1496,7 @@ package Trans is -- Null Mnode. Mnode_Null : constant Mnode := Mnode'(M1 => (State => Mstate_Null, - Comp => False, + Is_Composite => False, K => Mode_Value, Ptype => O_Tnode_Null, Vtype => O_Tnode_Null, @@ -1466,97 +1527,42 @@ package Trans is Kind : Object_Kind_Type := Mode_Value) return Mnode; - -- Return the value of field FIELD of lnode L that is contains - -- a pointer to a record. - -- This is equivalent to: - -- new_value (new_selected_element (new_access_element (new_value (l)), - -- field)) - function New_Value_Selected_Acc_Value (L : O_Lnode; Field : O_Fnode) - return O_Enode; - function New_Selected_Acc_Value (L : O_Lnode; Field : O_Fnode) - return O_Lnode; - - function New_Indexed_Acc_Value (L : O_Lnode; I : O_Enode) return O_Lnode; - - -- Equivalent to new_access_element (new_value (l)) - function New_Acc_Value (L : O_Lnode) return O_Lnode; - - procedure Init_Node_Infos; - procedure Update_Node_Infos; - procedure Free_Node_Infos; - - procedure Set_Info (Target : Iir; Info : Ortho_Info_Acc); - - procedure Clear_Info (Target : Iir); - - function Get_Info (Target : Iir) return Ortho_Info_Acc; - pragma Inline (Get_Info); - - -- Create an ortho_info field of kind KIND for iir node TARGET, and - -- return it. - function Add_Info (Target : Iir; Kind : Ortho_Info_Kind) - return Ortho_Info_Acc; - - procedure Free_Info (Target : Iir); - - procedure Free_Type_Info (Info : in out Type_Info_Acc); - - procedure Set_Ortho_Expr (Target : Iir; Expr : O_Cnode); - - function Get_Ortho_Expr (Target : Iir) return O_Cnode; - - function Get_Ortho_Type (Target : Iir; Is_Sig : Object_Kind_Type) - return O_Tnode; - - -- Return true is INFO is a type info for a composite type, ie: - -- * a record - -- * an array (fat or thin) - -- * a fat pointer. - function Is_Composite (Info : Type_Info_Acc) return Boolean; - pragma Inline (Is_Composite); - - function Is_Complex_Type (Tinfo : Type_Info_Acc) return Boolean; - pragma Inline (Is_Complex_Type); - - type Hexstr_Type is array (Integer range 0 .. 15) of Character; - N2hex : constant Hexstr_Type := "0123456789abcdef"; - function Get_Type_Info (M : Mnode) return Type_Info_Acc; pragma Inline (Get_Type_Info); function E2M (E : O_Enode; T : Type_Info_Acc; Kind : Object_Kind_Type) - return Mnode; + return Mnode; function Lv2M (L : O_Lnode; T : Type_Info_Acc; Kind : Object_Kind_Type) - return Mnode; + return Mnode; + function Lv2M (L : O_Lnode; + T : Type_Info_Acc; + Kind : Object_Kind_Type; Comp : Boolean; Vtype : O_Tnode; - Ptype : O_Tnode; - T : Type_Info_Acc; Kind : Object_Kind_Type) - return Mnode; + Ptype : O_Tnode) + return Mnode; function Lv2M (L : O_Lnode; T : Type_Info_Acc; Kind : Object_Kind_Type; Vtype : O_Tnode; Ptype : O_Tnode) - return Mnode; + return Mnode; function Lp2M (L : O_Lnode; T : Type_Info_Acc; Kind : Object_Kind_Type) - return Mnode; + return Mnode; function Lp2M (L : O_Lnode; T : Type_Info_Acc; Kind : Object_Kind_Type; Vtype : O_Tnode; Ptype : O_Tnode) - return Mnode; + return Mnode; - function Dv2M (D : O_Dnode; - T : Type_Info_Acc; - Kind : Object_Kind_Type) - return Mnode; + function Dv2M (D : O_Dnode; T : Type_Info_Acc; Kind : Object_Kind_Type) + return Mnode; function Dv2M (D : O_Dnode; T : Type_Info_Acc; @@ -1572,10 +1578,8 @@ package Trans is Ptype : O_Tnode) return Mnode; - function Dp2M (D : O_Dnode; - T : Type_Info_Acc; - Kind : Object_Kind_Type) - return Mnode; + function Dp2M (D : O_Dnode; T : Type_Info_Acc; Kind : Object_Kind_Type) + return Mnode; function M2Lv (M : Mnode) return O_Lnode; @@ -1630,8 +1634,20 @@ package Trans is -- Generate code to exit from loop LABEL iff COND is true. procedure Gen_Exit_When (Label : O_Snode; Cond : O_Enode); - -- Create a region for temporary variables. + -- Create a region for temporary variables. The region is only created + -- on demand (at the first Create_Temp*), so you must be careful not + -- to nest with control statement. For example, the following + -- sequence is not correct: + -- Open_Temp + -- Start_If_Stmt + -- ... Create_Temp ... + -- Finish_If_Stmt + -- Close_Temp + -- Because the first Create_Temp is within the if statement, the + -- declare block will be created within the if statement, and must + -- have been closed before the end of the if statement. procedure Open_Temp; + -- Create a temporary variable. function Create_Temp (Atype : O_Tnode) return O_Dnode; -- Create a temporary variable of ATYPE and initialize it with VALUE. @@ -1648,6 +1664,7 @@ package Trans is -- Add ATYPE in the chain of types to be destroyed at the end of the -- temp scope. procedure Add_Transient_Type_In_Temp (Atype : Iir); + -- Close the temporary region. procedure Close_Temp; |