From patchwork Sat Dec 16 05:00:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 82292 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C16A3858284 for ; Sat, 16 Dec 2023 05:01:08 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 588AF3858D28 for ; Sat, 16 Dec 2023 05:00:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 588AF3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 588AF3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702702854; cv=none; b=Fj5TPFWYPLqb9R5AuXdrKCjd1JhpTPkSUtSA5UuZ7bZpurwOM2rjBqM0DfkgVcbjk73YMj5dhuda8r9rCs1mze+TpndMPE3VEMCs6fkgfDrzetQb+uEwSD5VK8CPNFp5DEuTLznzYApA5AAu/9uXZ0MiapC/c9Echb8hIQEeyC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702702854; c=relaxed/simple; bh=oU23hI+CqzJR88vkR3p6fB75mluPx9uSl4A5ZqEMVVs=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=YTjqEnyW/xzUaE9ZgIScy/M/IqBHvOtZKGzmFHOkFOVNHeoHij4kLJQFLEL/+ZvTV+p8ptFCH4jgzVonm8UYbePmQclZRNd1q3mM26jhTxe4XhuwmhSuCBpyhItfdCkb5k8mQGyVkmKwHrf11k+qts2uJvQ5j6lVm537m0sjYkM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id DC1E1335D77; Sat, 16 Dec 2023 05:00:51 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 1/2] sim: sh: tidy up gencode slightly Date: Sat, 16 Dec 2023 00:00:46 -0500 Message-ID: <20231216050047.13827-1-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Mark a few things static/const, and clean up trailing whitespace. --- sim/sh/gencode.c | 140 ++++++++++++++++++++++++----------------------- 1 file changed, 72 insertions(+), 68 deletions(-) diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c index fa4f9886cf6d..0a04e339fa18 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 #, ", "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+,", "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 ,@-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+,", "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 ", "10001101i8p1....", @@ -498,7 +498,7 @@ static op tab[] = /* sh4 */ { "", "", "fipr ,", "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, @", "0000nnnn01110011", + { "", "n0", "movco.l R0, @", "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 @, R0", "0000nnnn01100011", + { "0", "n", "movli.l @, R0", "0000nnnn01100011", "/* 1 -> LDST */", "SET_LDST (1);", "/* (Rn) -> R0 */", @@ -1173,13 +1173,13 @@ static op tab[] = "R[n] = T;", }, { "", "", "movrt ", "0000nnnn00111001", - "R[n] = (T == 0);", + "R[n] = (T == 0);", }, { "0", "n", "movua.l @,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 #", "11000011i8*1....", + { "0", "", "trapa #", "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 #,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)