aboutsummaryrefslogtreecommitdiffstats
path: root/src/ortho/gcc
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 /src/ortho/gcc
parent58756712b9465c24e1d2a198e5a03aae7ebbf774 (diff)
downloadghdl-691d4875f0710e0603a7ae563600f9a6c041c6d6.tar.gz
ghdl-691d4875f0710e0603a7ae563600f9a6c041c6d6.tar.bz2
ghdl-691d4875f0710e0603a7ae563600f9a6c041c6d6.zip
ortho: add a length parameter to start_array_aggr.
Diffstat (limited to 'src/ortho/gcc')
-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
7 files changed, 116 insertions, 103 deletions
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;