From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16277 invoked by alias); 5 Aug 2004 15:22:31 -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 16262 invoked from network); 5 Aug 2004 15:22:30 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 5 Aug 2004 15:22:30 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i75FMUe1028762 for ; Thu, 5 Aug 2004 11:22:30 -0400 Received: from zenia.home.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i75FMRa32066; Thu, 5 Aug 2004 11:22:28 -0400 To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: RFA: PowerPC sim & GDB: use fixed register numbering References: <410F8C3E.3060502@gnu.org> <4110EA27.7020904@gnu.org> <41111DEC.7080102@gnu.org> <411125CF.1040102@gnu.org> <41117CBE.3000904@gnu.org> From: Jim Blandy Date: Thu, 05 Aug 2004 15:22:00 -0000 In-Reply-To: <41117CBE.3000904@gnu.org> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-08/txt/msg00116.txt.bz2 Andrew Cagney writes: > Close, I checked this in. > > Andrew > > 2004-08-04 Andrew Cagney > Jim Blandy > > * sim_callbacks.h (simulator): Declare. > * Makefile.in (gdb-sim.o): New rule. > (MAIN_SRC, GDB_OBJ): Add gdb-sim.o, gdb-sim.c. > (DEFS_H): Delete. > (GDB_SIM_PPC_H): Define. > * gdb-sim.c: New file. > * sim_calls.c: Do not include "defs.h". > (simulator): Drop static. > (sim_store_register, sim_fetch_register): Delete. Works for me. Thanks very much. In light of the changes you asked for, I have a question about the D10v simulator. It has code like this: switch ((enum sim_d10v_regs) rn) { case SIM_D10V_R0_REGNUM: case SIM_D10V_R1_REGNUM: case SIM_D10V_R2_REGNUM: case SIM_D10V_R3_REGNUM: case SIM_D10V_R4_REGNUM: case SIM_D10V_R5_REGNUM: case SIM_D10V_R6_REGNUM: case SIM_D10V_R7_REGNUM: case SIM_D10V_R8_REGNUM: case SIM_D10V_R9_REGNUM: case SIM_D10V_R10_REGNUM: case SIM_D10V_R11_REGNUM: case SIM_D10V_R12_REGNUM: case SIM_D10V_R13_REGNUM: case SIM_D10V_R14_REGNUM: case SIM_D10V_R15_REGNUM: SET_GPR (rn - SIM_D10V_R0_REGNUM, READ_16 (memory)); size = 2; break; By doing arithmetic on the enum values, this code assumes that they're listed contiguously in the enum, in the order given. Is this kosher? Wouldn't it be preferable to have something like: /* If REGNUM is a general-purpose register number, return the gpr index (0 for R0, 7 for R7, ...). Otherwise, return -1. */ int d10v_gpr_regnum (enum sim_d10v_regs regnum) { switch (regnum) { case SIM_D10V_R0_REGNUM: return 0; case SIM_D10V_R1_REGNUM: return 1; case SIM_D10V_R2_REGNUM: return 2; case SIM_D10V_R3_REGNUM: return 3; case SIM_D10V_R4_REGNUM: return 4; case SIM_D10V_R5_REGNUM: return 5; case SIM_D10V_R6_REGNUM: return 6; case SIM_D10V_R7_REGNUM: return 7; case SIM_D10V_R8_REGNUM: return 8; case SIM_D10V_R9_REGNUM: return 9; case SIM_D10V_R10_REGNUM: return 10; case SIM_D10V_R11_REGNUM: return 11; case SIM_D10V_R12_REGNUM: return 12; case SIM_D10V_R13_REGNUM: return 13; case SIM_D10V_R14_REGNUM: return 14; case SIM_D10V_R15_REGNUM: return 15; default: return -1; } } with corresponding functions for the other register banks, and then write sim_store_register as a chain of 'if's?