Configury changes for obstack optimization
[official-gcc.git] / gcc / config / s390 / constraints.md
blob66d4acecdb3524f21993a59381519a4565f470a6
1 ;; Constraints definitions belonging to the gcc backend for IBM S/390.
2 ;; Copyright (C) 2006-2015 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 ;;    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 ;;    t -- Access registers 36 and 37.
38 ;;    v -- Vector registers v0-v31.
39 ;;    C -- A signed 8-bit constant (-128..127)
40 ;;    D -- An unsigned 16-bit constant (0..65535)
41 ;;    G -- Const double zero operand
42 ;;    I -- An 8-bit constant (0..255).
43 ;;    J -- A 12-bit constant (0..4095).
44 ;;    K -- A 16-bit constant (-32768..32767).
45 ;;    L -- Value appropriate as displacement.
46 ;;         (0..4095) for short displacement
47 ;;         (-524288..524287) for long displacement
48 ;;    M -- Constant integer with a value of 0x7fffffff.
49 ;;    N -- Multiple letter constraint followed by 4 parameter letters.
50 ;;         0..9,x:  number of the part counting from most to least significant
51 ;;         H,Q:     mode of the part
52 ;;         D,S,H:   mode of the containing operand
53 ;;         0,F:     value of the other parts (F - all bits set)
54 ;;         --
55 ;;         xx[DS]q  satisfies s390_contiguous_bitmask_p for DImode or SImode
57 ;;         The constraint matches if the specified part of a constant
58 ;;         has a value different from its other parts.  If the letter x
59 ;;         is specified instead of a part number, the constraint matches
60 ;;         if there is any single part with non-default value.
61 ;;    O -- Multiple letter constraint followed by 1 parameter.
62 ;;         s:  Signed extended immediate value (-2G .. 2G-1).
63 ;;         p:  Positive extended immediate value (0 .. 4G-1).
64 ;;         n:  Negative extended immediate value (-4G+1 .. -1).
65 ;;         These constraints do not accept any operand if the machine does
66 ;;         not provide the extended-immediate facility.
67 ;;    P -- Any integer constant that can be loaded without literal pool.
68 ;;    Q -- Memory reference without index register and with short displacement.
69 ;;    R -- Memory reference with index register and short displacement.
70 ;;    S -- Memory reference without index register but with long displacement.
71 ;;    T -- Memory reference with index register and long displacement.
72 ;;    A -- Multiple letter constraint followed by Q, R, S, or T:
73 ;;         Offsettable memory reference of type specified by second letter.
74 ;;    B -- Multiple letter constraint followed by Q, R, S, or T:
75 ;;         Memory reference of the type specified by second letter that
76 ;;         does *not* refer to a literal pool entry.
77 ;;    U -- Pointer with short displacement. (deprecated - use ZQZR)
78 ;;    W -- Pointer with long displacement. (deprecated - use ZSZT)
79 ;;    Y -- Shift count operand.
80 ;;    ZQ -- Pointer without index register and with short displacement.
81 ;;    ZR -- Pointer with index register and short displacement.
82 ;;    ZS -- Pointer without index register but with long displacement.
83 ;;    ZT -- Pointer with index register and long displacement.
89 ;;  Register constraints.
92 (define_register_constraint "a"
93   "ADDR_REGS"
94   "Any address register from 1 to 15.")
97 (define_register_constraint "c"
98   "CC_REGS"
99   "Condition code register 33")
102 (define_register_constraint "d"
103   "GENERAL_REGS"
104   "Any register from 0 to 15")
107 (define_register_constraint "f"
108   "FP_REGS"
109   "Floating point registers")
111 (define_constraint "j00"
112   "Zero scalar or vector constant"
113   (match_test "op == CONST0_RTX (GET_MODE (op))"))
115 (define_constraint "jm1"
116   "All one bit scalar or vector constant"
117   (match_test "op == CONSTM1_RTX (GET_MODE (op))"))
119 (define_constraint "jxx"
120   "@internal"
121   (and (match_code "const_vector")
122        (match_test "s390_contiguous_bitmask_vector_p (op, NULL, NULL)")))
124 (define_constraint "jyy"
125   "@internal"
126   (and (match_code "const_vector")
127        (match_test "s390_bytemask_vector_p (op, NULL)")))
129 (define_register_constraint "t"
130   "ACCESS_REGS"
131   "@internal
132    Access registers 36 and 37")
135 (define_register_constraint "v"
136   "VEC_REGS"
137   "Vector registers v0-v31")
141 ;;  General constraints for constants.
144 (define_constraint "C"
145   "@internal
146    An 8-bit signed immediate constant (-128..127)"
147   (and (match_code "const_int")
148        (match_test "ival >= -128 && ival <= 127")))
151 (define_constraint "D"
152   "An unsigned 16-bit constant (0..65535)"
153   (and (match_code "const_int")
154        (match_test "ival >= 0 && ival <= 65535")))
157 (define_constraint "G"
158   "@internal
159    Const double zero operand"
160    (and (match_code "const_double")
161         (match_test "s390_float_const_zero_p (op)")))
164 (define_constraint "I"
165   "An 8-bit constant (0..255)"
166   (and (match_code "const_int")
167        (match_test "(unsigned HOST_WIDE_INT) ival <= 255")))
170 (define_constraint "J"
171   "A 12-bit constant (0..4095)"
172   (and (match_code "const_int")
173        (match_test "(unsigned HOST_WIDE_INT) ival <= 4095")))
176 (define_constraint "K"
177   "A 16-bit constant (-32768..32767)"
178   (and (match_code "const_int")
179        (match_test "ival >= -32768 && ival <= 32767")))
182 (define_constraint "L"
183   "Value appropriate as displacement.
184       (0..4095) for short displacement
185       (-524288..524287) for long displacement"
186   (and (match_code "const_int")
187        (match_test "TARGET_LONG_DISPLACEMENT ?
188               (ival >= -524288 && ival <= 524287)
189             : (ival >= 0 && ival <= 4095)")))
192 (define_constraint "M"
193   "Constant integer with a value of 0x7fffffff"
194   (and (match_code "const_int")
195        (match_test "ival == 2147483647")))
198 (define_constraint "P"
199   "@internal
200    Any integer constant that can be loaded without literal pool"
201    (and (match_code "const_int")
202         (match_test "legitimate_reload_constant_p (GEN_INT (ival))")))
205 (define_address_constraint "Y"
206   "Shift count operand"
208 ;; Simply check for the basic form of a shift count.  Reload will
209 ;; take care of making sure we have a proper base register.
211   (match_test "s390_decompose_shift_count (op, NULL, NULL)"  ))
214 ;;    N -- Multiple letter constraint followed by 4 parameter letters.
215 ;;         0..9,x:  number of the part counting from most to least significant
216 ;;         H,Q:     mode of the part
217 ;;         D,S,H:   mode of the containing operand
218 ;;         0,F:     value of the other parts (F = all bits set)
220 ;;         The constraint matches if the specified part of a constant
221 ;;         has a value different from its other parts.  If the letter x
222 ;;         is specified instead of a part number, the constraint matches
223 ;;         if there is any single part with non-default value.
225 ;; The following patterns define only those constraints that are actually
226 ;; used in s390.md.  If you need an additional one, simply add it in the
227 ;; obvious way.  Function s390_N_constraint_str is ready to handle all
228 ;; combinations.
232 (define_constraint "NxQS0"
233   "@internal"
234   (and (match_code "const_int")
235        (match_test "s390_N_constraint_str (\"xQS0\", ival)")))
238 (define_constraint "NxQD0"
239   "@internal"
240    (and (match_code "const_int")
241         (match_test "s390_N_constraint_str (\"xQD0\", ival)")))
244 (define_constraint "N3HD0"
245   "@internal"
246   (and (match_code "const_int")
247        (match_test "s390_N_constraint_str (\"3HD0\", ival)")))
250 (define_constraint "N2HD0"
251   "@internal"
252   (and (match_code "const_int")
253        (match_test "s390_N_constraint_str (\"2HD0\", ival)")))
256 (define_constraint "N1SD0"
257   "@internal"
258   (and (match_code "const_int")
259        (match_test "s390_N_constraint_str (\"1SD0\", ival)")))
262 (define_constraint "N1HS0"
263   "@internal"
264   (and (match_code "const_int")
265        (match_test "s390_N_constraint_str (\"1HS0\", ival)")))
268 (define_constraint "N1HD0"
269   "@internal"
270   (and (match_code "const_int")
271        (match_test "s390_N_constraint_str (\"1HD0\", ival)")))
274 (define_constraint "N0SD0"
275   "@internal"
276   (and (match_code "const_int")
277        (match_test "s390_N_constraint_str (\"0SD0\", ival)")))
280 (define_constraint "N0HS0"
281   "@internal"
282   (and (match_code "const_int")
283        (match_test "s390_N_constraint_str (\"0HS0\", ival)")))
286 (define_constraint "N0HD0"
287   "@internal"
288   (and (match_code "const_int")
289        (match_test "s390_N_constraint_str (\"0HD0\", ival)")))
292 (define_constraint "NxQDF"
293   "@internal"
294   (and (match_code "const_int")
295        (match_test "s390_N_constraint_str (\"xQDF\", ival)")))
298 (define_constraint "N1SDF"
299   "@internal"
300   (and (match_code "const_int")
301        (match_test "s390_N_constraint_str (\"1SDF\", ival)")))
304 (define_constraint "N0SDF"
305   "@internal"
306   (and (match_code "const_int")
307        (match_test "s390_N_constraint_str (\"0SDF\", ival)")))
310 (define_constraint "N3HDF"
311   "@internal"
312   (and (match_code "const_int")
313        (match_test "s390_N_constraint_str (\"3HDF\", ival)")))
316 (define_constraint "N2HDF"
317   "@internal"
318   (and (match_code "const_int")
319        (match_test "s390_N_constraint_str (\"2HDF\", ival)")))
322 (define_constraint "N1HDF"
323   "@internal"
324   (and (match_code "const_int")
325        (match_test "s390_N_constraint_str (\"1HDF\", ival)")))
328 (define_constraint "N0HDF"
329   "@internal"
330   (and (match_code "const_int")
331        (match_test "s390_N_constraint_str (\"0HDF\", ival)")))
334 (define_constraint "N0HSF"
335   "@internal"
336   (and (match_code "const_int")
337        (match_test "s390_N_constraint_str (\"0HSF\", ival)")))
340 (define_constraint "N1HSF"
341   "@internal"
342   (and (match_code "const_int")
343        (match_test "s390_N_constraint_str (\"1HSF\", ival)")))
346 (define_constraint "NxQSF"
347   "@internal"
348   (and (match_code "const_int")
349        (match_test "s390_N_constraint_str (\"xQSF\", ival)")))
352 (define_constraint "NxQHF"
353   "@internal"
354   (and (match_code "const_int")
355        (match_test "s390_N_constraint_str (\"xQHF\", ival)")))
358 (define_constraint "NxQH0"
359   "@internal"
360   (and (match_code "const_int")
361        (match_test "s390_N_constraint_str (\"xQH0\", ival)")))
363 (define_constraint "NxxDq"
364   "@internal"
365   (and (match_code "const_int")
366        (match_test "s390_contiguous_bitmask_p (ival, 64, NULL, NULL)")))
368 (define_constraint "NxxSq"
369   "@internal"
370   (and (match_code "const_int")
371        (match_test "s390_contiguous_bitmask_p (ival, 32, NULL, NULL)")))
374 ;; Double-letter constraints starting with O follow.
378 (define_constraint "Os"
379   "@internal
380    Signed extended immediate value (-2G .. 2G-1).
381    This constraint will only match if the machine provides
382    the extended-immediate facility."
383   (and (match_code "const_int")
384        (match_test "s390_O_constraint_str ('s', ival)")))
387 (define_constraint "Op"
388   "@internal
389    Positive extended immediate value (0 .. 4G-1).
390    This constraint will only match if the machine provides
391    the extended-immediate facility."
392   (and (match_code "const_int")
393        (match_test "s390_O_constraint_str ('p', ival)")))
396 (define_constraint "On"
397   "@internal
398    Negative extended immediate value (-4G+1 .. -1).
399    This constraint will only match if the machine provides
400    the extended-immediate facility."
401   (and (match_code "const_int")
402        (match_test "s390_O_constraint_str ('n', ival)")))
408 ;; Memory constraints follow.
411 (define_memory_constraint "Q"
412   "Memory reference without index register and with short displacement"
413   (match_test "s390_mem_constraint (\"Q\", op)"))
416 (define_memory_constraint "R"
417   "Memory reference with index register and short displacement"
418   (match_test "s390_mem_constraint (\"R\", op)"))
421 (define_memory_constraint "S"
422   "Memory reference without index register but with long displacement"
423   (match_test "s390_mem_constraint (\"S\", op)"))
426 (define_memory_constraint "T"
427   "Memory reference with index register and long displacement"
428   (match_test "s390_mem_constraint (\"T\", op)"))
431 (define_memory_constraint "b"
432   "Memory reference whose address is a naturally aligned symbol reference."
433   (match_test "MEM_P (op)
434                && s390_check_symref_alignment (XEXP (op, 0),
435                                                GET_MODE_SIZE (GET_MODE (op)))"))
437 ; This defines 'm' as normal memory constraint.  This is only possible
438 ; since the standard memory constraint is re-defined in s390.h using
439 ; the TARGET_MEM_CONSTRAINT macro.
440 (define_memory_constraint "m"
441   "Matches the most general memory address for pre-z10 machines."
442   (match_test "s390_mem_constraint (\"R\", op)
443                || s390_mem_constraint (\"T\", op)"))
445 (define_memory_constraint "AQ"
446   "@internal
447    Offsettable memory reference without index register and with short displacement"
448   (match_test "s390_mem_constraint (\"AQ\", op)"))
451 (define_memory_constraint "AR"
452   "@internal
453    Offsettable memory reference with index register and short displacement"
454   (match_test "s390_mem_constraint (\"AR\", op)"))
457 (define_memory_constraint "AS"
458   "@internal
459    Offsettable memory reference without index register but with long displacement"
460   (match_test "s390_mem_constraint (\"AS\", op)"))
463 (define_memory_constraint "AT"
464   "@internal
465    Offsettable memory reference with index register and long displacement"
466   (match_test "s390_mem_constraint (\"AT\", op)"))
470 (define_constraint "BQ"
471   "@internal
472    Memory reference without index register and with short
473    displacement that does *not* refer to a literal pool entry."
474   (match_test "s390_mem_constraint (\"BQ\", op)"))
477 (define_constraint "BR"
478   "@internal
479    Memory reference with index register and short displacement that
480    does *not* refer to a literal pool entry. "
481   (match_test "s390_mem_constraint (\"BR\", op)"))
484 (define_constraint "BS"
485   "@internal
486    Memory reference without index register but with long displacement
487    that does *not* refer to a literal pool entry. "
488   (match_test "s390_mem_constraint (\"BS\", op)"))
491 (define_constraint "BT"
492   "@internal
493    Memory reference with index register and long displacement that
494    does *not* refer to a literal pool entry. "
495   (match_test "s390_mem_constraint (\"BT\", op)"))
498 (define_address_constraint "U"
499   "Pointer with short displacement. (deprecated - use ZQZR)"
500   (match_test "s390_mem_constraint (\"U\", op)"))
502 (define_address_constraint "W"
503   "Pointer with long displacement. (deprecated - use ZSZT)"
504   (match_test "s390_mem_constraint (\"W\", op)"))
507 (define_address_constraint "ZQ"
508   "Pointer without index register and with short displacement."
509   (match_test "s390_mem_constraint (\"ZQ\", op)"))
511 (define_address_constraint "ZR"
512   "Pointer with index register and short displacement."
513   (match_test "s390_mem_constraint (\"ZR\", op)"))
515 (define_address_constraint "ZS"
516   "Pointer without index register but with long displacement."
517   (match_test "s390_mem_constraint (\"ZS\", op)"))
519 (define_address_constraint "ZT"
520   "Pointer with index register and long displacement."
521   (match_test "s390_mem_constraint (\"ZT\", op)"))