From: Michael Snyder <msnyder@redhat.com>
To: gdb-patches@sources.redhat.com
Cc: cagney@redhat.com, kevinb@redhat.com
Subject: [RFA] mips-n32 reg_struct_has_addr
Date: Thu, 01 Aug 2002 19:37:00 -0000 [thread overview]
Message-ID: <3D49EC2D.86CF5517@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 269 bytes --]
This patch gdbarch-ifies reg_struct_has_addr for mips,
and then makes it work correctly for N32. In the process,
we move the functionality of reg_struct_has_addr out of
mips_push_arguments and put it where it belongs.
This is the other half of my earlier N32 patch.
[-- Attachment #2: patch1a.diff --]
[-- Type: text/plain, Size: 5757 bytes --]
2002-08-01 Michael Snyder <msnyder@redhat.com>
* mips-tdep.c (mips_eabi_reg_struct_has_addr,
mips_newabi_reg_struct_has_addr,
mips_oldabi_reg_struct_has_addr): New gdbarch functions.
(mips_push_argument): Don't convert struct args to pointers,
leave it to REG_STRUCT_HAS_ADDR.
(mips_gdbarch_init): Set gdbarch_reg_struct_has_addr.
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.87
diff -c -3 -p -r1.87 mips-tdep.c
*** mips-tdep.c 1 Aug 2002 21:36:27 -0000 1.87
--- mips-tdep.c 2 Aug 2002 02:01:01 -0000
*************** mips_use_struct_convention (int gcc_p, s
*** 567,572 ****
--- 567,606 ----
return 1; /* Structures are returned by ref in extra arg0 */
}
+ /* Should call_function pass struct by reference?
+ For each architecture, structs are passed either by
+ value or by reference, depending on their size. */
+
+ static int
+ mips_eabi_reg_struct_has_addr (int gcc_p, struct type *type)
+ {
+ enum type_code typecode = TYPE_CODE (check_typedef (type));
+ int len = TYPE_LENGTH (check_typedef (type));
+
+ if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
+ return (len > MIPS_SAVED_REGSIZE);
+
+ return 0;
+ }
+
+ static int
+ mips_newabi_reg_struct_has_addr (int gcc_p, struct type *type)
+ {
+ enum type_code typecode = TYPE_CODE (check_typedef (type));
+ int len = TYPE_LENGTH (check_typedef (type));
+
+ if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
+ return (len > MIPS_SAVED_REGSIZE && len % MIPS_SAVED_REGSIZE != 0);
+
+ return 0;
+ }
+
+ int
+ mips_oldabi_reg_struct_has_addr (int gcc_p, struct type *type)
+ {
+ return 0; /* FIXME: what should we do for old abi? */
+ }
+
/* Tell if the program counter value in MEMADDR is in a MIPS16 function. */
static int
*************** mips_push_arguments (int nargs,
*** 2428,2448 ****
"mips_push_arguments: %d len=%d type=%d",
argnum + 1, len, (int) typecode);
! /* The EABI passes structures that do not fit in a register by
! reference. In all other cases, pass the structure by value. */
! if (MIPS_EABI
! && len > MIPS_SAVED_REGSIZE
! && (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION))
! {
! store_address (valbuf, MIPS_SAVED_REGSIZE, VALUE_ADDRESS (arg));
! typecode = TYPE_CODE_PTR;
! len = MIPS_SAVED_REGSIZE;
! val = valbuf;
! if (mips_debug)
! fprintf_unfiltered (gdb_stdlog, " push");
! }
! else
! val = (char *) VALUE_CONTENTS (arg);
/* 32-bit ABIs always start floating point arguments in an
even-numbered floating point register. Round the FP register
--- 2462,2468 ----
"mips_push_arguments: %d len=%d type=%d",
argnum + 1, len, (int) typecode);
! val = (char *) VALUE_CONTENTS (arg);
/* 32-bit ABIs always start floating point arguments in an
even-numbered floating point register. Round the FP register
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4472,4477 ****
--- 4492,4500 ----
set_gdbarch_long_bit (gdbarch, 32);
set_gdbarch_ptr_bit (gdbarch, 32);
set_gdbarch_long_long_bit (gdbarch, 64);
+ /* Set up reg_struct_has_addr. */
+ set_gdbarch_reg_struct_has_addr (gdbarch,
+ mips_oldabi_reg_struct_has_addr);
break;
case MIPS_ABI_O64:
tdep->mips_default_saved_regsize = 8;
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4485,4490 ****
--- 4508,4516 ----
set_gdbarch_long_bit (gdbarch, 32);
set_gdbarch_ptr_bit (gdbarch, 32);
set_gdbarch_long_long_bit (gdbarch, 64);
+ /* Set up reg_struct_has_addr. */
+ set_gdbarch_reg_struct_has_addr (gdbarch,
+ mips_oldabi_reg_struct_has_addr);
break;
case MIPS_ABI_EABI32:
tdep->mips_default_saved_regsize = 4;
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4498,4503 ****
--- 4524,4532 ----
set_gdbarch_long_bit (gdbarch, 32);
set_gdbarch_ptr_bit (gdbarch, 32);
set_gdbarch_long_long_bit (gdbarch, 64);
+ /* Set up reg_struct_has_addr. */
+ set_gdbarch_reg_struct_has_addr (gdbarch,
+ mips_eabi_reg_struct_has_addr);
break;
case MIPS_ABI_EABI64:
tdep->mips_default_saved_regsize = 8;
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4511,4516 ****
--- 4540,4548 ----
set_gdbarch_long_bit (gdbarch, 64);
set_gdbarch_ptr_bit (gdbarch, 64);
set_gdbarch_long_long_bit (gdbarch, 64);
+ /* Set up reg_struct_has_addr. */
+ set_gdbarch_reg_struct_has_addr (gdbarch,
+ mips_eabi_reg_struct_has_addr);
break;
case MIPS_ABI_N32:
tdep->mips_default_saved_regsize = 4;
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4535,4540 ****
--- 4567,4575 ----
tm_print_insn_info.mach = info.bfd_arch_info->mach;
else
tm_print_insn_info.mach = bfd_mach_mips8000;
+ /* Set up reg_struct_has_addr. */
+ set_gdbarch_reg_struct_has_addr (gdbarch,
+ mips_newabi_reg_struct_has_addr);
break;
case MIPS_ABI_N64:
tdep->mips_default_saved_regsize = 8;
*************** mips_gdbarch_init (struct gdbarch_info i
*** 4559,4564 ****
--- 4594,4602 ----
tm_print_insn_info.mach = info.bfd_arch_info->mach;
else
tm_print_insn_info.mach = bfd_mach_mips8000;
+ /* Set up reg_struct_has_addr. */
+ set_gdbarch_reg_struct_has_addr (gdbarch,
+ mips_newabi_reg_struct_has_addr);
break;
default:
internal_error (__FILE__, __LINE__,
next reply other threads:[~2002-08-02 2:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-01 19:37 Michael Snyder [this message]
2002-08-06 15:02 ` Andrew Cagney
2002-08-06 15:50 ` Michael Snyder
2002-08-06 15:51 ` Michael Snyder
2002-08-07 10:12 ` Andrew Cagney
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=3D49EC2D.86CF5517@redhat.com \
--to=msnyder@redhat.com \
--cc=cagney@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=kevinb@redhat.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