fpu.h
7.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#ifndef __SYS_FPU_H__
#define __SYS_FPU_H__
/**************************************************************************
* *
* Copyright (C) 1990-1992 Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
/* ------------------------------------------------------------------ */
/* | Copyright Unpublished, MIPS Computer Systems, Inc. All Rights | */
/* | Reserved. This software contains proprietary and confidential | */
/* | information of MIPS and its suppliers. Use, disclosure or | */
/* | reproduction is prohibited without the prior express written | */
/* | consent of MIPS. | */
/* ------------------------------------------------------------------ */
/* %Q% %I% %M% */
#ident "$Revision: 1.1 $"
/*
* fpu.h -- fpu specific defines
*/
#ifdef _LANGUAGE_C
/*
* Structure and constant definisions for floating-point instructions.
*/
union fpu_instr {
unsigned int instr;
struct {
#ifdef _MIPSEB
unsigned op : 6;
unsigned base : 5;
unsigned rt : 5;
signed immed : 16;
#endif /* _MIPSEB */
#ifdef _MIPSEL
signed immed : 16;
unsigned rt : 5;
unsigned base : 5;
unsigned op : 6;
#endif /* _MIPSEL */
} itype;
struct {
#ifdef _MIPSEB
unsigned op : 6;
unsigned sub : 5;
unsigned rt : 5;
unsigned rs : 5;
unsigned : 11;
#endif /* _MIPSEB */
#ifdef _MIPSEL
unsigned : 11;
unsigned rs : 5;
unsigned rt : 5;
unsigned sub : 5;
unsigned op : 6;
#endif /* _MIPSEL */
} mtype;
struct {
#ifdef _MIPSEB
unsigned op : 6;
unsigned one : 1;
unsigned fmt : 4;
unsigned rt : 5;
unsigned rs : 5;
unsigned rd : 5;
unsigned func : 6;
#endif /* _MIPSEB */
#ifdef _MIPSEL
unsigned func : 6;
unsigned rd : 5;
unsigned rs : 5;
unsigned rt : 5;
unsigned fmt : 4;
unsigned one : 1;
unsigned op : 6;
#endif /* _MIPSEL */
} rtype;
struct {
#ifdef _MIPSEB
unsigned op : 6;
unsigned rr : 5;
unsigned rt : 5;
unsigned rs : 5;
unsigned rd : 5;
unsigned func : 3;
unsigned fmt : 3;
#endif /* _MIPSEB */
#ifdef _MIPSEL
unsigned fmt : 3;
unsigned func : 3;
unsigned rd : 5;
unsigned rs : 5;
unsigned rt : 5;
unsigned rr : 5;
unsigned op : 6;
#endif /* _MIPSEL */
} r4type;
};
#endif /* _LANGUAGE_C */
#define FMT_SINGLE 0
#define FMT_DOUBLE 1
#define FMT_EXTENDED 2
#define FMT_QUAD 3
#define FMT_WORD 4
#define FMT_LONGWORD 5
#define FMT_MAX 5
#define FUNC_ADD 0
#define FUNC_SUB 1
#define FUNC_MUL 2
#define FUNC_DIV 3
#define FUNC_SQRT 4
#define FUNC_ABS 5
#define FUNC_MOV 6
#define FUNC_NEG 7
#define FUNC_ROUNDL 0x08
#define FUNC_TRUNCL 0x09
#define FUNC_CEILL 0x0a
#define FUNC_FLOORL 0x0b
#define FUNC_ROUND 0x0c
#define FUNC_TRUNC 0x0d
#define FUNC_CEIL 0x0e
#define FUNC_FLOOR 0x0f
#define FUNC_RECIP 0x19
#define FUNC_RSQRT 0x1a
#define FUNC_CVTS 0x20
#define FUNC_CVTD 0x21
#define FUNC_CVTE 0x22
#define FUNC_CVTQ 0x23
#define FUNC_CVTW 0x24
#define FUNC_CVTL 0x25
/*
* op codes for madd, msub, nmadd, nmsub; notice that these are
* the same as some of the other floating point op codes, however
* they are COP1X functions. To distinguish them in code, do
* something like adding 64 to the op code. Then you can do
* a switch statement with cases like
* case FUNC_MADD+64:
*/
#define FUNC_MADD 0x4
#define FUNC_MSUB 0x5
#define FUNC_NMADD 0x6
#define FUNC_NMSUB 0x7
/*
* The func field of floating-point compare opcodes are FUNC_FC with
* some combination of conditions (COND_*).
*/
#define FUNC_FC 0x30
#define COND_UN_MASK 0x1
#define COND_EQ_MASK 0x2
#define COND_LT_MASK 0x4
#define COND_IN_MASK 0x8
/*
* The _MASK's are used to get a the specified field after it has been
* shifted by _SHIFT and then bit patterns above can be used to test
* the field. These are useful in assembly code.
*/
#define FPU_BASE_SHIFT 21
#define FPU_BASE_MASK 0x1f
#define FPU_FMT_SHIFT 21
#define FPU_FMT_MASK 0xf
#define FPU_RT_SHIFT 16
#define FPU_RT_MASK 0x1f
#define FPU_RT_FPRMASK 0x1e
#define FPU_RS_SHIFT 11
#define FPU_RS_MASK 0x1f
#define FPU_RS_FPRMASK 0x1e
#define FPU_RD_SHIFT 6
#define FPU_RD_MASK 0x1f
#define FPU_RD_FPRMASK 0x1e
#ifdef _LANGUAGE_C
/*
* These functions are used to get and set the floating-point control
* registers. They are defined in the library module fp_control.s
*/
extern unsigned int get_fpc_csr(void);
extern unsigned int set_fpc_csr(unsigned int);
extern unsigned int get_fpc_irr(void);
extern unsigned int get_fpc_eir(void);
/*
* Structure and constant definisions for the floating-point control
* implementation and revision register (fpc_irr).
*/
union fpc_irr {
unsigned int fi_word;
struct {
#ifdef _MIPSEB
unsigned reserved : 16;
unsigned implementation : 8;
unsigned revision : 8;
#endif /* _MIPSEB */
#ifdef _MIPSEL
unsigned revision : 8;
unsigned implementation : 8;
unsigned reserved : 16;
#endif /* _MIPSEL */
} fi_struct;
};
#endif /* _LANGUAGE_C */
/*
* Constants for the implementation fieid of the fpc_irr structure for the
* known implementations.
*/
#define IMPLEMENTATION_NONE 0 /* software */
#define IMPLEMENTATION_R2360 1 /* board */
#define IMPLEMENTATION_R2010 2 /* chip */
/*
* The constant IRR_IMP_MASK is to get at the implementation fieid of the
* implementation and revision register. The other constants (IRR_IMP_*)
* are constants for the known implementations.
*/
#define IRR_IMP_MASK 0x0000ff00
#define IRR_IMP_NONE 0x00000000
#define IRR_IMP_R2360 0x00000100
#define IRR_IMP_R2010 0x00000200
/*
* Structure and constant definisions for the floating-point control
* control and status register (fpc_csr).
*/
#ifdef _LANGUAGE_C
union fpc_csr {
unsigned int fc_word;
struct {
#ifdef _MIPSEB
unsigned fcc : 7; /* only used for mips4 */
unsigned flush : 1;
unsigned condition : 1;
unsigned reserved1 : 5;
unsigned ex_unimplemented : 1;
unsigned ex_invalid : 1;
unsigned ex_divide0 : 1;
unsigned ex_overflow : 1;
unsigned ex_underflow : 1;
unsigned ex_inexact : 1;
unsigned en_invalid : 1;
unsigned en_divide0 : 1;
unsigned en_overflow : 1;
unsigned en_underflow : 1;
unsigned en_inexact : 1;
unsigned se_invalid : 1;
unsigned se_divide0 : 1;
unsigned se_overflow : 1;
unsigned se_underflow : 1;
unsigned se_inexact : 1;
unsigned rounding_mode : 2;
#endif /* _MIPSEB */
#ifdef _MIPSEL
unsigned rounding_mode : 2;
unsigned se_inexact : 1;
unsigned se_underflow : 1;
unsigned se_overflow : 1;
unsigned se_divide0 : 1;
unsigned se_invalid : 1;
unsigned en_inexact : 1;
unsigned en_underflow : 1;
unsigned en_overflow : 1;
unsigned en_divide0 : 1;
unsigned en_invalid : 1;
unsigned ex_inexact : 1;
unsigned ex_underflow : 1;
unsigned ex_overflow : 1;
unsigned ex_divide0 : 1;
unsigned ex_invalid : 1;
unsigned ex_unimplemented : 1;
unsigned reserved1 : 5;
unsigned condition : 1;
unsigned flush : 1;
unsigned fcc : 7; /* only used for mips4 */
#endif /* _MIPSEL */
} fc_struct;
};
#endif /* _LANGUAGE_C */
/*
* Constants for the rounding_mode field of the fpc_csr
*/
#define ROUND_TO_NEAREST 0
#define ROUND_TO_ZERO 1
#define ROUND_TO_PLUS_INFINITY 2
#define ROUND_TO_MINUS_INFINITY 3
/* Masks to get at the unimplemented exception */
#define FPCSR_FLUSH_ZERO 0x01000000
#define FPCSR_UNIMP 0x00020000
#define FPCSR_EXCEPTIONS 0x0003f000 /* all exceptions */
#define FPCSR_ENABLES 0x00000f80
#define FPCSR_FLAGS 0x0000007c
#ifdef _LANGUAGE_ASSEMBLY
/*
* Assembly register names for the floating-point control registers.
*/
#define fpc_irr $0
#define fpc_led $0
#define fpc_eir $30
#define fpc_csr $31
#endif /* _LANGUAGE_ASSEMBLY */
#endif /* __SYS_FPU_H__ */