2003-12-18 Michael Snyder <msnyder@redhat.com>
* gencode.c (expand_opcode): Simplify and reorganize. Eliminate "shift" parameter. Eliminate "4 bits at a time" assumption. Flatten switch statement to a single level. Add "eeee" token for even-numbered registers. (bton): Delete. (fsca): Use "eeee" token. (ppi_moves): Rename to "expand_ppi_movxy". Do the ddt [movx/movy] expansion here, as well as the ppi expansion. (gensim_caselist): Accept 'eeee' along with 'nnnn'.
This commit is contained in:
parent
3d29fdb489
commit
673fc5d0a7
|
@ -1,3 +1,15 @@
|
||||||
|
2003-12-18 Michael Snyder <msnyder@redhat.com>
|
||||||
|
|
||||||
|
* gencode.c (expand_opcode): Simplify and reorganize.
|
||||||
|
Eliminate "shift" parameter. Eliminate "4 bits at a time"
|
||||||
|
assumption. Flatten switch statement to a single level.
|
||||||
|
Add "eeee" token for even-numbered registers.
|
||||||
|
(bton): Delete.
|
||||||
|
(fsca): Use "eeee" token.
|
||||||
|
(ppi_moves): Rename to "expand_ppi_movxy". Do the ddt
|
||||||
|
[movx/movy] expansion here, as well as the ppi expansion.
|
||||||
|
(gensim_caselist): Accept 'eeee' along with 'nnnn'.
|
||||||
|
|
||||||
2003-11-03 J"orn Rennecke <joern.rennecke@superh.com>
|
2003-11-03 J"orn Rennecke <joern.rennecke@superh.com>
|
||||||
|
|
||||||
* interp.c (fsca_s, fsrra_s): New functions.
|
* interp.c (fsca_s, fsrra_s): New functions.
|
||||||
|
|
165
sim/sh/gencode.c
165
sim/sh/gencode.c
|
@ -449,7 +449,7 @@ op tab[] =
|
||||||
},
|
},
|
||||||
|
|
||||||
/* sh4 */
|
/* sh4 */
|
||||||
{ "", "", "fsca", "1111nnn011111101",
|
{ "", "", "fsca", "1111eeee11111101",
|
||||||
"if (FPSCR_PR)",
|
"if (FPSCR_PR)",
|
||||||
" RAISE_EXCEPTION (SIGILL);",
|
" RAISE_EXCEPTION (SIGILL);",
|
||||||
"else",
|
"else",
|
||||||
|
@ -1950,128 +1950,100 @@ gengastab ()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert a string of 4 binary digits into an int */
|
|
||||||
|
|
||||||
static
|
|
||||||
int
|
|
||||||
bton (s)
|
|
||||||
char *s;
|
|
||||||
|
|
||||||
{
|
|
||||||
int n = 0;
|
|
||||||
int v = 8;
|
|
||||||
while (v)
|
|
||||||
{
|
|
||||||
if (*s == '1')
|
|
||||||
n |= v;
|
|
||||||
v >>= 1;
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned char table[1 << 16];
|
static unsigned char table[1 << 16];
|
||||||
|
|
||||||
/* Take an opcode expand all varying fields in it out and fill all the
|
/* Take an opcode, expand all varying fields in it out and fill all the
|
||||||
right entries in 'table' with the opcode index*/
|
right entries in 'table' with the opcode index. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
expand_opcode (shift, val, i, s)
|
expand_opcode (val, i, s)
|
||||||
int shift;
|
|
||||||
int val;
|
int val;
|
||||||
int i;
|
int i;
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
int j;
|
|
||||||
|
|
||||||
if (*s == 0)
|
if (*s == 0)
|
||||||
{
|
{
|
||||||
table[val] = i;
|
table[val] = i;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int j = 0, m = 0;
|
||||||
|
|
||||||
switch (s[0])
|
switch (s[0])
|
||||||
{
|
{
|
||||||
|
default:
|
||||||
|
fprintf (stderr, "expand_opcode: illegal char '%c'\n", s[0]);
|
||||||
|
exit (1);
|
||||||
case '0':
|
case '0':
|
||||||
case '1':
|
case '1':
|
||||||
{
|
/* Consume an arbitrary number of ones and zeros. */
|
||||||
int m, mv;
|
do {
|
||||||
|
j = (j << 1) + (s[m++] - '0');
|
||||||
if (s[1] - '0' > 1U || !s[2] || ! s[3])
|
} while (s[m] == '0' || s[m] == '1');
|
||||||
expand_opcode (shift - 1, val + s[0] - '0', i, s + 1);
|
expand_opcode ((val << m) | j, i, s + m);
|
||||||
val |= bton (s) << shift;
|
|
||||||
if (s[2] == '0' || s[2] == '1')
|
|
||||||
expand_opcode (shift - 4, val, i, s + 4);
|
|
||||||
else if (s[2] == 'N')
|
|
||||||
for (j = 0; j < 4; j++)
|
|
||||||
expand_opcode (shift - 4, val | (j << shift), i, s + 4);
|
|
||||||
else if (s[2] == 'x')
|
|
||||||
for (j = 0; j < 4; j += 2)
|
|
||||||
for (m = 0; m < 32; m++)
|
|
||||||
{
|
|
||||||
/* Ignore illegal nopy */
|
|
||||||
if ((m & 7) == 0 && m != 0)
|
|
||||||
continue;
|
|
||||||
mv = m & 3 | (m & 4) << 2 | (m & 8) << 3 | (m & 16) << 4;
|
|
||||||
expand_opcode (shift - 4, val | mv | (j << shift), i,
|
|
||||||
s + 4);
|
|
||||||
}
|
|
||||||
else if (s[2] == 'y')
|
|
||||||
for (j = 0; j < 2; j++)
|
|
||||||
expand_opcode (shift - 4, val | (j << shift), i, s + 4);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
case 'N': /* NN -- four-way fork */
|
||||||
|
for (j = 0; j < 4; j++)
|
||||||
|
expand_opcode ((val << 2) | j, i, s + 2);
|
||||||
|
break;
|
||||||
|
case 'x': /* xx -- 2-way fork */
|
||||||
|
/* Cross-breeding with movy moved to separate function. */
|
||||||
|
for (j = 0; j < 4; j += 2)
|
||||||
|
expand_opcode ((val << 2) | j, i, s + 2);
|
||||||
|
break;
|
||||||
|
case 'y': /* yy -- two-way fork */
|
||||||
|
for (j = 0; j < 2; j++)
|
||||||
|
expand_opcode ((val << 2) | j, i, s + 2);
|
||||||
|
break;
|
||||||
|
case 'i': /* eg. "i8*1" */
|
||||||
|
case '.': /* "...." is a wildcard */
|
||||||
case 'n':
|
case 'n':
|
||||||
case 'm':
|
case 'm':
|
||||||
{
|
/* nnnn, mmmm, i#*#, .... -- 16-way fork. */
|
||||||
int digits = 1;
|
for (j = 0; j < 16; j++)
|
||||||
while (s[digits] == s[0])
|
expand_opcode ((val << 4) | j, i, s + 4);
|
||||||
digits++;
|
break;
|
||||||
for (j = 0; j < (1 << digits); j++)
|
case 'e':
|
||||||
{
|
/* eeee -- even numbered register:
|
||||||
expand_opcode (shift - digits, val | (j << shift), i,
|
8 way fork. */
|
||||||
s + digits);
|
for (j = 0; j < 15; j += 2)
|
||||||
}
|
expand_opcode ((val << 4) | j, i, s + 4);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 'M':
|
case 'M':
|
||||||
/* A1, A0,X0,X1,Y0,Y1,M0,A1G,M1,M1G */
|
/* A0, A1, X0, X1, Y0, Y1, M0, M1, A0G, A1G:
|
||||||
for (j = 5; j < 16; j++)
|
MMMM -- 10-way fork */
|
||||||
if (j != 6)
|
expand_opcode ((val << 4) | 5, i, s + 4);
|
||||||
expand_opcode (shift - 4, val | (j << shift), i, s + 4);
|
for (j = 7; j < 16; j++)
|
||||||
|
expand_opcode ((val << 4) | j, i, s + 4);
|
||||||
break;
|
break;
|
||||||
case 'G':
|
case 'G':
|
||||||
/* A1G, A0G: */
|
/* A1G, A0G:
|
||||||
|
GGGG -- two-way fork */
|
||||||
for (j = 13; j <= 15; j +=2)
|
for (j = 13; j <= 15; j +=2)
|
||||||
expand_opcode (shift - 4, val | (j << shift), i, s + 4);
|
expand_opcode ((val << 4) | j, i, s + 4);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
|
/* ssss -- 10-way fork */
|
||||||
/* System registers mach, macl, pr: */
|
/* System registers mach, macl, pr: */
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
expand_opcode (shift - 4, val | (j << shift), i, s + 4);
|
expand_opcode ((val << 4) | j, i, s + 4);
|
||||||
/* System registers fpul, fpscr/dsr, a0, x0, x1, y0, y1: */
|
/* System registers fpul, fpscr/dsr, a0, x0, x1, y0, y1: */
|
||||||
for (j = 5; j < 12; j++)
|
for (j = 5; j < 12; j++)
|
||||||
expand_opcode (shift - 4, val | (j << shift), i, s + 4);
|
expand_opcode ((val << 4) | j, i, s + 4);
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
case 'a':
|
case 'a':
|
||||||
val |= bton (s) << shift;
|
/* XX, aa -- two-way fork */
|
||||||
for (j = 0; j < 16; j += 8)
|
for (j = 0; j < 4; j += 2)
|
||||||
expand_opcode (shift - 4, val | (j << shift), i, s + 4);
|
expand_opcode ((val << 2) | j, i, s + 2);
|
||||||
break;
|
break;
|
||||||
case 'Y':
|
case 'Y':
|
||||||
case 'A':
|
case 'A':
|
||||||
val |= bton (s) << shift;
|
/* YY, AA -- two-way fork */
|
||||||
for (j = 0; j < 8; j += 4)
|
for (j = 0; j < 2; j++)
|
||||||
expand_opcode (shift - 4, val | (j << shift), i, s + 4);
|
expand_opcode ((val << 2) | j, i, s + 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
for (j = 0; j < (1 << (shift + 4)); j++)
|
|
||||||
{
|
|
||||||
table[val | j] = i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2127,7 +2099,7 @@ filltable (p)
|
||||||
for (; p->name; p++)
|
for (; p->name; p++)
|
||||||
{
|
{
|
||||||
p->index = index++;
|
p->index = index++;
|
||||||
expand_opcode (12, 0, p->index, p->code);
|
expand_opcode (0, p->index, p->code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2136,10 +2108,28 @@ filltable (p)
|
||||||
processing insns (ppi) for code 0xf800 (ppi nopx nopy). Copy the
|
processing insns (ppi) for code 0xf800 (ppi nopx nopy). Copy the
|
||||||
latter tag to represent all combinations of ppi with ddt. */
|
latter tag to represent all combinations of ppi with ddt. */
|
||||||
static void
|
static void
|
||||||
ppi_moves ()
|
expand_ppi_movxy ()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
for (i = 0xf000; i < 0xf400; i++)
|
||||||
|
if ((i & 3) == 0 && (i & 12) != 0 && table[i] != 0)
|
||||||
|
{
|
||||||
|
/* A movx insn, which needs to be filled out with the
|
||||||
|
corresponding movy insns. This used to be done in
|
||||||
|
expand_opcode. */
|
||||||
|
int m, mv;
|
||||||
|
|
||||||
|
for (m = 0; m < 32; m++)
|
||||||
|
{
|
||||||
|
/* Ignore illegal nopy */
|
||||||
|
if ((m & 7) == 0 && m != 0)
|
||||||
|
continue;
|
||||||
|
mv = m & 3 | (m & 4) << 2 | (m & 8) << 3 | (m & 16) << 4;
|
||||||
|
table [i | mv] = table [i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0xf000; i < 0xf400; i++)
|
for (i = 0xf000; i < 0xf400; i++)
|
||||||
if (table[i])
|
if (table[i])
|
||||||
table[i + 0x800] = table[0xf800];
|
table[i + 0x800] = table[0xf800];
|
||||||
|
@ -2179,6 +2169,7 @@ gensim_caselist (p)
|
||||||
s += 4;
|
s += 4;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
|
case 'e':
|
||||||
printf (" int n = (iword >> 8) & 0xf;\n");
|
printf (" int n = (iword >> 8) & 0xf;\n");
|
||||||
needn = 1;
|
needn = 1;
|
||||||
s += 4;
|
s += 4;
|
||||||
|
@ -2618,7 +2609,7 @@ main (ac, av)
|
||||||
|
|
||||||
memset (table, 0, sizeof table);
|
memset (table, 0, sizeof table);
|
||||||
filltable (movsxy_tab);
|
filltable (movsxy_tab);
|
||||||
ppi_moves ();
|
expand_ppi_movxy ();
|
||||||
dumptable ("sh_dsp_table", 1 << 12, 0xf000);
|
dumptable ("sh_dsp_table", 1 << 12, 0xf000);
|
||||||
|
|
||||||
memset (table, 0, sizeof table);
|
memset (table, 0, sizeof table);
|
||||||
|
|
Loading…
Reference in New Issue