From patchwork Sat Feb 17 18:22:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 128694 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1828404ljc; Sat, 17 Feb 2018 10:44:09 -0800 (PST) X-Google-Smtp-Source: AH8x225wH4BS7jiWA5iyBQYEKBfvmJJLf2sb7NU6PoGDh96qL9zolFyxhk+4u/04LplzwedodT/6 X-Received: by 10.129.133.6 with SMTP id v6mr7631082ywf.514.1518893049508; Sat, 17 Feb 2018 10:44:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518893049; cv=none; d=google.com; s=arc-20160816; b=oSjs3rYVmNbUtMhKIzXzsS3DILUHwkyU4Dg1Og/Q4MkJGVt3wo995kdTASId2YXtFa B4QXsdkwO5gJ9ZsrmkBpxIdtloztDa/72LfhW5VQz3dhHnzUc8lGHf1dxauUxKWKXu0Y WT9k6wSj12tTrmCHMkpc9vA3ScEiB/0bwvUnbIvfNRvmPfrNnuwJx0pdr427wd2vzG3f kiwdtvEp9r6YH5KDRrxWs1kFRscuXUkN35x5+ZgmXKzuN1FCJQOZlxgl20VOXBSLvzNm wxPfHwexObDMHSIwYUVBmkXcTqPxkd3gvvZ7+e+6IJ6CYdFvhw0M27zlWZIJ4RGD/GUC V77w== 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=DwIEfXE8CNgM0TRpz0r+ylrsP3Cl/uBo6B2EBJ/28wM=; b=ndTeCxpZC4ZWvS+sCg5D4RYffTiyrVeFNEJ1kVsi/eItKOfY+y0Iura8nj2vecQvSn wMV3CnaTVz6kKpMQh0SECe5xAQpxB4i1i/mw05YSrmtJxhfi6n670od2r5aNOxN5DVZG LYmMXZDVEoDviTLk+EibqiYP+2nf4pLwMAqRBZCzdECRl/E7Zt6vgcix4vBKcOSh5s4P QRnrKgnuyNB0tw2uSn8I+a4E4bH8Mbk0zYQqOxrQoa+99yh8L7VkA0oQtzeHvZ37AOfb H5YzFOVv31WRiK55OL8AeYcAS6CDTddgjwUM0JqVStncy6qay9rrgrPLkGIt8ihQU6Zz 0/Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jhabaLD6; 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 z186si3447684yba.810.2018.02.17.10.44.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 17 Feb 2018 10:44:09 -0800 (PST) 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=jhabaLD6; 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]:48211 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1en7Sy-0000H0-Po for patch@linaro.org; Sat, 17 Feb 2018 13:44:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1en79f-0000mM-37 for qemu-devel@nongnu.org; Sat, 17 Feb 2018 13:24:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1en79d-0001mo-PN for qemu-devel@nongnu.org; Sat, 17 Feb 2018 13:24:11 -0500 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:39664) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1en79d-0001mK-HR for qemu-devel@nongnu.org; Sat, 17 Feb 2018 13:24:09 -0500 Received: by mail-pl0-x241.google.com with SMTP id s13so3436999plq.6 for ; Sat, 17 Feb 2018 10:24:09 -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; bh=DwIEfXE8CNgM0TRpz0r+ylrsP3Cl/uBo6B2EBJ/28wM=; b=jhabaLD67l4OK/+vLYeFc4Wb2gL/RzzTtyf+eul8Ai1bKqBT3RoGsh1oACmODiXAPU NsFiVErzTnhKkC4qcJyIuOgXoGCGaVDLgv75N6ZXQZ0qMRnb8fI/Ofkpucd/gFXRL7VO egXLF3Iyy5g0QLZDVCMqUvTFv6xNsi82BgPII= 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=DwIEfXE8CNgM0TRpz0r+ylrsP3Cl/uBo6B2EBJ/28wM=; b=Y/VQlkS3wlKZxcOS/cLaZ+rXlWZ1qEJnXufwIdca5dsxPpNRTcH3hsxrU37LXJMLHh Z0jLZD4zeBEkNyBmvNapAoMn05lNcgUqqlQL37NDeLrIcyYFCj2ntl7mK4/9BuedpMfy 9R58NTmSzsL7JZEiWfXUbO+JNsV8oqPIGTMhGdi9iC6VCclWFRxvzb+THxr+r1kx/Qoc 1rqKjiSvVjlxnqtiG43Zbb7T8+sLNoCSF1SGk6+50faLiRuSNM2g2BtUfeiQiHhL7/tW ZnTkcgQP8L8oLFeYAGKuC6pbTxi6gglCnQKBq963Va8SMx/yf3LmxPtnTvon3SmHT2qU dWFw== X-Gm-Message-State: APf1xPBATTb+O7ohd4I8D8unnyY4qbGsujJKAVJK/HlzQ9YoQ9HL4KSg fTrWjdHOyeipxmWT62mH1OxXgxSiaDk= X-Received: by 2002:a17:902:42c3:: with SMTP id h61-v6mr9349488pld.269.1518891848270; Sat, 17 Feb 2018 10:24:08 -0800 (PST) Received: from cloudburst.twiddle.net ([50.0.192.64]) by smtp.gmail.com with ESMTPSA id h15sm13466712pfi.56.2018.02.17.10.24.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Feb 2018 10:24:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 17 Feb 2018 10:22:42 -0800 Message-Id: <20180217182323.25885-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180217182323.25885-1-richard.henderson@linaro.org> References: <20180217182323.25885-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:c01::241 Subject: [Qemu-devel] [PATCH v2 26/67] target/arm: Implement SVE Permute - Extract Group 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-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/helper-sve.h | 2 ++ target/arm/sve_helper.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++ target/arm/translate-sve.c | 29 +++++++++++++++++ target/arm/sve.decode | 9 +++++- 4 files changed, 120 insertions(+), 1 deletion(-) -- 2.14.3 Reviewed-by: Peter Maydell diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h index 79493ab647..94f4356ce9 100644 --- a/target/arm/helper-sve.h +++ b/target/arm/helper-sve.h @@ -414,6 +414,8 @@ DEF_HELPER_FLAGS_4(sve_cpy_z_h, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) DEF_HELPER_FLAGS_4(sve_cpy_z_s, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) DEF_HELPER_FLAGS_4(sve_cpy_z_d, TCG_CALL_NO_RWG, void, ptr, ptr, i64, i32) +DEF_HELPER_FLAGS_4(sve_ext, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) + DEF_HELPER_FLAGS_5(sve_and_pppp, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_5(sve_bic_pppp, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) DEF_HELPER_FLAGS_5(sve_eor_pppp, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32) diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index 6a95d1ec48..fb3f54300b 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -1469,3 +1469,84 @@ void HELPER(sve_cpy_z_d)(void *vd, void *vg, uint64_t val, uint32_t desc) d[i] = (pg[H1(i)] & 1 ? val : 0); } } + +/* Big-endian hosts need to frob the byte indicies. If the copy + * happens to be 8-byte aligned, then no frobbing necessary. + */ +static void swap_memmove(void *vd, void *vs, size_t n) +{ + uintptr_t d = (uintptr_t)vd; + uintptr_t s = (uintptr_t)vs; + uintptr_t o = (d | s | n) & 7; + size_t i; + +#ifndef HOST_WORDS_BIGENDIAN + o = 0; +#endif + switch (o) { + case 0: + memmove(vd, vs, n); + break; + + case 4: + if (d < s || d >= s + n) { + for (i = 0; i < n; i += 4) { + *(uint32_t *)H1_4(d + i) = *(uint32_t *)H1_4(s + i); + } + } else { + for (i = n; i > 0; ) { + i -= 4; + *(uint32_t *)H1_4(d + i) = *(uint32_t *)H1_4(s + i); + } + } + break; + + case 2: + case 6: + if (d < s || d >= s + n) { + for (i = 0; i < n; i += 2) { + *(uint16_t *)H1_2(d + i) = *(uint16_t *)H1_2(s + i); + } + } else { + for (i = n; i > 0; ) { + i -= 2; + *(uint16_t *)H1_2(d + i) = *(uint16_t *)H1_2(s + i); + } + } + break; + + default: + if (d < s || d >= s + n) { + for (i = 0; i < n; i++) { + *(uint8_t *)H1(d + i) = *(uint8_t *)H1(s + i); + } + } else { + for (i = n; i > 0; ) { + i -= 1; + *(uint8_t *)H1(d + i) = *(uint8_t *)H1(s + i); + } + } + break; + } +} + +void HELPER(sve_ext)(void *vd, void *vn, void *vm, uint32_t desc) +{ + intptr_t opr_sz = simd_oprsz(desc); + size_t n_ofs = simd_data(desc); + size_t n_siz = opr_sz - n_ofs; + + if (vd != vm) { + swap_memmove(vd, vn + n_ofs, n_siz); + swap_memmove(vd + n_siz, vm, n_ofs); + } else if (vd != vn) { + swap_memmove(vd + n_siz, vd, n_ofs); + swap_memmove(vd, vn + n_ofs, n_siz); + } else { + /* vd == vn == vm. Need temp space. */ + ARMVectorReg tmp; + swap_memmove(&tmp, vm, n_ofs); + swap_memmove(vd, vd + n_ofs, n_siz); + memcpy(vd + n_siz, &tmp, n_ofs); + } +} diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index dd085b084b..07a5eac092 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -1790,6 +1790,35 @@ static void trans_CPY_z_i(DisasContext *s, arg_CPY_z_i *a, uint32_t insn) tcg_temp_free_i64(t_imm); } +/* + *** SVE Permute Extract Group + */ + +static void trans_EXT(DisasContext *s, arg_EXT *a, uint32_t insn) +{ + unsigned vsz = vec_full_reg_size(s); + unsigned n_ofs = a->imm >= vsz ? 0 : a->imm; + unsigned n_siz = vsz - n_ofs; + unsigned d = vec_full_reg_offset(s, a->rd); + unsigned n = vec_full_reg_offset(s, a->rn); + unsigned m = vec_full_reg_offset(s, a->rm); + + /* Use host vector move insns if we have appropriate sizes + and no unfortunate overlap. */ + if (m != d + && n_ofs == size_for_gvec(n_ofs) + && n_siz == size_for_gvec(n_siz) + && (d != n || n_siz <= n_ofs)) { + tcg_gen_gvec_mov(0, d, n + n_ofs, n_siz, n_siz); + if (n_ofs != 0) { + tcg_gen_gvec_mov(0, d + n_siz, m, n_ofs, n_ofs); + } + return; + } + + tcg_gen_gvec_3_ool(d, n, m, vsz, vsz, n_ofs, gen_helper_sve_ext); +} + /* *** SVE Memory - 32-bit Gather and Unsized Contiguous Group */ diff --git a/target/arm/sve.decode b/target/arm/sve.decode index e6e10a4f84..5e3a9839d4 100644 --- a/target/arm/sve.decode +++ b/target/arm/sve.decode @@ -22,8 +22,9 @@ ########################################################################### # Named fields. These are primarily for disjoint fields. -%imm4_16_p1 16:4 !function=plus1 +%imm4_16_p1 16:4 !function=plus1 %imm6_22_5 22:1 5:5 +%imm8_16_10 16:5 10:3 %imm9_16_10 16:s6 10:3 %preg4_5 5:4 @@ -363,6 +364,12 @@ FCPY 00000101 .. 01 .... 110 imm:8 ..... @rdn_pg4 CPY_m_i 00000101 .. 01 .... 01 . ........ ..... @rdn_pg4 imm=%sh8_i8s CPY_z_i 00000101 .. 01 .... 00 . ........ ..... @rdn_pg4 imm=%sh8_i8s +### SVE Permute - Extract Group + +# SVE extract vector (immediate offset) +EXT 00000101 001 ..... 000 ... rm:5 rd:5 \ + &rrri rn=%reg_movprfx imm=%imm8_16_10 + ### SVE Predicate Logical Operations Group # SVE predicate logical operations