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 / arm.md < prev    next >
Text File  |  1994-02-06  |  37KB  |  1,318 lines

  1. ;;- Machine description Acorn RISC Machine for GNU compiler
  2. ;;  Copyright (C) 1991 Free Software Foundation, Inc.
  3. ;;  Contributed by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl)
  4. ;;             and Martin Simmons (@harleqn.co.uk).
  5.  
  6. ;; This file is part of GNU CC.
  7.  
  8. ;; GNU CC is free software; you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation; either version 2, or (at your option)
  11. ;; any later version.
  12.  
  13. ;; GNU CC is distributed in the hope that it will be useful,
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ;; GNU General Public License for more details.
  17.  
  18. ;; You should have received a copy of the GNU General Public License
  19. ;; along with GNU CC; see the file COPYING.  If not, write to
  20. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
  23.  
  24. ;; Every template must be output by arm_output_asm_insn, since this keeps
  25. ;; track of the offset of labels within the text segment.  This is needed to
  26. ;; to be able to (correctly) output instructions for loading a value from a
  27. ;; function's constant pool, since different instructions are needed when the
  28. ;; constant pool is more than 4095 bytes away from the PC.
  29.  
  30. ;; Addition insns.
  31.  
  32. (define_insn "adddi3"
  33.   [(set (match_operand:DI 0 "di_operand" "=&r")
  34.     (plus:DI (match_operand:DI 1 "di_operand" "%r")
  35.          (match_operand:DI 2 "di_operand" "r")))]
  36.   ""
  37.   "*
  38.   arm_output_asm_insn (\"adds\\t%0, %1, %2\", operands);
  39.   return (arm_output_asm_insn (\"adc\\t%R0, %R1, %R2\", operands));
  40. ")
  41.  
  42. (define_insn "addsi3"
  43.   [(set (match_operand:SI 0 "register_operand" "=r,r")
  44.     (plus:SI (match_operand:SI 1 "register_operand" "r,r")
  45.          (match_operand:SI 2 "general_operand" "r,n")))]
  46.   ""
  47.   "*
  48.   switch (which_alternative)
  49.     {
  50.     case 0:
  51.       return (arm_output_asm_insn (\"add\\t%0, %1, %2\", operands));
  52.     case 1:
  53.       return (output_add_immediate (operands));
  54.     }
  55. ")
  56.  
  57. (define_insn "addsf3"
  58.   [(set (match_operand:SF 0 "register_operand" "=f")
  59.     (plus:SF (match_operand:SF 1 "register_operand" "f")
  60.          (match_operand:SF 2 "fpu_rhs_operand" "fG")))]
  61.   ""
  62.   "*
  63.   return (arm_output_asm_insn (\"adfs\\t%0, %1, %2\", operands));
  64. ")
  65.  
  66. (define_insn "adddf3"
  67.   [(set (match_operand:DF 0 "register_operand" "=f")
  68.     (plus:DF (match_operand:DF 1 "register_operand" "f")
  69.          (match_operand:DF 2 "fpu_rhs_operand" "fG")))]
  70.   ""
  71.   "*
  72.   return (arm_output_asm_insn (\"adfd\\t%0, %1, %2\", operands));
  73. ")
  74.  
  75. (define_insn "subdi3"
  76.   [(set (match_operand:DI 0 "di_operand" "=&r")
  77.     (minus:DI (match_operand:DI 1 "di_operand" "%r")
  78.           (match_operand:DI 2 "di_operand" "r")))]
  79.   ""
  80.   "*
  81.   arm_output_asm_insn (\"subs\\t%0, %1, %2\", operands);
  82.   return (arm_output_asm_insn (\"sbc\\t%R0, %R1, %R2\", operands));
  83. ")
  84.  
  85. (define_insn "subsi3"
  86.   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
  87.     (minus:SI (match_operand:SI 1 "arm_rhs_operand" "r,r,I")
  88.           (match_operand:SI 2 "general_operand" "r,n,r")))]
  89.   ""
  90.   "*
  91.   switch (which_alternative)
  92.     {
  93.     case 0:
  94.       return (arm_output_asm_insn (\"sub\\t%0, %1, %2\", operands));
  95.     case 1:
  96.       operands[2] = gen_rtx (CONST_INT, VOIDmode, -INTVAL (operands[2]));
  97.       return (output_add_immediate (operands));
  98.     case 2:
  99.       return (arm_output_asm_insn (\"rsb\\t%0, %2, %1\", operands));
  100.     }
  101. ")
  102.  
  103. (define_insn "subsf3"
  104.   [(set (match_operand:SF 0 "register_operand" "=f,f")
  105.     (minus:SF (match_operand:SF 1 "fpu_rhs_operand" "f,G")
  106.           (match_operand:SF 2 "fpu_rhs_operand" "fG,f")))]
  107.   ""
  108.   "*
  109.   switch (which_alternative)
  110.     {
  111.     case 0:
  112.       return (arm_output_asm_insn (\"sufs\\t%0, %1, %2\", operands));
  113.     case 1:
  114.       return (arm_output_asm_insn (\"rsfs\\t%0, %2, %1\", operands));
  115.     }
  116. ")
  117.  
  118. (define_insn "subdf3"
  119.   [(set (match_operand:DF 0 "register_operand" "=f,f")
  120.     (minus:DF (match_operand:DF 1 "fpu_rhs_operand" "f,G")
  121.       (match_operand:DF 2 "fpu_rhs_operand" "fG,f")))]
  122.   ""
  123.   "*
  124.   switch (which_alternative)
  125.     {
  126.     case 0:
  127.       return (arm_output_asm_insn (\"sufd\\t%0, %1, %2\", operands));
  128.     case 2:
  129.       return (arm_output_asm_insn (\"rsfd\\t%0, %2, %1\", operands));
  130.     }
  131. ")
  132.  
  133. ;; Multiplication insns
  134.  
  135. ;; The `&' is too strict, but at least generates correct code.
  136. (define_insn "mulsi3"
  137.   [(set (match_operand:SI 0 "register_operand" "=&r")
  138.     (mult:SI (match_operand:SI 1 "register_operand" "%r")
  139.          (match_operand:SI 2 "register_operand" "r")))]
  140.   ""
  141.   "*
  142.   if (REGNO (operands[0]) == REGNO (operands[1]))
  143.     return (arm_output_asm_insn (\"mul\\t%0, %2, %1\", operands));
  144.   else
  145.     return (arm_output_asm_insn (\"mul\\t%0, %1, %2\", operands));
  146. ")
  147.  
  148. ;; Unnamed templates to match MLA instruction.
  149.  
  150. (define_insn ""
  151.   [(set (match_operand:SI 0 "register_operand" "=&r")
  152.     (plus:SI
  153.       (mult:SI (match_operand:SI 1 "register_operand" "%r")
  154.            (match_operand:SI 2 "register_operand" "r"))
  155.       (match_operand:SI 3 "register_operand" "r")))]
  156.   ""
  157.   "*
  158.   if (REGNO (operands[0]) == REGNO (operands[1]))
  159.     return (arm_output_asm_insn (\"mla\\t%0, %2, %1, %3\", operands));
  160.   else
  161.     return (arm_output_asm_insn (\"mla\\t%0, %1, %2, %3\", operands));
  162. ")
  163.  
  164. (define_insn ""
  165.   [(set (match_operand:SI 0 "register_operand" "=&r")
  166.     (plus:SI
  167.       (match_operand:SI 3 "register_operand" "r")
  168.       (mult:SI (match_operand:SI 1 "register_operand" "%r")
  169.            (match_operand:SI 2 "register_operand" "r"))))]
  170.   ""
  171.   "*
  172.   if (REGNO (operands[0]) == REGNO (operands[1]))
  173.     return (arm_output_asm_insn (\"mla\\t%0, %2, %1, %3\", operands));
  174.   else
  175.     return (arm_output_asm_insn (\"mla\\t%0, %1, %2, %3\", operands));
  176. ")
  177.  
  178. (define_insn "mulsf3"
  179.   [(set (match_operand:SF 0 "register_operand" "=f")
  180.     (mult:SF (match_operand:SF 1 "register_operand" "f")
  181.          (match_operand:SF 2 "fpu_rhs_operand" "fG")))]
  182.   ""
  183.   "*return (arm_output_asm_insn (\"mufs\\t%0, %1, %2\", operands));")
  184.  
  185. (define_insn "muldf3"
  186.   [(set (match_operand:DF 0 "register_operand" "=f")
  187.     (mult:DF (match_operand:DF 1 "register_operand" "f")
  188.          (match_operand:DF 2 "fpu_rhs_operand" "fG")))]
  189.   ""
  190.   "*
  191.   return (arm_output_asm_insn (\"mufd\\t%0, %1, %2\", operands));
  192. ")
  193.  
  194. ;; Division insns
  195.  
  196. (define_insn "divsf3"
  197.   [(set (match_operand:SF 0 "register_operand" "=f,f")
  198.     (div:SF (match_operand:SF 1 "fpu_rhs_operand" "f,G")
  199.         (match_operand:SF 2 "fpu_rhs_operand" "fG,f")))]
  200.   ""
  201.   "*
  202.   switch (which_alternative)
  203.     {
  204.     case 0:
  205.       return (arm_output_asm_insn (\"dvfs\\t%0, %1, %2\", operands));
  206.     case 1:
  207.       return (arm_output_asm_insn (\"rdfs\\t%0, %2, %1\", operands));
  208.     }
  209. ")
  210.  
  211. (define_insn "divdf3"
  212.   [(set (match_operand:DF 0 "register_operand" "=f,f")
  213.     (div:DF (match_operand:DF 1 "fpu_rhs_operand" "f,G")
  214.         (match_operand:DF 2 "fpu_rhs_operand" "fG,f")))]
  215.   ""
  216.   "*
  217.   switch (which_alternative)
  218.     {
  219.     case 0:
  220.       return (arm_output_asm_insn (\"dvfd\\t%0, %1, %2\", operands));
  221.     case 1:
  222.       return (arm_output_asm_insn (\"rdfd\\t%0, %2, %1\", operands));
  223.     }
  224. ")
  225.  
  226. ;; Modulo insns
  227.  
  228. (define_insn "modsf3"
  229.   [(set (match_operand:SF 0 "register_operand" "=f")
  230.     (mod:SF (match_operand:SF 1 "register_operand" "f")
  231.         (match_operand:SF 2 "fpu_rhs_operand" "fG")))]
  232.   ""
  233.   "*
  234.   return (arm_output_asm_insn (\"rmfs\\t%0, %1, %2\", operands));
  235. ")
  236.  
  237. (define_insn "moddf3"
  238.   [(set (match_operand:DF 0 "register_operand" "=f")
  239.     (mod:DF (match_operand:DF 1 "register_operand" "f")
  240.         (match_operand:DF 2 "fpu_rhs_operand" "fG")))]
  241.   ""
  242.   "*
  243.   return (arm_output_asm_insn (\"rmfd\\t%0, %1, %2\", operands));
  244. ")
  245.  
  246. ;; Boolean and,ior,xor insns
  247.  
  248. (define_insn "anddi3"
  249.   [(set (match_operand:DI 0 "di_operand" "=&r")
  250.     (and:DI (match_operand:DI 1 "di_operand" "%r")
  251.         (match_operand:DI 2 "di_operand" "r")))]
  252.   ""
  253.   "*
  254.   arm_output_asm_insn (\"and\\t%0, %1, %2\", operands);
  255.   return (arm_output_asm_insn (\"and\\t%R0, %R1, %R2\", operands));
  256. ")
  257.  
  258. (define_insn "andsi3"
  259.   [(set (match_operand:SI 0 "register_operand" "=r")
  260.     (and:SI (match_operand:SI 1 "register_operand" "r")
  261.         (match_operand:SI 2 "arm_rhs_operand" "rI")))]
  262.   ""
  263.   "*
  264.   return (arm_output_asm_insn (\"and\\t%0, %1, %2\", operands));
  265. ")
  266.  
  267. (define_insn "andcbsi3"
  268.   [(set (match_operand:SI