]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
target/hexagon: Widen MemLog::width to 32 bits
authorAnton Johansson <anjo@rev.ng>
Mon, 9 Feb 2026 14:42:49 +0000 (15:42 +0100)
committerBrian Cain <brian.cain@oss.qualcomm.com>
Fri, 13 Feb 2026 02:39:43 +0000 (18:39 -0800)
MemLog::width is a uint8_t value mapped to a TCGv (32 bit), the only
reason this currently works is because MemLog::width is padded to 32
bits.  Widen the field to uint32_t and fix the size of the TCGv
operations as well.  Use uint32_t when referencing and passing around
the field, as valid values are asserted in commit_store().

Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Anton Johansson <anjo@rev.ng>
--
Changes in v3:
- Added reviewed-by
Changes in v2:
- Removed truncation to uint8_t, valid values of 1,2,4,8 are checked in
  commit_store() already.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
target/hexagon/cpu.h
target/hexagon/genptr.c
target/hexagon/genptr.h
target/hexagon/op_helper.c
target/hexagon/op_helper.h
target/hexagon/translate.c
target/hexagon/translate.h

index 656b7dc04498ee28ab1164248be268c8d6c8829f..85afd592778cec64dfecdaa9e7acda66cc2c25ab 100644 (file)
@@ -46,7 +46,7 @@
 
 typedef struct {
     target_ulong va;
-    uint8_t width;
+    uint32_t width;
     uint32_t data32;
     uint64_t data64;
 } MemLog;
index 36968549d5dd33b8e252e16d6bf90f22aea76c09..9eb21da6f3ebf669a7da35456ee90f348c6f1292 100644 (file)
@@ -387,10 +387,10 @@ static TCGv gen_slotval(DisasContext *ctx)
 }
 #endif
 
-void gen_store32(TCGv vaddr, TCGv src, int width, uint32_t slot)
+void gen_store32(TCGv vaddr, TCGv src, uint32_t width, uint32_t slot)
 {
     tcg_gen_mov_tl(hex_store_addr[slot], vaddr);
-    tcg_gen_movi_tl(hex_store_width[slot], width);
+    tcg_gen_movi_i32(hex_store_width[slot], width);
     tcg_gen_mov_tl(hex_store_val32[slot], src);
 }
 
@@ -430,7 +430,7 @@ void gen_store4i(TCGv_env tcg_env, TCGv vaddr, int32_t src, uint32_t slot)
 void gen_store8(TCGv_env tcg_env, TCGv vaddr, TCGv_i64 src, uint32_t slot)
 {
     tcg_gen_mov_tl(hex_store_addr[slot], vaddr);
-    tcg_gen_movi_tl(hex_store_width[slot], 8);
+    tcg_gen_movi_i32(hex_store_width[slot], 8);
     tcg_gen_mov_i64(hex_store_val64[slot], src);
 }
 
index 228d7f1d7da5988a013f9ba2f24d5f66672453ea..45ee038ca943c355c48190485f9e6aeee77c63c6 100644 (file)
@@ -24,7 +24,7 @@
 
 extern const SemanticInsn opcode_genptr[];
 
-void gen_store32(TCGv vaddr, TCGv src, int width, uint32_t slot);
+void gen_store32(TCGv vaddr, TCGv src, uint32_t width, uint32_t slot);
 void gen_store1(TCGv_env cpu_env, TCGv vaddr, TCGv src, uint32_t slot);
 void gen_store2(TCGv_env cpu_env, TCGv vaddr, TCGv src, uint32_t slot);
 void gen_store4(TCGv_env cpu_env, TCGv vaddr, TCGv src, uint32_t slot);
index bfeadd65fcbf419f08e7789c014f1edd2df8c56f..368391bb8463a86e0c46d42b09b5f6d364229642 100644 (file)
@@ -52,7 +52,7 @@ G_NORETURN void HELPER(raise_exception)(CPUHexagonState *env, uint32_t excp)
 }
 
 void log_store32(CPUHexagonState *env, target_ulong addr,
-                 target_ulong val, int width, int slot)
+                 target_ulong val, uint32_t width, int slot)
 {
     env->mem_log_stores[slot].va = addr;
     env->mem_log_stores[slot].width = width;
@@ -60,7 +60,7 @@ void log_store32(CPUHexagonState *env, target_ulong addr,
 }
 
 void log_store64(CPUHexagonState *env, target_ulong addr,
-                 int64_t val, int width, int slot)
+                 int64_t val, uint32_t width, int slot)
 {
     env->mem_log_stores[slot].va = addr;
     env->mem_log_stores[slot].width = width;
@@ -69,7 +69,7 @@ void log_store64(CPUHexagonState *env, target_ulong addr,
 
 static void commit_store(CPUHexagonState *env, int slot_num, uintptr_t ra)
 {
-    uint8_t width = env->mem_log_stores[slot_num].width;
+    uint32_t width = env->mem_log_stores[slot_num].width;
     target_ulong va = env->mem_log_stores[slot_num].va;
 
     switch (width) {
@@ -363,7 +363,7 @@ static void probe_store(CPUHexagonState *env, int slot, int mmu_idx,
                         bool is_predicated, uintptr_t retaddr)
 {
     if (!is_predicated || !(env->slot_cancelled & (1 << slot))) {
-        size1u_t width = env->mem_log_stores[slot].width;
+        uint32_t width = env->mem_log_stores[slot].width;
         target_ulong va = env->mem_log_stores[slot].va;
         probe_write(env, va, width, mmu_idx, retaddr);
     }
index 66119cf3d4cef5ea1bfd666a0fdbf636b8080be2..e8fdabddb3bd6eb72e2759fd232dab040c302f18 100644 (file)
@@ -20,8 +20,8 @@
 
 /* Misc functions */
 void log_store64(CPUHexagonState *env, target_ulong addr,
-                 int64_t val, int width, int slot);
+                 int64_t val, uint32_t width, int slot);
 void log_store32(CPUHexagonState *env, target_ulong addr,
-                 target_ulong val, int width, int slot);
+                 target_ulong val, uint32_t width, int slot);
 
 #endif
index 0234bbf15d742ca953a7e211251f1e984ce13cd6..2fdc956bf997c8aefd18854576d37b35c7175372 100644 (file)
@@ -55,7 +55,7 @@ TCGv hex_pred[NUM_PREGS];
 TCGv hex_slot_cancelled;
 TCGv hex_new_value_usr;
 TCGv hex_store_addr[STORES_MAX];
-TCGv hex_store_width[STORES_MAX];
+TCGv_i32 hex_store_width[STORES_MAX];
 TCGv hex_store_val32[STORES_MAX];
 TCGv_i64 hex_store_val64[STORES_MAX];
 TCGv hex_llsc_addr;
@@ -1123,7 +1123,7 @@ void hexagon_translate_init(void)
             store_addr_names[i]);
 
         snprintf(store_width_names[i], NAME_LEN, "store_width_%d", i);
-        hex_store_width[i] = tcg_global_mem_new(tcg_env,
+        hex_store_width[i] = tcg_global_mem_new_i32(tcg_env,
             offsetof(CPUHexagonState, mem_log_stores[i].width),
             store_width_names[i]);
 
index a0102b6cbd24893a413f78972e59faac01ff3de9..b37cb492381cdeeda3798c770e17a1130fe545d1 100644 (file)
@@ -272,7 +272,7 @@ extern TCGv hex_pred[NUM_PREGS];
 extern TCGv hex_slot_cancelled;
 extern TCGv hex_new_value_usr;
 extern TCGv hex_store_addr[STORES_MAX];
-extern TCGv hex_store_width[STORES_MAX];
+extern TCGv_i32 hex_store_width[STORES_MAX];
 extern TCGv hex_store_val32[STORES_MAX];
 extern TCGv_i64 hex_store_val64[STORES_MAX];
 extern TCGv hex_llsc_addr;