From patchwork Thu Jan 4 16:42:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 855723 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zCDSf2507z9s7G for ; Fri, 5 Jan 2018 03:55:30 +1100 (AEDT) Received: from localhost ([::1]:50280 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eX8ng-0003Zl-9G for incoming@patchwork.ozlabs.org; Thu, 04 Jan 2018 11:55:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eX8bd-0007b0-Fi for qemu-devel@nongnu.org; Thu, 04 Jan 2018 11:43:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eX8ba-0003Zx-6Z for qemu-devel@nongnu.org; Thu, 04 Jan 2018 11:43:01 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:50011) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eX8bZ-0003Xd-No for qemu-devel@nongnu.org; Thu, 04 Jan 2018 11:42:58 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.167]) with ESMTPSA (Nemesis) id 0McRqW-1eFTEG0pd2-00Hfs7; Thu, 04 Jan 2018 17:42:56 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 4 Jan 2018 17:42:42 +0100 Message-Id: <20180104164251.26494-9-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180104164251.26494-1-laurent@vivier.eu> References: <20180104164251.26494-1-laurent@vivier.eu> X-Provags-ID: V03:K0:yMthnqEVL1udd77h61zv319zWnYTyb/Pmc4l4WmU8krncz/km9h ErizGTlESscBEPceAht8hm9do6kyzD5lDII1oHf4FxlB2TcpV2IGS78qEFRcv9XvDiLgaAv DtcNhKms8rTUAkw8pZwp0dqNBqbCE4fEUzpNxb7iNCzydRPVyF2S2q+sQDFKc/mE0yvN1FW 7Xpu62bihaCDb/oJq1oeA== X-UI-Out-Filterresults: notjunk:1; V01:K0:BDOBgbE5E34=:oGa8L5w+UN++YR9/fXiW8L z7xAtmXpRJhBT6n6UdZdV1VoI0LoUZbnq0Vi0OFPH3s8JGNh4ed9MCFQymDJ548M9QGaymf1t ybG+UJJN74MpJ1Q+qyHbzrbGF5fGjr9XffRE5iJyOk/rzyuV3fF1EazrU9/zn8CVwOCfLOwZd dPSxwMCy27WijI5HDb0CkqEFHE2qL7vVs7nD7K5zJZfRiefzhGM/BpRAu/jyYBZn0TxgUirWn q/AUSGgtrBdBDUlGTO9llCTujkihLLN0vN24SPKkAwaW3Xkh3w+6Q7mimD9bzcFKMpKuHAiR8 ZDRIyDo3IegaUjPyQBSrViRwE3nhFdWZr7hg84a9W72yb+QwVBlwR2g1nPo2pzOMnEUzyxJlR Puu/b/kEuzeXpiT+3qjjCgLdVu8zt1wEttE4lAv/t4YRKqUP7Llt3fNSCcdfcyZUiu30BX7F7 GuVIPN3cP27CZlS7v9c52E6XZhlfKufWm03nVV8QYulz9Dvx2eecWD4DYtQfcWrY5OSeyz3Jv wlUMojBPPpoIVmriE78HwXf6lNMdKtO0m89iqo4kpfRLwo+dYqxQmce+zYDN3sETkIeVQbWiw +sX+7ARgONt8/Pdv/KW4Uf7M1X+fSb4dwqfcGcewzozT6GLd0mRwh8Jzzr4dTkisIyG3RiLEy SgQjyoY4M1xFzcfISo90IndG/s7ABAMKqTeeFVFs2Q+xzF0wFT1Tf0GRuwlc0flYFev8coD1Q V1L7mZEOS46Snt4rOP1ptIXyCtvtfNY9MQ40Q9z/Cxl6qZed5frxzJdj1II= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.134 Subject: [Qemu-devel] [PULL 08/17] target/m68k: add move16 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" move16 moves the source line to the destination line. Lines are aligned to 16-byte boundaries and are 16 bytes long. Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20180104012913.30763-9-laurent@vivier.eu> --- target/m68k/cpu.c | 10 ++++++- target/m68k/cpu.h | 1 + target/m68k/translate.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 57ffcb2114..1936efd170 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -137,7 +137,15 @@ static void m68020_cpu_initfn(Object *obj) m68k_set_feature(env, M68K_FEATURE_CHK2); } #define m68030_cpu_initfn m68020_cpu_initfn -#define m68040_cpu_initfn m68020_cpu_initfn + +static void m68040_cpu_initfn(Object *obj) +{ + M68kCPU *cpu = M68K_CPU(obj); + CPUM68KState *env = &cpu->env; + + m68020_cpu_initfn(obj); + m68k_set_feature(env, M68K_FEATURE_M68040); +} static void m68060_cpu_initfn(Object *obj) { diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index 68396bdd70..2ac4ab191e 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -306,6 +306,7 @@ enum m68k_features { M68K_FEATURE_BKPT, M68K_FEATURE_RTD, M68K_FEATURE_CHK2, + M68K_FEATURE_M68040, /* instructions specific to MC68040 */ }; static inline int m68k_feature(CPUM68KState *env, int feature) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 7f52065375..0ef933a545 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -4277,6 +4277,76 @@ DISAS_INSN(chk2) tcg_temp_free(reg); } +static void m68k_copy_line(TCGv dst, TCGv src, int index) +{ + TCGv addr; + TCGv_i64 t0, t1; + + addr = tcg_temp_new(); + + t0 = tcg_temp_new_i64(); + t1 = tcg_temp_new_i64(); + + tcg_gen_andi_i32(addr, src, ~15); + tcg_gen_qemu_ld64(t0, addr, index); + tcg_gen_addi_i32(addr, addr, 8); + tcg_gen_qemu_ld64(t1, addr, index); + + tcg_gen_andi_i32(addr, dst, ~15); + tcg_gen_qemu_st64(t0, addr, index); + tcg_gen_addi_i32(addr, addr, 8); + tcg_gen_qemu_st64(t1, addr, index); + + tcg_temp_free_i64(t0); + tcg_temp_free_i64(t1); + tcg_temp_free(addr); +} + +DISAS_INSN(move16_reg) +{ + int index = IS_USER(s); + TCGv tmp; + uint16_t ext; + + ext = read_im16(env, s); + if ((ext & (1 << 15)) == 0) { + gen_exception(s, s->insn_pc, EXCP_ILLEGAL); + } + + m68k_copy_line(AREG(ext, 12), AREG(insn, 0), index); + + /* Ax can be Ay, so save Ay before incrementing Ax */ + tmp = tcg_temp_new(); + tcg_gen_mov_i32(tmp, AREG(ext, 12)); + tcg_gen_addi_i32(AREG(insn, 0), AREG(insn, 0), 16); + tcg_gen_addi_i32(AREG(ext, 12), tmp, 16); + tcg_temp_free(tmp); +} + +DISAS_INSN(move16_mem) +{ + int index = IS_USER(s); + TCGv reg, addr; + + reg = AREG(insn, 0); + addr = tcg_const_i32(read_im32(env, s)); + + if ((insn >> 3) & 1) { + /* MOVE16 (xxx).L, (Ay) */ + m68k_copy_line(reg, addr, index); + } else { + /* MOVE16 (Ay), (xxx).L */ + m68k_copy_line(addr, reg, index); + } + + tcg_temp_free(addr); + + if (((insn >> 3) & 2) == 0) { + /* (Ay)+ */ + tcg_gen_addi_i32(reg, reg, 16); + } +} + static TCGv gen_get_sr(DisasContext *s) { TCGv ccr; @@ -5578,6 +5648,8 @@ void register_m68k_insns (CPUM68KState *env) INSN(fsave, f300, ffc0, FPU); INSN(intouch, f340, ffc0, CF_ISA_A); INSN(cpushl, f428, ff38, CF_ISA_A); + INSN(move16_mem, f600, ffe0, M68040); + INSN(move16_reg, f620, fff8, M68040); INSN(wddata, fb00, ff00, CF_ISA_A); INSN(wdebug, fbc0, ffc0, CF_ISA_A); #undef INSN