From 0e98271e5137b0377ad5c1ecc6eb404b2960f98e Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sat, 27 Jun 2020 06:40:45 +0200 Subject: ortho/gcc: apply previous patch to all gcc versions. --- src/ortho/gcc/ortho-lang-49.c | 54 ++++++++++++++++++++++++++++++------------- src/ortho/gcc/ortho-lang-5.c | 54 ++++++++++++++++++++++++++++++------------- src/ortho/gcc/ortho-lang-6.c | 54 ++++++++++++++++++++++++++++++------------- src/ortho/gcc/ortho-lang-7.c | 54 ++++++++++++++++++++++++++++++------------- src/ortho/gcc/ortho-lang-8.c | 54 ++++++++++++++++++++++++++++++------------- 5 files changed, 190 insertions(+), 80 deletions(-) (limited to 'src/ortho') diff --git a/src/ortho/gcc/ortho-lang-49.c b/src/ortho/gcc/ortho-lang-49.c index 6be55dabe..f73965615 100644 --- a/src/ortho/gcc/ortho-lang-49.c +++ b/src/ortho/gcc/ortho-lang-49.c @@ -1227,44 +1227,55 @@ finish_access_type (tree atype, tree dtype) TREE_TYPE (atype) = dtype; } +/* Create a range type from INDEX_TYPE of length LENGTH. */ +static tree +ortho_build_array_range(tree index_type, tree length) +{ + tree len; + + if (integer_zerop (length)) + { + /* Handle null array, by creating a one-length array... */ + len = size_zero_node; + } + else + { + len = fold_build2 (MINUS_EXPR, index_type, + convert (index_type, length), + convert (index_type, size_one_node)); + } + return build_range_type (index_type, size_zero_node, len); +} + tree new_array_type (tree el_type, tree index_type) { /* Incomplete array. */ tree range_type; + tree res; + /* Build an incomplete array. */ range_type = build_range_type (index_type, size_zero_node, NULL_TREE); - return build_array_type (el_type, range_type); + res = build_array_type (el_type, range_type); + return res; } - tree new_constrained_array_type (tree atype, tree length) { tree range_type; tree index_type; - tree len; tree res; index_type = TYPE_DOMAIN (atype); - if (integer_zerop (length)) - { - /* Handle null array, by creating a one-length array... */ - len = size_zero_node; - } - else - { - 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); + range_type = ortho_build_array_range(index_type, length); res = build_array_type (TREE_TYPE (atype), range_type); /* Constrained arrays are *always* a subtype of its array type. Just copy alias set. */ TYPE_ALIAS_SET (res) = get_alias_set (atype); + return res; } @@ -1408,6 +1419,14 @@ new_slice (tree arr, tree res_type, tree index) { gcc_assert (TREE_CODE (res_type) == ARRAY_TYPE); + /* gcc needs a complete array type, so create the biggest one if it is + not. */ + if (TYPE_MAX_VALUE (TYPE_DOMAIN (res_type)) == NULL_TREE) + { + res_type = build_array_type (TREE_TYPE (res_type), + TREE_TYPE (TYPE_DOMAIN (res_type))); + } + ortho_mark_addressable (arr); return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, NULL_TREE); } @@ -1643,8 +1662,11 @@ finish_init_value (tree *decl, tree val) TREE_STATIC (*decl) = 1; /* The variable may be declared with an incomplete array, so be sure it - has a completed type. */ + has a completed type. + Force re-layout by clearing the size. */ + DECL_SIZE (*decl) = NULL_TREE; TREE_TYPE (*decl) = TREE_TYPE (val); + layout_decl (*decl, 0); 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 140a4a370..6dedb14b0 100644 --- a/src/ortho/gcc/ortho-lang-5.c +++ b/src/ortho/gcc/ortho-lang-5.c @@ -1213,44 +1213,55 @@ finish_access_type (tree atype, tree dtype) TREE_TYPE (atype) = dtype; } +/* Create a range type from INDEX_TYPE of length LENGTH. */ +static tree +ortho_build_array_range(tree index_type, tree length) +{ + tree len; + + if (integer_zerop (length)) + { + /* Handle null array, by creating a one-length array... */ + len = size_zero_node; + } + else + { + len = fold_build2 (MINUS_EXPR, index_type, + convert (index_type, length), + convert (index_type, size_one_node)); + } + return build_range_type (index_type, size_zero_node, len); +} + tree new_array_type (tree el_type, tree index_type) { /* Incomplete array. */ tree range_type; + tree res; + /* Build an incomplete array. */ range_type = build_range_type (index_type, size_zero_node, NULL_TREE); - return build_array_type (el_type, range_type); + res = build_array_type (el_type, range_type); + return res; } - tree new_constrained_array_type (tree atype, tree length) { tree range_type; tree index_type; - tree len; tree res; index_type = TYPE_DOMAIN (atype); - if (integer_zerop (length)) - { - /* Handle null array, by creating a one-length array... */ - len = size_zero_node; - } - else - { - 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); + range_type = ortho_build_array_range(index_type, length); res = build_array_type (TREE_TYPE (atype), range_type); /* Constrained arrays are *always* a subtype of its array type. Just copy alias set. */ TYPE_ALIAS_SET (res) = get_alias_set (atype); + return res; } @@ -1394,6 +1405,14 @@ new_slice (tree arr, tree res_type, tree index) { gcc_assert (TREE_CODE (res_type) == ARRAY_TYPE); + /* gcc needs a complete array type, so create the biggest one if it is + not. */ + if (TYPE_MAX_VALUE (TYPE_DOMAIN (res_type)) == NULL_TREE) + { + res_type = build_array_type (TREE_TYPE (res_type), + TREE_TYPE (TYPE_DOMAIN (res_type))); + } + ortho_mark_addressable (arr); return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, NULL_TREE); } @@ -1629,8 +1648,11 @@ finish_init_value (tree *decl, tree val) TREE_STATIC (*decl) = 1; /* The variable may be declared with an incomplete array, so be sure it - has a completed type. */ + has a completed type. + Force re-layout by clearing the size. */ + DECL_SIZE (*decl) = NULL_TREE; TREE_TYPE (*decl) = TREE_TYPE (val); + layout_decl (*decl, 0); 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 550006b66..639356085 100644 --- a/src/ortho/gcc/ortho-lang-6.c +++ b/src/ortho/gcc/ortho-lang-6.c @@ -1213,44 +1213,55 @@ finish_access_type (tree atype, tree dtype) TREE_TYPE (atype) = dtype; } +/* Create a range type from INDEX_TYPE of length LENGTH. */ +static tree +ortho_build_array_range(tree index_type, tree length) +{ + tree len; + + if (integer_zerop (length)) + { + /* Handle null array, by creating a one-length array... */ + len = size_zero_node; + } + else + { + len = fold_build2 (MINUS_EXPR, index_type, + convert (index_type, length), + convert (index_type, size_one_node)); + } + return build_range_type (index_type, size_zero_node, len); +} + tree new_array_type (tree el_type, tree index_type) { /* Incomplete array. */ tree range_type; + tree res; + /* Build an incomplete array. */ range_type = build_range_type (index_type, size_zero_node, NULL_TREE); - return build_array_type (el_type, range_type); + res = build_array_type (el_type, range_type); + return res; } - tree new_constrained_array_type (tree atype, tree length) { tree range_type; tree index_type; - tree len; tree res; index_type = TYPE_DOMAIN (atype); - if (integer_zerop (length)) - { - /* Handle null array, by creating a one-length array... */ - len = size_zero_node; - } - else - { - 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); + range_type = ortho_build_array_range(index_type, length); res = build_array_type (TREE_TYPE (atype), range_type); /* Constrained arrays are *always* a subtype of its array type. Just copy alias set. */ TYPE_ALIAS_SET (res) = get_alias_set (atype); + return res; } @@ -1394,6 +1405,14 @@ new_slice (tree arr, tree res_type, tree index) { gcc_assert (TREE_CODE (res_type) == ARRAY_TYPE); + /* gcc needs a complete array type, so create the biggest one if it is + not. */ + if (TYPE_MAX_VALUE (TYPE_DOMAIN (res_type)) == NULL_TREE) + { + res_type = build_array_type (TREE_TYPE (res_type), + TREE_TYPE (TYPE_DOMAIN (res_type))); + } + ortho_mark_addressable (arr); return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, NULL_TREE); } @@ -1629,8 +1648,11 @@ finish_init_value (tree *decl, tree val) TREE_STATIC (*decl) = 1; /* The variable may be declared with an incomplete array, so be sure it - has a completed type. */ + has a completed type. + Force re-layout by clearing the size. */ + DECL_SIZE (*decl) = NULL_TREE; TREE_TYPE (*decl) = TREE_TYPE (val); + layout_decl (*decl, 0); 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 395edb617..f871bf93c 100644 --- a/src/ortho/gcc/ortho-lang-7.c +++ b/src/ortho/gcc/ortho-lang-7.c @@ -1225,44 +1225,55 @@ finish_access_type (tree atype, tree dtype) TREE_TYPE (atype) = dtype; } +/* Create a range type from INDEX_TYPE of length LENGTH. */ +static tree +ortho_build_array_range(tree index_type, tree length) +{ + tree len; + + if (integer_zerop (length)) + { + /* Handle null array, by creating a one-length array... */ + len = size_zero_node; + } + else + { + len = fold_build2 (MINUS_EXPR, index_type, + convert (index_type, length), + convert (index_type, size_one_node)); + } + return build_range_type (index_type, size_zero_node, len); +} + tree new_array_type (tree el_type, tree index_type) { /* Incomplete array. */ tree range_type; + tree res; + /* Build an incomplete array. */ range_type = build_range_type (index_type, size_zero_node, NULL_TREE); - return build_array_type (el_type, range_type); + res = build_array_type (el_type, range_type); + return res; } - tree new_constrained_array_type (tree atype, tree length) { tree range_type; tree index_type; - tree len; tree res; index_type = TYPE_DOMAIN (atype); - if (integer_zerop (length)) - { - /* Handle null array, by creating a one-length array... */ - len = size_zero_node; - } - else - { - 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); + range_type = ortho_build_array_range(index_type, length); res = build_array_type (TREE_TYPE (atype), range_type); /* Constrained arrays are *always* a subtype of its array type. Just copy alias set. */ TYPE_ALIAS_SET (res) = get_alias_set (atype); + return res; } @@ -1406,6 +1417,14 @@ new_slice (tree arr, tree res_type, tree index) { gcc_assert (TREE_CODE (res_type) == ARRAY_TYPE); + /* gcc needs a complete array type, so create the biggest one if it is + not. */ + if (TYPE_MAX_VALUE (TYPE_DOMAIN (res_type)) == NULL_TREE) + { + res_type = build_array_type (TREE_TYPE (res_type), + TREE_TYPE (TYPE_DOMAIN (res_type))); + } + ortho_mark_addressable (arr); return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, NULL_TREE); } @@ -1641,8 +1660,11 @@ finish_init_value (tree *decl, tree val) TREE_STATIC (*decl) = 1; /* The variable may be declared with an incomplete array, so be sure it - has a completed type. */ + has a completed type. + Force re-layout by clearing the size. */ + DECL_SIZE (*decl) = NULL_TREE; TREE_TYPE (*decl) = TREE_TYPE (val); + layout_decl (*decl, 0); 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 091565055..de5080036 100644 --- a/src/ortho/gcc/ortho-lang-8.c +++ b/src/ortho/gcc/ortho-lang-8.c @@ -1226,44 +1226,55 @@ finish_access_type (tree atype, tree dtype) TREE_TYPE (atype) = dtype; } +/* Create a range type from INDEX_TYPE of length LENGTH. */ +static tree +ortho_build_array_range(tree index_type, tree length) +{ + tree len; + + if (integer_zerop (length)) + { + /* Handle null array, by creating a one-length array... */ + len = size_zero_node; + } + else + { + len = fold_build2 (MINUS_EXPR, index_type, + convert (index_type, length), + convert (index_type, size_one_node)); + } + return build_range_type (index_type, size_zero_node, len); +} + tree new_array_type (tree el_type, tree index_type) { /* Incomplete array. */ tree range_type; + tree res; + /* Build an incomplete array. */ range_type = build_range_type (index_type, size_zero_node, NULL_TREE); - return build_array_type (el_type, range_type); + res = build_array_type (el_type, range_type); + return res; } - tree new_constrained_array_type (tree atype, tree length) { tree range_type; tree index_type; - tree len; tree res; index_type = TYPE_DOMAIN (atype); - if (integer_zerop (length)) - { - /* Handle null array, by creating a one-length array... */ - len = size_zero_node; - } - else - { - 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); + range_type = ortho_build_array_range(index_type, length); res = build_array_type (TREE_TYPE (atype), range_type); /* Constrained arrays are *always* a subtype of its array type. Just copy alias set. */ TYPE_ALIAS_SET (res) = get_alias_set (atype); + return res; } @@ -1407,6 +1418,14 @@ new_slice (tree arr, tree res_type, tree index) { gcc_assert (TREE_CODE (res_type) == ARRAY_TYPE); + /* gcc needs a complete array type, so create the biggest one if it is + not. */ + if (TYPE_MAX_VALUE (TYPE_DOMAIN (res_type)) == NULL_TREE) + { + res_type = build_array_type (TREE_TYPE (res_type), + TREE_TYPE (TYPE_DOMAIN (res_type))); + } + ortho_mark_addressable (arr); return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, NULL_TREE); } @@ -1642,8 +1661,11 @@ finish_init_value (tree *decl, tree val) TREE_STATIC (*decl) = 1; /* The variable may be declared with an incomplete array, so be sure it - has a completed type. */ + has a completed type. + Force re-layout by clearing the size. */ + DECL_SIZE (*decl) = NULL_TREE; TREE_TYPE (*decl) = TREE_TYPE (val); + layout_decl (*decl, 0); rest_of_decl_compilation (*decl, current_function_decl == NULL_TREE, 0); } -- cgit v1.2.3