diff options
-rw-r--r-- | src/vhdl/nodes.adb | 71 | ||||
-rw-r--r-- | src/vhdl/nodes.ads | 72 |
2 files changed, 66 insertions, 77 deletions
diff --git a/src/vhdl/nodes.adb b/src/vhdl/nodes.adb index c5a16f2fe..ef22fb028 100644 --- a/src/vhdl/nodes.adb +++ b/src/vhdl/nodes.adb @@ -27,10 +27,6 @@ package body Nodes is -- Null_Node or Error_Node). --pragma Suppress (Index_Check); - -- Suppress discriminant checks on the table. Relatively safe, since - -- iirs do their own checks. - pragma Suppress (Discriminant_Check); - package Nodet is new Tables (Table_Component_Type => Node_Record, Table_Index_Type => Node_Type, @@ -44,55 +40,38 @@ package body Nodes is Free_Chain : Node_Type := Null_Node; - -- Just to have the default value. - pragma Warnings (Off); - Init_Short : Node_Record (Format_Short); - Init_Medium : Node_Record (Format_Medium); - pragma Warnings (On); - function Create_Node (Format : Format_Type) return Node_Type is Res : Node_Type; begin - if Format = Format_Medium then - -- Allocate a first node. - Nodet.Increment_Last; - Res := Nodet.Last; - -- Check alignment. - if Res mod 2 = 1 then - Set_Field1 (Res, Free_Chain); - Free_Chain := Res; + case Format is + when Format_Medium => + -- Allocate a first node. Nodet.Increment_Last; Res := Nodet.Last; - end if; - -- Allocate the second node. - Nodet.Increment_Last; - Nodet.Table (Res) := Init_Medium; - Nodet.Table (Res + 1) := Init_Medium; - else - -- Check from free pool - if Free_Chain = Null_Node then + -- Check alignment. + if Res mod 2 = 1 then + Set_Field1 (Res, Free_Chain); + Free_Chain := Res; + Nodet.Increment_Last; + Res := Nodet.Last; + end if; + -- Allocate the second node. Nodet.Increment_Last; - Res := Nodet.Last; - else - Res := Free_Chain; - Free_Chain := Get_Field1 (Res); - end if; - case Format is - when Format_Short => - -- Inline initialization for speed. - Nodet.Table (Res) := Node_Record' - (Format => Format_Short, - Kind => 0, - State1 | State2 => 0, - Location => Location_Nil, - Field0 | Field1 | Field2 | Field3 => Null_Node, - Field4 | Field5 => Null_Node, - others => False); - when Format_Medium => - raise Program_Error; - end case; - end if; + Nodet.Table (Res) := Init_Node; + Nodet.Table (Res).Format := Format_Medium; + Nodet.Table (Res + 1) := Init_Node; + when Format_Short => + -- Check from free pool + if Free_Chain = Null_Node then + Nodet.Increment_Last; + Res := Nodet.Last; + else + Res := Free_Chain; + Free_Chain := Get_Field1 (Res); + end if; + Nodet.Table (Res) := Init_Node; + end case; return Res; end Create_Node; diff --git a/src/vhdl/nodes.ads b/src/vhdl/nodes.ads index d9920736c..b3fe3fd7d 100644 --- a/src/vhdl/nodes.ads +++ b/src/vhdl/nodes.ads @@ -261,50 +261,60 @@ package Nodes is -- Free all and reinit. procedure Initialize; private - type Node_Record (Format : Format_Type := Format_Short) is record - -- First byte (with Format): - Flag1 : Boolean := False; - Flag2 : Boolean := False; - Flag3 : Boolean := False; - Flag4 : Boolean := False; - Flag5 : Boolean := False; - Flag6 : Boolean := False; - Flag7 : Boolean := False; + type Node_Record is record + -- First byte: + Format : Format_Type; + Flag1 : Boolean; + Flag2 : Boolean; + Flag3 : Boolean; + Flag4 : Boolean; + Flag5 : Boolean; + Flag6 : Boolean; + Flag7 : Boolean; -- Second byte: - Flag8 : Boolean := False; - Flag9 : Boolean := False; - Flag10 : Boolean := False; - Flag11 : Boolean := False; - Flag12 : Boolean := False; - Flag13 : Boolean := False; - Flag14 : Boolean := False; - Flag15 : Boolean := False; + Flag8 : Boolean; + Flag9 : Boolean; + Flag10 : Boolean; + Flag11 : Boolean; + Flag12 : Boolean; + Flag13 : Boolean; + Flag14 : Boolean; + Flag15 : Boolean; -- Third byte: - Flag16 : Boolean := False; - Flag17 : Boolean := False; - Flag18 : Boolean := False; + Flag16 : Boolean; + Flag17 : Boolean; + Flag18 : Boolean; -- 2*2 = 4 bits - State1 : Bit2_Type := 0; - State2 : Bit2_Type := 0; + State1 : Bit2_Type; + State2 : Bit2_Type; -- 9 bits Kind : Kind_Type; -- Location. - Location: Location_Type := Location_Nil; - - Field0 : Node_Type := Null_Node; - Field1 : Node_Type := Null_Node; - Field2 : Node_Type := Null_Node; - Field3 : Node_Type := Null_Node; - Field4 : Node_Type := Null_Node; - Field5 : Node_Type := Null_Node; + Location: Location_Type; + + Field0 : Node_Type; + Field1 : Node_Type; + Field2 : Node_Type; + Field3 : Node_Type; + Field4 : Node_Type; + Field5 : Node_Type; end record; - pragma Pack (Node_Record); for Node_Record'Size use 8*32; for Node_Record'Alignment use 4; + pragma Suppress_Initialization (Node_Record); + + Init_Node : constant Node_Record := Node_Record' + (Format => Format_Short, + Kind => 0, + State1 | State2 => 0, + Location => Location_Nil, + Field0 | Field1 | Field2 | Field3 | Field4 | Field5 => Null_Node, + others => False); + end Nodes; |