]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/s390/s390.md
ChangeLog: Fix typos.
[thirdparty/gcc.git] / gcc / config / s390 / s390.md
CommitLineData
9db1d521 1;;- Machine description for GNU compiler -- S/390 / zSeries version.
c161ecf7 2;; Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
9db1d521 3;; Contributed by Hartmut Penner (hpenner@de.ibm.com) and
f314b9b1 4;; Ulrich Weigand (uweigand@de.ibm.com).
9db1d521 5
58add37a
UW
6;; This file is part of GCC.
7
8;; GCC is free software; you can redistribute it and/or modify it under
9;; the terms of the GNU General Public License as published by the Free
10;; Software Foundation; either version 2, or (at your option) any later
11;; version.
12
13;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
15;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16;; for more details.
9db1d521
HP
17
18;; You should have received a copy of the GNU General Public License
58add37a
UW
19;; along with GCC; see the file COPYING. If not, write to the Free
20;; Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21;; 02111-1307, USA.
9db1d521
HP
22
23;;
24;; Special constraints for s/390 machine description:
25;;
26;; a -- Any address register from 1 to 15.
27;; d -- Any register from 0 to 15.
28;; I -- An 8-bit constant (0..255).
29;; J -- A 12-bit constant (0..4095).
30;; K -- A 16-bit constant (-32768..32767).
f19a9af7
AK
31;; L -- Value appropriate as displacement.
32;; (0..4095) for short displacement
33;; (-524288..524287) for long displacement
34;; M -- Constant integer with a value of 0x7fffffff.
35;; N -- Multiple letter constraint followed by 4 parameter letters.
36;; 0..9: number of the part counting from most to least significant
37;; H,Q: mode of the part
38;; D,S,H: mode of the containing operand
39;; 0,F: value of the other parts (F - all bits set)
40;;
41;; The constraint matches if the specified part of a constant
42;; has a value different from its other parts.
43;; Q -- Memory reference without index register and with short displacement.
44;; R -- Memory reference with index register and short displacement.
45;; S -- Memory reference without index register but with long displacement.
46;; T -- Memory reference with index register and long displacement.
47;; U -- Pointer with short displacement.
48;; W -- Pointer with long displacement.
49;; Y -- Shift count operand.
9db1d521
HP
50;;
51;; Special formats used for outputting 390 instructions.
52;;
f19a9af7
AK
53;; %C: print opcode suffix for branch condition.
54;; %D: print opcode suffix for inverse branch condition.
55;; %J: print tls_load/tls_gdcall/tls_ldcall suffix
56;; %O: print only the displacement of a memory reference.
57;; %R: print only the base register of a memory reference.
58;; %N: print the second word of a DImode operand.
59;; %M: print the second word of a TImode operand.
60
61;; %b: print integer X as if it's an unsigned byte.
62;; %x: print integer X as if it's an unsigned word.
63;; %h: print integer X as if it's a signed word.
64;; %i: print the first nonzero HImode part of X
65;; %j: print the first HImode part unequal to 0xffff of X
66
9db1d521
HP
67;;
68;; We have a special constraint for pattern matching.
69;;
70;; s_operand -- Matches a valid S operand in a RS, SI or SS type instruction.
71;;
9db1d521 72
fd3cd001
UW
73;;
74;; UNSPEC usage
75;;
76
77(define_constants
10bbf137
UW
78 [; Miscellaneous
79 (UNSPEC_ROUND 1)
80 (UNSPEC_SETHIGH 10)
81
82 ; GOT/PLT and lt-relative accesses
fd7643fb
UW
83 (UNSPEC_LTREL_OFFSET 100)
84 (UNSPEC_LTREL_BASE 101)
85 (UNSPEC_GOTENT 110)
86 (UNSPEC_GOT 111)
87 (UNSPEC_GOTOFF 112)
88 (UNSPEC_PLT 113)
89 (UNSPEC_PLTOFF 114)
90
91 ; Literal pool
92 (UNSPEC_RELOAD_BASE 210)
5af2f3d3 93 (UNSPEC_MAIN_BASE 211)
fd7643fb
UW
94
95 ; TLS relocation specifiers
fd3cd001
UW
96 (UNSPEC_TLSGD 500)
97 (UNSPEC_TLSLDM 501)
98 (UNSPEC_NTPOFF 502)
99 (UNSPEC_DTPOFF 503)
100 (UNSPEC_GOTNTPOFF 504)
101 (UNSPEC_INDNTPOFF 505)
102
103 ; TLS support
104 (UNSPEC_TP 510)
105 (UNSPEC_TLSLDM_NTPOFF 511)
106 (UNSPEC_TLS_LOAD 512)
107 ])
108
109;;
110;; UNSPEC_VOLATILE usage
111;;
112
113(define_constants
10bbf137
UW
114 [; Blockage
115 (UNSPECV_BLOCKAGE 0)
116
117 ; Literal pool
fd7643fb
UW
118 (UNSPECV_POOL 200)
119 (UNSPECV_POOL_START 201)
120 (UNSPECV_POOL_END 202)
416cf582 121 (UNSPECV_POOL_ENTRY 203)
fd7643fb
UW
122 (UNSPECV_MAIN_POOL 300)
123
124 ; TLS support
fd3cd001
UW
125 (UNSPECV_SET_TP 500)
126 ])
127
128
1fec52be
HP
129;; Processor type. This attribute must exactly match the processor_type
130;; enumeration in s390.h.
131
f13e0d4e
UW
132(define_attr "cpu" "g5,g6,z900,z990"
133 (const (symbol_ref "s390_tune")))
9db1d521 134
f2d3c02a
HP
135;; Define an insn type attribute. This is used in function unit delay
136;; computations.
9db1d521 137
077dab3b
HP
138(define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
139 cs,vs,store,imul,idiv,
140 branch,jsr,fsimpd,fsimps,
141 floadd,floads,fstored, fstores,
142 fmuld,fmuls,fdivd,fdivs,
143 ftoi,itof,fsqrtd,fsqrts,
144 other,o2,o3"
c7453384 145 (const_string "integer"))
9db1d521 146
077dab3b 147;; Operand type. Used to default length attribute values
9db1d521 148
077dab3b 149(define_attr "op_type"
d3632d41 150 "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY"
077dab3b
HP
151 (const_string "RX"))
152
153;; Insn are devide in two classes:
154;; agen: Insn using agen
155;; reg: Insn not using agen
156
157(define_attr "atype" "agen,reg"
158(cond [ (eq_attr "op_type" "E") (const_string "reg")
159 (eq_attr "op_type" "RR") (const_string "reg")
160 (eq_attr "op_type" "RX") (const_string "agen")
161 (eq_attr "op_type" "RI") (const_string "reg")
162 (eq_attr "op_type" "RRE") (const_string "reg")
163 (eq_attr "op_type" "RS") (const_string "agen")
164 (eq_attr "op_type" "RSI") (const_string "agen")
165 (eq_attr "op_type" "S") (const_string "agen")
166 (eq_attr "op_type" "SI") (const_string "agen")
167 (eq_attr "op_type" "SS") (const_string "agen")
168 (eq_attr "op_type" "SSE") (const_string "agen")
169 (eq_attr "op_type" "RXE") (const_string "agen")
170 (eq_attr "op_type" "RSE") (const_string "agen")
d3632d41
UW
171 (eq_attr "op_type" "RIL") (const_string "agen")
172 (eq_attr "op_type" "RXY") (const_string "agen")
173 (eq_attr "op_type" "RSY") (const_string "agen")
174 (eq_attr "op_type" "SIY") (const_string "agen")]
077dab3b 175 (const_string "reg")))
9db1d521 176
c7453384 177;; Generic pipeline function unit.
9db1d521 178
4023fb28
UW
179(define_function_unit "integer" 1 0
180 (eq_attr "type" "none") 0 0)
181
f2d3c02a
HP
182(define_function_unit "integer" 1 0
183 (eq_attr "type" "integer") 1 1)
9db1d521 184
077dab3b
HP
185(define_function_unit "integer" 1 0
186 (eq_attr "type" "fsimpd") 1 1)
187
188(define_function_unit "integer" 1 0
189 (eq_attr "type" "fsimps") 1 1)
190
f2d3c02a
HP
191(define_function_unit "integer" 1 0
192 (eq_attr "type" "load") 1 1)
9db1d521 193
077dab3b
HP
194(define_function_unit "integer" 1 0
195 (eq_attr "type" "floadd") 1 1)
196
197(define_function_unit "integer" 1 0
198 (eq_attr "type" "floads") 1 1)
199
f2d3c02a
HP
200(define_function_unit "integer" 1 0
201 (eq_attr "type" "la") 1 1)
9db1d521 202
077dab3b
HP
203(define_function_unit "integer" 1 0
204 (eq_attr "type" "larl") 1 1)
205
f2d3c02a
HP
206(define_function_unit "integer" 1 0
207 (eq_attr "type" "lr") 1 1)
9db1d521 208
077dab3b
HP
209(define_function_unit "integer" 1 0
210 (eq_attr "type" "branch") 1 1)
211
f2d3c02a
HP
212(define_function_unit "integer" 1 0
213 (eq_attr "type" "store") 1 1)
9db1d521 214
077dab3b
HP
215(define_function_unit "integer" 1 0
216 (eq_attr "type" "fstored") 1 1)
217
218(define_function_unit "integer" 1 0
219 (eq_attr "type" "fstores") 1 1)
220
4023fb28
UW
221(define_function_unit "integer" 1 0
222 (eq_attr "type" "lm") 2 2)
223
224(define_function_unit "integer" 1 0
225 (eq_attr "type" "stm") 2 2)
226
227(define_function_unit "integer" 1 0
228 (eq_attr "type" "cs") 5 5)
229
230(define_function_unit "integer" 1 0
231 (eq_attr "type" "vs") 30 30)
232
f2d3c02a
HP
233(define_function_unit "integer" 1 0
234 (eq_attr "type" "jsr") 5 5)
9db1d521 235
f2d3c02a
HP
236(define_function_unit "integer" 1 0
237 (eq_attr "type" "imul") 7 7)
238
239(define_function_unit "integer" 1 0
077dab3b
HP
240 (eq_attr "type" "fmuld") 6 6)
241
242(define_function_unit "integer" 1 0
243 (eq_attr "type" "fmuls") 6 6)
9db1d521 244
f2d3c02a
HP
245(define_function_unit "integer" 1 0
246 (eq_attr "type" "idiv") 33 33)
9db1d521 247
f2d3c02a 248(define_function_unit "integer" 1 0
077dab3b
HP
249 (eq_attr "type" "fdivd") 33 33)
250
251(define_function_unit "integer" 1 0
252 (eq_attr "type" "fdivs") 33 33)
253
254(define_function_unit "integer" 1 0
255 (eq_attr "type" "fsqrtd") 30 30)
256
257(define_function_unit "integer" 1 0
258 (eq_attr "type" "fsqrts") 30 30)
259
260(define_function_unit "integer" 1 0
261 (eq_attr "type" "ftoi") 2 2)
262
263(define_function_unit "integer" 1 0
264 (eq_attr "type" "itof") 2 2)
9db1d521 265
f2d3c02a
HP
266(define_function_unit "integer" 1 0
267 (eq_attr "type" "o2") 2 2)
9db1d521 268
f2d3c02a
HP
269(define_function_unit "integer" 1 0
270 (eq_attr "type" "o3") 3 3)
9db1d521 271
f2d3c02a
HP
272(define_function_unit "integer" 1 0
273 (eq_attr "type" "other") 5 5)
274
077dab3b 275;; Pipeline description for z900
9db1d521 276
077dab3b 277(include "2064.md")
52609473 278(include "2084.md")
9db1d521
HP
279
280;; Length in bytes.
281
282(define_attr "length" ""
283(cond [ (eq_attr "op_type" "E") (const_int 2)
284 (eq_attr "op_type" "RR") (const_int 2)
285 (eq_attr "op_type" "RX") (const_int 4)
286 (eq_attr "op_type" "RI") (const_int 4)
287 (eq_attr "op_type" "RRE") (const_int 4)
288 (eq_attr "op_type" "RS") (const_int 4)
289 (eq_attr "op_type" "RSI") (const_int 4)
9db1d521
HP
290 (eq_attr "op_type" "S") (const_int 4)
291 (eq_attr "op_type" "SI") (const_int 4)
292 (eq_attr "op_type" "SS") (const_int 6)
293 (eq_attr "op_type" "SSE") (const_int 6)
294 (eq_attr "op_type" "RXE") (const_int 6)
295 (eq_attr "op_type" "RSE") (const_int 6)
d3632d41
UW
296 (eq_attr "op_type" "RIL") (const_int 6)
297 (eq_attr "op_type" "RXY") (const_int 6)
298 (eq_attr "op_type" "RSY") (const_int 6)
299 (eq_attr "op_type" "SIY") (const_int 6)]
9db1d521
HP
300 (const_int 4)))
301
302;; Define attributes for `asm' insns.
303
f2d3c02a 304(define_asm_attributes [(set_attr "type" "other")
9db1d521
HP
305 (set_attr "op_type" "NN")])
306
307;;
308;; Condition Codes
309;;
310;
311; CCL: Zero Nonzero Zero Nonzero (AL, ALR, SL, SLR, N, NC, NI, NR, O, OC, OI, OR, X, XC, XI, XR)
312; CCA: Zero <Zero >Zero Overflow (A, AR, AH, AHI, S, SR, SH, SHI, LTR, LCR, LNR, LPR, SLA, SLDA, SLA, SRDA)
313; CCU: Equal ULess UGreater -- (CL, CLR, CLI, CLM)
314; CCS: Equal SLess SGreater -- (C, CR, CH, CHI, ICM)
315; CCT: Zero Mixed Mixed Ones (TM, TMH, TML)
c7453384 316
9db1d521
HP
317; CCZ -> CCL / CCZ1
318; CCZ1 -> CCA/CCU/CCS/CCT
319; CCS -> CCA
c7453384 320
9db1d521
HP
321; String: CLC, CLCL, CLCLE, CLST, CUSE, MVCL, MVCLE, MVPG, MVST, SRST
322; Clobber: CKSM, CFC, CS, CDS, CUUTF, CUTFU, PLO, SPM, STCK, STCKE, TS, TRT, TRE, UPT
323
324
325;;
326;;- Compare instructions.
327;;
328
329(define_expand "cmpdi"
330 [(set (reg:CC 33)
331 (compare:CC (match_operand:DI 0 "register_operand" "")
332 (match_operand:DI 1 "general_operand" "")))]
333 "TARGET_64BIT"
9db1d521
HP
334{
335 s390_compare_op0 = operands[0];
336 s390_compare_op1 = operands[1];
337 DONE;
10bbf137 338})
9db1d521
HP
339
340(define_expand "cmpsi"
341 [(set (reg:CC 33)
342 (compare:CC (match_operand:SI 0 "register_operand" "")
343 (match_operand:SI 1 "general_operand" "")))]
344 ""
9db1d521
HP
345{
346 s390_compare_op0 = operands[0];
347 s390_compare_op1 = operands[1];
348 DONE;
10bbf137 349})
9db1d521 350
9db1d521
HP
351(define_expand "cmpdf"
352 [(set (reg:CC 33)
353 (compare:CC (match_operand:DF 0 "register_operand" "")
354 (match_operand:DF 1 "general_operand" "")))]
355 "TARGET_HARD_FLOAT"
9db1d521
HP
356{
357 s390_compare_op0 = operands[0];
358 s390_compare_op1 = operands[1];
359 DONE;
10bbf137 360})
9db1d521
HP
361
362(define_expand "cmpsf"
363 [(set (reg:CC 33)
364 (compare:CC (match_operand:SF 0 "register_operand" "")
365 (match_operand:SF 1 "general_operand" "")))]
366 "TARGET_HARD_FLOAT"
9db1d521
HP
367{
368 s390_compare_op0 = operands[0];
369 s390_compare_op1 = operands[1];
370 DONE;
10bbf137 371})
9db1d521
HP
372
373
07893d4f 374; Test-under-Mask (zero_extract) instructions
9db1d521 375
07893d4f 376(define_insn "*tmdi_ext"
9db1d521
HP
377 [(set (reg 33)
378 (compare (zero_extract:DI (match_operand:DI 0 "register_operand" "d")
4023fb28
UW
379 (match_operand:DI 1 "const_int_operand" "n")
380 (match_operand:DI 2 "const_int_operand" "n"))
9db1d521 381 (const_int 0)))]
4023fb28 382 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT
c7453384 383 && INTVAL (operands[1]) >= 1 && INTVAL (operands[2]) >= 0
4023fb28
UW
384 && INTVAL (operands[1]) + INTVAL (operands[2]) <= 64
385 && (INTVAL (operands[1]) + INTVAL (operands[2]) - 1) >> 4
386 == INTVAL (operands[2]) >> 4"
9db1d521 387{
4023fb28
UW
388 int part = INTVAL (operands[2]) >> 4;
389 int block = (1 << INTVAL (operands[1])) - 1;
390 int shift = 16 - INTVAL (operands[1]) - (INTVAL (operands[2]) & 15);
9db1d521 391
4023fb28 392 operands[2] = GEN_INT (block << shift);
9db1d521 393
4023fb28
UW
394 switch (part)
395 {
d40c829f
UW
396 case 0: return "tmhh\t%0,%x2";
397 case 1: return "tmhl\t%0,%x2";
398 case 2: return "tmlh\t%0,%x2";
399 case 3: return "tmll\t%0,%x2";
4023fb28
UW
400 default: abort ();
401 }
10bbf137 402}
4023fb28
UW
403 [(set_attr "op_type" "RI")])
404
07893d4f 405(define_insn "*tmsi_ext"
9db1d521 406 [(set (reg 33)
07893d4f
UW
407 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
408 (match_operand:SI 1 "const_int_operand" "n")
409 (match_operand:SI 2 "const_int_operand" "n"))
9db1d521 410 (const_int 0)))]
07893d4f 411 "s390_match_ccmode(insn, CCTmode)
c7453384 412 && INTVAL (operands[1]) >= 1 && INTVAL (operands[2]) >= 0
07893d4f
UW
413 && INTVAL (operands[1]) + INTVAL (operands[2]) <= 32
414 && (INTVAL (operands[1]) + INTVAL (operands[2]) - 1) >> 4
415 == INTVAL (operands[2]) >> 4"
9db1d521 416{
07893d4f
UW
417 int part = INTVAL (operands[2]) >> 4;
418 int block = (1 << INTVAL (operands[1])) - 1;
419 int shift = 16 - INTVAL (operands[1]) - (INTVAL (operands[2]) & 15);
420
421 operands[2] = GEN_INT (block << shift);
9db1d521 422
4023fb28 423 switch (part)
9db1d521 424 {
d40c829f
UW
425 case 0: return "tmh\t%0,%x2";
426 case 1: return "tml\t%0,%x2";
4023fb28 427 default: abort ();
9db1d521 428 }
10bbf137 429}
4023fb28
UW
430 [(set_attr "op_type" "RI")])
431
07893d4f 432(define_insn "*tmqi_ext"
4023fb28 433 [(set (reg 33)
d3632d41
UW
434 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "Q,S")
435 (match_operand:SI 1 "const_int_operand" "n,n")
436 (match_operand:SI 2 "const_int_operand" "n,n"))
4023fb28 437 (const_int 0)))]
07893d4f 438 "s390_match_ccmode(insn, CCTmode)
c7453384 439 && INTVAL (operands[1]) >= 1 && INTVAL (operands[2]) >= 0
07893d4f 440 && INTVAL (operands[1]) + INTVAL (operands[2]) <= 8"
4023fb28 441{
07893d4f
UW
442 int block = (1 << INTVAL (operands[1])) - 1;
443 int shift = 8 - INTVAL (operands[1]) - INTVAL (operands[2]);
9db1d521 444
07893d4f 445 operands[2] = GEN_INT (block << shift);
d40c829f 446 return which_alternative == 0 ? "tm\t%0,%b2" : "tmy\t%0,%b2";
10bbf137 447}
d3632d41 448 [(set_attr "op_type" "SI,SIY")])
9db1d521 449
07893d4f 450; Test-under-Mask instructions
9db1d521 451
07893d4f
UW
452(define_insn "*tmdi_mem"
453 [(set (reg 33)
d3632d41
UW
454 (compare (and:DI (match_operand:DI 0 "memory_operand" "Q,S")
455 (match_operand:DI 1 "immediate_operand" "n,n"))
456 (match_operand:DI 2 "immediate_operand" "n,n")))]
9e8327e3 457 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 0))
f19a9af7 458 && s390_single_part (operands[1], DImode, QImode, 0) >= 0"
07893d4f 459{
f19a9af7
AK
460 int part = s390_single_part (operands[1], DImode, QImode, 0);
461 operands[1] = GEN_INT (s390_extract_part (operands[1], QImode, 0));
07893d4f 462
c7453384 463 operands[0] = gen_rtx_MEM (QImode,
07893d4f 464 plus_constant (XEXP (operands[0], 0), part));
d40c829f 465 return which_alternative == 0 ? "tm\t%0,%b1" : "tmy\t%0,%b1";
10bbf137 466}
d3632d41 467 [(set_attr "op_type" "SI,SIY")])
07893d4f
UW
468
469(define_insn "*tmsi_mem"
4023fb28 470 [(set (reg 33)
d3632d41
UW
471 (compare (and:SI (match_operand:SI 0 "memory_operand" "Q,S")
472 (match_operand:SI 1 "immediate_operand" "n,n"))
473 (match_operand:SI 2 "immediate_operand" "n,n")))]
07893d4f 474 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 0))
f19a9af7 475 && s390_single_part (operands[1], SImode, QImode, 0) >= 0"
4023fb28 476{
f19a9af7
AK
477 int part = s390_single_part (operands[1], SImode, QImode, 0);
478 operands[1] = GEN_INT (s390_extract_part (operands[1], QImode, 0));
4023fb28 479
c7453384 480 operands[0] = gen_rtx_MEM (QImode,
4023fb28 481 plus_constant (XEXP (operands[0], 0), part));
d40c829f 482 return which_alternative == 0 ? "tm\t%0,%b1" : "tmy\t%0,%b1";
10bbf137 483}
077dab3b 484 [(set_attr "op_type" "SI")])
9db1d521 485
07893d4f 486(define_insn "*tmhi_mem"
9db1d521 487 [(set (reg 33)
d3632d41
UW
488 (compare (and:SI (subreg:SI (match_operand:HI 0 "memory_operand" "Q,S") 0)
489 (match_operand:SI 1 "immediate_operand" "n,n"))
490 (match_operand:SI 2 "immediate_operand" "n,n")))]
07893d4f 491 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 0))
f19a9af7 492 && s390_single_part (operands[1], HImode, QImode, 0) >= 0"
07893d4f 493{
f19a9af7
AK
494 int part = s390_single_part (operands[1], HImode, QImode, 0);
495 operands[1] = GEN_INT (s390_extract_part (operands[1], QImode, 0));
9db1d521 496
c7453384 497 operands[0] = gen_rtx_MEM (QImode,
07893d4f 498 plus_constant (XEXP (operands[0], 0), part));
d40c829f 499 return which_alternative == 0 ? "tm\t%0,%b1" : "tmy\t%0,%b1";
10bbf137 500}
077dab3b 501 [(set_attr "op_type" "SI")])
9db1d521 502
07893d4f 503(define_insn "*tmqi_mem"
9db1d521 504 [(set (reg 33)
d3632d41
UW
505 (compare (and:SI (subreg:SI (match_operand:QI 0 "memory_operand" "Q,S") 0)
506 (match_operand:SI 1 "immediate_operand" "n,n"))
507 (match_operand:SI 2 "immediate_operand" "n,n")))]
07893d4f 508 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 0))"
d3632d41 509 "@
d40c829f
UW
510 tm\t%0,%b1
511 tmy\t%0,%b1"
d3632d41 512 [(set_attr "op_type" "SI,SIY")])
9db1d521 513
05b9aaaa
UW
514(define_insn "*tmdi_reg"
515 [(set (reg 33)
f19a9af7
AK
516 (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
517 (match_operand:DI 1 "immediate_operand"
518 "N0HD0,N1HD0,N2HD0,N3HD0"))
519 (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
05b9aaaa
UW
520 "TARGET_64BIT
521 && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 1))
f19a9af7
AK
522 && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
523 "@
524 tmhh\t%0,%i1
525 tmhl\t%0,%i1
526 tmlh\t%0,%i1
527 tmll\t%0,%i1"
05b9aaaa
UW
528 [(set_attr "op_type" "RI")])
529
530(define_insn "*tmsi_reg"
531 [(set (reg 33)
f19a9af7
AK
532 (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
533 (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
534 (match_operand:SI 2 "immediate_operand" "n,n")))]
05b9aaaa 535 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 1))
f19a9af7
AK
536 && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
537 "@
538 tmh\t%0,%i1
539 tml\t%0,%i1"
05b9aaaa
UW
540 [(set_attr "op_type" "RI")])
541
07893d4f 542(define_insn "*tmhi_full"
9db1d521 543 [(set (reg 33)
07893d4f
UW
544 (compare (match_operand:HI 0 "register_operand" "d")
545 (match_operand:HI 1 "immediate_operand" "n")))]
546 "s390_match_ccmode (insn, s390_tm_ccmode (GEN_INT (-1), operands[1], 1))"
d40c829f 547 "tml\t%0,65535"
07893d4f 548 [(set_attr "op_type" "RX")])
9db1d521 549
07893d4f 550(define_insn "*tmqi_full"
9db1d521 551 [(set (reg 33)
07893d4f
UW
552 (compare (match_operand:QI 0 "register_operand" "d")
553 (match_operand:QI 1 "immediate_operand" "n")))]
554 "s390_match_ccmode (insn, s390_tm_ccmode (GEN_INT (-1), operands[1], 1))"
d40c829f 555 "tml\t%0,255"
07893d4f 556 [(set_attr "op_type" "RI")])
9db1d521 557
07893d4f
UW
558
559; Load-and-Test instructions
560
561(define_insn "*tstdi_sign"
9db1d521 562 [(set (reg 33)
07893d4f
UW
563 (compare (ashiftrt:DI (ashift:DI (subreg:DI (match_operand:SI 0 "register_operand" "d") 0)
564 (const_int 32)) (const_int 32))
565 (match_operand:DI 1 "const0_operand" "")))
566 (set (match_operand:DI 2 "register_operand" "=d")
567 (sign_extend:DI (match_dup 0)))]
568 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
d40c829f 569 "ltgfr\t%2,%0"
07893d4f
UW
570 [(set_attr "op_type" "RRE")])
571
572(define_insn "*tstdi"
9db1d521 573 [(set (reg 33)
07893d4f
UW
574 (compare (match_operand:DI 0 "register_operand" "d")
575 (match_operand:DI 1 "const0_operand" "")))
576 (set (match_operand:DI 2 "register_operand" "=d")
577 (match_dup 0))]
578 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
d40c829f 579 "ltgr\t%2,%0"
07893d4f 580 [(set_attr "op_type" "RRE")])
9db1d521 581
07893d4f 582(define_insn "*tstdi_cconly"
9db1d521 583 [(set (reg 33)
07893d4f
UW
584 (compare (match_operand:DI 0 "register_operand" "d")
585 (match_operand:DI 1 "const0_operand" "")))]
586 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
d40c829f 587 "ltgr\t%0,%0"
07893d4f 588 [(set_attr "op_type" "RRE")])
9db1d521 589
07893d4f
UW
590(define_insn "*tstdi_cconly_31"
591 [(set (reg 33)
592 (compare (match_operand:DI 0 "register_operand" "d")
593 (match_operand:DI 1 "const0_operand" "")))]
594 "s390_match_ccmode(insn, CCSmode) && !TARGET_64BIT"
d40c829f 595 "srda\t%0,0"
077dab3b
HP
596 [(set_attr "op_type" "RS")
597 (set_attr "atype" "reg")])
598
4023fb28 599
07893d4f
UW
600(define_insn "*tstsi"
601 [(set (reg 33)
d3632d41 602 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
07893d4f 603 (match_operand:SI 1 "const0_operand" "")))
d3632d41 604 (set (match_operand:SI 2 "register_operand" "=d,d,d")
07893d4f
UW
605 (match_dup 0))]
606 "s390_match_ccmode(insn, CCSmode)"
607 "@
d40c829f
UW
608 ltr\t%2,%0
609 icm\t%2,15,%0
610 icmy\t%2,15,%0"
d3632d41 611 [(set_attr "op_type" "RR,RS,RSY")])
9db1d521 612
07893d4f 613(define_insn "*tstsi_cconly"
4023fb28 614 [(set (reg 33)
d3632d41 615 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
07893d4f 616 (match_operand:SI 1 "const0_operand" "")))
d3632d41 617 (clobber (match_scratch:SI 2 "=X,d,d"))]
07893d4f
UW
618 "s390_match_ccmode(insn, CCSmode)"
619 "@
d40c829f
UW
620 ltr\t%0,%0
621 icm\t%2,15,%0
622 icmy\t%2,15,%0"
d3632d41 623 [(set_attr "op_type" "RR,RS,RSY")])
4023fb28 624
07893d4f
UW
625(define_insn "*tstsi_cconly2"
626 [(set (reg 33)
627 (compare (match_operand:SI 0 "register_operand" "d")
628 (match_operand:SI 1 "const0_operand" "")))]
629 "s390_match_ccmode(insn, CCSmode)"
d40c829f 630 "ltr\t%0,%0"
07893d4f 631 [(set_attr "op_type" "RR")])
4023fb28 632
3af97654
UW
633(define_insn "*tsthiCCT"
634 [(set (reg 33)
d3632d41 635 (compare (match_operand:HI 0 "nonimmediate_operand" "?Q,?S,d")
3af97654 636 (match_operand:HI 1 "const0_operand" "")))
d3632d41 637 (set (match_operand:HI 2 "register_operand" "=d,d,0")
3af97654
UW
638 (match_dup 0))]
639 "s390_match_ccmode(insn, CCTmode)"
640 "@
d40c829f
UW
641 icm\t%2,3,%0
642 icmy\t%2,3,%0
643 tml\t%0,65535"
d3632d41 644 [(set_attr "op_type" "RS,RSY,RI")])
3af97654
UW
645
646(define_insn "*tsthiCCT_cconly"
647 [(set (reg 33)
d3632d41 648 (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
3af97654 649 (match_operand:HI 1 "const0_operand" "")))
d3632d41 650 (clobber (match_scratch:HI 2 "=d,d,X"))]
3af97654
UW
651 "s390_match_ccmode(insn, CCTmode)"
652 "@
d40c829f
UW
653 icm\t%2,3,%0
654 icmy\t%2,3,%0
655 tml\t%0,65535"
d3632d41 656 [(set_attr "op_type" "RS,RSY,RI")])
3af97654 657
07893d4f 658(define_insn "*tsthi"
9db1d521 659 [(set (reg 33)
d3632d41 660 (compare (match_operand:HI 0 "s_operand" "Q,S")
9db1d521 661 (match_operand:HI 1 "const0_operand" "")))
d3632d41 662 (set (match_operand:HI 2 "register_operand" "=d,d")
9db1d521
HP
663 (match_dup 0))]
664 "s390_match_ccmode(insn, CCSmode)"
d3632d41 665 "@
d40c829f
UW
666 icm\t%2,3,%0
667 icmy\t%2,3,%0"
d3632d41 668 [(set_attr "op_type" "RS,RSY")])
9db1d521 669
07893d4f 670(define_insn "*tsthi_cconly"
9db1d521 671 [(set (reg 33)
d3632d41 672 (compare (match_operand:HI 0 "s_operand" "Q,S")
9db1d521 673 (match_operand:HI 1 "const0_operand" "")))
d3632d41 674 (clobber (match_scratch:HI 2 "=d,d"))]
9db1d521 675 "s390_match_ccmode(insn, CCSmode)"
d3632d41 676 "@
d40c829f
UW
677 icm\t%2,3,%0
678 icmy\t%2,3,%0"
d3632d41 679 [(set_attr "op_type" "RS,RSY")])
9db1d521 680
3af97654
UW
681(define_insn "*tstqiCCT"
682 [(set (reg 33)
d3632d41 683 (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
3af97654 684 (match_operand:QI 1 "const0_operand" "")))
d3632d41 685 (set (match_operand:QI 2 "register_operand" "=d,d,0")
3af97654
UW
686 (match_dup 0))]
687 "s390_match_ccmode(insn, CCTmode)"
688 "@
d40c829f
UW
689 icm\t%2,1,%0
690 icmy\t%2,1,%0
691 tml\t%0,255"
d3632d41 692 [(set_attr "op_type" "RS,RSY,RI")])
3af97654
UW
693
694(define_insn "*tstqiCCT_cconly"
695 [(set (reg 33)
d3632d41 696 (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
3af97654
UW
697 (match_operand:QI 1 "const0_operand" "")))]
698 "s390_match_ccmode(insn, CCTmode)"
699 "@
d40c829f
UW
700 cli\t%0,0
701 cliy\t%0,0
702 tml\t%0,255"
d3632d41 703 [(set_attr "op_type" "SI,SIY,RI")])
3af97654 704
07893d4f 705(define_insn "*tstqi"
9db1d521 706 [(set (reg 33)
d3632d41 707 (compare (match_operand:QI 0 "s_operand" "Q,S")
07893d4f 708 (match_operand:QI 1 "const0_operand" "")))
d3632d41 709 (set (match_operand:QI 2 "register_operand" "=d,d")
07893d4f
UW
710 (match_dup 0))]
711 "s390_match_ccmode(insn, CCSmode)"
d3632d41 712 "@
d40c829f
UW
713 icm\t%2,1,%0
714 icmy\t%2,1,%0"
d3632d41 715 [(set_attr "op_type" "RS,RSY")])
9db1d521 716
07893d4f 717(define_insn "*tstqi_cconly"
9db1d521 718 [(set (reg 33)
d3632d41 719 (compare (match_operand:QI 0 "s_operand" "Q,S")
07893d4f 720 (match_operand:QI 1 "const0_operand" "")))
d3632d41 721 (clobber (match_scratch:QI 2 "=d,d"))]
07893d4f 722 "s390_match_ccmode(insn, CCSmode)"
d3632d41 723 "@
d40c829f
UW
724 icm\t%2,1,%0
725 icmy\t%2,1,%0"
d3632d41
UW
726 [(set_attr "op_type" "RS,RSY")])
727
9db1d521 728
07893d4f 729; Compare (signed) instructions
4023fb28 730
07893d4f 731(define_insn "*cmpdi_ccs_sign"
4023fb28 732 [(set (reg 33)
07893d4f
UW
733 (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m"))
734 (match_operand:DI 0 "register_operand" "d,d")))]
735 "s390_match_ccmode(insn, CCSRmode) && TARGET_64BIT"
4023fb28 736 "@
d40c829f
UW
737 cgfr\t%0,%1
738 cgf\t%0,%1"
d3632d41 739 [(set_attr "op_type" "RRE,RXY")])
4023fb28 740
07893d4f 741(define_insn "*cmpdi_ccs"
4023fb28 742 [(set (reg 33)
07893d4f
UW
743 (compare (match_operand:DI 0 "register_operand" "d,d,d")
744 (match_operand:DI 1 "general_operand" "d,K,m")))]
745 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
746 "@
d40c829f
UW
747 cgr\t%0,%1
748 cghi\t%0,%c1
749 cg\t%0,%1"
d3632d41 750 [(set_attr "op_type" "RRE,RI,RXY")])
c7453384 751
07893d4f
UW
752(define_insn "*cmpsi_ccs_sign"
753 [(set (reg 33)
d3632d41
UW
754 (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T"))
755 (match_operand:SI 0 "register_operand" "d,d")))]
07893d4f 756 "s390_match_ccmode(insn, CCSRmode)"
d3632d41 757 "@
d40c829f
UW
758 ch\t%0,%1
759 chy\t%0,%1"
d3632d41 760 [(set_attr "op_type" "RX,RXY")])
4023fb28 761
07893d4f 762(define_insn "*cmpsi_ccs"
9db1d521 763 [(set (reg 33)
d3632d41
UW
764 (compare (match_operand:SI 0 "register_operand" "d,d,d,d")
765 (match_operand:SI 1 "general_operand" "d,K,R,T")))]
9db1d521 766 "s390_match_ccmode(insn, CCSmode)"
07893d4f 767 "@
d40c829f
UW
768 cr\t%0,%1
769 chi\t%0,%c1
770 c\t%0,%1
771 cy\t%0,%1"
d3632d41 772 [(set_attr "op_type" "RR,RI,RX,RXY")])
c7453384 773
07893d4f
UW
774
775; Compare (unsigned) instructions
9db1d521 776
07893d4f 777(define_insn "*cmpdi_ccu_zero"
9db1d521 778 [(set (reg 33)
07893d4f
UW
779 (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m"))
780 (match_operand:DI 0 "register_operand" "d,d")))]
781 "s390_match_ccmode(insn, CCURmode) && TARGET_64BIT"
782 "@
d40c829f
UW
783 clgfr\t%0,%1
784 clgf\t%0,%1"
d3632d41 785 [(set_attr "op_type" "RRE,RXY")])
9db1d521 786
07893d4f 787(define_insn "*cmpdi_ccu"
9db1d521 788 [(set (reg 33)
07893d4f
UW
789 (compare (match_operand:DI 0 "register_operand" "d,d")
790 (match_operand:DI 1 "general_operand" "d,m")))]
791 "s390_match_ccmode(insn, CCUmode) && TARGET_64BIT"
792 "@
d40c829f
UW
793 clgr\t%0,%1
794 clg\t%0,%1"
d3632d41 795 [(set_attr "op_type" "RRE,RXY")])
9db1d521 796
07893d4f 797(define_insn "*cmpsi_ccu"
9db1d521 798 [(set (reg 33)
d3632d41
UW
799 (compare (match_operand:SI 0 "register_operand" "d,d,d")
800 (match_operand:SI 1 "general_operand" "d,R,T")))]
07893d4f
UW
801 "s390_match_ccmode(insn, CCUmode)"
802 "@
d40c829f
UW
803 clr\t%0,%1
804 cl\t%0,%1
805 cly\t%0,%1"
d3632d41 806 [(set_attr "op_type" "RR,RX,RXY")])
9db1d521 807
07893d4f 808(define_insn "*cmphi_ccu"
9db1d521 809 [(set (reg 33)
d3632d41
UW
810 (compare (match_operand:HI 0 "register_operand" "d,d")
811 (match_operand:HI 1 "s_imm_operand" "Q,S")))]
9db1d521 812 "s390_match_ccmode(insn, CCUmode)"
d3632d41 813 "@
d40c829f
UW
814 clm\t%0,3,%1
815 clmy\t%0,3,%1"
d3632d41 816 [(set_attr "op_type" "RS,RSY")])
9db1d521
HP
817
818(define_insn "*cmpqi_ccu"
819 [(set (reg 33)
d3632d41
UW
820 (compare (match_operand:QI 0 "register_operand" "d,d")
821 (match_operand:QI 1 "s_imm_operand" "Q,S")))]
9db1d521 822 "s390_match_ccmode(insn, CCUmode)"
d3632d41 823 "@
d40c829f
UW
824 clm\t%0,1,%1
825 clmy\t%0,1,%1"
d3632d41 826 [(set_attr "op_type" "RS,RSY")])
9db1d521 827
07893d4f 828(define_insn "*cli"
9db1d521 829 [(set (reg 33)
d3632d41
UW
830 (compare (match_operand:QI 0 "memory_operand" "Q,S")
831 (match_operand:QI 1 "immediate_operand" "n,n")))]
07893d4f 832 "s390_match_ccmode (insn, CCUmode)"
d3632d41 833 "@
d40c829f
UW
834 cli\t%0,%b1
835 cliy\t%0,%b1"
d3632d41 836 [(set_attr "op_type" "SI,SIY")])
9db1d521 837
07893d4f
UW
838(define_insn "*cmpdi_ccu_mem"
839 [(set (reg 33)
ccfc6cc8
UW
840 (compare (match_operand:DI 0 "s_operand" "Q")
841 (match_operand:DI 1 "s_imm_operand" "Q")))]
07893d4f 842 "s390_match_ccmode(insn, CCUmode)"
d40c829f 843 "clc\t%O0(8,%R0),%1"
077dab3b 844 [(set_attr "op_type" "SS")])
07893d4f
UW
845
846(define_insn "*cmpsi_ccu_mem"
847 [(set (reg 33)
ccfc6cc8
UW
848 (compare (match_operand:SI 0 "s_operand" "Q")
849 (match_operand:SI 1 "s_imm_operand" "Q")))]
07893d4f 850 "s390_match_ccmode(insn, CCUmode)"
d40c829f 851 "clc\t%O0(4,%R0),%1"
077dab3b 852 [(set_attr "op_type" "SS")])
07893d4f
UW
853
854(define_insn "*cmphi_ccu_mem"
855 [(set (reg 33)
ccfc6cc8
UW
856 (compare (match_operand:HI 0 "s_operand" "Q")
857 (match_operand:HI 1 "s_imm_operand" "Q")))]
07893d4f 858 "s390_match_ccmode(insn, CCUmode)"
d40c829f 859 "clc\t%O0(2,%R0),%1"
077dab3b 860 [(set_attr "op_type" "SS")])
07893d4f 861
9db1d521
HP
862(define_insn "*cmpqi_ccu_mem"
863 [(set (reg 33)
ccfc6cc8
UW
864 (compare (match_operand:QI 0 "s_operand" "Q")
865 (match_operand:QI 1 "s_imm_operand" "Q")))]
9db1d521 866 "s390_match_ccmode(insn, CCUmode)"
d40c829f 867 "clc\t%O0(1,%R0),%1"
077dab3b 868 [(set_attr "op_type" "SS")])
9db1d521
HP
869
870
871; DF instructions
872
873(define_insn "*cmpdf_ccs_0"
874 [(set (reg 33)
875 (compare (match_operand:DF 0 "register_operand" "f")
876 (match_operand:DF 1 "const0_operand" "")))]
877 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 878 "ltdbr\t%0,%0"
077dab3b
HP
879 [(set_attr "op_type" "RRE")
880 (set_attr "type" "fsimpd")])
9db1d521
HP
881
882(define_insn "*cmpdf_ccs_0_ibm"
883 [(set (reg 33)
884 (compare (match_operand:DF 0 "register_operand" "f")
885 (match_operand:DF 1 "const0_operand" "")))]
886 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
d40c829f 887 "ltdr\t%0,%0"
077dab3b
HP
888 [(set_attr "op_type" "RR")
889 (set_attr "type" "fsimpd")])
9db1d521
HP
890
891(define_insn "*cmpdf_ccs"
892 [(set (reg 33)
893 (compare (match_operand:DF 0 "register_operand" "f,f")
d3632d41 894 (match_operand:DF 1 "general_operand" "f,R")))]
9db1d521
HP
895 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
896 "@
d40c829f
UW
897 cdbr\t%0,%1
898 cdb\t%0,%1"
ce50cae8 899 [(set_attr "op_type" "RRE,RXE")
077dab3b 900 (set_attr "type" "fsimpd")])
9db1d521
HP
901
902(define_insn "*cmpdf_ccs_ibm"
903 [(set (reg 33)
904 (compare (match_operand:DF 0 "register_operand" "f,f")
d3632d41 905 (match_operand:DF 1 "general_operand" "f,R")))]
9db1d521
HP
906 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
907 "@
d40c829f
UW
908 cdr\t%0,%1
909 cd\t%0,%1"
9db1d521 910 [(set_attr "op_type" "RR,RX")
077dab3b 911 (set_attr "type" "fsimpd")])
9db1d521
HP
912
913
914; SF instructions
915
916(define_insn "*cmpsf_ccs_0"
917 [(set (reg 33)
918 (compare (match_operand:SF 0 "register_operand" "f")
919 (match_operand:SF 1 "const0_operand" "")))]
920 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 921 "ltebr\t%0,%0"
077dab3b
HP
922 [(set_attr "op_type" "RRE")
923 (set_attr "type" "fsimps")])
9db1d521
HP
924
925(define_insn "*cmpsf_ccs_0_ibm"
926 [(set (reg 33)
927 (compare (match_operand:SF 0 "register_operand" "f")
928 (match_operand:SF 1 "const0_operand" "")))]
929 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
d40c829f 930 "lter\t%0,%0"
077dab3b
HP
931 [(set_attr "op_type" "RR")
932 (set_attr "type" "fsimps")])
9db1d521
HP
933
934(define_insn "*cmpsf_ccs"
935 [(set (reg 33)
936 (compare (match_operand:SF 0 "register_operand" "f,f")
d3632d41 937 (match_operand:SF 1 "general_operand" "f,R")))]
9db1d521
HP
938 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
939 "@
d40c829f
UW
940 cebr\t%0,%1
941 ceb\t%0,%1"
077dab3b
HP
942 [(set_attr "op_type" "RRE,RXE")
943 (set_attr "type" "fsimps")])
9db1d521
HP
944
945(define_insn "*cmpsf_ccs"
946 [(set (reg 33)
947 (compare (match_operand:SF 0 "register_operand" "f,f")
d3632d41 948 (match_operand:SF 1 "general_operand" "f,R")))]
9db1d521
HP
949 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
950 "@
d40c829f
UW
951 cer\t%0,%1
952 ce\t%0,%1"
077dab3b
HP
953 [(set_attr "op_type" "RR,RX")
954 (set_attr "type" "fsimps")])
9db1d521
HP
955
956
957;;
958;;- Move instructions.
959;;
960
961;
962; movti instruction pattern(s).
963;
964
965(define_insn "movti"
d3632d41
UW
966 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,d,o,Q")
967 (match_operand:TI 1 "general_operand" "QS,d,dKm,d,Q"))]
9db1d521 968 "TARGET_64BIT"
4023fb28 969 "@
d40c829f
UW
970 lmg\t%0,%N0,%1
971 stmg\t%1,%N1,%0
4023fb28 972 #
9b7c75b9 973 #
d40c829f 974 mvc\t%O0(16,%R0),%1"
d3632d41 975 [(set_attr "op_type" "RSY,RSY,NN,NN,SS")
fe03d631 976 (set_attr "type" "lm,stm,*,*,cs")])
4023fb28
UW
977
978(define_split
979 [(set (match_operand:TI 0 "nonimmediate_operand" "")
980 (match_operand:TI 1 "general_operand" ""))]
981 "TARGET_64BIT && reload_completed
dc65c307 982 && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
4023fb28
UW
983 [(set (match_dup 2) (match_dup 4))
984 (set (match_dup 3) (match_dup 5))]
9db1d521 985{
dc65c307
UW
986 operands[2] = operand_subword (operands[0], 0, 0, TImode);
987 operands[3] = operand_subword (operands[0], 1, 0, TImode);
988 operands[4] = operand_subword (operands[1], 0, 0, TImode);
989 operands[5] = operand_subword (operands[1], 1, 0, TImode);
990})
991
992(define_split
993 [(set (match_operand:TI 0 "nonimmediate_operand" "")
994 (match_operand:TI 1 "general_operand" ""))]
995 "TARGET_64BIT && reload_completed
996 && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
997 [(set (match_dup 2) (match_dup 4))
998 (set (match_dup 3) (match_dup 5))]
999{
1000 operands[2] = operand_subword (operands[0], 1, 0, TImode);
1001 operands[3] = operand_subword (operands[0], 0, 0, TImode);
1002 operands[4] = operand_subword (operands[1], 1, 0, TImode);
1003 operands[5] = operand_subword (operands[1], 0, 0, TImode);
1004})
4023fb28
UW
1005
1006(define_split
1007 [(set (match_operand:TI 0 "register_operand" "")
1008 (match_operand:TI 1 "memory_operand" ""))]
1009 "TARGET_64BIT && reload_completed
1010 && !s_operand (operands[1], VOIDmode)"
a41c6c53 1011 [(set (match_dup 0) (match_dup 1))]
a41c6c53
UW
1012{
1013 rtx addr = operand_subword (operands[0], 1, 0, TImode);
1014 s390_load_address (addr, XEXP (operands[1], 0));
1015 operands[1] = replace_equiv_address (operands[1], addr);
dc65c307
UW
1016})
1017
1018(define_expand "reload_outti"
1019 [(parallel [(match_operand:TI 0 "memory_operand" "")
1020 (match_operand:TI 1 "register_operand" "d")
1021 (match_operand:DI 2 "register_operand" "=&a")])]
1022 "TARGET_64BIT"
1023{
1024 s390_load_address (operands[2], XEXP (operands[0], 0));
1025 operands[0] = replace_equiv_address (operands[0], operands[2]);
1026 emit_move_insn (operands[0], operands[1]);
1027 DONE;
1028})
9db1d521
HP
1029
1030;
1031; movdi instruction pattern(s).
1032;
1033
9db1d521
HP
1034(define_expand "movdi"
1035 [(set (match_operand:DI 0 "general_operand" "")
1036 (match_operand:DI 1 "general_operand" ""))]
1037 ""
9db1d521 1038{
fd3cd001
UW
1039 /* Handle symbolic constants. */
1040 if (TARGET_64BIT && SYMBOLIC_CONST (operands[1]))
1041 emit_symbolic_move (operands);
4023fb28
UW
1042
1043 /* During and after reload, we need to force constants
1044 to the literal pool ourselves, if necessary. */
1045 if ((reload_in_progress || reload_completed)
c7453384 1046 && CONSTANT_P (operands[1])
4023fb28 1047 && (!legitimate_reload_constant_p (operands[1])
8e509cf9 1048 || FP_REG_P (operands[0])))
4023fb28 1049 operands[1] = force_const_mem (DImode, operands[1]);
10bbf137 1050})
9db1d521 1051
4023fb28
UW
1052(define_insn "*movdi_larl"
1053 [(set (match_operand:DI 0 "register_operand" "=d")
1054 (match_operand:DI 1 "larl_operand" "X"))]
1055 "TARGET_64BIT
8e509cf9 1056 && !FP_REG_P (operands[0])"
d40c829f 1057 "larl\t%0,%1"
4023fb28 1058 [(set_attr "op_type" "RIL")
077dab3b 1059 (set_attr "type" "larl")])
4023fb28 1060
9db1d521 1061(define_insn "*movdi_64"
f19a9af7
AK
1062 [(set (match_operand:DI 0 "nonimmediate_operand"
1063 "=d,d,d,d,d,d,d,d,m,!*f,!*f,!*f,!R,!T,?Q")
1064 (match_operand:DI 1 "general_operand"
1065 "K,N0HD0,N1HD0,N2HD0,N3HD0,L,d,m,d,*f,R,T,*f,*f,?Q"))]
9db1d521
HP
1066 "TARGET_64BIT"
1067 "@
f19a9af7
AK
1068 lghi\t%0,%h1
1069 llihh\t%0,%i1
1070 llihl\t%0,%i1
1071 llilh\t%0,%i1
1072 llill\t%0,%i1
1073 lay\t%0,%a1
d40c829f
UW
1074 lgr\t%0,%1
1075 lg\t%0,%1
1076 stg\t%1,%0
1077 ldr\t%0,%1
1078 ld\t%0,%1
1079 ldy\t%0,%1
1080 std\t%1,%0
1081 stdy\t%1,%0
1082 mvc\t%O0(8,%R0),%1"
f19a9af7
AK
1083 [(set_attr "op_type" "RI,RI,RI,RI,RI,RXY,RRE,RXY,RXY,RR,RX,RXY,RX,RXY,SS")
1084 (set_attr "type" "*,*,*,*,*,la,lr,load,store,floadd,floadd,floadd,
1085 fstored,fstored,cs")])
9db1d521
HP
1086
1087(define_insn "*movdi_31"
d3632d41
UW
1088 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,Q,d,o,!*f,!*f,!*f,!R,!T,Q")
1089 (match_operand:DI 1 "general_operand" "Q,d,dKm,d,*f,R,T,*f,*f,Q"))]
9db1d521 1090 "!TARGET_64BIT"
4023fb28 1091 "@
d40c829f
UW
1092 lm\t%0,%N0,%1
1093 stm\t%1,%N1,%0
4023fb28
UW
1094 #
1095 #
d40c829f
UW
1096 ldr\t%0,%1
1097 ld\t%0,%1
1098 ldy\t%0,%1
1099 std\t%1,%0
1100 stdy\t%1,%0
1101 mvc\t%O0(8,%R0),%1"
d3632d41
UW
1102 [(set_attr "op_type" "RS,RS,NN,NN,RR,RX,RXY,RX,RXY,SS")
1103 (set_attr "type" "lm,stm,*,*,floadd,floadd,floadd,fstored,fstored,cs")])
4023fb28
UW
1104
1105(define_split
1106 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1107 (match_operand:DI 1 "general_operand" ""))]
1108 "!TARGET_64BIT && reload_completed
dc65c307 1109 && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
4023fb28
UW
1110 [(set (match_dup 2) (match_dup 4))
1111 (set (match_dup 3) (match_dup 5))]
9db1d521 1112{
dc65c307
UW
1113 operands[2] = operand_subword (operands[0], 0, 0, DImode);
1114 operands[3] = operand_subword (operands[0], 1, 0, DImode);
1115 operands[4] = operand_subword (operands[1], 0, 0, DImode);
1116 operands[5] = operand_subword (operands[1], 1, 0, DImode);
1117})
1118
1119(define_split
1120 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1121 (match_operand:DI 1 "general_operand" ""))]
1122 "!TARGET_64BIT && reload_completed
1123 && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
1124 [(set (match_dup 2) (match_dup 4))
1125 (set (match_dup 3) (match_dup 5))]
1126{
1127 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1128 operands[3] = operand_subword (operands[0], 0, 0, DImode);
1129 operands[4] = operand_subword (operands[1], 1, 0, DImode);
1130 operands[5] = operand_subword (operands[1], 0, 0, DImode);
1131})
9db1d521 1132
4023fb28
UW
1133(define_split
1134 [(set (match_operand:DI 0 "register_operand" "")
1135 (match_operand:DI 1 "memory_operand" ""))]
1136 "!TARGET_64BIT && reload_completed
8e509cf9 1137 && !FP_REG_P (operands[0])
4023fb28 1138 && !s_operand (operands[1], VOIDmode)"
a41c6c53 1139 [(set (match_dup 0) (match_dup 1))]
a41c6c53
UW
1140{
1141 rtx addr = operand_subword (operands[0], 1, 0, DImode);
1142 s390_load_address (addr, XEXP (operands[1], 0));
1143 operands[1] = replace_equiv_address (operands[1], addr);
dc65c307
UW
1144})
1145
1146(define_expand "reload_outdi"
1147 [(parallel [(match_operand:DI 0 "memory_operand" "")
1148 (match_operand:DI 1 "register_operand" "d")
1149 (match_operand:SI 2 "register_operand" "=&a")])]
1150 "!TARGET_64BIT"
1151{
1152 s390_load_address (operands[2], XEXP (operands[0], 0));
1153 operands[0] = replace_equiv_address (operands[0], operands[2]);
1154 emit_move_insn (operands[0], operands[1]);
1155 DONE;
1156})
9db1d521 1157
84817c5d
UW
1158(define_peephole2
1159 [(set (match_operand:DI 0 "register_operand" "")
1160 (mem:DI (match_operand 1 "address_operand" "")))]
1161 "TARGET_64BIT
1162 && !FP_REG_P (operands[0])
1163 && GET_CODE (operands[1]) == SYMBOL_REF
1164 && CONSTANT_POOL_ADDRESS_P (operands[1])
1165 && get_pool_mode (operands[1]) == DImode
1166 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1167 [(set (match_dup 0) (match_dup 2))]
1168 "operands[2] = get_pool_constant (operands[1]);")
1169
9db1d521
HP
1170;
1171; movsi instruction pattern(s).
1172;
1173
9db1d521
HP
1174(define_expand "movsi"
1175 [(set (match_operand:SI 0 "general_operand" "")
1176 (match_operand:SI 1 "general_operand" ""))]
1177 ""
9db1d521 1178{
fd3cd001
UW
1179 /* Handle symbolic constants. */
1180 if (!TARGET_64BIT && SYMBOLIC_CONST (operands[1]))
1181 emit_symbolic_move (operands);
ba956982 1182
c7453384
EC
1183 /* expr.c tries to load an effective address using
1184 force_reg. This fails because we don't have a
ba956982
UW
1185 generic load_address pattern. Convert the move
1186 to a proper arithmetic operation instead, unless
1187 it is guaranteed to be OK. */
1188 if (GET_CODE (operands[1]) == PLUS
1189 && !legitimate_la_operand_p (operands[1]))
1190 {
1191 operands[1] = force_operand (operands[1], operands[0]);
1192 if (operands[1] == operands[0])
1193 DONE;
1194 }
4023fb28
UW
1195
1196 /* During and after reload, we need to force constants
1197 to the literal pool ourselves, if necessary. */
1198 if ((reload_in_progress || reload_completed)
c7453384 1199 && CONSTANT_P (operands[1])
4023fb28 1200 && (!legitimate_reload_constant_p (operands[1])
8e509cf9 1201 || FP_REG_P (operands[0])))
4023fb28 1202 operands[1] = force_const_mem (SImode, operands[1]);
10bbf137 1203})
9db1d521 1204
9e8327e3
UW
1205(define_insn "*movsi_larl"
1206 [(set (match_operand:SI 0 "register_operand" "=d")
1207 (match_operand:SI 1 "larl_operand" "X"))]
1208 "!TARGET_64BIT && TARGET_CPU_ZARCH
1209 && !FP_REG_P (operands[0])"
1210 "larl\t%0,%1"
1211 [(set_attr "op_type" "RIL")
1212 (set_attr "type" "larl")])
1213
f19a9af7
AK
1214(define_insn "*movsi_zarch"
1215 [(set (match_operand:SI 0 "nonimmediate_operand"
1216 "=d,d,d,d,d,d,d,R,T,!*f,!*f,!*f,!R,!T,?Q")
1217 (match_operand:SI 1 "general_operand"
1218 "K,N0HS0,N1HS0,L,d,R,T,d,d,*f,R,T,*f,*f,?Q"))]
1219 "TARGET_ZARCH"
9db1d521 1220 "@
f19a9af7
AK
1221 lhi\t%0,%h1
1222 llilh\t%0,%i1
1223 llill\t%0,%i1
1224 lay\t%0,%a1
d40c829f
UW
1225 lr\t%0,%1
1226 l\t%0,%1
1227 ly\t%0,%1
1228 st\t%1,%0
1229 sty\t%1,%0
1230 ler\t%0,%1
1231 le\t%0,%1
1232 ley\t%0,%1
1233 ste\t%1,%0
1234 stey\t%1,%0
1235 mvc\t%O0(4,%R0),%1"
f19a9af7
AK
1236 [(set_attr "op_type" "RI,RI,RI,RXY,RR,RX,RXY,RX,RXY,RR,RX,RXY,RX,RXY,SS")
1237 (set_attr "type" "*,*,*,la,lr,load,load,store,store,floads,floads,floads,fstores,fstores,cs")])
1238
1239(define_insn "*movsi_esa"
1240 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!R,?Q")
1241 (match_operand:SI 1 "general_operand" "K,d,R,d,*f,R,*f,?Q"))]
1242 "!TARGET_ZARCH"
1243 "@
1244 lhi\t%0,%h1
1245 lr\t%0,%1
1246 l\t%0,%1
1247 st\t%1,%0
1248 ler\t%0,%1
1249 le\t%0,%1
1250 ste\t%1,%0
1251 mvc\t%O0(4,%R0),%1"
1252 [(set_attr "op_type" "RI,RR,RX,RX,RR,RX,RX,SS")
1253 (set_attr "type" "*,lr,load,store,floads,floads,fstores,cs")])
9db1d521 1254
84817c5d
UW
1255(define_peephole2
1256 [(set (match_operand:SI 0 "register_operand" "")
1257 (mem:SI (match_operand 1 "address_operand" "")))]
1258 "!FP_REG_P (operands[0])
1259 && GET_CODE (operands[1]) == SYMBOL_REF
1260 && CONSTANT_POOL_ADDRESS_P (operands[1])
1261 && get_pool_mode (operands[1]) == SImode
1262 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1263 [(set (match_dup 0) (match_dup 2))]
1264 "operands[2] = get_pool_constant (operands[1]);")
9db1d521
HP
1265
1266;
1267; movhi instruction pattern(s).
1268;
1269
02ed3c5e
UW
1270(define_expand "movhi"
1271 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1272 (match_operand:HI 1 "general_operand" ""))]
1273 ""
1274{
1275 /* Make it explicit that loading a register from memory
1276 always sign-extends (at least) to SImode. */
1277 if (optimize && !no_new_pseudos
1278 && register_operand (operands[0], VOIDmode)
d71a8c3b
UW
1279 && GET_CODE (operands[1]) == MEM
1280 && GET_CODE (XEXP (operands[1], 0)) != ADDRESSOF)
02ed3c5e
UW
1281 {
1282 rtx tmp = gen_reg_rtx (SImode);
1283 rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
1284 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1285 operands[1] = gen_lowpart (HImode, tmp);
1286 }
1287})
1288
1289(define_insn "*movhi"
d3632d41
UW
1290 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,R,T,?Q")
1291 (match_operand:HI 1 "general_operand" "d,n,R,T,d,d,?Q"))]
9db1d521
HP
1292 ""
1293 "@
d40c829f
UW
1294 lr\t%0,%1
1295 lhi\t%0,%h1
1296 lh\t%0,%1
1297 lhy\t%0,%1
1298 sth\t%1,%0
1299 sthy\t%1,%0
1300 mvc\t%O0(2,%R0),%1"
d3632d41
UW
1301 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SS")
1302 (set_attr "type" "lr,*,*,*,store,store,cs")])
9db1d521 1303
84817c5d
UW
1304(define_peephole2
1305 [(set (match_operand:HI 0 "register_operand" "")
1306 (mem:HI (match_operand 1 "address_operand" "")))]
1307 "GET_CODE (operands[1]) == SYMBOL_REF
1308 && CONSTANT_POOL_ADDRESS_P (operands[1])
1309 && get_pool_mode (operands[1]) == HImode
1310 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1311 [(set (match_dup 0) (match_dup 2))]
1312 "operands[2] = get_pool_constant (operands[1]);")
4023fb28 1313
9db1d521
HP
1314;
1315; movqi instruction pattern(s).
1316;
1317
02ed3c5e
UW
1318(define_expand "movqi"
1319 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1320 (match_operand:QI 1 "general_operand" ""))]
1321 ""
1322{
c19ec8f9 1323 /* On z/Architecture, zero-extending from memory to register
02ed3c5e 1324 is just as fast as a QImode load. */
c19ec8f9 1325 if (TARGET_ZARCH && optimize && !no_new_pseudos
02ed3c5e 1326 && register_operand (operands[0], VOIDmode)
d71a8c3b
UW
1327 && GET_CODE (operands[1]) == MEM
1328 && GET_CODE (XEXP (operands[1], 0)) != ADDRESSOF)
02ed3c5e 1329 {
c19ec8f9
UW
1330 rtx tmp = gen_reg_rtx (word_mode);
1331 rtx ext = gen_rtx_ZERO_EXTEND (word_mode, operands[1]);
02ed3c5e
UW
1332 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1333 operands[1] = gen_lowpart (QImode, tmp);
1334 }
1335})
4023fb28 1336
02ed3c5e 1337(define_insn "*movqi"
d3632d41
UW
1338 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q")
1339 (match_operand:QI 1 "general_operand" "d,n,R,T,d,d,n,n,?Q"))]
9db1d521
HP
1340 ""
1341 "@
d40c829f
UW
1342 lr\t%0,%1
1343 lhi\t%0,%b1
1344 ic\t%0,%1
1345 icy\t%0,%1
1346 stc\t%1,%0
1347 stcy\t%1,%0
1348 mvi\t%0,%b1
1349 mviy\t%0,%b1
1350 mvc\t%O0(1,%R0),%1"
d3632d41
UW
1351 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS")
1352 (set_attr "type" "lr,*,*,*,store,store,store,store,cs")])
9db1d521 1353
84817c5d
UW
1354(define_peephole2
1355 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1356 (mem:QI (match_operand 1 "address_operand" "")))]
1357 "GET_CODE (operands[1]) == SYMBOL_REF
1358 && CONSTANT_POOL_ADDRESS_P (operands[1])
1359 && get_pool_mode (operands[1]) == QImode
1360 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1361 [(set (match_dup 0) (match_dup 2))]
1362 "operands[2] = get_pool_constant (operands[1]);")
4023fb28 1363
9db1d521 1364;
05b9aaaa 1365; movstrictqi instruction pattern(s).
9db1d521
HP
1366;
1367
1368(define_insn "*movstrictqi"
d3632d41
UW
1369 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
1370 (match_operand:QI 1 "memory_operand" "R,T"))]
9db1d521 1371 ""
d3632d41 1372 "@
d40c829f
UW
1373 ic\t%0,%1
1374 icy\t%0,%1"
d3632d41 1375 [(set_attr "op_type" "RX,RXY")])
9db1d521
HP
1376
1377;
1378; movstricthi instruction pattern(s).
1379;
1380
1381(define_insn "*movstricthi"
d3632d41
UW
1382 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
1383 (match_operand:HI 1 "s_imm_operand" "Q,S"))
9db1d521
HP
1384 (clobber (reg:CC 33))]
1385 ""
d3632d41 1386 "@
d40c829f
UW
1387 icm\t%0,3,%1
1388 icmy\t%0,3,%1"
d3632d41 1389 [(set_attr "op_type" "RS,RSY")])
9db1d521
HP
1390
1391;
1392; movstrictsi instruction pattern(s).
1393;
1394
05b9aaaa 1395(define_insn "movstrictsi"
d3632d41
UW
1396 [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d"))
1397 (match_operand:SI 1 "general_operand" "d,R,T"))]
9db1d521
HP
1398 "TARGET_64BIT"
1399 "@
d40c829f
UW
1400 lr\t%0,%1
1401 l\t%0,%1
1402 ly\t%0,%1"
d3632d41
UW
1403 [(set_attr "op_type" "RR,RX,RXY")
1404 (set_attr "type" "lr,load,load")])
9db1d521
HP
1405
1406;
1407; movdf instruction pattern(s).
1408;
1409
1410(define_expand "movdf"
1411 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1412 (match_operand:DF 1 "general_operand" ""))]
1413 ""
9db1d521 1414{
4023fb28
UW
1415 /* During and after reload, we need to force constants
1416 to the literal pool ourselves, if necessary. */
1417 if ((reload_in_progress || reload_completed)
1418 && CONSTANT_P (operands[1]))
1419 operands[1] = force_const_mem (DFmode, operands[1]);
10bbf137 1420})
9db1d521
HP
1421
1422(define_insn "*movdf_64"
d3632d41
UW
1423 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,R,T,d,d,m,?Q")
1424 (match_operand:DF 1 "general_operand" "f,R,T,f,f,d,m,d,?Q"))]
4023fb28 1425 "TARGET_64BIT"
9db1d521 1426 "@
d40c829f
UW
1427 ldr\t%0,%1
1428 ld\t%0,%1
1429 ldy\t%0,%1
1430 std\t%1,%0
1431 stdy\t%1,%0
1432 lgr\t%0,%1
1433 lg\t%0,%1
1434 stg\t%1,%0
1435 mvc\t%O0(8,%R0),%1"
d3632d41
UW
1436 [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RRE,RXY,RXY,SS")
1437 (set_attr "type" "floadd,floadd,floadd,fstored,fstored,lr,load,store,cs")])
9db1d521
HP
1438
1439(define_insn "*movdf_31"
d3632d41
UW
1440 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,R,T,d,Q,d,o,Q")
1441 (match_operand:DF 1 "general_operand" "f,R,T,f,f,Q,d,dKm,d,Q"))]
4023fb28 1442 "!TARGET_64BIT"
9db1d521 1443 "@
d40c829f
UW
1444 ldr\t%0,%1
1445 ld\t%0,%1
1446 ldy\t%0,%1
1447 std\t%1,%0
1448 stdy\t%1,%0
1449 lm\t%0,%N0,%1
1450 stm\t%1,%N1,%0
4023fb28 1451 #
9b7c75b9 1452 #
d40c829f 1453 mvc\t%O0(8,%R0),%1"
d3632d41
UW
1454 [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RS,RS,NN,NN,SS")
1455 (set_attr "type" "floadd,floadd,floadd,fstored,fstored,lm,stm,*,*,cs")])
4023fb28
UW
1456
1457(define_split
1458 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1459 (match_operand:DF 1 "general_operand" ""))]
1460 "!TARGET_64BIT && reload_completed
dc65c307 1461 && s390_split_ok_p (operands[0], operands[1], DFmode, 0)"
4023fb28
UW
1462 [(set (match_dup 2) (match_dup 4))
1463 (set (match_dup 3) (match_dup 5))]
9db1d521 1464{
dc65c307
UW
1465 operands[2] = operand_subword (operands[0], 0, 0, DFmode);
1466 operands[3] = operand_subword (operands[0], 1, 0, DFmode);
1467 operands[4] = operand_subword (operands[1], 0, 0, DFmode);
1468 operands[5] = operand_subword (operands[1], 1, 0, DFmode);
1469})
1470
1471(define_split
1472 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1473 (match_operand:DF 1 "general_operand" ""))]
1474 "!TARGET_64BIT && reload_completed
1475 && s390_split_ok_p (operands[0], operands[1], DFmode, 1)"
1476 [(set (match_dup 2) (match_dup 4))
1477 (set (match_dup 3) (match_dup 5))]
1478{
1479 operands[2] = operand_subword (operands[0], 1, 0, DFmode);
1480 operands[3] = operand_subword (operands[0], 0, 0, DFmode);
1481 operands[4] = operand_subword (operands[1], 1, 0, DFmode);
1482 operands[5] = operand_subword (operands[1], 0, 0, DFmode);
1483})
9db1d521 1484
4023fb28
UW
1485(define_split
1486 [(set (match_operand:DF 0 "register_operand" "")
1487 (match_operand:DF 1 "memory_operand" ""))]
1488 "!TARGET_64BIT && reload_completed
8e509cf9 1489 && !FP_REG_P (operands[0])
4023fb28 1490 && !s_operand (operands[1], VOIDmode)"
a41c6c53 1491 [(set (match_dup 0) (match_dup 1))]
a41c6c53
UW
1492{
1493 rtx addr = operand_subword (operands[0], 1, 0, DFmode);
1494 s390_load_address (addr, XEXP (operands[1], 0));
1495 operands[1] = replace_equiv_address (operands[1], addr);
dc65c307
UW
1496})
1497
1498(define_expand "reload_outdf"
1499 [(parallel [(match_operand:DF 0 "memory_operand" "")
1500 (match_operand:DF 1 "register_operand" "d")
1501 (match_operand:SI 2 "register_operand" "=&a")])]
1502 "!TARGET_64BIT"
1503{
1504 s390_load_address (operands[2], XEXP (operands[0], 0));
1505 operands[0] = replace_equiv_address (operands[0], operands[2]);
1506 emit_move_insn (operands[0], operands[1]);
1507 DONE;
1508})
9db1d521
HP
1509
1510;
1511; movsf instruction pattern(s).
1512;
1513
1514(define_expand "movsf"
1515 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1516 (match_operand:SF 1 "general_operand" ""))]
1517 ""
9db1d521 1518{
4023fb28
UW
1519 /* During and after reload, we need to force constants
1520 to the literal pool ourselves, if necessary. */
1521 if ((reload_in_progress || reload_completed)
1522 && CONSTANT_P (operands[1]))
1523 operands[1] = force_const_mem (SFmode, operands[1]);
10bbf137 1524})
9db1d521 1525
4023fb28 1526(define_insn "*movsf"
d3632d41
UW
1527 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,R,T,d,d,d,R,T,?Q")
1528 (match_operand:SF 1 "general_operand" "f,R,T,f,f,d,R,T,d,d,?Q"))]
4023fb28 1529 ""
9db1d521 1530 "@
d40c829f
UW
1531 ler\t%0,%1
1532 le\t%0,%1
1533 ley\t%0,%1
1534 ste\t%1,%0
1535 stey\t%1,%0
1536 lr\t%0,%1
1537 l\t%0,%1
1538 ly\t%0,%1
1539 st\t%1,%0
1540 sty\t%1,%0
1541 mvc\t%O0(4,%R0),%1"
d3632d41
UW
1542 [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RR,RX,RXY,RX,RXY,SS")
1543 (set_attr "type" "floads,floads,floads,fstores,fstores,lr,load,load,store,store,cs")])
4023fb28 1544
9db1d521
HP
1545;
1546; load_multiple pattern(s).
1547;
1548
1549(define_expand "load_multiple"
1550 [(match_par_dup 3 [(set (match_operand 0 "" "")
1551 (match_operand 1 "" ""))
1552 (use (match_operand 2 "" ""))])]
1553 ""
9db1d521 1554{
c19ec8f9 1555 enum machine_mode mode;
9db1d521
HP
1556 int regno;
1557 int count;
1558 rtx from;
4023fb28 1559 int i, off;
9db1d521
HP
1560
1561 /* Support only loading a constant number of fixed-point registers from
1562 memory and only bother with this if more than two */
1563 if (GET_CODE (operands[2]) != CONST_INT
4023fb28 1564 || INTVAL (operands[2]) < 2
9db1d521
HP
1565 || INTVAL (operands[2]) > 16
1566 || GET_CODE (operands[1]) != MEM
1567 || GET_CODE (operands[0]) != REG
1568 || REGNO (operands[0]) >= 16)
1569 FAIL;
1570
1571 count = INTVAL (operands[2]);
1572 regno = REGNO (operands[0]);
c19ec8f9
UW
1573 mode = GET_MODE (operands[0]);
1574 if (mode != SImode && mode != word_mode)
1575 FAIL;
9db1d521
HP
1576
1577 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
4023fb28
UW
1578 if (no_new_pseudos)
1579 {
1580 if (GET_CODE (XEXP (operands[1], 0)) == REG)
1581 {
1582 from = XEXP (operands[1], 0);
1583 off = 0;
1584 }
1585 else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
1586 && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
1587 && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
1588 {
1589 from = XEXP (XEXP (operands[1], 0), 0);
1590 off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
1591 }
1592 else
1593 FAIL;
1594
1595 if (from == frame_pointer_rtx || from == arg_pointer_rtx)
1596 FAIL;
1597 }
1598 else
1599 {
1600 from = force_reg (Pmode, XEXP (operands[1], 0));
1601 off = 0;
1602 }
9db1d521
HP
1603
1604 for (i = 0; i < count; i++)
1605 XVECEXP (operands[3], 0, i)
c19ec8f9
UW
1606 = gen_rtx_SET (VOIDmode, gen_rtx_REG (mode, regno + i),
1607 change_address (operands[1], mode,
1608 plus_constant (from, off + i * GET_MODE_SIZE (mode))));
10bbf137 1609})
9db1d521
HP
1610
1611(define_insn "*load_multiple_di"
1612 [(match_parallel 0 "load_multiple_operation"
1613 [(set (match_operand:DI 1 "register_operand" "=r")
d3632d41 1614 (match_operand:DI 2 "s_operand" "QS"))])]
c19ec8f9 1615 "word_mode == DImode"
9db1d521
HP
1616{
1617 int words = XVECLEN (operands[0], 0);
9db1d521 1618 operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
d40c829f 1619 return "lmg\t%1,%0,%2";
10bbf137 1620}
d3632d41 1621 [(set_attr "op_type" "RSY")
4023fb28 1622 (set_attr "type" "lm")])
9db1d521
HP
1623
1624(define_insn "*load_multiple_si"
1625 [(match_parallel 0 "load_multiple_operation"
d3632d41
UW
1626 [(set (match_operand:SI 1 "register_operand" "=r,r")
1627 (match_operand:SI 2 "s_operand" "Q,S"))])]
9db1d521 1628 ""
9db1d521
HP
1629{
1630 int words = XVECLEN (operands[0], 0);
9db1d521 1631 operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
d40c829f 1632 return which_alternative == 0 ? "lm\t%1,%0,%2" : "lmy\t%1,%0,%2";
10bbf137 1633}
d3632d41 1634 [(set_attr "op_type" "RS,RSY")
4023fb28 1635 (set_attr "type" "lm")])
9db1d521
HP
1636
1637;
c7453384 1638; store multiple pattern(s).
9db1d521
HP
1639;
1640
1641(define_expand "store_multiple"
1642 [(match_par_dup 3 [(set (match_operand 0 "" "")
1643 (match_operand 1 "" ""))
1644 (use (match_operand 2 "" ""))])]
1645 ""
9db1d521 1646{
c19ec8f9 1647 enum machine_mode mode;
9db1d521
HP
1648 int regno;
1649 int count;
1650 rtx to;
4023fb28 1651 int i, off;
9db1d521
HP
1652
1653 /* Support only storing a constant number of fixed-point registers to
1654 memory and only bother with this if more than two. */
1655 if (GET_CODE (operands[2]) != CONST_INT
4023fb28 1656 || INTVAL (operands[2]) < 2
9db1d521
HP
1657 || INTVAL (operands[2]) > 16
1658 || GET_CODE (operands[0]) != MEM
1659 || GET_CODE (operands[1]) != REG
1660 || REGNO (operands[1]) >= 16)
1661 FAIL;
1662
1663 count = INTVAL (operands[2]);
1664 regno = REGNO (operands[1]);
c19ec8f9
UW
1665 mode = GET_MODE (operands[1]);
1666 if (mode != SImode && mode != word_mode)
1667 FAIL;
9db1d521
HP
1668
1669 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
4023fb28
UW
1670
1671 if (no_new_pseudos)
1672 {
1673 if (GET_CODE (XEXP (operands[0], 0)) == REG)
1674 {
1675 to = XEXP (operands[0], 0);
1676 off = 0;
1677 }
1678 else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
1679 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
1680 && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
1681 {
1682 to = XEXP (XEXP (operands[0], 0), 0);
1683 off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
1684 }
1685 else
1686 FAIL;
1687
1688 if (to == frame_pointer_rtx || to == arg_pointer_rtx)
1689 FAIL;
1690 }
c7453384 1691 else
4023fb28
UW
1692 {
1693 to = force_reg (Pmode, XEXP (operands[0], 0));
1694 off = 0;
1695 }
9db1d521
HP
1696
1697 for (i = 0; i < count; i++)
1698 XVECEXP (operands[3], 0, i)
1699 = gen_rtx_SET (VOIDmode,
c19ec8f9
UW
1700 change_address (operands[0], mode,
1701 plus_constant (to, off + i * GET_MODE_SIZE (mode))),
1702 gen_rtx_REG (mode, regno + i));
10bbf137 1703})
9db1d521
HP
1704
1705(define_insn "*store_multiple_di"
1706 [(match_parallel 0 "store_multiple_operation"
d3632d41 1707 [(set (match_operand:DI 1 "s_operand" "=QS")
9db1d521 1708 (match_operand:DI 2 "register_operand" "r"))])]
c19ec8f9 1709 "word_mode == DImode"
9db1d521
HP
1710{
1711 int words = XVECLEN (operands[0], 0);
9db1d521 1712 operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
d40c829f 1713 return "stmg\t%2,%0,%1";
10bbf137 1714}
d3632d41 1715 [(set_attr "op_type" "RSY")
4023fb28 1716 (set_attr "type" "stm")])
9db1d521
HP
1717
1718
1719(define_insn "*store_multiple_si"
1720 [(match_parallel 0 "store_multiple_operation"
d3632d41
UW
1721 [(set (match_operand:SI 1 "s_operand" "=Q,S")
1722 (match_operand:SI 2 "register_operand" "r,r"))])]
9db1d521 1723 ""
9db1d521
HP
1724{
1725 int words = XVECLEN (operands[0], 0);
9db1d521 1726 operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
d40c829f 1727 return which_alternative == 0 ? "stm\t%2,%0,%1" : "stmy\t%2,%0,%1";
10bbf137 1728}
d3632d41 1729 [(set_attr "op_type" "RS,RSY")
4023fb28 1730 (set_attr "type" "stm")])
9db1d521
HP
1731
1732;;
1733;; String instructions.
1734;;
1735
1736;
a41c6c53 1737; movstrM instruction pattern(s).
9db1d521
HP
1738;
1739
1740(define_expand "movstrdi"
a41c6c53
UW
1741 [(set (match_operand:BLK 0 "memory_operand" "")
1742 (match_operand:BLK 1 "memory_operand" ""))
1743 (use (match_operand:DI 2 "general_operand" ""))
1744 (match_operand 3 "" "")]
1745 "TARGET_64BIT"
1746 "s390_expand_movstr (operands[0], operands[1], operands[2]); DONE;")
9db1d521
HP
1747
1748(define_expand "movstrsi"
a41c6c53
UW
1749 [(set (match_operand:BLK 0 "memory_operand" "")
1750 (match_operand:BLK 1 "memory_operand" ""))
1751 (use (match_operand:SI 2 "general_operand" ""))
1752 (match_operand 3 "" "")]
1753 ""
1754 "s390_expand_movstr (operands[0], operands[1], operands[2]); DONE;")
9db1d521 1755
ecbe845e
UW
1756; Move a block that is up to 256 bytes in length.
1757; The block length is taken as (operands[2] % 256) + 1.
9db1d521 1758
b9404c99
UW
1759(define_expand "movstr_short"
1760 [(parallel
1761 [(set (match_operand:BLK 0 "memory_operand" "")
1762 (match_operand:BLK 1 "memory_operand" ""))
1763 (use (match_operand 2 "nonmemory_operand" ""))
1764 (clobber (match_dup 3))])]
1765 ""
1766 "operands[3] = gen_rtx_SCRATCH (Pmode);")
ecbe845e 1767
b9404c99 1768(define_insn "*movstr_short"
a41c6c53
UW
1769 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q")
1770 (match_operand:BLK 1 "memory_operand" "Q,Q"))
b9404c99
UW
1771 (use (match_operand 2 "nonmemory_operand" "n,a"))
1772 (clobber (match_scratch 3 "=X,&a"))]
1773 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
1774 && GET_MODE (operands[3]) == Pmode"
ecbe845e
UW
1775{
1776 switch (which_alternative)
1777 {
1778 case 0:
d40c829f 1779 return "mvc\t%O0(%b2+1,%R0),%1";
ecbe845e
UW
1780
1781 case 1:
d40c829f
UW
1782 output_asm_insn ("bras\t%3,.+10", operands);
1783 output_asm_insn ("mvc\t%O0(1,%R0),%1", operands);
1784 return "ex\t%2,0(%3)";
9db1d521 1785
ecbe845e
UW
1786 default:
1787 abort ();
1788 }
10bbf137 1789}
ecbe845e 1790 [(set_attr "op_type" "SS,NN")
a41c6c53 1791 (set_attr "type" "cs,cs")
077dab3b 1792 (set_attr "atype" "*,agen")
ecbe845e 1793 (set_attr "length" "*,14")])
9db1d521 1794
a41c6c53 1795; Move a block of arbitrary length.
9db1d521 1796
b9404c99
UW
1797(define_expand "movstr_long"
1798 [(parallel
1799 [(clobber (match_dup 2))
1800 (clobber (match_dup 3))
1801 (set (match_operand:BLK 0 "memory_operand" "")
1802 (match_operand:BLK 1 "memory_operand" ""))
1803 (use (match_operand 2 "general_operand" ""))
1804 (use (match_dup 3))
1805 (clobber (reg:CC 33))])]
1806 ""
1807{
1808 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
1809 rtx reg0 = gen_reg_rtx (dword_mode);
1810 rtx reg1 = gen_reg_rtx (dword_mode);
1811 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
1812 rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
1813 rtx len0 = gen_lowpart (Pmode, reg0);
1814 rtx len1 = gen_lowpart (Pmode, reg1);
1815
1816 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
1817 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
1818 emit_move_insn (len0, operands[2]);
1819
1820 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
1821 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
1822 emit_move_insn (len1, operands[2]);
1823
1824 operands[0] = replace_equiv_address_nv (operands[0], addr0);
1825 operands[1] = replace_equiv_address_nv (operands[1], addr1);
1826 operands[2] = reg0;
1827 operands[3] = reg1;
1828})
1829
1830(define_insn "*movstr_long_64"
1831 [(clobber (match_operand:TI 0 "register_operand" "=d"))
1832 (clobber (match_operand:TI 1 "register_operand" "=d"))
1833 (set (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
1834 (mem:BLK (subreg:DI (match_operand:TI 3 "register_operand" "1") 0)))
1835 (use (match_dup 2))
1836 (use (match_dup 3))
9db1d521 1837 (clobber (reg:CC 33))]
9f37ccb1 1838 "TARGET_64BIT"
d40c829f 1839 "mvcle\t%0,%1,0\;jo\t.-4"
9db1d521 1840 [(set_attr "op_type" "NN")
a41c6c53 1841 (set_attr "type" "vs")
9db1d521
HP
1842 (set_attr "length" "8")])
1843
b9404c99
UW
1844(define_insn "*movstr_long_31"
1845 [(clobber (match_operand:DI 0 "register_operand" "=d"))
1846 (clobber (match_operand:DI 1 "register_operand" "=d"))
1847 (set (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
1848 (mem:BLK (subreg:SI (match_operand:DI 3 "register_operand" "1") 0)))
1849 (use (match_dup 2))
1850 (use (match_dup 3))
9db1d521 1851 (clobber (reg:CC 33))]
9f37ccb1 1852 "!TARGET_64BIT"
d40c829f 1853 "mvcle\t%0,%1,0\;jo\t.-4"
a41c6c53
UW
1854 [(set_attr "op_type" "NN")
1855 (set_attr "type" "vs")
a41c6c53 1856 (set_attr "length" "8")])
9db1d521
HP
1857
1858;
a41c6c53 1859; clrstrM instruction pattern(s).
9db1d521
HP
1860;
1861
1862(define_expand "clrstrdi"
a41c6c53 1863 [(set (match_operand:BLK 0 "memory_operand" "")
9db1d521
HP
1864 (const_int 0))
1865 (use (match_operand:DI 1 "general_operand" ""))
1866 (match_operand 2 "" "")]
1867 "TARGET_64BIT"
a41c6c53 1868 "s390_expand_clrstr (operands[0], operands[1]); DONE;")
9db1d521
HP
1869
1870(define_expand "clrstrsi"
a41c6c53 1871 [(set (match_operand:BLK 0 "memory_operand" "")
9db1d521
HP
1872 (const_int 0))
1873 (use (match_operand:SI 1 "general_operand" ""))
1874 (match_operand 2 "" "")]
a41c6c53
UW
1875 ""
1876 "s390_expand_clrstr (operands[0], operands[1]); DONE;")
9db1d521 1877
a41c6c53 1878; Clear a block that is up to 256 bytes in length.
b9404c99
UW
1879; The block length is taken as (operands[1] % 256) + 1.
1880
1881(define_expand "clrstr_short"
1882 [(parallel
1883 [(set (match_operand:BLK 0 "memory_operand" "")
1884 (const_int 0))
1885 (use (match_operand 1 "nonmemory_operand" ""))
1886 (clobber (match_dup 2))
1887 (clobber (reg:CC 33))])]
1888 ""
1889 "operands[2] = gen_rtx_SCRATCH (Pmode);")
9db1d521 1890
b9404c99 1891(define_insn "*clrstr_short"
a41c6c53
UW
1892 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q")
1893 (const_int 0))
b9404c99
UW
1894 (use (match_operand 1 "nonmemory_operand" "n,a"))
1895 (clobber (match_scratch 2 "=X,&a"))
a41c6c53 1896 (clobber (reg:CC 33))]
b9404c99
UW
1897 "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)
1898 && GET_MODE (operands[2]) == Pmode"
a41c6c53
UW
1899{
1900 switch (which_alternative)
1901 {
1902 case 0:
d40c829f 1903 return "xc\t%O0(%b1+1,%R0),%0";
9db1d521 1904
a41c6c53 1905 case 1:
d40c829f
UW
1906 output_asm_insn ("bras\t%2,.+10", operands);
1907 output_asm_insn ("xc\t%O0(1,%R0),%0", operands);
1908 return "ex\t%1,0(%2)";
9db1d521 1909
a41c6c53
UW
1910 default:
1911 abort ();
1912 }
10bbf137 1913}
a41c6c53
UW
1914 [(set_attr "op_type" "SS,NN")
1915 (set_attr "type" "cs,cs")
077dab3b 1916 (set_attr "atype" "*,agen")
a41c6c53 1917 (set_attr "length" "*,14")])
9db1d521 1918
b9404c99
UW
1919; Clear a block of arbitrary length.
1920
1921(define_expand "clrstr_long"
1922 [(parallel
1923 [(clobber (match_dup 1))
1924 (set (match_operand:BLK 0 "memory_operand" "")
1925 (const_int 0))
1926 (use (match_operand 1 "general_operand" ""))
1927 (use (match_dup 2))
1928 (clobber (reg:CC 33))])]
1929 ""
a41c6c53 1930{
b9404c99
UW
1931 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
1932 rtx reg0 = gen_reg_rtx (dword_mode);
1933 rtx reg1 = gen_reg_rtx (dword_mode);
1934 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
1935 rtx len0 = gen_lowpart (Pmode, reg0);
9db1d521 1936
b9404c99
UW
1937 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
1938 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
1939 emit_move_insn (len0, operands[1]);
9db1d521 1940
b9404c99 1941 emit_move_insn (reg1, const0_rtx);
a41c6c53 1942
b9404c99
UW
1943 operands[0] = replace_equiv_address_nv (operands[0], addr0);
1944 operands[1] = reg0;
1945 operands[2] = reg1;
1946})
a41c6c53 1947
b9404c99
UW
1948(define_insn "*clrstr_long_64"
1949 [(clobber (match_operand:TI 0 "register_operand" "=d"))
1950 (set (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
9db1d521 1951 (const_int 0))
b9404c99 1952 (use (match_dup 2))
9f37ccb1 1953 (use (match_operand:TI 1 "register_operand" "d"))
9db1d521
HP
1954 (clobber (reg:CC 33))]
1955 "TARGET_64BIT"
d40c829f 1956 "mvcle\t%0,%1,0\;jo\t.-4"
9db1d521 1957 [(set_attr "op_type" "NN")
4023fb28 1958 (set_attr "type" "vs")
9db1d521
HP
1959 (set_attr "length" "8")])
1960
b9404c99
UW
1961(define_insn "*clrstr_long_31"
1962 [(clobber (match_operand:DI 0 "register_operand" "=d"))
1963 (set (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
9db1d521 1964 (const_int 0))
b9404c99 1965 (use (match_dup 2))
9f37ccb1 1966 (use (match_operand:DI 1 "register_operand" "d"))
9db1d521
HP
1967 (clobber (reg:CC 33))]
1968 "!TARGET_64BIT"
d40c829f 1969 "mvcle\t%0,%1,0\;jo\t.-4"
9db1d521 1970 [(set_attr "op_type" "NN")
4023fb28 1971 (set_attr "type" "vs")
9db1d521
HP
1972 (set_attr "length" "8")])
1973
1974;
358b8f01 1975; cmpmemM instruction pattern(s).
9db1d521
HP
1976;
1977
358b8f01 1978(define_expand "cmpmemdi"
a41c6c53
UW
1979 [(set (match_operand:DI 0 "register_operand" "")
1980 (compare:DI (match_operand:BLK 1 "memory_operand" "")
1981 (match_operand:BLK 2 "memory_operand" "") ) )
1982 (use (match_operand:DI 3 "general_operand" ""))
1983 (use (match_operand:DI 4 "" ""))]
1984 "TARGET_64BIT"
c7453384 1985 "s390_expand_cmpmem (operands[0], operands[1],
a41c6c53 1986 operands[2], operands[3]); DONE;")
9db1d521 1987
358b8f01 1988(define_expand "cmpmemsi"
a41c6c53
UW
1989 [(set (match_operand:SI 0 "register_operand" "")
1990 (compare:SI (match_operand:BLK 1 "memory_operand" "")
1991 (match_operand:BLK 2 "memory_operand" "") ) )
1992 (use (match_operand:SI 3 "general_operand" ""))
1993 (use (match_operand:SI 4 "" ""))]
1994 ""
c7453384 1995 "s390_expand_cmpmem (operands[0], operands[1],
a41c6c53 1996 operands[2], operands[3]); DONE;")
9db1d521 1997
a41c6c53
UW
1998; Compare a block that is up to 256 bytes in length.
1999; The block length is taken as (operands[2] % 256) + 1.
9db1d521 2000
b9404c99
UW
2001(define_expand "cmpmem_short"
2002 [(parallel
2003 [(set (reg:CCS 33)
2004 (compare:CCS (match_operand:BLK 0 "memory_operand" "")
2005 (match_operand:BLK 1 "memory_operand" "")))
2006 (use (match_operand 2 "nonmemory_operand" ""))
2007 (clobber (match_dup 3))])]
2008 ""
2009 "operands[3] = gen_rtx_SCRATCH (Pmode);")
9db1d521 2010
b9404c99 2011(define_insn "*cmpmem_short"
a41c6c53
UW
2012 [(set (reg:CCS 33)
2013 (compare:CCS (match_operand:BLK 0 "memory_operand" "=Q,Q")
2014 (match_operand:BLK 1 "memory_operand" "Q,Q")))
b9404c99
UW
2015 (use (match_operand 2 "nonmemory_operand" "n,a"))
2016 (clobber (match_scratch 3 "=X,&a"))]
2017 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2018 && GET_MODE (operands[3]) == Pmode"
9db1d521 2019{
a41c6c53 2020 switch (which_alternative)
9db1d521 2021 {
a41c6c53 2022 case 0:
d40c829f 2023 return "clc\t%O0(%b2+1,%R0),%1";
9db1d521 2024
a41c6c53 2025 case 1:
d40c829f
UW
2026 output_asm_insn ("bras\t%3,.+10", operands);
2027 output_asm_insn ("clc\t%O0(1,%R0),%1", operands);
2028 return "ex\t%2,0(%3)";
9db1d521 2029
a41c6c53
UW
2030 default:
2031 abort ();
9db1d521 2032 }
10bbf137 2033}
a41c6c53
UW
2034 [(set_attr "op_type" "SS,NN")
2035 (set_attr "type" "cs,cs")
077dab3b 2036 (set_attr "atype" "*,agen")
a41c6c53 2037 (set_attr "length" "*,14")])
9db1d521 2038
a41c6c53 2039; Compare a block of arbitrary length.
9db1d521 2040
b9404c99
UW
2041(define_expand "cmpmem_long"
2042 [(parallel
2043 [(clobber (match_dup 2))
2044 (clobber (match_dup 3))
2045 (set (reg:CCS 33)
2046 (compare:CCS (match_operand:BLK 0 "memory_operand" "")
2047 (match_operand:BLK 1 "memory_operand" "")))
2048 (use (match_operand 2 "general_operand" ""))
2049 (use (match_dup 3))])]
2050 ""
2051{
2052 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2053 rtx reg0 = gen_reg_rtx (dword_mode);
2054 rtx reg1 = gen_reg_rtx (dword_mode);
2055 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2056 rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
2057 rtx len0 = gen_lowpart (Pmode, reg0);
2058 rtx len1 = gen_lowpart (Pmode, reg1);
2059
2060 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2061 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2062 emit_move_insn (len0, operands[2]);
2063
2064 emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
2065 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2066 emit_move_insn (len1, operands[2]);
2067
2068 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2069 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2070 operands[2] = reg0;
2071 operands[3] = reg1;
2072})
2073
2074(define_insn "*cmpmem_long_64"
4023fb28
UW
2075 [(clobber (match_operand:TI 0 "register_operand" "=d"))
2076 (clobber (match_operand:TI 1 "register_operand" "=d"))
2077 (set (reg:CCS 33)
2078 (compare:CCS (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
f8766020
HP
2079 (mem:BLK (subreg:DI (match_operand:TI 3 "register_operand" "1") 0))))
2080 (use (match_dup 2))
2081 (use (match_dup 3))]
9db1d521 2082 "TARGET_64BIT"
d40c829f 2083 "clcl\t%0,%1"
9db1d521 2084 [(set_attr "op_type" "RR")
4023fb28 2085 (set_attr "type" "vs")])
9db1d521 2086
b9404c99 2087(define_insn "*cmpmem_long_31"
4023fb28
UW
2088 [(clobber (match_operand:DI 0 "register_operand" "=d"))
2089 (clobber (match_operand:DI 1 "register_operand" "=d"))
2090 (set (reg:CCS 33)
2091 (compare:CCS (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
f8766020
HP
2092 (mem:BLK (subreg:SI (match_operand:DI 3 "register_operand" "1") 0))))
2093 (use (match_dup 2))
2094 (use (match_dup 3))]
9db1d521 2095 "!TARGET_64BIT"
d40c829f 2096 "clcl\t%0,%1"
9db1d521 2097 [(set_attr "op_type" "RR")
4023fb28 2098 (set_attr "type" "vs")])
9db1d521
HP
2099
2100; Convert condition code to integer in range (-1, 0, 1)
2101
2102(define_insn "cmpint_si"
2103 [(set (match_operand:SI 0 "register_operand" "=d")
ba956982 2104 (compare:SI (reg:CCS 33) (const_int 0)))]
9db1d521 2105 ""
9db1d521 2106{
d40c829f
UW
2107 output_asm_insn ("lhi\t%0,1", operands);
2108 output_asm_insn ("jh\t.+12", operands);
2109 output_asm_insn ("jl\t.+6", operands);
2110 output_asm_insn ("sr\t%0,%0", operands);
2111 return "lcr\t%0,%0";
10bbf137 2112}
9db1d521
HP
2113 [(set_attr "op_type" "NN")
2114 (set_attr "length" "16")
f2d3c02a 2115 (set_attr "type" "other")])
9db1d521
HP
2116
2117(define_insn "cmpint_di"
2118 [(set (match_operand:DI 0 "register_operand" "=d")
ba956982 2119 (compare:DI (reg:CCS 33) (const_int 0)))]
9db1d521 2120 "TARGET_64BIT"
9db1d521 2121{
d40c829f 2122 output_asm_insn ("lghi\t%0,1", operands);
fd87a357
UW
2123 output_asm_insn ("jh\t.+16", operands);
2124 output_asm_insn ("jl\t.+8", operands);
d40c829f
UW
2125 output_asm_insn ("sgr\t%0,%0", operands);
2126 return "lcgr\t%0,%0";
10bbf137 2127}
9db1d521 2128 [(set_attr "op_type" "NN")
fd87a357 2129 (set_attr "length" "20")
f2d3c02a 2130 (set_attr "type" "other")])
9db1d521 2131
4023fb28 2132
9db1d521
HP
2133;;
2134;;- Conversion instructions.
2135;;
2136
4023fb28 2137(define_insn "*sethighqisi"
d3632d41 2138 [(set (match_operand:SI 0 "register_operand" "=d,d")
10bbf137 2139 (unspec:SI [(match_operand:QI 1 "s_operand" "Q,S")] UNSPEC_SETHIGH))
4023fb28
UW
2140 (clobber (reg:CC 33))]
2141 ""
d3632d41 2142 "@
d40c829f
UW
2143 icm\t%0,8,%1
2144 icmy\t%0,8,%1"
d3632d41 2145 [(set_attr "op_type" "RS,RSY")])
4023fb28
UW
2146
2147(define_insn "*sethighhisi"
d3632d41 2148 [(set (match_operand:SI 0 "register_operand" "=d,d")
10bbf137 2149 (unspec:SI [(match_operand:HI 1 "s_operand" "Q,S")] UNSPEC_SETHIGH))
4023fb28
UW
2150 (clobber (reg:CC 33))]
2151 ""
d3632d41 2152 "@
d40c829f
UW
2153 icm\t%0,12,%1
2154 icmy\t%0,12,%1"
d3632d41 2155 [(set_attr "op_type" "RS,RSY")])
4023fb28
UW
2156
2157(define_insn "*sethighqidi_64"
2158 [(set (match_operand:DI 0 "register_operand" "=d")
10bbf137 2159 (unspec:DI [(match_operand:QI 1 "s_operand" "QS")] UNSPEC_SETHIGH))
4023fb28
UW
2160 (clobber (reg:CC 33))]
2161 "TARGET_64BIT"
d40c829f 2162 "icmh\t%0,8,%1"
d3632d41 2163 [(set_attr "op_type" "RSY")])
4023fb28
UW
2164
2165(define_insn "*sethighqidi_31"
d3632d41 2166 [(set (match_operand:DI 0 "register_operand" "=d,d")
10bbf137 2167 (unspec:DI [(match_operand:QI 1 "s_operand" "Q,S")] UNSPEC_SETHIGH))
4023fb28
UW
2168 (clobber (reg:CC 33))]
2169 "!TARGET_64BIT"
d3632d41 2170 "@
d40c829f
UW
2171 icm\t%0,8,%1
2172 icmy\t%0,8,%1"
d3632d41 2173 [(set_attr "op_type" "RS,RSY")])
4023fb28 2174
cc7ab9b7
UW
2175(define_insn_and_split "*extractqi"
2176 [(set (match_operand:SI 0 "register_operand" "=d")
2177 (zero_extract:SI (match_operand:QI 1 "s_operand" "Q")
2178 (match_operand 2 "const_int_operand" "n")
2179 (const_int 0)))
2180 (clobber (reg:CC 33))]
2181 "!TARGET_64BIT
4023fb28 2182 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 8"
cc7ab9b7
UW
2183 "#"
2184 "&& reload_completed"
4023fb28 2185 [(parallel
10bbf137 2186 [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
4023fb28
UW
2187 (clobber (reg:CC 33))])
2188 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
4023fb28
UW
2189{
2190 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
2191 operands[1] = change_address (operands[1], QImode, 0);
10bbf137 2192}
0796c16a 2193 [(set_attr "atype" "agen")])
4023fb28 2194
cc7ab9b7
UW
2195(define_insn_and_split "*extracthi"
2196 [(set (match_operand:SI 0 "register_operand" "=d")
2197 (zero_extract:SI (match_operand:QI 1 "s_operand" "Q")
2198 (match_operand 2 "const_int_operand" "n")
2199 (const_int 0)))
2200 (clobber (reg:CC 33))]
2201 "!TARGET_64BIT
4023fb28 2202 && INTVAL (operands[2]) >= 8 && INTVAL (operands[2]) < 16"
cc7ab9b7
UW
2203 "#"
2204 "&& reload_completed"
4023fb28 2205 [(parallel
10bbf137 2206 [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
4023fb28
UW
2207 (clobber (reg:CC 33))])
2208 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
4023fb28
UW
2209{
2210 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
2211 operands[1] = change_address (operands[1], HImode, 0);
10bbf137 2212}
0796c16a 2213 [(set_attr "atype" "agen")])
4023fb28 2214
9db1d521
HP
2215;
2216; extendsidi2 instruction pattern(s).
2217;
2218
4023fb28
UW
2219(define_expand "extendsidi2"
2220 [(set (match_operand:DI 0 "register_operand" "")
2221 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
2222 ""
2223 "
2224{
2225 if (!TARGET_64BIT)
2226 {
9f37ccb1
UW
2227 emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
2228 emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
2229 emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
2230 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
4023fb28
UW
2231 DONE;
2232 }
2233}
2234")
2235
2236(define_insn "*extendsidi2"
9db1d521
HP
2237 [(set (match_operand:DI 0 "register_operand" "=d,d")
2238 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
2239 "TARGET_64BIT"
2240 "@
d40c829f
UW
2241 lgfr\t%0,%1
2242 lgf\t%0,%1"
d3632d41 2243 [(set_attr "op_type" "RRE,RXY")])
9db1d521 2244
9db1d521
HP
2245;
2246; extendhidi2 instruction pattern(s).
2247;
2248
4023fb28
UW
2249(define_expand "extendhidi2"
2250 [(set (match_operand:DI 0 "register_operand" "")
2251 (sign_extend:DI (match_operand:HI 1 "register_operand" "")))]
2252 ""
2253 "
2254{
2255 if (!TARGET_64BIT)
2256 {
2257 rtx tmp = gen_reg_rtx (SImode);
2258 emit_insn (gen_extendhisi2 (tmp, operands[1]));
2259 emit_insn (gen_extendsidi2 (operands[0], tmp));
2260 DONE;
2261 }
2262 else
2263 {
2264 operands[1] = gen_lowpart (DImode, operands[1]);
2265 emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (48)));
c7453384 2266 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (48)));
4023fb28
UW
2267 DONE;
2268 }
2269}
2270")
2271
2272(define_insn "*extendhidi2"
9db1d521 2273 [(set (match_operand:DI 0 "register_operand" "=d")
4023fb28 2274 (sign_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
9db1d521 2275 "TARGET_64BIT"
d40c829f 2276 "lgh\t%0,%1"
d3632d41 2277 [(set_attr "op_type" "RXY")])
9db1d521
HP
2278
2279;
2280; extendqidi2 instruction pattern(s).
2281;
2282
4023fb28
UW
2283(define_expand "extendqidi2"
2284 [(set (match_operand:DI 0 "register_operand" "")
2285 (sign_extend:DI (match_operand:QI 1 "register_operand" "")))]
2286 ""
2287 "
2288{
2289 if (!TARGET_64BIT)
2290 {
2291 rtx tmp = gen_reg_rtx (SImode);
2292 emit_insn (gen_extendqisi2 (tmp, operands[1]));
2293 emit_insn (gen_extendsidi2 (operands[0], tmp));
2294 DONE;
2295 }
2296 else
2297 {
2298 operands[1] = gen_lowpart (DImode, operands[1]);
2299 emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (56)));
c7453384 2300 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (56)));
4023fb28
UW
2301 DONE;
2302 }
2303}
2304")
2305
d3632d41
UW
2306(define_insn "*extendqidi2"
2307 [(set (match_operand:DI 0 "register_operand" "=d")
2308 (sign_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
2309 "TARGET_64BIT && TARGET_LONG_DISPLACEMENT"
d40c829f 2310 "lgb\t%0,%1"
d3632d41
UW
2311 [(set_attr "op_type" "RXY")])
2312
4023fb28
UW
2313(define_split
2314 [(set (match_operand:DI 0 "register_operand" "")
2315 (sign_extend:DI (match_operand:QI 1 "s_operand" "")))]
d3632d41 2316 "TARGET_64BIT && !TARGET_LONG_DISPLACEMENT && !reload_completed"
4023fb28 2317 [(parallel
10bbf137 2318 [(set (match_dup 0) (unspec:DI [(match_dup 1)] UNSPEC_SETHIGH))
4023fb28
UW
2319 (clobber (reg:CC 33))])
2320 (parallel
2321 [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 56)))
2322 (clobber (reg:CC 33))])]
2323 "")
9db1d521
HP
2324
2325;
2326; extendhisi2 instruction pattern(s).
2327;
2328
4023fb28
UW
2329(define_expand "extendhisi2"
2330 [(set (match_operand:SI 0 "register_operand" "")
2331 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
9db1d521 2332 ""
4023fb28
UW
2333 "
2334{
2335 operands[1] = gen_lowpart (SImode, operands[1]);
2336 emit_insn (gen_ashlsi3 (operands[0], operands[1], GEN_INT (16)));
c7453384 2337 emit_insn (gen_ashrsi3 (operands[0], operands[0], GEN_INT (16)));
4023fb28
UW
2338 DONE;
2339}
2340")
9db1d521 2341
4023fb28 2342(define_insn "*extendhisi2"
d3632d41
UW
2343 [(set (match_operand:SI 0 "register_operand" "=d,d")
2344 (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
4023fb28 2345 ""
d3632d41 2346 "@
d40c829f
UW
2347 lh\t%0,%1
2348 lhy\t%0,%1"
d3632d41 2349 [(set_attr "op_type" "RX,RXY")])
9db1d521
HP
2350
2351;
2352; extendqisi2 instruction pattern(s).
2353;
2354
4023fb28
UW
2355(define_expand "extendqisi2"
2356 [(set (match_operand:SI 0 "register_operand" "")
2357 (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
9db1d521 2358 ""
4023fb28
UW
2359 "
2360{
2361 operands[1] = gen_lowpart (SImode, operands[1]);
2362 emit_insn (gen_ashlsi3 (operands[0], operands[1], GEN_INT (24)));
c7453384 2363 emit_insn (gen_ashrsi3 (operands[0], operands[0], GEN_INT (24)));
4023fb28
UW
2364 DONE;
2365}
2366")
9db1d521 2367
d3632d41
UW
2368(define_insn "*extendqisi2"
2369 [(set (match_operand:SI 0 "register_operand" "=d")
2370 (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
9e8327e3 2371 "TARGET_LONG_DISPLACEMENT"
d40c829f 2372 "lb\t%0,%1"
d3632d41
UW
2373 [(set_attr "op_type" "RXY")])
2374
4023fb28
UW
2375(define_split
2376 [(set (match_operand:SI 0 "register_operand" "")
2377 (sign_extend:SI (match_operand:QI 1 "s_operand" "")))]
9e8327e3 2378 "!TARGET_LONG_DISPLACEMENT && !reload_completed"
4023fb28 2379 [(parallel
10bbf137 2380 [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
4023fb28
UW
2381 (clobber (reg:CC 33))])
2382 (parallel
2383 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 24)))
2384 (clobber (reg:CC 33))])]
2385 "")
9db1d521
HP
2386
2387;
2388; extendqihi2 instruction pattern(s).
2389;
2390
9db1d521
HP
2391
2392;
2393; zero_extendsidi2 instruction pattern(s).
2394;
2395
4023fb28
UW
2396(define_expand "zero_extendsidi2"
2397 [(set (match_operand:DI 0 "register_operand" "")
2398 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
2399 ""
2400 "
2401{
2402 if (!TARGET_64BIT)
2403 {
9f37ccb1
UW
2404 emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
2405 emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
2406 emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
4023fb28
UW
2407 DONE;
2408 }
2409}
2410")
2411
2412(define_insn "*zero_extendsidi2"
9db1d521
HP
2413 [(set (match_operand:DI 0 "register_operand" "=d,d")
2414 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
2415 "TARGET_64BIT"
2416 "@
d40c829f
UW
2417 llgfr\t%0,%1
2418 llgf\t%0,%1"
d3632d41 2419 [(set_attr "op_type" "RRE,RXY")])
9db1d521 2420
9db1d521
HP
2421;
2422; zero_extendhidi2 instruction pattern(s).
2423;
2424
4023fb28
UW
2425(define_expand "zero_extendhidi2"
2426 [(set (match_operand:DI 0 "register_operand" "")
2427 (zero_extend:DI (match_operand:HI 1 "register_operand" "")))]
2428 ""
2429 "
2430{
2431 if (!TARGET_64BIT)
2432 {
2433 rtx tmp = gen_reg_rtx (SImode);
2434 emit_insn (gen_zero_extendhisi2 (tmp, operands[1]));
2435 emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
2436 DONE;
2437 }
2438 else
2439 {
2440 operands[1] = gen_lowpart (DImode, operands[1]);
2441 emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (48)));
c7453384 2442 emit_insn (gen_lshrdi3 (operands[0], operands[0], GEN_INT (48)));
4023fb28
UW
2443 DONE;
2444 }
2445}
2446")
9db1d521 2447
4023fb28
UW
2448(define_insn "*zero_extendhidi2"
2449 [(set (match_operand:DI 0 "register_operand" "=d")
2450 (zero_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
9db1d521 2451 "TARGET_64BIT"
d40c829f 2452 "llgh\t%0,%1"
d3632d41 2453 [(set_attr "op_type" "RXY")])
9db1d521 2454
288e517f
AK
2455;
2456; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
2457;
2458
2459(define_insn "*llgt_sisi"
2460 [(set (match_operand:SI 0 "register_operand" "=d,d")
2461 (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,m")
2462 (const_int 2147483647)))]
2463 "TARGET_64BIT"
2464 "@
2465 llgtr\t%0,%1
2466 llgt\t%0,%1"
2467 [(set_attr "op_type" "RRE,RXE")])
2468
f19a9af7
AK
2469(define_split
2470 [(set (match_operand:SI 0 "register_operand" "")
2471 (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
288e517f
AK
2472 (const_int 2147483647)))
2473 (clobber (reg:CC 33))]
f19a9af7 2474 "TARGET_64BIT && reload_completed"
288e517f
AK
2475 [(set (match_dup 0)
2476 (and:SI (match_dup 1)
2477 (const_int 2147483647)))]
2478 "")
2479
2480(define_insn "*llgt_didi"
2481 [(set (match_operand:DI 0 "register_operand" "=d,d")
2482 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
2483 (const_int 2147483647)))]
2484 "TARGET_64BIT"
2485 "@
2486 llgtr\t%0,%1
2487 llgt\t%0,%N1"
2488 [(set_attr "op_type" "RRE,RXE")])
2489
f19a9af7
AK
2490(define_split
2491 [(set (match_operand:DI 0 "register_operand" "")
2492 (and:DI (match_operand:DI 1 "nonimmediate_operand" "")
288e517f
AK
2493 (const_int 2147483647)))
2494 (clobber (reg:CC 33))]
f19a9af7 2495 "TARGET_64BIT && reload_completed"
288e517f
AK
2496 [(set (match_dup 0)
2497 (and:DI (match_dup 1)
2498 (const_int 2147483647)))]
2499 "")
2500
2501(define_insn "*llgt_sidi"
2502 [(set (match_operand:DI 0 "register_operand" "=d")
2503 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0)
2504 (const_int 2147483647)))]
2505 "TARGET_64BIT"
2506 "llgt\t%0,%1"
2507 [(set_attr "op_type" "RXE")])
2508
2509(define_insn_and_split "*llgt_sidi_split"
2510 [(set (match_operand:DI 0 "register_operand" "=d")
2511 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0)
2512 (const_int 2147483647)))
2513 (clobber (reg:CC 33))]
2514 "TARGET_64BIT"
2515 "#"
2516 "&& reload_completed"
2517 [(set (match_dup 0)
2518 (and:DI (subreg:DI (match_dup 1) 0)
2519 (const_int 2147483647)))]
2520 "")
2521
9db1d521 2522;
4023fb28 2523; zero_extendqidi2 instruction pattern(s)
9db1d521
HP
2524;
2525
4023fb28
UW
2526(define_expand "zero_extendqidi2"
2527 [(set (match_operand:DI 0 "register_operand" "")
2528 (zero_extend:DI (match_operand:QI 1 "register_operand" "")))]
9db1d521
HP
2529 ""
2530 "
2531{
2532 if (!TARGET_64BIT)
2533 {
4023fb28
UW
2534 rtx tmp = gen_reg_rtx (SImode);
2535 emit_insn (gen_zero_extendqisi2 (tmp, operands[1]));
2536 emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
9db1d521
HP
2537 DONE;
2538 }
4023fb28
UW
2539 else
2540 {
2541 operands[1] = gen_lowpart (DImode, operands[1]);
2542 emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (56)));
c7453384 2543 emit_insn (gen_lshrdi3 (operands[0], operands[0], GEN_INT (56)));
4023fb28
UW
2544 DONE;
2545 }
2546}
2547")
9db1d521 2548
4023fb28
UW
2549(define_insn "*zero_extendqidi2"
2550 [(set (match_operand:DI 0 "register_operand" "=d")
2551 (zero_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
9db1d521 2552 "TARGET_64BIT"
d40c829f 2553 "llgc\t%0,%1"
d3632d41 2554 [(set_attr "op_type" "RXY")])
9db1d521
HP
2555
2556;
4023fb28 2557; zero_extendhisi2 instruction pattern(s).
9db1d521
HP
2558;
2559
4023fb28
UW
2560(define_expand "zero_extendhisi2"
2561 [(set (match_operand:SI 0 "register_operand" "")
2562 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
9db1d521 2563 ""
4023fb28
UW
2564 "
2565{
2566 operands[1] = gen_lowpart (SImode, operands[1]);
2567 emit_insn (gen_andsi3 (operands[0], operands[1], GEN_INT (0xffff)));
2568 DONE;
2569}
2570")
9db1d521 2571
4023fb28 2572(define_insn "*zero_extendhisi2_64"
9db1d521 2573 [(set (match_operand:SI 0 "register_operand" "=d")
4023fb28 2574 (zero_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
9db1d521 2575 "TARGET_64BIT"
d40c829f 2576 "llgh\t%0,%1"
d3632d41 2577 [(set_attr "op_type" "RXY")])
cc7ab9b7
UW
2578
2579(define_insn_and_split "*zero_extendhisi2_31"
2580 [(set (match_operand:SI 0 "register_operand" "=&d")
02ed3c5e 2581 (zero_extend:SI (match_operand:HI 1 "s_operand" "QS")))
cc7ab9b7
UW
2582 (clobber (reg:CC 33))]
2583 "!TARGET_64BIT"
2584 "#"
2585 "&& reload_completed"
2586 [(set (match_dup 0) (const_int 0))
2587 (parallel
2588 [(set (strict_low_part (match_dup 2)) (match_dup 1))
2589 (clobber (reg:CC 33))])]
2590 "operands[2] = gen_lowpart (HImode, operands[0]);"
0796c16a 2591 [(set_attr "atype" "agen")])
c7453384 2592
4023fb28
UW
2593;
2594; zero_extendqisi2 instruction pattern(s).
2595;
9db1d521
HP
2596
2597(define_expand "zero_extendqisi2"
2598 [(set (match_operand:SI 0 "register_operand" "")
4023fb28 2599 (zero_extend:SI (match_operand:QI 1 "register_operand" "")))]
9db1d521
HP
2600 ""
2601 "
2602{
4023fb28
UW
2603 operands[1] = gen_lowpart (SImode, operands[1]);
2604 emit_insn (gen_andsi3 (operands[0], operands[1], GEN_INT (0xff)));
2605 DONE;
2606}
2607")
9db1d521 2608
4023fb28
UW
2609(define_insn "*zero_extendqisi2_64"
2610 [(set (match_operand:SI 0 "register_operand" "=d")
2611 (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
9e8327e3 2612 "TARGET_ZARCH"
d40c829f 2613 "llgc\t%0,%1"
d3632d41 2614 [(set_attr "op_type" "RXY")])
cc7ab9b7
UW
2615
2616(define_insn_and_split "*zero_extendqisi2_31"
2617 [(set (match_operand:SI 0 "register_operand" "=&d")
2618 (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
9e8327e3 2619 "!TARGET_ZARCH"
cc7ab9b7
UW
2620 "#"
2621 "&& reload_completed"
2622 [(set (match_dup 0) (const_int 0))
2623 (set (strict_low_part (match_dup 2)) (match_dup 1))]
2624 "operands[2] = gen_lowpart (QImode, operands[0]);"
0796c16a 2625 [(set_attr "atype" "agen")])
c7453384 2626
9db1d521
HP
2627;
2628; zero_extendqihi2 instruction pattern(s).
2629;
2630
9db1d521
HP
2631(define_expand "zero_extendqihi2"
2632 [(set (match_operand:HI 0 "register_operand" "")
4023fb28 2633 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
9e8327e3 2634 "TARGET_ZARCH"
9db1d521
HP
2635 "
2636{
4023fb28
UW
2637 operands[1] = gen_lowpart (HImode, operands[1]);
2638 emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
2639 DONE;
2640}
2641")
9db1d521 2642
4023fb28 2643(define_insn "*zero_extendqihi2_64"
9db1d521 2644 [(set (match_operand:HI 0 "register_operand" "=d")
cc7ab9b7 2645 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
9e8327e3 2646 "TARGET_ZARCH"
d40c829f 2647 "llgc\t%0,%1"
d3632d41 2648 [(set_attr "op_type" "RXY")])
9db1d521 2649
cc7ab9b7
UW
2650(define_insn_and_split "*zero_extendqihi2_31"
2651 [(set (match_operand:HI 0 "register_operand" "=&d")
2652 (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
9e8327e3 2653 "!TARGET_ZARCH"
cc7ab9b7
UW
2654 "#"
2655 "&& reload_completed"
2656 [(set (match_dup 0) (const_int 0))
2657 (set (strict_low_part (match_dup 2)) (match_dup 1))]
2658 "operands[2] = gen_lowpart (QImode, operands[0]);"
0796c16a 2659 [(set_attr "atype" "agen")])
cc7ab9b7
UW
2660
2661
9db1d521
HP
2662;
2663; fixuns_truncdfdi2 and fix_truncdfsi2 instruction pattern(s).
2664;
2665
2666(define_expand "fixuns_truncdfdi2"
2667 [(set (match_operand:DI 0 "register_operand" "")
2668 (unsigned_fix:DI (match_operand:DF 1 "register_operand" "")))]
2669 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
9db1d521
HP
2670{
2671 rtx label1 = gen_label_rtx ();
2672 rtx label2 = gen_label_rtx ();
2673 rtx temp = gen_reg_rtx (DFmode);
2674 operands[1] = force_reg (DFmode, operands[1]);
2675
c7453384 2676 emit_insn (gen_cmpdf (operands[1],
4023fb28 2677 CONST_DOUBLE_FROM_REAL_VALUE (
10bbf137 2678 REAL_VALUE_ATOF ("9223372036854775808.0", DFmode), DFmode)));
9db1d521 2679 emit_jump_insn (gen_blt (label1));
4023fb28
UW
2680 emit_insn (gen_subdf3 (temp, operands[1],
2681 CONST_DOUBLE_FROM_REAL_VALUE (
10bbf137 2682 REAL_VALUE_ATOF ("18446744073709551616.0", DFmode), DFmode)));
9db1d521 2683 emit_insn (gen_fix_truncdfdi2_ieee (operands[0], temp, GEN_INT(7)));
f314b9b1 2684 emit_jump (label2);
9db1d521
HP
2685
2686 emit_label (label1);
2687 emit_insn (gen_fix_truncdfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2688 emit_label (label2);
2689 DONE;
10bbf137 2690})
9db1d521
HP
2691
2692(define_expand "fix_truncdfdi2"
2693 [(set (match_operand:DI 0 "register_operand" "")
2694 (fix:DI (match_operand:DF 1 "nonimmediate_operand" "")))]
2695 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
9db1d521
HP
2696{
2697 operands[1] = force_reg (DFmode, operands[1]);
2698 emit_insn (gen_fix_truncdfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2699 DONE;
10bbf137 2700})
9db1d521
HP
2701
2702(define_insn "fix_truncdfdi2_ieee"
2703 [(set (match_operand:DI 0 "register_operand" "=d")
2704 (fix:DI (match_operand:DF 1 "register_operand" "f")))
10bbf137 2705 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
9db1d521
HP
2706 (clobber (reg:CC 33))]
2707 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 2708 "cgdbr\t%0,%h2,%1"
9db1d521 2709 [(set_attr "op_type" "RRE")
077dab3b 2710 (set_attr "type" "ftoi")])
9db1d521
HP
2711
2712;
2713; fixuns_truncdfsi2 and fix_truncdfsi2 instruction pattern(s).
2714;
2715
2716(define_expand "fixuns_truncdfsi2"
2717 [(set (match_operand:SI 0 "register_operand" "")
2718 (unsigned_fix:SI (match_operand:DF 1 "register_operand" "")))]
2719 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
9db1d521
HP
2720{
2721 rtx label1 = gen_label_rtx ();
2722 rtx label2 = gen_label_rtx ();
2723 rtx temp = gen_reg_rtx (DFmode);
2724
2725 operands[1] = force_reg (DFmode,operands[1]);
c7453384 2726 emit_insn (gen_cmpdf (operands[1],
4023fb28 2727 CONST_DOUBLE_FROM_REAL_VALUE (
10bbf137 2728 REAL_VALUE_ATOF ("2147483648.0", DFmode), DFmode)));
9db1d521 2729 emit_jump_insn (gen_blt (label1));
4023fb28
UW
2730 emit_insn (gen_subdf3 (temp, operands[1],
2731 CONST_DOUBLE_FROM_REAL_VALUE (
10bbf137 2732 REAL_VALUE_ATOF ("4294967296.0", DFmode), DFmode)));
9db1d521 2733 emit_insn (gen_fix_truncdfsi2_ieee (operands[0], temp, GEN_INT (7)));
f314b9b1 2734 emit_jump (label2);
9db1d521
HP
2735
2736 emit_label (label1);
2737 emit_insn (gen_fix_truncdfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2738 emit_label (label2);
2739 DONE;
10bbf137 2740})
9db1d521
HP
2741
2742(define_expand "fix_truncdfsi2"
2743 [(set (match_operand:SI 0 "register_operand" "")
2744 (fix:SI (match_operand:DF 1 "nonimmediate_operand" "")))]
2745 "TARGET_HARD_FLOAT"
9db1d521 2746{
c7453384 2747 if (TARGET_IBM_FLOAT)
9db1d521
HP
2748 {
2749 /* This is the algorithm from POP chapter A.5.7.2. */
2750
c19ec8f9 2751 rtx temp = assign_stack_local (BLKmode, 8, BITS_PER_WORD);
4023fb28
UW
2752 rtx two31r = s390_gen_rtx_const_DI (0x4f000000, 0x08000000);
2753 rtx two32 = s390_gen_rtx_const_DI (0x4e000001, 0x00000000);
9db1d521
HP
2754
2755 operands[1] = force_reg (DFmode, operands[1]);
c7453384 2756 emit_insn (gen_fix_truncdfsi2_ibm (operands[0], operands[1],
9db1d521 2757 two31r, two32, temp));
c7453384
EC
2758 }
2759 else
9db1d521
HP
2760 {
2761 operands[1] = force_reg (DFmode, operands[1]);
2762 emit_insn (gen_fix_truncdfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2763 }
2764
2765 DONE;
10bbf137 2766})
9db1d521
HP
2767
2768(define_insn "fix_truncdfsi2_ieee"
2769 [(set (match_operand:SI 0 "register_operand" "=d")
2770 (fix:SI (match_operand:DF 1 "register_operand" "f")))
10bbf137 2771 (unspec:SI [(match_operand:SI 2 "immediate_operand" "K")] UNSPEC_ROUND)
9db1d521
HP
2772 (clobber (reg:CC 33))]
2773 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 2774 "cfdbr\t%0,%h2,%1"
9db1d521 2775 [(set_attr "op_type" "RRE")
4023fb28 2776 (set_attr "type" "other" )])
9db1d521
HP
2777
2778(define_insn "fix_truncdfsi2_ibm"
2779 [(set (match_operand:SI 0 "register_operand" "=d")
2780 (fix:SI (match_operand:DF 1 "nonimmediate_operand" "+f")))
4023fb28
UW
2781 (use (match_operand:DI 2 "immediate_operand" "m"))
2782 (use (match_operand:DI 3 "immediate_operand" "m"))
9db1d521
HP
2783 (use (match_operand:BLK 4 "memory_operand" "m"))
2784 (clobber (reg:CC 33))]
2785 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
9db1d521 2786{
d40c829f
UW
2787 output_asm_insn ("sd\t%1,%2", operands);
2788 output_asm_insn ("aw\t%1,%3", operands);
2789 output_asm_insn ("std\t%1,%4", operands);
2790 output_asm_insn ("xi\t%N4,128", operands);
2791 return "l\t%0,%N4";
10bbf137 2792}
9db1d521 2793 [(set_attr "op_type" "NN")
077dab3b
HP
2794 (set_attr "type" "ftoi")
2795 (set_attr "atype" "agen")
9db1d521
HP
2796 (set_attr "length" "20")])
2797
2798;
2799; fixuns_truncsfdi2 and fix_truncsfdi2 instruction pattern(s).
2800;
2801
2802(define_expand "fixuns_truncsfdi2"
2803 [(set (match_operand:DI 0 "register_operand" "")
2804 (unsigned_fix:DI (match_operand:SF 1 "register_operand" "")))]
2805 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
9db1d521
HP
2806{
2807 rtx label1 = gen_label_rtx ();
2808 rtx label2 = gen_label_rtx ();
2809 rtx temp = gen_reg_rtx (SFmode);
2810
2811 operands[1] = force_reg (SFmode, operands[1]);
c7453384 2812 emit_insn (gen_cmpsf (operands[1],
4023fb28 2813 CONST_DOUBLE_FROM_REAL_VALUE (
10bbf137 2814 REAL_VALUE_ATOF ("9223372036854775808.0", SFmode), SFmode)));
9db1d521
HP
2815 emit_jump_insn (gen_blt (label1));
2816
4023fb28
UW
2817 emit_insn (gen_subsf3 (temp, operands[1],
2818 CONST_DOUBLE_FROM_REAL_VALUE (
10bbf137 2819 REAL_VALUE_ATOF ("18446744073709551616.0", SFmode), SFmode)));
9db1d521 2820 emit_insn (gen_fix_truncsfdi2_ieee (operands[0], temp, GEN_INT(7)));
f314b9b1 2821 emit_jump (label2);
9db1d521
HP
2822
2823 emit_label (label1);
2824 emit_insn (gen_fix_truncsfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2825 emit_label (label2);
2826 DONE;
10bbf137 2827})
9db1d521
HP
2828
2829(define_expand "fix_truncsfdi2"
2830 [(set (match_operand:DI 0 "register_operand" "")
2831 (fix:DI (match_operand:SF 1 "nonimmediate_operand" "")))]
2832 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
9db1d521
HP
2833{
2834 operands[1] = force_reg (SFmode, operands[1]);
2835 emit_insn (gen_fix_truncsfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2836 DONE;
10bbf137 2837})
9db1d521
HP
2838
2839(define_insn "fix_truncsfdi2_ieee"
2840 [(set (match_operand:DI 0 "register_operand" "=d")
2841 (fix:DI (match_operand:SF 1 "register_operand" "f")))
10bbf137 2842 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
9db1d521
HP
2843 (clobber (reg:CC 33))]
2844 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 2845 "cgebr\t%0,%h2,%1"
9db1d521 2846 [(set_attr "op_type" "RRE")
077dab3b 2847 (set_attr "type" "ftoi")])
9db1d521
HP
2848
2849;
2850; fixuns_truncsfsi2 and fix_truncsfsi2 instruction pattern(s).
2851;
2852
2853(define_expand "fixuns_truncsfsi2"
2854 [(set (match_operand:SI 0 "register_operand" "")
2855 (unsigned_fix:SI (match_operand:SF 1 "register_operand" "")))]
2856 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
9db1d521
HP
2857{
2858 rtx label1 = gen_label_rtx ();
2859 rtx label2 = gen_label_rtx ();
2860 rtx temp = gen_reg_rtx (SFmode);
2861
2862 operands[1] = force_reg (SFmode, operands[1]);
4023fb28
UW
2863 emit_insn (gen_cmpsf (operands[1],
2864 CONST_DOUBLE_FROM_REAL_VALUE (
10bbf137 2865 REAL_VALUE_ATOF ("2147483648.0", SFmode), SFmode)));
9db1d521 2866 emit_jump_insn (gen_blt (label1));
4023fb28
UW
2867 emit_insn (gen_subsf3 (temp, operands[1],
2868 CONST_DOUBLE_FROM_REAL_VALUE (
10bbf137 2869 REAL_VALUE_ATOF ("4294967296.0", SFmode), SFmode)));
9db1d521 2870 emit_insn (gen_fix_truncsfsi2_ieee (operands[0], temp, GEN_INT (7)));
f314b9b1 2871 emit_jump (label2);
9db1d521
HP
2872
2873 emit_label (label1);
2874 emit_insn (gen_fix_truncsfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2875 emit_label (label2);
2876 DONE;
10bbf137 2877})
9db1d521
HP
2878
2879(define_expand "fix_truncsfsi2"
2880 [(set (match_operand:SI 0 "register_operand" "")
2881 (fix:SI (match_operand:SF 1 "nonimmediate_operand" "")))]
2882 "TARGET_HARD_FLOAT"
9db1d521
HP
2883{
2884 if (TARGET_IBM_FLOAT)
2885 {
2886 /* Convert to DFmode and then use the POP algorithm. */
2887 rtx temp = gen_reg_rtx (DFmode);
2888 emit_insn (gen_extendsfdf2 (temp, operands[1]));
2889 emit_insn (gen_fix_truncdfsi2 (operands[0], temp));
2890 }
2891 else
2892 {
2893 operands[1] = force_reg (SFmode, operands[1]);
2894 emit_insn (gen_fix_truncsfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2895 }
2896
2897 DONE;
10bbf137 2898})
9db1d521
HP
2899
2900(define_insn "fix_truncsfsi2_ieee"
2901 [(set (match_operand:SI 0 "register_operand" "=d")
2902 (fix:SI (match_operand:SF 1 "register_operand" "f")))
10bbf137 2903 (unspec:SI [(match_operand:SI 2 "immediate_operand" "K")] UNSPEC_ROUND)
9db1d521
HP
2904 (clobber (reg:CC 33))]
2905 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 2906 "cfebr\t%0,%h2,%1"
9db1d521 2907 [(set_attr "op_type" "RRE")
077dab3b 2908 (set_attr "type" "ftoi")])
9db1d521
HP
2909
2910;
2911; floatdidf2 instruction pattern(s).
2912;
2913
2914(define_insn "floatdidf2"
2915 [(set (match_operand:DF 0 "register_operand" "=f")
4023fb28
UW
2916 (float:DF (match_operand:DI 1 "register_operand" "d")))
2917 (clobber (reg:CC 33))]
9db1d521 2918 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 2919 "cdgbr\t%0,%1"
9db1d521 2920 [(set_attr "op_type" "RRE")
f0bf1270 2921 (set_attr "type" "itof" )])
9db1d521
HP
2922
2923;
2924; floatdisf2 instruction pattern(s).
2925;
2926
2927(define_insn "floatdisf2"
2928 [(set (match_operand:SF 0 "register_operand" "=f")
4023fb28
UW
2929 (float:SF (match_operand:DI 1 "register_operand" "d")))
2930 (clobber (reg:CC 33))]
9db1d521 2931 "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 2932 "cegbr\t%0,%1"
9db1d521 2933 [(set_attr "op_type" "RRE")
077dab3b 2934 (set_attr "type" "itof" )])
9db1d521
HP
2935
2936;
2937; floatsidf2 instruction pattern(s).
2938;
2939
2940(define_expand "floatsidf2"
4023fb28
UW
2941 [(parallel
2942 [(set (match_operand:DF 0 "register_operand" "")
2943 (float:DF (match_operand:SI 1 "register_operand" "")))
2944 (clobber (reg:CC 33))])]
9db1d521 2945 "TARGET_HARD_FLOAT"
9db1d521 2946{
c7453384 2947 if (TARGET_IBM_FLOAT)
9db1d521
HP
2948 {
2949 /* This is the algorithm from POP chapter A.5.7.1. */
2950
c19ec8f9 2951 rtx temp = assign_stack_local (BLKmode, 8, BITS_PER_WORD);
c7453384 2952 rtx two31 = s390_gen_rtx_const_DI (0x4e000000, 0x80000000);
9db1d521
HP
2953
2954 emit_insn (gen_floatsidf2_ibm (operands[0], operands[1], two31, temp));
2955 DONE;
2956 }
10bbf137 2957})
9db1d521
HP
2958
2959(define_insn "floatsidf2_ieee"
2960 [(set (match_operand:DF 0 "register_operand" "=f")
4023fb28
UW
2961 (float:DF (match_operand:SI 1 "register_operand" "d")))
2962 (clobber (reg:CC 33))]
9db1d521 2963 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 2964 "cdfbr\t%0,%1"
9db1d521 2965 [(set_attr "op_type" "RRE")
077dab3b 2966 (set_attr "type" "itof" )])
9db1d521
HP
2967
2968(define_insn "floatsidf2_ibm"
2969 [(set (match_operand:DF 0 "register_operand" "=f")
2970 (float:DF (match_operand:SI 1 "register_operand" "d")))
4023fb28 2971 (use (match_operand:DI 2 "immediate_operand" "m"))
9db1d521
HP
2972 (use (match_operand:BLK 3 "memory_operand" "m"))
2973 (clobber (reg:CC 33))]
2974 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
9db1d521 2975{
d40c829f
UW
2976 output_asm_insn ("st\t%1,%N3", operands);
2977 output_asm_insn ("xi\t%N3,128", operands);
2978 output_asm_insn ("mvc\t%O3(4,%R3),%2", operands);
2979 output_asm_insn ("ld\t%0,%3", operands);
2980 return "sd\t%0,%2";
10bbf137 2981}
9db1d521 2982 [(set_attr "op_type" "NN")
4023fb28 2983 (set_attr "type" "other" )
077dab3b 2984 (set_attr "atype" "agen")
9db1d521
HP
2985 (set_attr "length" "20")])
2986
2987;
2988; floatsisf2 instruction pattern(s).
2989;
2990
2991(define_expand "floatsisf2"
4023fb28
UW
2992 [(parallel
2993 [(set (match_operand:SF 0 "register_operand" "")
2994 (float:SF (match_operand:SI 1 "register_operand" "")))
2995 (clobber (reg:CC 33))])]
9db1d521 2996 "TARGET_HARD_FLOAT"
9db1d521
HP
2997{
2998 if (TARGET_IBM_FLOAT)
2999 {
3000 /* Use the POP algorithm to convert to DFmode and then truncate. */
3001 rtx temp = gen_reg_rtx (DFmode);
3002 emit_insn (gen_floatsidf2 (temp, operands[1]));
3003 emit_insn (gen_truncdfsf2 (operands[0], temp));
3004 DONE;
3005 }
10bbf137 3006})
9db1d521
HP
3007
3008(define_insn "floatsisf2_ieee"
3009 [(set (match_operand:SF 0 "register_operand" "=f")
4023fb28
UW
3010 (float:SF (match_operand:SI 1 "register_operand" "d")))
3011 (clobber (reg:CC 33))]
9db1d521 3012 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 3013 "cefbr\t%0,%1"
9db1d521 3014 [(set_attr "op_type" "RRE")
077dab3b 3015 (set_attr "type" "itof" )])
9db1d521
HP
3016
3017;
3018; truncdfsf2 instruction pattern(s).
3019;
3020
3021(define_expand "truncdfsf2"
3022 [(set (match_operand:SF 0 "register_operand" "")
3023 (float_truncate:SF (match_operand:DF 1 "general_operand" "")))]
3024 "TARGET_HARD_FLOAT"
4023fb28 3025 "")
9db1d521
HP
3026
3027(define_insn "truncdfsf2_ieee"
3028 [(set (match_operand:SF 0 "register_operand" "=f")
4023fb28 3029 (float_truncate:SF (match_operand:DF 1 "general_operand" "f")))]
9db1d521 3030 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 3031 "ledbr\t%0,%1"
ce50cae8 3032 [(set_attr "op_type" "RRE")])
9db1d521
HP
3033
3034(define_insn "truncdfsf2_ibm"
3035 [(set (match_operand:SF 0 "register_operand" "=f,f")
d3632d41 3036 (float_truncate:SF (match_operand:DF 1 "general_operand" "f,R")))]
9db1d521
HP
3037 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3038 "@
d40c829f
UW
3039 lrer\t%0,%1
3040 le\t%0,%1"
4023fb28 3041 [(set_attr "op_type" "RR,RX")
077dab3b 3042 (set_attr "type" "floads,floads")])
9db1d521
HP
3043
3044;
3045; extendsfdf2 instruction pattern(s).
3046;
3047
3048(define_expand "extendsfdf2"
3049 [(set (match_operand:DF 0 "register_operand" "")
3050 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "")))]
3051 "TARGET_HARD_FLOAT"
9db1d521
HP
3052{
3053 if (TARGET_IBM_FLOAT)
3054 {
3055 emit_insn (gen_extendsfdf2_ibm (operands[0], operands[1]));
3056 DONE;
3057 }
10bbf137 3058})
9db1d521
HP
3059
3060(define_insn "extendsfdf2_ieee"
3061 [(set (match_operand:DF 0 "register_operand" "=f,f")
d3632d41 3062 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,R")))]
9db1d521
HP
3063 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3064 "@
d40c829f
UW
3065 ldebr\t%0,%1
3066 ldeb\t%0,%1"
077dab3b
HP
3067 [(set_attr "op_type" "RRE,RXE")
3068 (set_attr "type" "floads,floads")])
9db1d521
HP
3069
3070(define_insn "extendsfdf2_ibm"
3071 [(set (match_operand:DF 0 "register_operand" "=f,f")
d3632d41 3072 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,R")))
9db1d521
HP
3073 (clobber (reg:CC 33))]
3074 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3075 "@
d40c829f
UW
3076 sdr\t%0,%0\;ler\t%0,%1
3077 sdr\t%0,%0\;le\t%0,%1"
077dab3b
HP
3078 [(set_attr "op_type" "NN,NN")
3079 (set_attr "atype" "reg,agen")
3080 (set_attr "length" "4,6")
c7453384 3081 (set_attr "type" "o2,o2")])
9db1d521
HP
3082
3083
3084;;
fae778eb 3085;; ARITHMETIC OPERATIONS
9db1d521 3086;;
fae778eb 3087; arithmetic operations set the ConditionCode,
9db1d521
HP
3088; because of unpredictable Bits in Register for Halfword and Byte
3089; the ConditionCode can be set wrong in operations for Halfword and Byte
3090
07893d4f
UW
3091;;
3092;;- Add instructions.
3093;;
3094
3095;
3096; adddi3 instruction pattern(s).
3097;
3098
07893d4f
UW
3099(define_insn "*adddi3_sign"
3100 [(set (match_operand:DI 0 "register_operand" "=d,d")
3101 (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3102 (match_operand:DI 1 "register_operand" "0,0")))
3103 (clobber (reg:CC 33))]
3104 "TARGET_64BIT"
3105 "@
d40c829f
UW
3106 agfr\t%0,%2
3107 agf\t%0,%2"
d3632d41 3108 [(set_attr "op_type" "RRE,RXY")])
07893d4f
UW
3109
3110(define_insn "*adddi3_zero_cc"
c7453384 3111 [(set (reg 33)
07893d4f
UW
3112 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3113 (match_operand:DI 1 "register_operand" "0,0"))
3114 (const_int 0)))
3115 (set (match_operand:DI 0 "register_operand" "=d,d")
3116 (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
3117 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3118 "@
d40c829f
UW
3119 algfr\t%0,%2
3120 algf\t%0,%2"
d3632d41 3121 [(set_attr "op_type" "RRE,RXY")])
07893d4f
UW
3122
3123(define_insn "*adddi3_zero_cconly"
c7453384 3124 [(set (reg 33)
07893d4f
UW
3125 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3126 (match_operand:DI 1 "register_operand" "0,0"))
3127 (const_int 0)))
3128 (clobber (match_scratch:DI 0 "=d,d"))]
3129 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3130 "@
d40c829f
UW
3131 algfr\t%0,%2
3132 algf\t%0,%2"
d3632d41 3133 [(set_attr "op_type" "RRE,RXY")])
07893d4f
UW
3134
3135(define_insn "*adddi3_zero"
3136 [(set (match_operand:DI 0 "register_operand" "=d,d")
3137 (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3138 (match_operand:DI 1 "register_operand" "0,0")))
3139 (clobber (reg:CC 33))]
3140 "TARGET_64BIT"
3141 "@
d40c829f
UW
3142 algfr\t%0,%2
3143 algf\t%0,%2"
d3632d41 3144 [(set_attr "op_type" "RRE,RXY")])
07893d4f 3145
0a3bdf9d 3146(define_insn "*adddi3_imm_cc"
c7453384 3147 [(set (reg 33)
0a3bdf9d
UW
3148 (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "0")
3149 (match_operand:DI 2 "const_int_operand" "K"))
3150 (const_int 0)))
3151 (set (match_operand:DI 0 "register_operand" "=d")
3152 (plus:DI (match_dup 1) (match_dup 2)))]
c7453384
EC
3153 "TARGET_64BIT
3154 && s390_match_ccmode (insn, CCAmode)
f19a9af7 3155 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")"
d40c829f 3156 "aghi\t%0,%h2"
077dab3b 3157 [(set_attr "op_type" "RI")])
0a3bdf9d 3158
b2ba71ca
UW
3159(define_insn "*adddi3_carry1_cc"
3160 [(set (reg 33)
3161 (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3162 (match_operand:DI 2 "general_operand" "d,m"))
3163 (match_dup 1)))
3164 (set (match_operand:DI 0 "register_operand" "=d,d")
3165 (plus:DI (match_dup 1) (match_dup 2)))]
3166 "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3167 "@
3168 algr\t%0,%2
3169 alg\t%0,%2"
3170 [(set_attr "op_type" "RRE,RXY")])
3171
3172(define_insn "*adddi3_carry1_cconly"
3173 [(set (reg 33)
3174 (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3175 (match_operand:DI 2 "general_operand" "d,m"))
3176 (match_dup 1)))
3177 (clobber (match_scratch:DI 0 "=d,d"))]
3178 "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3179 "@
3180 algr\t%0,%2
3181 alg\t%0,%2"
3182 [(set_attr "op_type" "RRE,RXY")])
3183
3184(define_insn "*adddi3_carry2_cc"
3185 [(set (reg 33)
3186 (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3187 (match_operand:DI 2 "general_operand" "d,m"))
3188 (match_dup 2)))
3189 (set (match_operand:DI 0 "register_operand" "=d,d")
3190 (plus:DI (match_dup 1) (match_dup 2)))]
3191 "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3192 "@
3193 algr\t%0,%2
3194 alg\t%0,%2"
3195 [(set_attr "op_type" "RRE,RXY")])
3196
3197(define_insn "*adddi3_carry2_cconly"
3198 [(set (reg 33)
3199 (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3200 (match_operand:DI 2 "general_operand" "d,m"))
3201 (match_dup 2)))
3202 (clobber (match_scratch:DI 0 "=d,d"))]
3203 "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3204 "@
3205 algr\t%0,%2
3206 alg\t%0,%2"
3207 [(set_attr "op_type" "RRE,RXY")])
3208
07893d4f 3209(define_insn "*adddi3_cc"
c7453384 3210 [(set (reg 33)
96fd3851 3211 (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
07893d4f
UW
3212 (match_operand:DI 2 "general_operand" "d,m"))
3213 (const_int 0)))
3214 (set (match_operand:DI 0 "register_operand" "=d,d")
3215 (plus:DI (match_dup 1) (match_dup 2)))]
3216 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3217 "@
d40c829f
UW
3218 algr\t%0,%2
3219 alg\t%0,%2"
d3632d41 3220 [(set_attr "op_type" "RRE,RXY")])
9db1d521 3221
07893d4f 3222(define_insn "*adddi3_cconly"
c7453384 3223 [(set (reg 33)
96fd3851 3224 (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
07893d4f
UW
3225 (match_operand:DI 2 "general_operand" "d,m"))
3226 (const_int 0)))
3227 (clobber (match_scratch:DI 0 "=d,d"))]
3228 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3229 "@
d40c829f
UW
3230 algr\t%0,%2
3231 alg\t%0,%2"
d3632d41 3232 [(set_attr "op_type" "RRE,RXY")])
9db1d521 3233
07893d4f 3234(define_insn "*adddi3_cconly2"
c7453384 3235 [(set (reg 33)
96fd3851 3236 (compare (match_operand:DI 1 "nonimmediate_operand" "%0,0")
07893d4f
UW
3237 (neg:SI (match_operand:DI 2 "general_operand" "d,m"))))
3238 (clobber (match_scratch:DI 0 "=d,d"))]
3239 "s390_match_ccmode(insn, CCLmode) && TARGET_64BIT"
9db1d521 3240 "@
d40c829f
UW
3241 algr\t%0,%2
3242 alg\t%0,%2"
d3632d41 3243 [(set_attr "op_type" "RRE,RXY")])
9db1d521 3244
07893d4f 3245(define_insn "*adddi3_64"
9db1d521 3246 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
96fd3851 3247 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
9db1d521
HP
3248 (match_operand:DI 2 "general_operand" "d,K,m") ) )
3249 (clobber (reg:CC 33))]
3250 "TARGET_64BIT"
3251 "@
d40c829f
UW
3252 agr\t%0,%2
3253 aghi\t%0,%h2
3254 ag\t%0,%2"
d3632d41 3255 [(set_attr "op_type" "RRE,RI,RXY")])
9db1d521 3256
e69166de
UW
3257(define_insn_and_split "*adddi3_31z"
3258 [(set (match_operand:DI 0 "register_operand" "=&d")
3259 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
3260 (match_operand:DI 2 "general_operand" "do") ) )
3261 (clobber (reg:CC 33))]
3262 "!TARGET_64BIT && TARGET_CPU_ZARCH"
3263 "#"
3264 "&& reload_completed"
3265 [(parallel
3266 [(set (reg:CCL1 33)
3267 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
3268 (match_dup 7)))
3269 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
3270 (parallel
3271 [(set (match_dup 3) (plus:SI (plus:SI (match_dup 4) (match_dup 5))
3272 (ltu:SI (reg:CCL1 33) (const_int 0))))
3273 (clobber (reg:CC 33))])]
3274 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3275 operands[4] = operand_subword (operands[1], 0, 0, DImode);
3276 operands[5] = operand_subword (operands[2], 0, 0, DImode);
3277 operands[6] = operand_subword (operands[0], 1, 0, DImode);
3278 operands[7] = operand_subword (operands[1], 1, 0, DImode);
3279 operands[8] = operand_subword (operands[2], 1, 0, DImode);"
3280 [(set_attr "op_type" "NN")])
3281
07893d4f
UW
3282(define_insn_and_split "*adddi3_31"
3283 [(set (match_operand:DI 0 "register_operand" "=&d")
96fd3851 3284 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
97c6f7ad 3285 (match_operand:DI 2 "general_operand" "do") ) )
9db1d521 3286 (clobber (reg:CC 33))]
e69166de 3287 "!TARGET_CPU_ZARCH"
07893d4f
UW
3288 "#"
3289 "&& reload_completed"
3290 [(parallel
3291 [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
3292 (clobber (reg:CC 33))])
3293 (parallel
3294 [(set (reg:CCL1 33)
3295 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
3296 (match_dup 7)))
3297 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
3298 (set (pc)
3299 (if_then_else (ltu (reg:CCL1 33) (const_int 0))
3300 (pc)
3301 (label_ref (match_dup 9))))
3302 (parallel
3303 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
3304 (clobber (reg:CC 33))])
3305 (match_dup 9)]
97c6f7ad
UW
3306 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3307 operands[4] = operand_subword (operands[1], 0, 0, DImode);
3308 operands[5] = operand_subword (operands[2], 0, 0, DImode);
3309 operands[6] = operand_subword (operands[0], 1, 0, DImode);
3310 operands[7] = operand_subword (operands[1], 1, 0, DImode);
3311 operands[8] = operand_subword (operands[2], 1, 0, DImode);
07893d4f 3312 operands[9] = gen_label_rtx ();"
0796c16a 3313 [(set_attr "op_type" "NN")])
9db1d521
HP
3314
3315(define_expand "adddi3"
07893d4f
UW
3316 [(parallel
3317 [(set (match_operand:DI 0 "register_operand" "")
96fd3851 3318 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
07893d4f
UW
3319 (match_operand:DI 2 "general_operand" "")))
3320 (clobber (reg:CC 33))])]
9db1d521 3321 ""
07893d4f 3322 "")
9db1d521 3323
f3e9edff 3324(define_insn "*la_64"
d3632d41
UW
3325 [(set (match_operand:DI 0 "register_operand" "=d,d")
3326 (match_operand:QI 1 "address_operand" "U,W"))]
9db1d521 3327 "TARGET_64BIT"
d3632d41 3328 "@
d40c829f
UW
3329 la\t%0,%a1
3330 lay\t%0,%a1"
d3632d41 3331 [(set_attr "op_type" "RX,RXY")
9db1d521
HP
3332 (set_attr "type" "la")])
3333
4888ec5d
UW
3334(define_peephole2
3335 [(parallel
3336 [(set (match_operand:DI 0 "register_operand" "")
3337 (match_operand:QI 1 "address_operand" ""))
3338 (clobber (reg:CC 33))])]
3339 "TARGET_64BIT
3340 && strict_memory_address_p (VOIDmode, operands[1])
3341 && preferred_la_operand_p (operands[1])"
3342 [(set (match_dup 0) (match_dup 1))]
3343 "")
3344
3345(define_peephole2
3346 [(set (match_operand:DI 0 "register_operand" "")
3347 (match_operand:DI 1 "register_operand" ""))
3348 (parallel
3349 [(set (match_dup 0)
3350 (plus:DI (match_dup 0)
3351 (match_operand:DI 2 "nonmemory_operand" "")))
3352 (clobber (reg:CC 33))])]
3353 "TARGET_64BIT
3354 && !reg_overlap_mentioned_p (operands[0], operands[2])
3355 && strict_memory_address_p (VOIDmode, gen_rtx_PLUS (DImode, operands[1], operands[2]))
3356 && preferred_la_operand_p (gen_rtx_PLUS (DImode, operands[1], operands[2]))"
3357 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
3358 "")
3359
f3e9edff
UW
3360(define_expand "reload_indi"
3361 [(parallel [(match_operand:DI 0 "register_operand" "=a")
3362 (match_operand:DI 1 "s390_plus_operand" "")
7974fe63 3363 (match_operand:DI 2 "register_operand" "=&a")])]
9db1d521 3364 "TARGET_64BIT"
4023fb28 3365{
f3e9edff
UW
3366 s390_expand_plus_operand (operands[0], operands[1], operands[2]);
3367 DONE;
10bbf137 3368})
4023fb28 3369
c7453384 3370
9db1d521
HP
3371;
3372; addsi3 instruction pattern(s).
3373;
9db1d521 3374
0a3bdf9d 3375(define_insn "*addsi3_imm_cc"
c7453384 3376 [(set (reg 33)
0a3bdf9d
UW
3377 (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "0")
3378 (match_operand:SI 2 "const_int_operand" "K"))
3379 (const_int 0)))
3380 (set (match_operand:SI 0 "register_operand" "=d")
3381 (plus:SI (match_dup 1) (match_dup 2)))]
3382 "s390_match_ccmode (insn, CCAmode)
f19a9af7 3383 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")"
d40c829f 3384 "ahi\t%0,%h2"
077dab3b 3385 [(set_attr "op_type" "RI")])
0a3bdf9d 3386
07893d4f 3387(define_insn "*addsi3_carry1_cc"
c7453384 3388 [(set (reg 33)
d3632d41
UW
3389 (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3390 (match_operand:SI 2 "general_operand" "d,R,T"))
07893d4f 3391 (match_dup 1)))
d3632d41 3392 (set (match_operand:SI 0 "register_operand" "=d,d,d")
07893d4f 3393 (plus:SI (match_dup 1) (match_dup 2)))]
c7453384 3394 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 3395 "@
d40c829f
UW
3396 alr\t%0,%2
3397 al\t%0,%2
3398 aly\t%0,%2"
d3632d41 3399 [(set_attr "op_type" "RR,RX,RXY")])
07893d4f
UW
3400
3401(define_insn "*addsi3_carry1_cconly"
c7453384 3402 [(set (reg 33)
d3632d41
UW
3403 (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3404 (match_operand:SI 2 "general_operand" "d,R,T"))
07893d4f 3405 (match_dup 1)))
d3632d41 3406 (clobber (match_scratch:SI 0 "=d,d,d"))]
c7453384 3407 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 3408 "@
d40c829f
UW
3409 alr\t%0,%2
3410 al\t%0,%2
3411 aly\t%0,%2"
d3632d41 3412 [(set_attr "op_type" "RR,RX,RXY")])
07893d4f
UW
3413
3414(define_insn "*addsi3_carry2_cc"
c7453384 3415 [(set (reg 33)
d3632d41
UW
3416 (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3417 (match_operand:SI 2 "general_operand" "d,R,T"))
07893d4f 3418 (match_dup 2)))
d3632d41 3419 (set (match_operand:SI 0 "register_operand" "=d,d,d")
07893d4f 3420 (plus:SI (match_dup 1) (match_dup 2)))]
c7453384 3421 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 3422 "@
d40c829f
UW
3423 alr\t%0,%2
3424 al\t%0,%2
3425 aly\t%0,%2"
d3632d41 3426 [(set_attr "op_type" "RR,RX,RXY")])
07893d4f
UW
3427
3428(define_insn "*addsi3_carry2_cconly"
c7453384 3429 [(set (reg 33)
d3632d41
UW
3430 (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3431 (match_operand:SI 2 "general_operand" "d,R,T"))
07893d4f 3432 (match_dup 2)))
d3632d41 3433 (clobber (match_scratch:SI 0 "=d,d,d"))]
c7453384 3434 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 3435 "@
d40c829f
UW
3436 alr\t%0,%2
3437 al\t%0,%2
3438 aly\t%0,%2"
d3632d41 3439 [(set_attr "op_type" "RR,RX,RXY")])
07893d4f 3440
9db1d521 3441(define_insn "*addsi3_cc"
c7453384 3442 [(set (reg 33)
d3632d41
UW
3443 (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3444 (match_operand:SI 2 "general_operand" "d,R,T"))
9db1d521 3445 (const_int 0)))
d3632d41 3446 (set (match_operand:SI 0 "register_operand" "=d,d,d")
9db1d521 3447 (plus:SI (match_dup 1) (match_dup 2)))]
c7453384 3448 "s390_match_ccmode (insn, CCLmode)"
9db1d521 3449 "@
d40c829f
UW
3450 alr\t%0,%2
3451 al\t%0,%2
3452 aly\t%0,%2"
d3632d41 3453 [(set_attr "op_type" "RR,RX,RXY")])
9db1d521
HP
3454
3455(define_insn "*addsi3_cconly"
c7453384 3456 [(set (reg 33)
d3632d41
UW
3457 (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3458 (match_operand:SI 2 "general_operand" "d,R,T"))
9db1d521 3459 (const_int 0)))
d3632d41 3460 (clobber (match_scratch:SI 0 "=d,d,d"))]
c7453384 3461 "s390_match_ccmode (insn, CCLmode)"
9db1d521 3462 "@
d40c829f
UW
3463 alr\t%0,%2
3464 al\t%0,%2
3465 aly\t%0,%2"
d3632d41 3466 [(set_attr "op_type" "RR,RX,RXY")])
9db1d521
HP
3467
3468(define_insn "*addsi3_cconly2"
c7453384 3469 [(set (reg 33)
d3632d41
UW
3470 (compare (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3471 (neg:SI (match_operand:SI 2 "general_operand" "d,R,T"))))
3472 (clobber (match_scratch:SI 0 "=d,d,d"))]
b2ba71ca 3473 "s390_match_ccmode (insn, CCLmode)"
9db1d521 3474 "@
d40c829f
UW
3475 alr\t%0,%2
3476 al\t%0,%2
3477 aly\t%0,%2"
d3632d41 3478 [(set_attr "op_type" "RR,RX,RXY")])
9db1d521 3479
07893d4f 3480(define_insn "*addsi3_sign"
d3632d41
UW
3481 [(set (match_operand:SI 0 "register_operand" "=d,d")
3482 (plus:SI (match_operand:SI 1 "register_operand" "0,0")
3483 (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
07893d4f
UW
3484 (clobber (reg:CC 33))]
3485 ""
d3632d41 3486 "@
d40c829f
UW
3487 ah\t%0,%2
3488 ahy\t%0,%2"
d3632d41 3489 [(set_attr "op_type" "RX,RXY")])
07893d4f 3490
9db1d521 3491(define_insn "addsi3"
d3632d41
UW
3492 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
3493 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
3494 (match_operand:SI 2 "general_operand" "d,K,R,T")))
9db1d521
HP
3495 (clobber (reg:CC 33))]
3496 ""
3497 "@
d40c829f
UW
3498 ar\t%0,%2
3499 ahi\t%0,%h2
3500 a\t%0,%2
3501 ay\t%0,%2"
d3632d41 3502 [(set_attr "op_type" "RR,RI,RX,RXY")])
9db1d521 3503
f3e9edff 3504(define_insn "*la_31"
d3632d41
UW
3505 [(set (match_operand:SI 0 "register_operand" "=d,d")
3506 (match_operand:QI 1 "address_operand" "U,W"))]
100c7420 3507 "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
d3632d41 3508 "@
d40c829f
UW
3509 la\t%0,%a1
3510 lay\t%0,%a1"
d3632d41 3511 [(set_attr "op_type" "RX,RXY")
100c7420
UW
3512 (set_attr "type" "la")])
3513
4888ec5d
UW
3514(define_peephole2
3515 [(parallel
3516 [(set (match_operand:SI 0 "register_operand" "")
3517 (match_operand:QI 1 "address_operand" ""))
3518 (clobber (reg:CC 33))])]
3519 "!TARGET_64BIT
3520 && strict_memory_address_p (VOIDmode, operands[1])
3521 && preferred_la_operand_p (operands[1])"
3522 [(set (match_dup 0) (match_dup 1))]
3523 "")
3524
3525(define_peephole2
3526 [(set (match_operand:SI 0 "register_operand" "")
3527 (match_operand:SI 1 "register_operand" ""))
3528 (parallel
3529 [(set (match_dup 0)
3530 (plus:SI (match_dup 0)
3531 (match_operand:SI 2 "nonmemory_operand" "")))
3532 (clobber (reg:CC 33))])]
3533 "!TARGET_64BIT
3534 && !reg_overlap_mentioned_p (operands[0], operands[2])
3535 && strict_memory_address_p (VOIDmode, gen_rtx_PLUS (SImode, operands[1], operands[2]))
3536 && preferred_la_operand_p (gen_rtx_PLUS (SImode, operands[1], operands[2]))"
3537 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
3538 "")
3539
100c7420 3540(define_insn "*la_31_and"
d3632d41
UW
3541 [(set (match_operand:SI 0 "register_operand" "=d,d")
3542 (and:SI (match_operand:QI 1 "address_operand" "U,W")
100c7420
UW
3543 (const_int 2147483647)))]
3544 "!TARGET_64BIT"
d3632d41 3545 "@
d40c829f
UW
3546 la\t%0,%a1
3547 lay\t%0,%a1"
d3632d41 3548 [(set_attr "op_type" "RX,RXY")
9db1d521 3549 (set_attr "type" "la")])
100c7420
UW
3550
3551(define_insn_and_split "*la_31_and_cc"
3552 [(set (match_operand:SI 0 "register_operand" "=d")
3553 (and:SI (match_operand:QI 1 "address_operand" "p")
3554 (const_int 2147483647)))
3555 (clobber (reg:CC 33))]
3556 "!TARGET_64BIT"
3557 "#"
3558 "&& reload_completed"
c7453384 3559 [(set (match_dup 0)
100c7420
UW
3560 (and:SI (match_dup 1) (const_int 2147483647)))]
3561 ""
3562 [(set_attr "op_type" "RX")
100c7420 3563 (set_attr "type" "la")])
9db1d521 3564
a41c6c53 3565(define_insn "force_la_31"
d3632d41
UW
3566 [(set (match_operand:SI 0 "register_operand" "=d,d")
3567 (match_operand:QI 1 "address_operand" "U,W"))
a41c6c53
UW
3568 (use (const_int 0))]
3569 "!TARGET_64BIT"
d3632d41 3570 "@
d40c829f
UW
3571 la\t%0,%a1
3572 lay\t%0,%a1"
a41c6c53 3573 [(set_attr "op_type" "RX")
a41c6c53
UW
3574 (set_attr "type" "la")])
3575
f3e9edff
UW
3576(define_expand "reload_insi"
3577 [(parallel [(match_operand:SI 0 "register_operand" "=a")
3578 (match_operand:SI 1 "s390_plus_operand" "")
7974fe63 3579 (match_operand:SI 2 "register_operand" "=&a")])]
f3e9edff 3580 "!TARGET_64BIT"
4023fb28 3581{
f3e9edff
UW
3582 s390_expand_plus_operand (operands[0], operands[1], operands[2]);
3583 DONE;
10bbf137 3584})
bc1fa59c 3585
9db1d521 3586
9db1d521
HP
3587;
3588; adddf3 instruction pattern(s).
3589;
3590
3591(define_expand "adddf3"
3592 [(parallel
3593 [(set (match_operand:DF 0 "register_operand" "=f,f")
96fd3851 3594 (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
d3632d41 3595 (match_operand:DF 2 "general_operand" "f,R")))
9db1d521
HP
3596 (clobber (reg:CC 33))])]
3597 "TARGET_HARD_FLOAT"
3598 "")
3599
3600(define_insn "*adddf3"
3601 [(set (match_operand:DF 0 "register_operand" "=f,f")
96fd3851 3602 (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
d3632d41 3603 (match_operand:DF 2 "general_operand" "f,R")))
9db1d521
HP
3604 (clobber (reg:CC 33))]
3605 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3606 "@
d40c829f
UW
3607 adbr\t%0,%2
3608 adb\t%0,%2"
ce50cae8 3609 [(set_attr "op_type" "RRE,RXE")
077dab3b 3610 (set_attr "type" "fsimpd,fsimpd")])
9db1d521 3611
3ef093a8
AK
3612(define_insn "*adddf3_cc"
3613 [(set (reg 33)
3614 (compare (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3615 (match_operand:DF 2 "general_operand" "f,R"))
3616 (match_operand:DF 3 "const0_operand" "")))
3617 (set (match_operand:DF 0 "register_operand" "=f,f")
3618 (plus:DF (match_dup 1) (match_dup 2)))]
3619 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3620 "@
d40c829f
UW
3621 adbr\t%0,%2
3622 adb\t%0,%2"
3ef093a8
AK
3623 [(set_attr "op_type" "RRE,RXE")
3624 (set_attr "type" "fsimpd,fsimpd")])
3625
3626(define_insn "*adddf3_cconly"
3627 [(set (reg 33)
3628 (compare (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3629 (match_operand:DF 2 "general_operand" "f,R"))
3630 (match_operand:DF 3 "const0_operand" "")))
3631 (clobber (match_scratch:DF 0 "=f,f"))]
3632 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3633 "@
d40c829f
UW
3634 adbr\t%0,%2
3635 adb\t%0,%2"
3ef093a8
AK
3636 [(set_attr "op_type" "RRE,RXE")
3637 (set_attr "type" "fsimpd,fsimpd")])
3638
9db1d521
HP
3639(define_insn "*adddf3_ibm"
3640 [(set (match_operand:DF 0 "register_operand" "=f,f")
96fd3851 3641 (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
d3632d41 3642 (match_operand:DF 2 "general_operand" "f,R")))
9db1d521
HP
3643 (clobber (reg:CC 33))]
3644 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3645 "@
d40c829f
UW
3646 adr\t%0,%2
3647 ad\t%0,%2"
9db1d521 3648 [(set_attr "op_type" "RR,RX")
077dab3b 3649 (set_attr "type" "fsimpd,fsimpd")])
9db1d521
HP
3650
3651;
3652; addsf3 instruction pattern(s).
3653;
3654
3655(define_expand "addsf3"
3656 [(parallel
3657 [(set (match_operand:SF 0 "register_operand" "=f,f")
96fd3851 3658 (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
d3632d41 3659 (match_operand:SF 2 "general_operand" "f,R")))
9db1d521
HP
3660 (clobber (reg:CC 33))])]
3661 "TARGET_HARD_FLOAT"
3662 "")
3663
3664(define_insn "*addsf3"
3665 [(set (match_operand:SF 0 "register_operand" "=f,f")
96fd3851 3666 (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
d3632d41 3667 (match_operand:SF 2 "general_operand" "f,R")))
9db1d521
HP
3668 (clobber (reg:CC 33))]
3669 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3670 "@
d40c829f
UW
3671 aebr\t%0,%2
3672 aeb\t%0,%2"
ce50cae8 3673 [(set_attr "op_type" "RRE,RXE")
077dab3b 3674 (set_attr "type" "fsimps,fsimps")])
9db1d521 3675
3ef093a8
AK
3676(define_insn "*addsf3_cc"
3677 [(set (reg 33)
3678 (compare (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3679 (match_operand:SF 2 "general_operand" "f,R"))
3680 (match_operand:SF 3 "const0_operand" "")))
3681 (set (match_operand:SF 0 "register_operand" "=f,f")
3682 (plus:SF (match_dup 1) (match_dup 2)))]
3683 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3684 "@
d40c829f
UW
3685 aebr\t%0,%2
3686 aeb\t%0,%2"
3ef093a8
AK
3687 [(set_attr "op_type" "RRE,RXE")
3688 (set_attr "type" "fsimps,fsimps")])
3689
3690(define_insn "*addsf3_cconly"
3691 [(set (reg 33)
3692 (compare (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3693 (match_operand:SF 2 "general_operand" "f,R"))
3694 (match_operand:SF 3 "const0_operand" "")))
3695 (clobber (match_scratch:SF 0 "=f,f"))]
3696 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3697 "@
d40c829f
UW
3698 aebr\t%0,%2
3699 aeb\t%0,%2"
3ef093a8
AK
3700 [(set_attr "op_type" "RRE,RXE")
3701 (set_attr "type" "fsimps,fsimps")])
3702
9db1d521
HP
3703(define_insn "*addsf3"
3704 [(set (match_operand:SF 0 "register_operand" "=f,f")
96fd3851 3705 (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
d3632d41 3706 (match_operand:SF 2 "general_operand" "f,R")))
9db1d521
HP
3707 (clobber (reg:CC 33))]
3708 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3709 "@
d40c829f
UW
3710 aer\t%0,%2
3711 ae\t%0,%2"
9db1d521 3712 [(set_attr "op_type" "RR,RX")
077dab3b 3713 (set_attr "type" "fsimps,fsimps")])
9db1d521
HP
3714
3715
3716;;
3717;;- Subtract instructions.
3718;;
3719
3720;
3721; subdi3 instruction pattern(s).
3722;
3723
07893d4f
UW
3724(define_insn "*subdi3_sign"
3725 [(set (match_operand:DI 0 "register_operand" "=d,d")
3726 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3727 (sign_extend:DI (match_operand:SI 2 "general_operand" "d,m"))))
3728 (clobber (reg:CC 33))]
3729 "TARGET_64BIT"
3730 "@
d40c829f
UW
3731 sgfr\t%0,%2
3732 sgf\t%0,%2"
d3632d41 3733 [(set_attr "op_type" "RRE,RXY")])
07893d4f
UW
3734
3735(define_insn "*subdi3_zero_cc"
c7453384 3736 [(set (reg 33)
07893d4f
UW
3737 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3738 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m")))
3739 (const_int 0)))
3740 (set (match_operand:DI 0 "register_operand" "=d,d")
3741 (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
3742 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3743 "@
d40c829f
UW
3744 slgfr\t%0,%2
3745 slgf\t%0,%2"
d3632d41 3746 [(set_attr "op_type" "RRE,RXY")])
07893d4f
UW
3747
3748(define_insn "*subdi3_zero_cconly"
c7453384 3749 [(set (reg 33)
07893d4f
UW
3750 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3751 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m")))
3752 (const_int 0)))
3753 (clobber (match_scratch:DI 0 "=d,d"))]
3754 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3755 "@
d40c829f
UW
3756 slgfr\t%0,%2
3757 slgf\t%0,%2"
d3632d41 3758 [(set_attr "op_type" "RRE,RXY")])
07893d4f
UW
3759
3760(define_insn "*subdi3_zero"
3761 [(set (match_operand:DI 0 "register_operand" "=d,d")
3762 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3763 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))))
3764 (clobber (reg:CC 33))]
3765 "TARGET_64BIT"
3766 "@
d40c829f
UW
3767 slgfr\t%0,%2
3768 slgf\t%0,%2"
d3632d41 3769 [(set_attr "op_type" "RRE,RXY")])
07893d4f 3770
b2ba71ca
UW
3771(define_insn "*subdi3_borrow_cc"
3772 [(set (reg 33)
3773 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3774 (match_operand:DI 2 "general_operand" "d,m"))
3775 (match_dup 1)))
3776 (set (match_operand:DI 0 "register_operand" "=d,d")
3777 (minus:DI (match_dup 1) (match_dup 2)))]
3778 "s390_match_ccmode (insn, CCL2mode) && TARGET_64BIT"
3779 "@
3780 slgr\t%0,%2
3781 slg\t%0,%2"
3782 [(set_attr "op_type" "RRE,RXY")])
3783
3784(define_insn "*subdi3_borrow_cconly"
3785 [(set (reg 33)
3786 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3787 (match_operand:DI 2 "general_operand" "d,m"))
3788 (match_dup 1)))
3789 (clobber (match_scratch:DI 0 "=d,d"))]
3790 "s390_match_ccmode (insn, CCL2mode) && TARGET_64BIT"
3791 "@
3792 slgr\t%0,%2
3793 slg\t%0,%2"
3794 [(set_attr "op_type" "RRE,RXY")])
3795
07893d4f
UW
3796(define_insn "*subdi3_cc"
3797 [(set (reg 33)
3798 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3799 (match_operand:DI 2 "general_operand" "d,m"))
3800 (const_int 0)))
3801 (set (match_operand:DI 0 "register_operand" "=d,d")
3802 (minus:DI (match_dup 1) (match_dup 2)))]
b2ba71ca 3803 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
07893d4f 3804 "@
d40c829f
UW
3805 slgr\t%0,%2
3806 slg\t%0,%2"
d3632d41 3807 [(set_attr "op_type" "RRE,RXY")])
07893d4f
UW
3808
3809(define_insn "*subdi3_cconly"
3810 [(set (reg 33)
3811 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3812 (match_operand:DI 2 "general_operand" "d,m"))
3813 (const_int 0)))
3814 (clobber (match_scratch:DI 0 "=d,d"))]
b2ba71ca 3815 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
07893d4f 3816 "@
d40c829f
UW
3817 slgr\t%0,%2
3818 slg\t%0,%2"
d3632d41 3819 [(set_attr "op_type" "RRE,RXY")])
07893d4f 3820
9db1d521
HP
3821(define_insn "*subdi3_64"
3822 [(set (match_operand:DI 0 "register_operand" "=d,d")
3823 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3824 (match_operand:DI 2 "general_operand" "d,m") ) )
3825 (clobber (reg:CC 33))]
3826 "TARGET_64BIT"
3827 "@
d40c829f
UW
3828 sgr\t%0,%2
3829 sg\t%0,%2"
077dab3b 3830 [(set_attr "op_type" "RRE,RRE")])
9db1d521 3831
e69166de
UW
3832(define_insn_and_split "*subdi3_31z"
3833 [(set (match_operand:DI 0 "register_operand" "=&d")
3834 (minus:DI (match_operand:DI 1 "register_operand" "0")
3835 (match_operand:DI 2 "general_operand" "do") ) )
3836 (clobber (reg:CC 33))]
3837 "!TARGET_64BIT && TARGET_CPU_ZARCH"
3838 "#"
3839 "&& reload_completed"
3840 [(parallel
3841 [(set (reg:CCL2 33)
3842 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
3843 (match_dup 7)))
3844 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
3845 (parallel
3846 [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
3847 (gtu:SI (reg:CCL2 33) (const_int 0))))
3848 (clobber (reg:CC 33))])]
3849 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3850 operands[4] = operand_subword (operands[1], 0, 0, DImode);
3851 operands[5] = operand_subword (operands[2], 0, 0, DImode);
3852 operands[6] = operand_subword (operands[0], 1, 0, DImode);
3853 operands[7] = operand_subword (operands[1], 1, 0, DImode);
3854 operands[8] = operand_subword (operands[2], 1, 0, DImode);"
3855 [(set_attr "op_type" "NN")])
3856
07893d4f
UW
3857(define_insn_and_split "*subdi3_31"
3858 [(set (match_operand:DI 0 "register_operand" "=&d")
3859 (minus:DI (match_operand:DI 1 "register_operand" "0")
97c6f7ad 3860 (match_operand:DI 2 "general_operand" "do") ) )
9db1d521 3861 (clobber (reg:CC 33))]
e69166de 3862 "!TARGET_CPU_ZARCH"
07893d4f
UW
3863 "#"
3864 "&& reload_completed"
3865 [(parallel
3866 [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
3867 (clobber (reg:CC 33))])
3868 (parallel
3869 [(set (reg:CCL2 33)
3870 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
3871 (match_dup 7)))
3872 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
3873 (set (pc)
3874 (if_then_else (gtu (reg:CCL2 33) (const_int 0))
3875 (pc)
3876 (label_ref (match_dup 9))))
3877 (parallel
3878 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
3879 (clobber (reg:CC 33))])
3880 (match_dup 9)]
97c6f7ad
UW
3881 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3882 operands[4] = operand_subword (operands[1], 0, 0, DImode);
3883 operands[5] = operand_subword (operands[2], 0, 0, DImode);
3884 operands[6] = operand_subword (operands[0], 1, 0, DImode);
3885 operands[7] = operand_subword (operands[1], 1, 0, DImode);
3886 operands[8] = operand_subword (operands[2], 1, 0, DImode);
07893d4f 3887 operands[9] = gen_label_rtx ();"
0796c16a 3888 [(set_attr "op_type" "NN")])
07893d4f
UW
3889
3890(define_expand "subdi3"
3891 [(parallel
3892 [(set (match_operand:DI 0 "register_operand" "")
3893 (minus:DI (match_operand:DI 1 "register_operand" "")
3894 (match_operand:DI 2 "general_operand" "")))
3895 (clobber (reg:CC 33))])]
9db1d521 3896 ""
07893d4f 3897 "")
9db1d521
HP
3898
3899;
3900; subsi3 instruction pattern(s).
3901;
3902
07893d4f
UW
3903(define_insn "*subsi3_borrow_cc"
3904 [(set (reg 33)
d3632d41
UW
3905 (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
3906 (match_operand:SI 2 "general_operand" "d,R,T"))
07893d4f 3907 (match_dup 1)))
d3632d41 3908 (set (match_operand:SI 0 "register_operand" "=d,d,d")
07893d4f 3909 (minus:SI (match_dup 1) (match_dup 2)))]
b2ba71ca 3910 "s390_match_ccmode (insn, CCL2mode)"
07893d4f 3911 "@
d40c829f
UW
3912 slr\t%0,%2
3913 sl\t%0,%2
3914 sly\t%0,%2"
d3632d41 3915 [(set_attr "op_type" "RR,RX,RXY")])
07893d4f
UW
3916
3917(define_insn "*subsi3_borrow_cconly"
3918 [(set (reg 33)
d3632d41
UW
3919 (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
3920 (match_operand:SI 2 "general_operand" "d,R,T"))
07893d4f 3921 (match_dup 1)))
d3632d41 3922 (clobber (match_scratch:SI 0 "=d,d,d"))]
b2ba71ca 3923 "s390_match_ccmode (insn, CCL2mode)"
07893d4f 3924 "@
d40c829f
UW
3925 slr\t%0,%2
3926 sl\t%0,%2
3927 sly\t%0,%2"
b2ba71ca 3928 [(set_attr "op_type" "RR,RX,RXY")])
07893d4f 3929
9db1d521
HP
3930(define_insn "*subsi3_cc"
3931 [(set (reg 33)
d3632d41
UW
3932 (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
3933 (match_operand:SI 2 "general_operand" "d,R,T"))
9db1d521 3934 (const_int 0)))
d3632d41 3935 (set (match_operand:SI 0 "register_operand" "=d,d,d")
9db1d521 3936 (minus:SI (match_dup 1) (match_dup 2)))]
b2ba71ca 3937 "s390_match_ccmode (insn, CCLmode)"
9db1d521 3938 "@
d40c829f
UW
3939 slr\t%0,%2
3940 sl\t%0,%2
3941 sly\t%0,%2"
d3632d41 3942 [(set_attr "op_type" "RR,RX,RXY")])
9db1d521
HP
3943
3944(define_insn "*subsi3_cconly"
3945 [(set (reg 33)
d3632d41
UW
3946 (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
3947 (match_operand:SI 2 "general_operand" "d,R,T"))
9db1d521 3948 (const_int 0)))
d3632d41 3949 (clobber (match_scratch:SI 0 "=d,d,d"))]
b2ba71ca 3950 "s390_match_ccmode (insn, CCLmode)"
9db1d521 3951 "@
d40c829f
UW
3952 slr\t%0,%2
3953 sl\t%0,%2
3954 sly\t%0,%2"
d3632d41 3955 [(set_attr "op_type" "RR,RX,RXY")])
9db1d521 3956
07893d4f 3957(define_insn "*subsi3_sign"
d3632d41
UW
3958 [(set (match_operand:SI 0 "register_operand" "=d,d")
3959 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
3960 (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
07893d4f
UW
3961 (clobber (reg:CC 33))]
3962 ""
d3632d41 3963 "@
d40c829f
UW
3964 sh\t%0,%2
3965 shy\t%0,%2"
d3632d41 3966 [(set_attr "op_type" "RX,RXY")])
07893d4f 3967
9db1d521 3968(define_insn "subsi3"
d3632d41
UW
3969 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
3970 (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
3971 (match_operand:SI 2 "general_operand" "d,R,T")))
9db1d521
HP
3972 (clobber (reg:CC 33))]
3973 ""
3974 "@
d40c829f
UW
3975 sr\t%0,%2
3976 s\t%0,%2
3977 sy\t%0,%2"
d3632d41 3978 [(set_attr "op_type" "RR,RX,RXY")])
9db1d521 3979
9db1d521
HP
3980
3981;
3982; subdf3 instruction pattern(s).
3983;
3984
3985(define_expand "subdf3"
3986 [(parallel
3987 [(set (match_operand:DF 0 "register_operand" "=f,f")
3988 (minus:DF (match_operand:DF 1 "register_operand" "0,0")
d3632d41 3989 (match_operand:DF 2 "general_operand" "f,R")))
9db1d521
HP
3990 (clobber (reg:CC 33))])]
3991 "TARGET_HARD_FLOAT"
3992 "")
3993
3994(define_insn "*subdf3"
3995 [(set (match_operand:DF 0 "register_operand" "=f,f")
3996 (minus:DF (match_operand:DF 1 "register_operand" "0,0")
d3632d41 3997 (match_operand:DF 2 "general_operand" "f,R")))
9db1d521
HP
3998 (clobber (reg:CC 33))]
3999 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4000 "@
d40c829f
UW
4001 sdbr\t%0,%2
4002 sdb\t%0,%2"
ce50cae8 4003 [(set_attr "op_type" "RRE,RXE")
077dab3b 4004 (set_attr "type" "fsimpd,fsimpd")])
9db1d521 4005
3ef093a8
AK
4006(define_insn "*subdf3_cc"
4007 [(set (reg 33)
4008 (compare (minus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4009 (match_operand:DF 2 "general_operand" "f,R"))
4010 (match_operand:DF 3 "const0_operand" "")))
4011 (set (match_operand:DF 0 "register_operand" "=f,f")
4012 (plus:DF (match_dup 1) (match_dup 2)))]
4013 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4014 "@
d40c829f
UW
4015 sdbr\t%0,%2
4016 sdb\t%0,%2"
3ef093a8
AK
4017 [(set_attr "op_type" "RRE,RXE")
4018 (set_attr "type" "fsimpd,fsimpd")])
4019
4020(define_insn "*subdf3_cconly"
4021 [(set (reg 33)
4022 (compare (minus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4023 (match_operand:DF 2 "general_operand" "f,R"))
4024 (match_operand:DF 3 "const0_operand" "")))
4025 (clobber (match_scratch:DF 0 "=f,f"))]
4026 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4027 "@
d40c829f
UW
4028 sdbr\t%0,%2
4029 sdb\t%0,%2"
3ef093a8
AK
4030 [(set_attr "op_type" "RRE,RXE")
4031 (set_attr "type" "fsimpd,fsimpd")])
4032
9db1d521
HP
4033(define_insn "*subdf3_ibm"
4034 [(set (match_operand:DF 0 "register_operand" "=f,f")
4035 (minus:DF (match_operand:DF 1 "register_operand" "0,0")
d3632d41 4036 (match_operand:DF 2 "general_operand" "f,R")))
9db1d521
HP
4037 (clobber (reg:CC 33))]
4038 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4039 "@
d40c829f
UW
4040 sdr\t%0,%2
4041 sd\t%0,%2"
9db1d521 4042 [(set_attr "op_type" "RR,RX")
077dab3b 4043 (set_attr "type" "fsimpd,fsimpd")])
9db1d521
HP
4044
4045;
4046; subsf3 instruction pattern(s).
4047;
4048
4049(define_expand "subsf3"
4050 [(parallel
4051 [(set (match_operand:SF 0 "register_operand" "=f,f")
4052 (minus:SF (match_operand:SF 1 "register_operand" "0,0")
d3632d41 4053 (match_operand:SF 2 "general_operand" "f,R")))
9db1d521
HP
4054 (clobber (reg:CC 33))])]
4055 "TARGET_HARD_FLOAT"
4056 "")
4057
4058(define_insn "*subsf3"
4059 [(set (match_operand:SF 0 "register_operand" "=f,f")
4060 (minus:SF (match_operand:SF 1 "register_operand" "0,0")
d3632d41 4061 (match_operand:SF 2 "general_operand" "f,R")))
9db1d521
HP
4062 (clobber (reg:CC 33))]
4063 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4064 "@
d40c829f
UW
4065 sebr\t%0,%2
4066 seb\t%0,%2"
ce50cae8 4067 [(set_attr "op_type" "RRE,RXE")
077dab3b 4068 (set_attr "type" "fsimps,fsimps")])
9db1d521 4069
3ef093a8
AK
4070(define_insn "*subsf3_cc"
4071 [(set (reg 33)
4072 (compare (minus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4073 (match_operand:SF 2 "general_operand" "f,R"))
4074 (match_operand:SF 3 "const0_operand" "")))
4075 (set (match_operand:SF 0 "register_operand" "=f,f")
4076 (minus:SF (match_dup 1) (match_dup 2)))]
4077 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4078 "@
d40c829f
UW
4079 sebr\t%0,%2
4080 seb\t%0,%2"
3ef093a8
AK
4081 [(set_attr "op_type" "RRE,RXE")
4082 (set_attr "type" "fsimps,fsimps")])
4083
4084(define_insn "*subsf3_cconly"
4085 [(set (reg 33)
4086 (compare (minus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4087 (match_operand:SF 2 "general_operand" "f,R"))
4088 (match_operand:SF 3 "const0_operand" "")))
4089 (clobber (match_scratch:SF 0 "=f,f"))]
4090 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4091 "@
d40c829f
UW
4092 sebr\t%0,%2
4093 seb\t%0,%2"
3ef093a8
AK
4094 [(set_attr "op_type" "RRE,RXE")
4095 (set_attr "type" "fsimps,fsimps")])
4096
9db1d521
HP
4097(define_insn "*subsf3_ibm"
4098 [(set (match_operand:SF 0 "register_operand" "=f,f")
4099 (minus:SF (match_operand:SF 1 "register_operand" "0,0")
d3632d41 4100 (match_operand:SF 2 "general_operand" "f,R")))
9db1d521
HP
4101 (clobber (reg:CC 33))]
4102 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4103 "@
d40c829f
UW
4104 ser\t%0,%2
4105 se\t%0,%2"
9db1d521 4106 [(set_attr "op_type" "RR,RX")
077dab3b 4107 (set_attr "type" "fsimps,fsimps")])
9db1d521
HP
4108
4109
e69166de
UW
4110;;
4111;;- Conditional add/subtract instructions.
4112;;
4113
4114;
4115; adddicc instruction pattern(s).
4116;
4117
4118(define_insn "*adddi3_alc_cc"
4119 [(set (reg 33)
4120 (compare
4121 (plus:DI (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4122 (match_operand:DI 2 "general_operand" "d,m"))
4123 (match_operand:DI 3 "s390_alc_comparison" ""))
4124 (const_int 0)))
4125 (set (match_operand:DI 0 "register_operand" "=d,d")
4126 (plus:DI (plus:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4127 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4128 "@
4129 alcgr\\t%0,%2
4130 alcg\\t%0,%2"
4131 [(set_attr "op_type" "RRE,RXY")])
4132
4133(define_insn "*adddi3_alc"
4134 [(set (match_operand:DI 0 "register_operand" "=d,d")
4135 (plus:DI (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4136 (match_operand:DI 2 "general_operand" "d,m"))
4137 (match_operand:DI 3 "s390_alc_comparison" "")))
4138 (clobber (reg:CC 33))]
4139 "TARGET_64BIT"
4140 "@
4141 alcgr\\t%0,%2
4142 alcg\\t%0,%2"
4143 [(set_attr "op_type" "RRE,RXY")])
4144
4145(define_insn "*subdi3_slb_cc"
4146 [(set (reg 33)
4147 (compare
4148 (minus:DI (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
4149 (match_operand:DI 2 "general_operand" "d,m"))
4150 (match_operand:DI 3 "s390_slb_comparison" ""))
4151 (const_int 0)))
4152 (set (match_operand:DI 0 "register_operand" "=d,d")
4153 (minus:DI (minus:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4154 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4155 "@
4156 slbgr\\t%0,%2
4157 slbg\\t%0,%2"
4158 [(set_attr "op_type" "RRE,RXY")])
4159
4160(define_insn "*subdi3_slb"
4161 [(set (match_operand:DI 0 "register_operand" "=d,d")
4162 (minus:DI (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
4163 (match_operand:DI 2 "general_operand" "d,m"))
4164 (match_operand:DI 3 "s390_slb_comparison" "")))
4165 (clobber (reg:CC 33))]
4166 "TARGET_64BIT"
4167 "@
4168 slbgr\\t%0,%2
4169 slbg\\t%0,%2"
4170 [(set_attr "op_type" "RRE,RXY")])
4171
4172;
4173; addsicc instruction pattern(s).
4174;
4175
4176(define_insn "*addsi3_alc_cc"
4177 [(set (reg 33)
4178 (compare
4179 (plus:SI (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
4180 (match_operand:SI 2 "general_operand" "d,m"))
4181 (match_operand:SI 3 "s390_alc_comparison" ""))
4182 (const_int 0)))
4183 (set (match_operand:SI 0 "register_operand" "=d,d")
4184 (plus:SI (plus:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4185 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
4186 "@
4187 alcr\\t%0,%2
4188 alc\\t%0,%2"
4189 [(set_attr "op_type" "RRE,RXY")])
4190
4191(define_insn "*addsi3_alc"
4192 [(set (match_operand:SI 0 "register_operand" "=d,d")
4193 (plus:SI (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
4194 (match_operand:SI 2 "general_operand" "d,m"))
4195 (match_operand:SI 3 "s390_alc_comparison" "")))
4196 (clobber (reg:CC 33))]
4197 "TARGET_CPU_ZARCH"
4198 "@
4199 alcr\\t%0,%2
4200 alc\\t%0,%2"
4201 [(set_attr "op_type" "RRE,RXY")])
4202
4203(define_insn "*subsi3_slb_cc"
4204 [(set (reg 33)
4205 (compare
4206 (minus:SI (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
4207 (match_operand:SI 2 "general_operand" "d,m"))
4208 (match_operand:SI 3 "s390_slb_comparison" ""))
4209 (const_int 0)))
4210 (set (match_operand:SI 0 "register_operand" "=d,d")
4211 (minus:SI (minus:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4212 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
4213 "@
4214 slbr\\t%0,%2
4215 slb\\t%0,%2"
4216 [(set_attr "op_type" "RRE,RXY")])
4217
4218(define_insn "*subsi3_slb"
4219 [(set (match_operand:SI 0 "register_operand" "=d,d")
4220 (minus:SI (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
4221 (match_operand:SI 2 "general_operand" "d,m"))
4222 (match_operand:SI 3 "s390_slb_comparison" "")))
4223 (clobber (reg:CC 33))]
4224 "TARGET_CPU_ZARCH"
4225 "@
4226 slbr\\t%0,%2
4227 slb\\t%0,%2"
4228 [(set_attr "op_type" "RRE,RXY")])
4229
4230
9db1d521
HP
4231;;
4232;;- Multiply instructions.
4233;;
4234
4023fb28
UW
4235;
4236; muldi3 instruction pattern(s).
4237;
9db1d521 4238
07893d4f
UW
4239(define_insn "*muldi3_sign"
4240 [(set (match_operand:DI 0 "register_operand" "=d,d")
4241 (mult:DI (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "d,m"))
4242 (match_operand:DI 1 "register_operand" "0,0")))]
4243 "TARGET_64BIT"
4244 "@
d40c829f
UW
4245 msgfr\t%0,%2
4246 msgf\t%0,%2"
d3632d41 4247 [(set_attr "op_type" "RRE,RXY")
07893d4f
UW
4248 (set_attr "type" "imul")])
4249
4023fb28 4250(define_insn "muldi3"
9db1d521 4251 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
96fd3851 4252 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
07893d4f 4253 (match_operand:DI 2 "general_operand" "d,K,m")))]
9db1d521
HP
4254 "TARGET_64BIT"
4255 "@
d40c829f
UW
4256 msgr\t%0,%2
4257 mghi\t%0,%h2
4258 msg\t%0,%2"
d3632d41 4259 [(set_attr "op_type" "RRE,RI,RXY")
f2d3c02a
HP
4260 (set_attr "type" "imul")])
4261
9db1d521
HP
4262;
4263; mulsi3 instruction pattern(s).
4264;
4265
f1e77d83
UW
4266(define_insn "*mulsi3_sign"
4267 [(set (match_operand:SI 0 "register_operand" "=d")
4268 (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R"))
4269 (match_operand:SI 1 "register_operand" "0")))]
4270 ""
4271 "mh\t%0,%2"
4272 [(set_attr "op_type" "RX")
4273 (set_attr "type" "imul")])
4274
9db1d521 4275(define_insn "mulsi3"
d3632d41
UW
4276 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
4277 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
4278 (match_operand:SI 2 "general_operand" "d,K,R,T")))]
9db1d521
HP
4279 ""
4280 "@
d40c829f
UW
4281 msr\t%0,%2
4282 mhi\t%0,%h2
4283 ms\t%0,%2
4284 msy\t%0,%2"
d3632d41 4285 [(set_attr "op_type" "RRE,RI,RX,RXY")
f2d3c02a 4286 (set_attr "type" "imul")])
9db1d521 4287
4023fb28
UW
4288;
4289; mulsidi3 instruction pattern(s).
4290;
4291
f1e77d83
UW
4292(define_insn "mulsidi3"
4293 [(set (match_operand:DI 0 "register_operand" "=d,d")
4294 (mult:DI (sign_extend:DI
4295 (match_operand:SI 1 "register_operand" "%0,0"))
4296 (sign_extend:DI
4297 (match_operand:SI 2 "nonimmediate_operand" "d,R"))))]
4023fb28 4298 "!TARGET_64BIT"
f1e77d83
UW
4299 "@
4300 mr\t%0,%2
4301 m\t%0,%2"
4302 [(set_attr "op_type" "RR,RX")
4303 (set_attr "type" "imul")])
4023fb28 4304
f1e77d83
UW
4305;
4306; umulsidi3 instruction pattern(s).
4307;
c7453384 4308
f1e77d83
UW
4309(define_insn "umulsidi3"
4310 [(set (match_operand:DI 0 "register_operand" "=d,d")
4311 (mult:DI (zero_extend:DI
4312 (match_operand:SI 1 "register_operand" "%0,0"))
4313 (zero_extend:DI
4314 (match_operand:SI 2 "nonimmediate_operand" "d,m"))))]
4315 "!TARGET_64BIT && TARGET_CPU_ZARCH"
4316 "@
4317 mlr\t%0,%2
4318 ml\t%0,%2"
4319 [(set_attr "op_type" "RRE,RXY")
f2d3c02a 4320 (set_attr "type" "imul")])
c7453384 4321
9db1d521
HP
4322;
4323; muldf3 instruction pattern(s).
4324;
4325
4326(define_expand "muldf3"
553e5ce9
UW
4327 [(set (match_operand:DF 0 "register_operand" "=f,f")
4328 (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4329 (match_operand:DF 2 "general_operand" "f,R")))]
9db1d521
HP
4330 "TARGET_HARD_FLOAT"
4331 "")
4332
4333(define_insn "*muldf3"
4334 [(set (match_operand:DF 0 "register_operand" "=f,f")
96fd3851 4335 (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
553e5ce9 4336 (match_operand:DF 2 "general_operand" "f,R")))]
9db1d521
HP
4337 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4338 "@
d40c829f
UW
4339 mdbr\t%0,%2
4340 mdb\t%0,%2"
ce50cae8 4341 [(set_attr "op_type" "RRE,RXE")
077dab3b 4342 (set_attr "type" "fmuld")])
9db1d521
HP
4343
4344(define_insn "*muldf3_ibm"
4345 [(set (match_operand:DF 0 "register_operand" "=f,f")
96fd3851 4346 (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
553e5ce9 4347 (match_operand:DF 2 "general_operand" "f,R")))]
9db1d521
HP
4348 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4349 "@
d40c829f
UW
4350 mdr\t%0,%2
4351 md\t%0,%2"
9db1d521 4352 [(set_attr "op_type" "RR,RX")
077dab3b 4353 (set_attr "type" "fmuld")])
9db1d521 4354
a1b892b5
AK
4355(define_insn "*fmadddf"
4356 [(set (match_operand:DF 0 "register_operand" "=f,f")
4357 (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "%f,f")
4358 (match_operand:DF 2 "nonimmediate_operand" "f,R"))
4359 (match_operand:DF 3 "register_operand" "0,0")))]
f2d226e1 4360 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
a1b892b5
AK
4361 "@
4362 madbr\t%0,%1,%2
4363 madb\t%0,%1,%2"
4364 [(set_attr "op_type" "RRE,RXE")
4365 (set_attr "type" "fmuld")])
4366
4367(define_insn "*fmsubdf"
4368 [(set (match_operand:DF 0 "register_operand" "=f,f")
4369 (minus:DF (mult:DF (match_operand:DF 1 "register_operand" "f,f")
4370 (match_operand:DF 2 "nonimmediate_operand" "f,R"))
4371 (match_operand:DF 3 "register_operand" "0,0")))]
f2d226e1 4372 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
a1b892b5
AK
4373 "@
4374 msdbr\t%0,%1,%2
4375 msdb\t%0,%1,%2"
4376 [(set_attr "op_type" "RRE,RXE")
4377 (set_attr "type" "fmuld")])
4378
9db1d521
HP
4379;
4380; mulsf3 instruction pattern(s).
4381;
4382
4383(define_expand "mulsf3"
553e5ce9
UW
4384 [(set (match_operand:SF 0 "register_operand" "=f,f")
4385 (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4386 (match_operand:SF 2 "general_operand" "f,R")))]
9db1d521
HP
4387 "TARGET_HARD_FLOAT"
4388 "")
4389
4390(define_insn "*mulsf3"
4391 [(set (match_operand:SF 0 "register_operand" "=f,f")
96fd3851 4392 (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
553e5ce9 4393 (match_operand:SF 2 "general_operand" "f,R")))]
9db1d521
HP
4394 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4395 "@
d40c829f
UW
4396 meebr\t%0,%2
4397 meeb\t%0,%2"
ce50cae8 4398 [(set_attr "op_type" "RRE,RXE")
077dab3b 4399 (set_attr "type" "fmuls")])
9db1d521
HP
4400
4401(define_insn "*mulsf3_ibm"
4402 [(set (match_operand:SF 0 "register_operand" "=f,f")
96fd3851 4403 (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
553e5ce9 4404 (match_operand:SF 2 "general_operand" "f,R")))]
9db1d521
HP
4405 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4406 "@
d40c829f
UW
4407 mer\t%0,%2
4408 me\t%0,%2"
9db1d521 4409 [(set_attr "op_type" "RR,RX")
077dab3b 4410 (set_attr "type" "fmuls")])
9db1d521 4411
a1b892b5
AK
4412(define_insn "*fmaddsf"
4413 [(set (match_operand:SF 0 "register_operand" "=f,f")
4414 (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f,f")
4415 (match_operand:SF 2 "nonimmediate_operand" "f,R"))
4416 (match_operand:SF 3 "register_operand" "0,0")))]
f2d226e1 4417 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
a1b892b5
AK
4418 "@
4419 maebr\t%0,%1,%2
4420 maeb\t%0,%1,%2"
4421 [(set_attr "op_type" "RRE,RXE")
4422 (set_attr "type" "fmuls")])
4423
4424(define_insn "*fmsubsf"
4425 [(set (match_operand:SF 0 "register_operand" "=f,f")
4426 (minus:SF (mult:SF (match_operand:SF 1 "register_operand" "f,f")
4427 (match_operand:SF 2 "nonimmediate_operand" "f,R"))
4428 (match_operand:SF 3 "register_operand" "0,0")))]
f2d226e1 4429 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
a1b892b5
AK
4430 "@
4431 msebr\t%0,%1,%2
4432 mseb\t%0,%1,%2"
4433 [(set_attr "op_type" "RRE,RXE")
4434 (set_attr "type" "fmuls")])
9db1d521
HP
4435
4436;;
4437;;- Divide and modulo instructions.
4438;;
4439
4440;
4023fb28 4441; divmoddi4 instruction pattern(s).
9db1d521
HP
4442;
4443
4023fb28
UW
4444(define_expand "divmoddi4"
4445 [(parallel [(set (match_operand:DI 0 "general_operand" "")
f1e77d83 4446 (div:DI (match_operand:DI 1 "register_operand" "")
4023fb28
UW
4447 (match_operand:DI 2 "general_operand" "")))
4448 (set (match_operand:DI 3 "general_operand" "")
4449 (mod:DI (match_dup 1) (match_dup 2)))])
4450 (clobber (match_dup 4))]
9db1d521 4451 "TARGET_64BIT"
9db1d521 4452{
f1e77d83 4453 rtx insn, div_equal, mod_equal;
4023fb28
UW
4454
4455 div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
4456 mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
4023fb28
UW
4457
4458 operands[4] = gen_reg_rtx(TImode);
f1e77d83 4459 emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
4023fb28
UW
4460
4461 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
4462 REG_NOTES (insn) =
4463 gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4464
4465 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
4466 REG_NOTES (insn) =
4467 gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
9db1d521 4468
9db1d521 4469 DONE;
10bbf137 4470})
9db1d521
HP
4471
4472(define_insn "divmodtidi3"
4023fb28
UW
4473 [(set (match_operand:TI 0 "register_operand" "=d,d")
4474 (ior:TI
4475 (zero_extend:TI
f1e77d83 4476 (div:DI (match_operand:DI 1 "register_operand" "0,0")
4023fb28
UW
4477 (match_operand:DI 2 "general_operand" "d,m")))
4478 (ashift:TI
4479 (zero_extend:TI
f1e77d83 4480 (mod:DI (match_dup 1)
4023fb28
UW
4481 (match_dup 2)))
4482 (const_int 64))))]
9db1d521
HP
4483 "TARGET_64BIT"
4484 "@
d40c829f
UW
4485 dsgr\t%0,%2
4486 dsg\t%0,%2"
d3632d41 4487 [(set_attr "op_type" "RRE,RXY")
077dab3b 4488 (set_attr "type" "idiv")])
9db1d521 4489
4023fb28
UW
4490(define_insn "divmodtisi3"
4491 [(set (match_operand:TI 0 "register_operand" "=d,d")
4492 (ior:TI
4493 (zero_extend:TI
f1e77d83 4494 (div:DI (match_operand:DI 1 "register_operand" "0,0")
4023fb28
UW
4495 (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "d,m"))))
4496 (ashift:TI
4497 (zero_extend:TI
f1e77d83 4498 (mod:DI (match_dup 1)
4023fb28
UW
4499 (sign_extend:DI (match_dup 2))))
4500 (const_int 64))))]
9db1d521 4501 "TARGET_64BIT"
4023fb28 4502 "@
d40c829f
UW
4503 dsgfr\t%0,%2
4504 dsgf\t%0,%2"
d3632d41 4505 [(set_attr "op_type" "RRE,RXY")
077dab3b 4506 (set_attr "type" "idiv")])
9db1d521 4507
4023fb28
UW
4508;
4509; udivmoddi4 instruction pattern(s).
4510;
9db1d521 4511
4023fb28
UW
4512(define_expand "udivmoddi4"
4513 [(parallel [(set (match_operand:DI 0 "general_operand" "")
4514 (udiv:DI (match_operand:DI 1 "general_operand" "")
4515 (match_operand:DI 2 "nonimmediate_operand" "")))
4516 (set (match_operand:DI 3 "general_operand" "")
4517 (umod:DI (match_dup 1) (match_dup 2)))])
4518 (clobber (match_dup 4))]
9db1d521 4519 "TARGET_64BIT"
9db1d521 4520{
4023fb28
UW
4521 rtx insn, div_equal, mod_equal, equal;
4522
4523 div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
4524 mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
4525 equal = gen_rtx_IOR (TImode,
4526 gen_rtx_ZERO_EXTEND (TImode, div_equal),
4527 gen_rtx_ASHIFT (TImode,
4528 gen_rtx_ZERO_EXTEND (TImode, mod_equal),
4529 GEN_INT (64)));
4530
4531 operands[4] = gen_reg_rtx(TImode);
4532 emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4]));
4533 emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
4534 emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
4535 insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
4536 REG_NOTES (insn) =
4537 gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4538
4539 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
4540 REG_NOTES (insn) =
4541 gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4542
4543 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
4544 REG_NOTES (insn) =
4545 gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
9db1d521 4546
9db1d521 4547 DONE;
10bbf137 4548})
9db1d521
HP
4549
4550(define_insn "udivmodtidi3"
4023fb28 4551 [(set (match_operand:TI 0 "register_operand" "=d,d")
c7453384 4552 (ior:TI (zero_extend:TI
4023fb28
UW
4553 (truncate:DI
4554 (udiv:TI (match_operand:TI 1 "register_operand" "0,0")
4555 (zero_extend:TI
4556 (match_operand:DI 2 "nonimmediate_operand" "d,m")))))
4557 (ashift:TI
4558 (zero_extend:TI
4559 (truncate:DI
4560 (umod:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))
4561 (const_int 64))))]
9db1d521
HP
4562 "TARGET_64BIT"
4563 "@
d40c829f
UW
4564 dlgr\t%0,%2
4565 dlg\t%0,%2"
d3632d41 4566 [(set_attr "op_type" "RRE,RXY")
077dab3b 4567 (set_attr "type" "idiv")])
9db1d521
HP
4568
4569;
4023fb28 4570; divmodsi4 instruction pattern(s).
9db1d521
HP
4571;
4572
4023fb28
UW
4573(define_expand "divmodsi4"
4574 [(parallel [(set (match_operand:SI 0 "general_operand" "")
4575 (div:SI (match_operand:SI 1 "general_operand" "")
4576 (match_operand:SI 2 "nonimmediate_operand" "")))
4577 (set (match_operand:SI 3 "general_operand" "")
4578 (mod:SI (match_dup 1) (match_dup 2)))])
4579 (clobber (match_dup 4))]
9db1d521 4580 "!TARGET_64BIT"
9db1d521 4581{
4023fb28
UW
4582 rtx insn, div_equal, mod_equal, equal;
4583
4584 div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
4585 mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
4586 equal = gen_rtx_IOR (DImode,
4587 gen_rtx_ZERO_EXTEND (DImode, div_equal),
4588 gen_rtx_ASHIFT (DImode,
4589 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
4590 GEN_INT (32)));
4591
4592 operands[4] = gen_reg_rtx(DImode);
4593 emit_insn (gen_extendsidi2 (operands[4], operands[1]));
4594 insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
4595 REG_NOTES (insn) =
4596 gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4597
4598 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
4599 REG_NOTES (insn) =
4600 gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4601
4602 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
4603 REG_NOTES (insn) =
4604 gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
9db1d521 4605
9db1d521 4606 DONE;
10bbf137 4607})
9db1d521
HP
4608
4609(define_insn "divmoddisi3"
4023fb28
UW
4610 [(set (match_operand:DI 0 "register_operand" "=d,d")
4611 (ior:DI (zero_extend:DI
4612 (truncate:SI
4613 (div:DI (match_operand:DI 1 "register_operand" "0,0")
c7453384 4614 (sign_extend:DI
d3632d41 4615 (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
4023fb28
UW
4616 (ashift:DI
4617 (zero_extend:DI
4618 (truncate:SI
4619 (mod:DI (match_dup 1) (sign_extend:SI (match_dup 2)))))
4620 (const_int 32))))]
9db1d521
HP
4621 "!TARGET_64BIT"
4622 "@
d40c829f
UW
4623 dr\t%0,%2
4624 d\t%0,%2"
9db1d521 4625 [(set_attr "op_type" "RR,RX")
077dab3b 4626 (set_attr "type" "idiv")])
9db1d521
HP
4627
4628;
4629; udivsi3 and umodsi3 instruction pattern(s).
4630;
4631
f1e77d83
UW
4632(define_expand "udivmodsi4"
4633 [(parallel [(set (match_operand:SI 0 "general_operand" "")
4634 (udiv:SI (match_operand:SI 1 "general_operand" "")
4635 (match_operand:SI 2 "nonimmediate_operand" "")))
4636 (set (match_operand:SI 3 "general_operand" "")
4637 (umod:SI (match_dup 1) (match_dup 2)))])
4638 (clobber (match_dup 4))]
4639 "!TARGET_64BIT && TARGET_CPU_ZARCH"
4640{
4641 rtx insn, div_equal, mod_equal, equal;
4642
4643 div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4644 mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4645 equal = gen_rtx_IOR (DImode,
4646 gen_rtx_ZERO_EXTEND (DImode, div_equal),
4647 gen_rtx_ASHIFT (DImode,
4648 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
4649 GEN_INT (32)));
4650
4651 operands[4] = gen_reg_rtx(DImode);
4652 emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4]));
4653 emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
4654 emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
4655 insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
4656 REG_NOTES (insn) =
4657 gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4658
4659 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
4660 REG_NOTES (insn) =
4661 gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4662
4663 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
4664 REG_NOTES (insn) =
4665 gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4666
4667 DONE;
4668})
4669
4670(define_insn "udivmoddisi3"
4671 [(set (match_operand:DI 0 "register_operand" "=d,d")
4672 (ior:DI (zero_extend:DI
4673 (truncate:SI
4674 (udiv:DI (match_operand:DI 1 "register_operand" "0,0")
4675 (zero_extend:DI
4676 (match_operand:SI 2 "nonimmediate_operand" "d,m")))))
4677 (ashift:DI
4678 (zero_extend:DI
4679 (truncate:SI
4680 (umod:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))
4681 (const_int 32))))]
4682 "!TARGET_64BIT && TARGET_CPU_ZARCH"
4683 "@
4684 dlr\t%0,%2
4685 dl\t%0,%2"
4686 [(set_attr "op_type" "RRE,RXY")
4687 (set_attr "type" "idiv")])
4023fb28 4688
9db1d521
HP
4689(define_expand "udivsi3"
4690 [(set (match_operand:SI 0 "register_operand" "=d")
4691 (udiv:SI (match_operand:SI 1 "general_operand" "")
4023fb28
UW
4692 (match_operand:SI 2 "general_operand" "")))
4693 (clobber (match_dup 3))]
f1e77d83 4694 "!TARGET_64BIT && !TARGET_CPU_ZARCH"
9db1d521 4695{
4023fb28
UW
4696 rtx insn, udiv_equal, umod_equal, equal;
4697
4698 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4699 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4700 equal = gen_rtx_IOR (DImode,
4701 gen_rtx_ZERO_EXTEND (DImode, udiv_equal),
4702 gen_rtx_ASHIFT (DImode,
4703 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
4704 GEN_INT (32)));
9db1d521 4705
4023fb28 4706 operands[3] = gen_reg_rtx (DImode);
9db1d521
HP
4707
4708 if (CONSTANT_P (operands[2]))
4709 {
4710 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
4711 {
4712 rtx label1 = gen_label_rtx ();
4713
4023fb28
UW
4714 operands[1] = make_safe_from (operands[1], operands[0]);
4715 emit_move_insn (operands[0], const0_rtx);
4716 emit_insn (gen_cmpsi (operands[1], operands[2]));
9db1d521 4717 emit_jump_insn (gen_bltu (label1));
4023fb28 4718 emit_move_insn (operands[0], const1_rtx);
9db1d521
HP
4719 emit_label (label1);
4720 }
4721 else
4722 {
c7453384
EC
4723 operands[2] = force_reg (SImode, operands[2]);
4724 operands[2] = make_safe_from (operands[2], operands[0]);
4023fb28
UW
4725
4726 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
4727 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
4728 operands[2]));
4729 REG_NOTES (insn) =
4730 gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
c7453384
EC
4731
4732 insn = emit_move_insn (operands[0],
4023fb28
UW
4733 gen_lowpart (SImode, operands[3]));
4734 REG_NOTES (insn) =
c7453384 4735 gen_rtx_EXPR_LIST (REG_EQUAL,
4023fb28 4736 udiv_equal, REG_NOTES (insn));
9db1d521
HP
4737 }
4738 }
4739 else
c7453384 4740 {
9db1d521
HP
4741 rtx label1 = gen_label_rtx ();
4742 rtx label2 = gen_label_rtx ();
4743 rtx label3 = gen_label_rtx ();
4744
c7453384
EC
4745 operands[1] = force_reg (SImode, operands[1]);
4746 operands[1] = make_safe_from (operands[1], operands[0]);
4747 operands[2] = force_reg (SImode, operands[2]);
4748 operands[2] = make_safe_from (operands[2], operands[0]);
4023fb28
UW
4749
4750 emit_move_insn (operands[0], const0_rtx);
9db1d521
HP
4751 emit_insn (gen_cmpsi (operands[2], operands[1]));
4752 emit_jump_insn (gen_bgtu (label3));
4753 emit_insn (gen_cmpsi (operands[2], const1_rtx));
4754 emit_jump_insn (gen_blt (label2));
4755 emit_insn (gen_cmpsi (operands[2], const1_rtx));
4756 emit_jump_insn (gen_beq (label1));
4023fb28
UW
4757 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
4758 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
4759 operands[2]));
4760 REG_NOTES (insn) =
4761 gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
c7453384
EC
4762
4763 insn = emit_move_insn (operands[0],
4023fb28
UW
4764 gen_lowpart (SImode, operands[3]));
4765 REG_NOTES (insn) =
c7453384 4766 gen_rtx_EXPR_LIST (REG_EQUAL,
4023fb28 4767 udiv_equal, REG_NOTES (insn));
f314b9b1 4768 emit_jump (label3);
9db1d521 4769 emit_label (label1);
4023fb28 4770 emit_move_insn (operands[0], operands[1]);
f314b9b1 4771 emit_jump (label3);
9db1d521 4772 emit_label (label2);
4023fb28 4773 emit_move_insn (operands[0], const1_rtx);
9db1d521
HP
4774 emit_label (label3);
4775 }
c7453384 4776 emit_move_insn (operands[0], operands[0]);
9db1d521 4777 DONE;
10bbf137 4778})
9db1d521
HP
4779
4780(define_expand "umodsi3"
4781 [(set (match_operand:SI 0 "register_operand" "=d")
4782 (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
4023fb28
UW
4783 (match_operand:SI 2 "nonimmediate_operand" "")))
4784 (clobber (match_dup 3))]
f1e77d83 4785 "!TARGET_64BIT && !TARGET_CPU_ZARCH"
9db1d521 4786{
4023fb28
UW
4787 rtx insn, udiv_equal, umod_equal, equal;
4788
4789 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4790 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4791 equal = gen_rtx_IOR (DImode,
4792 gen_rtx_ZERO_EXTEND (DImode, udiv_equal),
4793 gen_rtx_ASHIFT (DImode,
4794 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
4795 GEN_INT (32)));
9db1d521 4796
4023fb28 4797 operands[3] = gen_reg_rtx (DImode);
9db1d521
HP
4798
4799 if (CONSTANT_P (operands[2]))
4800 {
4801 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
4802 {
4803 rtx label1 = gen_label_rtx ();
4804
4023fb28
UW
4805 operands[1] = make_safe_from (operands[1], operands[0]);
4806 emit_move_insn (operands[0], operands[1]);
4807 emit_insn (gen_cmpsi (operands[0], operands[2]));
9db1d521 4808 emit_jump_insn (gen_bltu (label1));
4023fb28
UW
4809 emit_insn (gen_abssi2 (operands[0], operands[2]));
4810 emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
9db1d521
HP
4811 emit_label (label1);
4812 }
4813 else
4814 {
c7453384
EC
4815 operands[2] = force_reg (SImode, operands[2]);
4816 operands[2] = make_safe_from (operands[2], operands[0]);
4023fb28
UW
4817
4818 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
4819 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
4820 operands[2]));
4821 REG_NOTES (insn) =
4822 gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
c7453384
EC
4823
4824 insn = emit_move_insn (operands[0],
4023fb28
UW
4825 gen_highpart (SImode, operands[3]));
4826 REG_NOTES (insn) =
c7453384 4827 gen_rtx_EXPR_LIST (REG_EQUAL,
4023fb28 4828 umod_equal, REG_NOTES (insn));
9db1d521
HP
4829 }
4830 }
4831 else
4832 {
4833 rtx label1 = gen_label_rtx ();
4834 rtx label2 = gen_label_rtx ();
4835 rtx label3 = gen_label_rtx ();
4836
c7453384
EC
4837 operands[1] = force_reg (SImode, operands[1]);
4838 operands[1] = make_safe_from (operands[1], operands[0]);
4839 operands[2] = force_reg (SImode, operands[2]);
4840 operands[2] = make_safe_from (operands[2], operands[0]);
9db1d521 4841
c7453384 4842 emit_move_insn(operands[0], operands[1]);
4023fb28 4843 emit_insn (gen_cmpsi (operands[2], operands[1]));
9db1d521
HP
4844 emit_jump_insn (gen_bgtu (label3));
4845 emit_insn (gen_cmpsi (operands[2], const1_rtx));
4846 emit_jump_insn (gen_blt (label2));
4847 emit_insn (gen_cmpsi (operands[2], const1_rtx));
4848 emit_jump_insn (gen_beq (label1));
4023fb28
UW
4849 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
4850 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
4851 operands[2]));
4852 REG_NOTES (insn) =
4853 gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
c7453384
EC
4854
4855 insn = emit_move_insn (operands[0],
4023fb28
UW
4856 gen_highpart (SImode, operands[3]));
4857 REG_NOTES (insn) =
c7453384 4858 gen_rtx_EXPR_LIST (REG_EQUAL,
4023fb28 4859 umod_equal, REG_NOTES (insn));
f314b9b1 4860 emit_jump (label3);
9db1d521 4861 emit_label (label1);
4023fb28 4862 emit_move_insn (operands[0], const0_rtx);
f314b9b1 4863 emit_jump (label3);
9db1d521 4864 emit_label (label2);
4023fb28 4865 emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
9db1d521
HP
4866 emit_label (label3);
4867 }
9db1d521 4868 DONE;
10bbf137 4869})
9db1d521
HP
4870
4871;
4872; divdf3 instruction pattern(s).
4873;
4874
4875(define_expand "divdf3"
553e5ce9
UW
4876 [(set (match_operand:DF 0 "register_operand" "=f,f")
4877 (div:DF (match_operand:DF 1 "register_operand" "0,0")
4878 (match_operand:DF 2 "general_operand" "f,R")))]
9db1d521
HP
4879 "TARGET_HARD_FLOAT"
4880 "")
4881
4882(define_insn "*divdf3"
4023fb28
UW
4883 [(set (match_operand:DF 0 "register_operand" "=f,f")
4884 (div:DF (match_operand:DF 1 "register_operand" "0,0")
553e5ce9 4885 (match_operand:DF 2 "general_operand" "f,R")))]
9db1d521
HP
4886 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4887 "@
d40c829f
UW
4888 ddbr\t%0,%2
4889 ddb\t%0,%2"
ce50cae8 4890 [(set_attr "op_type" "RRE,RXE")
077dab3b 4891 (set_attr "type" "fdivd")])
9db1d521
HP
4892
4893(define_insn "*divdf3_ibm"
4023fb28
UW
4894 [(set (match_operand:DF 0 "register_operand" "=f,f")
4895 (div:DF (match_operand:DF 1 "register_operand" "0,0")
553e5ce9 4896 (match_operand:DF 2 "general_operand" "f,R")))]
9db1d521
HP
4897 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4898 "@
d40c829f
UW
4899 ddr\t%0,%2
4900 dd\t%0,%2"
9db1d521 4901 [(set_attr "op_type" "RR,RX")
077dab3b 4902 (set_attr "type" "fdivd")])
9db1d521
HP
4903
4904;
4905; divsf3 instruction pattern(s).
4906;
4907
4908(define_expand "divsf3"
553e5ce9
UW
4909 [(set (match_operand:SF 0 "register_operand" "=f,f")
4910 (div:SF (match_operand:SF 1 "register_operand" "0,0")
4911 (match_operand:SF 2 "general_operand" "f,R")))]
9db1d521
HP
4912 "TARGET_HARD_FLOAT"
4913 "")
4914
4915(define_insn "*divsf3"
4023fb28
UW
4916 [(set (match_operand:SF 0 "register_operand" "=f,f")
4917 (div:SF (match_operand:SF 1 "register_operand" "0,0")
553e5ce9 4918 (match_operand:SF 2 "general_operand" "f,R")))]
9db1d521
HP
4919 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4920 "@
d40c829f
UW
4921 debr\t%0,%2
4922 deb\t%0,%2"
ce50cae8 4923 [(set_attr "op_type" "RRE,RXE")
077dab3b 4924 (set_attr "type" "fdivs")])
9db1d521
HP
4925
4926(define_insn "*divsf3"
4023fb28
UW
4927 [(set (match_operand:SF 0 "register_operand" "=f,f")
4928 (div:SF (match_operand:SF 1 "register_operand" "0,0")
553e5ce9 4929 (match_operand:SF 2 "general_operand" "f,R")))]
9db1d521
HP
4930 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4931 "@
d40c829f
UW
4932 der\t%0,%2
4933 de\t%0,%2"
9db1d521 4934 [(set_attr "op_type" "RR,RX")
077dab3b 4935 (set_attr "type" "fdivs")])
9db1d521
HP
4936
4937
4938;;
4939;;- And instructions.
4940;;
4941
4942;
4943; anddi3 instruction pattern(s).
4944;
4945
4946(define_insn "*anddi3_cc"
4947 [(set (reg 33)
96fd3851 4948 (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4023fb28 4949 (match_operand:DI 2 "general_operand" "d,m"))
9db1d521 4950 (const_int 0)))
4023fb28 4951 (set (match_operand:DI 0 "register_operand" "=d,d")
9db1d521
HP
4952 (and:DI (match_dup 1) (match_dup 2)))]
4953 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
4954 "@
d40c829f
UW
4955 ngr\t%0,%2
4956 ng\t%0,%2"
d3632d41 4957 [(set_attr "op_type" "RRE,RXY")])
9db1d521
HP
4958
4959(define_insn "*anddi3_cconly"
4960 [(set (reg 33)
96fd3851 4961 (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4023fb28 4962 (match_operand:DI 2 "general_operand" "d,m"))
9db1d521
HP
4963 (const_int 0)))
4964 (clobber (match_scratch:DI 0 "=d,d"))]
4965 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
4966 "@
d40c829f
UW
4967 ngr\t%0,%2
4968 ng\t%0,%2"
d3632d41 4969 [(set_attr "op_type" "RRE,RXY")])
9db1d521
HP
4970
4971(define_insn "anddi3"
f19a9af7
AK
4972 [(set (match_operand:DI 0 "register_operand" "=d,d,d,d,d,d,d,d")
4973 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o,0,0,0,0,0,0")
4974 (match_operand:DI 2 "general_operand"
4975 "M,M,N0HDF,N1HDF,N2HDF,N3HDF,d,m")))
4976 (clobber (reg:CC 33))]
4977 "TARGET_64BIT"
4978 "@
4979 #
4980 #
4981 nihh\t%0,%j2
4982 nihl\t%0,%j2
4983 nilh\t%0,%j2
4984 nill\t%0,%j2
4985 ngr\t%0,%2
4986 ng\t%0,%2"
4987 [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RRE,RXY")])
4023fb28
UW
4988
4989(define_insn "*anddi3_ss"
ccfc6cc8 4990 [(set (match_operand:DI 0 "s_operand" "=Q")
4023fb28 4991 (and:DI (match_dup 0)
ccfc6cc8 4992 (match_operand:DI 1 "s_imm_operand" "Q")))
4023fb28
UW
4993 (clobber (reg:CC 33))]
4994 ""
d40c829f 4995 "nc\t%O0(8,%R0),%1"
077dab3b 4996 [(set_attr "op_type" "SS")])
4023fb28
UW
4997
4998(define_insn "*anddi3_ss_inv"
ccfc6cc8
UW
4999 [(set (match_operand:DI 0 "s_operand" "=Q")
5000 (and:DI (match_operand:DI 1 "s_imm_operand" "Q")
4023fb28
UW
5001 (match_dup 0)))
5002 (clobber (reg:CC 33))]
5003 ""
d40c829f 5004 "nc\t%O0(8,%R0),%1"
077dab3b 5005 [(set_attr "op_type" "SS")])
9db1d521
HP
5006
5007;
5008; andsi3 instruction pattern(s).
5009;
5010
5011(define_insn "*andsi3_cc"
5012 [(set (reg 33)
d3632d41
UW
5013 (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5014 (match_operand:SI 2 "general_operand" "d,R,T"))
9db1d521 5015 (const_int 0)))
d3632d41 5016 (set (match_operand:SI 0 "register_operand" "=d,d,d")
9db1d521
HP
5017 (and:SI (match_dup 1) (match_dup 2)))]
5018 "s390_match_ccmode(insn, CCTmode)"
5019 "@
d40c829f
UW
5020 nr\t%0,%2
5021 n\t%0,%2
5022 ny\t%0,%2"
d3632d41 5023 [(set_attr "op_type" "RR,RX,RXY")])
9db1d521
HP
5024
5025(define_insn "*andsi3_cconly"
5026 [(set (reg 33)
d3632d41
UW
5027 (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5028 (match_operand:SI 2 "general_operand" "d,R,T"))
9db1d521 5029 (const_int 0)))
d3632d41 5030 (clobber (match_scratch:SI 0 "=d,d,d"))]
9db1d521
HP
5031 "s390_match_ccmode(insn, CCTmode)"
5032 "@
d40c829f
UW
5033 nr\t%0,%2
5034 n\t%0,%2
5035 ny\t%0,%2"
d3632d41 5036 [(set_attr "op_type" "RR,RX,RXY")])
9db1d521 5037
f19a9af7
AK
5038(define_expand "andsi3"
5039 [(parallel
5040 [(set (match_operand:SI 0 "register_operand" "")
5041 (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
5042 (match_operand:SI 2 "general_operand" "")))
5043 (clobber (reg:CC 33))])]
5044 ""
5045 "")
4023fb28 5046
f19a9af7
AK
5047(define_insn "*andsi3_zarch"
5048 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d,d,d")
5049 (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,o,0,0,0,0,0")
5050 (match_operand:SI 2 "general_operand" "M,M,N0HSF,N1HSF,d,R,T")))
9db1d521 5051 (clobber (reg:CC 33))]
f19a9af7 5052 "TARGET_ZARCH"
9db1d521 5053 "@
f19a9af7
AK
5054 #
5055 #
5056 nilh\t%0,%j2
5057 nill\t%0,%j2
d40c829f
UW
5058 nr\t%0,%2
5059 n\t%0,%2
5060 ny\t%0,%2"
f19a9af7
AK
5061 [(set_attr "op_type" "RRE,RXE,RI,RI,RR,RX,RXY")])
5062
5063(define_insn "*andsi3_esa"
5064 [(set (match_operand:SI 0 "register_operand" "=d,d")
5065 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
5066 (match_operand:SI 2 "general_operand" "d,R")))
5067 (clobber (reg:CC 33))]
5068 "!TARGET_ZARCH"
5069 "@
5070 nr\t%0,%2
5071 n\t%0,%2"
5072 [(set_attr "op_type" "RR,RX")])
4023fb28
UW
5073
5074(define_insn "*andsi3_ss"
ccfc6cc8 5075 [(set (match_operand:SI 0 "s_operand" "=Q")
4023fb28 5076 (and:SI (match_dup 0)
ccfc6cc8 5077 (match_operand:SI 1 "s_imm_operand" "Q")))
4023fb28
UW
5078 (clobber (reg:CC 33))]
5079 ""
d40c829f 5080 "nc\t%O0(4,%R0),%1"
077dab3b 5081 [(set_attr "op_type" "SS")])
4023fb28
UW
5082
5083(define_insn "*andsi3_ss_inv"
ccfc6cc8
UW
5084 [(set (match_operand:SI 0 "s_operand" "=Q")
5085 (and:SI (match_operand:SI 1 "s_imm_operand" "Q")
4023fb28
UW
5086 (match_dup 0)))
5087 (clobber (reg:CC 33))]
5088 ""
d40c829f 5089 "nc\t%O0(4,%R0),%1"
077dab3b 5090 [(set_attr "op_type" "SS")])
9db1d521
HP
5091
5092;
5093; andhi3 instruction pattern(s).
5094;
5095
4023fb28
UW
5096(define_insn "*andhi3_ni"
5097 [(set (match_operand:HI 0 "register_operand" "=d,d")
5098 (and:HI (match_operand:HI 1 "register_operand" "%0,0")
5099 (match_operand:HI 2 "nonmemory_operand" "d,n")))
5100 (clobber (reg:CC 33))]
9e8327e3 5101 "TARGET_ZARCH"
4023fb28 5102 "@
d40c829f
UW
5103 nr\t%0,%2
5104 nill\t%0,%x2"
077dab3b 5105 [(set_attr "op_type" "RR,RI")])
4023fb28
UW
5106
5107(define_insn "andhi3"
5108 [(set (match_operand:HI 0 "register_operand" "=d")
5109 (and:HI (match_operand:HI 1 "register_operand" "%0")
5110 (match_operand:HI 2 "nonmemory_operand" "d")))
5111 (clobber (reg:CC 33))]
9db1d521 5112 ""
d40c829f 5113 "nr\t%0,%2"
077dab3b 5114 [(set_attr "op_type" "RR")])
4023fb28
UW
5115
5116(define_insn "*andhi3_ss"
ccfc6cc8 5117 [(set (match_operand:HI 0 "s_operand" "=Q")
4023fb28 5118 (and:HI (match_dup 0)
ccfc6cc8 5119 (match_operand:HI 1 "s_imm_operand" "Q")))
4023fb28
UW
5120 (clobber (reg:CC 33))]
5121 ""
d40c829f 5122 "nc\t%O0(2,%R0),%1"
077dab3b 5123 [(set_attr "op_type" "SS")])
9db1d521 5124
4023fb28 5125(define_insn "*andhi3_ss_inv"
ccfc6cc8
UW
5126 [(set (match_operand:HI 0 "s_operand" "=Q")
5127 (and:HI (match_operand:HI 1 "s_imm_operand" "Q")
4023fb28 5128 (match_dup 0)))
9db1d521
HP
5129 (clobber (reg:CC 33))]
5130 ""
d40c829f 5131 "nc\t%O0(2,%R0),%1"
077dab3b 5132 [(set_attr "op_type" "SS")])
9db1d521
HP
5133
5134;
5135; andqi3 instruction pattern(s).
5136;
5137
4023fb28
UW
5138(define_insn "*andqi3_ni"
5139 [(set (match_operand:QI 0 "register_operand" "=d,d")
5140 (and:QI (match_operand:QI 1 "register_operand" "%0,0")
5141 (match_operand:QI 2 "nonmemory_operand" "d,n")))
5142 (clobber (reg:CC 33))]
9e8327e3 5143 "TARGET_ZARCH"
4023fb28 5144 "@
d40c829f
UW
5145 nr\t%0,%2
5146 nill\t%0,%b2"
077dab3b 5147 [(set_attr "op_type" "RR,RI")])
4023fb28 5148
9db1d521 5149(define_insn "andqi3"
4023fb28
UW
5150 [(set (match_operand:QI 0 "register_operand" "=d")
5151 (and:QI (match_operand:QI 1 "register_operand" "%0")
5152 (match_operand:QI 2 "nonmemory_operand" "d")))
5153 (clobber (reg:CC 33))]
5154 ""
d40c829f 5155 "nr\t%0,%2"
077dab3b 5156 [(set_attr "op_type" "RR")])
4023fb28
UW
5157
5158(define_insn "*andqi3_ss"
d3632d41 5159 [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
4023fb28 5160 (and:QI (match_dup 0)
d3632d41 5161 (match_operand:QI 1 "s_imm_operand" "n,n,Q")))
9db1d521
HP
5162 (clobber (reg:CC 33))]
5163 ""
5164 "@
d40c829f
UW
5165 ni\t%0,%b1
5166 niy\t%0,%b1
5167 nc\t%O0(1,%R0),%1"
d3632d41 5168 [(set_attr "op_type" "SI,SIY,SS")])
4023fb28
UW
5169
5170(define_insn "*andqi3_ss_inv"
d3632d41
UW
5171 [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5172 (and:QI (match_operand:QI 1 "s_imm_operand" "n,n,Q")
4023fb28
UW
5173 (match_dup 0)))
5174 (clobber (reg:CC 33))]
5175 ""
5176 "@
d40c829f
UW
5177 ni\t%0,%b1
5178 niy\t%0,%b1
5179 nc\t%O0(1,%R0),%1"
d3632d41 5180 [(set_attr "op_type" "SI,SIY,SS")])
9db1d521
HP
5181
5182
5183;;
5184;;- Bit set (inclusive or) instructions.
5185;;
5186
5187;
5188; iordi3 instruction pattern(s).
5189;
5190
4023fb28
UW
5191(define_insn "*iordi3_cc"
5192 [(set (reg 33)
96fd3851 5193 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4023fb28
UW
5194 (match_operand:DI 2 "general_operand" "d,m"))
5195 (const_int 0)))
5196 (set (match_operand:DI 0 "register_operand" "=d,d")
5197 (ior:DI (match_dup 1) (match_dup 2)))]
5198 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5199 "@
d40c829f
UW
5200 ogr\t%0,%2
5201 og\t%0,%2"
d3632d41 5202 [(set_attr "op_type" "RRE,RXY")])
4023fb28
UW
5203
5204(define_insn "*iordi3_cconly"
5205 [(set (reg 33)
96fd3851 5206 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4023fb28
UW
5207 (match_operand:DI 2 "general_operand" "d,m"))
5208 (const_int 0)))
5209 (clobber (match_scratch:DI 0 "=d,d"))]
5210 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5211 "@
d40c829f
UW
5212 ogr\t%0,%2
5213 og\t%0,%2"
d3632d41 5214 [(set_attr "op_type" "RRE,RXY")])
4023fb28 5215
9db1d521 5216(define_insn "iordi3"
f19a9af7
AK
5217 [(set (match_operand:DI 0 "register_operand" "=d,d,d,d,d,d")
5218 (ior:DI (match_operand:DI 1 "nonimmediate_operand" "0,0,0,0,0,0")
5219 (match_operand:DI 2 "general_operand" "N0HD0,N1HD0,N2HD0,N3HD0,d,m")))
9db1d521
HP
5220 (clobber (reg:CC 33))]
5221 "TARGET_64BIT"
5222 "@
f19a9af7
AK
5223 oihh\t%0,%i2
5224 oihl\t%0,%i2
5225 oilh\t%0,%i2
5226 oill\t%0,%i2
d40c829f
UW
5227 ogr\t%0,%2
5228 og\t%0,%2"
f19a9af7 5229 [(set_attr "op_type" "RI,RI,RI,RI,RRE,RXY")])
4023fb28
UW
5230
5231(define_insn "*iordi3_ss"
ccfc6cc8 5232 [(set (match_operand:DI 0 "s_operand" "=Q")
4023fb28 5233 (ior:DI (match_dup 0)
ccfc6cc8 5234 (match_operand:DI 1 "s_imm_operand" "Q")))
4023fb28
UW
5235 (clobber (reg:CC 33))]
5236 ""
d40c829f 5237 "oc\t%O0(8,%R0),%1"
077dab3b 5238 [(set_attr "op_type" "SS")])
4023fb28
UW
5239
5240(define_insn "*iordi3_ss_inv"
ccfc6cc8
UW
5241 [(set (match_operand:DI 0 "s_operand" "=Q")
5242 (ior:DI (match_operand:DI 1 "s_imm_operand" "Q")
4023fb28
UW
5243 (match_dup 0)))
5244 (clobber (reg:CC 33))]
5245 ""
d40c829f 5246 "oc\t%O0(8,%R0),%1"
077dab3b 5247 [(set_attr "op_type" "SS")])
9db1d521
HP
5248
5249;
5250; iorsi3 instruction pattern(s).
5251;
5252
4023fb28
UW
5253(define_insn "*iorsi3_cc"
5254 [(set (reg 33)
d3632d41
UW
5255 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5256 (match_operand:SI 2 "general_operand" "d,R,T"))
4023fb28 5257 (const_int 0)))
d3632d41 5258 (set (match_operand:SI 0 "register_operand" "=d,d,d")
4023fb28
UW
5259 (ior:SI (match_dup 1) (match_dup 2)))]
5260 "s390_match_ccmode(insn, CCTmode)"
5261 "@
d40c829f
UW
5262 or\t%0,%2
5263 o\t%0,%2
5264 oy\t%0,%2"
d3632d41 5265 [(set_attr "op_type" "RR,RX,RXY")])
4023fb28
UW
5266
5267(define_insn "*iorsi3_cconly"
5268 [(set (reg 33)
d3632d41
UW
5269 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5270 (match_operand:SI 2 "general_operand" "d,R,T"))
4023fb28 5271 (const_int 0)))
d3632d41 5272 (clobber (match_scratch:SI 0 "=d,d,d"))]
4023fb28
UW
5273 "s390_match_ccmode(insn, CCTmode)"
5274 "@
d40c829f
UW
5275 or\t%0,%2
5276 o\t%0,%2
5277 oy\t%0,%2"
d3632d41 5278 [(set_attr "op_type" "RR,RX,RXY")])
4023fb28 5279
f19a9af7
AK
5280(define_expand "iorsi3"
5281 [(parallel
5282 [(set (match_operand:SI 0 "register_operand" "")
5283 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "")
5284 (match_operand:SI 2 "general_operand" "")))
5285 (clobber (reg:CC 33))])]
5286 ""
5287 "")
4023fb28 5288
f19a9af7
AK
5289(define_insn "iorsi3_zarch"
5290 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
5291 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "0,0,0,0,0")
5292 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,d,R,T")))
4023fb28 5293 (clobber (reg:CC 33))]
f19a9af7 5294 "TARGET_ZARCH"
4023fb28 5295 "@
f19a9af7
AK
5296 oilh\t%0,%i2
5297 oill\t%0,%i2
d40c829f
UW
5298 or\t%0,%2
5299 o\t%0,%2
5300 oy\t%0,%2"
f19a9af7
AK
5301 [(set_attr "op_type" "RI,RI,RR,RX,RXY")])
5302
5303(define_insn "iorsi3_esa"
5304 [(set (match_operand:SI 0 "register_operand" "=d,d")
5305 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
5306 (match_operand:SI 2 "general_operand" "d,R")))
5307 (clobber (reg:CC 33))]
5308 "!TARGET_ZARCH"
5309 "@
5310 or\t%0,%2
5311 o\t%0,%2"
5312 [(set_attr "op_type" "RR,RX")])
4023fb28
UW
5313
5314(define_insn "*iorsi3_ss"
ccfc6cc8 5315 [(set (match_operand:SI 0 "s_operand" "=Q")
4023fb28 5316 (ior:SI (match_dup 0)
ccfc6cc8 5317 (match_operand:SI 1 "s_imm_operand" "Q")))
4023fb28
UW
5318 (clobber (reg:CC 33))]
5319 ""
d40c829f 5320 "oc\t%O0(4,%R0),%1"
077dab3b 5321 [(set_attr "op_type" "SS")])
4023fb28
UW
5322
5323(define_insn "*iorsi3_ss_inv"
ccfc6cc8
UW
5324 [(set (match_operand:SI 0 "s_operand" "=Q")
5325 (ior:SI (match_operand:SI 1 "s_imm_operand" "Q")
4023fb28
UW
5326 (match_dup 0)))
5327 (clobber (reg:CC 33))]
5328 ""
d40c829f 5329 "oc\t%O0(4,%R0),%1"
077dab3b 5330 [(set_attr "op_type" "SS")])
4023fb28
UW
5331
5332;
5333; iorhi3 instruction pattern(s).
5334;
5335
5336(define_insn "*iorhi3_oi"
5337 [(set (match_operand:HI 0 "register_operand" "=d,d")
5338 (ior:HI (match_operand:HI 1 "register_operand" "%0,0")
5339 (match_operand:HI 2 "nonmemory_operand" "d,n")))
5340 (clobber (reg:CC 33))]
9e8327e3 5341 "TARGET_ZARCH"
4023fb28 5342 "@
d40c829f
UW
5343 or\t%0,%2
5344 oill\t%0,%x2"
077dab3b 5345 [(set_attr "op_type" "RR,RI")])
4023fb28
UW
5346
5347(define_insn "iorhi3"
5348 [(set (match_operand:HI 0 "register_operand" "=d")
5349 (ior:HI (match_operand:HI 1 "register_operand" "%0")
5350 (match_operand:HI 2 "nonmemory_operand" "d")))
5351 (clobber (reg:CC 33))]
9db1d521 5352 ""
d40c829f 5353 "or\t%0,%2"
077dab3b 5354 [(set_attr "op_type" "RR")])
4023fb28
UW
5355
5356(define_insn "*iorhi3_ss"
ccfc6cc8 5357 [(set (match_operand:HI 0 "s_operand" "=Q")
4023fb28 5358 (ior:HI (match_dup 0)
ccfc6cc8 5359 (match_operand:HI 1 "s_imm_operand" "Q")))
4023fb28
UW
5360 (clobber (reg:CC 33))]
5361 ""
d40c829f 5362 "oc\t%O0(2,%R0),%1"
077dab3b 5363 [(set_attr "op_type" "SS")])
9db1d521 5364
4023fb28 5365(define_insn "*iorhi3_ss_inv"
ccfc6cc8
UW
5366 [(set (match_operand:HI 0 "s_operand" "=Q")
5367 (ior:HI (match_operand:HI 1 "s_imm_operand" "Q")
4023fb28 5368 (match_dup 0)))
9db1d521
HP
5369 (clobber (reg:CC 33))]
5370 ""
d40c829f 5371 "oc\t%O0(2,%R0),%1"
077dab3b 5372 [(set_attr "op_type" "SS")])
9db1d521
HP
5373
5374;
4023fb28 5375; iorqi3 instruction pattern(s).
9db1d521
HP
5376;
5377
4023fb28
UW
5378(define_insn "*iorqi3_oi"
5379 [(set (match_operand:QI 0 "register_operand" "=d,d")
5380 (ior:QI (match_operand:QI 1 "register_operand" "%0,0")
5381 (match_operand:QI 2 "nonmemory_operand" "d,n")))
5382 (clobber (reg:CC 33))]
9e8327e3 5383 "TARGET_ZARCH"
4023fb28 5384 "@
d40c829f
UW
5385 or\t%0,%2
5386 oill\t%0,%b2"
077dab3b 5387 [(set_attr "op_type" "RR,RI")])
9db1d521 5388
4023fb28
UW
5389(define_insn "iorqi3"
5390 [(set (match_operand:QI 0 "register_operand" "=d")
5391 (ior:QI (match_operand:QI 1 "register_operand" "%0")
5392 (match_operand:QI 2 "nonmemory_operand" "d")))
5393 (clobber (reg:CC 33))]
5394 ""
d40c829f 5395 "or\t%0,%2"
077dab3b 5396 [(set_attr "op_type" "RR")])
4023fb28
UW
5397
5398(define_insn "*iorqi3_ss"
d3632d41 5399 [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
4023fb28 5400 (ior:QI (match_dup 0)
d3632d41 5401 (match_operand:QI 1 "s_imm_operand" "n,n,Q")))
9db1d521
HP
5402 (clobber (reg:CC 33))]
5403 ""
5404 "@
d40c829f
UW
5405 oi\t%0,%b1
5406 oiy\t%0,%b1
5407 oc\t%O0(1,%R0),%1"
d3632d41 5408 [(set_attr "op_type" "SI,SIY,SS")])
9db1d521 5409
4023fb28 5410(define_insn "*iorqi3_ss_inv"
d3632d41
UW
5411 [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5412 (ior:QI (match_operand:QI 1 "s_imm_operand" "n,n,Q")
4023fb28 5413 (match_dup 0)))
9db1d521
HP
5414 (clobber (reg:CC 33))]
5415 ""
5416 "@
d40c829f
UW
5417 oi\t%0,%b1
5418 oiy\t%0,%b1
5419 oc\t%O0(1,%R0),%1"
d3632d41 5420 [(set_attr "op_type" "SI,SIY,SS")])
9db1d521
HP
5421
5422
5423;;
5424;;- Xor instructions.
5425;;
5426
5427;
5428; xordi3 instruction pattern(s).
5429;
5430
4023fb28
UW
5431(define_insn "*xordi3_cc"
5432 [(set (reg 33)
96fd3851 5433 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4023fb28
UW
5434 (match_operand:DI 2 "general_operand" "d,m"))
5435 (const_int 0)))
5436 (set (match_operand:DI 0 "register_operand" "=d,d")
5437 (xor:DI (match_dup 1) (match_dup 2)))]
5438 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5439 "@
d40c829f
UW
5440 xgr\t%0,%2
5441 xg\t%0,%2"
d3632d41 5442 [(set_attr "op_type" "RRE,RXY")])
4023fb28
UW
5443
5444(define_insn "*xordi3_cconly"
5445 [(set (reg 33)
96fd3851 5446 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4023fb28
UW
5447 (match_operand:DI 2 "general_operand" "d,m"))
5448 (const_int 0)))
5449 (clobber (match_scratch:DI 0 "=d,d"))]
5450 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5451 "@
d40c829f
UW
5452 xgr\t%0,%2
5453 xr\t%0,%2"
d3632d41 5454 [(set_attr "op_type" "RRE,RXY")])
4023fb28 5455
9db1d521 5456(define_insn "xordi3"
4023fb28 5457 [(set (match_operand:DI 0 "register_operand" "=d,d")
96fd3851 5458 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4023fb28 5459 (match_operand:DI 2 "general_operand" "d,m")))
9db1d521
HP
5460 (clobber (reg:CC 33))]
5461 "TARGET_64BIT"
5462 "@
d40c829f
UW
5463 xgr\t%0,%2
5464 xg\t%0,%2"
d3632d41 5465 [(set_attr "op_type" "RRE,RXY")])
4023fb28
UW
5466
5467(define_insn "*xordi3_ss"
ccfc6cc8 5468 [(set (match_operand:DI 0 "s_operand" "=Q")
4023fb28 5469 (xor:DI (match_dup 0)
ccfc6cc8 5470 (match_operand:DI 1 "s_imm_operand" "Q")))
4023fb28
UW
5471 (clobber (reg:CC 33))]
5472 ""
d40c829f 5473 "xc\t%O0(8,%R0),%1"
077dab3b 5474 [(set_attr "op_type" "SS")])
4023fb28
UW
5475
5476(define_insn "*xordi3_ss_inv"
ccfc6cc8
UW
5477 [(set (match_operand:DI 0 "s_operand" "=Q")
5478 (xor:DI (match_operand:DI 1 "s_imm_operand" "Q")
4023fb28
UW
5479 (match_dup 0)))
5480 (clobber (reg:CC 33))]
5481 ""
d40c829f 5482 "xc\t%O0(8,%R0),%1"
077dab3b 5483 [(set_attr "op_type" "SS")])
9db1d521
HP
5484
5485;
5486; xorsi3 instruction pattern(s).
5487;
5488
4023fb28
UW
5489(define_insn "*xorsi3_cc"
5490 [(set (reg 33)
d3632d41
UW
5491 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5492 (match_operand:SI 2 "general_operand" "d,R,T"))
4023fb28 5493 (const_int 0)))
d3632d41 5494 (set (match_operand:SI 0 "register_operand" "=d,d,d")
4023fb28
UW
5495 (xor:SI (match_dup 1) (match_dup 2)))]
5496 "s390_match_ccmode(insn, CCTmode)"
5497 "@
d40c829f
UW
5498 xr\t%0,%2
5499 x\t%0,%2
5500 xy\t%0,%2"
d3632d41 5501 [(set_attr "op_type" "RR,RX,RXY")])
4023fb28
UW
5502
5503(define_insn "*xorsi3_cconly"
5504 [(set (reg 33)
d3632d41
UW
5505 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5506 (match_operand:SI 2 "general_operand" "d,R,T"))
4023fb28 5507 (const_int 0)))
d3632d41 5508 (clobber (match_scratch:SI 0 "=d,d,d"))]
4023fb28
UW
5509 "s390_match_ccmode(insn, CCTmode)"
5510 "@
d40c829f
UW
5511 xr\t%0,%2
5512 x\t%0,%2
5513 xy\t%0,%2"
d3632d41 5514 [(set_attr "op_type" "RR,RX,RXY")])
9db1d521 5515
4023fb28 5516(define_insn "xorsi3"
d3632d41
UW
5517 [(set (match_operand:SI 0 "register_operand" "=d,d,d")
5518 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5519 (match_operand:SI 2 "general_operand" "d,R,T")))
9db1d521
HP
5520 (clobber (reg:CC 33))]
5521 ""
5522 "@
d40c829f
UW
5523 xr\t%0,%2
5524 x\t%0,%2
5525 xy\t%0,%2"
d3632d41 5526 [(set_attr "op_type" "RR,RX,RXY")])
4023fb28
UW
5527
5528(define_insn "*xorsi3_ss"
ccfc6cc8 5529 [(set (match_operand:SI 0 "s_operand" "=Q")
4023fb28 5530 (xor:SI (match_dup 0)
ccfc6cc8 5531 (match_operand:SI 1 "s_imm_operand" "Q")))
4023fb28
UW
5532 (clobber (reg:CC 33))]
5533 ""
d40c829f 5534 "xc\t%O0(4,%R0),%1"
077dab3b 5535 [(set_attr "op_type" "SS")])
4023fb28
UW
5536
5537(define_insn "*xorsi3_ss_inv"
ccfc6cc8
UW
5538 [(set (match_operand:SI 0 "s_operand" "=Q")
5539 (xor:SI (match_operand:SI 1 "s_imm_operand" "Q")
4023fb28
UW
5540 (match_dup 0)))
5541 (clobber (reg:CC 33))]
5542 ""
d40c829f 5543 "xc\t%O0(4,%R0),%1"
077dab3b 5544 [(set_attr "op_type" "SS")])
9db1d521
HP
5545
5546;
5547; xorhi3 instruction pattern(s).
5548;
5549
4023fb28
UW
5550(define_insn "xorhi3"
5551 [(set (match_operand:HI 0 "register_operand" "=d")
5552 (xor:HI (match_operand:HI 1 "register_operand" "%0")
5553 (match_operand:HI 2 "nonmemory_operand" "d")))
5554 (clobber (reg:CC 33))]
9db1d521 5555 ""
d40c829f 5556 "xr\t%0,%2"
d3632d41 5557 [(set_attr "op_type" "RR")])
4023fb28
UW
5558
5559(define_insn "*xorhi3_ss"
ccfc6cc8 5560 [(set (match_operand:HI 0 "s_operand" "=Q")
4023fb28 5561 (xor:HI (match_dup 0)
ccfc6cc8 5562 (match_operand:HI 1 "s_imm_operand" "Q")))
4023fb28
UW
5563 (clobber (reg:CC 33))]
5564 ""
d40c829f 5565 "xc\t%O0(2,%R0),%1"
077dab3b 5566 [(set_attr "op_type" "SS")])
9db1d521 5567
4023fb28 5568(define_insn "*xorhi3_ss_inv"
ccfc6cc8
UW
5569 [(set (match_operand:HI 0 "s_operand" "=Q")
5570 (xor:HI (match_operand:HI 1 "s_imm_operand" "Q")
4023fb28 5571 (match_dup 0)))
9db1d521
HP
5572 (clobber (reg:CC 33))]
5573 ""
d40c829f 5574 "xc\t%O0(2,%R0),%1"
077dab3b 5575 [(set_attr "op_type" "SS")])
9db1d521
HP
5576
5577;
5578; xorqi3 instruction pattern(s).
5579;
5580
5581(define_insn "xorqi3"
4023fb28
UW
5582 [(set (match_operand:QI 0 "register_operand" "=d")
5583 (xor:QI (match_operand:QI 1 "register_operand" "%0")
5584 (match_operand:QI 2 "nonmemory_operand" "d")))
5585 (clobber (reg:CC 33))]
5586 ""
d40c829f 5587 "xr\t%0,%2"
077dab3b 5588 [(set_attr "op_type" "RR")])
4023fb28
UW
5589
5590(define_insn "*xorqi3_ss"
d3632d41 5591 [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
4023fb28 5592 (xor:QI (match_dup 0)
d3632d41 5593 (match_operand:QI 1 "s_imm_operand" "n,n,Q")))
9db1d521
HP
5594 (clobber (reg:CC 33))]
5595 ""
5596 "@
d40c829f
UW
5597 xi\t%0,%b1
5598 xiy\t%0,%b1
5599 xc\t%O0(1,%R0),%1"
d3632d41 5600 [(set_attr "op_type" "SI,SIY,SS")])
4023fb28
UW
5601
5602(define_insn "*xorqi3_ss_inv"
d3632d41
UW
5603 [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5604 (xor:QI (match_operand:QI 1 "s_imm_operand" "n,n,Q")
4023fb28
UW
5605 (match_dup 0)))
5606 (clobber (reg:CC 33))]
5607 ""
5608 "@
d40c829f
UW
5609 xi\t%0,%b1
5610 xiy\t%0,%b1
5611 xc\t%O0(1,%R0),%1"
d3632d41 5612 [(set_attr "op_type" "SI,SIY,SS")])
9db1d521
HP
5613
5614
5615;;
5616;;- Negate instructions.
5617;;
5618
5619;
5620; negdi2 instruction pattern(s).
5621;
5622
5623(define_expand "negdi2"
5624 [(parallel
5625 [(set (match_operand:DI 0 "register_operand" "=d")
5626 (neg:DI (match_operand:DI 1 "register_operand" "d")))
5627 (clobber (reg:CC 33))])]
5628 ""
5629 "")
5630
5631(define_insn "*negdi2_64"
5632 [(set (match_operand:DI 0 "register_operand" "=d")
5633 (neg:DI (match_operand:DI 1 "register_operand" "d")))
5634 (clobber (reg:CC 33))]
5635 "TARGET_64BIT"
d40c829f 5636 "lcgr\t%0,%1"
f2d3c02a 5637 [(set_attr "op_type" "RR")])
9db1d521
HP
5638
5639(define_insn "*negdi2_31"
5640 [(set (match_operand:DI 0 "register_operand" "=d")
5641 (neg:DI (match_operand:DI 1 "register_operand" "d")))
5642 (clobber (reg:CC 33))]
5643 "!TARGET_64BIT"
9db1d521
HP
5644{
5645 rtx xop[1];
5646 xop[0] = gen_label_rtx ();
d40c829f
UW
5647 output_asm_insn ("lcr\t%0,%1", operands);
5648 output_asm_insn ("lcr\t%N0,%N1", operands);
5649 output_asm_insn ("je\t%l0", xop);
5650 output_asm_insn ("bctr\t%0,0", operands);
47798692 5651 targetm.asm_out.internal_label (asm_out_file, "L",
9db1d521 5652 CODE_LABEL_NUMBER (xop[0]));
10bbf137
UW
5653 return "";
5654}
9db1d521 5655 [(set_attr "op_type" "NN")
4023fb28
UW
5656 (set_attr "type" "other")
5657 (set_attr "length" "10")])
9db1d521
HP
5658
5659;
5660; negsi2 instruction pattern(s).
5661;
5662
5663(define_insn "negsi2"
5664 [(set (match_operand:SI 0 "register_operand" "=d")
5665 (neg:SI (match_operand:SI 1 "register_operand" "d")))
5666 (clobber (reg:CC 33))]
5667 ""
d40c829f 5668 "lcr\t%0,%1"
f2d3c02a 5669 [(set_attr "op_type" "RR")])
9db1d521
HP
5670
5671;
5672; negdf2 instruction pattern(s).
5673;
5674
5675(define_expand "negdf2"
5676 [(parallel
5677 [(set (match_operand:DF 0 "register_operand" "=f")
5678 (neg:DF (match_operand:DF 1 "register_operand" "f")))
5679 (clobber (reg:CC 33))])]
5680 "TARGET_HARD_FLOAT"
5681 "")
5682
5683(define_insn "*negdf2"
5684 [(set (match_operand:DF 0 "register_operand" "=f")
5685 (neg:DF (match_operand:DF 1 "register_operand" "f")))
5686 (clobber (reg:CC 33))]
5687 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 5688 "lcdbr\t%0,%1"
077dab3b
HP
5689 [(set_attr "op_type" "RRE")
5690 (set_attr "type" "fsimpd")])
9db1d521
HP
5691
5692(define_insn "*negdf2_ibm"
5693 [(set (match_operand:DF 0 "register_operand" "=f")
5694 (neg:DF (match_operand:DF 1 "register_operand" "f")))
5695 (clobber (reg:CC 33))]
5696 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
d40c829f 5697 "lcdr\t%0,%1"
077dab3b
HP
5698 [(set_attr "op_type" "RR")
5699 (set_attr "type" "fsimpd")])
9db1d521
HP
5700
5701;
5702; negsf2 instruction pattern(s).
5703;
5704
5705(define_expand "negsf2"
5706 [(parallel
5707 [(set (match_operand:SF 0 "register_operand" "=f")
5708 (neg:SF (match_operand:SF 1 "register_operand" "f")))
5709 (clobber (reg:CC 33))])]
5710 "TARGET_HARD_FLOAT"
5711 "")
5712
5713(define_insn "*negsf2"
5714 [(set (match_operand:SF 0 "register_operand" "=f")
5715 (neg:SF (match_operand:SF 1 "register_operand" "f")))
5716 (clobber (reg:CC 33))]
5717 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 5718 "lcebr\t%0,%1"
077dab3b
HP
5719 [(set_attr "op_type" "RRE")
5720 (set_attr "type" "fsimps")])
9db1d521
HP
5721
5722(define_insn "*negsf2"
5723 [(set (match_operand:SF 0 "register_operand" "=f")
5724 (neg:SF (match_operand:SF 1 "register_operand" "f")))
5725 (clobber (reg:CC 33))]
5726 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
d40c829f 5727 "lcer\t%0,%1"
077dab3b
HP
5728 [(set_attr "op_type" "RR")
5729 (set_attr "type" "fsimps")])
9db1d521
HP
5730
5731
5732;;
5733;;- Absolute value instructions.
5734;;
5735
5736;
5737; absdi2 instruction pattern(s).
5738;
5739
5740(define_insn "absdi2"
5741 [(set (match_operand:DI 0 "register_operand" "=d")
5742 (abs:DI (match_operand:DI 1 "register_operand" "d")))
5743 (clobber (reg:CC 33))]
5744 "TARGET_64BIT"
d40c829f 5745 "lpgr\t%0,%1"
f2d3c02a 5746 [(set_attr "op_type" "RRE")])
9db1d521
HP
5747
5748;
5749; abssi2 instruction pattern(s).
5750;
5751
5752(define_insn "abssi2"
5753 [(set (match_operand:SI 0 "register_operand" "=d")
5754 (abs:SI (match_operand:SI 1 "register_operand" "d")))
5755 (clobber (reg:CC 33))]
5756 ""
d40c829f 5757 "lpr\t%0,%1"
f2d3c02a 5758 [(set_attr "op_type" "RR")])
9db1d521 5759
9db1d521
HP
5760;
5761; absdf2 instruction pattern(s).
5762;
5763
5764(define_expand "absdf2"
5765 [(parallel
5766 [(set (match_operand:DF 0 "register_operand" "=f")
5767 (abs:DF (match_operand:DF 1 "register_operand" "f")))
5768 (clobber (reg:CC 33))])]
5769 "TARGET_HARD_FLOAT"
5770 "")
5771
5772(define_insn "*absdf2"
5773 [(set (match_operand:DF 0 "register_operand" "=f")
5774 (abs:DF (match_operand:DF 1 "register_operand" "f")))
5775 (clobber (reg:CC 33))]
5776 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 5777 "lpdbr\t%0,%1"
077dab3b
HP
5778 [(set_attr "op_type" "RRE")
5779 (set_attr "type" "fsimpd")])
9db1d521
HP
5780
5781(define_insn "*absdf2_ibm"
5782 [(set (match_operand:DF 0 "register_operand" "=f")
5783 (abs:DF (match_operand:DF 1 "register_operand" "f")))
5784 (clobber (reg:CC 33))]
5785 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
d40c829f 5786 "lpdr\t%0,%1"
077dab3b
HP
5787 [(set_attr "op_type" "RR")
5788 (set_attr "type" "fsimpd")])
9db1d521
HP
5789
5790;
5791; abssf2 instruction pattern(s).
5792;
5793
5794(define_expand "abssf2"
5795 [(parallel
5796 [(set (match_operand:SF 0 "register_operand" "=f")
5797 (abs:SF (match_operand:SF 1 "register_operand" "f")))
5798 (clobber (reg:CC 33))])]
5799 "TARGET_HARD_FLOAT"
5800 "")
5801
5802(define_insn "*abssf2"
5803 [(set (match_operand:SF 0 "register_operand" "=f")
5804 (abs:SF (match_operand:SF 1 "register_operand" "f")))
5805 (clobber (reg:CC 33))]
5806 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 5807 "lpebr\t%0,%1"
077dab3b
HP
5808 [(set_attr "op_type" "RRE")
5809 (set_attr "type" "fsimps")])
9db1d521
HP
5810
5811(define_insn "*abssf2_ibm"
5812 [(set (match_operand:SF 0 "register_operand" "=f")
5813 (abs:SF (match_operand:SF 1 "register_operand" "f")))
5814 (clobber (reg:CC 33))]
5815 "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
d40c829f 5816 "lper\t%0,%1"
077dab3b
HP
5817 [(set_attr "op_type" "RR")
5818 (set_attr "type" "fsimps")])
9db1d521 5819
3ef093a8
AK
5820;;
5821;;- Negated absolute value instructions
5822;;
5823
5824;
5825; Integer
5826;
5827
5828(define_insn "*negabssi2"
5829 [(set (match_operand:SI 0 "register_operand" "=d")
5830 (neg:SI (abs:SI (match_operand:SI 1 "register_operand" "d"))))
5831 (clobber (reg:CC 33))]
5832 ""
d40c829f 5833 "lnr\t%0,%1"
3ef093a8
AK
5834 [(set_attr "op_type" "RR")])
5835
5836(define_insn "*negabsdi2"
5837 [(set (match_operand:DI 0 "register_operand" "=d")
5838 (neg:DI (abs:DI (match_operand:DI 1 "register_operand" "d"))))
5839 (clobber (reg:CC 33))]
5840 "TARGET_64BIT"
d40c829f 5841 "lngr\t%0,%1"
3ef093a8
AK
5842 [(set_attr "op_type" "RRE")])
5843
5844;
5845; Floating point
5846;
5847
5848(define_insn "*negabssf2"
5849 [(set (match_operand:SF 0 "register_operand" "=f")
5850 (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
5851 (clobber (reg:CC 33))]
5852 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 5853 "lnebr\t%0,%1"
3ef093a8
AK
5854 [(set_attr "op_type" "RRE")
5855 (set_attr "type" "fsimps")])
5856
5857(define_insn "*negabsdf2"
5858 [(set (match_operand:DF 0 "register_operand" "=f")
5859 (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
5860 (clobber (reg:CC 33))]
5861 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
d40c829f 5862 "lndbr\t%0,%1"
3ef093a8
AK
5863 [(set_attr "op_type" "RRE")
5864 (set_attr "type" "fsimpd")])
5865
4023fb28
UW
5866;;
5867;;- Square root instructions.
5868;;
5869
5870;
5871; sqrtdf2 instruction pattern(s).
5872;
5873
5874(define_insn "sqrtdf2"
5875 [(set (match_operand:DF 0 "register_operand" "=f,f")
d3632d41 5876 (sqrt:DF (match_operand:DF 1 "general_operand" "f,R")))]
4023fb28
UW
5877 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5878 "@
d40c829f
UW
5879 sqdbr\t%0,%1
5880 sqdb\t%0,%1"
d3632d41 5881 [(set_attr "op_type" "RRE,RXE")])
4023fb28
UW
5882
5883;
5884; sqrtsf2 instruction pattern(s).
5885;
5886
5887(define_insn "sqrtsf2"
5888 [(set (match_operand:SF 0 "register_operand" "=f,f")
d3632d41 5889 (sqrt:SF (match_operand:SF 1 "general_operand" "f,R")))]
4023fb28
UW
5890 "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5891 "@
d40c829f
UW
5892 sqebr\t%0,%1
5893 sqeb\t%0,%1"
d3632d41 5894 [(set_attr "op_type" "RRE,RXE")])
9db1d521
HP
5895
5896;;
5897;;- One complement instructions.
5898;;
5899
5900;
5901; one_cmpldi2 instruction pattern(s).
5902;
c7453384 5903
9db1d521
HP
5904(define_expand "one_cmpldi2"
5905 [(parallel
4023fb28
UW
5906 [(set (match_operand:DI 0 "register_operand" "")
5907 (xor:DI (match_operand:DI 1 "register_operand" "")
5908 (const_int -1)))
9db1d521
HP
5909 (clobber (reg:CC 33))])]
5910 "TARGET_64BIT"
4023fb28 5911 "")
c7453384 5912
9db1d521
HP
5913;
5914; one_cmplsi2 instruction pattern(s).
5915;
c7453384 5916
9db1d521
HP
5917(define_expand "one_cmplsi2"
5918 [(parallel
4023fb28
UW
5919 [(set (match_operand:SI 0 "register_operand" "")
5920 (xor:SI (match_operand:SI 1 "register_operand" "")
5921 (const_int -1)))
9db1d521
HP
5922 (clobber (reg:CC 33))])]
5923 ""
4023fb28 5924 "")
c7453384 5925
9db1d521
HP
5926;
5927; one_cmplhi2 instruction pattern(s).
5928;
c7453384 5929
9db1d521
HP
5930(define_expand "one_cmplhi2"
5931 [(parallel
4023fb28
UW
5932 [(set (match_operand:HI 0 "register_operand" "")
5933 (xor:HI (match_operand:HI 1 "register_operand" "")
5934 (const_int -1)))
9db1d521
HP
5935 (clobber (reg:CC 33))])]
5936 ""
4023fb28 5937 "")
c7453384 5938
9db1d521
HP
5939;
5940; one_cmplqi2 instruction pattern(s).
5941;
c7453384 5942
4023fb28
UW
5943(define_expand "one_cmplqi2"
5944 [(parallel
5945 [(set (match_operand:QI 0 "register_operand" "")
5946 (xor:QI (match_operand:QI 1 "register_operand" "")
5947 (const_int -1)))
5948 (clobber (reg:CC 33))])]
9db1d521 5949 ""
4023fb28 5950 "")
9db1d521
HP
5951
5952
5953;;
5954;;- Rotate instructions.
5955;;
5956
5957;
5958; rotldi3 instruction pattern(s).
5959;
5960
5961(define_insn "rotldi3"
ac32b25e
UW
5962 [(set (match_operand:DI 0 "register_operand" "=d")
5963 (rotate:DI (match_operand:DI 1 "register_operand" "d")
5964 (match_operand:SI 2 "shift_count_operand" "Y")))]
9db1d521 5965 "TARGET_64BIT"
ac32b25e 5966 "rllg\t%0,%1,%Y2"
077dab3b
HP
5967 [(set_attr "op_type" "RSE")
5968 (set_attr "atype" "reg")])
9db1d521
HP
5969
5970;
5971; rotlsi3 instruction pattern(s).
5972;
5973
5974(define_insn "rotlsi3"
ac32b25e
UW
5975 [(set (match_operand:SI 0 "register_operand" "=d")
5976 (rotate:SI (match_operand:SI 1 "register_operand" "d")
5977 (match_operand:SI 2 "shift_count_operand" "Y")))]
9e8327e3 5978 "TARGET_CPU_ZARCH"
ac32b25e 5979 "rll\t%0,%1,%Y2"
077dab3b
HP
5980 [(set_attr "op_type" "RSE")
5981 (set_attr "atype" "reg")])
9db1d521
HP
5982
5983
5984;;
5985;;- Arithmetic shift instructions.
5986;;
9db1d521
HP
5987
5988;
5989; ashldi3 instruction pattern(s).
5990;
5991
5992(define_expand "ashldi3"
ecbe845e
UW
5993 [(set (match_operand:DI 0 "register_operand" "")
5994 (ashift:DI (match_operand:DI 1 "register_operand" "")
ac32b25e 5995 (match_operand:SI 2 "shift_count_operand" "")))]
9db1d521
HP
5996 ""
5997 "")
5998
5999(define_insn "*ashldi3_31"
ac32b25e
UW
6000 [(set (match_operand:DI 0 "register_operand" "=d")
6001 (ashift:DI (match_operand:DI 1 "register_operand" "0")
6002 (match_operand:SI 2 "shift_count_operand" "Y")))]
9db1d521 6003 "!TARGET_64BIT"
ac32b25e 6004 "sldl\t%0,%Y2"
077dab3b
HP
6005 [(set_attr "op_type" "RS")
6006 (set_attr "atype" "reg")])
9db1d521
HP
6007
6008(define_insn "*ashldi3_64"
ac32b25e
UW
6009 [(set (match_operand:DI 0 "register_operand" "=d")
6010 (ashift:DI (match_operand:DI 1 "register_operand" "d")
6011 (match_operand:SI 2 "shift_count_operand" "Y")))]
9db1d521 6012 "TARGET_64BIT"
ac32b25e 6013 "sllg\t%0,%1,%Y2"
077dab3b
HP
6014 [(set_attr "op_type" "RSE")
6015 (set_attr "atype" "reg")])
9db1d521
HP
6016
6017;
6018; ashrdi3 instruction pattern(s).
6019;
6020
6021(define_expand "ashrdi3"
6022 [(parallel
6023 [(set (match_operand:DI 0 "register_operand" "")
6024 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
ac32b25e 6025 (match_operand:SI 2 "shift_count_operand" "")))
9db1d521
HP
6026 (clobber (reg:CC 33))])]
6027 ""
6028 "")
6029
ecbe845e
UW
6030(define_insn "*ashrdi3_cc_31"
6031 [(set (reg 33)
ac32b25e
UW
6032 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6033 (match_operand:SI 2 "shift_count_operand" "Y"))
ecbe845e 6034 (const_int 0)))
ac32b25e 6035 (set (match_operand:DI 0 "register_operand" "=d")
ecbe845e
UW
6036 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6037 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
ac32b25e 6038 "srda\t%0,%Y2"
077dab3b
HP
6039 [(set_attr "op_type" "RS")
6040 (set_attr "atype" "reg")])
ecbe845e
UW
6041
6042(define_insn "*ashrdi3_cconly_31"
6043 [(set (reg 33)
ac32b25e
UW
6044 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6045 (match_operand:SI 2 "shift_count_operand" "Y"))
ecbe845e 6046 (const_int 0)))
ac32b25e 6047 (clobber (match_scratch:DI 0 "=d"))]
ecbe845e 6048 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
ac32b25e 6049 "srda\t%0,%Y2"
077dab3b
HP
6050 [(set_attr "op_type" "RS")
6051 (set_attr "atype" "reg")])
ecbe845e 6052
9db1d521 6053(define_insn "*ashrdi3_31"
ac32b25e
UW
6054 [(set (match_operand:DI 0 "register_operand" "=d")
6055 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6056 (match_operand:SI 2 "shift_count_operand" "Y")))
9db1d521
HP
6057 (clobber (reg:CC 33))]
6058 "!TARGET_64BIT"
ac32b25e 6059 "srda\t%0,%Y2"
077dab3b
HP
6060 [(set_attr "op_type" "RS")
6061 (set_attr "atype" "reg")])
c7453384 6062
ecbe845e
UW
6063(define_insn "*ashrdi3_cc_64"
6064 [(set (reg 33)
ac32b25e
UW
6065 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6066 (match_operand:SI 2 "shift_count_operand" "Y"))
ecbe845e 6067 (const_int 0)))
ac32b25e 6068 (set (match_operand:DI 0 "register_operand" "=d")
ecbe845e
UW
6069 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6070 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
ac32b25e 6071 "srag\t%0,%1,%Y2"
077dab3b
HP
6072 [(set_attr "op_type" "RSE")
6073 (set_attr "atype" "reg")])
ecbe845e
UW
6074
6075(define_insn "*ashrdi3_cconly_64"
6076 [(set (reg 33)
ac32b25e
UW
6077 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6078 (match_operand:SI 2 "shift_count_operand" "Y"))
ecbe845e 6079 (const_int 0)))
ac32b25e 6080 (clobber (match_scratch:DI 0 "=d"))]
ecbe845e 6081 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
ac32b25e 6082 "srag\t%0,%1,%Y2"
077dab3b
HP
6083 [(set_attr "op_type" "RSE")
6084 (set_attr "atype" "reg")])
ecbe845e 6085
9db1d521 6086(define_insn "*ashrdi3_64"
ac32b25e
UW
6087 [(set (match_operand:DI 0 "register_operand" "=d")
6088 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6089 (match_operand:SI 2 "shift_count_operand" "Y")))
9db1d521
HP
6090 (clobber (reg:CC 33))]
6091 "TARGET_64BIT"
ac32b25e 6092 "srag\t%0,%1,%Y2"
077dab3b
HP
6093 [(set_attr "op_type" "RSE")
6094 (set_attr "atype" "reg")])
6095
9db1d521
HP
6096
6097;
6098; ashlsi3 instruction pattern(s).
6099;
9db1d521
HP
6100
6101(define_insn "ashlsi3"
ac32b25e
UW
6102 [(set (match_operand:SI 0 "register_operand" "=d")
6103 (ashift:SI (match_operand:SI 1 "register_operand" "0")
6104 (match_operand:SI 2 "shift_count_operand" "Y")))]
9db1d521 6105 ""
ac32b25e 6106 "sll\t%0,%Y2"
077dab3b
HP
6107 [(set_attr "op_type" "RS")
6108 (set_attr "atype" "reg")])
9db1d521
HP
6109
6110;
6111; ashrsi3 instruction pattern(s).
6112;
6113
ecbe845e
UW
6114(define_insn "*ashrsi3_cc"
6115 [(set (reg 33)
ac32b25e
UW
6116 (compare (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6117 (match_operand:SI 2 "shift_count_operand" "Y"))
ecbe845e 6118 (const_int 0)))
ac32b25e 6119 (set (match_operand:SI 0 "register_operand" "=d")
ecbe845e
UW
6120 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
6121 "s390_match_ccmode(insn, CCSmode)"
ac32b25e 6122 "sra\t%0,%Y2"
077dab3b
HP
6123 [(set_attr "op_type" "RS")
6124 (set_attr "atype" "reg")])
6125
ecbe845e
UW
6126
6127(define_insn "*ashrsi3_cconly"
6128 [(set (reg 33)
ac32b25e
UW
6129 (compare (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6130 (match_operand:SI 2 "shift_count_operand" "Y"))
ecbe845e 6131 (const_int 0)))
ac32b25e 6132 (clobber (match_scratch:SI 0 "=d"))]
ecbe845e 6133 "s390_match_ccmode(insn, CCSmode)"
ac32b25e 6134 "sra\t%0,%Y2"
077dab3b
HP
6135 [(set_attr "op_type" "RS")
6136 (set_attr "atype" "reg")])
ecbe845e 6137
9db1d521 6138(define_insn "ashrsi3"
ac32b25e
UW
6139 [(set (match_operand:SI 0 "register_operand" "=d")
6140 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6141 (match_operand:SI 2 "shift_count_operand" "Y")))
9db1d521
HP
6142 (clobber (reg:CC 33))]
6143 ""
ac32b25e 6144 "sra\t%0,%Y2"
077dab3b
HP
6145 [(set_attr "op_type" "RS")
6146 (set_attr "atype" "reg")])
9db1d521 6147
9db1d521
HP
6148
6149;;
6150;;- logical shift instructions.
6151;;
6152
6153;
6154; lshrdi3 instruction pattern(s).
6155;
6156
6157(define_expand "lshrdi3"
ecbe845e
UW
6158 [(set (match_operand:DI 0 "register_operand" "")
6159 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
ac32b25e 6160 (match_operand:SI 2 "shift_count_operand" "")))]
9db1d521
HP
6161 ""
6162 "")
6163
6164(define_insn "*lshrdi3_31"
ac32b25e
UW
6165 [(set (match_operand:DI 0 "register_operand" "=d")
6166 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
6167 (match_operand:SI 2 "shift_count_operand" "Y")))]
9db1d521 6168 "!TARGET_64BIT"
ac32b25e
UW
6169 "srdl\t%0,%Y2"
6170 [(set_attr "op_type" "RS")
077dab3b 6171 (set_attr "atype" "reg")])
9db1d521
HP
6172
6173(define_insn "*lshrdi3_64"
ac32b25e
UW
6174 [(set (match_operand:DI 0 "register_operand" "=d")
6175 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
6176 (match_operand:SI 2 "shift_count_operand" "Y")))]
9db1d521 6177 "TARGET_64BIT"
ac32b25e
UW
6178 "srlg\t%0,%1,%Y2"
6179 [(set_attr "op_type" "RSE")
077dab3b 6180 (set_attr "atype" "reg")])
9db1d521
HP
6181
6182;
6183; lshrsi3 instruction pattern(s).
6184;
6185
6186(define_insn "lshrsi3"
ac32b25e
UW
6187 [(set (match_operand:SI 0 "register_operand" "=d")
6188 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
6189 (match_operand:SI 2 "shift_count_operand" "Y")))]
9db1d521 6190 ""
ac32b25e 6191 "srl\t%0,%Y2"
077dab3b
HP
6192 [(set_attr "op_type" "RS")
6193 (set_attr "atype" "reg")])
9db1d521 6194
9db1d521
HP
6195
6196;;
6197;; Branch instruction patterns.
6198;;
6199
6200(define_expand "beq"
6201 [(set (reg:CCZ 33) (compare:CCZ (match_dup 1) (match_dup 2)))
6202 (set (pc)
6203 (if_then_else (eq (reg:CCZ 33) (const_int 0))
6204 (label_ref (match_operand 0 "" ""))
6205 (pc)))]
6206 ""
10bbf137 6207 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
9db1d521
HP
6208
6209(define_expand "bne"
6210 [(set (reg:CCZ 33) (compare:CCZ (match_dup 1) (match_dup 2)))
6211 (set (pc)
6212 (if_then_else (ne (reg:CCZ 33) (const_int 0))
6213 (label_ref (match_operand 0 "" ""))
6214 (pc)))]
6215 ""
10bbf137 6216 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
9db1d521
HP
6217
6218(define_expand "bgt"
6219 [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6220 (set (pc)
6221 (if_then_else (gt (reg:CCS 33) (const_int 0))
6222 (label_ref (match_operand 0 "" ""))
6223 (pc)))]
6224 ""
10bbf137 6225 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
9db1d521
HP
6226
6227(define_expand "bgtu"
6228 [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
6229 (set (pc)
6230 (if_then_else (gtu (reg:CCU 33) (const_int 0))
6231 (label_ref (match_operand 0 "" ""))
6232 (pc)))]
6233 ""
10bbf137 6234 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
9db1d521
HP
6235
6236(define_expand "blt"
6237 [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6238 (set (pc)
6239 (if_then_else (lt (reg:CCS 33) (const_int 0))
6240 (label_ref (match_operand 0 "" ""))
6241 (pc)))]
6242 ""
10bbf137 6243 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
9db1d521
HP
6244
6245(define_expand "bltu"
6246 [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
6247 (set (pc)
6248 (if_then_else (ltu (reg:CCU 33) (const_int 0))
6249 (label_ref (match_operand 0 "" ""))
6250 (pc)))]
6251 ""
10bbf137 6252 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
9db1d521
HP
6253
6254(define_expand "bge"
6255 [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6256 (set (pc)
6257 (if_then_else (ge (reg:CCS 33) (const_int 0))
6258 (label_ref (match_operand 0 "" ""))
6259 (pc)))]
6260 ""
10bbf137 6261 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
9db1d521
HP
6262
6263(define_expand "bgeu"
6264 [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
6265 (set (pc)
6266 (if_then_else (geu (reg:CCU 33) (const_int 0))
6267 (label_ref (match_operand 0 "" ""))
6268 (pc)))]
6269 ""
10bbf137 6270 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
9db1d521
HP
6271
6272(define_expand "ble"
6273 [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6274 (set (pc)
6275 (if_then_else (le (reg:CCS 33) (const_int 0))
6276 (label_ref (match_operand 0 "" ""))
6277 (pc)))]
6278 ""
10bbf137 6279 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
9db1d521
HP
6280
6281(define_expand "bleu"
6282 [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
6283 (set (pc)
6284 (if_then_else (leu (reg:CCU 33) (const_int 0))
6285 (label_ref (match_operand 0 "" ""))
6286 (pc)))]
6287 ""
10bbf137 6288 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
9db1d521 6289
ba956982
UW
6290(define_expand "bunordered"
6291 [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6292 (set (pc)
6293 (if_then_else (unordered (reg:CCS 33) (const_int 0))
6294 (label_ref (match_operand 0 "" ""))
6295 (pc)))]
6296 ""
10bbf137 6297 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
ba956982
UW
6298
6299(define_expand "bordered"
6300 [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6301 (set (pc)
6302 (if_then_else (ordered (reg:CCS 33) (const_int 0))
6303 (label_ref (match_operand 0 "" ""))
6304 (pc)))]
6305 ""
10bbf137 6306 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
ba956982
UW
6307
6308(define_expand "buneq"
6309 [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6310 (set (pc)
6311 (if_then_else (uneq (reg:CCS 33) (const_int 0))
6312 (label_ref (match_operand 0 "" ""))
6313 (pc)))]
6314 ""
10bbf137 6315 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
ba956982
UW
6316
6317(define_expand "bungt"
6318 [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6319 (set (pc)
6320 (if_then_else (ungt (reg:CCS 33) (const_int 0))
6321 (label_ref (match_operand 0 "" ""))
6322 (pc)))]
6323 ""
10bbf137 6324 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
ba956982
UW
6325
6326(define_expand "bunlt"
6327 [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6328 (set (pc)
6329 (if_then_else (unlt (reg:CCS 33) (const_int 0))
6330 (label_ref (match_operand 0 "" ""))
6331 (pc)))]
6332 ""
10bbf137 6333 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
ba956982
UW
6334
6335(define_expand "bunge"
6336 [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6337 (set (pc)
6338 (if_then_else (unge (reg:CCS 33) (const_int 0))
6339 (label_ref (match_operand 0 "" ""))
6340 (pc)))]
6341 ""
10bbf137 6342 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
ba956982
UW
6343
6344(define_expand "bunle"
6345 [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6346 (set (pc)
6347 (if_then_else (unle (reg:CCS 33) (const_int 0))
6348 (label_ref (match_operand 0 "" ""))
6349 (pc)))]
6350 ""
10bbf137 6351 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
ba956982
UW
6352
6353(define_expand "bltgt"
6354 [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6355 (set (pc)
6356 (if_then_else (ltgt (reg:CCS 33) (const_int 0))
6357 (label_ref (match_operand 0 "" ""))
6358 (pc)))]
6359 ""
10bbf137 6360 "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
ba956982 6361
9db1d521
HP
6362
6363;;
6364;;- Conditional jump instructions.
6365;;
6366
6367(define_insn "cjump"
6368 [(set (pc)
c7453384 6369 (if_then_else
9db1d521
HP
6370 (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
6371 (label_ref (match_operand 0 "" ""))
6372 (pc)))]
6373 ""
9db1d521 6374{
13e58269 6375 if (get_attr_length (insn) == 4)
d40c829f 6376 return "j%C1\t%l0";
9e8327e3 6377 else if (TARGET_CPU_ZARCH)
d40c829f 6378 return "jg%C1\t%l0";
9db1d521 6379 else
13e58269 6380 abort ();
10bbf137 6381}
9db1d521 6382 [(set_attr "op_type" "RI")
077dab3b 6383 (set_attr "type" "branch")
13e58269
UW
6384 (set (attr "length")
6385 (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6386 (const_int 4)
9e8327e3 6387 (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
13e58269
UW
6388 (const_int 6)
6389 (eq (symbol_ref "flag_pic") (const_int 0))
6390 (const_int 6)] (const_int 8)))])
9db1d521 6391
f314b9b1 6392(define_insn "*cjump_long"
9db1d521
HP
6393 [(set (pc)
6394 (if_then_else
6395 (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
d3632d41 6396 (match_operand 0 "address_operand" "U")
9db1d521
HP
6397 (pc)))]
6398 ""
f314b9b1
UW
6399{
6400 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 6401 return "b%C1r\t%0";
f314b9b1 6402 else
d40c829f 6403 return "b%C1\t%a0";
10bbf137 6404}
c7453384 6405 [(set (attr "op_type")
f314b9b1
UW
6406 (if_then_else (match_operand 0 "register_operand" "")
6407 (const_string "RR") (const_string "RX")))
077dab3b
HP
6408 (set_attr "type" "branch")
6409 (set_attr "atype" "agen")])
9db1d521
HP
6410
6411
6412;;
6413;;- Negated conditional jump instructions.
6414;;
6415
6416(define_insn "icjump"
6417 [(set (pc)
6418 (if_then_else
6419 (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
c7453384 6420 (pc)
9db1d521
HP
6421 (label_ref (match_operand 0 "" ""))))]
6422 ""
c7453384 6423{
13e58269 6424 if (get_attr_length (insn) == 4)
d40c829f 6425 return "j%D1\t%l0";
9e8327e3 6426 else if (TARGET_CPU_ZARCH)
d40c829f 6427 return "jg%D1\t%l0";
9db1d521 6428 else
13e58269 6429 abort ();
10bbf137 6430}
9db1d521 6431 [(set_attr "op_type" "RI")
077dab3b 6432 (set_attr "type" "branch")
13e58269
UW
6433 (set (attr "length")
6434 (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6435 (const_int 4)
9e8327e3 6436 (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
13e58269
UW
6437 (const_int 6)
6438 (eq (symbol_ref "flag_pic") (const_int 0))
6439 (const_int 6)] (const_int 8)))])
9db1d521 6440
f314b9b1 6441(define_insn "*icjump_long"
9db1d521
HP
6442 [(set (pc)
6443 (if_then_else
6444 (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
f314b9b1 6445 (pc)
d3632d41 6446 (match_operand 0 "address_operand" "U")))]
9db1d521 6447 ""
f314b9b1
UW
6448{
6449 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 6450 return "b%D1r\t%0";
f314b9b1 6451 else
d40c829f 6452 return "b%D1\t%a0";
10bbf137 6453}
c7453384 6454 [(set (attr "op_type")
f314b9b1
UW
6455 (if_then_else (match_operand 0 "register_operand" "")
6456 (const_string "RR") (const_string "RX")))
077dab3b
HP
6457 (set_attr "type" "branch")
6458 (set_attr "atype" "agen")])
9db1d521 6459
4456530d
HP
6460;;
6461;;- Trap instructions.
6462;;
6463
6464(define_insn "trap"
6465 [(trap_if (const_int 1) (const_int 0))]
6466 ""
d40c829f 6467 "j\t.+2"
077dab3b
HP
6468 [(set_attr "op_type" "RX")
6469 (set_attr "type" "branch")])
4456530d
HP
6470
6471(define_expand "conditional_trap"
6472 [(set (match_dup 2) (match_dup 3))
6473 (trap_if (match_operator 0 "comparison_operator"
6474 [(match_dup 2) (const_int 0)])
6475 (match_operand:SI 1 "general_operand" ""))]
6476 ""
4456530d
HP
6477{
6478 enum machine_mode ccmode;
6479
c7453384 6480 if (operands[1] != const0_rtx) FAIL;
4456530d 6481
c7453384
EC
6482 ccmode = s390_select_ccmode (GET_CODE (operands[0]),
6483 s390_compare_op0, s390_compare_op1);
4456530d
HP
6484 operands[2] = gen_rtx_REG (ccmode, 33);
6485 operands[3] = gen_rtx_COMPARE (ccmode, s390_compare_op0, s390_compare_op1);
10bbf137 6486})
4456530d
HP
6487
6488(define_insn "*trap"
6489 [(trap_if (match_operator 0 "comparison_operator" [(reg 33) (const_int 0)])
6490 (const_int 0))]
6491 ""
d40c829f 6492 "j%C0\t.+2";
077dab3b
HP
6493 [(set_attr "op_type" "RI")
6494 (set_attr "type" "branch")])
9db1d521
HP
6495
6496;;
0a3bdf9d 6497;;- Loop instructions.
9db1d521 6498;;
0a3bdf9d
UW
6499;; This is all complicated by the fact that since this is a jump insn
6500;; we must handle our own output reloads.
c7453384 6501
0a3bdf9d
UW
6502(define_expand "doloop_end"
6503 [(use (match_operand 0 "" "")) ; loop pseudo
6504 (use (match_operand 1 "" "")) ; iterations; zero if unknown
6505 (use (match_operand 2 "" "")) ; max iterations
6506 (use (match_operand 3 "" "")) ; loop level
6507 (use (match_operand 4 "" ""))] ; label
6508 ""
0a3bdf9d
UW
6509{
6510 if (GET_MODE (operands[0]) == SImode)
6511 emit_jump_insn (gen_doloop_si (operands[4], operands[0], operands[0]));
6512 else if (GET_MODE (operands[0]) == DImode && TARGET_64BIT)
6513 emit_jump_insn (gen_doloop_di (operands[4], operands[0], operands[0]));
6514 else
6515 FAIL;
6516
6517 DONE;
10bbf137 6518})
0a3bdf9d
UW
6519
6520(define_insn "doloop_si"
6521 [(set (pc)
6522 (if_then_else
6523 (ne (match_operand:SI 1 "register_operand" "d,d")
6524 (const_int 1))
6525 (label_ref (match_operand 0 "" ""))
6526 (pc)))
6527 (set (match_operand:SI 2 "register_operand" "=1,?*m*d")
6528 (plus:SI (match_dup 1) (const_int -1)))
6529 (clobber (match_scratch:SI 3 "=X,&d"))
6530 (clobber (reg:CC 33))]
6531 ""
0a3bdf9d
UW
6532{
6533 if (which_alternative != 0)
10bbf137 6534 return "#";
0a3bdf9d 6535 else if (get_attr_length (insn) == 4)
d40c829f 6536 return "brct\t%1,%l0";
545d16ff
UW
6537 else if (TARGET_CPU_ZARCH)
6538 return "ahi\t%1,-1\;jgne\t%l0";
0a3bdf9d
UW
6539 else
6540 abort ();
10bbf137 6541}
0a3bdf9d 6542 [(set_attr "op_type" "RI")
077dab3b 6543 (set_attr "type" "branch")
0a3bdf9d
UW
6544 (set (attr "length")
6545 (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6546 (const_int 4)
9e8327e3 6547 (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
0a3bdf9d 6548 (const_int 10)
0a3bdf9d
UW
6549 (eq (symbol_ref "flag_pic") (const_int 0))
6550 (const_int 6)] (const_int 8)))])
9db1d521 6551
0a3bdf9d
UW
6552(define_insn "*doloop_si_long"
6553 [(set (pc)
6554 (if_then_else
6555 (ne (match_operand:SI 1 "register_operand" "d,d")
6556 (const_int 1))
d3632d41 6557 (match_operand 0 "address_operand" "U,U")
0a3bdf9d
UW
6558 (pc)))
6559 (set (match_operand:SI 2 "register_operand" "=1,?*m*d")
6560 (plus:SI (match_dup 1) (const_int -1)))
6561 (clobber (match_scratch:SI 3 "=X,&d"))
6562 (clobber (reg:CC 33))]
6563 ""
0a3bdf9d
UW
6564{
6565 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 6566 return "bctr\t%1,%0";
0a3bdf9d 6567 else
d40c829f 6568 return "bct\t%1,%a0";
10bbf137 6569}
c7453384 6570 [(set (attr "op_type")
0a3bdf9d
UW
6571 (if_then_else (match_operand 0 "register_operand" "")
6572 (const_string "RR") (const_string "RX")))
077dab3b
HP
6573 (set_attr "type" "branch")
6574 (set_attr "atype" "agen")])
0a3bdf9d
UW
6575
6576(define_split
6577 [(set (pc)
6578 (if_then_else (ne (match_operand:SI 1 "register_operand" "")
6579 (const_int 1))
6580 (match_operand 0 "" "")
6581 (pc)))
6582 (set (match_operand:SI 2 "nonimmediate_operand" "")
6583 (plus:SI (match_dup 1) (const_int -1)))
6584 (clobber (match_scratch:SI 3 ""))
6585 (clobber (reg:CC 33))]
6586 "reload_completed
6587 && (! REG_P (operands[2])
6588 || ! rtx_equal_p (operands[1], operands[2]))"
6589 [(set (match_dup 3) (match_dup 1))
6590 (parallel [(set (reg:CCAN 33)
6591 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
6592 (const_int 0)))
6593 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
6594 (set (match_dup 2) (match_dup 3))
6595 (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
6596 (match_dup 0)
6597 (pc)))]
6598 "")
9db1d521 6599
0a3bdf9d
UW
6600(define_insn "doloop_di"
6601 [(set (pc)
6602 (if_then_else
6603 (ne (match_operand:DI 1 "register_operand" "d,d")
6604 (const_int 1))
6605 (label_ref (match_operand 0 "" ""))
6606 (pc)))
6607 (set (match_operand:DI 2 "register_operand" "=1,?*m*r")
6608 (plus:DI (match_dup 1) (const_int -1)))
6609 (clobber (match_scratch:DI 3 "=X,&d"))
6610 (clobber (reg:CC 33))]
6611 "TARGET_64BIT"
0a3bdf9d
UW
6612{
6613 if (which_alternative != 0)
10bbf137 6614 return "#";
0a3bdf9d 6615 else if (get_attr_length (insn) == 4)
d40c829f 6616 return "brctg\t%1,%l0";
0a3bdf9d 6617 else
545d16ff 6618 return "aghi\t%1,-1\;jgne\t%l0";
10bbf137 6619}
0a3bdf9d 6620 [(set_attr "op_type" "RI")
077dab3b 6621 (set_attr "type" "branch")
0a3bdf9d
UW
6622 (set (attr "length")
6623 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
545d16ff 6624 (const_int 4) (const_int 10)))])
0a3bdf9d
UW
6625
6626(define_split
6627 [(set (pc)
6628 (if_then_else (ne (match_operand:DI 1 "register_operand" "")
6629 (const_int 1))
6630 (match_operand 0 "" "")
6631 (pc)))
6632 (set (match_operand:DI 2 "nonimmediate_operand" "")
6633 (plus:DI (match_dup 1) (const_int -1)))
6634 (clobber (match_scratch:DI 3 ""))
6635 (clobber (reg:CC 33))]
6636 "reload_completed
6637 && (! REG_P (operands[2])
6638 || ! rtx_equal_p (operands[1], operands[2]))"
6639 [(set (match_dup 3) (match_dup 1))
6640 (parallel [(set (reg:CCAN 33)
6641 (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
6642 (const_int 0)))
6643 (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
6644 (set (match_dup 2) (match_dup 3))
6645 (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
6646 (match_dup 0)
6647 (pc)))]
6648 "")
9db1d521
HP
6649
6650;;
6651;;- Unconditional jump instructions.
6652;;
6653
6654;
6655; jump instruction pattern(s).
6656;
6657
6658(define_insn "jump"
6659 [(set (pc) (label_ref (match_operand 0 "" "")))]
6660 ""
9db1d521 6661{
13e58269 6662 if (get_attr_length (insn) == 4)
d40c829f 6663 return "j\t%l0";
9e8327e3 6664 else if (TARGET_CPU_ZARCH)
d40c829f 6665 return "jg\t%l0";
9db1d521 6666 else
13e58269 6667 abort ();
10bbf137 6668}
9db1d521 6669 [(set_attr "op_type" "RI")
077dab3b 6670 (set_attr "type" "branch")
13e58269
UW
6671 (set (attr "length")
6672 (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6673 (const_int 4)
9e8327e3 6674 (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
13e58269
UW
6675 (const_int 6)
6676 (eq (symbol_ref "flag_pic") (const_int 0))
6677 (const_int 6)] (const_int 8)))])
9db1d521
HP
6678
6679;
6680; indirect-jump instruction pattern(s).
6681;
6682
6683(define_insn "indirect_jump"
d3632d41 6684 [(set (pc) (match_operand 0 "address_operand" "U"))]
9db1d521 6685 ""
f314b9b1
UW
6686{
6687 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 6688 return "br\t%0";
f314b9b1 6689 else
d40c829f 6690 return "b\t%a0";
10bbf137 6691}
c7453384 6692 [(set (attr "op_type")
f314b9b1
UW
6693 (if_then_else (match_operand 0 "register_operand" "")
6694 (const_string "RR") (const_string "RX")))
077dab3b
HP
6695 (set_attr "type" "branch")
6696 (set_attr "atype" "agen")])
9db1d521
HP
6697
6698;
f314b9b1 6699; casesi instruction pattern(s).
9db1d521
HP
6700;
6701
f314b9b1 6702(define_insn "casesi_jump"
d3632d41 6703 [(set (pc) (match_operand 0 "address_operand" "U"))
f314b9b1 6704 (use (label_ref (match_operand 1 "" "")))]
9db1d521 6705 ""
9db1d521 6706{
f314b9b1 6707 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 6708 return "br\t%0";
f314b9b1 6709 else
d40c829f 6710 return "b\t%a0";
10bbf137 6711}
c7453384 6712 [(set (attr "op_type")
f314b9b1
UW
6713 (if_then_else (match_operand 0 "register_operand" "")
6714 (const_string "RR") (const_string "RX")))
077dab3b
HP
6715 (set_attr "type" "branch")
6716 (set_attr "atype" "agen")])
9db1d521 6717
f314b9b1
UW
6718(define_expand "casesi"
6719 [(match_operand:SI 0 "general_operand" "")
6720 (match_operand:SI 1 "general_operand" "")
6721 (match_operand:SI 2 "general_operand" "")
6722 (label_ref (match_operand 3 "" ""))
6723 (label_ref (match_operand 4 "" ""))]
9db1d521 6724 ""
f314b9b1
UW
6725{
6726 rtx index = gen_reg_rtx (SImode);
6727 rtx base = gen_reg_rtx (Pmode);
6728 rtx target = gen_reg_rtx (Pmode);
6729
6730 emit_move_insn (index, operands[0]);
6731 emit_insn (gen_subsi3 (index, index, operands[1]));
6732 emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
e790b36a 6733 operands[4]);
f314b9b1
UW
6734
6735 if (Pmode != SImode)
6736 index = convert_to_mode (Pmode, index, 1);
6737 if (GET_CODE (index) != REG)
6738 index = copy_to_mode_reg (Pmode, index);
6739
6740 if (TARGET_64BIT)
6741 emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
6742 else
6743 emit_insn (gen_ashlsi3 (index, index, GEN_INT (2)));
9db1d521 6744
f314b9b1
UW
6745 emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
6746
6747 index = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, base, index));
6748 emit_move_insn (target, index);
6749
6750 if (flag_pic)
6751 target = gen_rtx_PLUS (Pmode, base, target);
6752 emit_jump_insn (gen_casesi_jump (target, operands[3]));
6753
6754 DONE;
10bbf137 6755})
9db1d521
HP
6756
6757
6758;;
6759;;- Jump to subroutine.
6760;;
6761;;
6762
6763;
6764; untyped call instruction pattern(s).
6765;
6766
6767;; Call subroutine returning any type.
6768(define_expand "untyped_call"
6769 [(parallel [(call (match_operand 0 "" "")
6770 (const_int 0))
6771 (match_operand 1 "" "")
6772 (match_operand 2 "" "")])]
6773 ""
9db1d521
HP
6774{
6775 int i;
6776
6777 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
6778
6779 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6780 {
6781 rtx set = XVECEXP (operands[2], 0, i);
6782 emit_move_insn (SET_DEST (set), SET_SRC (set));
6783 }
6784
6785 /* The optimizer does not know that the call sets the function value
6786 registers we stored in the result block. We avoid problems by
6787 claiming that all hard registers are used and clobbered at this
6788 point. */
6789 emit_insn (gen_blockage ());
6790
6791 DONE;
10bbf137 6792})
9db1d521
HP
6793
6794;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6795;; all of memory. This blocks insns from being moved across this point.
6796
6797(define_insn "blockage"
10bbf137 6798 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
9db1d521 6799 ""
4023fb28 6800 ""
d5869ca0
UW
6801 [(set_attr "type" "none")
6802 (set_attr "length" "0")])
4023fb28 6803
9db1d521
HP
6804
6805
6806;
6807; call instruction pattern(s).
6808;
6809
6810(define_expand "call"
44b8152b
UW
6811 [(call (match_operand 0 "" "")
6812 (match_operand 1 "" ""))
6813 (use (match_operand 2 "" ""))]
9db1d521 6814 ""
9db1d521 6815{
9e8327e3 6816 bool plt_call = false;
44b8152b 6817 rtx insn;
9db1d521
HP
6818
6819 /* Direct function calls need special treatment. */
6820 if (GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
6821 {
6822 rtx sym = XEXP (operands[0], 0);
6823
6824 /* When calling a global routine in PIC mode, we must
6825 replace the symbol itself with the PLT stub. */
114278e7 6826 if (flag_pic && !SYMBOL_REF_LOCAL_P (sym))
9db1d521 6827 {
fd7643fb 6828 sym = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym), UNSPEC_PLT);
9db1d521 6829 sym = gen_rtx_CONST (Pmode, sym);
9e8327e3 6830 plt_call = true;
9db1d521
HP
6831 }
6832
c7453384 6833 /* Unless we can use the bras(l) insn, force the
9db1d521 6834 routine address into a register. */
9e8327e3 6835 if (!TARGET_SMALL_EXEC && !TARGET_CPU_ZARCH)
fd7643fb
UW
6836 {
6837 if (flag_pic)
6838 sym = legitimize_pic_address (sym, 0);
6839 else
6840 sym = force_reg (Pmode, sym);
6841 }
9db1d521
HP
6842
6843 operands[0] = gen_rtx_MEM (QImode, sym);
6844 }
44b8152b
UW
6845
6846 /* Emit insn. */
6847 insn = emit_call_insn (gen_call_exp (operands[0], operands[1],
6848 gen_rtx_REG (Pmode, RETURN_REGNUM)));
9e8327e3
UW
6849
6850 /* 31-bit PLT stubs use the GOT register implicitly. */
6851 if (!TARGET_64BIT && plt_call)
6852 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), pic_offset_table_rtx);
6853
44b8152b 6854 DONE;
10bbf137 6855})
9db1d521 6856
44b8152b
UW
6857(define_expand "call_exp"
6858 [(parallel [(call (match_operand 0 "" "")
6859 (match_operand 1 "" ""))
6860 (clobber (match_operand 2 "" ""))])]
6861 ""
6862 "")
6863
9e8327e3
UW
6864(define_insn "*bras"
6865 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
6866 (match_operand 1 "const_int_operand" "n"))
6867 (clobber (match_operand 2 "register_operand" "=r"))]
6868 "TARGET_SMALL_EXEC && GET_MODE (operands[2]) == Pmode"
d40c829f 6869 "bras\t%2,%0"
9db1d521 6870 [(set_attr "op_type" "RI")
4023fb28 6871 (set_attr "type" "jsr")])
9db1d521 6872
9e8327e3
UW
6873(define_insn "*brasl"
6874 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
6875 (match_operand 1 "const_int_operand" "n"))
6876 (clobber (match_operand 2 "register_operand" "=r"))]
6877 "TARGET_CPU_ZARCH && GET_MODE (operands[2]) == Pmode"
6878 "brasl\t%2,%0"
6879 [(set_attr "op_type" "RIL")
077dab3b 6880 (set_attr "type" "jsr")])
9db1d521 6881
9e8327e3
UW
6882(define_insn "*basr"
6883 [(call (mem:QI (match_operand 0 "address_operand" "U"))
6884 (match_operand 1 "const_int_operand" "n"))
6885 (clobber (match_operand 2 "register_operand" "=r"))]
6886 "GET_MODE (operands[2]) == Pmode"
6887{
6888 if (get_attr_op_type (insn) == OP_TYPE_RR)
6889 return "basr\t%2,%0";
6890 else
6891 return "bas\t%2,%a0";
6892}
6893 [(set (attr "op_type")
6894 (if_then_else (match_operand 0 "register_operand" "")
6895 (const_string "RR") (const_string "RX")))
6896 (set_attr "type" "jsr")
6897 (set_attr "atype" "agen")])
9db1d521
HP
6898
6899;
6900; call_value instruction pattern(s).
6901;
6902
6903(define_expand "call_value"
44b8152b
UW
6904 [(set (match_operand 0 "" "")
6905 (call (match_operand 1 "" "")
6906 (match_operand 2 "" "")))
6907 (use (match_operand 3 "" ""))]
9db1d521 6908 ""
9db1d521 6909{
9e8327e3 6910 bool plt_call = false;
44b8152b 6911 rtx insn;
9db1d521
HP
6912
6913 /* Direct function calls need special treatment. */
6914 if (GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
6915 {
6916 rtx sym = XEXP (operands[1], 0);
6917
6918 /* When calling a global routine in PIC mode, we must
6919 replace the symbol itself with the PLT stub. */
114278e7 6920 if (flag_pic && !SYMBOL_REF_LOCAL_P (sym))
9db1d521 6921 {
fd7643fb 6922 sym = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym), UNSPEC_PLT);
9db1d521 6923 sym = gen_rtx_CONST (Pmode, sym);
9e8327e3 6924 plt_call = true;
9db1d521
HP
6925 }
6926
c7453384 6927 /* Unless we can use the bras(l) insn, force the
9db1d521 6928 routine address into a register. */
9e8327e3 6929 if (!TARGET_SMALL_EXEC && !TARGET_CPU_ZARCH)
9db1d521 6930 {
fd7643fb
UW
6931 if (flag_pic)
6932 sym = legitimize_pic_address (sym, 0);
6933 else
6934 sym = force_reg (Pmode, sym);
9db1d521
HP
6935 }
6936
6937 operands[1] = gen_rtx_MEM (QImode, sym);
6938 }
44b8152b
UW
6939
6940 /* Emit insn. */
6941 insn = emit_call_insn (
6942 gen_call_value_exp (operands[0], operands[1], operands[2],
6943 gen_rtx_REG (Pmode, RETURN_REGNUM)));
9e8327e3
UW
6944
6945 /* 31-bit PLT stubs use the GOT register implicitly. */
6946 if (!TARGET_64BIT && plt_call)
6947 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), pic_offset_table_rtx);
6948
44b8152b 6949 DONE;
10bbf137 6950})
9db1d521 6951
44b8152b
UW
6952(define_expand "call_value_exp"
6953 [(parallel [(set (match_operand 0 "" "")
6954 (call (match_operand 1 "" "")
6955 (match_operand 2 "" "")))
6956 (clobber (match_operand 3 "" ""))])]
6957 ""
6958 "")
6959
9e8327e3 6960(define_insn "*bras_r"
c19ec8f9 6961 [(set (match_operand 0 "" "")
9e8327e3 6962 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9db1d521 6963 (match_operand:SI 2 "const_int_operand" "n")))
9e8327e3
UW
6964 (clobber (match_operand 3 "register_operand" "=r"))]
6965 "TARGET_SMALL_EXEC && GET_MODE (operands[3]) == Pmode"
d40c829f 6966 "bras\t%3,%1"
9db1d521 6967 [(set_attr "op_type" "RI")
f2d3c02a 6968 (set_attr "type" "jsr")])
9db1d521 6969
9e8327e3 6970(define_insn "*brasl_r"
c19ec8f9 6971 [(set (match_operand 0 "" "")
9e8327e3
UW
6972 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
6973 (match_operand 2 "const_int_operand" "n")))
6974 (clobber (match_operand 3 "register_operand" "=r"))]
6975 "TARGET_CPU_ZARCH && GET_MODE (operands[3]) == Pmode"
6976 "brasl\t%3,%1"
6977 [(set_attr "op_type" "RIL")
077dab3b 6978 (set_attr "type" "jsr")])
9db1d521 6979
9e8327e3 6980(define_insn "*basr_r"
c19ec8f9 6981 [(set (match_operand 0 "" "")
9e8327e3
UW
6982 (call (mem:QI (match_operand 1 "address_operand" "U"))
6983 (match_operand 2 "const_int_operand" "n")))
6984 (clobber (match_operand 3 "register_operand" "=r"))]
6985 "GET_MODE (operands[3]) == Pmode"
6986{
6987 if (get_attr_op_type (insn) == OP_TYPE_RR)
6988 return "basr\t%3,%1";
6989 else
6990 return "bas\t%3,%a1";
6991}
6992 [(set (attr "op_type")
6993 (if_then_else (match_operand 1 "register_operand" "")
6994 (const_string "RR") (const_string "RX")))
6995 (set_attr "type" "jsr")
6996 (set_attr "atype" "agen")])
9db1d521 6997
fd3cd001
UW
6998;;
6999;;- Thread-local storage support.
7000;;
7001
7002(define_insn "get_tp_64"
7003 [(set (match_operand:DI 0 "nonimmediate_operand" "=??d,Q")
7004 (unspec:DI [(const_int 0)] UNSPEC_TP))]
7005 "TARGET_64BIT"
7006 "@
d40c829f
UW
7007 ear\t%0,%%a0\;sllg\t%0,%0,32\;ear\t%0,%%a1
7008 stam\t%%a0,%%a1,%0"
fd3cd001
UW
7009 [(set_attr "op_type" "NN,RS")
7010 (set_attr "atype" "reg,*")
7011 (set_attr "type" "o3,*")
7012 (set_attr "length" "14,*")])
7013
7014(define_insn "get_tp_31"
7015 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,Q")
7016 (unspec:SI [(const_int 0)] UNSPEC_TP))]
7017 "!TARGET_64BIT"
7018 "@
d40c829f
UW
7019 ear\t%0,%%a0
7020 stam\t%%a0,%%a0,%0"
fd3cd001
UW
7021 [(set_attr "op_type" "RRE,RS")])
7022
7023(define_insn "set_tp_64"
7024 [(unspec_volatile [(match_operand:DI 0 "general_operand" "??d,Q")] UNSPECV_SET_TP)
7025 (clobber (match_scratch:SI 1 "=d,X"))]
7026 "TARGET_64BIT"
7027 "@
d40c829f
UW
7028 sar\t%%a1,%0\;srlg\t%1,%0,32\;sar\t%%a0,%1
7029 lam\t%%a0,%%a1,%0"
fd3cd001
UW
7030 [(set_attr "op_type" "NN,RS")
7031 (set_attr "atype" "reg,*")
7032 (set_attr "type" "o3,*")
7033 (set_attr "length" "14,*")])
7034
7035(define_insn "set_tp_31"
7036 [(unspec_volatile [(match_operand:SI 0 "general_operand" "d,Q")] UNSPECV_SET_TP)]
7037 "!TARGET_64BIT"
7038 "@
d40c829f
UW
7039 sar\t%%a0,%0
7040 lam\t%%a0,%%a0,%0"
fd3cd001 7041 [(set_attr "op_type" "RRE,RS")])
c7453384 7042
fd3cd001
UW
7043(define_insn "*tls_load_64"
7044 [(set (match_operand:DI 0 "register_operand" "=d")
7045 (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
7046 (match_operand:DI 2 "" "")]
7047 UNSPEC_TLS_LOAD))]
7048 "TARGET_64BIT"
d40c829f 7049 "lg\t%0,%1%J2"
fd3cd001
UW
7050 [(set_attr "op_type" "RXE")])
7051
7052(define_insn "*tls_load_31"
d3632d41
UW
7053 [(set (match_operand:SI 0 "register_operand" "=d,d")
7054 (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
fd3cd001
UW
7055 (match_operand:SI 2 "" "")]
7056 UNSPEC_TLS_LOAD))]
7057 "!TARGET_64BIT"
d3632d41 7058 "@
d40c829f
UW
7059 l\t%0,%1%J2
7060 ly\t%0,%1%J2"
d3632d41 7061 [(set_attr "op_type" "RX,RXY")])
fd3cd001
UW
7062
7063(define_expand "call_value_tls"
7064 [(set (match_operand 0 "" "")
7065 (call (const_int 0) (const_int 0)))
7066 (use (match_operand 1 "" ""))]
7067 ""
fd3cd001
UW
7068{
7069 rtx insn, sym;
7070
7071 if (!flag_pic)
7072 abort ();
7073
7074 sym = s390_tls_get_offset ();
fd7643fb 7075 sym = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym), UNSPEC_PLT);
fd3cd001
UW
7076 sym = gen_rtx_CONST (Pmode, sym);
7077
c7453384 7078 /* Unless we can use the bras(l) insn, force the
fd3cd001 7079 routine address into a register. */
9e8327e3 7080 if (!TARGET_SMALL_EXEC && !TARGET_CPU_ZARCH)
fd3cd001 7081 {
fd7643fb
UW
7082 if (flag_pic)
7083 sym = legitimize_pic_address (sym, 0);
7084 else
7085 sym = force_reg (Pmode, sym);
fd3cd001
UW
7086 }
7087
7088 sym = gen_rtx_MEM (QImode, sym);
7089
7090 /* Emit insn. */
7091 insn = emit_call_insn (
7092 gen_call_value_tls_exp (operands[0], sym, const0_rtx,
7093 gen_rtx_REG (Pmode, RETURN_REGNUM),
7094 operands[1]));
7095
7096 /* The calling convention of __tls_get_offset uses the
7097 GOT register implicitly. */
7098 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), pic_offset_table_rtx);
7099 use_reg (&CALL_INSN_FUNCTION_USAGE (insn), operands[0]);
7100 CONST_OR_PURE_CALL_P (insn) = 1;
7101
7102 DONE;
10bbf137 7103})
fd3cd001
UW
7104
7105(define_expand "call_value_tls_exp"
7106 [(parallel [(set (match_operand 0 "" "")
7107 (call (match_operand 1 "" "")
7108 (match_operand 2 "" "")))
7109 (clobber (match_operand 3 "" ""))
7110 (use (match_operand 4 "" ""))])]
7111 ""
7112 "")
7113
9e8327e3 7114(define_insn "*bras_tls"
c19ec8f9 7115 [(set (match_operand 0 "" "")
9e8327e3
UW
7116 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7117 (match_operand 2 "const_int_operand" "n")))
7118 (clobber (match_operand 3 "register_operand" "=r"))
7119 (use (match_operand 4 "" ""))]
7120 "TARGET_SMALL_EXEC && GET_MODE (operands[3]) == Pmode"
d40c829f 7121 "bras\t%3,%1%J4"
fd3cd001
UW
7122 [(set_attr "op_type" "RI")
7123 (set_attr "type" "jsr")])
7124
9e8327e3 7125(define_insn "*brasl_tls"
c19ec8f9 7126 [(set (match_operand 0 "" "")
9e8327e3
UW
7127 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7128 (match_operand 2 "const_int_operand" "n")))
7129 (clobber (match_operand 3 "register_operand" "=r"))
7130 (use (match_operand 4 "" ""))]
7131 "TARGET_CPU_ZARCH && GET_MODE (operands[3]) == Pmode"
7132 "brasl\t%3,%1%J4"
7133 [(set_attr "op_type" "RIL")
fd3cd001
UW
7134 (set_attr "type" "jsr")])
7135
9e8327e3 7136(define_insn "*basr_tls"
c19ec8f9 7137 [(set (match_operand 0 "" "")
9e8327e3
UW
7138 (call (mem:QI (match_operand 1 "address_operand" "U"))
7139 (match_operand 2 "const_int_operand" "n")))
7140 (clobber (match_operand 3 "register_operand" "=r"))
7141 (use (match_operand 4 "" ""))]
7142 "GET_MODE (operands[3]) == Pmode"
7143{
7144 if (get_attr_op_type (insn) == OP_TYPE_RR)
7145 return "basr\t%3,%1%J4";
7146 else
7147 return "bas\t%3,%a1%J4";
7148}
7149 [(set (attr "op_type")
7150 (if_then_else (match_operand 1 "register_operand" "")
7151 (const_string "RR") (const_string "RX")))
7152 (set_attr "type" "jsr")
7153 (set_attr "atype" "agen")])
fd3cd001 7154
9db1d521
HP
7155;;
7156;;- Miscellaneous instructions.
7157;;
7158
7159;
7160; allocate stack instruction pattern(s).
7161;
7162
7163(define_expand "allocate_stack"
7164 [(set (reg 15)
7165 (plus (reg 15) (match_operand 1 "general_operand" "")))
7166 (set (match_operand 0 "general_operand" "")
7167 (reg 15))]
7168 ""
9db1d521
HP
7169{
7170 rtx stack = gen_rtx (REG, Pmode, STACK_POINTER_REGNUM);
7171 rtx chain = gen_rtx (MEM, Pmode, stack);
7172 rtx temp = gen_reg_rtx (Pmode);
c7453384 7173
9db1d521
HP
7174 emit_move_insn (temp, chain);
7175
7176 if (TARGET_64BIT)
7177 emit_insn (gen_adddi3 (stack, stack, negate_rtx (Pmode, operands[1])));
7178 else
7179 emit_insn (gen_addsi3 (stack, stack, negate_rtx (Pmode, operands[1])));
7180
7181 emit_move_insn (chain, temp);
7182
c7453384 7183 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9db1d521 7184 DONE;
10bbf137 7185})
9db1d521
HP
7186
7187
7188;
43ab026f 7189; setjmp instruction pattern.
9db1d521
HP
7190;
7191
9db1d521 7192(define_expand "builtin_setjmp_receiver"
fd7643fb 7193 [(match_operand 0 "" "")]
f314b9b1 7194 "flag_pic"
9db1d521 7195{
fd7643fb
UW
7196 s390_load_got (false);
7197 emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
9db1d521 7198 DONE;
fd7643fb 7199})
9db1d521 7200
9db1d521
HP
7201;; These patterns say how to save and restore the stack pointer. We need not
7202;; save the stack pointer at function level since we are careful to
7203;; preserve the backchain. At block level, we have to restore the backchain
7204;; when we restore the stack pointer.
7205;;
7206;; For nonlocal gotos, we must save both the stack pointer and its
7207;; backchain and restore both. Note that in the nonlocal case, the
7208;; save area is a memory location.
7209
7210(define_expand "save_stack_function"
7211 [(match_operand 0 "general_operand" "")
7212 (match_operand 1 "general_operand" "")]
7213 ""
7214 "DONE;")
7215
7216(define_expand "restore_stack_function"
7217 [(match_operand 0 "general_operand" "")
7218 (match_operand 1 "general_operand" "")]
7219 ""
7220 "DONE;")
7221
7222(define_expand "restore_stack_block"
7223 [(use (match_operand 0 "register_operand" ""))
7224 (set (match_dup 2) (match_dup 3))
7225 (set (match_dup 0) (match_operand 1 "register_operand" ""))
7226 (set (match_dup 3) (match_dup 2))]
7227 ""
9db1d521
HP
7228{
7229 operands[2] = gen_reg_rtx (Pmode);
7230 operands[3] = gen_rtx_MEM (Pmode, operands[0]);
10bbf137 7231})
9db1d521
HP
7232
7233(define_expand "save_stack_nonlocal"
7234 [(match_operand 0 "memory_operand" "")
7235 (match_operand 1 "register_operand" "")]
7236 ""
9db1d521
HP
7237{
7238 rtx temp = gen_reg_rtx (Pmode);
7239
43ab026f
AK
7240 /* Copy the backchain to the first word, sp to the second and the literal pool
7241 base to the third. */
7242 emit_move_insn (operand_subword (operands[0], 2, 0,
7243 TARGET_64BIT ? OImode : TImode),
7244 gen_rtx_REG (Pmode, BASE_REGISTER));
9db1d521
HP
7245 emit_move_insn (temp, gen_rtx_MEM (Pmode, operands[1]));
7246 emit_move_insn (operand_subword (operands[0], 0, 0,
43ab026f 7247 TARGET_64BIT ? OImode : TImode),
9db1d521
HP
7248 temp);
7249 emit_move_insn (operand_subword (operands[0], 1, 0,
43ab026f 7250 TARGET_64BIT ? OImode : TImode),
9db1d521
HP
7251 operands[1]);
7252 DONE;
10bbf137 7253})
9db1d521
HP
7254
7255(define_expand "restore_stack_nonlocal"
7256 [(match_operand 0 "register_operand" "")
7257 (match_operand 1 "memory_operand" "")]
7258 ""
9db1d521
HP
7259{
7260 rtx temp = gen_reg_rtx (Pmode);
43ab026f 7261 rtx base = gen_rtx_REG (Pmode, BASE_REGISTER);
9db1d521 7262
43ab026f
AK
7263 /* Restore the backchain from the first word, sp from the second and the
7264 literal pool base from the third. */
9db1d521
HP
7265 emit_move_insn (temp,
7266 operand_subword (operands[1], 0, 0,
43ab026f 7267 TARGET_64BIT ? OImode : TImode));
9db1d521
HP
7268 emit_move_insn (operands[0],
7269 operand_subword (operands[1], 1, 0,
43ab026f 7270 TARGET_64BIT ? OImode : TImode));
9db1d521 7271 emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), temp);
43ab026f
AK
7272 emit_move_insn (base,
7273 operand_subword (operands[1], 2, 0,
7274 TARGET_64BIT ? OImode : TImode));
7275 emit_insn (gen_rtx_USE (VOIDmode, base));
7276
9db1d521 7277 DONE;
10bbf137 7278})
9db1d521
HP
7279
7280
7281;
7282; nop instruction pattern(s).
7283;
7284
7285(define_insn "nop"
7286 [(const_int 0)]
7287 ""
d40c829f 7288 "lr\t0,0"
9db1d521
HP
7289 [(set_attr "op_type" "RR")])
7290
7291
7292;
7293; Special literal pool access instruction pattern(s).
7294;
7295
416cf582
UW
7296(define_insn "*pool_entry"
7297 [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
7298 UNSPECV_POOL_ENTRY)]
9db1d521 7299 ""
9db1d521 7300{
416cf582
UW
7301 enum machine_mode mode = GET_MODE (PATTERN (insn));
7302 unsigned int align = GET_MODE_BITSIZE (mode);
7303 s390_output_pool_entry (asm_out_file, operands[0], mode, align);
fd7643fb
UW
7304 return "";
7305}
416cf582
UW
7306 [(set_attr "op_type" "NN")
7307 (set (attr "length")
7308 (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
b2ccb744
UW
7309
7310(define_insn "pool_start_31"
fd7643fb 7311 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_START)]
9e8327e3 7312 "!TARGET_CPU_ZARCH"
d40c829f 7313 ".align\t4"
b2ccb744
UW
7314 [(set_attr "op_type" "NN")
7315 (set_attr "length" "2")])
7316
7317(define_insn "pool_end_31"
fd7643fb 7318 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_END)]
9e8327e3 7319 "!TARGET_CPU_ZARCH"
d40c829f 7320 ".align\t2"
b2ccb744
UW
7321 [(set_attr "op_type" "NN")
7322 (set_attr "length" "2")])
7323
7324(define_insn "pool_start_64"
fd7643fb 7325 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_START)]
9e8327e3 7326 "TARGET_CPU_ZARCH"
d40c829f 7327 ".section\t.rodata\;.align\t8"
b2ccb744
UW
7328 [(set_attr "op_type" "NN")
7329 (set_attr "length" "0")])
7330
7331(define_insn "pool_end_64"
fd7643fb 7332 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_END)]
9e8327e3 7333 "TARGET_CPU_ZARCH"
b2ccb744
UW
7334 ".previous"
7335 [(set_attr "op_type" "NN")
7336 (set_attr "length" "0")])
7337
5af2f3d3 7338(define_insn "main_base_31_small"
9e8327e3
UW
7339 [(set (match_operand 0 "register_operand" "=a")
7340 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
7341 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
5af2f3d3
UW
7342 "basr\t%0,0"
7343 [(set_attr "op_type" "RR")
7344 (set_attr "type" "la")])
7345
7346(define_insn "main_base_31_large"
9e8327e3
UW
7347 [(set (match_operand 0 "register_operand" "=a")
7348 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
5af2f3d3 7349 (set (pc) (label_ref (match_operand 2 "" "")))]
9e8327e3 7350 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
5af2f3d3
UW
7351 "bras\t%0,%2"
7352 [(set_attr "op_type" "RI")])
7353
7354(define_insn "main_base_64"
9e8327e3
UW
7355 [(set (match_operand 0 "register_operand" "=a")
7356 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
7357 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
5af2f3d3
UW
7358 "larl\t%0,%1"
7359 [(set_attr "op_type" "RIL")
7360 (set_attr "type" "larl")])
7361
7362(define_insn "main_pool"
7363 [(unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL)]
7364 ""
7365 "* abort ();"
7366 [(set_attr "op_type" "NN")])
7367
aee4e0db 7368(define_insn "reload_base_31"
9e8327e3
UW
7369 [(set (match_operand 0 "register_operand" "=a")
7370 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
7371 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
d40c829f 7372 "basr\t%0,0\;la\t%0,%1-.(%0)"
9db1d521 7373 [(set_attr "op_type" "NN")
b2ccb744
UW
7374 (set_attr "type" "la")
7375 (set_attr "length" "6")])
7376
aee4e0db 7377(define_insn "reload_base_64"
9e8327e3
UW
7378 [(set (match_operand 0 "register_operand" "=a")
7379 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
7380 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
d40c829f 7381 "larl\t%0,%1"
aee4e0db 7382 [(set_attr "op_type" "RIL")
077dab3b 7383 (set_attr "type" "larl")])
aee4e0db 7384
aee4e0db 7385(define_insn "pool"
fd7643fb 7386 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
aee4e0db
UW
7387 ""
7388 "* abort ();"
7389 [(set_attr "op_type" "NN")
7390 (set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
9db1d521 7391
4023fb28
UW
7392;;
7393;; Insns related to generating the function prologue and epilogue.
7394;;
7395
7396
7397(define_expand "prologue"
7398 [(use (const_int 0))]
7399 ""
10bbf137 7400 "s390_emit_prologue (); DONE;")
4023fb28
UW
7401
7402(define_expand "epilogue"
7403 [(use (const_int 1))]
7404 ""
10bbf137 7405 "s390_emit_epilogue (); DONE;")
4023fb28 7406
9e8327e3 7407(define_insn "*return"
4023fb28 7408 [(return)
9e8327e3
UW
7409 (use (match_operand 0 "register_operand" "a"))]
7410 "GET_MODE (operands[0]) == Pmode"
d40c829f 7411 "br\t%0"
4023fb28 7412 [(set_attr "op_type" "RR")
c7453384 7413 (set_attr "type" "jsr")
077dab3b 7414 (set_attr "atype" "agen")])
4023fb28 7415
4023fb28 7416
c7453384
EC
7417;; Instruction definition to extend a 31-bit pointer into a 64-bit
7418;; pointer. This is used for compatability.
7419
7420(define_expand "ptr_extend"
7421 [(set (match_operand:DI 0 "register_operand" "=r")
7422 (match_operand:SI 1 "register_operand" "r"))]
9e8327e3 7423 "TARGET_64BIT"
c7453384 7424{
c7453384
EC
7425 emit_insn (gen_anddi3 (operands[0],
7426 gen_lowpart (DImode, operands[1]),
7427 GEN_INT (0x7fffffff)));
c7453384 7428 DONE;
10bbf137 7429})