2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / config / s390 / constraints.md
blobad953080ff138ea7628c91987955138b70217995
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.
5 ;;
6 ;; This file is part of GCC.
7 ;;
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
11 ;; version.
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
16 ;; for more details.
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.
70 ;;    W -- Pointer with long displacement.
71 ;;    Y -- Shift count operand.
76 ;;  Register constraints.
79 (define_register_constraint "a" 
80   "ADDR_REGS"
81   "Any address register from 1 to 15.")
84 (define_register_constraint "c" 
85   "CC_REGS"
86   "Condition code register 33")
89 (define_register_constraint "d" 
90   "GENERAL_REGS"
91   "Any register from 0 to 15")
94 (define_register_constraint "f" 
95   "FP_REGS"
96   "Floating point registers")
99 (define_register_constraint "t" 
100   "ACCESS_REGS"
101   "@internal
102    Access registers 36 and 37")
106 ;;  General constraints for constants.
109 (define_constraint "C"
110   "@internal
111    An 8-bit signed immediate constant (-128..127)"
112   (and (match_code "const_int")
113        (match_test "ival >= -128 && ival <= 127")))
116 (define_constraint "D"
117   "An unsigned 16-bit constant (0..65535)"
118   (and (match_code "const_int")
119        (match_test "ival >= 0 && ival <= 65535")))
122 (define_constraint "G"
123   "@internal
124    Const double zero operand"
125    (and (match_code "const_double")
126         (match_test "s390_float_const_zero_p (op)")))
129 (define_constraint "I"
130   "An 8-bit constant (0..255)"
131   (and (match_code "const_int")
132        (match_test "(unsigned int) ival <= 255")))
135 (define_constraint "J"
136   "A 12-bit constant (0..4095)"
137   (and (match_code "const_int")
138        (match_test "(unsigned int) ival <= 4095")))
141 (define_constraint "K"
142   "A 16-bit constant (-32768..32767)"
143   (and (match_code "const_int")
144        (match_test "ival >= -32768 && ival <= 32767")))
147 (define_constraint "L"
148   "Value appropriate as displacement.
149       (0..4095) for short displacement
150       (-524288..524287) for long displacement"
151   (and (match_code "const_int")
152        (match_test "TARGET_LONG_DISPLACEMENT ?
153               (ival >= -524288 && ival <= 524287)
154             : (ival >= 0 && ival <= 4095)")))
157 (define_constraint "M"
158   "Constant integer with a value of 0x7fffffff"
159   (and (match_code "const_int")
160        (match_test "ival == 2147483647")))
163 (define_constraint "P"
164   "@internal
165    Any integer constant that can be loaded without literal pool"
166    (and (match_code "const_int")
167         (match_test "legitimate_reload_constant_p (GEN_INT (ival))")))
170 (define_address_constraint "Y"
171   "Shift count operand"
173 ;; Simply check for the basic form of a shift count.  Reload will
174 ;; take care of making sure we have a proper base register.
176   (match_test "s390_decompose_shift_count (op, NULL, NULL)"  ))
179 ;;    N -- Multiple letter constraint followed by 4 parameter letters.
180 ;;         0..9,x:  number of the part counting from most to least significant
181 ;;         H,Q:     mode of the part
182 ;;         D,S,H:   mode of the containing operand
183 ;;         0,F:     value of the other parts (F = all bits set)
185 ;;         The constraint matches if the specified part of a constant
186 ;;         has a value different from its other parts.  If the letter x
187 ;;         is specified instead of a part number, the constraint matches
188 ;;         if there is any single part with non-default value.
190 ;; The following patterns define only those constraints that are actually 
191 ;; used in s390.md.  If you need an additional one, simply add it in the 
192 ;; obvious way.  Function s390_N_constraint_str is ready to handle all 
193 ;; combinations.
197 (define_constraint "NxQS0"
198   "@internal"
199   (and (match_code "const_int")
200        (match_test "s390_N_constraint_str (\"xQS0\", ival)")))
203 (define_constraint "NxQD0"
204   "@internal"
205    (and (match_code "const_int")
206         (match_test "s390_N_constraint_str (\"xQD0\", ival)")))
209 (define_constraint "N3HD0"
210   "@internal"
211   (and (match_code "const_int")
212        (match_test "s390_N_constraint_str (\"3HD0\", ival)")))
215 (define_constraint "N2HD0"
216   "@internal"
217   (and (match_code "const_int")
218        (match_test "s390_N_constraint_str (\"2HD0\", ival)")))
221 (define_constraint "N1SD0"
222   "@internal"
223   (and (match_code "const_int")
224        (match_test "s390_N_constraint_str (\"1SD0\", ival)")))
227 (define_constraint "N1HS0"
228   "@internal"
229   (and (match_code "const_int")
230        (match_test "s390_N_constraint_str (\"1HS0\", ival)")))
233 (define_constraint "N1HD0"
234   "@internal"
235   (and (match_code "const_int")
236        (match_test "s390_N_constraint_str (\"1HD0\", ival)")))
239 (define_constraint "N0SD0"
240   "@internal"
241   (and (match_code "const_int")
242        (match_test "s390_N_constraint_str (\"0SD0\", ival)")))
245 (define_constraint "N0HS0"
246   "@internal"
247   (and (match_code "const_int")
248        (match_test "s390_N_constraint_str (\"0HS0\", ival)")))
251 (define_constraint "N0HD0"
252   "@internal"
253   (and (match_code "const_int")
254        (match_test "s390_N_constraint_str (\"0HD0\", ival)")))
257 (define_constraint "NxQDF"
258   "@internal"
259   (and (match_code "const_int")
260        (match_test "s390_N_constraint_str (\"xQDF\", ival)")))
263 (define_constraint "N1SDF"
264   "@internal"
265   (and (match_code "const_int")
266        (match_test "s390_N_constraint_str (\"1SDF\", ival)")))
269 (define_constraint "N0SDF"
270   "@internal"
271   (and (match_code "const_int")
272        (match_test "s390_N_constraint_str (\"0SDF\", ival)")))
275 (define_constraint "N3HDF"
276   "@internal"
277   (and (match_code "const_int")
278        (match_test "s390_N_constraint_str (\"3HDF\", ival)")))
281 (define_constraint "N2HDF"
282   "@internal"
283   (and (match_code "const_int")
284        (match_test "s390_N_constraint_str (\"2HDF\", ival)")))
287 (define_constraint "N1HDF"
288   "@internal"
289   (and (match_code "const_int")
290        (match_test "s390_N_constraint_str (\"1HDF\", ival)")))
293 (define_constraint "N0HDF"
294   "@internal"
295   (and (match_code "const_int")
296        (match_test "s390_N_constraint_str (\"0HDF\", ival)")))
299 (define_constraint "N0HSF"
300   "@internal"
301   (and (match_code "const_int")
302        (match_test "s390_N_constraint_str (\"0HSF\", ival)")))
305 (define_constraint "N1HSF"
306   "@internal"
307   (and (match_code "const_int")
308        (match_test "s390_N_constraint_str (\"1HSF\", ival)")))
311 (define_constraint "NxQSF"
312   "@internal"
313   (and (match_code "const_int")
314        (match_test "s390_N_constraint_str (\"xQSF\", ival)")))
317 (define_constraint "NxQHF"
318   "@internal"
319   (and (match_code "const_int")
320        (match_test "s390_N_constraint_str (\"xQHF\", ival)")))
323 (define_constraint "NxQH0"
324   "@internal"
325   (and (match_code "const_int")
326        (match_test "s390_N_constraint_str (\"xQH0\", ival)")))
332 ;; Double-letter constraints starting with O follow.
336 (define_constraint "Os"
337   "@internal
338    Signed extended immediate value (-2G .. 2G-1).
339    This constraint will only match if the machine provides
340    the extended-immediate facility."
341   (and (match_code "const_int")
342        (match_test "s390_O_constraint_str ('s', ival)")))
345 (define_constraint "Op"
346   "@internal
347    Positive extended immediate value (0 .. 4G-1).
348    This constraint will only match if the machine provides
349    the extended-immediate facility."
350   (and (match_code "const_int")
351        (match_test "s390_O_constraint_str ('p', ival)")))
354 (define_constraint "On"
355   "@internal
356    Negative extended immediate value (-4G+1 .. -1).
357    This constraint will only match if the machine provides
358    the extended-immediate facility."
359   (and (match_code "const_int")
360        (match_test "s390_O_constraint_str ('n', ival)")))
366 ;; Memory constraints follow.
369 (define_memory_constraint "Q"
370   "Memory reference without index register and with short displacement"
371   (match_test "s390_mem_constraint (\"Q\", op)"))
374 (define_memory_constraint "R"
375   "Memory reference with index register and short displacement"
376   (match_test "s390_mem_constraint (\"R\", op)"))
379 (define_memory_constraint "S"
380   "Memory reference without index register but with long displacement"
381   (match_test "s390_mem_constraint (\"S\", op)"))
384 (define_memory_constraint "T"
385   "Memory reference with index register and long displacement"
386   (match_test "s390_mem_constraint (\"T\", op)"))
389 (define_memory_constraint "b"
390   "Memory reference whose address is a naturally aligned symbol reference."
391   (match_test "MEM_P (op)
392                && s390_check_symref_alignment (XEXP (op, 0),
393                                                GET_MODE_SIZE (GET_MODE (op)))"))
395 (define_memory_constraint "e"
396   "Matches all memory references available on the current architecture
397 level.  This constraint will never be used and using it in an inline
398 assembly is *always* a bug since there is no instruction accepting all
399 those addresses.  It just serves as a placeholder for a generic memory
400 constraint."
401   (match_test "legitimate_address_p (GET_MODE (op), op, 1)"))
403 ; This defines 'm' as normal memory constraint.  This is only possible
404 ; since the standard memory constraint is re-defined in s390.h using
405 ; the TARGET_MEM_CONSTRAINT macro.
406 (define_memory_constraint "m"
407   "Matches the most general memory address for pre-z10 machines."
408   (match_test "s390_mem_constraint (\"R\", op)
409                || s390_mem_constraint (\"T\", op)"))
411 (define_memory_constraint "AQ"
412   "@internal 
413    Offsettable memory reference without index register and with short displacement"
414   (match_test "s390_mem_constraint (\"AQ\", op)"))
417 (define_memory_constraint "AR"
418   "@internal 
419    Offsettable memory reference with index register and short displacement"
420   (match_test "s390_mem_constraint (\"AR\", op)"))
423 (define_memory_constraint "AS"
424   "@internal 
425    Offsettable memory reference without index register but with long displacement"
426   (match_test "s390_mem_constraint (\"AS\", op)"))
429 (define_memory_constraint "AT"
430   "@internal 
431    Offsettable memory reference with index register and long displacement"
432   (match_test "s390_mem_constraint (\"AT\", op)"))
436 (define_constraint "BQ"
437   "@internal 
438    Memory reference without index register and with short 
439    displacement that does *not* refer to a literal pool entry."
440   (match_test "s390_mem_constraint (\"BQ\", op)"))
443 (define_constraint "BR"
444   "@internal 
445    Memory reference with index register and short displacement that
446    does *not* refer to a literal pool entry. "
447   (match_test "s390_mem_constraint (\"BR\", op)"))
450 (define_constraint "BS"
451   "@internal 
452    Memory reference without index register but with long displacement
453    that does *not* refer to a literal pool entry. "
454   (match_test "s390_mem_constraint (\"BS\", op)"))
457 (define_constraint "BT"
458   "@internal 
459    Memory reference with index register and long displacement that
460    does *not* refer to a literal pool entry. "
461   (match_test "s390_mem_constraint (\"BT\", op)"))
464 (define_address_constraint "U"
465   "Pointer with short displacement"
466   (match_test "s390_mem_constraint (\"U\", op)"))
470 (define_address_constraint "W"
471   "Pointer with long displacement"
472   (match_test "s390_mem_constraint (\"W\", op)"))