]>
Commit | Line | Data |
---|---|---|
b80a3db0 | 1 | /* Assembly macros for 32-bit PowerPC. |
d614a753 | 2 | Copyright (C) 1999-2020 Free Software Foundation, Inc. |
b80a3db0 RM |
3 | This file is part of the GNU C Library. |
4 | ||
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 | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
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. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
b80a3db0 | 18 | |
b80a3db0 RM |
19 | #include <sysdeps/powerpc/sysdep.h> |
20 | ||
ffdd5e50 UD |
21 | #ifdef __ASSEMBLER__ |
22 | ||
b80a3db0 RM |
23 | /* If compiled for profiling, call `_mcount' at the start of each |
24 | function. */ | |
25 | #ifdef PROF | |
26 | /* The mcount code relies on a the return address being on the stack | |
27 | to locate our caller and so it can restore it; so store one just | |
28 | for its benefit. */ | |
99c7f870 | 29 | # define CALL_MCOUNT \ |
a334319f | 30 | mflr r0; \ |
9759bbf1 | 31 | stw r0,4(r1); \ |
b67e9372 | 32 | cfi_offset (lr, 4); \ |
a334319f | 33 | bl JUMPTARGET(_mcount); |
b80a3db0 | 34 | #else /* PROF */ |
a592f998 | 35 | # define CALL_MCOUNT /* Do nothing. */ |
b80a3db0 RM |
36 | #endif /* PROF */ |
37 | ||
38 | #define ENTRY(name) \ | |
b67e9372 MP |
39 | .globl C_SYMBOL_NAME(name); \ |
40 | .type C_SYMBOL_NAME(name),@function; \ | |
b80a3db0 RM |
41 | .align ALIGNARG(2); \ |
42 | C_LABEL(name) \ | |
9759bbf1 | 43 | cfi_startproc; \ |
b80a3db0 RM |
44 | CALL_MCOUNT |
45 | ||
d5b41185 AM |
46 | #define ENTRY_TOCLESS(name) ENTRY(name) |
47 | ||
91d2a845 WS |
48 | /* helper macro for accessing the 32-bit powerpc GOT. */ |
49 | ||
b67e9372 | 50 | #define SETUP_GOT_ACCESS(regname,GOT_LABEL) \ |
91d2a845 WS |
51 | bcl 20,31,GOT_LABEL ; \ |
52 | GOT_LABEL: ; \ | |
53 | mflr (regname) | |
54 | ||
b80a3db0 RM |
55 | #define EALIGN_W_0 /* No words to insert. */ |
56 | #define EALIGN_W_1 nop | |
57 | #define EALIGN_W_2 nop;nop | |
58 | #define EALIGN_W_3 nop;nop;nop | |
59 | #define EALIGN_W_4 EALIGN_W_3;nop | |
60 | #define EALIGN_W_5 EALIGN_W_4;nop | |
61 | #define EALIGN_W_6 EALIGN_W_5;nop | |
62 | #define EALIGN_W_7 EALIGN_W_6;nop | |
63 | ||
64 | /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes | |
65 | past a 2^align boundary. */ | |
66 | #ifdef PROF | |
a592f998 | 67 | # define EALIGN(name, alignt, words) \ |
b67e9372 MP |
68 | .globl C_SYMBOL_NAME(name); \ |
69 | .type C_SYMBOL_NAME(name),@function; \ | |
b80a3db0 RM |
70 | .align ALIGNARG(2); \ |
71 | C_LABEL(name) \ | |
9759bbf1 | 72 | cfi_startproc; \ |
b80a3db0 RM |
73 | CALL_MCOUNT \ |
74 | b 0f; \ | |
75 | .align ALIGNARG(alignt); \ | |
76 | EALIGN_W_##words; \ | |
77 | 0: | |
78 | #else /* PROF */ | |
a592f998 | 79 | # define EALIGN(name, alignt, words) \ |
b67e9372 MP |
80 | .globl C_SYMBOL_NAME(name); \ |
81 | .type C_SYMBOL_NAME(name),@function; \ | |
b80a3db0 RM |
82 | .align ALIGNARG(alignt); \ |
83 | EALIGN_W_##words; \ | |
9759bbf1 UD |
84 | C_LABEL(name) \ |
85 | cfi_startproc; | |
b80a3db0 RM |
86 | #endif |
87 | ||
88 | #undef END | |
89 | #define END(name) \ | |
9759bbf1 | 90 | cfi_endproc; \ |
b80a3db0 RM |
91 | ASM_SIZE_DIRECTIVE(name) |
92 | ||
b67e9372 | 93 | #define DO_CALL(syscall) \ |
929d11c7 | 94 | li 0,syscall; \ |
b80a3db0 RM |
95 | sc |
96 | ||
29d9a17d | 97 | #undef JUMPTARGET |
b80a3db0 | 98 | #ifdef PIC |
a592f998 | 99 | # define JUMPTARGET(name) name##@plt |
b80a3db0 | 100 | #else |
a592f998 UD |
101 | # define JUMPTARGET(name) name |
102 | #endif | |
103 | ||
3f2e46a4 | 104 | #if defined SHARED && defined PIC && !defined NO_HIDDEN |
a592f998 UD |
105 | # undef HIDDEN_JUMPTARGET |
106 | # define HIDDEN_JUMPTARGET(name) __GI_##name##@local | |
b80a3db0 RM |
107 | #endif |
108 | ||
109 | #define PSEUDO(name, syscall_name, args) \ | |
110 | .section ".text"; \ | |
111 | ENTRY (name) \ | |
112 | DO_CALL (SYS_ify (syscall_name)); | |
113 | ||
114 | #define PSEUDO_RET \ | |
52f3d213 | 115 | bnslr+; \ |
b0e196a4 | 116 | b __syscall_error@local |
b80a3db0 RM |
117 | #define ret PSEUDO_RET |
118 | ||
119 | #undef PSEUDO_END | |
120 | #define PSEUDO_END(name) \ | |
121 | END (name) | |
122 | ||
9eb88290 UD |
123 | #define PSEUDO_NOERRNO(name, syscall_name, args) \ |
124 | .section ".text"; \ | |
125 | ENTRY (name) \ | |
126 | DO_CALL (SYS_ify (syscall_name)); | |
127 | ||
128 | #define PSEUDO_RET_NOERRNO \ | |
129 | blr | |
130 | #define ret_NOERRNO PSEUDO_RET_NOERRNO | |
131 | ||
132 | #undef PSEUDO_END_NOERRNO | |
133 | #define PSEUDO_END_NOERRNO(name) \ | |
134 | END (name) | |
135 | ||
137ffcdc UD |
136 | #define PSEUDO_ERRVAL(name, syscall_name, args) \ |
137 | .section ".text"; \ | |
138 | ENTRY (name) \ | |
139 | DO_CALL (SYS_ify (syscall_name)); | |
140 | ||
141 | #define PSEUDO_RET_ERRVAL \ | |
142 | blr | |
143 | #define ret_ERRVAL PSEUDO_RET_ERRVAL | |
144 | ||
145 | #undef PSEUDO_END_ERRVAL | |
146 | #define PSEUDO_END_ERRVAL(name) \ | |
147 | END (name) | |
148 | ||
b80a3db0 RM |
149 | /* Local labels stripped out by the linker. */ |
150 | #undef L | |
151 | #define L(x) .L##x | |
152 | ||
929d11c7 WS |
153 | #define XGLUE(a,b) a##b |
154 | #define GLUE(a,b) XGLUE (a,b) | |
155 | #define GENERATE_GOT_LABEL(name) GLUE (.got_label, name) | |
156 | ||
b80a3db0 RM |
157 | /* Label in text section. */ |
158 | #define C_TEXT(name) name | |
159 | ||
b80a3db0 | 160 | #endif /* __ASSEMBLER__ */ |