]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/aarch64/aarch64.h
mklog: Symbol '}' stops search for changes.
[thirdparty/gcc.git] / gcc / config / aarch64 / aarch64.h
CommitLineData
43e9d192 1/* Machine description for AArch64 architecture.
23a5b65a 2 Copyright (C) 2009-2014 Free Software Foundation, Inc.
43e9d192
IB
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/* Target CPU builtins. */
26#define TARGET_CPU_CPP_BUILTINS() \
27 do \
28 { \
9e98c8c3
RL
29 builtin_define ("__aarch64__"); \
30 builtin_define ("__ARM_64BIT_STATE"); \
0c6caaf8
RL
31 builtin_define_with_int_value \
32 ("__ARM_ARCH", aarch64_architecture_version); \
33 cpp_define_formatted \
34 (parse_in, "__ARM_ARCH_%dA", aarch64_architecture_version); \
9e98c8c3 35 builtin_define ("__ARM_ARCH_ISA_A64"); \
0c6caaf8
RL
36 builtin_define_with_int_value \
37 ("__ARM_ARCH_PROFILE", 'A'); \
9e98c8c3
RL
38 builtin_define ("__ARM_FEATURE_CLZ"); \
39 builtin_define ("__ARM_FEATURE_IDIV"); \
40 builtin_define ("__ARM_FEATURE_UNALIGNED"); \
41 builtin_define ("__ARM_PCS_AAPCS64"); \
42 builtin_define_with_int_value \
43 ("__ARM_SIZEOF_WCHAR_T", WCHAR_TYPE_SIZE / 8); \
44 builtin_define_with_int_value \
45 ("__ARM_SIZEOF_MINIMAL_ENUM", \
46 flag_short_enums? 1 : 4); \
43e9d192 47 if (TARGET_BIG_END) \
9e98c8c3
RL
48 { \
49 builtin_define ("__AARCH64EB__"); \
50 builtin_define ("__ARM_BIG_ENDIAN"); \
51 } \
43e9d192
IB
52 else \
53 builtin_define ("__AARCH64EL__"); \
54 \
683e3333 55 if (TARGET_SIMD) \
5750e120
IB
56 builtin_define ("__ARM_NEON"); \
57 \
5d357f26
KT
58 if (TARGET_CRC32) \
59 builtin_define ("__ARM_FEATURE_CRC32"); \
60 \
43e9d192
IB
61 switch (aarch64_cmodel) \
62 { \
63 case AARCH64_CMODEL_TINY: \
64 case AARCH64_CMODEL_TINY_PIC: \
65 builtin_define ("__AARCH64_CMODEL_TINY__"); \
66 break; \
67 case AARCH64_CMODEL_SMALL: \
68 case AARCH64_CMODEL_SMALL_PIC: \
69 builtin_define ("__AARCH64_CMODEL_SMALL__");\
70 break; \
71 case AARCH64_CMODEL_LARGE: \
72 builtin_define ("__AARCH64_CMODEL_LARGE__"); \
73 break; \
74 default: \
75 break; \
76 } \
77 \
43be9a95
YZ
78 if (TARGET_ILP32) \
79 { \
80 cpp_define (parse_in, "_ILP32"); \
81 cpp_define (parse_in, "__ILP32__"); \
82 } \
afb582f1
TB
83 if (TARGET_CRYPTO) \
84 builtin_define ("__ARM_FEATURE_CRYPTO"); \
43e9d192
IB
85 } while (0)
86
87\f
88
89/* Target machine storage layout. */
90
91#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
92 if (GET_MODE_CLASS (MODE) == MODE_INT \
93 && GET_MODE_SIZE (MODE) < 4) \
94 { \
95 if (MODE == QImode || MODE == HImode) \
96 { \
97 MODE = SImode; \
98 } \
99 }
100
101/* Bits are always numbered from the LSBit. */
102#define BITS_BIG_ENDIAN 0
103
104/* Big/little-endian flavour. */
105#define BYTES_BIG_ENDIAN (TARGET_BIG_END != 0)
106#define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN)
107
108/* AdvSIMD is supported in the default configuration, unless disabled by
683e3333
KT
109 -mgeneral-regs-only or by the +nosimd extension. */
110#define TARGET_SIMD (!TARGET_GENERAL_REGS_ONLY && AARCH64_ISA_SIMD)
111#define TARGET_FLOAT (!TARGET_GENERAL_REGS_ONLY && AARCH64_ISA_FP)
43e9d192
IB
112
113#define UNITS_PER_WORD 8
114
115#define UNITS_PER_VREG 16
116
117#define PARM_BOUNDARY 64
118
119#define STACK_BOUNDARY 128
120
121#define FUNCTION_BOUNDARY 32
122
123#define EMPTY_FIELD_BOUNDARY 32
124
125#define BIGGEST_ALIGNMENT 128
126
127#define SHORT_TYPE_SIZE 16
128
129#define INT_TYPE_SIZE 32
130
17a819cb
YZ
131#define LONG_TYPE_SIZE (TARGET_ILP32 ? 32 : 64)
132
133#define POINTER_SIZE (TARGET_ILP32 ? 32 : 64)
43e9d192
IB
134
135#define LONG_LONG_TYPE_SIZE 64
136
137#define FLOAT_TYPE_SIZE 32
138
139#define DOUBLE_TYPE_SIZE 64
140
141#define LONG_DOUBLE_TYPE_SIZE 128
142
143/* The architecture reserves all bits of the address for hardware use,
144 so the vbit must go into the delta field of pointers to member
145 functions. This is the same config as that in the AArch32
146 port. */
147#define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_delta
148
149/* Make strings word-aligned so that strcpy from constants will be
150 faster. */
151#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
152 ((TREE_CODE (EXP) == STRING_CST \
153 && !optimize_size \
154 && (ALIGN) < BITS_PER_WORD) \
155 ? BITS_PER_WORD : ALIGN)
156
157#define DATA_ALIGNMENT(EXP, ALIGN) \
158 ((((ALIGN) < BITS_PER_WORD) \
159 && (TREE_CODE (EXP) == ARRAY_TYPE \
160 || TREE_CODE (EXP) == UNION_TYPE \
161 || TREE_CODE (EXP) == RECORD_TYPE)) \
162 ? BITS_PER_WORD : (ALIGN))
163
164#define LOCAL_ALIGNMENT(EXP, ALIGN) DATA_ALIGNMENT(EXP, ALIGN)
165
166#define STRUCTURE_SIZE_BOUNDARY 8
167
168/* Defined by the ABI */
169#define WCHAR_TYPE "unsigned int"
170#define WCHAR_TYPE_SIZE 32
171
172/* Using long long breaks -ansi and -std=c90, so these will need to be
173 made conditional for an LLP64 ABI. */
174
175#define SIZE_TYPE "long unsigned int"
176
177#define PTRDIFF_TYPE "long int"
178
179#define PCC_BITFIELD_TYPE_MATTERS 1
180
0c6caaf8
RL
181/* Major revision number of the ARM Architecture implemented by the target. */
182extern unsigned aarch64_architecture_version;
43e9d192
IB
183
184/* Instruction tuning/selection flags. */
185
186/* Bit values used to identify processor capabilities. */
187#define AARCH64_FL_SIMD (1 << 0) /* Has SIMD instructions. */
188#define AARCH64_FL_FP (1 << 1) /* Has FP. */
189#define AARCH64_FL_CRYPTO (1 << 2) /* Has crypto. */
190#define AARCH64_FL_SLOWMUL (1 << 3) /* A slow multiply core. */
5922847b 191#define AARCH64_FL_CRC (1 << 4) /* Has CRC. */
43e9d192
IB
192
193/* Has FP and SIMD. */
194#define AARCH64_FL_FPSIMD (AARCH64_FL_FP | AARCH64_FL_SIMD)
195
196/* Has FP without SIMD. */
197#define AARCH64_FL_FPQ16 (AARCH64_FL_FP & ~AARCH64_FL_SIMD)
198
199/* Architecture flags that effect instruction selection. */
200#define AARCH64_FL_FOR_ARCH8 (AARCH64_FL_FPSIMD)
201
202/* Macros to test ISA flags. */
203extern unsigned long aarch64_isa_flags;
5922847b 204#define AARCH64_ISA_CRC (aarch64_isa_flags & AARCH64_FL_CRC)
43e9d192
IB
205#define AARCH64_ISA_CRYPTO (aarch64_isa_flags & AARCH64_FL_CRYPTO)
206#define AARCH64_ISA_FP (aarch64_isa_flags & AARCH64_FL_FP)
207#define AARCH64_ISA_SIMD (aarch64_isa_flags & AARCH64_FL_SIMD)
208
209/* Macros to test tuning flags. */
210extern unsigned long aarch64_tune_flags;
211#define AARCH64_TUNE_SLOWMUL (aarch64_tune_flags & AARCH64_FL_SLOWMUL)
212
683e3333
KT
213/* Crypto is an optional extension to AdvSIMD. */
214#define TARGET_CRYPTO (TARGET_SIMD && AARCH64_ISA_CRYPTO)
43e9d192 215
5d357f26
KT
216/* CRC instructions that can be enabled through +crc arch extension. */
217#define TARGET_CRC32 (AARCH64_ISA_CRC)
218
43e9d192
IB
219/* Standard register usage. */
220
221/* 31 64-bit general purpose registers R0-R30:
222 R30 LR (link register)
223 R29 FP (frame pointer)
224 R19-R28 Callee-saved registers
225 R18 The platform register; use as temporary register.
226 R17 IP1 The second intra-procedure-call temporary register
227 (can be used by call veneers and PLT code); otherwise use
228 as a temporary register
229 R16 IP0 The first intra-procedure-call temporary register (can
230 be used by call veneers and PLT code); otherwise use as a
231 temporary register
232 R9-R15 Temporary registers
233 R8 Structure value parameter / temporary register
234 R0-R7 Parameter/result registers
235
236 SP stack pointer, encoded as X/R31 where permitted.
237 ZR zero register, encoded as X/R31 elsewhere
238
239 32 x 128-bit floating-point/vector registers
240 V16-V31 Caller-saved (temporary) registers
241 V8-V15 Callee-saved registers
242 V0-V7 Parameter/result registers
243
244 The vector register V0 holds scalar B0, H0, S0 and D0 in its least
245 significant bits. Unlike AArch32 S1 is not packed into D0,
246 etc. */
247
248/* Note that we don't mark X30 as a call-clobbered register. The idea is
249 that it's really the call instructions themselves which clobber X30.
250 We don't care what the called function does with it afterwards.
251
252 This approach makes it easier to implement sibcalls. Unlike normal
253 calls, sibcalls don't clobber X30, so the register reaches the
254 called function intact. EPILOGUE_USES says that X30 is useful
255 to the called function. */
256
257#define FIXED_REGISTERS \
258 { \
259 0, 0, 0, 0, 0, 0, 0, 0, /* R0 - R7 */ \
260 0, 0, 0, 0, 0, 0, 0, 0, /* R8 - R15 */ \
261 0, 0, 0, 0, 0, 0, 0, 0, /* R16 - R23 */ \
262 0, 0, 0, 0, 0, 1, 0, 1, /* R24 - R30, SP */ \
263 0, 0, 0, 0, 0, 0, 0, 0, /* V0 - V7 */ \
264 0, 0, 0, 0, 0, 0, 0, 0, /* V8 - V15 */ \
265 0, 0, 0, 0, 0, 0, 0, 0, /* V16 - V23 */ \
266 0, 0, 0, 0, 0, 0, 0, 0, /* V24 - V31 */ \
267 1, 1, 1, /* SFP, AP, CC */ \
268 }
269
270#define CALL_USED_REGISTERS \
271 { \
272 1, 1, 1, 1, 1, 1, 1, 1, /* R0 - R7 */ \
273 1, 1, 1, 1, 1, 1, 1, 1, /* R8 - R15 */ \
274 1, 1, 1, 0, 0, 0, 0, 0, /* R16 - R23 */ \
275 0, 0, 0, 0, 0, 1, 0, 1, /* R24 - R30, SP */ \
276 1, 1, 1, 1, 1, 1, 1, 1, /* V0 - V7 */ \
277 0, 0, 0, 0, 0, 0, 0, 0, /* V8 - V15 */ \
278 1, 1, 1, 1, 1, 1, 1, 1, /* V16 - V23 */ \
279 1, 1, 1, 1, 1, 1, 1, 1, /* V24 - V31 */ \
280 1, 1, 1, /* SFP, AP, CC */ \
281 }
282
283#define REGISTER_NAMES \
284 { \
285 "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", \
286 "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15", \
287 "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23", \
288 "x24", "x25", "x26", "x27", "x28", "x29", "x30", "sp", \
289 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", \
290 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", \
291 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", \
292 "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", \
293 "sfp", "ap", "cc", \
294 }
295
296/* Generate the register aliases for core register N */
297#define R_ALIASES(N) {"r" # N, R0_REGNUM + (N)}, \
298 {"w" # N, R0_REGNUM + (N)}
299
300#define V_ALIASES(N) {"q" # N, V0_REGNUM + (N)}, \
301 {"d" # N, V0_REGNUM + (N)}, \
302 {"s" # N, V0_REGNUM + (N)}, \
303 {"h" # N, V0_REGNUM + (N)}, \
304 {"b" # N, V0_REGNUM + (N)}
305
306/* Provide aliases for all of the ISA defined register name forms.
307 These aliases are convenient for use in the clobber lists of inline
308 asm statements. */
309
310#define ADDITIONAL_REGISTER_NAMES \
311 { R_ALIASES(0), R_ALIASES(1), R_ALIASES(2), R_ALIASES(3), \
312 R_ALIASES(4), R_ALIASES(5), R_ALIASES(6), R_ALIASES(7), \
313 R_ALIASES(8), R_ALIASES(9), R_ALIASES(10), R_ALIASES(11), \
314 R_ALIASES(12), R_ALIASES(13), R_ALIASES(14), R_ALIASES(15), \
315 R_ALIASES(16), R_ALIASES(17), R_ALIASES(18), R_ALIASES(19), \
316 R_ALIASES(20), R_ALIASES(21), R_ALIASES(22), R_ALIASES(23), \
317 R_ALIASES(24), R_ALIASES(25), R_ALIASES(26), R_ALIASES(27), \
9259db42 318 R_ALIASES(28), R_ALIASES(29), R_ALIASES(30), {"wsp", R0_REGNUM + 31}, \
43e9d192
IB
319 V_ALIASES(0), V_ALIASES(1), V_ALIASES(2), V_ALIASES(3), \
320 V_ALIASES(4), V_ALIASES(5), V_ALIASES(6), V_ALIASES(7), \
321 V_ALIASES(8), V_ALIASES(9), V_ALIASES(10), V_ALIASES(11), \
322 V_ALIASES(12), V_ALIASES(13), V_ALIASES(14), V_ALIASES(15), \
323 V_ALIASES(16), V_ALIASES(17), V_ALIASES(18), V_ALIASES(19), \
324 V_ALIASES(20), V_ALIASES(21), V_ALIASES(22), V_ALIASES(23), \
325 V_ALIASES(24), V_ALIASES(25), V_ALIASES(26), V_ALIASES(27), \
326 V_ALIASES(28), V_ALIASES(29), V_ALIASES(30), V_ALIASES(31) \
327 }
328
329/* Say that the epilogue uses the return address register. Note that
330 in the case of sibcalls, the values "used by the epilogue" are
331 considered live at the start of the called function. */
332
333#define EPILOGUE_USES(REGNO) \
334 ((REGNO) == LR_REGNUM)
335
336/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
337 the stack pointer does not matter. The value is tested only in
338 functions that have frame pointers. */
339#define EXIT_IGNORE_STACK 1
340
341#define STATIC_CHAIN_REGNUM R18_REGNUM
342#define HARD_FRAME_POINTER_REGNUM R29_REGNUM
343#define FRAME_POINTER_REGNUM SFP_REGNUM
344#define STACK_POINTER_REGNUM SP_REGNUM
345#define ARG_POINTER_REGNUM AP_REGNUM
346#define FIRST_PSEUDO_REGISTER 67
347
348/* The number of (integer) argument register available. */
349#define NUM_ARG_REGS 8
350#define NUM_FP_ARG_REGS 8
351
352/* A Homogeneous Floating-Point or Short-Vector Aggregate may have at most
353 four members. */
354#define HA_MAX_NUM_FLDS 4
355
356/* External dwarf register number scheme. These number are used to
357 identify registers in dwarf debug information, the values are
358 defined by the AArch64 ABI. The numbering scheme is independent of
359 GCC's internal register numbering scheme. */
360
361#define AARCH64_DWARF_R0 0
362
363/* The number of R registers, note 31! not 32. */
364#define AARCH64_DWARF_NUMBER_R 31
365
366#define AARCH64_DWARF_SP 31
367#define AARCH64_DWARF_V0 64
368
369/* The number of V registers. */
370#define AARCH64_DWARF_NUMBER_V 32
371
372/* For signal frames we need to use an alternative return column. This
373 value must not correspond to a hard register and must be out of the
374 range of DWARF_FRAME_REGNUM(). */
375#define DWARF_ALT_FRAME_RETURN_COLUMN \
376 (AARCH64_DWARF_V0 + AARCH64_DWARF_NUMBER_V)
377
378/* We add 1 extra frame register for use as the
379 DWARF_ALT_FRAME_RETURN_COLUMN. */
380#define DWARF_FRAME_REGISTERS (DWARF_ALT_FRAME_RETURN_COLUMN + 1)
381
382
383#define DBX_REGISTER_NUMBER(REGNO) aarch64_dbx_register_number (REGNO)
384/* Provide a definition of DWARF_FRAME_REGNUM here so that fallback unwinders
385 can use DWARF_ALT_FRAME_RETURN_COLUMN defined below. This is just the same
386 as the default definition in dwarf2out.c. */
387#undef DWARF_FRAME_REGNUM
388#define DWARF_FRAME_REGNUM(REGNO) DBX_REGISTER_NUMBER (REGNO)
389
390#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (LR_REGNUM)
391
392#define HARD_REGNO_NREGS(REGNO, MODE) aarch64_hard_regno_nregs (REGNO, MODE)
393
394#define HARD_REGNO_MODE_OK(REGNO, MODE) aarch64_hard_regno_mode_ok (REGNO, MODE)
395
97e1ad78 396#define MODES_TIEABLE_P(MODE1, MODE2) aarch64_modes_tieable_p (MODE1, MODE2)
43e9d192
IB
397
398#define DWARF2_UNWIND_INFO 1
399
400/* Use R0 through R3 to pass exception handling information. */
401#define EH_RETURN_DATA_REGNO(N) \
402 ((N) < 4 ? ((unsigned int) R0_REGNUM + (N)) : INVALID_REGNUM)
403
404/* Select a format to encode pointers in exception handling data. */
405#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
406 aarch64_asm_preferred_eh_data_format ((CODE), (GLOBAL))
407
408/* The register that holds the return address in exception handlers. */
409#define AARCH64_EH_STACKADJ_REGNUM (R0_REGNUM + 4)
410#define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, AARCH64_EH_STACKADJ_REGNUM)
411
412/* Don't use __builtin_setjmp until we've defined it. */
413#undef DONT_USE_BUILTIN_SETJMP
414#define DONT_USE_BUILTIN_SETJMP 1
415
416/* Register in which the structure value is to be returned. */
417#define AARCH64_STRUCT_VALUE_REGNUM R8_REGNUM
418
419/* Non-zero if REGNO is part of the Core register set.
420
421 The rather unusual way of expressing this check is to avoid
422 warnings when building the compiler when R0_REGNUM is 0 and REGNO
423 is unsigned. */
424#define GP_REGNUM_P(REGNO) \
425 (((unsigned) (REGNO - R0_REGNUM)) <= (R30_REGNUM - R0_REGNUM))
426
427#define FP_REGNUM_P(REGNO) \
428 (((unsigned) (REGNO - V0_REGNUM)) <= (V31_REGNUM - V0_REGNUM))
429
430#define FP_LO_REGNUM_P(REGNO) \
431 (((unsigned) (REGNO - V0_REGNUM)) <= (V15_REGNUM - V0_REGNUM))
432
433\f
434/* Register and constant classes. */
435
436enum reg_class
437{
438 NO_REGS,
fee9ba42 439 CALLER_SAVE_REGS,
43e9d192
IB
440 GENERAL_REGS,
441 STACK_REG,
442 POINTER_REGS,
443 FP_LO_REGS,
444 FP_REGS,
445 ALL_REGS,
446 LIM_REG_CLASSES /* Last */
447};
448
449#define N_REG_CLASSES ((int) LIM_REG_CLASSES)
450
451#define REG_CLASS_NAMES \
452{ \
453 "NO_REGS", \
fee9ba42 454 "CALLER_SAVE_REGS", \
43e9d192
IB
455 "GENERAL_REGS", \
456 "STACK_REG", \
457 "POINTER_REGS", \
458 "FP_LO_REGS", \
459 "FP_REGS", \
460 "ALL_REGS" \
461}
462
463#define REG_CLASS_CONTENTS \
464{ \
465 { 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \
fee9ba42 466 { 0x0007ffff, 0x00000000, 0x00000000 }, /* CALLER_SAVE_REGS */ \
43e9d192
IB
467 { 0x7fffffff, 0x00000000, 0x00000003 }, /* GENERAL_REGS */ \
468 { 0x80000000, 0x00000000, 0x00000000 }, /* STACK_REG */ \
469 { 0xffffffff, 0x00000000, 0x00000003 }, /* POINTER_REGS */ \
470 { 0x00000000, 0x0000ffff, 0x00000000 }, /* FP_LO_REGS */ \
471 { 0x00000000, 0xffffffff, 0x00000000 }, /* FP_REGS */ \
472 { 0xffffffff, 0xffffffff, 0x00000007 } /* ALL_REGS */ \
473}
474
475#define REGNO_REG_CLASS(REGNO) aarch64_regno_regclass (REGNO)
476
a4a182c6 477#define INDEX_REG_CLASS GENERAL_REGS
43e9d192
IB
478#define BASE_REG_CLASS POINTER_REGS
479
6991c977 480/* Register pairs used to eliminate unneeded registers that point into
43e9d192
IB
481 the stack frame. */
482#define ELIMINABLE_REGS \
483{ \
484 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
485 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
486 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
487 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
488}
489
490#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
491 (OFFSET) = aarch64_initial_elimination_offset (FROM, TO)
492
493/* CPU/ARCH option handling. */
494#include "config/aarch64/aarch64-opts.h"
495
496enum target_cpus
497{
192ed1dd
JG
498#define AARCH64_CORE(NAME, INTERNAL_IDENT, IDENT, ARCH, FLAGS, COSTS) \
499 TARGET_CPU_##INTERNAL_IDENT,
43e9d192
IB
500#include "aarch64-cores.def"
501#undef AARCH64_CORE
502 TARGET_CPU_generic
503};
504
a3cd0246 505/* If there is no CPU defined at configure, use generic as default. */
43e9d192
IB
506#ifndef TARGET_CPU_DEFAULT
507#define TARGET_CPU_DEFAULT \
a3cd0246 508 (TARGET_CPU_generic | (AARCH64_CPU_DEFAULT_FLAGS << 6))
43e9d192
IB
509#endif
510
75cf1494
KT
511/* If inserting NOP before a mult-accumulate insn remember to adjust the
512 length so that conditional branching code is updated appropriately. */
513#define ADJUST_INSN_LENGTH(insn, length) \
8baff86e
KT
514 do \
515 { \
516 if (aarch64_madd_needs_nop (insn)) \
517 length += 4; \
518 } while (0)
75cf1494
KT
519
520#define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
521 aarch64_final_prescan_insn (INSN); \
522
43e9d192
IB
523/* The processor for which instructions should be scheduled. */
524extern enum aarch64_processor aarch64_tune;
525
526/* RTL generation support. */
527#define INIT_EXPANDERS aarch64_init_expanders ()
528\f
529
530/* Stack layout; function entry, exit and calling. */
531#define STACK_GROWS_DOWNWARD 1
532
6991c977 533#define FRAME_GROWS_DOWNWARD 1
43e9d192
IB
534
535#define STARTING_FRAME_OFFSET 0
536
537#define ACCUMULATE_OUTGOING_ARGS 1
538
539#define FIRST_PARM_OFFSET(FNDECL) 0
540
541/* Fix for VFP */
542#define LIBCALL_VALUE(MODE) \
543 gen_rtx_REG (MODE, FLOAT_MODE_P (MODE) ? V0_REGNUM : R0_REGNUM)
544
545#define DEFAULT_PCC_STRUCT_RETURN 0
546
547#define AARCH64_ROUND_UP(X, ALIGNMENT) \
548 (((X) + ((ALIGNMENT) - 1)) & ~((ALIGNMENT) - 1))
549
550#define AARCH64_ROUND_DOWN(X, ALIGNMENT) \
551 ((X) & ~((ALIGNMENT) - 1))
552
553#ifdef HOST_WIDE_INT
554struct GTY (()) aarch64_frame
555{
556 HOST_WIDE_INT reg_offset[FIRST_PSEUDO_REGISTER];
8799637a
MS
557
558 /* The number of extra stack bytes taken up by register varargs.
559 This area is allocated by the callee at the very top of the
560 frame. This value is rounded up to a multiple of
561 STACK_BOUNDARY. */
562 HOST_WIDE_INT saved_varargs_size;
563
43e9d192
IB
564 HOST_WIDE_INT saved_regs_size;
565 /* Padding if needed after the all the callee save registers have
566 been saved. */
567 HOST_WIDE_INT padding0;
568 HOST_WIDE_INT hardfp_offset; /* HARD_FRAME_POINTER_REGNUM */
43e9d192 569
1c960e02
MS
570 /* Offset from the base of the frame (incomming SP) to the
571 hard_frame_pointer. This value is always a multiple of
572 STACK_BOUNDARY. */
573 HOST_WIDE_INT hard_fp_offset;
574
575 /* The size of the frame. This value is the offset from base of the
576 * frame (incomming SP) to the stack_pointer. This value is always
577 * a multiple of STACK_BOUNDARY. */
578
363ffa50
JW
579 unsigned wb_candidate1;
580 unsigned wb_candidate2;
581
1c960e02
MS
582 HOST_WIDE_INT frame_size;
583
43e9d192
IB
584 bool laid_out;
585};
586
587typedef struct GTY (()) machine_function
588{
589 struct aarch64_frame frame;
43e9d192
IB
590} machine_function;
591#endif
592
17a819cb
YZ
593/* Which ABI to use. */
594enum aarch64_abi_type
595{
596 AARCH64_ABI_LP64 = 0,
597 AARCH64_ABI_ILP32 = 1
598};
599
600#ifndef AARCH64_ABI_DEFAULT
601#define AARCH64_ABI_DEFAULT AARCH64_ABI_LP64
602#endif
603
604#define TARGET_ILP32 (aarch64_abi & AARCH64_ABI_ILP32)
43e9d192 605
43e9d192
IB
606enum arm_pcs
607{
608 ARM_PCS_AAPCS64, /* Base standard AAPCS for 64 bit. */
609 ARM_PCS_UNKNOWN
610};
611
612
43e9d192 613
43e9d192 614
ef4bddc2 615/* We can't use machine_mode inside a generator file because it
43e9d192
IB
616 hasn't been created yet; we shouldn't be using any code that
617 needs the real definition though, so this ought to be safe. */
618#ifdef GENERATOR_FILE
619#define MACHMODE int
620#else
621#include "insn-modes.h"
86fea2cb 622#define MACHMODE enum machine_mode
43e9d192
IB
623#endif
624
625
626/* AAPCS related state tracking. */
627typedef struct
628{
629 enum arm_pcs pcs_variant;
630 int aapcs_arg_processed; /* No need to lay out this argument again. */
631 int aapcs_ncrn; /* Next Core register number. */
632 int aapcs_nextncrn; /* Next next core register number. */
633 int aapcs_nvrn; /* Next Vector register number. */
634 int aapcs_nextnvrn; /* Next Next Vector register number. */
635 rtx aapcs_reg; /* Register assigned to this argument. This
636 is NULL_RTX if this parameter goes on
637 the stack. */
638 MACHMODE aapcs_vfp_rmode;
639 int aapcs_stack_words; /* If the argument is passed on the stack, this
640 is the number of words needed, after rounding
641 up. Only meaningful when
642 aapcs_reg == NULL_RTX. */
643 int aapcs_stack_size; /* The total size (in words, per 8 byte) of the
644 stack arg area so far. */
645} CUMULATIVE_ARGS;
646
647#define FUNCTION_ARG_PADDING(MODE, TYPE) \
648 (aarch64_pad_arg_upward (MODE, TYPE) ? upward : downward)
649
650#define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
651 (aarch64_pad_reg_upward (MODE, TYPE, FIRST) ? upward : downward)
652
653#define PAD_VARARGS_DOWN 0
654
655#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
656 aarch64_init_cumulative_args (&(CUM), FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS)
657
658#define FUNCTION_ARG_REGNO_P(REGNO) \
659 aarch64_function_arg_regno_p(REGNO)
660\f
661
662/* ISA Features. */
663
664/* Addressing modes, etc. */
665#define HAVE_POST_INCREMENT 1
666#define HAVE_PRE_INCREMENT 1
667#define HAVE_POST_DECREMENT 1
668#define HAVE_PRE_DECREMENT 1
669#define HAVE_POST_MODIFY_DISP 1
670#define HAVE_PRE_MODIFY_DISP 1
671
672#define MAX_REGS_PER_ADDRESS 2
673
674#define CONSTANT_ADDRESS_P(X) aarch64_constant_address_p(X)
675
676/* Try a machine-dependent way of reloading an illegitimate address
677 operand. If we find one, push the reload and jump to WIN. This
678 macro is used in only one place: `find_reloads_address' in reload.c. */
679
680#define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_L, WIN) \
681do { \
682 rtx new_x = aarch64_legitimize_reload_address (&(X), MODE, OPNUM, TYPE, \
683 IND_L); \
684 if (new_x) \
685 { \
686 X = new_x; \
687 goto WIN; \
688 } \
689} while (0)
690
691#define REGNO_OK_FOR_BASE_P(REGNO) \
692 aarch64_regno_ok_for_base_p (REGNO, true)
693
694#define REGNO_OK_FOR_INDEX_P(REGNO) \
695 aarch64_regno_ok_for_index_p (REGNO, true)
696
697#define LEGITIMATE_PIC_OPERAND_P(X) \
698 aarch64_legitimate_pic_operand_p (X)
699
700#define CASE_VECTOR_MODE Pmode
701
702#define DEFAULT_SIGNED_CHAR 0
703
704/* An integer expression for the size in bits of the largest integer machine
705 mode that should actually be used. We allow pairs of registers. */
706#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TImode)
707
708/* Maximum bytes moved by a single instruction (load/store pair). */
709#define MOVE_MAX (UNITS_PER_WORD * 2)
710
711/* The base cost overhead of a memcpy call, for MOVE_RATIO and friends. */
712#define AARCH64_CALL_RATIO 8
713
e2c75eea
JG
714/* MOVE_RATIO dictates when we will use the move_by_pieces infrastructure.
715 move_by_pieces will continually copy the largest safe chunks. So a
716 7-byte copy is a 4-byte + 2-byte + byte copy. This proves inefficient
717 for both size and speed of copy, so we will instead use the "movmem"
718 standard name to implement the copy. This logic does not apply when
719 targeting -mstrict-align, so keep a sensible default in that case. */
43e9d192 720#define MOVE_RATIO(speed) \
e2c75eea 721 (!STRICT_ALIGNMENT ? 2 : (((speed) ? 15 : AARCH64_CALL_RATIO) / 2))
43e9d192
IB
722
723/* For CLEAR_RATIO, when optimizing for size, give a better estimate
724 of the length of a memset call, but use the default otherwise. */
725#define CLEAR_RATIO(speed) \
726 ((speed) ? 15 : AARCH64_CALL_RATIO)
727
728/* SET_RATIO is similar to CLEAR_RATIO, but for a non-zero constant, so when
729 optimizing for size adjust the ratio to account for the overhead of loading
730 the constant. */
731#define SET_RATIO(speed) \
732 ((speed) ? 15 : AARCH64_CALL_RATIO - 2)
733
43e9d192
IB
734/* Disable auto-increment in move_by_pieces et al. Use of auto-increment is
735 rarely a good idea in straight-line code since it adds an extra address
736 dependency between each instruction. Better to use incrementing offsets. */
737#define USE_LOAD_POST_INCREMENT(MODE) 0
738#define USE_LOAD_POST_DECREMENT(MODE) 0
739#define USE_LOAD_PRE_INCREMENT(MODE) 0
740#define USE_LOAD_PRE_DECREMENT(MODE) 0
741#define USE_STORE_POST_INCREMENT(MODE) 0
742#define USE_STORE_POST_DECREMENT(MODE) 0
743#define USE_STORE_PRE_INCREMENT(MODE) 0
744#define USE_STORE_PRE_DECREMENT(MODE) 0
745
746/* ?? #define WORD_REGISTER_OPERATIONS */
747
748/* Define if loading from memory in MODE, an integral mode narrower than
749 BITS_PER_WORD will either zero-extend or sign-extend. The value of this
750 macro should be the code that says which one of the two operations is
751 implicitly done, or UNKNOWN if none. */
752#define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
753
754/* Define this macro to be non-zero if instructions will fail to work
755 if given data not on the nominal alignment. */
756#define STRICT_ALIGNMENT TARGET_STRICT_ALIGN
757
758/* Define this macro to be non-zero if accessing less than a word of
759 memory is no faster than accessing a word of memory, i.e., if such
760 accesses require more than one instruction or if there is no
761 difference in cost.
762 Although there's no difference in instruction count or cycles,
763 in AArch64 we don't want to expand to a sub-word to a 64-bit access
764 if we don't have to, for power-saving reasons. */
765#define SLOW_BYTE_ACCESS 0
766
767#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
768
769#define NO_FUNCTION_CSE 1
770
17a819cb
YZ
771/* Specify the machine mode that the hardware addresses have.
772 After generation of rtl, the compiler makes no further distinction
773 between pointers and any other objects of this machine mode. */
43e9d192 774#define Pmode DImode
17a819cb
YZ
775
776/* A C expression whose value is zero if pointers that need to be extended
777 from being `POINTER_SIZE' bits wide to `Pmode' are sign-extended and
778 greater then zero if they are zero-extended and less then zero if the
779 ptr_extend instruction should be used. */
780#define POINTERS_EXTEND_UNSIGNED 1
781
782/* Mode of a function address in a call instruction (for indexing purposes). */
43e9d192
IB
783#define FUNCTION_MODE Pmode
784
785#define SELECT_CC_MODE(OP, X, Y) aarch64_select_cc_mode (OP, X, Y)
786
f8bf91ab
N
787#define REVERSIBLE_CC_MODE(MODE) 1
788
43e9d192
IB
789#define REVERSE_CONDITION(CODE, MODE) \
790 (((MODE) == CCFPmode || (MODE) == CCFPEmode) \
791 ? reverse_condition_maybe_unordered (CODE) \
792 : reverse_condition (CODE))
793
794#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
0fe04f5c 795 ((VALUE) = GET_MODE_UNIT_BITSIZE (MODE))
43e9d192
IB
796#define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
797 ((VALUE) = ((MODE) == SImode ? 32 : 64), 2)
798
799#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LR_REGNUM)
800
801#define RETURN_ADDR_RTX aarch64_return_addr
802
28514dda
YZ
803/* 3 insns + padding + 2 pointer-sized entries. */
804#define TRAMPOLINE_SIZE (TARGET_ILP32 ? 24 : 32)
43e9d192
IB
805
806/* Trampolines contain dwords, so must be dword aligned. */
807#define TRAMPOLINE_ALIGNMENT 64
808
809/* Put trampolines in the text section so that mapping symbols work
810 correctly. */
811#define TRAMPOLINE_SECTION text_section
43e9d192
IB
812
813/* To start with. */
814#define BRANCH_COST(SPEED_P, PREDICTABLE_P) 2
815\f
816
817/* Assembly output. */
818
819/* For now we'll make all jump tables pc-relative. */
820#define CASE_VECTOR_PC_RELATIVE 1
821
822#define CASE_VECTOR_SHORTEN_MODE(min, max, body) \
823 ((min < -0x1fff0 || max > 0x1fff0) ? SImode \
824 : (min < -0x1f0 || max > 0x1f0) ? HImode \
825 : QImode)
826
827/* Jump table alignment is explicit in ASM_OUTPUT_CASE_LABEL. */
828#define ADDR_VEC_ALIGN(JUMPTABLE) 0
829
830#define PRINT_OPERAND(STREAM, X, CODE) aarch64_print_operand (STREAM, X, CODE)
831
832#define PRINT_OPERAND_ADDRESS(STREAM, X) \
833 aarch64_print_operand_address (STREAM, X)
834
92d649c4
VK
835#define MCOUNT_NAME "_mcount"
836
837#define NO_PROFILE_COUNTERS 1
838
839/* Emit rtl for profiling. Output assembler code to FILE
840 to call "_mcount" for profiling a function entry. */
3294102b
MS
841#define PROFILE_HOOK(LABEL) \
842 { \
843 rtx fun, lr; \
844 lr = get_hard_reg_initial_val (Pmode, LR_REGNUM); \
845 fun = gen_rtx_SYMBOL_REF (Pmode, MCOUNT_NAME); \
846 emit_library_call (fun, LCT_NORMAL, VOIDmode, 1, lr, Pmode); \
847 }
92d649c4
VK
848
849/* All the work done in PROFILE_HOOK, but still required. */
850#define FUNCTION_PROFILER(STREAM, LABELNO) do { } while (0)
43e9d192
IB
851
852/* For some reason, the Linux headers think they know how to define
853 these macros. They don't!!! */
854#undef ASM_APP_ON
855#undef ASM_APP_OFF
856#define ASM_APP_ON "\t" ASM_COMMENT_START " Start of user assembly\n"
857#define ASM_APP_OFF "\t" ASM_COMMENT_START " End of user assembly\n"
858
43e9d192
IB
859#define CONSTANT_POOL_BEFORE_FUNCTION 0
860
861/* This definition should be relocated to aarch64-elf-raw.h. This macro
862 should be undefined in aarch64-linux.h and a clear_cache pattern
863 implmented to emit either the call to __aarch64_sync_cache_range()
864 directly or preferably the appropriate sycall or cache clear
865 instructions inline. */
866#define CLEAR_INSN_CACHE(beg, end) \
867 extern void __aarch64_sync_cache_range (void *, void *); \
868 __aarch64_sync_cache_range (beg, end)
869
43e9d192 870#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
69675d50 871 aarch64_cannot_change_mode_class (FROM, TO, CLASS)
43e9d192
IB
872
873#define SHIFT_COUNT_TRUNCATED !TARGET_SIMD
874
73d9ac6a
IB
875/* Choose appropriate mode for caller saves, so we do the minimum
876 required size of load/store. */
877#define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE) \
878 aarch64_hard_regno_caller_save_mode ((REGNO), (NREGS), (MODE))
879
43e9d192
IB
880/* Callee only saves lower 64-bits of a 128-bit register. Tell the
881 compiler the callee clobbers the top 64-bits when restoring the
882 bottom 64-bits. */
883#define HARD_REGNO_CALL_PART_CLOBBERED(REGNO, MODE) \
884 (FP_REGNUM_P (REGNO) && GET_MODE_SIZE (MODE) > 8)
885
886/* Check TLS Descriptors mechanism is selected. */
887#define TARGET_TLS_DESC (aarch64_tls_dialect == TLS_DESCRIPTORS)
888
889extern enum aarch64_code_model aarch64_cmodel;
890
891/* When using the tiny addressing model conditional and unconditional branches
892 can span the whole of the available address space (1MB). */
893#define HAS_LONG_COND_BRANCH \
894 (aarch64_cmodel == AARCH64_CMODEL_TINY \
895 || aarch64_cmodel == AARCH64_CMODEL_TINY_PIC)
896
897#define HAS_LONG_UNCOND_BRANCH \
898 (aarch64_cmodel == AARCH64_CMODEL_TINY \
899 || aarch64_cmodel == AARCH64_CMODEL_TINY_PIC)
900
901/* Modes valid for AdvSIMD Q registers. */
902#define AARCH64_VALID_SIMD_QREG_MODE(MODE) \
903 ((MODE) == V4SImode || (MODE) == V8HImode || (MODE) == V16QImode \
904 || (MODE) == V4SFmode || (MODE) == V2DImode || mode == V2DFmode)
905
e58bf20a
TB
906#define ENDIAN_LANE_N(mode, n) \
907 (BYTES_BIG_ENDIAN ? GET_MODE_NUNITS (mode) - 1 - n : n)
908
9815fafa
RE
909/* Support for a configure-time default CPU, etc. We currently support
910 --with-arch and --with-cpu. Both are ignored if either is specified
911 explicitly on the command line at run time. */
912#define OPTION_DEFAULT_SPECS \
913 {"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" }, \
914 {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" },
915
682287fb 916#define BIG_LITTLE_SPEC \
1c05df59 917 " %{mcpu=*:-mcpu=%:rewrite_mcpu(%{mcpu=*:%*})}"
682287fb
JG
918
919extern const char *aarch64_rewrite_mcpu (int argc, const char **argv);
920#define BIG_LITTLE_CPU_SPEC_FUNCTIONS \
921 { "rewrite_mcpu", aarch64_rewrite_mcpu },
922
923#define ASM_CPU_SPEC \
924 BIG_LITTLE_SPEC
925
926#define EXTRA_SPEC_FUNCTIONS BIG_LITTLE_CPU_SPEC_FUNCTIONS
927
928#define EXTRA_SPECS \
929 { "asm_cpu_spec", ASM_CPU_SPEC }
930
43e9d192 931#endif /* GCC_AARCH64_H */