From patchwork Fri Jan 16 17:26:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Lawrence X-Patchwork-Id: 429946 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 84DAA140276 for ; Sat, 17 Jan 2015 04:26:53 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=kCiiC9s6GNmmn3yqP D8uzEzTDX/ij3xCLLmM2gfzaDcR56e/QRzPxD36/xRBCqGFFklyKy2+/ydLe3D8r mp1HQIv+oY2Cor/z4M7nXNCSWHbLgsFhiPur0R4db+M/kzGmZBa2LqVoPXFgxRNW VWodJrtIv85MsnTvDdki5LTJJg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=LG5EuKhRGU8b8xqmVenBP1N O5hg=; b=TdfJkFJdGZbyqcdgW6JjkbquQZ1wtb7h05iUVacv61u2W9zTE/qu+V4 izop5hkbtz1D+yADqOUuMTVHQaYeohhdjUxy12+Qmj3jluGneFwVdWTiMknuDBFG xQK8eGDoQE+pCnvPJ3q5XSZGR3sUnLmWRgvc0NI16wKdo1oQAJGA= Received: (qmail 32081 invoked by alias); 16 Jan 2015 17:26:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 32069 invoked by uid 89); 16 Jan 2015 17:26:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Jan 2015 17:26:43 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by service87.mimecast.com; Fri, 16 Jan 2015 17:26:41 +0000 Received: from [10.1.209.51] ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 16 Jan 2015 17:26:40 +0000 Message-ID: <54B949D0.3010509@arm.com> Date: Fri, 16 Jan 2015 17:26:40 +0000 From: Alan Lawrence User-Agent: Thunderbird 2.0.0.24 (X11/20101213) MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Charles Baylis Subject: [PATCH 2/2][ARM] PR/63870: Add a __builtin_lane_check References: <54B94342.3070607@arm.com> In-Reply-To: <54B94342.3070607@arm.com> X-MC-Unique: 115011617264102501 X-IsSubscribed: yes This parallels the present form of __builtin_aarch64_im_lane_boundsi, and allows to check lane indices for intrinsics that can otherwise be written in terms of GCC vector extensions. The new builtin is not used in this patch but is used in my series of float16_t intrinsics (https://gcc.gnu.org/ml/gcc-patches/2015-01/msg01434.html), and at some point in the future we should rewrite existing intrinsics (for other types) to this form too, but I'm leaving that for a later patch series :). Cross-tested check-gcc on arm-none-eabi Bootstrapped on arm-none-linux-gnueabihf cortex-a15 gcc/ChangeLog: * config/arm/arm-builtins.c (enum arm_builtins): Add ARM_BUILTIN_NEON_BASE and ARM_BUILTIN_NEON_LANE_CHECK. (ARM_BUILTIN_NEON_BASE): Rename macro to.... (ARM_BUILTIN_NEON_PATTERN_START): ...this. (arm_init_neon_builtins): Register __builtin_arm_lane_check. (arm_expand_neon_builtin): Handle ARM_BUILTIN_NEON_LANE_CHECK. diff --git a/gcc/config/arm/arm-builtins.c b/gcc/config/arm/arm-builtins.c index 2ca7ac5ad3cf82941a5d3b6707a0a41f3157190b..baa83490fcd9bf68d9e9bdbd57cdf6f2d3d0e056 100644 --- a/gcc/config/arm/arm-builtins.c +++ b/gcc/config/arm/arm-builtins.c @@ -521,12 +521,16 @@ enum arm_builtins #undef CRYPTO2 #undef CRYPTO3 + ARM_BUILTIN_NEON_BASE, + ARM_BUILTIN_NEON_LANE_CHECK = ARM_BUILTIN_NEON_BASE, + #include "arm_neon_builtins.def" ARM_BUILTIN_MAX }; -#define ARM_BUILTIN_NEON_BASE (ARM_BUILTIN_MAX - ARRAY_SIZE (neon_builtin_data)) +#define ARM_BUILTIN_NEON_PATTERN_START \ + (ARM_BUILTIN_MAX - ARRAY_SIZE (neon_builtin_data)) #undef CF #undef VAR1 @@ -885,7 +889,7 @@ arm_init_simd_builtin_scalar_types (void) static void arm_init_neon_builtins (void) { - unsigned int i, fcode = ARM_BUILTIN_NEON_BASE; + unsigned int i, fcode = ARM_BUILTIN_NEON_PATTERN_START; arm_init_simd_builtin_types (); @@ -895,6 +899,15 @@ arm_init_neon_builtins (void) system. */ arm_init_simd_builtin_scalar_types (); + tree lane_check_fpr = build_function_type_list (void_type_node, + intSI_type_node, + intSI_type_node, + NULL); + arm_builtin_decls[ARM_BUILTIN_NEON_LANE_CHECK] = + add_builtin_function ("__builtin_arm_lane_check", lane_check_fpr, + ARM_BUILTIN_NEON_LANE_CHECK, BUILT_IN_MD, + NULL, NULL_TREE); + for (i = 0; i < ARRAY_SIZE (neon_builtin_data); i++, fcode++) { bool print_type_signature_p = false; @@ -2155,14 +2168,28 @@ arm_expand_neon_args (rtx target, machine_mode map_mode, int fcode, return target; } -/* Expand a Neon builtin. These are "special" because they don't have symbolic +/* Expand a Neon builtin, i.e. those registered only if TARGET_NEON holds. + Most of these are "special" because they don't have symbolic constants defined per-instruction or per instruction-variant. Instead, the required info is looked up in the table neon_builtin_data. */ static rtx arm_expand_neon_builtin (int fcode, tree exp, rtx target) { + if (fcode == ARM_BUILTIN_NEON_LANE_CHECK) + { + tree nlanes = CALL_EXPR_ARG (exp, 0); + gcc_assert (TREE_CODE (nlanes) == INTEGER_CST); + rtx lane_idx = expand_normal (CALL_EXPR_ARG (exp, 1)); + if (CONST_INT_P (lane_idx)) + neon_lane_bounds (lane_idx, 0, TREE_INT_CST_LOW (nlanes), exp); + else + error ("%Klane index must be a constant immediate", exp); + /* Don't generate any RTL. */ + return const0_rtx; + } + neon_builtin_datum *d = - &neon_builtin_data[fcode - ARM_BUILTIN_NEON_BASE]; + &neon_builtin_data[fcode - ARM_BUILTIN_NEON_PATTERN_START]; enum insn_code icode = d->code; builtin_arg args[SIMD_MAX_BUILTIN_ARGS]; int num_args = insn_data[d->code].n_operands;