On 8/7/23 18:54, Jiajie Chen wrote:
--- a/target/loongarch/translate.c
+++ b/target/loongarch/translate.c
@@ -218,6 +218,19 @@ static TCGv va32_address(DisasContext *ctx, TCGv addr)
      return addr;
  }
+static uint64_t sign_extend32(uint64_t data)
+{
+    return (data & 0x7FFFFFFF) - (data & 0x80000000);
+}

While correct, this is just (int32_t)data.
You can fold that into the only user.

+
+static uint64_t va32_result(DisasContext *ctx, uint64_t addr)
+{
+    if (ctx->va32) {
+        addr = sign_extend32(addr);
+    }
+    return addr;
+}

I would call this make_address_pc to match make_address_{i,x}.


r~

Reply via email to