From patchwork Tue May 8 15:14:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135180 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4516522lji; Tue, 8 May 2018 08:20:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpt7eK1Fc2kz7cJ+9Y/DWQnVeF32WT8lkaOV7oIyZFzcUnDiX0wzoM11WCVohyISL26a2Tt X-Received: by 10.55.203.9 with SMTP id d9mr33613220qkj.95.1525792817750; Tue, 08 May 2018 08:20:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525792817; cv=none; d=google.com; s=arc-20160816; b=pGsYlrjWkpBU8tfD5NOX2gi6lEu4lRD6bsp9DdfsKkNx9EDGf4bwsL+giZajRmcJtn f0mjcqvs9sPaOWUKbzQUBqpoPqRu1zP+FpAF6/5HY7m8dQSrKdkpcoQiZvFcr5wMoov+ SRFtPG+DDCd8iZ7BoU2MTqOLmAgBRaLEp0QYunCRD6whiTFKyy0T1/3aJRcEbmShSYyc MKc1Wc/Utjrxm712hK+oPmyr1eNHTEruvZhz7KolLge5EIKhQ+W8/mr7R4L5AJjer5Vs 4R/HXQaiziUgSpowrWxmDvJuFMNpVlQcRp1JkZPP3kpFZAbLzP63IRr5k2y0fSsC9nfG PYJg== 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=EsGl25LvlT9EqBGGoFevS68sok0rgkMK1nuBmemsfhw=; b=KeQo7Q75EwpW6SFYHmZnFwheAQ7PVX4kxpcTHnj+ucKTt5Dar92N7EKm6lT6R6duIu 1fP+WfaWtbjwZACsZHO+PhKs/xtBKMsEufhTZFyrA+umSNFpP4Ky8zcasGsAwoWa61iA /eJibDKnSYfGbeY9SURL5lFhhIQiAlLEG8gSFhAktYYa7Odq6LzGJtarbimyU0MXlPew /x46L+4WEIa0tXCHEnsn9lDR6wOAhsh3eu+vhNB1HakrLyfjGsMHNQXva6gwC46wWbf8 jTQ9C/0mNzRVIvyErBgwzmKkPzkzRewuIDzTIB7NevCXm9l7kIx3PCkMyIKY0S/LH/wO njdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FCrnnNhX; 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 k64si9851628qkb.100.2018.05.08.08.20.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 May 2018 08:20:17 -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=FCrnnNhX; 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]:51831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4PZ-00021m-4r for patch@linaro.org; Tue, 08 May 2018 11:20:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4KI-0006dV-Ql for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG4KH-0008Cg-OV for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:50 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:40486) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4KH-0008C0-Hh for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:49 -0400 Received: by mail-pg0-x244.google.com with SMTP id l2-v6so21307656pgc.7 for ; Tue, 08 May 2018 08:14:49 -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=EsGl25LvlT9EqBGGoFevS68sok0rgkMK1nuBmemsfhw=; b=FCrnnNhXchISswLWQBILIuV7V1ZVK9EO8oSX1hhVA909NGPng/S2QECTjvreNvAeK4 1LX0VUfLQEpffxIY4oim7sPuDRbHAKeemrt8ScXjqpyWk4cuXcB1ysYOAc66G2WVPU44 dFXerUu6VgrAvhKcEoky4EcG/J5lmuL7yNL5g= 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=EsGl25LvlT9EqBGGoFevS68sok0rgkMK1nuBmemsfhw=; b=GFY7E8R401hwtvSRPslE2JueWDDVWs7GJqhKeeYGodWnnCJImWre4iZTIkc7EghiQx yvgeesU33dLgI+zTXtptxzqS7C6lJdq7J3rgGb0s9+3W5hD6qp1dZLO7c+RSey7XOOHj GU6eZSS9ujBRaKDzAijzEqr68csAL2j7xgiicJVotxXFNUyN/38OtBFXXrWE7mIr6JLE oswGD+alrLAQ+yg8ro9Inus9dDBz7u8XXTvfxZM3BR4bVp4W/bOC2mMJNHvMF/SWcedA Dp8yt72Z1aQ3J0ByB+b08GQIkar1OlbTXPk3qGwJ6/5jtUpuWgcKvbOXrDQYkGK+DD3k me/g== X-Gm-Message-State: ALQs6tCcsjU9YlelJutOy9hPmabo3431P8HsqFnx3CKshkx/l0RHOgE1 MkJFcizJsJwjuvjHBWPMCmx6C4Np04U= X-Received: by 10.98.130.140 with SMTP id w134mr32598723pfd.138.1525792488272; Tue, 08 May 2018 08:14:48 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id n10sm55598896pfj.68.2018.05.08.08.14.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:14:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 08:14:33 -0700 Message-Id: <20180508151437.4232-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180508151437.4232-1-richard.henderson@linaro.org> References: <20180508151437.4232-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 v3 06/10] 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Michael Clark Signed-off-by: Richard Henderson --- target/riscv/translate.c | 72 +++++++++++----------------------------- 1 file changed, 20 insertions(+), 52 deletions(-) -- 2.17.0 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: