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 ;; 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 ;; 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 ;; xx[DS]q satisfies s390_contiguous_bitmask_p for DImode or SImode
60 ;; The constraint matches if the specified part of a constant
61 ;; has a value different from its other parts. If the letter x
62 ;; is specified instead of a part number, the constraint matches
63 ;; if there is any single part with non-default value.
64 ;; O -- Multiple letter constraint followed by 1 parameter.
65 ;; s: Signed extended immediate value (-2G .. 2G-1).
66 ;; p: Positive extended immediate value (0 .. 4G-1).
67 ;; n: Negative extended immediate value (-4G+1 .. -1).
68 ;; These constraints do not accept any operand if the machine does
69 ;; not provide the extended-immediate facility.
70 ;; P -- Any integer constant that can be loaded without literal pool.
71 ;; Q -- Memory reference without index register and with short displacement.
72 ;; R -- Memory reference with index register and short displacement.
73 ;; S -- Memory reference without index register but with long displacement.
74 ;; T -- Memory reference with index register and long displacement.
75 ;; A -- Multiple letter constraint followed by Q, R, S, or T:
76 ;; Offsettable memory reference of type specified by second letter.
77 ;; B -- Multiple letter constraint followed by Q, R, S, or T:
78 ;; Memory reference of the type specified by second letter that
79 ;; does *not* refer to a literal pool entry.
80 ;; U -- Pointer with short displacement. (deprecated - use ZR)
81 ;; W -- Pointer with long displacement. (deprecated - use ZT)
82 ;; Y -- Address style operand without index.
83 ;; ZQ -- Pointer without index register and with short displacement.
84 ;; ZR -- Pointer with index register and short displacement.
85 ;; ZS -- Pointer without index register but with long displacement.
86 ;; ZT -- Pointer with index register and long displacement.
92 ;; Register constraints.
95 (define_register_constraint "a"
97 "Any address register from 1 to 15.")
100 (define_register_constraint "c"
102 "Condition code register 33")
105 (define_register_constraint "d"
107 "Any register from 0 to 15")
110 (define_register_constraint "f"
112 "Floating point registers")
115 (define_register_constraint "t"
118 Access registers 36 and 37")
121 (define_register_constraint "v"
123 "Vector registers v0-v31")
127 ;; General constraints for constants.
130 (define_constraint "C"
132 An 8-bit signed immediate constant (-128..127)"
133 (and (match_code "const_int")
134 (match_test "ival >= -128 && ival <= 127")))
137 (define_constraint "D"
138 "An unsigned 16-bit constant (0..65535)"
139 (and (match_code "const_int")
140 (match_test "ival >= 0 && ival <= 65535")))
143 (define_constraint "G"
145 Const double zero operand"
146 (and (match_code "const_double")
147 (match_test "s390_float_const_zero_p (op)")))
150 (define_constraint "I"
151 "An 8-bit constant (0..255)"
152 (and (match_code "const_int")
153 (match_test "(unsigned HOST_WIDE_INT) ival <= 255")))
156 (define_constraint "J"
157 "A 12-bit constant (0..4095)"
158 (and (match_code "const_int")
159 (match_test "(unsigned HOST_WIDE_INT) ival <= 4095")))
162 (define_constraint "K"
163 "A 16-bit constant (-32768..32767)"
164 (and (match_code "const_int")
165 (match_test "ival >= -32768 && ival <= 32767")))
168 (define_constraint "L"
169 "Value appropriate as displacement.
170 (0..4095) for short displacement
171 (-524288..524287) for long displacement"
172 (and (match_code "const_int")
173 (match_test "TARGET_LONG_DISPLACEMENT ?
174 (ival >= -524288 && ival <= 524287)
175 : (ival >= 0 && ival <= 4095)")))
178 (define_constraint "M"
179 "Constant integer with a value of 0x7fffffff"
180 (and (match_code "const_int")
181 (match_test "ival == 2147483647")))
184 (define_constraint "P"
186 Any integer constant that can be loaded without literal pool"
187 (and (match_code "const_int")
188 (match_test "legitimate_reload_constant_p (GEN_INT (ival))")))
191 (define_address_constraint "Y"
192 "Address style operand without index register"
194 ;; Simply check for base + offset style operands. Reload will take
195 ;; care of making sure we have a proper base register.
197 (match_test "s390_decompose_addrstyle_without_index (op, NULL, NULL)" ))
200 ;; N -- Multiple letter constraint followed by 4 parameter letters.
201 ;; 0..9,x: number of the part counting from most to least significant
202 ;; H,Q: mode of the part
203 ;; D,S,H: mode of the containing operand
204 ;; 0,F: value of the other parts (F = all bits set)
206 ;; The constraint matches if the specified part of a constant
207 ;; has a value different from its other parts. If the letter x
208 ;; is specified instead of a part number, the constraint matches
209 ;; if there is any single part with non-default value.
211 ;; The following patterns define only those constraints that are actually
212 ;; used in s390.md. If you need an additional one, simply add it in the
213 ;; obvious way. Function s390_N_constraint_str is ready to handle all
218 (define_constraint "NxQS0"
220 (and (match_code "const_int")
221 (match_test "s390_N_constraint_str (\"xQS0\", ival)")))
224 (define_constraint "NxQD0"
226 (and (match_code "const_int")
227 (match_test "s390_N_constraint_str (\"xQD0\", ival)")))
230 (define_constraint "N3HD0"
232 (and (match_code "const_int")
233 (match_test "s390_N_constraint_str (\"3HD0\", ival)")))
236 (define_constraint "N2HD0"
238 (and (match_code "const_int")
239 (match_test "s390_N_constraint_str (\"2HD0\", ival)")))
242 (define_constraint "N1SD0"
244 (and (match_code "const_int")
245 (match_test "s390_N_constraint_str (\"1SD0\", ival)")))
248 (define_constraint "N1HS0"
250 (and (match_code "const_int")
251 (match_test "s390_N_constraint_str (\"1HS0\", ival)")))
254 (define_constraint "N1HD0"
256 (and (match_code "const_int")
257 (match_test "s390_N_constraint_str (\"1HD0\", ival)")))
260 (define_constraint "N0SD0"
262 (and (match_code "const_int")
263 (match_test "s390_N_constraint_str (\"0SD0\", ival)")))
266 (define_constraint "N0HS0"
268 (and (match_code "const_int")
269 (match_test "s390_N_constraint_str (\"0HS0\", ival)")))
272 (define_constraint "N0HD0"
274 (and (match_code "const_int")
275 (match_test "s390_N_constraint_str (\"0HD0\", ival)")))
278 (define_constraint "NxQDF"
280 (and (match_code "const_int")
281 (match_test "s390_N_constraint_str (\"xQDF\", ival)")))
284 (define_constraint "N1SDF"
286 (and (match_code "const_int")
287 (match_test "s390_N_constraint_str (\"1SDF\", ival)")))
290 (define_constraint "N0SDF"
292 (and (match_code "const_int")
293 (match_test "s390_N_constraint_str (\"0SDF\", ival)")))
296 (define_constraint "N3HDF"
298 (and (match_code "const_int")
299 (match_test "s390_N_constraint_str (\"3HDF\", ival)")))
302 (define_constraint "N2HDF"
304 (and (match_code "const_int")
305 (match_test "s390_N_constraint_str (\"2HDF\", ival)")))
308 (define_constraint "N1HDF"
310 (and (match_code "const_int")
311 (match_test "s390_N_constraint_str (\"1HDF\", ival)")))
314 (define_constraint "N0HDF"
316 (and (match_code "const_int")
317 (match_test "s390_N_constraint_str (\"0HDF\", ival)")))
320 (define_constraint "N0HSF"
322 (and (match_code "const_int")
323 (match_test "s390_N_constraint_str (\"0HSF\", ival)")))
326 (define_constraint "N1HSF"
328 (and (match_code "const_int")
329 (match_test "s390_N_constraint_str (\"1HSF\", ival)")))
332 (define_constraint "NxQSF"
334 (and (match_code "const_int")
335 (match_test "s390_N_constraint_str (\"xQSF\", ival)")))
338 (define_constraint "NxQHF"
340 (and (match_code "const_int")
341 (match_test "s390_N_constraint_str (\"xQHF\", ival)")))
344 (define_constraint "NxQH0"
346 (and (match_code "const_int")
347 (match_test "s390_N_constraint_str (\"xQH0\", ival)")))
349 (define_constraint "NxxDq"
351 (and (match_code "const_int")
352 (match_test "s390_contiguous_bitmask_p (ival, 64, NULL, NULL)")))
354 (define_constraint "NxxSq"
356 (and (match_code "const_int")
357 (match_test "s390_contiguous_bitmask_p (ival, 32, NULL, NULL)")))
360 ;; Double-letter constraints starting with O follow.
364 (define_constraint "Os"
366 Signed extended immediate value (-2G .. 2G-1).
367 This constraint will only match if the machine provides
368 the extended-immediate facility."
369 (and (match_code "const_int")
370 (match_test "s390_O_constraint_str ('s', ival)")))
373 (define_constraint "Op"
375 Positive extended immediate value (0 .. 4G-1).
376 This constraint will only match if the machine provides
377 the extended-immediate facility."
378 (and (match_code "const_int")
379 (match_test "s390_O_constraint_str ('p', ival)")))
382 (define_constraint "On"
384 Negative extended immediate value (-4G+1 .. -1).
385 This constraint will only match if the machine provides
386 the extended-immediate facility."
387 (and (match_code "const_int")
388 (match_test "s390_O_constraint_str ('n', ival)")))
392 ;; Vector constraints follow.
395 (define_constraint "j00"
396 "Zero scalar or vector constant"
397 (match_test "op == CONST0_RTX (GET_MODE (op))"))
399 (define_constraint "jm1"
400 "All one bit scalar or vector constant"
401 (match_test "op == CONSTM1_RTX (GET_MODE (op))"))
403 (define_constraint "jxx"
405 (and (match_code "const_vector")
406 (match_test "s390_contiguous_bitmask_vector_p (op, NULL, NULL)")))
408 (define_constraint "jyy"
410 (and (match_code "const_vector")
411 (match_test "s390_bytemask_vector_p (op, NULL)")))
413 (define_constraint "jKK"
415 (and (and (match_code "const_vector")
416 (match_test "const_vec_duplicate_p (op)"))
417 (match_test "satisfies_constraint_K (XVECEXP (op, 0, 0))")))
419 (define_constraint "jm6"
420 "@internal An integer operand with the lowest order 6 bits all ones."
421 (match_operand 0 "const_int_6bitset_operand"))
424 ;; Memory constraints follow.
427 (define_memory_constraint "Q"
428 "Memory reference without index register and with short displacement"
429 (match_test "s390_mem_constraint (\"Q\", op)"))
432 (define_memory_constraint "R"
433 "Memory reference with index register and short displacement"
434 (match_test "s390_mem_constraint (\"R\", op)"))
437 (define_memory_constraint "S"
438 "Memory reference without index register but with long displacement"
439 (match_test "s390_mem_constraint (\"S\", op)"))
442 (define_memory_constraint "T"
443 "Memory reference with index register and long displacement"
444 (match_test "s390_mem_constraint (\"T\", op)"))
447 (define_memory_constraint "b"
448 "Memory reference whose address is a naturally aligned symbol reference."
449 (match_test "MEM_P (op)
450 && s390_check_symref_alignment (XEXP (op, 0),
451 GET_MODE_SIZE (GET_MODE (op)))"))
453 ; This defines 'm' as normal memory constraint. This is only possible
454 ; since the standard memory constraint is re-defined in s390.h using
455 ; the TARGET_MEM_CONSTRAINT macro.
456 (define_memory_constraint "m"
457 "Matches the most general memory address for pre-z10 machines."
458 (match_test "s390_mem_constraint (\"T\", op)"))
460 (define_memory_constraint "AQ"
462 Offsettable memory reference without index register and with short displacement"
463 (match_test "s390_mem_constraint (\"AQ\", op)"))
466 (define_memory_constraint "AR"
468 Offsettable memory reference with index register and short displacement"
469 (match_test "s390_mem_constraint (\"AR\", op)"))
472 (define_memory_constraint "AS"
474 Offsettable memory reference without index register but with long displacement"
475 (match_test "s390_mem_constraint (\"AS\", op)"))
478 (define_memory_constraint "AT"
480 Offsettable memory reference with index register and long displacement"
481 (match_test "s390_mem_constraint (\"AT\", op)"))
485 (define_constraint "BQ"
487 Memory reference without index register and with short
488 displacement that does *not* refer to a literal pool entry."
489 (match_test "s390_mem_constraint (\"BQ\", op)"))
492 (define_constraint "BR"
494 Memory reference with index register and short displacement that
495 does *not* refer to a literal pool entry. "
496 (match_test "s390_mem_constraint (\"BR\", op)"))
499 (define_constraint "BS"
501 Memory reference without index register but with long displacement
502 that does *not* refer to a literal pool entry. "
503 (match_test "s390_mem_constraint (\"BS\", op)"))
506 (define_constraint "BT"
508 Memory reference with index register and long displacement that
509 does *not* refer to a literal pool entry. "
510 (match_test "s390_mem_constraint (\"BT\", op)"))
513 (define_address_constraint "U"
514 "Pointer with short displacement. (deprecated - use ZR)"
515 (match_test "s390_mem_constraint (\"ZR\", op)"))
517 (define_address_constraint "W"
518 "Pointer with long displacement. (deprecated - use ZT)"
519 (match_test "s390_mem_constraint (\"ZT\", op)"))
522 (define_address_constraint "ZQ"
523 "Pointer without index register and with short displacement."
524 (match_test "s390_mem_constraint (\"ZQ\", op)"))
526 (define_address_constraint "ZR"
527 "Pointer with index register and short displacement."
528 (match_test "s390_mem_constraint (\"ZR\", op)"))
530 (define_address_constraint "ZS"
531 "Pointer without index register but with long displacement."
532 (match_test "s390_mem_constraint (\"ZS\", op)"))
534 (define_address_constraint "ZT"
535 "Pointer with index register and long displacement."
536 (match_test "s390_mem_constraint (\"ZT\", op)"))