[PATCH v3 15/37] target/hexagon: Add guest/sys reg writes to DisasContext

Brian Cain posted 37 patches 2 days, 12 hours ago
Maintainers: Brian Cain <brian.cain@oss.qualcomm.com>, Pierrick Bouvier <pierrick.bouvier@linaro.org>, Laurent Vivier <laurent@vivier.eu>, Alessandro Di Federico <ale@rev.ng>, Anton Johansson <anjo@rev.ng>
[PATCH v3 15/37] target/hexagon: Add guest/sys reg writes to DisasContext
Posted by Brian Cain 2 days, 12 hours ago
From: Brian Cain <bcain@quicinc.com>

Reviewed-by: Taylor Simpson <ltaylorsimpson@gmail.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 target/hexagon/translate.h | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/target/hexagon/translate.h b/target/hexagon/translate.h
index f80830f5f16..6e1008b363a 100644
--- a/target/hexagon/translate.h
+++ b/target/hexagon/translate.h
@@ -40,6 +40,14 @@ typedef struct DisasContext {
     DECLARE_BITMAP(regs_written, TOTAL_PER_THREAD_REGS);
     DECLARE_BITMAP(predicated_regs, TOTAL_PER_THREAD_REGS);
     bool implicit_usr_write;
+#ifndef CONFIG_USER_ONLY
+    int greg_log[GREG_WRITES_MAX];
+    int greg_log_idx;
+    int sreg_log[SREG_WRITES_MAX];
+    int sreg_log_idx;
+    TCGv t_sreg_new_value[NUM_SREGS];
+    TCGv greg_new_value[NUM_GREGS];
+#endif
     int preg_log[PRED_WRITES_MAX];
     int preg_log_idx;
     DECLARE_BITMAP(pregs_written, NUM_PREGS);
@@ -80,6 +88,34 @@ typedef struct DisasContext {
 
 bool is_gather_store_insn(DisasContext *ctx);
 
+#ifndef CONFIG_USER_ONLY
+static inline void ctx_log_greg_write(DisasContext *ctx, int rnum)
+{
+    if (rnum <= HEX_GREG_G3) {
+        ctx->greg_log[ctx->greg_log_idx] = rnum;
+        ctx->greg_log_idx++;
+    }
+}
+
+static inline void ctx_log_greg_write_pair(DisasContext *ctx, int rnum)
+{
+    ctx_log_greg_write(ctx, rnum);
+    ctx_log_greg_write(ctx, rnum + 1);
+}
+
+static inline void ctx_log_sreg_write(DisasContext *ctx, int rnum)
+{
+    ctx->sreg_log[ctx->sreg_log_idx] = rnum;
+    ctx->sreg_log_idx++;
+}
+
+static inline void ctx_log_sreg_write_pair(DisasContext *ctx, int rnum)
+{
+    ctx_log_sreg_write(ctx, rnum);
+    ctx_log_sreg_write(ctx, rnum + 1);
+}
+#endif
+
 static inline void ctx_log_pred_write(DisasContext *ctx, int pnum)
 {
     if (!test_bit(pnum, ctx->pregs_written)) {
-- 
2.34.1

Re: [PATCH v3 15/37] target/hexagon: Add guest/sys reg writes to DisasContext
Posted by Philippe Mathieu-Daudé 2 days, 10 hours ago
On 27/2/26 21:36, Brian Cain wrote:
> From: Brian Cain <bcain@quicinc.com>
> 
> Reviewed-by: Taylor Simpson <ltaylorsimpson@gmail.com>
> Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
> ---
>   target/hexagon/translate.h | 36 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 36 insertions(+)
> 
> diff --git a/target/hexagon/translate.h b/target/hexagon/translate.h
> index f80830f5f16..6e1008b363a 100644
> --- a/target/hexagon/translate.h
> +++ b/target/hexagon/translate.h
> @@ -40,6 +40,14 @@ typedef struct DisasContext {
>       DECLARE_BITMAP(regs_written, TOTAL_PER_THREAD_REGS);
>       DECLARE_BITMAP(predicated_regs, TOTAL_PER_THREAD_REGS);
>       bool implicit_usr_write;
> +#ifndef CONFIG_USER_ONLY
> +    int greg_log[GREG_WRITES_MAX];
> +    int greg_log_idx;
> +    int sreg_log[SREG_WRITES_MAX];
> +    int sreg_log_idx;
> +    TCGv t_sreg_new_value[NUM_SREGS];
> +    TCGv greg_new_value[NUM_GREGS];

TCGv_i32.

> +#endif
>       int preg_log[PRED_WRITES_MAX];
>       int preg_log_idx;
>       DECLARE_BITMAP(pregs_written, NUM_PREGS);
> @@ -80,6 +88,34 @@ typedef struct DisasContext {
>   
>   bool is_gather_store_insn(DisasContext *ctx);
>   
> +#ifndef CONFIG_USER_ONLY
> +static inline void ctx_log_greg_write(DisasContext *ctx, int rnum)
> +{
> +    if (rnum <= HEX_GREG_G3) {

Shouldn't we assert(rnum > HEX_GREG_G3)?

> +        ctx->greg_log[ctx->greg_log_idx] = rnum;
> +        ctx->greg_log_idx++;
> +    }
> +}
> +
> +static inline void ctx_log_greg_write_pair(DisasContext *ctx, int rnum)
> +{
> +    ctx_log_greg_write(ctx, rnum);

Should we assert(!(rnum % 2))?

> +    ctx_log_greg_write(ctx, rnum + 1);
> +}