From afc6c3378460fc07e0e2d04007fab63acc2290e3 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Fri, 22 Nov 2019 19:04:13 +0100 Subject: synth: handle allocator_by_expression. --- src/synth/synth-expr.adb | 10 ++++++++++ src/synth/synth-heap.adb | 30 ++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'src') 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 -- cgit v1.2.3