Skip to contentSkip to conversation

hexagon: model the PCYCLE registers

PATCH In review Brian Cain 2 participants 8 messages Oct 14

lore
Share & tools
lore

Brian Cain

author
#0 lore raw

v2 cover hexagon: model the PCYCLE registers

The pcycle registers measure activity - a very coarse and simple PMU-like feature. The baseline had a "count the instructions per TB and scale a counter" model (to be summed across vCPUs upon reg read). But that's not a good model and it adds work to all TBs.

Instead: we'll use time as a slightly better model, but only accumulating when there's activity. Using a clock is unfortunately less stable across hosts and changes to translation, but still a net improvement all things considered.

In v2:
- Removed "pcycle_freq_hz" property.
- Moved deletions into "remove packet-count PCYCLE implementation" patch at the start of the series.
- Removed translator_io_start() from start/stop/wait/resume instructions:
these do not trigger I/O.
- added comment update for translator_io_start()

v1: https://lore.kernel.org/qemu-devel/[email protected]/

Brian Cain (4):
target/hexagon: remove packet-count PCYCLE implementation hw/hexagon: model PCYCLE with virtual clock target/hexagon: mark clock-backed register reads as I/O
exec: correct translator_io_start documentation

 include/exec/translator.h              |   5 +-
 include/hw/hexagon/hexagon_globalreg.h |   5 +
 target/hexagon/cpu.h                   |   2 -
 target/hexagon/cpu_helper.h            |   6 --
 target/hexagon/gen_tcg_sys.h           |   8 +-
 target/hexagon/helper.h                |   2 +
 target/hexagon/translate.h             |   2 -
 hw/hexagon/hexagon_globalreg.c         | 129 +++++++++++++++++++++++++
 target/hexagon/cpu.c                   |  10 +-
 target/hexagon/cpu_helper.c            |  79 ---------------
 target/hexagon/genptr.c                |  38 +++++++-
 target/hexagon/hexswi.c                |  10 +-
 target/hexagon/machine.c               |   2 +-
 target/hexagon/op_helper.c             |  45 +++++++++
 target/hexagon/translate.c             |  21 ----
 hw/hexagon/trace-events                |   1 +
 target/hexagon/hex_common.py           |   8 +-
 17 files changed, 244 insertions(+), 129 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 1/4 target/hexagon: remove packet-count PCYCLE implementation

---
 target/hexagon/cpu.h        |  2 -
 target/hexagon/cpu_helper.h |  6 ---
 target/hexagon/translate.h  |  2 -
 target/hexagon/cpu.c        |  1 -
 target/hexagon/cpu_helper.c | 79 -------------------------------------
 target/hexagon/machine.c    |  2 +-
 target/hexagon/translate.c  | 21 ----------
 7 files changed, 1 insertion(+), 112 deletions(-)
target/hexagon/cpu.h +0 -2
index 65fd2b29830..2da3b586b5a 100644
@@ -151,7 +151,6 @@ typedef struct CPUArchState {
     hex_lock_state_t k0_lock_state;
     uint32_t tlb_lock_count;
     uint32_t k0_lock_count;
-    uint64_t t_cycle_count;
 #endif
     uint32_t imprecise_exception;
     target_ulong new_value_usr;
@@ -226,7 +225,6 @@ static inline HexagonHVXContext *hex_hvx(CPUHexagonState *env)
 
 FIELD(TB_FLAGS, IS_TIGHT_LOOP, 0, 1)
 FIELD(TB_FLAGS, MMU_INDEX, 1, 3)
-FIELD(TB_FLAGS, PCYCLE_ENABLED, 4, 1)
 FIELD(TB_FLAGS, HVX_COPROC_ENABLED, 5, 1)
 
 G_NORETURN void hexagon_raise_exception_err(CPUHexagonState *env,
target/hexagon/cpu_helper.h +0 -6
index 95a8f6587b6..8b1fb98a51a 100644
@@ -24,11 +24,5 @@ void hexagon_start_threads(CPUHexagonState *env, uint32_t mask);
 void hexagon_stop_thread(CPUHexagonState *env);
 void hexagon_nmi(CPUHexagonState *env, uint32_t thread_mask);
 void hexagon_resume_threads(CPUHexagonState *env, uint32_t mask);
-uint64_t hexagon_get_sys_pcycle_count(CPUHexagonState *env);
-uint32_t hexagon_get_sys_pcycle_count_high(CPUHexagonState *env);
-uint32_t hexagon_get_sys_pcycle_count_low(CPUHexagonState *env);
-void hexagon_set_sys_pcycle_count_high(CPUHexagonState *env, uint32_t val);
-void hexagon_set_sys_pcycle_count_low(CPUHexagonState *env, uint32_t val);
-void hexagon_set_sys_pcycle_count(CPUHexagonState *env, uint64_t val);
 
 #endif
target/hexagon/translate.h +0 -2
index 2d1ed5208b7..ccf9d52997a 100644
@@ -97,10 +97,8 @@ typedef struct DisasContext {
     TCGv new_pred_value[NUM_PREGS];
     TCGv branch_taken;
     TCGv dczero_addr;
-    bool pcycle_enabled;
     bool hvx_coproc_enabled;
     bool hvx_check_emitted;
-    uint32_t num_cycles;
 } DisasContext;
 
 bool is_gather_store_insn(DisasContext *ctx);
target/hexagon/cpu.c +0 -1
index 6550e7fa800..1bdc3d8aed6 100644
@@ -349,7 +349,6 @@ static TCGTBCPUState hexagon_get_tb_cpu_state(CPUState *cs)
     cpu = env_archcpu(env);
     hex_flags = FIELD_DP32(hex_flags, TB_FLAGS, MMU_INDEX,
                            cpu_mmu_index(env_cpu(env), false));
-    hex_flags = FIELD_DP32(hex_flags, TB_FLAGS, PCYCLE_ENABLED, 1);
     hex_flags = FIELD_DP32(hex_flags, TB_FLAGS, HVX_COPROC_ENABLED,
                            cpu->hvx_ctx[0] &&
                            GET_SSR_FIELD(SSR_XE, env->t_sreg[HEX_SREG_SSR]));
target/hexagon/cpu_helper.c +0 -79

85 lines not on this page · raw message

target/hexagon/machine.c +1 -1
index f3e97224d81..36fee33d333 100644
@@ -35,7 +35,7 @@ const VMStateDescription vmstate_hexagon_cpu = {
         VMSTATE_UINT32(env.k0_lock_count, HexagonCPU),
         VMSTATE_UINT32(env.threadId, HexagonCPU),
         VMSTATE_UINT32(env.cause_code, HexagonCPU),
-        VMSTATE_UINT64(env.t_cycle_count, HexagonCPU),
+        VMSTATE_UNUSED(sizeof(uint64_t)),
         VMSTATE_UINT32(env.imprecise_exception, HexagonCPU),
 
         VMSTATE_END_OF_LIST()
target/hexagon/translate.c +0 -21
index cd1abdf1461..beee09bc4cb 100644
@@ -63,7 +63,6 @@ TCGv hex_llsc_addr;
 TCGv hex_llsc_val;
 TCGv_i64 hex_llsc_val_i64;
 #ifndef CONFIG_USER_ONLY
-TCGv_i64 hex_cycle_count;
 TCGv hex_imprecise_exception;
 #endif
 TCGv hex_vstore_addr[VSTORES_MAX];
@@ -144,16 +143,6 @@ static void gen_precise_exception(int cause, uint32_t PC)
                                tcg_constant_i32(PC));
 }
 
-#ifndef CONFIG_USER_ONLY
-static void gen_pcycle_counters(DisasContext *ctx)
-{
-    if (ctx->pcycle_enabled) {
-        tcg_gen_addi_i64(hex_cycle_count, hex_cycle_count, ctx->num_cycles);
-    }
-}
-#endif
-
-
 static void gen_exec_counters(DisasContext *ctx)
 {
     tcg_gen_addi_tl(hex_gpr[HEX_REG_QEMU_PKT_CNT],
@@ -162,9 +151,6 @@ static void gen_exec_counters(DisasContext *ctx)
                     hex_gpr[HEX_REG_QEMU_INSN_CNT], ctx->num_insns);
     tcg_gen_addi_tl(hex_gpr[HEX_REG_QEMU_HVX_CNT],
                     hex_gpr[HEX_REG_QEMU_HVX_CNT], ctx->num_hvx_insns);
-#ifndef CONFIG_USER_ONLY
-    gen_pcycle_counters(ctx);
-#endif
 }
 
 static bool use_goto_tb(DisasContext *ctx, target_ulong dest)
@@ -1128,8 +1114,6 @@ static void gen_commit_hvx(DisasContext *ctx)
     }
 }
 
-#define PCYCLES_PER_PACKET 1
-
 static void update_exec_counters(DisasContext *ctx)
 {
     int num_real_insns = 0;
@@ -1149,7 +1133,6 @@ static void update_exec_counters(DisasContext *ctx)
     ctx->num_packets++;
     ctx->num_insns += num_real_insns;
     ctx->num_hvx_insns += num_hvx_insns;
-    ctx->num_cycles += PCYCLES_PER_PACKET;
 }
 
 #ifndef CONFIG_USER_ONLY
@@ -1335,8 +1318,6 @@ static void hexagon_tr_init_disas_context(DisasContextBase *dcbase,
     ctx->hex_def = HEXAGON_CPU_GET_CLASS(hex_cpu)->hex_def;
     ctx->ieee_fp_extension = hex_cpu->cfg.ieee_fp_extension;
 #ifndef CONFIG_USER_ONLY
-    ctx->num_cycles = 0;
-    ctx->pcycle_enabled = FIELD_EX32(hex_flags, TB_FLAGS, PCYCLE_ENABLED);
     ctx->hvx_coproc_enabled =
         FIELD_EX32(hex_flags, TB_FLAGS, HVX_COPROC_ENABLED);
     ctx->hvx_check_emitted = false;
@@ -1489,8 +1470,6 @@ void hexagon_translate_init(void)
     hex_cause_code = tcg_global_mem_new_i32(tcg_env,
         offsetof(CPUHexagonState, cause_code), "cause_code");
 #ifndef CONFIG_USER_ONLY
-    hex_cycle_count = tcg_global_mem_new_i64(tcg_env,
-        offsetof(CPUHexagonState, t_cycle_count), "t_cycle_count");
     hex_imprecise_exception = tcg_global_mem_new(tcg_env,
         offsetof(CPUHexagonState, imprecise_exception), "imprecise_exception");
 #endif
Signature · 1 line
2.34.1
Reviewed-by on v2 1/4
#2 lore raw

Re: [PATCH v2 1/4] target/hexagon: remove packet-count PCYCLE implementation

Quoted 11 lines · Brian Cain
---
 target/hexagon/cpu.h        |  2 -
 target/hexagon/cpu_helper.h |  6 ---
 target/hexagon/translate.h  |  2 -
 target/hexagon/cpu.c        |  1 -
 target/hexagon/cpu_helper.c | 79 -------------------------------------
 target/hexagon/machine.c    |  2 +-
 target/hexagon/translate.c  | 21 ----------
 7 files changed, 1 insertion(+), 112 deletions(-)
author
#3 lore raw

PATCH v2 2/4 hw/hexagon: model PCYCLE with virtual clock

In reply to Brian Cain
---
 include/hw/hexagon/hexagon_globalreg.h |   5 +
 target/hexagon/helper.h                |   2 +
 hw/hexagon/hexagon_globalreg.c         | 129 +++++++++++++++++++++++++
 target/hexagon/cpu.c                   |   9 +-
 target/hexagon/genptr.c                |   8 ++
 target/hexagon/hexswi.c                |  10 +-
 target/hexagon/op_helper.c             |  45 +++++++++
 hw/hexagon/trace-events                |   1 +
 8 files changed, 205 insertions(+), 4 deletions(-)
include/hw/hexagon/hexagon_globalreg.h +5 -0
index 07437dfabb1..2d5c3c166b1 100644
@@ -33,6 +33,10 @@ struct HexagonGlobalRegState {
     /* Global performance cycle counter base */
     uint64_t g_pcycle_base;
 
+    /* Global performance cycle counter clock state */
+    int64_t pcycle_start_ns;
+    bool pcycle_running;
+
     /* Properties for global register reset values */
     uint32_t boot_evb;           /* Boot Exception Vector Base (HEX_SREG_EVB) */
     uint64_t config_table_addr;  /* Configuration table base */
@@ -56,6 +60,7 @@ void hexagon_globalreg_write_masked(HexagonGlobalRegState *s, uint32_t reg,
                                     uint32_t value);
 
 /* Global performance cycle counter access */
+uint64_t hexagon_globalreg_read_pcycle(HexagonGlobalRegState *s);
 uint64_t hexagon_globalreg_get_pcycle_base(HexagonGlobalRegState *s);
 void hexagon_globalreg_set_pcycle_base(HexagonGlobalRegState *s,
                                        uint64_t value);
target/hexagon/helper.h +2 -0
index 997d87e38e6..47958c48ea9 100644
@@ -130,6 +130,8 @@ DEF_HELPER_2(getimask, i32, env, i32)
 DEF_HELPER_3(setimask, void, env, i32, i32)
 DEF_HELPER_2(sreg_read, i32, env, i32)
 DEF_HELPER_2(sreg_read_pair, i64, env, i32)
+DEF_HELPER_2(upcycle_read, i32, env, i32)
+DEF_HELPER_1(upcycle_read_pair, i64, env)
 DEF_HELPER_2(greg_read, i32, env, i32)
 DEF_HELPER_2(greg_read_pair, i64, env, i32)
 DEF_HELPER_3(sreg_write_masked, void, env, i32, i32)
hw/hexagon/hexagon_globalreg.c +129 -0

179 lines not on this page · raw message

target/hexagon/cpu.c +7 -2
index 1bdc3d8aed6..796bb6df9db 100644
@@ -861,15 +861,20 @@ uint32_t hexagon_greg_read(CPUHexagonState *env, uint32_t reg)
 {
     uint32_t ssr = env->t_sreg[HEX_SREG_SSR];
     int ssr_ce = GET_SSR_FIELD(SSR_CE, ssr);
+    HexagonCPU *cpu = env_archcpu(env);
 
     if (reg <= HEX_GREG_G3) {
         return env->greg[reg];
     }
     switch (reg) {
     case HEX_GREG_GPCYCLELO:
-        return ssr_ce ? hexagon_get_sys_pcycle_count_low(env) : 0;
+        return ssr_ce ?
+            hexagon_globalreg_read(cpu->globalregs, HEX_SREG_PCYCLELO,
+                                   env->threadId) : 0;
     case HEX_GREG_GPCYCLEHI:
-        return ssr_ce ? hexagon_get_sys_pcycle_count_high(env) : 0;
+        return ssr_ce ?
+            hexagon_globalreg_read(cpu->globalregs, HEX_SREG_PCYCLEHI,
+                                   env->threadId) : 0;
     default:
         return env->greg[reg];
     }
target/hexagon/genptr.c +8 -0
index 90197c6e72e..e19b9c359b3 100644
@@ -443,6 +443,12 @@ static inline void gen_read_ctrl_reg(DisasContext *ctx, const int reg_num,
     } else if (reg_num == HEX_REG_UTIMERHI) {
         gen_helper_sreg_read(dest, tcg_env,
                              tcg_constant_i32(HEX_SREG_TIMERHI));
+    } else if (reg_num == HEX_REG_UPCYCLELO) {
+        gen_helper_upcycle_read(dest, tcg_env,
+                                tcg_constant_i32(HEX_SREG_PCYCLELO));
+    } else if (reg_num == HEX_REG_UPCYCLEHI) {
+        gen_helper_upcycle_read(dest, tcg_env,
+                                tcg_constant_i32(HEX_SREG_PCYCLEHI));
 #else
     } else if (reg_num == HEX_REG_UTIMERLO) {
         TCGv_i64 utimer = tcg_temp_new_i64();
@@ -488,6 +494,8 @@ static inline void gen_read_ctrl_reg_pair(DisasContext *ctx, const int reg_num,
         gen_helper_sreg_read(lo, tcg_env, tcg_constant_i32(HEX_SREG_TIMERLO));
         gen_helper_sreg_read(hi, tcg_env, tcg_constant_i32(HEX_SREG_TIMERHI));
         tcg_gen_concat_i32_i64(dest, lo, hi);
+    } else if (reg_num == HEX_REG_UPCYCLELO) {
+        gen_helper_upcycle_read_pair(dest, tcg_env);
 #else
     } else if (reg_num == HEX_REG_UTIMERLO) {
         /* One helper call, so the pair is a coherent 64-bit snapshot. */
target/hexagon/hexswi.c +8 -2
index ef1d558dfc4..e7362b56650 100644
@@ -692,8 +692,14 @@ static void sim_handle_trap0(CPUHexagonState *env)
 
     case HEX_SYS_READ_PCYCLES:
     {
-        env->gpr[HEX_REG_R00] = hexagon_get_sys_pcycle_count_low(env);
-        env->gpr[HEX_REG_R01] = hexagon_get_sys_pcycle_count_high(env);
+        HexagonCPU *cpu = env_archcpu(env);
+        uint64_t pcycles;
+
+        BQL_LOCK_GUARD();
+        pcycles = cpu->globalregs ?
+            hexagon_globalreg_read_pcycle(cpu->globalregs) : 0;
+        env->gpr[HEX_REG_R00] = (uint32_t)pcycles;
+        env->gpr[HEX_REG_R01] = (uint32_t)(pcycles >> 32);
         break;
     }
 
target/hexagon/op_helper.c +45 -0

72 lines not on this page · raw message

hw/hexagon/trace-events +1 -0
index 5d623ed2516..8c906a30ebd 100644
@@ -1,3 +1,4 @@
 # Hexagon global register access
 hexagon_globalreg_read(uint32_t htid, const char *reg_name, uint32_t value) "htid=%u reg=%s value=0x%x"
 hexagon_globalreg_write(uint32_t htid, const char *reg_name, uint32_t value) "htid=%u reg=%s value=0x%x"
+hexagon_pcycle_run_state(bool running, uint64_t base) "running=%u base=%" PRIu64
Signature · 1 line
2.34.1
Reviewed-by on v2 2/4
#4 lore raw

Re: [PATCH v2 2/4] hw/hexagon: model PCYCLE with virtual clock

Quoted 12 lines · Brian Cain
---
 include/hw/hexagon/hexagon_globalreg.h |   5 +
 target/hexagon/helper.h                |   2 +
 hw/hexagon/hexagon_globalreg.c         | 129 +++++++++++++++++++++++++
 target/hexagon/cpu.c                   |   9 +-
 target/hexagon/genptr.c                |   8 ++
 target/hexagon/hexswi.c                |  10 +-
 target/hexagon/op_helper.c             |  45 +++++++++
 hw/hexagon/trace-events                |   1 +
 8 files changed, 205 insertions(+), 4 deletions(-)
author
#5 lore raw

PATCH v2 3/4 target/hexagon: mark clock-backed register reads as I/O

In reply to Brian Cain

Mark scalar and pair reads of *PCYCLE* regs as I/O so icount synchronizes before reading.

Cover the read paths of {U,G}{PCYCLE,TIMER}{LO,HI,} registers.

---
 target/hexagon/gen_tcg_sys.h |  8 ++++++--
 target/hexagon/genptr.c      | 30 ++++++++++++++++++++++++++----
 target/hexagon/hex_common.py |  8 ++++----
 3 files changed, 36 insertions(+), 10 deletions(-)
target/hexagon/gen_tcg_sys.h +6 -2
index c9f6b41a877..413ccc97f7b 100644
@@ -84,10 +84,14 @@
     } while (0)
 
 #define fGEN_TCG_Y2_resume(SHORTCODE) \
-    gen_helper_resume(tcg_env, RsV)
+    do { \
+        gen_helper_resume(tcg_env, RsV); \
+    } while (0)
 
 #define fGEN_TCG_Y2_start(SHORTCODE) \
-    gen_helper_start(tcg_env, RsV)
+    do { \
+        gen_helper_start(tcg_env, RsV); \
+    } while (0)
 
 #define fGEN_TCG_Y2_stop(SHORTCODE) \
     do { \
target/hexagon/genptr.c +26 -4
index e19b9c359b3..1a68d8c1b8d 100644
@@ -297,6 +297,9 @@ static void gen_log_sreg_write(DisasContext *ctx, int rnum, TCGv_i32 val)
 {
     uint32_t reg_mask = sreg_immut_masks[rnum];
 
+    if (rnum == HEX_SREG_MODECTL || rnum == HEX_SREG_SYSCFG) {
+        translator_io_start(&ctx->base);
+    }
     if (rnum == HEX_SREG_IMASK &&
         ctx->hex_def->hex_version < HEX_VER_V81) {
         reg_mask = 0xffff0000;
@@ -331,8 +334,12 @@ static void gen_log_sreg_write_pair(DisasContext *ctx, int rnum, TCGv_i64 val)
 }
 
 G_GNUC_UNUSED
-static void gen_read_sreg(TCGv_i32 dst, int reg_num)
+static void gen_read_sreg(DisasContext *ctx, TCGv_i32 dst, int reg_num)
 {
+    if (reg_num == HEX_SREG_TIMERLO || reg_num == HEX_SREG_TIMERHI ||
+        reg_num == HEX_SREG_PCYCLELO || reg_num == HEX_SREG_PCYCLEHI) {
+        translator_io_start(&ctx->base);
+    }
     if (reg_num >= HEX_SREG_GLB_START || reg_num == HEX_SREG_BADVA) {
         gen_helper_sreg_read(dst, tcg_env, tcg_constant_i32(reg_num));
     } else {
@@ -341,8 +348,11 @@ static void gen_read_sreg(TCGv_i32 dst, int reg_num)
 }
 
 G_GNUC_UNUSED
-static void gen_read_sreg_pair(TCGv_i64 dst, int reg_num)
+static void gen_read_sreg_pair(DisasContext *ctx, TCGv_i64 dst, int reg_num)
 {
+    if (reg_num == HEX_SREG_TIMERLO || reg_num == HEX_SREG_PCYCLELO) {
+        translator_io_start(&ctx->base);
+    }
     if (reg_num < HEX_SREG_GLB_START) {
         if (reg_num + 1 == HEX_SREG_BADVA) {
             TCGv_i32 badva = tcg_temp_new_i32();
@@ -359,8 +369,11 @@ static void gen_read_sreg_pair(TCGv_i64 dst, int reg_num)
 }
 
 G_GNUC_UNUSED
-static void gen_read_greg(TCGv_i32 dst, int reg_num)
+static void gen_read_greg(DisasContext *ctx, TCGv_i32 dst, int reg_num)
 {
+    if (reg_num == HEX_GREG_GPCYCLELO || reg_num == HEX_GREG_GPCYCLEHI) {
+        translator_io_start(&ctx->base);
+    }
     if (reg_num <= HEX_GREG_G3) {
         tcg_gen_mov_i32(dst, hex_greg[reg_num]);
     } else {
@@ -369,8 +382,11 @@ static void gen_read_greg(TCGv_i32 dst, int reg_num)
 }
 
 G_GNUC_UNUSED
-static void gen_read_greg_pair(TCGv_i64 dst, int reg_num)
+static void gen_read_greg_pair(DisasContext *ctx, TCGv_i64 dst, int reg_num)
 {
+    if (reg_num == HEX_GREG_GPCYCLELO) {
+        translator_io_start(&ctx->base);
+    }
     if (reg_num == HEX_GREG_G0 || reg_num == HEX_GREG_G2) {
         tcg_gen_concat_i32_i64(dst, hex_greg[reg_num],
                                     hex_greg[reg_num + 1]);
@@ -438,15 +454,19 @@ static inline void gen_read_ctrl_reg(DisasContext *ctx, const int reg_num,
                         ctx->num_hvx_insns);
 #ifndef CONFIG_USER_ONLY
     } else if (reg_num == HEX_REG_UTIMERLO) {
+        translator_io_start(&ctx->base);
         gen_helper_sreg_read(dest, tcg_env,
                              tcg_constant_i32(HEX_SREG_TIMERLO));
     } else if (reg_num == HEX_REG_UTIMERHI) {
+        translator_io_start(&ctx->base);
         gen_helper_sreg_read(dest, tcg_env,
                              tcg_constant_i32(HEX_SREG_TIMERHI));
     } else if (reg_num == HEX_REG_UPCYCLELO) {
+        translator_io_start(&ctx->base);
         gen_helper_upcycle_read(dest, tcg_env,
                                 tcg_constant_i32(HEX_SREG_PCYCLELO));
     } else if (reg_num == HEX_REG_UPCYCLEHI) {
+        translator_io_start(&ctx->base);
         gen_helper_upcycle_read(dest, tcg_env,
                                 tcg_constant_i32(HEX_SREG_PCYCLEHI));
 #else
@@ -489,12 +509,14 @@ static inline void gen_read_ctrl_reg_pair(DisasContext *ctx, const int reg_num,
         tcg_gen_concat_i32_i64(dest, hvx_cnt, hex_gpr[reg_num + 1]);
 #ifndef CONFIG_USER_ONLY
     } else if (reg_num == HEX_REG_UTIMERLO) {
+        translator_io_start(&ctx->base);
         TCGv lo = tcg_temp_new();
         TCGv hi = tcg_temp_new();
         gen_helper_sreg_read(lo, tcg_env, tcg_constant_i32(HEX_SREG_TIMERLO));
         gen_helper_sreg_read(hi, tcg_env, tcg_constant_i32(HEX_SREG_TIMERHI));
         tcg_gen_concat_i32_i64(dest, lo, hi);
     } else if (reg_num == HEX_REG_UPCYCLELO) {
+        translator_io_start(&ctx->base);
         gen_helper_upcycle_read_pair(dest, tcg_env);
 #else
     } else if (reg_num == HEX_REG_UTIMERLO) {
target/hexagon/hex_common.py +4 -4
index 9d4650f52fb..94e70b8657d 100755
@@ -1244,7 +1244,7 @@ def decl_tcg(self, f, tag, regno):
         self.gen_check_impl(f, regno)
         f.write(code_fmt(f"""\
             TCGv_i32 {self.reg_tcg()} = tcg_temp_new_i32();
-            gen_read_greg({self.reg_tcg()}, {self.reg_num});
+            gen_read_greg(ctx, {self.reg_tcg()}, {self.reg_num});
         """))
     def analyze_read(self, f, regno):
         pass
@@ -1275,7 +1275,7 @@ def decl_tcg(self, f, tag, regno):
         self.gen_check_impl(f, regno)
         f.write(code_fmt(f"""\
             TCGv_i64 {self.reg_tcg()} = tcg_temp_new_i64();
-            gen_read_greg_pair({self.reg_tcg()}, {self.reg_num});
+            gen_read_greg_pair(ctx, {self.reg_tcg()}, {self.reg_num});
         """))
     def analyze_read(self, f, regno):
         pass
@@ -1304,7 +1304,7 @@ def decl_tcg(self, f, tag, regno):
         self.decl_reg_num(f, regno)
         f.write(code_fmt(f"""\
             TCGv_i32 {self.reg_tcg()} = tcg_temp_new_i32();
-            gen_read_sreg({self.reg_tcg()}, {self.reg_num});
+            gen_read_sreg(ctx, {self.reg_tcg()}, {self.reg_num});
         """))
     def analyze_read(self, f, regno):
         pass
@@ -1333,7 +1333,7 @@ def decl_tcg(self, f, tag, regno):
         self.decl_reg_num(f, regno)
         f.write(code_fmt(f"""\
             TCGv_i64 {self.reg_tcg()} = tcg_temp_new_i64();
-            gen_read_sreg_pair({self.reg_tcg()}, {self.reg_num});
+            gen_read_sreg_pair(ctx, {self.reg_tcg()}, {self.reg_num});
         """))
     def analyze_read(self, f, regno):
         pass
Signature · 1 line
2.34.1
author
#6 lore raw

PATCH v2 4/4 exec: correct translator_io_start documentation

In reply to Brian Cain
---
 include/exec/translator.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/exec/translator.h +2 -3
index 104e6d4f361..4e6e424e7cf 100644
@@ -168,9 +168,8 @@ bool translator_use_goto_tb(DisasContextBase *db, vaddr dest);
  * translator_io_start
  * @db: Disassembly context
  *
- * If icount is enabled, set cpu->can_do_io, adjust db->is_jmp to
- * DISAS_TOO_MANY if it is still DISAS_NEXT, and return true.
- * Otherwise return false.
+ * Adjust db->is_jmp to DISAS_TOO_MANY if it is still DISAS_NEXT and return
+ * true.  The instruction will then be the last instruction in the TB.
  */
 bool translator_io_start(DisasContextBase *db);
 
Signature · 1 line
2.34.1