From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12482 invoked by alias); 10 Feb 2004 16:14:39 -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 12473 invoked from network); 10 Feb 2004 16:14:37 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 10 Feb 2004 16:14:37 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu-dmz.redhat.com [172.16.52.200] (may be forged)) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id i1AGEab26364 for ; Tue, 10 Feb 2004 11:14:36 -0500 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i1AGEZM14677 for ; Tue, 10 Feb 2004 11:14:35 -0500 Received: from cygbert.vinschen.de (vpn50-37.rdu.redhat.com [172.16.50.37]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id i1AGESX21992 for ; Tue, 10 Feb 2004 08:14:29 -0800 Received: by cygbert.vinschen.de (Postfix, from userid 500) id 48EC158459; Tue, 10 Feb 2004 17:14:22 +0100 (CET) Date: Tue, 10 Feb 2004 16:14:00 -0000 From: Corinna Vinschen To: gdb-patches@sources.redhat.com Subject: [RFA] sh-tdep.c: optimize and rename virtual register conversion functions Message-ID: <20040210161422.GI4162@cygbert.vinschen.de> Reply-To: gdb-patches@sources.redhat.com Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-SW-Source: 2004-02/txt/msg00234.txt.bz2 Hi, the functions sh_sh4_register_convert_to_virtual and sh_sh4_register_convert_to_raw are only called once each. In both cases, the register numbers are already tested for the correct range, before the function is actually called. Therefore it's possible to optimize the register number tests away from both functions. Also, I'd like to propose to rename both functions to get rid of the "sh4" in the name. The functions are universal so I'd like to reuse them for an upcoming SH variant with different virtual register numbering, if that's ok. Thanks in advance, Corinna ChangeLog: * sh-tdep.c (sh_register_convert_to_virtual): Rename from sh_sh4_register_convert_to_virtual. Remove register number test. (sh_register_convert_to_raw): Rename from sh_sh4_register_convert_to_raw. Remove register number test. Index: sh-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/sh-tdep.c,v retrieving revision 1.156 diff -u -p -r1.156 sh-tdep.c --- sh-tdep.c 26 Jan 2004 20:52:12 -0000 1.156 +++ sh-tdep.c 10 Feb 2004 15:58:04 -0000 @@ -1541,33 +1541,22 @@ sh_default_register_type (struct gdbarch because they are stored as 4 individual FP elements. */ static void -sh_sh4_register_convert_to_virtual (int regnum, struct type *type, +sh_register_convert_to_virtual (int regnum, struct type *type, char *from, char *to) { - 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); - } - else - error - ("sh_register_convert_to_virtual called with non DR register number"); + DOUBLEST val; + floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword, + from, &val); + store_typed_floating (to, type, val); } static void -sh_sh4_register_convert_to_raw (struct type *type, int regnum, +sh_register_convert_to_raw (struct type *type, int regnum, const void *from, void *to) { - 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); - } - else - error ("sh_register_convert_to_raw called with non DR register number"); + DOUBLEST val = extract_typed_floating (from, type); + floatformat_from_doublest (&floatformat_ieee_double_littlebyte_bigword, + &val, to); } /* For vectors of 4 floating point registers. */ @@ -1609,7 +1598,7 @@ sh_pseudo_register_read (struct gdbarch + register_size (gdbarch, base_regnum) * portion)); /* We must pay attention to the endiannes. */ - sh_sh4_register_convert_to_virtual (reg_nr, + sh_register_convert_to_virtual (reg_nr, gdbarch_register_type (gdbarch, reg_nr), temp_buffer, buffer); @@ -1639,7 +1628,7 @@ sh_pseudo_register_write (struct gdbarch base_regnum = dr_reg_base_num (reg_nr); /* We must pay attention to the endiannes. */ - sh_sh4_register_convert_to_raw (gdbarch_register_type (gdbarch, reg_nr), + sh_register_convert_to_raw (gdbarch_register_type (gdbarch, reg_nr), reg_nr, buffer, temp_buffer); /* Write the real regs for which this one is an alias. */ -- Corinna Vinschen Cygwin Developer Red Hat, Inc.