From patchwork Tue Jul 26 01:31:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 176 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp1981047pxt; Mon, 25 Jul 2022 18:31:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s5nFHOTrJtsPPqARdfiOaycx3ynfulQLh2yRy7Yl06dVueRPn7d0LfjDQ2aLpnv7yIvB8B X-Received: by 2002:a17:906:58d6:b0:72f:25c0:af2b with SMTP id e22-20020a17090658d600b0072f25c0af2bmr12056920ejs.326.1658799118116; Mon, 25 Jul 2022 18:31:58 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hp8-20020a1709073e0800b0072edc70deb2si17301803ejc.624.2022.07.25.18.31.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 18:31:58 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=TgXv1hjI; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CE9D538560B3 for ; Tue, 26 Jul 2022 01:31:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE9D538560B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658799116; bh=RMLBWZhxo1m/EOy56jluVdPEsUurdOy8F6iuNhRGVcA=; h=To:Subject:Date:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=TgXv1hjIsoLF6YR3sDXJBB9Orn8xy/nm2oH4Fi6ZkYqx1D2RL/ZPcJH/tJIPJ2BxI 6Ad0/Gn+648/pndsN9Yu6GsDGTafdA6xvgtj5VriavIOurNC2keqM6cCqQ4meXzYxt EzBFnbGx3itP3wRbtr9pRlXSCOUHRDMzL4BUFbWQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by sourceware.org (Postfix) with ESMTPS id 6A1A53858CDA for ; Tue, 26 Jul 2022 01:31:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A1A53858CDA X-IronPort-AV: E=McAfee;i="6400,9594,10419"; a="285380879" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="285380879" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 18:31:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="845697035" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga006.fm.intel.com with ESMTP; 25 Jul 2022 18:31:07 -0700 Received: from fmsmsx604.amr.corp.intel.com (10.18.126.84) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 25 Jul 2022 18:31:06 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Mon, 25 Jul 2022 18:31:06 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.28; Mon, 25 Jul 2022 18:31:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DRJJpzkKwU9Xl3iMiZHpQtYjJcWOsNPcP1QkcUeOA70wk7YuSnnNk3qekysbPjetRTLu924fGXnvcPWkCfDxyNgSFDZL8o9+HE9l/rbuuqq0PLRZ1+ayK2qu0Rv9FCSSH+3DqwMRIbaQD06EJtZ9qDS4BZIojPaH497w+MYEDwFnXFRwZqrlQ8mRpVMgieE2p3L0b0ra4HArJhsMWDIgNwYx708HPenPsWfRvEUebKI+iFPQjXm5Sm+BXnNIAFvIXa63Hmj0J1kXv/Yc2ogdYF0s2CX2XiWmciWmIHQRxbja46++Em2KPxON2xCNet7aJN+Du+KbGTTRApe8oTo8AQ== 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=RMLBWZhxo1m/EOy56jluVdPEsUurdOy8F6iuNhRGVcA=; b=hmhuQaNSSG0Q8d9NhbNpErTq4JU43dICJgNOc+AIty7P2QFxkDmNpd1JdtG0HGP/GONs16kRflopesXtVYCCxx3uwjT9Uf7yJKCwDkCFORoVzZFd3Q/l1IPiCYV8aA/WFeN7OFzadkqS1OydPwwO1Kr/UPopF+LB6MsKqZHwj3rGoWaMK4J9TJgwPB2lBKjnapF7eT7PN8W1muZsueaZDS/K+p6KLh56JnHb3GikG0+c4eQXeZGiiENOGLFc+RnSOo21Opaah0MS31ncdlr6vrurktLYnz/FIPEEF/7cGxsFqK5/1UwNJi0TO7VZzVBBBOfCrLLoK1KmQBQ6QYe1hQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM4PR11MB5487.namprd11.prod.outlook.com (2603:10b6:5:39f::22) by PH0PR11MB5612.namprd11.prod.outlook.com (2603:10b6:510:e7::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.18; Tue, 26 Jul 2022 01:31:03 +0000 Received: from DM4PR11MB5487.namprd11.prod.outlook.com ([fe80::d0fb:381e:3499:e048]) by DM4PR11MB5487.namprd11.prod.outlook.com ([fe80::d0fb:381e:3499:e048%9]) with mapi id 15.20.5458.025; Tue, 26 Jul 2022 01:31:03 +0000 To: "Liu, Hongtao" , "gcc-patches@gcc.gnu.org" Subject: [PATCH] x86: Enable __bf16 type for TARGET_SSE2 and above Thread-Topic: [PATCH] x86: Enable __bf16 type for TARGET_SSE2 and above Thread-Index: AQHYoI0DcrOQRHlIPkegbMwKUvZ/vK2P2RDg Date: Tue, 26 Jul 2022 01:31:03 +0000 Message-ID: References: <20220726011357.12001-1-lingling.kong@intel.com> In-Reply-To: <20220726011357.12001-1-lingling.kong@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.500.17 dlp-reaction: no-action x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8d853c27-bf7e-4d52-fdc4-08da6ea680fd x-ms-traffictypediagnostic: PH0PR11MB5612:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 27QqRX9mj6Kll1qEtu0vOAa4PFceWLcED6BKrubHaDHNQiQ1L6A/UmoUn5PbEYBT9OjPKlWKO+HjwaGJ5DrDLc6r86heXVALOIi4bhi82u/HsWlFD728PYRIWUjTlUehkrgifXAdFQuc3PksbfcxM9RQEJwoOn20P/LjSgKvKf9bjTWt9yD5FI7a7FqhBpIpSKZuKNMDT12+cM9Qq2B++PbnLkJEZwWhX7Y6iO33ngj0uHt/OXHBZsBHXvquJAmR3g7cwA2Fqw80GpragjkPBc4Kp/GW6oK6f7rsp0XUpvHWI6ZQEbix9xbQvnvUoPJHvBTMzc4msB1tSRFBqtLShbQbkrUGlOgKaXhkomkrr33MKRt5ApubIFB0K9DdCRqQ8i/Vam7aNHxrxtdZVYscK4VrT2GIHIeeUhXvCvrJw3IhLRN0clZiOnbxk3g2Uf5tKGu5xxcQ1AZe/PeGqMnARsSYnytxthOLhZJYLxElqXasnFEFnqjbu6eytYXffcz6zubceDh/MmhSoMudpd6zdsbPiPodwI4H3OiKVdfsgA3Lki1lPGUw8wk5KdPZVBCmUnSYrfztxqocdfWOulUnN+T3ArKejazkt5A9ZKue7xJ5p1GTysyjEmSYb8XPyVKMZaBWkOR0Pc6ar3svWb7iBAYmK6M04yoWxds4xtnGI7qfiR/uWNJ8Da/S3ztegwPUoBWk5kiNAg3T9hgxzmEQSOsAoZrpMnoPzYbxa9viG6RR0zrFTVBmy3+gK8pPF2FsSFfXGQsjiF7MxBc5n03n9h0KmXSPay4aBYO0QC8wl+Fbf0ESx8SQ8AwISmCb72sp5ywNTZBg1r3DRbN4zlsWqA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5487.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(39860400002)(366004)(346002)(376002)(396003)(136003)(66556008)(82960400001)(71200400001)(66446008)(66476007)(66946007)(76116006)(84970400001)(186003)(41300700001)(64756008)(4326008)(8676002)(2906002)(30864003)(5660300002)(38070700005)(83380400001)(966005)(52536014)(55016003)(8936002)(478600001)(33656002)(122000001)(107886003)(86362001)(316002)(110136005)(38100700002)(9686003)(6506007)(26005)(7696005)(579004)(559001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: rueik2RIVOmp7oamlPAT/2oUrCktxyNbv0pKcBbjykl7bncjeh9fo5jbQJ9BmYPmBlGvl7dDRUmQLzvlE8gpzZIkZ9El6vTbyDkfM4xBj8i2Gy5FkpwrnXazSxF3lJOii6m2KQ5KpZHIivV08AX3W0piBwc3OYGAsjSRzDS7zNk2HIIIeIhR+m73Au61w4W1amQIKnGSNj+7Uz10IUi6ThmcToBMgQZKp1Y4nVS7GpjCBxiBDBGm5vBr7zqPCCA5O3KCa2qjPZERD0DtHQbDyz+zVR9WHRGv+juVQykPs3ZjCwHJYTs6tgxpYDpsJnCBe6YctvSIKstFbsWb5O/gjNbcEkA8aP3JRtxYgJ5siCdRSgRPKWLf5flNgHOljgbQg79Ck2+5IKnjlB9BBlYiIRiuxwW/ulhjkIIdACmD58zx0K/17v3S3/QixQaamBtra7eVbWhurF+qbzPFdFktojpZoZcVrIgx1FIN9P9DxYtD8/l6hC9etksF3CauLapQ5+bkBjVGXt/fyoGBRlmmwFfnF44WCgIFIGAusOOYtP/XEInoFVC34ZOgzemyTATF1s3TcEYFlcrjTE6AsijUjtawPUyuvz35U6cGNdxfpFv4oHZMkVBW6+ylXUTxpSLoFkAlKljKfkInElt7McvCNqbcJFmmk3BOPpCSgmMHm0MK+W1XF6ZESDGjBjFLMWoz4gr5dNkH0IOqATAUhIcUfmWlZt6SUK2ATRbf2adubMT6t0oM8gelPQZVtqfBzwXCEsdxg6HqIcxUjo0CvAU4wYFdF8mcuk0xNTSnOkuho8LBTXaVS2N/sqcgQ9V1No29KWIGlBHx4IrdzuxjAav+JAmhpk33BxP6PQfi5hpBa16wZX2rpXILRGTWS2UnfnOmubIhHLsakhaLofYkT9bGuh5sGQhVT7TUO04313H/jnsUSdnU02eYrWzbLe8+BMuhGhk+KLzulxp1Gm0y3Xy6KfedsExVTp3KU03UpnBmfSf1TyENmKG0WQEQhK65A35s6mvvxzPdR13KYQfm4SYKkXQyjRZTGxfYLVfrlca69UE8xFUd9XGPreg6QcDpXP0mboRHAS+lTvJRIBd6dfDK0/3xIG+SGxaccwZYeOCqZvZbMn5z2SZ0EFDC6+rQ9jcjzTD4LJiqJKqeOUJWnJVRKjLhZQQ94rds0o607pDV1KXqMsS+Yw1A0E9T2RSKMXQxfFWpqJOlH8koPFsO5A7sUQvbFxgZUuHk/TGym2PJ51D/VjRx1xLvcoFQ9rMnZrsuM7Gk+Ocvsv95tiPXfSoV8g3DEu4KAyeE08Op9oJ55KHDNCTpPIxr0wvFy88wkEg2tPDIvieSgtKrEvalRnxGbowPceTzCRFitCS23+ZbSlpp5/N8VjrY7ba6DklcYYLWazrs2uXKO3ld3XTvMMy1YqmsVs5crCIobXOukHtNuw8gfrL7aKyCpFwDLFsplNx2a7uLOjE7g0IijxS9+MPsa3AQR0pfrUk5qvU/KrqenFx9UcVg/uIXG6KUKp9J9LEw0dctAfJeEJKSB52itbACiBOLVaIEB0C/Yp7oHRbZCxcjmyjme8euVQIq6nG6KBM2 MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5487.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d853c27-bf7e-4d52-fdc4-08da6ea680fd X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jul 2022 01:31:03.3789 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: VoJPeeVJuVncPrwi7+GnYrSbtP+isHWmMx4R1IGgN0WL5Byh9p9GQnOi1SQE8YxpTIIK4khg7VlibUH91hZm6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5612 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Kong, Lingling via Gcc-patches" From: "Li, Pan2 via Gcc-patches" Reply-To: "Kong, Lingling" Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1739376943883159232?= X-GMAIL-MSGID: =?utf-8?q?1739376943883159232?= Hi, The patch is enable __bf16 scalar type for target sse2 and above according to psABI(https://gitlab.com/x86-psABIs/x86-64-ABI/-/merge_requests/35/diffs). The __bf16 type is a storage type like arm. OK for master? gcc/ChangeLog: * config/i386/i386-builtin-types.def (BFLOAT16): New primitive type. * config/i386/i386-builtins.cc : Support __bf16 type for i386 backend. (ix86_register_bf16_builtin_type): New function. (ix86_bf16_type_node): New. (ix86_bf16_ptr_type_node): Ditto. (ix86_init_builtin_types): Add ix86_register_bf16_builtin_type function call. * config/i386/i386-modes.def (FLOAT_MODE): Add BFmode. (ADJUST_FLOAT_FORMAT): Ditto. * config/i386/i386.cc (merge_classes): Handle BFmode. (classify_argument): Ditto. (examine_argument): Ditto. (construct_container): Ditto. (function_value_32): Return __bf16 by %xmm0. (function_value_64): Return __bf16 by SSE register. (ix86_print_operand): Handle CONST_DOUBLE BFmode. (ix86_secondary_reload): Require gpr as intermediate register to store __bf16 from sse register when sse4 is not available. (ix86_scalar_mode_supported_p): Enable __bf16 under sse2. (ix86_mangle_type): Add manlging for __bf16 type. (ix86_invalid_conversion): New function for target hook. (ix86_invalid_unary_op): Ditto. (ix86_invalid_binary_op): Ditto. (TARGET_INVALID_CONVERSION): New define for target hook. (TARGET_INVALID_UNARY_OP): Ditto. (TARGET_INVALID_BINARY_OP): Ditto. * config/i386/i386.h (host_detect_local_cpu): Add BFmode. * config/i386/i386.md (*pushhf_rex64): Change for BFmode. (*push_rex64): Ditto. (*pushhf): Ditto. (*push): Ditto. (*movhf_internal): Ditto. (*mov_internal): Ditto. gcc/testsuite/ChangeLog: * g++.target/i386/bfloat_cpp_typecheck.C: New test. * gcc.target/i386/bfloat16-1.c: Ditto. * gcc.target/i386/sse2-bfloat16-1.c: Ditto. * gcc.target/i386/sse2-bfloat16-2.c: Ditto. * gcc.target/i386/sse2-bfloat16-scalar-typecheck.c: Ditto. --- gcc/config/i386/i386-builtin-types.def | 1 + gcc/config/i386/i386-builtins.cc | 21 ++ gcc/config/i386/i386-modes.def | 2 + gcc/config/i386/i386.cc | 75 +++++- gcc/config/i386/i386.h | 4 +- gcc/config/i386/i386.md | 32 +-- .../g++.target/i386/bfloat_cpp_typecheck.C | 10 + gcc/testsuite/gcc.target/i386/bfloat16-1.c | 12 + .../gcc.target/i386/sse2-bfloat16-1.c | 8 + .../gcc.target/i386/sse2-bfloat16-2.c | 17 ++ .../i386/sse2-bfloat16-scalar-typecheck.c | 215 ++++++++++++++++++ 11 files changed, 375 insertions(+), 22 deletions(-) create mode 100644 gcc/testsuite/g++.target/i386/bfloat_cpp_typecheck.C create mode 100644 gcc/testsuite/gcc.target/i386/bfloat16-1.c create mode 100644 gcc/testsuite/gcc.target/i386/sse2-bfloat16-1.c create mode 100644 gcc/testsuite/gcc.target/i386/sse2-bfloat16-2.c create mode 100644 gcc/testsuite/gcc.target/i386/sse2-bfloat16-scalar-typecheck.c + bfloat_ptr != &scalar0; + bfloat_ptr < &scalar0; + bfloat_ptr <= &scalar0; + bfloat_ptr > &scalar0; + bfloat_ptr >= &scalar0; + bfloat_ptr == bfloat_ptr2; + bfloat_ptr != bfloat_ptr2; + bfloat_ptr < bfloat_ptr2; + bfloat_ptr <= bfloat_ptr2; + bfloat_ptr > bfloat_ptr2; + bfloat_ptr >= bfloat_ptr2; + + /* Conditional expressions. */ + + 0 ? scalar0 : scalar0; + 0 ? scalar0 : is_a_float; /* { dg-error {invalid conversion from type + '__bf16'} } */ + 0 ? is_a_float : scalar0; /* { dg-error {invalid conversion from type + '__bf16'} } */ + 0 ? scalar0 : 0; /* { dg-error {invalid conversion to type '__bf16'} + } */ + 0 ? 0 : scalar0; /* { dg-error {invalid conversion to type '__bf16'} + } */ + 0 ? 0.1 : scalar0; /* { dg-error {invalid conversion from type + '__bf16'} } */ + 0 ? scalar0 : 0.1; /* { dg-error {invalid conversion from type + '__bf16'} } */ + 0 ? bfloat_ptr : bfloat_ptr2; + 0 ? bfloat_ptr : float_ptr; /* { dg-warning {pointer type mismatch in + conditional expression} } */ + 0 ? float_ptr : bfloat_ptr; /* { dg-warning {pointer type mismatch in + conditional expression} } */ + + scalar0 ? scalar0 : scalar0; /* { dg-error {operation not permitted + on type '__bf16'} } */ + scalar0 ? is_a_float : scalar0; /* { dg-error {operation not + permitted on type '__bf16'} } */ + scalar0 ? scalar0 : is_a_float; /* { dg-error {operation not + permitted on type '__bf16'} } */ + scalar0 ? is_a_float : is_a_float; /* { dg-error {operation not + permitted on type '__bf16'} } */ + + /* Unary operators. */ + + +scalar0; /* { dg-error {operation not permitted on type '__bf16'} } + */ -scalar0; /* { dg-error {operation not permitted on type '__bf16'} + } */ ~scalar0; /* { dg-error {operation not permitted on type + '__bf16'} } */ !scalar0; /* { dg-error {operation not permitted on + type '__bf16'} } */ *scalar0; /* { dg-error {invalid type argument of + unary '\*'} } */ __real scalar0; /* { dg-error {operation not + permitted on type '__bf16'} } */ __imag scalar0; /* { dg-error + {operation not permitted on type '__bf16'} } */ ++scalar0; /* { + dg-error {operation not permitted on type '__bf16'} } */ --scalar0; + /* { dg-error {operation not permitted on type '__bf16'} } */ + scalar0++; /* { dg-error {operation not permitted on type '__bf16'} } + */ scalar0--; /* { dg-error {operation not permitted on type + '__bf16'} } */ + + /* Binary arithmetic operations. */ + + scalar0 = glob_bfloat + *bfloat_ptr; /* { dg-error {operation not + permitted on type '__bf16'} } */ + scalar0 = glob_bfloat + 0.1; /* { dg-error {operation not permitted + on type '__bf16'} } */ + scalar0 = glob_bfloat + 0; /* { dg-error {operation not permitted on + type '__bf16'} } */ + scalar0 = glob_bfloat + is_a_float; /* { dg-error {operation not + permitted on type '__bf16'} } */ + + return scalar0; +} + -- 2.18.2 diff --git a/gcc/config/i386/i386-builtin-types.def b/gcc/config/i386/i386-builtin-types.def index 7a2da1db0b0..63a360b0f8b 100644 --- a/gcc/config/i386/i386-builtin-types.def +++ b/gcc/config/i386/i386-builtin-types.def @@ -69,6 +69,7 @@ DEF_PRIMITIVE_TYPE (UINT16, short_unsigned_type_node) DEF_PRIMITIVE_TYPE (INT64, long_long_integer_type_node) DEF_PRIMITIVE_TYPE (UINT64, long_long_unsigned_type_node) DEF_PRIMITIVE_TYPE (FLOAT16, ix86_float16_type_node) +DEF_PRIMITIVE_TYPE (BFLOAT16, ix86_bf16_type_node) DEF_PRIMITIVE_TYPE (FLOAT, float_type_node) DEF_PRIMITIVE_TYPE (DOUBLE, double_type_node) DEF_PRIMITIVE_TYPE (FLOAT80, float80_type_node) diff --git a/gcc/config/i386/i386-builtins.cc b/gcc/config/i386/i386-builtins.cc index fe7243c3837..6a04fb57e65 100644 --- a/gcc/config/i386/i386-builtins.cc +++ b/gcc/config/i386/i386-builtins.cc @@ -126,6 +126,9 @@ BDESC_VERIFYS (IX86_BUILTIN_MAX, static GTY(()) tree ix86_builtin_type_tab[(int) IX86_BT_LAST_CPTR + 1]; tree ix86_float16_type_node = NULL_TREE; +tree ix86_bf16_type_node = NULL_TREE; +tree ix86_bf16_ptr_type_node = NULL_TREE; + /* Retrieve an element from the above table, building some of the types lazily. */ @@ -1366,6 +1369,22 @@ ix86_register_float16_builtin_type (void) "_Float16"); } +static void +ix86_register_bf16_builtin_type (void) +{ + ix86_bf16_type_node = make_node (REAL_TYPE); + TYPE_PRECISION (ix86_bf16_type_node) = 16; + SET_TYPE_MODE (ix86_bf16_type_node, BFmode); + layout_type (ix86_bf16_type_node); + + if (!maybe_get_identifier ("__bf16") && TARGET_SSE2) + { + lang_hooks.types.register_builtin_type (ix86_bf16_type_node, + "__bf16"); + ix86_bf16_ptr_type_node = build_pointer_type (ix86_bf16_type_node); + } +} + static void ix86_init_builtin_types (void) { @@ -1396,6 +1415,8 @@ ix86_init_builtin_types (void) ix86_register_float16_builtin_type (); + ix86_register_bf16_builtin_type (); + const_string_type_node = build_pointer_type (build_qualified_type (char_type_node, TYPE_QUAL_CONST)); diff --git a/gcc/config/i386/i386-modes.def b/gcc/config/i386/i386-modes.def index e2e1e18d24d..b49daaef253 100644 --- a/gcc/config/i386/i386-modes.def +++ b/gcc/config/i386/i386-modes.def @@ -24,6 +24,8 @@ along with GCC; see the file COPYING3. If not see FRACTIONAL_FLOAT_MODE (XF, 80, 12, ieee_extended_intel_96_format); FLOAT_MODE (TF, 16, ieee_quad_format); FLOAT_MODE (HF, 2, ieee_half_format); +FLOAT_MODE (BF, 2, 0); +ADJUST_FLOAT_FORMAT (BF, &arm_bfloat_half_format); /* In ILP32 mode, XFmode has size 12 and alignment 4. In LP64 mode, XFmode has size and alignment 16. */ diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index e03f86d4a23..5d589f6a05c 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -2399,6 +2399,7 @@ classify_argument (machine_mode mode, const_tree type, case E_CTImode: return 0; case E_HFmode: + case E_BFmode: if (!(bit_offset % 64)) classes[0] = X86_64_SSEHF_CLASS; else @@ -2792,9 +2793,10 @@ construct_container (machine_mode mode, machine_mode orig_mode, intreg++; break; case X86_64_SSEHF_CLASS: + tmpmode = (mode == BFmode ? BFmode : HFmode); exp [nexps++] = gen_rtx_EXPR_LIST (VOIDmode, - gen_rtx_REG (HFmode, + gen_rtx_REG (tmpmode, GET_SSE_REGNO (sse_regno)), GEN_INT (i*8)); sse_regno++; @@ -4001,8 +4003,8 @@ function_value_32 (machine_mode orig_mode, machine_mode mode, /* Most things go in %eax. */ regno = AX_REG; - /* Return _Float16/_Complex _Foat16 by sse register. */ - if (mode == HFmode) + /* Return __bf16/ _Float16/_Complex _Foat16 by sse register. */ if + (mode == HFmode || mode == BFmode) regno = FIRST_SSE_REG; if (mode == HCmode) { @@ -4050,6 +4052,7 @@ function_value_64 (machine_mode orig_mode, machine_mode mode, switch (mode) { + case E_BFmode: case E_HFmode: case E_HCmode: case E_SFmode: @@ -5631,6 +5634,7 @@ ix86_output_ssemov (rtx_insn *insn, rtx *operands) return "%vmovss\t{%1, %0|%0, %1}"; case MODE_HF: + case MODE_BF: if (REG_P (operands[0]) && REG_P (operands[1])) return "vmovsh\t{%d1, %0|%0, %d1}"; else @@ -19402,7 +19406,8 @@ ix86_secondary_reload (bool in_p, rtx x, reg_class_t rclass, } /* Require movement to gpr, and then store to memory. */ - if ((mode == HFmode || mode == HImode || mode == V2QImode) + if ((mode == HFmode || mode == HImode || mode == V2QImode + || mode == BFmode) && !TARGET_SSE4_1 && SSE_CLASS_P (rclass) && !in_p && MEM_P (x)) @@ -22331,7 +22336,7 @@ ix86_scalar_mode_supported_p (scalar_mode mode) return default_decimal_float_supported_p (); else if (mode == TFmode) return true; - else if (mode == HFmode && TARGET_SSE2) + else if ((mode == HFmode || mode == BFmode) && TARGET_SSE2) return true; else return default_scalar_mode_supported_p (mode); @@ -22646,6 +22651,8 @@ ix86_mangle_type (const_tree type) switch (TYPE_MODE (type)) { + case E_BFmode: + return "u6__bf16"; case E_HFmode: /* _Float16 is "DF16_". Align with clang's decision in https://reviews.llvm.org/D33719. */ @@ -22661,6 +22668,55 @@ ix86_mangle_type (const_tree type) } } +/* Return the diagnostic message string if conversion from FROMTYPE to + TOTYPE is not allowed, NULL otherwise. */ + +static const char * +ix86_invalid_conversion (const_tree fromtype, const_tree totype) { + if (element_mode (fromtype) != element_mode (totype)) + { + /* Do no allow conversions to/from BFmode scalar types. */ + if (TYPE_MODE (fromtype) == BFmode) + return N_("invalid conversion from type %<__bf16%>"); + if (TYPE_MODE (totype) == BFmode) + return N_("invalid conversion to type %<__bf16%>"); + } + + /* Conversion allowed. */ + return NULL; +} + +/* Return the diagnostic message string if the unary operation OP is + not permitted on TYPE, NULL otherwise. */ + +static const char * +ix86_invalid_unary_op (int op, const_tree type) { + /* Reject all single-operand operations on BFmode except for &. */ + if (element_mode (type) == BFmode && op != ADDR_EXPR) + return N_("operation not permitted on type %<__bf16%>"); + + /* Operation allowed. */ + return NULL; +} + +/* Return the diagnostic message string if the binary operation OP is + not permitted on TYPE1 and TYPE2, NULL otherwise. */ + +static const char * +ix86_invalid_binary_op (int op ATTRIBUTE_UNUSED, const_tree type1, + const_tree type2) +{ + /* Reject all 2-operand operations on BFmode. */ + if (element_mode (type1) == BFmode + || element_mode (type2) == BFmode) + return N_("operation not permitted on type %<__bf16%>"); + + /* Operation allowed. */ + return NULL; +} + static GTY(()) tree ix86_tls_stack_chk_guard_decl; static tree @@ -24718,6 +24774,15 @@ ix86_libgcc_floating_mode_supported_p #undef TARGET_MANGLE_TYPE #define TARGET_MANGLE_TYPE ix86_mangle_type +#undef TARGET_INVALID_CONVERSION +#define TARGET_INVALID_CONVERSION ix86_invalid_conversion + +#undef TARGET_INVALID_UNARY_OP +#define TARGET_INVALID_UNARY_OP ix86_invalid_unary_op + +#undef TARGET_INVALID_BINARY_OP +#define TARGET_INVALID_BINARY_OP ix86_invalid_binary_op + #undef TARGET_STACK_PROTECT_GUARD #define TARGET_STACK_PROTECT_GUARD ix86_stack_protect_guard diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index f16df633e84..0da3dce1d31 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -1046,7 +1046,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); || (MODE) == V8HFmode || (MODE) == V4HFmode || (MODE) == V2HFmode \ || (MODE) == V4QImode || (MODE) == V2HImode || (MODE) == V1SImode \ || (MODE) == V2DImode || (MODE) == V2QImode || (MODE) == DFmode \ - || (MODE) == HFmode) + || (MODE) == HFmode || (MODE) == BFmode) #define VALID_SSE_REG_MODE(MODE) \ ((MODE) == V1TImode || (MODE) == TImode \ @@ -1077,7 +1077,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); || (MODE) == CQImode || (MODE) == CHImode \ || (MODE) == CSImode || (MODE) == CDImode \ || (MODE) == SDmode || (MODE) == DDmode \ - || (MODE) == HFmode || (MODE) == HCmode \ + || (MODE) == HFmode || (MODE) == HCmode || (MODE) == BFmode \ || (MODE) == V2HImode || (MODE) == V2HFmode \ || (MODE) == V1SImode || (MODE) == V4QImode || (MODE) == V2QImode \ || (TARGET_64BIT \ diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 9aaeb695f0f..1f7b018913a 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -499,7 +499,7 @@ ;; Main data type used by the insn (define_attr "mode" - "unknown,none,QI,HI,SI,DI,TI,OI,XI,HF,SF,DF,XF,TF,V32HF,V16HF,V8HF, + + "unknown,none,QI,HI,SI,DI,TI,OI,XI,HF,BF,SF,DF,XF,TF,V32HF,V16HF,V8HF, V16SF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF,V8DF,V4HF,V2HF" (const_string "unknown")) @@ -1104,7 +1104,7 @@ ;; GET_MODE_SIZE (mode). For XFmode which depends on ;; command line options just use GET_MODE_SIZE macro. (define_mode_attr MODE_SIZE [(QI "1") (HI "2") (SI "4") (DI "8") - (TI "16") (HF "2") (SF "4") (DF "8") + (TI "16") (HF "2") (BF "2") (SF "4") (DF "8") (XF "GET_MODE_SIZE (XFmode)") (V16QI "16") (V32QI "32") (V64QI "64") (V8HI "16") (V16HI "32") (V32HI "64") @@ -1248,7 +1248,7 @@ (define_mode_iterator X87MODEF [SF DF XF]) ;; All x87 floating point modes plus HFmode -(define_mode_iterator X87MODEFH [HF SF DF XF]) +(define_mode_iterator X87MODEFH [HF SF DF XF BF]) ;; All SSE floating point modes (define_mode_iterator SSEMODEF [HF SF DF TF]) @@ -3408,9 +3408,11 @@ operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx); }) -(define_insn "*pushhf_rex64" - [(set (match_operand:HF 0 "push_operand" "=X,X") - (match_operand:HF 1 "nonmemory_no_elim_operand" "r,x"))] +(define_mode_iterator HFBF [HF BF]) + +(define_insn "*push_rex64" + [(set (match_operand:HFBF 0 "push_operand" "=X,X") + (match_operand:HFBF 1 "nonmemory_no_elim_operand" "r,x"))] "TARGET_64BIT" { /* Anything else should be already split before reg-stack. */ @@ -3421,9 +3423,9 @@ (set_attr "type" "push,multi") (set_attr "mode" "DI,TI")]) -(define_insn "*pushhf" - [(set (match_operand:HF 0 "push_operand" "=X,X") - (match_operand:HF 1 "general_no_elim_operand" "rmF,x"))] +(define_insn "*push" + [(set (match_operand:HFBF 0 "push_operand" "=X,X") + (match_operand:HFBF 1 "general_no_elim_operand" "rmF,x"))] "!TARGET_64BIT" { /* Anything else should be already split before reg-stack. */ @@ -3462,7 +3464,7 @@ (set_attr "unit" "i387,*,*") (set_attr "mode" "SF,SI,SF")]) -(define_mode_iterator MODESH [SF HF]) +(define_mode_iterator MODESH [SF HF BF]) ;; %%% Kill this when call knows how to work this out. (define_split [(set (match_operand:MODESH 0 "push_operand") @@ -3950,18 +3952,18 @@ ] (const_string "*")))]) -(define_insn "*movhf_internal" - [(set (match_operand:HF 0 "nonimmediate_operand" +(define_insn "*mov_internal" + [(set (match_operand:HFBF 0 "nonimmediate_operand" "=?r,?r,?r,?m,v,v,?r,m,?v,v") - (match_operand:HF 1 "general_operand" + (match_operand:HFBF 1 "general_operand" "r ,F ,m ,rF,C,v, v,v,r ,m"))] "!(MEM_P (operands[0]) && MEM_P (operands[1])) && (lra_in_progress || reload_completed || !CONST_DOUBLE_P (operands[1]) || (TARGET_SSE2 - && standard_sse_constant_p (operands[1], HFmode) == 1) - || memory_operand (operands[0], HFmode))" + && standard_sse_constant_p (operands[1], mode) == 1) + || memory_operand (operands[0], mode))" { switch (get_attr_type (insn)) { diff --git a/gcc/testsuite/g++.target/i386/bfloat_cpp_typecheck.C b/gcc/testsuite/g++.target/i386/bfloat_cpp_typecheck.C new file mode 100644 index 00000000000..962c8504775 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/bfloat_cpp_typecheck.C @@ -0,0 +1,10 @@ +/* { dg-do assemble { target sse2} } */ +/* { dg-options "-msse2 -O3 --save-temps" } */ + +void foo (void) +{ + __bf16 (); /* { dg-bogus {invalid conversion to type '__bf16'} } */ + __bf16 a = __bf16(); /* { dg-bogus {invalid conversion to type +'__bf16'} } */ + __bf16 (0x1234); /* { dg-error {invalid conversion to type '__bf16'} +} */ + __bf16 (0.1); /* { dg-error {invalid conversion to type '__bf16'} } +*/ } diff --git a/gcc/testsuite/gcc.target/i386/bfloat16-1.c b/gcc/testsuite/gcc.target/i386/bfloat16-1.c new file mode 100644 index 00000000000..6aaec28efd2 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/bfloat16-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-msse2 -O2" } */ +__bf16 +foo (int a) +{ + union { + int a; + __bf16 b; + }c; + c.a = a; + return c.b; +} diff --git a/gcc/testsuite/gcc.target/i386/sse2-bfloat16-1.c b/gcc/testsuite/gcc.target/i386/sse2-bfloat16-1.c new file mode 100644 index 00000000000..612d55be826 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/sse2-bfloat16-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mno-sse2" } */ + +__bf16/* { dg-error "unknown type name '__bf16'" } */ foo (__bf16 x) /* +{ dg-error "unknown type name '__bf16'" } */ { + return x; +} diff --git a/gcc/testsuite/gcc.target/i386/sse2-bfloat16-2.c b/gcc/testsuite/gcc.target/i386/sse2-bfloat16-2.c new file mode 100644 index 00000000000..a3286e26c48 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/sse2-bfloat16-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -msse2 -mno-avx512f" } */ + +union flt +{ + __bf16 flt; + short s; +}; + +__bf16 +foo (union flt x) +{ + return x.flt; +} + +/* { dg-final { scan-assembler {(?n)pinsrw[\t ].*%xmm0} { target ia32 } +} } */ +/* { dg-final { scan-assembler {(?n)movd[\t ].*%xmm0} { target { ! ia32 +} } } } */ diff --git a/gcc/testsuite/gcc.target/i386/sse2-bfloat16-scalar-typecheck.c b/gcc/testsuite/gcc.target/i386/sse2-bfloat16-scalar-typecheck.c new file mode 100644 index 00000000000..f76d5547758 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/sse2-bfloat16-scalar-typecheck.c @@ -0,0 +1,215 @@ +/* { dg-do compile } */ +/* { dg-options "-msse2 -O2" } */ + + +__bf16 glob_bfloat; + +int is_an_int; +short is_a_short_int; +float is_a_float; +float is_a_float16; +double is_a_double; + +float *float_ptr; + +__bf16 foo1 (void) { return (__bf16) 0x1234; } /* { dg-error {invalid +conversion to type '__bf16'} } */ +__bf16 foo2 (void) { return (__bf16) (short) 0x1234; } /* { dg-error +{invalid conversion to type '__bf16'} } */ + +__bf16 footest (__bf16 scalar0) +{ + + /* Initialisation */ + + __bf16 scalar1_1; + __bf16 scalar1_2 = glob_bfloat; + __bf16 scalar1_3 = 0; /* { dg-error {invalid conversion to type '__bf16'} } */ + __bf16 scalar1_4 = 0.1; /* { dg-error {invalid conversion to type + '__bf16'} } */ + __bf16 scalar1_5 = is_a_float; /* { dg-error {invalid conversion to + type '__bf16'} } */ + __bf16 scalar1_6 = is_an_int; /* { dg-error {invalid conversion to + type '__bf16'} } */ + __bf16 scalar1_7 = is_a_float16; /* { dg-error {invalid conversion to + type '__bf16'} } */ + __bf16 scalar1_8 = is_a_double; /* { dg-error {invalid conversion to + type '__bf16'} } */ + __bf16 scalar1_9 = is_a_short_int; /* { dg-error {invalid conversion + to type '__bf16'} } */ + + int initi_1_1 = glob_bfloat; /* { dg-error {invalid conversion from + type '__bf16'} } */ float initi_1_2 = glob_bfloat; /* { dg-error + {invalid conversion from type '__bf16'} } */ + _Float16 initi_1_3 = glob_bfloat; /* { dg-error {invalid conversion + from type '__bf16'} } */ short initi_1_4 = glob_bfloat; /* { dg-error + {invalid conversion from type '__bf16'} } */ double initi_1_5 = + glob_bfloat; /* { dg-error {invalid conversion from type '__bf16'} } + */ + + __bf16 scalar2_1 = {}; /* { dg-error {empty scalar initializer} } */ + __bf16 scalar2_2 = { glob_bfloat }; + __bf16 scalar2_3 = { 0 }; /* { dg-error {invalid conversion to type + '__bf16'} } */ + __bf16 scalar2_4 = { 0.1 }; /* { dg-error {invalid conversion to type + '__bf16'} } */ + __bf16 scalar2_5 = { is_a_float }; /* { dg-error {invalid conversion + to type '__bf16'} } */ + __bf16 scalar2_6 = { is_an_int }; /* { dg-error {invalid conversion + to type '__bf16'} } */ + __bf16 scalar2_7 = { is_a_float16 }; /* { dg-error {invalid + conversion to type '__bf16'} } */ + __bf16 scalar2_8 = { is_a_double }; /* { dg-error {invalid conversion + to type '__bf16'} } */ + __bf16 scalar2_9 = { is_a_short_int }; /* { dg-error {invalid + conversion to type '__bf16'} } */ + + int initi_2_1 = { glob_bfloat }; /* { dg-error {invalid conversion + from type '__bf16'} } */ float initi_2_2 = { glob_bfloat }; /* { + dg-error {invalid conversion from type '__bf16'} } */ + _Float16 initi_2_3 = { glob_bfloat }; /* { dg-error {invalid + conversion from type '__bf16'} } */ short initi_2_4 = { glob_bfloat + }; /* { dg-error {invalid conversion from type '__bf16'} } */ double + initi_2_5 = { glob_bfloat }; /* { dg-error {invalid conversion from + type '__bf16'} } */ + + /* Assignments. */ + + glob_bfloat = glob_bfloat; + glob_bfloat = 0; /* { dg-error {invalid conversion to type '__bf16'} } */ + glob_bfloat = 0.1; /* { dg-error {invalid conversion to type + '__bf16'} } */ glob_bfloat = is_a_float; /* { dg-error {invalid + conversion to type '__bf16'} } */ glob_bfloat = is_an_int; /* { + dg-error {invalid conversion to type '__bf16'} } */ glob_bfloat = + is_a_float16; /* { dg-error {invalid conversion to type '__bf16'} } */ + glob_bfloat = is_a_double; /* { dg-error {invalid conversion to type + '__bf16'} } */ glob_bfloat = is_a_short_int; /* { dg-error {invalid + conversion to type '__bf16'} } */ + + is_an_int = glob_bfloat; /* { dg-error {invalid conversion from type + '__bf16'} } */ is_a_float = glob_bfloat; /* { dg-error {invalid + conversion from type '__bf16'} } */ + is_a_float16 = glob_bfloat; /* { dg-error {invalid conversion from + type '__bf16'} } */ is_a_double = glob_bfloat; /* { dg-error {invalid + conversion from type '__bf16'} } */ is_a_short_int = glob_bfloat; /* + { dg-error {invalid conversion from type '__bf16'} } */ + + /* Casting. */ + + (void) glob_bfloat; + (__bf16) glob_bfloat; + + (int) glob_bfloat; /* { dg-error {invalid conversion from type + '__bf16'} } */ + (float) glob_bfloat; /* { dg-error {invalid conversion from type + '__bf16'} } */ + (_Float16) glob_bfloat; /* { dg-error {invalid conversion from type + '__bf16'} } */ + (double) glob_bfloat; /* { dg-error {invalid conversion from type + '__bf16'} } */ + (short) glob_bfloat; /* { dg-error {invalid conversion from type + '__bf16'} } */ + + (__bf16) is_an_int; /* { dg-error {invalid conversion to type + '__bf16'} } */ + (__bf16) is_a_float; /* { dg-error {invalid conversion to type + '__bf16'} } */ + (__bf16) is_a_float16; /* { dg-error {invalid conversion to type + '__bf16'} } */ + (__bf16) is_a_double; /* { dg-error {invalid conversion to type + '__bf16'} } */ + (__bf16) is_a_short_int; /* { dg-error {invalid conversion to type + '__bf16'} } */ + + /* Compound literals. */ + + (__bf16) {}; /* { dg-error {empty scalar initializer} } */ + (__bf16) { glob_bfloat }; + (__bf16) { 0 }; /* { dg-error {invalid conversion to type '__bf16'} } + */ + (__bf16) { 0.1 }; /* { dg-error {invalid conversion to type '__bf16'} + } */ + (__bf16) { is_a_float }; /* { dg-error {invalid conversion to type + '__bf16'} } */ + (__bf16) { is_an_int }; /* { dg-error {invalid conversion to type + '__bf16'} } */ + (__bf16) { is_a_float16 }; /* { dg-error {invalid conversion to type + '__bf16'} } */ + (__bf16) { is_a_double }; /* { dg-error {invalid conversion to type + '__bf16'} } */ + (__bf16) { is_a_short_int }; /* { dg-error {invalid conversion to + type '__bf16'} } */ + + (int) { glob_bfloat }; /* { dg-error {invalid conversion from type + '__bf16'} } */ + (float) { glob_bfloat }; /* { dg-error {invalid conversion from type + '__bf16'} } */ + (_Float16) { glob_bfloat }; /* { dg-error {invalid conversion from + type '__bf16'} } */ + (double) { glob_bfloat }; /* { dg-error {invalid conversion from type + '__bf16'} } */ + (short) { glob_bfloat }; /* { dg-error {invalid conversion from type + '__bf16'} } */ + + /* Arrays and Structs. */ + + typedef __bf16 array_type[2]; + extern __bf16 extern_array[]; + + __bf16 array[2]; + __bf16 zero_length_array[0]; + __bf16 empty_init_array[] = {}; + typedef __bf16 some_other_type[is_an_int]; + + struct struct1 { + __bf16 a; + }; + + union union1 { + __bf16 a; + }; + + /* Addressing and dereferencing. */ + + __bf16 *bfloat_ptr = &scalar0; + scalar0 = *bfloat_ptr; + + /* Pointer assignment. */ + + __bf16 *bfloat_ptr2 = bfloat_ptr; + __bf16 *bfloat_ptr3 = array; + + /* Pointer arithmetic. */ + + ++bfloat_ptr; + --bfloat_ptr; + bfloat_ptr++; + bfloat_ptr--; + bfloat_ptr += 1; + bfloat_ptr -= 1; + bfloat_ptr - bfloat_ptr2; + bfloat_ptr = &bfloat_ptr3[0]; + bfloat_ptr = &bfloat_ptr3[1]; + + /* Simple comparison. */ + scalar0 > glob_bfloat; /* { dg-error {operation not permitted on type + '__bf16'} } */ glob_bfloat == scalar0; /* { dg-error {operation not + permitted on type '__bf16'} } */ + scalar0 > is_a_float; /* { dg-error {operation not permitted on type + '__bf16'} } */ is_a_float == scalar0; /* { dg-error {operation not + permitted on type '__bf16'} } */ + scalar0 > 0; /* { dg-error {operation not permitted on type '__bf16'} + } */ + 0 == scalar0; /* { dg-error {operation not permitted on type + '__bf16'} } */ + scalar0 > 0.1; /* { dg-error {operation not permitted on type + '__bf16'} } */ + 0.1 == scalar0; /* { dg-error {operation not permitted on type + '__bf16'} } */ + scalar0 > is_an_int; /* { dg-error {operation not permitted on type + '__bf16'} } */ is_an_int == scalar0; /* { dg-error {operation not + permitted on type '__bf16'} } */ + + /* Pointer comparison. */ + + bfloat_ptr == &scalar0;