10ec57554Sraf /*
20ec57554Sraf * CDDL HEADER START
30ec57554Sraf *
40ec57554Sraf * The contents of this file are subject to the terms of the
50ec57554Sraf * Common Development and Distribution License (the "License").
60ec57554Sraf * You may not use this file except in compliance with the License.
70ec57554Sraf *
80ec57554Sraf * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90ec57554Sraf * or http://www.opensolaris.org/os/licensing.
100ec57554Sraf * See the License for the specific language governing permissions
110ec57554Sraf * and limitations under the License.
120ec57554Sraf *
130ec57554Sraf * When distributing Covered Code, include this CDDL HEADER in each
140ec57554Sraf * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150ec57554Sraf * If applicable, add the following below this CDDL HEADER, with the
160ec57554Sraf * fields enclosed by brackets "[]" replaced with your own identifying
170ec57554Sraf * information: Portions Copyright [yyyy] [name of copyright owner]
180ec57554Sraf *
190ec57554Sraf * CDDL HEADER END
200ec57554Sraf */
210ec57554Sraf
220ec57554Sraf /*
230ec57554Sraf * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
240ec57554Sraf * Use is subject to license terms.
250ec57554Sraf */
260ec57554Sraf
270ec57554Sraf #ifndef _BASE_INLINES_H
280ec57554Sraf #define _BASE_INLINES_H
290ec57554Sraf
30*6a3e8e86SRichard Lowe #include <sys/ccompile.h>
310ec57554Sraf #include <sys/types.h>
320ec57554Sraf
330ec57554Sraf #if !defined(__lint) && defined(__GNUC__)
340ec57554Sraf
350ec57554Sraf /*
360ec57554Sraf * This file is intended to contain gcc-style inline assembly that corresponds
370ec57554Sraf * to base.il for all architectures. At the moment these inlines exist only
380ec57554Sraf * for sparc and sparcv9 and these functions are implemented in C for x86.
390ec57554Sraf * They should be inlined here for gcc if a new x86 base.il is created.
400ec57554Sraf */
410ec57554Sraf
420ec57554Sraf #if defined(__sparc)
43*6a3e8e86SRichard Lowe extern __GNU_INLINE double
__mul_set(double x,double y,int * pe)440ec57554Sraf __mul_set(double x, double y, int *pe)
450ec57554Sraf {
460ec57554Sraf double __result;
470ec57554Sraf uint32_t __fsr;
480ec57554Sraf uint32_t *__addr = &__fsr;
490ec57554Sraf
500ec57554Sraf __asm__ __volatile__(
510ec57554Sraf "fmuld %4, %5, %0\n\t"
520ec57554Sraf "st %%fsr, %3\n\t"
530ec57554Sraf "ld %3, %2\n\t"
540ec57554Sraf "and %2, 1, %2\n\t"
550ec57554Sraf "st %2, %1"
560ec57554Sraf : "=&e" (__result), "=m" (*pe), "=r" (__fsr), "=m" (*__addr)
570ec57554Sraf : "e" (x), "e" (y));
580ec57554Sraf return (__result);
590ec57554Sraf }
600ec57554Sraf #endif /* __sparc */
610ec57554Sraf
620ec57554Sraf #if defined(__sparc)
63*6a3e8e86SRichard Lowe extern __GNU_INLINE double
__div_set(double x,double y,int * pe)640ec57554Sraf __div_set(double x, double y, int *pe)
650ec57554Sraf {
660ec57554Sraf double __result;
670ec57554Sraf uint32_t __fsr;
680ec57554Sraf uint32_t *__addr = &__fsr;
690ec57554Sraf
700ec57554Sraf __asm__ __volatile__(
710ec57554Sraf "fdivd %4, %5, %0\n\t"
720ec57554Sraf "st %%fsr, %3\n\t"
730ec57554Sraf "ld %3, %2\n\t"
740ec57554Sraf "and %2, 1, %2\n\t"
750ec57554Sraf "st %2, %1"
760ec57554Sraf : "=&e" (__result), "=m" (*pe), "=r" (__fsr), "=m" (*__addr)
770ec57554Sraf : "e" (x), "e" (y));
780ec57554Sraf return (__result);
790ec57554Sraf }
800ec57554Sraf #endif /* __sparc */
810ec57554Sraf
820ec57554Sraf #if defined(__sparc)
83*6a3e8e86SRichard Lowe extern __GNU_INLINE double
__dabs(double * x)840ec57554Sraf __dabs(double *x)
850ec57554Sraf {
860ec57554Sraf double __result;
870ec57554Sraf
880ec57554Sraf __asm__ __volatile__(
890ec57554Sraf #if defined(__sparcv9)
900ec57554Sraf "fabsd %1, %0"
910ec57554Sraf #else
920ec57554Sraf "fabss %1, %0"
930ec57554Sraf #endif
940ec57554Sraf : "=e" (__result)
950ec57554Sraf : "0" (*x));
960ec57554Sraf return (__result);
970ec57554Sraf }
980ec57554Sraf #endif /* __sparc */
990ec57554Sraf
1000ec57554Sraf #if defined(__sparc)
101*6a3e8e86SRichard Lowe extern __GNU_INLINE void
__get_ieee_flags(__ieee_flags_type * b)1020ec57554Sraf __get_ieee_flags(__ieee_flags_type *b)
1030ec57554Sraf {
1040ec57554Sraf uint32_t __fsr;
1050ec57554Sraf
1060ec57554Sraf /*
1070ec57554Sraf * It's preferable to let the assembler insert the nops as
1080ec57554Sraf * needed; however, it warns as it does so. Add them here for now.
1090ec57554Sraf */
1100ec57554Sraf __asm__ __volatile__(
1110ec57554Sraf "st %%fsr, %0\n\t"
1120ec57554Sraf "st %%g0, %1\n\t"
1130ec57554Sraf "ld %1, %%fsr\n\t"
1140ec57554Sraf "nop; nop; nop"
1150ec57554Sraf : "=m" (*b), "=m" (__fsr));
1160ec57554Sraf }
1170ec57554Sraf #endif /* __sparc */
1180ec57554Sraf
1190ec57554Sraf #if defined(__sparc)
120*6a3e8e86SRichard Lowe extern __GNU_INLINE void
__set_ieee_flags(__ieee_flags_type * b)1210ec57554Sraf __set_ieee_flags(__ieee_flags_type *b)
1220ec57554Sraf {
1230ec57554Sraf /*
1240ec57554Sraf * It's preferable to let the assembler insert the nops as
1250ec57554Sraf * needed; however, it warns as it does so. Add them here for now.
1260ec57554Sraf */
1270ec57554Sraf __asm__ __volatile__(
1280ec57554Sraf "ld %0, %%fsr\n\t"
1290ec57554Sraf "nop; nop; nop"
1300ec57554Sraf : /* no outputs */
1310ec57554Sraf : "m" (*b));
1320ec57554Sraf }
1330ec57554Sraf #endif /* __sparc */
1340ec57554Sraf
1350ec57554Sraf #endif /* !__lint && __GNUC__ */
1360ec57554Sraf
1370ec57554Sraf #endif /* _BASE_INLINES_H */
138