1 /* Assembly macros for 64-bit PowerPC.
2 Copyright (C) 2002, 2003, 2004, 2006 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
7 License as published by the Free Software Foundation; either
8 version 2.1 of the 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, write to the Free
17 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA
20 #include <sysdeps/powerpc/sysdep.h>
26 /* Support macros for CALL_MCOUNT. */
30 std
2+\NARG
,-72+8*(\NARG
)(1)
37 ld
2+\NARG
,40+8*(\NARG
)(1)
41 /* If compiled for profiling, call `_mcount' at the start of each function.
42 see ppc-mcount.S for more details. */
43 .macro CALL_MCOUNT NARG
49 bl
JUMPTARGET (_mcount
)
57 #ifdef USE_PPC64_OVERLAPPING_OPD
58 # define OPD_ENT(name) .quad BODY_LABEL (name), .TOC.@tocbase
60 # define OPD_ENT(name) .quad BODY_LABEL (name), .TOC.@tocbase, 0
63 #define ENTRY_1(name) \
65 .type BODY_LABEL(name),@function; \
67 .section ".opd","aw"; \
69 name##: OPD_ENT (name); \
72 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
73 # define DOT_LABEL(X) .##X
74 # define BODY_LABEL(X) .##X
75 # define ENTRY_2(name) \
76 .globl BODY_LABEL(name); \
79 # define END_2(name) \
80 .size BODY_LABEL(name),.-BODY_LABEL(name);
82 # define DOT_LABEL(X) X
83 # define BODY_LABEL(X) .LY##X
84 # define ENTRY_2(name) \
85 .type name,@function; \
87 # define END_2(name) \
88 .size name,.-BODY_LABEL(name); \
89 .size BODY_LABEL(name),.-BODY_LABEL(name);
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
107 /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
108 past a 2^alignt boundary. */
109 #define EALIGN(name, alignt, words) \
111 .align ALIGNARG(alignt); \
116 /* Local labels stripped out by the linker. */
120 #define tostring(s) #s
121 #define stringify(s) tostring(s)
122 #define XGLUE(a,b) a##b
123 #define GLUE(a,b) XGLUE(a,b)
124 #define LT_LABEL(name) GLUE(.LT,name)
125 #define LT_LABELSUFFIX(name,suffix) GLUE(GLUE(.LT,name),suffix)
127 /* Support Traceback tables */
128 #define TB_ASM 0x000c000000000000
129 #define TB_GLOBALLINK 0x0000800000000000
130 #define TB_IS_EPROL 0x0000400000000000
131 #define TB_HAS_TBOFF 0x0000200000000000
132 #define TB_INT_PROC 0x0000100000000000
133 #define TB_HAS_CTL 0x0000080000000000
134 #define TB_TOCLESS 0x0000040000000000
135 #define TB_FP_PRESENT 0x0000020000000000
136 #define TB_LOG_ABORT 0x0000010000000000
137 #define TB_INT_HANDL 0x0000008000000000
138 #define TB_NAME_PRESENT 0x0000004000000000
139 #define TB_USES_ALLOCA 0x0000002000000000
140 #define TB_SAVES_CR 0x0000000200000000
141 #define TB_SAVES_LR 0x0000000100000000
142 #define TB_STORES_BC 0x0000000080000000
143 #define TB_FIXUP 0x0000000040000000
144 #define TB_FP_SAVED(fprs) (((fprs) & 0x3f) << 24)
145 #define TB_GPR_SAVED(gprs) (((fprs) & 0x3f) << 16)
146 #define TB_FIXEDPARMS(parms) (((parms) & 0xff) << 8)
147 #define TB_FLOATPARMS(parms) (((parms) & 0x7f) << 1)
148 #define TB_PARMSONSTK 0x0000000000000001
150 #define PPC_HIGHER(v) (((v) >> 32) & 0xffff)
151 #define TB_DEFAULT TB_ASM | TB_HAS_TBOFF | TB_NAME_PRESENT
153 #define TRACEBACK(name) \
157 .long LT_LABEL(name)-BODY_LABEL(name) ; \
158 .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \
159 LT_LABELSUFFIX(name,_name_start): ;\
160 .ascii stringify(name) ; \
161 LT_LABELSUFFIX(name,_name_end): ; \
164 #define TRACEBACK_MASK(name,mask) \
167 .quad TB_DEFAULT | mask ; \
168 .long LT_LABEL(name)-BODY_LABEL(name) ; \
169 .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \
170 LT_LABELSUFFIX(name,_name_start): ;\
171 .ascii stringify(name) ; \
172 LT_LABELSUFFIX(name,_name_end): ; \
175 /* END generates Traceback tables */
182 /* This form supports more informative traceback tables */
183 #define END_GEN_TB(name,mask) \
185 TRACEBACK_MASK(name,mask) \
188 #define DO_CALL(syscall) \
192 /* ppc64 is always PIC */
194 #define JUMPTARGET(name) DOT_LABEL(name)
196 #define PSEUDO(name, syscall_name, args) \
199 DO_CALL (SYS_ify (syscall_name));
203 b JUMPTARGET(__syscall_error)
205 #define ret PSEUDO_RET
208 #define PSEUDO_END(name) \
211 #define PSEUDO_NOERRNO(name, syscall_name, args) \
214 DO_CALL (SYS_ify (syscall_name));
216 #define PSEUDO_RET_NOERRNO \
219 #define ret_NOERRNO PSEUDO_RET_NOERRNO
221 #undef PSEUDO_END_NOERRNO
222 #define PSEUDO_END_NOERRNO(name) \
225 #define PSEUDO_ERRVAL(name, syscall_name, args) \
228 DO_CALL (SYS_ify (syscall_name));
230 #define PSEUDO_RET_ERRVAL \
233 #define ret_ERRVAL PSEUDO_RET_ERRVAL
235 #undef PSEUDO_END_ERRVAL
236 #define PSEUDO_END_ERRVAL(name) \
239 #else /* !__ASSEMBLER__ */
241 #ifdef USE_PPC64_OVERLAPPING_OPD
242 # define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase;"
244 # define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase, 0;"
247 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
248 # define DOT_PREFIX "."
249 # define BODY_PREFIX "."
250 # define ENTRY_2(name) \
251 ".globl " BODY_PREFIX #name ";\n" \
252 ".size " #name ", 24;"
253 # define END_2(name) \
254 ".size " BODY_PREFIX #name ",.-" BODY_PREFIX #name ";"
256 # define DOT_PREFIX ""
257 # define BODY_PREFIX ".LY"
258 # define ENTRY_2(name) ".type " #name ",@function;"
259 # define END_2(name) \
260 ".size " #name ",.-" BODY_PREFIX #name ";\n" \
261 ".size " BODY_PREFIX #name ",.-" BODY_PREFIX #name ";"
264 #endif /* __ASSEMBLER__ */