Skip to contentSkip to conversation

target/m68k: Remove pointless @cpu_halted TCGv

PATCH Applied Philippe Mathieu-Daudé 2 participants 3 messages Sep 25, 2025 – Oct 7, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/m68k: Remove pointless @cpu_halted TCGv

Avoid registering a TCGv to write the generic CPUState::halted field. Access it directly via @env in both STOP / HALT opcodes.

---
Based-on: <[email protected]>

---
 target/m68k/translate.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
target/m68k/translate.c +4 -7
index 0cee54f4900..eb1ba150745 100644
@@ -44,8 +44,6 @@
 #undef DEFO32
 #undef DEFO64
 
-static TCGv_i32 cpu_halted;
-
 static char cpu_reg_names[2 * 8 * 3 + 5 * 4];
 static TCGv cpu_dregs[8];
 static TCGv cpu_aregs[8];
@@ -77,9 +75,6 @@ void m68k_tcg_init(void)
 #undef DEFO32
 #undef DEFO64
 
-    cpu_halted = tcg_global_mem_new_i32(tcg_env,
-                                        -offsetof(M68kCPU, env) +
-                                        offsetof(CPUState, halted), "HALTED");
     p = cpu_reg_names;
     for (i = 0; i < 8; i++) {
         sprintf(p, "D%d", i);
@@ -4506,7 +4501,8 @@ DISAS_INSN(halt)
         gen_exception(s, s->pc, EXCP_SEMIHOSTING);
         return;
     }
-    tcg_gen_movi_i32(cpu_halted, 1);
+    tcg_gen_st_i32(tcg_constant_i32(1), tcg_env,
+                   offsetof(CPUState, halted) - offsetof(M68kCPU, env));
     gen_exception(s, s->pc, EXCP_HLT);
 }
 
@@ -4522,7 +4518,8 @@ DISAS_INSN(stop)
     ext = read_im16(env, s);
 
     gen_set_sr_im(s, ext, 0);
-    tcg_gen_movi_i32(cpu_halted, 1);
+    tcg_gen_st_i32(tcg_constant_i32(1), tcg_env,
+                   offsetof(CPUState, halted) - offsetof(M68kCPU, env));
     gen_exception(s, s->pc, EXCP_HLT);
 }
 
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Philippe Mathieu-Daudé

Avoid registering a TCGv to write the generic CPUState::halted field. Access it directly via @env in both STOP / HALT opcodes.

---
Based-on: <[email protected]>

---
  target/m68k/translate.c | 11 ++++-------
  1 file changed, 4 insertions(+), 7 deletions(-)

r~

Quoted 44 lines
target/m68k/translate.c +4 -7
index 0cee54f4900..eb1ba150745 100644
@@ -44,8 +44,6 @@
  #undef DEFO32
  #undef DEFO64
 
-static TCGv_i32 cpu_halted;
-
  static char cpu_reg_names[2 * 8 * 3 + 5 * 4];
  static TCGv cpu_dregs[8];
  static TCGv cpu_aregs[8];
@@ -77,9 +75,6 @@ void m68k_tcg_init(void)
  #undef DEFO32
  #undef DEFO64
 
-    cpu_halted = tcg_global_mem_new_i32(tcg_env,
-                                        -offsetof(M68kCPU, env) +
-                                        offsetof(CPUState, halted), "HALTED");
      p = cpu_reg_names;
      for (i = 0; i < 8; i++) {
          sprintf(p, "D%d", i);
@@ -4506,7 +4501,8 @@ DISAS_INSN(halt)
          gen_exception(s, s->pc, EXCP_SEMIHOSTING);
          return;
      }
-    tcg_gen_movi_i32(cpu_halted, 1);
+    tcg_gen_st_i32(tcg_constant_i32(1), tcg_env,
+                   offsetof(CPUState, halted) - offsetof(M68kCPU, env));
      gen_exception(s, s->pc, EXCP_HLT);
  }
 
@@ -4522,7 +4518,8 @@ DISAS_INSN(stop)
      ext = read_im16(env, s);
 
      gen_set_sr_im(s, ext, 0);
-    tcg_gen_movi_i32(cpu_halted, 1);
+    tcg_gen_st_i32(tcg_constant_i32(1), tcg_env,
+                   offsetof(CPUState, halted) - offsetof(M68kCPU, env));
      gen_exception(s, s->pc, EXCP_HLT);
  }