From patchwork Wed May 31 22:01:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 769393 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wdPxP72w4z9s8F for ; Thu, 1 Jun 2017 08:18:01 +1000 (AEST) Received: from localhost ([::1]:34100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGBwD-0006jP-G1 for incoming@patchwork.ozlabs.org; Wed, 31 May 2017 18:17:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGBgd-00017R-Si for qemu-devel@nongnu.org; Wed, 31 May 2017 18:01:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGBgb-0005U9-MN for qemu-devel@nongnu.org; Wed, 31 May 2017 18:01:51 -0400 Received: from hall.aurel32.net ([2001:bc8:30d7:100::1]:34982) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dGBgb-0005Ls-8R for qemu-devel@nongnu.org; Wed, 31 May 2017 18:01:49 -0400 Received: from [2001:bc8:30d7:120:9bb5:8936:7e6a:9e36] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1dGBgN-0004QJ-VC; Thu, 01 Jun 2017 00:01:36 +0200 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.89) (envelope-from ) id 1dGBgM-0000xq-2e; Thu, 01 Jun 2017 00:01:34 +0200 From: Aurelien Jarno To: qemu-devel@nongnu.org Date: Thu, 1 Jun 2017 00:01:11 +0200 Message-Id: <20170531220129.27724-13-aurelien@aurel32.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170531220129.27724-1-aurelien@aurel32.net> References: <20170531220129.27724-1-aurelien@aurel32.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:bc8:30d7:100::1 Subject: [Qemu-devel] [PATCH v3 12/30] target/s390x: implement MOVE WITH OFFSET 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: Alexander Graf , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Richard Henderson Signed-off-by: Aurelien Jarno --- target/s390x/helper.h | 1 + target/s390x/insn-data.def | 4 ++++ target/s390x/mem_helper.c | 31 +++++++++++++++++++++++++++++++ target/s390x/translate.c | 8 ++++++++ 4 files changed, 44 insertions(+) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index e62e45534d..a197b8bc39 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -14,6 +14,7 @@ DEF_HELPER_FLAGS_4(divu64, TCG_CALL_NO_WG, i64, env, i64, i64, i64) DEF_HELPER_4(srst, i64, env, i64, i64, i64) DEF_HELPER_4(clst, i64, env, i64, i64, i64) DEF_HELPER_FLAGS_4(mvn, TCG_CALL_NO_WG, void, env, i32, i64, i64) +DEF_HELPER_FLAGS_4(mvo, TCG_CALL_NO_WG, void, env, i32, i64, i64) DEF_HELPER_FLAGS_4(mvpg, TCG_CALL_NO_WG, i32, env, i64, i64, i64) DEF_HELPER_4(mvst, i64, env, i64, i64, i64) DEF_HELPER_4(ex, void, env, i32, i64, i64) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index 6af717648c..47542eeaf3 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -584,6 +584,10 @@ C(0xb254, MVPG, RRE, Z, r1_o, r2_o, 0, 0, mvpg, 0) /* MOVE STRING */ C(0xb255, MVST, RRE, Z, r1_o, r2_o, 0, 0, mvst, 0) +/* MOVE WITH OFFSET */ + /* Really format SS_b, but we pack both lengths into one argument + for the helper call, so we might as well leave one 8-bit field. */ + C(0xf100, MVO, SS_a, Z, la1, a2, 0, 0, mvo, 0) /* MULTIPLY */ C(0x1c00, MR, RR_a, Z, r1p1_32s, r2_32s, new, r1_D32, mul, 0) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 53852784e6..3601bb9cdd 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -256,6 +256,37 @@ void HELPER(mvn)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src) } } +/* move with offset */ +void HELPER(mvo)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src) +{ + uintptr_t ra = GETPC(); + int len_dest = l >> 4; + int len_src = l & 0xf; + uint8_t byte_dest, byte_src; + int i; + + src += len_src; + dest += len_dest; + + /* Handle rightmost byte */ + byte_src = cpu_ldub_data_ra(env, src, ra); + byte_dest = cpu_ldub_data_ra(env, dest, ra); + byte_dest = (byte_dest & 0x0f) | (byte_src << 4); + cpu_stb_data_ra(env, dest, byte_dest, ra); + + /* Process remaining bytes from right to left */ + for (i = 1; i <= len_dest; i++) { + byte_dest = byte_src >> 4; + if (len_src - i >= 0) { + byte_src = cpu_ldub_data_ra(env, src - i, ra); + } else { + byte_src = 0; + } + byte_dest |= byte_src << 4; + cpu_stb_data_ra(env, dest - i, byte_dest, ra); + } +} + /* compare unsigned byte arrays */ static uint32_t do_helper_clc(CPUS390XState *env, uint32_t l, uint64_t s1, uint64_t s2, uintptr_t ra) diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 4e7211203a..b1877cf27b 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -2998,6 +2998,14 @@ static ExitStatus op_mvn(DisasContext *s, DisasOps *o) return NO_EXIT; } +static ExitStatus op_mvo(DisasContext *s, DisasOps *o) +{ + TCGv_i32 l = tcg_const_i32(get_field(s->fields, l1)); + gen_helper_mvo(cpu_env, l, o->addr1, o->in2); + tcg_temp_free_i32(l); + return NO_EXIT; +} + static ExitStatus op_mvpg(DisasContext *s, DisasOps *o) { gen_helper_mvpg(cc_op, cpu_env, regs[0], o->in1, o->in2);