This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/3 v2] RISC-V: Handle vector type alignment.
- From: Jim Wilson <jimw at sifive dot com>
- To: gdb-patches at sourceware dot org
- Cc: andrew dot burgess at embecosm dot com, Jim Wilson <jimw at sifive dot com>
- Date: Mon, 12 Nov 2018 21:38:32 -0800
- Subject: [PATCH 2/3 v2] RISC-V: Handle vector type alignment.
- References: <CAFyWVaaJf8+UT27GhCqEBZahr8qSF5Z63krgY-8kLqztmWnRkA@mail.gmail.com>
For riscv64-linxu target, first half of fix for
FAIL: gdb.base/gnu_vector.exp: call add_various_floatvecs
GCC gives vectors natural aligment based on total size, not element size,
bounded by the maximum supported type alignment.
gdb/
* riscv-tdep.c (BIGGEST_ALIGNMENT): New.
(riscv_type_alignment) <TYPE_CODE_ARRAY>: If TYPE_VECTOR, return min
of TYPE_LENGTH and BIGGEST_ALIGNMENT.
---
gdb/riscv-tdep.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index f4650dfbf3..58dca3b86e 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -59,6 +59,9 @@
/* The stack must be 16-byte aligned. */
#define SP_ALIGNMENT 16
+/* The biggest alignment that the target supports. */
+#define BIGGEST_ALIGNMENT 16
+
/* Forward declarations. */
static bool riscv_has_feature (struct gdbarch *gdbarch, char feature);
@@ -1640,6 +1643,10 @@ riscv_type_alignment (struct type *t)
return TYPE_LENGTH (t);
case TYPE_CODE_ARRAY:
+ if (TYPE_VECTOR (t))
+ return std::min (TYPE_LENGTH (t), (unsigned) BIGGEST_ALIGNMENT);
+ /* FALLTHROUGH */
+
case TYPE_CODE_COMPLEX:
return riscv_type_alignment (TYPE_TARGET_TYPE (t));
--
2.17.1