Skip to contentSkip to conversation

Hexagon: two minor cleanups to comments and python scripts

PATCH Superseded Matheus Tavares Bernardino 2 participants 5 messages May 23, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Hexagon: two minor cleanups to comments and python scripts

These are two minor follow ups to the last Hexagon pull, updating some stale code comments and removing undefined variables from error messages at python scripts.

Matheus Tavares Bernardino (2):
target/hexagon/*.py: remove undef vars from bad_register()
Hexagon: fix outdated hex_new_* references in comments

 target/hexagon/genptr.c            | 10 +++++-----
 target/hexagon/translate.c         |  2 +-
 target/hexagon/gen_helper_funcs.py |  8 ++++----
 target/hexagon/gen_tcg_funcs.py    |  6 +++---
 4 files changed, 13 insertions(+), 13 deletions(-)
Signature · 1 line
2.37.2
#1 lore raw

PATCH 1/2 target/hexagon/*.py: remove undef vars from bad_register()

Some calls to hex_common.bad_register() in Hexagon python files are passing undefined variables. Let's remove those.

---
 target/hexagon/gen_helper_funcs.py | 8 ++++----
 target/hexagon/gen_tcg_funcs.py    | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)
target/hexagon/gen_helper_funcs.py +4 -4
index e80550f94e..367d08aceb 100755
@@ -87,9 +87,9 @@ def gen_helper_arg_opn(f, regtype, regid, i, tag):
         elif hex_common.is_new_val(regtype, regid, tag):
             gen_helper_arg_new(f, regtype, regid, i)
         else:
-            hex_common.bad_register(regtype, regid, toss, numregs)
+            hex_common.bad_register(regtype, regid)
     else:
-        hex_common.bad_register(regtype, regid, toss, numregs)
+        hex_common.bad_register(regtype, regid)
 
 
 def gen_helper_arg_imm(f, immlett):
@@ -135,7 +135,7 @@ def gen_helper_dest_decl_opn(f, regtype, regid, i):
         else:
             gen_helper_dest_decl(f, regtype, regid, i)
     else:
-        hex_common.bad_register(regtype, regid, toss, numregs)
+        hex_common.bad_register(regtype, regid)
 
 
 def gen_helper_src_var_ext(f, regtype, regid):
@@ -185,7 +185,7 @@ def gen_helper_return_opn(f, regtype, regid, i):
         else:
             gen_helper_return(f, regtype, regid, i)
     else:
-        hex_common.bad_register(regtype, regid, toss, numregs)
+        hex_common.bad_register(regtype, regid)
 
 
 ##
target/hexagon/gen_tcg_funcs.py +3 -3
index c73467b840..c87ea856f7 100755
@@ -354,9 +354,9 @@ def genptr_src_read_opn(f, regtype, regid, tag):
         elif hex_common.is_new_val(regtype, regid, tag):
             genptr_src_read_new(f, regtype, regid)
         else:
-            hex_common.bad_register(regtype, regid, toss, numregs)
+            hex_common.bad_register(regtype, regid)
     else:
-        hex_common.bad_register(regtype, regid, toss, numregs)
+        hex_common.bad_register(regtype, regid)
 
 
 def gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i):
@@ -468,7 +468,7 @@ def genptr_dst_write_opn(f, regtype, regid, tag):
         else:
             genptr_dst_write(f, tag, regtype, regid)
     else:
-        hex_common.bad_register(regtype, regid, toss, numregs)
+        hex_common.bad_register(regtype, regid)
 
 
 ##
Signature · 1 line
2.37.2
#2 lore raw

RE: [PATCH 1/2] target/hexagon/*.py: remove undef vars from bad_register()

Quoted 26 lines

-----Original Message-----
From: Matheus Tavares Bernardino <[email protected]>
Sent: Tuesday, May 23, 2023 3:36 PM
To: [email protected]
Cc: Taylor Simpson <[email protected]>; Brian Cain <[email protected]>; Marco Liebel (QUIC) <[email protected]>
Subject: [PATCH 1/2] target/hexagon/*.py: remove undef vars from bad_register()

Some calls to hex_common.bad_register() in Hexagon python files are passing undefined variables. Let's remove those.

---
 target/hexagon/gen_helper_funcs.py | 8 ++++----
 target/hexagon/gen_tcg_funcs.py    | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)
target/hexagon/gen_helper_funcs.py +0 -0
index e80550f94e..367d08aceb 100755

target/hexagon/gen_helper_funcs.py def gen_helper_arg_opn(f, regtype, regid, i, tag): · line 92

Quoted 8 lines
target/hexagon/gen_helper_funcs.py +2 -2
@@ -87,9 +87,9 @@ def gen_helper_arg_opn(f, regtype, regid, i, tag):
         elif hex_common.is_new_val(regtype, regid, tag):
             gen_helper_arg_new(f, regtype, regid, i)
         else:
-            hex_common.bad_register(regtype, regid, toss, numregs)
+            hex_common.bad_register(regtype, regid)
     else:
-        hex_common.bad_register(regtype, regid, toss, numregs)
+        hex_common.bad_register(regtype, regid)

There are other places where toss and numregs are passed to bad_register. Let's go ahead and change bad_register to only take regtype and regid as arguments and remove those arguments everywhere.

Also, if you want to pull the thread on the sweater, go ahead and remove toss and numregs from the many places they are unused.

Thanks,
Taylor

#3 lore raw

PATCH 2/2 Hexagon: fix outdated `hex_new_*` references in comments

In reply to Matheus Tavares Bernardino

Some code comments refer to hex_new_value and hex_new_pred_value, which have been transferred to DisasContext and, in the case of hex_new_value, should now be accessed through get_result_gpr(). Let's update these comments to reflect the new state of the codebase. Since they are only meant to assist developers, we can replace the old names with some pseudocode when convenient.

---
 target/hexagon/genptr.c    | 10 +++++-----
 target/hexagon/translate.c |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)
target/hexagon/genptr.c +5 -5
index cb2aa28a19..8d11d928c9 100644
@@ -880,7 +880,7 @@ static void gen_endloop0(DisasContext *ctx)
         /*
          *    if (hex_gpr[HEX_REG_LC0] > 1) {
          *        PC = hex_gpr[HEX_REG_SA0];
-         *        hex_new_value[HEX_REG_LC0] = hex_gpr[HEX_REG_LC0] - 1;
+         *        result_gpr(HEX_REG_LC0) = hex_gpr[HEX_REG_LC0] - 1;
          *    }
          */
         TCGLabel *label3 = gen_new_label();
@@ -899,7 +899,7 @@ static void gen_endloop1(DisasContext *ctx)
     /*
      *    if (hex_gpr[HEX_REG_LC1] > 1) {
      *        PC = hex_gpr[HEX_REG_SA1];
-     *        hex_new_value[HEX_REG_LC1] = hex_gpr[HEX_REG_LC1] - 1;
+     *        result_gpr(HEX_REG_LC1) = hex_gpr[HEX_REG_LC1] - 1;
      *    }
      */
     TCGLabel *label = gen_new_label();
@@ -948,11 +948,11 @@ static void gen_endloop01(DisasContext *ctx)
     /*
      *    if (hex_gpr[HEX_REG_LC0] > 1) {
      *        PC = hex_gpr[HEX_REG_SA0];
-     *        hex_new_value[HEX_REG_LC0] = hex_gpr[HEX_REG_LC0] - 1;
+     *        result_gpr(HEX_REG_LC0) = hex_gpr[HEX_REG_LC0] - 1;
      *    } else {
      *        if (hex_gpr[HEX_REG_LC1] > 1) {
-     *            hex_next_pc = hex_gpr[HEX_REG_SA1];
-     *            hex_new_value[HEX_REG_LC1] = hex_gpr[HEX_REG_LC1] - 1;
+     *            next_pc = hex_gpr[HEX_REG_SA1];
+     *            result_gpr(HEX_REG_LC1) = hex_gpr[HEX_REG_LC1] - 1;
      *        }
      *    }
      */
target/hexagon/translate.c +1 -1
index b18f1a9051..8838ab2364 100644
@@ -556,7 +556,7 @@ static void gen_start_packet(DisasContext *ctx)
     }
 
     /*
-     * Preload the predicated pred registers into hex_new_pred_value[pred_num]
+     * Preload the predicated pred registers into ctx->new_pred_value[pred_num]
      * Only endloop instructions conditionally write to pred registers
      */
     if (ctx->need_commit && pkt->pkt_has_endloop) {
Signature · 1 line
2.37.2
#4 lore raw

RE: [PATCH 2/2] Hexagon: fix outdated `hex_new_*` references in comments

Quoted 29 lines

-----Original Message-----
From: Matheus Tavares Bernardino <[email protected]>
Sent: Tuesday, May 23, 2023 3:36 PM
To: [email protected]
Cc: Taylor Simpson <[email protected]>; Brian Cain <[email protected]>; Marco Liebel (QUIC) <[email protected]>
Subject: [PATCH 2/2] Hexagon: fix outdated hex_new_* references in comments

Some code comments refer to hex_new_value and hex_new_pred_value, which have been transferred to DisasContext and, in the case of hex_new_value, should now be accessed through get_result_gpr(). Let's update these comments to reflect the new state of the codebase. Since they are only meant to assist developers, we can replace the old names with some pseudocode when convenient.

---
 target/hexagon/genptr.c    | 10 +++++-----
 target/hexagon/translate.c |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)
target/hexagon/genptr.c index renamed from target/hexagon/genptr.c +0 -0

cb2aa28a19..8d11d928c9 100644

target/hexagon/genptr.c static void gen_endloop0(DisasContext *ctx) · line 885

Quoted 7 lines
target/hexagon/genptr.c +1 -1
@@ -880,7 +880,7 @@ static void gen_endloop0(DisasContext *ctx)
         /*
          *    if (hex_gpr[HEX_REG_LC0] > 1) {
          *        PC = hex_gpr[HEX_REG_SA0];
-         *        hex_new_value[HEX_REG_LC0] = hex_gpr[HEX_REG_LC0] - 1;
+         *        result_gpr(HEX_REG_LC0) = hex_gpr[HEX_REG_LC0] - 1;
          *    }
          */

Go ahead and change these completely to pseudo-code

    If (LC0 > 1) {
        PC = SA0;
        LC0 = LC0 - 1;
    }

Thanks,
Taylor