* [RFA] mips-n32 reg_struct_has_addr
@ 2002-08-01 19:37 Michael Snyder
2002-08-06 15:02 ` Andrew Cagney
0 siblings, 1 reply; 5+ messages in thread
From: Michael Snyder @ 2002-08-01 19:37 UTC (permalink / raw)
To: gdb-patches; +Cc: cagney, kevinb
[-- 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__,
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFA] mips-n32 reg_struct_has_addr
2002-08-01 19:37 [RFA] mips-n32 reg_struct_has_addr Michael Snyder
@ 2002-08-06 15:02 ` Andrew Cagney
2002-08-06 15:50 ` Michael Snyder
2002-08-06 15:51 ` Michael Snyder
0 siblings, 2 replies; 5+ messages in thread
From: Andrew Cagney @ 2002-08-06 15:02 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
> + 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;
> + }
No, I don't think this is right. As best I can tell, there is no cap on
the size of a struct that is passed by register.
http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi/srch3@o32/0650/bks/SGI_Developer/books/Mpro_n32_ABI/sgi_html/ch02.html#id80931
I.e., o32 and n32/n64 are the same -> never pass structures by reference.
> *************** 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
Per other e-mail, rather than modify the existing mips_push_argument()
can you please created a dedicated mips_n32n64_push-arguments() function
and hack on that. That way, I don't have to worry about the other ABIs.
> + /* Set up reg_struct_has_addr. */
> + set_gdbarch_reg_struct_has_addr (gdbarch,
BTW, the comment here is redundant.
enjoy,
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFA] mips-n32 reg_struct_has_addr
2002-08-06 15:02 ` Andrew Cagney
@ 2002-08-06 15:50 ` Michael Snyder
2002-08-06 15:51 ` Michael Snyder
1 sibling, 0 replies; 5+ messages in thread
From: Michael Snyder @ 2002-08-06 15:50 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
Andrew Cagney wrote:
>
> > + 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;
> > + }
>
> No, I don't think this is right. As best I can tell, there is no cap on
> the size of a struct that is passed by register.
>
> http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi/srch3@o32/0650/bks/SGI_Developer/books/Mpro_n32_ABI/sgi_html/ch02.html#id80931
>
> I.e., o32 and n32/n64 are the same -> never pass structures by reference.
>
> > *************** 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
>
> Per other e-mail, rather than modify the existing mips_push_argument()
> can you please created a dedicated mips_n32n64_push-arguments() function
> and hack on that. That way, I don't have to worry about the other ABIs.
>
> > + /* Set up reg_struct_has_addr. */
> > + set_gdbarch_reg_struct_has_addr (gdbarch,
>
> BTW, the comment here is redundant.
>
> enjoy,
> Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFA] mips-n32 reg_struct_has_addr
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
1 sibling, 1 reply; 5+ messages in thread
From: Michael Snyder @ 2002-08-06 15:51 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
Andrew Cagney wrote:
>
> > + 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;
> > + }
>
> No, I don't think this is right. As best I can tell, there is no cap on
> the size of a struct that is passed by register.
>
> http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi/srch3@o32/0650/bks/SGI_Developer/books/Mpro_n32_ABI/sgi_html/ch02.html#id80931
>
> I.e., o32 and n32/n64 are the same -> never pass structures by reference.
OK, patch withdrawn, I will resubmit it using this assumption,
just to get the gdbarch-ification checked in, and then we can
work on resolving how N32/64 should work.
>
> > *************** 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
>
> Per other e-mail, rather than modify the existing mips_push_argument()
> can you please created a dedicated mips_n32n64_push-arguments() function
> and hack on that. That way, I don't have to worry about the other ABIs.
>
> > + /* Set up reg_struct_has_addr. */
> > + set_gdbarch_reg_struct_has_addr (gdbarch,
>
> BTW, the comment here is redundant.
>
> enjoy,
> Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFA] mips-n32 reg_struct_has_addr
2002-08-06 15:51 ` Michael Snyder
@ 2002-08-07 10:12 ` Andrew Cagney
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Cagney @ 2002-08-07 10:12 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
> No, I don't think this is right. As best I can tell, there is no cap on
>> the size of a struct that is passed by register.
>>
>> http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi/srch3@o32/0650/bks/SGI_Developer/books/Mpro_n32_ABI/sgi_html/ch02.html#id80931
>>
>> I.e., o32 and n32/n64 are the same -> never pass structures by reference.
>
>
> OK, patch withdrawn, I will resubmit it using this assumption,
> just to get the gdbarch-ification checked in, and then we can
> work on resolving how N32/64 should work.
Thanks!
BTW, if you're trying to test this, DO NOT TRUST GCC! Check things out
with an SGI compiler.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-08-07 17:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-01 19:37 [RFA] mips-n32 reg_struct_has_addr Michael Snyder
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox