public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
Subject: [PATCH 01/14] ada: use _P() defines from tree.h
Date: Sun, 14 May 2023 01:23:08 +0200	[thread overview]
Message-ID: <20230513232321.279733-2-rep.dot.nop@gmail.com> (raw)
In-Reply-To: <20230513232321.279733-1-rep.dot.nop@gmail.com>

From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>

gcc/ada/ChangeLog:

	* gcc-interface/decl.cc (gnat_to_gnu_entity): Use _P defines
	from tree.h.
	(constructor_address_p): Ditto.
	(elaborate_expression_1): Ditto.
	* gcc-interface/trans.cc (Identifier_to_gnu): Ditto.
	(is_nrv_p): Ditto.
	(Subprogram_Body_to_gnu): Ditto.
	(gnat_to_gnu): Ditto.
	(gnat_to_gnu_external): Ditto.
	(add_decl_expr): Ditto.
	(gnat_gimplify_expr): Ditto.
	* gcc-interface/utils.cc (finish_record_type): Ditto.
	(create_var_decl): Ditto.
	* gcc-interface/utils2.cc (get_base_type): Ditto.
	(build_binary_op): Ditto.
	(build_unary_op): Ditto.
	(gnat_protect_expr): Ditto.
	(gnat_invariant_expr): Ditto.
---
 gcc/ada/gcc-interface/decl.cc   | 17 ++++++++---------
 gcc/ada/gcc-interface/trans.cc  | 20 ++++++++++----------
 gcc/ada/gcc-interface/utils.cc  | 10 +++++-----
 gcc/ada/gcc-interface/utils2.cc | 16 ++++++++--------
 4 files changed, 31 insertions(+), 32 deletions(-)

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 20f43de9ea9..ec61593a65b 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -785,7 +785,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	if ((TREE_CODE (gnu_type) == UNCONSTRAINED_ARRAY_TYPE
 	     && No (gnat_renamed_obj))
 	    || TYPE_IS_DUMMY_P (gnu_type)
-	    || TREE_CODE (gnu_type) == VOID_TYPE)
+	    || VOID_TYPE_P (gnu_type))
 	  {
 	    gcc_assert (type_annotate_only);
 	    if (this_global)
@@ -840,7 +840,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 		    if (TREE_CODE (gnu_expr) == COMPONENT_REF
 			&& TYPE_IS_PADDING_P
 			   (TREE_TYPE (TREE_OPERAND (gnu_expr, 0)))
-			&& TREE_CODE (TREE_OPERAND (gnu_expr, 0)) == VAR_DECL
+			&& VAR_P (TREE_OPERAND (gnu_expr, 0))
 			&& (TREE_READONLY (TREE_OPERAND (gnu_expr, 0))
 			    || DECL_READONLY_ONCE_ELAB
 			       (TREE_OPERAND (gnu_expr, 0))))
@@ -1077,7 +1077,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 		/* We need to detect the case where a temporary is created to
 		   hold the return value, since we cannot safely rename it at
 		   top level as it lives only in the elaboration routine.  */
-		|| (TREE_CODE (inner) == VAR_DECL
+		|| (VAR_P (inner)
 		    && DECL_RETURN_VALUE_P (inner))
 		/* We also need to detect the case where the front-end creates
 		   a dangling 'reference to a function call at top level and
@@ -1093,10 +1093,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 
 		   We cannot safely rename the rewritten expression since the
 		   underlying object lives only in the elaboration routine.  */
-		|| (TREE_CODE (inner) == INDIRECT_REF
+		|| (INDIRECT_REF_P (inner)
 		    && (inner
 			= remove_conversions (TREE_OPERAND (inner, 0), true))
-		    && TREE_CODE (inner) == VAR_DECL
+		    && VAR_P (inner)
 		    && DECL_RETURN_VALUE_P (inner)))
 	      ;
 
@@ -1611,7 +1611,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	   and optimization isn't enabled, then force it in memory so that
 	   a register won't be allocated to it with possible subparts left
 	   uninitialized and reaching the register allocator.  */
-	else if (TREE_CODE (gnu_decl) == VAR_DECL
+	else if (VAR_P (gnu_decl)
 		 && !DECL_EXTERNAL (gnu_decl)
 		 && !TREE_STATIC (gnu_decl)
 		 && DECL_MODE (gnu_decl) != BLKmode
@@ -6717,8 +6717,7 @@ range_cannot_be_superflat (Node_Id gnat_range)
 static bool
 constructor_address_p (tree gnu_expr)
 {
-  while (TREE_CODE (gnu_expr) == NOP_EXPR
-	 || TREE_CODE (gnu_expr) == CONVERT_EXPR
+  while (CONVERT_EXPR_P (gnu_expr)
 	 || TREE_CODE (gnu_expr) == NON_LVALUE_EXPR)
     gnu_expr = TREE_OPERAND (gnu_expr, 0);
 
@@ -7061,7 +7060,7 @@ elaborate_expression_1 (tree gnu_expr, Entity_Id gnat_entity, const char *s,
 
       expr_variable_p
 	= !(inner
-	    && TREE_CODE (inner) == VAR_DECL
+	    && VAR_P (inner)
 	    && (TREE_READONLY (inner) || DECL_READONLY_ONCE_ELAB (inner)));
     }
 
diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 5fc1a26fede..c26f1b6e1ac 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -1241,7 +1241,7 @@ Identifier_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p)
       /* Do the final dereference.  */
       gnu_result = build_unary_op (INDIRECT_REF, NULL_TREE, gnu_result);
 
-      if ((TREE_CODE (gnu_result) == INDIRECT_REF
+      if ((INDIRECT_REF_P (gnu_result)
 	   || TREE_CODE (gnu_result) == UNCONSTRAINED_ARRAY_REF)
 	  && No (Address_Clause (gnat_entity)))
 	TREE_THIS_NOTRAP (gnu_result) = 1;
@@ -3391,7 +3391,7 @@ struct nrv_data
 static inline bool
 is_nrv_p (bitmap nrv, tree t)
 {
-  return TREE_CODE (t) == VAR_DECL && bitmap_bit_p (nrv, DECL_UID (t));
+  return VAR_P (t) && bitmap_bit_p (nrv, DECL_UID (t));
 }
 
 /* Helper function for walk_tree, used by finalize_nrv below.  */
@@ -4136,7 +4136,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_node)
        gnat_param = Next_Formal_With_Extras (gnat_param))
     {
       tree gnu_param = get_gnu_tree (gnat_param);
-      bool is_var_decl = (TREE_CODE (gnu_param) == VAR_DECL);
+      bool is_var_decl = VAR_P (gnu_param);
 
       annotate_object (gnat_param, TREE_TYPE (gnu_param), NULL_TREE,
 		       DECL_BY_REF_P (gnu_param));
@@ -6908,7 +6908,7 @@ gnat_to_gnu (Node_Id gnat_node)
 	    && TYPE_CONTAINS_TEMPLATE_P (gnu_result_type))
 	  gnu_aggr_type
 	    = TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (gnu_result_type)));
-	else if (TREE_CODE (gnu_result_type) == VECTOR_TYPE)
+	else if (VECTOR_TYPE_P (gnu_result_type))
 	  gnu_aggr_type = TYPE_REPRESENTATIVE_ARRAY (gnu_result_type);
 	else
 	  gnu_aggr_type = gnu_result_type;
@@ -7740,7 +7740,7 @@ gnat_to_gnu (Node_Id gnat_node)
 		gnu_result = build2 (INIT_EXPR, void_type_node,
 				     gnu_ret_deref, gnu_ret_val);
 		/* Avoid a useless copy with __builtin_return_slot.  */
-		if (TREE_CODE (gnu_ret_val) == INDIRECT_REF)
+		if (INDIRECT_REF_P (gnu_ret_val))
 		  gnu_result
 		    = build3 (COND_EXPR, void_type_node,
 			      fold_build2 (NE_EXPR, boolean_type_node,
@@ -8415,7 +8415,7 @@ gnat_to_gnu (Node_Id gnat_node)
 
   /* If we're supposed to return something of void_type, it means we have
      something we're elaborating for effect, so just return.  */
-  if (TREE_CODE (gnu_result_type) == VOID_TYPE)
+  if (VOID_TYPE_P (gnu_result_type))
     return gnu_result;
 
   /* If the result is a constant that overflowed, raise Constraint_Error.  */
@@ -8588,7 +8588,7 @@ gnat_to_gnu_external (Node_Id gnat_node)
     current_function_decl = NULL_TREE;
 
   /* Do not import locations from external units.  */
-  if (gnu_result && EXPR_P (gnu_result))
+  if (CAN_HAVE_LOCATION_P (gnu_result))
     SET_EXPR_LOCATION (gnu_result, UNKNOWN_LOCATION);
 
   return gnu_result;
@@ -8722,7 +8722,7 @@ add_decl_expr (tree gnu_decl, Node_Id gnat_node)
 	 Note that walk_tree knows how to deal with TYPE_DECL, but neither
 	 VAR_DECL nor CONST_DECL.  This appears to be somewhat arbitrary.  */
       MARK_VISITED (gnu_stmt);
-      if (TREE_CODE (gnu_decl) == VAR_DECL
+      if (VAR_P (gnu_decl)
 	  || TREE_CODE (gnu_decl) == CONST_DECL)
 	{
 	  MARK_VISITED (DECL_SIZE (gnu_decl));
@@ -8739,7 +8739,7 @@ add_decl_expr (tree gnu_decl, Node_Id gnat_node)
       && !TYPE_FAT_POINTER_P (type))
     MARK_VISITED (TYPE_ADA_SIZE (type));
 
-  if (TREE_CODE (gnu_decl) == VAR_DECL && (gnu_init = DECL_INITIAL (gnu_decl)))
+  if (VAR_P (gnu_decl) && (gnu_init = DECL_INITIAL (gnu_decl)))
     {
       /* If this is a variable and an initializer is attached to it, it must be
 	 valid for the context.  Similar to init_const in create_var_decl.  */
@@ -9000,7 +9000,7 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p,
 
       /* The expressions for the RM bounds must be gimplified to ensure that
 	 they are properly elaborated.  See gimplify_decl_expr.  */
-      if ((TREE_CODE (op) == TYPE_DECL || TREE_CODE (op) == VAR_DECL)
+      if ((TREE_CODE (op) == TYPE_DECL || VAR_P (op))
 	  && !TYPE_SIZES_GIMPLIFIED (TREE_TYPE (op))
 	  && (INTEGRAL_TYPE_P (TREE_TYPE (op))
 	      || SCALAR_FLOAT_TYPE_P (TREE_TYPE (op))))
diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index 0c4f8b90c8e..460ef6f1f01 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -1966,7 +1966,7 @@ finish_record_type (tree record_type, tree field_list, int rep_level,
 		    bool debug_info_p)
 {
   const enum tree_code orig_code = TREE_CODE (record_type);
-  const bool had_size = TYPE_SIZE (record_type) != NULL_TREE;
+  const bool had_size = COMPLETE_TYPE_P (record_type);
   const bool had_align = TYPE_ALIGN (record_type) > 0;
   /* For all-repped records with a size specified, lay the QUAL_UNION_TYPE
      out just like a UNION_TYPE, since the size will be fixed.  */
@@ -2802,7 +2802,7 @@ create_var_decl (tree name, tree asm_name, tree type, tree init,
       if (TREE_CODE (inner) == ADDR_EXPR
 	  && ((TREE_CODE (TREE_OPERAND (inner, 0)) == CALL_EXPR
 	       && !call_is_atomic_load (TREE_OPERAND (inner, 0)))
-	      || (TREE_CODE (TREE_OPERAND (inner, 0)) == VAR_DECL
+	      || (VAR_P (TREE_OPERAND (inner, 0))
 		  && DECL_RETURN_VALUE_P (TREE_OPERAND (inner, 0)))))
 	DECL_RETURN_VALUE_P (var_decl) = 1;
     }
@@ -2853,7 +2853,7 @@ create_var_decl (tree name, tree asm_name, tree type, tree init,
      support global BSS sections, uninitialized global variables would
      go in DATA instead, thus increasing the size of the executable.  */
   if (!flag_no_common
-      && TREE_CODE (var_decl) == VAR_DECL
+      && VAR_P (var_decl)
       && TREE_PUBLIC (var_decl)
       && !have_global_bss_p ())
     DECL_COMMON (var_decl) = 1;
@@ -2871,13 +2871,13 @@ create_var_decl (tree name, tree asm_name, tree type, tree init,
     DECL_IGNORED_P (var_decl) = 1;
 
   /* ??? Some attributes cannot be applied to CONST_DECLs.  */
-  if (TREE_CODE (var_decl) == VAR_DECL)
+  if (VAR_P (var_decl))
     process_attributes (&var_decl, &attr_list, true, gnat_node);
 
   /* Add this decl to the current binding level.  */
   gnat_pushdecl (var_decl, gnat_node);
 
-  if (TREE_CODE (var_decl) == VAR_DECL && asm_name)
+  if (VAR_P (var_decl) && asm_name)
     {
       /* Let the target mangle the name if this isn't a verbatim asm.  */
       if (*IDENTIFIER_POINTER (asm_name) != '*')
diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc
index 6c17675f488..c56fccb4a98 100644
--- a/gcc/ada/gcc-interface/utils2.cc
+++ b/gcc/ada/gcc-interface/utils2.cc
@@ -68,7 +68,7 @@ get_base_type (tree type)
 
   while (TREE_TYPE (type)
 	 && (TREE_CODE (type) == INTEGER_TYPE
-	     || TREE_CODE (type) == REAL_TYPE))
+	     || SCALAR_FLOAT_TYPE_P (type)))
     type = TREE_TYPE (type);
 
   return type;
@@ -986,7 +986,7 @@ build_binary_op (enum tree_code op_code, tree result_type,
 	    break;
 	}
 
-      gcc_assert (TREE_CODE (result) == INDIRECT_REF
+      gcc_assert (INDIRECT_REF_P (result)
 		  || TREE_CODE (result) == NULL_EXPR
 		  || TREE_CODE (result) == SAVE_EXPR
 		  || DECL_P (result));
@@ -1423,7 +1423,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
 	     the corresponding address, e.g. for an allocator.  However do
 	     it for a return value to expose it for later recognition.  */
 	  if (TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE
-	      || (TREE_CODE (TREE_OPERAND (operand, 1)) == VAR_DECL
+	      || (VAR_P (TREE_OPERAND (operand, 1))
 		  && DECL_RETURN_VALUE_P (TREE_OPERAND (operand, 1))))
 	    {
 	      result = build_unary_op (ADDR_EXPR, result_type,
@@ -1597,11 +1597,11 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
 	if (!TYPE_IS_FAT_POINTER_P (type) && TYPE_VOLATILE (TREE_TYPE (type)))
 	  {
 	    TREE_SIDE_EFFECTS (result) = 1;
-	    if (TREE_CODE (result) == INDIRECT_REF)
+	    if (INDIRECT_REF_P (result))
 	      TREE_THIS_VOLATILE (result) = TYPE_VOLATILE (TREE_TYPE (result));
 	  }
 
-	if ((TREE_CODE (result) == INDIRECT_REF
+	if ((INDIRECT_REF_P (result)
 	     || TREE_CODE (result) == UNCONSTRAINED_ARRAY_REF)
 	    && can_never_be_null)
 	  TREE_THIS_NOTRAP (result) = 1;
@@ -2926,7 +2926,7 @@ gnat_protect_expr (tree exp)
 
   /* Likewise if we're indirectly referencing part of something.  */
   if (code == COMPONENT_REF
-      && TREE_CODE (TREE_OPERAND (exp, 0)) == INDIRECT_REF)
+      && INDIRECT_REF_P (TREE_OPERAND (exp, 0)))
     return build3 (code, type, gnat_protect_expr (TREE_OPERAND (exp, 0)),
 		   TREE_OPERAND (exp, 1), NULL_TREE);
 
@@ -3263,7 +3263,7 @@ gnat_invariant_expr (tree expr)
 
   /* Look through temporaries created to capture values.  */
   while ((TREE_CODE (expr) == CONST_DECL
-	  || (TREE_CODE (expr) == VAR_DECL && TREE_READONLY (expr)))
+	  || (VAR_P (expr) && TREE_READONLY (expr)))
 	 && decl_function_context (expr) == current_function_decl
 	 && DECL_INITIAL (expr))
     {
@@ -3362,7 +3362,7 @@ object:
   if (TREE_CODE (t) == PARM_DECL)
     return fold_convert (type, expr);
 
-  if (TREE_CODE (t) == VAR_DECL
+  if (VAR_P (t)
       && (DECL_EXTERNAL (t)
 	  || decl_function_context (t) != current_function_decl))
     return fold_convert (type, expr);
-- 
2.30.2


  reply	other threads:[~2023-05-13 23:23 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-13 23:23 [PATCH 00/14] " Bernhard Reutner-Fischer
2023-05-13 23:23 ` Bernhard Reutner-Fischer [this message]
2023-05-14 23:03   ` [PATCH 01/14] ada: " Jeff Law
2023-05-18 19:59     ` Bernhard Reutner-Fischer
2023-05-15 10:05   ` Eric Botcazou
2023-05-18 19:53     ` Bernhard Reutner-Fischer
2023-05-13 23:23 ` [PATCH 02/14] analyzer: " Bernhard Reutner-Fischer
2023-05-13 23:23 ` [PATCH 03/14] gcc/config/*: " Bernhard Reutner-Fischer
2023-05-14  8:21   ` Iain Sandoe
2023-05-15  7:46     ` Richard Biener
2023-05-13 23:23 ` [PATCH 04/14] c++: " Bernhard Reutner-Fischer
2023-06-01 15:24   ` Patrick Palka
2023-06-01 16:33     ` Bernhard Reutner-Fischer
2023-06-01 18:10       ` Bernhard Reutner-Fischer
2023-08-02 16:51         ` Patrick Palka
2023-08-08 20:31           ` Jason Merrill
2023-11-15 17:42             ` Bernhard Reutner-Fischer
2023-05-13 23:23 ` [PATCH 05/14] m2: " Bernhard Reutner-Fischer
2023-05-14  1:44   ` Gaius Mulley
2023-05-14  1:47   ` Gaius Mulley
2023-05-13 23:23 ` [PATCH 06/14] lto: " Bernhard Reutner-Fischer
2023-05-15  7:45   ` Richard Biener
2023-05-13 23:23 ` [PATCH 07/14] d: " Bernhard Reutner-Fischer
2023-05-13 23:23 ` [PATCH 08/14] fortran: " Bernhard Reutner-Fischer
2023-05-14 13:10   ` Mikael Morin
2023-05-18 15:18     ` Bernhard Reutner-Fischer
2023-05-18 19:20       ` Mikael Morin
2023-05-19 19:19         ` Bernhard Reutner-Fischer
2023-05-13 23:23 ` [PATCH 09/14] rust: " Bernhard Reutner-Fischer
2023-05-13 23:23 ` [PATCH 10/14] c: " Bernhard Reutner-Fischer
2023-05-13 23:23 ` [PATCH 11/14] objc: " Bernhard Reutner-Fischer
2023-05-14  8:13   ` Iain Sandoe
2023-05-13 23:23 ` [PATCH 12/14] go: " Bernhard Reutner-Fischer
2023-05-13 23:23 ` [PATCH 13/14] omp: " Bernhard Reutner-Fischer
2023-05-13 23:23 ` [PATCH 14/14] gcc: " Bernhard Reutner-Fischer
2023-05-15  7:45   ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230513232321.279733-2-rep.dot.nop@gmail.com \
    --to=rep.dot.nop@gmail.com \
    --cc=aldot@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).