From: Yao Qi <qiyaoltc@gmail.com>
To: Tristan Gingold <gingold@adacore.com>
Cc: GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH/aarch64] Fix handling of hfa/hva arrays
Date: Mon, 14 Dec 2015 12:59:00 -0000 [thread overview]
Message-ID: <864mflp4oc.fsf@gmail.com> (raw)
In-Reply-To: <9807AC8E-AB8B-42D5-BEF8-1CF4D5731E28@adacore.com> (Tristan Gingold's message of "Wed, 9 Dec 2015 12:04:22 +0100")
Tristan Gingold <gingold@adacore.com> writes:
> the current handling of hfa arrays is not correct: first the length comparison
> is using the size instead of the length so only array of a single float could
> be considered as an hfa.
>
> Second, where used HFA were only considered as struct/union. Incorrect
> accessor (like TYPE_NFIELDS) were used on arrays.
Hi Tristan,
Thanks for your patch. I spot this problem before, but I didn't fix it
because I can't write a test case in ada. Could you add a test case to
expose these problems you described above?
>
> Unfortunately, we don’t have the setup to run the gdb testsuite on that
> processor. So this patch was only manually tested (using our own
> internal testsuite) on a slightly older version of gdb.
Your can run testsuite on aarch64 machine on gcc compile farm, as Pedro
suggested.
> @@ -932,12 +932,13 @@ is_hfa_or_hva (struct type *ty)
> {
> case TYPE_CODE_ARRAY:
> {
> - struct type *target_ty = TYPE_TARGET_TYPE (ty);
> + struct type *target_ty = check_typedef (TYPE_TARGET_TYPE (ty));
>
> if (TYPE_VECTOR (ty))
> return 0;
>
> - if (TYPE_LENGTH (ty) <= 4 /* HFA or HVA has at most 4 members. */
> + /* HFA or HVA has at most 4 members. */
> + if (TYPE_LENGTH (ty) / TYPE_LENGTH (target_ty) <= 4
> && (TYPE_CODE (target_ty) == TYPE_CODE_FLT /* HFA */
> || (TYPE_CODE (target_ty) == TYPE_CODE_ARRAY /* HVA */
> && TYPE_VECTOR (target_ty))))
We can use get_array_bounds here, and take care of empty array in ada.
We can do something like this?
+ LONGEST low_bound, high_bound;
+
+ if (get_array_bounds (ty, &low_bound, &high_bound))
+ {
+ struct type *target_ty = TYPE_TARGET_TYPE (ty);
+
+ if (low_bound > high_bound)
+ {
+ /* Empty array in Ada. */
+ return 0;
+ }
+ else if (high_bound - low_bound + 1 > 4)
+ {
+ /* There are at most 4 members in HFA. */
+ return 0;
+ }
+ else if (TYPE_CODE (target_ty) == TYPE_CODE_FLT /* HFA */
+ || (TYPE_CODE (target_ty) == TYPE_CODE_ARRAY /* HVA */
+ && TYPE_VECTOR (target_ty))))
+ return 1;
+ else
+ return 0;
+ }
+ else
+ return 0;
+
> @@ -1313,7 +1314,16 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
> case TYPE_CODE_UNION:
> if (is_hfa_or_hva (arg_type))
> {
> - int elements = TYPE_NFIELDS (arg_type);
> + int elements;
> +
> + if (TYPE_CODE (arg_type) == TYPE_CODE_ARRAY)
> + {
> + struct type *el_type;
> + el_type = check_typedef (TYPE_TARGET_TYPE (arg_type));
> + elements = TYPE_LENGTH (arg_type) / TYPE_LENGTH (el_type);
> + }
> + else
> + elements = TYPE_NFIELDS (arg_type);
The change is correct, but it would be nice to move them into
is_hfa_or_hva, so that it becomes,
static int
is_hfa_or_hva (struct type *ty, int *elenum)
*ELENUM is set to the number of elements or fields of *TY if *TY is a
Homogeneous Aggregates.
What do you think?
--
Yao (齐尧)
prev parent reply other threads:[~2015-12-14 12:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-09 11:04 Tristan Gingold
2015-12-09 11:23 ` Pedro Alves
2015-12-14 12:59 ` Yao Qi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=864mflp4oc.fsf@gmail.com \
--to=qiyaoltc@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=gingold@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox