This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch] sh-sim: fencepost error fixes
- From: Michael Snyder <msnyder at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 25 Jul 2003 17:33:47 -0700
- Subject: [patch] sh-sim: fencepost error fixes
2003-07-25 Michael Snyder <msnyder@redhat.com>
* gencode.c (pshl): Change < to <= (shift by 16 is allowed).
Cast argument of >> to unsigned to prevent sign extension.
(psha): Change < to <= (shift by 32 is allowed).
Index: gencode.c
===================================================================
RCS file: /cvs/cvsfiles/devo/sim/sh/gencode.c,v
retrieving revision 1.64
diff -p -r1.64 gencode.c
*** gencode.c 25 Jul 2003 00:58:09 -0000 1.64
--- gencode.c 25 Jul 2003 23:49:07 -0000
*************** op ppi_tab[] =
*** 1653,1662 ****
{ "","", "pshl #<imm>,dz", "00000iiim16.zzzz",
"int Sz = DSP_R (z) & 0xffff0000;",
"",
! "if (i < 16)",
" res = Sz << i;",
"else if (i >= 128 - 16)",
! " res = Sz >> 128 - i;",
"else",
" {",
" RAISE_EXCEPTION (SIGILL);",
--- 1653,1662 ----
{ "","", "pshl #<imm>,dz", "00000iiim16.zzzz",
"int Sz = DSP_R (z) & 0xffff0000;",
"",
! "if (i <= 16)",
" res = Sz << i;",
"else if (i >= 128 - 16)",
! " res = (unsigned) Sz >> 128 - i; /* no sign extension */",
"else",
" {",
" RAISE_EXCEPTION (SIGILL);",
*************** op ppi_tab[] =
*** 1670,1676 ****
"int Sz = DSP_R (z);",
"int Sz_grd = GET_DSP_GRD (z);",
"",
! "if (i < 32)",
" {",
" if (i == 32)",
" {",
--- 1670,1676 ----
"int Sz = DSP_R (z);",
"int Sz_grd = GET_DSP_GRD (z);",
"",
! "if (i <= 32)",
" {",
" if (i == 32)",
" {",
*************** op ppi_tab[] =
*** 1962,1971 ****
"int Sx = DSP_R (x) & 0xffff0000;",
"int Sy = DSP_R (y) >> 16 & 0x7f;",
"",
! "if (Sy < 16)",
" res = Sx << Sy;",
"else if (Sy >= 128 - 16)",
! " res = Sx >> 128 - Sy;",
"else",
" {",
" RAISE_EXCEPTION (SIGILL);",
--- 1962,1971 ----
"int Sx = DSP_R (x) & 0xffff0000;",
"int Sy = DSP_R (y) >> 16 & 0x7f;",
"",
! "if (Sy <= 16)",
" res = Sx << Sy;",
"else if (Sy >= 128 - 16)",
! " res = (unsigned) Sx >> 128 - Sy; /* no sign extension */",
"else",
" {",
" RAISE_EXCEPTION (SIGILL);",
*************** op ppi_tab[] =
*** 1978,1984 ****
"int Sx_grd = GET_DSP_GRD (x);",
"int Sy = DSP_R (y) >> 16 & 0x7f;",
"",
! "if (Sy < 32)",
" {",
" if (Sy == 32)",
" {",
--- 1978,1984 ----
"int Sx_grd = GET_DSP_GRD (x);",
"int Sy = DSP_R (y) >> 16 & 0x7f;",
"",
! "if (Sy <= 32)",
" {",
" if (Sy == 32)",
" {",