From patchwork Tue Dec 18 06:38:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 154089 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3349000ljp; Mon, 17 Dec 2018 22:46:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/VJ6uLL1OVlK1XjUf7rrBSuwJsumk6DdiqdL9CjtrL+sBuWoDBqXIViGdS+ijCRloma6QeV X-Received: by 2002:a0c:b8ac:: with SMTP id y44mr15836012qvf.76.1545115597216; Mon, 17 Dec 2018 22:46:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545115597; cv=none; d=google.com; s=arc-20160816; b=YQ451z0/aYITbkK/Ven5bb19/2nK1Et6POlH5W7i81GDQlCyWfIUVZOdW1ki/3md77 bHadW4WqOc3qKLfXnTzLDY2kxJ6fMtxS0253TJ5E3YEVGmHFWuTTFbAHcUtnW9hmVzZr Dd2KQ54tStI/knU+R9Jvms8bjwtoUKqTS4Y7Qa2LWXW7j+PPDPj4PG/zsQYakEdp8Ha2 IHMGVVb1i/2VIC5yosjszpm2ygVZlsfSt/dg7GFf+38/QPwTtGHPW7J033VX1t3DyQeT WJllPZHWVyBaMRTFJEkjKWPoX58QR1Zxk9F5DPdJgqSqWXN6jx+vzOYfEaWAR4QZX6WS CWlQ== 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; bh=b6Irb6oSf56jzkl09+An3n/u5tlRfj1yzixgXmHIxxE=; b=PEE34PW4aeU/LD3verRsvGOhjgvKXqb2yXipEyog1FKzDAvpdn1OEcX6xsAITJLpaf nPJQ0t4yLwUvGIzYaFNkK2dOayYaRh+69k24lLU8AP8OnUrhWa0tibm0JmGbwCocvDp6 d0TAAph/gsgwj7Y4VbHUqSGhF2OGAO5QPvLFevxvvwbkdR8VJcLY9FY9r6pUusvtR+du CGfKzwdmI+EXqwOAJ2N2AwRfGVNeDCGhEr4HYLdK+myG6ZmEp0/stAc010hugi77ZWJx DsTySbd2Ms8t7nv/6C0/2suke41U6loGBs5IhPQ4meLZb0ybumCovExhEBCEyq6Wo0+g +RHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=E7Oy0q2Y; 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 j5si5998346qvi.95.2018.12.17.22.46.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 17 Dec 2018 22:46:37 -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=E7Oy0q2Y; 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]:52057 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZ99I-00076Z-JU for patch@linaro.org; Tue, 18 Dec 2018 01:46:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZ92t-0001fJ-Rp for qemu-devel@nongnu.org; Tue, 18 Dec 2018 01:40:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZ92q-0002ow-58 for qemu-devel@nongnu.org; Tue, 18 Dec 2018 01:39:59 -0500 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:42869) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZ92p-0001vu-PB for qemu-devel@nongnu.org; Tue, 18 Dec 2018 01:39:55 -0500 Received: by mail-pg1-x541.google.com with SMTP id d72so7337986pga.9 for ; Mon, 17 Dec 2018 22:39:22 -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=b6Irb6oSf56jzkl09+An3n/u5tlRfj1yzixgXmHIxxE=; b=E7Oy0q2Yzm5pQVlbO7R0eF2H97xpXz3TaxnOlJMsO2/6zf4qEk+g3hyXlswQbnqSVB faB9EhKS0mi7SFpMCToAKY/Idofc3PcfSsak6rnkkKcqg1/bPFXYIUCy7sILa7LFyTDJ nkYbXL3R7VXcfnomJfcl6ih3TE4TmBTChRA6c= 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=b6Irb6oSf56jzkl09+An3n/u5tlRfj1yzixgXmHIxxE=; b=RtIsBW70x2dYnzyirMdK9WdYyovuPcdlL/7PeR7Dm68JpejHUGOSfVO/QscoDJI3I2 HDw3UM4j5EpJir5q7Ts3TBpcSYFv8kxYHtufp8/f9yghYXwsvHxe5HFgP0UHGv82DIU9 n41dBm26zBTeJO69ghmEwPd/9L43Dv5JgKxSsr9pNM3eqrGQvMH5A89vTVBhXi05YdK3 KrQTHfYU2yQwwUlSFhrzSFXQdYlXH5ujO8WeCA/SnnndTd1eRyax7SaVZl3GPOCn+m62 3vkmgnPIvx+LUcZvNq9Id6bASp2qvx9ESKEH26pqYrnmgtfEkF10jPF5aTjPv/aRt0XP cRvw== X-Gm-Message-State: AA+aEWaE8FvLZB7NGwyy3Xc6bixXBkkkyHRu20Xb/9IffXhJXUoJF76w 4wS3IFWePYEf0sg/O23FM/QZckVGgpg= X-Received: by 2002:a65:49cd:: with SMTP id t13mr14937083pgs.376.1545115161073; Mon, 17 Dec 2018 22:39:21 -0800 (PST) Received: from cloudburst.twiddle.net (97-126-115-157.tukw.qwest.net. [97.126.115.157]) by smtp.gmail.com with ESMTPSA id c7sm27072509pfh.18.2018.12.17.22.39.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Dec 2018 22:39:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 17 Dec 2018 22:38:43 -0800 Message-Id: <20181218063911.2112-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181218063911.2112-1-richard.henderson@linaro.org> References: <20181218063911.2112-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH 06/34] tcg/i386: Implement vector saturating arithmetic 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, mark.cave-ayland@ilande.co.uk, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Only MO_8 and MO_16 are implemented, since that's all the instruction set provides. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.h | 2 +- tcg/i386/tcg-target.inc.c | 42 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) -- 2.17.2 diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 44381062e6..f50234d97b 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -185,7 +185,7 @@ extern bool have_avx2; #define TCG_TARGET_HAS_shv_vec 0 #define TCG_TARGET_HAS_cmp_vec 1 #define TCG_TARGET_HAS_mul_vec 1 -#define TCG_TARGET_HAS_sat_vec 0 +#define TCG_TARGET_HAS_sat_vec 1 #define TCG_TARGET_deposit_i32_valid(ofs, len) \ (((ofs) == 0 && (len) == 8) || ((ofs) == 8 && (len) == 8) || \ diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index c21c3272f2..3571483bae 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -377,6 +377,10 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, #define OPC_PADDW (0xfd | P_EXT | P_DATA16) #define OPC_PADDD (0xfe | P_EXT | P_DATA16) #define OPC_PADDQ (0xd4 | P_EXT | P_DATA16) +#define OPC_PADDSB (0xec | P_EXT | P_DATA16) +#define OPC_PADDSW (0xed | P_EXT | P_DATA16) +#define OPC_PADDUB (0xdc | P_EXT | P_DATA16) +#define OPC_PADDUW (0xdd | P_EXT | P_DATA16) #define OPC_PAND (0xdb | P_EXT | P_DATA16) #define OPC_PANDN (0xdf | P_EXT | P_DATA16) #define OPC_PBLENDW (0x0e | P_EXT3A | P_DATA16) @@ -408,6 +412,10 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, #define OPC_PSUBW (0xf9 | P_EXT | P_DATA16) #define OPC_PSUBD (0xfa | P_EXT | P_DATA16) #define OPC_PSUBQ (0xfb | P_EXT | P_DATA16) +#define OPC_PSUBSB (0xe8 | P_EXT | P_DATA16) +#define OPC_PSUBSW (0xe9 | P_EXT | P_DATA16) +#define OPC_PSUBUB (0xd8 | P_EXT | P_DATA16) +#define OPC_PSUBUW (0xd9 | P_EXT | P_DATA16) #define OPC_PUNPCKLBW (0x60 | P_EXT | P_DATA16) #define OPC_PUNPCKLWD (0x61 | P_EXT | P_DATA16) #define OPC_PUNPCKLDQ (0x62 | P_EXT | P_DATA16) @@ -2591,9 +2599,21 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, static int const add_insn[4] = { OPC_PADDB, OPC_PADDW, OPC_PADDD, OPC_PADDQ }; + static int const ssadd_insn[4] = { + OPC_PADDSB, OPC_PADDSW, OPC_UD2, OPC_UD2 + }; + static int const usadd_insn[4] = { + OPC_PADDSB, OPC_PADDSW, OPC_UD2, OPC_UD2 + }; static int const sub_insn[4] = { OPC_PSUBB, OPC_PSUBW, OPC_PSUBD, OPC_PSUBQ }; + static int const sssub_insn[4] = { + OPC_PSUBSB, OPC_PSUBSW, OPC_UD2, OPC_UD2 + }; + static int const ussub_insn[4] = { + OPC_PSUBSB, OPC_PSUBSW, OPC_UD2, OPC_UD2 + }; static int const mul_insn[4] = { OPC_UD2, OPC_PMULLW, OPC_PMULLD, OPC_UD2 }; @@ -2631,9 +2651,21 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, case INDEX_op_add_vec: insn = add_insn[vece]; goto gen_simd; + case INDEX_op_ssadd_vec: + insn = ssadd_insn[vece]; + goto gen_simd; + case INDEX_op_usadd_vec: + insn = usadd_insn[vece]; + goto gen_simd; case INDEX_op_sub_vec: insn = sub_insn[vece]; goto gen_simd; + case INDEX_op_sssub_vec: + insn = sssub_insn[vece]; + goto gen_simd; + case INDEX_op_ussub_vec: + insn = ussub_insn[vece]; + goto gen_simd; case INDEX_op_mul_vec: insn = mul_insn[vece]; goto gen_simd; @@ -3007,6 +3039,10 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_or_vec: case INDEX_op_xor_vec: case INDEX_op_andc_vec: + case INDEX_op_ssadd_vec: + case INDEX_op_usadd_vec: + case INDEX_op_sssub_vec: + case INDEX_op_ussub_vec: case INDEX_op_cmp_vec: case INDEX_op_x86_shufps_vec: case INDEX_op_x86_blend_vec: @@ -3074,6 +3110,12 @@ int tcg_can_emit_vec_op(TCGOpcode opc, TCGType type, unsigned vece) } return 1; + case INDEX_op_ssadd_vec: + case INDEX_op_usadd_vec: + case INDEX_op_sssub_vec: + case INDEX_op_ussub_vec: + return vece <= MO_16; + default: return 0; }