diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-04-01 23:12:30 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-04-01 23:12:30 +0200 |
commit | 345a2a99fac5291417c1f477bdfd6caad7ee71a9 (patch) | |
tree | 2e0077047d02166f7d8a32e8c027262c9da4e21c | |
parent | 2c66a8bd567a50f4eb2e4bb3d35e9e3dd1e10ff5 (diff) | |
download | ghdl-345a2a99fac5291417c1f477bdfd6caad7ee71a9.tar.gz ghdl-345a2a99fac5291417c1f477bdfd6caad7ee71a9.tar.bz2 ghdl-345a2a99fac5291417c1f477bdfd6caad7ee71a9.zip |
synth: use more Dim_Type.
-rw-r--r-- | src/synth/synth-decls.adb | 6 | ||||
-rw-r--r-- | src/synth/synth-expr.adb | 23 | ||||
-rw-r--r-- | src/synth/synth-expr.ads | 2 | ||||
-rw-r--r-- | src/synth/synth-stmts.adb | 2 | ||||
-rw-r--r-- | src/synth/synth-values.adb | 8 | ||||
-rw-r--r-- | src/synth/synth-values.ads | 12 |
6 files changed, 27 insertions, 26 deletions
diff --git a/src/synth/synth-decls.adb b/src/synth/synth-decls.adb index 704e6a65d..ff3556ae3 100644 --- a/src/synth/synth-decls.adb +++ b/src/synth/synth-decls.adb @@ -94,7 +94,7 @@ package body Synth.Decls is if El_Typ.Kind in Type_Nets and then Ndims = 1 then Typ := Create_Unbounded_Vector (El_Typ); else - Typ := Create_Unbounded_Array (Iir_Index32 (Ndims), El_Typ); + Typ := Create_Unbounded_Array (Dim_Type (Ndims), El_Typ); end if; return Typ; end Synth_Array_Type_Definition; @@ -325,10 +325,10 @@ package body Synth.Decls is Etyp := Get_Value_Type (Syn_Inst, El_Type); if Get_Index_Constraint_Flag (Atype) then Bnds := Create_Bound_Array - (Iir_Index32 (Get_Nbr_Elements (St_Indexes))); + (Dim_Type (Get_Nbr_Elements (St_Indexes))); for I in Flist_First .. Flist_Last (St_Indexes) loop St_El := Get_Index_Type (St_Indexes, I); - Bnds.D (Iir_Index32 (I + 1)) := + Bnds.D (Dim_Type (I + 1)) := Synth_Bounds_From_Range (Syn_Inst, St_El); end loop; return Create_Array_Type (Bnds, Etyp); diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index 8dcd8d058..55d89fbb9 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -292,15 +292,15 @@ package body Synth.Expr is end if; end Get_Index_Offset; - function Get_Array_Bound (Typ : Type_Acc; Dim : Natural) + function Get_Array_Bound (Typ : Type_Acc; Dim : Dim_Type) return Bound_Type is begin case Typ.Kind is when Type_Vector => - pragma Assert (Dim = 0); + pragma Assert (Dim = 1); return Typ.Vbound; when Type_Array => - return Typ.Abounds.D (Iir_Index32 (Dim + 1)); + return Typ.Abounds.D (Dim); when others => raise Internal_Error; end case; @@ -333,7 +333,7 @@ package body Synth.Expr is when Type_Array => declare Bnds : constant Bound_Array_Acc := Typ.Abounds; - Res : Stride_Array (1 .. Dim_Type (Bnds.Len)); + Res : Stride_Array (1 .. Bnds.Len); Stride : Iir_Index32; begin Stride := 1; @@ -358,7 +358,7 @@ package body Synth.Expr is Dim : Dim_Type; Const_P : out Boolean) is - Bound : constant Bound_Type := Get_Array_Bound (Typ, Natural (Dim - 1)); + Bound : constant Bound_Type := Get_Array_Bound (Typ, Dim); El_Typ : constant Type_Acc := Get_Array_Element (Typ); Stride : constant Iir_Index32 := Strides (Dim); Value : Node; @@ -829,14 +829,15 @@ package body Synth.Expr is function Synth_Array_Bounds (Syn_Inst : Synth_Instance_Acc; Atype : Node; - Dim : Natural) return Bound_Type + Dim : Dim_Type) return Bound_Type is Info : constant Sim_Info_Acc := Get_Info (Atype); begin if Info = null then pragma Assert (Get_Type_Declarator (Atype) = Null_Node); declare - Index_Type : constant Node := Get_Index_Type (Atype, Dim); + Index_Type : constant Node := + Get_Index_Type (Atype, Natural (Dim - 1)); begin return Synth_Bounds_From_Range (Syn_Inst, Index_Type); end; @@ -846,10 +847,10 @@ package body Synth.Expr is begin case Bnds.Typ.Kind is when Type_Vector => - pragma Assert (Dim = 0); + pragma Assert (Dim = 1); return Bnds.Typ.Vbound; when Type_Array => - return Bnds.Typ.Abounds.D (Iir_Index32 (Dim + 1)); + return Bnds.Typ.Abounds.D (Dim); when others => raise Internal_Error; end case; @@ -953,7 +954,7 @@ package body Synth.Expr is Val : Value_Acc; begin -- Allocate the result. - Bnd := Synth_Array_Bounds (Syn_Inst, Aggr_Type, 0); + Bnd := Synth_Array_Bounds (Syn_Inst, Aggr_Type, 1); pragma Assert (Bnd.Len = Uns32 (Last + 1)); if El_Typ.Kind in Type_Nets then @@ -1922,7 +1923,7 @@ package body Synth.Expr is Bounds := Str_Typ.Abounds.D (1); when Type_Unbounded_Vector | Type_Unbounded_Array => - Bounds := Synth_Array_Bounds (Syn_Inst, Str_Type, 0); + Bounds := Synth_Array_Bounds (Syn_Inst, Str_Type, 1); when others => raise Internal_Error; end case; diff --git a/src/synth/synth-expr.ads b/src/synth/synth-expr.ads index ed419ab76..35c1acc0e 100644 --- a/src/synth/synth-expr.ads +++ b/src/synth/synth-expr.ads @@ -84,7 +84,7 @@ package Synth.Expr is function Synth_Array_Bounds (Syn_Inst : Synth_Instance_Acc; Atype : Node; - Dim : Natural) return Bound_Type; + Dim : Dim_Type) return Bound_Type; function Synth_Discrete_Range_Expression (L : Int64; R : Int64; Dir : Iir_Direction) return Discrete_Range_Type; diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb index 36b5deeba..6c3974a16 100644 --- a/src/synth/synth-stmts.adb +++ b/src/synth/synth-stmts.adb @@ -345,7 +345,7 @@ package body Synth.Stmts is Get_Value_Type (Syn_Inst, Get_Base_Type (Targ_Type)); case Base_Typ.Kind is when Type_Unbounded_Vector => - Bnd := Expr.Synth_Array_Bounds (Syn_Inst, Targ_Type, 0); + Bnd := Expr.Synth_Array_Bounds (Syn_Inst, Targ_Type, 1); return Target_Info' (Kind => Target_Aggregate, Targ_Type => Create_Vector_Type (Bnd, Base_Typ.Uvec_El), diff --git a/src/synth/synth-values.adb b/src/synth/synth-values.adb index f9fd187cb..2fbdd0d6a 100644 --- a/src/synth/synth-values.adb +++ b/src/synth/synth-values.adb @@ -343,7 +343,7 @@ package body Synth.Values is El); end Create_Vec_Type_By_Length; - function Create_Bound_Array (Ndims : Iir_Index32) return Bound_Array_Acc + function Create_Bound_Array (Ndims : Dim_Type) return Bound_Array_Acc is use System; subtype Data_Type is Bound_Array (Ndims); @@ -388,7 +388,7 @@ package body Synth.Values is Arr_El => El_Type))); end Create_Array_Type; - function Create_Unbounded_Array (Ndim : Iir_Index32; El_Type : Type_Acc) + function Create_Unbounded_Array (Ndim : Dim_Type; El_Type : Type_Acc) return Type_Acc is subtype Unbounded_Type_Type is Type_Type (Type_Unbounded_Array); @@ -438,7 +438,7 @@ package body Synth.Values is end if; return Typ.Vbound; when Type_Array => - return Typ.Abounds.D (Iir_Index32 (Dim)); + return Typ.Abounds.D (Dim); when others => raise Internal_Error; end case; @@ -850,7 +850,7 @@ package body Synth.Values is return Atype.W; end Get_Type_Width; - function Get_Bound_Length (T : Type_Acc; Dim : Iir_Index32) return Width is + function Get_Bound_Length (T : Type_Acc; Dim : Dim_Type) return Width is begin case T.Kind is when Type_Vector => diff --git a/src/synth/synth-values.ads b/src/synth/synth-values.ads index 2bc2e9940..c7eef52c4 100644 --- a/src/synth/synth-values.ads +++ b/src/synth/synth-values.ads @@ -58,9 +58,9 @@ package Synth.Values is Len : Width; end record; - type Bound_Array_Type is array (Iir_Index32 range <>) of Bound_Type; + type Bound_Array_Type is array (Dim_Type range <>) of Bound_Type; - type Bound_Array (Len : Iir_Index32) is record + type Bound_Array (Len : Dim_Type) is record D : Bound_Array_Type (1 .. Len); end record; @@ -129,7 +129,7 @@ package Synth.Values is Abounds : Bound_Array_Acc; Arr_El : Type_Acc; when Type_Unbounded_Array => - Uarr_Ndim : Iir_Index32; + Uarr_Ndim : Dim_Type; Uarr_El : Type_Acc; when Type_Record => Rec : Rec_El_Array_Acc; @@ -258,10 +258,10 @@ package Synth.Values is return Type_Acc; function Create_Unbounded_Vector (El_Type : Type_Acc) return Type_Acc; function Create_Slice_Type (W : Width; El_Type : Type_Acc) return Type_Acc; - function Create_Bound_Array (Ndims : Iir_Index32) return Bound_Array_Acc; + function Create_Bound_Array (Ndims : Dim_Type) return Bound_Array_Acc; function Create_Array_Type (Bnd : Bound_Array_Acc; El_Type : Type_Acc) return Type_Acc; - function Create_Unbounded_Array (Ndim : Iir_Index32; El_Type : Type_Acc) + function Create_Unbounded_Array (Ndim : Dim_Type; El_Type : Type_Acc) return Type_Acc; function Create_Rec_El_Array (Nels : Iir_Index32) return Rec_El_Array_Acc; @@ -353,7 +353,7 @@ package Synth.Values is function Get_Array_Flat_Length (Typ : Type_Acc) return Width; -- Return length of dimension DIM of type T. - function Get_Bound_Length (T : Type_Acc; Dim : Iir_Index32) return Width; + function Get_Bound_Length (T : Type_Acc; Dim : Dim_Type) return Width; function Is_Matching_Bounds (L, R : Type_Acc) return Boolean; |