From patchwork Mon May 16 10:33:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 54030 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 085223858C56 for ; Mon, 16 May 2022 10:35:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 085223858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652697304; bh=6vgtMbigic8y/1fO9hsdUj5O0U6MaWHxqRxgwi48tdY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=fGYr283pm6itHqOTRuss0j7isnc+OP4n1KIvdCoNWz2PUjE0rL4ieTg4kETbvJMBQ jiL/BjyM9YLHsGhhexHa9wObWt3nmqM4rZz4u9KlZA8r6d832w0dFePAAhoBO610tM aTW2KmadQedjBX+CbDzh19hhz+JRBdC8xL5MKdWI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 512293857370 for ; Mon, 16 May 2022 10:33:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 512293857370 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2BA011FAE9; Mon, 16 May 2022 10:33:47 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 13C6C13ADC; Mon, 16 May 2022 10:33:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id psWmA4sogmIbLQAAMHmgww (envelope-from ); Mon, 16 May 2022 10:33:47 +0000 Date: Mon, 16 May 2022 12:33:46 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Move code_helper to tree.h MIME-Version: 1.0 Message-Id: <20220516103347.13C6C13ADC@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Cc: richard.sandiford@arm.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" tree.h already contains combined_fn handling at the top and moving code_helper away from gimple-match.h makes improving the gimple_build API easier. Bootstrapped on x86_64-unknown-linux-gnu. Will push this if there are no comments when I've finished enhancing the gimple_build API (and moving pieces out from gimple-match.h). Richard. 2022-05-16 Richard Biener * gimple-match.h (code_helper): Move class ... * tree.h (code_helper): ... here. --- gcc/gimple-match.h | 49 ---------------------------------------------- gcc/tree.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/gcc/gimple-match.h b/gcc/gimple-match.h index d7b0b676059..e96c31ed09f 100644 --- a/gcc/gimple-match.h +++ b/gcc/gimple-match.h @@ -23,55 +23,6 @@ along with GCC; see the file COPYING3. If not see #define GCC_GIMPLE_MATCH_H -/* Helper to transparently allow tree codes and builtin function codes - exist in one storage entity. */ -class code_helper -{ -public: - code_helper () {} - code_helper (tree_code code) : rep ((int) code) {} - code_helper (combined_fn fn) : rep (-(int) fn) {} - code_helper (internal_fn fn) : rep (-(int) as_combined_fn (fn)) {} - explicit operator tree_code () const { return (tree_code) rep; } - explicit operator combined_fn () const { return (combined_fn) -rep; } - explicit operator internal_fn () const; - explicit operator built_in_function () const; - bool is_tree_code () const { return rep > 0; } - bool is_fn_code () const { return rep < 0; } - bool is_internal_fn () const; - bool is_builtin_fn () const; - int get_rep () const { return rep; } - bool operator== (const code_helper &other) { return rep == other.rep; } - bool operator!= (const code_helper &other) { return rep != other.rep; } - bool operator== (tree_code c) { return rep == code_helper (c).rep; } - bool operator!= (tree_code c) { return rep != code_helper (c).rep; } - -private: - int rep; -}; - -inline code_helper::operator internal_fn () const -{ - return as_internal_fn (combined_fn (*this)); -} - -inline code_helper::operator built_in_function () const -{ - return as_builtin_fn (combined_fn (*this)); -} - -inline bool -code_helper::is_internal_fn () const -{ - return is_fn_code () && internal_fn_p (combined_fn (*this)); -} - -inline bool -code_helper::is_builtin_fn () const -{ - return is_fn_code () && builtin_fn_p (combined_fn (*this)); -} - /* Represents the condition under which an operation should happen, and the value to use otherwise. The condition applies elementwise (as for VEC_COND_EXPR) if the values are vectors. */ diff --git a/gcc/tree.h b/gcc/tree.h index 5f4b03dc5df..c92c5bf344b 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -75,6 +75,55 @@ as_internal_fn (combined_fn code) return internal_fn (int (code) - int (END_BUILTINS)); } +/* Helper to transparently allow tree codes and builtin function codes + exist in one storage entity. */ +class code_helper +{ +public: + code_helper () {} + code_helper (tree_code code) : rep ((int) code) {} + code_helper (combined_fn fn) : rep (-(int) fn) {} + code_helper (internal_fn fn) : rep (-(int) as_combined_fn (fn)) {} + explicit operator tree_code () const { return (tree_code) rep; } + explicit operator combined_fn () const { return (combined_fn) -rep; } + explicit operator internal_fn () const; + explicit operator built_in_function () const; + bool is_tree_code () const { return rep > 0; } + bool is_fn_code () const { return rep < 0; } + bool is_internal_fn () const; + bool is_builtin_fn () const; + int get_rep () const { return rep; } + bool operator== (const code_helper &other) { return rep == other.rep; } + bool operator!= (const code_helper &other) { return rep != other.rep; } + bool operator== (tree_code c) { return rep == code_helper (c).rep; } + bool operator!= (tree_code c) { return rep != code_helper (c).rep; } + +private: + int rep; +}; + +inline code_helper::operator internal_fn () const +{ + return as_internal_fn (combined_fn (*this)); +} + +inline code_helper::operator built_in_function () const +{ + return as_builtin_fn (combined_fn (*this)); +} + +inline bool +code_helper::is_internal_fn () const +{ + return is_fn_code () && internal_fn_p (combined_fn (*this)); +} + +inline bool +code_helper::is_builtin_fn () const +{ + return is_fn_code () && builtin_fn_p (combined_fn (*this)); +} + /* Macros for initializing `tree_contains_struct'. */ #define MARK_TS_BASE(C) \ (tree_contains_struct[C][TS_BASE] = true)