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, see
17 <http://www.gnu.org/licenses/>. */
23 /* Support macros for CALL_MCOUNT. */
27 std 2+\NARG,-72+8*(\NARG)(1)
34 ld 2+\NARG,40+8*(\NARG)(1)
38 /* If compiled for profiling, call `_mcount' at the start of each function.
39 see ppc-mcount.S for more details. */
40 .macro CALL_MCOUNT NARG
46 bl JUMPTARGET (_mcount)
54 #ifdef USE_PPC64_OVERLAPPING_OPD
55 # define OPD_ENT(name) .quad BODY_LABEL (name), .TOC.@tocbase
57 # define OPD_ENT(name) .quad BODY_LABEL (name), .TOC.@tocbase, 0
60 #define ENTRY_1(name) \
62 .type BODY_LABEL(name),@function; \
64 .section ".opd","aw"; \
66 name##: OPD_ENT (name); \
69 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
70 # define DOT_LABEL(X) .##X
71 # define BODY_LABEL(X) .##X
72 # define ENTRY_2(name) \
73 .globl BODY_LABEL(name); \
76 # define END_2(name) \
77 .size BODY_LABEL(name),.-BODY_LABEL(name);
79 # define DOT_LABEL(X) X
80 # define BODY_LABEL(X) .LY##X
81 # define ENTRY_2(name) \
82 .type name,@function; \
84 # define END_2(name) \
85 .size name,.-BODY_LABEL(name); \
86 .size BODY_LABEL(name),.-BODY_LABEL(name);
95 #define EALIGN_W_0 /* No words to insert. */
96 #define EALIGN_W_1 nop
97 #define EALIGN_W_2 nop;nop
98 #define EALIGN_W_3 nop;nop;nop
99 #define EALIGN_W_4 EALIGN_W_3;nop
100 #define EALIGN_W_5 EALIGN_W_4;nop
101 #define EALIGN_W_6 EALIGN_W_5;nop
102 #define EALIGN_W_7 EALIGN_W_6;nop
104 /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
105 past a 2^alignt boundary. */
106 #define EALIGN(name, alignt, words) \
108 .align ALIGNARG(alignt); \
113 /* Local labels stripped out by the linker. */
117 #define tostring(s) #s
118 #define stringify(s) tostring(s)
119 #define XGLUE(a,b) a##b
120 #define GLUE(a,b) XGLUE(a,b)
121 #define LT_LABEL(name) GLUE(.LT,name)
122 #define LT_LABELSUFFIX(name,suffix) GLUE(GLUE(.LT,name),suffix)
124 /* Support Traceback tables */
125 #define TB_ASM 0x000c000000000000
126 #define TB_GLOBALLINK 0x0000800000000000
127 #define TB_IS_EPROL 0x0000400000000000
128 #define TB_HAS_TBOFF 0x0000200000000000
129 #define TB_INT_PROC 0x0000100000000000
130 #define TB_HAS_CTL 0x0000080000000000
131 #define TB_TOCLESS 0x0000040000000000
132 #define TB_FP_PRESENT 0x0000020000000000
133 #define TB_LOG_ABORT 0x0000010000000000
134 #define TB_INT_HANDL 0x0000008000000000
135 #define TB_NAME_PRESENT 0x0000004000000000
136 #define TB_USES_ALLOCA 0x0000002000000000
137 #define TB_SAVES_CR 0x0000000200000000
138 #define TB_SAVES_LR 0x0000000100000000
139 #define TB_STORES_BC 0x0000000080000000
140 #define TB_FIXUP 0x0000000040000000
141 #define TB_FP_SAVED(fprs) (((fprs) & 0x3f) << 24)
142 #define TB_GPR_SAVED(gprs) (((fprs) & 0x3f) << 16)
143 #define TB_FIXEDPARMS(parms) (((parms) & 0xff) << 8)
144 #define TB_FLOATPARMS(parms) (((parms) & 0x7f) << 1)
145 #define TB_PARMSONSTK 0x0000000000000001
147 #define PPC_HIGHER(v) (((v) >> 32) & 0xffff)
148 #define TB_DEFAULT TB_ASM | TB_HAS_TBOFF | TB_NAME_PRESENT
150 #define TRACEBACK(name) \
154 .long LT_LABEL(name)-BODY_LABEL(name) ; \
155 .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \
156 LT_LABELSUFFIX(name,_name_start): ;\
157 .ascii stringify(name) ; \
158 LT_LABELSUFFIX(name,_name_end): ; \
161 #define TRACEBACK_MASK(name,mask) \
164 .quad TB_DEFAULT | mask ; \
165 .long LT_LABEL(name)-BODY_LABEL(name) ; \
166 .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \
167 LT_LABELSUFFIX(name,_name_start): ;\
168 .ascii stringify(name) ; \
169 LT_LABELSUFFIX(name,_name_end): ; \
172 /* END generates Traceback tables */
179 /* This form supports more informative traceback tables */
180 #define END_GEN_TB(name,mask) \
182 TRACEBACK_MASK(name,mask) \
185 #define DO_CALL(syscall) \
189 /* ppc64 is always PIC */
191 #define JUMPTARGET(name) DOT_LABEL(name)
193 #define PSEUDO(name, syscall_name, args) \
196 DO_CALL (SYS_ify (syscall_name));
200 b JUMPTARGET(__syscall_error)
202 #define ret PSEUDO_RET
205 #define PSEUDO_END(name) \
208 #define PSEUDO_NOERRNO(name, syscall_name, args) \
211 DO_CALL (SYS_ify (syscall_name));
213 #define PSEUDO_RET_NOERRNO \
216 #define ret_NOERRNO PSEUDO_RET_NOERRNO
218 #undef PSEUDO_END_NOERRNO
219 #define PSEUDO_END_NOERRNO(name) \
222 #define PSEUDO_ERRVAL(name, syscall_name, args) \
225 DO_CALL (SYS_ify (syscall_name));
227 #define PSEUDO_RET_ERRVAL \
231 #define ret_ERRVAL PSEUDO_RET_ERRVAL
233 #undef PSEUDO_END_ERRVAL
234 #define PSEUDO_END_ERRVAL(name) \
237 #else /* !__ASSEMBLER__ */
239 #ifdef USE_PPC64_OVERLAPPING_OPD
240 # define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase;"
242 # define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase, 0;"
245 #ifdef HAVE_ASM_GLOBAL_DOT_NAME
246 # define DOT_PREFIX "."
247 # define BODY_PREFIX "."
248 # define ENTRY_2(name) \
249 ".globl " BODY_PREFIX #name ";\n" \
250 ".size " #name ", 24;"
251 # define END_2(name) \
252 ".size " BODY_PREFIX #name ",.-" BODY_PREFIX #name ";"
254 # define DOT_PREFIX ""
255 # define BODY_PREFIX ".LY"
256 # define ENTRY_2(name) ".type " #name ",@function;"
257 # define END_2(name) \
258 ".size " #name ",.-" BODY_PREFIX #name ";\n" \
259 ".size " BODY_PREFIX #name ",.-" BODY_PREFIX #name ";"
262 #endif /* __ASSEMBLER__ */