stmt.c (expand_goto): Do virtual_stack_vars_rtx replacement for HAVE_nonlocal_goto...
[gcc.git] / gcc / config / pj / pj.md
1 ;; Machine description for GNU compiler, picoJava Version
2 ;; Copyright (C) 2000 Free Software Foundation, Inc.
3 ;; Contributed by Steve Chamberlain, of Transmeta (sac@pobox.com).
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, 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
21
22 ;; Move instructions.
23
24 (define_insn "movsi"
25 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
26 (match_operand:SI 1 "pj_source_operand" "gS"))]
27 ""
28 "%S1%R0")
29
30 (define_insn "movhi"
31 [(set (match_operand:HI 0 "nonimmediate_operand" "=gD")
32 (match_operand:HI 1 "pj_source_operand" "gS"))]
33 ""
34 "%S1%R0")
35
36 (define_insn "movqi"
37 [(set (match_operand:QI 0 "nonimmediate_operand" "=gD")
38 (match_operand:QI 1 "pj_source_operand" "gS"))]
39 ""
40 "%S1%R0")
41
42 (define_insn "movdi"
43 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
44 (match_operand:DI 1 "pj_source_operand" "gS"))]
45 ""
46 "%D1%*%R0")
47
48 (define_insn "movdf"
49 [(set (match_operand:DF 0 "nonimmediate_operand" "=gD")
50 (match_operand:DF 1 "pj_source_operand" "gS"))]
51 ""
52 "%D1%R0")
53
54 (define_insn "movsf"
55 [(set (match_operand:SF 0 "nonimmediate_operand" "=gD")
56 (match_operand:SF 1 "pj_source_operand" "gS"))]
57 ""
58 "%S1%R0")
59
60 \f
61 ;; Arithmetic.
62
63 (define_insn "addsi3"
64 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
65 (plus:SI (match_operand:SI 1 "pj_source_operand" "%gS")
66 (match_operand:SI 2 "pj_source_operand" "gS")))]
67 ""
68 "* return pj_output_addsi3 (operands);")
69
70 (define_insn "adddi3"
71 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
72 (plus:DI (match_operand:DI 1 "pj_source_operand" "%gS")
73 (match_operand:DI 2 "pj_source_operand" "gS")))]
74 ""
75 "%D1%D2%*ladd%R0")
76
77 (define_insn "addsf3"
78 [(set (match_operand:SF 0 "nonimmediate_operand" "=gD")
79 (plus:SF (match_operand:SF 1 "pj_source_operand" "%gS")
80 (match_operand:SF 2 "pj_source_operand" "gS")))]
81 ""
82 "%S1%S2%*fadd%R0")
83
84 (define_insn "adddf3"
85 [(set (match_operand:DF 0 "nonimmediate_operand" "=gD")
86 (plus:DF (match_operand:DF 1 "pj_source_operand" "%gS")
87 (match_operand:DF 2 "pj_source_operand" "gS")))]
88 ""
89 "%D1%D2%*dadd%R0")
90
91 (define_insn "negsi2"
92 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
93 (neg:SI (match_operand:SI 1 "pj_source_operand" "gS")))]
94 ""
95 "%S1%*ineg%R0")
96
97 (define_insn "negdi2"
98 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
99 (neg:DI (match_operand:DI 1 "pj_source_operand" "gS")))]
100 ""
101 "%S1%*lneg%R0")
102
103 (define_insn "negsf2"
104 [(set (match_operand:SF 0 "nonimmediate_operand" "=gD")
105 (neg:SF (match_operand:SF 1 "pj_source_operand" "gS")))]
106 ""
107 "%S1%*fneg%R0")
108
109 (define_insn "negdf2"
110 [(set (match_operand:DF 0 "nonimmediate_operand" "=gD")
111 (neg:DF (match_operand:DF 1 "pj_source_operand" "gS")))]
112 ""
113 "%D1%*dneg%R0")
114
115 (define_insn "subsi3"
116 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
117 (minus:SI (match_operand:SI 1 "pj_source_operand" "gS")
118 (match_operand:SI 2 "pj_source_operand" "gS")))]
119 ""
120 "%S1%S2%*isub%R0")
121
122 (define_insn "subdi3"
123 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
124 (minus:DI (match_operand:DI 1 "pj_source_operand" "gS")
125 (match_operand:DI 2 "pj_source_operand" "gS")))]
126 ""
127 "%D1%D2%*lsub%R0")
128
129 (define_insn "subsf3"
130 [(set (match_operand:SF 0 "nonimmediate_operand" "=gD")
131 (minus:SF (match_operand:SF 1 "pj_source_operand" "gS")
132 (match_operand:SF 2 "pj_source_operand" "gS")))]
133 ""
134 "%S1%S2%*fsub%R0")
135
136 (define_insn "subdf3"
137 [(set (match_operand:DF 0 "nonimmediate_operand" "=gD")
138 (minus:DF (match_operand:DF 1 "pj_source_operand" "gS")
139 (match_operand:DF 2 "pj_source_operand" "gS")))]
140 ""
141 "%D1%D2%*dsub%R0")
142
143 (define_insn "divsi3"
144 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
145 (div:SI (match_operand:SI 1 "pj_source_operand" "gS")
146 (match_operand:SI 2 "pj_source_operand" "gS")))]
147 ""
148 "%S1%S2%*idiv%R0")
149
150 (define_insn "divdi3"
151 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
152 (div:DI (match_operand:DI 1 "pj_source_operand" "gS")
153 (match_operand:DI 2 "pj_source_operand" "gS")))]
154 ""
155 "%D1%D2%*ldiv%R0")
156
157 (define_insn "divsf3"
158 [(set (match_operand:SF 0 "nonimmediate_operand" "=gD")
159 (div:SF (match_operand:SF 1 "pj_source_operand" "gS")
160 (match_operand:SF 2 "pj_source_operand" "gS")))]
161 ""
162 "%S1%S2%*fdiv%R0")
163
164 (define_insn "divdf3"
165 [(set (match_operand:DF 0 "nonimmediate_operand" "=gD")
166 (div:DF (match_operand:DF 1 "pj_source_operand" "gS")
167 (match_operand:DF 2 "pj_source_operand" "gS")))]
168 ""
169 "%D1%D2%*ddiv%R0")
170
171 (define_insn "udivsi3"
172 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
173 (udiv:SI (match_operand:SI 1 "pj_source_operand" "gS")
174 (match_operand:SI 2 "pj_source_operand" "gS")))]
175 ""
176 "%P1%P2%*ldiv%*l2i%R0")
177
178 (define_insn "mulsi3"
179 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
180 (mult:SI (match_operand:SI 1 "pj_source_operand" "gS")
181 (match_operand:SI 2 "pj_source_operand" "gS")))]
182 ""
183 "%S1%S2%*imul%R0")
184
185 (define_insn "muldi3"
186 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
187 (mult:DI (match_operand:DI 1 "pj_source_operand" "gS")
188 (match_operand:DI 2 "pj_source_operand" "gS")))]
189 ""
190 "%D1%D2%*lmul%R0")
191
192 (define_insn "muldf3"
193 [(set (match_operand:DF 0 "nonimmediate_operand" "=gD")
194 (mult:DF (match_operand:DF 1 "pj_source_operand" "%gS")
195 (match_operand:DF 2 "pj_source_operand" "gS")))]
196 ""
197 "%D1%D2%*dmul%R0")
198
199 (define_insn "mulsf3"
200 [(set (match_operand:SF 0 "nonimmediate_operand" "=gD")
201 (mult:SF (match_operand:SF 1 "pj_source_operand" "%gS")
202 (match_operand:SF 2 "pj_source_operand" "gS")))]
203 ""
204 "%S1%S2%*fmul%R0")
205
206 (define_insn "modsi3"
207 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
208 (mod:SI (match_operand:SI 1 "pj_source_operand" "gS")
209 (match_operand:SI 2 "pj_source_operand" "gS")))]
210 ""
211 "%S1%S2%*irem%R0")
212
213 (define_insn "moddi3"
214 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
215 (mod:DI (match_operand:DI 1 "pj_source_operand" "gS")
216 (match_operand:DI 2 "pj_source_operand" "gS")))]
217 ""
218 "%D1%D2%*lrem%R0")
219
220 (define_insn "moddf3"
221 [(set (match_operand:DF 0 "nonimmediate_operand" "=gD")
222 (mod:DF (match_operand:DF 1 "pj_source_operand" "gS")
223 (match_operand:DF 2 "pj_source_operand" "gS")))]
224 ""
225 "%D1%D2%*drem%R0")
226
227 (define_insn "modsf3"
228 [(set (match_operand:SF 0 "nonimmediate_operand" "=gD")
229 (mod:SF (match_operand:SF 1 "pj_source_operand" "gS")
230 (match_operand:SF 2 "pj_source_operand" "gS")))]
231 ""
232 "%S1%S2%*frem%R0")
233
234 (define_insn "umodsi3"
235 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
236 (umod:SI (match_operand:SI 1 "pj_source_operand" "gS")
237 (match_operand:SI 2 "pj_source_operand" "gS")))]
238 ""
239 "%P1%P2%*lrem%*l2i%R0")
240
241 \f
242 ;; Logical operations.
243
244 (define_insn "andsi3"
245 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
246 (and:SI (match_operand:SI 1 "pj_source_operand" "%gS")
247 (match_operand:SI 2 "pj_source_operand" "gS")))]
248 ""
249 "%S1%S2%*iand%R0")
250
251 (define_insn "anddi3"
252 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
253 (and:DI (match_operand:DI 1 "pj_source_operand" "%gS")
254 (match_operand:DI 2 "pj_source_operand" "gS")))]
255 ""
256 "%D1%D2%*land%R0")
257
258 (define_insn "iorsi3"
259 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
260 (ior:SI (match_operand:SI 1 "pj_source_operand" "%gS")
261 (match_operand:SI 2 "pj_source_operand" "gS")))]
262 ""
263 "%S1%S2%*ior%R0")
264
265 (define_insn "iordi3"
266 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
267 (ior:DI (match_operand:DI 1 "pj_source_operand" "%gS")
268 (match_operand:DI 2 "pj_source_operand" "gS")))]
269 ""
270 "%D1%D2%*lor%R0")
271
272 (define_insn "xorsi3"
273 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
274 (xor:SI (match_operand:SI 1 "pj_source_operand" "%gS")
275 (match_operand:SI 2 "pj_source_operand" "gS")))]
276 ""
277 "%S1%S2%*ixor%R0")
278
279 (define_insn "xordi3"
280 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
281 (xor:DI (match_operand:DI 1 "pj_source_operand" "%gS")
282 (match_operand:DI 2 "pj_source_operand" "gS")))]
283 ""
284 "%D1%D2%*lxor%R0")
285
286 (define_insn "one_cmplsi2"
287 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
288 (not:SI (match_operand:SI 1 "pj_source_operand" "gS")))]
289 ""
290 "%S1%*iconst_m1%*ixor%R0")
291
292 (define_insn "one_cmpldi2"
293 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
294 (not:DI (match_operand:DI 1 "pj_source_operand" "gS")))]
295 ""
296 "%S1%*iconst_m1%*iconst_m1%*lxor%R0")
297
298 \f
299 ;; Shift instructions.
300
301 (define_insn "ashlsi3"
302 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
303 (ashift:SI (match_operand:SI 1 "pj_source_operand" "gS")
304 (match_operand:SI 2 "pj_source_operand" "gS")))]
305 ""
306 "%S1%S2%*ishl%R0")
307
308
309 (define_insn "ashldi3"
310 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
311 (ashift:DI (match_operand:DI 1 "pj_source_operand" "gS")
312 (match_operand:SI 2 "pj_source_operand" "gS")))]
313 ""
314 "%D1%S2%*lshl%R0")
315
316 (define_insn "ashrsi3"
317 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
318 (ashiftrt:SI (match_operand:SI 1 "pj_source_operand" "gS")
319 (match_operand:SI 2 "pj_source_operand" "gS")))]
320 ""
321 "%S1%S2%*ishr%R0")
322
323 (define_insn "ashrdi3"
324 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
325 (ashiftrt:DI (match_operand:DI 1 "pj_source_operand" "gS")
326 (match_operand:SI 2 "pj_source_operand" "gS")))]
327 ""
328 "%D1%S2%*lshr%R0")
329
330 (define_insn "lshrsi3"
331 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
332 (lshiftrt:SI (match_operand:SI 1 "pj_source_operand" "gS")
333 (match_operand:SI 2 "pj_source_operand" "gS")))]
334 ""
335 "%S1%S2%*iushr%R0")
336
337 (define_insn "lshrdi3"
338 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
339 (lshiftrt:DI (match_operand:DI 1 "pj_source_operand" "gS")
340 (match_operand:SI 2 "pj_source_operand" "gS")))]
341 ""
342 "%D1%S2%*lushr%R0")
343
344 \f
345 ;; Comparisons.
346
347 (define_expand "cmpsi"
348 [(set (cc0) (compare (match_operand:SI 0 "pj_source_operand" "gS")
349 (match_operand:SI 1 "pj_source_operand" "gS")))]
350 ""
351 "{
352 pj_cmp_op0 = operands[0];
353 pj_cmp_op1 = operands[1];
354 pj_cmp_mode = SImode;
355 DONE;
356 }")
357
358 (define_expand "cmpdi"
359 [(set (cc0) (compare (match_operand:DI 0 "pj_source_operand" "gS")
360 (match_operand:DI 1 "pj_source_operand" "gS")))]
361 ""
362 "{
363 pj_cmp_op0 = operands[0];
364 pj_cmp_op1 = operands[1];
365 pj_cmp_mode = DImode;
366 DONE;
367 }")
368
369 (define_expand "cmpsf"
370 [(set (cc0) (compare (match_operand:SF 0 "pj_source_operand" "gS")
371 (match_operand:SF 1 "pj_source_operand" "gS")))]
372 ""
373 "{
374 pj_cmp_op0 = operands[0];
375 pj_cmp_op1 = operands[1];
376 pj_cmp_mode = SFmode;
377 DONE;
378 }")
379
380 (define_expand "cmpdf"
381 [(set (cc0) (compare (match_operand:DF 0 "pj_source_operand" "gS")
382 (match_operand:DF 1 "pj_source_operand" "gS")))]
383 ""
384 "{
385 pj_cmp_op0 = operands[0];
386 pj_cmp_op1 = operands[1];
387 pj_cmp_mode = DFmode;
388 DONE;
389 }")
390
391 \f
392 ;; Conversions.
393
394 (define_insn "truncsiqi2"
395 [(set (match_operand:QI 0 "nonimmediate_operand" "=gD")
396 (truncate:QI (match_operand:SI 1 "pj_source_operand" "gS")))]
397 ""
398 "%S1%*%R0")
399
400 (define_insn "truncsihi2"
401 [(set (match_operand:HI 0 "nonimmediate_operand" "=gD")
402 (truncate:HI (match_operand:SI 1 "pj_source_operand" "gS")))]
403 ""
404 "%S1%*i2c%R0")
405
406 (define_insn "truncdisi2"
407 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
408 (truncate:SI (match_operand:DI 1 "pj_source_operand" "gS")))]
409 ""
410 "%D1%*l2i%R0")
411
412 (define_insn "fix_truncsfsi2"
413 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
414 (fix:SI (match_operand:SF 1 "pj_source_operand" "gS")))]
415 ""
416 "%S1%*f2i%R0")
417
418 (define_insn "fix_truncsfdi2"
419 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
420 (fix:DI (match_operand:SF 1 "pj_source_operand" "gS")))]
421 ""
422 "%S1%*f2l%R0")
423
424 (define_insn "truncdfsf2"
425 [(set (match_operand:SF 0 "nonimmediate_operand" "=gD")
426 (float_truncate:SF (match_operand:DF 1 "pj_source_operand" "gS")))]
427 ""
428 "%D1%*d2f%R0")
429
430 (define_insn "fix_truncdfsi2"
431 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
432 (fix:SI (match_operand:DF 1 "pj_source_operand" "gS")))]
433 ""
434 "%D1%*d2i%R0")
435
436 (define_insn "fix_truncdfdi2"
437 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
438 (fix:DI (match_operand:DF 1 "pj_source_operand" "gS")))]
439 ""
440 "%D1%*d2l%R0")
441
442 (define_insn "floatsisf2"
443 [(set (match_operand:SF 0 "nonimmediate_operand" "=gD")
444 (float:SF (match_operand:SI 1 "pj_source_operand" "gS")))]
445 ""
446 "%S1%*i2f%R0")
447
448 (define_insn "floatsidf2"
449 [(set (match_operand:DF 0 "nonimmediate_operand" "=gD")
450 (float:DF (match_operand:SI 1 "pj_source_operand" "gS")))]
451 ""
452 "%S1%*i2d%R0")
453
454 (define_insn "floatdisf2"
455 [(set (match_operand:SF 0 "nonimmediate_operand" "=gD")
456 (float:SF (match_operand:DI 1 "pj_source_operand" "gS")))]
457 ""
458 "%D1%*l2f%R0")
459
460 (define_insn "floatdidf2"
461 [(set (match_operand:DF 0 "nonimmediate_operand" "=gD")
462 (float:DF (match_operand:DI 1 "pj_source_operand" "gS")))]
463 ""
464 "%D1%*l2d%R0")
465
466 \f
467 ;; Zero-extend move instructions.
468
469 (define_insn "zero_extendsidi2"
470 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
471 (zero_extend:DI (match_operand:SI 1 "pj_source_operand" "gS")))]
472 ""
473 "%P1%R0")
474
475 (define_insn "zero_extendhisi2"
476 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
477 (zero_extend:SI (match_operand:HI 1 "pj_source_operand" "gS")))]
478 ""
479 "%S1%*i2c%R0")
480
481 (define_insn "zero_extendqisi2"
482 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
483 (zero_extend:SI (match_operand:QI 1 "pj_source_operand" "gS")))]
484 ""
485 "%S1%*sipush 0xff%*iand%R0")
486
487 \f
488 ;; Conditional branch instructions.
489
490 (define_expand "beq"
491 [(set (pc) (if_then_else (match_op_dup 3 [(match_dup 1) (match_dup 2)])
492 (label_ref (match_operand 0 "" ""))
493 (pc)))]
494 ""
495 "operands[3] = gen_rtx (EQ, pj_cmp_mode);
496 operands[1] = pj_cmp_op0;
497 operands[2] = pj_cmp_op1;")
498
499 (define_expand "bne"
500 [(set (pc) (if_then_else (match_op_dup 3 [(match_dup 1) (match_dup 2)])
501 (label_ref (match_operand 0 "" ""))
502 (pc)))]
503 ""
504 "operands[3] = gen_rtx (NE, pj_cmp_mode);
505 operands[1] = pj_cmp_op0;
506 operands[2] = pj_cmp_op1;")
507
508 (define_expand "bgt"
509 [(set (pc) (if_then_else (match_op_dup 3 [(match_dup 1) (match_dup 2)])
510 (label_ref (match_operand 0 "" ""))
511 (pc)))]
512 ""
513 "operands[3] = gen_rtx (GT, pj_cmp_mode);
514 operands[1] = pj_cmp_op0;
515 operands[2] = pj_cmp_op1;")
516
517 (define_expand "blt"
518 [(set (pc) (if_then_else (match_op_dup 3 [(match_dup 1) (match_dup 2)])
519 (label_ref (match_operand 0 "" ""))
520 (pc)))]
521 ""
522 "operands[3] = gen_rtx (LT, pj_cmp_mode);
523 operands[1] = pj_cmp_op0;
524 operands[2] = pj_cmp_op1;")
525
526 (define_expand "bge"
527 [(set (pc) (if_then_else (match_op_dup 3 [(match_dup 1) (match_dup 2)])
528 (label_ref (match_operand 0 "" ""))
529 (pc)))]
530 ""
531 "operands[3] = gen_rtx (GE, pj_cmp_mode);
532 operands[1] = pj_cmp_op0;
533 operands[2] = pj_cmp_op1;")
534
535 (define_expand "ble"
536 [(set (pc) (if_then_else (match_op_dup 3 [(match_dup 1) (match_dup 2)])
537 (label_ref (match_operand 0 "" ""))
538 (pc)))]
539 ""
540 "operands[3] = gen_rtx (LE, pj_cmp_mode);
541 operands[1] = pj_cmp_op0;
542 operands[2] = pj_cmp_op1;")
543
544 (define_expand "bgtu"
545 [(set (pc) (if_then_else (match_op_dup 3 [(match_dup 1) (match_dup 2)])
546 (label_ref (match_operand 0 "" ""))
547 (pc)))]
548 ""
549 "operands[3] = gen_rtx (GTU, pj_cmp_mode);
550 operands[1] = pj_cmp_op0;
551 operands[2] = pj_cmp_op1;")
552
553 (define_expand "bltu"
554 [(set (pc) (if_then_else (match_op_dup 3 [(match_dup 1) (match_dup 2)])
555 (label_ref (match_operand 0 "" ""))
556 (pc)))]
557 ""
558 "operands[3] = gen_rtx (LTU, pj_cmp_mode);
559 operands[1] = pj_cmp_op0;
560 operands[2] = pj_cmp_op1;")
561
562 (define_expand "bgeu"
563 [(set (pc) (if_then_else (match_op_dup 3 [(match_dup 1) (match_dup 2)])
564 (label_ref (match_operand 0 "" ""))
565 (pc)))]
566 ""
567 "operands[3] = gen_rtx (GEU, pj_cmp_mode);
568 operands[1] = pj_cmp_op0;
569 operands[2] = pj_cmp_op1;")
570
571 (define_expand "bleu"
572 [(set (pc) (if_then_else (match_op_dup 3 [(match_dup 1) (match_dup 2)])
573 (label_ref (match_operand 0 "" ""))
574 (pc)))]
575 ""
576 "operands[3] = gen_rtx (LEU, pj_cmp_mode);
577 operands[1] = pj_cmp_op0;
578 operands[2] = pj_cmp_op1;")
579
580 (define_insn "*bop"
581 [(set (pc) (if_then_else (match_operand:SI 0 "pj_source_operand" "gS")
582 (label_ref (match_operand 1 "" ""))
583 (pc)))]
584 ""
585 "%S0%*ifne %1")
586
587 (define_insn "*rev_bop"
588 [(set (pc) (if_then_else (match_operand:SI 0 "pj_source_operand" "gS")
589 (pc)
590 (label_ref (match_operand 1 "" ""))))]
591
592 ""
593 "%S0%*ifeq %1")
594
595 (define_insn "*blopsi"
596 [(set (pc)
597 (if_then_else
598 (match_operator:SI 3 "pj_signed_comparison_operator"
599 [(match_operand:SI 0 "pj_source_operand" "gS,gS")
600 (match_operand:SI 1 "pj_source_operand" "K,gS")])
601 (label_ref (match_operand 2 "" ""))
602 (pc)))]
603 ""
604 "@
605 %S0%*if%Y3 %2
606 %S0%S1%*if_icmp%Y3 %2")
607
608 (define_insn "*rev_blopsi"
609 [(set (pc)
610 (if_then_else
611 (match_operator:SI 3 "pj_signed_comparison_operator"
612 [(match_operand:SI 0 "pj_source_operand" "gS,gS")
613 (match_operand:SI 1 "pj_source_operand" "K,gS")])
614 (pc)
615 (label_ref (match_operand 2 "" ""))))]
616 ""
617 "@
618 %S0%*if%Z3 %2
619 %S0%S1%*if_icmp%Z3 %2")
620
621 (define_insn "*bluopsi"
622 [(set (pc)
623 (if_then_else
624 (match_operator:SI 3 "pj_unsigned_comparison_operator"
625 [(match_operand:SI 0 "pj_source_operand" "gS")
626 (match_operand:SI 1 "pj_source_operand" "gS")])
627 (label_ref (match_operand 2 "" ""))
628 (pc)))]
629 ""
630 "%S0%S1%*iucmp%*if%Y3 %2")
631
632 (define_insn "*rev_bluopsi"
633 [(set (pc)
634 (if_then_else
635 (match_operator:SI 3 "pj_unsigned_comparison_operator"
636 [(match_operand:SI 0 "pj_source_operand" "gS")
637 (match_operand:SI 1 "pj_source_operand" "gS")])
638 (pc)
639 (label_ref (match_operand 2 "" ""))))]
640 ""
641 "%S0%S1%*iucmp%*if%Z3 %2")
642
643 (define_insn "*blopdi"
644 [(set (pc)
645 (if_then_else
646 (match_operator:DI 3 "pj_signed_comparison_operator"
647 [(match_operand:DI 0 "pj_source_operand" "gS")
648 (match_operand:DI 1 "pj_source_operand" "gS")])
649 (label_ref (match_operand 2 "" ""))
650 (pc)))]
651 ""
652 "%D0%D1%*lcmp%*if%Y3 %2")
653
654 (define_insn "*rev_blopdi"
655 [(set (pc)
656 (if_then_else
657 (match_operator:DI 3 "pj_signed_comparison_operator"
658 [(match_operand:DI 0 "pj_source_operand" "gS")
659 (match_operand:DI 1 "pj_source_operand" "gS")])
660 (pc)
661 (label_ref (match_operand 2 "" ""))))]
662 ""
663 "%D0%D1%*lcmp%*if%Z3 %2")
664
665 (define_insn "*bluopdi"
666 [(set (pc)
667 (if_then_else
668 (match_operator:DI 3 "pj_unsigned_comparison_operator"
669 [(match_operand:DI 0 "pj_source_operand" "gS")
670 (match_operand:DI 1 "pj_source_operand" "gS")])
671 (label_ref (match_operand 2 "" ""))
672 (pc)))]
673 ""
674 "%D0%D1%*ipush __pjucmpdi2%*bipush 6%*call%*if%Y3 %2")
675
676 (define_insn "*rev_bluopdi"
677 [(set (pc)
678 (if_then_else
679 (match_operator:DI 3 "pj_unsigned_comparison_operator"
680 [(match_operand:DI 0 "pj_source_operand" "gS")
681 (match_operand:DI 1 "pj_source_operand" "gS")])
682 (pc)
683 (label_ref (match_operand 2 "" ""))))]
684 ""
685 "%D0%D1%*ipush __pjucmpdi2%*bipush 6%*call%*if%Z3 %2")
686
687 (define_insn "*blopsf"
688 [(set (pc)
689 (if_then_else
690 (match_operator:SF 3 "comparison_operator"
691 [(match_operand:SF 0 "pj_source_operand" "gS")
692 (match_operand:SF 1 "pj_source_operand" "gS")])
693 (label_ref (match_operand 2 "" ""))
694 (pc)))]
695 ""
696 "%S0%S1%*fcmp%X3%*if%Y3 %2")
697
698 (define_insn "*rev_bluopsf"
699 [(set (pc)
700 (if_then_else
701 (match_operator:SF 3 "comparison_operator"
702 [(match_operand:SF 0 "pj_source_operand" "gS")
703 (match_operand:SF 1 "pj_source_operand" "gS")])
704 (pc)
705 (label_ref (match_operand 2 "" ""))))]
706 ""
707 "%S0%S1%*fcmp%X3%*if%Z3 %2")
708
709 (define_insn "*blopdf"
710 [(set (pc)
711 (if_then_else
712 (match_operator:DF 3 "comparison_operator"
713 [(match_operand:DF 0 "pj_source_operand" "gS")
714 (match_operand:DF 1 "pj_source_operand" "gS")])
715 (label_ref (match_operand 2 "" ""))
716 (pc)))]
717 ""
718 "%D0%D1%*dcmp%X3%*if%Y3 %2")
719
720 (define_insn "*rev_bluopdf"
721 [(set (pc)
722 (if_then_else
723 (match_operator:DF 3 "comparison_operator"
724 [(match_operand:DF 0 "pj_source_operand" "gS")
725 (match_operand:DF 1 "pj_source_operand" "gS")])
726 (pc)
727 (label_ref (match_operand 2 "" ""))))]
728 ""
729 "%D0%D1%*dcmp%X3%*if%Z3 %2")
730
731 \f
732 ;; call instructions
733
734 (define_insn "pj_call"
735 [(call (mem:QI (match_operand:SI 0 "pj_source_operand" "gS"))
736 (match_operand:SI 1 "immediate_operand" "i"))]
737 ""
738 "%C0%E1%S0%S1%*call")
739
740 (define_insn "pj_call_value"
741 [(set (match_operand 0 "nonimmediate_operand" "=gD")
742 (call (mem:QI (match_operand:SI 1 "pj_source_operand" "gS"))
743 (match_operand:SI 2 "immediate_operand" "i")))]
744
745 ""
746 "%C1%E2%S1%S2%*call")
747
748 (define_expand "call"
749 [(call (match_operand:SI 0 "pj_source_operand" "gS")
750 (match_operand:SI 1 "immediate_operand" "i"))
751 (use (match_operand:SI 2 "register_operand" "r"))
752 (use (match_operand:SI 3 "" ""))]
753 ""
754 "{
755 emit_call_insn (gen_pj_call (XEXP (operands[0], 0),
756 pj_workout_arg_words (operands[1],
757 operands[2])));
758 DONE;
759 }")
760
761 (define_expand "call_value"
762 [(set (match_operand:SI 0 "nonimmediate_operand" "gS")
763 (call (match_operand:SI 1 "pj_source_operand" "gS")
764 (match_operand:SI 2 "immediate_operand" "i")))
765 (use (match_operand:SI 3 "register_operand" "r"))
766 (use (match_operand:SI 4 "" ""))]
767 ""
768 "{
769 emit_call_insn (gen_pj_call_value (operands[0],
770 XEXP (operands[1], 0),
771 pj_workout_arg_words (operands[2],
772 operands[3])));
773 DONE;
774 }")
775
776 \f
777 ;; No-op instruction.
778
779 (define_insn "nop"
780 [(const_int 0)]
781 ""
782 "nop")
783
784 \f
785 ;; Jump instructions
786
787 (define_insn "jump"
788 [(set (pc) (label_ref (match_operand 0 "" "")))]
789 ""
790 "%*goto %l0")
791
792 (define_insn "indirect_jump"
793 [(set (pc) (match_operand:SI 0 "pj_source_operand" "gS"))]
794 ""
795 "%S0%*write_pc")
796
797 (define_insn "casesi"
798 [(set (pc)
799 (if_then_else
800 (leu (minus:SI (match_operand:SI 0 "pj_source_operand" "gS")
801 (match_operand:SI 1 "immediate_operand" "i"))
802 (match_operand:SI 2 "immediate_operand" "i"))
803 (plus:SI (sign_extend:SI
804 (mem:SI
805 (plus:SI (pc)
806 (mult:SI (minus:SI (match_dup 0)
807 (match_dup 1))
808 (const_int 4)))))
809 (label_ref (match_operand 3 "" "")))
810 (label_ref (match_operand 4 "" ""))))]
811 ""
812 "%S0\\n%3i:%*tableswitch\\n\\t%*.align 2%*.long %4-%3i%*.long %1%*.long %1+%2")
813 \f
814 ;; Sign-extend move instructions.
815
816 (define_insn "extendsfdf2"
817 [(set (match_operand:DF 0 "nonimmediate_operand" "=gD")
818 (float_extend:DF (match_operand:SF 1 "pj_source_operand" "gS")))]
819 ""
820 "%S1%*f2d%R0")
821
822 (define_insn "extendhisi2"
823 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
824 (sign_extend:SI (match_operand:HI 1 "pj_source_operand" "gS")))]
825 ""
826 "%S1%*bipush 16%*ishl%*bipush 16%*ishr%R0")
827
828 (define_insn "extendqisi2"
829 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
830 (sign_extend:SI (match_operand:QI 1 "pj_source_operand" "gS")))]
831 ""
832 "%S1%*bipush 24%*ishl%*bipush 24%*ishr%R0")
833
834 (define_insn "extendqihi2"
835 [(set (match_operand:HI 0 "nonimmediate_operand" "=gD")
836 (sign_extend:HI (match_operand:QI 1 "pj_source_operand" "gS")))]
837 ""
838 "%S1%*bipush 24%*ishl%*bipush 24%*ishr%R0")
839
840 (define_insn "extendsidi2"
841 [(set (match_operand:DI 0 "nonimmediate_operand" "=gD")
842 (sign_extend:DI (match_operand:SI 1 "pj_source_operand" "gS")))]
843 ""
844 "%S1%*i2l%R0")
845
846 \f
847 ;; non local control flow.
848
849 (define_expand "save_stack_nonlocal"
850 [(set (match_operand 0 "nonimmediate_operand" "=gD")
851 (match_operand 1 "pj_source_operand" "gS"))]
852 ""
853 "{
854 rtx reg = force_reg (Pmode, XEXP (operands[0], 0));
855 rtx addr0 = gen_rtx_MEM (SImode,reg);
856 rtx addr1 = gen_rtx_MEM (SImode, gen_rtx_PRE_INC (SImode, reg));
857 rtx addr2 = gen_rtx_MEM (SImode, gen_rtx_PRE_INC (SImode, reg));
858
859 emit_move_insn (addr0, gen_rtx_REG (SImode, 64));
860 emit_move_insn (addr1, gen_rtx_REG (SImode, 72));
861 emit_move_insn (addr2, gen_rtx_REG (SImode, 73));
862
863 DONE;
864 }")
865
866 (define_insn "restore_stack_nonlocal_helper"
867 [(set (reg:SI 64) (mem:SI (match_operand:SI 0 "register_operand" "r")))
868 (set (reg:SI 72) (mem:SI (pre_inc:SI (match_dup 0))))
869 (set (reg:SI 73) (mem:SI (pre_inc:SI (match_dup 0))))]
870 ""
871 "%S0%*load_word%*write_global0%*iinc %J0,4%S0%*load_word%*iinc %J0,4%S0%*load_word%*write_vars%*write_optop")
872
873 (define_expand "restore_stack_nonlocal"
874 [(set (match_operand 0 "nonimmediate_operand" "=gD")
875 (match_operand 1 "pj_source_operand" "gS"))]
876 ""
877 "{
878 rtx reg = force_reg (Pmode, XEXP (operands[1], 0));
879 emit_insn (gen_restore_stack_nonlocal_helper (reg));
880 DONE;
881 }")
882
883 (define_insn "nonlocal_goto_helper"
884 [(set (reg:SI 64) (mem:SI (match_operand:SI 0 "register_operand" "r")))
885 (set (reg:SI 72) (mem:SI (pre_inc:SI (match_dup 0))))
886 (set (reg:SI 73) (mem:SI (pre_inc:SI (match_dup 0))))
887 (set (pc) (match_operand:SI 1 "pj_source_operand" "gS"))]
888 ""
889 "%S0%*load_word%*write_global0%*iinc %J0,4%*%S0%*load_word%*%S1%*iinc %J0,4%*%S0%*load_word%*iinc %J0,4%*write_vars%*return0")
890
891 (define_expand "nonlocal_goto"
892 [(match_operand:SI 0 "pj_source_operand" "")
893 (match_operand:SI 1 "pj_source_operand" "")
894 (match_operand:SI 2 "pj_source_operand" "")
895 (match_operand:SI 3 "" "")]
896 ""
897 "{
898 operands[2] = force_reg (Pmode, XEXP (operands[2], 0));
899 emit_move_insn (hard_frame_pointer_rtx, operands[0]);
900 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
901 emit_insn (gen_nonlocal_goto_helper (operands[2], operands[1]));
902 emit_barrier ();
903 DONE;
904 }")
905 \f
906 ;; Function overhead.
907
908 (define_expand "prologue"
909 [(const_int 0)]
910 ""
911 "pj_expand_prologue (); DONE;")
912
913 (define_expand "epilogue"
914 [(return)]
915 ""
916 "pj_expand_epilogue();")
917
918 (define_insn "return"
919 [(return)]
920 "reload_completed"
921 "%*return0")
922
923 (define_insn "tm_frame"
924 [(use (match_operand:SI 0 "pj_source_operand" "gS"))
925 (set (reg:SI 73)
926 (minus:SI (reg:SI 73)
927 (mult:SI (match_operand:SI 1 "pj_source_operand" "gS")
928 (const_int 4))))]
929
930 ""
931 "%S0%S1%*tm_frame")
932
933 (define_insn "varargs"
934 [(unspec_volatile [(match_operand:SI 0 "pj_source_operand" "gS")] 10)]
935 ""
936 "%S0%*jsr_w __vhelper")
937
938 (define_insn "varargs_finish"
939 [(unspec_volatile [(match_operand:SI 0 "pj_source_operand" "gS")] 11)]
940 ""
941 "%*iload %J0%*write_global0")
942 \f
943 ;; Extensions to picoJava.
944
945 (define_insn "strlensi"
946 [(set (match_operand:SI 0 "nonimmediate_operand" "=g")
947 (unspec:SI [(match_operand:BLK 1 "memory_operand" "gS")
948 (match_operand:QI 2 "pj_source_operand" "gS")
949 (match_operand:SI 3 "immediate_operand" "gS")] 0))
950 (clobber (reg:SI 65))]
951 "TARGET_TM_EXTENSIONS"
952 "%I1%S2%S3%*iconst_0%*write_global1%*tm_strlensi%R0")
953
954 (define_insn "movstrsi"
955 [(set (match_operand:BLK 0 "memory_operand" "=gS")
956 (match_operand:BLK 1 "memory_operand" "gS"))
957 (use (match_operand:SI 2 "pj_source_operand" "gS"))
958 (use (match_operand:SI 3 "pj_source_operand" "gS"))
959 (clobber (reg:SI 65))]
960 "TARGET_TM_EXTENSIONS"
961 "%I0%I1%S2%S3%*iconst_0%*write_global1%*tm_movstrsi")
962
963 (define_insn "clrstrsi"
964 [(set (match_operand:BLK 0 "memory_operand" "=gS")
965 (const_int 0))
966 (use (match_operand:SI 1 "pj_source_operand" "gS"))
967 (use (match_operand:SI 2 "pj_source_operand" "gS"))
968 (clobber (reg:SI 65))]
969 "TARGET_TM_EXTENSIONS"
970 "%I0%*iconst_0%S1%S2%*iconst_0%*write_global1%*tm_memsetsi")
971
972 (define_insn "cmpstrsi"
973 [(set (match_operand:SI 0 "nonimmediate_operand" "=gD")
974 (compare:SI (match_operand:BLK 1 "memory_operand" "g")
975 (match_operand:BLK 2 "memory_operand" "g")))
976 (use (match_operand:SI 3 "pj_source_operand" "gS"))
977 (use (match_operand:SI 4 "pj_source_operand" "gS"))
978 (clobber (reg:SI 65))]
979 "TARGET_TM_EXTENSIONS"
980 "%I1%I2%S3%S4%*iconst_0%*write_global1%*tm_cmpstrsi%R0")