1 ;; Constraints definitions belonging to the gcc backend for IBM S/390.
2 ;; Copyright (C) 2006-2016 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 ;; t -- Access registers 36 and 37.
40 ;; v -- Vector registers v0-v31.
41 ;; C -- A signed 8-bit constant (-128..127)
42 ;; D -- An unsigned 16-bit constant (0..65535)
43 ;; G -- Const double zero operand
44 ;; I -- An 8-bit constant (0..255).
45 ;; J -- A 12-bit constant (0..4095).
46 ;; K -- A 16-bit constant (-32768..32767).
47 ;; L -- Value appropriate as displacement.
48 ;; (0..4095) for short displacement
49 ;; (-524288..524287) for long displacement
50 ;; M -- Constant integer with a value of 0x7fffffff.
51 ;; N -- Multiple letter constraint followed by 4 parameter letters.
52 ;; 0..9,x: number of the part counting from most to least significant
53 ;; H,Q: mode of the part
54 ;; D,S,H: mode of the containing operand
55 ;; 0,F: value of the other parts (F - all bits set)
57 ;; xx[DS]q satisfies s390_contiguous_bitmask_p for DImode or SImode
59 ;; The constraint matches if the specified part of a constant
60 ;; has a value different from its other parts. If the letter x
61 ;; is specified instead of a part number, the constraint matches
62 ;; if there is any single part with non-default value.
63 ;; O -- Multiple letter constraint followed by 1 parameter.
64 ;; s: Signed extended immediate value (-2G .. 2G-1).
65 ;; p: Positive extended immediate value (0 .. 4G-1).
66 ;; n: Negative extended immediate value (-4G+1 .. -1).
67 ;; These constraints do not accept any operand if the machine does
68 ;; not provide the extended-immediate facility.
69 ;; P -- Any integer constant that can be loaded without literal pool.
70 ;; Q -- Memory reference without index register and with short displacement.
71 ;; R -- Memory reference with index register and short displacement.
72 ;; S -- Memory reference without index register but with long displacement.
73 ;; T -- Memory reference with index register and long displacement.
74 ;; A -- Multiple letter constraint followed by Q, R, S, or T:
75 ;; Offsettable memory reference of type specified by second letter.
76 ;; B -- Multiple letter constraint followed by Q, R, S, or T:
77 ;; Memory reference of the type specified by second letter that
78 ;; does *not* refer to a literal pool entry.
79 ;; U -- Pointer with short displacement. (deprecated - use ZQZR)
80 ;; W -- Pointer with long displacement. (deprecated - use ZSZT)
81 ;; Y -- Shift count operand.
82 ;; ZQ -- Pointer without index register and with short displacement.
83 ;; ZR -- Pointer with index register and short displacement.
84 ;; ZS -- Pointer without index register but with long displacement.
85 ;; ZT -- Pointer with index register and long displacement.
91 ;; Register constraints.
94 (define_register_constraint "a"
96 "Any address register from 1 to 15.")
99 (define_register_constraint "c"
101 "Condition code register 33")
104 (define_register_constraint "d"
106 "Any register from 0 to 15")
109 (define_register_constraint "f"
111 "Floating point registers")
114 (define_register_constraint "t"
117 Access registers 36 and 37")
120 (define_register_constraint "v"
122 "Vector registers v0-v31")
126 ;; General constraints for constants.
129 (define_constraint "C"
131 An 8-bit signed immediate constant (-128..127)"
132 (and (match_code "const_int")
133 (match_test "ival >= -128 && ival <= 127")))
136 (define_constraint "D"
137 "An unsigned 16-bit constant (0..65535)"
138 (and (match_code "const_int")
139 (match_test "ival >= 0 && ival <= 65535")))
142 (define_constraint "G"
144 Const double zero operand"
145 (and (match_code "const_double")
146 (match_test "s390_float_const_zero_p (op)")))
149 (define_constraint "I"
150 "An 8-bit constant (0..255)"
151 (and (match_code "const_int")
152 (match_test "(unsigned HOST_WIDE_INT) ival <= 255")))
155 (define_constraint "J"
156 "A 12-bit constant (0..4095)"
157 (and (match_code "const_int")
158 (match_test "(unsigned HOST_WIDE_INT) ival <= 4095")))
161 (define_constraint "K"
162 "A 16-bit constant (-32768..32767)"
163 (and (match_code "const_int")
164 (match_test "ival >= -32768 && ival <= 32767")))
167 (define_constraint "L"
168 "Value appropriate as displacement.
169 (0..4095) for short displacement
170 (-524288..524287) for long displacement"
171 (and (match_code "const_int")
172 (match_test "TARGET_LONG_DISPLACEMENT ?
173 (ival >= -524288 && ival <= 524287)
174 : (ival >= 0 && ival <= 4095)")))
177 (define_constraint "M"
178 "Constant integer with a value of 0x7fffffff"
179 (and (match_code "const_int")
180 (match_test "ival == 2147483647")))
183 (define_constraint "P"
185 Any integer constant that can be loaded without literal pool"
186 (and (match_code "const_int")
187 (match_test "legitimate_reload_constant_p (GEN_INT (ival))")))
190 (define_address_constraint "Y"
191 "Shift count operand"
193 ;; Simply check for the basic form of a shift count. Reload will
194 ;; take care of making sure we have a proper base register.
196 (match_test "s390_decompose_shift_count (op, NULL, NULL)" ))
199 ;; N -- Multiple letter constraint followed by 4 parameter letters.
200 ;; 0..9,x: number of the part counting from most to least significant
201 ;; H,Q: mode of the part
202 ;; D,S,H: mode of the containing operand
203 ;; 0,F: value of the other parts (F = all bits set)
205 ;; The constraint matches if the specified part of a constant
206 ;; has a value different from its other parts. If the letter x
207 ;; is specified instead of a part number, the constraint matches
208 ;; if there is any single part with non-default value.
210 ;; The following patterns define only those constraints that are actually
211 ;; used in s390.md. If you need an additional one, simply add it in the
212 ;; obvious way. Function s390_N_constraint_str is ready to handle all
217 (define_constraint "NxQS0"
219 (and (match_code "const_int")
220 (match_test "s390_N_constraint_str (\"xQS0\", ival)")))
223 (define_constraint "NxQD0"
225 (and (match_code "const_int")
226 (match_test "s390_N_constraint_str (\"xQD0\", ival)")))
229 (define_constraint "N3HD0"
231 (and (match_code "const_int")
232 (match_test "s390_N_constraint_str (\"3HD0\", ival)")))
235 (define_constraint "N2HD0"
237 (and (match_code "const_int")
238 (match_test "s390_N_constraint_str (\"2HD0\", ival)")))
241 (define_constraint "N1SD0"
243 (and (match_code "const_int")
244 (match_test "s390_N_constraint_str (\"1SD0\", ival)")))
247 (define_constraint "N1HS0"
249 (and (match_code "const_int")
250 (match_test "s390_N_constraint_str (\"1HS0\", ival)")))
253 (define_constraint "N1HD0"
255 (and (match_code "const_int")
256 (match_test "s390_N_constraint_str (\"1HD0\", ival)")))
259 (define_constraint "N0SD0"
261 (and (match_code "const_int")
262 (match_test "s390_N_constraint_str (\"0SD0\", ival)")))
265 (define_constraint "N0HS0"
267 (and (match_code "const_int")
268 (match_test "s390_N_constraint_str (\"0HS0\", ival)")))
271 (define_constraint "N0HD0"
273 (and (match_code "const_int")
274 (match_test "s390_N_constraint_str (\"0HD0\", ival)")))
277 (define_constraint "NxQDF"
279 (and (match_code "const_int")
280 (match_test "s390_N_constraint_str (\"xQDF\", ival)")))
283 (define_constraint "N1SDF"
285 (and (match_code "const_int")
286 (match_test "s390_N_constraint_str (\"1SDF\", ival)")))
289 (define_constraint "N0SDF"
291 (and (match_code "const_int")
292 (match_test "s390_N_constraint_str (\"0SDF\", ival)")))
295 (define_constraint "N3HDF"
297 (and (match_code "const_int")
298 (match_test "s390_N_constraint_str (\"3HDF\", ival)")))
301 (define_constraint "N2HDF"
303 (and (match_code "const_int")
304 (match_test "s390_N_constraint_str (\"2HDF\", ival)")))
307 (define_constraint "N1HDF"
309 (and (match_code "const_int")
310 (match_test "s390_N_constraint_str (\"1HDF\", ival)")))
313 (define_constraint "N0HDF"
315 (and (match_code "const_int")
316 (match_test "s390_N_constraint_str (\"0HDF\", ival)")))
319 (define_constraint "N0HSF"
321 (and (match_code "const_int")
322 (match_test "s390_N_constraint_str (\"0HSF\", ival)")))
325 (define_constraint "N1HSF"
327 (and (match_code "const_int")
328 (match_test "s390_N_constraint_str (\"1HSF\", ival)")))
331 (define_constraint "NxQSF"
333 (and (match_code "const_int")
334 (match_test "s390_N_constraint_str (\"xQSF\", ival)")))
337 (define_constraint "NxQHF"
339 (and (match_code "const_int")
340 (match_test "s390_N_constraint_str (\"xQHF\", ival)")))
343 (define_constraint "NxQH0"
345 (and (match_code "const_int")
346 (match_test "s390_N_constraint_str (\"xQH0\", ival)")))
348 (define_constraint "NxxDq"
350 (and (match_code "const_int")
351 (match_test "s390_contiguous_bitmask_p (ival, 64, NULL, NULL)")))
353 (define_constraint "NxxSq"
355 (and (match_code "const_int")
356 (match_test "s390_contiguous_bitmask_p (ival, 32, NULL, NULL)")))
359 ;; Double-letter constraints starting with O follow.
363 (define_constraint "Os"
365 Signed extended immediate value (-2G .. 2G-1).
366 This constraint will only match if the machine provides
367 the extended-immediate facility."
368 (and (match_code "const_int")
369 (match_test "s390_O_constraint_str ('s', ival)")))
372 (define_constraint "Op"
374 Positive extended immediate value (0 .. 4G-1).
375 This constraint will only match if the machine provides
376 the extended-immediate facility."
377 (and (match_code "const_int")
378 (match_test "s390_O_constraint_str ('p', ival)")))
381 (define_constraint "On"
383 Negative extended immediate value (-4G+1 .. -1).
384 This constraint will only match if the machine provides
385 the extended-immediate facility."
386 (and (match_code "const_int")
387 (match_test "s390_O_constraint_str ('n', ival)")))
391 ;; Vector constraints follow.
394 (define_constraint "j00"
395 "Zero scalar or vector constant"
396 (match_test "op == CONST0_RTX (GET_MODE (op))"))
398 (define_constraint "jm1"
399 "All one bit scalar or vector constant"
400 (match_test "op == CONSTM1_RTX (GET_MODE (op))"))
402 (define_constraint "jxx"
404 (and (match_code "const_vector")
405 (match_test "s390_contiguous_bitmask_vector_p (op, NULL, NULL)")))
407 (define_constraint "jyy"
409 (and (match_code "const_vector")
410 (match_test "s390_bytemask_vector_p (op, NULL)")))
412 (define_constraint "jKK"
414 (and (and (match_code "const_vector")
415 (match_test "const_vec_duplicate_p (op)"))
416 (match_test "satisfies_constraint_K (XVECEXP (op, 0, 0))")))
420 ;; Memory constraints follow.
423 (define_memory_constraint "Q"
424 "Memory reference without index register and with short displacement"
425 (match_test "s390_mem_constraint (\"Q\", op)"))
428 (define_memory_constraint "R"
429 "Memory reference with index register and short displacement"
430 (match_test "s390_mem_constraint (\"R\", op)"))
433 (define_memory_constraint "S"
434 "Memory reference without index register but with long displacement"
435 (match_test "s390_mem_constraint (\"S\", op)"))
438 (define_memory_constraint "T"
439 "Memory reference with index register and long displacement"
440 (match_test "s390_mem_constraint (\"T\", op)"))
443 (define_memory_constraint "b"
444 "Memory reference whose address is a naturally aligned symbol reference."
445 (match_test "MEM_P (op)
446 && s390_check_symref_alignment (XEXP (op, 0),
447 GET_MODE_SIZE (GET_MODE (op)))"))
449 ; This defines 'm' as normal memory constraint. This is only possible
450 ; since the standard memory constraint is re-defined in s390.h using
451 ; the TARGET_MEM_CONSTRAINT macro.
452 (define_memory_constraint "m"
453 "Matches the most general memory address for pre-z10 machines."
454 (match_test "s390_mem_constraint (\"R\", op)
455 || s390_mem_constraint (\"T\", op)"))
457 (define_memory_constraint "AQ"
459 Offsettable memory reference without index register and with short displacement"
460 (match_test "s390_mem_constraint (\"AQ\", op)"))
463 (define_memory_constraint "AR"
465 Offsettable memory reference with index register and short displacement"
466 (match_test "s390_mem_constraint (\"AR\", op)"))
469 (define_memory_constraint "AS"
471 Offsettable memory reference without index register but with long displacement"
472 (match_test "s390_mem_constraint (\"AS\", op)"))
475 (define_memory_constraint "AT"
477 Offsettable memory reference with index register and long displacement"
478 (match_test "s390_mem_constraint (\"AT\", op)"))
482 (define_constraint "BQ"
484 Memory reference without index register and with short
485 displacement that does *not* refer to a literal pool entry."
486 (match_test "s390_mem_constraint (\"BQ\", op)"))
489 (define_constraint "BR"
491 Memory reference with index register and short displacement that
492 does *not* refer to a literal pool entry. "
493 (match_test "s390_mem_constraint (\"BR\", op)"))
496 (define_constraint "BS"
498 Memory reference without index register but with long displacement
499 that does *not* refer to a literal pool entry. "
500 (match_test "s390_mem_constraint (\"BS\", op)"))
503 (define_constraint "BT"
505 Memory reference with index register and long displacement that
506 does *not* refer to a literal pool entry. "
507 (match_test "s390_mem_constraint (\"BT\", op)"))
510 (define_address_constraint "U"
511 "Pointer with short displacement. (deprecated - use ZQZR)"
512 (match_test "s390_mem_constraint (\"U\", op)"))
514 (define_address_constraint "W"
515 "Pointer with long displacement. (deprecated - use ZSZT)"
516 (match_test "s390_mem_constraint (\"W\", op)"))
519 (define_address_constraint "ZQ"
520 "Pointer without index register and with short displacement."
521 (match_test "s390_mem_constraint (\"ZQ\", op)"))
523 (define_address_constraint "ZR"
524 "Pointer with index register and short displacement."
525 (match_test "s390_mem_constraint (\"ZR\", op)"))
527 (define_address_constraint "ZS"
528 "Pointer without index register but with long displacement."
529 (match_test "s390_mem_constraint (\"ZS\", op)"))
531 (define_address_constraint "ZT"
532 "Pointer with index register and long displacement."
533 (match_test "s390_mem_constraint (\"ZT\", op)"))