From: Daniel Jacobowitz <drow@mvista.com>
To: Richard Henderson <rth@twiddle.net>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] handle complex arguments/return values
Date: Mon, 02 Jun 2003 18:42:00 -0000 [thread overview]
Message-ID: <20030602184221.GA31924@nevyn.them.org> (raw)
In-Reply-To: <20030602054045.GA7569@twiddle.net>
On Sun, Jun 01, 2003 at 10:40:45PM -0700, Richard Henderson wrote:
> Ok?
This is fine, barring Mark's comment about using abort () in GDB.
> r~
>
>
>
> * alpha-tdep.c (alpha_push_dummy_call): Handle COMPLEX types.
> (alpha_extract_return_value): Likewise.
> (alpha_store_return_value): Likewise.
>
> --- alpha-tdep.c.4 2003-06-01 22:27:00.000000000 -0700
> +++ alpha-tdep.c 2003-06-01 22:30:53.000000000 -0700
> @@ -282,6 +282,7 @@ alpha_push_dummy_call (struct gdbarch *g
> arg = value_cast (arg_type, arg);
> }
> break;
> +
> case TYPE_CODE_FLT:
> /* "float" arguments loaded in registers must be passed in
> register format, aka "double". */
> @@ -306,6 +307,28 @@ alpha_push_dummy_call (struct gdbarch *g
> arg = value_from_pointer (arg_type, sp);
> }
> break;
> +
> + case TYPE_CODE_COMPLEX:
> + /* ??? The ABI says that complex values are passed as two
> + separate scalar values. This distinction only matters
> + for complex float. However, GCC does not implement this. */
> +
> + /* Tru64 5.1 has a 128-bit long double, and passes this by
> + invisible reference. */
> + if (TYPE_LENGTH (arg_type) == 32)
> + {
> + /* Allocate aligned storage. */
> + sp = (sp & -16) - 16;
> +
> + /* Write the real data into the stack. */
> + write_memory (sp, VALUE_CONTENTS (arg), 32);
> +
> + /* Construct the indirection. */
> + arg_type = lookup_pointer_type (arg_type);
> + arg = value_from_pointer (arg_type, sp);
> + }
> + break;
> +
> default:
> break;
> }
> @@ -384,13 +407,14 @@ static void
> alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
> void *valbuf)
> {
> + int length = TYPE_LENGTH (valtype);
> char raw_buffer[ALPHA_REGISTER_SIZE];
> ULONGEST l;
>
> switch (TYPE_CODE (valtype))
> {
> case TYPE_CODE_FLT:
> - switch (TYPE_LENGTH (valtype))
> + switch (length)
> {
> case 4:
> regcache_cooked_read (regcache, ALPHA_FP0_REGNUM, raw_buffer);
> @@ -411,10 +435,34 @@ alpha_extract_return_value (struct type
> }
> break;
>
> + case TYPE_CODE_COMPLEX:
> + switch (length)
> + {
> + case 8:
> + /* ??? This isn't correct wrt the ABI, but it's what GCC does. */
> + regcache_cooked_read (regcache, ALPHA_FP0_REGNUM, valbuf);
> + break;
> +
> + case 16:
> + regcache_cooked_read (regcache, ALPHA_FP0_REGNUM, valbuf);
> + regcache_cooked_read (regcache, ALPHA_FP0_REGNUM+1,
> + (char *)valbuf + 8);
> + break;
> +
> + case 32:
> + regcache_cooked_read_signed (regcache, ALPHA_V0_REGNUM, &l);
> + read_memory (l, valbuf, 32);
> + break;
> +
> + default:
> + abort ();
> + }
> + break;
> +
> default:
> /* Assume everything else degenerates to an integer. */
> regcache_cooked_read_unsigned (regcache, ALPHA_V0_REGNUM, &l);
> - store_unsigned_integer (valbuf, TYPE_LENGTH (valtype), l);
> + store_unsigned_integer (valbuf, length, l);
> break;
> }
> }
> @@ -466,6 +514,31 @@ alpha_store_return_value (struct type *v
> }
> break;
>
> + case TYPE_CODE_COMPLEX:
> + switch (length)
> + {
> + case 8:
> + /* ??? This isn't correct wrt the ABI, but it's what GCC does. */
> + regcache_cooked_write (regcache, ALPHA_FP0_REGNUM, valbuf);
> + break;
> +
> + case 16:
> + regcache_cooked_write (regcache, ALPHA_FP0_REGNUM, valbuf);
> + regcache_cooked_write (regcache, ALPHA_FP0_REGNUM+1,
> + (const char *)valbuf + 8);
> + break;
> +
> + case 32:
> + /* FIXME: 128-bit long doubles are returned like structures:
> + by writing into indirect storage provided by the caller
> + as the first argument. */
> + error ("Cannot set a 128-bit long double return value.");
> +
> + default:
> + abort ();
> + }
> + break;
> +
> default:
> /* Assume everything else degenerates to an integer. */
> l = unpack_long (valtype, valbuf);
>
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
next prev parent reply other threads:[~2003-06-02 18:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-02 5:40 Richard Henderson
2003-06-02 18:42 ` Daniel Jacobowitz [this message]
2003-06-03 0:27 ` Michael Snyder
2003-06-03 1:20 ` Daniel Jacobowitz
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=20030602184221.GA31924@nevyn.them.org \
--to=drow@mvista.com \
--cc=gdb-patches@sources.redhat.com \
--cc=rth@twiddle.net \
/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