1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef __FPOPCODE_H__
24#define __FPOPCODE_H__
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#define BIT_PREINDEX 0x01000000
186#define BIT_UP 0x00800000
187#define BIT_WRITE_BACK 0x00200000
188#define BIT_LOAD 0x00100000
189
190
191#define MASK_CPDT 0x0c000000
192#define MASK_OFFSET 0x000000ff
193#define MASK_TRANSFER_LENGTH 0x00408000
194#define MASK_REGISTER_COUNT MASK_TRANSFER_LENGTH
195#define MASK_COPROCESSOR 0x00000f00
196
197
198#define TRANSFER_SINGLE 0x00000000
199#define TRANSFER_DOUBLE 0x00008000
200#define TRANSFER_EXTENDED 0x00400000
201#define TRANSFER_PACKED MASK_TRANSFER_LENGTH
202
203
204#define getCoprocessorNumber(opcode) ((opcode & MASK_COPROCESSOR) >> 8)
205
206
207#define getOffset(opcode) (opcode & MASK_OFFSET)
208
209
210#define TEST_OPCODE(opcode,mask) (((opcode) & (mask)) == (mask))
211
212#define LOAD_OP(opcode) TEST_OPCODE((opcode),MASK_CPDT | BIT_LOAD)
213#define STORE_OP(opcode) ((opcode & (MASK_CPDT | BIT_LOAD)) == MASK_CPDT)
214
215#define LDF_OP(opcode) (LOAD_OP(opcode) && (getCoprocessorNumber(opcode) == 1))
216#define LFM_OP(opcode) (LOAD_OP(opcode) && (getCoprocessorNumber(opcode) == 2))
217#define STF_OP(opcode) (STORE_OP(opcode) && (getCoprocessorNumber(opcode) == 1))
218#define SFM_OP(opcode) (STORE_OP(opcode) && (getCoprocessorNumber(opcode) == 2))
219
220#define PREINDEXED(opcode) ((opcode & BIT_PREINDEX) != 0)
221#define POSTINDEXED(opcode) ((opcode & BIT_PREINDEX) == 0)
222#define BIT_UP_SET(opcode) ((opcode & BIT_UP) != 0)
223#define BIT_UP_CLEAR(opcode) ((opcode & BIT_DOWN) == 0)
224#define WRITE_BACK(opcode) ((opcode & BIT_WRITE_BACK) != 0)
225#define LOAD(opcode) ((opcode & BIT_LOAD) != 0)
226#define STORE(opcode) ((opcode & BIT_LOAD) == 0)
227
228
229
230
231
232
233
234#define BIT_MONADIC 0x00008000
235#define BIT_CONSTANT 0x00000008
236
237#define CONSTANT_FM(opcode) ((opcode & BIT_CONSTANT) != 0)
238#define MONADIC_INSTRUCTION(opcode) ((opcode & BIT_MONADIC) != 0)
239
240
241#define MASK_CPDO 0x0e000000
242#define MASK_ARITHMETIC_OPCODE 0x00f08000
243#define MASK_DESTINATION_SIZE 0x00080080
244
245
246#define ADF_CODE 0x00000000
247#define MUF_CODE 0x00100000
248#define SUF_CODE 0x00200000
249#define RSF_CODE 0x00300000
250#define DVF_CODE 0x00400000
251#define RDF_CODE 0x00500000
252#define POW_CODE 0x00600000
253#define RPW_CODE 0x00700000
254#define RMF_CODE 0x00800000
255#define FML_CODE 0x00900000
256#define FDV_CODE 0x00a00000
257#define FRD_CODE 0x00b00000
258#define POL_CODE 0x00c00000
259
260
261
262
263
264#define MVF_CODE 0x00008000
265#define MNF_CODE 0x00108000
266#define ABS_CODE 0x00208000
267#define RND_CODE 0x00308000
268#define SQT_CODE 0x00408000
269#define LOG_CODE 0x00508000
270#define LGN_CODE 0x00608000
271#define EXP_CODE 0x00708000
272#define SIN_CODE 0x00808000
273#define COS_CODE 0x00908000
274#define TAN_CODE 0x00a08000
275#define ASN_CODE 0x00b08000
276#define ACS_CODE 0x00c08000
277#define ATN_CODE 0x00d08000
278#define URD_CODE 0x00e08000
279#define NRM_CODE 0x00f08000
280
281
282
283
284
285
286
287#define MASK_CPRT 0x0e000010
288#define MASK_CPRT_CODE 0x00f00000
289#define FLT_CODE 0x00000000
290#define FIX_CODE 0x00100000
291#define WFS_CODE 0x00200000
292#define RFS_CODE 0x00300000
293#define WFC_CODE 0x00400000
294#define RFC_CODE 0x00500000
295#define CMF_CODE 0x00900000
296#define CNF_CODE 0x00b00000
297#define CMFE_CODE 0x00d00000
298#define CNFE_CODE 0x00f00000
299
300
301
302
303
304
305
306
307#define MASK_Rd 0x0000f000
308#define MASK_Rn 0x000f0000
309#define MASK_Fd 0x00007000
310#define MASK_Fm 0x00000007
311#define MASK_Fn 0x00070000
312
313
314#define CC_MASK 0xf0000000
315#define CC_NEGATIVE 0x80000000
316#define CC_ZERO 0x40000000
317#define CC_CARRY 0x20000000
318#define CC_OVERFLOW 0x10000000
319#define CC_EQ 0x00000000
320#define CC_NE 0x10000000
321#define CC_CS 0x20000000
322#define CC_HS CC_CS
323#define CC_CC 0x30000000
324#define CC_LO CC_CC
325#define CC_MI 0x40000000
326#define CC_PL 0x50000000
327#define CC_VS 0x60000000
328#define CC_VC 0x70000000
329#define CC_HI 0x80000000
330#define CC_LS 0x90000000
331#define CC_GE 0xa0000000
332#define CC_LT 0xb0000000
333#define CC_GT 0xc0000000
334#define CC_LE 0xd0000000
335#define CC_AL 0xe0000000
336#define CC_NV 0xf0000000
337
338
339#define MASK_ROUNDING_MODE 0x00000060
340#define ROUND_TO_NEAREST 0x00000000
341#define ROUND_TO_PLUS_INFINITY 0x00000020
342#define ROUND_TO_MINUS_INFINITY 0x00000040
343#define ROUND_TO_ZERO 0x00000060
344
345#define MASK_ROUNDING_PRECISION 0x00080080
346#define ROUND_SINGLE 0x00000000
347#define ROUND_DOUBLE 0x00000080
348#define ROUND_EXTENDED 0x00080000
349
350
351#define getCondition(opcode) (opcode >> 28)
352
353
354#define getRn(opcode) ((opcode & MASK_Rn) >> 16)
355
356
357#define getFd(opcode) ((opcode & MASK_Fd) >> 12)
358
359
360#define getFn(opcode) ((opcode & MASK_Fn) >> 16)
361
362
363#define getFm(opcode) (opcode & MASK_Fm)
364
365
366#define getRd(opcode) ((opcode & MASK_Rd) >> 12)
367
368
369#define getRoundingMode(opcode) ((opcode & MASK_ROUNDING_MODE) >> 5)
370
371#ifdef CONFIG_FPE_NWFPE_XP
372static inline floatx80 __pure getExtendedConstant(const unsigned int nIndex)
373{
374 extern const floatx80 floatx80Constant[];
375 return floatx80Constant[nIndex];
376}
377#endif
378
379static inline float64 __pure getDoubleConstant(const unsigned int nIndex)
380{
381 extern const float64 float64Constant[];
382 return float64Constant[nIndex];
383}
384
385static inline float32 __pure getSingleConstant(const unsigned int nIndex)
386{
387 extern const float32 float32Constant[];
388 return float32Constant[nIndex];
389}
390
391static inline unsigned int getTransferLength(const unsigned int opcode)
392{
393 unsigned int nRc;
394
395 switch (opcode & MASK_TRANSFER_LENGTH) {
396 case 0x00000000:
397 nRc = 1;
398 break;
399 case 0x00008000:
400 nRc = 2;
401 break;
402 case 0x00400000:
403 nRc = 3;
404 break;
405 default:
406 nRc = 0;
407 }
408
409 return (nRc);
410}
411
412static inline unsigned int getRegisterCount(const unsigned int opcode)
413{
414 unsigned int nRc;
415
416 switch (opcode & MASK_REGISTER_COUNT) {
417 case 0x00000000:
418 nRc = 4;
419 break;
420 case 0x00008000:
421 nRc = 1;
422 break;
423 case 0x00400000:
424 nRc = 2;
425 break;
426 case 0x00408000:
427 nRc = 3;
428 break;
429 default:
430 nRc = 0;
431 }
432
433 return (nRc);
434}
435
436static inline unsigned int getRoundingPrecision(const unsigned int opcode)
437{
438 unsigned int nRc;
439
440 switch (opcode & MASK_ROUNDING_PRECISION) {
441 case 0x00000000:
442 nRc = 1;
443 break;
444 case 0x00000080:
445 nRc = 2;
446 break;
447 case 0x00080000:
448 nRc = 3;
449 break;
450 default:
451 nRc = 0;
452 }
453
454 return (nRc);
455}
456
457static inline unsigned int getDestinationSize(const unsigned int opcode)
458{
459 unsigned int nRc;
460
461 switch (opcode & MASK_DESTINATION_SIZE) {
462 case 0x00000000:
463 nRc = typeSingle;
464 break;
465 case 0x00000080:
466 nRc = typeDouble;
467 break;
468 case 0x00080000:
469 nRc = typeExtended;
470 break;
471 default:
472 nRc = typeNone;
473 }
474
475 return (nRc);
476}
477
478extern const float64 float64Constant[];
479extern const float32 float32Constant[];
480
481#endif
482