From patchwork Tue Jun 28 17:12:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1649653 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=uNdXnX5T; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LXWPH2LHNz9sFx for ; Wed, 29 Jun 2022 03:12:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A0E75385115E for ; Tue, 28 Jun 2022 17:12:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0E75385115E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1656436352; bh=WbY2CmF05D9D0YBIN0mLdCNkKA49tKfFsPWFXZca1TA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=uNdXnX5TqSM7da3NK5feHYGITtSElX0MdinAFtEU1bHLe1rLMS60rq1x1rH5M6iC4 fH/713z1Sg98folUzX3V3mf5Iae6SloP/QjTi2/1M9pmtDo9CGAGav/Sp8AfI0yfs2 d5cgy6GJEBDwaFVjDfET8D5QvLZFiDkoNQQ8qwT8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050:0:465::101]) by sourceware.org (Postfix) with ESMTPS id D5BB33851173 for ; Tue, 28 Jun 2022 17:12:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D5BB33851173 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4LXWNn5TmPz9smL; Tue, 28 Jun 2022 19:12:09 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Use create_tmp_var_raw and get_callee_fndecl Date: Tue, 28 Jun 2022 19:12:08 +0200 Message-Id: <20220628171208.188117-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4LXWNn5TmPz9smL X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, A couple of small patterns that repeat are generating a temporary, and getting a function out of a CALL_EXPR (there are other changes that are in the works where I ended up adding more repeats of these patterns). There are convenience functions for these in the common parts of gcc, use them instead. Regstrapped on x86_64-linux-gnu, and committed to mainline. Regards, Iain. --- gcc/d/ChangeLog: * d-codegen.cc: Include gimple-expr.h. (force_target_expr): Use create_tmp_var_raw. * decl.cc: Inlucde gimple-expr.h. (build_local_temp): Use create_tmp_var_raw. * intrinsics.cc (expand_intrinsic_rotate): Use get_callee_fndecl. (maybe_expand_intrinsic): Likewise. --- gcc/d/d-codegen.cc | 6 ++---- gcc/d/decl.cc | 7 ++----- gcc/d/intrinsics.cc | 13 +++---------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc index 8a8bf12e7fc..2d90899b37f 100644 --- a/gcc/d/d-codegen.cc +++ b/gcc/d/d-codegen.cc @@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see #include "stor-layout.h" #include "attribs.h" #include "function.h" +#include "gimple-expr.h" #include "d-tree.h" @@ -623,11 +624,8 @@ build_target_expr (tree decl, tree exp) tree force_target_expr (tree exp) { - tree decl = build_decl (input_location, VAR_DECL, NULL_TREE, - TREE_TYPE (exp)); + tree decl = create_tmp_var_raw (TREE_TYPE (exp)); DECL_CONTEXT (decl) = current_function_decl; - DECL_ARTIFICIAL (decl) = 1; - DECL_IGNORED_P (decl) = 1; layout_decl (decl, 0); return build_target_expr (decl, exp); diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 5032ae02d6b..3caa465dd1e 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -57,6 +57,7 @@ along with GCC; see the file COPYING3. If not see #include "alloc-pool.h" #include "symbol-summary.h" #include "symtab-thunks.h" +#include "gimple-expr.h" #include "d-tree.h" #include "d-target.h" @@ -1465,11 +1466,7 @@ declare_local_var (VarDeclaration *var) tree build_local_temp (tree type) { - tree decl = build_decl (input_location, VAR_DECL, NULL_TREE, type); - - DECL_CONTEXT (decl) = current_function_decl; - DECL_ARTIFICIAL (decl) = 1; - DECL_IGNORED_P (decl) = 1; + tree decl = create_tmp_var_raw (type); d_pushdecl (decl); return decl; diff --git a/gcc/d/intrinsics.cc b/gcc/d/intrinsics.cc index 0f96284473f..0dd5543fdd1 100644 --- a/gcc/d/intrinsics.cc +++ b/gcc/d/intrinsics.cc @@ -421,12 +421,8 @@ expand_intrinsic_rotate (intrinsic_code intrinsic, tree callexp) count = CALL_EXPR_ARG (callexp, 1); else { - tree callee = CALL_EXPR_FN (callexp); - - if (TREE_CODE (callee) == ADDR_EXPR) - callee = TREE_OPERAND (callee, 0); - /* Retrieve from the encoded template instantation. */ + tree callee = get_callee_fndecl (callexp); TemplateInstance *ti = DECL_LANG_FRONTEND (callee)->isInstantiated (); gcc_assert (ti && ti->tiargs && ti->tiargs->length == 2); @@ -761,12 +757,9 @@ expand_volatile_store (tree callexp) tree maybe_expand_intrinsic (tree callexp) { - tree callee = CALL_EXPR_FN (callexp); - - if (TREE_CODE (callee) == ADDR_EXPR) - callee = TREE_OPERAND (callee, 0); + tree callee = get_callee_fndecl (callexp); - if (TREE_CODE (callee) != FUNCTION_DECL) + if (callee == NULL_TREE || TREE_CODE (callee) != FUNCTION_DECL) return callexp; /* Don't expand CTFE-only intrinsics outside of semantic processing. */