From: Jim Blandy <jimb@redhat.com>
To: Andrew Cagney <cagney@gnu.org>
Cc: gdb-patches@sources.redhat.com
Subject: Re: RFA: PowerPC sim & GDB: use fixed register numbering
Date: Thu, 05 Aug 2004 15:22:00 -0000 [thread overview]
Message-ID: <vt2n0198ve1.fsf@zenia.home> (raw)
In-Reply-To: <41117CBE.3000904@gnu.org>
Andrew Cagney <cagney@gnu.org> writes:
> Close, I checked this in.
>
> Andrew
>
> 2004-08-04 Andrew Cagney <cagney@gnu.org>
> Jim Blandy <jimb@redhat.com>
>
> * 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?
next prev parent reply other threads:[~2004-08-05 15:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-20 20:40 Jim Blandy
2004-07-23 23:12 ` Kevin Buettner
2004-08-03 14:23 ` Andrew Cagney
2004-08-04 5:47 ` Jim Blandy
2004-08-04 13:53 ` Andrew Cagney
2004-08-04 17:13 ` Jim Blandy
2004-08-04 17:33 ` Andrew Cagney
2004-08-04 17:56 ` Jim Blandy
2004-08-04 18:07 ` Andrew Cagney
2004-08-04 21:26 ` Jim Blandy
2004-08-05 0:18 ` Andrew Cagney
2004-08-05 15:22 ` Jim Blandy [this message]
2004-08-05 16:10 ` Andrew Cagney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vt2n0198ve1.fsf@zenia.home \
--to=jimb@redhat.com \
--cc=cagney@gnu.org \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox