target/hexagon: Widen MemLog::width to 32 bits
PATCH 1/1 target/hexagon: Widen MemLog::width to 32 bits
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 uint8_t when passing around the field as an immediate to retain previous truncation behaviour.
--- target/hexagon/cpu.h | 2 +- target/hexagon/op_helper.h | 4 ++-- target/hexagon/translate.h | 2 +- target/hexagon/genptr.c | 6 +++--- target/hexagon/op_helper.c | 4 ++-- target/hexagon/translate.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-)
target/hexagon/cpu.h +1 -1
@@ -46,7 +46,7 @@typedef struct {target_ulong va; -uint8_t width; +uint32_t width;uint32_t data32;uint64_t data64; }MemLog ;
target/hexagon/op_helper.h +2 -2
@@ -20,8 +20,8 @@/* Misc functions */ void log_store64 (CPUHexagonState *env,target_ulong addr, -int64_t val,int width,int slot); +int64_t val,uint8_t width,int slot);void log_store32 (CPUHexagonState *env,target_ulong addr, -target_ulong val,int width,int slot); +target_ulong val,uint8_t width,int slot);#endif
target/hexagon/translate.h +1 -1
@@ -271,7 +271,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;
target/hexagon/genptr.c +3 -3
@@ -401,10 +401,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,uint8_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); }
@@ -444,7 +444,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); }
target/hexagon/op_helper.c +2 -2
@@ -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,uint8_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,uint8_t width,int slot) { env->mem_log_stores[slot].va = addr; env->mem_log_stores[slot].width = width;
target/hexagon/translate.c +2 -2
@@ -51,7 +51,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;
@@ -1079,7 +1079,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]);
Signature · 1 line
2.51.0
Quoted 9 lines · Anton Johansson
MemLog::widthis auint8_tvalue mapped to a TCGv (32 bit), the only reason this currently works is becauseMemLog::widthis padded to 32 bits. Widen the field touint32_tand fix the size of the TCGv operations as well. Useuint8_twhen passing around the field as an immediate to retain previous truncation behaviour.Signed-off-by Anton Johansson <[email protected]>---
target/hexagon/cpu.h | 2 +-
Quoted 124 lines
target/hexagon/op_helper.h | 4 ++-- target/hexagon/translate.h | 2 +- target/hexagon/genptr.c | 6 +++--- target/hexagon/op_helper.c | 4 ++-- target/hexagon/translate.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-)target/hexagon/cpu.h +1
-1@@ -46,7 +46,7 @@typedef struct {target_ulong va; -uint8_t width; +uint32_t width;uint32_t data32;uint64_t data64; }MemLog ;target/hexagon/op_helper.h +2
-2@@ -20,8 +20,8 @@/* Misc functions */ void log_store64 (CPUHexagonState *env,target_ulong addr, -int64_t val,int width,int slot); +int64_t val,uint8_t width,int slot);void log_store32 (CPUHexagonState *env,target_ulong addr, -target_ulong val,int width,int slot); +target_ulong val,uint8_t width,int slot);#endif target/hexagon/translate.h +1
-1@@ -271,7 +271,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;target/hexagon/genptr.c +3
-3@@ -401,10 +401,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,uint8_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); }@@ -444,7 +444,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); }target/hexagon/op_helper.c +1
-1@@ -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,uint8_t width,int slot) { env->mem_log_stores[slot].va = addr;env->mem_log_stores[slot].width = width;target/hexagon/op_helper.c +1
-1@@ -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,uint8_t width,int slot) { env->mem_log_stores[slot].va = addr; env->mem_log_stores[slot].width = width;target/hexagon/translate.c +2
-3@@ -51,7 +51,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;@@ -1079,7 +1079,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]); --2.51.0
Quoted 22 lines · Anton Johansson via
MemLog::widthis auint8_tvalue mapped to a TCGv (32 bit), the only reason this currently works is becauseMemLog::widthis padded to 32 bits. Widen the field touint32_tand fix the size of the TCGv operations as well. Useuint8_twhen passing around the field as an immediate to retain previous truncation behaviour.Signed-off-by Anton Johansson <[email protected]>--- target/hexagon/cpu.h | 2 +- target/hexagon/op_helper.h | 4 ++-- target/hexagon/translate.h | 2 +- target/hexagon/genptr.c | 6 +++--- target/hexagon/op_helper.c | 4 ++-- target/hexagon/translate.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-)target/hexagon/op_helper.h +0
-0
target/hexagon/op_helper.h line 25
Quoted 8 lines
target/hexagon/op_helper.h +2
-2@@ -20,8 +20,8 @@/* Misc functions */ void log_store64 (CPUHexagonState *env,target_ulong addr, -int64_t val,int width,int slot); +int64_t val,uint8_t width,int slot);void log_store32 (CPUHexagonState *env,target_ulong addr, -target_ulong val,int width,int slot); +target_ulong val,uint8_t width,int slot);
With the rationale of this commit, I'm not really keen on using a uint8_t to truncate. Can we use a uint32_t but assert for a valid range, or do an explicit truncation?