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.
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 2, 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 COPYING.  If not, write to the Free
20;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
21;; 02110-1301, USA.
22
23
24;;
25;; Special constraints for s/390 machine description:
26;;
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)
45;;
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.
69;;
70
71
72;;
73;;  Register constraints.
74;;
75
76(define_register_constraint "a" 
77  "ADDR_REGS"
78  "Any address register from 1 to 15.")
79
80
81(define_register_constraint "c" 
82  "CC_REGS"
83  "Condition code register 33")
84
85
86(define_register_constraint "d" 
87  "GENERAL_REGS"
88  "Any register from 0 to 15")
89
90
91(define_register_constraint "f" 
92  "FP_REGS"
93  "Floating point registers")
94
95
96(define_register_constraint "t" 
97  "ACCESS_REGS"
98  "@internal
99   Access registers 36 and 37")
100
101
102;;
103;;  General constraints for constants.
104;;
105
106(define_constraint "G"
107  "@internal
108   Const double zero operand"
109   (and (match_code "const_double")
110        (match_test "s390_float_const_zero_p (op)")))
111
112
113(define_constraint "I"
114  "An 8-bit constant (0..255)"
115  (and (match_code "const_int")
116       (match_test "(unsigned int) ival <= 255")))
117
118
119(define_constraint "J"
120  "A 12-bit constant (0..4095)"
121  (and (match_code "const_int")
122       (match_test "(unsigned int) ival <= 4095")))
123
124
125(define_constraint "K"
126  "A 16-bit constant (-32768..32767)"
127  (and (match_code "const_int")
128       (match_test "ival >= -32768 && ival <= 32767")))
129
130
131
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)")))
140
141
142(define_constraint "M"
143  "Constant integer with a value of 0x7fffffff"
144  (and (match_code "const_int")
145       (match_test "ival == 2147483647")))
146
147
148(define_constraint "P"
149  "@internal
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))")))
153
154
155(define_address_constraint "Y"
156  "Shift count operand"
157
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.
160
161  (match_test "s390_decompose_shift_count (op, NULL, NULL)"  ))
162
163
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)
169;;
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.
174;;
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 
178;; combinations.
179;;
180
181
182(define_constraint "NxQS0"
183  "@internal"
184  (and (match_code "const_int")
185       (match_test "s390_N_constraint_str (\"xQS0\", ival)")))
186
187
188(define_constraint "NxQD0"
189  "@internal"
190   (and (match_code "const_int")
191        (match_test "s390_N_constraint_str (\"xQD0\", ival)")))
192
193
194(define_constraint "N3HD0"
195  "@internal"
196  (and (match_code "const_int")
197       (match_test "s390_N_constraint_str (\"3HD0\", ival)")))
198
199
200(define_constraint "N2HD0"
201  "@internal"
202  (and (match_code "const_int")
203       (match_test "s390_N_constraint_str (\"2HD0\", ival)")))
204
205
206(define_constraint "N1SD0"
207  "@internal"
208  (and (match_code "const_int")
209       (match_test "s390_N_constraint_str (\"1SD0\", ival)")))
210
211
212(define_constraint "N1HS0"
213  "@internal"
214  (and (match_code "const_int")
215       (match_test "s390_N_constraint_str (\"1HS0\", ival)")))
216
217
218(define_constraint "N1HD0"
219  "@internal"
220  (and (match_code "const_int")
221       (match_test "s390_N_constraint_str (\"1HD0\", ival)")))
222
223
224(define_constraint "N0SD0"
225  "@internal"
226  (and (match_code "const_int")
227       (match_test "s390_N_constraint_str (\"0SD0\", ival)")))
228
229
230(define_constraint "N0HS0"
231  "@internal"
232  (and (match_code "const_int")
233       (match_test "s390_N_constraint_str (\"0HS0\", ival)")))
234
235
236(define_constraint "N0HD0"
237  "@internal"
238  (and (match_code "const_int")
239       (match_test "s390_N_constraint_str (\"0HD0\", ival)")))
240
241
242(define_constraint "NxQDF"
243  "@internal"
244  (and (match_code "const_int")
245       (match_test "s390_N_constraint_str (\"xQDF\", ival)")))
246
247
248(define_constraint "N1SDF"
249  "@internal"
250  (and (match_code "const_int")
251       (match_test "s390_N_constraint_str (\"1SDF\", ival)")))
252
253
254(define_constraint "N0SDF"
255  "@internal"
256  (and (match_code "const_int")
257       (match_test "s390_N_constraint_str (\"0SDF\", ival)")))
258
259
260(define_constraint "N3HDF"
261  "@internal"
262  (and (match_code "const_int")
263       (match_test "s390_N_constraint_str (\"3HDF\", ival)")))
264
265
266(define_constraint "N2HDF"
267  "@internal"
268  (and (match_code "const_int")
269       (match_test "s390_N_constraint_str (\"2HDF\", ival)")))
270
271
272(define_constraint "N1HDF"
273  "@internal"
274  (and (match_code "const_int")
275       (match_test "s390_N_constraint_str (\"1HDF\", ival)")))
276
277
278(define_constraint "N0HDF"
279  "@internal"
280  (and (match_code "const_int")
281       (match_test "s390_N_constraint_str (\"0HDF\", ival)")))
282
283
284(define_constraint "N0HSF"
285  "@internal"
286  (and (match_code "const_int")
287       (match_test "s390_N_constraint_str (\"0HSF\", ival)")))
288
289
290(define_constraint "N1HSF"
291  "@internal"
292  (and (match_code "const_int")
293       (match_test "s390_N_constraint_str (\"1HSF\", ival)")))
294
295
296(define_constraint "NxQSF"
297  "@internal"
298  (and (match_code "const_int")
299       (match_test "s390_N_constraint_str (\"xQSF\", ival)")))
300
301
302(define_constraint "NxQHF"
303  "@internal"
304  (and (match_code "const_int")
305       (match_test "s390_N_constraint_str (\"xQHF\", ival)")))
306
307
308(define_constraint "NxQH0"
309  "@internal"
310  (and (match_code "const_int")
311       (match_test "s390_N_constraint_str (\"xQH0\", ival)")))
312
313
314
315
316;;
317;; Double-letter constraints starting with O follow.
318;;
319
320
321(define_constraint "Os"
322  "@internal
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)")))
328
329
330(define_constraint "Op"
331  "@internal
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)")))
337
338
339(define_constraint "On"
340  "@internal
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)")))
346
347
348
349
350;;
351;; Memory constraints follow.
352;;
353
354(define_memory_constraint "Q"
355  "Memory reference without index register and with short displacement"
356  (match_test "s390_mem_constraint (\"Q\", op)"))
357
358
359
360(define_memory_constraint "R"
361  "Memory reference with index register and short displacement"
362  (match_test "s390_mem_constraint (\"R\", op)"))
363
364
365(define_memory_constraint "S"
366  "Memory reference without index register but with long displacement"
367  (match_test "s390_mem_constraint (\"S\", op)"))
368
369
370(define_memory_constraint "T"
371  "Memory reference with index register and long displacement"
372  (match_test "s390_mem_constraint (\"T\", op)"))
373
374
375
376(define_memory_constraint "AQ"
377  "@internal 
378   Offsettable memory reference without index register and with short displacement"
379  (match_test "s390_mem_constraint (\"AQ\", op)"))
380
381
382(define_memory_constraint "AR"
383  "@internal 
384   Offsettable memory reference with index register and short displacement"
385  (match_test "s390_mem_constraint (\"AR\", op)"))
386
387
388(define_memory_constraint "AS"
389  "@internal 
390   Offsettable memory reference without index register but with long displacement"
391  (match_test "s390_mem_constraint (\"AS\", op)"))
392
393
394(define_memory_constraint "AT"
395  "@internal 
396   Offsettable memory reference with index register and long displacement"
397  (match_test "s390_mem_constraint (\"AT\", op)"))
398
399
400
401(define_constraint "BQ"
402  "@internal 
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)"))
406
407
408(define_constraint "BR"
409  "@internal 
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)"))
413
414
415(define_constraint "BS"
416  "@internal 
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)"))
420
421
422(define_constraint "BT"
423  "@internal 
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)"))
427
428
429
430(define_address_constraint "U"
431  "Pointer with short displacement"
432  (match_test "s390_mem_constraint (\"U\", op)"))
433
434
435
436(define_address_constraint "W"
437  "Pointer with long displacement"
438  (match_test "s390_mem_constraint (\"W\", op)"))
439