aboutsummaryrefslogtreecommitdiffstats
path: root/src/ortho/gcc
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-09-13 21:51:43 +0200
committerTristan Gingold <tgingold@free.fr>2021-09-14 04:16:51 +0200
commit77476d6ecc45f1761125524cbdeddfe74e3b157a (patch)
treef6107b185b8c92f28e99d129e839a0c28fbe211e /src/ortho/gcc
parent95cbcc921d92d58dbd25d328de60c18976083d2a (diff)
downloadghdl-77476d6ecc45f1761125524cbdeddfe74e3b157a.tar.gz
ghdl-77476d6ecc45f1761125524cbdeddfe74e3b157a.tar.bz2
ghdl-77476d6ecc45f1761125524cbdeddfe74e3b157a.zip
ortho: for slices, get element size from the result type
and not from the object type. Fix #1862
Diffstat (limited to 'src/ortho/gcc')
-rw-r--r--src/ortho/gcc/ortho-lang-49.c11
-rw-r--r--src/ortho/gcc/ortho-lang-5.c11
-rw-r--r--src/ortho/gcc/ortho-lang-6.c11
-rw-r--r--src/ortho/gcc/ortho-lang-7.c11
-rw-r--r--src/ortho/gcc/ortho-lang-8.c11
-rw-r--r--src/ortho/gcc/ortho-lang-9.c11
6 files changed, 60 insertions, 6 deletions
diff --git a/src/ortho/gcc/ortho-lang-49.c b/src/ortho/gcc/ortho-lang-49.c
index f5586bf41..a411ba813 100644
--- a/src/ortho/gcc/ortho-lang-49.c
+++ b/src/ortho/gcc/ortho-lang-49.c
@@ -1500,8 +1500,17 @@ new_slice (tree arr, tree res_type, tree index)
TREE_TYPE (TYPE_DOMAIN (res_type)));
}
+ /* Take the element size from RES_TYPE (and not from ARR, which is the
+ default. */
+ tree elmt_type = TREE_TYPE (res_type);
+ tree elmt_size = TYPE_SIZE_UNIT (elmt_type);
+ tree factor = size_int (TYPE_ALIGN_UNIT (elmt_type));
+
+ /* Divide the element size by the alignment of the element type (above). */
+ elmt_size = size_binop (EXACT_DIV_EXPR, elmt_size, factor);
+
ortho_mark_addressable (arr);
- return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, NULL_TREE);
+ return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, elmt_size);
}
tree
diff --git a/src/ortho/gcc/ortho-lang-5.c b/src/ortho/gcc/ortho-lang-5.c
index 66233d49e..647854bb0 100644
--- a/src/ortho/gcc/ortho-lang-5.c
+++ b/src/ortho/gcc/ortho-lang-5.c
@@ -1486,8 +1486,17 @@ new_slice (tree arr, tree res_type, tree index)
TREE_TYPE (TYPE_DOMAIN (res_type)));
}
+ /* Take the element size from RES_TYPE (and not from ARR, which is the
+ default. */
+ tree elmt_type = TREE_TYPE (res_type);
+ tree elmt_size = TYPE_SIZE_UNIT (elmt_type);
+ tree factor = size_int (TYPE_ALIGN_UNIT (elmt_type));
+
+ /* Divide the element size by the alignment of the element type (above). */
+ elmt_size = size_binop (EXACT_DIV_EXPR, elmt_size, factor);
+
ortho_mark_addressable (arr);
- return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, NULL_TREE);
+ return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, elmt_size);
}
tree
diff --git a/src/ortho/gcc/ortho-lang-6.c b/src/ortho/gcc/ortho-lang-6.c
index 15649c8ae..736d0ddce 100644
--- a/src/ortho/gcc/ortho-lang-6.c
+++ b/src/ortho/gcc/ortho-lang-6.c
@@ -1486,8 +1486,17 @@ new_slice (tree arr, tree res_type, tree index)
TREE_TYPE (TYPE_DOMAIN (res_type)));
}
+ /* Take the element size from RES_TYPE (and not from ARR, which is the
+ default. */
+ tree elmt_type = TREE_TYPE (res_type);
+ tree elmt_size = TYPE_SIZE_UNIT (elmt_type);
+ tree factor = size_int (TYPE_ALIGN_UNIT (elmt_type));
+
+ /* Divide the element size by the alignment of the element type (above). */
+ elmt_size = size_binop (EXACT_DIV_EXPR, elmt_size, factor);
+
ortho_mark_addressable (arr);
- return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, NULL_TREE);
+ return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, elmt_size);
}
tree
diff --git a/src/ortho/gcc/ortho-lang-7.c b/src/ortho/gcc/ortho-lang-7.c
index 1bc705298..b87e4d60c 100644
--- a/src/ortho/gcc/ortho-lang-7.c
+++ b/src/ortho/gcc/ortho-lang-7.c
@@ -1498,8 +1498,17 @@ new_slice (tree arr, tree res_type, tree index)
TREE_TYPE (TYPE_DOMAIN (res_type)));
}
+ /* Take the element size from RES_TYPE (and not from ARR, which is the
+ default. */
+ tree elmt_type = TREE_TYPE (res_type);
+ tree elmt_size = TYPE_SIZE_UNIT (elmt_type);
+ tree factor = size_int (TYPE_ALIGN_UNIT (elmt_type));
+
+ /* Divide the element size by the alignment of the element type (above). */
+ elmt_size = size_binop (EXACT_DIV_EXPR, elmt_size, factor);
+
ortho_mark_addressable (arr);
- return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, NULL_TREE);
+ return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, elmt_size);
}
tree
diff --git a/src/ortho/gcc/ortho-lang-8.c b/src/ortho/gcc/ortho-lang-8.c
index d710c8b99..d6d72b0a9 100644
--- a/src/ortho/gcc/ortho-lang-8.c
+++ b/src/ortho/gcc/ortho-lang-8.c
@@ -1499,8 +1499,17 @@ new_slice (tree arr, tree res_type, tree index)
TREE_TYPE (TYPE_DOMAIN (res_type)));
}
+ /* Take the element size from RES_TYPE (and not from ARR, which is the
+ default. */
+ tree elmt_type = TREE_TYPE (res_type);
+ tree elmt_size = TYPE_SIZE_UNIT (elmt_type);
+ tree factor = size_int (TYPE_ALIGN_UNIT (elmt_type));
+
+ /* Divide the element size by the alignment of the element type (above). */
+ elmt_size = size_binop (EXACT_DIV_EXPR, elmt_size, factor);
+
ortho_mark_addressable (arr);
- return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, NULL_TREE);
+ return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, elmt_size);
}
tree
diff --git a/src/ortho/gcc/ortho-lang-9.c b/src/ortho/gcc/ortho-lang-9.c
index 622bd5b38..cd3e14240 100644
--- a/src/ortho/gcc/ortho-lang-9.c
+++ b/src/ortho/gcc/ortho-lang-9.c
@@ -1499,8 +1499,17 @@ new_slice (tree arr, tree res_type, tree index)
TREE_TYPE (TYPE_DOMAIN (res_type)));
}
+ /* Take the element size from RES_TYPE (and not from ARR, which is the
+ default. */
+ tree elmt_type = TREE_TYPE (res_type);
+ tree elmt_size = TYPE_SIZE_UNIT (elmt_type);
+ tree factor = size_int (TYPE_ALIGN_UNIT (elmt_type));
+
+ /* Divide the element size by the alignment of the element type (above). */
+ elmt_size = size_binop (EXACT_DIV_EXPR, elmt_size, factor);
+
ortho_mark_addressable (arr);
- return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, NULL_TREE);
+ return build4 (ARRAY_RANGE_REF, res_type, arr, index, NULL_TREE, elmt_size);
}
tree