]> gcc.gnu.org Git - gcc.git/blame - gcc/config/rs6000/rs6000.md
(fix_truncdfsi2, fixuns_truncdfsi2, trunc_call): Fix typo in type of
[gcc.git] / gcc / config / rs6000 / rs6000.md
CommitLineData
1fd4e8c1 1;;- Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
b542afe9 2;; Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
1fd4e8c1
RK
3;; Contributed by Richard Kenner (kenner@nyu.edu)
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;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
22\f
23;; Define an insn type attribute. This is used in function unit delay
24;; computations.
5c23c401 25(define_attr "type" "load,integer,fp,compare,delayed_compare,fpcompare,mtlr"
1fd4e8c1
RK
26 (const_string "integer"))
27
28;; Memory delivers its result in two cycles.
29(define_function_unit "memory" 1 0 (eq_attr "type" "load") 2 0)
30
31;; We consider floating-point insns to deliver their result in two cycles
32;; to try to intersperse integer and FP operations.
33(define_function_unit "fp" 1 0 (eq_attr "type" "fp,fpcompare") 2 0)
34
35;; Most integer comparisons are ready in four cycles (a stall of three).
36(define_function_unit "compare" 1 0 (eq_attr "type" "compare") 4 0)
37
38;; Some integer comparisons aren't ready for five cycles (a stall of four).
39(define_function_unit "compare" 1 0 (eq_attr "type" "delayed_compare") 5 0)
40
41;; Floating-point comparisons take eight cycles.
42(define_function_unit "compare" 1 0 (eq_attr "type" "fpcompare") 8 0)
5c23c401
RK
43
44;; Branches on LR cannot be done until five cycles after LR is set.
45(define_function_unit "branch" 1 0 (eq_attr "type" "mtlr") 5 0)
1fd4e8c1
RK
46\f
47;; Start with fixed-point load and store insns. Here we put only the more
48;; complex forms. Basic data transfer is done later.
49
50(define_expand "zero_extendqisi2"
cd2b37d9
RK
51 [(set (match_operand:SI 0 "gpc_reg_operand" "")
52 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
53 ""
54 "")
55
56(define_insn ""
cd2b37d9 57 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
58 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
59 ""
60 "@
61 lbz%U1%X1 %0,%1
62 rlinm %0,%1,0,24,31"
63 [(set_attr "type" "load,*")])
64
65(define_insn ""
66 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9 67 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
1fd4e8c1
RK
68 (const_int 0)))
69 (clobber (match_scratch:SI 2 "=r"))]
70 ""
71 "andil. %2,%1,255"
72 [(set_attr "type" "compare")])
73
74(define_insn ""
75 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
cd2b37d9 76 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
1fd4e8c1 77 (const_int 0)))
cd2b37d9 78 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
79 (zero_extend:SI (match_dup 1)))]
80 ""
81 "andil. %0,%1,255"
82 [(set_attr "type" "compare")])
83
84(define_expand "zero_extendqihi2"
cd2b37d9
RK
85 [(set (match_operand:HI 0 "gpc_reg_operand" "")
86 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
87 ""
88 "")
89
90(define_insn ""
cd2b37d9 91 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
92 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
93 ""
94 "@
95 lbz%U1%X1 %0,%1
96 rlinm %0,%1,0,24,31"
97 [(set_attr "type" "load,*")])
98
99(define_expand "zero_extendhisi2"
5f243543 100 [(set (match_operand:SI 0 "gpc_reg_operand" "")
cd2b37d9 101 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
102 ""
103 "")
104
105(define_insn ""
cd2b37d9 106 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
107 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
108 ""
109 "@
110 lhz%U1%X1 %0,%1
111 rlinm %0,%1,0,16,31"
112 [(set_attr "type" "load,*")])
113
114(define_insn ""
115 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9 116 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
1fd4e8c1
RK
117 (const_int 0)))
118 (clobber (match_scratch:SI 2 "=r"))]
119 ""
120 "andil. %2,%1,65535"
121 [(set_attr "type" "compare")])
122
123(define_insn ""
124 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
cd2b37d9 125 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
1fd4e8c1 126 (const_int 0)))
cd2b37d9 127 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
128 (zero_extend:SI (match_dup 1)))]
129 ""
130 "andil. %0,%1,65535"
131 [(set_attr "type" "compare")])
132
133(define_expand "extendhisi2"
cd2b37d9
RK
134 [(set (match_operand:SI 0 "gpc_reg_operand" "")
135 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
136 ""
137 "")
138
139(define_insn ""
cd2b37d9 140 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
141 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
142 ""
143 "@
144 lha%U1%X1 %0,%1
145 exts %0,%1"
146 [(set_attr "type" "load,*")])
147
148(define_insn ""
149 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9 150 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
1fd4e8c1
RK
151 (const_int 0)))
152 (clobber (match_scratch:SI 2 "=r"))]
153 ""
154 "exts. %2,%1"
155 [(set_attr "type" "compare")])
156
157(define_insn ""
158 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
cd2b37d9 159 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
1fd4e8c1 160 (const_int 0)))
cd2b37d9 161 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
162 (sign_extend:SI (match_dup 1)))]
163 ""
164 "exts. %0,%1"
165 [(set_attr "type" "compare")])
166\f
167;; Fixed-point arithmetic insns.
f357808b 168(define_insn "addsi3"
cd2b37d9
RK
169 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
170 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,b")
1fd4e8c1
RK
171 (match_operand:SI 2 "add_operand" "rI,J")))]
172 ""
173 "@
174 a%I2 %0,%1,%2
175 cau %0,%1,%u2")
176
177(define_insn ""
178 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9 179 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
180 (match_operand:SI 2 "reg_or_short_operand" "rI"))
181 (const_int 0)))
182 (clobber (match_scratch:SI 3 "=r"))]
183 ""
184 "a%I2. %3,%1,%2"
185 [(set_attr "type" "compare")])
186
187(define_insn ""
188 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
cd2b37d9 189 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
190 (match_operand:SI 2 "reg_or_short_operand" "rI"))
191 (const_int 0)))
cd2b37d9 192 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
193 (plus:SI (match_dup 1) (match_dup 2)))]
194 ""
195 "a%I2. %0,%1,%2"
196 [(set_attr "type" "compare")])
197
f357808b
RK
198;; Split an add that we can't do in one insn into two insns, each of which
199;; does one 16-bit part. This is used by combine. Note that the low-order
200;; add should be last in case the result gets used in an address.
201
202(define_split
cd2b37d9
RK
203 [(set (match_operand:SI 0 "gpc_reg_operand" "")
204 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
f357808b 205 (match_operand:SI 2 "non_add_cint_operand" "")))]
1fd4e8c1 206 ""
f357808b
RK
207 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
208 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
209"
1fd4e8c1 210{
f357808b
RK
211 int low = INTVAL (operands[2]) & 0xffff;
212 int high = (unsigned) INTVAL (operands[2]) >> 16;
1fd4e8c1 213
f357808b
RK
214 if (low & 0x8000)
215 high++, low |= 0xffff0000;
1fd4e8c1 216
f357808b
RK
217 operands[3] = gen_rtx (CONST_INT, VOIDmode, high << 16);
218 operands[4] = gen_rtx (CONST_INT, VOIDmode, low);
1fd4e8c1
RK
219}")
220
221(define_insn "one_cmplsi2"
cd2b37d9
RK
222 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
223 (not:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1fd4e8c1
RK
224 ""
225 "sfi %0,%1,-1")
226
227(define_insn ""
cd2b37d9 228 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 229 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "r,I")
cd2b37d9 230 (match_operand:SI 2 "gpc_reg_operand" "r,r")))]
1fd4e8c1
RK
231 ""
232 "@
233 sf %0,%2,%1
234 sfi %0,%2,%1")
235
236(define_insn ""
237 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9
RK
238 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
239 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1
RK
240 (const_int 0)))
241 (clobber (match_scratch:SI 3 "=r"))]
242 ""
243 "sf. %3,%2,%1"
244 [(set_attr "type" "compare")])
245
246(define_insn ""
247 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
cd2b37d9
RK
248 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
249 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1 250 (const_int 0)))
cd2b37d9 251 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
252 (minus:SI (match_dup 1) (match_dup 2)))]
253 ""
254 "sf. %0,%2,%1"
255 [(set_attr "type" "compare")])
256
257(define_expand "subsi3"
cd2b37d9 258 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
259 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "")
260 (match_operand:SI 2 "reg_or_cint_operand" "")))]
261 ""
a0044fb1
RK
262 "
263{
264 if (GET_CODE (operands[2]) == CONST_INT)
265 {
266 emit_insn (gen_addsi3 (operands[0], operands[1],
267 negate_rtx (SImode, operands[2])));
268 DONE;
269 }
270}")
1fd4e8c1
RK
271
272;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
273;; instruction and some auxiliary computations. Then we just have a single
95ac8e67
RK
274;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
275;; combine.
1fd4e8c1
RK
276
277(define_expand "sminsi3"
278 [(set (match_dup 3)
cd2b37d9 279 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
280 (match_operand:SI 2 "reg_or_short_operand" ""))
281 (const_int 0)
282 (minus:SI (match_dup 2) (match_dup 1))))
cd2b37d9 283 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
284 (minus:SI (match_dup 2) (match_dup 3)))]
285 ""
286 "
287{ operands[3] = gen_reg_rtx (SImode); }")
288
95ac8e67
RK
289(define_split
290 [(set (match_operand:SI 0 "gpc_reg_operand" "")
291 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
292 (match_operand:SI 2 "reg_or_short_operand" "")))
293 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
294 ""
295 [(set (match_dup 3)
296 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
297 (const_int 0)
298 (minus:SI (match_dup 2) (match_dup 1))))
299 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
300 "")
301
1fd4e8c1
RK
302(define_expand "smaxsi3"
303 [(set (match_dup 3)
cd2b37d9 304 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
305 (match_operand:SI 2 "reg_or_short_operand" ""))
306 (const_int 0)
307 (minus:SI (match_dup 2) (match_dup 1))))
cd2b37d9 308 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
309 (plus:SI (match_dup 3) (match_dup 1)))]
310 ""
311 "
312{ operands[3] = gen_reg_rtx (SImode); }")
313
95ac8e67
RK
314(define_split
315 [(set (match_operand:SI 0 "gpc_reg_operand" "")
316 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
317 (match_operand:SI 2 "reg_or_short_operand" "")))
318 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
319 ""
320 [(set (match_dup 3)
321 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
322 (const_int 0)
323 (minus:SI (match_dup 2) (match_dup 1))))
324 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
325 "")
326
1fd4e8c1 327(define_expand "uminsi3"
cd2b37d9 328 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 329 (const_int -2147483648)))
cd2b37d9 330 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1fd4e8c1
RK
331 (const_int -2147483648)))
332 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
333 (const_int 0)
334 (minus:SI (match_dup 4) (match_dup 3))))
cd2b37d9 335 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
336 (minus:SI (match_dup 2) (match_dup 3)))]
337 ""
338 "
339{ operands[3] = gen_reg_rtx (SImode); operands[4] = gen_reg_rtx (SImode); }")
340
341(define_expand "umaxsi3"
cd2b37d9 342 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 343 (const_int -2147483648)))
cd2b37d9 344 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1fd4e8c1
RK
345 (const_int -2147483648)))
346 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
347 (const_int 0)
348 (minus:SI (match_dup 4) (match_dup 3))))
cd2b37d9 349 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
350 (plus:SI (match_dup 3) (match_dup 1)))]
351 ""
352 "
353{ operands[3] = gen_reg_rtx (SImode); operands[4] = gen_reg_rtx (SImode); }")
354
355(define_insn ""
cd2b37d9
RK
356 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
357 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
5c23c401 358 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1fd4e8c1
RK
359 (const_int 0)
360 (minus:SI (match_dup 2) (match_dup 1))))]
361 ""
362 "doz%I2 %0,%1,%2")
363
364(define_insn ""
365 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
366 (compare:CC
cd2b37d9 367 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
5c23c401 368 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1fd4e8c1
RK
369 (const_int 0)
370 (minus:SI (match_dup 2) (match_dup 1)))
371 (const_int 0)))
372 (clobber (match_scratch:SI 3 "=r"))]
373 ""
374 "doz%I2. %3,%1,%2"
375 [(set_attr "type" "delayed_compare")])
376
377(define_insn ""
378 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
379 (compare:CC
cd2b37d9 380 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
5c23c401 381 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1fd4e8c1
RK
382 (const_int 0)
383 (minus:SI (match_dup 2) (match_dup 1)))
384 (const_int 0)))
cd2b37d9 385 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
386 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
387 (const_int 0)
388 (minus:SI (match_dup 2) (match_dup 1))))]
389 ""
390 "doz%I2. %0,%1,%2"
391 [(set_attr "type" "delayed_compare")])
392
393;; We don't need abs with condition code because such comparisons should
394;; never be done.
395(define_insn "abssi2"
cd2b37d9
RK
396 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
397 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1fd4e8c1
RK
398 ""
399 "abs %0,%1")
400
401(define_insn ""
cd2b37d9
RK
402 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
403 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
1fd4e8c1
RK
404 ""
405 "nabs %0,%1")
406
407(define_insn "negsi2"
cd2b37d9
RK
408 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
409 (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1fd4e8c1
RK
410 ""
411 "neg %0,%1")
412
413(define_insn ""
414 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9 415 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1fd4e8c1
RK
416 (const_int 0)))
417 (clobber (match_scratch:SI 2 "=r"))]
418 ""
419 "neg. %2,%1"
420 [(set_attr "type" "compare")])
421
422(define_insn ""
423 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
cd2b37d9 424 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1fd4e8c1 425 (const_int 0)))
cd2b37d9 426 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
427 (neg:SI (match_dup 1)))]
428 ""
429 "neg. %0,%1"
430 [(set_attr "type" "compare")])
431
432(define_insn "ffssi2"
433 [(set (match_operand:SI 0 "register_operand" "=&r")
434 (ffs:SI (match_operand:SI 1 "register_operand" "r")))]
435 ""
436 "neg %0,%1\;and %0,%0,%1\;cntlz %0,%0\;sfi %0,%0,32")
437
438;; There is no need for (set (condition) (compare (ffs) 0)) because that
439;; can be simplified to an ordinary comparison. A parallel set and compare
440;; might be used, so include it.
441
442(define_insn ""
443 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
444 (compare:CC (ffs:SI (match_operand:SI 1 "register_operand" "r"))
445 (const_int 0)))
446 (set (match_operand:SI 0 "register_operand" "=&r")
447 (ffs:SI (match_dup 1)))]
448 ""
449 "neg %0,%1\;and %0,%0,%1\;cntlz %0,%0\;sfi. %0,%0,32"
450 [(set_attr "type" "compare")])
451
452(define_insn "mulsi3"
cd2b37d9
RK
453 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
454 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1fd4e8c1
RK
455 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
456 (clobber (match_scratch:SI 3 "=q,q"))]
457 ""
458 "@
459 muls %0,%1,%2
460 muli %0,%1,%2")
461
462(define_insn ""
463 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9
RK
464 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "r")
465 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1
RK
466 (const_int 0)))
467 (clobber (match_scratch:SI 3 "=r"))
468 (clobber (match_scratch:SI 4 "=q"))]
469 ""
470 "muls. %3,%1,%2"
471 [(set_attr "type" "delayed_compare")])
472
473(define_insn ""
474 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
cd2b37d9
RK
475 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "r")
476 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1 477 (const_int 0)))
cd2b37d9 478 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
479 (mult:SI (match_dup 1) (match_dup 2)))
480 (clobber (match_scratch:SI 4 "=q"))]
481 ""
482 "muls. %0,%1,%2"
483 [(set_attr "type" "delayed_compare")])
484
485;; Operand 1 is divided by operand 2; quotient goes to operand
486;; 0 and remainder to operand 3.
487;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
488
489(define_insn "divmodsi4"
cd2b37d9
RK
490 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
491 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
492 (match_operand:SI 2 "gpc_reg_operand" "r")))
493 (set (match_operand:SI 3 "gpc_reg_operand" "=q")
1fd4e8c1
RK
494 (mod:SI (match_dup 1) (match_dup 2)))]
495 ""
496 "divs %0,%1,%2")
497
498;; For powers of two we can do srai/aze for divide and then adjust for
499;; modulus. If it isn't a power of two, FAIL so divmodsi4 will be used.
500(define_expand "divsi3"
cd2b37d9
RK
501 [(set (match_operand:SI 0 "gpc_reg_operand" "")
502 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
503 (match_operand:SI 2 "reg_or_cint_operand" "")))]
504 ""
505 "
506{
507 if (GET_CODE (operands[2]) != CONST_INT
508 || exact_log2 (INTVAL (operands[2])) < 0)
509 FAIL;
510}")
511
512(define_expand "modsi3"
513 [(set (match_dup 3)
cd2b37d9 514 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
515 (match_operand:SI 2 "reg_or_cint_operand" "")))
516 (parallel [(set (match_dup 4) (ashift:SI (match_dup 3) (match_dup 5)))
517 (clobber (scratch:SI))])
cd2b37d9 518 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
519 (minus:SI (match_dup 1) (match_dup 4)))]
520 ""
521 "
522{
523 int i = exact_log2 (INTVAL (operands[2]));
524
525 if (GET_CODE (operands[2]) != CONST_INT || i < 0)
526 FAIL;
527
528 operands[3] = gen_reg_rtx (SImode);
529 operands[4] = gen_reg_rtx (SImode);
530 operands[5] = gen_rtx (CONST_INT, VOIDmode, i);
531}")
532
533(define_insn ""
cd2b37d9
RK
534 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
535 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
536 (match_operand:SI 2 "const_int_operand" "N")))]
537 "exact_log2 (INTVAL (operands[2])) >= 0"
538 "srai %0,%1,%p2\;aze %0,%0")
539
540(define_insn ""
541 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9 542 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
543 (match_operand:SI 2 "const_int_operand" "N")))
544 (clobber (match_scratch:SI 3 "=r"))]
545 "exact_log2 (INTVAL (operands[2])) >= 0"
546 "srai %3,%1,%p2\;aze. %3,%3"
547 [(set_attr "type" "compare")])
548
549(define_insn ""
550 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
cd2b37d9 551 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 552 (match_operand:SI 2 "const_int_operand" "N")))
cd2b37d9 553 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
554 (div:SI (match_dup 1) (match_dup 2)))]
555 "exact_log2 (INTVAL (operands[2])) >= 0"
556 "srai %0,%1,%p2\;aze. %0,%0"
557 [(set_attr "type" "compare")])
558
559(define_insn ""
cd2b37d9 560 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
561 (udiv:SI
562 (plus:DI (lshift:DI
cd2b37d9 563 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
1fd4e8c1 564 (const_int 32))
23a900dc 565 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
cd2b37d9 566 (match_operand:SI 3 "gpc_reg_operand" "r")))
740ab4a2 567 (set (match_operand:SI 2 "register_operand" "=*q")
1fd4e8c1
RK
568 (umod:SI
569 (plus:DI (lshift:DI
570 (zero_extend:DI (match_dup 1)) (const_int 32))
740ab4a2 571 (zero_extend:DI (match_dup 4)))
1fd4e8c1
RK
572 (match_dup 3)))]
573
574 ""
575 "div %0,%1,%3")
576
577;; To do unsigned divide we handle the cases of the divisor looking like a
578;; negative number. If it is a constant that is less than 2**31, we don't
579;; have to worry about the branches. So make a few subroutines here.
580;;
581;; First comes the normal case.
582(define_expand "udivmodsi4_normal"
583 [(set (match_dup 4) (const_int 0))
584 (parallel [(set (match_operand:SI 0 "" "")
585 (udiv:SI (plus:DI (lshift:DI (zero_extend:DI (match_dup 4))
586 (const_int 32))
587 (zero_extend:DI (match_operand:SI 1 "" "")))
588 (match_operand:SI 2 "" "")))
589 (set (match_operand:SI 3 "" "")
590 (umod:SI (plus:DI (lshift:DI (zero_extend:DI (match_dup 4))
591 (const_int 32))
592 (zero_extend:DI (match_dup 1)))
593 (match_dup 2)))])]
594 ""
595 "
596{ operands[4] = gen_reg_rtx (SImode); }")
597
598;; This handles the branches.
599(define_expand "udivmodsi4_tests"
600 [(set (match_operand:SI 0 "" "") (const_int 0))
601 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
602 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
603 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
604 (label_ref (match_operand:SI 4 "" "")) (pc)))
605 (set (match_dup 0) (const_int 1))
606 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
607 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
608 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
609 (label_ref (match_dup 4)) (pc)))]
610 ""
611 "
612{ operands[5] = gen_reg_rtx (CCUNSmode);
613 operands[6] = gen_reg_rtx (CCmode);
614}")
615
616(define_expand "udivmodsi4"
cd2b37d9
RK
617 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
618 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 619 (match_operand:SI 2 "reg_or_cint_operand" "")))
cd2b37d9 620 (set (match_operand:SI 3 "gpc_reg_operand" "")
1fd4e8c1
RK
621 (umod:SI (match_dup 1) (match_dup 2)))])]
622 ""
623 "
624{
625 rtx label = 0;
626
627 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
628 {
629 operands[2] = force_reg (SImode, operands[2]);
630 label = gen_label_rtx ();
631 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
632 operands[3], label));
633 }
634 else
635 operands[2] = force_reg (SImode, operands[2]);
636
637 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
638 operands[3]));
639 if (label)
640 emit_label (label);
641
642 DONE;
643}")
644
645(define_insn "andsi3"
cd2b37d9
RK
646 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
647 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1fd4e8c1
RK
648 (match_operand:SI 2 "and_operand" "?r,L,K,J")))
649 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
650 ""
651 "@
652 and %0,%1,%2
653 rlinm %0,%1,0,%m2,%M2
654 andil. %0,%1,%b2
655 andiu. %0,%1,%u2")
656
657(define_insn ""
658 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x")
cd2b37d9 659 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1fd4e8c1
RK
660 (match_operand:SI 2 "and_operand" "r,K,J,L"))
661 (const_int 0)))
662 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
663 ""
664 "@
665 and. %3,%1,%2
666 andil. %3,%1,%b2
667 andiu. %3,%1,%u2
668 rlinm. %3,%1,0,%m2,%M2"
669 [(set_attr "type" "compare,compare,compare,delayed_compare")])
670
671(define_insn ""
672 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x")
cd2b37d9 673 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1fd4e8c1
RK
674 (match_operand:SI 2 "and_operand" "r,K,J,L"))
675 (const_int 0)))
cd2b37d9 676 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1
RK
677 (and:SI (match_dup 1) (match_dup 2)))]
678 ""
679 "@
680 and. %0,%1,%2
681 andil. %0,%1,%b2
682 andiu. %0,%1,%u2
683 rlinm. %0,%1,0,%m2,%M2"
684 [(set_attr "type" "compare,compare,compare,delayed_compare")])
685
f357808b
RK
686;; Take a AND with a constant that cannot be done in a single insn and try to
687;; split it into two insns. This does not verify that the insns are valid
688;; since this need not be done as combine will do it.
689
690(define_split
cd2b37d9
RK
691 [(set (match_operand:SI 0 "gpc_reg_operand" "")
692 (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
f357808b
RK
693 (match_operand:SI 2 "non_and_cint_operand" "")))]
694 ""
695 [(set (match_dup 0) (and:SI (match_dup 1) (match_dup 3)))
696 (set (match_dup 0) (and:SI (match_dup 0) (match_dup 4)))]
697 "
698{
699 int maskval = INTVAL (operands[2]);
700 int i, transitions, last_bit_value;
701 int orig = maskval, first_c = maskval, second_c;
702
703 /* We know that MASKVAL must have more than 2 bit-transitions. Start at
704 the low-order bit and count for the third transition. When we get there,
705 make a first mask that has everything to the left of that position
706 a one. Then make the second mask to turn off whatever else is needed. */
707
708 for (i = 1, transitions = 0, last_bit_value = maskval & 1; i < 32; i++)
709 {
710 if (((maskval >>= 1) & 1) != last_bit_value)
711 last_bit_value ^= 1, transitions++;
712
713 if (transitions > 2)
714 {
715 first_c |= (~0) << i;
716 break;
717 }
718 }
719
720 second_c = orig | ~ first_c;
721
722 operands[3] = gen_rtx (CONST_INT, VOIDmode, first_c);
723 operands[4] = gen_rtx (CONST_INT, VOIDmode, second_c);
724}")
725
726(define_insn "iorsi3"
cd2b37d9
RK
727 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
728 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
1fd4e8c1
RK
729 (match_operand:SI 2 "logical_operand" "r,K,J")))]
730 ""
731 "@
732 or %0,%1,%2
733 oril %0,%1,%b2
734 oriu %0,%1,%u2")
735
736(define_insn ""
737 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9
RK
738 (compare:CC (ior:SI (match_operand:SI 1 "gpc_reg_operand" "r")
739 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1
RK
740 (const_int 0)))
741 (clobber (match_scratch:SI 3 "=r"))]
742 ""
743 "or. %3,%1,%2"
744 [(set_attr "type" "compare")])
745
746(define_insn ""
747 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
cd2b37d9
RK
748 (compare:CC (ior:SI (match_operand:SI 1 "gpc_reg_operand" "r")
749 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1 750 (const_int 0)))
cd2b37d9 751 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
752 (ior:SI (match_dup 1) (match_dup 2)))]
753 ""
754 "or. %0,%1,%2"
755 [(set_attr "type" "compare")])
756
f357808b
RK
757;; Split an IOR that we can't do in one insn into two insns, each of which
758;; does one 16-bit part. This is used by combine.
759
760(define_split
cd2b37d9
RK
761 [(set (match_operand:SI 0 "gpc_reg_operand" "")
762 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
f357808b 763 (match_operand:SI 2 "non_logical_cint_operand" "")))]
1fd4e8c1 764 ""
f357808b
RK
765 [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 3)))
766 (set (match_dup 0) (ior:SI (match_dup 0) (match_dup 4)))]
767"
1fd4e8c1 768{
f357808b
RK
769 operands[3] = gen_rtx (CONST_INT, VOIDmode,
770 INTVAL (operands[2]) & 0xffff0000);
771 operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
1fd4e8c1
RK
772}")
773
f357808b 774(define_insn "xorsi3"
cd2b37d9
RK
775 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
776 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
1fd4e8c1
RK
777 (match_operand:SI 2 "logical_operand" "r,K,J")))]
778 ""
779 "@
780 xor %0,%1,%2
781 xoril %0,%1,%b2
782 xoriu %0,%1,%u2")
783
784(define_insn ""
785 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9
RK
786 (compare:CC (xor:SI (match_operand:SI 1 "gpc_reg_operand" "r")
787 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1
RK
788 (const_int 0)))
789 (clobber (match_scratch:SI 3 "=r"))]
790 ""
791 "xor. %3,%1,%2"
792 [(set_attr "type" "compare")])
793
794(define_insn ""
795 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
cd2b37d9
RK
796 (compare:CC (xor:SI (match_operand:SI 1 "gpc_reg_operand" "r")
797 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1 798 (const_int 0)))
cd2b37d9 799 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
800 (xor:SI (match_dup 1) (match_dup 2)))]
801 ""
802 "xor. %0,%1,%2"
803 [(set_attr "type" "compare")])
804
f357808b
RK
805;; Split an XOR that we can't do in one insn into two insns, each of which
806;; does one 16-bit part. This is used by combine.
807
808(define_split
cd2b37d9
RK
809 [(set (match_operand:SI 0 "gpc_reg_operand" "")
810 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
f357808b 811 (match_operand:SI 2 "non_logical_cint_operand" "")))]
1fd4e8c1 812 ""
f357808b
RK
813 [(set (match_dup 0) (xor:SI (match_dup 1) (match_dup 3)))
814 (set (match_dup 0) (xor:SI (match_dup 0) (match_dup 4)))]
815"
1fd4e8c1 816{
f357808b
RK
817 operands[3] = gen_rtx (CONST_INT, VOIDmode,
818 INTVAL (operands[2]) & 0xffff0000);
819 operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
1fd4e8c1
RK
820}")
821
822(define_insn ""
cd2b37d9
RK
823 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
824 (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
825 (match_operand:SI 2 "gpc_reg_operand" "r"))))]
1fd4e8c1
RK
826 ""
827 "eqv %0,%1,%2")
828
829(define_insn ""
830 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9
RK
831 (compare:CC (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
832 (match_operand:SI 2 "gpc_reg_operand" "r")))
1fd4e8c1
RK
833 (const_int 0)))
834 (clobber (match_scratch:SI 3 "=r"))]
835 ""
836 "eqv. %3,%1,%2"
837 [(set_attr "type" "compare")])
838
839(define_insn ""
840 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
cd2b37d9
RK
841 (compare:CC (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
842 (match_operand:SI 2 "gpc_reg_operand" "r")))
1fd4e8c1 843 (const_int 0)))
cd2b37d9 844 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
845 (not:SI (xor:SI (match_dup 1) (match_dup 2))))]
846 ""
847 "eqv. %0,%1,%2"
848 [(set_attr "type" "compare")])
849
850(define_insn ""
cd2b37d9
RK
851 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
852 (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
853 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1fd4e8c1
RK
854 ""
855 "andc %0,%2,%1")
856
857(define_insn ""
858 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9
RK
859 (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
860 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1
RK
861 (const_int 0)))
862 (clobber (match_scratch:SI 3 "=r"))]
863 ""
864 "andc. %3,%2,%1"
865 [(set_attr "type" "compare")])
866
867(define_insn ""
868 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
cd2b37d9
RK
869 (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
870 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1 871 (const_int 0)))
cd2b37d9 872 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
873 (and:SI (not:SI (match_dup 1)) (match_dup 2)))]
874 ""
875 "andc. %0,%2,%1"
876 [(set_attr "type" "compare")])
877
878(define_insn ""
cd2b37d9
RK
879 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
880 (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
881 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1fd4e8c1
RK
882 ""
883 "orc %0,%2,%1")
884
885(define_insn ""
886 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9
RK
887 (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
888 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1
RK
889 (const_int 0)))
890 (clobber (match_scratch:SI 3 "=r"))]
891 ""
892 "orc. %3,%2,%1"
893 [(set_attr "type" "compare")])
894
895(define_insn ""
896 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
cd2b37d9
RK
897 (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
898 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1 899 (const_int 0)))
cd2b37d9 900 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
901 (ior:SI (not:SI (match_dup 1)) (match_dup 2)))]
902 ""
903 "orc. %0,%2,%1"
904 [(set_attr "type" "compare")])
905
906(define_insn ""
cd2b37d9
RK
907 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
908 (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
909 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
1fd4e8c1
RK
910 ""
911 "nand %0,%1,%2")
912
913(define_insn ""
914 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9
RK
915 (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
916 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1fd4e8c1
RK
917 (const_int 0)))
918 (clobber (match_scratch:SI 3 "=r"))]
919 ""
920 "nand. %3,%1,%2"
921 [(set_attr "type" "compare")])
922
923(define_insn ""
924 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
cd2b37d9
RK
925 (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
926 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1fd4e8c1 927 (const_int 0)))
cd2b37d9 928 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
929 (ior:SI (not:SI (match_dup 1)) (not:SI (match_dup 2))))]
930 ""
931 "nand. %0,%1,%2"
932 [(set_attr "type" "compare")])
933
934(define_insn ""
cd2b37d9
RK
935 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
936 (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
937 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
1fd4e8c1
RK
938 ""
939 "nor %0,%1,%2")
940
941(define_insn ""
942 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9
RK
943 (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
944 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1fd4e8c1
RK
945 (const_int 0)))
946 (clobber (match_scratch:SI 3 "=r"))]
947 ""
948 "nor. %3,%1,%2"
949 [(set_attr "type" "compare")])
950
951(define_insn ""
952 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
cd2b37d9
RK
953 (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
954 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1fd4e8c1 955 (const_int 0)))
cd2b37d9 956 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
957 (and:SI (not:SI (match_dup 1)) (not:SI (match_dup 2))))]
958 ""
959 "nor. %0,%1,%2"
960 [(set_attr "type" "compare")])
961
962;; maskir insn. We need four forms because things might be in arbitrary
963;; orders. Don't define forms that only set CR fields because these
964;; would modify an input register.
965
966(define_insn ""
cd2b37d9 967 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764
RK
968 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
969 (match_operand:SI 1 "gpc_reg_operand" "0"))
970 (and:SI (match_dup 2)
cd2b37d9 971 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
1fd4e8c1 972 ""
01def764 973 "maskir %0,%3,%2")
1fd4e8c1
RK
974
975(define_insn ""
976 [(set (match_operand:SI 0 "register_operand" "=r")
01def764
RK
977 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
978 (match_operand:SI 1 "gpc_reg_operand" "0"))
cd2b37d9 979 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
01def764 980 (match_dup 2))))]
1fd4e8c1 981 ""
01def764 982 "maskir %0,%3,%2")
1fd4e8c1
RK
983
984(define_insn ""
cd2b37d9 985 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764 986 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
cd2b37d9 987 (match_operand:SI 3 "gpc_reg_operand" "r"))
01def764
RK
988 (and:SI (not:SI (match_dup 2))
989 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
1fd4e8c1 990 ""
01def764 991 "maskir %0,%3,%2")
1fd4e8c1
RK
992
993(define_insn ""
cd2b37d9
RK
994 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
995 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
01def764
RK
996 (match_operand:SI 2 "gpc_reg_operand" "r"))
997 (and:SI (not:SI (match_dup 2))
998 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
1fd4e8c1 999 ""
01def764 1000 "maskir %0,%3,%2")
1fd4e8c1
RK
1001
1002(define_insn ""
1003 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
1004 (compare:CC
01def764
RK
1005 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
1006 (match_operand:SI 1 "gpc_reg_operand" "0"))
1007 (and:SI (match_dup 2)
cd2b37d9 1008 (match_operand:SI 3 "gpc_reg_operand" "r")))
1fd4e8c1 1009 (const_int 0)))
cd2b37d9 1010 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764
RK
1011 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
1012 (and:SI (match_dup 2) (match_dup 3))))]
1fd4e8c1 1013 ""
01def764 1014 "maskir. %0,%3,%2"
1fd4e8c1
RK
1015 [(set_attr "type" "compare")])
1016
1017(define_insn ""
1018 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
1019 (compare:CC
01def764
RK
1020 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
1021 (match_operand:SI 1 "gpc_reg_operand" "0"))
cd2b37d9 1022 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
01def764 1023 (match_dup 2)))
1fd4e8c1
RK
1024 (const_int 0)))
1025 (set (match_operand:SI 0 "register_operand" "=r")
01def764
RK
1026 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
1027 (and:SI (match_dup 3) (match_dup 2))))]
1fd4e8c1 1028 ""
01def764 1029 "maskir. %0,%3,%2"
1fd4e8c1
RK
1030 [(set_attr "type" "compare")])
1031
1032(define_insn ""
1033 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
1034 (compare:CC
01def764 1035 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
cd2b37d9 1036 (match_operand:SI 3 "gpc_reg_operand" "r"))
01def764
RK
1037 (and:SI (not:SI (match_dup 2))
1038 (match_operand:SI 1 "gpc_reg_operand" "0")))
1fd4e8c1 1039 (const_int 0)))
cd2b37d9 1040 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764
RK
1041 (ior:SI (and:SI (match_dup 2) (match_dup 3))
1042 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
1fd4e8c1 1043 ""
01def764 1044 "maskir. %0,%3,%2"
1fd4e8c1
RK
1045 [(set_attr "type" "compare")])
1046
1047(define_insn ""
1048 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
1049 (compare:CC
cd2b37d9 1050 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
01def764
RK
1051 (match_operand:SI 2 "gpc_reg_operand" "r"))
1052 (and:SI (not:SI (match_dup 2))
1053 (match_operand:SI 1 "gpc_reg_operand" "0")))
1fd4e8c1 1054 (const_int 0)))
cd2b37d9 1055 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
01def764
RK
1056 (ior:SI (and:SI (match_dup 3) (match_dup 2))
1057 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
1fd4e8c1 1058 ""
01def764 1059 "maskir. %0,%3,%2"
1fd4e8c1
RK
1060 [(set_attr "type" "compare")])
1061\f
1062;; Rotate and shift insns, in all their variants. These support shifts,
1063;; field inserts and extracts, and various combinations thereof.
1064(define_insn "insv"
cd2b37d9 1065 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1
RK
1066 (match_operand:SI 1 "const_int_operand" "i")
1067 (match_operand:SI 2 "const_int_operand" "i"))
cd2b37d9 1068 (match_operand:SI 3 "gpc_reg_operand" "r"))]
1fd4e8c1
RK
1069 ""
1070 "*
1071{
1072 int start = INTVAL (operands[2]) & 31;
1073 int size = INTVAL (operands[1]) & 31;
1074
1075 operands[4] = gen_rtx (CONST_INT, VOIDmode, 32 - start - size);
1076 operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
1077 return \"rlimi %0,%3,%4,%h2,%h1\";
1078}")
1079
1080(define_insn "extzv"
cd2b37d9
RK
1081 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1082 (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1083 (match_operand:SI 2 "const_int_operand" "i")
1084 (match_operand:SI 3 "const_int_operand" "i")))]
1085 ""
1086 "*
1087{
1088 int start = INTVAL (operands[3]) & 31;
1089 int size = INTVAL (operands[2]) & 31;
1090
1091 if (start + size >= 32)
1092 operands[3] = const0_rtx;
1093 else
1094 operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
1095 return \"rlinm %0,%1,%3,%s2,31\";
1096}")
1097
1098(define_insn ""
1099 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9 1100 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1101 (match_operand:SI 2 "const_int_operand" "i")
1102 (match_operand:SI 3 "const_int_operand" "i"))
1103 (const_int 0)))
1104 (clobber (match_scratch:SI 4 "=r"))]
1105 ""
1106 "*
1107{
1108 int start = INTVAL (operands[3]) & 31;
1109 int size = INTVAL (operands[2]) & 31;
1110
a7a975e1
RK
1111 /* If the bitfield being tested fits in the upper or lower half of a
1112 word, it is possible to use andiu. or andil. to test it. This is
1113 useful because the condition register set-use delay is smaller for
1114 andi[ul]. than for rlinm. This doesn't work when the starting bit
1115 position is 0 because the LT and GT bits may be set wrong. */
1116
1117 if ((start > 0 && start + size <= 16) || start >= 16)
df031c43
RK
1118 {
1119 operands[3] = gen_rtx (CONST_INT, VOIDmode,
1120 ((1 << (16 - (start & 15)))
1121 - (1 << (16 - (start & 15) - size))));
1122 if (start < 16)
1123 return \"andiu. %4,%1,%3\";
1124 else
1125 return \"andil. %4,%1,%3\";
1126 }
1127
1fd4e8c1
RK
1128 if (start + size >= 32)
1129 operands[3] = const0_rtx;
1130 else
1131 operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
1132 return \"rlinm. %4,%1,%3,%s2,31\";
1133}"
1134 [(set_attr "type" "compare")])
1135
1136(define_insn ""
1137 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
cd2b37d9 1138 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1139 (match_operand:SI 2 "const_int_operand" "i")
1140 (match_operand:SI 3 "const_int_operand" "i"))
1141 (const_int 0)))
cd2b37d9 1142 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
1143 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
1144 ""
1145 "*
1146{
1147 int start = INTVAL (operands[3]) & 31;
1148 int size = INTVAL (operands[2]) & 31;
1149
a7a975e1 1150 if (start >= 16 && start + size == 32)
df031c43 1151 {
a7a975e1
RK
1152 operands[3] = gen_rtx (CONST_INT, VOIDmode, (1 << (32 - start)) - 1);
1153 return \"andil. %0,%1,%3\";
df031c43
RK
1154 }
1155
1fd4e8c1
RK
1156 if (start + size >= 32)
1157 operands[3] = const0_rtx;
1158 else
1159 operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
1160 return \"rlinm. %0,%1,%3,%s2,31\";
1161}"
1162 [(set_attr "type" "delayed_compare")])
1163
1164(define_insn "rotlsi3"
cd2b37d9
RK
1165 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1166 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1167 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
1168 ""
1169 "rl%I2nm %0,%1,%h2,0,31")
1170
1171(define_insn ""
1172 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
cd2b37d9 1173 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1174 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
1175 (const_int 0)))
1176 (clobber (match_scratch:SI 3 "=r"))]
1177 ""
1178 "rl%I2nm. %3,%1,%h2,0,31"
1179 [(set_attr "type" "delayed_compare")])
1180
1181(define_insn ""
1182 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
cd2b37d9 1183 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1184 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
1185 (const_int 0)))
cd2b37d9 1186 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
1187 (rotate:SI (match_dup 1) (match_dup 2)))]
1188 ""
1189 "rl%I2nm. %0,%1,%h2,0,31"
1190 [(set_attr "type" "delayed_compare")])
1191
1192(define_insn ""
cd2b37d9
RK
1193 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1194 (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1195 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
1196 (match_operand:SI 3 "mask_operand" "L")))]
1197 ""
1198 "rl%I2nm %0,%1,%h2,%m3,%M3")
1199
1200(define_insn ""
1201 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1202 (compare:CC (and:SI
cd2b37d9 1203 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1204 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
1205 (match_operand:SI 3 "mask_operand" "L"))
1206 (const_int 0)))
1207 (clobber (match_scratch:SI 4 "=r"))]
1208 ""
1209 "rl%I2nm. %4,%1,%h2,%m3,%M3"
1210 [(set_attr "type" "delayed_compare")])
1211
1212(define_insn ""
1213 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
1214 (compare:CC (and:SI
cd2b37d9 1215 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1216 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
1217 (match_operand:SI 3 "mask_operand" "L"))
1218 (const_int 0)))
cd2b37d9 1219 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
1220 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
1221 ""
1222 "rl%I2nm. %0,%1,%h2,%m3,%M3"
1223 [(set_attr "type" "delayed_compare")])
1224
1225(define_insn ""
cd2b37d9 1226 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
1227 (zero_extend:SI
1228 (subreg:QI
cd2b37d9 1229 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1230 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
1231 ""
1232 "rl%I2nm %0,%1,%h2,24,31")
1233
1234(define_insn ""
1235 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1236 (compare:CC (zero_extend:SI
1237 (subreg:QI
cd2b37d9 1238 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1239 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
1240 (const_int 0)))
1241 (clobber (match_scratch:SI 3 "=r"))]
1242 ""
1243 "rl%I2nm. %3,%1,%h2,24,31"
1244 [(set_attr "type" "delayed_compare")])
1245
1246(define_insn ""
1247 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1248 (compare:CC (zero_extend:SI
1249 (subreg:QI
cd2b37d9 1250 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1251 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
1252 (const_int 0)))
cd2b37d9 1253 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
1254 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
1255 ""
1256 "rl%I2nm. %0,%1,%h2,24,31"
1257 [(set_attr "type" "delayed_compare")])
1258
1259(define_insn ""
cd2b37d9 1260 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
1261 (zero_extend:SI
1262 (subreg:HI
cd2b37d9 1263 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1264 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
1265 ""
1266 "rl%I2nm %0,%1,%h2,16,31")
1267
1268(define_insn ""
1269 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1270 (compare:CC (zero_extend:SI
1271 (subreg:HI
cd2b37d9 1272 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1273 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
1274 (const_int 0)))
1275 (clobber (match_scratch:SI 3 "=r"))]
1276 ""
1277 "rl%I2nm. %3,%1,%h2,16,31"
1278 [(set_attr "type" "delayed_compare")])
1279
1280(define_insn ""
1281 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1282 (compare:CC (zero_extend:SI
1283 (subreg:HI
cd2b37d9 1284 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1285 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
1286 (const_int 0)))
cd2b37d9 1287 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
1288 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
1289 ""
1290 "rl%I2nm. %0,%1,%h2,16,31"
1291 [(set_attr "type" "delayed_compare")])
1292
1293;; Note that we use "sle." instead of "sl." so that we can set
1294;; SHIFT_COUNT_TRUNCATED.
1295
1296(define_insn "ashlsi3"
cd2b37d9
RK
1297 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1298 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
1299 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
1300 (clobber (match_scratch:SI 3 "=q,X"))]
1301 ""
1302 "@
1303 sle %0,%1,%2
1304 sli %0,%1,%h2")
1305
1306(define_insn ""
1307 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
cd2b37d9 1308 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
1309 (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
1310 (const_int 0)))
1311 (clobber (match_scratch:SI 3 "=r,r"))
1312 (clobber (match_scratch:SI 4 "=q,X"))]
1313 ""
1314 "@
1315 sle. %3,%1,%2
1316 sli. %3,%1,%h2"
1317 [(set_attr "type" "delayed_compare")])
1318
1319(define_insn ""
1320 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
cd2b37d9 1321 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
1322 (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
1323 (const_int 0)))
cd2b37d9 1324 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
1325 (ashift:SI (match_dup 1) (match_dup 2)))
1326 (clobber (match_scratch:SI 4 "=q,X"))]
1327 ""
1328 "@
1329 sle. %0,%1,%2
1330 sli. %0,%1,%h2"
1331 [(set_attr "type" "delayed_compare")])
1332
1333(define_insn ""
cd2b37d9
RK
1334 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1335 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1336 (match_operand:SI 2 "const_int_operand" "i"))
1337 (match_operand:SI 3 "mask_operand" "L")))]
1338 "includes_lshift_p (operands[2], operands[3])"
1339 "rlinm %0,%h1,%h2,%m3,%M3")
1340
1341(define_insn ""
1342 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1343 (compare:CC
cd2b37d9 1344 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1345 (match_operand:SI 2 "const_int_operand" "i"))
1346 (match_operand:SI 3 "mask_operand" "L"))
1347 (const_int 0)))
1348 (clobber (match_scratch:SI 4 "=r"))]
1349 "includes_lshift_p (operands[2], operands[3])"
1350 "rlinm. %4,%h1,%h2,%m3,%M3"
1351 [(set_attr "type" "delayed_compare")])
1352
1353(define_insn ""
1354 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
1355 (compare:CC
cd2b37d9 1356 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1357 (match_operand:SI 2 "const_int_operand" "i"))
1358 (match_operand:SI 3 "mask_operand" "L"))
1359 (const_int 0)))
cd2b37d9 1360 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
1361 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
1362 "includes_lshift_p (operands[2], operands[3])"
1363 "rlinm. %0,%h1,%h2,%m3,%M3"
1364 [(set_attr "type" "delayed_compare")])
1365
5c23c401
RK
1366;; The RS/6000 assembler mis-handles "sri x,x,0", so write that case as
1367;; "sli x,x,0".
1fd4e8c1 1368(define_insn "lshrsi3"
cd2b37d9
RK
1369 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1370 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
1371 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
1372 (clobber (match_scratch:SI 3 "=q,X"))]
1373 ""
1374 "@
1375 sre %0,%1,%2
5c23c401 1376 s%A2i %0,%1,%h2")
1fd4e8c1
RK
1377
1378(define_insn ""
1379 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
cd2b37d9 1380 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
1381 (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
1382 (const_int 0)))
1383 (clobber (match_scratch:SI 3 "=r,r"))
1384 (clobber (match_scratch:SI 4 "=q,X"))]
1385 ""
1386 "@
1387 sre. %3,%1,%2
5c23c401 1388 s%A2i. %3,%1,%h2"
1fd4e8c1
RK
1389 [(set_attr "type" "delayed_compare")])
1390
1391(define_insn ""
1392 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
cd2b37d9 1393 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
1394 (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
1395 (const_int 0)))
cd2b37d9 1396 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
1397 (lshiftrt:SI (match_dup 1) (match_dup 2)))
1398 (clobber (match_scratch:SI 4 "=q,X"))]
1399 ""
1400 "@
1401 sre. %0,%1,%2
5c23c401 1402 s%A2i. %0,%1,%h2"
1fd4e8c1
RK
1403 [(set_attr "type" "delayed_compare")])
1404
1405(define_insn ""
cd2b37d9
RK
1406 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1407 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1408 (match_operand:SI 2 "const_int_operand" "i"))
1409 (match_operand:SI 3 "mask_operand" "L")))]
1410 "includes_rshift_p (operands[2], operands[3])"
1411 "rlinm %0,%1,%s2,%m3,%M3")
1412
1413(define_insn ""
1414 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1415 (compare:CC
cd2b37d9 1416 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1417 (match_operand:SI 2 "const_int_operand" "i"))
1418 (match_operand:SI 3 "mask_operand" "L"))
1419 (const_int 0)))
1420 (clobber (match_scratch:SI 4 "=r"))]
1421 "includes_rshift_p (operands[2], operands[3])"
1422 "rlinm. %4,%1,%s2,%m3,%M3"
1423 [(set_attr "type" "delayed_compare")])
1424
1425(define_insn ""
1426 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
1427 (compare:CC
cd2b37d9 1428 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1429 (match_operand:SI 2 "const_int_operand" "i"))
1430 (match_operand:SI 3 "mask_operand" "L"))
1431 (const_int 0)))
cd2b37d9 1432 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
1433 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
1434 "includes_rshift_p (operands[2], operands[3])"
1435 "rlinm. %0,%1,%s2,%m3,%M3"
1436 [(set_attr "type" "delayed_compare")])
1437
1438(define_insn ""
cd2b37d9 1439 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
1440 (zero_extend:SI
1441 (subreg:QI
cd2b37d9 1442 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1443 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
1444 "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
1445 "rlinm %0,%1,%s2,24,31")
1446
1447(define_insn ""
1448 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1449 (compare:CC
1450 (zero_extend:SI
1451 (subreg:QI
cd2b37d9 1452 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1453 (match_operand:SI 2 "const_int_operand" "i")) 0))
1454 (const_int 0)))
1455 (clobber (match_scratch:SI 3 "=r"))]
1456 "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
1457 "rlinm. %3,%1,%s2,24,31"
1458 [(set_attr "type" "delayed_compare")])
1459
1460(define_insn ""
1461 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1462 (compare:CC
1463 (zero_extend:SI
1464 (subreg:QI
cd2b37d9 1465 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1466 (match_operand:SI 2 "const_int_operand" "i")) 0))
1467 (const_int 0)))
cd2b37d9 1468 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
1469 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
1470 "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
1471 "rlinm. %0,%1,%s2,24,31"
1472 [(set_attr "type" "delayed_compare")])
1473
1474(define_insn ""
cd2b37d9 1475 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
1476 (zero_extend:SI
1477 (subreg:HI
cd2b37d9 1478 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1479 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
1480 "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
1481 "rlinm %0,%1,%s2,16,31")
1482
1483(define_insn ""
1484 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1485 (compare:CC
1486 (zero_extend:SI
1487 (subreg:HI
cd2b37d9 1488 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1489 (match_operand:SI 2 "const_int_operand" "i")) 0))
1490 (const_int 0)))
1491 (clobber (match_scratch:SI 3 "=r"))]
1492 "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
1493 "rlinm. %3,%1,%s2,16,31"
1494 [(set_attr "type" "delayed_compare")])
1495
1496(define_insn ""
1497 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1498 (compare:CC
1499 (zero_extend:SI
1500 (subreg:HI
cd2b37d9 1501 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
1502 (match_operand:SI 2 "const_int_operand" "i")) 0))
1503 (const_int 0)))
cd2b37d9 1504 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
1505 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
1506 "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
1507 "rlinm. %0,%1,%s2,16,31"
1508 [(set_attr "type" "delayed_compare")])
1509
1510(define_insn ""
cd2b37d9 1511 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1 1512 (const_int 1)
cd2b37d9
RK
1513 (match_operand:SI 1 "gpc_reg_operand" "r"))
1514 (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1fd4e8c1
RK
1515 (const_int 31)))]
1516 ""
1517 "rrib %0,%1,%2")
1518
1519(define_insn ""
cd2b37d9 1520 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1 1521 (const_int 1)
cd2b37d9
RK
1522 (match_operand:SI 1 "gpc_reg_operand" "r"))
1523 (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1fd4e8c1
RK
1524 (const_int 31)))]
1525 ""
1526 "rrib %0,%1,%2")
1527
1528(define_insn ""
cd2b37d9 1529 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
1fd4e8c1 1530 (const_int 1)
cd2b37d9
RK
1531 (match_operand:SI 1 "gpc_reg_operand" "r"))
1532 (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1fd4e8c1
RK
1533 (const_int 1)
1534 (const_int 0)))]
1535 ""
1536 "rrib %0,%1,%2")
1537
1538(define_insn "ashrsi3"
cd2b37d9
RK
1539 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1540 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
1541 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
1542 (clobber (match_scratch:SI 3 "=q,X"))]
1543 ""
1544 "@
1545 srea %0,%1,%2
1546 srai %0,%1,%h2")
1547
1548(define_insn ""
1549 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
cd2b37d9 1550 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
1551 (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
1552 (const_int 0)))
1553 (clobber (match_scratch:SI 3 "=r,r"))
1554 (clobber (match_scratch:SI 4 "=q,X"))]
1555 ""
1556 "@
1557 srea. %3,%1,%2
1558 srai. %3,%1,%h2"
1559 [(set_attr "type" "delayed_compare")])
1560
1561(define_insn ""
1562 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
cd2b37d9 1563 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
1564 (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
1565 (const_int 0)))
cd2b37d9 1566 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
1567 (ashiftrt:SI (match_dup 1) (match_dup 2)))
1568 (clobber (match_scratch:SI 4 "=q,X"))]
1569 ""
1570 "@
1571 srea. %0,%1,%2
1572 srai. %0,%1,%h2"
1573 [(set_attr "type" "delayed_compare")])
1574
1575(define_expand "extendqisi2"
1576 [(parallel [(set (match_dup 2)
cd2b37d9 1577 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
1578 (const_int 24)))
1579 (clobber (scratch:SI))])
cd2b37d9 1580 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
1581 (ashiftrt:SI (match_dup 2)
1582 (const_int 24)))
1583 (clobber (scratch:SI))])]
1584 ""
1585 "
1586{ operands[1] = gen_lowpart (SImode, operands[1]);
1587 operands[2] = gen_reg_rtx (SImode); }")
1588
1589(define_expand "extendqihi2"
1590 [(parallel [(set (match_dup 2)
cd2b37d9 1591 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
1592 (const_int 24)))
1593 (clobber (scratch:SI))])
cd2b37d9 1594 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
1595 (ashiftrt:SI (match_dup 2)
1596 (const_int 24)))
1597 (clobber (scratch:SI))])]
1598 ""
1599 "
1600{ operands[0] = gen_lowpart (SImode, operands[0]);
1601 operands[1] = gen_lowpart (SImode, operands[1]);
1602 operands[2] = gen_reg_rtx (SImode); }")
1603\f
1604;; Floating-point insns, excluding normal data motion.
1605;;
1606;; We pretend that we have both SFmode and DFmode insns, while, in fact,
1607;; all fp insns are actually done in double. The only conversions we will
1608;; do will be when storing to memory. In that case, we will use the "frsp"
1609;; instruction before storing.
1610;;
1611;; Note that when we store into a single-precision memory location, we need to
1612;; use the frsp insn first. If the register being stored isn't dead, we
1613;; need a scratch register for the frsp. But this is difficult when the store
1614;; is done by reload. It is not incorrect to do the frsp on the register in
1615;; this case, we just lose precision that we would have otherwise gotten but
1616;; is not guaranteed. Perhaps this should be tightened up at some point.
1617
1618(define_insn "extendsfdf2"
cd2b37d9
RK
1619 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
1620 (float_extend:DF (match_operand:SF 1 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1621 ""
1622 "*
1623{
1624 if (REGNO (operands[0]) == REGNO (operands[1]))
1625 return \"\";
1626 else
1627 return \"fmr %0,%1\";
1628}"
1629 [(set_attr "type" "fp")])
1630
1631(define_insn "truncdfsf2"
cd2b37d9
RK
1632 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
1633 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1634 ""
1635 "*
1636{
1637 if (REGNO (operands[0]) == REGNO (operands[1]))
1638 return \"\";
1639 else
1640 return \"fmr %0,%1\";
1641}"
1642 [(set_attr "type" "fp")])
1643
1644(define_insn "negsf2"
cd2b37d9
RK
1645 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
1646 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1647 ""
1648 "fneg %0,%1"
1649 [(set_attr "type" "fp")])
1650
1651(define_insn "abssf2"
cd2b37d9
RK
1652 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
1653 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1654 ""
1655 "fabs %0,%1"
1656 [(set_attr "type" "fp")])
1657
1658(define_insn ""
cd2b37d9
RK
1659 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
1660 (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
1fd4e8c1
RK
1661 ""
1662 "fnabs %0,%1"
1663 [(set_attr "type" "fp")])
1664
1665(define_insn "addsf3"
cd2b37d9
RK
1666 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
1667 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
1668 (match_operand:SF 2 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1669 ""
1670 "fa %0,%1,%2"
1671 [(set_attr "type" "fp")])
1672
1673(define_insn "subsf3"
cd2b37d9
RK
1674 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
1675 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
1676 (match_operand:SF 2 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1677 ""
1678 "fs %0,%1,%2"
1679 [(set_attr "type" "fp")])
1680
1681(define_insn "mulsf3"
cd2b37d9
RK
1682 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
1683 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
1684 (match_operand:SF 2 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1685 ""
1686 "fm %0,%1,%2"
1687 [(set_attr "type" "fp")])
1688
1689(define_insn "divsf3"
cd2b37d9
RK
1690 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
1691 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
1692 (match_operand:SF 2 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1693 ""
1694 "fd %0,%1,%2"
1695 [(set_attr "type" "fp")])
1696
1697(define_insn ""
cd2b37d9
RK
1698 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
1699 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
1700 (match_operand:SF 2 "gpc_reg_operand" "f"))
1701 (match_operand:SF 3 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1702 ""
1703 "fma %0,%1,%2,%3"
1704 [(set_attr "type" "fp")])
1705
1706(define_insn ""
cd2b37d9
RK
1707 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
1708 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
1709 (match_operand:SF 2 "gpc_reg_operand" "f"))
1710 (match_operand:SF 3 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1711 ""
1712 "fms %0,%1,%2,%3"
1713 [(set_attr "type" "fp")])
1714
1715(define_insn ""
cd2b37d9
RK
1716 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
1717 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
1718 (match_operand:SF 2 "gpc_reg_operand" "f"))
1719 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
1fd4e8c1
RK
1720 ""
1721 "fnma %0,%1,%2,%3"
1722 [(set_attr "type" "fp")])
1723
1724(define_insn ""
cd2b37d9
RK
1725 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
1726 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
1727 (match_operand:SF 2 "gpc_reg_operand" "f"))
1728 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
1fd4e8c1
RK
1729 ""
1730 "fnms %0,%1,%2,%3"
1731 [(set_attr "type" "fp")])
1732
1733(define_insn "negdf2"
cd2b37d9
RK
1734 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
1735 (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1736 ""
1737 "fneg %0,%1"
1738 [(set_attr "type" "fp")])
1739
1740(define_insn "absdf2"
cd2b37d9
RK
1741 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
1742 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1743 ""
1744 "fabs %0,%1"
1745 [(set_attr "type" "fp")])
1746
1747(define_insn ""
cd2b37d9
RK
1748 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
1749 (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
1fd4e8c1
RK
1750 ""
1751 "fnabs %0,%1"
1752 [(set_attr "type" "fp")])
1753
1754(define_insn "adddf3"
cd2b37d9
RK
1755 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
1756 (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
1757 (match_operand:DF 2 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1758 ""
1759 "fa %0,%1,%2"
1760 [(set_attr "type" "fp")])
1761
1762(define_insn "subdf3"
cd2b37d9
RK
1763 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
1764 (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
1765 (match_operand:DF 2 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1766 ""
1767 "fs %0,%1,%2"
1768 [(set_attr "type" "fp")])
1769
1770(define_insn "muldf3"
cd2b37d9
RK
1771 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
1772 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
1773 (match_operand:DF 2 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1774 ""
1775 "fm %0,%1,%2"
1776 [(set_attr "type" "fp")])
1777
1778(define_insn "divdf3"
cd2b37d9
RK
1779 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
1780 (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
1781 (match_operand:DF 2 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1782 ""
1783 "fd %0,%1,%2"
1784 [(set_attr "type" "fp")])
1785
1786(define_insn ""
cd2b37d9
RK
1787 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
1788 (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
1789 (match_operand:DF 2 "gpc_reg_operand" "f"))
1790 (match_operand:DF 3 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1791 ""
1792 "fma %0,%1,%2,%3"
1793 [(set_attr "type" "fp")])
1794
1795(define_insn ""
cd2b37d9
RK
1796 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
1797 (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
1798 (match_operand:DF 2 "gpc_reg_operand" "f"))
1799 (match_operand:DF 3 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
1800 ""
1801 "fms %0,%1,%2,%3"
1802 [(set_attr "type" "fp")])
1803
1804(define_insn ""
cd2b37d9
RK
1805 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
1806 (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
1807 (match_operand:DF 2 "gpc_reg_operand" "f"))
1808 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
1fd4e8c1
RK
1809 ""
1810 "fnma %0,%1,%2,%3"
1811 [(set_attr "type" "fp")])
1812
1813(define_insn ""
cd2b37d9
RK
1814 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
1815 (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
1816 (match_operand:DF 2 "gpc_reg_operand" "f"))
1817 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
1fd4e8c1
RK
1818 ""
1819 "fnms %0,%1,%2,%3"
1820 [(set_attr "type" "fp")])
1821\f
1822;; Conversions to and from floating-point.
1823(define_expand "floatsidf2"
1824 [(set (match_dup 2)
1825 (plus:DI (zero_extend:DI
cd2b37d9 1826 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
1827 (match_dup 3)))
1828 (match_dup 4)))
cd2b37d9 1829 (set (match_operand:DF 0 "gpc_reg_operand" "")
1fd4e8c1
RK
1830 (minus:DF (subreg:DF (match_dup 2) 0)
1831 (match_dup 5)))]
1832 ""
1833 "
1834{
1835#if HOST_BITS_PER_INT != BITS_PER_WORD
1836 /* Maybe someone can figure out how to do this in that case. I don't
1837 want to right now. */
1838 abort ();
1839#endif
1840
1841 operands[2] = gen_reg_rtx (DImode);
1842 operands[3] = gen_rtx (CONST_INT, VOIDmode, 0x80000000);
1843 operands[4] = immed_double_const (0, 0x43300000, DImode);
1844 operands[5] = force_reg (DFmode, immed_double_const (0x43300000,
1845 0x80000000, DFmode));
1846}")
1847
1848(define_expand "floatunssidf2"
1849 [(set (match_dup 2)
cd2b37d9 1850 (plus:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1fd4e8c1 1851 (match_dup 3)))
cd2b37d9 1852 (set (match_operand:DF 0 "gpc_reg_operand" "")
1fd4e8c1
RK
1853 (minus:DF (subreg:DF (match_dup 2) 0)
1854 (match_dup 4)))]
1855 ""
1856 "
1857{
1858#if HOST_BITS_PER_INT != BITS_PER_WORD
1859 /* Maybe someone can figure out how to do this in that case. I don't
1860 want to right now. */
1861 abort ();
1862#endif
1863
1864 operands[2] = gen_reg_rtx (DImode);
1865 operands[3] = immed_double_const (0, 0x43300000, DImode);
1866 operands[4] = force_reg (DFmode, immed_double_const (0x43300000, 0, DFmode));
1867}")
1868
1869;; For the above two cases, we always split.
1870(define_split
cd2b37d9 1871 [(set (match_operand:DI 0 "gpc_reg_operand" "")
1fd4e8c1 1872 (plus:DI (zero_extend:DI
cd2b37d9 1873 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
1874 (match_operand:SI 2 "logical_operand" "")))
1875 (match_operand:DI 3 "immediate_operand" "")))]
1876 "reload_completed && HOST_BITS_PER_INT == BITS_PER_WORD
1877 && GET_CODE (operands[3]) == CONST_DOUBLE
1878 && CONST_DOUBLE_LOW (operands[3]) == 0"
1879 [(set (match_dup 6) (xor:SI (match_dup 1) (match_dup 2)))
1880 (set (match_dup 4) (match_dup 5))]
1881 "
1882{ operands[4] = operand_subword (operands[0], 0, 0, DImode);
1883 operands[5] = operand_subword (operands[3], 0, 0, DImode);
1884 operands[6] = operand_subword (operands[0], 1, 0, DImode);
1885}")
1886
1887(define_insn ""
cd2b37d9 1888 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
1fd4e8c1 1889 (plus:DI (zero_extend:DI
cd2b37d9 1890 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1fd4e8c1
RK
1891 (match_operand:SI 2 "logical_operand" "rKJ")))
1892 (match_operand:DI 3 "immediate_operand" "n")))]
1893 "HOST_BITS_PER_INT == BITS_PER_WORD
1894 && GET_CODE (operands[3]) == CONST_DOUBLE
1895 && CONST_DOUBLE_LOW (operands[3]) == 0"
1896 "#")
1897
1898(define_split
cd2b37d9
RK
1899 [(set (match_operand:DI 0 "gpc_reg_operand" "=")
1900 (plus:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1fd4e8c1
RK
1901 (match_operand:DI 2 "immediate_operand" "")))]
1902 "reload_completed && HOST_BITS_PER_INT == BITS_PER_WORD
1903 && GET_CODE (operands[2]) == CONST_DOUBLE
1904 && CONST_DOUBLE_LOW (operands[2]) == 0"
1905 [(set (match_dup 3) (match_dup 4))
1906 (set (match_dup 5) (match_dup 1))]
1907 "
1908{ operands[3] = operand_subword (operands[0], 0, 0, DImode);
1909 operands[4] = operand_subword (operands[2], 0, 0, DImode);
1910 operands[5] = operand_subword (operands[0], 1, 0, DImode);
1911
1912 if (rtx_equal_p (operands[1], operands[5]))
1913 {
1914 emit_move_insn (operands[3], operands[4]);
1915 DONE;
1916 }
c283c989
RK
1917
1918 if (rtx_equal_p (operands[1], operands[3]))
1919 {
1920 rtx temp;
1921
1922 temp = operands[3]; operands[3] = operands[5]; operands[5] = temp;
1923 temp = operands[4]; operands[4] = operands[1]; operands[1] = temp;
1924 }
1fd4e8c1
RK
1925}")
1926
1927(define_insn ""
cd2b37d9
RK
1928 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
1929 (plus:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
1fd4e8c1
RK
1930 (match_operand:DI 2 "immediate_operand" "n")))]
1931 "HOST_BITS_PER_INT == BITS_PER_WORD
1932 && GET_CODE (operands[2]) == CONST_DOUBLE
1933 && CONST_DOUBLE_LOW (operands[2]) == 0"
1934 "#")
1935
1936(define_expand "fix_truncdfsi2"
cd2b37d9 1937 [(set (match_operand:SI 0 "gpc_reg_operand" "")
b542afe9 1938 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
1939 ""
1940 "
1941{
1942 emit_insn (gen_trunc_call (operands[0], operands[1],
1943 gen_rtx (SYMBOL_REF, Pmode, \"itrunc\")));
1944 DONE;
1945}")
1946
1947(define_expand "fixuns_truncdfsi2"
cd2b37d9 1948 [(set (match_operand:SI 0 "gpc_reg_operand" "")
b542afe9 1949 (unsigned_fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
1950 ""
1951 "
1952{
1953 emit_insn (gen_trunc_call (operands[0], operands[1],
1954 gen_rtx (SYMBOL_REF, Pmode, \"uitrunc\")));
1955 DONE;
1956}")
1957
1958
1959(define_expand "trunc_call"
1960 [(parallel [(set (match_operand:SI 0 "" "")
b542afe9 1961 (fix:SI (match_operand:DF 1 "" "")))
1fd4e8c1
RK
1962 (use (match_operand:SI 2 "" ""))])]
1963 ""
1964 "
1965{
1966 rtx insns = gen_trunc_call_rtl (operands[0], operands[1], operands[2]);
1967 rtx first = XVECEXP (insns, 0, 0);
1968 rtx last = XVECEXP (insns, 0, XVECLEN (insns, 0) - 1);
1969
1970 REG_NOTES (first) = gen_rtx (INSN_LIST, REG_LIBCALL, last,
1971 REG_NOTES (first));
1972 REG_NOTES (last) = gen_rtx (INSN_LIST, REG_RETVAL, first, REG_NOTES (last));
1973
1974 emit_insn (insns);
1975 DONE;
1976}")
1977
1978(define_expand "trunc_call_rtl"
cd2b37d9 1979 [(set (reg:DF 33) (match_operand:DF 1 "gpc_reg_operand" ""))
1fd4e8c1
RK
1980 (use (reg:DF 33))
1981 (parallel [(set (reg:SI 3)
1982 (call (mem:SI (match_operand 2 "" "")) (const_int 0)))
1983 (clobber (scratch:SI))])
cd2b37d9 1984 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
1985 (reg:SI 3))]
1986 ""
1987 "
1988{
1989 rs6000_trunc_used = 1;
1990}")
1991\f
1992;; Define the DImode operations that can be done in a small number
1993;; of instructions.
1994(define_insn "adddi3"
fa5679bb
RK
1995 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1996 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
1997 (match_operand:DI 2 "reg_or_short_operand" "r,I")))]
1fd4e8c1 1998 ""
fa5679bb
RK
1999 "@
2000 a %L0,%L1,%L2\;ae %0,%1,%2
2001 ai %L0,%L1,%2\;a%G2e %0,%1")
1fd4e8c1
RK
2002
2003(define_insn "subdi3"
fa5679bb
RK
2004 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
2005 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I")
2006 (match_operand:DI 2 "gpc_reg_operand" "r,r")))]
1fd4e8c1 2007 ""
fa5679bb
RK
2008 "@
2009 sf %L0,%L2,%L1\;sfe %0,%2,%1
2010 sfi %L0,%L2,%1\;sf%G1e %0,%2")
1fd4e8c1 2011
a8ddbf69 2012(define_insn "negdi2"
cd2b37d9
RK
2013 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
2014 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
1fd4e8c1
RK
2015 ""
2016 "sfi %L0,%L1,0\;sfze %0,%1")
2017
2018(define_insn "mulsidi3"
cd2b37d9
RK
2019 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
2020 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2021 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
1fd4e8c1
RK
2022 (clobber (match_scratch:SI 3 "=q"))]
2023 ""
2024 "mul %0,%1,%2\;mfmq %L0")
2025
2026;; If operands 0 and 2 are in the same register, we have a problem. But
2027;; operands 0 and 1 (the usual case) can be in the same register. That's
2028;; why we have the strange constraints below.
2029(define_insn "ashldi3"
cd2b37d9
RK
2030 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
2031 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
1fd4e8c1
RK
2032 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
2033 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
2034 ""
2035 "@
2036 sli %0,%L1,%h2\;cal %L0,0(0)
2037 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
2038 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5c23c401 2039 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2")
1fd4e8c1
RK
2040
2041(define_insn "lshrdi3"
cd2b37d9
RK
2042 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r,r,&r")
2043 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
1fd4e8c1
RK
2044 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
2045 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
2046 ""
2047 "@
5c23c401 2048 cal %0,0(0)\;s%A2i %L0,%1,%h2
46a48c7f
RK
2049 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
2050 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
2051 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2")
1fd4e8c1
RK
2052
2053;; Shift by a variable amount is too complex to be worth open-coding. We
2054;; just handle shifts by constants.
2055
2056(define_expand "ashrdi3"
cd2b37d9
RK
2057 [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=")
2058 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
2059 (match_operand:SI 2 "general_operand" "")))
2060 (clobber (match_scratch:SI 3 ""))])]
2061 ""
2062 "
2063{ if (GET_CODE (operands[2]) != CONST_INT)
2064 FAIL;
2065}")
2066
2067(define_insn ""
cd2b37d9
RK
2068 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
2069 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
2070 (match_operand:SI 2 "const_int_operand" "M,i")))
2071 (clobber (match_scratch:SI 3 "=X,q"))]
2072 ""
2073 "@
2074 srai %0,%1,31\;srai %L0,%1,%h2
46a48c7f 2075 sraiq %0,%1,%h2\;srliq %L0,%L1,%h2")
1fd4e8c1
RK
2076\f
2077;; Now define ways of moving data around.
2078;;
2079;; For SI, we special-case integers that can't be loaded in one insn. We
2080;; do the load 16-bits at a time. We could do this by loading from memory,
2081;; and this is even supposed to be faster, but it is simpler not to get
2082;; integers in the TOC.
2083(define_expand "movsi"
2084 [(set (match_operand:SI 0 "general_operand" "")
2085 (match_operand:SI 1 "any_operand" ""))]
2086 ""
2087 "
2088{
2089 if (GET_CODE (operands[0]) != REG)
2090 operands[1] = force_reg (SImode, operands[1]);
2091
2092 if (CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != CONST_INT)
2093 operands[1] = force_const_mem (SImode, operands[1]);
2094
2095 if (GET_CODE (operands[1]) == CONST_INT
2096 && (unsigned) (INTVAL (operands[1]) + 0x8000) >= 0x10000
2097 && (INTVAL (operands[1]) & 0xffff) != 0)
2098 {
2099 emit_move_insn (operands[0],
2100 gen_rtx (CONST_INT, VOIDmode,
2101 INTVAL (operands[1]) & 0xffff0000));
2102 emit_insn (gen_iorsi3 (operands[0], operands[0],
2103 gen_rtx (CONST_INT, VOIDmode,
2104 INTVAL (operands[1]) & 0xffff)));
2105 DONE;
2106 }
2107}")
2108
2109(define_insn ""
e76e75bb
RK
2110 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,m,r,r,r,*c*q,*l,*h")
2111 (match_operand:SI 1 "input_operand" "r,m,r,I,J,*h,r,r,0"))]
cd2b37d9
RK
2112 "gpc_reg_operand (operands[0], SImode)
2113 || gpc_reg_operand (operands[1], SImode)"
1fd4e8c1
RK
2114 "@
2115 ai %0,%1,0
2116 l%U1%X1 %0,%1
2117 st%U0%X0 %1,%0
2118 cal %0,%1(0)
2119 cau %0,0,%u1
2120 mf%1 %0
5c23c401 2121 mt%0 %1
e76e75bb
RK
2122 mt%0 %1
2123 cror 0,0,0"
2124 [(set_attr "type" "*,load,*,*,*,*,*,mtlr,*")])
1fd4e8c1 2125
77fa0940
RK
2126;; Split a load of a large constant into the appropriate two-insn
2127;; sequence.
2128
2129(define_split
2130 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2131 (match_operand:SI 1 "const_int_operand" ""))]
2132 "(unsigned) (INTVAL (operands[1]) + 0x8000) >= 0x10000
2133 && (INTVAL (operands[1]) & 0xffff) != 0"
2134 [(set (match_dup 0)
2135 (match_dup 2))
2136 (set (match_dup 0)
2137 (ior:SI (match_dup 0)
2138 (match_dup 3)))]
2139 "
2140{
2141 operands[2] = gen_rtx (CONST_INT, VOIDmode,
2142 INTVAL (operands[1]) & 0xffff0000);
2143 operands[3] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) & 0xffff);
2144}")
2145
1fd4e8c1
RK
2146(define_insn ""
2147 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
cd2b37d9 2148 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 2149 (const_int 0)))
cd2b37d9 2150 (set (match_operand:SI 0 "gpc_reg_operand" "=r") (match_dup 1))]
1fd4e8c1
RK
2151 ""
2152 "ai. %0,%1,0"
2153 [(set_attr "type" "compare")])
2154\f
2155(define_expand "movhi"
2156 [(set (match_operand:HI 0 "general_operand" "")
2157 (match_operand:HI 1 "any_operand" ""))]
2158 ""
2159 "
2160{
2161 if (GET_CODE (operands[0]) != REG)
2162 operands[1] = force_reg (HImode, operands[1]);
2163
2164 if (CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != CONST_INT)
2165 operands[1] = force_const_mem (HImode, operands[1]);
2166}")
2167
2168(define_insn ""
e76e75bb
RK
2169 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*h,*h")
2170 (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,0"))]
cd2b37d9
RK
2171 "gpc_reg_operand (operands[0], HImode)
2172 || gpc_reg_operand (operands[1], HImode)"
1fd4e8c1
RK
2173 "@
2174 oril %0,%1,0
2175 lhz%U1%X1 %0,%1
2176 sth%U0%X0 %1,%0
2177 cal %0,%w1(0)
2178 mf%1 %0
e76e75bb
RK
2179 mt%0 %1
2180 cror 0,0,0"
2181 [(set_attr "type" "*,load,*,*,*,*,*")])
1fd4e8c1
RK
2182
2183(define_expand "movqi"
2184 [(set (match_operand:QI 0 "general_operand" "")
2185 (match_operand:QI 1 "any_operand" ""))]
2186 ""
2187 "
2188{
2189 if (GET_CODE (operands[0]) != REG)
2190 operands[1] = force_reg (QImode, operands[1]);
2191
2192 if (CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != CONST_INT)
2193 operands[1] = force_const_mem (QImode, operands[1]);
2194}")
2195
2196(define_insn ""
e76e75bb
RK
2197 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*h,*h")
2198 (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,0"))]
cd2b37d9
RK
2199 "gpc_reg_operand (operands[0], QImode)
2200 || gpc_reg_operand (operands[1], QImode)"
1fd4e8c1
RK
2201 "@
2202 oril %0,%1,0
2203 lbz%U1%X1 %0,%1
2204 stb%U0%X0 %1,%0
2205 cal %0,%1(0)
2206 mf%1 %0
e76e75bb
RK
2207 mt%0 %1
2208 cror 0,0,0"
2209 [(set_attr "type" "*,load,*,*,*,*,*")])
1fd4e8c1
RK
2210\f
2211;; Here is how to move condition codes around. When we store CC data in
2212;; an integer register or memory, we store just the high-order 4 bits.
2213;; This lets us not shift in the most common case of CR0.
2214(define_expand "movcc"
2215 [(set (match_operand:CC 0 "nonimmediate_operand" "")
2216 (match_operand:CC 1 "nonimmediate_operand" ""))]
2217 ""
2218 "")
2219
2220(define_insn ""
2221 [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,y,r,r,r,r,m")
2222 (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,m,r"))]
2223 "register_operand (operands[0], CCmode)
2224 || register_operand (operands[1], CCmode)"
2225 "@
2226 mcrf %0,%1
2227 mtcrf 128,%1
2228 rlinm %1,%1,%F0,0,31\;mtcrf %R0,%1\;rlinm %1,%1,%f0,0,31
2229 mfcr %0
2230 mfcr %0\;rlinm %0,%0,%f1,0,3
2231 ai %0,%1,0
2232 l%U1%X1 %0,%1
2233 st%U0%U1 %1,%0"
2234 [(set_attr "type" "*,*,*,compare,*,*,load,*")])
2235\f
2236;; For floating-point, we normally deal with the floating-point registers.
2237;; The sole exception is that parameter passing can produce floating-point
2238;; values in fixed-point registers. Unless the value is a simple constant
2239;; or already in memory, we deal with this by allocating memory and copying
2240;; the value explicitly via that memory location.
2241(define_expand "movsf"
2242 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2243 (match_operand:SF 1 "any_operand" ""))]
2244 ""
2245 "
2246{
2247 /* If we are called from reload, we might be getting a SUBREG of a hard
2248 reg. So expand it. */
2249 if (GET_CODE (operands[0]) == SUBREG
2250 && GET_CODE (SUBREG_REG (operands[0])) == REG
2251 && REGNO (SUBREG_REG (operands[0])) < FIRST_PSEUDO_REGISTER)
2252 operands[0] = alter_subreg (operands[0]);
2253 if (GET_CODE (operands[1]) == SUBREG
2254 && GET_CODE (SUBREG_REG (operands[1])) == REG
2255 && REGNO (SUBREG_REG (operands[1])) < FIRST_PSEUDO_REGISTER)
2256 operands[1] = alter_subreg (operands[1]);
2257
2258 /* If we are being called from reload, it is possible that operands[1]
2259 is a hard non-fp register. So handle those cases. */
2260 if (reload_in_progress && GET_CODE (operands[1]) == REG
2261 && REGNO (operands[1]) < 32)
2262 {
2263 rtx stack_slot;
2264
2265 /* Remember that we only see a pseudo here if it didn't get a hard
2266 register, so it is memory. */
2267 if (GET_CODE (operands[0]) == MEM
2268 || (GET_CODE (operands[0]) == REG
2269 && (REGNO (operands[0]) < 32
2270 || REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))
2271 || (GET_CODE (operands[0]) == REG && REGNO (operands[0]) < 32))
2272 {
2273 emit_move_insn (operand_subword (operands[0], 0, 0, SFmode),
2274 operand_subword (operands[1], 0, 0, SFmode));
2275 DONE;
2276 }
2277
2278 stack_slot = gen_rtx (MEM, SFmode, plus_constant (stack_pointer_rtx, 4));
2279 emit_move_insn (stack_slot, operands[1]);
2280 emit_move_insn (operands[0], stack_slot);
2281 DONE;
2282 }
2283
2284 if (GET_CODE (operands[0]) == MEM)
2285 operands[1] = force_reg (SFmode, operands[1]);
2286
2287 if (GET_CODE (operands[0]) == REG && REGNO (operands[0]) < 32)
2288 {
2289 rtx stack_slot;
2290
2291 if (GET_CODE (operands[1]) == MEM
2292#if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT && ! defined(REAL_IS_NOT_DOUBLE)
2293 || GET_CODE (operands[1]) == CONST_DOUBLE
2294#endif
2295 || (GET_CODE (operands[1]) == REG && REGNO (operands[1]) < 32)
2296 || (reload_in_progress && GET_CODE (operands[1]) == REG
2297 && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER))
2298 {
2299 emit_move_insn (operand_subword (operands[0], 0, 0, SFmode),
2300 operand_subword (operands[1], 0, 0, SFmode));
2301 DONE;
2302 }
2303
2304 if (reload_in_progress)
2305 stack_slot = gen_rtx (MEM, SFmode,
2306 plus_constant (stack_pointer_rtx, 4));
2307 else
2308 stack_slot = assign_stack_temp (SFmode, 4, 0);
2309 emit_move_insn (stack_slot, operands[1]);
2310 emit_move_insn (operands[0], stack_slot);
2311 DONE;
2312 }
2313
2314 if (CONSTANT_P (operands[1]))
2315 {
2316 operands[1] = force_const_mem (SFmode, operands[1]);
2317 if (! memory_address_p (SFmode, XEXP (operands[1], 0))
2318 && ! reload_in_progress)
2319 operands[1] = change_address (operands[1], SFmode,
2320 XEXP (operands[1], 0));
2321 }
2322}")
2323
2324(define_insn ""
cd2b37d9 2325 [(set (match_operand:SF 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
2326 (match_operand:SF 1 "mem_or_easy_const_operand" "G,m"))]
2327 "REGNO (operands[0]) <= 31"
2328 "@
2329 #
2330 l%U1%X1 %0,%1"
2331 [(set_attr "type" "*,load")])
2332
2333(define_split
cd2b37d9 2334 [(set (match_operand:SF 0 "gpc_reg_operand" "")
1fd4e8c1
RK
2335 (match_operand:SF 1 "easy_fp_constant" ""))]
2336 "reload_completed && REGNO (operands[0]) <= 31"
2337 [(set (match_dup 2) (match_dup 3))]
2338 "
2339{ operands[2] = operand_subword (operands[0], 0, 0, SFmode);
2340 operands[3] = operand_subword (operands[1], 0, 0, SFmode); }")
2341
2342(define_insn ""
2343 [(set (match_operand:SF 0 "fp_reg_or_mem_operand" "=f,f,m")
2344 (match_operand:SF 1 "input_operand" "f,m,f"))]
cd2b37d9
RK
2345 "gpc_reg_operand (operands[0], SFmode)
2346 || gpc_reg_operand (operands[1], SFmode)"
1fd4e8c1
RK
2347 "@
2348 fmr %0,%1
2349 lfs%U1%X1 %0,%1
2350 frsp %1,%1\;stfs%U0%X0 %1,%0"
2351 [(set_attr "type" "fp,load,*")])
2352\f
2353(define_expand "movdf"
2354 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2355 (match_operand:DF 1 "any_operand" ""))]
2356 ""
2357 "
2358{
2359 /* If we are called from reload, we might be getting a SUBREG of a hard
2360 reg. So expand it. */
2361 if (GET_CODE (operands[0]) == SUBREG
2362 && GET_CODE (SUBREG_REG (operands[0])) == REG
2363 && REGNO (SUBREG_REG (operands[0])) < FIRST_PSEUDO_REGISTER)
2364 operands[0] = alter_subreg (operands[0]);
2365 if (GET_CODE (operands[1]) == SUBREG
2366 && GET_CODE (SUBREG_REG (operands[1])) == REG
2367 && REGNO (SUBREG_REG (operands[1])) < FIRST_PSEUDO_REGISTER)
2368 operands[1] = alter_subreg (operands[1]);
2369
2370 /* If we are being called from reload, it is possible that operands[1]
2371 is a hard non-fp register. So handle those cases. */
2372 if (reload_in_progress && GET_CODE (operands[1]) == REG
2373 && REGNO (operands[1]) < 32)
2374 {
2375 rtx stack_slot;
2376
2377 /* Remember that we only see a pseudo here if it didn't get a hard
2378 register, so it is memory. */
2379 if (GET_CODE (operands[0]) == MEM
2380 || (GET_CODE (operands[0]) == REG
2381 && (REGNO (operands[0]) < 32
2382 || REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER)))
2383 {
2384 emit_move_insn (operand_subword (operands[0], 0, 0, DFmode),
2385 operand_subword (operands[1], 0, 0, DFmode));
2386 emit_move_insn (operand_subword (operands[0], 1, 0, DFmode),
2387 operand_subword (operands[1], 1, 0, DFmode));
2388 DONE;
2389 }
2390
2391 stack_slot = gen_rtx (MEM, DFmode, plus_constant (stack_pointer_rtx, 8));
2392 emit_move_insn (stack_slot, operands[1]);
2393 emit_move_insn (operands[0], stack_slot);
2394 DONE;
2395 }
2396
2397 if (GET_CODE (operands[0]) == MEM)
2398 {
2399 if (GET_CODE (operands[1]) == MEM)
2400 {
2401 emit_move_insn (operand_subword (operands[0], 0, 0, DFmode),
2402 operand_subword (operands[1], 0, 0, DFmode));
2403 emit_move_insn (operand_subword (operands[0], 1, 0, DFmode),
2404 operand_subword (operands[1], 1, 0, DFmode));
2405 DONE;
2406 }
2407
2408 operands[1] = force_reg (DFmode, operands[1]);
2409 }
2410
2411 if (GET_CODE (operands[0]) == REG && REGNO (operands[0]) < 32)
2412 {
2413 rtx stack_slot;
2414
2415 if (GET_CODE (operands[1]) == MEM
2416#if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT && ! defined(REAL_IS_NOT_DOUBLE)
2417 || GET_CODE (operands[1]) == CONST_DOUBLE
2418#endif
2419 || (GET_CODE (operands[1]) == REG && REGNO (operands[1]) < 32)
2420 || (reload_in_progress && GET_CODE (operands[1]) == REG
2421 && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER))
2422 {
2423 emit_move_insn (operand_subword (operands[0], 0, 0, DFmode),
2424 operand_subword (operands[1], 0, 0, DFmode));
2425 emit_move_insn (operand_subword (operands[0], 1, 0, DFmode),
2426 operand_subword (operands[1], 1, 0, DFmode));
2427 DONE;
2428 }
2429
2430 if (reload_in_progress)
2431 stack_slot = gen_rtx (MEM, DFmode,
2432 plus_constant (stack_pointer_rtx, 8));
2433 else
2434 stack_slot = assign_stack_temp (DFmode, 8, 0);
2435 emit_move_insn (stack_slot, operands[1]);
2436 emit_move_insn (operands[0], stack_slot);
2437 DONE;
2438 }
2439
2440 if (CONSTANT_P (operands[1]))
2441 {
2442 operands[1] = force_const_mem (DFmode, operands[1]);
2443 if (! memory_address_p (DFmode, XEXP (operands[1], 0))
2444 && ! reload_in_progress)
2445 operands[1] = change_address (operands[1], DFmode,
2446 XEXP (operands[1], 0));
2447 }
2448}")
2449
2450(define_insn ""
cd2b37d9 2451 [(set (match_operand:DF 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
2452 (match_operand:DF 1 "mem_or_easy_const_operand" "G,m"))]
2453 "REGNO (operands[0]) <= 31"
2454 "@
2455 #
2456 l %0,%1\;l %L0,%L1"
2457 [(set_attr "type" "*,load")])
2458
2459(define_split
cd2b37d9 2460 [(set (match_operand:DF 0 "gpc_reg_operand" "")
1fd4e8c1
RK
2461 (match_operand:DF 1 "easy_fp_constant" ""))]
2462 "reload_completed && REGNO (operands[0]) <= 31"
2463 [(set (match_dup 2) (match_dup 3))
2464 (set (match_dup 4) (match_dup 5))]
2465 "
2466{ operands[2] = operand_subword (operands[0], 0, 0, DFmode);
2467 operands[3] = operand_subword (operands[1], 0, 0, DFmode);
2468 operands[4] = operand_subword (operands[0], 1, 0, DFmode);
2469 operands[5] = operand_subword (operands[1], 1, 0, DFmode); }")
2470
2471(define_insn ""
2472 [(set (match_operand:DF 0 "fp_reg_or_mem_operand" "=f,f,m")
2473 (match_operand:DF 1 "fp_reg_or_mem_operand" "f,m,f"))]
cd2b37d9
RK
2474 "gpc_reg_operand (operands[0], DFmode)
2475 || gpc_reg_operand (operands[1], DFmode)"
1fd4e8c1
RK
2476 "@
2477 fmr %0,%1
2478 lfd%U1%X1 %0,%1
2479 stfd%U0%X0 %1,%0"
2480 [(set_attr "type" "fp,load,*")])
2481\f
2482;; Next come the multi-word integer load and store and the load and store
2483;; multiple insns.
2484(define_expand "movdi"
2485 [(set (match_operand:DI 0 "general_operand" "")
2486 (match_operand:DI 1 "general_operand" ""))]
2487 ""
2488 "
2489{
062284d8
RK
2490 if (GET_CODE (operands[1]) == CONST_DOUBLE
2491 || GET_CODE (operands[1]) == CONST_INT)
1fd4e8c1
RK
2492 {
2493 emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
2494 operand_subword (operands[1], 0, 0, DImode));
2495 emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
2496 operand_subword (operands[1], 1, 0, DImode));
2497 DONE;
2498 }
062284d8
RK
2499
2500 if (GET_CODE (operands[0]) == MEM)
2501 operands[1] = force_reg (DImode, operands[1]);
1fd4e8c1
RK
2502}")
2503
2504(define_insn ""
2505 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m")
2506 (match_operand:DI 1 "input_operand" "r,m,r"))]
cd2b37d9
RK
2507 "gpc_reg_operand (operands[0], DImode)
2508 || gpc_reg_operand (operands[1], DImode)"
1fd4e8c1
RK
2509 "*
2510{
2511 switch (which_alternative)
2512 {
2513 case 0:
2514 /* We normally copy the low-numbered register first. However, if
2515 the first register operand 0 is the same as the second register of
2516 operand 1, we must copy in the opposite order. */
2517 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
2518 return \"oril %L0,%L1,0\;oril %0,%1,0\";
2519 else
2520 return \"oril %0,%1,0\;oril %L0,%L1,0\";
2521 case 1:
2522 /* If the low-address word is used in the address, we must load it
2523 last. Otherwise, load it first. Note that we cannot have
2524 auto-increment in that case since the address register is known to be
2525 dead. */
2526 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
2527 operands [1], 0))
2528 return \"l %L0,%L1\;l %0,%1\";
2529 else
2530 return \"l%U1 %0,%1\;l %L0,%L1\";
2531 case 2:
2532 return \"st%U0 %1,%0\;st %L1,%L0\";
2533 }
2534}"
2535 [(set_attr "type" "*,load,*")])
2536\f
2537;; TImode is similar, except that we usually want to compute the address into
2538;; a register and use lsi/stsi (the exception is during reload). MQ is also
2539;; clobbered in stsi, so we need a SCRATCH for it.
2540(define_expand "movti"
2541 [(parallel [(set (match_operand:TI 0 "general_operand" "")
2542 (match_operand:TI 1 "general_operand" ""))
2543 (clobber (scratch:SI))])]
2544 ""
2545 "
2546{
2547 if (GET_CODE (operands[0]) == MEM)
2548 operands[1] = force_reg (TImode, operands[1]);
2549
2550 if (GET_CODE (operands[0]) == MEM
2551 && GET_CODE (XEXP (operands[0], 0)) != REG
2552 && ! reload_in_progress)
2553 operands[0] = change_address (operands[0], TImode,
2554 copy_addr_to_reg (XEXP (operands[0], 0)));
2555
2556 if (GET_CODE (operands[1]) == MEM
2557 && GET_CODE (XEXP (operands[1], 0)) != REG
2558 && ! reload_in_progress)
2559 operands[1] = change_address (operands[1], TImode,
2560 copy_addr_to_reg (XEXP (operands[1], 0)));
2561}")
2562
2563;; We say that MQ is clobbered in the last alternative because the first
2564;; alternative would never get used otherwise since it would need a reload
2565;; while the 2nd alternative would not. We put memory cases first so they
2566;; are preferred. Otherwise, we'd try to reload the output instead of
2567;; giving the SCRATCH mq.
2568(define_insn ""
2569 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,r,r,r")
2570 (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))
2571 (clobber (match_scratch:SI 2 "=q,q#X,X,X,X"))]
cd2b37d9
RK
2572 "gpc_reg_operand (operands[0], TImode)
2573 || gpc_reg_operand (operands[1], TImode)"
1fd4e8c1
RK
2574 "*
2575{
2576 switch (which_alternative)
2577 {
2578 case 0:
2579 return \"stsi %1,%P0,16\";
2580
2581 case 1:
2582 return \"st%U0 %1,%0\;st %L1,%L0\;st %Y1,%Y0\;st %Z1,%Z0\";
2583
2584 case 2:
2585 /* Normally copy registers with lowest numbered register copied first.
2586 But copy in the other order if the first register of the output
2587 is the second, third, or fourth register in the input. */
2588 if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
2589 && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
2590 return \"oril %Z0,%Z1,0\;oril %Y0,%Y1,0\;oril %L0,%L1,0\;oril %0,%1,0\";
2591 else
2592 return \"oril %0,%1,0\;oril %L0,%L1,0\;oril %Y0,%Y1,0\;oril %Z0,%Z1,0\";
2593 case 3:
2594 /* If the address is not used in the output, we can use lsi. Otherwise,
2595 fall through to generating four loads. */
2596 if (! reg_overlap_mentioned_p (operands[0], operands[1]))
2597 return \"lsi %0,%P1,16\";
2598 /* ... fall through ... */
2599 case 4:
2600 /* If the address register is the same as the register for the lowest-
2601 addressed word, load it last. Similarly for the next two words.
2602 Otherwise load lowest address to highest. */
2603 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
2604 operands[1], 0))
2605 return \"l %L0,%L1\;l %Y0,%Y1\;l %Z0,%Z1\;l %0,%1\";
2606 else if (refers_to_regno_p (REGNO (operands[0]) + 1,
2607 REGNO (operands[0]) + 2, operands[1], 0))
2608 return \"l %0,%1\;l %Y0,%Y1\;l %Z0,%Z1\;l %L0,%L1\";
2609 else if (refers_to_regno_p (REGNO (operands[0]) + 2,
2610 REGNO (operands[0]) + 3, operands[1], 0))
2611 return \"l %0,%1\;l %L0,%L1\;l %Z0,%Z1\;l %Y0,%Y1\";
2612 else
2613 return \"l%U1 %0,%1\;l %L0,%L1\;l %Y0,%Y1\;l %Z0,%Z1\";
2614 }
2615}"
2616 [(set_attr "type" "*,load,load,*,*")])
2617\f
2618(define_expand "load_multiple"
2f622005
RK
2619 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
2620 (match_operand:SI 1 "" ""))
2621 (use (match_operand:SI 2 "" ""))])]
1fd4e8c1
RK
2622 ""
2623 "
2624{
2625 int regno;
2626 int count;
2627 rtx from;
2628 int i;
2629
2630 /* Support only loading a constant number of fixed-point registers from
2631 memory and only bother with this if more than two; the machine
2632 doesn't support more than eight. */
2633 if (GET_CODE (operands[2]) != CONST_INT
2634 || INTVAL (operands[2]) <= 2
2635 || INTVAL (operands[2]) > 8
2636 || GET_CODE (operands[1]) != MEM
2637 || GET_CODE (operands[0]) != REG
2638 || REGNO (operands[0]) >= 32)
2639 FAIL;
2640
2641 count = INTVAL (operands[2]);
2642 regno = REGNO (operands[0]);
2643
2644 operands[3] = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (count));
2645 from = force_reg (SImode, XEXP (operands[1], 0));
2646
2647 for (i = 0; i < count; i++)
2648 XVECEXP (operands[3], 0, i)
2649 = gen_rtx (SET, VOIDmode, gen_rtx (REG, SImode, regno + i),
2650 gen_rtx (MEM, SImode, plus_constant (from, i * 4)));
2651}")
2652
2653(define_insn ""
2654 [(match_parallel 0 "load_multiple_operation"
cd2b37d9 2655 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
1fd4e8c1
RK
2656 (match_operand:SI 2 "indirect_operand" "Q"))])]
2657 ""
2658 "*
2659{
2660 /* We have to handle the case where the pseudo used to contain the address
2661 is assigned to one of the output registers. In that case, do the
2662 lsi, but then load the correct value. This is a bit of a mess, but is
2663 the best we can do. */
2664 static char result[100];
2665 char newload[40];
2666 int i;
2667
2668 strcpy (result, \"lsi %1,%P2,%N0\");
2669 for (i = 0; i < XVECLEN (operands[0], 0); i++)
2670 if (refers_to_regno_p (REGNO (operands[1]) + i,
2671 REGNO (operands[1]) + i + 1, operands[2], 0))
2672 {
2673 sprintf (newload, \"\;l %d,%d(%d)\",
2674 REGNO (operands[1]) + i,
2675 i * 4, REGNO (XEXP (operands[2], 0)));
2676 strcat (result, newload);
2677 }
2678
2679 return result;
2680}"
2681 [(set_attr "type" "load")])
2682\f
2683(define_expand "store_multiple"
2f622005
RK
2684 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
2685 (match_operand:SI 1 "" ""))
2686 (clobber (scratch:SI))
2687 (use (match_operand:SI 2 "" ""))])]
1fd4e8c1
RK
2688 ""
2689 "
2690{
2691 int regno;
2692 int count;
2693 rtx to;
2694 int i;
2695
2696 /* Support only storing a constant number of fixed-point registers to
2697 memory and only bother with this if more than two; the machine
2698 doesn't support more than eight. */
2699 if (GET_CODE (operands[2]) != CONST_INT
2700 || INTVAL (operands[2]) <= 2
2701 || INTVAL (operands[2]) > 8
2702 || GET_CODE (operands[0]) != MEM
2703 || GET_CODE (operands[1]) != REG
2704 || REGNO (operands[1]) >= 32)
2705 FAIL;
2706
2707 count = INTVAL (operands[2]);
2708 regno = REGNO (operands[1]);
2709
2710 operands[3] = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (count + 1));
2711 to = force_reg (SImode, XEXP (operands[0], 0));
2712
2713 XVECEXP (operands[3], 0, 0)
2714 = gen_rtx (SET, VOIDmode, gen_rtx (MEM, SImode, to), operands[1]);
2715 XVECEXP (operands[3], 0, 1) = gen_rtx (CLOBBER, VOIDmode,
2716 gen_rtx (SCRATCH, SImode));
2717
2718 for (i = 1; i < count; i++)
2719 XVECEXP (operands[3], 0, i + 1)
2720 = gen_rtx (SET, VOIDmode,
2721 gen_rtx (MEM, SImode, plus_constant (to, i * 4)),
2722 gen_rtx (REG, SImode, regno + i));
2723}")
2724
2725(define_insn ""
2726 [(match_parallel 0 "store_multiple_operation"
2727 [(set (match_operand:SI 1 "indirect_operand" "=Q")
cd2b37d9 2728 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1
RK
2729 (clobber (match_scratch:SI 3 "=q"))])]
2730 ""
2731 "stsi %2,%P1,%O0")
2732\f
2733;; Define insns that do load or store with update. Some of these we can
2734;; get by using pre-decrement or pre-increment, but the hardware can also
2735;; do cases where the increment is not the size of the object.
2736;;
2737;; In all these cases, we use operands 0 and 1 for the register being
2738;; incremented because those are the operands that local-alloc will
2739;; tie and these are the pair most likely to be tieable (and the ones
2740;; that will benefit the most).
2741
2742(define_insn ""
cd2b37d9
RK
2743 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
2744 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 2745 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 2746 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1
RK
2747 (plus:SI (match_dup 1) (match_dup 2)))]
2748 ""
2749 "@
5f243543
RK
2750 lux %3,%0,%2
2751 lu %3,%2(%0)"
1fd4e8c1
RK
2752 [(set_attr "type" "load,load")])
2753
2754(define_insn ""
cd2b37d9 2755 [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 2756 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
2757 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
2758 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1
RK
2759 (plus:SI (match_dup 1) (match_dup 2)))]
2760 ""
2761 "@
5f243543
RK
2762 stux %3,%0,%2
2763 stu %3,%2(%0)")
1fd4e8c1
RK
2764
2765(define_insn ""
cd2b37d9
RK
2766 [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
2767 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 2768 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 2769 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1
RK
2770 (plus:SI (match_dup 1) (match_dup 2)))]
2771 ""
2772 "@
5f243543
RK
2773 lhzux %3,%0,%2
2774 lhzu %3,%2(%0)"
1fd4e8c1
RK
2775 [(set_attr "type" "load,load")])
2776
2777(define_insn ""
cd2b37d9 2778 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 2779 (zero_extend:SI
cd2b37d9 2780 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 2781 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
cd2b37d9 2782 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1
RK
2783 (plus:SI (match_dup 1) (match_dup 2)))]
2784 ""
2785 "@
5f243543
RK
2786 lhzux %3,%0,%2
2787 lhzu %3,%2(%0)"
1fd4e8c1
RK
2788 [(set_attr "type" "load,load")])
2789
2790(define_insn ""
cd2b37d9 2791 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 2792 (sign_extend:SI
cd2b37d9 2793 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 2794 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
cd2b37d9 2795 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1
RK
2796 (plus:SI (match_dup 1) (match_dup 2)))]
2797 ""
2798 "@
5f243543
RK
2799 lhaux %3,%0,%2
2800 lhau %3,%2(%0)"
1fd4e8c1
RK
2801 [(set_attr "type" "load,load")])
2802
2803(define_insn ""
cd2b37d9 2804 [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 2805 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
2806 (match_operand:HI 3 "gpc_reg_operand" "r,r"))
2807 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1
RK
2808 (plus:SI (match_dup 1) (match_dup 2)))]
2809 ""
2810 "@
5f243543
RK
2811 sthux %3,%0,%2
2812 sthu %3,%2(%0)"
1fd4e8c1
RK
2813 [(set_attr "type" "load,load")])
2814
2815(define_insn ""
cd2b37d9
RK
2816 [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
2817 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 2818 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 2819 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1
RK
2820 (plus:SI (match_dup 1) (match_dup 2)))]
2821 ""
2822 "@
5f243543
RK
2823 lbzux %3,%0,%2
2824 lbzu %3,%2(%0)"
1fd4e8c1
RK
2825 [(set_attr "type" "load,load")])
2826
2827(define_insn ""
cd2b37d9 2828 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
1fd4e8c1 2829 (zero_extend:SI
cd2b37d9 2830 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 2831 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
cd2b37d9 2832 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1
RK
2833 (plus:SI (match_dup 1) (match_dup 2)))]
2834 ""
2835 "@
5f243543
RK
2836 lbzux %3,%0,%2
2837 lbzu %3,%2(%0)"
1fd4e8c1
RK
2838 [(set_attr "type" "load,load")])
2839
2840(define_insn ""
cd2b37d9 2841 [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 2842 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
2843 (match_operand:QI 3 "gpc_reg_operand" "r,r"))
2844 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1
RK
2845 (plus:SI (match_dup 1) (match_dup 2)))]
2846 ""
2847 "@
5f243543
RK
2848 stbux %3,%0,%2
2849 stbu %3,%2(%0)")
1fd4e8c1
RK
2850
2851(define_insn ""
cd2b37d9
RK
2852 [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
2853 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 2854 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 2855 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1
RK
2856 (plus:SI (match_dup 1) (match_dup 2)))]
2857 ""
2858 "@
5f243543
RK
2859 lfsux %3,%0,%2
2860 lfsu %3,%2(%0)"
1fd4e8c1
RK
2861 [(set_attr "type" "load,load")])
2862
2863(define_insn ""
cd2b37d9 2864 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 2865 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
2866 (match_operand:SF 3 "gpc_reg_operand" "f,f"))
2867 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1
RK
2868 (plus:SI (match_dup 1) (match_dup 2)))]
2869 ""
2870 "@
5f243543
RK
2871 frsp %3,%3\;stfsux %3,%0,%2
2872 frsp %3,%3\;stfsu %3,%2(%0)")
1fd4e8c1
RK
2873
2874(define_insn ""
cd2b37d9
RK
2875 [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
2876 (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 2877 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
cd2b37d9 2878 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1
RK
2879 (plus:SI (match_dup 1) (match_dup 2)))]
2880 ""
2881 "@
5f243543
RK
2882 lfdux %3,%0,%2
2883 lfdu %3,%2(%0)"
1fd4e8c1
RK
2884 [(set_attr "type" "load,load")])
2885
2886(define_insn ""
cd2b37d9 2887 [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
1fd4e8c1 2888 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
cd2b37d9
RK
2889 (match_operand:DF 3 "gpc_reg_operand" "f,f"))
2890 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
1fd4e8c1
RK
2891 (plus:SI (match_dup 1) (match_dup 2)))]
2892 ""
2893 "@
5f243543
RK
2894 stfdux %3,%0,%2
2895 stfdu %3,%2(%0)")
1fd4e8c1
RK
2896\f
2897;; Next come insns related to the calling sequence.
2898;;
2899;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
59257ff7 2900;; We move the back-chain and decrement the stack pointer.
1fd4e8c1
RK
2901
2902(define_expand "allocate_stack"
2903 [(set (reg:SI 1)
01def764 2904 (minus:SI (reg:SI 1) (match_operand:SI 0 "reg_or_short_operand" "")))]
1fd4e8c1
RK
2905 ""
2906 "
2907{ rtx chain = gen_reg_rtx (SImode);
2908 rtx stack_bot = gen_rtx (MEM, Pmode, stack_pointer_rtx);
2909
2910 emit_move_insn (chain, stack_bot);
a0044fb1 2911 emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx, operands[0]));
1fd4e8c1
RK
2912 emit_move_insn (stack_bot, chain);
2913 DONE;
2914}")
59257ff7
RK
2915
2916;; These patterns say how to save and restore the stack pointer. We need not
2917;; save the stack pointer at function level since we are careful to
2918;; preserve the backchain. At block level, we have to restore the backchain
2919;; when we restore the stack pointer.
2920;;
2921;; For nonlocal gotos, we must save both the stack pointer and its
2922;; backchain and restore both. Note that in the nonlocal case, the
2923;; save area is a memory location.
2924
2925(define_expand "save_stack_function"
2926 [(use (const_int 0))]
2927 ""
2928 "")
2929
2930(define_expand "restore_stack_function"
2931 [(use (const_int 0))]
2932 ""
2933 "")
2934
2935(define_expand "restore_stack_block"
2936 [(set (match_dup 2) (mem:SI (match_operand:SI 0 "register_operand" "")))
2937 (set (match_dup 0) (match_operand:SI 1 "register_operand" ""))
2938 (set (mem:SI (match_dup 0)) (match_dup 2))]
2939 ""
2940 "
2941{ operands[2] = gen_reg_rtx (SImode); }")
2942
2943(define_expand "save_stack_nonlocal"
2944 [(match_operand:DI 0 "memory_operand" "")
2945 (match_operand:SI 1 "register_operand" "")]
2946 ""
2947 "
2948{
2949 rtx temp = gen_reg_rtx (SImode);
2950
2951 /* Copy the backchain to the first word, sp to the second. */
2952 emit_move_insn (temp, gen_rtx (MEM, SImode, operands[1]));
2953 emit_move_insn (operand_subword (operands[0], 0, 0, DImode), temp);
2954 emit_move_insn (operand_subword (operands[0], 1, 0, DImode), operands[1]);
2955 DONE;
2956}")
2957
2958(define_expand "restore_stack_nonlocal"
2959 [(match_operand:SI 0 "register_operand" "")
2960 (match_operand:DI 1 "memory_operand" "")]
2961 ""
2962 "
2963{
2964 rtx temp = gen_reg_rtx (SImode);
2965
2966 /* Restore the backchain from the first word, sp from the second. */
2967 emit_move_insn (temp, operand_subword (operands[1], 0, 0, DImode));
2968 emit_move_insn (operands[0], operand_subword (operands[1], 1, 0, DImode));
2969 emit_move_insn (gen_rtx (MEM, SImode, operands[0]), temp);
2970 DONE;
2971}")
1fd4e8c1
RK
2972\f
2973;; A function pointer is a pointer to a data area whose first word contains
2974;; the actual address of the function, whose second word contains a pointer
2975;; to its TOC, and whose third word contains a value to place in the static
2976;; chain register (r11). Note that if we load the static chain, our
2977;; "trampoline" need not have any executable code.
2978;;
2979;; operands[0] is an SImode pseudo in which we place the address of the
2980;; function.
2981;; operands[1] is the address of data area of the function to call
2982
2983(define_expand "call_via_ptr"
cd2b37d9
RK
2984 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2985 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "")))
1fd4e8c1
RK
2986 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
2987 (reg:SI 2))
2988 (set (reg:SI 2)
2989 (mem:SI (plus:SI (match_dup 1)
2990 (const_int 4))))
2991 (set (reg:SI 11)
2992 (mem:SI (plus:SI (match_dup 1)
2993 (const_int 8))))
2994 (use (reg:SI 2))
2995 (use (reg:SI 11))]
2996 ""
2997 "")
2998
2999(define_expand "call"
3000 [(parallel [(call (mem:SI (match_operand:SI 0 "address_operand" ""))
3001 (match_operand 1 "" ""))
3002 (clobber (scratch:SI))])]
3003 ""
3004 "
3005{
3006 if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
3007 abort ();
3008
3009 operands[0] = XEXP (operands[0], 0);
3010 if (GET_CODE (operands[0]) != SYMBOL_REF)
3011 {
3012 rtx temp = gen_reg_rtx (SImode);
3013
3014 emit_insn (gen_call_via_ptr (temp, force_reg (SImode, operands[0])));
3015 operands[0] = temp;
3016 }
3017}")
3018
3019(define_expand "call_value"
3020 [(parallel [(set (match_operand 0 "" "")
3021 (call (mem:SI (match_operand:SI 1 "address_operand" ""))
3022 (match_operand 2 "" "")))
3023 (clobber (scratch:SI))])]
3024 ""
3025 "
3026{
3027 if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
3028 abort ();
3029
3030 operands[1] = XEXP (operands[1], 0);
3031 if (GET_CODE (operands[1]) != SYMBOL_REF)
3032 {
3033 rtx temp = gen_reg_rtx (SImode);
3034
3035 emit_insn (gen_call_via_ptr (temp, force_reg (SImode, operands[1])));
3036 operands[1] = temp;
3037 }
3038}")
3039
3040(define_insn ""
3041 [(call (mem:SI (match_operand:SI 0 "call_operand" "l,s"))
3042 (match_operand 1 "" "fg,fg"))
9482d6de 3043 (clobber (match_scratch:SI 2 "=l,l"))]
1fd4e8c1
RK
3044 ""
3045 "@
3046 brl\;l 2,20(1)
3047 bl %z0\;cror 15,15,15")
3048
3049(define_insn ""
5f243543 3050 [(set (match_operand 0 "" "=fg,fg")
1fd4e8c1
RK
3051 (call (mem:SI (match_operand:SI 1 "call_operand" "l,s"))
3052 (match_operand 2 "" "fg,fg")))
3053 (clobber (match_scratch:SI 3 "=l,l"))]
3054 ""
3055 "@
3056 brl\;l 2,20(1)
3057 bl %z1\;cror 15,15,15")
e6f948e3
RK
3058
3059;; Call subroutine returning any type.
3060
3061(define_expand "untyped_call"
3062 [(parallel [(call (match_operand 0 "" "")
3063 (const_int 0))
3064 (match_operand 1 "" "")
3065 (match_operand 2 "" "")])]
3066 ""
3067 "
3068{
3069 int i;
3070
3071 emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx));
3072
3073 for (i = 0; i < XVECLEN (operands[2], 0); i++)
3074 {
3075 rtx set = XVECEXP (operands[2], 0, i);
3076 emit_move_insn (SET_DEST (set), SET_SRC (set));
3077 }
3078
3079 /* The optimizer does not know that the call sets the function value
3080 registers we stored in the result block. We avoid problems by
3081 claiming that all hard registers are used and clobbered at this
3082 point. */
3083 emit_insn (gen_blockage ());
3084
3085 DONE;
3086}")
3087
3088;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
3089;; all of memory. This blocks insns from being moved across this point.
3090
3091(define_insn "blockage"
3092 [(unspec_volatile [(const_int 0)] 0)]
3093 ""
3094 "")
1fd4e8c1
RK
3095\f
3096;; Compare insns are next. Note that the RS/6000 has two types of compares,
3097;; signed & unsigned, and one type of branch.
3098;;
3099;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
3100;; insns, and branches. We store the operands of compares until we see
3101;; how it is used.
3102(define_expand "cmpsi"
3103 [(set (cc0)
cd2b37d9 3104 (compare (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
3105 (match_operand:SI 1 "reg_or_short_operand" "")))]
3106 ""
3107 "
3108{
3109 /* Take care of the possibility that operands[1] might be negative but
3110 this might be a logical operation. That insn doesn't exist. */
3111 if (GET_CODE (operands[1]) == CONST_INT
3112 && INTVAL (operands[1]) < 0)
3113 operands[1] = force_reg (SImode, operands[1]);
3114
3115 rs6000_compare_op0 = operands[0];
3116 rs6000_compare_op1 = operands[1];
3117 rs6000_compare_fp_p = 0;
3118 DONE;
3119}")
3120
3121(define_expand "cmpsf"
cd2b37d9
RK
3122 [(set (cc0) (compare (match_operand:SF 0 "gpc_reg_operand" "")
3123 (match_operand:SF 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
3124 ""
3125 "
3126{
3127 rs6000_compare_op0 = operands[0];
3128 rs6000_compare_op1 = operands[1];
3129 rs6000_compare_fp_p = 1;
3130 DONE;
3131}")
3132
3133(define_expand "cmpdf"
cd2b37d9
RK
3134 [(set (cc0) (compare (match_operand:DF 0 "gpc_reg_operand" "")
3135 (match_operand:DF 1 "gpc_reg_operand" "")))]
1fd4e8c1
RK
3136 ""
3137 "
3138{
3139 rs6000_compare_op0 = operands[0];
3140 rs6000_compare_op1 = operands[1];
3141 rs6000_compare_fp_p = 1;
3142 DONE;
3143}")
3144
3145(define_expand "beq"
3146 [(set (match_dup 2) (match_dup 1))
3147 (set (pc)
3148 (if_then_else (eq (match_dup 2)
3149 (const_int 0))
3150 (label_ref (match_operand 0 "" ""))
3151 (pc)))]
3152 ""
3153 "
3154{ enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
3155 operands[1] = gen_rtx (COMPARE, mode,
3156 rs6000_compare_op0, rs6000_compare_op1);
3157 operands[2] = gen_reg_rtx (mode);
3158}")
3159
3160(define_expand "bne"
3161 [(set (match_dup 2) (match_dup 1))
3162 (set (pc)
3163 (if_then_else (ne (match_dup 2)
3164 (const_int 0))
3165 (label_ref (match_operand 0 "" ""))
3166 (pc)))]
3167 ""
3168 "
3169{ enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
3170 operands[1] = gen_rtx (COMPARE, mode,
3171 rs6000_compare_op0, rs6000_compare_op1);
3172 operands[2] = gen_reg_rtx (mode);
3173}")
3174
3175(define_expand "blt"
3176 [(set (match_dup 2) (match_dup 1))
3177 (set (pc)
3178 (if_then_else (lt (match_dup 2)
3179 (const_int 0))
3180 (label_ref (match_operand 0 "" ""))
3181 (pc)))]
3182 ""
3183 "
3184{ enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
3185 operands[1] = gen_rtx (COMPARE, mode,
3186 rs6000_compare_op0, rs6000_compare_op1);
3187 operands[2] = gen_reg_rtx (mode);
3188}")
3189
3190(define_expand "bgt"
3191 [(set (match_dup 2) (match_dup 1))
3192 (set (pc)
3193 (if_then_else (gt (match_dup 2)
3194 (const_int 0))
3195 (label_ref (match_operand 0 "" ""))
3196 (pc)))]
3197 ""
3198 "
3199{ enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
3200 operands[1] = gen_rtx (COMPARE, mode,
3201 rs6000_compare_op0, rs6000_compare_op1);
3202 operands[2] = gen_reg_rtx (mode);
3203}")
3204
3205(define_expand "ble"
3206 [(set (match_dup 2) (match_dup 1))
3207 (set (pc)
3208 (if_then_else (le (match_dup 2)
3209 (const_int 0))
3210 (label_ref (match_operand 0 "" ""))
3211 (pc)))]
3212 ""
3213 "
3214{ enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
3215 operands[1] = gen_rtx (COMPARE, mode,
3216 rs6000_compare_op0, rs6000_compare_op1);
3217 operands[2] = gen_reg_rtx (mode);
3218}")
3219
3220(define_expand "bge"
3221 [(set (match_dup 2) (match_dup 1))
3222 (set (pc)
3223 (if_then_else (ge (match_dup 2)
3224 (const_int 0))
3225 (label_ref (match_operand 0 "" ""))
3226 (pc)))]
3227 ""
3228 "
3229{ enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
3230 operands[1] = gen_rtx (COMPARE, mode,
3231 rs6000_compare_op0, rs6000_compare_op1);
3232 operands[2] = gen_reg_rtx (mode);
3233}")
3234
3235(define_expand "bgtu"
3236 [(set (match_dup 2) (match_dup 1))
3237 (set (pc)
3238 (if_then_else (gtu (match_dup 2)
3239 (const_int 0))
3240 (label_ref (match_operand 0 "" ""))
3241 (pc)))]
3242 ""
3243 "
3244{ operands[1] = gen_rtx (COMPARE, CCUNSmode,
3245 rs6000_compare_op0, rs6000_compare_op1);
3246 operands[2] = gen_reg_rtx (CCUNSmode);
3247}")
3248
3249(define_expand "bltu"
3250 [(set (match_dup 2) (match_dup 1))
3251 (set (pc)
3252 (if_then_else (ltu (match_dup 2)
3253 (const_int 0))
3254 (label_ref (match_operand 0 "" ""))
3255 (pc)))]
3256 ""
3257 "
3258{ operands[1] = gen_rtx (COMPARE, CCUNSmode,
3259 rs6000_compare_op0, rs6000_compare_op1);
3260 operands[2] = gen_reg_rtx (CCUNSmode);
3261}")
3262
3263(define_expand "bgeu"
3264 [(set (match_dup 2) (match_dup 1))
3265 (set (pc)
3266 (if_then_else (geu (match_dup 2)
3267 (const_int 0))
3268 (label_ref (match_operand 0 "" ""))
3269 (pc)))]
3270 ""
3271 "
3272{ operands[1] = gen_rtx (COMPARE, CCUNSmode,
3273 rs6000_compare_op0, rs6000_compare_op1);
3274 operands[2] = gen_reg_rtx (CCUNSmode);
3275}")
3276
3277(define_expand "bleu"
3278 [(set (match_dup 2) (match_dup 1))
3279 (set (pc)
3280 (if_then_else (leu (match_dup 2)
3281 (const_int 0))
3282 (label_ref (match_operand 0 "" ""))
3283 (pc)))]
3284 ""
3285 "
3286{ operands[1] = gen_rtx (COMPARE, CCUNSmode,
3287 rs6000_compare_op0, rs6000_compare_op1);
3288 operands[2] = gen_reg_rtx (CCUNSmode);
3289}")
3290
3291;; For SNE, we would prefer that the xor/abs sequence be used for integers.
3292;; For SEQ, likewise, except that comparisons with zero should be done
3293;; with an scc insns. However, due to the order that combine see the
3294;; resulting insns, we must, in fact, allow SEQ for integers. Fail in
3295;; the cases we don't want to handle.
3296(define_expand "seq"
3297 [(set (match_dup 2) (match_dup 1))
cd2b37d9 3298 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
3299 (eq:SI (match_dup 2) (const_int 0)))]
3300 ""
3301 "
3302{ enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
3303 operands[1] = gen_rtx (COMPARE, mode,
3304 rs6000_compare_op0, rs6000_compare_op1);
3305 operands[2] = gen_reg_rtx (mode);
3306}")
3307
3308(define_expand "sne"
3309 [(set (match_dup 2) (match_dup 1))
cd2b37d9 3310 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
3311 (ne:SI (match_dup 2) (const_int 0)))]
3312 ""
3313 "
3314{ if (! rs6000_compare_fp_p)
3315 FAIL;
3316
3317 operands[1] = gen_rtx (COMPARE, CCFPmode,
3318 rs6000_compare_op0, rs6000_compare_op1);
3319 operands[2] = gen_reg_rtx (CCFPmode);
3320}")
3321
3322;; A > 0 is best done using the portable sequence, so fail in that case.
3323(define_expand "sgt"
3324 [(set (match_dup 2) (match_dup 1))
cd2b37d9 3325 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
3326 (gt:SI (match_dup 2) (const_int 0)))]
3327 ""
3328 "
3329{ enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
3330
3331 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
3332 FAIL;
3333
3334 operands[1] = gen_rtx (COMPARE, mode,
3335 rs6000_compare_op0, rs6000_compare_op1);
3336 operands[2] = gen_reg_rtx (mode);
3337}")
3338
3339;; A < 0 is best done in the portable way for A an integer.
3340(define_expand "slt"
3341 [(set (match_dup 2) (match_dup 1))
cd2b37d9 3342 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
3343 (lt:SI (match_dup 2) (const_int 0)))]
3344 ""
3345 "
3346{ enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
3347
3348 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
3349 FAIL;
3350
3351 operands[1] = gen_rtx (COMPARE, mode,
3352 rs6000_compare_op0, rs6000_compare_op1);
3353 operands[2] = gen_reg_rtx (mode);
3354}")
3355
3356(define_expand "sge"
3357 [(set (match_dup 2) (match_dup 1))
cd2b37d9 3358 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
3359 (ge:SI (match_dup 2) (const_int 0)))]
3360 ""
3361 "
3362{ enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
3363 operands[1] = gen_rtx (COMPARE, mode,
3364 rs6000_compare_op0, rs6000_compare_op1);
3365 operands[2] = gen_reg_rtx (mode);
3366}")
3367
3368;; A <= 0 is best done the portable way for A an integer.
3369(define_expand "sle"
3370 [(set (match_dup 2) (match_dup 1))
cd2b37d9 3371 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
3372 (le:SI (match_dup 2) (const_int 0)))]
3373 ""
3374 "
3375{ enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
3376
3377 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
3378 FAIL;
3379
3380 operands[1] = gen_rtx (COMPARE, mode,
3381 rs6000_compare_op0, rs6000_compare_op1);
3382 operands[2] = gen_reg_rtx (mode);
3383}")
3384
3385(define_expand "sgtu"
3386 [(set (match_dup 2) (match_dup 1))
cd2b37d9 3387 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
3388 (gtu:SI (match_dup 2) (const_int 0)))]
3389 ""
3390 "
3391{ operands[1] = gen_rtx (COMPARE, CCUNSmode,
3392 rs6000_compare_op0, rs6000_compare_op1);
3393 operands[2] = gen_reg_rtx (CCUNSmode);
3394}")
3395
3396(define_expand "sltu"
3397 [(set (match_dup 2) (match_dup 1))
cd2b37d9 3398 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
3399 (ltu:SI (match_dup 2) (const_int 0)))]
3400 ""
3401 "
3402{ operands[1] = gen_rtx (COMPARE, CCUNSmode,
3403 rs6000_compare_op0, rs6000_compare_op1);
3404 operands[2] = gen_reg_rtx (CCUNSmode);
3405}")
3406
3407(define_expand "sgeu"
3408 [(set (match_dup 2) (match_dup 1))
cd2b37d9 3409 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
3410 (geu:SI (match_dup 2) (const_int 0)))]
3411 ""
3412 "
3413{ operands[1] = gen_rtx (COMPARE, CCUNSmode,
3414 rs6000_compare_op0, rs6000_compare_op1);
3415 operands[2] = gen_reg_rtx (CCUNSmode);
3416}")
3417
3418(define_expand "sleu"
3419 [(set (match_dup 2) (match_dup 1))
cd2b37d9 3420 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
3421 (leu:SI (match_dup 2) (const_int 0)))]
3422 ""
3423 "
3424{ operands[1] = gen_rtx (COMPARE, CCUNSmode,
3425 rs6000_compare_op0, rs6000_compare_op1);
3426 operands[2] = gen_reg_rtx (CCUNSmode);
3427}")
3428\f
3429;; Here are the actual compare insns.
3430(define_insn ""
3431 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
cd2b37d9 3432 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3433 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
3434 ""
3435 "cmp%I2 %0,%1,%2"
3436 [(set_attr "type" "compare")])
3437
f357808b
RK
3438;; If we are comparing a register for equality with a large constant,
3439;; we can do this with an XOR followed by a compare. But we need a scratch
3440;; register for the result of the XOR.
3441
3442(define_split
3443 [(set (match_operand:CC 0 "cc_reg_operand" "")
cd2b37d9 3444 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
f357808b 3445 (match_operand:SI 2 "non_short_cint_operand" "")))
cd2b37d9 3446 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
f357808b
RK
3447 "find_single_use (operands[0], insn, 0)
3448 && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
3449 || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
3450 [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
3451 (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
3452 "
3453{
3454 /* Get the constant we are comparing against, C, and see what it looks like
3455 sign-extended to 16 bits. Then see what constant could be XOR'ed
3456 with C to get the sign-extended value. */
3457
3458 int c = INTVAL (operands[2]);
3459 int sextc = (c << 16) >> 16;
3460 int xorv = c ^ sextc;
3461
3462 operands[4] = gen_rtx (CONST_INT, VOIDmode, xorv);
3463 operands[5] = gen_rtx (CONST_INT, VOIDmode, sextc);
3464}")
3465
1fd4e8c1
RK
3466(define_insn ""
3467 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
cd2b37d9 3468 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3469 (match_operand:SI 2 "reg_or_u_short_operand" "rI")))]
3470 ""
3471 "cmpl%I2 %0,%1,%W2"
3472 [(set_attr "type" "compare")])
3473
3474;; The following two insns don't exist as single insns, but if we provide
3475;; them, we can swap an add and compare, which will enable us to overlap more
3476;; of the required delay between a compare and branch. We generate code for
3477;; them by splitting.
3478
3479(define_insn ""
3480 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
cd2b37d9 3481 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 3482 (match_operand:SI 2 "short_cint_operand" "i")))
cd2b37d9 3483 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3484 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
3485 ""
3486 "#")
3487
3488(define_insn ""
3489 [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
cd2b37d9 3490 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 3491 (match_operand:SI 2 "u_short_cint_operand" "i")))
cd2b37d9 3492 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3493 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
3494 ""
3495 "#")
3496
3497(define_split
3498 [(set (match_operand:CC 3 "cc_reg_operand" "")
cd2b37d9 3499 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 3500 (match_operand:SI 2 "short_cint_operand" "")))
cd2b37d9 3501 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
3502 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
3503 ""
3504 [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
3505 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
3506
3507(define_split
3508 [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
cd2b37d9 3509 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1 3510 (match_operand:SI 2 "u_short_cint_operand" "")))
cd2b37d9 3511 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
3512 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
3513 ""
3514 [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
3515 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
3516
3517(define_insn ""
3518 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
cd2b37d9
RK
3519 (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
3520 (match_operand:SF 2 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
3521 ""
3522 "fcmpu %0,%1,%2"
3523 [(set_attr "type" "fpcompare")])
3524
3525(define_insn ""
3526 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
cd2b37d9
RK
3527 (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
3528 (match_operand:DF 2 "gpc_reg_operand" "f")))]
1fd4e8c1
RK
3529 ""
3530 "fcmpu %0,%1,%2"
3531 [(set_attr "type" "fpcompare")])
3532\f
3533;; Now we have the scc insns. We can do some combinations because of the
3534;; way the machine works.
3535;;
3536;; Note that this is probably faster if we can put an insn between the
c5defebb
RK
3537;; mfcr and rlinm, but this is tricky. Let's leave it for now. In most
3538;; cases the insns below which don't use an intermediate CR field will
3539;; be used instead.
1fd4e8c1 3540(define_insn ""
cd2b37d9 3541 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3542 (match_operator:SI 1 "scc_comparison_operator"
3543 [(match_operand 2 "cc_reg_operand" "y")
3544 (const_int 0)]))]
3545 ""
3546 "%D1mfcr %0\;rlinm %0,%0,%J1,31,31")
3547
3548(define_insn ""
3549 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
3550 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
3551 [(match_operand 2 "cc_reg_operand" "y")
3552 (const_int 0)])
3553 (const_int 0)))
cd2b37d9 3554 (set (match_operand:SI 3 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3555 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
3556 ""
3557 "%D1mfcr %3\;rlinm. %3,%3,%J1,30,31"
3558 [(set_attr "type" "delayed_compare")])
3559
3560(define_insn ""
cd2b37d9 3561 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3562 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
3563 [(match_operand 2 "cc_reg_operand" "y")
3564 (const_int 0)])
3565 (match_operand:SI 3 "const_int_operand" "n")))]
3566 ""
3567 "*
3568{
3569 int is_bit = ccr_bit (operands[1], 1);
3570 int put_bit = 31 - (INTVAL (operands[3]) & 31);
3571 int count;
3572
3573 if (is_bit >= put_bit)
3574 count = is_bit - put_bit;
3575 else
3576 count = 32 - (put_bit - is_bit);
3577
3578 operands[4] = gen_rtx (CONST_INT, VOIDmode, count);
3579 operands[5] = gen_rtx (CONST_INT, VOIDmode, put_bit);
3580
3581 return \"%D1mfcr %0\;rlinm %0,%0,%4,%5,%5\";
3582}")
3583
3584(define_insn ""
3585 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
3586 (compare:CC
3587 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
3588 [(match_operand 2 "cc_reg_operand" "y")
3589 (const_int 0)])
3590 (match_operand:SI 3 "const_int_operand" "n"))
3591 (const_int 0)))
cd2b37d9 3592 (set (match_operand:SI 4 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3593 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
3594 (match_dup 3)))]
3595 ""
3596 "*
3597{
3598 int is_bit = ccr_bit (operands[1], 1);
3599 int put_bit = 31 - (INTVAL (operands[3]) & 31);
3600 int count;
3601
3602 if (is_bit >= put_bit)
3603 count = is_bit - put_bit;
3604 else
3605 count = 32 - (put_bit - is_bit);
3606
3607 operands[5] = gen_rtx (CONST_INT, VOIDmode, count);
3608 operands[6] = gen_rtx (CONST_INT, VOIDmode, put_bit);
3609
3610 return \"%D1mfcr %4\;rlinm. %4,%4,%5,%6,%6\";
3611}"
3612 [(set_attr "type" "delayed_compare")])
3613
c5defebb
RK
3614;; If we are comparing the result of two comparisons, this can be done
3615;; using creqv or crxor.
3616
3617(define_insn ""
3618 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
3619 (compare:CCEQ (match_operator 1 "scc_comparison_operator"
3620 [(match_operand 2 "cc_reg_operand" "y")
3621 (const_int 0)])
3622 (match_operator 3 "scc_comparison_operator"
3623 [(match_operand 4 "cc_reg_operand" "y")
3624 (const_int 0)])))]
3625 "REGNO (operands[2]) != REGNO (operands[4])"
3626 "*
3627{
3628 enum rtx_code code1, code2;
3629
3630 code1 = GET_CODE (operands[1]);
3631 code2 = GET_CODE (operands[3]);
3632
3633 if ((code1 == EQ || code1 == LT || code1 == GT
3634 || code1 == LTU || code1 == GTU
3635 || (code1 != NE && GET_MODE (operands[2]) == CCFPmode))
3636 !=
3637 (code2 == EQ || code2 == LT || code2 == GT
3638 || code2 == LTU || code2 == GTU
3639 || (code2 != NE && GET_MODE (operands[4]) == CCFPmode)))
3640 return \"%C1%C3crxor %E0,%j1,%j3\";
3641 else
3642 return \"%C1%C3creqv %E0,%j1,%j3\";
3643}")
3644
3645;; There is a 3 cycle delay between consecutive mfcr instructions
3646;; so it is useful to combine 2 scc instructions to use only one mfcr.
3647
3648(define_peephole
cd2b37d9 3649 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
c5defebb
RK
3650 (match_operator:SI 1 "scc_comparison_operator"
3651 [(match_operand 2 "cc_reg_operand" "y")
3652 (const_int 0)]))
cd2b37d9 3653 (set (match_operand:SI 3 "gpc_reg_operand" "=r")
c5defebb
RK
3654 (match_operator:SI 4 "scc_comparison_operator"
3655 [(match_operand 5 "cc_reg_operand" "y")
3656 (const_int 0)]))]
3657 "REGNO (operands[2]) != REGNO (operands[5])"
3658 "%D1%D4mfcr %3\;rlinm %0,%3,%J1,31,31\;rlinm %3,%3,%J4,31,31")
3659
1fd4e8c1
RK
3660;; There are some scc insns that can be done directly, without a compare.
3661;; These are faster because they don't involve the communications between
3662;; the FXU and branch units. In fact, we will be replacing all of the
3663;; integer scc insns here or in the portable methods in emit_store_flag.
3664;;
3665;; Also support (neg (scc ..)) since that construct is used to replace
3666;; branches, (plus (scc ..) ..) since that construct is common and
3667;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
3668;; cases where it is no more expensive than (neg (scc ..)).
3669
3670;; Have reload force a constant into a register for the simple insns that
3671;; otherwise won't accept constants. We do this because it is faster than
3672;; the cmp/mfcr sequence we would otherwise generate.
3673
3674(define_insn ""
cd2b37d9
RK
3675 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
3676 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
1fd4e8c1
RK
3677 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I")))
3678 (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
3679 ""
3680 "@
3681 xor %0,%1,%2\;sfi %3,%0,0\;ae %0,%3,%0
3682 sfi %3,%1,0\;ae %0,%3,%1
3683 xoril %0,%1,%b2\;sfi %3,%0,0\;ae %0,%3,%0
3684 xoriu %0,%1,%u2\;sfi %3,%0,0\;ae %0,%3,%0
3685 sfi %0,%1,%2\;sfi %3,%0,0\;ae %0,%3,%0")
3686
3687(define_insn ""
3688 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x")
3689 (compare:CC
cd2b37d9 3690 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
1fd4e8c1
RK
3691 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
3692 (const_int 0)))
cd2b37d9 3693 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
1fd4e8c1
RK
3694 (eq:SI (match_dup 1) (match_dup 2)))
3695 (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
3696 ""
3697 "@
3698 xor %0,%1,%2\;sfi %3,%0,0\;ae. %0,%3,%0
3699 sfi %3,%1,0\;ae. %0,%3,%1
3700 xoril %0,%1,%b2\;sfi %3,%0,0\;ae. %0,%3,%0
3701 xoriu %0,%1,%u2\;sfi %3,%0,0\;ae. %0,%3,%0
3702 sfi %0,%1,%2\;sfi %3,%0,0\;ae. %0,%3,%0"
3703 [(set_attr "type" "compare")])
3704
3705(define_insn ""
cd2b37d9
RK
3706 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
3707 (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
1fd4e8c1 3708 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
cd2b37d9 3709 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))
1fd4e8c1
RK
3710 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
3711 ""
3712 "@
3713 xor %4,%1,%2\;sfi %4,%4,0\;aze %0,%3
3714 sfi %4,%1,0\;aze %0,%3
3715 xoril %4,%1,%b2\;sfi %4,%4,0\;aze %0,%3
3716 xoriu %4,%1,%u2\;sfi %4,%4,0\;aze %0,%3
3717 sfi %4,%1,%2\;sfi %4,%4,0\;aze %0,%3")
3718
3719(define_insn ""
3720 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x")
3721 (compare:CC
3722 (plus:SI
cd2b37d9 3723 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
1fd4e8c1 3724 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
cd2b37d9 3725 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r"))
1fd4e8c1
RK
3726 (const_int 0)))
3727 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
3728 ""
3729 "@
3730 xor %4,%1,%2\;sfi %4,%4,0\;aze. %4,%3
3731 sfi %4,%1,0\;aze. %0,%3
3732 xoril %4,%1,%b2\;sfi %4,%4,0\;aze. %4,%3
3733 xoriu %4,%1,%u2\;sfi %4,%4,0\;aze. %4,%3
3734 sfi %4,%1,%2\;sfi %4,%4,0\;aze. %4,%3"
3735 [(set_attr "type" "compare")])
3736
3737(define_insn ""
3738 [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,x,x,x")
3739 (compare:CC
3740 (plus:SI
cd2b37d9 3741 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
1fd4e8c1 3742 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
cd2b37d9 3743 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r"))
1fd4e8c1 3744 (const_int 0)))
cd2b37d9 3745 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
1fd4e8c1
RK
3746 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3747 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
3748 ""
3749 "@
3750 xor %4,%1,%2\;sfi %4,%4,0\;aze. %0,%3
3751 sfi %4,%1,0\;aze. %4,%3
3752 xoril %4,%1,%b2\;sfi %4,%4,0\;aze. %0,%3
3753 xoriu %4,%1,%u2\;sfi %4,%4,0\;aze. %0,%3
3754 sfi %4,%1,%2\;sfi %4,%4,0\;aze. %0,%3"
3755 [(set_attr "type" "compare")])
3756
3757(define_insn ""
cd2b37d9
RK
3758 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
3759 (neg:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r")
1fd4e8c1
RK
3760 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))))]
3761 ""
3762 "@
3763 xor %0,%1,%2\;ai %0,%0,-1\;sfe %0,%0,%0
3764 ai %0,%1,-1\;sfe %0,%0,%0
3765 xoril %0,%1,%b2\;ai %0,%0,-1\;sfe %0,%0,%0
3766 xoriu %0,%1,%u2\;ai %0,%0,-1\;sfe %0,%0,%0
3767 sfi %0,%1,%2\;ai %0,%0,-1\;sfe %0,%0,%0")
3768
3769;; This is what (plus (ne X (const_int 0)) Y) looks like.
3770(define_insn ""
cd2b37d9 3771 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1 3772 (plus:SI (lshiftrt:SI
cd2b37d9 3773 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
1fd4e8c1 3774 (const_int 31))
cd2b37d9 3775 (match_operand:SI 2 "gpc_reg_operand" "r")))
1fd4e8c1
RK
3776 (clobber (match_scratch:SI 3 "=&r"))]
3777 ""
3778 "ai %3,%1,-1\;aze %0,%2")
3779
3780(define_insn ""
3781 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
3782 (compare:CC
3783 (plus:SI (lshiftrt:SI
cd2b37d9 3784 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
1fd4e8c1 3785 (const_int 31))
cd2b37d9 3786 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1
RK
3787 (const_int 0)))
3788 (clobber (match_scratch:SI 3 "=&r"))]
3789 ""
3790 "ai %3,%1,-1\;aze. %3,%2"
3791 [(set_attr "type" "compare")])
3792
3793(define_insn ""
3794 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
3795 (compare:CC
3796 (plus:SI (lshiftrt:SI
cd2b37d9 3797 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
1fd4e8c1 3798 (const_int 31))
cd2b37d9 3799 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1 3800 (const_int 0)))
cd2b37d9 3801 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3802 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
3803 (match_dup 2)))
3804 (clobber (match_scratch:SI 3 "=&r"))]
3805 ""
3806 "ai %3,%1,-1\;aze. %0,%2"
3807 [(set_attr "type" "compare")])
3808
3809(define_insn ""
cd2b37d9
RK
3810 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3811 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
3812 (match_operand:SI 2 "reg_or_short_operand" "r,O")))
3813 (clobber (match_scratch:SI 3 "=r,X"))]
3814 ""
3815 "@
3816 doz %3,%2,%1\;sfi %0,%3,0\;ae %0,%0,%3
3817 ai %0,%1,-1\;aze %0,%0\;sri %0,%0,31")
3818
3819(define_insn ""
3820 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x")
3821 (compare:CC
cd2b37d9 3822 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
3823 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
3824 (const_int 0)))
cd2b37d9 3825 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
3826 (le:SI (match_dup 1) (match_dup 2)))
3827 (clobber (match_scratch:SI 3 "=r,X"))]
3828 ""
3829 "@
3830 doz %3,%2,%1\;sfi %0,%3,0\;ae. %0,%0,%3
3831 ai %0,%1,-1\;aze %0,%0\;sri. %0,%0,31"
3832 [(set_attr "type" "delayed_compare,compare")])
3833
3834(define_insn ""
cd2b37d9
RK
3835 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3836 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 3837 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
cd2b37d9 3838 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
1fd4e8c1
RK
3839 (clobber (match_scratch:SI 4 "=&r,&r"))]
3840 ""
3841 "@
3842 doz %4,%2,%1\;sfi %4,%4,0\;aze %0,%3
3843 srai %4,%1,31\;sf %4,%1,%4\;aze %0,%3")
3844
3845(define_insn ""
3846 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
3847 (compare:CC
cd2b37d9 3848 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 3849 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
cd2b37d9 3850 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1
RK
3851 (const_int 0)))
3852 (clobber (match_scratch:SI 4 "=&r,&r"))]
3853 ""
3854 "@
3855 doz %4,%2,%1\;sfi %4,%4,0\;aze. %4,%3
3856 srai %4,%1,31\;sf %4,%1,%4\;aze. %4,%3"
3857 [(set_attr "type" "compare")])
3858
3859(define_insn ""
3860 [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
3861 (compare:CC
cd2b37d9 3862 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 3863 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
cd2b37d9 3864 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 3865 (const_int 0)))
cd2b37d9 3866 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
3867 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3868 (clobber (match_scratch:SI 4 "=&r,&r"))]
3869 ""
3870 "@
3871 doz %4,%2,%1\;sfi %4,%4,0\;aze. %0,%3
3872 srai %4,%1,31\;sf %4,%1,%4\;aze. %0,%3"
3873 [(set_attr "type" "compare")])
3874
3875(define_insn ""
cd2b37d9
RK
3876 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3877 (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
3878 (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
3879 ""
3880 "@
3881 doz %0,%2,%1\;ai %0,%0,-1\;sfe %0,%0,%0
3882 ai %0,%1,-1\;aze %0,%0\;srai %0,%0,31")
3883
3884(define_insn ""
cd2b37d9
RK
3885 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3886 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3887 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
3888 ""
3889 "sf%I2 %0,%1,%2\;cal %0,0(0)\;ae %0,%0,%0")
3890
3891(define_insn ""
3892 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
3893 (compare:CC
cd2b37d9 3894 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3895 (match_operand:SI 2 "reg_or_short_operand" "rI"))
3896 (const_int 0)))
cd2b37d9 3897 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3898 (leu:SI (match_dup 1) (match_dup 2)))]
3899 ""
3900 "sf%I2 %0,%1,%2\;cal %0,0(0)\;ae. %0,%0,%0"
3901 [(set_attr "type" "compare")])
3902
3903(define_insn ""
cd2b37d9
RK
3904 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3905 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 3906 (match_operand:SI 2 "reg_or_short_operand" "rI"))
cd2b37d9 3907 (match_operand:SI 3 "gpc_reg_operand" "r")))
1fd4e8c1
RK
3908 (clobber (match_scratch:SI 4 "=&r"))]
3909 ""
3910 "sf%I2 %4,%1,%2\;aze %0,%3")
3911
3912(define_insn ""
3913 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
3914 (compare:CC
cd2b37d9 3915 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 3916 (match_operand:SI 2 "reg_or_short_operand" "rI"))
cd2b37d9 3917 (match_operand:SI 3 "gpc_reg_operand" "r"))
1fd4e8c1
RK
3918 (const_int 0)))
3919 (clobber (match_scratch:SI 4 "=&r"))]
3920 ""
3921 "sf%I2 %4,%1,%2\;aze. %4,%3"
3922 [(set_attr "type" "compare")])
3923
3924(define_insn ""
3925 [(set (match_operand:CC 5 "cc_reg_operand" "=x")
3926 (compare:CC
cd2b37d9 3927 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 3928 (match_operand:SI 2 "reg_or_short_operand" "rI"))
cd2b37d9 3929 (match_operand:SI 3 "gpc_reg_operand" "r"))
1fd4e8c1 3930 (const_int 0)))
cd2b37d9 3931 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3932 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3933 (clobber (match_scratch:SI 4 "=&r"))]
3934 ""
3935 "sf%I2 %4,%1,%2\;aze. %0,%3"
3936 [(set_attr "type" "compare")])
3937
3938(define_insn ""
cd2b37d9
RK
3939 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3940 (neg:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3941 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
3942 ""
3943 "sf%I2 %0,%1,%2\;sfe %0,%0,%0\;nand %0,%0,%0")
3944
3945(define_insn ""
cd2b37d9 3946 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1 3947 (and:SI (neg:SI
cd2b37d9 3948 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 3949 (match_operand:SI 2 "reg_or_short_operand" "rI")))
cd2b37d9 3950 (match_operand:SI 3 "gpc_reg_operand" "r")))
1fd4e8c1
RK
3951 (clobber (match_scratch:SI 4 "=&r"))]
3952 ""
3953 "sf%I2 %4,%1,%2\;sfe %4,%4,%4\;andc %0,%3,%4")
3954
3955(define_insn ""
3956 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
3957 (compare:CC
3958 (and:SI (neg:SI
cd2b37d9 3959 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 3960 (match_operand:SI 2 "reg_or_short_operand" "rI")))
cd2b37d9 3961 (match_operand:SI 3 "gpc_reg_operand" "r"))
1fd4e8c1
RK
3962 (const_int 0)))
3963 (clobber (match_scratch:SI 4 "=&r"))]
3964 ""
3965 "sf%I2 %4,%1,%2\;sfe %4,%4,%4\;andc. %4,%3,%4"
3966 [(set_attr "type" "compare")])
3967
3968(define_insn ""
3969 [(set (match_operand:CC 5 "cc_reg_operand" "=x")
3970 (compare:CC
3971 (and:SI (neg:SI
cd2b37d9 3972 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 3973 (match_operand:SI 2 "reg_or_short_operand" "rI")))
cd2b37d9 3974 (match_operand:SI 3 "gpc_reg_operand" "r"))
1fd4e8c1 3975 (const_int 0)))
cd2b37d9 3976 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3977 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
3978 (clobber (match_scratch:SI 4 "=&r"))]
3979 ""
3980 "sf%I2 %4,%1,%2\;sfe %4,%4,%4\;andc. %0,%3,%4"
3981 [(set_attr "type" "compare")])
3982
3983(define_insn ""
cd2b37d9
RK
3984 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3985 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3986 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
3987 ""
3988 "doz%I2 %0,%1,%2\;nabs %0,%0\;sri %0,%0,31")
3989
3990(define_insn ""
3991 [(set (match_operand:SI 3 "cc_reg_operand" "=x")
3992 (compare:CC
cd2b37d9 3993 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
3994 (match_operand:SI 2 "reg_or_short_operand" "rI"))
3995 (const_int 0)))
cd2b37d9 3996 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
3997 (lt:SI (match_dup 1) (match_dup 2)))]
3998 ""
3999 "doz%I2 %0,%1,%2\;nabs %0,%0\;sri. %0,%0,31"
4000 [(set_attr "type" "delayed_compare")])
4001
4002(define_insn ""
cd2b37d9
RK
4003 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4004 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4005 (match_operand:SI 2 "reg_or_short_operand" "rI"))
cd2b37d9 4006 (match_operand:SI 3 "gpc_reg_operand" "r")))
1fd4e8c1
RK
4007 (clobber (match_scratch:SI 4 "=&r"))]
4008 ""
4009 "doz%I2 %4,%1,%2\;ai %4,%4,-1\;aze %0,%3")
4010
4011(define_insn ""
4012 [(set (match_operand:SI 0 "cc_reg_operand" "=x")
4013 (compare:CC
cd2b37d9 4014 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4015 (match_operand:SI 2 "reg_or_short_operand" "rI"))
cd2b37d9 4016 (match_operand:SI 3 "gpc_reg_operand" "r"))
1fd4e8c1
RK
4017 (const_int 0)))
4018 (clobber (match_scratch:SI 4 "=&r"))]
4019 ""
4020 "doz%I2 %4,%1,%2\;ai %4,%4,-1\;aze. %4,%3"
4021 [(set_attr "type" "compare")])
4022
4023(define_insn ""
4024 [(set (match_operand:SI 5 "cc_reg_operand" "=x")
4025 (compare:CC
cd2b37d9 4026 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4027 (match_operand:SI 2 "reg_or_short_operand" "rI"))
cd2b37d9 4028 (match_operand:SI 3 "gpc_reg_operand" "r"))
1fd4e8c1 4029 (const_int 0)))
cd2b37d9 4030 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4031 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4032 (clobber (match_scratch:SI 4 "=&r"))]
4033 ""
4034 "doz%I2 %4,%1,%2\;ai %4,%4,-1\;aze. %0,%3"
4035 [(set_attr "type" "compare")])
4036
4037(define_insn ""
cd2b37d9
RK
4038 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4039 (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4040 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
4041 ""
4042 "doz%I2 %0,%1,%2\;nabs %0,%0\;srai %0,%0,31")
4043
4044(define_insn ""
cd2b37d9
RK
4045 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4046 (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
4047 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
4048 ""
4049 "@
4050 sf %0,%2,%1\;sfe %0,%0,%0\;neg %0,%0
4051 ai %0,%1,%n2\;sfe %0,%0,%0\;neg %0,%0")
4052
4053(define_insn ""
4054 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
4055 (compare:CC
cd2b37d9 4056 (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
4057 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
4058 (const_int 0)))
cd2b37d9 4059 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
4060 (ltu:SI (match_dup 1) (match_dup 2)))]
4061 ""
4062 "@
4063 sf %0,%2,%1\;sfe %0,%0,%0\;neg. %0,%0
4064 ai %0,%1,%n2\;sfe %0,%0,%0\;neg. %0,%0"
4065 [(set_attr "type" "compare")])
4066
4067(define_insn ""
cd2b37d9
RK
4068 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4069 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
1fd4e8c1
RK
4070 (match_operand:SI 2 "reg_or_neg_short_operand" "r,r,P,P"))
4071 (match_operand:SI 3 "reg_or_short_operand" "r,I,r,I")))
4072 (clobber (match_scratch:SI 4 "=&r,r,&r,r"))]
4073 ""
4074 "@
4075 sf %4,%2,%1\;sfe %4,%4,%4\;sf%I3 %0,%4,%3
4076 sf %4,%2,%1\;sfe %4,%4,%4\;sf%I3 %0,%4,%3
4077 ai %4,%1,%n2\;sfe %4,%4,%4\;sf%I3 %0,%4,%3
4078 ai %4,%1,%n2\;sfe %4,%4,%4\;sf%I3 %0,%4,%3")
4079
4080(define_insn ""
4081 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x")
4082 (compare:CC
cd2b37d9 4083 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
1fd4e8c1
RK
4084 (match_operand:SI 2 "reg_or_neg_short_operand" "r,r,P,P"))
4085 (match_operand:SI 3 "reg_or_short_operand" "r,I,r,I"))
4086 (const_int 0)))
4087 (clobber (match_scratch:SI 4 "=&r,r,&r,r"))]
4088 ""
4089 "@
4090 sf %4,%2,%1\;sfe %4,%4,%4\;sf%I3. %4,%4,%3
4091 sf %4,%2,%1\;sfe %4,%4,%4\;sf%I3. %4,%4,%3
4092 ai %4,%1,%n2\;sfe %4,%4,%4\;sf%I3. %4,%4,%3
4093 ai %4,%1,%n2\;sfe %4,%4,%4\;sf%I3. %4,%4,%3"
4094 [(set_attr "type" "compare")])
4095
4096(define_insn ""
4097 [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,x,x")
4098 (compare:CC
cd2b37d9 4099 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
1fd4e8c1
RK
4100 (match_operand:SI 2 "reg_or_neg_short_operand" "r,r,P,P"))
4101 (match_operand:SI 3 "reg_or_short_operand" "r,I,r,I"))
4102 (const_int 0)))
cd2b37d9 4103 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1fd4e8c1
RK
4104 (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4105 (clobber (match_scratch:SI 4 "=&r,r,&r,r"))]
4106 ""
4107 "@
4108 sf %4,%2,%1\;sfe %4,%4,%4\;sf%I3. %0,%4,%3
4109 sf %4,%2,%1\;sfe %4,%4,%4\;sf%I3. %0,%4,%3
4110 ai %4,%1,%n2\;sfe %4,%4,%4\;sf%I3. %0,%4,%3
4111 ai %4,%1,%n2\;sfe %4,%4,%4\;sf%I3. %0,%4,%3"
4112 [(set_attr "type" "compare")])
4113
4114(define_insn ""
cd2b37d9
RK
4115 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4116 (neg:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
4117 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))))]
4118 ""
4119 "@
4120 sf %0,%2,%1\;sfe %0,%0,%0
4121 ai %0,%1,%n2\;sfe %0,%0,%0")
4122
4123(define_insn ""
cd2b37d9
RK
4124 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4125 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4126 (match_operand:SI 2 "reg_or_short_operand" "rI")))
4127 (clobber (match_scratch:SI 3 "=r"))]
4128 ""
4129 "doz%I2 %3,%1,%2\;sfi %0,%3,0\;ae %0,%0,%3")
4130
4131(define_insn ""
4132 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
4133 (compare:CC
cd2b37d9 4134 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4135 (match_operand:SI 2 "reg_or_short_operand" "rI"))
4136 (const_int 0)))
cd2b37d9 4137 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4138 (ge:SI (match_dup 1) (match_dup 2)))
4139 (clobber (match_scratch:SI 3 "=r"))]
4140 ""
4141 "doz%I2 %3,%1,%2\;sfi %0,%3,0\;ae. %0,%0,%3"
4142 [(set_attr "type" "compare")])
4143
4144(define_insn ""
cd2b37d9
RK
4145 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4146 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4147 (match_operand:SI 2 "reg_or_short_operand" "rI"))
cd2b37d9 4148 (match_operand:SI 3 "gpc_reg_operand" "r")))
1fd4e8c1
RK
4149 (clobber (match_scratch:SI 4 "=&r"))]
4150 ""
4151 "doz%I2 %4,%1,%2\;sfi %4,%4,0\;aze %0,%3")
4152
4153(define_insn ""
4154 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4155 (compare:CC
cd2b37d9 4156 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4157 (match_operand:SI 2 "reg_or_short_operand" "rI"))
cd2b37d9 4158 (match_operand:SI 3 "gpc_reg_operand" "r"))
1fd4e8c1
RK
4159 (const_int 0)))
4160 (clobber (match_scratch:SI 4 "=&r"))]
4161 ""
4162 "doz%I2 %4,%1,%2\;sfi %4,%4,0\;aze. %4,%3"
4163 [(set_attr "type" "compare")])
4164
4165(define_insn ""
4166 [(set (match_operand:CC 5 "cc_reg_operand" "=x")
4167 (compare:CC
cd2b37d9 4168 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4169 (match_operand:SI 2 "reg_or_short_operand" "rI"))
cd2b37d9 4170 (match_operand:SI 3 "gpc_reg_operand" "r"))
1fd4e8c1 4171 (const_int 0)))
cd2b37d9 4172 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4173 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4174 (clobber (match_scratch:SI 4 "=&r"))]
4175 ""
4176 "doz%I2 %4,%1,%2\;sfi %4,%4,0\;aze. %0,%3"
4177 [(set_attr "type" "compare")])
4178
4179(define_insn ""
cd2b37d9
RK
4180 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4181 (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4182 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
4183 ""
4184 "doz%I2 %0,%1,%2\;ai %0,%0,-1\;sfe %0,%0,%0")
4185
4186;; This is (and (neg (ge X (const_int 0))) Y).
4187(define_insn ""
cd2b37d9 4188 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4189 (and:SI (neg:SI
4190 (lshiftrt:SI
cd2b37d9 4191 (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1fd4e8c1 4192 (const_int 31)))
cd2b37d9 4193 (match_operand:SI 2 "gpc_reg_operand" "r")))
1fd4e8c1
RK
4194 (clobber (match_scratch:SI 3 "=&r"))]
4195 ""
4196 "srai %3,%1,31\;andc %0,%2,%3")
4197
4198(define_insn ""
4199 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4200 (compare:CC
4201 (and:SI (neg:SI
4202 (lshiftrt:SI
cd2b37d9 4203 (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1fd4e8c1 4204 (const_int 31)))
cd2b37d9 4205 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1
RK
4206 (const_int 0)))
4207 (clobber (match_scratch:SI 3 "=&r"))]
4208 ""
4209 "srai %3,%1,31\;andc. %3,%2,%3"
4210 [(set_attr "type" "compare")])
4211
4212(define_insn ""
4213 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
4214 (compare:CC
4215 (and:SI (neg:SI
4216 (lshiftrt:SI
cd2b37d9 4217 (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1fd4e8c1 4218 (const_int 31)))
cd2b37d9 4219 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1 4220 (const_int 0)))
cd2b37d9 4221 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4222 (and:SI (neg:SI (lshiftrt:SI (not:SI (match_dup 1))
4223 (const_int 31)))
4224 (match_dup 2)))
4225 (clobber (match_scratch:SI 3 "=&r"))]
4226 ""
4227 "srai %3,%1,31\;andc. %0,%2,%3"
4228 [(set_attr "type" "compare")])
4229
4230(define_insn ""
cd2b37d9
RK
4231 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4232 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
4233 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
4234 ""
4235 "@
4236 sf %0,%2,%1\;cal %0,0(0)\;ae %0,%0,%0
4237 ai %0,%1,%n2\;cal %0,0(0)\;ae %0,%0,%0")
4238
4239(define_insn ""
4240 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
4241 (compare:CC
cd2b37d9 4242 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
4243 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
4244 (const_int 0)))
cd2b37d9 4245 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
4246 (geu:SI (match_dup 1) (match_dup 2)))]
4247 ""
4248 "@
4249 sf %0,%2,%1\;cal %0,0(0)\;ae. %0,%0,%0
4250 ai %0,%1,%n2\;cal %0,0(0)\;ae. %0,%0,%0"
4251 [(set_attr "type" "compare")])
4252
4253(define_insn ""
cd2b37d9
RK
4254 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4255 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 4256 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
cd2b37d9 4257 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
1fd4e8c1
RK
4258 (clobber (match_scratch:SI 4 "=&r,&r"))]
4259 ""
4260 "@
4261 sf %4,%2,%1\;aze %0,%3
4262 ai %4,%1,%n2\;aze %0,%3")
4263
4264(define_insn ""
4265 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
4266 (compare:CC
cd2b37d9 4267 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 4268 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
cd2b37d9 4269 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1
RK
4270 (const_int 0)))
4271 (clobber (match_scratch:SI 4 "=&r,&r"))]
4272 ""
4273 "@
4274 sf %4,%2,%1\;aze. %4,%3
4275 ai %4,%1,%n2\;aze. %4,%3"
4276 [(set_attr "type" "compare")])
4277
4278(define_insn ""
4279 [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
4280 (compare:CC
cd2b37d9 4281 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 4282 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
cd2b37d9 4283 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 4284 (const_int 0)))
cd2b37d9 4285 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
4286 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4287 (clobber (match_scratch:SI 4 "=&r,&r"))]
4288 ""
4289 "@
4290 sf %4,%2,%1\;aze. %0,%3
4291 ai %4,%1,%n2\;aze. %4,%3"
4292 [(set_attr "type" "compare")])
4293
4294(define_insn ""
cd2b37d9
RK
4295 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4296 (neg:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1
RK
4297 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))]
4298 ""
4299 "@
4300 sf %0,%2,%1\;sfe %0,%0,%0\;nand %0,%0,%0
4301 sfi %0,%1,-1\;a%I2 %0,%0,%2\;sfe %0,%0,%0")
4302
4303(define_insn ""
cd2b37d9 4304 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1 4305 (and:SI (neg:SI
cd2b37d9 4306 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 4307 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
cd2b37d9 4308 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
1fd4e8c1
RK
4309 (clobber (match_scratch:SI 4 "=&r,&r"))]
4310 ""
4311 "@
4312 sf %4,%2,%1\;sfe %4,%4,%4\;andc %0,%3,%4
4313 ai %4,%1,%n2\;sfe %4,%4,%4\;andc %0,%3,%4")
4314
4315(define_insn ""
4316 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
4317 (compare:CC
4318 (and:SI (neg:SI
cd2b37d9 4319 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 4320 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
cd2b37d9 4321 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1
RK
4322 (const_int 0)))
4323 (clobber (match_scratch:SI 4 "=&r,&r"))]
4324 ""
4325 "@
4326 sf %4,%2,%1\;sfe %4,%4,%4\;andc. %4,%3,%4
4327 ai %4,%1,%n2\;sfe %4,%4,%4\;andc. %4,%3,%4"
4328 [(set_attr "type" "compare")])
4329
4330(define_insn ""
4331 [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
4332 (compare:CC
4333 (and:SI (neg:SI
cd2b37d9 4334 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1fd4e8c1 4335 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
cd2b37d9 4336 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
1fd4e8c1 4337 (const_int 0)))
cd2b37d9 4338 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1fd4e8c1
RK
4339 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
4340 (clobber (match_scratch:SI 4 "=&r,&r"))]
4341 ""
4342 "@
4343 sf %4,%2,%1\;sfe %4,%4,%4\;andc. %0,%3,%4
4344 ai %4,%1,%n2\;sfe %4,%4,%4\;andc. %0,%3,%4"
4345 [(set_attr "type" "compare")])
4346
4347(define_insn ""
cd2b37d9
RK
4348 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4349 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4350 (const_int 0)))]
4351 ""
4352 "sfi %0,%1,0\;ame %0,%0\;sri %0,%0,31")
4353
4354(define_insn ""
4355 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
4356 (compare:CC
cd2b37d9 4357 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4358 (const_int 0))
4359 (const_int 0)))
cd2b37d9 4360 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4361 (gt:SI (match_dup 1) (const_int 0)))]
4362 ""
4363 "sfi %0,%1,0\;ame %0,%0\;sri. %0,%0,31"
4364 [(set_attr "type" "delayed_compare")])
4365
4366(define_insn ""
cd2b37d9
RK
4367 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4368 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4369 (match_operand:SI 2 "reg_or_short_operand" "r")))]
4370 ""
4371 "doz %0,%2,%1\;nabs %0,%0\;sri %0,%0,31")
4372
4373(define_insn ""
4374 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4375 (compare:CC
cd2b37d9 4376 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4377 (match_operand:SI 2 "reg_or_short_operand" "r"))
4378 (const_int 0)))
cd2b37d9 4379 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4380 (gt:SI (match_dup 1) (match_dup 2)))]
4381 ""
4382 "doz %0,%2,%1\;nabs %0,%0\;sri. %0,%0,31"
4383 [(set_attr "type" "delayed_compare")])
4384
4385(define_insn ""
cd2b37d9
RK
4386 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4387 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4388 (const_int 0))
cd2b37d9 4389 (match_operand:SI 2 "gpc_reg_operand" "r")))
1fd4e8c1
RK
4390 (clobber (match_scratch:SI 3 "=&r"))]
4391 ""
4392 "a %3,%1,%1\;sfe %3,%1,%3\;aze %0,%2")
4393
4394(define_insn ""
4395 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4396 (compare:CC
cd2b37d9 4397 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4398 (const_int 0))
cd2b37d9 4399 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1
RK
4400 (const_int 0)))
4401 (clobber (match_scratch:SI 3 "=&r"))]
4402 ""
4403 "a %3,%1,%1\;sfe %3,%1,%3\;aze. %0,%2"
4404 [(set_attr "type" "compare")])
4405
4406(define_insn ""
4407 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
4408 (compare:CC
cd2b37d9 4409 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4410 (const_int 0))
cd2b37d9 4411 (match_operand:SI 2 "gpc_reg_operand" "r"))
1fd4e8c1 4412 (const_int 0)))
cd2b37d9 4413 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4414 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
4415 (clobber (match_scratch:SI 3 "=&r"))]
4416 ""
4417 "a %3,%1,%1\;sfe %3,%1,%3\;aze. %3,%2"
4418 [(set_attr "type" "compare")])
4419
4420(define_insn ""
cd2b37d9
RK
4421 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4422 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4423 (match_operand:SI 2 "reg_or_short_operand" "r"))
cd2b37d9 4424 (match_operand:SI 3 "gpc_reg_operand" "r")))
1fd4e8c1
RK
4425 (clobber (match_scratch:SI 4 "=&r"))]
4426 ""
4427 "doz %4,%2,%1\;ai %4,%4,-1\;aze %0,%3")
4428
4429(define_insn ""
4430 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4431 (compare:CC
cd2b37d9 4432 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4433 (match_operand:SI 2 "reg_or_short_operand" "r"))
cd2b37d9 4434 (match_operand:SI 3 "gpc_reg_operand" "r"))
1fd4e8c1
RK
4435 (const_int 0)))
4436 (clobber (match_scratch:SI 4 "=&r"))]
4437 ""
4438 "doz %4,%2,%1\;ai %4,%4,-1\;aze. %4,%3"
4439 [(set_attr "type" "compare")])
4440
4441(define_insn ""
4442 [(set (match_operand:CC 5 "cc_reg_operand" "=x")
4443 (compare:CC
cd2b37d9 4444 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1 4445 (match_operand:SI 2 "reg_or_short_operand" "r"))
cd2b37d9 4446 (match_operand:SI 3 "gpc_reg_operand" "r"))
1fd4e8c1 4447 (const_int 0)))
cd2b37d9 4448 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4449 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4450 (clobber (match_scratch:SI 4 "=&r"))]
4451 ""
4452 "doz %4,%2,%1\;ai %4,%4,-1\;aze. %0,%3"
4453 [(set_attr "type" "compare")])
4454
4455(define_insn ""
cd2b37d9
RK
4456 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4457 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4458 (const_int 0))))]
4459 ""
4460 "sfi %0,%1,0\;ame %0,%0\;srai %0,%0,31")
4461
4462(define_insn ""
cd2b37d9
RK
4463 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4464 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4465 (match_operand:SI 2 "reg_or_short_operand" "r"))))]
4466 ""
4467 "doz %0,%2,%1\;nabs %0,%0\;srai %0,%0,31")
4468
4469(define_insn ""
cd2b37d9
RK
4470 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4471 (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4472 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
4473 ""
4474 "sf%I2 %0,%1,%2\;sfe %0,%0,%0\;neg %0,%0")
4475
4476(define_insn ""
4477 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4478 (compare:CC
cd2b37d9 4479 (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4480 (match_operand:SI 2 "reg_or_short_operand" "rI"))
4481 (const_int 0)))
cd2b37d9 4482 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1fd4e8c1
RK
4483 (gtu:SI (match_dup 1) (match_dup 2)))]
4484 ""
4485 "sf%I2 %0,%1,%2\;sfe %0,%0,%0\;neg. %0,%0"
4486 [(set_attr "type" "compare")])
4487
4488(define_insn ""
00751805
RK
4489 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
4490 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
4491 (match_operand:SI 2 "reg_or_short_operand" "I,r,rI"))
4492 (match_operand:SI 3 "reg_or_short_operand" "r,r,I")))
4493 (clobber (match_scratch:SI 4 "=&r,&r,&r"))]
1fd4e8c1 4494 ""
00751805
RK
4495 "@
4496 ai %4,%1,%k2\;aze %0,%3
4497 sf%I2 %4,%1,%2\;sfe %4,%4,%4\;sf%I3 %0,%4,%3
4498 sf%I2 %4,%1,%2\;sfe %4,%4,%4\;sf%I3 %0,%4,%3")
1fd4e8c1
RK
4499
4500(define_insn ""
00751805 4501 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x")
1fd4e8c1 4502 (compare:CC
00751805
RK
4503 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
4504 (match_operand:SI 2 "reg_or_short_operand" "I,r,rI"))
4505 (match_operand:SI 3 "reg_or_short_operand" "r,r,I"))
1fd4e8c1 4506 (const_int 0)))
00751805 4507 (clobber (match_scratch:SI 4 "=&r,&r,&r"))]
1fd4e8c1 4508 ""
00751805
RK
4509 "@
4510 ai %4,%1,%k2\;aze. %0,%3
4511 sf%I2 %4,%1,%2\;sfe %4,%4,%4\;sf%I3. %0,%4,%3
4512 sf%I2 %4,%1,%2\;sfe %4,%4,%4\;sf%I3. %0,%4,%3"
1fd4e8c1
RK
4513 [(set_attr "type" "compare")])
4514
4515(define_insn ""
00751805 4516 [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,x")
1fd4e8c1 4517 (compare:CC
00751805
RK
4518 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
4519 (match_operand:SI 2 "reg_or_short_operand" "I,r,rI"))
4520 (match_operand:SI 3 "reg_or_short_operand" "r,r,I"))
1fd4e8c1 4521 (const_int 0)))
00751805 4522 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
1fd4e8c1 4523 (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
00751805 4524 (clobber (match_scratch:SI 4 "=&r,&r,&r"))]
1fd4e8c1 4525 ""
00751805
RK
4526 "@
4527 ai %4,%1,%k2\;aze. %0,%3
4528 sf%I2 %4,%1,%2\;sfe %4,%4,%4\;sf%I3. %0,%4,%3
4529 sf%I2 %4,%1,%2\;sfe %4,%4,%4\;sf%I3. %0,%4,%3"
1fd4e8c1
RK
4530 [(set_attr "type" "compare")])
4531
4532(define_insn ""
cd2b37d9
RK
4533 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4534 (neg:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1fd4e8c1
RK
4535 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
4536 ""
4537 "sf%I2 %0,%1,%2\;sfe %0,%0,%0")
4538\f
4539;; Define both directions of branch and return. If we need a reload
4540;; register, we'd rather use CR0 since it is much easier to copy a
4541;; register CC value to there.
4542
4543(define_insn ""
4544 [(set (pc)
4545 (if_then_else (match_operator 1 "branch_comparison_operator"
4546 [(match_operand 2
4547 "cc_reg_operand" "x,?y")
4548 (const_int 0)])
4549 (label_ref (match_operand 0 "" ""))
4550 (pc)))]
4551 ""
4552 "%C1bc %t1,%j1,%0")
4553
4554(define_insn ""
4555 [(set (pc)
4556 (if_then_else (match_operator 0 "branch_comparison_operator"
4557 [(match_operand 1
4558 "cc_reg_operand" "x,?y")
4559 (const_int 0)])
4560 (return)
4561 (pc)))]
4562 "direct_return ()"
4563 "%C0bcr %t0,%j0")
4564
4565(define_insn ""
4566 [(set (pc)
4567 (if_then_else (match_operator 1 "branch_comparison_operator"
4568 [(match_operand 2
4569 "cc_reg_operand" "x,?y")
4570 (const_int 0)])
4571 (pc)
4572 (label_ref (match_operand 0 "" ""))))]
4573 ""
4574 "%C1bc %T1,%j1,%0")
4575
4576(define_insn ""
4577 [(set (pc)
4578 (if_then_else (match_operator 0 "branch_comparison_operator"
4579 [(match_operand 1
4580 "cc_reg_operand" "x,?y")
4581 (const_int 0)])
4582 (pc)
4583 (return)))]
4584 "direct_return ()"
4585 "%C0bcr %T0,%j0")
4586
4587;; Unconditional branch and return.
4588
4589(define_insn "jump"
4590 [(set (pc)
4591 (label_ref (match_operand 0 "" "")))]
4592 ""
4593 "b %l0")
4594
4595(define_insn "return"
4596 [(return)]
4597 "direct_return ()"
4598 "br")
4599
4600(define_insn "indirect_jump"
4601 [(set (pc) (match_operand:SI 0 "register_operand" "c,l"))]
4602 ""
4603 "@
4604 bctr
4605 br")
4606
4607;; Table jump for switch statements:
4608(define_expand "tablejump"
4609 [(set (match_dup 3)
4610 (plus:SI (match_operand:SI 0 "" "")
4611 (match_dup 2)))
4612 (parallel [(set (pc) (match_dup 3))
4613 (use (label_ref (match_operand 1 "" "")))])]
4614 ""
4615 "
4616{ operands[0] = force_reg (SImode, operands[0]);
4617 operands[2] = force_reg (SImode, gen_rtx (LABEL_REF, VOIDmode, operands[1]));
4618 operands[3] = gen_reg_rtx (SImode);
4619}")
4620
4621(define_insn ""
4622 [(set (pc)
740ab4a2 4623 (match_operand:SI 0 "register_operand" "c,l"))
1fd4e8c1
RK
4624 (use (label_ref (match_operand 1 "" "")))]
4625 ""
4626 "@
4627 bctr
4628 br")
4629
4630(define_insn "nop"
4631 [(const_int 0)]
4632 ""
4633 "cror 0,0,0")
4634\f
789bc282 4635;; Define the subtract-one-and-jump insns.
1fd4e8c1
RK
4636;; We need to be able to do this for any operand, including MEM, or we
4637;; will cause reload to blow up since we don't allow output reloads on
4638;; JUMP_INSNs.
4639(define_insn ""
4640 [(set (pc)
4641 (if_then_else (ne (match_operand:SI 1 "register_operand" "0,*r,*r")
4642 (const_int 1))
4643 (label_ref (match_operand 2 "" ""))
4644 (pc)))
4645 (set (match_operand:SI 0 "register_operand" "=c,*r,m*q*c*l")
4646 (plus:SI (match_dup 1) (const_int -1)))
4647 (clobber (match_scratch:CC 3 "=X,&x,&x"))
4648 (clobber (match_scratch:SI 4 "=X,X,r"))]
4649 ""
4650 "@
4651 bdn %l2
4652 #
4653 #")
4654
789bc282 4655;; Similar, but we can use GE since we have a REG_NOTES.
1fd4e8c1
RK
4656(define_insn ""
4657 [(set (pc)
4658 (if_then_else (ge (match_operand:SI 1 "register_operand" "0,*r,*r")
4659 (const_int 0))
4660 (label_ref (match_operand 2 "" ""))
4661 (pc)))
4662 (set (match_operand:SI 0 "register_operand" "=c,*r,m*q*c*l")
4663 (plus:SI (match_dup 1) (const_int -1)))
4664 (clobber (match_scratch:CC 3 "=X,&x,&X"))
4665 (clobber (match_scratch:SI 4 "=X,X,r"))]
4666 "find_reg_note (insn, REG_NONNEG, 0)"
4667 "@
4668 bdn %l2
4669 #
4670 #")
4671
4672(define_insn ""
4673 [(set (pc)
4674 (if_then_else (eq (match_operand:SI 1 "register_operand" "0,*r,*r")
4675 (const_int 1))
4676 (label_ref (match_operand 2 "" ""))
4677 (pc)))
4678 (set (match_operand:SI 0 "register_operand" "=c,*r,m*q*c*l")
4679 (plus:SI (match_dup 1) (const_int -1)))
4680 (clobber (match_scratch:CC 3 "=X,&x,&x"))
4681 (clobber (match_scratch:SI 4 "=X,X,r"))]
4682 ""
4683 "@
4684 bdz %l2
4685 #
4686 #")
4687
4688(define_split
4689 [(set (pc)
4690 (if_then_else (match_operator 2 "comparison_operator"
cd2b37d9 4691 [(match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
4692 (const_int 1)])
4693 (match_operand 5 "" "")
4694 (match_operand 6 "" "")))
cd2b37d9 4695 (set (match_operand:SI 0 "gpc_reg_operand" "")
1fd4e8c1
RK
4696 (plus:SI (match_dup 1) (const_int -1)))
4697 (clobber (match_scratch:CC 3 ""))
4698 (clobber (match_scratch:SI 4 ""))]
4699 "reload_completed"
4700 [(parallel [(set (match_dup 3)
4701 (compare:CC (plus:SI (match_dup 1) (const_int -1))
4702 (const_int 0)))
4703 (set (match_dup 0) (plus:SI (match_dup 1) (const_int -1)))])
4704 (set (pc) (if_then_else (match_dup 7) (match_dup 5) (match_dup 6)))]
4705 "
4706{ operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
4707 const0_rtx); }")
4708
4709(define_split
4710 [(set (pc)
4711 (if_then_else (match_operator 2 "comparison_operator"
cd2b37d9 4712 [(match_operand:SI 1 "gpc_reg_operand" "")
1fd4e8c1
RK
4713 (const_int 1)])
4714 (match_operand 5 "" "")
4715 (match_operand 6 "" "")))
4716 (set (match_operand:SI 0 "general_operand" "")
4717 (plus:SI (match_dup 1) (const_int -1)))
4718 (clobber (match_scratch:CC 3 ""))
4719 (clobber (match_scratch:SI 4 ""))]
cd2b37d9 4720 "reload_completed && ! gpc_reg_operand (operands[0], SImode)"
1fd4e8c1
RK
4721 [(parallel [(set (match_dup 3)
4722 (compare:CC (plus:SI (match_dup 1) (const_int -1))
4723 (const_int 0)))
4724 (set (match_dup 4) (plus:SI (match_dup 1) (const_int -1)))])
4725 (set (match_dup 0) (match_dup 4))
4726 (set (pc) (if_then_else (match_dup 7) (match_dup 5) (match_dup 6)))]
4727 "
4728{ operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
4729 const0_rtx); }")
This page took 0.644256 seconds and 5 git commands to generate.