From patchwork Fri May 4 18:30:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135019 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp378082lji; Fri, 4 May 2018 11:31:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrRRwfsGC+VTYvJh9z0NGIlJbs+m+GoSyHplqAT99qE0GQf+cNcX/P61qRys49vYgDtEryG X-Received: by 10.55.113.194 with SMTP id m185mr13888382qkc.177.1525458662786; Fri, 04 May 2018 11:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525458662; cv=none; d=google.com; s=arc-20160816; b=NkSZhhnSvACo0f0aS86BGtzwmpRX2R4fHoEOXQZTiz8mRqq5dEsfLJIo0ws1bbzq6D yG0NAPEw19HBQ9uD1PWcvA+642/y2rcZu/XM+HYAqe//zPLfzlmB2qu8641wUA/CeTia vxPsGd/TUck6ShXC7J3tS9DG+tDchp/xn5QlTGOD7yDaI350IJjHhRbVTg3vyQk/Uuez ytzAgJrDqCnH7nHencghI/y64oAUALnn9L2xpVgN7kUwzb8wJKUI1uKSZCXZ68E1oYiR TNrWuQm7l9d5nafivY762sEdfEj/ReyeUVgXiAPM6BVqEtA71mt+Z6g1Hkso1/skDkX9 LptA== 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=nb233U1bSWEt1qvuLILy6QuTyZNRED2l7P5Q74E4EVA=; b=QQjWPuQ05TSneop0DCfILj7UnGjaxhGs4T5jTb41NZBHLu9LMlJ5iotS3xD32EpNXQ zzsVL6Mz4CLJ2kWLwlDn7cEUcXyBJeSqCPGekpBqwKuvzD52pC24CUUEf2kS05yW3abo vObMDrb7gvT6BU07D59pvTntEo5UMxAYdxSeFUASOO/FH+UDtW+U7ZmMesUD+lQxt0Jd b5jiQktk4rgE6+DhduBX3PUCIYVG7m/M3ymzKXOusGBFK8i50UGwZBeaegKC6mr1zMAi dzjYzhmzCCcSLsJ0qkqV77BlCOAtGBDff9vYamonhLnH0TLGPs3KfYtWD91hMnfXensq 0oUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PTen3hXF; 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 k16-v6si7552297qta.340.2018.05.04.11.31.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 04 May 2018 11:31:02 -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=PTen3hXF; 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]:35974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfTy-0007U1-4I for patch@linaro.org; Fri, 04 May 2018 14:31:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfTQ-0007Sf-K6 for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEfTO-00013Z-Pk for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:28 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:33876) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fEfTO-000127-KB for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:26 -0400 Received: by mail-pg0-x244.google.com with SMTP id g20-v6so9292611pgv.1 for ; Fri, 04 May 2018 11:30:26 -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=nb233U1bSWEt1qvuLILy6QuTyZNRED2l7P5Q74E4EVA=; b=PTen3hXFDPB6ewhBLGwepyVzdGkJJcXsmwyZyceTI8gnGQSCRWcyFS4yChHAncSJOx 1ZR9XtyVoNLZwPZAVeMqbP62HmRNIyBnpeAoGfqwLV1i/5aah/PQ62L7Mje9z71kQuNJ DTVlMpKqhcmV8pORzQEbZal9DUTHe4nKvfMeo= 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=nb233U1bSWEt1qvuLILy6QuTyZNRED2l7P5Q74E4EVA=; b=hZpXXffOrwvI1AHx09TWJ6V2Q7Qn6LeRwB0j0fqT7waFexSTGfzUF6si70vz+maF4v ukgzp1xQcE4Wgy5BCmhkUD8oq+1HAZ1KQ5XaTlhVdfwLfH0ns3orwzCFhY7FXKGxHB/S kagCmTaHw2yvdD5gSJYvz/EY4H8p6gPsvU9Lo29Hq212gBROrPZf0L+PpXERBPiK8kz7 oyfSU1LoM7IIlbwZp6vSXdl0L2RQ4d5Dz2tU1NC+T8lmf+h0+ujvTtMdvOgBwE5ejBQ5 Fh3l3a9qfzTaZYG5laPGADGmu822XQIWD7EMqbfowfK9DcISZMhJCRvmE0vgiIMFRpzq iubA== X-Gm-Message-State: ALQs6tBTTKFigR4wCVJOdOgDtGEft3tWmmc9GV5ovxYm2K8SzaijZdE+ nRbnR7v6HfPQtJDrxoXZIKJg33wd1x8= X-Received: by 2002:a63:4383:: with SMTP id q125-v6mr23640373pga.412.1525458625366; Fri, 04 May 2018 11:30:25 -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 r8-v6sm16987413pgn.2.2018.05.04.11.30.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 11:30:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 4 May 2018 11:30:12 -0700 Message-Id: <20180504183021.19318-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504183021.19318-1-richard.henderson@linaro.org> References: <20180504183021.19318-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 v2 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, qemu-arm@nongnu.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.14.3 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 Fri May 4 18:30:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135021 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp381140lji; Fri, 4 May 2018 11:34:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZruFtBMVXOoCXdGA41JDFKyhr0JJ/iVcOKZHTkGPvU73b0wq+c0xvyke65N5LeIQ1sM6dUy X-Received: by 2002:ac8:2ff6:: with SMTP id m51-v6mr24823635qta.265.1525458855262; Fri, 04 May 2018 11:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525458855; cv=none; d=google.com; s=arc-20160816; b=O6oERX7jxIBEI4wIkAGK9Zf3DxkesspatJ6jwhd/8YzkeBEUEVV9gVuh8zUq4axEfN GIsvQNiZXA7ixSiw5lwD3/g4Zdg4TfjJ6u6vFmW5md6Z6/y7o6YpwOMYJiRMx3qAVAyg vGNWZ+5MzN93sOHq+VR3KwT5hStgnm7lkKhC9MI3cY/3kT0D22e2g/It/NY9uBuWBavE VNf++62cTOCOAspTb/ROcIOxAoV2TQPNaJN72cwXFFP/SnH18KooU1zOGeXDRL6NpTLe AScW4wsBy1YNNMYPjEf2sM8JAtOG1dhKwcvic2BNHl6CNMrlJJvOdR9EJvpl8xZCs4oS dumg== 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=8liVC1EvOhXEjQqPTbUiUiso0NQryYqSK+kZmW2XosI=; b=FuuMivByENKDBmQK4HmgD7TlH7+JOQ9PgFIUqvk4attEJgLX7evu2hZcWweOBV1XU+ w1FXHVnMmuQFZSHOBEXuT2Fk4K9GvkrBptNJAQuKvXT2UX+tW+BLdB5kgUGlT8avdhHG btsfVIVEC9YkLy6o8OBD0hX5nphGvcayNv9Dk4f5PDenWqXJCnl1V5Uoqdj7DDAIIjoJ gZURS4Zj4PpJQtWx9a3hGX0a919F8kQIdMMnMNLRkS+Kop6qwO/ouS/oKTPtBVW3mC0D CsTtuh/jrq3IUTQNTwYbaTMpCTiPfUps7ryPumBUFSlS3JdxyL2ztusxzaefLNAzbpCP 2MRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=auTPZvxO; 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 o62si6086263qke.305.2018.05.04.11.34.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 04 May 2018 11:34: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=auTPZvxO; 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]:35993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfX4-000253-K6 for patch@linaro.org; Fri, 04 May 2018 14:34:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfTR-0007Sk-K7 for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEfTQ-00014h-De for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:29 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:40582) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fEfTQ-00014J-5n for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:28 -0400 Received: by mail-pg0-x241.google.com with SMTP id l2-v6so15967712pgc.7 for ; Fri, 04 May 2018 11:30:28 -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=8liVC1EvOhXEjQqPTbUiUiso0NQryYqSK+kZmW2XosI=; b=auTPZvxOL43cPk1dHmLGtoavykFo4zabs/busrfaqJA9CjiIIPvXbcsnQ5zh9s6p9o 3zkNeGOpxsLrzsejsckcj4frw62YLwWTgQmbcdDD9orA4UN0RAMoHJpt0jFooI8NX2oq JjxHRKbojPIlaiLTIokkks9XXUlUxggcQ/wbA= 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=8liVC1EvOhXEjQqPTbUiUiso0NQryYqSK+kZmW2XosI=; b=IRTH6mExWD3voyWgG4u2ALloU0x4YehfcWvTfr5bgcBORvpvg2M4z5ZMxHnR96hiBJ jF5J+oTbDUNRngx+3aSL1CpMowEolF55uhAjoAquH5m1MZWjLXV9GZ9VOfIsXooOKBBT l1qIuM+RjJOTQdZSAVArATGHSyGZVPTSsBeQvK6VqXHUu58ZCRIbw9os2w43z23stKdO rbeP2JjPobXkRi61oA9RE1vC9nht+LN0a59+4NB3d0Z/mfmpIZ5jKinsSuYudOFx2aP8 rb1OW530YVGdG7qgsDToQSwtfgvokVYmwjTd3Yt5r+w5s7VGAuy1JoMdxy/pV435QdHt SWUQ== X-Gm-Message-State: ALQs6tDJwTBpPCU2qpL0nilObqUBc/14fbpc6hiBHAfVP/a5GkDGF7wW +54rekzKvoVqJwcf+r6pok2qUClW24A= X-Received: by 2002:a65:5d0f:: with SMTP id e15-v6mr23701692pgr.119.1525458626756; Fri, 04 May 2018 11:30:26 -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 r8-v6sm16987413pgn.2.2018.05.04.11.30.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 11:30:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 4 May 2018 11:30:13 -0700 Message-Id: <20180504183021.19318-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504183021.19318-1-richard.henderson@linaro.org> References: <20180504183021.19318-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::241 Subject: [Qemu-devel] [PATCH v2 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, qemu-arm@nongnu.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.14.3 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 Fri May 4 18:30:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135024 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp383591lji; Fri, 4 May 2018 11:36:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp44XgUxsYn05Lm4nFWrAIqTLmwMB9tc1IdQi6OAkGmwlr06Fg2WLmSdHVEen8ML5sQypu3 X-Received: by 10.55.17.137 with SMTP id 9mr21782152qkr.392.1525459010125; Fri, 04 May 2018 11:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525459010; cv=none; d=google.com; s=arc-20160816; b=k5WlEp/Um2YwgBK2AZR2a+bTAp92O38/qyRRCZguwciSL1KvbXKi4l0vgDUIX0Zzx1 CVjyM69B3453QNn7HdVtX+/3M9PaSpjvOP19+qxvqY8aThylb3l3vcfTNHsGg6xcyrOT ULFkAzJnksUq7TvP15KpX5C6maa/nRcS2a7YJqFTrKit+f7FekEsB1HMJePHoA7IXyo6 ETGdaKJHoqjuG8RxfGtd5XMq6AKhjLpe+dDLGxHCxYUWeYynNUr5cMdnfEUh6WxIAcrv OYAzWAC+I48SK+rlfixcrSucT9zcAajHFmHBDEJV7gYiHw7ezLKPD6fOD7NK0gegyTcv vbQw== 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=SPjqhxLd7+E3Y6suNDHxXLhiZ2uZGVurwI4LU+Q6Rpw=; b=POOOOApSxCbR985Waj5YCY+fIc7yNnqYpmkgkYV3FAJxTP1GRTDjFY1mabaQ+/y1Ux lmpkjIu8u8JuOz115WTsZipjc6bTiL+mZOyWeNjSZyfOCUAnnVxmq+5aZxoRB2wstPG4 X2vjGTfg0nDnA1SNqFKMI+fwqNe77wvaEc4WNEibI4EYTtpw1pTtq6UIOYhHf/vx72gx iqqCIRZVcX5NbriUuXics38HNaVO1jESMIo9ifVVm6m5dgvqGkQvrtV6ghJ+n+vNsxeq 5bY/FVIdy2+0bp2CDUXDbYZMM1WYR7m9pGtx9DFU/Omukt01MRtB6EyyQTBwHmF0IIiQ qDSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eYYgX/I4; 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 c40-v6si16109488qte.106.2018.05.04.11.36.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 04 May 2018 11:36:50 -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=eYYgX/I4; 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]:36010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfZZ-0004NS-Ki for patch@linaro.org; Fri, 04 May 2018 14:36:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfTS-0007TG-VD for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEfTR-000163-LW for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:30 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:40077) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fEfTR-00015L-Fi for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:29 -0400 Received: by mail-pf0-x243.google.com with SMTP id f189so18067515pfa.7 for ; Fri, 04 May 2018 11:30:29 -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=SPjqhxLd7+E3Y6suNDHxXLhiZ2uZGVurwI4LU+Q6Rpw=; b=eYYgX/I4G2Y7Al99KqdFCDicCsWg0XZFcjwqtjo/+OQx6kgzE+O4tEDwursqE3XDaX xtH0Qx5MKhSJypQm9uvHsyeLENPwc9JwxGiHvXRltcK3wD0tFBcKIAsyzXMqvODCJmbt TAMTh4iNwUU77YVx6JCdKTRI+kfROI9J4Z3Mg= 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=SPjqhxLd7+E3Y6suNDHxXLhiZ2uZGVurwI4LU+Q6Rpw=; b=AZ/qsRTOEwMtbeOBufLaDLbqlLA1fUis1p/RORcmX5BSoGO1km5tm9+yea52/waku7 mwMzsiGDVLbJVuM+y290roTcpu/5qz4UwB+XzXMffQkjA0wVBZOU8r1pMy13L4xnIsi4 TieYCzVnGkkmzHfNHIuwtc5ISHsZSbwxxhlxA+9F9YUCfM9mIBKl8aTMjkbwanBxPk9k k/Z5b3QT4RXinPR5xgD+Cb1GdEwEgkT2ZRB5YLXu2AtoBEcn+svTLd3THD59vmMH+4kE LSi1AclBJRnmrmq5o0kE59n8iSEoPHWioZ68WMbu6+3X4w+ak7m54b69TTNbqht1zA8k sajQ== X-Gm-Message-State: ALQs6tDZIAM6v/FuQ9pe+B6cDgK/GJnU5KKpQ3cGCKsJRdBDNLcLVYYg xMvYpJG2VYdBvIwlUEis6f0fo+uE69o= X-Received: by 10.98.150.150 with SMTP id s22mr27371635pfk.191.1525458628151; Fri, 04 May 2018 11:30:28 -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 r8-v6sm16987413pgn.2.2018.05.04.11.30.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 11:30:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 4 May 2018 11:30:14 -0700 Message-Id: <20180504183021.19318-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504183021.19318-1-richard.henderson@linaro.org> References: <20180504183021.19318-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 v2 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, qemu-arm@nongnu.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.14.3 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 Fri May 4 18:30:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135027 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp385502lji; Fri, 4 May 2018 11:38:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqRypbVEcW6jWp7wuQdC3ksBZFkQmdzlMXL03iTYucF6P6+MofAxsWLA2RtIeWaM5BN2Xm0 X-Received: by 10.55.159.131 with SMTP id i125mr22068326qke.188.1525459135255; Fri, 04 May 2018 11:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525459135; cv=none; d=google.com; s=arc-20160816; b=tXftYSE/V+sDs2Ab6VsQmLFmEbjh8rR46hBPZeXJmXcmMLqUqlhQPhkw0yPshx3Oh3 G1Hl5A65SxmnSXeynZEm3F1BS96hrcDg2UIZZEPb+KLdARlfrfqs3WVn+exJ1LeJ0W+g gvrA2etMeLtdrkHKN8P0cYc9cRis2/LN6M3ky9st2hst3jsgdWoRlwGdiIJZ0gPlmp2o Qs2d7Zs2eG46Tsp0SuVIYIFGaZa7pKG8QwTcFlNabGv3n0JnR5mlwFd2bYlTw4p3T6Wn rIADlg/EYTvA23lEPSBPHye3I9j6ywicvTA/JGevH3JgpJhFjj7gMZtZIj5w/Iq6bYtx cNmA== 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=4PxQ9ypwFLuzoamvhpohGwQ9B+0V26vuEkgTGmcr9do=; b=gswCZWe+1guyQCpM38kF3oqDZdKElyoHy9Sf4h4EE92YhDeqLJNmINOOVzlExvvza6 CTlz8MpX07kEkxuWxMIT14ocdIAT7OmsdRQjg1YGzoxYYhgkwsAZ71EqJjXIhX/hO0PJ zhZ3VrxzlDOIe4PkMh9JxWwBHUftXs6/FsVjmdU4+0N8WHYY7RNkrXqkjXIt9MYGRNzK Jl3Udb47M0QvdVvQ9wLqTAZ5EqkaDFyJx/4gl4HeJNHxoPXqDS+crTAkuXDxwiOSppxx 1XOKfLpN0krVSMAxzTva5siJMA/SKGgQ6q/zD3rA+/DrncB0FdxrPkejCTANxrbj188v dvng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=R3JN2Fn3; 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 g6si3306340qkd.386.2018.05.04.11.38.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 04 May 2018 11:38: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=R3JN2Fn3; 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]:36021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfba-0006Sd-Lr for patch@linaro.org; Fri, 04 May 2018 14:38:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfTU-0007Vb-Kp for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEfTS-00017F-V7 for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:32 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:39358) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fEfTS-00016P-NQ for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:30 -0400 Received: by mail-pf0-x242.google.com with SMTP id a22so3971311pfn.6 for ; Fri, 04 May 2018 11:30:30 -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=4PxQ9ypwFLuzoamvhpohGwQ9B+0V26vuEkgTGmcr9do=; b=R3JN2Fn3Ax3FGhDJJ9hF4ubSCaIByueo3XntQ4rKvNMCSyhClS4moSLHpNQ2v+AnRq qz9il6eGf/Z/7OCSIese9Y9+kH/1ja49z7aqRHx1cMc9aaMGpae/ZVpPYJq+ilxYBcQV yfxxqlTvQe8/q+i6hXQbAkrTVfyz1SHCvXZM8= 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=4PxQ9ypwFLuzoamvhpohGwQ9B+0V26vuEkgTGmcr9do=; b=eskcYk6FDmHKFQSnNIRO+K6VBL7Nrj/5aueun3k6ojP4vmj+v1vCrjoiPuOzeBxSH0 Sie9UK3bCFHdFc+zXAd96F/b0ECNY9ydWSO1eDm+osW3/eaqozrsLkqQrI4N+5NkZa2C HVhRyKF3N0U+Py7HspLf3VYKJQSNKDw8zATP/WyD5bEYA40XP7iI5si6Qw+NjfFmzHy9 UVZCvgeKOFubeXOc8yBurS0wVLOdb/SmHe3SbYd4Fg59bMQbHECr0s+6rMpTdSCI/PaJ AGPGY7a4ei5xu0dTc+w2swd2vT9IG03dnGpTZ3oWf7+B7prde62X1zL99lDa+tbJ3al2 IhJg== X-Gm-Message-State: ALQs6tDh+sSmAvBiHPY9YsUPjSN22e5o+urlqHmkf2igmBTd5VP3tOSz CtfMWBsjQ82SmW7rOIaj73lol0LEYxU= X-Received: by 2002:a17:902:22cc:: with SMTP id o12-v6mr29717058plg.38.1525458629408; Fri, 04 May 2018 11:30:29 -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 r8-v6sm16987413pgn.2.2018.05.04.11.30.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 11:30:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 4 May 2018 11:30:15 -0700 Message-Id: <20180504183021.19318-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504183021.19318-1-richard.henderson@linaro.org> References: <20180504183021.19318-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 v2 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, qemu-arm@nongnu.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.14.3 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 Fri May 4 18:30:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135023 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp383438lji; Fri, 4 May 2018 11:36:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrVFpLKQBYMUBR36vbiI5QjfuqYY6mMa6abpxA7y/xMriL+NEYKtazN14IS9BfiZbaI/X/r X-Received: by 2002:a0c:bdac:: with SMTP id n44-v6mr23936801qvg.165.1525458999953; Fri, 04 May 2018 11:36:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525458999; cv=none; d=google.com; s=arc-20160816; b=ars6062SzLQISbC6HQvZwsbIUl1b19h4gdsR22Igz6k/5Iw0So/kdEVcjqOMJVetdw FQ+ABuvuwR414kfW5Rarzth2Y2DdWpoWYq74JLWh+qHBOOc2s5FZFWsgZEaXUREz/mvF X+AedqPtvoQz8varDMQRIlCVV4rNY68O53bGJx3Ye4YFM8wp/iDBpFYWTuJ5hbBqGuZQ Cb/Ll+WTH0eRxeDitEhrwi4xoGjBy1iyb2N+/tQ6meMHOTIgSSzuXWWT8EnLkHHRpU4h qnb7//4S0NtCn6aB/PT4wLLVZKr434zudWmqIM9jRFaedNmpJyn4p5koRiymmt7t8+0S NH8Q== 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=pX83ru2E3i1FHrQMTmbujCaU3VeAorJ2wf0oyrpNImg=; b=zFfECNr2rjThXdv5u9gA+gTuBzvNSrB76fo/e+ozRzx0FA0YrXzS7iRSuVMVFLyfHS 7kjh6f+Ww6zAssyFQSSB6rljbBKmAYils3IqmKJb1WXKsHmgukFPhopep67dhwhWM0qn jS2uUwcz4oPEy64bmwLKJ+cthrc4cg/EKhBK3eMYJp2Y7Z2/3gVBIp8uloRR1mW6nXRF T169rzKgAAdSZd1QvHM+JCfrmQJoSzCZUcqkQTajGNqqmnHdPp/XLQzZApUe7C7tpebg YgHsSuDzysYmmdiw76Ub+mYPUL9VZ8jgT7F9o7b7VAfGMjSvIi7SBBONu39BOcqgzRHK 0vkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CvleDs3g; 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 x127si4270754qke.143.2018.05.04.11.36.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 04 May 2018 11:36:39 -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=CvleDs3g; 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]:36008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfZP-0004Ew-CS for patch@linaro.org; Fri, 04 May 2018 14:36:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfTV-0007Vr-0M for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEfTU-00018M-7t for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:33 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:37409) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fEfTU-00017o-2G for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:32 -0400 Received: by mail-pf0-x243.google.com with SMTP id e9so14078306pfi.4 for ; Fri, 04 May 2018 11:30:31 -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=pX83ru2E3i1FHrQMTmbujCaU3VeAorJ2wf0oyrpNImg=; b=CvleDs3g8JmKMkxfP3OtTB94Ww3Rb//Oj1uizsTVgfVz3l0TASH5EAsw22/6gcoci4 9O+e4G1ftvzA4FeHmW8CoifbclTWsDKZGajIaeVt/ZT4Uvbv1oFZp+v/mMi+A1pqCOft MkaO4aJxfKT+n5GZfvQDKIFDPMSxxV3tPdmdY= 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=pX83ru2E3i1FHrQMTmbujCaU3VeAorJ2wf0oyrpNImg=; b=HyUoIXNIex+IvK19AhDhwj6/Yz9iLzDGyRMV62+JzjbaMuytLYs+4pYTNbP3mVYZAe B1Kulbq3NNhL/gq4HZzbjy7qhHNkIgtM44O+t1ZGe3s95dret4MceG7RUDZml4lj5NDI DXPkKJCvs78gcM4BXnCljFq0opaEIyM7EqPX8sjpBlLp35Pc7qXvoF8bEGjGR9UbmUio 5PV7KMRYrLyyMkj5tZQWJi6jGezhrYFPGpzNI5FY8LkvRvuWIJ7nOHpK9Z6WPoELcQJ/ IFJsHYEma8KzvGh4HtToUmUmewqlyY2WzPVvyAEaG3j781/kJbQBW6mraulDQ5cuTf0X lg4Q== X-Gm-Message-State: ALQs6tDjOIxi9Uy8KHJB/WaWobsdUfxePZudbylPqHamp0iZ1H0tPT5/ fAStoXQe6e+vkXh2E+5rl9QaSl1iFbk= X-Received: by 2002:a17:902:9a9:: with SMTP id 38-v6mr29290044pln.114.1525458630724; Fri, 04 May 2018 11:30:30 -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 r8-v6sm16987413pgn.2.2018.05.04.11.30.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 11:30:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 4 May 2018 11:30:16 -0700 Message-Id: <20180504183021.19318-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504183021.19318-1-richard.henderson@linaro.org> References: <20180504183021.19318-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 v2 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, qemu-arm@nongnu.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.14.3 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 Fri May 4 18:30:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135022 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp381711lji; Fri, 4 May 2018 11:34:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpEqCF1v/b2kyApKy0qLRpEES8V6j15MiUnzmU+kuSrKJqpdX4tmlJe2sAvhVsZn+VRW/lm X-Received: by 2002:a0c:e849:: with SMTP id l9-v6mr8835968qvo.55.1525458891200; Fri, 04 May 2018 11:34:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525458891; cv=none; d=google.com; s=arc-20160816; b=gKSVpnkhbBPvcEBYHZ+DOLk9Qf6DomKaIKlZRjqUVW0QS/2+3w6pX3uP4FBrtN1rmE XqG4mtC2+nlYEH8aOzFADoDGfFKEr+NzKz9po2/srWuZ//K4U2Eu9mligunS6x40gqrI ZKHbmixf3Yz3DWarCNgXdH1bvSZwrrXdrUCcvFawJBpfzA6vcir07WGYt2W2R//qjyD/ NJ9Lelz2fYax3KPZCm3j4Bl/Io4HINO2laUOqTDR86Ik4oG6o53CqYjYZaA6hsEsKcxo 6goDVLZ5B/Stu8rackIuwuV9zwtgYWY0+8zvu2CrsGi6veY1dB8CWtJHLXmBL02oMVHM yTpQ== 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=2pebf/0PR+IvJNPCRpXipzxGfr/2aHKqB2n6O6kIo6g=; b=vWa+a4kqkmVkpq/Jm9xif6AaAdaOZUO0KcTC489Aq0PzzGHdQ+rH86ryPG8NYYI7Yi iJ+YAb8GmNWBwsuDe1pbD8uS8OOtpre8ZWVqg6VnzJuM+5YMawlc6vDqyKqZt/u4xPbg f2ByCK3tie0dpKx7hKNPTKsu5PI+L5Ah5t97wx++9rUrZN3yAOH6gxsnZ9ZRmWHUyejk 2CJSpCDif8UJb5OPodQ9Nc9N4ACgD2O69afn7MzxtPKF8kstH6A/7mMzS+FIGF4T4KHz RCL8K6jxoBxy/66Yyt9Q9SDnH2dpLqqYtzSda6KEZLoHazjNPURMob877hhV8syFHM8X i++w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Sx5oaXRo; 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 r11-v6si1166193qta.137.2018.05.04.11.34.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 04 May 2018 11:34:51 -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=Sx5oaXRo; 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]:35995 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfXe-0002ZZ-Jl for patch@linaro.org; Fri, 04 May 2018 14:34:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfTW-0007Xi-Cm for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEfTV-00019i-FM for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:34 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:37438) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fEfTV-00018y-B0 for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:33 -0400 Received: by mail-pg0-x241.google.com with SMTP id a13-v6so15979063pgu.4 for ; Fri, 04 May 2018 11:30:33 -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=2pebf/0PR+IvJNPCRpXipzxGfr/2aHKqB2n6O6kIo6g=; b=Sx5oaXRo4C8YWxHMGfFrR+PmOR9mtPX6JVxLGYYu3V3GG/7IRq6iEW8BjON1pnxMan 82mZsRnMFl7U7w4hlH3FPdHvVXffsSlJ2jCVsJy/kMjZ0nx3rONYNiyd7dJ+iV/vH5aL A+iKhdwzi15qC+hkm3xyOZVRmndVvLWfFCm44= 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=2pebf/0PR+IvJNPCRpXipzxGfr/2aHKqB2n6O6kIo6g=; b=SKqcTN5Y3WINZmGQW0DEdNvra84+wMoHmpdgNE4xhAyuAdQo2/k42L4PgM7AqA+fEJ X0h91zRXwjOZrXqqNT9G1Ga9bSjupX8d3wXSykzKn6TFw1AkTGs4xIJx4J4KN/yYAlA1 2NiXJyNCaM3aRIeAb33ICy4bJ2Ms7ofniWb+EDbnsdLWWFvfOZOTpeQO4y9zRIj94lJn 8D7KFMq2cj7zyuNKJxOwgJMCFRBVJVTW+hF2NH8EozFxqPHyzQKaclabsHWuwMhcpFqI +9BI7lkC3V/7jQrCGt8dPTwZ44mdyiFIswwJBn+Dzma5XVq0IF9yo5h6NID+rSEcUFDH z3GQ== X-Gm-Message-State: ALQs6tCyktC6bdrHRSE+9T4B3PsmX5raxSTUIEn72KFz123Jk2eH/ynd EDnYR0nG1b54Tfx5RdxJ3Ff0X5mejlA= X-Received: by 2002:a17:902:2f84:: with SMTP id t4-v6mr29620928plb.24.1525458632062; Fri, 04 May 2018 11:30:32 -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 r8-v6sm16987413pgn.2.2018.05.04.11.30.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 11:30:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 4 May 2018 11:30:17 -0700 Message-Id: <20180504183021.19318-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504183021.19318-1-richard.henderson@linaro.org> References: <20180504183021.19318-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::241 Subject: [Qemu-devel] [PATCH v2 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, qemu-arm@nongnu.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.14.3 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 Fri May 4 18:30:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135026 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp385343lji; Fri, 4 May 2018 11:38:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp93GphDNEWPPoj0YPZm9MmHHl5XyPS4o78k2DU81XI0EJpQM/387ISl8FxxDZTN9PTgaDJ X-Received: by 2002:a0c:8975:: with SMTP id 50-v6mr8749775qvq.177.1525459123301; Fri, 04 May 2018 11:38:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525459123; cv=none; d=google.com; s=arc-20160816; b=al/SWCIAQDzNsBaANeKkmmzQm6rrdckjFV8fKzn92JVqHh61BKn1+252f3dDGiF9n1 RuPnsp0k8reN8WfWGKJgncvGRfRu0fIPr6zpf039EhK7a2BYTU+PkeKpN9h5KWf6PWG5 qQo8ODVDafup0VyfQleE48QPqW6XIALkpT3YCISOHfKw0UdDeqERHJdtjIHI064tNoUU zJCyd4cJZbevvUGmAyQlJnBZT9of9gi++/4+7VU6aW0q/cto6GrRVn1PJy1Rf4LX81oz 7F1HkXndaRh6jRXhYC+fnd4sCflw6yMO3gu4gWOiLXuKd7H9B/xpqr/aOc7Nv5a6lPgV HNEw== 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=pKPiVaiwadysMdD9E0b+nOim1DheQytzhdVTzOKHZuY=; b=WeeJlXDNsm/sUJRh4zsD6HFInNh885+/jgjznjbb1r6yGv1VTc1cK67cSbG3hdgPax FTAK+p3vxONY9pXY0Kb2CHzFT6qNQQfKAGTkoTe7PHlylrUdz+3SAk2g2wKuizga+wdA 90XL0bWsIueM8a47EUAgYssl1ADZUCIQYf0FRKHbjn6CQ/PdMSywC0/9AW0n/9dvnuKe v10ag7xXJNHlN/Eo5RCYUpqNnCiHNvzT6Sm/MrlXy4MmQYnYvoWECFw3iJGcgbfMjWCZ q+d9vqw38+pwA/c/9HczPSgKDM+PE2+TD1bZtZX2WnBamRj3cNJ4dvo6AHBzxSiRmnLj 84gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BI3/nnhE; 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 e29-v6si1848995qvb.30.2018.05.04.11.38.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 04 May 2018 11:38: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=BI3/nnhE; 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]:36018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfbO-0006JA-NI for patch@linaro.org; Fri, 04 May 2018 14:38:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfTZ-0007b0-Bn for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEfTX-0001CM-1c for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:37 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:45586) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fEfTW-0001Bb-QZ for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:34 -0400 Received: by mail-pg0-x241.google.com with SMTP id i29-v6so15957636pgn.12 for ; Fri, 04 May 2018 11:30:34 -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=pKPiVaiwadysMdD9E0b+nOim1DheQytzhdVTzOKHZuY=; b=BI3/nnhE2RYHw8AMd3jxvXNNmMBLiYK8ZQ3SzZOJcFOruk5LLR8TkrKSU5uXGaRpNh 7pgN46Z0IbgIAqkx/xr34t6dtMnnU0pgJF7egnV2Kxle2O7/TMl0pUdebrSLePzO+qDN gy0YoPbPMppyzSLQJr/zUwttrFpPfOYWSXS6A= 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=pKPiVaiwadysMdD9E0b+nOim1DheQytzhdVTzOKHZuY=; b=WI40S0K3gofkFRknp/iAyP0wUqifH40ao50su4GOz7CjA2CCKxTaIrpWast/Mm4zut tB4hCm80IyHRMP5Si5t3/eWB5MKm6Xhk8CtV9XGUYdgJb4QwjwEAIkmhhvQzJ7+ZXP1B nHgTwB6++eadvUP+m/RFe3hPZdLbEfJ939Wp6drB+Kwl2OdBe3HcOqzq9hrvVZTzB9yE jJuZSdC/fJpDNT1DyjkGuNPKP3lOgzvUJxt4qsi6gUEXx/6sCv+XgYkO3gC1p8Smf2U+ lARhW+f2DccRNIlLpX0Ra0wDp+TkfvlUcnh6Bz4CUUEbGEuoXdkiqijjnjm/qLyiZnEs RIlA== X-Gm-Message-State: ALQs6tCA05oWE/J32hjg9BjwyvnnMMZ/2KjETKsrxq9BN3Oo5awQjrG9 fH6W2t2kps8Fp39bmOuYCgGSFPp/lvo= X-Received: by 2002:a17:902:9883:: with SMTP id s3-v6mr24367725plp.179.1525458633443; Fri, 04 May 2018 11:30:33 -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 r8-v6sm16987413pgn.2.2018.05.04.11.30.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 11:30:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 4 May 2018 11:30:18 -0700 Message-Id: <20180504183021.19318-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504183021.19318-1-richard.henderson@linaro.org> References: <20180504183021.19318-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::241 Subject: [Qemu-devel] [PATCH v2 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, qemu-arm@nongnu.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.14.3 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 Fri May 4 18:30:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135028 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp385816lji; Fri, 4 May 2018 11:39:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo5YwF51TZ2wtz6Wvm/ed6jUPO1BndnDYTvaxgoJvg1TTRBu5PDIR54e1+auzTgDjrHr+zb X-Received: by 2002:ac8:1881:: with SMTP id s1-v6mr20133176qtj.405.1525459158801; Fri, 04 May 2018 11:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525459158; cv=none; d=google.com; s=arc-20160816; b=suBnT8h1+SGRG/GjFplbbcuDa3DkFNDIrcbNtrc5eis/phlGqmeYfFoL/x25ekWwlO 0fmj+NER0bPez7kexFnuPQieUdzzbgAdH31cIhFKggLKI1rfwFEFXN6iGU5O8mSjfsMK oobVQ3S07KPxq/JTbm3G9YpiKwaujtdB2fTltBPmiLYZD5oWrChq/P59Pd14eOqZU4Gu zexmXRpcZTiAkBB+RtPWIfKJpcQ69AI+mt4nrb7LHIviMKE1dTHrlbOzad0FpQJh/NNa aVEi4UuCPlsM80CSR0ki+vJ45wWL+o5CzhrT4IKrrkO7s99ix6AtEOQDfBicmF6kwmNM ldzQ== 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=ThPvhn6D+UVVPyfam//ZDBRKSjR9Wis18Q00SIwCn4E=; b=ZDLk5AaZ52592XmviSYd0I5w6rUmMGlpNL6GqNzGNBR/s35ctpE5HZXyoP6SNpw9Bj WbfJL2/MSuJAN4yRwHdRefDZiQfWajUxEMeNsGDcFjaMMABRQ171lXPKjFQgJQ7CvfaH deA8g7jioDbkZrszfJEZR2fDLJIRbFkV1MSLc7OiVcBSYQ5f+jq9jCJrIRfg/e/hC4fs V/H9cuZ/eIC5aq/S8NycZnAJzptyQuiJ9275AchgavnDT410+q/ycBP3zrH39ngsBFoM TS08bcXSOdOrsRwJcXipQXME0rK1NZpAiOllUurXtQP28eWQHbxQu4JDnoBML78kdPIH PoxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X9KfoqKq; 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 s6-v6si6580588qtb.240.2018.05.04.11.39.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 04 May 2018 11:39:18 -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=X9KfoqKq; 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]:36024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfby-0006Vn-BO for patch@linaro.org; Fri, 04 May 2018 14:39:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfTZ-0007b7-F1 for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEfTY-0001Dc-42 for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:37 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:36176) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fEfTX-0001Ci-VB for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:36 -0400 Received: by mail-pf0-x243.google.com with SMTP id w129so12647536pfd.3 for ; Fri, 04 May 2018 11:30:35 -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=ThPvhn6D+UVVPyfam//ZDBRKSjR9Wis18Q00SIwCn4E=; b=X9KfoqKqpbum7f63Qqa7Y6q2RS+TNVn2kvWZljpyJvM+1KDguuQbSwdZ/hpL2rymMD hVkq3afSZKgWMuTCX1MObOInefrq0F8QZgw0dKqiKavmQdXZ17ac+8OBKC0DYS+sBvsP a8NVHveBbovW5hyLqBYVif7HxOz++r24B8QzE= 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=ThPvhn6D+UVVPyfam//ZDBRKSjR9Wis18Q00SIwCn4E=; b=krSAQ7UuMTunOMmwhbmXhb1BxrpV2kO3DHNUM/4uGIV9xuGlJptG7yADhGxTO/y/L1 gq6bajji/DlF8tQGDLtC28w4NkA6oi7OOUwI4Z7OjeW3lvgtfESuk/7Dlb4S0s95aR4Y tf6HWZPcHZy0rlg8EiRpwiEz2Y7kFW1ySVz3xLA0zS8fYrWwraN4TX/KElEAnVVOZYQQ UE+1DD6jFvW9bBv+MTdiIfmC8Z9iIRVJjBWQP+G3imi6NSqoMsZmW55Cr3xbcWnRo5Da ajm9j5ETIlTpwXK8zSEugHWLKTtNsSw2VyAKrRtXPFFFOpyVhE2SAiK9DmDdG/ieZZnF FfMQ== X-Gm-Message-State: ALQs6tAjg/5ZnIqdVc0zut9UXVeAJc7Zn0Y6Gq2cJkmZz6hy7LOnlgyI 4YqK8MsTVnHNqD+dPRuqsVGlbUDVTWc= X-Received: by 2002:a17:902:a60d:: with SMTP id u13-v6mr10205339plq.40.1525458634738; Fri, 04 May 2018 11:30:34 -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 r8-v6sm16987413pgn.2.2018.05.04.11.30.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 11:30:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 4 May 2018 11:30:19 -0700 Message-Id: <20180504183021.19318-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504183021.19318-1-richard.henderson@linaro.org> References: <20180504183021.19318-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 v2 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, qemu-arm@nongnu.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.14.3 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 6acad791e6..5af6028089 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, false); + + 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 Fri May 4 18:30:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135029 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp387196lji; Fri, 4 May 2018 11:40:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr2dMb34r81JvLEZ4dnrP4njWucjAmRIzKsAzvDMX4L9nNhSVtFMdIwvLY0Yn/ogAe36dq6 X-Received: by 10.55.217.202 with SMTP id q71mr22769755qkl.304.1525459257247; Fri, 04 May 2018 11:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525459257; cv=none; d=google.com; s=arc-20160816; b=B9rP9svSccTgy7mdPvtF1BYSkh5sZDe4HNOmMw3Vja57wP6pvNZy98dkhfLwUXswg0 BqJiZPA2QwLz9H/ITbhhiF567N4qQVEL60oosXpWbsw0P/6R1AFmPGlthC7GMZnwLqlr 2LgE0xYJmANU2pqC3fWdRwibqMxt+wxNEy/A5UiCdRpnkqDqLMb4V4XL91F8zsAujIDb jxz4DiMsElb0dLKNIaD3kxWh2d0qQjcRtrUKcwZHhdTyRE8FUIwNaxuohc9GjqEVVS1E ZOyX628i7lrb0cxsBZdQSv3XESh6X3Bm0U6xP4ajAiL4eye9yV7+8QG7KEfKAuG7DjcL bUvA== 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=CvitQzZ0KyAseNwhvu7lo9iCrZnSsdMX4Co5PcrM5L8=; b=LE3JGUw8r9xZwe6BLeZ8E1a3fkXMuzMVpAROpFdShBoXBXKEcYRKTc7hx0RpU5M8Js gcb9S09kPMi6NG8dOQHvztaWkMqJT49g/OwZGJ1YCl2AzT+TqI33HRh0TgFVl/YMvAAX 38gRK5iz2Gbo2GKPY1fKO9EGzpbQ4FXnlX0jslj7b6XEutgvOfyaWhRj4fYWK9h9Ra8O smsyNGynwCZTHyAp0JmThax7wLsRJTENfdE9NDrqo9Iq/GsXpt+oWznnhOyqoVDA4uJ+ F0fp1O0gt7gR58EV76rCAO8eh85QyYuWFytEiQMNeMvnyxBTPCt/8qZtU4LE3dI91/qb AQwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eSLjOtq4; 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 135si9354808qkj.208.2018.05.04.11.40.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 04 May 2018 11:40: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=eSLjOtq4; 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]:36043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfdY-00009U-PY for patch@linaro.org; Fri, 04 May 2018 14:40:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfTb-0007cC-97 for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEfTZ-0001Fh-NO for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:39 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:43288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fEfTZ-0001EJ-Gf for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:37 -0400 Received: by mail-pf0-x243.google.com with SMTP id j20so3756695pff.10 for ; Fri, 04 May 2018 11:30:37 -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=CvitQzZ0KyAseNwhvu7lo9iCrZnSsdMX4Co5PcrM5L8=; b=eSLjOtq4tEm78a6CriSrEDngd2kg39lzMtIaM+vvUE/LFL9GfmMfQYN3+jTVWdmY0c QdMnSQRb5PHTRwPSzO9E43gmsysPJrggBJbjfpTR2Nhpj1XupFzOHGNkjTGPpWeTSOub jsKAg6GMAicNBCClaMwM2WofQRBNJR4H93roU= 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=CvitQzZ0KyAseNwhvu7lo9iCrZnSsdMX4Co5PcrM5L8=; b=ndRitjK5zwciBxsK43oCaYDJ/SOGNMPz2ufyVFHa61e8qw8+N2fcTdBuEMxYH/8Spg 1ZUTBWAdg4pH8s/aHS9cGh4q4y+aEekE0LsRrguK+ZWdaRnqEMjyXpO5q7eJWFdJx8x4 fMFo1Fo8hiP8L+qdChAGSXM91esS1IoTBCsoQ6mKprtXSuuAc7HHYFLx3R5MmrXSMD8A Mn5+DjLR7h7J3gAzuFOQBaPwQC/W9q5tcesgnHfQ4np0xL+TxCMNcNbbRRgArPdEhJ+W eU7+StfVQDLvp7pRGaDKVobserUzghcb+Upe5+8dQTmIXXhDFUnXSoC7Afndfjw8KeHi 45OQ== X-Gm-Message-State: ALQs6tCc3f7Jr0LyasLLFsZpj5RXwxmRddEqwhxCaF6QBtQocSYqEINt 0ZeCpMD/PBeC3gvK0gYJ5awSLK6hsS4= X-Received: by 2002:a17:902:887:: with SMTP id 7-v6mr29551720pll.319.1525458635998; Fri, 04 May 2018 11:30:35 -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 r8-v6sm16987413pgn.2.2018.05.04.11.30.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 11:30:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 4 May 2018 11:30:20 -0700 Message-Id: <20180504183021.19318-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504183021.19318-1-richard.henderson@linaro.org> References: <20180504183021.19318-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 v2 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, qemu-arm@nongnu.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.14.3 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 5af6028089..08debc7a93 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 Fri May 4 18:30:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135025 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp384277lji; Fri, 4 May 2018 11:37:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq5IznZ9Ny+N3nHMRL1p8IoL6dOAG/a81eWWRzwLIPVTH7Gj+5TKuV06zD2JL1y/snh+YlX X-Received: by 2002:ac8:1b43:: with SMTP id p3-v6mr25098734qtk.254.1525459049866; Fri, 04 May 2018 11:37:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525459049; cv=none; d=google.com; s=arc-20160816; b=RvPYlHG25FoyuS+B7JisY6LLSFOvbkGZzpb4hn2OH4WcV4q/wYdtnnB/5n1yEAbqej WlDEoHS6lpKJNuZK1HifbjSHQbb3DXeYujyWiXYml8eH/cXWJXJR5EiRSGQ6jO6BduCZ vsbvzl5dK+mVlt3OKYyv2e8Hap/DVPm45ree/ldViW9S1TjltXhuxXmALnPA520Ch03m VI1X+gE21WQvad4wZV+Zz+WGION4ZzJf6xJsmUk0gKyU1ki7UzADIoq8hvJ/0EFnTAQO V+kMLw6BeF0Z/+9wJYdAStuUZ7AnL+llLzI9OQjzHCPsTKttVOjIU6SmLN9rmN9CJ8zE gDlg== 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=2OINtN/zuGI/xN0qhS4Am3G+0D2/hLRY6vwsOrAimeM=; b=sGM8q2vGRz9thFDtNpVMk42tpEr+EVtXdjJyCRGSLqbz39Fq5cRkayOQwKc3PS/Yhv yAUfL2TtaYprfFMcy3Ndv5t4Ks8lgVWhYvBoEXKr7/fCUL1IjQ1QLzV/Wh/6A30ma7A2 sVwBTLJpvWm0DCRtbrZ+CwyIr4+DNeVrSxz4+EyBsWkLz+3Ls/qCbW1HYz2hZaQdvJih 22FvtUTRPpAafGH4c4RCVHg6H0YTApxgCDRV0DgNMdDzHc/yb4gdxTCetz9C0559UIib roPcS2OD4e0EgLx0S8t0+XXlUj3MEm9JKN/3UJ083Ut27FLKQTKvpbwsW/eHoikIWa0F 0NFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SSDUz/2D; 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 q4-v6si3762493qvb.115.2018.05.04.11.37.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 04 May 2018 11:37:29 -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=SSDUz/2D; 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]:36013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfaD-000538-Ai for patch@linaro.org; Fri, 04 May 2018 14:37:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEfTb-0007cB-8n for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEfTa-0001Go-Fa for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:39 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:40584) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fEfTa-0001G0-AB for qemu-devel@nongnu.org; Fri, 04 May 2018 14:30:38 -0400 Received: by mail-pg0-x243.google.com with SMTP id l2-v6so15967999pgc.7 for ; Fri, 04 May 2018 11:30:38 -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=2OINtN/zuGI/xN0qhS4Am3G+0D2/hLRY6vwsOrAimeM=; b=SSDUz/2DR+ElLsJB7v9S8gIdY4tBjobWQw3DBOyRpbKu6/eMN7q4SgnV9FLHYRUCFU mmU9YSVxNraMdX/BL4XxoMVQBDpeZiQxyLvkWhEZn2ejjErBVN7fRutdJjqRbaEYCnwk g23ieqjfKPRve8jVOPz9pdQ+nex2zy9+rjFzk= 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=2OINtN/zuGI/xN0qhS4Am3G+0D2/hLRY6vwsOrAimeM=; b=NL70l3n9ngTfcYS5UEnyxsjtlsqkgFhA+E8PoRTiXgRH89ixc8G5uJv8Gmiqy5wv8j XM8dCh8gYfZUWJLON7C+laQtcjoX7YQwh/7efINVumK3W9sTsaxt6j1RbmcKhPFjd2rY AVcKarST2X3+76y2BMqwnk10qmYIeyViUa1aP0ODp++zSim02NksheZfaHPZ8rOtHZ2w BjaKqDnBdth9oKNBdIW5oQY8A2Nho1Zper9GiL7kToyytZO+HyS2G7sygKYbfgzgffwj 240k6Vg1oXQYdVRc7rKwsncU4sHzB6yXad/8qJpJfvgWtf/1UlWkS7rKWTUD23X9R5Eb 17rA== X-Gm-Message-State: ALQs6tCpyHXkNvitt0AVI9plOjVg5nHX2drZSjbaiC4lJ4k69mci9hWx IESfMjwvCeqtOYfj54BtZRco6iyuX+c= X-Received: by 2002:a17:902:bc48:: with SMTP id t8-v6mr28880227plz.133.1525458637090; Fri, 04 May 2018 11:30:37 -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 r8-v6sm16987413pgn.2.2018.05.04.11.30.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 11:30:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 4 May 2018 11:30:21 -0700 Message-Id: <20180504183021.19318-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504183021.19318-1-richard.henderson@linaro.org> References: <20180504183021.19318-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::243 Subject: [Qemu-devel] [PATCH v2 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, qemu-arm@nongnu.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.14.3 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);