1 ;; Constraints definitions belonging to the gcc backend for IBM S/390.
2 ;; Copyright (C) 2006, 2007 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 ;; c -- Condition code register 33.
28 ;; d -- Any register from 0 to 15.
29 ;; f -- Floating point registers.
30 ;; t -- Access registers 36 and 37.
31 ;; G -- Const double zero operand
32 ;; I -- An 8-bit constant (0..255).
33 ;; J -- A 12-bit constant (0..4095).
34 ;; K -- A 16-bit constant (-32768..32767).
35 ;; L -- Value appropriate as displacement.
36 ;; (0..4095) for short displacement
37 ;; (-524288..524287) for long displacement
38 ;; M -- Constant integer with a value of 0x7fffffff.
39 ;; N -- Multiple letter constraint followed by 4 parameter letters.
40 ;; 0..9,x: number of the part counting from most to least significant
41 ;; H,Q: mode of the part
42 ;; D,S,H: mode of the containing operand
43 ;; 0,F: value of the other parts (F - all bits set)
45 ;; The constraint matches if the specified part of a constant
46 ;; has a value different from its other parts. If the letter x
47 ;; is specified instead of a part number, the constraint matches
48 ;; if there is any single part with non-default value.
49 ;; O -- Multiple letter constraint followed by 1 parameter.
50 ;; s: Signed extended immediate value (-2G .. 2G-1).
51 ;; p: Positive extended immediate value (0 .. 4G-1).
52 ;; n: Negative extended immediate value (-4G+1 .. -1).
53 ;; These constraints do not accept any operand if the machine does
54 ;; not provide the extended-immediate facility.
55 ;; P -- Any integer constant that can be loaded without literal pool.
56 ;; Q -- Memory reference without index register and with short displacement.
57 ;; R -- Memory reference with index register and short displacement.
58 ;; S -- Memory reference without index register but with long displacement.
59 ;; T -- Memory reference with index register and long displacement.
60 ;; A -- Multiple letter constraint followed by Q, R, S, or T:
61 ;; Offsettable memory reference of type specified by second letter.
62 ;; B -- Multiple letter constraint followed by Q, R, S, or T:
63 ;; Memory reference of the type specified by second letter that
64 ;; does *not* refer to a literal pool entry.
65 ;; U -- Pointer with short displacement.
66 ;; W -- Pointer with long displacement.
67 ;; Y -- Shift count operand.
72 ;; Register constraints.
75 (define_register_constraint "a"
77 "Any address register from 1 to 15.")
80 (define_register_constraint "c"
82 "Condition code register 33")
85 (define_register_constraint "d"
87 "Any register from 0 to 15")
90 (define_register_constraint "f"
92 "Floating point registers")
95 (define_register_constraint "t"
98 Access registers 36 and 37")
102 ;; General constraints for constants.
105 (define_constraint "G"
107 Const double zero operand"
108 (and (match_code "const_double")
109 (match_test "s390_float_const_zero_p (op)")))
112 (define_constraint "I"
113 "An 8-bit constant (0..255)"
114 (and (match_code "const_int")
115 (match_test "(unsigned int) ival <= 255")))
118 (define_constraint "J"
119 "A 12-bit constant (0..4095)"
120 (and (match_code "const_int")
121 (match_test "(unsigned int) ival <= 4095")))
124 (define_constraint "K"
125 "A 16-bit constant (-32768..32767)"
126 (and (match_code "const_int")
127 (match_test "ival >= -32768 && ival <= 32767")))
131 (define_constraint "L"
132 "Value appropriate as displacement.
133 (0..4095) for short displacement
134 (-524288..524287) for long displacement"
135 (and (match_code "const_int")
136 (match_test "TARGET_LONG_DISPLACEMENT ?
137 (ival >= -524288 && ival <= 524287)
138 : (ival >= 0 && ival <= 4095)")))
141 (define_constraint "M"
142 "Constant integer with a value of 0x7fffffff"
143 (and (match_code "const_int")
144 (match_test "ival == 2147483647")))
147 (define_constraint "P"
149 Any integer constant that can be loaded without literal pool"
150 (and (match_code "const_int")
151 (match_test "legitimate_reload_constant_p (GEN_INT (ival))")))
154 (define_address_constraint "Y"
155 "Shift count operand"
157 ;; Simply check for the basic form of a shift count. Reload will
158 ;; take care of making sure we have a proper base register.
160 (match_test "s390_decompose_shift_count (op, NULL, NULL)" ))
163 ;; N -- Multiple letter constraint followed by 4 parameter letters.
164 ;; 0..9,x: number of the part counting from most to least significant
165 ;; H,Q: mode of the part
166 ;; D,S,H: mode of the containing operand
167 ;; 0,F: value of the other parts (F = all bits set)
169 ;; The constraint matches if the specified part of a constant
170 ;; has a value different from its other parts. If the letter x
171 ;; is specified instead of a part number, the constraint matches
172 ;; if there is any single part with non-default value.
174 ;; The following patterns define only those constraints that are actually
175 ;; used in s390.md. If you need an additional one, simply add it in the
176 ;; obvious way. Function s390_N_constraint_str is ready to handle all
181 (define_constraint "NxQS0"
183 (and (match_code "const_int")
184 (match_test "s390_N_constraint_str (\"xQS0\", ival)")))
187 (define_constraint "NxQD0"
189 (and (match_code "const_int")
190 (match_test "s390_N_constraint_str (\"xQD0\", ival)")))
193 (define_constraint "N3HD0"
195 (and (match_code "const_int")
196 (match_test "s390_N_constraint_str (\"3HD0\", ival)")))
199 (define_constraint "N2HD0"
201 (and (match_code "const_int")
202 (match_test "s390_N_constraint_str (\"2HD0\", ival)")))
205 (define_constraint "N1SD0"
207 (and (match_code "const_int")
208 (match_test "s390_N_constraint_str (\"1SD0\", ival)")))
211 (define_constraint "N1HS0"
213 (and (match_code "const_int")
214 (match_test "s390_N_constraint_str (\"1HS0\", ival)")))
217 (define_constraint "N1HD0"
219 (and (match_code "const_int")
220 (match_test "s390_N_constraint_str (\"1HD0\", ival)")))
223 (define_constraint "N0SD0"
225 (and (match_code "const_int")
226 (match_test "s390_N_constraint_str (\"0SD0\", ival)")))
229 (define_constraint "N0HS0"
231 (and (match_code "const_int")
232 (match_test "s390_N_constraint_str (\"0HS0\", ival)")))
235 (define_constraint "N0HD0"
237 (and (match_code "const_int")
238 (match_test "s390_N_constraint_str (\"0HD0\", ival)")))
241 (define_constraint "NxQDF"
243 (and (match_code "const_int")
244 (match_test "s390_N_constraint_str (\"xQDF\", ival)")))
247 (define_constraint "N1SDF"
249 (and (match_code "const_int")
250 (match_test "s390_N_constraint_str (\"1SDF\", ival)")))
253 (define_constraint "N0SDF"
255 (and (match_code "const_int")
256 (match_test "s390_N_constraint_str (\"0SDF\", ival)")))
259 (define_constraint "N3HDF"
261 (and (match_code "const_int")
262 (match_test "s390_N_constraint_str (\"3HDF\", ival)")))
265 (define_constraint "N2HDF"
267 (and (match_code "const_int")
268 (match_test "s390_N_constraint_str (\"2HDF\", ival)")))
271 (define_constraint "N1HDF"
273 (and (match_code "const_int")
274 (match_test "s390_N_constraint_str (\"1HDF\", ival)")))
277 (define_constraint "N0HDF"
279 (and (match_code "const_int")
280 (match_test "s390_N_constraint_str (\"0HDF\", ival)")))
283 (define_constraint "N0HSF"
285 (and (match_code "const_int")
286 (match_test "s390_N_constraint_str (\"0HSF\", ival)")))
289 (define_constraint "N1HSF"
291 (and (match_code "const_int")
292 (match_test "s390_N_constraint_str (\"1HSF\", ival)")))
295 (define_constraint "NxQSF"
297 (and (match_code "const_int")
298 (match_test "s390_N_constraint_str (\"xQSF\", ival)")))
301 (define_constraint "NxQHF"
303 (and (match_code "const_int")
304 (match_test "s390_N_constraint_str (\"xQHF\", ival)")))
307 (define_constraint "NxQH0"
309 (and (match_code "const_int")
310 (match_test "s390_N_constraint_str (\"xQH0\", ival)")))
316 ;; Double-letter constraints starting with O follow.
320 (define_constraint "Os"
322 Signed extended immediate value (-2G .. 2G-1).
323 This constraint will only match if the machine provides
324 the extended-immediate facility."
325 (and (match_code "const_int")
326 (match_test "s390_O_constraint_str ('s', ival)")))
329 (define_constraint "Op"
331 Positive extended immediate value (0 .. 4G-1).
332 This constraint will only match if the machine provides
333 the extended-immediate facility."
334 (and (match_code "const_int")
335 (match_test "s390_O_constraint_str ('p', ival)")))
338 (define_constraint "On"
340 Negative extended immediate value (-4G+1 .. -1).
341 This constraint will only match if the machine provides
342 the extended-immediate facility."
343 (and (match_code "const_int")
344 (match_test "s390_O_constraint_str ('n', ival)")))
350 ;; Memory constraints follow.
353 (define_memory_constraint "Q"
354 "Memory reference without index register and with short displacement"
355 (match_test "s390_mem_constraint (\"Q\", op)"))
359 (define_memory_constraint "R"
360 "Memory reference with index register and short displacement"
361 (match_test "s390_mem_constraint (\"R\", op)"))
364 (define_memory_constraint "S"
365 "Memory reference without index register but with long displacement"
366 (match_test "s390_mem_constraint (\"S\", op)"))
369 (define_memory_constraint "T"
370 "Memory reference with index register and long displacement"
371 (match_test "s390_mem_constraint (\"T\", op)"))
375 (define_memory_constraint "AQ"
377 Offsettable memory reference without index register and with short displacement"
378 (match_test "s390_mem_constraint (\"AQ\", op)"))
381 (define_memory_constraint "AR"
383 Offsettable memory reference with index register and short displacement"
384 (match_test "s390_mem_constraint (\"AR\", op)"))
387 (define_memory_constraint "AS"
389 Offsettable memory reference without index register but with long displacement"
390 (match_test "s390_mem_constraint (\"AS\", op)"))
393 (define_memory_constraint "AT"
395 Offsettable memory reference with index register and long displacement"
396 (match_test "s390_mem_constraint (\"AT\", op)"))
400 (define_constraint "BQ"
402 Memory reference without index register and with short
403 displacement that does *not* refer to a literal pool entry."
404 (match_test "s390_mem_constraint (\"BQ\", op)"))
407 (define_constraint "BR"
409 Memory reference with index register and short displacement that
410 does *not* refer to a literal pool entry. "
411 (match_test "s390_mem_constraint (\"BR\", op)"))
414 (define_constraint "BS"
416 Memory reference without index register but with long displacement
417 that does *not* refer to a literal pool entry. "
418 (match_test "s390_mem_constraint (\"BS\", op)"))
421 (define_constraint "BT"
423 Memory reference with index register and long displacement that
424 does *not* refer to a literal pool entry. "
425 (match_test "s390_mem_constraint (\"BT\", op)"))
429 (define_address_constraint "U"
430 "Pointer with short displacement"
431 (match_test "s390_mem_constraint (\"U\", op)"))
435 (define_address_constraint "W"
436 "Pointer with long displacement"
437 (match_test "s390_mem_constraint (\"W\", op)"))