Skip to contentSkip to conversation

target/alpha: Remove unnecessary target_ulong uses

PATCH In review Philippe Mathieu-Daudé 2 participants 10 messages Feb 2 – Feb 3 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover target/alpha: Remove unnecessary target_ulong uses

Replace target_ulong -> uint64_t / vaddr / hwaddr
and TCGv -> TCGv_i64.

Philippe Mathieu-Daudé (7):
target/alpha: Avoid target-specific migration headers in machine.c target/alpha: Build system units in common source set target/alpha: Replace target_ulong -> uint64_t in gdb_write_register() target/alpha: Do not use target_ulong for trap arguments target/alpha: Do not use target_ulong for page table entries / indexes target/alpha: Remove target_ulong uses in get_physical_address() target/alpha: Expand TCGv type for 64-bit target

 target/alpha/gdbstub.c   |   2 +-
 target/alpha/helper.c    |  17 +--
 target/alpha/machine.c   |   3 +-
 target/alpha/translate.c | 228 ++++++++++++++++++++-------------------
 target/alpha/meson.build |   2 +-
 5 files changed, 129 insertions(+), 123 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/7 target/alpha: Avoid target-specific migration headers in machine.c

machine.c doesn't use any target-specific macro defined by the "migration/cpu.h" header. Use the minimum header required:
"migration/qemu-file-types.h" and "migration/vmstate.h", which are not target-specific.

---
 target/alpha/machine.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target/alpha/machine.c +2 -1
index 6828b123ca1..dcba5d441be 100644
@@ -1,6 +1,7 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
-#include "migration/cpu.h"
+#include "migration/qemu-file-types.h"
+#include "migration/vmstate.h"
 
 static int get_fpcr(QEMUFile *f, void *opaque, size_t size,
                     const VMStateField *field)
Signature · 1 line
2.52.0
#2 lore raw

PATCH 2/7 target/alpha: Build system units in common source set

In reply to Philippe Mathieu-Daudé

Since commits bb5de52524c ("target: Widen pc/cs_base in cpu_get_tb_cpu_state") and 32f0c394bbf ("target: Use vaddr in gen_intermediate_code") we remove all uses of the target_ulong type in target/alpha/. Use the meson target_common_system_arch[] source set to prevent further uses of target-specific types.

---
 target/alpha/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/alpha/meson.build +1 -1
index 7dbbd557171..9447f8020be 100644
@@ -18,4 +18,4 @@ alpha_system_ss.add(files(
 ))
 
 target_arch += {'alpha': alpha_ss}
-target_system_arch += {'alpha': alpha_system_ss}
+target_common_system_arch += {'alpha': alpha_system_ss}
Signature · 1 line
2.52.0
#3 lore raw

PATCH 3/7 target/alpha: Replace target_ulong -> uint64_t in gdb_write_register()

In reply to Philippe Mathieu-Daudé

On Alpha, the target_ulong type expands to uint64_t. Besides, ldq_be_p() returns a uint64_t type, and all field / values accessed are uint64_t, see target/alpha/cpu.h:

  200 typedef struct CPUArchState {
  201     uint64_t ir[31];
  202     float64 fir[31];
  203     uint64_t pc;
  204     uint64_t unique;
  ...
  443 void cpu_alpha_store_fpcr (CPUAlphaState *env, uint64_t val);
  445 void cpu_alpha_store_gr(CPUAlphaState *env, unsigned reg, uint64_t val);

Use uint64_t instead of target_ulong.

---
 target/alpha/gdbstub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/alpha/gdbstub.c +1 -1
index 1a7e2dd9202..a7110e8d1eb 100644
@@ -59,7 +59,7 @@ int alpha_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
 int alpha_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
 {
     CPUAlphaState *env = cpu_env(cs);
-    target_ulong tmp = ldq_le_p(mem_buf);
+    uint64_t tmp = ldq_le_p(mem_buf);
     CPU_DoubleU d;
 
     switch (n) {
Signature · 1 line
2.52.0
#4 lore raw

PATCH 4/7 target/alpha: Do not use target_ulong for trap arguments

In reply to Philippe Mathieu-Daudé

%mmcsr and %cause are filled with @trap_arg1 / @trap_arg2, both declared as uint64_t in target/alpha/cpu.h:

    229     uint64_t trap_arg1;
    230     uint64_t trap_arg2;
    ...

Use uint64_t instead of target_ulong.

---
 target/alpha/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/alpha/helper.c +1 -1
index 126a53c829b..2dc52cc4465 100644
@@ -129,7 +129,7 @@ void alpha_cpu_record_sigsegv(CPUState *cs, vaddr address,
                               bool maperr, uintptr_t retaddr)
 {
     CPUAlphaState *env = cpu_env(cs);
-    target_ulong mmcsr, cause;
+    uint64_t mmcsr, cause;
 
     /* Assuming !maperr, infer the missing protection. */
     switch (access_type) {
Signature · 1 line
2.52.0
#5 lore raw

PATCH 5/7 target/alpha: Do not use target_ulong for page table entries / indexes

In reply to Philippe Mathieu-Daudé

%L[123]pte are loaded calling ldq_le_phys() which returns a uint64_t. %pt is loaded with @ptbr, declared as uint64_t in target/alpha/cpu.h:

236 uint64_t ptbr;

%index is at most 1024 so can fit in uint16_t.

---
 target/alpha/helper.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target/alpha/helper.c +3 -2
index 2dc52cc4465..d6200d101cc 100644
@@ -173,8 +173,9 @@ static int get_physical_address(CPUAlphaState *env, target_ulong addr,
     CPUState *cs = env_cpu(env);
     target_long saddr = addr;
     target_ulong phys = 0;
-    target_ulong L1pte, L2pte, L3pte;
-    target_ulong pt, index;
+    uint64_t L1pte, L2pte, L3pte;
+    uint64_t pt;
+    uint16_t index;
     int prot = 0;
     int ret = MM_K_ACV;
     MemTxResult txres;
Signature · 1 line
2.52.0
#6 lore raw

PATCH 6/7 target/alpha: Remove target_ulong uses in get_physical_address()

In reply to Philippe Mathieu-Daudé

%addr is a virtual address, so use the 'vaddr' type. %pphys is a pointer to a physical address, so use the 'hwaddr' type.

---
 target/alpha/helper.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
target/alpha/helper.c +5 -5
index d6200d101cc..179dc2dc7ae 100644
@@ -165,14 +165,14 @@ void alpha_cpu_record_sigsegv(CPUState *cs, vaddr address,
 }
 #else
 /* Returns the OSF/1 entMM failure indication, or -1 on success.  */
-static int get_physical_address(CPUAlphaState *env, target_ulong addr,
+static int get_physical_address(CPUAlphaState *env, vaddr addr,
                                 int prot_need, int mmu_idx,
-                                target_ulong *pphys, int *pprot)
+                                hwaddr *pphys, int *pprot)
 {
     const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
     CPUState *cs = env_cpu(env);
     target_long saddr = addr;
-    target_ulong phys = 0;
+    hwaddr phys = 0;
     uint64_t L1pte, L2pte, L3pte;
     uint64_t pt;
     uint16_t index;
@@ -297,7 +297,7 @@ static int get_physical_address(CPUAlphaState *env, target_ulong addr,
 
 hwaddr alpha_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
 {
-    target_ulong phys;
+    hwaddr phys;
     int prot, fail;
 
     fail = get_physical_address(cpu_env(cs), addr, 0, 0, &phys, &prot);
@@ -309,7 +309,7 @@ bool alpha_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,
                         bool probe, uintptr_t retaddr)
 {
     CPUAlphaState *env = cpu_env(cs);
-    target_ulong phys;
+    hwaddr phys;
     int prot, fail;
 
     fail = get_physical_address(env, addr, 1 << access_type,
Signature · 1 line
2.52.0
#7 lore raw

PATCH 7/7 target/alpha: Expand TCGv type for 64-bit target

In reply to Philippe Mathieu-Daudé

The Alpha targets are only built as 64-bit:

  $ git grep TARGET_LONG_BITS configs/targets/alpha-*
  configs/targets/alpha-linux-user.mak:4:TARGET_LONG_BITS=64
  configs/targets/alpha-softmmu.mak:2:TARGET_LONG_BITS=64

Replace:

TCGv -> TCGv_i64
tcg_temp_new -> tcg_temp_new_i64

This is a mechanical replacement, adapting style to pass the checkpatch.pl script.

---
 target/alpha/translate.c | 228 ++++++++++++++++++++-------------------
 1 file changed, 116 insertions(+), 112 deletions(-)
target/alpha/translate.c +116 -112
index 48ac50a7cdf..4442462891e 100644
@@ -65,11 +65,11 @@ struct DisasContext {
     int tb_ftz;
 
     /* The set of registers active in the current context.  */
-    TCGv *ir;
+    TCGv_i64 *ir;
 
     /* Temporaries for $31 and $f31 as source and destination.  */
-    TCGv zero;
-    TCGv sink;
+    TCGv_i64 zero;
+    TCGv_i64 sink;
 };
 
 #ifdef CONFIG_USER_ONLY
@@ -86,21 +86,21 @@ struct DisasContext {
 #define DISAS_PC_STALE            DISAS_TARGET_2
 
 /* global register indexes */
-static TCGv cpu_std_ir[31];
-static TCGv cpu_fir[31];
-static TCGv cpu_pc;
-static TCGv cpu_lock_addr;
-static TCGv cpu_lock_value;
+static TCGv_i64 cpu_std_ir[31];
+static TCGv_i64 cpu_fir[31];
+static TCGv_i64 cpu_pc;
+static TCGv_i64 cpu_lock_addr;
+static TCGv_i64 cpu_lock_value;
 
 #ifndef CONFIG_USER_ONLY
-static TCGv cpu_pal_ir[31];
+static TCGv_i64 cpu_pal_ir[31];
 #endif
 
 void alpha_translate_init(void)
 {
 #define DEF_VAR(V)  { &cpu_##V, #V, offsetof(CPUAlphaState, V) }
 
-    typedef struct { TCGv *var; const char *name; int ofs; } GlobalVar;
+    typedef struct { TCGv_i64 *var; const char *name; int ofs; } GlobalVar;
     static const GlobalVar vars[] = {
         DEF_VAR(pc),
         DEF_VAR(lock_addr),
@@ -160,7 +160,7 @@ void alpha_translate_init(void)
     }
 }
 
-static TCGv load_zero(DisasContext *ctx)
+static TCGv_i64 load_zero(DisasContext *ctx)
 {
     if (!ctx->zero) {
         ctx->zero = tcg_constant_i64(0);
@@ -168,10 +168,10 @@ static TCGv load_zero(DisasContext *ctx)
     return ctx->zero;
 }
 
-static TCGv dest_sink(DisasContext *ctx)
+static TCGv_i64 dest_sink(DisasContext *ctx)
 {
     if (!ctx->sink) {
-        ctx->sink = tcg_temp_new();
+        ctx->sink = tcg_temp_new_i64();
     }
     return ctx->sink;
 }
@@ -184,7 +184,7 @@ static void free_context_temps(DisasContext *ctx)
     }
 }
 
-static TCGv load_gpr(DisasContext *ctx, unsigned reg)
+static TCGv_i64 load_gpr(DisasContext *ctx, unsigned reg)
 {
     if (likely(reg < 31)) {
         return ctx->ir[reg];
@@ -193,7 +193,7 @@ static TCGv load_gpr(DisasContext *ctx, unsigned reg)
     }
 }
 
-static TCGv load_gpr_lit(DisasContext *ctx, unsigned reg,
+static TCGv_i64 load_gpr_lit(DisasContext *ctx, unsigned reg,
                          uint8_t lit, bool islit)
 {
     if (islit) {
@@ -205,7 +205,7 @@ static TCGv load_gpr_lit(DisasContext *ctx, unsigned reg,
     }
 }
 
-static TCGv dest_gpr(DisasContext *ctx, unsigned reg)
+static TCGv_i64 dest_gpr(DisasContext *ctx, unsigned reg)
 {
     if (likely(reg < 31)) {
         return ctx->ir[reg];
@@ -214,7 +214,7 @@ static TCGv dest_gpr(DisasContext *ctx, unsigned reg)
     }
 }
 
-static TCGv load_fpr(DisasContext *ctx, unsigned reg)
+static TCGv_i64 load_fpr(DisasContext *ctx, unsigned reg)
 {
     if (likely(reg < 31)) {
         return cpu_fir[reg];
@@ -223,7 +223,7 @@ static TCGv load_fpr(DisasContext *ctx, unsigned reg)
     }
 }
 
-static TCGv dest_fpr(DisasContext *ctx, unsigned reg)
+static TCGv_i64 dest_fpr(DisasContext *ctx, unsigned reg)
 {
     if (likely(reg < 31)) {
         return cpu_fir[reg];
@@ -243,17 +243,17 @@ static int get_flag_ofs(unsigned shift)
     return ofs;
 }
 
-static void ld_flag_byte(TCGv val, unsigned shift)
+static void ld_flag_byte(TCGv_i64 val, unsigned shift)
 {
     tcg_gen_ld8u_i64(val, tcg_env, get_flag_ofs(shift));
 }
 
-static void st_flag_byte(TCGv val, unsigned shift)
+static void st_flag_byte(TCGv_i64 val, unsigned shift)
 {
     tcg_gen_st8_i64(val, tcg_env, get_flag_ofs(shift));
 }
 
-static void gen_pc_disp(DisasContext *ctx, TCGv dest, int32_t disp)
+static void gen_pc_disp(DisasContext *ctx, TCGv_i64 dest, int32_t disp)
 {
     uint64_t addr = ctx->base.pc_next + disp;
     if (ctx->pcrel) {
@@ -284,38 +284,38 @@ static inline DisasJumpType gen_invalid(DisasContext *ctx)
     return gen_excp(ctx, EXCP_OPCDEC, 0);
 }
 
-static void gen_ldf(DisasContext *ctx, TCGv dest, TCGv addr)
+static void gen_ldf(DisasContext *ctx, TCGv_i64 dest, TCGv_i64 addr)
 {
     TCGv_i32 tmp32 = tcg_temp_new_i32();
     tcg_gen_qemu_ld_i32(tmp32, addr, ctx->mem_idx, MO_LEUL | UNALIGN(ctx));
     gen_helper_memory_to_f(dest, tmp32);
 }
 
-static void gen_ldg(DisasContext *ctx, TCGv dest, TCGv addr)
+static void gen_ldg(DisasContext *ctx, TCGv_i64 dest, TCGv_i64 addr)
 {
-    TCGv tmp = tcg_temp_new();
+    TCGv_i64 tmp = tcg_temp_new_i64();
     tcg_gen_qemu_ld_i64(tmp, addr, ctx->mem_idx, MO_LEUQ | UNALIGN(ctx));
     gen_helper_memory_to_g(dest, tmp);
 }
 
-static void gen_lds(DisasContext *ctx, TCGv dest, TCGv addr)
+static void gen_lds(DisasContext *ctx, TCGv_i64 dest, TCGv_i64 addr)
 {
     TCGv_i32 tmp32 = tcg_temp_new_i32();
     tcg_gen_qemu_ld_i32(tmp32, addr, ctx->mem_idx, MO_LEUL | UNALIGN(ctx));
     gen_helper_memory_to_s(dest, tmp32);
 }
 
-static void gen_ldt(DisasContext *ctx, TCGv dest, TCGv addr)
+static void gen_ldt(DisasContext *ctx, TCGv_i64 dest, TCGv_i64 addr)
 {
     tcg_gen_qemu_ld_i64(dest, addr, ctx->mem_idx, MO_LEUQ | UNALIGN(ctx));
 }
 
 static void gen_load_fp(DisasContext *ctx, int ra, int rb, int32_t disp16,
-                        void (*func)(DisasContext *, TCGv, TCGv))
+                        void (*func)(DisasContext *, TCGv_i64, TCGv_i64))
 {
     /* Loads to $f31 are prefetches, which we can treat as nops. */
     if (likely(ra != 31)) {
-        TCGv addr = tcg_temp_new();
+        TCGv_i64 addr = tcg_temp_new_i64();
         tcg_gen_addi_i64(addr, load_gpr(ctx, rb), disp16);
         func(ctx, cpu_fir[ra], addr);
     }
@@ -324,7 +324,7 @@ static void gen_load_fp(DisasContext *ctx, int ra, int rb, int32_t disp16,
 static void gen_load_int(DisasContext *ctx, int ra, int rb, int32_t disp16,
                          MemOp op, bool clear, bool locked)
 {
-    TCGv addr, dest;
+    TCGv_i64 addr, dest;
 
     /* LDQ_U with ra $31 is UNOP.  Other various loads are forms of
        prefetches, which we can treat as nops.  No worries about
@@ -333,7 +333,7 @@ static void gen_load_int(DisasContext *ctx, int ra, int rb, int32_t disp16,
         return;
     }
 
-    addr = tcg_temp_new();
+    addr = tcg_temp_new_i64();
     tcg_gen_addi_i64(addr, load_gpr(ctx, rb), disp16);
     if (clear) {
         tcg_gen_andi_i64(addr, addr, ~0x7);
@@ -350,36 +350,36 @@ static void gen_load_int(DisasContext *ctx, int ra, int rb, int32_t disp16,
     }
 }
 
-static void gen_stf(DisasContext *ctx, TCGv src, TCGv addr)
+static void gen_stf(DisasContext *ctx, TCGv_i64 src, TCGv_i64 addr)
 {
     TCGv_i32 tmp32 = tcg_temp_new_i32();
     gen_helper_f_to_memory(tmp32, addr);
     tcg_gen_qemu_st_i32(tmp32, addr, ctx->mem_idx, MO_LEUL | UNALIGN(ctx));
 }
 
-static void gen_stg(DisasContext *ctx, TCGv src, TCGv addr)
+static void gen_stg(DisasContext *ctx, TCGv_i64 src, TCGv_i64 addr)
 {
-    TCGv tmp = tcg_temp_new();
+    TCGv_i64 tmp = tcg_temp_new_i64();
     gen_helper_g_to_memory(tmp, src);
     tcg_gen_qemu_st_i64(tmp, addr, ctx->mem_idx, MO_LEUQ | UNALIGN(ctx));
 }
 
-static void gen_sts(DisasContext *ctx, TCGv src, TCGv addr)
+static void gen_sts(DisasContext *ctx, TCGv_i64 src, TCGv_i64 addr)
 {
     TCGv_i32 tmp32 = tcg_temp_new_i32();
     gen_helper_s_to_memory(tmp32, src);
     tcg_gen_qemu_st_i32(tmp32, addr, ctx->mem_idx, MO_LEUL | UNALIGN(ctx));
 }
 
-static void gen_stt(DisasContext *ctx, TCGv src, TCGv addr)
+static void gen_stt(DisasContext *ctx, TCGv_i64 src, TCGv_i64 addr)
 {
     tcg_gen_qemu_st_i64(src, addr, ctx->mem_idx, MO_LEUQ | UNALIGN(ctx));
 }
 
 static void gen_store_fp(DisasContext *ctx, int ra, int rb, int32_t disp16,
-                         void (*func)(DisasContext *, TCGv, TCGv))
+                         void (*func)(DisasContext *, TCGv_i64, TCGv_i64))
 {
-    TCGv addr = tcg_temp_new();
+    TCGv_i64 addr = tcg_temp_new_i64();
     tcg_gen_addi_i64(addr, load_gpr(ctx, rb), disp16);
     func(ctx, load_fpr(ctx, ra), addr);
 }
@@ -387,9 +387,9 @@ static void gen_store_fp(DisasContext *ctx, int ra, int rb, int32_t disp16,
 static void gen_store_int(DisasContext *ctx, int ra, int rb, int32_t disp16,
                           MemOp op, bool clear)
 {
-    TCGv addr, src;
+    TCGv_i64 addr, src;
 
-    addr = tcg_temp_new();
+    addr = tcg_temp_new_i64();
     tcg_gen_addi_i64(addr, load_gpr(ctx, rb), disp16);
     if (clear) {
         tcg_gen_andi_i64(addr, addr, ~0x7);
@@ -406,7 +406,7 @@ static DisasJumpType gen_store_conditional(DisasContext *ctx, int ra, int rb,
                                            MemOp op)
 {
     TCGLabel *lab_fail, *lab_done;
-    TCGv addr, val;
+    TCGv_i64 addr, val;
 
     addr = tcg_temp_new_i64();
     tcg_gen_addi_i64(addr, load_gpr(ctx, rb), disp16);
@@ -469,7 +469,8 @@ static DisasJumpType gen_bdirect(DisasContext *ctx, int ra, int32_t disp)
 }
 
 static DisasJumpType gen_bcond_internal(DisasContext *ctx, TCGCond cond,
-                                        TCGv cmp, uint64_t imm, int32_t disp)
+                                        TCGv_i64 cmp,
+                                        uint64_t imm, int32_t disp)
 {
     TCGLabel *lab_true = gen_new_label();
 
@@ -616,9 +617,9 @@ static void gen_qual_flushzero(DisasContext *ctx, int fn11)
 #endif
 }
 
-static TCGv gen_ieee_input(DisasContext *ctx, int reg, int fn11, int is_cmp)
+static TCGv_i64 gen_ieee_input(DisasContext *ctx, int reg, int fn11, int is_cmp)
 {
-    TCGv val;
+    TCGv_i64 val;
 
     if (unlikely(reg == 31)) {
         val = load_zero(ctx);
@@ -674,9 +675,9 @@ static void gen_fp_exc_raise(int rc, int fn11)
     }
 }
 
-static void gen_cvtlq(TCGv vc, TCGv vb)
+static void gen_cvtlq(TCGv_i64 vc, TCGv_i64 vb)
 {
-    TCGv tmp = tcg_temp_new();
+    TCGv_i64 tmp = tcg_temp_new_i64();
 
     /* The arithmetic right shift here, plus the sign-extended mask below
        yields a sign-extended result without an explicit ext32s_i64.  */
@@ -686,10 +687,10 @@ static void gen_cvtlq(TCGv vc, TCGv vb)
 }
 
 static void gen_ieee_arith2(DisasContext *ctx,
-                            void (*helper)(TCGv, TCGv_ptr, TCGv),
+                            void (*helper)(TCGv_i64, TCGv_ptr, TCGv_i64),
                             int rb, int rc, int fn11)
 {
-    TCGv vb;
+    TCGv_i64 vb;
 
     gen_qual_roundmode(ctx, fn11);
     gen_qual_flushzero(ctx, fn11);
@@ -713,7 +714,7 @@ IEEE_ARITH2(cvtts)
 
 static void gen_cvttq(DisasContext *ctx, int rb, int rc, int fn11)
 {
-    TCGv vb, vc;
+    TCGv_i64 vb, vc;
 
     /* No need to set flushzero, since we have an integer output.  */
     vb = gen_ieee_input(ctx, rb, fn11, 0);
@@ -731,10 +732,10 @@ static void gen_cvttq(DisasContext *ctx, int rb, int rc, int fn11)
 }
 
 static void gen_ieee_intcvt(DisasContext *ctx,
-                            void (*helper)(TCGv, TCGv_ptr, TCGv),
+                            void (*helper)(TCGv_i64, TCGv_ptr, TCGv_i64),
                             int rb, int rc, int fn11)
 {
-    TCGv vb, vc;
+    TCGv_i64 vb, vc;
 
     gen_qual_roundmode(ctx, fn11);
     vb = load_fpr(ctx, rb);
@@ -760,10 +761,11 @@ static inline void glue(gen_, name)(DisasContext *ctx,          \
 IEEE_INTCVT(cvtqs)
 IEEE_INTCVT(cvtqt)
 
-static void gen_cpy_mask(TCGv vc, TCGv va, TCGv vb, bool inv_a, uint64_t mask)
+static void gen_cpy_mask(TCGv_i64 vc, TCGv_i64 va, TCGv_i64 vb,
+                         bool inv_a, uint64_t mask)
 {
-    TCGv vmask = tcg_constant_i64(mask);
-    TCGv tmp = tcg_temp_new_i64();
+    TCGv_i64 vmask = tcg_constant_i64(mask);
+    TCGv_i64 tmp = tcg_temp_new_i64();
 
     if (inv_a) {
         tcg_gen_andc_i64(tmp, vmask, va);
@@ -776,10 +778,11 @@ static void gen_cpy_mask(TCGv vc, TCGv va, TCGv vb, bool inv_a, uint64_t mask)
 }
 
 static void gen_ieee_arith3(DisasContext *ctx,
-                            void (*helper)(TCGv, TCGv_ptr, TCGv, TCGv),
+                            void (*helper)(TCGv_i64, TCGv_ptr,
+                                           TCGv_i64, TCGv_i64),
                             int ra, int rb, int rc, int fn11)
 {
-    TCGv va, vb, vc;
+    TCGv_i64 va, vb, vc;
 
     gen_qual_roundmode(ctx, fn11);
     gen_qual_flushzero(ctx, fn11);
@@ -808,10 +811,11 @@ IEEE_ARITH3(mult)
 IEEE_ARITH3(divt)
 
 static void gen_ieee_compare(DisasContext *ctx,
-                             void (*helper)(TCGv, TCGv_ptr, TCGv, TCGv),
+                             void (*helper)(TCGv_i64, TCGv_ptr,
+                                            TCGv_i64, TCGv_i64),
                              int ra, int rb, int rc, int fn11)
 {
-    TCGv va, vb, vc;
+    TCGv_i64 va, vb, vc;
 
     va = gen_ieee_input(ctx, ra, fn11, 1);
     vb = gen_ieee_input(ctx, rb, fn11, 1);
@@ -848,7 +852,7 @@ static inline uint64_t zapnot_mask(uint8_t lit)
 /* Implement zapnot with an immediate operand, which expands to some
    form of immediate AND.  This is a basic building block in the
    definition of many of the other byte manipulation instructions.  */
-static void gen_zapnoti(TCGv dest, TCGv src, uint8_t lit)
+static void gen_zapnoti(TCGv_i64 dest, TCGv_i64 src, uint8_t lit)
 {
     switch (lit) {
     case 0x00:
@@ -873,8 +877,8 @@ static void gen_zapnoti(TCGv dest, TCGv src, uint8_t lit)
 }
 
 /* EXTWH, EXTLH, EXTQH */
-static void gen_ext_h(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
-                      uint8_t lit, uint8_t byte_mask)
+static void gen_ext_h(DisasContext *ctx, TCGv_i64 vc, TCGv_i64 va,
+                      int rb, bool islit, uint8_t lit, uint8_t byte_mask)
 {
     if (islit) {
         int pos = (64 - lit * 8) & 0x3f;
@@ -885,7 +889,7 @@ static void gen_ext_h(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
             tcg_gen_movi_i64(vc, 0);
         }
     } else {
-        TCGv tmp = tcg_temp_new();
+        TCGv_i64 tmp = tcg_temp_new_i64();
         tcg_gen_shli_i64(tmp, load_gpr(ctx, rb), 3);
         tcg_gen_neg_i64(tmp, tmp);
         tcg_gen_andi_i64(tmp, tmp, 0x3f);
@@ -895,8 +899,8 @@ static void gen_ext_h(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
 }
 
 /* EXTBL, EXTWL, EXTLL, EXTQL */
-static void gen_ext_l(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
-                      uint8_t lit, uint8_t byte_mask)
+static void gen_ext_l(DisasContext *ctx, TCGv_i64 vc, TCGv_i64 va,
+                      int rb, bool islit, uint8_t lit, uint8_t byte_mask)
 {
     if (islit) {
         int pos = (lit & 7) * 8;
@@ -906,7 +910,7 @@ static void gen_ext_l(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
         }
         tcg_gen_extract_i64(vc, va, pos, len);
     } else {
-        TCGv tmp = tcg_temp_new();
+        TCGv_i64 tmp = tcg_temp_new_i64();
         tcg_gen_andi_i64(tmp, load_gpr(ctx, rb), 7);
         tcg_gen_shli_i64(tmp, tmp, 3);
         tcg_gen_shr_i64(vc, va, tmp);
@@ -915,8 +919,8 @@ static void gen_ext_l(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
 }
 
 /* INSWH, INSLH, INSQH */
-static void gen_ins_h(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
-                      uint8_t lit, uint8_t byte_mask)
+static void gen_ins_h(DisasContext *ctx, TCGv_i64 vc, TCGv_i64 va,
+                      int rb, bool islit, uint8_t lit, uint8_t byte_mask)
 {
     if (islit) {
         int pos = 64 - (lit & 7) * 8;
@@ -927,8 +931,8 @@ static void gen_ins_h(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
             tcg_gen_movi_i64(vc, 0);
         }
     } else {
-        TCGv tmp = tcg_temp_new();
-        TCGv shift = tcg_temp_new();
+        TCGv_i64 tmp = tcg_temp_new_i64();
+        TCGv_i64 shift = tcg_temp_new_i64();
 
         /* The instruction description has us left-shift the byte mask
            and extract bits <15:8> and apply that zap at the end.  This
@@ -951,8 +955,8 @@ static void gen_ins_h(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
 }
 
 /* INSBL, INSWL, INSLL, INSQL */
-static void gen_ins_l(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
-                      uint8_t lit, uint8_t byte_mask)
+static void gen_ins_l(DisasContext *ctx, TCGv_i64 vc, TCGv_i64 va,
+                      int rb, bool islit, uint8_t lit, uint8_t byte_mask)
 {
     if (islit) {
         int pos = (lit & 7) * 8;
@@ -962,8 +966,8 @@ static void gen_ins_l(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
         }
         tcg_gen_deposit_z_i64(vc, va, pos, len);
     } else {
-        TCGv tmp = tcg_temp_new();
-        TCGv shift = tcg_temp_new();
+        TCGv_i64 tmp = tcg_temp_new_i64();
+        TCGv_i64 shift = tcg_temp_new_i64();
 
         /* The instruction description has us left-shift the byte mask
            and extract bits <15:8> and apply that zap at the end.  This
@@ -978,14 +982,14 @@ static void gen_ins_l(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
 }
 
 /* MSKWH, MSKLH, MSKQH */
-static void gen_msk_h(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
-                      uint8_t lit, uint8_t byte_mask)
+static void gen_msk_h(DisasContext *ctx, TCGv_i64 vc, TCGv_i64 va,
+                      int rb, bool islit, uint8_t lit, uint8_t byte_mask)
 {
     if (islit) {
         gen_zapnoti(vc, va, ~((byte_mask << (lit & 7)) >> 8));
     } else {
-        TCGv shift = tcg_temp_new();
-        TCGv mask = tcg_temp_new();
+        TCGv_i64 shift = tcg_temp_new_i64();
+        TCGv_i64 mask = tcg_temp_new_i64();
 
         /* The instruction description is as above, where the byte_mask
            is shifted left, and then we extract bits <15:8>.  This can be
@@ -1008,14 +1012,14 @@ static void gen_msk_h(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
 }
 
 /* MSKBL, MSKWL, MSKLL, MSKQL */
-static void gen_msk_l(DisasContext *ctx, TCGv vc, TCGv va, int rb, bool islit,
-                      uint8_t lit, uint8_t byte_mask)
+static void gen_msk_l(DisasContext *ctx, TCGv_i64 vc, TCGv_i64 va,
+                      int rb, bool islit, uint8_t lit, uint8_t byte_mask)
 {
     if (islit) {
         gen_zapnoti(vc, va, ~(byte_mask << (lit & 7)));
     } else {
-        TCGv shift = tcg_temp_new();
-        TCGv mask = tcg_temp_new();
+        TCGv_i64 shift = tcg_temp_new_i64();
+        TCGv_i64 mask = tcg_temp_new_i64();
 
         tcg_gen_andi_i64(shift, load_gpr(ctx, rb), 7);
         tcg_gen_shli_i64(shift, shift, 3);
@@ -1100,7 +1104,7 @@ static DisasJumpType gen_call_pal(DisasContext *ctx, int palcode)
 
             /* But make sure and store only the 3 IPL bits from the user.  */
             {
-                TCGv tmp = tcg_temp_new();
+                TCGv_i64 tmp = tcg_temp_new_i64();
                 tcg_gen_andi_i64(tmp, ctx->ir[IR_A0], PS_INT_MASK);
                 st_flag_byte(tmp, ENV_FLAG_PS_SHIFT);
             }
@@ -1151,7 +1155,7 @@ static DisasJumpType gen_call_pal(DisasContext *ctx, int palcode)
     return gen_excp(ctx, EXCP_CALL_PAL, palcode);
 #else
     {
-        TCGv tmp = tcg_temp_new();
+        TCGv_i64 tmp = tcg_temp_new_i64();
 
         gen_pc_disp(ctx, tmp, 0);
         if (ctx->tbflags & ENV_FLAG_PAL_MODE) {
@@ -1199,9 +1203,9 @@ static int cpu_pr_data(int pr)
     return 0;
 }
 
-static DisasJumpType gen_mfpr(DisasContext *ctx, TCGv va, int regno)
+static DisasJumpType gen_mfpr(DisasContext *ctx, TCGv_i64 va, int regno)
 {
-    void (*helper)(TCGv);
+    void (*helper)(TCGv_i64);
     int data;
 
     switch (regno) {
@@ -1249,7 +1253,7 @@ static DisasJumpType gen_mfpr(DisasContext *ctx, TCGv va, int regno)
     return DISAS_NEXT;
 }
 
-static DisasJumpType gen_mtpr(DisasContext *ctx, TCGv vb, int regno)
+static DisasJumpType gen_mtpr(DisasContext *ctx, TCGv_i64 vb, int regno)
 {
     int data;
     DisasJumpType ret = DISAS_NEXT;
@@ -1361,7 +1365,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
     uint16_t fn11;
     uint8_t opc, ra, rb, rc, fpfn, fn7, lit;
     bool islit, real_islit;
-    TCGv va, vb, vc, tmp, tmp2;
+    TCGv_i64 va, vb, vc, tmp, tmp2;
     TCGv_i32 t32;
     DisasJumpType ret;
 
@@ -1484,7 +1488,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             break;
         case 0x02:
             /* S4ADDL */
-            tmp = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
             tcg_gen_shli_i64(tmp, va, 2);
             tcg_gen_add_i64(tmp, tmp, vb);
             tcg_gen_ext32s_i64(vc, tmp);
@@ -1496,7 +1500,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             break;
         case 0x0B:
             /* S4SUBL */
-            tmp = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
             tcg_gen_shli_i64(tmp, va, 2);
             tcg_gen_sub_i64(tmp, tmp, vb);
             tcg_gen_ext32s_i64(vc, tmp);
@@ -1512,14 +1516,14 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             break;
         case 0x12:
             /* S8ADDL */
-            tmp = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
             tcg_gen_shli_i64(tmp, va, 3);
             tcg_gen_add_i64(tmp, tmp, vb);
             tcg_gen_ext32s_i64(vc, tmp);
             break;
         case 0x1B:
             /* S8SUBL */
-            tmp = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
             tcg_gen_shli_i64(tmp, va, 3);
             tcg_gen_sub_i64(tmp, tmp, vb);
             tcg_gen_ext32s_i64(vc, tmp);
@@ -1534,7 +1538,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             break;
         case 0x22:
             /* S4ADDQ */
-            tmp = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
             tcg_gen_shli_i64(tmp, va, 2);
             tcg_gen_add_i64(vc, tmp, vb);
             break;
@@ -1544,7 +1548,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             break;
         case 0x2B:
             /* S4SUBQ */
-            tmp = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
             tcg_gen_shli_i64(tmp, va, 2);
             tcg_gen_sub_i64(vc, tmp, vb);
             break;
@@ -1554,13 +1558,13 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             break;
         case 0x32:
             /* S8ADDQ */
-            tmp = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
             tcg_gen_shli_i64(tmp, va, 3);
             tcg_gen_add_i64(vc, tmp, vb);
             break;
         case 0x3B:
             /* S8SUBQ */
-            tmp = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
             tcg_gen_shli_i64(tmp, va, 3);
             tcg_gen_sub_i64(vc, tmp, vb);
             break;
@@ -1570,7 +1574,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             break;
         case 0x40:
             /* ADDL/V */
-            tmp = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
             tcg_gen_ext32s_i64(tmp, va);
             tcg_gen_ext32s_i64(vc, vb);
             tcg_gen_add_i64(tmp, tmp, vc);
@@ -1579,7 +1583,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             break;
         case 0x49:
             /* SUBL/V */
-            tmp = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
             tcg_gen_ext32s_i64(tmp, va);
             tcg_gen_ext32s_i64(vc, vb);
             tcg_gen_sub_i64(tmp, tmp, vc);
@@ -1592,8 +1596,8 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             break;
         case 0x60:
             /* ADDQ/V */
-            tmp = tcg_temp_new();
-            tmp2 = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
+            tmp2 = tcg_temp_new_i64();
             tcg_gen_eqv_i64(tmp, va, vb);
             tcg_gen_mov_i64(tmp2, va);
             tcg_gen_add_i64(vc, va, vb);
@@ -1605,8 +1609,8 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             break;
         case 0x69:
             /* SUBQ/V */
-            tmp = tcg_temp_new();
-            tmp2 = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
+            tmp2 = tcg_temp_new_i64();
             tcg_gen_xor_i64(tmp, va, vb);
             tcg_gen_mov_i64(tmp2, va);
             tcg_gen_sub_i64(vc, va, vb);
@@ -1798,7 +1802,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             if (islit) {
                 tcg_gen_shri_i64(vc, va, lit & 0x3f);
             } else {
-                tmp = tcg_temp_new();
+                tmp = tcg_temp_new_i64();
                 vb = load_gpr(ctx, rb);
                 tcg_gen_andi_i64(tmp, vb, 0x3f);
                 tcg_gen_shr_i64(vc, va, tmp);
@@ -1813,7 +1817,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             if (islit) {
                 tcg_gen_shli_i64(vc, va, lit & 0x3f);
             } else {
-                tmp = tcg_temp_new();
+                tmp = tcg_temp_new_i64();
                 vb = load_gpr(ctx, rb);
                 tcg_gen_andi_i64(tmp, vb, 0x3f);
                 tcg_gen_shl_i64(vc, va, tmp);
@@ -1828,7 +1832,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             if (islit) {
                 tcg_gen_sari_i64(vc, va, lit & 0x3f);
             } else {
-                tmp = tcg_temp_new();
+                tmp = tcg_temp_new_i64();
                 vb = load_gpr(ctx, rb);
                 tcg_gen_andi_i64(tmp, vb, 0x3f);
                 tcg_gen_sar_i64(vc, va, tmp);
@@ -1891,12 +1895,12 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             break;
         case 0x30:
             /* UMULH */
-            tmp = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
             tcg_gen_mulu2_i64(tmp, vc, va, vb);
             break;
         case 0x40:
             /* MULL/V */
-            tmp = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
             tcg_gen_ext32s_i64(tmp, va);
             tcg_gen_ext32s_i64(vc, vb);
             tcg_gen_mul_i64(tmp, tmp, vc);
@@ -1905,8 +1909,8 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
             break;
         case 0x60:
             /* MULQ/V */
-            tmp = tcg_temp_new();
-            tmp2 = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
+            tmp2 = tcg_temp_new_i64();
             tcg_gen_muls2_i64(vc, tmp, va, vb);
             tcg_gen_sari_i64(tmp2, vc, 63);
             gen_helper_check_overflow(tcg_env, tmp, tmp2);
@@ -2351,7 +2355,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
            prediction stack action, which of course we don't implement.  */
         vb = load_gpr(ctx, rb);
         if (ra != 31) {
-            tmp = tcg_temp_new();
+            tmp = tcg_temp_new_i64();
             tcg_gen_andi_i64(tmp, vb, ~3);
             gen_pc_disp(ctx, ctx->ir[ra], 0);
             tcg_gen_mov_i64(cpu_pc, tmp);
@@ -2366,7 +2370,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
 #ifndef CONFIG_USER_ONLY
         REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
         {
-            TCGv addr = tcg_temp_new();
+            TCGv_i64 addr = tcg_temp_new_i64();
             vb = load_gpr(ctx, rb);
             va = dest_gpr(ctx, ra);
 
@@ -2615,7 +2619,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
         }
         tcg_gen_movi_i64(cpu_lock_addr, -1);
         st_flag_byte(load_zero(ctx), ENV_FLAG_RX_SHIFT);
-        tmp = tcg_temp_new();
+        tmp = tcg_temp_new_i64();
         tcg_gen_andi_i64(tmp, vb, 1);
         st_flag_byte(tmp, ENV_FLAG_PAL_SHIFT);
         tcg_gen_andi_i64(cpu_pc, vb, ~3);
@@ -2636,7 +2640,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
                 /* Longword physical access */
                 va = load_gpr(ctx, ra);
                 vb = load_gpr(ctx, rb);
-                tmp = tcg_temp_new();
+                tmp = tcg_temp_new_i64();
                 tcg_gen_addi_i64(tmp, vb, disp12);
                 tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LESL | MO_ALIGN);
                 break;
@@ -2644,7 +2648,7 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
                 /* Quadword physical access */
                 va = load_gpr(ctx, ra);
                 vb = load_gpr(ctx, rb);
-                tmp = tcg_temp_new();
+                tmp = tcg_temp_new_i64();
                 tcg_gen_addi_i64(tmp, vb, disp12);
                 tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LEUQ | MO_ALIGN);
                 break;
Signature · 1 line
2.52.0
#8 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 6 lines · Philippe Mathieu-Daudé

Replace target_ulong -> uint64_t / vaddr / hwaddr
and TCGv -> TCGv_i64.

Philippe Mathieu-Daudé (7):
target/alpha: Avoid target-specific migration headers in machine.c target/alpha: Build system units in common source set

The following patches aren't required anymore for single-binary; I just happen to write them before Pierrick's meson rework, they rebase cleanly, and are good style cleanup IMHO, so I included them.

Quoted 13 lines

target/alpha: Replace target_ulong -> uint64_t in gdb_write_register() target/alpha: Do not use target_ulong for trap arguments target/alpha: Do not use target_ulong for page table entries / indexes target/alpha: Remove target_ulong uses in get_physical_address() target/alpha: Expand TCGv type for 64-bit target

  target/alpha/gdbstub.c   |   2 +-
  target/alpha/helper.c    |  17 +--
  target/alpha/machine.c   |   3 +-
  target/alpha/translate.c | 228 ++++++++++++++++++++-------------------
  target/alpha/meson.build |   2 +-
  5 files changed, 129 insertions(+), 123 deletions(-)
Reviewed-by on the v1 series
#9 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 8 lines · Philippe Mathieu-Daudé

Philippe Mathieu-Daudé (7):
target/alpha: Avoid target-specific migration headers in machine.c target/alpha: Build system units in common source set target/alpha: Replace target_ulong -> uint64_t in gdb_write_register() target/alpha: Do not use target_ulong for trap arguments target/alpha: Do not use target_ulong for page table entries / indexes target/alpha: Remove target_ulong uses in get_physical_address() target/alpha: Expand TCGv type for 64-bit target

r~