1 ;; Machine description for AArch64 architecture.
2 ;; Copyright (C) 2009-2024 Free Software Foundation, Inc.
3 ;; Contributed by ARM Ltd.
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3, or (at your option)
12 ;; GCC is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
21 (define_register_constraint "k" "STACK_REG"
22 "@internal The stack register.")
24 (define_register_constraint "Uci" "W8_W11_REGS"
25 "@internal r8-r11, which can be used to index ZA.")
27 (define_register_constraint "Ucj" "W12_W15_REGS"
28 "@internal r12-r15, which can be used to index ZA.")
30 (define_register_constraint "Ucs" "TAILCALL_ADDR_REGS"
31 "@internal Registers suitable for an indirect tail call")
33 (define_register_constraint "Ucr"
34 "aarch64_harden_sls_blr_p () ? STUB_REGS : GENERAL_REGS"
35 "@internal Registers to be used for an indirect call.
36 This is usually the general registers, but when we are hardening against
37 Straight Line Speculation we disallow x16, x17, and x30 so we can use
38 indirection stubs. These indirection stubs cannot use the above registers
39 since they will be reached by a BL that may have to go through a linker
42 (define_register_constraint "w" "FP_REGS"
43 "Floating point and SIMD vector registers.")
45 (define_register_constraint "x" "FP_LO_REGS"
46 "Floating point and SIMD vector registers V0 - V15.")
48 (define_register_constraint "y" "FP_LO8_REGS"
49 "Floating point and SIMD vector registers V0 - V7.")
51 (define_register_constraint "Uw2" "FP_REGS"
52 "Even floating point and SIMD vector registers."
55 (define_register_constraint "Uw4" "FP_REGS"
56 "4-tuple-aligned floating point and SIMD vector registers."
59 (define_register_constraint "Uwd" "FP_REGS"
60 "@internal The first register in a tuple of 2 strided FPRs."
63 (define_register_constraint "Uwt" "FP_REGS"
64 "@internal The first register in a tuple of 4 strided FPRs."
67 (define_register_constraint "Upa" "PR_REGS"
68 "SVE predicate registers p0 - p15.")
70 (define_register_constraint "Up2" "PR_REGS"
71 "An even SVE predicate register, p0 - p14."
74 (define_register_constraint "Upl" "PR_LO_REGS"
75 "SVE predicate registers p0 - p7.")
77 (define_register_constraint "Uph" "PR_HI_REGS"
78 "SVE predicate registers p8 - p15.")
80 (define_constraint "c"
81 "@internal The condition code register."
82 (match_operand 0 "cc_register"))
84 (define_constraint "I"
85 "A constant that can be used with an ADD operation."
86 (and (match_code "const_int")
87 (match_test "aarch64_uimm12_shift (ival)")))
89 (define_constraint "Uaa"
90 "@internal A constant that matches two uses of add instructions."
91 (and (match_code "const_int")
92 (match_test "aarch64_pluslong_strict_immedate (op, VOIDmode)")))
94 (define_constraint "Uai"
96 A constraint that matches a VG-based constant that can be added by
98 (match_operand 0 "aarch64_sve_scalar_inc_dec_immediate"))
100 (define_constraint "Uav"
102 A constraint that matches a VG-based constant that can be added by
103 a single ADDVL or ADDPL."
104 (match_operand 0 "aarch64_sve_addvl_addpl_immediate"))
106 (define_constraint "UaV"
108 A constraint that matches a VG-based constant that can be added by
109 a single ADDSVL or ADDSPL."
110 (match_operand 0 "aarch64_addsvl_addspl_immediate"))
112 (define_constraint "Uat"
114 A constraint that matches a VG-based constant that can be added by
115 using multiple instructions, with one temporary register."
116 (match_operand 0 "aarch64_split_add_offset_immediate"))
118 (define_constraint "J"
119 "A constant that can be used with a SUB operation (once negated)."
120 (and (match_code "const_int")
121 (match_test "aarch64_uimm12_shift (-ival)")))
123 ;; We can't use the mode of a CONST_INT to determine the context in
124 ;; which it is being used, so we must have a separate constraint for
127 (define_constraint "K"
128 "A constant that can be used with a 32-bit logical operation."
129 (and (match_code "const_int")
130 (match_test "aarch64_bitmask_imm (ival, SImode)")))
132 (define_constraint "L"
133 "A constant that can be used with a 64-bit logical operation."
134 (and (match_code "const_int")
135 (match_test "aarch64_bitmask_imm (ival, DImode)")))
137 (define_constraint "M"
138 "A constant that can be used with a 32-bit MOV immediate operation."
139 (and (match_code "const_int")
140 (match_test "aarch64_move_imm (ival, SImode)")))
142 (define_constraint "N"
143 "A constant that can be used with a 64-bit MOV immediate operation."
144 (and (match_code "const_int")
145 (match_test "aarch64_is_mov_xn_imm (ival)")))
147 (define_constraint "O"
148 "A constant that can be used with a 32 or 64-bit MOV immediate operation."
149 (and (match_code "const_int")
150 (match_test "aarch64_move_imm (ival, DImode)")))
152 (define_constraint "Uti"
153 "A constant that can be used with a 128-bit MOV immediate operation."
154 (and (ior (match_code "const_int")
155 (match_code "const_wide_int"))
156 (match_test "aarch64_mov128_immediate (op)")))
158 (define_constraint "UsO"
159 "A constant that can be used with a 32-bit and operation."
160 (and (match_code "const_int")
161 (match_test "aarch64_and_bitmask_imm (ival, SImode)")))
163 (define_constraint "UsP"
164 "A constant that can be used with a 64-bit and operation."
165 (and (match_code "const_int")
166 (match_test "aarch64_and_bitmask_imm (ival, DImode)")))
168 (define_constraint "S"
169 "A constraint that matches an absolute symbolic address."
170 (and (match_code "const,symbol_ref,label_ref")
171 (match_test "aarch64_symbolic_address_p (op)")))
173 (define_constraint "Y"
174 "Floating point constant zero."
175 (and (match_code "const_double")
176 (match_test "aarch64_float_const_zero_rtx_p (op)")))
178 (define_constraint "Z"
179 "Integer or floating-point constant zero."
180 (match_test "op == CONST0_RTX (GET_MODE (op))"))
182 (define_constraint "Ush"
183 "A constraint that matches an absolute symbolic address high part."
184 (and (match_code "high")
185 (match_test "aarch64_valid_symref (XEXP (op, 0), GET_MODE (XEXP (op, 0)))")))
187 (define_constraint "Usa"
189 A constraint that matches an absolute symbolic address that can be
190 loaded by a single ADR."
191 (and (match_code "const,symbol_ref,label_ref")
192 (match_test "aarch64_symbolic_address_p (op)")
193 (match_test "aarch64_mov_operand_p (op, GET_MODE (op))")))
195 (define_constraint "Usm"
196 "A constant that can be used with the S[MIN/MAX] CSSC instructions."
197 (and (match_code "const_int")
198 (match_test "aarch64_sminmax_immediate (op, VOIDmode)")))
200 ;; const is needed here to support UNSPEC_SALT_ADDR.
201 (define_constraint "Usw"
203 A constraint that matches a small GOT access."
204 (and (match_code "const,symbol_ref")
205 (match_test "aarch64_classify_symbolic_expression (op)
206 == SYMBOL_SMALL_GOT_4G")))
208 (define_constraint "Uss"
210 A constraint that matches an immediate shift constant in SImode."
211 (and (match_code "const_int")
212 (match_test "(unsigned HOST_WIDE_INT) ival < 32")))
214 (define_constraint "Usn"
215 "A constant that can be used with a CCMN operation (once negated)."
216 (and (match_code "const_int")
217 (match_test "IN_RANGE (ival, -31, 0)")))
219 (define_constraint "Usd"
221 A constraint that matches an immediate shift constant in DImode."
222 (and (match_code "const_int")
223 (match_test "(unsigned HOST_WIDE_INT) ival < 64")))
225 (define_constraint "Usf"
226 "@internal Usf is a symbol reference under the context where plt stub allowed."
227 (and (match_code "symbol_ref")
228 (match_test "!(aarch64_is_noplt_call_p (op)
229 || aarch64_is_long_call_p (op))")))
231 (define_constraint "Usg"
233 A constraint that matches an immediate right shift constant in SImode
234 suitable for a SISD instruction."
235 (and (match_code "const_int")
236 (match_test "IN_RANGE (ival, 1, 31)")))
238 (define_constraint "Usj"
240 A constraint that matches an immediate right shift constant in DImode
241 suitable for a SISD instruction."
242 (and (match_code "const_int")
243 (match_test "IN_RANGE (ival, 1, 63)")))
245 (define_constraint "UsM"
247 A constraint that matches the immediate constant -1."
248 (match_test "op == constm1_rtx"))
250 (define_constraint "Ulc"
252 A constraint that matches a constant integer whose bits are consecutive ones
254 (and (match_code "const_int")
255 (match_test "aarch64_high_bits_all_ones_p (ival)")))
257 (define_constraint "Usr"
259 A constraint that matches a value produced by RDVL."
260 (and (match_code "const_poly_int")
261 (match_test "aarch64_sve_rdvl_immediate_p (op)")))
263 (define_constraint "UsR"
265 A constraint that matches a value produced by RDSVL."
266 (and (match_code "const")
267 (match_test "aarch64_rdsvl_immediate_p (op)")))
269 (define_constraint "Usv"
271 A constraint that matches a VG-based constant that can be loaded by
273 (match_operand 0 "aarch64_sve_cnt_immediate"))
275 (define_constraint "Usi"
277 A constraint that matches an immediate operand valid for
278 the SVE INDEX instruction."
279 (match_operand 0 "aarch64_sve_index_immediate"))
281 (define_constraint "Ui1"
283 A constraint that matches the immediate constant +1."
284 (match_test "op == const1_rtx"))
286 (define_constraint "Ui2"
288 A constraint that matches the integers 0...3."
289 (and (match_code "const_int")
290 (match_test "(unsigned HOST_WIDE_INT) ival <= 3")))
292 (define_constraint "Ui3"
294 A constraint that matches the integers 0...4."
295 (and (match_code "const_int")
296 (match_test "(unsigned HOST_WIDE_INT) ival <= 4")))
298 (define_constraint "Ui7"
300 A constraint that matches the integers 0...7."
301 (and (match_code "const_int")
302 (match_test "(unsigned HOST_WIDE_INT) ival <= 7")))
304 (define_constraint "Up3"
306 A constraint that matches the integers 2^(0...4)."
307 (and (match_code "const_int")
308 (match_test "(unsigned) exact_log2 (ival) <= 4")))
310 (define_constraint "Uih"
312 A constraint that matches HImode integers zero extendable to
313 SImode plus_operand."
314 (and (match_code "const_int")
315 (match_test "aarch64_plushi_immediate (op, VOIDmode)")))
317 (define_memory_constraint "Q"
318 "A memory address which uses a single base register with no offset."
319 (and (match_code "mem")
320 (match_test "REG_P (XEXP (op, 0))")))
322 (define_memory_constraint "Ust"
324 A memory address with 9bit unscaled offset."
325 (match_operand 0 "aarch64_9bit_offset_memory_operand"))
327 (define_memory_constraint "Ump"
329 A memory address suitable for a load/store pair operation."
330 (and (match_code "mem")
331 (match_test "aarch64_legitimate_address_p (GET_MODE (op), XEXP (op, 0),
332 true, ADDR_QUERY_LDP_STP)")))
334 ;; Used for storing or loading pairs in an AdvSIMD register using an STP/LDP
335 ;; as a vector-concat. The address mode uses the same constraints as if it
336 ;; were for a single value.
337 (define_relaxed_memory_constraint "Umn"
339 A memory address suitable for a load/store pair operation."
340 (and (match_code "mem")
341 (match_test "aarch64_legitimate_address_p (GET_MODE (op), XEXP (op, 0),
343 ADDR_QUERY_LDP_STP_N)")))
345 (define_address_constraint "UPb"
347 An address valid for SVE PRFB instructions."
348 (match_test "aarch64_sve_prefetch_operand_p (op, VNx16QImode)"))
350 (define_address_constraint "UPd"
352 An address valid for SVE PRFD instructions."
353 (match_test "aarch64_sve_prefetch_operand_p (op, VNx2DImode)"))
355 (define_address_constraint "UPh"
357 An address valid for SVE PRFH instructions."
358 (match_test "aarch64_sve_prefetch_operand_p (op, VNx8HImode)"))
360 (define_address_constraint "UPw"
362 An address valid for SVE PRFW instructions."
363 (match_test "aarch64_sve_prefetch_operand_p (op, VNx4SImode)"))
365 (define_memory_constraint "Utf"
367 An address valid for SVE LDFF1 instructions."
368 (and (match_code "mem")
369 (match_test "aarch64_sve_ldff1_operand_p (op)")))
371 (define_memory_constraint "Utn"
373 An address valid for SVE LDNF1 instructions."
374 (and (match_code "mem")
375 (match_test "aarch64_sve_ldnf1_operand_p (op)")))
377 (define_memory_constraint "Utr"
379 An address valid for SVE LDR and STR instructions (as distinct from
380 LD[1234] and ST[1234] patterns)."
381 (and (match_code "mem")
382 (match_test "aarch64_sve_ldr_operand_p (op)")))
384 (define_memory_constraint "Utv"
386 An address valid for loading/storing opaque structure
387 types wider than TImode."
388 (and (match_code "mem")
389 (match_test "aarch64_simd_mem_operand_p (op)")))
391 (define_relaxed_memory_constraint "Utq"
393 An address valid for loading or storing a 128-bit AdvSIMD register"
394 (and (match_code "mem")
395 (match_test "aarch64_legitimate_address_p (GET_MODE (op),
397 (match_test "aarch64_legitimate_address_p (V2DImode,
400 (define_relaxed_memory_constraint "UtQ"
402 An address valid for SVE LD1RQs."
403 (and (match_code "mem")
404 (match_test "aarch64_sve_ld1rq_operand_p (op)")))
406 (define_relaxed_memory_constraint "UOb"
408 An address valid for SVE LD1ROH."
409 (and (match_code "mem")
410 (match_test "aarch64_sve_ld1ro_operand_p (op, QImode)")))
412 (define_relaxed_memory_constraint "UOh"
414 An address valid for SVE LD1ROH."
415 (and (match_code "mem")
416 (match_test "aarch64_sve_ld1ro_operand_p (op, HImode)")))
419 (define_relaxed_memory_constraint "UOw"
421 An address valid for SVE LD1ROW."
422 (and (match_code "mem")
423 (match_test "aarch64_sve_ld1ro_operand_p (op, SImode)")))
425 (define_relaxed_memory_constraint "UOd"
427 An address valid for SVE LD1ROD."
428 (and (match_code "mem")
429 (match_test "aarch64_sve_ld1ro_operand_p (op, DImode)")))
431 (define_relaxed_memory_constraint "Uty"
433 An address valid for SVE LD1Rs."
434 (and (match_code "mem")
435 (match_test "aarch64_sve_ld1r_operand_p (op)")))
437 (define_memory_constraint "Utx"
439 An address valid for SVE structure mov patterns (as distinct from
440 LD[234] and ST[234] patterns)."
441 (match_operand 0 "aarch64_sve_struct_memory_operand"))
443 (define_constraint "Ufc"
444 "A floating point constant which can be used with an\
445 FMOV immediate operation."
446 (and (match_code "const_double,const_vector")
447 (match_test "aarch64_float_const_representable_p (op)")))
449 (define_constraint "Uum"
450 "A constant that can be used with the U[MIN/MAX] CSSC instructions."
451 (and (match_code "const_int")
452 (match_test "aarch64_uminmax_immediate (op, VOIDmode)")))
454 (define_constraint "Uvi"
455 "A floating point constant which can be used with a\
456 MOVI immediate operation."
457 (and (match_code "const_double")
458 (match_test "aarch64_can_const_movi_rtx_p (op, GET_MODE (op))")))
460 (define_constraint "Do"
462 A constraint that matches vector of immediates for orr."
463 (and (match_code "const_vector")
464 (match_test "aarch64_simd_valid_immediate (op, NULL,
465 AARCH64_CHECK_ORR)")))
467 (define_constraint "Db"
469 A constraint that matches vector of immediates for bic."
470 (and (match_code "const_vector")
471 (match_test "aarch64_simd_valid_immediate (op, NULL,
472 AARCH64_CHECK_BIC)")))
474 (define_constraint "Dn"
476 A constraint that matches vector of immediates."
477 (and (match_code "const,const_vector")
478 (match_test "aarch64_simd_valid_immediate (op, NULL)")))
480 (define_constraint "Dh"
482 A constraint that matches an immediate operand valid for\
483 AdvSIMD scalar move in HImode."
484 (and (match_code "const_int")
485 (match_test "aarch64_simd_scalar_immediate_valid_for_move (op,
488 (define_constraint "Dq"
490 A constraint that matches an immediate operand valid for\
491 AdvSIMD scalar move in QImode."
492 (and (match_code "const_int")
493 (match_test "aarch64_simd_scalar_immediate_valid_for_move (op,
496 (define_constraint "Dt"
498 A const_double which is the reciprocal of an exact power of two, can be
499 used in an scvtf with fract bits operation"
500 (and (match_code "const_double")
501 (match_test "aarch64_fpconst_pow2_recip (op) > 0")))
503 (define_constraint "Dl"
505 A constraint that matches vector of immediates for left shifts."
506 (and (match_code "const,const_vector")
507 (match_test "aarch64_simd_shift_imm_p (op, GET_MODE (op),
510 (define_constraint "D1"
512 A constraint that matches vector of immediates that is bits(mode)-1."
513 (and (match_code "const,const_vector")
514 (match_test "aarch64_const_vec_all_same_in_range_p (op,
515 GET_MODE_UNIT_BITSIZE (mode) - 1,
516 GET_MODE_UNIT_BITSIZE (mode) - 1)")))
518 (define_constraint "D2"
520 A constraint that matches vector of immediates that is bits(mode)/2."
521 (and (match_code "const,const_vector")
522 (match_test "aarch64_simd_shift_imm_vec_exact_top (op, mode)")))
524 (define_constraint "DL"
526 A constraint that matches vector of immediates for left shift long.
527 That is immediates between 0 to (bits(mode)/2)-1."
528 (and (match_code "const,const_vector")
529 (match_test "aarch64_const_vec_all_same_in_range_p (op, 0,
530 (GET_MODE_UNIT_BITSIZE (mode) / 2) - 1)")))
532 (define_constraint "Dr"
534 A constraint that matches vector of immediates for right shifts."
535 (and (match_code "const,const_vector")
536 (match_test "aarch64_simd_shift_imm_p (op, GET_MODE (op),
539 (define_constraint "Dx"
541 A constraint that matches a vector of 64-bit immediates which we don't have a
542 single instruction to create but that we can create in creative ways."
543 (and (match_code "const_int,const,const_vector")
544 (match_test "aarch64_simd_special_constant_p (op, DImode)")))
546 (define_constraint "Dz"
548 A constraint that matches a vector of immediate zero."
549 (and (match_code "const,const_vector")
550 (match_test "op == CONST0_RTX (GET_MODE (op))")))
552 (define_constraint "Dm"
554 A constraint that matches a vector of immediate minus one."
555 (and (match_code "const,const_vector")
556 (match_test "op == CONST1_RTX (GET_MODE (op))")))
558 (define_constraint "Dd"
560 A constraint that matches an integer immediate operand valid\
561 for AdvSIMD scalar operations in DImode."
562 (and (match_code "const_int")
563 (match_test "aarch64_can_const_movi_rtx_p (op, DImode)")))
565 (define_constraint "Ds"
567 A constraint that matches an integer immediate operand valid\
568 for AdvSIMD scalar operations in SImode."
569 (and (match_code "const_int")
570 (match_test "aarch64_can_const_movi_rtx_p (op, SImode)")))
572 (define_address_constraint "Dp"
574 An address valid for a prefetch instruction."
575 (match_test "aarch64_address_valid_for_prefetch_p (op, true)"))
577 (define_constraint "vgb"
579 A constraint that matches an immediate offset valid for SVE LD1B
580 gather instructions."
581 (match_operand 0 "aarch64_sve_gather_immediate_b"))
583 (define_constraint "vgd"
585 A constraint that matches an immediate offset valid for SVE LD1D
586 gather instructions."
587 (match_operand 0 "aarch64_sve_gather_immediate_d"))
589 (define_constraint "vgh"
591 A constraint that matches an immediate offset valid for SVE LD1H
592 gather instructions."
593 (match_operand 0 "aarch64_sve_gather_immediate_h"))
595 (define_constraint "vgw"
597 A constraint that matches an immediate offset valid for SVE LD1W
598 gather instructions."
599 (match_operand 0 "aarch64_sve_gather_immediate_w"))
601 (define_constraint "vsa"
603 A constraint that matches an immediate operand valid for SVE
604 arithmetic instructions."
605 (match_operand 0 "aarch64_sve_arith_immediate"))
607 (define_constraint "vsb"
609 A constraint that matches an immediate operand valid for SVE UMAX
610 and UMIN operations."
611 (match_operand 0 "aarch64_sve_vsb_immediate"))
613 (define_constraint "vsc"
615 A constraint that matches a signed immediate operand valid for SVE
617 (match_operand 0 "aarch64_sve_cmp_vsc_immediate"))
619 (define_constraint "vss"
621 A constraint that matches a signed immediate operand valid for SVE
623 (match_test "aarch64_sve_dup_immediate_p (op)"))
625 (define_constraint "vsd"
627 A constraint that matches an unsigned immediate operand valid for SVE
629 (match_operand 0 "aarch64_sve_cmp_vsd_immediate"))
631 (define_constraint "vsi"
633 A constraint that matches a vector count operand valid for SVE INC and
635 (match_operand 0 "aarch64_sve_vector_inc_dec_immediate"))
637 (define_constraint "vsn"
639 A constraint that matches an immediate operand whose negative
640 is valid for SVE SUB instructions."
641 (match_operand 0 "aarch64_sve_sub_arith_immediate"))
643 (define_constraint "vsQ"
645 Like vsa, but additionally check that the immediate is nonnegative
646 when interpreted as a signed value."
647 (match_operand 0 "aarch64_sve_qadd_immediate"))
649 (define_constraint "vsS"
651 Like vsn, but additionally check that the immediate is negative
652 when interpreted as a signed value."
653 (match_operand 0 "aarch64_sve_qsub_immediate"))
655 (define_constraint "vsl"
657 A constraint that matches an immediate operand valid for SVE logical
659 (match_operand 0 "aarch64_sve_logical_immediate"))
661 (define_constraint "vsm"
663 A constraint that matches an immediate operand valid for SVE MUL,
664 SMAX and SMIN operations."
665 (match_operand 0 "aarch64_sve_vsm_immediate"))
667 (define_constraint "vsA"
669 A constraint that matches an immediate operand valid for SVE FADD
670 and FSUB operations."
671 (match_operand 0 "aarch64_sve_float_arith_immediate"))
674 (define_constraint "vsB"
676 A constraint that matches an immediate operand valid for SVE FMAX
677 and FMIN operations."
678 (match_operand 0 "aarch64_sve_float_maxmin_immediate"))
680 (define_constraint "vsM"
682 A constraint that matches an immediate operand valid for SVE FMUL
684 (match_operand 0 "aarch64_sve_float_mul_immediate"))
686 (define_constraint "vsN"
688 A constraint that matches the negative of vsA"
689 (match_operand 0 "aarch64_sve_float_negated_arith_immediate"))