From nobody Tue Feb 10 19:09:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494353354323421.57479486031036; Tue, 9 May 2017 11:09:14 -0700 (PDT) Received: from localhost ([::1]:38765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d89ZP-0002W4-Q5 for importer@patchew.org; Tue, 09 May 2017 14:09:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d89Xm-0001AB-IB for qemu-devel@nongnu.org; Tue, 09 May 2017 14:07:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d89Xl-0002rc-2d for qemu-devel@nongnu.org; Tue, 09 May 2017 14:07:30 -0400 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:35385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d89Xk-0002qo-UF for qemu-devel@nongnu.org; Tue, 09 May 2017 14:07:29 -0400 Received: by mail-qk0-x244.google.com with SMTP id k74so1225109qke.2 for ; Tue, 09 May 2017 11:07:28 -0700 (PDT) Received: from bigtime.twiddle.net.com ([2602:47:d954:1500:5e51:4fff:fe40:9c64]) by smtp.gmail.com with ESMTPSA id w12sm213102qtc.20.2017.05.09.11.07.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 May 2017 11:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=BNMx7Jnn4LQzjDsF7EH4Qcqb5ITPPgYAH9WsEfmXFDQ=; b=Hm3G1m1Bx3qdbanHaXH5K3CdqJFDtKdcyuxzE9/2mJXcP/ZNj7n6u6HYpE4oDsdpdQ 46KPVtNg7zXHo0MVImkhelnz+ZEEqsxxWROMAAJ+Opf21AS62f9lIqgfN44Sa497pHmP r8NiiRVzqJ8WM4pS6NVQiarIfW9UgmyhlmCUVgHfd0jK64mCsASYpmlnm/3wQA8/h6VX D+gT3srOGBuu5K1f/Zxvp4Nlvyz+VhsuilueR4l4PgBqRD1n4lABPTZX31hBrtZgg+xz oFMjEeIIt26jfb0lISG4+hc4C9Ym7XEzQjqPaOgkyQmdEjRRZFjeLki6udlqhR+52IMb upXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=BNMx7Jnn4LQzjDsF7EH4Qcqb5ITPPgYAH9WsEfmXFDQ=; b=cxCXdl0UAiCwc2dp12RsYif0RdcgXgsY5RbRPH5G3X1he2YMWdLmqDV2jzo6C/d13e zXyJzPSqtFpnpvlIPiYD+cJMJlew9BHrQxdppb6Xr80Bm5WAHUHaYx5rDeuDK31YtPSI AzKLEJiXPsr/8lG+3vyvPJiwXfXmf4KAby8DnpB1fMq9QEsjZQuaWRUFchTocYfTKTrZ v7MS/PVaHnCG2/GouwpMZcLP6PUFyCooJ/17mjcvGNNUSgNFXzBFlOkm2z4YPMYeKrIL uA8M+04wcznvrBPAoXfmQR0RVjmccll6Ul93BQdKrbpM12bHrAPvgDa4O7AWLXBwW90o pfIg== X-Gm-Message-State: AODbwcC+U6OVtlQLmlzRuqm75RGn5NTwraygPV5bxBHiUTqXjjiI4sKO eUYNt+m2LC+I9IKYxM4= X-Received: by 10.55.207.140 with SMTP id v12mr1485473qkl.68.1494353248118; Tue, 09 May 2017 11:07:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 9 May 2017 11:07:15 -0700 Message-Id: <20170509180715.22910-7-rth@twiddle.net> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170509180715.22910-1-rth@twiddle.net> References: <20170509180715.22910-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::244 Subject: [Qemu-devel] [PATCH v3 6/6] target/s390x: Use atomic operations for LOAD AND OP 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reviewed-by: Aurelien Jarno Signed-off-by: Richard Henderson --- target/s390x/insn-data.def | 20 ++++++------ target/s390x/translate.c | 78 +++++++++++++++++++++++++++++-------------= ---- 2 files changed, 60 insertions(+), 38 deletions(-) diff --git a/target/s390x/insn-data.def b/target/s390x/insn-data.def index 5e5fcc5..55a7c52 100644 --- a/target/s390x/insn-data.def +++ b/target/s390x/insn-data.def @@ -390,20 +390,20 @@ /* LOAD ADDRESS RELATIVE LONG */ C(0xc000, LARL, RIL_b, Z, 0, ri2, 0, r1, mov2, 0) /* LOAD AND ADD */ - C(0xebf8, LAA, RSY_a, ILA, r3_32s, m2_32s_atomic, new, m2_32_r1_at= omic, add, adds32) - C(0xebe8, LAAG, RSY_a, ILA, r3, m2_64_atomic, new, m2_64_r1_atomic,= add, adds64) + D(0xebf8, LAA, RSY_a, ILA, r3_32s, a2, new, in2_r1_32, laa, adds32= , MO_TESL) + D(0xebe8, LAAG, RSY_a, ILA, r3, a2, new, in2_r1, laa, adds64, MO_TE= Q) /* LOAD AND ADD LOGICAL */ - C(0xebfa, LAAL, RSY_a, ILA, r3_32s, m2_32s_atomic, new, m2_32_r1_at= omic, add, addu32) - C(0xebea, LAALG, RSY_a, ILA, r3, m2_64_atomic, new, m2_64_r1_atomic,= add, addu64) + D(0xebfa, LAAL, RSY_a, ILA, r3_32u, a2, new, in2_r1_32, laa, addu32= , MO_TEUL) + D(0xebea, LAALG, RSY_a, ILA, r3, a2, new, in2_r1, laa, addu64, MO_TE= Q) /* LOAD AND AND */ - C(0xebf4, LAN, RSY_a, ILA, r3_32s, m2_32s_atomic, new, m2_32_r1_at= omic, and, nz32) - C(0xebe4, LANG, RSY_a, ILA, r3, m2_64_atomic, new, m2_64_r1_atomic,= and, nz64) + D(0xebf4, LAN, RSY_a, ILA, r3_32s, a2, new, in2_r1_32, lan, nz32, = MO_TESL) + D(0xebe4, LANG, RSY_a, ILA, r3, a2, new, in2_r1, lan, nz64, MO_TEQ) /* LOAD AND EXCLUSIVE OR */ - C(0xebf7, LAX, RSY_a, ILA, r3_32s, m2_32s_atomic, new, m2_32_r1_at= omic, xor, nz32) - C(0xebe7, LAXG, RSY_a, ILA, r3, m2_64_atomic, new, m2_64_r1_atomic,= xor, nz64) + D(0xebf7, LAX, RSY_a, ILA, r3_32s, a2, new, in2_r1_32, lax, nz32, = MO_TESL) + D(0xebe7, LAXG, RSY_a, ILA, r3, a2, new, in2_r1, lax, nz64, MO_TEQ) /* LOAD AND OR */ - C(0xebf6, LAO, RSY_a, ILA, r3_32s, m2_32s_atomic, new, m2_32_r1_at= omic, or, nz32) - C(0xebe6, LAOG, RSY_a, ILA, r3, m2_64_atomic, new, m2_64_r1_atomic,= or, nz64) + D(0xebf6, LAO, RSY_a, ILA, r3_32s, a2, new, in2_r1_32, lao, nz32, = MO_TESL) + D(0xebe6, LAOG, RSY_a, ILA, r3, a2, new, in2_r1, lao, nz64, MO_TEQ) /* LOAD AND TEST */ C(0x1200, LTR, RR_a, Z, 0, r2_o, 0, cond_r1r2_32, mov2, s32) C(0xb902, LTGR, RRE, Z, 0, r2_o, 0, r1, mov2, s64) diff --git a/target/s390x/translate.c b/target/s390x/translate.c index ec250bb..f738c7b 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -2309,6 +2309,50 @@ static ExitStatus op_iske(DisasContext *s, DisasOps = *o) } #endif =20 +static ExitStatus op_laa(DisasContext *s, DisasOps *o) +{ + /* The real output is indeed the original value in memory; + recompute the addition for the computation of CC. */ + tcg_gen_atomic_fetch_add_i64(o->in2, o->in2, o->in1, get_mem_index(s), + s->insn->data | MO_ALIGN); + /* However, we need to recompute the addition for setting CC. */ + tcg_gen_add_i64(o->out, o->in1, o->in2); + return NO_EXIT; +} + +static ExitStatus op_lan(DisasContext *s, DisasOps *o) +{ + /* The real output is indeed the original value in memory; + recompute the addition for the computation of CC. */ + tcg_gen_atomic_fetch_and_i64(o->in2, o->in2, o->in1, get_mem_index(s), + s->insn->data | MO_ALIGN); + /* However, we need to recompute the operation for setting CC. */ + tcg_gen_and_i64(o->out, o->in1, o->in2); + return NO_EXIT; +} + +static ExitStatus op_lao(DisasContext *s, DisasOps *o) +{ + /* The real output is indeed the original value in memory; + recompute the addition for the computation of CC. */ + tcg_gen_atomic_fetch_or_i64(o->in2, o->in2, o->in1, get_mem_index(s), + s->insn->data | MO_ALIGN); + /* However, we need to recompute the operation for setting CC. */ + tcg_gen_or_i64(o->out, o->in1, o->in2); + return NO_EXIT; +} + +static ExitStatus op_lax(DisasContext *s, DisasOps *o) +{ + /* The real output is indeed the original value in memory; + recompute the addition for the computation of CC. */ + tcg_gen_atomic_fetch_xor_i64(o->in2, o->in2, o->in1, get_mem_index(s), + s->insn->data | MO_ALIGN); + /* However, we need to recompute the operation for setting CC. */ + tcg_gen_xor_i64(o->out, o->in1, o->in2); + return NO_EXIT; +} + static ExitStatus op_ldeb(DisasContext *s, DisasOps *o) { gen_helper_ldeb(o->out, cpu_env, o->in2); @@ -4483,21 +4527,17 @@ static void wout_m2_32(DisasContext *s, DisasFields= *f, DisasOps *o) } #define SPEC_wout_m2_32 0 =20 -static void wout_m2_32_r1_atomic(DisasContext *s, DisasFields *f, DisasOps= *o) +static void wout_in2_r1(DisasContext *s, DisasFields *f, DisasOps *o) { - /* XXX release reservation */ - tcg_gen_qemu_st32(o->out, o->addr1, get_mem_index(s)); - store_reg32_i64(get_field(f, r1), o->in2); + store_reg(get_field(f, r1), o->in2); } -#define SPEC_wout_m2_32_r1_atomic 0 +#define SPEC_wout_in2_r1 0 =20 -static void wout_m2_64_r1_atomic(DisasContext *s, DisasFields *f, DisasOps= *o) +static void wout_in2_r1_32(DisasContext *s, DisasFields *f, DisasOps *o) { - /* XXX release reservation */ - tcg_gen_qemu_st64(o->out, o->addr1, get_mem_index(s)); - store_reg(get_field(f, r1), o->in2); + store_reg32_i64(get_field(f, r1), o->in2); } -#define SPEC_wout_m2_64_r1_atomic 0 +#define SPEC_wout_in2_r1_32 0 =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* The "INput 1" generators. These load the first operand to an insn. */ @@ -4941,24 +4981,6 @@ static void in2_mri2_64(DisasContext *s, DisasFields= *f, DisasOps *o) } #define SPEC_in2_mri2_64 0 =20 -static void in2_m2_32s_atomic(DisasContext *s, DisasFields *f, DisasOps *o) -{ - /* XXX should reserve the address */ - in1_la2(s, f, o); - o->in2 =3D tcg_temp_new_i64(); - tcg_gen_qemu_ld32s(o->in2, o->addr1, get_mem_index(s)); -} -#define SPEC_in2_m2_32s_atomic 0 - -static void in2_m2_64_atomic(DisasContext *s, DisasFields *f, DisasOps *o) -{ - /* XXX should reserve the address */ - in1_la2(s, f, o); - o->in2 =3D tcg_temp_new_i64(); - tcg_gen_qemu_ld64(o->in2, o->addr1, get_mem_index(s)); -} -#define SPEC_in2_m2_64_atomic 0 - static void in2_i2(DisasContext *s, DisasFields *f, DisasOps *o) { o->in2 =3D tcg_const_i64(get_field(f, i2)); --=20 2.9.3