avr.md: Document UNSPEC usage.
authorMarek Michalkiewicz <marekm@linux.org.pl>
Sat, 2 Dec 2000 13:12:45 +0000 (14:12 +0100)
committerDenis Chertykov <denisc@gcc.gnu.org>
Sat, 2 Dec 2000 13:12:45 +0000 (16:12 +0300)
* config/avr/avr.md: Document UNSPEC usage.
(*tablejump_rjmp, *tablejump_lib, *tablejump_enh, *tablejump):
Make operand 0 input only, clobber it.  Use UNSPEC, not a bogus
MEM for program memory word reference.  Do not add the label to
the table index in each of the asm output templates, instead ...
(casesi): ... do it in RTL.  Adjust to match the above change.

From-SVN: r37951

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

index 8b7e9f9a5904e4f926453ef9a35b9c38f120ebd8..f38ff599b444eddcd46bf94c7f41e47e6337d28c 100644 (file)
@@ -1,3 +1,12 @@
+2000-11-23  Marek Michalkiewicz  <marekm@linux.org.pl>
+
+       * config/avr/avr.md: Document UNSPEC usage.
+       (*tablejump_rjmp, *tablejump_lib, *tablejump_enh, *tablejump):
+       Make operand 0 input only, clobber it.  Use UNSPEC, not a bogus
+       MEM for program memory word reference.  Do not add the label to
+       the table index in each of the asm output templates, instead ...
+       (casesi): ... do it in RTL.  Adjust to match the above change.
+
 2000-12-02  Bernd Schmidt  <bernds@redhat.co.uk>
 
        * c-common.c (PTRDIFF_TYPE): Provide default here, ...
index 57972e6156613fb7963ae112e7e170ffd6f3fbfe..c49b72dbe18bc5159e04807e831b1053d2cd8e5a 100644 (file)
 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
+;; UNSPEC usage:
+;;  0  Length of a string, see "strlenhi".
+;;  1  Read from a word address in program memory, see "casesi".
+
 ;; Condition code settings.
 (define_attr "cc" "none,set_czn,set_zn,set_n,compare,clobber"
   (const_string "none"))
 
 ;; table jump
 
-;; Note: the (mem:HI (...)) memory references here are special - actually
-;; the data is read from a word address in program memory (r31:r30 is the
-;; index in the table, not multiplied by 2 - see the "casesi" pattern).
-
 ;; Table made from "rjmp" instructions for <=8K devices.
 (define_insn "*tablejump_rjmp"
-   [(set (pc) (mem:HI
-              (plus:HI (match_operand:HI 0 "register_operand" "=&z")
-                       (label_ref (match_operand 2 "" "")))))
-    (use (label_ref (match_operand 1 "" "")))]
+  [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "!z,*r")] 1))
+   (use (label_ref (match_operand 1 "" "")))
+   (clobber (match_dup 0))]
   "!AVR_MEGA"
-  "subi r30,pm_lo8(-(%2))
-       sbci r31,pm_hi8(-(%2))
-       ijmp"
-  [(set_attr "length" "3")
-   (set_attr "cc" "clobber")])
+  "@
+       ijmp
+       push %A0\;push %B0\;ret"
+  [(set_attr "length" "1,3")
+   (set_attr "cc" "none,none")])
 
 ;; 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 "" "")))]
+  [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")] 1))
+   (use (label_ref (match_operand 1 "" "")))
+   (clobber (match_dup 0))]
   "AVR_MEGA && TARGET_CALL_PROLOGUES"
-  "subi r30,pm_lo8(-(%2))
-       sbci r31,pm_hi8(-(%2))
-       jmp __tablejump2__"
-  [(set_attr "length" "4")
+  "jmp __tablejump2__"
+  [(set_attr "length" "2")
    (set_attr "cc" "clobber")])
 
 (define_insn "*tablejump_enh"
-   [(set (pc) (mem:HI
-              (plus:HI (match_operand:HI 0 "register_operand" "=&z")
-                       (label_ref (match_operand 2 "" "")))))
-    (use (label_ref (match_operand 1 "" "")))]
+  [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")] 1))
+   (use (label_ref (match_operand 1 "" "")))
+   (clobber (match_dup 0))]
   "AVR_MEGA && AVR_ENHANCED"
-  "subi r30,pm_lo8(-(%2))
-       sbci r31,pm_hi8(-(%2))
-       lsl r30
+  "lsl r30
        rol r31
        lpm __tmp_reg__,Z+
        lpm r31,Z
        mov r30,__tmp_reg__
        ijmp"
-  [(set_attr "length" "8")
+  [(set_attr "length" "6")
    (set_attr "cc" "clobber")])
 
 (define_insn "*tablejump"
-   [(set (pc) (mem:HI
-              (plus:HI (match_operand:HI 0 "register_operand" "=&z")
-                       (label_ref (match_operand 2 "" "")))))
-    (use (label_ref (match_operand 1 "" "")))]
+  [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")] 1))
+   (use (label_ref (match_operand 1 "" "")))
+   (clobber (match_dup 0))]
   "AVR_MEGA"
-  "subi r30,pm_lo8(-(%2))
-       sbci r31,pm_hi8(-(%2))
-       lsl r30
+  "lsl r30
        rol r31
        lpm
        inc r30
        lpm
        push r0
        ret"
-  [(set_attr "length" "10")
+  [(set_attr "length" "8")
    (set_attr "cc" "clobber")])
 
 (define_expand "casesi"
                           (const_int 0))
                      (label_ref (match_operand 4 "" ""))
                      (pc)))
-;;   (set (match_dup 6)
-;;     (plus:HI (match_dup 6)
-;;              (match_dup 6)))
-;;   (set (match_dup 6)
-;;     (plus:HI (match_dup 6) (label_ref (match_operand:HI 3 "" ""))))
-                
-   (parallel [(set (pc) (mem:HI
-                        (plus:HI (match_dup 6)
-                                 (label_ref (match_operand:HI 3 "" "")))))
-             (use (label_ref (match_dup 3)))])]
+
+   (set (match_dup 6)
+       (plus:HI (match_dup 6) (label_ref (match_operand:HI 3 "" ""))))
+
+   (parallel [(set (pc) (unspec:HI [(match_dup 6)] 1))
+             (use (label_ref (match_dup 3)))
+             (clobber (match_dup 6))])]
   ""
   "
 {