1 /* Copyright (C) 1997-2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _AARCH64_SYSDEP_H
20 #define _AARCH64_SYSDEP_H
22 #include <sysdeps/generic/sysdep.h>
25 # define AARCH64_R(NAME) R_AARCH64_ ## NAME
26 # define PTR_REG(n) x##n
27 # define PTR_LOG_SIZE 3
30 # define AARCH64_R(NAME) R_AARCH64_P32_ ## NAME
31 # define PTR_REG(n) w##n
32 # define PTR_LOG_SIZE 2
33 # define DELOUSE(n) mov w##n, w##n
36 #define PTR_SIZE (1<<PTR_LOG_SIZE)
40 /* Syntactic details of assembler. */
42 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
44 /* Define an entry point visible from C. */
46 .globl C_SYMBOL_NAME(name); \
47 .type C_SYMBOL_NAME(name),%function; \
53 /* Define an entry point visible from C. */
54 #define ENTRY_ALIGN(name, align) \
55 .globl C_SYMBOL_NAME(name); \
56 .type C_SYMBOL_NAME(name),%function; \
62 /* Define an entry point visible from C with a specified alignment and
63 pre-padding with NOPs. This can be used to ensure that a critical
64 loop within a function is cache line aligned. Note this version
65 does not adjust the padding if CALL_MCOUNT is defined. */
67 #define ENTRY_ALIGN_AND_PAD(name, align, padding) \
68 .globl C_SYMBOL_NAME(name); \
69 .type C_SYMBOL_NAME(name),%function; \
81 ASM_SIZE_DIRECTIVE(name)
83 /* If compiled for profiling, call `mcount' at the start of each function. */
85 # define CALL_MCOUNT \
86 str x30, [sp, #-80]!; \
87 cfi_adjust_cfa_offset (80); \
88 cfi_rel_offset (x30, 0); \
89 stp x0, x1, [sp, #16]; \
90 cfi_rel_offset (x0, 16); \
91 cfi_rel_offset (x1, 24); \
92 stp x2, x3, [sp, #32]; \
93 cfi_rel_offset (x2, 32); \
94 cfi_rel_offset (x3, 40); \
95 stp x4, x5, [sp, #48]; \
96 cfi_rel_offset (x4, 48); \
97 cfi_rel_offset (x5, 56); \
98 stp x6, x7, [sp, #64]; \
99 cfi_rel_offset (x6, 64); \
100 cfi_rel_offset (x7, 72); \
103 ldp x0, x1, [sp, #16]; \
106 ldp x2, x3, [sp, #32]; \
109 ldp x4, x5, [sp, #48]; \
112 ldp x6, x7, [sp, #64]; \
115 ldr x30, [sp], #80; \
116 cfi_adjust_cfa_offset (-80); \
119 # define CALL_MCOUNT /* Do nothing. */
122 /* Local label name for asm code. */
124 # define L(name) .L##name
127 /* Load or store to/from a pc-relative EXPR into/from R, using T.
128 Note R and T are register numbers and not register names. */
129 #define LDST_PCREL(OP, R, T, EXPR) \
131 OP PTR_REG (R), [x##T, #:lo12:EXPR]; \
133 /* Load or store to/from a got-relative EXPR into/from R, using T.
134 Note R and T are register numbers and not register names. */
135 #define LDST_GLOBAL(OP, R, T, EXPR) \
136 adrp x##T, :got:EXPR; \
137 ldr PTR_REG (T), [x##T, #:got_lo12:EXPR]; \
138 OP PTR_REG (R), [x##T];
140 /* Load an immediate into R.
141 Note R is a register number and not a register name. */
143 # define MOVL(R, NAME) \
144 movz PTR_REG (R), #:abs_g3:NAME; \
145 movk PTR_REG (R), #:abs_g2_nc:NAME; \
146 movk PTR_REG (R), #:abs_g1_nc:NAME; \
147 movk PTR_REG (R), #:abs_g0_nc:NAME;
149 # define MOVL(R, NAME) \
150 movz PTR_REG (R), #:abs_g1:NAME; \
151 movk PTR_REG (R), #:abs_g0_nc:NAME;
154 /* Since C identifiers are not normally prefixed with an underscore
155 on this system, the asm identifier `syscall_error' intrudes on the
156 C name space. Make sure we use an innocuous name. */
157 #define syscall_error __syscall_error
158 #define mcount _mcount
160 #endif /* __ASSEMBLER__ */
162 #endif /* _AARCH64_SYSDEP_H */