1 ;; Constraints definitions belonging to the gcc backend for IBM S/390.
2 ;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
3 ;; Written by Wolfgang Gellerich, using code and information found in
4 ;; files s390.md, s390.h, and s390.c.
6 ;; This file is part of GCC.
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 3, or (at your option) any later
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
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING3. If not see
20 ;; <http://www.gnu.org/licenses/>.
24 ;; Special constraints for s/390 machine description:
26 ;; a -- Any address register from 1 to 15.
27 ;; b -- Memory operand whose address is a symbol reference or a symbol
28 ;; reference + constant which can be proven to be naturally aligned.
29 ;; c -- Condition code register 33.
30 ;; d -- Any register from 0 to 15.
31 ;; f -- Floating point registers.
32 ;; j -- Multiple letter constraint for constant scalar and vector values
33 ;; j00: constant zero scalar or vector
34 ;; jm1: constant scalar or vector with all bits set
35 ;; jxx: contiguous bitmask of 0 or 1 in all vector elements
36 ;; jyy: constant consisting of byte chunks being either 0 or 0xff
37 ;; jKK: constant vector with all elements having the same value and
38 ;; matching K constraint
39 ;; jm6: An integer operand with the lowest order 6 bits all ones.
40 ;; t -- Access registers 36 and 37.
41 ;; v -- Vector registers v0-v31.
42 ;; C -- A signed 8-bit constant (-128..127)
43 ;; D -- An unsigned 16-bit constant (0..65535)
44 ;; G -- Const double zero operand
45 ;; I -- An 8-bit constant (0..255).
46 ;; J -- A 12-bit constant (0..4095).
47 ;; K -- A 16-bit constant (-32768..32767).
48 ;; L -- Value appropriate as displacement.
49 ;; (0..4095) for short displacement
50 ;; (-524288..524287) for long displacement
51 ;; M -- Constant integer with a value of 0x7fffffff.
52 ;; N -- Multiple letter constraint followed by 4 parameter letters.
53 ;; 0..9,x: number of the part counting from most to least significant
54 ;; S,H,Q: mode of the part
55 ;; D,S,H: mode of the containing operand
56 ;; 0,F: value of the other parts (F - all bits set)
58 ;; xxDq satisfies s390_contiguous_bitmask_p for DImode
59 ;; (with possible wraparound of the one-bit range)
60 ;; xxSw satisfies s390_contiguous_bitmask_p for SImode
61 ;; (with possible wraparound of the one-bit range)
62 ;; xxSq satisfies s390_contiguous_bitmask_nowrap_p for SImode
63 ;; (without wraparound of the one-bit range)
65 ;; The constraint matches if the specified part of a constant
66 ;; has a value different from its other parts. If the letter x
67 ;; is specified instead of a part number, the constraint matches
68 ;; if there is any single part with non-default value.
69 ;; O -- Multiple letter constraint followed by 1 parameter.
70 ;; s: Signed extended immediate value (-2G .. 2G-1).
71 ;; p: Positive extended immediate value (0 .. 4G-1).
72 ;; n: Negative extended immediate value (-4G+1 .. -1).
73 ;; These constraints do not accept any operand if the machine does
74 ;; not provide the extended-immediate facility.
75 ;; P -- Any integer constant that can be loaded without literal pool.
76 ;; Q -- Memory reference without index register and with short displacement.
77 ;; R -- Memory reference with index register and short displacement.
78 ;; S -- Memory reference without index register but with long displacement.
79 ;; T -- Memory reference with index register and long displacement.
80 ;; A -- Multiple letter constraint followed by Q, R, S, or T:
81 ;; Offsettable memory reference of type specified by second letter.
82 ;; B -- Multiple letter constraint followed by Q, R, S, or T:
83 ;; Memory reference of the type specified by second letter that
84 ;; does *not* refer to a literal pool entry.
85 ;; U -- Pointer with short displacement. (deprecated - use ZR)
86 ;; W -- Pointer with long displacement. (deprecated - use ZT)
87 ;; Y -- Address style operand without index.
88 ;; ZQ -- Pointer without index register and with short displacement.
89 ;; ZR -- Pointer with index register and short displacement.
90 ;; ZS -- Pointer without index register but with long displacement.
91 ;; ZT -- Pointer with index register and long displacement.
92 ;; ZL -- LARL operand when in 64-bit mode, otherwise nothing.
98 ;; Register constraints.
101 (define_register_constraint "a"
103 "Any address register from 1 to 15.")
106 (define_register_constraint "c"
108 "Condition code register 33")
111 (define_register_constraint "d"
113 "Any register from 0 to 15")
116 (define_register_constraint "f"
118 "Floating point registers")
121 (define_register_constraint "t"
124 Access registers 36 and 37")
127 (define_register_constraint "v"
129 "Vector registers v0-v31")
133 ;; General constraints for constants.
136 (define_constraint "C"
138 An 8-bit signed immediate constant (-128..127)"
139 (and (match_code "const_int")
140 (match_test "ival >= -128 && ival <= 127")))
143 (define_constraint "D"
144 "An unsigned 16-bit constant (0..65535)"
145 (and (match_code "const_int")
146 (match_test "ival >= 0 && ival <= 65535")))
149 (define_constraint "G"
151 Const double zero operand"
152 (and (match_code "const_double")
153 (match_test "s390_float_const_zero_p (op)")))
156 (define_constraint "I"
157 "An 8-bit constant (0..255)"
158 (and (match_code "const_int")
159 (match_test "(unsigned HOST_WIDE_INT) ival <= 255")))
162 (define_constraint "J"
163 "A 12-bit constant (0..4095)"
164 (and (match_code "const_int")
165 (match_test "(unsigned HOST_WIDE_INT) ival <= 4095")))
168 (define_constraint "K"
169 "A 16-bit constant (-32768..32767)"
170 (and (match_code "const_int")
171 (match_test "ival >= -32768 && ival <= 32767")))
174 (define_constraint "L"
175 "Value appropriate as displacement.
176 (0..4095) for short displacement
177 (-524288..524287) for long displacement"
178 (and (match_code "const_int")
179 (match_test "TARGET_LONG_DISPLACEMENT ?
180 (ival >= -524288 && ival <= 524287)
181 : (ival >= 0 && ival <= 4095)")))
184 (define_constraint "M"
185 "Constant integer with a value of 0x7fffffff"
186 (and (match_code "const_int")
187 (match_test "ival == 2147483647")))
190 (define_constraint "P"
192 Any integer constant that can be loaded without literal pool"
193 (and (match_code "const_int")
194 (match_test "legitimate_reload_constant_p (GEN_INT (ival))")))
197 (define_address_constraint "Y"
198 "Address style operand without index register"
200 ;; Simply check for base + offset style operands. Reload will take
201 ;; care of making sure we have a proper base register.
203 (match_test "s390_decompose_addrstyle_without_index (op, NULL, NULL)" ))
206 ;; N -- Multiple letter constraint followed by 4 parameter letters.
207 ;; 0..9,x: number of the part counting from most to least significant
208 ;; S,H,Q: mode of the part
209 ;; D,S,H: mode of the containing operand
210 ;; 0,F: value of the other parts (F = all bits set)
212 ;; The constraint matches if the specified part of a constant
213 ;; has a value different from its other parts. If the letter x
214 ;; is specified instead of a part number, the constraint matches
215 ;; if there is any single part with non-default value.
217 ;; The following patterns define only those constraints that are actually
218 ;; used in s390.md. If you need an additional one, simply add it in the
219 ;; obvious way. Function s390_N_constraint_str is ready to handle all
224 (define_constraint "NxQS0"
226 (and (match_code "const_int")
227 (match_test "s390_N_constraint_str (\"xQS0\", ival)")))
230 (define_constraint "NxHD0"
232 (and (match_code "const_int")
233 (match_test "s390_N_constraint_str (\"xHD0\", ival)")))
236 (define_constraint "NxSD0"
238 (and (match_code "const_int")
239 (match_test "s390_N_constraint_str (\"xSD0\", ival)")))
242 (define_constraint "NxQD0"
244 (and (match_code "const_int")
245 (match_test "s390_N_constraint_str (\"xQD0\", ival)")))
248 (define_constraint "N3HD0"
250 (and (match_code "const_int")
251 (match_test "s390_N_constraint_str (\"3HD0\", ival)")))
254 (define_constraint "N2HD0"
256 (and (match_code "const_int")
257 (match_test "s390_N_constraint_str (\"2HD0\", ival)")))
260 (define_constraint "N1SD0"
262 (and (match_code "const_int")
263 (match_test "s390_N_constraint_str (\"1SD0\", ival)")))
266 (define_constraint "N1HS0"
268 (and (match_code "const_int")
269 (match_test "s390_N_constraint_str (\"1HS0\", ival)")))
272 (define_constraint "N1HD0"
274 (and (match_code "const_int")
275 (match_test "s390_N_constraint_str (\"1HD0\", ival)")))
278 (define_constraint "N0SD0"
280 (and (match_code "const_int")
281 (match_test "s390_N_constraint_str (\"0SD0\", ival)")))
284 (define_constraint "N0HS0"
286 (and (match_code "const_int")
287 (match_test "s390_N_constraint_str (\"0HS0\", ival)")))
290 (define_constraint "N0HD0"
292 (and (match_code "const_int")
293 (match_test "s390_N_constraint_str (\"0HD0\", ival)")))
296 (define_constraint "NxQDF"
298 (and (match_code "const_int")
299 (match_test "s390_N_constraint_str (\"xQDF\", ival)")))
302 (define_constraint "N1SDF"
304 (and (match_code "const_int")
305 (match_test "s390_N_constraint_str (\"1SDF\", ival)")))
308 (define_constraint "N0SDF"
310 (and (match_code "const_int")
311 (match_test "s390_N_constraint_str (\"0SDF\", ival)")))
314 (define_constraint "N3HDF"
316 (and (match_code "const_int")
317 (match_test "s390_N_constraint_str (\"3HDF\", ival)")))
320 (define_constraint "N2HDF"
322 (and (match_code "const_int")
323 (match_test "s390_N_constraint_str (\"2HDF\", ival)")))
326 (define_constraint "N1HDF"
328 (and (match_code "const_int")
329 (match_test "s390_N_constraint_str (\"1HDF\", ival)")))
332 (define_constraint "N0HDF"
334 (and (match_code "const_int")
335 (match_test "s390_N_constraint_str (\"0HDF\", ival)")))
338 (define_constraint "N0HSF"
340 (and (match_code "const_int")
341 (match_test "s390_N_constraint_str (\"0HSF\", ival)")))
344 (define_constraint "N1HSF"
346 (and (match_code "const_int")
347 (match_test "s390_N_constraint_str (\"1HSF\", ival)")))
350 (define_constraint "NxQSF"
352 (and (match_code "const_int")
353 (match_test "s390_N_constraint_str (\"xQSF\", ival)")))
356 (define_constraint "NxQHF"
358 (and (match_code "const_int")
359 (match_test "s390_N_constraint_str (\"xQHF\", ival)")))
362 (define_constraint "NxQH0"
364 (and (match_code "const_int")
365 (match_test "s390_N_constraint_str (\"xQH0\", ival)")))
367 (define_constraint "NxxDw"
369 (and (match_code "const_int")
370 (match_test "s390_contiguous_bitmask_p (ival, true, 64, NULL, NULL)")))
372 (define_constraint "NxxSq"
374 (and (match_code "const_int")
375 (match_test "s390_contiguous_bitmask_p (ival, false, 32, NULL, NULL)")))
377 (define_constraint "NxxSw"
379 (and (match_code "const_int")
380 (match_test "s390_contiguous_bitmask_p (ival, true, 32, NULL, NULL)")))
383 ;; Double-letter constraints starting with O follow.
387 (define_constraint "Os"
389 Signed extended immediate value (-2G .. 2G-1).
390 This constraint will only match if the machine provides
391 the extended-immediate facility."
392 (and (match_code "const_int")
393 (match_test "s390_O_constraint_str ('s', ival)")))
396 (define_constraint "Op"
398 Positive extended immediate value (0 .. 4G-1).
399 This constraint will only match if the machine provides
400 the extended-immediate facility."
401 (and (match_code "const_int")
402 (match_test "s390_O_constraint_str ('p', ival)")))
405 (define_constraint "On"
407 Negative extended immediate value (-4G+1 .. -1).
408 This constraint will only match if the machine provides
409 the extended-immediate facility."
410 (and (match_code "const_int")
411 (match_test "s390_O_constraint_str ('n', ival)")))
415 ;; Vector constraints follow.
418 (define_constraint "j00"
419 "Zero scalar or vector constant"
420 (match_test "op == CONST0_RTX (GET_MODE (op))"))
422 (define_constraint "jm1"
423 "All one bit scalar or vector constant"
424 (match_test "op == CONSTM1_RTX (GET_MODE (op))"))
426 ; vector generate mask operand - support for up to 64 bit elements
427 (define_constraint "jxx"
429 (and (match_code "const_vector")
430 (match_test "s390_contiguous_bitmask_vector_p (op, NULL, NULL)")))
432 ; vector generate byte mask operand - this is only supposed to deal
433 ; with real vectors 128 bit values of being either 0 or -1 are handled
435 (define_constraint "jyy"
437 (and (match_code "const_vector")
438 (match_test "s390_bytemask_vector_p (op, NULL)")))
440 ; vector replicate immediate operand - support for up to 64 bit elements
441 (define_constraint "jKK"
443 (and (and (and (match_code "const_vector")
444 (match_test "const_vec_duplicate_p (op)"))
445 (match_test "GET_MODE_UNIT_SIZE (GET_MODE (op)) <= 8"))
446 (match_test "satisfies_constraint_K (XVECEXP (op, 0, 0))")))
448 (define_constraint "jm6"
449 "@internal An integer operand with the lowest order 6 bits all ones."
450 (match_operand 0 "const_int_6bitset_operand"))
453 ;; Memory constraints follow.
456 (define_memory_constraint "Q"
457 "Memory reference without index register and with short displacement"
458 (match_test "s390_mem_constraint (\"Q\", op)"))
461 (define_memory_constraint "R"
462 "Memory reference with index register and short displacement"
463 (match_test "s390_mem_constraint (\"R\", op)"))
466 (define_memory_constraint "S"
467 "Memory reference without index register but with long displacement"
468 (match_test "s390_mem_constraint (\"S\", op)"))
471 (define_memory_constraint "T"
472 "Memory reference with index register and long displacement"
473 (match_test "s390_mem_constraint (\"T\", op)"))
476 (define_memory_constraint "b"
477 "Memory reference whose address is a naturally aligned symbol reference."
478 (match_test "MEM_P (op)
479 && s390_check_symref_alignment (XEXP (op, 0),
480 GET_MODE_SIZE (GET_MODE (op)))"))
482 ; This defines 'm' as normal memory constraint. This is only possible
483 ; since the standard memory constraint is re-defined in s390.h using
484 ; the TARGET_MEM_CONSTRAINT macro.
485 (define_memory_constraint "m"
486 "Matches the most general memory address for pre-z10 machines."
487 (match_test "s390_mem_constraint (\"T\", op)"))
489 (define_memory_constraint "AQ"
491 Offsettable memory reference without index register and with short displacement"
492 (match_test "s390_mem_constraint (\"AQ\", op)"))
495 (define_memory_constraint "AR"
497 Offsettable memory reference with index register and short displacement"
498 (match_test "s390_mem_constraint (\"AR\", op)"))
501 (define_memory_constraint "AS"
503 Offsettable memory reference without index register but with long displacement"
504 (match_test "s390_mem_constraint (\"AS\", op)"))
507 (define_memory_constraint "AT"
509 Offsettable memory reference with index register and long displacement"
510 (match_test "s390_mem_constraint (\"AT\", op)"))
514 (define_constraint "BQ"
516 Memory reference without index register and with short
517 displacement that does *not* refer to a literal pool entry."
518 (match_test "s390_mem_constraint (\"BQ\", op)"))
521 (define_constraint "BR"
523 Memory reference with index register and short displacement that
524 does *not* refer to a literal pool entry. "
525 (match_test "s390_mem_constraint (\"BR\", op)"))
528 (define_constraint "BS"
530 Memory reference without index register but with long displacement
531 that does *not* refer to a literal pool entry. "
532 (match_test "s390_mem_constraint (\"BS\", op)"))
535 (define_constraint "BT"
537 Memory reference with index register and long displacement that
538 does *not* refer to a literal pool entry. "
539 (match_test "s390_mem_constraint (\"BT\", op)"))
542 (define_address_constraint "U"
543 "Pointer with short displacement. (deprecated - use ZR)"
544 (match_test "s390_mem_constraint (\"ZR\", op)"))
546 (define_address_constraint "W"
547 "Pointer with long displacement. (deprecated - use ZT)"
548 (match_test "s390_mem_constraint (\"ZT\", op)"))
551 (define_address_constraint "ZQ"
552 "Pointer without index register and with short displacement."
553 (match_test "s390_mem_constraint (\"ZQ\", op)"))
555 (define_address_constraint "ZR"
556 "Pointer with index register and short displacement."
557 (match_test "s390_mem_constraint (\"ZR\", op)"))
559 (define_address_constraint "ZS"
560 "Pointer without index register but with long displacement."
561 (match_test "s390_mem_constraint (\"ZS\", op)"))
563 (define_address_constraint "ZT"
564 "Pointer with index register and long displacement."
565 (match_test "s390_mem_constraint (\"ZT\", op)"))
567 (define_constraint "ZL"
568 "LARL operand when in 64-bit mode, otherwise nothing."
569 (match_test "TARGET_64BIT && larl_operand (op, VOIDmode)"))