This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use more DECL_BUILT_IN_P macro.


On 08/14/2018 06:02 PM, Martin Sebor wrote:
> On 08/14/2018 03:06 AM, Martin Liška wrote:
>> Hi.
>>
>> The patch adds more usages of the new macro. I hope it improves
>> readability of code.
> 
> I think it does :)  I see that most invocations of it in your
> patch are with BUILT_IN_NORMAL as the second argument.  Is
> the argument implied by the last argument?  E.g., in
> 
>   DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL, BUILT_IN_VA_ARG_PACK)
> 
> is there a way to determine that BUILT_IN_VA_ARG_PACK implies
> DECL_BUILT_IN_CLASS(fndecl), so that the second argument could
> be eliminated?  (Both to make the invocation less verbose and
> to avoid the mistake of using the macro with the wrong class.)

If I see correctly not, there are separate enums:

BUILT_IN_MD:

enum ix86_builtins {
  IX86_BUILTIN_MASKMOVQ,
  IX86_BUILTIN_LDMXCSR,
  IX86_BUILTIN_STMXCSR,
...
}

BUILT_IN_NORMAL:
enum built_in_function {
BUILT_IN_NONE,
BUILT_IN_ACOS,
BUILT_IN_ACOSF,
...
}

So the enum values overlap and thus one needs the class.


> 
> If not, adding DECL_NORMAL_BUILT_IN_P() would make it possible
> to omit it.

But yes, this is nice idea, I'm sending V2 of the patch that I'm testing
right now.

Martin

> 
> Martin
> 
>>
>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>
>> Ready to be installed?
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2018-08-10  Martin Liska  <mliska@suse.cz>
>>
>>     * tree.h (DECL_BUILT_IN_P): Add also check
>>         for TREE_CODE (NODE) == FUNCTION_DECL.
>>     * builtins.c (fold_call_expr): Use DECL_BUILT_IN_P macro.
>>     (fold_builtin_call_array): Likewise.
>>     * cgraph.c (cgraph_update_edges_for_call_stmt_node): Likewise.
>>     (cgraph_edge::verify_corresponds_to_fndecl): Likewise.
>>     (cgraph_node::verify_node): Likewise.
>>     * cgraphclones.c (cgraph_node::create_clone): Likewise.
>>     * dse.c (scan_insn): Likewise.
>>     * fold-const.c (fold_binary_loc): Likewise.
>>     * gimple-pretty-print.c (dump_gimple_call): Likewise.
>>     * gimple.c (gimple_call_builtin_p): Likewise.
>>     * gimplify.c (gimplify_call_expr): Likewise.
>>     (gimple_boolify): Likewise.
>>     (gimplify_modify_expr): Likewise.
>>     * ipa-fnsummary.c (compute_fn_summary): Likewise.
>>     * omp-low.c (setjmp_or_longjmp_p): Likewise.
>>     * trans-mem.c (is_tm_irrevocable): Likewise.
>>     (is_tm_abort): Likewise.
>>     * tree-cfg.c (stmt_can_terminate_bb_p): Likewise.
>>     * tree-inline.c (copy_bb): Likewise.
>>     * tree-sra.c (scan_function): Likewise.
>>     * tree-ssa-ccp.c (optimize_stack_restore): Likewise.
>>     (pass_fold_builtins::execute): Likewise.
>>     * tree-ssa-dom.c (dom_opt_dom_walker::optimize_stmt): Likewise.
>>     * tree-ssa-loop-im.c (stmt_cost): Likewise.
>>     * tree-stdarg.c (optimize_va_list_gpr_fpr_size): Likewise.
>>
>> gcc/c/ChangeLog:
>>
>> 2018-08-10  Martin Liska  <mliska@suse.cz>
>>
>>     * c-parser.c (c_parser_postfix_expression_after_primary):
>>         Use DECL_BUILT_IN_P macro.
>>
>> gcc/cp/ChangeLog:
>>
>> 2018-08-10  Martin Liska  <mliska@suse.cz>
>>
>>     * constexpr.c (constexpr_fn_retval): Use DECL_BUILT_IN_P macro.
>>     (cxx_eval_builtin_function_call): Likewise.
>>     * cp-gimplify.c (cp_gimplify_expr): Likewise.
>>     (cp_fold): Likewise.
>>     * semantics.c (finish_call_expr): Likewise.
>>     * tree.c (builtin_valid_in_constant_expr_p): Likewise.
>> ---
>>  gcc/builtins.c            | 10 ++--------
>>  gcc/c/c-parser.c          |  9 +++------
>>  gcc/cgraph.c              | 13 ++++++-------
>>  gcc/cgraphclones.c        |  4 ++--
>>  gcc/cp/constexpr.c        | 12 +++++-------
>>  gcc/cp/cp-gimplify.c      | 12 ++++--------
>>  gcc/cp/semantics.c        |  4 +---
>>  gcc/cp/tree.c             |  5 ++---
>>  gcc/dse.c                 |  5 ++---
>>  gcc/fold-const.c          |  4 +---
>>  gcc/gimple-pretty-print.c |  4 +---
>>  gcc/gimple.c              |  3 +--
>>  gcc/gimplify.c            | 14 ++++----------
>>  gcc/ipa-fnsummary.c       |  8 ++++----
>>  gcc/omp-low.c             |  5 ++---
>>  gcc/trans-mem.c           |  8 ++------
>>  gcc/tree-cfg.c            |  3 +--
>>  gcc/tree-inline.c         |  4 ++--
>>  gcc/tree-sra.c            |  4 ++--
>>  gcc/tree-ssa-ccp.c        |  8 ++------
>>  gcc/tree-ssa-dom.c        |  4 +---
>>  gcc/tree-ssa-loop-im.c    |  4 +---
>>  gcc/tree-stdarg.c         |  6 ++----
>>  gcc/tree.h                |  4 +++-
>>  24 files changed, 56 insertions(+), 101 deletions(-)
>>
>>
> 

>From 257e63dcd53f218fc08e91f0f4961ea2b46e3e1d Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Fri, 10 Aug 2018 13:29:48 +0200
Subject: [PATCH] Use new macros: DECL_FE_BUILT_IN_P and
 DECL_NORMAL_BUILT_IN_P.

gcc/ChangeLog:

2018-08-10  Martin Liska  <mliska@suse.cz>

	* tree.h (DECL_BUILT_IN_P): Add also check
        for TREE_CODE (NODE) == FUNCTION_DECL.
	(DECL_NORMAL_BUILT_IN_P): New macro.
	(DECL_FE_BUILT_IN_P): Likewise.
	* builtins.c (fold_call_expr): Use DECL_{NORMAL,FE}_BUILT_IN_P macro.
	(fold_builtin_call_array): Likewise.
	* cgraph.c (cgraph_update_edges_for_call_stmt_node): Likewise.
	(cgraph_edge::verify_corresponds_to_fndecl): Likewise.
	(cgraph_node::verify_node): Likewise.
	* cgraphclones.c (cgraph_node::create_clone): Likewise.
	* dse.c (scan_insn): Likewise.
	* fold-const.c (fold_binary_loc): Likewise.
	* gimple-pretty-print.c (dump_gimple_call): Likewise.
	* gimple.c (gimple_call_builtin_p): Likewise.
	* gimplify.c (gimplify_call_expr): Likewise.
	(gimple_boolify): Likewise.
	(gimplify_modify_expr): Likewise.
	* ipa-fnsummary.c (compute_fn_summary): Likewise.
	* omp-low.c (setjmp_or_longjmp_p): Likewise.
	* trans-mem.c (is_tm_irrevocable): Likewise.
	(is_tm_abort): Likewise.
	* tree-cfg.c (stmt_can_terminate_bb_p): Likewise.
	* tree-inline.c (copy_bb): Likewise.
	* tree-sra.c (scan_function): Likewise.
	* tree-ssa-ccp.c (optimize_stack_restore): Likewise.
	(pass_fold_builtins::execute): Likewise.
	* tree-ssa-dom.c (dom_opt_dom_walker::optimize_stmt): Likewise.
	* tree-ssa-loop-im.c (stmt_cost): Likewise.
	* tree-stdarg.c (optimize_va_list_gpr_fpr_size): Likewise.

gcc/c/ChangeLog:

2018-08-10  Martin Liska  <mliska@suse.cz>

	* c-parser.c (c_parser_postfix_expression_after_primary):
        Use DECL_{NORMAL,FE}_BUILT_IN_P macro.

gcc/cp/ChangeLog:

2018-08-10  Martin Liska  <mliska@suse.cz>

	* constexpr.c (constexpr_fn_retval):
        Use DECL_{NORMAL,FE}_BUILT_IN_P macro.
	(cxx_eval_builtin_function_call): Likewise.
	* cp-gimplify.c (cp_gimplify_expr): Likewise.
	(cp_fold): Likewise.
	* semantics.c (finish_call_expr): Likewise.
	* tree.c (builtin_valid_in_constant_expr_p): Likewise.
---
 gcc/builtins.c            | 16 +++++-----------
 gcc/c/c-parser.c          |  8 ++------
 gcc/cgraph.c              | 13 ++++++-------
 gcc/cgraphclones.c        |  3 +--
 gcc/cp/constexpr.c        | 10 +++-------
 gcc/cp/cp-gimplify.c      | 10 ++--------
 gcc/cp/semantics.c        |  4 +---
 gcc/cp/tree.c             |  4 +---
 gcc/dse.c                 |  4 +---
 gcc/fold-const.c          |  4 +---
 gcc/gimple-pretty-print.c |  4 +---
 gcc/gimple.c              |  3 +--
 gcc/gimplify.c            | 13 +++----------
 gcc/ipa-fnsummary.c       |  6 ++----
 gcc/omp-low.c             |  5 ++---
 gcc/predict.c             |  6 +++---
 gcc/trans-mem.c           |  8 ++------
 gcc/tree-cfg.c            |  3 +--
 gcc/tree-inline.c         |  4 ++--
 gcc/tree-sra.c            |  4 ++--
 gcc/tree-ssa-ccp.c        |  8 ++------
 gcc/tree-ssa-dom.c        |  4 +---
 gcc/tree-ssa-loop-im.c    |  4 +---
 gcc/tree-stdarg.c         |  6 ++----
 gcc/tree.h                | 14 +++++++++++++-
 25 files changed, 61 insertions(+), 107 deletions(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 867d153d798..569651807a2 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -8298,9 +8298,9 @@ fold_builtin_expect (location_t loc, tree arg0, tree arg1, tree arg2,
 
   if (TREE_CODE (inner) == CALL_EXPR
       && (fndecl = get_callee_fndecl (inner))
-      && (DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL, BUILT_IN_EXPECT)
-	  || DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL,
-			      BUILT_IN_EXPECT_WITH_PROBABILITY)))
+      && (DECL_NORMAL_BUILT_IN_P (fndecl, BUILT_IN_EXPECT)
+	  || DECL_NORMAL_BUILT_IN_P (fndecl,
+				     BUILT_IN_EXPECT_WITH_PROBABILITY)))
     return arg0;
 
   inner = inner_arg0;
@@ -9629,10 +9629,7 @@ fold_call_expr (location_t loc, tree exp, bool ignore)
       if (nargs && TREE_CODE (CALL_EXPR_ARG (exp, nargs - 1)) == CALL_EXPR)
 	{
 	  tree fndecl2 = get_callee_fndecl (CALL_EXPR_ARG (exp, nargs - 1));
-	  if (fndecl2
-	      && TREE_CODE (fndecl2) == FUNCTION_DECL
-	      && DECL_BUILT_IN_CLASS (fndecl2) == BUILT_IN_NORMAL
-	      && DECL_FUNCTION_CODE (fndecl2) == BUILT_IN_VA_ARG_PACK)
+	  if (DECL_NORMAL_BUILT_IN_P (fndecl2, BUILT_IN_VA_ARG_PACK))
 	    return NULL_TREE;
 	}
 
@@ -9675,10 +9672,7 @@ fold_builtin_call_array (location_t loc, tree,
       if (n && TREE_CODE (argarray[n - 1]) == CALL_EXPR)
 	{
 	  tree fndecl2 = get_callee_fndecl (argarray[n - 1]);
-	  if (fndecl2
-	      && TREE_CODE (fndecl2) == FUNCTION_DECL
-	      && DECL_BUILT_IN_CLASS (fndecl2) == BUILT_IN_NORMAL
-	      && DECL_FUNCTION_CODE (fndecl2) == BUILT_IN_VA_ARG_PACK)
+	  if (DECL_NORMAL_BUILT_IN_P (fndecl2, BUILT_IN_VA_ARG_PACK))
 	    return NULL_TREE;
 	}
       if (avoid_folding_inline_builtin (fndecl))
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 5ad4f57a4fe..885efda172e 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -9168,9 +9168,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
 					      expr.value, exprlist,
 					      sizeof_arg,
 					      sizeof_ptr_memacc_comptypes);
-	  if (TREE_CODE (expr.value) == FUNCTION_DECL
-	      && DECL_BUILT_IN_CLASS (expr.value) == BUILT_IN_NORMAL
-	      && DECL_FUNCTION_CODE (expr.value) == BUILT_IN_MEMSET
+	  if (DECL_NORMAL_BUILT_IN_P (expr.value, BUILT_IN_MEMSET)
 	      && vec_safe_length (exprlist) == 3)
 	    {
 	      tree arg0 = (*exprlist)[0];
@@ -9187,9 +9185,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
 
 	  expr.original_code = ERROR_MARK;
 	  if (TREE_CODE (expr.value) == INTEGER_CST
-	      && TREE_CODE (orig_expr.value) == FUNCTION_DECL
-	      && DECL_BUILT_IN_CLASS (orig_expr.value) == BUILT_IN_NORMAL
-	      && DECL_FUNCTION_CODE (orig_expr.value) == BUILT_IN_CONSTANT_P)
+	      && DECL_NORMAL_BUILT_IN_P (orig_expr.value, BUILT_IN_CONSTANT_P))
 	    expr.original_code = C_MAYBE_CONST_EXPR;
 	  expr.original_type = NULL;
 	  if (exprlist)
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index d19f1aacab8..b3a1dd7d85d 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1559,8 +1559,8 @@ cgraph_update_edges_for_call_stmt_node (cgraph_node *node,
 	{
 	  /* Keep calls marked as dead dead.  */
 	  if (new_stmt && is_gimple_call (new_stmt) && e->callee
-	      && DECL_BUILT_IN_CLASS (e->callee->decl) == BUILT_IN_NORMAL
-	      && DECL_FUNCTION_CODE (e->callee->decl) == BUILT_IN_UNREACHABLE)
+	      && DECL_NORMAL_BUILT_IN_P (e->callee->decl,
+					 BUILT_IN_UNREACHABLE))
 	    {
               node->get_edge (old_stmt)->set_call_stmt
 		 (as_a <gcall *> (new_stmt));
@@ -3060,8 +3060,8 @@ cgraph_edge::verify_corresponds_to_fndecl (tree decl)
 
   /* Optimizers can redirect unreachable calls or calls triggering undefined
      behavior to builtin_unreachable.  */
-  if (DECL_BUILT_IN_CLASS (callee->decl) == BUILT_IN_NORMAL
-      && DECL_FUNCTION_CODE (callee->decl) == BUILT_IN_UNREACHABLE)
+
+  if (DECL_NORMAL_BUILT_IN_P (callee->decl, BUILT_IN_UNREACHABLE))
     return false;
 
   if (callee->former_clone_of != node->decl
@@ -3186,9 +3186,8 @@ cgraph_node::verify_node (void)
 	  && !e->speculative
 	  /* Optimized out calls are redirected to __builtin_unreachable.  */
 	  && (e->count.nonzero_p ()
-	      || ! e->callee->decl
-	      || DECL_BUILT_IN_CLASS (e->callee->decl) != BUILT_IN_NORMAL
-	      || DECL_FUNCTION_CODE (e->callee->decl) != BUILT_IN_UNREACHABLE)
+	      || !DECL_NORMAL_BUILT_IN_P (e->callee->decl,
+					  BUILT_IN_UNREACHABLE))
 	  && count
 	      == ENTRY_BLOCK_PTR_FOR_FN (DECL_STRUCT_FUNCTION (decl))->count
 	  && (!e->count.ipa_p ()
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index 6e84a31c1a5..ed353d2c060 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -482,8 +482,7 @@ cgraph_node::create_clone (tree new_decl, profile_count prof_count,
 	 version.  The only exception is when the edge was proved to
 	 be unreachable during the clonning procedure.  */
       if (!e->callee
-	  || DECL_BUILT_IN_CLASS (e->callee->decl) != BUILT_IN_NORMAL
-	  || DECL_FUNCTION_CODE (e->callee->decl) != BUILT_IN_UNREACHABLE)
+	  || !DECL_NORMAL_BUILT_IN_P (e->callee->decl, BUILT_IN_UNREACHABLE))
         e->redirect_callee_duplicating_thunks (new_node);
     }
   new_node->expand_all_artificial_thunks ();
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index ece2c8a92d9..c41ca019c14 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -712,9 +712,7 @@ constexpr_fn_retval (tree body)
     case CALL_EXPR:
 	{
 	  tree fun = get_function_named_in_call (body);
-	  if (fun != NULL_TREE
-	      && DECL_BUILT_IN_CLASS (fun) == BUILT_IN_NORMAL
-	      && DECL_FUNCTION_CODE (fun) == BUILT_IN_UNREACHABLE)
+	  if (DECL_NORMAL_BUILT_IN_P (fun, BUILT_IN_UNREACHABLE))
 	    return NULL_TREE;
 	}
       /* Fallthru.  */
@@ -1189,8 +1187,7 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun,
 
   /* For __builtin_is_constant_evaluated, defer it if not
      ctx->pretend_const_required, otherwise fold it to true.  */
-  if (DECL_BUILT_IN_CLASS (fun) == BUILT_IN_FRONTEND
-      && (int) DECL_FUNCTION_CODE (fun) == CP_BUILT_IN_IS_CONSTANT_EVALUATED)
+  if (DECL_FE_BUILT_IN_P (fun, CP_BUILT_IN_IS_CONSTANT_EVALUATED))
     {
       if (!ctx->pretend_const_required)
 	{
@@ -1233,8 +1230,7 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun,
 	  /* Do not allow__builtin_unreachable in constexpr function.
 	     The __builtin_unreachable call with BUILTINS_LOCATION
 	     comes from cp_maybe_instrument_return.  */
-	  if (DECL_BUILT_IN_CLASS (fun) == BUILT_IN_NORMAL
-	      && DECL_FUNCTION_CODE (fun) == BUILT_IN_UNREACHABLE
+	  if (DECL_NORMAL_BUILT_IN_P (fun, BUILT_IN_UNREACHABLE)
 	      && EXPR_LOCATION (t) == BUILTINS_LOCATION)
 	    error ("%<constexpr%> call flows off the end of the function");
 	  else
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 7db4accb504..bd6acc9523f 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -796,10 +796,7 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
       if (ret != GS_ERROR)
 	{
 	  tree decl = cp_get_callee_fndecl_nofold (*expr_p);
-	  if (decl
-	      && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_FRONTEND
-	      && ((int) DECL_FUNCTION_CODE (decl)
-		  == CP_BUILT_IN_IS_CONSTANT_EVALUATED))
+	  if (DECL_FE_BUILT_IN_P (decl, CP_BUILT_IN_IS_CONSTANT_EVALUATED))
 	    *expr_p = boolean_false_node;
 	}
       break;
@@ -2493,10 +2490,7 @@ cp_fold (tree x)
 	  nw = 1;
 
 	/* Defer folding __builtin_is_constant_evaluated.  */
-	if (callee
-	    && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_FRONTEND
-	    && ((int) DECL_FUNCTION_CODE (callee)
-		== CP_BUILT_IN_IS_CONSTANT_EVALUATED))
+	if (DECL_FE_BUILT_IN_P (callee,  CP_BUILT_IN_IS_CONSTANT_EVALUATED))
 	  break;
 
 	x = copy_node (x);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index bfdca5024d3..e3bafe58e4a 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2545,9 +2545,7 @@ finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual,
 	    }
 
 	  if ((complain & tf_warning)
-	      && TREE_CODE (fn) == FUNCTION_DECL
-	      && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
-	      && DECL_FUNCTION_CODE (fn) == BUILT_IN_MEMSET
+	      && DECL_NORMAL_BUILT_IN_P (fn, BUILT_IN_MEMSET)
 	      && vec_safe_length (*args) == 3
 	      && !any_type_dependent_arguments_p (*args))
 	    {
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 1cf3269d880..48508a17c1d 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -420,9 +420,7 @@ builtin_valid_in_constant_expr_p (const_tree decl)
     return false;
   if (DECL_BUILT_IN_CLASS (decl) != BUILT_IN_NORMAL)
     {
-      if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_FRONTEND
-	  && ((int) DECL_FUNCTION_CODE (decl)
-	      == CP_BUILT_IN_IS_CONSTANT_EVALUATED))
+      if (DECL_FE_BUILT_IN_P (decl, CP_BUILT_IN_IS_CONSTANT_EVALUATED))
 	return true;
       /* Not a built-in.  */
       return false;
diff --git a/gcc/dse.c b/gcc/dse.c
index 26c6007b9ed..228cb8606da 100644
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -2418,9 +2418,7 @@ scan_insn (bb_info_t bb_info, rtx_insn *insn)
 	  && (sym = XEXP (XEXP (call, 0), 0))
 	  && GET_CODE (sym) == SYMBOL_REF
 	  && SYMBOL_REF_DECL (sym)
-	  && TREE_CODE (SYMBOL_REF_DECL (sym)) == FUNCTION_DECL
-	  && DECL_BUILT_IN_CLASS (SYMBOL_REF_DECL (sym)) == BUILT_IN_NORMAL
-	  && DECL_FUNCTION_CODE (SYMBOL_REF_DECL (sym)) == BUILT_IN_MEMSET)
+	  && DECL_NORMAL_BUILT_IN_P (SYMBOL_REF_DECL (sym), BUILT_IN_MEMSET))
 	memset_call = SYMBOL_REF_DECL (sym);
 
       if (const_call || memset_call)
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index b318fc7705f..a9c48fbad81 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -10752,9 +10752,7 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type,
 	{
 	  tree fndecl = get_callee_fndecl (arg0);
 
-	  if (fndecl
-	      && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
-	      && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_STRLEN
+	  if (DECL_NORMAL_BUILT_IN_P (fndecl, BUILT_IN_STRLEN)
 	      && call_expr_nargs (arg0) == 1
 	      && TREE_CODE (TREE_TYPE (CALL_EXPR_ARG (arg0, 0))) == POINTER_TYPE)
 	    {
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index d3c5ec6f79b..e2eb0cdab0b 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -910,9 +910,7 @@ dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc,
     fn = TREE_OPERAND (fn, 0);
   if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
     pp_string (buffer, " [tm-clone]");
-  if (TREE_CODE (fn) == FUNCTION_DECL
-      && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
-      && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
+  if (DECL_NORMAL_BUILT_IN_P (fn, BUILT_IN_TM_START)
       && gimple_call_num_args (gs) > 0)
     {
       tree t = gimple_call_arg (gs, 0);
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 8d56a966cc1..a90551b420a 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -2681,8 +2681,7 @@ gimple_call_builtin_p (const gimple *stmt, enum built_in_function code)
   tree fndecl;
   if (is_gimple_call (stmt)
       && (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE
-      && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL 
-      && DECL_FUNCTION_CODE (fndecl) == code)
+      && DECL_NORMAL_BUILT_IN_P (fndecl, code))
     return gimple_builtin_call_types_compatible_p (stmt, fndecl);
   return false;
 }
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 4a109aee27a..ed62241d823 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -3295,10 +3295,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value)
       tree last_arg = CALL_EXPR_ARG (*expr_p, nargs - 1);
       tree last_arg_fndecl = get_callee_fndecl (last_arg);
 
-      if (last_arg_fndecl
-	  && TREE_CODE (last_arg_fndecl) == FUNCTION_DECL
-	  && DECL_BUILT_IN_CLASS (last_arg_fndecl) == BUILT_IN_NORMAL
-	  && DECL_FUNCTION_CODE (last_arg_fndecl) == BUILT_IN_VA_ARG_PACK)
+      if (DECL_NORMAL_BUILT_IN_P (last_arg_fndecl, BUILT_IN_VA_ARG_PACK))
 	{
 	  tree call = *expr_p;
 
@@ -3771,9 +3768,7 @@ gimple_boolify (tree expr)
 
       /* For __builtin_expect ((long) (x), y) recurse into x as well
 	 if x is truth_value_p.  */
-      if (fn
-	  && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
-	  && DECL_FUNCTION_CODE (fn) == BUILT_IN_EXPECT
+      if (DECL_NORMAL_BUILT_IN_P (fn, BUILT_IN_EXPECT)
 	  && call_expr_nargs (call) == 2)
 	{
 	  tree arg = CALL_EXPR_ARG (call, 0);
@@ -5717,9 +5712,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 	  CALL_EXPR_FN (*from_p) = TREE_OPERAND (CALL_EXPR_FN (*from_p), 0);
 	  STRIP_USELESS_TYPE_CONVERSION (CALL_EXPR_FN (*from_p));
 	  tree fndecl = get_callee_fndecl (*from_p);
-	  if (fndecl
-	      && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
-	      && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT
+	  if (DECL_NORMAL_BUILT_IN_P (fndecl, BUILT_IN_EXPECT)
 	      && call_expr_nargs (*from_p) == 3)
 	    call_stmt = gimple_build_call_internal (IFN_BUILTIN_EXPECT, 3,
 						    CALL_EXPR_ARG (*from_p, 0),
diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c
index a8fc2c2df9a..8c4e3a48ae4 100644
--- a/gcc/ipa-fnsummary.c
+++ b/gcc/ipa-fnsummary.c
@@ -2455,10 +2455,8 @@ compute_fn_summary (struct cgraph_node *node, bool early)
 	       for (e = node->callees; e; e = e->next_callee)
 		 {
 		   tree cdecl = e->callee->decl;
-		   if (DECL_BUILT_IN (cdecl)
-		       && DECL_BUILT_IN_CLASS (cdecl) == BUILT_IN_NORMAL
-		       && (DECL_FUNCTION_CODE (cdecl) == BUILT_IN_APPLY_ARGS
-			   || DECL_FUNCTION_CODE (cdecl) == BUILT_IN_VA_START))
+		   if (DECL_NORMAL_BUILT_IN_P (cdecl, BUILT_IN_APPLY_ARGS)
+		       || DECL_NORMAL_BUILT_IN_P (cdecl, BUILT_IN_VA_START))
 		     break;
 		 }
 	       node->local.can_change_signature = !e;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 843c66fd221..8aa72c1092f 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2975,9 +2975,8 @@ scan_omp_1_op (tree *tp, int *walk_subtrees, void *data)
 static bool
 setjmp_or_longjmp_p (const_tree fndecl)
 {
-  if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
-      && (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_SETJMP
-	  || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_LONGJMP))
+  if (DECL_NORMAL_BUILT_IN_P (fndecl, BUILT_IN_SETJMP)
+      || DECL_NORMAL_BUILT_IN_P (fndecl, BUILT_IN_LONGJMP))
     return true;
 
   tree declname = DECL_NAME (fndecl);
diff --git a/gcc/predict.c b/gcc/predict.c
index 3fbe3b704b3..7d511717fa8 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -3991,10 +3991,10 @@ strip_predict_hints (function *fun, bool early)
 	      tree fndecl = gimple_call_fndecl (stmt);
 
 	      if (!early
-		  && ((DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL, BUILT_IN_EXPECT)
+		  && ((DECL_NORMAL_BUILT_IN_P (fndecl, BUILT_IN_EXPECT)
 		       && gimple_call_num_args (stmt) == 2)
-		      || (DECL_BUILT_IN_P (fndecl, BUILT_IN_NORMAL,
-					   BUILT_IN_EXPECT_WITH_PROBABILITY)
+		      || (DECL_NORMAL_BUILT_IN_P (fndecl,
+						  BUILT_IN_EXPECT_WITH_PROBABILITY)
 			  && gimple_call_num_args (stmt) == 3)
 		      || (gimple_call_internal_p (stmt)
 			  && gimple_call_internal_fn (stmt) == IFN_BUILTIN_EXPECT)))
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index ca14915ef0d..b171bf91366 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -234,9 +234,7 @@ is_tm_irrevocable (tree x)
      irrevocable.  */
   if (TREE_CODE (x) == ADDR_EXPR)
     x = TREE_OPERAND (x, 0);
-  if (TREE_CODE (x) == FUNCTION_DECL
-      && DECL_BUILT_IN_CLASS (x) == BUILT_IN_NORMAL
-      && DECL_FUNCTION_CODE (x) == BUILT_IN_TM_IRREVOCABLE)
+  if (DECL_NORMAL_BUILT_IN_P (x, BUILT_IN_TM_IRREVOCABLE))
     return true;
 
   return false;
@@ -440,9 +438,7 @@ is_tm_simple_store (gimple *stmt)
 static bool
 is_tm_abort (tree fndecl)
 {
-  return (fndecl
-	  && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
-	  && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_TM_ABORT);
+  return DECL_NORMAL_BUILT_IN_P (fndecl, BUILT_IN_TM_ABORT);
 }
 
 /* Build a GENERIC tree for a user abort.  This is called by front ends
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 14d66b7a728..74adc39f475 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -8312,8 +8312,7 @@ stmt_can_terminate_bb_p (gimple *t)
          wrapping it in __gcov_fork() which calls __gcov_flush()
 	 and clears the counters before forking has the same
 	 effect as returning twice.  Force a fake edge.  */
-      && !(DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
-	   && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_FORK))
+      && !DECL_NORMAL_BUILT_IN_P (fndecl, BUILT_IN_FORK))
     return false;
 
   if (is_gimple_call (t))
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 6a16ce546cb..cfad4d909c6 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1939,8 +1939,8 @@ copy_bb (copy_body_data *id, basic_block bb,
 	  else if (call_stmt
 		   && id->call_stmt
 		   && (decl = gimple_call_fndecl (stmt))
-		   && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
-		   && DECL_FUNCTION_CODE (decl) == BUILT_IN_VA_ARG_PACK_LEN
+		   && DECL_NORMAL_BUILT_IN_P (decl,
+					      BUILT_IN_VA_ARG_PACK_LEN)
 		   && ! gimple_call_va_arg_pack_p (id->call_stmt))
 	    {
 	      /* __builtin_va_arg_pack_len () should be replaced by
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 3e30f6bc3d4..03ec5e092cd 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1498,8 +1498,8 @@ scan_function (void)
 
 		  if (dest)
 		    {
-		      if (DECL_BUILT_IN_CLASS (dest) == BUILT_IN_NORMAL
-			  && DECL_FUNCTION_CODE (dest) == BUILT_IN_APPLY_ARGS)
+		      if (DECL_NORMAL_BUILT_IN_P (dest,
+						  BUILT_IN_APPLY_ARGS))
 			encountered_apply_args = true;
 		      if (recursive_call_p (current_function_decl, dest))
 			{
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 63c95318ace..e657c26cbfa 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -2596,9 +2596,7 @@ optimize_stack_restore (gimple_stmt_iterator i)
       if (is_gimple_call (stack_save))
 	{
 	  callee = gimple_call_fndecl (stack_save);
-	  if (callee
-	      && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL
-	      && DECL_FUNCTION_CODE (callee) == BUILT_IN_STACK_SAVE)
+	  if (DECL_NORMAL_BUILT_IN_P (callee, BUILT_IN_STACK_SAVE))
 	    {
 	      gimple_stmt_iterator stack_save_gsi;
 	      tree rhs;
@@ -3369,9 +3367,7 @@ pass_fold_builtins::execute (function *fun)
 	      continue;
 	    }
 	  callee = gimple_call_fndecl (stmt);
-	  if (!callee
-              || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL
-	      || DECL_FUNCTION_CODE (callee) == fcode)
+	  if (!DECL_NORMAL_BUILT_IN_P (callee, fcode))
 	    gsi_next (&i);
 	}
     }
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 267880f3b5c..e015e1db635 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1985,9 +1985,7 @@ dom_opt_dom_walker::optimize_stmt (basic_block bb, gimple_stmt_iterator si)
 	     folded to integer_one_node by now, it's fairly
 	     certain that the value simply isn't constant.  */
 	  tree callee = gimple_call_fndecl (stmt);
-	  if (callee
-	      && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL
-	      && DECL_FUNCTION_CODE (callee) == BUILT_IN_CONSTANT_P)
+	  if (DECL_NORMAL_BUILT_IN_P (callee, BUILT_IN_CONSTANT_P))
 	    {
 	      propagate_tree_value_into_stmt (&si, integer_zero_node);
 	      stmt = gsi_stmt (si);
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 01a954eeb1e..d03fc5786e6 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -471,9 +471,7 @@ stmt_cost (gimple *stmt)
       /* Unless the call is a builtin_constant_p; this always folds to a
 	 constant, so moving it is useless.  */
       fndecl = gimple_call_fndecl (stmt);
-      if (fndecl
-	  && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
-	  && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CONSTANT_P)
+      if (DECL_NORMAL_BUILT_IN_P (fndecl, BUILT_IN_CONSTANT_P))
 	return 0;
 
       return LIM_EXPENSIVE;
diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c
index c8594851957..734f5c31c2f 100644
--- a/gcc/tree-stdarg.c
+++ b/gcc/tree-stdarg.c
@@ -866,10 +866,8 @@ optimize_va_list_gpr_fpr_size (function *fun)
 	    {
 	      tree callee = gimple_call_fndecl (stmt);
 
-	      if (callee
-		  && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL
-		  && (DECL_FUNCTION_CODE (callee) == BUILT_IN_VA_START
-		      || DECL_FUNCTION_CODE (callee) == BUILT_IN_VA_END))
+	      if (DECL_NORMAL_BUILT_IN_P (callee, BUILT_IN_VA_START)
+		  || DECL_NORMAL_BUILT_IN_P (callee, BUILT_IN_VA_END))
 		continue;
 	    }
 
diff --git a/gcc/tree.h b/gcc/tree.h
index 648e9e2a3c4..a7959eaaaeb 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -3011,9 +3011,21 @@ extern vec<tree, va_gc> **decl_debug_args_insert (tree);
 /* For a function declaration, return true if NODE is non-null and it is
    a builtin of a CLASS with requested NAME.  */
 #define DECL_BUILT_IN_P(NODE, CLASS, NAME) \
-  (NODE != NULL_TREE && DECL_BUILT_IN_CLASS (NODE) == CLASS \
+  (NODE != NULL_TREE \
+   && TREE_CODE (NODE) == FUNCTION_DECL \
+   && DECL_BUILT_IN_CLASS (NODE) == CLASS \
    && DECL_FUNCTION_CODE (NODE) == NAME)
 
+/* For a function declaration, return true if NODE is non-null and it is
+   a builtin of a BUILT_IN_NORMAL class with requested NAME.  */
+#define DECL_NORMAL_BUILT_IN_P(NODE, NAME) \
+  DECL_BUILT_IN_P (NODE, BUILT_IN_NORMAL, NAME)
+
+/* For a function declaration, return true if NODE is non-null and it is
+   a builtin of a BUILT_IN_FRONTEND class with requested NAME.  */
+#define DECL_FE_BUILT_IN_P(NODE, NAME) \
+  DECL_BUILT_IN_P (NODE, BUILT_IN_FRONTEND, NAME)
+
 /* In FUNCTION_DECL, a chain of ..._DECL nodes.  */
 #define DECL_ARGUMENTS(NODE) \
    (FUNCTION_DECL_CHECK (NODE)->function_decl.arguments)
-- 
2.18.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]