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