From patchwork Tue Jun 26 16:19: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: 140017 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp5446320lji; Tue, 26 Jun 2018 09:23:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdGnWsFo9TKLCDi6ykbuYet7oiyJtHdTkwNNlbgb8sZRcpMsGZ+WPwkVbmgjqD8UrVBk3Lm X-Received: by 2002:ac8:2b92:: with SMTP id m18-v6mr2102010qtm.130.1530030237291; Tue, 26 Jun 2018 09:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530030237; cv=none; d=google.com; s=arc-20160816; b=Jfuuxh2rfbV/3V3qQbGVOYrCaJasouOTJwLQbq/ERrc9L6nWjPPRspLnqZMvaFxGa8 ontMovK4+a8ECyFpMyrVQyIf43PVyXuJz39AU+7vcKaj2De2biPwtibwEYUFGq6J51Oa hCu/B+hV1KN47tiJseVtiy8P/NpFpeKh3EFCCDy/elNlViArz18zFS/Jho0sknkU49Ld yoHchKYoURbixGEU5xqvL0/dm56lJah3kOvwS12KkB65/CHraZ9+OpEYXijATHhLnEue lESCkeYCFJUDk7/veh3tmMUxZ9XOZxSZ/7th2AjJcXQ8MpWaM7HzIP4bCbSMatkUfslp hCoQ== 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=5hcmVyiOT6a6zB+QxuPp45HBjX7dc7cUIiq5aJ23H4M=; b=D4davRmZZg3p5Gtz6XUyHecZ7PXuvXkH97LEqSmYkYNqIeyxW4aa3XLEWbDQv6oH7r hjQASFp+UIoPW33RjOAvrWvQ7MC4CWUbKUxMs1auI49jlbwDD55R+jSkO21mvPVChSjS uVlWbyV8oytoJ8si+swIEnHI0Volyo7XCy0UuRZj30CocJRxrW+7HbaugoQARZoiudUC 063V80F35NLstSEYbMhCqrzJjHH1mwCHfsjiYm+pXOEb0SetzXWQapci1V1YpRpXBiTk l7LgcOyoUuyXgmMZNQ2lZdG2rwgcQeO+rb0b8Th0l+0A3erk+KLPsqfC6LXdT/Dmo5Xz FhPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="T17Jf/zR"; 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 r24-v6si403536qtc.283.2018.06.26.09.23.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 26 Jun 2018 09:23:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="T17Jf/zR"; 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]:53775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXql2-00041k-LX for patch@linaro.org; Tue, 26 Jun 2018 12:23:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXqgt-0000zz-00 for qemu-devel@nongnu.org; Tue, 26 Jun 2018 12:19:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXqgr-0005xv-Nr for qemu-devel@nongnu.org; Tue, 26 Jun 2018 12:19:38 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:36414) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXqgr-0005xQ-G0 for qemu-devel@nongnu.org; Tue, 26 Jun 2018 12:19:37 -0400 Received: by mail-pf0-x241.google.com with SMTP id u16-v6so4545630pfh.3 for ; Tue, 26 Jun 2018 09:19: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=5hcmVyiOT6a6zB+QxuPp45HBjX7dc7cUIiq5aJ23H4M=; b=T17Jf/zRefPlkmZzS0Z1xwTi+VVZQBtNd5MwhJoZL8ai0NSBM5DLqj9UFm9DZH+tpB R6iJyQqV0foGDs70YmYrp1fBFFCC4CPN0P/rxqGalmnkyKA0AsDeGJFGQXKljRW/FXTl HzEo/DyK4fqM3a8VSVaS79qTSnnps8A19F90o= 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=5hcmVyiOT6a6zB+QxuPp45HBjX7dc7cUIiq5aJ23H4M=; b=IsvZoVJPOiRdDWGNFTYIWClQ37mIhS7T2qo6lGHmwdTZakWECCSPfBWvqvf4ynmWbt zFCThas2edpwLaYoXIlP9EXsD+Mk0aUjjfq8f6PFhFyxznToaNcLzaOqvF+TXj0YZQuz 6mfa2noh3xX0ue4AExt2FD2k+wvR4tYEdQFpUIERvfIBmWxGOkJXQR/7Es/iEhcVv9zA FSN6FkH5HDYXTp8cxjFXJk7gG5p1/Q97LJ2ZDnClSf5vs7zEnRY7VzVvdbNAO5ac29uB VyshiLtEwzbkwyr1Q6VYwlsTLLfz3lMmBdOF5N/59tWqJMX5AVf6KuPEwo7o08t/kG2z RV7Q== X-Gm-Message-State: APt69E0i/yo2hpHmusAfgUj2enq/F+ShJmGQIaEBg/VYu5XaTv6AoaJk wYL+Bbq04SuSoDIHulfLH8RoSi220cY= X-Received: by 2002:a65:490d:: with SMTP id p13-v6mr1948311pgs.84.1530029976271; Tue, 26 Jun 2018 09:19:36 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id 67-v6sm5054306pfm.171.2018.06.26.09.19.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jun 2018 09:19:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 26 Jun 2018 09:19:16 -0700 Message-Id: <20180626161921.27941-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626161921.27941-1-richard.henderson@linaro.org> References: <20180626161921.27941-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::241 Subject: [Qemu-devel] [PATCH 08/13] target/ppc: Split out gen_ld_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: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Move the guts of LD_ATOMIC to a function. Use foo_tl for the operations instead of foo_i32 or foo_i64 specifically. Use MO_ALIGN instead of an explicit call to gen_check_align. Signed-off-by: Richard Henderson --- target/ppc/translate.c | 105 ++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 53 deletions(-) -- 2.17.1 diff --git a/target/ppc/translate.c b/target/ppc/translate.c index f48fcbeefb..361b178db8 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -3095,61 +3095,60 @@ LARX(lbarx, DEF_MEMOP(MO_UB)) LARX(lharx, DEF_MEMOP(MO_UW)) LARX(lwarx, DEF_MEMOP(MO_UL)) -#define LD_ATOMIC(name, memop, tp, op, eop) \ -static void gen_##name(DisasContext *ctx) \ -{ \ - int len = MEMOP_GET_SIZE(memop); \ - uint32_t gpr_FC = FC(ctx->opcode); \ - TCGv EA = tcg_temp_local_new(); \ - TCGv_##tp t0, t1; \ - \ - gen_addr_register(ctx, EA); \ - if (len > 1) { \ - gen_check_align(ctx, EA, len - 1); \ - } \ - t0 = tcg_temp_new_##tp(); \ - t1 = tcg_temp_new_##tp(); \ - tcg_gen_##op(t0, cpu_gpr[rD(ctx->opcode) + 1]); \ - \ - switch (gpr_FC) { \ - case 0: /* Fetch and add */ \ - tcg_gen_atomic_fetch_add_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 1: /* Fetch and xor */ \ - tcg_gen_atomic_fetch_xor_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 2: /* Fetch and or */ \ - tcg_gen_atomic_fetch_or_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 3: /* Fetch and 'and' */ \ - tcg_gen_atomic_fetch_and_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 8: /* Swap */ \ - tcg_gen_atomic_xchg_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 4: /* Fetch and max unsigned */ \ - case 5: /* Fetch and max signed */ \ - case 6: /* Fetch and min unsigned */ \ - case 7: /* Fetch and min signed */ \ - case 16: /* compare and swap not equal */ \ - case 24: /* Fetch and increment bounded */ \ - case 25: /* Fetch and increment equal */ \ - case 28: /* Fetch and decrement bounded */ \ - gen_invalid(ctx); \ - break; \ - default: \ - /* invoke data storage error handler */ \ - gen_exception_err(ctx, POWERPC_EXCP_DSI, POWERPC_EXCP_INVAL); \ - } \ - tcg_gen_##eop(cpu_gpr[rD(ctx->opcode)], t1); \ - tcg_temp_free_##tp(t0); \ - tcg_temp_free_##tp(t1); \ - tcg_temp_free(EA); \ +static void gen_ld_atomic(DisasContext *ctx, TCGMemOp memop) +{ + uint32_t gpr_FC = FC(ctx->opcode); + TCGv EA = tcg_temp_new(); + TCGv src, dst; + + gen_addr_register(ctx, EA); + dst = cpu_gpr[rD(ctx->opcode)]; + src = cpu_gpr[rD(ctx->opcode) + 1]; + + memop |= MO_ALIGN; + switch (gpr_FC) { + case 0: /* Fetch and add */ + tcg_gen_atomic_fetch_add_tl(dst, EA, src, ctx->mem_idx, memop); + break; + case 1: /* Fetch and xor */ + tcg_gen_atomic_fetch_xor_tl(dst, EA, src, ctx->mem_idx, memop); + break; + case 2: /* Fetch and or */ + tcg_gen_atomic_fetch_or_tl(dst, EA, src, ctx->mem_idx, memop); + break; + case 3: /* Fetch and 'and' */ + tcg_gen_atomic_fetch_and_tl(dst, EA, src, ctx->mem_idx, memop); + break; + case 8: /* Swap */ + tcg_gen_atomic_xchg_tl(dst, EA, src, ctx->mem_idx, memop); + break; + case 4: /* Fetch and max unsigned */ + case 5: /* Fetch and max signed */ + case 6: /* Fetch and min unsigned */ + case 7: /* Fetch and min signed */ + case 16: /* compare and swap not equal */ + case 24: /* Fetch and increment bounded */ + case 25: /* Fetch and increment equal */ + case 28: /* Fetch and decrement bounded */ + gen_invalid(ctx); + break; + default: + /* invoke data storage error handler */ + gen_exception_err(ctx, POWERPC_EXCP_DSI, POWERPC_EXCP_INVAL); + } + tcg_temp_free(EA); } -LD_ATOMIC(lwat, DEF_MEMOP(MO_UL), i32, trunc_tl_i32, extu_i32_tl) -#if defined(TARGET_PPC64) -LD_ATOMIC(ldat, DEF_MEMOP(MO_Q), i64, mov_i64, mov_i64) +static void gen_lwat(DisasContext *ctx) +{ + gen_ld_atomic(ctx, DEF_MEMOP(MO_UL)); +} + +#ifdef TARGET_PPC64 +static void gen_ldat(DisasContext *ctx) +{ + gen_ld_atomic(ctx, DEF_MEMOP(MO_Q)); +} #endif #define ST_ATOMIC(name, memop, tp, op) \