home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / gcc-2.3.3-src.lha / GNU / src / amiga / gcc-2.3.3 / config / vax.md < prev    next >
Text File  |  1994-02-06  |  57KB  |  2,034 lines

  1. ;;- Machine description for GNU compiler, Vax Version
  2. ;;   Copyright (C) 1987, 1988, 1991 Free Software Foundation, Inc.
  3.  
  4. ;; This file is part of GNU CC.
  5.  
  6. ;; GNU CC is free software; you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation; either version 2, or (at your option)
  9. ;; any later version.
  10.  
  11. ;; GNU CC is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;; GNU General Public License for more details.
  15.  
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU CC; see the file COPYING.  If not, write to
  18. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.  
  21. ;;- Instruction patterns.  When multiple patterns apply,
  22. ;;- the first one in the file is chosen.
  23. ;;-
  24. ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
  25. ;;-
  26. ;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code
  27. ;;- updates for most instructions.
  28.  
  29. ;; We don't want to allow a constant operand for test insns because
  30. ;; (set (cc0) (const_int foo)) has no mode information.  Such insns will
  31. ;; be folded while optimizing anyway.
  32.  
  33. (define_insn "tstsi"
  34.   [(set (cc0)
  35.     (match_operand:SI 0 "nonimmediate_operand" "g"))]
  36.   ""
  37.   "tstl %0")
  38.  
  39. (define_insn "tsthi"
  40.   [(set (cc0)
  41.     (match_operand:HI 0 "nonimmediate_operand" "g"))]
  42.   ""
  43.   "tstw %0")
  44.  
  45. (define_insn "tstqi"
  46.   [(set (cc0)
  47.     (match_operand:QI 0 "nonimmediate_operand" "g"))]
  48.   ""
  49.   "tstb %0")
  50.  
  51. (define_insn "tstdf"
  52.   [(set (cc0)
  53.     (match_operand:DF 0 "general_operand" "gF"))]
  54.   ""
  55.   "tst%# %0")
  56.  
  57. (define_insn "tstsf"
  58.   [(set (cc0)
  59.     (match_operand:SF 0 "general_operand" "gF"))]
  60.   ""
  61.   "tstf %0")
  62.  
  63. (define_insn "cmpsi"
  64.   [(set (cc0)
  65.     (compare (match_operand:SI 0 "nonimmediate_operand" "g")
  66.          (match_operand:SI 1 "general_operand" "g")))]
  67.   ""
  68.   "cmpl %0,%1")
  69.  
  70. (define_insn "cmphi"
  71.   [(set (cc0)
  72.     (compare (match_operand:HI 0 "nonimmediate_operand" "g")
  73.          (match_operand:HI 1 "general_operand" "g")))]
  74.   ""
  75.   "cmpw %0,%1")
  76.  
  77. (define_insn "cmpqi"
  78.   [(set (cc0)
  79.     (compare (match_operand:QI 0 "nonimmediate_operand" "g")
  80.          (match_operand:QI 1 "general_operand" "g")))]
  81.   ""
  82.   "cmpb %0,%1")
  83.  
  84. (define_insn "cmpdf"
  85.   [(set (cc0)
  86.     (compare (match_operand:DF 0 "general_operand" "gF,gF")
  87.          (match_operand:DF 1 "general_operand" "G,gF")))]
  88.   ""
  89.   "@
  90.    tst%# %0
  91.    cmp%# %0,%1")
  92.  
  93. (define_insn "cmpsf"
  94.   [(set (cc0)
  95.     (compare (match_operand:SF 0 "general_operand" "gF,gF")
  96.          (match_operand:SF 1 "general_operand" "G,gF")))]
  97.   ""
  98.   "@
  99.    tstf %0
  100.    cmpf %0,%1")
  101.  
  102. (define_insn ""
  103.   [(set (cc0)
  104.     (and:SI (match_operand:SI 0 "general_operand" "g")
  105.         (match_operand:SI 1 "general_operand" "g")))]
  106.   ""
  107.   "bitl %0,%1")
  108.  
  109. (define_insn ""
  110.   [(set (cc0)
  111.     (and:HI (match_operand:HI 0 "general_operand" "g")
  112.         (match_operand:HI 1 "general_operand" "g")))]
  113.   ""
  114.   "bitw %0,%1")
  115.  
  116. (define_insn ""
  117.   [(set (cc0)
  118.     (and:QI (match_operand:QI 0 "general_operand" "g")
  119.         (match_operand:QI 1 "general_operand" "g")))]
  120.   ""
  121.   "bitb %0,%1")
  122.  
  123. ;; The vax has no sltu or sgeu patterns, but does have two-operand
  124. ;; add/subtract with carry.  This is still better than the alternative.
  125. ;; Since the cc0-using insn cannot be separated from the cc0-setting insn,
  126. ;; and the two are created independently, we can't just use a define_expand
  127. ;; to try to optimize this.  (The "movl" and "clrl" insns alter the cc0
  128. ;; flags, but leave the carry flag alone, but that can't easily be expressed.)
  129. ;;
  130. ;; Several two-operator combinations could be added to make slightly more
  131. ;; optimal code, but they'd have to cover all combinations of plus and minus
  132. ;; using match_dup.  If you want to do this, I'd suggest changing the "sgeu"
  133. ;; pattern to something like (minus (const_int 1) (ltu ...)), so fewer
  134. ;; patterns need to be recognized.
  135. ;; -- Ken Raeburn (Raeburn@Watch.COM) 24 August 1991.
  136.  
  137. (define_insn "sltu"
  138.   [(set (match_operand:SI 0 "general_operand" "=ro")
  139.     (ltu (cc0) (const_int 0)))]
  140.   ""
  141.   "clrl %0\;adwc $0,%0")
  142.  
  143. (define_insn "sgeu"
  144.   [(set (match_operand:SI 0 "general_operand" "=ro")
  145.     (geu (cc0) (const_int 0)))]
  146.   ""
  147.   "movl $1,%0\;sbwc $0,%0")
  148.  
  149. (define_insn "movdf"
  150.   [(set (match_operand:DF 0 "general_operand" "=g,g")
  151.     (match_operand:DF 1 "general_operand" "G,gF"))]
  152.   ""
  153.   "@
  154.    clr%# %0
  155.    mov%# %1,%0")
  156.  
  157. (define_insn "movsf"
  158.   [(set (match_operand:SF 0 "general_operand" "=g,g")
  159.     (match_operand:SF 1 "general_operand" "G,gF"))]
  160.   ""
  161.   "@
  162.    clrf %0
  163.    movf %1,%0")
  164.  
  165. ;; Some vaxes don't support this instruction.
  166. ;;(define_insn "movti"
  167. ;;  [(set (match_operand:TI 0 "general_operand" "=g")
  168. ;;    (match_operand:TI 1 "general_operand" "g"))]
  169. ;;  ""
  170. ;;  "movh %1,%0")
  171.  
  172. (define_insn "movdi"
  173.   [(set (match_operand:DI 0 "general_operand" "=g,g")
  174.     (match_operand:DI 1 "general_operand" "I,g"))]
  175.   ""
  176.   "@
  177.    clrq %0
  178.    movq %D1,%0")
  179.  
  180. ;; The VAX move instructions have space-time tradeoffs.  On a microVAX
  181. ;; register-register mov instructions take 3 bytes and 2 CPU cycles.  clrl
  182. ;; takes 2 bytes and 3 cycles.  mov from constant to register takes 2 cycles
  183. ;; if the constant is smaller than 4 bytes, 3 cycles for a longword
  184. ;; constant.  movz, mneg, and mcom are as fast as mov, so movzwl is faster
  185. ;; than movl for positive constants that fit in 16 bits but not 6 bits.  cvt
  186. ;; instructions take 4 cycles.  inc takes 3 cycles.  The machine description
  187. ;; is willing to trade 1 byte for 1 cycle (clrl instead of movl $0; cvtwl
  188. ;; instead of movl).
  189.  
  190. ;; Cycle counts for other models may vary (on a VAX 750 they are similar,
  191. ;; but on a VAX 9000 most move and add instructions with one constant
  192. ;; operand take 1 cycle).
  193.  
  194. ;;  Loads of constants between 64 and 128 used to be done with
  195. ;; "addl3 $63,#,dst" but this is slower than movzbl and takes as much space.
  196.  
  197. (define_insn "movsi"
  198.   [(set (match_operand:SI 0 "general_operand" "=g")
  199.     (match_operand:SI 1 "general_operand" "g"))]
  200.   ""
  201.   "*
  202. {
  203.   rtx link;
  204.   if (operands[1] == const1_rtx
  205.       && (link = find_reg_note (insn, REG_WAS_0, 0))
  206.       /* Make sure the insn that stored the 0 is still present.  */
  207.       && ! INSN_DELETED_P (XEXP (link, 0))
  208.       && GET_CODE (XEXP (link, 0)) != NOTE
  209.       /* Make sure cross jumping didn't happen here.  */
  210.       && no_labels_between_p (XEXP (link, 0), insn))
  211.     return \"incl %0\";
  212.   if (GET_CODE (operands[1]) == SYMBOL_REF || GET_CODE (operands[1]) == CONST)
  213.     {
  214.       if (push_operand (operands[0], SImode))
  215.     return \"pushab %a1\";
  216.       return \"movab %a1,%0\";
  217.     }
  218.   if (operands[1] == const0_rtx)
  219.     return \"clrl %0\";
  220.   if (GET_CODE (operands[1]) == CONST_INT
  221.       && (unsigned) INTVAL (operands[1]) >= 64)
  222.     {
  223.       int i = INTVAL (operands[1]);
  224.       if ((unsigned)(~i) < 64)
  225.     return \"mcoml %N1,%0\";
  226.       if ((unsigned)i < 0x100)
  227.     return \"movzbl %1,%0\";
  228.       if (i >= -0x80 && i < 0)
  229.     return \"cvtbl %1,%0\";
  230.       if ((unsigned)i < 0x10000)
  231.     return \"movzwl %1,%0\";
  232.       if (i >= -0x8000 && i < 0)
  233.     return \"cvtwl %1,%0\";
  234.     }
  235.   if (push_operand (operands[0], SImode))
  236.     return \"pushl %1\";
  237.   return \"movl %1,%0\";
  238. }")
  239.  
  240. (define_insn "movhi"
  241.   [(set (match_operand:HI 0 "general_operand" "=g")
  242.     (match_operand:HI 1 "general_operand" "g"))]
  243.   ""
  244.   "*
  245. {
  246.   rtx link;
  247.   if (operands[1] == const1_rtx
  248.       && (link = find_reg_note (insn, REG_WAS_0, 0))
  249.       /* Make sure the insn that stored the 0 is still present.  */
  250.       && ! INSN_DELETED_P (XEXP (link, 0))
  251.       && GET_CODE (XEXP (link, 0)) != NOTE
  252.       /* Make sure cross jumping didn't happen here.  */
  253.       && no_labels_between_p (XEXP (link, 0), insn))
  254.     return \"incw %0\";
  255.  
  256.   if (GET_CODE (operands[1]) == CONST_INT)
  257.     {
  258.       int i = INTVAL (operands[1]);
  259.       if (i == 0)
  260.     return \"clrw %0\";
  261.       else if ((unsigned int)i < 64)
  262.     return \"movw %1,%0\";
  263.       else if ((unsigned int)~i < 64)
  264.     return \"mcomw %H1,%0\";
  265.       else if ((unsigned int)i < 256)
  266.     return \"movzbw %1,%0\";
  267.     }
  268.   return \"movw %1,%0\";
  269. }")
  270.  
  271. (define_insn "movstricthi"
  272.   [(set (strict_low_part (match_operand:HI 0 "register_operand" "=g"))
  273.     (match_operand:HI 1 "general_operand" "g"))]
  274.   ""
  275.   "*
  276. {
  277.   if (GET_CODE (operands[1]) =