From: Michael Snyder <msnyder@redhat.com>
To: Kazu Hirata <kazu@cs.umass.edu>
Cc: gdb-patches@sources.redhat.com
Subject: Re: Unreviewed patches
Date: Wed, 05 Feb 2003 22:41:00 -0000 [thread overview]
Message-ID: <3E4192FB.3CACD354@redhat.com> (raw)
In-Reply-To: <20030203.183018.48516571.kazu@cs.umass.edu>
Kazu Hirata wrote:
>
> Hi Michael,
>
> > > I understand your concern. But then if GET_W_REG may give a
> > > byte-swapped value, would the following be endian unsafe?
> > >
> > > case O (O_ADD, SW):
> > > rd = GET_W_REG (code->dst.reg);
> > > ea = fetch (&code->src);
> > > res = rd + ea;
> > > goto alu16;
> > >
> > > The addition is done in host-order.
> >
> > I don't know, other than to say that it evidently works. However in
> > this case we are fetching a half-word as a half-word. In the other
> > case, we are fetching a byte as a half-word, and assuming
> > (incorrectly, I think) that the byte we actually want will be in the
> > lower half of the half-word.
>
> Well, not quite. In *both* cases (O_ADD and O_EXTU), we assume that
>
> (GET_W_REG(0) & 0xff) == r0l
>
> Otherwise, the instructions like addition, subtraction, and shift
> wouldn't work. If you think of extu.w as a special case of and.w,
> where you clear off the upper half by anding with 0x00ff, my patch
> should be correct.
>
> What about something like the attached patch? If every wreg[i] is set
> to some useful value, that means that both of
>
> if (*q == 0x2233)
>
> and
>
> if (*q == 0x0011)
>
> triggered for every i. 0x2233 is exactly the lower half of
> 0x00112233. Likewise, 0x0011 is exactly the upper half of 0x00112233.
> This means that wreg[i] can access either the lower or upper half of a
> 32-bit register without the byte swap. In turn, this means that
> GET_W_REG is guaranteed to return a non-swapped value. If wreg[i] is
> NULL, the simulator won't work, so just abort().
>
> Kazu Hirata
All right.
> Index: compile.c
> ===================================================================
> RCS file: /cvs/src/src/sim/h8300/compile.c,v
> retrieving revision 1.21
> diff -u -6 -r1.21 compile.c
> --- compile.c 1 Feb 2003 03:00:14 -0000 1.21
> +++ compile.c 3 Feb 2003 23:17:16 -0000
> @@ -750,24 +750,27 @@
> if (*p == 0x33)
> {
> breg[i + 8] = p;
> }
> p++;
> }
> + wreg[i] = wreg[i + 8] = 0;
> while (q < u)
> {
> if (*q == 0x2233)
> {
> wreg[i] = q;
> }
> if (*q == 0x0011)
> {
> wreg[i + 8] = q;
> }
> q++;
> }
> + if (wreg[i] == 0 || wreg[i + 8] == 0)
> + abort ();
> cpu.regs[i] = 0;
> lreg[i] = &cpu.regs[i];
> }
>
> lreg[8] = &cpu.regs[8];
>
> @@ -1603,23 +1606,23 @@
> else
> nz = 0;
> SET_L_REG (code->dst.reg, (rd & 0xffff) | (tmp << 16));
> goto next;
> }
> case O (O_EXTS, SW):
> - rd = GET_B_REG (code->src.reg + 8) & 0xff; /* Yes, src, not dst. */
> + rd = GET_W_REG (code->src.reg) & 0xff; /* Yes, src, not dst. */
> ea = rd & 0x80 ? -256 : 0;
> res = rd + ea;
> goto log16;
> case O (O_EXTS, SL):
> rd = GET_W_REG (code->src.reg) & 0xffff;
> ea = rd & 0x8000 ? -65536 : 0;
> res = rd + ea;
> goto log32;
> case O (O_EXTU, SW):
> - rd = GET_B_REG (code->src.reg + 8) & 0xff;
> + rd = GET_W_REG (code->src.reg) & 0xff;
> ea = 0;
> res = rd + ea;
> goto log16;
> case O (O_EXTU, SL):
> rd = GET_W_REG (code->src.reg) & 0xffff;
> ea = 0;
next prev parent reply other threads:[~2003-02-05 22:41 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-30 6:03 Kazu Hirata
2003-01-31 2:36 ` Michael Snyder
2003-01-31 4:54 ` Kazu Hirata
2003-02-01 1:27 ` Michael Snyder
2003-02-01 3:23 ` Kazu Hirata
2003-02-03 20:30 ` Michael Snyder
2003-02-03 23:30 ` Kazu Hirata
2003-02-05 22:41 ` Michael Snyder [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-10-11 14:51 Kazu Hirata
2007-10-04 12:04 Kazu Hirata
2003-01-17 4:33 Kazu Hirata
2002-07-01 6:55 Joern Rennecke
2002-07-01 8:47 ` Elena Zannoni
2002-07-01 10:10 ` Joern Rennecke
2002-07-01 14:24 ` Elena Zannoni
2002-07-01 15:01 ` Joern Rennecke
2002-07-02 12:32 ` Elena Zannoni
2002-07-03 13:49 ` Joern Rennecke
2002-07-12 4:59 ` Elena Zannoni
2002-07-12 5:47 ` Joern Rennecke
2002-07-12 8:23 ` Andrew Cagney
2002-07-17 11:30 ` Joern Rennecke
2002-07-17 13:04 ` Andrew Cagney
2002-08-05 6:47 ` Elena Zannoni
2002-07-12 11:36 ` Elena Zannoni
2002-06-19 14:29 Joern Rennecke
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=3E4192FB.3CACD354@redhat.com \
--to=msnyder@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=kazu@cs.umass.edu \
/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