]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
avr.md ("*tablejump_lib"): New pattern.
authorDenis Chertykov <denisc@overta.ru>
Sun, 3 Sep 2000 11:33:33 +0000 (11:33 +0000)
committerDenis Chertykov <denisc@gcc.gnu.org>
Sun, 3 Sep 2000 11:33:33 +0000 (15:33 +0400)
* config/avr/avr.md ("*tablejump_lib"): New pattern.
(call_value_insn): Right length claculation.
(call_insn): Likewise.

From-SVN: r36119

gcc/ChangeLog
gcc/config/avr/avr.md

index 13beb1363410bbb0e8c3a1d3b574a598ff3ff23c..ff47d02e00da3b78505efb409cdef94a0cb49de4 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2000-09-02  Marek Michalkiewicz  <marekm@linux.org.pl>
 
        * config/avr/avr-protos.h, config/avr/avr.c (unique_section,
index 59f9aa72eff99c116c77d937c09297db5edeffb0..ba456ff0706d61addc16d0aef15009f7ae43c72f 100644 (file)
   ""
   "")
 
-;; 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)
    (set (attr "length")
        (cond [(eq (symbol_ref "which_alternative") (const_int 0))
               (const_int 1)
-              (eq (symbol_ref "which_alternative") (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))
+              (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"))
    (set (attr "length")
        (cond [(eq (symbol_ref "which_alternative") (const_int 0))
               (const_int 1)
-              (eq (symbol_ref "which_alternative") (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))
   "optimize"
   "")
 
-;; TODO: jump to __tabjejump__ in libgcc
+;; 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