From c421a1adec85343c7e855dc584743fbb95274be5 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Fri, 16 Apr 2021 06:57:07 +0200 Subject: synth: renaming (synth-heap -> synth-vhdl_heap) --- src/synth/synth-expr.adb | 6 +-- src/synth/synth-heap.adb | 92 ------------------------------------ src/synth/synth-heap.ads | 30 ------------ src/synth/synth-stmts.adb | 4 +- src/synth/synth-vhdl_heap.adb | 92 ++++++++++++++++++++++++++++++++++++ src/synth/synth-vhdl_heap.ads | 30 ++++++++++++ src/synth/synth-vhdl_static_proc.adb | 4 +- 7 files changed, 129 insertions(+), 129 deletions(-) delete mode 100644 src/synth/synth-heap.adb delete mode 100644 src/synth/synth-heap.ads create mode 100644 src/synth/synth-vhdl_heap.adb create mode 100644 src/synth/synth-vhdl_heap.ads diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index 6c50ab6a9..d52ab0c29 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -44,7 +44,7 @@ with Synth.Environment; with Synth.Decls; with Synth.Stmts; use Synth.Stmts; with Synth.Vhdl_Oper; use Synth.Vhdl_Oper; -with Synth.Heap; use Synth.Heap; +with Synth.Vhdl_Heap; use Synth.Vhdl_Heap; with Synth.Debugger; with Synth.Vhdl_Aggr; @@ -528,7 +528,7 @@ package body Synth.Expr is begin -- Maybe do not dereference it if its type is known ? Val := Synth_Expression (Syn_Inst, Get_Prefix (Expr)); - Res := Heap.Synth_Dereference (Read_Access (Val)); + Res := Vhdl_Heap.Synth_Dereference (Read_Access (Val)); return Res.Typ; end; @@ -1072,7 +1072,7 @@ package body Synth.Expr is Val : Valtyp; begin Val := Synth_Expression (Syn_Inst, Get_Prefix (Name)); - return Heap.Synth_Dereference (Read_Access (Val)); + return Vhdl_Heap.Synth_Dereference (Read_Access (Val)); end; when others => Error_Kind ("synth_name", Name); diff --git a/src/synth/synth-heap.adb b/src/synth/synth-heap.adb deleted file mode 100644 index 3f6a93732..000000000 --- a/src/synth/synth-heap.adb +++ /dev/null @@ -1,92 +0,0 @@ --- Heap for synthesis. --- Copyright (C) 2017 Tristan Gingold --- --- This file is part of GHDL. --- --- This program is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 2 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . - -with Types; use Types; -with Tables; - - -package body Synth.Heap is - - package Heap_Table is new Tables - (Table_Component_Type => Valtyp, - Table_Index_Type => Heap_Index, - Table_Low_Bound => 1, - Table_Initial => 16); - - function Alloc_Mem (Sz : Size_Type) return Memory_Ptr; - pragma Import (C, Alloc_Mem, "malloc"); - - function Allocate_Memory (T : Type_Acc) return Value_Acc - is - M : Memory_Ptr; - begin - M := Alloc_Mem (T.Sz); - return new Value_Type'(Kind => Value_Memory, Mem => M); - end Allocate_Memory; - - function Allocate_By_Type (T : Type_Acc) return Value_Acc - is - Res : Value_Acc; - begin - Res := Allocate_Memory (T); - Write_Value_Default (Res.Mem, T); - return Res; - end Allocate_By_Type; - - function Allocate_By_Type (T : Type_Acc) return Heap_Index is - begin - -- FIXME: allocate type. - Heap_Table.Append ((T, Allocate_By_Type (T))); - return Heap_Table.Last; - end Allocate_By_Type; - - function Allocate_By_Value (V : Valtyp) return Value_Acc - is - Res : Value_Acc; - begin - Res := Allocate_Memory (V.Typ); - Write_Value (Res.Mem, V); - return Res; - end Allocate_By_Value; - - function Allocate_By_Value (V : Valtyp) return Heap_Index is - begin - Heap_Table.Append ((V.Typ, Allocate_By_Value (V))); - return Heap_Table.Last; - end Allocate_By_Value; - - function Synth_Dereference (Idx : Heap_Index) return Valtyp is - begin - return Heap_Table.Table (Idx); - end Synth_Dereference; - - procedure Free (Obj : in out Valtyp) is - begin - -- TODO - Obj := No_Valtyp; - end Free; - - procedure Synth_Deallocate (Idx : Heap_Index) is - begin - if Heap_Table.Table (Idx) = No_Valtyp then - return; - end if; - Free (Heap_Table.Table (Idx)); - end Synth_Deallocate; - -end Synth.Heap; diff --git a/src/synth/synth-heap.ads b/src/synth/synth-heap.ads deleted file mode 100644 index be01deb6c..000000000 --- a/src/synth/synth-heap.ads +++ /dev/null @@ -1,30 +0,0 @@ --- Heap for synthesis. --- Copyright (C) 2017 Tristan Gingold --- --- This file is part of GHDL. --- --- This program is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 2 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . - -with Synth.Objtypes; use Synth.Objtypes; -with Synth.Values; use Synth.Values; - -package Synth.Heap is - -- Allocate a value. - function Allocate_By_Type (T : Type_Acc) return Heap_Index; - function Allocate_By_Value (V : Valtyp) return Heap_Index; - - function Synth_Dereference (Idx : Heap_Index) return Valtyp; - - procedure Synth_Deallocate (Idx : Heap_Index); -end Synth.Heap; diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb index 03f5de65f..bc7c7f4a4 100644 --- a/src/synth/synth-stmts.adb +++ b/src/synth/synth-stmts.adb @@ -45,7 +45,7 @@ with Synth.Expr; use Synth.Expr; with Synth.Insts; use Synth.Insts; with Synth.Source; with Synth.Vhdl_Static_Proc; -with Synth.Heap; +with Synth.Vhdl_Heap; with Synth.Flags; with Synth.Debugger; @@ -240,7 +240,7 @@ package body Synth.Stmts is if Dest_Off /= (0, 0) and then Dest_Dyn.Voff /= No_Net then raise Internal_Error; end if; - Dest_Base := Heap.Synth_Dereference (Read_Access (Dest_Base)); + Dest_Base := Vhdl_Heap.Synth_Dereference (Read_Access (Dest_Base)); Dest_Typ := Dest_Base.Typ; when others => diff --git a/src/synth/synth-vhdl_heap.adb b/src/synth/synth-vhdl_heap.adb new file mode 100644 index 000000000..5270c99e0 --- /dev/null +++ b/src/synth/synth-vhdl_heap.adb @@ -0,0 +1,92 @@ +-- Heap for synthesis. +-- Copyright (C) 2017 Tristan Gingold +-- +-- This file is part of GHDL. +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +with Types; use Types; +with Tables; + + +package body Synth.Vhdl_Heap is + + package Heap_Table is new Tables + (Table_Component_Type => Valtyp, + Table_Index_Type => Heap_Index, + Table_Low_Bound => 1, + Table_Initial => 16); + + function Alloc_Mem (Sz : Size_Type) return Memory_Ptr; + pragma Import (C, Alloc_Mem, "malloc"); + + function Allocate_Memory (T : Type_Acc) return Value_Acc + is + M : Memory_Ptr; + begin + M := Alloc_Mem (T.Sz); + return new Value_Type'(Kind => Value_Memory, Mem => M); + end Allocate_Memory; + + function Allocate_By_Type (T : Type_Acc) return Value_Acc + is + Res : Value_Acc; + begin + Res := Allocate_Memory (T); + Write_Value_Default (Res.Mem, T); + return Res; + end Allocate_By_Type; + + function Allocate_By_Type (T : Type_Acc) return Heap_Index is + begin + -- FIXME: allocate type. + Heap_Table.Append ((T, Allocate_By_Type (T))); + return Heap_Table.Last; + end Allocate_By_Type; + + function Allocate_By_Value (V : Valtyp) return Value_Acc + is + Res : Value_Acc; + begin + Res := Allocate_Memory (V.Typ); + Write_Value (Res.Mem, V); + return Res; + end Allocate_By_Value; + + function Allocate_By_Value (V : Valtyp) return Heap_Index is + begin + Heap_Table.Append ((V.Typ, Allocate_By_Value (V))); + return Heap_Table.Last; + end Allocate_By_Value; + + function Synth_Dereference (Idx : Heap_Index) return Valtyp is + begin + return Heap_Table.Table (Idx); + end Synth_Dereference; + + procedure Free (Obj : in out Valtyp) is + begin + -- TODO + Obj := No_Valtyp; + end Free; + + procedure Synth_Deallocate (Idx : Heap_Index) is + begin + if Heap_Table.Table (Idx) = No_Valtyp then + return; + end if; + Free (Heap_Table.Table (Idx)); + end Synth_Deallocate; + +end Synth.Vhdl_Heap; diff --git a/src/synth/synth-vhdl_heap.ads b/src/synth/synth-vhdl_heap.ads new file mode 100644 index 000000000..0e1928b26 --- /dev/null +++ b/src/synth/synth-vhdl_heap.ads @@ -0,0 +1,30 @@ +-- Heap for synthesis. +-- Copyright (C) 2017 Tristan Gingold +-- +-- This file is part of GHDL. +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +with Synth.Objtypes; use Synth.Objtypes; +with Synth.Values; use Synth.Values; + +package Synth.Vhdl_Heap is + -- Allocate a value. + function Allocate_By_Type (T : Type_Acc) return Heap_Index; + function Allocate_By_Value (V : Valtyp) return Heap_Index; + + function Synth_Dereference (Idx : Heap_Index) return Valtyp; + + procedure Synth_Deallocate (Idx : Heap_Index); +end Synth.Vhdl_Heap; diff --git a/src/synth/synth-vhdl_static_proc.adb b/src/synth/synth-vhdl_static_proc.adb index 4c68bb58b..462896451 100644 --- a/src/synth/synth-vhdl_static_proc.adb +++ b/src/synth/synth-vhdl_static_proc.adb @@ -21,7 +21,7 @@ with Vhdl.Errors; use Vhdl.Errors; with Synth.Values; use Synth.Values; with Synth.Errors; use Synth.Errors; with Synth.Vhdl_Files; use Synth.Vhdl_Files; -with Synth.Heap; +with Synth.Vhdl_Heap; package body Synth.Vhdl_Static_Proc is @@ -33,7 +33,7 @@ package body Synth.Vhdl_Static_Proc is begin Val := Read_Access (Param); if Val /= Null_Heap_Index then - Synth.Heap.Synth_Deallocate (Val); + Synth.Vhdl_Heap.Synth_Deallocate (Val); Write_Access (Param.Val.Mem, Null_Heap_Index); end if; end Synth_Deallocate; -- cgit v1.2.3