xref: /illumos-gate/usr/src/uts/sparc/sys/fpu/globals.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_FPU_GLOBALS_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_FPU_GLOBALS_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * Sparc floating-point simulator PRIVATE include file.
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
37*7c478bd9Sstevel@tonic-gate #include <vm/seg.h>
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
40*7c478bd9Sstevel@tonic-gate extern "C" {
41*7c478bd9Sstevel@tonic-gate #endif
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate /*	PRIVATE CONSTANTS	*/
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #define	INTEGER_BIAS	   31
46*7c478bd9Sstevel@tonic-gate #define	LONGLONG_BIAS	   63
47*7c478bd9Sstevel@tonic-gate #define	SINGLE_BIAS	  127
48*7c478bd9Sstevel@tonic-gate #define	DOUBLE_BIAS	 1023
49*7c478bd9Sstevel@tonic-gate #define	EXTENDED_BIAS	16383
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate /* PRIVATE TYPES	*/
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate #define	DOUBLE_E(n) (n & 0xfffe)	/* More significant word of double. */
54*7c478bd9Sstevel@tonic-gate #define	DOUBLE_F(n) (1+DOUBLE_E(n))	/* Less significant word of double. */
55*7c478bd9Sstevel@tonic-gate #define	EXTENDED_E(n) (n & 0xfffc) /* Sign/exponent/significand of extended. */
56*7c478bd9Sstevel@tonic-gate #define	EXTENDED_F(n) (1+EXTENDED_E(n)) /* 2nd word of extended significand. */
57*7c478bd9Sstevel@tonic-gate #define	EXTENDED_G(n) (2+EXTENDED_E(n)) /* 3rd word of extended significand. */
58*7c478bd9Sstevel@tonic-gate #define	EXTENDED_H(n) (3+EXTENDED_E(n)) /* 4th word of extended significand. */
59*7c478bd9Sstevel@tonic-gate #define	DOUBLE(n) ((n & 0xfffe) >> 1)	/* Shift n to access double regs. */
60*7c478bd9Sstevel@tonic-gate #define	QUAD_E(n) ((n & 0xfffc) >> 1)	/* More significant half of quad. */
61*7c478bd9Sstevel@tonic-gate #define	QUAD_F(n) (1+QUAD_E(n))		/* Less significant half of quad. */
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate #if defined(_KERNEL)
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate typedef struct {
67*7c478bd9Sstevel@tonic-gate 	int sign;
68*7c478bd9Sstevel@tonic-gate 	enum fp_class_type fpclass;
69*7c478bd9Sstevel@tonic-gate 	int	exponent;		/* Unbiased exponent	*/
70*7c478bd9Sstevel@tonic-gate 	uint_t significand[4];		/* Four significand word . */
71*7c478bd9Sstevel@tonic-gate 	int	rounded;		/* rounded bit */
72*7c478bd9Sstevel@tonic-gate 	int	sticky;			/* stick bit */
73*7c478bd9Sstevel@tonic-gate } unpacked;
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate /*
77*7c478bd9Sstevel@tonic-gate  * PRIVATE FUNCTIONS
78*7c478bd9Sstevel@tonic-gate  * pfreg routines use "physical" FPU registers, in fpusystm.h.
79*7c478bd9Sstevel@tonic-gate  * vfreg routines use "virtual" FPU registers at *_fp_current_pfregs.
80*7c478bd9Sstevel@tonic-gate  */
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate extern void _fp_read_vfreg(FPU_REGS_TYPE *, uint_t, fp_simd_type *);
83*7c478bd9Sstevel@tonic-gate extern void _fp_write_vfreg(FPU_REGS_TYPE *, uint_t, fp_simd_type *);
84*7c478bd9Sstevel@tonic-gate extern void _fp_read_vdreg(FPU_DREGS_TYPE *, uint_t, fp_simd_type *);
85*7c478bd9Sstevel@tonic-gate extern void _fp_write_vdreg(FPU_DREGS_TYPE *, uint_t, fp_simd_type *);
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate extern enum ftt_type _fp_iu_simulator(fp_simd_type *, fp_inst_type,
88*7c478bd9Sstevel@tonic-gate 			struct regs *, void *, kfpu_t *);
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate extern void _fp_unpack(fp_simd_type *, unpacked *, uint_t, enum fp_op_type);
91*7c478bd9Sstevel@tonic-gate extern void _fp_pack(fp_simd_type *, unpacked *, uint_t, enum fp_op_type);
92*7c478bd9Sstevel@tonic-gate extern void _fp_unpack_word(fp_simd_type *, uint32_t *, uint_t);
93*7c478bd9Sstevel@tonic-gate extern void _fp_pack_word(fp_simd_type *, uint32_t *, uint_t);
94*7c478bd9Sstevel@tonic-gate extern void _fp_unpack_extword(fp_simd_type *, uint64_t *, uint_t);
95*7c478bd9Sstevel@tonic-gate extern void _fp_pack_extword(fp_simd_type *, uint64_t *, uint_t);
96*7c478bd9Sstevel@tonic-gate extern enum ftt_type fmovcc(fp_simd_type *, fp_inst_type, fsr_type *);
97*7c478bd9Sstevel@tonic-gate extern enum ftt_type fmovr(fp_simd_type *, fp_inst_type);
98*7c478bd9Sstevel@tonic-gate extern enum ftt_type movcc(fp_simd_type *, fp_inst_type, struct regs *,
99*7c478bd9Sstevel@tonic-gate 				void *, kfpu_t *);
100*7c478bd9Sstevel@tonic-gate extern enum ftt_type fldst(fp_simd_type *, fp_inst_type, struct regs *,
101*7c478bd9Sstevel@tonic-gate 				void *);
102*7c478bd9Sstevel@tonic-gate extern void fpu_normalize(unpacked *);
103*7c478bd9Sstevel@tonic-gate extern void fpu_rightshift(unpacked *, int);
104*7c478bd9Sstevel@tonic-gate extern void fpu_set_exception(fp_simd_type *, enum fp_exception_type);
105*7c478bd9Sstevel@tonic-gate extern void fpu_error_nan(fp_simd_type *, unpacked *);
106*7c478bd9Sstevel@tonic-gate extern void unpacksingle(fp_simd_type *, unpacked *, single_type);
107*7c478bd9Sstevel@tonic-gate extern void unpackdouble(fp_simd_type *, unpacked *, double_type, uint_t);
108*7c478bd9Sstevel@tonic-gate extern uint_t fpu_add3wc(uint_t *, uint_t, uint_t, uint_t);
109*7c478bd9Sstevel@tonic-gate extern uint_t fpu_sub3wc(uint_t *, uint_t, uint_t, uint_t);
110*7c478bd9Sstevel@tonic-gate extern uint_t fpu_neg2wc(uint_t *, uint_t, uint_t);
111*7c478bd9Sstevel@tonic-gate extern int fpu_cmpli(uint_t *, uint_t *, int);
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate /* extern void _fp_product(uint_t, uint_t, uint_t *); */
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate extern enum fcc_type _fp_compare(fp_simd_type *, unpacked *, unpacked *, int);
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate extern void _fp_add(fp_simd_type *, unpacked *, unpacked *, unpacked *);
118*7c478bd9Sstevel@tonic-gate extern void _fp_sub(fp_simd_type *, unpacked *, unpacked *, unpacked *);
119*7c478bd9Sstevel@tonic-gate extern void _fp_mul(fp_simd_type *, unpacked *, unpacked *, unpacked *);
120*7c478bd9Sstevel@tonic-gate extern void _fp_div(fp_simd_type *, unpacked *, unpacked *, unpacked *);
121*7c478bd9Sstevel@tonic-gate extern void _fp_sqrt(fp_simd_type *, unpacked *, unpacked *);
122*7c478bd9Sstevel@tonic-gate 
123*7c478bd9Sstevel@tonic-gate extern enum ftt_type	_fp_write_word(uint32_t *, uint32_t, fp_simd_type *);
124*7c478bd9Sstevel@tonic-gate extern enum ftt_type	_fp_read_word(const uint32_t *, uint32_t *,
125*7c478bd9Sstevel@tonic-gate 					fp_simd_type *);
126*7c478bd9Sstevel@tonic-gate extern enum ftt_type	_fp_read_inst(const uint32_t *, uint32_t *,
127*7c478bd9Sstevel@tonic-gate 					fp_simd_type *);
128*7c478bd9Sstevel@tonic-gate extern enum ftt_type	_fp_write_extword(uint64_t *, uint64_t, fp_simd_type *);
129*7c478bd9Sstevel@tonic-gate extern enum ftt_type	_fp_read_extword(const uint64_t *, uint64_t *,
130*7c478bd9Sstevel@tonic-gate 					fp_simd_type *);
131*7c478bd9Sstevel@tonic-gate extern enum ftt_type	read_iureg(fp_simd_type *, uint_t, struct regs *,
132*7c478bd9Sstevel@tonic-gate 					void *, uint64_t *);
133*7c478bd9Sstevel@tonic-gate extern enum ftt_type	write_iureg(fp_simd_type *, uint_t, struct regs *,
134*7c478bd9Sstevel@tonic-gate 					void *, uint64_t *);
135*7c478bd9Sstevel@tonic-gate #endif  /* _KERNEL */
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
138*7c478bd9Sstevel@tonic-gate }
139*7c478bd9Sstevel@tonic-gate #endif
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_FPU_GLOBALS_H */
142