On 1/10/26 17:59, Anton Johansson via qemu development wrote:
Replaces uses of target_ulong with fixed-size integers, this is a
prerequisite step to compiling cpu.c once for system-mode.

Note: the widening of target_long to int64_t in adjust_addr_body() is
safe as rv32 is ruled out earlier in the function via the check

   /* do nothing for rv32 mode */
   if (riscv_cpu_mxl(env) == MXL_RV32) {
       return addr;
   }

meaning target_long must be equal to int64_t anyway.

Duplicate includes between vector_helper.c and vector_internals.h are
removed.

Signed-off-by: Anton Johansson <[email protected]>
---
  target/riscv/internals.h            | 31 +++++++++---------
  target/riscv/tcg/vector_internals.h |  5 +--
  target/riscv/tcg/vector_helper.c    | 64 +++++++++++++++++--------------------
  3 files changed, 47 insertions(+), 53 deletions(-)


  /* Zjpm addr masking routine */
-static inline target_ulong adjust_addr_body(CPURISCVState *env,
-                                            target_ulong addr,
-                                            bool is_virt_addr)
+static inline uint64_t adjust_addr_body(CPURISCVState *env,
+                                        uint64_t addr,
+                                        bool is_virt_addr)
  {
      RISCVPmPmm pmm = PMM_FIELD_DISABLED;
      uint32_t pmlen = 0;
@@ -239,7 +238,7 @@ static inline target_ulong adjust_addr_body(CPURISCVState 
*env,
/* sign/zero extend masked address by N-1 bit */
      if (signext) {
-        addr = (target_long)addr >> pmlen;
+        addr = (int64_t)addr >> pmlen;
      } else {
          addr = addr >> pmlen;
      }
Maybe safer as (untested):

        addr = (sign ? sextract64 : extract64)
               (addr, 0, (riscv_cpu_mxl_bits(env) - pmlen);

Reply via email to