1;; Constraints definitions belonging to the gcc backend for IBM S/390.
2;; Copyright (C) 2006-2016 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.
12;;
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.
17;;
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/>.
21
22
23;;
24;; Special constraints for s/390 machine description:
25;;
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;;         jKK: constant vector with all elements having the same value and
38;;              matching K constraint
39;;         jm6: An integer operand with the lowest order 6 bits all ones.
40;;    t -- Access registers 36 and 37.
41;;    v -- Vector registers v0-v31.
42;;    C -- A signed 8-bit constant (-128..127)
43;;    D -- An unsigned 16-bit constant (0..65535)
44;;    G -- Const double zero operand
45;;    I -- An 8-bit constant (0..255).
46;;    J -- A 12-bit constant (0..4095).
47;;    K -- A 16-bit constant (-32768..32767).
48;;    L -- Value appropriate as displacement.
49;;         (0..4095) for short displacement
50;;         (-524288..524287) for long displacement
51;;    M -- Constant integer with a value of 0x7fffffff.
52;;    N -- Multiple letter constraint followed by 4 parameter letters.
53;;         0..9,x:  number of the part counting from most to least significant
54;;         H,Q:     mode of the part
55;;         D,S,H:   mode of the containing operand
56;;         0,F:     value of the other parts (F - all bits set)
57;;         --
58;;         xx[DS]q  satisfies s390_contiguous_bitmask_p for DImode or SImode
59;;
60;;         The constraint matches if the specified part of a constant
61;;         has a value different from its other parts.  If the letter x
62;;         is specified instead of a part number, the constraint matches
63;;         if there is any single part with non-default value.
64;;    O -- Multiple letter constraint followed by 1 parameter.
65;;         s:  Signed extended immediate value (-2G .. 2G-1).
66;;         p:  Positive extended immediate value (0 .. 4G-1).
67;;         n:  Negative extended immediate value (-4G+1 .. -1).
68;;         These constraints do not accept any operand if the machine does
69;;         not provide the extended-immediate facility.
70;;    P -- Any integer constant that can be loaded without literal pool.
71;;    Q -- Memory reference without index register and with short displacement.
72;;    R -- Memory reference with index register and short displacement.
73;;    S -- Memory reference without index register but with long displacement.
74;;    T -- Memory reference with index register and long displacement.
75;;    A -- Multiple letter constraint followed by Q, R, S, or T:
76;;         Offsettable memory reference of type specified by second letter.
77;;    B -- Multiple letter constraint followed by Q, R, S, or T:
78;;         Memory reference of the type specified by second letter that
79;;         does *not* refer to a literal pool entry.
80;;    U -- Pointer with short displacement. (deprecated - use ZQZR)
81;;    W -- Pointer with long displacement. (deprecated - use ZSZT)
82;;    Y -- Address style operand without index.
83;;    ZQ -- Pointer without index register and with short displacement.
84;;    ZR -- Pointer with index register and short displacement.
85;;    ZS -- Pointer without index register but with long displacement.
86;;    ZT -- Pointer with index register and long displacement.
87;;
88;;
89
90
91;;
92;;  Register constraints.
93;;
94
95(define_register_constraint "a"
96  "ADDR_REGS"
97  "Any address register from 1 to 15.")
98
99
100(define_register_constraint "c"
101  "CC_REGS"
102  "Condition code register 33")
103
104
105(define_register_constraint "d"
106  "GENERAL_REGS"
107  "Any register from 0 to 15")
108
109
110(define_register_constraint "f"
111  "FP_REGS"
112  "Floating point registers")
113
114
115(define_register_constraint "t"
116  "ACCESS_REGS"
117  "@internal
118   Access registers 36 and 37")
119
120
121(define_register_constraint "v"
122  "VEC_REGS"
123  "Vector registers v0-v31")
124
125
126;;
127;;  General constraints for constants.
128;;
129
130(define_constraint "C"
131  "@internal
132   An 8-bit signed immediate constant (-128..127)"
133  (and (match_code "const_int")
134       (match_test "ival >= -128 && ival <= 127")))
135
136
137(define_constraint "D"
138  "An unsigned 16-bit constant (0..65535)"
139  (and (match_code "const_int")
140       (match_test "ival >= 0 && ival <= 65535")))
141
142
143(define_constraint "G"
144  "@internal
145   Const double zero operand"
146   (and (match_code "const_double")
147        (match_test "s390_float_const_zero_p (op)")))
148
149
150(define_constraint "I"
151  "An 8-bit constant (0..255)"
152  (and (match_code "const_int")
153       (match_test "(unsigned HOST_WIDE_INT) ival <= 255")))
154
155
156(define_constraint "J"
157  "A 12-bit constant (0..4095)"
158  (and (match_code "const_int")
159       (match_test "(unsigned HOST_WIDE_INT) ival <= 4095")))
160
161
162(define_constraint "K"
163  "A 16-bit constant (-32768..32767)"
164  (and (match_code "const_int")
165       (match_test "ival >= -32768 && ival <= 32767")))
166
167
168(define_constraint "L"
169  "Value appropriate as displacement.
170      (0..4095) for short displacement
171      (-524288..524287) for long displacement"
172  (and (match_code "const_int")
173       (match_test "TARGET_LONG_DISPLACEMENT ?
174              (ival >= -524288 && ival <= 524287)
175            : (ival >= 0 && ival <= 4095)")))
176
177
178(define_constraint "M"
179  "Constant integer with a value of 0x7fffffff"
180  (and (match_code "const_int")
181       (match_test "ival == 2147483647")))
182
183
184(define_constraint "P"
185  "@internal
186   Any integer constant that can be loaded without literal pool"
187   (and (match_code "const_int")
188        (match_test "legitimate_reload_constant_p (GEN_INT (ival))")))
189
190
191(define_address_constraint "Y"
192  "Address style operand without index register"
193
194;; Simply check for base + offset style operands.  Reload will take
195;; care of making sure we have a proper base register.
196
197  (match_test "s390_decompose_addrstyle_without_index (op, NULL, NULL)"  ))
198
199
200;;    N -- Multiple letter constraint followed by 4 parameter letters.
201;;         0..9,x:  number of the part counting from most to least significant
202;;         H,Q:     mode of the part
203;;         D,S,H:   mode of the containing operand
204;;         0,F:     value of the other parts (F = all bits set)
205;;
206;;         The constraint matches if the specified part of a constant
207;;         has a value different from its other parts.  If the letter x
208;;         is specified instead of a part number, the constraint matches
209;;         if there is any single part with non-default value.
210;;
211;; The following patterns define only those constraints that are actually
212;; used in s390.md.  If you need an additional one, simply add it in the
213;; obvious way.  Function s390_N_constraint_str is ready to handle all
214;; combinations.
215;;
216
217
218(define_constraint "NxQS0"
219  "@internal"
220  (and (match_code "const_int")
221       (match_test "s390_N_constraint_str (\"xQS0\", ival)")))
222
223
224(define_constraint "NxQD0"
225  "@internal"
226   (and (match_code "const_int")
227        (match_test "s390_N_constraint_str (\"xQD0\", ival)")))
228
229
230(define_constraint "N3HD0"
231  "@internal"
232  (and (match_code "const_int")
233       (match_test "s390_N_constraint_str (\"3HD0\", ival)")))
234
235
236(define_constraint "N2HD0"
237  "@internal"
238  (and (match_code "const_int")
239       (match_test "s390_N_constraint_str (\"2HD0\", ival)")))
240
241
242(define_constraint "N1SD0"
243  "@internal"
244  (and (match_code "const_int")
245       (match_test "s390_N_constraint_str (\"1SD0\", ival)")))
246
247
248(define_constraint "N1HS0"
249  "@internal"
250  (and (match_code "const_int")
251       (match_test "s390_N_constraint_str (\"1HS0\", ival)")))
252
253
254(define_constraint "N1HD0"
255  "@internal"
256  (and (match_code "const_int")
257       (match_test "s390_N_constraint_str (\"1HD0\", ival)")))
258
259
260(define_constraint "N0SD0"
261  "@internal"
262  (and (match_code "const_int")
263       (match_test "s390_N_constraint_str (\"0SD0\", ival)")))
264
265
266(define_constraint "N0HS0"
267  "@internal"
268  (and (match_code "const_int")
269       (match_test "s390_N_constraint_str (\"0HS0\", ival)")))
270
271
272(define_constraint "N0HD0"
273  "@internal"
274  (and (match_code "const_int")
275       (match_test "s390_N_constraint_str (\"0HD0\", ival)")))
276
277
278(define_constraint "NxQDF"
279  "@internal"
280  (and (match_code "const_int")
281       (match_test "s390_N_constraint_str (\"xQDF\", ival)")))
282
283
284(define_constraint "N1SDF"
285  "@internal"
286  (and (match_code "const_int")
287       (match_test "s390_N_constraint_str (\"1SDF\", ival)")))
288
289
290(define_constraint "N0SDF"
291  "@internal"
292  (and (match_code "const_int")
293       (match_test "s390_N_constraint_str (\"0SDF\", ival)")))
294
295
296(define_constraint "N3HDF"
297  "@internal"
298  (and (match_code "const_int")
299       (match_test "s390_N_constraint_str (\"3HDF\", ival)")))
300
301
302(define_constraint "N2HDF"
303  "@internal"
304  (and (match_code "const_int")
305       (match_test "s390_N_constraint_str (\"2HDF\", ival)")))
306
307
308(define_constraint "N1HDF"
309  "@internal"
310  (and (match_code "const_int")
311       (match_test "s390_N_constraint_str (\"1HDF\", ival)")))
312
313
314(define_constraint "N0HDF"
315  "@internal"
316  (and (match_code "const_int")
317       (match_test "s390_N_constraint_str (\"0HDF\", ival)")))
318
319
320(define_constraint "N0HSF"
321  "@internal"
322  (and (match_code "const_int")
323       (match_test "s390_N_constraint_str (\"0HSF\", ival)")))
324
325
326(define_constraint "N1HSF"
327  "@internal"
328  (and (match_code "const_int")
329       (match_test "s390_N_constraint_str (\"1HSF\", ival)")))
330
331
332(define_constraint "NxQSF"
333  "@internal"
334  (and (match_code "const_int")
335       (match_test "s390_N_constraint_str (\"xQSF\", ival)")))
336
337
338(define_constraint "NxQHF"
339  "@internal"
340  (and (match_code "const_int")
341       (match_test "s390_N_constraint_str (\"xQHF\", ival)")))
342
343
344(define_constraint "NxQH0"
345  "@internal"
346  (and (match_code "const_int")
347       (match_test "s390_N_constraint_str (\"xQH0\", ival)")))
348
349(define_constraint "NxxDq"
350  "@internal"
351  (and (match_code "const_int")
352       (match_test "s390_contiguous_bitmask_p (ival, 64, NULL, NULL)")))
353
354(define_constraint "NxxSq"
355  "@internal"
356  (and (match_code "const_int")
357       (match_test "s390_contiguous_bitmask_p (ival, 32, NULL, NULL)")))
358
359;;
360;; Double-letter constraints starting with O follow.
361;;
362
363
364(define_constraint "Os"
365  "@internal
366   Signed extended immediate value (-2G .. 2G-1).
367   This constraint will only match if the machine provides
368   the extended-immediate facility."
369  (and (match_code "const_int")
370       (match_test "s390_O_constraint_str ('s', ival)")))
371
372
373(define_constraint "Op"
374  "@internal
375   Positive extended immediate value (0 .. 4G-1).
376   This constraint will only match if the machine provides
377   the extended-immediate facility."
378  (and (match_code "const_int")
379       (match_test "s390_O_constraint_str ('p', ival)")))
380
381
382(define_constraint "On"
383  "@internal
384   Negative extended immediate value (-4G+1 .. -1).
385   This constraint will only match if the machine provides
386   the extended-immediate facility."
387  (and (match_code "const_int")
388       (match_test "s390_O_constraint_str ('n', ival)")))
389
390
391;;
392;; Vector constraints follow.
393;;
394
395(define_constraint "j00"
396  "Zero scalar or vector constant"
397  (match_test "op == CONST0_RTX (GET_MODE (op))"))
398
399(define_constraint "jm1"
400  "All one bit scalar or vector constant"
401  (match_test "op == CONSTM1_RTX (GET_MODE (op))"))
402
403(define_constraint "jxx"
404  "@internal"
405  (and (match_code "const_vector")
406       (match_test "s390_contiguous_bitmask_vector_p (op, NULL, NULL)")))
407
408(define_constraint "jyy"
409  "@internal"
410  (and (match_code "const_vector")
411       (match_test "s390_bytemask_vector_p (op, NULL)")))
412
413(define_constraint "jKK"
414  "@internal"
415  (and (and (match_code "const_vector")
416	    (match_test "const_vec_duplicate_p (op)"))
417       (match_test "satisfies_constraint_K (XVECEXP (op, 0, 0))")))
418
419(define_constraint "jm6"
420  "@internal An integer operand with the lowest order 6 bits all ones."
421  (match_operand 0 "const_int_6bitset_operand"))
422
423;;
424;; Memory constraints follow.
425;;
426
427(define_memory_constraint "Q"
428  "Memory reference without index register and with short displacement"
429  (match_test "s390_mem_constraint (\"Q\", op)"))
430
431
432(define_memory_constraint "R"
433  "Memory reference with index register and short displacement"
434  (match_test "s390_mem_constraint (\"R\", op)"))
435
436
437(define_memory_constraint "S"
438  "Memory reference without index register but with long displacement"
439  (match_test "s390_mem_constraint (\"S\", op)"))
440
441
442(define_memory_constraint "T"
443  "Memory reference with index register and long displacement"
444  (match_test "s390_mem_constraint (\"T\", op)"))
445
446
447(define_memory_constraint "b"
448  "Memory reference whose address is a naturally aligned symbol reference."
449  (match_test "MEM_P (op)
450               && s390_check_symref_alignment (XEXP (op, 0),
451                                               GET_MODE_SIZE (GET_MODE (op)))"))
452
453; This defines 'm' as normal memory constraint.  This is only possible
454; since the standard memory constraint is re-defined in s390.h using
455; the TARGET_MEM_CONSTRAINT macro.
456(define_memory_constraint "m"
457  "Matches the most general memory address for pre-z10 machines."
458  (match_test "s390_mem_constraint (\"R\", op)
459               || s390_mem_constraint (\"T\", op)"))
460
461(define_memory_constraint "AQ"
462  "@internal
463   Offsettable memory reference without index register and with short displacement"
464  (match_test "s390_mem_constraint (\"AQ\", op)"))
465
466
467(define_memory_constraint "AR"
468  "@internal
469   Offsettable memory reference with index register and short displacement"
470  (match_test "s390_mem_constraint (\"AR\", op)"))
471
472
473(define_memory_constraint "AS"
474  "@internal
475   Offsettable memory reference without index register but with long displacement"
476  (match_test "s390_mem_constraint (\"AS\", op)"))
477
478
479(define_memory_constraint "AT"
480  "@internal
481   Offsettable memory reference with index register and long displacement"
482  (match_test "s390_mem_constraint (\"AT\", op)"))
483
484
485
486(define_constraint "BQ"
487  "@internal
488   Memory reference without index register and with short
489   displacement that does *not* refer to a literal pool entry."
490  (match_test "s390_mem_constraint (\"BQ\", op)"))
491
492
493(define_constraint "BR"
494  "@internal
495   Memory reference with index register and short displacement that
496   does *not* refer to a literal pool entry. "
497  (match_test "s390_mem_constraint (\"BR\", op)"))
498
499
500(define_constraint "BS"
501  "@internal
502   Memory reference without index register but with long displacement
503   that does *not* refer to a literal pool entry. "
504  (match_test "s390_mem_constraint (\"BS\", op)"))
505
506
507(define_constraint "BT"
508  "@internal
509   Memory reference with index register and long displacement that
510   does *not* refer to a literal pool entry. "
511  (match_test "s390_mem_constraint (\"BT\", op)"))
512
513
514(define_address_constraint "U"
515  "Pointer with short displacement. (deprecated - use ZQZR)"
516  (match_test "s390_mem_constraint (\"U\", op)"))
517
518(define_address_constraint "W"
519  "Pointer with long displacement. (deprecated - use ZSZT)"
520  (match_test "s390_mem_constraint (\"W\", op)"))
521
522
523(define_address_constraint "ZQ"
524  "Pointer without index register and with short displacement."
525  (match_test "s390_mem_constraint (\"ZQ\", op)"))
526
527(define_address_constraint "ZR"
528  "Pointer with index register and short displacement."
529  (match_test "s390_mem_constraint (\"ZR\", op)"))
530
531(define_address_constraint "ZS"
532  "Pointer without index register but with long displacement."
533  (match_test "s390_mem_constraint (\"ZS\", op)"))
534
535(define_address_constraint "ZT"
536  "Pointer with index register and long displacement."
537  (match_test "s390_mem_constraint (\"ZT\", op)"))
538