From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 C2171385842C for ; Wed, 15 Dec 2021 22:10:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C2171385842C Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-407-ptpgC0RVPtGb5dFZt558fA-1; Wed, 15 Dec 2021 17:10:17 -0500 X-MC-Unique: ptpgC0RVPtGb5dFZt558fA-1 Received: by mail-qt1-f197.google.com with SMTP id a8-20020ac86108000000b002b63fc40062so31617718qtm.2 for ; Wed, 15 Dec 2021 14:10:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=z0uoJff7IZUxZEDefD6MQjl1Ht7SLsY/UJXaA0H6i1A=; b=EQGNT5HIPXctv2mivAwSbtvdP7qRAqLvAP1w+f7g9Yw65eJNpbMM3JxgcsufKJ8mqf hQ9QtHydZRgKpab9EhoK9DqbJiLJ2BHTzni1UTi51eee6t1yF5najKmUKUpac6rDNQRY toTYjZ/PV3fxNoRM1zCovGxZ7EiKEUwiHpoPZxIRqQj9NWvgnpspvbiwWnzEgXrbjyUz 99/6w5mresv2ad1U4c4u3UObhbB5372rayvR9YYl5tbiGDFezAOdoQTUgsRzmoqb3wXL 4SNCaYjbz6b6OiUQ4E0ABdxoSdf6zBHcvh5En6vI1yrNtPM7MR4UrMn9OMG61//aOgkm oflg== X-Gm-Message-State: AOAM5320MG6MxCQHjzpPBvkagwestBarSZPidSOaax7Nrlad6Pa8lXb/ P+XSCIUisewygvIOxl63eUwE8LtLJrBicyPtXoPrle2c0FRSNRCRQi9JO/+Cbkj9jX/atpfAQp8 7hmfGSegiJiSSNVZL9Q== X-Received: by 2002:a05:6214:4112:: with SMTP id kc18mr13376931qvb.76.1639606216499; Wed, 15 Dec 2021 14:10:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcuWx70dSKgl654vVnQqMhsiUTYsU3dfgYdpHSplSjZIlc8tBLFJc83L7bLyIOOiFlD96itA== X-Received: by 2002:a05:6214:4112:: with SMTP id kc18mr13376903qvb.76.1639606216139; Wed, 15 Dec 2021 14:10:16 -0800 (PST) Received: from [192.168.1.149] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id w8sm2481608qtc.36.2021.12.15.14.10.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Dec 2021 14:10:15 -0800 (PST) Message-ID: Date: Wed, 15 Dec 2021 17:10:14 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH] gengtype: remove "tree_exp" special attribute To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20211210154101.2898414-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20211210154101.2898414-1-ppalka@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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-List-Received-Date: Wed, 15 Dec 2021 22:10:20 -0000 On 12/10/21 10:41, Patrick Palka wrote: > The function comment for adjust_field_tree_exp says this special case > is for handling trees whose operands may contain pointers to RTL instead > of to trees. But ever since r0-59671, which fixed/removed the last two > tree codes for which this was possible (GOTO_SUBROUTINE_EXPR and > WITH_CLEANUP_EXPR), this special attribute is largely a no-op. > > This patch removes it and instead just annotates struct tree_exp > with the "length" attribute directly. Not sure it makes a difference, > but I use %h instead of %0 in the "length" attribute to be consistent > with other structures' "length" attributes within tree-core.h. > > This changes the code generated for TS_EXP handling in gt-cp-tree.h from: > > case TS_EXP: > gt_ggc_m_9tree_node ((*x).generic.exp.typed.type); > switch ((int) (TREE_CODE ((tree) &(*x)))) > { > default: > { > size_t i3; > size_t l3 = (size_t)(TREE_OPERAND_LENGTH ((tree) &(*x))); > for (i3 = 0; i3 != l3; i3++) { > gt_ggc_m_9tree_node ((*x).generic.exp.operands[i3]); > } > } > break; > } > break; > > to: > > case TS_EXP: > { > size_t l3 = (size_t)(TREE_OPERAND_LENGTH ((tree)&((*x).generic.exp))); > gt_ggc_m_9tree_node ((*x).generic.exp.typed.type); > { > size_t i3; > for (i3 = 0; i3 != l3; i3++) { > gt_ggc_m_9tree_node ((*x).generic.exp.operands[i3]); > } > } > } > > which seems equivalent and simpler. > > Boostrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? OK. > gcc/ChangeLog: > > * gengtype.c (adjust_field_tree_exp): Remove. > (adjust_field_type): Don't handle the "tree_exp" special attribute. > * tree-core.h (struct tree_exp): Replace special and desc > attributes with length. > --- > gcc/gengtype.c | 35 +---------------------------------- > gcc/tree-core.h | 4 +--- > 2 files changed, 2 insertions(+), 37 deletions(-) > > diff --git a/gcc/gengtype.c b/gcc/gengtype.c > index db218a7bce7..2dc443175fa 100644 > --- a/gcc/gengtype.c > +++ b/gcc/gengtype.c > @@ -511,7 +511,6 @@ pair_p typedefs = NULL; > type_p structures = NULL; > pair_p variables = NULL; > > -static type_p adjust_field_tree_exp (type_p t, options_p opt); > static type_p adjust_field_rtx_def (type_p t, options_p opt); > > /* Define S as a typedef to T at POS. */ > @@ -1384,36 +1383,6 @@ adjust_field_rtx_def (type_p t, options_p ARG_UNUSED (opt)) > nodot, NULL); > } > > -/* Handle `special("tree_exp")'. This is a special case for > - field `operands' of struct tree_exp, which although it claims to contain > - pointers to trees, actually sometimes contains pointers to RTL too. > - Passed T, the old type of the field, and OPT its options. Returns > - a new type for the field. */ > - > -static type_p > -adjust_field_tree_exp (type_p t, options_p opt ATTRIBUTE_UNUSED) > -{ > - pair_p flds; > - options_p nodot; > - > - if (t->kind != TYPE_ARRAY) > - { > - error_at_line (&lexer_line, > - "special `tree_exp' must be applied to an array"); > - return &string_type; > - } > - > - nodot = create_string_option (NULL, "dot", ""); > - > - flds = create_field (NULL, t, ""); > - flds->opt = create_string_option (nodot, "length", > - "TREE_OPERAND_LENGTH ((tree) &%0)"); > - flds->opt = create_string_option (flds->opt, "default", ""); > - > - return new_structure ("tree_exp_subunion", TYPE_UNION, &lexer_line, flds, > - nodot, NULL); > -} > - > /* Perform any special processing on a type T, about to become the type > of a field. Return the appropriate type for the field. > At present: > @@ -1447,9 +1416,7 @@ adjust_field_type (type_p t, options_p opt) > && opt->kind == OPTION_STRING) > { > const char *special_name = opt->info.string; > - if (strcmp (special_name, "tree_exp") == 0) > - t = adjust_field_tree_exp (t, opt); > - else if (strcmp (special_name, "rtx_def") == 0) > + if (strcmp (special_name, "rtx_def") == 0) > t = adjust_field_rtx_def (t, opt); > else > error_at_line (&lexer_line, "unknown special `%s'", special_name); > diff --git a/gcc/tree-core.h b/gcc/tree-core.h > index 91ae5237d7e..c48018999ce 100644 > --- a/gcc/tree-core.h > +++ b/gcc/tree-core.h > @@ -1547,9 +1547,7 @@ enum omp_clause_linear_kind > struct GTY(()) tree_exp { > struct tree_typed typed; > location_t locus; > - tree GTY ((special ("tree_exp"), > - desc ("TREE_CODE ((tree) &%0)"))) > - operands[1]; > + tree GTY ((length ("TREE_OPERAND_LENGTH ((tree)&%h)"))) operands[1]; > }; > > /* Immediate use linking structure. This structure is used for maintaining