Debian Codegraph @

gcc/config/s390/constraints.md

raw
1 ;; Constraints definitions belonging to the gcc backend for IBM S/390.
2 ;; Copyright (C) 2006-2025 Free Software Foundation, Inc.
3 ;; Written by Wolfgang Gellerich, using code and information found in
4 ;; files s390.md, s390.h, and s390.cc.
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 ;; jzz: constant consisting of 16-bit chunks which may be sign-extended
38 ;; jm6: An integer operand with the lowest order 6 bits all ones.
39 ;; jdd: A constant operand that fits into the data section.
40 ;; j>f: An integer operand whose lower 32 bits are greater than or equal to 15
41 ;; jb4: An unsigned constant 4 bit operand.
42 ;; t -- Access registers 36 and 37.
43 ;; v -- Vector registers v0-v31.
44 ;; C -- A signed 8-bit constant (-128..127)
45 ;; D -- An unsigned 16-bit constant (0..65535)
46 ;; G -- Const double zero operand
47 ;; I -- An 8-bit constant (0..255).
48 ;; J -- A 12-bit constant (0..4095).
49 ;; K -- A 16-bit constant (-32768..32767).
50 ;; L -- Value appropriate as displacement.
51 ;; (0..4095) for short displacement
52 ;; (-524288..524287) for long displacement
53 ;; M -- Constant integer with a value of 0x7fffffff.
54 ;; N -- Multiple letter constraint followed by 4 parameter letters.
55 ;; 0..9,x: number of the part counting from most to least significant
56 ;; S,H,Q: mode of the part
57 ;; D,S,H: mode of the containing operand
58 ;; 0,F: value of the other parts (F - all bits set)
59 ;; --
60 ;; xxDq satisfies s390_contiguous_bitmask_p for DImode
61 ;; (with possible wraparound of the one-bit range)
62 ;; xxSw satisfies s390_contiguous_bitmask_p for SImode
63 ;; (with possible wraparound of the one-bit range)
64 ;; xxSq satisfies s390_contiguous_bitmask_nowrap_p for SImode
65 ;; (without wraparound of the one-bit range)
66 ;;
67 ;; The constraint matches if the specified part of a constant
68 ;; has a value different from its other parts. If the letter x
69 ;; is specified instead of a part number, the constraint matches
70 ;; if there is any single part with non-default value.
71 ;; O -- Multiple letter constraint followed by 1 parameter.
72 ;; s: Signed extended immediate value (-2G .. 2G-1).
73 ;; p: Positive extended immediate value (0 .. 4G-1).
74 ;; n: Negative extended immediate value (-4G+1 .. -1).
75 ;; These constraints do not accept any operand if the machine does
76 ;; not provide the extended-immediate facility.
77 ;; P -- Any integer constant that can be loaded without literal pool.
78 ;; Q -- Memory reference without index register and with short displacement.
79 ;; R -- Memory reference with index register and short displacement.
80 ;; S -- Memory reference without index register but with long displacement.
81 ;; T -- Memory reference with index register and long displacement.
82 ;; A -- Multiple letter constraint followed by Q, R, S, or T:
83 ;; Offsettable memory reference of type specified by second letter.
84 ;; B -- Multiple letter constraint followed by Q, R, S, or T:
85 ;; Memory reference of the type specified by second letter that
86 ;; does *not* refer to a literal pool entry.
87 ;; U -- Pointer with short displacement. (deprecated - use ZR)
88 ;; W -- Pointer with long displacement. (deprecated - use ZT)
89 ;; Y -- Address style operand without index.
90 ;; ZQ -- Pointer without index register and with short displacement.
91 ;; ZR -- Pointer with index register and short displacement.
92 ;; ZS -- Pointer without index register but with long displacement.
93 ;; ZT -- Pointer with index register and long displacement.
94 ;; ZL -- LARL operand when in 64-bit mode, otherwise nothing.
95 ;;
96 ;;
97
98
99 ;;
100 ;; Register constraints.
101 ;;
102
103 (define_register_constraint "a"
104 "ADDR_REGS"
105 "Any address register from 1 to 15.")
106
107
108 (define_register_constraint "c"
109 "CC_REGS"
110 "Condition code register 33")
111
112
113 (define_register_constraint "d"
114 "GENERAL_REGS"
115 "Any register from 0 to 15")
116
117
118 (define_register_constraint "f"
119 "FP_REGS"
120 "Floating point registers")
121
122
123 (define_register_constraint "t"
124 "ACCESS_REGS"
125 "@internal
126 Access registers 36 and 37")
127
128
129 (define_register_constraint "v"
130 "VEC_REGS"
131 "Vector registers v0-v31")
132
133
134 ;;
135 ;; General constraints for constants.
136 ;;
137
138 (define_constraint "C"
139 "@internal
140 An 8-bit signed immediate constant (-128..127)"
141 (and (match_code "const_int")
142 (match_test "ival >= -128 && ival <= 127")))
143
144
145 (define_constraint "D"
146 "An unsigned 16-bit constant (0..65535)"
147 (and (match_code "const_int")
148 (match_test "ival >= 0 && ival <= 65535")))
149
150
151 (define_constraint "G"
152 "@internal
153 Const double zero operand"
154 (and (match_code "const_double")
155 (match_test "s390_float_const_zero_p (op)")))
156
157
158 (define_constraint "I"
159 "An 8-bit constant (0..255)"
160 (and (match_code "const_int")
161 (match_test "(unsigned HOST_WIDE_INT) ival <= 255")))
162
163
164 (define_constraint "J"
165 "A 12-bit constant (0..4095)"
166 (and (match_code "const_int")
167 (match_test "(unsigned HOST_WIDE_INT) ival <= 4095")))
168
169
170 (define_constraint "K"
171 "A 16-bit constant (-32768..32767)"
172 (and (match_code "const_int")
173 (match_test "ival >= -32768 && ival <= 32767")))
174
175
176 (define_constraint "L"
177 "Value appropriate as displacement.
178 (0..4095) for short displacement
179 (-524288..524287) for long displacement"
180 (and (match_code "const_int")
181 (match_test "TARGET_LONG_DISPLACEMENT ?
182 (ival >= -524288 && ival <= 524287)
183 : (ival >= 0 && ival <= 4095)")))
184
185
186 (define_constraint "M"
187 "Constant integer with a value of 0x7fffffff"
188 (and (match_code "const_int")
189 (match_test "ival == 2147483647")))
190
191
192 (define_constraint "P"
193 "@internal
194 Any integer constant that can be loaded without literal pool"
195 (and (match_code "const_int")
196 (match_test "legitimate_reload_constant_p (GEN_INT (ival))")))
197
198
199 (define_address_constraint "Y"
200 "Address style operand without index register"
201
202 ;; Simply check for base + offset style operands. Reload will take
203 ;; care of making sure we have a proper base register.
204
205 (match_test "s390_decompose_addrstyle_without_index (op, NULL, NULL)" ))
206
207
208 ;; Shift count operands are not necessarily legitimate addresses
209 ;; but the predicate shift_count_operand will only allow
210 ;; proper operands. If reload/lra need to change e.g. a spilled register
211 ;; they can still do so via the special handling of address constraints.
212 ;; To avoid further reloading (caused by a non-matching constraint) we
213 ;; always return true here as the predicate's checks are already sufficient.
214
215 (define_address_constraint "jsc"
216 "Address style operand used as shift count."
217 (match_test "true" ))
218
219
220 ;; N -- Multiple letter constraint followed by 4 parameter letters.
221 ;; 0..9,x: number of the part counting from most to least significant
222 ;; S,H,Q: mode of the part
223 ;; D,S,H: mode of the containing operand
224 ;; 0,F: value of the other parts (F = all bits set)
225 ;;
226 ;; The constraint matches if the specified part of a constant
227 ;; has a value different from its other parts. If the letter x
228 ;; is specified instead of a part number, the constraint matches
229 ;; if there is any single part with non-default value.
230 ;;
231 ;; The following patterns define only those constraints that are actually
232 ;; used in s390.md. If you need an additional one, simply add it in the
233 ;; obvious way. Function s390_N_constraint_str is ready to handle all
234 ;; combinations.
235 ;;
236
237
238 (define_constraint "NxQS0"
239 "@internal"
240 (and (match_code "const_int")
241 (match_test "s390_N_constraint_str (\"xQS0\", ival)")))
242
243
244 (define_constraint "NxHD0"
245 "@internal"
246 (and (match_code "const_int")
247 (match_test "s390_N_constraint_str (\"xHD0\", ival)")))
248
249
250 (define_constraint "NxSD0"
251 "@internal"
252 (and (match_code "const_int")
253 (match_test "s390_N_constraint_str (\"xSD0\", ival)")))
254
255
256 (define_constraint "NxQD0"
257 "@internal"
258 (and (match_code "const_int")
259 (match_test "s390_N_constraint_str (\"xQD0\", ival)")))
260
261
262 (define_constraint "N3HD0"
263 "@internal"
264 (and (match_code "const_int")
265 (match_test "s390_N_constraint_str (\"3HD0\", ival)")))
266
267
268 (define_constraint "N2HD0"
269 "@internal"
270 (and (match_code "const_int")
271 (match_test "s390_N_constraint_str (\"2HD0\", ival)")))
272
273
274 (define_constraint "N1SD0"
275 "@internal"
276 (and (match_code "const_int")
277 (match_test "s390_N_constraint_str (\"1SD0\", ival)")))
278
279
280 (define_constraint "N1HS0"
281 "@internal"
282 (and (match_code "const_int")
283 (match_test "s390_N_constraint_str (\"1HS0\", ival)")))
284
285
286 (define_constraint "N1HD0"
287 "@internal"
288 (and (match_code "const_int")
289 (match_test "s390_N_constraint_str (\"1HD0\", ival)")))
290
291
292 (define_constraint "N0SD0"
293 "@internal"
294 (and (match_code "const_int")
295 (match_test "s390_N_constraint_str (\"0SD0\", ival)")))
296
297
298 (define_constraint "N0HS0"
299 "@internal"
300 (and (match_code "const_int")
301 (match_test "s390_N_constraint_str (\"0HS0\", ival)")))
302
303
304 (define_constraint "N0HD0"
305 "@internal"
306 (and (match_code "const_int")
307 (match_test "s390_N_constraint_str (\"0HD0\", ival)")))
308
309
310 (define_constraint "NxQDF"
311 "@internal"
312 (and (match_code "const_int")
313 (match_test "s390_N_constraint_str (\"xQDF\", ival)")))
314
315
316 (define_constraint "N1SDF"
317 "@internal"
318 (and (match_code "const_int")
319 (match_test "s390_N_constraint_str (\"1SDF\", ival)")))
320
321
322 (define_constraint "N0SDF"
323 "@internal"
324 (and (match_code "const_int")
325 (match_test "s390_N_constraint_str (\"0SDF\", ival)")))
326
327
328 (define_constraint "N3HDF"
329 "@internal"
330 (and (match_code "const_int")
331 (match_test "s390_N_constraint_str (\"3HDF\", ival)")))
332
333
334 (define_constraint "N2HDF"
335 "@internal"
336 (and (match_code "const_int")
337 (match_test "s390_N_constraint_str (\"2HDF\", ival)")))
338
339
340 (define_constraint "N1HDF"
341 "@internal"
342 (and (match_code "const_int")
343 (match_test "s390_N_constraint_str (\"1HDF\", ival)")))
344
345
346 (define_constraint "N0HDF"
347 "@internal"
348 (and (match_code "const_int")
349 (match_test "s390_N_constraint_str (\"0HDF\", ival)")))
350
351
352 (define_constraint "N0HSF"
353 "@internal"
354 (and (match_code "const_int")
355 (match_test "s390_N_constraint_str (\"0HSF\", ival)")))
356
357
358 (define_constraint "N1HSF"
359 "@internal"
360 (and (match_code "const_int")
361 (match_test "s390_N_constraint_str (\"1HSF\", ival)")))
362
363
364 (define_constraint "NxQSF"
365 "@internal"
366 (and (match_code "const_int")
367 (match_test "s390_N_constraint_str (\"xQSF\", ival)")))
368
369
370 (define_constraint "NxQHF"
371 "@internal"
372 (and (match_code "const_int")
373 (match_test "s390_N_constraint_str (\"xQHF\", ival)")))
374
375
376 (define_constraint "NxQH0"
377 "@internal"
378 (and (match_code "const_int")
379 (match_test "s390_N_constraint_str (\"xQH0\", ival)")))
380
381 (define_constraint "NxxDw"
382 "@internal"
383 (and (match_code "const_int")
384 (match_test "s390_contiguous_bitmask_p (ival, true, 64, NULL, NULL)")))
385
386 (define_constraint "NxxSq"
387 "@internal"
388 (and (match_code "const_int")
389 (match_test "s390_contiguous_bitmask_p (ival, false, 32, NULL, NULL)")))
390
391 (define_constraint "NxxSw"
392 "@internal"
393 (and (match_code "const_int")
394 (match_test "s390_contiguous_bitmask_p (ival, true, 32, NULL, NULL)")))
395
396 ;;
397 ;; Double-letter constraints starting with O follow.
398 ;;
399
400
401 (define_constraint "Os"
402 "@internal
403 Signed extended immediate value (-2G .. 2G-1).
404 This constraint will only match if the machine provides
405 the extended-immediate facility."
406 (and (match_code "const_int")
407 (match_test "s390_O_constraint_str ('s', ival)")))
408
409
410 (define_constraint "Op"
411 "@internal
412 Positive extended immediate value (0 .. 4G-1).
413 This constraint will only match if the machine provides
414 the extended-immediate facility."
415 (and (match_code "const_int")
416 (match_test "s390_O_constraint_str ('p', ival)")))
417
418
419 (define_constraint "On"
420 "@internal
421 Negative extended immediate value (-4G+1 .. -1).
422 This constraint will only match if the machine provides
423 the extended-immediate facility."
424 (and (match_code "const_int")
425 (match_test "s390_O_constraint_str ('n', ival)")))
426
427
428 ;;
429 ;; Vector and scalar constraints for constant values follow.
430 ;;
431
432 (define_constraint "j00"
433 "Zero scalar or vector constant"
434 (match_test "op == CONST0_RTX (GET_MODE (op))"))
435
436 (define_constraint "jm1"
437 "All one bit scalar or vector constant"
438 (match_test "op == CONSTM1_RTX (GET_MODE (op))"))
439
440 ; vector generate mask operand
441 (define_constraint "jxx"
442 "@internal"
443 (match_test "s390_constant_via_vgm_p (op, NULL, NULL, NULL)"))
444
445 ; vector generate byte mask operand - constant 0 and -1 vectors are handled
446 ; by j00 and jm1, respectively.
447 (define_constraint "jyy"
448 "@internal"
449 (match_test "s390_constant_via_vgbm_p (op, NULL)"))
450
451 ; vector replicate immediate operand
452 (define_constraint "jzz"
453 "@internal"
454 (match_test "s390_constant_via_vrepi_p (op, NULL, NULL)"))
455
456 (define_constraint "jm6"
457 "@internal An integer operand with the lowest order 6 bits all ones."
458 (match_operand 0 "const_int_6bitset_operand"))
459
460 (define_constraint "j>f"
461 "@internal An integer operand whose lower 32 bits are greater than or equal to 15."
462 (and (match_code "const_int")
463 (match_test "(unsigned int)(ival & 0xffffffff) >= 15")))
464
465 (define_constraint "jb4"
466 "@internal Constant unsigned integer 4 bit value"
467 (and (match_code "const_int")
468 (match_test "ival >= 0 && ival <= 15")))
469
470 ;;
471 ;; Memory constraints follow.
472 ;;
473
474 (define_memory_constraint "Q"
475 "Memory reference without index register and with short displacement"
476 (match_test "s390_mem_constraint (\"Q\", op)"))
477
478
479 (define_memory_constraint "R"
480 "Memory reference with index register and short displacement"
481 (match_test "s390_mem_constraint (\"R\", op)"))
482
483
484 (define_memory_constraint "S"
485 "Memory reference without index register but with long displacement"
486 (match_test "s390_mem_constraint (\"S\", op)"))
487
488
489 (define_memory_constraint "T"
490 "Memory reference with index register and long displacement"
491 (match_test "s390_mem_constraint (\"T\", op)"))
492
493
494 (define_memory_constraint "b"
495 "Memory reference whose address is a naturally aligned symbol reference."
496 (match_test "MEM_P (op)
497 && s390_check_symref_alignment (XEXP (op, 0),
498 GET_MODE_SIZE (GET_MODE (op)))"))
499
500 ; This defines 'm' as normal memory constraint. This is only possible
501 ; since the standard memory constraint is re-defined in s390.h using
502 ; the TARGET_MEM_CONSTRAINT macro.
503 (define_memory_constraint "m"
504 "Matches the most general memory address for pre-z10 machines."
505 (match_test "s390_mem_constraint (\"T\", op)"))
506
507 (define_memory_constraint "AQ"
508 "@internal
509 Offsettable memory reference without index register and with short displacement"
510 (match_test "s390_mem_constraint (\"AQ\", op)"))
511
512
513 (define_memory_constraint "AR"
514 "@internal
515 Offsettable memory reference with index register and short displacement"
516 (match_test "s390_mem_constraint (\"AR\", op)"))
517
518
519 (define_memory_constraint "AS"
520 "@internal
521 Offsettable memory reference without index register but with long displacement"
522 (match_test "s390_mem_constraint (\"AS\", op)"))
523
524
525 (define_memory_constraint "AT"
526 "@internal
527 Offsettable memory reference with index register and long displacement"
528 (match_test "s390_mem_constraint (\"AT\", op)"))
529
530
531
532 (define_constraint "BQ"
533 "@internal
534 Memory reference without index register and with short
535 displacement that does *not* refer to a literal pool entry."
536 (match_test "s390_mem_constraint (\"BQ\", op)"))
537
538
539 (define_constraint "BR"
540 "@internal
541 Memory reference with index register and short displacement that
542 does *not* refer to a literal pool entry. "
543 (match_test "s390_mem_constraint (\"BR\", op)"))
544
545
546 (define_constraint "BS"
547 "@internal
548 Memory reference without index register but with long displacement
549 that does *not* refer to a literal pool entry. "
550 (match_test "s390_mem_constraint (\"BS\", op)"))
551
552
553 (define_constraint "BT"
554 "@internal
555 Memory reference with index register and long displacement that
556 does *not* refer to a literal pool entry. "
557 (match_test "s390_mem_constraint (\"BT\", op)"))
558
559
560 (define_address_constraint "U"
561 "Pointer with short displacement. (deprecated - use ZR)"
562 (match_test "s390_mem_constraint (\"ZR\", op)"))
563
564 (define_address_constraint "W"
565 "Pointer with long displacement. (deprecated - use ZT)"
566 (match_test "s390_mem_constraint (\"ZT\", op)"))
567
568
569 (define_address_constraint "ZQ"
570 "Pointer without index register and with short displacement."
571 (match_test "s390_mem_constraint (\"ZQ\", op)"))
572
573 (define_address_constraint "ZR"
574 "Pointer with index register and short displacement."
575 (match_test "s390_mem_constraint (\"ZR\", op)"))
576
577 (define_address_constraint "ZS"
578 "Pointer without index register but with long displacement."
579 (match_test "s390_mem_constraint (\"ZS\", op)"))
580
581 (define_address_constraint "ZT"
582 "Pointer with index register and long displacement."
583 (match_test "s390_mem_constraint (\"ZT\", op)"))
584
585 (define_constraint "ZL"
586 "LARL operand when in 64-bit mode, otherwise nothing."
587 (match_test "TARGET_64BIT && larl_operand (op, VOIDmode)"))
588
589 ;; This constraint must behave like "i", in particular, the matching values
590 ;; must never be placed into registers or memory by
591 ;; cfgexpand.cc:expand_asm_stmt. It could be straightforward to start its name
592 ;; with a letter from genpreds.cc:const_int_constraints, however it would
593 ;; require using (match_code "const_int"), which is infeasible. To achieve the
594 ;; same effect, that is, setting maybe_allows_reg and maybe_allows_mem to false
595 ;; in genpreds.cc:add_constraint, we explicitly exclude reg, subreg and mem
596 ;; codes.
597 (define_constraint "jdd"
598 "A constant operand that fits into the data section.
599 Usage of this constraint might produce a relocation."
600 (and (not (match_code "reg"))
601 (not (match_code "subreg"))
602 (not (match_code "mem"))
603 (match_test "CONSTANT_P (op)")))