]>
Commit | Line | Data |
---|---|---|
b80a3db0 | 1 | /* Assembly macros for 64-bit PowerPC. |
29d9a17d | 2 | Copyright (C) 2002, 2003 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 | |
16 | License along with the GNU C Library; if not, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
19 | ||
20 | #ifdef __ASSEMBLER__ | |
21 | ||
22 | #include <sysdeps/powerpc/sysdep.h> | |
23 | ||
24 | #ifdef __ELF__ | |
25 | /* If compiled for profiling, call `_mcount' at the start of each function. | |
26 | see ppc-mcount.S for more details. */ | |
27 | #ifdef PROF | |
28 | /* The mcount code relies on a the return address being on the stack | |
29 | to locate our caller and so it can restore it; so store one just | |
30 | for its benefit. */ | |
31 | #ifdef PIC | |
32 | #ifdef SYSV_ELF_PROFILING | |
33 | #define CALL_MCOUNT \ | |
34 | .pushsection; \ | |
35 | .section ".data"; \ | |
36 | .align ALIGNARG(2); \ | |
2ce1a10f UD |
37 | __mcount: \ |
38 | .long 0; \ | |
39 | .previous; \ | |
40 | .section ".toc","aw"; \ | |
41 | .LC__mcount:; \ | |
42 | .tc __mcount[TC],__mcount; \ | |
b80a3db0 RM |
43 | .previous; \ |
44 | mflr r0; \ | |
45 | std r0,16(r1); \ | |
2ce1a10f | 46 | ld r0,.LC__mcount@toc(r2); \ |
b80a3db0 RM |
47 | bl JUMPTARGET(_mcount); |
48 | #else /* SYSV_ELF_PROFILING */ | |
49 | #define CALL_MCOUNT \ | |
50 | mflr r0; \ | |
51 | std r0,16(r1); \ | |
52 | bl JUMPTARGET(_mcount); | |
53 | #endif /* SYSV_ELF_PROFILING */ | |
54 | #else /* PIC */ | |
55 | #ifdef SYSV_ELF_PROFILING | |
56 | #define CALL_MCOUNT \ | |
57 | .pushsection; \ | |
58 | .section ".data"; \ | |
59 | .align ALIGNARG(2); \ | |
2ce1a10f UD |
60 | __mcount: \ |
61 | .long 0; \ | |
62 | .previous; \ | |
63 | .section ".toc","aw"; \ | |
64 | .LC__mcount:; \ | |
65 | .tc __mcount[TC],__mcount; \ | |
b80a3db0 RM |
66 | .previous; \ |
67 | mflr r0; \ | |
68 | std r0,16(r1); \ | |
2ce1a10f | 69 | ld r0,.LC__mcount@toc(r2); \ |
b80a3db0 RM |
70 | bl JUMPTARGET(_mcount); |
71 | #else /* SYSV_ELF_PROFILING */ | |
72 | #define CALL_MCOUNT \ | |
73 | mflr r0; \ | |
74 | std r0,16(r1); \ | |
75 | bl JUMPTARGET(_mcount); | |
76 | #endif /* SYSV_ELF_PROFILING */ | |
77 | #endif /* PIC */ | |
78 | #else /* PROF */ | |
79 | #define CALL_MCOUNT /* Do nothing. */ | |
80 | #endif /* PROF */ | |
81 | ||
82 | #define DOT_LABEL(X) .##X | |
83 | ||
84 | #define ENTRY(name) \ | |
85 | .section ".text"; \ | |
86 | .align ALIGNARG(2); \ | |
87 | .globl DOT_LABEL(name); \ | |
88 | .type DOT_LABEL(name),@function ; \ | |
89 | .globl name; \ | |
90 | .section ".opd","aw"; \ | |
91 | name##: ; \ | |
92 | .quad DOT_LABEL(name) ; \ | |
93 | .quad .TOC.@tocbase, 0; \ | |
94 | .previous; \ | |
95 | DOT_LABEL(name): | |
96 | ||
97 | ||
98 | #define EALIGN_W_0 /* No words to insert. */ | |
99 | #define EALIGN_W_1 nop | |
100 | #define EALIGN_W_2 nop;nop | |
101 | #define EALIGN_W_3 nop;nop;nop | |
102 | #define EALIGN_W_4 EALIGN_W_3;nop | |
103 | #define EALIGN_W_5 EALIGN_W_4;nop | |
104 | #define EALIGN_W_6 EALIGN_W_5;nop | |
105 | #define EALIGN_W_7 EALIGN_W_6;nop | |
106 | ||
107 | /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes | |
108 | past a 2^align boundary. */ | |
109 | #ifdef PROF | |
110 | #define EALIGN(name, alignt, words) \ | |
111 | .section ".text"; \ | |
112 | .globl DOT_LABEL(name); \ | |
113 | .type DOT_LABEL(name),@function ; \ | |
114 | .globl name; \ | |
115 | .section ".opd","aw"; \ | |
116 | name##: ; \ | |
117 | .quad DOT_LABEL(name) ; \ | |
118 | .quad .TOC.@tocbase, 0; \ | |
119 | .previous; \ | |
120 | .align ALIGNARG(alignt); \ | |
121 | EALIGN_W_##words; \ | |
122 | DOT_LABEL(name): \ | |
123 | CALL_MCOUNT \ | |
124 | b 0f; \ | |
125 | .align ALIGNARG(alignt); \ | |
126 | EALIGN_W_##words; \ | |
127 | 0: | |
128 | #else /* PROF */ | |
129 | #define EALIGN(name, alignt, words) \ | |
130 | .section ".text"; \ | |
131 | .globl DOT_LABEL(name); \ | |
132 | .type DOT_LABEL(name),@function ; \ | |
133 | .globl name; \ | |
134 | .section ".opd","aw"; \ | |
135 | name##: ; \ | |
136 | .quad DOT_LABEL(name) ; \ | |
137 | .quad .TOC.@tocbase, 0; \ | |
138 | .previous; \ | |
139 | .align ALIGNARG(alignt); \ | |
140 | EALIGN_W_##words; \ | |
141 | DOT_LABEL(name): | |
142 | #endif | |
143 | ||
144 | /* Local labels stripped out by the linker. */ | |
145 | #undef L | |
146 | #define L(x) .L##x | |
147 | ||
148 | #define tostring(s) #s | |
149 | #define stringify(s) tostring(s) | |
150 | #define XGLUE(a,b) a##b | |
151 | #define GLUE(a,b) XGLUE(a,b) | |
152 | #define LT_LABEL(name) GLUE(.LT,name) | |
153 | #define LT_LABELSUFFIX(name,suffix) GLUE(GLUE(.LT,name),suffix) | |
154 | ||
155 | /* Support Traceback tables */ | |
156 | #define TB_ASM 0x000c000000000000 | |
157 | #define TB_GLOBALLINK 0x0000800000000000 | |
158 | #define TB_IS_EPROL 0x0000400000000000 | |
159 | #define TB_HAS_TBOFF 0x0000200000000000 | |
160 | #define TB_INT_PROC 0x0000100000000000 | |
161 | #define TB_HAS_CTL 0x0000080000000000 | |
162 | #define TB_TOCLESS 0x0000040000000000 | |
163 | #define TB_FP_PRESENT 0x0000020000000000 | |
164 | #define TB_LOG_ABORT 0x0000010000000000 | |
165 | #define TB_INT_HANDL 0x0000008000000000 | |
166 | #define TB_NAME_PRESENT 0x0000004000000000 | |
167 | #define TB_USES_ALLOCA 0x0000002000000000 | |
168 | #define TB_SAVES_CR 0x0000000200000000 | |
169 | #define TB_SAVES_LR 0x0000000100000000 | |
170 | #define TB_STORES_BC 0x0000000080000000 | |
171 | #define TB_FIXUP 0x0000000040000000 | |
172 | #define TB_FP_SAVED(fprs) (((fprs) & 0x3f) << 24) | |
173 | #define TB_GPR_SAVED(gprs) (((fprs) & 0x3f) << 16) | |
174 | #define TB_FIXEDPARMS(parms) (((parms) & 0xff) << 8) | |
175 | #define TB_FLOATPARMS(parms) (((parms) & 0x7f) << 1) | |
176 | #define TB_PARMSONSTK 0x0000000000000001 | |
177 | ||
178 | #define PPC_HIGHER(v) (((v) >> 32) & 0xffff) | |
179 | #define TB_DEFAULT TB_ASM | TB_HAS_TBOFF | TB_NAME_PRESENT | |
180 | ||
181 | #define TRACEBACK(name) \ | |
182 | LT_LABEL(name): ; \ | |
183 | .long 0 ; \ | |
184 | .quad TB_DEFAULT ; \ | |
185 | .long LT_LABEL(name)-DOT_LABEL(name) ; \ | |
186 | .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \ | |
187 | LT_LABELSUFFIX(name,_name_start): ;\ | |
188 | .ascii stringify(name) ; \ | |
189 | LT_LABELSUFFIX(name,_name_end): ; \ | |
190 | .align 2 ; | |
191 | ||
192 | #define TRACEBACK_MASK(name,mask) \ | |
193 | LT_LABEL(name): ; \ | |
194 | .long 0 ; \ | |
195 | .quad TB_DEFAULT | mask ; \ | |
196 | .long LT_LABEL(name)-DOT_LABEL(name) ; \ | |
197 | .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \ | |
198 | LT_LABELSUFFIX(name,_name_start): ;\ | |
199 | .ascii stringify(name) ; \ | |
200 | LT_LABELSUFFIX(name,_name_end): ; \ | |
201 | .align 2 ; | |
202 | ||
203 | /* END generates Traceback tables */ | |
204 | #undef END | |
205 | #define END(name) \ | |
206 | TRACEBACK(name) \ | |
207 | ASM_SIZE_DIRECTIVE(name) | |
208 | ||
209 | /* This form supports more informative traceback tables */ | |
210 | #define END_GEN_TB(name,mask) \ | |
211 | TRACEBACK_MASK(name,mask) \ | |
212 | ASM_SIZE_DIRECTIVE(name) | |
213 | ||
214 | ||
215 | #define DO_CALL(syscall) \ | |
216 | li 0,syscall; \ | |
217 | sc | |
218 | ||
219 | /* ppc64 is always PIC */ | |
29d9a17d | 220 | #undef JUMPTARGET |
b80a3db0 RM |
221 | #define JUMPTARGET(name) DOT_LABEL(name) |
222 | ||
223 | #define PSEUDO(name, syscall_name, args) \ | |
224 | .section ".text"; \ | |
225 | ENTRY (name) \ | |
226 | DO_CALL (SYS_ify (syscall_name)); | |
227 | ||
228 | #define PSEUDO_RET \ | |
aff4519d | 229 | bnslr+; \ |
b80a3db0 RM |
230 | b JUMPTARGET(__syscall_error) |
231 | ||
232 | #define ret PSEUDO_RET | |
233 | ||
234 | #undef PSEUDO_END | |
235 | #define PSEUDO_END(name) \ | |
236 | END (name) | |
237 | ||
9eb88290 UD |
238 | #define PSEUDO_NOERRNO(name, syscall_name, args) \ |
239 | .section ".text"; \ | |
240 | ENTRY (name) \ | |
241 | DO_CALL (SYS_ify (syscall_name)); | |
242 | ||
243 | #define PSEUDO_RET_NOERRNO \ | |
244 | blr | |
245 | ||
246 | #define ret_NOERRNO PSEUDO_RET_NOERRNO | |
247 | ||
248 | #undef PSEUDO_END_NOERRNO | |
c6289757 | 249 | #define PSEUDO_END_NOERRNO(name) \ |
9eb88290 UD |
250 | END (name) |
251 | ||
b80a3db0 RM |
252 | /* Label in text section. */ |
253 | /* ppc64 function descriptors which requires . notation */ | |
254 | #define C_TEXT(name) .##name | |
255 | ||
256 | #endif /* __ELF__ */ | |
257 | ||
258 | #endif /* __ASSEMBLER__ */ |