convex.md: Use "+" instead of "=" for outputs wrapped in a STRICT_LOW_PART.
[official-gcc.git] / gcc / config / i370 / i370.md
blob33827e0d3335388391c8a2f4cbc7ea84c12c1b14
1 ;;- Machine description for GNU compiler -- System/370 version.
2 ;;  Copyright (C) 1989, 1993, 1994, 1995, 1997, 1998, 1999, 2000
3 ;;  Free Software Foundation, Inc.
4 ;;  Contributed by Jan Stein (jan@cd.chalmers.se).
5 ;;  Modified for OS/390 LanguageEnvironment C by Dave Pitts (dpitts@cozx.com)
6 ;;  Lots of Bug Fixes & Enhancements by Linas Vepstas (linas@linas.org)
8 ;; This file is part of GNU CC.
10 ;; GNU CC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
15 ;; GNU CC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU CC; see the file COPYING.  If not, write to
22 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;; =======================================================================
26 ;; Condition codes for some of the instructions (in particular, for 
27 ;; add, sub, shift, abs, etc. are handled with the cpp macro NOTICE_UPDATE_CC 
29 ;; Special constraints for 370 machine description:
31 ;;    a -- Any address register from 1 to 15.
32 ;;    d -- Any register from 0 to 15.
33 ;;    I -- An 8-bit constant (0..255).
34 ;;    J -- A 12-bit constant (0..4095).
35 ;;    K -- A 16-bit constant (-32768..32767).
36 ;;    R -- a valid S operand in an RS, SI or SS instruction, or register
37 ;;    S -- a valid S operand in an RS, SI or SS instruction
39 ;; Note this well: 
40 ;; When defining an instruction, e.g. the movsi pattern:
41 ;; 
42 ;;    (define_insn ""
43 ;;        [(set (match_operand:SI 0 "r_or_s_operand" "=dm,d,dm")
44 ;;            (match_operand:SI 1 "r_or_s_operand" "diR,dim,*fF"))]
46 ;; The "r_or_s_operand" predicate is used to recognize the instruction;
47 ;; however, it is not further used to enforce a constraint at later stages.
48 ;; Thus, for example, although "r_or_s_operand" bars operands of the form
49 ;; base+index+displacement, such operands can none-the-less show up during
50 ;; post-instruction-recog processing: thus, for example, garbage like
51 ;; MVC     152(4,r13),0(r5,r13) might be generated if both op0 and op1 are 
52 ;; mem operands.   To avoid this, use the S constraint.
53 ;; 
55 ;; Special formats used for outputting 370 instructions.
57 ;;   %B -- Print a constant byte integer.
58 ;;   %H -- Print a signed 16-bit constant.
59 ;;   %K -- Print a signed 16-bit constant signed-extended to 32-bits.
60 ;;   %L -- Print least significant word of a CONST_DOUBLE.
61 ;;   %M -- Print most significant word of a CONST_DOUBLE.
62 ;;   %N -- Print next register (second word of a DImode reg).
63 ;;   %O -- Print the offset of a memory reference (PLUS (REG) (CONST_INT)).
64 ;;   %R -- Print the register of a memory reference (PLUS (REG) (CONST_INT)).
65 ;;   %X -- Print a constant byte integer in hex.
66 ;;   %W -- Print a signed 32-bit int sign-extended to 64-bits.
68 ;; We have a special constraint for pattern matching.
70 ;;   s_operand -- Matches a valid S operand in a RS, SI or SS type instruction.
72 ;;   r_or_s_operand -- Matches a register or a valid S operand in a RS, SI
73 ;;                     or SS type instruction or a register
75 ;; For MVS C/370 we use the following stack locations for:
77 ;;   136 - internal function result buffer
78 ;;   140 - numeric conversion buffer
79 ;;   144 - pointer to internal function result buffer
80 ;;   148 - start of automatic variables and function arguments
82 ;; To support programs larger than a page, 4096 bytes, PAGE_REGISTER points
83 ;; to a page origin table, all internal labels are generated to reload the
84 ;; BASE_REGISTER knowing what page it is on and all branch instructions go
85 ;; directly to the target if it is known that the target is on the current
86 ;; page (essentially backward references).  All forward references and off
87 ;; page references are handled by loading the address of target into a
88 ;; register and branching indirectly.
90 ;; Some *di patterns have been commented out per advice from RMS, as gcc
91 ;; will generate the right things to do.
93 ;; See the note in i370.h about register 14, clobbering it, and optimization.
94 ;; Basically, using clobber in egcs-1.1.1 will ruin ability to optimize around
95 ;; branches, so don't do it.
97 ;; We use the "length" attirbute to store the max possible code size of an
98 ;; insn.  We use this length to estimate the length of forward branches, to
99 ;; determine if they're on page or off.
101 (define_attr "length" "" (const_int 0))
104 ;;- Test instructions.
108 ; tstdi instruction pattern(s).
111 (define_insn "tstdi"
112   [(set (cc0)
113         (match_operand:DI 0 "register_operand" "d"))]
114   ""
115   "*
117   check_label_emit ();
118   mvs_check_page (0, 4, 0);
119   return \"SRDA %0,0\";
121    [(set_attr "length" "4")]
125 ; tstsi instruction pattern(s).
128 (define_insn "tstsi"
129   [(set (cc0)
130         (match_operand:SI 0 "register_operand" "d"))]
131   ""
132   "*
134   check_label_emit ();
135   mvs_check_page (0, 2, 0);
136   return \"LTR  %0,%0\";
138    [(set_attr "length" "2")]
142 ; tsthi instruction pattern(s).
145 (define_insn "tsthi"
146   [(set (cc0)
147         (match_operand:HI 0 "register_operand" "d"))]
148   ""
149   "*
151   check_label_emit ();
152   mvs_check_page (0, 4, 2);
153   return \"CH   %0,=H'0'\";
155    [(set_attr "length" "4")]
159 ; tstqi instruction pattern(s).
162 (define_insn ""
163   [(set (cc0)
164         (match_operand:QI 0 "r_or_s_operand" "dm"))]
165   "unsigned_jump_follows_p (insn)"
166   "*
168   check_label_emit ();
169   if (REG_P (operands[0]))
170     {
171       /* an unsigned compare to zero is always zero/not-zero... */
172       mvs_check_page (0, 4, 4);
173       return \"N        %0,=XL4'000000FF'\";
174     }
175   mvs_check_page (0, 4, 0);
176   return \"CLI  %0,0\";
178    [(set_attr "length" "4")]
181 (define_insn "tstqi"
182   [(set (cc0)
183      (match_operand:QI 0 "register_operand" "d"))]
184   ""
185   "*
187   check_label_emit ();
188   if (unsigned_jump_follows_p (insn))
189     {
190       /* an unsigned compare to zero is always zero/not-zero... */
191       mvs_check_page (0, 4, 4);
192       return \"N        %0,=XL4'000000FF'\";
193     }
194   mvs_check_page (0, 8, 0);
195   return \"SLL  %0,24\;SRA      %0,24\";
197    [(set_attr "length" "8")]
201 ; tstdf instruction pattern(s).
204 (define_insn "tstdf"
205   [(set (cc0)
206         (match_operand:DF 0 "general_operand" "f"))]
207   ""
208   "*
210   check_label_emit ();
211   mvs_check_page (0, 2, 0);
212   return \"LTDR %0,%0\";
214    [(set_attr "length" "2")]
218 ; tstsf instruction pattern(s).
221 (define_insn "tstsf"
222   [(set (cc0)
223         (match_operand:SF 0 "general_operand" "f"))]
224   ""
225   "*
227   check_label_emit ();
228   mvs_check_page (0, 2, 0);
229   return \"LTER %0,%0\";
231    [(set_attr "length" "2")]
235 ;;- Compare instructions.
239 ; cmpdi instruction pattern(s).
242 ;(define_insn "cmpdi"
243 ;  [(set (cc0)
244 ;       (compare (match_operand:DI 0 "register_operand" "d")
245 ;                (match_operand:DI 1 "general_operand" "")))]
246 ;  ""
247 ;  "*
249 ;  check_label_emit ();
250 ;  if (REG_P (operands[1]))
251 ;    {
252 ;      mvs_check_page (0, 8, 0);
253 ;      if (unsigned_jump_follows_p (insn))
254 ;        return \"CLR   %0,%1\;BNE      *+6\;CLR        %N0,%N1\";
255 ;      return \"CR      %0,%1\;BNE      *+6\;CLR        %N0,%N1\";
256 ;    }
257 ;  mvs_check_page (0, 12, 0);
258 ;  if (unsigned_jump_follows_p (insn))
259 ;    return \"CL        %0,%M1\;BNE     *+8\;CL %N0,%L1\";
260 ;  return \"C   %0,%M1\;BNE     *+8\;CL %N0,%L1\";
261 ;}")
264 ; cmpsi instruction pattern(s).
267 (define_insn "cmpsi"
268   [(set (cc0)
269         (compare (match_operand:SI 0 "register_operand" "d")
270                  (match_operand:SI 1 "general_operand" "md")))]
271   ""
272   "*
274   check_label_emit ();
275   if (REG_P (operands[1]))
276     {
277       mvs_check_page (0, 2, 0);
278       if (unsigned_jump_follows_p (insn))
279         return \"CLR    %0,%1\";
280       return \"CR       %0,%1\";
281     }
282   if (GET_CODE (operands[1]) == CONST_INT)
283     {
284       mvs_check_page (0, 4, 4);
285       if (unsigned_jump_follows_p (insn))
286          return \"CL    %0,=F'%c1'\";
287       return \"C        %0,=F'%c1'\";
288     }
289   mvs_check_page (0, 4, 0);
290   if (unsigned_jump_follows_p (insn))
291     return \"CL %0,%1\";
292   return \"C    %0,%1\";
294    [(set_attr "length" "4")]
298 ; cmphi instruction pattern(s).
301 ; depricate constraint d because it takes multiple instructions
302 ; and a memeory access ...
303 (define_insn "cmphi"
304   [(set (cc0)
305         (compare (match_operand:HI 0 "register_operand" "d")
306                  (match_operand:HI 1 "general_operand" "???dim")))]
307   ""
308   "*
310   check_label_emit ();
311   if (REG_P (operands[1]))
312     {
313       mvs_check_page (0, 8, 0);
314       if (unsigned_jump_follows_p (insn))
315         return \"STH    %1,140(,13)\;CLM        %0,3,140(13)\";
316       return \"STH      %1,140(,13)\;CH %0,140(,13)\";
317     }
318   if (GET_CODE (operands[1]) == CONST_INT)
319     {
320       mvs_check_page (0, 4, 0);
321       return \"CH       %0,%H1\";
322     }
323   mvs_check_page (0, 4, 0);
324   return \"CH   %0,%1\";
326    [(set_attr "length" "8")]
330 ; cmpqi instruction pattern(s).
333 (define_insn ""
334   [(set (cc0)
335         (compare (match_operand:QI 0 "r_or_s_operand" "dS")
336                  (match_operand:QI 1 "r_or_s_operand" "diS")))]
337   "unsigned_jump_follows_p (insn)"
338   "*
340   check_label_emit ();
341   if (REG_P (operands[0]))
342     {
343       if (REG_P (operands[1]))
344         {
345           mvs_check_page (0, 8, 0);
346           return \"STC  %1,140(,13)\;CLM        %0,1,140(13)\";
347         }
348       if (GET_CODE (operands[1]) == CONST_INT)
349         {
350           mvs_check_page (0, 4, 1);
351           return \"CLM  %0,1,=XL1'%X1'\";
352         }
353       mvs_check_page (0, 4, 0);
354       return \"CLM      %0,1,%1\";
355     }
356   else if (GET_CODE (operands[0]) == CONST_INT)
357     {
358       cc_status.flags |= CC_REVERSED;
359       if (REG_P (operands[1]))
360         {
361           mvs_check_page (0, 4, 1);
362           return \"CLM  %1,1,=XL1'%X0'\";
363         }
364       mvs_check_page (0, 4, 0);
365       return \"CLI      %1,%B0\";
366     }
367   if (GET_CODE (operands[1]) == CONST_INT)
368     {
369       mvs_check_page (0, 4, 0);
370       return \"CLI      %0,%B1\";
371     }
372   if (GET_CODE (operands[1]) == MEM)
373     {
374       mvs_check_page (0, 6, 0);
375       return \"CLC      %O0(1,%R0),%1\";
376     }
377   cc_status.flags |= CC_REVERSED;
378   mvs_check_page (0, 4, 0);
379   return \"CLM  %1,1,%0\";
381    [(set_attr "length" "8")]
384 (define_insn "cmpqi"
385   [(set (cc0)
386         (compare (match_operand:QI 0 "register_operand" "d")
387                  (match_operand:QI 1 "general_operand" "di")))]
388   ""
389   "*
391   check_label_emit ();
392   if (unsigned_jump_follows_p (insn))
393     {
394       if (GET_CODE (operands[1]) == CONST_INT)
395         {
396           mvs_check_page (0, 4, 1);
397           return \"CLM  %0,1,=XL1'%X1'\";
398         }
399       if (!(REG_P (operands[1])))
400         {
401           mvs_check_page (0, 4, 0);
402           return \"CLM  %0,1,%1\";
403         }
404       mvs_check_page (0, 8, 0);
405       return \"STC      %1,140(,13)\;CLM        %0,1,140(13)\";
406     }
407   if (REG_P (operands[1]))
408     {
409       mvs_check_page (0, 18, 0);
410       return \"SLL      %0,24\;SRA      %0,24\;SLL      %1,24\;SRA      %1,24\;CR       %0,%1\";
411     }
412   mvs_check_page (0, 12, 0);
413   return \"SLL  %0,24\;SRA      %0,24\;C        %0,%1\";
415    [(set_attr "length" "18")]
419 ; cmpdf instruction pattern(s).
422 (define_insn "cmpdf"
423   [(set (cc0)
424         (compare (match_operand:DF 0 "general_operand" "f,mF")
425                  (match_operand:DF 1 "general_operand" "fmF,f")))]
426   ""
427   "*
429   check_label_emit ();
430   if (FP_REG_P (operands[0]))
431     {
432       if (FP_REG_P (operands[1]))
433         {
434           mvs_check_page (0, 2, 0);
435           return \"CDR  %0,%1\";
436         }
437       mvs_check_page (0, 4, 0);
438       return \"CD       %0,%1\";
439     }
440   cc_status.flags |= CC_REVERSED;
441   mvs_check_page (0, 4, 0);
442   return \"CD   %1,%0\";
444    [(set_attr "length" "4")]
448 ; cmpsf instruction pattern(s).
451 (define_insn "cmpsf"
452   [(set (cc0)
453         (compare (match_operand:SF 0 "general_operand" "f,mF")
454                  (match_operand:SF 1 "general_operand" "fmF,f")))]
455   ""
456   "*
458 check_label_emit ();
459   if (FP_REG_P (operands[0]))
460     {
461       if (FP_REG_P (operands[1]))
462         {
463           mvs_check_page (0, 2, 0);
464           return \"CER  %0,%1\";
465         }
466       mvs_check_page (0, 4, 0);
467       return \"CE       %0,%1\";
468     }
469   cc_status.flags |= CC_REVERSED;
470   mvs_check_page (0, 4, 0);
471   return \"CE   %1,%0\";
473    [(set_attr "length" "4")]
477 ; cmpstrsi instruction pattern(s).
480 (define_expand "cmpstrsi"
481   [(set (match_operand:SI 0 "general_operand" "")
482           (compare (match_operand:BLK 1 "general_operand" "")
483                    (match_operand:BLK 2 "general_operand" "")))
484      (use (match_operand:SI 3 "general_operand" ""))
485      (use (match_operand:SI 4 "" ""))]
486    ""
487    "
489   rtx op1, op2;
491   op1 = XEXP (operands[1], 0);
492   if (GET_CODE (op1) == REG
493       || (GET_CODE (op1) == PLUS && GET_CODE (XEXP (op1, 0)) == REG
494           && GET_CODE (XEXP (op1, 1)) == CONST_INT
495           && (unsigned) INTVAL (XEXP (op1, 1)) < 4096))
496     {
497       op1 = operands[1];
498     }
499   else
500     {
501       op1 = gen_rtx_MEM (BLKmode, copy_to_mode_reg (SImode, op1));
502     }
504   op2 = XEXP (operands[2], 0);
505   if (GET_CODE (op2) == REG
506       || (GET_CODE (op2) == PLUS && GET_CODE (XEXP (op2, 0)) == REG
507           && GET_CODE (XEXP (op2, 1)) == CONST_INT
508           && (unsigned) INTVAL (XEXP (op2, 1)) < 4096))
509     {
510       op2 = operands[2];
511     }
512   else
513     {
514       op2 = gen_rtx_MEM (BLKmode, copy_to_mode_reg (SImode, op2));
515     }
516       
517   if (GET_CODE (operands[3]) == CONST_INT && INTVAL (operands[3]) < 256)
518     {
519       emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2,
520                 gen_rtx_SET (VOIDmode, operands[0], 
521                         gen_rtx_COMPARE (VOIDmode, op1, op2)),
522                 gen_rtx_USE (VOIDmode, operands[3]))));
523     }
524   else
525     {
526         /* implementation suggested by  Richard Henderson <rth@cygnus.com> */
527         rtx reg1 = gen_reg_rtx (DImode);
528         rtx reg2 = gen_reg_rtx (DImode);
529         rtx result = operands[0];
530         rtx mem1 = operands[1];
531         rtx mem2 = operands[2];
532         rtx len = operands[3];
533         if (!CONSTANT_P (len))
534           len = force_reg (SImode, len);
536         /* Load up the address+length pairs.  */
537         emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
538         emit_move_insn (gen_rtx_SUBREG (SImode, reg1, 0),
539                         force_operand (XEXP (mem1, 0), NULL_RTX));
540         emit_move_insn (gen_rtx_SUBREG (SImode, reg1, 1), len);
542         emit_insn (gen_rtx_CLOBBER (VOIDmode, reg2));
543         emit_move_insn (gen_rtx_SUBREG (SImode, reg2, 0),
544                         force_operand (XEXP (mem2, 0), NULL_RTX));
545         emit_move_insn (gen_rtx_SUBREG (SImode, reg2, 1), len);
547         /* Compare! */
548         emit_insn (gen_cmpstrsi_1 (result, reg1, reg2));
549     }
550   DONE;
553 ; Compare a block that is less than 256 bytes in length.
555 (define_insn ""
556   [(set (match_operand:SI 0 "register_operand" "=d")
557         (compare (match_operand:BLK 1 "s_operand" "m")
558                  (match_operand:BLK 2 "s_operand" "m")))
559    (use (match_operand:QI 3 "immediate_operand" "I"))]
560   "((unsigned) INTVAL (operands[3]) < 256)"
561   "*
563   check_label_emit ();
564   mvs_check_page (0, 22, 0);
565   return \"LA   %0,%1\;CLC      %O1(%c3,%R1),%2\;BH     *+12\;BL        *+6\;SLR        %0,%0\;LNR      %0,%0\";
567    [(set_attr "length" "22")]
570 ; Compare a block that is larger than 255 bytes in length.
572 (define_insn "cmpstrsi_1"
573   [(set (match_operand:SI 0 "register_operand" "+d")
574         (compare
575         (mem:BLK (subreg:SI (match_operand:DI 1 "register_operand" "+d") 0))
576         (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "+d") 0))))
577    (use (match_dup 1))
578    (use (match_dup 2))
579    (clobber (match_dup 1))
580    (clobber (match_dup 2))]
581   ""
582   "*
584   check_label_emit ();
585   mvs_check_page (0, 18, 0);
586   return \"LA   %0,1(0,0)\;CLCL %1,%2\;BH       *+12\;BL        *+6\;SLR        %0,%0\;LNR      %0,%0\";
588    [(set_attr "length" "18")]
592 ;;- Move instructions.
596 ; movdi instruction pattern(s).
599 (define_insn ""
600 ;;  [(set (match_operand:DI 0 "r_or_s_operand" "=dm")
601 ;;        (match_operand:DI 1 "r_or_s_operand" "dim*fF"))]
602   [(set (match_operand:DI 0 "r_or_s_operand" "=dS,m")
603         (match_operand:DI 1 "r_or_s_operand" "diS*fF,d*fF"))]
605   "TARGET_CHAR_INSTRUCTIONS"
606   "*
608   check_label_emit ();
609   if (REG_P (operands[0]))
610     {
611       if (FP_REG_P (operands[1]))
612         {
613           mvs_check_page (0, 8, 0);
614           return \"STD  %1,140(,13)\;LM %0,%N0,140(13)\";
615         }
616       if (REG_P (operands[1]))
617         {
618           mvs_check_page (0, 4, 0);
619           return \"LR   %0,%1\;LR       %N0,%N1\";
620         }
621       if (operands[1] == const0_rtx)
622         {
623           CC_STATUS_INIT;
624           mvs_check_page (0, 4, 0);
625           return \"SLR  %0,%0\;SLR      %N0,%N0\";
626         }
627       if (GET_CODE (operands[1]) == CONST_INT
628           && (unsigned) INTVAL (operands[1]) < 4096)
629         {
630           CC_STATUS_INIT;
631           mvs_check_page (0, 6, 0);
632           return \"SLR  %0,%0\;LA       %N0,%c1(0,0)\";
633         }
634       if (GET_CODE (operands[1]) == CONST_INT)
635         {
636           CC_STATUS_SET (operands[0], operands[1]);
637           mvs_check_page (0, 8, 0);
638           return \"L    %0,%1\;SRDA     %0,32\";
639         }
640       mvs_check_page (0, 4, 0);
641       return \"LM       %0,%N0,%1\";
642     }
643   else if (FP_REG_P (operands[1]))
644     {
645       mvs_check_page (0, 4, 0);
646       return \"STD      %1,%0\";
647     }
648   else if (REG_P (operands[1]))
649     {
650       mvs_check_page (0, 4, 0);
651       return \"STM      %1,%N1,%0\"; 
652     }
653   mvs_check_page (0, 6, 0);
654   return \"MVC  %O0(8,%R0),%W1\";
656    [(set_attr "length" "8")]
659 (define_insn "movdi"
660 ;;  [(set (match_operand:DI 0 "general_operand" "=d,dm")
661 ;;      (match_operand:DI 1 "general_operand" "dimF,*fd"))]
662   [(set (match_operand:DI 0 "general_operand" "=d,dm")
663         (match_operand:DI 1 "r_or_s_operand" "diSF,*fd"))]
664   ""
665   "*
667   check_label_emit ();
668   if (REG_P (operands[0]))
669     {
670       if (FP_REG_P (operands[1]))
671         {
672           mvs_check_page (0, 8, 0);
673           return \"STD  %1,140(,13)\;LM %0,%N0,140(13)\";
674         }
675       if (REG_P (operands[1]))
676         {
677           mvs_check_page (0, 4, 0);
678           return \"LR   %0,%1\;LR       %N0,%N1\";
679         }
680       if (operands[1] == const0_rtx)
681         {
682           CC_STATUS_INIT;
683           mvs_check_page (0, 4, 0);
684           return \"SLR  %0,%0\;SLR      %N0,%N0\";
685         }
686       if (GET_CODE (operands[1]) == CONST_INT
687           && (unsigned) INTVAL (operands[1]) < 4096)
688         {
689           CC_STATUS_INIT;
690           mvs_check_page (0, 6, 0);
691           return \"SLR  %0,%0\;LA       %N0,%c1(0,0)\";
692         }
693       if (GET_CODE (operands[1]) == CONST_INT)
694         {
695           CC_STATUS_SET (operands[0], operands[1]);
696           mvs_check_page (0, 8, 0);
697           return \"L    %0,%1\;SRDA     %0,32\";
698         }
699       mvs_check_page (0, 4, 0);
700       return \"LM       %0,%N0,%1\";
701     }
702   else if (FP_REG_P (operands[1]))
703     {
704       mvs_check_page (0, 4, 0);
705       return \"STD      %1,%0\";
706     }
707   mvs_check_page (0, 4, 0);
708   return \"STM  %1,%N1,%0\";
710    [(set_attr "length" "8")]
713 ;; we have got to provide a movdi alternative that will go from 
714 ;; register to memory & back in its full glory.  However, we try to 
715 ;; discourage its use by listing this alternative last.
716 ;; The problem is that the instructions above only provide 
717 ;; S-form style (base + displacement) mem access, while the
718 ;; below provvides the full (base+index+displacement) RX-form.
719 ;; These are rarely needed, but when needed they're needed.
721 (define_insn ""
722   [(set (match_operand:DI 0 "general_operand" "=d,???m")
723         (match_operand:DI 1 "general_operand" "???m,d"))]
725   ""
726   "*
728   check_label_emit ();
729   if (REG_P (operands[0]))
730     {
731       mvs_check_page (0, 8, 0);
732       return \"LM       %0,%N0,%1\";
733     }
734   else if (REG_P (operands[1]))
735     {
736       mvs_check_page (0, 8, 0);
737       return \"STM      %1,%N1,%0\";
738     }
739   mvs_check_page (0, 6, 0);
740   return \"MVC  %O0(8,%R0),%1\";
742    [(set_attr "length" "8")]
746 ; movsi instruction pattern(s).
749 (define_insn ""
750 ;;  [(set (match_operand:SI 0 "r_or_s_operand" "=dm,d,dm")
751 ;;        (match_operand:SI 1 "r_or_s_operand" "diR,dim,*fF"))]
752   [(set (match_operand:SI 0 "r_or_s_operand" "=d,dS,dm")
753         (match_operand:SI 1 "general_operand" "dim,diS,di*fF"))]
755   "TARGET_CHAR_INSTRUCTIONS"
756   "*
758   check_label_emit ();
759   if (REG_P (operands[0]))
760     {
761       if (FP_REG_P (operands[1]))
762         {
763           mvs_check_page (0, 8, 0);
764           return \"STE  %1,140(,13)\;L  %0,140(,13)\";
765         }
766       if (REG_P (operands[1]))
767         {
768           mvs_check_page (0, 2, 0);
769           return \"LR   %0,%1\";
770         }
771       if (operands[1] == const0_rtx)
772         {
773           CC_STATUS_INIT;
774           mvs_check_page (0, 2, 0);
775           return \"SLR  %0,%0\";
776         }
777       if (GET_CODE (operands[1]) == CONST_INT
778           && (unsigned) INTVAL (operands[1]) < 4096)
779         {
780           mvs_check_page (0, 4, 0);
781           return \"LA   %0,%c1(0,0)\";
782         }
783       mvs_check_page (0, 4, 0);
784       return \"L        %0,%1\";
785     }
786   else if (FP_REG_P (operands[1]))
787     {
788       mvs_check_page (0, 4, 0);
789       return \"STE      %1,%0\";
790     }
791   else if (REG_P (operands[1]))
792     {
793       mvs_check_page (0, 4, 0);
794       return \"ST       %1,%0\";
795     }
796   mvs_check_page (0, 6, 0);
797   return \"MVC  %O0(4,%R0),%1\";
799    [(set_attr "length" "8")]
802 (define_insn "movsi"
803   [(set (match_operand:SI 0 "general_operand" "=d,dm")
804         (match_operand:SI 1 "general_operand" "dimF,*fd"))]
805   ""
806   "*
808   check_label_emit ();
809   if (REG_P (operands[0]))
810     {
811       if (FP_REG_P (operands[1]))
812         {
813           mvs_check_page (0, 8, 0);
814           return \"STE  %1,140(,13)\;L  %0,140(,13)\";
815         }
816       if (REG_P (operands[1]))
817         {
818           mvs_check_page (0, 2, 0);
819           return \"LR   %0,%1\";
820         }
821       if (operands[1] == const0_rtx)
822         {
823           CC_STATUS_INIT;
824           mvs_check_page (0, 2, 0);
825           return \"SLR  %0,%0\";
826         }
827       if (GET_CODE (operands[1]) == CONST_INT
828           && (unsigned) INTVAL (operands[1]) < 4096)
829         {
830           mvs_check_page (0, 4, 0);
831           return \"LA   %0,%c1(0,0)\";
832         }
833       mvs_check_page (0, 4, 0);
834       return \"L        %0,%1\";
835     }
836   else if (FP_REG_P (operands[1]))
837     {
838       mvs_check_page (0, 4, 0);
839       return \"STE      %1,%0\";
840     }
841   mvs_check_page (0, 4, 0);
842   return \"ST   %1,%0\";
844    [(set_attr "length" "8")]
847 ;(define_expand "movsi"
848 ;  [(set (match_operand:SI 0 "general_operand" "=d,dm")
849 ;       (match_operand:SI 1 "general_operand" "dimF,*fd"))]
850 ;  ""
851 ;  "
853 ;  rtx op0, op1;
855 ;  op0 = operands[0];
856 ;  if (GET_CODE (op0) == CONST
857 ;      && GET_CODE (XEXP (XEXP (op0, 0), 0)) == SYMBOL_REF
858 ;      && SYMBOL_REF_FLAG (XEXP (XEXP (op0, 0), 0)))
859 ;    {
860 ;      op0 = gen_rtx_MEM (SImode, copy_to_mode_reg (SImode, XEXP (op0, 0)));
861 ;    }
863 ;  op1 = operands[1];
864 ;  if (GET_CODE (op1) == CONST
865 ;      && GET_CODE (XEXP (XEXP (op1, 0), 0)) == SYMBOL_REF
866 ;      && SYMBOL_REF_FLAG (XEXP (XEXP (op1, 0), 0)))
867 ;    {
868 ;      op1 = gen_rtx_MEM (SImode, copy_to_mode_reg (SImode, XEXP (op1, 0)));
869 ;    }
871 ;  emit_insn (gen_rtx_SET (VOIDmode, op0, op1));
872 ;  DONE;
873 ;}")
876 ; movhi instruction pattern(s).
879 (define_insn ""
880   [(set (match_operand:HI 0 "r_or_s_operand" "=g")
881         (match_operand:HI 1 "r_or_s_operand" "g"))]
882   "TARGET_CHAR_INSTRUCTIONS"
883   "*
885   check_label_emit ();
886   if (REG_P (operands[0]))
887     {
888       if (REG_P (operands[1]))
889         {
890           mvs_check_page (0, 2, 0);
891           return \"LR   %0,%1\";
892         }
893       if (operands[1] == const0_rtx)
894         {
895           CC_STATUS_INIT;
896           mvs_check_page (0, 2, 0);
897           return \"SLR  %0,%0\";
898         }
899       if (GET_CODE (operands[1]) == CONST_INT
900           && (unsigned) INTVAL (operands[1]) < 4096)
901         {
902           mvs_check_page (0, 4, 0);
903           return \"LA   %0,%c1(0,0)\";
904         }
905       if (GET_CODE (operands[1]) == CONST_INT)
906         {
907           mvs_check_page (0, 4, 0);
908           return \"LH   %0,%H1\";
909         }
910       mvs_check_page (0, 4, 0);
911       return \"LH       %0,%1\";
912     }
913   else if (REG_P (operands[1]))
914     {
915       mvs_check_page (0, 4, 0);
916       return \"STH      %1,%0\";
917     }
918   if (GET_CODE (operands[1]) == CONST_INT)
919     {
920       mvs_check_page (0, 6, 0);
921       return \"MVC      %O0(2,%R0),%H1\";
922     }
923   mvs_check_page (0, 6, 0);
924   return \"MVC  %O0(2,%R0),%1\";
926    [(set_attr "length" "6")]
929 (define_insn "movhi"
930   [(set (match_operand:HI 0 "general_operand" "=d,m")
931         (match_operand:HI 1 "general_operand" "g,d"))]
932   ""
933   "*
935   check_label_emit ();
936   if (REG_P (operands[0]))
937     {
938       if (REG_P (operands[1]))
939         {
940           mvs_check_page (0, 2, 0);
941           return \"LR   %0,%1\";
942         }
943       if (operands[1] == const0_rtx)
944         {
945           CC_STATUS_INIT;
946           mvs_check_page (0, 2, 0);
947           return \"SLR  %0,%0\";
948         }
949       if (GET_CODE (operands[1]) == CONST_INT
950           && (unsigned) INTVAL (operands[1]) < 4096)
951         {
952           mvs_check_page (0, 4, 0);
953           return \"LA   %0,%c1(0,0)\";
954         }
955       if (GET_CODE (operands[1]) == CONST_INT)
956         {
957           mvs_check_page (0, 4, 0);
958           return \"LH   %0,%H1\";
959         }
960       mvs_check_page (0, 4, 0);
961       return \"LH       %0,%1\";
962     }
963   mvs_check_page (0, 4, 0);
964   return \"STH  %1,%0\";
966    [(set_attr "length" "4")]
970 ; movqi instruction pattern(s).
973 (define_insn ""
974   [(set (match_operand:QI 0 "r_or_s_operand" "=g")
975         (match_operand:QI 1 "r_or_s_operand" "g"))]
976   "TARGET_CHAR_INSTRUCTIONS"
977   "*
979   check_label_emit ();
980   if (REG_P (operands[0]))
981     {
982       if (REG_P (operands[1]))
983         {
984           mvs_check_page (0, 2, 0);
985           return \"LR   %0,%1\";
986         }
987       if (operands[1] == const0_rtx)
988         {
989           CC_STATUS_INIT;
990           mvs_check_page (0, 2, 0);
991           return \"SLR  %0,%0\";
992         }
993       if (GET_CODE (operands[1]) == CONST_INT)
994         {
995           if ((INTVAL (operands[1]) >= 0)
996               && (unsigned) INTVAL (operands[1]) < 4096)
997             {
998               mvs_check_page (0, 4, 0);
999               return \"LA       %0,%c1(0,0)\";
1000             }
1001           mvs_check_page (0, 4, 0);
1002           return \"L    %0,=F'%c1'\";
1003         }
1004       mvs_check_page (0, 4, 0);
1005       return \"IC       %0,%1\";
1006     }
1007   else if (REG_P (operands[1]))
1008     {
1009       mvs_check_page (0, 4, 0);
1010       return \"STC      %1,%0\";
1011     }
1012   else if (GET_CODE (operands[1]) == CONST_INT)
1013     {
1014       mvs_check_page (0, 4, 0);
1015       return \"MVI      %0,%B1\";
1016     }
1017   mvs_check_page (0, 6, 0);
1018   return \"MVC  %O0(1,%R0),%1\";
1020    [(set_attr "length" "6")]
1023 (define_insn "movqi"
1024   [(set (match_operand:QI 0 "general_operand" "=d,m")
1025         (match_operand:QI 1 "general_operand" "g,d"))]
1026   ""
1027   "*
1029   check_label_emit ();
1030   if (REG_P (operands[0]))
1031     {
1032       if (REG_P (operands[1]))
1033         {
1034           mvs_check_page (0, 2, 0);
1035           return \"LR   %0,%1\";
1036         }
1037       if (operands[1] == const0_rtx)
1038         {
1039           CC_STATUS_INIT;
1040           mvs_check_page (0, 2, 0);
1041           return \"SLR  %0,%0\";
1042         }
1043       if (GET_CODE (operands[1]) == CONST_INT)
1044         {
1045           if ((INTVAL (operands[1]) >= 0)
1046               && (unsigned) INTVAL (operands[1]) < 4096)
1047             {
1048               mvs_check_page (0, 4, 0);
1049               return \"LA       %0,%c1(0,0)\";
1050             }
1051           mvs_check_page (0, 4, 0);
1052           return \"L    %0,=F'%c1'\";
1053         }
1054       mvs_check_page (0, 4, 0);
1055       return \"IC       %0,%1\";
1056     }
1057   mvs_check_page (0, 4, 0);
1058   return \"STC  %1,%0\";
1060    [(set_attr "length" "4")]
1064 ; movstrictqi instruction pattern(s).
1067 (define_insn "movstrictqi"
1068   [(set (strict_low_part (match_operand:QI 0 "general_operand" "+d"))
1069         (match_operand:QI 1 "general_operand" "g"))]
1070   ""
1071   "*
1073   check_label_emit ();
1074   if (REG_P (operands[1]))
1075     {
1076       mvs_check_page (0, 8, 0);
1077       return \"STC      %1,140(,13)\;IC %0,140(,13)\";
1078     }
1079   mvs_check_page (0, 4, 0);
1080   return \"IC   %0,%1\";
1082    [(set_attr "length" "8")]
1086 ; movstricthi instruction pattern(s).
1089 (define_insn ""
1090   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
1091         (match_operand:HI 1 "r_or_s_operand" "g"))]
1092   ""
1093   "*
1095   check_label_emit ();
1096   if (REG_P (operands[1]))
1097     {
1098       mvs_check_page (0, 8, 0);
1099       return \"STH      %1,140(,13)\;ICM        %0,3,140(13)\";
1100     }
1101   else if (GET_CODE (operands[1]) == CONST_INT)
1102     {
1103       mvs_check_page (0, 4, 0);
1104       return \"ICM      %0,3,%H1\";
1105     }
1106   mvs_check_page (0, 4, 0);
1107   return \"ICM  %0,3,%1\";
1109    [(set_attr "length" "8")]
1112 (define_insn "movstricthi"
1113   [(set (strict_low_part (match_operand:HI 0 "general_operand" "+dm"))
1114         (match_operand:HI 1 "general_operand" "d"))]
1115   ""
1116   "*
1118   check_label_emit ();
1119   if (REG_P (operands[0]))
1120     {
1121       mvs_check_page (0, 8, 0);
1122       return \"STH      %1,140(,13)\;ICM        %0,3,140(13)\";
1123     }
1124   mvs_check_page (0, 4, 0);
1125   return \"STH  %1,%0\";
1127    [(set_attr "length" "8")]
1131 ; movdf instruction pattern(s).
1134 (define_insn ""
1135 ;;  [(set (match_operand:DF 0 "r_or_s_operand" "=fm,fm,*dm")
1136 ;;        (match_operand:DF 1 "r_or_s_operand" "fmF,*dm,fmF"))]
1137   [(set (match_operand:DF 0 "general_operand" "=f,m,fS,*dS,???d")
1138       (match_operand:DF 1 "general_operand" "fmF,fF,*dS,fSF,???d"))]
1140   "TARGET_CHAR_INSTRUCTIONS"
1141   "*
1143   check_label_emit ();
1144   if (FP_REG_P (operands[0]))
1145     {
1146       if (FP_REG_P (operands[1]))
1147         {
1148           mvs_check_page (0, 2, 0);
1149           return \"LDR  %0,%1\";
1150         }
1151       if (REG_P (operands[1]))
1152         {
1153           mvs_check_page (0, 8, 0);
1154           return \"STM  %1,%N1,140(13)\;LD      %0,140(,13)\";
1155         }
1156       if (operands[1] == const0_rtx)
1157         {
1158           CC_STATUS_SET (operands[0], operands[1]);
1159           mvs_check_page (0, 2, 0);
1160           return \"SDR  %0,%0\";
1161         }
1162       mvs_check_page (0, 4, 0);
1163       return \"LD       %0,%1\";
1164     }
1165   if (REG_P (operands[0]))
1166     {
1167       if (FP_REG_P (operands[1]))
1168         {
1169           mvs_check_page (0, 12, 0);
1170           return \"STD  %1,140(,13)\;LM %0,%N0,140(13)\";
1171         }
1172       if (REG_P (operands[1]))
1173         {
1174           mvs_check_page (0, 4, 0);
1175           return \"LR   %0,%1\;LR       %N0,%N1\";
1176         }
1177       mvs_check_page (0, 4, 0);
1178       return \"LM       %0,%N0,%1\";
1179     }
1180   else if (FP_REG_P (operands[1]))
1181     {
1182       mvs_check_page (0, 4, 0);
1183       return \"STD      %1,%0\";
1184     }
1185   else if (REG_P (operands[1]))
1186     {
1187       mvs_check_page (0, 4, 0);
1188       return \"STM      %1,%N1,%0\";
1189     }
1190   mvs_check_page (0, 6, 0);
1191   return \"MVC  %O0(8,%R0),%1\";
1193    [(set_attr "length" "12")]
1196 (define_insn "movdf"
1197 ;;  [(set (match_operand:DF 0 "general_operand" "=f,fm,m,*d")
1198 ;;      (match_operand:DF 1 "general_operand" "fmF,*d,f,fmF"))]
1199   [(set (match_operand:DF 0 "general_operand" "=f,m,fS,*d,???d")
1200       (match_operand:DF 1 "general_operand" "fmF,f,*d,SfF,???d"))]
1202   ""
1203   "*
1205   check_label_emit ();
1206   if (FP_REG_P (operands[0]))
1207     {
1208       if (FP_REG_P (operands[1]))
1209         {
1210           mvs_check_page (0, 2, 0);
1211           return \"LDR  %0,%1\";
1212         }
1213       if (REG_P (operands[1]))
1214         {
1215           mvs_check_page (0, 8, 0);
1216           return \"STM  %1,%N1,140(13)\;LD      %0,140(,13)\";
1217         }
1218       if (operands[1] == const0_rtx)
1219         {
1220           CC_STATUS_SET (operands[0], operands[1]);
1221           mvs_check_page (0, 2, 0);
1222           return \"SDR  %0,%0\";
1223         }
1224       mvs_check_page (0, 4, 0);
1225       return \"LD       %0,%1\";
1226     }
1227   else if (REG_P (operands[0]))
1228     {
1229       if (FP_REG_P (operands[1]))
1230         {
1231           mvs_check_page (0, 12, 0);
1232           return \"STD  %1,140(,13)\;LM %0,%N0,140(13)\";
1233         }
1234       if (REG_P (operands[1]))
1235         {
1236           mvs_check_page (0, 4, 0);
1237           return \"LR   %0,%1\;LR       %N0,%N1\";
1238         }
1239       mvs_check_page (0, 4, 0);
1240       return \"LM       %0,%N0,%1\";
1241     }
1242   else if (FP_REG_P (operands[1]))
1243     {
1244       mvs_check_page (0, 4, 0);
1245       return \"STD      %1,%0\";
1246     }
1247   mvs_check_page (0, 4, 0);
1248   return \"STM  %1,%N1,%0\";
1250    [(set_attr "length" "12")]
1254 ; movsf instruction pattern(s).
1257 (define_insn ""
1258 ;;  [(set (match_operand:SF 0 "r_or_s_operand" "=fm,fm,*dm")
1259 ;;        (match_operand:SF 1 "r_or_s_operand" "fmF,*dm,fmF"))]
1260 ;;  [(set (match_operand:SF 0 "general_operand" "=f,m,fm,*d,S")
1261 ;;         (match_operand:SF 1 "general_operand" "fmF,fF,*d,fmF,S"))]
1262   [(set (match_operand:SF 0 "general_operand" "=f*d,fm,S,???d")
1263         (match_operand:SF 1 "general_operand" "fmF,fF*d,S,???d"))]
1265   "TARGET_CHAR_INSTRUCTIONS"
1266   "*
1268   check_label_emit ();
1269   if (FP_REG_P (operands[0]))
1270     {
1271       if (FP_REG_P (operands[1]))
1272         {
1273           mvs_check_page (0, 2, 0);
1274           return \"LER  %0,%1\";
1275         }
1276       if (REG_P (operands[1]))
1277         {
1278           mvs_check_page (0, 8, 0);
1279           return \"ST   %1,140(,13)\;LE %0,140(,13)\";
1280         }
1281       if (operands[1] == const0_rtx)
1282         {
1283           CC_STATUS_SET (operands[0], operands[1]);
1284           mvs_check_page (0, 2, 0);
1285           return \"SER  %0,%0\";
1286         }
1287       mvs_check_page (0, 4, 0);
1288       return \"LE       %0,%1\";
1289     }
1290   else if (REG_P (operands[0]))
1291     {
1292       if (FP_REG_P (operands[1]))
1293         {
1294           mvs_check_page (0, 8, 0);
1295           return \"STE  %1,140(,13)\;L  %0,140(,13)\";
1296         }
1297       if (REG_P (operands[1]))
1298         {
1299           mvs_check_page (0, 2, 0);
1300           return \"LR   %0,%1\";
1301         }
1302       mvs_check_page (0, 4, 0);
1303       return \"L        %0,%1\";
1304     }
1305   else if (FP_REG_P (operands[1]))
1306     {
1307       mvs_check_page (0, 4, 0);
1308       return \"STE      %1,%0\";
1309     }
1310   else if (REG_P (operands[1]))
1311     {
1312       mvs_check_page (0, 4, 0);
1313       return \"ST       %1,%0\";
1314     }
1315   mvs_check_page (0, 6, 0);
1316   return \"MVC  %O0(4,%R0),%1\";
1318    [(set_attr "length" "8")]
1321 (define_insn "movsf"
1322   [(set (match_operand:SF 0 "general_operand" "=f,fm,m,*d")
1323         (match_operand:SF 1 "general_operand" "fmF,*d,f,fmF"))]
1324   ""
1325   "*
1327   check_label_emit ();
1328   if (FP_REG_P (operands[0]))
1329     {
1330       if (FP_REG_P (operands[1]))
1331         {
1332           mvs_check_page (0, 2, 0);
1333           return \"LER  %0,%1\";
1334         }
1335       if (REG_P (operands[1]))
1336         {
1337           mvs_check_page (0, 8, 0);
1338           return \"ST   %1,140(,13)\;LE %0,140(,13)\";
1339         }
1340       if (operands[1] == const0_rtx)
1341         {
1342           CC_STATUS_SET (operands[0], operands[1]);
1343           mvs_check_page (0, 2, 0);
1344           return \"SER  %0,%0\";
1345         }
1346       mvs_check_page (0, 4, 0);
1347       return \"LE       %0,%1\";
1348     }
1349   else if (REG_P (operands[0]))
1350     {
1351       if (FP_REG_P (operands[1]))
1352         {
1353           mvs_check_page (0, 8, 0);
1354           return \"STE  %1,140(,13)\;L  %0,140(,13)\";
1355         }
1356       mvs_check_page (0, 4, 0);
1357       return \"L        %0,%1\";
1358     }
1359   else if (FP_REG_P (operands[1]))
1360     {
1361       mvs_check_page (0, 4, 0);
1362       return \"STE      %1,%0\";
1363     }
1364   mvs_check_page (0, 4, 0);
1365   return \"ST   %1,%0\";
1367    [(set_attr "length" "8")]
1371 ; clrstrsi instruction pattern(s).
1372 ; memset a block of bytes to zero.
1373 ; block must be less than 16M (24 bits) in length
1375 (define_expand "clrstrsi"
1376   [(set (match_operand:BLK 0 "general_operand" "g")
1377         (const_int 0)) 
1378    (use (match_operand:SI  1 "general_operand" ""))
1379    (match_operand 2 "" "")]
1380    ""
1381    "
1384   XXX bogus, i think, unless change_address has a side effet we need
1385   rtx op0;
1387   op0 = XEXP (operands[0], 0);
1388   if (GET_CODE (op0) == REG
1389       || (GET_CODE (op0) == PLUS && GET_CODE (XEXP (op0, 0)) == REG
1390           && GET_CODE (XEXP (op0, 1)) == CONST_INT
1391           && (unsigned) INTVAL (XEXP (op0, 1)) < 4096))
1392     op0 = operands[0];
1393   else
1394     op0 = change_address (operands[0], VOIDmode,
1395                           copy_to_mode_reg (SImode, op0));
1398   {
1399         /* implementation suggested by  Richard Henderson <rth@cygnus.com> */
1400         rtx reg1 = gen_reg_rtx (DImode);
1401         rtx reg2 = gen_reg_rtx (DImode);
1402         rtx mem1 = operands[0];
1403         rtx zippo = gen_rtx_CONST_INT (SImode, 0);
1404         rtx len = operands[1];
1405         if (!CONSTANT_P (len))
1406           len = force_reg (SImode, len);
1408         /* Load up the address+length pairs.  */
1409         emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
1410         emit_move_insn (gen_rtx_SUBREG (SImode, reg1, 0),
1411                         force_operand (XEXP (mem1, 0), NULL_RTX));
1412         emit_move_insn (gen_rtx_SUBREG (SImode, reg1, 1), len);
1414         emit_insn (gen_rtx_CLOBBER (VOIDmode, reg2));
1415         emit_move_insn (gen_rtx_SUBREG (SImode, reg2, 0), zippo);
1416         emit_move_insn (gen_rtx_SUBREG (SImode, reg2, 1), zippo);
1418         /* Copy! */
1419         emit_insn (gen_movstrsi_1 (reg1, reg2));
1420   }
1421   DONE;
1425 ; movstrsi instruction pattern(s).
1426 ; block must be less than 16M (24 bits) in length
1428 (define_expand "movstrsi"
1429   [(set (match_operand:BLK 0 "general_operand" "")
1430         (match_operand:BLK 1 "general_operand" ""))
1431    (use (match_operand:SI  2 "general_operand" ""))
1432    (match_operand 3 "" "")]
1433    ""
1434    "
1436   rtx op0, op1;
1438   op0 = XEXP (operands[0], 0);
1439   if (GET_CODE (op0) == REG
1440       || (GET_CODE (op0) == PLUS && GET_CODE (XEXP (op0, 0)) == REG
1441           && GET_CODE (XEXP (op0, 1)) == CONST_INT
1442           && (unsigned) INTVAL (XEXP (op0, 1)) < 4096))
1443     op0 = operands[0];
1444   else
1445     op0 = change_address (operands[0], VOIDmode,
1446                           copy_to_mode_reg (SImode, op0));
1448   op1 = XEXP (operands[1], 0);
1449   if (GET_CODE (op1) == REG
1450       || (GET_CODE (op1) == PLUS && GET_CODE (XEXP (op1, 0)) == REG
1451           && GET_CODE (XEXP (op1, 1)) == CONST_INT
1452           && (unsigned) INTVAL (XEXP (op1, 1)) < 4096))
1453     op1 = operands[1];
1454   else
1455     op1 = change_address (operands[1], VOIDmode,
1456                           copy_to_mode_reg (SImode, op1));
1458   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 256)
1459     emit_insn (gen_rtx_PARALLEL (VOIDmode,
1460                         gen_rtvec (2,
1461                                    gen_rtx_SET (VOIDmode, op0, op1),
1462                                    gen_rtx_USE (VOIDmode, operands[2]))));
1464   else
1465     {
1466         /* implementation provided by  Richard Henderson <rth@cygnus.com> */
1467         rtx reg1 = gen_reg_rtx (DImode);
1468         rtx reg2 = gen_reg_rtx (DImode);
1469         rtx mem1 = operands[0];
1470         rtx mem2 = operands[1];
1471         rtx len = operands[2];
1472         if (!CONSTANT_P (len))
1473           len = force_reg (SImode, len);
1475         /* Load up the address+length pairs.  */
1476         emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
1477         emit_move_insn (gen_rtx_SUBREG (SImode, reg1, 0),
1478                         force_operand (XEXP (mem1, 0), NULL_RTX));
1479         emit_move_insn (gen_rtx_SUBREG (SImode, reg1, 1), len);
1481         emit_insn (gen_rtx_CLOBBER (VOIDmode, reg2));
1482         emit_move_insn (gen_rtx_SUBREG (SImode, reg2, 0),
1483                         force_operand (XEXP (mem2, 0), NULL_RTX));
1484         emit_move_insn (gen_rtx_SUBREG (SImode, reg2, 1), len);
1486         /* Copy! */
1487         emit_insn (gen_movstrsi_1 (reg1, reg2));
1488     }
1489   DONE;
1492 ; Move a block that is less than 256 bytes in length.
1494 (define_insn ""
1495   [(set (match_operand:BLK 0 "s_operand" "=m")
1496         (match_operand:BLK 1 "s_operand" "m"))
1497    (use (match_operand 2 "immediate_operand" "I"))]
1498   "((unsigned) INTVAL (operands[2]) < 256)"
1499   "*
1501   check_label_emit ();
1502   mvs_check_page (0, 6, 0);
1503   return \"MVC  %O0(%c2,%R0),%1\";
1505    [(set_attr "length" "6")]
1508 ; Move a block that is larger than 255 bytes in length.
1510 (define_insn "movstrsi_1"
1511   [(set (mem:BLK (subreg:SI (match_operand:DI 0 "register_operand" "+d") 0))
1512         (mem:BLK (subreg:SI (match_operand:DI 1 "register_operand" "+d") 0)))
1513    (use (match_dup 0))
1514    (use (match_dup 1))
1515    (clobber (match_dup 0))
1516    (clobber (match_dup 1))]
1517   ""
1518   "*
1520   check_label_emit ();
1521   mvs_check_page (0, 2, 0);
1522   return \"MVCL %0,%1\";
1524    [(set_attr "length" "2")]
1528 ;;- Conversion instructions.
1532 ; extendsidi2 instruction pattern(s).
1535 (define_expand "extendsidi2"
1536   [(set (match_operand:DI 0 "register_operand" "=d")
1537         (sign_extend:DI (match_operand:SI 1 "general_operand" "")))]
1538   ""
1539   "
1541   if (GET_CODE (operands[1]) != CONST_INT)
1542     {
1543       emit_insn (gen_rtx_SET (VOIDmode,
1544                   operand_subword (operands[0], 0, 1, DImode), operands[1]));
1545       emit_insn (gen_rtx_SET (VOIDmode, operands[0],
1546                         gen_rtx_ASHIFTRT (DImode, operands[0],
1547                                 gen_rtx_CONST_INT (SImode, 32))));
1548     }
1549   else
1550     {
1551       if (INTVAL (operands[1]) < 0)
1552         {
1553           emit_insn (gen_rtx_SET (VOIDmode,
1554                                   operand_subword (operands[0], 0, 1, DImode),
1555                                gen_rtx_CONST_INT (SImode, -1)));
1556         }
1557       else
1558         {
1559           emit_insn (gen_rtx_SET (VOIDmode,
1560                                 operand_subword (operands[0], 0, 1, DImode),
1561                                gen_rtx_CONST_INT (SImode, 0)));
1562         }
1563       emit_insn (gen_rtx_SET (VOIDmode, gen_lowpart (SImode, operands[0]),
1564                            operands[1]));
1565     }
1566   DONE;
1570 ; extendhisi2 instruction pattern(s).
1573 (define_insn "extendhisi2"
1574   [(set (match_operand:SI 0 "general_operand" "=d,m")
1575         (sign_extend:SI (match_operand:HI 1 "general_operand" "g,d")))]
1576   ""
1577   "*
1579   check_label_emit ();
1580   if (REG_P (operands[0]))
1581     {
1582       if (REG_P (operands[1]))
1583       {
1584         if (REGNO (operands[0]) != REGNO (operands[1]))
1585           {
1586             mvs_check_page (0, 10, 0);
1587             return \"LR %0,%1\;SLL      %0,16\;SRA      %0,16\";
1588           }
1589         else
1590           return \"\"; /* Should be empty.  16-bits regs are always 32-bits.  */
1591       }
1592       if (operands[1] == const0_rtx)
1593         {
1594           CC_STATUS_INIT;
1595           mvs_check_page (0, 2, 0);
1596           return \"SLR  %0,%0\";
1597         }
1598       if (GET_CODE (operands[1]) == CONST_INT
1599           && (unsigned) INTVAL (operands[1]) < 4096)
1600         {
1601           mvs_check_page (0, 4, 0);
1602           return \"LA   %0,%c1(0,0)\";
1603         }
1604       if (GET_CODE (operands[1]) == CONST_INT)
1605         {
1606           mvs_check_page (0, 4, 0);
1607           return \"LH   %0,%H1\";
1608         }
1609       mvs_check_page (0, 4, 0);
1610       return \"LH       %0,%1\";
1611     }
1612   mvs_check_page (0, 12, 0);
1613   return \"SLL  %1,16\;SRA      %1,16\;ST       %1,%0\";
1615    [(set_attr "length" "12")]
1619 ; extendqisi2 instruction pattern(s).
1622 (define_insn "extendqisi2"
1623   [(set (match_operand:SI 0 "general_operand" "=d")
1624         (sign_extend:SI (match_operand:QI 1 "general_operand" "0mi")))]
1625   ""
1626   "*
1628   check_label_emit ();
1629   CC_STATUS_SET (operands[0], operands[1]);
1630   if (REG_P (operands[1]))
1631     {
1632       mvs_check_page (0, 8, 0);
1633       return \"SLL      %0,24\;SRA      %0,24\";
1634     }
1635   if (s_operand (operands[1], GET_MODE (operands[1])))
1636     {
1637       mvs_check_page (0, 8, 0);
1638       return \"ICM      %0,8,%1\;SRA    %0,24\";
1639     }
1640   mvs_check_page (0, 12, 0);
1641   return \"IC   %0,%1\;SLL      %0,24\;SRA      %0,24\";
1643    [(set_attr "length" "12")]
1647 ; extendqihi2 instruction pattern(s).
1650 (define_insn "extendqihi2"
1651   [(set (match_operand:HI 0 "general_operand" "=d")
1652         (sign_extend:HI (match_operand:QI 1 "general_operand" "0m")))]
1653   ""
1654   "*
1656   check_label_emit ();
1657   CC_STATUS_SET (operands[0], operands[1]);
1658   if (REG_P (operands[1]))
1659     {
1660       mvs_check_page (0, 8, 0);
1661       return \"SLL      %0,24\;SRA      %0,24\";
1662     }
1663   if (s_operand (operands[1], GET_MODE (operands[1])))
1664     {
1665       mvs_check_page (0, 8, 0);
1666       return \"ICM      %0,8,%1\;SRA    %0,24\";
1667     }
1668   mvs_check_page (0, 12, 0);
1669   return \"IC   %0,%1\;SLL      %0,24\;SRA      %0,24\";
1671    [(set_attr "length" "12")]
1675 ; zero_extendsidi2 instruction pattern(s).
1678 (define_expand "zero_extendsidi2"
1679   [(set (match_operand:DI 0 "register_operand" "=d")
1680         (zero_extend:DI (match_operand:SI 1 "general_operand" "")))]
1681   ""
1682   "
1684       emit_insn (gen_rtx_SET (VOIDmode,
1685                   operand_subword (operands[0], 0, 1, DImode), operands[1]));
1686       emit_insn (gen_rtx_SET (VOIDmode, operands[0],
1687                         gen_rtx_LSHIFTRT (DImode, operands[0],
1688                                 gen_rtx_CONST_INT (SImode, 32))));
1689   DONE;
1693 ; zero_extendhisi2 instruction pattern(s).
1696 (define_insn "zero_extendhisi2"
1697   [(set (match_operand:SI 0 "general_operand" "=d")
1698         (zero_extend:SI (match_operand:HI 1 "general_operand" "0")))]
1699   ""
1700   "*
1702   check_label_emit ();
1703   /* AND only sets zero/not-zero bits not the arithmetic bits ... */
1704   CC_STATUS_INIT;
1705   mvs_check_page (0, 4, 4);
1706   return \"N    %1,=XL4'0000FFFF'\";
1708    [(set_attr "length" "4")]
1712 ; zero_extendqisi2 instruction pattern(s).
1715 (define_insn "zero_extendqisi2"
1716   [(set (match_operand:SI 0 "general_operand" "=d,&d")
1717         (zero_extend:SI (match_operand:QI 1 "general_operand" "0i,m")))]
1718   ""
1719   "*
1721   check_label_emit ();
1722   if (REG_P (operands[1]))
1723     {
1724       /* AND only sets zero/not-zero bits not the arithmetic bits ... */
1725       CC_STATUS_INIT;
1726       mvs_check_page (0, 4, 4);
1727       return \"N        %0,=XL4'000000FF'\";
1728     }
1729   if (GET_CODE (operands[1]) == CONST_INT)
1730     {
1731       mvs_check_page (0, 4, 0);
1732       return \"LA       %0,%c1(0,0)\";
1733     }
1734   CC_STATUS_INIT;
1735   mvs_check_page (0, 8, 0);
1736   return \"SLR  %0,%0\;IC       %0,%1\";
1738    [(set_attr "length" "8")]
1742 ; zero_extendqihi2 instruction pattern(s).
1745 (define_insn "zero_extendqihi2"
1746   [(set (match_operand:HI 0 "general_operand" "=d,&d")
1747         (zero_extend:HI (match_operand:QI 1 "general_operand" "0i,m")))]
1748   ""
1749   "*
1751   check_label_emit ();
1752   if (REG_P (operands[1]))
1753     {
1754       /* AND only sets zero/not-zero bits not the arithmetic bits ... */
1755       CC_STATUS_INIT;
1756       mvs_check_page (0, 4, 4);
1757       return \"N        %0,=XL4'000000FF'\";
1758     }
1759   if (GET_CODE (operands[1]) == CONST_INT)
1760     {
1761       mvs_check_page (0, 4, 0);
1762       return \"LA       %0,%c1(0,0)\";
1763     }
1764   CC_STATUS_INIT;
1765   mvs_check_page (0, 8, 0);
1766   return \"SLR  %0,%0\;IC       %0,%1\";
1768    [(set_attr "length" "8")]
1772 ; truncsihi2 instruction pattern(s).
1775 (define_insn "truncsihi2"
1776   [(set (match_operand:HI 0 "general_operand" "=d,m")
1777         (truncate:HI (match_operand:SI 1 "general_operand" "0,d")))]
1778   ""
1779   "*
1781   check_label_emit ();
1782   if (REG_P (operands[0]))
1783     {
1784       CC_STATUS_SET (operands[0], operands[1]);
1785       mvs_check_page (0, 8, 0);
1786       return \"SLL      %0,16\;SRA      %0,16\";
1787     }
1788   mvs_check_page (0, 4, 0);
1789   return \"STH  %1,%0\";
1791    [(set_attr "length" "8")]
1795 ; fix_truncdfsi2 instruction pattern(s).
1798 (define_insn "fix_truncdfsi2"
1799   [(set (match_operand:SI 0 "general_operand" "=d")
1800         (fix:SI (truncate:DF (match_operand:DF 1 "general_operand" "+f"))))
1801         (clobber (reg:DF 16))]
1802   ""
1803   "*
1805   check_label_emit ();
1806   CC_STATUS_INIT;
1807   if (REGNO (operands[1]) == 16)
1808     {
1809       mvs_check_page (0, 12, 8);
1810       return \"AD       0,=XL8'4F08000000000000'\;STD   0,140(,13)\;L   %0,144(,13)\";
1811     }
1812   mvs_check_page (0, 14, 8);
1813   return \"LDR  0,%1\;AD        0,=XL8'4F08000000000000'\;STD   0,140(,13)\;L   %0,144(,13)\";
1815    [(set_attr "length" "14")]
1819 ; floatsidf2 instruction pattern(s).
1821 ; LE/370 mode uses the float field of the TCA.
1824 (define_insn "floatsidf2"
1825   [(set (match_operand:DF 0 "general_operand" "=f")
1826         (float:DF (match_operand:SI 1 "general_operand" "d")))]
1827   ""
1828   "*
1830   check_label_emit ();
1831   CC_STATUS_INIT;
1832 #ifdef TARGET_ELF_ABI
1833   mvs_check_page (0, 22, 12);
1834   return \"MVC  140(4,13),=XL4'4E000000'\;ST    %1,144(,13)\;XI 144(13),128\;LD %0,140(,13)\;SD %0,=XL8'4E00000080000000'\";
1835 #else
1836   mvs_check_page (0, 16, 8);
1837   return \"ST   %1,508(,12)\;XI 508(12),128\;LD %0,504(,12)\;SD %0,=XL8'4E00000080000000'\";
1838 #endif
1840    [(set_attr "length" "22")]
1844 ; truncdfsf2 instruction pattern(s).
1847 (define_insn "truncdfsf2"
1848   [(set (match_operand:SF 0 "general_operand" "=f")
1849         (float_truncate:SF (match_operand:DF 1 "general_operand" "f")))]
1850   ""
1851   "*
1853   check_label_emit ();
1854   mvs_check_page (0, 2, 0);
1855   return \"LRER %0,%1\";
1857    [(set_attr "length" "2")]
1861 ; extendsfdf2 instruction pattern(s).
1864 (define_insn "extendsfdf2"
1865   [(set (match_operand:DF 0 "general_operand" "=f")
1866         (float_extend:DF (match_operand:SF 1 "general_operand" "fmF")))]
1867   ""
1868   "*
1870   check_label_emit ();
1871   CC_STATUS_SET (0, const0_rtx);
1872   if (FP_REG_P (operands[1]))
1873     {
1874       if (REGNO (operands[0]) == REGNO (operands[1]))
1875         {
1876           mvs_check_page (0, 10, 0);
1877           return \"STE  %1,140(,13)\;SDR        %0,%0\;LE       %0,140(,13)\";
1878         }
1879       mvs_check_page (0, 4, 0);
1880       return \"SDR      %0,%0\;LER      %0,%1\";
1881     }
1882   mvs_check_page (0, 6, 0);
1883   return \"SDR  %0,%0\;LE       %0,%1\";
1885    [(set_attr "length" "10")]
1889 ;;- Add instructions.
1893 ; adddi3 instruction pattern(s).
1896 ;(define_expand "adddi3"
1897 ;  [(set (match_operand:DI 0 "general_operand" "")
1898 ;       (plus:DI (match_operand:DI 1 "general_operand" "")
1899 ;                (match_operand:DI 2 "general_operand" "")))]
1900 ;  ""
1901 ;  "
1903 ;  rtx label = gen_label_rtx ();
1904 ;  rtx op0_high = operand_subword (operands[0], 0, 1, DImode);
1905 ;  rtx op0_low = gen_lowpart (SImode, operands[0]);
1906 ;       
1907 ;  emit_insn (gen_rtx_SET (VOIDmode, op0_high,
1908 ;                   gen_rtx_PLUS (SImode,
1909 ;                           operand_subword (operands[1], 0, 1, DImode),
1910 ;                           operand_subword (operands[2], 0, 1, DImode))));
1911 ;  emit_jump_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2,
1912 ;             gen_rtx_SET (VOIDmode, op0_low,
1913 ;                     gen_rtx_PLUS (SImode, gen_lowpart (SImode, operands[1]),
1914 ;                             gen_lowpart (SImode, operands[2]))),
1915 ;             gen_rtx_USE (VOIDmode, gen_rtx_LABEL_REF (VOIDmode, label)))));
1916 ;  emit_insn (gen_rtx_SET (VOIDmode, op0_high,
1917 ;                   gen_rtx_PLUS (SImode, op0_high,
1918 ;                           gen_rtx_CONST_INT (SImode, 1))));
1919 ;  emit_label (label);
1920 ;  DONE;
1921 ;}")
1923 (define_insn ""
1924   [(set (match_operand:SI 0 "general_operand" "=d")
1925         (plus:SI (match_operand:SI 1 "general_operand" "%0")
1926                  (match_operand:SI 2 "general_operand" "g")))
1927    (use (label_ref (match_operand 3 "" "")))
1928 ;   (clobber (reg:SI 14))
1929    ]
1930   ""
1931   "*
1933   int onpage;
1935   check_label_emit ();
1936   onpage = mvs_check_label (CODE_LABEL_NUMBER (operands[3]));
1937   if (REG_P (operands[2]))
1938     {
1939       if (!onpage)
1940         {
1941           mvs_check_page (0, 8, 4);
1942           return \"ALR  %0,%2\;L        14,=A(%l3)\;BCR 12,14\";
1943         }
1944       if (mvs_check_page (0, 6, 0))
1945         {
1946           mvs_check_page (0, 2, 4);
1947           return \"ALR  %0,%2\;L        14,=A(%l3)\;BCR 12,14\";
1948         }
1949       return \"ALR      %0,%2\;BC       12,%l3\";
1950     }
1951   if (!onpage)
1952     {
1953       mvs_check_page (0, 10, 4);
1954       return \"AL       %0,%2\;L        14,=A(%l3)\;BCR 12,14\";
1955     }
1956   if (mvs_check_page (0, 8 ,0))
1957     {
1958       mvs_check_page (0, 2, 4);
1959       return \"AL       %0,%2\;L        14,=A(%l3)\;BCR 12,14\";
1960     }
1961   return \"AL   %0,%2\;BC       12,%l3\";
1963    [(set_attr "length" "10")]
1967 ; addsi3 instruction pattern(s).
1969 ; The following insn is used when it is known that operand one is an address,
1970 ; frame, stack or argument pointer, and operand two is a constant that is
1971 ; small enough to fit in the displacement field.
1972 ; Notice that we can't allow the frame pointer to used as a normal register
1973 ; because of this insn.
1976 (define_insn ""
1977   [(set (match_operand:SI 0 "register_operand" "=d")
1978         (plus:SI (match_operand:SI 1 "general_operand" "%a")
1979                  (match_operand:SI 2 "immediate_operand" "J")))]
1980   "((REGNO (operands[1]) == FRAME_POINTER_REGNUM || REGNO (operands[1]) == ARG_POINTER_REGNUM || REGNO (operands[1]) == STACK_POINTER_REGNUM) && (unsigned) INTVAL (operands[2]) < 4096)"
1981   "*
1983   check_label_emit ();
1984   CC_STATUS_INIT;  /* add assumes CC but LA doesnt set CC */
1985   mvs_check_page (0, 4, 0);
1986   return \"LA   %0,%c2(,%1)\";
1988    [(set_attr "length" "4")]
1991 ; This insn handles additions that are relative to the frame pointer.
1993 (define_insn ""
1994   [(set (match_operand:SI 0 "register_operand" "=d")
1995          (plus:SI (match_operand:SI 1 "register_operand" "%a")
1996                   (match_operand:SI 2 "immediate_operand" "i")))]
1997   "REGNO (operands[1]) == FRAME_POINTER_REGNUM"
1998   "*
2000   check_label_emit ();
2001   if ((unsigned) INTVAL (operands[2]) < 4096)
2002     {
2003       CC_STATUS_INIT;  /* add assumes CC but LA doesnt set CC */
2004       mvs_check_page (0, 4, 0);
2005       return \"LA       %0,%c2(,%1)\";
2006     }
2007   if (REGNO (operands[1]) == REGNO (operands[0]))
2008     {
2009       CC_STATUS_INIT;
2010       mvs_check_page (0, 4, 0);
2011       return \"A        %0,%2\";
2012     }
2013   mvs_check_page (0, 6, 0);
2014   return \"L    %0,%2\;AR       %0,%1\";
2016    [(set_attr "length" "6")]
2020 ;; The CC status bits for the arithmetic instructions are handled
2021 ;; in the NOTICE_UPDATE_CC macro (yeah???) and so they do not need
2022 ;; to be set below.  They only need to be invalidated if *not* set 
2023 ;; (e.g. by BCTR) ... yeah I think that's right ...
2024 ;; 
2026 (define_insn "addsi3"
2027   [(set (match_operand:SI 0 "general_operand" "=d")
2028         (plus:SI (match_operand:SI 1 "general_operand" "%0")
2029                  (match_operand:SI 2 "general_operand" "g")))]
2030   ""
2031   "*
2033   check_label_emit ();
2034   if (REG_P (operands[2]))
2035     {
2036       mvs_check_page (0, 2, 0);
2037       return \"AR       %0,%2\";
2038     }
2039   if (GET_CODE (operands[2]) == CONST_INT)
2040     {
2041       if (INTVAL (operands[2]) == -1)
2042         {
2043           CC_STATUS_INIT;  /* add assumes CC but BCTR doesnt set CC */
2044           mvs_check_page (0, 2, 0);
2045           return \"BCTR %0,0\";
2046         }
2047     }
2048   mvs_check_page (0, 4, 0);
2049   return \"A    %0,%2\";
2051    [(set_attr "length" "4")]
2055 ; addhi3 instruction pattern(s).
2058 (define_insn "addhi3"
2059   [(set (match_operand:HI 0 "general_operand" "=d")
2060         (plus:HI (match_operand:HI 1 "general_operand" "%0")
2061                  (match_operand:HI 2 "general_operand" "dmi")))]
2062   ""
2063   "*
2065   check_label_emit ();
2066   if (REG_P (operands[2]))
2067     {
2068       mvs_check_page (0, 8, 0);
2069       return \"STH      %2,140(,13)\;AH %0,140(,13)\";
2070     }
2071   if (GET_CODE (operands[2]) == CONST_INT)
2072     {
2073       if (INTVAL (operands[2]) == -1)
2074         {
2075           CC_STATUS_INIT;  /* add assumes CC but BCTR doesnt set CC */
2076           mvs_check_page (0, 2, 0);
2077           return \"BCTR %0,0\";
2078         }
2079       mvs_check_page (0, 4, 0);
2080       return \"AH       %0,%H2\";
2081     }
2082   mvs_check_page (0, 4, 0);
2083   return \"AH   %0,%2\";
2085    [(set_attr "length" "8")]
2089 ; addqi3 instruction pattern(s).
2092 (define_insn "addqi3"
2093   [(set (match_operand:QI 0 "general_operand" "=d")
2094         (plus:QI (match_operand:QI 1 "general_operand" "%a")
2095                  (match_operand:QI 2 "general_operand" "ai")))]
2096   ""
2097   "*
2099   check_label_emit ();
2100   CC_STATUS_INIT;  /* add assumes CC but LA doesnt set CC */
2101   mvs_check_page (0, 4, 0);
2102   if (REG_P (operands[2]))
2103     return \"LA %0,0(%1,%2)\";
2104   return \"LA   %0,%B2(,%1)\";
2106    [(set_attr "length" "4")]
2110 ; adddf3 instruction pattern(s).
2113 (define_insn "adddf3"
2114   [(set (match_operand:DF 0 "general_operand" "=f")
2115         (plus:DF (match_operand:DF 1 "general_operand" "%0")
2116                  (match_operand:DF 2 "general_operand" "fmF")))]
2117   ""
2118   "*
2120   check_label_emit ();
2121   if (FP_REG_P (operands[2]))
2122     {
2123       mvs_check_page (0, 2, 0);
2124       return \"ADR      %0,%2\";
2125     }
2126   mvs_check_page (0, 4, 0);
2127   return \"AD   %0,%2\";
2129    [(set_attr "length" "4")]
2133 ; addsf3 instruction pattern(s).
2136 (define_insn "addsf3"
2137   [(set (match_operand:SF 0 "general_operand" "=f")
2138         (plus:SF (match_operand:SF 1 "general_operand" "%0")
2139                  (match_operand:SF 2 "general_operand" "fmF")))]
2140   ""
2141   "*
2143   check_label_emit ();
2144   if (FP_REG_P (operands[2]))
2145     {
2146       mvs_check_page (0, 2, 0);
2147       return \"AER      %0,%2\";
2148     }
2149   mvs_check_page (0, 4, 0);
2150   return \"AE   %0,%2\";
2152    [(set_attr "length" "4")]
2156 ;;- Subtract instructions.
2160 ; subdi3 instruction pattern(s).
2163 ;(define_expand "subdi3"
2164 ;  [(set (match_operand:DI 0 "general_operand" "")
2165 ;       (minus:DI (match_operand:DI 1 "general_operand" "")
2166 ;                 (match_operand:DI 2 "general_operand" "")))]
2167 ;  ""
2168 ;  "
2170 ;  rtx label = gen_label_rtx ();
2171 ;  rtx op0_high = operand_subword (operands[0], 0, 1, DImode);
2172 ;  rtx op0_low = gen_lowpart (SImode, operands[0]);
2173 ;       
2174 ;  emit_insn (gen_rtx_SET (VOIDmode, op0_high,
2175 ;                   gen_rtx_MINUS (SImode,
2176 ;                             operand_subword (operands[1], 0, 1, DImode),
2177 ;                             operand_subword (operands[2], 0, 1, DImode))));
2178 ;  emit_jump_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2,
2179 ;                   gen_rtx_SET (VOIDmode, op0_low,
2180 ;                             gen_rtx_MINUS (SImode,
2181 ;                                     gen_lowpart (SImode, operands[1]),
2182 ;                                     gen_lowpart (SImode, operands[2]))),
2183 ;                   gen_rtx_USE (VOIDmode,
2184 ;                             gen_rtx_LABEL_REF (VOIDmode, label)))));
2185 ;  emit_insn (gen_rtx_SET (VOIDmode, op0_high,
2186 ;                     gen_rtx_MINUS (SImode, op0_high,
2187 ;                             gen_rtx_CONST_INT (SImode, 1))));
2188 ;  emit_label (label);
2189 ;  DONE;
2190 ;}")
2192 (define_insn ""
2193   [(set (match_operand:SI 0 "general_operand" "=d")
2194         (minus:SI (match_operand:SI 1 "general_operand" "0")
2195                   (match_operand:SI 2 "general_operand" "g")))
2196    (use (label_ref (match_operand 3 "" "")))
2197 ;   (clobber (reg:SI 14))
2198    ]
2199   ""
2200   "*
2202   int onpage;
2204   check_label_emit ();
2205   CC_STATUS_INIT;
2206   onpage = mvs_check_label (CODE_LABEL_NUMBER (operands[3]));
2207   if (REG_P (operands[2]))
2208     {
2209       if (!onpage)
2210         {
2211           mvs_check_page (0, 8, 4);
2212           return \"SLR  %0,%2\;L        14,=A(%l3)\;BCR 12,14\";
2213         }
2214       if (mvs_check_page (0, 6, 0))
2215         {
2216           mvs_check_page (0, 2, 4);
2217           return \"SLR  %0,%2\;L        14,=A(%l3)\;BCR 12,14\";
2218         }
2219       return \"SLR      %0,%2\;BC       12,%l3\";
2220     }
2221   if (!onpage)
2222     {
2223       mvs_check_page (0, 10, 4);
2224       return \"SL       %0,%2\;L        14,=A(%l3)\;BCR 12,14\";
2225     }
2226   if (mvs_check_page (0, 8, 0))
2227     {
2228       mvs_check_page (0, 2, 4);
2229       return \"SL       %0,%2\;L        14,=A(%l3)\;BCR 12,14\";
2230     }
2231   return \"SL   %0,%2\;BC       12,%l3\";
2233    [(set_attr "length" "10")]
2237 ; subsi3 instruction pattern(s).
2240 (define_insn "subsi3"
2241   [(set (match_operand:SI 0 "general_operand" "=d")
2242         (minus:SI (match_operand:SI 1 "general_operand" "0")
2243                   (match_operand:SI 2 "general_operand" "g")))]
2244   ""
2245   "*
2247   check_label_emit ();
2248   if (REG_P (operands[2]))
2249     {
2250       mvs_check_page (0, 2, 0);
2251       return \"SR       %0,%2\";
2252     }
2253   if (operands[2] == const1_rtx)
2254     {
2255       CC_STATUS_INIT;  /* subtract assumes CC but BCTR doesnt set CC */
2256       mvs_check_page (0, 2, 0);
2257       return \"BCTR     %0,0\";
2258     }
2259   mvs_check_page (0, 4, 0);
2260   return \"S    %0,%2\";
2262    [(set_attr "length" "4")]
2266 ; subhi3 instruction pattern(s).
2269 (define_insn "subhi3"
2270   [(set (match_operand:HI 0 "general_operand" "=d")
2271         (minus:HI (match_operand:HI 1 "general_operand" "0")
2272                   (match_operand:HI 2 "general_operand" "g")))]
2273   ""
2274   "*
2276   check_label_emit ();
2277   if (REG_P (operands[2]))
2278     {
2279       mvs_check_page (0, 8, 0);
2280       return \"STH      %2,140(,13)\;SH %0,140(,13)\";
2281     }
2282   if (operands[2] == const1_rtx)
2283     {
2284       CC_STATUS_INIT;  /* subtract assumes CC but BCTR doesnt set CC */
2285       mvs_check_page (0, 2, 0);
2286       return \"BCTR     %0,0\";
2287     }
2288   if (GET_CODE (operands[2]) == CONST_INT)
2289     {
2290       mvs_check_page (0, 4, 0);
2291       return \"SH       %0,%H2\";
2292     }
2293   mvs_check_page (0, 4, 0);
2294   return \"SH   %0,%2\";
2296    [(set_attr "length" "8")]
2300 ; subqi3 instruction pattern(s).
2303 (define_expand "subqi3"
2304   [(set (match_operand:QI 0 "general_operand" "=d")
2305         (minus:QI (match_operand:QI 1 "general_operand" "0")
2306                   (match_operand:QI 2 "general_operand" "di")))]
2307   ""
2308   "
2310   if (REG_P (operands[2]))
2311     {
2312       emit_insn (gen_rtx_SET (VOIDmode, operands[0],
2313                         gen_rtx_MINUS (QImode, operands[1], operands[2])));
2314     }
2315   else
2316     {
2317       emit_insn (gen_rtx_SET (VOIDmode, operands[0],
2318                         gen_rtx_PLUS (QImode, operands[1],
2319                                  negate_rtx (QImode, operands[2]))));
2320     }
2321   DONE;
2324 (define_insn ""
2325   [(set (match_operand:QI 0 "register_operand" "=d")
2326         (minus:QI (match_operand:QI 1 "register_operand" "0")
2327                  (match_operand:QI 2 "register_operand" "d")))]
2328   ""
2329   "*
2331   check_label_emit ();
2332   mvs_check_page (0, 2, 0);
2333   return \"SR   %0,%2\";
2335    [(set_attr "length" "2")]
2339 ; subdf3 instruction pattern(s).
2342 (define_insn "subdf3"
2343   [(set (match_operand:DF 0 "general_operand" "=f")
2344         (minus:DF (match_operand:DF 1 "general_operand" "0")
2345                   (match_operand:DF 2 "general_operand" "fmF")))]
2346   ""
2347   "*
2349   check_label_emit ();
2350   if (FP_REG_P (operands[2]))
2351     {
2352       mvs_check_page (0, 2, 0);
2353       return \"SDR      %0,%2\";
2354     }
2355   mvs_check_page (0, 4, 0);
2356   return \"SD   %0,%2\";
2358    [(set_attr "length" "4")]
2362 ; subsf3 instruction pattern(s).
2365 (define_insn "subsf3"
2366   [(set (match_operand:SF 0 "general_operand" "=f")
2367         (minus:SF (match_operand:SF 1 "general_operand" "0")
2368                   (match_operand:SF 2 "general_operand" "fmF")))]
2369   ""
2370   "*
2372   check_label_emit ();
2373   if (FP_REG_P (operands[2]))
2374     {
2375       mvs_check_page (0, 2, 0);
2376       return \"SER      %0,%2\";
2377     }
2378   mvs_check_page (0, 4, 0);
2379   return \"SE   %0,%2\";
2381    [(set_attr "length" "4")]
2385 ;;- Multiply instructions.
2389 ; mulsi3 instruction pattern(s).
2392 (define_expand "mulsi3"
2393   [(set (match_operand:SI 0 "general_operand" "")
2394         (mult:SI (match_operand:SI 1 "general_operand" "")
2395                  (match_operand:SI 2 "general_operand" "")))]
2396   ""
2397   "
2399   if (GET_CODE (operands[1]) == CONST_INT
2400       && CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'K'))
2401     {
2402       emit_insn (gen_rtx_SET (VOIDmode, operands[0],
2403                           gen_rtx_MULT (SImode, operands[2], operands[1])));
2404     }
2405   else if (GET_CODE (operands[2]) == CONST_INT
2406            && CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K'))
2407     {
2408       emit_insn (gen_rtx_SET (VOIDmode, operands[0],
2409                           gen_rtx_MULT (SImode, operands[1], operands[2])));
2410     }
2411   else
2412     {
2413       rtx r = gen_reg_rtx (DImode);
2415       /* XXX trouble.  Below we generate some rtx's that model what
2416        * is really supposed to happen with multiply on the 370/390
2417        * hardware, and that is all well & good.  However, during optimization
2418        * it can happen that the two operands are exchanged (after all, 
2419        * multiplication is commutitive), in which case the doubleword
2420        * ends up in memory and everything is hosed.  The gen_reg_rtx
2421        * should have kept it in a reg ...  We hack around this
2422        * below, in the M/MR isntruction pattern, and constrain it to
2423        * \"di\" instead of \"g\".  But this still ends up with lots & lots of
2424        * movement between registers & memory and is an awful waste.
2425        * Dunno how to untwist it elegantly; but it seems to work for now.
2426        */
2427       emit_insn (gen_rtx_SET (VOIDmode,
2428                           gen_rtx_SUBREG (SImode, r, 1), operands[1]));
2429       emit_insn (gen_rtx_SET (VOIDmode, r,
2430                           gen_rtx_MULT (DImode, r, operands[2])));
2431       emit_insn (gen_rtx_SET (VOIDmode, operands[0],
2432                           gen_rtx_SUBREG (SImode, r, 1)));
2433     }
2434   DONE;
2437 (define_insn ""
2438   [(set (match_operand:SI 0 "general_operand" "=d")
2439         (mult:SI (match_operand:SI 1 "general_operand" "%0")
2440                  (match_operand:SI 2 "immediate_operand" "K")))]
2441   ""
2442   "*
2444   check_label_emit ();
2445   mvs_check_page (0, 4, 0);
2446   return \"MH   %0,%H2\";
2448    [(set_attr "length" "4")]
2451 (define_insn ""
2452   [(set (match_operand:DI 0 "register_operand" "=d")
2453         (mult:DI (match_operand:DI 1 "general_operand" "%0")
2454                  (match_operand:SI 2 "general_operand" "di")))]
2455   ""
2456   "*
2458   check_label_emit ();
2459   if (REG_P (operands[2]))
2460     {
2461       mvs_check_page (0, 2, 0);
2462       return \"MR       %0,%2\";
2463     }
2464   mvs_check_page (0, 4, 0);
2465   return \"M    %0,%2\";
2467    [(set_attr "length" "4")]
2471 ; muldf3 instruction pattern(s).
2474 (define_insn "muldf3"
2475   [(set (match_operand:DF 0 "general_operand" "=f")
2476         (mult:DF (match_operand:DF 1 "general_operand" "%0")
2477                  (match_operand:DF 2 "general_operand" "fmF")))]
2478   ""
2479   "*
2481   check_label_emit ();
2482   if (FP_REG_P (operands[2]))
2483     {
2484       mvs_check_page (0, 2, 0);
2485       return \"MDR      %0,%2\";
2486     }
2487   mvs_check_page (0, 4, 0);
2488   return \"MD   %0,%2\";
2490    [(set_attr "length" "4")]
2494 ; mulsf3 instruction pattern(s).
2497 (define_insn "mulsf3"
2498   [(set (match_operand:SF 0 "general_operand" "=f")
2499         (mult:SF (match_operand:SF 1 "general_operand" "%0")
2500                  (match_operand:SF 2 "general_operand" "fmF")))]
2501   ""
2502   "*
2504   check_label_emit ();
2505   if (FP_REG_P (operands[2]))
2506     {
2507       mvs_check_page (0, 2, 0);
2508       return \"MER      %0,%2\";
2509     }
2510   mvs_check_page (0, 4, 0);
2511   return \"ME   %0,%2\";
2513    [(set_attr "length" "4")]
2517 ;;- Divide instructions.
2521 ; divsi3 instruction pattern(s).
2524 (define_expand "divsi3"
2525   [(set (match_operand:SI 0 "general_operand" "")
2526         (div:SI (match_operand:SI 1 "general_operand" "")
2527                 (match_operand:SI 2 "general_operand" "")))]
2528   ""
2529   "
2531   rtx r = gen_reg_rtx (DImode);
2533   emit_insn (gen_extendsidi2 (r, operands[1]));
2534   emit_insn (gen_rtx_SET (VOIDmode, r,
2535                         gen_rtx_DIV (DImode, r, operands[2])));
2536   emit_insn (gen_rtx_SET (VOIDmode, operands[0],
2537                         gen_rtx_SUBREG (SImode, r, 1)));
2538   DONE;
2543 ; udivsi3 instruction pattern(s).
2546 (define_expand "udivsi3"
2547   [(set (match_operand:SI 0 "general_operand" "")
2548         (udiv:SI (match_operand:SI 1 "general_operand" "")
2549                  (match_operand:SI 2 "general_operand" "")))]
2550   ""
2551   "
2553   rtx dr = gen_reg_rtx (DImode);
2554   rtx dr_0 = gen_rtx_SUBREG (SImode, dr, 0);
2555   rtx dr_1 = gen_rtx_SUBREG (SImode, dr, 1);
2558   if (GET_CODE (operands[2]) == CONST_INT)
2559     {
2560       if (INTVAL (operands[2]) > 0)
2561         {
2562           emit_insn (gen_zero_extendsidi2 (dr, operands[1]));
2563           emit_insn (gen_rtx_SET (VOIDmode, dr,
2564                         gen_rtx_DIV (DImode, dr, operands[2])));
2565         }
2566       else
2567         {
2568           rtx label1 = gen_label_rtx ();
2570           emit_insn (gen_rtx_SET (VOIDmode, dr_0, operands[1]));
2571           emit_insn (gen_rtx_SET (VOIDmode, dr_1, const0_rtx));
2572           emit_insn (gen_cmpsi (dr_0, operands[2]));
2573           emit_jump_insn (gen_bltu (label1));
2574           emit_insn (gen_rtx_SET (VOIDmode, dr_1, const1_rtx));
2575           emit_label (label1);
2576         }
2577     }
2578   else
2579     {
2580       rtx label1 = gen_label_rtx ();
2581       rtx label2 = gen_label_rtx ();
2582       rtx label3 = gen_label_rtx ();
2583       rtx sr = gen_reg_rtx (SImode);
2585       emit_insn (gen_rtx_SET (VOIDmode, dr_0, operands[1]));
2586       emit_insn (gen_rtx_SET (VOIDmode, sr, operands[2]));
2587       emit_insn (gen_rtx_SET (VOIDmode, dr_1, const0_rtx));
2588       emit_insn (gen_cmpsi (sr, dr_0));
2589       emit_jump_insn (gen_bgtu (label3));
2590       emit_insn (gen_cmpsi (sr, const1_rtx));
2591       emit_jump_insn (gen_blt (label2));
2592       emit_insn (gen_cmpsi (sr, const1_rtx));
2593       emit_jump_insn (gen_beq (label1));
2594       emit_insn (gen_rtx_SET (VOIDmode, dr,
2595                           gen_rtx_LSHIFTRT (DImode, dr,
2596                                     gen_rtx_CONST_INT (SImode, 32))));
2597       emit_insn (gen_rtx_SET (VOIDmode, dr,
2598                     gen_rtx_DIV (DImode, dr, sr)));
2599       emit_jump_insn (gen_jump (label3));
2600       emit_label (label1);
2601       emit_insn (gen_rtx_SET (VOIDmode, dr_1, dr_0));
2602       emit_jump_insn (gen_jump (label3));
2603       emit_label (label2);
2604       emit_insn (gen_rtx_SET (VOIDmode, dr_1, const1_rtx));
2605       emit_label (label3);
2606     }
2607   emit_insn (gen_rtx_SET (VOIDmode, operands[0], dr_1));
2609   DONE;
2612 ; This is used by divsi3 & udivsi3.
2614 (define_insn ""
2615   [(set (match_operand:DI 0 "register_operand" "=d")
2616         (div:DI (match_operand:DI 1 "register_operand" "0")
2617                 (match_operand:SI 2 "general_operand" "dm")))]
2618   ""
2619   "*
2621   check_label_emit ();
2622   if (REG_P (operands[2]))
2623     {
2624       mvs_check_page (0, 2, 0);
2625       return \"DR       %0,%2\";
2626     }
2627   mvs_check_page (0, 4, 0);
2628   return \"D    %0,%2\";
2630    [(set_attr "length" "4")]
2634 ; divdf3 instruction pattern(s).
2637 (define_insn "divdf3"
2638   [(set (match_operand:DF 0 "general_operand" "=f")
2639         (div:DF (match_operand:DF 1 "general_operand" "0")
2640                 (match_operand:DF 2 "general_operand" "fmF")))]
2641   ""
2642   "*
2644   check_label_emit ();
2645   if (FP_REG_P (operands[2]))
2646     {
2647       mvs_check_page (0, 2, 0);
2648       return \"DDR      %0,%2\";
2649     }
2650   mvs_check_page (0, 4, 0);
2651   return \"DD   %0,%2\";
2653    [(set_attr "length" "4")]
2657 ; divsf3 instruction pattern(s).
2660 (define_insn "divsf3"
2661   [(set (match_operand:SF 0 "general_operand" "=f")
2662         (div:SF (match_operand:SF 1 "general_operand" "0")
2663                 (match_operand:SF 2 "general_operand" "fmF")))]
2664   ""
2665   "*
2667   check_label_emit ();
2668   if (FP_REG_P (operands[2]))
2669     {
2670       mvs_check_page (0, 2, 0);
2671       return \"DER      %0,%2\";
2672     }
2673   mvs_check_page (0, 4, 0);
2674   return \"DE   %0,%2\";
2676    [(set_attr "length" "4")]
2680 ;;- Modulo instructions.
2684 ; modsi3 instruction pattern(s).
2687 (define_expand "modsi3"
2688   [(set (match_operand:SI 0 "general_operand" "")
2689         (mod:SI (match_operand:SI 1 "general_operand" "")
2690                 (match_operand:SI 2 "general_operand" "")))]
2691   ""
2692   "
2694   rtx r = gen_reg_rtx (DImode);
2696   emit_insn (gen_extendsidi2 (r, operands[1]));
2697   emit_insn (gen_rtx_SET (VOIDmode, r,
2698                         gen_rtx_MOD (DImode, r, operands[2])));
2699   emit_insn (gen_rtx_SET (VOIDmode, operands[0],
2700                         gen_rtx_SUBREG (SImode, r, 0)));
2701   DONE;
2705 ; umodsi3 instruction pattern(s).
2708 (define_expand "umodsi3"
2709   [(set (match_operand:SI 0 "general_operand" "")
2710         (umod:SI (match_operand:SI 1 "general_operand" "")
2711                  (match_operand:SI 2 "general_operand" "")))]
2712   ""
2713   "
2715   rtx dr = gen_reg_rtx (DImode);
2716   rtx dr_0 = gen_rtx_SUBREG (SImode, dr, 0);
2718   emit_insn (gen_rtx_SET (VOIDmode, dr_0, operands[1]));
2720   if (GET_CODE (operands[2]) == CONST_INT)
2721     {
2722       if (INTVAL (operands[2]) > 0)
2723         {
2724           emit_insn (gen_rtx_SET (VOIDmode, dr,
2725                               gen_rtx_LSHIFTRT (DImode, dr,
2726                                         gen_rtx_CONST_INT (SImode, 32))));
2727           emit_insn (gen_rtx_SET (VOIDmode, dr,
2728                         gen_rtx_MOD (DImode, dr, operands[2])));
2729         }
2730       else
2731         {
2732           rtx label1 = gen_label_rtx ();
2733           rtx sr = gen_reg_rtx (SImode);
2735           emit_insn (gen_rtx_SET (VOIDmode, sr, operands[2]));
2736           emit_insn (gen_cmpsi (dr_0, sr));
2737           emit_jump_insn (gen_bltu (label1));
2738           emit_insn (gen_rtx_SET (VOIDmode, sr, gen_rtx_ABS (SImode, sr)));
2739           emit_insn (gen_rtx_SET (VOIDmode, dr_0,
2740                               gen_rtx_PLUS (SImode, dr_0, sr)));
2741           emit_label (label1);
2742         }
2743     }
2744   else
2745     {
2746       rtx label1 = gen_label_rtx ();
2747       rtx label2 = gen_label_rtx ();
2748       rtx label3 = gen_label_rtx ();
2749       rtx sr = gen_reg_rtx (SImode);
2751       emit_insn (gen_rtx_SET (VOIDmode, dr_0, operands[1]));
2752       emit_insn (gen_rtx_SET (VOIDmode, sr, operands[2]));
2753       emit_insn (gen_cmpsi (sr, dr_0));
2754       emit_jump_insn (gen_bgtu (label3));
2755       emit_insn (gen_cmpsi (sr, const1_rtx));
2756       emit_jump_insn (gen_blt (label2));
2757       emit_jump_insn (gen_beq (label1));
2758       emit_insn (gen_rtx_SET (VOIDmode, dr,
2759                           gen_rtx_LSHIFTRT (DImode, dr,
2760                                     gen_rtx_CONST_INT (SImode, 32))));
2761       emit_insn (gen_rtx_SET (VOIDmode, dr, gen_rtx_MOD (DImode, dr, sr)));
2762       emit_jump_insn (gen_jump (label3));
2763       emit_label (label1);
2764       emit_insn (gen_rtx_SET (VOIDmode, dr_0, const0_rtx));
2765       emit_jump_insn (gen_jump (label3));
2766       emit_label (label2);
2767       emit_insn (gen_rtx_SET (VOIDmode, dr_0,
2768                           gen_rtx_MINUS (SImode, dr_0, sr)));
2769       emit_label (label3);
2771     }
2772   emit_insn (gen_rtx_SET (VOIDmode, operands[0], dr_0));
2774   DONE;
2777 ; This is used by modsi3 & umodsi3.
2779 (define_insn ""
2780   [(set (match_operand:DI 0 "register_operand" "=d")
2781         (mod:DI (match_operand:DI 1 "register_operand" "0")
2782                 (match_operand:SI 2 "general_operand" "dm")))]
2783   ""
2784   "*
2786   check_label_emit ();
2787   if (REG_P (operands[2]))
2788     {
2789       mvs_check_page (0, 2, 0);
2790       return \"DR       %0,%2\";
2791     }
2792   mvs_check_page (0, 4, 0);
2793   return \"D    %0,%2\";
2795    [(set_attr "length" "4")]
2799 ;;- And instructions.
2803 ; anddi3 instruction pattern(s).
2806 ;(define_expand "anddi3"
2807 ;  [(set (match_operand:DI 0 "general_operand" "")
2808 ;       (and:DI (match_operand:DI 1 "general_operand" "")
2809 ;               (match_operand:DI 2 "general_operand" "")))]
2810 ;  ""
2811 ;  "
2813 ;  rtx gen_andsi3();
2815 ;  emit_insn (gen_andsi3 (operand_subword (operands[0], 0, 1, DImode),
2816 ;                        operand_subword (operands[1], 0, 1, DImode),
2817 ;                        operand_subword (operands[2], 0, 1, DImode)));
2818 ;  emit_insn (gen_andsi3 (gen_lowpart (SImode, operands[0]),
2819 ;                        gen_lowpart (SImode, operands[1]),
2820 ;                        gen_lowpart (SImode, operands[2])));
2821 ;  DONE;
2822 ;}")
2825 ; andsi3 instruction pattern(s).
2828 (define_insn ""
2829   [(set (match_operand:SI 0 "r_or_s_operand" "=d,m")
2830         (and:SI (match_operand:SI 1 "r_or_s_operand" "%0,0")
2831                 (match_operand:SI 2 "r_or_s_operand" "g,mi")))]
2832   "TARGET_CHAR_INSTRUCTIONS"
2833   "*
2835   check_label_emit ();
2836   CC_STATUS_INIT;  /* and sets CC but not how we want it */
2837   if (REG_P (operands[2]))
2838     {
2839       mvs_check_page (0, 2, 0);
2840       return \"NR       %0,%2\";
2841     }
2842   if (REG_P (operands[0]))
2843     {
2844       mvs_check_page (0, 4, 0);
2845       return \"N        %0,%2\";
2846     }
2847   mvs_check_page (0, 6, 0);
2848   return \"NC   %O0(4,%R0),%2\";
2850    [(set_attr "length" "6")]
2853 (define_insn "andsi3"
2854   [(set (match_operand:SI 0 "general_operand" "=d")
2855         (and:SI (match_operand:SI 1 "general_operand" "%0")
2856                 (match_operand:SI 2 "general_operand" "g")))]
2857   ""
2858   "*
2860   check_label_emit ();
2861   CC_STATUS_INIT;  /* and sets CC but not how we want it */
2862   if (REG_P (operands[2]))
2863     {
2864       mvs_check_page (0, 2, 0);
2865       return \"NR       %0,%2\";
2866     }
2867   mvs_check_page (0, 4, 0);
2868   return \"N    %0,%2\";
2870    [(set_attr "length" "4")]
2874 ; andhi3 instruction pattern(s).
2877 (define_insn ""
2878   [(set (match_operand:HI 0 "r_or_s_operand" "=d,m")
2879         (and:HI (match_operand:HI 1 "r_or_s_operand" "%0,0")
2880                 (match_operand:HI 2 "r_or_s_operand" "di,mi")))]
2881   "TARGET_CHAR_INSTRUCTIONS"
2882   "*
2884   check_label_emit ();
2885   CC_STATUS_INIT;  /* and sets CC but not how we want it */
2886   if (REG_P (operands[2]))
2887     {
2888       mvs_check_page (0, 2, 0);
2889       return \"NR       %0,%2\";
2890     }
2891   if (REG_P (operands[0]))
2892     {
2893       /* %K2 == sign extend operand to 32 bits so that CH works */
2894       mvs_check_page (0, 4, 0);
2895       if (GET_CODE (operands[2]) == CONST_INT)
2896          return \"N     %0,%K2\";
2897       return \"N        %0,%2\";
2898     }
2899   if (GET_CODE (operands[2]) == CONST_INT)
2900     {
2901       mvs_check_page (0, 6, 0);
2902       return \"NC       %O0(2,%R0),%H2\";
2903     }
2904   mvs_check_page (0, 6, 0);
2905   return \"NC   %O0(2,%R0),%2\";
2907    [(set_attr "length" "6")]
2910 (define_insn "andhi3"
2911   [(set (match_operand:HI 0 "general_operand" "=d")
2912         (and:HI (match_operand:HI 1 "general_operand" "%0")
2913                 (match_operand:HI 2 "general_operand" "di")))]
2914   ""
2915   "*
2917   check_label_emit ();
2918   CC_STATUS_INIT;  /* and sets CC but not how we want it */
2919   if (GET_CODE (operands[2]) == CONST_INT)
2920     {
2921       /* %K2 == sign extend operand to 32 bits so that CH works */
2922       mvs_check_page (0, 4, 0);
2923       return \"N        %0,%K2\";
2924     }
2925   mvs_check_page (0, 2, 0);
2926   return \"NR   %0,%2\";
2928    [(set_attr "length" "4")]
2932 ; andqi3 instruction pattern(s).
2935 (define_insn ""
2936   [(set (match_operand:QI 0 "r_or_s_operand" "=d,m")
2937         (and:QI (match_operand:QI 1 "r_or_s_operand" "%0,0")
2938                 (match_operand:QI 2 "r_or_s_operand" "di,mi")))]
2939   "TARGET_CHAR_INSTRUCTIONS"
2940   "*
2942   check_label_emit ();
2943   CC_STATUS_INIT;  /* and sets CC but not how we want it */
2944   if (REG_P (operands[2]))
2945     {
2946       mvs_check_page (0, 2, 0);
2947       return \"NR       %0,%2\";
2948     }
2949   if (REG_P (operands[0]))
2950     {
2951       mvs_check_page (0, 4, 0);
2952       return \"N        %0,%2\";
2953     }
2954   if (GET_CODE (operands[2]) == CONST_INT)
2955     {
2956       mvs_check_page (0, 4, 0);
2957       return \"NI       %0,%B2\";
2958     }
2959   mvs_check_page (0, 6, 0);
2960   return \"NC   %O0(1,%R0),%2\";
2962    [(set_attr "length" "6")]
2965 (define_insn "andqi3"
2966   [(set (match_operand:QI 0 "general_operand" "=d")
2967         (and:QI (match_operand:QI 1 "general_operand" "%0")
2968                 (match_operand:QI 2 "general_operand" "di")))]
2969   ""
2970   "*
2972   check_label_emit ();
2973   CC_STATUS_INIT;  /* and sets CC but not how we want it */
2974   if (GET_CODE (operands[2]) == CONST_INT)
2975     {
2976       mvs_check_page (0, 4, 0);
2977       return \"N        %0,%2\";
2978     }
2979   mvs_check_page (0, 2, 0);
2980   return \"NR   %0,%2\";
2982    [(set_attr "length" "4")]
2986 ;;- Bit set (inclusive or) instructions.
2990 ; iordi3 instruction pattern(s).
2993 ;(define_expand "iordi3"
2994 ;  [(set (match_operand:DI 0 "general_operand" "")
2995 ;       (ior:DI (match_operand:DI 1 "general_operand" "")
2996 ;               (match_operand:DI 2 "general_operand" "")))]
2997 ;  ""
2998 ;  "
3000 ;  rtx gen_iorsi3();
3002 ;  emit_insn (gen_iorsi3 (operand_subword (operands[0], 0, 1, DImode),
3003 ;                        operand_subword (operands[1], 0, 1, DImode),
3004 ;                        operand_subword (operands[2], 0, 1, DImode)));
3005 ;  emit_insn (gen_iorsi3 (gen_lowpart (SImode, operands[0]),
3006 ;                        gen_lowpart (SImode, operands[1]),
3007 ;                        gen_lowpart (SImode, operands[2])));
3008 ;  DONE;
3009 ;}")
3012 ; iorsi3 instruction pattern(s).
3015 (define_insn ""
3016   [(set (match_operand:SI 0 "r_or_s_operand" "=d,m")
3017         (ior:SI (match_operand:SI 1 "r_or_s_operand" "%0,0")
3018                 (match_operand:SI 2 "r_or_s_operand" "g,Si")))]
3019   "TARGET_CHAR_INSTRUCTIONS"
3020   "*
3022   check_label_emit ();
3023   CC_STATUS_INIT;  /* OR sets CC but not how we want it */
3024   if (REG_P (operands[2]))
3025     {
3026       mvs_check_page (0, 2, 0);
3027       return \"OR       %0,%2\";
3028     }
3029   if (REG_P (operands[0]))
3030     {
3031       mvs_check_page (0, 4, 0);
3032       return \"O        %0,%2\";
3033     }
3034   mvs_check_page (0, 6, 0);
3035   return \"OC   %O0(4,%R0),%2\";
3037   [(set_attr "length" "6")]
3040 (define_insn "iorsi3"
3041   [(set (match_operand:SI 0 "general_operand" "=d")
3042         (ior:SI (match_operand:SI 1 "general_operand" "%0")
3043                 (match_operand:SI 2 "general_operand" "g")))]
3044   ""
3045   "*
3047   check_label_emit ();
3048   CC_STATUS_INIT;  /* OR sets CC but not how we want it */
3049   if (REG_P (operands[2]))
3050     {
3051       mvs_check_page (0, 2, 0);
3052       return \"OR       %0,%2\";
3053     }
3054   mvs_check_page (0, 4, 0);
3055   return \"O    %0,%2\";
3057    [(set_attr "length" "4")]
3061 ; iorhi3 instruction pattern(s).
3064 (define_insn ""
3065   [(set (match_operand:HI 0 "r_or_s_operand" "=d,m")
3066         (ior:HI (match_operand:HI 1 "r_or_s_operand" "%0,0")
3067                 (match_operand:HI 2 "r_or_s_operand" "di,mi")))]
3068   "TARGET_CHAR_INSTRUCTIONS"
3069   "*
3071   check_label_emit ();
3072   CC_STATUS_INIT;  /* OR sets CC but not how we want it */
3073   if (REG_P (operands[2]))
3074     {
3075       mvs_check_page (0, 2, 0);
3076       return \"OR       %0,%2\";
3077     }
3078   if (REG_P (operands[0]))
3079     {
3080       mvs_check_page (0, 4, 0);
3081       return \"O        %0,%2\";
3082     }
3083   if (GET_CODE (operands[2]) == CONST_INT)
3084     {
3085       mvs_check_page (0, 6, 2);
3086       return \"OC       %O0(2,%R0),%H2\";
3087     }
3088   mvs_check_page (0, 6, 0);
3089   return \"OC   %O0(2,%R0),%2\";
3091    [(set_attr "length" "6")]
3094 (define_insn "iorhi3"
3095   [(set (match_operand:HI 0 "general_operand" "=d")
3096         (ior:HI (match_operand:HI 1 "general_operand" "%0")
3097                 (match_operand:HI 2 "general_operand" "di")))]
3098   ""
3099   "*
3101   check_label_emit ();
3102   CC_STATUS_INIT;  /* OR sets CC but not how we want it */
3103   if (GET_CODE (operands[2]) == CONST_INT)
3104     {
3105       mvs_check_page (0, 4, 0);
3106       return \"O        %0,%2\";
3107     }
3108   mvs_check_page (0, 2, 0);
3109   return \"OR   %0,%2\";
3111    [(set_attr "length" "4")]
3115 ; iorqi3 instruction pattern(s).
3118 (define_insn ""
3119   [(set (match_operand:QI 0 "r_or_s_operand" "=d,m")
3120         (ior:QI (match_operand:QI 1 "r_or_s_operand" "%0,0")
3121                 (match_operand:QI 2 "r_or_s_operand" "di,mi")))]
3122   "TARGET_CHAR_INSTRUCTIONS"
3123   "*
3125   check_label_emit ();
3126   CC_STATUS_INIT;  /* OR sets CC but not how we want it */
3127   if (REG_P (operands[2]))
3128     {
3129       mvs_check_page (0, 2, 0);
3130       return \"OR       %0,%2\";
3131     }
3132   if (REG_P (operands[0]))
3133     {
3134       mvs_check_page (0, 4, 0);
3135       return \"O        %0,%2\";
3136     }
3137   if (GET_CODE (operands[2]) == CONST_INT)
3138     {
3139       mvs_check_page (0, 4, 0);
3140       return \"OI       %0,%B2\";
3141     }
3142   mvs_check_page (0, 6, 0);
3143   return \"OC   %O0(1,%R0),%2\";
3145    [(set_attr "length" "6")]
3148 (define_insn "iorqi3"
3149   [(set (match_operand:QI 0 "general_operand" "=d")
3150         (ior:QI (match_operand:QI 1 "general_operand" "%0")
3151                 (match_operand:QI 2 "general_operand" "di")))]
3152   ""
3153   "*
3155   check_label_emit ();
3156   CC_STATUS_INIT;  /* OR sets CC but not how we want it */
3157   if (GET_CODE (operands[2]) == CONST_INT)
3158     {
3159       mvs_check_page (0, 4, 0);
3160       return \"O        %0,%2\";
3161     }
3162   mvs_check_page (0, 2, 0);
3163   return \"OR   %0,%2\";
3165    [(set_attr "length" "4")]
3169 ;;- Xor instructions.
3173 ; xordi3 instruction pattern(s).
3176 ;(define_expand "xordi3"
3177 ;  [(set (match_operand:DI 0 "general_operand" "")
3178 ;       (xor:DI (match_operand:DI 1 "general_operand" "")
3179 ;               (match_operand:DI 2 "general_operand" "")))]
3180 ;  ""
3181 ;  "
3183 ;  rtx gen_xorsi3();
3185 ;  emit_insn (gen_xorsi3 (operand_subword (operands[0], 0, 1, DImode),
3186 ;                        operand_subword (operands[1], 0, 1, DImode),
3187 ;                        operand_subword (operands[2], 0, 1, DImode)));
3188 ;  emit_insn (gen_xorsi3 (gen_lowpart (SImode, operands[0]),
3189 ;                        gen_lowpart (SImode, operands[1]),
3190 ;                        gen_lowpart (SImode, operands[2])));
3191 ;  DONE;
3192 ;}")
3195 ; xorsi3 instruction pattern(s).
3198 (define_insn ""
3199   [(set (match_operand:SI 0 "r_or_s_operand" "=d,m")
3200         (xor:SI (match_operand:SI 1 "r_or_s_operand" "%0,0")
3201                 (match_operand:SI 2 "r_or_s_operand" "g,mi")))]
3202   "TARGET_CHAR_INSTRUCTIONS"
3203   "*
3205   check_label_emit ();
3206   CC_STATUS_INIT;  /* XOR sets CC but not how we want it */
3207   if (REG_P (operands[2]))
3208     {
3209       mvs_check_page (0, 2, 0);
3210       return \"XR       %0,%2\";
3211     }
3212   if (REG_P (operands[0]))
3213     {
3214       mvs_check_page (0, 4, 0);
3215       return \"X        %0,%2\";
3216     }
3217   mvs_check_page (0, 6, 0);
3218   return \"XC   %O0(4,%R0),%2\";
3220    [(set_attr "length" "6")]
3223 (define_insn "xorsi3"
3224   [(set (match_operand:SI 0 "general_operand" "=d")
3225         (xor:SI (match_operand:SI 1 "general_operand" "%0")
3226                 (match_operand:SI 2 "general_operand" "g")))]
3227   ""
3228   "*
3230   check_label_emit ();
3231   CC_STATUS_INIT;  /* XOR sets CC but not how we want it */
3232   if (REG_P (operands[2]))
3233     {
3234       mvs_check_page (0, 2, 0);
3235       return \"XR       %0,%2\";
3236     }
3237   mvs_check_page (0, 4, 0);
3238   return \"X    %0,%2\";
3240   [(set_attr "length" "4")]
3244 ; xorhi3 instruction pattern(s).
3247 (define_insn ""
3248   [(set (match_operand:HI 0 "r_or_s_operand" "=d,m")
3249         (xor:HI (match_operand:HI 1 "r_or_s_operand" "%0,0")
3250                 (match_operand:HI 2 "r_or_s_operand" "di,mi")))]
3251   "TARGET_CHAR_INSTRUCTIONS"
3252   "*
3254   check_label_emit ();
3255   CC_STATUS_INIT;  /* XOR sets CC but not how we want it */
3256   if (REG_P (operands[2]))
3257     {
3258       mvs_check_page (0, 2, 0);
3259       return \"XR       %0,%2\";
3260     }
3261   if (REG_P (operands[0]))
3262     {
3263       mvs_check_page (0, 4, 0);
3264       return \"X        %0,%H2\";
3265     }
3266   if (GET_CODE (operands[2]) == CONST_INT)
3267     {
3268       mvs_check_page (0, 6, 0);
3269       return \"XC       %O0(2,%R0),%H2\";
3270     }
3271   mvs_check_page (0, 6, 0);
3272   return \"XC   %O0(2,%R0),%2\";
3274   [(set_attr "length" "6")]
3277 (define_insn "xorhi3"
3278   [(set (match_operand:HI 0 "general_operand" "=d")
3279         (xor:HI (match_operand:HI 1 "general_operand" "%0")
3280                 (match_operand:HI 2 "general_operand" "di")))]
3281   ""
3282   "*
3284   check_label_emit ();
3285   CC_STATUS_INIT;  /* XOR sets CC but not how we want it */
3286   if (GET_CODE (operands[2]) == CONST_INT)
3287     {
3288       mvs_check_page (0, 4, 0);
3289       return \"X        %0,%H2\";
3290     }
3291   mvs_check_page (0, 2, 0);
3292   return \"XR   %0,%2\";
3294   [(set_attr "length" "4")]
3298 ; xorqi3 instruction pattern(s).
3301 (define_insn ""
3302   [(set (match_operand:QI 0 "r_or_s_operand" "=d,m")
3303         (xor:QI (match_operand:QI 1 "r_or_s_operand" "%0,0")
3304                 (match_operand:QI 2 "r_or_s_operand" "di,mi")))]
3305   "TARGET_CHAR_INSTRUCTIONS"
3306   "*
3308   check_label_emit ();
3309   CC_STATUS_INIT;  /* XOR sets CC but not how we want it */
3310   if (REG_P (operands[2]))
3311     {
3312       mvs_check_page (0, 2, 0);
3313       return \"XR       %0,%2\";
3314     }
3315   if (REG_P (operands[0]))
3316     {
3317       mvs_check_page (0, 4, 0);
3318       return \"X        %0,%2\";
3319     }
3320   if (GET_CODE (operands[2]) == CONST_INT)
3321     {
3322       mvs_check_page (0, 4, 0);
3323       return \"XI       %0,%B2\";
3324     }
3325   mvs_check_page (0, 6, 0);
3326   return \"XC   %O0(1,%R0),%2\";
3328   [(set_attr "length" "6")]
3331 (define_insn "xorqi3"
3332   [(set (match_operand:QI 0 "general_operand" "=d")
3333         (xor:QI (match_operand:QI 1 "general_operand" "%0")
3334                 (match_operand:QI 2 "general_operand" "di")))]
3335   ""
3336   "*
3338   check_label_emit ();
3339   CC_STATUS_INIT;  /* XOR sets CC but not how we want it */
3340   if (GET_CODE (operands[2]) == CONST_INT)
3341     {
3342       mvs_check_page (0, 4, 0);
3343       return \"X        %0,%2\";
3344     }
3345   mvs_check_page (0, 2, 0);
3346   return \"XR   %0,%2\";
3348   [(set_attr "length" "4")]
3352 ;;- Negate instructions.
3356 ; negsi2 instruction pattern(s).
3359 (define_insn "negsi2"
3360   [(set (match_operand:SI 0 "general_operand" "=d")
3361         (neg:SI (match_operand:SI 1 "general_operand" "d")))]
3362   ""
3363   "*
3365   check_label_emit ();
3366   mvs_check_page (0, 2, 0);
3367   return \"LCR  %0,%1\";
3369   [(set_attr "length" "2")]
3373 ; neghi2 instruction pattern(s).
3376 (define_insn "neghi2"
3377   [(set (match_operand:HI 0 "general_operand" "=d")
3378         (neg:HI (match_operand:HI 1 "general_operand" "d")))]
3379   ""
3380   "*
3382   check_label_emit ();
3383   mvs_check_page (0, 10, 0);
3384   return \"SLL  %1,16\;SRA      %1,16\;LCR      %0,%1\";
3386   [(set_attr "length" "10")]
3390 ; negdf2 instruction pattern(s).
3393 (define_insn "negdf2"
3394   [(set (match_operand:DF 0 "general_operand" "=f")
3395         (neg:DF (match_operand:DF 1 "general_operand" "f")))]
3396   ""
3397   "*
3399   check_label_emit ();
3400   mvs_check_page (0, 2, 0);
3401   return \"LCDR %0,%1\";
3403   [(set_attr "length" "2")]
3407 ; negsf2 instruction pattern(s).
3410 (define_insn "negsf2"
3411   [(set (match_operand:SF 0 "general_operand" "=f")
3412         (neg:SF (match_operand:SF 1 "general_operand" "f")))]
3413   ""
3414   "*
3416   check_label_emit ();
3417   mvs_check_page (0, 2, 0);
3418   return \"LCER %0,%1\";
3420   [(set_attr "length" "2")]
3424 ;;- Absolute value instructions.
3428 ; abssi2 instruction pattern(s).
3431 (define_insn "abssi2"
3432   [(set (match_operand:SI 0 "general_operand" "=d")
3433         (abs:SI (match_operand:SI 1 "general_operand" "d")))]
3434   ""
3435   "*
3437   check_label_emit ();
3438   mvs_check_page (0, 2, 0);
3439   return \"LPR  %0,%1\";
3441   [(set_attr "length" "2")]
3445 ; abshi2 instruction pattern(s).
3448 (define_insn "abshi2"
3449   [(set (match_operand:HI 0 "general_operand" "=d")
3450         (abs:HI (match_operand:HI 1 "general_operand" "d")))]
3451   ""
3452   "*
3454   check_label_emit ();
3455   mvs_check_page (0, 10, 0);
3456   return \"SLL  %1,16\;SRA      %1,16\;LPR      %0,%1\";
3458   [(set_attr "length" "10")]
3462 ; absdf2 instruction pattern(s).
3465 (define_insn "absdf2"
3466   [(set (match_operand:DF 0 "general_operand" "=f")
3467         (abs:DF (match_operand:DF 1 "general_operand" "f")))]
3468   ""
3469   "*
3471   check_label_emit ();
3472   mvs_check_page (0, 2, 0);
3473   return \"LPDR %0,%1\";
3475   [(set_attr "length" "2")]
3479 ; abssf2 instruction pattern(s).
3482 (define_insn "abssf2"
3483   [(set (match_operand:SF 0 "general_operand" "=f")
3484         (abs:SF (match_operand:SF 1 "general_operand" "f")))]
3485   ""
3486   "*
3488   check_label_emit ();
3489   mvs_check_page (0, 2, 0);
3490   return \"LPER %0,%1\";
3492   [(set_attr "length" "2")]
3496 ;;- One complement instructions.
3500 ; one_cmpldi2 instruction pattern(s).
3503 ;(define_expand "one_cmpldi2"
3504 ;  [(set (match_operand:DI 0 "general_operand" "")
3505 ;       (not:DI (match_operand:DI 1 "general_operand" "")))]
3506 ;  ""
3507 ;  "
3509 ;  rtx gen_one_cmplsi2();
3511 ;  emit_insn (gen_one_cmplsi2 (operand_subword (operands[0], 0, 1, DImode),
3512 ;                             operand_subword (operands[1], 0, 1, DImode)));
3513 ;  emit_insn (gen_one_cmplsi2 (gen_lowpart (SImode, operands[0]),
3514 ;                             gen_lowpart (SImode, operands[1])));
3515 ;  DONE;
3516 ;}")
3519 ; one_cmplsi2 instruction pattern(s).
3522 (define_insn ""
3523   [(set (match_operand:SI 0 "r_or_s_operand" "=dm")
3524         (not:SI (match_operand:SI 1 "r_or_s_operand" "0")))]
3525   "TARGET_CHAR_INSTRUCTIONS"
3526   "*
3528   check_label_emit ();
3529   CC_STATUS_INIT;  /* XOR sets CC but not how we want it */
3530   if (REG_P (operands[0]))
3531     {
3532       mvs_check_page (0, 4, 4);
3533       return \"X        %0,=F'-1'\";
3534     }
3535   CC_STATUS_INIT;
3536   mvs_check_page (0, 6, 4);
3537   return \"XC   %O0(4,%R0),=F'-1'\";
3539   [(set_attr "length" "6")]
3542 (define_insn "one_cmplsi2"
3543   [(set (match_operand:SI 0 "general_operand" "=d")
3544         (not:SI (match_operand:SI 1 "general_operand" "0")))]
3545   ""
3546   "*
3548   check_label_emit ();
3549   CC_STATUS_INIT;  /* XOR sets CC but not how we want it */
3550   mvs_check_page (0, 4, 4);
3551   return \"X    %0,=F'-1'\";
3553   [(set_attr "length" "4")]
3557 ; one_cmplhi2 instruction pattern(s).
3560 (define_insn ""
3561   [(set (match_operand:HI 0 "r_or_s_operand" "=dm")
3562         (not:HI (match_operand:HI 1 "r_or_s_operand" "0")))]
3563   "TARGET_CHAR_INSTRUCTIONS"
3564   "*
3566   check_label_emit ();
3567   CC_STATUS_INIT;  /* XOR sets CC but not how we want it */
3568   if (REG_P (operands[0]))
3569     {
3570       mvs_check_page (0, 4, 4);
3571       return \"X        %0,=F'-1'\";
3572     }
3573   mvs_check_page (0, 6, 4);
3574   return \"XC   %O0(2,%R0),=XL4'FFFF'\";
3576   [(set_attr "length" "6")]
3579 (define_insn "one_cmplhi2"
3580   [(set (match_operand:HI 0 "general_operand" "=d")
3581         (not:HI (match_operand:HI 1 "general_operand" "0")))]
3582   ""
3583   "*
3585   check_label_emit ();
3586   CC_STATUS_INIT;  /* XOR sets CC but not how we want it */
3587   mvs_check_page (0, 4, 4);
3588   return \"X    %0,=F'-1'\";
3590   [(set_attr "length" "4")]
3594 ; one_cmplqi2 instruction pattern(s).
3597 (define_insn ""
3598   [(set (match_operand:QI 0 "r_or_s_operand" "=dm")
3599         (not:QI (match_operand:QI 1 "r_or_s_operand" "0")))]
3600   "TARGET_CHAR_INSTRUCTIONS"
3601   "*
3603   check_label_emit ();
3604   CC_STATUS_INIT;  /* XOR sets CC but not how we want it */
3605   if (REG_P (operands[0]))
3606     {
3607       mvs_check_page (0, 4, 4);
3608       return \"X        %0,=F'-1'\";
3609     }
3610   mvs_check_page (0, 4, 0);
3611   return \"XI   %0,255\";
3613   [(set_attr "length" "4")]
3616 (define_insn "one_cmplqi2"
3617   [(set (match_operand:QI 0 "general_operand" "=d")
3618         (not:QI (match_operand:QI 1 "general_operand" "0")))]
3619   ""
3620   "*
3622   check_label_emit ();
3623   CC_STATUS_INIT;  /* XOR sets CC but not how we want it */
3624   mvs_check_page (0, 4, 4);
3625   return \"X    %0,=F'-1'\";
3627   [(set_attr "length" "4")]
3631 ;;- Arithmetic shift instructions.
3635 ; ashldi3 instruction pattern(s).
3638 (define_insn "ashldi3"
3639   [(set (match_operand:DI 0 "general_operand" "=d")
3640         (ashift:DI (match_operand:DI 1 "general_operand" "0")
3641                    (match_operand:SI 2 "general_operand" "Ja")))]
3642   ""
3643   "*
3645   check_label_emit ();
3646   /* this status set seems not have the desired effect,
3647    * proably because the 64-bit long-long test is emulated ?! */
3648   CC_STATUS_SET (operands[0], operands[1]);
3649   mvs_check_page (0, 4, 0);
3650   if (REG_P (operands[2]))
3651     return \"SLDA       %0,0(%2)\";
3652   return \"SLDA %0,%c2\";
3654   [(set_attr "length" "4")]
3658 ; ashrdi3 instruction pattern(s).
3661 (define_insn "ashrdi3"
3662   [(set (match_operand:DI 0 "register_operand" "=d")
3663         (ashiftrt:DI (match_operand:DI 1 "general_operand" "0")
3664                      (match_operand:SI 2 "general_operand" "Ja")))]
3665   ""
3666   "*
3668   check_label_emit ();
3669   /* this status set seems not have the desired effect,
3670    * proably because the 64-bit long-long test is emulated ?! */
3671   CC_STATUS_SET (operands[0], operands[1]);
3672   mvs_check_page (0, 4, 0);
3673   if (REG_P (operands[2])) 
3674     return \"SRDA       %0,0(%2)\";
3675   return \"SRDA %0,%c2\";
3677   [(set_attr "length" "4")]
3681 ; ashlsi3 instruction pattern(s).
3684 (define_insn "ashlsi3"
3685   [(set (match_operand:SI 0 "general_operand" "=d")
3686         (ashift:SI (match_operand:SI 1 "general_operand" "0")
3687                    (match_operand:SI 2 "general_operand" "Ja")))]
3688   ""
3689   "*
3691   check_label_emit ();
3692   mvs_check_page (0, 4, 0);
3693   if (REG_P (operands[2])) 
3694     return \"SLL        %0,0(%2)\";
3695   return \"SLL  %0,%c2\";
3697   [(set_attr "length" "4")]
3701 ; ashrsi3 instruction pattern(s).
3704 (define_insn "ashrsi3"
3705   [(set (match_operand:SI 0 "general_operand" "=d")
3706         (ashiftrt:SI (match_operand:SI 1 "general_operand" "0")
3707                      (match_operand:SI 2 "general_operand" "Ja")))]
3708   ""
3709   "*
3711   check_label_emit ();
3712   CC_STATUS_SET (operands[0], operands[1]);
3713   mvs_check_page (0, 4, 0);
3714   if (REG_P (operands[2])) 
3715     return \"SRA        %0,0(%2)\";
3716   return \"SRA  %0,%c2\";
3718   [(set_attr "length" "4")]
3722 ; ashlhi3 instruction pattern(s).
3725 (define_insn "ashlhi3"
3726   [(set (match_operand:HI 0 "general_operand" "=d")
3727         (ashift:HI (match_operand:HI 1 "general_operand" "0")
3728                    (match_operand:SI 2 "general_operand" "Ja")))]
3729   ""
3730   "*
3732   check_label_emit ();
3733   mvs_check_page (0, 8, 0);
3734   if (REG_P (operands[2])) 
3735     return \"SLL        %0,16(%2)\;SRA  %0,16\";
3736   return \"SLL  %0,16+%c2\;SRA  %0,16\";
3738   [(set_attr "length" "8")]
3742 ; ashrhi3 instruction pattern(s).
3745 (define_insn "ashrhi3"
3746   [(set (match_operand:HI 0 "general_operand" "=d")
3747         (ashiftrt:HI (match_operand:HI 1 "general_operand" "0")
3748                      (match_operand:SI 2 "general_operand" "Ja")))]
3749   ""
3750   "*
3752   check_label_emit ();
3753   mvs_check_page (0, 8, 0);
3754   if (REG_P (operands[2])) 
3755     return \"SLL        %0,16\;SRA      %0,16(%2)\";
3756   return \"SLL  %0,16\;SRA      %0,16+%c2\";
3758   [(set_attr "length" "8")]
3762 ; ashlqi3 instruction pattern(s).
3765 (define_insn "ashlqi3"
3766   [(set (match_operand:QI 0 "general_operand" "=d")
3767         (ashift:QI (match_operand:QI 1 "general_operand" "0")
3768                    (match_operand:SI 2 "general_operand" "Ja")))]
3769   ""
3770   "*
3772   check_label_emit ();
3773   mvs_check_page (0, 4, 0);
3774   if (REG_P (operands[2])) 
3775     return \"SLL        %0,0(%2)\";
3776   return \"SLL  %0,%c2\";
3778   [(set_attr "length" "4")]
3782 ; ashrqi3 instruction pattern(s).
3785 (define_insn "ashrqi3"
3786   [(set (match_operand:QI 0 "general_operand" "=d")
3787         (ashiftrt:QI (match_operand:QI 1 "general_operand" "0")
3788                      (match_operand:SI 2 "general_operand" "Ja")))]
3789   ""
3790   "*
3792   check_label_emit ();
3793   mvs_check_page (0, 8, 0);
3794   if (REG_P (operands[2])) 
3795     return \"SLL        %0,24\;SRA      %0,24(%2)\";
3796   return \"SLL  %0,24\;SRA      %0,24+%c2\";
3798   [(set_attr "length" "8")]
3802 ;;- Logical shift instructions.
3806 ; lshrdi3 instruction pattern(s).
3809 (define_insn "lshrdi3"
3810   [(set (match_operand:DI 0 "general_operand" "=d")
3811         (lshiftrt:DI (match_operand:DI 1 "general_operand" "0")
3812                      (match_operand:SI 2 "general_operand" "Ja")))]
3813   ""
3814   "*
3816   check_label_emit ();
3817   mvs_check_page (0, 4, 0);
3818   if (REG_P (operands[2])) 
3819     return \"SRDL       %0,0(%2)\";
3820   return \"SRDL %0,%c2\";
3822   [(set_attr "length" "4")]
3827 ; lshrsi3 instruction pattern(s).
3830 (define_insn "lshrsi3"
3831   [(set (match_operand:SI 0 "general_operand" "=d")
3832         (lshiftrt:SI (match_operand:SI 1 "general_operand" "0")
3833                      (match_operand:SI 2 "general_operand" "Ja")))]
3834   ""
3835   "*
3837   check_label_emit ();
3838   mvs_check_page (0, 4, 0);
3839   if (REG_P (operands[2])) 
3840     return \"SRL        %0,0(%2)\";
3841   return \"SRL  %0,%c2\";
3843   [(set_attr "length" "4")]
3847 ; lshrhi3 instruction pattern(s).
3850 (define_insn "lshrhi3"
3851   [(set (match_operand:HI 0 "general_operand" "=d")
3852         (lshiftrt:HI (match_operand:HI 1 "general_operand" "0")
3853                      (match_operand:SI 2 "general_operand" "Ja")))]
3854   ""
3855   "*
3857   check_label_emit ();
3858   CC_STATUS_INIT; /* AND sets the CC but not how we want it */
3859   if (REG_P (operands[2]))
3860     {
3861       mvs_check_page (0, 8, 4);
3862       return \"N        %0,=XL4'0000FFFF'\;SRL  %0,0(%2)\";
3863     }
3864   mvs_check_page (0, 8, 4);
3865   return \"N    %0,=XL4'0000FFFF'\;SRL  %0,%c2\";
3867   [(set_attr "length" "8")]
3871 ; lshrqi3 instruction pattern(s).
3874 (define_insn "lshrqi3"
3875   [(set (match_operand:QI 0 "general_operand" "=d")
3876         (lshiftrt:QI (match_operand:QI 1 "general_operand" "0")
3877                      (match_operand:SI 2 "general_operand" "Ja")))]
3878   ""
3879   "*
3881   check_label_emit ();
3882   CC_STATUS_INIT; /* AND sets the CC but not how we want it */
3883   mvs_check_page (0, 8, 4);
3884   if (REG_P (operands[2])) 
3885     return \"N  %0,=XL4'000000FF'\;SRL  %0,0(%2)\";
3886   return \"N    %0,=XL4'000000FF'\;SRL  %0,%c2\";
3888   [(set_attr "length" "8")]
3891 ;; =======================================================================
3892 ;;- Conditional jump instructions.
3893 ;; =======================================================================
3896 ; beq instruction pattern(s).
3899 (define_insn "beq"
3900   [(set (pc)
3901         (if_then_else (eq (cc0)
3902                           (const_int 0))
3903                       (label_ref (match_operand 0 "" ""))
3904                       (pc)))
3905 ;   (clobber (reg:SI 14))
3906    ]
3907   ""
3908   "*
3910   check_label_emit ();
3911   mvs_check_page (0, 4, 0);
3912   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
3913     { 
3914       return \"BE       %l0\";
3915     }
3916   mvs_check_page (0, 2, 4);
3917   return \"L    14,=A(%l0)\;BER 14\";
3919   [(set_attr "length" "6")]
3923 ; bne instruction pattern(s).
3926 (define_insn "bne"
3927   [(set (pc)
3928         (if_then_else (ne (cc0)
3929                           (const_int 0))
3930                       (label_ref (match_operand 0 "" ""))
3931                       (pc)))
3932 ;   (clobber (reg:SI 14))
3933    ]
3934   ""
3935   "*
3937   check_label_emit ();
3938   mvs_check_page (0, 4, 0);
3939   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
3940     { 
3941       return \"BNE      %l0\";
3942     }
3943   mvs_check_page (0, 2, 4);
3944   return \"L    14,=A(%l0)\;BNER        14\";
3946   [(set_attr "length" "6")]
3950 ; bgt instruction pattern(s).
3953 (define_insn "bgt"
3954   [(set (pc)
3955         (if_then_else (gt (cc0)
3956                           (const_int 0))
3957                       (label_ref (match_operand 0 "" ""))
3958                       (pc)))
3959 ;   (clobber (reg:SI 14))
3960    ]
3961   ""
3962   "*
3964   check_label_emit ();
3965   mvs_check_page (0, 4, 0);
3966   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
3967     { 
3968       return \"BH       %l0\";
3969     }
3970   mvs_check_page (0, 2, 4);
3971   return \"L    14,=A(%l0)\;BHR 14\";
3973   [(set_attr "length" "6")]
3977 ; bgtu instruction pattern(s).
3980 (define_insn "bgtu"
3981   [(set (pc)
3982         (if_then_else (gtu (cc0)
3983                            (const_int 0))
3984                       (label_ref (match_operand 0 "" ""))
3985                       (pc)))
3986 ;   (clobber (reg:SI 14))
3987    ]
3988   ""
3989   "*
3991   check_label_emit ();
3992   mvs_check_page (0, 4, 0);
3993   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
3994     { 
3995       return \"BH       %l0\";
3996     }
3997   mvs_check_page (0, 2, 4);
3998   return \"L    14,=A(%l0)\;BHR 14\";
4000   [(set_attr "length" "6")]
4004 ; blt instruction pattern(s).
4007 (define_insn "blt"
4008   [(set (pc)
4009         (if_then_else (lt (cc0)
4010                           (const_int 0))
4011                       (label_ref (match_operand 0 "" ""))
4012                       (pc)))
4013 ;   (clobber (reg:SI 14))
4014    ]
4015   ""
4016   "*
4018   check_label_emit ();
4019   mvs_check_page (0, 4, 0);
4020   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4021     { 
4022       return \"BL       %l0\";
4023     }
4024   mvs_check_page (0, 2, 4);
4025   return \"L    14,=A(%l0)\;BLR 14\";
4027   [(set_attr "length" "6")]
4031 ; bltu instruction pattern(s).
4034 (define_insn "bltu"
4035   [(set (pc)
4036         (if_then_else (ltu (cc0)
4037                            (const_int 0))
4038                       (label_ref (match_operand 0 "" ""))
4039                       (pc)))
4040 ;   (clobber (reg:SI 14))
4041    ]
4042   ""
4043   "*
4045   check_label_emit ();
4046   mvs_check_page (0, 4, 0);
4047   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4048     { 
4049       return \"BL       %l0\";
4050     }
4051   mvs_check_page (0, 2, 4);
4052   return \"L    14,=A(%l0)\;BLR 14\";
4054   [(set_attr "length" "6")]
4058 ; bge instruction pattern(s).
4061 (define_insn "bge"
4062   [(set (pc)
4063         (if_then_else (ge (cc0)
4064                           (const_int 0))
4065                       (label_ref (match_operand 0 "" ""))
4066                       (pc)))
4067 ;   (clobber (reg:SI 14))
4068    ]
4069   ""
4070   "*
4072   check_label_emit ();
4073   mvs_check_page (0, 4, 0);
4074   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4075     { 
4076       return \"BNL      %l0\";
4077     }
4078   mvs_check_page (0, 2, 4);
4079   return \"L    14,=A(%l0)\;BNLR        14\";
4081   [(set_attr "length" "6")]
4085 ; bgeu instruction pattern(s).
4088 (define_insn "bgeu"
4089   [(set (pc)
4090         (if_then_else (geu (cc0)
4091                            (const_int 0))
4092                       (label_ref (match_operand 0 "" ""))
4093                       (pc)))
4094 ;   (clobber (reg:SI 14))
4095    ]
4096   ""
4097   "*
4099   check_label_emit ();
4100   mvs_check_page (0, 4, 0);
4101   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4102     { 
4103       return \"BNL      %l0\";
4104     }
4105   mvs_check_page (0, 2, 4);
4106   return \"L    14,=A(%l0)\;BNLR        14\";
4108   [(set_attr "length" "6")]
4112 ; ble instruction pattern(s).
4115 (define_insn "ble"
4116   [(set (pc)
4117         (if_then_else (le (cc0)
4118                           (const_int 0))
4119                       (label_ref (match_operand 0 "" ""))
4120                       (pc)))
4121 ;   (clobber (reg:SI 14))
4122    ]
4123   ""
4124   "*
4126   check_label_emit ();
4127   mvs_check_page (0, 4, 0);
4128   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4129     { 
4130       return \"BNH      %l0\";
4131     }
4132   mvs_check_page (0, 2, 4);
4133   return \"L    14,=A(%l0)\;BNHR        14\";
4135   [(set_attr "length" "6")]
4139 ; bleu instruction pattern(s).
4142 (define_insn "bleu"
4143   [(set (pc)
4144         (if_then_else (leu (cc0)
4145                            (const_int 0))
4146                       (label_ref (match_operand 0 "" ""))
4147                       (pc)))
4148 ;   (clobber (reg:SI 14))
4149    ]
4150   ""
4151   "*
4153   check_label_emit ();
4154   mvs_check_page (0, 4, 0);
4155   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4156     { 
4157       return \"BNH      %l0\";
4158     }
4159   mvs_check_page (0, 2, 4);
4160   return \"L    14,=A(%l0)\;BNHR        14\";
4162   [(set_attr "length" "6")]
4166 ;;- Negated conditional jump instructions.
4169 (define_insn ""
4170   [(set (pc)
4171         (if_then_else (eq (cc0)
4172                           (const_int 0))
4173                       (pc)
4174                       (label_ref (match_operand 0 "" ""))))
4175 ;   (clobber (reg:SI 14))
4176    ]
4177   ""
4178   "*
4180   check_label_emit ();
4181   mvs_check_page (0, 4, 0);
4182   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4183     { 
4184       return \"BNE      %l0\";
4185     }
4186   mvs_check_page (0, 2, 4);
4187   return \"L    14,=A(%l0)\;BNER        14\";
4189   [(set_attr "length" "6")]
4192 (define_insn ""
4193   [(set (pc)
4194         (if_then_else (ne (cc0)
4195                           (const_int 0))
4196                       (pc)
4197                       (label_ref (match_operand 0 "" ""))))
4198 ;   (clobber (reg:SI 14))
4199    ]
4200   ""
4201   "*
4203   check_label_emit ();
4204   mvs_check_page (0, 4, 0);
4205   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4206     { 
4207       return \"BE       %l0\";
4208     }
4209   mvs_check_page (0, 2, 4);
4210   return \"L    14,=A(%l0)\;BER 14\";
4212   [(set_attr "length" "6")]
4215 (define_insn ""
4216   [(set (pc)
4217         (if_then_else (gt (cc0)
4218                           (const_int 0))
4219                       (pc)
4220                       (label_ref (match_operand 0 "" ""))))
4221 ;   (clobber (reg:SI 14))
4222    ]
4223   ""
4224   "*
4226   check_label_emit ();
4227   mvs_check_page (0, 4, 0);
4228   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4229     { 
4230       return \"BNH      %l0\";
4231     }
4232   mvs_check_page (0, 2, 4);
4233   return \"L    14,=A(%l0)\;BNHR        14\";
4235   [(set_attr "length" "6")]
4238 (define_insn ""
4239   [(set (pc)
4240         (if_then_else (gtu (cc0)
4241                            (const_int 0))
4242                       (pc)
4243                       (label_ref (match_operand 0 "" ""))))
4244 ;   (clobber (reg:SI 14))
4245    ]
4246   ""
4247   "*
4249   check_label_emit ();
4250   mvs_check_page (0, 4, 0);
4251   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4252     { 
4253       return \"BNH      %l0\";
4254     }
4255   mvs_check_page (0, 2, 4);
4256   return \"L    14,=A(%l0)\;BNHR        14\";
4258   [(set_attr "length" "6")]
4261 (define_insn ""
4262   [(set (pc)
4263         (if_then_else (lt (cc0)
4264                           (const_int 0))
4265                       (pc)
4266                       (label_ref (match_operand 0 "" ""))))
4267 ;   (clobber (reg:SI 14))
4268    ]
4269   ""
4270   "*
4272   check_label_emit ();
4273   mvs_check_page (0, 4, 0);
4274   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4275     { 
4276       return \"BNL      %l0\";
4277     }
4278   mvs_check_page (0, 2, 4);
4279   return \"L    14,=A(%l0)\;BNLR        14\";
4281   [(set_attr "length" "6")]
4284 (define_insn ""
4285   [(set (pc)
4286         (if_then_else (ltu (cc0)
4287                            (const_int 0))
4288                       (pc)
4289                       (label_ref (match_operand 0 "" ""))))
4290 ;   (clobber (reg:SI 14))
4291    ]
4292   ""
4293   "*
4295   check_label_emit ();
4296   mvs_check_page (0, 4, 0);
4297   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4298     { 
4299       return \"BNL      %l0\";
4300     }
4301   mvs_check_page (0, 2, 4);
4302   return \"L    14,=A(%l0)\;BNLR        14\";
4304   [(set_attr "length" "6")]
4307 (define_insn ""
4308   [(set (pc)
4309         (if_then_else (ge (cc0)
4310                           (const_int 0))
4311                       (pc)
4312                       (label_ref (match_operand 0 "" ""))))
4313 ;   (clobber (reg:SI 14))
4314    ]
4315   ""
4316   "*
4318   check_label_emit ();
4319   mvs_check_page (0, 4, 0);
4320   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4321     { 
4322       return \"BL       %l0\";
4323     }
4324   mvs_check_page (0, 2, 4);
4325   return \"L    14,=A(%l0)\;BLR 14\";
4327   [(set_attr "length" "6")]
4330 (define_insn ""
4331   [(set (pc)
4332         (if_then_else (geu (cc0)
4333                            (const_int 0))
4334                       (pc)
4335                       (label_ref (match_operand 0 "" ""))))
4336 ;   (clobber (reg:SI 14))
4337    ]
4338   ""
4339   "*
4341   check_label_emit ();
4342   mvs_check_page (0, 4, 0);
4343   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4344     { 
4345       return \"BL       %l0\";
4346     }
4347   mvs_check_page (0, 2, 4);
4348   return \"L    14,=A(%l0)\;BLR 14\";
4350   [(set_attr "length" "6")]
4353 (define_insn ""
4354   [(set (pc)
4355         (if_then_else (le (cc0)
4356                           (const_int 0))
4357                       (pc)
4358                       (label_ref (match_operand 0 "" ""))))
4359 ;   (clobber (reg:SI 14))
4360    ]
4361   ""
4362   "*
4364   check_label_emit ();
4365   mvs_check_page (0, 4, 0);
4366   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4367     { 
4368       return \"BH       %l0\";
4369     }
4370   mvs_check_page (0, 2, 4);
4371   return \"L    14,=A(%l0)\;BHR 14\";
4373   [(set_attr "length" "6")]
4376 (define_insn ""
4377   [(set (pc)
4378         (if_then_else (leu (cc0)
4379                            (const_int 0))
4380                       (pc)
4381                       (label_ref (match_operand 0 "" ""))))
4382 ;   (clobber (reg:SI 14))
4383    ]
4384   ""
4385   "*
4387   check_label_emit ();
4388   mvs_check_page (0, 4, 0);
4389   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4390     { 
4391       return \"BH       %l0\";
4392     }
4393   mvs_check_page (0, 2, 4);
4394   return \"L    14,=A(%l0)\;BHR 14\";
4396   [(set_attr "length" "6")]
4399 ;; ==============================================================
4400 ;;- Subtract one and jump if not zero.
4401 ;; These insns seem to not be getting matched ...
4402 ;; XXX should fix this, as it would improve for loops
4404 (define_insn ""
4405   [(set (pc)
4406         (if_then_else
4407          (ne (plus:SI (match_operand:SI 0 "register_operand" "+d")
4408                       (const_int -1))
4409              (const_int 0))
4410          (label_ref (match_operand 1 "" ""))
4411          (pc)))
4412    (set (match_dup 0)
4413         (plus:SI (match_dup 0)
4414                  (const_int -1)))
4415 ;   (clobber (reg:SI 14))
4416    ]
4417   ""
4418   "*
4420   check_label_emit ();
4421   mvs_check_page (0, 4, 0);
4422   if (mvs_check_label (CODE_LABEL_NUMBER (operands[1])))
4423     {
4424       return \"BCT      %0,%l1\";
4425     }
4426   mvs_check_page (0, 2, 4);
4427   return \"L    14,=A(%l1)\;BCTR        %0,14\";
4429   [(set_attr "length" "6")]
4432 (define_insn ""
4433   [(set (pc)
4434         (if_then_else
4435          (eq (plus:SI (match_operand:SI 0 "register_operand" "+d")
4436                       (const_int -1))
4437              (const_int 0))
4438          (pc)
4439          (label_ref (match_operand 1 "" ""))))
4440    (set (match_dup 0)
4441         (plus:SI (match_dup 0)
4442                  (const_int -1)))
4443 ;   (clobber (reg:SI 14))
4444    ]
4445   ""
4446   "*
4448   check_label_emit ();
4449   mvs_check_page (0, 4, 0);
4450   if (mvs_check_label (CODE_LABEL_NUMBER (operands[1])))
4451     {
4452       return \"BCT      %0,%l1\";
4453     }
4454   mvs_check_page (0, 2, 4);
4455   return \"L    14,=A(%l1)\;BCTR        %0,14\";
4457   [(set_attr "length" "6")]
4460 ;; =============================================================
4461 ;;- Unconditional jump instructions.
4465 ; jump instruction pattern(s).
4468 (define_insn "jump"
4469   [(set (pc)
4470         (label_ref (match_operand 0 "" "")))
4471 ;   (clobber (reg:SI 14))
4472    ]
4473   ""
4474   "*
4476   check_label_emit ();
4477   mvs_check_page (0, 4, 0);
4478   if (i370_short_branch(insn) || mvs_check_label (CODE_LABEL_NUMBER (operands[0])))
4479     {
4480       return \"B        %l0\";
4481     }
4482   mvs_check_page (0, 2, 4);
4483   return \"L    14,=A(%l0)\;BR  14\";
4485   [(set_attr "length" "6")]
4489 ; indirect-jump instruction pattern(s).
4490 ; hack alert -- should check that displacement is < 4096
4492 (define_insn "indirect_jump"
4493   [(set (pc) (match_operand:SI 0 "general_operand" "rm"))]
4494   ""
4495   "*
4497   check_label_emit ();
4498   if (REG_P (operands[0]))
4499     {
4500       mvs_check_page (0, 2, 0);
4501       return \"BR       %0\";
4502     }
4503   mvs_check_page (0, 4, 0);
4504   return \"B    %0\";
4506   [(set_attr "length" "4")]
4510 ; tablejump instruction pattern(s).
4513 (define_insn "tablejump"
4514   [(set (pc)
4515         (match_operand:SI 0 "general_operand" "am"))
4516    (use (label_ref (match_operand 1 "" "")))
4517 ;   (clobber (reg:SI 14))
4518    ]
4519   ""
4520   "*
4522   check_label_emit ();
4523   if (REG_P (operands[0]))
4524     {
4525       mvs_check_page (0, 6, 0);
4526       return \"BR       %0\;DS  0F\";
4527     }
4528   mvs_check_page (0, 10, 0);
4529   return \"L    14,%0\;BR       14\;DS  0F\";
4531   [(set_attr "length" "10")]
4535 ;;- Jump to subroutine.
4537 ;; For the C/370 environment the internal functions, ie. sqrt, are called with
4538 ;; a non-standard form.  So, we must fix it here.  There's no BM like IBM.
4540 ;; The ELF ABI is different from the C/370 ABI because we have a simpler,
4541 ;; more powerful way of dealing with structure-value returns.  Basically, 
4542 ;; we use R1 to point at structure returns (64-bit and larger returns)
4543 ;; and R11 to point at the args.  Note that this handles double-precision
4544 ;; (64-bit) values just fine, in a less-kludged manner than the C/370 ABI.
4545 ;; Since R1 is used, we use R2 to pass the argument pointer to the routine.
4548 ; call instruction pattern(s).
4550 ; We define four call instruction patterns below. The first two patterns,
4551 ; although general, end up matching (only?) calls through function pointers.  
4552 ; The last two, which require a symbol-ref to match, get used for all
4553 ; ordinary subroutine calls.
4555 (define_insn "call"
4556   [(call (match_operand:QI 0 "memory_operand" "m")
4557          (match_operand:SI 1 "immediate_operand" "i"))
4558    (clobber (reg:SI 2))
4559    ]
4560   ""
4561   "*
4563   static char temp[128];
4564   int i = STACK_POINTER_OFFSET;
4565   CC_STATUS_INIT;
4567   check_label_emit ();
4568 #ifdef TARGET_ELF_ABI
4569   mvs_check_page (0, 10, 4);
4570   sprintf ( temp, \"LA  r2,%d(,sp)\;LA  15,%%0\;BASR    14,15\", i );
4571   return temp;
4572 #else
4573   if (mvs_function_check (XSTR (operands[0], 0)))
4574     {
4575       mvs_check_page (0, 22, 4);
4576       sprintf ( temp, \"LA      1,136(,13)\;ST  1,%d(,13)\;LA 1,%d(,13)\;LA     15,%%0\;BALR    14,15\;LD       0,136(,13)\",
4577              i - 4, i - 4 );
4578     }
4579   else
4580     {
4581       mvs_check_page (0, 10, 4);
4582       sprintf ( temp, \"LA      1,%d(,13)\;LA   15,%%0\;BALR    14,15\", i );
4583     }
4584   return temp;
4585 #endif
4587   [(set_attr "length" "22")]
4591 ; call_value instruction pattern(s).
4594 (define_insn "call_value"
4595   [(set (match_operand 0 "" "=rf")
4596         (call (match_operand:QI 1 "memory_operand" "m")
4597               (match_operand:SI 2 "general_operand" "i")))
4598    (clobber (reg:SI 2))
4599    ]
4600   ""
4601   "*
4603   static char temp[128];
4604   int i = STACK_POINTER_OFFSET;
4605   CC_STATUS_INIT;
4607   check_label_emit ();
4608 #ifdef TARGET_ELF_ABI
4609   mvs_check_page (0, 10, 4);
4610   sprintf ( temp, \"LA  r2,%d(,sp)\;LA  15,%%1\;BASR    14,15\", i );
4611   return temp;
4612 #else
4613   if (mvs_function_check (XSTR (operands[1], 0)))
4614     {
4615       mvs_check_page (0, 22, 4);
4616       sprintf ( temp, \"LA      1,136(,13)\;ST  1,%d(,13)\;LA 1,%d(,13)\;LA     15,%%1\;BALR    14,15\;LD       0,136(,13)\",
4617            i - 4, i - 4 );
4618     }
4619   else
4620     {
4621       mvs_check_page (0, 10, 4);
4622       sprintf ( temp, \"LA      1,%d(,13)\;LA   15,%%1\;BALR    14,15\", i );
4623     }
4624   return temp;
4625 #endif
4627   [(set_attr "length" "22")]
4630 (define_insn ""
4631   [(call (mem:QI (match_operand:SI 0 "" "i"))
4632          (match_operand:SI 1 "general_operand" "g"))
4633    (clobber (reg:SI 2))
4634    ]
4635   "GET_CODE (operands[0]) == SYMBOL_REF"
4636   "*
4638   static char temp[128];
4639   int i = STACK_POINTER_OFFSET;
4640   CC_STATUS_INIT;
4642   check_label_emit ();
4643 #ifdef TARGET_ELF_ABI
4644   mvs_check_page (0, 10, 4);
4645   sprintf ( temp, \"LA  r2,%d(,sp)\;L   15,%%0\;BASR    14,15\", i );
4646   return temp;
4647 #else
4648   if (mvs_function_check (XSTR (operands[0], 0)))
4649     {
4650       mvs_check_page (0, 22, 4);
4651       sprintf ( temp, \"LA      1,136(,13)\;ST  1,%d(,13)\;LA   1,%d(,13)\;L    15,%%0\;BALR    14,15\;LD       0,136(,13)\",
4652            i - 4, i - 4 );
4653     }
4654   else
4655     {
4656       mvs_check_page (0, 10, 4);
4657       sprintf ( temp, \"LA      1,%d(,13)\;L    15,%%0\;BALR    14,15\", i );
4658     }
4659   return temp;
4660 #endif
4662   [(set_attr "length" "22")]
4665 (define_insn ""
4666   [(set (match_operand 0 "" "=rf")
4667         (call (mem:QI (match_operand:SI 1 "" "i"))
4668               (match_operand:SI 2 "general_operand" "g")))
4669    (clobber (reg:SI 2))
4670    ]
4671   "GET_CODE (operands[1]) == SYMBOL_REF"
4672   "*
4674   static char temp[128];
4675   int i = STACK_POINTER_OFFSET;
4676   CC_STATUS_INIT;
4678   check_label_emit ();
4679 #ifdef TARGET_ELF_ABI
4680   mvs_check_page (0, 10, 4);
4681   sprintf ( temp, \"LA  r2,%d(,sp)\;L   15,%%1\;BASR    14,15\", i );
4682   return temp;
4683 #else
4684   if (mvs_function_check (XSTR (operands[1], 0)))
4685     {
4686       mvs_check_page (0, 22, 4);
4687       sprintf ( temp, \"LA      1,136(,13)\;ST  1,%d(,13)\;LA   1,%d(,13)\;L    15,%%1\;BALR    14,15\;LD       0,136(,13)\",
4688            i - 4, i - 4 );
4689     }
4690   else
4691     {
4692       mvs_check_page (0, 10, 4);
4693       sprintf ( temp, \"LA      1,%d(,13)\;L    15,%%1\;BALR    14,15\", i );
4694     }
4695   return temp;
4696 #endif
4698   [(set_attr "length" "22")]
4702 ;; Call subroutine returning any type.
4703 ;; This instruction pattern appears to be used only by the
4704 ;; expand_builtin_apply definition for __builtin_apply.  It is needed
4705 ;; since call_value might return an in in r15 or a float in fpr0 (r16)
4706 ;; and the builtin code calla abort since the reg is ambiguous. Well,
4707 ;; the below is probably broken anyway, we just want to go for now.
4709 (define_expand "untyped_call"
4710 [(parallel [(call (match_operand 0 "" "")
4711                   (const_int 0))
4712               (match_operand 1 "" "")
4713               (match_operand 2 "" "")])]
4714   ""
4715   "
4717   int i;
4719   emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
4721   for (i = 0; i < XVECLEN (operands[2], 0); i++)
4722     {
4723       rtx set = XVECEXP (operands[2], 0, i);
4724       emit_move_insn (SET_DEST (set), SET_SRC (set));
4725     }
4727   /* The optimizer does not know that the call sets the function value
4728      registers we stored in the result block.  We avoid problems by
4729      claiming that all hard registers are used and clobbered at this
4730      point.  */
4731   /* emit_insn (gen_blockage ()); */
4733   DONE;
4738 ;;- Miscellaneous instructions.
4742 ; nop instruction pattern(s).
4745 (define_insn "nop"
4746   [(const_int 0)]
4747   ""
4748   "*
4750   check_label_emit ();
4751   mvs_check_page (0, 2, 0);
4752   return \"LR   0,0\";
4754   [(set_attr "length" "2")]