From patchwork Thu Dec 9 15:24:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murray Steele X-Patchwork-Id: 48714 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 150EA3858027 for ; Thu, 9 Dec 2021 15:25:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 150EA3858027 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1639063551; bh=UnUExu46kzfD/k8Q6WYaFPAfZoipGQRNXsmQBi4g098=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=QbcbkW/A5XRx+oUVtleSmEx+q7w06kJm3JxVQWJT3iw5RDGP/+5Exk3YXzSu9ydF6 ma2Lp1PRLus9GIzSOFlNjp8XQhoc7gk/kpzjDpMHK5uM+QcfH05b4uK2agkcVf899j k8ba+7x8kJvhCVwA/5/ZWYJfu6ztt3JwHBiUhJcU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150071.outbound.protection.outlook.com [40.107.15.71]) by sourceware.org (Postfix) with ESMTPS id 8219F3858402 for ; Thu, 9 Dec 2021 15:24:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8219F3858402 Received: from DB6PR0601CA0018.eurprd06.prod.outlook.com (2603:10a6:4:7b::28) by AM9PR08MB6851.eurprd08.prod.outlook.com (2603:10a6:20b:305::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.19; Thu, 9 Dec 2021 15:24:56 +0000 Received: from DB5EUR03FT048.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:7b:cafe::bf) by DB6PR0601CA0018.outlook.office365.com (2603:10a6:4:7b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.17 via Frontend Transport; Thu, 9 Dec 2021 15:24:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT048.mail.protection.outlook.com (10.152.21.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12 via Frontend Transport; Thu, 9 Dec 2021 15:24:56 +0000 Received: ("Tessian outbound a33f292be81b:v110"); Thu, 09 Dec 2021 15:24:56 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f21f93597b3ec3c1 X-CR-MTA-TID: 64aa7808 Received: from a30f764af84d.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CE20C55C-9FA0-4943-B697-4E9633A00A50.1; Thu, 09 Dec 2021 15:24:44 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a30f764af84d.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 09 Dec 2021 15:24:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XYTz/cJhPJ04v3Ot0sbWjrUBfjL10YaZ2m5N7D4gNqFrFxGjUIJj2wwTB5UYCRlPbHQy49aNcmaYGqt0khc1/5gKB2FJTJM6gtqgzkDyca/jSfbp/dzlBSGFTspx0kTuAckGrbNu6lyYfYx/v9P2tUbcc4C7V5QiKaKxCWDdb64of+Kks+CbQzLcbp5cvqVUkv6et0VNHMQYXqoboHU5KOkfXRYIe59sWwhpzOdMzKuzfw4xpFRii4uOeE2H0nnyZwRzJfw/mZ/0uj7ibc4GL3WfrYDD6Uin36XW4IKkJt00HcrZjEBU7vkLGLr+gNOXV/4XuZMZSyvr2jbVv7XihQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UnUExu46kzfD/k8Q6WYaFPAfZoipGQRNXsmQBi4g098=; b=Q3ezSiqp1aYJM+3Cz1MA91GawAgk84KtBfhbsPB00oTdJ4ynJW+FA+utZWA4QED5xM2DvX/dgcLa9TUmmtri6bLFn45fOoBeKodB5my6qrV/+WPxC3r6EV4jomP+lR43DUAZvWMQ4vyu32UZtHI4wB6m7C9ZdfPz5ev3gKM5ZlDZo/fMVBt8MKxrXYHZ54c6ChkZjZGctTFNfRqg9/GKOwHX+uwdwTiMUNyzcl/peBR0vlim0If2Fdm5HLQNin+dxK5z5WVncULjfJzMIgpo28lH1FuXOyRqx+frjDiySgZg6YWwJQRYJoe5pKX4E0tmIz9YJJR6aJSzVZxFj8MWaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB5175.eurprd08.prod.outlook.com (2603:10a6:20b:ef::11) by AM6PR08MB4659.eurprd08.prod.outlook.com (2603:10a6:20b:ca::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.19; Thu, 9 Dec 2021 15:24:32 +0000 Received: from AM6PR08MB5175.eurprd08.prod.outlook.com ([fe80::8d8f:5a4a:c1f8:c305]) by AM6PR08MB5175.eurprd08.prod.outlook.com ([fe80::8d8f:5a4a:c1f8:c305%6]) with mapi id 15.20.4755.025; Thu, 9 Dec 2021 15:24:32 +0000 Message-ID: <03099bb4-1dcf-aae5-3d77-7112ae22948a@arm.com> Date: Thu, 9 Dec 2021 15:24:30 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: [PATCH v3 2/2][GCC] arm: Declare MVE types internally via pragma To: Richard Earnshaw References: <55ba6a8c-4dda-c023-0e93-a052e4830d06@arm.com> <342ef4e3-6013-2d67-adc8-6310febe2f52@foss.arm.com> <2a59e081-0a5f-5b9b-c398-d89c6c217822@arm.com> <9ccc226a-fdf7-d465-6074-b6a78d16b316@arm.com> <060230b8-22b0-36eb-2594-c469efaabf35@arm.com> <3ad22fca-fa13-04ea-f114-01e8c52dd280@foss.arm.com> <9849efef-a0db-825a-2473-8f71dc2412b6@foss.arm.com> In-Reply-To: <9849efef-a0db-825a-2473-8f71dc2412b6@foss.arm.com> X-ClientProxiedBy: LO2P265CA0060.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::24) To AM6PR08MB5175.eurprd08.prod.outlook.com (2603:10a6:20b:ef::11) MIME-Version: 1.0 Received: from [192.168.0.15] (81.102.185.239) by LO2P265CA0060.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.21 via Frontend Transport; Thu, 9 Dec 2021 15:24:32 +0000 X-MS-Office365-Filtering-Correlation-Id: 0be8350b-d018-47d6-4742-08d9bb280e45 X-MS-TrafficTypeDiagnostic: AM6PR08MB4659:EE_|DB5EUR03FT048:EE_|AM9PR08MB6851:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: BGMiM6AGoxRS0wfKUMU0kv+cDCx+lheyRGjJj4u5Be5vMFdqgBGDvId36Bw3nJYrkszebyF/sqh7UO8rxRYu67e4vvnpVqWorg4E5tfnkCI5nB5CTO63GWT+4BTGOW7CqF9cFQkvQn4Fne/T17a8MinxL2Y5Pidcp1aekmkzrgjsVvxcuLOYQE2w6kfrlmDIwBGM0tKUzzfTYK2MrGxSQ0Pad7dHcq1q+qHCbuAmqtU+xcCkCMtb97CP7oDy0M/dLqQbLkfpBMgQKz5vLJ9shqYWTfTZqgE33ThhjP8bAefCCZ3xSAJNGLdc/QOL6pNbESpcLc9c2lSq2AgCAJMNkdnVMA7T3ip1A6gmw1O9re11tunAF8S0ebN+Vel7ajZcVGvAv8kA3uKk+xI4Flqi9+Re53+GEeu0a45vxSBPSEFwqxxL2ulOkXLO3m0RCVdRqX6bImyVF3DAIMpBp7Dys55MNDKjeGvVuzs2vmHEkuJonrOvKTiNXjh1cQeRg4QHYbeUoTTdzMYKtIm0UfIu4ifldJBj5n9wYBZyiDgwM7oNgMpsOycpiXJCIFsXQSUpsspSsk2FsWUmD/9jvWOu/GzNr/lx+8gDS0FyQnNcoatuF+TqjzI4277yzR3pBq72ClIxWHkoFJoQUGkXO/vvrjxWAGCIASikIz9fB4JVXBwy35tw0qvUFUK5FOPVail22wgE4INd/f1z1V9D0UroA3gPwrQuyQKqZ/sF//6JjkQuaRBSlJos2VUrWsFvxHiA5tCG6hjs9DEvysEY0UdJIu20kfkI99UKB3FMEDEvBLKUOLhn05agGjBHYHy+vveEIP6NGszmAGZEXEIhNJaqfvMSl8ABnJ770mk4C04fAS8= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB5175.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(956004)(235185007)(5660300002)(66946007)(36756003)(2616005)(16576012)(44832011)(8936002)(316002)(66476007)(33964004)(66556008)(6486002)(186003)(508600001)(26005)(21480400003)(38100700002)(4326008)(6862004)(2906002)(31686004)(31696002)(84970400001)(8676002)(86362001)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4659 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: dcc30b2d-aaeb-4b3e-f2bc-08d9bb280013 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tp1tyIdBYrRJSwAhhiWql1tBI1bANpnq7TyiP6DRVyGW1eSPFQsc1tGOYKYu8e590fMsxu/XZaJYkeZkHUq/UdyCFgNBDKkub7peH1+7OlYbnSQOsQxBNo2akmcFevl9ql4q6NXuOsApuy/Sq+cBbwvNwvSGLZhHX91piftd6Nfg8+6r5vnrX9fgSOelom9eyhUWymC6QR/dyTdmZQMltgsnc9/s0iv92KFQbHXaDSdgXoDDwyue4TG0h8ZxUyRikWQ9CNLkXn1NtByLedzgeUkr364STBsWO4TBhrR6Ojh2zxsRfYNHtF5L/6MDNZ3/KxQ8IKL8H4R2b+Fx7+CwUQV0I7lMc06hbAdWdA7SZ89S7FDHR7sg+aBvVxZjAzecwuCUbchWrV5MiF3PBu1CVH4kSTtZgwo7vKr04+ClhuIitbZ5iqoxa3mB582gVBu0zFbDrbVsyAxvYwQUIL3OUzLAge4TzShQjYQ5gVKBp4AEJv8+NLDV91w7zp+BSK4CAzynu6VKIMpaNT97gOKACbTS0VausBWuN6K5r7/PBtCv67kCxIgF7ov50u7l+MUFpJX4p2r1+Ah7H5+Q/z/cLac0wXV4RPq8mU1y9R4AJylXDVNbfRt+5hnK3gtJrEIEjDc+TyLrYjwdjlab8OZ02L82LzPABtiz6nG5bbYrWZv/StnHNwjiObFyMhI6TqnPxqg048zxHHMfAFaga6IGjgHyMwZOho35dajYatNBCkya0aodC8PD/D5mzIwpPEg7gBC8tVC20diBvvpwiBIIEPl2NkgxIpUnDUcS30oyXnF8KoFLuPJgGpS5AC/TQsfHasJHJEdGZ/AmkY8iyI9hBbDSMaf4pwSo6n7XyFgbZedRS7+pMTqboazcSh9QLWXXK+Vxt0MyK+nmBJPMmxKoOIAC0EOHNPcfk7xVXP82tnI= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(40470700001)(31696002)(356005)(86362001)(40460700001)(6862004)(235185007)(16576012)(33964004)(44832011)(82310400004)(4326008)(81166007)(84970400001)(2616005)(956004)(36860700001)(6486002)(70586007)(336012)(31686004)(5660300002)(21480400003)(316002)(70206006)(2906002)(26005)(8676002)(508600001)(47076005)(8936002)(186003)(36756003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 15:24:56.1986 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0be8350b-d018-47d6-4742-08d9bb280e45 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6851 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_LOTSOFHASH, KAM_SHORT, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Murray Steele via Gcc-patches From: Murray Steele Reply-To: Murray Steele Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Changes from original patch: 1. Make mentioned changes to changelog. 2. Add namespace-end comments. 3. Add #error for when arm-mve-builtins.def is included without defining DEF_MVE_TYPE. 4. Make placement of '#undef DEF_MVE_TYPE' consistent. --- This patch moves the implementation of MVE ACLE types from arm_mve_types.h to inside GCC via a new pragma, which replaces the prior type definitions. This allows for the types to be used internally for intrinsic function definitions. Bootstrapped and regression tested on arm-none-linux-gnuabihf, and regression tested on arm-eabi -- no issues. Thanks, Murray gcc/ChangeLog: * config.gcc: Add arm-mve-builtins.o to extra_objs. * config/arm/arm-c.c (arm_pragma_arm): Handle "#pragma GCC arm". (arm_register_target_pragmas): Register it. * config/arm/arm-protos.h: (arm_mve::arm_handle_mve_types_h): New prototype. * config/arm/arm_mve_types.h: Replace MVE type definitions with new pragma. * config/arm/t-arm: (arm-mve-builtins.o): New target rule. * config/arm/arm-mve-builtins.cc: New file. * config/arm/arm-mve-builtins.def: New file. * config/arm/arm-mve-builtins.h: New file. gcc/testsuite/ChangeLog: * gcc.target/arm/mve/mve.exp: Add new subdirectories. * gcc.target/arm/mve/general-c/type_redef_1.c: New test. * gcc.target/arm/mve/general/double_pragmas_1.c: New test. * gcc.target/arm/mve/general/nomve_1.c: New test. diff --git a/gcc/config.gcc b/gcc/config.gcc index edd12655c4a1e6feb09aabbee77eacd9f66b4171..0aa386403112eff80cb5071fa6ff2fdbe610c9fc 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -352,14 +352,14 @@ arc*-*-*) ;; arm*-*-*) cpu_type=arm - extra_objs="arm-builtins.o aarch-common.o" + extra_objs="arm-builtins.o arm-mve-builtins.o aarch-common.o" extra_headers="mmintrin.h arm_neon.h arm_acle.h arm_fp16.h arm_cmse.h arm_bf16.h arm_mve_types.h arm_mve.h arm_cde.h" target_type_format_char='%' c_target_objs="arm-c.o" cxx_target_objs="arm-c.o" d_target_objs="arm-d.o" extra_options="${extra_options} arm/arm-tables.opt" - target_gtfiles="\$(srcdir)/config/arm/arm-builtins.c" + target_gtfiles="\$(srcdir)/config/arm/arm-builtins.c \$(srcdir)/config/arm/arm-mve-builtins.h \$(srcdir)/config/arm/arm-mve-builtins.cc" ;; avr-*-*) cpu_type=avr diff --git a/gcc/config/arm/arm-c.c b/gcc/config/arm/arm-c.c index cc7901bca8dc9c5c27ed6afc5bc26afd42689e6d..d1414f6e0e1c2bd0a7364b837c16adf493221376 100644 --- a/gcc/config/arm/arm-c.c +++ b/gcc/config/arm/arm-c.c @@ -28,6 +28,7 @@ #include "c-family/c-pragma.h" #include "stringpool.h" #include "arm-builtins.h" +#include "arm-protos.h" tree arm_resolve_cde_builtin (location_t loc, tree fndecl, void *arglist) @@ -129,6 +130,24 @@ arm_resolve_cde_builtin (location_t loc, tree fndecl, void *arglist) return call_expr; } +/* Implement "#pragma GCC arm". */ +static void +arm_pragma_arm (cpp_reader *) +{ + tree x; + if (pragma_lex (&x) != CPP_STRING) + { + error ("%<#pragma GCC arm%> requires a string parameter"); + return; + } + + const char *name = TREE_STRING_POINTER (x); + if (strcmp (name, "arm_mve_types.h") == 0) + arm_mve::handle_arm_mve_types_h (); + else + error ("unknown %<#pragma GCC arm%> option %qs", name); +} + /* Implement TARGET_RESOLVE_OVERLOADED_BUILTIN. This is currently only used for the MVE related builtins for the CDE extension. Here we ensure the type of arguments is such that the size is correct, and @@ -476,6 +495,8 @@ arm_register_target_pragmas (void) targetm.target_option.pragma_parse = arm_pragma_target_parse; targetm.resolve_overloaded_builtin = arm_resolve_overloaded_builtin; + c_register_pragma ("GCC", "arm", arm_pragma_arm); + #ifdef REGISTER_SUBTARGET_PRAGMAS REGISTER_SUBTARGET_PRAGMAS (); #endif diff --git a/gcc/config/arm/arm-mve-builtins.cc b/gcc/config/arm/arm-mve-builtins.cc new file mode 100644 index 0000000000000000000000000000000000000000..71838a83caa417195971114239accc1633c238fb --- /dev/null +++ b/gcc/config/arm/arm-mve-builtins.cc @@ -0,0 +1,196 @@ +/* ACLE support for Arm MVE + Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#define IN_TARGET_CODE 1 + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tree.h" +#include "fold-const.h" +#include "langhooks.h" +#include "stringpool.h" +#include "attribs.h" +#include "diagnostic.h" +#include "arm-protos.h" +#include "arm-builtins.h" +#include "arm-mve-builtins.h" + +namespace arm_mve { + +/* Static information about each single-predicate or single-vector + ACLE type. */ +struct vector_type_info +{ + /* The name of the type as declared by arm_mve.h. */ + const char *acle_name; + + /* Whether the type requires a floating point abi. */ + const bool requires_float; +}; + +/* Flag indicating whether the arm MVE types have been handled. */ +static bool handle_arm_mve_types_p; + +/* Information about each single-predicate or single-vector type. */ +static CONSTEXPR const vector_type_info vector_types[] = { +#define DEF_MVE_TYPE(ACLE_NAME, SCALAR_TYPE) \ + { #ACLE_NAME, REQUIRES_FLOAT }, +#include "arm-mve-builtins.def" +#undef DEF_MVE_TYPE +}; + +/* The scalar type associated with each vector type. */ +GTY(()) tree scalar_types[NUM_VECTOR_TYPES]; + +/* The single-predicate and single-vector types, with their built-in + "__simd128_..._t" name. Allow an index of NUM_VECTOR_TYPES, which always + yields a null tree. */ +static GTY(()) tree abi_vector_types[NUM_VECTOR_TYPES + 1]; + +/* Same, but with the arm_mve.h names. */ +GTY(()) tree acle_vector_types[3][NUM_VECTOR_TYPES + 1]; + +/* Return the MVE abi type with element of type TYPE. */ +static tree +arm_mve_type_for_scalar_type (tree eltype) +{ + for (unsigned int i = 0; i < __TYPE_FINAL; ++i) + if (arm_simd_types[i].eltype == eltype + && GET_MODE_SIZE (arm_simd_types[i].mode) == 16) + return arm_simd_types[i].itype; + + gcc_unreachable (); +} + +/* Register the built-in MVE ABI vector types, such as uint32x4_t. */ +static void +register_builtin_types () +{ +#define DEF_MVE_TYPE(ACLE_NAME, SCALAR_TYPE) \ + scalar_types[VECTOR_TYPE_ ## ACLE_NAME] = SCALAR_TYPE; +#include "arm-mve-builtins.def" +#undef DEF_MVE_TYPE + for (unsigned int i = 0; i < NUM_VECTOR_TYPES; ++i) + { + if (vector_types[i].requires_float && !TARGET_HAVE_MVE_FLOAT) + continue; + tree eltype = scalar_types[i]; + tree vectype; + if (eltype == boolean_type_node) + { + vectype = get_typenode_from_name (UINT16_TYPE); + gcc_assert (GET_MODE_SIZE (TYPE_MODE (vectype)) == 2); + } + else + { + vectype = arm_mve_type_for_scalar_type (eltype); + gcc_assert (VECTOR_MODE_P (TYPE_MODE (vectype)) + && GET_MODE_SIZE (TYPE_MODE (vectype)) == 16); + } + abi_vector_types[i] = vectype; + } +} + +/* Register vector type TYPE under its arm_mve.h name. */ +static void +register_vector_type (vector_type_index type) +{ + if (vector_types[type].requires_float && !TARGET_HAVE_MVE_FLOAT) + return; + tree vectype = abi_vector_types[type]; + tree id = get_identifier (vector_types[type].acle_name); + tree decl = build_decl (input_location, TYPE_DECL, id, vectype); + decl = lang_hooks.decls.pushdecl (decl); + + /* Record the new ACLE type if pushdecl succeeded without error. Use + the ABI type otherwise, so that the type we record at least has the + right form, even if it doesn't have the right name. This should give + better error recovery behavior than installing error_mark_node or + installing an incorrect type. */ + if (decl + && TREE_CODE (decl) == TYPE_DECL + && TREE_TYPE (decl) != error_mark_node + && TYPE_MAIN_VARIANT (TREE_TYPE (decl)) == vectype) + vectype = TREE_TYPE (decl); + acle_vector_types[0][type] = vectype; +} + +/* Register tuple type TYPE with NUM_VECTORS arity under its + arm_mve_types.h name. */ +static void +register_builtin_tuple_types (vector_type_index type) +{ + const vector_type_info* info = &vector_types[type]; + if (scalar_types[type] == boolean_type_node + || (info->requires_float && !TARGET_HAVE_MVE_FLOAT)) + return; + const char *vector_type_name = info->acle_name; + char buffer[sizeof ("float32x4x2_t")]; + for (unsigned int num_vectors = 2; num_vectors <= 4; num_vectors += 2) + { + snprintf (buffer, sizeof (buffer), "%.*sx%d_t", + (int) strlen (vector_type_name) - 2, vector_type_name, + num_vectors); + + tree vectype = acle_vector_types[0][type]; + tree arrtype = build_array_type_nelts (vectype, num_vectors); + gcc_assert (TYPE_MODE_RAW (arrtype) == TYPE_MODE (arrtype)); + tree field = build_decl (input_location, FIELD_DECL, + get_identifier ("val"), arrtype); + + tree t = lang_hooks.types.simulate_record_decl (input_location, buffer, + make_array_slice (&field, + 1)); + gcc_assert (TYPE_MODE_RAW (t) == TYPE_MODE (t)); + acle_vector_types[num_vectors >> 1][type] = TREE_TYPE (t); + } +} + +/* Implement #pragma GCC arm "arm_mve_types.h". */ +void +handle_arm_mve_types_h () +{ + if (handle_arm_mve_types_p) + { + error ("duplicate definition of %qs", "arm_mve_types.h"); + return; + } + handle_arm_mve_types_p = true; + if (!TARGET_HAVE_MVE) + { + error ("this definition requires the MVE ISA extension"); + return; + } + register_builtin_types (); + for (unsigned int type_i = 0; type_i < NUM_VECTOR_TYPES; ++type_i) + { + vector_type_index type = vector_type_index (type_i); + register_vector_type (type); + if (type_i != VECTOR_TYPE_mve_pred16_t) + register_builtin_tuple_types (type); + } +} + +} /* end namespace arm_mve */ + +using namespace arm_mve; + +#include "gt-arm-mve-builtins.h" diff --git a/gcc/config/arm/arm-mve-builtins.def b/gcc/config/arm/arm-mve-builtins.def new file mode 100644 index 0000000000000000000000000000000000000000..31bfa60d678c914a732a23704dfd3728f0873ef8 --- /dev/null +++ b/gcc/config/arm/arm-mve-builtins.def @@ -0,0 +1,39 @@ +/* Builtin lists for Arm MVE + Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#ifndef DEF_MVE_TYPE +#error "arm-mve-builtins.def included without defining DEF_MVE_TYPE" +#endif + +#define REQUIRES_FLOAT false +DEF_MVE_TYPE (mve_pred16_t, boolean_type_node) +DEF_MVE_TYPE (uint8x16_t, unsigned_intQI_type_node) +DEF_MVE_TYPE (uint16x8_t, unsigned_intHI_type_node) +DEF_MVE_TYPE (uint32x4_t, unsigned_intSI_type_node) +DEF_MVE_TYPE (uint64x2_t, unsigned_intDI_type_node) +DEF_MVE_TYPE (int8x16_t, intQI_type_node) +DEF_MVE_TYPE (int16x8_t, intHI_type_node) +DEF_MVE_TYPE (int32x4_t, intSI_type_node) +DEF_MVE_TYPE (int64x2_t, intDI_type_node) +#undef REQUIRES_FLOAT + +#define REQUIRES_FLOAT true +DEF_MVE_TYPE (float16x8_t, arm_fp16_type_node) +DEF_MVE_TYPE (float32x4_t, float_type_node) +#undef REQUIRES_FLOAT diff --git a/gcc/config/arm/arm-mve-builtins.h b/gcc/config/arm/arm-mve-builtins.h new file mode 100644 index 0000000000000000000000000000000000000000..aa5c2cc483552886db63ceafd9b508ad197e6efa --- /dev/null +++ b/gcc/config/arm/arm-mve-builtins.h @@ -0,0 +1,41 @@ +/* ACLE support for Arm MVE + Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#ifndef GCC_ARM_MVE_BUILTINS_H +#define GCC_ARM_MVE_BUILTINS_H + +namespace arm_mve { + +/* Enumerates the MVE predicate and (data) vector types, together called + "vector types" for brevity. */ +enum vector_type_index +{ +#define DEF_MVE_TYPE(ACLE_NAME, SCALAR_TYPE) \ + VECTOR_TYPE_ ## ACLE_NAME, +#include "arm-mve-builtins.def" + NUM_VECTOR_TYPES +#undef DEF_MVE_TYPE +}; + +extern tree scalar_types[NUM_VECTOR_TYPES]; +extern tree acle_vector_types[3][NUM_VECTOR_TYPES + 1]; + +} /* end namespace arm_mve */ + +#endif /* GCC_ARM_MVE_BUILTINS_H */ diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index 9b1f61394ad7d778a6c0b84bc6c805f14709f598..c91cb5ad69b9d911c31e6018a2ca6bf2ac6239d3 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -204,6 +204,11 @@ extern int arm_apply_result_size (void); #endif /* RTX_CODE */ +/* MVE functions. */ +namespace arm_mve { + void handle_arm_mve_types_h (); +} + /* Thumb functions. */ extern void arm_init_expanders (void); extern const char *thumb1_unexpanded_epilogue (void); diff --git a/gcc/config/arm/arm_mve_types.h b/gcc/config/arm/arm_mve_types.h index 8958f4efdb9952602887bfcb186db6e8364d6351..7fbc89b5982ea73de973dfc25774a8f67ca8bf48 100644 --- a/gcc/config/arm/arm_mve_types.h +++ b/gcc/config/arm/arm_mve_types.h @@ -25,37 +25,9 @@ #if (__ARM_FEATURE_MVE & 2) /* MVE Floating point. */ typedef __fp16 float16_t; typedef float float32_t; -typedef __simd128_float16_t float16x8_t; -typedef __simd128_float32_t float32x4_t; - -typedef struct { float16x8_t val[2]; } float16x8x2_t; -typedef struct { float16x8_t val[4]; } float16x8x4_t; -typedef struct { float32x4_t val[2]; } float32x4x2_t; -typedef struct { float32x4_t val[4]; } float32x4x4_t; #endif -typedef uint16_t mve_pred16_t; -typedef __simd128_uint8_t uint8x16_t; -typedef __simd128_uint16_t uint16x8_t; -typedef __simd128_uint32_t uint32x4_t; -typedef __simd128_uint64_t uint64x2_t; -typedef __simd128_int8_t int8x16_t; -typedef __simd128_int16_t int16x8_t; -typedef __simd128_int32_t int32x4_t; -typedef __simd128_int64_t int64x2_t; - -typedef struct { int16x8_t val[2]; } int16x8x2_t; -typedef struct { int16x8_t val[4]; } int16x8x4_t; -typedef struct { int32x4_t val[2]; } int32x4x2_t; -typedef struct { int32x4_t val[4]; } int32x4x4_t; -typedef struct { int8x16_t val[2]; } int8x16x2_t; -typedef struct { int8x16_t val[4]; } int8x16x4_t; -typedef struct { uint16x8_t val[2]; } uint16x8x2_t; -typedef struct { uint16x8_t val[4]; } uint16x8x4_t; -typedef struct { uint32x4_t val[2]; } uint32x4x2_t; -typedef struct { uint32x4_t val[4]; } uint32x4x4_t; -typedef struct { uint8x16_t val[2]; } uint8x16x2_t; -typedef struct { uint8x16_t val[4]; } uint8x16x4_t; +#pragma GCC arm "arm_mve_types.h" __extension__ extern __inline int16x8_t __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) diff --git a/gcc/config/arm/t-arm b/gcc/config/arm/t-arm index 5f69ee6451efb8709fe9b455a45c2e634e009170..f655f369724ca711f0a389abaf0e70adb3ab4b7c 100644 --- a/gcc/config/arm/t-arm +++ b/gcc/config/arm/t-arm @@ -153,6 +153,16 @@ arm-builtins.o: $(srcdir)/config/arm/arm-builtins.c $(CONFIG_H) \ $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ $(srcdir)/config/arm/arm-builtins.c +arm-mve-builtins.o: $(srcdir)/config/arm/arm-mve-builtins.cc $(CONFIG_H) \ + $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ + fold-const.h langhooks.h stringpool.h attribs.h diagnostic.h \ + $(srcdir)/config/arm/arm-protos.h \ + $(srcdir)/config/arm/arm-builtins.h \ + $(srcdir)/config/arm/arm-mve-builtins.h \ + $(srcdir)/config/arm/arm-mve-builtins.def + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(srcdir)/config/arm/arm-mve-builtins.cc + arm-c.o: $(srcdir)/config/arm/arm-c.c $(CONFIG_H) $(SYSTEM_H) \ coretypes.h $(TM_H) $(TREE_H) output.h $(C_COMMON_H) $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ diff --git a/gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_1.c b/gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_1.c new file mode 100644 index 0000000000000000000000000000000000000000..cd230f14b2bb136c4b4ab7b335394bc31eb04f71 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/mve/general-c/type_redef_1.c @@ -0,0 +1,67 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_v8_1m_mve_fp_ok } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ + +int mve_pred16_t; /* { dg-message "note: previous declaration of 'mve_pred16_t'" } */ +int int8x16_t; /* { dg-message "note: previous declaration of 'int8x16_t'" } */ +int int16x8_t; /* { dg-message "note: previous declaration of 'int16x8_t'" } */ +int int32x4_t; /* { dg-message "note: previous declaration of 'int32x4_t'" } */ +int int64x2_t; /* { dg-message "note: previous declaration of 'int64x2_t'" } */ +int uint8x16_t; /* { dg-message "note: previous declaration of 'uint8x16_t'" } */ +int uint16x8_t; /* { dg-message "note: previous declaration of 'uint16x8_t'" } */ +int uint32x4_t; /* { dg-message "note: previous declaration of 'uint32x4_t'" } */ +int uint64x2_t; /* { dg-message "note: previous declaration of 'uint64x2_t'" } */ +int float16x8_t; /* { dg-message "note: previous declaration of 'float16x8_t'" } */ +int float32x4_t; /* { dg-message "note: previous declaration of 'float32x4_t'" } */ +int int8x16x2_t; /* { dg-message "note: previous declaration of 'int8x16x2_t'" } */ +int int8x16x4_t; /* { dg-message "note: previous declaration of 'int8x16x4_t'" } */ +int int16x8x2_t; /* { dg-message "note: previous declaration of 'int16x8x2_t'" } */ +int int16x8x4_t; /* { dg-message "note: previous declaration of 'int16x8x4_t'" } */ +int int32x4x2_t; /* { dg-message "note: previous declaration of 'int32x4x2_t'" } */ +int int32x4x4_t; /* { dg-message "note: previous declaration of 'int32x4x4_t'" } */ +int int64x2x2_t; /* { dg-message "note: previous declaration of 'int64x2x2_t'" } */ +int int64x2x4_t; /* { dg-message "note: previous declaration of 'int64x2x4_t'" } */ +int uint8x16x2_t; /* { dg-message "note: previous declaration of 'uint8x16x2_t'" } */ +int uint8x16x4_t; /* { dg-message "note: previous declaration of 'uint8x16x4_t'" } */ +int uint16x8x2_t; /* { dg-message "note: previous declaration of 'uint16x8x2_t'" } */ +int uint16x8x4_t; /* { dg-message "note: previous declaration of 'uint16x8x4_t'" } */ +int uint32x4x2_t; /* { dg-message "note: previous declaration of 'uint32x4x2_t'" } */ +int uint32x4x4_t; /* { dg-message "note: previous declaration of 'uint32x4x4_t'" } */ +int uint64x2x2_t; /* { dg-message "note: previous declaration of 'uint64x2x2_t'" } */ +int uint64x2x4_t; /* { dg-message "note: previous declaration of 'uint64x2x4_t'" } */ +int float16x8x2_t; /* { dg-message "note: previous declaration of 'float16x8x2_t'" } */ +int float16x8x4_t; /* { dg-message "note: previous declaration of 'float16x8x4_t'" } */ +int float32x4x2_t; /* { dg-message "note: previous declaration of 'float32x4x2_t'" } */ +int float32x4x4_t; /* { dg-message "note: previous declaration of 'float32x4x4_t'" } */ + +#pragma GCC arm "arm_mve_types.h" /* { dg-error {'mve_pred16_t' redeclared} } */ + /* { dg-error {'int8x16_t' redeclared} "" {target *-*-*} .-1 } */ + /* { dg-error {'int16x8_t' redeclared} "" {target *-*-*} .-2 } */ + /* { dg-error {'int32x4_t' redeclared} "" {target *-*-*} .-3 } */ + /* { dg-error {'int64x2_t' redeclared} "" {target *-*-*} .-4 } */ + /* { dg-error {'uint8x16_t' redeclared} "" {target *-*-*} .-5 } */ + /* { dg-error {'uint16x8_t' redeclared} "" {target *-*-*} .-6 } */ + /* { dg-error {'uint32x4_t' redeclared} "" {target *-*-*} .-7 } */ + /* { dg-error {'uint64x2_t' redeclared} "" {target *-*-*} .-8 } */ + /* { dg-error {'float16x8_t' redeclared} "" {target *-*-*} .-9 } */ + /* { dg-error {'float32x4_t' redeclared} "" {target *-*-*} .-10 } */ + /* { dg-error {'int8x16x2_t' redeclared} "" {target *-*-*} .-11 } */ + /* { dg-error {'int8x16x4_t' redeclared} "" {target *-*-*} .-12 } */ + /* { dg-error {'int16x8x2_t' redeclared} "" {target *-*-*} .-13 } */ + /* { dg-error {'int16x8x4_t' redeclared} "" {target *-*-*} .-14 } */ + /* { dg-error {'int32x4x2_t' redeclared} "" {target *-*-*} .-15 } */ + /* { dg-error {'int32x4x4_t' redeclared} "" {target *-*-*} .-16 } */ + /* { dg-error {'int64x2x2_t' redeclared} "" {target *-*-*} .-17 } */ + /* { dg-error {'int64x2x4_t' redeclared} "" {target *-*-*} .-18 } */ + /* { dg-error {'uint8x16x2_t' redeclared} "" {target *-*-*} .-19 } */ + /* { dg-error {'uint8x16x4_t' redeclared} "" {target *-*-*} .-20 } */ + /* { dg-error {'uint16x8x2_t' redeclared} "" {target *-*-*} .-21 } */ + /* { dg-error {'uint16x8x4_t' redeclared} "" {target *-*-*} .-22 } */ + /* { dg-error {'uint32x4x2_t' redeclared} "" {target *-*-*} .-23 } */ + /* { dg-error {'uint32x4x4_t' redeclared} "" {target *-*-*} .-24 } */ + /* { dg-error {'uint64x2x2_t' redeclared} "" {target *-*-*} .-25 } */ + /* { dg-error {'uint64x2x4_t' redeclared} "" {target *-*-*} .-26 } */ + /* { dg-error {'float16x8x2_t' redeclared} "" {target *-*-*} .-27 } */ + /* { dg-error {'float16x8x4_t' redeclared} "" {target *-*-*} .-28 } */ + /* { dg-error {'float32x4x2_t' redeclared} "" {target *-*-*} .-29 } */ + /* { dg-error {'float32x4x4_t' redeclared} "" {target *-*-*} .-30 } */ diff --git a/gcc/testsuite/gcc.target/arm/mve/general/double_pragmas_1.c b/gcc/testsuite/gcc.target/arm/mve/general/double_pragmas_1.c new file mode 100644 index 0000000000000000000000000000000000000000..58466db6940d3f272ca6f90ea697a4b35440bbe6 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/mve/general/double_pragmas_1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_v8_1m_mve_ok } */ +/* { dg-add-options arm_v8_1m_mve } */ + +/* It doesn't really matter if this produces errors about redefinitions, + but it mustn't trigger an ICE. */ +#pragma GCC arm "arm_mve_types.h" +#pragma GCC arm "arm_mve_types.h" /* { dg-error "duplicate definition of 'arm_mve_types.h'" } */ diff --git a/gcc/testsuite/gcc.target/arm/mve/general/nomve_1.c b/gcc/testsuite/gcc.target/arm/mve/general/nomve_1.c new file mode 100644 index 0000000000000000000000000000000000000000..cdfb974b7a23c70b2beb9138a75ea88cc39eca5d --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/mve/general/nomve_1.c @@ -0,0 +1,3 @@ +/* { dg-options "-mfloat-abi=soft" } */ + +#pragma GCC arm "arm_mve_types.h" /* { dg-error {this definition requires the MVE ISA extension} } */ diff --git a/gcc/testsuite/gcc.target/arm/mve/mve.exp b/gcc/testsuite/gcc.target/arm/mve/mve.exp index a858e52d9208b6e2bbd3c2175ed45724871598e2..7cea03d6befc9a7080acb58b0245af576a19e61c 100644 --- a/gcc/testsuite/gcc.target/arm/mve/mve.exp +++ b/gcc/testsuite/gcc.target/arm/mve/mve.exp @@ -44,6 +44,12 @@ dg-init dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/intrinsics/*.\[cCS\]]] \ "" $DEFAULT_CFLAGS +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/general/*.\[cCS\]]] \ + "" $DEFAULT_CFLAGS + +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/general-c/*.\[cCS\]]] \ + "" $DEFAULT_CFLAGS + dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \ "" $DEFAULT_CFLAGS