aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-11-22 19:04:13 +0100
committerTristan Gingold <tgingold@free.fr>2019-11-22 19:04:13 +0100
commitafc6c3378460fc07e0e2d04007fab63acc2290e3 (patch)
tree11317d6e46a239f6282a6f064502145093d16370 /src/synth
parent777617b6c027da1cc3ffb2aec7d108fe4802a835 (diff)
downloadghdl-afc6c3378460fc07e0e2d04007fab63acc2290e3.tar.gz
ghdl-afc6c3378460fc07e0e2d04007fab63acc2290e3.tar.bz2
ghdl-afc6c3378460fc07e0e2d04007fab63acc2290e3.zip
synth: handle allocator_by_expression.
Diffstat (limited to 'src/synth')
-rw-r--r--src/synth/synth-expr.adb10
-rw-r--r--src/synth/synth-heap.adb30
2 files changed, 38 insertions, 2 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb
index 6c47d3e2a..239015f3c 100644
--- a/src/synth/synth-expr.adb
+++ b/src/synth/synth-expr.adb
@@ -1844,6 +1844,16 @@ package body Synth.Expr is
Acc := Allocate_By_Type (T);
return Create_Value_Access (Expr_Type, Acc);
end;
+ when Iir_Kind_Allocator_By_Expression =>
+ declare
+ V : Value_Acc;
+ Acc : Heap_Index;
+ begin
+ V := Synth_Expression_With_Type
+ (Syn_Inst, Get_Expression (Expr), Expr_Type.Acc_Acc);
+ Acc := Allocate_By_Value (V);
+ return Create_Value_Access (Expr_Type, Acc);
+ end;
when Iir_Kind_Overflow_Literal =>
declare
N : Net;
diff --git a/src/synth/synth-heap.adb b/src/synth/synth-heap.adb
index d92d4c561..27d5fb787 100644
--- a/src/synth/synth-heap.adb
+++ b/src/synth/synth-heap.adb
@@ -66,10 +66,36 @@ package body Synth.Heap is
return Heap_Table.Last;
end Allocate_By_Type;
+ function Allocate_By_Value (V : Value_Acc) return Value_Acc is
+ begin
+ case V.Kind is
+ when Value_Net
+ | Value_Wire =>
+ raise Internal_Error;
+ when Value_Discrete =>
+ return new Value_Type'
+ (Kind => Value_Discrete, Typ => V.Typ, Scal => V.Scal);
+ when Value_Array
+ | Value_Const_Array =>
+ declare
+ Arr : Value_Array_Acc;
+ begin
+ Arr := new Value_Array_Type (V.Arr.Len);
+ for I in Arr.V'Range loop
+ Arr.V (I) := Allocate_By_Value (V.Arr.V (I));
+ end loop;
+ return new Value_Type'
+ (Kind => Value_Const_Array, Typ => V.Typ, Arr => Arr);
+ end;
+ when others =>
+ raise Internal_Error;
+ end case;
+ end Allocate_By_Value;
+
function Allocate_By_Value (V : Value_Acc) return Heap_Index is
begin
- raise Internal_Error;
- return Null_Heap_Index;
+ Heap_Table.Append (Allocate_By_Value (V));
+ return Heap_Table.Last;
end Allocate_By_Value;
function Synth_Dereference (Idx : Heap_Index) return Value_Acc is