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 patch: length in `call...' insns and tablejump


Sun Sep  3 13:10:56 2000  Denis Chertykov  <denisc@overta.ru>

	* config/avr/avr.md ("*tablejump_lib"): New pattern.
	(call_value_insn): Right length claculation.
	(call_insn): Likewise.

Index: config/avr/avr.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/avr/avr.md,v
retrieving revision 1.11
diff -c -3 -p -r1.11 avr.md
*** avr.md	2000/09/03 07:37:48	1.11
--- avr.md	2000/09/03 11:31:50
***************
*** 1616,1630 ****
    ""
    "")
  
- ;; TODO: insn length for AVR_ENHANCED
  (define_insn "call_insn"
    [(call (mem:HI (match_operand:HI 0 "nonmemory_operand" "!z,*r,i"))
           (match_operand:HI 1 "general_operand" "X,X,X"))]
  ;; We don't need in saving Z register because r30,r31 is a call used registers
    ;; Operand 1 not used on the AVR.
    "(register_operand (operands[0], HImode) || CONSTANT_P (operands[0]))"
!   "*
! {
    if (which_alternative==0)
       return \"icall\";
    else if (which_alternative==1)
--- 1616,1628 ----
    ""
    "")
  
  (define_insn "call_insn"
    [(call (mem:HI (match_operand:HI 0 "nonmemory_operand" "!z,*r,i"))
           (match_operand:HI 1 "general_operand" "X,X,X"))]
  ;; We don't need in saving Z register because r30,r31 is a call used registers
    ;; Operand 1 not used on the AVR.
    "(register_operand (operands[0], HImode) || CONSTANT_P (operands[0]))"
!   "*{
    if (which_alternative==0)
       return \"icall\";
    else if (which_alternative==1)
***************
*** 1645,1658 ****
     (set (attr "length")
  	(cond [(eq (symbol_ref "which_alternative") (const_int 0))
  	       (const_int 1)
! 	       (eq (symbol_ref "which_alternative") (const_int 1))
  	       (const_int 3)
! 	       (eq (symbol_ref "!AVR_MEGA")
! 		   (const_int 0))
  	       (const_int 2)]
  	(const_int 1)))])
  
- ;; TODO: insn length for AVR_ENHANCED
  (define_insn "call_value_insn"
    [(set (match_operand 0 "register_operand" "=r,r,r")
          (call (mem:HI (match_operand:HI 1 "nonmemory_operand" "!z,*r,i"))
--- 1643,1658 ----
     (set (attr "length")
  	(cond [(eq (symbol_ref "which_alternative") (const_int 0))
  	       (const_int 1)
! 	       (eq (symbol_ref "(which_alternative == 1 && AVR_ENHANCED)")
!                    (const_int 1))
! 	       (const_int 2)
! 	       (eq (symbol_ref "(which_alternative == 1 && !AVR_ENHANCED)")
!                    (const_int 1))
  	       (const_int 3)
! 	       (eq (symbol_ref "!AVR_MEGA") (const_int 0))
  	       (const_int 2)]
  	(const_int 1)))])
  
  (define_insn "call_value_insn"
    [(set (match_operand 0 "register_operand" "=r,r,r")
          (call (mem:HI (match_operand:HI 1 "nonmemory_operand" "!z,*r,i"))
***************
*** 1682,1688 ****
     (set (attr "length")
  	(cond [(eq (symbol_ref "which_alternative") (const_int 0))
  	       (const_int 1)
! 	       (eq (symbol_ref "which_alternative") (const_int 1))
  	       (const_int 3)
  	       (eq (symbol_ref "!AVR_MEGA")
  		   (const_int 0))
--- 1682,1692 ----
     (set (attr "length")
  	(cond [(eq (symbol_ref "which_alternative") (const_int 0))
  	       (const_int 1)
! 	       (eq (symbol_ref "(which_alternative == 1 && AVR_ENHANCED)")
!                    (const_int 1))
! 	       (const_int 2)
! 	       (eq (symbol_ref "(which_alternative == 1 && !AVR_ENHANCED)")
!                    (const_int 1))
  	       (const_int 3)
  	       (eq (symbol_ref "!AVR_MEGA")
  		   (const_int 0))
***************
*** 1712,1719 ****
  	      (use (label_ref (match_operand 1 "" "")))])]
    "optimize"
    "")
  
- ;; TODO: jump to __tabjejump__ in libgcc
  
  (define_insn "*tablejump_enh"
     [(set (pc) (mem:HI
--- 1716,1742 ----
  	      (use (label_ref (match_operand 1 "" "")))])]
    "optimize"
    "")
+ 
+ ;; Not a prologue, but similar idea - move the common piece of code to libgcc.
+ (define_insn "*tablejump_lib"
+    [(set (pc) (mem:HI (plus:HI (match_operand:HI 0 "register_operand" "=&z")
+ 			       (label_ref (match_operand 2 "" "")))))
+     (use (label_ref (match_operand 1 "" "")))]
+   "TARGET_CALL_PROLOGUES"
+   "*{
+   output_asm_insn (AS2 (subi,r30,lo8(-(%2))) CR_TAB
+ 	           AS2 (sbci,r31,hi8(-(%2))), operands);
+   return (AVR_MEGA
+           ? AS1 (jmp,__tablejump__)
+           : AS1 (rjmp,__tablejump__));
+   }"
+   [(set_attr "cc" "clobber")
+    (set (attr "length")
+ 	(if_then_else (eq (symbol_ref "AVR_MEGA")
+ 			  (const_int 0))
+ 		      (const_int 3)
+ 		      (const_int 4)))])
  
  
  (define_insn "*tablejump_enh"
     [(set (pc) (mem:HI



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