]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/arc/constraints.md
Update copyright years.
[thirdparty/gcc.git] / gcc / config / arc / constraints.md
CommitLineData
526b7aee 1;; Constraint definitions for Synopsys DesignWare ARC.
a945c346 2;; Copyright (C) 2007-2024 Free Software Foundation, Inc.
526b7aee
SV
3;;
4;; This file is part of GCC.
5;;
6;; GCC is free software; you can redistribute it and/or modify
7;; it under the terms of the GNU General Public License as published by
8;; the Free Software Foundation; either version 3, or (at your option)
9;; any later version.
10;;
11;; GCC is distributed in the hope that it will be useful,
12;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;; GNU General Public License for more details.
15;;
16;; You should have received a copy of the GNU General Public License
17;; along with GCC; see the file COPYING3. If not see
18;; <http://www.gnu.org/licenses/>.
19
20;; Register constraints
21
22; Most instructions accept arbitrary core registers for their inputs, even
23; if the core register in question cannot be written to, like the multiply
fb155425 24; result registers of ARC600.
526b7aee
SV
25; First, define a class for core registers that can be read cheaply. This
26; is most or all core registers for ARC600, but only r0-r31 for ARC700
73dac59b
CZ
27(define_register_constraint "c" "GENERAL_REGS"
28 "Legacy, core register @code{r0}-@code{r31}, @code{ap},@code{pcl}")
526b7aee
SV
29
30; All core regs - e.g. for when we must have a way to reload a register.
73dac59b
CZ
31(define_register_constraint "Rac" "GENERAL_REGS"
32 "Legacy, core register @code{r0}-@code{r60}, @code{ap},@code{pcl}")
526b7aee
SV
33
34; Some core registers (.e.g lp_count) aren't general registers because they
35; can't be used as the destination of a multi-cycle operation like
36; load and/or multiply, yet they are still writable in the sense that
37; register-register moves and single-cycle arithmetic (e.g "add", "and",
38; but not "mpy") can write to them.
73dac59b
CZ
39(define_register_constraint "w" "GENERAL_REGS"
40 "Legacy, writable core register: @code{r0}-@code{r31}, @code{r60},
41 nonfixed core register")
526b7aee 42
73dac59b
CZ
43(define_register_constraint "W" "GENERAL_REGS"
44 "Legacy, writable core register except @code{LP_COUNT} (@code{r60}):
45 @code{r0}-@code{r31}, nonfixed core register")
526b7aee 46
73dac59b 47(define_constraint "l"
526b7aee 48 "@internal
73dac59b
CZ
49 Loop count register @code{r60}"
50 (and (match_code "reg")
51 (match_test "REGNO (op) == LP_COUNT")))
526b7aee
SV
52
53(define_register_constraint "x" "R0_REGS"
54 "@code{R0} register.")
55
9ebba06b 56(define_register_constraint "q" "ARCOMPACT16_REGS"
526b7aee
SV
57 "Registers usable in ARCompact 16-bit instructions: @code{r0}-@code{r3},
58 @code{r12}-@code{r15}")
59
ceaaa9fe
JR
60; NPS400 bitfield instructions require registers from the r0-r3,r12-r15
61; range, and thus we need a register class and constraint that works
62; independently of size optimization.
63(define_register_constraint
64 "Rrq" "TARGET_RRQ_CLASS ? ARCOMPACT16_REGS : NO_REGS"
65 "Registers usable in NPS400 bitfield instructions: @code{r0}-@code{r3},
66 @code{r12}-@code{r15}")
67
526b7aee
SV
68(define_register_constraint "D" "DOUBLE_REGS"
69 "ARC FPX (dpfp) 64-bit registers. @code{D0}, @code{D1}")
70
71(define_register_constraint "d" "SIMD_DMA_CONFIG_REGS"
72 "@internal
73 ARC SIMD DMA configuration registers @code{di0}-@code{di7},
74 @code{do0}-@code{do7}")
75
76(define_register_constraint "v" "SIMD_VR_REGS"
77 "ARC SIMD 128-bit registers @code{VR0}-@code{VR23}")
78
79; We could allow call-saved registers for sibling calls if we restored them
80; in the delay slot of the call. However, that would not allow to adjust the
81; stack pointer afterwards, so the call-saved register would have to be
82; restored from a call-used register that was just loaded with the value
83; before. So sticking to call-used registers for sibcalls will likely
84; generate better code overall.
85(define_register_constraint "Rsc" "SIBCALL_REGS"
86 "@internal
87 Sibling call register")
88
89;; Integer constraints
90
91(define_constraint "I"
92 "@internal
93 A signed 12-bit integer constant."
94 (and (match_code "const_int")
95 (match_test "SIGNED_INT12 (ival)")))
96
97(define_constraint "K"
98 "@internal
99 A 3-bit unsigned integer constant"
100 (and (match_code "const_int")
101 (match_test "UNSIGNED_INT3 (ival)")))
102
103(define_constraint "L"
104 "@internal
105 A 6-bit unsigned integer constant"
106 (and (match_code "const_int")
107 (match_test "UNSIGNED_INT6 (ival)")))
108
109(define_constraint "CnL"
110 "@internal
111 One's complement of a 6-bit unsigned integer constant"
112 (and (match_code "const_int")
113 (match_test "UNSIGNED_INT6 (~ival)")))
114
f50bb868
CZ
115(define_constraint "C16"
116 "@internal
117 A 16-bit signed integer constant"
118 (and (match_code "const_int")
119 (match_test "SIGNED_INT16 (ival)")))
120
526b7aee
SV
121(define_constraint "M"
122 "@internal
123 A 5-bit unsigned integer constant"
124 (and (match_code "const_int")
125 (match_test "UNSIGNED_INT5 (ival)")))
126
127(define_constraint "N"
128 "@internal
129 Integer constant 1"
130 (and (match_code "const_int")
131 (match_test "IS_ONE (ival)")))
132
133(define_constraint "O"
134 "@internal
135 A 7-bit unsigned integer constant"
136 (and (match_code "const_int")
137 (match_test "UNSIGNED_INT7 (ival)")))
138
139(define_constraint "P"
140 "@internal
141 An 8-bit unsigned integer constant"
142 (and (match_code "const_int")
143 (match_test "UNSIGNED_INT8 (ival)")))
144
145(define_constraint "C_0"
146 "@internal
147 Zero"
148 (and (match_code "const_int")
149 (match_test "ival == 0")))
150
151(define_constraint "Cn0"
152 "@internal
153 Negative or zero"
154 (and (match_code "const_int")
155 (match_test "ival <= 0")))
156
526b7aee
SV
157(define_constraint "CM4"
158 "@internal
1cf57a14 159 A valid 5-bit unsigned stack offset for a short add"
526b7aee
SV
160 (and (match_code "const_int")
161 (match_test "!(ival & ~124)")))
162
1cf57a14 163(define_constraint "CP4"
526b7aee 164 "@internal
1cf57a14 165 A valid 5-bit unsigned stack offset for a short sub"
526b7aee 166 (and (match_code "const_int")
1cf57a14 167 (match_test "!(-ival & ~124)")))
526b7aee
SV
168
169(define_constraint "C0p"
170 "@internal
171 power of two"
172 (and (match_code "const_int")
03301dcc 173 (match_test "IS_POWEROF2_P (ival & 0xffffffff)")))
526b7aee
SV
174
175(define_constraint "C1p"
176 "@internal
177 constant such that x+1 is a power of two, and x != 0"
178 (and (match_code "const_int")
179 (match_test "ival && IS_POWEROF2_P (ival + 1)")))
180
fc1c2d04
CZ
181(define_constraint "C2p"
182 "@internal
183 constant such that (~x)+1 is a power of two, and x < -1"
184 (and (match_code "const_int")
185 (match_test "TARGET_V2
186 && (ival < -1)
187 && IS_POWEROF2_P ((~ival) + 1)")))
188
f50bb868
CZ
189(define_constraint "C3p"
190 "@internal
191 constant int used to select xbfu a,b,u6 instruction. The values accepted are 1 and 2."
192 (and (match_code "const_int")
193 (match_test "((ival == 1) || (ival == 2))")))
194
526b7aee
SV
195(define_constraint "Ccp"
196 "@internal
197 constant such that ~x (one's Complement) is a power of two"
198 (and (match_code "const_int")
199 (match_test "IS_POWEROF2_P (~ival)")))
200
201(define_constraint "Cux"
202 "@internal
203 constant such that AND gives an unsigned extension"
204 (and (match_code "const_int")
205 (match_test "ival == 0xff || ival == 0xffff")))
206
ceaaa9fe
JR
207(define_constraint "Chs"
208 "@internal
209 constant for a highpart that can be checked with a shift (asr.f 0,rn,m)"
210 (and (match_code "const_int")
491483b0
CZ
211 (match_test "IS_POWEROF2_P (-ival)")
212 (match_test "TARGET_BARREL_SHIFTER")))
ceaaa9fe
JR
213
214(define_constraint "Clo"
215 "@internal
216 constant that fits into 16 lower bits, for movl"
217 (and (match_code "const_int")
218 (match_test "TARGET_NPS_BITOPS")
219 (match_test "(ival & ~0xffffU) == 0")))
220
221(define_constraint "Chi"
222 "@internal
223 constant that fits into 16 higher bits, for movh_i"
224 (and (match_code "const_int")
225 (match_test "TARGET_NPS_BITOPS")
226 (match_test "trunc_int_for_mode (ival >> 16, HImode) << 16 == ival")))
227
228(define_constraint "Cbf"
229 "@internal
230 a mask for a bit field, for AND using movb_i"
231 (and (match_code "const_int")
232 (match_test "TARGET_NPS_BITOPS")
233 (match_test "IS_POWEROF2_OR_0_P (ival + (ival & -ival))")))
234
235(define_constraint "Cbn"
236 "@internal
237 a constant integer, valid only if TARGET_NPS_BITOPS is true"
238 (and (match_code "const_int")
239 (match_test "TARGET_NPS_BITOPS")))
240
241(define_constraint "C18"
242 "@internal
243 1,2,4 or 8"
244 (and (match_code "const_int")
245 (match_test "ival == 1 || ival == 2 || ival == 4 || ival == 8")))
246
ceaaa9fe
JR
247(define_constraint "Cbi"
248 "@internal
249 constant that can be loaded with movbi.cl"
250 (and (match_code "const_int")
251 (match_test "TARGET_NPS_BITOPS")
252 (match_test "!ival
253 || ((ival & 0xffffffffUL) >> exact_log2 (ival & -ival)
254 <= 0xff)")))
255
03301dcc
CZ
256(define_constraint "C0x"
257 "@internal
258 special const_int pattern used to split ior insns"
259 (and (match_code "const_int")
260 (match_test "optimize_size")
261 (match_test "arc_check_ior_const (ival)")))
262
263(define_constraint "Cax"
264 "@internal
265 special const_int pattern used to split mov insns"
266 (and (match_code "const_int")
267 (match_test "optimize_size")
268 (match_test "arc_check_mov_const (ival)")))
269
526b7aee
SV
270;; Floating-point constraints
271
272(define_constraint "G"
273 "@internal
274 A 32-bit constant double value"
275 (and (match_code "const_double")
276 (match_test "arc_double_limm_p (op)")))
277
278(define_constraint "H"
279 "@internal
280 All const_double values (including 64-bit values)"
281 (and (match_code "const_double")
282 (match_test "1")))
283
a9637757
CZ
284(define_constraint "CfZ"
285 "@internal
286 Match a floating-point zero"
287 (and (match_code "const_double")
288 (match_test "op == CONST0_RTX (SFmode)")))
289
526b7aee
SV
290;; Memory constraints
291(define_memory_constraint "T"
292 "@internal
293 A valid memory operand for ARCompact load instructions"
294 (and (match_code "mem")
fc1c2d04
CZ
295 (match_test "compact_memory_operand_p (op, mode, false, false)")))
296
297(define_memory_constraint "Uts"
298 "@internal
299 A valid memory operand for ARCompact load instructions scaled"
300 (and (match_code "mem")
301 (match_test "compact_memory_operand_p (op, mode, false, TARGET_CODE_DENSITY)")))
526b7aee
SV
302
303(define_memory_constraint "S"
304 "@internal
305 A valid memory operand for ARCompact store instructions"
306 (and (match_code "mem")
307 (match_test "compact_store_memory_operand (op, VOIDmode)")))
308
4d03dc2f
JR
309(define_memory_constraint "Uex"
310 "@internal
311 A valid memory operand for limm-free extend instructions"
312 (and (match_code "mem")
313 (match_test "!cmem_address (XEXP (op, 0), SImode)")
314 (not (match_operand 0 "long_immediate_loadstore_operand"))))
315
e0be3321 316(define_memory_constraint "Usd"
c20ef9d2
AB
317 "@internal
318 A valid _small-data_ memory operand for ARCompact instructions"
319 (and (match_code "mem")
b6fb7933 320 (match_test "compact_sda_memory_operand (op, VOIDmode, true)")))
526b7aee 321
1370fccf
CZ
322; Usc constant is only used for storing long constants, hence we can
323; have only [b,s9], and [b] types of addresses.
526b7aee
SV
324(define_memory_constraint "Usc"
325 "@internal
326 A valid memory operand for storing constants"
327 (and (match_code "mem")
1370fccf 328 (match_test "!CONSTANT_P (XEXP (op,0))")))
526b7aee 329
c20ef9d2 330(define_constraint "Us<"
526b7aee
SV
331 "@internal
332 Stack pre-decrement"
333 (and (match_code "mem")
334 (match_test "GET_CODE (XEXP (op, 0)) == PRE_DEC")
335 (match_test "REG_P (XEXP (XEXP (op, 0), 0))")
336 (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == SP_REG")))
337
c20ef9d2 338(define_constraint "Us>"
526b7aee
SV
339 "@internal
340 Stack post-increment"
341 (and (match_code "mem")
342 (match_test "GET_CODE (XEXP (op, 0)) == POST_INC")
343 (match_test "REG_P (XEXP (XEXP (op, 0), 0))")
344 (match_test "REGNO (XEXP (XEXP (op, 0), 0)) == SP_REG")))
345
4d03dc2f
JR
346(define_constraint "Ucm"
347 "@internal
348 cmem access"
349 (and (match_code "mem")
350 (match_test "TARGET_NPS_CMEM && cmem_address (XEXP (op, 0), VOIDmode)")))
351
526b7aee
SV
352;; General constraints
353
354(define_constraint "Cbr"
355 "Branch destination"
356 (ior (and (match_code "symbol_ref")
357 (match_test "!arc_is_longcall_p (op)"))
358 (match_code "label_ref")))
359
360(define_constraint "Cbp"
361 "predicable branch/call destination"
362 (ior (and (match_code "symbol_ref")
363 (match_test "arc_is_shortcall_p (op)"))
364 (match_code "label_ref")))
365
6b55f8c9
CZ
366(define_constraint "Cji"
367 "JLI call"
368 (and (match_code "symbol_ref")
369 (match_test "TARGET_CODE_DENSITY")
370 (match_test "arc_is_jli_call_p (op)")))
371
7778a1ad
CZ
372(define_constraint "Csc"
373 "Secure call"
374 (and (match_code "symbol_ref")
375 (match_test "TARGET_CODE_DENSITY")
376 (match_test "TARGET_EM")
377 (match_test "arc_is_secure_call_p (op)")))
378
526b7aee
SV
379(define_constraint "Cpc"
380 "pc-relative constant"
b6c354eb 381 (match_test "arc_legitimate_pic_addr_p (op)"))
526b7aee
SV
382
383(define_constraint "Clb"
384 "label"
385 (and (match_code "label_ref")
b32d5189 386 (match_test "arc_text_label (as_a <rtx_insn *> (XEXP (op, 0)))")))
526b7aee
SV
387
388(define_constraint "Cal"
389 "constant for arithmetic/logical operations"
b6c354eb 390 (match_test "immediate_operand (op, VOIDmode) && !arc_legitimate_pic_addr_p (op)"))
526b7aee
SV
391
392(define_constraint "C32"
393 "32 bit constant for arithmetic/logical operations"
394 (match_test "immediate_operand (op, VOIDmode)
b6c354eb 395 && !arc_legitimate_pic_addr_p (op)
526b7aee
SV
396 && !satisfies_constraint_I (op)"))
397
e04108c7
CZ
398(define_constraint "Csz"
399 "a 32 bit constant avoided when compiling for size."
400 (match_test "immediate_operand (op, VOIDmode)
401 && !arc_legitimate_pic_addr_p (op)
402 && !(satisfies_constraint_I (op) && optimize_size)"))
403
526b7aee
SV
404(define_constraint "Rcb"
405 "@internal
406 Stack Pointer register @code{r28} - do not reload into its class"
8da140e0 407 (and (match_code "reg")
526b7aee
SV
408 (match_test "REGNO (op) == 28")))
409
410(define_constraint "Rck"
411 "@internal
412 blink (usful for push_s / pop_s)"
8da140e0 413 (and (match_code "reg")
526b7aee
SV
414 (match_test "REGNO (op) == 31")))
415
526b7aee
SV
416(define_constraint "Rcc"
417 "@internal
418 Condition Codes"
8da140e0 419 (and (match_code "reg") (match_test "cc_register (op, VOIDmode)")))
526b7aee 420
c5395d88
CZ
421(define_constraint "Ral"
422 "@internal
423 Accumulator register @code{ACCL} - do not reload into its class"
424 (and (match_code "reg")
425 (match_test "REGNO (op) == ACCL_REGNO")))
526b7aee
SV
426
427(define_constraint "Q"
428 "@internal
429 Integer constant zero"
430 (and (match_code "const_int")
431 (match_test "IS_ZERO (ival)")))
f50bb868 432
fc1c2d04
CZ
433(define_constraint "Cm1"
434 "@internal
435 Integer signed constant in the interval [-1,6]"
436 (and (match_code "const_int")
437 (match_test "(ival >= -1) && (ival <=6)")
438 (match_test "TARGET_V2")))
439
f50bb868
CZ
440(define_constraint "Cm2"
441 "@internal
442 A signed 9-bit integer constant."
443 (and (match_code "const_int")
444 (match_test "(ival >= -256) && (ival <=255)")))
445
fc1c2d04
CZ
446(define_constraint "Cm3"
447 "@internal
448 A signed 6-bit integer constant."
449 (and (match_code "const_int")
450 (match_test "(ival >= -32) && (ival <=31)")
451 (match_test "TARGET_V2")))
452
f50bb868
CZ
453(define_constraint "C62"
454 "@internal
455 An unsigned 6-bit integer constant, up to 62."
456 (and (match_code "const_int")
457 (match_test "UNSIGNED_INT6 (ival - 1)")))
b8a64b7f
CZ
458
459;; Memory constraint used for atomic ops.
460(define_memory_constraint "ATO"
461 "A memory with only a base register"
462 (match_operand 0 "mem_noofs_operand"))
7132ae19
CZ
463
464(define_constraint "J12"
465 "@internal
466 An unsigned 12-bit integer constant."
467 (and (match_code "const_int")
468 (match_test "UNSIGNED_INT12 (ival)")))
469
470(define_constraint "J16"
471 "@internal
472 An unsigned 16-bit integer constant"
473 (and (match_code "const_int")
474 (match_test "UNSIGNED_INT16 (ival)")))
fc1c2d04
CZ
475
476; Memory addresses suited for code density load ops
477(define_memory_constraint "Ucd"
478 "@internal
479 A valid memory operand for use with code density load ops"
480 (and (match_code "mem")
481 (match_test "compact_memory_operand_p (op, mode, true, false)")
482 (match_test "TARGET_V2")))
483
484(define_register_constraint "h"
485 "TARGET_V2 ? AC16_H_REGS : NO_REGS"
486 "5-bit h register set except @code{r30} and @code{r29}:
487 @code{r0}-@code{r31}, nonfixed core register")
488
489; Code density registers
490(define_register_constraint "Rcd"
491 "TARGET_CODE_DENSITY ? R0R3_CD_REGS : NO_REGS"
492 "@internal
493 core register @code{r0}-@code{r3}")
494
495(define_register_constraint "Rsd"
496 "TARGET_CODE_DENSITY ? R0R1_CD_REGS : NO_REGS"
497 "@internal
498 core register @code{r0}-@code{r1}")
499
500(define_register_constraint "Rzd"
501 "TARGET_CODE_DENSITY ? R0_REGS : NO_REGS"
502 "@internal
503 @code{r0} register for code density instructions.")
1cf57a14
CZ
504
505(define_constraint "C6u" "@internal
506 A 6-bit unsigned integer constant shifted by x-bit(s)"
507 (and (match_code "const_int")
508 (ior (match_test "UNSIGNED_INT9_SHIFTED (ival,3)")
509 (match_test "UNSIGNED_INT8_SHIFTED (ival,2)")
510 (match_test "UNSIGNED_INT7_SHIFTED (ival,1)")
511 (match_test "UNSIGNED_INT6 (ival)"))))
512
513(define_constraint "C6n" "@internal
514 A negative 6-bit integer constant shifted by x-bit(s) used by add."
515 (and (match_code "const_int")
516 (match_test "ival < 0")
517 (match_test "SIGNED_INT10(ival)")
518 (ior (match_test "UNSIGNED_INT9_SHIFTED (-ival,3)")
519 (match_test "UNSIGNED_INT8_SHIFTED (-ival,2)")
520 (match_test "UNSIGNED_INT7_SHIFTED (-ival,1)")
521 (match_test "UNSIGNED_INT6 (-ival)"))))
522
523(define_constraint "CIs" "@internal
524 A 12-bit signed integer constant shifted by x-bit(s)"
525 (and (match_code "const_int")
526 (ior (match_test "SIGNED_INT15_SHIFTED (ival,3)")
527 (match_test "SIGNED_INT14_SHIFTED (ival,2)")
528 (match_test "SIGNED_INT13_SHIFTED (ival,1)")
529 (match_test "SIGNED_INT12 (ival)"))))
530
531(define_constraint "C4p"
532 "@internal
533 Matches 0x8000_0000"
534 (and (match_code "const_int")
535 (match_test "ival == (HOST_WIDE_INT) (HOST_WIDE_INT_M1U << 31)")))