aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-05-27 17:50:12 +0200
committerTristan Gingold <tgingold@free.fr>2020-05-28 17:47:48 +0200
commit691d4875f0710e0603a7ae563600f9a6c041c6d6 (patch)
tree529071dca47189003ebc87cc6e1c6afd5e12b975
parent58756712b9465c24e1d2a198e5a03aae7ebbf774 (diff)
downloadghdl-691d4875f0710e0603a7ae563600f9a6c041c6d6.tar.gz
ghdl-691d4875f0710e0603a7ae563600f9a6c041c6d6.tar.bz2
ghdl-691d4875f0710e0603a7ae563600f9a6c041c6d6.zip
ortho: add a length parameter to start_array_aggr.
-rw-r--r--src/ortho/debug/ortho_debug-disp.adb51
-rw-r--r--src/ortho/debug/ortho_debug.adb35
-rw-r--r--src/ortho/debug/ortho_debug.private.ads10
-rw-r--r--src/ortho/gcc/ortho-lang-49.c36
-rw-r--r--src/ortho/gcc/ortho-lang-5.c36
-rw-r--r--src/ortho/gcc/ortho-lang-6.c36
-rw-r--r--src/ortho/gcc/ortho-lang-7.c36
-rw-r--r--src/ortho/gcc/ortho-lang-8.c36
-rw-r--r--src/ortho/gcc/ortho-lang-9.c36
-rw-r--r--src/ortho/gcc/ortho_gcc.ads3
-rw-r--r--src/ortho/llvm-nodebug/ortho_llvm.adb5
-rw-r--r--src/ortho/llvm35/ortho_llvm.adb5
-rw-r--r--src/ortho/llvm35/ortho_llvm.ads3
-rw-r--r--src/ortho/llvm4-nodebug/ortho_llvm.adb5
-rw-r--r--src/ortho/llvm4-nodebug/ortho_llvm.ads3
-rw-r--r--src/ortho/mcode/ortho_code-consts.adb42
-rw-r--r--src/ortho/mcode/ortho_code-consts.ads6
-rw-r--r--src/ortho/mcode/ortho_code-types.adb1
-rw-r--r--src/ortho/mcode/ortho_code-x86-emits.adb2
-rw-r--r--src/ortho/mcode/ortho_mcode.adb6
-rw-r--r--src/ortho/mcode/ortho_mcode.ads3
-rw-r--r--src/ortho/oread/ortho_front.adb61
-rw-r--r--src/ortho/ortho_nodes.common.ads3
-rw-r--r--src/vhdl/translate/trans-chap3.adb10
-rw-r--r--src/vhdl/translate/trans-chap3.ads3
-rw-r--r--src/vhdl/translate/trans-chap7.adb35
-rw-r--r--src/vhdl/translate/trans-chap8.adb19
-rw-r--r--src/vhdl/translate/trans-helpers2.adb8
-rw-r--r--src/vhdl/translate/trans-rtis.adb28
29 files changed, 327 insertions, 236 deletions
diff --git a/src/ortho/debug/ortho_debug-disp.adb b/src/ortho/debug/ortho_debug-disp.adb
index e2e5793f9..465de8f7e 100644
--- a/src/ortho/debug/ortho_debug-disp.adb
+++ b/src/ortho/debug/ortho_debug-disp.adb
@@ -582,36 +582,55 @@ package body Ortho_Debug.Disp is
Put (".");
Disp_Ident (C.Off_Field.Ident);
Put (")");
- when OC_Aggregate =>
+ when OC_Array_Aggregate =>
declare
El : O_Cnode;
El_Type : O_Tnode;
- Field : O_Fnode;
begin
- Put ('{');
- El := C.Aggr_Els;
+ El := C.Arr_Els;
case C.Ctype.Kind is
- when ON_Record_Type =>
- Field := C.Ctype.Elements;
- El_Type := Field.Ftype;
when ON_Array_Sub_Type =>
- Field := null;
El_Type := C.Ctype.Base_Type.El_Type;
+ when ON_Array_Type =>
+ El_Type := C.Ctype.El_Type;
when others =>
raise Program_Error;
end case;
+ Put ('[');
+ Put_Trim (Unsigned_32'Image (C.Arr_Len));
+ Put (']');
+ Put ('{');
if El /= null then
loop
Set_Mark;
- if Field /= null then
- if Disp_All_Types then
- Put ('.');
- Disp_Ident (Field.Ident);
- Put (" = ");
- end if;
- El_Type := Field.Ftype;
- Field := Field.Next;
+ Disp_Cnode (El.Aggr_Value, El_Type);
+ El := El.Aggr_Next;
+ exit when El = null;
+ Put (", ");
+ end loop;
+ end if;
+ Put ('}');
+ end;
+ when OC_Record_Aggregate =>
+ declare
+ El : O_Cnode;
+ El_Type : O_Tnode;
+ Field : O_Fnode;
+ begin
+ Put ('{');
+ El := C.Rec_Els;
+ pragma Assert (C.Ctype.Kind = ON_Record_Type);
+ Field := C.Ctype.Elements;
+ if El /= null then
+ loop
+ Set_Mark;
+ if Disp_All_Types then
+ Put ('.');
+ Disp_Ident (Field.Ident);
+ Put (" = ");
end if;
+ El_Type := Field.Ftype;
+ Field := Field.Next;
Disp_Cnode (El.Aggr_Value, El_Type);
El := El.Aggr_Next;
exit when El = null;
diff --git a/src/ortho/debug/ortho_debug.adb b/src/ortho/debug/ortho_debug.adb
index bb32197a4..30a9478ef 100644
--- a/src/ortho/debug/ortho_debug.adb
+++ b/src/ortho/debug/ortho_debug.adb
@@ -811,17 +811,17 @@ package body Ortho_Debug is
procedure Start_Record_Aggr (List : out O_Record_Aggr_List; Atype : O_Tnode)
is
- subtype O_Cnode_Aggregate is O_Cnode_Type (OC_Aggregate);
+ subtype O_Cnode_Aggregate is O_Cnode_Type (OC_Record_Aggregate);
Res : O_Cnode;
begin
if Atype.Kind /= ON_Record_Type then
raise Type_Error;
end if;
Check_Complete_Type (Atype);
- Res := new O_Cnode_Aggregate'(Kind => OC_Aggregate,
+ Res := new O_Cnode_Aggregate'(Kind => OC_Record_Aggregate,
Ctype => Atype,
Ref => False,
- Aggr_Els => null);
+ Rec_Els => null);
List.Res := Res;
List.Last := null;
List.Field := Atype.Elements;
@@ -844,7 +844,7 @@ package body Ortho_Debug is
Aggr_Value => Value,
Aggr_Next => null);
if List.Last = null then
- List.Res.Aggr_Els := El;
+ List.Res.Rec_Els := El;
else
List.Last.Aggr_Next := El;
end if;
@@ -863,22 +863,31 @@ package body Ortho_Debug is
Res := List.Res;
end Finish_Record_Aggr;
- procedure Start_Array_Aggr (List : out O_Array_Aggr_List; Atype : O_Tnode)
+ procedure Start_Array_Aggr
+ (List : out O_Array_Aggr_List; Atype : O_Tnode; Len : Unsigned_32)
is
- subtype O_Cnode_Aggregate is O_Cnode_Type (OC_Aggregate);
+ subtype O_Cnode_Aggregate is O_Cnode_Type (OC_Array_Aggregate);
Res : O_Cnode;
begin
- if Atype.Kind /= ON_Array_Sub_Type then
- raise Type_Error;
- end if;
+ case Atype.Kind is
+ when ON_Array_Sub_Type =>
+ if Atype.Length.U_Val /= Unsigned_64 (Len) then
+ raise Type_Error;
+ end if;
+ List.El_Type := Atype.Base_Type.El_Type;
+ when ON_Array_Type =>
+ List.El_Type := Atype.El_Type;
+ when others =>
+ raise Type_Error;
+ end case;
Check_Complete_Type (Atype);
- Res := new O_Cnode_Aggregate'(Kind => OC_Aggregate,
+ Res := new O_Cnode_Aggregate'(Kind => OC_Array_Aggregate,
Ctype => Atype,
Ref => False,
- Aggr_Els => null);
+ Arr_Len => Len,
+ Arr_Els => null);
List.Res := Res;
List.Last := null;
- List.El_Type := Atype.Base_Type.El_Type;
end Start_Array_Aggr;
procedure New_Array_Aggr_El (List : in out O_Array_Aggr_List;
@@ -894,7 +903,7 @@ package body Ortho_Debug is
Aggr_Value => Value,
Aggr_Next => null);
if List.Last = null then
- List.Res.Aggr_Els := El;
+ List.Res.Arr_Els := El;
else
List.Last.Aggr_Next := El;
end if;
diff --git a/src/ortho/debug/ortho_debug.private.ads b/src/ortho/debug/ortho_debug.private.ads
index b505ff434..7586319ff 100644
--- a/src/ortho/debug/ortho_debug.private.ads
+++ b/src/ortho/debug/ortho_debug.private.ads
@@ -135,7 +135,8 @@ private
OC_Alignof_Lit,
OC_Offsetof_Lit,
OC_Default_Lit,
- OC_Aggregate,
+ OC_Array_Aggregate,
+ OC_Record_Aggregate,
OC_Aggr_Element,
OC_Union_Aggr,
OC_Address,
@@ -170,8 +171,11 @@ private
S_Type : O_Tnode;
when OC_Offsetof_Lit =>
Off_Field : O_Fnode;
- when OC_Aggregate =>
- Aggr_Els : O_Cnode;
+ when OC_Array_Aggregate =>
+ Arr_Len : Unsigned_32;
+ Arr_Els : O_Cnode;
+ when OC_Record_Aggregate =>
+ Rec_Els : O_Cnode;
when OC_Union_Aggr =>
Uaggr_Field : O_Fnode;
Uaggr_Value : O_Cnode;
diff --git a/src/ortho/gcc/ortho-lang-49.c b/src/ortho/gcc/ortho-lang-49.c
index fc86d799f..7de15aea9 100644
--- a/src/ortho/gcc/ortho-lang-49.c
+++ b/src/ortho/gcc/ortho-lang-49.c
@@ -1224,7 +1224,11 @@ finish_access_type (tree atype, tree dtype)
tree
new_array_type (tree el_type, tree index_type)
{
- return build_array_type (el_type, index_type);
+ /* Incomplete array. */
+ tree range_type;
+
+ range_type = build_range_type (index_type, size_zero_node, NULL_TREE);
+ return build_array_type (el_type, range_type);
}
@@ -1234,10 +1238,10 @@ new_constrained_array_type (tree atype, tree length)
tree range_type;
tree index_type;
tree len;
- tree one;
tree res;
index_type = TYPE_DOMAIN (atype);
+
if (integer_zerop (length))
{
/* Handle null array, by creating a one-length array... */
@@ -1245,11 +1249,10 @@ new_constrained_array_type (tree atype, tree length)
}
else
{
- one = build_int_cstu (index_type, 1);
- len = build2 (MINUS_EXPR, index_type, length, one);
- len = fold (len);
+ len = fold_build2 (MINUS_EXPR, index_type,
+ convert (index_type, length),
+ convert (index_type, size_one_node));
}
-
range_type = build_range_type (index_type, size_zero_node, len);
res = build_array_type (TREE_TYPE (atype), range_type);
@@ -1349,19 +1352,13 @@ struct GTY(()) o_array_aggr_list
};
void
-start_array_aggr (struct o_array_aggr_list *list, tree atype)
+start_array_aggr (struct o_array_aggr_list *list, tree atype, unsigned len)
{
- tree nelts;
- unsigned HOST_WIDE_INT n;
+ tree length;
- list->atype = atype;
- list->elts = NULL;
-
- nelts = array_type_nelts (atype);
- gcc_assert (nelts != NULL_TREE && tree_fits_uhwi_p (nelts));
-
- n = tree_to_uhwi (nelts) + 1;
- vec_alloc(list->elts, n);
+ length = new_unsigned_literal (sizetype, len);
+ list->atype = new_constrained_array_type (atype, length);
+ vec_alloc(list->elts, len);
}
void
@@ -1638,6 +1635,11 @@ finish_init_value (tree *decl, tree val)
DECL_INITIAL (*decl) = val;
TREE_CONSTANT (val) = 1;
TREE_STATIC (*decl) = 1;
+
+ /* The variable may be declared with an incomplete array, so be sure it
+ has a completed type. */
+ TREE_TYPE (*decl) = TREE_TYPE (val);
+
rest_of_decl_compilation (*decl, current_function_decl == NULL_TREE, 0);
}
diff --git a/src/ortho/gcc/ortho-lang-5.c b/src/ortho/gcc/ortho-lang-5.c
index 927b9594a..52fd049f7 100644
--- a/src/ortho/gcc/ortho-lang-5.c
+++ b/src/ortho/gcc/ortho-lang-5.c
@@ -1210,7 +1210,11 @@ finish_access_type (tree atype, tree dtype)
tree
new_array_type (tree el_type, tree index_type)
{
- return build_array_type (el_type, index_type);
+ /* Incomplete array. */
+ tree range_type;
+
+ range_type = build_range_type (index_type, size_zero_node, NULL_TREE);
+ return build_array_type (el_type, range_type);
}
@@ -1220,10 +1224,10 @@ new_constrained_array_type (tree atype, tree length)
tree range_type;
tree index_type;
tree len;
- tree one;
tree res;
index_type = TYPE_DOMAIN (atype);
+
if (integer_zerop (length))
{
/* Handle null array, by creating a one-length array... */
@@ -1231,11 +1235,10 @@ new_constrained_array_type (tree atype, tree length)
}
else
{
- one = build_int_cstu (index_type, 1);
- len = build2 (MINUS_EXPR, index_type, length, one);
- len = fold (len);
+ len = fold_build2 (MINUS_EXPR, index_type,
+ convert (index_type, length),
+ convert (index_type, size_one_node));
}
-
range_type = build_range_type (index_type, size_zero_node, len);
res = build_array_type (TREE_TYPE (atype), range_type);
@@ -1335,19 +1338,13 @@ struct GTY(()) o_array_aggr_list
};
void
-start_array_aggr (struct o_array_aggr_list *list, tree atype)
+start_array_aggr (struct o_array_aggr_list *list, tree atype, unsigned len)
{
- tree nelts;
- unsigned HOST_WIDE_INT n;
+ tree length;
- list->atype = atype;
- list->elts = NULL;
-
- nelts = array_type_nelts (atype);
- gcc_assert (nelts != NULL_TREE && tree_fits_uhwi_p (nelts));
-
- n = tree_to_uhwi (nelts) + 1;
- vec_alloc(list->elts, n);
+ length = new_unsigned_literal (sizetype, len);
+ list->atype = new_constrained_array_type (atype, length);
+ vec_alloc(list->elts, len);
}
void
@@ -1624,6 +1621,11 @@ finish_init_value (tree *decl, tree val)
DECL_INITIAL (*decl) = val;
TREE_CONSTANT (val) = 1;
TREE_STATIC (*decl) = 1;
+
+ /* The variable may be declared with an incomplete array, so be sure it
+ has a completed type. */
+ TREE_TYPE (*decl) = TREE_TYPE (val);
+
rest_of_decl_compilation (*decl, current_function_decl == NULL_TREE, 0);
}
diff --git a/src/ortho/gcc/ortho-lang-6.c b/src/ortho/gcc/ortho-lang-6.c
index d2d247976..f78017da4 100644
--- a/src/ortho/gcc/ortho-lang-6.c
+++ b/src/ortho/gcc/ortho-lang-6.c
@@ -1210,7 +1210,11 @@ finish_access_type (tree atype, tree dtype)
tree
new_array_type (tree el_type, tree index_type)
{
- return build_array_type (el_type, index_type);
+ /* Incomplete array. */
+ tree range_type;
+
+ range_type = build_range_type (index_type, size_zero_node, NULL_TREE);
+ return build_array_type (el_type, range_type);
}
@@ -1220,10 +1224,10 @@ new_constrained_array_type (tree atype, tree length)
tree range_type;
tree index_type;
tree len;
- tree one;
tree res;
index_type = TYPE_DOMAIN (atype);
+
if (integer_zerop (length))
{
/* Handle null array, by creating a one-length array... */
@@ -1231,11 +1235,10 @@ new_constrained_array_type (tree atype, tree length)
}
else
{
- one = build_int_cstu (index_type, 1);
- len = build2 (MINUS_EXPR, index_type, length, one);
- len = fold (len);
+ len = fold_build2 (MINUS_EXPR, index_type,
+ convert (index_type, length),
+ convert (index_type, size_one_node));
}
-
range_type = build_range_type (index_type, size_zero_node, len);
res = build_array_type (TREE_TYPE (atype), range_type);
@@ -1335,19 +1338,13 @@ struct GTY(()) o_array_aggr_list
};
void
-start_array_aggr (struct o_array_aggr_list *list, tree atype)
+start_array_aggr (struct o_array_aggr_list *list, tree atype, unsigned len)
{
- tree nelts;
- unsigned HOST_WIDE_INT n;
+ tree length;
- list->atype = atype;
- list->elts = NULL;
-
- nelts = array_type_nelts (atype);
- gcc_assert (nelts != NULL_TREE && tree_fits_uhwi_p (nelts));
-
- n = tree_to_uhwi (nelts) + 1;
- vec_alloc(list->elts, n);
+ length = new_unsigned_literal (sizetype, len);
+ list->atype = new_constrained_array_type (atype, length);
+ vec_alloc(list->elts, len);
}
void
@@ -1624,6 +1621,11 @@ finish_init_value (tree *decl, tree val)
DECL_INITIAL (*decl) = val;
TREE_CONSTANT (val) = 1;
TREE_STATIC (*decl) = 1;
+
+ /* The variable may be declared with an incomplete array, so be sure it
+ has a completed type. */
+ TREE_TYPE (*decl) = TREE_TYPE (val);
+
rest_of_decl_compilation (*decl, current_function_decl == NULL_TREE, 0);
}
diff --git a/src/ortho/gcc/ortho-lang-7.c b/src/ortho/gcc/ortho-lang-7.c
index 28df56c07..92bfc8d46 100644
--- a/src/ortho/gcc/ortho-lang-7.c
+++ b/src/ortho/gcc/ortho-lang-7.c
@@ -1222,7 +1222,11 @@ finish_access_type (tree atype, tree dtype)
tree
new_array_type (tree el_type, tree index_type)
{
- return build_array_type (el_type, index_type);
+ /* Incomplete array. */
+ tree range_type;
+
+ range_type = build_range_type (index_type, size_zero_node, NULL_TREE);
+ return build_array_type (el_type, range_type);
}
@@ -1232,10 +1236,10 @@ new_constrained_array_type (tree atype, tree length)
tree range_type;
tree index_type;
tree len;
- tree one;
tree res;
index_type = TYPE_DOMAIN (atype);
+
if (integer_zerop (length))
{
/* Handle null array, by creating a one-length array... */
@@ -1243,11 +1247,10 @@ new_constrained_array_type (tree atype, tree length)
}
else
{
- one = build_int_cstu (index_type, 1);
- len = build2 (MINUS_EXPR, index_type, length, one);
- len = fold (len);
+ len = fold_build2 (MINUS_EXPR, index_type,
+ convert (index_type, length),
+ convert (index_type, size_one_node));
}
-
range_type = build_range_type (index_type, size_zero_node, len);
res = build_array_type (TREE_TYPE (atype), range_type);
@@ -1347,19 +1350,13 @@ struct GTY(()) o_array_aggr_list
};
void
-start_array_aggr (struct o_array_aggr_list *list, tree atype)
+start_array_aggr (struct o_array_aggr_list *list, tree atype, unsigned len)
{
- tree nelts;
- unsigned HOST_WIDE_INT n;
+ tree length;
- list->atype = atype;
- list->elts = NULL;
-
- nelts = array_type_nelts (atype);
- gcc_assert (nelts != NULL_TREE && tree_fits_uhwi_p (nelts));
-
- n = tree_to_uhwi (nelts) + 1;
- vec_alloc(list->elts, n);
+ length = new_unsigned_literal (sizetype, len);
+ list->atype = new_constrained_array_type (atype, length);
+ vec_alloc(list->elts, len);
}
void
@@ -1636,6 +1633,11 @@ finish_init_value (tree *decl, tree val)
DECL_INITIAL (*decl) = val;
TREE_CONSTANT (val) = 1;
TREE_STATIC (*decl) = 1;
+
+ /* The variable may be declared with an incomplete array, so be sure it
+ has a completed type. */
+ TREE_TYPE (*decl) = TREE_TYPE (val);
+
rest_of_decl_compilation (*decl, current_function_decl == NULL_TREE, 0);
}
diff --git a/src/ortho/gcc/ortho-lang-8.c b/src/ortho/gcc/ortho-lang-8.c
index 1c2b0c0b8..5b253aee2 100644
--- a/src/ortho/gcc/ortho-lang-8.c
+++ b/src/ortho/gcc/ortho-lang-8.c
@@ -1223,7 +1223,11 @@ finish_access_type (tree atype, tree dtype)
tree
new_array_type (tree el_type, tree index_type)
{
- return build_array_type (el_type, index_type);
+ /* Incomplete array. */
+ tree range_type;
+
+ range_type = build_range_type (index_type, size_zero_node, NULL_TREE);
+ return build_array_type (el_type, range_type);
}
@@ -1233,10 +1237,10 @@ new_constrained_array_type (tree atype, tree length)
tree range_type;
tree index_type;
tree len;
- tree one;
tree res;
index_type = TYPE_DOMAIN (atype);
+
if (integer_zerop (length))
{
/* Handle null array, by creating a one-length array... */
@@ -1244,11 +1248,10 @@ new_constrained_array_type (tree atype, tree length)
}
else
{
- one = build_int_cstu (index_type, 1);
- len = build2 (MINUS_EXPR, index_type, length, one);
- len = fold (len);
+ len = fold_build2 (MINUS_EXPR, index_type,
+ convert (index_type, length),
+ convert (index_type, size_one_node));
}
-
range_type = build_range_type (index_type, size_zero_node, len);
res = build_array_type (TREE_TYPE (atype), range_type);
@@ -1348,19 +1351,13 @@ struct GTY(()) o_array_aggr_list
};
void
-start_array_aggr (struct o_array_aggr_list *list, tree atype)
+start_array_aggr (struct o_array_aggr_list *list, tree atype, unsigned len)
{
- tree nelts;
- unsigned HOST_WIDE_INT n;
+ tree length;
- list->atype = atype;
- list->elts = NULL;
-
- nelts = array_type_nelts (atype);
- gcc_assert (nelts != NULL_TREE && tree_fits_uhwi_p (nelts));
-
- n = tree_to_uhwi (nelts) + 1;
- vec_alloc(list->elts, n);
+ length = new_unsigned_literal (sizetype, len);
+ list->atype = new_constrained_array_type (atype, length);
+ vec_alloc(list->elts, len);
}
void
@@ -1637,6 +1634,11 @@ finish_init_value (tree *decl, tree val)
DECL_INITIAL (*decl) = val;
TREE_CONSTANT (val) = 1;
TREE_STATIC (*decl) = 1;
+
+ /* The variable may be declared with an incomplete array, so be sure it
+ has a completed type. */
+ TREE_TYPE (*decl) = TREE_TYPE (val);
+
rest_of_decl_compilation (*decl, current_function_decl == NULL_TREE, 0);
}
diff --git a/src/ortho/gcc/ortho-lang-9.c b/src/ortho/gcc/ortho-lang-9.c
index f9eac7082..80e793125 100644
--- a/src/ortho/gcc/ortho-lang-9.c
+++ b/src/ortho/gcc/ortho-lang-9.c
@@ -1223,7 +1223,11 @@ finish_access_type (tree atype, tree dtype)
tree
new_array_type (tree el_type, tree index_type)
{
- return build_array_type (el_type, index_type);
+ /* Incomplete array. */
+ tree range_type;
+
+ range_type = build_range_type (index_type, size_zero_node, NULL_TREE);
+ return build_array_type (el_type, range_type);
}
@@ -1233,10 +1237,10 @@ new_constrained_array_type (tree atype, tree length)
tree range_type;
tree index_type;
tree len;
- tree one;
tree res;
index_type = TYPE_DOMAIN (atype);
+
if (integer_zerop (length))
{
/* Handle null array, by creating a one-length array... */
@@ -1244,11 +1248,10 @@ new_constrained_array_type (tree atype, tree length)
}
else
{
- one = build_int_cstu (index_type, 1);
- len = build2 (MINUS_EXPR, index_type, length, one);
- len = fold (len);
+ len = fold_build2 (MINUS_EXPR, index_type,
+ convert (index_type, length),
+ convert (index_type, size_one_node));
}
-
range_type = build_range_type (index_type, size_zero_node, len);
res = build_array_type (TREE_TYPE (atype), range_type);
@@ -1348,19 +1351,13 @@ struct GTY(()) o_array_aggr_list
};
void
-start_array_aggr (struct o_array_aggr_list *list, tree atype)
+start_array_aggr (struct o_array_aggr_list *list, tree atype, unsigned len)
{
- tree nelts;
- unsigned HOST_WIDE_INT n;
+ tree length;
- list->atype = atype;
- list->elts = NULL;
-
- nelts = array_type_nelts (atype);
- gcc_assert (nelts != NULL_TREE && tree_fits_uhwi_p (nelts));
-
- n = tree_to_uhwi (nelts) + 1;
- vec_alloc(list->elts, n);
+ length = new_unsigned_literal (sizetype, len);
+ list->atype = new_constrained_array_type (atype, length);
+ vec_alloc(list->elts, len);
}
void
@@ -1637,6 +1634,11 @@ finish_init_value (tree *decl, tree val)
DECL_INITIAL (*decl) = val;
TREE_CONSTANT (val) = 1;
TREE_STATIC (*decl) = 1;
+
+ /* The variable may be declared with an incomplete array, so be sure it
+ has a completed type. */
+ TREE_TYPE (*decl) = TREE_TYPE (val);
+
rest_of_decl_compilation (*decl, current_function_decl == NULL_TREE, 0);
}
diff --git a/src/ortho/gcc/ortho_gcc.ads b/src/ortho/gcc/ortho_gcc.ads
index 6273435dc..d5cbf51c1 100644
--- a/src/ortho/gcc/ortho_gcc.ads
+++ b/src/ortho/gcc/ortho_gcc.ads
@@ -159,7 +159,8 @@ package Ortho_Gcc is
procedure Finish_Record_Aggr (List : in out O_Record_Aggr_List;
Res : out O_Cnode);
- procedure Start_Array_Aggr (List : out O_Array_Aggr_List; Atype : O_Tnode);
+ procedure Start_Array_Aggr
+ (List : out O_Array_Aggr_List; Atype : O_Tnode; Len : Unsigned_32);
procedure New_Array_Aggr_El (List : in out O_Array_Aggr_List;
Value : O_Cnode);
procedure Finish_Array_Aggr (List : in out O_Array_Aggr_List;
diff --git a/src/ortho/llvm-nodebug/ortho_llvm.adb b/src/ortho/llvm-nodebug/ortho_llvm.adb
index 443b469aa..56b22f092 100644
--- a/src/ortho/llvm-nodebug/ortho_llvm.adb
+++ b/src/ortho/llvm-nodebug/ortho_llvm.adb
@@ -627,13 +627,12 @@ package body Ortho_LLVM is
----------------------
procedure Start_Array_Aggr
- (List : out O_Array_Aggr_List;
- Atype : O_Tnode)
+ (List : out O_Array_Aggr_List; Atype : O_Tnode; Len : Unsigned_32)
is
Llvm : constant TypeRef := Get_LLVM_Type (Atype);
begin
List := (Len => 0,
- Vals => new ValueRefArray (1 .. GetArrayLength (Llvm)),
+ Vals => new ValueRefArray (1 .. unsigned (Len)),
El_Type => GetElementType (Llvm),
Atype => Atype);
end Start_Array_Aggr;
diff --git a/src/ortho/llvm35/ortho_llvm.adb b/src/ortho/llvm35/ortho_llvm.adb
index 250870224..a4f4599e6 100644
--- a/src/ortho/llvm35/ortho_llvm.adb
+++ b/src/ortho/llvm35/ortho_llvm.adb
@@ -963,13 +963,12 @@ package body Ortho_LLVM is
----------------------
procedure Start_Array_Aggr
- (List : out O_Array_Aggr_List;
- Atype : O_Tnode)
+ (List : out O_Array_Aggr_List; Atype : O_Tnode; Len : Unsigned_32)
is
Llvm : constant TypeRef := Get_LLVM_Type (Atype);
begin
List := (Len => 0,
- Vals => new ValueRefArray (1 .. GetArrayLength (Llvm)),
+ Vals => new ValueRefArray (1 .. unsigned (Len)),
El_Type => GetElementType (Llvm),
Atype => Atype);
end Start_Array_Aggr;
diff --git a/src/ortho/llvm35/ortho_llvm.ads b/src/ortho/llvm35/ortho_llvm.ads
index 2779d0233..85f52b796 100644
--- a/src/ortho/llvm35/ortho_llvm.ads
+++ b/src/ortho/llvm35/ortho_llvm.ads
@@ -182,7 +182,8 @@ package Ortho_LLVM is
procedure Finish_Record_Aggr (List : in out O_Record_Aggr_List;
Res : out O_Cnode);
- procedure Start_Array_Aggr (List : out O_Array_Aggr_List; Atype : O_Tnode);
+ procedure Start_Array_Aggr
+ (List : out O_Array_Aggr_List; Atype : O_Tnode; Len : Unsigned_32);
procedure New_Array_Aggr_El (List : in out O_Array_Aggr_List;
Value : O_Cnode);
procedure Finish_Array_Aggr (List : in out O_Array_Aggr_List;
diff --git a/src/ortho/llvm4-nodebug/ortho_llvm.adb b/src/ortho/llvm4-nodebug/ortho_llvm.adb
index 2f0edca3c..68828497b 100644
--- a/src/ortho/llvm4-nodebug/ortho_llvm.adb
+++ b/src/ortho/llvm4-nodebug/ortho_llvm.adb
@@ -630,13 +630,12 @@ package body Ortho_LLVM is
----------------------
procedure Start_Array_Aggr
- (List : out O_Array_Aggr_List;
- Atype : O_Tnode)
+ (List : out O_Array_Aggr_List; Atype : O_Tnode; Len : Unsigned_32)
is
Llvm : constant TypeRef := Get_LLVM_Type (Atype);
begin
List := (Len => 0,
- Vals => new ValueRefArray (1 .. GetArrayLength (Llvm)),
+ Vals => new ValueRefArray (1 .. unsigned (Len)),
El_Type => GetElementType (Llvm),
Atype => Atype);
end Start_Array_Aggr;
diff --git a/src/ortho/llvm4-nodebug/ortho_llvm.ads b/src/ortho/llvm4-nodebug/ortho_llvm.ads
index 837f4846e..df30a5d8d 100644
--- a/src/ortho/llvm4-nodebug/ortho_llvm.ads
+++ b/src/ortho/llvm4-nodebug/ortho_llvm.ads
@@ -175,7 +175,8 @@ package Ortho_LLVM is
procedure Finish_Record_Aggr (List : in out O_Record_Aggr_List;
Res : out O_Cnode);
- procedure Start_Array_Aggr (List : out O_Array_Aggr_List; Atype : O_Tnode);
+ procedure Start_Array_Aggr
+ (List : out O_Array_Aggr_List; Atype : O_Tnode; Len : Unsigned_32);
procedure New_Array_Aggr_El (List : in out O_Array_Aggr_List;
Value : O_Cnode);
procedure Finish_Array_Aggr (List : in out O_Array_Aggr_List;
diff --git a/src/ortho/mcode/ortho_code-consts.adb b/src/ortho/mcode/ortho_code-consts.adb
index 1b2146dc4..dcb9c13be 100644
--- a/src/ortho/mcode/ortho_code-consts.adb
+++ b/src/ortho/mcode/ortho_code-consts.adb
@@ -420,20 +420,29 @@ package body Ortho_Code.Consts is
end Finish_Record_Aggr;
- procedure Start_Array_Aggr (List : out O_Array_Aggr_List; Atype : O_Tnode)
+ procedure Start_Array_Aggr
+ (List : out O_Array_Aggr_List; Arr_Type : O_Tnode; Len : Unsigned_32)
is
- Num : constant Uns32 := Get_Type_Subarray_Length (Atype);
Val : Int32;
begin
- Val := Els.Allocate (Integer (Num));
+ case Get_Type_Kind (Arr_Type) is
+ when OT_Subarray =>
+ pragma Assert (Uns32 (Len) = Get_Type_Subarray_Length (Arr_Type));
+ when OT_Ucarray =>
+ null;
+ when others =>
+ -- The type of an array aggregate must be an array type.
+ raise Syntax_Error;
+ end case;
+ Val := Els.Allocate (Integer (Len));
Cnodes.Append (Cnode_Common'(Kind => OC_Array,
- Lit_Type => Atype));
+ Lit_Type => Arr_Type));
List := (Res => Cnodes.Last,
El => Val,
- Len => Num);
+ Len => Uns32 (Len));
Cnodes.Append (To_Cnode_Common (Cnode_Aggr'(Els => Val,
- Nbr => Int32 (Num))));
+ Nbr => Int32 (Len))));
end Start_Array_Aggr;
procedure New_Array_Aggr_El (List : in out O_Array_Aggr_List;
@@ -658,6 +667,27 @@ package body Ortho_Code.Consts is
end case;
end Get_Const_Bytes;
+ function Get_Const_Size (Cst : O_Cnode) return Uns32
+ is
+ T : constant O_Tnode := Get_Const_Type (Cst);
+ begin
+ case Get_Type_Kind (T) is
+ when OT_Ucarray =>
+ declare
+ Len : constant Int32 := Get_Const_Aggr_Length (Cst);
+ El_Sz : Uns32;
+ begin
+ if Len = 0 then
+ return 0;
+ end if;
+ El_Sz := Get_Const_Size (Get_Const_Aggr_Element (Cst, 0));
+ return Uns32 (Len) * El_Sz;
+ end;
+ when others =>
+ return Get_Type_Size (T);
+ end case;
+ end Get_Const_Size;
+
procedure Mark (M : out Mark_Type) is
begin
M.Cnode := Cnodes.Last;
diff --git a/src/ortho/mcode/ortho_code-consts.ads b/src/ortho/mcode/ortho_code-consts.ads
index dcb719f26..f49dbb315 100644
--- a/src/ortho/mcode/ortho_code-consts.ads
+++ b/src/ortho/mcode/ortho_code-consts.ads
@@ -68,6 +68,9 @@ package Ortho_Code.Consts is
-- Get the type from an OC_Alignof node.
function Get_Alignof_Type (Cst : O_Cnode) return O_Tnode;
+ -- Get the size (number of bytes) for CST.
+ function Get_Const_Size (Cst : O_Cnode) return Uns32;
+
-- Get the value of a named literal.
--function Get_Const_Literal (Cst : O_Cnode) return Uns32;
@@ -122,7 +125,8 @@ package Ortho_Code.Consts is
procedure Finish_Record_Aggr (List : in out O_Record_Aggr_List;
Res : out O_Cnode);
- procedure Start_Array_Aggr (List : out O_Array_Aggr_List; Atype : O_Tnode);
+ procedure Start_Array_Aggr
+ (List : out O_Array_Aggr_List; Arr_Type : O_Tnode; Len : Unsigned_32);
procedure New_Array_Aggr_El (List : in out O_Array_Aggr_List;
Value : O_Cnode);
procedure Finish_Array_Aggr (List : in out O_Array_Aggr_List;
diff --git a/src/ortho/mcode/ortho_code-types.adb b/src/ortho/mcode/ortho_code-types.adb
index 95ed20f73..177c1ec99 100644
--- a/src/ortho/mcode/ortho_code-types.adb
+++ b/src/ortho/mcode/ortho_code-types.adb
@@ -96,6 +96,7 @@ package body Ortho_Code.Types is
function Get_Type_Size (Atype : O_Tnode) return Uns32 is
begin
+ pragma Assert (Get_Type_Kind (Atype) /= OT_Ucarray);
return Tnodes.Table (Atype).Size;
end Get_Type_Size;
diff --git a/src/ortho/mcode/ortho_code-x86-emits.adb b/src/ortho/mcode/ortho_code-x86-emits.adb
index cc27a3a23..a8696d19f 100644
--- a/src/ortho/mcode/ortho_code-x86-emits.adb
+++ b/src/ortho/mcode/ortho_code-x86-emits.adb
@@ -3216,7 +3216,7 @@ package body Ortho_Code.X86.Emits is
Gen_Pow_Align (Get_Type_Align (Dtype));
Set_Symbol_Pc (Sym, Get_Decl_Storage (Decl) = O_Storage_Public);
- Prealloc (Pc_Type (Get_Type_Size (Dtype)));
+ Prealloc (Pc_Type (Consts.Get_Const_Size (Val)));
Emit_Const (Val);
Set_Current_Section (Sect_Text);
diff --git a/src/ortho/mcode/ortho_mcode.adb b/src/ortho/mcode/ortho_mcode.adb
index 16638300d..95f442c89 100644
--- a/src/ortho/mcode/ortho_mcode.adb
+++ b/src/ortho/mcode/ortho_mcode.adb
@@ -283,12 +283,14 @@ package body Ortho_Mcode is
Ortho_Code.O_Cnode (Res));
end Finish_Record_Aggr;
- procedure Start_Array_Aggr (List : out O_Array_Aggr_List; Atype : O_Tnode)
+ procedure Start_Array_Aggr
+ (List : out O_Array_Aggr_List; Arr_Type : O_Tnode; Len : Unsigned_32)
is
begin
Ortho_Code.Consts.Start_Array_Aggr
(Ortho_Code.Consts.O_Array_Aggr_List (List),
- Ortho_Code.O_Tnode (Atype));
+ Ortho_Code.O_Tnode (Arr_Type),
+ Len);
end Start_Array_Aggr;
procedure New_Array_Aggr_El (List : in out O_Array_Aggr_List;
diff --git a/src/ortho/mcode/ortho_mcode.ads b/src/ortho/mcode/ortho_mcode.ads
index 515242561..554b1ee19 100644
--- a/src/ortho/mcode/ortho_mcode.ads
+++ b/src/ortho/mcode/ortho_mcode.ads
@@ -166,7 +166,8 @@ package Ortho_Mcode is
procedure Finish_Record_Aggr (List : in out O_Record_Aggr_List;
Res : out O_Cnode);
- procedure Start_Array_Aggr (List : out O_Array_Aggr_List; Atype : O_Tnode);
+ procedure Start_Array_Aggr
+ (List : out O_Array_Aggr_List; Arr_Type : O_Tnode; Len : Unsigned_32);
procedure New_Array_Aggr_El (List : in out O_Array_Aggr_List;
Value : O_Cnode);
procedure Finish_Array_Aggr (List : in out O_Array_Aggr_List;
diff --git a/src/ortho/oread/ortho_front.adb b/src/ortho/oread/ortho_front.adb
index 42f72ea71..9d2da4192 100644
--- a/src/ortho/oread/ortho_front.adb
+++ b/src/ortho/oread/ortho_front.adb
@@ -2674,31 +2674,54 @@ package body Ortho_Front is
return Res;
end Parse_Constant_Address;
+ function Parse_Array_Aggregate (Aggr_Type : Node_Acc; El_Type : Node_Acc)
+ return O_Cnode
+ is
+ Res : O_Cnode;
+ Constr : O_Array_Aggr_List;
+ Len : Unsigned_32;
+ begin
+ -- Parse '[' LEN ']'
+ Expect (Tok_Left_Brack);
+ Next_Token;
+ Expect (Tok_Num);
+ Len := Unsigned_32 (Token_Number);
+ Next_Token;
+ Expect (Tok_Right_Brack);
+ Next_Token;
+
+ Expect (Tok_Left_Brace);
+ Next_Token;
+ Start_Array_Aggr (Constr, Aggr_Type.Type_Onode, Len);
+ for I in Unsigned_32 loop
+ if Tok = Tok_Right_Brace then
+ if I /= Len then
+ Parse_Error ("bad number of aggregate element");
+ end if;
+ exit;
+ end if;
+
+ if I /= 0 then
+ Expect (Tok_Comma);
+ Next_Token;
+ end if;
+ New_Array_Aggr_El (Constr, Parse_Constant_Value (El_Type));
+ end loop;
+ Finish_Array_Aggr (Constr, Res);
+ Next_Token;
+ return Res;
+ end Parse_Array_Aggregate;
+
function Parse_Constant_Value (Atype : Node_Acc) return O_Cnode
is
Res : O_Cnode;
begin
case Atype.Kind is
when Type_Subarray =>
- declare
- El : constant Node_Acc := Atype.Subarray_Base.Array_Element;
- Constr : O_Array_Aggr_List;
- begin
- Expect (Tok_Left_Brace);
- Next_Token;
- Start_Array_Aggr (Constr, Atype.Type_Onode);
- for I in Natural loop
- exit when Tok = Tok_Right_Brace;
- if I /= 0 then
- Expect (Tok_Comma);
- Next_Token;
- end if;
- New_Array_Aggr_El (Constr, Parse_Constant_Value (El));
- end loop;
- Finish_Array_Aggr (Constr, Res);
- Next_Token;
- return Res;
- end;
+ return Parse_Array_Aggregate
+ (Atype, Atype.Subarray_Base.Array_Element);
+ when Type_Array =>
+ return Parse_Array_Aggregate (Atype, Atype.Array_Element);
when Type_Unsigned
| Type_Signed
| Type_Enum
diff --git a/src/ortho/ortho_nodes.common.ads b/src/ortho/ortho_nodes.common.ads
index 30e44d6fd..e2dd1521b 100644
--- a/src/ortho/ortho_nodes.common.ads
+++ b/src/ortho/ortho_nodes.common.ads
@@ -153,7 +153,8 @@ package ORTHO_NODES is
procedure Finish_Record_Aggr (List : in out O_Record_Aggr_List;
Res : out O_Cnode);
- procedure Start_Array_Aggr (List : out O_Array_Aggr_List; Atype : O_Tnode);
+ procedure Start_Array_Aggr
+ (List : out O_Array_Aggr_List; Atype : O_Tnode; Len : Unsigned_32);
procedure New_Array_Aggr_El (List : in out O_Array_Aggr_List;
Value : O_Cnode);
procedure Finish_Array_Aggr (List : in out O_Array_Aggr_List;
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb
index a360c26dc..88cc0d367 100644
--- a/src/vhdl/translate/trans-chap3.adb
+++ b/src/vhdl/translate/trans-chap3.adb
@@ -2563,7 +2563,7 @@ package body Trans.Chap3 is
Elab_Type_Definition (Get_Type (Decl));
end Elab_Subtype_Declaration;
- function Get_Thin_Array_Length (Atype : Iir) return O_Cnode
+ function Get_Static_Array_Length (Atype : Iir) return Int64
is
Indexes_List : constant Iir_Flist := Get_Index_Subtype_List (Atype);
Nbr_Dim : constant Natural := Get_Nbr_Elements (Indexes_List);
@@ -2577,7 +2577,13 @@ package body Trans.Chap3 is
Rng := Get_Range_Constraint (Index);
Val := Val * Eval_Discrete_Range_Length (Rng);
end loop;
- return New_Unsigned_Literal (Ghdl_Index_Type, Unsigned_64 (Val));
+ return Val;
+ -- return New_Unsigned_Literal (Ghdl_Index_Type, Unsigned_64 (Val));
+ end Get_Static_Array_Length;
+
+ function Get_Thin_Array_Length (Atype : Iir) return O_Cnode is
+ begin
+ return New_Index_Lit (Unsigned_64 (Get_Static_Array_Length (Atype)));
end Get_Thin_Array_Length;
function Bounds_To_Range (B : Mnode; Atype : Iir; Dim : Positive)
diff --git a/src/vhdl/translate/trans-chap3.ads b/src/vhdl/translate/trans-chap3.ads
index 4bc05de9f..7e252f521 100644
--- a/src/vhdl/translate/trans-chap3.ads
+++ b/src/vhdl/translate/trans-chap3.ads
@@ -164,6 +164,9 @@ package Trans.Chap3 is
-- automatically stabilized if necessary.
function Get_Bounds_Length (Bounds : Mnode; Atype : Iir) return O_Enode;
+ -- Return the number of elements for statically bounded array ATYPE.
+ function Get_Static_Array_Length (Atype : Iir) return Int64;
+
-- Get the number of elements in array ATYPE.
function Get_Array_Type_Length (Atype : Iir) return O_Enode;
diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb
index 32c8b8537..016132a29 100644
--- a/src/vhdl/translate/trans-chap7.adb
+++ b/src/vhdl/translate/trans-chap7.adb
@@ -266,7 +266,9 @@ package body Trans.Chap7 is
Res : O_Cnode;
begin
Chap3.Translate_Anonymous_Subtype_Definition (Aggr_Type, False);
- Start_Array_Aggr (List, Get_Ortho_Type (Aggr_Type, Mode_Value));
+ Start_Array_Aggr
+ (List, Get_Ortho_Type (Aggr_Type, Mode_Value),
+ Unsigned_32 (Chap3.Get_Static_Array_Length (Aggr_Type)));
Translate_Static_Array_Aggregate_1 (List, Aggr, Aggr_Type, 1);
Finish_Array_Aggr (List, Res);
@@ -283,7 +285,9 @@ package body Trans.Chap7 is
Res : O_Cnode;
begin
Chap3.Translate_Anonymous_Subtype_Definition (Aggr_Type, False);
- Start_Array_Aggr (List, Get_Ortho_Type (Aggr_Type, Mode_Value));
+ Start_Array_Aggr (List,
+ Get_Ortho_Type (Aggr_Type, Mode_Value),
+ Unsigned_32 (Get_Nbr_Elements (El_List)));
for I in Flist_First .. Flist_Last (El_List) loop
El := Get_Nth_Element (El_List, I);
@@ -306,7 +310,9 @@ package body Trans.Chap7 is
Chap3.Translate_Anonymous_Subtype_Definition (Lit_Type, False);
Arr_Type := Get_Ortho_Type (Lit_Type, Mode_Value);
- Start_Array_Aggr (List, Arr_Type);
+ Start_Array_Aggr
+ (List, Arr_Type,
+ Unsigned_32 (Chap3.Get_Static_Array_Length (Lit_Type)));
Translate_Static_String_Literal8_Inner (List, Str, Element_Type);
@@ -318,12 +324,13 @@ package body Trans.Chap7 is
-- The type of the literal element is ELEMENT_TYPE, and the ortho type
-- of the string (a constrained array type) is STR_TYPE.
function Create_String_Literal_Var_Inner
- (Str : Iir; Element_Type : Iir; Str_Type : O_Tnode) return Var_Type
+ (Str : Iir; Element_Type : Iir; Arr_Type : O_Tnode) return Var_Type
is
Val_Aggr : O_Array_Aggr_List;
Res : O_Cnode;
begin
- Start_Array_Aggr (Val_Aggr, Str_Type);
+ Start_Array_Aggr
+ (Val_Aggr, Arr_Type, Unsigned_32 (Get_String_Length (Str)));
case Get_Kind (Str) is
when Iir_Kind_String_Literal8 =>
Translate_Static_String_Literal8_Inner
@@ -334,7 +341,7 @@ package body Trans.Chap7 is
Finish_Array_Aggr (Val_Aggr, Res);
return Create_Global_Const
- (Create_Uniq_Identifier, Str_Type, O_Storage_Private, Res);
+ (Create_Uniq_Identifier, Arr_Type, O_Storage_Private, Res);
end Create_String_Literal_Var_Inner;
-- Create a variable (constant) for string or bit string literal STR.
@@ -344,11 +351,7 @@ package body Trans.Chap7 is
Arr_Type : O_Tnode;
begin
-- Create the string value.
- Arr_Type := New_Constrained_Array_Type
- (Get_Info (Str_Type).B.Base_Type (Mode_Value),
- New_Unsigned_Literal (Ghdl_Index_Type,
- Unsigned_64 (Get_String_Length (Str))));
-
+ Arr_Type := Get_Info (Str_Type).B.Base_Type (Mode_Value);
return Create_String_Literal_Var_Inner
(Str, Get_Element_Subtype (Str_Type), Arr_Type);
end Create_String_Literal_Var;
@@ -445,7 +448,8 @@ package body Trans.Chap7 is
begin
Chap3.Translate_Anonymous_Subtype_Definition (Str_Type, False);
- Start_Array_Aggr (List, Get_Ortho_Type (Str_Type, Mode_Value));
+ Start_Array_Aggr
+ (List, Get_Ortho_Type (Str_Type, Mode_Value), Img'Length);
for I in Img'Range loop
Lit := Get_Nth_Element (Literal_List, Character'Pos (Img (I)));
@@ -2913,9 +2917,6 @@ package body Trans.Chap7 is
-- Type of the unconstrained array type.
Arr_Type : O_Tnode;
- -- Type of the constrained array type.
- Str_Type : O_Tnode;
-
Cst : Var_Type;
Var_I : O_Dnode;
Label : O_Snode;
@@ -2928,9 +2929,7 @@ package body Trans.Chap7 is
Arr_Type := New_Array_Type
(Get_Ortho_Type (Expr_Type, Mode_Value), Ghdl_Index_Type);
New_Type_Decl (Create_Uniq_Identifier, Arr_Type);
- Str_Type := New_Constrained_Array_Type
- (Arr_Type, New_Index_Lit (Unsigned_64 (Len)));
- Cst := Create_String_Literal_Var_Inner (Aggr, Expr_Type, Str_Type);
+ Cst := Create_String_Literal_Var_Inner (Aggr, Expr_Type, Arr_Type);
-- Copy it.
Open_Temp;
diff --git a/src/vhdl/translate/trans-chap8.adb b/src/vhdl/translate/trans-chap8.adb
index 2c67eebd4..1b7c756b9 100644
--- a/src/vhdl/translate/trans-chap8.adb
+++ b/src/vhdl/translate/trans-chap8.adb
@@ -1423,7 +1423,6 @@ package body Trans.Chap8 is
-- Dichotomy table (table of choices).
String_Type : O_Tnode;
Table_Base_Type : O_Tnode;
- Table_Type : O_Tnode;
Table : O_Dnode;
List : O_Array_Aggr_List;
Table_Cst : O_Cnode;
@@ -1433,7 +1432,6 @@ package body Trans.Chap8 is
-- statement list.
-- Could be replaced by jump table.
Assoc_Table_Base_Type : O_Tnode;
- Assoc_Table_Type : O_Tnode;
Assoc_Table : O_Dnode;
begin
-- Fill Choices_Info array, and count number of associations.
@@ -1541,14 +1539,10 @@ package body Trans.Chap8 is
New_Unsigned_Literal (Ghdl_Index_Type, Unsigned_64 (Sel_Length)));
Table_Base_Type := New_Array_Type (String_Type, Ghdl_Index_Type);
New_Type_Decl (Create_Uniq_Identifier, Table_Base_Type);
- Table_Type := New_Constrained_Array_Type
- (Table_Base_Type,
- New_Unsigned_Literal (Ghdl_Index_Type, Unsigned_64 (Nbr_Choices)));
- New_Type_Decl (Create_Uniq_Identifier, Table_Type);
New_Const_Decl (Table, Create_Uniq_Identifier, O_Storage_Private,
- Table_Type);
+ Table_Base_Type);
Start_Init_Value (Table);
- Start_Array_Aggr (List, Table_Type);
+ Start_Array_Aggr (List, Table_Base_Type, Unsigned_32 (Nbr_Choices));
El := First;
while El /= No_Choice_Id loop
@@ -1563,14 +1557,11 @@ package body Trans.Chap8 is
Assoc_Table_Base_Type :=
New_Array_Type (Ghdl_Index_Type, Ghdl_Index_Type);
New_Type_Decl (Create_Uniq_Identifier, Assoc_Table_Base_Type);
- Assoc_Table_Type := New_Constrained_Array_Type
- (Assoc_Table_Base_Type,
- New_Unsigned_Literal (Ghdl_Index_Type, Unsigned_64 (Nbr_Choices)));
- New_Type_Decl (Create_Uniq_Identifier, Assoc_Table_Type);
New_Const_Decl (Assoc_Table, Create_Uniq_Identifier,
- O_Storage_Private, Assoc_Table_Type);
+ O_Storage_Private, Assoc_Table_Base_Type);
Start_Init_Value (Assoc_Table);
- Start_Array_Aggr (List, Assoc_Table_Type);
+ Start_Array_Aggr
+ (List, Assoc_Table_Base_Type, Unsigned_32 (Nbr_Choices));
El := First;
while El /= No_Choice_Id loop
New_Array_Aggr_El
diff --git a/src/vhdl/translate/trans-helpers2.adb b/src/vhdl/translate/trans-helpers2.adb
index f05bf2477..4072fe321 100644
--- a/src/vhdl/translate/trans-helpers2.adb
+++ b/src/vhdl/translate/trans-helpers2.adb
@@ -51,7 +51,7 @@ package body Trans.Helpers2 is
List : O_Array_Aggr_List;
begin
Start_Init_Value (Const);
- Start_Array_Aggr (List, Const_Type);
+ Start_Array_Aggr (List, Const_Type, Str'Length + 1);
for I in Str'Range loop
New_Array_Aggr_El
(List,
@@ -64,12 +64,10 @@ package body Trans.Helpers2 is
function Create_String (Str : String; Id : O_Ident) return O_Dnode
is
- Atype : O_Tnode;
Const : O_Dnode;
begin
- Atype := Create_String_Type (Str);
- New_Const_Decl (Const, Id, O_Storage_Private, Atype);
- Create_String_Value (Const, Atype, Str);
+ New_Const_Decl (Const, Id, O_Storage_Private, Chararray_Type);
+ Create_String_Value (Const, Chararray_Type, Str);
return Const;
end Create_String;
diff --git a/src/vhdl/translate/trans-rtis.adb b/src/vhdl/translate/trans-rtis.adb
index 8a691fac5..5b55c69c6 100644
--- a/src/vhdl/translate/trans-rtis.adb
+++ b/src/vhdl/translate/trans-rtis.adb
@@ -877,20 +877,16 @@ package body Trans.Rtis is
function Generate_Rti_Array (Id : O_Ident) return O_Dnode
is
- Arr_Type : O_Tnode;
List : O_Array_Aggr_List;
L : Rti_Array_List_Acc;
Nbr : Integer;
Val : O_Cnode;
Res : O_Dnode;
begin
- Arr_Type := New_Constrained_Array_Type
- (Ghdl_Rti_Array,
- New_Unsigned_Literal (Ghdl_Index_Type,
- Unsigned_64 (Cur_Block.Nbr + 1)));
- New_Const_Decl (Res, Id, O_Storage_Private, Arr_Type);
+ New_Const_Decl (Res, Id, O_Storage_Private, Ghdl_Rti_Array);
Start_Init_Value (Res);
- Start_Array_Aggr (List, Arr_Type);
+ Start_Array_Aggr
+ (List, Ghdl_Rti_Array, Unsigned_32 (Cur_Block.Nbr + 1));
Nbr := Cur_Block.Nbr;
-- First chunk.
@@ -1098,7 +1094,6 @@ package body Trans.Rtis is
type Dnode_Array is array (Natural range <>) of O_Dnode;
Name_Lits : Dnode_Array (0 .. Nbr_Lit - 1);
Mark : Id_Mark_Type;
- Name_Arr_Type : O_Tnode;
Name_Arr : O_Dnode;
Arr_Aggr : O_Array_Aggr_List;
@@ -1115,14 +1110,11 @@ package body Trans.Rtis is
end loop;
-- Generate array of names.
- Name_Arr_Type := New_Constrained_Array_Type
- (Char_Ptr_Array_Type,
- New_Unsigned_Literal (Ghdl_Index_Type,
- Unsigned_64 (Nbr_Lit)));
New_Const_Decl (Name_Arr, Create_Identifier ("RTINAMES"),
- O_Storage_Private, Name_Arr_Type);
+ O_Storage_Private, Char_Ptr_Array_Type);
Start_Init_Value (Name_Arr);
- Start_Array_Aggr (Arr_Aggr, Name_Arr_Type);
+ Start_Array_Aggr
+ (Arr_Aggr, Char_Ptr_Array_Type, Unsigned_32 (Nbr_Lit));
for I in Name_Lits'Range loop
New_Array_Aggr_El (Arr_Aggr, New_Name_Address (Name_Lits (I)));
end loop;
@@ -1413,7 +1405,6 @@ package body Trans.Rtis is
Index : Iir;
Tmp : O_Dnode;
pragma Unreferenced (Tmp);
- Arr_Type : O_Tnode;
Arr_Aggr : O_Array_Aggr_List;
Val : O_Cnode;
Mark : Id_Mark_Type;
@@ -1429,14 +1420,11 @@ package body Trans.Rtis is
end loop;
-- Generate array of index.
- Arr_Type := New_Constrained_Array_Type
- (Ghdl_Rti_Array,
- New_Unsigned_Literal (Ghdl_Index_Type, Unsigned_64 (Nbr_Indexes)));
New_Const_Decl (Res, Create_Identifier ("RTIINDEXES"),
- Global_Storage, Arr_Type);
+ Global_Storage, Ghdl_Rti_Array);
Start_Init_Value (Res);
- Start_Array_Aggr (Arr_Aggr, Arr_Type);
+ Start_Array_Aggr (Arr_Aggr, Ghdl_Rti_Array, Unsigned_32 (Nbr_Indexes));
for I in 1 .. Nbr_Indexes loop
Index := Get_Index_Type (List, I - 1);
New_Array_Aggr_El