OSDN Git Service

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