1 /* This file is part of the GNU C Library.
2 Copyright (C) 2012-2013 Free Software Foundation, Inc.
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, see
16 <http://www.gnu.org/licenses/>. */
24 # define SPARC_ASM_IFUNC_DFLT(name, dflt) \
26 .type __##name, @gnu_indirect_function; \
27 SETUP_PIC_REG_LEAF(o3, o5); \
28 sethi %gdop_hix22(dflt), %o1; \
29 xor %o1, %gdop_lox10(dflt), %o1; \
35 # define SPARC_ASM_IFUNC1(name, m1, f1, dflt) \
37 .type __##name, @gnu_indirect_function; \
38 SETUP_PIC_REG_LEAF(o3, o5); \
40 andcc %o0, %o1, %g0; \
43 sethi %gdop_hix22(f1), %o1; \
44 xor %o1, %gdop_lox10(f1), %o1; \
47 9: sethi %gdop_hix22(dflt), %o1; \
48 xor %o1, %gdop_lox10(dflt), %o1; \
49 10: add %o3, %o1, %o1; \
54 # define SPARC_ASM_IFUNC2(name, m1, f1, m2, f2, dflt) \
56 .type __##name, @gnu_indirect_function; \
57 SETUP_PIC_REG_LEAF(o3, o5); \
59 andcc %o0, %o1, %g0; \
62 sethi %gdop_hix22(f1), %o1; \
63 xor %o1, %gdop_lox10(f1), %o1; \
67 andcc %o0, %o1, %g0; \
70 sethi %gdop_hix22(f2), %o1; \
71 xor %o1, %gdop_lox10(f2), %o1; \
74 9: sethi %gdop_hix22(dflt), %o1; \
75 xor %o1, %gdop_lox10(dflt), %o1; \
76 10: add %o3, %o1, %o1; \
84 # define SET(SYM, TMP, REG) setx SYM, TMP, REG
86 # define SET(SYM, TMP, REG) set SYM, REG
89 # define SPARC_ASM_IFUNC_DFLT(name, dflt) \
91 .type __##name, @gnu_indirect_function; \
92 SET(dflt, %g1, %o1); \
97 # define SPARC_ASM_IFUNC1(name, m1, f1, dflt) \
99 .type __##name, @gnu_indirect_function; \
101 andcc %o0, %o1, %g0; \
107 9: SET(dflt, %g1, %o1); \
112 # define SPARC_ASM_IFUNC2(name, m1, f1, m2, f2, dflt) \
114 .type __##name, @gnu_indirect_function; \
116 andcc %o0, %o1, %g0; \
123 andcc %o0, %o1, %g0; \
129 9: SET(dflt, %g1, %o1); \
136 #define SPARC_ASM_VIS2_IFUNC(name) \
137 SPARC_ASM_IFUNC1(name, HWCAP_SPARC_VIS2, \
138 __##name##_vis2, __##name##_generic)
140 # ifdef HAVE_AS_VIS3_SUPPORT
142 #define SPARC_ASM_VIS3_IFUNC(name) \
143 SPARC_ASM_IFUNC1(name, HWCAP_SPARC_VIS3, \
144 __##name##_vis3, __##name##_generic)
146 #define SPARC_ASM_VIS3_VIS2_IFUNC(name) \
147 SPARC_ASM_IFUNC2(name, HWCAP_SPARC_VIS3, \
150 __##name##_vis2, __##name##_generic)
152 # else /* HAVE_AS_VIS3_SUPPORT */
154 #define SPARC_ASM_VIS3_IFUNC(name) \
155 SPARC_ASM_IFUNC_DFLT(name, __##name##_generic)
157 #define SPARC_ASM_VIS3_VIS2_IFUNC(name) \
158 SPARC_ASM_VIS2_IFUNC(name)
160 # endif /* HAVE_AS_VIS3_SUPPORT */
163 #else /* __ASSEMBLER__ */
165 # define sparc_libm_ifunc(name, expr) \
166 extern void *name##_ifunc (int) __asm__ (#name); \
167 void *name##_ifunc (int hwcap) \
169 __typeof (name) *res = expr; \
172 __asm__ (".type " #name ", %gnu_indirect_function");
174 # define sparc_libc_ifunc(name, expr) sparc_libm_ifunc (name, expr)
176 #endif /* __ASSEMBLER__ */