From patchwork Tue Sep 5 18:20:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 22633 Received: (qmail 53059 invoked by alias); 5 Sep 2017 18:20:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 52913 invoked by uid 89); 5 Sep 2017 18:20:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=pose, obstacle X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Sep 2017 18:20:52 +0000 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v85IKMZj050709 for ; Tue, 5 Sep 2017 14:20:50 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2csvwp57w4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 05 Sep 2017 14:20:50 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Sep 2017 19:20:48 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 5 Sep 2017 19:20:46 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v85IKjoV14221512 for ; Tue, 5 Sep 2017 18:20:45 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1018152041 for ; Tue, 5 Sep 2017 18:16:04 +0100 (BST) Received: from oc3748833570.ibm.com (unknown [9.164.150.234]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id E7DE85203F for ; Tue, 5 Sep 2017 18:16:03 +0100 (BST) Received: by oc3748833570.ibm.com (Postfix, from userid 1000) id 22009D8086F; Tue, 5 Sep 2017 20:20:45 +0200 (CEST) Subject: [RFC][03/19] Target FP: Complete tdep move to convert_typed_floating To: gdb-patches@sourceware.org Date: Tue, 5 Sep 2017 20:20:45 +0200 (CEST) From: "Ulrich Weigand" MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17090518-0012-0000-0000-00000574D674 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17090518-0013-0000-0000-000018ED0E5B Message-Id: <20170905182045.22009D8086F@oc3748833570.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-05_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709050267 [RFC][03/19] Target FP: Complete tdep move to convert_typed_floating Many tdep files need to perform conversions between two floating-point types, usually when accessing FP registers. Most targets now use the convert_typed_floating helper routine to do so. However, a small number still use the old method of converting via a DOUBLEST. Since we want to get rid of DOUBLEST, these targets need to be moves to the new method as well. The main obstacle is that for convert_typed_floating we need an actual *type*, not just a floatformat. In arm-tdep.c, this is very straightforward, since there is already a type using the ARM extended floatformat. For sh-tdep.c and sh64-tdep.c, no such type already exists, so I've added one to the gdbarch_tdep struct as done on other targets. Bye, Ulrich ChangeLog: * arm-tdep.c: Do not include "floatformat.h". (convert_from_extended): Remove. (convert_to_extended): Likewise. (arm_extract_return_value): Use convert_typed_floating. (arm_store_return_value): Likewise. * sh-tdep.h (struct gdbarch_tdep): Add sh_littlebyte_bigword_type. * sh-tdep.c: Do not include "floatformat.h". (sh_littlebyte_bigword_type): New function. (sh_register_convert_to_virtual): Use convert_typed_floating. (sh_register_convert_to_raw): Likewise. * sh64-tdep.c: Do not include "floatformat.h". (struct gdbarch_tdep): Add sh_littlebyte_bigword_type. (sh64_littlebyte_bigword_type): New function. (sh64_extract_return_value): Use convert_typed_floating. (sh64_register_convert_to_virtual): Likewise. (sh64_register_convert_to_raw): Likewise. Index: binutils-gdb/gdb/arm-tdep.c =================================================================== --- binutils-gdb.orig/gdb/arm-tdep.c +++ binutils-gdb/gdb/arm-tdep.c @@ -31,7 +31,6 @@ #include "regcache.h" #include "reggroups.h" #include "doublest.h" -#include "floatformat.h" #include "value.h" #include "arch-utils.h" #include "osabi.h" @@ -227,11 +226,6 @@ static void show_disassembly_style_sfunc struct cmd_list_element *, const char *); -static void convert_from_extended (const struct floatformat *, const void *, - void *, int); -static void convert_to_extended (const struct floatformat *, void *, - const void *, int); - static enum register_status arm_neon_quad_read (struct gdbarch *gdbarch, struct regcache *regcache, int regnum, gdb_byte *buf); @@ -4212,39 +4206,6 @@ arm_register_sim_regno (struct gdbarch * internal_error (__FILE__, __LINE__, _("Bad REGNUM %d"), regnum); } -/* NOTE: cagney/2001-08-20: Both convert_from_extended() and - convert_to_extended() use floatformat_arm_ext_littlebyte_bigword. - It is thought that this is is the floating-point register format on - little-endian systems. */ - -static void -convert_from_extended (const struct floatformat *fmt, const void *ptr, - void *dbl, int endianess) -{ - DOUBLEST d; - - if (endianess == BFD_ENDIAN_BIG) - floatformat_to_doublest (&floatformat_arm_ext_big, ptr, &d); - else - floatformat_to_doublest (&floatformat_arm_ext_littlebyte_bigword, - ptr, &d); - floatformat_from_doublest (fmt, &d, dbl); -} - -static void -convert_to_extended (const struct floatformat *fmt, void *dbl, const void *ptr, - int endianess) -{ - DOUBLEST d; - - floatformat_to_doublest (fmt, ptr, &d); - if (endianess == BFD_ENDIAN_BIG) - floatformat_from_doublest (&floatformat_arm_ext_big, &d, dbl); - else - floatformat_from_doublest (&floatformat_arm_ext_littlebyte_bigword, - &d, dbl); -} - /* Given BUF, which is OLD_LEN bytes ending at ENDADDR, expand the buffer to be NEW_LEN bytes ending at ENDADDR. Return NULL if an error occurs. BUF is freed. */ @@ -7949,8 +7910,8 @@ arm_extract_return_value (struct type *t bfd_byte tmpbuf[FP_REGISTER_SIZE]; regcache_cooked_read (regs, ARM_F0_REGNUM, tmpbuf); - convert_from_extended (floatformat_from_type (type), tmpbuf, - valbuf, gdbarch_byte_order (gdbarch)); + convert_typed_floating (tmpbuf, arm_ext_type (gdbarch), + valbuf, type); } break; @@ -8154,8 +8115,7 @@ arm_store_return_value (struct type *typ { case ARM_FLOAT_FPA: - convert_to_extended (floatformat_from_type (type), buf, valbuf, - gdbarch_byte_order (gdbarch)); + convert_typed_floating (valbuf, type, buf, arm_ext_type (gdbarch)); regcache_cooked_write (regs, ARM_F0_REGNUM, buf); break; Index: binutils-gdb/gdb/sh-tdep.h =================================================================== --- binutils-gdb.orig/gdb/sh-tdep.h +++ binutils-gdb/gdb/sh-tdep.h @@ -101,6 +101,8 @@ struct gdbarch_tdep inside the associated core file section. */ struct sh_corefile_regmap *core_fpregmap; int sizeof_fpregset; + /* ISA-specific data types. */ + struct type *sh_littlebyte_bigword_type; }; extern const struct regset sh_corefile_gregset; Index: binutils-gdb/gdb/sh-tdep.c =================================================================== --- binutils-gdb.orig/gdb/sh-tdep.c +++ binutils-gdb/gdb/sh-tdep.c @@ -33,7 +33,6 @@ #include "dis-asm.h" #include "inferior.h" #include "arch-utils.h" -#include "floatformat.h" #include "regcache.h" #include "doublest.h" #include "osabi.h" @@ -1552,6 +1551,19 @@ sh_register_reggroup_p (struct gdbarch * The other pseudo registers (the FVs) also don't pose a problem because they are stored as 4 individual FP elements. */ +static struct type * +sh_littlebyte_bigword_type (struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (!tdep->sh_littlebyte_bigword_type) + tdep->sh_littlebyte_bigword_type + = arch_float_type (gdbarch, -1, "builtin_type_sh_littlebyte_bigword", + floatformats_arm_ext); + + return tdep->sh_littlebyte_bigword_type; +} + static void sh_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum, struct type *type, gdb_byte *from, gdb_byte *to) @@ -1564,12 +1576,8 @@ sh_register_convert_to_virtual (struct g } if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM) - { - DOUBLEST val; - floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword, - from, &val); - store_typed_floating (to, type, val); - } + convert_typed_floating (from, sh_littlebyte_bigword_type (gdbarch), + to, type); else error ("sh_register_convert_to_virtual called with non DR register number"); @@ -1587,11 +1595,8 @@ sh_register_convert_to_raw (struct gdbar } if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM) - { - DOUBLEST val = extract_typed_floating (from, type); - floatformat_from_doublest (&floatformat_ieee_double_littlebyte_bigword, - &val, to); - } + convert_typed_floating (from, type, + to, sh_littlebyte_bigword_type (gdbarch)); else error (_("sh_register_convert_to_raw called with non DR register number")); } Index: binutils-gdb/gdb/sh64-tdep.c =================================================================== --- binutils-gdb.orig/gdb/sh64-tdep.c +++ binutils-gdb/gdb/sh64-tdep.c @@ -26,7 +26,6 @@ #include "frame-unwind.h" #include "dwarf2-frame.h" #include "symtab.h" -#include "floatformat.h" #include "gdbtypes.h" #include "gdbcmd.h" #include "gdbcore.h" @@ -59,8 +58,23 @@ enum sh_abi struct gdbarch_tdep { enum sh_abi sh_abi; + /* ISA-specific data types. */ + struct type *sh_littlebyte_bigword_type; }; +struct type * +sh64_littlebyte_bigword_type (struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + if (!tdep->sh_littlebyte_bigword_type) + tdep->sh_littlebyte_bigword_type + = arch_float_type (gdbarch, -1, "builtin_type_sh_littlebyte_bigword", + floatformats_arm_ext); + + return tdep->sh_littlebyte_bigword_type; +} + struct sh64_frame_cache { /* Base address. */ @@ -1241,18 +1255,11 @@ sh64_extract_return_value (struct type * else if (len == 8) { /* return value stored in DR0_REGNUM. */ - DOUBLEST val; gdb_byte buf[8]; - regcache_cooked_read (regcache, DR0_REGNUM, buf); - if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) - floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword, - buf, &val); - else - floatformat_to_doublest (&floatformat_ieee_double_big, - buf, &val); - store_typed_floating (valbuf, type, val); + convert_typed_floating (buf, sh64_littlebyte_bigword_type (gdbarch), + valbuf, type); } } else @@ -1461,12 +1468,8 @@ sh64_register_convert_to_virtual (struct && regnum <= DR_LAST_REGNUM) || (regnum >= DR0_C_REGNUM && regnum <= DR_LAST_C_REGNUM)) - { - DOUBLEST val; - floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword, - from, &val); - store_typed_floating (to, type, val); - } + convert_typed_floating (from, sh64_littlebyte_bigword_type (gdbarch), + to, type); else error (_("sh64_register_convert_to_virtual " "called with non DR register number")); @@ -1487,11 +1490,8 @@ sh64_register_convert_to_raw (struct gdb && regnum <= DR_LAST_REGNUM) || (regnum >= DR0_C_REGNUM && regnum <= DR_LAST_C_REGNUM)) - { - DOUBLEST val = extract_typed_floating (from, type); - floatformat_from_doublest (&floatformat_ieee_double_littlebyte_bigword, - &val, to); - } + convert_typed_floating (from, type, + to, sh64_littlebyte_bigword_type (gdbarch)); else error (_("sh64_register_convert_to_raw called " "with non DR register number"));