1 ;; Constraints definitions belonging to the gcc backend for IBM S/390.
2 ;; Copyright (C) 2006, 2007, 2008 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 ;; t -- Access registers 36 and 37.
33 ;; C -- A signed 8-bit constant (-128..127)
34 ;; D -- An unsigned 16-bit constant (0..65535)
35 ;; G -- Const double zero operand
36 ;; I -- An 8-bit constant (0..255).
37 ;; J -- A 12-bit constant (0..4095).
38 ;; K -- A 16-bit constant (-32768..32767).
39 ;; L -- Value appropriate as displacement.
40 ;; (0..4095) for short displacement
41 ;; (-524288..524287) for long displacement
42 ;; M -- Constant integer with a value of 0x7fffffff.
43 ;; N -- Multiple letter constraint followed by 4 parameter letters.
44 ;; 0..9,x: number of the part counting from most to least significant
45 ;; H,Q: mode of the part
46 ;; D,S,H: mode of the containing operand
47 ;; 0,F: value of the other parts (F - all bits set)
49 ;; The constraint matches if the specified part of a constant
50 ;; has a value different from its other parts. If the letter x
51 ;; is specified instead of a part number, the constraint matches
52 ;; if there is any single part with non-default value.
53 ;; O -- Multiple letter constraint followed by 1 parameter.
54 ;; s: Signed extended immediate value (-2G .. 2G-1).
55 ;; p: Positive extended immediate value (0 .. 4G-1).
56 ;; n: Negative extended immediate value (-4G+1 .. -1).
57 ;; These constraints do not accept any operand if the machine does
58 ;; not provide the extended-immediate facility.
59 ;; P -- Any integer constant that can be loaded without literal pool.
60 ;; Q -- Memory reference without index register and with short displacement.
61 ;; R -- Memory reference with index register and short displacement.
62 ;; S -- Memory reference without index register but with long displacement.
63 ;; T -- Memory reference with index register and long displacement.
64 ;; A -- Multiple letter constraint followed by Q, R, S, or T:
65 ;; Offsettable memory reference of type specified by second letter.
66 ;; B -- Multiple letter constraint followed by Q, R, S, or T:
67 ;; Memory reference of the type specified by second letter that
68 ;; does *not* refer to a literal pool entry.
69 ;; U -- Pointer with short displacement. (deprecated - use ZQZR)
70 ;; W -- Pointer with long displacement. (deprecated - use ZSZT)
71 ;; Y -- Shift count operand.
72 ;; ZQ -- Pointer without index register and with short displacement.
73 ;; ZR -- Pointer with index register and short displacement.
74 ;; ZS -- Pointer without index register but with long displacement.
75 ;; ZT -- Pointer with index register and long displacement.
81 ;; Register constraints.
84 (define_register_constraint "a"
86 "Any address register from 1 to 15.")
89 (define_register_constraint "c"
91 "Condition code register 33")
94 (define_register_constraint "d"
96 "Any register from 0 to 15")
99 (define_register_constraint "f"
101 "Floating point registers")
104 (define_register_constraint "t"
107 Access registers 36 and 37")
111 ;; General constraints for constants.
114 (define_constraint "C"
116 An 8-bit signed immediate constant (-128..127)"
117 (and (match_code "const_int")
118 (match_test "ival >= -128 && ival <= 127")))
121 (define_constraint "D"
122 "An unsigned 16-bit constant (0..65535)"
123 (and (match_code "const_int")
124 (match_test "ival >= 0 && ival <= 65535")))
127 (define_constraint "G"
129 Const double zero operand"
130 (and (match_code "const_double")
131 (match_test "s390_float_const_zero_p (op)")))
134 (define_constraint "I"
135 "An 8-bit constant (0..255)"
136 (and (match_code "const_int")
137 (match_test "(unsigned HOST_WIDE_INT) ival <= 255")))
140 (define_constraint "J"
141 "A 12-bit constant (0..4095)"
142 (and (match_code "const_int")
143 (match_test "(unsigned HOST_WIDE_INT) ival <= 4095")))
146 (define_constraint "K"
147 "A 16-bit constant (-32768..32767)"
148 (and (match_code "const_int")
149 (match_test "ival >= -32768 && ival <= 32767")))
152 (define_constraint "L"
153 "Value appropriate as displacement.
154 (0..4095) for short displacement
155 (-524288..524287) for long displacement"
156 (and (match_code "const_int")
157 (match_test "TARGET_LONG_DISPLACEMENT ?
158 (ival >= -524288 && ival <= 524287)
159 : (ival >= 0 && ival <= 4095)")))
162 (define_constraint "M"
163 "Constant integer with a value of 0x7fffffff"
164 (and (match_code "const_int")
165 (match_test "ival == 2147483647")))
168 (define_constraint "P"
170 Any integer constant that can be loaded without literal pool"
171 (and (match_code "const_int")
172 (match_test "legitimate_reload_constant_p (GEN_INT (ival))")))
175 (define_address_constraint "Y"
176 "Shift count operand"
178 ;; Simply check for the basic form of a shift count. Reload will
179 ;; take care of making sure we have a proper base register.
181 (match_test "s390_decompose_shift_count (op, NULL, NULL)" ))
184 ;; N -- Multiple letter constraint followed by 4 parameter letters.
185 ;; 0..9,x: number of the part counting from most to least significant
186 ;; H,Q: mode of the part
187 ;; D,S,H: mode of the containing operand
188 ;; 0,F: value of the other parts (F = all bits set)
190 ;; The constraint matches if the specified part of a constant
191 ;; has a value different from its other parts. If the letter x
192 ;; is specified instead of a part number, the constraint matches
193 ;; if there is any single part with non-default value.
195 ;; The following patterns define only those constraints that are actually
196 ;; used in s390.md. If you need an additional one, simply add it in the
197 ;; obvious way. Function s390_N_constraint_str is ready to handle all
202 (define_constraint "NxQS0"
204 (and (match_code "const_int")
205 (match_test "s390_N_constraint_str (\"xQS0\", ival)")))
208 (define_constraint "NxQD0"
210 (and (match_code "const_int")
211 (match_test "s390_N_constraint_str (\"xQD0\", ival)")))
214 (define_constraint "N3HD0"
216 (and (match_code "const_int")
217 (match_test "s390_N_constraint_str (\"3HD0\", ival)")))
220 (define_constraint "N2HD0"
222 (and (match_code "const_int")
223 (match_test "s390_N_constraint_str (\"2HD0\", ival)")))
226 (define_constraint "N1SD0"
228 (and (match_code "const_int")
229 (match_test "s390_N_constraint_str (\"1SD0\", ival)")))
232 (define_constraint "N1HS0"
234 (and (match_code "const_int")
235 (match_test "s390_N_constraint_str (\"1HS0\", ival)")))
238 (define_constraint "N1HD0"
240 (and (match_code "const_int")
241 (match_test "s390_N_constraint_str (\"1HD0\", ival)")))
244 (define_constraint "N0SD0"
246 (and (match_code "const_int")
247 (match_test "s390_N_constraint_str (\"0SD0\", ival)")))
250 (define_constraint "N0HS0"
252 (and (match_code "const_int")
253 (match_test "s390_N_constraint_str (\"0HS0\", ival)")))
256 (define_constraint "N0HD0"
258 (and (match_code "const_int")
259 (match_test "s390_N_constraint_str (\"0HD0\", ival)")))
262 (define_constraint "NxQDF"
264 (and (match_code "const_int")
265 (match_test "s390_N_constraint_str (\"xQDF\", ival)")))
268 (define_constraint "N1SDF"
270 (and (match_code "const_int")
271 (match_test "s390_N_constraint_str (\"1SDF\", ival)")))
274 (define_constraint "N0SDF"
276 (and (match_code "const_int")
277 (match_test "s390_N_constraint_str (\"0SDF\", ival)")))
280 (define_constraint "N3HDF"
282 (and (match_code "const_int")
283 (match_test "s390_N_constraint_str (\"3HDF\", ival)")))
286 (define_constraint "N2HDF"
288 (and (match_code "const_int")
289 (match_test "s390_N_constraint_str (\"2HDF\", ival)")))
292 (define_constraint "N1HDF"
294 (and (match_code "const_int")
295 (match_test "s390_N_constraint_str (\"1HDF\", ival)")))
298 (define_constraint "N0HDF"
300 (and (match_code "const_int")
301 (match_test "s390_N_constraint_str (\"0HDF\", ival)")))
304 (define_constraint "N0HSF"
306 (and (match_code "const_int")
307 (match_test "s390_N_constraint_str (\"0HSF\", ival)")))
310 (define_constraint "N1HSF"
312 (and (match_code "const_int")
313 (match_test "s390_N_constraint_str (\"1HSF\", ival)")))
316 (define_constraint "NxQSF"
318 (and (match_code "const_int")
319 (match_test "s390_N_constraint_str (\"xQSF\", ival)")))
322 (define_constraint "NxQHF"
324 (and (match_code "const_int")
325 (match_test "s390_N_constraint_str (\"xQHF\", ival)")))
328 (define_constraint "NxQH0"
330 (and (match_code "const_int")
331 (match_test "s390_N_constraint_str (\"xQH0\", ival)")))
337 ;; Double-letter constraints starting with O follow.
341 (define_constraint "Os"
343 Signed extended immediate value (-2G .. 2G-1).
344 This constraint will only match if the machine provides
345 the extended-immediate facility."
346 (and (match_code "const_int")
347 (match_test "s390_O_constraint_str ('s', ival)")))
350 (define_constraint "Op"
352 Positive extended immediate value (0 .. 4G-1).
353 This constraint will only match if the machine provides
354 the extended-immediate facility."
355 (and (match_code "const_int")
356 (match_test "s390_O_constraint_str ('p', ival)")))
359 (define_constraint "On"
361 Negative extended immediate value (-4G+1 .. -1).
362 This constraint will only match if the machine provides
363 the extended-immediate facility."
364 (and (match_code "const_int")
365 (match_test "s390_O_constraint_str ('n', ival)")))
371 ;; Memory constraints follow.
374 (define_memory_constraint "Q"
375 "Memory reference without index register and with short displacement"
376 (match_test "s390_mem_constraint (\"Q\", op)"))
379 (define_memory_constraint "R"
380 "Memory reference with index register and short displacement"
381 (match_test "s390_mem_constraint (\"R\", op)"))
384 (define_memory_constraint "S"
385 "Memory reference without index register but with long displacement"
386 (match_test "s390_mem_constraint (\"S\", op)"))
389 (define_memory_constraint "T"
390 "Memory reference with index register and long displacement"
391 (match_test "s390_mem_constraint (\"T\", op)"))
394 (define_memory_constraint "b"
395 "Memory reference whose address is a naturally aligned symbol reference."
396 (match_test "MEM_P (op)
397 && s390_check_symref_alignment (XEXP (op, 0),
398 GET_MODE_SIZE (GET_MODE (op)))"))
400 (define_memory_constraint "e"
401 "Matches all memory references available on the current architecture
402 level. This constraint will never be used and using it in an inline
403 assembly is *always* a bug since there is no instruction accepting all
404 those addresses. It just serves as a placeholder for a generic memory
406 (match_test "strict_memory_address_p (GET_MODE (op), op)"))
408 ; This defines 'm' as normal memory constraint. This is only possible
409 ; since the standard memory constraint is re-defined in s390.h using
410 ; the TARGET_MEM_CONSTRAINT macro.
411 (define_memory_constraint "m"
412 "Matches the most general memory address for pre-z10 machines."
413 (match_test "s390_mem_constraint (\"R\", op)
414 || s390_mem_constraint (\"T\", op)"))
416 (define_memory_constraint "AQ"
418 Offsettable memory reference without index register and with short displacement"
419 (match_test "s390_mem_constraint (\"AQ\", op)"))
422 (define_memory_constraint "AR"
424 Offsettable memory reference with index register and short displacement"
425 (match_test "s390_mem_constraint (\"AR\", op)"))
428 (define_memory_constraint "AS"
430 Offsettable memory reference without index register but with long displacement"
431 (match_test "s390_mem_constraint (\"AS\", op)"))
434 (define_memory_constraint "AT"
436 Offsettable memory reference with index register and long displacement"
437 (match_test "s390_mem_constraint (\"AT\", op)"))
441 (define_constraint "BQ"
443 Memory reference without index register and with short
444 displacement that does *not* refer to a literal pool entry."
445 (match_test "s390_mem_constraint (\"BQ\", op)"))
448 (define_constraint "BR"
450 Memory reference with index register and short displacement that
451 does *not* refer to a literal pool entry. "
452 (match_test "s390_mem_constraint (\"BR\", op)"))
455 (define_constraint "BS"
457 Memory reference without index register but with long displacement
458 that does *not* refer to a literal pool entry. "
459 (match_test "s390_mem_constraint (\"BS\", op)"))
462 (define_constraint "BT"
464 Memory reference with index register and long displacement that
465 does *not* refer to a literal pool entry. "
466 (match_test "s390_mem_constraint (\"BT\", op)"))
469 (define_address_constraint "U"
470 "Pointer with short displacement. (deprecated - use ZQZR)"
471 (match_test "s390_mem_constraint (\"U\", op)"))
473 (define_address_constraint "W"
474 "Pointer with long displacement. (deprecated - use ZSZT)"
475 (match_test "s390_mem_constraint (\"W\", op)"))
478 (define_address_constraint "ZQ"
479 "Pointer without index register and with short displacement."
480 (match_test "s390_mem_constraint (\"ZQ\", op)"))
482 (define_address_constraint "ZR"
483 "Pointer with index register and short displacement."
484 (match_test "s390_mem_constraint (\"ZR\", op)"))
486 (define_address_constraint "ZS"
487 "Pointer without index register but with long displacement."
488 (match_test "s390_mem_constraint (\"ZS\", op)"))
490 (define_address_constraint "ZT"
491 "Pointer with index register and long displacement."
492 (match_test "s390_mem_constraint (\"ZT\", op)"))