Patchwork RFA: Fix avr --enable-werror-always build

login
register
mail settings
Submitter Joern Rennecke
Date Nov. 11, 2010, 9:08 p.m.
Message ID <20101111160810.mifeij591wswc0os-nzlynne@webmail.spamcop.net>
Download mbox | patch
Permalink /patch/70881/
State New
Headers show

Comments

Joern Rennecke - Nov. 11, 2010, 9:08 p.m.
built on i686-pc-linux-gnu with gcc (GCC) 4.6.0 20101111 (experimental) .
2010-11-11  Joern Rennecke  <amylaar@spamcop.net>

	PR target/46430
	* config/avr/avr-protos.h (avr_return_addr_rtx): Update prototype.
	* config/avr/driver-avr.c (avr_device_to_arch): Always return value.
	(avr_device_to_data_start, avr_device_to_startfiles): Likewise.
	(avr_device_to_devicelib): Likewise.
	* config/avr/avr.md (zero_extendqihi2): Put variable declarations
	into block.
	(zero_extendqisi2, zero_extendhisi2, zero_extendqidi2): Likewise.
	(zero_extendhidi2, zero_extendsidi2): Likewise.
	* config/avr/avr.c (avr_num_arg_regs): Constify type.
	(avr_return_addr_rtx): De-constify tem.
	(avr_rotate_bytes): Move declarations to start of block.
	Don't use variable length array.
	Put nested if/else into block.
Denis Chertykov - Nov. 12, 2010, 8:29 a.m.
2010/11/12 Joern Rennecke <amylaar@spamcop.net>:
> built on i686-pc-linux-gnu with gcc (GCC) 4.6.0 20101111 (experimental) .
>
> 2010-11-11  Joern Rennecke  <amylaar@spamcop.net>
>
>        PR target/46430
>        * config/avr/avr-protos.h (avr_return_addr_rtx): Update prototype.
>        * config/avr/driver-avr.c (avr_device_to_arch): Always return value.
>        (avr_device_to_data_start, avr_device_to_startfiles): Likewise.
>        (avr_device_to_devicelib): Likewise.
>        * config/avr/avr.md (zero_extendqihi2): Put variable declarations
>        into block.
>        (zero_extendqisi2, zero_extendhisi2, zero_extendqidi2): Likewise.
>        (zero_extendhidi2, zero_extendsidi2): Likewise.
>        * config/avr/avr.c (avr_num_arg_regs): Constify type.
>        (avr_return_addr_rtx): De-constify tem.
>        (avr_rotate_bytes): Move declarations to start of block.
>        Don't use variable length array.
>        Put nested if/else into block.
>

Approved.
Please, commit.

Denis.

Patch

Index: config/avr/avr-protos.h
===================================================================
--- config/avr/avr-protos.h	(revision 166609)
+++ config/avr/avr-protos.h	(working copy)
@@ -33,7 +33,7 @@  extern int avr_simple_epilogue (void);
 extern void gas_output_limited_string (FILE *file, const char *str);
 extern void gas_output_ascii (FILE *file, const char *str, size_t length);
 extern int avr_hard_regno_rename_ok (unsigned int, unsigned int);
-extern rtx avr_return_addr_rtx (int count, const_rtx tem);
+extern rtx avr_return_addr_rtx (int count, rtx tem);
 
 #ifdef TREE_CODE
 extern void asm_output_external (FILE *file, tree decl, char *name);
Index: config/avr/driver-avr.c
===================================================================
--- config/avr/driver-avr.c	(revision 166609)
+++ config/avr/driver-avr.c	(working copy)
@@ -55,7 +55,7 @@  avr_set_current_device (const char *name
 avr_device_to_arch (int argc, const char **argv)
 {
   if (0 == argc)
-    return;
+    return NULL;
 
   avr_set_current_device (argv[0]);
 
@@ -71,7 +71,7 @@  avr_device_to_data_start (int argc, cons
   char data_section_start_str[16];
 
   if (0 == argc)
-    return;  
+    return NULL;
 
   avr_set_current_device (argv[0]);
   
@@ -93,7 +93,7 @@  avr_device_to_data_start (int argc, cons
 avr_device_to_startfiles (int argc, const char **argv)
 {
   if (0 == argc)
-    return;
+    return NULL;
 
   avr_set_current_device (argv[0]);
 
@@ -106,7 +106,7 @@  avr_device_to_startfiles (int argc, cons
 avr_device_to_devicelib (int argc, const char **argv)
 {
   if (0 == argc)
-    return;
+    return NULL;
 
   avr_set_current_device (argv[0]);
 
Index: config/avr/avr.md
===================================================================
--- config/avr/avr.md	(revision 166609)
+++ config/avr/avr.md	(working copy)
@@ -2077,12 +2077,13 @@  (define_insn_and_split "zero_extendqihi2
   "reload_completed"
   [(set (match_dup 2) (match_dup 1))
    (set (match_dup 3) (const_int 0))]
-  "unsigned int low_off = subreg_lowpart_offset (QImode, HImode);
-   unsigned int high_off = subreg_highpart_offset (QImode, HImode);
-   
-   operands[2] = simplify_gen_subreg (QImode, operands[0], HImode, low_off);
-   operands[3] = simplify_gen_subreg (QImode, operands[0], HImode, high_off);
-  ")
+{
+  unsigned int low_off = subreg_lowpart_offset (QImode, HImode);
+  unsigned int high_off = subreg_highpart_offset (QImode, HImode);
+
+  operands[2] = simplify_gen_subreg (QImode, operands[0], HImode, low_off);
+  operands[3] = simplify_gen_subreg (QImode, operands[0], HImode, high_off);
+})
 
 (define_insn_and_split "zero_extendqisi2"
   [(set (match_operand:SI 0 "register_operand" "=r")
@@ -2092,12 +2093,13 @@  (define_insn_and_split "zero_extendqisi2
   "reload_completed"
   [(set (match_dup 2) (zero_extend:HI (match_dup 1)))
    (set (match_dup 3) (const_int 0))]
-  "unsigned int low_off = subreg_lowpart_offset (HImode, SImode);
-   unsigned int high_off = subreg_highpart_offset (HImode, SImode);
-   
-   operands[2] = simplify_gen_subreg (HImode, operands[0], SImode, low_off);
-   operands[3] = simplify_gen_subreg (HImode, operands[0], SImode, high_off);
-  ")
+{
+  unsigned int low_off = subreg_lowpart_offset (HImode, SImode);
+  unsigned int high_off = subreg_highpart_offset (HImode, SImode);
+
+  operands[2] = simplify_gen_subreg (HImode, operands[0], SImode, low_off);
+  operands[3] = simplify_gen_subreg (HImode, operands[0], SImode, high_off);
+})
 
 (define_insn_and_split "zero_extendhisi2"
   [(set (match_operand:SI 0 "register_operand" "=r")
@@ -2107,12 +2109,13 @@  (define_insn_and_split "zero_extendhisi2
   "reload_completed"
   [(set (match_dup 2) (match_dup 1))
    (set (match_dup 3) (const_int 0))]
-  "unsigned int low_off = subreg_lowpart_offset (HImode, SImode);
-   unsigned int high_off = subreg_highpart_offset (HImode, SImode);
-   
-   operands[2] = simplify_gen_subreg (HImode, operands[0], SImode, low_off);
-   operands[3] = simplify_gen_subreg (HImode, operands[0], SImode, high_off);
-  ")
+{
+  unsigned int low_off = subreg_lowpart_offset (HImode, SImode);
+  unsigned int high_off = subreg_highpart_offset (HImode, SImode);
+
+  operands[2] = simplify_gen_subreg (HImode, operands[0], SImode, low_off);
+  operands[3] = simplify_gen_subreg (HImode, operands[0], SImode, high_off);
+})
 
 (define_insn_and_split "zero_extendqidi2"
   [(set (match_operand:DI 0 "register_operand" "=r")
@@ -2122,12 +2125,13 @@  (define_insn_and_split "zero_extendqidi2
   "reload_completed"
   [(set (match_dup 2) (zero_extend:SI (match_dup 1)))
    (set (match_dup 3) (const_int 0))]
-  "unsigned int low_off = subreg_lowpart_offset (SImode, DImode);
-   unsigned int high_off = subreg_highpart_offset (SImode, DImode);
-   
-   operands[2] = simplify_gen_subreg (SImode, operands[0], DImode, low_off);
-   operands[3] = simplify_gen_subreg (SImode, operands[0], DImode, high_off);
-  ")
+{
+  unsigned int low_off = subreg_lowpart_offset (SImode, DImode);
+  unsigned int high_off = subreg_highpart_offset (SImode, DImode);
+
+  operands[2] = simplify_gen_subreg (SImode, operands[0], DImode, low_off);
+  operands[3] = simplify_gen_subreg (SImode, operands[0], DImode, high_off);
+})
 
 (define_insn_and_split "zero_extendhidi2"
   [(set (match_operand:DI 0 "register_operand" "=r")
@@ -2137,12 +2141,13 @@  (define_insn_and_split "zero_extendhidi2
   "reload_completed"
   [(set (match_dup 2) (zero_extend:SI (match_dup 1)))
    (set (match_dup 3) (const_int 0))]
-  "unsigned int low_off = subreg_lowpart_offset (SImode, DImode);
-   unsigned int high_off = subreg_highpart_offset (SImode, DImode);
-   
-   operands[2] = simplify_gen_subreg (SImode, operands[0], DImode, low_off);
-   operands[3] = simplify_gen_subreg (SImode, operands[0], DImode, high_off);
-  ")
+{
+  unsigned int low_off = subreg_lowpart_offset (SImode, DImode);
+  unsigned int high_off = subreg_highpart_offset (SImode, DImode);
+
+  operands[2] = simplify_gen_subreg (SImode, operands[0], DImode, low_off);
+  operands[3] = simplify_gen_subreg (SImode, operands[0], DImode, high_off);
+})
 
 (define_insn_and_split "zero_extendsidi2"
   [(set (match_operand:DI 0 "register_operand" "=r")
@@ -2152,12 +2157,13 @@  (define_insn_and_split "zero_extendsidi2
   "reload_completed"
   [(set (match_dup 2) (match_dup 1))
    (set (match_dup 3) (const_int 0))]
-  "unsigned int low_off = subreg_lowpart_offset (SImode, DImode);
-   unsigned int high_off = subreg_highpart_offset (SImode, DImode);
-   
-   operands[2] = simplify_gen_subreg (SImode, operands[0], DImode, low_off);
-   operands[3] = simplify_gen_subreg (SImode, operands[0], DImode, high_off);
-  ")
+{
+  unsigned int low_off = subreg_lowpart_offset (SImode, DImode);
+  unsigned int high_off = subreg_highpart_offset (SImode, DImode);
+
+  operands[2] = simplify_gen_subreg (SImode, operands[0], DImode, low_off);
+  operands[3] = simplify_gen_subreg (SImode, operands[0], DImode, high_off);
+})
 
 ;;<=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=>
 ;; compare
Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c	(revision 166609)
+++ config/avr/avr.c	(working copy)
@@ -60,7 +60,7 @@  static int get_sequence_length (rtx insn
 static int sequent_regs_live (void);
 static const char *ptrreg_to_str (int);
 static const char *cond_string (enum rtx_code);
-static int avr_num_arg_regs (enum machine_mode, tree);
+static int avr_num_arg_regs (enum machine_mode, const_tree);
 
 static RTX_CODE compare_condition (rtx insn);
 static rtx avr_legitimize_address (rtx, rtx, enum machine_mode);
@@ -436,7 +436,7 @@  rtx avr_builtin_setjmp_frame_value (void
 /* Return contents of MEM at frame pointer + stack size + 1 (+2 if 3 byte PC).
    This is return address of function.  */
 rtx 
-avr_return_addr_rtx (int count, const_rtx tem)
+avr_return_addr_rtx (int count, rtx tem)
 {
   rtx r;
     
@@ -1566,7 +1566,7 @@  init_cumulative_args (CUMULATIVE_ARGS *c
 /* Returns the number of registers to allocate for a function argument.  */
 
 static int
-avr_num_arg_regs (enum machine_mode mode, tree type)
+avr_num_arg_regs (enum machine_mode mode, const_tree type)
 {
   int size;
 
@@ -4256,6 +4256,8 @@  avr_rotate_bytes (rtx operands[])
     /* Work out if byte or word move is needed.  Odd byte rotates need QImode.
        Word move if no scratch is needed, otherwise use size of scratch.  */
     enum machine_mode move_mode = QImode;
+    int move_size, offset, size;
+
     if (num & 0xf)
       move_mode = QImode;
     else if ((mode == SImode && !same_reg) || !overlapped)
@@ -4271,11 +4273,11 @@  avr_rotate_bytes (rtx operands[])
     if (GET_MODE (scratch) == HImode && move_mode == QImode)
       scratch = simplify_gen_subreg (move_mode, scratch, HImode, 0); 
 
-    int move_size = GET_MODE_SIZE (move_mode);
+    move_size = GET_MODE_SIZE (move_mode);
     /* Number of bytes/words to rotate.  */
-    int offset = (num  >> 3) / move_size;
+    offset = (num  >> 3) / move_size;
     /* Number of moves needed.  */
-    int size = GET_MODE_SIZE (mode) / move_size;
+    size = GET_MODE_SIZE (mode) / move_size;
     /* Himode byte swap is special case to avoid a scratch register.  */
     if (mode == HImode && same_reg)
       {
@@ -4292,12 +4294,15 @@  avr_rotate_bytes (rtx operands[])
       }    
     else  
       {
+#define MAX_SIZE 8 /* GET_MODE_SIZE (DImode) / GET_MODE_SIZE (QImode)  */
 	/* Create linked list of moves to determine move order.  */
 	struct {
 	  rtx src, dst;
 	  int links;
-	} move[size + 8];
+	} move[MAX_SIZE + 8];
+	int blocked, moves;
 
+	gcc_assert (size <= MAX_SIZE);
 	/* Generate list of subreg moves.  */
 	for (i = 0; i < size; i++)
 	  {
@@ -4323,8 +4328,8 @@  avr_rotate_bytes (rtx operands[])
 		    break;
 		  }
 
-	int blocked = -1;
-	int moves = 0;
+	blocked = -1;
+	moves = 0;
 	/* Go through move list and perform non-conflicting moves.  As each
 	   non-overlapping move is made, it may remove other conflicts
 	   so the process is repeated until no conflicts remain.  */
@@ -4336,18 +4341,21 @@  avr_rotate_bytes (rtx operands[])
 	       src already.  */
 	    for (i = 0; i < size; i++)
 	      if (move[i].src != NULL_RTX)
-		if  (move[i].links == -1 || move[move[i].links].src == NULL_RTX)
-		  {
-		    moves++;
-		    /* Ignore NOP moves to self.  */
-		    if (!rtx_equal_p (move[i].dst, move[i].src))
-		      emit_move_insn (move[i].dst, move[i].src);
+		{
+		  if (move[i].links == -1
+		      || move[move[i].links].src == NULL_RTX)
+		    {
+		      moves++;
+		      /* Ignore NOP moves to self.  */
+		      if (!rtx_equal_p (move[i].dst, move[i].src))
+			emit_move_insn (move[i].dst, move[i].src);
 
-		    /* Remove  conflict from list.  */
-		    move[i].src = NULL_RTX;
-		  }
-		else
-		  blocked = i;
+		      /* Remove  conflict from list.  */
+		      move[i].src = NULL_RTX;
+		    }
+		  else
+		    blocked = i;
+		}
 
 	    /* Check for deadlock. This is when no moves occurred and we have
 	       at least one blocked move.  */