]>
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); \ | |
37 | 0: .long 0; \ | |
38 | .previous; \ | |
39 | mflr r0; \ | |
40 | std r0,16(r1); \ | |
41 | ld r0,0b@got(r2); \ | |
42 | bl JUMPTARGET(_mcount); | |
43 | #else /* SYSV_ELF_PROFILING */ | |
44 | #define CALL_MCOUNT \ | |
45 | mflr r0; \ | |
46 | std r0,16(r1); \ | |
47 | bl JUMPTARGET(_mcount); | |
48 | #endif /* SYSV_ELF_PROFILING */ | |
49 | #else /* PIC */ | |
50 | #ifdef SYSV_ELF_PROFILING | |
51 | #define CALL_MCOUNT \ | |
52 | .pushsection; \ | |
53 | .section ".data"; \ | |
54 | .align ALIGNARG(2); \ | |
55 | 0: .long 0; \ | |
56 | .previous; \ | |
57 | mflr r0; \ | |
58 | std r0,16(r1); \ | |
59 | ld r0,0b@got(r2); \ | |
60 | bl JUMPTARGET(_mcount); | |
61 | #else /* SYSV_ELF_PROFILING */ | |
62 | #define CALL_MCOUNT \ | |
63 | mflr r0; \ | |
64 | std r0,16(r1); \ | |
65 | bl JUMPTARGET(_mcount); | |
66 | #endif /* SYSV_ELF_PROFILING */ | |
67 | #endif /* PIC */ | |
68 | #else /* PROF */ | |
69 | #define CALL_MCOUNT /* Do nothing. */ | |
70 | #endif /* PROF */ | |
71 | ||
72 | #define DOT_LABEL(X) .##X | |
73 | ||
74 | #define ENTRY(name) \ | |
75 | .section ".text"; \ | |
76 | .align ALIGNARG(2); \ | |
77 | .globl DOT_LABEL(name); \ | |
78 | .type DOT_LABEL(name),@function ; \ | |
79 | .globl name; \ | |
80 | .section ".opd","aw"; \ | |
81 | name##: ; \ | |
82 | .quad DOT_LABEL(name) ; \ | |
83 | .quad .TOC.@tocbase, 0; \ | |
84 | .previous; \ | |
85 | DOT_LABEL(name): | |
86 | ||
87 | ||
88 | #define EALIGN_W_0 /* No words to insert. */ | |
89 | #define EALIGN_W_1 nop | |
90 | #define EALIGN_W_2 nop;nop | |
91 | #define EALIGN_W_3 nop;nop;nop | |
92 | #define EALIGN_W_4 EALIGN_W_3;nop | |
93 | #define EALIGN_W_5 EALIGN_W_4;nop | |
94 | #define EALIGN_W_6 EALIGN_W_5;nop | |
95 | #define EALIGN_W_7 EALIGN_W_6;nop | |
96 | ||
97 | /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes | |
98 | past a 2^align boundary. */ | |
99 | #ifdef PROF | |
100 | #define EALIGN(name, alignt, words) \ | |
101 | .section ".text"; \ | |
102 | .globl DOT_LABEL(name); \ | |
103 | .type DOT_LABEL(name),@function ; \ | |
104 | .globl name; \ | |
105 | .section ".opd","aw"; \ | |
106 | name##: ; \ | |
107 | .quad DOT_LABEL(name) ; \ | |
108 | .quad .TOC.@tocbase, 0; \ | |
109 | .previous; \ | |
110 | .align ALIGNARG(alignt); \ | |
111 | EALIGN_W_##words; \ | |
112 | DOT_LABEL(name): \ | |
113 | CALL_MCOUNT \ | |
114 | b 0f; \ | |
115 | .align ALIGNARG(alignt); \ | |
116 | EALIGN_W_##words; \ | |
117 | 0: | |
118 | #else /* PROF */ | |
119 | #define EALIGN(name, alignt, words) \ | |
120 | .section ".text"; \ | |
121 | .globl DOT_LABEL(name); \ | |
122 | .type DOT_LABEL(name),@function ; \ | |
123 | .globl name; \ | |
124 | .section ".opd","aw"; \ | |
125 | name##: ; \ | |
126 | .quad DOT_LABEL(name) ; \ | |
127 | .quad .TOC.@tocbase, 0; \ | |
128 | .previous; \ | |
129 | .align ALIGNARG(alignt); \ | |
130 | EALIGN_W_##words; \ | |
131 | DOT_LABEL(name): | |
132 | #endif | |
133 | ||
134 | /* Local labels stripped out by the linker. */ | |
135 | #undef L | |
136 | #define L(x) .L##x | |
137 | ||
138 | #define tostring(s) #s | |
139 | #define stringify(s) tostring(s) | |
140 | #define XGLUE(a,b) a##b | |
141 | #define GLUE(a,b) XGLUE(a,b) | |
142 | #define LT_LABEL(name) GLUE(.LT,name) | |
143 | #define LT_LABELSUFFIX(name,suffix) GLUE(GLUE(.LT,name),suffix) | |
144 | ||
145 | /* Support Traceback tables */ | |
146 | #define TB_ASM 0x000c000000000000 | |
147 | #define TB_GLOBALLINK 0x0000800000000000 | |
148 | #define TB_IS_EPROL 0x0000400000000000 | |
149 | #define TB_HAS_TBOFF 0x0000200000000000 | |
150 | #define TB_INT_PROC 0x0000100000000000 | |
151 | #define TB_HAS_CTL 0x0000080000000000 | |
152 | #define TB_TOCLESS 0x0000040000000000 | |
153 | #define TB_FP_PRESENT 0x0000020000000000 | |
154 | #define TB_LOG_ABORT 0x0000010000000000 | |
155 | #define TB_INT_HANDL 0x0000008000000000 | |
156 | #define TB_NAME_PRESENT 0x0000004000000000 | |
157 | #define TB_USES_ALLOCA 0x0000002000000000 | |
158 | #define TB_SAVES_CR 0x0000000200000000 | |
159 | #define TB_SAVES_LR 0x0000000100000000 | |
160 | #define TB_STORES_BC 0x0000000080000000 | |
161 | #define TB_FIXUP 0x0000000040000000 | |
162 | #define TB_FP_SAVED(fprs) (((fprs) & 0x3f) << 24) | |
163 | #define TB_GPR_SAVED(gprs) (((fprs) & 0x3f) << 16) | |
164 | #define TB_FIXEDPARMS(parms) (((parms) & 0xff) << 8) | |
165 | #define TB_FLOATPARMS(parms) (((parms) & 0x7f) << 1) | |
166 | #define TB_PARMSONSTK 0x0000000000000001 | |
167 | ||
168 | #define PPC_HIGHER(v) (((v) >> 32) & 0xffff) | |
169 | #define TB_DEFAULT TB_ASM | TB_HAS_TBOFF | TB_NAME_PRESENT | |
170 | ||
171 | #define TRACEBACK(name) \ | |
172 | LT_LABEL(name): ; \ | |
173 | .long 0 ; \ | |
174 | .quad TB_DEFAULT ; \ | |
175 | .long LT_LABEL(name)-DOT_LABEL(name) ; \ | |
176 | .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \ | |
177 | LT_LABELSUFFIX(name,_name_start): ;\ | |
178 | .ascii stringify(name) ; \ | |
179 | LT_LABELSUFFIX(name,_name_end): ; \ | |
180 | .align 2 ; | |
181 | ||
182 | #define TRACEBACK_MASK(name,mask) \ | |
183 | LT_LABEL(name): ; \ | |
184 | .long 0 ; \ | |
185 | .quad TB_DEFAULT | mask ; \ | |
186 | .long LT_LABEL(name)-DOT_LABEL(name) ; \ | |
187 | .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \ | |
188 | LT_LABELSUFFIX(name,_name_start): ;\ | |
189 | .ascii stringify(name) ; \ | |
190 | LT_LABELSUFFIX(name,_name_end): ; \ | |
191 | .align 2 ; | |
192 | ||
193 | /* END generates Traceback tables */ | |
194 | #undef END | |
195 | #define END(name) \ | |
196 | TRACEBACK(name) \ | |
197 | ASM_SIZE_DIRECTIVE(name) | |
198 | ||
199 | /* This form supports more informative traceback tables */ | |
200 | #define END_GEN_TB(name,mask) \ | |
201 | TRACEBACK_MASK(name,mask) \ | |
202 | ASM_SIZE_DIRECTIVE(name) | |
203 | ||
204 | ||
205 | #define DO_CALL(syscall) \ | |
206 | li 0,syscall; \ | |
207 | sc | |
208 | ||
209 | /* ppc64 is always PIC */ | |
29d9a17d | 210 | #undef JUMPTARGET |
b80a3db0 RM |
211 | #define JUMPTARGET(name) DOT_LABEL(name) |
212 | ||
213 | #define PSEUDO(name, syscall_name, args) \ | |
214 | .section ".text"; \ | |
215 | ENTRY (name) \ | |
216 | DO_CALL (SYS_ify (syscall_name)); | |
217 | ||
218 | #define PSEUDO_RET \ | |
219 | bnslr; \ | |
220 | b JUMPTARGET(__syscall_error) | |
221 | ||
222 | #define ret PSEUDO_RET | |
223 | ||
224 | #undef PSEUDO_END | |
225 | #define PSEUDO_END(name) \ | |
226 | END (name) | |
227 | ||
228 | /* Label in text section. */ | |
229 | /* ppc64 function descriptors which requires . notation */ | |
230 | #define C_TEXT(name) .##name | |
231 | ||
232 | #endif /* __ELF__ */ | |
233 | ||
234 | #endif /* __ASSEMBLER__ */ |