Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Simon Marchi <simon.marchi@efficios.com>, gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>,
	Mike Frysinger <vapier@gentoo.org>,
	Stephane Carrez <Stephane.Carrez@gmail.com>
Subject: Re: [PATCH] sim/m68hc11: remove unused current_insn_size variable
Date: Fri, 20 Nov 2026 17:43:47 +0000	[thread overview]
Message-ID: <xhuyf4idbxuss.fsf@aburgess-thinkpadp1gen8.rmtgb.csb> (raw)
In-Reply-To: <20261030150123.1147003-1-simon.marchi@efficios.com>

Simon Marchi <simon.marchi@efficios.com> writes:

> Building the m68hc11 simulator with a recent clang fails with:
>
>     /home/smarchi/src/binutils-gdb/sim/m68hc11/gencode.c:1143:12: error: variable 'current_insn_size' set but not used [-Werror,-Wunused-but-set-global]
>
> The only read of current_insn_size is an instruction size consistency
> check, which has been disabled with "#if 0" since commit 81e09ed8322b
> ("Improve HC11 simulator to support HC12", 2001-05-20).  Remove the
> variable, the code computing it, and the disabled check.

Fine with me.  Anything disabled for that long counts as dead code in my
book.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew


>
> Cc: Andrew Burgess <aburgess@redhat.com>
> Cc: Mike Frysinger <vapier@gentoo.org>
> Cc: Stephane Carrez <Stephane.Carrez@gmail.com>
> Change-Id: Ibd7ee5ac16d5511d40a9ddcc175a94dcbc387b2b
> ---
>  sim/m68hc11/gencode.c | 41 -----------------------------------------
>  1 file changed, 41 deletions(-)
>
> diff --git a/sim/m68hc11/gencode.c b/sim/m68hc11/gencode.c
> index 248005a9dd84..822c90ef9a5e 100644
> --- a/sim/m68hc11/gencode.c
> +++ b/sim/m68hc11/gencode.c
> @@ -1140,7 +1140,6 @@ static struct m6811_opcode_def m6812_page2_opcodes[] = {
>  
>  
>  static int indent_level = 2;
> -static int current_insn_size = 0;
>  
>  /* Fatal error message and exit.  This method is called when an inconsistency
>     is detected in the generation table.	 */
> @@ -1344,7 +1343,6 @@ gen_fetch_operands (FILE *fp, int col,
>  	    fatal_error (opcode, "Wrong use of '*', 'addr' already used");
>  	  
>  	  addr_set = 1;
> -	  current_insn_size += 1;
>  	  print (fp, col, "addr = (uint16_t) cpu_fetch8 (cpu);");
>  	  print (fp, col, "%s%s = memory_read%s (cpu, addr);",
>  		 vars[cur_var], operand_size, operand_size);
> @@ -1357,25 +1355,21 @@ gen_fetch_operands (FILE *fp, int col,
>  	  addr_set = 1;
>  	  if (strncmp (operands, "(x)", 3) == 0)
>  	    {
> -	      current_insn_size += 1;
>  	      print (fp, col, "addr = cpu_get_x (cpu) + (uint16_t) cpu_fetch8 (cpu);");
>  	      operands += 3;
>  	    }
>  	  else if (strncmp (operands, "(y)", 3) == 0)
>  	    {
> -	      current_insn_size += 1;
>  	      print (fp, col, "addr = cpu_get_y (cpu) + (uint16_t) cpu_fetch8 (cpu);");
>  	      operands += 3;
>  	    }
>  	  else if (strncmp (operands, "()", 2) == 0)
>  	    {
> -	      current_insn_size += 2;
>  	      print (fp, col, "addr = cpu_fetch16 (cpu);");
>  	      operands += 2;
>  	    }
>  	  else if (strncmp (operands, "[]", 2) == 0)
>  	    {
> -	      current_insn_size += 1;
>  	      print (fp, col, "addr = cpu_get_indexed_operand_addr (cpu, 0);");
>  	      operands += 2;
>  	    }
> @@ -1395,7 +1389,6 @@ gen_fetch_operands (FILE *fp, int col,
>  	  if (strncmp (operands, "x)", 2) == 0)
>  	    {
>  	      addr_set = 1;
> -	      current_insn_size += 1;
>  	      print (fp, col, "addr = cpu_get_x (cpu) + (uint16_t) cpu_fetch8 (cpu);");
>  	      print (fp, col, "%s%s = memory_read%s (cpu, addr);",
>  		     vars[cur_var], operand_size, operand_size);
> @@ -1404,7 +1397,6 @@ gen_fetch_operands (FILE *fp, int col,
>  	  else if (strncmp (operands, "y)", 2) == 0)
>  	    {
>  	      addr_set = 1;
> -	      current_insn_size += 1;
>  	      print (fp, col, "addr = cpu_get_y (cpu) + (uint16_t) cpu_fetch8 (cpu);");
>  	      print (fp, col, "%s%s = memory_read%s (cpu, addr);",
>  		     vars[cur_var], operand_size, operand_size);
> @@ -1413,7 +1405,6 @@ gen_fetch_operands (FILE *fp, int col,
>  	  else if (strncmp (operands, ")", 1) == 0)
>  	    {
>  	      addr_set = 1;
> -	      current_insn_size += 2;
>  	      print (fp, col, "addr = cpu_fetch16 (cpu);");
>  	      print (fp, col, "%s%s = memory_read%s (cpu, addr);",
>  		     vars[cur_var], operand_size, operand_size);
> @@ -1421,7 +1412,6 @@ gen_fetch_operands (FILE *fp, int col,
>  	    }
>  	  else if (strncmp (operands, "@)", 2) == 0)
>  	    {
> -	      current_insn_size += 2;
>  	      print (fp, col, "addr = cpu_fetch16 (cpu);");
>  	      print (fp, col, "%s%s = memory_read%s (cpu, addr);",
>  		     vars[cur_var], operand_size, operand_size);
> @@ -1451,7 +1441,6 @@ gen_fetch_operands (FILE *fp, int col,
>  	  if (strncmp (operands, "]", 1) == 0)
>  	    {
>  	      addr_set = 1;
> -	      current_insn_size += 1;
>  	      print (fp, col, "addr = cpu_get_indexed_operand_addr (cpu,0);");
>  	      print (fp, col, "%s%s = memory_read%s (cpu, addr);",
>  		     vars[cur_var], operand_size, operand_size);
> @@ -1461,7 +1450,6 @@ gen_fetch_operands (FILE *fp, int col,
>  	 removed because it may be that there is a typo in strncmp test below.  */
>  	  else if (strncmp (operands, "]", 1) == 0)
>  	    {
> -	      current_insn_size += 1;
>  	      print (fp, col, "%s%s = cpu_get_indexed_operand%s (cpu,0);",
>  		     vars[cur_var], operand_size, operand_size);
>  	      operands += 1;
> @@ -1482,7 +1470,6 @@ gen_fetch_operands (FILE *fp, int col,
>  	  
>  	  if (strncmp (operands, "}", 1) == 0)
>  	    {
> -	      current_insn_size += 1;
>  	      print (fp, col, "%s%s = cpu_get_indexed_operand%s (cpu, 1);",
>  		     vars[cur_var], operand_size, operand_size);
>  	      operands += 1;
> @@ -1525,7 +1512,6 @@ gen_fetch_operands (FILE *fp, int col,
>  	    fatal_error (opcode, "Wrong use of 'r'");
>  
>  	  addr_set = 1;
> -	  current_insn_size += 1;
>  	  print (fp, col, "addr = cpu_fetch_relbranch (cpu);");
>  	  break;
>  
> @@ -1534,19 +1520,10 @@ gen_fetch_operands (FILE *fp, int col,
>  	    fatal_error (opcode, "Wrong use of 'R'");
>  
>  	  addr_set = 1;
> -	  current_insn_size += 2;
>  	  print (fp, col, "addr = cpu_fetch_relbranch16 (cpu);");
>  	  break;
>  
>  	case '#':
> -	  if (strcmp (operand_size, "8") == 0)
> -	    {
> -	      current_insn_size += 1;
> -	    }
> -	  else
> -	    {
> -	      current_insn_size += 2;
> -	    }
>  	  print (fp, col, "%s%s = cpu_fetch%s (cpu);", vars[cur_var],
>  		 operand_size, operand_size);
>  	  break;
> @@ -1655,7 +1632,6 @@ gen_save_result (FILE *fp, int col,
>      case '*':
>        if (addr_set == 0)
>  	{
> -	  current_insn_size += 1;
>  	  print (fp, col, "addr = (uint16_t) cpu_fetch8 (cpu);");
>  	}
>        result_size = operand_size;
> @@ -1668,7 +1644,6 @@ gen_save_result (FILE *fp, int col,
>  	{
>  	  if (addr_set == 0)
>  	    {
> -	      current_insn_size += 1;
>  	      print (fp, col, "addr = cpu_get_x (cpu) + cpu_fetch8 (cpu);");
>  	    }
>  	  print (fp, col, "memory_write%s (cpu, addr, dst%s);",
> @@ -1680,7 +1655,6 @@ gen_save_result (FILE *fp, int col,
>  	{
>  	  if (addr_set == 0)
>  	    {
> -	      current_insn_size += 1;
>  	      print (fp, col, "addr = cpu_get_y (cpu) + cpu_fetch8 (cpu);");
>  	    }
>  	  print (fp, col, "memory_write%s (cpu, addr, dst%s);",
> @@ -1692,7 +1666,6 @@ gen_save_result (FILE *fp, int col,
>  	{
>  	  if (addr_set == 0)
>  	    {
> -	      current_insn_size += 2;
>  	      print (fp, col, "addr = cpu_fetch16 (cpu);");
>  	    }
>  	  print (fp, col, "memory_write%s (cpu, addr, dst%s);",
> @@ -1719,7 +1692,6 @@ gen_save_result (FILE *fp, int col,
>  	{
>  	  if (addr_set == 0)
>  	    {
> -	      current_insn_size += 1;
>  	      print (fp, col, "addr = cpu_get_indexed_operand_addr (cpu,0);");
>  	    }
>  	  print (fp, col, "memory_write%s (cpu, addr, dst%s);",
> @@ -1736,7 +1708,6 @@ gen_save_result (FILE *fp, int col,
>      case '{':
>        if (strncmp (operands, "}", 1) == 0)
>  	{
> -	  current_insn_size += 1;
>  	  print (fp, col, "addr = cpu_get_indexed_operand_addr (cpu, 1);");
>  	  print (fp, col, "memory_write%s (cpu, addr, dst%s);",
>  		 operand_size, operand_size);
> @@ -1880,11 +1851,7 @@ gen_interpreter_for_table (FILE *fp, int col,
>  			   const char *cycles_table_name)
>  {
>    int i;
> -  int init_size;
>  
> -  init_size = table == m6811_page1_opcodes
> -    || table == m6812_page1_opcodes? 1 : 2;
> -  
>    /* Get the opcode and dispatch directly.  */
>    print (fp, col, "op = cpu_fetch8 (cpu);");
>    print (fp, col, "cpu_add_cycles (cpu, %s[op]);", cycles_table_name);
> @@ -1899,15 +1866,7 @@ gen_interpreter_for_table (FILE *fp, int col,
>        if (i > 0 && table[i].insn_code == table[i - 1].insn_code)
>  	continue;
>  
> -      current_insn_size = init_size;
>        gen_interp (fp, col, &table[i]);
> -#if 0
> -      if (current_insn_size != table[i].insn_size)
> -	{
> -	  fatal_error (&table[i], "Insn size %ld inconsistent with %ld",
> -		       current_insn_size, table[i].insn_size);
> -	}
> -#endif
>      }
>  
>    print (fp, col, "default:\n");
>
> base-commit: bb0a4659ab1eb997ad095181ef309f7b7d9aa289
> -- 
> 2.56.0


  reply	other threads:[~2026-11-20 17:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 15:01 Simon Marchi
2026-11-20 17:43 ` Andrew Burgess [this message]
2026-11-21  2:44   ` Simon Marchi

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=xhuyf4idbxuss.fsf@aburgess-thinkpadp1gen8.rmtgb.csb \
    --to=aburgess@redhat.com \
    --cc=Stephane.Carrez@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    --cc=vapier@gentoo.org \
    /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