From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27047 invoked by alias); 2 Aug 2002 02:37:49 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 27039 invoked from network); 2 Aug 2002 02:37:49 -0000 Received: from unknown (HELO cygnus.com) (205.180.83.203) by sources.redhat.com with SMTP; 2 Aug 2002 02:37:49 -0000 Received: from redhat.com (reddwarf.sfbay.redhat.com [172.16.24.50]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id TAA07774; Thu, 1 Aug 2002 19:37:10 -0700 (PDT) Message-ID: <3D49EC2D.86CF5517@redhat.com> Date: Thu, 01 Aug 2002 19:37:00 -0000 From: Michael Snyder Organization: Red Hat, Inc. X-Accept-Language: en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com CC: cagney@redhat.com, kevinb@redhat.com Subject: [RFA] mips-n32 reg_struct_has_addr Content-Type: multipart/mixed; boundary="------------44F14D9B1D5A51B7DD4EB912" X-SW-Source: 2002-08/txt/msg00049.txt.bz2 This is a multi-part message in MIME format. --------------44F14D9B1D5A51B7DD4EB912 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-length: 269 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. --------------44F14D9B1D5A51B7DD4EB912 Content-Type: text/plain; charset=us-ascii; name="patch1a.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch1a.diff" Content-length: 5757 2002-08-01 Michael Snyder * 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__, --------------44F14D9B1D5A51B7DD4EB912--