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