Skip to contentSkip to conversation

target-m68k patches

PATCH Superseded Richard Henderson 3 participants 15 messages Nov 6, 2016 – Nov 7, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover target-m68k patches

I believe the first two patches have already been posted. No changes there, but included here for completeness.

Next is a proposed shift patch, with the changes I believe I mentioned wanting during review.

Finally, implementations of the bitfield instructions. At least the register portion depends on the generic tcg (s)extract primitives that I have queued for 2.9.

The full tree is at

git://github.com/rth7680/qemu.git tgt-m68k

r~

Laurent Vivier (1):
target-m68k: implement 680x0 movem

Richard Henderson (4):
target-m68k: Do not cpu_abort on undefined insns
target-m68k: Inline shifts
target-m68k: Implement bitfield ops for registers
target-m68k: Implement bitfield ops for memory

 target-m68k/cpu.h       |   1 +
 target-m68k/helper.c    | 235 ++++++++++++----
 target-m68k/helper.h    |  10 +-
 target-m68k/translate.c | 702 ++++++++++++++++++++++++++++++++++++++++++++----
 4 files changed, 840 insertions(+), 108 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/5 target-m68k: implement 680x0 movem

From: Laurent Vivier <[email protected]>

680x0 movem can load/store words and long words and can use more addressing modes.
Coldfire can only use long words with (Ax) and (d16,Ax) addressing modes.

Message-Id: <[email protected]>

---
 target-m68k/translate.c | 130 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 107 insertions(+), 23 deletions(-)
target-m68k/translate.c +107 -23
index 9b4ad52..60c8b4b 100644
@@ -1430,40 +1430,122 @@ static void gen_push(DisasContext *s, TCGv val)
     tcg_gen_mov_i32(QREG_SP, tmp);
 }
 
+static TCGv mreg(int reg)
+{
+    if (reg < 8) {
+        /* Dx */
+        return cpu_dregs[reg];
+    }
+    /* Ax */
+    return cpu_aregs[reg & 7];
+}
+
 DISAS_INSN(movem)
 {
-    TCGv addr;
+    TCGv addr, incr, tmp, r[16];
+    int is_load = (insn & 0x0400) != 0;
+    int opsize = (insn & 0x40) != 0 ? OS_LONG : OS_WORD;
+    uint16_t mask = read_im16(env, s);
+    int mode = extract32(insn, 3, 3);
+    int reg0 = REG(insn, 0);
     int i;
-    uint16_t mask;
-    TCGv reg;
-    TCGv tmp;
-    int is_load;
 
-    mask = read_im16(env, s);
-    tmp = gen_lea(env, s, insn, OS_LONG);
-    if (IS_NULL_QREG(tmp)) {
+    tmp = cpu_aregs[reg0];
+
+    switch (mode) {
+    case 0: /* data register direct */
+    case 1: /* addr register direct */
+    do_addr_fault:
         gen_addr_fault(s);
         return;
+
+    case 2: /* indirect */
+        break;
+
+    case 3: /* indirect post-increment */
+        if (!is_load) {
+            /* post-increment is not allowed */
+            goto do_addr_fault;
+        }
+        break;
+
+    case 4: /* indirect pre-decrement */
+        if (is_load) {
+            /* pre-decrement is not allowed */
+            goto do_addr_fault;
+        }
+        /* We want a bare copy of the address reg, without any pre-decrement
+           adjustment, as gen_lea would provide.  */
+        break;
+
+    default:
+        tmp = gen_lea_mode(env, s, mode, reg0, opsize);
+        if (IS_NULL_QREG(tmp)) {
+            goto do_addr_fault;
+        }
+        break;
     }
+
     addr = tcg_temp_new();
     tcg_gen_mov_i32(addr, tmp);
-    is_load = ((insn & 0x0400) != 0);
-    for (i = 0; i < 16; i++, mask >>= 1) {
-        if (mask & 1) {
-            if (i < 8)
-                reg = DREG(i, 0);
-            else
-                reg = AREG(i, 0);
-            if (is_load) {
-                tmp = gen_load(s, OS_LONG, addr, 0);
-                tcg_gen_mov_i32(reg, tmp);
-            } else {
-                gen_store(s, OS_LONG, addr, reg);
+    incr = tcg_const_i32(opsize_bytes(opsize));
+
+    if (is_load) {
+        /* memory to register */
+        for (i = 0; i < 16; i++) {
+            if (mask & (1 << i)) {
+                r[i] = gen_load(s, opsize, addr, 1);
+                tcg_gen_add_i32(addr, addr, incr);
+            }
+        }
+        for (i = 0; i < 16; i++) {
+            if (mask & (1 << i)) {
+                tcg_gen_mov_i32(mreg(i), r[i]);
+                tcg_temp_free(r[i]);
+            }
+        }
+        if (mode == 3) {
+            /* post-increment: movem (An)+,X */
+            tcg_gen_mov_i32(AREG(insn, 0), addr);
+        }
+    } else {
+        /* register to memory */
+        if (mode == 4) {
+            /* pre-decrement: movem X,-(An) */
+            for (i = 15; i >= 0; i--) {
+                if ((mask << i) & 0x8000) {
+                    tcg_gen_sub_i32(addr, addr, incr);
+                    if (reg0 + 8 == i &&
+                        m68k_feature(s->env, M68K_FEATURE_EXT_FULL)) {
+                        /* M68020+: if the addressing register is the
+                         * register moved to memory, the value written
+                         * is the initial value decremented by the size of
+                         * the operation, regardless of how many actual
+                         * stores have been performed until this point.
+                         * M68000/M68010: the value is the initial value.
+                         */
+                        TCGv tmp = tcg_temp_new();
+                        tcg_gen_sub_i32(tmp, cpu_aregs[reg0], incr);
+                        gen_store(s, opsize, addr, tmp);
+                        tcg_temp_free(tmp);
+                    } else {
+                        gen_store(s, opsize, addr, mreg(i));
+                    }
+                }
+            }
+            tcg_gen_mov_i32(cpu_aregs[reg0], addr);
+        } else {
+            for (i = 0; i < 16; i++) {
+                if (mask & (1 << i)) {
+                    gen_store(s, opsize, addr, mreg(i));
+                    tcg_gen_add_i32(addr, addr, incr);
+                }
             }
-            if (mask != 1)
-                tcg_gen_addi_i32(addr, addr, 4);
         }
     }
+
+    tcg_temp_free(incr);
+    tcg_temp_free(addr);
 }
 
 DISAS_INSN(bitop_im)
@@ -3452,7 +3534,9 @@ void register_m68k_insns (CPUM68KState *env)
     BASE(pea,       4840, ffc0);
     BASE(swap,      4840, fff8);
     INSN(bkpt,      4848, fff8, BKPT);
-    BASE(movem,     48c0, fbc0);
+    INSN(movem,     48d0, fbf8, CF_ISA_A);
+    INSN(movem,     48e8, fbf8, CF_ISA_A);
+    INSN(movem,     4880, fb80, M68000);
     BASE(ext,       4880, fff8);
     BASE(ext,       48c0, fff8);
     BASE(ext,       49c0, fff8);
Signature · 1 line
2.7.4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/5] target-m68k: implement 680x0 movem

Le 06/11/2016 à 07:18, Richard Henderson a écrit :
...

Quoted 7 lines
target-m68k/translate.c +7 -0
+    if (is_load) {
+        /* memory to register */
+        for (i = 0; i < 16; i++) {
+            if (mask & (1 << i)) {
+                r[i] = gen_load(s, opsize, addr, 1);
+                tcg_gen_add_i32(addr, addr, incr);
+            }

target-m68k/translate.c static void gen_push(DisasContext *s, TCGv val) · line 1509

Quoted 10 lines
target-m68k/translate.c +10 -0
+        }
+        for (i = 0; i < 16; i++) {
+            if (mask & (1 << i)) {
+                tcg_gen_mov_i32(mreg(i), r[i]);
+                tcg_temp_free(r[i]);
+            }
+        }
+        if (mode == 3) {
+            /* post-increment: movem (An)+,X */
+            tcg_gen_mov_i32(AREG(insn, 0), addr);

Why AREG() instead of cpu_aregs[]?

Quoted 8 lines
target-m68k/translate.c +8 -0
+        }
+    } else {
+        /* register to memory */
+        if (mode == 4) {
+            /* pre-decrement: movem X,-(An) */
+            for (i = 15; i >= 0; i--) {
+                if ((mask << i) & 0x8000) {
+                    tcg_gen_sub_i32(addr, addr, incr);

target-m68k/translate.c static void gen_push(DisasContext *s, TCGv val) · line 1527

Quoted 10 lines
target-m68k/translate.c +10 -0
+                    if (reg0 + 8 == i &&
+                        m68k_feature(s->env, M68K_FEATURE_EXT_FULL)) {
+                        /* M68020+: if the addressing register is the
+                         * register moved to memory, the value written
+                         * is the initial value decremented by the size of
+                         * the operation, regardless of how many actual
+                         * stores have been performed until this point.
+                         * M68000/M68010: the value is the initial value.
+                         */
+                        TCGv tmp = tcg_temp_new();

tmp is already declared at the top of the function, perhaps you can remove the declaration part here?

Thanks,
Laurent

#3 lore raw

PATCH 2/5 target-m68k: Do not cpu_abort on undefined insns

In reply to Richard Henderson

Report this properly via exception and, importantly, allow the disassembler the chance to tell us what insn is not handled.

---
 target-m68k/translate.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
target-m68k/translate.c +5 -3
index 60c8b4b..2f956d9 100644
@@ -1214,10 +1214,12 @@ DISAS_INSN(undef_fpu)
 
 DISAS_INSN(undef)
 {
-    M68kCPU *cpu = m68k_env_get_cpu(env);
-
+    /* ??? This is both instructions that are as yet unimplemented
+       for the 680x0 series, as well as those that are implemented
+       but actually illegal for CPU32 or pre-68020.  */
+    qemu_log_mask(LOG_UNIMP, "Illegal instruction: %04x @ %08x",
+                  insn, s->pc - 2);
     gen_exception(s, s->pc - 2, EXCP_UNSUPPORTED);
-    cpu_abort(CPU(cpu), "Illegal instruction: %04x @ %08x", insn, s->pc - 2);
 }
 
 DISAS_INSN(mulw)
Signature · 1 line
2.7.4
#5 lore raw

PATCH 3/5 target-m68k: Inline shifts

In reply to Richard Henderson

Also manage word and byte operands and fix the computation of overflow in the case of M68000 arithmetic shifts.

---
 target-m68k/helper.c    |  52 ------------
 target-m68k/helper.h    |   3 -
 target-m68k/translate.c | 216 ++++++++++++++++++++++++++++++++++++++++++------
 3 files changed, 190 insertions(+), 81 deletions(-)
target-m68k/helper.c +0 -52
index 7aed9ff..f750d3d 100644
@@ -284,58 +284,6 @@ void HELPER(set_sr)(CPUM68KState *env, uint32_t val)
     m68k_switch_sp(env);
 }
 
-uint32_t HELPER(shl_cc)(CPUM68KState *env, uint32_t val, uint32_t shift)
-{
-    uint64_t result;
-
-    shift &= 63;
-    result = (uint64_t)val << shift;
-
-    env->cc_c = (result >> 32) & 1;
-    env->cc_n = result;
-    env->cc_z = result;
-    env->cc_v = 0;
-    env->cc_x = shift ? env->cc_c : env->cc_x;
-
-    return result;
-}
-
-uint32_t HELPER(shr_cc)(CPUM68KState *env, uint32_t val, uint32_t shift)
-{
-    uint64_t temp;
-    uint32_t result;
-
-    shift &= 63;
-    temp = (uint64_t)val << 32 >> shift;
-    result = temp >> 32;
-
-    env->cc_c = (temp >> 31) & 1;
-    env->cc_n = result;
-    env->cc_z = result;
-    env->cc_v = 0;
-    env->cc_x = shift ? env->cc_c : env->cc_x;
-
-    return result;
-}
-
-uint32_t HELPER(sar_cc)(CPUM68KState *env, uint32_t val, uint32_t shift)
-{
-    uint64_t temp;
-    uint32_t result;
-
-    shift &= 63;
-    temp = (int64_t)val << 32 >> shift;
-    result = temp >> 32;
-
-    env->cc_c = (temp >> 31) & 1;
-    env->cc_n = result;
-    env->cc_z = result;
-    env->cc_v = result ^ val;
-    env->cc_x = shift ? env->cc_c : env->cc_x;
-
-    return result;
-}
-
 /* FPU helpers.  */
 uint32_t HELPER(f64_to_i32)(CPUM68KState *env, float64 val)
 {
target-m68k/helper.h +0 -3
index 6180dc5..d863e55 100644
@@ -7,9 +7,6 @@ DEF_HELPER_4(divul, void, env, int, int, i32)
 DEF_HELPER_4(divsl, void, env, int, int, s32)
 DEF_HELPER_4(divull, void, env, int, int, i32)
 DEF_HELPER_4(divsll, void, env, int, int, s32)
-DEF_HELPER_3(shl_cc, i32, env, i32, i32)
-DEF_HELPER_3(shr_cc, i32, env, i32, i32)
-DEF_HELPER_3(sar_cc, i32, env, i32, i32)
 DEF_HELPER_2(set_sr, void, env, i32)
 DEF_HELPER_3(movec, void, env, i32, i32)
 
target-m68k/translate.c +190 -26

244 lines not on this page · raw message

Signature · 1 line
2.7.4
#6 lore raw

PATCH 4/5 target-m68k: Implement bitfield ops for registers

In reply to Richard Henderson
---
 target-m68k/translate.c | 210 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 210 insertions(+)
target-m68k/translate.c +210 -0
index b538d74..477a511 100644
@@ -2721,6 +2721,210 @@ DISAS_INSN(shift_mem)
     set_cc_op(s, CC_OP_FLAGS);
 }
 
+DISAS_INSN(bfext_reg)
+{
+    int ext = read_im16(env, s);
+    int is_sign = insn & 0x200;
+    TCGv src = DREG(insn, 0);
+    TCGv dst = DREG(ext, 12);
+    int len = ((extract32(ext, 0, 5) - 1) & 31) + 1;
+    int ofs = extract32(ext, 6, 5);  /* big bit-endian */
+    int pos = 31 - ofs;              /* little bit-endian */
+    TCGv tmp = tcg_temp_new();
+    TCGv shift;
+
+    /* In general, we're going to rotate the field so that it's at the
+       top of the word and then right-shift by the compliment of the
+       width to extend the field.  */
+    if (ext & 0x20) {
+        /* Variable width.  */
+        if (ext & 0x800) {
+            /* Variable offset.  */
+            tcg_gen_andi_i32(tmp, DREG(ext, 6), 31);
+            tcg_gen_rotl_i32(tmp, src, tmp);
+        } else {
+            tcg_gen_rotli_i32(tmp, src, ofs);
+        }
+
+        shift = tcg_temp_new();
+        tcg_gen_neg_i32(shift, DREG(ext, 0));
+        tcg_gen_andi_i32(shift, shift, 31);
+        tcg_gen_sar_i32(QREG_CC_N, tmp, shift);
+        if (is_sign) {
+            tcg_gen_mov_i32(dst, QREG_CC_N);
+        } else {
+            tcg_gen_shr_i32(dst, tmp, shift);
+        }
+        tcg_temp_free(shift);
+    } else {
+        /* Immediate width.  */
+        if (ext & 0x800) {
+            /* Variable offset */
+            tcg_gen_andi_i32(tmp, DREG(ext, 6), 31);
+            tcg_gen_rotl_i32(tmp, src, tmp);
+            src = tmp;
+            pos = 32 - len;
+        } else {
+            /* Immediate offset.  If the field doesn't wrap around the
+               end of the word, rely on (s)extract completely.  */
+            if (pos + len > 32) {
+                tcg_gen_rotli_i32(tmp, src, ofs);
+                src = tmp;
+                pos = 32 - len;
+            }
+        }
+
+        tcg_gen_sextract_i32(QREG_CC_N, src, pos, len);
+        if (is_sign) {
+            tcg_gen_mov_i32(dst, QREG_CC_N);
+        } else {
+            tcg_gen_extract_i32(dst, src, pos, len);
+        }
+    }
+
+    tcg_temp_free(tmp);
+    set_cc_op(s, CC_OP_LOGIC);
+}
+
+DISAS_INSN(bfop_reg)
+{
+    int ext = read_im16(env, s);
+    TCGv src = DREG(insn, 0);
+    int len = ((extract32(ext, 0, 5) - 1) & 31) + 1;
+    int ofs = extract32(ext, 6, 5);  /* big bit-endian */
+    TCGv mask;
+
+    if ((ext & 0x820) == 0) {
+        /* Immediate width and offset.  */
+        uint32_t maski = 0x7fffffffu >> (len - 1);
+        if (ofs + len <= 32) {
+            tcg_gen_shli_i32(QREG_CC_N, src, ofs);
+        } else {
+            tcg_gen_rotli_i32(QREG_CC_N, src, ofs);
+        }
+        tcg_gen_andi_i32(QREG_CC_N, QREG_CC_N, ~maski);
+        mask = tcg_const_i32(ror32(maski, ofs));
+    } else {
+        TCGv tmp = tcg_temp_new();
+        if (ext & 0x20) {
+            /* Variable width */
+            tcg_gen_subi_i32(tmp, DREG(ext, 0), 1);
+            tcg_gen_andi_i32(tmp, tmp, 31);
+            mask = tcg_const_i32(0x7fffffffu);
+            tcg_gen_shr_i32(mask, mask, tmp);
+        } else {
+            /* Immediate width */
+            mask = tcg_const_i32(0x7fffffffu >> (len - 1));
+        }
+        if (ext & 0x800) {
+            /* Variable offset */
+            tcg_gen_andi_i32(tmp, DREG(ext, 6), 31);
+            tcg_gen_rotl_i32(QREG_CC_N, src, tmp);
+            tcg_gen_andc_i32(QREG_CC_N, QREG_CC_N, mask);
+            tcg_gen_rotr_i32(mask, mask, tmp);
+        } else {
+            /* Immediate offset (and variable width) */
+            tcg_gen_rotli_i32(QREG_CC_N, src, ofs);
+            tcg_gen_andc_i32(QREG_CC_N, QREG_CC_N, mask);
+            tcg_gen_rotri_i32(mask, mask, ofs);
+        }
+        tcg_temp_free(tmp);
+    }
+    set_cc_op(s, CC_OP_LOGIC);
+
+    switch (insn & 0x0f00) {
+    case 0x0a00: /* bfchg */
+        tcg_gen_eqv_i32(src, src, mask);
+        break;
+    case 0x0c00: /* bfclr */
+        tcg_gen_and_i32(src, src, mask);
+        break;
+    case 0x0e00: /* bfset */
+        tcg_gen_orc_i32(src, src, mask);
+        break;
+    case 0x0800: /* bftst */
+        /* flags already set; no other work to do.  */
+        break;
+    default:
+        g_assert_not_reached();
+    }
+    tcg_temp_free(mask);
+}
+
+DISAS_INSN(bfins_reg)
+{
+    int ext = read_im16(env, s);
+    TCGv dst = DREG(insn, 0);
+    TCGv src = DREG(ext, 12);
+    int len = ((extract32(ext, 0, 5) - 1) & 31) + 1;
+    int ofs = extract32(ext, 6, 5);  /* big bit-endian */
+    int pos = 31 - ofs;              /* little bit-endian */
+    TCGv tmp;
+
+    tmp = tcg_temp_new();
+
+    if (ext & 0x20) {
+        /* Variable width */
+        tcg_gen_neg_i32(tmp, DREG(ext, 0));
+        tcg_gen_andi_i32(tmp, tmp, 31);
+        tcg_gen_shl_i32(QREG_CC_N, src, tmp);
+    } else {
+        /* Immediate width */
+        tcg_gen_shli_i32(QREG_CC_N, src, 32 - len);
+    }
+    set_cc_op(s, CC_OP_LOGIC);
+
+    /* Immediate width and offset */
+    if ((ext & 0x820) == 0) {
+        /* Check for suitability for deposit.  */
+        if (pos + len <= 32) {
+            tcg_gen_deposit_i32(dst, dst, src, pos, len);
+        } else {
+            uint32_t maski = -2U << (len - 1);
+            uint32_t roti = (ofs + len) & 31;
+            tcg_gen_andi_i32(tmp, src, maski);
+            tcg_gen_rotri_i32(tmp, tmp, roti);
+            tcg_gen_andi_i32(dst, dst, ror32(maski, roti));
+            tcg_gen_or_i32(dst, dst, tmp);
+        }
+    } else {
+        TCGv mask = tcg_temp_new();
+        TCGv rot = tcg_temp_new();
+
+        if (ext & 0x20) {
+            /* Variable width */
+            tcg_gen_subi_i32(rot, DREG(ext, 0), 1);
+            tcg_gen_andi_i32(rot, rot, 31);
+            tcg_gen_movi_i32(mask, -2);
+            tcg_gen_shl_i32(mask, mask, rot);
+            tcg_gen_mov_i32(rot, DREG(ext, 0));
+            tcg_gen_andc_i32(tmp, src, mask);
+        } else {
+            /* Immediate width (variable offset) */
+            uint32_t maski = -2U << (len - 1);
+            tcg_gen_andi_i32(tmp, src, ~maski);
+            tcg_gen_movi_i32(mask, maski);
+            tcg_gen_movi_i32(rot, len & 31);
+        }
+        if (ext & 0x800) {
+            /* Variable offset */
+            tcg_gen_add_i32(rot, rot, DREG(ext, 6));
+        } else {
+            /* Immediate offset (variable width) */
+            tcg_gen_addi_i32(rot, rot, ofs);
+        }
+        tcg_gen_andi_i32(rot, rot, 31);
+        tcg_gen_rotr_i32(mask, mask, rot);
+        tcg_gen_rotr_i32(tmp, tmp, rot);
+        tcg_gen_and_i32(dst, dst, mask);
+        tcg_gen_or_i32(dst, dst, tmp);
+
+        tcg_temp_free(rot);
+        tcg_temp_free(mask);
+    }
+    tcg_temp_free(tmp);
+}
+
 DISAS_INSN(ff1)
 {
     TCGv reg;
@@ -3795,6 +3999,12 @@ void register_m68k_insns (CPUM68KState *env)
     INSN(shift16_reg, e060, f0f0, M68000);
     INSN(shift_reg, e0a0, f0f0, M68000);
     INSN(shift_mem, e0c0, fcc0, M68000);
+    INSN(bfext_reg, e9c0, fdf8, BITFIELD);  /* bfextu & bfexts */
+    INSN(bfins_reg, efc0, fff8, BITFIELD);
+    INSN(bfop_reg, eac0, fff8, BITFIELD);   /* bfchg */
+    INSN(bfop_reg, ecc0, fff8, BITFIELD);   /* bfclr */
+    INSN(bfop_reg, eec0, fff8, BITFIELD);   /* bfset */
+    INSN(bfop_reg, e8c0, fff8, BITFIELD);   /* bftst */
     INSN(undef_fpu, f000, f000, CF_ISA_A);
     INSN(fpu,       f200, ffc0, CF_FPU);
     INSN(fbcc,      f280, ffc0, CF_FPU);
Signature · 1 line
2.7.4
#7 lore raw

PATCH 5/5 target-m68k: Implement bitfield ops for memory

In reply to Richard Henderson
---
 target-m68k/cpu.h       |   1 +
 target-m68k/helper.c    | 183 +++++++++++++++++++++++++++++++++++++++++++++++-
 target-m68k/helper.h    |   7 ++
 target-m68k/translate.c | 142 ++++++++++++++++++++++++++++++++++++-
 4 files changed, 330 insertions(+), 3 deletions(-)
target-m68k/cpu.h +1 -0
index 0b4ed7b..fc1f16f 100644
@@ -37,6 +37,7 @@
 #define OS_DOUBLE   4
 #define OS_EXTENDED 5
 #define OS_PACKED   6
+#define OS_UNSIZED  7
 
 #define MAX_QREGS 32
 
target-m68k/helper.c +182 -1

193 lines not on this page · raw message

target-m68k/helper.h +7 -0
index d863e55..8db741a 100644
@@ -48,3 +48,10 @@ DEF_HELPER_2(flush_flags, void, env, i32)
 DEF_HELPER_2(set_ccr, void, env, i32)
 DEF_HELPER_FLAGS_1(get_ccr, TCG_CALL_NO_WG_SE, i32, env)
 DEF_HELPER_2(raise_exception, void, env, i32)
+
+DEF_HELPER_FLAGS_4(bfexts_mem, TCG_CALL_NO_WG, i32, env, i32, s32, i32)
+DEF_HELPER_FLAGS_4(bfextu_mem, TCG_CALL_NO_WG, i64, env, i32, s32, i32)
+DEF_HELPER_FLAGS_5(bfins_mem, TCG_CALL_NO_WG, i32, env, i32, i32, s32, i32)
+DEF_HELPER_FLAGS_4(bfchg_mem, TCG_CALL_NO_WG, i32, env, i32, s32, i32)
+DEF_HELPER_FLAGS_4(bfclr_mem, TCG_CALL_NO_WG, i32, env, i32, s32, i32)
+DEF_HELPER_FLAGS_4(bfset_mem, TCG_CALL_NO_WG, i32, env, i32, s32, i32)
target-m68k/translate.c +140 -2

179 lines not on this page · raw message

Signature · 1 line
2.7.4
#8 lore raw
In reply to Richard Henderson
Quoted 18 lines · Richard Henderson

I believe the first two patches have already been posted. No changes there, but included here for completeness.

Next is a proposed shift patch, with the changes I believe I mentioned wanting during review.

Finally, implementations of the bitfield instructions. At least the register portion depends on the generic tcg (s)extract primitives that I have queued for 2.9.

The full tree is at

git://github.com/rth7680/qemu.git tgt-m68k

r~

Quoted 8 lines

Laurent Vivier (1):
target-m68k: implement 680x0 movem

Richard Henderson (4):
target-m68k: Do not cpu_abort on undefined insns
target-m68k: Inline shifts
target-m68k: Implement bitfield ops for registers
target-m68k: Implement bitfield ops for memory

There is something wrong with the bitfield patches, because when I use them instead of the version I use usually I'm not able to boot a container with qemu-m68k (SEGFAULT).

Laurent

#9 lore raw
Quoted 9 lines · Laurent Vivier
Quoted 5 lines

Richard Henderson (4):
target-m68k: Do not cpu_abort on undefined insns
target-m68k: Inline shifts
target-m68k: Implement bitfield ops for registers
target-m68k: Implement bitfield ops for memory

There is something wrong with the bitfield patches, because when I use them instead of the version I use usually I'm not able to boot a container with qemu-m68k (SEGFAULT).

Ah, too bad. I was testing with the linux-user-0.3 busybox, but we don't yet implement enough to actually execute it. So the testing consisted of maybe 3 or 4 such insns until I reach the fmovemx. ;-)

Can you tell if the breakage is limited to the memory patch, or if the register patch is also broken?

r~

#10 lore raw
Quoted 11 lines · Richard Henderson
Quoted 9 lines · Laurent Vivier
Quoted 5 lines

Richard Henderson (4):
target-m68k: Do not cpu_abort on undefined insns
target-m68k: Inline shifts
target-m68k: Implement bitfield ops for registers
target-m68k: Implement bitfield ops for memory

There is something wrong with the bitfield patches, because when I use them instead of the version I use usually I'm not able to boot a container with qemu-m68k (SEGFAULT).

Quoted 6 lines

Ah, too bad. I was testing with the linux-user-0.3 busybox, but we don't yet implement enough to actually execute it. So the testing consisted of maybe 3 or 4 such insns until I reach the fmovemx. ;-)

Can you tell if the breakage is limited to the memory patch, or if the register patch is also broken?

I need to test more, because if I only apply the register patch, I have an illegal instruction exception.

If it can help:

sudo QEMU_LOG=in_asm chroot /var/lib/lxc/virtm68k-etch-m68k/rootfs 2>&1 |grep bf

0xf67f9160:  bfextu %d3,27,3,%d1
0xf67f8988:  bftst %d1,30,2
0xf67f2786:  bfins %d0,%a1@,0,2
0xf67eeb56:  bfins %d0,%a2@(824),0,2
0xf67f362c:  bfins %d0,%a2@(384),5,2
0xf67f8b80:  bftst %d1,30,2
0xf67f8b9e:  bftst %d4,30,2
0xf67f8998:  bftst %d0,30,2
0xf67f8998:  bftst %d0,30,2
0xf67f9160:  bfextu %d3,27,3,%d1
0xf67f8f88:  bftst %d4,30,2
0xf67f39d8:  bfins %d0,%a1@(384),5,2
0xf67f3876:  bfclr %a0@(384),5,2

If you want to have a try, this tree is based on tgt-m68k + what is needed to boot an etch-m68k container.

git://github.com/vivier/qemu-m68k.git for-rth

The working tree is:

git://github.com/vivier/qemu-m68k.git m68k-dev

Thanks,
Laurent

#11 lore raw
Quoted 4 lines · Laurent Vivier

If you want to have a try, this tree is based on tgt-m68k + what is needed to boot an etch-m68k container.

git://github.com/vivier/qemu-m68k.git for-rth

You could try using 'risu' to do single-instruction level comprehensive testing, if you've got enough of a linux-user port to be able to run it...

thanks
-- PMM

#12 lore raw
Quoted 9 lines · Peter Maydell
Quoted 4 lines · Laurent Vivier

If you want to have a try, this tree is based on tgt-m68k + what is needed to boot an etch-m68k container.

git://github.com/vivier/qemu-m68k.git for-rth

You could try using 'risu' to do single-instruction level comprehensive testing, if you've got enough of a linux-user port to be able to run it...

Thank you Peter.

I know risu, I would like to port it to m68k but for the moment it's too much work. I think someone is already working on a port to PPC, perhaps after that it will be easier to port it to m68k.

For m68k, I've taken the work from Ray Arachelian [1] for the LISA emulator and Gwenole Beauchesne for Basilisk II [2].

I also test FPU with testfloat and softfloat. [3]

Laurent

[1] http://lisa.sunder.net/cputest.html
[2] https://github.com/vivier/m68k-testgen
https://github.com/vivier/m68k-tester
(I have 584MB of results I can't put in the repo..)
[3] https://github.com/vivier/m68k-testfloat
https://github.com/vivier/m68k-softfloat

#13 lore raw
Quoted 3 lines · Laurent Vivier

I know risu, I would like to port it to m68k but for the moment it's too much work. I think someone is already working on a port to PPC, perhaps after that it will be easier to port it to m68k.

Yes, I have the ppc patchset on my review queue.

Quoted 2 lines

For m68k, I've taken the work from Ray Arachelian [1] for the LISA emulator and Gwenole Beauchesne for Basilisk II [2].

Cool. If you've already got a decent test coverage setup then risu probably won't add much extra for you.

thanks
-- PMM

#14 lore raw
Quoted 6 lines · Peter Maydell
Quoted 3 lines · Laurent Vivier

I know risu, I would like to port it to m68k but for the moment it's too much work. I think someone is already working on a port to PPC, perhaps after that it will be easier to port it to m68k.

Yes, I have the ppc patchset on my review queue.

Great!

Quoted 5 lines
Quoted 2 lines

For m68k, I've taken the work from Ray Arachelian [1] for the LISA emulator and Gwenole Beauchesne for Basilisk II [2].

Cool. If you've already got a decent test coverage setup then risu probably won't add much extra for you.

I think risu is better because it is more flexible and able to test memory access. My current test suite can only test instructions with data in registers.

Laurent