diff mbox series

[v2,01/10] target/s390x: Change help_goto_direct to work on displacements

Message ID 20240605215739.4758-2-richard.henderson@linaro.org
State New
Headers show
Series target/s390x: pc-relative translation | expand

Commit Message

Richard Henderson June 5, 2024, 9:57 p.m. UTC
In preparation for CF_PCREL, reduce reliance on absolute values.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/s390x/tcg/translate.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
index c81e035dea..f25ae02a4e 100644
--- a/target/s390x/tcg/translate.c
+++ b/target/s390x/tcg/translate.c
@@ -1073,13 +1073,15 @@  struct DisasInsn {
 /* ====================================================================== */
 /* Miscellaneous helpers, used by several operations.  */
 
-static DisasJumpType help_goto_direct(DisasContext *s, uint64_t dest)
+static DisasJumpType help_goto_direct(DisasContext *s, int64_t disp)
 {
+    uint64_t dest = s->base.pc_next + disp;
+
     update_cc_op(s);
     per_breaking_event(s);
     per_branch(s, tcg_constant_i64(dest));
 
-    if (dest == s->pc_tmp) {
+    if (disp == s->ilen) {
         return DISAS_NEXT;
     }
     if (use_goto_tb(s, dest)) {
@@ -1105,7 +1107,8 @@  static DisasJumpType help_goto_indirect(DisasContext *s, TCGv_i64 dest)
 static DisasJumpType help_branch(DisasContext *s, DisasCompare *c,
                                  bool is_imm, int imm, TCGv_i64 cdest)
 {
-    uint64_t dest = s->base.pc_next + (int64_t)imm * 2;
+    int64_t disp = (int64_t)imm * 2;
+    uint64_t dest = s->base.pc_next + disp;
     TCGLabel *lab;
 
     /* Take care of the special cases first.  */
@@ -1120,7 +1123,7 @@  static DisasJumpType help_branch(DisasContext *s, DisasCompare *c,
         if (c->cond == TCG_COND_ALWAYS
             || (dest == s->pc_tmp &&
                 !(s->base.tb->flags & FLAG_MASK_PER_BRANCH))) {
-            return help_goto_direct(s, dest);
+            return help_goto_direct(s, disp);
         }
     } else {
         if (!cdest) {