home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / bbs / gnu / gcc-2.6.0-src.lha / GNU / src / amiga / gcc-2.6.0 / config / sh / sh.md < prev    next >
Encoding:
Text File  |  1994-04-20  |  52.0 KB  |  1,867 lines

  1. ;;- Machine description the Hitachi SH
  2. ;;  Copyright (C) 1993 Free Software Foundation, Inc.
  3. ;;  Contributed by Steve Chamberlain (sac@cygnus.com)
  4.  
  5. ;; This file is part of GNU CC.
  6.  
  7. ;; GNU CC is free software; you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation; either version 2, or (at your option)
  10. ;; any later version.
  11.  
  12. ;; GNU CC is distributed in the hope that it will be useful,
  13. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ;; GNU General Public License for more details.
  16.  
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with GNU CC; see the file COPYING.  If not, write to
  19. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.  
  22.  
  23. ;; Special constraints for SH machine description:
  24. ;;
  25. ;;    t -- T 
  26. ;;    x -- mac 
  27. ;;    l -- pr 
  28. ;;    z -- r0
  29. ;;
  30. ;; Special formats used for outputting SH instructions:
  31. ;;
  32. ;;   %.  --  print a .s if insn needs delay slot
  33. ;;   %*  --  print a local label
  34. ;;   %^  --  increment the local label number
  35. ;;   %#  --  output a nop if there is nothing to put in the delay slot
  36. ;;   %R  --  print the next register or memory location along, ie the lsw in
  37. ;;           a double word value
  38. ;;   %O  --  print a constant without the #
  39. ;;   %M  --  print a constant as its negative
  40. ;;
  41. ;;
  42. ;; Special predicates:
  43. ;;
  44. ;;  arith_operand          -- operand is valid source for arithmetic op
  45. ;;  arith_reg_operand      -- operand is valid register for arithmetic op
  46. ;;  byte_index_operand     -- operand is ok as an index in a mov.b
  47. ;;  general_movdst_operand -- operand is valid move destination
  48. ;;  general_movsrc_operand -- operand is valid move source
  49. ;;  logical_operand        -- operand is valid source for logical op
  50. ;;  pop_operand            -- operand is a pop from the stack
  51. ;;  system_reg_operand     -- operand is MACL, MACH, or PR
  52. ;; -------------------------------------------------------------------------
  53. ;; Attributes
  54. ;; -------------------------------------------------------------------------
  55.  
  56. ; Target CPU.
  57.  
  58. (define_attr "cpu" "sh0,sh1,sh2,sh3"
  59.   (const (symbol_ref "sh_cpu")))
  60.  
  61. (define_attr "interrupt_function" "no,yes"
  62.   (const (symbol_ref "pragma_interrupt")))
  63. ;;
  64. ;; cbranch    conditional branch instructions
  65. ;; jump        unconditional jumps
  66. ;; arith    ordinary arithmetic
  67. ;; load        from memory
  68. ;; store    to memory
  69. ;; move        register to register
  70. ;; smpy        single precision integer multiply
  71. ;; dmpy        double precision integer multiply
  72. ;; return    rts
  73. ;; pload    load of pr reg (can't be put into delay slot of rts)
  74. ;; pcloadsi    pc relative load of SI value
  75. ;; pcloadhi     pc relative load of HI value
  76. ;; rte        return from exception
  77. ;; sfunc    special function call with known used registers
  78.  
  79. (define_attr "type" 
  80.  "cbranch,jump,arith,other,load,store,move,smpy,dmpy,return,pload,pcloadsi,pcloadhi,rte,sfunc"
  81.   (const_string "other"))
  82.  
  83. ; If a conditional branch destination is within -120..120 bytes away 
  84. ; from the instruction it can be 2 bytes long.  Something in the
  85. ; range -4090..4090 bytes can be 6 bytes long, all other conditional
  86. ; branches are 8 bytes long.
  87.  
  88. ; An unconditional jump which can reach forward or back 4k can be 
  89. ; 6 bytes long (including the delay slot).  If it is too big, it
  90. ; must be 10 bytes long.
  91.  
  92. ; If a pcrel instruction is within 500 bytes of the constant, then the insn is 
  93. ; 2 bytes long, otherwise 12 bytes
  94. ; All other instructions are two bytes long by default.
  95.  
  96. (define_attr "length" "" 
  97.   (cond [(eq_attr "type" "cbranch")
  98.      (if_then_else (and (ge (minus (pc) (match_dup 0))
  99.                 (const_int -122))
  100.                 (le (minus (pc) (match_dup 0))
  101.                 (const_int 122)))
  102.                (const_int 2)
  103.                (if_then_else (and (ge (minus (pc) (match_dup 0))
  104.                           (const_int -4090))
  105.                       (le (minus (pc) (match_dup 0))
  106.                           (const_int 4090)))
  107.                      (const_int 6)
  108.                      (const_int 16)))
  109.  
  110.      (eq_attr "type" "jump")
  111.      (if_then_else (and (ge (minus (pc) (match_dup 0))
  112.                 (const_int -4090))
  113.                 (le (minus (pc) (match_dup 0))
  114.                 (const_int 4090)))
  115.                (const_int 4)
  116.                (const_int 10))
  117.      (eq_attr "type" "pcloadsi")
  118.      (if_then_else (gt (pc) (minus (match_dup 0) (const_int 1000)))
  119.                (const_int 2)
  120.                (const_int 12))
  121.      (eq_attr "type" "pcloadhi")
  122.      (if_then_else (gt (pc) (minus (match_dup 0) (const_int 500)))
  123.                (const_int 2)
  124.                (const_int 12))
  125.  
  126.      ] (const_int 2)))
  127.  
  128. ;; (define_function_unit {name} {num-units} {n-users} {test}
  129. ;;                       {ready-delay} {issue-delay} [{conflict-list}])
  130.                       
  131. (define_function_unit "memory" 1 0 (eq_attr "type" "load,pcloadsi,pcloadhi") 2 0)
  132. (define_function_unit "mpy"    1 0 (eq_attr "type" "smpy") 3 0)
  133. (define_function_unit "mpy"    1 0 (eq_attr "type" "dmpy") 5 0)
  134.  
  135. (define_attr "needs_delay_slot" "yes,no"
  136.   (cond [(eq_attr "type" "jump")   (const_string "yes")
  137.      (eq_attr "type" "return") (const_string "yes")]
  138.     (const_string "no")))
  139.  
  140. (define_delay 
  141.   (eq_attr "needs_delay_slot" "yes")
  142.   [(eq_attr "in_delay_slot" "yes") (nil) (nil)])
  143.  
  144. (define_delay 
  145.   (eq_attr "type" "return")
  146.   [(and (eq_attr "in_delay_slot" "yes") 
  147.     (ior (eq_attr "interrupt_function" "no")
  148.         (eq_attr "hit_stack" "no"))) (nil) (nil)])
  149.  
  150. (define_attr "hit_stack" "yes,no" (const_string "no"))
  151.  
  152. (define_delay 
  153.   (and (eq_attr "type" "cbranch") 
  154.        (eq_attr "cpu" "sh2"))
  155.   [(eq_attr "in_delay_slot" "yes") (nil) (nil)])
  156.  
  157. (define_attr "in_delay_slot" "maybe,yes,no" 
  158.   (cond [(eq_attr "type" "cbranch") (const_string "no")
  159.      (eq_attr "type" "jump") (const_string "no")
  160.      (eq_attr "type" "pload") (const_string "no")
  161.      (eq_attr "type" "return") (const_string "no")
  162.      (eq_attr "length" "2") (const_string "yes")
  163.      (eq_attr "length" "4,6,8,10,12") (const_string "no")
  164.      ] (const_string "yes")))
  165.  
  166.  
  167. ;; -------------------------------------------------------------------------
  168. ;; SImode signed integer comparisons
  169. ;; -------------------------------------------------------------------------
  170.  
  171. (define_insn ""
  172.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  173.     (eq:SI (reg:SI 18)
  174.            (const_int 1)))]
  175.   ""
  176.   "movt    %0 !movt1")
  177.  
  178. (define_insn ""
  179.   [(set (reg:SI 18) (gt:SI (match_operand:SI 0 "arith_reg_operand" "r")
  180.                (const_int 0)))]
  181.   ""
  182.   "cmp/pl    %0")
  183.  
  184. (define_insn ""
  185.   [(set (reg:SI 18) (ge:SI (match_operand:SI 0 "arith_reg_operand" "r")
  186.                (const_int 0)))]
  187.   ""
  188.   "cmp/pz    %0")
  189.  
  190. (define_insn "cmpeq_0"
  191.   [(set (reg:SI 18) (eq:SI (match_operand:SI 0 "arith_reg_operand" "r")
  192.                (const_int 0)))]
  193.   ""
  194.   "tst    %0,%0 ! t0")
  195.  
  196. (define_insn "cmpeqsi_t"
  197.   [(set (reg:SI 18) (eq:SI (match_operand:SI 0 "arith_operand" "r,N,z,r")
  198.                (match_operand:SI 1 "arith_operand" "N,r,rI,r")))]
  199.   ""
  200.   "@
  201.     tst    %0,%0 !t1
  202.     tst    %1,%1 !t2
  203.     cmp/eq    %1,%0
  204.     cmp/eq    %1,%0")
  205.  
  206. (define_insn "cmpgtsi_t"
  207.   [(set (reg:SI 18) (gt:SI (match_operand:SI 0 "arith_reg_operand" "r,r")
  208.                (match_operand:SI 1 "arith_operand" "N,r")))]
  209.   ""
  210.   "@
  211.     cmp/pl    %0
  212.     cmp/gt    %1,%0")
  213.  
  214. (define_insn "cmpgesi_t"
  215.   [(set (reg:SI 18) (ge:SI (match_operand:SI 0 "arith_reg_operand" "r,r")
  216.                (match_operand:SI 1 "arith_operand" "N,r")))]
  217.   ""
  218.   "@
  219.     cmp/pz    %0
  220.     cmp/ge    %1,%0")
  221.  
  222.  
  223. ;; -------------------------------------------------------------------------
  224. ;; SImode unsigned integer comparisons
  225. ;; -------------------------------------------------------------------------
  226.  
  227. (define_insn "cmpgeusi_t"
  228.   [(set (reg:SI 18) (geu:SI (match_operand:SI 0 "arith_reg_operand" "r,r")
  229.                 (match_operand:SI 1 "arith_operand" "N,r")))]
  230.   ""
  231.   "@
  232.     cmp/pz    %1
  233.     cmp/hs    %1,%0")
  234.  
  235. (define_insn "cmpgtusi_t"
  236.   [(set (reg:SI 18) (gtu:SI (match_operand:SI 0 "arith_operand" "r,r")
  237.                 (match_operand:SI 1 "arith_operand" "N,r")))]
  238.   ""
  239.   "@
  240.     cmp/pl    %1
  241.     cmp/hi    %1,%0")
  242.  
  243. ;; We save the compare operands in the cmpxx patterns and use them when
  244. ;; we generate the branch.
  245.  
  246. (define_expand "cmpsi"
  247.   [(set (reg:SI 18) (compare (match_operand:SI 0 "arith_operand" "")
  248.                  (match_operand:SI 1 "arith_operand" "")))]
  249.   ""
  250.   "
  251. {
  252.   sh_compare_op0 = operands[0];
  253.   sh_compare_op1 = operands[1];
  254.   DONE;
  255. }")
  256.  
  257.  
  258. ;; -------------------------------------------------------------------------
  259. ;; Addition instructions
  260. ;; -------------------------------------------------------------------------
  261.  
  262. (define_insn "addc"
  263.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  264.     (plus:SI (reg:SI 18)
  265.          (plus:SI (match_operand:SI 1 "arith_reg_operand" "%0")
  266.               (match_operand:SI 2 "arith_reg_operand" "r"))))
  267.    (set (reg:SI 18) (gt:SI (match_dup 1) (match_dup 0)))]
  268.   ""
  269.   "addc    %2,%0")
  270.  
  271.  
  272. ;; this should be a define split.
  273.  
  274. (define_expand "adddi3"
  275.   [(set (match_operand:DI 0 "register_operand" "")
  276.     (plus:DI (match_operand:DI 1 "register_operand" "")
  277.          (match_operand:DI 2 "register_operand" "")))]
  278.   ""
  279.   "
  280. {
  281.   rtx low_a = gen_rtx (SUBREG, SImode, operands[1], 1);
  282.   rtx low_b = gen_rtx (SUBREG, SImode, operands[2], 1);
  283.   rtx low_s = gen_rtx (SUBREG, SImode, operands[0], 1);
  284.  
  285.   rtx high_a = gen_rtx (SUBREG, SImode, operands[1], 0);
  286.   rtx high_b = gen_rtx (SUBREG, SImode, operands[2], 0);
  287.   rtx high_s = gen_rtx (SUBREG, SImode, operands[0], 0);
  288.  
  289.   emit_insn (gen_clrt ());
  290.   emit_insn (gen_addc (low_s, low_a, low_b));
  291.   emit_insn (gen_addc (high_s, high_a, high_b));
  292.  
  293.   DONE;
  294. }")
  295.  
  296. (define_insn "addsi3_real"
  297.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  298.     (plus:SI (match_operand:SI 1 "arith_reg_operand" "%0")
  299.          (match_operand:SI 2 "arith_operand" "rI")))]
  300.   ""
  301.   "add    %2,%0"
  302.   [(set_attr "length" "2")
  303.    (set_attr "type" "arith")])
  304.  
  305. (define_expand "addsi3"
  306.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  307.     (plus:SI (match_operand:SI 1 "arith_operand" "%0")
  308.          (match_operand:SI 2 "arith_operand" "rI")))]
  309.   ""
  310.   "")
  311.  
  312.  
  313. ;; -------------------------------------------------------------------------
  314. ;; Subtraction instructions
  315. ;; -------------------------------------------------------------------------
  316.  
  317. (define_insn "subdi3"
  318.   [(set (match_operand:DI 0 "arith_reg_operand" "=r")
  319.     (minus:DI (match_operand:DI 1 "arith_reg_operand" "0")
  320.           (match_operand:DI 2 "arith_reg_operand" "r")))
  321.    (clobber (reg:SI 18))]
  322.   ""
  323.   "clrt\;subc    %R2,%R0\;subc    %2,%0"
  324.   [(set_attr "length" "6")
  325.    (set_attr "in_delay_slot" "no")
  326.    (set_attr "type" "arith")])
  327.  
  328. (define_insn "subsi3"
  329.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  330.     (minus:SI (match_operand:SI 1 "arith_reg_operand" "0")
  331.           (match_operand:SI 2 "arith_operand" "r")))]
  332.   ""
  333.   "sub    %2,%0"
  334.   [(set_attr "type" "arith")])
  335.  
  336.  
  337. ;; -------------------------------------------------------------------------
  338. ;; Division instructions
  339. ;; -------------------------------------------------------------------------
  340.  
  341.  
  342. ;; we take advantage of the library routines which don't clobber as many
  343. ;; registers as a normal function call would.
  344.  
  345.  
  346. (define_insn ""
  347.   [(set (reg:SI 0)
  348.     (udiv:SI (reg:SI 4) (reg:SI 5)))
  349.    (clobber (reg:SI 18))
  350.    (clobber (reg:SI 17))
  351.    (clobber (reg:SI 6))
  352.    (clobber (reg:SI 4))
  353.    (use (match_operand:SI 0 "register_operand" "r"))]
  354.   ""
  355.   "jsr    @%0%#"
  356.   [(set_attr "type" "sfunc")
  357.    (set_attr "length" "4")
  358.    (set_attr "needs_delay_slot" "yes")])
  359.  
  360. (define_expand "udivsi3"
  361.   [(set (reg:SI 4) (match_operand:SI 1 "general_operand" "g"))
  362.    (set (reg:SI 5) (match_operand:SI 2 "general_operand" "g"))
  363.    (set (match_dup 3) (symbol_ref:SI "__udivsi3"))
  364.    (parallel[(set (reg:SI 0)
  365.           (udiv:SI (reg:SI 4)
  366.                (reg:SI 5)))
  367.          (clobber (reg:SI 18))
  368.          (clobber (reg:SI 17))
  369.          (clobber (reg:SI 6))
  370.          (clobber (reg:SI 4))
  371.          (use (match_dup 3))])
  372.    (set (match_operand:SI 0 "general_operand" "=g") 
  373.     (reg:SI 0))]
  374.   ""
  375.   "operands[3] = gen_reg_rtx(SImode);")
  376.  
  377.  
  378. (define_insn ""
  379.   [(set (reg:SI 0)
  380.     (div:SI (reg:SI 4) (reg:SI 5)))
  381.    (clobber (reg:SI 18))
  382.    (clobber (reg:SI 17))
  383.    (clobber (reg:SI 4))
  384.    (clobber (reg:SI 3))
  385.    (use (match_operand:SI 0 "register_operand" "r"))]
  386.   ""
  387.   "jsr    @%0%#"
  388.   [(set_attr "type" "sfunc")
  389.    (set_attr "length" "4")
  390.    (set_attr "needs_delay_slot" "yes")])
  391.  
  392. (define_expand "divsi3"
  393.   [(set (reg:SI 4) (match_operand:SI 1 "general_operand" "g"))
  394.    (set (reg:SI 5) (match_operand:SI 2 "general_operand" "g"))
  395.    (set (match_dup 3) (symbol_ref:SI "__sdivsi3"))
  396.    (parallel[(set (reg:SI 0)
  397.           (div:SI (reg:SI 4)
  398.                (reg:SI 5)))
  399.          (clobber (reg:SI 18))
  400.          (clobber (reg:SI 17))
  401.          (clobber (reg:SI 4))
  402.          (clobber (reg:SI 3))
  403.          (use (match_dup 3))])
  404.    (set (match_operand:SI 0 "general_operand" "=g") 
  405.     (reg:SI 0))]
  406.   ""
  407.   "operands[3] = gen_reg_rtx(SImode);")
  408.         
  409.  
  410. ;; -------------------------------------------------------------------------
  411. ;; Multiplication instructions
  412. ;; -------------------------------------------------------------------------
  413.  
  414. (define_insn ""
  415.   [(set (reg:SI 21)
  416.     (mult:SI (zero_extend:SI (match_operand:HI 1 "arith_reg_operand" "r"))
  417.          (zero_extend:SI (match_operand:HI 2 "arith_reg_operand" "r"))))]
  418.   ""
  419.   "mulu    %2,%1"
  420.   [(set_attr "type" "smpy")])
  421.  
  422. (define_insn ""
  423.   [(set (reg:SI 21)
  424.     (mult:SI (sign_extend:SI
  425.           (match_operand:HI 1 "arith_reg_operand" "r"))
  426.          (sign_extend:SI
  427.           (match_operand:HI 2 "arith_reg_operand" "r"))))]
  428.   ""
  429.   "muls    %2,%1"
  430.   [(set_attr "type" "smpy")])
  431.  
  432. (define_expand "mulhisi3"
  433.   [(set (reg:SI 21)
  434.     (mult:SI (sign_extend:SI
  435.           (match_operand:HI 1 "mac_operand" "r"))
  436.          (sign_extend:SI
  437.           (match_operand:HI 2 "mac_operand" "r"))))
  438.    (set (match_operand:SI 0 "arith_reg_operand" "=r")
  439.     (reg:SI 21))]
  440.   ""
  441.   "")
  442.  
  443. (define_expand "umulhisi3"
  444.   [(set (reg:SI 21)
  445.     (mult:SI (zero_extend:SI
  446.           (match_operand:HI 1 "arith_reg_operand" "r"))
  447.          (zero_extend:SI
  448.           (match_operand:HI 2 "arith_reg_operand" "r"))))
  449.    (set (match_operand:SI 0 "arith_reg_operand" "=r")
  450.     (reg:SI 21))]
  451.   ""
  452.   "")
  453.  
  454. ;; mulsi3 on the SH2 can be done in one instruction, on the SH1 we generate
  455. ;; a call to a routine which clobbers known registers.
  456.  
  457. (define_insn ""
  458.   [(set (reg:SI 0)
  459.     (mult:SI (reg:SI 4) (reg:SI 5)))
  460.    (clobber (reg:SI 21))
  461.    (clobber (reg:SI 18))
  462.    (clobber (reg:SI 17))
  463.    (clobber (reg:SI 3))
  464.    (clobber (reg:SI 2))
  465.    (clobber (reg:SI 1))
  466.    (use (match_operand:SI 0 "register_operand" "r"))]
  467.   ""
  468.   "jsr    @%0%#"
  469.   [(set_attr "type" "sfunc")
  470.    (set_attr "length" "4")
  471.    (set_attr "needs_delay_slot" "yes")])
  472.  
  473. (define_expand "mulsi3_call"
  474.   [(set (reg:SI 4) (match_operand:SI 1 "general_operand" "g"))
  475.    (set (reg:SI 5) (match_operand:SI 2 "general_operand" "g"))
  476.    (set (match_dup 3) (symbol_ref:SI "__mulsi3"))
  477.    (parallel[(set (reg:SI 0)
  478.           (mult:SI (reg:SI 4)
  479.                (reg:SI 5)))
  480.          (clobber (reg:SI 21))
  481.          (clobber (reg:SI 18))
  482.          (clobber (reg:SI 17))
  483.          (clobber (reg:SI 3))
  484.          (clobber (reg:SI 2))
  485.          (clobber (reg:SI 1))
  486.          (use (match_dup 3))])
  487.    (set (match_operand:SI 0 "general_operand" "=g") 
  488.     (reg:SI 0))]
  489.   ""
  490.   "operands[3] = gen_reg_rtx(SImode);")
  491.     
  492. (define_insn "mul_l"
  493.   [(set (reg:SI 21)
  494.     (mult:SI (match_operand:SI 0 "arith_reg_operand" "r")
  495.          (match_operand:SI 1 "arith_reg_operand" "r")))]
  496.   "TARGET_SH2"
  497.   "mul.l    %1,%0"
  498.   [(set_attr "type" "smpy")])
  499.  
  500. (define_expand "mulsi3"
  501.   [(set (reg:SI 21)
  502.     (mult:SI  (match_operand:SI 1 "arith_reg_operand" "r")
  503.           (match_operand:SI 2 "arith_reg_operand" "r")))
  504.    (set (match_operand:SI 0 "arith_reg_operand" "=r")
  505.     (reg:SI 21))]
  506.   "TARGET_SH2"
  507.   "
  508. {
  509.   if (!TARGET_SH2)
  510.     {
  511.       emit_insn (gen_mulsi3_call (operands[0], operands[1], operands[2])); 
  512.       DONE; 
  513.     } 
  514. }")
  515.  
  516. (define_insn ""
  517.   [(set (reg:DI 20)
  518.     (mult:DI (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))
  519.          (sign_extend:DI (match_operand:SI 2 "arith_reg_operand" "r"))))]
  520.   "TARGET_SH2"
  521.   "dmuls.l    %2,%1"
  522.   [(set_attr "type" "dmpy")])
  523.  
  524. (define_expand "mulsidi3"
  525.   [(set (reg:DI 20)
  526.     (mult:DI (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))
  527.          (sign_extend:DI (match_operand:SI 2 "arith_reg_operand" "r"))))
  528.    (set (match_operand:DI 0 "arith_reg_operand" "=r")
  529.     (reg:DI 20))]
  530.   "TARGET_SH2"
  531.   "")
  532.  
  533. (define_insn ""
  534.   [(set (reg:DI 20)
  535.     (mult:DI (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))
  536.          (zero_extend:DI (match_operand:SI 2 "arith_reg_operand" "r"))))]
  537.   "TARGET_SH2"
  538.   "dmulu.l    %2,%1"
  539.   [(set_attr "type" "dmpy")])
  540.  
  541. (define_expand "umulsidi3"
  542.   [(set (reg:DI 20)
  543.     (mult:DI (zero_extend:DI (match_operand:SI 1 "arith_reg_operand" "r"))
  544.          (zero_extend:DI (match_operand:SI 2 "arith_reg_operand" "r"))))
  545.    (set (match_operand:DI 0 "arith_reg_operand" "=r")
  546.     (reg:DI 20))]
  547.   "TARGET_SH2"
  548.   "")
  549.  
  550.  
  551. ;; -------------------------------------------------------------------------
  552. ;; Logical operations
  553. ;; -------------------------------------------------------------------------
  554.  
  555. (define_insn "and_ffff"
  556.  [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  557.        (and:SI (match_operand:SI 1 "arith_reg_operand" "r")
  558.            (const_int 65535)))]
  559.  ""
  560.  "extu.w    %1,%0"
  561.  [(set_attr "type" "arith")])
  562.  
  563. (define_insn "and_ff"
  564.  [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  565.        (and:SI (match_operand:SI 1 "arith_reg_operand" "r")
  566.            (const_int 255)))]
  567.  ""
  568.  "extu.b    %1,%0"
  569.  [(set_attr "type" "arith")])
  570.    
  571. (define_insn ""
  572.   [(set (match_operand:SI 0 "arith_reg_operand" "=r,z")
  573.     (and:SI (match_operand:SI 1 "arith_reg_operand" "%0,0")
  574.         (match_operand:SI 2 "logical_operand" "r,L")))]
  575.   ""
  576.   "and    %2,%0"
  577.   [(set_attr "type" "arith")])
  578.  
  579. (define_expand "andsi3"
  580.   [(set (match_operand:SI 0 "arith_reg_operand" "")
  581.     (and:SI (match_operand:SI 1 "arith_reg_operand" "")
  582.         (match_operand:SI 2 "logical_operand" "")))]
  583.   ""
  584.   "")
  585.  
  586. (define_insn "iorsi3"
  587.   [(set (match_operand:SI 0 "arith_reg_operand" "=r,z")
  588.     (ior:SI (match_operand:SI 1 "arith_reg_operand" "%0,0")
  589.         (match_operand:SI 2 "logical_operand" "r,L")))]
  590.   ""
  591.   "or    %2,%0")
  592.  
  593. (define_insn "xorsi3"
  594.   [(set (match_operand:SI 0 "arith_reg_operand" "=z,r")
  595.     (xor:SI (match_operand:SI 1 "arith_reg_operand" "%0,0")
  596.         (match_operand:SI 2 "logical_operand" "L,r")))]
  597.   ""
  598.   "xor    %2,%0"
  599.   [(set_attr "type" "arith")])
  600.  
  601.  
  602. ;; -------------------------------------------------------------------------
  603. ;; Shifts and rotates
  604. ;; -------------------------------------------------------------------------
  605.  
  606. (define_insn "rotlsi3_k"
  607.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  608.     (rotate:SI (match_operand:SI 1 "arith_reg_operand" "0")
  609.            (const_int 1)))
  610.    (clobber (reg:SI 18))]
  611.   ""
  612.   "rotl    %0")
  613.  
  614. (define_expand "rotlsi3"
  615.   [(parallel[(set (match_operand:SI 0 "arith_reg_operand" "")
  616.           (rotate:SI (match_operand:SI 1 "arith_reg_operand" "")
  617.                  (match_operand:SI 2 "immediate_operand" "")))
  618.          (clobber (reg:SI 18))])]
  619.   ""
  620.   "{ if (GET_CODE(operands[2]) != CONST_INT || INTVAL(operands[2]) != 1) FAIL;}")
  621.  
  622. (define_insn "rotrsi3_k"
  623.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  624.     (rotatert:SI (match_operand:SI 1 "arith_reg_operand" "0")
  625.              (const_int 1)))
  626.    (clobber (reg:SI 18))]
  627.   ""
  628.   "rotr    %0")
  629.  
  630. (define_expand "rotrsi3"
  631.   [(parallel[(set (match_operand:SI 0 "arith_reg_operand" "")
  632.            (rotatert:SI (match_operand:SI 1 "arith_reg_operand" "")
  633.                 (match_operand:SI 2 "immediate_operand" "")))
  634.           (clobber (reg:SI 18))])]
  635.   ""
  636.   "{ if (GET_CODE(operands[2]) != CONST_INT || INTVAL(operands[2]) != 1) FAIL;}")
  637.  
  638.  
  639. ;;
  640. ;; shift left
  641.  
  642. (define_insn "ashlsi3_k"
  643.   [(set (match_operand:SI 0 "arith_reg_operand" "=r,r")
  644.     (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0,0")
  645.            (match_operand:SI 2 "immediate_operand" "M,K")))
  646.    (clobber (reg:SI 18))]
  647.   "CONST_OK_FOR_K (INTVAL (operands[2]))"
  648.   "@
  649.     shll    %0
  650.     shll%O2    %0")
  651.  
  652. ; seperate pattern for shifts by any N.  Look at pnum_clobbers
  653. ; to see if this is being recognised inside combine.  If so, dont
  654. ; match, since combine will try and merge shifts, which will break
  655. ; scheduling
  656.  
  657. (define_insn "ashlsi3_n"
  658.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  659.     (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0")
  660.            (match_operand:SI 2 "immediate_operand" "n")))
  661.    (clobber (reg:SI 18))]
  662.   ""
  663.   "*return output_shift(\"shll\", operands[0], operands[2], ASHIFT);"
  664.   [(set_attr "length" "12")
  665.    (set_attr "in_delay_slot" "no")
  666.    (set_attr "type" "arith")])
  667.  
  668. (define_expand "ashlsi3"
  669.   [(parallel[(set (match_operand:SI 0 "arith_reg_operand" "")
  670.           (ashift:SI (match_operand:SI 1 "arith_reg_operand" "")
  671.                  (match_operand:SI 2 "immediate_operand" "")))
  672.          (clobber (reg:SI 18))])]
  673.   ""
  674.   "if (gen_shifty_op (ASHIFT, operands)) DONE; else FAIL;")
  675.  
  676. ;
  677. ; arithmetic shift right
  678. ;
  679.  
  680. (define_insn "ashrsi3_k"
  681.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  682.     (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
  683.              (match_operand:SI 2 "immediate_operand" "M")))
  684.    (clobber (reg:SI 18))]
  685.   "INTVAL(operands[2]) == 1"
  686.   "shar    %0"
  687.   [(set_attr "type" "arith")])
  688.  
  689. (define_insn "ashrsi3_16"
  690.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  691.     (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
  692.              (match_operand:SI 2 "immediate_operand" "i")))
  693.    (clobber (reg:SI 18))]
  694.   "INTVAL(operands[2]) == 16"
  695.   "shlr16    %0\;exts.w    %0,%0"
  696.   [(set_attr "type" "arith")
  697.    (set_attr "length" "4")])
  698.  
  699. ; an arithmetic shift right by 16 is better as a logical shift and a 
  700. ; sign extend
  701.  
  702. ;(define_split 
  703. ;  [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  704. ;    (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
  705. ;             (const_int 16)))
  706. ;   (clobber (reg:SI 18))]
  707. ;  ""
  708. ;  [(set (match_dup 3) (match_dup 0))
  709. ;    (set (match_dup 3) (lshiftrt:SI (match_dup 3) (const_int 16)))
  710. ;    (set (match_dup 0) (sign_extend:SI (subreg:HI (match_dup 3) 0)))]
  711. ;  "operands[3] = gen_reg_rtx (SImode);")
  712.  
  713. (define_insn "ashrsi3_n"
  714.   [(set (reg:SI 4)
  715.     (ashiftrt:SI (reg:SI 4)
  716.              (match_operand:SI 0 "immediate_operand" "i")))
  717.    (clobber (reg:SI 18))
  718.    (clobber (reg:SI 17))
  719.    (use (match_operand:SI 1 "arith_reg_operand" "r"))]
  720.   ""
  721.   "jsr    @%1%#"
  722.   [(set_attr "type" "sfunc")
  723.    (set_attr "in_delay_slot" "no")
  724.    (set_attr "length" "4")
  725.    (set_attr "needs_delay_slot" "yes")])
  726.  
  727. (define_expand "ashrsi3"
  728.   [(parallel[(set (match_operand:SI 0 "arith_reg_operand" "=r")
  729.           (ashiftrt:SI (match_operand:SI 1 "arith_reg_operand" "r")
  730.                    (match_operand:SI 2 "nonmemory_operand" "M")))
  731.          (clobber (reg:SI 18))])]
  732.   ""
  733.   "if (gen_shifty_op (ASHIFTRT, operands)) DONE; else FAIL;")
  734.  
  735. ; logical shift right
  736. ;
  737.  
  738. (define_insn "lshrsi3_k"
  739.   [(set (match_operand:SI 0 "arith_reg_operand" "=r,r")
  740.     (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0,0")
  741.              (match_operand:SI 2 "immediate_operand" "M,K")))
  742.    (clobber (reg:SI 18))]
  743.   "CONST_OK_FOR_K (INTVAL (operands[2]))"
  744.   "@
  745.     shlr    %0
  746.     shlr%O2    %0")
  747.  
  748. ; seperate pattern for shifts by any N. 
  749.  
  750. (define_insn "lshrsi3_n"
  751.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  752.     (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "0")
  753.              (match_operand:SI 2 "immediate_operand" "n")))
  754.    (clobber (reg:SI 18))]
  755.   ""
  756.   "* return output_shift (\"shlr\", operands[0], operands[2], LSHIFTRT);"
  757.   [(set_attr "length" "12")
  758.    (set_attr "in_delay_slot" "no")
  759.    (set_attr "type" "arith")])
  760.  
  761. (define_expand "lshrsi3"
  762.   [(parallel[(set (match_operand:SI 0 "arith_reg_operand" "")
  763.           (lshiftrt:SI (match_operand:SI 1 "arith_reg_operand" "")
  764.                    (match_operand:SI 2 "immediate_operand" "")))
  765.          (clobber (reg:SI 18))])]
  766.   ""
  767.   "if (gen_shifty_op (LSHIFTRT, operands)) DONE; else FAIL;") 
  768.  
  769. (define_insn "ashldi3_k"
  770.   [(set (match_operand:DI 0 "arith_reg_operand" "=r")
  771.     (ashift:DI (match_operand:DI 1 "arith_reg_operand" "0")
  772.            (match_operand:DI 2 "immediate_operand" "I")))
  773.    (clobber (reg:SI 18))]
  774.   ""
  775.   "shll    %R0\;rotcl    %0"
  776.   [(set_attr "length" "4")])
  777.  
  778. (define_expand "ashldi3"
  779.   [(parallel[(set (match_operand:DI 0 "arith_reg_operand" "")
  780.           (ashift:DI (match_operand:DI 1 "arith_reg_operand" "")
  781.                  (match_operand:DI 2 "immediate_operand" "")))
  782.          (clobber (reg:SI 18))])]
  783.         
  784.   ""
  785.   "{ if (GET_CODE (operands[2]) != CONST_INT     
  786.     || INTVAL (operands[2]) != 1) FAIL;} ")
  787.  
  788. (define_insn "lshrdi3_k"
  789.   [(set (match_operand:DI 0 "arith_reg_operand" "=r")
  790.     (lshiftrt:DI (match_operand:DI 1 "arith_reg_operand" "0")
  791.              (match_operand:DI 2 "immediate_operand" "I")))
  792.    (clobber (reg:SI 18))]
  793.   ""
  794.   "shlr    %0\;rotcr    %R0"
  795.   [(set_attr "length" "4")])
  796.  
  797. (define_expand "lshrdi3"
  798.   [(parallel[(set (match_operand:DI 0 "arith_reg_operand" "")
  799.           (lshiftrt:DI (match_operand:DI 1 "arith_reg_operand" "")
  800.                    (match_operand:DI 2 "immediate_operand" "")))
  801.          (clobber (reg:SI 18))])]
  802.   ""
  803.   "{ if (GET_CODE (operands[2]) != CONST_INT 
  804.     || INTVAL (operands[2]) != 1) FAIL;} ")
  805.  
  806. (define_insn "ashrdi3_k"
  807.   [(set (match_operand:DI 0 "arith_reg_operand" "=r")
  808.     (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "0")
  809.              (match_operand:DI 2 "immediate_operand" "")))
  810.    (clobber (reg:SI 18))]
  811.   ""
  812.   "shar    %0\;rotcr    %R0"
  813.   [(set_attr "length" "4")])
  814.  
  815. (define_expand "ashrdi3"
  816.   [(parallel[(set (match_operand:DI 0 "arith_reg_operand" "")
  817.           (ashiftrt:DI (match_operand:DI 1 "arith_reg_operand" "")
  818.                    (match_operand:DI 2 "immediate_operand" "")))
  819.          (clobber (reg:SI 18))])]
  820.   ""
  821.   "{ if (GET_CODE (operands[2]) != CONST_INT 
  822.     || INTVAL (operands[2]) != 1) FAIL; } ")
  823.  
  824.  
  825. ;; -------------------------------------------------------------------------
  826. ;; Unary arithmetic
  827. ;; -------------------------------------------------------------------------
  828.  
  829. (define_insn "negdi2"
  830.   [(set (match_operand:DI 0 "arith_reg_operand" "=&r")
  831.     (neg:DI (match_operand:DI 1 "arith_reg_operand" "0")))
  832.    (clobber (reg:SI 18))]
  833.   ""
  834.   "clrt\;negc    %R1,%R0\;negc    %1,%0"
  835.   [(set_attr "length" "6")
  836.    (set_attr "type" "arith")])
  837.  
  838. (define_insn "negsi2"
  839.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  840.     (neg:SI (match_operand:SI 1 "arith_reg_operand" "r")))]
  841.   ""
  842.   "neg    %1,%0"
  843.   [(set_attr "type" "arith")])
  844.  
  845. (define_insn "one_cmplsi2"
  846.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  847.     (not:SI (match_operand:SI 1 "arith_reg_operand" "r")))]
  848.   ""
  849.   "not    %1,%0"
  850.   [(set_attr "type" "arith")])
  851.  
  852.  
  853. ;; -------------------------------------------------------------------------
  854. ;; Zero extension instructions
  855. ;; -------------------------------------------------------------------------
  856.  
  857. (define_insn "zero_extendhisi2"
  858.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  859.     (zero_extend:SI (match_operand:HI 1 "arith_reg_operand" "r")))]
  860.   ""
  861.   "extu.w    %1,%0"
  862.   [(set_attr "type" "arith")])
  863.  
  864. (define_insn "zero_extendqisi2"
  865.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  866.     (zero_extend:SI (match_operand:QI 1 "arith_reg_operand" "r")))]
  867.   ""
  868.   "extu.b    %1,%0"
  869.   [(set_attr "type" "arith")]) 
  870.  
  871. (define_insn "zero_extendqihi2"
  872.   [(set (match_operand:HI 0 "arith_reg_operand" "=r")
  873.     (zero_extend:HI (match_operand:QI 1 "arith_reg_operand" "r")))]
  874.   ""
  875.   "extu.b    %1,%0"
  876.   [(set_attr "type" "arith")]) 
  877.  
  878.  
  879. ;; -------------------------------------------------------------------------
  880. ;; Sign extension instructions
  881. ;; -------------------------------------------------------------------------
  882.  
  883. (define_insn "extendsidi2"
  884.   [(set (match_operand:DI 0 "arith_reg_operand" "=r,r")
  885.     (sign_extend:DI (match_operand:SI 1 "arith_reg_operand" "0,r")))
  886.    (clobber (reg:SI 18))]
  887.   ""
  888.   "@
  889.     mov    %1,%0\;shll    %0\;subc    %0,%0 ! b sidi2
  890.     mov    %1,%0\;mov    %1,%R0\;shll    %0\;subc    %0,%0 ! a sidi2"
  891.   [(set_attr "length" "6,8")]) 
  892.  
  893. (define_insn "extendhisi2"
  894.   [(set (match_operand:SI 0 "arith_reg_operand" "=r,z,r")
  895.     (sign_extend:SI (match_operand:HI 1 "arith_operand" "r,u,m")))]
  896.   ""
  897.   "@
  898.     exts.w    %1,%0
  899.        mov.w    %1,%0
  900.        mov.w    %1,%0"
  901.   [(set_attr "type" "arith,load,load")])
  902.  
  903. (define_insn "extendqisi2"
  904.   [(set (match_operand:SI 0 "arith_reg_operand" "=r,z,r")
  905.     (sign_extend:SI (match_operand:QI 1 "general_movsrc_operand" "r,U,m")))]
  906.   ""
  907.   "@
  908.     exts.b    %1,%0
  909.     mov.b    %1,%0 !p9
  910.     mov.b    %1,%0 !p8"
  911.   [(set_attr "type" "arith,load,load")])
  912.  
  913. (define_insn "extendqihi2"
  914.   [(set (match_operand:HI 0 "arith_reg_operand" "=r,z,r")
  915.     (sign_extend:HI (match_operand:QI 1 "general_movsrc_operand" "r,U,m")))]
  916.   ""
  917.   "@
  918.     exts.b    %1,%0
  919.     mov.b    %1,%0  !p7
  920.     mov.b    %1,%0 ! p6"
  921.   [(set_attr "type" "arith,load,load")])
  922.  
  923.  
  924. ;; -------------------------------------------------------------------------
  925. ;; Move instructions
  926. ;; -------------------------------------------------------------------------
  927.  
  928. ;; define push and pop so it is easy for sh.c
  929.  
  930. (define_insn "push"
  931.   [(set (mem:SI (pre_dec:SI (reg:SI 15)))
  932.     (match_operand:SI 0 "register_operand" "r,lx"))]
  933.   ""
  934.   "@
  935.     mov.l    %0,@-r15
  936.     sts.l    %0,@-r15 ! push"
  937.   [(set_attr "type" "store")
  938.    (set_attr "hit_stack" "yes")])
  939.  
  940. (define_insn "pop"
  941.   [(set (match_operand:SI 0 "register_operand" "=r,lx")
  942.     (mem:SI (post_inc:SI (reg:SI 15))))]
  943.   ""
  944.   "@
  945.     mov.l    @r15+,%0
  946.     lds.l    @r15+,%0"
  947.   [(set_attr "type" "load,pload")
  948.    (set_attr "hit_stack" "yes")])
  949.  
  950. (define_insn ""
  951.   [(set (match_operand:SI 0 "push_operand" "=<,<")
  952.     (match_operand:SI 1 "arith_reg_operand" "r,xl"))]
  953.   ""
  954.   "@
  955.     mov.l    %1,%0
  956.     sts.l    %1,%0"
  957.   [(set_attr "type" "store")])
  958.  
  959. (define_insn ""
  960.   [(set    (match_operand:SI 0 "arith_reg_operand" "=r,xl")
  961.     (match_operand:SI 1 "pop_operand" "=>,>"))]
  962.   ""
  963.   "@
  964.     mov.l    %1,%0
  965.     lds.l    %1,%0"
  966.   [(set_attr "type" "load")])
  967.  
  968. (define_insn "clrt"
  969.   [(set (reg:SI 18) (const_int 0))]
  970.   ""
  971.   "clrt")
  972.  
  973. ;(define_insn "movsi_pi"
  974. ;  [(set (match_operand:SI 0 "general_movdst_operand" "=r")
  975. ;    (mem:SI (post_inc (match_operand:SI 1 "register_operand" "r"))))]
  976. ;  ""
  977. ;  "mov.l    @%1,%0\;add    #4,%1"
  978. ;  [(set_attr "length" "4")])
  979.  
  980.  
  981. (define_insn "movsi_i"
  982.   [(set (match_operand:SI 0 "general_movdst_operand" "=r,r,r,r,r,<m,<,xl,xl,t,r")
  983.     (match_operand:SI 1 "general_movsrc_operand" "Q,rI,>m,xl,t,r,xl,r,>,r,i"))]
  984.   ""
  985.   "*
  986. {
  987.   switch (which_alternative)
  988.     {
  989.     case 0:
  990.       switch (get_attr_length(insn)) 
  991.     {
  992.     case 2:
  993.       return \"mov.l    %1,%0\";
  994.     case 12:
  995.       return \"mov.l    TA%*,%0\;bra    TB%*\;mov.l    @%0,%0\;.align 2\;TA%*: .long %1\;TB%*:%^\";
  996.     }
  997.     case 1: return \"mov    %1,%0\";
  998.     case 2: return \"mov.l    %1,%0\";
  999.     case 3: return \"sts    %1,%0\";
  1000.     case 4: return \"movt    %0\";
  1001.     case 5: return \"mov.l    %1,%0\";
  1002.     case 6: return \"sts.l    %1,%0\";
  1003.     case 7: return \"lds    %1,%0\";
  1004.     case 8: return \"lds.l    %1,%0\";
  1005.     case 9: return \"tst    %1,%1\;bt    T%*\;bra    F%*\;sett\;T%*:clrt\;F%*:%^\";
  1006.     case 10: return \"fake %1,%0\";
  1007.     }
  1008. }"
  1009.   [(set_attr "length" "*,2,2,2,2,2,2,2,2,6,2")
  1010.    (set_attr "type" "pcloadsi,move,load,move,store,store,move,load,move,move,move")])
  1011.               
  1012. (define_expand "movsi"
  1013.   [(set (match_operand:SI 0 "general_movdst_operand" "")
  1014.     (match_operand:SI 1 "general_movsrc_operand" ""))]
  1015.   ""
  1016.  
  1017.   "{ if (prepare_move_operands(operands, SImode)) DONE; } ")
  1018.  
  1019.  
  1020. (define_insn "movqi_i"
  1021.   [(set (match_operand:QI 0 "general_movdst_operand" "=r,r,>m,r,r,l")
  1022.     (match_operand:QI 1 "general_movsrc_operand"  "ri,<m,r,t,l,r"))]
  1023.   "arith_reg_operand (operands[0], QImode) 
  1024.    || arith_reg_operand (operands[1], QImode)"
  1025.   "@
  1026.     mov    %1,%0
  1027.     mov.b    %1,%0
  1028.     mov.b    %1,%0
  1029.     movt    %0
  1030.     sts    %1,%0
  1031.     lds    %1,%0"
  1032.  [(set_attr "length" "2,2,2,2,2,2")
  1033.   (set_attr "type" "move,load,store,move,move,move")])
  1034.  
  1035. (define_expand "movqi"
  1036.   [(set (match_operand:QI 0 "general_operand" "")
  1037.     (match_operand:QI 1 "general_operand"  ""))]
  1038.   ""
  1039.   "if (prepare_move_operands(operands, QImode)) DONE; ")
  1040.  
  1041. (define_insn "movhi_i"
  1042.   [(set (match_operand:HI 0 "general_movdst_operand" "=r,r,r,r,<m,r,r,l")
  1043.     (match_operand:HI 1 "general_movsrc_operand" "Q,rI,>m,t,r,i,l,r"))]
  1044.   ""
  1045.   "*
  1046. {
  1047.   switch (which_alternative)
  1048.     {
  1049.     case 0:
  1050.       switch (get_attr_length(insn)) 
  1051.     {
  1052.     case 2:
  1053.       return \"mov.w    %1,%0\";
  1054.     case 12:
  1055.       return \"mov.l    TA%*,%0\;bra    TB%*\;mov.w    @%0,%0\;.align 2\;TA%*: .long %1\;TB%*:%^\";
  1056.     }
  1057.     case 1: return \"mov    %1,%0\";
  1058.     case 2: return \"mov.w    %1,%0\";
  1059.     case 3: return \"movt    %0\";
  1060.     case 4: return \"mov.w    %1,%0\";
  1061.     case 5: return \"fake %1,%0\";
  1062.     case 6: return \"sts    %1,%0\";
  1063.     case 7: return \"lds    %1,%0\";
  1064.     }
  1065. }"
  1066.   [(set_attr "length" "*,2,2,2,2,2,2,2")
  1067.    (set_attr "type" "pcloadhi,move,load,move,store,move,move,move")])
  1068.  
  1069. (define_expand "movhi"
  1070.   [(set (match_operand:HI 0 "general_movdst_operand" "")
  1071.     (match_operand:HI 1 "general_movsrc_operand"  ""))]
  1072.   ""
  1073.   "if (prepare_move_operands (operands, HImode)) DONE;")
  1074.  
  1075. (define_insn ""
  1076.   [(set (match_operand:DI 0 "push_operand" "=<")
  1077.     (match_operand:DI 1 "arith_reg_operand" "r"))]
  1078.    ""
  1079.    "mov.l    %R1,%0\;mov.l    %1,%0"
  1080.    [(set_attr "length" "4")
  1081.     (set_attr "type" "store")])
  1082.  
  1083. (define_insn ""
  1084.   [(set (match_operand:DI 0 "general_movdst_operand" "=r,r,r,m,r")
  1085.     (match_operand:DI 1 "general_movsrc_operand" "Q,r,m,r,i"))]
  1086.   "register_operand (operands[0], DImode)
  1087.   || register_operand (operands[1], DImode)"
  1088.   "* return output_movedouble (insn, operands, DImode);"
  1089.   [(set_attr "length" "*,4,4,4,4")
  1090.    (set_attr "type" "pcloadsi,move,load,store,move")])
  1091.  
  1092.  
  1093.     
  1094. (define_expand "movdi"
  1095.   [(set (match_operand:DI 0 "general_movdst_operand" "")
  1096.     (match_operand:DI 1 "general_movsrc_operand" ""))]
  1097.   ""
  1098.   "if ( prepare_move_operands(operands, DImode)) DONE; ")
  1099.  
  1100. (define_insn ""
  1101.   [(set (match_operand:DF 0 "push_operand" "=<")
  1102.     (match_operand:DF 1 "arith_reg_operand" "r"))]
  1103.    ""
  1104.   "mov.l    %R1,%0\;mov.l    %1,%0"
  1105.    [(set_attr "length" "4")
  1106.     (set_attr "type" "store")])
  1107.  
  1108. (define_insn "movdf_k"
  1109.   [(set (match_operand:DF 0 "general_movdst_operand" "=r,r,m")
  1110.     (match_operand:DF 1 "general_movsrc_operand" "r,m,r"))]
  1111.   "register_operand (operands[0], DFmode)
  1112.    || register_operand (operands[1], DFmode)"
  1113.   "* return output_movedouble (insn, operands, DFmode);"
  1114.   [(set_attr "length" "4")
  1115.    (set_attr "type" "move,load,store")])
  1116.  
  1117. (define_expand "movdf"
  1118.   [(set (match_operand:DF 0 "general_movdst_operand" "")
  1119.     (match_operand:DF 1 "general_movsrc_operand" ""))]
  1120.   ""
  1121.  "{ if (prepare_move_operands(operands, DFmode)) DONE; } ")
  1122.  
  1123. (define_insn ""
  1124.   [(set (match_operand:SF 0 "push_operand" "=<")
  1125.     (match_operand:SF 1 "arith_reg_operand" "r"))]
  1126.    ""
  1127.    "mov.l    %1,%0"
  1128.   [(set_attr "type" "store")])
  1129.         
  1130. (define_insn "movsf_i"
  1131.   [(set (match_operand:SF 0 "general_movdst_operand" "=>,r,r,r,r,m,l,r")
  1132.     (match_operand:SF 1 "general_movsrc_operand"  "r,<,r,I,m,r,r,l"))]
  1133.   ""
  1134.   "@
  1135.         mov.l    %1,@%N0\;add    #4,%N0 !bad
  1136.         add    #-4,%1\;mov.l    @%N1,%0 !bad
  1137.     mov    %1,%0
  1138.     mov    %1,%0
  1139.     mov.l    %1,%0
  1140.     mov.l    %1,%0
  1141.     lds    %1,%0
  1142.     sts    %1,%0"
  1143.   [(set_attr "type" "store,load,move,move,load,store,move,move")
  1144.    (set_attr "length" "4,4,*,*,*,*,*,*")])
  1145.  
  1146. (define_expand "movsf"
  1147.   [(set (match_operand:SF 0 "general_movdst_operand" "")
  1148.     (match_operand:SF 1 "general_movsrc_operand" ""))]
  1149.   ""
  1150.   "if (prepare_move_operands (operands, SFmode)) DONE;")
  1151.  
  1152.  
  1153. ;; ------------------------------------------------------------------------
  1154. ;; Define the real conditional branch instructions.
  1155. ;; ------------------------------------------------------------------------
  1156.  
  1157. (define_insn "branch_true"
  1158.   [(set (pc) (if_then_else (eq (reg:SI 18) (const_int 1))
  1159.                (label_ref (match_operand 0 "" ""))
  1160.                (pc)))]
  1161.   ""
  1162.   "* return output_branch (1, insn);"
  1163.   [(set_attr "type" "cbranch")])
  1164.  
  1165. (define_insn "branch_false"
  1166.   [(set (pc) (if_then_else (ne (reg:SI 18) (const_int 1))
  1167.                (label_ref (match_operand 0 "" ""))
  1168.                (pc)))]
  1169.   ""
  1170.   "* return output_branch (0, insn);"
  1171.   [(set_attr "type" "cbranch")])
  1172.  
  1173. (define_insn "inverse_branch_true"
  1174.   [(set (pc) (if_then_else (eq (reg:SI 18) (const_int 1))
  1175.                (pc)
  1176.                (label_ref (match_operand 0 "" ""))))]
  1177.   ""
  1178.   "* return output_branch (0, insn);"
  1179.   [(set_attr "type" "cbranch")])
  1180.  
  1181. (define_insn "inverse_branch_false"
  1182.   [(set (pc) (if_then_else (ne (reg:SI 18) (const_int 1))
  1183.                   (pc)
  1184.                (label_ref (match_operand 0 "" ""))))]
  1185.   ""
  1186.   "* return output_branch (1, insn);"
  1187.   [(set_attr "type" "cbranch")])
  1188.  
  1189.  
  1190. ;; Conditional branch insns
  1191.  
  1192. (define_expand "beq"
  1193.   [(set (reg:SI 18) (eq:SI (match_dup 1) (match_dup 2)))
  1194.    (set (pc)
  1195.     (if_then_else (eq (reg:SI 18)
  1196.               (const_int 1))
  1197.               (label_ref (match_operand 0 "" ""))
  1198.               (pc)))]
  1199.   ""
  1200.   "from_compare (operands, EQ);")
  1201.  
  1202. ; There is no bne compare, so we reverse the branch arms.
  1203.  
  1204. (define_expand "bne"
  1205.   [(set (reg:SI 18) (eq:SI (match_dup 1) (match_dup 2)))
  1206.    (set (pc)
  1207.     (if_then_else (eq (reg:SI 18)
  1208.               (const_int 1))
  1209.               (pc)
  1210.               (label_ref (match_operand 0 "" ""))))]
  1211.   ""
  1212.   "from_compare (operands, NE);")
  1213.  
  1214. (define_expand "bgt"
  1215.   [(set (reg:SI 18) (gt:SI (match_dup 1) (match_dup 2)))
  1216.    (set (pc)
  1217.     (if_then_else (eq (reg:SI 18)
  1218.               (const_int 1))
  1219.               (label_ref (match_operand 0 "" ""))
  1220.               (pc))) ]
  1221.   ""
  1222.   "from_compare (operands, GT);")
  1223.  
  1224. (define_expand "blt"
  1225.   [(set (reg:SI 18) (ge:SI (match_dup 1) (match_dup 2)))
  1226.    (set (pc)
  1227.     (if_then_else (eq (reg:SI 18)(const_int 1))
  1228.               (pc)
  1229.               (label_ref (match_operand 0 "" ""))))]
  1230.   ""
  1231.   "from_compare (operands, LT);")
  1232.  
  1233. (define_expand "ble"
  1234.   [(set (reg:SI 18) (gt:SI (match_dup 1) (match_dup 2)))
  1235.    (set (pc)
  1236.     (if_then_else (eq (reg:SI 18)
  1237.               (const_int 1))
  1238.               (pc)
  1239.               (label_ref (match_operand 0 "" ""))))
  1240.    ]
  1241.   ""
  1242.   "from_compare (operands, LE);")
  1243.  
  1244. (define_expand "bge"
  1245.   [(set (reg:SI 18) (ge:SI (match_dup 1) (match_dup 2)))
  1246.    (set (pc)
  1247.     (if_then_else (eq (reg:SI 18)
  1248.               (const_int 1))
  1249.               (label_ref (match_operand 0 "" ""))
  1250.               (pc))) ]
  1251.   ""
  1252.   "from_compare (operands, GE);")
  1253.  
  1254. (define_expand "bgtu"
  1255.   [(set (reg:SI 18) (gtu:SI (match_dup 1) (match_dup 2)))
  1256.    (set (pc)
  1257.     (if_then_else (eq (reg:SI 18)
  1258.               (const_int 1))
  1259.               (label_ref (match_operand 0 "" ""))
  1260.               (pc)))]
  1261.   ""
  1262.   "from_compare (operands, GTU); ")
  1263.  
  1264. (define_expand "bltu"
  1265.   [(set (reg:SI 18) (geu:SI (match_dup 1) (match_dup 2)))
  1266.    (set (pc)
  1267.           (if_then_else (eq (reg:SI 18)
  1268.                     (const_int 1))
  1269.                 (pc)
  1270.                 (label_ref (match_operand 0 "" ""))))]
  1271.   ""
  1272.   "from_compare (operands, LTU);")
  1273.  
  1274. (define_expand "bgeu"
  1275.   [(set (reg:SI 18) (geu:SI (match_dup 1) (match_dup 2)))
  1276.    (set (pc)
  1277.     (if_then_else (eq (reg:SI 18)
  1278.               (const_int 1))
  1279.               (label_ref (match_operand 0 "" ""))
  1280.               (pc)))
  1281.    ]
  1282.   ""
  1283.   "from_compare (operands, GEU);")
  1284.  
  1285. (define_expand "bleu"
  1286.   [(set (reg:SI 18) (gtu:SI (match_dup 1) (match_dup 2)))
  1287.    (set (pc)
  1288.     (if_then_else (eq (reg:SI 18)
  1289.               (const_int 1))
  1290.               (pc)
  1291.               (label_ref (match_operand 0 "" ""))))]
  1292.   ""
  1293.   "from_compare (operands, LEU);")
  1294.  
  1295.  
  1296. ;; ------------------------------------------------------------------------
  1297. ;; Jump and linkage insns
  1298. ;; ------------------------------------------------------------------------
  1299.  
  1300. (define_insn "jump"
  1301.   [(set (pc)
  1302.     (label_ref (match_operand 0 "" "")))]
  1303.   ""
  1304.   "*
  1305. {
  1306.   if (get_attr_length(insn) == 10) 
  1307.     {
  1308.       return output_far_jump(insn, operands[0]);
  1309.     }
  1310.   else
  1311.     {
  1312.       return   \"bra    %l0%#\";
  1313.     }
  1314. }"
  1315.   [(set_attr "type" "jump")
  1316.    (set_attr "needs_delay_slot" "yes")])
  1317.  
  1318.  
  1319. (define_insn "bsr"
  1320.   [(call (mem:SI (match_operand 0 "bsr_operand" "i"))
  1321.      (match_operand 1 "" ""))
  1322.    (clobber (reg:SI 17))]
  1323.   "TARGET_BSR"
  1324.   "bsr    %O0%#"
  1325.   [(set_attr "needs_delay_slot" "yes")
  1326.    (set_attr "in_delay_slot" "no")
  1327.    (set_attr "length" "4")])
  1328.  
  1329. (define_insn "calli"
  1330.   [(call (mem:SI (match_operand:SI 0 "arith_reg_operand" "r"))
  1331.      (match_operand 1 "" ""))
  1332.    (clobber (reg:SI 17))]
  1333.   ""
  1334.   "jsr    @%0%#"
  1335.   [(set_attr "needs_delay_slot" "yes")
  1336.    (set_attr "in_delay_slot" "no")
  1337.    (set_attr "length" "4")])
  1338.  
  1339. (define_insn "bsr_value"
  1340.   [(set (match_operand 0 "" "=rf")
  1341.     (call (mem:SI (match_operand 1 "bsr_operand" "i"))
  1342.           (match_operand 2 "" "")))
  1343.    (clobber (reg:SI 17))]
  1344.   "TARGET_BSR"
  1345.   "bsr    %O1%#"
  1346.   [(set_attr "needs_delay_slot" "yes")
  1347.    (set_attr "in_delay_slot" "no")
  1348.    (set_attr "length" "4")])
  1349.  
  1350. (define_insn "call_valuei"
  1351.   [(set (match_operand 0 "" "=rf")
  1352.     (call (mem:SI (match_operand:SI 1 "arith_reg_operand" "r"))
  1353.           (match_operand 2 "" "")))
  1354.    (clobber (reg:SI 17))]
  1355.   ""
  1356.   "jsr    @%1%#"
  1357.   [(set_attr "needs_delay_slot" "yes")
  1358.    (set_attr "in_delay_slot" "no")
  1359.    (set_attr "length" "4")])
  1360.  
  1361. (define_expand "call"
  1362.   [(parallel[(call (match_operand 0 "arith_reg_operand" "o")
  1363.            (match_operand 1 "" ""))
  1364.          (clobber (reg:SI 17))])]
  1365.   ""
  1366.   "expand_acall(0, operands); DONE;")
  1367.  
  1368. (define_expand "call_value"
  1369.   [(parallel[(set (match_operand 0 "" "=rf")
  1370.           (call (match_operand 1 "arith_reg_operand" "o")
  1371.             (match_operand 2 "" "")))
  1372.          (clobber (reg:SI 17))])]
  1373.   ""
  1374.   "expand_acall(1, operands); DONE; ")
  1375.  
  1376. (define_insn "indirect_jump"
  1377.   [(set (pc)
  1378.     (match_operand:SI 0 "arith_reg_operand" "r"))]
  1379.   ""
  1380.   "jmp    @%0%#"
  1381.   [(set_attr "needs_delay_slot" "yes")
  1382.    (set_attr "in_delay_slot" "no")
  1383.    (set_attr "length" "4")])
  1384.  
  1385.  
  1386. ;; ------------------------------------------------------------------------
  1387. ;; Misc insns
  1388. ;; ------------------------------------------------------------------------
  1389.  
  1390. (define_insn "dect"
  1391.   [(parallel[
  1392.          (set (reg:SI 18)
  1393.           (eq:SI (match_operand:SI 0 "register_operand" "=r")
  1394.              (const_int 1)))
  1395.  
  1396.          (set (match_dup 0)
  1397.           (plus:SI (match_dup 0)
  1398.                (const_int -1)))])]
  1399.   "TARGET_SH2"
  1400.   "dt    %0")
  1401.  
  1402. (define_insn "nop"
  1403.   [(const_int 0)]
  1404.   ""
  1405.   "or    r0,r0")
  1406.  
  1407. ; experimental use of auto inc and dec made these...
  1408. ; can be deleted
  1409.  
  1410. (define_insn "fake"
  1411.   [(set (match_operand:QI 0 "register_operand" "=r")
  1412.     (mem:QI (pre_dec:SI (match_operand:SI 1 "register_operand" "r"))))]
  1413.   ""
  1414.   "add    #-1,%1\;mov.b    @%1,%0 !bad"
  1415.   [(set_attr "length" "4")])
  1416.  
  1417. ;; Load address of a label. This is only generated by the casesi expand.
  1418.  
  1419. (define_insn "mova"
  1420.   [(set (reg:SI 0) 
  1421.     (label_ref (match_operand 0 "" "")))]
  1422.   ""
  1423.   "mova    %O0,r0"
  1424.   [(set_attr "in_delay_slot" "no")])
  1425.  
  1426. ;; case instruction for switch statements.
  1427.  
  1428. ;; Operand 0 is index
  1429. ;; operand 1 is the minimum bound
  1430. ;; operand 2 is the maximum bound - minimum bound + 1
  1431. ;; operand 3 is CODE_LABEL for the table;
  1432. ;; operand 4 is the CODE_LABEL to go to if index out of range.
  1433.  
  1434. (define_expand "casesi"
  1435.   [(set (match_dup 5) (match_operand:SI 0 "arith_reg_operand" ""))
  1436.    (set (match_dup 5) (minus:SI (match_dup 5)
  1437.                 (match_operand:SI 1 "arith_operand" "")))
  1438.    (set (reg:SI 18)
  1439.     (gtu:SI (match_dup 5)
  1440.         (match_operand:SI 2 "arith_operand" "")))
  1441.    (set (pc)
  1442.     (if_then_else (eq (reg:SI 18)
  1443.               (const_int 1))
  1444.               (label_ref (match_operand 4 "" ""))
  1445.               (pc)))
  1446.    (set (match_dup 6) (plus:SI (match_dup 5) (match_dup 5)))
  1447.    (set (reg:SI 0) (label_ref (match_operand 3 "" "")))
  1448.    (parallel[(set (reg:SI 0) (plus:SI (reg:SI 0)
  1449.                       (mem:HI (plus:SI (reg:SI 0)
  1450.                                (match_dup 6)))))
  1451.          (set (match_dup 6) (mem:HI (plus:SI (reg:SI 0) (match_dup 6))))])
  1452.    (set (pc) (reg:SI 0))]
  1453.   ""
  1454.   "
  1455. {
  1456.   operands[1] = copy_to_mode_reg (SImode, operands[1]);
  1457.   operands[2] = copy_to_mode_reg (SImode, operands[2]);
  1458.   operands[5] = gen_reg_rtx (SImode);
  1459.   operands[6] = gen_reg_rtx (SImode);
  1460. }")
  1461.  
  1462. (define_insn "casesi_worker"
  1463.   [(set (reg:SI 0) 
  1464.     (plus:SI (reg:SI 0) 
  1465.          (mem:HI (plus:SI (reg:SI 0)
  1466.                   (match_operand:SI 0 "register_operand" "=r")))))
  1467.    (set (match_dup 0) (mem:HI (plus:SI (reg:SI 0)
  1468.                        (match_dup 0))))]
  1469.   ""
  1470.   "mov.w    @(r0,%0),%0\;add    %0,r0"
  1471.   [(set_attr "needs_delay_slot" "no")
  1472.    (set_attr "in_delay_slot" "no")
  1473.    (set_attr "length" "6")])
  1474.  
  1475.  
  1476. (define_insn "return"
  1477.   [(return)]
  1478.   "reload_completed"
  1479.   "%@    %#"
  1480.   [(set_attr "type" "return")])
  1481.  
  1482. (define_expand "prologue"
  1483.   [(const_int 0)]
  1484.   ""
  1485.   "sh_expand_prologue (); DONE;")
  1486.  
  1487. (define_expand "epilogue"
  1488.   [(return)]
  1489.   ""
  1490.   "sh_expand_epilogue ();")
  1491.  
  1492. (define_insn "blockage"
  1493.   [(unspec_volatile [(const_int 0)] 0)]
  1494.   ""
  1495.   ""
  1496.   [(set_attr "length" "0")])
  1497.  
  1498.  
  1499. ;; ------------------------------------------------------------------------
  1500. ;; Scc instructions
  1501. ;; ------------------------------------------------------------------------
  1502.  
  1503. (define_insn "movt"
  1504.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  1505.     (eq:SI (reg:SI 18) (const_int 1)))]
  1506.   ""
  1507.   "movt    %0 ! ")
  1508.  
  1509. (define_expand "seq"
  1510.   [(set (match_operand:SI 0 "arith_reg_operand" "")
  1511.     (match_dup 1))]
  1512.   ""
  1513.   "operands[1] = prepare_scc_operands (EQ);")
  1514.  
  1515. (define_expand "slt"
  1516.   [(set (match_operand:SI 0 "arith_reg_operand" "")
  1517.     (match_dup 1))]
  1518.   ""
  1519.   "operands[1] = prepare_scc_operands (LT);")
  1520.  
  1521. (define_expand "sle"
  1522.   [(set (match_operand:SI 0 "arith_reg_operand" "")
  1523.     (match_dup 1))]
  1524.   ""
  1525.   "operands[1] = prepare_scc_operands (LE);")
  1526.  
  1527. (define_expand "sgt"
  1528.   [(set (match_operand:SI 0 "arith_reg_operand" "")
  1529.     (match_dup 1))]
  1530.   ""
  1531.   "operands[1] = prepare_scc_operands (GT);")
  1532.  
  1533. (define_expand "sge"
  1534.   [(set (match_operand:SI 0 "arith_reg_operand" "")
  1535.     (match_dup 1))]
  1536.   ""
  1537.   "operands[1] = prepare_scc_operands (GE);")
  1538.  
  1539. (define_expand "sgtu"
  1540.   [(set (match_operand:SI 0 "arith_reg_operand" "")
  1541.     (match_dup 1))]
  1542.   ""
  1543.   "operands[1] = prepare_scc_operands (GTU);")
  1544.  
  1545. (define_expand "sltu"
  1546.   [(set (match_operand:SI 0 "arith_reg_operand" "")
  1547.     (match_dup 1))]
  1548.   ""
  1549.   "operands[1] = prepare_scc_operands (LTU);")
  1550.  
  1551. (define_expand "sleu"
  1552.   [(set (match_operand:SI 0 "arith_reg_operand" "")
  1553.     (match_dup 1))]
  1554.   ""
  1555.   "operands[1] = prepare_scc_operands (LEU);")
  1556.  
  1557. (define_expand "sgeu"
  1558.   [(set (match_operand:SI 0 "arith_reg_operand" "")
  1559.     (match_dup 1))]
  1560.   ""
  1561.   "operands[1] = prepare_scc_operands (GEU);")
  1562.  
  1563. (define_expand "sne"
  1564.   [(set (match_operand:SI 0 "arith_reg_operand" "")
  1565.     (match_dup 1))
  1566.    (set (match_dup 0) (xor:SI (match_dup 0) (const_int 1)))]
  1567.   ""
  1568.   "operands[1] = prepare_scc_operands (EQ);")
  1569.  
  1570. ;; -------------------------------------------------------------------------
  1571. ;; Peepholes
  1572. ;; -------------------------------------------------------------------------
  1573.  
  1574.  
  1575. (define_peephole 
  1576.   [(set (match_operand:QI 0 "arith_reg_operand" "")
  1577.     (mem:QI (match_operand:SI 1 "arith_reg_operand" "")))
  1578.    (set (match_dup 1) (plus:SI (match_dup 1) (const_int 1)))]
  1579.   "REGNO (operands[1]) != REGNO (operands[0])"
  1580.   "mov.b    @%1+,%0")
  1581.  
  1582. (define_peephole 
  1583.   [(set (match_operand:HI 0 "arith_reg_operand" "")
  1584.     (mem:HI (match_operand:SI 1 "arith_reg_operand" "")))
  1585.    (set (match_dup 1) (plus:SI (match_dup 1) (const_int 2)))]
  1586.   "REGNO (operands[1]) != REGNO (operands[0])"
  1587.   "mov.w    @%1+,%0")
  1588.  
  1589. (define_peephole 
  1590.   [(set (match_operand:SI 0 "arith_reg_operand" "")
  1591.     (mem:SI (match_operand:SI 1 "arith_reg_operand" "")))
  1592.    (set (match_dup 1) (plus:SI (match_dup 1) (const_int 4)))]
  1593.   "REGNO (operands[1]) != REGNO (operands[0])"
  1594.   "mov.l    @%1+,%0")
  1595.  
  1596. (define_peephole
  1597.   [(set (match_operand:QI 0 "register_operand" "=r")
  1598.     (match_operand:QI 1 "memory_operand" "g"))
  1599.    (set (match_operand:SI 2 "register_operand" "=r")
  1600.     (sign_extend:SI (match_dup 0)))]
  1601.   "REGNO (operands[0]) == REGNO (operands[2])"
  1602.   "mov.b    %1,%0 !p 5")
  1603.  
  1604. (define_peephole 
  1605.   [(set (match_operand:QI 0 "register_operand" "=r")
  1606.     (match_operand:QI 1 "general_movsrc_operand" "g"))
  1607.    (set (match_operand:SI 2 "register_operand" "=r")
  1608.     (sign_extend:SI (match_dup 0)))]
  1609.   "REGNO (operands[0]) != REGNO (operands[2]) 
  1610.    && 0 && dead_or_set_p (insn, operands[0])"
  1611.   "mov.b    %1,%2 ! p4")
  1612.  
  1613.   
  1614. ;; -------------------------------------------------------------------------
  1615. ;; Peepholes
  1616. ;; -------------------------------------------------------------------------
  1617.  
  1618. (define_peephole 
  1619.   [(set (reg:SI 0) (label_ref (match_operand 0 "" "")))
  1620.    (set (match_operand:SI 1 "register_operand" "=r")
  1621.     (reg:SI 0))
  1622.    (set (reg:SI 0) (label_ref (match_dup 0)))
  1623.    (set (match_operand:SI 2 "register_operand" "=r")
  1624.     (reg:SI 0))]
  1625.    ""
  1626.    "mova    %O0,r0\;mov    r0,%1\;mov    r0,%2"
  1627.    [(set_attr "length" "6")
  1628.     (set_attr "in_delay_slot" "no")])
  1629.  
  1630.  
  1631. ;; -------------------------------------------------------------------------
  1632. ;; Combine patterns
  1633. ;; -------------------------------------------------------------------------
  1634.  
  1635. (define_insn ""
  1636.   [(set (match_operand:SI 0 "register_operand" "=r")
  1637.     (plus:SI (match_operand:HI 1 "register_operand" "%0")
  1638.          (match_operand:SI 2 "register_operand" "r")))]
  1639.   ""
  1640.   "add    %2,%0 ! why")
  1641.  
  1642. (define_insn "addc_2"
  1643.   [(set (match_operand:SI 0 "arith_reg_operand" "=&r")
  1644.     (plus:SI (reg:SI 18)
  1645.          (match_operand:SI 1 "arith_reg_operand" "r")))
  1646.    (clobber (reg:SI 18))]
  1647.   ""
  1648.   "mov    #0,%0\;addc    %1,%0 ! addc1"
  1649.   [(set_attr "length" "4")])
  1650.  
  1651. (define_insn "combine_1"
  1652.   [(set (match_operand:SI 0 "arith_reg_operand" "=r")
  1653.     (sign_extend:SI (mem:QI (match_operand:SI 1 "arith_reg_operand" "r"))))]
  1654.   ""
  1655.   "mov.b    @%1,%0 ! why"
  1656.   [(set_attr "type" "load")])
  1657.   
  1658. (define_insn "combine_2"
  1659.   [(set (reg:SI 18)
  1660.     (eq:SI (and:SI (match_operand:SI 0 "arith_reg_operand" "z,r")
  1661.             (match_operand:SI 1 "arith_operand" "L,r"))
  1662.         (const_int 0)))]
  1663.   ""
  1664.   "tst    %1,%0 !t2c")
  1665.  
  1666. (define_split
  1667.   [(set (pc) 
  1668.     (if_then_else
  1669.      (match_operator 2 "equality_operator" [(match_operand:SI 0 "arith_reg_operand" "r")
  1670.                         (const_int 0)])
  1671.      (label_ref (match_operand 1 "" ""))
  1672.      (pc)))
  1673.    (clobber (reg:SI 18))]
  1674.   ""
  1675.   [(set (reg:SI 18) (eq:SI (and:SI (match_dup 0) (match_dup 0))
  1676.             (const_int 0)))
  1677.    (set (pc)
  1678.     (if_then_else (match_op_dup 2 [(reg:SI 18) (const_int 1)])
  1679.               (label_ref (match_dup 1))
  1680.               (pc)))]
  1681.   "")
  1682.  
  1683. ;; -------------------------------------------------------------------------
  1684. ;; Instructions to cope with inline literal tables
  1685. ;; -------------------------------------------------------------------------
  1686.  
  1687. ; 2 byte integer in line
  1688.  
  1689. (define_insn "consttable_2"
  1690.  [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")] 2)]
  1691.  ""
  1692.  "*
  1693. {
  1694.   assemble_integer (operands[0], 2, 1);
  1695.   return \"\";
  1696. }"
  1697.  [(set_attr "length" "2")
  1698.  (set_attr "in_delay_slot" "no")])
  1699.  
  1700. ; 4 byte integer in line
  1701.  
  1702. (define_insn "consttable_4"
  1703.  [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")] 4)]
  1704.  ""
  1705.  "*
  1706. {
  1707.   assemble_integer (operands[0], 4, 1);
  1708.   return \"\";
  1709. }"
  1710.  [(set_attr "length" "4")
  1711.   (set_attr "in_delay_slot" "no")])
  1712.  
  1713. ; 8 byte integer in line
  1714.  
  1715. (define_insn "consttable_8"
  1716.  [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")] 6)]
  1717.  ""
  1718.  "*
  1719. {
  1720.   assemble_integer (operands[0], 8, 1);
  1721.   return \"\";
  1722. }"
  1723.  [(set_attr "length" "8")
  1724.   (set_attr "in_delay_slot" "no")])
  1725.  
  1726. ; align to a two byte boundary
  1727.  
  1728. (define_insn "align_2"
  1729.  [(unspec_volatile [(const_int 0)] 10)]
  1730.  ""
  1731.  ".align 1"
  1732.  [(set_attr "length" "0")
  1733.   (set_attr "in_delay_slot" "no")])
  1734.  
  1735. ; align to a four byte boundary
  1736.  
  1737. (define_insn "align_4"
  1738.  [(unspec_volatile [(const_int 0)] 5)]
  1739.  ""
  1740.  ".align 2"
  1741.  [(set_attr "in_delay_slot" "no")])
  1742.  
  1743. ; emitted at the end of the literal table, used to emit the
  1744. ; 32bit branch labels if needed.
  1745.  
  1746. (define_insn "consttable_end"
  1747.   [(unspec_volatile [(const_int 0)] 11)]
  1748.   ""
  1749.   "* return output_jump_label_table ();"
  1750.   [(set_attr "in_delay_slot" "no")])
  1751.  
  1752.  
  1753. ;(define_split 
  1754. ;  [(set (subreg:SI (match_operand:QI 0 "register_operand" "=r") 0)
  1755. ;    (plus:SI (subreg:SI (match_operand:QI 1 "general_operand" "g") 0)
  1756. ;         (subreg:SI (match_operand:QI 2 "general_operand" "g") 0)))]
  1757. ;  ""
  1758. ;  [(set (match_dup 3) (plus:SI (match_dup 1) (match_dup 2)))
  1759. ;   (set (match_dup 1) (subreg:SI (match_dup 3) 0))]
  1760. ;  "operands[3] = gen_reg_rtx(SImode);")
  1761.  
  1762.  
  1763. ; byte arithmetic involving constants which need to be sign extended can be 
  1764. ; fixed up...
  1765.  
  1766.  
  1767. (define_split 
  1768.   [(set (subreg:SI (match_operand:QI 0 "register_operand" "=r") 0)
  1769.     (plus:SI (subreg:SI (match_operand:QI 1 "register_operand" "0") 0)
  1770.          (subreg:SI (match_operand 2 "immediate_operand" "n") 0)))]
  1771.   ""
  1772.   [(set (match_dup 4) (plus:SI (match_dup 2) (match_dup 3)))
  1773.    (set (match_dup 0) (and:SI (match_dup 0) (const_int 255)))]
  1774.   "{ int i = INTVAL(operands[2]) & 0xff;
  1775.    if (i > 127) i = i - 256;
  1776.    operands[3] = GEN_INT(i); 
  1777.    operands[4] = gen_reg_rtx(SImode);} ")
  1778.  
  1779.  
  1780. ;; these instructions don't really exist - they are needed
  1781. ;; before machine_dependent_reorg
  1782.  
  1783. (define_insn "movsi_k"
  1784.  [(set (match_operand:SI 0 "register_operand" "=r")
  1785.        (match_operand:SI 1 "immediate_operand" ""))]
  1786.   ""
  1787.   "! this is a fake")
  1788.  
  1789.  
  1790. (define_insn "movhi_k"
  1791.  [(set (match_operand:HI 0 "register_operand" "=r")
  1792.        (match_operand:HI 1 "immediate_operand" ""))]
  1793.   ""
  1794.   "! this is a fake")
  1795.  
  1796. (define_insn "movdi_k"
  1797.  [(set (match_operand:DI 0 "register_operand" "=r")
  1798.        (match_operand:DI 1 "immediate_operand" ""))]
  1799.   ""
  1800.   "! this is a fake")
  1801.  
  1802. ;; -------------------------------------------------------------------------
  1803. ;; Misc
  1804. ;; -------------------------------------------------------------------------
  1805.  
  1806.  
  1807. ;; String/block move insn.  
  1808.  
  1809. (define_expand "movstrsi"
  1810.   [(parallel [(set (mem:BLK (match_operand:BLK 0 "" ""))
  1811.            (mem:BLK (match_operand:BLK 1 "" "")))
  1812.           (use (match_operand:SI 2 "nonmemory_operand" ""))
  1813.           (use (match_operand:SI 3 "immediate_operand" ""))
  1814.           (clobber (reg:SI 17))
  1815.           (clobber (reg:SI 4))
  1816.           (clobber (reg:SI 5))
  1817.           (clobber (reg:SI 0))])]
  1818.   ""
  1819.   "
  1820. {
  1821.   if(expand_block_move (operands))
  1822.      DONE;
  1823.   else FAIL;
  1824. }")
  1825.  
  1826. (define_insn "block_move_real"
  1827.   [(parallel [(set (mem:BLK (reg:SI 4))
  1828.            (mem:BLK (reg:SI 5)))
  1829.           (use (match_operand:SI 0 "arith_reg_operand" "r"))
  1830.           (clobber (reg:SI 17))
  1831.           (clobber (reg:SI 4))
  1832.           (clobber (reg:SI 5))
  1833.           (clobber (reg:SI 0))])]
  1834.   ""
  1835.   "jsr    @%0%#"
  1836.   [(set_attr "length" "4")
  1837.    (set_attr "type" "sfunc")
  1838.    (set_attr "needs_delay_slot" "yes")])
  1839.  
  1840. (define_insn "block_lump_real"
  1841.   [(parallel [(set (mem:BLK (reg:SI 4))
  1842.            (mem:BLK (reg:SI 5)))
  1843.           (use (match_operand:SI 0 "arith_reg_operand" "r"))
  1844.           (use (reg:SI 6))
  1845.           (clobber (reg:SI 17))
  1846.           (clobber (reg:SI 4))
  1847.           (clobber (reg:SI 5))
  1848.           (clobber (reg:SI 6))
  1849.           (clobber (reg:SI 0))])]
  1850.   ""
  1851.   "jsr    @%0%#"
  1852.   [(set_attr "length" "4")
  1853.    (set_attr "type" "sfunc")
  1854.    (set_attr "needs_delay_slot" "yes")])
  1855.  
  1856. (define_insn "mac"
  1857.   [(set (reg:SI 21)
  1858.     (mult:SI (sign_extend:SI (mem:HI (post_inc:SI 
  1859.                       (match_operand:SI 0 "arith_reg_operand" "r"))))
  1860.          (sign_extend:SI (mem:HI (post_inc:SI
  1861.                       (match_operand:SI 1 "arith_reg_operand" "r"))))))]
  1862.   ""
  1863.   "mac.w    @%0+,@%1+")
  1864.  
  1865.  
  1866.             
  1867.