OSDN Git Service

2007-04-04 Chen Liqin <liqin@sunnorth.com.cn>
[pf3gnuchains/gcc-fork.git] / gcc / config / score / mac.md
1 ;;  Machine description for Sunplus S+CORE
2 ;;  Copyright (C) 2005
3 ;;  Free Software Foundation, Inc.
4 ;;  Contributed by Sunnorth.
5
6 ;; This file is part of GCC.
7
8 ;; GCC 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 ;; GCC 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 GCC; see the file COPYING.  If not, write to
20 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
22
23 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
24
25 (define_insn "smaxsi3"
26   [(set (match_operand:SI 0 "register_operand" "=d")
27         (smax:SI (match_operand:SI 1 "register_operand" "d")
28                  (match_operand:SI 2 "register_operand" "d")))]
29   "TARGET_MAC || TARGET_SCORE7D"
30   "max     %0, %1, %2"
31   [(set_attr "type" "arith")
32    (set_attr "mode" "SI")])
33
34 (define_insn "sminsi3"
35   [(set (match_operand:SI 0 "register_operand" "=d")
36         (smin:SI (match_operand:SI 1 "register_operand" "d")
37                  (match_operand:SI 2 "register_operand" "d")))]
38   "TARGET_MAC || TARGET_SCORE7D"
39   "min     %0, %1, %2"
40   [(set_attr "type" "arith")
41    (set_attr "mode" "SI")])
42
43 (define_insn "abssi2"
44   [(set (match_operand:SI 0 "register_operand" "=d")
45         (abs:SI (match_operand:SI 1 "register_operand" "d")))]
46   "TARGET_MAC || TARGET_SCORE7D"
47   "abs     %0, %1"
48   [(set_attr "type" "arith")
49    (set_attr "mode" "SI")])
50
51 (define_insn "clzsi2"
52   [(set (match_operand:SI 0 "register_operand" "=d")
53         (clz:SI (match_operand:SI 1 "register_operand" "d")))]
54   "TARGET_MAC || TARGET_SCORE7D"
55   "clz     %0, %1"
56   [(set_attr "type" "arith")
57    (set_attr "mode" "SI")])
58
59 (define_insn "sffs"
60   [(set (match_operand:SI 0 "register_operand" "=d")
61         (unspec:SI [(match_operand:SI 1 "register_operand" "d")] SFFS))]
62   "TARGET_MAC || TARGET_SCORE7D"
63   "bitrev  %0, %1, r0\;clz     %0, %0\;addi    %0, 0x1"
64   [(set_attr "type" "arith")
65    (set_attr "mode" "SI")])
66
67 (define_expand "ffssi2"
68   [(set (match_operand:SI 0 "register_operand")
69         (ffs:SI (match_operand:SI 1 "register_operand")))]
70   "TARGET_MAC || TARGET_SCORE7D"
71 {
72   emit_insn (gen_sffs (operands[0], operands[1]));
73   emit_insn (gen_rtx_SET (VOIDmode, gen_rtx_REG (CC_NZmode, CC_REGNUM),
74                           gen_rtx_COMPARE (CC_NZmode, operands[0],
75                                            GEN_INT (33))));
76   emit_insn (gen_movsicc_internal (operands[0],
77              gen_rtx_fmt_ee (EQ, VOIDmode, operands[0], GEN_INT (33)),
78              GEN_INT (0),
79              operands[0]));
80   DONE;
81 })
82
83 (define_peephole2
84   [(set (match_operand:SI 0 "loreg_operand" "")
85         (match_operand:SI 1 "register_operand" ""))
86    (set (match_operand:SI 2 "hireg_operand" "")
87         (match_operand:SI 3 "register_operand" ""))]
88   "TARGET_MAC || TARGET_SCORE7D"
89   [(parallel
90        [(set (match_dup 0) (match_dup 1))
91         (set (match_dup 2) (match_dup 3))])])
92
93 (define_peephole2
94   [(set (match_operand:SI 0 "hireg_operand" "")
95         (match_operand:SI 1 "register_operand" ""))
96    (set (match_operand:SI 2 "loreg_operand" "")
97         (match_operand:SI 3 "register_operand" ""))]
98   "TARGET_MAC || TARGET_SCORE7D"
99   [(parallel
100        [(set (match_dup 2) (match_dup 3))
101         (set (match_dup 0) (match_dup 1))])])
102
103 (define_insn "movtohilo"
104   [(parallel
105        [(set (match_operand:SI 0 "loreg_operand" "=l")
106              (match_operand:SI 1 "register_operand" "d"))
107         (set (match_operand:SI 2 "hireg_operand" "=h")
108              (match_operand:SI 3 "register_operand" "d"))])]
109   "TARGET_MAC || TARGET_SCORE7D"
110   "mtcehl  %3, %1"
111   [(set_attr "type" "fce")
112    (set_attr "mode" "SI")])
113
114 (define_insn "mulsi3addsi"
115   [(set (match_operand:SI 0 "register_operand" "=l,l,d")
116         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "d,d,d")
117                           (match_operand:SI 3 "register_operand" "d,d,d"))
118                  (match_operand:SI 1 "register_operand" "0,d,l")))
119    (clobber (reg:SI HI_REGNUM))]
120   "TARGET_MAC || TARGET_SCORE7D"
121   "@
122    mad     %2, %3
123    mtcel%S1 %1\;mad     %2, %3
124    mad      %2, %3\;mfcel%S0 %0"
125   [(set_attr "mode" "SI")])
126
127 (define_insn "mulsi3subsi"
128   [(set (match_operand:SI 0 "register_operand" "=l,l,d")
129         (minus:SI (match_operand:SI 1 "register_operand" "0,d,l")
130                   (mult:SI (match_operand:SI 2 "register_operand" "d,d,d")
131                            (match_operand:SI 3 "register_operand" "d,d,d"))))
132    (clobber (reg:SI HI_REGNUM))]
133   "TARGET_MAC || TARGET_SCORE7D"
134   "@
135    msb     %2, %3
136    mtcel%S1 %1\;msb     %2, %3
137    msb     %2, %3\;mfcel%S0 %0"
138   [(set_attr "mode" "SI")])
139
140 (define_insn "mulsidi3adddi"
141   [(set (match_operand:DI 0 "register_operand" "=x")
142         (plus:DI (mult:DI
143                   (sign_extend:DI (match_operand:SI 2 "register_operand" "%d"))
144                   (sign_extend:DI (match_operand:SI 3 "register_operand" "d")))
145                  (match_operand:DI 1 "register_operand" "0")))]
146   "TARGET_MAC || TARGET_SCORE7D"
147   "mad     %2, %3"
148   [(set_attr "mode" "DI")])
149
150 (define_insn "umulsidi3adddi"
151   [(set (match_operand:DI 0 "register_operand" "=x")
152         (plus:DI (mult:DI
153                   (zero_extend:DI (match_operand:SI 2 "register_operand" "%d"))
154                   (zero_extend:DI (match_operand:SI 3 "register_operand" "d")))
155                  (match_operand:DI 1 "register_operand" "0")))]
156   "TARGET_MAC || TARGET_SCORE7D"
157   "madu    %2, %3"
158   [(set_attr "mode" "DI")])
159
160 (define_insn "mulsidi3subdi"
161   [(set (match_operand:DI 0 "register_operand" "=x")
162         (minus:DI
163          (match_operand:DI 1 "register_operand" "0")
164          (mult:DI
165           (sign_extend:DI (match_operand:SI 2 "register_operand" "%d"))
166           (sign_extend:DI (match_operand:SI 3 "register_operand" "d")))))]
167   "TARGET_MAC || TARGET_SCORE7D"
168   "msb     %2, %3"
169   [(set_attr "mode" "DI")])
170
171 (define_insn "umulsidi3subdi"
172   [(set (match_operand:DI 0 "register_operand" "=x")
173         (minus:DI
174          (match_operand:DI 1 "register_operand" "0")
175          (mult:DI (zero_extend:DI
176                    (match_operand:SI 2 "register_operand" "%d"))
177                   (zero_extend:DI
178                    (match_operand:SI 3 "register_operand" "d")))))]
179   "TARGET_MAC || TARGET_SCORE7D"
180   "msbu    %2, %3"
181   [(set_attr "mode" "DI")])