From patchwork Tue May 8 15:14:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135178 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4514319lji; Tue, 8 May 2018 08:18:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpxySTeNrhz2I9V9e76FvnR5iwbO0lC863cUjDhBStzfyysJFs0t04VHSDY6uHUQWJmH9zW X-Received: by 2002:ac8:2ce3:: with SMTP id 32-v6mr36540866qtx.236.1525792699728; Tue, 08 May 2018 08:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525792699; cv=none; d=google.com; s=arc-20160816; b=MpAsn9YOVqBmV8/iSSbGmEvDVGvlZkCQZJ+5rxVv1npVYHWrlriR6d+riQlR+FtmUs Lc4CWJypoXCLrRpnPeHzfZyJ3AZ3O+Hzxvr7+x4Tyq0BrV/7CQKtrFIpGXPbKmNwDUKq iDCEakCCul9aNe76Hoi9YGcAYICZ8lp07YiKBkII9OIFbcg2iVNRu6BJ9Lm1pT02x07x bxZ6siCJGRzHgqhhGmEL6QfDkGp/XHmAzhD9dRyXbOBcHpgeMLxrGwEk+VlYNyGB81Pu nlyLsqzgkggi1jsqT/rydg/wXTmJ327Q/maiIjPegEE3t80/fVrF91/gU+WGga2l0nml CxhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=HApj84Fe4eAK9Kd60kVbQtpsu/0PF5w5mrUbloNYPXc=; b=ikfUQNNzl9WAfvA5leGYKXcJTeZFmfDdROIYlSLfuSCTRPk1ZNwKscxknwL5KGiNRM 2mNDd6WYp/r3wiNrWESOcBYpRQCEHPdSHALXqUj3zZryoeWCitft1hoaVaLRM9aiKDgR 6T3csnmdjp7zfGncIN1wo5e9V3ed3mudX7LwyZTUZLe36UT6M/s088ZLkyQxtH9azBxW QWFmFnWrt6tQi9sJ2FmpdOhxTZvF+Xir13examR9CZ/FKv3BwVBC+xQyqlsLmyawEqR6 RxFyEjbGOYsmzwUOgRbwwJh98Qpu9tXUIUN1wPUf1k7mvqRgBFY/ekegCow3rR6YCOEW gbZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fsEe0nxl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v6si2969883qkd.253.2018.05.08.08.18.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 May 2018 08:18:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fsEe0nxl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4Nf-0000a8-56 for patch@linaro.org; Tue, 08 May 2018 11:18:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4KJ-0006eD-CA for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG4KF-0008AY-HD for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:51 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:32941) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4KF-00089z-Af for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:47 -0400 Received: by mail-pf0-x244.google.com with SMTP id f20so15325092pfn.0 for ; Tue, 08 May 2018 08:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HApj84Fe4eAK9Kd60kVbQtpsu/0PF5w5mrUbloNYPXc=; b=fsEe0nxlC+xh+IXm8I9PQHxwLVKjqWm+5x3YnyGEcmz8bDYy95tlIZ3svbDpZV4bFB XoSdYTWvME68G/v+iBT/RmFLeG1AxEjYqV7Q10FGr+trNrwpztUTD4TxlJzENEZklB2e aMUvIIO60+LUq0G67wnIQlYdPEJ44ZzRwHsOo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HApj84Fe4eAK9Kd60kVbQtpsu/0PF5w5mrUbloNYPXc=; b=UbxnjuaFpI7SP0brcClkLL/2PbgBqsN8TAvLwPGxfItlDLJQyg9cgYnP8INexwgw4t fBO50UPSM8OSqWlaG9oacWCUkc30+xMM4LVQwgRg87VVrN/nd7DkcsZoZmnp2gEADyIH 4W4AY0sNTUuiRMIlqROTLQFul2L0eYIZ17eUQVldVx97DkgAXZ24LmflmK7wSBAVfs/b GsD3qdBRNRyg/jAySNqvzScxXw3gwcXpebCN/LFGI2NDye9Vt/hc6B74s1Q0IhTOj6fn h7tPWSz8K8upJm8h2Eq0RxSipSUoiM9gK6QblTLY+ISXCMe5b7fcW0o7EKUwUgat8X4E Y0Rg== X-Gm-Message-State: ALQs6tBha26nGXSFZaj8ORVlxvbOZxfaZqd6hq91A+lG+LAEGZO/9bm5 0Y9oIy0GK5NgSmMi9wgxAfJ5q1g+ICo= X-Received: by 2002:a63:b406:: with SMTP id s6-v6mr33927907pgf.334.1525792486058; Tue, 08 May 2018 08:14:46 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id n10sm55598896pfj.68.2018.05.08.08.14.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:14:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 08:14:32 -0700 Message-Id: <20180508151437.4232-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180508151437.4232-1-richard.henderson@linaro.org> References: <20180508151437.4232-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v3 05/10] tcg: Use GEN_ATOMIC_HELPER_FN for opposite endian atomic add X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Suggested-by: Peter Maydell Signed-off-by: Richard Henderson --- accel/tcg/atomic_template.h | 49 ++++++------------------------------- 1 file changed, 7 insertions(+), 42 deletions(-) -- 2.17.0 diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index 2489dd3ec1..3f41ef2782 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -229,48 +229,6 @@ GEN_ATOMIC_HELPER(xor_fetch) #undef GEN_ATOMIC_HELPER -/* Note that for addition, we need to use a separate cmpxchg loop instead - of bswaps for the reverse-host-endian helpers. */ -ABI_TYPE ATOMIC_NAME(fetch_add)(CPUArchState *env, target_ulong addr, - ABI_TYPE val EXTRA_ARGS) -{ - ATOMIC_MMU_DECLS; - DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; - DATA_TYPE ldo, ldn, ret, sto; - - ldo = atomic_read__nocheck(haddr); - while (1) { - ret = BSWAP(ldo); - sto = BSWAP(ret + val); - ldn = atomic_cmpxchg__nocheck(haddr, ldo, sto); - if (ldn == ldo) { - ATOMIC_MMU_CLEANUP; - return ret; - } - ldo = ldn; - } -} - -ABI_TYPE ATOMIC_NAME(add_fetch)(CPUArchState *env, target_ulong addr, - ABI_TYPE val EXTRA_ARGS) -{ - ATOMIC_MMU_DECLS; - DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; - DATA_TYPE ldo, ldn, ret, sto; - - ldo = atomic_read__nocheck(haddr); - while (1) { - ret = BSWAP(ldo) + val; - sto = BSWAP(ret); - ldn = atomic_cmpxchg__nocheck(haddr, ldo, sto); - if (ldn == ldo) { - ATOMIC_MMU_CLEANUP; - return ret; - } - ldo = ldn; - } -} - /* These helpers are, as a whole, full barriers. Within the helper, * the leading barrier is explicit and the trailing barrier is within * cmpxchg primitive. @@ -302,6 +260,13 @@ GEN_ATOMIC_HELPER_FN(umin_fetch, MIN, DATA_TYPE, new) GEN_ATOMIC_HELPER_FN(smax_fetch, MAX, SDATA_TYPE, new) GEN_ATOMIC_HELPER_FN(umax_fetch, MAX, DATA_TYPE, new) +/* Note that for addition, we need to use a separate cmpxchg loop instead + of bswaps for the reverse-host-endian helpers. */ +#define ADD(X, Y) (X + Y) +GEN_ATOMIC_HELPER_FN(fetch_add, ADD, DATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(add_fetch, ADD, DATA_TYPE, new) +#undef ADD + #undef GEN_ATOMIC_HELPER_FN #endif /* DATA_SIZE >= 16 */