1 ;; Constraints definitions belonging to the gcc backend for IBM S/390.
2 ;; Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free
20 ;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
25 ;; Special constraints for s/390 machine description:
27 ;; a -- Any address register from 1 to 15.
28 ;; c -- Condition code register 33.
29 ;; d -- Any register from 0 to 15.
30 ;; f -- Floating point registers.
31 ;; t -- Access registers 36 and 37.
32 ;; G -- Const double zero operand
33 ;; I -- An 8-bit constant (0..255).
34 ;; J -- A 12-bit constant (0..4095).
35 ;; K -- A 16-bit constant (-32768..32767).
36 ;; L -- Value appropriate as displacement.
37 ;; (0..4095) for short displacement
38 ;; (-524288..524287) for long displacement
39 ;; M -- Constant integer with a value of 0x7fffffff.
40 ;; N -- Multiple letter constraint followed by 4 parameter letters.
41 ;; 0..9,x: number of the part counting from most to least significant
42 ;; H,Q: mode of the part
43 ;; D,S,H: mode of the containing operand
44 ;; 0,F: value of the other parts (F - all bits set)
46 ;; The constraint matches if the specified part of a constant
47 ;; has a value different from its other parts. If the letter x
48 ;; is specified instead of a part number, the constraint matches
49 ;; if there is any single part with non-default value.
50 ;; O -- Multiple letter constraint followed by 1 parameter.
51 ;; s: Signed extended immediate value (-2G .. 2G-1).
52 ;; p: Positive extended immediate value (0 .. 4G-1).
53 ;; n: Negative extended immediate value (-4G .. -1).
54 ;; These constraints do not accept any operand if the machine does
55 ;; not provide the extended-immediate facility.
56 ;; P -- Any integer constant that can be loaded without literal pool.
57 ;; Q -- Memory reference without index register and with short displacement.
58 ;; R -- Memory reference with index register and short displacement.
59 ;; S -- Memory reference without index register but with long displacement.
60 ;; T -- Memory reference with index register and long displacement.
61 ;; A -- Multiple letter constraint followed by Q, R, S, or T:
62 ;; Offsettable memory reference of type specified by second letter.
63 ;; B -- Multiple letter constraint followed by Q, R, S, or T:
64 ;; Memory reference of the type specified by second letter that
65 ;; does *not* refer to a literal pool entry.
66 ;; U -- Pointer with short displacement.
67 ;; W -- Pointer with long displacement.
68 ;; Y -- Shift count operand.
73 ;; Register constraints.
76 (define_register_constraint "a"
78 "Any address register from 1 to 15.")
81 (define_register_constraint "c"
83 "Condition code register 33")
86 (define_register_constraint "d"
88 "Any register from 0 to 15")
91 (define_register_constraint "f"
93 "Floating point registers")
96 (define_register_constraint "t"
99 Access registers 36 and 37")
103 ;; General constraints for constants.
106 (define_constraint "G"
108 Const double zero operand"
109 (and (match_code "const_double")
110 (match_test "s390_float_const_zero_p (op)")))
113 (define_constraint "I"
114 "An 8-bit constant (0..255)"
115 (and (match_code "const_int")
116 (match_test "(unsigned int) ival <= 255")))
119 (define_constraint "J"
120 "A 12-bit constant (0..4095)"
121 (and (match_code "const_int")
122 (match_test "(unsigned int) ival <= 4095")))
125 (define_constraint "K"
126 "A 16-bit constant (-32768..32767)"
127 (and (match_code "const_int")
128 (match_test "ival >= -32768 && ival <= 32767")))
132 (define_constraint "L"
133 "Value appropriate as displacement.
134 (0..4095) for short displacement
135 (-524288..524287) for long displacement"
136 (and (match_code "const_int")
137 (match_test "TARGET_LONG_DISPLACEMENT ?
138 (ival >= -524288 && ival <= 524287)
139 : (ival >= 0 && ival <= 4095)")))
142 (define_constraint "M"
143 "Constant integer with a value of 0x7fffffff"
144 (and (match_code "const_int")
145 (match_test "ival == 2147483647")))
148 (define_constraint "P"
150 Any integer constant that can be loaded without literal pool"
151 (and (match_code "const_int")
152 (match_test "legitimate_reload_constant_p (GEN_INT (ival))")))
155 (define_address_constraint "Y"
156 "Shift count operand"
158 ;; Simply check for the basic form of a shift count. Reload will
159 ;; take care of making sure we have a proper base register.
161 (match_test "s390_decompose_shift_count (op, NULL, NULL)" ))
164 ;; N -- Multiple letter constraint followed by 4 parameter letters.
165 ;; 0..9,x: number of the part counting from most to least significant
166 ;; H,Q: mode of the part
167 ;; D,S,H: mode of the containing operand
168 ;; 0,F: value of the other parts (F = all bits set)
170 ;; The constraint matches if the specified part of a constant
171 ;; has a value different from its other parts. If the letter x
172 ;; is specified instead of a part number, the constraint matches
173 ;; if there is any single part with non-default value.
175 ;; The following patterns define only those constraints that are actually
176 ;; used in s390.md. If you need an additional one, simply add it in the
177 ;; obvious way. Function s390_N_constraint_str is ready to handle all
182 (define_constraint "NxQS0"
184 (and (match_code "const_int")
185 (match_test "s390_N_constraint_str (\"xQS0\", ival)")))
188 (define_constraint "NxQD0"
190 (and (match_code "const_int")
191 (match_test "s390_N_constraint_str (\"xQD0\", ival)")))
194 (define_constraint "N3HD0"
196 (and (match_code "const_int")
197 (match_test "s390_N_constraint_str (\"3HD0\", ival)")))
200 (define_constraint "N2HD0"
202 (and (match_code "const_int")
203 (match_test "s390_N_constraint_str (\"2HD0\", ival)")))
206 (define_constraint "N1SD0"
208 (and (match_code "const_int")
209 (match_test "s390_N_constraint_str (\"1SD0\", ival)")))
212 (define_constraint "N1HS0"
214 (and (match_code "const_int")
215 (match_test "s390_N_constraint_str (\"1HS0\", ival)")))
218 (define_constraint "N1HD0"
220 (and (match_code "const_int")
221 (match_test "s390_N_constraint_str (\"1HD0\", ival)")))
224 (define_constraint "N0SD0"
226 (and (match_code "const_int")
227 (match_test "s390_N_constraint_str (\"0SD0\", ival)")))
230 (define_constraint "N0HS0"
232 (and (match_code "const_int")
233 (match_test "s390_N_constraint_str (\"0HS0\", ival)")))
236 (define_constraint "N0HD0"
238 (and (match_code "const_int")
239 (match_test "s390_N_constraint_str (\"0HD0\", ival)")))
242 (define_constraint "NxQDF"
244 (and (match_code "const_int")
245 (match_test "s390_N_constraint_str (\"xQDF\", ival)")))
248 (define_constraint "N1SDF"
250 (and (match_code "const_int")
251 (match_test "s390_N_constraint_str (\"1SDF\", ival)")))
254 (define_constraint "N0SDF"
256 (and (match_code "const_int")
257 (match_test "s390_N_constraint_str (\"0SDF\", ival)")))
260 (define_constraint "N3HDF"
262 (and (match_code "const_int")
263 (match_test "s390_N_constraint_str (\"3HDF\", ival)")))
266 (define_constraint "N2HDF"
268 (and (match_code "const_int")
269 (match_test "s390_N_constraint_str (\"2HDF\", ival)")))
272 (define_constraint "N1HDF"
274 (and (match_code "const_int")
275 (match_test "s390_N_constraint_str (\"1HDF\", ival)")))
278 (define_constraint "N0HDF"
280 (and (match_code "const_int")
281 (match_test "s390_N_constraint_str (\"0HDF\", ival)")))
284 (define_constraint "N0HSF"
286 (and (match_code "const_int")
287 (match_test "s390_N_constraint_str (\"0HSF\", ival)")))
290 (define_constraint "N1HSF"
292 (and (match_code "const_int")
293 (match_test "s390_N_constraint_str (\"1HSF\", ival)")))
296 (define_constraint "NxQSF"
298 (and (match_code "const_int")
299 (match_test "s390_N_constraint_str (\"xQSF\", ival)")))
302 (define_constraint "NxQHF"
304 (and (match_code "const_int")
305 (match_test "s390_N_constraint_str (\"xQHF\", ival)")))
308 (define_constraint "NxQH0"
310 (and (match_code "const_int")
311 (match_test "s390_N_constraint_str (\"xQH0\", ival)")))
317 ;; Double-letter constraints starting with O follow.
321 (define_constraint "Os"
323 Signed extended immediate value (-2G .. 2G-1).
324 This constraint will only match if the machine provides
325 the extended-immediate facility."
326 (and (match_code "const_int")
327 (match_test "s390_O_constraint_str ('s', ival)")))
330 (define_constraint "Op"
332 Positive extended immediate value (0 .. 4G-1).
333 This constraint will only match if the machine provides
334 the extended-immediate facility."
335 (and (match_code "const_int")
336 (match_test "s390_O_constraint_str ('p', ival)")))
339 (define_constraint "On"
341 Negative extended immediate value (-4G .. -1).
342 This constraint will only match if the machine provides
343 the extended-immediate facility."
344 (and (match_code "const_int")
345 (match_test "s390_O_constraint_str ('n', ival)")))
351 ;; Memory constraints follow.
354 (define_memory_constraint "Q"
355 "Memory reference without index register and with short displacement"
356 (match_test "s390_mem_constraint (\"Q\", op)"))
360 (define_memory_constraint "R"
361 "Memory reference with index register and short displacement"
362 (match_test "s390_mem_constraint (\"R\", op)"))
365 (define_memory_constraint "S"
366 "Memory reference without index register but with long displacement"
367 (match_test "s390_mem_constraint (\"S\", op)"))
370 (define_memory_constraint "T"
371 "Memory reference with index register and long displacement"
372 (match_test "s390_mem_constraint (\"T\", op)"))
376 (define_memory_constraint "AQ"
378 Offsettable memory reference without index register and with short displacement"
379 (match_test "s390_mem_constraint (\"AQ\", op)"))
382 (define_memory_constraint "AR"
384 Offsettable memory reference with index register and short displacement"
385 (match_test "s390_mem_constraint (\"AR\", op)"))
388 (define_memory_constraint "AS"
390 Offsettable memory reference without index register but with long displacement"
391 (match_test "s390_mem_constraint (\"AS\", op)"))
394 (define_memory_constraint "AT"
396 Offsettable memory reference with index register and long displacement"
397 (match_test "s390_mem_constraint (\"AT\", op)"))
401 (define_constraint "BQ"
403 Memory reference without index register and with short
404 displacement that does *not* refer to a literal pool entry."
405 (match_test "s390_mem_constraint (\"BQ\", op)"))
408 (define_constraint "BR"
410 Memory reference with index register and short displacement that
411 does *not* refer to a literal pool entry. "
412 (match_test "s390_mem_constraint (\"BR\", op)"))
415 (define_constraint "BS"
417 Memory reference without index register but with long displacement
418 that does *not* refer to a literal pool entry. "
419 (match_test "s390_mem_constraint (\"BS\", op)"))
422 (define_constraint "BT"
424 Memory reference with index register and long displacement that
425 does *not* refer to a literal pool entry. "
426 (match_test "s390_mem_constraint (\"BT\", op)"))
430 (define_address_constraint "U"
431 "Pointer with short displacement"
432 (match_test "s390_mem_constraint (\"U\", op)"))
436 (define_address_constraint "W"
437 "Pointer with long displacement"
438 (match_test "s390_mem_constraint (\"W\", op)"))