From patchwork Tue Dec 8 18:01:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 339773 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3916669jai; Tue, 8 Dec 2020 10:14:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyj838ck6m+NKbzwGWiiS1DyjqtYMRGVpvKi8PKAgStHJi5dYKPYCeRNye4/9X5gARbIchI X-Received: by 2002:a25:d713:: with SMTP id o19mr32631996ybg.378.1607451298648; Tue, 08 Dec 2020 10:14:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607451298; cv=none; d=google.com; s=arc-20160816; b=hDnjMJoBGjaE5bNNx2X44R/MVSGGQVEgqLOjqY3rINcbQKfLtWQFu8BRK4CnlvhRVN D1meJrz9IoftX+QCk66npfJRoum1GE5mPdW6RREnqYymgHKJ7/8NUMWAg2theC3HHW5n KZkb3wMa2Pg+GqJGQ2H/hN5gGycRQAYw3SZ26jdvpCzlBYMNxj8s1S3q3quiBGd4LLXV FxdSiLMWAI8qv+DuuuzsC1riH1etMNRFymzwP6eZ5refbTxi+i25y7vwCgbmaGF5ohTX UeNzDNsU9X2hCfNO0qQgzt/Rc6dS+tjaAuNsz38lHSN3zJ2tae1jDzYOg3Yz4ugI550x IZrA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=kG55pxrRqXSzKnfpX7pLeFgoSMBsIFropfupWBTNCJw=; b=kE6rIVVzZfczD0ZviXRWAS23qxGBAooz0WYV9TtqEAKXHPoVWGk/ym+6kC2A1AoCl3 VbhPzV6fvUi7i4ZHs8toJJf7qlHBetraOJ8g6XS7UJCPcrGXjHIoxk3Eu+G+6T2wlTcb CKFz+mjCRD6mcmpLaJqVdTO0T0ht/5pFVCdYQHBcQLlaOFTMFG/0DJVl33UcKuYhgGUl 1eQgHviJYdf+apHc/gGXrx9jashdl2Ckp90CLiKxHOhwOIdI7U3VeoeYyaZlZZgME8s6 r7afRKlkojxdMtI5hMzfssDgDESBLweFZYLwOLB+GWq3gwbz0pj6E0TwVjVoevMRLbHi gB3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tbKX9hIr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id 188si14367742ybo.326.2020.12.08.10.14.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Dec 2020 10:14:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=tbKX9hIr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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]:58004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmhVq-0002x9-3o for patch@linaro.org; Tue, 08 Dec 2020 13:14:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmhJB-00082C-Sq for qemu-devel@nongnu.org; Tue, 08 Dec 2020 13:01:53 -0500 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]:38727) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kmhJA-0006PL-7B for qemu-devel@nongnu.org; Tue, 08 Dec 2020 13:01:53 -0500 Received: by mail-oi1-x241.google.com with SMTP id o25so20326964oie.5 for ; Tue, 08 Dec 2020 10:01:51 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=kG55pxrRqXSzKnfpX7pLeFgoSMBsIFropfupWBTNCJw=; b=tbKX9hIr7R0lWf+3O9wWFcrI47ZhEKNwLWRWj2R4dfUdgKwJqUd9S+DO9J40bff/5Y 3253CmSjxnCwVw5LVvGvgq52kgwpU+xsStD/OOZS4J/HQTbu1uoIWS+aNsfDyOr7MAcc Jd5Xxbmgmlq5dnIFI/WFpfjaCZk9OdyvHdjhFt6BZ9xm56MTya8YHyaa7NGMVkkqb5/I Tqqg6LJhBsHjxwhxcoBB72fKkEfG7/GjHM5glcRMQQSR0lnSTNwX9tgE5joj8yv/vH1j CyKKFYCa38CzBP6O01+fWv8ucVtsfJ2PrwcxA4vCBIYyFzx4WOHt49A4mJKzkqPQcxLZ WUfQ== 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:mime-version:content-transfer-encoding; bh=kG55pxrRqXSzKnfpX7pLeFgoSMBsIFropfupWBTNCJw=; b=PGSuzIPkjIEGyF6soYCl9zETMtcQIznFsk1eCzVi/GmSvM9nNsSzLcVSl8fszuYaYv x9qY3wlWxVVddk2ZKQHqXu6dnB4zhShnWfVukpbo0i0+nM9MiwV9EcxbeKG2Z1uZmAYq kBJhCgdSHZ4/3kkVG2EImF/pIMGsFGcfWiitg8AYPjr00kx9KTGyvbd2jI/opLUl/swX R+rKTOFdAqUHtON5l5WJZYFDfj3RA8XDe4wbf7WhjyD58J/Zl30qRxcN7QQUTQ6xHqtY MraDX9MruZWrcWnzNjPxvvTSMrD3jLtpVxkl1H0MfJwfmFM8yr7W+4vFQl1KL8LRGgm3 BuZQ== X-Gm-Message-State: AOAM532lq1Y9AL7G7uSwt+IDpQZkzh3PjIb7Vj3eAqsSQnm+xzvNFuz0 nKgSgG4gW6R22CEongsdr6Zbz4FhFqNqkNpA X-Received: by 2002:aca:4ec9:: with SMTP id c192mr3760362oib.115.1607450508366; Tue, 08 Dec 2020 10:01:48 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id k20sm3886805oig.35.2020.12.08.10.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 10:01:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 16/24] target/arm: Enforce alignment for VLDn/VSTn (single) Date: Tue, 8 Dec 2020 12:01:10 -0600 Message-Id: <20201208180118.157911-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208180118.157911-1-richard.henderson@linaro.org> References: <20201208180118.157911-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::241; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x241.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" Signed-off-by: Richard Henderson --- target/arm/translate-neon.c.inc | 48 ++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 6 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc index 4dab01ae18..3a9ea3a0bb 100644 --- a/target/arm/translate-neon.c.inc +++ b/target/arm/translate-neon.c.inc @@ -611,6 +611,7 @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) int nregs = a->n + 1; int vd = a->vd; TCGv_i32 addr, tmp; + MemOp mop; if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { return false; @@ -660,23 +661,58 @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) return true; } + /* Pick up SCTLR settings */ + mop = finalize_memop(s, a->size); + + if (a->align) { + MemOp align_op; + + switch (nregs) { + case 1: + /* For VLD1, use natural alignment. */ + align_op = MO_ALIGN; + break; + case 2: + /* For VLD2, use double alignment. */ + align_op = pow2_align(a->size + 1); + break; + case 4: + if (a->size == MO_32) { + /* + * For VLD4.32, align = 1 is double alignment, align = 2 is + * quad alignment; align = 3 is rejected above. + */ + align_op = pow2_align(a->size + a->align); + } else { + /* For VLD4.8 and VLD.16, we want quad alignment. */ + align_op = pow2_align(a->size + 2); + } + break; + default: + /* For VLD3, the alignment field is zero and rejected above. */ + g_assert_not_reached(); + } + + mop = (mop & ~MO_AMASK) | align_op; + } + tmp = tcg_temp_new_i32(); addr = tcg_temp_new_i32(); load_reg_var(s, addr, a->rn); - /* - * TODO: if we implemented alignment exceptions, we should check - * addr against the alignment encoded in a->align here. - */ + for (reg = 0; reg < nregs; reg++) { if (a->l) { - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), a->size); + gen_aa32_ld_internal_i32(s, tmp, addr, get_mem_index(s), mop); neon_store_element(vd, a->reg_idx, a->size, tmp); } else { /* Store */ neon_load_element(tmp, vd, a->reg_idx, a->size); - gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), a->size); + gen_aa32_st_internal_i32(s, tmp, addr, get_mem_index(s), mop); } vd += a->stride; tcg_gen_addi_i32(addr, addr, 1 << a->size); + + /* Subsequent memory operations inherit alignment */ + mop &= ~MO_AMASK; } tcg_temp_free_i32(addr); tcg_temp_free_i32(tmp);