From patchwork Wed Sep 4 13:26:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 1980815 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=rQInIzEb; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WzNl13CVMz1yg3 for ; Wed, 4 Sep 2024 23:34:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 13A25384A4A3 for ; Wed, 4 Sep 2024 13:34:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by sourceware.org (Postfix) with ESMTPS id 259CA385C6C0 for ; Wed, 4 Sep 2024 13:27:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 259CA385C6C0 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 259CA385C6C0 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c32 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725456462; cv=none; b=dXBvmTRj90wmKqqrvjaThpdaN3/BwNm3rpprNQse6843vlPI+VippmfWCdppQUNOEXEIWsRbWeciwQPSs2M0dBAhhLRbRHj75XGq2ZdsWYStxJ4gI2OdTHggD9PA4LBTZONuoPauYJUvyROJKNBBeBYmsiXno2WSfnNOw+Lnycc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725456462; c=relaxed/simple; bh=Phyz/d8Y6cT+rKmjCZZPjAyQ1AP8kqBP1Gc7OHCbtPg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=oRa/5Uck0Tu9aOBSvOZuec7nc38GEORqV0FDMiQDa5TkWqk7QRJf/CLxDYXLNcQkt0QOqYZpBokE3E6NZuKDf/U2qOCWjMpUqL7Q2QElhgkC4Raa3NyuObJzuYuTA3gVBYVzDZ9jDx+tLFR11NnakEbew2mtnFknWjWCBBPWl9Y= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-5e16cb56d4aso1926382eaf.1 for ; Wed, 04 Sep 2024 06:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725456457; x=1726061257; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JGdOAonFxFcTh38HT3zQ7Og5cZWF3iDIv8VSU6omoYE=; b=rQInIzEbi6PcwrvKBwLNXbxGa/fm+5MlLBexI73tpDb2HYKn9Lbk7FhdawQ9vroeNP qXy8jcqG/XrX/dC69Icbrs2WcTv5Qc9XASPj/xots7FkHhNAub07pzQAj3VifA0G2RBl k9JW/Td4cyHNVeJhek50PElZ5wSbJiEQFRDXQd87XoW0O4AQ6tlwx8tS5I0VsArEFNvc GmpiJ5+UZ5GztdcCN+YERtClVMkkzNSKbIUVxJCR2dqQ0Lcj2fkhaHMexZ8+EsGV9Hyq W8aAAPCZRH5G+m6AZ10J3j742xIo7nKJ9+J7hB2qDePBZOcTizJKsca63TBwJbv6x1gg faQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725456457; x=1726061257; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JGdOAonFxFcTh38HT3zQ7Og5cZWF3iDIv8VSU6omoYE=; b=B6vzEP/bRon8neMoiG2QfOf0Hs9ahtMYraWWSeM0fTe/Y1SWqg1RzK8o8xCULPPbPh 1EEUrpWO6WV+7p0tHrEP1NR30Jqv0+Wok8oJKq9kJlJeH9GMTYSr+0GUWhW5USiEWR6S /D0mmAT//nCSdj/SjW+IPkQ5/+DF4jTV0jX+RykRQVHxBV8qzScBHrmSVrhDRNoNF8cI CRYdQVD07gyd83LbEkpQWoWDcecXAzjNTueyVpMliqiLkL1XTLbYMI4hja1Ov3OmbRH2 tCKQtUme53rbxBJIymCg5pcyJuSnJ5x0fnrulA5D/Xf+cgY5FGbMgq5vEl8h7yDLPz/x 1AmQ== X-Gm-Message-State: AOJu0YxAh23GpbyZ0T4HRrdhdOzdGsu1AofgUCiB6R1REqQi8y3yyg+F 0fbUd4IyoDDvD/GZBPBU5WfYSsewm7GPoDi7FwlPVt3E/IWFlZhYD/+0Ckyw37cS0qQ/KISGTyt +WM/o3Q== X-Google-Smtp-Source: AGHT+IGwEPS+54xHTj1WLc2RozgiHTVRs/JAtXBWsrP170/ns+k4dWPF4oS1zFaxEM0zjKgp2hbeKg== X-Received: by 2002:a05:6820:545:b0:5c4:57d:691e with SMTP id 006d021491bc7-5dfacf23410mr18429522eaf.2.1725456456681; Wed, 04 Sep 2024 06:27:36 -0700 (PDT) Received: from localhost.localdomain ([139.178.84.207]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5dfa0580692sm2308062eaf.46.2024.09.04.06.27.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 06:27:35 -0700 (PDT) From: Christophe Lyon To: gcc-patches@gcc.gnu.org, richard.earnshaw@arm.com, ramanara@nvidia.com Cc: Christophe Lyon Subject: [PATCH v2 18/36] arm: [MVE intrinsics] add viddup shape Date: Wed, 4 Sep 2024 13:26:32 +0000 Message-Id: <20240904132650.2720446-19-christophe.lyon@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240904132650.2720446-1-christophe.lyon@linaro.org> References: <20240711214305.3193022-1-christophe.lyon@linaro.org> <20240904132650.2720446-1-christophe.lyon@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org This patch adds the viddup shape description for vidup and vddup. This requires the addition of report_not_one_of and function_checker::require_immediate_one_of to gcc/config/arm/arm-mve-builtins.cc (they are copies of the aarch64 SVE counterpart). This patch also introduces MODE_wb. 2024-08-21 Christophe Lyon gcc/ * config/arm/arm-mve-builtins-shapes.cc (viddup): New. * config/arm/arm-mve-builtins-shapes.h (viddup): New. * config/arm/arm-mve-builtins.cc (report_not_one_of): New. (function_checker::require_immediate_one_of): New. * config/arm/arm-mve-builtins.def (wb): New mode. * config/arm/arm-mve-builtins.h (function_checker) Add require_immediate_one_of. --- gcc/config/arm/arm-mve-builtins-shapes.cc | 85 +++++++++++++++++++++++ gcc/config/arm/arm-mve-builtins-shapes.h | 1 + gcc/config/arm/arm-mve-builtins.cc | 44 ++++++++++++ gcc/config/arm/arm-mve-builtins.def | 1 + gcc/config/arm/arm-mve-builtins.h | 2 + 5 files changed, 133 insertions(+) diff --git a/gcc/config/arm/arm-mve-builtins-shapes.cc b/gcc/config/arm/arm-mve-builtins-shapes.cc index 8a849c2bc02..971e86a2727 100644 --- a/gcc/config/arm/arm-mve-builtins-shapes.cc +++ b/gcc/config/arm/arm-mve-builtins-shapes.cc @@ -2191,6 +2191,91 @@ struct vcvtx_def : public overloaded_base<0> }; SHAPE (vcvtx) +/* _t vfoo[_n]_t0(uint32_t, const int) + _t vfoo[_wb]_t0(uint32_t *, const int) + + Shape for vector increment or decrement and duplicate operations that take + an integer or pointer to integer first argument and an immediate, and + produce a vector. + + Check that 'imm' is one of 1, 2, 4 or 8. + + Example: vddupq. + uint8x16_t [__arm_]vddupq[_n]_u8(uint32_t a, const int imm) + uint8x16_t [__arm_]vddupq[_wb]_u8(uint32_t *a, const int imm) + uint8x16_t [__arm_]vddupq_m[_n_u8](uint8x16_t inactive, uint32_t a, const int imm, mve_pred16_t p) + uint8x16_t [__arm_]vddupq_m[_wb_u8](uint8x16_t inactive, uint32_t *a, const int imm, mve_pred16_t p) + uint8x16_t [__arm_]vddupq_x[_n]_u8(uint32_t a, const int imm, mve_pred16_t p) + uint8x16_t [__arm_]vddupq_x[_wb]_u8(uint32_t *a, const int imm, mve_pred16_t p) */ +struct viddup_def : public overloaded_base<0> +{ + bool + explicit_type_suffix_p (unsigned int i, enum predication_index pred, + enum mode_suffix_index, + type_suffix_info) const override + { + return ((i == 0) && (pred != PRED_m)); + } + + bool + skip_overload_p (enum predication_index, enum mode_suffix_index mode) const override + { + /* For MODE_wb, share the overloaded instance with MODE_n. */ + if (mode == MODE_wb) + return true; + + return false; + } + + void + build (function_builder &b, const function_group_info &group, + bool preserve_user_namespace) const override + { + b.add_overloaded_functions (group, MODE_none, preserve_user_namespace); + build_all (b, "v0,su32,su64", group, MODE_n, preserve_user_namespace); + build_all (b, "v0,as,su64", group, MODE_wb, preserve_user_namespace); + } + + tree + resolve (function_resolver &r) const override + { + unsigned int i, nargs; + type_suffix_index type_suffix = NUM_TYPE_SUFFIXES; + if (!r.check_gp_argument (2, i, nargs)) + return error_mark_node; + + type_suffix = r.type_suffix_ids[0]; + /* With PRED_m, ther is no type suffix, so infer it from the first (inactive) + argument. */ + if (type_suffix == NUM_TYPE_SUFFIXES) + type_suffix = r.infer_vector_type (0); + + unsigned int last_arg = i - 1; + /* Check that last_arg is either scalar or pointer. */ + if (!r.scalar_argument_p (last_arg)) + return error_mark_node; + + if (!r.require_integer_immediate (last_arg + 1)) + return error_mark_node; + + /* With MODE_n we expect a scalar, with MODE_wb we expect a pointer. */ + mode_suffix_index mode_suffix; + if (POINTER_TYPE_P (r.get_argument_type (last_arg))) + mode_suffix = MODE_wb; + else + mode_suffix = MODE_n; + + return r.resolve_to (mode_suffix, type_suffix); + } + + bool + check (function_checker &c) const override + { + return c.require_immediate_one_of (1, 1, 2, 4, 8); + } +}; +SHAPE (viddup) + /* _t vfoo[_t0](_t, _t, mve_pred16_t) i.e. a version of the standard ternary shape in which diff --git a/gcc/config/arm/arm-mve-builtins-shapes.h b/gcc/config/arm/arm-mve-builtins-shapes.h index 80340dc33ec..186287c1620 100644 --- a/gcc/config/arm/arm-mve-builtins-shapes.h +++ b/gcc/config/arm/arm-mve-builtins-shapes.h @@ -82,6 +82,7 @@ namespace arm_mve extern const function_shape *const vcvt_f16_f32; extern const function_shape *const vcvt_f32_f16; extern const function_shape *const vcvtx; + extern const function_shape *const viddup; extern const function_shape *const vpsel; } /* end namespace arm_mve::shapes */ diff --git a/gcc/config/arm/arm-mve-builtins.cc b/gcc/config/arm/arm-mve-builtins.cc index 84d94bb634f..1180421bf0a 100644 --- a/gcc/config/arm/arm-mve-builtins.cc +++ b/gcc/config/arm/arm-mve-builtins.cc @@ -630,6 +630,20 @@ report_not_enum (location_t location, tree fndecl, unsigned int argno, " a valid %qT value", actual, argno + 1, fndecl, enumtype); } +/* Report that LOCATION has a call to FNDECL in which argument ARGNO has + the value ACTUAL, whereas the function requires one of VALUE0..3. + ARGNO counts from zero. */ +static void +report_not_one_of (location_t location, tree fndecl, unsigned int argno, + HOST_WIDE_INT actual, HOST_WIDE_INT value0, + HOST_WIDE_INT value1, HOST_WIDE_INT value2, + HOST_WIDE_INT value3) +{ + error_at (location, "passing %wd to argument %d of %qE, which expects" + " %wd, %wd, %wd or %wd", actual, argno + 1, fndecl, value0, value1, + value2, value3); +} + /* Checks that the mve.fp extension is enabled, given that REQUIRES_FLOAT indicates whether it is required or not for function FNDECL. Report an error against LOCATION if not. */ @@ -1969,6 +1983,36 @@ function_checker::require_immediate_enum (unsigned int rel_argno, tree type) return false; } +/* Check that argument REL_ARGNO is an integer constant expression that + has one of the given values. */ +bool +function_checker::require_immediate_one_of (unsigned int rel_argno, + HOST_WIDE_INT value0, + HOST_WIDE_INT value1, + HOST_WIDE_INT value2, + HOST_WIDE_INT value3) +{ + unsigned int argno = m_base_arg + rel_argno; + if (!argument_exists_p (argno)) + return true; + + HOST_WIDE_INT actual; + if (!require_immediate (argno, actual)) + return false; + + if (actual != value0 + && actual != value1 + && actual != value2 + && actual != value3) + { + report_not_one_of (location, fndecl, argno, actual, + value0, value1, value2, value3); + return false; + } + + return true; +} + /* Check that argument REL_ARGNO is an integer constant expression in the range [MIN, MAX]. REL_ARGNO counts from the end of the predication arguments. */ diff --git a/gcc/config/arm/arm-mve-builtins.def b/gcc/config/arm/arm-mve-builtins.def index 24ebb3375f0..265cc7b0c69 100644 --- a/gcc/config/arm/arm-mve-builtins.def +++ b/gcc/config/arm/arm-mve-builtins.def @@ -36,6 +36,7 @@ DEF_MVE_MODE (n, none, none, none) DEF_MVE_MODE (offset, none, none, bytes) DEF_MVE_MODE (r, none, none, none) +DEF_MVE_MODE (wb, none, none, none) #define REQUIRES_FLOAT false DEF_MVE_TYPE (mve_pred16_t, boolean_type_node) diff --git a/gcc/config/arm/arm-mve-builtins.h b/gcc/config/arm/arm-mve-builtins.h index 3306736bff0..fe7adf0e054 100644 --- a/gcc/config/arm/arm-mve-builtins.h +++ b/gcc/config/arm/arm-mve-builtins.h @@ -433,6 +433,8 @@ public: bool require_immediate_enum (unsigned int, tree); bool require_immediate_lane_index (unsigned int, unsigned int = 1); + bool require_immediate_one_of (unsigned int, HOST_WIDE_INT, HOST_WIDE_INT, + HOST_WIDE_INT, HOST_WIDE_INT); bool require_immediate_range (unsigned int, HOST_WIDE_INT, HOST_WIDE_INT); bool check ();