d: Use create_tmp_var_raw and get_callee_fndecl

A couple of small patterns that repeat are generating a temporary, and
getting a function out of a CALL_EXPR.  There are convenience functions
for these in the common parts of gcc, use them instead.

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.
This commit is contained in:
Iain Buclaw 2022-06-28 18:49:27 +02:00
parent 6201277441
commit ad4c44d20e
3 changed files with 7 additions and 19 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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);
tree callee = get_callee_fndecl (callexp);
if (TREE_CODE (callee) == ADDR_EXPR)
callee = TREE_OPERAND (callee, 0);
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. */