From patchwork Tue May 14 00:05:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164110 Delivered-To: patch@linaro.org Received: by 2002:ac9:2a84:0:0:0:0:0 with SMTP id p4csp5907229oca; Mon, 13 May 2019 23:09:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6gZa6p8xJBcQSYxPlD+87lFTc+TKcHBvgexgr4i39beQS22cNclriEWMyKa0vb6wYyFS1 X-Received: by 2002:a17:906:5e4e:: with SMTP id b14mr15672544eju.100.1557814189316; Mon, 13 May 2019 23:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557814189; cv=none; d=google.com; s=arc-20160816; b=AMmTB9fqYzDI4olqFb9ryoVPo5SOa4+7vuzjdHf7n5HB+4pXlgxnI3TTuPMpwIWAL7 PSri8mMXPID5zmnqv87Vawm90B78fhJ+3xJd6IgZlvmSHnLul6kfkCEWY4i+Xw3LcLlT 4+pOH49abMqA2HfIICV7GUMqdR0PCgXA2IiGtivKLXBSnx/IHqmteDlFobjQId+VHvTT 4kyknIqMW1kPg/xdQY52EnGbIrDhLRNr68GQhBB5kpRmnHumH8XRNldwXH/B6SB0xsIG aTZNrYUUBF1cqgMdyacvSsMs2r06wydNh7yJyvb4jCMAwU8+PTL0jTmktc+izU4M+hNz 8PSA== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=JF2bKE9XmhoHbt9KR1NJ6aVBR5o9hUq7Nq5BVGZIG24=; b=GVKXk0RkUbbFDyM48+QoP0s2L5wwO6U4zlViBel/9gWnSz9DbZrw6YZ6WHX6Wm3kiR MYxr7XK1jRe682LO/vkhQ2a/UUyEfiulitUV4JqaO7QenPSIz+gHhFIY3TebBn4Wt0iZ oIf3Nrki8nGSJXtS7W/Ph4CD46bJu7r2LfVpn6hDZdhqxTr7a061MiZJuIFDYQFqlSro hE/2yIsbGV7HgaVp/XR+QjEKwF1VOMrE2GKiCKM/O4lYzZYpbb8cXUT6e+dBJBhN1BwX N7LQLc0sWZNLuPwvRy3WV7rtI3SkFCvxFxuQ7HWu+EDi26eYKCsyNwJONm8vf3u86JUd 2Mhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LcN1CWte; 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 q5si6389769edd.0.2019.05.13.23.09.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 13 May 2019 23:09:49 -0700 (PDT) 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=LcN1CWte; 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 ([127.0.0.1]:39975 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQQdI-00025p-9U for patch@linaro.org; Tue, 14 May 2019 02:09:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQQbt-0001IT-QY for qemu-devel@nongnu.org; Tue, 14 May 2019 02:08:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQQbs-00061F-OA for qemu-devel@nongnu.org; Tue, 14 May 2019 02:08:21 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:44557) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQKx6-0002xw-RC for qemu-devel@nongnu.org; Mon, 13 May 2019 20:05:54 -0400 Received: by mail-pl1-x633.google.com with SMTP id d3so7261676plj.11 for ; Mon, 13 May 2019 17:05:48 -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 :mime-version:content-transfer-encoding; bh=JF2bKE9XmhoHbt9KR1NJ6aVBR5o9hUq7Nq5BVGZIG24=; b=LcN1CWtejXlR4vPyIVND7D+/ad9xERF+38DPtvt1fWZ9u+6yhisaiq+OT9dfkUb7d0 P+5v23BgYWG1N57AWYPOr/A6yQxvFMQY9tVirHSHBPZe02nyAkyHamb0UUlHL7xZrHOo q9WWif05Q6upWGi84sAHzMkMeXkcEpJbAPhkaX08wMP+zey+f0nnHqPpDdKMJHg26Ua7 6VIa1ins50U4KpmUuoEYGhWpIZMERoxp8okUO3RkKgTtUdY+CuulqfOmdg6EVngKP3Gi 38/Pv+B3ntzaw/d8ZS5+XQklQGe/G7tnBIXOIc/D9qR7dyVzZumRA6hy0vbCODHMHMRk lkzA== 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=JF2bKE9XmhoHbt9KR1NJ6aVBR5o9hUq7Nq5BVGZIG24=; b=X6KNZnAQHducFE2RXsMFOhu6OvX0b5OafnUwx2PI/p85lbzl0d0fJEw12MZNyStf7f hI38hPN2gO99islSiyknYZeydNyFB1uBoJYdiO5YU64cA6HaAG9kAYX1P/Aie5G47AaI 0hING2fFupm+yJWn9rbsghFFYVELgRNncfIJt+CcRD+UvQ4uGOD/CA7RtzgvSVI6nVKu a0ENql1+ou3eel0X/JkKGpMydzP3Kr1XJ1Kn/abC8LqDNlKn7J31sX+bxO3AQ+cc51kY lWB31VL2UXMDIjX9FaS4BIVWA6zyNxTzo80uIMXuFQq/YtN48FHKdinoTMbou7MI4iYy UiHw== X-Gm-Message-State: APjAAAUlF1Kxh4NSFfF8VZoXb+1GCTSbc6wcp8TWg+cey7kzvOEpwFXJ PZZ9a7iWTTTtI4ADf1/HyIH/NE4f5Dg= X-Received: by 2002:a17:902:2f:: with SMTP id 44mr34503984pla.137.1557792346948; Mon, 13 May 2019 17:05:46 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id u3sm238151pfn.29.2019.05.13.17.05.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 17:05:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 17:05:12 -0700 Message-Id: <20190514000540.4313-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190514000540.4313-1-richard.henderson@linaro.org> References: <20190514000540.4313-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::633 Subject: [Qemu-devel] [PULL 03/31] tcg: Allow add_vec, sub_vec, neg_vec, not_vec to be expanded 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: peter.maydell@linux.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" PowerPC Altivec does not support add and subtract of 64-bit elements. Prepare for that configuration by not assuming the operation is universally supported. Reviewed-by: Alex Bennée Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- tcg/tcg-op-vec.c | 49 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/tcg/tcg-op-vec.c b/tcg/tcg-op-vec.c index 27f65600c3..cfb18682b1 100644 --- a/tcg/tcg-op-vec.c +++ b/tcg/tcg-op-vec.c @@ -226,16 +226,6 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr b, TCGArg o, TCGType low_type) vec_gen_3(INDEX_op_st_vec, low_type, 0, ri, bi, o); } -void tcg_gen_add_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) -{ - vec_gen_op3(INDEX_op_add_vec, vece, r, a, b); -} - -void tcg_gen_sub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) -{ - vec_gen_op3(INDEX_op_sub_vec, vece, r, a, b); -} - void tcg_gen_and_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) { vec_gen_op3(INDEX_op_and_vec, 0, r, a, b); @@ -296,11 +286,30 @@ void tcg_gen_eqv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) tcg_gen_not_vec(0, r, r); } +static bool do_op2(unsigned vece, TCGv_vec r, TCGv_vec a, TCGOpcode opc) +{ + TCGTemp *rt = tcgv_vec_temp(r); + TCGTemp *at = tcgv_vec_temp(a); + TCGArg ri = temp_arg(rt); + TCGArg ai = temp_arg(at); + TCGType type = rt->base_type; + int can; + + tcg_debug_assert(at->base_type >= type); + can = tcg_can_emit_vec_op(opc, type, vece); + if (can > 0) { + vec_gen_2(opc, type, vece, ri, ai); + } else if (can < 0) { + tcg_expand_vec_op(opc, type, vece, ri, ai); + } else { + return false; + } + return true; +} + void tcg_gen_not_vec(unsigned vece, TCGv_vec r, TCGv_vec a) { - if (TCG_TARGET_HAS_not_vec) { - vec_gen_op2(INDEX_op_not_vec, 0, r, a); - } else { + if (!TCG_TARGET_HAS_not_vec || !do_op2(vece, r, a, INDEX_op_not_vec)) { TCGv_vec t = tcg_const_ones_vec_matching(r); tcg_gen_xor_vec(0, r, a, t); tcg_temp_free_vec(t); @@ -309,9 +318,7 @@ void tcg_gen_not_vec(unsigned vece, TCGv_vec r, TCGv_vec a) void tcg_gen_neg_vec(unsigned vece, TCGv_vec r, TCGv_vec a) { - if (TCG_TARGET_HAS_neg_vec) { - vec_gen_op2(INDEX_op_neg_vec, vece, r, a); - } else { + if (!TCG_TARGET_HAS_neg_vec || !do_op2(vece, r, a, INDEX_op_neg_vec)) { TCGv_vec t = tcg_const_zeros_vec_matching(r); tcg_gen_sub_vec(vece, r, t, a); tcg_temp_free_vec(t); @@ -409,6 +416,16 @@ static void do_op3(unsigned vece, TCGv_vec r, TCGv_vec a, } } +void tcg_gen_add_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) +{ + do_op3(vece, r, a, b, INDEX_op_add_vec); +} + +void tcg_gen_sub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) +{ + do_op3(vece, r, a, b, INDEX_op_sub_vec); +} + void tcg_gen_mul_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b) { do_op3(vece, r, a, b, INDEX_op_mul_vec);