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