1 ;;- Machine description for GNU compiler -- S/390 / zSeries version.
2 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
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 3, 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 COPYING3. If not see
21 ;; <http://www.gnu.org/licenses/>.
24 ;; See constraints.md for a description of constraints specific to s390.
27 ;; Special formats used for outputting 390 instructions.
29 ;; %C: print opcode suffix for branch condition.
30 ;; %D: print opcode suffix for inverse branch condition.
31 ;; %J: print tls_load/tls_gdcall/tls_ldcall suffix
32 ;; %G: print the size of the operand in bytes.
33 ;; %O: print only the displacement of a memory reference.
34 ;; %R: print only the base register of a memory reference.
35 ;; %S: print S-type memory reference (base+displacement).
36 ;; %N: print the second word of a DImode operand.
37 ;; %M: print the second word of a TImode operand.
38 ;; %Y: print shift count operand.
40 ;; %b: print integer X as if it's an unsigned byte.
41 ;; %x: print integer X as if it's an unsigned halfword.
42 ;; %h: print integer X as if it's a signed halfword.
43 ;; %i: print the first nonzero HImode part of X.
44 ;; %j: print the first HImode part unequal to -1 of X.
45 ;; %k: print the first nonzero SImode part of X.
46 ;; %m: print the first SImode part unequal to -1 of X.
47 ;; %o: print integer X as if it's an unsigned 32bit word.
49 ;; We have a special constraint for pattern matching.
51 ;; 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)
104 ; Test Data Class (TDC)
105 (UNSPEC_TDC_INSN 900)
109 ;; UNSPEC_VOLATILE usage
117 (UNSPECV_TPF_PROLOGUE 20)
118 (UNSPECV_TPF_EPILOGUE 21)
122 (UNSPECV_POOL_SECTION 201)
123 (UNSPECV_POOL_ALIGN 202)
124 (UNSPECV_POOL_ENTRY 203)
125 (UNSPECV_MAIN_POOL 300)
139 ; Registers with special meaning
143 ; Sibling call register.
145 ; Literal pool base register.
147 ; Return address register.
149 ; Condition code register.
151 ; Thread local storage pointer register.
155 ; Hardware register names
159 ; General purpose registers
161 ; Floating point registers.
167 ;; PFPO GPR0 argument format
172 ; PFPO operation type
173 (PFPO_CONVERT 0x1000000)
175 (PFPO_OP_TYPE_SF 0x5)
176 (PFPO_OP_TYPE_DF 0x6)
177 (PFPO_OP_TYPE_TF 0x7)
178 (PFPO_OP_TYPE_SD 0x8)
179 (PFPO_OP_TYPE_DD 0x9)
180 (PFPO_OP_TYPE_TD 0xa)
181 ; Bitposition of operand types
182 (PFPO_OP0_TYPE_SHIFT 16)
183 (PFPO_OP1_TYPE_SHIFT 8)
187 ;; Instruction operand type as used in the Principles of Operation.
188 ;; Used to determine defaults for length and other attribute values.
190 (define_attr "op_type"
191 "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY,RRF,RRR"
194 ;; Instruction type attribute used for scheduling.
196 (define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
197 cs,vs,store,sem,idiv,
198 imulhi,imulsi,imuldi,
199 branch,jsr,fsimptf,fsimpdf,fsimpsf,
200 floadtf,floaddf,floadsf,fstoredf,fstoresf,
201 fmultf,fmuldf,fmulsf,fdivtf,fdivdf,fdivsf,
202 ftoi,itof,fsqrttf,fsqrtdf,fsqrtsf,
203 ftrunctf,ftruncdf,other"
204 (cond [(eq_attr "op_type" "NN") (const_string "other")
205 (eq_attr "op_type" "SS") (const_string "cs")]
206 (const_string "integer")))
208 ;; Another attribute used for scheduling purposes:
209 ;; agen: Instruction uses the address generation unit
210 ;; reg: Instruction does not use the agen unit
212 (define_attr "atype" "agen,reg"
213 (if_then_else (eq_attr "op_type" "E,RR,RI,RRE")
215 (const_string "agen")))
219 (define_attr "length" ""
220 (cond [(eq_attr "op_type" "E,RR") (const_int 2)
221 (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI") (const_int 4)]
225 ;; Processor type. This attribute must exactly match the processor_type
226 ;; enumeration in s390.h. The current machine description does not
227 ;; distinguish between g5 and g6, but there are differences between the two
228 ;; CPUs could in theory be modeled.
230 (define_attr "cpu" "g5,g6,z900,z990,z9_109"
231 (const (symbol_ref "s390_tune")))
233 ;; Pipeline description for z900. For lack of anything better,
234 ;; this description is also used for the g5 and g6.
237 ;; Pipeline description for z990, z9-109 and z9-ec.
241 (include "predicates.md")
243 ;; Constraint definitions
244 (include "constraints.md")
251 ;; These mode iterators allow floating point patterns to be generated from the
253 (define_mode_iterator FP [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")])
254 (define_mode_iterator BFP [TF DF SF])
255 (define_mode_iterator DFP [TD DD])
256 (define_mode_iterator DFP_ALL [TD DD SD])
257 (define_mode_iterator DSF [DF SF])
258 (define_mode_iterator SD_SF [SF SD])
259 (define_mode_iterator DD_DF [DF DD])
260 (define_mode_iterator TD_TF [TF TD])
262 ;; This mode iterator allows 31-bit and 64-bit TDSI patterns to be generated
263 ;; from the same template.
264 (define_mode_iterator TDSI [(TI "TARGET_64BIT") DI SI])
266 ;; These mode iterators allow 31-bit and 64-bit GPR patterns to be generated
267 ;; from the same template.
268 (define_mode_iterator GPR [(DI "TARGET_64BIT") SI])
269 (define_mode_iterator DSI [DI SI])
271 ;; These mode iterators allow :P to be used for patterns that operate on
272 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
273 (define_mode_iterator DP [(TI "TARGET_64BIT") (DI "!TARGET_64BIT")])
274 (define_mode_iterator P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
276 ;; This mode iterator allows the QI and HI patterns to be defined from
277 ;; the same template.
278 (define_mode_iterator HQI [HI QI])
280 ;; This mode iterator allows the integer patterns to be defined from the
282 (define_mode_iterator INT [(DI "TARGET_64BIT") SI HI QI])
284 ;; This iterator allows to unify all 'bCOND' expander patterns.
285 (define_code_iterator COMPARE [eq ne gt gtu lt ltu ge geu le leu unordered
286 ordered uneq unlt ungt unle unge ltgt])
288 ;; This iterator allows to unify all 'sCOND' patterns.
289 (define_code_iterator SCOND [ltu gtu leu geu])
291 ;; This iterator allows some 'ashift' and 'lshiftrt' pattern to be defined from
292 ;; the same template.
293 (define_code_iterator SHIFT [ashift lshiftrt])
295 ;; This iterator and attribute allow to combine most atomic operations.
296 (define_code_iterator ATOMIC [and ior xor plus minus mult])
297 (define_code_attr atomic [(and "and") (ior "ior") (xor "xor")
298 (plus "add") (minus "sub") (mult "nand")])
300 ;; In FP templates, a string like "lt<de>br" will expand to "ltxbr" in
301 ;; TF/TDmode, "ltdbr" in DF/DDmode, and "ltebr" in SF/SDmode.
302 (define_mode_attr xde [(TF "x") (DF "d") (SF "e") (TD "x") (DD "d") (SD "e")])
304 ;; In FP templates, a <dee> in "m<dee><bt>r" will expand to "mx<bt>r" in
305 ;; TF/TDmode, "md<bt>r" in DF/DDmode, "mee<bt>r" in SFmode and "me<bt>r in
307 (define_mode_attr xdee [(TF "x") (DF "d") (SF "ee") (TD "x") (DD "d") (SD "e")])
309 ;; In FP templates, "<RRe>" will expand to "RRE" in TFmode and "RR" otherwise.
310 ;; Likewise for "<RXe>".
311 (define_mode_attr RRe [(TF "RRE") (DF "RR") (SF "RR")])
312 (define_mode_attr RXe [(TF "RXE") (DF "RX") (SF "RX")])
314 ;; The decimal floating point variants of add, sub, div and mul support 3
315 ;; fp register operands. The following attributes allow to merge the bfp and
316 ;; dfp variants in a single insn definition.
318 ;; This attribute is used to set op_type accordingly.
319 (define_mode_attr RRer [(TF "RRE") (DF "RRE") (SF "RRE") (TD "RRR")
320 (DD "RRR") (SD "RRR")])
322 ;; This attribute is used in the operand constraint list in order to have the
323 ;; first and the second operand match for bfp modes.
324 (define_mode_attr f0 [(TF "0") (DF "0") (SF "0") (TD "f") (DD "f") (DD "f")])
326 ;; This attribute is used in the operand list of the instruction to have an
327 ;; additional operand for the dfp instructions.
328 (define_mode_attr op1 [(TF "") (DF "") (SF "")
329 (TD "%1,") (DD "%1,") (SD "%1,")])
332 ;; This attribute is used in the operand constraint list
333 ;; for instructions dealing with the sign bit of 32 or 64bit fp values.
334 ;; TFmode values are represented by a fp register pair. Since the
335 ;; sign bit instructions only handle single source and target fp registers
336 ;; these instructions can only be used for TFmode values if the source and
337 ;; target operand uses the same fp register.
338 (define_mode_attr fT0 [(TF "0") (DF "f") (SF "f")])
340 ;; In FP templates, "<Rf>" will expand to "f" in TFmode and "R" otherwise.
341 ;; This is used to disable the memory alternative in TFmode patterns.
342 (define_mode_attr Rf [(TF "f") (DF "R") (SF "R") (TD "f") (DD "f") (SD "f")])
344 ;; This attribute adds b for bfp instructions and t for dfp instructions and is used
345 ;; within instruction mnemonics.
346 (define_mode_attr bt [(TF "b") (DF "b") (SF "b") (TD "t") (DD "t") (SD "t")])
348 ;; Although it is imprecise for z9-ec we handle all dfp instructions like
349 ;; bfp regarding the pipeline description.
350 (define_mode_attr bfp [(TF "tf") (DF "df") (SF "sf")
351 (TD "tf") (DD "df") (SD "sf")])
354 ;; In GPR and P templates, a constraint like "<d0>" will expand to "d" in DImode
355 ;; and "0" in SImode. This allows to combine instructions of which the 31bit
356 ;; version only operates on one register.
357 (define_mode_attr d0 [(DI "d") (SI "0")])
359 ;; In combination with d0 this allows to combine instructions of which the 31bit
360 ;; version only operates on one register. The DImode version needs an additional
361 ;; register for the assembler output.
362 (define_mode_attr 1 [(DI "%1,") (SI "")])
364 ;; In SHIFT templates, a string like "s<lr>dl" will expand to "sldl" in
365 ;; 'ashift' and "srdl" in 'lshiftrt'.
366 (define_code_attr lr [(ashift "l") (lshiftrt "r")])
368 ;; In SHIFT templates, this attribute holds the correct standard name for the
369 ;; pattern itself and the corresponding function calls.
370 (define_code_attr shift [(ashift "ashl") (lshiftrt "lshr")])
372 ;; This attribute handles differences in the instruction 'type' and will result
373 ;; in "RRE" for DImode and "RR" for SImode.
374 (define_mode_attr E [(DI "E") (SI "")])
376 ;; This attribute handles differences in the instruction 'type' and makes RX<Y>
377 ;; to result in "RXY" for DImode and "RX" for SImode.
378 (define_mode_attr Y [(DI "Y") (SI "")])
380 ;; This attribute handles differences in the instruction 'type' and will result
381 ;; in "RSE" for TImode and "RS" for DImode.
382 (define_mode_attr TE [(TI "E") (DI "")])
384 ;; In GPR templates, a string like "lc<g>r" will expand to "lcgr" in DImode
385 ;; and "lcr" in SImode.
386 (define_mode_attr g [(DI "g") (SI "")])
388 ;; In GPR templates, a string like "sl<y>" will expand to "slg" in DImode
389 ;; and "sly" in SImode. This is useful because on 64bit the ..g instructions
390 ;; were enhanced with long displacements whereas 31bit instructions got a ..y
391 ;; variant for long displacements.
392 (define_mode_attr y [(DI "g") (SI "y")])
394 ;; In DP templates, a string like "cds<g>" will expand to "cdsg" in TImode
395 ;; and "cds" in DImode.
396 (define_mode_attr tg [(TI "g") (DI "")])
398 ;; In GPR templates, a string like "c<gf>dbr" will expand to "cgdbr" in DImode
399 ;; and "cfdbr" in SImode.
400 (define_mode_attr gf [(DI "g") (SI "f")])
402 ;; ICM mask required to load MODE value into the lowest subreg
403 ;; of a SImode register.
404 (define_mode_attr icm_lo [(HI "3") (QI "1")])
406 ;; In HQI templates, a string like "llg<hc>" will expand to "llgh" in
407 ;; HImode and "llgc" in QImode.
408 (define_mode_attr hc [(HI "h") (QI "c")])
410 ;; In P templates, the mode <DBL> will expand to "TI" in DImode and "DI"
412 (define_mode_attr DBL [(DI "TI") (SI "DI")])
414 ;; This attribute expands to DF for TFmode and to DD for TDmode . It is
415 ;; used for Txmode splitters splitting a Txmode copy into 2 Dxmode copies.
416 (define_mode_attr HALF_TMODE [(TF "DF") (TD "DD")])
418 ;; Maximum unsigned integer that fits in MODE.
419 (define_mode_attr max_uint [(HI "65535") (QI "255")])
423 ;;- Compare instructions.
426 (define_expand "cmp<mode>"
427 [(set (reg:CC CC_REGNUM)
428 (compare:CC (match_operand:GPR 0 "register_operand" "")
429 (match_operand:GPR 1 "general_operand" "")))]
432 s390_compare_op0 = operands[0];
433 s390_compare_op1 = operands[1];
437 (define_expand "cmp<mode>"
438 [(set (reg:CC CC_REGNUM)
439 (compare:CC (match_operand:FP 0 "register_operand" "")
440 (match_operand:FP 1 "general_operand" "")))]
443 s390_compare_op0 = operands[0];
444 s390_compare_op1 = operands[1];
449 ; Test-under-Mask instructions
451 (define_insn "*tmqi_mem"
452 [(set (reg CC_REGNUM)
453 (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
454 (match_operand:QI 1 "immediate_operand" "n,n"))
455 (match_operand:QI 2 "immediate_operand" "n,n")))]
456 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], false))"
460 [(set_attr "op_type" "SI,SIY")])
462 (define_insn "*tmdi_reg"
463 [(set (reg CC_REGNUM)
464 (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
465 (match_operand:DI 1 "immediate_operand"
466 "N0HD0,N1HD0,N2HD0,N3HD0"))
467 (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
469 && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
470 && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
476 [(set_attr "op_type" "RI")])
478 (define_insn "*tmsi_reg"
479 [(set (reg CC_REGNUM)
480 (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
481 (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
482 (match_operand:SI 2 "immediate_operand" "n,n")))]
483 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
484 && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
488 [(set_attr "op_type" "RI")])
490 (define_insn "*tm<mode>_full"
491 [(set (reg CC_REGNUM)
492 (compare (match_operand:HQI 0 "register_operand" "d")
493 (match_operand:HQI 1 "immediate_operand" "n")))]
494 "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], true))"
496 [(set_attr "op_type" "RI")])
500 ; Load-and-Test instructions
503 ; tst(di|si) instruction pattern(s).
505 (define_insn "*tstdi_sign"
506 [(set (reg CC_REGNUM)
507 (compare (ashiftrt:DI (ashift:DI (subreg:DI (match_operand:SI 0 "register_operand" "d") 0)
508 (const_int 32)) (const_int 32))
509 (match_operand:DI 1 "const0_operand" "")))
510 (set (match_operand:DI 2 "register_operand" "=d")
511 (sign_extend:DI (match_dup 0)))]
512 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
514 [(set_attr "op_type" "RRE")])
517 (define_insn "*tst<mode>_extimm"
518 [(set (reg CC_REGNUM)
519 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,m")
520 (match_operand:GPR 1 "const0_operand" "")))
521 (set (match_operand:GPR 2 "register_operand" "=d,d")
523 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
527 [(set_attr "op_type" "RR<E>,RXY")])
530 (define_insn "*tst<mode>_cconly_extimm"
531 [(set (reg CC_REGNUM)
532 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,m")
533 (match_operand:GPR 1 "const0_operand" "")))
534 (clobber (match_scratch:GPR 2 "=X,d"))]
535 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
539 [(set_attr "op_type" "RR<E>,RXY")])
541 (define_insn "*tstdi"
542 [(set (reg CC_REGNUM)
543 (compare (match_operand:DI 0 "register_operand" "d")
544 (match_operand:DI 1 "const0_operand" "")))
545 (set (match_operand:DI 2 "register_operand" "=d")
547 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT && !TARGET_EXTIMM"
549 [(set_attr "op_type" "RRE")])
551 (define_insn "*tstsi"
552 [(set (reg CC_REGNUM)
553 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
554 (match_operand:SI 1 "const0_operand" "")))
555 (set (match_operand:SI 2 "register_operand" "=d,d,d")
557 "s390_match_ccmode(insn, CCSmode) && !TARGET_EXTIMM"
562 [(set_attr "op_type" "RR,RS,RSY")])
564 (define_insn "*tstsi_cconly"
565 [(set (reg CC_REGNUM)
566 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
567 (match_operand:SI 1 "const0_operand" "")))
568 (clobber (match_scratch:SI 2 "=X,d,d"))]
569 "s390_match_ccmode(insn, CCSmode)"
574 [(set_attr "op_type" "RR,RS,RSY")])
576 (define_insn "*tstdi_cconly_31"
577 [(set (reg CC_REGNUM)
578 (compare (match_operand:DI 0 "register_operand" "d")
579 (match_operand:DI 1 "const0_operand" "")))]
580 "s390_match_ccmode(insn, CCSmode) && !TARGET_64BIT"
582 [(set_attr "op_type" "RS")
583 (set_attr "atype" "reg")])
586 (define_insn "*tst<mode>_cconly2"
587 [(set (reg CC_REGNUM)
588 (compare (match_operand:GPR 0 "register_operand" "d")
589 (match_operand:GPR 1 "const0_operand" "")))]
590 "s390_match_ccmode(insn, CCSmode)"
592 [(set_attr "op_type" "RR<E>")])
594 ; tst(hi|qi) instruction pattern(s).
596 (define_insn "*tst<mode>CCT"
597 [(set (reg CC_REGNUM)
598 (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
599 (match_operand:HQI 1 "const0_operand" "")))
600 (set (match_operand:HQI 2 "register_operand" "=d,d,0")
602 "s390_match_ccmode(insn, CCTmode)"
605 icmy\t%2,<icm_lo>,%S0
607 [(set_attr "op_type" "RS,RSY,RI")])
609 (define_insn "*tsthiCCT_cconly"
610 [(set (reg CC_REGNUM)
611 (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
612 (match_operand:HI 1 "const0_operand" "")))
613 (clobber (match_scratch:HI 2 "=d,d,X"))]
614 "s390_match_ccmode(insn, CCTmode)"
619 [(set_attr "op_type" "RS,RSY,RI")])
621 (define_insn "*tstqiCCT_cconly"
622 [(set (reg CC_REGNUM)
623 (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
624 (match_operand:QI 1 "const0_operand" "")))]
625 "s390_match_ccmode(insn, CCTmode)"
630 [(set_attr "op_type" "SI,SIY,RI")])
632 (define_insn "*tst<mode>"
633 [(set (reg CC_REGNUM)
634 (compare (match_operand:HQI 0 "s_operand" "Q,S")
635 (match_operand:HQI 1 "const0_operand" "")))
636 (set (match_operand:HQI 2 "register_operand" "=d,d")
638 "s390_match_ccmode(insn, CCSmode)"
641 icmy\t%2,<icm_lo>,%S0"
642 [(set_attr "op_type" "RS,RSY")])
644 (define_insn "*tst<mode>_cconly"
645 [(set (reg CC_REGNUM)
646 (compare (match_operand:HQI 0 "s_operand" "Q,S")
647 (match_operand:HQI 1 "const0_operand" "")))
648 (clobber (match_scratch:HQI 2 "=d,d"))]
649 "s390_match_ccmode(insn, CCSmode)"
652 icmy\t%2,<icm_lo>,%S0"
653 [(set_attr "op_type" "RS,RSY")])
656 ; Compare (equality) instructions
658 (define_insn "*cmpdi_cct"
659 [(set (reg CC_REGNUM)
660 (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,d,Q")
661 (match_operand:DI 1 "general_operand" "d,K,Os,m,BQ")))]
662 "s390_match_ccmode (insn, CCTmode) && TARGET_64BIT"
669 [(set_attr "op_type" "RRE,RI,RIL,RXY,SS")])
671 (define_insn "*cmpsi_cct"
672 [(set (reg CC_REGNUM)
673 (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,d,Q")
674 (match_operand:SI 1 "general_operand" "d,K,Os,R,T,BQ")))]
675 "s390_match_ccmode (insn, CCTmode)"
683 [(set_attr "op_type" "RR,RI,RIL,RX,RXY,SS")])
686 ; Compare (signed) instructions
688 (define_insn "*cmpdi_ccs_sign"
689 [(set (reg CC_REGNUM)
690 (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m"))
691 (match_operand:DI 0 "register_operand" "d,d")))]
692 "s390_match_ccmode(insn, CCSRmode) && TARGET_64BIT"
696 [(set_attr "op_type" "RRE,RXY")])
698 (define_insn "*cmpsi_ccs_sign"
699 [(set (reg CC_REGNUM)
700 (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T"))
701 (match_operand:SI 0 "register_operand" "d,d")))]
702 "s390_match_ccmode(insn, CCSRmode)"
706 [(set_attr "op_type" "RX,RXY")])
708 ; cr, chi, cfi, c, cy, cgr, cghi, cgfi, cg
709 (define_insn "*cmp<mode>_ccs"
710 [(set (reg CC_REGNUM)
711 (compare (match_operand:GPR 0 "register_operand" "d,d,d,d,d")
712 (match_operand:GPR 1 "general_operand" "d,K,Os,R,T")))]
713 "s390_match_ccmode(insn, CCSmode)"
720 [(set_attr "op_type" "RR<E>,RI,RIL,RX<Y>,RXY")])
723 ; Compare (unsigned) instructions
725 (define_insn "*cmpdi_ccu_zero"
726 [(set (reg CC_REGNUM)
727 (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m"))
728 (match_operand:DI 0 "register_operand" "d,d")))]
729 "s390_match_ccmode (insn, CCURmode) && TARGET_64BIT"
733 [(set_attr "op_type" "RRE,RXY")])
735 (define_insn "*cmpdi_ccu"
736 [(set (reg CC_REGNUM)
737 (compare (match_operand:DI 0 "nonimmediate_operand" "d,d,d,Q,BQ")
738 (match_operand:DI 1 "general_operand" "d,Op,m,BQ,Q")))]
739 "s390_match_ccmode (insn, CCUmode) && TARGET_64BIT"
746 [(set_attr "op_type" "RRE,RIL,RXY,SS,SS")])
748 (define_insn "*cmpsi_ccu"
749 [(set (reg CC_REGNUM)
750 (compare (match_operand:SI 0 "nonimmediate_operand" "d,d,d,d,Q,BQ")
751 (match_operand:SI 1 "general_operand" "d,Os,R,T,BQ,Q")))]
752 "s390_match_ccmode (insn, CCUmode)"
760 [(set_attr "op_type" "RR,RIL,RX,RXY,SS,SS")])
762 (define_insn "*cmphi_ccu"
763 [(set (reg CC_REGNUM)
764 (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,BQ")
765 (match_operand:HI 1 "general_operand" "Q,S,BQ,Q")))]
766 "s390_match_ccmode (insn, CCUmode)
767 && !register_operand (operands[1], HImode)"
773 [(set_attr "op_type" "RS,RSY,SS,SS")])
775 (define_insn "*cmpqi_ccu"
776 [(set (reg CC_REGNUM)
777 (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
778 (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
779 "s390_match_ccmode (insn, CCUmode)
780 && !register_operand (operands[1], QImode)"
788 [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")])
791 ; Block compare (CLC) instruction patterns.
794 [(set (reg CC_REGNUM)
795 (compare (match_operand:BLK 0 "memory_operand" "Q")
796 (match_operand:BLK 1 "memory_operand" "Q")))
797 (use (match_operand 2 "const_int_operand" "n"))]
798 "s390_match_ccmode (insn, CCUmode)
799 && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
800 "clc\t%O0(%2,%R0),%S1"
801 [(set_attr "op_type" "SS")])
804 [(set (reg CC_REGNUM)
805 (compare (match_operand 0 "memory_operand" "")
806 (match_operand 1 "memory_operand" "")))]
808 && s390_match_ccmode (insn, CCUmode)
809 && GET_MODE (operands[0]) == GET_MODE (operands[1])
810 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
812 [(set (match_dup 0) (match_dup 1))
813 (use (match_dup 2))])]
815 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
816 operands[0] = adjust_address (operands[0], BLKmode, 0);
817 operands[1] = adjust_address (operands[1], BLKmode, 0);
819 operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
820 operands[0], operands[1]);
821 operands[0] = SET_DEST (PATTERN (curr_insn));
825 ; (TF|DF|SF|TD|DD|SD) instructions
827 ; ltxbr, ltdbr, ltebr, ltxtr, ltdtr
828 (define_insn "*cmp<mode>_ccs_0"
829 [(set (reg CC_REGNUM)
830 (compare (match_operand:FP 0 "register_operand" "f")
831 (match_operand:FP 1 "const0_operand" "")))]
832 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
833 "lt<xde><bt>r\t%0,%0"
834 [(set_attr "op_type" "RRE")
835 (set_attr "type" "fsimp<bfp>")])
837 ; cxtr, cxbr, cdbr, cebr, cxb, cdb, ceb, cxbtr, cdbtr
838 (define_insn "*cmp<mode>_ccs"
839 [(set (reg CC_REGNUM)
840 (compare (match_operand:FP 0 "register_operand" "f,f")
841 (match_operand:FP 1 "general_operand" "f,<Rf>")))]
842 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
846 [(set_attr "op_type" "RRE,RXE")
847 (set_attr "type" "fsimp<bfp>")])
850 ;;- Move instructions.
854 ; movti instruction pattern(s).
858 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,d,o,Q")
859 (match_operand:TI 1 "general_operand" "QS,d,dPm,d,Q"))]
867 [(set_attr "op_type" "RSY,RSY,*,*,SS")
868 (set_attr "type" "lm,stm,*,*,*")])
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, 0)"
875 [(set (match_dup 2) (match_dup 4))
876 (set (match_dup 3) (match_dup 5))]
878 operands[2] = operand_subword (operands[0], 0, 0, TImode);
879 operands[3] = operand_subword (operands[0], 1, 0, TImode);
880 operands[4] = operand_subword (operands[1], 0, 0, TImode);
881 operands[5] = operand_subword (operands[1], 1, 0, TImode);
885 [(set (match_operand:TI 0 "nonimmediate_operand" "")
886 (match_operand:TI 1 "general_operand" ""))]
887 "TARGET_64BIT && reload_completed
888 && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
889 [(set (match_dup 2) (match_dup 4))
890 (set (match_dup 3) (match_dup 5))]
892 operands[2] = operand_subword (operands[0], 1, 0, TImode);
893 operands[3] = operand_subword (operands[0], 0, 0, TImode);
894 operands[4] = operand_subword (operands[1], 1, 0, TImode);
895 operands[5] = operand_subword (operands[1], 0, 0, TImode);
899 [(set (match_operand:TI 0 "register_operand" "")
900 (match_operand:TI 1 "memory_operand" ""))]
901 "TARGET_64BIT && reload_completed
902 && !s_operand (operands[1], VOIDmode)"
903 [(set (match_dup 0) (match_dup 1))]
905 rtx addr = operand_subword (operands[0], 1, 0, TImode);
906 s390_load_address (addr, XEXP (operands[1], 0));
907 operands[1] = replace_equiv_address (operands[1], addr);
912 ; Patterns used for secondary reloads
915 ; Handles loading a PLUS (load address) expression
917 (define_expand "reload<mode>_plus"
918 [(parallel [(match_operand:P 0 "register_operand" "=a")
919 (match_operand:P 1 "s390_plus_operand" "")
920 (match_operand:P 2 "register_operand" "=&a")])]
923 s390_expand_plus_operand (operands[0], operands[1], operands[2]);
927 ; Handles assessing a non-offsetable memory address
929 (define_expand "reload<mode>_nonoffmem_in"
930 [(parallel [(match_operand 0 "register_operand" "")
931 (match_operand 1 "" "")
932 (match_operand:P 2 "register_operand" "=&a")])]
935 gcc_assert (MEM_P (operands[1]));
936 s390_load_address (operands[2], find_replacement (&XEXP (operands[1], 0)));
937 operands[1] = replace_equiv_address (operands[1], operands[2]);
938 emit_move_insn (operands[0], operands[1]);
942 (define_expand "reload<mode>_nonoffmem_out"
943 [(parallel [(match_operand 0 "" "")
944 (match_operand 1 "register_operand" "")
945 (match_operand:P 2 "register_operand" "=&a")])]
948 gcc_assert (MEM_P (operands[0]));
949 s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
950 operands[0] = replace_equiv_address (operands[0], operands[2]);
951 emit_move_insn (operands[0], operands[1]);
956 ; movdi instruction pattern(s).
959 (define_expand "movdi"
960 [(set (match_operand:DI 0 "general_operand" "")
961 (match_operand:DI 1 "general_operand" ""))]
964 /* Handle symbolic constants. */
966 && (SYMBOLIC_CONST (operands[1])
967 || (GET_CODE (operands[1]) == PLUS
968 && XEXP (operands[1], 0) == pic_offset_table_rtx
969 && SYMBOLIC_CONST (XEXP (operands[1], 1)))))
970 emit_symbolic_move (operands);
973 (define_insn "*movdi_larl"
974 [(set (match_operand:DI 0 "register_operand" "=d")
975 (match_operand:DI 1 "larl_operand" "X"))]
977 && !FP_REG_P (operands[0])"
979 [(set_attr "op_type" "RIL")
980 (set_attr "type" "larl")])
982 (define_insn "*movdi_64dfp"
983 [(set (match_operand:DI 0 "nonimmediate_operand"
984 "=d,d,d,d,d,d,d,d,f,d,d,d,d,
985 m,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
986 (match_operand:DI 1 "general_operand"
987 "K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,d,m,
988 d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
989 "TARGET_64BIT && TARGET_DFP"
1015 [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RRE,RXY,RXY,
1016 RR,RX,RXY,RX,RXY,*,*,RS,RS,SS")
1017 (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,lr,load,store,
1018 floaddf,floaddf,floaddf,fstoredf,fstoredf,*,*,*,*,*")])
1020 (define_insn "*movdi_64extimm"
1021 [(set (match_operand:DI 0 "nonimmediate_operand"
1022 "=d,d,d,d,d,d,d,d,d,d,d,m,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
1023 (match_operand:DI 1 "general_operand"
1024 "K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,L,d,m,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
1025 "TARGET_64BIT && TARGET_EXTIMM"
1049 [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RXY,RRE,RXY,RXY,
1050 RR,RX,RXY,RX,RXY,*,*,RS,RS,SS")
1051 (set_attr "type" "*,*,*,*,*,*,*,*,la,lr,load,store,
1052 floaddf,floaddf,floaddf,fstoredf,fstoredf,*,*,*,*,*")])
1054 (define_insn "*movdi_64"
1055 [(set (match_operand:DI 0 "nonimmediate_operand"
1056 "=d,d,d,d,d,d,d,d,m,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
1057 (match_operand:DI 1 "general_operand"
1058 "K,N0HD0,N1HD0,N2HD0,N3HD0,L,d,m,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
1059 "TARGET_64BIT && !TARGET_EXTIMM"
1080 [(set_attr "op_type" "RI,RI,RI,RI,RI,RXY,RRE,RXY,RXY,
1081 RR,RX,RXY,RX,RXY,*,*,RS,RS,SS")
1082 (set_attr "type" "*,*,*,*,*,la,lr,load,store,
1083 floaddf,floaddf,floaddf,fstoredf,fstoredf,*,*,*,*,*")])
1086 [(set (match_operand:DI 0 "register_operand" "")
1087 (match_operand:DI 1 "register_operand" ""))]
1088 "TARGET_64BIT && ACCESS_REG_P (operands[1])"
1089 [(set (match_dup 2) (match_dup 3))
1090 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
1091 (set (strict_low_part (match_dup 2)) (match_dup 4))]
1092 "operands[2] = gen_lowpart (SImode, operands[0]);
1093 s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
1096 [(set (match_operand:DI 0 "register_operand" "")
1097 (match_operand:DI 1 "register_operand" ""))]
1098 "TARGET_64BIT && ACCESS_REG_P (operands[0])
1099 && dead_or_set_p (insn, operands[1])"
1100 [(set (match_dup 3) (match_dup 2))
1101 (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
1102 (set (match_dup 4) (match_dup 2))]
1103 "operands[2] = gen_lowpart (SImode, operands[1]);
1104 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1107 [(set (match_operand:DI 0 "register_operand" "")
1108 (match_operand:DI 1 "register_operand" ""))]
1109 "TARGET_64BIT && ACCESS_REG_P (operands[0])
1110 && !dead_or_set_p (insn, operands[1])"
1111 [(set (match_dup 3) (match_dup 2))
1112 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
1113 (set (match_dup 4) (match_dup 2))
1114 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
1115 "operands[2] = gen_lowpart (SImode, operands[1]);
1116 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1118 (define_insn "*movdi_31"
1119 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,Q,S,d,o,!*f,!*f,!*f,!R,!T,Q")
1120 (match_operand:DI 1 "general_operand" "Q,S,d,d,dPm,d,*f,R,T,*f,*f,Q"))]
1135 [(set_attr "op_type" "RS,RSY,RS,RSY,*,*,RR,RX,RXY,RX,RXY,SS")
1136 (set_attr "type" "lm,lm,stm,stm,*,*,floaddf,floaddf,floaddf,fstoredf,fstoredf,*")])
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, 0)"
1143 [(set (match_dup 2) (match_dup 4))
1144 (set (match_dup 3) (match_dup 5))]
1146 operands[2] = operand_subword (operands[0], 0, 0, DImode);
1147 operands[3] = operand_subword (operands[0], 1, 0, DImode);
1148 operands[4] = operand_subword (operands[1], 0, 0, DImode);
1149 operands[5] = operand_subword (operands[1], 1, 0, DImode);
1153 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1154 (match_operand:DI 1 "general_operand" ""))]
1155 "!TARGET_64BIT && reload_completed
1156 && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
1157 [(set (match_dup 2) (match_dup 4))
1158 (set (match_dup 3) (match_dup 5))]
1160 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1161 operands[3] = operand_subword (operands[0], 0, 0, DImode);
1162 operands[4] = operand_subword (operands[1], 1, 0, DImode);
1163 operands[5] = operand_subword (operands[1], 0, 0, DImode);
1167 [(set (match_operand:DI 0 "register_operand" "")
1168 (match_operand:DI 1 "memory_operand" ""))]
1169 "!TARGET_64BIT && reload_completed
1170 && !FP_REG_P (operands[0])
1171 && !s_operand (operands[1], VOIDmode)"
1172 [(set (match_dup 0) (match_dup 1))]
1174 rtx addr = operand_subword (operands[0], 1, 0, DImode);
1175 s390_load_address (addr, XEXP (operands[1], 0));
1176 operands[1] = replace_equiv_address (operands[1], addr);
1180 [(set (match_operand:DI 0 "register_operand" "")
1181 (mem:DI (match_operand 1 "address_operand" "")))]
1183 && !FP_REG_P (operands[0])
1184 && GET_CODE (operands[1]) == SYMBOL_REF
1185 && CONSTANT_POOL_ADDRESS_P (operands[1])
1186 && get_pool_mode (operands[1]) == DImode
1187 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1188 [(set (match_dup 0) (match_dup 2))]
1189 "operands[2] = get_pool_constant (operands[1]);")
1191 (define_insn "*la_64"
1192 [(set (match_operand:DI 0 "register_operand" "=d,d")
1193 (match_operand:QI 1 "address_operand" "U,W"))]
1198 [(set_attr "op_type" "RX,RXY")
1199 (set_attr "type" "la")])
1203 [(set (match_operand:DI 0 "register_operand" "")
1204 (match_operand:QI 1 "address_operand" ""))
1205 (clobber (reg:CC CC_REGNUM))])]
1207 && preferred_la_operand_p (operands[1], const0_rtx)"
1208 [(set (match_dup 0) (match_dup 1))]
1212 [(set (match_operand:DI 0 "register_operand" "")
1213 (match_operand:DI 1 "register_operand" ""))
1216 (plus:DI (match_dup 0)
1217 (match_operand:DI 2 "nonmemory_operand" "")))
1218 (clobber (reg:CC CC_REGNUM))])]
1220 && !reg_overlap_mentioned_p (operands[0], operands[2])
1221 && preferred_la_operand_p (operands[1], operands[2])"
1222 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1226 ; movsi instruction pattern(s).
1229 (define_expand "movsi"
1230 [(set (match_operand:SI 0 "general_operand" "")
1231 (match_operand:SI 1 "general_operand" ""))]
1234 /* Handle symbolic constants. */
1236 && (SYMBOLIC_CONST (operands[1])
1237 || (GET_CODE (operands[1]) == PLUS
1238 && XEXP (operands[1], 0) == pic_offset_table_rtx
1239 && SYMBOLIC_CONST (XEXP(operands[1], 1)))))
1240 emit_symbolic_move (operands);
1243 (define_insn "*movsi_larl"
1244 [(set (match_operand:SI 0 "register_operand" "=d")
1245 (match_operand:SI 1 "larl_operand" "X"))]
1246 "!TARGET_64BIT && TARGET_CPU_ZARCH
1247 && !FP_REG_P (operands[0])"
1249 [(set_attr "op_type" "RIL")
1250 (set_attr "type" "larl")])
1252 (define_insn "*movsi_zarch"
1253 [(set (match_operand:SI 0 "nonimmediate_operand"
1254 "=d,d,d,d,d,d,d,d,R,T,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
1255 (match_operand:SI 1 "general_operand"
1256 "K,N0HS0,N1HS0,Os,L,d,R,T,d,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
1279 [(set_attr "op_type" "RI,RI,RI,RIL,RXY,RR,RX,RXY,RX,RXY,
1280 RR,RX,RXY,RX,RXY,RRE,RRE,RS,RS,SS")
1281 (set_attr "type" "*,*,*,*,la,lr,load,load,store,store,
1282 floadsf,floadsf,floadsf,fstoresf,fstoresf,*,*,*,*,*")])
1284 (define_insn "*movsi_esa"
1285 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!R,d,t,Q,t,?Q")
1286 (match_operand:SI 1 "general_operand" "K,d,R,d,*f,R,*f,t,d,t,Q,?Q"))]
1301 [(set_attr "op_type" "RI,RR,RX,RX,RR,RX,RX,RRE,RRE,RS,RS,SS")
1302 (set_attr "type" "*,lr,load,store,floadsf,floadsf,fstoresf,*,*,*,*,*")])
1305 [(set (match_operand:SI 0 "register_operand" "")
1306 (mem:SI (match_operand 1 "address_operand" "")))]
1307 "!FP_REG_P (operands[0])
1308 && GET_CODE (operands[1]) == SYMBOL_REF
1309 && CONSTANT_POOL_ADDRESS_P (operands[1])
1310 && get_pool_mode (operands[1]) == SImode
1311 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1312 [(set (match_dup 0) (match_dup 2))]
1313 "operands[2] = get_pool_constant (operands[1]);")
1315 (define_insn "*la_31"
1316 [(set (match_operand:SI 0 "register_operand" "=d,d")
1317 (match_operand:QI 1 "address_operand" "U,W"))]
1318 "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
1322 [(set_attr "op_type" "RX,RXY")
1323 (set_attr "type" "la")])
1327 [(set (match_operand:SI 0 "register_operand" "")
1328 (match_operand:QI 1 "address_operand" ""))
1329 (clobber (reg:CC CC_REGNUM))])]
1331 && preferred_la_operand_p (operands[1], const0_rtx)"
1332 [(set (match_dup 0) (match_dup 1))]
1336 [(set (match_operand:SI 0 "register_operand" "")
1337 (match_operand:SI 1 "register_operand" ""))
1340 (plus:SI (match_dup 0)
1341 (match_operand:SI 2 "nonmemory_operand" "")))
1342 (clobber (reg:CC CC_REGNUM))])]
1344 && !reg_overlap_mentioned_p (operands[0], operands[2])
1345 && preferred_la_operand_p (operands[1], operands[2])"
1346 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
1349 (define_insn "*la_31_and"
1350 [(set (match_operand:SI 0 "register_operand" "=d,d")
1351 (and:SI (match_operand:QI 1 "address_operand" "U,W")
1352 (const_int 2147483647)))]
1357 [(set_attr "op_type" "RX,RXY")
1358 (set_attr "type" "la")])
1360 (define_insn_and_split "*la_31_and_cc"
1361 [(set (match_operand:SI 0 "register_operand" "=d")
1362 (and:SI (match_operand:QI 1 "address_operand" "p")
1363 (const_int 2147483647)))
1364 (clobber (reg:CC CC_REGNUM))]
1367 "&& reload_completed"
1369 (and:SI (match_dup 1) (const_int 2147483647)))]
1371 [(set_attr "op_type" "RX")
1372 (set_attr "type" "la")])
1374 (define_insn "force_la_31"
1375 [(set (match_operand:SI 0 "register_operand" "=d,d")
1376 (match_operand:QI 1 "address_operand" "U,W"))
1377 (use (const_int 0))]
1382 [(set_attr "op_type" "RX")
1383 (set_attr "type" "la")])
1386 ; movhi instruction pattern(s).
1389 (define_expand "movhi"
1390 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1391 (match_operand:HI 1 "general_operand" ""))]
1394 /* Make it explicit that loading a register from memory
1395 always sign-extends (at least) to SImode. */
1396 if (optimize && can_create_pseudo_p ()
1397 && register_operand (operands[0], VOIDmode)
1398 && GET_CODE (operands[1]) == MEM)
1400 rtx tmp = gen_reg_rtx (SImode);
1401 rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
1402 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1403 operands[1] = gen_lowpart (HImode, tmp);
1407 (define_insn "*movhi"
1408 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,R,T,?Q")
1409 (match_operand:HI 1 "general_operand" "d,n,R,T,d,d,?Q"))]
1419 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SS")
1420 (set_attr "type" "lr,*,*,*,store,store,*")])
1423 [(set (match_operand:HI 0 "register_operand" "")
1424 (mem:HI (match_operand 1 "address_operand" "")))]
1425 "GET_CODE (operands[1]) == SYMBOL_REF
1426 && CONSTANT_POOL_ADDRESS_P (operands[1])
1427 && get_pool_mode (operands[1]) == HImode
1428 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1429 [(set (match_dup 0) (match_dup 2))]
1430 "operands[2] = get_pool_constant (operands[1]);")
1433 ; movqi instruction pattern(s).
1436 (define_expand "movqi"
1437 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1438 (match_operand:QI 1 "general_operand" ""))]
1441 /* On z/Architecture, zero-extending from memory to register
1442 is just as fast as a QImode load. */
1443 if (TARGET_ZARCH && optimize && can_create_pseudo_p ()
1444 && register_operand (operands[0], VOIDmode)
1445 && GET_CODE (operands[1]) == MEM)
1447 rtx tmp = gen_reg_rtx (word_mode);
1448 rtx ext = gen_rtx_ZERO_EXTEND (word_mode, operands[1]);
1449 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1450 operands[1] = gen_lowpart (QImode, tmp);
1454 (define_insn "*movqi"
1455 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q")
1456 (match_operand:QI 1 "general_operand" "d,n,R,T,d,d,n,n,?Q"))]
1468 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS")
1469 (set_attr "type" "lr,*,*,*,store,store,store,store,*")])
1472 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1473 (mem:QI (match_operand 1 "address_operand" "")))]
1474 "GET_CODE (operands[1]) == SYMBOL_REF
1475 && CONSTANT_POOL_ADDRESS_P (operands[1])
1476 && get_pool_mode (operands[1]) == QImode
1477 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1478 [(set (match_dup 0) (match_dup 2))]
1479 "operands[2] = get_pool_constant (operands[1]);")
1482 ; movstrictqi instruction pattern(s).
1485 (define_insn "*movstrictqi"
1486 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
1487 (match_operand:QI 1 "memory_operand" "R,T"))]
1492 [(set_attr "op_type" "RX,RXY")])
1495 ; movstricthi instruction pattern(s).
1498 (define_insn "*movstricthi"
1499 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
1500 (match_operand:HI 1 "memory_operand" "Q,S"))
1501 (clobber (reg:CC CC_REGNUM))]
1506 [(set_attr "op_type" "RS,RSY")])
1509 ; movstrictsi instruction pattern(s).
1512 (define_insn "movstrictsi"
1513 [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
1514 (match_operand:SI 1 "general_operand" "d,R,T,t"))]
1521 [(set_attr "op_type" "RR,RX,RXY,RRE")
1522 (set_attr "type" "lr,load,load,*")])
1525 ; mov(tf|td) instruction pattern(s).
1528 (define_expand "mov<mode>"
1529 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1530 (match_operand:TD_TF 1 "general_operand" ""))]
1534 (define_insn "*mov<mode>_64"
1535 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o, d,QS, d,o,Q")
1536 (match_operand:TD_TF 1 "general_operand" " G,f,o,f,QS, d,dm,d,Q"))]
1548 [(set_attr "op_type" "RRE,RRE,*,*,RSY,RSY,*,*,*")
1549 (set_attr "type" "fsimptf,fsimptf,*,*,lm,stm,*,*,*")])
1551 (define_insn "*mov<mode>_31"
1552 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o,Q")
1553 (match_operand:TD_TF 1 "general_operand" " G,f,o,f,Q"))]
1561 [(set_attr "op_type" "RRE,RRE,*,*,*")
1562 (set_attr "type" "fsimptf,fsimptf,*,*,*")])
1564 ; TFmode in GPRs splitters
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, 0)"
1571 [(set (match_dup 2) (match_dup 4))
1572 (set (match_dup 3) (match_dup 5))]
1574 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
1575 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
1576 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
1577 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
1581 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1582 (match_operand:TD_TF 1 "general_operand" ""))]
1583 "TARGET_64BIT && reload_completed
1584 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
1585 [(set (match_dup 2) (match_dup 4))
1586 (set (match_dup 3) (match_dup 5))]
1588 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
1589 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
1590 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
1591 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
1595 [(set (match_operand:TD_TF 0 "register_operand" "")
1596 (match_operand:TD_TF 1 "memory_operand" ""))]
1597 "TARGET_64BIT && reload_completed
1598 && !FP_REG_P (operands[0])
1599 && !s_operand (operands[1], VOIDmode)"
1600 [(set (match_dup 0) (match_dup 1))]
1602 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
1603 s390_load_address (addr, XEXP (operands[1], 0));
1604 operands[1] = replace_equiv_address (operands[1], addr);
1607 ; TFmode in BFPs splitters
1610 [(set (match_operand:TD_TF 0 "register_operand" "")
1611 (match_operand:TD_TF 1 "memory_operand" ""))]
1612 "reload_completed && offsettable_memref_p (operands[1])
1613 && FP_REG_P (operands[0])"
1614 [(set (match_dup 2) (match_dup 4))
1615 (set (match_dup 3) (match_dup 5))]
1617 operands[2] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
1619 operands[3] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
1621 operands[4] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 0);
1622 operands[5] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 8);
1626 [(set (match_operand:TD_TF 0 "memory_operand" "")
1627 (match_operand:TD_TF 1 "register_operand" ""))]
1628 "reload_completed && offsettable_memref_p (operands[0])
1629 && FP_REG_P (operands[1])"
1630 [(set (match_dup 2) (match_dup 4))
1631 (set (match_dup 3) (match_dup 5))]
1633 operands[2] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 0);
1634 operands[3] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 8);
1635 operands[4] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
1637 operands[5] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
1642 ; mov(df|dd) instruction pattern(s).
1645 (define_expand "mov<mode>"
1646 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
1647 (match_operand:DD_DF 1 "general_operand" ""))]
1651 (define_insn "*mov<mode>_64dfp"
1652 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
1653 "=f,f,f,d,f,f,R,T,d,d,m,?Q")
1654 (match_operand:DD_DF 1 "general_operand"
1655 "G,f,d,f,R,T,f,f,d,m,d,?Q"))]
1656 "TARGET_64BIT && TARGET_DFP"
1670 [(set_attr "op_type" "RRE,RR,RRE,RRE,RX,RXY,RX,RXY,RRE,RXY,RXY,SS")
1671 (set_attr "type" "fsimpdf,floaddf,floaddf,floaddf,floaddf,floaddf,
1672 fstoredf,fstoredf,lr,load,store,*")])
1674 (define_insn "*mov<mode>_64"
1675 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "=f,f,f,f,R,T,d,d,m,?Q")
1676 (match_operand:DD_DF 1 "general_operand" "G,f,R,T,f,f,d,m,d,?Q"))]
1689 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RRE,RXY,RXY,SS")
1690 (set_attr "type" "fsimp<bfp>,fload<bfp>,fload<bfp>,fload<bfp>,
1691 fstore<bfp>,fstore<bfp>,lr,load,store,*")])
1693 (define_insn "*mov<mode>_31"
1694 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
1695 "=f,f,f,f,R,T,d,d,Q,S, d,o,Q")
1696 (match_operand:DD_DF 1 "general_operand"
1697 " G,f,R,T,f,f,Q,S,d,d,dPm,d,Q"))]
1713 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RS,RSY,RS,RSY,*,*,SS")
1714 (set_attr "type" "fsimp<bfp>,fload<bfp>,fload<bfp>,fload<bfp>,
1715 fstore<bfp>,fstore<bfp>,lm,lm,stm,stm,*,*,*")])
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, 0)"
1722 [(set (match_dup 2) (match_dup 4))
1723 (set (match_dup 3) (match_dup 5))]
1725 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
1726 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
1727 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
1728 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
1732 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
1733 (match_operand:DD_DF 1 "general_operand" ""))]
1734 "!TARGET_64BIT && reload_completed
1735 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
1736 [(set (match_dup 2) (match_dup 4))
1737 (set (match_dup 3) (match_dup 5))]
1739 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
1740 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
1741 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
1742 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
1746 [(set (match_operand:DD_DF 0 "register_operand" "")
1747 (match_operand:DD_DF 1 "memory_operand" ""))]
1748 "!TARGET_64BIT && reload_completed
1749 && !FP_REG_P (operands[0])
1750 && !s_operand (operands[1], VOIDmode)"
1751 [(set (match_dup 0) (match_dup 1))]
1753 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
1754 s390_load_address (addr, XEXP (operands[1], 0));
1755 operands[1] = replace_equiv_address (operands[1], addr);
1759 ; mov(sf|sd) instruction pattern(s).
1762 (define_insn "mov<mode>"
1763 [(set (match_operand:SD_SF 0 "nonimmediate_operand"
1764 "=f,f,f,f,R,T,d,d,d,R,T,?Q")
1765 (match_operand:SD_SF 1 "general_operand"
1766 " G,f,R,T,f,f,d,R,T,d,d,?Q"))]
1781 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RR,RX,RXY,RX,RXY,SS")
1782 (set_attr "type" "fsimp<bfp>,fload<bfp>,fload<bfp>,fload<bfp>,
1783 fstore<bfp>,fstore<bfp>,lr,load,load,store,store,*")])
1786 ; movcc instruction pattern
1789 (define_insn "movcc"
1790 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
1791 (match_operand:CC 1 "nonimmediate_operand" "d,d,c,R,T,d,d"))]
1801 [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
1802 (set_attr "type" "lr,*,*,store,store,load,load")])
1805 ; Block move (MVC) patterns.
1809 [(set (match_operand:BLK 0 "memory_operand" "=Q")
1810 (match_operand:BLK 1 "memory_operand" "Q"))
1811 (use (match_operand 2 "const_int_operand" "n"))]
1812 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
1813 "mvc\t%O0(%2,%R0),%S1"
1814 [(set_attr "op_type" "SS")])
1817 [(set (match_operand 0 "memory_operand" "")
1818 (match_operand 1 "memory_operand" ""))]
1820 && GET_MODE (operands[0]) == GET_MODE (operands[1])
1821 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
1823 [(set (match_dup 0) (match_dup 1))
1824 (use (match_dup 2))])]
1826 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
1827 operands[0] = adjust_address (operands[0], BLKmode, 0);
1828 operands[1] = adjust_address (operands[1], BLKmode, 0);
1833 [(set (match_operand:BLK 0 "memory_operand" "")
1834 (match_operand:BLK 1 "memory_operand" ""))
1835 (use (match_operand 2 "const_int_operand" ""))])
1837 [(set (match_operand:BLK 3 "memory_operand" "")
1838 (match_operand:BLK 4 "memory_operand" ""))
1839 (use (match_operand 5 "const_int_operand" ""))])]
1840 "s390_offset_p (operands[0], operands[3], operands[2])
1841 && s390_offset_p (operands[1], operands[4], operands[2])
1842 && !s390_overlap_p (operands[0], operands[1],
1843 INTVAL (operands[2]) + INTVAL (operands[5]))
1844 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
1846 [(set (match_dup 6) (match_dup 7))
1847 (use (match_dup 8))])]
1848 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
1849 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
1850 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
1854 ; load_multiple pattern(s).
1856 ; ??? Due to reload problems with replacing registers inside match_parallel
1857 ; we currently support load_multiple/store_multiple only after reload.
1860 (define_expand "load_multiple"
1861 [(match_par_dup 3 [(set (match_operand 0 "" "")
1862 (match_operand 1 "" ""))
1863 (use (match_operand 2 "" ""))])]
1866 enum machine_mode mode;
1872 /* Support only loading a constant number of fixed-point registers from
1873 memory and only bother with this if more than two */
1874 if (GET_CODE (operands[2]) != CONST_INT
1875 || INTVAL (operands[2]) < 2
1876 || INTVAL (operands[2]) > 16
1877 || GET_CODE (operands[1]) != MEM
1878 || GET_CODE (operands[0]) != REG
1879 || REGNO (operands[0]) >= 16)
1882 count = INTVAL (operands[2]);
1883 regno = REGNO (operands[0]);
1884 mode = GET_MODE (operands[0]);
1885 if (mode != SImode && mode != word_mode)
1888 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
1889 if (!can_create_pseudo_p ())
1891 if (GET_CODE (XEXP (operands[1], 0)) == REG)
1893 from = XEXP (operands[1], 0);
1896 else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
1897 && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
1898 && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
1900 from = XEXP (XEXP (operands[1], 0), 0);
1901 off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
1908 from = force_reg (Pmode, XEXP (operands[1], 0));
1912 for (i = 0; i < count; i++)
1913 XVECEXP (operands[3], 0, i)
1914 = gen_rtx_SET (VOIDmode, gen_rtx_REG (mode, regno + i),
1915 change_address (operands[1], mode,
1916 plus_constant (from, off + i * GET_MODE_SIZE (mode))));
1919 (define_insn "*load_multiple_di"
1920 [(match_parallel 0 "load_multiple_operation"
1921 [(set (match_operand:DI 1 "register_operand" "=r")
1922 (match_operand:DI 2 "s_operand" "QS"))])]
1923 "reload_completed && word_mode == DImode"
1925 int words = XVECLEN (operands[0], 0);
1926 operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
1927 return "lmg\t%1,%0,%S2";
1929 [(set_attr "op_type" "RSY")
1930 (set_attr "type" "lm")])
1932 (define_insn "*load_multiple_si"
1933 [(match_parallel 0 "load_multiple_operation"
1934 [(set (match_operand:SI 1 "register_operand" "=r,r")
1935 (match_operand:SI 2 "s_operand" "Q,S"))])]
1938 int words = XVECLEN (operands[0], 0);
1939 operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
1940 return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
1942 [(set_attr "op_type" "RS,RSY")
1943 (set_attr "type" "lm")])
1946 ; store multiple pattern(s).
1949 (define_expand "store_multiple"
1950 [(match_par_dup 3 [(set (match_operand 0 "" "")
1951 (match_operand 1 "" ""))
1952 (use (match_operand 2 "" ""))])]
1955 enum machine_mode mode;
1961 /* Support only storing a constant number of fixed-point registers to
1962 memory and only bother with this if more than two. */
1963 if (GET_CODE (operands[2]) != CONST_INT
1964 || INTVAL (operands[2]) < 2
1965 || INTVAL (operands[2]) > 16
1966 || GET_CODE (operands[0]) != MEM
1967 || GET_CODE (operands[1]) != REG
1968 || REGNO (operands[1]) >= 16)
1971 count = INTVAL (operands[2]);
1972 regno = REGNO (operands[1]);
1973 mode = GET_MODE (operands[1]);
1974 if (mode != SImode && mode != word_mode)
1977 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
1979 if (!can_create_pseudo_p ())
1981 if (GET_CODE (XEXP (operands[0], 0)) == REG)
1983 to = XEXP (operands[0], 0);
1986 else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
1987 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
1988 && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
1990 to = XEXP (XEXP (operands[0], 0), 0);
1991 off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
1998 to = force_reg (Pmode, XEXP (operands[0], 0));
2002 for (i = 0; i < count; i++)
2003 XVECEXP (operands[3], 0, i)
2004 = gen_rtx_SET (VOIDmode,
2005 change_address (operands[0], mode,
2006 plus_constant (to, off + i * GET_MODE_SIZE (mode))),
2007 gen_rtx_REG (mode, regno + i));
2010 (define_insn "*store_multiple_di"
2011 [(match_parallel 0 "store_multiple_operation"
2012 [(set (match_operand:DI 1 "s_operand" "=QS")
2013 (match_operand:DI 2 "register_operand" "r"))])]
2014 "reload_completed && word_mode == DImode"
2016 int words = XVECLEN (operands[0], 0);
2017 operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
2018 return "stmg\t%2,%0,%S1";
2020 [(set_attr "op_type" "RSY")
2021 (set_attr "type" "stm")])
2024 (define_insn "*store_multiple_si"
2025 [(match_parallel 0 "store_multiple_operation"
2026 [(set (match_operand:SI 1 "s_operand" "=Q,S")
2027 (match_operand:SI 2 "register_operand" "r,r"))])]
2030 int words = XVECLEN (operands[0], 0);
2031 operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
2032 return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
2034 [(set_attr "op_type" "RS,RSY")
2035 (set_attr "type" "stm")])
2038 ;; String instructions.
2041 (define_insn "*execute"
2042 [(match_parallel 0 ""
2043 [(unspec [(match_operand 1 "register_operand" "a")
2044 (match_operand:BLK 2 "memory_operand" "R")
2045 (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
2046 "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2047 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2049 [(set_attr "op_type" "RX")
2050 (set_attr "type" "cs")])
2054 ; strlenM instruction pattern(s).
2057 (define_expand "strlen<mode>"
2058 [(set (reg:SI 0) (match_operand:SI 2 "immediate_operand" ""))
2061 (unspec:P [(const_int 0)
2062 (match_operand:BLK 1 "memory_operand" "")
2064 (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
2065 (clobber (scratch:P))
2066 (clobber (reg:CC CC_REGNUM))])
2068 [(set (match_operand:P 0 "register_operand" "")
2069 (minus:P (match_dup 4) (match_dup 5)))
2070 (clobber (reg:CC CC_REGNUM))])]
2073 operands[4] = gen_reg_rtx (Pmode);
2074 operands[5] = gen_reg_rtx (Pmode);
2075 emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
2076 operands[1] = replace_equiv_address (operands[1], operands[5]);
2079 (define_insn "*strlen<mode>"
2080 [(set (match_operand:P 0 "register_operand" "=a")
2081 (unspec:P [(match_operand:P 2 "general_operand" "0")
2082 (mem:BLK (match_operand:P 3 "register_operand" "1"))
2084 (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
2085 (clobber (match_scratch:P 1 "=a"))
2086 (clobber (reg:CC CC_REGNUM))]
2088 "srst\t%0,%1\;jo\t.-4"
2089 [(set_attr "length" "8")
2090 (set_attr "type" "vs")])
2093 ; cmpstrM instruction pattern(s).
2096 (define_expand "cmpstrsi"
2097 [(set (reg:SI 0) (const_int 0))
2099 [(clobber (match_operand 3 "" ""))
2100 (clobber (match_dup 4))
2101 (set (reg:CCU CC_REGNUM)
2102 (compare:CCU (match_operand:BLK 1 "memory_operand" "")
2103 (match_operand:BLK 2 "memory_operand" "")))
2106 [(set (match_operand:SI 0 "register_operand" "=d")
2107 (unspec:SI [(reg:CCU CC_REGNUM)] UNSPEC_CCU_TO_INT))
2108 (clobber (reg:CC CC_REGNUM))])]
2111 /* As the result of CMPINT is inverted compared to what we need,
2112 we have to swap the operands. */
2113 rtx op1 = operands[2];
2114 rtx op2 = operands[1];
2115 rtx addr1 = gen_reg_rtx (Pmode);
2116 rtx addr2 = gen_reg_rtx (Pmode);
2118 emit_move_insn (addr1, force_operand (XEXP (op1, 0), NULL_RTX));
2119 emit_move_insn (addr2, force_operand (XEXP (op2, 0), NULL_RTX));
2120 operands[1] = replace_equiv_address_nv (op1, addr1);
2121 operands[2] = replace_equiv_address_nv (op2, addr2);
2122 operands[3] = addr1;
2123 operands[4] = addr2;
2126 (define_insn "*cmpstr<mode>"
2127 [(clobber (match_operand:P 0 "register_operand" "=d"))
2128 (clobber (match_operand:P 1 "register_operand" "=d"))
2129 (set (reg:CCU CC_REGNUM)
2130 (compare:CCU (mem:BLK (match_operand:P 2 "register_operand" "0"))
2131 (mem:BLK (match_operand:P 3 "register_operand" "1"))))
2134 "clst\t%0,%1\;jo\t.-4"
2135 [(set_attr "length" "8")
2136 (set_attr "type" "vs")])
2139 ; movstr instruction pattern.
2142 (define_expand "movstr"
2143 [(set (reg:SI 0) (const_int 0))
2145 [(clobber (match_dup 3))
2146 (set (match_operand:BLK 1 "memory_operand" "")
2147 (match_operand:BLK 2 "memory_operand" ""))
2148 (set (match_operand 0 "register_operand" "")
2149 (unspec [(match_dup 1)
2151 (reg:SI 0)] UNSPEC_MVST))
2152 (clobber (reg:CC CC_REGNUM))])]
2155 rtx addr1 = gen_reg_rtx (Pmode);
2156 rtx addr2 = gen_reg_rtx (Pmode);
2158 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2159 emit_move_insn (addr2, force_operand (XEXP (operands[2], 0), NULL_RTX));
2160 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2161 operands[2] = replace_equiv_address_nv (operands[2], addr2);
2162 operands[3] = addr2;
2165 (define_insn "*movstr"
2166 [(clobber (match_operand:P 2 "register_operand" "=d"))
2167 (set (mem:BLK (match_operand:P 1 "register_operand" "0"))
2168 (mem:BLK (match_operand:P 3 "register_operand" "2")))
2169 (set (match_operand:P 0 "register_operand" "=d")
2170 (unspec [(mem:BLK (match_dup 1))
2171 (mem:BLK (match_dup 3))
2172 (reg:SI 0)] UNSPEC_MVST))
2173 (clobber (reg:CC CC_REGNUM))]
2175 "mvst\t%1,%2\;jo\t.-4"
2176 [(set_attr "length" "8")
2177 (set_attr "type" "vs")])
2181 ; movmemM instruction pattern(s).
2184 (define_expand "movmem<mode>"
2185 [(set (match_operand:BLK 0 "memory_operand" "")
2186 (match_operand:BLK 1 "memory_operand" ""))
2187 (use (match_operand:GPR 2 "general_operand" ""))
2188 (match_operand 3 "" "")]
2190 "s390_expand_movmem (operands[0], operands[1], operands[2]); DONE;")
2192 ; Move a block that is up to 256 bytes in length.
2193 ; The block length is taken as (operands[2] % 256) + 1.
2195 (define_expand "movmem_short"
2197 [(set (match_operand:BLK 0 "memory_operand" "")
2198 (match_operand:BLK 1 "memory_operand" ""))
2199 (use (match_operand 2 "nonmemory_operand" ""))
2200 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2201 (clobber (match_dup 3))])]
2203 "operands[3] = gen_rtx_SCRATCH (Pmode);")
2205 (define_insn "*movmem_short"
2206 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q")
2207 (match_operand:BLK 1 "memory_operand" "Q,Q,Q"))
2208 (use (match_operand 2 "nonmemory_operand" "n,a,a"))
2209 (use (match_operand 3 "immediate_operand" "X,R,X"))
2210 (clobber (match_scratch 4 "=X,X,&a"))]
2211 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2212 && GET_MODE (operands[4]) == Pmode"
2214 [(set_attr "type" "cs")])
2217 [(set (match_operand:BLK 0 "memory_operand" "")
2218 (match_operand:BLK 1 "memory_operand" ""))
2219 (use (match_operand 2 "const_int_operand" ""))
2220 (use (match_operand 3 "immediate_operand" ""))
2221 (clobber (scratch))]
2224 [(set (match_dup 0) (match_dup 1))
2225 (use (match_dup 2))])]
2226 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 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 (match_operand 3 "memory_operand" ""))
2233 (clobber (scratch))]
2236 [(unspec [(match_dup 2) (match_dup 3)
2237 (const_int 0)] UNSPEC_EXECUTE)
2238 (set (match_dup 0) (match_dup 1))
2239 (use (const_int 1))])]
2243 [(set (match_operand:BLK 0 "memory_operand" "")
2244 (match_operand:BLK 1 "memory_operand" ""))
2245 (use (match_operand 2 "register_operand" ""))
2246 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2247 (clobber (match_operand 3 "register_operand" ""))]
2248 "reload_completed && TARGET_CPU_ZARCH"
2249 [(set (match_dup 3) (label_ref (match_dup 4)))
2251 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
2252 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2253 (set (match_dup 0) (match_dup 1))
2254 (use (const_int 1))])]
2255 "operands[4] = gen_label_rtx ();")
2257 ; Move a block of arbitrary length.
2259 (define_expand "movmem_long"
2261 [(clobber (match_dup 2))
2262 (clobber (match_dup 3))
2263 (set (match_operand:BLK 0 "memory_operand" "")
2264 (match_operand:BLK 1 "memory_operand" ""))
2265 (use (match_operand 2 "general_operand" ""))
2267 (clobber (reg:CC CC_REGNUM))])]
2270 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2271 rtx reg0 = gen_reg_rtx (dword_mode);
2272 rtx reg1 = gen_reg_rtx (dword_mode);
2273 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2274 rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
2275 rtx len0 = gen_lowpart (Pmode, reg0);
2276 rtx len1 = gen_lowpart (Pmode, reg1);
2278 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2279 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2280 emit_move_insn (len0, operands[2]);
2282 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
2283 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2284 emit_move_insn (len1, operands[2]);
2286 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2287 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2292 (define_insn "*movmem_long"
2293 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2294 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
2295 (set (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
2296 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0)))
2299 (clobber (reg:CC CC_REGNUM))]
2301 "mvcle\t%0,%1,0\;jo\t.-4"
2302 [(set_attr "length" "8")
2303 (set_attr "type" "vs")])
2310 (define_expand "signbit<mode>2"
2311 [(set (reg:CCZ CC_REGNUM)
2312 (unspec:CCZ [(match_operand:BFP 1 "register_operand" "f")
2315 (set (match_operand:SI 0 "register_operand" "=d")
2316 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CCZ_TO_INT))]
2319 operands[2] = GEN_INT (S390_TDC_SIGNBIT_SET);
2322 (define_expand "isinf<mode>2"
2323 [(set (reg:CCZ CC_REGNUM)
2324 (unspec:CCZ [(match_operand:BFP 1 "register_operand" "f")
2327 (set (match_operand:SI 0 "register_operand" "=d")
2328 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CCZ_TO_INT))]
2331 operands[2] = GEN_INT (S390_TDC_INFINITY);
2334 ; This insn is used to generate all variants of the Test Data Class
2335 ; instruction, namely tcxb, tcdb, and tceb. The insn's first operand
2336 ; is the register to be tested and the second one is the bit mask
2337 ; specifying the required test(s).
2339 (define_insn "*TDC_insn_<mode>"
2340 [(set (reg:CCZ CC_REGNUM)
2341 (unspec:CCZ [(match_operand:BFP 0 "register_operand" "f")
2342 (match_operand:SI 1 "const_int_operand")] UNSPEC_TDC_INSN))]
2345 [(set_attr "op_type" "RXE")
2346 (set_attr "type" "fsimp<mode>")])
2348 (define_insn_and_split "*ccz_to_int"
2349 [(set (match_operand:SI 0 "register_operand" "=d")
2350 (unspec:SI [(match_operand:CCZ 1 "register_operand" "0")]
2351 UNSPEC_CCZ_TO_INT))]
2355 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 28)))])
2359 ; setmemM instruction pattern(s).
2362 (define_expand "setmem<mode>"
2363 [(set (match_operand:BLK 0 "memory_operand" "")
2364 (match_operand:QI 2 "general_operand" ""))
2365 (use (match_operand:GPR 1 "general_operand" ""))
2366 (match_operand 3 "" "")]
2368 "s390_expand_setmem (operands[0], operands[1], operands[2]); DONE;")
2370 ; Clear a block that is up to 256 bytes in length.
2371 ; The block length is taken as (operands[1] % 256) + 1.
2373 (define_expand "clrmem_short"
2375 [(set (match_operand:BLK 0 "memory_operand" "")
2377 (use (match_operand 1 "nonmemory_operand" ""))
2378 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2379 (clobber (match_dup 2))
2380 (clobber (reg:CC CC_REGNUM))])]
2382 "operands[2] = gen_rtx_SCRATCH (Pmode);")
2384 (define_insn "*clrmem_short"
2385 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q")
2387 (use (match_operand 1 "nonmemory_operand" "n,a,a"))
2388 (use (match_operand 2 "immediate_operand" "X,R,X"))
2389 (clobber (match_scratch 3 "=X,X,&a"))
2390 (clobber (reg:CC CC_REGNUM))]
2391 "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)
2392 && GET_MODE (operands[3]) == Pmode"
2394 [(set_attr "type" "cs")])
2397 [(set (match_operand:BLK 0 "memory_operand" "")
2399 (use (match_operand 1 "const_int_operand" ""))
2400 (use (match_operand 2 "immediate_operand" ""))
2402 (clobber (reg:CC CC_REGNUM))]
2405 [(set (match_dup 0) (const_int 0))
2407 (clobber (reg:CC CC_REGNUM))])]
2408 "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
2411 [(set (match_operand:BLK 0 "memory_operand" "")
2413 (use (match_operand 1 "register_operand" ""))
2414 (use (match_operand 2 "memory_operand" ""))
2416 (clobber (reg:CC CC_REGNUM))]
2419 [(unspec [(match_dup 1) (match_dup 2)
2420 (const_int 0)] UNSPEC_EXECUTE)
2421 (set (match_dup 0) (const_int 0))
2423 (clobber (reg:CC CC_REGNUM))])]
2427 [(set (match_operand:BLK 0 "memory_operand" "")
2429 (use (match_operand 1 "register_operand" ""))
2430 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2431 (clobber (match_operand 2 "register_operand" ""))
2432 (clobber (reg:CC CC_REGNUM))]
2433 "reload_completed && TARGET_CPU_ZARCH"
2434 [(set (match_dup 2) (label_ref (match_dup 3)))
2436 [(unspec [(match_dup 1) (mem:BLK (match_dup 2))
2437 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2438 (set (match_dup 0) (const_int 0))
2440 (clobber (reg:CC CC_REGNUM))])]
2441 "operands[3] = gen_label_rtx ();")
2443 ; Initialize a block of arbitrary length with (operands[2] % 256).
2445 (define_expand "setmem_long"
2447 [(clobber (match_dup 1))
2448 (set (match_operand:BLK 0 "memory_operand" "")
2449 (match_operand 2 "shift_count_or_setmem_operand" ""))
2450 (use (match_operand 1 "general_operand" ""))
2452 (clobber (reg:CC CC_REGNUM))])]
2455 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2456 rtx reg0 = gen_reg_rtx (dword_mode);
2457 rtx reg1 = gen_reg_rtx (dword_mode);
2458 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2459 rtx len0 = gen_lowpart (Pmode, reg0);
2461 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2462 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2463 emit_move_insn (len0, operands[1]);
2465 emit_move_insn (reg1, const0_rtx);
2467 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2472 (define_insn "*setmem_long"
2473 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2474 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
2475 (match_operand 2 "shift_count_or_setmem_operand" "Y"))
2477 (use (match_operand:<DBL> 1 "register_operand" "d"))
2478 (clobber (reg:CC CC_REGNUM))]
2480 "mvcle\t%0,%1,%Y2\;jo\t.-4"
2481 [(set_attr "length" "8")
2482 (set_attr "type" "vs")])
2484 (define_insn "*setmem_long_and"
2485 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2486 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
2487 (and (match_operand 2 "shift_count_or_setmem_operand" "Y")
2488 (match_operand 4 "const_int_operand" "n")))
2490 (use (match_operand:<DBL> 1 "register_operand" "d"))
2491 (clobber (reg:CC CC_REGNUM))]
2492 "(INTVAL (operands[4]) & 255) == 255"
2493 "mvcle\t%0,%1,%Y2\;jo\t.-4"
2494 [(set_attr "length" "8")
2495 (set_attr "type" "vs")])
2497 ; cmpmemM instruction pattern(s).
2500 (define_expand "cmpmemsi"
2501 [(set (match_operand:SI 0 "register_operand" "")
2502 (compare:SI (match_operand:BLK 1 "memory_operand" "")
2503 (match_operand:BLK 2 "memory_operand" "") ) )
2504 (use (match_operand:SI 3 "general_operand" ""))
2505 (use (match_operand:SI 4 "" ""))]
2507 "s390_expand_cmpmem (operands[0], operands[1],
2508 operands[2], operands[3]); DONE;")
2510 ; Compare a block that is up to 256 bytes in length.
2511 ; The block length is taken as (operands[2] % 256) + 1.
2513 (define_expand "cmpmem_short"
2515 [(set (reg:CCU CC_REGNUM)
2516 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2517 (match_operand:BLK 1 "memory_operand" "")))
2518 (use (match_operand 2 "nonmemory_operand" ""))
2519 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2520 (clobber (match_dup 3))])]
2522 "operands[3] = gen_rtx_SCRATCH (Pmode);")
2524 (define_insn "*cmpmem_short"
2525 [(set (reg:CCU CC_REGNUM)
2526 (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q")
2527 (match_operand:BLK 1 "memory_operand" "Q,Q,Q")))
2528 (use (match_operand 2 "nonmemory_operand" "n,a,a"))
2529 (use (match_operand 3 "immediate_operand" "X,R,X"))
2530 (clobber (match_scratch 4 "=X,X,&a"))]
2531 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2532 && GET_MODE (operands[4]) == Pmode"
2534 [(set_attr "type" "cs")])
2537 [(set (reg:CCU CC_REGNUM)
2538 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2539 (match_operand:BLK 1 "memory_operand" "")))
2540 (use (match_operand 2 "const_int_operand" ""))
2541 (use (match_operand 3 "immediate_operand" ""))
2542 (clobber (scratch))]
2545 [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2546 (use (match_dup 2))])]
2547 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2550 [(set (reg:CCU CC_REGNUM)
2551 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2552 (match_operand:BLK 1 "memory_operand" "")))
2553 (use (match_operand 2 "register_operand" ""))
2554 (use (match_operand 3 "memory_operand" ""))
2555 (clobber (scratch))]
2558 [(unspec [(match_dup 2) (match_dup 3)
2559 (const_int 0)] UNSPEC_EXECUTE)
2560 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2561 (use (const_int 1))])]
2565 [(set (reg:CCU CC_REGNUM)
2566 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2567 (match_operand:BLK 1 "memory_operand" "")))
2568 (use (match_operand 2 "register_operand" ""))
2569 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2570 (clobber (match_operand 3 "register_operand" ""))]
2571 "reload_completed && TARGET_CPU_ZARCH"
2572 [(set (match_dup 3) (label_ref (match_dup 4)))
2574 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
2575 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2576 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2577 (use (const_int 1))])]
2578 "operands[4] = gen_label_rtx ();")
2580 ; Compare a block of arbitrary length.
2582 (define_expand "cmpmem_long"
2584 [(clobber (match_dup 2))
2585 (clobber (match_dup 3))
2586 (set (reg:CCU CC_REGNUM)
2587 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2588 (match_operand:BLK 1 "memory_operand" "")))
2589 (use (match_operand 2 "general_operand" ""))
2590 (use (match_dup 3))])]
2593 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2594 rtx reg0 = gen_reg_rtx (dword_mode);
2595 rtx reg1 = gen_reg_rtx (dword_mode);
2596 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2597 rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
2598 rtx len0 = gen_lowpart (Pmode, reg0);
2599 rtx len1 = gen_lowpart (Pmode, reg1);
2601 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2602 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2603 emit_move_insn (len0, operands[2]);
2605 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
2606 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2607 emit_move_insn (len1, operands[2]);
2609 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2610 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2615 (define_insn "*cmpmem_long"
2616 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2617 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
2618 (set (reg:CCU CC_REGNUM)
2619 (compare:CCU (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
2620 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0))))
2622 (use (match_dup 3))]
2624 "clcle\t%0,%1,0\;jo\t.-4"
2625 [(set_attr "length" "8")
2626 (set_attr "type" "vs")])
2628 ; Convert CCUmode condition code to integer.
2629 ; Result is zero if EQ, positive if LTU, negative if GTU.
2631 (define_insn_and_split "cmpint"
2632 [(set (match_operand:SI 0 "register_operand" "=d")
2633 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2635 (clobber (reg:CC CC_REGNUM))]
2639 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
2641 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
2642 (clobber (reg:CC CC_REGNUM))])])
2644 (define_insn_and_split "*cmpint_cc"
2645 [(set (reg CC_REGNUM)
2646 (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2649 (set (match_operand:SI 0 "register_operand" "=d")
2650 (unspec:SI [(match_dup 1)] UNSPEC_CCU_TO_INT))]
2651 "s390_match_ccmode (insn, CCSmode)"
2653 "&& reload_completed"
2654 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
2656 [(set (match_dup 2) (match_dup 3))
2657 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
2659 rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
2660 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
2661 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
2664 (define_insn_and_split "*cmpint_sign"
2665 [(set (match_operand:DI 0 "register_operand" "=d")
2666 (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2667 UNSPEC_CCU_TO_INT)))
2668 (clobber (reg:CC CC_REGNUM))]
2671 "&& reload_completed"
2672 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
2674 [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
2675 (clobber (reg:CC CC_REGNUM))])])
2677 (define_insn_and_split "*cmpint_sign_cc"
2678 [(set (reg CC_REGNUM)
2679 (compare (ashiftrt:DI (ashift:DI (subreg:DI
2680 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2681 UNSPEC_CCU_TO_INT) 0)
2682 (const_int 32)) (const_int 32))
2684 (set (match_operand:DI 0 "register_operand" "=d")
2685 (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_CCU_TO_INT)))]
2686 "s390_match_ccmode (insn, CCSmode) && TARGET_64BIT"
2688 "&& reload_completed"
2689 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
2691 [(set (match_dup 2) (match_dup 3))
2692 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
2694 rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
2695 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
2696 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
2701 ;;- Conversion instructions.
2704 (define_insn "*sethighpartsi"
2705 [(set (match_operand:SI 0 "register_operand" "=d,d")
2706 (unspec:SI [(match_operand:BLK 1 "s_operand" "Q,S")
2707 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
2708 (clobber (reg:CC CC_REGNUM))]
2713 [(set_attr "op_type" "RS,RSY")])
2715 (define_insn "*sethighpartdi_64"
2716 [(set (match_operand:DI 0 "register_operand" "=d")
2717 (unspec:DI [(match_operand:BLK 1 "s_operand" "QS")
2718 (match_operand 2 "const_int_operand" "n")] UNSPEC_ICM))
2719 (clobber (reg:CC CC_REGNUM))]
2722 [(set_attr "op_type" "RSY")])
2724 (define_insn "*sethighpartdi_31"
2725 [(set (match_operand:DI 0 "register_operand" "=d,d")
2726 (unspec:DI [(match_operand:BLK 1 "s_operand" "Q,S")
2727 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
2728 (clobber (reg:CC CC_REGNUM))]
2733 [(set_attr "op_type" "RS,RSY")])
2735 (define_insn_and_split "*extzv<mode>"
2736 [(set (match_operand:GPR 0 "register_operand" "=d")
2737 (zero_extract:GPR (match_operand:QI 1 "s_operand" "QS")
2738 (match_operand 2 "const_int_operand" "n")
2740 (clobber (reg:CC CC_REGNUM))]
2741 "INTVAL (operands[2]) > 0
2742 && INTVAL (operands[2]) <= GET_MODE_BITSIZE (SImode)"
2744 "&& reload_completed"
2746 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
2747 (clobber (reg:CC CC_REGNUM))])
2748 (set (match_dup 0) (lshiftrt:GPR (match_dup 0) (match_dup 2)))]
2750 int bitsize = INTVAL (operands[2]);
2751 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
2752 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
2754 operands[1] = adjust_address (operands[1], BLKmode, 0);
2755 set_mem_size (operands[1], GEN_INT (size));
2756 operands[2] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - bitsize);
2757 operands[3] = GEN_INT (mask);
2760 (define_insn_and_split "*extv<mode>"
2761 [(set (match_operand:GPR 0 "register_operand" "=d")
2762 (sign_extract:GPR (match_operand:QI 1 "s_operand" "QS")
2763 (match_operand 2 "const_int_operand" "n")
2765 (clobber (reg:CC CC_REGNUM))]
2766 "INTVAL (operands[2]) > 0
2767 && INTVAL (operands[2]) <= GET_MODE_BITSIZE (SImode)"
2769 "&& reload_completed"
2771 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
2772 (clobber (reg:CC CC_REGNUM))])
2774 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
2775 (clobber (reg:CC CC_REGNUM))])]
2777 int bitsize = INTVAL (operands[2]);
2778 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
2779 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
2781 operands[1] = adjust_address (operands[1], BLKmode, 0);
2782 set_mem_size (operands[1], GEN_INT (size));
2783 operands[2] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - bitsize);
2784 operands[3] = GEN_INT (mask);
2788 ; insv instruction patterns
2791 (define_expand "insv"
2792 [(set (zero_extract (match_operand 0 "nonimmediate_operand" "")
2793 (match_operand 1 "const_int_operand" "")
2794 (match_operand 2 "const_int_operand" ""))
2795 (match_operand 3 "general_operand" ""))]
2798 if (s390_expand_insv (operands[0], operands[1], operands[2], operands[3]))
2803 (define_insn "*insv<mode>_mem_reg"
2804 [(set (zero_extract:P (match_operand:QI 0 "memory_operand" "+Q,S")
2805 (match_operand 1 "const_int_operand" "n,n")
2807 (match_operand:P 2 "register_operand" "d,d"))]
2808 "INTVAL (operands[1]) > 0
2809 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
2810 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
2812 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
2814 operands[1] = GEN_INT ((1ul << size) - 1);
2815 return (which_alternative == 0) ? "stcm\t%2,%1,%S0"
2816 : "stcmy\t%2,%1,%S0";
2818 [(set_attr "op_type" "RS,RSY")])
2820 (define_insn "*insvdi_mem_reghigh"
2821 [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "+QS")
2822 (match_operand 1 "const_int_operand" "n")
2824 (lshiftrt:DI (match_operand:DI 2 "register_operand" "d")
2827 && INTVAL (operands[1]) > 0
2828 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
2829 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
2831 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
2833 operands[1] = GEN_INT ((1ul << size) - 1);
2834 return "stcmh\t%2,%1,%S0";
2836 [(set_attr "op_type" "RSY")])
2838 (define_insn "*insv<mode>_reg_imm"
2839 [(set (zero_extract:P (match_operand:P 0 "register_operand" "+d")
2841 (match_operand 1 "const_int_operand" "n"))
2842 (match_operand:P 2 "const_int_operand" "n"))]
2844 && INTVAL (operands[1]) >= 0
2845 && INTVAL (operands[1]) < BITS_PER_WORD
2846 && INTVAL (operands[1]) % 16 == 0"
2848 switch (BITS_PER_WORD - INTVAL (operands[1]))
2850 case 64: return "iihh\t%0,%x2"; break;
2851 case 48: return "iihl\t%0,%x2"; break;
2852 case 32: return "iilh\t%0,%x2"; break;
2853 case 16: return "iill\t%0,%x2"; break;
2854 default: gcc_unreachable();
2857 [(set_attr "op_type" "RI")])
2859 (define_insn "*insv<mode>_reg_extimm"
2860 [(set (zero_extract:P (match_operand:P 0 "register_operand" "+d")
2862 (match_operand 1 "const_int_operand" "n"))
2863 (match_operand:P 2 "const_int_operand" "n"))]
2865 && INTVAL (operands[1]) >= 0
2866 && INTVAL (operands[1]) < BITS_PER_WORD
2867 && INTVAL (operands[1]) % 32 == 0"
2869 switch (BITS_PER_WORD - INTVAL (operands[1]))
2871 case 64: return "iihf\t%0,%o2"; break;
2872 case 32: return "iilf\t%0,%o2"; break;
2873 default: gcc_unreachable();
2876 [(set_attr "op_type" "RIL")])
2879 ; extendsidi2 instruction pattern(s).
2882 (define_expand "extendsidi2"
2883 [(set (match_operand:DI 0 "register_operand" "")
2884 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
2889 emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
2890 emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
2891 emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
2892 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
2897 (define_insn "*extendsidi2"
2898 [(set (match_operand:DI 0 "register_operand" "=d,d")
2899 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
2904 [(set_attr "op_type" "RRE,RXY")])
2907 ; extend(hi|qi)(si|di)2 instruction pattern(s).
2910 (define_expand "extend<HQI:mode><DSI:mode>2"
2911 [(set (match_operand:DSI 0 "register_operand" "")
2912 (sign_extend:DSI (match_operand:HQI 1 "nonimmediate_operand" "")))]
2915 if (<DSI:MODE>mode == DImode && !TARGET_64BIT)
2917 rtx tmp = gen_reg_rtx (SImode);
2918 emit_insn (gen_extend<HQI:mode>si2 (tmp, operands[1]));
2919 emit_insn (gen_extendsidi2 (operands[0], tmp));
2922 else if (!TARGET_EXTIMM)
2924 rtx bitcount = GEN_INT (GET_MODE_BITSIZE (<DSI:MODE>mode) -
2925 GET_MODE_BITSIZE (<HQI:MODE>mode));
2927 operands[1] = gen_lowpart (<DSI:MODE>mode, operands[1]);
2928 emit_insn (gen_ashl<DSI:mode>3 (operands[0], operands[1], bitcount));
2929 emit_insn (gen_ashr<DSI:mode>3 (operands[0], operands[0], bitcount));
2935 ; extendhidi2 instruction pattern(s).
2938 (define_insn "*extendhidi2_extimm"
2939 [(set (match_operand:DI 0 "register_operand" "=d,d")
2940 (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand" "d,m")))]
2941 "TARGET_64BIT && TARGET_EXTIMM"
2945 [(set_attr "op_type" "RRE,RXY")])
2947 (define_insn "*extendhidi2"
2948 [(set (match_operand:DI 0 "register_operand" "=d")
2949 (sign_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
2952 [(set_attr "op_type" "RXY")])
2955 ; extendhisi2 instruction pattern(s).
2958 (define_insn "*extendhisi2_extimm"
2959 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
2960 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "d,R,T")))]
2966 [(set_attr "op_type" "RRE,RX,RXY")])
2968 (define_insn "*extendhisi2"
2969 [(set (match_operand:SI 0 "register_operand" "=d,d")
2970 (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
2975 [(set_attr "op_type" "RX,RXY")])
2978 ; extendqi(si|di)2 instruction pattern(s).
2981 ; lbr, lgbr, lb, lgb
2982 (define_insn "*extendqi<mode>2_extimm"
2983 [(set (match_operand:GPR 0 "register_operand" "=d,d")
2984 (sign_extend:GPR (match_operand:QI 1 "nonimmediate_operand" "d,m")))]
2989 [(set_attr "op_type" "RRE,RXY")])
2992 (define_insn "*extendqi<mode>2"
2993 [(set (match_operand:GPR 0 "register_operand" "=d")
2994 (sign_extend:GPR (match_operand:QI 1 "memory_operand" "m")))]
2995 "!TARGET_EXTIMM && TARGET_LONG_DISPLACEMENT"
2997 [(set_attr "op_type" "RXY")])
2999 (define_insn_and_split "*extendqi<mode>2_short_displ"
3000 [(set (match_operand:GPR 0 "register_operand" "=d")
3001 (sign_extend:GPR (match_operand:QI 1 "s_operand" "Q")))
3002 (clobber (reg:CC CC_REGNUM))]
3003 "!TARGET_EXTIMM && !TARGET_LONG_DISPLACEMENT"
3005 "&& reload_completed"
3007 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (const_int 8)] UNSPEC_ICM))
3008 (clobber (reg:CC CC_REGNUM))])
3010 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3011 (clobber (reg:CC CC_REGNUM))])]
3013 operands[1] = adjust_address (operands[1], BLKmode, 0);
3014 set_mem_size (operands[1], GEN_INT (GET_MODE_SIZE (QImode)));
3015 operands[2] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode)
3016 - GET_MODE_BITSIZE (QImode));
3020 ; zero_extendsidi2 instruction pattern(s).
3023 (define_expand "zero_extendsidi2"
3024 [(set (match_operand:DI 0 "register_operand" "")
3025 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3030 emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
3031 emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
3032 emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
3037 (define_insn "*zero_extendsidi2"
3038 [(set (match_operand:DI 0 "register_operand" "=d,d")
3039 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
3044 [(set_attr "op_type" "RRE,RXY")])
3047 ; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
3050 (define_insn "*llgt_sidi"
3051 [(set (match_operand:DI 0 "register_operand" "=d")
3052 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0)
3053 (const_int 2147483647)))]
3056 [(set_attr "op_type" "RXE")])
3058 (define_insn_and_split "*llgt_sidi_split"
3059 [(set (match_operand:DI 0 "register_operand" "=d")
3060 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0)
3061 (const_int 2147483647)))
3062 (clobber (reg:CC CC_REGNUM))]
3065 "&& reload_completed"
3067 (and:DI (subreg:DI (match_dup 1) 0)
3068 (const_int 2147483647)))]
3071 (define_insn "*llgt_sisi"
3072 [(set (match_operand:SI 0 "register_operand" "=d,d")
3073 (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,m")
3074 (const_int 2147483647)))]
3079 [(set_attr "op_type" "RRE,RXE")])
3081 (define_insn "*llgt_didi"
3082 [(set (match_operand:DI 0 "register_operand" "=d,d")
3083 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
3084 (const_int 2147483647)))]
3089 [(set_attr "op_type" "RRE,RXE")])
3092 [(set (match_operand:GPR 0 "register_operand" "")
3093 (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
3094 (const_int 2147483647)))
3095 (clobber (reg:CC CC_REGNUM))]
3096 "TARGET_ZARCH && reload_completed"
3098 (and:GPR (match_dup 1)
3099 (const_int 2147483647)))]
3103 ; zero_extend(hi|qi)(si|di)2 instruction pattern(s).
3106 (define_expand "zero_extend<mode>di2"
3107 [(set (match_operand:DI 0 "register_operand" "")
3108 (zero_extend:DI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3113 rtx tmp = gen_reg_rtx (SImode);
3114 emit_insn (gen_zero_extend<mode>si2 (tmp, operands[1]));
3115 emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
3118 else if (!TARGET_EXTIMM)
3120 rtx bitcount = GEN_INT (GET_MODE_BITSIZE(DImode) -
3121 GET_MODE_BITSIZE(<MODE>mode));
3122 operands[1] = gen_lowpart (DImode, operands[1]);
3123 emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
3124 emit_insn (gen_lshrdi3 (operands[0], operands[0], bitcount));
3129 (define_expand "zero_extend<mode>si2"
3130 [(set (match_operand:SI 0 "register_operand" "")
3131 (zero_extend:SI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3136 operands[1] = gen_lowpart (SImode, operands[1]);
3137 emit_insn (gen_andsi3 (operands[0], operands[1],
3138 GEN_INT ((1 << GET_MODE_BITSIZE(<MODE>mode)) - 1)));
3143 ; llhr, llcr, llghr, llgcr, llh, llc, llgh, llgc
3144 (define_insn "*zero_extend<HQI:mode><GPR:mode>2_extimm"
3145 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3146 (zero_extend:GPR (match_operand:HQI 1 "nonimmediate_operand" "d,m")))]
3151 [(set_attr "op_type" "RRE,RXY")])
3154 (define_insn "*zero_extend<HQI:mode><GPR:mode>2"
3155 [(set (match_operand:GPR 0 "register_operand" "=d")
3156 (zero_extend:GPR (match_operand:HQI 1 "memory_operand" "m")))]
3157 "TARGET_ZARCH && !TARGET_EXTIMM"
3159 [(set_attr "op_type" "RXY")])
3161 (define_insn_and_split "*zero_extendhisi2_31"
3162 [(set (match_operand:SI 0 "register_operand" "=&d")
3163 (zero_extend:SI (match_operand:HI 1 "s_operand" "QS")))
3164 (clobber (reg:CC CC_REGNUM))]
3167 "&& reload_completed"
3168 [(set (match_dup 0) (const_int 0))
3170 [(set (strict_low_part (match_dup 2)) (match_dup 1))
3171 (clobber (reg:CC CC_REGNUM))])]
3172 "operands[2] = gen_lowpart (HImode, operands[0]);")
3174 (define_insn_and_split "*zero_extendqisi2_31"
3175 [(set (match_operand:SI 0 "register_operand" "=&d")
3176 (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
3179 "&& reload_completed"
3180 [(set (match_dup 0) (const_int 0))
3181 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3182 "operands[2] = gen_lowpart (QImode, operands[0]);")
3185 ; zero_extendqihi2 instruction pattern(s).
3188 (define_expand "zero_extendqihi2"
3189 [(set (match_operand:HI 0 "register_operand" "")
3190 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
3191 "TARGET_ZARCH && !TARGET_EXTIMM"
3193 operands[1] = gen_lowpart (HImode, operands[1]);
3194 emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
3198 (define_insn "*zero_extendqihi2_64"
3199 [(set (match_operand:HI 0 "register_operand" "=d")
3200 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
3201 "TARGET_ZARCH && !TARGET_EXTIMM"
3203 [(set_attr "op_type" "RXY")])
3205 (define_insn_and_split "*zero_extendqihi2_31"
3206 [(set (match_operand:HI 0 "register_operand" "=&d")
3207 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
3210 "&& reload_completed"
3211 [(set (match_dup 0) (const_int 0))
3212 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3213 "operands[2] = gen_lowpart (QImode, operands[0]);")
3216 ; fixuns_trunc(dd|td)di2 instruction pattern(s).
3219 (define_expand "fixuns_truncdddi2"
3221 [(set (match_operand:DI 0 "register_operand" "")
3222 (unsigned_fix:DI (match_operand:DD 1 "register_operand" "")))
3223 (clobber (match_scratch:TD 2 "=f"))])]
3225 "TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3227 rtx label1 = gen_label_rtx ();
3228 rtx label2 = gen_label_rtx ();
3229 rtx temp = gen_reg_rtx (TDmode);
3230 REAL_VALUE_TYPE cmp, sub;
3232 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
3233 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
3235 /* 2^63 can't be represented as 64bit DFP number with full precision. The
3236 solution is doing the check and the subtraction in TD mode and using a
3237 TD -> DI convert afterwards. */
3238 emit_insn (gen_extendddtd2 (temp, operands[1]));
3239 temp = force_reg (TDmode, temp);
3240 emit_insn (gen_cmptd (temp,
3241 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode)));
3242 emit_jump_insn (gen_blt (label1));
3243 emit_insn (gen_subtd3 (temp, temp,
3244 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
3245 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
3248 emit_label (label1);
3249 emit_insn (gen_fix_truncdddi2_dfp (operands[0], operands[1], GEN_INT (9)));
3250 emit_label (label2);
3254 (define_expand "fixuns_trunctddi2"
3255 [(set (match_operand:DI 0 "register_operand" "")
3256 (unsigned_fix:DI (match_operand:TD 1 "register_operand" "")))]
3257 "TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3259 rtx label1 = gen_label_rtx ();
3260 rtx label2 = gen_label_rtx ();
3261 rtx temp = gen_reg_rtx (TDmode);
3262 REAL_VALUE_TYPE cmp, sub;
3264 operands[1] = force_reg (TDmode, operands[1]);
3265 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
3266 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
3268 emit_insn (gen_cmptd (operands[1],
3269 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode)));
3270 emit_jump_insn (gen_blt (label1));
3271 emit_insn (gen_subtd3 (temp, operands[1],
3272 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
3273 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
3276 emit_label (label1);
3277 emit_insn (gen_fix_trunctddi2_dfp (operands[0], operands[1], GEN_INT (9)));
3278 emit_label (label2);
3283 ; fixuns_trunc(sf|df)(si|di)2 and fix_trunc(sf|df)(si|di)2
3284 ; instruction pattern(s).
3287 (define_expand "fixuns_trunc<BFP:mode><GPR:mode>2"
3288 [(set (match_operand:GPR 0 "register_operand" "")
3289 (unsigned_fix:GPR (match_operand:BFP 1 "register_operand" "")))]
3292 rtx label1 = gen_label_rtx ();
3293 rtx label2 = gen_label_rtx ();
3294 rtx temp = gen_reg_rtx (<BFP:MODE>mode);
3295 REAL_VALUE_TYPE cmp, sub;
3297 operands[1] = force_reg (<BFP:MODE>mode, operands[1]);
3298 real_2expN (&cmp, GET_MODE_BITSIZE(<GPR:MODE>mode) - 1, <BFP:mode>mode);
3299 real_2expN (&sub, GET_MODE_BITSIZE(<GPR:MODE>mode), <BFP:mode>mode);
3301 emit_insn (gen_cmp<BFP:mode> (operands[1],
3302 CONST_DOUBLE_FROM_REAL_VALUE (cmp, <BFP:MODE>mode)));
3303 emit_jump_insn (gen_blt (label1));
3304 emit_insn (gen_sub<BFP:mode>3 (temp, operands[1],
3305 CONST_DOUBLE_FROM_REAL_VALUE (sub, <BFP:MODE>mode)));
3306 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0], temp,
3310 emit_label (label1);
3311 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0],
3312 operands[1], GEN_INT (5)));
3313 emit_label (label2);
3317 (define_expand "fix_trunc<DSF:mode><GPR:mode>2"
3318 [(set (match_operand:GPR 0 "register_operand" "")
3319 (fix:GPR (match_operand:DSF 1 "register_operand" "")))]
3322 emit_insn (gen_fix_trunc<DSF:mode><GPR:mode>2_bfp (operands[0], operands[1],
3327 ; cgxbr, cgdbr, cgebr, cfxbr, cfdbr, cfebr
3328 (define_insn "fix_trunc<BFP:mode><GPR:mode>2_bfp"
3329 [(set (match_operand:GPR 0 "register_operand" "=d")
3330 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
3331 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
3332 (clobber (reg:CC CC_REGNUM))]
3334 "c<GPR:gf><BFP:xde>br\t%0,%h2,%1"
3335 [(set_attr "op_type" "RRE")
3336 (set_attr "type" "ftoi")])
3340 ; fix_trunc(td|dd)di2 instruction pattern(s).
3343 (define_expand "fix_trunc<mode>di2"
3344 [(set (match_operand:DI 0 "register_operand" "")
3345 (fix:DI (match_operand:DFP 1 "nonimmediate_operand" "")))]
3346 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3348 operands[1] = force_reg (<MODE>mode, operands[1]);
3349 emit_insn (gen_fix_trunc<mode>di2_dfp (operands[0], operands[1],
3355 (define_insn "fix_trunc<DFP:mode>di2_dfp"
3356 [(set (match_operand:DI 0 "register_operand" "=d")
3357 (fix:DI (match_operand:DFP 1 "register_operand" "f")))
3358 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
3359 (clobber (reg:CC CC_REGNUM))]
3360 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3361 "cg<DFP:xde>tr\t%0,%h2,%1"
3362 [(set_attr "op_type" "RRF")
3363 (set_attr "type" "ftoi")])
3367 ; fix_trunctf(si|di)2 instruction pattern(s).
3370 (define_expand "fix_trunctf<mode>2"
3371 [(parallel [(set (match_operand:GPR 0 "register_operand" "")
3372 (fix:GPR (match_operand:TF 1 "register_operand" "")))
3373 (unspec:GPR [(const_int 5)] UNSPEC_ROUND)
3374 (clobber (reg:CC CC_REGNUM))])]
3380 ; float(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
3383 ; cxgbr, cdgbr, cegbr, cxgtr, cdgtr
3384 (define_insn "floatdi<mode>2"
3385 [(set (match_operand:FP 0 "register_operand" "=f")
3386 (float:FP (match_operand:DI 1 "register_operand" "d")))]
3387 "TARGET_64BIT && TARGET_HARD_FLOAT"
3388 "c<xde>g<bt>r\t%0,%1"
3389 [(set_attr "op_type" "RRE")
3390 (set_attr "type" "itof" )])
3392 ; cxfbr, cdfbr, cefbr
3393 (define_insn "floatsi<mode>2"
3394 [(set (match_operand:BFP 0 "register_operand" "=f")
3395 (float:BFP (match_operand:SI 1 "register_operand" "d")))]
3398 [(set_attr "op_type" "RRE")
3399 (set_attr "type" "itof" )])
3403 ; truncdfsf2 instruction pattern(s).
3406 (define_insn "truncdfsf2"
3407 [(set (match_operand:SF 0 "register_operand" "=f")
3408 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
3411 [(set_attr "op_type" "RRE")
3412 (set_attr "type" "ftruncdf")])
3415 ; trunctf(df|sf)2 instruction pattern(s).
3419 (define_insn "trunctf<mode>2"
3420 [(set (match_operand:DSF 0 "register_operand" "=f")
3421 (float_truncate:DSF (match_operand:TF 1 "register_operand" "f")))
3422 (clobber (match_scratch:TF 2 "=f"))]
3424 "l<xde>xbr\t%2,%1\;l<xde>r\t%0,%2"
3425 [(set_attr "length" "6")
3426 (set_attr "type" "ftrunctf")])
3429 ; trunctddd2 and truncddsd2 instruction pattern(s).
3432 (define_insn "trunctddd2"
3433 [(set (match_operand:DD 0 "register_operand" "=f")
3434 (float_truncate:DD (match_operand:TD 1 "register_operand" "f")))
3435 (clobber (match_scratch:TD 2 "=f"))]
3436 "TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3437 "ldxtr\t%2,0,%1,0\;ldr\t%0,%2"
3438 [(set_attr "length" "6")
3439 (set_attr "type" "ftrunctf")])
3441 (define_insn "truncddsd2"
3442 [(set (match_operand:SD 0 "register_operand" "=f")
3443 (float_truncate:SD (match_operand:DD 1 "register_operand" "f")))]
3444 "TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3446 [(set_attr "op_type" "RRF")
3447 (set_attr "type" "fsimptf")])
3450 ; extend(sf|df)(df|tf)2 instruction pattern(s).
3453 ; ldebr, ldeb, lxdbr, lxdb, lxebr, lxeb
3454 (define_insn "extend<DSF:mode><BFP:mode>2"
3455 [(set (match_operand:BFP 0 "register_operand" "=f,f")
3456 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "f,R")))]
3458 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)"
3460 l<BFP:xde><DSF:xde>br\t%0,%1
3461 l<BFP:xde><DSF:xde>b\t%0,%1"
3462 [(set_attr "op_type" "RRE,RXE")
3463 (set_attr "type" "fsimp<BFP:mode>, fload<BFP:mode>")])
3466 ; extendddtd2 and extendsddd2 instruction pattern(s).
3469 (define_insn "extendddtd2"
3470 [(set (match_operand:TD 0 "register_operand" "=f")
3471 (float_extend:TD (match_operand:DD 1 "register_operand" "f")))]
3472 "TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3474 [(set_attr "op_type" "RRF")
3475 (set_attr "type" "fsimptf")])
3477 (define_insn "extendsddd2"
3478 [(set (match_operand:DD 0 "register_operand" "=f")
3479 (float_extend:DD (match_operand:SD 1 "register_operand" "f")))]
3480 "TARGET_HARD_FLOAT && TARGET_HARD_DFP"
3482 [(set_attr "op_type" "RRF")
3483 (set_attr "type" "fsimptf")])
3485 ; Binary <-> Decimal floating point trunc patterns
3488 (define_insn "*trunc<BFP:mode><DFP_ALL:mode>2"
3489 [(set (reg:DFP_ALL FPR0_REGNUM)
3490 (float_truncate:DFP_ALL (reg:BFP FPR2_REGNUM)))
3491 (use (reg:SI GPR0_REGNUM))
3492 (clobber (reg:CC CC_REGNUM))]
3493 "TARGET_HARD_FLOAT && TARGET_DFP"
3496 (define_insn "*trunc<DFP_ALL:mode><BFP:mode>2"
3497 [(set (reg:BFP FPR0_REGNUM)
3498 (float_truncate:BFP (reg:DFP_ALL FPR2_REGNUM)))
3499 (use (reg:SI GPR0_REGNUM))
3500 (clobber (reg:CC CC_REGNUM))]
3501 "TARGET_HARD_FLOAT && TARGET_DFP"
3504 (define_expand "trunc<BFP:mode><DFP_ALL:mode>2"
3505 [(set (reg:BFP FPR2_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
3506 (set (reg:SI GPR0_REGNUM) (match_dup 2))
3508 [(set (reg:DFP_ALL FPR0_REGNUM)
3509 (float_truncate:DFP_ALL (reg:BFP FPR2_REGNUM)))
3510 (use (reg:SI GPR0_REGNUM))
3511 (clobber (reg:CC CC_REGNUM))])
3512 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
3513 (reg:DFP_ALL FPR0_REGNUM))]
3514 "TARGET_HARD_FLOAT && TARGET_DFP
3515 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
3517 HOST_WIDE_INT flags;
3519 flags = (PFPO_CONVERT |
3520 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
3521 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
3523 operands[2] = GEN_INT (flags);
3526 (define_expand "trunc<DFP_ALL:mode><BFP:mode>2"
3527 [(set (reg:DFP_ALL FPR2_REGNUM)
3528 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
3529 (set (reg:SI GPR0_REGNUM) (match_dup 2))
3531 [(set (reg:BFP FPR0_REGNUM) (float_truncate:BFP (reg:DFP_ALL FPR2_REGNUM)))
3532 (use (reg:SI GPR0_REGNUM))
3533 (clobber (reg:CC CC_REGNUM))])
3534 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]