Skip to contentSkip to conversation

target/hexagon: use vaddr for wait PC

PATCH In review Yonggang Luo 2 participants 3 messages Sep 30

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/hexagon: use vaddr for wait PC

Pass the wait-instruction resume PC as vaddr through the helper interface and implementation.

---
 target/hexagon/gen_tcg_sys.h | 2 +-
 target/hexagon/helper.h      | 2 +-
 target/hexagon/op_helper.c   | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)
target/hexagon/gen_tcg_sys.h +1 -1
index af5032214c..de66b85b49 100644
@@ -80,7 +80,7 @@
 #define fGEN_TCG_Y2_wait(SHORTCODE) \
     do { \
         RsV = RsV; \
-        gen_helper_wait(tcg_env, tcg_constant_tl(ctx->pkt.pc)); \
+        gen_helper_wait(tcg_env, tcg_constant_vaddr(ctx->pkt.pc)); \
     } while (0)
 
 #define fGEN_TCG_Y2_resume(SHORTCODE) \
target/hexagon/helper.h +1 -1
index 71c8da4c46..18cff7f4d2 100644
@@ -136,7 +136,7 @@ DEF_HELPER_3(sreg_write_masked, void, env, i32, i32)
 DEF_HELPER_3(setprio, void, env, i32, i32)
 DEF_HELPER_2(start, void, env, i32)
 DEF_HELPER_1(stop, void, env)
-DEF_HELPER_2(wait, void, env, i32)
+DEF_HELPER_2(wait, void, env, vaddr)
 DEF_HELPER_2(resume, void, env, i32)
 DEF_HELPER_1(resched, void, env)
 DEF_HELPER_3(modify_ssr, void, env, i32, i32)
target/hexagon/op_helper.c +4 -4
index 4f00ca773f..0785f1a127 100644
@@ -1741,7 +1741,7 @@ static void set_wait_mode(CPUHexagonState *env)
     SET_SYSTEM_FIELD(env, HEX_SREG_MODECTL, MODECTL_W, thread_wait_mask);
 }
 
-static void hexagon_wait_thread(CPUHexagonState *env, uint32_t PC)
+static void hexagon_wait_thread(CPUHexagonState *env, vaddr pc)
 {
     CPUState *cs;
 
@@ -1768,7 +1768,7 @@ static void hexagon_wait_thread(CPUHexagonState *env, uint32_t PC)
         return;
     }
     set_wait_mode(env);
-    env->wait_next_pc = PC + 4;
+    env->wait_next_pc = pc + 4;
 
     cpu_interrupt(cs, CPU_INTERRUPT_HALT);
 }
@@ -1836,12 +1836,12 @@ void HELPER(resched)(CPUHexagonState *env)
     resched(env);
 }
 
-void HELPER(wait)(CPUHexagonState *env, uint32_t PC)
+void HELPER(wait)(CPUHexagonState *env, vaddr pc)
 {
     BQL_LOCK_GUARD();
 
     if (!fIN_DEBUG_MODE(env->threadId)) {
-        hexagon_wait_thread(env, PC);
+        hexagon_wait_thread(env, pc);
     }
 }
 
Signature · 1 line
2.55.0.windows.3
#1 lore raw
Quoted 15 lines · Yonggang Luo

Pass the wait-instruction resume PC as vaddr through the helper interface and implementation.

---
  target/hexagon/gen_tcg_sys.h | 2 +-
  target/hexagon/helper.h      | 2 +-
  target/hexagon/op_helper.c   | 8 ++++----
  3 files changed, 6 insertions(+), 6 deletions(-)
target/hexagon/gen_tcg_sys.h +0 -0
index af5032214c..de66b85b49 100644

target/hexagon/gen_tcg_sys.h line 83

Quoted 5 lines
target/hexagon/gen_tcg_sys.h +1 -1
@@ -80,7 +80,7 @@
  #define fGEN_TCG_Y2_wait(SHORTCODE) \
      do { \
          RsV = RsV; \
-        gen_helper_wait(tcg_env, tcg_constant_tl(ctx->pkt.pc)); \
+        gen_helper_wait(tcg_env, tcg_constant_vaddr(ctx->pkt.pc)); \

Just curious, why tcg_constant_vaddr over tcg_constant_i32?

Quoted 53 lines
target/hexagon/gen_tcg_sys.h +0 -0
      } while (0)
 
  #define fGEN_TCG_Y2_resume(SHORTCODE) \
target/hexagon/helper.h +1 -1
index 71c8da4c46..18cff7f4d2 100644
@@ -136,7 +136,7 @@ DEF_HELPER_3(sreg_write_masked, void, env, i32, i32)
  DEF_HELPER_3(setprio, void, env, i32, i32)
  DEF_HELPER_2(start, void, env, i32)
  DEF_HELPER_1(stop, void, env)
-DEF_HELPER_2(wait, void, env, i32)
+DEF_HELPER_2(wait, void, env, vaddr)
  DEF_HELPER_2(resume, void, env, i32)
  DEF_HELPER_1(resched, void, env)
  DEF_HELPER_3(modify_ssr, void, env, i32, i32)
target/hexagon/op_helper.c +4 -4
index 4f00ca773f..0785f1a127 100644
@@ -1741,7 +1741,7 @@ static void set_wait_mode(CPUHexagonState *env)
      SET_SYSTEM_FIELD(env, HEX_SREG_MODECTL, MODECTL_W, thread_wait_mask);
  }
 
-static void hexagon_wait_thread(CPUHexagonState *env, uint32_t PC)
+static void hexagon_wait_thread(CPUHexagonState *env, vaddr pc)
  {
      CPUState *cs;
 
@@ -1768,7 +1768,7 @@ static void hexagon_wait_thread(CPUHexagonState *env, uint32_t PC)
          return;
      }
      set_wait_mode(env);
-    env->wait_next_pc = PC + 4;
+    env->wait_next_pc = pc + 4;
 
      cpu_interrupt(cs, CPU_INTERRUPT_HALT);
  }
@@ -1836,12 +1836,12 @@ void HELPER(resched)(CPUHexagonState *env)
      resched(env);
  }
 
-void HELPER(wait)(CPUHexagonState *env, uint32_t PC)
+void HELPER(wait)(CPUHexagonState *env, vaddr pc)
  {
      BQL_LOCK_GUARD();
 
      if (!fIN_DEBUG_MODE(env->threadId)) {
-        hexagon_wait_thread(env, PC);
+        hexagon_wait_thread(env, pc);
      }
  }
 
#2 lore raw
Quoted 12 lines · Philippe Mathieu-Daudé
Quoted 10 lines · Yonggang Luo

Pass the wait-instruction resume PC as vaddr through the helper interface and implementation.

---
  target/hexagon/gen_tcg_sys.h | 2 +-
  target/hexagon/helper.h      | 2 +-
  target/hexagon/op_helper.c   | 8 ++++----
  3 files changed, 6 insertions(+), 6 deletions(-)
Quoted 12 lines

target/hexagon/gen_tcg_sys.h line 83

Quoted 10 lines
target/hexagon/gen_tcg_sys.h +1 -1
index af5032214c..de66b85b49 100644
@@ -80,7 +80,7 @@
  #define fGEN_TCG_Y2_wait(SHORTCODE) \
      do { \
          RsV = RsV; \
-        gen_helper_wait(tcg_env, tcg_constant_tl(ctx->pkt.pc)); \
+        gen_helper_wait(tcg_env, tcg_constant_vaddr(ctx->pkt.pc)); \

Just curious, why tcg_constant_vaddr over tcg_constant_i32?

because "pc" is more like an addr than i32, if the hexagon is i32 only then i32 is fine. but addr is still easier to understand(pc is an address).

Quoted 55 lines
Quoted 54 lines
target/hexagon/gen_tcg_sys.h +0 -0
      } while (0)
 
  #define fGEN_TCG_Y2_resume(SHORTCODE) \
target/hexagon/helper.h +1 -1
index 71c8da4c46..18cff7f4d2 100644
@@ -136,7 +136,7 @@ DEF_HELPER_3(sreg_write_masked, void, env, i32, i32)
  DEF_HELPER_3(setprio, void, env, i32, i32)
  DEF_HELPER_2(start, void, env, i32)
  DEF_HELPER_1(stop, void, env)
-DEF_HELPER_2(wait, void, env, i32)
+DEF_HELPER_2(wait, void, env, vaddr)
  DEF_HELPER_2(resume, void, env, i32)
  DEF_HELPER_1(resched, void, env)
  DEF_HELPER_3(modify_ssr, void, env, i32, i32)
target/hexagon/op_helper.c +4 -4
index 4f00ca773f..0785f1a127 100644
@@ -1741,7 +1741,7 @@ static void set_wait_mode(CPUHexagonState *env)
      SET_SYSTEM_FIELD(env, HEX_SREG_MODECTL, MODECTL_W, thread_wait_mask);
  }
 
-static void hexagon_wait_thread(CPUHexagonState *env, uint32_t PC)
+static void hexagon_wait_thread(CPUHexagonState *env, vaddr pc)
  {
      CPUState *cs;
 
@@ -1768,7 +1768,7 @@ static void hexagon_wait_thread(CPUHexagonState *env, uint32_t PC)
          return;
      }
      set_wait_mode(env);
-    env->wait_next_pc = PC + 4;
+    env->wait_next_pc = pc + 4;
 
      cpu_interrupt(cs, CPU_INTERRUPT_HALT);
  }
@@ -1836,12 +1836,12 @@ void HELPER(resched)(CPUHexagonState *env)
      resched(env);
  }
 
-void HELPER(wait)(CPUHexagonState *env, uint32_t PC)
+void HELPER(wait)(CPUHexagonState *env, vaddr pc)
  {
      BQL_LOCK_GUARD();
 
      if (!fIN_DEBUG_MODE(env->threadId)) {
-        hexagon_wait_thread(env, PC);
+        hexagon_wait_thread(env, pc);
      }
  }
 
Signature · 6 lines
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo