From patchwork Tue May 8 15:14:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135177 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4513509lji; Tue, 8 May 2018 08:17:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoM3iYKnSvH2SQQliz1PFes6Mr1F8r8ODeVxGIubmbDuFxJJ+2iI2ovFrQ6hPAheqJxNuQS X-Received: by 2002:aed:3641:: with SMTP id e59-v6mr12423068qtb.341.1525792660361; Tue, 08 May 2018 08:17:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525792660; cv=none; d=google.com; s=arc-20160816; b=rPXQx9f81V3Ok+A4ZIsz5SIvsghQ6djRHd6cY9sK6bqpLSuxaFKuauPW6G3GRvRm0t 50XSTm1DLB0KZ1H6gO98HVOs1MOoJCg8BGbJyEaqShycsNW5mBhmw9w0jaxQ4wL7PGeT QDYsZnFt+GXZET84U1kJkANtLvINvD9XXRb9L0tIjTBsVffiq4NlQKmP/haeLYCRZaPd S6PGhTu78EabXiHRaGK9+KoZPUBhSp3O2LNfmEKZONz1+pUFGu15ga93gHFI4NSxOmaw yq/SJA2i/CIbqjymDWiJZ1sRhQqGk4Cek0PZVvYcjImTh556aiMihwMxb2+L4G9760pY QtuQ== 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=aE6V3PiTSNNT++yQIFfjD934zl2l9CsEY3U24eKhdTs=; b=N/ZZK0smgApjkB2BmcU/Nog97n/Xe9Go+gno+WFtO+PpalqdOKEAwDhzRud/jRaBGq dPInk39ss0eb6c+hSVlnFF1p1fVxhj6/cxQ2fqX24Z+muFx8oYSn6f5/IfGDwvTFD9q0 NN+bA+qTiMTHcsScq95or1fWGr4m5ScrrLGCIAkYs8CGlXM6mX2KSeICpFIKkMH6+A3a Y0A21CYeSVg8BS/jWfBfTmDyl/PnDGT4/2b9giS8coPeJRq0f2LJfJe2jZhXePETotJB 2t4Its7IF0ktZB31BHLvfqCpo7ZzMyAiK+UusVyI43LWawh2z6LVM4wp7TYg0Q9wNWf9 LBqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=etEpoO50; 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 f16-v6si2028000qvm.80.2018.05.08.08.17.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 May 2018 08:17:40 -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=etEpoO50; 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]:51816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4N1-00005D-O2 for patch@linaro.org; Tue, 08 May 2018 11:17:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4KC-0006Xe-Ua for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG4KA-00085k-8O for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:44 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:46991) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4KA-00085A-3M for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:42 -0400 Received: by mail-pg0-x242.google.com with SMTP id z4-v6so21298088pgu.13 for ; Tue, 08 May 2018 08:14:42 -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=aE6V3PiTSNNT++yQIFfjD934zl2l9CsEY3U24eKhdTs=; b=etEpoO500Zx1Ji2czEnjGQDQluhfJVJALZ3TqGGwT1KbsPHeJ5nt3zlvKQrktnoZ7r 6XoWdeg2Q06qAjqRQRkd6Z43t8tPI8X5dpmkqmeiZefF69g2hIDSWsa/1P4pKdZ8xplx 05wh46RraBSnFl+in2C1KWyhIVC50HqA9hDBU= 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=aE6V3PiTSNNT++yQIFfjD934zl2l9CsEY3U24eKhdTs=; b=Kx1BF3h03ZHjD+DazYRiLQZ3SCxuvugo5pF/M4P37DDokAk4RNBRfw92eJasj7YmUo KsoEMBbZfu+y3FYOo97WalN0wOshh1AxNiFtgQYQuKxsgraiHROMIFSFcg9N2ceK0C7q TcgtCe29RZSrLhsHI4AkGbMS6bMdfn7uJg+u1BmKvuvUyG7SZk3+SVwJsdYNslRA55iT HWAdofcr3q/PLp4QGyz3b2zXiOGVWYSDJ4fpl0lLZqOTGk90rIGorL5xFDXhDDWGwhS4 K04PQIq6/6Tnc5Jr9D7setFm8znrEZgJnk/srDRElquof7H9DDDOISGz87BbuD/+04M1 +AfQ== X-Gm-Message-State: ALQs6tD4qvVpijqGWfyS1UhhuCKJd5pven/PaJdM8F9HzltOsj9bQAEe YZ6YUlzBWziIwexrjP7LV2goTGudQhw= X-Received: by 10.98.157.137 with SMTP id a9mr40253017pfk.206.1525792480839; Tue, 08 May 2018 08:14:40 -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.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:14:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 08:14:28 -0700 Message-Id: <20180508151437.4232-2-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::242 Subject: [Qemu-devel] [PATCH v3 01/10] tcg: Introduce helpers for integer min/max 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" These operations are re-invented by several targets so far. Several supported hosts have insns for these, so place the expanders out-of-line for a future introduction of tcg opcodes. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/tcg-op.h | 16 ++++++++++++++++ tcg/tcg-op.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) -- 2.17.0 diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 5d2c91a1b6..0451e2752e 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -324,6 +324,10 @@ void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg); void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg); void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg); void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg); +void tcg_gen_smin_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); +void tcg_gen_smax_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); +void tcg_gen_umin_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); +void tcg_gen_umax_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); static inline void tcg_gen_discard_i32(TCGv_i32 arg) { @@ -517,6 +521,10 @@ void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg); void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg); void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg); void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg); +void tcg_gen_smin_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); +void tcg_gen_smax_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); +void tcg_gen_umin_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); +void tcg_gen_umax_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); #if TCG_TARGET_REG_BITS == 64 static inline void tcg_gen_discard_i64(TCGv_i64 arg) @@ -1025,6 +1033,10 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); #define tcg_gen_mulu2_tl tcg_gen_mulu2_i64 #define tcg_gen_muls2_tl tcg_gen_muls2_i64 #define tcg_gen_mulsu2_tl tcg_gen_mulsu2_i64 +#define tcg_gen_smin_tl tcg_gen_smin_i64 +#define tcg_gen_umin_tl tcg_gen_umin_i64 +#define tcg_gen_smax_tl tcg_gen_smax_i64 +#define tcg_gen_umax_tl tcg_gen_umax_i64 #define tcg_gen_atomic_cmpxchg_tl tcg_gen_atomic_cmpxchg_i64 #define tcg_gen_atomic_xchg_tl tcg_gen_atomic_xchg_i64 #define tcg_gen_atomic_fetch_add_tl tcg_gen_atomic_fetch_add_i64 @@ -1123,6 +1135,10 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); #define tcg_gen_mulu2_tl tcg_gen_mulu2_i32 #define tcg_gen_muls2_tl tcg_gen_muls2_i32 #define tcg_gen_mulsu2_tl tcg_gen_mulsu2_i32 +#define tcg_gen_smin_tl tcg_gen_smin_i32 +#define tcg_gen_umin_tl tcg_gen_umin_i32 +#define tcg_gen_smax_tl tcg_gen_smax_i32 +#define tcg_gen_umax_tl tcg_gen_umax_i32 #define tcg_gen_atomic_cmpxchg_tl tcg_gen_atomic_cmpxchg_i32 #define tcg_gen_atomic_xchg_tl tcg_gen_atomic_xchg_i32 #define tcg_gen_atomic_fetch_add_tl tcg_gen_atomic_fetch_add_i32 diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 34b96d68f3..5b82c3be8d 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -1033,6 +1033,26 @@ void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg) } } +void tcg_gen_smin_i32(TCGv_i32 ret, TCGv_i32 a, TCGv_i32 b) +{ + tcg_gen_movcond_i32(TCG_COND_LT, ret, a, b, a, b); +} + +void tcg_gen_umin_i32(TCGv_i32 ret, TCGv_i32 a, TCGv_i32 b) +{ + tcg_gen_movcond_i32(TCG_COND_LTU, ret, a, b, a, b); +} + +void tcg_gen_smax_i32(TCGv_i32 ret, TCGv_i32 a, TCGv_i32 b) +{ + tcg_gen_movcond_i32(TCG_COND_LT, ret, a, b, b, a); +} + +void tcg_gen_umax_i32(TCGv_i32 ret, TCGv_i32 a, TCGv_i32 b) +{ + tcg_gen_movcond_i32(TCG_COND_LTU, ret, a, b, b, a); +} + /* 64-bit ops */ #if TCG_TARGET_REG_BITS == 32 @@ -2438,6 +2458,26 @@ void tcg_gen_mulsu2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2) tcg_temp_free_i64(t2); } +void tcg_gen_smin_i64(TCGv_i64 ret, TCGv_i64 a, TCGv_i64 b) +{ + tcg_gen_movcond_i64(TCG_COND_LT, ret, a, b, a, b); +} + +void tcg_gen_umin_i64(TCGv_i64 ret, TCGv_i64 a, TCGv_i64 b) +{ + tcg_gen_movcond_i64(TCG_COND_LTU, ret, a, b, a, b); +} + +void tcg_gen_smax_i64(TCGv_i64 ret, TCGv_i64 a, TCGv_i64 b) +{ + tcg_gen_movcond_i64(TCG_COND_LT, ret, a, b, b, a); +} + +void tcg_gen_umax_i64(TCGv_i64 ret, TCGv_i64 a, TCGv_i64 b) +{ + tcg_gen_movcond_i64(TCG_COND_LTU, ret, a, b, b, a); +} + /* Size changing operations. */ void tcg_gen_extrl_i64_i32(TCGv_i32 ret, TCGv_i64 arg) From patchwork Tue May 8 15:14:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135181 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4518424lji; Tue, 8 May 2018 08:21:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp8KOmeBUanv7X9QuZ8IqTSlNe1rqP6L3Nl3EdEQhGEH4F/GdTv9U0h+zu9BtKZgdnhYP3m X-Received: by 2002:a0c:a3c3:: with SMTP id v61-v6mr30230362qvv.72.1525792915527; Tue, 08 May 2018 08:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525792915; cv=none; d=google.com; s=arc-20160816; b=Gwm0/ehveQOUBnwfhOwGGY2EIA8zjYmEhmkWzPa0DcZqqHnaT1WcLZZThuE0vrcNJY /qZ5xinsUAuze7i3Sm8kffjE7n6YbTF2XCcjcnzPPxLwVTdvPONMbtcxd4D96vPaKS0B F8PmSoxhdiV7v6NnSQ6brLMENVOEOTsDkAxzsy2VV5sljjn5FzST36VBOkm6KloIYc68 irfjDXaHhEtnPiPuCX6MRuT9KYC/kMwSKaLk9qXk0eODcDhbTw00PR5KMKbKBbQhUzD2 4YgKXIzaBY/dcaXxmUCySzlIhfw7woIdduLIVzAM7YZrLKKW29dtHZy411nzS5nn8dtA yF7w== 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=JPbKyRbGHUC+ZTBbJLdOh2b1BPPW3PUldr8irMjIU1o=; b=oddLrulksU3Svj0z4tN8t8WjooT3TQAuKRO7eZGAPpx2wMt3V+nVUE4QBo9tHH/EQ0 OHjJFKQT1qNYrMAh13Pvy6MgVI9HqGwdGrP+0KwPUGk3fAy/BFBwlPjXiCNpUgofhTk7 sjjLkQbhsR2aejuSCIg5thAYhjI0PQzKdA1onvIYB1qiBpi4lyu0sxmxdg7jOOyNBJp3 R4HJ3j/lOKLYmogiBbpkzGosFTlkLLSuX7CF2aiml62lUkXN5TeHWNcHy7GN/qPqtRf4 wKZXmdMMB8QPzPQK3EmNkTMKpi6K8v/b+JRtZsgDjtB3oYiSEg0luLpoo/eFEe0Bw+xt /pVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EoDaCnXQ; 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 m89-v6si5310896qva.63.2018.05.08.08.21.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 May 2018 08:21:55 -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=EoDaCnXQ; 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]:51846 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4R8-0003PL-UW for patch@linaro.org; Tue, 08 May 2018 11:21:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4KC-0006Xf-VO for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG4KB-000870-L1 for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:44 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:32940) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4KB-00086K-Ct for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:43 -0400 Received: by mail-pf0-x243.google.com with SMTP id f20so15325000pfn.0 for ; Tue, 08 May 2018 08:14:43 -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=JPbKyRbGHUC+ZTBbJLdOh2b1BPPW3PUldr8irMjIU1o=; b=EoDaCnXQMnPI1/jT/3Ak2hHHdPktlHZ4/W2fshpXlZ/gJi4WJNYhJgEwEiytKhi2q5 GGPGGbYGpmwDhMWAeAd1g+qGhcs1AUpDfCa6Jj4Pg9Mzit7OMGQ1i1/1pA7PIcFPiNRY 8BKNUdunjOy0756vuLwDR7nq4oDublViqKx74= 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=JPbKyRbGHUC+ZTBbJLdOh2b1BPPW3PUldr8irMjIU1o=; b=S9gzlhq90iySHt4zdalQjTGXzZ08NzUPJ8wvq2ATp5pLp6SJcnx6Awnqz8AHPUclag 1rU3NCksl6XIN5oe1YDEIsOUawO+oC5mfpomZeUV1stoeLsgWNS74AJYomXoVd6f9PuT 9k7gJq4EjolZdKOGtbqgEQH5QNY8DREoig6pWSWTb6ESbKODaeSLcNTSc74LWr3vxl8s kiRiFQEzCe60RVXoSpkq09J9acr/IqT+6w+VYScexqEEtUSoQ/tbDxhvetzqIfb1U/UJ +vbzMRTItYMA4v0m2PELKgOFR97PEsn9mnl1q2CdQK2DSK2Sj3U4+zNzDPwfWa1bO8Kf xVrA== X-Gm-Message-State: ALQs6tDVbPdyYPtgv4dDVxGhyBHF16kh3AO0U/sSQq3NPlNaPvSR5ASK PVn3PM3bnYWkgE2M6sUIEiuGqFSmC4M= X-Received: by 10.98.229.13 with SMTP id n13mr40432641pff.125.1525792482064; Tue, 08 May 2018 08:14:42 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:14:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 08:14:29 -0700 Message-Id: <20180508151437.4232-3-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:c00::243 Subject: [Qemu-devel] [PATCH v3 02/10] target/arm: Use new 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" The generic expanders replace nearly identical code in the translator. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 46 ++++++++++++-------------------------- 1 file changed, 14 insertions(+), 32 deletions(-) -- 2.17.0 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index bff4e13bf6..d916fea3a3 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -6021,15 +6021,18 @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn) tcg_gen_add_i64(tcg_res, tcg_res, tcg_elt); break; case 0x0a: /* SMAXV / UMAXV */ - tcg_gen_movcond_i64(is_u ? TCG_COND_GEU : TCG_COND_GE, - tcg_res, - tcg_res, tcg_elt, tcg_res, tcg_elt); + if (is_u) { + tcg_gen_umax_i64(tcg_res, tcg_res, tcg_elt); + } else { + tcg_gen_smax_i64(tcg_res, tcg_res, tcg_elt); + } break; case 0x1a: /* SMINV / UMINV */ - tcg_gen_movcond_i64(is_u ? TCG_COND_LEU : TCG_COND_LE, - tcg_res, - tcg_res, tcg_elt, tcg_res, tcg_elt); - break; + if (is_u) { + tcg_gen_umin_i64(tcg_res, tcg_res, tcg_elt); + } else { + tcg_gen_smin_i64(tcg_res, tcg_res, tcg_elt); + } break; default: g_assert_not_reached(); @@ -9931,27 +9934,6 @@ static void disas_simd_3same_logic(DisasContext *s, uint32_t insn) } } -/* Helper functions for 32 bit comparisons */ -static void gen_max_s32(TCGv_i32 res, TCGv_i32 op1, TCGv_i32 op2) -{ - tcg_gen_movcond_i32(TCG_COND_GE, res, op1, op2, op1, op2); -} - -static void gen_max_u32(TCGv_i32 res, TCGv_i32 op1, TCGv_i32 op2) -{ - tcg_gen_movcond_i32(TCG_COND_GEU, res, op1, op2, op1, op2); -} - -static void gen_min_s32(TCGv_i32 res, TCGv_i32 op1, TCGv_i32 op2) -{ - tcg_gen_movcond_i32(TCG_COND_LE, res, op1, op2, op1, op2); -} - -static void gen_min_u32(TCGv_i32 res, TCGv_i32 op1, TCGv_i32 op2) -{ - tcg_gen_movcond_i32(TCG_COND_LEU, res, op1, op2, op1, op2); -} - /* Pairwise op subgroup of C3.6.16. * * This is called directly or via the handle_3same_float for float pairwise @@ -10051,7 +10033,7 @@ static void handle_simd_3same_pair(DisasContext *s, int is_q, int u, int opcode, static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_pmax_s8, gen_helper_neon_pmax_u8 }, { gen_helper_neon_pmax_s16, gen_helper_neon_pmax_u16 }, - { gen_max_s32, gen_max_u32 }, + { tcg_gen_smax_i32, tcg_gen_umax_i32 }, }; genfn = fns[size][u]; break; @@ -10061,7 +10043,7 @@ static void handle_simd_3same_pair(DisasContext *s, int is_q, int u, int opcode, static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_pmin_s8, gen_helper_neon_pmin_u8 }, { gen_helper_neon_pmin_s16, gen_helper_neon_pmin_u16 }, - { gen_min_s32, gen_min_u32 }, + { tcg_gen_smin_i32, tcg_gen_umin_i32 }, }; genfn = fns[size][u]; break; @@ -10516,7 +10498,7 @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_max_s8, gen_helper_neon_max_u8 }, { gen_helper_neon_max_s16, gen_helper_neon_max_u16 }, - { gen_max_s32, gen_max_u32 }, + { tcg_gen_smax_i32, tcg_gen_umax_i32 }, }; genfn = fns[size][u]; break; @@ -10527,7 +10509,7 @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) static NeonGenTwoOpFn * const fns[3][2] = { { gen_helper_neon_min_s8, gen_helper_neon_min_u8 }, { gen_helper_neon_min_s16, gen_helper_neon_min_u16 }, - { gen_min_s32, gen_min_u32 }, + { tcg_gen_smin_i32, tcg_gen_umin_i32 }, }; genfn = fns[size][u]; break; From patchwork Tue May 8 15:14:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135179 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4515839lji; Tue, 8 May 2018 08:19:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq6Wu+PQDIyep3U37CI1LktE878Hz5haFku/KesF2jEyryemA7wt6wyZBCrSuiaY6dPlL7m X-Received: by 10.55.194.65 with SMTP id j1mr1551087qkm.108.1525792783099; Tue, 08 May 2018 08:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525792783; cv=none; d=google.com; s=arc-20160816; b=kPZl9LQ5/lzWU1Wif45CU7KYdhELHnvT482937fBybAatyaLzwTOL2jxt/1ImkAsb/ dblFFYnqWil/EzmJ9IIOpXnQGcH/SlUxBLj3umT/2N2gdkL+JdaobzVC27G84/UW+eYz KY04Q2o/dyOVN5kjOTcDzXp4u7Ol1aTarildWLS7wnOwrT3u0e6kKKPVHY7Yxb+SiADO V5fWIsaDsgSXokOIYtheAoldnh3RrLOVy1ybqIFp5CXDStRr2Mkm3aZUPa8bZUivF72c BAZc68sob52u+MQGx69GWsLIe94WeQ9ovvoefcsN80jW6TCLLpAmEAGIHkmdS3Kzjleq BmRA== 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=fw6BpfxewIu3YtIiReuneFzbAKyrC+lK3DRHx3c0Yd0=; b=NDDB+pGRc0fRCrJWaL1NIQAfYc83IsBpCkZXMlQtQWpZa2xvl+Algi2qZ0J+3/rSM5 4/Ps+FK8eimCEbJ1Sk6LpjBoU8PRbtMUZczPHu4Dr7x7KzQq6j54Odolx6TIuTvTyr9N 8C2CLecgrPhs4KSpnY8LE9cxqGlJXQU+b2OeR6mYDc9KxEQe8n+1wV35Ri9gxaVYwFBO F3U/TMVVMKVBpBzm8WYvPXpAlqVU6/oXWHNP4MbjDpEqsDneDC7JSly2g+Sd0EA8ntSM F/49fvWm0EyySyACj8iKzHLCTPiSoJ+aIMXqAAKlEQy1/aSjVSPuw9EliHCU83pHg5OC kOQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KgCMPxxJ; 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 m10-v6si1663726qtc.129.2018.05.08.08.19.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 May 2018 08:19:43 -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=KgCMPxxJ; 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]:51822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4P0-0000mC-HY for patch@linaro.org; Tue, 08 May 2018 11:19:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4KD-0006YX-Tq for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG4KC-00087t-PX for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:45 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:45547) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4KC-00087N-Jb for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:44 -0400 Received: by mail-pf0-x242.google.com with SMTP id c10so24105242pfi.12 for ; Tue, 08 May 2018 08:14:44 -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=fw6BpfxewIu3YtIiReuneFzbAKyrC+lK3DRHx3c0Yd0=; b=KgCMPxxJSH33MYqQEhr060e2rSZo6bIGTDY5K8WfQHbSitadgr/usyp7WKlMBUjcVS t/KDRQFV+NG96NM7STD9zyCqqtVddwrAufc5RzxGhLdYqRRiC9S2Gs48orhQNdWvinMS Ax8MiLypirJo+3f2gIS2N+xoq/BJA9RlL50k0= 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=fw6BpfxewIu3YtIiReuneFzbAKyrC+lK3DRHx3c0Yd0=; b=gA4gAOdkwzY5Dm8kpanY+TzjFbRjPzl9Bc3hbHapFx6Rn9AN8miXilZnmWpBASoslg T8o4lR1ARwQxo42f3K7Ear1f47ySKVBEQavMIB+N4oZQqaZ2LMeqQZbBUg6kYYPoHQbI uO2pxhQTGb+gLBYh3no06gpFPUtFHE6mmHoluXk29oqM/zrB5qcjeMlqipU+/Q4GqrwF HqiDruaIu9KFOwQe10eB8P72TT2QA4V0UFju06u5GlV5RH5usKCXJN+jW5R31tB/vqGt H7SRDCNkWWsJVRf/R5GYbr1b7yUnyYIdfs1Yb4PM99rthPGt7I7FCixRRdLbIWtupbiC Janw== X-Gm-Message-State: ALQs6tBCV3TXxKaFQibdk3nWWc1XBE9YVcUhOQsqCszFF9ydKL8K5b/B cac36FiONeXlt3GT7yHNSGY0SDhwEZg= X-Received: by 2002:a65:4189:: with SMTP id a9-v6mr32840918pgq.118.1525792483353; Tue, 08 May 2018 08:14:43 -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.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:14:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 08:14:30 -0700 Message-Id: <20180508151437.4232-4-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:c00::242 Subject: [Qemu-devel] [PATCH v3 03/10] target/xtensa: Use new 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" The generic expanders replace nearly identical code in the translator. Acked-by: Max Filippov Signed-off-by: Richard Henderson --- target/xtensa/translate.c | 50 ++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 17 deletions(-) -- 2.17.0 diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 4f6d03059f..bad5cdb009 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -1527,10 +1527,8 @@ static void translate_clamps(DisasContext *dc, const uint32_t arg[], TCGv_i32 tmp1 = tcg_const_i32(-1u << arg[2]); TCGv_i32 tmp2 = tcg_const_i32((1 << arg[2]) - 1); - tcg_gen_movcond_i32(TCG_COND_GT, tmp1, - cpu_R[arg[1]], tmp1, cpu_R[arg[1]], tmp1); - tcg_gen_movcond_i32(TCG_COND_LT, cpu_R[arg[0]], - tmp1, tmp2, tmp1, tmp2); + tcg_gen_smax_i32(tmp1, tmp1, cpu_R[arg[1]]); + tcg_gen_smin_i32(cpu_R[arg[0]], tmp1, tmp2); tcg_temp_free(tmp1); tcg_temp_free(tmp2); } @@ -1855,13 +1853,35 @@ static void translate_memw(DisasContext *dc, const uint32_t arg[], tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL); } -static void translate_minmax(DisasContext *dc, const uint32_t arg[], - const uint32_t par[]) +static void translate_smin(DisasContext *dc, const uint32_t arg[], + const uint32_t par[]) { if (gen_window_check3(dc, arg[0], arg[1], arg[2])) { - tcg_gen_movcond_i32(par[0], cpu_R[arg[0]], - cpu_R[arg[1]], cpu_R[arg[2]], - cpu_R[arg[1]], cpu_R[arg[2]]); + tcg_gen_smin_i32(cpu_R[arg[0]], cpu_R[arg[1]], cpu_R[arg[2]]); + } +} + +static void translate_umin(DisasContext *dc, const uint32_t arg[], + const uint32_t par[]) +{ + if (gen_window_check3(dc, arg[0], arg[1], arg[2])) { + tcg_gen_umin_i32(cpu_R[arg[0]], cpu_R[arg[1]], cpu_R[arg[2]]); + } +} + +static void translate_smax(DisasContext *dc, const uint32_t arg[], + const uint32_t par[]) +{ + if (gen_window_check3(dc, arg[0], arg[1], arg[2])) { + tcg_gen_smax_i32(cpu_R[arg[0]], cpu_R[arg[1]], cpu_R[arg[2]]); + } +} + +static void translate_umax(DisasContext *dc, const uint32_t arg[], + const uint32_t par[]) +{ + if (gen_window_check3(dc, arg[0], arg[1], arg[2])) { + tcg_gen_umax_i32(cpu_R[arg[0]], cpu_R[arg[1]], cpu_R[arg[2]]); } } @@ -2984,23 +3004,19 @@ static const XtensaOpcodeOps core_ops[] = { .par = (const uint32_t[]){TCG_COND_NE}, }, { .name = "max", - .translate = translate_minmax, - .par = (const uint32_t[]){TCG_COND_GE}, + .translate = translate_smax, }, { .name = "maxu", - .translate = translate_minmax, - .par = (const uint32_t[]){TCG_COND_GEU}, + .translate = translate_umax, }, { .name = "memw", .translate = translate_memw, }, { .name = "min", - .translate = translate_minmax, - .par = (const uint32_t[]){TCG_COND_LT}, + .translate = translate_smin, }, { .name = "minu", - .translate = translate_minmax, - .par = (const uint32_t[]){TCG_COND_LTU}, + .translate = translate_umin, }, { .name = "mov", .translate = translate_mov, From patchwork Tue May 8 15:14:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135183 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4520601lji; Tue, 8 May 2018 08:23:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp9GEfDEb3pn1qN/2pJOFPeQbrT0iAncx8Lw6bStIKkqhB6XG4P1lRTZ3ml+xGO3KwhCxrG X-Received: by 10.55.132.130 with SMTP id g124mr36370519qkd.226.1525793037381; Tue, 08 May 2018 08:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525793037; cv=none; d=google.com; s=arc-20160816; b=W89MEVGWJvtcYxJcynHAzTVYwghe+epM/6DWnJHHd9e0hH1a/BUR7CMTwMhHP+dstZ i2EKMFegVOynTBt8aM6nCB3X1WCOeKUK1IXKeoxVG8HhrMxhevP47f2yHcEznfRQvft/ qiEdFXTb9I8+/MxykEg6Yb9/EJFHFHFcQl1TKHsIteBMro3XGNVFdHRoi9b6INH48Rts nN5DwI7JWlfI7uhweKuDAs9zwk5z4PuEXPuuiDHuPhOHaCw7vpI0ML//SXtv8ao+X55y IjYnKWKeYg1XXjfPc4WUiYHKRPPcB0r0RHcrXfUyHTNuZRlwnczsj4kENU+krWoYlNau 3zdA== 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=FfEmHksR+3pyFv66trIAEh3WAKpOXw8plnaw/DUDLWg=; b=Bsnpl3nhFdXcUZsL+P8vqQTcPxaw5SqsAB4jS+yLs+ZjTe5Zl37gCeObaO8QSG5xSe RAgwyoyUAikDLv+t5xNihOQo/qSgyTEc+u9ccKLwDdM0/RjyzJWQrgiaYKggxdZJZhr8 3XkKuMi/EQT5kJBQeFnVTtQ8IgsO2Pix5OTval2NQycYQrQ2HYnzl7hu1sxg4OgnfZZ0 BixYa1t1WB9GDxZeTTxmOHShudnmqoMgBu4cRxFuCgojOKHVQWEyg7s/ugzQvlbC3UNQ lCK9j5QZZDzl+tjEyXxoG02fTCsZVFLWanWStRA3BPC+7o88cfYDGb5QoGLBfDNSknCZ h6YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aCLltiRl; 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 f14si5485398qke.321.2018.05.08.08.23.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 May 2018 08:23:57 -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=aCLltiRl; 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]:51848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4T6-0004KE-Pq for patch@linaro.org; Tue, 08 May 2018 11:23:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4KI-0006dd-U3 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 1fG4KE-00089U-86 for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:50 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:37977) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4KD-00088k-WD for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:46 -0400 Received: by mail-pf0-x243.google.com with SMTP id o76so24120276pfi.5 for ; Tue, 08 May 2018 08:14:45 -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=FfEmHksR+3pyFv66trIAEh3WAKpOXw8plnaw/DUDLWg=; b=aCLltiRlEuNDOkIFmsbDs0a7jfA/U8RNzL9w1x4SM9BKCMjoPbp4I3+EWP9lU4R6BB e1VGDwa9VWZUp4Us7gU+5gX0XJdVO1A5gVipKc/a+49uMJFy7BftmRUFtQiendaqZuo+ SkMVSq3C9KetIqorb6UeLrZB46OHREEfbBmcc= 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=FfEmHksR+3pyFv66trIAEh3WAKpOXw8plnaw/DUDLWg=; b=KdEXJpyJ/kzegcldAXKKle53UNPFIdx2m5grnVZK1fNFBvUn6l+HRRhaWVbJP3o8zP NQO8Xbg09ZunwifR8NnqTDiX5wRJza2dOvK4M8DL6Mapw68zCbjkEZeisf2ZpVAUocDx iirxKL5iLSKc7HL0a7oQTqPdjgV1awdphCyZa3gLwlViPFgHPZ93OEu+463pBv8W9Hxa 8u/QPtPEFNarSElrxKfQlo2butbRCeR088GsnATLoiaqMw9cGZGq8+puwY+lEog5QsCQ FkmlnMqUEjKf7eUsCNdEJq9dt06NaWESZvMMiow4Fp7OENyu+zELcCWdJaN3d+XE3bqy ThSA== X-Gm-Message-State: ALQs6tBRpchfeb6aMQ3K93EzoeE9KZWE5wQomVFGjdK44omg9EA0C9Jj sF1koftwNp6f/euJ4pcuvqaNkTgAL+4= X-Received: by 2002:a63:7b53:: with SMTP id k19-v6mr33282079pgn.146.1525792484730; Tue, 08 May 2018 08:14:44 -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.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:14:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 08:14:31 -0700 Message-Id: <20180508151437.4232-5-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:c00::243 Subject: [Qemu-devel] [PATCH v3 04/10] tcg: Introduce atomic helpers for integer min/max 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" Given that this atomic operation will be used by both risc-v and aarch64, let's not duplicate code across the two targets. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- accel/tcg/atomic_template.h | 71 +++++++++++++++++++++++++++++++++++++ accel/tcg/tcg-runtime.h | 8 +++++ tcg/tcg-op.h | 34 ++++++++++++++++++ tcg/tcg.h | 8 +++++ tcg/tcg-op.c | 8 +++++ 5 files changed, 129 insertions(+) -- 2.17.0 diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index e022df4571..2489dd3ec1 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -25,18 +25,22 @@ #elif DATA_SIZE == 8 # define SUFFIX q # define DATA_TYPE uint64_t +# define SDATA_TYPE int64_t # define BSWAP bswap64 #elif DATA_SIZE == 4 # define SUFFIX l # define DATA_TYPE uint32_t +# define SDATA_TYPE int32_t # define BSWAP bswap32 #elif DATA_SIZE == 2 # define SUFFIX w # define DATA_TYPE uint16_t +# define SDATA_TYPE int16_t # define BSWAP bswap16 #elif DATA_SIZE == 1 # define SUFFIX b # define DATA_TYPE uint8_t +# define SDATA_TYPE int8_t # define BSWAP #else # error unsupported data size @@ -118,6 +122,39 @@ GEN_ATOMIC_HELPER(or_fetch) GEN_ATOMIC_HELPER(xor_fetch) #undef GEN_ATOMIC_HELPER + +/* These helpers are, as a whole, full barriers. Within the helper, + * the leading barrier is explicit and the trailing barrier is within + * cmpxchg primitive. + */ +#define GEN_ATOMIC_HELPER_FN(X, FN, XDATA_TYPE, RET) \ +ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ + ABI_TYPE xval EXTRA_ARGS) \ +{ \ + ATOMIC_MMU_DECLS; \ + XDATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \ + XDATA_TYPE cmp, old, new, val = xval; \ + smp_mb(); \ + cmp = atomic_read__nocheck(haddr); \ + do { \ + old = cmp; new = FN(old, val); \ + cmp = atomic_cmpxchg__nocheck(haddr, old, new); \ + } while (cmp != old); \ + ATOMIC_MMU_CLEANUP; \ + return RET; \ +} + +GEN_ATOMIC_HELPER_FN(fetch_smin, MIN, SDATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(fetch_umin, MIN, DATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(fetch_smax, MAX, SDATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(fetch_umax, MAX, DATA_TYPE, old) + +GEN_ATOMIC_HELPER_FN(smin_fetch, MIN, SDATA_TYPE, new) +GEN_ATOMIC_HELPER_FN(umin_fetch, MIN, DATA_TYPE, new) +GEN_ATOMIC_HELPER_FN(smax_fetch, MAX, SDATA_TYPE, new) +GEN_ATOMIC_HELPER_FN(umax_fetch, MAX, DATA_TYPE, new) + +#undef GEN_ATOMIC_HELPER_FN #endif /* DATA SIZE >= 16 */ #undef END @@ -233,6 +270,39 @@ ABI_TYPE ATOMIC_NAME(add_fetch)(CPUArchState *env, target_ulong addr, ldo = ldn; } } + +/* These helpers are, as a whole, full barriers. Within the helper, + * the leading barrier is explicit and the trailing barrier is within + * cmpxchg primitive. + */ +#define GEN_ATOMIC_HELPER_FN(X, FN, XDATA_TYPE, RET) \ +ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ + ABI_TYPE xval EXTRA_ARGS) \ +{ \ + ATOMIC_MMU_DECLS; \ + XDATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \ + XDATA_TYPE ldo, ldn, old, new, val = xval; \ + smp_mb(); \ + ldn = atomic_read__nocheck(haddr); \ + do { \ + ldo = ldn; old = BSWAP(ldo); new = FN(old, val); \ + ldn = atomic_cmpxchg__nocheck(haddr, ldo, BSWAP(new)); \ + } while (ldo != ldn); \ + ATOMIC_MMU_CLEANUP; \ + return RET; \ +} + +GEN_ATOMIC_HELPER_FN(fetch_smin, MIN, SDATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(fetch_umin, MIN, DATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(fetch_smax, MAX, SDATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(fetch_umax, MAX, DATA_TYPE, old) + +GEN_ATOMIC_HELPER_FN(smin_fetch, MIN, SDATA_TYPE, new) +GEN_ATOMIC_HELPER_FN(umin_fetch, MIN, DATA_TYPE, new) +GEN_ATOMIC_HELPER_FN(smax_fetch, MAX, SDATA_TYPE, new) +GEN_ATOMIC_HELPER_FN(umax_fetch, MAX, DATA_TYPE, new) + +#undef GEN_ATOMIC_HELPER_FN #endif /* DATA_SIZE >= 16 */ #undef END @@ -241,5 +311,6 @@ ABI_TYPE ATOMIC_NAME(add_fetch)(CPUArchState *env, target_ulong addr, #undef BSWAP #undef ABI_TYPE #undef DATA_TYPE +#undef SDATA_TYPE #undef SUFFIX #undef DATA_SIZE diff --git a/accel/tcg/tcg-runtime.h b/accel/tcg/tcg-runtime.h index 2536959a18..1bd39d136d 100644 --- a/accel/tcg/tcg-runtime.h +++ b/accel/tcg/tcg-runtime.h @@ -125,11 +125,19 @@ GEN_ATOMIC_HELPERS(fetch_add) GEN_ATOMIC_HELPERS(fetch_and) GEN_ATOMIC_HELPERS(fetch_or) GEN_ATOMIC_HELPERS(fetch_xor) +GEN_ATOMIC_HELPERS(fetch_smin) +GEN_ATOMIC_HELPERS(fetch_umin) +GEN_ATOMIC_HELPERS(fetch_smax) +GEN_ATOMIC_HELPERS(fetch_umax) GEN_ATOMIC_HELPERS(add_fetch) GEN_ATOMIC_HELPERS(and_fetch) GEN_ATOMIC_HELPERS(or_fetch) GEN_ATOMIC_HELPERS(xor_fetch) +GEN_ATOMIC_HELPERS(smin_fetch) +GEN_ATOMIC_HELPERS(umin_fetch) +GEN_ATOMIC_HELPERS(smax_fetch) +GEN_ATOMIC_HELPERS(umax_fetch) GEN_ATOMIC_HELPERS(xchg) diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 0451e2752e..04eb3e9e17 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -898,6 +898,7 @@ void tcg_gen_atomic_cmpxchg_i64(TCGv_i64, TCGv, TCGv_i64, TCGv_i64, void tcg_gen_atomic_xchg_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); void tcg_gen_atomic_xchg_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); + void tcg_gen_atomic_fetch_add_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); void tcg_gen_atomic_fetch_add_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); void tcg_gen_atomic_fetch_and_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); @@ -906,6 +907,15 @@ void tcg_gen_atomic_fetch_or_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); void tcg_gen_atomic_fetch_or_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); void tcg_gen_atomic_fetch_xor_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); void tcg_gen_atomic_fetch_xor_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); +void tcg_gen_atomic_fetch_smin_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); +void tcg_gen_atomic_fetch_smin_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); +void tcg_gen_atomic_fetch_umin_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); +void tcg_gen_atomic_fetch_umin_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); +void tcg_gen_atomic_fetch_smax_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); +void tcg_gen_atomic_fetch_smax_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); +void tcg_gen_atomic_fetch_umax_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); +void tcg_gen_atomic_fetch_umax_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); + void tcg_gen_atomic_add_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); void tcg_gen_atomic_add_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); void tcg_gen_atomic_and_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); @@ -914,6 +924,14 @@ void tcg_gen_atomic_or_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); void tcg_gen_atomic_or_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); void tcg_gen_atomic_xor_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); void tcg_gen_atomic_xor_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); +void tcg_gen_atomic_smin_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); +void tcg_gen_atomic_smin_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); +void tcg_gen_atomic_umin_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); +void tcg_gen_atomic_umin_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); +void tcg_gen_atomic_smax_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); +void tcg_gen_atomic_smax_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); +void tcg_gen_atomic_umax_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp); +void tcg_gen_atomic_umax_fetch_i64(TCGv_i64, TCGv, TCGv_i64, TCGArg, TCGMemOp); void tcg_gen_mov_vec(TCGv_vec, TCGv_vec); void tcg_gen_dup_i32_vec(unsigned vece, TCGv_vec, TCGv_i32); @@ -1043,10 +1061,18 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); #define tcg_gen_atomic_fetch_and_tl tcg_gen_atomic_fetch_and_i64 #define tcg_gen_atomic_fetch_or_tl tcg_gen_atomic_fetch_or_i64 #define tcg_gen_atomic_fetch_xor_tl tcg_gen_atomic_fetch_xor_i64 +#define tcg_gen_atomic_fetch_smin_tl tcg_gen_atomic_fetch_smin_i64 +#define tcg_gen_atomic_fetch_umin_tl tcg_gen_atomic_fetch_umin_i64 +#define tcg_gen_atomic_fetch_smax_tl tcg_gen_atomic_fetch_smax_i64 +#define tcg_gen_atomic_fetch_umax_tl tcg_gen_atomic_fetch_umax_i64 #define tcg_gen_atomic_add_fetch_tl tcg_gen_atomic_add_fetch_i64 #define tcg_gen_atomic_and_fetch_tl tcg_gen_atomic_and_fetch_i64 #define tcg_gen_atomic_or_fetch_tl tcg_gen_atomic_or_fetch_i64 #define tcg_gen_atomic_xor_fetch_tl tcg_gen_atomic_xor_fetch_i64 +#define tcg_gen_atomic_smin_fetch_tl tcg_gen_atomic_smin_fetch_i64 +#define tcg_gen_atomic_umin_fetch_tl tcg_gen_atomic_umin_fetch_i64 +#define tcg_gen_atomic_smax_fetch_tl tcg_gen_atomic_smax_fetch_i64 +#define tcg_gen_atomic_umax_fetch_tl tcg_gen_atomic_umax_fetch_i64 #define tcg_gen_dup_tl_vec tcg_gen_dup_i64_vec #else #define tcg_gen_movi_tl tcg_gen_movi_i32 @@ -1145,10 +1171,18 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); #define tcg_gen_atomic_fetch_and_tl tcg_gen_atomic_fetch_and_i32 #define tcg_gen_atomic_fetch_or_tl tcg_gen_atomic_fetch_or_i32 #define tcg_gen_atomic_fetch_xor_tl tcg_gen_atomic_fetch_xor_i32 +#define tcg_gen_atomic_fetch_smin_tl tcg_gen_atomic_fetch_smin_i32 +#define tcg_gen_atomic_fetch_umin_tl tcg_gen_atomic_fetch_umin_i32 +#define tcg_gen_atomic_fetch_smax_tl tcg_gen_atomic_fetch_smax_i32 +#define tcg_gen_atomic_fetch_umax_tl tcg_gen_atomic_fetch_umax_i32 #define tcg_gen_atomic_add_fetch_tl tcg_gen_atomic_add_fetch_i32 #define tcg_gen_atomic_and_fetch_tl tcg_gen_atomic_and_fetch_i32 #define tcg_gen_atomic_or_fetch_tl tcg_gen_atomic_or_fetch_i32 #define tcg_gen_atomic_xor_fetch_tl tcg_gen_atomic_xor_fetch_i32 +#define tcg_gen_atomic_smin_fetch_tl tcg_gen_atomic_smin_fetch_i32 +#define tcg_gen_atomic_umin_fetch_tl tcg_gen_atomic_umin_fetch_i32 +#define tcg_gen_atomic_smax_fetch_tl tcg_gen_atomic_smax_fetch_i32 +#define tcg_gen_atomic_umax_fetch_tl tcg_gen_atomic_umax_fetch_i32 #define tcg_gen_dup_tl_vec tcg_gen_dup_i32_vec #endif diff --git a/tcg/tcg.h b/tcg/tcg.h index 75fbad128b..1ca985479b 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -1415,12 +1415,20 @@ GEN_ATOMIC_HELPER_ALL(fetch_sub) GEN_ATOMIC_HELPER_ALL(fetch_and) GEN_ATOMIC_HELPER_ALL(fetch_or) GEN_ATOMIC_HELPER_ALL(fetch_xor) +GEN_ATOMIC_HELPER_ALL(fetch_smin) +GEN_ATOMIC_HELPER_ALL(fetch_umin) +GEN_ATOMIC_HELPER_ALL(fetch_smax) +GEN_ATOMIC_HELPER_ALL(fetch_umax) GEN_ATOMIC_HELPER_ALL(add_fetch) GEN_ATOMIC_HELPER_ALL(sub_fetch) GEN_ATOMIC_HELPER_ALL(and_fetch) GEN_ATOMIC_HELPER_ALL(or_fetch) GEN_ATOMIC_HELPER_ALL(xor_fetch) +GEN_ATOMIC_HELPER_ALL(smin_fetch) +GEN_ATOMIC_HELPER_ALL(umin_fetch) +GEN_ATOMIC_HELPER_ALL(smax_fetch) +GEN_ATOMIC_HELPER_ALL(umax_fetch) GEN_ATOMIC_HELPER_ALL(xchg) diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 5b82c3be8d..6a914654f5 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -3051,11 +3051,19 @@ GEN_ATOMIC_HELPER(fetch_add, add, 0) GEN_ATOMIC_HELPER(fetch_and, and, 0) GEN_ATOMIC_HELPER(fetch_or, or, 0) GEN_ATOMIC_HELPER(fetch_xor, xor, 0) +GEN_ATOMIC_HELPER(fetch_smin, smin, 0) +GEN_ATOMIC_HELPER(fetch_umin, umin, 0) +GEN_ATOMIC_HELPER(fetch_smax, smax, 0) +GEN_ATOMIC_HELPER(fetch_umax, umax, 0) GEN_ATOMIC_HELPER(add_fetch, add, 1) GEN_ATOMIC_HELPER(and_fetch, and, 1) GEN_ATOMIC_HELPER(or_fetch, or, 1) GEN_ATOMIC_HELPER(xor_fetch, xor, 1) +GEN_ATOMIC_HELPER(smin_fetch, smin, 1) +GEN_ATOMIC_HELPER(umin_fetch, umin, 1) +GEN_ATOMIC_HELPER(smax_fetch, smax, 1) +GEN_ATOMIC_HELPER(umax_fetch, umax, 1) static void tcg_gen_mov2_i32(TCGv_i32 r, TCGv_i32 a, TCGv_i32 b) { From patchwork Tue May 8 15:14:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135178 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4514319lji; Tue, 8 May 2018 08:18:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpxySTeNrhz2I9V9e76FvnR5iwbO0lC863cUjDhBStzfyysJFs0t04VHSDY6uHUQWJmH9zW X-Received: by 2002:ac8:2ce3:: with SMTP id 32-v6mr36540866qtx.236.1525792699728; Tue, 08 May 2018 08:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525792699; cv=none; d=google.com; s=arc-20160816; b=MpAsn9YOVqBmV8/iSSbGmEvDVGvlZkCQZJ+5rxVv1npVYHWrlriR6d+riQlR+FtmUs Lc4CWJypoXCLrRpnPeHzfZyJ3AZ3O+Hzxvr7+x4Tyq0BrV/7CQKtrFIpGXPbKmNwDUKq iDCEakCCul9aNe76Hoi9YGcAYICZ8lp07YiKBkII9OIFbcg2iVNRu6BJ9Lm1pT02x07x bxZ6siCJGRzHgqhhGmEL6QfDkGp/XHmAzhD9dRyXbOBcHpgeMLxrGwEk+VlYNyGB81Pu nlyLsqzgkggi1jsqT/rydg/wXTmJ327Q/maiIjPegEE3t80/fVrF91/gU+WGga2l0nml CxhA== 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=HApj84Fe4eAK9Kd60kVbQtpsu/0PF5w5mrUbloNYPXc=; b=ikfUQNNzl9WAfvA5leGYKXcJTeZFmfDdROIYlSLfuSCTRPk1ZNwKscxknwL5KGiNRM 2mNDd6WYp/r3wiNrWESOcBYpRQCEHPdSHALXqUj3zZryoeWCitft1hoaVaLRM9aiKDgR 6T3csnmdjp7zfGncIN1wo5e9V3ed3mudX7LwyZTUZLe36UT6M/s088ZLkyQxtH9azBxW QWFmFnWrt6tQi9sJ2FmpdOhxTZvF+Xir13examR9CZ/FKv3BwVBC+xQyqlsLmyawEqR6 RxFyEjbGOYsmzwUOgRbwwJh98Qpu9tXUIUN1wPUf1k7mvqRgBFY/ekegCow3rR6YCOEW gbZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fsEe0nxl; 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 v6si2969883qkd.253.2018.05.08.08.18.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 May 2018 08:18:19 -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=fsEe0nxl; 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]:51819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4Nf-0000a8-56 for patch@linaro.org; Tue, 08 May 2018 11:18:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4KJ-0006eD-CA 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 1fG4KF-0008AY-HD for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:51 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:32941) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4KF-00089z-Af for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:47 -0400 Received: by mail-pf0-x244.google.com with SMTP id f20so15325092pfn.0 for ; Tue, 08 May 2018 08:14:47 -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=HApj84Fe4eAK9Kd60kVbQtpsu/0PF5w5mrUbloNYPXc=; b=fsEe0nxlC+xh+IXm8I9PQHxwLVKjqWm+5x3YnyGEcmz8bDYy95tlIZ3svbDpZV4bFB XoSdYTWvME68G/v+iBT/RmFLeG1AxEjYqV7Q10FGr+trNrwpztUTD4TxlJzENEZklB2e aMUvIIO60+LUq0G67wnIQlYdPEJ44ZzRwHsOo= 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=HApj84Fe4eAK9Kd60kVbQtpsu/0PF5w5mrUbloNYPXc=; b=UbxnjuaFpI7SP0brcClkLL/2PbgBqsN8TAvLwPGxfItlDLJQyg9cgYnP8INexwgw4t fBO50UPSM8OSqWlaG9oacWCUkc30+xMM4LVQwgRg87VVrN/nd7DkcsZoZmnp2gEADyIH 4W4AY0sNTUuiRMIlqROTLQFul2L0eYIZ17eUQVldVx97DkgAXZ24LmflmK7wSBAVfs/b GsD3qdBRNRyg/jAySNqvzScxXw3gwcXpebCN/LFGI2NDye9Vt/hc6B74s1Q0IhTOj6fn h7tPWSz8K8upJm8h2Eq0RxSipSUoiM9gK6QblTLY+ISXCMe5b7fcW0o7EKUwUgat8X4E Y0Rg== X-Gm-Message-State: ALQs6tBha26nGXSFZaj8ORVlxvbOZxfaZqd6hq91A+lG+LAEGZO/9bm5 0Y9oIy0GK5NgSmMi9wgxAfJ5q1g+ICo= X-Received: by 2002:a63:b406:: with SMTP id s6-v6mr33927907pgf.334.1525792486058; Tue, 08 May 2018 08:14:46 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:14:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 08:14:32 -0700 Message-Id: <20180508151437.4232-6-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:c00::244 Subject: [Qemu-devel] [PATCH v3 05/10] tcg: Use GEN_ATOMIC_HELPER_FN for opposite endian atomic add 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" Suggested-by: Peter Maydell Signed-off-by: Richard Henderson --- accel/tcg/atomic_template.h | 49 ++++++------------------------------- 1 file changed, 7 insertions(+), 42 deletions(-) -- 2.17.0 diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index 2489dd3ec1..3f41ef2782 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -229,48 +229,6 @@ GEN_ATOMIC_HELPER(xor_fetch) #undef GEN_ATOMIC_HELPER -/* Note that for addition, we need to use a separate cmpxchg loop instead - of bswaps for the reverse-host-endian helpers. */ -ABI_TYPE ATOMIC_NAME(fetch_add)(CPUArchState *env, target_ulong addr, - ABI_TYPE val EXTRA_ARGS) -{ - ATOMIC_MMU_DECLS; - DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; - DATA_TYPE ldo, ldn, ret, sto; - - ldo = atomic_read__nocheck(haddr); - while (1) { - ret = BSWAP(ldo); - sto = BSWAP(ret + val); - ldn = atomic_cmpxchg__nocheck(haddr, ldo, sto); - if (ldn == ldo) { - ATOMIC_MMU_CLEANUP; - return ret; - } - ldo = ldn; - } -} - -ABI_TYPE ATOMIC_NAME(add_fetch)(CPUArchState *env, target_ulong addr, - ABI_TYPE val EXTRA_ARGS) -{ - ATOMIC_MMU_DECLS; - DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; - DATA_TYPE ldo, ldn, ret, sto; - - ldo = atomic_read__nocheck(haddr); - while (1) { - ret = BSWAP(ldo) + val; - sto = BSWAP(ret); - ldn = atomic_cmpxchg__nocheck(haddr, ldo, sto); - if (ldn == ldo) { - ATOMIC_MMU_CLEANUP; - return ret; - } - ldo = ldn; - } -} - /* These helpers are, as a whole, full barriers. Within the helper, * the leading barrier is explicit and the trailing barrier is within * cmpxchg primitive. @@ -302,6 +260,13 @@ GEN_ATOMIC_HELPER_FN(umin_fetch, MIN, DATA_TYPE, new) GEN_ATOMIC_HELPER_FN(smax_fetch, MAX, SDATA_TYPE, new) GEN_ATOMIC_HELPER_FN(umax_fetch, MAX, DATA_TYPE, new) +/* Note that for addition, we need to use a separate cmpxchg loop instead + of bswaps for the reverse-host-endian helpers. */ +#define ADD(X, Y) (X + Y) +GEN_ATOMIC_HELPER_FN(fetch_add, ADD, DATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(add_fetch, ADD, DATA_TYPE, new) +#undef ADD + #undef GEN_ATOMIC_HELPER_FN #endif /* DATA_SIZE >= 16 */ 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: From patchwork Tue May 8 15:14:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135182 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4519873lji; Tue, 8 May 2018 08:23:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpwaIPKHw+KL27KsVR4LO8nSyS9FRJsR8iZTJBXWoSlVz0NHa3cnlXwk9tp7Y9pwvqLukii X-Received: by 2002:ac8:2c98:: with SMTP id 24-v6mr37775374qtw.420.1525792996006; Tue, 08 May 2018 08:23:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525792996; cv=none; d=google.com; s=arc-20160816; b=afqXeLVkokxwDWMRg/tcdcMq7aC1Mho3PEfY09fSmtPxA5P4W2q74eVuRsliSDEn3j JdSsK3CLgnQB6nov41R9qUHa7K45qYru9MwBMt3c6dVJAaVokViCaPncEFrJMF5eUfYA 23DH1uPzRrpRiAlMHPn0ZieTo6ZYgdg2x7gsDCX5gG4jNGFn3MGAB7dpnzV62VrL6x4T mlwzw88+CcIabaYe5RrUDeKBwIMx1qY0C6aM+5GgMGrd+dXLvI280BMOB8G/0R5HZ5R5 zl31nnnv3fgmzxL9Y/MV7EzfnY03nKzOM4WclrR6OhlfGbMamOE3exYolT+hj+nAo5gA NPcA== 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=bjgI3WauApoqD1F00+Lyrj50kR1HQs41odIFgtqZ3wM=; b=kf4pbgKs4u5L3x/bDm4XbyaGB/TPyR4xGuA3DawqNzens3Qeafv4UaBgM5GvesKeIb wJFjaKJKfuQXea8godbEKwkVYPrMmh1ZKoWm1U/kG7Kqdf1jt936ptNNSGr5b3aRARWe JmWFaAPPWbX4H1FA4t5DCIPla8J4FSTQYkLOEl/9nso9UI5gSGREaeF8m5eq95DdzLJA RP1uJFB4FnziQR54fA8J0dxI1oyK3I0pKbKrxXY39QktS8Ig6n6jjfhh43drBHOpbrZt uciwNTpnOeWI6K02rZszsDv/DNr+425UOMkHkDAz1cOIwFs+QDN0dI69mI1BDUpyChtY nKqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iy+NGVLt; 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 12-v6si4001655qtc.338.2018.05.08.08.23.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 May 2018 08:23:15 -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=iy+NGVLt; 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]:51851 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4SR-0004Xc-C4 for patch@linaro.org; Tue, 08 May 2018 11:23:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4KM-0006hZ-UA for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG4KJ-0008EI-2y for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:54 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:46192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4KI-0008DI-RW for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:51 -0400 Received: by mail-pl0-x242.google.com with SMTP id 59-v6so2415346plc.13 for ; Tue, 08 May 2018 08:14:50 -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=bjgI3WauApoqD1F00+Lyrj50kR1HQs41odIFgtqZ3wM=; b=iy+NGVLtENU/qjdcxD4X1aWFMt6YQ3xNZYzQwD/4ckoPI/0W3IAJD+D5g0Rv3fk45Q o0gdK6rFUPZ+6uGvWhJsDwF+PAOU2z2+L750YMlA7xksSkcktphnb2byxKlWD3bN1q0O dfM0VU1C8KINHhar2fQiwxqs3xG0HXdmFBuM4= 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=bjgI3WauApoqD1F00+Lyrj50kR1HQs41odIFgtqZ3wM=; b=QhTwfQ7S4G/6uOvF3Z5spRtv4OfhSR/Wh/v+1/UBCnHlKuyy2fIRU/xvXPmuA04IAb I2pGwbdKcmEt0Tr3mfiShuIKff0oznKcWFCbnXkjWbMAOW4L4EppMX0z4L1IuywU1EmI 8tmNM2mywqw4SjZr6MnOlJxXVQf46vRVJQWErrsfGizwZ/J/gQW15jGRGpfXt1NddA3R 8KPNJow2v+t1WEFDNpxEzKiYMt/khzBDOQCXgzKEaKfCndml9WD293Dg0RSB4oVefTPZ zEsbGwR3qlNfWbqxkswf9S8AzPi88/o0k60J2wg+yQN4iIeQZp2lSdSWMk1Ne7D+d6kV BMJQ== X-Gm-Message-State: ALQs6tCq1Ure0N+/iBPdSO7tBKLqGxU+maphDHiDn5q3Wtz4ivS2nk+O vTgx4RwLrJ6A2PhGqrVAYJlIR6W38jY= X-Received: by 2002:a17:902:9304:: with SMTP id bc4-v6mr19351096plb.189.1525792489499; Tue, 08 May 2018 08:14:49 -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.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:14:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 08:14:34 -0700 Message-Id: <20180508151437.4232-8-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:c01::242 Subject: [Qemu-devel] [PATCH v3 07/10] target/arm: Introduce ARM_FEATURE_V8_ATOMICS and initial decode 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" The insns in the ARMv8.1-Atomics are added to the existing load/store exclusive and load/store reg opcode spaces. Rearrange the top-level decoders for these to accomodate. The Atomics insns themselves still generate Unallocated. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 2 + linux-user/elfload.c | 1 + target/arm/translate-a64.c | 182 +++++++++++++++++++++++++++---------- 3 files changed, 139 insertions(+), 46 deletions(-) -- 2.17.0 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 44e6b77151..f71a78d908 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1449,6 +1449,8 @@ enum arm_features { ARM_FEATURE_V8_SHA3, /* implements SHA3 part of v8 Crypto Extensions */ ARM_FEATURE_V8_SM3, /* implements SM3 part of v8 Crypto Extensions */ ARM_FEATURE_V8_SM4, /* implements SM4 part of v8 Crypto Extensions */ + ARM_FEATURE_V8_1, + ARM_FEATURE_V8_ATOMICS = ARM_FEATURE_V8_1, /* mandatory extension */ ARM_FEATURE_V8_RDM, /* implements v8.1 simd round multiply */ ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */ ARM_FEATURE_V8_FCMA, /* has complex number part of v8.3 extensions. */ diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 36d52194bc..13bc78d0c8 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -581,6 +581,7 @@ static uint32_t get_elf_hwcap(void) GET_FEATURE(ARM_FEATURE_V8_SHA512, ARM_HWCAP_A64_SHA512); GET_FEATURE(ARM_FEATURE_V8_FP16, ARM_HWCAP_A64_FPHP | ARM_HWCAP_A64_ASIMDHP); + GET_FEATURE(ARM_FEATURE_V8_ATOMICS, ARM_HWCAP_A64_ATOMICS); GET_FEATURE(ARM_FEATURE_V8_RDM, ARM_HWCAP_A64_ASIMDRDM); GET_FEATURE(ARM_FEATURE_V8_FCMA, ARM_HWCAP_A64_FCMA); #undef GET_FEATURE diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index d916fea3a3..6acad791e6 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -2147,62 +2147,98 @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) int rt = extract32(insn, 0, 5); int rn = extract32(insn, 5, 5); int rt2 = extract32(insn, 10, 5); - int is_lasr = extract32(insn, 15, 1); int rs = extract32(insn, 16, 5); - int is_pair = extract32(insn, 21, 1); - int is_store = !extract32(insn, 22, 1); - int is_excl = !extract32(insn, 23, 1); + int is_lasr = extract32(insn, 15, 1); + int o2_L_o1_o0 = extract32(insn, 21, 3) * 2 | is_lasr; int size = extract32(insn, 30, 2); TCGv_i64 tcg_addr; - if ((!is_excl && !is_pair && !is_lasr) || - (!is_excl && is_pair) || - (is_pair && size < 2)) { - unallocated_encoding(s); + switch (o2_L_o1_o0) { + case 0x0: /* STXR */ + case 0x1: /* STLXR */ + if (rn == 31) { + gen_check_sp_alignment(s); + } + if (is_lasr) { + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); + } + tcg_addr = read_cpu_reg_sp(s, rn, 1); + gen_store_exclusive(s, rs, rt, rt2, tcg_addr, size, false); return; - } - if (rn == 31) { - gen_check_sp_alignment(s); - } - tcg_addr = read_cpu_reg_sp(s, rn, 1); - - /* Note that since TCG is single threaded load-acquire/store-release - * semantics require no extra if (is_lasr) { ... } handling. - */ - - if (is_excl) { - if (!is_store) { - s->is_ldex = true; - gen_load_exclusive(s, rt, rt2, tcg_addr, size, is_pair); - if (is_lasr) { - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); - } - } else { - if (is_lasr) { - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); - } - gen_store_exclusive(s, rs, rt, rt2, tcg_addr, size, is_pair); + case 0x4: /* LDXR */ + case 0x5: /* LDAXR */ + if (rn == 31) { + gen_check_sp_alignment(s); } - } else { - TCGv_i64 tcg_rt = cpu_reg(s, rt); - bool iss_sf = disas_ldst_compute_iss_sf(size, false, 0); + tcg_addr = read_cpu_reg_sp(s, rn, 1); + s->is_ldex = true; + gen_load_exclusive(s, rt, rt2, tcg_addr, size, false); + if (is_lasr) { + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); + } + return; + case 0x9: /* STLR */ /* Generate ISS for non-exclusive accesses including LASR. */ - if (is_store) { + if (rn == 31) { + gen_check_sp_alignment(s); + } + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); + tcg_addr = read_cpu_reg_sp(s, rn, 1); + do_gpr_st(s, cpu_reg(s, rt), tcg_addr, size, true, rt, + disas_ldst_compute_iss_sf(size, false, 0), is_lasr); + return; + + case 0xd: /* LDAR */ + /* Generate ISS for non-exclusive accesses including LASR. */ + if (rn == 31) { + gen_check_sp_alignment(s); + } + tcg_addr = read_cpu_reg_sp(s, rn, 1); + do_gpr_ld(s, cpu_reg(s, rt), tcg_addr, size, false, false, true, rt, + disas_ldst_compute_iss_sf(size, false, 0), is_lasr); + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); + return; + + case 0x2: case 0x3: /* CASP / STXP */ + if (size & 2) { /* STXP / STLXP */ + if (rn == 31) { + gen_check_sp_alignment(s); + } if (is_lasr) { tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); } - do_gpr_st(s, tcg_rt, tcg_addr, size, - true, rt, iss_sf, is_lasr); - } else { - do_gpr_ld(s, tcg_rt, tcg_addr, size, false, false, - true, rt, iss_sf, is_lasr); + tcg_addr = read_cpu_reg_sp(s, rn, 1); + gen_store_exclusive(s, rs, rt, rt2, tcg_addr, size, true); + return; + } + /* CASP / CASPL */ + break; + + case 0x6: case 0x7: /* CASP / LDXP */ + if (size & 2) { /* LDXP / LDAXP */ + if (rn == 31) { + gen_check_sp_alignment(s); + } + tcg_addr = read_cpu_reg_sp(s, rn, 1); + s->is_ldex = true; + gen_load_exclusive(s, rt, rt2, tcg_addr, size, true); if (is_lasr) { tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); } + return; } + /* CASPA / CASPAL */ + break; + + case 0xa: /* CAS */ + case 0xb: /* CASL */ + case 0xe: /* CASA */ + case 0xf: /* CASAL */ + break; } + unallocated_encoding(s); } /* @@ -2715,6 +2751,55 @@ static void disas_ldst_reg_unsigned_imm(DisasContext *s, uint32_t insn, } } +/* Atomic memory operations + * + * 31 30 27 26 24 22 21 16 15 12 10 5 0 + * +------+-------+---+-----+-----+---+----+----+-----+-----+----+-----+ + * | size | 1 1 1 | V | 0 0 | A R | 1 | Rs | o3 | opc | 0 0 | Rn | Rt | + * +------+-------+---+-----+-----+--------+----+-----+-----+----+-----+ + * + * Rt: the result register + * Rn: base address or SP + * Rs: the source register for the operation + * V: vector flag (always 0 as of v8.3) + * A: acquire flag + * R: release flag + */ +static void disas_ldst_atomic(DisasContext *s, uint32_t insn, + int size, int rt, bool is_vector) +{ + int rs = extract32(insn, 16, 5); + int rn = extract32(insn, 5, 5); + int o3_opc = extract32(insn, 12, 4); + int feature = ARM_FEATURE_V8_ATOMICS; + + if (is_vector) { + unallocated_encoding(s); + return; + } + switch (o3_opc) { + case 000: /* LDADD */ + case 001: /* LDCLR */ + case 002: /* LDEOR */ + case 003: /* LDSET */ + case 004: /* LDSMAX */ + case 005: /* LDSMIN */ + case 006: /* LDUMAX */ + case 007: /* LDUMIN */ + case 010: /* SWP */ + default: + unallocated_encoding(s); + return; + } + if (!arm_dc_feature(s, feature)) { + unallocated_encoding(s); + return; + } + + (void)rs; + (void)rn; +} + /* Load/store register (all forms) */ static void disas_ldst_reg(DisasContext *s, uint32_t insn) { @@ -2725,23 +2810,28 @@ static void disas_ldst_reg(DisasContext *s, uint32_t insn) switch (extract32(insn, 24, 2)) { case 0: - if (extract32(insn, 21, 1) == 1 && extract32(insn, 10, 2) == 2) { - disas_ldst_reg_roffset(s, insn, opc, size, rt, is_vector); - } else { + if (extract32(insn, 21, 1) == 0) { /* Load/store register (unscaled immediate) * Load/store immediate pre/post-indexed * Load/store register unprivileged */ disas_ldst_reg_imm9(s, insn, opc, size, rt, is_vector); + return; + } + switch (extract32(insn, 10, 2)) { + case 0: + disas_ldst_atomic(s, insn, size, rt, is_vector); + return; + case 2: + disas_ldst_reg_roffset(s, insn, opc, size, rt, is_vector); + return; } break; case 1: disas_ldst_reg_unsigned_imm(s, insn, opc, size, rt, is_vector); - break; - default: - unallocated_encoding(s); - break; + return; } + unallocated_encoding(s); } /* AdvSIMD load/store multiple structures From patchwork Tue May 8 15:14:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135185 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4523544lji; Tue, 8 May 2018 08:26:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq72tsQ2Uk9ZZskdsq1avErXm40qcK3/vbkOpw1z4QSdUwIgeeVyQHsozp5B3+uoKnHALXQ X-Received: by 10.55.194.65 with SMTP id j1mr1577414qkm.108.1525793198538; Tue, 08 May 2018 08:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525793198; cv=none; d=google.com; s=arc-20160816; b=UAP9AAgrSgFpFatYFSTTd3R/8TWqD/NKEyQPuuScx0xMnXqaF+NDSbk7tyJzHad9Wp FDvHrMxxDFeNRjAXpp5Q/qc34VSkfQ+3PTPV5O49IziYNXknaCEmKfGjT+SfO4MHG24O ovLB3zySb7DR95ui7QgGZqI5RTBZSvSeIiJR6hk0JkfDRk13YIvApJWJzkUPaJhw+IaW 18uFidRRM9F8U0XzPHNHeLopjeKjW/QElDn/+2ichxtwYHfIZA9ThvauywokCaDPoHu8 uMeGClJ5vClb8y4Huo2wQmUPPAbOCON+WqzNllgyuxGRZEXSfxvjZY/qB8lnkBtiEKZP qyNA== 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=8rcPASnE+C7rW9/bI3AEK2ZVz+3GRCpBYozOZLaQ8f8=; b=wbBlVw1yD/e3VN1hxWuACb0Y7yVLZRzzJWwStnao8pNRi1BWgqdTEuyIv3ran74SVS yFSEOSo6RXgfi/n2ukGtf4nhMY0WtYODLjt8EYftmT3emtlhZpTAffRYEhKevQhk3uQT Ti7++C+RTbmnEmr42PNeq5Gd/QWEj0NsQkXm00IP6uOssAfW6UnUztpUmIB5CUz93XZM vje3bRXZr7b8UlrNDrQ6FfF846sY/YF/e0QUM1FrLdupofMu81DpOz/PV3Z/JSF9YfoM em0hF8Qyryxu3Kk6/Y29Ubw9tnUWad2VdJGDDG0I8KgOcXHC4ISlgou00oQUCKRgITBd j0gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C+/sOXwV; 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 e44-v6si894529qvd.129.2018.05.08.08.26.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 May 2018 08:26:38 -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=C+/sOXwV; 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]:51871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4Vh-0007YN-RD for patch@linaro.org; Tue, 08 May 2018 11:26:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4KM-0006hY-U9 for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG4KK-0008Fs-9T for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:54 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:35145) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4KK-0008Ex-4m for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:52 -0400 Received: by mail-pl0-x241.google.com with SMTP id i5-v6so2416543plt.2 for ; Tue, 08 May 2018 08:14:52 -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=8rcPASnE+C7rW9/bI3AEK2ZVz+3GRCpBYozOZLaQ8f8=; b=C+/sOXwV2h4jn9oE5bnTe/cCvgX58TgMsBIEL9aKnhhG6Lc0QjddF83W/oxnsnLvap SkKtaINBwAA3akK5I35xYoWfqq7+UFZ0TSkcCRdx+gH5OlDj4LEHRicQUlaOBiqbEO2L gZAlPS/JAW5pg8Fr0JZRPY9VRzr0icu/gkdOo= 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=8rcPASnE+C7rW9/bI3AEK2ZVz+3GRCpBYozOZLaQ8f8=; b=Ud6HruYv7Tx+q30xEb/Pzs8EiuYklV3pf3bEWteeMBjl84PsLe4V/EeRpyKYqKAGJr L6UTvSLeRgbyyr0fvX8MQ82tyoWKAVfzIatrffN5GCGZ7YteRFJ1bgPmdymjudsssQif NTYqTEVe2IS2N9KPc2hEtjd0Y9UCFSegnbATl8cIk2nRFx97u6kj2AWMnD2cOEgxavMA tjnFMu5Hv3XAdHLtsnSd48rR8V7cRV65AgSa7N3giTH+Q2iTSKUT7TmZ7qTtUCVnItF0 AgN1GAsuwRhxAG4Tt7ThLagbnKYL9KIurKopP5Nc99UvXU5hWIidEqQdBdi6kBOq574S yqnA== X-Gm-Message-State: ALQs6tAfyhotg5PRxnvHy1yS+RtsWcQYC6ktBtyjoPMj5whSWqor5eMv DwGhkTu31KXcxxtS+P4fkpjKxjiFe0s= X-Received: by 2002:a17:902:b485:: with SMTP id y5-v6mr10138235plr.381.1525792490916; Tue, 08 May 2018 08:14:50 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:14:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 08:14:35 -0700 Message-Id: <20180508151437.4232-9-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:c01::241 Subject: [Qemu-devel] [PATCH v3 08/10] target/arm: Fill in disas_ldst_atomic 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" This implements all of the v8.1-Atomics instructions except for compare-and-swap, which is decoded elsewhere. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) -- 2.17.0 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 6acad791e6..c13858a690 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -84,6 +84,7 @@ typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64); typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr); typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); +typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, TCGMemOp); /* Note that the gvec expanders operate on offsets + sizes. */ typedef void GVecGen2Fn(unsigned, uint32_t, uint32_t, uint32_t, uint32_t); @@ -2772,6 +2773,8 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, int rn = extract32(insn, 5, 5); int o3_opc = extract32(insn, 12, 4); int feature = ARM_FEATURE_V8_ATOMICS; + TCGv_i64 tcg_rn, tcg_rs; + AtomicThreeOpFn *fn; if (is_vector) { unallocated_encoding(s); @@ -2779,14 +2782,32 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, } switch (o3_opc) { case 000: /* LDADD */ + fn = tcg_gen_atomic_fetch_add_i64; + break; case 001: /* LDCLR */ + fn = tcg_gen_atomic_fetch_and_i64; + break; case 002: /* LDEOR */ + fn = tcg_gen_atomic_fetch_xor_i64; + break; case 003: /* LDSET */ + fn = tcg_gen_atomic_fetch_or_i64; + break; case 004: /* LDSMAX */ + fn = tcg_gen_atomic_fetch_smax_i64; + break; case 005: /* LDSMIN */ + fn = tcg_gen_atomic_fetch_smin_i64; + break; case 006: /* LDUMAX */ + fn = tcg_gen_atomic_fetch_umax_i64; + break; case 007: /* LDUMIN */ + fn = tcg_gen_atomic_fetch_umin_i64; + break; case 010: /* SWP */ + fn = tcg_gen_atomic_xchg_i64; + break; default: unallocated_encoding(s); return; @@ -2796,8 +2817,21 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, return; } - (void)rs; - (void)rn; + if (rn == 31) { + gen_check_sp_alignment(s); + } + tcg_rn = cpu_reg_sp(s, rn); + tcg_rs = read_cpu_reg(s, rs, true); + + if (o3_opc == 1) { /* LDCLR */ + tcg_gen_not_i64(tcg_rs, tcg_rs); + } + + /* The tcg atomic primitives are all full barriers. Therefore we + * can ignore the Acquire and Release bits of this instruction. + */ + fn(cpu_reg(s, rt), tcg_rn, tcg_rs, get_mem_index(s), + s->be_data | size | MO_ALIGN); } /* Load/store register (all forms) */ From patchwork Tue May 8 15:14:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135184 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4522824lji; Tue, 8 May 2018 08:25:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpZsALAHOwRcswWov/dYMMDSep+K6vBq+4hZAIB2zAUDhSIl4IB1eXr1tO8g1lZIhBBAfaf X-Received: by 2002:a0c:965a:: with SMTP id 26-v6mr22418040qvy.133.1525793159681; Tue, 08 May 2018 08:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525793159; cv=none; d=google.com; s=arc-20160816; b=R42cEzDeYS9rRo1EdrYNsinQjLolHpH/QpCs3X18iDc77EmdKXCMAuCsQULY8h8yb6 ZhbMow3PRgecUb+PXM/5QT1QY1UJGqQQvZV5kYs17GKucNdhMAQ4PwvfPkvI/wXkGhnz 8BtGHmLWA3tGZkP5m1JAQftz6M4uWaXT348SLmwfiE3F83+u+Jk1CYhhsBswaarMA5X1 CpS7mt/FtHguWC85Xgn/q2GNhFQAivDe5+E0S3PccZB6oxi3SjjQm2q81TO7RRS48/89 XUzLrdJ5xyXoz4nQukXpLUEQM36fPHwaeV9xr2cEnAR0yVBHWIllU7CW4fWuMSo9m3wc Q5dA== 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=7A9XEgWChxB+rPK5/XKmD/6XiegwwZSHREIlzYhR5iU=; b=w+uT/I1wnec37DUGr/oHZpUrqLymU+J37Lb/7Hc9NIy6v+o3/e6yOc6hn80VRufU74 DfxA93SyTlh+1boFOkxbN8bsn3J0KfUB8zDB396dlaO4QBUkl1SS9YqTgKBV8R14wXVw IONV2ZgZBOBaEYKtBawlbeYyxjVZtzRvdGS+goQSaDtclJ3y7LCJTLh1xoHieKL5YoMm MroUNaszK8HAgz/YdFCr3ytwnYRlA7nFVwFNMkUVum90City/bhEe1Vufmio4LGtM0+G P7nX6ys1FrF5VLyjeVTrS1Yjg5F/aiPM2fIYaI9+y9lfwnSFkZgHWYQ74eMGUStkQS+Y 2ylA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WWtIr9PV; 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 f8-v6si1302915qvo.2.2018.05.08.08.25.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 May 2018 08:25:59 -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=WWtIr9PV; 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]:51873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4V5-0007pw-2o for patch@linaro.org; Tue, 08 May 2018 11:25:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4KN-0006iE-En for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG4KL-0008Hb-L1 for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:55 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:41706) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4KL-0008Gk-Ct for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:53 -0400 Received: by mail-pl0-x243.google.com with SMTP id az12-v6so2410949plb.8 for ; Tue, 08 May 2018 08:14:53 -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=7A9XEgWChxB+rPK5/XKmD/6XiegwwZSHREIlzYhR5iU=; b=WWtIr9PVwQaURAfy9c8BGaqmQDYjUd9che3/25B1CzizNlZ6d0tV4fKVHg3QGQCPkz p6a2rQTsmZzaeKq0H830xqf+NYtpwKg7+L3c6ddXtvosnYkXPD6VvXftKz2DWAL6Ovu5 bponW0ml9uI4fF18hQbg2dwIAUaLAwQ1Ixx8s= 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=7A9XEgWChxB+rPK5/XKmD/6XiegwwZSHREIlzYhR5iU=; b=eh2Ax5bG8qcsu84NAWR614UNSOaRXAHoS4qBDO55PwW+FN8ETBvtzyUjBgosCNXLbe zcORcLyEQVfsHyet0afzdTV4Fmyu3Ymp0O7O2LanG4Yqg4jSogcQDDEfnGC91zxedIxg McUUt2F7oIsBGEeoojSgMVwU2KPpuRESgkScAQl1JPtm2zr6HECnSm5pc5kEBFSnbrBU 7p5Es0+23lkodbU+2tqXHNKH6elJOw3DikTGUkM8hD8BjTRPjhtGP0ItZdycPg87OSTS 0NgPm/aq2FBAzeAMaTnDs/996a+TfYFxnIqUMzHj3vsHb82C6aT+XkjbzJpfgJZ9lW8h oaaw== X-Gm-Message-State: ALQs6tB8dVgneNN6xhJNQY2691E2xOcknnjGm3Vf57XCYkeB+OCNUMJk g19SQCGNOedsbot+kaIa1n0Sk2RjDtI= X-Received: by 2002:a17:902:e8:: with SMTP id a95-v6mr41951106pla.274.1525792492108; Tue, 08 May 2018 08:14:52 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:14:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 08:14:36 -0700 Message-Id: <20180508151437.4232-10-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:c01::243 Subject: [Qemu-devel] [PATCH v3 09/10] target/arm: Implement CAS and CASP 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: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper-a64.h | 2 + target/arm/helper-a64.c | 43 ++++++++++++++ target/arm/translate-a64.c | 119 ++++++++++++++++++++++++++++++++++++- 3 files changed, 161 insertions(+), 3 deletions(-) -- 2.17.0 diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index ef4ddfe9d8..b8028ac98c 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -51,6 +51,8 @@ DEF_HELPER_FLAGS_4(paired_cmpxchg64_le_parallel, TCG_CALL_NO_WG, DEF_HELPER_FLAGS_4(paired_cmpxchg64_be, TCG_CALL_NO_WG, i64, env, i64, i64, i64) DEF_HELPER_FLAGS_4(paired_cmpxchg64_be_parallel, TCG_CALL_NO_WG, i64, env, i64, i64, i64) +DEF_HELPER_5(casp_le_parallel, void, env, i32, i64, i64, i64) +DEF_HELPER_5(casp_be_parallel, void, env, i32, i64, i64, i64) DEF_HELPER_FLAGS_3(advsimd_maxh, TCG_CALL_NO_RWG, f16, f16, f16, ptr) DEF_HELPER_FLAGS_3(advsimd_minh, TCG_CALL_NO_RWG, f16, f16, f16, ptr) DEF_HELPER_FLAGS_3(advsimd_maxnumh, TCG_CALL_NO_RWG, f16, f16, f16, ptr) diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index afb25ad20c..549ed3513e 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -636,6 +636,49 @@ uint64_t HELPER(paired_cmpxchg64_be_parallel)(CPUARMState *env, uint64_t addr, return do_paired_cmpxchg64_be(env, addr, new_lo, new_hi, true, GETPC()); } +/* Writes back the old data into Rs. */ +void HELPER(casp_le_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, + uint64_t new_lo, uint64_t new_hi) +{ + uintptr_t ra = GETPC(); +#ifndef CONFIG_ATOMIC128 + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); +#else + Int128 oldv, cmpv, newv; + + cmpv = int128_make128(env->xregs[rs], env->xregs[rs + 1]); + newv = int128_make128(new_lo, new_hi); + + int mem_idx = cpu_mmu_index(env, false); + TCGMemOpIdx oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); + oldv = helper_atomic_cmpxchgo_le_mmu(env, addr, cmpv, newv, oi, ra); + + env->xregs[rs] = int128_getlo(oldv); + env->xregs[rs + 1] = int128_gethi(oldv); +#endif +} + +void HELPER(casp_be_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, + uint64_t new_hi, uint64_t new_lo) +{ + uintptr_t ra = GETPC(); +#ifndef CONFIG_ATOMIC128 + cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); +#else + Int128 oldv, cmpv, newv; + + cmpv = int128_make128(env->xregs[rs + 1], env->xregs[rs]); + newv = int128_make128(new_lo, new_hi); + + int mem_idx = cpu_mmu_index(env, false); + TCGMemOpIdx oi = make_memop_idx(MO_LEQ | MO_ALIGN_16, mem_idx); + oldv = helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, oi, ra); + + env->xregs[rs + 1] = int128_getlo(oldv); + env->xregs[rs] = int128_gethi(oldv); +#endif +} + /* * AdvSIMD half-precision */ diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index c13858a690..e6cd88303f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -2114,6 +2114,103 @@ static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2, tcg_gen_movi_i64(cpu_exclusive_addr, -1); } +static void gen_compare_and_swap(DisasContext *s, int rs, int rt, + int rn, int size) +{ + TCGv_i64 tcg_rs = cpu_reg(s, rs); + TCGv_i64 tcg_rt = cpu_reg(s, rt); + int memidx = get_mem_index(s); + TCGv_i64 addr = cpu_reg_sp(s, rn); + + if (rn == 31) { + gen_check_sp_alignment(s); + } + tcg_gen_atomic_cmpxchg_i64(tcg_rs, addr, tcg_rs, tcg_rt, memidx, + size | MO_ALIGN | s->be_data); +} + +static void gen_compare_and_swap_pair(DisasContext *s, int rs, int rt, + int rn, int size) +{ + TCGv_i64 s1 = cpu_reg(s, rs); + TCGv_i64 s2 = cpu_reg(s, rs + 1); + TCGv_i64 t1 = cpu_reg(s, rt); + TCGv_i64 t2 = cpu_reg(s, rt + 1); + TCGv_i64 addr = cpu_reg_sp(s, rn); + int memidx = get_mem_index(s); + + if (rn == 31) { + gen_check_sp_alignment(s); + } + + if (size == 2) { + TCGv_i64 cmp = tcg_temp_new_i64(); + TCGv_i64 val = tcg_temp_new_i64(); + + if (s->be_data == MO_LE) { + tcg_gen_concat32_i64(val, t1, t2); + tcg_gen_concat32_i64(cmp, s1, s2); + } else { + tcg_gen_concat32_i64(val, t2, t1); + tcg_gen_concat32_i64(cmp, s2, s1); + } + + tcg_gen_atomic_cmpxchg_i64(cmp, addr, cmp, val, memidx, + MO_64 | MO_ALIGN | s->be_data); + tcg_temp_free_i64(val); + + if (s->be_data == MO_LE) { + tcg_gen_extr32_i64(s1, s2, cmp); + } else { + tcg_gen_extr32_i64(s2, s1, cmp); + } + tcg_temp_free_i64(cmp); + } else if (tb_cflags(s->base.tb) & CF_PARALLEL) { + TCGv_i32 tcg_rs = tcg_const_i32(rs); + + if (s->be_data == MO_LE) { + gen_helper_casp_le_parallel(cpu_env, tcg_rs, addr, t1, t2); + } else { + gen_helper_casp_be_parallel(cpu_env, tcg_rs, addr, t1, t2); + } + tcg_temp_free_i32(tcg_rs); + } else { + TCGv_i64 d1 = tcg_temp_new_i64(); + TCGv_i64 d2 = tcg_temp_new_i64(); + TCGv_i64 a2 = tcg_temp_new_i64(); + TCGv_i64 c1 = tcg_temp_new_i64(); + TCGv_i64 c2 = tcg_temp_new_i64(); + TCGv_i64 zero = tcg_const_i64(0); + + /* Load the two words, in memory order. */ + tcg_gen_qemu_ld_i64(d1, addr, memidx, + MO_64 | MO_ALIGN_16 | s->be_data); + tcg_gen_addi_i64(a2, addr, 8); + tcg_gen_qemu_ld_i64(d2, addr, memidx, MO_64 | s->be_data); + + /* Compare the two words, also in memory order. */ + tcg_gen_setcond_i64(TCG_COND_EQ, c1, d1, s1); + tcg_gen_setcond_i64(TCG_COND_EQ, c2, d2, s2); + tcg_gen_and_i64(c2, c2, c1); + + /* If compare equal, write back new data, else write back old data. */ + tcg_gen_movcond_i64(TCG_COND_NE, c1, c2, zero, t1, d1); + tcg_gen_movcond_i64(TCG_COND_NE, c2, c2, zero, t2, d2); + tcg_gen_qemu_st_i64(c1, addr, memidx, MO_64 | s->be_data); + tcg_gen_qemu_st_i64(c2, a2, memidx, MO_64 | s->be_data); + tcg_temp_free_i64(a2); + tcg_temp_free_i64(c1); + tcg_temp_free_i64(c2); + tcg_temp_free_i64(zero); + + /* Write back the data from memory to Rs. */ + tcg_gen_mov_i64(s1, d1); + tcg_gen_mov_i64(s2, d2); + tcg_temp_free_i64(d1); + tcg_temp_free_i64(d2); + } +} + /* Update the Sixty-Four bit (SF) registersize. This logic is derived * from the ARMv8 specs for LDR (Shared decode for all encodings). */ @@ -2214,10 +2311,16 @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) gen_store_exclusive(s, rs, rt, rt2, tcg_addr, size, true); return; } - /* CASP / CASPL */ + if (rt2 == 31 + && ((rt | rs) & 1) == 0 + && arm_dc_feature(s, ARM_FEATURE_V8_ATOMICS)) { + /* CASP / CASPL */ + gen_compare_and_swap_pair(s, rs, rt, rn, size | 2); + return; + } break; - case 0x6: case 0x7: /* CASP / LDXP */ + case 0x6: case 0x7: /* CASPA / LDXP */ if (size & 2) { /* LDXP / LDAXP */ if (rn == 31) { gen_check_sp_alignment(s); @@ -2230,13 +2333,23 @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) } return; } - /* CASPA / CASPAL */ + if (rt2 == 31 + && ((rt | rs) & 1) == 0 + && arm_dc_feature(s, ARM_FEATURE_V8_ATOMICS)) { + /* CASPA / CASPAL */ + gen_compare_and_swap_pair(s, rs, rt, rn, size | 2); + return; + } break; case 0xa: /* CAS */ case 0xb: /* CASL */ case 0xe: /* CASA */ case 0xf: /* CASAL */ + if (rt2 == 31 && arm_dc_feature(s, ARM_FEATURE_V8_ATOMICS)) { + gen_compare_and_swap(s, rs, rt, rn, size); + return; + } break; } unallocated_encoding(s); From patchwork Tue May 8 15:14:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135186 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4523832lji; Tue, 8 May 2018 08:26:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrstlTuyxxXgOE8no+UcF8X1N4Yzv8Y5qlBzJOOKJ0QggbRsMIQQ9q5GWAX4aOmobVt17fF X-Received: by 2002:a0c:e7cd:: with SMTP id c13-v6mr37802418qvo.35.1525793214646; Tue, 08 May 2018 08:26:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525793214; cv=none; d=google.com; s=arc-20160816; b=ap8jkiKu/2HdD59EPSnZm3Y6nmuJ9mM9+Q1/4UrkIJL2khSvbp1pagYv9sTNi8K4Cr dvr+iOTQFiymfQoq4VYLx8+BrtRo6k6D2HTnfjRExVr0eqz8p7RWk996e4eotxUwQMTU ypBHuvDTYGzwZseIRWEm+6ryddbtdkNv/CcelSj6I50tQ6PYX+SG7x+IfjcK1qfdgY0j dgmvHn+BB6IyITDH4ltijKWn5TyDnsCMo4ncLVlTnDJvkPGqFhx/R7epq94yVHdVdwb3 vKQhnkzRcdj+sb8XiyNhzanSCVEqOJtcEnd21nbYwkegp1KEKbp5HU9CkJnd20INoBdH rdZA== 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=OxuSkG/6B/DtTOkrD/2RTm5jo2gArqrTu7ixOnNRJhE=; b=Km6t8irVuGCO6inh4VuSw54IlkPbA0yL0ZhtmAyxiL1+D3jkBd2nCmc2jE/m82om4p skh+ZuKzTh4SMGNYB97ETixQnscsGVPJVYG8J2mktlSE+JDIsCFXJAfWtH2JbG1J1+vz UWtH28sVvxXFElbafceiv+l5JIa5txQXj08uS5ltP/d45HtvilMm5PyvU3+xTDbEVlBd JnUslsk05WUVRbb/qbg7UkvnwGUvGdHvmnScEAy2QOVU4NYVM16Qc4e5v51Et5UhWSWc lJArQmaahVLuyaFWPnv/Ff+vSHAZROuwxLm0yQvU+4hjZOYp2McolYwmFPTmR4O34ha4 K0+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kfcM2TfZ; 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 v6-v6si816127qtv.284.2018.05.08.08.26.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 May 2018 08:26:54 -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=kfcM2TfZ; 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]:51874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4Vy-0007q4-1Z for patch@linaro.org; Tue, 08 May 2018 11:26:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4KN-0006iY-Qf for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG4KM-0008IS-MT for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:55 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:39934) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4KM-0008Hr-GX for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:54 -0400 Received: by mail-pl0-x241.google.com with SMTP id q18-v6so2421291plr.6 for ; Tue, 08 May 2018 08:14:54 -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=OxuSkG/6B/DtTOkrD/2RTm5jo2gArqrTu7ixOnNRJhE=; b=kfcM2TfZ97yJubXlMzpxanGpzWe1xN/Bz9vlkkcolsPVngIOiEYAXU+WXhQNpzdnVe aidpMJZ01LE9lOVrHfefspvG0IrnaoA2ximzNNQitiTHJLktgvhG6TeKTeULE9PDKEui dPZZoRLMpvGLMe17+Fwz/Pf5FjVNC8y0yg01c= 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=OxuSkG/6B/DtTOkrD/2RTm5jo2gArqrTu7ixOnNRJhE=; b=LjY1Z69d8SoUTw8VXYyoZzPj9uuwRLMthUhGEvB6ZmAHitgvw0iAPd8Ds3nplP7Gh1 t8pFs2JnwxKtgrOP+//vUDyoYNh4i6UOX6rAxydurp8otCt6nI+rEft3bMdoY3+9OsCd GbXVS6CVMURxFXI0G1QhnPG/FMwc/gHW3a/O+miX04BNHjmJUv1ct9bV4sD63Jsl6v1c yaNqqoGktQpuyQTpCXdGOB/GceDZ8u16RthcFD+ONqIFx7thrJMzy9ktbJigZ02ALn7J tOezNmqyz79texIR70z2x+dxCvc667P6VsTL82XspnwYWikk928UsltEdoOJMWu7J2mE Wldw== X-Gm-Message-State: ALQs6tB2UFoQpQuX5KyJ5zaGaWPkgrN/9YWPnvclQjH0HoZYe2y6Hqfn HlB8CY2VRH7JaGvae1obSNMBK9/z/dg= X-Received: by 2002:a17:902:d24:: with SMTP id 33-v6mr41348027plu.22.1525792493352; Tue, 08 May 2018 08:14:53 -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.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:14:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 08:14:37 -0700 Message-Id: <20180508151437.4232-11-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:c01::241 Subject: [Qemu-devel] [PATCH v3 10/10] target/arm: Enable ARM_FEATURE_V8_ATOMICS for user-only 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: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu64.c | 1 + 1 file changed, 1 insertion(+) -- 2.17.0 diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 991d764674..c50dcd4077 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -248,6 +248,7 @@ static void aarch64_max_initfn(Object *obj) set_feature(&cpu->env, ARM_FEATURE_V8_SM4); set_feature(&cpu->env, ARM_FEATURE_V8_PMULL); set_feature(&cpu->env, ARM_FEATURE_CRC); + set_feature(&cpu->env, ARM_FEATURE_V8_ATOMICS); set_feature(&cpu->env, ARM_FEATURE_V8_RDM); set_feature(&cpu->env, ARM_FEATURE_V8_FP16); set_feature(&cpu->env, ARM_FEATURE_V8_FCMA);