From patchwork Tue Feb 28 10:04:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 62390 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2923921wrd; Tue, 28 Feb 2023 02:05:33 -0800 (PST) X-Google-Smtp-Source: AK7set9iRlfsIQ0F3wLTTZLf7u68879QXuoz6aCumEkx+C26XqPMoU1lQ/776LON1bL5dck6I8GO X-Received: by 2002:a17:906:3b04:b0:8f8:5779:f1af with SMTP id g4-20020a1709063b0400b008f85779f1afmr1755173ejf.15.1677578733528; Tue, 28 Feb 2023 02:05:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677578733; cv=none; d=google.com; s=arc-20160816; b=BNCtMEGeiwyfg7/QU7k4vEAyR/sHEaUTeLct6LoqkSdIufxcBG7Q1khdx7LY0HCUwC /eCWlPdD5bix8zAjSGxfws3QIVY90jegh8OK5KHnNE329xk5LZluvbTzyeFJsgCKE7RG Z8mr1p+ZU20nPyPs4GBn7YrNjY8oiqSjLpmjPFnNk7osoLrNP5tiZzxIoRZ/4zA4lr39 a/2h14MtcYioGX3rVcVNGt6JU+DT62wUkEg6nKuIuCaMxPHaY8RnXMUK5rWNkgaf7YnV gOMQ2JPdhEs5C3NH2A+lPAgfcJfvyHeuqgDgEFeG31Y1aVbRSGNoA/lFlUGkUStdg9GA 0l8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:in-reply-to:mime-version:references:message-id :subject:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=8f2RkRRzxyKeFF9zudsGf1pgh7DAn78JQuAlq9DgC1M=; b=GYYy2yKIyh8+Ktbxyz0RiIrNrW479d2tTUy7aGcze/gQbQNoEUmxuqPRW4MaqaD2fl eV+LAtyAosWD29W9pq4BO7h15onT4QpcLr1rmzdSNwC3eC57bR7Blc/osnyvibkBbWNH uuoQlcX8IH2ur06aGHX0rad8R2UD443/BjXeyFnAKua5t+o8l4ySdaGrxfWXbylT/t+p uvun8DGv5a+VuLIoRCaqB252FN5UZZzmylvdXn9bTryA3ssQZY2Nx5kU0kQSbGTxgL4D e5Wgs0+EYOfErcHvgAM8xyjn/1hQyUxcp4+mF+ufMOabvTlgrof0l5vTzBJjvmYih3xi 7+Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=lDo2t2zf; 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 sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 4-20020a170906308400b008dd85c37895si10589223ejv.215.2023.02.28.02.05.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 02:05:33 -0800 (PST) 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=lDo2t2zf; 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 8993B385840C for ; Tue, 28 Feb 2023 10:05:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8993B385840C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677578732; bh=8f2RkRRzxyKeFF9zudsGf1pgh7DAn78JQuAlq9DgC1M=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=lDo2t2zfkOFA0zlcJDInl3JUBGsBgq1St7k/qWnO1xkJshS4d9iUCjoZCNqEbANIe asCk5G/wYlGKP51iEqJmYBALhwyMauRC04cHdwBatxd7mGFF24RGiM+kns8fIA9+IE BnAd1kgbncaDHxk+/b13UU8uxfM/Rp5noyUI4NdM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 23E213858D39 for ; Tue, 28 Feb 2023 10:04:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23E213858D39 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-507-ifVZGbPWN9qUa9NlbfOlrA-1; Tue, 28 Feb 2023 05:04:45 -0500 X-MC-Unique: ifVZGbPWN9qUa9NlbfOlrA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 401B088904E for ; Tue, 28 Feb 2023 10:04:45 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.101]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0666C404BEC5; Tue, 28 Feb 2023 10:04:44 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 31SA4gH51110977 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 28 Feb 2023 11:04:43 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 31SA4gQv1110976; Tue, 28 Feb 2023 11:04:42 +0100 Date: Tue, 28 Feb 2023 11:04:42 +0100 To: Jason Merrill , Jonathan Wakely , gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Emit fundamental tinfos for all _Float*/decltype(0.0bf16) types unconditionally [PR108883] Message-ID: References: <7163c5db-3025-01cb-c0ad-5526e46eff8c@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-15.0 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek 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?1759068797799968020?= X-GMAIL-MSGID: =?utf-8?q?1759068797799968020?= Hi! On Tue, Feb 28, 2023 at 12:51:06AM +0100, Jakub Jelinek via Gcc-patches wrote: > And then there is a question whether we want to emit rtti for > _Float{16,32,64,128}, _Float{32,64,128}x and decltype(0.0bf16) regardless > of whether the target supports them at all or not. If the answer to that is yes, we want them all, then the following patch arranges that (had to force immediate emit_tinfo_decl to get rid of the fallback_* stuff), these days it doesn't mean it will be emitted right away anyway, just it will be registered with varpool and have initializers created. If the answer is yes, except _Float128x, we could in the patch just move that &float128x_type_node to the other initializer. If the answer is no, then I think we need a target hook which would tell us which fundamentals should be forced this way, could have e.g. a form of returning a vector of global tree addresses to be treated that way in addition to the standard ones (dfloat*), or a hook that would take a callback pointer and be called with &emit_support_tinfo_1 and the backend would call the callback on any types it wants to handle that way. 2023-02-28 Jakub Jelinek PR target/108883 * cp-tree.h (enum cp_tree_index): Remove CPTI_FALLBACK_DFLOAT*_TYPE enumerators. (fallback_dfloat32_type, fallback_dfloat64_type, fallback_dfloat128_type): Remove. * rtti.cc (emit_support_tinfo_1): If not emitted already, call emit_tinfo_decl and remove from unemitted_tinfo_decls right away. (emit_support_tinfos): Move &dfloat*_type_node, &bfloat16-type_node and &float[0-9]*_type_node from fundamentals array into new fundamentals_with_fallback array. Call emit_support_tinfo_1 on elements of that array too, with the difference that if the type is NULL, use a fallback REAL_TYPE for it temporarily. Drop the !targetm.decimal_float_supported_p () handling. * mangle.cc (write_builtin_type): Remove references to fallback_dfloat*_type. Jakub --- gcc/cp/cp-tree.h.jj 2023-02-18 12:38:30.910023526 +0100 +++ gcc/cp/cp-tree.h 2023-02-28 10:39:22.377379948 +0100 @@ -235,10 +235,6 @@ enum cp_tree_index CPTI_PSEUDO_CONTRACT_VIOLATION, - CPTI_FALLBACK_DFLOAT32_TYPE, - CPTI_FALLBACK_DFLOAT64_TYPE, - CPTI_FALLBACK_DFLOAT128_TYPE, - CPTI_MAX }; @@ -397,13 +393,6 @@ extern GTY(()) tree cp_global_trees[CPTI access nodes in tree.h. */ #define access_default_node null_node - -/* Variant of dfloat{32,64,128}_type_node only used for fundamental - rtti purposes if DFP is disabled. */ -#define fallback_dfloat32_type cp_global_trees[CPTI_FALLBACK_DFLOAT32_TYPE] -#define fallback_dfloat64_type cp_global_trees[CPTI_FALLBACK_DFLOAT64_TYPE] -#define fallback_dfloat128_type cp_global_trees[CPTI_FALLBACK_DFLOAT128_TYPE] - #include "name-lookup.h" --- gcc/cp/rtti.cc.jj 2023-02-22 15:58:50.137998090 +0100 +++ gcc/cp/rtti.cc 2023-02-28 10:31:53.693893021 +0100 @@ -1577,6 +1577,15 @@ emit_support_tinfo_1 (tree bltn) gcc_assert (TREE_PUBLIC (tinfo) && !DECL_COMDAT (tinfo)); DECL_INTERFACE_KNOWN (tinfo) = 1; } + + /* Emit it right away if not emitted already. */ + if (DECL_INITIAL (tinfo) == NULL_TREE) + { + gcc_assert (unemitted_tinfo_decls->last () == tinfo); + bool ok = emit_tinfo_decl (tinfo); + gcc_assert (ok); + unemitted_tinfo_decls->pop (); + } } } @@ -1602,10 +1611,17 @@ emit_support_tinfos (void) &long_integer_type_node, &long_unsigned_type_node, &long_long_integer_type_node, &long_long_unsigned_type_node, &float_type_node, &double_type_node, &long_double_type_node, + &nullptr_type_node, + 0 + }; + /* Similar, but for floating point types only which should get type info + regardless whether they are non-NULL or NULL. */ + static tree *const fundamentals_with_fallback[] = + { &dfloat32_type_node, &dfloat64_type_node, &dfloat128_type_node, &bfloat16_type_node, &float16_type_node, &float32_type_node, &float64_type_node, &float128_type_node, &float32x_type_node, - &float64x_type_node, &float128x_type_node, &nullptr_type_node, + &float64x_type_node, &float128x_type_node, 0 }; int ix; @@ -1627,8 +1643,20 @@ emit_support_tinfos (void) location_t saved_loc = input_location; input_location = BUILTINS_LOCATION; doing_runtime = 1; + tree fallback = NULL_TREE; for (ix = 0; fundamentals[ix]; ix++) emit_support_tinfo_1 (*fundamentals[ix]); + for (ix = 0; fundamentals_with_fallback[ix]; ix++) + if (*fundamentals_with_fallback[ix]) + emit_support_tinfo_1 (*fundamentals_with_fallback[ix]); + else + { + if (fallback == NULL_TREE) + fallback = make_node (REAL_TYPE); + *fundamentals_with_fallback[ix] = fallback; + emit_support_tinfo_1 (fallback); + *fundamentals_with_fallback[ix] = NULL_TREE; + } for (ix = 0; ix < NUM_INT_N_ENTS; ix ++) if (int_n_enabled_p[ix]) { @@ -1637,20 +1665,6 @@ emit_support_tinfos (void) } for (tree t = registered_builtin_types; t; t = TREE_CHAIN (t)) emit_support_tinfo_1 (TREE_VALUE (t)); - /* For compatibility, emit DFP typeinfos even when DFP isn't enabled, - because we've emitted that in the past. */ - if (!targetm.decimal_float_supported_p ()) - { - gcc_assert (dfloat32_type_node == NULL_TREE - && dfloat64_type_node == NULL_TREE - && dfloat128_type_node == NULL_TREE); - fallback_dfloat32_type = make_node (REAL_TYPE); - fallback_dfloat64_type = make_node (REAL_TYPE); - fallback_dfloat128_type = make_node (REAL_TYPE); - emit_support_tinfo_1 (fallback_dfloat32_type); - emit_support_tinfo_1 (fallback_dfloat64_type); - emit_support_tinfo_1 (fallback_dfloat128_type); - } input_location = saved_loc; } --- gcc/cp/mangle.cc.jj 2023-02-09 09:31:48.900375193 +0100 +++ gcc/cp/mangle.cc 2023-02-28 09:39:24.683561290 +0100 @@ -2732,11 +2732,11 @@ write_builtin_type (tree type) write_char ('d'); else if (type == long_double_type_node) write_char ('e'); - else if (type == dfloat32_type_node || type == fallback_dfloat32_type) + else if (type == dfloat32_type_node) write_string ("Df"); - else if (type == dfloat64_type_node || type == fallback_dfloat64_type) + else if (type == dfloat64_type_node) write_string ("Dd"); - else if (type == dfloat128_type_node || type == fallback_dfloat128_type) + else if (type == dfloat128_type_node) write_string ("De"); else if (type == float16_type_node) write_string ("DF16_");