]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/sparc/sparc-ifunc.h
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / sparc / sparc-ifunc.h
CommitLineData
006f1daa 1/* This file is part of the GNU C Library.
d4697bc9 2 Copyright (C) 2012-2014 Free Software Foundation, Inc.
006f1daa
DM
3
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.
8
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.
13
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/>. */
17
18#include <sysdep.h>
19
20#ifdef __ASSEMBLER__
21
22# ifdef SHARED
23
24# define SPARC_ASM_IFUNC_DFLT(name, dflt) \
25ENTRY (__##name) \
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; \
30 add %o3, %o1, %o1; \
31 retl; \
32 mov %o1, %o0; \
33END (__##name)
34
35# define SPARC_ASM_IFUNC1(name, m1, f1, dflt) \
36ENTRY (__##name) \
37 .type __##name, @gnu_indirect_function; \
38 SETUP_PIC_REG_LEAF(o3, o5); \
39 set m1, %o1; \
40 andcc %o0, %o1, %g0; \
41 be 9f; \
42 nop; \
43 sethi %gdop_hix22(f1), %o1; \
44 xor %o1, %gdop_lox10(f1), %o1; \
45 ba 10f; \
46 nop; \
479: sethi %gdop_hix22(dflt), %o1; \
48 xor %o1, %gdop_lox10(dflt), %o1; \
4910: add %o3, %o1, %o1; \
50 retl; \
51 mov %o1, %o0; \
52END (__##name)
53
8b954ab9
DM
54# define SPARC_ASM_IFUNC2(name, m1, f1, m2, f2, dflt) \
55ENTRY (__##name) \
56 .type __##name, @gnu_indirect_function; \
57 SETUP_PIC_REG_LEAF(o3, o5); \
58 set m1, %o1; \
59 andcc %o0, %o1, %g0; \
60 be 8f; \
61 nop; \
62 sethi %gdop_hix22(f1), %o1; \
63 xor %o1, %gdop_lox10(f1), %o1; \
64 ba 10f; \
65 nop; \
668: set m2, %o1; \
67 andcc %o0, %o1, %g0; \
68 be 9f; \
69 nop; \
70 sethi %gdop_hix22(f2), %o1; \
71 xor %o1, %gdop_lox10(f2), %o1; \
72 ba 10f; \
73 nop; \
749: sethi %gdop_hix22(dflt), %o1; \
75 xor %o1, %gdop_lox10(dflt), %o1; \
7610: add %o3, %o1, %o1; \
77 retl; \
78 mov %o1, %o0; \
79END (__##name)
80
006f1daa
DM
81# else /* SHARED */
82
83# ifdef __arch64__
84# define SET(SYM, TMP, REG) setx SYM, TMP, REG
85# else
86# define SET(SYM, TMP, REG) set SYM, REG
87# endif
88
89# define SPARC_ASM_IFUNC_DFLT(name, dflt) \
90ENTRY (__##name) \
91 .type __##name, @gnu_indirect_function; \
92 SET(dflt, %g1, %o1); \
93 retl; \
94 mov %o1, %o0; \
95END (__##name)
96
97# define SPARC_ASM_IFUNC1(name, m1, f1, dflt) \
98ENTRY (__##name) \
99 .type __##name, @gnu_indirect_function; \
100 set m1, %o1; \
101 andcc %o0, %o1, %g0; \
102 be 9f; \
103 nop; \
104 SET(f1, %g1, %o1); \
105 ba 10f; \
106 nop; \
1079: SET(dflt, %g1, %o1); \
10810: retl; \
109 mov %o1, %o0; \
110END (__##name)
111
8b954ab9
DM
112# define SPARC_ASM_IFUNC2(name, m1, f1, m2, f2, dflt) \
113ENTRY (__##name) \
114 .type __##name, @gnu_indirect_function; \
115 set m1, %o1; \
116 andcc %o0, %o1, %g0; \
117 be 8f; \
118 nop; \
119 SET(f1, %g1, %o1); \
120 ba 10f; \
121 nop; \
1228: set m2, %o1; \
123 andcc %o0, %o1, %g0; \
124 be 9f; \
125 nop; \
126 SET(f2, %g1, %o1); \
127 ba 10f; \
128 nop; \
1299: SET(dflt, %g1, %o1); \
13010: retl; \
131 mov %o1, %o0; \
132END (__##name)
133
006f1daa
DM
134# endif /* SHARED */
135
8b954ab9
DM
136#define SPARC_ASM_VIS2_IFUNC(name) \
137 SPARC_ASM_IFUNC1(name, HWCAP_SPARC_VIS2, \
138 __##name##_vis2, __##name##_generic)
139
006f1daa
DM
140# ifdef HAVE_AS_VIS3_SUPPORT
141
142#define SPARC_ASM_VIS3_IFUNC(name) \
143 SPARC_ASM_IFUNC1(name, HWCAP_SPARC_VIS3, \
144 __##name##_vis3, __##name##_generic)
145
8b954ab9
DM
146#define SPARC_ASM_VIS3_VIS2_IFUNC(name) \
147 SPARC_ASM_IFUNC2(name, HWCAP_SPARC_VIS3, \
148 __##name##_vis3, \
149 HWCAP_SPARC_VIS2, \
150 __##name##_vis2, __##name##_generic)
151
006f1daa
DM
152# else /* HAVE_AS_VIS3_SUPPORT */
153
154#define SPARC_ASM_VIS3_IFUNC(name) \
155 SPARC_ASM_IFUNC_DFLT(name, __##name##_generic)
156
8b954ab9
DM
157#define SPARC_ASM_VIS3_VIS2_IFUNC(name) \
158 SPARC_ASM_VIS2_IFUNC(name)
159
006f1daa
DM
160# endif /* HAVE_AS_VIS3_SUPPORT */
161
162
163#else /* __ASSEMBLER__ */
164
165# define sparc_libm_ifunc(name, expr) \
166 extern void *name##_ifunc (int) __asm__ (#name); \
167 void *name##_ifunc (int hwcap) \
168 { \
169 __typeof (name) *res = expr; \
170 return res; \
171 } \
172 __asm__ (".type " #name ", %gnu_indirect_function");
173
3a0d900a
DM
174# define sparc_libc_ifunc(name, expr) sparc_libm_ifunc (name, expr)
175
006f1daa 176#endif /* __ASSEMBLER__ */