This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

avr port: bugfix patch



Wed May  3 22:52:53 2000  Denis Chertykov  <denisc@overta.ru>

	* config/avr/avr-protos.h (test_hard_reg_class): Declared.
	* config/avr/avr.c (ashrhi3_out): optimized shift by 15.
	(lshrhi3_out): Likewise.
	(ashrsi3_out): bugfix in shift by 8.
	(test_hard_reg_class): New function.
	* config/avr/avr.md: Bugfix inside conditions in peepholes.
	(ashlhi3): removed define_expand of this pattern.
	(*ashlhi3_insn): renamed to ashlhi3.
	(ashlsi3): removed define_expand of this pattern.
	(*ashlsi3_insn): renamed to ashlsi3.
	(ashrqi3): removed define_expand of this pattern.
	(*ashrqi3_insn): renamed to ashrqi3.
	(ashrhi3): removed define_expand of this pattern.
	(*ashrhi3_insn): renamed to ashrhi3.
	(ashrsi3): removed define_expand of this pattern.
	(*ashrsi3_insn): renamed to ashrsi3.
	(lshrhi3): removed define_expand of this pattern.
	(*lshrhi3_insn): renamed to lshrhi3.
	(lshrsi3): removed define_expand of this pattern.
	(*lshrsi3_insn): renamed to lshrsi3.

Index: gcc/config/avr/avr-protos.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/avr/avr-protos.h,v
retrieving revision 1.1
diff -c -3 -p -r1.1 avr-protos.h
*** avr-protos.h	2000/02/11 22:31:46	1.1
--- avr-protos.h	2000/05/03 18:52:30
*************** extern char * lshrqi3_out     PARAMS ((r
*** 107,115 ****
  extern char * lshrhi3_out     PARAMS ((rtx insn, rtx operands[], int *len));
  extern char * lshrsi3_out     PARAMS ((rtx insn, rtx operands[], int *len));
  
- extern int    avr_address_cost       PARAMS ((rtx x));
  extern enum reg_class preferred_reload_class PARAMS ((rtx x,
  						     enum reg_class class));
  extern int    extra_constraint       PARAMS ((rtx x, char c));
  extern rtx    legitimize_address     PARAMS ((rtx x, rtx oldx,
  					     enum machine_mode mode));
--- 107,115 ----
  extern char * lshrhi3_out     PARAMS ((rtx insn, rtx operands[], int *len));
  extern char * lshrsi3_out     PARAMS ((rtx insn, rtx operands[], int *len));
  
  extern enum reg_class preferred_reload_class PARAMS ((rtx x,
  						     enum reg_class class));
+ extern int    avr_address_cost       PARAMS ((rtx x));
  extern int    extra_constraint       PARAMS ((rtx x, char c));
  extern rtx    legitimize_address     PARAMS ((rtx x, rtx oldx,
  					     enum machine_mode mode));
*************** extern int    _reg_unused_after      PAR
*** 135,140 ****
--- 135,141 ----
  extern int    avr_jump_mode          PARAMS ((rtx x, rtx insn));
  extern int    byte_immediate_operand PARAMS ((register rtx op,
  					     enum machine_mode mode));
+ extern int    test_hard_reg_class    PARAMS ((enum reg_class class, rtx x));
  
  #endif /* RTX_CODE */
  
Index: gcc/config/avr/avr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/avr/avr.c,v
retrieving revision 1.6
diff -c -3 -p -r1.6 avr.c
*** avr.c	2000/05/01 14:37:11	1.6
--- avr.c	2000/05/03 18:52:50
*************** ashrhi3_out (insn,operands,len)
*** 2401,2406 ****
--- 2401,2410 ----
  	    return *len = 3, (AS1 (clr,%B0)     CR_TAB
  			      AS2 (sbrc,%A0,7)  CR_TAB
  			      AS1 (dec,%B0));
+ 	case 15:
+ 	  return *len = 3, (AS1 (lsl,%B0)     CR_TAB
+ 			    AS2 (sbc,%A0,%A0) CR_TAB
+ 			    AS2 (mov,%B0,%A0));
  	}
      }
    if (len)
*************** ashrsi3_out (insn,operands,len)
*** 2455,2461 ****
  				AS1 (dec,%D0));
  	    else
  	      return (AS1 (clr,%D0)     CR_TAB
! 		      AS2 (sbrc,%C0,7)  CR_TAB
  		      AS1 (dec,%D0)     CR_TAB
  		      AS2 (mov,%C0,%D1) CR_TAB
  		      AS2 (mov,%B0,%C1) CR_TAB
--- 2459,2465 ----
  				AS1 (dec,%D0));
  	    else
  	      return (AS1 (clr,%D0)     CR_TAB
! 		      AS2 (sbrc,%D1,7)  CR_TAB
  		      AS1 (dec,%D0)     CR_TAB
  		      AS2 (mov,%C0,%D1) CR_TAB
  		      AS2 (mov,%B0,%C1) CR_TAB
*************** lshrhi3_out (insn,operands,len)
*** 2634,2640 ****
  			      AS1 (clr,%B0));
  	  else
  	    return *len = 1, AS1 (clr,%B0);
! 	    
  	}
      }
    if (len)
--- 2638,2649 ----
  			      AS1 (clr,%B0));
  	  else
  	    return *len = 1, AS1 (clr,%B0);
! 	  
! 	case 15:
! 	  return *len = 4, (AS1 (lsl,%B0)     CR_TAB
! 			    AS2 (sbc,%A0,%A0) CR_TAB
! 			    AS1 (neg,%A0)     CR_TAB
! 			    AS1 (clr,%B0));
  	}
      }
    if (len)
*************** preferred_reload_class(x,class)
*** 3734,3739 ****
--- 3743,3759 ----
        return LD_REGS;
      }
    return class;
+ }
+ 
+ int
+ test_hard_reg_class(class, x)
+      enum reg_class class;
+      rtx x;
+ {
+   int regno = true_regnum (x);
+   if (regno < 0)
+     return 0;
+   return TEST_HARD_REG_CLASS (class, regno);
  }
  
  void
Index: gcc/config/avr/avr.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/avr/avr.md,v
retrieving revision 1.1
diff -c -3 -p -r1.1 avr.md
*** avr.md	2000/02/11 22:31:46	1.1
--- avr.md	2000/05/03 18:53:15
***************
*** 877,891 ****
    [(set_attr "length" "6,4,6,7")
     (set_attr "cc" "clobber,set_czn,set_czn,clobber")])
  
! (define_expand "ashlhi3"
!   [(parallel [(set (match_operand:HI 0 "register_operand" "")
! 		   (ashift:HI (match_operand:HI 1 "register_operand" "")
! 			      (match_operand:QI 2 "general_operand" "")))
! 	      (clobber (match_scratch:QI 3 ""))])]
!   ""
!   "")
! 
! (define_insn "*ashlhi3_insn"
    [(set (match_operand:HI 0 "register_operand"           "=r,r,r,r,r,r")
  	(ashift:HI (match_operand:HI 1 "register_operand" "0,0,r,0,0,0")
  		   (match_operand:QI 2 "general_operand"  "r,P,O,K,i,Qm")))
--- 877,883 ----
    [(set_attr "length" "6,4,6,7")
     (set_attr "cc" "clobber,set_czn,set_czn,clobber")])
  
! (define_insn "ashlhi3"
    [(set (match_operand:HI 0 "register_operand"           "=r,r,r,r,r,r")
  	(ashift:HI (match_operand:HI 1 "register_operand" "0,0,r,0,0,0")
  		   (match_operand:QI 2 "general_operand"  "r,P,O,K,i,Qm")))
***************
*** 894,909 ****
    "* return ashlhi3_out (insn,operands, NULL);"
    [(set_attr "length" "7,2,4,2,5,8")
     (set_attr "cc" "clobber,clobber,clobber,clobber,clobber,clobber")])
- 
- (define_expand "ashlsi3"
-   [(parallel [(set (match_operand:SI 0 "register_operand" "")
- 		   (ashift:SI (match_operand:SI 1 "register_operand" "")
- 			      (match_operand:QI 2 "general_operand" "")))
- 	      (clobber (match_scratch:QI 3 ""))])]
-   ""
-   "")
  
! (define_insn "*ashlsi3_insn"
    [(set (match_operand:SI 0 "register_operand"           "=r,r,r,r,r")
  	(ashift:SI (match_operand:SI 1 "register_operand" "0,0,r,0,0")
  		   (match_operand:QI 2 "general_operand"  "r,P,O,i,Qm")))
--- 886,893 ----
    "* return ashlhi3_out (insn,operands, NULL);"
    [(set_attr "length" "7,2,4,2,5,8")
     (set_attr "cc" "clobber,clobber,clobber,clobber,clobber,clobber")])
  
! (define_insn "ashlsi3"
    [(set (match_operand:SI 0 "register_operand"           "=r,r,r,r,r")
  	(ashift:SI (match_operand:SI 1 "register_operand" "0,0,r,0,0")
  		   (match_operand:QI 2 "general_operand"  "r,P,O,i,Qm")))
***************
*** 916,930 ****
  ;; >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>
  ;; arithmetic shift right
  
! (define_expand "ashrqi3"
!   [(parallel [(set (match_operand:QI 0 "register_operand" "")
! 		   (ashiftrt:QI (match_operand:QI 1 "register_operand" "")
! 				(match_operand:QI 2 "general_operand" "")))
! 	      (clobber (match_scratch:QI 3 ""))])]
!   ""
!   "")
! 
! (define_insn "*ashrqi3"
    [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r")
  	(ashiftrt:QI (match_operand:QI 1 "register_operand" "0,0,0,0,0")
  		     (match_operand:QI 2 "general_operand" "r,P,K,i,Qm")))
--- 900,906 ----
  ;; >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>
  ;; arithmetic shift right
  
! (define_insn "ashrqi3"
    [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r")
  	(ashiftrt:QI (match_operand:QI 1 "register_operand" "0,0,0,0,0")
  		     (match_operand:QI 2 "general_operand" "r,P,K,i,Qm")))
***************
*** 933,949 ****
    "* return ashrqi3_out (insn,operands, NULL);"
    [(set_attr "length" "6,1,2,4,7")
     (set_attr "cc" "clobber,clobber,clobber,clobber,clobber")])
- 
- 
- (define_expand "ashrhi3"
-   [(parallel [(set (match_operand:HI 0 "register_operand" "")
- 		   (ashiftrt:HI (match_operand:HI 1 "register_operand" "")
- 				(match_operand:QI 2 "general_operand" "")))
- 	      (clobber (match_scratch:QI 3 ""))])]
-   ""
-   "")
  
! (define_insn "*ashrhi3_insn"
    [(set (match_operand:HI 0 "register_operand"             "=r,r,r,r,r,r")
  	(ashiftrt:HI (match_operand:HI 1 "register_operand" "0,0,0,r,0,0")
  		     (match_operand:QI 2 "general_operand"  "r,P,K,O,i,Qm")))
--- 909,916 ----
    "* return ashrqi3_out (insn,operands, NULL);"
    [(set_attr "length" "6,1,2,4,7")
     (set_attr "cc" "clobber,clobber,clobber,clobber,clobber")])
  
! (define_insn "ashrhi3"
    [(set (match_operand:HI 0 "register_operand"             "=r,r,r,r,r,r")
  	(ashiftrt:HI (match_operand:HI 1 "register_operand" "0,0,0,r,0,0")
  		     (match_operand:QI 2 "general_operand"  "r,P,K,O,i,Qm")))
***************
*** 952,967 ****
    "* return ashrhi3_out (insn,operands, NULL);"
    [(set_attr "length" "7,2,4,2,5,8")
     (set_attr "cc" "clobber,clobber,clobber,clobber,clobber,clobber")])
- 
- (define_expand "ashrsi3"
-   [(parallel [(set (match_operand:SI 0 "register_operand" "")
- 		   (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
- 				(match_operand:QI 2 "general_operand" "")))
- 	      (clobber (match_scratch:QI 3 ""))])]
-   ""
-   "")
  
! (define_insn "*ashrsi3_insn"
    [(set (match_operand:SI 0 "register_operand"             "=r,r,r,r,r")
  	(ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r,0,0")
  		     (match_operand:QI 2 "general_operand"  "r,P,O,i,Qm")))
--- 919,926 ----
    "* return ashrhi3_out (insn,operands, NULL);"
    [(set_attr "length" "7,2,4,2,5,8")
     (set_attr "cc" "clobber,clobber,clobber,clobber,clobber,clobber")])
  
! (define_insn "ashrsi3"
    [(set (match_operand:SI 0 "register_operand"             "=r,r,r,r,r")
  	(ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r,0,0")
  		     (match_operand:QI 2 "general_operand"  "r,P,O,i,Qm")))
***************
*** 982,997 ****
    "* return lshrqi3_out (insn,operands, NULL);"
    [(set_attr "length" "6,4,6,7")
     (set_attr "cc" "clobber,set_czn,set_czn,clobber")])
- 
- (define_expand "lshrhi3"
-   [(parallel [(set (match_operand:HI 0 "register_operand" "")
- 		   (lshiftrt:HI (match_operand:HI 1 "register_operand" "")
- 				(match_operand:QI 2 "general_operand" "")))
- 	      (clobber (match_scratch:QI 3 ""))])]
-   ""
-   "")
  
! (define_insn "*lshrhi3_insn"
    [(set (match_operand:HI 0 "register_operand"             "=r,r,r,r,r,r")
  	(lshiftrt:HI (match_operand:HI 1 "register_operand" "0,0,0,r,0,0")
  		     (match_operand:QI 2 "general_operand"  "r,P,K,O,i,Qm")))
--- 941,948 ----
    "* return lshrqi3_out (insn,operands, NULL);"
    [(set_attr "length" "6,4,6,7")
     (set_attr "cc" "clobber,set_czn,set_czn,clobber")])
  
! (define_insn "lshrhi3"
    [(set (match_operand:HI 0 "register_operand"             "=r,r,r,r,r,r")
  	(lshiftrt:HI (match_operand:HI 1 "register_operand" "0,0,0,r,0,0")
  		     (match_operand:QI 2 "general_operand"  "r,P,K,O,i,Qm")))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]