Update Copyright years for files modified in 2008 and/or 2009.
[gcc.git] / gcc / config / s390 / s390.md
1 ;;- Machine description for GNU compiler -- S/390 / zSeries version.
2 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
3 ;; 2009 Free Software Foundation, Inc.
4 ;; Contributed by Hartmut Penner (hpenner@de.ibm.com) and
5 ;; Ulrich Weigand (uweigand@de.ibm.com) and
6 ;; Andreas Krebbel (Andreas.Krebbel@de.ibm.com)
7
8 ;; This file is part of GCC.
9
10 ;; GCC is free software; you can redistribute it and/or modify it under
11 ;; the terms of the GNU General Public License as published by the Free
12 ;; Software Foundation; either version 3, or (at your option) any later
13 ;; version.
14
15 ;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
16 ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 ;; for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING3. If not see
22 ;; <http://www.gnu.org/licenses/>.
23
24 ;;
25 ;; See constraints.md for a description of constraints specific to s390.
26 ;;
27
28 ;; Special formats used for outputting 390 instructions.
29 ;;
30 ;; %C: print opcode suffix for branch condition.
31 ;; %D: print opcode suffix for inverse branch condition.
32 ;; %J: print tls_load/tls_gdcall/tls_ldcall suffix
33 ;; %G: print the size of the operand in bytes.
34 ;; %O: print only the displacement of a memory reference.
35 ;; %R: print only the base register of a memory reference.
36 ;; %S: print S-type memory reference (base+displacement).
37 ;; %N: print the second word of a DImode operand.
38 ;; %M: print the second word of a TImode operand.
39 ;; %Y: print shift count operand.
40 ;;
41 ;; %b: print integer X as if it's an unsigned byte.
42 ;; %c: print integer X as if it's an signed byte.
43 ;; %x: print integer X as if it's an unsigned halfword.
44 ;; %h: print integer X as if it's a signed halfword.
45 ;; %i: print the first nonzero HImode part of X.
46 ;; %j: print the first HImode part unequal to -1 of X.
47 ;; %k: print the first nonzero SImode part of X.
48 ;; %m: print the first SImode part unequal to -1 of X.
49 ;; %o: print integer X as if it's an unsigned 32bit word.
50 ;;
51 ;; We have a special constraint for pattern matching.
52 ;;
53 ;; s_operand -- Matches a valid S operand in a RS, SI or SS type instruction.
54 ;;
55
56 ;;
57 ;; UNSPEC usage
58 ;;
59
60 (define_constants
61 [; Miscellaneous
62 (UNSPEC_ROUND 1)
63 (UNSPEC_CCU_TO_INT 2)
64 (UNSPEC_CCZ_TO_INT 3)
65 (UNSPEC_ICM 10)
66 (UNSPEC_TIE 11)
67
68 ; GOT/PLT and lt-relative accesses
69 (UNSPEC_LTREL_OFFSET 100)
70 (UNSPEC_LTREL_BASE 101)
71 (UNSPEC_POOL_OFFSET 102)
72 (UNSPEC_GOTENT 110)
73 (UNSPEC_GOT 111)
74 (UNSPEC_GOTOFF 112)
75 (UNSPEC_PLT 113)
76 (UNSPEC_PLTOFF 114)
77
78 ; Literal pool
79 (UNSPEC_RELOAD_BASE 210)
80 (UNSPEC_MAIN_BASE 211)
81 (UNSPEC_LTREF 212)
82 (UNSPEC_INSN 213)
83 (UNSPEC_EXECUTE 214)
84
85 ; Atomic Support
86 (UNSPEC_MB 400)
87
88 ; TLS relocation specifiers
89 (UNSPEC_TLSGD 500)
90 (UNSPEC_TLSLDM 501)
91 (UNSPEC_NTPOFF 502)
92 (UNSPEC_DTPOFF 503)
93 (UNSPEC_GOTNTPOFF 504)
94 (UNSPEC_INDNTPOFF 505)
95
96 ; TLS support
97 (UNSPEC_TLSLDM_NTPOFF 511)
98 (UNSPEC_TLS_LOAD 512)
99
100 ; String Functions
101 (UNSPEC_SRST 600)
102 (UNSPEC_MVST 601)
103
104 ; Stack Smashing Protector
105 (UNSPEC_SP_SET 700)
106 (UNSPEC_SP_TEST 701)
107
108 ; Copy sign instructions
109 (UNSPEC_COPYSIGN 800)
110
111 ; Test Data Class (TDC)
112 (UNSPEC_TDC_INSN 900)
113 ])
114
115 ;;
116 ;; UNSPEC_VOLATILE usage
117 ;;
118
119 (define_constants
120 [; Blockage
121 (UNSPECV_BLOCKAGE 0)
122
123 ; TPF Support
124 (UNSPECV_TPF_PROLOGUE 20)
125 (UNSPECV_TPF_EPILOGUE 21)
126
127 ; Literal pool
128 (UNSPECV_POOL 200)
129 (UNSPECV_POOL_SECTION 201)
130 (UNSPECV_POOL_ALIGN 202)
131 (UNSPECV_POOL_ENTRY 203)
132 (UNSPECV_MAIN_POOL 300)
133
134 ; TLS support
135 (UNSPECV_SET_TP 500)
136
137 ; Atomic Support
138 (UNSPECV_CAS 700)
139 ])
140
141 ;;
142 ;; Registers
143 ;;
144
145 ; Registers with special meaning
146
147 (define_constants
148 [
149 ; Sibling call register.
150 (SIBCALL_REGNUM 1)
151 ; Literal pool base register.
152 (BASE_REGNUM 13)
153 ; Return address register.
154 (RETURN_REGNUM 14)
155 ; Condition code register.
156 (CC_REGNUM 33)
157 ; Thread local storage pointer register.
158 (TP_REGNUM 36)
159 ])
160
161 ; Hardware register names
162
163 (define_constants
164 [
165 ; General purpose registers
166 (GPR0_REGNUM 0)
167 ; Floating point registers.
168 (FPR0_REGNUM 16)
169 (FPR2_REGNUM 18)
170 ])
171
172 ;;
173 ;; PFPO GPR0 argument format
174 ;;
175
176 (define_constants
177 [
178 ; PFPO operation type
179 (PFPO_CONVERT 0x1000000)
180 ; PFPO operand types
181 (PFPO_OP_TYPE_SF 0x5)
182 (PFPO_OP_TYPE_DF 0x6)
183 (PFPO_OP_TYPE_TF 0x7)
184 (PFPO_OP_TYPE_SD 0x8)
185 (PFPO_OP_TYPE_DD 0x9)
186 (PFPO_OP_TYPE_TD 0xa)
187 ; Bitposition of operand types
188 (PFPO_OP0_TYPE_SHIFT 16)
189 (PFPO_OP1_TYPE_SHIFT 8)
190 ])
191
192
193 ;; Instruction operand type as used in the Principles of Operation.
194 ;; Used to determine defaults for length and other attribute values.
195
196 (define_attr "op_type"
197 "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY,RRF,RRR,SIL,RRS,RIS"
198 (const_string "NN"))
199
200 ;; Instruction type attribute used for scheduling.
201
202 (define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
203 cs,vs,store,sem,idiv,
204 imulhi,imulsi,imuldi,
205 branch,jsr,fsimptf,fsimpdf,fsimpsf,
206 floadtf,floaddf,floadsf,fstoredf,fstoresf,
207 fmultf,fmuldf,fmulsf,fdivtf,fdivdf,fdivsf,
208 ftoi,fsqrttf,fsqrtdf,fsqrtsf,
209 ftrunctf,ftruncdf, ftruncsd, ftruncdd,
210 itoftf, itofdf, itofsf, itofdd, itoftd,
211 fdivdd, fdivtd, floaddd, floadsd, fmuldd, fmultd,
212 fsimpdd, fsimpsd, fsimptd, fstoredd, fstoresd,
213 ftoidfp, other"
214 (cond [(eq_attr "op_type" "NN") (const_string "other")
215 (eq_attr "op_type" "SS") (const_string "cs")]
216 (const_string "integer")))
217
218 ;; Another attribute used for scheduling purposes:
219 ;; agen: Instruction uses the address generation unit
220 ;; reg: Instruction does not use the agen unit
221
222 (define_attr "atype" "agen,reg"
223 (if_then_else (eq_attr "op_type" "E,RR,RI,RRE")
224 (const_string "reg")
225 (const_string "agen")))
226
227 ;; Properties concerning Z10 execution grouping and value forwarding.
228 ;; z10_super: instruction is superscalar.
229 ;; z10_super_c: instruction is superscalar and meets the condition of z10_c.
230 ;; z10_fwd: The instruction reads the value of an operand and stores it into a
231 ;; target register. It can forward this value to a second instruction that reads
232 ;; the same register if that second instruction is issued in the same group.
233 ;; z10_rec: The instruction is in the T pipeline and reads a register. If the
234 ;; instruction in the S pipe writes to the register, then the T instruction
235 ;; can immediately read the new value.
236 ;; z10_fr: union of Z10_fwd and z10_rec.
237 ;; z10_c: second operand of instruction is a register and read with complemented bits.
238 ;; z10_cobra: its a compare and branch instruction
239 ;;
240 ;; An additional suffix A1, A3, or E1 indicates the respective AGI bypass.
241
242
243 (define_attr "z10prop" "none,
244 z10_super, z10_super_E1, z10_super_A1, z10_super_c, z10_super_c_E1,
245 z10_fwd, z10_fwd_A1, z10_fwd_A3, z10_fwd_E1,
246 z10_rec,
247 z10_fr, z10_fr_A3, z10_fr_E1,
248 z10_c, z10_cobra"
249 (const_string "none"))
250
251
252 ;; Length in bytes.
253
254 (define_attr "length" ""
255 (cond [(eq_attr "op_type" "E,RR") (const_int 2)
256 (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI,RRF,RRR") (const_int 4)]
257 (const_int 6)))
258
259
260 ;; Processor type. This attribute must exactly match the processor_type
261 ;; enumeration in s390.h. The current machine description does not
262 ;; distinguish between g5 and g6, but there are differences between the two
263 ;; CPUs could in theory be modeled.
264
265 (define_attr "cpu" "g5,g6,z900,z990,z9_109,z10"
266 (const (symbol_ref "s390_tune")))
267
268 (define_attr "cpu_facility" "standard,ieee,zarch,longdisp,extimm,dfp,z10"
269 (const_string "standard"))
270
271 (define_attr "enabled" ""
272 (cond [(eq_attr "cpu_facility" "standard")
273 (const_int 1)
274
275 (and (eq_attr "cpu_facility" "ieee")
276 (ne (symbol_ref "TARGET_CPU_IEEE_FLOAT") (const_int 0)))
277 (const_int 1)
278
279 (and (eq_attr "cpu_facility" "zarch")
280 (ne (symbol_ref "TARGET_ZARCH") (const_int 0)))
281 (const_int 1)
282
283 (and (eq_attr "cpu_facility" "longdisp")
284 (ne (symbol_ref "TARGET_LONG_DISPLACEMENT") (const_int 0)))
285 (const_int 1)
286
287 (and (eq_attr "cpu_facility" "extimm")
288 (ne (symbol_ref "TARGET_EXTIMM") (const_int 0)))
289 (const_int 1)
290
291 (and (eq_attr "cpu_facility" "dfp")
292 (ne (symbol_ref "TARGET_DFP") (const_int 0)))
293 (const_int 1)
294
295 (and (eq_attr "cpu_facility" "z10")
296 (ne (symbol_ref "TARGET_Z10") (const_int 0)))
297 (const_int 1)]
298 (const_int 0)))
299
300 ;; Pipeline description for z900. For lack of anything better,
301 ;; this description is also used for the g5 and g6.
302 (include "2064.md")
303
304 ;; Pipeline description for z990, z9-109 and z9-ec.
305 (include "2084.md")
306
307 ;; Pipeline description for z10
308 (include "2097.md")
309
310 ;; Predicates
311 (include "predicates.md")
312
313 ;; Constraint definitions
314 (include "constraints.md")
315
316 ;; Other includes
317 (include "tpf.md")
318
319 ;; Iterators
320
321 ;; These mode iterators allow floating point patterns to be generated from the
322 ;; same template.
323 (define_mode_iterator FP_ALL [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")
324 (SD "TARGET_HARD_DFP")])
325 (define_mode_iterator FP [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")])
326 (define_mode_iterator FPALL [TF DF SF TD DD SD])
327 (define_mode_iterator BFP [TF DF SF])
328 (define_mode_iterator DFP [TD DD])
329 (define_mode_iterator DFP_ALL [TD DD SD])
330 (define_mode_iterator DSF [DF SF])
331 (define_mode_iterator SD_SF [SF SD])
332 (define_mode_iterator DD_DF [DF DD])
333 (define_mode_iterator TD_TF [TF TD])
334
335 ;; This mode iterator allows 31-bit and 64-bit TDSI patterns to be generated
336 ;; from the same template.
337 (define_mode_iterator TDSI [(TI "TARGET_64BIT") DI SI])
338
339 ;; These mode iterators allow 31-bit and 64-bit GPR patterns to be generated
340 ;; from the same template.
341 (define_mode_iterator GPR [(DI "TARGET_64BIT") SI])
342 (define_mode_iterator DSI [DI SI])
343
344 ;; These mode iterators allow :P to be used for patterns that operate on
345 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
346 (define_mode_iterator DP [(TI "TARGET_64BIT") (DI "!TARGET_64BIT")])
347 (define_mode_iterator P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
348
349 ;; This mode iterator allows the QI and HI patterns to be defined from
350 ;; the same template.
351 (define_mode_iterator HQI [HI QI])
352
353 ;; This mode iterator allows the integer patterns to be defined from the
354 ;; same template.
355 (define_mode_iterator INT [(DI "TARGET_64BIT") SI HI QI])
356 (define_mode_iterator INTALL [TI DI SI HI QI])
357
358 ;; This iterator allows to unify all 'bCOND' expander patterns.
359 (define_code_iterator COMPARE [eq ne gt gtu lt ltu ge geu le leu unordered
360 ordered uneq unlt ungt unle unge ltgt])
361
362 ;; This iterator allows to unify all 'sCOND' patterns.
363 (define_code_iterator SCOND [ltu gtu leu geu])
364
365 ;; This iterator allows some 'ashift' and 'lshiftrt' pattern to be defined from
366 ;; the same template.
367 (define_code_iterator SHIFT [ashift lshiftrt])
368
369 ;; This iterator and attribute allow to combine most atomic operations.
370 (define_code_iterator ATOMIC [and ior xor plus minus mult])
371 (define_code_attr atomic [(and "and") (ior "ior") (xor "xor")
372 (plus "add") (minus "sub") (mult "nand")])
373
374 ;; In FP templates, a string like "lt<de>br" will expand to "ltxbr" in
375 ;; TF/TDmode, "ltdbr" in DF/DDmode, and "ltebr" in SF/SDmode.
376 (define_mode_attr xde [(TF "x") (DF "d") (SF "e") (TD "x") (DD "d") (SD "e")])
377
378 ;; In FP templates, a <dee> in "m<dee><bt>r" will expand to "mx<bt>r" in
379 ;; TF/TDmode, "md<bt>r" in DF/DDmode, "mee<bt>r" in SFmode and "me<bt>r in
380 ;; SDmode.
381 (define_mode_attr xdee [(TF "x") (DF "d") (SF "ee") (TD "x") (DD "d") (SD "e")])
382
383 ;; In FP templates, "<RRe>" will expand to "RRE" in TFmode and "RR" otherwise.
384 ;; Likewise for "<RXe>".
385 (define_mode_attr RRe [(TF "RRE") (DF "RR") (SF "RR")])
386 (define_mode_attr RXe [(TF "RXE") (DF "RX") (SF "RX")])
387
388 ;; The decimal floating point variants of add, sub, div and mul support 3
389 ;; fp register operands. The following attributes allow to merge the bfp and
390 ;; dfp variants in a single insn definition.
391
392 ;; This attribute is used to set op_type accordingly.
393 (define_mode_attr RRer [(TF "RRE") (DF "RRE") (SF "RRE") (TD "RRR")
394 (DD "RRR") (SD "RRR")])
395
396 ;; This attribute is used in the operand constraint list in order to have the
397 ;; first and the second operand match for bfp modes.
398 (define_mode_attr f0 [(TF "0") (DF "0") (SF "0") (TD "f") (DD "f") (DD "f")])
399
400 ;; This attribute is used in the operand list of the instruction to have an
401 ;; additional operand for the dfp instructions.
402 (define_mode_attr op1 [(TF "") (DF "") (SF "")
403 (TD "%1,") (DD "%1,") (SD "%1,")])
404
405
406 ;; This attribute is used in the operand constraint list
407 ;; for instructions dealing with the sign bit of 32 or 64bit fp values.
408 ;; TFmode values are represented by a fp register pair. Since the
409 ;; sign bit instructions only handle single source and target fp registers
410 ;; these instructions can only be used for TFmode values if the source and
411 ;; target operand uses the same fp register.
412 (define_mode_attr fT0 [(TF "0") (DF "f") (SF "f")])
413
414 ;; In FP templates, "<Rf>" will expand to "f" in TFmode and "R" otherwise.
415 ;; This is used to disable the memory alternative in TFmode patterns.
416 (define_mode_attr Rf [(TF "f") (DF "R") (SF "R") (TD "f") (DD "f") (SD "f")])
417
418 ;; This attribute adds b for bfp instructions and t for dfp instructions and is used
419 ;; within instruction mnemonics.
420 (define_mode_attr bt [(TF "b") (DF "b") (SF "b") (TD "t") (DD "t") (SD "t")])
421
422 ;; This attribute is used within instruction mnemonics. It evaluates to d for dfp
423 ;; modes and to an empty string for bfp modes.
424 (define_mode_attr _d [(TF "") (DF "") (SF "") (TD "d") (DD "d") (SD "d")])
425
426 ;; In GPR and P templates, a constraint like "<d0>" will expand to "d" in DImode
427 ;; and "0" in SImode. This allows to combine instructions of which the 31bit
428 ;; version only operates on one register.
429 (define_mode_attr d0 [(DI "d") (SI "0")])
430
431 ;; In combination with d0 this allows to combine instructions of which the 31bit
432 ;; version only operates on one register. The DImode version needs an additional
433 ;; register for the assembler output.
434 (define_mode_attr 1 [(DI "%1,") (SI "")])
435
436 ;; In SHIFT templates, a string like "s<lr>dl" will expand to "sldl" in
437 ;; 'ashift' and "srdl" in 'lshiftrt'.
438 (define_code_attr lr [(ashift "l") (lshiftrt "r")])
439
440 ;; In SHIFT templates, this attribute holds the correct standard name for the
441 ;; pattern itself and the corresponding function calls.
442 (define_code_attr shift [(ashift "ashl") (lshiftrt "lshr")])
443
444 ;; This attribute handles differences in the instruction 'type' and will result
445 ;; in "RRE" for DImode and "RR" for SImode.
446 (define_mode_attr E [(DI "E") (SI "")])
447
448 ;; This attribute handles differences in the instruction 'type' and makes RX<Y>
449 ;; to result in "RXY" for DImode and "RX" for SImode.
450 (define_mode_attr Y [(DI "Y") (SI "")])
451
452 ;; This attribute handles differences in the instruction 'type' and will result
453 ;; in "RSE" for TImode and "RS" for DImode.
454 (define_mode_attr TE [(TI "E") (DI "")])
455
456 ;; In GPR templates, a string like "lc<g>r" will expand to "lcgr" in DImode
457 ;; and "lcr" in SImode.
458 (define_mode_attr g [(DI "g") (SI "")])
459
460 ;; In GPR templates, a string like "sl<y>" will expand to "slg" in DImode
461 ;; and "sly" in SImode. This is useful because on 64bit the ..g instructions
462 ;; were enhanced with long displacements whereas 31bit instructions got a ..y
463 ;; variant for long displacements.
464 (define_mode_attr y [(DI "g") (SI "y")])
465
466 ;; In DP templates, a string like "cds<g>" will expand to "cdsg" in TImode
467 ;; and "cds" in DImode.
468 (define_mode_attr tg [(TI "g") (DI "")])
469
470 ;; In GPR templates, a string like "c<gf>dbr" will expand to "cgdbr" in DImode
471 ;; and "cfdbr" in SImode.
472 (define_mode_attr gf [(DI "g") (SI "f")])
473
474 ;; ICM mask required to load MODE value into the lowest subreg
475 ;; of a SImode register.
476 (define_mode_attr icm_lo [(HI "3") (QI "1")])
477
478 ;; In HQI templates, a string like "llg<hc>" will expand to "llgh" in
479 ;; HImode and "llgc" in QImode.
480 (define_mode_attr hc [(HI "h") (QI "c")])
481
482 ;; In P templates, the mode <DBL> will expand to "TI" in DImode and "DI"
483 ;; in SImode.
484 (define_mode_attr DBL [(DI "TI") (SI "DI")])
485
486 ;; This attribute expands to DF for TFmode and to DD for TDmode . It is
487 ;; used for Txmode splitters splitting a Txmode copy into 2 Dxmode copies.
488 (define_mode_attr HALF_TMODE [(TF "DF") (TD "DD")])
489
490 ;; Maximum unsigned integer that fits in MODE.
491 (define_mode_attr max_uint [(HI "65535") (QI "255")])
492
493 ;;
494 ;;- Compare instructions.
495 ;;
496
497 (define_expand "cmp<mode>"
498 [(set (reg:CC CC_REGNUM)
499 (compare:CC (match_operand:GPR 0 "register_operand" "")
500 (match_operand:GPR 1 "general_operand" "")))]
501 ""
502 {
503 s390_compare_op0 = operands[0];
504 s390_compare_op1 = operands[1];
505 DONE;
506 })
507
508 (define_expand "cmp<mode>"
509 [(set (reg:CC CC_REGNUM)
510 (compare:CC (match_operand:FP 0 "register_operand" "")
511 (match_operand:FP 1 "general_operand" "")))]
512 "TARGET_HARD_FLOAT"
513 {
514 s390_compare_op0 = operands[0];
515 s390_compare_op1 = operands[1];
516 DONE;
517 })
518
519
520 ; Test-under-Mask instructions
521
522 (define_insn "*tmqi_mem"
523 [(set (reg CC_REGNUM)
524 (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
525 (match_operand:QI 1 "immediate_operand" "n,n"))
526 (match_operand:QI 2 "immediate_operand" "n,n")))]
527 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], false))"
528 "@
529 tm\t%S0,%b1
530 tmy\t%S0,%b1"
531 [(set_attr "op_type" "SI,SIY")
532 (set_attr "z10prop" "z10_super,z10_super")])
533
534 (define_insn "*tmdi_reg"
535 [(set (reg CC_REGNUM)
536 (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
537 (match_operand:DI 1 "immediate_operand"
538 "N0HD0,N1HD0,N2HD0,N3HD0"))
539 (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
540 "TARGET_64BIT
541 && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
542 && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
543 "@
544 tmhh\t%0,%i1
545 tmhl\t%0,%i1
546 tmlh\t%0,%i1
547 tmll\t%0,%i1"
548 [(set_attr "op_type" "RI")
549 (set_attr "z10prop" "z10_super,z10_super,z10_super,z10_super")])
550
551 (define_insn "*tmsi_reg"
552 [(set (reg CC_REGNUM)
553 (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
554 (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
555 (match_operand:SI 2 "immediate_operand" "n,n")))]
556 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
557 && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
558 "@
559 tmh\t%0,%i1
560 tml\t%0,%i1"
561 [(set_attr "op_type" "RI")
562 (set_attr "z10prop" "z10_super,z10_super")])
563
564 (define_insn "*tm<mode>_full"
565 [(set (reg CC_REGNUM)
566 (compare (match_operand:HQI 0 "register_operand" "d")
567 (match_operand:HQI 1 "immediate_operand" "n")))]
568 "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], true))"
569 "tml\t%0,<max_uint>"
570 [(set_attr "op_type" "RI")
571 (set_attr "z10prop" "z10_super")])
572
573
574 ;
575 ; Load-and-Test instructions
576 ;
577
578 ; tst(di|si) instruction pattern(s).
579
580 (define_insn "*tstdi_sign"
581 [(set (reg CC_REGNUM)
582 (compare
583 (ashiftrt:DI
584 (ashift:DI
585 (subreg:DI (match_operand:SI 0 "nonimmediate_operand" "d,RT") 0)
586 (const_int 32)) (const_int 32))
587 (match_operand:DI 1 "const0_operand" "")))
588 (set (match_operand:DI 2 "register_operand" "=d,d")
589 (sign_extend:DI (match_dup 0)))]
590 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
591 "ltgfr\t%2,%0
592 ltgf\t%2,%0"
593 [(set_attr "op_type" "RRE,RXY")
594 (set_attr "cpu_facility" "*,z10")
595 (set_attr "z10prop" "z10_super_E1,z10_super_E1") ])
596
597 ; ltr, lt, ltgr, ltg
598 (define_insn "*tst<mode>_extimm"
599 [(set (reg CC_REGNUM)
600 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,RT")
601 (match_operand:GPR 1 "const0_operand" "")))
602 (set (match_operand:GPR 2 "register_operand" "=d,d")
603 (match_dup 0))]
604 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
605 "@
606 lt<g>r\t%2,%0
607 lt<g>\t%2,%0"
608 [(set_attr "op_type" "RR<E>,RXY")
609 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3") ])
610
611 ; ltr, lt, ltgr, ltg
612 (define_insn "*tst<mode>_cconly_extimm"
613 [(set (reg CC_REGNUM)
614 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,RT")
615 (match_operand:GPR 1 "const0_operand" "")))
616 (clobber (match_scratch:GPR 2 "=X,d"))]
617 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
618 "@
619 lt<g>r\t%0,%0
620 lt<g>\t%2,%0"
621 [(set_attr "op_type" "RR<E>,RXY")
622 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3")])
623
624 (define_insn "*tstdi"
625 [(set (reg CC_REGNUM)
626 (compare (match_operand:DI 0 "register_operand" "d")
627 (match_operand:DI 1 "const0_operand" "")))
628 (set (match_operand:DI 2 "register_operand" "=d")
629 (match_dup 0))]
630 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT && !TARGET_EXTIMM"
631 "ltgr\t%2,%0"
632 [(set_attr "op_type" "RRE")
633 (set_attr "z10prop" "z10_fr_E1")])
634
635 (define_insn "*tstsi"
636 [(set (reg CC_REGNUM)
637 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
638 (match_operand:SI 1 "const0_operand" "")))
639 (set (match_operand:SI 2 "register_operand" "=d,d,d")
640 (match_dup 0))]
641 "s390_match_ccmode(insn, CCSmode) && !TARGET_EXTIMM"
642 "@
643 ltr\t%2,%0
644 icm\t%2,15,%S0
645 icmy\t%2,15,%S0"
646 [(set_attr "op_type" "RR,RS,RSY")
647 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
648
649 (define_insn "*tstsi_cconly"
650 [(set (reg CC_REGNUM)
651 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
652 (match_operand:SI 1 "const0_operand" "")))
653 (clobber (match_scratch:SI 2 "=X,d,d"))]
654 "s390_match_ccmode(insn, CCSmode)"
655 "@
656 ltr\t%0,%0
657 icm\t%2,15,%S0
658 icmy\t%2,15,%S0"
659 [(set_attr "op_type" "RR,RS,RSY")
660 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
661
662 (define_insn "*tstdi_cconly_31"
663 [(set (reg CC_REGNUM)
664 (compare (match_operand:DI 0 "register_operand" "d")
665 (match_operand:DI 1 "const0_operand" "")))]
666 "s390_match_ccmode(insn, CCSmode) && !TARGET_64BIT"
667 "srda\t%0,0"
668 [(set_attr "op_type" "RS")
669 (set_attr "atype" "reg")])
670
671 ; ltr, ltgr
672 (define_insn "*tst<mode>_cconly2"
673 [(set (reg CC_REGNUM)
674 (compare (match_operand:GPR 0 "register_operand" "d")
675 (match_operand:GPR 1 "const0_operand" "")))]
676 "s390_match_ccmode(insn, CCSmode)"
677 "lt<g>r\t%0,%0"
678 [(set_attr "op_type" "RR<E>")
679 (set_attr "z10prop" "z10_fr_E1")])
680
681 ; tst(hi|qi) instruction pattern(s).
682
683 (define_insn "*tst<mode>CCT"
684 [(set (reg CC_REGNUM)
685 (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
686 (match_operand:HQI 1 "const0_operand" "")))
687 (set (match_operand:HQI 2 "register_operand" "=d,d,0")
688 (match_dup 0))]
689 "s390_match_ccmode(insn, CCTmode)"
690 "@
691 icm\t%2,<icm_lo>,%S0
692 icmy\t%2,<icm_lo>,%S0
693 tml\t%0,<max_uint>"
694 [(set_attr "op_type" "RS,RSY,RI")
695 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
696
697 (define_insn "*tsthiCCT_cconly"
698 [(set (reg CC_REGNUM)
699 (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
700 (match_operand:HI 1 "const0_operand" "")))
701 (clobber (match_scratch:HI 2 "=d,d,X"))]
702 "s390_match_ccmode(insn, CCTmode)"
703 "@
704 icm\t%2,3,%S0
705 icmy\t%2,3,%S0
706 tml\t%0,65535"
707 [(set_attr "op_type" "RS,RSY,RI")
708 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
709
710 (define_insn "*tstqiCCT_cconly"
711 [(set (reg CC_REGNUM)
712 (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
713 (match_operand:QI 1 "const0_operand" "")))]
714 "s390_match_ccmode(insn, CCTmode)"
715 "@
716 cli\t%S0,0
717 cliy\t%S0,0
718 tml\t%0,255"
719 [(set_attr "op_type" "SI,SIY,RI")
720 (set_attr "z10prop" "z10_super,z10_super,z10_super")])
721
722 (define_insn "*tst<mode>"
723 [(set (reg CC_REGNUM)
724 (compare (match_operand:HQI 0 "s_operand" "Q,S")
725 (match_operand:HQI 1 "const0_operand" "")))
726 (set (match_operand:HQI 2 "register_operand" "=d,d")
727 (match_dup 0))]
728 "s390_match_ccmode(insn, CCSmode)"
729 "@
730 icm\t%2,<icm_lo>,%S0
731 icmy\t%2,<icm_lo>,%S0"
732 [(set_attr "op_type" "RS,RSY")
733 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
734
735 (define_insn "*tst<mode>_cconly"
736 [(set (reg CC_REGNUM)
737 (compare (match_operand:HQI 0 "s_operand" "Q,S")
738 (match_operand:HQI 1 "const0_operand" "")))
739 (clobber (match_scratch:HQI 2 "=d,d"))]
740 "s390_match_ccmode(insn, CCSmode)"
741 "@
742 icm\t%2,<icm_lo>,%S0
743 icmy\t%2,<icm_lo>,%S0"
744 [(set_attr "op_type" "RS,RSY")
745 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
746
747
748 ; Compare (equality) instructions
749
750 (define_insn "*cmpdi_cct"
751 [(set (reg CC_REGNUM)
752 (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,d,Q")
753 (match_operand:DI 1 "general_operand" "d,K,Os,RT,BQ")))]
754 "s390_match_ccmode (insn, CCTmode) && TARGET_64BIT"
755 "@
756 cgr\t%0,%1
757 cghi\t%0,%h1
758 cgfi\t%0,%1
759 cg\t%0,%1
760 #"
761 [(set_attr "op_type" "RRE,RI,RIL,RXY,SS")
762 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,*")])
763
764 (define_insn "*cmpsi_cct"
765 [(set (reg CC_REGNUM)
766 (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,d,Q")
767 (match_operand:SI 1 "general_operand" "d,K,Os,R,T,BQ")))]
768 "s390_match_ccmode (insn, CCTmode)"
769 "@
770 cr\t%0,%1
771 chi\t%0,%h1
772 cfi\t%0,%1
773 c\t%0,%1
774 cy\t%0,%1
775 #"
776 [(set_attr "op_type" "RR,RI,RIL,RX,RXY,SS")
777 (set_attr "z10prop" "z10_super,z10_super,z10_super,z10_super,z10_super,*")])
778
779 ; Compare (signed) instructions
780
781 (define_insn "*cmpdi_ccs_sign"
782 [(set (reg CC_REGNUM)
783 (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand"
784 "d,RT,b"))
785 (match_operand:DI 0 "register_operand" "d, d,d")))]
786 "s390_match_ccmode(insn, CCSRmode) && TARGET_64BIT"
787 "@
788 cgfr\t%0,%1
789 cgf\t%0,%1
790 cgfrl\t%0,%1"
791 [(set_attr "op_type" "RRE,RXY,RIL")
792 (set_attr "z10prop" "z10_c,*,*")
793 (set_attr "type" "*,*,larl")])
794
795
796
797 (define_insn "*cmpsi_ccs_sign"
798 [(set (reg CC_REGNUM)
799 (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T,b"))
800 (match_operand:SI 0 "register_operand" "d,d,d")))]
801 "s390_match_ccmode(insn, CCSRmode)"
802 "@
803 ch\t%0,%1
804 chy\t%0,%1
805 chrl\t%0,%1"
806 [(set_attr "op_type" "RX,RXY,RIL")
807 (set_attr "cpu_facility" "*,*,z10")
808 (set_attr "type" "*,*,larl")])
809
810 (define_insn "*cmphi_ccs_z10"
811 [(set (reg CC_REGNUM)
812 (compare (match_operand:HI 0 "s_operand" "Q")
813 (match_operand:HI 1 "immediate_operand" "K")))]
814 "s390_match_ccmode(insn, CCSmode) && TARGET_Z10"
815 "chhsi\t%0,%1"
816 [(set_attr "op_type" "SIL")])
817
818 (define_insn "*cmpdi_ccs_signhi_rl"
819 [(set (reg CC_REGNUM)
820 (compare (sign_extend:DI (match_operand:HI 1 "memory_operand" "RT,b"))
821 (match_operand:GPR 0 "register_operand" "d,d")))]
822 "s390_match_ccmode(insn, CCSRmode) && TARGET_Z10"
823 "@
824 cgh\t%0,%1
825 cghrl\t%0,%1"
826 [(set_attr "op_type" "RXY,RIL")
827 (set_attr "type" "*,larl")])
828
829 ; cr, chi, cfi, c, cy, cgr, cghi, cgfi, cg, chsi, cghsi, crl, cgrl
830 (define_insn "*cmp<mode>_ccs"
831 [(set (reg CC_REGNUM)
832 (compare (match_operand:GPR 0 "nonimmediate_operand"
833 "d,d,Q, d,d,d,d")
834 (match_operand:GPR 1 "general_operand"
835 "d,K,K,Os,R,T,b")))]
836 "s390_match_ccmode(insn, CCSmode)"
837 "@
838 c<g>r\t%0,%1
839 c<g>hi\t%0,%h1
840 c<g>hsi\t%0,%h1
841 c<g>fi\t%0,%1
842 c<g>\t%0,%1
843 c<y>\t%0,%1
844 c<g>rl\t%0,%1"
845 [(set_attr "op_type" "RR<E>,RI,SIL,RIL,RX<Y>,RXY,RIL")
846 (set_attr "cpu_facility" "*,*,z10,extimm,*,*,z10")
847 (set_attr "type" "*,*,*,*,*,*,larl")
848 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,z10_super")])
849
850
851 ; Compare (unsigned) instructions
852
853 (define_insn "*cmpsi_ccu_zerohi_rlsi"
854 [(set (reg CC_REGNUM)
855 (compare (zero_extend:SI (mem:HI (match_operand:SI 1
856 "larl_operand" "X")))
857 (match_operand:SI 0 "register_operand" "d")))]
858 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
859 "clhrl\t%0,%1"
860 [(set_attr "op_type" "RIL")
861 (set_attr "type" "larl")
862 (set_attr "z10prop" "z10_super")])
863
864 ; clhrl, clghrl
865 (define_insn "*cmp<GPR:mode>_ccu_zerohi_rldi"
866 [(set (reg CC_REGNUM)
867 (compare (zero_extend:GPR (mem:HI (match_operand:DI 1
868 "larl_operand" "X")))
869 (match_operand:GPR 0 "register_operand" "d")))]
870 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
871 "cl<g>hrl\t%0,%1"
872 [(set_attr "op_type" "RIL")
873 (set_attr "type" "larl")
874 (set_attr "z10prop" "z10_super")])
875
876 (define_insn "*cmpdi_ccu_zero"
877 [(set (reg CC_REGNUM)
878 (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand"
879 "d,RT,b"))
880 (match_operand:DI 0 "register_operand" "d, d,d")))]
881 "s390_match_ccmode (insn, CCURmode) && TARGET_64BIT"
882 "@
883 clgfr\t%0,%1
884 clgf\t%0,%1
885 clgfrl\t%0,%1"
886 [(set_attr "op_type" "RRE,RXY,RIL")
887 (set_attr "cpu_facility" "*,*,z10")
888 (set_attr "type" "*,*,larl")
889 (set_attr "z10prop" "z10_super_c,z10_super_E1,z10_super")])
890
891 (define_insn "*cmpdi_ccu"
892 [(set (reg CC_REGNUM)
893 (compare (match_operand:DI 0 "nonimmediate_operand"
894 "d, d,d,Q, d, Q,BQ")
895 (match_operand:DI 1 "general_operand"
896 "d,Op,b,D,RT,BQ,Q")))]
897 "s390_match_ccmode (insn, CCUmode) && TARGET_64BIT"
898 "@
899 clgr\t%0,%1
900 clgfi\t%0,%1
901 clgrl\t%0,%1
902 clghsi\t%0,%x1
903 clg\t%0,%1
904 #
905 #"
906 [(set_attr "op_type" "RRE,RIL,RIL,SIL,RXY,SS,SS")
907 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*")
908 (set_attr "type" "*,*,larl,*,*,*,*")
909 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*,*")])
910
911 (define_insn "*cmpsi_ccu"
912 [(set (reg CC_REGNUM)
913 (compare (match_operand:SI 0 "nonimmediate_operand" "d, d,d,Q,d,d, Q,BQ")
914 (match_operand:SI 1 "general_operand" "d,Os,b,D,R,T,BQ, Q")))]
915 "s390_match_ccmode (insn, CCUmode)"
916 "@
917 clr\t%0,%1
918 clfi\t%0,%o1
919 clrl\t%0,%1
920 clfhsi\t%0,%x1
921 cl\t%0,%1
922 cly\t%0,%1
923 #
924 #"
925 [(set_attr "op_type" "RR,RIL,RIL,SIL,RX,RXY,SS,SS")
926 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*,*")
927 (set_attr "type" "*,*,larl,*,*,*,*,*")
928 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,*,*")])
929
930 (define_insn "*cmphi_ccu"
931 [(set (reg CC_REGNUM)
932 (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,Q,BQ")
933 (match_operand:HI 1 "general_operand" "Q,S,D,BQ,Q")))]
934 "s390_match_ccmode (insn, CCUmode)
935 && !register_operand (operands[1], HImode)"
936 "@
937 clm\t%0,3,%S1
938 clmy\t%0,3,%S1
939 clhhsi\t%0,%1
940 #
941 #"
942 [(set_attr "op_type" "RS,RSY,SIL,SS,SS")
943 (set_attr "cpu_facility" "*,*,z10,*,*")
944 (set_attr "z10prop" "*,*,z10_super,*,*")])
945
946 (define_insn "*cmpqi_ccu"
947 [(set (reg CC_REGNUM)
948 (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
949 (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
950 "s390_match_ccmode (insn, CCUmode)
951 && !register_operand (operands[1], QImode)"
952 "@
953 clm\t%0,1,%S1
954 clmy\t%0,1,%S1
955 cli\t%S0,%b1
956 cliy\t%S0,%b1
957 #
958 #"
959 [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")
960 (set_attr "z10prop" "*,*,z10_super,z10_super,*,*")])
961
962
963 ; Block compare (CLC) instruction patterns.
964
965 (define_insn "*clc"
966 [(set (reg CC_REGNUM)
967 (compare (match_operand:BLK 0 "memory_operand" "Q")
968 (match_operand:BLK 1 "memory_operand" "Q")))
969 (use (match_operand 2 "const_int_operand" "n"))]
970 "s390_match_ccmode (insn, CCUmode)
971 && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
972 "clc\t%O0(%2,%R0),%S1"
973 [(set_attr "op_type" "SS")])
974
975 (define_split
976 [(set (reg CC_REGNUM)
977 (compare (match_operand 0 "memory_operand" "")
978 (match_operand 1 "memory_operand" "")))]
979 "reload_completed
980 && s390_match_ccmode (insn, CCUmode)
981 && GET_MODE (operands[0]) == GET_MODE (operands[1])
982 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
983 [(parallel
984 [(set (match_dup 0) (match_dup 1))
985 (use (match_dup 2))])]
986 {
987 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
988 operands[0] = adjust_address (operands[0], BLKmode, 0);
989 operands[1] = adjust_address (operands[1], BLKmode, 0);
990
991 operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
992 operands[0], operands[1]);
993 operands[0] = SET_DEST (PATTERN (curr_insn));
994 })
995
996
997 ; (TF|DF|SF|TD|DD|SD) instructions
998
999 ; ltxbr, ltdbr, ltebr, ltxtr, ltdtr
1000 (define_insn "*cmp<mode>_ccs_0"
1001 [(set (reg CC_REGNUM)
1002 (compare (match_operand:FP 0 "register_operand" "f")
1003 (match_operand:FP 1 "const0_operand" "")))]
1004 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
1005 "lt<xde><bt>r\t%0,%0"
1006 [(set_attr "op_type" "RRE")
1007 (set_attr "type" "fsimp<mode>")])
1008
1009 ; cxtr, cxbr, cdbr, cebr, cdb, ceb, cxbtr, cdbtr
1010 (define_insn "*cmp<mode>_ccs"
1011 [(set (reg CC_REGNUM)
1012 (compare (match_operand:FP 0 "register_operand" "f,f")
1013 (match_operand:FP 1 "general_operand" "f,<Rf>")))]
1014 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
1015 "@
1016 c<xde><bt>r\t%0,%1
1017 c<xde>b\t%0,%1"
1018 [(set_attr "op_type" "RRE,RXE")
1019 (set_attr "type" "fsimp<mode>")])
1020
1021
1022 ; Compare and Branch instructions
1023
1024 ; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1025 ; The following instructions do a complementary access of their second
1026 ; operand (z01 only): crj_c, cgrjc, cr, cgr
1027 (define_insn "*cmp_and_br_signed_<mode>"
1028 [(set (pc)
1029 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1030 [(match_operand:GPR 1 "register_operand" "d,d")
1031 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1032 (label_ref (match_operand 3 "" ""))
1033 (pc)))
1034 (clobber (reg:CC CC_REGNUM))]
1035 "TARGET_Z10"
1036 {
1037 if (get_attr_length (insn) == 6)
1038 return which_alternative ?
1039 "c<g>ij%C0\t%1,%c2,%l3" : "c<g>rj%C0\t%1,%2,%l3";
1040 else
1041 return which_alternative ?
1042 "c<g>fi\t%1,%c2\;jg%C0\t%l3" : "c<g>r\t%1,%2\;jg%C0\t%l3";
1043 }
1044 [(set_attr "op_type" "RIE")
1045 (set_attr "type" "branch")
1046 (set_attr "z10prop" "z10_cobra,z10_super")
1047 (set (attr "length")
1048 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1049 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1050 ; 10 byte for cgr/jg
1051
1052 ; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1053 ; The following instructions do a complementary access of their second
1054 ; operand (z10 only): clrj, clgrj, clr, clgr
1055 (define_insn "*cmp_and_br_unsigned_<mode>"
1056 [(set (pc)
1057 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1058 [(match_operand:GPR 1 "register_operand" "d,d")
1059 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1060 (label_ref (match_operand 3 "" ""))
1061 (pc)))
1062 (clobber (reg:CC CC_REGNUM))]
1063 "TARGET_Z10"
1064 {
1065 if (get_attr_length (insn) == 6)
1066 return which_alternative ?
1067 "cl<g>ij%C0\t%1,%b2,%l3" : "cl<g>rj%C0\t%1,%2,%l3";
1068 else
1069 return which_alternative ?
1070 "cl<g>fi\t%1,%b2\;jg%C0\t%l3" : "cl<g>r\t%1,%2\;jg%C0\t%l3";
1071 }
1072 [(set_attr "op_type" "RIE")
1073 (set_attr "type" "branch")
1074 (set_attr "z10prop" "z10_cobra,z10_super")
1075 (set (attr "length")
1076 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1077 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1078 ; 10 byte for clgr/jg
1079
1080 ;;
1081 ;;- Move instructions.
1082 ;;
1083
1084 ;
1085 ; movti instruction pattern(s).
1086 ;
1087
1088 (define_insn "movti"
1089 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,d,o")
1090 (match_operand:TI 1 "general_operand" "QS,d,dPRT,d"))]
1091 "TARGET_64BIT"
1092 "@
1093 lmg\t%0,%N0,%S1
1094 stmg\t%1,%N1,%S0
1095 #
1096 #"
1097 [(set_attr "op_type" "RSY,RSY,*,*")
1098 (set_attr "type" "lm,stm,*,*")])
1099
1100 (define_split
1101 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1102 (match_operand:TI 1 "general_operand" ""))]
1103 "TARGET_64BIT && reload_completed
1104 && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
1105 [(set (match_dup 2) (match_dup 4))
1106 (set (match_dup 3) (match_dup 5))]
1107 {
1108 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1109 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1110 operands[4] = operand_subword (operands[1], 0, 0, TImode);
1111 operands[5] = operand_subword (operands[1], 1, 0, TImode);
1112 })
1113
1114 (define_split
1115 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1116 (match_operand:TI 1 "general_operand" ""))]
1117 "TARGET_64BIT && reload_completed
1118 && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
1119 [(set (match_dup 2) (match_dup 4))
1120 (set (match_dup 3) (match_dup 5))]
1121 {
1122 operands[2] = operand_subword (operands[0], 1, 0, TImode);
1123 operands[3] = operand_subword (operands[0], 0, 0, TImode);
1124 operands[4] = operand_subword (operands[1], 1, 0, TImode);
1125 operands[5] = operand_subword (operands[1], 0, 0, TImode);
1126 })
1127
1128 (define_split
1129 [(set (match_operand:TI 0 "register_operand" "")
1130 (match_operand:TI 1 "memory_operand" ""))]
1131 "TARGET_64BIT && reload_completed
1132 && !s_operand (operands[1], VOIDmode)"
1133 [(set (match_dup 0) (match_dup 1))]
1134 {
1135 rtx addr = operand_subword (operands[0], 1, 0, TImode);
1136 s390_load_address (addr, XEXP (operands[1], 0));
1137 operands[1] = replace_equiv_address (operands[1], addr);
1138 })
1139
1140
1141 ;
1142 ; Patterns used for secondary reloads
1143 ;
1144
1145 ; z10 provides move instructions accepting larl memory operands.
1146 ; Unfortunately there is no such variant for QI, TI and FP mode moves.
1147 ; These patterns are also used for unaligned SI and DI accesses.
1148
1149 (define_expand "reload<INTALL:mode><P:mode>_tomem_z10"
1150 [(parallel [(match_operand:INTALL 0 "memory_operand" "")
1151 (match_operand:INTALL 1 "register_operand" "=d")
1152 (match_operand:P 2 "register_operand" "=&a")])]
1153 "TARGET_Z10"
1154 {
1155 s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1156 DONE;
1157 })
1158
1159 (define_expand "reload<INTALL:mode><P:mode>_toreg_z10"
1160 [(parallel [(match_operand:INTALL 0 "register_operand" "=d")
1161 (match_operand:INTALL 1 "memory_operand" "")
1162 (match_operand:P 2 "register_operand" "=a")])]
1163 "TARGET_Z10"
1164 {
1165 s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1166 DONE;
1167 })
1168
1169 (define_expand "reload<FPALL:mode><P:mode>_tomem_z10"
1170 [(parallel [(match_operand:FPALL 0 "memory_operand" "")
1171 (match_operand:FPALL 1 "register_operand" "=d")
1172 (match_operand:P 2 "register_operand" "=&a")])]
1173 "TARGET_Z10"
1174 {
1175 s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1176 DONE;
1177 })
1178
1179 (define_expand "reload<FPALL:mode><P:mode>_toreg_z10"
1180 [(parallel [(match_operand:FPALL 0 "register_operand" "=d")
1181 (match_operand:FPALL 1 "memory_operand" "")
1182 (match_operand:P 2 "register_operand" "=a")])]
1183 "TARGET_Z10"
1184 {
1185 s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1186 DONE;
1187 })
1188
1189 (define_expand "reload<P:mode>_larl_odd_addend_z10"
1190 [(parallel [(match_operand:P 0 "register_operand" "=d")
1191 (match_operand:P 1 "larl_operand" "")
1192 (match_operand:P 2 "register_operand" "=a")])]
1193 "TARGET_Z10"
1194 {
1195 s390_reload_larl_operand (operands[0], operands[1], operands[2]);
1196 DONE;
1197 })
1198
1199 ; Handles loading a PLUS (load address) expression
1200
1201 (define_expand "reload<mode>_plus"
1202 [(parallel [(match_operand:P 0 "register_operand" "=a")
1203 (match_operand:P 1 "s390_plus_operand" "")
1204 (match_operand:P 2 "register_operand" "=&a")])]
1205 ""
1206 {
1207 s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1208 DONE;
1209 })
1210
1211 ; Handles assessing a non-offsetable memory address
1212
1213 (define_expand "reload<mode>_nonoffmem_in"
1214 [(parallel [(match_operand 0 "register_operand" "")
1215 (match_operand 1 "" "")
1216 (match_operand:P 2 "register_operand" "=&a")])]
1217 ""
1218 {
1219 gcc_assert (MEM_P (operands[1]));
1220 s390_load_address (operands[2], find_replacement (&XEXP (operands[1], 0)));
1221 operands[1] = replace_equiv_address (operands[1], operands[2]);
1222 emit_move_insn (operands[0], operands[1]);
1223 DONE;
1224 })
1225
1226 (define_expand "reload<mode>_nonoffmem_out"
1227 [(parallel [(match_operand 0 "" "")
1228 (match_operand 1 "register_operand" "")
1229 (match_operand:P 2 "register_operand" "=&a")])]
1230 ""
1231 {
1232 gcc_assert (MEM_P (operands[0]));
1233 s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
1234 operands[0] = replace_equiv_address (operands[0], operands[2]);
1235 emit_move_insn (operands[0], operands[1]);
1236 DONE;
1237 })
1238
1239 (define_expand "reload<mode>_PIC_addr"
1240 [(parallel [(match_operand 0 "register_operand" "=d")
1241 (match_operand 1 "larl_operand" "")
1242 (match_operand:P 2 "register_operand" "=a")])]
1243 ""
1244 {
1245 rtx new_rtx = legitimize_pic_address (operands[1], operands[2]);
1246 emit_move_insn (operands[0], new_rtx);
1247 })
1248
1249 ;
1250 ; movdi instruction pattern(s).
1251 ;
1252
1253 (define_expand "movdi"
1254 [(set (match_operand:DI 0 "general_operand" "")
1255 (match_operand:DI 1 "general_operand" ""))]
1256 ""
1257 {
1258 /* Handle symbolic constants. */
1259 if (TARGET_64BIT
1260 && (SYMBOLIC_CONST (operands[1])
1261 || (GET_CODE (operands[1]) == PLUS
1262 && XEXP (operands[1], 0) == pic_offset_table_rtx
1263 && SYMBOLIC_CONST (XEXP (operands[1], 1)))))
1264 emit_symbolic_move (operands);
1265 })
1266
1267 (define_insn "*movdi_larl"
1268 [(set (match_operand:DI 0 "register_operand" "=d")
1269 (match_operand:DI 1 "larl_operand" "X"))]
1270 "TARGET_64BIT
1271 && !FP_REG_P (operands[0])"
1272 "larl\t%0,%1"
1273 [(set_attr "op_type" "RIL")
1274 (set_attr "type" "larl")
1275 (set_attr "z10prop" "z10_super_A1")])
1276
1277 (define_insn "*movdi_64"
1278 [(set (match_operand:DI 0 "nonimmediate_operand"
1279 "=d,d,d,d,d,d,d,d,f,d,d,d,d,d,
1280 RT,!*f,!*f,!*f,!R,!T,b,Q,d,t,Q,t")
1281 (match_operand:DI 1 "general_operand"
1282 "K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,b,d,RT,
1283 d,*f,R,T,*f,*f,d,K,t,d,t,Q"))]
1284 "TARGET_64BIT"
1285 "@
1286 lghi\t%0,%h1
1287 llihh\t%0,%i1
1288 llihl\t%0,%i1
1289 llilh\t%0,%i1
1290 llill\t%0,%i1
1291 lgfi\t%0,%1
1292 llihf\t%0,%k1
1293 llilf\t%0,%k1
1294 ldgr\t%0,%1
1295 lgdr\t%0,%1
1296 lay\t%0,%a1
1297 lgrl\t%0,%1
1298 lgr\t%0,%1
1299 lg\t%0,%1
1300 stg\t%1,%0
1301 ldr\t%0,%1
1302 ld\t%0,%1
1303 ldy\t%0,%1
1304 std\t%1,%0
1305 stdy\t%1,%0
1306 stgrl\t%1,%0
1307 mvghi\t%0,%1
1308 #
1309 #
1310 stam\t%1,%N1,%S0
1311 lam\t%0,%N0,%S1"
1312 [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RIL,RRE,RXY,
1313 RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS")
1314 (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,larl,lr,load,store,
1315 floaddf,floaddf,floaddf,fstoredf,fstoredf,larl,*,*,*,
1316 *,*")
1317 (set_attr "cpu_facility" "*,*,*,*,*,extimm,extimm,extimm,dfp,dfp,longdisp,
1318 z10,*,*,*,*,*,longdisp,*,longdisp,
1319 z10,z10,*,*,*,*")
1320 (set_attr "z10prop" "z10_fwd_A1,
1321 z10_fwd_E1,
1322 z10_fwd_E1,
1323 z10_fwd_E1,
1324 z10_fwd_E1,
1325 z10_fwd_A1,
1326 z10_fwd_E1,
1327 z10_fwd_E1,
1328 *,
1329 *,
1330 z10_fwd_A1,
1331 z10_fwd_A3,
1332 z10_fr_E1,
1333 z10_fwd_A3,
1334 z10_rec,
1335 *,
1336 *,
1337 *,
1338 *,
1339 *,
1340 z10_rec,
1341 z10_super,
1342 *,
1343 *,
1344 *,
1345 *")
1346 ])
1347
1348 (define_split
1349 [(set (match_operand:DI 0 "register_operand" "")
1350 (match_operand:DI 1 "register_operand" ""))]
1351 "TARGET_64BIT && ACCESS_REG_P (operands[1])"
1352 [(set (match_dup 2) (match_dup 3))
1353 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
1354 (set (strict_low_part (match_dup 2)) (match_dup 4))]
1355 "operands[2] = gen_lowpart (SImode, operands[0]);
1356 s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
1357
1358 (define_split
1359 [(set (match_operand:DI 0 "register_operand" "")
1360 (match_operand:DI 1 "register_operand" ""))]
1361 "TARGET_64BIT && ACCESS_REG_P (operands[0])
1362 && dead_or_set_p (insn, operands[1])"
1363 [(set (match_dup 3) (match_dup 2))
1364 (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
1365 (set (match_dup 4) (match_dup 2))]
1366 "operands[2] = gen_lowpart (SImode, operands[1]);
1367 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1368
1369 (define_split
1370 [(set (match_operand:DI 0 "register_operand" "")
1371 (match_operand:DI 1 "register_operand" ""))]
1372 "TARGET_64BIT && ACCESS_REG_P (operands[0])
1373 && !dead_or_set_p (insn, operands[1])"
1374 [(set (match_dup 3) (match_dup 2))
1375 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
1376 (set (match_dup 4) (match_dup 2))
1377 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
1378 "operands[2] = gen_lowpart (SImode, operands[1]);
1379 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1380
1381 (define_insn "*movdi_31"
1382 [(set (match_operand:DI 0 "nonimmediate_operand"
1383 "=d,d,Q,S,d ,o,!*f,!*f,!*f,!R,!T,d")
1384 (match_operand:DI 1 "general_operand"
1385 " Q,S,d,d,dPRT,d, *f, R, T,*f,*f,b"))]
1386 "!TARGET_64BIT"
1387 "@
1388 lm\t%0,%N0,%S1
1389 lmy\t%0,%N0,%S1
1390 stm\t%1,%N1,%S0
1391 stmy\t%1,%N1,%S0
1392 #
1393 #
1394 ldr\t%0,%1
1395 ld\t%0,%1
1396 ldy\t%0,%1
1397 std\t%1,%0
1398 stdy\t%1,%0
1399 #"
1400 [(set_attr "op_type" "RS,RSY,RS,RSY,*,*,RR,RX,RXY,RX,RXY,*")
1401 (set_attr "type" "lm,lm,stm,stm,*,*,floaddf,floaddf,floaddf,fstoredf,fstoredf,*")
1402 (set_attr "cpu_facility" "*,*,*,*,*,*,*,*,*,*,*,z10")])
1403
1404 ; For a load from a symbol ref we can use one of the target registers
1405 ; together with larl to load the address.
1406 (define_split
1407 [(set (match_operand:DI 0 "register_operand" "")
1408 (match_operand:DI 1 "memory_operand" ""))]
1409 "!TARGET_64BIT && reload_completed && TARGET_Z10
1410 && larl_operand (XEXP (operands[1], 0), SImode)"
1411 [(set (match_dup 2) (match_dup 3))
1412 (set (match_dup 0) (match_dup 1))]
1413 {
1414 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1415 operands[3] = XEXP (operands[1], 0);
1416 operands[1] = replace_equiv_address (operands[1], operands[2]);
1417 })
1418
1419 (define_split
1420 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1421 (match_operand:DI 1 "general_operand" ""))]
1422 "!TARGET_64BIT && reload_completed
1423 && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
1424 [(set (match_dup 2) (match_dup 4))
1425 (set (match_dup 3) (match_dup 5))]
1426 {
1427 operands[2] = operand_subword (operands[0], 0, 0, DImode);
1428 operands[3] = operand_subword (operands[0], 1, 0, DImode);
1429 operands[4] = operand_subword (operands[1], 0, 0, DImode);
1430 operands[5] = operand_subword (operands[1], 1, 0, DImode);
1431 })
1432
1433 (define_split
1434 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1435 (match_operand:DI 1 "general_operand" ""))]
1436 "!TARGET_64BIT && reload_completed
1437 && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
1438 [(set (match_dup 2) (match_dup 4))
1439 (set (match_dup 3) (match_dup 5))]
1440 {
1441 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1442 operands[3] = operand_subword (operands[0], 0, 0, DImode);
1443 operands[4] = operand_subword (operands[1], 1, 0, DImode);
1444 operands[5] = operand_subword (operands[1], 0, 0, DImode);
1445 })
1446
1447 (define_split
1448 [(set (match_operand:DI 0 "register_operand" "")
1449 (match_operand:DI 1 "memory_operand" ""))]
1450 "!TARGET_64BIT && reload_completed
1451 && !FP_REG_P (operands[0])
1452 && !s_operand (operands[1], VOIDmode)"
1453 [(set (match_dup 0) (match_dup 1))]
1454 {
1455 rtx addr = operand_subword (operands[0], 1, 0, DImode);
1456 s390_load_address (addr, XEXP (operands[1], 0));
1457 operands[1] = replace_equiv_address (operands[1], addr);
1458 })
1459
1460 (define_peephole2
1461 [(set (match_operand:DI 0 "register_operand" "")
1462 (mem:DI (match_operand 1 "address_operand" "")))]
1463 "TARGET_64BIT
1464 && !FP_REG_P (operands[0])
1465 && GET_CODE (operands[1]) == SYMBOL_REF
1466 && CONSTANT_POOL_ADDRESS_P (operands[1])
1467 && get_pool_mode (operands[1]) == DImode
1468 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1469 [(set (match_dup 0) (match_dup 2))]
1470 "operands[2] = get_pool_constant (operands[1]);")
1471
1472 (define_insn "*la_64"
1473 [(set (match_operand:DI 0 "register_operand" "=d,d")
1474 (match_operand:QI 1 "address_operand" "U,W"))]
1475 "TARGET_64BIT"
1476 "@
1477 la\t%0,%a1
1478 lay\t%0,%a1"
1479 [(set_attr "op_type" "RX,RXY")
1480 (set_attr "type" "la")
1481 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1482
1483 (define_peephole2
1484 [(parallel
1485 [(set (match_operand:DI 0 "register_operand" "")
1486 (match_operand:QI 1 "address_operand" ""))
1487 (clobber (reg:CC CC_REGNUM))])]
1488 "TARGET_64BIT
1489 && preferred_la_operand_p (operands[1], const0_rtx)"
1490 [(set (match_dup 0) (match_dup 1))]
1491 "")
1492
1493 (define_peephole2
1494 [(set (match_operand:DI 0 "register_operand" "")
1495 (match_operand:DI 1 "register_operand" ""))
1496 (parallel
1497 [(set (match_dup 0)
1498 (plus:DI (match_dup 0)
1499 (match_operand:DI 2 "nonmemory_operand" "")))
1500 (clobber (reg:CC CC_REGNUM))])]
1501 "TARGET_64BIT
1502 && !reg_overlap_mentioned_p (operands[0], operands[2])
1503 && preferred_la_operand_p (operands[1], operands[2])"
1504 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1505 "")
1506
1507 ;
1508 ; movsi instruction pattern(s).
1509 ;
1510
1511 (define_expand "movsi"
1512 [(set (match_operand:SI 0 "general_operand" "")
1513 (match_operand:SI 1 "general_operand" ""))]
1514 ""
1515 {
1516 /* Handle symbolic constants. */
1517 if (!TARGET_64BIT
1518 && (SYMBOLIC_CONST (operands[1])
1519 || (GET_CODE (operands[1]) == PLUS
1520 && XEXP (operands[1], 0) == pic_offset_table_rtx
1521 && SYMBOLIC_CONST (XEXP(operands[1], 1)))))
1522 emit_symbolic_move (operands);
1523 })
1524
1525 (define_insn "*movsi_larl"
1526 [(set (match_operand:SI 0 "register_operand" "=d")
1527 (match_operand:SI 1 "larl_operand" "X"))]
1528 "!TARGET_64BIT && TARGET_CPU_ZARCH
1529 && !FP_REG_P (operands[0])"
1530 "larl\t%0,%1"
1531 [(set_attr "op_type" "RIL")
1532 (set_attr "type" "larl")
1533 (set_attr "z10prop" "z10_fwd_A1")])
1534
1535 (define_insn "*movsi_zarch"
1536 [(set (match_operand:SI 0 "nonimmediate_operand"
1537 "=d,d,d,d,d,d,d,d,d,R,T,!*f,!*f,!*f,!R,!T,d,t,Q,b,Q,t")
1538 (match_operand:SI 1 "general_operand"
1539 "K,N0HS0,N1HS0,Os,L,b,d,R,T,d,d,*f,R,T,*f,*f,t,d,t,d,K,Q"))]
1540 "TARGET_ZARCH"
1541 "@
1542 lhi\t%0,%h1
1543 llilh\t%0,%i1
1544 llill\t%0,%i1
1545 iilf\t%0,%o1
1546 lay\t%0,%a1
1547 lrl\t%0,%1
1548 lr\t%0,%1
1549 l\t%0,%1
1550 ly\t%0,%1
1551 st\t%1,%0
1552 sty\t%1,%0
1553 ler\t%0,%1
1554 le\t%0,%1
1555 ley\t%0,%1
1556 ste\t%1,%0
1557 stey\t%1,%0
1558 ear\t%0,%1
1559 sar\t%0,%1
1560 stam\t%1,%1,%S0
1561 strl\t%1,%0
1562 mvhi\t%0,%1
1563 lam\t%0,%0,%S1"
1564 [(set_attr "op_type" "RI,RI,RI,RIL,RXY,RIL,RR,RX,RXY,RX,RXY,
1565 RR,RX,RXY,RX,RXY,RRE,RRE,RS,RIL,SIL,RS")
1566 (set_attr "type" "*,
1567 *,
1568 *,
1569 *,
1570 la,
1571 larl,
1572 lr,
1573 load,
1574 load,
1575 store,
1576 store,
1577 floadsf,
1578 floadsf,
1579 floadsf,
1580 fstoresf,
1581 fstoresf,
1582 *,
1583 *,
1584 *,
1585 larl,
1586 *,
1587 *")
1588 (set_attr "cpu_facility" "*,*,*,extimm,longdisp,z10,*,*,longdisp,*,longdisp,
1589 *,*,longdisp,*,longdisp,*,*,*,z10,z10,*")
1590 (set_attr "z10prop" "z10_fwd_A1,
1591 z10_fwd_E1,
1592 z10_fwd_E1,
1593 z10_fwd_A1,
1594 z10_fwd_A1,
1595 z10_fwd_A3,
1596 z10_fr_E1,
1597 z10_fwd_A3,
1598 z10_fwd_A3,
1599 z10_rec,
1600 z10_rec,
1601 *,
1602 *,
1603 *,
1604 *,
1605 *,
1606 z10_super_E1,
1607 z10_super,
1608 *,
1609 z10_rec,
1610 z10_super,
1611 *")])
1612
1613 (define_insn "*movsi_esa"
1614 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!R,d,t,Q,t")
1615 (match_operand:SI 1 "general_operand" "K,d,R,d,*f,R,*f,t,d,t,Q"))]
1616 "!TARGET_ZARCH"
1617 "@
1618 lhi\t%0,%h1
1619 lr\t%0,%1
1620 l\t%0,%1
1621 st\t%1,%0
1622 ler\t%0,%1
1623 le\t%0,%1
1624 ste\t%1,%0
1625 ear\t%0,%1
1626 sar\t%0,%1
1627 stam\t%1,%1,%S0
1628 lam\t%0,%0,%S1"
1629 [(set_attr "op_type" "RI,RR,RX,RX,RR,RX,RX,RRE,RRE,RS,RS")
1630 (set_attr "type" "*,lr,load,store,floadsf,floadsf,fstoresf,*,*,*,*")
1631 (set_attr "z10prop" "z10_fwd_A1,
1632 z10_fr_E1,
1633 z10_fwd_A3,
1634 z10_rec,
1635 *,
1636 *,
1637 *,
1638 z10_super_E1,
1639 z10_super,
1640 *,
1641 *")
1642 ])
1643
1644 (define_peephole2
1645 [(set (match_operand:SI 0 "register_operand" "")
1646 (mem:SI (match_operand 1 "address_operand" "")))]
1647 "!FP_REG_P (operands[0])
1648 && GET_CODE (operands[1]) == SYMBOL_REF
1649 && CONSTANT_POOL_ADDRESS_P (operands[1])
1650 && get_pool_mode (operands[1]) == SImode
1651 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1652 [(set (match_dup 0) (match_dup 2))]
1653 "operands[2] = get_pool_constant (operands[1]);")
1654
1655 (define_insn "*la_31"
1656 [(set (match_operand:SI 0 "register_operand" "=d,d")
1657 (match_operand:QI 1 "address_operand" "U,W"))]
1658 "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
1659 "@
1660 la\t%0,%a1
1661 lay\t%0,%a1"
1662 [(set_attr "op_type" "RX,RXY")
1663 (set_attr "type" "la")
1664 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1665
1666 (define_peephole2
1667 [(parallel
1668 [(set (match_operand:SI 0 "register_operand" "")
1669 (match_operand:QI 1 "address_operand" ""))
1670 (clobber (reg:CC CC_REGNUM))])]
1671 "!TARGET_64BIT
1672 && preferred_la_operand_p (operands[1], const0_rtx)"
1673 [(set (match_dup 0) (match_dup 1))]
1674 "")
1675
1676 (define_peephole2
1677 [(set (match_operand:SI 0 "register_operand" "")
1678 (match_operand:SI 1 "register_operand" ""))
1679 (parallel
1680 [(set (match_dup 0)
1681 (plus:SI (match_dup 0)
1682 (match_operand:SI 2 "nonmemory_operand" "")))
1683 (clobber (reg:CC CC_REGNUM))])]
1684 "!TARGET_64BIT
1685 && !reg_overlap_mentioned_p (operands[0], operands[2])
1686 && preferred_la_operand_p (operands[1], operands[2])"
1687 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
1688 "")
1689
1690 (define_insn "*la_31_and"
1691 [(set (match_operand:SI 0 "register_operand" "=d,d")
1692 (and:SI (match_operand:QI 1 "address_operand" "U,W")
1693 (const_int 2147483647)))]
1694 "!TARGET_64BIT"
1695 "@
1696 la\t%0,%a1
1697 lay\t%0,%a1"
1698 [(set_attr "op_type" "RX,RXY")
1699 (set_attr "type" "la")
1700 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1701
1702 (define_insn_and_split "*la_31_and_cc"
1703 [(set (match_operand:SI 0 "register_operand" "=d")
1704 (and:SI (match_operand:QI 1 "address_operand" "p")
1705 (const_int 2147483647)))
1706 (clobber (reg:CC CC_REGNUM))]
1707 "!TARGET_64BIT"
1708 "#"
1709 "&& reload_completed"
1710 [(set (match_dup 0)
1711 (and:SI (match_dup 1) (const_int 2147483647)))]
1712 ""
1713 [(set_attr "op_type" "RX")
1714 (set_attr "type" "la")])
1715
1716 (define_insn "force_la_31"
1717 [(set (match_operand:SI 0 "register_operand" "=d,d")
1718 (match_operand:QI 1 "address_operand" "U,W"))
1719 (use (const_int 0))]
1720 "!TARGET_64BIT"
1721 "@
1722 la\t%0,%a1
1723 lay\t%0,%a1"
1724 [(set_attr "op_type" "RX")
1725 (set_attr "type" "la")
1726 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1727
1728 ;
1729 ; movhi instruction pattern(s).
1730 ;
1731
1732 (define_expand "movhi"
1733 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1734 (match_operand:HI 1 "general_operand" ""))]
1735 ""
1736 {
1737 /* Make it explicit that loading a register from memory
1738 always sign-extends (at least) to SImode. */
1739 if (optimize && can_create_pseudo_p ()
1740 && register_operand (operands[0], VOIDmode)
1741 && GET_CODE (operands[1]) == MEM)
1742 {
1743 rtx tmp = gen_reg_rtx (SImode);
1744 rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
1745 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1746 operands[1] = gen_lowpart (HImode, tmp);
1747 }
1748 })
1749
1750 (define_insn "*movhi"
1751 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,d,R,T,b,Q")
1752 (match_operand:HI 1 "general_operand" " d,n,R,T,b,d,d,d,K"))]
1753 ""
1754 "@
1755 lr\t%0,%1
1756 lhi\t%0,%h1
1757 lh\t%0,%1
1758 lhy\t%0,%1
1759 lhrl\t%0,%1
1760 sth\t%1,%0
1761 sthy\t%1,%0
1762 sthrl\t%1,%0
1763 mvhhi\t%0,%1"
1764 [(set_attr "op_type" "RR,RI,RX,RXY,RIL,RX,RXY,RIL,SIL")
1765 (set_attr "type" "lr,*,*,*,larl,store,store,store,*")
1766 (set_attr "cpu_facility" "*,*,*,*,z10,*,*,z10,z10")
1767 (set_attr "z10prop" "z10_fr_E1,
1768 z10_fwd_A1,
1769 z10_super_E1,
1770 z10_super_E1,
1771 z10_super_E1,
1772 z10_rec,
1773 z10_rec,
1774 z10_rec,
1775 z10_super")])
1776
1777 (define_peephole2
1778 [(set (match_operand:HI 0 "register_operand" "")
1779 (mem:HI (match_operand 1 "address_operand" "")))]
1780 "GET_CODE (operands[1]) == SYMBOL_REF
1781 && CONSTANT_POOL_ADDRESS_P (operands[1])
1782 && get_pool_mode (operands[1]) == HImode
1783 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1784 [(set (match_dup 0) (match_dup 2))]
1785 "operands[2] = get_pool_constant (operands[1]);")
1786
1787 ;
1788 ; movqi instruction pattern(s).
1789 ;
1790
1791 (define_expand "movqi"
1792 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1793 (match_operand:QI 1 "general_operand" ""))]
1794 ""
1795 {
1796 /* On z/Architecture, zero-extending from memory to register
1797 is just as fast as a QImode load. */
1798 if (TARGET_ZARCH && optimize && can_create_pseudo_p ()
1799 && register_operand (operands[0], VOIDmode)
1800 && GET_CODE (operands[1]) == MEM)
1801 {
1802 rtx tmp = gen_reg_rtx (word_mode);
1803 rtx ext = gen_rtx_ZERO_EXTEND (word_mode, operands[1]);
1804 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1805 operands[1] = gen_lowpart (QImode, tmp);
1806 }
1807 })
1808
1809 (define_insn "*movqi"
1810 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S")
1811 (match_operand:QI 1 "general_operand" "d,n,R,T,d,d,n,n"))]
1812 ""
1813 "@
1814 lr\t%0,%1
1815 lhi\t%0,%b1
1816 ic\t%0,%1
1817 icy\t%0,%1
1818 stc\t%1,%0
1819 stcy\t%1,%0
1820 mvi\t%S0,%b1
1821 mviy\t%S0,%b1"
1822 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY")
1823 (set_attr "type" "lr,*,*,*,store,store,store,store")
1824 (set_attr "z10prop" "z10_fr_E1,
1825 z10_fwd_A1,
1826 z10_super_E1,
1827 z10_super_E1,
1828 z10_rec,
1829 z10_rec,
1830 z10_super,
1831 z10_super")])
1832
1833 (define_peephole2
1834 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1835 (mem:QI (match_operand 1 "address_operand" "")))]
1836 "GET_CODE (operands[1]) == SYMBOL_REF
1837 && CONSTANT_POOL_ADDRESS_P (operands[1])
1838 && get_pool_mode (operands[1]) == QImode
1839 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1840 [(set (match_dup 0) (match_dup 2))]
1841 "operands[2] = get_pool_constant (operands[1]);")
1842
1843 ;
1844 ; movstrictqi instruction pattern(s).
1845 ;
1846
1847 (define_insn "*movstrictqi"
1848 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
1849 (match_operand:QI 1 "memory_operand" "R,T"))]
1850 ""
1851 "@
1852 ic\t%0,%1
1853 icy\t%0,%1"
1854 [(set_attr "op_type" "RX,RXY")
1855 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
1856
1857 ;
1858 ; movstricthi instruction pattern(s).
1859 ;
1860
1861 (define_insn "*movstricthi"
1862 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
1863 (match_operand:HI 1 "memory_operand" "Q,S"))
1864 (clobber (reg:CC CC_REGNUM))]
1865 ""
1866 "@
1867 icm\t%0,3,%S1
1868 icmy\t%0,3,%S1"
1869 [(set_attr "op_type" "RS,RSY")
1870 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
1871
1872 ;
1873 ; movstrictsi instruction pattern(s).
1874 ;
1875
1876 (define_insn "movstrictsi"
1877 [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
1878 (match_operand:SI 1 "general_operand" "d,R,T,t"))]
1879 "TARGET_64BIT"
1880 "@
1881 lr\t%0,%1
1882 l\t%0,%1
1883 ly\t%0,%1
1884 ear\t%0,%1"
1885 [(set_attr "op_type" "RR,RX,RXY,RRE")
1886 (set_attr "type" "lr,load,load,*")
1887 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_super_E1")])
1888
1889 ;
1890 ; mov(tf|td) instruction pattern(s).
1891 ;
1892
1893 (define_expand "mov<mode>"
1894 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1895 (match_operand:TD_TF 1 "general_operand" ""))]
1896 ""
1897 "")
1898
1899 (define_insn "*mov<mode>_64"
1900 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o, d,QS, d,o")
1901 (match_operand:TD_TF 1 "general_operand" " G,f,o,f,QS, d,dRT,d"))]
1902 "TARGET_64BIT"
1903 "@
1904 lzxr\t%0
1905 lxr\t%0,%1
1906 #
1907 #
1908 lmg\t%0,%N0,%S1
1909 stmg\t%1,%N1,%S0
1910 #
1911 #"
1912 [(set_attr "op_type" "RRE,RRE,*,*,RSY,RSY,*,*")
1913 (set_attr "type" "fsimptf,fsimptf,*,*,lm,stm,*,*")])
1914
1915 (define_insn "*mov<mode>_31"
1916 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o")
1917 (match_operand:TD_TF 1 "general_operand" " G,f,o,f"))]
1918 "!TARGET_64BIT"
1919 "@
1920 lzxr\t%0
1921 lxr\t%0,%1
1922 #
1923 #"
1924 [(set_attr "op_type" "RRE,RRE,*,*")
1925 (set_attr "type" "fsimptf,fsimptf,*,*")])
1926
1927 ; TFmode in GPRs splitters
1928
1929 (define_split
1930 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1931 (match_operand:TD_TF 1 "general_operand" ""))]
1932 "TARGET_64BIT && reload_completed
1933 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
1934 [(set (match_dup 2) (match_dup 4))
1935 (set (match_dup 3) (match_dup 5))]
1936 {
1937 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
1938 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
1939 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
1940 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
1941 })
1942
1943 (define_split
1944 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1945 (match_operand:TD_TF 1 "general_operand" ""))]
1946 "TARGET_64BIT && reload_completed
1947 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
1948 [(set (match_dup 2) (match_dup 4))
1949 (set (match_dup 3) (match_dup 5))]
1950 {
1951 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
1952 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
1953 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
1954 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
1955 })
1956
1957 (define_split
1958 [(set (match_operand:TD_TF 0 "register_operand" "")
1959 (match_operand:TD_TF 1 "memory_operand" ""))]
1960 "TARGET_64BIT && reload_completed
1961 && !FP_REG_P (operands[0])
1962 && !s_operand (operands[1], VOIDmode)"
1963 [(set (match_dup 0) (match_dup 1))]
1964 {
1965 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
1966 s390_load_address (addr, XEXP (operands[1], 0));
1967 operands[1] = replace_equiv_address (operands[1], addr);
1968 })
1969
1970 ; TFmode in BFPs splitters
1971
1972 (define_split
1973 [(set (match_operand:TD_TF 0 "register_operand" "")
1974 (match_operand:TD_TF 1 "memory_operand" ""))]
1975 "reload_completed && offsettable_memref_p (operands[1])
1976 && FP_REG_P (operands[0])"
1977 [(set (match_dup 2) (match_dup 4))
1978 (set (match_dup 3) (match_dup 5))]
1979 {
1980 operands[2] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
1981 <MODE>mode, 0);
1982 operands[3] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
1983 <MODE>mode, 8);
1984 operands[4] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 0);
1985 operands[5] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 8);
1986 })
1987
1988 (define_split
1989 [(set (match_operand:TD_TF 0 "memory_operand" "")
1990 (match_operand:TD_TF 1 "register_operand" ""))]
1991 "reload_completed && offsettable_memref_p (operands[0])
1992 && FP_REG_P (operands[1])"
1993 [(set (match_dup 2) (match_dup 4))
1994 (set (match_dup 3) (match_dup 5))]
1995 {
1996 operands[2] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 0);
1997 operands[3] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 8);
1998 operands[4] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
1999 <MODE>mode, 0);
2000 operands[5] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2001 <MODE>mode, 8);
2002 })
2003
2004 ;
2005 ; mov(df|dd) instruction pattern(s).
2006 ;
2007
2008 (define_expand "mov<mode>"
2009 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2010 (match_operand:DD_DF 1 "general_operand" ""))]
2011 ""
2012 "")
2013
2014 (define_insn "*mov<mode>_64dfp"
2015 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2016 "=f,f,f,d,f,f,R,T,d, d,RT")
2017 (match_operand:DD_DF 1 "general_operand"
2018 " G,f,d,f,R,T,f,f,d,RT, d"))]
2019 "TARGET_64BIT && TARGET_DFP"
2020 "@
2021 lzdr\t%0
2022 ldr\t%0,%1
2023 ldgr\t%0,%1
2024 lgdr\t%0,%1
2025 ld\t%0,%1
2026 ldy\t%0,%1
2027 std\t%1,%0
2028 stdy\t%1,%0
2029 lgr\t%0,%1
2030 lg\t%0,%1
2031 stg\t%1,%0"
2032 [(set_attr "op_type" "RRE,RR,RRE,RRE,RX,RXY,RX,RXY,RRE,RXY,RXY")
2033 (set_attr "type" "fsimpdf,floaddf,floaddf,floaddf,floaddf,floaddf,
2034 fstoredf,fstoredf,lr,load,store")
2035 (set_attr "z10prop" "*,
2036 *,
2037 *,
2038 *,
2039 *,
2040 *,
2041 *,
2042 *,
2043 z10_fr_E1,
2044 z10_fwd_A3,
2045 z10_rec")
2046 ])
2047
2048 (define_insn "*mov<mode>_64"
2049 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "=f,f,f,f,R,T,d, d,RT")
2050 (match_operand:DD_DF 1 "general_operand" "G,f,R,T,f,f,d,RT, d"))]
2051 "TARGET_64BIT"
2052 "@
2053 lzdr\t%0
2054 ldr\t%0,%1
2055 ld\t%0,%1
2056 ldy\t%0,%1
2057 std\t%1,%0
2058 stdy\t%1,%0
2059 lgr\t%0,%1
2060 lg\t%0,%1
2061 stg\t%1,%0"
2062 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RRE,RXY,RXY")
2063 (set_attr "type" "fsimp<mode>,fload<mode>,fload<mode>,fload<mode>,
2064 fstore<mode>,fstore<mode>,lr,load,store")
2065 (set_attr "z10prop" "*,
2066 *,
2067 *,
2068 *,
2069 *,
2070 *,
2071 z10_fr_E1,
2072 z10_fwd_A3,
2073 z10_rec")])
2074
2075 (define_insn "*mov<mode>_31"
2076 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2077 "=f,f,f,f,R,T,d,d,Q,S, d,o")
2078 (match_operand:DD_DF 1 "general_operand"
2079 " G,f,R,T,f,f,Q,S,d,d,dPRT,d"))]
2080 "!TARGET_64BIT"
2081 "@
2082 lzdr\t%0
2083 ldr\t%0,%1
2084 ld\t%0,%1
2085 ldy\t%0,%1
2086 std\t%1,%0
2087 stdy\t%1,%0
2088 lm\t%0,%N0,%S1
2089 lmy\t%0,%N0,%S1
2090 stm\t%1,%N1,%S0
2091 stmy\t%1,%N1,%S0
2092 #
2093 #"
2094 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RS,RSY,RS,RSY,*,*")
2095 (set_attr "type" "fsimp<mode>,fload<mode>,fload<mode>,fload<mode>,
2096 fstore<mode>,fstore<mode>,lm,lm,stm,stm,*,*")])
2097
2098 (define_split
2099 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2100 (match_operand:DD_DF 1 "general_operand" ""))]
2101 "!TARGET_64BIT && reload_completed
2102 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
2103 [(set (match_dup 2) (match_dup 4))
2104 (set (match_dup 3) (match_dup 5))]
2105 {
2106 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2107 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2108 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2109 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
2110 })
2111
2112 (define_split
2113 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2114 (match_operand:DD_DF 1 "general_operand" ""))]
2115 "!TARGET_64BIT && reload_completed
2116 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
2117 [(set (match_dup 2) (match_dup 4))
2118 (set (match_dup 3) (match_dup 5))]
2119 {
2120 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2121 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2122 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2123 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
2124 })
2125
2126 (define_split
2127 [(set (match_operand:DD_DF 0 "register_operand" "")
2128 (match_operand:DD_DF 1 "memory_operand" ""))]
2129 "!TARGET_64BIT && reload_completed
2130 && !FP_REG_P (operands[0])
2131 && !s_operand (operands[1], VOIDmode)"
2132 [(set (match_dup 0) (match_dup 1))]
2133 {
2134 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
2135 s390_load_address (addr, XEXP (operands[1], 0));
2136 operands[1] = replace_equiv_address (operands[1], addr);
2137 })
2138
2139 ;
2140 ; mov(sf|sd) instruction pattern(s).
2141 ;
2142
2143 (define_insn "mov<mode>"
2144 [(set (match_operand:SD_SF 0 "nonimmediate_operand"
2145 "=f,f,f,f,R,T,d,d,d,R,T")
2146 (match_operand:SD_SF 1 "general_operand"
2147 " G,f,R,T,f,f,d,R,T,d,d"))]
2148 ""
2149 "@
2150 lzer\t%0
2151 ler\t%0,%1
2152 le\t%0,%1
2153 ley\t%0,%1
2154 ste\t%1,%0
2155 stey\t%1,%0
2156 lr\t%0,%1
2157 l\t%0,%1
2158 ly\t%0,%1
2159 st\t%1,%0
2160 sty\t%1,%0"
2161 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RR,RX,RXY,RX,RXY")
2162 (set_attr "type" "fsimp<mode>,fload<mode>,fload<mode>,fload<mode>,
2163 fstore<mode>,fstore<mode>,lr,load,load,store,store")
2164 (set_attr "z10prop" "*,
2165 *,
2166 *,
2167 *,
2168 *,
2169 *,
2170 z10_fr_E1,
2171 z10_fwd_A3,
2172 z10_fwd_A3,
2173 z10_rec,
2174 z10_rec")])
2175
2176 ;
2177 ; movcc instruction pattern
2178 ;
2179
2180 (define_insn "movcc"
2181 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
2182 (match_operand:CC 1 "nonimmediate_operand" "d,d,c,R,T,d,d"))]
2183 ""
2184 "@
2185 lr\t%0,%1
2186 tmh\t%1,12288
2187 ipm\t%0
2188 st\t%0,%1
2189 sty\t%0,%1
2190 l\t%1,%0
2191 ly\t%1,%0"
2192 [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
2193 (set_attr "type" "lr,*,*,store,store,load,load")
2194 (set_attr "z10prop" "z10_fr_E1,z10_super,*,z10_rec,z10_rec,z10_fwd_A3,z10_fwd_A3")])
2195
2196 ;
2197 ; Block move (MVC) patterns.
2198 ;
2199
2200 (define_insn "*mvc"
2201 [(set (match_operand:BLK 0 "memory_operand" "=Q")
2202 (match_operand:BLK 1 "memory_operand" "Q"))
2203 (use (match_operand 2 "const_int_operand" "n"))]
2204 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
2205 "mvc\t%O0(%2,%R0),%S1"
2206 [(set_attr "op_type" "SS")])
2207
2208 (define_peephole2
2209 [(parallel
2210 [(set (match_operand:BLK 0 "memory_operand" "")
2211 (match_operand:BLK 1 "memory_operand" ""))
2212 (use (match_operand 2 "const_int_operand" ""))])
2213 (parallel
2214 [(set (match_operand:BLK 3 "memory_operand" "")
2215 (match_operand:BLK 4 "memory_operand" ""))
2216 (use (match_operand 5 "const_int_operand" ""))])]
2217 "s390_offset_p (operands[0], operands[3], operands[2])
2218 && s390_offset_p (operands[1], operands[4], operands[2])
2219 && !s390_overlap_p (operands[0], operands[1],
2220 INTVAL (operands[2]) + INTVAL (operands[5]))
2221 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
2222 [(parallel
2223 [(set (match_dup 6) (match_dup 7))
2224 (use (match_dup 8))])]
2225 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
2226 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
2227 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
2228
2229
2230 ;
2231 ; load_multiple pattern(s).
2232 ;
2233 ; ??? Due to reload problems with replacing registers inside match_parallel
2234 ; we currently support load_multiple/store_multiple only after reload.
2235 ;
2236
2237 (define_expand "load_multiple"
2238 [(match_par_dup 3 [(set (match_operand 0 "" "")
2239 (match_operand 1 "" ""))
2240 (use (match_operand 2 "" ""))])]
2241 "reload_completed"
2242 {
2243 enum machine_mode mode;
2244 int regno;
2245 int count;
2246 rtx from;
2247 int i, off;
2248
2249 /* Support only loading a constant number of fixed-point registers from
2250 memory and only bother with this if more than two */
2251 if (GET_CODE (operands[2]) != CONST_INT
2252 || INTVAL (operands[2]) < 2
2253 || INTVAL (operands[2]) > 16
2254 || GET_CODE (operands[1]) != MEM
2255 || GET_CODE (operands[0]) != REG
2256 || REGNO (operands[0]) >= 16)
2257 FAIL;
2258
2259 count = INTVAL (operands[2]);
2260 regno = REGNO (operands[0]);
2261 mode = GET_MODE (operands[0]);
2262 if (mode != SImode && mode != word_mode)
2263 FAIL;
2264
2265 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2266 if (!can_create_pseudo_p ())
2267 {
2268 if (GET_CODE (XEXP (operands[1], 0)) == REG)
2269 {
2270 from = XEXP (operands[1], 0);
2271 off = 0;
2272 }
2273 else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
2274 && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
2275 && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
2276 {
2277 from = XEXP (XEXP (operands[1], 0), 0);
2278 off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
2279 }
2280 else
2281 FAIL;
2282 }
2283 else
2284 {
2285 from = force_reg (Pmode, XEXP (operands[1], 0));
2286 off = 0;
2287 }
2288
2289 for (i = 0; i < count; i++)
2290 XVECEXP (operands[3], 0, i)
2291 = gen_rtx_SET (VOIDmode, gen_rtx_REG (mode, regno + i),
2292 change_address (operands[1], mode,
2293 plus_constant (from, off + i * GET_MODE_SIZE (mode))));
2294 })
2295
2296 (define_insn "*load_multiple_di"
2297 [(match_parallel 0 "load_multiple_operation"
2298 [(set (match_operand:DI 1 "register_operand" "=r")
2299 (match_operand:DI 2 "s_operand" "QS"))])]
2300 "reload_completed && word_mode == DImode"
2301 {
2302 int words = XVECLEN (operands[0], 0);
2303 operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
2304 return "lmg\t%1,%0,%S2";
2305 }
2306 [(set_attr "op_type" "RSY")
2307 (set_attr "type" "lm")])
2308
2309 (define_insn "*load_multiple_si"
2310 [(match_parallel 0 "load_multiple_operation"
2311 [(set (match_operand:SI 1 "register_operand" "=r,r")
2312 (match_operand:SI 2 "s_operand" "Q,S"))])]
2313 "reload_completed"
2314 {
2315 int words = XVECLEN (operands[0], 0);
2316 operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
2317 return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
2318 }
2319 [(set_attr "op_type" "RS,RSY")
2320 (set_attr "type" "lm")])
2321
2322 ;
2323 ; store multiple pattern(s).
2324 ;
2325
2326 (define_expand "store_multiple"
2327 [(match_par_dup 3 [(set (match_operand 0 "" "")
2328 (match_operand 1 "" ""))
2329 (use (match_operand 2 "" ""))])]
2330 "reload_completed"
2331 {
2332 enum machine_mode mode;
2333 int regno;
2334 int count;
2335 rtx to;
2336 int i, off;
2337
2338 /* Support only storing a constant number of fixed-point registers to
2339 memory and only bother with this if more than two. */
2340 if (GET_CODE (operands[2]) != CONST_INT
2341 || INTVAL (operands[2]) < 2
2342 || INTVAL (operands[2]) > 16
2343 || GET_CODE (operands[0]) != MEM
2344 || GET_CODE (operands[1]) != REG
2345 || REGNO (operands[1]) >= 16)
2346 FAIL;
2347
2348 count = INTVAL (operands[2]);
2349 regno = REGNO (operands[1]);
2350 mode = GET_MODE (operands[1]);
2351 if (mode != SImode && mode != word_mode)
2352 FAIL;
2353
2354 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2355
2356 if (!can_create_pseudo_p ())
2357 {
2358 if (GET_CODE (XEXP (operands[0], 0)) == REG)
2359 {
2360 to = XEXP (operands[0], 0);
2361 off = 0;
2362 }
2363 else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
2364 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
2365 && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
2366 {
2367 to = XEXP (XEXP (operands[0], 0), 0);
2368 off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
2369 }
2370 else
2371 FAIL;
2372 }
2373 else
2374 {
2375 to = force_reg (Pmode, XEXP (operands[0], 0));
2376 off = 0;
2377 }
2378
2379 for (i = 0; i < count; i++)
2380 XVECEXP (operands[3], 0, i)
2381 = gen_rtx_SET (VOIDmode,
2382 change_address (operands[0], mode,
2383 plus_constant (to, off + i * GET_MODE_SIZE (mode))),
2384 gen_rtx_REG (mode, regno + i));
2385 })
2386
2387 (define_insn "*store_multiple_di"
2388 [(match_parallel 0 "store_multiple_operation"
2389 [(set (match_operand:DI 1 "s_operand" "=QS")
2390 (match_operand:DI 2 "register_operand" "r"))])]
2391 "reload_completed && word_mode == DImode"
2392 {
2393 int words = XVECLEN (operands[0], 0);
2394 operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
2395 return "stmg\t%2,%0,%S1";
2396 }
2397 [(set_attr "op_type" "RSY")
2398 (set_attr "type" "stm")])
2399
2400
2401 (define_insn "*store_multiple_si"
2402 [(match_parallel 0 "store_multiple_operation"
2403 [(set (match_operand:SI 1 "s_operand" "=Q,S")
2404 (match_operand:SI 2 "register_operand" "r,r"))])]
2405 "reload_completed"
2406 {
2407 int words = XVECLEN (operands[0], 0);
2408 operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
2409 return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
2410 }
2411 [(set_attr "op_type" "RS,RSY")
2412 (set_attr "type" "stm")])
2413
2414 ;;
2415 ;; String instructions.
2416 ;;
2417
2418 (define_insn "*execute_rl"
2419 [(match_parallel 0 ""
2420 [(unspec [(match_operand 1 "register_operand" "a")
2421 (match_operand 2 "" "")
2422 (match_operand:SI 3 "larl_operand" "X")] UNSPEC_EXECUTE)])]
2423 "TARGET_Z10 && GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2424 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2425 "exrl\t%1,%3"
2426 [(set_attr "op_type" "RIL")
2427 (set_attr "type" "cs")])
2428
2429 (define_insn "*execute"
2430 [(match_parallel 0 ""
2431 [(unspec [(match_operand 1 "register_operand" "a")
2432 (match_operand:BLK 2 "memory_operand" "R")
2433 (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
2434 "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2435 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2436 "ex\t%1,%2"
2437 [(set_attr "op_type" "RX")
2438 (set_attr "type" "cs")])
2439
2440
2441 ;
2442 ; strlenM instruction pattern(s).
2443 ;
2444
2445 (define_expand "strlen<mode>"
2446 [(set (reg:SI 0) (match_operand:SI 2 "immediate_operand" ""))
2447 (parallel
2448 [(set (match_dup 4)
2449 (unspec:P [(const_int 0)
2450 (match_operand:BLK 1 "memory_operand" "")
2451 (reg:SI 0)
2452 (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
2453 (clobber (scratch:P))
2454 (clobber (reg:CC CC_REGNUM))])
2455 (parallel
2456 [(set (match_operand:P 0 "register_operand" "")
2457 (minus:P (match_dup 4) (match_dup 5)))
2458 (clobber (reg:CC CC_REGNUM))])]
2459 ""
2460 {
2461 operands[4] = gen_reg_rtx (Pmode);
2462 operands[5] = gen_reg_rtx (Pmode);
2463 emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
2464 operands[1] = replace_equiv_address (operands[1], operands[5]);
2465 })
2466
2467 (define_insn "*strlen<mode>"
2468 [(set (match_operand:P 0 "register_operand" "=a")
2469 (unspec:P [(match_operand:P 2 "general_operand" "0")
2470 (mem:BLK (match_operand:P 3 "register_operand" "1"))
2471 (reg:SI 0)
2472 (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
2473 (clobber (match_scratch:P 1 "=a"))
2474 (clobber (reg:CC CC_REGNUM))]
2475 ""
2476 "srst\t%0,%1\;jo\t.-4"
2477 [(set_attr "length" "8")
2478 (set_attr "type" "vs")])
2479
2480 ;
2481 ; cmpstrM instruction pattern(s).
2482 ;
2483
2484 (define_expand "cmpstrsi"
2485 [(set (reg:SI 0) (const_int 0))
2486 (parallel
2487 [(clobber (match_operand 3 "" ""))
2488 (clobber (match_dup 4))
2489 (set (reg:CCU CC_REGNUM)
2490 (compare:CCU (match_operand:BLK 1 "memory_operand" "")
2491 (match_operand:BLK 2 "memory_operand" "")))
2492 (use (reg:SI 0))])
2493 (parallel
2494 [(set (match_operand:SI 0 "register_operand" "=d")
2495 (unspec:SI [(reg:CCU CC_REGNUM)] UNSPEC_CCU_TO_INT))
2496 (clobber (reg:CC CC_REGNUM))])]
2497 ""
2498 {
2499 /* As the result of CMPINT is inverted compared to what we need,
2500 we have to swap the operands. */
2501 rtx op1 = operands[2];
2502 rtx op2 = operands[1];
2503 rtx addr1 = gen_reg_rtx (Pmode);
2504 rtx addr2 = gen_reg_rtx (Pmode);
2505
2506 emit_move_insn (addr1, force_operand (XEXP (op1, 0), NULL_RTX));
2507 emit_move_insn (addr2, force_operand (XEXP (op2, 0), NULL_RTX));
2508 operands[1] = replace_equiv_address_nv (op1, addr1);
2509 operands[2] = replace_equiv_address_nv (op2, addr2);
2510 operands[3] = addr1;
2511 operands[4] = addr2;
2512 })
2513
2514 (define_insn "*cmpstr<mode>"
2515 [(clobber (match_operand:P 0 "register_operand" "=d"))
2516 (clobber (match_operand:P 1 "register_operand" "=d"))
2517 (set (reg:CCU CC_REGNUM)
2518 (compare:CCU (mem:BLK (match_operand:P 2 "register_operand" "0"))
2519 (mem:BLK (match_operand:P 3 "register_operand" "1"))))
2520 (use (reg:SI 0))]
2521 ""
2522 "clst\t%0,%1\;jo\t.-4"
2523 [(set_attr "length" "8")
2524 (set_attr "type" "vs")])
2525
2526 ;
2527 ; movstr instruction pattern.
2528 ;
2529
2530 (define_expand "movstr"
2531 [(set (reg:SI 0) (const_int 0))
2532 (parallel
2533 [(clobber (match_dup 3))
2534 (set (match_operand:BLK 1 "memory_operand" "")
2535 (match_operand:BLK 2 "memory_operand" ""))
2536 (set (match_operand 0 "register_operand" "")
2537 (unspec [(match_dup 1)
2538 (match_dup 2)
2539 (reg:SI 0)] UNSPEC_MVST))
2540 (clobber (reg:CC CC_REGNUM))])]
2541 ""
2542 {
2543 rtx addr1 = gen_reg_rtx (Pmode);
2544 rtx addr2 = gen_reg_rtx (Pmode);
2545
2546 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2547 emit_move_insn (addr2, force_operand (XEXP (operands[2], 0), NULL_RTX));
2548 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2549 operands[2] = replace_equiv_address_nv (operands[2], addr2);
2550 operands[3] = addr2;
2551 })
2552
2553 (define_insn "*movstr"
2554 [(clobber (match_operand:P 2 "register_operand" "=d"))
2555 (set (mem:BLK (match_operand:P 1 "register_operand" "0"))
2556 (mem:BLK (match_operand:P 3 "register_operand" "2")))
2557 (set (match_operand:P 0 "register_operand" "=d")
2558 (unspec [(mem:BLK (match_dup 1))
2559 (mem:BLK (match_dup 3))
2560 (reg:SI 0)] UNSPEC_MVST))
2561 (clobber (reg:CC CC_REGNUM))]
2562 ""
2563 "mvst\t%1,%2\;jo\t.-4"
2564 [(set_attr "length" "8")
2565 (set_attr "type" "vs")])
2566
2567
2568 ;
2569 ; movmemM instruction pattern(s).
2570 ;
2571
2572 (define_expand "movmem<mode>"
2573 [(set (match_operand:BLK 0 "memory_operand" "") ; destination
2574 (match_operand:BLK 1 "memory_operand" "")) ; source
2575 (use (match_operand:GPR 2 "general_operand" "")) ; count
2576 (match_operand 3 "" "")]
2577 ""
2578 "s390_expand_movmem (operands[0], operands[1], operands[2]); DONE;")
2579
2580 ; Move a block that is up to 256 bytes in length.
2581 ; The block length is taken as (operands[2] % 256) + 1.
2582
2583 (define_expand "movmem_short"
2584 [(parallel
2585 [(set (match_operand:BLK 0 "memory_operand" "")
2586 (match_operand:BLK 1 "memory_operand" ""))
2587 (use (match_operand 2 "nonmemory_operand" ""))
2588 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2589 (clobber (match_dup 3))])]
2590 ""
2591 "operands[3] = gen_rtx_SCRATCH (Pmode);")
2592
2593 (define_insn "*movmem_short"
2594 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
2595 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q"))
2596 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
2597 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
2598 (clobber (match_scratch 4 "=X,X,X,&a"))]
2599 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2600 && GET_MODE (operands[4]) == Pmode"
2601 "#"
2602 [(set_attr "type" "cs")
2603 (set_attr "cpu_facility" "*,*,z10,*")])
2604
2605 (define_split
2606 [(set (match_operand:BLK 0 "memory_operand" "")
2607 (match_operand:BLK 1 "memory_operand" ""))
2608 (use (match_operand 2 "const_int_operand" ""))
2609 (use (match_operand 3 "immediate_operand" ""))
2610 (clobber (scratch))]
2611 "reload_completed"
2612 [(parallel
2613 [(set (match_dup 0) (match_dup 1))
2614 (use (match_dup 2))])]
2615 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2616
2617 (define_split
2618 [(set (match_operand:BLK 0 "memory_operand" "")
2619 (match_operand:BLK 1 "memory_operand" ""))
2620 (use (match_operand 2 "register_operand" ""))
2621 (use (match_operand 3 "memory_operand" ""))
2622 (clobber (scratch))]
2623 "reload_completed"
2624 [(parallel
2625 [(unspec [(match_dup 2) (match_dup 3)
2626 (const_int 0)] UNSPEC_EXECUTE)
2627 (set (match_dup 0) (match_dup 1))
2628 (use (const_int 1))])]
2629 "")
2630
2631 (define_split
2632 [(set (match_operand:BLK 0 "memory_operand" "")
2633 (match_operand:BLK 1 "memory_operand" ""))
2634 (use (match_operand 2 "register_operand" ""))
2635 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2636 (clobber (scratch))]
2637 "TARGET_Z10 && reload_completed"
2638 [(parallel
2639 [(unspec [(match_dup 2) (const_int 0)
2640 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2641 (set (match_dup 0) (match_dup 1))
2642 (use (const_int 1))])]
2643 "operands[3] = gen_label_rtx ();")
2644
2645 (define_split
2646 [(set (match_operand:BLK 0 "memory_operand" "")
2647 (match_operand:BLK 1 "memory_operand" ""))
2648 (use (match_operand 2 "register_operand" ""))
2649 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2650 (clobber (match_operand 3 "register_operand" ""))]
2651 "reload_completed && TARGET_CPU_ZARCH"
2652 [(set (match_dup 3) (label_ref (match_dup 4)))
2653 (parallel
2654 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
2655 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2656 (set (match_dup 0) (match_dup 1))
2657 (use (const_int 1))])]
2658 "operands[4] = gen_label_rtx ();")
2659
2660 ; Move a block of arbitrary length.
2661
2662 (define_expand "movmem_long"
2663 [(parallel
2664 [(clobber (match_dup 2))
2665 (clobber (match_dup 3))
2666 (set (match_operand:BLK 0 "memory_operand" "")
2667 (match_operand:BLK 1 "memory_operand" ""))
2668 (use (match_operand 2 "general_operand" ""))
2669 (use (match_dup 3))
2670 (clobber (reg:CC CC_REGNUM))])]
2671 ""
2672 {
2673 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2674 rtx reg0 = gen_reg_rtx (dword_mode);
2675 rtx reg1 = gen_reg_rtx (dword_mode);
2676 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2677 rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
2678 rtx len0 = gen_lowpart (Pmode, reg0);
2679 rtx len1 = gen_lowpart (Pmode, reg1);
2680
2681 emit_clobber (reg0);
2682 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2683 emit_move_insn (len0, operands[2]);
2684
2685 emit_clobber (reg1);
2686 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2687 emit_move_insn (len1, operands[2]);
2688
2689 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2690 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2691 operands[2] = reg0;
2692 operands[3] = reg1;
2693 })
2694
2695 (define_insn "*movmem_long"
2696 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2697 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
2698 (set (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
2699 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0)))
2700 (use (match_dup 2))
2701 (use (match_dup 3))
2702 (clobber (reg:CC CC_REGNUM))]
2703 ""
2704 "mvcle\t%0,%1,0\;jo\t.-4"
2705 [(set_attr "length" "8")
2706 (set_attr "type" "vs")])
2707
2708
2709 ;
2710 ; Test data class.
2711 ;
2712
2713 (define_expand "signbit<mode>2"
2714 [(set (reg:CCZ CC_REGNUM)
2715 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
2716 (match_dup 2)]
2717 UNSPEC_TDC_INSN))
2718 (set (match_operand:SI 0 "register_operand" "=d")
2719 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CCZ_TO_INT))]
2720 "TARGET_HARD_FLOAT"
2721 {
2722 operands[2] = GEN_INT (S390_TDC_SIGNBIT_SET);
2723 })
2724
2725 (define_expand "isinf<mode>2"
2726 [(set (reg:CCZ CC_REGNUM)
2727 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
2728 (match_dup 2)]
2729 UNSPEC_TDC_INSN))
2730 (set (match_operand:SI 0 "register_operand" "=d")
2731 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CCZ_TO_INT))]
2732 "TARGET_HARD_FLOAT"
2733 {
2734 operands[2] = GEN_INT (S390_TDC_INFINITY);
2735 })
2736
2737 ; This insn is used to generate all variants of the Test Data Class
2738 ; instruction, namely tcxb, tcdb, and tceb. The insn's first operand
2739 ; is the register to be tested and the second one is the bit mask
2740 ; specifying the required test(s).
2741 ;
2742 (define_insn "*TDC_insn_<mode>"
2743 [(set (reg:CCZ CC_REGNUM)
2744 (unspec:CCZ [(match_operand:FP_ALL 0 "register_operand" "f")
2745 (match_operand:SI 1 "const_int_operand")] UNSPEC_TDC_INSN))]
2746 "TARGET_HARD_FLOAT"
2747 "t<_d>c<xde><bt>\t%0,%1"
2748 [(set_attr "op_type" "RXE")
2749 (set_attr "type" "fsimp<mode>")])
2750
2751 (define_insn_and_split "*ccz_to_int"
2752 [(set (match_operand:SI 0 "register_operand" "=d")
2753 (unspec:SI [(match_operand:CCZ 1 "register_operand" "0")]
2754 UNSPEC_CCZ_TO_INT))]
2755 ""
2756 "#"
2757 "reload_completed"
2758 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 28)))])
2759
2760
2761 ;
2762 ; setmemM instruction pattern(s).
2763 ;
2764
2765 (define_expand "setmem<mode>"
2766 [(set (match_operand:BLK 0 "memory_operand" "")
2767 (match_operand:QI 2 "general_operand" ""))
2768 (use (match_operand:GPR 1 "general_operand" ""))
2769 (match_operand 3 "" "")]
2770 ""
2771 "s390_expand_setmem (operands[0], operands[1], operands[2]); DONE;")
2772
2773 ; Clear a block that is up to 256 bytes in length.
2774 ; The block length is taken as (operands[1] % 256) + 1.
2775
2776 (define_expand "clrmem_short"
2777 [(parallel
2778 [(set (match_operand:BLK 0 "memory_operand" "")
2779 (const_int 0))
2780 (use (match_operand 1 "nonmemory_operand" ""))
2781 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2782 (clobber (match_dup 2))
2783 (clobber (reg:CC CC_REGNUM))])]
2784 ""
2785 "operands[2] = gen_rtx_SCRATCH (Pmode);")
2786
2787 (define_insn "*clrmem_short"
2788 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
2789 (const_int 0))
2790 (use (match_operand 1 "nonmemory_operand" "n,a,a,a"))
2791 (use (match_operand 2 "immediate_operand" "X,R,X,X"))
2792 (clobber (match_scratch 3 "=X,X,X,&a"))
2793 (clobber (reg:CC CC_REGNUM))]
2794 "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)
2795 && GET_MODE (operands[3]) == Pmode"
2796 "#"
2797 [(set_attr "type" "cs")
2798 (set_attr "cpu_facility" "*,*,z10,*")])
2799
2800 (define_split
2801 [(set (match_operand:BLK 0 "memory_operand" "")
2802 (const_int 0))
2803 (use (match_operand 1 "const_int_operand" ""))
2804 (use (match_operand 2 "immediate_operand" ""))
2805 (clobber (scratch))
2806 (clobber (reg:CC CC_REGNUM))]
2807 "reload_completed"
2808 [(parallel
2809 [(set (match_dup 0) (const_int 0))
2810 (use (match_dup 1))
2811 (clobber (reg:CC CC_REGNUM))])]
2812 "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
2813
2814 (define_split
2815 [(set (match_operand:BLK 0 "memory_operand" "")
2816 (const_int 0))
2817 (use (match_operand 1 "register_operand" ""))
2818 (use (match_operand 2 "memory_operand" ""))
2819 (clobber (scratch))
2820 (clobber (reg:CC CC_REGNUM))]
2821 "reload_completed"
2822 [(parallel
2823 [(unspec [(match_dup 1) (match_dup 2)
2824 (const_int 0)] UNSPEC_EXECUTE)
2825 (set (match_dup 0) (const_int 0))
2826 (use (const_int 1))
2827 (clobber (reg:CC CC_REGNUM))])]
2828 "")
2829
2830 (define_split
2831 [(set (match_operand:BLK 0 "memory_operand" "")
2832 (const_int 0))
2833 (use (match_operand 1 "register_operand" ""))
2834 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2835 (clobber (scratch))
2836 (clobber (reg:CC CC_REGNUM))]
2837 "TARGET_Z10 && reload_completed"
2838 [(parallel
2839 [(unspec [(match_dup 1) (const_int 0)
2840 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2841 (set (match_dup 0) (const_int 0))
2842 (use (const_int 1))
2843 (clobber (reg:CC CC_REGNUM))])]
2844 "operands[3] = gen_label_rtx ();")
2845
2846 (define_split
2847 [(set (match_operand:BLK 0 "memory_operand" "")
2848 (const_int 0))
2849 (use (match_operand 1 "register_operand" ""))
2850 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2851 (clobber (match_operand 2 "register_operand" ""))
2852 (clobber (reg:CC CC_REGNUM))]
2853 "reload_completed && TARGET_CPU_ZARCH"
2854 [(set (match_dup 2) (label_ref (match_dup 3)))
2855 (parallel
2856 [(unspec [(match_dup 1) (mem:BLK (match_dup 2))
2857 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2858 (set (match_dup 0) (const_int 0))
2859 (use (const_int 1))
2860 (clobber (reg:CC CC_REGNUM))])]
2861 "operands[3] = gen_label_rtx ();")
2862
2863 ; Initialize a block of arbitrary length with (operands[2] % 256).
2864
2865 (define_expand "setmem_long"
2866 [(parallel
2867 [(clobber (match_dup 1))
2868 (set (match_operand:BLK 0 "memory_operand" "")
2869 (match_operand 2 "shift_count_or_setmem_operand" ""))
2870 (use (match_operand 1 "general_operand" ""))
2871 (use (match_dup 3))
2872 (clobber (reg:CC CC_REGNUM))])]
2873 ""
2874 {
2875 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2876 rtx reg0 = gen_reg_rtx (dword_mode);
2877 rtx reg1 = gen_reg_rtx (dword_mode);
2878 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2879 rtx len0 = gen_lowpart (Pmode, reg0);
2880
2881 emit_clobber (reg0);
2882 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2883 emit_move_insn (len0, operands[1]);
2884
2885 emit_move_insn (reg1, const0_rtx);
2886
2887 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2888 operands[1] = reg0;
2889 operands[3] = reg1;
2890 })
2891
2892 (define_insn "*setmem_long"
2893 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2894 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
2895 (match_operand 2 "shift_count_or_setmem_operand" "Y"))
2896 (use (match_dup 3))
2897 (use (match_operand:<DBL> 1 "register_operand" "d"))
2898 (clobber (reg:CC CC_REGNUM))]
2899 ""
2900 "mvcle\t%0,%1,%Y2\;jo\t.-4"
2901 [(set_attr "length" "8")
2902 (set_attr "type" "vs")])
2903
2904 (define_insn "*setmem_long_and"
2905 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2906 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
2907 (and (match_operand 2 "shift_count_or_setmem_operand" "Y")
2908 (match_operand 4 "const_int_operand" "n")))
2909 (use (match_dup 3))
2910 (use (match_operand:<DBL> 1 "register_operand" "d"))
2911 (clobber (reg:CC CC_REGNUM))]
2912 "(INTVAL (operands[4]) & 255) == 255"
2913 "mvcle\t%0,%1,%Y2\;jo\t.-4"
2914 [(set_attr "length" "8")
2915 (set_attr "type" "vs")])
2916 ;
2917 ; cmpmemM instruction pattern(s).
2918 ;
2919
2920 (define_expand "cmpmemsi"
2921 [(set (match_operand:SI 0 "register_operand" "")
2922 (compare:SI (match_operand:BLK 1 "memory_operand" "")
2923 (match_operand:BLK 2 "memory_operand" "") ) )
2924 (use (match_operand:SI 3 "general_operand" ""))
2925 (use (match_operand:SI 4 "" ""))]
2926 ""
2927 "s390_expand_cmpmem (operands[0], operands[1],
2928 operands[2], operands[3]); DONE;")
2929
2930 ; Compare a block that is up to 256 bytes in length.
2931 ; The block length is taken as (operands[2] % 256) + 1.
2932
2933 (define_expand "cmpmem_short"
2934 [(parallel
2935 [(set (reg:CCU CC_REGNUM)
2936 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2937 (match_operand:BLK 1 "memory_operand" "")))
2938 (use (match_operand 2 "nonmemory_operand" ""))
2939 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2940 (clobber (match_dup 3))])]
2941 ""
2942 "operands[3] = gen_rtx_SCRATCH (Pmode);")
2943
2944 (define_insn "*cmpmem_short"
2945 [(set (reg:CCU CC_REGNUM)
2946 (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q,Q")
2947 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q")))
2948 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
2949 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
2950 (clobber (match_scratch 4 "=X,X,X,&a"))]
2951 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2952 && GET_MODE (operands[4]) == Pmode"
2953 "#"
2954 [(set_attr "type" "cs")
2955 (set_attr "cpu_facility" "*,*,z10,*")])
2956
2957 (define_split
2958 [(set (reg:CCU CC_REGNUM)
2959 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2960 (match_operand:BLK 1 "memory_operand" "")))
2961 (use (match_operand 2 "const_int_operand" ""))
2962 (use (match_operand 3 "immediate_operand" ""))
2963 (clobber (scratch))]
2964 "reload_completed"
2965 [(parallel
2966 [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2967 (use (match_dup 2))])]
2968 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2969
2970 (define_split
2971 [(set (reg:CCU CC_REGNUM)
2972 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2973 (match_operand:BLK 1 "memory_operand" "")))
2974 (use (match_operand 2 "register_operand" ""))
2975 (use (match_operand 3 "memory_operand" ""))
2976 (clobber (scratch))]
2977 "reload_completed"
2978 [(parallel
2979 [(unspec [(match_dup 2) (match_dup 3)
2980 (const_int 0)] UNSPEC_EXECUTE)
2981 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2982 (use (const_int 1))])]
2983 "")
2984
2985 (define_split
2986 [(set (reg:CCU CC_REGNUM)
2987 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2988 (match_operand:BLK 1 "memory_operand" "")))
2989 (use (match_operand 2 "register_operand" ""))
2990 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2991 (clobber (scratch))]
2992 "TARGET_Z10 && reload_completed"
2993 [(parallel
2994 [(unspec [(match_dup 2) (const_int 0)
2995 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2996 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2997 (use (const_int 1))])]
2998 "operands[4] = gen_label_rtx ();")
2999
3000 (define_split
3001 [(set (reg:CCU CC_REGNUM)
3002 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3003 (match_operand:BLK 1 "memory_operand" "")))
3004 (use (match_operand 2 "register_operand" ""))
3005 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3006 (clobber (match_operand 3 "register_operand" ""))]
3007 "reload_completed && TARGET_CPU_ZARCH"
3008 [(set (match_dup 3) (label_ref (match_dup 4)))
3009 (parallel
3010 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
3011 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3012 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3013 (use (const_int 1))])]
3014 "operands[4] = gen_label_rtx ();")
3015
3016 ; Compare a block of arbitrary length.
3017
3018 (define_expand "cmpmem_long"
3019 [(parallel
3020 [(clobber (match_dup 2))
3021 (clobber (match_dup 3))
3022 (set (reg:CCU CC_REGNUM)
3023 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3024 (match_operand:BLK 1 "memory_operand" "")))
3025 (use (match_operand 2 "general_operand" ""))
3026 (use (match_dup 3))])]
3027 ""
3028 {
3029 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
3030 rtx reg0 = gen_reg_rtx (dword_mode);
3031 rtx reg1 = gen_reg_rtx (dword_mode);
3032 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
3033 rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
3034 rtx len0 = gen_lowpart (Pmode, reg0);
3035 rtx len1 = gen_lowpart (Pmode, reg1);
3036
3037 emit_clobber (reg0);
3038 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3039 emit_move_insn (len0, operands[2]);
3040
3041 emit_clobber (reg1);
3042 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3043 emit_move_insn (len1, operands[2]);
3044
3045 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3046 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3047 operands[2] = reg0;
3048 operands[3] = reg1;
3049 })
3050
3051 (define_insn "*cmpmem_long"
3052 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3053 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
3054 (set (reg:CCU CC_REGNUM)
3055 (compare:CCU (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
3056 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0))))
3057 (use (match_dup 2))
3058 (use (match_dup 3))]
3059 ""
3060 "clcle\t%0,%1,0\;jo\t.-4"
3061 [(set_attr "length" "8")
3062 (set_attr "type" "vs")])
3063
3064 ; Convert CCUmode condition code to integer.
3065 ; Result is zero if EQ, positive if LTU, negative if GTU.
3066
3067 (define_insn_and_split "cmpint"
3068 [(set (match_operand:SI 0 "register_operand" "=d")
3069 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3070 UNSPEC_CCU_TO_INT))
3071 (clobber (reg:CC CC_REGNUM))]
3072 ""
3073 "#"
3074 "reload_completed"
3075 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3076 (parallel
3077 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
3078 (clobber (reg:CC CC_REGNUM))])])
3079
3080 (define_insn_and_split "*cmpint_cc"
3081 [(set (reg CC_REGNUM)
3082 (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3083 UNSPEC_CCU_TO_INT)
3084 (const_int 0)))
3085 (set (match_operand:SI 0 "register_operand" "=d")
3086 (unspec:SI [(match_dup 1)] UNSPEC_CCU_TO_INT))]
3087 "s390_match_ccmode (insn, CCSmode)"
3088 "#"
3089 "&& reload_completed"
3090 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3091 (parallel
3092 [(set (match_dup 2) (match_dup 3))
3093 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
3094 {
3095 rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
3096 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3097 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3098 })
3099
3100 (define_insn_and_split "*cmpint_sign"
3101 [(set (match_operand:DI 0 "register_operand" "=d")
3102 (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3103 UNSPEC_CCU_TO_INT)))
3104 (clobber (reg:CC CC_REGNUM))]
3105 "TARGET_64BIT"
3106 "#"
3107 "&& reload_completed"
3108 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3109 (parallel
3110 [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
3111 (clobber (reg:CC CC_REGNUM))])])
3112
3113 (define_insn_and_split "*cmpint_sign_cc"
3114 [(set (reg CC_REGNUM)
3115 (compare (ashiftrt:DI (ashift:DI (subreg:DI
3116 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3117 UNSPEC_CCU_TO_INT) 0)
3118 (const_int 32)) (const_int 32))
3119 (const_int 0)))
3120 (set (match_operand:DI 0 "register_operand" "=d")
3121 (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_CCU_TO_INT)))]
3122 "s390_match_ccmode (insn, CCSmode) && TARGET_64BIT"
3123 "#"
3124 "&& reload_completed"
3125 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3126 (parallel
3127 [(set (match_dup 2) (match_dup 3))
3128 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
3129 {
3130 rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
3131 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3132 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3133 })
3134
3135
3136 ;;
3137 ;;- Conversion instructions.
3138 ;;
3139
3140 (define_insn "*sethighpartsi"
3141 [(set (match_operand:SI 0 "register_operand" "=d,d")
3142 (unspec:SI [(match_operand:BLK 1 "s_operand" "Q,S")
3143 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
3144 (clobber (reg:CC CC_REGNUM))]
3145 ""
3146 "@
3147 icm\t%0,%2,%S1
3148 icmy\t%0,%2,%S1"
3149 [(set_attr "op_type" "RS,RSY")
3150 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3151
3152 (define_insn "*sethighpartdi_64"
3153 [(set (match_operand:DI 0 "register_operand" "=d")
3154 (unspec:DI [(match_operand:BLK 1 "s_operand" "QS")
3155 (match_operand 2 "const_int_operand" "n")] UNSPEC_ICM))
3156 (clobber (reg:CC CC_REGNUM))]
3157 "TARGET_64BIT"
3158 "icmh\t%0,%2,%S1"
3159 [(set_attr "op_type" "RSY")
3160 (set_attr "z10prop" "z10_super")])
3161
3162 (define_insn "*sethighpartdi_31"
3163 [(set (match_operand:DI 0 "register_operand" "=d,d")
3164 (unspec:DI [(match_operand:BLK 1 "s_operand" "Q,S")
3165 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
3166 (clobber (reg:CC CC_REGNUM))]
3167 "!TARGET_64BIT"
3168 "@
3169 icm\t%0,%2,%S1
3170 icmy\t%0,%2,%S1"
3171 [(set_attr "op_type" "RS,RSY")
3172 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3173
3174
3175 (define_insn_and_split "*extzv<mode>"
3176 [(set (match_operand:GPR 0 "register_operand" "=d")
3177 (zero_extract:GPR (match_operand:QI 1 "s_operand" "QS")
3178 (match_operand 2 "const_int_operand" "n")
3179 (const_int 0)))
3180 (clobber (reg:CC CC_REGNUM))]
3181 "INTVAL (operands[2]) > 0
3182 && INTVAL (operands[2]) <= GET_MODE_BITSIZE (SImode)"
3183 "#"
3184 "&& reload_completed"
3185 [(parallel
3186 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
3187 (clobber (reg:CC CC_REGNUM))])
3188 (set (match_dup 0) (lshiftrt:GPR (match_dup 0) (match_dup 2)))]
3189 {
3190 int bitsize = INTVAL (operands[2]);
3191 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3192 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3193
3194 operands[1] = adjust_address (operands[1], BLKmode, 0);
3195 set_mem_size (operands[1], GEN_INT (size));
3196 operands[2] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - bitsize);
3197 operands[3] = GEN_INT (mask);
3198 })
3199
3200 (define_insn_and_split "*extv<mode>"
3201 [(set (match_operand:GPR 0 "register_operand" "=d")
3202 (sign_extract:GPR (match_operand:QI 1 "s_operand" "QS")
3203 (match_operand 2 "const_int_operand" "n")
3204 (const_int 0)))
3205 (clobber (reg:CC CC_REGNUM))]
3206 "INTVAL (operands[2]) > 0
3207 && INTVAL (operands[2]) <= GET_MODE_BITSIZE (SImode)"
3208 "#"
3209 "&& reload_completed"
3210 [(parallel
3211 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
3212 (clobber (reg:CC CC_REGNUM))])
3213 (parallel
3214 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3215 (clobber (reg:CC CC_REGNUM))])]
3216 {
3217 int bitsize = INTVAL (operands[2]);
3218 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3219 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3220
3221 operands[1] = adjust_address (operands[1], BLKmode, 0);
3222 set_mem_size (operands[1], GEN_INT (size));
3223 operands[2] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - bitsize);
3224 operands[3] = GEN_INT (mask);
3225 })
3226
3227 ;
3228 ; insv instruction patterns
3229 ;
3230
3231 (define_expand "insv"
3232 [(set (zero_extract (match_operand 0 "nonimmediate_operand" "")
3233 (match_operand 1 "const_int_operand" "")
3234 (match_operand 2 "const_int_operand" ""))
3235 (match_operand 3 "general_operand" ""))]
3236 ""
3237 {
3238 if (s390_expand_insv (operands[0], operands[1], operands[2], operands[3]))
3239 DONE;
3240 FAIL;
3241 })
3242
3243 (define_insn "*insv<mode>_z10"
3244 [(set (zero_extract:GPR (match_operand:GPR 0 "nonimmediate_operand" "+d")
3245 (match_operand 1 "const_int_operand" "I")
3246 (match_operand 2 "const_int_operand" "I"))
3247 (match_operand:GPR 3 "nonimmediate_operand" "d"))
3248 (clobber (reg:CC CC_REGNUM))]
3249 "TARGET_Z10
3250 && (INTVAL (operands[1]) + INTVAL (operands[2])) <=
3251 GET_MODE_BITSIZE (<MODE>mode)"
3252 {
3253 int start = INTVAL (operands[2]);
3254 int size = INTVAL (operands[1]);
3255 int offset = 64 - GET_MODE_BITSIZE (<MODE>mode);
3256
3257 operands[2] = GEN_INT (offset + start); /* start bit position */
3258 operands[1] = GEN_INT (offset + start + size - 1); /* end bit position */
3259 operands[4] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) -
3260 start - size); /* left shift count */
3261
3262 return "risbg\t%0,%3,%b2,%b1,%b4";
3263 }
3264 [(set_attr "op_type" "RIE")
3265 (set_attr "z10prop" "z10_super_E1")])
3266
3267 ; and op1 with a mask being 1 for the selected bits and 0 for the rest
3268 ; and op3=op0 with a mask being 0 for the selected bits and 1 for the rest
3269 (define_insn "*insv<mode>_z10_noshift"
3270 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3271 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
3272 (match_operand 2 "const_int_operand" "n"))
3273 (and:GPR (match_operand:GPR 3 "nonimmediate_operand" "0")
3274 (match_operand 4 "const_int_operand" "n"))))
3275 (clobber (reg:CC CC_REGNUM))]
3276 "TARGET_Z10
3277 && s390_contiguous_bitmask_p (INTVAL (operands[2]),
3278 GET_MODE_BITSIZE (<MODE>mode), NULL, NULL)
3279 && INTVAL (operands[2]) == ~(INTVAL (operands[4]))"
3280
3281 {
3282 int start;
3283 int size;
3284
3285 s390_contiguous_bitmask_p (INTVAL (operands[2]),
3286 GET_MODE_BITSIZE (<MODE>mode), &start, &size);
3287
3288 operands[5] = GEN_INT (64 - start - size); /* start bit position */
3289 operands[6] = GEN_INT (64 - 1 - start); /* end bit position */
3290 operands[7] = const0_rtx; /* left shift count */
3291
3292 return "risbg\t%0,%1,%b5,%b6,%b7";
3293 }
3294 [(set_attr "op_type" "RIE")
3295 (set_attr "z10prop" "z10_super_E1")])
3296
3297 ; and op1 with a mask being 1 for the selected bits and 0 for the rest
3298 (define_insn "*insv<mode>_or_z10_noshift"
3299 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3300 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
3301 (match_operand 2 "const_int_operand" "n"))
3302 (match_operand:GPR 3 "nonimmediate_operand" "0")))
3303 (clobber (reg:CC CC_REGNUM))]
3304 "TARGET_Z10
3305 && s390_contiguous_bitmask_p (INTVAL (operands[2]),
3306 GET_MODE_BITSIZE (<MODE>mode), NULL, NULL)"
3307 {
3308 int start;
3309 int size;
3310
3311 s390_contiguous_bitmask_p (INTVAL (operands[2]),
3312 GET_MODE_BITSIZE (<MODE>mode), &start, &size);
3313
3314 operands[4] = GEN_INT (64 - start - size); /* start bit position */
3315 operands[5] = GEN_INT (64 - 1 - start); /* end bit position */
3316 operands[6] = const0_rtx; /* left shift count */
3317
3318 return "rosbg\t%0,%1,%b4,%b5,%b6";
3319 }
3320 [(set_attr "op_type" "RIE")])
3321
3322 (define_insn "*insv<mode>_mem_reg"
3323 [(set (zero_extract:P (match_operand:QI 0 "memory_operand" "+Q,S")
3324 (match_operand 1 "const_int_operand" "n,n")
3325 (const_int 0))
3326 (match_operand:P 2 "register_operand" "d,d"))]
3327 "INTVAL (operands[1]) > 0
3328 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
3329 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
3330 {
3331 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
3332
3333 operands[1] = GEN_INT ((1ul << size) - 1);
3334 return (which_alternative == 0) ? "stcm\t%2,%1,%S0"
3335 : "stcmy\t%2,%1,%S0";
3336 }
3337 [(set_attr "op_type" "RS,RSY")
3338 (set_attr "z10prop" "z10_super,z10_super")])
3339
3340 (define_insn "*insvdi_mem_reghigh"
3341 [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "+QS")
3342 (match_operand 1 "const_int_operand" "n")
3343 (const_int 0))
3344 (lshiftrt:DI (match_operand:DI 2 "register_operand" "d")
3345 (const_int 32)))]
3346 "TARGET_64BIT
3347 && INTVAL (operands[1]) > 0
3348 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
3349 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
3350 {
3351 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
3352
3353 operands[1] = GEN_INT ((1ul << size) - 1);
3354 return "stcmh\t%2,%1,%S0";
3355 }
3356 [(set_attr "op_type" "RSY")
3357 (set_attr "z10prop" "z10_super")])
3358
3359 (define_insn "*insv<mode>_reg_imm"
3360 [(set (zero_extract:P (match_operand:P 0 "register_operand" "+d")
3361 (const_int 16)
3362 (match_operand 1 "const_int_operand" "n"))
3363 (match_operand:P 2 "const_int_operand" "n"))]
3364 "TARGET_ZARCH
3365 && INTVAL (operands[1]) >= 0
3366 && INTVAL (operands[1]) < BITS_PER_WORD
3367 && INTVAL (operands[1]) % 16 == 0"
3368 {
3369 switch (BITS_PER_WORD - INTVAL (operands[1]))
3370 {
3371 case 64: return "iihh\t%0,%x2"; break;
3372 case 48: return "iihl\t%0,%x2"; break;
3373 case 32: return "iilh\t%0,%x2"; break;
3374 case 16: return "iill\t%0,%x2"; break;
3375 default: gcc_unreachable();
3376 }
3377 }
3378 [(set_attr "op_type" "RI")
3379 (set_attr "z10prop" "z10_super_E1")])
3380
3381 ; Update the left-most 32 bit of a DI.
3382 (define_insn "*insv_h_di_reg_extimm"
3383 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3384 (const_int 32)
3385 (const_int 0))
3386 (match_operand:DI 1 "const_int_operand" "n"))]
3387 "TARGET_EXTIMM"
3388 "iihf\t%0,%o1"
3389 [(set_attr "op_type" "RIL")
3390 (set_attr "z10prop" "z10_fwd_E1")])
3391
3392 ; Update the right-most 32 bit of a DI, or the whole of a SI.
3393 (define_insn "*insv_l<mode>_reg_extimm"
3394 [(set (zero_extract:P (match_operand:P 0 "register_operand" "+d")
3395 (const_int 32)
3396 (match_operand 1 "const_int_operand" "n"))
3397 (match_operand:P 2 "const_int_operand" "n"))]
3398 "TARGET_EXTIMM
3399 && BITS_PER_WORD - INTVAL (operands[1]) == 32"
3400 "iilf\t%0,%o2"
3401 [(set_attr "op_type" "RIL")
3402 (set_attr "z10prop" "z10_fwd_A1")])
3403
3404 ;
3405 ; extendsidi2 instruction pattern(s).
3406 ;
3407
3408 (define_expand "extendsidi2"
3409 [(set (match_operand:DI 0 "register_operand" "")
3410 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3411 ""
3412 {
3413 if (!TARGET_64BIT)
3414 {
3415 emit_clobber (operands[0]);
3416 emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
3417 emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
3418 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
3419 DONE;
3420 }
3421 })
3422
3423 (define_insn "*extendsidi2"
3424 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3425 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,RT,b")))]
3426 "TARGET_64BIT"
3427 "@
3428 lgfr\t%0,%1
3429 lgf\t%0,%1
3430 lgfrl\t%0,%1"
3431 [(set_attr "op_type" "RRE,RXY,RIL")
3432 (set_attr "type" "*,*,larl")
3433 (set_attr "cpu_facility" "*,*,z10")
3434 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
3435
3436 ;
3437 ; extend(hi|qi)(si|di)2 instruction pattern(s).
3438 ;
3439
3440 (define_expand "extend<HQI:mode><DSI:mode>2"
3441 [(set (match_operand:DSI 0 "register_operand" "")
3442 (sign_extend:DSI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3443 ""
3444 {
3445 if (<DSI:MODE>mode == DImode && !TARGET_64BIT)
3446 {
3447 rtx tmp = gen_reg_rtx (SImode);
3448 emit_insn (gen_extend<HQI:mode>si2 (tmp, operands[1]));
3449 emit_insn (gen_extendsidi2 (operands[0], tmp));
3450 DONE;
3451 }
3452 else if (!TARGET_EXTIMM)
3453 {
3454 rtx bitcount = GEN_INT (GET_MODE_BITSIZE (<DSI:MODE>mode) -
3455 GET_MODE_BITSIZE (<HQI:MODE>mode));
3456
3457 operands[1] = gen_lowpart (<DSI:MODE>mode, operands[1]);
3458 emit_insn (gen_ashl<DSI:mode>3 (operands[0], operands[1], bitcount));
3459 emit_insn (gen_ashr<DSI:mode>3 (operands[0], operands[0], bitcount));
3460 DONE;
3461 }
3462 })
3463
3464 ;
3465 ; extendhidi2 instruction pattern(s).
3466 ;
3467
3468 (define_insn "*extendhidi2_extimm"
3469 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3470 (sign_extend:DI (match_operand:HI 1 "general_operand" "d,RT,b")))]
3471 "TARGET_64BIT && TARGET_EXTIMM"
3472 "@
3473 lghr\t%0,%1
3474 lgh\t%0,%1
3475 lghrl\t%0,%1"
3476 [(set_attr "op_type" "RRE,RXY,RIL")
3477 (set_attr "type" "*,*,larl")
3478 (set_attr "cpu_facility" "extimm,extimm,z10")
3479 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
3480
3481 (define_insn "*extendhidi2"
3482 [(set (match_operand:DI 0 "register_operand" "=d")
3483 (sign_extend:DI (match_operand:HI 1 "memory_operand" "RT")))]
3484 "TARGET_64BIT"
3485 "lgh\t%0,%1"
3486 [(set_attr "op_type" "RXY")
3487 (set_attr "z10prop" "z10_super_E1")])
3488
3489 ;
3490 ; extendhisi2 instruction pattern(s).
3491 ;
3492
3493 (define_insn "*extendhisi2_extimm"
3494 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
3495 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" " d,R,T,b")))]
3496 "TARGET_EXTIMM"
3497 "@
3498 lhr\t%0,%1
3499 lh\t%0,%1
3500 lhy\t%0,%1
3501 lhrl\t%0,%1"
3502 [(set_attr "op_type" "RRE,RX,RXY,RIL")
3503 (set_attr "type" "*,*,*,larl")
3504 (set_attr "cpu_facility" "extimm,extimm,extimm,z10")
3505 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
3506
3507 (define_insn "*extendhisi2"
3508 [(set (match_operand:SI 0 "register_operand" "=d,d")
3509 (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
3510 "!TARGET_EXTIMM"
3511 "@
3512 lh\t%0,%1
3513 lhy\t%0,%1"
3514 [(set_attr "op_type" "RX,RXY")
3515 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3516
3517 ;
3518 ; extendqi(si|di)2 instruction pattern(s).
3519 ;
3520
3521 ; lbr, lgbr, lb, lgb
3522 (define_insn "*extendqi<mode>2_extimm"
3523 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3524 (sign_extend:GPR (match_operand:QI 1 "nonimmediate_operand" "d,RT")))]
3525 "TARGET_EXTIMM"
3526 "@
3527 l<g>br\t%0,%1
3528 l<g>b\t%0,%1"
3529 [(set_attr "op_type" "RRE,RXY")
3530 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3531
3532 ; lb, lgb
3533 (define_insn "*extendqi<mode>2"
3534 [(set (match_operand:GPR 0 "register_operand" "=d")
3535 (sign_extend:GPR (match_operand:QI 1 "memory_operand" "RT")))]
3536 "!TARGET_EXTIMM && TARGET_LONG_DISPLACEMENT"
3537 "l<g>b\t%0,%1"
3538 [(set_attr "op_type" "RXY")
3539 (set_attr "z10prop" "z10_super_E1")])
3540
3541 (define_insn_and_split "*extendqi<mode>2_short_displ"
3542 [(set (match_operand:GPR 0 "register_operand" "=d")
3543 (sign_extend:GPR (match_operand:QI 1 "s_operand" "Q")))
3544 (clobber (reg:CC CC_REGNUM))]
3545 "!TARGET_EXTIMM && !TARGET_LONG_DISPLACEMENT"
3546 "#"
3547 "&& reload_completed"
3548 [(parallel
3549 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (const_int 8)] UNSPEC_ICM))
3550 (clobber (reg:CC CC_REGNUM))])
3551 (parallel
3552 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3553 (clobber (reg:CC CC_REGNUM))])]
3554 {
3555 operands[1] = adjust_address (operands[1], BLKmode, 0);
3556 set_mem_size (operands[1], GEN_INT (GET_MODE_SIZE (QImode)));
3557 operands[2] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode)
3558 - GET_MODE_BITSIZE (QImode));
3559 })
3560
3561 ;
3562 ; zero_extendsidi2 instruction pattern(s).
3563 ;
3564
3565 (define_expand "zero_extendsidi2"
3566 [(set (match_operand:DI 0 "register_operand" "")
3567 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3568 ""
3569 {
3570 if (!TARGET_64BIT)
3571 {
3572 emit_clobber (operands[0]);
3573 emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
3574 emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
3575 DONE;
3576 }
3577 })
3578
3579 (define_insn "*zero_extendsidi2"
3580 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3581 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,RT,b")))]
3582 "TARGET_64BIT"
3583 "@
3584 llgfr\t%0,%1
3585 llgf\t%0,%1
3586 llgfrl\t%0,%1"
3587 [(set_attr "op_type" "RRE,RXY,RIL")
3588 (set_attr "type" "*,*,larl")
3589 (set_attr "cpu_facility" "*,*,z10")
3590 (set_attr "z10prop" "z10_fwd_E1,z10_fwd_A3,z10_fwd_A3")])
3591
3592 ;
3593 ; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
3594 ;
3595
3596 (define_insn "*llgt_sidi"
3597 [(set (match_operand:DI 0 "register_operand" "=d")
3598 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "RT") 0)
3599 (const_int 2147483647)))]
3600 "TARGET_64BIT"
3601 "llgt\t%0,%1"
3602 [(set_attr "op_type" "RXE")
3603 (set_attr "z10prop" "z10_super_E1")])
3604
3605 (define_insn_and_split "*llgt_sidi_split"
3606 [(set (match_operand:DI 0 "register_operand" "=d")
3607 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "RT") 0)
3608 (const_int 2147483647)))
3609 (clobber (reg:CC CC_REGNUM))]
3610 "TARGET_64BIT"
3611 "#"
3612 "&& reload_completed"
3613 [(set (match_dup 0)
3614 (and:DI (subreg:DI (match_dup 1) 0)
3615 (const_int 2147483647)))]
3616 "")
3617
3618 (define_insn "*llgt_sisi"
3619 [(set (match_operand:SI 0 "register_operand" "=d,d")
3620 (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,RT")
3621 (const_int 2147483647)))]
3622 "TARGET_ZARCH"
3623 "@
3624 llgtr\t%0,%1
3625 llgt\t%0,%1"
3626 [(set_attr "op_type" "RRE,RXE")
3627 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3628
3629 (define_insn "*llgt_didi"
3630 [(set (match_operand:DI 0 "register_operand" "=d,d")
3631 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
3632 (const_int 2147483647)))]
3633 "TARGET_64BIT"
3634 "@
3635 llgtr\t%0,%1
3636 llgt\t%0,%N1"
3637 [(set_attr "op_type" "RRE,RXE")
3638 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3639
3640 (define_split
3641 [(set (match_operand:GPR 0 "register_operand" "")
3642 (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
3643 (const_int 2147483647)))
3644 (clobber (reg:CC CC_REGNUM))]
3645 "TARGET_ZARCH && reload_completed"
3646 [(set (match_dup 0)
3647 (and:GPR (match_dup 1)
3648 (const_int 2147483647)))]
3649 "")
3650
3651 ;
3652 ; zero_extend(hi|qi)(si|di)2 instruction pattern(s).
3653 ;
3654
3655 (define_expand "zero_extend<mode>di2"
3656 [(set (match_operand:DI 0 "register_operand" "")
3657 (zero_extend:DI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3658 ""
3659 {
3660 if (!TARGET_64BIT)
3661 {
3662 rtx tmp = gen_reg_rtx (SImode);
3663 emit_insn (gen_zero_extend<mode>si2 (tmp, operands[1]));
3664 emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
3665 DONE;
3666 }
3667 else if (!TARGET_EXTIMM)
3668 {
3669 rtx bitcount = GEN_INT (GET_MODE_BITSIZE(DImode) -
3670 GET_MODE_BITSIZE(<MODE>mode));
3671 operands[1] = gen_lowpart (DImode, operands[1]);
3672 emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
3673 emit_insn (gen_lshrdi3 (operands[0], operands[0], bitcount));
3674 DONE;
3675 }
3676 })
3677
3678 (define_expand "zero_extend<mode>si2"
3679 [(set (match_operand:SI 0 "register_operand" "")
3680 (zero_extend:SI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3681 ""
3682 {
3683 if (!TARGET_EXTIMM)
3684 {
3685 operands[1] = gen_lowpart (SImode, operands[1]);
3686 emit_insn (gen_andsi3 (operands[0], operands[1],
3687 GEN_INT ((1 << GET_MODE_BITSIZE(<MODE>mode)) - 1)));
3688 DONE;
3689 }
3690 })
3691
3692 ; llhrl, llghrl
3693 (define_insn "*zero_extendhi<mode>2_z10"
3694 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
3695 (zero_extend:GPR (match_operand:HI 1 "nonimmediate_operand" "d,RT,b")))]
3696 "TARGET_Z10"
3697 "@
3698 ll<g>hr\t%0,%1
3699 ll<g>h\t%0,%1
3700 ll<g>hrl\t%0,%1"
3701 [(set_attr "op_type" "RXY,RRE,RIL")
3702 (set_attr "type" "*,*,larl")
3703 (set_attr "cpu_facility" "*,*,z10")
3704 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3,z10_fwd_A3")])
3705
3706 ; llhr, llcr, llghr, llgcr, llh, llc, llgh, llgc
3707 (define_insn "*zero_extend<HQI:mode><GPR:mode>2_extimm"
3708 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3709 (zero_extend:GPR (match_operand:HQI 1 "nonimmediate_operand" "d,RT")))]
3710 "TARGET_EXTIMM"
3711 "@
3712 ll<g><hc>r\t%0,%1
3713 ll<g><hc>\t%0,%1"
3714 [(set_attr "op_type" "RRE,RXY")
3715 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3")])
3716
3717 ; llgh, llgc
3718 (define_insn "*zero_extend<HQI:mode><GPR:mode>2"
3719 [(set (match_operand:GPR 0 "register_operand" "=d")
3720 (zero_extend:GPR (match_operand:HQI 1 "memory_operand" "RT")))]
3721 "TARGET_ZARCH && !TARGET_EXTIMM"
3722 "llg<hc>\t%0,%1"
3723 [(set_attr "op_type" "RXY")
3724 (set_attr "z10prop" "z10_fwd_A3")])
3725
3726 (define_insn_and_split "*zero_extendhisi2_31"
3727 [(set (match_operand:SI 0 "register_operand" "=&d")
3728 (zero_extend:SI (match_operand:HI 1 "s_operand" "QS")))
3729 (clobber (reg:CC CC_REGNUM))]
3730 "!TARGET_ZARCH"
3731 "#"
3732 "&& reload_completed"
3733 [(set (match_dup 0) (const_int 0))
3734 (parallel
3735 [(set (strict_low_part (match_dup 2)) (match_dup 1))
3736 (clobber (reg:CC CC_REGNUM))])]
3737 "operands[2] = gen_lowpart (HImode, operands[0]);")
3738
3739 (define_insn_and_split "*zero_extendqisi2_31"
3740 [(set (match_operand:SI 0 "register_operand" "=&d")
3741 (zero_extend:SI (match_operand:QI 1 "memory_operand" "RT")))]
3742 "!TARGET_ZARCH"
3743 "#"
3744 "&& reload_completed"
3745 [(set (match_dup 0) (const_int 0))
3746 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3747 "operands[2] = gen_lowpart (QImode, operands[0]);")
3748
3749 ;
3750 ; zero_extendqihi2 instruction pattern(s).
3751 ;
3752
3753 (define_expand "zero_extendqihi2"
3754 [(set (match_operand:HI 0 "register_operand" "")
3755 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
3756 "TARGET_ZARCH && !TARGET_EXTIMM"
3757 {
3758 operands[1] = gen_lowpart (HImode, operands[1]);
3759 emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
3760 DONE;
3761 })
3762
3763 (define_insn "*zero_extendqihi2_64"
3764 [(set (match_operand:HI 0 "register_operand" "=d")
3765 (zero_extend:HI (match_operand:QI 1 "memory_operand" "RT")))]
3766 "TARGET_ZARCH && !TARGET_EXTIMM"
3767 "llgc\t%0,%1"
3768 [(set_attr "op_type" "RXY")
3769 (set_attr "z10prop" "z10_fwd_A3")])
3770
3771 (define_insn_and_split "*zero_extendqihi2_31"
3772 [(set (match_operand:HI 0 "register_operand" "=&d")
3773 (zero_extend:HI (match_operand:QI 1 "memory_operand" "RT")))]
3774 "!TARGET_ZARCH"
3775 "#"
3776 "&& reload_completed"
3777 [(set (match_dup 0) (const_int 0))
3778 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3779 "operands[2] = gen_lowpart (QImode, operands[0]);")
3780
3781 ;
3782 ; fixuns_trunc(dd|td)di2 instruction pattern(s).
3783 ;
3784
3785 (define_expand "fixuns_truncdddi2"
3786 [(parallel
3787 [(set (match_operand:DI 0 "register_operand" "")
3788 (unsigned_fix:DI (match_operand:DD 1 "register_operand" "")))
3789 (clobber (match_scratch:TD 2 "=f"))])]
3790
3791 "TARGET_HARD_DFP"
3792 {
3793 rtx label1 = gen_label_rtx ();
3794 rtx label2 = gen_label_rtx ();
3795 rtx temp = gen_reg_rtx (TDmode);
3796 REAL_VALUE_TYPE cmp, sub;
3797
3798 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
3799 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
3800
3801 /* 2^63 can't be represented as 64bit DFP number with full precision. The
3802 solution is doing the check and the subtraction in TD mode and using a
3803 TD -> DI convert afterwards. */
3804 emit_insn (gen_extendddtd2 (temp, operands[1]));
3805 temp = force_reg (TDmode, temp);
3806 emit_insn (gen_cmptd (temp,
3807 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode)));
3808 emit_jump_insn (gen_blt (label1));
3809 emit_insn (gen_subtd3 (temp, temp,
3810 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
3811 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
3812 emit_jump (label2);
3813
3814 emit_label (label1);
3815 emit_insn (gen_fix_truncdddi2_dfp (operands[0], operands[1], GEN_INT (9)));
3816 emit_label (label2);
3817 DONE;
3818 })
3819
3820 (define_expand "fixuns_trunctddi2"
3821 [(set (match_operand:DI 0 "register_operand" "")
3822 (unsigned_fix:DI (match_operand:TD 1 "register_operand" "")))]
3823 "TARGET_HARD_DFP"
3824 {
3825 rtx label1 = gen_label_rtx ();
3826 rtx label2 = gen_label_rtx ();
3827 rtx temp = gen_reg_rtx (TDmode);
3828 REAL_VALUE_TYPE cmp, sub;
3829
3830 operands[1] = force_reg (TDmode, operands[1]);
3831 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
3832 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
3833
3834 emit_insn (gen_cmptd (operands[1],
3835 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode)));
3836 emit_jump_insn (gen_blt (label1));
3837 emit_insn (gen_subtd3 (temp, operands[1],
3838 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
3839 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
3840 emit_jump (label2);
3841
3842 emit_label (label1);
3843 emit_insn (gen_fix_trunctddi2_dfp (operands[0], operands[1], GEN_INT (9)));
3844 emit_label (label2);
3845 DONE;
3846 })
3847
3848 ;
3849 ; fixuns_trunc(sf|df)(si|di)2 and fix_trunc(sf|df)(si|di)2
3850 ; instruction pattern(s).
3851 ;
3852
3853 (define_expand "fixuns_trunc<BFP:mode><GPR:mode>2"
3854 [(set (match_operand:GPR 0 "register_operand" "")
3855 (unsigned_fix:GPR (match_operand:BFP 1 "register_operand" "")))]
3856 "TARGET_HARD_FLOAT"
3857 {
3858 rtx label1 = gen_label_rtx ();
3859 rtx label2 = gen_label_rtx ();
3860 rtx temp = gen_reg_rtx (<BFP:MODE>mode);
3861 REAL_VALUE_TYPE cmp, sub;
3862
3863 operands[1] = force_reg (<BFP:MODE>mode, operands[1]);
3864 real_2expN (&cmp, GET_MODE_BITSIZE(<GPR:MODE>mode) - 1, <BFP:MODE>mode);
3865 real_2expN (&sub, GET_MODE_BITSIZE(<GPR:MODE>mode), <BFP:MODE>mode);
3866
3867 emit_insn (gen_cmp<BFP:mode> (operands[1],
3868 CONST_DOUBLE_FROM_REAL_VALUE (cmp, <BFP:MODE>mode)));
3869 emit_jump_insn (gen_blt (label1));
3870 emit_insn (gen_sub<BFP:mode>3 (temp, operands[1],
3871 CONST_DOUBLE_FROM_REAL_VALUE (sub, <BFP:MODE>mode)));
3872 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0], temp,
3873 GEN_INT (7)));
3874 emit_jump (label2);
3875
3876 emit_label (label1);
3877 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0],
3878 operands[1], GEN_INT (5)));
3879 emit_label (label2);
3880 DONE;
3881 })
3882
3883 (define_expand "fix_trunc<DSF:mode><GPR:mode>2"
3884 [(set (match_operand:GPR 0 "register_operand" "")
3885 (fix:GPR (match_operand:DSF 1 "register_operand" "")))]
3886 "TARGET_HARD_FLOAT"
3887 {
3888 emit_insn (gen_fix_trunc<DSF:mode><GPR:mode>2_bfp (operands[0], operands[1],
3889 GEN_INT (5)));
3890 DONE;
3891 })
3892
3893 ; cgxbr, cgdbr, cgebr, cfxbr, cfdbr, cfebr
3894 (define_insn "fix_trunc<BFP:mode><GPR:mode>2_bfp"
3895 [(set (match_operand:GPR 0 "register_operand" "=d")
3896 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
3897 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
3898 (clobber (reg:CC CC_REGNUM))]
3899 "TARGET_HARD_FLOAT"
3900 "c<GPR:gf><BFP:xde>br\t%0,%h2,%1"
3901 [(set_attr "op_type" "RRE")
3902 (set_attr "type" "ftoi")])
3903
3904
3905 ;
3906 ; fix_trunc(td|dd)di2 instruction pattern(s).
3907 ;
3908
3909 (define_expand "fix_trunc<mode>di2"
3910 [(set (match_operand:DI 0 "register_operand" "")
3911 (fix:DI (match_operand:DFP 1 "nonimmediate_operand" "")))]
3912 "TARGET_64BIT && TARGET_HARD_DFP"
3913 {
3914 operands[1] = force_reg (<MODE>mode, operands[1]);
3915 emit_insn (gen_fix_trunc<mode>di2_dfp (operands[0], operands[1],
3916 GEN_INT (9)));
3917 DONE;
3918 })
3919
3920 ; cgxtr, cgdtr
3921 (define_insn "fix_trunc<DFP:mode>di2_dfp"
3922 [(set (match_operand:DI 0 "register_operand" "=d")
3923 (fix:DI (match_operand:DFP 1 "register_operand" "f")))
3924 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
3925 (clobber (reg:CC CC_REGNUM))]
3926 "TARGET_64BIT && TARGET_HARD_DFP"
3927 "cg<DFP:xde>tr\t%0,%h2,%1"
3928 [(set_attr "op_type" "RRF")
3929 (set_attr "type" "ftoidfp")])
3930
3931
3932 ;
3933 ; fix_trunctf(si|di)2 instruction pattern(s).
3934 ;
3935
3936 (define_expand "fix_trunctf<mode>2"
3937 [(parallel [(set (match_operand:GPR 0 "register_operand" "")
3938 (fix:GPR (match_operand:TF 1 "register_operand" "")))
3939 (unspec:GPR [(const_int 5)] UNSPEC_ROUND)
3940 (clobber (reg:CC CC_REGNUM))])]
3941 "TARGET_HARD_FLOAT"
3942 "")
3943
3944
3945 ;
3946 ; float(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
3947 ;
3948
3949 ; cxgbr, cdgbr, cegbr, cxgtr, cdgtr
3950 (define_insn "floatdi<mode>2"
3951 [(set (match_operand:FP 0 "register_operand" "=f")
3952 (float:FP (match_operand:DI 1 "register_operand" "d")))]
3953 "TARGET_64BIT && TARGET_HARD_FLOAT"
3954 "c<xde>g<bt>r\t%0,%1"
3955 [(set_attr "op_type" "RRE")
3956 (set_attr "type" "itof<mode>" )])
3957
3958 ; cxfbr, cdfbr, cefbr
3959 (define_insn "floatsi<mode>2"
3960 [(set (match_operand:BFP 0 "register_operand" "=f")
3961 (float:BFP (match_operand:SI 1 "register_operand" "d")))]
3962 "TARGET_HARD_FLOAT"
3963 "c<xde>fbr\t%0,%1"
3964 [(set_attr "op_type" "RRE")
3965 (set_attr "type" "itof<mode>" )])
3966
3967
3968 ;
3969 ; truncdfsf2 instruction pattern(s).
3970 ;
3971
3972 (define_insn "truncdfsf2"
3973 [(set (match_operand:SF 0 "register_operand" "=f")
3974 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
3975 "TARGET_HARD_FLOAT"
3976 "ledbr\t%0,%1"
3977 [(set_attr "op_type" "RRE")
3978 (set_attr "type" "ftruncdf")])
3979
3980 ;
3981 ; trunctf(df|sf)2 instruction pattern(s).
3982 ;
3983
3984 ; ldxbr, lexbr
3985 (define_insn "trunctf<mode>2"
3986 [(set (match_operand:DSF 0 "register_operand" "=f")
3987 (float_truncate:DSF (match_operand:TF 1 "register_operand" "f")))
3988 (clobber (match_scratch:TF 2 "=f"))]
3989 "TARGET_HARD_FLOAT"
3990 "l<xde>xbr\t%2,%1\;l<xde>r\t%0,%2"
3991 [(set_attr "length" "6")
3992 (set_attr "type" "ftrunctf")])
3993
3994 ;
3995 ; trunctddd2 and truncddsd2 instruction pattern(s).
3996 ;
3997
3998 (define_insn "trunctddd2"
3999 [(set (match_operand:DD 0 "register_operand" "=f")
4000 (float_truncate:DD (match_operand:TD 1 "register_operand" "f")))
4001 (clobber (match_scratch:TD 2 "=f"))]
4002 "TARGET_HARD_DFP"
4003 "ldxtr\t%2,0,%1,0\;ldr\t%0,%2"
4004 [(set_attr "length" "6")
4005 (set_attr "type" "ftruncdd")])
4006
4007 (define_insn "truncddsd2"
4008 [(set (match_operand:SD 0 "register_operand" "=f")
4009 (float_truncate:SD (match_operand:DD 1 "register_operand" "f")))]
4010 "TARGET_HARD_DFP"
4011 "ledtr\t%0,0,%1,0"
4012 [(set_attr "op_type" "RRF")
4013 (set_attr "type" "ftruncsd")])
4014
4015 ;
4016 ; extend(sf|df)(df|tf)2 instruction pattern(s).
4017 ;
4018
4019 ; ldebr, ldeb, lxdbr, lxdb, lxebr, lxeb
4020 (define_insn "extend<DSF:mode><BFP:mode>2"
4021 [(set (match_operand:BFP 0 "register_operand" "=f,f")
4022 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "f,R")))]
4023 "TARGET_HARD_FLOAT
4024 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)"
4025 "@
4026 l<BFP:xde><DSF:xde>br\t%0,%1
4027 l<BFP:xde><DSF:xde>b\t%0,%1"
4028 [(set_attr "op_type" "RRE,RXE")
4029 (set_attr "type" "fsimp<BFP:mode>, fload<BFP:mode>")])
4030
4031 ;
4032 ; extendddtd2 and extendsddd2 instruction pattern(s).
4033 ;
4034
4035 (define_insn "extendddtd2"
4036 [(set (match_operand:TD 0 "register_operand" "=f")
4037 (float_extend:TD (match_operand:DD 1 "register_operand" "f")))]
4038 "TARGET_HARD_DFP"
4039 "lxdtr\t%0,%1,0"
4040 [(set_attr "op_type" "RRF")
4041 (set_attr "type" "fsimptf")])
4042
4043 (define_insn "extendsddd2"
4044 [(set (match_operand:DD 0 "register_operand" "=f")
4045 (float_extend:DD (match_operand:SD 1 "register_operand" "f")))]
4046 "TARGET_HARD_DFP"
4047 "ldetr\t%0,%1,0"
4048 [(set_attr "op_type" "RRF")
4049 (set_attr "type" "fsimptf")])
4050
4051 ; Binary <-> Decimal floating point trunc patterns
4052 ;
4053
4054 (define_insn "*trunc<BFP:mode><DFP_ALL:mode>2"
4055 [(set (reg:DFP_ALL FPR0_REGNUM)
4056 (float_truncate:DFP_ALL (reg:BFP FPR2_REGNUM)))
4057 (use (reg:SI GPR0_REGNUM))
4058 (clobber (reg:CC CC_REGNUM))]
4059 "TARGET_HARD_DFP"
4060 "pfpo")
4061
4062 (define_insn "*trunc<DFP_ALL:mode><BFP:mode>2"
4063 [(set (reg:BFP FPR0_REGNUM)
4064 (float_truncate:BFP (reg:DFP_ALL FPR2_REGNUM)))
4065 (use (reg:SI GPR0_REGNUM))
4066 (clobber (reg:CC CC_REGNUM))]
4067 "TARGET_HARD_DFP"
4068 "pfpo")
4069
4070 (define_expand "trunc<BFP:mode><DFP_ALL:mode>2"
4071 [(set (reg:BFP FPR2_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
4072 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4073 (parallel
4074 [(set (reg:DFP_ALL FPR0_REGNUM)
4075 (float_truncate:DFP_ALL (reg:BFP FPR2_REGNUM)))
4076 (use (reg:SI GPR0_REGNUM))
4077 (clobber (reg:CC CC_REGNUM))])
4078 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
4079 (reg:DFP_ALL FPR0_REGNUM))]
4080 "TARGET_HARD_DFP
4081 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
4082 {
4083 HOST_WIDE_INT flags;
4084
4085 flags = (PFPO_CONVERT |
4086 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
4087 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
4088
4089 operands[2] = GEN_INT (flags);
4090 })
4091
4092 (define_expand "trunc<DFP_ALL:mode><BFP:mode>2"
4093 [(set (reg:DFP_ALL FPR2_REGNUM)
4094 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
4095 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4096 (parallel
4097 [(set (reg:BFP FPR0_REGNUM) (float_truncate:BFP (reg:DFP_ALL FPR2_REGNUM)))
4098 (use (reg:SI GPR0_REGNUM))
4099 (clobber (reg:CC CC_REGNUM))])
4100 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
4101 "TARGET_HARD_DFP
4102 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) >= GET_MODE_SIZE (<BFP:MODE>mode)"
4103 {
4104 HOST_WIDE_INT flags;
4105
4106 flags = (PFPO_CONVERT |
4107 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
4108 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
4109
4110 operands[2] = GEN_INT (flags);
4111 })
4112
4113 ;
4114 ; Binary <-> Decimal floating point extend patterns
4115 ;
4116
4117 (define_insn "*extend<BFP:mode><DFP_ALL:mode>2"
4118 [(set (reg:DFP_ALL FPR0_REGNUM) (float_extend:DFP_ALL (reg:BFP FPR2_REGNUM)))
4119 (use (reg:SI GPR0_REGNUM))
4120 (clobber (reg:CC CC_REGNUM))]
4121 "TARGET_HARD_DFP"
4122 "pfpo")
4123
4124 (define_insn "*extend<DFP_ALL:mode><BFP:mode>2"
4125 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR2_REGNUM)))
4126 (use (reg:SI GPR0_REGNUM))
4127 (clobber (reg:CC CC_REGNUM))]
4128 "TARGET_HARD_DFP"
4129 "pfpo")
4130
4131 (define_expand "extend<BFP:mode><DFP_ALL:mode>2"
4132 [(set (reg:BFP FPR2_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
4133 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4134 (parallel
4135 [(set (reg:DFP_ALL FPR0_REGNUM)
4136 (float_extend:DFP_ALL (reg:BFP FPR2_REGNUM)))
4137 (use (reg:SI GPR0_REGNUM))
4138 (clobber (reg:CC CC_REGNUM))])
4139 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
4140 (reg:DFP_ALL FPR0_REGNUM))]
4141 "TARGET_HARD_DFP
4142 && GET_MODE_SIZE (<BFP:MODE>mode) <= GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
4143 {
4144 HOST_WIDE_INT flags;
4145
4146 flags = (PFPO_CONVERT |
4147 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
4148 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
4149
4150 operands[2] = GEN_INT (flags);
4151 })
4152
4153 (define_expand "extend<DFP_ALL:mode><BFP:mode>2"
4154 [(set (reg:DFP_ALL FPR2_REGNUM)
4155 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
4156 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4157 (parallel
4158 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR2_REGNUM)))
4159 (use (reg:SI GPR0_REGNUM))
4160 (clobber (reg:CC CC_REGNUM))])
4161 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
4162 "TARGET_HARD_DFP
4163 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) < GET_MODE_SIZE (<BFP:MODE>mode)"
4164 {
4165 HOST_WIDE_INT flags;
4166
4167 flags = (PFPO_CONVERT |
4168 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
4169 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
4170
4171 operands[2] = GEN_INT (flags);
4172 })
4173
4174
4175 ;;
4176 ;; ARITHMETIC OPERATIONS
4177 ;;
4178 ; arithmetic operations set the ConditionCode,
4179 ; because of unpredictable Bits in Register for Halfword and Byte
4180 ; the ConditionCode can be set wrong in operations for Halfword and Byte
4181
4182 ;;
4183 ;;- Add instructions.
4184 ;;
4185
4186 ;
4187 ; addti3 instruction pattern(s).
4188 ;
4189
4190 (define_insn_and_split "addti3"
4191 [(set (match_operand:TI 0 "register_operand" "=&d")
4192 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
4193 (match_operand:TI 2 "general_operand" "do") ) )
4194 (clobber (reg:CC CC_REGNUM))]
4195 "TARGET_64BIT"
4196 "#"
4197 "&& reload_completed"
4198 [(parallel
4199 [(set (reg:CCL1 CC_REGNUM)
4200 (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
4201 (match_dup 7)))
4202 (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
4203 (parallel
4204 [(set (match_dup 3) (plus:DI
4205 (plus:DI (ltu:DI (reg:CCL1 CC_REGNUM) (const_int 0))
4206 (match_dup 4)) (match_dup 5)))
4207 (clobber (reg:CC CC_REGNUM))])]
4208 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
4209 operands[4] = operand_subword (operands[1], 0, 0, TImode);
4210 operands[5] = operand_subword (operands[2], 0, 0, TImode);
4211 operands[6] = operand_subword (operands[0], 1, 0, TImode);
4212 operands[7] = operand_subword (operands[1], 1, 0, TImode);
4213 operands[8] = operand_subword (operands[2], 1, 0, TImode);")
4214
4215 ;
4216 ; adddi3 instruction pattern(s).
4217 ;
4218
4219 (define_expand "adddi3"
4220 [(parallel
4221 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4222 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
4223 (match_operand:DI 2 "general_operand" "")))
4224 (clobber (reg:CC CC_REGNUM))])]
4225 ""
4226 "")
4227
4228 (define_insn "*adddi3_sign"
4229 [(set (match_operand:DI 0 "register_operand" "=d,d")
4230 (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4231 (match_operand:DI 1 "register_operand" "0,0")))
4232 (clobber (reg:CC CC_REGNUM))]
4233 "TARGET_64BIT"
4234 "@
4235 agfr\t%0,%2
4236 agf\t%0,%2"
4237 [(set_attr "op_type" "RRE,RXY")])
4238
4239 (define_insn "*adddi3_zero_cc"
4240 [(set (reg CC_REGNUM)
4241 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4242 (match_operand:DI 1 "register_operand" "0,0"))
4243 (const_int 0)))
4244 (set (match_operand:DI 0 "register_operand" "=d,d")
4245 (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
4246 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4247 "@
4248 algfr\t%0,%2
4249 algf\t%0,%2"
4250 [(set_attr "op_type" "RRE,RXY")
4251 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4252
4253 (define_insn "*adddi3_zero_cconly"
4254 [(set (reg CC_REGNUM)
4255 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4256 (match_operand:DI 1 "register_operand" "0,0"))
4257 (const_int 0)))
4258 (clobber (match_scratch:DI 0 "=d,d"))]
4259 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4260 "@
4261 algfr\t%0,%2
4262 algf\t%0,%2"
4263 [(set_attr "op_type" "RRE,RXY")
4264 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4265
4266 (define_insn "*adddi3_zero"
4267 [(set (match_operand:DI 0 "register_operand" "=d,d")
4268 (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4269 (match_operand:DI 1 "register_operand" "0,0")))
4270 (clobber (reg:CC CC_REGNUM))]
4271 "TARGET_64BIT"
4272 "@
4273 algfr\t%0,%2
4274 algf\t%0,%2"
4275 [(set_attr "op_type" "RRE,RXY")
4276 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4277
4278 (define_insn_and_split "*adddi3_31z"
4279 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
4280 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
4281 (match_operand:DI 2 "general_operand" "do") ) )
4282 (clobber (reg:CC CC_REGNUM))]
4283 "!TARGET_64BIT && TARGET_CPU_ZARCH"
4284 "#"
4285 "&& reload_completed"
4286 [(parallel
4287 [(set (reg:CCL1 CC_REGNUM)
4288 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
4289 (match_dup 7)))
4290 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
4291 (parallel
4292 [(set (match_dup 3) (plus:SI
4293 (plus:SI (ltu:SI (reg:CCL1 CC_REGNUM) (const_int 0))
4294 (match_dup 4)) (match_dup 5)))
4295 (clobber (reg:CC CC_REGNUM))])]
4296 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4297 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4298 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4299 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4300 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4301 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
4302
4303 (define_insn_and_split "*adddi3_31"
4304 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
4305 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
4306 (match_operand:DI 2 "general_operand" "do") ) )
4307 (clobber (reg:CC CC_REGNUM))]
4308 "!TARGET_CPU_ZARCH"
4309 "#"
4310 "&& reload_completed"
4311 [(parallel
4312 [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
4313 (clobber (reg:CC CC_REGNUM))])
4314 (parallel
4315 [(set (reg:CCL1 CC_REGNUM)
4316 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
4317 (match_dup 7)))
4318 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
4319 (set (pc)
4320 (if_then_else (ltu (reg:CCL1 CC_REGNUM) (const_int 0))
4321 (pc)
4322 (label_ref (match_dup 9))))
4323 (parallel
4324 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
4325 (clobber (reg:CC CC_REGNUM))])
4326 (match_dup 9)]
4327 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4328 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4329 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4330 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4331 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4332 operands[8] = operand_subword (operands[2], 1, 0, DImode);
4333 operands[9] = gen_label_rtx ();")
4334
4335 ;
4336 ; addsi3 instruction pattern(s).
4337 ;
4338
4339 (define_expand "addsi3"
4340 [(parallel
4341 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4342 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
4343 (match_operand:SI 2 "general_operand" "")))
4344 (clobber (reg:CC CC_REGNUM))])]
4345 ""
4346 "")
4347
4348 (define_insn "*addsi3_sign"
4349 [(set (match_operand:SI 0 "register_operand" "=d,d")
4350 (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
4351 (match_operand:SI 1 "register_operand" "0,0")))
4352 (clobber (reg:CC CC_REGNUM))]
4353 ""
4354 "@
4355 ah\t%0,%2
4356 ahy\t%0,%2"
4357 [(set_attr "op_type" "RX,RXY")])
4358
4359 ;
4360 ; add(di|si)3 instruction pattern(s).
4361 ;
4362
4363 ; ar, ahi, alfi, slfi, a, ay, agr, aghi, algfi, slgfi, ag, asi, agsi
4364 (define_insn "*add<mode>3"
4365 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,d,QS")
4366 (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0,0,0")
4367 (match_operand:GPR 2 "general_operand" "d,K,Op,On,R,T,C") ) )
4368 (clobber (reg:CC CC_REGNUM))]
4369 ""
4370 "@
4371 a<g>r\t%0,%2
4372 a<g>hi\t%0,%h2
4373 al<g>fi\t%0,%2
4374 sl<g>fi\t%0,%n2
4375 a<g>\t%0,%2
4376 a<y>\t%0,%2
4377 a<g>si\t%0,%c2"
4378 [(set_attr "op_type" "RR<E>,RI,RIL,RIL,RX<Y>,RXY,SIY")
4379 (set_attr "cpu_facility" "*,*,extimm,extimm,*,*,z10")
4380 (set_attr "z10prop" "z10_super_E1,
4381 z10_super_E1,
4382 z10_super_E1,
4383 z10_super_E1,
4384 z10_super_E1,
4385 z10_super_E1,
4386 z10_super_E1")])
4387
4388 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi
4389 (define_insn "*add<mode>3_carry1_cc"
4390 [(set (reg CC_REGNUM)
4391 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0,0")
4392 (match_operand:GPR 2 "general_operand" "d,Op,On,R,T,C"))
4393 (match_dup 1)))
4394 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,d")
4395 (plus:GPR (match_dup 1) (match_dup 2)))]
4396 "s390_match_ccmode (insn, CCL1mode)"
4397 "@
4398 al<g>r\t%0,%2
4399 al<g>fi\t%0,%2
4400 sl<g>fi\t%0,%n2
4401 al<g>\t%0,%2
4402 al<y>\t%0,%2
4403 al<g>si\t%0,%c2"
4404 [(set_attr "op_type" "RR<E>,RIL,RIL,RX<Y>,RXY,SIY")
4405 (set_attr "cpu_facility" "*,extimm,extimm,*,*,z10")
4406 (set_attr "z10prop" "z10_super_E1,
4407 z10_super_E1,
4408 z10_super_E1,
4409 z10_super_E1,
4410 z10_super_E1,
4411 z10_super_E1")])
4412
4413 ; alr, al, aly, algr, alg
4414 (define_insn "*add<mode>3_carry1_cconly"
4415 [(set (reg CC_REGNUM)
4416 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
4417 (match_operand:GPR 2 "general_operand" "d,R,T"))
4418 (match_dup 1)))
4419 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4420 "s390_match_ccmode (insn, CCL1mode)"
4421 "@
4422 al<g>r\t%0,%2
4423 al<g>\t%0,%2
4424 al<y>\t%0,%2"
4425 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4426 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4427
4428 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi
4429 (define_insn "*add<mode>3_carry2_cc"
4430 [(set (reg CC_REGNUM)
4431 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0,0")
4432 (match_operand:GPR 2 "general_operand" "d,Op,On,R,T,C"))
4433 (match_dup 2)))
4434 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,RS")
4435 (plus:GPR (match_dup 1) (match_dup 2)))]
4436 "s390_match_ccmode (insn, CCL1mode)"
4437 "@
4438 al<g>r\t%0,%2
4439 al<g>fi\t%0,%2
4440 sl<g>fi\t%0,%n2
4441 al<g>\t%0,%2
4442 al<y>\t%0,%2
4443 al<g>si\t%0,%c2"
4444 [(set_attr "op_type" "RR<E>,RIL,RIL,RX<Y>,RXY,SIY")
4445 (set_attr "cpu_facility" "*,extimm,extimm,*,*,z10")
4446 (set_attr "z10prop" "z10_super_E1,
4447 z10_super_E1,
4448 z10_super_E1,
4449 z10_super_E1,
4450 z10_super_E1,
4451 z10_super_E1")])
4452
4453 ; alr, al, aly, algr, alg
4454 (define_insn "*add<mode>3_carry2_cconly"
4455 [(set (reg CC_REGNUM)
4456 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
4457 (match_operand:GPR 2 "general_operand" "d,R,T"))
4458 (match_dup 2)))
4459 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4460 "s390_match_ccmode (insn, CCL1mode)"
4461 "@
4462 al<g>r\t%0,%2
4463 al<g>\t%0,%2
4464 al<y>\t%0,%2"
4465 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4466 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4467
4468 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi
4469 (define_insn "*add<mode>3_cc"
4470 [(set (reg CC_REGNUM)
4471 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0,0")
4472 (match_operand:GPR 2 "general_operand" "d,Op,On,R,T,C"))
4473 (const_int 0)))
4474 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,RS")
4475 (plus:GPR (match_dup 1) (match_dup 2)))]
4476 "s390_match_ccmode (insn, CCLmode)"
4477 "@
4478 al<g>r\t%0,%2
4479 al<g>fi\t%0,%2
4480 sl<g>fi\t%0,%n2
4481 al<g>\t%0,%2
4482 al<y>\t%0,%2
4483 al<g>si\t%0,%c2"
4484 [(set_attr "op_type" "RR<E>,RIL,RIL,RX<Y>,RXY,SIY")
4485 (set_attr "cpu_facility" "*,extimm,extimm,*,*,z10")
4486 (set_attr "z10prop" "z10_super_E1,
4487 z10_super_E1,
4488 z10_super_E1,
4489 z10_super_E1,
4490 z10_super_E1,
4491 z10_super_E1")])
4492
4493 ; alr, al, aly, algr, alg
4494 (define_insn "*add<mode>3_cconly"
4495 [(set (reg CC_REGNUM)
4496 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
4497 (match_operand:GPR 2 "general_operand" "d,R,T"))
4498 (const_int 0)))
4499 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4500 "s390_match_ccmode (insn, CCLmode)"
4501 "@
4502 al<g>r\t%0,%2
4503 al<g>\t%0,%2
4504 al<y>\t%0,%2"
4505 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4506 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4507
4508 ; alr, al, aly, algr, alg
4509 (define_insn "*add<mode>3_cconly2"
4510 [(set (reg CC_REGNUM)
4511 (compare (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
4512 (neg:GPR (match_operand:GPR 2 "general_operand" "d,R,T"))))
4513 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4514 "s390_match_ccmode(insn, CCLmode)"
4515 "@
4516 al<g>r\t%0,%2
4517 al<g>\t%0,%2
4518 al<y>\t%0,%2"
4519 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4520 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4521
4522 ; ahi, afi, aghi, agfi, asi, agsi
4523 (define_insn "*add<mode>3_imm_cc"
4524 [(set (reg CC_REGNUM)
4525 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0,0")
4526 (match_operand:GPR 2 "const_int_operand" "K,Os,C"))
4527 (const_int 0)))
4528 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,QS")
4529 (plus:GPR (match_dup 1) (match_dup 2)))]
4530 "s390_match_ccmode (insn, CCAmode)
4531 && (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")
4532 || CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'O', \"Os\")
4533 || CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'C', \"C\"))
4534 && INTVAL (operands[2]) != -((HOST_WIDE_INT)1 << (GET_MODE_BITSIZE(<MODE>mode) - 1))"
4535 "@
4536 a<g>hi\t%0,%h2
4537 a<g>fi\t%0,%2
4538 a<g>si\t%0,%c2"
4539 [(set_attr "op_type" "RI,RIL,SIY")
4540 (set_attr "cpu_facility" "*,extimm,z10")
4541 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4542
4543 ;
4544 ; add(tf|df|sf|td|dd)3 instruction pattern(s).
4545 ;
4546
4547 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4548 (define_insn "add<mode>3"
4549 [(set (match_operand:FP 0 "register_operand" "=f, f")
4550 (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4551 (match_operand:FP 2 "general_operand" " f,<Rf>")))
4552 (clobber (reg:CC CC_REGNUM))]
4553 "TARGET_HARD_FLOAT"
4554 "@
4555 a<xde><bt>r\t%0,<op1>%2
4556 a<xde>b\t%0,%2"
4557 [(set_attr "op_type" "<RRer>,RXE")
4558 (set_attr "type" "fsimp<mode>")])
4559
4560 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4561 (define_insn "*add<mode>3_cc"
4562 [(set (reg CC_REGNUM)
4563 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4564 (match_operand:FP 2 "general_operand" " f,<Rf>"))
4565 (match_operand:FP 3 "const0_operand" "")))
4566 (set (match_operand:FP 0 "register_operand" "=f,f")
4567 (plus:FP (match_dup 1) (match_dup 2)))]
4568 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4569 "@
4570 a<xde><bt>r\t%0,<op1>%2
4571 a<xde>b\t%0,%2"
4572 [(set_attr "op_type" "<RRer>,RXE")
4573 (set_attr "type" "fsimp<mode>")])
4574
4575 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4576 (define_insn "*add<mode>3_cconly"
4577 [(set (reg CC_REGNUM)
4578 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4579 (match_operand:FP 2 "general_operand" " f,<Rf>"))
4580 (match_operand:FP 3 "const0_operand" "")))
4581 (clobber (match_scratch:FP 0 "=f,f"))]
4582 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4583 "@
4584 a<xde><bt>r\t%0,<op1>%2
4585 a<xde>b\t%0,%2"
4586 [(set_attr "op_type" "<RRer>,RXE")
4587 (set_attr "type" "fsimp<mode>")])
4588
4589
4590 ;;
4591 ;;- Subtract instructions.
4592 ;;
4593
4594 ;
4595 ; subti3 instruction pattern(s).
4596 ;
4597
4598 (define_insn_and_split "subti3"
4599 [(set (match_operand:TI 0 "register_operand" "=&d")
4600 (minus:TI (match_operand:TI 1 "register_operand" "0")
4601 (match_operand:TI 2 "general_operand" "do") ) )
4602 (clobber (reg:CC CC_REGNUM))]
4603 "TARGET_64BIT"
4604 "#"
4605 "&& reload_completed"
4606 [(parallel
4607 [(set (reg:CCL2 CC_REGNUM)
4608 (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
4609 (match_dup 7)))
4610 (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
4611 (parallel
4612 [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
4613 (gtu:DI (reg:CCL2 CC_REGNUM) (const_int 0))))
4614 (clobber (reg:CC CC_REGNUM))])]
4615 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
4616 operands[4] = operand_subword (operands[1], 0, 0, TImode);
4617 operands[5] = operand_subword (operands[2], 0, 0, TImode);
4618 operands[6] = operand_subword (operands[0], 1, 0, TImode);
4619 operands[7] = operand_subword (operands[1], 1, 0, TImode);
4620 operands[8] = operand_subword (operands[2], 1, 0, TImode);")
4621
4622 ;
4623 ; subdi3 instruction pattern(s).
4624 ;
4625
4626 (define_expand "subdi3"
4627 [(parallel
4628 [(set (match_operand:DI 0 "register_operand" "")
4629 (minus:DI (match_operand:DI 1 "register_operand" "")
4630 (match_operand:DI 2 "general_operand" "")))
4631 (clobber (reg:CC CC_REGNUM))])]
4632 ""
4633 "")
4634
4635 (define_insn "*subdi3_sign"
4636 [(set (match_operand:DI 0 "register_operand" "=d,d")
4637 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4638 (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))))
4639 (clobber (reg:CC CC_REGNUM))]
4640 "TARGET_64BIT"
4641 "@
4642 sgfr\t%0,%2
4643 sgf\t%0,%2"
4644 [(set_attr "op_type" "RRE,RXY")
4645 (set_attr "z10prop" "z10_c,*")])
4646
4647 (define_insn "*subdi3_zero_cc"
4648 [(set (reg CC_REGNUM)
4649 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4650 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT")))
4651 (const_int 0)))
4652 (set (match_operand:DI 0 "register_operand" "=d,d")
4653 (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
4654 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4655 "@
4656 slgfr\t%0,%2
4657 slgf\t%0,%2"
4658 [(set_attr "op_type" "RRE,RXY")
4659 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
4660
4661 (define_insn "*subdi3_zero_cconly"
4662 [(set (reg CC_REGNUM)
4663 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4664 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT")))
4665 (const_int 0)))
4666 (clobber (match_scratch:DI 0 "=d,d"))]
4667 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4668 "@
4669 slgfr\t%0,%2
4670 slgf\t%0,%2"
4671 [(set_attr "op_type" "RRE,RXY")
4672 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
4673
4674 (define_insn "*subdi3_zero"
4675 [(set (match_operand:DI 0 "register_operand" "=d,d")
4676 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4677 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))))
4678 (clobber (reg:CC CC_REGNUM))]
4679 "TARGET_64BIT"
4680 "@
4681 slgfr\t%0,%2
4682 slgf\t%0,%2"
4683 [(set_attr "op_type" "RRE,RXY")
4684 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
4685
4686 (define_insn_and_split "*subdi3_31z"
4687 [(set (match_operand:DI 0 "register_operand" "=&d")
4688 (minus:DI (match_operand:DI 1 "register_operand" "0")
4689 (match_operand:DI 2 "general_operand" "do") ) )
4690 (clobber (reg:CC CC_REGNUM))]
4691 "!TARGET_64BIT && TARGET_CPU_ZARCH"
4692 "#"
4693 "&& reload_completed"
4694 [(parallel
4695 [(set (reg:CCL2 CC_REGNUM)
4696 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
4697 (match_dup 7)))
4698 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
4699 (parallel
4700 [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
4701 (gtu:SI (reg:CCL2 CC_REGNUM) (const_int 0))))
4702 (clobber (reg:CC CC_REGNUM))])]
4703 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4704 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4705 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4706 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4707 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4708 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
4709
4710 (define_insn_and_split "*subdi3_31"
4711 [(set (match_operand:DI 0 "register_operand" "=&d")
4712 (minus:DI (match_operand:DI 1 "register_operand" "0")
4713 (match_operand:DI 2 "general_operand" "do") ) )
4714 (clobber (reg:CC CC_REGNUM))]
4715 "!TARGET_CPU_ZARCH"
4716 "#"
4717 "&& reload_completed"
4718 [(parallel
4719 [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
4720 (clobber (reg:CC CC_REGNUM))])
4721 (parallel
4722 [(set (reg:CCL2 CC_REGNUM)
4723 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
4724 (match_dup 7)))
4725 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
4726 (set (pc)
4727 (if_then_else (gtu (reg:CCL2 CC_REGNUM) (const_int 0))
4728 (pc)
4729 (label_ref (match_dup 9))))
4730 (parallel
4731 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
4732 (clobber (reg:CC CC_REGNUM))])
4733 (match_dup 9)]
4734 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4735 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4736 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4737 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4738 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4739 operands[8] = operand_subword (operands[2], 1, 0, DImode);
4740 operands[9] = gen_label_rtx ();")
4741
4742 ;
4743 ; subsi3 instruction pattern(s).
4744 ;
4745
4746 (define_expand "subsi3"
4747 [(parallel
4748 [(set (match_operand:SI 0 "register_operand" "")
4749 (minus:SI (match_operand:SI 1 "register_operand" "")
4750 (match_operand:SI 2 "general_operand" "")))
4751 (clobber (reg:CC CC_REGNUM))])]
4752 ""
4753 "")
4754
4755 (define_insn "*subsi3_sign"
4756 [(set (match_operand:SI 0 "register_operand" "=d,d")
4757 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
4758 (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
4759 (clobber (reg:CC CC_REGNUM))]
4760 ""
4761 "@
4762 sh\t%0,%2
4763 shy\t%0,%2"
4764 [(set_attr "op_type" "RX,RXY")])
4765
4766 ;
4767 ; sub(di|si)3 instruction pattern(s).
4768 ;
4769
4770 ; sr, s, sy, sgr, sg
4771 (define_insn "*sub<mode>3"
4772 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
4773 (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4774 (match_operand:GPR 2 "general_operand" "d,R,T") ) )
4775 (clobber (reg:CC CC_REGNUM))]
4776 ""
4777 "@
4778 s<g>r\t%0,%2
4779 s<g>\t%0,%2
4780 s<y>\t%0,%2"
4781 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4782 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4783
4784 ; slr, sl, sly, slgr, slg
4785 (define_insn "*sub<mode>3_borrow_cc"
4786 [(set (reg CC_REGNUM)
4787 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4788 (match_operand:GPR 2 "general_operand" "d,R,T"))
4789 (match_dup 1)))
4790 (set (match_operand:GPR 0 "register_operand" "=d,d,d")
4791 (minus:GPR (match_dup 1) (match_dup 2)))]
4792 "s390_match_ccmode (insn, CCL2mode)"
4793 "@
4794 sl<g>r\t%0,%2
4795 sl<g>\t%0,%2
4796 sl<y>\t%0,%2"
4797 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4798 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4799
4800 ; slr, sl, sly, slgr, slg
4801 (define_insn "*sub<mode>3_borrow_cconly"
4802 [(set (reg CC_REGNUM)
4803 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4804 (match_operand:GPR 2 "general_operand" "d,R,T"))
4805 (match_dup 1)))
4806 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4807 "s390_match_ccmode (insn, CCL2mode)"
4808 "@
4809 sl<g>r\t%0,%2
4810 sl<g>\t%0,%2
4811 sl<y>\t%0,%2"
4812 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4813 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4814
4815 ; slr, sl, sly, slgr, slg
4816 (define_insn "*sub<mode>3_cc"
4817 [(set (reg CC_REGNUM)
4818 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4819 (match_operand:GPR 2 "general_operand" "d,R,T"))
4820 (const_int 0)))
4821 (set (match_operand:GPR 0 "register_operand" "=d,d,d")
4822 (minus:GPR (match_dup 1) (match_dup 2)))]
4823 "s390_match_ccmode (insn, CCLmode)"
4824 "@
4825 sl<g>r\t%0,%2
4826 sl<g>\t%0,%2
4827 sl<y>\t%0,%2"
4828 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4829 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4830
4831 ; slr, sl, sly, slgr, slg
4832 (define_insn "*sub<mode>3_cc2"
4833 [(set (reg CC_REGNUM)
4834 (compare (match_operand:GPR 1 "register_operand" "0,0,0")
4835 (match_operand:GPR 2 "general_operand" "d,R,T")))
4836 (set (match_operand:GPR 0 "register_operand" "=d,d,d")
4837 (minus:GPR (match_dup 1) (match_dup 2)))]
4838 "s390_match_ccmode (insn, CCL3mode)"
4839 "@
4840 sl<g>r\t%0,%2
4841 sl<g>\t%0,%2
4842 sl<y>\t%0,%2"
4843 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4844 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4845
4846 ; slr, sl, sly, slgr, slg
4847 (define_insn "*sub<mode>3_cconly"
4848 [(set (reg CC_REGNUM)
4849 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4850 (match_operand:GPR 2 "general_operand" "d,R,T"))
4851 (const_int 0)))
4852 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4853 "s390_match_ccmode (insn, CCLmode)"
4854 "@
4855 sl<g>r\t%0,%2
4856 sl<g>\t%0,%2
4857 sl<y>\t%0,%2"
4858 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4859 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4860
4861
4862 ; slr, sl, sly, slgr, slg
4863 (define_insn "*sub<mode>3_cconly2"
4864 [(set (reg CC_REGNUM)
4865 (compare (match_operand:GPR 1 "register_operand" "0,0,0")
4866 (match_operand:GPR 2 "general_operand" "d,R,T")))
4867 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4868 "s390_match_ccmode (insn, CCL3mode)"
4869 "@
4870 sl<g>r\t%0,%2
4871 sl<g>\t%0,%2
4872 sl<y>\t%0,%2"
4873 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4874 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4875
4876
4877 ;
4878 ; sub(tf|df|sf|td|dd)3 instruction pattern(s).
4879 ;
4880
4881 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
4882 (define_insn "sub<mode>3"
4883 [(set (match_operand:FP 0 "register_operand" "=f, f")
4884 (minus:FP (match_operand:FP 1 "register_operand" "<f0>,0")
4885 (match_operand:FP 2 "general_operand" "f,<Rf>")))
4886 (clobber (reg:CC CC_REGNUM))]
4887 "TARGET_HARD_FLOAT"
4888 "@
4889 s<xde><bt>r\t%0,<op1>%2
4890 s<xde>b\t%0,%2"
4891 [(set_attr "op_type" "<RRer>,RXE")
4892 (set_attr "type" "fsimp<mode>")])
4893
4894 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
4895 (define_insn "*sub<mode>3_cc"
4896 [(set (reg CC_REGNUM)
4897 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "<f0>,0")
4898 (match_operand:FP 2 "general_operand" "f,<Rf>"))
4899 (match_operand:FP 3 "const0_operand" "")))
4900 (set (match_operand:FP 0 "register_operand" "=f,f")
4901 (minus:FP (match_dup 1) (match_dup 2)))]
4902 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4903 "@
4904 s<xde><bt>r\t%0,<op1>%2
4905 s<xde>b\t%0,%2"
4906 [(set_attr "op_type" "<RRer>,RXE")
4907 (set_attr "type" "fsimp<mode>")])
4908
4909 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
4910 (define_insn "*sub<mode>3_cconly"
4911 [(set (reg CC_REGNUM)
4912 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "<f0>,0")
4913 (match_operand:FP 2 "general_operand" "f,<Rf>"))
4914 (match_operand:FP 3 "const0_operand" "")))
4915 (clobber (match_scratch:FP 0 "=f,f"))]
4916 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4917 "@
4918 s<xde><bt>r\t%0,<op1>%2
4919 s<xde>b\t%0,%2"
4920 [(set_attr "op_type" "<RRer>,RXE")
4921 (set_attr "type" "fsimp<mode>")])
4922
4923
4924 ;;
4925 ;;- Conditional add/subtract instructions.
4926 ;;
4927
4928 ;
4929 ; add(di|si)cc instruction pattern(s).
4930 ;
4931
4932 ; the following 4 patterns are used when the result of an add with
4933 ; carry is checked for an overflow condition
4934
4935 ; op1 + op2 + c < op1
4936
4937 ; alcr, alc, alcgr, alcg
4938 (define_insn "*add<mode>3_alc_carry1_cc"
4939 [(set (reg CC_REGNUM)
4940 (compare
4941 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
4942 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
4943 (match_operand:GPR 2 "general_operand" "d,RT"))
4944 (match_dup 1)))
4945 (set (match_operand:GPR 0 "register_operand" "=d,d")
4946 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
4947 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
4948 "@
4949 alc<g>r\t%0,%2
4950 alc<g>\t%0,%2"
4951 [(set_attr "op_type" "RRE,RXY")])
4952
4953 ; alcr, alc, alcgr, alcg
4954 (define_insn "*add<mode>3_alc_carry1_cconly"
4955 [(set (reg CC_REGNUM)
4956 (compare
4957 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
4958 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
4959 (match_operand:GPR 2 "general_operand" "d,RT"))
4960 (match_dup 1)))
4961 (clobber (match_scratch:GPR 0 "=d,d"))]
4962 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
4963 "@
4964 alc<g>r\t%0,%2
4965 alc<g>\t%0,%2"
4966 [(set_attr "op_type" "RRE,RXY")])
4967
4968 ; op1 + op2 + c < op2
4969
4970 ; alcr, alc, alcgr, alcg
4971 (define_insn "*add<mode>3_alc_carry2_cc"
4972 [(set (reg CC_REGNUM)
4973 (compare
4974 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
4975 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
4976 (match_operand:GPR 2 "general_operand" "d,RT"))
4977 (match_dup 2)))
4978 (set (match_operand:GPR 0 "register_operand" "=d,d")
4979 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
4980 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
4981 "@
4982 alc<g>r\t%0,%2
4983 alc<g>\t%0,%2"
4984 [(set_attr "op_type" "RRE,RXY")])
4985
4986 ; alcr, alc, alcgr, alcg
4987 (define_insn "*add<mode>3_alc_carry2_cconly"
4988 [(set (reg CC_REGNUM)
4989 (compare
4990 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
4991 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
4992 (match_operand:GPR 2 "general_operand" "d,RT"))
4993 (match_dup 2)))
4994 (clobber (match_scratch:GPR 0 "=d,d"))]
4995 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
4996 "@
4997 alc<g>r\t%0,%2
4998 alc<g>\t%0,%2"
4999 [(set_attr "op_type" "RRE,RXY")])
5000
5001 ; alcr, alc, alcgr, alcg
5002 (define_insn "*add<mode>3_alc_cc"
5003 [(set (reg CC_REGNUM)
5004 (compare
5005 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5006 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5007 (match_operand:GPR 2 "general_operand" "d,RT"))
5008 (const_int 0)))
5009 (set (match_operand:GPR 0 "register_operand" "=d,d")
5010 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
5011 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
5012 "@
5013 alc<g>r\t%0,%2
5014 alc<g>\t%0,%2"
5015 [(set_attr "op_type" "RRE,RXY")])
5016
5017 ; alcr, alc, alcgr, alcg
5018 (define_insn "*add<mode>3_alc"
5019 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5020 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5021 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5022 (match_operand:GPR 2 "general_operand" "d,RT")))
5023 (clobber (reg:CC CC_REGNUM))]
5024 "TARGET_CPU_ZARCH"
5025 "@
5026 alc<g>r\t%0,%2
5027 alc<g>\t%0,%2"
5028 [(set_attr "op_type" "RRE,RXY")])
5029
5030 ; slbr, slb, slbgr, slbg
5031 (define_insn "*sub<mode>3_slb_cc"
5032 [(set (reg CC_REGNUM)
5033 (compare
5034 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
5035 (match_operand:GPR 2 "general_operand" "d,RT"))
5036 (match_operand:GPR 3 "s390_slb_comparison" ""))
5037 (const_int 0)))
5038 (set (match_operand:GPR 0 "register_operand" "=d,d")
5039 (minus:GPR (minus:GPR (match_dup 1) (match_dup 2)) (match_dup 3)))]
5040 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
5041 "@
5042 slb<g>r\t%0,%2
5043 slb<g>\t%0,%2"
5044 [(set_attr "op_type" "RRE,RXY")
5045 (set_attr "z10prop" "z10_c,*")])
5046
5047 ; slbr, slb, slbgr, slbg
5048 (define_insn "*sub<mode>3_slb"
5049 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5050 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
5051 (match_operand:GPR 2 "general_operand" "d,RT"))
5052 (match_operand:GPR 3 "s390_slb_comparison" "")))
5053 (clobber (reg:CC CC_REGNUM))]
5054 "TARGET_CPU_ZARCH"
5055 "@
5056 slb<g>r\t%0,%2
5057 slb<g>\t%0,%2"
5058 [(set_attr "op_type" "RRE,RXY")
5059 (set_attr "z10prop" "z10_c,*")])
5060
5061 (define_expand "add<mode>cc"
5062 [(match_operand:GPR 0 "register_operand" "")
5063 (match_operand 1 "comparison_operator" "")
5064 (match_operand:GPR 2 "register_operand" "")
5065 (match_operand:GPR 3 "const_int_operand" "")]
5066 "TARGET_CPU_ZARCH"
5067 "if (!s390_expand_addcc (GET_CODE (operands[1]),
5068 s390_compare_op0, s390_compare_op1,
5069 operands[0], operands[2],
5070 operands[3])) FAIL; DONE;")
5071
5072 ;
5073 ; scond instruction pattern(s).
5074 ;
5075
5076 (define_insn_and_split "*scond<mode>"
5077 [(set (match_operand:GPR 0 "register_operand" "=&d")
5078 (match_operand:GPR 1 "s390_alc_comparison" ""))
5079 (clobber (reg:CC CC_REGNUM))]
5080 "TARGET_CPU_ZARCH"
5081 "#"
5082 "&& reload_completed"
5083 [(set (match_dup 0) (const_int 0))
5084 (parallel
5085 [(set (match_dup 0) (plus:GPR (plus:GPR (match_dup 1) (match_dup 0))
5086 (match_dup 0)))
5087 (clobber (reg:CC CC_REGNUM))])]
5088 "")
5089
5090 (define_insn_and_split "*scond<mode>_neg"
5091 [(set (match_operand:GPR 0 "register_operand" "=&d")
5092 (match_operand:GPR 1 "s390_slb_comparison" ""))
5093 (clobber (reg:CC CC_REGNUM))]
5094 "TARGET_CPU_ZARCH"
5095 "#"
5096 "&& reload_completed"
5097 [(set (match_dup 0) (const_int 0))
5098 (parallel
5099 [(set (match_dup 0) (minus:GPR (minus:GPR (match_dup 0) (match_dup 0))
5100 (match_dup 1)))
5101 (clobber (reg:CC CC_REGNUM))])
5102 (parallel
5103 [(set (match_dup 0) (neg:GPR (match_dup 0)))
5104 (clobber (reg:CC CC_REGNUM))])]
5105 "")
5106
5107
5108 (define_expand "s<code>"
5109 [(set (match_operand:SI 0 "register_operand" "")
5110 (SCOND (match_dup 0)
5111 (match_dup 0)))]
5112 "TARGET_CPU_ZARCH"
5113 "if (!s390_expand_addcc (<CODE>, s390_compare_op0, s390_compare_op1,
5114 operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
5115
5116 (define_expand "seq"
5117 [(parallel
5118 [(set (match_operand:SI 0 "register_operand" "=d")
5119 (match_dup 1))
5120 (clobber (reg:CC CC_REGNUM))])
5121 (parallel
5122 [(set (match_dup 0) (xor:SI (match_dup 0) (const_int 1)))
5123 (clobber (reg:CC CC_REGNUM))])]
5124 ""
5125 {
5126 if (!s390_compare_emitted || GET_MODE (s390_compare_emitted) != CCZ1mode)
5127 FAIL;
5128 operands[1] = s390_emit_compare (NE, s390_compare_op0, s390_compare_op1);
5129 PUT_MODE (operands[1], SImode);
5130 })
5131
5132 (define_insn_and_split "*sne"
5133 [(set (match_operand:SI 0 "register_operand" "=d")
5134 (ne:SI (match_operand:CCZ1 1 "register_operand" "0")
5135 (const_int 0)))
5136 (clobber (reg:CC CC_REGNUM))]
5137 ""
5138 "#"
5139 "reload_completed"
5140 [(parallel
5141 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 28)))
5142 (clobber (reg:CC CC_REGNUM))])])
5143
5144
5145 ;;
5146 ;;- Multiply instructions.
5147 ;;
5148
5149 ;
5150 ; muldi3 instruction pattern(s).
5151 ;
5152
5153 (define_insn "*muldi3_sign"
5154 [(set (match_operand:DI 0 "register_operand" "=d,d")
5155 (mult:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
5156 (match_operand:DI 1 "register_operand" "0,0")))]
5157 "TARGET_64BIT"
5158 "@
5159 msgfr\t%0,%2
5160 msgf\t%0,%2"
5161 [(set_attr "op_type" "RRE,RXY")
5162 (set_attr "type" "imuldi")])
5163
5164 (define_insn "muldi3"
5165 [(set (match_operand:DI 0 "register_operand" "=d,d,d,d")
5166 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0")
5167 (match_operand:DI 2 "general_operand" "d,K,RT,Os")))]
5168 "TARGET_64BIT"
5169 "@
5170 msgr\t%0,%2
5171 mghi\t%0,%h2
5172 msg\t%0,%2
5173 msgfi\t%0,%2"
5174 [(set_attr "op_type" "RRE,RI,RXY,RIL")
5175 (set_attr "type" "imuldi")
5176 (set_attr "cpu_facility" "*,*,*,z10")])
5177
5178 ;
5179 ; mulsi3 instruction pattern(s).
5180 ;
5181
5182 (define_insn "*mulsi3_sign"
5183 [(set (match_operand:SI 0 "register_operand" "=d,d")
5184 (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
5185 (match_operand:SI 1 "register_operand" "0,0")))]
5186 ""
5187 "@
5188 mh\t%0,%2
5189 mhy\t%0,%2"
5190 [(set_attr "op_type" "RX,RXY")
5191 (set_attr "type" "imulhi")
5192 (set_attr "cpu_facility" "*,z10")])
5193
5194 (define_insn "mulsi3"
5195 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
5196 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0")
5197 (match_operand:SI 2 "general_operand" "d,K,R,T,Os")))]
5198 ""
5199 "@
5200 msr\t%0,%2
5201 mhi\t%0,%h2
5202 ms\t%0,%2
5203 msy\t%0,%2
5204 msfi\t%0,%2"
5205 [(set_attr "op_type" "RRE,RI,RX,RXY,RIL")
5206 (set_attr "type" "imulsi,imulhi,imulsi,imulsi,imulsi")
5207 (set_attr "cpu_facility" "*,*,*,*,z10")])
5208
5209 ;
5210 ; mulsidi3 instruction pattern(s).
5211 ;
5212
5213 (define_insn "mulsidi3"
5214 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
5215 (mult:DI (sign_extend:DI
5216 (match_operand:SI 1 "register_operand" "%0,0,0"))
5217 (sign_extend:DI
5218 (match_operand:SI 2 "nonimmediate_operand" "d,R,T"))))]
5219 "!TARGET_64BIT"
5220 "@
5221 mr\t%0,%2
5222 m\t%0,%2
5223 mfy\t%0,%2"
5224 [(set_attr "op_type" "RR,RX,RXY")
5225 (set_attr "type" "imulsi")
5226 (set_attr "cpu_facility" "*,*,z10")])
5227
5228 ;
5229 ; umulsidi3 instruction pattern(s).
5230 ;
5231
5232 (define_insn "umulsidi3"
5233 [(set (match_operand:DI 0 "register_operand" "=d,d")
5234 (mult:DI (zero_extend:DI
5235 (match_operand:SI 1 "register_operand" "%0,0"))
5236 (zero_extend:DI
5237 (match_operand:SI 2 "nonimmediate_operand" "d,RT"))))]
5238 "!TARGET_64BIT && TARGET_CPU_ZARCH"
5239 "@
5240 mlr\t%0,%2
5241 ml\t%0,%2"
5242 [(set_attr "op_type" "RRE,RXY")
5243 (set_attr "type" "imulsi")])
5244
5245 ;
5246 ; mul(tf|df|sf|td|dd)3 instruction pattern(s).
5247 ;
5248
5249 ; mxbr, mdbr, meebr, mxb, mxb, meeb, mdtr, mxtr
5250 (define_insn "mul<mode>3"
5251 [(set (match_operand:FP 0 "register_operand" "=f,f")
5252 (mult:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
5253 (match_operand:FP 2 "general_operand" "f,<Rf>")))]
5254 "TARGET_HARD_FLOAT"
5255 "@
5256 m<xdee><bt>r\t%0,<op1>%2
5257 m<xdee>b\t%0,%2"
5258 [(set_attr "op_type" "<RRer>,RXE")
5259 (set_attr "type" "fmul<mode>")])
5260
5261 ; madbr, maebr, maxb, madb, maeb
5262 (define_insn "*fmadd<mode>"
5263 [(set (match_operand:DSF 0 "register_operand" "=f,f")
5264 (plus:DSF (mult:DSF (match_operand:DSF 1 "register_operand" "%f,f")
5265 (match_operand:DSF 2 "nonimmediate_operand" "f,R"))
5266 (match_operand:DSF 3 "register_operand" "0,0")))]
5267 "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5268 "@
5269 ma<xde>br\t%0,%1,%2
5270 ma<xde>b\t%0,%1,%2"
5271 [(set_attr "op_type" "RRE,RXE")
5272 (set_attr "type" "fmul<mode>")])
5273
5274 ; msxbr, msdbr, msebr, msxb, msdb, mseb
5275 (define_insn "*fmsub<mode>"
5276 [(set (match_operand:DSF 0 "register_operand" "=f,f")
5277 (minus:DSF (mult:DSF (match_operand:DSF 1 "register_operand" "f,f")
5278 (match_operand:DSF 2 "nonimmediate_operand" "f,R"))
5279 (match_operand:DSF 3 "register_operand" "0,0")))]
5280 "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5281 "@
5282 ms<xde>br\t%0,%1,%2
5283 ms<xde>b\t%0,%1,%2"
5284 [(set_attr "op_type" "RRE,RXE")
5285 (set_attr "type" "fmul<mode>")])
5286
5287 ;;
5288 ;;- Divide and modulo instructions.
5289 ;;
5290
5291 ;
5292 ; divmoddi4 instruction pattern(s).
5293 ;
5294
5295 (define_expand "divmoddi4"
5296 [(parallel [(set (match_operand:DI 0 "general_operand" "")
5297 (div:DI (match_operand:DI 1 "register_operand" "")
5298 (match_operand:DI 2 "general_operand" "")))
5299 (set (match_operand:DI 3 "general_operand" "")
5300 (mod:DI (match_dup 1) (match_dup 2)))])
5301 (clobber (match_dup 4))]
5302 "TARGET_64BIT"
5303 {
5304 rtx insn, div_equal, mod_equal;
5305
5306 div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
5307 mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
5308
5309 operands[4] = gen_reg_rtx(TImode);
5310 emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
5311
5312 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
5313 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5314
5315 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
5316 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5317
5318 DONE;
5319 })
5320
5321 (define_insn "divmodtidi3"
5322 [(set (match_operand:TI 0 "register_operand" "=d,d")
5323 (ior:TI
5324 (ashift:TI
5325 (zero_extend:TI
5326 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5327 (match_operand:DI 2 "general_operand" "d,RT")))
5328 (const_int 64))
5329 (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
5330 "TARGET_64BIT"
5331 "@
5332 dsgr\t%0,%2
5333 dsg\t%0,%2"
5334 [(set_attr "op_type" "RRE,RXY")
5335 (set_attr "type" "idiv")])
5336
5337 (define_insn "divmodtisi3"
5338 [(set (match_operand:TI 0 "register_operand" "=d,d")
5339 (ior:TI
5340 (ashift:TI
5341 (zero_extend:TI
5342 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5343 (sign_extend:DI
5344 (match_operand:SI 2 "nonimmediate_operand" "d,RT"))))
5345 (const_int 64))
5346 (zero_extend:TI
5347 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
5348 "TARGET_64BIT"
5349 "@
5350 dsgfr\t%0,%2
5351 dsgf\t%0,%2"
5352 [(set_attr "op_type" "RRE,RXY")
5353 (set_attr "type" "idiv")])
5354
5355 ;
5356 ; udivmoddi4 instruction pattern(s).
5357 ;
5358
5359 (define_expand "udivmoddi4"
5360 [(parallel [(set (match_operand:DI 0 "general_operand" "")
5361 (udiv:DI (match_operand:DI 1 "general_operand" "")
5362 (match_operand:DI 2 "nonimmediate_operand" "")))
5363 (set (match_operand:DI 3 "general_operand" "")
5364 (umod:DI (match_dup 1) (match_dup 2)))])
5365 (clobber (match_dup 4))]
5366 "TARGET_64BIT"
5367 {
5368 rtx insn, div_equal, mod_equal, equal;
5369
5370 div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
5371 mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
5372 equal = gen_rtx_IOR (TImode,
5373 gen_rtx_ASHIFT (TImode,
5374 gen_rtx_ZERO_EXTEND (TImode, mod_equal),
5375 GEN_INT (64)),
5376 gen_rtx_ZERO_EXTEND (TImode, div_equal));
5377
5378 operands[4] = gen_reg_rtx(TImode);
5379 emit_clobber (operands[4]);
5380 emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
5381 emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
5382
5383 insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
5384 set_unique_reg_note (insn, REG_EQUAL, equal);
5385
5386 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
5387 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5388
5389 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
5390 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5391
5392 DONE;
5393 })
5394
5395 (define_insn "udivmodtidi3"
5396 [(set (match_operand:TI 0 "register_operand" "=d,d")
5397 (ior:TI
5398 (ashift:TI
5399 (zero_extend:TI
5400 (truncate:DI
5401 (umod:TI (match_operand:TI 1 "register_operand" "0,0")
5402 (zero_extend:TI
5403 (match_operand:DI 2 "nonimmediate_operand" "d,RT")))))
5404 (const_int 64))
5405 (zero_extend:TI
5406 (truncate:DI
5407 (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
5408 "TARGET_64BIT"
5409 "@
5410 dlgr\t%0,%2
5411 dlg\t%0,%2"
5412 [(set_attr "op_type" "RRE,RXY")
5413 (set_attr "type" "idiv")])
5414
5415 ;
5416 ; divmodsi4 instruction pattern(s).
5417 ;
5418
5419 (define_expand "divmodsi4"
5420 [(parallel [(set (match_operand:SI 0 "general_operand" "")
5421 (div:SI (match_operand:SI 1 "general_operand" "")
5422 (match_operand:SI 2 "nonimmediate_operand" "")))
5423 (set (match_operand:SI 3 "general_operand" "")
5424 (mod:SI (match_dup 1) (match_dup 2)))])
5425 (clobber (match_dup 4))]
5426 "!TARGET_64BIT"
5427 {
5428 rtx insn, div_equal, mod_equal, equal;
5429
5430 div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
5431 mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
5432 equal = gen_rtx_IOR (DImode,
5433 gen_rtx_ASHIFT (DImode,
5434 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5435 GEN_INT (32)),
5436 gen_rtx_ZERO_EXTEND (DImode, div_equal));
5437
5438 operands[4] = gen_reg_rtx(DImode);
5439 emit_insn (gen_extendsidi2 (operands[4], operands[1]));
5440
5441 insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
5442 set_unique_reg_note (insn, REG_EQUAL, equal);
5443
5444 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
5445 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5446
5447 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
5448 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5449
5450 DONE;
5451 })
5452
5453 (define_insn "divmoddisi3"
5454 [(set (match_operand:DI 0 "register_operand" "=d,d")
5455 (ior:DI
5456 (ashift:DI
5457 (zero_extend:DI
5458 (truncate:SI
5459 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5460 (sign_extend:DI
5461 (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
5462 (const_int 32))
5463 (zero_extend:DI
5464 (truncate:SI
5465 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
5466 "!TARGET_64BIT"
5467 "@
5468 dr\t%0,%2
5469 d\t%0,%2"
5470 [(set_attr "op_type" "RR,RX")
5471 (set_attr "type" "idiv")])
5472
5473 ;
5474 ; udivsi3 and umodsi3 instruction pattern(s).
5475 ;
5476
5477 (define_expand "udivmodsi4"
5478 [(parallel [(set (match_operand:SI 0 "general_operand" "")
5479 (udiv:SI (match_operand:SI 1 "general_operand" "")
5480 (match_operand:SI 2 "nonimmediate_operand" "")))
5481 (set (match_operand:SI 3 "general_operand" "")
5482 (umod:SI (match_dup 1) (match_dup 2)))])
5483 (clobber (match_dup 4))]
5484 "!TARGET_64BIT && TARGET_CPU_ZARCH"
5485 {
5486 rtx insn, div_equal, mod_equal, equal;
5487
5488 div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
5489 mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
5490 equal = gen_rtx_IOR (DImode,
5491 gen_rtx_ASHIFT (DImode,
5492 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5493 GEN_INT (32)),
5494 gen_rtx_ZERO_EXTEND (DImode, div_equal));
5495
5496 operands[4] = gen_reg_rtx(DImode);
5497 emit_clobber (operands[4]);
5498 emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
5499 emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
5500
5501 insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
5502 set_unique_reg_note (insn, REG_EQUAL, equal);
5503
5504 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
5505 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5506
5507 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
5508 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5509
5510 DONE;
5511 })
5512
5513 (define_insn "udivmoddisi3"
5514 [(set (match_operand:DI 0 "register_operand" "=d,d")
5515 (ior:DI
5516 (ashift:DI
5517 (zero_extend:DI
5518 (truncate:SI
5519 (umod:DI (match_operand:DI 1 "register_operand" "0,0")
5520 (zero_extend:DI
5521 (match_operand:SI 2 "nonimmediate_operand" "d,RT")))))
5522 (const_int 32))
5523 (zero_extend:DI
5524 (truncate:SI
5525 (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
5526 "!TARGET_64BIT && TARGET_CPU_ZARCH"
5527 "@
5528 dlr\t%0,%2
5529 dl\t%0,%2"
5530 [(set_attr "op_type" "RRE,RXY")
5531 (set_attr "type" "idiv")])
5532
5533 (define_expand "udivsi3"
5534 [(set (match_operand:SI 0 "register_operand" "=d")
5535 (udiv:SI (match_operand:SI 1 "general_operand" "")
5536 (match_operand:SI 2 "general_operand" "")))
5537 (clobber (match_dup 3))]
5538 "!TARGET_64BIT && !TARGET_CPU_ZARCH"
5539 {
5540 rtx insn, udiv_equal, umod_equal, equal;
5541
5542 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
5543 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
5544 equal = gen_rtx_IOR (DImode,
5545 gen_rtx_ASHIFT (DImode,
5546 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5547 GEN_INT (32)),
5548 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
5549
5550 operands[3] = gen_reg_rtx (DImode);
5551
5552 if (CONSTANT_P (operands[2]))
5553 {
5554 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
5555 {
5556 rtx label1 = gen_label_rtx ();
5557
5558 operands[1] = make_safe_from (operands[1], operands[0]);
5559 emit_move_insn (operands[0], const0_rtx);
5560 emit_insn (gen_cmpsi (operands[1], operands[2]));
5561 emit_jump_insn (gen_bltu (label1));
5562 emit_move_insn (operands[0], const1_rtx);
5563 emit_label (label1);
5564 }
5565 else
5566 {
5567 operands[2] = force_reg (SImode, operands[2]);
5568 operands[2] = make_safe_from (operands[2], operands[0]);
5569
5570 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5571 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5572 operands[2]));
5573 set_unique_reg_note (insn, REG_EQUAL, equal);
5574
5575 insn = emit_move_insn (operands[0],
5576 gen_lowpart (SImode, operands[3]));
5577 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
5578 }
5579 }
5580 else
5581 {
5582 rtx label1 = gen_label_rtx ();
5583 rtx label2 = gen_label_rtx ();
5584 rtx label3 = gen_label_rtx ();
5585
5586 operands[1] = force_reg (SImode, operands[1]);
5587 operands[1] = make_safe_from (operands[1], operands[0]);
5588 operands[2] = force_reg (SImode, operands[2]);
5589 operands[2] = make_safe_from (operands[2], operands[0]);
5590
5591 emit_move_insn (operands[0], const0_rtx);
5592 emit_insn (gen_cmpsi (operands[2], operands[1]));
5593 emit_jump_insn (gen_bgtu (label3));
5594 emit_insn (gen_cmpsi (operands[2], const0_rtx));
5595 emit_jump_insn (gen_blt (label2));
5596 emit_insn (gen_cmpsi (operands[2], const1_rtx));
5597 emit_jump_insn (gen_beq (label1));
5598 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5599 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5600 operands[2]));
5601 set_unique_reg_note (insn, REG_EQUAL, equal);
5602
5603 insn = emit_move_insn (operands[0],
5604 gen_lowpart (SImode, operands[3]));
5605 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
5606
5607 emit_jump (label3);
5608 emit_label (label1);
5609 emit_move_insn (operands[0], operands[1]);
5610 emit_jump (label3);
5611 emit_label (label2);
5612 emit_move_insn (operands[0], const1_rtx);
5613 emit_label (label3);
5614 }
5615 emit_move_insn (operands[0], operands[0]);
5616 DONE;
5617 })
5618
5619 (define_expand "umodsi3"
5620 [(set (match_operand:SI 0 "register_operand" "=d")
5621 (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
5622 (match_operand:SI 2 "nonimmediate_operand" "")))
5623 (clobber (match_dup 3))]
5624 "!TARGET_64BIT && !TARGET_CPU_ZARCH"
5625 {
5626 rtx insn, udiv_equal, umod_equal, equal;
5627
5628 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
5629 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
5630 equal = gen_rtx_IOR (DImode,
5631 gen_rtx_ASHIFT (DImode,
5632 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5633 GEN_INT (32)),
5634 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
5635
5636 operands[3] = gen_reg_rtx (DImode);
5637
5638 if (CONSTANT_P (operands[2]))
5639 {
5640 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
5641 {
5642 rtx label1 = gen_label_rtx ();
5643
5644 operands[1] = make_safe_from (operands[1], operands[0]);
5645 emit_move_insn (operands[0], operands[1]);
5646 emit_insn (gen_cmpsi (operands[0], operands[2]));
5647 emit_jump_insn (gen_bltu (label1));
5648 emit_insn (gen_abssi2 (operands[0], operands[2]));
5649 emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
5650 emit_label (label1);
5651 }
5652 else
5653 {
5654 operands[2] = force_reg (SImode, operands[2]);
5655 operands[2] = make_safe_from (operands[2], operands[0]);
5656
5657 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5658 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5659 operands[2]));
5660 set_unique_reg_note (insn, REG_EQUAL, equal);
5661
5662 insn = emit_move_insn (operands[0],
5663 gen_highpart (SImode, operands[3]));
5664 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
5665 }
5666 }
5667 else
5668 {
5669 rtx label1 = gen_label_rtx ();
5670 rtx label2 = gen_label_rtx ();
5671 rtx label3 = gen_label_rtx ();
5672
5673 operands[1] = force_reg (SImode, operands[1]);
5674 operands[1] = make_safe_from (operands[1], operands[0]);
5675 operands[2] = force_reg (SImode, operands[2]);
5676 operands[2] = make_safe_from (operands[2], operands[0]);
5677
5678 emit_move_insn(operands[0], operands[1]);
5679 emit_insn (gen_cmpsi (operands[2], operands[1]));
5680 emit_jump_insn (gen_bgtu (label3));
5681 emit_insn (gen_cmpsi (operands[2], const0_rtx));
5682 emit_jump_insn (gen_blt (label2));
5683 emit_insn (gen_cmpsi (operands[2], const1_rtx));
5684 emit_jump_insn (gen_beq (label1));
5685 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5686 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5687 operands[2]));
5688 set_unique_reg_note (insn, REG_EQUAL, equal);
5689
5690 insn = emit_move_insn (operands[0],
5691 gen_highpart (SImode, operands[3]));
5692 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
5693
5694 emit_jump (label3);
5695 emit_label (label1);
5696 emit_move_insn (operands[0], const0_rtx);
5697 emit_jump (label3);
5698 emit_label (label2);
5699 emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
5700 emit_label (label3);
5701 }
5702 DONE;
5703 })
5704
5705 ;
5706 ; div(df|sf)3 instruction pattern(s).
5707 ;
5708
5709 ; dxbr, ddbr, debr, dxb, ddb, deb, ddtr, dxtr
5710 (define_insn "div<mode>3"
5711 [(set (match_operand:FP 0 "register_operand" "=f,f")
5712 (div:FP (match_operand:FP 1 "register_operand" "<f0>,0")
5713 (match_operand:FP 2 "general_operand" "f,<Rf>")))]
5714 "TARGET_HARD_FLOAT"
5715 "@
5716 d<xde><bt>r\t%0,<op1>%2
5717 d<xde>b\t%0,%2"
5718 [(set_attr "op_type" "<RRer>,RXE")
5719 (set_attr "type" "fdiv<mode>")])
5720
5721
5722 ;;
5723 ;;- And instructions.
5724 ;;
5725
5726 (define_expand "and<mode>3"
5727 [(set (match_operand:INT 0 "nonimmediate_operand" "")
5728 (and:INT (match_operand:INT 1 "nonimmediate_operand" "")
5729 (match_operand:INT 2 "general_operand" "")))
5730 (clobber (reg:CC CC_REGNUM))]
5731 ""
5732 "s390_expand_logical_operator (AND, <MODE>mode, operands); DONE;")
5733
5734 ;
5735 ; anddi3 instruction pattern(s).
5736 ;
5737
5738 (define_insn "*anddi3_cc"
5739 [(set (reg CC_REGNUM)
5740 (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5741 (match_operand:DI 2 "general_operand" "d,RT"))
5742 (const_int 0)))
5743 (set (match_operand:DI 0 "register_operand" "=d,d")
5744 (and:DI (match_dup 1) (match_dup 2)))]
5745 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5746 "@
5747 ngr\t%0,%2
5748 ng\t%0,%2"
5749 [(set_attr "op_type" "RRE,RXY")
5750 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
5751
5752 (define_insn "*anddi3_cconly"
5753 [(set (reg CC_REGNUM)
5754 (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5755 (match_operand:DI 2 "general_operand" "d,RT"))
5756 (const_int 0)))
5757 (clobber (match_scratch:DI 0 "=d,d"))]
5758 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT
5759 /* Do not steal TM patterns. */
5760 && s390_single_part (operands[2], DImode, HImode, 0) < 0"
5761 "@
5762 ngr\t%0,%2
5763 ng\t%0,%2"
5764 [(set_attr "op_type" "RRE,RXY")
5765 (set_attr "z10prop" "z10_super_E1, z10_super_E1")])
5766
5767 (define_insn "*anddi3"
5768 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,d,d,AQ,Q")
5769 (and:DI (match_operand:DI 1 "nonimmediate_operand"
5770 "%d,o,0,0,0,0,0,0,0,0,0,0")
5771 (match_operand:DI 2 "general_operand"
5772 "M,M,N0HDF,N1HDF,N2HDF,N3HDF,N0SDF,N1SDF,d,RT,NxQDF,Q")))
5773 (clobber (reg:CC CC_REGNUM))]
5774 "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
5775 "@
5776 #
5777 #
5778 nihh\t%0,%j2
5779 nihl\t%0,%j2
5780 nilh\t%0,%j2
5781 nill\t%0,%j2
5782 nihf\t%0,%m2
5783 nilf\t%0,%m2
5784 ngr\t%0,%2
5785 ng\t%0,%2
5786 #
5787 #"
5788 [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RIL,RIL,RRE,RXY,SI,SS")
5789 (set_attr "cpu_facility" "*,*,*,*,*,*,extimm,extimm,*,*,*,*")
5790 (set_attr "z10prop" "*,
5791 *,
5792 z10_super_E1,
5793 z10_super_E1,
5794 z10_super_E1,
5795 z10_super_E1,
5796 z10_super_E1,
5797 z10_super_E1,
5798 z10_super_E1,
5799 z10_super_E1,
5800 *,
5801 *")])
5802
5803 (define_split
5804 [(set (match_operand:DI 0 "s_operand" "")
5805 (and:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
5806 (clobber (reg:CC CC_REGNUM))]
5807 "reload_completed"
5808 [(parallel
5809 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5810 (clobber (reg:CC CC_REGNUM))])]
5811 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5812
5813
5814 ;
5815 ; andsi3 instruction pattern(s).
5816 ;
5817
5818 (define_insn "*andsi3_cc"
5819 [(set (reg CC_REGNUM)
5820 (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5821 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
5822 (const_int 0)))
5823 (set (match_operand:SI 0 "register_operand" "=d,d,d,d")
5824 (and:SI (match_dup 1) (match_dup 2)))]
5825 "s390_match_ccmode(insn, CCTmode)"
5826 "@
5827 nilf\t%0,%o2
5828 nr\t%0,%2
5829 n\t%0,%2
5830 ny\t%0,%2"
5831 [(set_attr "op_type" "RIL,RR,RX,RXY")
5832 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
5833
5834 (define_insn "*andsi3_cconly"
5835 [(set (reg CC_REGNUM)
5836 (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5837 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
5838 (const_int 0)))
5839 (clobber (match_scratch:SI 0 "=d,d,d,d"))]
5840 "s390_match_ccmode(insn, CCTmode)
5841 /* Do not steal TM patterns. */
5842 && s390_single_part (operands[2], SImode, HImode, 0) < 0"
5843 "@
5844 nilf\t%0,%o2
5845 nr\t%0,%2
5846 n\t%0,%2
5847 ny\t%0,%2"
5848 [(set_attr "op_type" "RIL,RR,RX,RXY")
5849 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
5850
5851 (define_insn "*andsi3_zarch"
5852 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
5853 (and:SI (match_operand:SI 1 "nonimmediate_operand"
5854 "%d,o,0,0,0,0,0,0,0,0")
5855 (match_operand:SI 2 "general_operand"
5856 "M,M,N0HSF,N1HSF,Os,d,R,T,NxQSF,Q")))
5857 (clobber (reg:CC CC_REGNUM))]
5858 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5859 "@
5860 #
5861 #
5862 nilh\t%0,%j2
5863 nill\t%0,%j2
5864 nilf\t%0,%o2
5865 nr\t%0,%2
5866 n\t%0,%2
5867 ny\t%0,%2
5868 #
5869 #"
5870 [(set_attr "op_type" "RRE,RXE,RI,RI,RIL,RR,RX,RXY,SI,SS")
5871 (set_attr "z10prop" "*,
5872 *,
5873 z10_super_E1,
5874 z10_super_E1,
5875 z10_super_E1,
5876 z10_super_E1,
5877 z10_super_E1,
5878 z10_super_E1,
5879 *,
5880 *")])
5881
5882 (define_insn "*andsi3_esa"
5883 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5884 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5885 (match_operand:SI 2 "general_operand" "d,R,NxQSF,Q")))
5886 (clobber (reg:CC CC_REGNUM))]
5887 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5888 "@
5889 nr\t%0,%2
5890 n\t%0,%2
5891 #
5892 #"
5893 [(set_attr "op_type" "RR,RX,SI,SS")
5894 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
5895
5896
5897 (define_split
5898 [(set (match_operand:SI 0 "s_operand" "")
5899 (and:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
5900 (clobber (reg:CC CC_REGNUM))]
5901 "reload_completed"
5902 [(parallel
5903 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5904 (clobber (reg:CC CC_REGNUM))])]
5905 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5906
5907 ;
5908 ; andhi3 instruction pattern(s).
5909 ;
5910
5911 (define_insn "*andhi3_zarch"
5912 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5913 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
5914 (match_operand:HI 2 "general_operand" "d,n,NxQHF,Q")))
5915 (clobber (reg:CC CC_REGNUM))]
5916 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5917 "@
5918 nr\t%0,%2
5919 nill\t%0,%x2
5920 #
5921 #"
5922 [(set_attr "op_type" "RR,RI,SI,SS")
5923 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")
5924 ])
5925
5926 (define_insn "*andhi3_esa"
5927 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
5928 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
5929 (match_operand:HI 2 "general_operand" "d,NxQHF,Q")))
5930 (clobber (reg:CC CC_REGNUM))]
5931 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5932 "@
5933 nr\t%0,%2
5934 #
5935 #"
5936 [(set_attr "op_type" "RR,SI,SS")
5937 (set_attr "z10prop" "z10_super_E1,*,*")
5938 ])
5939
5940 (define_split
5941 [(set (match_operand:HI 0 "s_operand" "")
5942 (and:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
5943 (clobber (reg:CC CC_REGNUM))]
5944 "reload_completed"
5945 [(parallel
5946 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5947 (clobber (reg:CC CC_REGNUM))])]
5948 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5949
5950 ;
5951 ; andqi3 instruction pattern(s).
5952 ;
5953
5954 (define_insn "*andqi3_zarch"
5955 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
5956 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
5957 (match_operand:QI 2 "general_operand" "d,n,n,n,Q")))
5958 (clobber (reg:CC CC_REGNUM))]
5959 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5960 "@
5961 nr\t%0,%2
5962 nill\t%0,%b2
5963 ni\t%S0,%b2
5964 niy\t%S0,%b2
5965 #"
5966 [(set_attr "op_type" "RR,RI,SI,SIY,SS")
5967 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super,z10_super,*")])
5968
5969 (define_insn "*andqi3_esa"
5970 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
5971 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
5972 (match_operand:QI 2 "general_operand" "d,n,Q")))
5973 (clobber (reg:CC CC_REGNUM))]
5974 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5975 "@
5976 nr\t%0,%2
5977 ni\t%S0,%b2
5978 #"
5979 [(set_attr "op_type" "RR,SI,SS")
5980 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
5981
5982 ;
5983 ; Block and (NC) patterns.
5984 ;
5985
5986 (define_insn "*nc"
5987 [(set (match_operand:BLK 0 "memory_operand" "=Q")
5988 (and:BLK (match_dup 0)
5989 (match_operand:BLK 1 "memory_operand" "Q")))
5990 (use (match_operand 2 "const_int_operand" "n"))
5991 (clobber (reg:CC CC_REGNUM))]
5992 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
5993 "nc\t%O0(%2,%R0),%S1"
5994 [(set_attr "op_type" "SS")])
5995
5996 (define_split
5997 [(set (match_operand 0 "memory_operand" "")
5998 (and (match_dup 0)
5999 (match_operand 1 "memory_operand" "")))
6000 (clobber (reg:CC CC_REGNUM))]
6001 "reload_completed
6002 && GET_MODE (operands[0]) == GET_MODE (operands[1])
6003 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6004 [(parallel
6005 [(set (match_dup 0) (and:BLK (match_dup 0) (match_dup 1)))
6006 (use (match_dup 2))
6007 (clobber (reg:CC CC_REGNUM))])]
6008 {
6009 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6010 operands[0] = adjust_address (operands[0], BLKmode, 0);
6011 operands[1] = adjust_address (operands[1], BLKmode, 0);
6012 })
6013
6014 (define_peephole2
6015 [(parallel
6016 [(set (match_operand:BLK 0 "memory_operand" "")
6017 (and:BLK (match_dup 0)
6018 (match_operand:BLK 1 "memory_operand" "")))
6019 (use (match_operand 2 "const_int_operand" ""))
6020 (clobber (reg:CC CC_REGNUM))])
6021 (parallel
6022 [(set (match_operand:BLK 3 "memory_operand" "")
6023 (and:BLK (match_dup 3)
6024 (match_operand:BLK 4 "memory_operand" "")))
6025 (use (match_operand 5 "const_int_operand" ""))
6026 (clobber (reg:CC CC_REGNUM))])]
6027 "s390_offset_p (operands[0], operands[3], operands[2])
6028 && s390_offset_p (operands[1], operands[4], operands[2])
6029 && !s390_overlap_p (operands[0], operands[1],
6030 INTVAL (operands[2]) + INTVAL (operands[5]))
6031 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6032 [(parallel
6033 [(set (match_dup 6) (and:BLK (match_dup 6) (match_dup 7)))
6034 (use (match_dup 8))
6035 (clobber (reg:CC CC_REGNUM))])]
6036 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6037 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6038 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6039
6040
6041 ;;
6042 ;;- Bit set (inclusive or) instructions.
6043 ;;
6044
6045 (define_expand "ior<mode>3"
6046 [(set (match_operand:INT 0 "nonimmediate_operand" "")
6047 (ior:INT (match_operand:INT 1 "nonimmediate_operand" "")
6048 (match_operand:INT 2 "general_operand" "")))
6049 (clobber (reg:CC CC_REGNUM))]
6050 ""
6051 "s390_expand_logical_operator (IOR, <MODE>mode, operands); DONE;")
6052
6053 ;
6054 ; iordi3 instruction pattern(s).
6055 ;
6056
6057 (define_insn "*iordi3_cc"
6058 [(set (reg CC_REGNUM)
6059 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
6060 (match_operand:DI 2 "general_operand" "d,RT"))
6061 (const_int 0)))
6062 (set (match_operand:DI 0 "register_operand" "=d,d")
6063 (ior:DI (match_dup 1) (match_dup 2)))]
6064 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
6065 "@
6066 ogr\t%0,%2
6067 og\t%0,%2"
6068 [(set_attr "op_type" "RRE,RXY")
6069 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6070
6071 (define_insn "*iordi3_cconly"
6072 [(set (reg CC_REGNUM)
6073 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
6074 (match_operand:DI 2 "general_operand" "d,RT"))
6075 (const_int 0)))
6076 (clobber (match_scratch:DI 0 "=d,d"))]
6077 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
6078 "@
6079 ogr\t%0,%2
6080 og\t%0,%2"
6081 [(set_attr "op_type" "RRE,RXY")
6082 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6083
6084 (define_insn "*iordi3"
6085 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
6086 (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0,0,0,0")
6087 (match_operand:DI 2 "general_operand"
6088 "N0HD0,N1HD0,N2HD0,N3HD0,N0SD0,N1SD0,d,RT,NxQD0,Q")))
6089 (clobber (reg:CC CC_REGNUM))]
6090 "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
6091 "@
6092 oihh\t%0,%i2
6093 oihl\t%0,%i2
6094 oilh\t%0,%i2
6095 oill\t%0,%i2
6096 oihf\t%0,%k2
6097 oilf\t%0,%k2
6098 ogr\t%0,%2
6099 og\t%0,%2
6100 #
6101 #"
6102 [(set_attr "op_type" "RI,RI,RI,RI,RIL,RIL,RRE,RXY,SI,SS")
6103 (set_attr "cpu_facility" "*,*,*,*,extimm,extimm,*,*,*,*")
6104 (set_attr "z10prop" "z10_super_E1,
6105 z10_super_E1,
6106 z10_super_E1,
6107 z10_super_E1,
6108 z10_super_E1,
6109 z10_super_E1,
6110 z10_super_E1,
6111 z10_super_E1,
6112 *,
6113 *")])
6114
6115 (define_split
6116 [(set (match_operand:DI 0 "s_operand" "")
6117 (ior:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
6118 (clobber (reg:CC CC_REGNUM))]
6119 "reload_completed"
6120 [(parallel
6121 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6122 (clobber (reg:CC CC_REGNUM))])]
6123 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6124
6125 ;
6126 ; iorsi3 instruction pattern(s).
6127 ;
6128
6129 (define_insn "*iorsi3_cc"
6130 [(set (reg CC_REGNUM)
6131 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6132 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
6133 (const_int 0)))
6134 (set (match_operand:SI 0 "register_operand" "=d,d,d,d")
6135 (ior:SI (match_dup 1) (match_dup 2)))]
6136 "s390_match_ccmode(insn, CCTmode)"
6137 "@
6138 oilf\t%0,%o2
6139 or\t%0,%2
6140 o\t%0,%2
6141 oy\t%0,%2"
6142 [(set_attr "op_type" "RIL,RR,RX,RXY")
6143 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
6144
6145 (define_insn "*iorsi3_cconly"
6146 [(set (reg CC_REGNUM)
6147 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6148 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
6149 (const_int 0)))
6150 (clobber (match_scratch:SI 0 "=d,d,d,d"))]
6151 "s390_match_ccmode(insn, CCTmode)"
6152 "@
6153 oilf\t%0,%o2
6154 or\t%0,%2
6155 o\t%0,%2
6156 oy\t%0,%2"
6157 [(set_attr "op_type" "RIL,RR,RX,RXY")
6158 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
6159
6160 (define_insn "*iorsi3_zarch"
6161 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,AQ,Q")
6162 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0,0")
6163 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,Os,d,R,T,NxQS0,Q")))
6164 (clobber (reg:CC CC_REGNUM))]
6165 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6166 "@
6167 oilh\t%0,%i2
6168 oill\t%0,%i2
6169 oilf\t%0,%o2
6170 or\t%0,%2
6171 o\t%0,%2
6172 oy\t%0,%2
6173 #
6174 #"
6175 [(set_attr "op_type" "RI,RI,RIL,RR,RX,RXY,SI,SS")
6176 (set_attr "z10prop" "z10_super_E1,
6177 z10_super_E1,
6178 z10_super_E1,
6179 z10_super_E1,
6180 z10_super_E1,
6181 z10_super_E1,
6182 *,
6183 *")])
6184
6185 (define_insn "*iorsi3_esa"
6186 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
6187 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6188 (match_operand:SI 2 "general_operand" "d,R,NxQS0,Q")))
6189 (clobber (reg:CC CC_REGNUM))]
6190 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6191 "@
6192 or\t%0,%2
6193 o\t%0,%2
6194 #
6195 #"
6196 [(set_attr "op_type" "RR,RX,SI,SS")
6197 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6198
6199 (define_split
6200 [(set (match_operand:SI 0 "s_operand" "")
6201 (ior:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
6202 (clobber (reg:CC CC_REGNUM))]
6203 "reload_completed"
6204 [(parallel
6205 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6206 (clobber (reg:CC CC_REGNUM))])]
6207 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6208
6209 ;
6210 ; iorhi3 instruction pattern(s).
6211 ;
6212
6213 (define_insn "*iorhi3_zarch"
6214 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
6215 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
6216 (match_operand:HI 2 "general_operand" "d,n,NxQH0,Q")))
6217 (clobber (reg:CC CC_REGNUM))]
6218 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6219 "@
6220 or\t%0,%2
6221 oill\t%0,%x2
6222 #
6223 #"
6224 [(set_attr "op_type" "RR,RI,SI,SS")
6225 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6226
6227 (define_insn "*iorhi3_esa"
6228 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
6229 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
6230 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
6231 (clobber (reg:CC CC_REGNUM))]
6232 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6233 "@
6234 or\t%0,%2
6235 #
6236 #"
6237 [(set_attr "op_type" "RR,SI,SS")
6238 (set_attr "z10prop" "z10_super_E1,*,*")])
6239
6240 (define_split
6241 [(set (match_operand:HI 0 "s_operand" "")
6242 (ior:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
6243 (clobber (reg:CC CC_REGNUM))]
6244 "reload_completed"
6245 [(parallel
6246 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6247 (clobber (reg:CC CC_REGNUM))])]
6248 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6249
6250 ;
6251 ; iorqi3 instruction pattern(s).
6252 ;
6253
6254 (define_insn "*iorqi3_zarch"
6255 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
6256 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
6257 (match_operand:QI 2 "general_operand" "d,n,n,n,Q")))
6258 (clobber (reg:CC CC_REGNUM))]
6259 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6260 "@
6261 or\t%0,%2
6262 oill\t%0,%b2
6263 oi\t%S0,%b2
6264 oiy\t%S0,%b2
6265 #"
6266 [(set_attr "op_type" "RR,RI,SI,SIY,SS")
6267 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super,z10_super,*")])
6268
6269 (define_insn "*iorqi3_esa"
6270 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
6271 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6272 (match_operand:QI 2 "general_operand" "d,n,Q")))
6273 (clobber (reg:CC CC_REGNUM))]
6274 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6275 "@
6276 or\t%0,%2
6277 oi\t%S0,%b2
6278 #"
6279 [(set_attr "op_type" "RR,SI,SS")
6280 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
6281
6282 ;
6283 ; Block inclusive or (OC) patterns.
6284 ;
6285
6286 (define_insn "*oc"
6287 [(set (match_operand:BLK 0 "memory_operand" "=Q")
6288 (ior:BLK (match_dup 0)
6289 (match_operand:BLK 1 "memory_operand" "Q")))
6290 (use (match_operand 2 "const_int_operand" "n"))
6291 (clobber (reg:CC CC_REGNUM))]
6292 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
6293 "oc\t%O0(%2,%R0),%S1"
6294 [(set_attr "op_type" "SS")])
6295
6296 (define_split
6297 [(set (match_operand 0 "memory_operand" "")
6298 (ior (match_dup 0)
6299 (match_operand 1 "memory_operand" "")))
6300 (clobber (reg:CC CC_REGNUM))]
6301 "reload_completed
6302 && GET_MODE (operands[0]) == GET_MODE (operands[1])
6303 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6304 [(parallel
6305 [(set (match_dup 0) (ior:BLK (match_dup 0) (match_dup 1)))
6306 (use (match_dup 2))
6307 (clobber (reg:CC CC_REGNUM))])]
6308 {
6309 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6310 operands[0] = adjust_address (operands[0], BLKmode, 0);
6311 operands[1] = adjust_address (operands[1], BLKmode, 0);
6312 })
6313
6314 (define_peephole2
6315 [(parallel
6316 [(set (match_operand:BLK 0 "memory_operand" "")
6317 (ior:BLK (match_dup 0)
6318 (match_operand:BLK 1 "memory_operand" "")))
6319 (use (match_operand 2 "const_int_operand" ""))
6320 (clobber (reg:CC CC_REGNUM))])
6321 (parallel
6322 [(set (match_operand:BLK 3 "memory_operand" "")
6323 (ior:BLK (match_dup 3)
6324 (match_operand:BLK 4 "memory_operand" "")))
6325 (use (match_operand 5 "const_int_operand" ""))
6326 (clobber (reg:CC CC_REGNUM))])]
6327 "s390_offset_p (operands[0], operands[3], operands[2])
6328 && s390_offset_p (operands[1], operands[4], operands[2])
6329 && !s390_overlap_p (operands[0], operands[1],
6330 INTVAL (operands[2]) + INTVAL (operands[5]))
6331 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6332 [(parallel
6333 [(set (match_dup 6) (ior:BLK (match_dup 6) (match_dup 7)))
6334 (use (match_dup 8))
6335 (clobber (reg:CC CC_REGNUM))])]
6336 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6337 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6338 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6339
6340
6341 ;;
6342 ;;- Xor instructions.
6343 ;;
6344
6345 (define_expand "xor<mode>3"
6346 [(set (match_operand:INT 0 "nonimmediate_operand" "")
6347 (xor:INT (match_operand:INT 1 "nonimmediate_operand" "")
6348 (match_operand:INT 2 "general_operand" "")))
6349 (clobber (reg:CC CC_REGNUM))]
6350 ""
6351 "s390_expand_logical_operator (XOR, <MODE>mode, operands); DONE;")
6352
6353 ;
6354 ; xordi3 instruction pattern(s).
6355 ;
6356
6357 (define_insn "*xordi3_cc"
6358 [(set (reg CC_REGNUM)
6359 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
6360 (match_operand:DI 2 "general_operand" "d,RT"))
6361 (const_int 0)))
6362 (set (match_operand:DI 0 "register_operand" "=d,d")
6363 (xor:DI (match_dup 1) (match_dup 2)))]
6364 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
6365 "@
6366 xgr\t%0,%2
6367 xg\t%0,%2"
6368 [(set_attr "op_type" "RRE,RXY")
6369 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6370
6371 (define_insn "*xordi3_cconly"
6372 [(set (reg CC_REGNUM)
6373 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
6374 (match_operand:DI 2 "general_operand" "d,RT"))
6375 (const_int 0)))
6376 (clobber (match_scratch:DI 0 "=d,d"))]
6377 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
6378 "@
6379 xgr\t%0,%2
6380 xg\t%0,%2"
6381 [(set_attr "op_type" "RRE,RXY")
6382 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6383
6384 (define_insn "*xordi3"
6385 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,AQ,Q")
6386 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0")
6387 (match_operand:DI 2 "general_operand" "N0SD0,N1SD0,d,RT,NxQD0,Q")))
6388 (clobber (reg:CC CC_REGNUM))]
6389 "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
6390 "@
6391 xihf\t%0,%k2
6392 xilf\t%0,%k2
6393 xgr\t%0,%2
6394 xg\t%0,%2
6395 #
6396 #"
6397 [(set_attr "op_type" "RIL,RIL,RRE,RXY,SI,SS")
6398 (set_attr "cpu_facility" "extimm,extimm,*,*,*,*")
6399 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1,*,*")])
6400
6401 (define_split
6402 [(set (match_operand:DI 0 "s_operand" "")
6403 (xor:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
6404 (clobber (reg:CC CC_REGNUM))]
6405 "reload_completed"
6406 [(parallel
6407 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
6408 (clobber (reg:CC CC_REGNUM))])]
6409 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
6410
6411 ;
6412 ; xorsi3 instruction pattern(s).
6413 ;
6414
6415 (define_insn "*xorsi3_cc"
6416 [(set (reg CC_REGNUM)
6417 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6418 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
6419 (const_int 0)))
6420 (set (match_operand:SI 0 "register_operand" "=d,d,d,d")
6421 (xor:SI (match_dup 1) (match_dup 2)))]
6422 "s390_match_ccmode(insn, CCTmode)"
6423 "@
6424 xilf\t%0,%o2
6425 xr\t%0,%2
6426 x\t%0,%2
6427 xy\t%0,%2"
6428 [(set_attr "op_type" "RIL,RR,RX,RXY")
6429 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
6430
6431 (define_insn "*xorsi3_cconly"
6432 [(set (reg CC_REGNUM)
6433 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6434 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
6435 (const_int 0)))
6436 (clobber (match_scratch:SI 0 "=d,d,d,d"))]
6437 "s390_match_ccmode(insn, CCTmode)"
6438 "@
6439 xilf\t%0,%o2
6440 xr\t%0,%2
6441 x\t%0,%2
6442 xy\t%0,%2"
6443 [(set_attr "op_type" "RIL,RR,RX,RXY")
6444 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
6445
6446 (define_insn "*xorsi3"
6447 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,AQ,Q")
6448 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0,0")
6449 (match_operand:SI 2 "general_operand" "Os,d,R,T,NxQS0,Q")))
6450 (clobber (reg:CC CC_REGNUM))]
6451 "s390_logical_operator_ok_p (operands)"
6452 "@
6453 xilf\t%0,%o2
6454 xr\t%0,%2
6455 x\t%0,%2
6456 xy\t%0,%2
6457 #
6458 #"
6459 [(set_attr "op_type" "RIL,RR,RX,RXY,SI,SS")
6460 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1,*,*")])
6461
6462 (define_split
6463 [(set (match_operand:SI 0 "s_operand" "")
6464 (xor:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
6465 (clobber (reg:CC CC_REGNUM))]
6466 "reload_completed"
6467 [(parallel
6468 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
6469 (clobber (reg:CC CC_REGNUM))])]
6470 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
6471
6472 ;
6473 ; xorhi3 instruction pattern(s).
6474 ;
6475
6476 (define_insn "*xorhi3"
6477 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
6478 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
6479 (match_operand:HI 2 "general_operand" "Os,d,NxQH0,Q")))
6480 (clobber (reg:CC CC_REGNUM))]
6481 "s390_logical_operator_ok_p (operands)"
6482 "@
6483 xilf\t%0,%x2
6484 xr\t%0,%2
6485 #
6486 #"
6487 [(set_attr "op_type" "RIL,RR,SI,SS")
6488 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6489
6490 (define_split
6491 [(set (match_operand:HI 0 "s_operand" "")
6492 (xor:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
6493 (clobber (reg:CC CC_REGNUM))]
6494 "reload_completed"
6495 [(parallel
6496 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
6497 (clobber (reg:CC CC_REGNUM))])]
6498 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
6499
6500 ;
6501 ; xorqi3 instruction pattern(s).
6502 ;
6503
6504 (define_insn "*xorqi3"
6505 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
6506 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
6507 (match_operand:QI 2 "general_operand" "Os,d,n,n,Q")))
6508 (clobber (reg:CC CC_REGNUM))]
6509 "s390_logical_operator_ok_p (operands)"
6510 "@
6511 xilf\t%0,%b2
6512 xr\t%0,%2
6513 xi\t%S0,%b2
6514 xiy\t%S0,%b2
6515 #"
6516 [(set_attr "op_type" "RIL,RR,SI,SIY,SS")
6517 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super,z10_super,*")])
6518
6519
6520 ;
6521 ; Block exclusive or (XC) patterns.
6522 ;
6523
6524 (define_insn "*xc"
6525 [(set (match_operand:BLK 0 "memory_operand" "=Q")
6526 (xor:BLK (match_dup 0)
6527 (match_operand:BLK 1 "memory_operand" "Q")))
6528 (use (match_operand 2 "const_int_operand" "n"))
6529 (clobber (reg:CC CC_REGNUM))]
6530 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
6531 "xc\t%O0(%2,%R0),%S1"
6532 [(set_attr "op_type" "SS")])
6533
6534 (define_split
6535 [(set (match_operand 0 "memory_operand" "")
6536 (xor (match_dup 0)
6537 (match_operand 1 "memory_operand" "")))
6538 (clobber (reg:CC CC_REGNUM))]
6539 "reload_completed
6540 && GET_MODE (operands[0]) == GET_MODE (operands[1])
6541 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6542 [(parallel
6543 [(set (match_dup 0) (xor:BLK (match_dup 0) (match_dup 1)))
6544 (use (match_dup 2))
6545 (clobber (reg:CC CC_REGNUM))])]
6546 {
6547 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6548 operands[0] = adjust_address (operands[0], BLKmode, 0);
6549 operands[1] = adjust_address (operands[1], BLKmode, 0);
6550 })
6551
6552 (define_peephole2
6553 [(parallel
6554 [(set (match_operand:BLK 0 "memory_operand" "")
6555 (xor:BLK (match_dup 0)
6556 (match_operand:BLK 1 "memory_operand" "")))
6557 (use (match_operand 2 "const_int_operand" ""))
6558 (clobber (reg:CC CC_REGNUM))])
6559 (parallel
6560 [(set (match_operand:BLK 3 "memory_operand" "")
6561 (xor:BLK (match_dup 3)
6562 (match_operand:BLK 4 "memory_operand" "")))
6563 (use (match_operand 5 "const_int_operand" ""))
6564 (clobber (reg:CC CC_REGNUM))])]
6565 "s390_offset_p (operands[0], operands[3], operands[2])
6566 && s390_offset_p (operands[1], operands[4], operands[2])
6567 && !s390_overlap_p (operands[0], operands[1],
6568 INTVAL (operands[2]) + INTVAL (operands[5]))
6569 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6570 [(parallel
6571 [(set (match_dup 6) (xor:BLK (match_dup 6) (match_dup 7)))
6572 (use (match_dup 8))
6573 (clobber (reg:CC CC_REGNUM))])]
6574 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6575 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6576 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6577
6578 ;
6579 ; Block xor (XC) patterns with src == dest.
6580 ;
6581
6582 (define_insn "*xc_zero"
6583 [(set (match_operand:BLK 0 "memory_operand" "=Q")
6584 (const_int 0))
6585 (use (match_operand 1 "const_int_operand" "n"))
6586 (clobber (reg:CC CC_REGNUM))]
6587 "INTVAL (operands[1]) >= 1 && INTVAL (operands[1]) <= 256"
6588 "xc\t%O0(%1,%R0),%S0"
6589 [(set_attr "op_type" "SS")])
6590
6591 (define_peephole2
6592 [(parallel
6593 [(set (match_operand:BLK 0 "memory_operand" "")
6594 (const_int 0))
6595 (use (match_operand 1 "const_int_operand" ""))
6596 (clobber (reg:CC CC_REGNUM))])
6597 (parallel
6598 [(set (match_operand:BLK 2 "memory_operand" "")
6599 (const_int 0))
6600 (use (match_operand 3 "const_int_operand" ""))
6601 (clobber (reg:CC CC_REGNUM))])]
6602 "s390_offset_p (operands[0], operands[2], operands[1])
6603 && INTVAL (operands[1]) + INTVAL (operands[3]) <= 256"
6604 [(parallel
6605 [(set (match_dup 4) (const_int 0))
6606 (use (match_dup 5))
6607 (clobber (reg:CC CC_REGNUM))])]
6608 "operands[4] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6609 operands[5] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[3]));")
6610
6611
6612 ;;
6613 ;;- Negate instructions.
6614 ;;
6615
6616 ;
6617 ; neg(di|si)2 instruction pattern(s).
6618 ;
6619
6620 (define_expand "neg<mode>2"
6621 [(parallel
6622 [(set (match_operand:DSI 0 "register_operand" "=d")
6623 (neg:DSI (match_operand:DSI 1 "register_operand" "d")))
6624 (clobber (reg:CC CC_REGNUM))])]
6625 ""
6626 "")
6627
6628 (define_insn "*negdi2_sign_cc"
6629 [(set (reg CC_REGNUM)
6630 (compare (neg:DI (ashiftrt:DI (ashift:DI (subreg:DI
6631 (match_operand:SI 1 "register_operand" "d") 0)
6632 (const_int 32)) (const_int 32)))
6633 (const_int 0)))
6634 (set (match_operand:DI 0 "register_operand" "=d")
6635 (neg:DI (sign_extend:DI (match_dup 1))))]
6636 "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6637 "lcgfr\t%0,%1"
6638 [(set_attr "op_type" "RRE")
6639 (set_attr "z10prop" "z10_c")])
6640
6641 (define_insn "*negdi2_sign"
6642 [(set (match_operand:DI 0 "register_operand" "=d")
6643 (neg:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
6644 (clobber (reg:CC CC_REGNUM))]
6645 "TARGET_64BIT"
6646 "lcgfr\t%0,%1"
6647 [(set_attr "op_type" "RRE")
6648 (set_attr "z10prop" "z10_c")])
6649
6650 ; lcr, lcgr
6651 (define_insn "*neg<mode>2_cc"
6652 [(set (reg CC_REGNUM)
6653 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
6654 (const_int 0)))
6655 (set (match_operand:GPR 0 "register_operand" "=d")
6656 (neg:GPR (match_dup 1)))]
6657 "s390_match_ccmode (insn, CCAmode)"
6658 "lc<g>r\t%0,%1"
6659 [(set_attr "op_type" "RR<E>")
6660 (set_attr "z10prop" "z10_super_c_E1")])
6661
6662 ; lcr, lcgr
6663 (define_insn "*neg<mode>2_cconly"
6664 [(set (reg CC_REGNUM)
6665 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
6666 (const_int 0)))
6667 (clobber (match_scratch:GPR 0 "=d"))]
6668 "s390_match_ccmode (insn, CCAmode)"
6669 "lc<g>r\t%0,%1"
6670 [(set_attr "op_type" "RR<E>")
6671 (set_attr "z10prop" "z10_super_c_E1")])
6672
6673 ; lcr, lcgr
6674 (define_insn "*neg<mode>2"
6675 [(set (match_operand:GPR 0 "register_operand" "=d")
6676 (neg:GPR (match_operand:GPR 1 "register_operand" "d")))
6677 (clobber (reg:CC CC_REGNUM))]
6678 ""
6679 "lc<g>r\t%0,%1"
6680 [(set_attr "op_type" "RR<E>")
6681 (set_attr "z10prop" "z10_super_c_E1")])
6682
6683 (define_insn_and_split "*negdi2_31"
6684 [(set (match_operand:DI 0 "register_operand" "=d")
6685 (neg:DI (match_operand:DI 1 "register_operand" "d")))
6686 (clobber (reg:CC CC_REGNUM))]
6687 "!TARGET_64BIT"
6688 "#"
6689 "&& reload_completed"
6690 [(parallel
6691 [(set (match_dup 2) (neg:SI (match_dup 3)))
6692 (clobber (reg:CC CC_REGNUM))])
6693 (parallel
6694 [(set (reg:CCAP CC_REGNUM)
6695 (compare:CCAP (neg:SI (match_dup 5)) (const_int 0)))
6696 (set (match_dup 4) (neg:SI (match_dup 5)))])
6697 (set (pc)
6698 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
6699 (pc)
6700 (label_ref (match_dup 6))))
6701 (parallel
6702 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
6703 (clobber (reg:CC CC_REGNUM))])
6704 (match_dup 6)]
6705 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
6706 operands[3] = operand_subword (operands[1], 0, 0, DImode);
6707 operands[4] = operand_subword (operands[0], 1, 0, DImode);
6708 operands[5] = operand_subword (operands[1], 1, 0, DImode);
6709 operands[6] = gen_label_rtx ();")
6710
6711 ;
6712 ; neg(df|sf)2 instruction pattern(s).
6713 ;
6714
6715 (define_expand "neg<mode>2"
6716 [(parallel
6717 [(set (match_operand:BFP 0 "register_operand" "=f")
6718 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
6719 (clobber (reg:CC CC_REGNUM))])]
6720 "TARGET_HARD_FLOAT"
6721 "")
6722
6723 ; lcxbr, lcdbr, lcebr
6724 (define_insn "*neg<mode>2_cc"
6725 [(set (reg CC_REGNUM)
6726 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
6727 (match_operand:BFP 2 "const0_operand" "")))
6728 (set (match_operand:BFP 0 "register_operand" "=f")
6729 (neg:BFP (match_dup 1)))]
6730 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6731 "lc<xde>br\t%0,%1"
6732 [(set_attr "op_type" "RRE")
6733 (set_attr "type" "fsimp<mode>")])
6734
6735 ; lcxbr, lcdbr, lcebr
6736 (define_insn "*neg<mode>2_cconly"
6737 [(set (reg CC_REGNUM)
6738 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
6739 (match_operand:BFP 2 "const0_operand" "")))
6740 (clobber (match_scratch:BFP 0 "=f"))]
6741 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6742 "lc<xde>br\t%0,%1"
6743 [(set_attr "op_type" "RRE")
6744 (set_attr "type" "fsimp<mode>")])
6745
6746 ; lcdfr
6747 (define_insn "*neg<mode>2_nocc"
6748 [(set (match_operand:FP 0 "register_operand" "=f")
6749 (neg:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
6750 "TARGET_DFP"
6751 "lcdfr\t%0,%1"
6752 [(set_attr "op_type" "RRE")
6753 (set_attr "type" "fsimp<mode>")])
6754
6755 ; lcxbr, lcdbr, lcebr
6756 (define_insn "*neg<mode>2"
6757 [(set (match_operand:BFP 0 "register_operand" "=f")
6758 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
6759 (clobber (reg:CC CC_REGNUM))]
6760 "TARGET_HARD_FLOAT"
6761 "lc<xde>br\t%0,%1"
6762 [(set_attr "op_type" "RRE")
6763 (set_attr "type" "fsimp<mode>")])
6764
6765
6766 ;;
6767 ;;- Absolute value instructions.
6768 ;;
6769
6770 ;
6771 ; abs(di|si)2 instruction pattern(s).
6772 ;
6773
6774 (define_insn "*absdi2_sign_cc"
6775 [(set (reg CC_REGNUM)
6776 (compare (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
6777 (match_operand:SI 1 "register_operand" "d") 0)
6778 (const_int 32)) (const_int 32)))
6779 (const_int 0)))
6780 (set (match_operand:DI 0 "register_operand" "=d")
6781 (abs:DI (sign_extend:DI (match_dup 1))))]
6782 "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6783 "lpgfr\t%0,%1"
6784 [(set_attr "op_type" "RRE")
6785 (set_attr "z10prop" "z10_c")])
6786
6787 (define_insn "*absdi2_sign"
6788 [(set (match_operand:DI 0 "register_operand" "=d")
6789 (abs:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
6790 (clobber (reg:CC CC_REGNUM))]
6791 "TARGET_64BIT"
6792 "lpgfr\t%0,%1"
6793 [(set_attr "op_type" "RRE")
6794 (set_attr "z10prop" "z10_c")])
6795
6796 ; lpr, lpgr
6797 (define_insn "*abs<mode>2_cc"
6798 [(set (reg CC_REGNUM)
6799 (compare (abs:GPR (match_operand:DI 1 "register_operand" "d"))
6800 (const_int 0)))
6801 (set (match_operand:GPR 0 "register_operand" "=d")
6802 (abs:GPR (match_dup 1)))]
6803 "s390_match_ccmode (insn, CCAmode)"
6804 "lp<g>r\t%0,%1"
6805 [(set_attr "op_type" "RR<E>")
6806 (set_attr "z10prop" "z10_c")])
6807
6808 ; lpr, lpgr
6809 (define_insn "*abs<mode>2_cconly"
6810 [(set (reg CC_REGNUM)
6811 (compare (abs:GPR (match_operand:GPR 1 "register_operand" "d"))
6812 (const_int 0)))
6813 (clobber (match_scratch:GPR 0 "=d"))]
6814 "s390_match_ccmode (insn, CCAmode)"
6815 "lp<g>r\t%0,%1"
6816 [(set_attr "op_type" "RR<E>")
6817 (set_attr "z10prop" "z10_c")])
6818
6819 ; lpr, lpgr
6820 (define_insn "abs<mode>2"
6821 [(set (match_operand:GPR 0 "register_operand" "=d")
6822 (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
6823 (clobber (reg:CC CC_REGNUM))]
6824 ""
6825 "lp<g>r\t%0,%1"
6826 [(set_attr "op_type" "RR<E>")
6827 (set_attr "z10prop" "z10_c")])
6828
6829 ;
6830 ; abs(df|sf)2 instruction pattern(s).
6831 ;
6832
6833 (define_expand "abs<mode>2"
6834 [(parallel
6835 [(set (match_operand:BFP 0 "register_operand" "=f")
6836 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6837 (clobber (reg:CC CC_REGNUM))])]
6838 "TARGET_HARD_FLOAT"
6839 "")
6840
6841 ; lpxbr, lpdbr, lpebr
6842 (define_insn "*abs<mode>2_cc"
6843 [(set (reg CC_REGNUM)
6844 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
6845 (match_operand:BFP 2 "const0_operand" "")))
6846 (set (match_operand:BFP 0 "register_operand" "=f")
6847 (abs:BFP (match_dup 1)))]
6848 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6849 "lp<xde>br\t%0,%1"
6850 [(set_attr "op_type" "RRE")
6851 (set_attr "type" "fsimp<mode>")])
6852
6853 ; lpxbr, lpdbr, lpebr
6854 (define_insn "*abs<mode>2_cconly"
6855 [(set (reg CC_REGNUM)
6856 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
6857 (match_operand:BFP 2 "const0_operand" "")))
6858 (clobber (match_scratch:BFP 0 "=f"))]
6859 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6860 "lp<xde>br\t%0,%1"
6861 [(set_attr "op_type" "RRE")
6862 (set_attr "type" "fsimp<mode>")])
6863
6864 ; lpdfr
6865 (define_insn "*abs<mode>2_nocc"
6866 [(set (match_operand:FP 0 "register_operand" "=f")
6867 (abs:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
6868 "TARGET_DFP"
6869 "lpdfr\t%0,%1"
6870 [(set_attr "op_type" "RRE")
6871 (set_attr "type" "fsimp<mode>")])
6872
6873 ; lpxbr, lpdbr, lpebr
6874 (define_insn "*abs<mode>2"
6875 [(set (match_operand:BFP 0 "register_operand" "=f")
6876 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6877 (clobber (reg:CC CC_REGNUM))]
6878 "TARGET_HARD_FLOAT"
6879 "lp<xde>br\t%0,%1"
6880 [(set_attr "op_type" "RRE")
6881 (set_attr "type" "fsimp<mode>")])
6882
6883
6884 ;;
6885 ;;- Negated absolute value instructions
6886 ;;
6887
6888 ;
6889 ; Integer
6890 ;
6891
6892 (define_insn "*negabsdi2_sign_cc"
6893 [(set (reg CC_REGNUM)
6894 (compare (neg:DI (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
6895 (match_operand:SI 1 "register_operand" "d") 0)
6896 (const_int 32)) (const_int 32))))
6897 (const_int 0)))
6898 (set (match_operand:DI 0 "register_operand" "=d")
6899 (neg:DI (abs:DI (sign_extend:DI (match_dup 1)))))]
6900 "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6901 "lngfr\t%0,%1"
6902 [(set_attr "op_type" "RRE")
6903 (set_attr "z10prop" "z10_c")])
6904
6905 (define_insn "*negabsdi2_sign"
6906 [(set (match_operand:DI 0 "register_operand" "=d")
6907 (neg:DI (abs:DI (sign_extend:DI
6908 (match_operand:SI 1 "register_operand" "d")))))
6909 (clobber (reg:CC CC_REGNUM))]
6910 "TARGET_64BIT"
6911 "lngfr\t%0,%1"
6912 [(set_attr "op_type" "RRE")
6913 (set_attr "z10prop" "z10_c")])
6914
6915 ; lnr, lngr
6916 (define_insn "*negabs<mode>2_cc"
6917 [(set (reg CC_REGNUM)
6918 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
6919 (const_int 0)))
6920 (set (match_operand:GPR 0 "register_operand" "=d")
6921 (neg:GPR (abs:GPR (match_dup 1))))]
6922 "s390_match_ccmode (insn, CCAmode)"
6923 "ln<g>r\t%0,%1"
6924 [(set_attr "op_type" "RR<E>")
6925 (set_attr "z10prop" "z10_c")])
6926
6927 ; lnr, lngr
6928 (define_insn "*negabs<mode>2_cconly"
6929 [(set (reg CC_REGNUM)
6930 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
6931 (const_int 0)))
6932 (clobber (match_scratch:GPR 0 "=d"))]
6933 "s390_match_ccmode (insn, CCAmode)"
6934 "ln<g>r\t%0,%1"
6935 [(set_attr "op_type" "RR<E>")
6936 (set_attr "z10prop" "z10_c")])
6937
6938 ; lnr, lngr
6939 (define_insn "*negabs<mode>2"
6940 [(set (match_operand:GPR 0 "register_operand" "=d")
6941 (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d"))))
6942 (clobber (reg:CC CC_REGNUM))]
6943 ""
6944 "ln<g>r\t%0,%1"
6945 [(set_attr "op_type" "RR<E>")
6946 (set_attr "z10prop" "z10_c")])
6947
6948 ;
6949 ; Floating point
6950 ;
6951
6952 ; lnxbr, lndbr, lnebr
6953 (define_insn "*negabs<mode>2_cc"
6954 [(set (reg CC_REGNUM)
6955 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6956 (match_operand:BFP 2 "const0_operand" "")))
6957 (set (match_operand:BFP 0 "register_operand" "=f")
6958 (neg:BFP (abs:BFP (match_dup 1))))]
6959 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6960 "ln<xde>br\t%0,%1"
6961 [(set_attr "op_type" "RRE")
6962 (set_attr "type" "fsimp<mode>")])
6963
6964 ; lnxbr, lndbr, lnebr
6965 (define_insn "*negabs<mode>2_cconly"
6966 [(set (reg CC_REGNUM)
6967 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6968 (match_operand:BFP 2 "const0_operand" "")))
6969 (clobber (match_scratch:BFP 0 "=f"))]
6970 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6971 "ln<xde>br\t%0,%1"
6972 [(set_attr "op_type" "RRE")
6973 (set_attr "type" "fsimp<mode>")])
6974
6975 ; lndfr
6976 (define_insn "*negabs<mode>2_nocc"
6977 [(set (match_operand:FP 0 "register_operand" "=f")
6978 (neg:FP (abs:FP (match_operand:BFP 1 "register_operand" "<fT0>"))))]
6979 "TARGET_DFP"
6980 "lndfr\t%0,%1"
6981 [(set_attr "op_type" "RRE")
6982 (set_attr "type" "fsimp<mode>")])
6983
6984 ; lnxbr, lndbr, lnebr
6985 (define_insn "*negabs<mode>2"
6986 [(set (match_operand:BFP 0 "register_operand" "=f")
6987 (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f"))))
6988 (clobber (reg:CC CC_REGNUM))]
6989 "TARGET_HARD_FLOAT"
6990 "ln<xde>br\t%0,%1"
6991 [(set_attr "op_type" "RRE")
6992 (set_attr "type" "fsimp<mode>")])
6993
6994 ;;
6995 ;;- Copy sign instructions
6996 ;;
6997
6998 ; cpsdr
6999 (define_insn "copysign<mode>3"
7000 [(set (match_operand:FP 0 "register_operand" "=f")
7001 (unspec:FP [(match_operand:FP 1 "register_operand" "<fT0>")
7002 (match_operand:FP 2 "register_operand" "f")]
7003 UNSPEC_COPYSIGN))]
7004 "TARGET_DFP"
7005 "cpsdr\t%0,%2,%1"
7006 [(set_attr "op_type" "RRF")
7007 (set_attr "type" "fsimp<mode>")])
7008
7009 ;;
7010 ;;- Square root instructions.
7011 ;;
7012
7013 ;
7014 ; sqrt(df|sf)2 instruction pattern(s).
7015 ;
7016
7017 ; sqxbr, sqdbr, sqebr, sqdb, sqeb
7018 (define_insn "sqrt<mode>2"
7019 [(set (match_operand:BFP 0 "register_operand" "=f,f")
7020 (sqrt:BFP (match_operand:BFP 1 "general_operand" "f,<Rf>")))]
7021 "TARGET_HARD_FLOAT"
7022 "@
7023 sq<xde>br\t%0,%1
7024 sq<xde>b\t%0,%1"
7025 [(set_attr "op_type" "RRE,RXE")
7026 (set_attr "type" "fsqrt<mode>")])
7027
7028
7029 ;;
7030 ;;- One complement instructions.
7031 ;;
7032
7033 ;
7034 ; one_cmpl(di|si|hi|qi)2 instruction pattern(s).
7035 ;
7036
7037 (define_expand "one_cmpl<mode>2"
7038 [(parallel
7039 [(set (match_operand:INT 0 "register_operand" "")
7040 (xor:INT (match_operand:INT 1 "register_operand" "")
7041 (const_int -1)))
7042 (clobber (reg:CC CC_REGNUM))])]
7043 ""
7044 "")
7045
7046
7047 ;;
7048 ;; Find leftmost bit instructions.
7049 ;;
7050
7051 (define_expand "clzdi2"
7052 [(set (match_operand:DI 0 "register_operand" "=d")
7053 (clz:DI (match_operand:DI 1 "register_operand" "d")))]
7054 "TARGET_EXTIMM && TARGET_64BIT"
7055 {
7056 rtx insn, clz_equal;
7057 rtx wide_reg = gen_reg_rtx (TImode);
7058 rtx msb = gen_rtx_CONST_INT (DImode, (unsigned HOST_WIDE_INT) 1 << 63);
7059
7060 clz_equal = gen_rtx_CLZ (DImode, operands[1]);
7061
7062 emit_insn (gen_clztidi2 (wide_reg, operands[1], msb));
7063
7064 insn = emit_move_insn (operands[0], gen_highpart (DImode, wide_reg));
7065 set_unique_reg_note (insn, REG_EQUAL, clz_equal);
7066
7067 DONE;
7068 })
7069
7070 (define_insn "clztidi2"
7071 [(set (match_operand:TI 0 "register_operand" "=d")
7072 (ior:TI
7073 (ashift:TI
7074 (zero_extend:TI
7075 (xor:DI (match_operand:DI 1 "register_operand" "d")
7076 (lshiftrt (match_operand:DI 2 "const_int_operand" "")
7077 (subreg:SI (clz:DI (match_dup 1)) 4))))
7078
7079 (const_int 64))
7080 (zero_extend:TI (clz:DI (match_dup 1)))))
7081 (clobber (reg:CC CC_REGNUM))]
7082 "(unsigned HOST_WIDE_INT) INTVAL (operands[2])
7083 == (unsigned HOST_WIDE_INT) 1 << 63
7084 && TARGET_EXTIMM && TARGET_64BIT"
7085 "flogr\t%0,%1"
7086 [(set_attr "op_type" "RRE")])
7087
7088
7089 ;;
7090 ;;- Rotate instructions.
7091 ;;
7092
7093 ;
7094 ; rotl(di|si)3 instruction pattern(s).
7095 ;
7096
7097 ; rll, rllg
7098 (define_insn "rotl<mode>3"
7099 [(set (match_operand:GPR 0 "register_operand" "=d")
7100 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
7101 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
7102 "TARGET_CPU_ZARCH"
7103 "rll<g>\t%0,%1,%Y2"
7104 [(set_attr "op_type" "RSE")
7105 (set_attr "atype" "reg")
7106 (set_attr "z10prop" "z10_super_E1")])
7107
7108 ; rll, rllg
7109 (define_insn "*rotl<mode>3_and"
7110 [(set (match_operand:GPR 0 "register_operand" "=d")
7111 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
7112 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7113 (match_operand:SI 3 "const_int_operand" "n"))))]
7114 "TARGET_CPU_ZARCH && (INTVAL (operands[3]) & 63) == 63"
7115 "rll<g>\t%0,%1,%Y2"
7116 [(set_attr "op_type" "RSE")
7117 (set_attr "atype" "reg")
7118 (set_attr "z10prop" "z10_super_E1")])
7119
7120
7121 ;;
7122 ;;- Shift instructions.
7123 ;;
7124
7125 ;
7126 ; (ashl|lshr)(di|si)3 instruction pattern(s).
7127 ;
7128
7129 (define_expand "<shift><mode>3"
7130 [(set (match_operand:DSI 0 "register_operand" "")
7131 (SHIFT:DSI (match_operand:DSI 1 "register_operand" "")
7132 (match_operand:SI 2 "shift_count_or_setmem_operand" "")))]
7133 ""
7134 "")
7135
7136 ; sldl, srdl
7137 (define_insn "*<shift>di3_31"
7138 [(set (match_operand:DI 0 "register_operand" "=d")
7139 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
7140 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
7141 "!TARGET_64BIT"
7142 "s<lr>dl\t%0,%Y2"
7143 [(set_attr "op_type" "RS")
7144 (set_attr "atype" "reg")])
7145
7146 ; sll, srl, sllg, srlg
7147 (define_insn "*<shift><mode>3"
7148 [(set (match_operand:GPR 0 "register_operand" "=d")
7149 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7150 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
7151 ""
7152 "s<lr>l<g>\t%0,<1>%Y2"
7153 [(set_attr "op_type" "RS<E>")
7154 (set_attr "atype" "reg")
7155 (set_attr "z10prop" "z10_super_E1")])
7156
7157 ; sldl, srdl
7158 (define_insn "*<shift>di3_31_and"
7159 [(set (match_operand:DI 0 "register_operand" "=d")
7160 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
7161 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7162 (match_operand:SI 3 "const_int_operand" "n"))))]
7163 "!TARGET_64BIT && (INTVAL (operands[3]) & 63) == 63"
7164 "s<lr>dl\t%0,%Y2"
7165 [(set_attr "op_type" "RS")
7166 (set_attr "atype" "reg")])
7167
7168 ; sll, srl, sllg, srlg
7169 (define_insn "*<shift><mode>3_and"
7170 [(set (match_operand:GPR 0 "register_operand" "=d")
7171 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7172 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7173 (match_operand:SI 3 "const_int_operand" "n"))))]
7174 "(INTVAL (operands[3]) & 63) == 63"
7175 "s<lr>l<g>\t%0,<1>%Y2"
7176 [(set_attr "op_type" "RS<E>")
7177 (set_attr "atype" "reg")
7178 (set_attr "z10prop" "z10_super_E1")])
7179
7180 ;
7181 ; ashr(di|si)3 instruction pattern(s).
7182 ;
7183
7184 (define_expand "ashr<mode>3"
7185 [(parallel
7186 [(set (match_operand:DSI 0 "register_operand" "")
7187 (ashiftrt:DSI (match_operand:DSI 1 "register_operand" "")
7188 (match_operand:SI 2 "shift_count_or_setmem_operand" "")))
7189 (clobber (reg:CC CC_REGNUM))])]
7190 ""
7191 "")
7192
7193 (define_insn "*ashrdi3_cc_31"
7194 [(set (reg CC_REGNUM)
7195 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7196 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7197 (const_int 0)))
7198 (set (match_operand:DI 0 "register_operand" "=d")
7199 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7200 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
7201 "srda\t%0,%Y2"
7202 [(set_attr "op_type" "RS")
7203 (set_attr "atype" "reg")])
7204
7205 (define_insn "*ashrdi3_cconly_31"
7206 [(set (reg CC_REGNUM)
7207 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7208 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7209 (const_int 0)))
7210 (clobber (match_scratch:DI 0 "=d"))]
7211 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
7212 "srda\t%0,%Y2"
7213 [(set_attr "op_type" "RS")
7214 (set_attr "atype" "reg")])
7215
7216 (define_insn "*ashrdi3_31"
7217 [(set (match_operand:DI 0 "register_operand" "=d")
7218 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7219 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))
7220 (clobber (reg:CC CC_REGNUM))]
7221 "!TARGET_64BIT"
7222 "srda\t%0,%Y2"
7223 [(set_attr "op_type" "RS")
7224 (set_attr "atype" "reg")])
7225
7226 ; sra, srag
7227 (define_insn "*ashr<mode>3_cc"
7228 [(set (reg CC_REGNUM)
7229 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7230 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7231 (const_int 0)))
7232 (set (match_operand:GPR 0 "register_operand" "=d")
7233 (ashiftrt:GPR (match_dup 1) (match_dup 2)))]
7234 "s390_match_ccmode(insn, CCSmode)"
7235 "sra<g>\t%0,<1>%Y2"
7236 [(set_attr "op_type" "RS<E>")
7237 (set_attr "atype" "reg")
7238 (set_attr "z10prop" "z10_super_E1")])
7239
7240 ; sra, srag
7241 (define_insn "*ashr<mode>3_cconly"
7242 [(set (reg CC_REGNUM)
7243 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7244 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7245 (const_int 0)))
7246 (clobber (match_scratch:GPR 0 "=d"))]
7247 "s390_match_ccmode(insn, CCSmode)"
7248 "sra<g>\t%0,<1>%Y2"
7249 [(set_attr "op_type" "RS<E>")
7250 (set_attr "atype" "reg")
7251 (set_attr "z10prop" "z10_super_E1")])
7252
7253 ; sra, srag
7254 (define_insn "*ashr<mode>3"
7255 [(set (match_operand:GPR 0 "register_operand" "=d")
7256 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7257 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))
7258 (clobber (reg:CC CC_REGNUM))]
7259 ""
7260 "sra<g>\t%0,<1>%Y2"
7261 [(set_attr "op_type" "RS<E>")
7262 (set_attr "atype" "reg")
7263 (set_attr "z10prop" "z10_super_E1")])
7264
7265
7266 ; shift pattern with implicit ANDs
7267
7268 (define_insn "*ashrdi3_cc_31_and"
7269 [(set (reg CC_REGNUM)
7270 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7271 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7272 (match_operand:SI 3 "const_int_operand" "n")))
7273 (const_int 0)))
7274 (set (match_operand:DI 0 "register_operand" "=d")
7275 (ashiftrt:DI (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
7276 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)
7277 && (INTVAL (operands[3]) & 63) == 63"
7278 "srda\t%0,%Y2"
7279 [(set_attr "op_type" "RS")
7280 (set_attr "atype" "reg")])
7281
7282 (define_insn "*ashrdi3_cconly_31_and"
7283 [(set (reg CC_REGNUM)
7284 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7285 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7286 (match_operand:SI 3 "const_int_operand" "n")))
7287 (const_int 0)))
7288 (clobber (match_scratch:DI 0 "=d"))]
7289 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)
7290 && (INTVAL (operands[3]) & 63) == 63"
7291 "srda\t%0,%Y2"
7292 [(set_attr "op_type" "RS")
7293 (set_attr "atype" "reg")])
7294
7295 (define_insn "*ashrdi3_31_and"
7296 [(set (match_operand:DI 0 "register_operand" "=d")
7297 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7298 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7299 (match_operand:SI 3 "const_int_operand" "n"))))
7300 (clobber (reg:CC CC_REGNUM))]
7301 "!TARGET_64BIT && (INTVAL (operands[3]) & 63) == 63"
7302 "srda\t%0,%Y2"
7303 [(set_attr "op_type" "RS")
7304 (set_attr "atype" "reg")])
7305
7306 ; sra, srag
7307 (define_insn "*ashr<mode>3_cc_and"
7308 [(set (reg CC_REGNUM)
7309 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7310 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7311 (match_operand:SI 3 "const_int_operand" "n")))
7312 (const_int 0)))
7313 (set (match_operand:GPR 0 "register_operand" "=d")
7314 (ashiftrt:GPR (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
7315 "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
7316 "sra<g>\t%0,<1>%Y2"
7317 [(set_attr "op_type" "RS<E>")
7318 (set_attr "atype" "reg")
7319 (set_attr "z10prop" "z10_super_E1")])
7320
7321 ; sra, srag
7322 (define_insn "*ashr<mode>3_cconly_and"
7323 [(set (reg CC_REGNUM)
7324 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7325 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7326 (match_operand:SI 3 "const_int_operand" "n")))
7327 (const_int 0)))
7328 (clobber (match_scratch:GPR 0 "=d"))]
7329 "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
7330 "sra<g>\t%0,<1>%Y2"
7331 [(set_attr "op_type" "RS<E>")
7332 (set_attr "atype" "reg")
7333 (set_attr "z10prop" "z10_super_E1")])
7334
7335 ; sra, srag
7336 (define_insn "*ashr<mode>3_and"
7337 [(set (match_operand:GPR 0 "register_operand" "=d")
7338 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7339 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7340 (match_operand:SI 3 "const_int_operand" "n"))))
7341 (clobber (reg:CC CC_REGNUM))]
7342 "(INTVAL (operands[3]) & 63) == 63"
7343 "sra<g>\t%0,<1>%Y2"
7344 [(set_attr "op_type" "RS<E>")
7345 (set_attr "atype" "reg")
7346 (set_attr "z10prop" "z10_super_E1")])
7347
7348
7349 ;;
7350 ;; Branch instruction patterns.
7351 ;;
7352
7353 (define_expand "b<code>"
7354 [(set (pc)
7355 (if_then_else (COMPARE (match_operand 0 "" "")
7356 (const_int 0))
7357 (match_dup 0)
7358 (pc)))]
7359 ""
7360 "s390_emit_jump (operands[0],
7361 s390_emit_compare (<CODE>, s390_compare_op0, s390_compare_op1)); DONE;")
7362
7363
7364 ;;
7365 ;;- Conditional jump instructions.
7366 ;;
7367
7368 (define_insn "*cjump_64"
7369 [(set (pc)
7370 (if_then_else
7371 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7372 (label_ref (match_operand 0 "" ""))
7373 (pc)))]
7374 "TARGET_CPU_ZARCH"
7375 {
7376 if (get_attr_length (insn) == 4)
7377 return "j%C1\t%l0";
7378 else
7379 return "jg%C1\t%l0";
7380 }
7381 [(set_attr "op_type" "RI")
7382 (set_attr "type" "branch")
7383 (set (attr "length")
7384 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7385 (const_int 4) (const_int 6)))])
7386
7387 (define_insn "*cjump_31"
7388 [(set (pc)
7389 (if_then_else
7390 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7391 (label_ref (match_operand 0 "" ""))
7392 (pc)))]
7393 "!TARGET_CPU_ZARCH"
7394 {
7395 gcc_assert (get_attr_length (insn) == 4);
7396 return "j%C1\t%l0";
7397 }
7398 [(set_attr "op_type" "RI")
7399 (set_attr "type" "branch")
7400 (set (attr "length")
7401 (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7402 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7403 (const_int 4) (const_int 6))
7404 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7405 (const_int 4) (const_int 8))))])
7406
7407 (define_insn "*cjump_long"
7408 [(set (pc)
7409 (if_then_else
7410 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7411 (match_operand 0 "address_operand" "U")
7412 (pc)))]
7413 ""
7414 {
7415 if (get_attr_op_type (insn) == OP_TYPE_RR)
7416 return "b%C1r\t%0";
7417 else
7418 return "b%C1\t%a0";
7419 }
7420 [(set (attr "op_type")
7421 (if_then_else (match_operand 0 "register_operand" "")
7422 (const_string "RR") (const_string "RX")))
7423 (set_attr "type" "branch")
7424 (set_attr "atype" "agen")])
7425
7426
7427 ;;
7428 ;;- Negated conditional jump instructions.
7429 ;;
7430
7431 (define_insn "*icjump_64"
7432 [(set (pc)
7433 (if_then_else
7434 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7435 (pc)
7436 (label_ref (match_operand 0 "" ""))))]
7437 "TARGET_CPU_ZARCH"
7438 {
7439 if (get_attr_length (insn) == 4)
7440 return "j%D1\t%l0";
7441 else
7442 return "jg%D1\t%l0";
7443 }
7444 [(set_attr "op_type" "RI")
7445 (set_attr "type" "branch")
7446 (set (attr "length")
7447 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7448 (const_int 4) (const_int 6)))])
7449
7450 (define_insn "*icjump_31"
7451 [(set (pc)
7452 (if_then_else
7453 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7454 (pc)
7455 (label_ref (match_operand 0 "" ""))))]
7456 "!TARGET_CPU_ZARCH"
7457 {
7458 gcc_assert (get_attr_length (insn) == 4);
7459 return "j%D1\t%l0";
7460 }
7461 [(set_attr "op_type" "RI")
7462 (set_attr "type" "branch")
7463 (set (attr "length")
7464 (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7465 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7466 (const_int 4) (const_int 6))
7467 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7468 (const_int 4) (const_int 8))))])
7469
7470 (define_insn "*icjump_long"
7471 [(set (pc)
7472 (if_then_else
7473 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7474 (pc)
7475 (match_operand 0 "address_operand" "U")))]
7476 ""
7477 {
7478 if (get_attr_op_type (insn) == OP_TYPE_RR)
7479 return "b%D1r\t%0";
7480 else
7481 return "b%D1\t%a0";
7482 }
7483 [(set (attr "op_type")
7484 (if_then_else (match_operand 0 "register_operand" "")
7485 (const_string "RR") (const_string "RX")))
7486 (set_attr "type" "branch")
7487 (set_attr "atype" "agen")])
7488
7489 ;;
7490 ;;- Trap instructions.
7491 ;;
7492
7493 (define_insn "trap"
7494 [(trap_if (const_int 1) (const_int 0))]
7495 ""
7496 "j\t.+2"
7497 [(set_attr "op_type" "RI")
7498 (set_attr "type" "branch")])
7499
7500 (define_expand "conditional_trap"
7501 [(trap_if (match_operand 0 "comparison_operator" "")
7502 (match_operand 1 "general_operand" ""))]
7503 ""
7504 {
7505 if (operands[1] != const0_rtx) FAIL;
7506 operands[0] = s390_emit_compare (GET_CODE (operands[0]),
7507 s390_compare_op0, s390_compare_op1);
7508 })
7509
7510 (define_insn "*trap"
7511 [(trap_if (match_operator 0 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7512 (const_int 0))]
7513 ""
7514 "j%C0\t.+2";
7515 [(set_attr "op_type" "RI")
7516 (set_attr "type" "branch")])
7517
7518 ; crt, cgrt, cit, cgit
7519 (define_insn "*cmp_and_trap_signed_int<mode>"
7520 [(trap_if (match_operator 0 "s390_signed_integer_comparison"
7521 [(match_operand:GPR 1 "register_operand" "d,d")
7522 (match_operand:GPR 2 "nonmemory_operand" "d,K")])
7523 (const_int 0))]
7524 "TARGET_Z10"
7525 "@
7526 c<g>rt%C0\t%1,%2
7527 c<g>it%C0\t%1,%h2"
7528 [(set_attr "op_type" "RRF,RIE")
7529 (set_attr "type" "branch")
7530 (set_attr "z10prop" "z10_super_c,z10_super")])
7531
7532 ; clrt, clgrt, clfit, clgit
7533 (define_insn "*cmp_and_trap_unsigned_int<mode>"
7534 [(trap_if (match_operator 0 "s390_unsigned_integer_comparison"
7535 [(match_operand:GPR 1 "register_operand" "d,d")
7536 (match_operand:GPR 2 "nonmemory_operand" "d,D")])
7537 (const_int 0))]
7538 "TARGET_Z10"
7539 "@
7540 cl<g>rt%C0\t%1,%2
7541 cl<gf>it%C0\t%1,%x2"
7542 [(set_attr "op_type" "RRF,RIE")
7543 (set_attr "type" "branch")
7544 (set_attr "z10prop" "z10_super_c,z10_super")])
7545
7546 ;;
7547 ;;- Loop instructions.
7548 ;;
7549 ;; This is all complicated by the fact that since this is a jump insn
7550 ;; we must handle our own output reloads.
7551
7552 (define_expand "doloop_end"
7553 [(use (match_operand 0 "" "")) ; loop pseudo
7554 (use (match_operand 1 "" "")) ; iterations; zero if unknown
7555 (use (match_operand 2 "" "")) ; max iterations
7556 (use (match_operand 3 "" "")) ; loop level
7557 (use (match_operand 4 "" ""))] ; label
7558 ""
7559 {
7560 if (GET_MODE (operands[0]) == SImode && !TARGET_CPU_ZARCH)
7561 emit_jump_insn (gen_doloop_si31 (operands[4], operands[0], operands[0]));
7562 else if (GET_MODE (operands[0]) == SImode && TARGET_CPU_ZARCH)
7563 emit_jump_insn (gen_doloop_si64 (operands[4], operands[0], operands[0]));
7564 else if (GET_MODE (operands[0]) == DImode && TARGET_64BIT)
7565 emit_jump_insn (gen_doloop_di (operands[4], operands[0], operands[0]));
7566 else
7567 FAIL;
7568
7569 DONE;
7570 })
7571
7572 (define_insn_and_split "doloop_si64"
7573 [(set (pc)
7574 (if_then_else
7575 (ne (match_operand:SI 1 "register_operand" "d,d,d")
7576 (const_int 1))
7577 (label_ref (match_operand 0 "" ""))
7578 (pc)))
7579 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
7580 (plus:SI (match_dup 1) (const_int -1)))
7581 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
7582 (clobber (reg:CC CC_REGNUM))]
7583 "TARGET_CPU_ZARCH"
7584 {
7585 if (which_alternative != 0)
7586 return "#";
7587 else if (get_attr_length (insn) == 4)
7588 return "brct\t%1,%l0";
7589 else
7590 return "ahi\t%1,-1\;jgne\t%l0";
7591 }
7592 "&& reload_completed
7593 && (! REG_P (operands[2])
7594 || ! rtx_equal_p (operands[1], operands[2]))"
7595 [(set (match_dup 3) (match_dup 1))
7596 (parallel [(set (reg:CCAN CC_REGNUM)
7597 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
7598 (const_int 0)))
7599 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
7600 (set (match_dup 2) (match_dup 3))
7601 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
7602 (label_ref (match_dup 0))
7603 (pc)))]
7604 ""
7605 [(set_attr "op_type" "RI")
7606 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
7607 ; hurt us in the (rare) case of ahi.
7608 (set_attr "z10prop" "z10_super_E1")
7609 (set_attr "type" "branch")
7610 (set (attr "length")
7611 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7612 (const_int 4) (const_int 10)))])
7613
7614 (define_insn_and_split "doloop_si31"
7615 [(set (pc)
7616 (if_then_else
7617 (ne (match_operand:SI 1 "register_operand" "d,d,d")
7618 (const_int 1))
7619 (label_ref (match_operand 0 "" ""))
7620 (pc)))
7621 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
7622 (plus:SI (match_dup 1) (const_int -1)))
7623 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
7624 (clobber (reg:CC CC_REGNUM))]
7625 "!TARGET_CPU_ZARCH"
7626 {
7627 if (which_alternative != 0)
7628 return "#";
7629 else if (get_attr_length (insn) == 4)
7630 return "brct\t%1,%l0";
7631 else
7632 gcc_unreachable ();
7633 }
7634 "&& reload_completed
7635 && (! REG_P (operands[2])
7636 || ! rtx_equal_p (operands[1], operands[2]))"
7637 [(set (match_dup 3) (match_dup 1))
7638 (parallel [(set (reg:CCAN CC_REGNUM)
7639 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
7640 (const_int 0)))
7641 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
7642 (set (match_dup 2) (match_dup 3))
7643 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
7644 (label_ref (match_dup 0))
7645 (pc)))]
7646 ""
7647 [(set_attr "op_type" "RI")
7648 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
7649 ; hurt us in the (rare) case of ahi.
7650 (set_attr "z10prop" "z10_super_E1")
7651 (set_attr "type" "branch")
7652 (set (attr "length")
7653 (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7654 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7655 (const_int 4) (const_int 6))
7656 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7657 (const_int 4) (const_int 8))))])
7658
7659 (define_insn "*doloop_si_long"
7660 [(set (pc)
7661 (if_then_else
7662 (ne (match_operand:SI 1 "register_operand" "d")
7663 (const_int 1))
7664 (match_operand 0 "address_operand" "U")
7665 (pc)))
7666 (set (match_operand:SI 2 "register_operand" "=1")
7667 (plus:SI (match_dup 1) (const_int -1)))
7668 (clobber (match_scratch:SI 3 "=X"))
7669 (clobber (reg:CC CC_REGNUM))]
7670 "!TARGET_CPU_ZARCH"
7671 {
7672 if (get_attr_op_type (insn) == OP_TYPE_RR)
7673 return "bctr\t%1,%0";
7674 else
7675 return "bct\t%1,%a0";
7676 }
7677 [(set (attr "op_type")
7678 (if_then_else (match_operand 0 "register_operand" "")
7679 (const_string "RR") (const_string "RX")))
7680 (set_attr "type" "branch")
7681 (set_attr "atype" "agen")
7682 (set_attr "z10prop" "z10_cobra")])
7683
7684 (define_insn_and_split "doloop_di"
7685 [(set (pc)
7686 (if_then_else
7687 (ne (match_operand:DI 1 "register_operand" "d,d,d")
7688 (const_int 1))
7689 (label_ref (match_operand 0 "" ""))
7690 (pc)))
7691 (set (match_operand:DI 2 "nonimmediate_operand" "=1,?X,?X")
7692 (plus:DI (match_dup 1) (const_int -1)))
7693 (clobber (match_scratch:DI 3 "=X,&1,&?d"))
7694 (clobber (reg:CC CC_REGNUM))]
7695 "TARGET_64BIT"
7696 {
7697 if (which_alternative != 0)
7698 return "#";
7699 else if (get_attr_length (insn) == 4)
7700 return "brctg\t%1,%l0";
7701 else
7702 return "aghi\t%1,-1\;jgne\t%l0";
7703 }
7704 "&& reload_completed
7705 && (! REG_P (operands[2])
7706 || ! rtx_equal_p (operands[1], operands[2]))"
7707 [(set (match_dup 3) (match_dup 1))
7708 (parallel [(set (reg:CCAN CC_REGNUM)
7709 (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
7710 (const_int 0)))
7711 (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
7712 (set (match_dup 2) (match_dup 3))
7713 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
7714 (label_ref (match_dup 0))
7715 (pc)))]
7716 ""
7717 [(set_attr "op_type" "RI")
7718 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
7719 ; hurt us in the (rare) case of ahi.
7720 (set_attr "z10prop" "z10_super_E1")
7721 (set_attr "type" "branch")
7722 (set (attr "length")
7723 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7724 (const_int 4) (const_int 10)))])
7725
7726 ;;
7727 ;;- Unconditional jump instructions.
7728 ;;
7729
7730 ;
7731 ; jump instruction pattern(s).
7732 ;
7733
7734 (define_expand "jump"
7735 [(match_operand 0 "" "")]
7736 ""
7737 "s390_emit_jump (operands[0], NULL_RTX); DONE;")
7738
7739 (define_insn "*jump64"
7740 [(set (pc) (label_ref (match_operand 0 "" "")))]
7741 "TARGET_CPU_ZARCH"
7742 {
7743 if (get_attr_length (insn) == 4)
7744 return "j\t%l0";
7745 else
7746 return "jg\t%l0";
7747 }
7748 [(set_attr "op_type" "RI")
7749 (set_attr "type" "branch")
7750 (set (attr "length")
7751 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7752 (const_int 4) (const_int 6)))])
7753
7754 (define_insn "*jump31"
7755 [(set (pc) (label_ref (match_operand 0 "" "")))]
7756 "!TARGET_CPU_ZARCH"
7757 {
7758 gcc_assert (get_attr_length (insn) == 4);
7759 return "j\t%l0";
7760 }
7761 [(set_attr "op_type" "RI")
7762 (set_attr "type" "branch")
7763 (set (attr "length")
7764 (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7765 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7766 (const_int 4) (const_int 6))
7767 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7768 (const_int 4) (const_int 8))))])
7769
7770 ;
7771 ; indirect-jump instruction pattern(s).
7772 ;
7773
7774 (define_insn "indirect_jump"
7775 [(set (pc) (match_operand 0 "address_operand" "U"))]
7776 ""
7777 {
7778 if (get_attr_op_type (insn) == OP_TYPE_RR)
7779 return "br\t%0";
7780 else
7781 return "b\t%a0";
7782 }
7783 [(set (attr "op_type")
7784 (if_then_else (match_operand 0 "register_operand" "")
7785 (const_string "RR") (const_string "RX")))
7786 (set_attr "type" "branch")
7787 (set_attr "atype" "agen")])
7788
7789 ;
7790 ; casesi instruction pattern(s).
7791 ;
7792
7793 (define_insn "casesi_jump"
7794 [(set (pc) (match_operand 0 "address_operand" "U"))
7795 (use (label_ref (match_operand 1 "" "")))]
7796 ""
7797 {
7798 if (get_attr_op_type (insn) == OP_TYPE_RR)
7799 return "br\t%0";
7800 else
7801 return "b\t%a0";
7802 }
7803 [(set (attr "op_type")
7804 (if_then_else (match_operand 0 "register_operand" "")
7805 (const_string "RR") (const_string "RX")))
7806 (set_attr "type" "branch")
7807 (set_attr "atype" "agen")])
7808
7809 (define_expand "casesi"
7810 [(match_operand:SI 0 "general_operand" "")
7811 (match_operand:SI 1 "general_operand" "")
7812 (match_operand:SI 2 "general_operand" "")
7813 (label_ref (match_operand 3 "" ""))
7814 (label_ref (match_operand 4 "" ""))]
7815 ""
7816 {
7817 rtx index = gen_reg_rtx (SImode);
7818 rtx base = gen_reg_rtx (Pmode);
7819 rtx target = gen_reg_rtx (Pmode);
7820
7821 emit_move_insn (index, operands[0]);
7822 emit_insn (gen_subsi3 (index, index, operands[1]));
7823 emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
7824 operands[4]);
7825
7826 if (Pmode != SImode)
7827 index = convert_to_mode (Pmode, index, 1);
7828 if (GET_CODE (index) != REG)
7829 index = copy_to_mode_reg (Pmode, index);
7830
7831 if (TARGET_64BIT)
7832 emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
7833 else
7834 emit_insn (gen_ashlsi3 (index, index, const2_rtx));
7835
7836 emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
7837
7838 index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
7839 emit_move_insn (target, index);
7840
7841 if (flag_pic)
7842 target = gen_rtx_PLUS (Pmode, base, target);
7843 emit_jump_insn (gen_casesi_jump (target, operands[3]));
7844
7845 DONE;
7846 })
7847
7848
7849 ;;
7850 ;;- Jump to subroutine.
7851 ;;
7852 ;;
7853
7854 ;
7855 ; untyped call instruction pattern(s).
7856 ;
7857
7858 ;; Call subroutine returning any type.
7859 (define_expand "untyped_call"
7860 [(parallel [(call (match_operand 0 "" "")
7861 (const_int 0))
7862 (match_operand 1 "" "")
7863 (match_operand 2 "" "")])]
7864 ""
7865 {
7866 int i;
7867
7868 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
7869
7870 for (i = 0; i < XVECLEN (operands[2], 0); i++)
7871 {
7872 rtx set = XVECEXP (operands[2], 0, i);
7873 emit_move_insn (SET_DEST (set), SET_SRC (set));
7874 }
7875
7876 /* The optimizer does not know that the call sets the function value
7877 registers we stored in the result block. We avoid problems by
7878 claiming that all hard registers are used and clobbered at this
7879 point. */
7880 emit_insn (gen_blockage ());
7881
7882 DONE;
7883 })
7884
7885 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
7886 ;; all of memory. This blocks insns from being moved across this point.
7887
7888 (define_insn "blockage"
7889 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
7890 ""
7891 ""
7892 [(set_attr "type" "none")
7893 (set_attr "length" "0")])
7894
7895 ;
7896 ; sibcall patterns
7897 ;
7898
7899 (define_expand "sibcall"
7900 [(call (match_operand 0 "" "")
7901 (match_operand 1 "" ""))]
7902 ""
7903 {
7904 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
7905 DONE;
7906 })
7907
7908 (define_insn "*sibcall_br"
7909 [(call (mem:QI (reg SIBCALL_REGNUM))
7910 (match_operand 0 "const_int_operand" "n"))]
7911 "SIBLING_CALL_P (insn)
7912 && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
7913 "br\t%%r1"
7914 [(set_attr "op_type" "RR")
7915 (set_attr "type" "branch")
7916 (set_attr "atype" "agen")])
7917
7918 (define_insn "*sibcall_brc"
7919 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7920 (match_operand 1 "const_int_operand" "n"))]
7921 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
7922 "j\t%0"
7923 [(set_attr "op_type" "RI")
7924 (set_attr "type" "branch")])
7925
7926 (define_insn "*sibcall_brcl"
7927 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7928 (match_operand 1 "const_int_operand" "n"))]
7929 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
7930 "jg\t%0"
7931 [(set_attr "op_type" "RIL")
7932 (set_attr "type" "branch")])
7933
7934 ;
7935 ; sibcall_value patterns
7936 ;
7937
7938 (define_expand "sibcall_value"
7939 [(set (match_operand 0 "" "")
7940 (call (match_operand 1 "" "")
7941 (match_operand 2 "" "")))]
7942 ""
7943 {
7944 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
7945 DONE;
7946 })
7947
7948 (define_insn "*sibcall_value_br"
7949 [(set (match_operand 0 "" "")
7950 (call (mem:QI (reg SIBCALL_REGNUM))
7951 (match_operand 1 "const_int_operand" "n")))]
7952 "SIBLING_CALL_P (insn)
7953 && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
7954 "br\t%%r1"
7955 [(set_attr "op_type" "RR")
7956 (set_attr "type" "branch")
7957 (set_attr "atype" "agen")])
7958
7959 (define_insn "*sibcall_value_brc"
7960 [(set (match_operand 0 "" "")
7961 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7962 (match_operand 2 "const_int_operand" "n")))]
7963 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
7964 "j\t%1"
7965 [(set_attr "op_type" "RI")
7966 (set_attr "type" "branch")])
7967
7968 (define_insn "*sibcall_value_brcl"
7969 [(set (match_operand 0 "" "")
7970 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7971 (match_operand 2 "const_int_operand" "n")))]
7972 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
7973 "jg\t%1"
7974 [(set_attr "op_type" "RIL")
7975 (set_attr "type" "branch")])
7976
7977
7978 ;
7979 ; call instruction pattern(s).
7980 ;
7981
7982 (define_expand "call"
7983 [(call (match_operand 0 "" "")
7984 (match_operand 1 "" ""))
7985 (use (match_operand 2 "" ""))]
7986 ""
7987 {
7988 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
7989 gen_rtx_REG (Pmode, RETURN_REGNUM));
7990 DONE;
7991 })
7992
7993 (define_insn "*bras"
7994 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7995 (match_operand 1 "const_int_operand" "n"))
7996 (clobber (match_operand 2 "register_operand" "=r"))]
7997 "!SIBLING_CALL_P (insn)
7998 && TARGET_SMALL_EXEC
7999 && GET_MODE (operands[2]) == Pmode"
8000 "bras\t%2,%0"
8001 [(set_attr "op_type" "RI")
8002 (set_attr "type" "jsr")])
8003
8004 (define_insn "*brasl"
8005 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8006 (match_operand 1 "const_int_operand" "n"))
8007 (clobber (match_operand 2 "register_operand" "=r"))]
8008 "!SIBLING_CALL_P (insn)
8009 && TARGET_CPU_ZARCH
8010 && GET_MODE (operands[2]) == Pmode"
8011 "brasl\t%2,%0"
8012 [(set_attr "op_type" "RIL")
8013 (set_attr "type" "jsr")])
8014
8015 (define_insn "*basr"
8016 [(call (mem:QI (match_operand 0 "address_operand" "U"))
8017 (match_operand 1 "const_int_operand" "n"))
8018 (clobber (match_operand 2 "register_operand" "=r"))]
8019 "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
8020 {
8021 if (get_attr_op_type (insn) == OP_TYPE_RR)
8022 return "basr\t%2,%0";
8023 else
8024 return "bas\t%2,%a0";
8025 }
8026 [(set (attr "op_type")
8027 (if_then_else (match_operand 0 "register_operand" "")
8028 (const_string "RR") (const_string "RX")))
8029 (set_attr "type" "jsr")
8030 (set_attr "atype" "agen")])
8031
8032 ;
8033 ; call_value instruction pattern(s).
8034 ;
8035
8036 (define_expand "call_value"
8037 [(set (match_operand 0 "" "")
8038 (call (match_operand 1 "" "")
8039 (match_operand 2 "" "")))
8040 (use (match_operand 3 "" ""))]
8041 ""
8042 {
8043 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
8044 gen_rtx_REG (Pmode, RETURN_REGNUM));
8045 DONE;
8046 })
8047
8048 (define_insn "*bras_r"
8049 [(set (match_operand 0 "" "")
8050 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8051 (match_operand:SI 2 "const_int_operand" "n")))
8052 (clobber (match_operand 3 "register_operand" "=r"))]
8053 "!SIBLING_CALL_P (insn)
8054 && TARGET_SMALL_EXEC
8055 && GET_MODE (operands[3]) == Pmode"
8056 "bras\t%3,%1"
8057 [(set_attr "op_type" "RI")
8058 (set_attr "type" "jsr")])
8059
8060 (define_insn "*brasl_r"
8061 [(set (match_operand 0 "" "")
8062 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8063 (match_operand 2 "const_int_operand" "n")))
8064 (clobber (match_operand 3 "register_operand" "=r"))]
8065 "!SIBLING_CALL_P (insn)
8066 && TARGET_CPU_ZARCH
8067 && GET_MODE (operands[3]) == Pmode"
8068 "brasl\t%3,%1"
8069 [(set_attr "op_type" "RIL")
8070 (set_attr "type" "jsr")])
8071
8072 (define_insn "*basr_r"
8073 [(set (match_operand 0 "" "")
8074 (call (mem:QI (match_operand 1 "address_operand" "U"))
8075 (match_operand 2 "const_int_operand" "n")))
8076 (clobber (match_operand 3 "register_operand" "=r"))]
8077 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
8078 {
8079 if (get_attr_op_type (insn) == OP_TYPE_RR)
8080 return "basr\t%3,%1";
8081 else
8082 return "bas\t%3,%a1";
8083 }
8084 [(set (attr "op_type")
8085 (if_then_else (match_operand 1 "register_operand" "")
8086 (const_string "RR") (const_string "RX")))
8087 (set_attr "type" "jsr")
8088 (set_attr "atype" "agen")])
8089
8090 ;;
8091 ;;- Thread-local storage support.
8092 ;;
8093
8094 (define_expand "get_tp_64"
8095 [(set (match_operand:DI 0 "nonimmediate_operand" "") (reg:DI TP_REGNUM))]
8096 "TARGET_64BIT"
8097 "")
8098
8099 (define_expand "get_tp_31"
8100 [(set (match_operand:SI 0 "nonimmediate_operand" "") (reg:SI TP_REGNUM))]
8101 "!TARGET_64BIT"
8102 "")
8103
8104 (define_expand "set_tp_64"
8105 [(set (reg:DI TP_REGNUM) (match_operand:DI 0 "nonimmediate_operand" ""))
8106 (set (reg:DI TP_REGNUM) (unspec_volatile:DI [(reg:DI TP_REGNUM)] UNSPECV_SET_TP))]
8107 "TARGET_64BIT"
8108 "")
8109
8110 (define_expand "set_tp_31"
8111 [(set (reg:SI TP_REGNUM) (match_operand:SI 0 "nonimmediate_operand" ""))
8112 (set (reg:SI TP_REGNUM) (unspec_volatile:SI [(reg:SI TP_REGNUM)] UNSPECV_SET_TP))]
8113 "!TARGET_64BIT"
8114 "")
8115
8116 (define_insn "*set_tp"
8117 [(set (reg TP_REGNUM) (unspec_volatile [(reg TP_REGNUM)] UNSPECV_SET_TP))]
8118 ""
8119 ""
8120 [(set_attr "type" "none")
8121 (set_attr "length" "0")])
8122
8123 (define_insn "*tls_load_64"
8124 [(set (match_operand:DI 0 "register_operand" "=d")
8125 (unspec:DI [(match_operand:DI 1 "memory_operand" "RT")
8126 (match_operand:DI 2 "" "")]
8127 UNSPEC_TLS_LOAD))]
8128 "TARGET_64BIT"
8129 "lg\t%0,%1%J2"
8130 [(set_attr "op_type" "RXE")
8131 (set_attr "z10prop" "z10_fwd_A3")])
8132
8133 (define_insn "*tls_load_31"
8134 [(set (match_operand:SI 0 "register_operand" "=d,d")
8135 (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
8136 (match_operand:SI 2 "" "")]
8137 UNSPEC_TLS_LOAD))]
8138 "!TARGET_64BIT"
8139 "@
8140 l\t%0,%1%J2
8141 ly\t%0,%1%J2"
8142 [(set_attr "op_type" "RX,RXY")
8143 (set_attr "type" "load")
8144 (set_attr "z10prop" "z10_fwd_A3,z10_fwd_A3")])
8145
8146 (define_insn "*bras_tls"
8147 [(set (match_operand 0 "" "")
8148 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8149 (match_operand 2 "const_int_operand" "n")))
8150 (clobber (match_operand 3 "register_operand" "=r"))
8151 (use (match_operand 4 "" ""))]
8152 "!SIBLING_CALL_P (insn)
8153 && TARGET_SMALL_EXEC
8154 && GET_MODE (operands[3]) == Pmode"
8155 "bras\t%3,%1%J4"
8156 [(set_attr "op_type" "RI")
8157 (set_attr "type" "jsr")])
8158
8159 (define_insn "*brasl_tls"
8160 [(set (match_operand 0 "" "")
8161 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8162 (match_operand 2 "const_int_operand" "n")))
8163 (clobber (match_operand 3 "register_operand" "=r"))
8164 (use (match_operand 4 "" ""))]
8165 "!SIBLING_CALL_P (insn)
8166 && TARGET_CPU_ZARCH
8167 && GET_MODE (operands[3]) == Pmode"
8168 "brasl\t%3,%1%J4"
8169 [(set_attr "op_type" "RIL")
8170 (set_attr "type" "jsr")])
8171
8172 (define_insn "*basr_tls"
8173 [(set (match_operand 0 "" "")
8174 (call (mem:QI (match_operand 1 "address_operand" "U"))
8175 (match_operand 2 "const_int_operand" "n")))
8176 (clobber (match_operand 3 "register_operand" "=r"))
8177 (use (match_operand 4 "" ""))]
8178 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
8179 {
8180 if (get_attr_op_type (insn) == OP_TYPE_RR)
8181 return "basr\t%3,%1%J4";
8182 else
8183 return "bas\t%3,%a1%J4";
8184 }
8185 [(set (attr "op_type")
8186 (if_then_else (match_operand 1 "register_operand" "")
8187 (const_string "RR") (const_string "RX")))
8188 (set_attr "type" "jsr")
8189 (set_attr "atype" "agen")])
8190
8191 ;;
8192 ;;- Atomic operations
8193 ;;
8194
8195 ;
8196 ; memory barrier pattern.
8197 ;
8198
8199 (define_expand "memory_barrier"
8200 [(set (match_dup 0)
8201 (unspec:BLK [(match_dup 0)] UNSPEC_MB))]
8202 ""
8203 {
8204 operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
8205 MEM_VOLATILE_P (operands[0]) = 1;
8206 })
8207
8208 (define_insn "*memory_barrier"
8209 [(set (match_operand:BLK 0 "" "")
8210 (unspec:BLK [(match_dup 0)] UNSPEC_MB))]
8211 ""
8212 "bcr\t15,0"
8213 [(set_attr "op_type" "RR")])
8214
8215 ; Although bcr is superscalar on Z10, this variant will never become part of
8216 ; an execution group.
8217
8218 ;
8219 ; compare and swap patterns.
8220 ;
8221
8222 (define_expand "sync_compare_and_swap<mode>"
8223 [(parallel
8224 [(set (match_operand:TDSI 0 "register_operand" "")
8225 (match_operand:TDSI 1 "memory_operand" ""))
8226 (set (match_dup 1)
8227 (unspec_volatile:TDSI
8228 [(match_dup 1)
8229 (match_operand:TDSI 2 "register_operand" "")
8230 (match_operand:TDSI 3 "register_operand" "")]
8231 UNSPECV_CAS))
8232 (set (reg:CCZ1 CC_REGNUM)
8233 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
8234 "")
8235
8236 (define_expand "sync_compare_and_swap<mode>"
8237 [(parallel
8238 [(set (match_operand:HQI 0 "register_operand" "")
8239 (match_operand:HQI 1 "memory_operand" ""))
8240 (set (match_dup 1)
8241 (unspec_volatile:HQI
8242 [(match_dup 1)
8243 (match_operand:HQI 2 "general_operand" "")
8244 (match_operand:HQI 3 "general_operand" "")]
8245 UNSPECV_CAS))
8246 (set (reg:CCZ1 CC_REGNUM)
8247 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
8248 ""
8249 "s390_expand_cs_hqi (<MODE>mode, operands[0], operands[1],
8250 operands[2], operands[3]); DONE;")
8251
8252 (define_expand "sync_compare_and_swap_cc<mode>"
8253 [(parallel
8254 [(set (match_operand:TDSI 0 "register_operand" "")
8255 (match_operand:TDSI 1 "memory_operand" ""))
8256 (set (match_dup 1)
8257 (unspec_volatile:TDSI
8258 [(match_dup 1)
8259 (match_operand:TDSI 2 "register_operand" "")
8260 (match_operand:TDSI 3 "register_operand" "")]
8261 UNSPECV_CAS))
8262 (set (match_dup 4)
8263 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
8264 ""
8265 {
8266 /* Emulate compare. */
8267 operands[4] = gen_rtx_REG (CCZ1mode, CC_REGNUM);
8268 s390_compare_op0 = operands[1];
8269 s390_compare_op1 = operands[2];
8270 s390_compare_emitted = operands[4];
8271 })
8272
8273 ; cds, cdsg
8274 (define_insn "*sync_compare_and_swap<mode>"
8275 [(set (match_operand:DP 0 "register_operand" "=r")
8276 (match_operand:DP 1 "memory_operand" "+Q"))
8277 (set (match_dup 1)
8278 (unspec_volatile:DP
8279 [(match_dup 1)
8280 (match_operand:DP 2 "register_operand" "0")
8281 (match_operand:DP 3 "register_operand" "r")]
8282 UNSPECV_CAS))
8283 (set (reg:CCZ1 CC_REGNUM)
8284 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
8285 ""
8286 "cds<tg>\t%0,%3,%S1"
8287 [(set_attr "op_type" "RS<TE>")
8288 (set_attr "type" "sem")])
8289
8290 ; cs, csg
8291 (define_insn "*sync_compare_and_swap<mode>"
8292 [(set (match_operand:GPR 0 "register_operand" "=r")
8293 (match_operand:GPR 1 "memory_operand" "+Q"))
8294 (set (match_dup 1)
8295 (unspec_volatile:GPR
8296 [(match_dup 1)
8297 (match_operand:GPR 2 "register_operand" "0")
8298 (match_operand:GPR 3 "register_operand" "r")]
8299 UNSPECV_CAS))
8300 (set (reg:CCZ1 CC_REGNUM)
8301 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
8302 ""
8303 "cs<g>\t%0,%3,%S1"
8304 [(set_attr "op_type" "RS<E>")
8305 (set_attr "type" "sem")])
8306
8307
8308 ;
8309 ; Other atomic instruction patterns.
8310 ;
8311
8312 (define_expand "sync_lock_test_and_set<mode>"
8313 [(match_operand:HQI 0 "register_operand")
8314 (match_operand:HQI 1 "memory_operand")
8315 (match_operand:HQI 2 "general_operand")]
8316 ""
8317 "s390_expand_atomic (<MODE>mode, SET, operands[0], operands[1],
8318 operands[2], false); DONE;")
8319
8320 (define_expand "sync_<atomic><mode>"
8321 [(set (match_operand:HQI 0 "memory_operand")
8322 (ATOMIC:HQI (match_dup 0)
8323 (match_operand:HQI 1 "general_operand")))]
8324 ""
8325 "s390_expand_atomic (<MODE>mode, <CODE>, NULL_RTX, operands[0],
8326 operands[1], false); DONE;")
8327
8328 (define_expand "sync_old_<atomic><mode>"
8329 [(set (match_operand:HQI 0 "register_operand")
8330 (match_operand:HQI 1 "memory_operand"))
8331 (set (match_dup 1)
8332 (ATOMIC:HQI (match_dup 1)
8333 (match_operand:HQI 2 "general_operand")))]
8334 ""
8335 "s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
8336 operands[2], false); DONE;")
8337
8338 (define_expand "sync_new_<atomic><mode>"
8339 [(set (match_operand:HQI 0 "register_operand")
8340 (ATOMIC:HQI (match_operand:HQI 1 "memory_operand")
8341 (match_operand:HQI 2 "general_operand")))
8342 (set (match_dup 1) (ATOMIC:HQI (match_dup 1) (match_dup 2)))]
8343 ""
8344 "s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
8345 operands[2], true); DONE;")
8346
8347 ;;
8348 ;;- Miscellaneous instructions.
8349 ;;
8350
8351 ;
8352 ; allocate stack instruction pattern(s).
8353 ;
8354
8355 (define_expand "allocate_stack"
8356 [(match_operand 0 "general_operand" "")
8357 (match_operand 1 "general_operand" "")]
8358 "TARGET_BACKCHAIN"
8359 {
8360 rtx temp = gen_reg_rtx (Pmode);
8361
8362 emit_move_insn (temp, s390_back_chain_rtx ());
8363 anti_adjust_stack (operands[1]);
8364 emit_move_insn (s390_back_chain_rtx (), temp);
8365
8366 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
8367 DONE;
8368 })
8369
8370
8371 ;
8372 ; setjmp instruction pattern.
8373 ;
8374
8375 (define_expand "builtin_setjmp_receiver"
8376 [(match_operand 0 "" "")]
8377 "flag_pic"
8378 {
8379 emit_insn (s390_load_got ());
8380 emit_use (pic_offset_table_rtx);
8381 DONE;
8382 })
8383
8384 ;; These patterns say how to save and restore the stack pointer. We need not
8385 ;; save the stack pointer at function level since we are careful to
8386 ;; preserve the backchain. At block level, we have to restore the backchain
8387 ;; when we restore the stack pointer.
8388 ;;
8389 ;; For nonlocal gotos, we must save both the stack pointer and its
8390 ;; backchain and restore both. Note that in the nonlocal case, the
8391 ;; save area is a memory location.
8392
8393 (define_expand "save_stack_function"
8394 [(match_operand 0 "general_operand" "")
8395 (match_operand 1 "general_operand" "")]
8396 ""
8397 "DONE;")
8398
8399 (define_expand "restore_stack_function"
8400 [(match_operand 0 "general_operand" "")
8401 (match_operand 1 "general_operand" "")]
8402 ""
8403 "DONE;")
8404
8405 (define_expand "restore_stack_block"
8406 [(match_operand 0 "register_operand" "")
8407 (match_operand 1 "register_operand" "")]
8408 "TARGET_BACKCHAIN"
8409 {
8410 rtx temp = gen_reg_rtx (Pmode);
8411
8412 emit_move_insn (temp, s390_back_chain_rtx ());
8413 emit_move_insn (operands[0], operands[1]);
8414 emit_move_insn (s390_back_chain_rtx (), temp);
8415
8416 DONE;
8417 })
8418
8419 (define_expand "save_stack_nonlocal"
8420 [(match_operand 0 "memory_operand" "")
8421 (match_operand 1 "register_operand" "")]
8422 ""
8423 {
8424 enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
8425 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
8426
8427 /* Copy the backchain to the first word, sp to the second and the
8428 literal pool base to the third. */
8429
8430 if (TARGET_BACKCHAIN)
8431 {
8432 rtx temp = force_reg (Pmode, s390_back_chain_rtx ());
8433 emit_move_insn (operand_subword (operands[0], 0, 0, mode), temp);
8434 }
8435
8436 emit_move_insn (operand_subword (operands[0], 1, 0, mode), operands[1]);
8437 emit_move_insn (operand_subword (operands[0], 2, 0, mode), base);
8438
8439 DONE;
8440 })
8441
8442 (define_expand "restore_stack_nonlocal"
8443 [(match_operand 0 "register_operand" "")
8444 (match_operand 1 "memory_operand" "")]
8445 ""
8446 {
8447 enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
8448 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
8449 rtx temp = NULL_RTX;
8450
8451 /* Restore the backchain from the first word, sp from the second and the
8452 literal pool base from the third. */
8453
8454 if (TARGET_BACKCHAIN)
8455 temp = force_reg (Pmode, operand_subword (operands[1], 0, 0, mode));
8456
8457 emit_move_insn (base, operand_subword (operands[1], 2, 0, mode));
8458 emit_move_insn (operands[0], operand_subword (operands[1], 1, 0, mode));
8459
8460 if (temp)
8461 emit_move_insn (s390_back_chain_rtx (), temp);
8462
8463 emit_use (base);
8464 DONE;
8465 })
8466
8467 (define_expand "exception_receiver"
8468 [(const_int 0)]
8469 ""
8470 {
8471 s390_set_has_landing_pad_p (true);
8472 DONE;
8473 })
8474
8475 ;
8476 ; nop instruction pattern(s).
8477 ;
8478
8479 (define_insn "nop"
8480 [(const_int 0)]
8481 ""
8482 "lr\t0,0"
8483 [(set_attr "op_type" "RR")
8484 (set_attr "z10prop" "z10_fr_E1")])
8485
8486 (define_insn "nop1"
8487 [(const_int 1)]
8488 ""
8489 "lr\t1,1"
8490 [(set_attr "op_type" "RR")])
8491
8492
8493 ;
8494 ; Special literal pool access instruction pattern(s).
8495 ;
8496
8497 (define_insn "*pool_entry"
8498 [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
8499 UNSPECV_POOL_ENTRY)]
8500 ""
8501 {
8502 enum machine_mode mode = GET_MODE (PATTERN (insn));
8503 unsigned int align = GET_MODE_BITSIZE (mode);
8504 s390_output_pool_entry (operands[0], mode, align);
8505 return "";
8506 }
8507 [(set (attr "length")
8508 (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
8509
8510 (define_insn "pool_align"
8511 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")]
8512 UNSPECV_POOL_ALIGN)]
8513 ""
8514 ".align\t%0"
8515 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
8516
8517 (define_insn "pool_section_start"
8518 [(unspec_volatile [(const_int 1)] UNSPECV_POOL_SECTION)]
8519 ""
8520 ".section\t.rodata"
8521 [(set_attr "length" "0")])
8522
8523 (define_insn "pool_section_end"
8524 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_SECTION)]
8525 ""
8526 ".previous"
8527 [(set_attr "length" "0")])
8528
8529 (define_insn "main_base_31_small"
8530 [(set (match_operand 0 "register_operand" "=a")
8531 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
8532 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8533 "basr\t%0,0"
8534 [(set_attr "op_type" "RR")
8535 (set_attr "type" "la")])
8536
8537 (define_insn "main_base_31_large"
8538 [(set (match_operand 0 "register_operand" "=a")
8539 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
8540 (set (pc) (label_ref (match_operand 2 "" "")))]
8541 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8542 "bras\t%0,%2"
8543 [(set_attr "op_type" "RI")])
8544
8545 (define_insn "main_base_64"
8546 [(set (match_operand 0 "register_operand" "=a")
8547 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
8548 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8549 "larl\t%0,%1"
8550 [(set_attr "op_type" "RIL")
8551 (set_attr "type" "larl")
8552 (set_attr "z10prop" "z10_fwd_A1")])
8553
8554 (define_insn "main_pool"
8555 [(set (match_operand 0 "register_operand" "=a")
8556 (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
8557 "GET_MODE (operands[0]) == Pmode"
8558 {
8559 gcc_unreachable ();
8560 }
8561 [(set (attr "type")
8562 (if_then_else (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
8563 (const_string "larl") (const_string "la")))])
8564
8565 (define_insn "reload_base_31"
8566 [(set (match_operand 0 "register_operand" "=a")
8567 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
8568 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8569 "basr\t%0,0\;la\t%0,%1-.(%0)"
8570 [(set_attr "length" "6")
8571 (set_attr "type" "la")])
8572
8573 (define_insn "reload_base_64"
8574 [(set (match_operand 0 "register_operand" "=a")
8575 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
8576 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8577 "larl\t%0,%1"
8578 [(set_attr "op_type" "RIL")
8579 (set_attr "type" "larl")
8580 (set_attr "z10prop" "z10_fwd_A1")])
8581
8582 (define_insn "pool"
8583 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
8584 ""
8585 {
8586 gcc_unreachable ();
8587 }
8588 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
8589
8590 ;;
8591 ;; Insns related to generating the function prologue and epilogue.
8592 ;;
8593
8594
8595 (define_expand "prologue"
8596 [(use (const_int 0))]
8597 ""
8598 "s390_emit_prologue (); DONE;")
8599
8600 (define_expand "epilogue"
8601 [(use (const_int 1))]
8602 ""
8603 "s390_emit_epilogue (false); DONE;")
8604
8605 (define_expand "sibcall_epilogue"
8606 [(use (const_int 0))]
8607 ""
8608 "s390_emit_epilogue (true); DONE;")
8609
8610 (define_insn "*return"
8611 [(return)
8612 (use (match_operand 0 "register_operand" "a"))]
8613 "GET_MODE (operands[0]) == Pmode"
8614 "br\t%0"
8615 [(set_attr "op_type" "RR")
8616 (set_attr "type" "jsr")
8617 (set_attr "atype" "agen")])
8618
8619
8620 ;; Instruction definition to extend a 31-bit pointer into a 64-bit
8621 ;; pointer. This is used for compatibility.
8622
8623 (define_expand "ptr_extend"
8624 [(set (match_operand:DI 0 "register_operand" "=r")
8625 (match_operand:SI 1 "register_operand" "r"))]
8626 "TARGET_64BIT"
8627 {
8628 emit_insn (gen_anddi3 (operands[0],
8629 gen_lowpart (DImode, operands[1]),
8630 GEN_INT (0x7fffffff)));
8631 DONE;
8632 })
8633
8634 ;; Instruction definition to expand eh_return macro to support
8635 ;; swapping in special linkage return addresses.
8636
8637 (define_expand "eh_return"
8638 [(use (match_operand 0 "register_operand" ""))]
8639 "TARGET_TPF"
8640 {
8641 s390_emit_tpf_eh_return (operands[0]);
8642 DONE;
8643 })
8644
8645 ;
8646 ; Stack Protector Patterns
8647 ;
8648
8649 (define_expand "stack_protect_set"
8650 [(set (match_operand 0 "memory_operand" "")
8651 (match_operand 1 "memory_operand" ""))]
8652 ""
8653 {
8654 #ifdef TARGET_THREAD_SSP_OFFSET
8655 operands[1]
8656 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
8657 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
8658 #endif
8659 if (TARGET_64BIT)
8660 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
8661 else
8662 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
8663
8664 DONE;
8665 })
8666
8667 (define_insn "stack_protect_set<mode>"
8668 [(set (match_operand:DSI 0 "memory_operand" "=Q")
8669 (unspec:DSI [(match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
8670 ""
8671 "mvc\t%O0(%G0,%R0),%S1"
8672 [(set_attr "op_type" "SS")])
8673
8674 (define_expand "stack_protect_test"
8675 [(set (reg:CC CC_REGNUM)
8676 (compare (match_operand 0 "memory_operand" "")
8677 (match_operand 1 "memory_operand" "")))
8678 (match_operand 2 "" "")]
8679 ""
8680 {
8681 #ifdef TARGET_THREAD_SSP_OFFSET
8682 operands[1]
8683 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
8684 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
8685 #endif
8686 s390_compare_op0 = operands[0];
8687 s390_compare_op1 = operands[1];
8688 s390_compare_emitted = gen_rtx_REG (CCZmode, CC_REGNUM);
8689
8690 if (TARGET_64BIT)
8691 emit_insn (gen_stack_protect_testdi (operands[0], operands[1]));
8692 else
8693 emit_insn (gen_stack_protect_testsi (operands[0], operands[1]));
8694
8695 emit_jump_insn (gen_beq (operands[2]));
8696
8697 DONE;
8698 })
8699
8700 (define_insn "stack_protect_test<mode>"
8701 [(set (reg:CCZ CC_REGNUM)
8702 (unspec:CCZ [(match_operand:DSI 0 "memory_operand" "Q")
8703 (match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
8704 ""
8705 "clc\t%O0(%G0,%R0),%S1"
8706 [(set_attr "op_type" "SS")])
8707
8708 ; This is used in s390_emit_prologue in order to prevent insns
8709 ; adjusting the stack pointer to be moved over insns writing stack
8710 ; slots using a copy of the stack pointer in a different register.
8711 (define_insn "stack_tie"
8712 [(set (match_operand:BLK 0 "memory_operand" "+m")
8713 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
8714 ""
8715 ""
8716 [(set_attr "length" "0")])
8717
8718
8719 ;
8720 ; Data prefetch patterns
8721 ;
8722
8723 (define_insn "prefetch"
8724 [(prefetch (match_operand 0 "address_operand" "UW,X")
8725 (match_operand:SI 1 "const_int_operand" "n,n")
8726 (match_operand:SI 2 "const_int_operand" "n,n"))]
8727 "TARGET_Z10"
8728 {
8729 if (larl_operand (operands[0], Pmode))
8730 return INTVAL (operands[1]) == 1 ? "pfdrl\t2,%a0" : "pfdrl\t1,%a0";
8731
8732 if (s390_mem_constraint ("W", operands[0])
8733 || s390_mem_constraint ("U", operands[0]))
8734 return INTVAL (operands[1]) == 1 ? "pfd\t2,%a0" : "pfd\t1,%a0";
8735
8736 /* This point might be reached if op0 is a larl operand with an
8737 uneven addend. In this case we simply omit issuing a prefetch
8738 instruction. */
8739
8740 return "";
8741 }
8742 [(set_attr "type" "load,larl")
8743 (set_attr "op_type" "RXY,RIL")
8744 (set_attr "z10prop" "z10_super")])
8745
8746
8747 ;
8748 ; Byte swap instructions
8749 ;
8750
8751 (define_insn "bswap<mode>2"
8752 [(set (match_operand:GPR 0 "register_operand" "=d, d")
8753 (bswap:GPR (match_operand:GPR 1 "nonimmediate_operand" " d,RT")))]
8754 ""
8755 "@
8756 lrv<g>r\t%0,%1
8757 lrv<g>\t%0,%1"
8758 [(set_attr "type" "*,load")
8759 (set_attr "op_type" "RRE,RXY")
8760 (set_attr "z10prop" "z10_super")])