public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-2166] final+varasm: Change return type of predicate functions from int to bool
@ 2023-06-28 14:31 Uros Bizjak
  0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2023-06-28 14:31 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:8719ab0d01d5a73767e34f88691c812db03e1449

commit r14-2166-g8719ab0d01d5a73767e34f88691c812db03e1449
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Wed Jun 28 10:22:20 2023 +0200

    final+varasm: Change return type of predicate functions from int to bool
    
    Also change some internal variables to bool and change return type of
    compute_alignments to void.
    
    gcc/ChangeLog:
    
            * output.h (leaf_function_p): Change return type from int to bool.
            (final_forward_branch_p): Ditto.
            (only_leaf_regs_used): Ditto.
            (maybe_assemble_visibility): Ditto.
            * varasm.h (supports_one_only): Ditto.
            * rtl.h (compute_alignments): Change return type from int to void.
            * final.cc (app_on): Change return type from int to bool.
            (compute_alignments): Change return type from int to void
            and adjust function body accordingly.
            (shorten_branches):  Change "something_changed" variable
            type from int to bool.
            (leaf_function_p):  Change return type from int to bool
            and adjust function body accordingly.
            (final_forward_branch_p): Ditto.
            (only_leaf_regs_used): Ditto.
            * varasm.cc (contains_pointers_p): Change return type from
            int to bool and adjust function body accordingly.
            (compare_constant): Ditto.
            (maybe_assemble_visibility): Ditto.
            (supports_one_only): Ditto.

Diff:
---
 gcc/final.cc  | 50 +++++++++++++++----------------
 gcc/output.h  | 14 ++++-----
 gcc/rtl.h     |  2 +-
 gcc/varasm.cc | 96 ++++++++++++++++++++++++++++++-----------------------------
 gcc/varasm.h  |  2 +-
 5 files changed, 83 insertions(+), 81 deletions(-)

diff --git a/gcc/final.cc b/gcc/final.cc
index e614491a69a..dd3e22547ac 100644
--- a/gcc/final.cc
+++ b/gcc/final.cc
@@ -163,9 +163,9 @@ static int insn_counter = 0;
 
 static int block_depth;
 
-/* Nonzero if have enabled APP processing of our assembler output.  */
+/* True if have enabled APP processing of our assembler output.  */
 
-static int app_on;
+static bool app_on;
 
 /* If we are outputting an insn sequence, this contains the sequence rtx.
    Zero otherwise.  */
@@ -603,7 +603,7 @@ insn_current_reference_address (rtx_insn *branch)
 \f
 /* Compute branch alignments based on CFG profile.  */
 
-unsigned int
+void
 compute_alignments (void)
 {
   basic_block bb;
@@ -617,7 +617,7 @@ compute_alignments (void)
 
   /* If not optimizing or optimizing for size, don't assign any alignments.  */
   if (! optimize || optimize_function_for_size_p (cfun))
-    return 0;
+    return;
 
   if (dump_file)
     {
@@ -721,7 +721,6 @@ compute_alignments (void)
 
   loop_optimizer_finalize ();
   free_dominance_info (CDI_DOMINATORS);
-  return 0;
 }
 
 /* Grow the LABEL_ALIGN array after new labels are created.  */
@@ -790,7 +789,8 @@ public:
   /* opt_pass methods: */
   unsigned int execute (function *) final override
   {
-    return compute_alignments ();
+    compute_alignments ();
+    return 0;
   }
 
 }; // class pass_compute_alignments
@@ -822,7 +822,7 @@ shorten_branches (rtx_insn *first)
   int max_uid;
   int i;
   rtx_insn *seq;
-  int something_changed = 1;
+  bool something_changed = true;
   char *varying_length;
   rtx body;
   int uid;
@@ -1103,7 +1103,7 @@ shorten_branches (rtx_insn *first)
 
   while (something_changed)
     {
-      something_changed = 0;
+      something_changed = false;
       insn_current_align = MAX_CODE_ALIGN - 1;
       for (insn_current_address = 0, insn = first;
 	   insn != 0;
@@ -1136,7 +1136,7 @@ shorten_branches (rtx_insn *first)
 			{
 			  log = newlog;
 			  LABEL_TO_ALIGNMENT (insn) = log;
-			  something_changed = 1;
+			  something_changed = true;
 			}
 		    }
 		}
@@ -1274,7 +1274,7 @@ shorten_branches (rtx_insn *first)
 		       * GET_MODE_SIZE (table->get_data_mode ()));
 		  insn_current_address += insn_lengths[uid];
 		  if (insn_lengths[uid] != old_length)
-		    something_changed = 1;
+		    something_changed = true;
 		}
 
 	      continue;
@@ -1332,7 +1332,7 @@ shorten_branches (rtx_insn *first)
 		      if (!increasing || inner_length > insn_lengths[inner_uid])
 			{
 			  insn_lengths[inner_uid] = inner_length;
-			  something_changed = 1;
+			  something_changed = true;
 			}
 		      else
 			inner_length = insn_lengths[inner_uid];
@@ -1358,7 +1358,7 @@ shorten_branches (rtx_insn *first)
 	      && (!increasing || new_length > insn_lengths[uid]))
 	    {
 	      insn_lengths[uid] = new_length;
-	      something_changed = 1;
+	      something_changed = true;
 	    }
 	  else
 	    insn_current_address += insn_lengths[uid] - new_length;
@@ -4043,9 +4043,9 @@ asm_fprintf (FILE *file, const char *p, ...)
   va_end (argptr);
 }
 \f
-/* Return nonzero if this function has no function calls.  */
+/* Return true if this function has no function calls.  */
 
-int
+bool
 leaf_function_p (void)
 {
   rtx_insn *insn;
@@ -4056,29 +4056,29 @@ leaf_function_p (void)
   /* Some back-ends (e.g. s390) want leaf functions to stay leaf
      functions even if they call mcount.  */
   if (crtl->profile && !targetm.keep_leaf_when_profiled ())
-    return 0;
+    return false;
 
   for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
     {
       if (CALL_P (insn)
 	  && ! SIBLING_CALL_P (insn)
 	  && ! FAKE_CALL_P (insn))
-	return 0;
+	return false;
       if (NONJUMP_INSN_P (insn)
 	  && GET_CODE (PATTERN (insn)) == SEQUENCE
 	  && CALL_P (XVECEXP (PATTERN (insn), 0, 0))
 	  && ! SIBLING_CALL_P (XVECEXP (PATTERN (insn), 0, 0)))
-	return 0;
+	return false;
     }
 
-  return 1;
+  return true;
 }
 
-/* Return 1 if branch is a forward branch.
+/* Return true if branch is a forward branch.
    Uses insn_shuid array, so it works only in the final pass.  May be used by
    output templates to customary add branch prediction hints.
  */
-int
+bool
 final_forward_branch_p (rtx_insn *insn)
 {
   int insn_id, label_id;
@@ -4102,10 +4102,10 @@ final_forward_branch_p (rtx_insn *insn)
 
 #ifdef LEAF_REGISTERS
 
-/* Return 1 if this function uses only the registers that can be
+/* Return bool if this function uses only the registers that can be
    safely renumbered.  */
 
-int
+bool
 only_leaf_regs_used (void)
 {
   int i;
@@ -4114,15 +4114,15 @@ only_leaf_regs_used (void)
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
     if ((df_regs_ever_live_p (i) || global_regs[i])
 	&& ! permitted_reg_in_leaf_functions[i])
-      return 0;
+      return false;
 
   if (crtl->uses_pic_offset_table
       && pic_offset_table_rtx != 0
       && REG_P (pic_offset_table_rtx)
       && ! permitted_reg_in_leaf_functions[REGNO (pic_offset_table_rtx)])
-    return 0;
+    return false;
 
-  return 1;
+  return true;
 }
 
 /* Scan all instructions and renumber all registers into those
diff --git a/gcc/output.h b/gcc/output.h
index 877d2afa55b..76cfd58c1e6 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -128,17 +128,17 @@ extern int sprint_ul (char *, unsigned long);
 extern void asm_fprintf (FILE *file, const char *p, ...)
      ATTRIBUTE_ASM_FPRINTF(2, 3);
 
-/* Return nonzero if this function has no function calls.  */
-extern int leaf_function_p (void);
+/* Return true if this function has no function calls.  */
+extern bool leaf_function_p (void);
 
-/* Return 1 if branch is a forward branch.
+/* Return true if branch is a forward branch.
    Uses insn_shuid array, so it works only in the final pass.  May be used by
    output templates to add branch prediction hints, for example.  */
-extern int final_forward_branch_p (rtx_insn *);
+extern bool final_forward_branch_p (rtx_insn *);
 
-/* Return 1 if this function uses only the registers that can be
+/* Return true if this function uses only the registers that can be
    safely renumbered.  */
-extern int only_leaf_regs_used (void);
+extern bool only_leaf_regs_used (void);
 
 /* Scan IN_RTX and its subexpressions, and renumber all regs into those
    available in leaf functions.  */
@@ -621,7 +621,7 @@ extern void default_elf_internal_label (FILE *, const char *, unsigned long);
 
 extern void default_elf_init_array_asm_out_constructor (rtx, int);
 extern void default_elf_fini_array_asm_out_destructor (rtx, int);
-extern int maybe_assemble_visibility (tree);
+extern bool maybe_assemble_visibility (tree);
 
 extern int default_address_cost (rtx, machine_mode, addr_space_t, bool);
 
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 9c6803f043e..098dc4ccc1c 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -4508,7 +4508,7 @@ extern rtx canon_condition (rtx);
 extern void simplify_using_condition (rtx, rtx *, bitmap);
 
 /* In final.cc  */
-extern unsigned int compute_alignments (void);
+extern void compute_alignments (void);
 extern void update_alignments (vec<rtx> &);
 extern int asm_str_count (const char *templ);
 \f
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index 542315f88cd..8ae0a2555cd 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -102,13 +102,13 @@ bool first_function_block_is_cold;
 static bool saw_no_split_stack;
 
 static const char *strip_reg_name (const char *);
-static int contains_pointers_p (tree);
+static bool contains_pointers_p (tree);
 #ifdef ASM_OUTPUT_EXTERNAL
 static bool incorporeal_function_p (tree);
 #endif
 static void decode_addr_const (tree, class addr_const *);
 static hashval_t const_hash_1 (const tree);
-static int compare_constant (const tree, const tree);
+static bool compare_constant (const tree, const tree);
 static void output_constant_def_contents (rtx);
 static void output_addressed_constants (tree, int);
 static unsigned HOST_WIDE_INT output_constant (tree, unsigned HOST_WIDE_INT,
@@ -2419,9 +2419,9 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED,
     }
 }
 
-/* Return 1 if type TYPE contains any pointers.  */
+/* Return true if type TYPE contains any pointers.  */
 
-static int
+static bool
 contains_pointers_p (tree type)
 {
   switch (TREE_CODE (type))
@@ -2431,7 +2431,7 @@ contains_pointers_p (tree type)
       /* I'm not sure whether OFFSET_TYPE needs this treatment,
 	 so I'll play safe and return 1.  */
     case OFFSET_TYPE:
-      return 1;
+      return true;
 
     case RECORD_TYPE:
     case UNION_TYPE:
@@ -2442,8 +2442,8 @@ contains_pointers_p (tree type)
 	for (fields = TYPE_FIELDS (type); fields; fields = DECL_CHAIN (fields))
 	  if (TREE_CODE (fields) == FIELD_DECL
 	      && contains_pointers_p (TREE_TYPE (fields)))
-	    return 1;
-	return 0;
+	    return true;
+	return false;
       }
 
     case ARRAY_TYPE:
@@ -2451,7 +2451,7 @@ contains_pointers_p (tree type)
       return contains_pointers_p (TREE_TYPE (type));
 
     default:
-      return 0;
+      return false;
     }
 }
 
@@ -3206,14 +3206,14 @@ tree_descriptor_hasher::equal (constant_descriptor_tree *c1,
 			       constant_descriptor_tree *c2)
 {
   if (c1->hash != c2->hash)
-    return 0;
+    return false;
   return compare_constant (c1->value, c2->value);
 }
 
-/* Compare t1 and t2, and return 1 only if they are known to result in
+/* Compare t1 and t2, and return true only if they are known to result in
    the same bit pattern on output.  */
 
-static int
+static bool
 compare_constant (const tree t1, const tree t2)
 {
   enum tree_code typecode;
@@ -3221,19 +3221,19 @@ compare_constant (const tree t1, const tree t2)
   if (t1 == NULL_TREE)
     return t2 == NULL_TREE;
   if (t2 == NULL_TREE)
-    return 0;
+    return false;
 
   if (TREE_CODE (t1) != TREE_CODE (t2))
-    return 0;
+    return false;
 
   switch (TREE_CODE (t1))
     {
     case INTEGER_CST:
       /* Integer constants are the same only if the same width of type.  */
       if (TYPE_PRECISION (TREE_TYPE (t1)) != TYPE_PRECISION (TREE_TYPE (t2)))
-	return 0;
+	return false;
       if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2)))
-	return 0;
+	return false;
       return tree_int_cst_equal (t1, t2);
 
     case REAL_CST:
@@ -3244,15 +3244,15 @@ compare_constant (const tree t1, const tree t2)
 	 different 128-bit floating point types (IBM extended double and IEEE
 	 128-bit floating point).  */
       if (TYPE_PRECISION (TREE_TYPE (t1)) != TYPE_PRECISION (TREE_TYPE (t2)))
-	return 0;
+	return false;
       if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2)))
-	return 0;
+	return false;
       return real_identical (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2));
 
     case FIXED_CST:
       /* Fixed constants are the same only if the same width of type.  */
       if (TYPE_PRECISION (TREE_TYPE (t1)) != TYPE_PRECISION (TREE_TYPE (t2)))
-	return 0;
+	return false;
 
       return FIXED_VALUES_IDENTICAL (TREE_FIXED_CST (t1), TREE_FIXED_CST (t2));
 
@@ -3260,7 +3260,7 @@ compare_constant (const tree t1, const tree t2)
       if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2))
 	  || int_size_in_bytes (TREE_TYPE (t1))
 	     != int_size_in_bytes (TREE_TYPE (t2)))
-	return 0;
+	return false;
 
       return (TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
 	      && ! memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
@@ -3274,19 +3274,19 @@ compare_constant (const tree t1, const tree t2)
       {
 	if (VECTOR_CST_NPATTERNS (t1)
 	    != VECTOR_CST_NPATTERNS (t2))
-	  return 0;
+	  return false;
 
 	if (VECTOR_CST_NELTS_PER_PATTERN (t1)
 	    != VECTOR_CST_NELTS_PER_PATTERN (t2))
-	  return 0;
+	  return false;
 
 	unsigned int count = vector_cst_encoded_nelts (t1);
 	for (unsigned int i = 0; i < count; ++i)
 	  if (!compare_constant (VECTOR_CST_ENCODED_ELT (t1, i),
 				 VECTOR_CST_ENCODED_ELT (t2, i)))
-	    return 0;
+	    return false;
 
-	return 1;
+	return true;
       }
 
     case CONSTRUCTOR:
@@ -3296,7 +3296,7 @@ compare_constant (const tree t1, const tree t2)
 
 	typecode = TREE_CODE (TREE_TYPE (t1));
 	if (typecode != TREE_CODE (TREE_TYPE (t2)))
-	  return 0;
+	  return false;
 
 	if (typecode == ARRAY_TYPE)
 	  {
@@ -3307,20 +3307,20 @@ compare_constant (const tree t1, const tree t2)
 		|| size_1 != int_size_in_bytes (TREE_TYPE (t2))
 		|| TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (t1))
 		   != TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (t2)))
-	      return 0;
+	      return false;
 	  }
 	else
 	  {
 	    /* For record and union constructors, require exact type
                equality.  */
 	    if (TREE_TYPE (t1) != TREE_TYPE (t2))
-	      return 0;
+	      return false;
 	  }
 
 	v1 = CONSTRUCTOR_ELTS (t1);
 	v2 = CONSTRUCTOR_ELTS (t2);
 	if (vec_safe_length (v1) != vec_safe_length (v2))
-	  return 0;
+	  return false;
 
 	for (idx = 0; idx < vec_safe_length (v1); ++idx)
 	  {
@@ -3329,21 +3329,21 @@ compare_constant (const tree t1, const tree t2)
 
 	    /* Check that each value is the same...  */
 	    if (!compare_constant (c1->value, c2->value))
-	      return 0;
+	      return false;
 	    /* ... and that they apply to the same fields!  */
 	    if (typecode == ARRAY_TYPE)
 	      {
 		if (!compare_constant (c1->index, c2->index))
-		  return 0;
+		  return false;
 	      }
 	    else
 	      {
 		if (c1->index != c2->index)
-		  return 0;
+		  return false;
 	      }
 	  }
 
-	return 1;
+	return true;
       }
 
     case ADDR_EXPR:
@@ -3351,17 +3351,17 @@ compare_constant (const tree t1, const tree t2)
       {
 	class addr_const value1, value2;
 	enum rtx_code code;
-	int ret;
+	bool ret;
 
 	decode_addr_const (t1, &value1);
 	decode_addr_const (t2, &value2);
 
 	if (maybe_ne (value1.offset, value2.offset))
-	  return 0;
+	  return false;
 
 	code = GET_CODE (value1.base);
 	if (code != GET_CODE (value2.base))
-	  return 0;
+	  return false;
 
 	switch (code)
 	  {
@@ -3392,7 +3392,7 @@ compare_constant (const tree t1, const tree t2)
       return compare_constant (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
 
     default:
-      return 0;
+      return false;
     }
 }
 \f
@@ -3760,7 +3760,7 @@ const_rtx_desc_hasher::equal (constant_descriptor_rtx *x,
 			      constant_descriptor_rtx *y)
 {
   if (x->mode != y->mode)
-    return 0;
+    return false;
   return rtx_equal_p (x->constant, y->constant);
 }
 
@@ -4377,7 +4377,7 @@ const_rtx_data_hasher::equal (constant_descriptor_rtx_data *x,
 			      constant_descriptor_rtx_data *y)
 {
   if (x->hash != y->hash || x->size != y->size)
-    return 0;
+    return false;
   unsigned int align1 = x->desc->align;
   unsigned int align2 = y->desc->align;
   unsigned int offset1 = (x->offset * BITS_PER_UNIT) & (align1 - 1);
@@ -4387,10 +4387,10 @@ const_rtx_data_hasher::equal (constant_descriptor_rtx_data *x,
   if (offset2)
     align2 = least_bit_hwi (offset2);
   if (align2 > align1)
-    return 0;
+    return false;
   if (memcmp (x->bytes, y->bytes, x->size * sizeof (target_unit)) != 0)
-    return 0;
-  return 1;
+    return false;
+  return true;
 }
 
 /* Attempt to optimize constant pool POOL.  If it contains both CONST_VECTOR
@@ -6528,30 +6528,32 @@ default_assemble_visibility (tree decl ATTRIBUTE_UNUSED,
 
 /* A helper function to call assemble_visibility when needed for a decl.  */
 
-int
+bool
 maybe_assemble_visibility (tree decl)
 {
   enum symbol_visibility vis = DECL_VISIBILITY (decl);
   if (vis != VISIBILITY_DEFAULT)
     {
       targetm.asm_out.assemble_visibility (decl, vis);
-      return 1;
+      return true;
     }
   else
-    return 0;
+    return false;
 }
 
-/* Returns 1 if the target configuration supports defining public symbols
+/* Returns true if the target configuration supports defining public symbols
    so that one of them will be chosen at link time instead of generating a
    multiply-defined symbol error, whether through the use of weak symbols or
    a target-specific mechanism for having duplicates discarded.  */
 
-int
+bool
 supports_one_only (void)
 {
   if (SUPPORTS_ONE_ONLY)
-    return 1;
-  return TARGET_SUPPORTS_WEAK;
+    return true;
+  if (TARGET_SUPPORTS_WEAK)
+    return true;
+  return false;
 }
 
 /* Set up DECL as a public symbol that can be defined in multiple
diff --git a/gcc/varasm.h b/gcc/varasm.h
index e6190cae0f8..ff302e8b6f4 100644
--- a/gcc/varasm.h
+++ b/gcc/varasm.h
@@ -31,7 +31,7 @@ extern tree tree_output_constant_def (tree);
 extern void make_decl_rtl (tree);
 extern rtx make_decl_rtl_for_debug (tree);
 extern void make_decl_one_only (tree, tree);
-extern int supports_one_only (void);
+extern bool supports_one_only (void);
 extern void resolve_unique_section (tree, int, int);
 extern void mark_referenced (tree);
 extern void mark_decl_referenced (tree);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-28 14:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-28 14:31 [gcc r14-2166] final+varasm: Change return type of predicate functions from int to bool Uros Bizjak

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).