Now that the C default is C23, we can use bool in avr.h
(which is still used in libgcc via tm.h).
bool is a keyword in C23, so no stdbool.h is required in libgcc.

No regressions. Ok for trunk?

Johan

--

AVR: Use more bool.

Now that the C default is C23, we can use bool in avr.h
(which is still used in libgcc via tm.h).
bool is a keyword in C23, so no stdbool.h is required in libgcc.

gcc/
        * config/avr/avr.h (avr_args.has_stack_args): Be a bool.
        (struct machine_function) <is_naked, is_noblock, is_OS_task,
        is_OS_task, sibcall_fails, attributes_checked_p, is_no_gccisr,
        use_L__stack_usage, gasisr.yes, gasisr.maybe>: Same.
        * config/avr/avr-protos.h (reg_unused_after)
        (test_hard_reg_class, jump_over_one_insn_p): Use bool as
        return type.
        * config/avr/avr.cc (reg_unused_after)
        (test_hard_reg_class, jump_over_one_insn_p): Same.
        (cfun->machine->attributes_checked_p, cum->has_stack_args)
        (cfun->machine->use_L__stack_usage, cfun->machine->gasisr.yes)
        (cfun->machine->sibcall_fails): Use like a bool.
    AVR: Use more bool.
    
    Now that the C default is C23, we can use bool in avr.h
    (which is still used in libgcc via tm.h).
    bool is a keyword in C23, so no stdbool.h is required in libgcc.
    
    gcc/
            * config/avr/avr.h (avr_args.has_stack_args): Be a bool.
            (struct machine_function) <is_naked, is_noblock, is_OS_task,
            is_OS_task, sibcall_fails, attributes_checked_p, is_no_gccisr,
            use_L__stack_usage, gasisr.yes, gasisr.maybe>: Same.
            * config/avr/avr-protos.h (reg_unused_after)
            (test_hard_reg_class, jump_over_one_insn_p): Use bool as
            return type.
            * config/avr/avr.cc (reg_unused_after)
            (test_hard_reg_class, jump_over_one_insn_p): Same.
            (cfun->machine->attributes_checked_p, cum->has_stack_args)
            (cfun->machine->use_L__stack_usage, cfun->machine->gasisr.yes)
            (cfun->machine->sibcall_fails): Use like a bool.

diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h
index ae3cc62d038..d316e0182a2 100644
--- a/gcc/config/avr/avr-protos.h
+++ b/gcc/config/avr/avr-protos.h
@@ -127,10 +127,10 @@ extern const char* avr_out_reload_inpsi (rtx*, rtx, int*);
 extern const char* avr_out_lpm (rtx_insn *, rtx*, int*);
 extern const char* avr_out_cmp_lsr (rtx_insn *, rtx*, int*);
 extern void avr_maybe_cmp_lsr (rtx *);
-extern int reg_unused_after (rtx_insn *insn, rtx reg);
+extern bool reg_unused_after (rtx_insn *insn, rtx reg);
 extern int avr_jump_mode (rtx x, rtx_insn *insn, int = 0);
-extern int test_hard_reg_class (enum reg_class rclass, rtx x);
-extern int jump_over_one_insn_p (rtx_insn *insn, rtx dest);
+extern bool test_hard_reg_class (enum reg_class rclass, rtx x);
+extern bool jump_over_one_insn_p (rtx_insn *insn, rtx dest);
 
 extern void avr_final_prescan_insn (rtx_insn *insn, rtx *operand,
 				    int num_operands);
diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 8fab896b70f..0a9d26af075 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -920,7 +920,7 @@ avr_set_current_function (tree decl)
 
   /* Don't print the above diagnostics more than once.  */
 
-  cfun->machine->attributes_checked_p = 1;
+  cfun->machine->attributes_checked_p = true;
 }
 
 
@@ -973,7 +973,7 @@ static int
 avr_regs_to_save (HARD_REG_SET *set)
 {
   int count = 0;
-  int int_or_sig_p = cfun->machine->is_interrupt || cfun->machine->is_signal;
+  bool int_or_sig_p = cfun->machine->is_interrupt || cfun->machine->is_signal;
 
   if (set)
     CLEAR_HARD_REG_SET (*set);
@@ -1138,7 +1138,7 @@ avr_return_addr_rtx (int count, rtx tem)
   else
     r = gen_rtx_SYMBOL_REF (Pmode, ".L__stack_usage+1");
 
-  cfun->machine->use_L__stack_usage = 1;
+  cfun->machine->use_L__stack_usage = true;
 
   r = gen_rtx_PLUS (Pmode, tem, r);
   r = gen_frame_mem (Pmode, memory_address (Pmode, r));
@@ -1637,7 +1637,7 @@ avr_expand_prologue (void)
 	     ZERO_REG and TMP_REG and one additional, optional register for
 	     us in an optimal way.  This even scans through inline asm.  */
 
-	  cfun->machine->gasisr.yes = 1;
+	  cfun->machine->gasisr.yes = true;
 
 	  // The optional reg or TMP_REG if we don't need one.  If we need one,
 	  // remove that reg from SET so that it's not puhed / popped twice.
@@ -2992,13 +2992,13 @@ avr_init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype, rtx libname,
 {
   cum->nregs = AVR_TINY ? 1 + REG_25 - REG_20 : 1 + REG_25 - REG_8;
   cum->regno = FIRST_CUM_REG;
-  cum->has_stack_args = 0;
+  cum->has_stack_args = false;
   if (!libname && stdarg_p (fntype))
     cum->nregs = 0;
 
   /* Assume the calle may be tail called */
 
-  cfun->machine->sibcall_fails = 0;
+  cfun->machine->sibcall_fails = false;
 }
 
 
@@ -3031,7 +3031,7 @@ avr_function_arg (cumulative_args_t cum_v, const function_arg_info &arg)
   if (cum->nregs && bytes <= cum->nregs)
     return gen_rtx_REG (arg.mode, cum->regno - bytes);
 
-  cum->has_stack_args = 1;
+  cum->has_stack_args = true;
 
   return NULL_RTX;
 }
@@ -3065,7 +3065,7 @@ avr_function_arg_advance (cumulative_args_t cum_v, const function_arg_info &arg)
 	 pass &args_so_far, too.  At present, CUMULATIVE_ARGS is target
 	 dependent so that such an extension is not wanted.  */
 
-      cfun->machine->sibcall_fails = 1;
+      cfun->machine->sibcall_fails = true;
     }
 
   /* Test if all registers needed by the ABI are actually available.  If the
@@ -3306,7 +3306,7 @@ _reg_unused_after (rtx_insn *insn, rtx reg, bool look_at_insn)
 
 /* Return nonzero if register REG dead after INSN.  */
 
-int
+bool
 reg_unused_after (rtx_insn *insn, rtx reg)
 {
   return (dead_or_set_p (insn, reg)
@@ -13212,17 +13212,17 @@ avr_function_value (const_tree type, const_tree /*fn_decl_or_type*/,
   return gen_rtx_REG (BLKmode, avr_ret_register () + 2 - offs);
 }
 
-int
+bool
 test_hard_reg_class (reg_class rclass, rtx x)
 {
   int regno = true_regnum (x);
   if (regno < 0)
-    return 0;
+    return false;
 
   if (TEST_HARD_REG_CLASS (rclass, regno))
-    return 1;
+    return true;
 
-  return 0;
+  return false;
 }
 
 
@@ -13276,7 +13276,7 @@ avr_2word_insn_p (rtx_insn *insn)
 }
 
 
-int
+bool
 jump_over_one_insn_p (rtx_insn *insn, rtx dest)
 {
   int uid = INSN_UID (GET_CODE (dest) == LABEL_REF
diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h
index 3ef18972979..df0462259db 100644
--- a/gcc/config/avr/avr.h
+++ b/gcc/config/avr/avr.h
@@ -340,7 +340,7 @@ typedef struct avr_args
 
   /* Whether some of the arguments are passed on the stack,
      and hence an arg pointer is needed.  */
-  int has_stack_args;
+  bool has_stack_args;
 } CUMULATIVE_ARGS;
 
 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
@@ -553,7 +553,7 @@ extern const char *avr_no_devlib (int, const char**);
 struct GTY(()) machine_function
 {
   /* 'true' - if current function is a naked function.  */
-  int is_naked;
+  bool is_naked;
 
   /* 0 when no "interrupt" attribute is present.
      1 when an "interrupt" attribute without arguments is present (and
@@ -571,45 +571,45 @@ struct GTY(()) machine_function
 
   /* 'true' - if current function is a non-blocking interrupt service
      routine as specified by the "isr_noblock" attribute.  */
-  int is_noblock;
+  bool is_noblock;
 
   /* 'true' - if current function is a 'task' function
      as specified by the "OS_task" attribute.  */
-  int is_OS_task;
+  bool is_OS_task;
 
   /* 'true' - if current function is a 'main' function
      as specified by the "OS_main" attribute.  */
-  int is_OS_main;
+  bool is_OS_main;
 
   /* Current function stack size.  */
   int stack_usage;
 
   /* 'true' if a callee might be tail called */
-  int sibcall_fails;
+  bool sibcall_fails;
 
   /* 'true' if the above is_foo predicates are sanity-checked to avoid
      multiple diagnose for the same function.  */
-  int attributes_checked_p;
+  bool attributes_checked_p;
 
   /* 'true' - if current function shall not use '__gcc_isr' pseudo
      instructions as specified by the "no_gccisr" attribute.  */
-  int is_no_gccisr;
+  bool is_no_gccisr;
 
   /* Used for `__gcc_isr' pseudo instruction handling of
      non-naked ISR prologue / epilogue(s).  */
   struct
   {
     /* 'true' if this function actually uses "*gasisr" insns. */
-    int yes;
+    bool yes;
     /* 'true' if this function is allowed to use "*gasisr" insns. */
-    int maybe;
+    bool maybe;
     /* The register numer as printed by the Done chunk.  */
     int regno;
   } gasisr;
 
   /* 'true' if this function references .L__stack_usage like with
      __builtin_return_address.  */
-  int use_L__stack_usage;
+  bool use_L__stack_usage;
 };
 
 /* AVR does not round pushes, but the existence of this macro is

Reply via email to