From patchwork Fri Apr 27 00:26:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 134540 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp90225lji; Thu, 26 Apr 2018 17:30:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrI0Dp8IYODvjQZx3De6or5it8mSWvbWIHEb6y0FLudlS+VyExk8HG5cxLJiDcoi5yUcRlp X-Received: by 2002:ac8:2dbb:: with SMTP id p56-v6mr212198qta.104.1524789047789; Thu, 26 Apr 2018 17:30:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524789047; cv=none; d=google.com; s=arc-20160816; b=kJhjXIzaV2VLj/GHcOUQO+xZasVJVRy1K8sgt2HU/b4RfnGIKBTgOP6bNTXy5OkLkf /XpqV8KqLrW7jZp7LqKnWSoIEBw0bXQyHaKzLFofsUKJ4PmStflNl62XIJ+KvTteacKr 9CjWeG3x5iUifUw6Lu7mJ74tOl9MWXLzVgZf2bxTHG2fojQz+tkU09pG/NSgnwEozr+f /ukO3EsfNmfi32OOkLCNYvJYRA6Vra7twp8UjsHLcl1y7fFRmAGmye3zhQzCGMeObA/w yZKKbq6mz9af8MQs76zNkXnKC3Sv+mawQEPtVQkSpRDwMKjRkNQR1WF0A2zyAjcjDc2r teng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=sEh2wGJE6rgMpMZZf3odblZRKaPH0BOzj0JTtUcsDDE=; b=FcqD6/ctDDBXc0l0EBDsBojeZAA86gK6TGd5oYGuPnMvLQJ0XjLjWhLoXH02OV6U/D +6TG6gt9LapHVb5NIGaYd4V42+cpQuexwVSK8PWBY5URROpGps1gn8LBasit/Pt/BNq3 Ej7+/pQTaFTUZFTPpzZr+PihsKRA3gLP+xFkQvXxbOS0Mjvpa2FcQwJMbUxBY/rruFkt gFn78L1y2eItpXK5jyBwcZp3QBRsqVATDzvHXxtz75wBXkUpIJ6eleCwVC3Mg7khNmrA AacyYIYdpyj1882klyIYQW4e7nuXOBMkNF2rjhTZg4NYVeCu/52RAUJLYYlAEThr1/Z+ wwXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FI1pOc0W; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z7-v6si110487qvc.143.2018.04.26.17.30.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 26 Apr 2018 17:30:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FI1pOc0W; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBrHj-0005N0-7G for patch@linaro.org; Thu, 26 Apr 2018 20:30:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBrEF-00026G-L1 for qemu-devel@nongnu.org; Thu, 26 Apr 2018 20:27:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBrEE-0004Uc-F1 for qemu-devel@nongnu.org; Thu, 26 Apr 2018 20:27:11 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:46801) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fBrEE-0004U5-AR for qemu-devel@nongnu.org; Thu, 26 Apr 2018 20:27:10 -0400 Received: by mail-pg0-x244.google.com with SMTP id z4-v6so134262pgu.13 for ; Thu, 26 Apr 2018 17:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sEh2wGJE6rgMpMZZf3odblZRKaPH0BOzj0JTtUcsDDE=; b=FI1pOc0WIAJOl2HQNSah4DIlYL2rd2/cHstiGpsYsuHJIn+XueVQVzmXYL0mWPdgPd MbNl9A8QziqmF8rtCHmu9JW0sqIJbDVYYVHaVKUaUEv+9NI0wem4S+HT1TTWaCMdmTUl gLcRyx6FHLJ9HyH/brwdBD+p/XRcYfYmFtYbQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sEh2wGJE6rgMpMZZf3odblZRKaPH0BOzj0JTtUcsDDE=; b=PzFgc97/fkTfbP0sYpS0i4nWHEzpu9GMbHU1tD/57wAKTnL8mhIMsxnL0mYYeHytVS T/bmmhY5XKTpN5uCptD+r8EwWkdZsyaNtltP2M5lx2deOppZIDshWzHpTnqRhS/w2Qw0 5hy38YY4Ube/2VP8qJ6exmNchH6AUN7gHRay/iWuiue4D7JrO4vn1wb+XzngKZsbNM4l vormsvyyDRtayimG3dUatEXeTT3Yp5VYSDnHYUOpZNRYJLiv4dhn9e0KFpwtFjjSS0Pq GB6+MAdhaWXuXY4F3vfOBOmOQYyT24QVAcs4g04hygu8Ntehp44rtaaE2GA1v4hCv0xx xqcQ== X-Gm-Message-State: ALQs6tBzEuCTIWUzbJvJaZLDUgWAcufFBWGiSFReRLiDaDgB2gfb3cSZ 942uvaxG7Ysu/6RuwnZFYoVhtM7ugNM= X-Received: by 2002:a63:af44:: with SMTP id s4-v6mr147975pgo.295.1524788829145; Thu, 26 Apr 2018 17:27:09 -0700 (PDT) Received: from cloudburst.twiddle.net.com ([2605:e000:112b:41da:c94c:5ee7:de92:7d78]) by smtp.gmail.com with ESMTPSA id g76sm86338pfj.102.2018.04.26.17.27.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Apr 2018 17:27:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 26 Apr 2018 14:26:47 -1000 Message-Id: <20180427002651.28356-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180427002651.28356-1-richard.henderson@linaro.org> References: <20180427002651.28356-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH 5/9] target/riscv: Use new atomic min/max expanders 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: Bastian Koppelmann , qemu-arm@nongnu.org, Michael Clark , Sagar Karandikar , Palmer Dabbelt Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: Michael Clark Cc: Palmer Dabbelt Cc: Sagar Karandikar Cc: Bastian Koppelmann Signed-off-by: Richard Henderson --- target/riscv/translate.c | 72 ++++++++++++++---------------------------------- 1 file changed, 20 insertions(+), 52 deletions(-) -- 2.14.3 Reviewed-by: Michael Clark diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 808eab7f50..9cab717088 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -725,7 +725,6 @@ static void gen_atomic(DisasContext *ctx, uint32_t opc, TCGv src1, src2, dat; TCGLabel *l1, *l2; TCGMemOp mop; - TCGCond cond; bool aq, rl; /* Extract the size of the atomic operation. */ @@ -823,60 +822,29 @@ static void gen_atomic(DisasContext *ctx, uint32_t opc, tcg_gen_atomic_fetch_or_tl(src2, src1, src2, ctx->mem_idx, mop); gen_set_gpr(rd, src2); break; - case OPC_RISC_AMOMIN: - cond = TCG_COND_LT; - goto do_minmax; - case OPC_RISC_AMOMAX: - cond = TCG_COND_GT; - goto do_minmax; - case OPC_RISC_AMOMINU: - cond = TCG_COND_LTU; - goto do_minmax; - case OPC_RISC_AMOMAXU: - cond = TCG_COND_GTU; - goto do_minmax; - do_minmax: - /* Handle the RL barrier. The AQ barrier is handled along the - parallel path by the SC atomic cmpxchg. On the serial path, - of course, barriers do not matter. */ - if (rl) { - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); - } - if (tb_cflags(ctx->tb) & CF_PARALLEL) { - l1 = gen_new_label(); - gen_set_label(l1); - } else { - l1 = NULL; - } - gen_get_gpr(src1, rs1); gen_get_gpr(src2, rs2); - if ((mop & MO_SSIZE) == MO_SL) { - /* Sign-extend the register comparison input. */ - tcg_gen_ext32s_tl(src2, src2); - } - dat = tcg_temp_local_new(); - tcg_gen_qemu_ld_tl(dat, src1, ctx->mem_idx, mop); - tcg_gen_movcond_tl(cond, src2, dat, src2, dat, src2); - - if (tb_cflags(ctx->tb) & CF_PARALLEL) { - /* Parallel context. Make this operation atomic by verifying - that the memory didn't change while we computed the result. */ - tcg_gen_atomic_cmpxchg_tl(src2, src1, dat, src2, ctx->mem_idx, mop); - - /* If the cmpxchg failed, retry. */ - /* ??? There is an assumption here that this will eventually - succeed, such that we don't live-lock. This is not unlike - a similar loop that the compiler would generate for e.g. - __atomic_fetch_and_xor, so don't worry about it. */ - tcg_gen_brcond_tl(TCG_COND_NE, dat, src2, l1); - } else { - /* Serial context. Directly store the result. */ - tcg_gen_qemu_st_tl(src2, src1, ctx->mem_idx, mop); - } - gen_set_gpr(rd, dat); - tcg_temp_free(dat); + tcg_gen_atomic_fetch_smin_tl(src2, src1, src2, ctx->mem_idx, mop); + gen_set_gpr(rd, src2); + break; + case OPC_RISC_AMOMAX: + gen_get_gpr(src1, rs1); + gen_get_gpr(src2, rs2); + tcg_gen_atomic_fetch_smax_tl(src2, src1, src2, ctx->mem_idx, mop); + gen_set_gpr(rd, src2); + break; + case OPC_RISC_AMOMINU: + gen_get_gpr(src1, rs1); + gen_get_gpr(src2, rs2); + tcg_gen_atomic_fetch_umin_tl(src2, src1, src2, ctx->mem_idx, mop); + gen_set_gpr(rd, src2); + break; + case OPC_RISC_AMOMAXU: + gen_get_gpr(src1, rs1); + gen_get_gpr(src2, rs2); + tcg_gen_atomic_fetch_umax_tl(src2, src1, src2, ctx->mem_idx, mop); + gen_set_gpr(rd, src2); break; default: