1 ;;- Machine description for GNU compiler -- S/390 / zSeries version.
2 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
3 ;; Free Software Foundation, Inc.
4 ;; Contributed by Hartmut Penner (hpenner@de.ibm.com) and
5 ;; Ulrich Weigand (uweigand@de.ibm.com).
7 ;; This file is part of GCC.
9 ;; GCC is free software; you can redistribute it and/or modify it under
10 ;; the terms of the GNU General Public License as published by the Free
11 ;; Software Foundation; either version 2, or (at your option) any later
14 ;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING. If not, write to the Free
21 ;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
25 ;; See constraints.md for a description of constraints specific to s390.
28 ;; Special formats used for outputting 390 instructions.
30 ;; %C: print opcode suffix for branch condition.
31 ;; %D: print opcode suffix for inverse branch condition.
32 ;; %J: print tls_load/tls_gdcall/tls_ldcall suffix
33 ;; %G: print the size of the operand in bytes.
34 ;; %O: print only the displacement of a memory reference.
35 ;; %R: print only the base register of a memory reference.
36 ;; %S: print S-type memory reference (base+displacement).
37 ;; %N: print the second word of a DImode operand.
38 ;; %M: print the second word of a TImode operand.
39 ;; %Y: print shift count operand.
41 ;; %b: print integer X as if it's an unsigned byte.
42 ;; %x: print integer X as if it's an unsigned halfword.
43 ;; %h: print integer X as if it's a signed halfword.
44 ;; %i: print the first nonzero HImode part of X.
45 ;; %j: print the first HImode part unequal to -1 of X.
46 ;; %k: print the first nonzero SImode part of X.
47 ;; %m: print the first SImode part unequal to -1 of X.
48 ;; %o: print integer X as if it's an unsigned 32bit word.
50 ;; We have a special constraint for pattern matching.
52 ;; s_operand -- Matches a valid S operand in a RS, SI or SS type instruction.
65 ; GOT/PLT and lt-relative accesses
66 (UNSPEC_LTREL_OFFSET 100)
67 (UNSPEC_LTREL_BASE 101)
75 (UNSPEC_RELOAD_BASE 210)
76 (UNSPEC_MAIN_BASE 211)
81 ; TLS relocation specifiers
86 (UNSPEC_GOTNTPOFF 504)
87 (UNSPEC_INDNTPOFF 505)
90 (UNSPEC_TLSLDM_NTPOFF 511)
97 ; Stack Smashing Protector
101 ; Copy sign instructions
102 (UNSPEC_COPYSIGN 800)
106 ;; UNSPEC_VOLATILE usage
114 (UNSPECV_TPF_PROLOGUE 20)
115 (UNSPECV_TPF_EPILOGUE 21)
119 (UNSPECV_POOL_SECTION 201)
120 (UNSPECV_POOL_ALIGN 202)
121 (UNSPECV_POOL_ENTRY 203)
122 (UNSPECV_MAIN_POOL 300)
138 ; Sibling call register.
140 ; Literal pool base register.
142 ; Return address register.
144 ; Condition code register.
146 ; Thread local storage pointer register.
151 ;; Instruction operand type as used in the Principles of Operation.
152 ;; Used to determine defaults for length and other attribute values.
154 (define_attr "op_type"
155 "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY,RRF,RRR"
158 ;; Instruction type attribute used for scheduling.
160 (define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
161 cs,vs,store,sem,idiv,
162 imulhi,imulsi,imuldi,
163 branch,jsr,fsimptf,fsimpdf,fsimpsf,
164 floadtf,floaddf,floadsf,fstoredf,fstoresf,
165 fmultf,fmuldf,fmulsf,fdivtf,fdivdf,fdivsf,
166 ftoi,itof,fsqrttf,fsqrtdf,fsqrtsf,
167 ftrunctf,ftruncdf,other"
168 (cond [(eq_attr "op_type" "NN") (const_string "other")
169 (eq_attr "op_type" "SS") (const_string "cs")]
170 (const_string "integer")))
172 ;; Another attribute used for scheduling purposes:
173 ;; agen: Instruction uses the address generation unit
174 ;; reg: Instruction does not use the agen unit
176 (define_attr "atype" "agen,reg"
177 (if_then_else (eq_attr "op_type" "E,RR,RI,RRE")
179 (const_string "agen")))
183 (define_attr "length" ""
184 (cond [(eq_attr "op_type" "E,RR") (const_int 2)
185 (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI") (const_int 4)]
189 ;; Processor type. This attribute must exactly match the processor_type
190 ;; enumeration in s390.h. The current machine description does not
191 ;; distinguish between g5 and g6, but there are differences between the two
192 ;; CPUs could in theory be modeled.
194 (define_attr "cpu" "g5,g6,z900,z990,z9_109"
195 (const (symbol_ref "s390_tune")))
197 ;; Pipeline description for z900. For lack of anything better,
198 ;; this description is also used for the g5 and g6.
201 ;; Pipeline description for z990, z9-109 and z9-ec.
205 (include "predicates.md")
207 ;; Constraint definitions
208 (include "constraints.md")
215 ;; This mode macro allows floating point patterns to be generated from the
217 (define_mode_macro FP [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")])
218 (define_mode_macro BFP [TF DF SF])
219 (define_mode_macro DFP [TD DD])
220 (define_mode_macro DSF [DF SF])
221 (define_mode_macro SD_SF [SF SD])
222 (define_mode_macro DD_DF [DF DD])
223 (define_mode_macro TD_TF [TF TD])
225 ;; These mode macros allow 31-bit and 64-bit TDSI patterns to be generated
226 ;; from the same template.
227 (define_mode_macro TDSI [(TI "TARGET_64BIT") DI SI])
229 ;; These mode macros allow 31-bit and 64-bit GPR patterns to be generated
230 ;; from the same template.
231 (define_mode_macro GPR [(DI "TARGET_64BIT") SI])
232 (define_mode_macro DSI [DI SI])
234 ;; This mode macro allows :P to be used for patterns that operate on
235 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
236 (define_mode_macro DP [(TI "TARGET_64BIT") (DI "!TARGET_64BIT")])
237 (define_mode_macro P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
239 ;; This mode macro allows the QI and HI patterns to be defined from
240 ;; the same template.
241 (define_mode_macro HQI [HI QI])
243 ;; This mode macro allows the integer patterns to be defined from the
245 (define_mode_macro INT [(DI "TARGET_64BIT") SI HI QI])
247 ;; This macro allows to unify all 'bCOND' expander patterns.
248 (define_code_macro COMPARE [eq ne gt gtu lt ltu ge geu le leu unordered
249 ordered uneq unlt ungt unle unge ltgt])
251 ;; This macro allows to unify all 'sCOND' patterns.
252 (define_code_macro SCOND [ltu gtu leu geu])
254 ;; This macro allows some 'ashift' and 'lshiftrt' pattern to be defined from
255 ;; the same template.
256 (define_code_macro SHIFT [ashift lshiftrt])
258 ;; These macros allow to combine most atomic operations.
259 (define_code_macro ATOMIC [and ior xor plus minus mult])
260 (define_code_attr atomic [(and "and") (ior "ior") (xor "xor")
261 (plus "add") (minus "sub") (mult "nand")])
263 ;; In FP templates, a string like "lt<de>br" will expand to "ltxbr" in
264 ;; TF/TDmode, "ltdbr" in DF/DDmode, and "ltebr" in SF/SDmode.
265 (define_mode_attr xde [(TF "x") (DF "d") (SF "e") (TD "x") (DD "d") (SD "e")])
267 ;; In FP templates, a <dee> in "m<dee><bt>r" will expand to "mx<bt>r" in
268 ;; TF/TDmode, "md<bt>r" in DF/DDmode, "mee<bt>r" in SFmode and "me<bt>r in
270 (define_mode_attr xdee [(TF "x") (DF "d") (SF "ee") (TD "x") (DD "d") (SD "e")])
272 ;; In FP templates, "<RRe>" will expand to "RRE" in TFmode and "RR" otherwise.
273 ;; Likewise for "<RXe>".
274 (define_mode_attr RRe [(TF "RRE") (DF "RR") (SF "RR")])
275 (define_mode_attr RXe [(TF "RXE") (DF "RX") (SF "RX")])
277 ;; The decimal floating point variants of add, sub, div and mul support 3
278 ;; fp register operands. The following macros allow to merge the bfp and
279 ;; dfp variants in a single insn definition.
281 ;; This macro is used to set op_type accordingly.
282 (define_mode_attr RRer [(TF "RRE") (DF "RRE") (SF "RRE") (TD "RRR")
283 (DD "RRR") (SD "RRR")])
285 ;; This macro is used in the operand constraint list in order to have the
286 ;; first and the second operand match for bfp modes.
287 (define_mode_attr f0 [(TF "0") (DF "0") (SF "0") (TD "f") (DD "f") (DD "f")])
289 ;; This macro is used in the operand list of the instruction to have an
290 ;; additional operand for the dfp instructions.
291 (define_mode_attr op1 [(TF "") (DF "") (SF "")
292 (TD "%1,") (DD "%1,") (SD "%1,")])
295 ;; This attribute is used in the operand constraint list
296 ;; for instructions dealing with the sign bit of 32 or 64bit fp values.
297 ;; TFmode values are represented by a fp register pair. Since the
298 ;; sign bit instructions only handle single source and target fp registers
299 ;; these instructions can only be used for TFmode values if the source and
300 ;; target operand uses the same fp register.
301 (define_mode_attr fT0 [(TF "0") (DF "f") (SF "f")])
303 ;; In FP templates, "<Rf>" will expand to "f" in TFmode and "R" otherwise.
304 ;; This is used to disable the memory alternative in TFmode patterns.
305 (define_mode_attr Rf [(TF "f") (DF "R") (SF "R") (TD "f") (DD "f") (SD "f")])
307 ;; This macro adds b for bfp instructions and t for dfp instructions and is used
308 ;; within instruction mnemonics.
309 (define_mode_attr bt [(TF "b") (DF "b") (SF "b") (TD "t") (DD "t") (SD "t")])
311 ;; Although it is unprecise for z9-ec we handle all dfp instructions like
312 ;; bfp regarding the pipeline description.
313 (define_mode_attr bfp [(TF "tf") (DF "df") (SF "sf")
314 (TD "tf") (DD "df") (SD "sf")])
317 ;; In GPR and P templates, a constraint like "<d0>" will expand to "d" in DImode
318 ;; and "0" in SImode. This allows to combine instructions of which the 31bit
319 ;; version only operates on one register.
320 (define_mode_attr d0 [(DI "d") (SI "0")])
322 ;; In combination with d0 this allows to combine instructions of which the 31bit
323 ;; version only operates on one register. The DImode version needs an additional
324 ;; register for the assembler output.
325 (define_mode_attr 1 [(DI "%1,") (SI "")])
327 ;; In SHIFT templates, a string like "s<lr>dl" will expand to "sldl" in
328 ;; 'ashift' and "srdl" in 'lshiftrt'.
329 (define_code_attr lr [(ashift "l") (lshiftrt "r")])
331 ;; In SHIFT templates, this attribute holds the correct standard name for the
332 ;; pattern itself and the corresponding function calls.
333 (define_code_attr shift [(ashift "ashl") (lshiftrt "lshr")])
335 ;; This attribute handles differences in the instruction 'type' and will result
336 ;; in "RRE" for DImode and "RR" for SImode.
337 (define_mode_attr E [(DI "E") (SI "")])
339 ;; This attribute handles differences in the instruction 'type' and makes RX<Y>
340 ;; to result in "RXY" for DImode and "RX" for SImode.
341 (define_mode_attr Y [(DI "Y") (SI "")])
343 ;; This attribute handles differences in the instruction 'type' and will result
344 ;; in "RSE" for TImode and "RS" for DImode.
345 (define_mode_attr TE [(TI "E") (DI "")])
347 ;; In GPR templates, a string like "lc<g>r" will expand to "lcgr" in DImode
348 ;; and "lcr" in SImode.
349 (define_mode_attr g [(DI "g") (SI "")])
351 ;; In GPR templates, a string like "sl<y>" will expand to "slg" in DImode
352 ;; and "sly" in SImode. This is useful because on 64bit the ..g instructions
353 ;; were enhanced with long displacements whereas 31bit instructions got a ..y
354 ;; variant for long displacements.
355 (define_mode_attr y [(DI "g") (SI "y")])
357 ;; In DP templates, a string like "cds<g>" will expand to "cdsg" in TImode
358 ;; and "cds" in DImode.
359 (define_mode_attr tg [(TI "g") (DI "")])
361 ;; In GPR templates, a string like "c<gf>dbr" will expand to "cgdbr" in DImode
362 ;; and "cfdbr" in SImode.
363 (define_mode_attr gf [(DI "g") (SI "f")])
365 ;; ICM mask required to load MODE value into the lowest subreg
366 ;; of a SImode register.
367 (define_mode_attr icm_lo [(HI "3") (QI "1")])
369 ;; In HQI templates, a string like "llg<hc>" will expand to "llgh" in
370 ;; HImode and "llgc" in QImode.
371 (define_mode_attr hc [(HI "h") (QI "c")])
373 ;; In P templates, the mode <DBL> will expand to "TI" in DImode and "DI"
375 (define_mode_attr DBL [(DI "TI") (SI "DI")])
377 ;; This attribute expands to DF for TFmode and to DD for TDmode . It is
378 ;; used for Txmode splitters splitting a Txmode copy into 2 Dxmode copies.
379 (define_mode_attr HALF_TMODE [(TF "DF") (TD "DD")])
381 ;; Maximum unsigned integer that fits in MODE.
382 (define_mode_attr max_uint [(HI "65535") (QI "255")])
386 ;;- Compare instructions.
389 (define_expand "cmp<mode>"
390 [(set (reg:CC CC_REGNUM)
391 (compare:CC (match_operand:GPR 0 "register_operand" "")
392 (match_operand:GPR 1 "general_operand" "")))]
395 s390_compare_op0 = operands[0];
396 s390_compare_op1 = operands[1];
400 (define_expand "cmp<mode>"
401 [(set (reg:CC CC_REGNUM)
402 (compare:CC (match_operand:FP 0 "register_operand" "")
403 (match_operand:FP 1 "general_operand" "")))]
406 s390_compare_op0 = operands[0];
407 s390_compare_op1 = operands[1];
412 ; Test-under-Mask instructions
414 (define_insn "*tmqi_mem"
415 [(set (reg CC_REGNUM)
416 (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
417 (match_operand:QI 1 "immediate_operand" "n,n"))
418 (match_operand:QI 2 "immediate_operand" "n,n")))]
419 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], false))"
423 [(set_attr "op_type" "SI,SIY")])
425 (define_insn "*tmdi_reg"
426 [(set (reg CC_REGNUM)
427 (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
428 (match_operand:DI 1 "immediate_operand"
429 "N0HD0,N1HD0,N2HD0,N3HD0"))
430 (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
432 && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
433 && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
439 [(set_attr "op_type" "RI")])
441 (define_insn "*tmsi_reg"
442 [(set (reg CC_REGNUM)
443 (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
444 (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
445 (match_operand:SI 2 "immediate_operand" "n,n")))]
446 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
447 && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
451 [(set_attr "op_type" "RI")])
453 (define_insn "*tm<mode>_full"
454 [(set (reg CC_REGNUM)
455 (compare (match_operand:HQI 0 "register_operand" "d")
456 (match_operand:HQI 1 "immediate_operand" "n")))]
457 "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], true))"
459 [(set_attr "op_type" "RI")])
463 ; Load-and-Test instructions
466 ; tst(di|si) instruction pattern(s).
468 (define_insn "*tstdi_sign"
469 [(set (reg CC_REGNUM)
470 (compare (ashiftrt:DI (ashift:DI (subreg:DI (match_operand:SI 0 "register_operand" "d") 0)
471 (const_int 32)) (const_int 32))
472 (match_operand:DI 1 "const0_operand" "")))
473 (set (match_operand:DI 2 "register_operand" "=d")
474 (sign_extend:DI (match_dup 0)))]
475 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
477 [(set_attr "op_type" "RRE")])
480 (define_insn "*tst<mode>_extimm"
481 [(set (reg CC_REGNUM)
482 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,m")
483 (match_operand:GPR 1 "const0_operand" "")))
484 (set (match_operand:GPR 2 "register_operand" "=d,d")
486 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
490 [(set_attr "op_type" "RR<E>,RXY")])
493 (define_insn "*tst<mode>_cconly_extimm"
494 [(set (reg CC_REGNUM)
495 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,m")
496 (match_operand:GPR 1 "const0_operand" "")))
497 (clobber (match_scratch:GPR 2 "=X,d"))]
498 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
502 [(set_attr "op_type" "RR<E>,RXY")])
504 (define_insn "*tstdi"
505 [(set (reg CC_REGNUM)
506 (compare (match_operand:DI 0 "register_operand" "d")
507 (match_operand:DI 1 "const0_operand" "")))
508 (set (match_operand:DI 2 "register_operand" "=d")
510 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT && !TARGET_EXTIMM"
512 [(set_attr "op_type" "RRE")])
514 (define_insn "*tstsi"
515 [(set (reg CC_REGNUM)
516 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
517 (match_operand:SI 1 "const0_operand" "")))
518 (set (match_operand:SI 2 "register_operand" "=d,d,d")
520 "s390_match_ccmode(insn, CCSmode) && !TARGET_EXTIMM"
525 [(set_attr "op_type" "RR,RS,RSY")])
527 (define_insn "*tstsi_cconly"
528 [(set (reg CC_REGNUM)
529 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
530 (match_operand:SI 1 "const0_operand" "")))
531 (clobber (match_scratch:SI 2 "=X,d,d"))]
532 "s390_match_ccmode(insn, CCSmode)"
537 [(set_attr "op_type" "RR,RS,RSY")])
539 (define_insn "*tstdi_cconly_31"
540 [(set (reg CC_REGNUM)
541 (compare (match_operand:DI 0 "register_operand" "d")
542 (match_operand:DI 1 "const0_operand" "")))]
543 "s390_match_ccmode(insn, CCSmode) && !TARGET_64BIT"
545 [(set_attr "op_type" "RS")
546 (set_attr "atype" "reg")])
549 (define_insn "*tst<mode>_cconly2"
550 [(set (reg CC_REGNUM)
551 (compare (match_operand:GPR 0 "register_operand" "d")
552 (match_operand:GPR 1 "const0_operand" "")))]
553 "s390_match_ccmode(insn, CCSmode)"
555 [(set_attr "op_type" "RR<E>")])
557 ; tst(hi|qi) instruction pattern(s).
559 (define_insn "*tst<mode>CCT"
560 [(set (reg CC_REGNUM)
561 (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
562 (match_operand:HQI 1 "const0_operand" "")))
563 (set (match_operand:HQI 2 "register_operand" "=d,d,0")
565 "s390_match_ccmode(insn, CCTmode)"
568 icmy\t%2,<icm_lo>,%S0
570 [(set_attr "op_type" "RS,RSY,RI")])
572 (define_insn "*tsthiCCT_cconly"
573 [(set (reg CC_REGNUM)
574 (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
575 (match_operand:HI 1 "const0_operand" "")))
576 (clobber (match_scratch:HI 2 "=d,d,X"))]
577 "s390_match_ccmode(insn, CCTmode)"
582 [(set_attr "op_type" "RS,RSY,RI")])
584 (define_insn "*tstqiCCT_cconly"
585 [(set (reg CC_REGNUM)
586 (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
587 (match_operand:QI 1 "const0_operand" "")))]
588 "s390_match_ccmode(insn, CCTmode)"
593 [(set_attr "op_type" "SI,SIY,RI")])
595 (define_insn "*tst<mode>"
596 [(set (reg CC_REGNUM)
597 (compare (match_operand:HQI 0 "s_operand" "Q,S")
598 (match_operand:HQI 1 "const0_operand" "")))
599 (set (match_operand:HQI 2 "register_operand" "=d,d")
601 "s390_match_ccmode(insn, CCSmode)"
604 icmy\t%2,<icm_lo>,%S0"
605 [(set_attr "op_type" "RS,RSY")])
607 (define_insn "*tst<mode>_cconly"
608 [(set (reg CC_REGNUM)
609 (compare (match_operand:HQI 0 "s_operand" "Q,S")
610 (match_operand:HQI 1 "const0_operand" "")))
611 (clobber (match_scratch:HQI 2 "=d,d"))]
612 "s390_match_ccmode(insn, CCSmode)"
615 icmy\t%2,<icm_lo>,%S0"
616 [(set_attr "op_type" "RS,RSY")])
619 ; Compare (equality) instructions
621 (define_insn "*cmpdi_cct"
622 [(set (reg CC_REGNUM)
623 (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,d,Q")
624 (match_operand:DI 1 "general_operand" "d,K,Os,m,BQ")))]
625 "s390_match_ccmode (insn, CCTmode) && TARGET_64BIT"
632 [(set_attr "op_type" "RRE,RI,RIL,RXY,SS")])
634 (define_insn "*cmpsi_cct"
635 [(set (reg CC_REGNUM)
636 (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,d,Q")
637 (match_operand:SI 1 "general_operand" "d,K,Os,R,T,BQ")))]
638 "s390_match_ccmode (insn, CCTmode)"
646 [(set_attr "op_type" "RR,RI,RIL,RX,RXY,SS")])
649 ; Compare (signed) instructions
651 (define_insn "*cmpdi_ccs_sign"
652 [(set (reg CC_REGNUM)
653 (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m"))
654 (match_operand:DI 0 "register_operand" "d,d")))]
655 "s390_match_ccmode(insn, CCSRmode) && TARGET_64BIT"
659 [(set_attr "op_type" "RRE,RXY")])
661 (define_insn "*cmpsi_ccs_sign"
662 [(set (reg CC_REGNUM)
663 (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T"))
664 (match_operand:SI 0 "register_operand" "d,d")))]
665 "s390_match_ccmode(insn, CCSRmode)"
669 [(set_attr "op_type" "RX,RXY")])
671 ; cr, chi, cfi, c, cy, cgr, cghi, cgfi, cg
672 (define_insn "*cmp<mode>_ccs"
673 [(set (reg CC_REGNUM)
674 (compare (match_operand:GPR 0 "register_operand" "d,d,d,d,d")
675 (match_operand:GPR 1 "general_operand" "d,K,Os,R,T")))]
676 "s390_match_ccmode(insn, CCSmode)"
683 [(set_attr "op_type" "RR<E>,RI,RIL,RX<Y>,RXY")])
686 ; Compare (unsigned) instructions
688 (define_insn "*cmpdi_ccu_zero"
689 [(set (reg CC_REGNUM)
690 (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m"))
691 (match_operand:DI 0 "register_operand" "d,d")))]
692 "s390_match_ccmode (insn, CCURmode) && TARGET_64BIT"
696 [(set_attr "op_type" "RRE,RXY")])
698 (define_insn "*cmpdi_ccu"
699 [(set (reg CC_REGNUM)
700 (compare (match_operand:DI 0 "nonimmediate_operand" "d,d,d,Q,BQ")
701 (match_operand:DI 1 "general_operand" "d,Op,m,BQ,Q")))]
702 "s390_match_ccmode (insn, CCUmode) && TARGET_64BIT"
709 [(set_attr "op_type" "RRE,RIL,RXY,SS,SS")])
711 (define_insn "*cmpsi_ccu"
712 [(set (reg CC_REGNUM)
713 (compare (match_operand:SI 0 "nonimmediate_operand" "d,d,d,d,Q,BQ")
714 (match_operand:SI 1 "general_operand" "d,Os,R,T,BQ,Q")))]
715 "s390_match_ccmode (insn, CCUmode)"
723 [(set_attr "op_type" "RR,RIL,RX,RXY,SS,SS")])
725 (define_insn "*cmphi_ccu"
726 [(set (reg CC_REGNUM)
727 (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,BQ")
728 (match_operand:HI 1 "general_operand" "Q,S,BQ,Q")))]
729 "s390_match_ccmode (insn, CCUmode)
730 && !register_operand (operands[1], HImode)"
736 [(set_attr "op_type" "RS,RSY,SS,SS")])
738 (define_insn "*cmpqi_ccu"
739 [(set (reg CC_REGNUM)
740 (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
741 (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
742 "s390_match_ccmode (insn, CCUmode)
743 && !register_operand (operands[1], QImode)"
751 [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")])
754 ; Block compare (CLC) instruction patterns.
757 [(set (reg CC_REGNUM)
758 (compare (match_operand:BLK 0 "memory_operand" "Q")
759 (match_operand:BLK 1 "memory_operand" "Q")))
760 (use (match_operand 2 "const_int_operand" "n"))]
761 "s390_match_ccmode (insn, CCUmode)
762 && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
763 "clc\t%O0(%2,%R0),%S1"
764 [(set_attr "op_type" "SS")])
767 [(set (reg CC_REGNUM)
768 (compare (match_operand 0 "memory_operand" "")
769 (match_operand 1 "memory_operand" "")))]
771 && s390_match_ccmode (insn, CCUmode)
772 && GET_MODE (operands[0]) == GET_MODE (operands[1])
773 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
775 [(set (match_dup 0) (match_dup 1))
776 (use (match_dup 2))])]
778 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
779 operands[0] = adjust_address (operands[0], BLKmode, 0);
780 operands[1] = adjust_address (operands[1], BLKmode, 0);
782 operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
783 operands[0], operands[1]);
784 operands[0] = SET_DEST (PATTERN (curr_insn));
788 ; (TF|DF|SF|TD|DD|SD) instructions
790 ; ltxbr, ltdbr, ltebr, ltxtr, ltdtr
791 (define_insn "*cmp<mode>_ccs_0"
792 [(set (reg CC_REGNUM)
793 (compare (match_operand:FP 0 "register_operand" "f")
794 (match_operand:FP 1 "const0_operand" "")))]
795 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
796 "lt<xde><bt>r\t%0,%0"
797 [(set_attr "op_type" "RRE")
798 (set_attr "type" "fsimp<bfp>")])
801 (define_insn "*cmp<mode>_ccs_0_ibm"
802 [(set (reg CC_REGNUM)
803 (compare (match_operand:BFP 0 "register_operand" "f")
804 (match_operand:BFP 1 "const0_operand" "")))]
805 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
807 [(set_attr "op_type" "<RRe>")
808 (set_attr "type" "fsimp<mode>")])
810 ; cxtr, cxbr, cdbr, cebr, cxb, cdb, ceb, cxbtr, cdbtr
811 (define_insn "*cmp<mode>_ccs"
812 [(set (reg CC_REGNUM)
813 (compare (match_operand:FP 0 "register_operand" "f,f")
814 (match_operand:FP 1 "general_operand" "f,<Rf>")))]
815 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
819 [(set_attr "op_type" "RRE,RXE")
820 (set_attr "type" "fsimp<bfp>")])
822 ; cxr, cdr, cer, cx, cd, ce
823 (define_insn "*cmp<mode>_ccs_ibm"
824 [(set (reg CC_REGNUM)
825 (compare (match_operand:BFP 0 "register_operand" "f,f")
826 (match_operand:BFP 1 "general_operand" "f,<Rf>")))]
827 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
831 [(set_attr "op_type" "<RRe>,<RXe>")
832 (set_attr "type" "fsimp<mode>")])
836 ;;- Move instructions.
840 ; movti instruction pattern(s).
844 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,d,o,Q")
845 (match_operand:TI 1 "general_operand" "QS,d,dPm,d,Q"))]
853 [(set_attr "op_type" "RSY,RSY,*,*,SS")
854 (set_attr "type" "lm,stm,*,*,*")])
857 [(set (match_operand:TI 0 "nonimmediate_operand" "")
858 (match_operand:TI 1 "general_operand" ""))]
859 "TARGET_64BIT && reload_completed
860 && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
861 [(set (match_dup 2) (match_dup 4))
862 (set (match_dup 3) (match_dup 5))]
864 operands[2] = operand_subword (operands[0], 0, 0, TImode);
865 operands[3] = operand_subword (operands[0], 1, 0, TImode);
866 operands[4] = operand_subword (operands[1], 0, 0, TImode);
867 operands[5] = operand_subword (operands[1], 1, 0, TImode);
871 [(set (match_operand:TI 0 "nonimmediate_operand" "")
872 (match_operand:TI 1 "general_operand" ""))]
873 "TARGET_64BIT && reload_completed
874 && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
875 [(set (match_dup 2) (match_dup 4))
876 (set (match_dup 3) (match_dup 5))]
878 operands[2] = operand_subword (operands[0], 1, 0, TImode);
879 operands[3] = operand_subword (operands[0], 0, 0, TImode);
880 operands[4] = operand_subword (operands[1], 1, 0, TImode);
881 operands[5] = operand_subword (operands[1], 0, 0, TImode);
885 [(set (match_operand:TI 0 "register_operand" "")
886 (match_operand:TI 1 "memory_operand" ""))]
887 "TARGET_64BIT && reload_completed
888 && !s_operand (operands[1], VOIDmode)"
889 [(set (match_dup 0) (match_dup 1))]
891 rtx addr = operand_subword (operands[0], 1, 0, TImode);
892 s390_load_address (addr, XEXP (operands[1], 0));
893 operands[1] = replace_equiv_address (operands[1], addr);
898 ; Patterns used for secondary reloads
901 ; Handles loading a PLUS (load address) expression
903 (define_expand "reload<mode>_plus"
904 [(parallel [(match_operand:P 0 "register_operand" "=a")
905 (match_operand:P 1 "s390_plus_operand" "")
906 (match_operand:P 2 "register_operand" "=&a")])]
909 s390_expand_plus_operand (operands[0], operands[1], operands[2]);
913 ; Handles assessing a non-offsetable memory address
915 (define_expand "reload<mode>_nonoffmem_in"
916 [(parallel [(match_operand 0 "register_operand" "")
917 (match_operand 1 "" "")
918 (match_operand:P 2 "register_operand" "=&a")])]
921 gcc_assert (MEM_P (operands[1]));
922 s390_load_address (operands[2], find_replacement (&XEXP (operands[1], 0)));
923 operands[1] = replace_equiv_address (operands[1], operands[2]);
924 emit_move_insn (operands[0], operands[1]);
928 (define_expand "reload<mode>_nonoffmem_out"
929 [(parallel [(match_operand 0 "" "")
930 (match_operand 1 "register_operand" "")
931 (match_operand:P 2 "register_operand" "=&a")])]
934 gcc_assert (MEM_P (operands[0]));
935 s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
936 operands[0] = replace_equiv_address (operands[0], operands[2]);
937 emit_move_insn (operands[0], operands[1]);
942 ; movdi instruction pattern(s).
945 (define_expand "movdi"
946 [(set (match_operand:DI 0 "general_operand" "")
947 (match_operand:DI 1 "general_operand" ""))]
950 /* Handle symbolic constants. */
952 && (SYMBOLIC_CONST (operands[1])
953 || (GET_CODE (operands[1]) == PLUS
954 && XEXP (operands[1], 0) == pic_offset_table_rtx
955 && SYMBOLIC_CONST (XEXP (operands[1], 1)))))
956 emit_symbolic_move (operands);
959 (define_insn "*movdi_larl"
960 [(set (match_operand:DI 0 "register_operand" "=d")
961 (match_operand:DI 1 "larl_operand" "X"))]
963 && !FP_REG_P (operands[0])"
965 [(set_attr "op_type" "RIL")
966 (set_attr "type" "larl")])
968 (define_insn "*movdi_64dfp"
969 [(set (match_operand:DI 0 "nonimmediate_operand"
970 "=d,d,d,d,d,d,d,d,f,d,d,d,d,
971 m,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
972 (match_operand:DI 1 "general_operand"
973 "K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,d,m,
974 d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
975 "TARGET_64BIT && TARGET_DFP"
1001 [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RRE,RXY,RXY,
1002 RR,RX,RXY,RX,RXY,*,*,RS,RS,SS")
1003 (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,lr,load,store,
1004 floaddf,floaddf,floaddf,fstoredf,fstoredf,*,*,*,*,*")])
1006 (define_insn "*movdi_64extimm"
1007 [(set (match_operand:DI 0 "nonimmediate_operand"
1008 "=d,d,d,d,d,d,d,d,d,d,d,m,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
1009 (match_operand:DI 1 "general_operand"
1010 "K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,L,d,m,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
1011 "TARGET_64BIT && TARGET_EXTIMM"
1035 [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RXY,RRE,RXY,RXY,
1036 RR,RX,RXY,RX,RXY,*,*,RS,RS,SS")
1037 (set_attr "type" "*,*,*,*,*,*,*,*,la,lr,load,store,
1038 floaddf,floaddf,floaddf,fstoredf,fstoredf,*,*,*,*,*")])
1040 (define_insn "*movdi_64"
1041 [(set (match_operand:DI 0 "nonimmediate_operand"
1042 "=d,d,d,d,d,d,d,d,m,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
1043 (match_operand:DI 1 "general_operand"
1044 "K,N0HD0,N1HD0,N2HD0,N3HD0,L,d,m,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
1045 "TARGET_64BIT && !TARGET_EXTIMM"
1066 [(set_attr "op_type" "RI,RI,RI,RI,RI,RXY,RRE,RXY,RXY,
1067 RR,RX,RXY,RX,RXY,*,*,RS,RS,SS")
1068 (set_attr "type" "*,*,*,*,*,la,lr,load,store,
1069 floaddf,floaddf,floaddf,fstoredf,fstoredf,*,*,*,*,*")])
1072 [(set (match_operand:DI 0 "register_operand" "")
1073 (match_operand:DI 1 "register_operand" ""))]
1074 "TARGET_64BIT && ACCESS_REG_P (operands[1])"
1075 [(set (match_dup 2) (match_dup 3))
1076 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
1077 (set (strict_low_part (match_dup 2)) (match_dup 4))]
1078 "operands[2] = gen_lowpart (SImode, operands[0]);
1079 s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
1082 [(set (match_operand:DI 0 "register_operand" "")
1083 (match_operand:DI 1 "register_operand" ""))]
1084 "TARGET_64BIT && ACCESS_REG_P (operands[0])
1085 && dead_or_set_p (insn, operands[1])"
1086 [(set (match_dup 3) (match_dup 2))
1087 (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
1088 (set (match_dup 4) (match_dup 2))]
1089 "operands[2] = gen_lowpart (SImode, operands[1]);
1090 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1093 [(set (match_operand:DI 0 "register_operand" "")
1094 (match_operand:DI 1 "register_operand" ""))]
1095 "TARGET_64BIT && ACCESS_REG_P (operands[0])
1096 && !dead_or_set_p (insn, operands[1])"
1097 [(set (match_dup 3) (match_dup 2))
1098 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
1099 (set (match_dup 4) (match_dup 2))
1100 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
1101 "operands[2] = gen_lowpart (SImode, operands[1]);
1102 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1104 (define_insn "*movdi_31"
1105 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,Q,S,d,o,!*f,!*f,!*f,!R,!T,Q")
1106 (match_operand:DI 1 "general_operand" "Q,S,d,d,dPm,d,*f,R,T,*f,*f,Q"))]
1121 [(set_attr "op_type" "RS,RSY,RS,RSY,*,*,RR,RX,RXY,RX,RXY,SS")
1122 (set_attr "type" "lm,lm,stm,stm,*,*,floaddf,floaddf,floaddf,fstoredf,fstoredf,*")])
1125 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1126 (match_operand:DI 1 "general_operand" ""))]
1127 "!TARGET_64BIT && reload_completed
1128 && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
1129 [(set (match_dup 2) (match_dup 4))
1130 (set (match_dup 3) (match_dup 5))]
1132 operands[2] = operand_subword (operands[0], 0, 0, DImode);
1133 operands[3] = operand_subword (operands[0], 1, 0, DImode);
1134 operands[4] = operand_subword (operands[1], 0, 0, DImode);
1135 operands[5] = operand_subword (operands[1], 1, 0, DImode);
1139 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1140 (match_operand:DI 1 "general_operand" ""))]
1141 "!TARGET_64BIT && reload_completed
1142 && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
1143 [(set (match_dup 2) (match_dup 4))
1144 (set (match_dup 3) (match_dup 5))]
1146 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1147 operands[3] = operand_subword (operands[0], 0, 0, DImode);
1148 operands[4] = operand_subword (operands[1], 1, 0, DImode);
1149 operands[5] = operand_subword (operands[1], 0, 0, DImode);
1153 [(set (match_operand:DI 0 "register_operand" "")
1154 (match_operand:DI 1 "memory_operand" ""))]
1155 "!TARGET_64BIT && reload_completed
1156 && !FP_REG_P (operands[0])
1157 && !s_operand (operands[1], VOIDmode)"
1158 [(set (match_dup 0) (match_dup 1))]
1160 rtx addr = operand_subword (operands[0], 1, 0, DImode);
1161 s390_load_address (addr, XEXP (operands[1], 0));
1162 operands[1] = replace_equiv_address (operands[1], addr);
1166 [(set (match_operand:DI 0 "register_operand" "")
1167 (mem:DI (match_operand 1 "address_operand" "")))]
1169 && !FP_REG_P (operands[0])
1170 && GET_CODE (operands[1]) == SYMBOL_REF
1171 && CONSTANT_POOL_ADDRESS_P (operands[1])
1172 && get_pool_mode (operands[1]) == DImode
1173 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1174 [(set (match_dup 0) (match_dup 2))]
1175 "operands[2] = get_pool_constant (operands[1]);")
1177 (define_insn "*la_64"
1178 [(set (match_operand:DI 0 "register_operand" "=d,d")
1179 (match_operand:QI 1 "address_operand" "U,W"))]
1184 [(set_attr "op_type" "RX,RXY")
1185 (set_attr "type" "la")])
1189 [(set (match_operand:DI 0 "register_operand" "")
1190 (match_operand:QI 1 "address_operand" ""))
1191 (clobber (reg:CC CC_REGNUM))])]
1193 && preferred_la_operand_p (operands[1], const0_rtx)"
1194 [(set (match_dup 0) (match_dup 1))]
1198 [(set (match_operand:DI 0 "register_operand" "")
1199 (match_operand:DI 1 "register_operand" ""))
1202 (plus:DI (match_dup 0)
1203 (match_operand:DI 2 "nonmemory_operand" "")))
1204 (clobber (reg:CC CC_REGNUM))])]
1206 && !reg_overlap_mentioned_p (operands[0], operands[2])
1207 && preferred_la_operand_p (operands[1], operands[2])"
1208 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1212 ; movsi instruction pattern(s).
1215 (define_expand "movsi"
1216 [(set (match_operand:SI 0 "general_operand" "")
1217 (match_operand:SI 1 "general_operand" ""))]
1220 /* Handle symbolic constants. */
1222 && (SYMBOLIC_CONST (operands[1])
1223 || (GET_CODE (operands[1]) == PLUS
1224 && XEXP (operands[1], 0) == pic_offset_table_rtx
1225 && SYMBOLIC_CONST (XEXP(operands[1], 1)))))
1226 emit_symbolic_move (operands);
1229 (define_insn "*movsi_larl"
1230 [(set (match_operand:SI 0 "register_operand" "=d")
1231 (match_operand:SI 1 "larl_operand" "X"))]
1232 "!TARGET_64BIT && TARGET_CPU_ZARCH
1233 && !FP_REG_P (operands[0])"
1235 [(set_attr "op_type" "RIL")
1236 (set_attr "type" "larl")])
1238 (define_insn "*movsi_zarch"
1239 [(set (match_operand:SI 0 "nonimmediate_operand"
1240 "=d,d,d,d,d,d,d,d,R,T,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
1241 (match_operand:SI 1 "general_operand"
1242 "K,N0HS0,N1HS0,Os,L,d,R,T,d,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
1265 [(set_attr "op_type" "RI,RI,RI,RIL,RXY,RR,RX,RXY,RX,RXY,
1266 RR,RX,RXY,RX,RXY,RRE,RRE,RS,RS,SS")
1267 (set_attr "type" "*,*,*,*,la,lr,load,load,store,store,
1268 floadsf,floadsf,floadsf,fstoresf,fstoresf,*,*,*,*,*")])
1270 (define_insn "*movsi_esa"
1271 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!R,d,t,Q,t,?Q")
1272 (match_operand:SI 1 "general_operand" "K,d,R,d,*f,R,*f,t,d,t,Q,?Q"))]
1287 [(set_attr "op_type" "RI,RR,RX,RX,RR,RX,RX,RRE,RRE,RS,RS,SS")
1288 (set_attr "type" "*,lr,load,store,floadsf,floadsf,fstoresf,*,*,*,*,*")])
1291 [(set (match_operand:SI 0 "register_operand" "")
1292 (mem:SI (match_operand 1 "address_operand" "")))]
1293 "!FP_REG_P (operands[0])
1294 && GET_CODE (operands[1]) == SYMBOL_REF
1295 && CONSTANT_POOL_ADDRESS_P (operands[1])
1296 && get_pool_mode (operands[1]) == SImode
1297 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1298 [(set (match_dup 0) (match_dup 2))]
1299 "operands[2] = get_pool_constant (operands[1]);")
1301 (define_insn "*la_31"
1302 [(set (match_operand:SI 0 "register_operand" "=d,d")
1303 (match_operand:QI 1 "address_operand" "U,W"))]
1304 "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
1308 [(set_attr "op_type" "RX,RXY")
1309 (set_attr "type" "la")])
1313 [(set (match_operand:SI 0 "register_operand" "")
1314 (match_operand:QI 1 "address_operand" ""))
1315 (clobber (reg:CC CC_REGNUM))])]
1317 && preferred_la_operand_p (operands[1], const0_rtx)"
1318 [(set (match_dup 0) (match_dup 1))]
1322 [(set (match_operand:SI 0 "register_operand" "")
1323 (match_operand:SI 1 "register_operand" ""))
1326 (plus:SI (match_dup 0)
1327 (match_operand:SI 2 "nonmemory_operand" "")))
1328 (clobber (reg:CC CC_REGNUM))])]
1330 && !reg_overlap_mentioned_p (operands[0], operands[2])
1331 && preferred_la_operand_p (operands[1], operands[2])"
1332 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
1335 (define_insn "*la_31_and"
1336 [(set (match_operand:SI 0 "register_operand" "=d,d")
1337 (and:SI (match_operand:QI 1 "address_operand" "U,W")
1338 (const_int 2147483647)))]
1343 [(set_attr "op_type" "RX,RXY")
1344 (set_attr "type" "la")])
1346 (define_insn_and_split "*la_31_and_cc"
1347 [(set (match_operand:SI 0 "register_operand" "=d")
1348 (and:SI (match_operand:QI 1 "address_operand" "p")
1349 (const_int 2147483647)))
1350 (clobber (reg:CC CC_REGNUM))]
1353 "&& reload_completed"
1355 (and:SI (match_dup 1) (const_int 2147483647)))]
1357 [(set_attr "op_type" "RX")
1358 (set_attr "type" "la")])
1360 (define_insn "force_la_31"
1361 [(set (match_operand:SI 0 "register_operand" "=d,d")
1362 (match_operand:QI 1 "address_operand" "U,W"))
1363 (use (const_int 0))]
1368 [(set_attr "op_type" "RX")
1369 (set_attr "type" "la")])
1372 ; movhi instruction pattern(s).
1375 (define_expand "movhi"
1376 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1377 (match_operand:HI 1 "general_operand" ""))]
1380 /* Make it explicit that loading a register from memory
1381 always sign-extends (at least) to SImode. */
1382 if (optimize && !no_new_pseudos
1383 && register_operand (operands[0], VOIDmode)
1384 && GET_CODE (operands[1]) == MEM)
1386 rtx tmp = gen_reg_rtx (SImode);
1387 rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
1388 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1389 operands[1] = gen_lowpart (HImode, tmp);
1393 (define_insn "*movhi"
1394 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,R,T,?Q")
1395 (match_operand:HI 1 "general_operand" "d,n,R,T,d,d,?Q"))]
1405 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SS")
1406 (set_attr "type" "lr,*,*,*,store,store,*")])
1409 [(set (match_operand:HI 0 "register_operand" "")
1410 (mem:HI (match_operand 1 "address_operand" "")))]
1411 "GET_CODE (operands[1]) == SYMBOL_REF
1412 && CONSTANT_POOL_ADDRESS_P (operands[1])
1413 && get_pool_mode (operands[1]) == HImode
1414 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1415 [(set (match_dup 0) (match_dup 2))]
1416 "operands[2] = get_pool_constant (operands[1]);")
1419 ; movqi instruction pattern(s).
1422 (define_expand "movqi"
1423 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1424 (match_operand:QI 1 "general_operand" ""))]
1427 /* On z/Architecture, zero-extending from memory to register
1428 is just as fast as a QImode load. */
1429 if (TARGET_ZARCH && optimize && !no_new_pseudos
1430 && register_operand (operands[0], VOIDmode)
1431 && GET_CODE (operands[1]) == MEM)
1433 rtx tmp = gen_reg_rtx (word_mode);
1434 rtx ext = gen_rtx_ZERO_EXTEND (word_mode, operands[1]);
1435 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1436 operands[1] = gen_lowpart (QImode, tmp);
1440 (define_insn "*movqi"
1441 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q")
1442 (match_operand:QI 1 "general_operand" "d,n,R,T,d,d,n,n,?Q"))]
1454 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS")
1455 (set_attr "type" "lr,*,*,*,store,store,store,store,*")])
1458 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1459 (mem:QI (match_operand 1 "address_operand" "")))]
1460 "GET_CODE (operands[1]) == SYMBOL_REF
1461 && CONSTANT_POOL_ADDRESS_P (operands[1])
1462 && get_pool_mode (operands[1]) == QImode
1463 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1464 [(set (match_dup 0) (match_dup 2))]
1465 "operands[2] = get_pool_constant (operands[1]);")
1468 ; movstrictqi instruction pattern(s).
1471 (define_insn "*movstrictqi"
1472 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
1473 (match_operand:QI 1 "memory_operand" "R,T"))]
1478 [(set_attr "op_type" "RX,RXY")])
1481 ; movstricthi instruction pattern(s).
1484 (define_insn "*movstricthi"
1485 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
1486 (match_operand:HI 1 "memory_operand" "Q,S"))
1487 (clobber (reg:CC CC_REGNUM))]
1492 [(set_attr "op_type" "RS,RSY")])
1495 ; movstrictsi instruction pattern(s).
1498 (define_insn "movstrictsi"
1499 [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
1500 (match_operand:SI 1 "general_operand" "d,R,T,t"))]
1507 [(set_attr "op_type" "RR,RX,RXY,RRE")
1508 (set_attr "type" "lr,load,load,*")])
1511 ; mov(tf|td) instruction pattern(s).
1514 (define_expand "mov<mode>"
1515 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1516 (match_operand:TD_TF 1 "general_operand" ""))]
1520 (define_insn "*mov<mode>_64"
1521 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o, d,QS, d,o,Q")
1522 (match_operand:TD_TF 1 "general_operand" " G,f,o,f,QS, d,dm,d,Q"))]
1534 [(set_attr "op_type" "RRE,RRE,*,*,RSY,RSY,*,*,*")
1535 (set_attr "type" "fsimptf,fsimptf,*,*,lm,stm,*,*,*")])
1537 (define_insn "*mov<mode>_31"
1538 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o,Q")
1539 (match_operand:TD_TF 1 "general_operand" " G,f,o,f,Q"))]
1547 [(set_attr "op_type" "RRE,RRE,*,*,*")
1548 (set_attr "type" "fsimptf,fsimptf,*,*,*")])
1550 ; TFmode in GPRs splitters
1553 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1554 (match_operand:TD_TF 1 "general_operand" ""))]
1555 "TARGET_64BIT && reload_completed
1556 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
1557 [(set (match_dup 2) (match_dup 4))
1558 (set (match_dup 3) (match_dup 5))]
1560 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
1561 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
1562 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
1563 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
1567 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1568 (match_operand:TD_TF 1 "general_operand" ""))]
1569 "TARGET_64BIT && reload_completed
1570 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
1571 [(set (match_dup 2) (match_dup 4))
1572 (set (match_dup 3) (match_dup 5))]
1574 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
1575 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
1576 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
1577 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
1581 [(set (match_operand:TD_TF 0 "register_operand" "")
1582 (match_operand:TD_TF 1 "memory_operand" ""))]
1583 "TARGET_64BIT && reload_completed
1584 && !FP_REG_P (operands[0])
1585 && !s_operand (operands[1], VOIDmode)"
1586 [(set (match_dup 0) (match_dup 1))]
1588 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
1589 s390_load_address (addr, XEXP (operands[1], 0));
1590 operands[1] = replace_equiv_address (operands[1], addr);
1593 ; TFmode in BFPs splitters
1596 [(set (match_operand:TD_TF 0 "register_operand" "")
1597 (match_operand:TD_TF 1 "memory_operand" ""))]
1598 "reload_completed && offsettable_memref_p (operands[1])
1599 && FP_REG_P (operands[0])"
1600 [(set (match_dup 2) (match_dup 4))
1601 (set (match_dup 3) (match_dup 5))]
1603 operands[2] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
1605 operands[3] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
1607 operands[4] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 0);
1608 operands[5] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 8);
1612 [(set (match_operand:TD_TF 0 "memory_operand" "")
1613 (match_operand:TD_TF 1 "register_operand" ""))]
1614 "reload_completed && offsettable_memref_p (operands[0])
1615 && FP_REG_P (operands[1])"
1616 [(set (match_dup 2) (match_dup 4))
1617 (set (match_dup 3) (match_dup 5))]
1619 operands[2] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 0);
1620 operands[3] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 8);
1621 operands[4] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
1623 operands[5] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
1628 ; mov(df|dd) instruction pattern(s).
1631 (define_expand "mov<mode>"
1632 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
1633 (match_operand:DD_DF 1 "general_operand" ""))]
1637 (define_insn "*mov<mode>_64dfp"
1638 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
1639 "=f,f,f,d,f,f,R,T,d,d,m,?Q")
1640 (match_operand:DD_DF 1 "general_operand"
1641 "G,f,d,f,R,T,f,f,d,m,d,?Q"))]
1642 "TARGET_64BIT && TARGET_DFP"
1656 [(set_attr "op_type" "RRE,RR,RRE,RRE,RX,RXY,RX,RXY,RRE,RXY,RXY,SS")
1657 (set_attr "type" "fsimpdf,floaddf,floaddf,floaddf,floaddf,floaddf,
1658 fstoredf,fstoredf,lr,load,store,*")])
1660 (define_insn "*mov<mode>_64"
1661 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "=f,f,f,f,R,T,d,d,m,?Q")
1662 (match_operand:DD_DF 1 "general_operand" "G,f,R,T,f,f,d,m,d,?Q"))]
1675 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RRE,RXY,RXY,SS")
1676 (set_attr "type" "fsimp<bfp>,fload<bfp>,fload<bfp>,fload<bfp>,
1677 fstore<bfp>,fstore<bfp>,lr,load,store,*")])
1679 (define_insn "*mov<mode>_31"
1680 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
1681 "=f,f,f,f,R,T,d,d,Q,S, d,o,Q")
1682 (match_operand:DD_DF 1 "general_operand"
1683 " G,f,R,T,f,f,Q,S,d,d,dPm,d,Q"))]
1699 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RS,RSY,RS,RSY,*,*,SS")
1700 (set_attr "type" "fsimp<bfp>,fload<bfp>,fload<bfp>,fload<bfp>,
1701 fstore<bfp>,fstore<bfp>,lm,lm,stm,stm,*,*,*")])
1704 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
1705 (match_operand:DD_DF 1 "general_operand" ""))]
1706 "!TARGET_64BIT && reload_completed
1707 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
1708 [(set (match_dup 2) (match_dup 4))
1709 (set (match_dup 3) (match_dup 5))]
1711 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
1712 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
1713 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
1714 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
1718 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
1719 (match_operand:DD_DF 1 "general_operand" ""))]
1720 "!TARGET_64BIT && reload_completed
1721 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
1722 [(set (match_dup 2) (match_dup 4))
1723 (set (match_dup 3) (match_dup 5))]
1725 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
1726 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
1727 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
1728 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
1732 [(set (match_operand:DD_DF 0 "register_operand" "")
1733 (match_operand:DD_DF 1 "memory_operand" ""))]
1734 "!TARGET_64BIT && reload_completed
1735 && !FP_REG_P (operands[0])
1736 && !s_operand (operands[1], VOIDmode)"
1737 [(set (match_dup 0) (match_dup 1))]
1739 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
1740 s390_load_address (addr, XEXP (operands[1], 0));
1741 operands[1] = replace_equiv_address (operands[1], addr);
1745 ; mov(sf|sd) instruction pattern(s).
1748 (define_insn "mov<mode>"
1749 [(set (match_operand:SD_SF 0 "nonimmediate_operand"
1750 "=f,f,f,f,R,T,d,d,d,R,T,?Q")
1751 (match_operand:SD_SF 1 "general_operand"
1752 " G,f,R,T,f,f,d,R,T,d,d,?Q"))]
1767 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RR,RX,RXY,RX,RXY,SS")
1768 (set_attr "type" "fsimp<bfp>,fload<bfp>,fload<bfp>,fload<bfp>,
1769 fstore<bfp>,fstore<bfp>,lr,load,load,store,store,*")])
1772 ; movcc instruction pattern
1775 (define_insn "movcc"
1776 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
1777 (match_operand:CC 1 "nonimmediate_operand" "d,d,c,R,T,d,d"))]
1787 [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
1788 (set_attr "type" "lr,*,*,store,store,load,load")])
1791 ; Block move (MVC) patterns.
1795 [(set (match_operand:BLK 0 "memory_operand" "=Q")
1796 (match_operand:BLK 1 "memory_operand" "Q"))
1797 (use (match_operand 2 "const_int_operand" "n"))]
1798 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
1799 "mvc\t%O0(%2,%R0),%S1"
1800 [(set_attr "op_type" "SS")])
1803 [(set (match_operand 0 "memory_operand" "")
1804 (match_operand 1 "memory_operand" ""))]
1806 && GET_MODE (operands[0]) == GET_MODE (operands[1])
1807 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
1809 [(set (match_dup 0) (match_dup 1))
1810 (use (match_dup 2))])]
1812 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
1813 operands[0] = adjust_address (operands[0], BLKmode, 0);
1814 operands[1] = adjust_address (operands[1], BLKmode, 0);
1819 [(set (match_operand:BLK 0 "memory_operand" "")
1820 (match_operand:BLK 1 "memory_operand" ""))
1821 (use (match_operand 2 "const_int_operand" ""))])
1823 [(set (match_operand:BLK 3 "memory_operand" "")
1824 (match_operand:BLK 4 "memory_operand" ""))
1825 (use (match_operand 5 "const_int_operand" ""))])]
1826 "s390_offset_p (operands[0], operands[3], operands[2])
1827 && s390_offset_p (operands[1], operands[4], operands[2])
1828 && !s390_overlap_p (operands[0], operands[1],
1829 INTVAL (operands[2]) + INTVAL (operands[5]))
1830 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
1832 [(set (match_dup 6) (match_dup 7))
1833 (use (match_dup 8))])]
1834 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
1835 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
1836 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
1840 ; load_multiple pattern(s).
1842 ; ??? Due to reload problems with replacing registers inside match_parallel
1843 ; we currently support load_multiple/store_multiple only after reload.
1846 (define_expand "load_multiple"
1847 [(match_par_dup 3 [(set (match_operand 0 "" "")
1848 (match_operand 1 "" ""))
1849 (use (match_operand 2 "" ""))])]
1852 enum machine_mode mode;
1858 /* Support only loading a constant number of fixed-point registers from
1859 memory and only bother with this if more than two */
1860 if (GET_CODE (operands[2]) != CONST_INT
1861 || INTVAL (operands[2]) < 2
1862 || INTVAL (operands[2]) > 16
1863 || GET_CODE (operands[1]) != MEM
1864 || GET_CODE (operands[0]) != REG
1865 || REGNO (operands[0]) >= 16)
1868 count = INTVAL (operands[2]);
1869 regno = REGNO (operands[0]);
1870 mode = GET_MODE (operands[0]);
1871 if (mode != SImode && mode != word_mode)
1874 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
1877 if (GET_CODE (XEXP (operands[1], 0)) == REG)
1879 from = XEXP (operands[1], 0);
1882 else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
1883 && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
1884 && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
1886 from = XEXP (XEXP (operands[1], 0), 0);
1887 off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
1894 from = force_reg (Pmode, XEXP (operands[1], 0));
1898 for (i = 0; i < count; i++)
1899 XVECEXP (operands[3], 0, i)
1900 = gen_rtx_SET (VOIDmode, gen_rtx_REG (mode, regno + i),
1901 change_address (operands[1], mode,
1902 plus_constant (from, off + i * GET_MODE_SIZE (mode))));
1905 (define_insn "*load_multiple_di"
1906 [(match_parallel 0 "load_multiple_operation"
1907 [(set (match_operand:DI 1 "register_operand" "=r")
1908 (match_operand:DI 2 "s_operand" "QS"))])]
1909 "reload_completed && word_mode == DImode"
1911 int words = XVECLEN (operands[0], 0);
1912 operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
1913 return "lmg\t%1,%0,%S2";
1915 [(set_attr "op_type" "RSY")
1916 (set_attr "type" "lm")])
1918 (define_insn "*load_multiple_si"
1919 [(match_parallel 0 "load_multiple_operation"
1920 [(set (match_operand:SI 1 "register_operand" "=r,r")
1921 (match_operand:SI 2 "s_operand" "Q,S"))])]
1924 int words = XVECLEN (operands[0], 0);
1925 operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
1926 return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
1928 [(set_attr "op_type" "RS,RSY")
1929 (set_attr "type" "lm")])
1932 ; store multiple pattern(s).
1935 (define_expand "store_multiple"
1936 [(match_par_dup 3 [(set (match_operand 0 "" "")
1937 (match_operand 1 "" ""))
1938 (use (match_operand 2 "" ""))])]
1941 enum machine_mode mode;
1947 /* Support only storing a constant number of fixed-point registers to
1948 memory and only bother with this if more than two. */
1949 if (GET_CODE (operands[2]) != CONST_INT
1950 || INTVAL (operands[2]) < 2
1951 || INTVAL (operands[2]) > 16
1952 || GET_CODE (operands[0]) != MEM
1953 || GET_CODE (operands[1]) != REG
1954 || REGNO (operands[1]) >= 16)
1957 count = INTVAL (operands[2]);
1958 regno = REGNO (operands[1]);
1959 mode = GET_MODE (operands[1]);
1960 if (mode != SImode && mode != word_mode)
1963 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
1967 if (GET_CODE (XEXP (operands[0], 0)) == REG)
1969 to = XEXP (operands[0], 0);
1972 else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
1973 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
1974 && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
1976 to = XEXP (XEXP (operands[0], 0), 0);
1977 off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
1984 to = force_reg (Pmode, XEXP (operands[0], 0));
1988 for (i = 0; i < count; i++)
1989 XVECEXP (operands[3], 0, i)
1990 = gen_rtx_SET (VOIDmode,
1991 change_address (operands[0], mode,
1992 plus_constant (to, off + i * GET_MODE_SIZE (mode))),
1993 gen_rtx_REG (mode, regno + i));
1996 (define_insn "*store_multiple_di"
1997 [(match_parallel 0 "store_multiple_operation"
1998 [(set (match_operand:DI 1 "s_operand" "=QS")
1999 (match_operand:DI 2 "register_operand" "r"))])]
2000 "reload_completed && word_mode == DImode"
2002 int words = XVECLEN (operands[0], 0);
2003 operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
2004 return "stmg\t%2,%0,%S1";
2006 [(set_attr "op_type" "RSY")
2007 (set_attr "type" "stm")])
2010 (define_insn "*store_multiple_si"
2011 [(match_parallel 0 "store_multiple_operation"
2012 [(set (match_operand:SI 1 "s_operand" "=Q,S")
2013 (match_operand:SI 2 "register_operand" "r,r"))])]
2016 int words = XVECLEN (operands[0], 0);
2017 operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
2018 return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
2020 [(set_attr "op_type" "RS,RSY")
2021 (set_attr "type" "stm")])
2024 ;; String instructions.
2027 (define_insn "*execute"
2028 [(match_parallel 0 ""
2029 [(unspec [(match_operand 1 "register_operand" "a")
2030 (match_operand:BLK 2 "memory_operand" "R")
2031 (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
2032 "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2033 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2035 [(set_attr "op_type" "RX")
2036 (set_attr "type" "cs")])
2040 ; strlenM instruction pattern(s).
2043 (define_expand "strlen<mode>"
2044 [(set (reg:SI 0) (match_operand:SI 2 "immediate_operand" ""))
2047 (unspec:P [(const_int 0)
2048 (match_operand:BLK 1 "memory_operand" "")
2050 (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
2051 (clobber (scratch:P))
2052 (clobber (reg:CC CC_REGNUM))])
2054 [(set (match_operand:P 0 "register_operand" "")
2055 (minus:P (match_dup 4) (match_dup 5)))
2056 (clobber (reg:CC CC_REGNUM))])]
2059 operands[4] = gen_reg_rtx (Pmode);
2060 operands[5] = gen_reg_rtx (Pmode);
2061 emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
2062 operands[1] = replace_equiv_address (operands[1], operands[5]);
2065 (define_insn "*strlen<mode>"
2066 [(set (match_operand:P 0 "register_operand" "=a")
2067 (unspec:P [(match_operand:P 2 "general_operand" "0")
2068 (mem:BLK (match_operand:P 3 "register_operand" "1"))
2070 (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
2071 (clobber (match_scratch:P 1 "=a"))
2072 (clobber (reg:CC CC_REGNUM))]
2074 "srst\t%0,%1\;jo\t.-4"
2075 [(set_attr "length" "8")
2076 (set_attr "type" "vs")])
2079 ; cmpstrM instruction pattern(s).
2082 (define_expand "cmpstrsi"
2083 [(set (reg:SI 0) (const_int 0))
2085 [(clobber (match_operand 3 "" ""))
2086 (clobber (match_dup 4))
2087 (set (reg:CCU CC_REGNUM)
2088 (compare:CCU (match_operand:BLK 1 "memory_operand" "")
2089 (match_operand:BLK 2 "memory_operand" "")))
2092 [(set (match_operand:SI 0 "register_operand" "=d")
2093 (unspec:SI [(reg:CCU CC_REGNUM)] UNSPEC_CMPINT))
2094 (clobber (reg:CC CC_REGNUM))])]
2097 /* As the result of CMPINT is inverted compared to what we need,
2098 we have to swap the operands. */
2099 rtx op1 = operands[2];
2100 rtx op2 = operands[1];
2101 rtx addr1 = gen_reg_rtx (Pmode);
2102 rtx addr2 = gen_reg_rtx (Pmode);
2104 emit_move_insn (addr1, force_operand (XEXP (op1, 0), NULL_RTX));
2105 emit_move_insn (addr2, force_operand (XEXP (op2, 0), NULL_RTX));
2106 operands[1] = replace_equiv_address_nv (op1, addr1);
2107 operands[2] = replace_equiv_address_nv (op2, addr2);
2108 operands[3] = addr1;
2109 operands[4] = addr2;
2112 (define_insn "*cmpstr<mode>"
2113 [(clobber (match_operand:P 0 "register_operand" "=d"))
2114 (clobber (match_operand:P 1 "register_operand" "=d"))
2115 (set (reg:CCU CC_REGNUM)
2116 (compare:CCU (mem:BLK (match_operand:P 2 "register_operand" "0"))
2117 (mem:BLK (match_operand:P 3 "register_operand" "1"))))
2120 "clst\t%0,%1\;jo\t.-4"
2121 [(set_attr "length" "8")
2122 (set_attr "type" "vs")])
2125 ; movstr instruction pattern.
2128 (define_expand "movstr"
2129 [(set (reg:SI 0) (const_int 0))
2131 [(clobber (match_dup 3))
2132 (set (match_operand:BLK 1 "memory_operand" "")
2133 (match_operand:BLK 2 "memory_operand" ""))
2134 (set (match_operand 0 "register_operand" "")
2135 (unspec [(match_dup 1)
2137 (reg:SI 0)] UNSPEC_MVST))
2138 (clobber (reg:CC CC_REGNUM))])]
2141 rtx addr1 = gen_reg_rtx (Pmode);
2142 rtx addr2 = gen_reg_rtx (Pmode);
2144 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2145 emit_move_insn (addr2, force_operand (XEXP (operands[2], 0), NULL_RTX));
2146 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2147 operands[2] = replace_equiv_address_nv (operands[2], addr2);
2148 operands[3] = addr2;
2151 (define_insn "*movstr"
2152 [(clobber (match_operand:P 2 "register_operand" "=d"))
2153 (set (mem:BLK (match_operand:P 1 "register_operand" "0"))
2154 (mem:BLK (match_operand:P 3 "register_operand" "2")))
2155 (set (match_operand:P 0 "register_operand" "=d")
2156 (unspec [(mem:BLK (match_dup 1))
2157 (mem:BLK (match_dup 3))
2158 (reg:SI 0)] UNSPEC_MVST))
2159 (clobber (reg:CC CC_REGNUM))]
2161 "mvst\t%1,%2\;jo\t.-4"
2162 [(set_attr "length" "8")
2163 (set_attr "type" "vs")])
2167 ; movmemM instruction pattern(s).
2170 (define_expand "movmem<mode>"
2171 [(set (match_operand:BLK 0 "memory_operand" "")
2172 (match_operand:BLK 1 "memory_operand" ""))
2173 (use (match_operand:GPR 2 "general_operand" ""))
2174 (match_operand 3 "" "")]
2176 "s390_expand_movmem (operands[0], operands[1], operands[2]); DONE;")
2178 ; Move a block that is up to 256 bytes in length.
2179 ; The block length is taken as (operands[2] % 256) + 1.
2181 (define_expand "movmem_short"
2183 [(set (match_operand:BLK 0 "memory_operand" "")
2184 (match_operand:BLK 1 "memory_operand" ""))
2185 (use (match_operand 2 "nonmemory_operand" ""))
2186 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2187 (clobber (match_dup 3))])]
2189 "operands[3] = gen_rtx_SCRATCH (Pmode);")
2191 (define_insn "*movmem_short"
2192 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q")
2193 (match_operand:BLK 1 "memory_operand" "Q,Q,Q"))
2194 (use (match_operand 2 "nonmemory_operand" "n,a,a"))
2195 (use (match_operand 3 "immediate_operand" "X,R,X"))
2196 (clobber (match_scratch 4 "=X,X,&a"))]
2197 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2198 && GET_MODE (operands[4]) == Pmode"
2200 [(set_attr "type" "cs")])
2203 [(set (match_operand:BLK 0 "memory_operand" "")
2204 (match_operand:BLK 1 "memory_operand" ""))
2205 (use (match_operand 2 "const_int_operand" ""))
2206 (use (match_operand 3 "immediate_operand" ""))
2207 (clobber (scratch))]
2210 [(set (match_dup 0) (match_dup 1))
2211 (use (match_dup 2))])]
2212 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2215 [(set (match_operand:BLK 0 "memory_operand" "")
2216 (match_operand:BLK 1 "memory_operand" ""))
2217 (use (match_operand 2 "register_operand" ""))
2218 (use (match_operand 3 "memory_operand" ""))
2219 (clobber (scratch))]
2222 [(unspec [(match_dup 2) (match_dup 3)
2223 (const_int 0)] UNSPEC_EXECUTE)
2224 (set (match_dup 0) (match_dup 1))
2225 (use (const_int 1))])]
2229 [(set (match_operand:BLK 0 "memory_operand" "")
2230 (match_operand:BLK 1 "memory_operand" ""))
2231 (use (match_operand 2 "register_operand" ""))
2232 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2233 (clobber (match_operand 3 "register_operand" ""))]
2234 "reload_completed && TARGET_CPU_ZARCH"
2235 [(set (match_dup 3) (label_ref (match_dup 4)))
2237 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
2238 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2239 (set (match_dup 0) (match_dup 1))
2240 (use (const_int 1))])]
2241 "operands[4] = gen_label_rtx ();")
2243 ; Move a block of arbitrary length.
2245 (define_expand "movmem_long"
2247 [(clobber (match_dup 2))
2248 (clobber (match_dup 3))
2249 (set (match_operand:BLK 0 "memory_operand" "")
2250 (match_operand:BLK 1 "memory_operand" ""))
2251 (use (match_operand 2 "general_operand" ""))
2253 (clobber (reg:CC CC_REGNUM))])]
2256 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2257 rtx reg0 = gen_reg_rtx (dword_mode);
2258 rtx reg1 = gen_reg_rtx (dword_mode);
2259 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2260 rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
2261 rtx len0 = gen_lowpart (Pmode, reg0);
2262 rtx len1 = gen_lowpart (Pmode, reg1);
2264 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2265 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2266 emit_move_insn (len0, operands[2]);
2268 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
2269 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2270 emit_move_insn (len1, operands[2]);
2272 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2273 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2278 (define_insn "*movmem_long"
2279 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2280 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
2281 (set (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
2282 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0)))
2285 (clobber (reg:CC CC_REGNUM))]
2287 "mvcle\t%0,%1,0\;jo\t.-4"
2288 [(set_attr "length" "8")
2289 (set_attr "type" "vs")])
2292 ; setmemM instruction pattern(s).
2295 (define_expand "setmem<mode>"
2296 [(set (match_operand:BLK 0 "memory_operand" "")
2297 (match_operand:QI 2 "general_operand" ""))
2298 (use (match_operand:GPR 1 "general_operand" ""))
2299 (match_operand 3 "" "")]
2301 "s390_expand_setmem (operands[0], operands[1], operands[2]); DONE;")
2303 ; Clear a block that is up to 256 bytes in length.
2304 ; The block length is taken as (operands[1] % 256) + 1.
2306 (define_expand "clrmem_short"
2308 [(set (match_operand:BLK 0 "memory_operand" "")
2310 (use (match_operand 1 "nonmemory_operand" ""))
2311 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2312 (clobber (match_dup 2))
2313 (clobber (reg:CC CC_REGNUM))])]
2315 "operands[2] = gen_rtx_SCRATCH (Pmode);")
2317 (define_insn "*clrmem_short"
2318 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q")
2320 (use (match_operand 1 "nonmemory_operand" "n,a,a"))
2321 (use (match_operand 2 "immediate_operand" "X,R,X"))
2322 (clobber (match_scratch 3 "=X,X,&a"))
2323 (clobber (reg:CC CC_REGNUM))]
2324 "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)
2325 && GET_MODE (operands[3]) == Pmode"
2327 [(set_attr "type" "cs")])
2330 [(set (match_operand:BLK 0 "memory_operand" "")
2332 (use (match_operand 1 "const_int_operand" ""))
2333 (use (match_operand 2 "immediate_operand" ""))
2335 (clobber (reg:CC CC_REGNUM))]
2338 [(set (match_dup 0) (const_int 0))
2340 (clobber (reg:CC CC_REGNUM))])]
2341 "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
2344 [(set (match_operand:BLK 0 "memory_operand" "")
2346 (use (match_operand 1 "register_operand" ""))
2347 (use (match_operand 2 "memory_operand" ""))
2349 (clobber (reg:CC CC_REGNUM))]
2352 [(unspec [(match_dup 1) (match_dup 2)
2353 (const_int 0)] UNSPEC_EXECUTE)
2354 (set (match_dup 0) (const_int 0))
2356 (clobber (reg:CC CC_REGNUM))])]
2360 [(set (match_operand:BLK 0 "memory_operand" "")
2362 (use (match_operand 1 "register_operand" ""))
2363 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2364 (clobber (match_operand 2 "register_operand" ""))
2365 (clobber (reg:CC CC_REGNUM))]
2366 "reload_completed && TARGET_CPU_ZARCH"
2367 [(set (match_dup 2) (label_ref (match_dup 3)))
2369 [(unspec [(match_dup 1) (mem:BLK (match_dup 2))
2370 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2371 (set (match_dup 0) (const_int 0))
2373 (clobber (reg:CC CC_REGNUM))])]
2374 "operands[3] = gen_label_rtx ();")
2376 ; Initialize a block of arbitrary length with (operands[2] % 256).
2378 (define_expand "setmem_long"
2380 [(clobber (match_dup 1))
2381 (set (match_operand:BLK 0 "memory_operand" "")
2382 (match_operand 2 "shift_count_or_setmem_operand" ""))
2383 (use (match_operand 1 "general_operand" ""))
2385 (clobber (reg:CC CC_REGNUM))])]
2388 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2389 rtx reg0 = gen_reg_rtx (dword_mode);
2390 rtx reg1 = gen_reg_rtx (dword_mode);
2391 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2392 rtx len0 = gen_lowpart (Pmode, reg0);
2394 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2395 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2396 emit_move_insn (len0, operands[1]);
2398 emit_move_insn (reg1, const0_rtx);
2400 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2405 (define_insn "*setmem_long"
2406 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2407 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
2408 (match_operand 2 "shift_count_or_setmem_operand" "Y"))
2410 (use (match_operand:<DBL> 1 "register_operand" "d"))
2411 (clobber (reg:CC CC_REGNUM))]
2413 "mvcle\t%0,%1,%Y2\;jo\t.-4"
2414 [(set_attr "length" "8")
2415 (set_attr "type" "vs")])
2417 (define_insn "*setmem_long_and"
2418 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2419 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
2420 (and (match_operand 2 "shift_count_or_setmem_operand" "Y")
2421 (match_operand 4 "const_int_operand" "n")))
2423 (use (match_operand:<DBL> 1 "register_operand" "d"))
2424 (clobber (reg:CC CC_REGNUM))]
2425 "(INTVAL (operands[4]) & 255) == 255"
2426 "mvcle\t%0,%1,%Y2\;jo\t.-4"
2427 [(set_attr "length" "8")
2428 (set_attr "type" "vs")])
2430 ; cmpmemM instruction pattern(s).
2433 (define_expand "cmpmemsi"
2434 [(set (match_operand:SI 0 "register_operand" "")
2435 (compare:SI (match_operand:BLK 1 "memory_operand" "")
2436 (match_operand:BLK 2 "memory_operand" "") ) )
2437 (use (match_operand:SI 3 "general_operand" ""))
2438 (use (match_operand:SI 4 "" ""))]
2440 "s390_expand_cmpmem (operands[0], operands[1],
2441 operands[2], operands[3]); DONE;")
2443 ; Compare a block that is up to 256 bytes in length.
2444 ; The block length is taken as (operands[2] % 256) + 1.
2446 (define_expand "cmpmem_short"
2448 [(set (reg:CCU CC_REGNUM)
2449 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2450 (match_operand:BLK 1 "memory_operand" "")))
2451 (use (match_operand 2 "nonmemory_operand" ""))
2452 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2453 (clobber (match_dup 3))])]
2455 "operands[3] = gen_rtx_SCRATCH (Pmode);")
2457 (define_insn "*cmpmem_short"
2458 [(set (reg:CCU CC_REGNUM)
2459 (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q")
2460 (match_operand:BLK 1 "memory_operand" "Q,Q,Q")))
2461 (use (match_operand 2 "nonmemory_operand" "n,a,a"))
2462 (use (match_operand 3 "immediate_operand" "X,R,X"))
2463 (clobber (match_scratch 4 "=X,X,&a"))]
2464 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2465 && GET_MODE (operands[4]) == Pmode"
2467 [(set_attr "type" "cs")])
2470 [(set (reg:CCU CC_REGNUM)
2471 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2472 (match_operand:BLK 1 "memory_operand" "")))
2473 (use (match_operand 2 "const_int_operand" ""))
2474 (use (match_operand 3 "immediate_operand" ""))
2475 (clobber (scratch))]
2478 [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2479 (use (match_dup 2))])]
2480 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2483 [(set (reg:CCU CC_REGNUM)
2484 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2485 (match_operand:BLK 1 "memory_operand" "")))
2486 (use (match_operand 2 "register_operand" ""))
2487 (use (match_operand 3 "memory_operand" ""))
2488 (clobber (scratch))]
2491 [(unspec [(match_dup 2) (match_dup 3)
2492 (const_int 0)] UNSPEC_EXECUTE)
2493 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2494 (use (const_int 1))])]
2498 [(set (reg:CCU CC_REGNUM)
2499 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2500 (match_operand:BLK 1 "memory_operand" "")))
2501 (use (match_operand 2 "register_operand" ""))
2502 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2503 (clobber (match_operand 3 "register_operand" ""))]
2504 "reload_completed && TARGET_CPU_ZARCH"
2505 [(set (match_dup 3) (label_ref (match_dup 4)))
2507 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
2508 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2509 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2510 (use (const_int 1))])]
2511 "operands[4] = gen_label_rtx ();")
2513 ; Compare a block of arbitrary length.
2515 (define_expand "cmpmem_long"
2517 [(clobber (match_dup 2))
2518 (clobber (match_dup 3))
2519 (set (reg:CCU CC_REGNUM)
2520 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2521 (match_operand:BLK 1 "memory_operand" "")))
2522 (use (match_operand 2 "general_operand" ""))
2523 (use (match_dup 3))])]
2526 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2527 rtx reg0 = gen_reg_rtx (dword_mode);
2528 rtx reg1 = gen_reg_rtx (dword_mode);
2529 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2530 rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
2531 rtx len0 = gen_lowpart (Pmode, reg0);
2532 rtx len1 = gen_lowpart (Pmode, reg1);
2534 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2535 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2536 emit_move_insn (len0, operands[2]);
2538 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
2539 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2540 emit_move_insn (len1, operands[2]);
2542 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2543 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2548 (define_insn "*cmpmem_long"
2549 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2550 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
2551 (set (reg:CCU CC_REGNUM)
2552 (compare:CCU (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
2553 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0))))
2555 (use (match_dup 3))]
2557 "clcle\t%0,%1,0\;jo\t.-4"
2558 [(set_attr "length" "8")
2559 (set_attr "type" "vs")])
2561 ; Convert CCUmode condition code to integer.
2562 ; Result is zero if EQ, positive if LTU, negative if GTU.
2564 (define_insn_and_split "cmpint"
2565 [(set (match_operand:SI 0 "register_operand" "=d")
2566 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2568 (clobber (reg:CC CC_REGNUM))]
2572 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
2574 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
2575 (clobber (reg:CC CC_REGNUM))])])
2577 (define_insn_and_split "*cmpint_cc"
2578 [(set (reg CC_REGNUM)
2579 (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2582 (set (match_operand:SI 0 "register_operand" "=d")
2583 (unspec:SI [(match_dup 1)] UNSPEC_CMPINT))]
2584 "s390_match_ccmode (insn, CCSmode)"
2586 "&& reload_completed"
2587 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
2589 [(set (match_dup 2) (match_dup 3))
2590 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
2592 rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
2593 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
2594 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
2597 (define_insn_and_split "*cmpint_sign"
2598 [(set (match_operand:DI 0 "register_operand" "=d")
2599 (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2601 (clobber (reg:CC CC_REGNUM))]
2604 "&& reload_completed"
2605 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
2607 [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
2608 (clobber (reg:CC CC_REGNUM))])])
2610 (define_insn_and_split "*cmpint_sign_cc"
2611 [(set (reg CC_REGNUM)
2612 (compare (ashiftrt:DI (ashift:DI (subreg:DI
2613 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2615 (const_int 32)) (const_int 32))
2617 (set (match_operand:DI 0 "register_operand" "=d")
2618 (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_CMPINT)))]
2619 "s390_match_ccmode (insn, CCSmode) && TARGET_64BIT"
2621 "&& reload_completed"
2622 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
2624 [(set (match_dup 2) (match_dup 3))
2625 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
2627 rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
2628 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
2629 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
2634 ;;- Conversion instructions.
2637 (define_insn "*sethighpartsi"
2638 [(set (match_operand:SI 0 "register_operand" "=d,d")
2639 (unspec:SI [(match_operand:BLK 1 "s_operand" "Q,S")
2640 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
2641 (clobber (reg:CC CC_REGNUM))]
2646 [(set_attr "op_type" "RS,RSY")])
2648 (define_insn "*sethighpartdi_64"
2649 [(set (match_operand:DI 0 "register_operand" "=d")
2650 (unspec:DI [(match_operand:BLK 1 "s_operand" "QS")
2651 (match_operand 2 "const_int_operand" "n")] UNSPEC_ICM))
2652 (clobber (reg:CC CC_REGNUM))]
2655 [(set_attr "op_type" "RSY")])
2657 (define_insn "*sethighpartdi_31"
2658 [(set (match_operand:DI 0 "register_operand" "=d,d")
2659 (unspec:DI [(match_operand:BLK 1 "s_operand" "Q,S")
2660 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
2661 (clobber (reg:CC CC_REGNUM))]
2666 [(set_attr "op_type" "RS,RSY")])
2668 (define_insn_and_split "*extzv<mode>"
2669 [(set (match_operand:GPR 0 "register_operand" "=d")
2670 (zero_extract:GPR (match_operand:QI 1 "s_operand" "QS")
2671 (match_operand 2 "const_int_operand" "n")
2673 (clobber (reg:CC CC_REGNUM))]
2674 "INTVAL (operands[2]) > 0
2675 && INTVAL (operands[2]) <= GET_MODE_BITSIZE (SImode)"
2677 "&& reload_completed"
2679 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
2680 (clobber (reg:CC CC_REGNUM))])
2681 (set (match_dup 0) (lshiftrt:GPR (match_dup 0) (match_dup 2)))]
2683 int bitsize = INTVAL (operands[2]);
2684 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
2685 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
2687 operands[1] = adjust_address (operands[1], BLKmode, 0);
2688 set_mem_size (operands[1], GEN_INT (size));
2689 operands[2] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - bitsize);
2690 operands[3] = GEN_INT (mask);
2693 (define_insn_and_split "*extv<mode>"
2694 [(set (match_operand:GPR 0 "register_operand" "=d")
2695 (sign_extract:GPR (match_operand:QI 1 "s_operand" "QS")
2696 (match_operand 2 "const_int_operand" "n")
2698 (clobber (reg:CC CC_REGNUM))]
2699 "INTVAL (operands[2]) > 0
2700 && INTVAL (operands[2]) <= GET_MODE_BITSIZE (SImode)"
2702 "&& reload_completed"
2704 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
2705 (clobber (reg:CC CC_REGNUM))])
2707 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
2708 (clobber (reg:CC CC_REGNUM))])]
2710 int bitsize = INTVAL (operands[2]);
2711 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
2712 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
2714 operands[1] = adjust_address (operands[1], BLKmode, 0);
2715 set_mem_size (operands[1], GEN_INT (size));
2716 operands[2] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - bitsize);
2717 operands[3] = GEN_INT (mask);
2721 ; insv instruction patterns
2724 (define_expand "insv"
2725 [(set (zero_extract (match_operand 0 "nonimmediate_operand" "")
2726 (match_operand 1 "const_int_operand" "")
2727 (match_operand 2 "const_int_operand" ""))
2728 (match_operand 3 "general_operand" ""))]
2731 if (s390_expand_insv (operands[0], operands[1], operands[2], operands[3]))
2736 (define_insn "*insv<mode>_mem_reg"
2737 [(set (zero_extract:P (match_operand:QI 0 "memory_operand" "+Q,S")
2738 (match_operand 1 "const_int_operand" "n,n")
2740 (match_operand:P 2 "register_operand" "d,d"))]
2741 "INTVAL (operands[1]) > 0
2742 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
2743 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
2745 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
2747 operands[1] = GEN_INT ((1ul << size) - 1);
2748 return (which_alternative == 0) ? "stcm\t%2,%1,%S0"
2749 : "stcmy\t%2,%1,%S0";
2751 [(set_attr "op_type" "RS,RSY")])
2753 (define_insn "*insvdi_mem_reghigh"
2754 [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "+QS")
2755 (match_operand 1 "const_int_operand" "n")
2757 (lshiftrt:DI (match_operand:DI 2 "register_operand" "d")
2760 && INTVAL (operands[1]) > 0
2761 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
2762 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
2764 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
2766 operands[1] = GEN_INT ((1ul << size) - 1);
2767 return "stcmh\t%2,%1,%S0";
2769 [(set_attr "op_type" "RSY")])
2771 (define_insn "*insv<mode>_reg_imm"
2772 [(set (zero_extract:P (match_operand:P 0 "register_operand" "+d")
2774 (match_operand 1 "const_int_operand" "n"))
2775 (match_operand:P 2 "const_int_operand" "n"))]
2777 && INTVAL (operands[1]) >= 0
2778 && INTVAL (operands[1]) < BITS_PER_WORD
2779 && INTVAL (operands[1]) % 16 == 0"
2781 switch (BITS_PER_WORD - INTVAL (operands[1]))
2783 case 64: return "iihh\t%0,%x2"; break;
2784 case 48: return "iihl\t%0,%x2"; break;
2785 case 32: return "iilh\t%0,%x2"; break;
2786 case 16: return "iill\t%0,%x2"; break;
2787 default: gcc_unreachable();
2790 [(set_attr "op_type" "RI")])
2792 (define_insn "*insv<mode>_reg_extimm"
2793 [(set (zero_extract:P (match_operand:P 0 "register_operand" "+d")
2795 (match_operand 1 "const_int_operand" "n"))
2796 (match_operand:P 2 "const_int_operand" "n"))]
2798 && INTVAL (operands[1]) >= 0
2799 && INTVAL (operands[1]) < BITS_PER_WORD
2800 && INTVAL (operands[1]) % 32 == 0"
2802 switch (BITS_PER_WORD - INTVAL (operands[1]))
2804 case 64: return "iihf\t%0,%o2"; break;
2805 case 32: return "iilf\t%0,%o2"; break;
2806 default: gcc_unreachable();
2809 [(set_attr "op_type" "RIL")])
2812 ; extendsidi2 instruction pattern(s).
2815 (define_expand "extendsidi2"
2816 [(set (match_operand:DI 0 "register_operand" "")
2817 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
2822 emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
2823 emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
2824 emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
2825 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
2830 (define_insn "*extendsidi2"
2831 [(set (match_operand:DI 0 "register_operand" "=d,d")
2832 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
2837 [(set_attr "op_type" "RRE,RXY")])
2840 ; extend(hi|qi)(si|di)2 instruction pattern(s).
2843 (define_expand "extend<HQI:mode><DSI:mode>2"
2844 [(set (match_operand:DSI 0 "register_operand" "")
2845 (sign_extend:DSI (match_operand:HQI 1 "nonimmediate_operand" "")))]
2848 if (<DSI:MODE>mode == DImode && !TARGET_64BIT)
2850 rtx tmp = gen_reg_rtx (SImode);
2851 emit_insn (gen_extend<HQI:mode>si2 (tmp, operands[1]));
2852 emit_insn (gen_extendsidi2 (operands[0], tmp));
2855 else if (!TARGET_EXTIMM)
2857 rtx bitcount = GEN_INT (GET_MODE_BITSIZE (<DSI:MODE>mode) -
2858 GET_MODE_BITSIZE (<HQI:MODE>mode));
2860 operands[1] = gen_lowpart (<DSI:MODE>mode, operands[1]);
2861 emit_insn (gen_ashl<DSI:mode>3 (operands[0], operands[1], bitcount));
2862 emit_insn (gen_ashr<DSI:mode>3 (operands[0], operands[0], bitcount));
2868 ; extendhidi2 instruction pattern(s).
2871 (define_insn "*extendhidi2_extimm"
2872 [(set (match_operand:DI 0 "register_operand" "=d,d")
2873 (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand" "d,m")))]
2874 "TARGET_64BIT && TARGET_EXTIMM"
2878 [(set_attr "op_type" "RRE,RXY")])
2880 (define_insn "*extendhidi2"
2881 [(set (match_operand:DI 0 "register_operand" "=d")
2882 (sign_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
2885 [(set_attr "op_type" "RXY")])
2888 ; extendhisi2 instruction pattern(s).
2891 (define_insn "*extendhisi2_extimm"
2892 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
2893 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d,R,T")))]
2899 [(set_attr "op_type" "RRE,RX,RXY")])
2901 (define_insn "*extendhisi2"
2902 [(set (match_operand:SI 0 "register_operand" "=d,d")
2903 (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
2908 [(set_attr "op_type" "RX,RXY")])
2911 ; extendqi(si|di)2 instruction pattern(s).
2914 ; lbr, lgbr, lb, lgb
2915 (define_insn "*extendqi<mode>2_extimm"
2916 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2917 (sign_extend:GPR (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
2922 [(set_attr "op_type" "RRE,RXY")])
2925 (define_insn "*extendqi<mode>2"
2926 [(set (match_operand:GPR 0 "register_operand" "=d")
2927 (sign_extend:GPR (match_operand:QI 1 "memory_operand" "m")))]
2928 "!TARGET_EXTIMM && TARGET_LONG_DISPLACEMENT"
2930 [(set_attr "op_type" "RXY")])
2932 (define_insn_and_split "*extendqi<mode>2_short_displ"
2933 [(set (match_operand:GPR 0 "register_operand" "=d")
2934 (sign_extend:GPR (match_operand:QI 1 "s_operand" "Q")))
2935 (clobber (reg:CC CC_REGNUM))]
2936 "!TARGET_EXTIMM && !TARGET_LONG_DISPLACEMENT"
2938 "&& reload_completed"
2940 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (const_int 8)] UNSPEC_ICM))
2941 (clobber (reg:CC CC_REGNUM))])
2943 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
2944 (clobber (reg:CC CC_REGNUM))])]
2946 operands[1] = adjust_address (operands[1], BLKmode, 0);
2947 set_mem_size (operands[1], GEN_INT (GET_MODE_SIZE (QImode)));
2948 operands[2] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode)
2949 - GET_MODE_BITSIZE (QImode));
2953 ; zero_extendsidi2 instruction pattern(s).
2956 (define_expand "zero_extendsidi2"
2957 [(set (match_operand:DI 0 "register_operand" "")
2958 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
2963 emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
2964 emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
2965 emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
2970 (define_insn "*zero_extendsidi2"
2971 [(set (match_operand:DI 0 "register_operand" "=d,d")
2972 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
2977 [(set_attr "op_type" "RRE,RXY")])
2980 ; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
2983 (define_insn "*llgt_sidi"
2984 [(set (match_operand:DI 0 "register_operand" "=d")
2985 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0)
2986 (const_int 2147483647)))]
2989 [(set_attr "op_type" "RXE")])
2991 (define_insn_and_split "*llgt_sidi_split"
2992 [(set (match_operand:DI 0 "register_operand" "=d")
2993 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0)
2994 (const_int 2147483647)))
2995 (clobber (reg:CC CC_REGNUM))]
2998 "&& reload_completed"
3000 (and:DI (subreg:DI (match_dup 1) 0)
3001 (const_int 2147483647)))]
3004 (define_insn "*llgt_sisi"
3005 [(set (match_operand:SI 0 "register_operand" "=d,d")
3006 (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,m")
3007 (const_int 2147483647)))]
3012 [(set_attr "op_type" "RRE,RXE")])
3014 (define_insn "*llgt_didi"
3015 [(set (match_operand:DI 0 "register_operand" "=d,d")
3016 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
3017 (const_int 2147483647)))]
3022 [(set_attr "op_type" "RRE,RXE")])
3025 [(set (match_operand:GPR 0 "register_operand" "")
3026 (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
3027 (const_int 2147483647)))
3028 (clobber (reg:CC CC_REGNUM))]
3029 "TARGET_ZARCH && reload_completed"
3031 (and:GPR (match_dup 1)
3032 (const_int 2147483647)))]
3036 ; zero_extend(hi|qi)(si|di)2 instruction pattern(s).
3039 (define_expand "zero_extend<mode>di2"
3040 [(set (match_operand:DI 0 "register_operand" "")
3041 (zero_extend:DI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3046 rtx tmp = gen_reg_rtx (SImode);
3047 emit_insn (gen_zero_extend<mode>si2 (tmp, operands[1]));
3048 emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
3051 else if (!TARGET_EXTIMM)
3053 rtx bitcount = GEN_INT (GET_MODE_BITSIZE(DImode) -
3054 GET_MODE_BITSIZE(<MODE>mode));
3055 operands[1] = gen_lowpart (DImode, operands[1]);
3056 emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
3057 emit_insn (gen_lshrdi3 (operands[0], operands[0], bitcount));
3062 (define_expand "zero_extend<mode>si2"
3063 [(set (match_operand:SI 0 "register_operand" "")
3064 (zero_extend:SI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3069 operands[1] = gen_lowpart (SImode, operands[1]);
3070 emit_insn (gen_andsi3 (operands[0], operands[1],
3071 GEN_INT ((1 << GET_MODE_BITSIZE(<MODE>mode)) - 1)));
3076 ; llhr, llcr, llghr, llgcr, llh, llc, llgh, llgc
3077 (define_insn "*zero_extend<HQI:mode><GPR:mode>2_extimm"
3078 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3079 (zero_extend:GPR (match_operand:HQI 1 "nonimmediate_operand" "d,m")))]
3084 [(set_attr "op_type" "RRE,RXY")])
3087 (define_insn "*zero_extend<HQI:mode><GPR:mode>2"
3088 [(set (match_operand:GPR 0 "register_operand" "=d")
3089 (zero_extend:GPR (match_operand:HQI 1 "memory_operand" "m")))]
3090 "TARGET_ZARCH && !TARGET_EXTIMM"
3092 [(set_attr "op_type" "RXY")])
3094 (define_insn_and_split "*zero_extendhisi2_31"
3095 [(set (match_operand:SI 0 "register_operand" "=&d")
3096 (zero_extend:SI (match_operand:HI 1 "s_operand" "QS")))
3097 (clobber (reg:CC CC_REGNUM))]
3100 "&& reload_completed"
3101 [(set (match_dup 0) (const_int 0))
3103 [(set (strict_low_part (match_dup 2)) (match_dup 1))
3104 (clobber (reg:CC CC_REGNUM))])]
3105 "operands[2] = gen_lowpart (HImode, operands[0]);")
3107 (define_insn_and_split "*zero_extendqisi2_31"
3108 [(set (match_operand:SI 0 "register_operand" "=&d")
3109 (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
3112 "&& reload_completed"
3113 [(set (match_dup 0) (const_int 0))
3114 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3115 "operands[2] = gen_lowpart (QImode, operands[0]);")
3118 ; zero_extendqihi2 instruction pattern(s).
3121 (define_expand "zero_extendqihi2"
3122 [(set (match_operand:HI 0 "register_operand" "")
3123 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
3124 "TARGET_ZARCH && !TARGET_EXTIMM"
3126 operands[1] = gen_lowpart (HImode, operands[1]);
3127 emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
3131 (define_insn "*zero_extendqihi2_64"
3132 [(set (match_operand:HI 0 "register_operand" "=d")
3133 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
3134 "TARGET_ZARCH && !TARGET_EXTIMM"
3136 [(set_attr "op_type" "RXY")])
3138 (define_insn_and_split "*zero_extendqihi2_31"
3139 [(set (match_operand:HI 0 "register_operand" "=&d")
3140 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
3143 "&& reload_completed"
3144 [(set (match_dup 0) (const_int 0))
3145 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3146 "operands[2] = gen_lowpart (QImode, operands[0]);")
3149 ; fixuns_trunc(dd|td)di2 instruction pattern(s).
3152 (define_expand "fixuns_truncdddi2"
3154 [(set (match_operand:DI 0 "register_operand" "")
3155 (unsigned_fix:DI (match_operand:DD 1 "register_operand" "")))
3156 (clobber (match_scratch:TD 2 "=f"))])]
3158 "TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3160 rtx label1 = gen_label_rtx ();
3161 rtx label2 = gen_label_rtx ();
3162 rtx temp = gen_reg_rtx (TDmode);
3163 REAL_VALUE_TYPE cmp, sub;
3165 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
3166 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
3168 /* 2^63 can't be represented as 64bit DFP number with full precision. The
3169 solution is doing the check and the subtraction in TD mode and using a
3170 TD -> DI convert afterwards. */
3171 emit_insn (gen_extendddtd2 (temp, operands[1]));
3172 temp = force_reg (TDmode, temp);
3173 emit_insn (gen_cmptd (temp,
3174 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode)));
3175 emit_jump_insn (gen_blt (label1));
3176 emit_insn (gen_subtd3 (temp, temp,
3177 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
3178 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
3181 emit_label (label1);
3182 emit_insn (gen_fix_truncdddi2_dfp (operands[0], operands[1], GEN_INT (9)));
3183 emit_label (label2);
3187 (define_expand "fixuns_trunctddi2"
3188 [(set (match_operand:DI 0 "register_operand" "")
3189 (unsigned_fix:DI (match_operand:TD 1 "register_operand" "")))]
3190 "TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3192 rtx label1 = gen_label_rtx ();
3193 rtx label2 = gen_label_rtx ();
3194 rtx temp = gen_reg_rtx (TDmode);
3195 REAL_VALUE_TYPE cmp, sub;
3197 operands[1] = force_reg (TDmode, operands[1]);
3198 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
3199 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
3201 emit_insn (gen_cmptd (operands[1],
3202 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode)));
3203 emit_jump_insn (gen_blt (label1));
3204 emit_insn (gen_subtd3 (temp, operands[1],
3205 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
3206 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
3209 emit_label (label1);
3210 emit_insn (gen_fix_trunctddi2_dfp (operands[0], operands[1], GEN_INT (9)));
3211 emit_label (label2);
3216 ; fixuns_trunc(sf|df)(si|di)2 and fix_trunc(sf|df)(si|di)2
3217 ; instruction pattern(s).
3220 (define_expand "fixuns_trunc<BFP:mode><GPR:mode>2"
3221 [(set (match_operand:GPR 0 "register_operand" "")
3222 (unsigned_fix:GPR (match_operand:BFP 1 "register_operand" "")))]
3223 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3225 rtx label1 = gen_label_rtx ();
3226 rtx label2 = gen_label_rtx ();
3227 rtx temp = gen_reg_rtx (<BFP:MODE>mode);
3228 REAL_VALUE_TYPE cmp, sub;
3230 operands[1] = force_reg (<BFP:MODE>mode, operands[1]);
3231 real_2expN (&cmp, GET_MODE_BITSIZE(<GPR:MODE>mode) - 1);
3232 real_2expN (&sub, GET_MODE_BITSIZE(<GPR:MODE>mode));
3234 emit_insn (gen_cmp<BFP:mode> (operands[1],
3235 CONST_DOUBLE_FROM_REAL_VALUE (cmp, <BFP:MODE>mode)));
3236 emit_jump_insn (gen_blt (label1));
3237 emit_insn (gen_sub<BFP:mode>3 (temp, operands[1],
3238 CONST_DOUBLE_FROM_REAL_VALUE (sub, <BFP:MODE>mode)));
3239 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_ieee (operands[0], temp,
3243 emit_label (label1);
3244 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_ieee (operands[0],
3245 operands[1], GEN_INT (5)));
3246 emit_label (label2);
3250 (define_expand "fix_trunc<mode>di2"
3251 [(set (match_operand:DI 0 "register_operand" "")
3252 (fix:DI (match_operand:DSF 1 "nonimmediate_operand" "")))]
3253 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3255 operands[1] = force_reg (<MODE>mode, operands[1]);
3256 emit_insn (gen_fix_trunc<mode>di2_ieee (operands[0], operands[1],
3261 ; cgxbr, cgdbr, cgebr, cfxbr, cfdbr, cfebr
3262 (define_insn "fix_trunc<BFP:mode><GPR:mode>2_ieee"
3263 [(set (match_operand:GPR 0 "register_operand" "=d")
3264 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
3265 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
3266 (clobber (reg:CC CC_REGNUM))]
3267 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3268 "c<GPR:gf><BFP:xde>br\t%0,%h2,%1"
3269 [(set_attr "op_type" "RRE")
3270 (set_attr "type" "ftoi")])
3274 ; fix_trunc(td|dd)di2 instruction pattern(s).
3277 (define_expand "fix_trunc<mode>di2"
3278 [(set (match_operand:DI 0 "register_operand" "")
3279 (fix:DI (match_operand:DFP 1 "nonimmediate_operand" "")))]
3280 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3282 operands[1] = force_reg (<MODE>mode, operands[1]);
3283 emit_insn (gen_fix_trunc<mode>di2_dfp (operands[0], operands[1],
3289 (define_insn "fix_trunc<DFP:mode>di2_dfp"
3290 [(set (match_operand:DI 0 "register_operand" "=d")
3291 (fix:DI (match_operand:DFP 1 "register_operand" "f")))
3292 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
3293 (clobber (reg:CC CC_REGNUM))]
3294 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3295 "cg<DFP:xde>tr\t%0,%h2,%1"
3296 [(set_attr "op_type" "RRF")
3297 (set_attr "type" "ftoi")])
3301 ; fix_trunctf(si|di)2 instruction pattern(s).
3304 (define_expand "fix_trunctf<mode>2"
3305 [(parallel [(set (match_operand:GPR 0 "register_operand" "")
3306 (fix:GPR (match_operand:TF 1 "register_operand" "")))
3307 (unspec:GPR [(const_int 5)] UNSPEC_ROUND)
3308 (clobber (reg:CC CC_REGNUM))])]
3309 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3313 ; fix_truncdfsi2 instruction pattern(s).
3316 (define_expand "fix_truncdfsi2"
3317 [(set (match_operand:SI 0 "register_operand" "")
3318 (fix:SI (match_operand:DF 1 "nonimmediate_operand" "")))]
3321 if (TARGET_IBM_FLOAT)
3323 /* This is the algorithm from POP chapter A.5.7.2. */
3325 rtx temp = assign_stack_local (BLKmode, 8, BITS_PER_WORD);
3326 rtx two31r = s390_gen_rtx_const_DI (0x4f000000, 0x08000000);
3327 rtx two32 = s390_gen_rtx_const_DI (0x4e000001, 0x00000000);
3329 operands[1] = force_reg (DFmode, operands[1]);
3330 emit_insn (gen_fix_truncdfsi2_ibm (operands[0], operands[1],
3331 two31r, two32, temp));
3335 operands[1] = force_reg (DFmode, operands[1]);
3336 emit_insn (gen_fix_truncdfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
3342 (define_insn "fix_truncdfsi2_ibm"
3343 [(set (match_operand:SI 0 "register_operand" "=d")
3344 (fix:SI (match_operand:DF 1 "nonimmediate_operand" "+f")))
3345 (use (match_operand:DI 2 "immediate_operand" "m"))
3346 (use (match_operand:DI 3 "immediate_operand" "m"))
3347 (use (match_operand:BLK 4 "memory_operand" "m"))
3348 (clobber (reg:CC CC_REGNUM))]
3349 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3351 output_asm_insn ("sd\t%1,%2", operands);
3352 output_asm_insn ("aw\t%1,%3", operands);
3353 output_asm_insn ("std\t%1,%4", operands);
3354 output_asm_insn ("xi\t%N4,128", operands);
3357 [(set_attr "length" "20")])
3360 ; fix_truncsfsi2 instruction pattern(s).
3363 (define_expand "fix_truncsfsi2"
3364 [(set (match_operand:SI 0 "register_operand" "")
3365 (fix:SI (match_operand:SF 1 "nonimmediate_operand" "")))]
3368 if (TARGET_IBM_FLOAT)
3370 /* Convert to DFmode and then use the POP algorithm. */
3371 rtx temp = gen_reg_rtx (DFmode);
3372 emit_insn (gen_extendsfdf2 (temp, operands[1]));
3373 emit_insn (gen_fix_truncdfsi2 (operands[0], temp));
3377 operands[1] = force_reg (SFmode, operands[1]);
3378 emit_insn (gen_fix_truncsfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
3385 ; float(si|di)(tf|df|sf)2 instruction pattern(s).
3388 ; cxgbr, cdgbr, cegbr, cxgtr, cdgtr
3389 (define_insn "floatdi<mode>2"
3390 [(set (match_operand:FP 0 "register_operand" "=f")
3391 (float:FP (match_operand:DI 1 "register_operand" "d")))]
3392 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3393 "c<xde>g<bt>r\t%0,%1"
3394 [(set_attr "op_type" "RRE")
3395 (set_attr "type" "itof" )])
3397 ; cxfbr, cdfbr, cefbr
3398 (define_insn "floatsi<mode>2_ieee"
3399 [(set (match_operand:BFP 0 "register_operand" "=f")
3400 (float:BFP (match_operand:SI 1 "register_operand" "d")))]
3401 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3403 [(set_attr "op_type" "RRE")
3404 (set_attr "type" "itof" )])
3408 ; floatsi(tf|df)2 instruction pattern(s).
3411 (define_expand "floatsitf2"
3412 [(set (match_operand:TF 0 "register_operand" "")
3413 (float:TF (match_operand:SI 1 "register_operand" "")))]
3414 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3417 (define_expand "floatsidf2"
3418 [(set (match_operand:DF 0 "register_operand" "")
3419 (float:DF (match_operand:SI 1 "register_operand" "")))]
3422 if (TARGET_IBM_FLOAT)
3424 /* This is the algorithm from POP chapter A.5.7.1. */
3426 rtx temp = assign_stack_local (BLKmode, 8, BITS_PER_WORD);
3427 rtx two31 = s390_gen_rtx_const_DI (0x4e000000, 0x80000000);
3429 emit_insn (gen_floatsidf2_ibm (operands[0], operands[1], two31, temp));
3434 (define_insn "floatsidf2_ibm"
3435 [(set (match_operand:DF 0 "register_operand" "=f")
3436 (float:DF (match_operand:SI 1 "register_operand" "d")))
3437 (use (match_operand:DI 2 "immediate_operand" "m"))
3438 (use (match_operand:BLK 3 "memory_operand" "m"))
3439 (clobber (reg:CC CC_REGNUM))]
3440 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3442 output_asm_insn ("st\t%1,%N3", operands);
3443 output_asm_insn ("xi\t%N3,128", operands);
3444 output_asm_insn ("mvc\t%O3(4,%R3),%2", operands);
3445 output_asm_insn ("ld\t%0,%3", operands);
3448 [(set_attr "length" "20")])
3451 ; floatsisf2 instruction pattern(s).
3454 (define_expand "floatsisf2"
3455 [(set (match_operand:SF 0 "register_operand" "")
3456 (float:SF (match_operand:SI 1 "register_operand" "")))]
3459 if (TARGET_IBM_FLOAT)
3461 /* Use the POP algorithm to convert to DFmode and then truncate. */
3462 rtx temp = gen_reg_rtx (DFmode);
3463 emit_insn (gen_floatsidf2 (temp, operands[1]));
3464 emit_insn (gen_truncdfsf2 (operands[0], temp));
3470 ; truncdfsf2 instruction pattern(s).
3473 (define_expand "truncdfsf2"
3474 [(set (match_operand:SF 0 "register_operand" "")
3475 (float_truncate:SF (match_operand:DF 1 "register_operand" "")))]
3479 (define_insn "truncdfsf2_ieee"
3480 [(set (match_operand:SF 0 "register_operand" "=f")
3481 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
3482 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3484 [(set_attr "op_type" "RRE")
3485 (set_attr "type" "ftruncdf")])
3487 (define_insn "truncdfsf2_ibm"
3488 [(set (match_operand:SF 0 "register_operand" "=f,f")
3489 (float_truncate:SF (match_operand:DF 1 "nonimmediate_operand" "f,R")))]
3490 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3494 [(set_attr "op_type" "RR,RX")
3495 (set_attr "type" "floadsf")])
3498 ; trunctfdf2 instruction pattern(s).
3501 (define_expand "trunctfdf2"
3503 [(set (match_operand:DF 0 "register_operand" "")
3504 (float_truncate:DF (match_operand:TF 1 "register_operand" "")))
3505 (clobber (match_scratch:TF 2 "=f"))])]
3509 (define_insn "*trunctfdf2_ieee"
3510 [(set (match_operand:DF 0 "register_operand" "=f")
3511 (float_truncate:DF (match_operand:TF 1 "register_operand" "f")))
3512 (clobber (match_scratch:TF 2 "=f"))]
3513 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3514 "ldxbr\t%2,%1\;ldr\t%0,%2"
3515 [(set_attr "length" "6")
3516 (set_attr "type" "ftrunctf")])
3518 (define_insn "*trunctfdf2_ibm"
3519 [(set (match_operand:DF 0 "register_operand" "=f")
3520 (float_truncate:DF (match_operand:TF 1 "register_operand" "f")))
3521 (clobber (match_scratch:TF 2 "=f"))]
3522 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3523 "ldxr\t%2,%1\;ldr\t%0,%2"
3524 [(set_attr "length" "4")
3525 (set_attr "type" "ftrunctf")])
3528 ; trunctfsf2 instruction pattern(s).
3531 (define_expand "trunctfsf2"
3533 [(set (match_operand:SF 0 "register_operand" "=f")
3534 (float_truncate:SF (match_operand:TF 1 "register_operand" "f")))
3535 (clobber (match_scratch:TF 2 "=f"))])]
3539 (define_insn "*trunctfsf2_ieee"
3540 [(set (match_operand:SF 0 "register_operand" "=f")
3541 (float_truncate:SF (match_operand:TF 1 "register_operand" "f")))
3542 (clobber (match_scratch:TF 2 "=f"))]
3543 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3544 "lexbr\t%2,%1\;ler\t%0,%2"
3545 [(set_attr "length" "6")
3546 (set_attr "type" "ftrunctf")])
3548 (define_insn "*trunctfsf2_ibm"
3549 [(set (match_operand:SF 0 "register_operand" "=f")
3550 (float_truncate:SF (match_operand:TF 1 "register_operand" "f")))
3551 (clobber (match_scratch:TF 2 "=f"))]
3552 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3553 "lexr\t%2,%1\;ler\t%0,%2"
3554 [(set_attr "length" "6")
3555 (set_attr "type" "ftrunctf")])
3558 ; trunctddd2 and truncddsd2 instruction pattern(s).
3561 (define_insn "trunctddd2"
3562 [(set (match_operand:DD 0 "register_operand" "=f")
3563 (float_truncate:DD (match_operand:TD 1 "register_operand" "f")))
3564 (clobber (match_scratch:TD 2 "=f"))]
3565 "TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3566 "ldxtr\t%2,0,%1,0\;ldr\t%0,%2"
3567 [(set_attr "length" "6")
3568 (set_attr "type" "ftrunctf")])
3570 (define_insn "truncddsd2"
3571 [(set (match_operand:SD 0 "register_operand" "=f")
3572 (float_truncate:SD (match_operand:DD 1 "register_operand" "f")))]
3573 "TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3575 [(set_attr "op_type" "RRF")
3576 (set_attr "type" "fsimptf")])
3579 ; extendsfdf2 instruction pattern(s).
3582 (define_expand "extendsfdf2"
3583 [(set (match_operand:DF 0 "register_operand" "")
3584 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "")))]
3587 if (TARGET_IBM_FLOAT)
3589 emit_insn (gen_extendsfdf2_ibm (operands[0], operands[1]));
3594 (define_insn "extendsfdf2_ieee"
3595 [(set (match_operand:DF 0 "register_operand" "=f,f")
3596 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,R")))]
3597 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3601 [(set_attr "op_type" "RRE,RXE")
3602 (set_attr "type" "fsimpsf, floadsf")])
3604 (define_insn "extendsfdf2_ibm"
3605 [(set (match_operand:DF 0 "register_operand" "=f,f")
3606 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,R")))
3607 (clobber (reg:CC CC_REGNUM))]
3608 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3610 sdr\t%0,%0\;ler\t%0,%1
3611 sdr\t%0,%0\;le\t%0,%1"
3612 [(set_attr "length" "4,6")
3613 (set_attr "type" "floadsf")])
3616 ; extenddftf2 instruction pattern(s).
3619 (define_expand "extenddftf2"
3620 [(set (match_operand:TF 0 "register_operand" "")
3621 (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "")))]
3625 (define_insn "*extenddftf2_ieee"
3626 [(set (match_operand:TF 0 "register_operand" "=f,f")
3627 (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "f,R")))]
3628 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3632 [(set_attr "op_type" "RRE,RXE")
3633 (set_attr "type" "fsimptf, floadtf")])
3635 (define_insn "*extenddftf2_ibm"
3636 [(set (match_operand:TF 0 "register_operand" "=f,f")
3637 (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "f,R")))]
3638 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3642 [(set_attr "op_type" "RRE,RXE")
3643 (set_attr "type" "fsimptf, floadtf")])
3646 ; extendsftf2 instruction pattern(s).
3649 (define_expand "extendsftf2"
3650 [(set (match_operand:TF 0 "register_operand" "")
3651 (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "")))]
3655 (define_insn "*extendsftf2_ieee"
3656 [(set (match_operand:TF 0 "register_operand" "=f,f")
3657 (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "f,R")))]
3658 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3662 [(set_attr "op_type" "RRE,RXE")
3663 (set_attr "type" "fsimptf, floadtf")])
3665 (define_insn "*extendsftf2_ibm"
3666 [(set (match_operand:TF 0 "register_operand" "=f,f")
3667 (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "f,R")))]
3668 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3672 [(set_attr "op_type" "RRE,RXE")
3673 (set_attr "type" "fsimptf, floadtf")])
3676 ; extendddtd2 and extendsddd2 instruction pattern(s).
3679 (define_insn "extendddtd2"
3680 [(set (match_operand:TD 0 "register_operand" "=f")
3681 (float_extend:TD (match_operand:DD 1 "register_operand" "f")))]
3682 "TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3684 [(set_attr "op_type" "RRF")
3685 (set_attr "type" "fsimptf")])
3687 (define_insn "extendsddd2"
3688 [(set (match_operand:DD 0 "register_operand" "=f")
3689 (float_extend:DD (match_operand:SD 1 "register_operand" "f")))]
3690 "TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3692 [(set_attr "op_type" "RRF")
3693 (set_attr "type" "fsimptf")])
3696 ;; ARITHMETIC OPERATIONS
3698 ; arithmetic operations set the ConditionCode,
3699 ; because of unpredictable Bits in Register for Halfword and Byte
3700 ; the ConditionCode can be set wrong in operations for Halfword and Byte
3703 ;;- Add instructions.
3707 ; addti3 instruction pattern(s).
3710 (define_insn_and_split "addti3"
3711 [(set (match_operand:TI 0 "register_operand" "=&d")
3712 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
3713 (match_operand:TI 2 "general_operand" "do") ) )
3714 (clobber (reg:CC CC_REGNUM))]
3717 "&& reload_completed"
3719 [(set (reg:CCL1 CC_REGNUM)
3720 (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
3722 (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
3724 [(set (match_dup 3) (plus:DI (plus:DI (match_dup 4) (match_dup 5))
3725 (ltu:DI (reg:CCL1 CC_REGNUM) (const_int 0))))
3726 (clobber (reg:CC CC_REGNUM))])]
3727 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
3728 operands[4] = operand_subword (operands[1], 0, 0, TImode);
3729 operands[5] = operand_subword (operands[2], 0, 0, TImode);
3730 operands[6] = operand_subword (operands[0], 1, 0, TImode);
3731 operands[7] = operand_subword (operands[1], 1, 0, TImode);
3732 operands[8] = operand_subword (operands[2], 1, 0, TImode);")
3735 ; adddi3 instruction pattern(s).
3738 (define_expand "adddi3"
3740 [(set (match_operand:DI 0 "register_operand" "")
3741 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
3742 (match_operand:DI 2 "general_operand" "")))
3743 (clobber (reg:CC CC_REGNUM))])]
3747 (define_insn "*adddi3_sign"
3748 [(set (match_operand:DI 0 "register_operand" "=d,d")
3749 (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3750 (match_operand:DI 1 "register_operand" "0,0")))
3751 (clobber (reg:CC CC_REGNUM))]
3756 [(set_attr "op_type" "RRE,RXY")])
3758 (define_insn "*adddi3_zero_cc"
3759 [(set (reg CC_REGNUM)
3760 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3761 (match_operand:DI 1 "register_operand" "0,0"))
3763 (set (match_operand:DI 0 "register_operand" "=d,d")
3764 (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
3765 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3769 [(set_attr "op_type" "RRE,RXY")])
3771 (define_insn "*adddi3_zero_cconly"
3772 [(set (reg CC_REGNUM)
3773 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3774 (match_operand:DI 1 "register_operand" "0,0"))
3776 (clobber (match_scratch:DI 0 "=d,d"))]
3777 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3781 [(set_attr "op_type" "RRE,RXY")])
3783 (define_insn "*adddi3_zero"
3784 [(set (match_operand:DI 0 "register_operand" "=d,d")
3785 (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3786 (match_operand:DI 1 "register_operand" "0,0")))
3787 (clobber (reg:CC CC_REGNUM))]
3792 [(set_attr "op_type" "RRE,RXY")])
3794 (define_insn_and_split "*adddi3_31z"
3795 [(set (match_operand:DI 0 "register_operand" "=&d")
3796 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
3797 (match_operand:DI 2 "general_operand" "do") ) )
3798 (clobber (reg:CC CC_REGNUM))]
3799 "!TARGET_64BIT && TARGET_CPU_ZARCH"
3801 "&& reload_completed"
3803 [(set (reg:CCL1 CC_REGNUM)
3804 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
3806 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
3808 [(set (match_dup 3) (plus:SI (plus:SI (match_dup 4) (match_dup 5))
3809 (ltu:SI (reg:CCL1 CC_REGNUM) (const_int 0))))
3810 (clobber (reg:CC CC_REGNUM))])]
3811 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3812 operands[4] = operand_subword (operands[1], 0, 0, DImode);
3813 operands[5] = operand_subword (operands[2], 0, 0, DImode);
3814 operands[6] = operand_subword (operands[0], 1, 0, DImode);
3815 operands[7] = operand_subword (operands[1], 1, 0, DImode);
3816 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
3818 (define_insn_and_split "*adddi3_31"
3819 [(set (match_operand:DI 0 "register_operand" "=&d")
3820 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
3821 (match_operand:DI 2 "general_operand" "do") ) )
3822 (clobber (reg:CC CC_REGNUM))]
3825 "&& reload_completed"
3827 [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
3828 (clobber (reg:CC CC_REGNUM))])
3830 [(set (reg:CCL1 CC_REGNUM)
3831 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
3833 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
3835 (if_then_else (ltu (reg:CCL1 CC_REGNUM) (const_int 0))
3837 (label_ref (match_dup 9))))
3839 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
3840 (clobber (reg:CC CC_REGNUM))])
3842 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3843 operands[4] = operand_subword (operands[1], 0, 0, DImode);
3844 operands[5] = operand_subword (operands[2], 0, 0, DImode);
3845 operands[6] = operand_subword (operands[0], 1, 0, DImode);
3846 operands[7] = operand_subword (operands[1], 1, 0, DImode);
3847 operands[8] = operand_subword (operands[2], 1, 0, DImode);
3848 operands[9] = gen_label_rtx ();")
3851 ; addsi3 instruction pattern(s).
3854 (define_expand "addsi3"
3856 [(set (match_operand:SI 0 "register_operand" "")
3857 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
3858 (match_operand:SI 2 "general_operand" "")))
3859 (clobber (reg:CC CC_REGNUM))])]
3863 (define_insn "*addsi3_sign"
3864 [(set (match_operand:SI 0 "register_operand" "=d,d")
3865 (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
3866 (match_operand:SI 1 "register_operand" "0,0")))
3867 (clobber (reg:CC CC_REGNUM))]
3872 [(set_attr "op_type" "RX,RXY")])
3875 ; add(di|si)3 instruction pattern(s).
3878 ; ar, ahi, alfi, slfi, a, ay, agr, aghi, algfi, slgfi, ag
3879 (define_insn "*add<mode>3"
3880 [(set (match_operand:GPR 0 "register_operand" "=d,d,d,d,d,d")
3881 (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0,0")
3882 (match_operand:GPR 2 "general_operand" "d,K,Op,On,R,T") ) )
3883 (clobber (reg:CC CC_REGNUM))]
3892 [(set_attr "op_type" "RR<E>,RI,RIL,RIL,RX<Y>,RXY")])
3894 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg
3895 (define_insn "*add<mode>3_carry1_cc"
3896 [(set (reg CC_REGNUM)
3897 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0")
3898 (match_operand:GPR 2 "general_operand" "d,Op,On,R,T"))
3900 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d,d")
3901 (plus:GPR (match_dup 1) (match_dup 2)))]
3902 "s390_match_ccmode (insn, CCL1mode)"
3909 [(set_attr "op_type" "RR<E>,RIL,RIL,RX<Y>,RXY")])
3911 ; alr, al, aly, algr, alg
3912 (define_insn "*add<mode>3_carry1_cconly"
3913 [(set (reg CC_REGNUM)
3914 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
3915 (match_operand:GPR 2 "general_operand" "d,R,T"))
3917 (clobber (match_scratch:GPR 0 "=d,d,d"))]
3918 "s390_match_ccmode (insn, CCL1mode)"
3923 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")])
3925 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg
3926 (define_insn "*add<mode>3_carry2_cc"
3927 [(set (reg CC_REGNUM)
3928 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0")
3929 (match_operand:GPR 2 "general_operand" "d,Op,On,R,T"))
3931 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d,d")
3932 (plus:GPR (match_dup 1) (match_dup 2)))]
3933 "s390_match_ccmode (insn, CCL1mode)"
3940 [(set_attr "op_type" "RR<E>,RIL,RIL,RX<Y>,RXY")])
3942 ; alr, al, aly, algr, alg
3943 (define_insn "*add<mode>3_carry2_cconly"
3944 [(set (reg CC_REGNUM)
3945 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
3946 (match_operand:GPR 2 "general_operand" "d,R,T"))
3948 (clobber (match_scratch:GPR 0 "=d,d,d"))]
3949 "s390_match_ccmode (insn, CCL1mode)"
3954 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")])
3956 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg
3957 (define_insn "*add<mode>3_cc"
3958 [(set (reg CC_REGNUM)
3959 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0")
3960 (match_operand:GPR 2 "general_operand" "d,Op,On,R,T"))
3962 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d,d")
3963 (plus:GPR (match_dup 1) (match_dup 2)))]
3964 "s390_match_ccmode (insn, CCLmode)"
3971 [(set_attr "op_type" "RR<E>,RIL,RIL,RX<Y>,RXY")])
3973 ; alr, al, aly, algr, alg
3974 (define_insn "*add<mode>3_cconly"
3975 [(set (reg CC_REGNUM)
3976 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
3977 (match_operand:GPR 2 "general_operand" "d,R,T"))
3979 (clobber (match_scratch:GPR 0 "=d,d,d"))]
3980 "s390_match_ccmode (insn, CCLmode)"
3985 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")])
3987 ; alr, al, aly, algr, alg
3988 (define_insn "*add<mode>3_cconly2"
3989 [(set (reg CC_REGNUM)
3990 (compare (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
3991 (neg:GPR (match_operand:GPR 2 "general_operand" "d,R,T"))))
3992 (clobber (match_scratch:GPR 0 "=d,d,d"))]
3993 "s390_match_ccmode(insn, CCLmode)"
3998 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")])
4000 ; ahi, afi, aghi, agfi
4001 (define_insn "*add<mode>3_imm_cc"
4002 [(set (reg CC_REGNUM)
4003 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
4004 (match_operand:GPR 2 "const_int_operand" "K,Os"))
4006 (set (match_operand:GPR 0 "register_operand" "=d,d")
4007 (plus:GPR (match_dup 1) (match_dup 2)))]
4008 "s390_match_ccmode (insn, CCAmode)
4009 && (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")
4010 || CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'O', \"Os\"))
4011 && INTVAL (operands[2]) != -((HOST_WIDE_INT)1 << (GET_MODE_BITSIZE(<MODE>mode) - 1))"
4015 [(set_attr "op_type" "RI,RIL")])
4018 ; add(tf|df|sf|td|dd)3 instruction pattern(s).
4021 (define_expand "add<mode>3"
4023 [(set (match_operand:FP 0 "register_operand" "")
4024 (plus:FP (match_operand:FP 1 "nonimmediate_operand" "")
4025 (match_operand:FP 2 "general_operand" "")))
4026 (clobber (reg:CC CC_REGNUM))])]
4030 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4031 (define_insn "*add<mode>3"
4032 [(set (match_operand:FP 0 "register_operand" "=f, f")
4033 (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4034 (match_operand:FP 2 "general_operand" " f,<Rf>")))
4035 (clobber (reg:CC CC_REGNUM))]
4036 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4038 a<xde><bt>r\t%0,<op1>%2
4040 [(set_attr "op_type" "<RRer>,RXE")
4041 (set_attr "type" "fsimp<bfp>")])
4043 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4044 (define_insn "*add<mode>3_cc"
4045 [(set (reg CC_REGNUM)
4046 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4047 (match_operand:FP 2 "general_operand" " f,<Rf>"))
4048 (match_operand:FP 3 "const0_operand" "")))
4049 (set (match_operand:FP 0 "register_operand" "=f,f")
4050 (plus:FP (match_dup 1) (match_dup 2)))]
4051 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4053 a<xde><bt>r\t%0,<op1>%2
4055 [(set_attr "op_type" "<RRer>,RXE")
4056 (set_attr "type" "fsimp<bfp>")])
4058 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4059 (define_insn "*add<mode>3_cconly"
4060 [(set (reg CC_REGNUM)
4061 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4062 (match_operand:FP 2 "general_operand" " f,<Rf>"))
4063 (match_operand:FP 3 "const0_operand" "")))
4064 (clobber (match_scratch:FP 0 "=f,f"))]
4065 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4067 a<xde><bt>r\t%0,<op1>%2
4069 [(set_attr "op_type" "<RRer>,RXE")
4070 (set_attr "type" "fsimp<bfp>")])
4072 ; axr, adr, aer, ax, ad, ae
4073 (define_insn "*add<mode>3_ibm"
4074 [(set (match_operand:BFP 0 "register_operand" "=f,f")
4075 (plus:BFP (match_operand:BFP 1 "nonimmediate_operand" "%0,0")
4076 (match_operand:BFP 2 "general_operand" "f,<Rf>")))
4077 (clobber (reg:CC CC_REGNUM))]
4078 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4082 [(set_attr "op_type" "<RRe>,<RXe>")
4083 (set_attr "type" "fsimp<mode>")])
4087 ;;- Subtract instructions.
4091 ; subti3 instruction pattern(s).
4094 (define_insn_and_split "subti3"
4095 [(set (match_operand:TI 0 "register_operand" "=&d")
4096 (minus:TI (match_operand:TI 1 "register_operand" "0")
4097 (match_operand:TI 2 "general_operand" "do") ) )
4098 (clobber (reg:CC CC_REGNUM))]
4101 "&& reload_completed"
4103 [(set (reg:CCL2 CC_REGNUM)
4104 (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
4106 (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
4108 [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
4109 (gtu:DI (reg:CCL2 CC_REGNUM) (const_int 0))))
4110 (clobber (reg:CC CC_REGNUM))])]
4111 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
4112 operands[4] = operand_subword (operands[1], 0, 0, TImode);
4113 operands[5] = operand_subword (operands[2], 0, 0, TImode);
4114 operands[6] = operand_subword (operands[0], 1, 0, TImode);
4115 operands[7] = operand_subword (operands[1], 1, 0, TImode);
4116 operands[8] = operand_subword (operands[2], 1, 0, TImode);")
4119 ; subdi3 instruction pattern(s).
4122 (define_expand "subdi3"
4124 [(set (match_operand:DI 0 "register_operand" "")
4125 (minus:DI (match_operand:DI 1 "register_operand" "")
4126 (match_operand:DI 2 "general_operand" "")))
4127 (clobber (reg:CC CC_REGNUM))])]
4131 (define_insn "*subdi3_sign"
4132 [(set (match_operand:DI 0 "register_operand" "=d,d")
4133 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4134 (sign_extend:DI (match_operand:SI 2 "general_operand" "d,m"))))
4135 (clobber (reg:CC CC_REGNUM))]
4140 [(set_attr "op_type" "RRE,RXY")])
4142 (define_insn "*subdi3_zero_cc"
4143 [(set (reg CC_REGNUM)
4144 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4145 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m")))
4147 (set (match_operand:DI 0 "register_operand" "=d,d")
4148 (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
4149 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4153 [(set_attr "op_type" "RRE,RXY")])
4155 (define_insn "*subdi3_zero_cconly"
4156 [(set (reg CC_REGNUM)
4157 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4158 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m")))
4160 (clobber (match_scratch:DI 0 "=d,d"))]
4161 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4165 [(set_attr "op_type" "RRE,RXY")])
4167 (define_insn "*subdi3_zero"
4168 [(set (match_operand:DI 0 "register_operand" "=d,d")
4169 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4170 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))))
4171 (clobber (reg:CC CC_REGNUM))]
4176 [(set_attr "op_type" "RRE,RXY")])
4178 (define_insn_and_split "*subdi3_31z"
4179 [(set (match_operand:DI 0 "register_operand" "=&d")
4180 (minus:DI (match_operand:DI 1 "register_operand" "0")
4181 (match_operand:DI 2 "general_operand" "do") ) )
4182 (clobber (reg:CC CC_REGNUM))]
4183 "!TARGET_64BIT && TARGET_CPU_ZARCH"
4185 "&& reload_completed"
4187 [(set (reg:CCL2 CC_REGNUM)
4188 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
4190 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
4192 [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
4193 (gtu:SI (reg:CCL2 CC_REGNUM) (const_int 0))))
4194 (clobber (reg:CC CC_REGNUM))])]
4195 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4196 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4197 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4198 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4199 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4200 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
4202 (define_insn_and_split "*subdi3_31"
4203 [(set (match_operand:DI 0 "register_operand" "=&d")
4204 (minus:DI (match_operand:DI 1 "register_operand" "0")
4205 (match_operand:DI 2 "general_operand" "do") ) )
4206 (clobber (reg:CC CC_REGNUM))]
4209 "&& reload_completed"
4211 [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
4212 (clobber (reg:CC CC_REGNUM))])
4214 [(set (reg:CCL2 CC_REGNUM)
4215 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
4217 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
4219 (if_then_else (gtu (reg:CCL2 CC_REGNUM) (const_int 0))
4221 (label_ref (match_dup 9))))
4223 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
4224 (clobber (reg:CC CC_REGNUM))])
4226 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4227 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4228 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4229 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4230 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4231 operands[8] = operand_subword (operands[2], 1, 0, DImode);
4232 operands[9] = gen_label_rtx ();")
4235 ; subsi3 instruction pattern(s).
4238 (define_expand "subsi3"
4240 [(set (match_operand:SI 0 "register_operand" "")
4241 (minus:SI (match_operand:SI 1 "register_operand" "")
4242 (match_operand:SI 2 "general_operand" "")))
4243 (clobber (reg:CC CC_REGNUM))])]
4247 (define_insn "*subsi3_sign"
4248 [(set (match_operand:SI 0 "register_operand" "=d,d")
4249 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
4250 (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
4251 (clobber (reg:CC CC_REGNUM))]
4256 [(set_attr "op_type" "RX,RXY")])
4259 ; sub(di|si)3 instruction pattern(s).
4262 ; sr, s, sy, sgr, sg
4263 (define_insn "*sub<mode>3"
4264 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
4265 (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4266 (match_operand:GPR 2 "general_operand" "d,R,T") ) )
4267 (clobber (reg:CC CC_REGNUM))]
4273 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")])
4275 ; slr, sl, sly, slgr, slg
4276 (define_insn "*sub<mode>3_borrow_cc"
4277 [(set (reg CC_REGNUM)
4278 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4279 (match_operand:GPR 2 "general_operand" "d,R,T"))
4281 (set (match_operand:GPR 0 "register_operand" "=d,d,d")
4282 (minus:GPR (match_dup 1) (match_dup 2)))]
4283 "s390_match_ccmode (insn, CCL2mode)"
4288 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")])
4290 ; slr, sl, sly, slgr, slg
4291 (define_insn "*sub<mode>3_borrow_cconly"
4292 [(set (reg CC_REGNUM)
4293 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4294 (match_operand:GPR 2 "general_operand" "d,R,T"))
4296 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4297 "s390_match_ccmode (insn, CCL2mode)"
4302 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")])
4304 ; slr, sl, sly, slgr, slg
4305 (define_insn "*sub<mode>3_cc"
4306 [(set (reg CC_REGNUM)
4307 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4308 (match_operand:GPR 2 "general_operand" "d,R,T"))
4310 (set (match_operand:GPR 0 "register_operand" "=d,d,d")
4311 (minus:GPR (match_dup 1) (match_dup 2)))]
4312 "s390_match_ccmode (insn, CCLmode)"
4317 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")])
4319 ; slr, sl, sly, slgr, slg
4320 (define_insn "*sub<mode>3_cc2"
4321 [(set (reg CC_REGNUM)
4322 (compare (match_operand:GPR 1 "register_operand" "0,0,0")
4323 (match_operand:GPR 2 "general_operand" "d,R,T")))
4324 (set (match_operand:GPR 0 "register_operand" "=d,d,d")
4325 (minus:GPR (match_dup 1) (match_dup 2)))]
4326 "s390_match_ccmode (insn, CCL3mode)"
4331 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")])
4333 ; slr, sl, sly, slgr, slg
4334 (define_insn "*sub<mode>3_cconly"
4335 [(set (reg CC_REGNUM)
4336 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4337 (match_operand:GPR 2 "general_operand" "d,R,T"))
4339 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4340 "s390_match_ccmode (insn, CCLmode)"
4345 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")])
4347 ; slr, sl, sly, slgr, slg
4348 (define_insn "*sub<mode>3_cconly2"
4349 [(set (reg CC_REGNUM)
4350 (compare (match_operand:GPR 1 "register_operand" "0,0,0")
4351 (match_operand:GPR 2 "general_operand" "d,R,T")))
4352 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4353 "s390_match_ccmode (insn, CCL3mode)"
4358 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")])
4361 ; sub(tf|df|sf|td|dd)3 instruction pattern(s).
4364 (define_expand "sub<mode>3"
4366 [(set (match_operand:FP 0 "register_operand" "")
4367 (minus:FP (match_operand:FP 1 "register_operand" "")
4368 (match_operand:FP 2 "general_operand" "")))
4369 (clobber (reg:CC CC_REGNUM))])]
4373 ; sxbr, sdbr, sebr, sxb, sdb, seb, sxtr, sdtr
4374 (define_insn "*sub<mode>3"
4375 [(set (match_operand:FP 0 "register_operand" "=f, f")
4376 (minus:FP (match_operand:FP 1 "register_operand" "<f0>,0")
4377 (match_operand:FP 2 "general_operand" "f,<Rf>")))
4378 (clobber (reg:CC CC_REGNUM))]
4379 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4381 s<xde><bt>r\t%0,<op1>%2
4383 [(set_attr "op_type" "<RRer>,RXE")
4384 (set_attr "type" "fsimp<bfp>")])
4386 ; sxbr, sdbr, sebr, sxb, sdb, seb, sxtr, sdtr
4387 (define_insn "*sub<mode>3_cc"
4388 [(set (reg CC_REGNUM)
4389 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "<f0>,0")
4390 (match_operand:FP 2 "general_operand" "f,<Rf>"))
4391 (match_operand:FP 3 "const0_operand" "")))
4392 (set (match_operand:FP 0 "register_operand" "=f,f")
4393 (minus:FP (match_dup 1) (match_dup 2)))]
4394 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4396 s<xde><bt>r\t%0,<op1>%2
4398 [(set_attr "op_type" "<RRer>,RXE")
4399 (set_attr "type" "fsimp<bfp>")])
4401 ; sxbr, sdbr, sebr, sxb, sdb, seb, sxtr, sdtr
4402 (define_insn "*sub<mode>3_cconly"
4403 [(set (reg CC_REGNUM)
4404 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "<f0>,0")
4405 (match_operand:FP 2 "general_operand" "f,<Rf>"))
4406 (match_operand:FP 3 "const0_operand" "")))
4407 (clobber (match_scratch:FP 0 "=f,f"))]
4408 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4410 s<xde><bt>r\t%0,<op1>%2
4412 [(set_attr "op_type" "<RRer>,RXE")
4413 (set_attr "type" "fsimp<bfp>")])
4415 ; sxr, sdr, ser, sx, sd, se
4416 (define_insn "*sub<mode>3_ibm"
4417 [(set (match_operand:BFP 0 "register_operand" "=f,f")
4418 (minus:BFP (match_operand:BFP 1 "register_operand" "0,0")
4419 (match_operand:BFP 2 "general_operand" "f,<Rf>")))
4420 (clobber (reg:CC CC_REGNUM))]
4421 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4425 [(set_attr "op_type" "<RRe>,<RXe>")
4426 (set_attr "type" "fsimp<mode>")])
4430 ;;- Conditional add/subtract instructions.
4434 ; add(di|si)cc instruction pattern(s).
4437 ; alcr, alc, alcgr, alcg
4438 (define_insn "*add<mode>3_alc_cc"
4439 [(set (reg CC_REGNUM)
4441 (plus:GPR (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0")
4442 (match_operand:GPR 2 "general_operand" "d,m"))
4443 (match_operand:GPR 3 "s390_alc_comparison" ""))
4445 (set (match_operand:GPR 0 "register_operand" "=d,d")
4446 (plus:GPR (plus:GPR (match_dup 1) (match_dup 2)) (match_dup 3)))]
4447 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
4451 [(set_attr "op_type" "RRE,RXY")])
4453 ; alcr, alc, alcgr, alcg
4454 (define_insn "*add<mode>3_alc"
4455 [(set (match_operand:GPR 0 "register_operand" "=d,d")
4456 (plus:GPR (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0")
4457 (match_operand:GPR 2 "general_operand" "d,m"))
4458 (match_operand:GPR 3 "s390_alc_comparison" "")))
4459 (clobber (reg:CC CC_REGNUM))]
4464 [(set_attr "op_type" "RRE,RXY")])
4466 ; slbr, slb, slbgr, slbg
4467 (define_insn "*sub<mode>3_slb_cc"
4468 [(set (reg CC_REGNUM)
4470 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
4471 (match_operand:GPR 2 "general_operand" "d,m"))
4472 (match_operand:GPR 3 "s390_slb_comparison" ""))
4474 (set (match_operand:GPR 0 "register_operand" "=d,d")
4475 (minus:GPR (minus:GPR (match_dup 1) (match_dup 2)) (match_dup 3)))]
4476 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
4480 [(set_attr "op_type" "RRE,RXY")])
4482 ; slbr, slb, slbgr, slbg
4483 (define_insn "*sub<mode>3_slb"
4484 [(set (match_operand:GPR 0 "register_operand" "=d,d")
4485 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
4486 (match_operand:GPR 2 "general_operand" "d,m"))
4487 (match_operand:GPR 3 "s390_slb_comparison" "")))
4488 (clobber (reg:CC CC_REGNUM))]
4493 [(set_attr "op_type" "RRE,RXY")])
4495 (define_expand "add<mode>cc"
4496 [(match_operand:GPR 0 "register_operand" "")
4497 (match_operand 1 "comparison_operator" "")
4498 (match_operand:GPR 2 "register_operand" "")
4499 (match_operand:GPR 3 "const_int_operand" "")]
4501 "if (!s390_expand_addcc (GET_CODE (operands[1]),
4502 s390_compare_op0, s390_compare_op1,
4503 operands[0], operands[2],
4504 operands[3])) FAIL; DONE;")
4507 ; scond instruction pattern(s).
4510 (define_insn_and_split "*scond<mode>"
4511 [(set (match_operand:GPR 0 "register_operand" "=&d")
4512 (match_operand:GPR 1 "s390_alc_comparison" ""))
4513 (clobber (reg:CC CC_REGNUM))]
4516 "&& reload_completed"
4517 [(set (match_dup 0) (const_int 0))
4519 [(set (match_dup 0) (plus:GPR (plus:GPR (match_dup 0) (match_dup 0))
4521 (clobber (reg:CC CC_REGNUM))])]
4524 (define_insn_and_split "*scond<mode>_neg"
4525 [(set (match_operand:GPR 0 "register_operand" "=&d")
4526 (match_operand:GPR 1 "s390_slb_comparison" ""))
4527 (clobber (reg:CC CC_REGNUM))]
4530 "&& reload_completed"
4531 [(set (match_dup 0) (const_int 0))
4533 [(set (match_dup 0) (minus:GPR (minus:GPR (match_dup 0) (match_dup 0))
4535 (clobber (reg:CC CC_REGNUM))])
4537 [(set (match_dup 0) (neg:GPR (match_dup 0)))
4538 (clobber (reg:CC CC_REGNUM))])]
4542 (define_expand "s<code>"
4543 [(set (match_operand:SI 0 "register_operand" "")
4544 (SCOND (match_dup 0)
4547 "if (!s390_expand_addcc (<CODE>, s390_compare_op0, s390_compare_op1,
4548 operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
4550 (define_expand "seq"
4552 [(set (match_operand:SI 0 "register_operand" "=d")
4554 (clobber (reg:CC CC_REGNUM))])
4556 [(set (match_dup 0) (xor:SI (match_dup 0) (const_int 1)))
4557 (clobber (reg:CC CC_REGNUM))])]
4560 if (!s390_compare_emitted || GET_MODE (s390_compare_emitted) != CCZ1mode)
4562 operands[1] = s390_emit_compare (NE, s390_compare_op0, s390_compare_op1);
4563 PUT_MODE (operands[1], SImode);
4566 (define_insn_and_split "*sne"
4567 [(set (match_operand:SI 0 "register_operand" "=d")
4568 (ne:SI (match_operand:CCZ1 1 "register_operand" "0")
4570 (clobber (reg:CC CC_REGNUM))]
4575 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 28)))
4576 (clobber (reg:CC CC_REGNUM))])])
4580 ;;- Multiply instructions.
4584 ; muldi3 instruction pattern(s).
4587 (define_insn "*muldi3_sign"
4588 [(set (match_operand:DI 0 "register_operand" "=d,d")
4589 (mult:DI (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "d,m"))
4590 (match_operand:DI 1 "register_operand" "0,0")))]
4595 [(set_attr "op_type" "RRE,RXY")
4596 (set_attr "type" "imuldi")])
4598 (define_insn "muldi3"
4599 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
4600 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
4601 (match_operand:DI 2 "general_operand" "d,K,m")))]
4607 [(set_attr "op_type" "RRE,RI,RXY")
4608 (set_attr "type" "imuldi")])
4611 ; mulsi3 instruction pattern(s).
4614 (define_insn "*mulsi3_sign"
4615 [(set (match_operand:SI 0 "register_operand" "=d")
4616 (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R"))
4617 (match_operand:SI 1 "register_operand" "0")))]
4620 [(set_attr "op_type" "RX")
4621 (set_attr "type" "imulhi")])
4623 (define_insn "mulsi3"
4624 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
4625 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
4626 (match_operand:SI 2 "general_operand" "d,K,R,T")))]
4633 [(set_attr "op_type" "RRE,RI,RX,RXY")
4634 (set_attr "type" "imulsi,imulhi,imulsi,imulsi")])
4637 ; mulsidi3 instruction pattern(s).
4640 (define_insn "mulsidi3"
4641 [(set (match_operand:DI 0 "register_operand" "=d,d")
4642 (mult:DI (sign_extend:DI
4643 (match_operand:SI 1 "register_operand" "%0,0"))
4645 (match_operand:SI 2 "nonimmediate_operand" "d,R"))))]
4650 [(set_attr "op_type" "RR,RX")
4651 (set_attr "type" "imulsi")])
4654 ; umulsidi3 instruction pattern(s).
4657 (define_insn "umulsidi3"
4658 [(set (match_operand:DI 0 "register_operand" "=d,d")
4659 (mult:DI (zero_extend:DI
4660 (match_operand:SI 1 "register_operand" "%0,0"))
4662 (match_operand:SI 2 "nonimmediate_operand" "d,m"))))]
4663 "!TARGET_64BIT && TARGET_CPU_ZARCH"
4667 [(set_attr "op_type" "RRE,RXY")
4668 (set_attr "type" "imulsi")])
4671 ; mul(tf|df|sf|td|dd)3 instruction pattern(s).
4674 (define_expand "mul<mode>3"
4675 [(set (match_operand:FP 0 "register_operand" "")
4676 (mult:FP (match_operand:FP 1 "nonimmediate_operand" "")
4677 (match_operand:FP 2 "general_operand" "")))]
4681 ; mxbr mdbr, meebr, mxb, mxb, meeb, mdtr, mxtr
4682 (define_insn "*mul<mode>3"
4683 [(set (match_operand:FP 0 "register_operand" "=f,f")
4684 (mult:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4685 (match_operand:FP 2 "general_operand" "f,<Rf>")))]
4686 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4688 m<xdee><bt>r\t%0,<op1>%2
4690 [(set_attr "op_type" "<RRer>,RXE")
4691 (set_attr "type" "fmul<bfp>")])
4693 ; mxr, mdr, mer, mx, md, me
4694 (define_insn "*mul<mode>3_ibm"
4695 [(set (match_operand:BFP 0 "register_operand" "=f,f")
4696 (mult:BFP (match_operand:BFP 1 "nonimmediate_operand" "%0,0")
4697 (match_operand:BFP 2 "general_operand" "f,<Rf>")))]
4698 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4702 [(set_attr "op_type" "<RRe>,<RXe>")
4703 (set_attr "type" "fmul<mode>")])
4705 ; maxbr, madbr, maebr, maxb, madb, maeb
4706 (define_insn "*fmadd<mode>"
4707 [(set (match_operand:DSF 0 "register_operand" "=f,f")
4708 (plus:DSF (mult:DSF (match_operand:DSF 1 "register_operand" "%f,f")
4709 (match_operand:DSF 2 "nonimmediate_operand" "f,R"))
4710 (match_operand:DSF 3 "register_operand" "0,0")))]
4711 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4715 [(set_attr "op_type" "RRE,RXE")
4716 (set_attr "type" "fmul<mode>")])
4718 ; msxbr, msdbr, msebr, msxb, msdb, mseb
4719 (define_insn "*fmsub<mode>"
4720 [(set (match_operand:DSF 0 "register_operand" "=f,f")
4721 (minus:DSF (mult:DSF (match_operand:DSF 1 "register_operand" "f,f")
4722 (match_operand:DSF 2 "nonimmediate_operand" "f,R"))
4723 (match_operand:DSF 3 "register_operand" "0,0")))]
4724 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4728 [(set_attr "op_type" "RRE,RXE")
4729 (set_attr "type" "fmul<mode>")])
4732 ;;- Divide and modulo instructions.
4736 ; divmoddi4 instruction pattern(s).
4739 (define_expand "divmoddi4"
4740 [(parallel [(set (match_operand:DI 0 "general_operand" "")
4741 (div:DI (match_operand:DI 1 "register_operand" "")
4742 (match_operand:DI 2 "general_operand" "")))
4743 (set (match_operand:DI 3 "general_operand" "")
4744 (mod:DI (match_dup 1) (match_dup 2)))])
4745 (clobber (match_dup 4))]
4748 rtx insn, div_equal, mod_equal;
4750 div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
4751 mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
4753 operands[4] = gen_reg_rtx(TImode);
4754 emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
4756 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
4757 set_unique_reg_note (insn, REG_EQUAL, div_equal);
4759 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
4760 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
4765 (define_insn "divmodtidi3"
4766 [(set (match_operand:TI 0 "register_operand" "=d,d")
4770 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
4771 (match_operand:DI 2 "general_operand" "d,m")))
4773 (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
4778 [(set_attr "op_type" "RRE,RXY")
4779 (set_attr "type" "idiv")])
4781 (define_insn "divmodtisi3"
4782 [(set (match_operand:TI 0 "register_operand" "=d,d")
4786 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
4788 (match_operand:SI 2 "nonimmediate_operand" "d,m"))))
4791 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
4796 [(set_attr "op_type" "RRE,RXY")
4797 (set_attr "type" "idiv")])
4800 ; udivmoddi4 instruction pattern(s).
4803 (define_expand "udivmoddi4"
4804 [(parallel [(set (match_operand:DI 0 "general_operand" "")
4805 (udiv:DI (match_operand:DI 1 "general_operand" "")
4806 (match_operand:DI 2 "nonimmediate_operand" "")))
4807 (set (match_operand:DI 3 "general_operand" "")
4808 (umod:DI (match_dup 1) (match_dup 2)))])
4809 (clobber (match_dup 4))]
4812 rtx insn, div_equal, mod_equal, equal;
4814 div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
4815 mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
4816 equal = gen_rtx_IOR (TImode,
4817 gen_rtx_ASHIFT (TImode,
4818 gen_rtx_ZERO_EXTEND (TImode, mod_equal),
4820 gen_rtx_ZERO_EXTEND (TImode, div_equal));
4822 operands[4] = gen_reg_rtx(TImode);
4823 emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4]));
4824 emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
4825 emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
4827 insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
4828 set_unique_reg_note (insn, REG_EQUAL, equal);
4830 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
4831 set_unique_reg_note (insn, REG_EQUAL, div_equal);
4833 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
4834 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
4839 (define_insn "udivmodtidi3"
4840 [(set (match_operand:TI 0 "register_operand" "=d,d")
4845 (umod:TI (match_operand:TI 1 "register_operand" "0,0")
4847 (match_operand:DI 2 "nonimmediate_operand" "d,m")))))
4851 (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
4856 [(set_attr "op_type" "RRE,RXY")
4857 (set_attr "type" "idiv")])
4860 ; divmodsi4 instruction pattern(s).
4863 (define_expand "divmodsi4"
4864 [(parallel [(set (match_operand:SI 0 "general_operand" "")
4865 (div:SI (match_operand:SI 1 "general_operand" "")
4866 (match_operand:SI 2 "nonimmediate_operand" "")))
4867 (set (match_operand:SI 3 "general_operand" "")
4868 (mod:SI (match_dup 1) (match_dup 2)))])
4869 (clobber (match_dup 4))]
4872 rtx insn, div_equal, mod_equal, equal;
4874 div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
4875 mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
4876 equal = gen_rtx_IOR (DImode,
4877 gen_rtx_ASHIFT (DImode,
4878 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
4880 gen_rtx_ZERO_EXTEND (DImode, div_equal));
4882 operands[4] = gen_reg_rtx(DImode);
4883 emit_insn (gen_extendsidi2 (operands[4], operands[1]));
4885 insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
4886 set_unique_reg_note (insn, REG_EQUAL, equal);
4888 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
4889 set_unique_reg_note (insn, REG_EQUAL, div_equal);
4891 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
4892 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
4897 (define_insn "divmoddisi3"
4898 [(set (match_operand:DI 0 "register_operand" "=d,d")
4903 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
4905 (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
4909 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
4914 [(set_attr "op_type" "RR,RX")
4915 (set_attr "type" "idiv")])
4918 ; udivsi3 and umodsi3 instruction pattern(s).
4921 (define_expand "udivmodsi4"
4922 [(parallel [(set (match_operand:SI 0 "general_operand" "")
4923 (udiv:SI (match_operand:SI 1 "general_operand" "")
4924 (match_operand:SI 2 "nonimmediate_operand" "")))
4925 (set (match_operand:SI 3 "general_operand" "")
4926 (umod:SI (match_dup 1) (match_dup 2)))])
4927 (clobber (match_dup 4))]
4928 "!TARGET_64BIT && TARGET_CPU_ZARCH"
4930 rtx insn, div_equal, mod_equal, equal;
4932 div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4933 mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4934 equal = gen_rtx_IOR (DImode,
4935 gen_rtx_ASHIFT (DImode,
4936 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
4938 gen_rtx_ZERO_EXTEND (DImode, div_equal));
4940 operands[4] = gen_reg_rtx(DImode);
4941 emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4]));
4942 emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
4943 emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
4945 insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
4946 set_unique_reg_note (insn, REG_EQUAL, equal);
4948 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
4949 set_unique_reg_note (insn, REG_EQUAL, div_equal);
4951 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
4952 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
4957 (define_insn "udivmoddisi3"
4958 [(set (match_operand:DI 0 "register_operand" "=d,d")
4963 (umod:DI (match_operand:DI 1 "register_operand" "0,0")
4965 (match_operand:SI 2 "nonimmediate_operand" "d,m")))))
4969 (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
4970 "!TARGET_64BIT && TARGET_CPU_ZARCH"
4974 [(set_attr "op_type" "RRE,RXY")
4975 (set_attr "type" "idiv")])
4977 (define_expand "udivsi3"
4978 [(set (match_operand:SI 0 "register_operand" "=d")
4979 (udiv:SI (match_operand:SI 1 "general_operand" "")
4980 (match_operand:SI 2 "general_operand" "")))
4981 (clobber (match_dup 3))]
4982 "!TARGET_64BIT && !TARGET_CPU_ZARCH"
4984 rtx insn, udiv_equal, umod_equal, equal;
4986 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4987 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4988 equal = gen_rtx_IOR (DImode,
4989 gen_rtx_ASHIFT (DImode,
4990 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
4992 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
4994 operands[3] = gen_reg_rtx (DImode);
4996 if (CONSTANT_P (operands[2]))
4998 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
5000 rtx label1 = gen_label_rtx ();
5002 operands[1] = make_safe_from (operands[1], operands[0]);
5003 emit_move_insn (operands[0], const0_rtx);
5004 emit_insn (gen_cmpsi (operands[1], operands[2]));
5005 emit_jump_insn (gen_bltu (label1));
5006 emit_move_insn (operands[0], const1_rtx);
5007 emit_label (label1);
5011 operands[2] = force_reg (SImode, operands[2]);
5012 operands[2] = make_safe_from (operands[2], operands[0]);
5014 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5015 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5017 set_unique_reg_note (insn, REG_EQUAL, equal);
5019 insn = emit_move_insn (operands[0],
5020 gen_lowpart (SImode, operands[3]));
5021 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
5026 rtx label1 = gen_label_rtx ();
5027 rtx label2 = gen_label_rtx ();
5028 rtx label3 = gen_label_rtx ();
5030 operands[1] = force_reg (SImode, operands[1]);
5031 operands[1] = make_safe_from (operands[1], operands[0]);
5032 operands[2] = force_reg (SImode, operands[2]);
5033 operands[2] = make_safe_from (operands[2], operands[0]);
5035 emit_move_insn (operands[0], const0_rtx);
5036 emit_insn (gen_cmpsi (operands[2], operands[1]));
5037 emit_jump_insn (gen_bgtu (label3));
5038 emit_insn (gen_cmpsi (operands[2], const0_rtx));
5039 emit_jump_insn (gen_blt (label2));
5040 emit_insn (gen_cmpsi (operands[2], const1_rtx));
5041 emit_jump_insn (gen_beq (label1));
5042 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5043 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5045 set_unique_reg_note (insn, REG_EQUAL, equal);
5047 insn = emit_move_insn (operands[0],
5048 gen_lowpart (SImode, operands[3]));
5049 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
5052 emit_label (label1);
5053 emit_move_insn (operands[0], operands[1]);
5055 emit_label (label2);
5056 emit_move_insn (operands[0], const1_rtx);
5057 emit_label (label3);
5059 emit_move_insn (operands[0], operands[0]);
5063 (define_expand "umodsi3"
5064 [(set (match_operand:SI 0 "register_operand" "=d")
5065 (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
5066 (match_operand:SI 2 "nonimmediate_operand" "")))
5067 (clobber (match_dup 3))]
5068 "!TARGET_64BIT && !TARGET_CPU_ZARCH"
5070 rtx insn, udiv_equal, umod_equal, equal;
5072 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
5073 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
5074 equal = gen_rtx_IOR (DImode,
5075 gen_rtx_ASHIFT (DImode,
5076 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5078 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
5080 operands[3] = gen_reg_rtx (DImode);
5082 if (CONSTANT_P (operands[2]))
5084 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
5086 rtx label1 = gen_label_rtx ();
5088 operands[1] = make_safe_from (operands[1], operands[0]);
5089 emit_move_insn (operands[0], operands[1]);
5090 emit_insn (gen_cmpsi (operands[0], operands[2]));
5091 emit_jump_insn (gen_bltu (label1));
5092 emit_insn (gen_abssi2 (operands[0], operands[2]));
5093 emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
5094 emit_label (label1);
5098 operands[2] = force_reg (SImode, operands[2]);
5099 operands[2] = make_safe_from (operands[2], operands[0]);
5101 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5102 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5104 set_unique_reg_note (insn, REG_EQUAL, equal);
5106 insn = emit_move_insn (operands[0],
5107 gen_highpart (SImode, operands[3]));
5108 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
5113 rtx label1 = gen_label_rtx ();
5114 rtx label2 = gen_label_rtx ();
5115 rtx label3 = gen_label_rtx ();
5117 operands[1] = force_reg (SImode, operands[1]);
5118 operands[1] = make_safe_from (operands[1], operands[0]);
5119 operands[2] = force_reg (SImode, operands[2]);
5120 operands[2] = make_safe_from (operands[2], operands[0]);
5122 emit_move_insn(operands[0], operands[1]);
5123 emit_insn (gen_cmpsi (operands[2], operands[1]));
5124 emit_jump_insn (gen_bgtu (label3));
5125 emit_insn (gen_cmpsi (operands[2], const0_rtx));
5126 emit_jump_insn (gen_blt (label2));
5127 emit_insn (gen_cmpsi (operands[2], const1_rtx));
5128 emit_jump_insn (gen_beq (label1));
5129 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5130 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5132 set_unique_reg_note (insn, REG_EQUAL, equal);
5134 insn = emit_move_insn (operands[0],
5135 gen_highpart (SImode, operands[3]));
5136 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
5139 emit_label (label1);
5140 emit_move_insn (operands[0], const0_rtx);
5142 emit_label (label2);
5143 emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
5144 emit_label (label3);
5150 ; div(df|sf)3 instruction pattern(s).
5153 (define_expand "div<mode>3"
5154 [(set (match_operand:FP 0 "register_operand" "")
5155 (div:FP (match_operand:FP 1 "register_operand" "")
5156 (match_operand:FP 2 "general_operand" "")))]
5160 ; dxbr, ddbr, debr, dxb, ddb, deb, ddtr, dxtr
5161 (define_insn "*div<mode>3"
5162 [(set (match_operand:FP 0 "register_operand" "=f,f")
5163 (div:FP (match_operand:FP 1 "register_operand" "<f0>,0")
5164 (match_operand:FP 2 "general_operand" "f,<Rf>")))]
5165 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5167 d<xde><bt>r\t%0,<op1>%2
5169 [(set_attr "op_type" "<RRer>,RXE")
5170 (set_attr "type" "fdiv<bfp>")])
5172 ; dxr, ddr, der, dx, dd, de
5173 (define_insn "*div<mode>3_ibm"
5174 [(set (match_operand:BFP 0 "register_operand" "=f,f")
5175 (div:BFP (match_operand:BFP 1 "register_operand" "0,0")
5176 (match_operand:BFP 2 "general_operand" "f,<Rf>")))]
5177 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5181 [(set_attr "op_type" "<RRe>,<RXe>")
5182 (set_attr "type" "fdiv<mode>")])
5186 ;;- And instructions.
5189 (define_expand "and<mode>3"
5190 [(set (match_operand:INT 0 "nonimmediate_operand" "")
5191 (and:INT (match_operand:INT 1 "nonimmediate_operand" "")
5192 (match_operand:INT 2 "general_operand" "")))
5193 (clobber (reg:CC CC_REGNUM))]
5195 "s390_expand_logical_operator (AND, <MODE>mode, operands); DONE;")
5198 ; anddi3 instruction pattern(s).
5201 (define_insn "*anddi3_cc"
5202 [(set (reg CC_REGNUM)
5203 (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5204 (match_operand:DI 2 "general_operand" "d,m"))
5206 (set (match_operand:DI 0 "register_operand" "=d,d")
5207 (and:DI (match_dup 1) (match_dup 2)))]
5208 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5212 [(set_attr "op_type" "RRE,RXY")])
5214 (define_insn "*anddi3_cconly"
5215 [(set (reg CC_REGNUM)
5216 (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5217 (match_operand:DI 2 "general_operand" "d,m"))
5219 (clobber (match_scratch:DI 0 "=d,d"))]
5220 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT
5221 /* Do not steal TM patterns. */
5222 && s390_single_part (operands[2], DImode, HImode, 0) < 0"
5226 [(set_attr "op_type" "RRE,RXY")])
5228 (define_insn "*anddi3_extimm"
5229 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,d,d,AQ,Q")
5230 (and:DI (match_operand:DI 1 "nonimmediate_operand"
5231 "%d,o,0,0,0,0,0,0,0,0,0,0")
5232 (match_operand:DI 2 "general_operand"
5233 "M,M,N0HDF,N1HDF,N2HDF,N3HDF,N0SDF,N1SDF,d,m,NxQDF,Q")))
5234 (clobber (reg:CC CC_REGNUM))]
5235 "TARGET_64BIT && TARGET_EXTIMM && s390_logical_operator_ok_p (operands)"
5249 [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RIL,RIL,RRE,RXY,SI,SS")])
5251 (define_insn "*anddi3"
5252 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
5253 (and:DI (match_operand:DI 1 "nonimmediate_operand"
5254 "%d,o,0,0,0,0,0,0,0,0")
5255 (match_operand:DI 2 "general_operand"
5256 "M,M,N0HDF,N1HDF,N2HDF,N3HDF,d,m,NxQDF,Q")))
5257 (clobber (reg:CC CC_REGNUM))]
5258 "TARGET_64BIT && !TARGET_EXTIMM && s390_logical_operator_ok_p (operands)"
5270 [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RRE,RXY,SI,SS")])
5273 [(set (match_operand:DI 0 "s_operand" "")
5274 (and:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
5275 (clobber (reg:CC CC_REGNUM))]
5278 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5279 (clobber (reg:CC CC_REGNUM))])]
5280 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5284 ; andsi3 instruction pattern(s).
5287 (define_insn "*andsi3_cc"
5288 [(set (reg CC_REGNUM)
5289 (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5290 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
5292 (set (match_operand:SI 0 "register_operand" "=d,d,d,d")
5293 (and:SI (match_dup 1) (match_dup 2)))]
5294 "s390_match_ccmode(insn, CCTmode)"
5300 [(set_attr "op_type" "RIL,RR,RX,RXY")])
5302 (define_insn "*andsi3_cconly"
5303 [(set (reg CC_REGNUM)
5304 (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5305 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
5307 (clobber (match_scratch:SI 0 "=d,d,d,d"))]
5308 "s390_match_ccmode(insn, CCTmode)
5309 /* Do not steal TM patterns. */
5310 && s390_single_part (operands[2], SImode, HImode, 0) < 0"
5316 [(set_attr "op_type" "RIL,RR,RX,RXY")])
5318 (define_insn "*andsi3_zarch"
5319 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
5320 (and:SI (match_operand:SI 1 "nonimmediate_operand"
5321 "%d,o,0,0,0,0,0,0,0,0")
5322 (match_operand:SI 2 "general_operand"
5323 "M,M,N0HSF,N1HSF,Os,d,R,T,NxQSF,Q")))
5324 (clobber (reg:CC CC_REGNUM))]
5325 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5337 [(set_attr "op_type" "RRE,RXE,RI,RI,RIL,RR,RX,RXY,SI,SS")])
5339 (define_insn "*andsi3_esa"
5340 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5341 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5342 (match_operand:SI 2 "general_operand" "d,R,NxQSF,Q")))
5343 (clobber (reg:CC CC_REGNUM))]
5344 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5350 [(set_attr "op_type" "RR,RX,SI,SS")])
5353 [(set (match_operand:SI 0 "s_operand" "")
5354 (and:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
5355 (clobber (reg:CC CC_REGNUM))]
5358 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5359 (clobber (reg:CC CC_REGNUM))])]
5360 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5363 ; andhi3 instruction pattern(s).
5366 (define_insn "*andhi3_zarch"
5367 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5368 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
5369 (match_operand:HI 2 "general_operand" "d,n,NxQHF,Q")))
5370 (clobber (reg:CC CC_REGNUM))]
5371 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5377 [(set_attr "op_type" "RR,RI,SI,SS")])
5379 (define_insn "*andhi3_esa"
5380 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
5381 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
5382 (match_operand:HI 2 "general_operand" "d,NxQHF,Q")))
5383 (clobber (reg:CC CC_REGNUM))]
5384 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5389 [(set_attr "op_type" "RR,SI,SS")])
5392 [(set (match_operand:HI 0 "s_operand" "")
5393 (and:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
5394 (clobber (reg:CC CC_REGNUM))]
5397 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5398 (clobber (reg:CC CC_REGNUM))])]
5399 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5402 ; andqi3 instruction pattern(s).
5405 (define_insn "*andqi3_zarch"
5406 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
5407 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
5408 (match_operand:QI 2 "general_operand" "d,n,n,n,Q")))
5409 (clobber (reg:CC CC_REGNUM))]
5410 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5417 [(set_attr "op_type" "RR,RI,SI,SIY,SS")])
5419 (define_insn "*andqi3_esa"
5420 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
5421 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
5422 (match_operand:QI 2 "general_operand" "d,n,Q")))
5423 (clobber (reg:CC CC_REGNUM))]
5424 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5429 [(set_attr "op_type" "RR,SI,SS")])
5432 ; Block and (NC) patterns.
5436 [(set (match_operand:BLK 0 "memory_operand" "=Q")
5437 (and:BLK (match_dup 0)
5438 (match_operand:BLK 1 "memory_operand" "Q")))
5439 (use (match_operand 2 "const_int_operand" "n"))
5440 (clobber (reg:CC CC_REGNUM))]
5441 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
5442 "nc\t%O0(%2,%R0),%S1"
5443 [(set_attr "op_type" "SS")])
5446 [(set (match_operand 0 "memory_operand" "")
5448 (match_operand 1 "memory_operand" "")))
5449 (clobber (reg:CC CC_REGNUM))]
5451 && GET_MODE (operands[0]) == GET_MODE (operands[1])
5452 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
5454 [(set (match_dup 0) (and:BLK (match_dup 0) (match_dup 1)))
5456 (clobber (reg:CC CC_REGNUM))])]
5458 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
5459 operands[0] = adjust_address (operands[0], BLKmode, 0);
5460 operands[1] = adjust_address (operands[1], BLKmode, 0);
5465 [(set (match_operand:BLK 0 "memory_operand" "")
5466 (and:BLK (match_dup 0)
5467 (match_operand:BLK 1 "memory_operand" "")))
5468 (use (match_operand 2 "const_int_operand" ""))
5469 (clobber (reg:CC CC_REGNUM))])
5471 [(set (match_operand:BLK 3 "memory_operand" "")
5472 (and:BLK (match_dup 3)
5473 (match_operand:BLK 4 "memory_operand" "")))
5474 (use (match_operand 5 "const_int_operand" ""))
5475 (clobber (reg:CC CC_REGNUM))])]
5476 "s390_offset_p (operands[0], operands[3], operands[2])
5477 && s390_offset_p (operands[1], operands[4], operands[2])
5478 && !s390_overlap_p (operands[0], operands[1],
5479 INTVAL (operands[2]) + INTVAL (operands[5]))
5480 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
5482 [(set (match_dup 6) (and:BLK (match_dup 6) (match_dup 7)))
5484 (clobber (reg:CC CC_REGNUM))])]
5485 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
5486 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
5487 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
5491 ;;- Bit set (inclusive or) instructions.
5494 (define_expand "ior<mode>3"
5495 [(set (match_operand:INT 0 "nonimmediate_operand" "")
5496 (ior:INT (match_operand:INT 1 "nonimmediate_operand" "")
5497 (match_operand:INT 2 "general_operand" "")))
5498 (clobber (reg:CC CC_REGNUM))]
5500 "s390_expand_logical_operator (IOR, <MODE>mode, operands); DONE;")
5503 ; iordi3 instruction pattern(s).
5506 (define_insn "*iordi3_cc"
5507 [(set (reg CC_REGNUM)
5508 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5509 (match_operand:DI 2 "general_operand" "d,m"))
5511 (set (match_operand:DI 0 "register_operand" "=d,d")
5512 (ior:DI (match_dup 1) (match_dup 2)))]
5513 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5517 [(set_attr "op_type" "RRE,RXY")])
5519 (define_insn "*iordi3_cconly"
5520 [(set (reg CC_REGNUM)
5521 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5522 (match_operand:DI 2 "general_operand" "d,m"))
5524 (clobber (match_scratch:DI 0 "=d,d"))]
5525 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5529 [(set_attr "op_type" "RRE,RXY")])
5531 (define_insn "*iordi3_extimm"
5532 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
5533 (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0,0,0,0")
5534 (match_operand:DI 2 "general_operand"
5535 "N0HD0,N1HD0,N2HD0,N3HD0,N0SD0,N1SD0,d,m,NxQD0,Q")))
5536 (clobber (reg:CC CC_REGNUM))]
5537 "TARGET_64BIT && TARGET_EXTIMM && s390_logical_operator_ok_p (operands)"
5549 [(set_attr "op_type" "RI,RI,RI,RI,RIL,RIL,RRE,RXY,SI,SS")])
5551 (define_insn "*iordi3"
5552 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,AQ,Q")
5553 (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0,0")
5554 (match_operand:DI 2 "general_operand"
5555 "N0HD0,N1HD0,N2HD0,N3HD0,d,m,NxQD0,Q")))
5556 (clobber (reg:CC CC_REGNUM))]
5557 "TARGET_64BIT && !TARGET_EXTIMM && s390_logical_operator_ok_p (operands)"
5567 [(set_attr "op_type" "RI,RI,RI,RI,RRE,RXY,SI,SS")])
5570 [(set (match_operand:DI 0 "s_operand" "")
5571 (ior:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
5572 (clobber (reg:CC CC_REGNUM))]
5575 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
5576 (clobber (reg:CC CC_REGNUM))])]
5577 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
5580 ; iorsi3 instruction pattern(s).
5583 (define_insn "*iorsi3_cc"
5584 [(set (reg CC_REGNUM)
5585 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5586 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
5588 (set (match_operand:SI 0 "register_operand" "=d,d,d,d")
5589 (ior:SI (match_dup 1) (match_dup 2)))]
5590 "s390_match_ccmode(insn, CCTmode)"
5596 [(set_attr "op_type" "RIL,RR,RX,RXY")])
5598 (define_insn "*iorsi3_cconly"
5599 [(set (reg CC_REGNUM)
5600 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5601 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
5603 (clobber (match_scratch:SI 0 "=d,d,d,d"))]
5604 "s390_match_ccmode(insn, CCTmode)"
5610 [(set_attr "op_type" "RIL,RR,RX,RXY")])
5612 (define_insn "*iorsi3_zarch"
5613 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,AQ,Q")
5614 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0,0")
5615 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,Os,d,R,T,NxQS0,Q")))
5616 (clobber (reg:CC CC_REGNUM))]
5617 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5627 [(set_attr "op_type" "RI,RI,RIL,RR,RX,RXY,SI,SS")])
5629 (define_insn "*iorsi3_esa"
5630 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5631 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5632 (match_operand:SI 2 "general_operand" "d,R,NxQS0,Q")))
5633 (clobber (reg:CC CC_REGNUM))]
5634 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5640 [(set_attr "op_type" "RR,RX,SI,SS")])
5643 [(set (match_operand:SI 0 "s_operand" "")
5644 (ior:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
5645 (clobber (reg:CC CC_REGNUM))]
5648 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
5649 (clobber (reg:CC CC_REGNUM))])]
5650 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
5653 ; iorhi3 instruction pattern(s).
5656 (define_insn "*iorhi3_zarch"
5657 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5658 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
5659 (match_operand:HI 2 "general_operand" "d,n,NxQH0,Q")))
5660 (clobber (reg:CC CC_REGNUM))]
5661 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5667 [(set_attr "op_type" "RR,RI,SI,SS")])
5669 (define_insn "*iorhi3_esa"
5670 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
5671 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
5672 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
5673 (clobber (reg:CC CC_REGNUM))]
5674 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5679 [(set_attr "op_type" "RR,SI,SS")])
5682 [(set (match_operand:HI 0 "s_operand" "")
5683 (ior:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
5684 (clobber (reg:CC CC_REGNUM))]
5687 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
5688 (clobber (reg:CC CC_REGNUM))])]
5689 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
5692 ; iorqi3 instruction pattern(s).
5695 (define_insn "*iorqi3_zarch"
5696 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
5697 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
5698 (match_operand:QI 2 "general_operand" "d,n,n,n,Q")))
5699 (clobber (reg:CC CC_REGNUM))]
5700 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5707 [(set_attr "op_type" "RR,RI,SI,SIY,SS")])
5709 (define_insn "*iorqi3_esa"
5710 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
5711 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
5712 (match_operand:QI 2 "general_operand" "d,n,Q")))
5713 (clobber (reg:CC CC_REGNUM))]
5714 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5719 [(set_attr "op_type" "RR,SI,SS")])
5722 ; Block inclusive or (OC) patterns.
5726 [(set (match_operand:BLK 0 "memory_operand" "=Q")
5727 (ior:BLK (match_dup 0)
5728 (match_operand:BLK 1 "memory_operand" "Q")))
5729 (use (match_operand 2 "const_int_operand" "n"))
5730 (clobber (reg:CC CC_REGNUM))]
5731 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
5732 "oc\t%O0(%2,%R0),%S1"
5733 [(set_attr "op_type" "SS")])
5736 [(set (match_operand 0 "memory_operand" "")
5738 (match_operand 1 "memory_operand" "")))
5739 (clobber (reg:CC CC_REGNUM))]
5741 && GET_MODE (operands[0]) == GET_MODE (operands[1])
5742 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
5744 [(set (match_dup 0) (ior:BLK (match_dup 0) (match_dup 1)))
5746 (clobber (reg:CC CC_REGNUM))])]
5748 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
5749 operands[0] = adjust_address (operands[0], BLKmode, 0);
5750 operands[1] = adjust_address (operands[1], BLKmode, 0);
5755 [(set (match_operand:BLK 0 "memory_operand" "")
5756 (ior:BLK (match_dup 0)
5757 (match_operand:BLK 1 "memory_operand" "")))
5758 (use (match_operand 2 "const_int_operand" ""))
5759 (clobber (reg:CC CC_REGNUM))])
5761 [(set (match_operand:BLK 3 "memory_operand" "")
5762 (ior:BLK (match_dup 3)
5763 (match_operand:BLK 4 "memory_operand" "")))
5764 (use (match_operand 5 "const_int_operand" ""))
5765 (clobber (reg:CC CC_REGNUM))])]
5766 "s390_offset_p (operands[0], operands[3], operands[2])
5767 && s390_offset_p (operands[1], operands[4], operands[2])
5768 && !s390_overlap_p (operands[0], operands[1],
5769 INTVAL (operands[2]) + INTVAL (operands[5]))
5770 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
5772 [(set (match_dup 6) (ior:BLK (match_dup 6) (match_dup 7)))
5774 (clobber (reg:CC CC_REGNUM))])]
5775 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
5776 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
5777 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
5781 ;;- Xor instructions.
5784 (define_expand "xor<mode>3"
5785 [(set (match_operand:INT 0 "nonimmediate_operand" "")
5786 (xor:INT (match_operand:INT 1 "nonimmediate_operand" "")
5787 (match_operand:INT 2 "general_operand" "")))
5788 (clobber (reg:CC CC_REGNUM))]
5790 "s390_expand_logical_operator (XOR, <MODE>mode, operands); DONE;")
5793 ; xordi3 instruction pattern(s).
5796 (define_insn "*xordi3_cc"
5797 [(set (reg CC_REGNUM)
5798 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5799 (match_operand:DI 2 "general_operand" "d,m"))
5801 (set (match_operand:DI 0 "register_operand" "=d,d")
5802 (xor:DI (match_dup 1) (match_dup 2)))]
5803 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5807 [(set_attr "op_type" "RRE,RXY")])
5809 (define_insn "*xordi3_cconly"
5810 [(set (reg CC_REGNUM)
5811 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5812 (match_operand:DI 2 "general_operand" "d,m"))
5814 (clobber (match_scratch:DI 0 "=d,d"))]
5815 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5819 [(set_attr "op_type" "RRE,RXY")])
5821 (define_insn "*xordi3_extimm"
5822 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,AQ,Q")
5823 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0")
5824 (match_operand:DI 2 "general_operand" "N0SD0,N1SD0,d,m,NxQD0,Q")))
5825 (clobber (reg:CC CC_REGNUM))]
5826 "TARGET_64BIT && TARGET_EXTIMM && s390_logical_operator_ok_p (operands)"
5834 [(set_attr "op_type" "RIL,RIL,RRE,RXY,SI,SS")])
5836 (define_insn "*xordi3"
5837 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5838 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0")
5839 (match_operand:DI 2 "general_operand" "d,m,NxQD0,Q")))
5840 (clobber (reg:CC CC_REGNUM))]
5841 "TARGET_64BIT && !TARGET_EXTIMM && s390_logical_operator_ok_p (operands)"
5847 [(set_attr "op_type" "RRE,RXY,SI,SS")])
5850 [(set (match_operand:DI 0 "s_operand" "")
5851 (xor:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
5852 (clobber (reg:CC CC_REGNUM))]
5855 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
5856 (clobber (reg:CC CC_REGNUM))])]
5857 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
5860 ; xorsi3 instruction pattern(s).
5863 (define_insn "*xorsi3_cc"
5864 [(set (reg CC_REGNUM)
5865 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5866 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
5868 (set (match_operand:SI 0 "register_operand" "=d,d,d,d")
5869 (xor:SI (match_dup 1) (match_dup 2)))]
5870 "s390_match_ccmode(insn, CCTmode)"
5876 [(set_attr "op_type" "RIL,RR,RX,RXY")])
5878 (define_insn "*xorsi3_cconly"
5879 [(set (reg CC_REGNUM)
5880 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5881 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
5883 (clobber (match_scratch:SI 0 "=d,d,d,d"))]
5884 "s390_match_ccmode(insn, CCTmode)"
5890 [(set_attr "op_type" "RIL,RR,RX,RXY")])
5892 (define_insn "*xorsi3"
5893 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,AQ,Q")
5894 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0,0")
5895 (match_operand:SI 2 "general_operand" "Os,d,R,T,NxQS0,Q")))
5896 (clobber (reg:CC CC_REGNUM))]
5897 "s390_logical_operator_ok_p (operands)"
5905 [(set_attr "op_type" "RIL,RR,RX,RXY,SI,SS")])
5908 [(set (match_operand:SI 0 "s_operand" "")
5909 (xor:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
5910 (clobber (reg:CC CC_REGNUM))]
5913 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
5914 (clobber (reg:CC CC_REGNUM))])]
5915 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
5918 ; xorhi3 instruction pattern(s).
5921 (define_insn "*xorhi3"
5922 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5923 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
5924 (match_operand:HI 2 "general_operand" "Os,d,NxQH0,Q")))
5925 (clobber (reg:CC CC_REGNUM))]
5926 "s390_logical_operator_ok_p (operands)"
5932 [(set_attr "op_type" "RIL,RR,SI,SS")])
5935 [(set (match_operand:HI 0 "s_operand" "")
5936 (xor:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
5937 (clobber (reg:CC CC_REGNUM))]
5940 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
5941 (clobber (reg:CC CC_REGNUM))])]
5942 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
5945 ; xorqi3 instruction pattern(s).
5948 (define_insn "*xorqi3"
5949 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
5950 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
5951 (match_operand:QI 2 "general_operand" "Os,d,n,n,Q")))
5952 (clobber (reg:CC CC_REGNUM))]
5953 "s390_logical_operator_ok_p (operands)"
5960 [(set_attr "op_type" "RIL,RR,SI,SIY,SS")])
5963 ; Block exclusive or (XC) patterns.
5967 [(set (match_operand:BLK 0 "memory_operand" "=Q")
5968 (xor:BLK (match_dup 0)
5969 (match_operand:BLK 1 "memory_operand" "Q")))
5970 (use (match_operand 2 "const_int_operand" "n"))
5971 (clobber (reg:CC CC_REGNUM))]
5972 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
5973 "xc\t%O0(%2,%R0),%S1"
5974 [(set_attr "op_type" "SS")])
5977 [(set (match_operand 0 "memory_operand" "")
5979 (match_operand 1 "memory_operand" "")))
5980 (clobber (reg:CC CC_REGNUM))]
5982 && GET_MODE (operands[0]) == GET_MODE (operands[1])
5983 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
5985 [(set (match_dup 0) (xor:BLK (match_dup 0) (match_dup 1)))
5987 (clobber (reg:CC CC_REGNUM))])]
5989 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
5990 operands[0] = adjust_address (operands[0], BLKmode, 0);
5991 operands[1] = adjust_address (operands[1], BLKmode, 0);
5996 [(set (match_operand:BLK 0 "memory_operand" "")
5997 (xor:BLK (match_dup 0)
5998 (match_operand:BLK 1 "memory_operand" "")))
5999 (use (match_operand 2 "const_int_operand" ""))
6000 (clobber (reg:CC CC_REGNUM))])
6002 [(set (match_operand:BLK 3 "memory_operand" "")
6003 (xor:BLK (match_dup 3)
6004 (match_operand:BLK 4 "memory_operand" "")))
6005 (use (match_operand 5 "const_int_operand" ""))
6006 (clobber (reg:CC CC_REGNUM))])]
6007 "s390_offset_p (operands[0], operands[3], operands[2])
6008 && s390_offset_p (operands[1], operands[4], operands[2])
6009 && !s390_overlap_p (operands[0], operands[1],
6010 INTVAL (operands[2]) + INTVAL (operands[5]))
6011 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6013 [(set (match_dup 6) (xor:BLK (match_dup 6) (match_dup 7)))
6015 (clobber (reg:CC CC_REGNUM))])]
6016 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6017 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6018 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6021 ; Block xor (XC) patterns with src == dest.
6024 (define_insn "*xc_zero"
6025 [(set (match_operand:BLK 0 "memory_operand" "=Q")
6027 (use (match_operand 1 "const_int_operand" "n"))
6028 (clobber (reg:CC CC_REGNUM))]
6029 "INTVAL (operands[1]) >= 1 && INTVAL (operands[1]) <= 256"
6030 "xc\t%O0(%1,%R0),%S0"
6031 [(set_attr "op_type" "SS")])
6035 [(set (match_operand:BLK 0 "memory_operand" "")
6037 (use (match_operand 1 "const_int_operand" ""))
6038 (clobber (reg:CC CC_REGNUM))])
6040 [(set (match_operand:BLK 2 "memory_operand" "")
6042 (use (match_operand 3 "const_int_operand" ""))
6043 (clobber (reg:CC CC_REGNUM))])]
6044 "s390_offset_p (operands[0], operands[2], operands[1])
6045 && INTVAL (operands[1]) + INTVAL (operands[3]) <= 256"
6047 [(set (match_dup 4) (const_int 0))
6049 (clobber (reg:CC CC_REGNUM))])]
6050 "operands[4] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6051 operands[5] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[3]));")
6055 ;;- Negate instructions.
6059 ; neg(di|si)2 instruction pattern(s).
6062 (define_expand "neg<mode>2"
6064 [(set (match_operand:DSI 0 "register_operand" "=d")
6065 (neg:DSI (match_operand:DSI 1 "register_operand" "d")))
6066 (clobber (reg:CC CC_REGNUM))])]
6070 (define_insn "*negdi2_sign_cc"
6071 [(set (reg CC_REGNUM)
6072 (compare (neg:DI (ashiftrt:DI (ashift:DI (subreg:DI
6073 (match_operand:SI 1 "register_operand" "d") 0)
6074 (const_int 32)) (const_int 32)))
6076 (set (match_operand:DI 0 "register_operand" "=d")
6077 (neg:DI (sign_extend:DI (match_dup 1))))]
6078 "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6080 [(set_attr "op_type" "RRE")])
6082 (define_insn "*negdi2_sign"
6083 [(set (match_operand:DI 0 "register_operand" "=d")
6084 (neg:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
6085 (clobber (reg:CC CC_REGNUM))]
6088 [(set_attr "op_type" "RRE")])
6091 (define_insn "*neg<mode>2_cc"
6092 [(set (reg CC_REGNUM)
6093 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
6095 (set (match_operand:GPR 0 "register_operand" "=d")
6096 (neg:GPR (match_dup 1)))]
6097 "s390_match_ccmode (insn, CCAmode)"
6099 [(set_attr "op_type" "RR<E>")])
6102 (define_insn "*neg<mode>2_cconly"
6103 [(set (reg CC_REGNUM)
6104 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
6106 (clobber (match_scratch:GPR 0 "=d"))]
6107 "s390_match_ccmode (insn, CCAmode)"
6109 [(set_attr "op_type" "RR<E>")])
6112 (define_insn "*neg<mode>2"
6113 [(set (match_operand:GPR 0 "register_operand" "=d")
6114 (neg:GPR (match_operand:GPR 1 "register_operand" "d")))
6115 (clobber (reg:CC CC_REGNUM))]
6118 [(set_attr "op_type" "RR<E>")])
6120 (define_insn_and_split "*negdi2_31"
6121 [(set (match_operand:DI 0 "register_operand" "=d")
6122 (neg:DI (match_operand:DI 1 "register_operand" "d")))
6123 (clobber (reg:CC CC_REGNUM))]
6126 "&& reload_completed"
6128 [(set (match_dup 2) (neg:SI (match_dup 3)))
6129 (clobber (reg:CC CC_REGNUM))])
6131 [(set (reg:CCAP CC_REGNUM)
6132 (compare:CCAP (neg:SI (match_dup 5)) (const_int 0)))
6133 (set (match_dup 4) (neg:SI (match_dup 5)))])
6135 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
6137 (label_ref (match_dup 6))))
6139 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
6140 (clobber (reg:CC CC_REGNUM))])
6142 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
6143 operands[3] = operand_subword (operands[1], 0, 0, DImode);
6144 operands[4] = operand_subword (operands[0], 1, 0, DImode);
6145 operands[5] = operand_subword (operands[1], 1, 0, DImode);
6146 operands[6] = gen_label_rtx ();")
6149 ; neg(df|sf)2 instruction pattern(s).
6152 (define_expand "neg<mode>2"
6154 [(set (match_operand:BFP 0 "register_operand" "=f")
6155 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
6156 (clobber (reg:CC CC_REGNUM))])]
6160 ; lcxbr, lcdbr, lcebr
6161 (define_insn "*neg<mode>2_cc"
6162 [(set (reg CC_REGNUM)
6163 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
6164 (match_operand:BFP 2 "const0_operand" "")))
6165 (set (match_operand:BFP 0 "register_operand" "=f")
6166 (neg:BFP (match_dup 1)))]
6167 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6169 [(set_attr "op_type" "RRE")
6170 (set_attr "type" "fsimp<mode>")])
6172 ; lcxbr, lcdbr, lcebr
6173 (define_insn "*neg<mode>2_cconly"
6174 [(set (reg CC_REGNUM)
6175 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
6176 (match_operand:BFP 2 "const0_operand" "")))
6177 (clobber (match_scratch:BFP 0 "=f"))]
6178 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6180 [(set_attr "op_type" "RRE")
6181 (set_attr "type" "fsimp<mode>")])
6184 (define_insn "*neg<mode>2_nocc"
6185 [(set (match_operand:FP 0 "register_operand" "=f")
6186 (neg:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
6187 "TARGET_HARD_FLOAT && TARGET_DFP"
6189 [(set_attr "op_type" "RRE")
6190 (set_attr "type" "fsimp<bfp>")])
6192 ; lcxbr, lcdbr, lcebr
6193 (define_insn "*neg<mode>2"
6194 [(set (match_operand:BFP 0 "register_operand" "=f")
6195 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
6196 (clobber (reg:CC CC_REGNUM))]
6197 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6199 [(set_attr "op_type" "RRE")
6200 (set_attr "type" "fsimp<mode>")])
6203 (define_insn "*neg<mode>2_ibm"
6204 [(set (match_operand:BFP 0 "register_operand" "=f")
6205 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
6206 (clobber (reg:CC CC_REGNUM))]
6207 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
6209 [(set_attr "op_type" "<RRe>")
6210 (set_attr "type" "fsimp<mode>")])
6214 ;;- Absolute value instructions.
6218 ; abs(di|si)2 instruction pattern(s).
6221 (define_insn "*absdi2_sign_cc"
6222 [(set (reg CC_REGNUM)
6223 (compare (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
6224 (match_operand:SI 1 "register_operand" "d") 0)
6225 (const_int 32)) (const_int 32)))
6227 (set (match_operand:DI 0 "register_operand" "=d")
6228 (abs:DI (sign_extend:DI (match_dup 1))))]
6229 "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6231 [(set_attr "op_type" "RRE")])
6233 (define_insn "*absdi2_sign"
6234 [(set (match_operand:DI 0 "register_operand" "=d")
6235 (abs:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
6236 (clobber (reg:CC CC_REGNUM))]
6239 [(set_attr "op_type" "RRE")])
6242 (define_insn "*abs<mode>2_cc"
6243 [(set (reg CC_REGNUM)
6244 (compare (abs:GPR (match_operand:DI 1 "register_operand" "d"))
6246 (set (match_operand:GPR 0 "register_operand" "=d")
6247 (abs:GPR (match_dup 1)))]
6248 "s390_match_ccmode (insn, CCAmode)"
6250 [(set_attr "op_type" "RR<E>")])
6253 (define_insn "*abs<mode>2_cconly"
6254 [(set (reg CC_REGNUM)
6255 (compare (abs:GPR (match_operand:GPR 1 "register_operand" "d"))
6257 (clobber (match_scratch:GPR 0 "=d"))]
6258 "s390_match_ccmode (insn, CCAmode)"
6260 [(set_attr "op_type" "RR<E>")])
6263 (define_insn "abs<mode>2"
6264 [(set (match_operand:GPR 0 "register_operand" "=d")
6265 (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
6266 (clobber (reg:CC CC_REGNUM))]
6269 [(set_attr "op_type" "RR<E>")])
6272 ; abs(df|sf)2 instruction pattern(s).
6275 (define_expand "abs<mode>2"
6277 [(set (match_operand:BFP 0 "register_operand" "=f")
6278 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6279 (clobber (reg:CC CC_REGNUM))])]
6283 ; lpxbr, lpdbr, lpebr
6284 (define_insn "*abs<mode>2_cc"
6285 [(set (reg CC_REGNUM)
6286 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
6287 (match_operand:BFP 2 "const0_operand" "")))
6288 (set (match_operand:BFP 0 "register_operand" "=f")
6289 (abs:BFP (match_dup 1)))]
6290 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6292 [(set_attr "op_type" "RRE")
6293 (set_attr "type" "fsimp<mode>")])
6295 ; lpxbr, lpdbr, lpebr
6296 (define_insn "*abs<mode>2_cconly"
6297 [(set (reg CC_REGNUM)
6298 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
6299 (match_operand:BFP 2 "const0_operand" "")))
6300 (clobber (match_scratch:BFP 0 "=f"))]
6301 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6303 [(set_attr "op_type" "RRE")
6304 (set_attr "type" "fsimp<mode>")])
6307 (define_insn "*abs<mode>2_nocc"
6308 [(set (match_operand:FP 0 "register_operand" "=f")
6309 (abs:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
6310 "TARGET_HARD_FLOAT && TARGET_DFP"
6312 [(set_attr "op_type" "RRE")
6313 (set_attr "type" "fsimp<bfp>")])
6315 ; lpxbr, lpdbr, lpebr
6316 (define_insn "*abs<mode>2"
6317 [(set (match_operand:BFP 0 "register_operand" "=f")
6318 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6319 (clobber (reg:CC CC_REGNUM))]
6320 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6322 [(set_attr "op_type" "RRE")
6323 (set_attr "type" "fsimp<mode>")])
6326 (define_insn "*abs<mode>2_ibm"
6327 [(set (match_operand:BFP 0 "register_operand" "=f")
6328 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6329 (clobber (reg:CC CC_REGNUM))]
6330 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
6332 [(set_attr "op_type" "<RRe>")
6333 (set_attr "type" "fsimp<mode>")])
6336 ;;- Negated absolute value instructions
6343 (define_insn "*negabsdi2_sign_cc"
6344 [(set (reg CC_REGNUM)
6345 (compare (neg:DI (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
6346 (match_operand:SI 1 "register_operand" "d") 0)
6347 (const_int 32)) (const_int 32))))
6349 (set (match_operand:DI 0 "register_operand" "=d")
6350 (neg:DI (abs:DI (sign_extend:DI (match_dup 1)))))]
6351 "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6353 [(set_attr "op_type" "RRE")])
6355 (define_insn "*negabsdi2_sign"
6356 [(set (match_operand:DI 0 "register_operand" "=d")
6357 (neg:DI (abs:DI (sign_extend:DI
6358 (match_operand:SI 1 "register_operand" "d")))))
6359 (clobber (reg:CC CC_REGNUM))]
6362 [(set_attr "op_type" "RRE")])
6365 (define_insn "*negabs<mode>2_cc"
6366 [(set (reg CC_REGNUM)
6367 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
6369 (set (match_operand:GPR 0 "register_operand" "=d")
6370 (neg:GPR (abs:GPR (match_dup 1))))]
6371 "s390_match_ccmode (insn, CCAmode)"
6373 [(set_attr "op_type" "RR<E>")])
6376 (define_insn "*negabs<mode>2_cconly"
6377 [(set (reg CC_REGNUM)
6378 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
6380 (clobber (match_scratch:GPR 0 "=d"))]
6381 "s390_match_ccmode (insn, CCAmode)"
6383 [(set_attr "op_type" "RR<E>")])
6386 (define_insn "*negabs<mode>2"
6387 [(set (match_operand:GPR 0 "register_operand" "=d")
6388 (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d"))))
6389 (clobber (reg:CC CC_REGNUM))]
6392 [(set_attr "op_type" "RR<E>")])
6398 ; lnxbr, lndbr, lnebr
6399 (define_insn "*negabs<mode>2_cc"
6400 [(set (reg CC_REGNUM)
6401 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6402 (match_operand:BFP 2 "const0_operand" "")))
6403 (set (match_operand:BFP 0 "register_operand" "=f")
6404 (neg:BFP (abs:BFP (match_dup 1))))]
6405 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6407 [(set_attr "op_type" "RRE")
6408 (set_attr "type" "fsimp<mode>")])
6410 ; lnxbr, lndbr, lnebr
6411 (define_insn "*negabs<mode>2_cconly"
6412 [(set (reg CC_REGNUM)
6413 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6414 (match_operand:BFP 2 "const0_operand" "")))
6415 (clobber (match_scratch:BFP 0 "=f"))]
6416 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6418 [(set_attr "op_type" "RRE")
6419 (set_attr "type" "fsimp<mode>")])
6422 (define_insn "*negabs<mode>2_nocc"
6423 [(set (match_operand:FP 0 "register_operand" "=f")
6424 (neg:FP (abs:FP (match_operand:BFP 1 "register_operand" "<fT0>"))))]
6425 "TARGET_HARD_FLOAT && TARGET_DFP"
6427 [(set_attr "op_type" "RRE")
6428 (set_attr "type" "fsimp<bfp>")])
6430 ; lnxbr, lndbr, lnebr
6431 (define_insn "*negabs<mode>2"
6432 [(set (match_operand:BFP 0 "register_operand" "=f")
6433 (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f"))))
6434 (clobber (reg:CC CC_REGNUM))]
6435 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6437 [(set_attr "op_type" "RRE")
6438 (set_attr "type" "fsimp<mode>")])
6441 ;;- Copy sign instructions
6445 (define_insn "copysign<mode>3"
6446 [(set (match_operand:FP 0 "register_operand" "=f")
6447 (unspec:FP [(match_operand:FP 1 "register_operand" "<fT0>")
6448 (match_operand:FP 2 "register_operand" "f")]
6450 "TARGET_HARD_FLOAT && TARGET_DFP"
6452 [(set_attr "op_type" "RRF")
6453 (set_attr "type" "fsimp<bfp>")])
6456 ;;- Square root instructions.
6460 ; sqrt(df|sf)2 instruction pattern(s).
6463 ; sqxbr, sqdbr, sqebr, sqxb, sqdb, sqeb
6464 (define_insn "sqrt<mode>2"
6465 [(set (match_operand:BFP 0 "register_operand" "=f,f")
6466 (sqrt:BFP (match_operand:BFP 1 "general_operand" "f,<Rf>")))]
6467 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6471 [(set_attr "op_type" "RRE,RXE")
6472 (set_attr "type" "fsqrt<mode>")])
6476 ;;- One complement instructions.
6480 ; one_cmpl(di|si|hi|qi)2 instruction pattern(s).
6483 (define_expand "one_cmpl<mode>2"
6485 [(set (match_operand:INT 0 "register_operand" "")
6486 (xor:INT (match_operand:INT 1 "register_operand" "")
6488 (clobber (reg:CC CC_REGNUM))])]
6494 ;; Find leftmost bit instructions.
6497 (define_expand "clzdi2"
6498 [(set (match_operand:DI 0 "register_operand" "=d")
6499 (clz:DI (match_operand:DI 1 "register_operand" "d")))]
6500 "TARGET_EXTIMM && TARGET_64BIT"
6502 rtx insn, clz_equal;
6503 rtx wide_reg = gen_reg_rtx (TImode);
6504 rtx msb = gen_rtx_CONST_INT (DImode, (unsigned HOST_WIDE_INT) 1 << 63);
6506 clz_equal = gen_rtx_CLZ (DImode, operands[1]);
6508 emit_insn (gen_clztidi2 (wide_reg, operands[1], msb));
6510 insn = emit_move_insn (operands[0], gen_highpart (DImode, wide_reg));
6511 set_unique_reg_note (insn, REG_EQUAL, clz_equal);
6516 (define_insn "clztidi2"
6517 [(set (match_operand:TI 0 "register_operand" "=d")
6521 (xor:DI (match_operand:DI 1 "register_operand" "d")
6522 (lshiftrt (match_operand:DI 2 "const_int_operand" "")
6523 (subreg:SI (clz:DI (match_dup 1)) 4))))
6526 (zero_extend:TI (clz:DI (match_dup 1)))))
6527 (clobber (reg:CC CC_REGNUM))]
6528 "(unsigned HOST_WIDE_INT) INTVAL (operands[2])
6529 == (unsigned HOST_WIDE_INT) 1 << 63
6530 && TARGET_EXTIMM && TARGET_64BIT"
6532 [(set_attr "op_type" "RRE")])
6536 ;;- Rotate instructions.
6540 ; rotl(di|si)3 instruction pattern(s).
6544 (define_insn "rotl<mode>3"
6545 [(set (match_operand:GPR 0 "register_operand" "=d")
6546 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
6547 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
6550 [(set_attr "op_type" "RSE")
6551 (set_attr "atype" "reg")])
6554 (define_insn "*rotl<mode>3_and"
6555 [(set (match_operand:GPR 0 "register_operand" "=d")
6556 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
6557 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
6558 (match_operand:SI 3 "const_int_operand" "n"))))]
6559 "TARGET_CPU_ZARCH && (INTVAL (operands[3]) & 63) == 63"
6561 [(set_attr "op_type" "RSE")
6562 (set_attr "atype" "reg")])
6566 ;;- Shift instructions.
6570 ; (ashl|lshr)(di|si)3 instruction pattern(s).
6573 (define_expand "<shift><mode>3"
6574 [(set (match_operand:DSI 0 "register_operand" "")
6575 (SHIFT:DSI (match_operand:DSI 1 "register_operand" "")
6576 (match_operand:SI 2 "shift_count_or_setmem_operand" "")))]
6581 (define_insn "*<shift>di3_31"
6582 [(set (match_operand:DI 0 "register_operand" "=d")
6583 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
6584 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
6587 [(set_attr "op_type" "RS")
6588 (set_attr "atype" "reg")])
6590 ; sll, srl, sllg, srlg
6591 (define_insn "*<shift><mode>3"
6592 [(set (match_operand:GPR 0 "register_operand" "=d")
6593 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>")
6594 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
6596 "s<lr>l<g>\t%0,<1>%Y2"
6597 [(set_attr "op_type" "RS<E>")
6598 (set_attr "atype" "reg")])
6601 (define_insn "*<shift>di3_31_and"
6602 [(set (match_operand:DI 0 "register_operand" "=d")
6603 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
6604 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
6605 (match_operand:SI 3 "const_int_operand" "n"))))]
6606 "!TARGET_64BIT && (INTVAL (operands[3]) & 63) == 63"
6608 [(set_attr "op_type" "RS")
6609 (set_attr "atype" "reg")])
6611 ; sll, srl, sllg, srlg
6612 (define_insn "*<shift><mode>3_and"
6613 [(set (match_operand:GPR 0 "register_operand" "=d")
6614 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>")
6615 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
6616 (match_operand:SI 3 "const_int_operand" "n"))))]
6617 "(INTVAL (operands[3]) & 63) == 63"
6618 "s<lr>l<g>\t%0,<1>%Y2"
6619 [(set_attr "op_type" "RS<E>")
6620 (set_attr "atype" "reg")])
6623 ; ashr(di|si)3 instruction pattern(s).
6626 (define_expand "ashr<mode>3"
6628 [(set (match_operand:DSI 0 "register_operand" "")
6629 (ashiftrt:DSI (match_operand:DSI 1 "register_operand" "")
6630 (match_operand:SI 2 "shift_count_or_setmem_operand" "")))
6631 (clobber (reg:CC CC_REGNUM))])]
6635 (define_insn "*ashrdi3_cc_31"
6636 [(set (reg CC_REGNUM)
6637 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6638 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
6640 (set (match_operand:DI 0 "register_operand" "=d")
6641 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6642 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
6644 [(set_attr "op_type" "RS")
6645 (set_attr "atype" "reg")])
6647 (define_insn "*ashrdi3_cconly_31"
6648 [(set (reg CC_REGNUM)
6649 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6650 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
6652 (clobber (match_scratch:DI 0 "=d"))]
6653 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
6655 [(set_attr "op_type" "RS")
6656 (set_attr "atype" "reg")])
6658 (define_insn "*ashrdi3_31"
6659 [(set (match_operand:DI 0 "register_operand" "=d")
6660 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6661 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))
6662 (clobber (reg:CC CC_REGNUM))]
6665 [(set_attr "op_type" "RS")
6666 (set_attr "atype" "reg")])
6669 (define_insn "*ashr<mode>3_cc"
6670 [(set (reg CC_REGNUM)
6671 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
6672 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
6674 (set (match_operand:GPR 0 "register_operand" "=d")
6675 (ashiftrt:GPR (match_dup 1) (match_dup 2)))]
6676 "s390_match_ccmode(insn, CCSmode)"
6678 [(set_attr "op_type" "RS<E>")
6679 (set_attr "atype" "reg")])
6682 (define_insn "*ashr<mode>3_cconly"
6683 [(set (reg CC_REGNUM)
6684 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
6685 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
6687 (clobber (match_scratch:GPR 0 "=d"))]
6688 "s390_match_ccmode(insn, CCSmode)"
6690 [(set_attr "op_type" "RS<E>")
6691 (set_attr "atype" "reg")])
6694 (define_insn "*ashr<mode>3"
6695 [(set (match_operand:GPR 0 "register_operand" "=d")
6696 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
6697 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))
6698 (clobber (reg:CC CC_REGNUM))]
6701 [(set_attr "op_type" "RS<E>")
6702 (set_attr "atype" "reg")])
6705 ; shift pattern with implicit ANDs
6707 (define_insn "*ashrdi3_cc_31_and"
6708 [(set (reg CC_REGNUM)
6709 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6710 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
6711 (match_operand:SI 3 "const_int_operand" "n")))
6713 (set (match_operand:DI 0 "register_operand" "=d")
6714 (ashiftrt:DI (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
6715 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)
6716 && (INTVAL (operands[3]) & 63) == 63"
6718 [(set_attr "op_type" "RS")
6719 (set_attr "atype" "reg")])
6721 (define_insn "*ashrdi3_cconly_31_and"
6722 [(set (reg CC_REGNUM)
6723 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6724 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
6725 (match_operand:SI 3 "const_int_operand" "n")))
6727 (clobber (match_scratch:DI 0 "=d"))]
6728 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)
6729 && (INTVAL (operands[3]) & 63) == 63"
6731 [(set_attr "op_type" "RS")
6732 (set_attr "atype" "reg")])
6734 (define_insn "*ashrdi3_31_and"
6735 [(set (match_operand:DI 0 "register_operand" "=d")
6736 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6737 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
6738 (match_operand:SI 3 "const_int_operand" "n"))))
6739 (clobber (reg:CC CC_REGNUM))]
6740 "!TARGET_64BIT && (INTVAL (operands[3]) & 63) == 63"
6742 [(set_attr "op_type" "RS")
6743 (set_attr "atype" "reg")])
6746 (define_insn "*ashr<mode>3_cc_and"
6747 [(set (reg CC_REGNUM)
6748 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
6749 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
6750 (match_operand:SI 3 "const_int_operand" "n")))
6752 (set (match_operand:GPR 0 "register_operand" "=d")
6753 (ashiftrt:GPR (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
6754 "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
6756 [(set_attr "op_type" "RS<E>")
6757 (set_attr "atype" "reg")])
6760 (define_insn "*ashr<mode>3_cconly_and"
6761 [(set (reg CC_REGNUM)
6762 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
6763 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
6764 (match_operand:SI 3 "const_int_operand" "n")))
6766 (clobber (match_scratch:GPR 0 "=d"))]
6767 "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
6769 [(set_attr "op_type" "RS<E>")
6770 (set_attr "atype" "reg")])
6773 (define_insn "*ashr<mode>3_and"
6774 [(set (match_operand:GPR 0 "register_operand" "=d")
6775 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
6776 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
6777 (match_operand:SI 3 "const_int_operand" "n"))))
6778 (clobber (reg:CC CC_REGNUM))]
6779 "(INTVAL (operands[3]) & 63) == 63"
6781 [(set_attr "op_type" "RS<E>")
6782 (set_attr "atype" "reg")])
6786 ;; Branch instruction patterns.
6789 (define_expand "b<code>"
6791 (if_then_else (COMPARE (match_operand 0 "" "")
6796 "s390_emit_jump (operands[0],
6797 s390_emit_compare (<CODE>, s390_compare_op0, s390_compare_op1)); DONE;")
6801 ;;- Conditional jump instructions.
6804 (define_insn "*cjump_64"
6807 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6808 (label_ref (match_operand 0 "" ""))
6812 if (get_attr_length (insn) == 4)
6815 return "jg%C1\t%l0";
6817 [(set_attr "op_type" "RI")
6818 (set_attr "type" "branch")
6819 (set (attr "length")
6820 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6821 (const_int 4) (const_int 6)))])
6823 (define_insn "*cjump_31"
6826 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6827 (label_ref (match_operand 0 "" ""))
6831 gcc_assert (get_attr_length (insn) == 4);
6834 [(set_attr "op_type" "RI")
6835 (set_attr "type" "branch")
6836 (set (attr "length")
6837 (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
6838 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6839 (const_int 4) (const_int 6))
6840 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6841 (const_int 4) (const_int 8))))])
6843 (define_insn "*cjump_long"
6846 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6847 (match_operand 0 "address_operand" "U")
6851 if (get_attr_op_type (insn) == OP_TYPE_RR)
6856 [(set (attr "op_type")
6857 (if_then_else (match_operand 0 "register_operand" "")
6858 (const_string "RR") (const_string "RX")))
6859 (set_attr "type" "branch")
6860 (set_attr "atype" "agen")])
6864 ;;- Negated conditional jump instructions.
6867 (define_insn "*icjump_64"
6870 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6872 (label_ref (match_operand 0 "" ""))))]
6875 if (get_attr_length (insn) == 4)
6878 return "jg%D1\t%l0";
6880 [(set_attr "op_type" "RI")
6881 (set_attr "type" "branch")
6882 (set (attr "length")
6883 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6884 (const_int 4) (const_int 6)))])
6886 (define_insn "*icjump_31"
6889 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6891 (label_ref (match_operand 0 "" ""))))]
6894 gcc_assert (get_attr_length (insn) == 4);
6897 [(set_attr "op_type" "RI")
6898 (set_attr "type" "branch")
6899 (set (attr "length")
6900 (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
6901 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6902 (const_int 4) (const_int 6))
6903 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6904 (const_int 4) (const_int 8))))])
6906 (define_insn "*icjump_long"
6909 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6911 (match_operand 0 "address_operand" "U")))]
6914 if (get_attr_op_type (insn) == OP_TYPE_RR)
6919 [(set (attr "op_type")
6920 (if_then_else (match_operand 0 "register_operand" "")
6921 (const_string "RR") (const_string "RX")))
6922 (set_attr "type" "branch")
6923 (set_attr "atype" "agen")])
6926 ;;- Trap instructions.
6930 [(trap_if (const_int 1) (const_int 0))]
6933 [(set_attr "op_type" "RI")
6934 (set_attr "type" "branch")])
6936 (define_expand "conditional_trap"
6937 [(trap_if (match_operand 0 "comparison_operator" "")
6938 (match_operand 1 "general_operand" ""))]
6941 if (operands[1] != const0_rtx) FAIL;
6942 operands[0] = s390_emit_compare (GET_CODE (operands[0]),
6943 s390_compare_op0, s390_compare_op1);
6946 (define_insn "*trap"
6947 [(trap_if (match_operator 0 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6951 [(set_attr "op_type" "RI")
6952 (set_attr "type" "branch")])
6955 ;;- Loop instructions.
6957 ;; This is all complicated by the fact that since this is a jump insn
6958 ;; we must handle our own output reloads.
6960 (define_expand "doloop_end"
6961 [(use (match_operand 0 "" "")) ; loop pseudo
6962 (use (match_operand 1 "" "")) ; iterations; zero if unknown
6963 (use (match_operand 2 "" "")) ; max iterations
6964 (use (match_operand 3 "" "")) ; loop level
6965 (use (match_operand 4 "" ""))] ; label
6968 if (GET_MODE (operands[0]) == SImode && !TARGET_CPU_ZARCH)
6969 emit_jump_insn (gen_doloop_si31 (operands[4], operands[0], operands[0]));
6970 else if (GET_MODE (operands[0]) == SImode && TARGET_CPU_ZARCH)
6971 emit_jump_insn (gen_doloop_si64 (operands[4], operands[0], operands[0]));
6972 else if (GET_MODE (operands[0]) == DImode && TARGET_64BIT)
6973 emit_jump_insn (gen_doloop_di (operands[4], operands[0], operands[0]));
6980 (define_insn_and_split "doloop_si64"
6983 (ne (match_operand:SI 1 "register_operand" "d,d,d")
6985 (label_ref (match_operand 0 "" ""))
6987 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
6988 (plus:SI (match_dup 1) (const_int -1)))
6989 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
6990 (clobber (reg:CC CC_REGNUM))]
6993 if (which_alternative != 0)
6995 else if (get_attr_length (insn) == 4)
6996 return "brct\t%1,%l0";
6998 return "ahi\t%1,-1\;jgne\t%l0";
7000 "&& reload_completed
7001 && (! REG_P (operands[2])
7002 || ! rtx_equal_p (operands[1], operands[2]))"
7003 [(set (match_dup 3) (match_dup 1))
7004 (parallel [(set (reg:CCAN CC_REGNUM)
7005 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
7007 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
7008 (set (match_dup 2) (match_dup 3))
7009 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
7010 (label_ref (match_dup 0))
7013 [(set_attr "op_type" "RI")
7014 (set_attr "type" "branch")
7015 (set (attr "length")
7016 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7017 (const_int 4) (const_int 10)))])
7019 (define_insn_and_split "doloop_si31"
7022 (ne (match_operand:SI 1 "register_operand" "d,d,d")
7024 (label_ref (match_operand 0 "" ""))
7026 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
7027 (plus:SI (match_dup 1) (const_int -1)))
7028 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
7029 (clobber (reg:CC CC_REGNUM))]
7032 if (which_alternative != 0)
7034 else if (get_attr_length (insn) == 4)
7035 return "brct\t%1,%l0";
7039 "&& reload_completed
7040 && (! REG_P (operands[2])
7041 || ! rtx_equal_p (operands[1], operands[2]))"
7042 [(set (match_dup 3) (match_dup 1))
7043 (parallel [(set (reg:CCAN CC_REGNUM)
7044 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
7046 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
7047 (set (match_dup 2) (match_dup 3))
7048 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
7049 (label_ref (match_dup 0))
7052 [(set_attr "op_type" "RI")
7053 (set_attr "type" "branch")
7054 (set (attr "length")
7055 (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7056 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7057 (const_int 4) (const_int 6))
7058 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7059 (const_int 4) (const_int 8))))])
7061 (define_insn "*doloop_si_long"
7064 (ne (match_operand:SI 1 "register_operand" "d")
7066 (match_operand 0 "address_operand" "U")
7068 (set (match_operand:SI 2 "register_operand" "=1")
7069 (plus:SI (match_dup 1) (const_int -1)))
7070 (clobber (match_scratch:SI 3 "=X"))
7071 (clobber (reg:CC CC_REGNUM))]
7074 if (get_attr_op_type (insn) == OP_TYPE_RR)
7075 return "bctr\t%1,%0";
7077 return "bct\t%1,%a0";
7079 [(set (attr "op_type")
7080 (if_then_else (match_operand 0 "register_operand" "")
7081 (const_string "RR") (const_string "RX")))
7082 (set_attr "type" "branch")
7083 (set_attr "atype" "agen")])
7085 (define_insn_and_split "doloop_di"
7088 (ne (match_operand:DI 1 "register_operand" "d,d,d")
7090 (label_ref (match_operand 0 "" ""))
7092 (set (match_operand:DI 2 "nonimmediate_operand" "=1,?X,?X")
7093 (plus:DI (match_dup 1) (const_int -1)))
7094 (clobber (match_scratch:DI 3 "=X,&1,&?d"))
7095 (clobber (reg:CC CC_REGNUM))]
7098 if (which_alternative != 0)
7100 else if (get_attr_length (insn) == 4)
7101 return "brctg\t%1,%l0";
7103 return "aghi\t%1,-1\;jgne\t%l0";
7105 "&& reload_completed
7106 && (! REG_P (operands[2])
7107 || ! rtx_equal_p (operands[1], operands[2]))"
7108 [(set (match_dup 3) (match_dup 1))
7109 (parallel [(set (reg:CCAN CC_REGNUM)
7110 (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
7112 (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
7113 (set (match_dup 2) (match_dup 3))
7114 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
7115 (label_ref (match_dup 0))
7118 [(set_attr "op_type" "RI")
7119 (set_attr "type" "branch")
7120 (set (attr "length")
7121 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7122 (const_int 4) (const_int 10)))])
7125 ;;- Unconditional jump instructions.
7129 ; jump instruction pattern(s).
7132 (define_expand "jump"
7133 [(match_operand 0 "" "")]
7135 "s390_emit_jump (operands[0], NULL_RTX); DONE;")
7137 (define_insn "*jump64"
7138 [(set (pc) (label_ref (match_operand 0 "" "")))]
7141 if (get_attr_length (insn) == 4)
7146 [(set_attr "op_type" "RI")
7147 (set_attr "type" "branch")
7148 (set (attr "length")
7149 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7150 (const_int 4) (const_int 6)))])
7152 (define_insn "*jump31"
7153 [(set (pc) (label_ref (match_operand 0 "" "")))]
7156 gcc_assert (get_attr_length (insn) == 4);
7159 [(set_attr "op_type" "RI")
7160 (set_attr "type" "branch")
7161 (set (attr "length")
7162 (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7163 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7164 (const_int 4) (const_int 6))
7165 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7166 (const_int 4) (const_int 8))))])
7169 ; indirect-jump instruction pattern(s).
7172 (define_insn "indirect_jump"
7173 [(set (pc) (match_operand 0 "address_operand" "U"))]
7176 if (get_attr_op_type (insn) == OP_TYPE_RR)
7181 [(set (attr "op_type")
7182 (if_then_else (match_operand 0 "register_operand" "")
7183 (const_string "RR") (const_string "RX")))
7184 (set_attr "type" "branch")
7185 (set_attr "atype" "agen")])
7188 ; casesi instruction pattern(s).
7191 (define_insn "casesi_jump"
7192 [(set (pc) (match_operand 0 "address_operand" "U"))
7193 (use (label_ref (match_operand 1 "" "")))]
7196 if (get_attr_op_type (insn) == OP_TYPE_RR)
7201 [(set (attr "op_type")
7202 (if_then_else (match_operand 0 "register_operand" "")
7203 (const_string "RR") (const_string "RX")))
7204 (set_attr "type" "branch")
7205 (set_attr "atype" "agen")])
7207 (define_expand "casesi"
7208 [(match_operand:SI 0 "general_operand" "")
7209 (match_operand:SI 1 "general_operand" "")
7210 (match_operand:SI 2 "general_operand" "")
7211 (label_ref (match_operand 3 "" ""))
7212 (label_ref (match_operand 4 "" ""))]
7215 rtx index = gen_reg_rtx (SImode);
7216 rtx base = gen_reg_rtx (Pmode);
7217 rtx target = gen_reg_rtx (Pmode);
7219 emit_move_insn (index, operands[0]);
7220 emit_insn (gen_subsi3 (index, index, operands[1]));
7221 emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
7224 if (Pmode != SImode)
7225 index = convert_to_mode (Pmode, index, 1);
7226 if (GET_CODE (index) != REG)
7227 index = copy_to_mode_reg (Pmode, index);
7230 emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
7232 emit_insn (gen_ashlsi3 (index, index, const2_rtx));
7234 emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
7236 index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
7237 emit_move_insn (target, index);
7240 target = gen_rtx_PLUS (Pmode, base, target);
7241 emit_jump_insn (gen_casesi_jump (target, operands[3]));
7248 ;;- Jump to subroutine.
7253 ; untyped call instruction pattern(s).
7256 ;; Call subroutine returning any type.
7257 (define_expand "untyped_call"
7258 [(parallel [(call (match_operand 0 "" "")
7260 (match_operand 1 "" "")
7261 (match_operand 2 "" "")])]
7266 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
7268 for (i = 0; i < XVECLEN (operands[2], 0); i++)
7270 rtx set = XVECEXP (operands[2], 0, i);
7271 emit_move_insn (SET_DEST (set), SET_SRC (set));
7274 /* The optimizer does not know that the call sets the function value
7275 registers we stored in the result block. We avoid problems by
7276 claiming that all hard registers are used and clobbered at this
7278 emit_insn (gen_blockage ());
7283 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
7284 ;; all of memory. This blocks insns from being moved across this point.
7286 (define_insn "blockage"
7287 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
7290 [(set_attr "type" "none")
7291 (set_attr "length" "0")])
7297 (define_expand "sibcall"
7298 [(call (match_operand 0 "" "")
7299 (match_operand 1 "" ""))]
7302 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
7306 (define_insn "*sibcall_br"
7307 [(call (mem:QI (reg SIBCALL_REGNUM))
7308 (match_operand 0 "const_int_operand" "n"))]
7309 "SIBLING_CALL_P (insn)
7310 && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
7312 [(set_attr "op_type" "RR")
7313 (set_attr "type" "branch")
7314 (set_attr "atype" "agen")])
7316 (define_insn "*sibcall_brc"
7317 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7318 (match_operand 1 "const_int_operand" "n"))]
7319 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
7321 [(set_attr "op_type" "RI")
7322 (set_attr "type" "branch")])
7324 (define_insn "*sibcall_brcl"
7325 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7326 (match_operand 1 "const_int_operand" "n"))]
7327 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
7329 [(set_attr "op_type" "RIL")
7330 (set_attr "type" "branch")])
7333 ; sibcall_value patterns
7336 (define_expand "sibcall_value"
7337 [(set (match_operand 0 "" "")
7338 (call (match_operand 1 "" "")
7339 (match_operand 2 "" "")))]
7342 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
7346 (define_insn "*sibcall_value_br"
7347 [(set (match_operand 0 "" "")
7348 (call (mem:QI (reg SIBCALL_REGNUM))
7349 (match_operand 1 "const_int_operand" "n")))]
7350 "SIBLING_CALL_P (insn)
7351 && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
7353 [(set_attr "op_type" "RR")
7354 (set_attr "type" "branch")
7355 (set_attr "atype" "agen")])
7357 (define_insn "*sibcall_value_brc"
7358 [(set (match_operand 0 "" "")
7359 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7360 (match_operand 2 "const_int_operand" "n")))]
7361 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
7363 [(set_attr "op_type" "RI")
7364 (set_attr "type" "branch")])
7366 (define_insn "*sibcall_value_brcl"
7367 [(set (match_operand 0 "" "")
7368 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7369 (match_operand 2 "const_int_operand" "n")))]
7370 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
7372 [(set_attr "op_type" "RIL")
7373 (set_attr "type" "branch")])
7377 ; call instruction pattern(s).
7380 (define_expand "call"
7381 [(call (match_operand 0 "" "")
7382 (match_operand 1 "" ""))
7383 (use (match_operand 2 "" ""))]
7386 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
7387 gen_rtx_REG (Pmode, RETURN_REGNUM));
7391 (define_insn "*bras"
7392 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7393 (match_operand 1 "const_int_operand" "n"))
7394 (clobber (match_operand 2 "register_operand" "=r"))]
7395 "!SIBLING_CALL_P (insn)
7396 && TARGET_SMALL_EXEC
7397 && GET_MODE (operands[2]) == Pmode"
7399 [(set_attr "op_type" "RI")
7400 (set_attr "type" "jsr")])
7402 (define_insn "*brasl"
7403 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7404 (match_operand 1 "const_int_operand" "n"))
7405 (clobber (match_operand 2 "register_operand" "=r"))]
7406 "!SIBLING_CALL_P (insn)
7408 && GET_MODE (operands[2]) == Pmode"
7410 [(set_attr "op_type" "RIL")
7411 (set_attr "type" "jsr")])
7413 (define_insn "*basr"
7414 [(call (mem:QI (match_operand 0 "address_operand" "U"))
7415 (match_operand 1 "const_int_operand" "n"))
7416 (clobber (match_operand 2 "register_operand" "=r"))]
7417 "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
7419 if (get_attr_op_type (insn) == OP_TYPE_RR)
7420 return "basr\t%2,%0";
7422 return "bas\t%2,%a0";
7424 [(set (attr "op_type")
7425 (if_then_else (match_operand 0 "register_operand" "")
7426 (const_string "RR") (const_string "RX")))
7427 (set_attr "type" "jsr")
7428 (set_attr "atype" "agen")])
7431 ; call_value instruction pattern(s).
7434 (define_expand "call_value"
7435 [(set (match_operand 0 "" "")
7436 (call (match_operand 1 "" "")
7437 (match_operand 2 "" "")))
7438 (use (match_operand 3 "" ""))]
7441 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
7442 gen_rtx_REG (Pmode, RETURN_REGNUM));
7446 (define_insn "*bras_r"
7447 [(set (match_operand 0 "" "")
7448 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7449 (match_operand:SI 2 "const_int_operand" "n")))
7450 (clobber (match_operand 3 "register_operand" "=r"))]
7451 "!SIBLING_CALL_P (insn)
7452 && TARGET_SMALL_EXEC
7453 && GET_MODE (operands[3]) == Pmode"
7455 [(set_attr "op_type" "RI")
7456 (set_attr "type" "jsr")])
7458 (define_insn "*brasl_r"
7459 [(set (match_operand 0 "" "")
7460 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7461 (match_operand 2 "const_int_operand" "n")))
7462 (clobber (match_operand 3 "register_operand" "=r"))]
7463 "!SIBLING_CALL_P (insn)
7465 && GET_MODE (operands[3]) == Pmode"
7467 [(set_attr "op_type" "RIL")
7468 (set_attr "type" "jsr")])
7470 (define_insn "*basr_r"
7471 [(set (match_operand 0 "" "")
7472 (call (mem:QI (match_operand 1 "address_operand" "U"))
7473 (match_operand 2 "const_int_operand" "n")))
7474 (clobber (match_operand 3 "register_operand" "=r"))]
7475 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
7477 if (get_attr_op_type (insn) == OP_TYPE_RR)
7478 return "basr\t%3,%1";
7480 return "bas\t%3,%a1";
7482 [(set (attr "op_type")
7483 (if_then_else (match_operand 1 "register_operand" "")
7484 (const_string "RR") (const_string "RX")))
7485 (set_attr "type" "jsr")
7486 (set_attr "atype" "agen")])
7489 ;;- Thread-local storage support.
7492 (define_expand "get_tp_64"
7493 [(set (match_operand:DI 0 "nonimmediate_operand" "") (reg:DI TP_REGNUM))]
7497 (define_expand "get_tp_31"
7498 [(set (match_operand:SI 0 "nonimmediate_operand" "") (reg:SI TP_REGNUM))]
7502 (define_expand "set_tp_64"
7503 [(set (reg:DI TP_REGNUM) (match_operand:DI 0 "nonimmediate_operand" ""))
7504 (set (reg:DI TP_REGNUM) (unspec_volatile:DI [(reg:DI TP_REGNUM)] UNSPECV_SET_TP))]
7508 (define_expand "set_tp_31"
7509 [(set (reg:SI TP_REGNUM) (match_operand:SI 0 "nonimmediate_operand" ""))
7510 (set (reg:SI TP_REGNUM) (unspec_volatile:SI [(reg:SI TP_REGNUM)] UNSPECV_SET_TP))]
7514 (define_insn "*set_tp"
7515 [(set (reg TP_REGNUM) (unspec_volatile [(reg TP_REGNUM)] UNSPECV_SET_TP))]
7518 [(set_attr "type" "none")
7519 (set_attr "length" "0")])
7521 (define_insn "*tls_load_64"
7522 [(set (match_operand:DI 0 "register_operand" "=d")
7523 (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
7524 (match_operand:DI 2 "" "")]
7528 [(set_attr "op_type" "RXE")])
7530 (define_insn "*tls_load_31"
7531 [(set (match_operand:SI 0 "register_operand" "=d,d")
7532 (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
7533 (match_operand:SI 2 "" "")]
7539 [(set_attr "op_type" "RX,RXY")])
7541 (define_insn "*bras_tls"
7542 [(set (match_operand 0 "" "")
7543 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7544 (match_operand 2 "const_int_operand" "n")))
7545 (clobber (match_operand 3 "register_operand" "=r"))
7546 (use (match_operand 4 "" ""))]
7547 "!SIBLING_CALL_P (insn)
7548 && TARGET_SMALL_EXEC
7549 && GET_MODE (operands[3]) == Pmode"
7551 [(set_attr "op_type" "RI")
7552 (set_attr "type" "jsr")])
7554 (define_insn "*brasl_tls"
7555 [(set (match_operand 0 "" "")
7556 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7557 (match_operand 2 "const_int_operand" "n")))
7558 (clobber (match_operand 3 "register_operand" "=r"))
7559 (use (match_operand 4 "" ""))]
7560 "!SIBLING_CALL_P (insn)
7562 && GET_MODE (operands[3]) == Pmode"
7564 [(set_attr "op_type" "RIL")
7565 (set_attr "type" "jsr")])
7567 (define_insn "*basr_tls"
7568 [(set (match_operand 0 "" "")
7569 (call (mem:QI (match_operand 1 "address_operand" "U"))
7570 (match_operand 2 "const_int_operand" "n")))
7571 (clobber (match_operand 3 "register_operand" "=r"))
7572 (use (match_operand 4 "" ""))]
7573 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
7575 if (get_attr_op_type (insn) == OP_TYPE_RR)
7576 return "basr\t%3,%1%J4";
7578 return "bas\t%3,%a1%J4";
7580 [(set (attr "op_type")
7581 (if_then_else (match_operand 1 "register_operand" "")
7582 (const_string "RR") (const_string "RX")))
7583 (set_attr "type" "jsr")
7584 (set_attr "atype" "agen")])
7587 ;;- Atomic operations
7591 ; memory barrier pattern.
7594 (define_expand "memory_barrier"
7595 [(set (mem:BLK (match_dup 0))
7596 (unspec_volatile:BLK [(mem:BLK (match_dup 0))] UNSPECV_MB))]
7599 operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (DImode));
7600 MEM_VOLATILE_P (operands[0]) = 1;
7603 (define_insn "*memory_barrier"
7604 [(set (match_operand:BLK 0 "" "")
7605 (unspec_volatile:BLK [(match_operand:BLK 1 "" "")] UNSPECV_MB))]
7608 [(set_attr "op_type" "RR")])
7611 ; compare and swap patterns.
7614 (define_expand "sync_compare_and_swap<mode>"
7616 [(set (match_operand:TDSI 0 "register_operand" "")
7617 (match_operand:TDSI 1 "memory_operand" ""))
7619 (unspec_volatile:TDSI
7621 (match_operand:TDSI 2 "register_operand" "")
7622 (match_operand:TDSI 3 "register_operand" "")]
7624 (set (reg:CCZ1 CC_REGNUM)
7625 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
7628 (define_expand "sync_compare_and_swap<mode>"
7630 [(set (match_operand:HQI 0 "register_operand" "")
7631 (match_operand:HQI 1 "memory_operand" ""))
7633 (unspec_volatile:HQI
7635 (match_operand:HQI 2 "general_operand" "")
7636 (match_operand:HQI 3 "general_operand" "")]
7638 (set (reg:CCZ1 CC_REGNUM)
7639 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
7641 "s390_expand_cs_hqi (<MODE>mode, operands[0], operands[1],
7642 operands[2], operands[3]); DONE;")
7644 (define_expand "sync_compare_and_swap_cc<mode>"
7646 [(set (match_operand:TDSI 0 "register_operand" "")
7647 (match_operand:TDSI 1 "memory_operand" ""))
7649 (unspec_volatile:TDSI
7651 (match_operand:TDSI 2 "register_operand" "")
7652 (match_operand:TDSI 3 "register_operand" "")]
7655 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
7658 /* Emulate compare. */
7659 operands[4] = gen_rtx_REG (CCZ1mode, CC_REGNUM);
7660 s390_compare_op0 = operands[1];
7661 s390_compare_op1 = operands[2];
7662 s390_compare_emitted = operands[4];
7666 (define_insn "*sync_compare_and_swap<mode>"
7667 [(set (match_operand:DP 0 "register_operand" "=r")
7668 (match_operand:DP 1 "memory_operand" "+Q"))
7672 (match_operand:DP 2 "register_operand" "0")
7673 (match_operand:DP 3 "register_operand" "r")]
7675 (set (reg:CCZ1 CC_REGNUM)
7676 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
7678 "cds<tg>\t%0,%3,%S1"
7679 [(set_attr "op_type" "RS<TE>")
7680 (set_attr "type" "sem")])
7683 (define_insn "*sync_compare_and_swap<mode>"
7684 [(set (match_operand:GPR 0 "register_operand" "=r")
7685 (match_operand:GPR 1 "memory_operand" "+Q"))
7687 (unspec_volatile:GPR
7689 (match_operand:GPR 2 "register_operand" "0")
7690 (match_operand:GPR 3 "register_operand" "r")]
7692 (set (reg:CCZ1 CC_REGNUM)
7693 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
7696 [(set_attr "op_type" "RS<E>")
7697 (set_attr "type" "sem")])
7701 ; Other atomic instruction patterns.
7704 (define_expand "sync_lock_test_and_set<mode>"
7705 [(match_operand:HQI 0 "register_operand")
7706 (match_operand:HQI 1 "memory_operand")
7707 (match_operand:HQI 2 "general_operand")]
7709 "s390_expand_atomic (<MODE>mode, SET, operands[0], operands[1],
7710 operands[2], false); DONE;")
7712 (define_expand "sync_<atomic><mode>"
7713 [(set (match_operand:HQI 0 "memory_operand")
7714 (ATOMIC:HQI (match_dup 0)
7715 (match_operand:HQI 1 "general_operand")))]
7717 "s390_expand_atomic (<MODE>mode, <CODE>, NULL_RTX, operands[0],
7718 operands[1], false); DONE;")
7720 (define_expand "sync_old_<atomic><mode>"
7721 [(set (match_operand:HQI 0 "register_operand")
7722 (match_operand:HQI 1 "memory_operand"))
7724 (ATOMIC:HQI (match_dup 1)
7725 (match_operand:HQI 2 "general_operand")))]
7727 "s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
7728 operands[2], false); DONE;")
7730 (define_expand "sync_new_<atomic><mode>"
7731 [(set (match_operand:HQI 0 "register_operand")
7732 (ATOMIC:HQI (match_operand:HQI 1 "memory_operand")
7733 (match_operand:HQI 2 "general_operand")))
7734 (set (match_dup 1) (ATOMIC:HQI (match_dup 1) (match_dup 2)))]
7736 "s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
7737 operands[2], true); DONE;")
7740 ;;- Miscellaneous instructions.
7744 ; allocate stack instruction pattern(s).
7747 (define_expand "allocate_stack"
7748 [(match_operand 0 "general_operand" "")
7749 (match_operand 1 "general_operand" "")]
7752 rtx temp = gen_reg_rtx (Pmode);
7754 emit_move_insn (temp, s390_back_chain_rtx ());
7755 anti_adjust_stack (operands[1]);
7756 emit_move_insn (s390_back_chain_rtx (), temp);
7758 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
7764 ; setjmp instruction pattern.
7767 (define_expand "builtin_setjmp_receiver"
7768 [(match_operand 0 "" "")]
7771 emit_insn (s390_load_got ());
7772 emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
7776 ;; These patterns say how to save and restore the stack pointer. We need not
7777 ;; save the stack pointer at function level since we are careful to
7778 ;; preserve the backchain. At block level, we have to restore the backchain
7779 ;; when we restore the stack pointer.
7781 ;; For nonlocal gotos, we must save both the stack pointer and its
7782 ;; backchain and restore both. Note that in the nonlocal case, the
7783 ;; save area is a memory location.
7785 (define_expand "save_stack_function"
7786 [(match_operand 0 "general_operand" "")
7787 (match_operand 1 "general_operand" "")]
7791 (define_expand "restore_stack_function"
7792 [(match_operand 0 "general_operand" "")
7793 (match_operand 1 "general_operand" "")]
7797 (define_expand "restore_stack_block"
7798 [(match_operand 0 "register_operand" "")
7799 (match_operand 1 "register_operand" "")]
7802 rtx temp = gen_reg_rtx (Pmode);
7804 emit_move_insn (temp, s390_back_chain_rtx ());
7805 emit_move_insn (operands[0], operands[1]);
7806 emit_move_insn (s390_back_chain_rtx (), temp);
7811 (define_expand "save_stack_nonlocal"
7812 [(match_operand 0 "memory_operand" "")
7813 (match_operand 1 "register_operand" "")]
7816 enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
7817 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
7819 /* Copy the backchain to the first word, sp to the second and the
7820 literal pool base to the third. */
7822 if (TARGET_BACKCHAIN)
7824 rtx temp = force_reg (Pmode, s390_back_chain_rtx ());
7825 emit_move_insn (operand_subword (operands[0], 0, 0, mode), temp);
7828 emit_move_insn (operand_subword (operands[0], 1, 0, mode), operands[1]);
7829 emit_move_insn (operand_subword (operands[0], 2, 0, mode), base);
7834 (define_expand "restore_stack_nonlocal"
7835 [(match_operand 0 "register_operand" "")
7836 (match_operand 1 "memory_operand" "")]
7839 enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
7840 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
7841 rtx temp = NULL_RTX;
7843 /* Restore the backchain from the first word, sp from the second and the
7844 literal pool base from the third. */
7846 if (TARGET_BACKCHAIN)
7847 temp = force_reg (Pmode, operand_subword (operands[1], 0, 0, mode));
7849 emit_move_insn (base, operand_subword (operands[1], 2, 0, mode));
7850 emit_move_insn (operands[0], operand_subword (operands[1], 1, 0, mode));
7853 emit_move_insn (s390_back_chain_rtx (), temp);
7855 emit_insn (gen_rtx_USE (VOIDmode, base));
7859 (define_expand "exception_receiver"
7863 s390_set_has_landing_pad_p (true);
7868 ; nop instruction pattern(s).
7875 [(set_attr "op_type" "RR")])
7879 ; Special literal pool access instruction pattern(s).
7882 (define_insn "*pool_entry"
7883 [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
7884 UNSPECV_POOL_ENTRY)]
7887 enum machine_mode mode = GET_MODE (PATTERN (insn));
7888 unsigned int align = GET_MODE_BITSIZE (mode);
7889 s390_output_pool_entry (operands[0], mode, align);
7892 [(set (attr "length")
7893 (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
7895 (define_insn "pool_align"
7896 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")]
7897 UNSPECV_POOL_ALIGN)]
7900 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
7902 (define_insn "pool_section_start"
7903 [(unspec_volatile [(const_int 1)] UNSPECV_POOL_SECTION)]
7906 [(set_attr "length" "0")])
7908 (define_insn "pool_section_end"
7909 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_SECTION)]
7912 [(set_attr "length" "0")])
7914 (define_insn "main_base_31_small"
7915 [(set (match_operand 0 "register_operand" "=a")
7916 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
7917 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7919 [(set_attr "op_type" "RR")
7920 (set_attr "type" "la")])
7922 (define_insn "main_base_31_large"
7923 [(set (match_operand 0 "register_operand" "=a")
7924 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
7925 (set (pc) (label_ref (match_operand 2 "" "")))]
7926 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7928 [(set_attr "op_type" "RI")])
7930 (define_insn "main_base_64"
7931 [(set (match_operand 0 "register_operand" "=a")
7932 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
7933 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7935 [(set_attr "op_type" "RIL")
7936 (set_attr "type" "larl")])
7938 (define_insn "main_pool"
7939 [(set (match_operand 0 "register_operand" "=a")
7940 (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
7941 "GET_MODE (operands[0]) == Pmode"
7946 (if_then_else (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
7947 (const_string "larl") (const_string "la")))])
7949 (define_insn "reload_base_31"
7950 [(set (match_operand 0 "register_operand" "=a")
7951 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
7952 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7953 "basr\t%0,0\;la\t%0,%1-.(%0)"
7954 [(set_attr "length" "6")
7955 (set_attr "type" "la")])
7957 (define_insn "reload_base_64"
7958 [(set (match_operand 0 "register_operand" "=a")
7959 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
7960 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7962 [(set_attr "op_type" "RIL")
7963 (set_attr "type" "larl")])
7966 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
7971 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
7974 ;; Insns related to generating the function prologue and epilogue.
7978 (define_expand "prologue"
7979 [(use (const_int 0))]
7981 "s390_emit_prologue (); DONE;")
7983 (define_expand "epilogue"
7984 [(use (const_int 1))]
7986 "s390_emit_epilogue (false); DONE;")
7988 (define_expand "sibcall_epilogue"
7989 [(use (const_int 0))]
7991 "s390_emit_epilogue (true); DONE;")
7993 (define_insn "*return"
7995 (use (match_operand 0 "register_operand" "a"))]
7996 "GET_MODE (operands[0]) == Pmode"
7998 [(set_attr "op_type" "RR")
7999 (set_attr "type" "jsr")
8000 (set_attr "atype" "agen")])
8003 ;; Instruction definition to extend a 31-bit pointer into a 64-bit
8004 ;; pointer. This is used for compatibility.
8006 (define_expand "ptr_extend"
8007 [(set (match_operand:DI 0 "register_operand" "=r")
8008 (match_operand:SI 1 "register_operand" "r"))]
8011 emit_insn (gen_anddi3 (operands[0],
8012 gen_lowpart (DImode, operands[1]),
8013 GEN_INT (0x7fffffff)));
8017 ;; Instruction definition to expand eh_return macro to support
8018 ;; swapping in special linkage return addresses.
8020 (define_expand "eh_return"
8021 [(use (match_operand 0 "register_operand" ""))]
8024 s390_emit_tpf_eh_return (operands[0]);
8029 ; Stack Protector Patterns
8032 (define_expand "stack_protect_set"
8033 [(set (match_operand 0 "memory_operand" "")
8034 (match_operand 1 "memory_operand" ""))]
8037 #ifdef TARGET_THREAD_SSP_OFFSET
8039 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
8040 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
8043 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
8045 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
8050 (define_insn "stack_protect_set<mode>"
8051 [(set (match_operand:DSI 0 "memory_operand" "=Q")
8052 (unspec:DSI [(match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
8054 "mvc\t%O0(%G0,%R0),%S1"
8055 [(set_attr "op_type" "SS")])
8057 (define_expand "stack_protect_test"
8058 [(set (reg:CC CC_REGNUM)
8059 (compare (match_operand 0 "memory_operand" "")
8060 (match_operand 1 "memory_operand" "")))
8061 (match_operand 2 "" "")]
8064 #ifdef TARGET_THREAD_SSP_OFFSET
8066 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
8067 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
8069 s390_compare_op0 = operands[0];
8070 s390_compare_op1 = operands[1];
8071 s390_compare_emitted = gen_rtx_REG (CCZmode, CC_REGNUM);
8074 emit_insn (gen_stack_protect_testdi (operands[0], operands[1]));
8076 emit_insn (gen_stack_protect_testsi (operands[0], operands[1]));
8078 emit_jump_insn (gen_beq (operands[2]));
8083 (define_insn "stack_protect_test<mode>"
8084 [(set (reg:CCZ CC_REGNUM)
8085 (unspec:CCZ [(match_operand:DSI 0 "memory_operand" "Q")
8086 (match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
8088 "clc\t%O0(%G0,%R0),%S1"
8089 [(set_attr "op_type" "SS")])