Debian Codegraph @

gcc/config/aarch64/aarch64.h

raw
1 /* Machine description for AArch64 architecture.
2 Copyright (C) 2009-2025 Free Software Foundation, Inc.
3 Contributed by ARM Ltd.
4
5 This file is part of GCC.
6
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)
10 any later version.
11
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.
16
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/>. */
20
21
22 #ifndef GCC_AARCH64_H
23 #define GCC_AARCH64_H
24
25 #define aarch64_get_asm_isa_flags(opts) \
26 (aarch64_feature_flags ((opts)->x_aarch64_asm_isa_flags_0, \
27 (opts)->x_aarch64_asm_isa_flags_1))
28 #define aarch64_get_isa_flags(opts) \
29 (aarch64_feature_flags ((opts)->x_aarch64_isa_flags_0, \
30 (opts)->x_aarch64_isa_flags_1))
31
32 /* Make these flags read-only so that all uses go via
33 aarch64_set_asm_isa_flags. */
34 #ifdef GENERATOR_FILE
35 #undef aarch64_asm_isa_flags
36 #define aarch64_asm_isa_flags (aarch64_feature_flags (aarch64_asm_isa_flags_0,\
37 aarch64_asm_isa_flags_1))
38 #undef aarch64_isa_flags
39 #define aarch64_isa_flags (aarch64_feature_flags (aarch64_isa_flags_0, \
40 aarch64_isa_flags_1))
41 #else
42 #undef aarch64_asm_isa_flags
43 #define aarch64_asm_isa_flags (aarch64_get_asm_isa_flags (&global_options))
44 #undef aarch64_isa_flags
45 #define aarch64_isa_flags (aarch64_get_isa_flags (&global_options))
46 #endif
47
48 /* Target CPU builtins. */
49 #define TARGET_CPU_CPP_BUILTINS() \
50 aarch64_cpu_cpp_builtins (pfile)
51
52
53
54 #define REGISTER_TARGET_PRAGMAS() aarch64_register_pragmas ()
55
56 /* Target machine storage layout. */
57
58 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
59 if (GET_MODE_CLASS (MODE) == MODE_INT \
60 && GET_MODE_SIZE (MODE) < 4) \
61 { \
62 if (MODE == QImode || MODE == HImode) \
63 { \
64 MODE = SImode; \
65 } \
66 }
67
68 /* Bits are always numbered from the LSBit. */
69 #define BITS_BIG_ENDIAN 0
70
71 /* Big/little-endian flavour. */
72 #define BYTES_BIG_ENDIAN (TARGET_BIG_END != 0)
73 #define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN)
74
75 #define UNITS_PER_WORD 8
76
77 #define UNITS_PER_VREG 16
78
79 #define PARM_BOUNDARY 64
80
81 #define STACK_BOUNDARY 128
82
83 #define FUNCTION_BOUNDARY 32
84
85 #define EMPTY_FIELD_BOUNDARY 32
86
87 #define BIGGEST_ALIGNMENT 128
88
89 #define SHORT_TYPE_SIZE 16
90
91 #define INT_TYPE_SIZE 32
92
93 #define LONG_TYPE_SIZE (TARGET_ILP32 ? 32 : 64)
94
95 #define POINTER_SIZE (TARGET_ILP32 ? 32 : 64)
96
97 #define LONG_LONG_TYPE_SIZE 64
98
99 #define WIDEST_HARDWARE_FP_SIZE 64
100
101 /* This value is the amount of bytes a caller is allowed to drop the stack
102 before probing has to be done for stack clash protection. */
103 #define STACK_CLASH_CALLER_GUARD 1024
104
105 /* This value represents the minimum amount of bytes we expect the function's
106 outgoing arguments to be when stack-clash is enabled. */
107 #define STACK_CLASH_MIN_BYTES_OUTGOING_ARGS 8
108
109 /* This value controls how many pages we manually unroll the loop for when
110 generating stack clash probes. */
111 #define STACK_CLASH_MAX_UNROLL_PAGES 4
112
113 /* The architecture reserves all bits of the address for hardware use,
114 so the vbit must go into the delta field of pointers to member
115 functions. This is the same config as that in the AArch32
116 port. */
117 #define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_delta
118
119
120 /* Emit calls to libgcc helpers for atomic operations for runtime detection
121 of LSE instructions. */
122 #define TARGET_OUTLINE_ATOMICS (aarch64_flag_outline_atomics)
123
124 #ifndef AARCH64_SIMD_MEMOPS_DEFAULT
125 #define AARCH64_SIMD_MEMOPS_DEFAULT 1
126 #endif
127
128 /* Allow use of SIMD registers for memory copy and set expansions */
129 #define TARGET_SIMD_MEMOPS (TARGET_SIMD && aarch64_flag_simd_memops)
130
131 /* Align definitions of arrays, unions and structures so that
132 initializations and copies can be made more efficient. This is not
133 ABI-changing, so it only affects places where we can see the
134 definition. Increasing the alignment tends to introduce padding,
135 so don't do this when optimizing for size/conserving stack space. */
136 #define AARCH64_EXPAND_ALIGNMENT(COND, EXP, ALIGN) \
137 (((COND) && ((ALIGN) < BITS_PER_WORD) \
138 && (TREE_CODE (EXP) == ARRAY_TYPE \
139 || TREE_CODE (EXP) == UNION_TYPE \
140 || TREE_CODE (EXP) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))
141
142 /* Align global data as an optimization. */
143 #define DATA_ALIGNMENT(EXP, ALIGN) aarch64_data_alignment (EXP, ALIGN)
144
145 /* Align stack data as an optimization. */
146 #define LOCAL_ALIGNMENT(EXP, ALIGN) aarch64_stack_alignment (EXP, ALIGN)
147
148 #define STRUCTURE_SIZE_BOUNDARY 8
149
150 /* Heap alignment (same as BIGGEST_ALIGNMENT and STACK_BOUNDARY). */
151 #define MALLOC_ABI_ALIGNMENT 128
152
153 /* Defined by the ABI */
154 #define WCHAR_TYPE "unsigned int"
155 #define WCHAR_TYPE_SIZE 32
156
157 /* Using long long breaks -ansi and -std=c90, so these will need to be
158 made conditional for an LLP64 ABI. */
159
160 #define SIZE_TYPE "long unsigned int"
161
162 #define PTRDIFF_TYPE "long int"
163
164 #define PCC_BITFIELD_TYPE_MATTERS 1
165
166 /* Use the same RTL truth representation for vector elements as we do
167 for scalars. This maintains the property that a comparison like
168 eq:V4SI is a composition of 4 individual eq:SIs, just like plus:V4SI
169 is a composition of 4 individual plus:SIs.
170
171 This means that Advanced SIMD comparisons are represented in RTL as
172 (neg (op ...)). */
173
174 #define VECTOR_STORE_FLAG_VALUE(MODE) CONST1_RTX (GET_MODE_INNER (MODE))
175
176 #ifndef USED_FOR_TARGET
177
178 /* Define an enum of all features (ISA modes, architectures and extensions).
179 The ISA modes must come first. */
180 enum class aarch64_feature : unsigned char {
181 #define DEF_AARCH64_ISA_MODE(IDENT) IDENT,
182 #define AARCH64_OPT_EXTENSION(A, IDENT, C, D, E, F) IDENT,
183 #define AARCH64_ARCH(A, B, IDENT, D, E) IDENT,
184 #include "aarch64-isa-modes.def"
185 #include "aarch64-option-extensions.def"
186 #include "aarch64-arches.def"
187 };
188
189 /* Define unique flags for each of the above. */
190 #define HANDLE(IDENT) \
191 constexpr auto AARCH64_FL_##IDENT ATTRIBUTE_UNUSED \
192 = aarch64_feature_flags::from_index (int (aarch64_feature::IDENT));
193 #define DEF_AARCH64_ISA_MODE(IDENT) HANDLE (IDENT)
194 #define AARCH64_OPT_EXTENSION(A, IDENT, C, D, E, F) HANDLE (IDENT)
195 #define AARCH64_ARCH(A, B, IDENT, D, E) HANDLE (IDENT)
196 #include "aarch64-isa-modes.def"
197 #include "aarch64-option-extensions.def"
198 #include "aarch64-arches.def"
199 #undef HANDLE
200
201 /* Define aarch64_isa_mode masks. */
202 #define DEF_AARCH64_ISA_MODE(IDENT) \
203 constexpr auto AARCH64_ISA_MODE_##IDENT ATTRIBUTE_UNUSED \
204 = aarch64_isa_mode (1) << int (aarch64_feature::IDENT);
205 #include "aarch64-isa-modes.def"
206 #undef HANDLE
207
208 constexpr auto AARCH64_FL_SM_STATE ATTRIBUTE_UNUSED
209 = AARCH64_FL_SM_ON | AARCH64_FL_SM_OFF;
210 constexpr auto AARCH64_ISA_MODE_SM_STATE ATTRIBUTE_UNUSED
211 = AARCH64_ISA_MODE_SM_ON | AARCH64_ISA_MODE_SM_OFF;
212
213 /* The mask of all ISA modes. */
214 constexpr auto AARCH64_FL_ISA_MODES
215 = aarch64_feature_flags ((1 << AARCH64_NUM_ISA_MODES) - 1);
216
217 /* The default ISA mode, for functions with no attributes that specify
218 something to the contrary. */
219 constexpr auto AARCH64_DEFAULT_ISA_MODE ATTRIBUTE_UNUSED
220 = AARCH64_ISA_MODE_SM_OFF;
221 constexpr auto AARCH64_FL_DEFAULT_ISA_MODE ATTRIBUTE_UNUSED
222 = aarch64_feature_flags (AARCH64_DEFAULT_ISA_MODE);
223
224 #endif
225
226 /* Macros to test ISA flags.
227
228 There is intentionally no macro for AARCH64_FL_CRYPTO, since this flag bit
229 is not always set when its constituent features are present.
230 Check (TARGET_AES && TARGET_SHA2) instead. */
231
232 #define AARCH64_HAVE_ISA(X) (bool (aarch64_isa_flags & AARCH64_FL_##X))
233
234 #define AARCH64_ISA_MODE ((aarch64_isa_flags & AARCH64_FL_ISA_MODES).val[0])
235
236 /* The current function is a normal non-streaming function. */
237 #define TARGET_NON_STREAMING AARCH64_HAVE_ISA (SM_OFF)
238
239 /* The current function has a streaming body. */
240 #define TARGET_STREAMING AARCH64_HAVE_ISA (SM_ON)
241
242 /* The current function has a streaming-compatible body. */
243 #define TARGET_STREAMING_COMPATIBLE \
244 ((aarch64_isa_flags & AARCH64_FL_SM_STATE) == 0)
245
246 /* PSTATE.ZA is enabled in the current function body. */
247 #define TARGET_ZA AARCH64_HAVE_ISA (ZA_ON)
248
249 /* AdvSIMD is supported in the default configuration, unless disabled by
250 -mgeneral-regs-only or by the +nosimd extension. The set of available
251 instructions is then subdivided into:
252
253 - the "base" set, available both in SME streaming mode and in
254 non-streaming mode
255
256 - the full set, available only in non-streaming mode. */
257 #define TARGET_BASE_SIMD AARCH64_HAVE_ISA (SIMD)
258 #define TARGET_SIMD (TARGET_BASE_SIMD && TARGET_NON_STREAMING)
259 #define TARGET_FLOAT AARCH64_HAVE_ISA (FP)
260
261 /* AARCH64_FL options necessary for system register implementation. */
262
263 /* Define AARCH64_FL aliases for architectural features which are protected
264 by -march flags in binutils but which receive no special treatment by GCC.
265
266 Such flags are inherited from the Binutils definition of system registers
267 and are mapped to the architecture in which the feature is implemented. */
268 #define AARCH64_FL_RAS AARCH64_FL_V8A
269 #define AARCH64_FL_LOR AARCH64_FL_V8_1A
270 #define AARCH64_FL_PAN AARCH64_FL_V8_1A
271 #define AARCH64_FL_AMU AARCH64_FL_V8_4A
272 #define AARCH64_FL_SCXTNUM AARCH64_FL_V8_5A
273 #define AARCH64_FL_ID_PFR2 AARCH64_FL_V8_5A
274
275 /* Armv8.9-A extension feature bits defined in Binutils but absent from GCC,
276 aliased to their base architecture. */
277 #define AARCH64_FL_AIE AARCH64_FL_V8_9A
278 #define AARCH64_FL_DEBUGv8p9 AARCH64_FL_V8_9A
279 #define AARCH64_FL_FGT2 AARCH64_FL_V8_9A
280 #define AARCH64_FL_ITE AARCH64_FL_V8_9A
281 #define AARCH64_FL_PFAR AARCH64_FL_V8_9A
282 #define AARCH64_FL_PMUv3_ICNTR AARCH64_FL_V8_9A
283 #define AARCH64_FL_PMUv3_SS AARCH64_FL_V8_9A
284 #define AARCH64_FL_PMUv3p9 AARCH64_FL_V8_9A
285 #define AARCH64_FL_RASv2 AARCH64_FL_V8_9A
286 #define AARCH64_FL_S1PIE AARCH64_FL_V8_9A
287 #define AARCH64_FL_S1POE AARCH64_FL_V8_9A
288 #define AARCH64_FL_S2PIE AARCH64_FL_V8_9A
289 #define AARCH64_FL_S2POE AARCH64_FL_V8_9A
290 #define AARCH64_FL_SCTLR2 AARCH64_FL_V8_9A
291 #define AARCH64_FL_SEBEP AARCH64_FL_V8_9A
292 #define AARCH64_FL_SPE_FDS AARCH64_FL_V8_9A
293 #define AARCH64_FL_TCR2 AARCH64_FL_V8_9A
294
295 #define TARGET_V8R AARCH64_HAVE_ISA (V8R)
296 #define TARGET_V9A AARCH64_HAVE_ISA (V9A)
297
298
299 /* SHA2 is an optional extension to AdvSIMD. */
300 #define TARGET_SHA2 AARCH64_HAVE_ISA (SHA2)
301
302 /* SHA3 is an optional extension to AdvSIMD. */
303 #define TARGET_SHA3 AARCH64_HAVE_ISA (SHA3)
304
305 /* AES is an optional extension to AdvSIMD. */
306 #define TARGET_AES AARCH64_HAVE_ISA (AES)
307
308 /* SM is an optional extension to AdvSIMD. */
309 #define TARGET_SM4 AARCH64_HAVE_ISA (SM4)
310
311 /* CRC instructions that can be enabled through +crc arch extension. */
312 #define TARGET_CRC32 AARCH64_HAVE_ISA (CRC)
313
314 /* Atomic instructions that can be enabled through the +lse extension. */
315 #define TARGET_LSE AARCH64_HAVE_ISA (LSE)
316
317 /* ARMv8.2-A FP16 support that can be enabled through the +fp16 extension. */
318 #define TARGET_FP_F16INST AARCH64_HAVE_ISA (F16)
319 #define TARGET_SIMD_F16INST (TARGET_SIMD && TARGET_FP_F16INST)
320
321 /* FP16FML is an optional extension to AdvSIMD. */
322 #define TARGET_F16FML (TARGET_SIMD_F16INST && AARCH64_HAVE_ISA (F16FML))
323
324 /* Dot Product is an optional extension to AdvSIMD enabled through +dotprod. */
325 #define TARGET_DOTPROD AARCH64_HAVE_ISA (DOTPROD)
326
327 /* SVE instructions, enabled through +sve. */
328 #define TARGET_SVE AARCH64_HAVE_ISA (SVE)
329
330 /* SVE2 instructions, enabled through +sve2. */
331 #define TARGET_SVE2 AARCH64_HAVE_ISA (SVE2)
332
333 /* SVE2 AES instructions, enabled through +sve2-aes. */
334 #define TARGET_SVE2_AES (AARCH64_HAVE_ISA (SVE2_AES) && TARGET_NON_STREAMING)
335
336 /* SVE2 BITPERM instructions, enabled through +sve2-bitperm. */
337 #define TARGET_SVE2_BITPERM (AARCH64_HAVE_ISA (SVE2_BITPERM) \
338 && TARGET_NON_STREAMING)
339
340 /* SVE2 SHA3 instructions, enabled through +sve2-sha3. */
341 #define TARGET_SVE2_SHA3 (AARCH64_HAVE_ISA (SVE2_SHA3) && TARGET_NON_STREAMING)
342
343 /* SVE2 SM4 instructions, enabled through +sve2-sm4. */
344 #define TARGET_SVE2_SM4 (AARCH64_HAVE_ISA (SVE2_SM4) && TARGET_NON_STREAMING)
345
346 /* SVE2p1 instructions, enabled through +sve2p1. */
347 #define TARGET_SVE2p1 AARCH64_HAVE_ISA (SVE2p1)
348
349 /* SME instructions, enabled through +sme. Note that this does not
350 imply anything about the state of PSTATE.SM; instructions that require
351 SME and streaming mode should use TARGET_STREAMING instead. */
352 #define TARGET_SME AARCH64_HAVE_ISA (SME)
353
354 /* The FEAT_SME_I16I64 extension to SME, enabled through +sme-i16i64. */
355 #define TARGET_SME_I16I64 AARCH64_HAVE_ISA (SME_I16I64)
356
357 /* The FEAT_SME_B16B16 extension to SME, enabled through +sme-b16b16. */
358 #define TARGET_STREAMING_SME_B16B16 \
359 (AARCH64_HAVE_ISA (SME_B16B16) && TARGET_STREAMING)
360
361 /* The FEAT_SME_F16F16 extension to SME, enabled through +sme-f16f16. */
362 #define TARGET_STREAMING_SME_F16F16 \
363 (AARCH64_HAVE_ISA (SME_F16F16) && TARGET_STREAMING)
364
365 /* The FEAT_SME_F64F64 extension to SME, enabled through +sme-f64f64. */
366 #define TARGET_SME_F64F64 AARCH64_HAVE_ISA (SME_F64F64)
367
368 /* SME2 instructions, enabled through +sme2. */
369 #define TARGET_SME2 AARCH64_HAVE_ISA (SME2)
370
371 /* Same with streaming mode enabled. */
372 #define TARGET_STREAMING_SME2 (TARGET_STREAMING && TARGET_SME2)
373
374 #define TARGET_STREAMING_SME2p1 (TARGET_STREAMING && AARCH64_HAVE_ISA (SME2p1))
375
376 #define TARGET_SME_B16B16 AARCH64_HAVE_ISA (SME_B16B16)
377
378 /* ARMv8.3-A features. */
379 #define TARGET_ARMV8_3 AARCH64_HAVE_ISA (V8_3A)
380
381 /* Javascript conversion instruction from Armv8.3-a. */
382 #define TARGET_JSCVT AARCH64_HAVE_ISA (JSCVT)
383
384 /* Armv8.3-a Complex number extension to AdvSIMD extensions. */
385 #define TARGET_COMPLEX AARCH64_HAVE_ISA (FCMA)
386
387 /* Floating-point rounding instructions from Armv8.5-a. */
388 #define TARGET_FRINT AARCH64_HAVE_ISA (FRINTTS)
389
390 /* TME instructions are enabled. */
391 #define TARGET_TME AARCH64_HAVE_ISA (TME)
392
393 /* Random number instructions from Armv8.5-a. */
394 #define TARGET_RNG AARCH64_HAVE_ISA (RNG)
395
396 /* Memory Tagging instructions optional to Armv8.5 enabled through +memtag. */
397 #define TARGET_MEMTAG AARCH64_HAVE_ISA (MEMTAG)
398
399 /* I8MM instructions are enabled through +i8mm. */
400 #define TARGET_I8MM AARCH64_HAVE_ISA (I8MM)
401 #define TARGET_SVE_I8MM (TARGET_SVE && TARGET_I8MM)
402
403 /* F32MM instructions are enabled through +f32mm. */
404 #define TARGET_SVE_F32MM AARCH64_HAVE_ISA (F32MM)
405
406 /* F64MM instructions are enabled through +f64mm. */
407 #define TARGET_SVE_F64MM AARCH64_HAVE_ISA (F64MM)
408
409 /* BF16 instructions are enabled through +bf16. */
410 #define TARGET_BF16_FP AARCH64_HAVE_ISA (BF16)
411 #define TARGET_BF16_SIMD (TARGET_BF16_FP && TARGET_SIMD)
412 #define TARGET_SVE_BF16 (TARGET_BF16_FP && TARGET_SVE)
413
414 /* PAUTH instructions are enabled through +pauth. */
415 #define TARGET_PAUTH AARCH64_HAVE_ISA (PAUTH)
416
417 /* BTI instructions exist from Armv8.5-a onwards. Their automatic use is
418 enabled through -mbranch-protection by using NOP-space instructions,
419 but this TARGET_ is used for defining BTI-related ACLE things. */
420 #define TARGET_BTI AARCH64_HAVE_ISA (V8_5A)
421
422 /* MOPS instructions are enabled through +mops. */
423 #define TARGET_MOPS AARCH64_HAVE_ISA (MOPS)
424
425 /* LS64 instructions are enabled through +ls64. */
426 #define TARGET_LS64 AARCH64_HAVE_ISA (LS64)
427
428 /* CSSC instructions are enabled through +cssc. */
429 #define TARGET_CSSC AARCH64_HAVE_ISA (CSSC)
430
431 /* Make sure this is always defined so we don't have to check for ifdefs
432 but rather use normal ifs. */
433 #ifndef TARGET_FIX_ERR_A53_835769_DEFAULT
434 #define TARGET_FIX_ERR_A53_835769_DEFAULT 0
435 #else
436 #undef TARGET_FIX_ERR_A53_835769_DEFAULT
437 #define TARGET_FIX_ERR_A53_835769_DEFAULT 1
438 #endif
439
440 /* SB instruction is enabled through +sb. */
441 #define TARGET_SB AARCH64_HAVE_ISA (SB)
442
443 /* RCPC loads from Armv8.3-a. */
444 #define TARGET_RCPC AARCH64_HAVE_ISA (RCPC)
445
446 /* The RCPC2 extensions from Armv8.4-a that allow immediate offsets to LDAPR
447 and sign-extending versions.*/
448 #define TARGET_RCPC2 AARCH64_HAVE_ISA (RCPC2)
449
450 /* RCPC3 (Release Consistency) extensions, optional from Armv8.2-a. */
451 #define TARGET_RCPC3 AARCH64_HAVE_ISA (RCPC3)
452
453 /* Apply the workaround for Cortex-A53 erratum 835769. */
454 #define TARGET_FIX_ERR_A53_835769 \
455 ((aarch64_fix_a53_err835769 == 2) \
456 ? TARGET_FIX_ERR_A53_835769_DEFAULT : aarch64_fix_a53_err835769)
457
458 /* Make sure this is always defined so we don't have to check for ifdefs
459 but rather use normal ifs. */
460 #ifndef TARGET_FIX_ERR_A53_843419_DEFAULT
461 #define TARGET_FIX_ERR_A53_843419_DEFAULT 0
462 #else
463 #undef TARGET_FIX_ERR_A53_843419_DEFAULT
464 #define TARGET_FIX_ERR_A53_843419_DEFAULT 1
465 #endif
466
467 /* Apply the workaround for Cortex-A53 erratum 843419. */
468 #define TARGET_FIX_ERR_A53_843419 \
469 ((aarch64_fix_a53_err843419 == 2) \
470 ? TARGET_FIX_ERR_A53_843419_DEFAULT : aarch64_fix_a53_err843419)
471
472 /* ARMv8.1-A Adv.SIMD support. */
473 #define TARGET_SIMD_RDMA (TARGET_SIMD && AARCH64_HAVE_ISA (RDMA))
474
475 /* Armv9.4-A features. */
476 #define TARGET_ARMV9_4 AARCH64_HAVE_ISA (V9_4A)
477
478 /* 128-bit System Registers and Instructions from Armv9.4-a are enabled
479 through +d128. */
480 #define TARGET_D128 AARCH64_HAVE_ISA (D128)
481
482 /* Armv8.9-A/9.4-A Translation Hardening Extension system registers are
483 enabled through +the. */
484 #define TARGET_THE AARCH64_HAVE_ISA (THE)
485
486 /* Armv9.4-A Guarded Control Stack extension system registers are
487 enabled through +gcs. */
488 #define TARGET_GCS AARCH64_HAVE_ISA (GCS)
489
490 /* Floating Point Absolute Maximum/Minimum extension instructions are
491 enabled through +faminmax. */
492 #define TARGET_FAMINMAX AARCH64_HAVE_ISA (FAMINMAX)
493
494 /* Lookup table (LUTI) extension instructions are enabled through +lut. */
495 #define TARGET_LUT AARCH64_HAVE_ISA (LUT)
496
497 /* Prefer different predicate registers for the output of a predicated
498 operation over re-using an existing input predicate. */
499 #define TARGET_SVE_PRED_CLOBBER (TARGET_SVE \
500 && (aarch64_tune_params.extra_tuning_flags \
501 & AARCH64_EXTRA_TUNE_AVOID_PRED_RMW))
502
503 /* fp8 instructions are enabled through +fp8. */
504 #define TARGET_FP8 AARCH64_HAVE_ISA (FP8)
505
506 /* See the comment above the tuning flag for details. */
507 #define TARGET_CHEAP_FPMR_WRITE \
508 (bool (aarch64_tune_params.extra_tuning_flags \
509 & AARCH64_EXTRA_TUNE_CHEAP_FPMR_WRITE))
510
511 /* Combinatorial tests. */
512
513 #define TARGET_SVE2_OR_SME2 \
514 ((TARGET_SVE2 || TARGET_STREAMING) \
515 && (TARGET_SME2 || TARGET_NON_STREAMING))
516
517 /* There's no need to check TARGET_SME for streaming or streaming-compatible
518 functions, since streaming mode itself implies SME. */
519 #define TARGET_SVE2p1_OR_SME (TARGET_SVE2p1 || TARGET_STREAMING)
520
521 #define TARGET_SVE2p1_OR_SME2 \
522 ((TARGET_SVE2p1 || TARGET_STREAMING) \
523 && (TARGET_SME2 || TARGET_NON_STREAMING))
524
525 #define TARGET_SSVE_B16B16 \
526 (AARCH64_HAVE_ISA (SVE_B16B16) && TARGET_SVE2_OR_SME2)
527
528 /* Some fp8 instructions require +fp8 and one of +sve2 or +sme2. */
529 #define TARGET_SSVE_FP8 (TARGET_FP8 \
530 && (TARGET_SVE2 || TARGET_STREAMING) \
531 && (TARGET_SME2 || TARGET_NON_STREAMING))
532
533 /* fp8 multiply-accumulate instructions are enabled through +fp8fma. */
534 #define TARGET_FP8FMA AARCH64_HAVE_ISA (FP8FMA)
535
536 /* SVE2 versions of fp8 multiply-accumulate instructions are enabled for
537 non-streaming mode by +fp8fma and for streaming mode by +ssve-fp8fma. */
538 #define TARGET_SSVE_FP8FMA \
539 (((TARGET_SVE2 && TARGET_FP8FMA) || TARGET_STREAMING) \
540 && (AARCH64_HAVE_ISA (SSVE_FP8FMA) || TARGET_NON_STREAMING))
541
542 /* fp8 four way dot product enabled through +fp8dot4. */
543 #define TARGET_FP8DOT4 AARCH64_HAVE_ISA (FP8DOT4)
544
545 /* Streaming versions of fp8 four way dot product instructions are enabled
546 through +ssve-fp8dot4. */
547 #define TARGET_SSVE_FP8DOT4 ((\
548 (TARGET_SVE2 && TARGET_FP8DOT4) || TARGET_STREAMING) \
549 && (AARCH64_HAVE_ISA(SSVE_FP8DOT4) || TARGET_NON_STREAMING))
550
551 /* fp8 two way dot product enabled through +fp8dot2. */
552 #define TARGET_FP8DOT2 AARCH64_HAVE_ISA (FP8DOT2)
553
554 /* Streaming versions of fp8 two way dot product instructions are enabled
555 through +ssve-fp8dot2. */
556 #define TARGET_SSVE_FP8DOT2 ((\
557 (TARGET_SVE2 && TARGET_FP8DOT2) || TARGET_STREAMING) \
558 && (AARCH64_HAVE_ISA(SSVE_FP8DOT2) || TARGET_NON_STREAMING))
559
560 /* Standard register usage. */
561
562 /* 31 64-bit general purpose registers R0-R30:
563 R30 LR (link register)
564 R29 FP (frame pointer)
565 R19-R28 Callee-saved registers
566 R18 The platform register; use as temporary register.
567 R17 IP1 The second intra-procedure-call temporary register
568 (can be used by call veneers and PLT code); otherwise use
569 as a temporary register
570 R16 IP0 The first intra-procedure-call temporary register (can
571 be used by call veneers and PLT code); otherwise use as a
572 temporary register
573 R9-R15 Temporary registers
574 R8 Structure value parameter / temporary register
575 R0-R7 Parameter/result registers
576
577 SP stack pointer, encoded as X/R31 where permitted.
578 ZR zero register, encoded as X/R31 elsewhere
579
580 32 x 128-bit floating-point/vector registers
581 V16-V31 Caller-saved (temporary) registers
582 V8-V15 Callee-saved registers
583 V0-V7 Parameter/result registers
584
585 The vector register V0 holds scalar B0, H0, S0 and D0 in its least
586 significant bits. Unlike AArch32 S1 is not packed into D0, etc.
587
588 P0-P7 Predicate low registers: valid in all predicate contexts
589 P8-P15 Predicate high registers: used as scratch space
590
591 FFR First Fault Register, a fixed-use SVE predicate register
592 FFRT FFR token: a fake register used for modelling dependencies
593
594 VG Pseudo "vector granules" register
595
596 VG is the number of 64-bit elements in an SVE vector. We define
597 it as a hard register so that we can easily map it to the DWARF VG
598 register. GCC internally uses the poly_int variable aarch64_sve_vg
599 instead. */
600
601 #define FIXED_X18 0
602 #define CALL_USED_X18 1
603
604 #define FIXED_REGISTERS \
605 { \
606 0, 0, 0, 0, 0, 0, 0, 0, /* R0 - R7 */ \
607 0, 0, 0, 0, 0, 0, 0, 0, /* R8 - R15 */ \
608 0, 0, FIXED_X18, 0, 0, 0, 0, 0, /* R16 - R23. */ \
609 0, 0, 0, 0, 0, 1, 0, 1, /* R24 - R30, SP */ \
610 0, 0, 0, 0, 0, 0, 0, 0, /* V0 - V7 */ \
611 0, 0, 0, 0, 0, 0, 0, 0, /* V8 - V15 */ \
612 0, 0, 0, 0, 0, 0, 0, 0, /* V16 - V23 */ \
613 0, 0, 0, 0, 0, 0, 0, 0, /* V24 - V31 */ \
614 1, 1, 1, 1, /* SFP, AP, CC, VG */ \
615 0, 0, 0, 0, 0, 0, 0, 0, /* P0 - P7 */ \
616 0, 0, 0, 0, 0, 0, 0, 0, /* P8 - P15 */ \
617 1, /* FPMR */ \
618 1, 1, /* FFR and FFRT */ \
619 1, 1, 1, 1, 1, 1, 1, 1 /* Fake registers */ \
620 }
621
622 /* X30 is marked as caller-saved which is in line with regular function call
623 behavior since the call instructions clobber it; AARCH64_EXPAND_CALL does
624 that for regular function calls and avoids it for sibcalls. X30 is
625 considered live for sibcalls; EPILOGUE_USES helps achieve that by returning
626 true but not until function epilogues have been generated. This ensures
627 that X30 is available for use in leaf functions if needed. */
628
629 #define CALL_REALLY_USED_REGISTERS \
630 { \
631 1, 1, 1, 1, 1, 1, 1, 1, /* R0 - R7 */ \
632 1, 1, 1, 1, 1, 1, 1, 1, /* R8 - R15 */ \
633 1, 1, CALL_USED_X18, 0, 0, 0, 0, 0, /* R16 - R23. */ \
634 0, 0, 0, 0, 0, 1, 1, 1, /* R24 - R30, SP */ \
635 1, 1, 1, 1, 1, 1, 1, 1, /* V0 - V7 */ \
636 0, 0, 0, 0, 0, 0, 0, 0, /* V8 - V15 */ \
637 1, 1, 1, 1, 1, 1, 1, 1, /* V16 - V23 */ \
638 1, 1, 1, 1, 1, 1, 1, 1, /* V24 - V31 */ \
639 1, 1, 1, 0, /* SFP, AP, CC, VG */ \
640 1, 1, 1, 1, 1, 1, 1, 1, /* P0 - P7 */ \
641 1, 1, 1, 1, 1, 1, 1, 1, /* P8 - P15 */ \
642 1, /* FPMR */ \
643 1, 1, /* FFR and FFRT */ \
644 0, 0, 0, 0, 0, 0, 0, 0 /* Fake registers */ \
645 }
646
647 #define REGISTER_NAMES \
648 { \
649 "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", \
650 "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15", \
651 "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23", \
652 "x24", "x25", "x26", "x27", "x28", "x29", "x30", "sp", \
653 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", \
654 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", \
655 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", \
656 "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", \
657 "sfp", "ap", "cc", "vg", \
658 "p0", "p1", "p2", "p3", "p4", "p5", "p6", "p7", \
659 "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
660 "fpmr", \
661 "ffr", "ffrt", \
662 "lowering", "tpidr2_block", "sme_state", "tpidr2_setup", \
663 "za_free", "za_saved", "za", "zt0" \
664 }
665
666 /* Generate the register aliases for core register N */
667 #define R_ALIASES(N) {"r" # N, R0_REGNUM + (N)}, \
668 {"w" # N, R0_REGNUM + (N)}
669
670 #define V_ALIASES(N) {"q" # N, V0_REGNUM + (N)}, \
671 {"d" # N, V0_REGNUM + (N)}, \
672 {"s" # N, V0_REGNUM + (N)}, \
673 {"h" # N, V0_REGNUM + (N)}, \
674 {"b" # N, V0_REGNUM + (N)}, \
675 {"z" # N, V0_REGNUM + (N)}
676
677 #define P_ALIASES(N) {"pn" # N, P0_REGNUM + (N)}
678
679 /* Provide aliases for all of the ISA defined register name forms.
680 These aliases are convenient for use in the clobber lists of inline
681 asm statements. */
682
683 #define ADDITIONAL_REGISTER_NAMES \
684 { R_ALIASES(0), R_ALIASES(1), R_ALIASES(2), R_ALIASES(3), \
685 R_ALIASES(4), R_ALIASES(5), R_ALIASES(6), R_ALIASES(7), \
686 R_ALIASES(8), R_ALIASES(9), R_ALIASES(10), R_ALIASES(11), \
687 R_ALIASES(12), R_ALIASES(13), R_ALIASES(14), R_ALIASES(15), \
688 R_ALIASES(16), R_ALIASES(17), R_ALIASES(18), R_ALIASES(19), \
689 R_ALIASES(20), R_ALIASES(21), R_ALIASES(22), R_ALIASES(23), \
690 R_ALIASES(24), R_ALIASES(25), R_ALIASES(26), R_ALIASES(27), \
691 R_ALIASES(28), R_ALIASES(29), R_ALIASES(30), {"wsp", R0_REGNUM + 31}, \
692 V_ALIASES(0), V_ALIASES(1), V_ALIASES(2), V_ALIASES(3), \
693 V_ALIASES(4), V_ALIASES(5), V_ALIASES(6), V_ALIASES(7), \
694 V_ALIASES(8), V_ALIASES(9), V_ALIASES(10), V_ALIASES(11), \
695 V_ALIASES(12), V_ALIASES(13), V_ALIASES(14), V_ALIASES(15), \
696 V_ALIASES(16), V_ALIASES(17), V_ALIASES(18), V_ALIASES(19), \
697 V_ALIASES(20), V_ALIASES(21), V_ALIASES(22), V_ALIASES(23), \
698 V_ALIASES(24), V_ALIASES(25), V_ALIASES(26), V_ALIASES(27), \
699 V_ALIASES(28), V_ALIASES(29), V_ALIASES(30), V_ALIASES(31), \
700 P_ALIASES(0), P_ALIASES(1), P_ALIASES(2), P_ALIASES(3), \
701 P_ALIASES(4), P_ALIASES(5), P_ALIASES(6), P_ALIASES(7), \
702 P_ALIASES(8), P_ALIASES(9), P_ALIASES(10), P_ALIASES(11), \
703 P_ALIASES(12), P_ALIASES(13), P_ALIASES(14), P_ALIASES(15) \
704 }
705
706 #define EPILOGUE_USES(REGNO) (aarch64_epilogue_uses (REGNO))
707
708 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
709 the stack pointer does not matter. This is only true if the function
710 uses alloca. */
711 #define EXIT_IGNORE_STACK (cfun->calls_alloca)
712
713 #define STATIC_CHAIN_REGNUM R18_REGNUM
714 #define HARD_FRAME_POINTER_REGNUM R29_REGNUM
715 #define FRAME_POINTER_REGNUM SFP_REGNUM
716 #define STACK_POINTER_REGNUM SP_REGNUM
717 #define ARG_POINTER_REGNUM AP_REGNUM
718 #define FIRST_PSEUDO_REGISTER (LAST_FAKE_REGNUM + 1)
719
720 /* The number of argument registers available for each class. */
721 #define NUM_ARG_REGS 8
722 #define NUM_FP_ARG_REGS 8
723 #define NUM_PR_ARG_REGS 4
724
725 /* A Homogeneous Floating-Point or Short-Vector Aggregate may have at most
726 four members. */
727 #define HA_MAX_NUM_FLDS 4
728
729 /* External dwarf register number scheme. These number are used to
730 identify registers in dwarf debug information, the values are
731 defined by the AArch64 ABI. The numbering scheme is independent of
732 GCC's internal register numbering scheme. */
733
734 #define AARCH64_DWARF_R0 0
735
736 /* The number of R registers, note 31! not 32. */
737 #define AARCH64_DWARF_NUMBER_R 31
738
739 #define AARCH64_DWARF_SP 31
740 #define AARCH64_DWARF_VG 46
741 #define AARCH64_DWARF_P0 48
742 #define AARCH64_DWARF_V0 64
743
744 /* The number of V registers. */
745 #define AARCH64_DWARF_NUMBER_V 32
746
747 /* For signal frames we need to use an alternative return column. This
748 value must not correspond to a hard register and must be out of the
749 range of DWARF_FRAME_REGNUM(). */
750 #define DWARF_ALT_FRAME_RETURN_COLUMN \
751 (AARCH64_DWARF_V0 + AARCH64_DWARF_NUMBER_V)
752
753 /* We add 1 extra frame register for use as the
754 DWARF_ALT_FRAME_RETURN_COLUMN. */
755 #define DWARF_FRAME_REGISTERS (DWARF_ALT_FRAME_RETURN_COLUMN + 1)
756
757
758 #define DEBUGGER_REGNO(REGNO) aarch64_debugger_regno (REGNO)
759 /* Provide a definition of DWARF_FRAME_REGNUM here so that fallback unwinders
760 can use DWARF_ALT_FRAME_RETURN_COLUMN defined below. This is just the same
761 as the default definition in dwarf2out.cc. */
762 #undef DWARF_FRAME_REGNUM
763 #define DWARF_FRAME_REGNUM(REGNO) DEBUGGER_REGNO (REGNO)
764
765 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (LR_REGNUM)
766
767 #define DWARF2_UNWIND_INFO 1
768
769 /* Use R0 through R3 to pass exception handling information. */
770 #define EH_RETURN_DATA_REGNO(N) \
771 ((N) < 4 ? ((unsigned int) R0_REGNUM + (N)) : INVALID_REGNUM)
772
773 /* Select a format to encode pointers in exception handling data. */
774 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
775 aarch64_asm_preferred_eh_data_format ((CODE), (GLOBAL))
776
777 /* Output the assembly strings we want to add to a function definition. */
778 #define ASM_DECLARE_FUNCTION_NAME(STR, NAME, DECL) \
779 aarch64_declare_function_name (STR, NAME, DECL)
780
781 /* Output assembly strings for alias definition. */
782 #define ASM_OUTPUT_DEF_FROM_DECLS(STR, DECL, TARGET) \
783 aarch64_asm_output_alias (STR, DECL, TARGET)
784
785 /* Output assembly strings for undefined extern symbols. */
786 #undef ASM_OUTPUT_EXTERNAL
787 #define ASM_OUTPUT_EXTERNAL(STR, DECL, NAME) \
788 aarch64_asm_output_external (STR, DECL, NAME)
789
790 /* Output assembly strings after .cfi_startproc is emitted. */
791 #define ASM_POST_CFI_STARTPROC aarch64_post_cfi_startproc
792
793 /* For EH returns X4 is a flag that is set in the EH return
794 code paths and then X5 and X6 contain the stack adjustment
795 and return address respectively. */
796 #define EH_RETURN_TAKEN_RTX gen_rtx_REG (Pmode, R4_REGNUM)
797 #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, R5_REGNUM)
798 #define EH_RETURN_HANDLER_RTX gen_rtx_REG (Pmode, R6_REGNUM)
799
800 #undef TARGET_COMPUTE_FRAME_LAYOUT
801 #define TARGET_COMPUTE_FRAME_LAYOUT aarch64_layout_frame
802
803 /* Register in which the structure value is to be returned. */
804 #define AARCH64_STRUCT_VALUE_REGNUM R8_REGNUM
805
806 /* Non-zero if REGNO is part of the Core register set.
807
808 The rather unusual way of expressing this check is to avoid
809 warnings when building the compiler when R0_REGNUM is 0 and REGNO
810 is unsigned. */
811 #define GP_REGNUM_P(REGNO) \
812 (((unsigned) (REGNO - R0_REGNUM)) <= (R30_REGNUM - R0_REGNUM))
813
814 /* Registers known to be preserved over a BL instruction. This consists of the
815 GENERAL_REGS without x16, x17, and x30. The x30 register is changed by the
816 BL instruction itself, while the x16 and x17 registers may be used by
817 veneers which can be inserted by the linker. */
818 #define STUB_REGNUM_P(REGNO) \
819 (GP_REGNUM_P (REGNO) \
820 && (REGNO) != R16_REGNUM \
821 && (REGNO) != R17_REGNUM \
822 && (REGNO) != R30_REGNUM) \
823
824 #define W8_W11_REGNUM_P(REGNO) \
825 IN_RANGE (REGNO, R8_REGNUM, R11_REGNUM)
826
827 #define W12_W15_REGNUM_P(REGNO) \
828 IN_RANGE (REGNO, R12_REGNUM, R15_REGNUM)
829
830 #define FP_REGNUM_P(REGNO) \
831 (((unsigned) (REGNO - V0_REGNUM)) <= (V31_REGNUM - V0_REGNUM))
832
833 #define FP_LO_REGNUM_P(REGNO) \
834 (((unsigned) (REGNO - V0_REGNUM)) <= (V15_REGNUM - V0_REGNUM))
835
836 #define FP_LO8_REGNUM_P(REGNO) \
837 (((unsigned) (REGNO - V0_REGNUM)) <= (V7_REGNUM - V0_REGNUM))
838
839 #define PR_REGNUM_P(REGNO)\
840 (((unsigned) (REGNO - P0_REGNUM)) <= (P15_REGNUM - P0_REGNUM))
841
842 #define PR_LO_REGNUM_P(REGNO)\
843 (((unsigned) (REGNO - P0_REGNUM)) <= (P7_REGNUM - P0_REGNUM))
844
845 #define FP_SIMD_SAVED_REGNUM_P(REGNO) \
846 (((unsigned) (REGNO - V8_REGNUM)) <= (V23_REGNUM - V8_REGNUM))
847
848 #define FAKE_REGNUM_P(REGNO) \
849 IN_RANGE (REGNO, FIRST_FAKE_REGNUM, LAST_FAKE_REGNUM)
850
851 /* Register and constant classes. */
852
853 enum reg_class
854 {
855 NO_REGS,
856 W8_W11_REGS,
857 W12_W15_REGS,
858 TAILCALL_ADDR_REGS,
859 STUB_REGS,
860 GENERAL_REGS,
861 STACK_REG,
862 POINTER_REGS,
863 FP_LO8_REGS,
864 FP_LO_REGS,
865 FP_REGS,
866 POINTER_AND_FP_REGS,
867 PR_LO_REGS,
868 PR_HI_REGS,
869 PR_REGS,
870 FFR_REGS,
871 PR_AND_FFR_REGS,
872 MOVEABLE_SYSREGS,
873 FAKE_REGS,
874 ALL_REGS,
875 LIM_REG_CLASSES /* Last */
876 };
877
878 #define N_REG_CLASSES ((int) LIM_REG_CLASSES)
879
880 #define REG_CLASS_NAMES \
881 { \
882 "NO_REGS", \
883 "W8_W11_REGS", \
884 "W12_W15_REGS", \
885 "TAILCALL_ADDR_REGS", \
886 "STUB_REGS", \
887 "GENERAL_REGS", \
888 "STACK_REG", \
889 "POINTER_REGS", \
890 "FP_LO8_REGS", \
891 "FP_LO_REGS", \
892 "FP_REGS", \
893 "POINTER_AND_FP_REGS", \
894 "PR_LO_REGS", \
895 "PR_HI_REGS", \
896 "PR_REGS", \
897 "FFR_REGS", \
898 "PR_AND_FFR_REGS", \
899 "MOVEABLE_SYSREGS", \
900 "FAKE_REGS", \
901 "ALL_REGS" \
902 }
903
904 #define REG_CLASS_CONTENTS \
905 { \
906 { 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \
907 { 0x00000f00, 0x00000000, 0x00000000 }, /* W8_W11_REGS */ \
908 { 0x0000f000, 0x00000000, 0x00000000 }, /* W12_W15_REGS */ \
909 { 0x00030000, 0x00000000, 0x00000000 }, /* TAILCALL_ADDR_REGS */\
910 { 0x3ffcffff, 0x00000000, 0x00000000 }, /* STUB_REGS */ \
911 { 0x7fffffff, 0x00000000, 0x00000003 }, /* GENERAL_REGS */ \
912 { 0x80000000, 0x00000000, 0x00000000 }, /* STACK_REG */ \
913 { 0xffffffff, 0x00000000, 0x00000003 }, /* POINTER_REGS */ \
914 { 0x00000000, 0x000000ff, 0x00000000 }, /* FP_LO8_REGS */ \
915 { 0x00000000, 0x0000ffff, 0x00000000 }, /* FP_LO_REGS */ \
916 { 0x00000000, 0xffffffff, 0x00000000 }, /* FP_REGS */ \
917 { 0xffffffff, 0xffffffff, 0x00000003 }, /* POINTER_AND_FP_REGS */\
918 { 0x00000000, 0x00000000, 0x00000ff0 }, /* PR_LO_REGS */ \
919 { 0x00000000, 0x00000000, 0x000ff000 }, /* PR_HI_REGS */ \
920 { 0x00000000, 0x00000000, 0x000ffff0 }, /* PR_REGS */ \
921 { 0x00000000, 0x00000000, 0x00600000 }, /* FFR_REGS */ \
922 { 0x00000000, 0x00000000, 0x006ffff0 }, /* PR_AND_FFR_REGS */ \
923 { 0x00000000, 0x00000000, 0x00100000 }, /* MOVEABLE_SYSREGS */ \
924 { 0x00000000, 0x00000000, 0x7f800000 }, /* FAKE_REGS */ \
925 { 0xffffffff, 0xffffffff, 0x001fffff } /* ALL_REGS */ \
926 }
927
928 #define REGNO_REG_CLASS(REGNO) aarch64_regno_regclass (REGNO)
929
930 #define INDEX_REG_CLASS GENERAL_REGS
931 #define BASE_REG_CLASS POINTER_REGS
932
933 /* Register pairs used to eliminate unneeded registers that point into
934 the stack frame. */
935 #define ELIMINABLE_REGS \
936 { \
937 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
938 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
939 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
940 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
941 }
942
943 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
944 (OFFSET) = aarch64_initial_elimination_offset (FROM, TO)
945
946 /* CPU/ARCH option handling. */
947 #include "config/aarch64/aarch64-opts.h"
948
949 /* If there is no CPU defined at configure, use generic as default. */
950 #ifndef TARGET_CPU_DEFAULT
951 # define TARGET_CPU_DEFAULT AARCH64_CPU_generic_armv8_a
952 #endif
953
954 /* If inserting NOP before a mult-accumulate insn remember to adjust the
955 length so that conditional branching code is updated appropriately. */
956 #define ADJUST_INSN_LENGTH(insn, length) \
957 do \
958 { \
959 if (aarch64_madd_needs_nop (insn)) \
960 length += 4; \
961 } while (0)
962
963 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
964 aarch64_final_prescan_insn (INSN); \
965
966 /* The processor for which instructions should be scheduled. */
967 extern enum aarch64_cpu aarch64_tune;
968
969 /* RTL generation support. */
970 #define INIT_EXPANDERS aarch64_init_expanders ()
971
972
973 /* Stack layout; function entry, exit and calling. */
974 #define STACK_GROWS_DOWNWARD 1
975
976 #define FRAME_GROWS_DOWNWARD 1
977
978 #define ACCUMULATE_OUTGOING_ARGS 1
979
980 #define FIRST_PARM_OFFSET(FNDECL) 0
981
982 /* Fix for VFP */
983 #define LIBCALL_VALUE(MODE) \
984 gen_rtx_REG (MODE, FLOAT_MODE_P (MODE) ? V0_REGNUM : R0_REGNUM)
985
986 #define DEFAULT_PCC_STRUCT_RETURN 0
987
988 #if defined(HAVE_POLY_INT_H) && defined(GCC_VEC_H)
989 struct GTY (()) aarch64_frame
990 {
991 /* The offset from the bottom of the static frame (the bottom of the
992 outgoing arguments) of each register save slot, or -2 if no save is
993 needed. */
994 poly_int64 reg_offset[LAST_SAVED_REGNUM + 1];
995
996 /* The list of GPRs, FPRs and predicate registers that have nonnegative
997 entries in reg_offset. The registers are listed in order of
998 increasing offset (rather than increasing register number). */
999 vec<unsigned, va_gc_atomic> *saved_gprs;
1000 vec<unsigned, va_gc_atomic> *saved_fprs;
1001 vec<unsigned, va_gc_atomic> *saved_prs;
1002
1003 /* The offset from the base of the frame of a 64-bit slot whose low
1004 bit contains the incoming value of PSTATE.SM. This slot must be
1005 within reach of the hard frame pointer.
1006
1007 The offset is -1 if such a slot isn't needed. */
1008 poly_int64 old_svcr_offset;
1009
1010 /* The number of extra stack bytes taken up by register varargs.
1011 This area is allocated by the callee at the very top of the
1012 frame. This value is rounded up to a multiple of
1013 STACK_BOUNDARY. */
1014 HOST_WIDE_INT saved_varargs_size;
1015
1016 /* The number of bytes between the bottom of the static frame (the bottom
1017 of the outgoing arguments) and the bottom of the register save area.
1018 This value is always a multiple of STACK_BOUNDARY. */
1019 poly_int64 bytes_below_saved_regs;
1020
1021 /* The number of bytes between the bottom of the static frame (the bottom
1022 of the outgoing arguments) and the hard frame pointer. This value is
1023 always a multiple of STACK_BOUNDARY. */
1024 poly_int64 bytes_below_hard_fp;
1025
1026 /* The number of bytes between the top of the locals area and the top
1027 of the frame (the incomming SP). This value is always a multiple of
1028 STACK_BOUNDARY. */
1029 poly_int64 bytes_above_locals;
1030
1031 /* The number of bytes between the hard_frame_pointer and the top of
1032 the frame (the incomming SP). This value is always a multiple of
1033 STACK_BOUNDARY. */
1034 poly_int64 bytes_above_hard_fp;
1035
1036 /* The size of the frame, i.e. the number of bytes between the bottom
1037 of the outgoing arguments and the incoming SP. This value is always
1038 a multiple of STACK_BOUNDARY. */
1039 poly_int64 frame_size;
1040
1041 /* The size of the initial stack adjustment before saving callee-saves. */
1042 poly_int64 initial_adjust;
1043
1044 /* The writeback value when pushing callee-save registers.
1045 It is zero when no push is used. */
1046 HOST_WIDE_INT callee_adjust;
1047
1048 /* The size of the stack adjustment before saving or after restoring
1049 SVE registers. */
1050 poly_int64 sve_callee_adjust;
1051
1052 /* The size of the stack adjustment after saving callee-saves. */
1053 poly_int64 final_adjust;
1054
1055 /* Store FP,LR and setup a frame pointer. */
1056 bool emit_frame_chain;
1057
1058 /* In each frame, we can associate up to two register saves with the
1059 initial stack allocation. This happens in one of two ways:
1060
1061 (1) Using an STR or STP with writeback to perform the initial
1062 stack allocation. When EMIT_FRAME_CHAIN, the registers will
1063 be those needed to create a frame chain.
1064
1065 Indicated by CALLEE_ADJUST != 0.
1066
1067 (2) Using a separate STP to set up the frame record, after the
1068 initial stack allocation but before setting up the frame pointer.
1069 This is used if the offset is too large to use writeback.
1070
1071 Indicated by CALLEE_ADJUST == 0 && EMIT_FRAME_CHAIN.
1072
1073 These fields indicate which registers we've decided to handle using
1074 (1) or (2), or INVALID_REGNUM if none.
1075
1076 In some cases we don't always need to pop all registers in the push
1077 candidates, pop candidates record which registers need to be popped
1078 eventually. The initial value of a pop candidate is copied from its
1079 corresponding push candidate.
1080
1081 Currently, different pop candidates are only used for shadow call
1082 stack. When "-fsanitize=shadow-call-stack" is specified, we replace
1083 x30 in the pop candidate with INVALID_REGNUM to ensure that x30 is
1084 not popped twice. */
1085 unsigned wb_push_candidate1;
1086 unsigned wb_push_candidate2;
1087 unsigned wb_pop_candidate1;
1088 unsigned wb_pop_candidate2;
1089
1090 /* Big-endian SVE frames need a spare predicate register in order
1091 to save vector registers in the correct layout for unwinding.
1092 This is the register they should use. */
1093 unsigned spare_pred_reg;
1094
1095 /* An SVE register that is saved below the hard frame pointer and that acts
1096 as a probe for later allocations, or INVALID_REGNUM if none. */
1097 unsigned sve_save_and_probe;
1098
1099 /* A register that is saved at the hard frame pointer and that acts
1100 as a probe for later allocations, or INVALID_REGNUM if none. */
1101 unsigned hard_fp_save_and_probe;
1102
1103 bool laid_out;
1104
1105 /* True if shadow call stack should be enabled for the current function. */
1106 bool is_scs_enabled;
1107 };
1108
1109 /* Private to winnt.cc. */
1110 struct seh_frame_state;
1111
1112 #ifdef hash_set_h
1113 typedef struct GTY (()) machine_function
1114 {
1115 struct aarch64_frame frame;
1116 /* One entry for each hard register. */
1117 bool reg_is_wrapped_separately[LAST_SAVED_REGNUM + 1];
1118 /* One entry for each general purpose register. */
1119 rtx call_via[SP_REGNUM];
1120
1121 /* A pseudo register that points to the function's TPIDR2 block, or null
1122 if the function doesn't have a TPIDR2 block. */
1123 rtx tpidr2_block;
1124
1125 /* A pseudo register that points to the function's ZA save buffer,
1126 or null if none. */
1127 rtx za_save_buffer;
1128
1129 /* A stack slot that stores the contents of the function's ZT0 state. */
1130 rtx zt0_save_buffer;
1131
1132 bool label_is_assembled;
1133
1134 /* True if we've expanded at least one call to a function that changes
1135 PSTATE.SM. This should only be used for saving compile time: false
1136 guarantees that no such mode switch exists. */
1137 bool call_switches_pstate_sm;
1138
1139 /* Used to generated unique identifiers for each update to ZA by an
1140 asm statement. */
1141 unsigned int next_asm_update_za_id;
1142
1143 /* A set of all decls that have been passed to a vld1 intrinsic in the
1144 current function. This is used to help guide the vector cost model. */
1145 hash_set<tree> *vector_load_decls;
1146
1147 /* An instruction that was emitted at the start of the function to
1148 set an Advanced SIMD pseudo register to zero. If the instruction
1149 still exists and still fulfils its original purpose. the same register
1150 can be reused by other code. */
1151 rtx_insn *advsimd_zero_insn;
1152
1153 /* During SEH output, this is non-null. */
1154 struct seh_frame_state * GTY ((skip (""))) seh;
1155 } machine_function;
1156 #endif
1157 #endif
1158
1159 /* Which ABI to use. */
1160 enum aarch64_abi_type
1161 {
1162 AARCH64_ABI_LP64 = 0,
1163 AARCH64_ABI_ILP32 = 1
1164 };
1165
1166 #ifndef AARCH64_ABI_DEFAULT
1167 #define AARCH64_ABI_DEFAULT AARCH64_ABI_LP64
1168 #endif
1169
1170 #define TARGET_ILP32 (aarch64_abi & AARCH64_ABI_ILP32)
1171
1172 enum arm_pcs
1173 {
1174 ARM_PCS_AAPCS64, /* Base standard AAPCS for 64 bit. */
1175 ARM_PCS_SIMD, /* For aarch64_vector_pcs functions. */
1176 ARM_PCS_SVE, /* For functions that pass or return
1177 values in SVE registers. */
1178 ARM_PCS_TLSDESC, /* For targets of tlsdesc calls. */
1179 ARM_PCS_UNKNOWN
1180 };
1181
1182
1183
1184
1185 /* We can't use machine_mode inside a generator file because it
1186 hasn't been created yet; we shouldn't be using any code that
1187 needs the real definition though, so this ought to be safe. */
1188 #ifdef GENERATOR_FILE
1189 #define MACHMODE int
1190 #else
1191 #include "insn-modes.h"
1192 #define MACHMODE machine_mode
1193 #endif
1194
1195 #ifndef USED_FOR_TARGET
1196 /* AAPCS related state tracking. */
1197 typedef struct
1198 {
1199 enum arm_pcs pcs_variant;
1200 aarch64_isa_mode isa_mode;
1201 bool indirect_return; /* Whether function is marked with indirect_return attribute. */
1202 int aapcs_arg_processed; /* No need to lay out this argument again. */
1203 int aapcs_ncrn; /* Next Core register number. */
1204 int aapcs_nextncrn; /* Next next core register number. */
1205 int aapcs_nvrn; /* Next Vector register number. */
1206 int aapcs_nextnvrn; /* Next Next Vector register number. */
1207 int aapcs_nprn; /* Next Predicate register number. */
1208 int aapcs_nextnprn; /* Next Next Predicate register number. */
1209 rtx aapcs_reg; /* Register assigned to this argument. This
1210 is NULL_RTX if this parameter goes on
1211 the stack. */
1212 MACHMODE aapcs_vfp_rmode;
1213 int aapcs_stack_words; /* If the argument is passed on the stack, this
1214 is the number of words needed, after rounding
1215 up. Only meaningful when
1216 aapcs_reg == NULL_RTX. */
1217 int aapcs_stack_size; /* The total size (in words, per 8 byte) of the
1218 stack arg area so far. */
1219 bool silent_p; /* True if we should act silently, rather than
1220 raise an error for invalid calls. */
1221
1222 /* AARCH64_STATE_* flags that describe whether the function shares ZA
1223 and ZT0 with its callers. */
1224 unsigned int shared_za_flags;
1225 unsigned int shared_zt0_flags;
1226
1227 /* A list of registers that need to be saved and restored around a
1228 change to PSTATE.SM. An auto_vec would be more convenient, but those
1229 can't be copied. */
1230 unsigned int num_sme_mode_switch_args;
1231 rtx sme_mode_switch_args[12];
1232 } CUMULATIVE_ARGS;
1233 #endif
1234
1235 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
1236 (aarch64_pad_reg_upward (MODE, TYPE, FIRST) ? PAD_UPWARD : PAD_DOWNWARD)
1237
1238 #define PAD_VARARGS_DOWN 0
1239
1240 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
1241 aarch64_init_cumulative_args (&(CUM), FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS)
1242
1243 #define FUNCTION_ARG_REGNO_P(REGNO) \
1244 aarch64_function_arg_regno_p(REGNO)
1245
1246
1247 /* ISA Features. */
1248
1249 /* Addressing modes, etc. */
1250 #define HAVE_POST_INCREMENT 1
1251 #define HAVE_PRE_INCREMENT 1
1252 #define HAVE_POST_DECREMENT 1
1253 #define HAVE_PRE_DECREMENT 1
1254 #define HAVE_POST_MODIFY_DISP 1
1255 #define HAVE_PRE_MODIFY_DISP 1
1256
1257 #define MAX_REGS_PER_ADDRESS 2
1258
1259 #define CONSTANT_ADDRESS_P(X) aarch64_constant_address_p(X)
1260
1261 #define REGNO_OK_FOR_BASE_P(REGNO) \
1262 aarch64_regno_ok_for_base_p (REGNO, true)
1263
1264 #define REGNO_OK_FOR_INDEX_P(REGNO) \
1265 aarch64_regno_ok_for_index_p (REGNO, true)
1266
1267 #define LEGITIMATE_PIC_OPERAND_P(X) \
1268 aarch64_legitimate_pic_operand_p (X)
1269
1270 #define CASE_VECTOR_MODE Pmode
1271
1272 #define DEFAULT_SIGNED_CHAR 0
1273
1274 /* An integer expression for the size in bits of the largest integer machine
1275 mode that should actually be used. We allow pairs of registers. */
1276 #define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TImode)
1277
1278 /* Maximum bytes moved by a single instruction (load/store pair). */
1279 #define MOVE_MAX (UNITS_PER_WORD * 2)
1280
1281 /* The base cost overhead of a memcpy call, for MOVE_RATIO and friends. */
1282 #define AARCH64_CALL_RATIO 8
1283
1284 /* MOVE_RATIO dictates when we will use the move_by_pieces infrastructure.
1285 move_by_pieces will continually copy the largest safe chunks. So a
1286 7-byte copy is a 4-byte + 2-byte + byte copy. This proves inefficient
1287 for both size and speed of copy, so we will instead use the "cpymem"
1288 standard name to implement the copy. This logic does not apply when
1289 targeting -mstrict-align or TARGET_MOPS, so keep a sensible default in
1290 that case. */
1291 #define MOVE_RATIO(speed) \
1292 ((!STRICT_ALIGNMENT || TARGET_MOPS) ? 2 : (((speed) ? 15 : AARCH64_CALL_RATIO) / 2))
1293
1294 /* Like MOVE_RATIO, without -mstrict-align, make decisions in "setmem" when
1295 we would use more than 3 scalar instructions.
1296 Otherwise follow a sensible default: when optimizing for size, give a better
1297 estimate of the length of a memset call, but use the default otherwise. */
1298 #define CLEAR_RATIO(speed) \
1299 (!STRICT_ALIGNMENT ? (TARGET_MOPS ? 0 : 4) : (speed) ? 15 : AARCH64_CALL_RATIO)
1300
1301 /* SET_RATIO is similar to CLEAR_RATIO, but for a non-zero constant. Without
1302 -mstrict-align, make decisions in "setmem". Otherwise follow a sensible
1303 default: when optimizing for size adjust the ratio to account for the
1304 overhead of loading the constant. */
1305 #define SET_RATIO(speed) \
1306 ((!STRICT_ALIGNMENT || TARGET_MOPS) ? 0 : (speed) ? 15 : AARCH64_CALL_RATIO - 2)
1307
1308 /* Disable auto-increment in move_by_pieces et al. Use of auto-increment is
1309 rarely a good idea in straight-line code since it adds an extra address
1310 dependency between each instruction. Better to use incrementing offsets. */
1311 #define USE_LOAD_POST_INCREMENT(MODE) 0
1312 #define USE_LOAD_POST_DECREMENT(MODE) 0
1313 #define USE_LOAD_PRE_INCREMENT(MODE) 0
1314 #define USE_LOAD_PRE_DECREMENT(MODE) 0
1315 #define USE_STORE_POST_INCREMENT(MODE) 0
1316 #define USE_STORE_POST_DECREMENT(MODE) 0
1317 #define USE_STORE_PRE_INCREMENT(MODE) 0
1318 #define USE_STORE_PRE_DECREMENT(MODE) 0
1319
1320 /* WORD_REGISTER_OPERATIONS does not hold for AArch64.
1321 The assigned word_mode is DImode but operations narrower than SImode
1322 behave as 32-bit operations if using the W-form of the registers rather
1323 than as word_mode (64-bit) operations as WORD_REGISTER_OPERATIONS
1324 expects. */
1325 #define WORD_REGISTER_OPERATIONS 0
1326
1327 /* Define if loading from memory in MODE, an integral mode narrower than
1328 BITS_PER_WORD will either zero-extend or sign-extend. The value of this
1329 macro should be the code that says which one of the two operations is
1330 implicitly done, or UNKNOWN if none. */
1331 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
1332
1333 /* Define this macro to be non-zero if instructions will fail to work
1334 if given data not on the nominal alignment. */
1335 #define STRICT_ALIGNMENT TARGET_STRICT_ALIGN
1336
1337 /* Enable wide bitfield accesses for more efficient bitfield code. */
1338 #define SLOW_BYTE_ACCESS 1
1339
1340 #define NO_FUNCTION_CSE 1
1341
1342 /* Specify the machine mode that the hardware addresses have.
1343 After generation of rtl, the compiler makes no further distinction
1344 between pointers and any other objects of this machine mode. */
1345 #define Pmode DImode
1346
1347 /* A C expression whose value is zero if pointers that need to be extended
1348 from being `POINTER_SIZE' bits wide to `Pmode' are sign-extended and
1349 greater then zero if they are zero-extended and less then zero if the
1350 ptr_extend instruction should be used. */
1351 #define POINTERS_EXTEND_UNSIGNED 1
1352
1353 /* Mode of a function address in a call instruction (for indexing purposes). */
1354 #define FUNCTION_MODE Pmode
1355
1356 #define SELECT_CC_MODE(OP, X, Y) aarch64_select_cc_mode (OP, X, Y)
1357
1358 /* Having an integer comparison mode guarantees that we can use
1359 reverse_condition, but the usual restrictions apply to floating-point
1360 comparisons. */
1361 #define REVERSIBLE_CC_MODE(MODE) ((MODE) != CCFPmode && (MODE) != CCFPEmode)
1362
1363 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
1364 ((VALUE) = GET_MODE_UNIT_BITSIZE (MODE), 2)
1365 #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
1366 ((VALUE) = GET_MODE_UNIT_BITSIZE (MODE), 2)
1367
1368 /* Have space for both SP and GCSPR in the NONLOCAL case in
1369 emit_stack_save as well as in __builtin_setjmp, __builtin_longjmp
1370 and __builtin_nonlocal_goto.
1371 Note: On ILP32 the documented buf size is not enough PR84150. */
1372 #define STACK_SAVEAREA_MODE(LEVEL) \
1373 ((LEVEL) == SAVE_NONLOCAL ? E_CDImode : Pmode)
1374
1375 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LR_REGNUM)
1376
1377 #define RETURN_ADDR_RTX aarch64_return_addr
1378
1379 /* BTI c + 3 insns
1380 + sls barrier of DSB + ISB.
1381 + 2 pointer-sized entries. */
1382 #define TRAMPOLINE_SIZE (24 + (TARGET_ILP32 ? 8 : 16))
1383
1384 /* Trampolines contain dwords, so must be dword aligned. */
1385 #define TRAMPOLINE_ALIGNMENT 64
1386
1387 /* Put trampolines in the text section so that mapping symbols work
1388 correctly. */
1389 #define TRAMPOLINE_SECTION text_section
1390
1391 /* To start with. */
1392 #define BRANCH_COST(SPEED_P, PREDICTABLE_P) \
1393 (aarch64_branch_cost (SPEED_P, PREDICTABLE_P))
1394
1395
1396 /* Assembly output. */
1397
1398 /* For now we'll make all jump tables pc-relative. */
1399 #define CASE_VECTOR_PC_RELATIVE 1
1400
1401 #define CASE_VECTOR_SHORTEN_MODE(min, max, body) \
1402 ((min < -0x1fff0 || max > 0x1fff0) ? SImode \
1403 : (min < -0x1f0 || max > 0x1f0) ? HImode \
1404 : QImode)
1405
1406 /* Jump table alignment is explicit in ASM_OUTPUT_CASE_LABEL. */
1407 #define ADDR_VEC_ALIGN(JUMPTABLE) 0
1408
1409 #define MCOUNT_NAME "_mcount"
1410
1411 #define NO_PROFILE_COUNTERS 1
1412
1413 /* Emit rtl for profiling. Output assembler code to FILE
1414 to call "_mcount" for profiling a function entry. */
1415 #define PROFILE_HOOK(LABEL) \
1416 { \
1417 rtx fun, lr; \
1418 lr = aarch64_return_addr_rtx (); \
1419 fun = gen_rtx_SYMBOL_REF (Pmode, MCOUNT_NAME); \
1420 emit_library_call (fun, LCT_NORMAL, VOIDmode, lr, Pmode); \
1421 }
1422
1423 /* All the work done in PROFILE_HOOK, but still required. */
1424 #define FUNCTION_PROFILER(STREAM, LABELNO) do { } while (0)
1425
1426 /* For some reason, the Linux headers think they know how to define
1427 these macros. They don't!!! */
1428 #undef ASM_APP_ON
1429 #undef ASM_APP_OFF
1430 #define ASM_APP_ON "\t" ASM_COMMENT_START " Start of user assembly\n"
1431 #define ASM_APP_OFF "\t" ASM_COMMENT_START " End of user assembly\n"
1432
1433 #define CONSTANT_POOL_BEFORE_FUNCTION 0
1434
1435 /* This definition should be relocated to aarch64-elf-raw.h. This macro
1436 should be undefined in aarch64-linux.h and a clear_cache pattern
1437 implmented to emit either the call to __aarch64_sync_cache_range()
1438 directly or preferably the appropriate sycall or cache clear
1439 instructions inline. */
1440 #define CLEAR_INSN_CACHE(beg, end) \
1441 extern void __aarch64_sync_cache_range (void *, void *); \
1442 __aarch64_sync_cache_range (beg, end)
1443
1444 #define SHIFT_COUNT_TRUNCATED (!TARGET_SIMD)
1445
1446 /* Choose appropriate mode for caller saves, so we do the minimum
1447 required size of load/store. */
1448 #define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE) \
1449 aarch64_hard_regno_caller_save_mode ((REGNO), (NREGS), (MODE))
1450
1451 #undef SWITCHABLE_TARGET
1452 #define SWITCHABLE_TARGET 1
1453
1454 /* Check TLS Descriptors mechanism is selected. */
1455 #define TARGET_TLS_DESC (aarch64_tls_dialect == TLS_DESCRIPTORS)
1456
1457 extern enum aarch64_code_model aarch64_cmodel;
1458
1459 /* When using the tiny addressing model conditional and unconditional branches
1460 can span the whole of the available address space (1MB). */
1461 #define HAS_LONG_COND_BRANCH \
1462 (aarch64_cmodel == AARCH64_CMODEL_TINY \
1463 || aarch64_cmodel == AARCH64_CMODEL_TINY_PIC)
1464
1465 #define HAS_LONG_UNCOND_BRANCH \
1466 (aarch64_cmodel == AARCH64_CMODEL_TINY \
1467 || aarch64_cmodel == AARCH64_CMODEL_TINY_PIC)
1468
1469 #define TARGET_HAS_FMV_TARGET_ATTRIBUTE 0
1470
1471 #define TARGET_SUPPORTS_WIDE_INT 1
1472
1473 /* Modes valid for AdvSIMD D registers, i.e. that fit in half a Q register. */
1474 #define AARCH64_VALID_SIMD_DREG_MODE(MODE) \
1475 ((MODE) == V2SImode || (MODE) == V4HImode || (MODE) == V8QImode \
1476 || (MODE) == V2SFmode || (MODE) == V4HFmode || (MODE) == DImode \
1477 || (MODE) == DFmode || (MODE) == V4BFmode)
1478
1479 /* Modes valid for AdvSIMD Q registers. */
1480 #define AARCH64_VALID_SIMD_QREG_MODE(MODE) \
1481 ((MODE) == V4SImode || (MODE) == V8HImode || (MODE) == V16QImode \
1482 || (MODE) == V4SFmode || (MODE) == V8HFmode || (MODE) == V2DImode \
1483 || (MODE) == V2DFmode || (MODE) == V8BFmode)
1484
1485 #define ENDIAN_LANE_N(NUNITS, N) \
1486 (BYTES_BIG_ENDIAN ? NUNITS - 1 - N : N)
1487
1488 /* Extra specs when building a native AArch64-hosted compiler.
1489 Option rewriting rules based on host system. */
1490 #if defined(__aarch64__)
1491 extern const char *host_detect_local_cpu (int argc, const char **argv);
1492 #define HAVE_LOCAL_CPU_DETECT
1493 # define EXTRA_SPEC_FUNCTIONS \
1494 { "local_cpu_detect", host_detect_local_cpu }, \
1495 AARCH64_BASE_SPEC_FUNCTIONS
1496
1497 /* Rewrite -m{arch,cpu,tune}=native based on the host system information.
1498 When rewriting -march=native convert it into an -mcpu option if no other
1499 -mcpu or -mtune was given. */
1500 # define MCPU_MTUNE_NATIVE_SPECS \
1501 " %{march=native:%<march=native %:local_cpu_detect(%{mcpu=*|mtune=*:arch;:cpu})}" \
1502 " %{mcpu=native:%<mcpu=native %:local_cpu_detect(cpu)}" \
1503 " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
1504 /* This will be used in OPTION_DEFAULT_SPECS below.
1505 When GCC is configured with --with-tune we don't want to materialize an
1506 implicit -mtune would prevent the rewriting of -march=native into
1507 -mcpu=native as per the above rules. */
1508 #define CONFIG_TUNE_SPEC \
1509 { "tune", "%{!mcpu=*:%{!mtune=*:%{!march=native:-mtune=%(VALUE)}}}" },
1510 #else
1511 # define MCPU_MTUNE_NATIVE_SPECS ""
1512 # define EXTRA_SPEC_FUNCTIONS AARCH64_BASE_SPEC_FUNCTIONS
1513 # define CONFIG_TUNE_SPEC \
1514 {"tune", "%{!mcpu=*:%{!mtune=*:-mtune=%(VALUE)}}"},
1515 #endif
1516
1517 /* Support for configure-time --with-arch, --with-cpu and --with-tune.
1518 --with-arch and --with-cpu are ignored if either -mcpu or -march is used.
1519 --with-tune is ignored if either -mtune or -mcpu is used (but is not
1520 affected by -march, except in the -march=native case as per the
1521 CONFIG_TUNE_SPEC above). */
1522 #define OPTION_DEFAULT_SPECS \
1523 {"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" }, \
1524 {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \
1525 CONFIG_TUNE_SPEC
1526
1527 #define MARCH_REWRITE_SPEC \
1528 "%{march=*:-march=%:rewrite_march(%{march=*:%*});" \
1529 "mcpu=*:-march=%:rewrite_mcpu(%{mcpu=*:%*})}"
1530
1531 extern const char *aarch64_rewrite_march (int argc, const char **argv);
1532 extern const char *aarch64_rewrite_mcpu (int argc, const char **argv);
1533 extern const char *is_host_cpu_not_armv8_base (int argc, const char **argv);
1534 #define AARCH64_BASE_SPEC_FUNCTIONS \
1535 { "rewrite_march", aarch64_rewrite_march }, \
1536 { "rewrite_mcpu", aarch64_rewrite_mcpu }, \
1537 { "is_local_not_armv8_base", is_host_cpu_not_armv8_base },
1538
1539
1540 #define ASM_CPU_SPEC \
1541 MARCH_REWRITE_SPEC
1542
1543 #define EXTRA_SPECS \
1544 { "asm_cpu_spec", ASM_CPU_SPEC }
1545
1546 #define ASM_OUTPUT_POOL_EPILOGUE aarch64_asm_output_pool_epilogue
1547
1548 /* This type is the user-visible __mfp8, and a pointer to that type. We
1549 need it in many places in the backend. Defined in aarch64-builtins.cc. */
1550 extern GTY(()) tree aarch64_mfp8_type_node;
1551 extern GTY(()) tree aarch64_mfp8_ptr_type_node;
1552
1553 /* This type is the user-visible __fp16, and a pointer to that type. We
1554 need it in many places in the backend. Defined in aarch64-builtins.cc. */
1555 extern GTY(()) tree aarch64_fp16_type_node;
1556 extern GTY(()) tree aarch64_fp16_ptr_type_node;
1557
1558 /* Pointer to the user-visible __bf16 type. __bf16 itself is generic
1559 bfloat16_type_node. Defined in aarch64-builtins.cc. */
1560 extern GTY(()) tree aarch64_bf16_ptr_type_node;
1561
1562 /* The generic unwind code in libgcc does not initialize the frame pointer.
1563 So in order to unwind a function using a frame pointer, the very first
1564 function that is unwound must save the frame pointer. That way the frame
1565 pointer is restored and its value is now valid - otherwise _Unwind_GetGR
1566 crashes. Libgcc can now be safely built with -fomit-frame-pointer. */
1567 #define LIBGCC2_UNWIND_ATTRIBUTE \
1568 __attribute__((optimize ("no-omit-frame-pointer")))
1569
1570 #ifndef USED_FOR_TARGET
1571 extern poly_uint16 aarch64_sve_vg;
1572
1573 /* The number of bits and bytes in an SVE vector. */
1574 #define BITS_PER_SVE_VECTOR (poly_uint16 (aarch64_sve_vg * 64))
1575 #define BYTES_PER_SVE_VECTOR (poly_uint16 (aarch64_sve_vg * 8))
1576
1577 /* The number of bits and bytes in an SVE predicate. */
1578 #define BITS_PER_SVE_PRED BYTES_PER_SVE_VECTOR
1579 #define BYTES_PER_SVE_PRED aarch64_sve_vg
1580
1581 /* The SVE mode for a vector of bytes. */
1582 #define SVE_BYTE_MODE VNx16QImode
1583
1584 /* The maximum number of bytes in a fixed-size vector. This is 256 bytes
1585 (for -msve-vector-bits=2048) multiplied by the maximum number of
1586 vectors in a structure mode (4).
1587
1588 This limit must not be used for variable-size vectors, since
1589 VL-agnostic code must work with arbitary vector lengths. */
1590 #define MAX_COMPILE_TIME_VEC_BYTES (256 * 4)
1591 #endif
1592
1593 #define REGMODE_NATURAL_SIZE(MODE) aarch64_regmode_natural_size (MODE)
1594
1595 /* Allocate a minimum of STACK_CLASH_MIN_BYTES_OUTGOING_ARGS bytes for the
1596 outgoing arguments if stack clash protection is enabled. This is essential
1597 as the extra arg space allows us to skip a check in alloca. */
1598 #undef STACK_DYNAMIC_OFFSET
1599 #define STACK_DYNAMIC_OFFSET(FUNDECL) \
1600 ((flag_stack_clash_protection \
1601 && cfun->calls_alloca \
1602 && known_lt (crtl->outgoing_args_size, \
1603 STACK_CLASH_MIN_BYTES_OUTGOING_ARGS)) \
1604 ? ROUND_UP (STACK_CLASH_MIN_BYTES_OUTGOING_ARGS, \
1605 STACK_BOUNDARY / BITS_PER_UNIT) \
1606 : (crtl->outgoing_args_size + STACK_POINTER_OFFSET))
1607
1608 /* Filled in by aarch64_adjust_reg_alloc_order, which is called before
1609 the first relevant use. */
1610 #define REG_ALLOC_ORDER {}
1611 #define ADJUST_REG_ALLOC_ORDER aarch64_adjust_reg_alloc_order ()
1612
1613 #define AARCH64_VALID_SHRN_OP(T,S) \
1614 ((T) == TRUNCATE \
1615 || ((T) == US_TRUNCATE && (S) == LSHIFTRT) \
1616 || ((T) == SS_TRUNCATE && (S) == ASHIFTRT))
1617
1618 #ifndef USED_FOR_TARGET
1619
1620 /* Enumerates the mode-switching "entities" for AArch64. */
1621 enum class aarch64_mode_entity : int
1622 {
1623 /* An aarch64_tristate_mode that says whether we have created a local
1624 save buffer for the current function's ZA state. The only transition
1625 is from NO to YES. */
1626 HAVE_ZA_SAVE_BUFFER,
1627
1628 /* An aarch64_local_sme_state that reflects the state of all data
1629 controlled by PSTATE.ZA. */
1630 LOCAL_SME_STATE
1631 };
1632
1633 /* Describes the state of all data controlled by PSTATE.ZA */
1634 enum class aarch64_local_sme_state : int
1635 {
1636 /* ZA is in the off or dormant state. If it is dormant, the contents
1637 of ZA belong to a caller. */
1638 INACTIVE_CALLER,
1639
1640 /* ZA is in the off state: PSTATE.ZA is 0 and TPIDR2_EL0 is null. */
1641 OFF,
1642
1643 /* ZA is in the off or dormant state. If it is dormant, the contents
1644 of ZA belong to the current function. */
1645 INACTIVE_LOCAL,
1646
1647 /* ZA is in the off state and the current function's ZA contents are
1648 stored in the lazy save buffer. This is the state on entry to
1649 exception handlers. */
1650 SAVED_LOCAL,
1651
1652 /* ZA is in the active state: PSTATE.ZA is 1 and TPIDR2_EL0 is null.
1653 The contents of ZA are live. */
1654 ACTIVE_LIVE,
1655
1656 /* ZA is in the active state: PSTATE.ZA is 1 and TPIDR2_EL0 is null.
1657 The contents of ZA are dead. */
1658 ACTIVE_DEAD,
1659
1660 /* ZA could be in multiple states. */
1661 ANY
1662 };
1663
1664 enum class aarch64_tristate_mode : int { NO, YES, MAYBE };
1665
1666 #define OPTIMIZE_MODE_SWITCHING(ENTITY) \
1667 aarch64_optimize_mode_switching (aarch64_mode_entity (ENTITY))
1668
1669 #define NUM_MODES_FOR_MODE_SWITCHING \
1670 { int (aarch64_tristate_mode::MAYBE), \
1671 int (aarch64_local_sme_state::ANY) }
1672
1673 /* Zero terminated list of regnos for which hardreg PRE should be
1674 applied. */
1675 #define HARDREG_PRE_REGNOS { FPM_REGNUM, 0 }
1676
1677 #endif
1678
1679 #endif /* GCC_AARCH64_H */