From patchwork Tue Sep 12 16:25:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 112340 Delivered-To: patch@linaro.org Received: by 10.80.202.13 with SMTP id d13csp153149edi; Tue, 12 Sep 2017 09:34:09 -0700 (PDT) X-Received: by 10.200.56.189 with SMTP id f58mr23279422qtc.88.1505234049689; Tue, 12 Sep 2017 09:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505234049; cv=none; d=google.com; s=arc-20160816; b=CL8qKpnwIIwC8dR0gi9MNNm17pxEKvw+Wfc7bzok3o9hU5uYA/zX6e4xV/hLZuijul UgCvzVi8pojzyVipYGZ1V1TbfzkYKsNcJ2KfsGo8KFK4pz9c1sFaTB22qInLa0S5Hr4Z O25tIdged+0iphxkhMr86mZGSHDAnfOohNKXMLb+P+/Upj2yBqsTyc4JqNlPK4SgPVPk rMxaKvEnDjg8zSv9maUlKai/eafRjnH1Xojo47i65QH5hj1QpaQROpid74asGIJqDydb uFJQfD4aoPgRVqKIl4EjSJueJL+kSjSnvmYeh4pe3Kario87JtpYGbLuPZGWjE+3p5Ew E0Nw== 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=ByRv4yStlmXXTgaHEqSXUghKE6M2Phz6mSRs5MIlqMI=; b=V6rDDaIvVsu8P5vnCrbcZzB4LnPc3vXuWiEdiiLwIUDbN3X2NX6AaW9E1AGYOnQxMO XpnXbBBRTr6nTo/0AZvTzbHQxrp+FtRlZJ7nAOELU0Vp+t7ZnkyBK2oVVVE7/+5KF1BB RGtA6QnsDg1Wii7868Tv94XniM1YDY+drygJQCz2sXjuj6b9c8jcP3BAbaNF8KyX66dG gZ3Y7nMKXvbHEJw6nTU+aC7zmAcq/zrAX6XDjQdKwMQGwEgqjRqFsJBVqz+kFI59krdO fHAf8N33XGlf/UBLsqZBzl2Qa4QjgrcRVLsd5SFGp8GrtuP+5CRzXH2vRgk/hW4z+lyZ uzCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JjckUlqU; 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 f64si13590538qki.417.2017.09.12.09.34.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 12 Sep 2017 09:34:09 -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=JjckUlqU; 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]:36917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dro8V-0001H0-9G for patch@linaro.org; Tue, 12 Sep 2017 12:34:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dro0C-0001nm-Hf for qemu-devel@nongnu.org; Tue, 12 Sep 2017 12:25:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dro08-00073U-67 for qemu-devel@nongnu.org; Tue, 12 Sep 2017 12:25:32 -0400 Received: from mail-pg0-x234.google.com ([2607:f8b0:400e:c05::234]:35938) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dro07-000738-Th for qemu-devel@nongnu.org; Tue, 12 Sep 2017 12:25:28 -0400 Received: by mail-pg0-x234.google.com with SMTP id i130so14869833pgc.3 for ; Tue, 12 Sep 2017 09:25:27 -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=ByRv4yStlmXXTgaHEqSXUghKE6M2Phz6mSRs5MIlqMI=; b=JjckUlqUa3Dm5sgp5Kl3HgfPDimwFR8OkZXk+WPTz94ChclLftuiIizhJHm7crQ3zl hCrcvifmmZ6XtpU+9BsUDLhOUh3/081WYpw4CMHx8HzF4xQloQ3anWe09NTMUnsh1eky wEcqYY41M1jk879/Q2Q8Ejgf0Fky9KM68M9kA= 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=ByRv4yStlmXXTgaHEqSXUghKE6M2Phz6mSRs5MIlqMI=; b=XyAU5GNWX8kwSdniLYsXEimNP+x066IILIQgJbLhKKnzrVDV7kXFW/MnGE9Sayf8WC SVAs+UXrbj7rPqShE7RrVlXoRN+yDsIQ9Mu3U4++fXuXbQwIdVVLrBsvkQ+T1O2HqmU1 lkECZ7ITZp3FPHjJy0SQvKTMVTiGIKiztWQBL2aauLRFKwJrZ0/G0fk2UYba9+YykmWr zu8m8mNLV8cXSaS98KlFWWusFLEC6hGhrxkDO+y+DN7kHE7SSYfzuAMKrCpox1W0nA4Z HUZwxbB1zCsAsRKipbH7U4z0E0SO382DwujrB8Mks2E9jAIk4YpjMrJPX9+bhY2vDH8S zzMA== X-Gm-Message-State: AHPjjUhuNP3DC7lkAgx/l3U/uukAX+C0isgaleJt4ol8D9xtbVz6wk18 rkxG6v7Jh1TRASdam7onHA== X-Google-Smtp-Source: ADKCNb7kgCtZdLA5dBfqVxOr1McilTdyDslPlLZ5b8DP7yErMBioWS9tgOc0kgmZiHTA2zfnIHcx1g== X-Received: by 10.98.211.72 with SMTP id q69mr15458989pfg.308.1505233526743; Tue, 12 Sep 2017 09:25:26 -0700 (PDT) Received: from bigtime.twiddle.net (97-126-103-167.tukw.qwest.net. [97.126.103.167]) by smtp.gmail.com with ESMTPSA id b22sm20382140pfh.175.2017.09.12.09.25.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Sep 2017 09:25:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Sep 2017 09:25:05 -0700 Message-Id: <20170912162513.21694-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170912162513.21694-1-richard.henderson@linaro.org> References: <20170912162513.21694-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::234 Subject: [Qemu-devel] [PATCH v2 08/16] target/arm: Use vector infrastructure for aa64 add/sub/logic 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: alex.bennee@linaro.org, f4bug@amsat.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 137 ++++++++++++++++++++++++++++----------------- 1 file changed, 87 insertions(+), 50 deletions(-) -- 2.13.5 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 9017e30510..d01a180fba 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -21,6 +21,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "tcg-op.h" +#include "tcg-op-gvec.h" #include "qemu/log.h" #include "arm_ldst.h" #include "translate.h" @@ -82,6 +83,7 @@ typedef void NeonGenTwoDoubleOPFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_ptr); typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64); typedef void CryptoTwoOpEnvFn(TCGv_ptr, TCGv_i32, TCGv_i32); typedef void CryptoThreeOpEnvFn(TCGv_ptr, TCGv_i32, TCGv_i32, TCGv_i32); +typedef void GVecGenTwoFn(uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); /* initialize TCG globals. */ void a64_translate_init(void) @@ -537,6 +539,21 @@ static inline int vec_reg_offset(DisasContext *s, int regno, return offs; } +/* Return the offset info CPUARMState of the "whole" vector register Qn. */ +static inline int vec_full_reg_offset(DisasContext *s, int regno) +{ + assert_fp_access_checked(s); + return offsetof(CPUARMState, vfp.regs[regno * 2]); +} + +/* Return the byte size of the "whole" vector register, VL / 8. */ +static inline int vec_full_reg_size(DisasContext *s) +{ + /* FIXME SVE: We should put the composite ZCR_EL* value into tb->flags. + In the meantime this is just the AdvSIMD length of 128. */ + return 128 / 8; +} + /* Return the offset into CPUARMState of a slice (from * the least significant end) of FP register Qn (ie * Dn, Sn, Hn or Bn). @@ -9047,11 +9064,38 @@ static void disas_simd_3same_logic(DisasContext *s, uint32_t insn) bool is_q = extract32(insn, 30, 1); TCGv_i64 tcg_op1, tcg_op2, tcg_res[2]; int pass; + GVecGenTwoFn *gvec_op; if (!fp_access_check(s)) { return; } + switch (size + 4 * is_u) { + case 0: /* AND */ + gvec_op = tcg_gen_gvec_and; + goto do_gvec; + case 1: /* BIC */ + gvec_op = tcg_gen_gvec_andc; + goto do_gvec; + case 2: /* ORR */ + gvec_op = tcg_gen_gvec_or; + goto do_gvec; + case 3: /* ORN */ + gvec_op = tcg_gen_gvec_orc; + goto do_gvec; + case 4: /* EOR */ + gvec_op = tcg_gen_gvec_xor; + goto do_gvec; + do_gvec: + gvec_op(vec_full_reg_offset(s, rd), + vec_full_reg_offset(s, rn), + vec_full_reg_offset(s, rm), + is_q ? 16 : 8, vec_full_reg_size(s)); + return; + } + + /* Note that we've now eliminated all !is_u. */ + tcg_op1 = tcg_temp_new_i64(); tcg_op2 = tcg_temp_new_i64(); tcg_res[0] = tcg_temp_new_i64(); @@ -9061,47 +9105,27 @@ static void disas_simd_3same_logic(DisasContext *s, uint32_t insn) read_vec_element(s, tcg_op1, rn, pass, MO_64); read_vec_element(s, tcg_op2, rm, pass, MO_64); - if (!is_u) { - switch (size) { - case 0: /* AND */ - tcg_gen_and_i64(tcg_res[pass], tcg_op1, tcg_op2); - break; - case 1: /* BIC */ - tcg_gen_andc_i64(tcg_res[pass], tcg_op1, tcg_op2); - break; - case 2: /* ORR */ - tcg_gen_or_i64(tcg_res[pass], tcg_op1, tcg_op2); - break; - case 3: /* ORN */ - tcg_gen_orc_i64(tcg_res[pass], tcg_op1, tcg_op2); - break; - } - } else { - if (size != 0) { - /* B* ops need res loaded to operate on */ - read_vec_element(s, tcg_res[pass], rd, pass, MO_64); - } + /* B* ops need res loaded to operate on */ + read_vec_element(s, tcg_res[pass], rd, pass, MO_64); - switch (size) { - case 0: /* EOR */ - tcg_gen_xor_i64(tcg_res[pass], tcg_op1, tcg_op2); - break; - case 1: /* BSL bitwise select */ - tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_op2); - tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_res[pass]); - tcg_gen_xor_i64(tcg_res[pass], tcg_op2, tcg_op1); - break; - case 2: /* BIT, bitwise insert if true */ - tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[pass]); - tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_op2); - tcg_gen_xor_i64(tcg_res[pass], tcg_res[pass], tcg_op1); - break; - case 3: /* BIF, bitwise insert if false */ - tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[pass]); - tcg_gen_andc_i64(tcg_op1, tcg_op1, tcg_op2); - tcg_gen_xor_i64(tcg_res[pass], tcg_res[pass], tcg_op1); - break; - } + switch (size) { + case 1: /* BSL bitwise select */ + tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_op2); + tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_res[pass]); + tcg_gen_xor_i64(tcg_res[pass], tcg_op2, tcg_op1); + break; + case 2: /* BIT, bitwise insert if true */ + tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[pass]); + tcg_gen_and_i64(tcg_op1, tcg_op1, tcg_op2); + tcg_gen_xor_i64(tcg_res[pass], tcg_res[pass], tcg_op1); + break; + case 3: /* BIF, bitwise insert if false */ + tcg_gen_xor_i64(tcg_op1, tcg_op1, tcg_res[pass]); + tcg_gen_andc_i64(tcg_op1, tcg_op1, tcg_op2); + tcg_gen_xor_i64(tcg_res[pass], tcg_res[pass], tcg_op1); + break; + default: + g_assert_not_reached(); } } @@ -9375,6 +9399,7 @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) int rn = extract32(insn, 5, 5); int rd = extract32(insn, 0, 5); int pass; + GVecGenTwoFn *gvec_op; switch (opcode) { case 0x13: /* MUL, PMUL */ @@ -9414,6 +9439,28 @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) return; } + switch (opcode) { + case 0x10: /* ADD, SUB */ + { + static GVecGenTwoFn * const fns[4][2] = { + { tcg_gen_gvec_add8, tcg_gen_gvec_sub8 }, + { tcg_gen_gvec_add16, tcg_gen_gvec_sub16 }, + { tcg_gen_gvec_add32, tcg_gen_gvec_sub32 }, + { tcg_gen_gvec_add64, tcg_gen_gvec_sub64 }, + }; + gvec_op = fns[size][u]; + goto do_gvec; + } + break; + + do_gvec: + gvec_op(vec_full_reg_offset(s, rd), + vec_full_reg_offset(s, rn), + vec_full_reg_offset(s, rm), + is_q ? 16 : 8, vec_full_reg_size(s)); + return; + } + if (size == 3) { assert(is_q); for (pass = 0; pass < 2; pass++) { @@ -9586,16 +9633,6 @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) genfn = fns[size][u]; break; } - case 0x10: /* ADD, SUB */ - { - static NeonGenTwoOpFn * const fns[3][2] = { - { gen_helper_neon_add_u8, gen_helper_neon_sub_u8 }, - { gen_helper_neon_add_u16, gen_helper_neon_sub_u16 }, - { tcg_gen_add_i32, tcg_gen_sub_i32 }, - }; - genfn = fns[size][u]; - break; - } case 0x11: /* CMTST, CMEQ */ { static NeonGenTwoOpFn * const fns[3][2] = {