Re: [SH] Use more bool, NULL_RTX

2012-04-11 Thread Kaz Kojima
Oleg Endo  wrote:
> The attached patch make the code use some more 'bool' and 'NULL_RTX'.
> Tested with 'make all-gcc'.
> OK?

OK.

Regards,
kaz


[SH] Use more bool, NULL_RTX

2012-04-11 Thread Oleg Endo
Hello,

The attached patch make the code use some more 'bool' and 'NULL_RTX'.
Tested with 'make all-gcc'.
OK?

ChangeLog:

* config/sh/sh.h (RETURN_ADDR_RTX): Use NULL_RTX instead of 0.
* config/sh/sh.c (INSN_REGMODE_WEIGHT, CURR_REGMODE_PRESSURE):
Fix line width.
(dump_table): Use bool type for need_align and have_df 
variables.
(find_barrier, sfunc_uses_reg): Use NULL_RTX instead of 0.
(regs_used): Remove register modifier.
(barrier_align): Move variables slot, credit, jump_to_next
into if block above for loop.  Use bool type for jump_to_next.
(sh_function_arg): Use NULL_RTX instead of 0.
Index: gcc/config/sh/sh.c
===
--- gcc/config/sh/sh.c	(revision 186327)
+++ gcc/config/sh/sh.c	(working copy)
@@ -547,10 +547,12 @@
 #define TARGET_FRAME_POINTER_REQUIRED sh_frame_pointer_required
 
 /* Return regmode weight for insn.  */
-#define INSN_REGMODE_WEIGHT(INSN, MODE)  regmode_weight[((MODE) == SImode) ? 0 : 1][INSN_UID (INSN)]
+#define INSN_REGMODE_WEIGHT(INSN, MODE)\
+  regmode_weight[((MODE) == SImode) ? 0 : 1][INSN_UID (INSN)]
 
 /* Return current register pressure for regmode.  */
-#define CURR_REGMODE_PRESSURE(MODE) 	curr_regmode_pressure[((MODE) == SImode) ? 0 : 1]
+#define CURR_REGMODE_PRESSURE(MODE)\
+  curr_regmode_pressure[((MODE) == SImode) ? 0 : 1]
 
 #undef  TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO	sh_encode_section_info
@@ -4202,10 +4204,10 @@
 {
   rtx scan = barrier;
   int i;
-  int need_align = 1;
+  bool need_align = true;
   rtx lab;
   label_ref_list_t ref;
-  int have_df = 0;
+  bool have_df = false;
 
   /* Do two passes, first time dump out the HI sized constants.  */
 
@@ -4218,7 +4220,7 @@
 	  if (need_align)
 	{
 	  scan = emit_insn_after (gen_align_2 (), scan);
-	  need_align = 0;
+	  need_align = false;
 	}
 	  for (lab = p->label; lab; lab = LABEL_REFS (lab))
 	scan = emit_label_after (lab, scan);
@@ -4231,15 +4233,15 @@
 	}
 	}
   else if (p->mode == DFmode)
-	have_df = 1;
+	have_df = true;
 }
 
-  need_align = 1;
+  need_align = true;
 
   if (start)
 {
   scan = emit_insn_after (gen_align_4 (), scan);
-  need_align = 0;
+  need_align = false;
   for (; start != barrier; start = NEXT_INSN (start))
 	if (NONJUMP_INSN_P (start)
 	&& recog_memoized (start) == CODE_FOR_casesi_worker_2)
@@ -4256,7 +4258,7 @@
 
   scan = emit_label_after (gen_label_rtx (), scan);
   scan = emit_insn_after (gen_align_log (GEN_INT (3)), scan);
-  need_align = 0;
+  need_align = false;
 
   for (i = 0; i < pool_size; i++)
 	{
@@ -4298,7 +4300,7 @@
 		{
 		  scan = emit_insn_after (gen_align_log (GEN_INT (3)), scan);
 		  align_insn = scan;
-		  need_align = 0;
+		  need_align = false;
 		}
 	case DImode:
 	  for (lab = p->label; lab; lab = LABEL_REFS (lab))
@@ -4336,7 +4338,7 @@
 	case SFmode:
 	  if (need_align)
 	{
-	  need_align = 0;
+	  need_align = false;
 	  scan = emit_label_after (gen_label_rtx (), scan);
 	  scan = emit_insn_after (gen_align_4 (), scan);
 	}
@@ -4349,7 +4351,7 @@
 	case DImode:
 	  if (need_align)
 	{
-	  need_align = 0;
+	  need_align = false;
 	  scan = emit_label_after (gen_label_rtx (), scan);
 	  scan = emit_insn_after (gen_align_4 (), scan);
 	}
@@ -4548,7 +4550,9 @@
   int hi_align = 2;
   int si_align = 2;
   int leading_mova = num_mova;
-  rtx barrier_before_mova = 0, found_barrier = 0, good_barrier = 0;
+  rtx barrier_before_mova = NULL_RTX;
+  rtx found_barrier = NULL_RTX;
+  rtx good_barrier = NULL_RTX;
   int si_limit;
   int hi_limit;
   rtx orig = from;
@@ -4882,19 +4886,19 @@
   rtx pattern, part, reg_part, reg;
 
   if (!NONJUMP_INSN_P (insn))
-return 0;
+return NULL_RTX;
   pattern = PATTERN (insn);
   if (GET_CODE (pattern) != PARALLEL || get_attr_type (insn) != TYPE_SFUNC)
-return 0;
+return NULL_RTX;
 
-  for (reg_part = 0, i = XVECLEN (pattern, 0) - 1; i >= 1; i--)
+  for (reg_part = NULL_RTX, i = XVECLEN (pattern, 0) - 1; i >= 1; i--)
 {
   part = XVECEXP (pattern, 0, i);
   if (GET_CODE (part) == USE && GET_MODE (XEXP (part, 0)) == SImode)
 	reg_part = part;
 }
   if (! reg_part)
-return 0;
+return NULL_RTX;
   reg = XEXP (reg_part, 0);
   for (i = XVECLEN (pattern, 0) - 1; i >= 0; i--)
 {
@@ -4904,7 +4908,7 @@
   if (reg_mentioned_p (reg, ((GET_CODE (part) == SET
   && REG_P (SET_DEST (part)))
  ? SET_SRC (part) : part)))
-	return 0;
+	return NULL_RTX;
 }
   return reg;
 }
@@ -5054,7 +5058,7 @@
 {
   if (fmt[i] == 'E')
 	{
-	  register int j;
+	  int j;
 	  for (j = XVECLEN (x, i) - 1; j >= 0; j--)
 	used |= regs_used (XVECEXP (x, i, j), is_dest);
 	}
@@ -5339,7 +5343,6 @@
 barrier_align (rtx barrier_or_label)
 {
   rtx next = next_real_insn (barrier_or_label), pat, prev;
-  int slot, c