From patchwork Wed May 11 13:22:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 53808 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 DAD84384A460 for ; Wed, 11 May 2022 13:22:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DAD84384A460 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652275355; bh=n+18NXXKF0uHPlOE3OflmUx5+iGrOs/VR4Q8PwBS/Qk=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=n6CHfGnfH60FY/y7AIHvYsMEECenkPAqqWGwAPucw7fTDiDy27dY82/MDwkAb/JXG 0DKvG5vCgvdbEYTvQaO+b6nEgT3kjZc+HKED7jRCjPjXeGA8RteqJTWZ78BXei7jgr y7EwKsexuSrm2TWpxsAHdUqrJ/IH7zzNpwo/IHog= 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 18EC0385042D for ; Wed, 11 May 2022 13:22:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 18EC0385042D 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 043CC1FA69 for ; Wed, 11 May 2022 13:22:05 +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 E542E139F9 for ; Wed, 11 May 2022 13:22:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id NCLhNny4e2KNAQAAMHmgww (envelope-from ) for ; Wed, 11 May 2022 13:22:04 +0000 Date: Wed, 11 May 2022 15:22:04 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Use variadic template functions for the gimple_build forwarders MIME-Version: 1.0 Message-Id: <20220511132204.E542E139F9@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.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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The following consolidates the forwarders to gimple_build with UNKNOWN_LOCATION by using two variadic template functions. This makes the code visually less disturbing and is in preparation of adding more forwarders with different stmt insertion schemes. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. 2022-05-11 Richard Biener * gimple-fold.h (gimple_build): Use variadic template functions for the gimple_build API forwarders without location_t argument. --- gcc/gimple-fold.h | 45 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/gcc/gimple-fold.h b/gcc/gimple-fold.h index 3a0ef54394e..850f917bbc1 100644 --- a/gcc/gimple-fold.h +++ b/gcc/gimple-fold.h @@ -73,55 +73,32 @@ extern tree tree_vec_extract (gimple_stmt_iterator *, tree, tree, tree, tree); Supposed to replace force_gimple_operand (fold_buildN (...), ...). */ extern tree gimple_build (gimple_seq *, location_t, enum tree_code, tree, tree); -inline tree -gimple_build (gimple_seq *seq, - enum tree_code code, tree type, tree op0) -{ - return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0); -} extern tree gimple_build (gimple_seq *, location_t, enum tree_code, tree, tree, tree); -inline tree -gimple_build (gimple_seq *seq, - enum tree_code code, tree type, tree op0, tree op1) -{ - return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0, op1); -} extern tree gimple_build (gimple_seq *, location_t, enum tree_code, tree, tree, tree, tree); +template inline tree -gimple_build (gimple_seq *seq, - enum tree_code code, tree type, tree op0, tree op1, tree op2) +gimple_build (gimple_seq *seq, enum tree_code code, tree type, Args ...ops) { - return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0, op1, op2); + static_assert (sizeof...(ops) > 0 && sizeof...(ops) <= 3, + "Number of operands must be from one to three"); + return gimple_build (seq, UNKNOWN_LOCATION, code, type, ops...); } + extern tree gimple_build (gimple_seq *, location_t, combined_fn, tree); -inline tree -gimple_build (gimple_seq *seq, combined_fn fn, tree type) -{ - return gimple_build (seq, UNKNOWN_LOCATION, fn, type); -} extern tree gimple_build (gimple_seq *, location_t, combined_fn, tree, tree); -inline tree -gimple_build (gimple_seq *seq, combined_fn fn, tree type, tree arg0) -{ - return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0); -} extern tree gimple_build (gimple_seq *, location_t, combined_fn, tree, tree, tree); -inline tree -gimple_build (gimple_seq *seq, combined_fn fn, - tree type, tree arg0, tree arg1) -{ - return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0, arg1); -} extern tree gimple_build (gimple_seq *, location_t, combined_fn, tree, tree, tree, tree); +template inline tree -gimple_build (gimple_seq *seq, combined_fn fn, - tree type, tree arg0, tree arg1, tree arg2) +gimple_build (gimple_seq *seq, combined_fn fn, tree type, Args ...args) { - return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0, arg1, arg2); + static_assert (sizeof...(args) < 4, + "Number of arguments must be less than four"); + return gimple_build (seq, UNKNOWN_LOCATION, fn, type, args...); } extern tree gimple_convert (gimple_seq *, location_t, tree, tree);