aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2023-12-15 23:15:24 -0500
committerMike Frysinger <vapier@gentoo.org>2023-12-15 23:59:00 -0500
commit0fd9d0cec01437c8ca2951f3702be16123733442 (patch)
treecac843522b13c220735179237ae9a0aa22fef91d /sim
parent302bd5bf18271d963c19de328c0bda8d18a97102 (diff)
downloadgdb-0fd9d0cec01437c8ca2951f3702be16123733442.zip
gdb-0fd9d0cec01437c8ca2951f3702be16123733442.tar.gz
gdb-0fd9d0cec01437c8ca2951f3702be16123733442.tar.bz2
sim: sh: tidy up gencode slightly
Mark a few things static/const, and clean up trailing whitespace.
Diffstat (limited to 'sim')
-rw-r--r--sim/sh/gencode.c140
1 files changed, 72 insertions, 68 deletions
diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c
index fa4f988..0a04e33 100644
--- a/sim/sh/gencode.c
+++ b/sim/sh/gencode.c
@@ -41,10 +41,10 @@
typedef struct
{
- const char *defs;
- const char *refs;
- const char *name;
- const char *code;
+ const char * const defs;
+ const char * const refs;
+ const char * const name;
+ const char * const code;
const char * const stuff[MAX_NR_STUFF];
int index;
} op;
@@ -114,7 +114,7 @@ static op tab[] =
"if (i > 7)",
" RAISE_EXCEPTION (SIGILL);",
"MA (1);",
- "do_blog_insn (1 << i, (word2 & 0xfff) + R[n], ",
+ "do_blog_insn (1 << i, (word2 & 0xfff) + R[n],",
" (word2 >> 12) & 0xf, memory, maskb);",
"SET_NIP (nip + 2); /* Consume 2 more bytes. */",
},
@@ -155,7 +155,7 @@ static op tab[] =
" cycles += 2;",
"}",
},
-
+
{ "", "m", "bld/st #<imm>, <REG_M>", "10000111mmmmi4*1",
"/* MSB of 'i' is true for load, false for store. */",
"if (i <= 7)",
@@ -289,7 +289,7 @@ static op tab[] =
" WLAT (R[15], PR);",
" else",
" WLAT (R[15], R[n]);",
- "} while (n-- > 0);",
+ "} while (n-- > 0);",
},
{ "f", "f+", "movml.l @R15+,<REG_N>", "0100nnnn11110101",
"/* Pop R0...Rn (if n==15, pop R0...R14 and pr). */",
@@ -301,7 +301,7 @@ static op tab[] =
" else",
" R[i] = RLAT (R[15]);",
" R[15] += 4;",
- "} while (i++ < n);",
+ "} while (i++ < n);",
},
{ "f", "f-", "movmu.l <REG_N>,@-R15", "0100nnnn11110000",
"/* Push pr, R14...Rn (if n==15, push pr). */", /* FIXME */
@@ -313,7 +313,7 @@ static op tab[] =
" WLAT (R[15], PR);",
" else",
" WLAT (R[15], R[i]);",
- "} while (i-- > n);",
+ "} while (i-- > n);",
},
{ "f", "f+", "movmu.l @R15+,<REG_N>", "0100nnnn11110100",
"/* Pop Rn...R14, pr (if n==15, pop pr). */", /* FIXME */
@@ -324,10 +324,10 @@ static op tab[] =
" else",
" R[n] = RLAT (R[15]);",
" R[15] += 4;",
- "} while (n++ < 15);",
+ "} while (n++ < 15);",
},
{ "", "", "nott", "0000000001101000",
- "SET_SR_T (T == 0);",
+ "SET_SR_T (T == 0);",
},
{ "", "", "bt.s <bdisp8>", "10001101i8p1....",
@@ -498,7 +498,7 @@ static op tab[] =
/* sh4 */
{ "", "", "fipr <FV_M>,<FV_N>", "1111vvVV11101101",
- "if (FPSCR_PR)",
+ "if (FPSCR_PR)",
" RAISE_EXCEPTION (SIGILL);",
"else",
"{",
@@ -663,7 +663,7 @@ static op tab[] =
"}",
},
- /* sh4:
+ /* sh4:
See fmov instructions above for move to/from extended fp registers. */
/* sh2e */
@@ -757,12 +757,12 @@ static op tab[] =
"if (FPSCR_PR)",
" RAISE_EXCEPTION (SIGILL);",
"else",
- "{",
+ "{",
" if (saved_state.asregs.bfd_mach == bfd_mach_sh2a)",
" RAISE_EXCEPTION (SIGILL);",
" /* FIXME not implemented. */",
" printf (\"ftrv xmtrx, FV%d\\n\", v1);",
- "}",
+ "}",
},
/* sh2e */
@@ -1150,7 +1150,7 @@ static op tab[] =
"WLAT (R[n], R[0]);",
},
- { "", "n0", "movco.l R0, @<REG_N>", "0000nnnn01110011",
+ { "", "n0", "movco.l R0, @<REG_N>", "0000nnnn01110011",
"/* LDST -> T */",
"SET_SR_T (LDST);",
"/* if (T) R0 -> (Rn) */",
@@ -1160,7 +1160,7 @@ static op tab[] =
"SET_LDST (0);",
},
- { "0", "n", "movli.l @<REG_N>, R0", "0000nnnn01100011",
+ { "0", "n", "movli.l @<REG_N>, R0", "0000nnnn01100011",
"/* 1 -> LDST */",
"SET_LDST (1);",
"/* (Rn) -> R0 */",
@@ -1173,13 +1173,13 @@ static op tab[] =
"R[n] = T;",
},
{ "", "", "movrt <REG_N>", "0000nnnn00111001",
- "R[n] = (T == 0);",
+ "R[n] = (T == 0);",
},
{ "0", "n", "movua.l @<REG_N>,R0", "0100nnnn10101001",
"int regn = R[n];",
"int e = target_little_endian ? 3 : 0;",
"MA (1);",
- "R[0] = (RBAT (regn + (0^e)) << 24) + (RBAT (regn + (1^e)) << 16) + ",
+ "R[0] = (RBAT (regn + (0^e)) << 24) + (RBAT (regn + (1^e)) << 16) +",
" (RBAT (regn + (2^e)) << 8) + RBAT (regn + (3^e));",
"L (0);",
},
@@ -1187,7 +1187,7 @@ static op tab[] =
"int regn = R[n];",
"int e = target_little_endian ? 3 : 0;",
"MA (1);",
- "R[0] = (RBAT (regn + (0^e)) << 24) + (RBAT (regn + (1^e)) << 16) + ",
+ "R[0] = (RBAT (regn + (0^e)) << 24) + (RBAT (regn + (1^e)) << 16) +",
" (RBAT (regn + (2^e)) << 8) + RBAT (regn + (3^e));",
"R[n] += 4;",
"L (0);",
@@ -1276,8 +1276,8 @@ static op tab[] =
},
/* sh4a */
- { "", "", "synco", "0000000010101011",
- "/* Except for the effect on the pipeline - which is not simulated -",
+ { "", "", "synco", "0000000010101011",
+ "/* Except for the effect on the pipeline - which is not simulated -",
" this is like a nop. */",
},
@@ -1305,7 +1305,7 @@ static op tab[] =
"R[n] |= (T << 31);",
},
- { "", "", "rte", "0000000000101011",
+ { "", "", "rte", "0000000000101011",
#if 0
/* SH-[12] */
"int tmp = PC;",
@@ -1521,7 +1521,7 @@ static op tab[] =
"WBAT (R[n],ult|0x80);",
},
- { "0", "", "trapa #<imm>", "11000011i8*1....",
+ { "0", "", "trapa #<imm>", "11000011i8*1....",
"long imm = 0xff & i;",
"RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();",
"if (i < 20 || i == 33 || i == 34 || i == 0xc3)",
@@ -1584,7 +1584,7 @@ static op tab[] =
{0, 0}};
-op movsxy_tab[] =
+static op movsxy_tab[] =
{
/* If this is disabled, the simulator speeds up by about 12% on a
450 MHz PIII - 9% with ACE_FAST.
@@ -1855,7 +1855,7 @@ op movsxy_tab[] =
#endif
{0, 0}};
-op ppi_tab[] =
+static op ppi_tab[] =
{
{ "","", "pshl #<imm>,dz", "00000iiim16.zzzz",
"int Sz = DSP_R (z) & 0xffff0000;",
@@ -2024,8 +2024,8 @@ op ppi_tab[] =
"else",
" {",
" res = -res;",
- " carry = (res != 0); /* The manual has a bug here. */",
- " res_grd = -res_grd - carry;",
+ " carry = (res != 0); /* The manual has a bug here. */",
+ " res_grd = -res_grd - carry;",
" }",
"COMPUTE_OVERFLOW;",
"/* ??? The re-computing of overflow after",
@@ -2041,8 +2041,8 @@ op ppi_tab[] =
"else",
" {",
" res = -res;",
- " carry = (res != 0); /* The manual has a bug here. */",
- " res_grd = -res_grd - carry;",
+ " carry = (res != 0); /* The manual has a bug here. */",
+ " res_grd = -res_grd - carry;",
" }",
"COMPUTE_OVERFLOW;",
"/* ??? The re-computing of overflow after",
@@ -2599,9 +2599,9 @@ conflict_warn (int val, int i)
for (ix = ARRAY_SIZE (tab); ix >= 0; ix--)
if (tab[ix].index == i || tab[ix].index == j)
{
- key = ((tab[ix].code[0] - '0') << 3) +
- ((tab[ix].code[1] - '0') << 2) +
- ((tab[ix].code[2] - '0') << 1) +
+ key = ((tab[ix].code[0] - '0') << 3) +
+ ((tab[ix].code[1] - '0') << 2) +
+ ((tab[ix].code[2] - '0') << 1) +
((tab[ix].code[3] - '0'));
if (val >> 12 == key)
@@ -2611,26 +2611,26 @@ conflict_warn (int val, int i)
for (ix = ARRAY_SIZE (movsxy_tab); ix >= 0; ix--)
if (movsxy_tab[ix].index == i || movsxy_tab[ix].index == j)
{
- key = ((movsxy_tab[ix].code[0] - '0') << 3) +
- ((movsxy_tab[ix].code[1] - '0') << 2) +
- ((movsxy_tab[ix].code[2] - '0') << 1) +
+ key = ((movsxy_tab[ix].code[0] - '0') << 3) +
+ ((movsxy_tab[ix].code[1] - '0') << 2) +
+ ((movsxy_tab[ix].code[2] - '0') << 1) +
((movsxy_tab[ix].code[3] - '0'));
if (val >> 12 == key)
- fprintf (stderr, " %s -- %s\n",
+ fprintf (stderr, " %s -- %s\n",
movsxy_tab[ix].code, movsxy_tab[ix].name);
}
for (ix = ARRAY_SIZE (ppi_tab); ix >= 0; ix--)
if (ppi_tab[ix].index == i || ppi_tab[ix].index == j)
{
- key = ((ppi_tab[ix].code[0] - '0') << 3) +
- ((ppi_tab[ix].code[1] - '0') << 2) +
- ((ppi_tab[ix].code[2] - '0') << 1) +
+ key = ((ppi_tab[ix].code[0] - '0') << 3) +
+ ((ppi_tab[ix].code[1] - '0') << 2) +
+ ((ppi_tab[ix].code[2] - '0') << 1) +
((ppi_tab[ix].code[3] - '0'));
if (val >> 12 == key)
- fprintf (stderr, " %s -- %s\n",
+ fprintf (stderr, " %s -- %s\n",
ppi_tab[ix].code, ppi_tab[ix].name);
}
}
@@ -2706,7 +2706,7 @@ expand_opcode (int val, int i, const char *s)
expand_opcode ((val << 4) | j, i, s + 4);
break;
case 'G':
- /* A1G, A0G:
+ /* A1G, A0G:
GGGG -- two-way fork */
for (j = 13; j <= 15; j +=2)
expand_opcode ((val << 4) | j, i, s + 4);
@@ -2771,7 +2771,7 @@ dumptable (const char *name, int size, int start)
int i = start;
- printf ("unsigned short %s[%d]={\n", name, size);
+ printf ("unsigned short %s[%d] = {\n", name, size);
while (i < start + size)
{
int j = 0;
@@ -2961,7 +2961,7 @@ gensim_caselist (op *p)
switch (s[1])
{
default:
- fprintf (stderr,
+ fprintf (stderr,
"gensim_caselist: Unknown char '%c' in %s\n",
s[1], s);
exit (1);
@@ -2982,7 +2982,7 @@ gensim_caselist (op *p)
switch (s[3])
{
default:
- fprintf (stderr,
+ fprintf (stderr,
"gensim_caselist: Unknown char '%c' in %s\n",
s[3], s);
exit (1);
@@ -3009,7 +3009,7 @@ gensim_caselist (op *p)
}
if (needm && needn)
- printf (" TB (m,n);\n");
+ printf (" TB (m,n);\n");
else if (needm)
printf (" TL (m);\n");
else if (needn)
@@ -3021,7 +3021,7 @@ gensim_caselist (op *p)
for (r = p->refs; *r; r++)
{
if (*r == 'f') printf (" CREF (15);\n");
- if (*r == '-')
+ if (*r == '-')
{
printf (" {\n");
printf (" int i = n;\n");
@@ -3030,7 +3030,7 @@ gensim_caselist (op *p)
printf (" } while (i-- > 0);\n");
printf (" }\n");
}
- if (*r == '+')
+ if (*r == '+')
{
printf (" {\n");
printf (" int i = n;\n");
@@ -3039,11 +3039,11 @@ gensim_caselist (op *p)
printf (" } while (i++ < 14);\n");
printf (" }\n");
}
- if (*r == '0') printf (" CREF (0);\n");
- if (*r == '8') printf (" CREF (8);\n");
- if (*r == '9') printf (" CREF (9);\n");
- if (*r == 'n') printf (" CREF (n);\n");
- if (*r == 'm') printf (" CREF (m);\n");
+ if (*r == '0') printf (" CREF (0);\n");
+ if (*r == '8') printf (" CREF (8);\n");
+ if (*r == '9') printf (" CREF (9);\n");
+ if (*r == 'n') printf (" CREF (n);\n");
+ if (*r == 'm') printf (" CREF (m);\n");
}
}
@@ -3060,10 +3060,10 @@ gensim_caselist (op *p)
{
/* Do the defs. */
const char *r;
- for (r = p->defs; *r; r++)
+ for (r = p->defs; *r; r++)
{
if (*r == 'f') printf (" CDEF (15);\n");
- if (*r == '-')
+ if (*r == '-')
{
printf (" {\n");
printf (" int i = n;\n");
@@ -3072,7 +3072,7 @@ gensim_caselist (op *p)
printf (" } while (i-- > 0);\n");
printf (" }\n");
}
- if (*r == '+')
+ if (*r == '+')
{
printf (" {\n");
printf (" int i = n;\n");
@@ -3081,9 +3081,9 @@ gensim_caselist (op *p)
printf (" } while (i++ < 14);\n");
printf (" }\n");
}
- if (*r == '0') printf (" CDEF (0);\n");
- if (*r == 'n') printf (" CDEF (n);\n");
- if (*r == 'm') printf (" CDEF (m);\n");
+ if (*r == '0') printf (" CDEF (0);\n");
+ if (*r == 'n') printf (" CDEF (n);\n");
+ if (*r == 'm') printf (" CDEF (m);\n");
}
}
@@ -3220,20 +3220,20 @@ ppi_gensim (void)
printf ("#define DSR_MASK_V 0x10\n");
printf ("\n");
printf ("#define COMPUTE_OVERFLOW do {\\\n");
- printf (" overflow = res_grd != SIGN32 (res) ? DSR_MASK_V : 0; \\\n");
+ printf (" overflow = res_grd != SIGN32 (res) ? DSR_MASK_V : 0;\\\n");
printf (" if (overflow && S) \\\n");
printf (" { \\\n");
printf (" if (res_grd & 0x80) \\\n");
printf (" { \\\n");
- printf (" res = 0x80000000; \\\n");
- printf (" res_grd |= 0xff; \\\n");
+ printf (" res = 0x80000000;\\\n");
+ printf (" res_grd |= 0xff;\\\n");
printf (" } \\\n");
printf (" else \\\n");
printf (" { \\\n");
- printf (" res = 0x7fffffff; \\\n");
- printf (" res_grd &= ~0xff; \\\n");
+ printf (" res = 0x7fffffff;\\\n");
+ printf (" res_grd &= ~0xff;\\\n");
printf (" } \\\n");
- printf (" overflow = 0; \\\n");
+ printf (" overflow = 0;\\\n");
printf (" } \\\n");
printf ("} while (0)\n");
printf ("\n");
@@ -3323,9 +3323,13 @@ ppi_gensim (void)
{
if (p->stuff[j])
{
- printf (" %s%s\n",
- (havedecl == 2 ? " " : ""),
- p->stuff[j]);
+ if (*p->stuff[j])
+ {
+ printf (" %s%s",
+ (havedecl == 2 ? " " : ""),
+ p->stuff[j]);
+ }
+ printf ("\n");
}
}
if (havedecl == 2)