Update.
[glibc.git] / sysdeps / powerpc / sysdep.h
blob350fd1e3b1ec87febebe2d66d0f79571d5809032
1 /* Copyright (C) 1999, 2001 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #ifdef __ASSEMBLER__
21 /* Symbolic names for the registers. The only portable way to write asm
22 code is to use number but this produces really unreadable code.
23 Therefore these symbolic names. */
25 /* Integer registers. */
26 #define r0 0
27 #define r1 1
28 #define r2 2
29 #define r3 3
30 #define r4 4
31 #define r5 5
32 #define r6 6
33 #define r7 7
34 #define r8 8
35 #define r9 9
36 #define r10 10
37 #define r11 11
38 #define r12 12
39 #define r13 13
40 #define r14 14
41 #define r15 15
42 #define r16 16
43 #define r17 17
44 #define r18 18
45 #define r19 19
46 #define r20 20
47 #define r21 21
48 #define r22 22
49 #define r23 23
50 #define r24 24
51 #define r25 25
52 #define r26 26
53 #define r27 27
54 #define r28 28
55 #define r29 29
56 #define r30 30
57 #define r31 31
59 /* Floating-point registers. */
60 #define fp0 0
61 #define fp1 1
62 #define fp2 2
63 #define fp3 3
64 #define fp4 4
65 #define fp5 5
66 #define fp6 6
67 #define fp7 7
68 #define fp8 8
69 #define fp9 9
70 #define fp10 10
71 #define fp11 11
72 #define fp12 12
73 #define fp13 13
74 #define fp14 14
75 #define fp15 15
76 #define fp16 16
77 #define fp17 17
78 #define fp18 18
79 #define fp19 19
80 #define fp20 20
81 #define fp21 21
82 #define fp22 22
83 #define fp23 23
84 #define fp24 24
85 #define fp25 25
86 #define fp26 26
87 #define fp27 27
88 #define fp28 28
89 #define fp29 29
90 #define fp30 30
91 #define fp31 31
93 /* Condition code registers. */
94 #define cr0 0
95 #define cr1 1
96 #define cr2 2
97 #define cr3 3
98 #define cr4 4
99 #define cr5 5
100 #define cr6 6
101 #define cr7 7
104 #ifdef __ELF__
106 /* This seems to always be the case on PPC. */
107 #define ALIGNARG(log2) log2
108 /* For ELF we need the `.type' directive to make shared libs work right. */
109 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
110 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
112 /* If compiled for profiling, call `_mcount' at the start of each function. */
113 #ifdef PROF
114 /* The mcount code relies on a the return address being on the stack
115 to locate our caller and so it can restore it; so store one just
116 for its benefit. */
117 #ifdef PIC
118 #define CALL_MCOUNT \
119 .pushsection; \
120 .section ".data"; \
121 .align ALIGNARG(2); \
122 0:.long 0; \
123 .previous; \
124 mflr r0; \
125 stw r0,4(r1); \
126 bl _GLOBAL_OFFSET_TABLE_@local-4; \
127 mflr r11; \
128 lwz r0,0b@got(r11); \
129 bl JUMPTARGET(_mcount);
130 #else /* PIC */
131 #define CALL_MCOUNT \
132 .section ".data"; \
133 .align ALIGNARG(2); \
134 0:.long 0; \
135 .previous; \
136 mflr r0; \
137 lis r11,0b@ha; \
138 stw r0,4(r1); \
139 addi r0,r11,0b@l; \
140 bl JUMPTARGET(_mcount);
141 #endif /* PIC */
142 #else /* PROF */
143 #define CALL_MCOUNT /* Do nothing. */
144 #endif /* PROF */
146 #define ENTRY(name) \
147 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
148 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
149 .align ALIGNARG(2); \
150 C_LABEL(name) \
151 CALL_MCOUNT
153 #define EALIGN_W_0 /* No words to insert. */
154 #define EALIGN_W_1 nop
155 #define EALIGN_W_2 nop;nop
156 #define EALIGN_W_3 nop;nop;nop
157 #define EALIGN_W_4 EALIGN_W_3;nop
158 #define EALIGN_W_5 EALIGN_W_4;nop
159 #define EALIGN_W_6 EALIGN_W_5;nop
160 #define EALIGN_W_7 EALIGN_W_6;nop
162 /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
163 past a 2^align boundary. */
164 #ifdef PROF
165 #define EALIGN(name, alignt, words) \
166 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
167 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
168 .align ALIGNARG(2); \
169 C_LABEL(name) \
170 CALL_MCOUNT \
171 b 0f; \
172 .align ALIGNARG(alignt); \
173 EALIGN_W_##words; \
175 #else /* PROF */
176 #define EALIGN(name, alignt, words) \
177 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
178 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
179 .align ALIGNARG(alignt); \
180 EALIGN_W_##words; \
181 C_LABEL(name)
182 #endif
184 #undef END
185 #define END(name) \
186 ASM_SIZE_DIRECTIVE(name)
188 #define DO_CALL(syscall) \
189 li 0,syscall; \
192 #ifdef PIC
193 #define JUMPTARGET(name) name##@plt
194 #else
195 #define JUMPTARGET(name) name
196 #endif
198 #define PSEUDO(name, syscall_name, args) \
199 .section ".text"; \
200 ENTRY (name) \
201 DO_CALL (SYS_ify (syscall_name));
203 #define PSEUDO_RET \
204 bnslr; \
205 b JUMPTARGET(__syscall_error)
206 #define ret PSEUDO_RET
208 #undef PSEUDO_END
209 #define PSEUDO_END(name) \
210 END (name)
212 /* Local labels stripped out by the linker. */
213 #undef L
214 #define L(x) .L##x
216 /* Label in text section. */
217 #define C_TEXT(name) name
219 #endif /* __ELF__ */
222 #endif /* __ASSEMBLER__ */